@tiktool/live 2.12.2 → 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 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
@@ -496,6 +496,121 @@ var require_browser = __commonJS({
496
496
  }
497
497
  });
498
498
 
499
+ // ../../node_modules/has-flag/index.js
500
+ var require_has_flag = __commonJS({
501
+ "../../node_modules/has-flag/index.js"(exports2, module2) {
502
+ "use strict";
503
+ module2.exports = (flag, argv = process.argv) => {
504
+ const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
505
+ const position = argv.indexOf(prefix + flag);
506
+ const terminatorPosition = argv.indexOf("--");
507
+ return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
508
+ };
509
+ }
510
+ });
511
+
512
+ // ../../node_modules/supports-color/index.js
513
+ var require_supports_color = __commonJS({
514
+ "../../node_modules/supports-color/index.js"(exports2, module2) {
515
+ "use strict";
516
+ var os = require("os");
517
+ var tty = require("tty");
518
+ var hasFlag = require_has_flag();
519
+ var { env } = process;
520
+ var forceColor;
521
+ if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
522
+ forceColor = 0;
523
+ } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
524
+ forceColor = 1;
525
+ }
526
+ if ("FORCE_COLOR" in env) {
527
+ if (env.FORCE_COLOR === "true") {
528
+ forceColor = 1;
529
+ } else if (env.FORCE_COLOR === "false") {
530
+ forceColor = 0;
531
+ } else {
532
+ forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
533
+ }
534
+ }
535
+ function translateLevel(level) {
536
+ if (level === 0) {
537
+ return false;
538
+ }
539
+ return {
540
+ level,
541
+ hasBasic: true,
542
+ has256: level >= 2,
543
+ has16m: level >= 3
544
+ };
545
+ }
546
+ function supportsColor(haveStream, streamIsTTY) {
547
+ if (forceColor === 0) {
548
+ return 0;
549
+ }
550
+ if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
551
+ return 3;
552
+ }
553
+ if (hasFlag("color=256")) {
554
+ return 2;
555
+ }
556
+ if (haveStream && !streamIsTTY && forceColor === void 0) {
557
+ return 0;
558
+ }
559
+ const min = forceColor || 0;
560
+ if (env.TERM === "dumb") {
561
+ return min;
562
+ }
563
+ if (process.platform === "win32") {
564
+ const osRelease = os.release().split(".");
565
+ if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
566
+ return Number(osRelease[2]) >= 14931 ? 3 : 2;
567
+ }
568
+ return 1;
569
+ }
570
+ if ("CI" in env) {
571
+ if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
572
+ return 1;
573
+ }
574
+ return min;
575
+ }
576
+ if ("TEAMCITY_VERSION" in env) {
577
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
578
+ }
579
+ if (env.COLORTERM === "truecolor") {
580
+ return 3;
581
+ }
582
+ if ("TERM_PROGRAM" in env) {
583
+ const version = parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
584
+ switch (env.TERM_PROGRAM) {
585
+ case "iTerm.app":
586
+ return version >= 3 ? 3 : 2;
587
+ case "Apple_Terminal":
588
+ return 2;
589
+ }
590
+ }
591
+ if (/-256(color)?$/i.test(env.TERM)) {
592
+ return 2;
593
+ }
594
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
595
+ return 1;
596
+ }
597
+ if ("COLORTERM" in env) {
598
+ return 1;
599
+ }
600
+ return min;
601
+ }
602
+ function getSupportLevel(stream) {
603
+ const level = supportsColor(stream, stream && stream.isTTY);
604
+ return translateLevel(level);
605
+ }
606
+ module2.exports = {
607
+ supportsColor: getSupportLevel,
608
+ stdout: translateLevel(supportsColor(true, tty.isatty(1))),
609
+ stderr: translateLevel(supportsColor(true, tty.isatty(2)))
610
+ };
611
+ }
612
+ });
613
+
499
614
  // node_modules/debug/src/node.js
500
615
  var require_node = __commonJS({
501
616
  "node_modules/debug/src/node.js"(exports2, module2) {
@@ -515,7 +630,7 @@ var require_node = __commonJS({
515
630
  );
516
631
  exports2.colors = [6, 2, 3, 4, 5, 1];
517
632
  try {
518
- const supportsColor = require("supports-color");
633
+ const supportsColor = require_supports_color();
519
634
  if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
520
635
  exports2.colors = [
521
636
  20,
@@ -2512,8 +2627,12 @@ var TikTokLive = class _TikTokLive extends import_events.EventEmitter {
2512
2627
  * Resolve unknown host user IDs via the sign server API.
2513
2628
  * Caches results and re-emits the battleArmies event with enriched hostUser data.
2514
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;
2515
2634
  async resolveHostUsers(userIds, originalEvt) {
2516
- const toResolve = userIds.filter((id) => !this._pendingHostResolves.has(id));
2635
+ const toResolve = this._hostResolveUnavailable ? [] : userIds.filter((id) => !this._pendingHostResolves.has(id));
2517
2636
  if (toResolve.length === 0) {
2518
2637
  this.emit("event", originalEvt);
2519
2638
  this.emit(originalEvt.type, originalEvt);
@@ -2531,7 +2650,9 @@ var TikTokLive = class _TikTokLive extends import_events.EventEmitter {
2531
2650
  body: JSON.stringify({ user_ids: toResolve }),
2532
2651
  signal: AbortSignal.timeout(5e3)
2533
2652
  });
2534
- if (res.ok) {
2653
+ if (res.status === 401 || res.status === 403) {
2654
+ this._hostResolveUnavailable = true;
2655
+ } else if (res.ok) {
2535
2656
  const json = await res.json();
2536
2657
  if (json.data) {
2537
2658
  for (const [uid, info] of Object.entries(json.data)) {