forked from carcabot/tiktok-signature
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
37 lines (33 loc) · 1004 Bytes
/
server.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
37
const Signer = require("./index");
const http = require("http");
fs = require("fs");
(async function main() {
try {
const signer = new Signer();
const tacToken = await signer.getTac();
const jsCode = fs.readFileSync("./bytedcode.js").toString();
if (tacToken) {
console.log("tac loaded successfully");
}
fs.readFile("./index.html", "utf8", function(err, html) {
if (err) {
throw err;
}
http
.createServer(function(request, response) {
html = html.replace("<script>TACTOKEN</script>", tacToken);
html = html.replace("SIGNATURE_FUNCTION", jsCode);
response.writeHeader(200, { "Content-Type": "text/html" });
response.write(html);
response.end();
})
.listen(8080, '127.0.0.1')
.on("listening", function() {
console.log("TikTok Signature server started");
});
});
await signer.close();
} catch (err) {
console.error(err);
}
})();