@mastra/telegram 0.2.0 → 0.2.1-alpha.0
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/dist/index.cjs +7 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -8
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -24200,7 +24200,7 @@ async function setMyCommands(botToken, options, apiBaseUrl = TELEGRAM_API_BASE_U
|
|
|
24200
24200
|
* @see https://core.telegram.org/bots/api#setwebhook
|
|
24201
24201
|
*/
|
|
24202
24202
|
function generateSecretToken() {
|
|
24203
|
-
return (
|
|
24203
|
+
return Buffer.from(globalThis.crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(32))).toString("base64url");
|
|
24204
24204
|
}
|
|
24205
24205
|
//#endregion
|
|
24206
24206
|
//#region src/commands.ts
|
|
@@ -24269,8 +24269,8 @@ function isEncrypted(value) {
|
|
|
24269
24269
|
}
|
|
24270
24270
|
/** Encrypt a UTF-8 string with a per-value random salt + IV. */
|
|
24271
24271
|
function encrypt(plaintext, passphrase) {
|
|
24272
|
-
const salt = (
|
|
24273
|
-
const iv = (
|
|
24272
|
+
const salt = Buffer.from(globalThis.crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(16)));
|
|
24273
|
+
const iv = Buffer.from(globalThis.crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(12)));
|
|
24274
24274
|
const cipher = (0, crypto$1.createCipheriv)("aes-256-gcm", deriveKey(passphrase, salt), iv);
|
|
24275
24275
|
const enc = Buffer.concat([cipher.update(plaintext, "utf8"), cipher.final()]);
|
|
24276
24276
|
const tag = cipher.getAuthTag();
|
|
@@ -24631,11 +24631,11 @@ var TelegramProvider = class {
|
|
|
24631
24631
|
botToken = resolved;
|
|
24632
24632
|
} else botToken = options.botToken ?? this.#config.botToken;
|
|
24633
24633
|
if (!botToken) {
|
|
24634
|
-
const installationId = existing?.id ??
|
|
24634
|
+
const installationId = existing?.id ?? globalThis.crypto.randomUUID();
|
|
24635
24635
|
await store.save({
|
|
24636
24636
|
id: installationId,
|
|
24637
24637
|
agentId,
|
|
24638
|
-
webhookId: existing?.webhookId ??
|
|
24638
|
+
webhookId: existing?.webhookId ?? globalThis.crypto.randomUUID(),
|
|
24639
24639
|
status: "pending",
|
|
24640
24640
|
installedAt: existing?.installedAt ?? /* @__PURE__ */ new Date()
|
|
24641
24641
|
});
|
|
@@ -24658,8 +24658,8 @@ var TelegramProvider = class {
|
|
|
24658
24658
|
const duplicate = (await store.list()).find((i) => i.status === "active" && i.agentId !== agentId && (i.botUserId !== void 0 ? i.botUserId === me.id : i.botToken === botToken));
|
|
24659
24659
|
if (duplicate) throw new Error(`This Telegram bot is already connected to agent "${duplicate.agentId}". Disconnect it before connecting another agent.`);
|
|
24660
24660
|
}
|
|
24661
|
-
const installationId = existing?.id ??
|
|
24662
|
-
const webhookId = existing?.webhookId ??
|
|
24661
|
+
const installationId = existing?.id ?? globalThis.crypto.randomUUID();
|
|
24662
|
+
const webhookId = existing?.webhookId ?? globalThis.crypto.randomUUID();
|
|
24663
24663
|
const webhookUrl = mode === "webhook" ? `${baseUrl}/${PLATFORM}/events/${webhookId}` : void 0;
|
|
24664
24664
|
const commands = normalizeCommands(options.commands ?? this.#config.commands ?? DEFAULT_COMMANDS);
|
|
24665
24665
|
const installation = {
|