@xbibzlibrary/telebibz 0.1.11 → 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.id.md +2 -2
- package/README.md +1 -1
- package/README.zh-CN.md +3 -3
- package/dist/src/api/client.d.ts +1 -1
- package/dist/src/api/client.d.ts.map +1 -1
- package/dist/src/api/client.js +13 -1
- package/dist/src/api/client.js.map +1 -1
- package/dist/src/api/transport.d.ts.map +1 -1
- package/dist/src/api/transport.js +45 -4
- package/dist/src/api/transport.js.map +1 -1
- package/dist/src/core/bot.d.ts.map +1 -1
- package/dist/src/core/bot.js +7 -1
- package/dist/src/core/bot.js.map +1 -1
- package/dist/src/core/events.d.ts.map +1 -1
- package/dist/src/core/events.js +13 -2
- package/dist/src/core/events.js.map +1 -1
- package/dist/src/observability/logger.d.ts.map +1 -1
- package/dist/src/observability/logger.js +17 -1
- package/dist/src/observability/logger.js.map +1 -1
- package/dist/src/plugins/plugin.d.ts.map +1 -1
- package/dist/src/plugins/plugin.js +22 -1
- package/dist/src/plugins/plugin.js.map +1 -1
- package/dist/src/queue/queue.d.ts.map +1 -1
- package/dist/src/queue/queue.js +11 -4
- package/dist/src/queue/queue.js.map +1 -1
- package/dist/src/state/conversation.d.ts +1 -0
- package/dist/src/state/conversation.d.ts.map +1 -1
- package/dist/src/state/conversation.js +12 -3
- package/dist/src/state/conversation.js.map +1 -1
- package/dist/src/storage/storage.js +1 -1
- package/dist/src/storage/storage.js.map +1 -1
- package/dist/src/telegram-features.d.ts.map +1 -1
- package/dist/src/telegram-features.js +2 -0
- package/dist/src/telegram-features.js.map +1 -1
- package/dist/src/webhook/handler.d.ts.map +1 -1
- package/dist/src/webhook/handler.js +10 -1
- package/dist/src/webhook/handler.js.map +1 -1
- package/dist-cjs/src/api/client.js +13 -1
- package/dist-cjs/src/api/transport.js +45 -4
- package/dist-cjs/src/core/bot.js +7 -1
- package/dist-cjs/src/core/events.js +13 -2
- package/dist-cjs/src/observability/logger.js +17 -1
- package/dist-cjs/src/plugins/plugin.js +22 -1
- package/dist-cjs/src/queue/queue.js +11 -4
- package/dist-cjs/src/state/conversation.js +12 -3
- package/dist-cjs/src/storage/storage.js +1 -1
- package/dist-cjs/src/telegram-features.js +2 -0
- package/dist-cjs/src/webhook/handler.js +10 -1
- package/docs/API.id.md +3 -3
- package/docs/API.md +3 -3
- package/docs/API.zh-CN.md +3 -3
- package/package.json +1 -1
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createWebhookHandler = createWebhookHandler;
|
|
4
|
+
const node_crypto_1 = require("node:crypto");
|
|
4
5
|
function createWebhookHandler(bot, options = {}) {
|
|
5
6
|
const maxBodyBytes = options.maxBodyBytes ?? 1_048_576;
|
|
6
7
|
return async (request) => {
|
|
7
8
|
if (request.method !== "POST")
|
|
8
9
|
return new Response("Method Not Allowed", { status: 405, headers: { allow: "POST" } });
|
|
9
|
-
if (options.secretToken && request.headers.get("x-telegram-bot-api-secret-token")
|
|
10
|
+
if (options.secretToken && !secureEqual(request.headers.get("x-telegram-bot-api-secret-token") ?? "", options.secretToken))
|
|
10
11
|
return new Response("Unauthorized", { status: 401 });
|
|
12
|
+
const contentType = request.headers.get("content-type") ?? "";
|
|
13
|
+
if (!/^application\/json(?:\s*;|\s*$)/i.test(contentType))
|
|
14
|
+
return new Response("Unsupported Media Type", { status: 415 });
|
|
11
15
|
const contentLength = Number(request.headers.get("content-length") ?? 0);
|
|
12
16
|
if (contentLength > maxBodyBytes)
|
|
13
17
|
return new Response("Payload Too Large", { status: 413 });
|
|
@@ -27,3 +31,8 @@ function createWebhookHandler(bot, options = {}) {
|
|
|
27
31
|
}
|
|
28
32
|
};
|
|
29
33
|
}
|
|
34
|
+
function secureEqual(left, right) {
|
|
35
|
+
const leftBuffer = Buffer.from(left, "utf8");
|
|
36
|
+
const rightBuffer = Buffer.from(right, "utf8");
|
|
37
|
+
return leftBuffer.length === rightBuffer.length && (0, node_crypto_1.timingSafeEqual)(leftBuffer, rightBuffer);
|
|
38
|
+
}
|
package/docs/API.id.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|

|
|
6
6
|
|
|
7
|
-
Dokumen ini adalah referensi API untuk `@xbibzlibrary/telebibz
|
|
7
|
+
Dokumen ini adalah referensi API untuk rilis `@xbibzlibrary/telebibz` yang sedang dipublikasikan. Seluruh signature dan perilaku yang dijelaskan di sini dipetakan dari source TypeScript yang diekspor package. Jika suatu tipe Telegram belum memiliki pemetaan parameter/result khusus, package tetap menyediakan akses runtime melalui API dinamis, tetapi tipe parameternya masih generik.
|
|
8
8
|
|
|
9
9
|
> **Status implementasi.** Dokumentasi ini menjelaskan kemampuan yang tersedia pada rilis saat ini. `JsonFileStorage`, storage Redis/SQL/Mongo berbasis driver, session/conversation berbasis Storage, cron lima field lengkap, `MenuController`, terminal status output branded, structured logging dengan redaction, validasi Web App, `PaymentsClient`, dan declaration `TelegramTypes` sudah tersedia. Core method map tetap khusus untuk inferensi request/result tertentu, sedangkan `api.raw()` tersedia untuk method Telegram berikutnya.
|
|
10
10
|
|
|
@@ -1239,8 +1239,8 @@ interface MenuItem {
|
|
|
1239
1239
|
label: string;
|
|
1240
1240
|
callbackData?: string;
|
|
1241
1241
|
url?: string;
|
|
1242
|
-
visible?: boolean | (() => boolean | Promise<boolean>);
|
|
1243
|
-
permission?: string;
|
|
1242
|
+
visible?: boolean | ((context: MenuContext, item: MenuItem) => boolean | Promise<boolean>);
|
|
1243
|
+
permission?: string | ((context: MenuContext, item: MenuItem) => boolean | Promise<boolean>);
|
|
1244
1244
|
}
|
|
1245
1245
|
```
|
|
1246
1246
|
|
package/docs/API.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|

|
|
5
5
|
|
|
6
|
-
This document is the API reference for `@xbibzlibrary/telebibz
|
|
6
|
+
This document is the API reference for the current published `@xbibzlibrary/telebibz` release. All signatures and behaviors described here are mapped from the package's exported TypeScript source. If a Telegram type does not have a specific parameter/result mapping, the package still provides runtime access via a dynamic API, but the parameter types remain generic.
|
|
7
7
|
|
|
8
8
|
> **Implementation status.** This documentation describes the capabilities available in the current release. `JsonFileStorage`, driver-based Redis/SQL/Mongo storage, storage-backed sessions/conversations, full five-field cron, `MenuController`, terminal branding, structured redacted logging, Web App validation, PaymentsClient, and vendored `TelegramTypes` declarations are included. The core method map remains specialized for selected request/result inference, while `api.raw()` remains available for future Telegram methods.
|
|
9
9
|
|
|
@@ -1257,8 +1257,8 @@ interface MenuItem {
|
|
|
1257
1257
|
label: string;
|
|
1258
1258
|
callbackData?: string;
|
|
1259
1259
|
url?: string;
|
|
1260
|
-
visible?: boolean | (() => boolean | Promise<boolean>);
|
|
1261
|
-
permission?: string;
|
|
1260
|
+
visible?: boolean | ((context: MenuContext, item: MenuItem) => boolean | Promise<boolean>);
|
|
1261
|
+
permission?: string | ((context: MenuContext, item: MenuItem) => boolean | Promise<boolean>);
|
|
1262
1262
|
}
|
|
1263
1263
|
```
|
|
1264
1264
|
|
package/docs/API.zh-CN.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|

|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
本文件是当前发布的 `@xbibzlibrary/telebibz` API 参考。此处描述的所有签名和行为均映射自该包导出的 TypeScript 源代码。如果某个 Telegram 类型尚未有特定的参数/结果映射,该包仍通过动态 API 提供运行时访问,但其参数类型仍为通用类型。
|
|
8
8
|
|
|
9
9
|
> **实现状态。** 本文档说明当前版本中可用的功能。`JsonFileStorage`、基于 driver 的 Redis/SQL/Mongo storage、基于 Storage 的 session/conversation、完整五字段 cron、`MenuController`、带 branding 的 terminal status output、带 redaction 的 structured logging、Web App 验证、`PaymentsClient` 和 `TelegramTypes` declaration 均已提供。core method map 仍主要为特定 request/result inference 提供类型,未来 Telegram method 可通过 `api.raw()` 访问。
|
|
10
10
|
|
|
@@ -1233,8 +1233,8 @@ interface MenuItem {
|
|
|
1233
1233
|
label: string;
|
|
1234
1234
|
callbackData?: string;
|
|
1235
1235
|
url?: string;
|
|
1236
|
-
visible?: boolean | (() => boolean | Promise<boolean>);
|
|
1237
|
-
permission?: string;
|
|
1236
|
+
visible?: boolean | ((context: MenuContext, item: MenuItem) => boolean | Promise<boolean>);
|
|
1237
|
+
permission?: string | ((context: MenuContext, item: MenuItem) => boolean | Promise<boolean>);
|
|
1238
1238
|
}
|
|
1239
1239
|
```
|
|
1240
1240
|
|
package/package.json
CHANGED