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
|
60
index.js
60
index.js
@ -1,5 +1,5 @@
|
|||||||
const axios = require('axios');
|
const request = require("request");
|
||||||
const crypto = require('crypto');
|
const crypto = require("crypto");
|
||||||
const express = require("express");
|
const express = require("express");
|
||||||
const { sign } = require("./Signer.js");
|
const { sign } = require("./Signer.js");
|
||||||
|
|
||||||
@ -26,8 +26,8 @@ app.post("/", async (req, res) => {
|
|||||||
xbogus: xbogus,
|
xbogus: xbogus,
|
||||||
mstoken: xbogusToken,
|
mstoken: xbogusToken,
|
||||||
ttwid: ttwid,
|
ttwid: ttwid,
|
||||||
url: newUrl
|
url: newUrl,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
@ -68,31 +68,53 @@ app.get("/", (req, res) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function msToken(length) {
|
function msToken(length) {
|
||||||
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
const characters =
|
||||||
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||||
const randomBytes = crypto.randomBytes(length);
|
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() {
|
async function getTtwid() {
|
||||||
try {
|
try {
|
||||||
const url = 'https://ttwid.bytedance.com/ttwid/union/register/';
|
const url = "https://ttwid.bytedance.com/ttwid/union/register/";
|
||||||
const data = {
|
const options = {
|
||||||
"region": "cn",
|
method: "POST",
|
||||||
"aid": 1768,
|
url,
|
||||||
"needFid": false,
|
headers: {
|
||||||
"service": "www.ixigua.com",
|
"Content-Type": "application/json",
|
||||||
"migrate_info": { "ticket": "", "source": "node" },
|
},
|
||||||
"cbUrlProtocol": "https",
|
body: JSON.stringify({
|
||||||
"union": true
|
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 response = await new Promise((resolve, reject) => {
|
||||||
const setCookie = response.headers['set-cookie'];
|
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 regex = /ttwid=([^;]+)/;
|
||||||
const match = regex.exec(setCookie[0]);
|
const match = regex.exec(setCookie[0]);
|
||||||
return match && match.length > 1 ? match[1] : '';
|
return match && match.length > 1 ? match[1] : "";
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
return '';
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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.",
|
"description": "A tool for generating TikTok Signature.",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"dependencies": {
|
"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