-
Notifications
You must be signed in to change notification settings - Fork 4
/
sorter.js
36 lines (29 loc) · 1.05 KB
/
sorter.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import url from "url";
import querystring from "querystring";
import fs from "fs";
const Url = "URL HERE!!";
const parsedUrl = url.parse(Url);
const queryParams = querystring.parse(parsedUrl.hash.slice(1));
const tgWebAppData = queryParams.tgWebAppData;
const decodedData = querystring.parse(tgWebAppData);
try {
const user = JSON.parse(decodedData.user);
const details = {
query_id: decodedData.query_id,
user_id: user.id,
first_name: user.first_name,
last_name: user.last_name,
username: user.username,
language_code: user.language_code,
allows_write_to_pm: user.allows_write_to_pm,
auth_date: decodedData.auth_date,
hash: decodedData.hash,
tgWebAppVersion: queryParams.tgWebAppVersion,
tgWebAppPlatform: queryParams.tgWebAppPlatform,
tgWebAppThemeParams: JSON.parse(queryParams.tgWebAppThemeParams),
};
fs.writeFileSync("./auth/credentials.json", JSON.stringify(details, null, 2));
console.log("Details saved to credentials.json");
} catch (error) {
console.error("Error parsing JSON data:", error.message);
}