-
Notifications
You must be signed in to change notification settings - Fork 368
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Telegram Application
Telegram for macOS
Describe the Bug
@telegram-apps/init-data-node/web does not support non-Node.js environment as expected from the documentation.
The reason appears to be that it uses Buffer, a Node.js API in its code.
To Reproduce
I'm using Convex, which has a non-Node.js environment that appears to be supported by Deno.
Calling validate() from the non-Node.js environment yields an error of [ReferenceError: Buffer is not defined].
Here's the sample code:
import { validate } from "@telegram-apps/init-data-node/web";
import { v } from "convex/values";
import { action } from "./_generated/server";
export const verify = action({
args: {
initData: v.string(),
},
handler: async (_ctx, { initData }) => {
try {
await validate(initData, process.env.TELEGRAM_BOT_TOKEN!);
return { success: true };
} catch (e) {
console.log(e);
return { success: false };
}
},
});Expected Behavior
Expect the sample code to work without adding "use node"; at the beginning of the file, which will opt into using Node.js environment.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working