Socket
Socket
Sign inDemoInstall

@grammyjs/files

Package Overview
Dependencies
1
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.4 to 1.1.0

4

out/deps.node.d.ts
/// <reference types="node" />
import * as fs from "fs";
export { Api, Context, RawApi, Transformer } from "grammy";
export { File } from "@grammyjs/types";
export { Api, Context, type RawApi, type Transformer } from "grammy";
export { type File } from "grammy/types";
export { isAbsolute as isAbsolutePath } from "path";

@@ -6,0 +6,0 @@ export declare const createTempFile: () => Promise<string>;

@@ -40,2 +40,2 @@ import { File } from "./deps.node.js";

}
export declare function installFileMethods(file: File, linkBuilder: (path: string) => string): void;
export declare function installFileMethods(file: File, linkBuilder: (path: string) => string | URL): void;

@@ -13,3 +13,8 @@ "use strict";

}
return (0, deps_node_js_1.isAbsolutePath)(path) ? path : linkBuilder(path);
if ((0, deps_node_js_1.isAbsolutePath)(path))
return path;
const link = linkBuilder(path);
if (link instanceof URL)
return link.href;
return link;
},

@@ -16,0 +21,0 @@ download: async (path) => {

@@ -35,2 +35,15 @@ import { Api, Context, RawApi, Transformer } from "./deps.node.js";

/**
* Specifies whether to use the [test
* environment](https://core.telegram.org/bots/webapps#using-bots-in-the-test-environment).
* Can be either `"prod"` (default) or `"test"`.
*
* The testing infrastructure is separate from the regular production
* infrastructure. No chats, accounts, or other data is shared between them.
* If you set this option to `"test"`, you will need to make your Telegram
* client connect to the testing data centers of Telegram, register your
* phone number again, open a new chat with @BotFather, and create a
* separate bot.
*/
environment?: "prod" | "test";
/**
* URL builder function for downloading files. Can be used to modify which

@@ -42,5 +55,6 @@ * API server should be called when downloading files.

* @param path The `file_path` value that identifies the file
* @param env The value that was passed in `environment`, or its default value
* @returns The URL that will be fetched during the download
*/
buildFileUrl?: (root: string, token: string, path: string) => string;
buildFileUrl?: (root: string, token: string, method: string, env: "prod" | "test") => string | URL;
}

@@ -60,3 +74,3 @@ /**

* Check out [the official plugin
* documentation](https://grammy.dev/plugins/files.html) on the grammY webiste.
* documentation](https://grammy.dev/plugins/files.html) on the grammY website.
*

@@ -63,0 +77,0 @@ * @param token bot token, use `bot.token`

@@ -18,3 +18,3 @@ "use strict";

* Check out [the official plugin
* documentation](https://grammy.dev/plugins/files.html) on the grammY webiste.
* documentation](https://grammy.dev/plugins/files.html) on the grammY website.
*

@@ -25,6 +25,7 @@ * @param token bot token, use `bot.token`

function hydrateFiles(token, options) {
var _a, _b;
var _a, _b, _c;
const root = (_a = options === null || options === void 0 ? void 0 : options.apiRoot) !== null && _a !== void 0 ? _a : "https://api.telegram.org";
const buildFileUrl = (_b = options === null || options === void 0 ? void 0 : options.buildFileUrl) !== null && _b !== void 0 ? _b : ((root, token, path) => `${root}/file/bot${token}/${path}`);
const buildLink = (path) => buildFileUrl(root, token, path);
const environment = (_b = options === null || options === void 0 ? void 0 : options.environment) !== null && _b !== void 0 ? _b : "prod";
const buildFileUrl = (_c = options === null || options === void 0 ? void 0 : options.buildFileUrl) !== null && _c !== void 0 ? _c : ((root, token, path) => `${root}/file/bot${token}/${path}`);
const buildLink = (path) => buildFileUrl(root, token, path, environment);
const t = async (prev, method, payload, signal) => {

@@ -31,0 +32,0 @@ const res = await prev(method, payload, signal);

{
"name": "@grammyjs/files",
"description": "Files plugin for grammY",
"version": "1.0.4",
"version": "1.1.0",
"author": "KnorpelSenf",

@@ -19,2 +19,3 @@ "license": "MIT",

"scripts": {
"prepare": "npm run build",
"build": "deno2node tsconfig.json",

@@ -29,4 +30,3 @@ "cache": "deno cache src/mod.ts",

"devDependencies": {
"@grammyjs/types": "^2.7.0",
"@types/node": "^17.0.24",
"@types/node": "^12.20.55",
"deno2node": "1.3.0"

@@ -33,0 +33,0 @@ },

@@ -9,4 +9,4 @@ # File handling simplified in grammY

```ts
import { Bot, Context } from "grammy";
import { FileFlavor, hydrateFiles } from "@grammyjs/files";
import { Bot, type Context } from "grammy";
import { type FileFlavor, hydrateFiles } from "@grammyjs/files";

@@ -13,0 +13,0 @@ // Transformative API flavor

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc