mirror of
https://github.com/5ime/Tiktok_Signature.git
synced 2025-04-06 04:35:44 +08:00
Merge 47837d0922878aed2b0d01b9f95d6da7be1485f9 into 6c48a5c3865b5fbea9e7c0b029abf1e37607fa84
This commit is contained in:
commit
2878f60925
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
node_modules
|
62
index.js
62
index.js
@ -1,5 +1,5 @@
|
||||
const axios = require('axios');
|
||||
const crypto = require('crypto');
|
||||
const request = require("request");
|
||||
const crypto = require("crypto");
|
||||
const express = require("express");
|
||||
const { sign } = require("./Signer.js");
|
||||
|
||||
@ -26,8 +26,8 @@ app.post("/", async (req, res) => {
|
||||
xbogus: xbogus,
|
||||
mstoken: xbogusToken,
|
||||
ttwid: ttwid,
|
||||
url: newUrl
|
||||
}
|
||||
url: newUrl,
|
||||
},
|
||||
});
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
@ -68,34 +68,56 @@ app.get("/", (req, res) => {
|
||||
});
|
||||
|
||||
function msToken(length) {
|
||||
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||
const characters =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
const randomBytes = crypto.randomBytes(length);
|
||||
return Array.from(randomBytes, byte => characters[byte % characters.length]).join('');
|
||||
return Array.from(
|
||||
randomBytes,
|
||||
(byte) => characters[byte % characters.length]
|
||||
).join("");
|
||||
}
|
||||
|
||||
async function getTtwid() {
|
||||
try {
|
||||
const url = 'https://ttwid.bytedance.com/ttwid/union/register/';
|
||||
const data = {
|
||||
"region": "cn",
|
||||
"aid": 1768,
|
||||
"needFid": false,
|
||||
"service": "www.ixigua.com",
|
||||
"migrate_info": { "ticket": "", "source": "node" },
|
||||
"cbUrlProtocol": "https",
|
||||
"union": true
|
||||
const url = "https://ttwid.bytedance.com/ttwid/union/register/";
|
||||
const options = {
|
||||
method: "POST",
|
||||
url,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
region: "cn",
|
||||
aid: 1768,
|
||||
needFid: false,
|
||||
service: "www.ixigua.com",
|
||||
migrate_info: {
|
||||
ticket: "",
|
||||
source: "node",
|
||||
},
|
||||
cbUrlProtocol: "https",
|
||||
union: true,
|
||||
}),
|
||||
};
|
||||
const response = await axios.post(url, data, { headers: { 'Content-Type': 'application/json' } });
|
||||
const setCookie = response.headers['set-cookie'];
|
||||
const response = await new Promise((resolve, reject) => {
|
||||
request(options, (error, response, _) => {
|
||||
if (error) {
|
||||
reject("An error has occurred: ", error);
|
||||
} else {
|
||||
resolve(response);
|
||||
}
|
||||
});
|
||||
});
|
||||
const setCookie = await response.headers["set-cookie"];
|
||||
const regex = /ttwid=([^;]+)/;
|
||||
const match = regex.exec(setCookie[0]);
|
||||
return match && match.length > 1 ? match[1] : '';
|
||||
return match && match.length > 1 ? match[1] : "";
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return '';
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
app.listen(80, () => {
|
||||
console.log("Server is running on port 80");
|
||||
});
|
||||
});
|
||||
|
1038
package-lock.json
generated
Normal file
1038
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -4,7 +4,7 @@
|
||||
"description": "A tool for generating TikTok Signature.",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"axios": "^1.3.4",
|
||||
"express": "^4.18.1"
|
||||
"express": "^4.18.1",
|
||||
"request": "^2.88.2"
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user