File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -2,10 +2,12 @@ import dedent from "ts-dedent";
22
33export function getAuthPlugin ( ) {
44 return dedent /* ts */ `
5- import { validateAndParseInitData } from "@gramio/init-data";
6- import { Elysia } from "elysia";
7- import { config } from "../../ config.ts";
5+ import { validateAndParseInitData, signInitData, getBotTokenSecretKey } from "@gramio/init-data";
6+ import { Elysia, t } from "elysia";
7+ import { config } from "../config.ts";
88
9+ const secretKey = getBotTokenSecretKey(config.BOT_TOKEN);
10+
911 export const authElysia = new Elysia({
1012 name: "auth",
1113 })
@@ -33,7 +35,7 @@ export function getAuthPlugin() {
3335 .resolve(({ headers, error }) => {
3436 const result = validateAndParseInitData(
3537 headers["x-init-data"],
36- config.BOT_TOKEN
38+ secretKey
3739 );
3840 if (!result || !result.user)
3941 return error("Unauthorized", "UNAUTHORIZED");
You can’t perform that action at this time.
0 commit comments