This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export interface WebAppUser { | |
| id: number; | |
| is_bot: boolean; | |
| first_name: string; | |
| last_name: string; | |
| username: string; | |
| language_code: string; | |
| photo_url: string; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { createHmac } from 'crypto'; | |
| function isValidSignature(checkString) { | |
| const decoded = decodeURIComponent(checkString) | |
| .split('&') | |
| .map(chunk => chunk.split('=')) | |
| .reduce((accumulator, [key, value]) => ({ ...accumulator, [key]: value }), {}); | |
| const user = JSON.parse(decoded.user); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import axios from "axios"; | |
| import { Auth } from "firebase-admin/auth"; | |
| export const getIdToken = async (auth: Auth, uid: string) => { | |
| const customToken = await auth.createCustomToken(uid); | |
| const res = await axios.post( | |
| `http://localhost:[PORT]/www.googleapis.com/identitytoolkit/v3/relyingparty/verifyCustomToken?key=[KEY]`, | |
| { | |
| token: customToken, | |
| returnSecureToken: true, |