Better docker image and docs

This commit is contained in:
Pablo Ferreiro
2024-01-25 17:10:55 +01:00
parent b7c46979f1
commit 895e33d66c
4 changed files with 205 additions and 269 deletions

View File

@@ -2,11 +2,18 @@ const fs = require("fs");
const { JSDOM, ResourceLoader } = require("jsdom");
const { createCipheriv } = require("crypto");
/**
* Main Signer class
*/
class Signer {
/** Default user-agent used to signed the requests */
static DEFAULT_USERAGENT =
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 Edg/107.0.1418.35";
/** Password for x-tt-params AES enc/dec */
static PASSWORD = "webapp1.0+202106";
/**
* JSDOM main window
* @type Window
*/
window = null;
@@ -34,6 +41,10 @@ class Signer {
this.window.eval(webmssdk);
}
/**
* Get current virtual browser navigator
* @returns Navigator compatible with tiktok-signature
*/
navigator() {
return {
deviceScaleFactor: this.window.devicePixelRatio,
@@ -45,14 +56,29 @@ class Signer {
};
}
/**
* Get _signature GET query
* @param {string} url Unencrypted url
* @returns {string} _signature as string
*/
signature(url) {
return this.window.byted_acrawler.sign({ url });
}
/**
* Get X-Bogus header
* @param {string} params Unencrypted GET query
* @returns {string} X-Bogus string
*/
bogus(params) {
return this.window._0x32d649(params);
}
/**
* Get x-tt-params header from GET query
* @param {string} params Unencrypted GET query
* @returns {string} Encrypted x-tt-params
*/
xttparams(params) {
params += "&verifyFp=undefined";
params += "&is_encryption=1";
@@ -61,6 +87,11 @@ class Signer {
return Buffer.concat([cipher.update(params), cipher.final()]).toString("base64");
}
/**
* Sign a TikTok URL
* @param {string} url_str Unsigned URL
* @returns Object with signed data
*/
sign(url_str) {
const url = new URL(url_str);
const signature = this.signature(url.toString());