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
-- Token Based API Access for Supabase | |
-- | |
-- How to configure Supabase (https://supabase.com/) to generate and accept API tokens. | |
-- | |
-- (c) 2022 Felix Zedén Yverås | |
-- Provided under the MIT license (https://spdx.org/licenses/MIT.html) | |
-- | |
-- Disclaimer: This file is formatted using pg_format. I'm not happy with the result but | |
-- prefer to follow a tool over going by personal taste. | |
-- |
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
// Bot token | |
const bot_token = '0123456789:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; | |
// https://core.telegram.org/bots/webapps#validating-data-received-via-the-web-app | |
function isValidHash() { | |
// Parse query data | |
const parsedData = Telegram.Utils.urlParseQueryString(Telegram.WebApp.initData) | |
// Get Telegram hash | |
const hash = parsedData.hash |
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 hmac | |
def checkValidateInitData(hash_str, init_data, token, c_str="WebAppData"): | |
""" | |
Validates the data received from the Telegram web app, using the | |
method documented here: | |
https://core.telegram.org/bots/webapps#validating-data-received-via-the-web-app | |
hash_str - the has string passed by the webapp | |
init_data - the query string passed by the webapp |