@tiktool/live 2.12.1 → 2.12.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +39 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +36 -25
- package/dist/index.mjs.map +1 -1
- package/package.json +81 -78
package/dist/index.d.mts
CHANGED
|
@@ -444,6 +444,7 @@ declare class TikTokLive extends EventEmitter {
|
|
|
444
444
|
* Resolve unknown host user IDs via the sign server API.
|
|
445
445
|
* Caches results and re-emits the battleArmies event with enriched hostUser data.
|
|
446
446
|
*/
|
|
447
|
+
private _hostResolveUnavailable;
|
|
447
448
|
private resolveHostUsers;
|
|
448
449
|
private startHeartbeat;
|
|
449
450
|
private stopHeartbeat;
|
package/dist/index.d.ts
CHANGED
|
@@ -444,6 +444,7 @@ declare class TikTokLive extends EventEmitter {
|
|
|
444
444
|
* Resolve unknown host user IDs via the sign server API.
|
|
445
445
|
* Caches results and re-emits the battleArmies event with enriched hostUser data.
|
|
446
446
|
*/
|
|
447
|
+
private _hostResolveUnavailable;
|
|
447
448
|
private resolveHostUsers;
|
|
448
449
|
private startHeartbeat;
|
|
449
450
|
private stopHeartbeat;
|
package/dist/index.js
CHANGED
|
@@ -30,9 +30,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
30
|
));
|
|
31
31
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
32
|
|
|
33
|
-
//
|
|
33
|
+
// node_modules/ms/index.js
|
|
34
34
|
var require_ms = __commonJS({
|
|
35
|
-
"
|
|
35
|
+
"node_modules/ms/index.js"(exports2, module2) {
|
|
36
36
|
"use strict";
|
|
37
37
|
var s = 1e3;
|
|
38
38
|
var m = s * 60;
|
|
@@ -147,9 +147,9 @@ var require_ms = __commonJS({
|
|
|
147
147
|
}
|
|
148
148
|
});
|
|
149
149
|
|
|
150
|
-
//
|
|
150
|
+
// node_modules/debug/src/common.js
|
|
151
151
|
var require_common = __commonJS({
|
|
152
|
-
"
|
|
152
|
+
"node_modules/debug/src/common.js"(exports2, module2) {
|
|
153
153
|
"use strict";
|
|
154
154
|
function setup(env) {
|
|
155
155
|
createDebug.debug = createDebug;
|
|
@@ -325,9 +325,9 @@ var require_common = __commonJS({
|
|
|
325
325
|
}
|
|
326
326
|
});
|
|
327
327
|
|
|
328
|
-
//
|
|
328
|
+
// node_modules/debug/src/browser.js
|
|
329
329
|
var require_browser = __commonJS({
|
|
330
|
-
"
|
|
330
|
+
"node_modules/debug/src/browser.js"(exports2, module2) {
|
|
331
331
|
"use strict";
|
|
332
332
|
exports2.formatArgs = formatArgs;
|
|
333
333
|
exports2.save = save;
|
|
@@ -496,9 +496,9 @@ var require_browser = __commonJS({
|
|
|
496
496
|
}
|
|
497
497
|
});
|
|
498
498
|
|
|
499
|
-
//
|
|
499
|
+
// ../../node_modules/has-flag/index.js
|
|
500
500
|
var require_has_flag = __commonJS({
|
|
501
|
-
"
|
|
501
|
+
"../../node_modules/has-flag/index.js"(exports2, module2) {
|
|
502
502
|
"use strict";
|
|
503
503
|
module2.exports = (flag, argv = process.argv) => {
|
|
504
504
|
const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
|
|
@@ -509,9 +509,9 @@ var require_has_flag = __commonJS({
|
|
|
509
509
|
}
|
|
510
510
|
});
|
|
511
511
|
|
|
512
|
-
//
|
|
512
|
+
// ../../node_modules/supports-color/index.js
|
|
513
513
|
var require_supports_color = __commonJS({
|
|
514
|
-
"
|
|
514
|
+
"../../node_modules/supports-color/index.js"(exports2, module2) {
|
|
515
515
|
"use strict";
|
|
516
516
|
var os = require("os");
|
|
517
517
|
var tty = require("tty");
|
|
@@ -611,9 +611,9 @@ var require_supports_color = __commonJS({
|
|
|
611
611
|
}
|
|
612
612
|
});
|
|
613
613
|
|
|
614
|
-
//
|
|
614
|
+
// node_modules/debug/src/node.js
|
|
615
615
|
var require_node = __commonJS({
|
|
616
|
-
"
|
|
616
|
+
"node_modules/debug/src/node.js"(exports2, module2) {
|
|
617
617
|
"use strict";
|
|
618
618
|
var tty = require("tty");
|
|
619
619
|
var util = require("util");
|
|
@@ -786,9 +786,9 @@ var require_node = __commonJS({
|
|
|
786
786
|
}
|
|
787
787
|
});
|
|
788
788
|
|
|
789
|
-
//
|
|
789
|
+
// node_modules/debug/src/index.js
|
|
790
790
|
var require_src = __commonJS({
|
|
791
|
-
"
|
|
791
|
+
"node_modules/debug/src/index.js"(exports2, module2) {
|
|
792
792
|
"use strict";
|
|
793
793
|
if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) {
|
|
794
794
|
module2.exports = require_browser();
|
|
@@ -798,9 +798,9 @@ var require_src = __commonJS({
|
|
|
798
798
|
}
|
|
799
799
|
});
|
|
800
800
|
|
|
801
|
-
//
|
|
801
|
+
// node_modules/agent-base/dist/helpers.js
|
|
802
802
|
var require_helpers = __commonJS({
|
|
803
|
-
"
|
|
803
|
+
"node_modules/agent-base/dist/helpers.js"(exports2) {
|
|
804
804
|
"use strict";
|
|
805
805
|
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
806
806
|
if (k2 === void 0) k2 = k;
|
|
@@ -868,9 +868,9 @@ var require_helpers = __commonJS({
|
|
|
868
868
|
}
|
|
869
869
|
});
|
|
870
870
|
|
|
871
|
-
//
|
|
871
|
+
// node_modules/agent-base/dist/index.js
|
|
872
872
|
var require_dist = __commonJS({
|
|
873
|
-
"
|
|
873
|
+
"node_modules/agent-base/dist/index.js"(exports2) {
|
|
874
874
|
"use strict";
|
|
875
875
|
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
876
876
|
if (k2 === void 0) k2 = k;
|
|
@@ -1024,9 +1024,9 @@ var require_dist = __commonJS({
|
|
|
1024
1024
|
}
|
|
1025
1025
|
});
|
|
1026
1026
|
|
|
1027
|
-
//
|
|
1027
|
+
// node_modules/https-proxy-agent/dist/parse-proxy-response.js
|
|
1028
1028
|
var require_parse_proxy_response = __commonJS({
|
|
1029
|
-
"
|
|
1029
|
+
"node_modules/https-proxy-agent/dist/parse-proxy-response.js"(exports2) {
|
|
1030
1030
|
"use strict";
|
|
1031
1031
|
var __importDefault = exports2 && exports2.__importDefault || function(mod) {
|
|
1032
1032
|
return mod && mod.__esModule ? mod : { "default": mod };
|
|
@@ -1120,9 +1120,9 @@ var require_parse_proxy_response = __commonJS({
|
|
|
1120
1120
|
}
|
|
1121
1121
|
});
|
|
1122
1122
|
|
|
1123
|
-
//
|
|
1123
|
+
// node_modules/https-proxy-agent/dist/index.js
|
|
1124
1124
|
var require_dist2 = __commonJS({
|
|
1125
|
-
"
|
|
1125
|
+
"node_modules/https-proxy-agent/dist/index.js"(exports2) {
|
|
1126
1126
|
"use strict";
|
|
1127
1127
|
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
1128
1128
|
if (k2 === void 0) k2 = k;
|
|
@@ -1271,11 +1271,11 @@ var require_dist2 = __commonJS({
|
|
|
1271
1271
|
});
|
|
1272
1272
|
|
|
1273
1273
|
// src/index.ts
|
|
1274
|
-
var
|
|
1275
|
-
__export(
|
|
1274
|
+
var src_exports = {};
|
|
1275
|
+
__export(src_exports, {
|
|
1276
1276
|
TikTokLive: () => TikTokLive
|
|
1277
1277
|
});
|
|
1278
|
-
module.exports = __toCommonJS(
|
|
1278
|
+
module.exports = __toCommonJS(src_exports);
|
|
1279
1279
|
|
|
1280
1280
|
// src/client.ts
|
|
1281
1281
|
var import_events = require("events");
|
|
@@ -2237,6 +2237,7 @@ var TikTokLive = class _TikTokLive extends import_events.EventEmitter {
|
|
|
2237
2237
|
}
|
|
2238
2238
|
} else {
|
|
2239
2239
|
console.log(`[TikTokLive] No presets for @${this.uniqueId}. Resolving via sign server (${this.signServerUrl})...`);
|
|
2240
|
+
let confirmedOffline = false;
|
|
2240
2241
|
try {
|
|
2241
2242
|
const roomResp = await fetch(`${this.signServerUrl}/webcast/room_id`, {
|
|
2242
2243
|
method: "POST",
|
|
@@ -2246,7 +2247,10 @@ var TikTokLive = class _TikTokLive extends import_events.EventEmitter {
|
|
|
2246
2247
|
console.log(`[TikTokLive] room_id response: ${roomResp.status}`);
|
|
2247
2248
|
if (roomResp.ok) {
|
|
2248
2249
|
const roomData = await roomResp.json();
|
|
2249
|
-
if (roomData.status_code === 0 && roomData.data?.room_id) {
|
|
2250
|
+
if (roomData.status_code === 0 && roomData.data?.room_id && roomData.data.alive === false) {
|
|
2251
|
+
confirmedOffline = true;
|
|
2252
|
+
console.log(`[TikTokLive] @${this.uniqueId} resolved to ended room ${roomData.data.room_id} (alive:false)`);
|
|
2253
|
+
} else if (roomData.status_code === 0 && roomData.data?.room_id) {
|
|
2250
2254
|
roomId = roomData.data.room_id;
|
|
2251
2255
|
console.log(`[TikTokLive] \xE2\u0153\u2026 Got roomId from sign server: ${roomId}`);
|
|
2252
2256
|
} else {
|
|
@@ -2256,6 +2260,7 @@ var TikTokLive = class _TikTokLive extends import_events.EventEmitter {
|
|
|
2256
2260
|
} catch (e) {
|
|
2257
2261
|
console.log(`[TikTokLive] \xE2\x9D\u0152 room_id request failed: ${e.message}`);
|
|
2258
2262
|
}
|
|
2263
|
+
if (confirmedOffline) throw new Error(`User @${this.uniqueId} is not currently live`);
|
|
2259
2264
|
if (roomId) {
|
|
2260
2265
|
try {
|
|
2261
2266
|
const credResp = await fetch(`${this.signServerUrl}/webcast/ws_credentials`, {
|
|
@@ -2622,8 +2627,12 @@ var TikTokLive = class _TikTokLive extends import_events.EventEmitter {
|
|
|
2622
2627
|
* Resolve unknown host user IDs via the sign server API.
|
|
2623
2628
|
* Caches results and re-emits the battleArmies event with enriched hostUser data.
|
|
2624
2629
|
*/
|
|
2630
|
+
// Set once the sign server refuses host resolution for this key (tier below
|
|
2631
|
+
// Basic answers 403). Before this, every battle frame retried and filled the
|
|
2632
|
+
// customer's API log with 403s they never asked for.
|
|
2633
|
+
_hostResolveUnavailable = false;
|
|
2625
2634
|
async resolveHostUsers(userIds, originalEvt) {
|
|
2626
|
-
const toResolve = userIds.filter((id) => !this._pendingHostResolves.has(id));
|
|
2635
|
+
const toResolve = this._hostResolveUnavailable ? [] : userIds.filter((id) => !this._pendingHostResolves.has(id));
|
|
2627
2636
|
if (toResolve.length === 0) {
|
|
2628
2637
|
this.emit("event", originalEvt);
|
|
2629
2638
|
this.emit(originalEvt.type, originalEvt);
|
|
@@ -2641,7 +2650,9 @@ var TikTokLive = class _TikTokLive extends import_events.EventEmitter {
|
|
|
2641
2650
|
body: JSON.stringify({ user_ids: toResolve }),
|
|
2642
2651
|
signal: AbortSignal.timeout(5e3)
|
|
2643
2652
|
});
|
|
2644
|
-
if (res.
|
|
2653
|
+
if (res.status === 401 || res.status === 403) {
|
|
2654
|
+
this._hostResolveUnavailable = true;
|
|
2655
|
+
} else if (res.ok) {
|
|
2645
2656
|
const json = await res.json();
|
|
2646
2657
|
if (json.data) {
|
|
2647
2658
|
for (const [uid, info] of Object.entries(json.data)) {
|