stormcloud-video-player 0.8.23 → 0.8.24

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.
@@ -376,6 +376,350 @@ function publishMQTT(topic, payload) {
376
376
  return false;
377
377
  }
378
378
  }
379
+ // src/utils/vastEnvironmentSignals.ts
380
+ var PLAYER_ID_STORAGE_KEY = "stormcloud.player.id";
381
+ var DEVICE_ID_STORAGE_KEYS = [
382
+ "rdid",
383
+ "ifa",
384
+ "advertisingId",
385
+ "advertising_id",
386
+ "deviceAdvertisingId",
387
+ "aaid",
388
+ "adid",
389
+ "rida",
390
+ "tifa",
391
+ "lgudid"
392
+ ];
393
+ function inferDeviceIdType() {
394
+ if (typeof navigator === "undefined") {
395
+ return void 0;
396
+ }
397
+ var ua = navigator.userAgent;
398
+ if (/Roku/i.test(ua)) return "rida";
399
+ if (/Tizen|Samsung/i.test(ua)) return "tifa";
400
+ if (/AppleTV|Apple TV/i.test(ua)) return "tvOS";
401
+ if (/AFT|Fire TV|Amazon/i.test(ua)) return "afai";
402
+ if (/Web0S|webOS|LG Browser|LGSTB|LGE/i.test(ua)) return "lgudid";
403
+ if (/Android|Google TV/i.test(ua)) return "aaid";
404
+ if (/iPhone|iPad|iPod/i.test(ua)) return "idfa";
405
+ return void 0;
406
+ }
407
+ function resolveNativeDeviceId() {
408
+ var bridgeSignals = readNativeBridgeSignals();
409
+ var platformDevice = readPlatformNativeDeviceId();
410
+ var deviceId = bridgeSignals.deviceId || readStoredDeviceId() || platformDevice.deviceId;
411
+ if (!deviceId || isMacroPlaceholder(deviceId) || isZeroedAdId(deviceId)) {
412
+ return void 0;
413
+ }
414
+ return deviceId;
415
+ }
416
+ function getOrCreateStoredUuid(storageKey) {
417
+ if (typeof window === "undefined") {
418
+ return void 0;
419
+ }
420
+ var existing = readStoredString(storageKey);
421
+ if (existing) {
422
+ return existing;
423
+ }
424
+ var id = createUuid();
425
+ try {
426
+ var _window_localStorage;
427
+ (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.setItem(storageKey, id);
428
+ } catch (unused) {}
429
+ return id;
430
+ }
431
+ function createUuid() {
432
+ if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
433
+ return crypto.randomUUID();
434
+ }
435
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(char) {
436
+ var value = Math.floor(Math.random() * 16);
437
+ var nibble = char === "x" ? value : value & 3 | 8;
438
+ return nibble.toString(16);
439
+ });
440
+ }
441
+ function readPlatformNativeDeviceId() {
442
+ if (typeof window === "undefined") return {};
443
+ try {
444
+ var _window_webapis;
445
+ var adinfo = (_window_webapis = window.webapis) === null || _window_webapis === void 0 ? void 0 : _window_webapis.adinfo;
446
+ if (adinfo) {
447
+ var tifa = typeof adinfo.getTIFA === "function" ? adinfo.getTIFA() : adinfo.tifa;
448
+ if (typeof tifa === "string" && tifa && !isMacroPlaceholder(tifa)) {
449
+ var lat = typeof adinfo.isLATEnabled === "function" ? adinfo.isLATEnabled() : void 0;
450
+ return _object_spread({
451
+ deviceId: tifa,
452
+ deviceIdType: "tifa"
453
+ }, typeof lat === "boolean" ? {
454
+ limitAdTracking: lat
455
+ } : {});
456
+ }
457
+ }
458
+ } catch (unused) {}
459
+ try {
460
+ var webOSDev = window.webOSDev;
461
+ if (webOSDev) {
462
+ var _webOSDev_lgudid;
463
+ var lgudid = typeof webOSDev.LGUDID === "function" ? webOSDev.LGUDID() : (_webOSDev_lgudid = webOSDev.lgudid) !== null && _webOSDev_lgudid !== void 0 ? _webOSDev_lgudid : webOSDev.LGUDID;
464
+ if (typeof lgudid === "string" && lgudid) {
465
+ if (isZeroedAdId(lgudid)) {
466
+ return {
467
+ deviceIdType: "lgudid",
468
+ limitAdTracking: true
469
+ };
470
+ }
471
+ if (!isMacroPlaceholder(lgudid)) {
472
+ return {
473
+ deviceId: lgudid,
474
+ deviceIdType: "lgudid",
475
+ limitAdTracking: false
476
+ };
477
+ }
478
+ }
479
+ }
480
+ } catch (unused) {}
481
+ try {
482
+ var roku = window.Roku;
483
+ if (roku) {
484
+ var rida = typeof roku.getPublisherUniqueId === "function" ? roku.getPublisherUniqueId() : roku.rida;
485
+ if (typeof rida === "string" && rida && !isMacroPlaceholder(rida)) {
486
+ return {
487
+ deviceId: rida,
488
+ deviceIdType: "rida",
489
+ limitAdTracking: false
490
+ };
491
+ }
492
+ }
493
+ } catch (unused) {}
494
+ return {};
495
+ }
496
+ var ZEROED_AD_ID_PATTERNS = /* @__PURE__ */ new Set([
497
+ "38400000-8cf0-11bd-b23e-10b96e40000d",
498
+ "00000000-0000-0000-0000-000000000000"
499
+ ]);
500
+ function isMacroPlaceholder(value) {
501
+ var t = value.trim();
502
+ return !t || /^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%)$/.test(t) || /^(unknown|null|undefined|none|n\/a|\$\{[^}]+\})$/i.test(t) || ZEROED_AD_ID_PATTERNS.has(t.toLowerCase());
503
+ }
504
+ function isZeroedAdId(value) {
505
+ return ZEROED_AD_ID_PATTERNS.has(value.trim().toLowerCase());
506
+ }
507
+ function readNativeBridgeSignals() {
508
+ if (typeof window === "undefined") {
509
+ return {};
510
+ }
511
+ var candidates = [
512
+ window.__STORMCLOUD_CTV_AD_INFO__,
513
+ window.__STORMCLOUD_CTV__,
514
+ window.stormcloudCtv,
515
+ window.AiryTV,
516
+ window.Android,
517
+ window.webOS,
518
+ window.tizen,
519
+ window.amazon
520
+ ].filter(Boolean);
521
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
522
+ try {
523
+ for(var _iterator = candidates[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
524
+ var source = _step.value;
525
+ var contentUrl = readBridgeValue(source, [
526
+ "contentUrl",
527
+ "url",
528
+ "videoUrl",
529
+ "canonicalUrl"
530
+ ]) || void 0;
531
+ var appId = readBridgeValue(source, [
532
+ "appId",
533
+ "msid",
534
+ "applicationId",
535
+ "packageName"
536
+ ]) || void 0;
537
+ var appName = readBridgeValue(source, [
538
+ "appName",
539
+ "an",
540
+ "applicationName"
541
+ ]) || void 0;
542
+ var deviceId = readBridgeValue(source, [
543
+ "rdid",
544
+ "ifa",
545
+ "advertisingId",
546
+ "adId",
547
+ "deviceId",
548
+ "lgudid",
549
+ "LGUDID",
550
+ "tifa",
551
+ "rida",
552
+ "afai",
553
+ "aaid"
554
+ ]) || void 0;
555
+ if (!contentUrl && !deviceId && !appId && !appName) continue;
556
+ var deviceIdType = readBridgeValue(source, [
557
+ "idtype",
558
+ "deviceIdType",
559
+ "advertisingIdType",
560
+ "idType"
561
+ ]) || inferDeviceIdType();
562
+ var limitAdTracking = readBridgeBoolean(source, [
563
+ "is_lat",
564
+ "limitAdTracking",
565
+ "limitedAdTracking",
566
+ "lat"
567
+ ]);
568
+ return _object_spread({}, contentUrl ? {
569
+ contentUrl: contentUrl
570
+ } : {}, appId ? {
571
+ appId: appId
572
+ } : {}, appName ? {
573
+ appName: appName
574
+ } : {}, deviceId ? {
575
+ deviceId: deviceId
576
+ } : {}, deviceId && deviceIdType ? {
577
+ deviceIdType: deviceIdType
578
+ } : {}, deviceId && limitAdTracking != null ? {
579
+ limitAdTracking: limitAdTracking
580
+ } : {});
581
+ }
582
+ } catch (err) {
583
+ _didIteratorError = true;
584
+ _iteratorError = err;
585
+ } finally{
586
+ try {
587
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
588
+ _iterator.return();
589
+ }
590
+ } finally{
591
+ if (_didIteratorError) {
592
+ throw _iteratorError;
593
+ }
594
+ }
595
+ }
596
+ return {};
597
+ }
598
+ function readBridgeValue(source, keys) {
599
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
600
+ try {
601
+ for(var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
602
+ var key = _step.value;
603
+ var value = source === null || source === void 0 ? void 0 : source[key];
604
+ if (typeof value === "string" && value) {
605
+ return value;
606
+ }
607
+ if (typeof value === "function") {
608
+ try {
609
+ var result = value.call(source);
610
+ if (typeof result === "string" && result) {
611
+ return result;
612
+ }
613
+ } catch (unused) {}
614
+ }
615
+ }
616
+ } catch (err) {
617
+ _didIteratorError = true;
618
+ _iteratorError = err;
619
+ } finally{
620
+ try {
621
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
622
+ _iterator.return();
623
+ }
624
+ } finally{
625
+ if (_didIteratorError) {
626
+ throw _iteratorError;
627
+ }
628
+ }
629
+ }
630
+ return void 0;
631
+ }
632
+ function readBridgeBoolean(source, keys) {
633
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
634
+ try {
635
+ for(var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
636
+ var key = _step.value;
637
+ var value = source === null || source === void 0 ? void 0 : source[key];
638
+ var normalized = normalizeBoolean(value);
639
+ if (normalized != null) {
640
+ return normalized;
641
+ }
642
+ if (typeof value === "function") {
643
+ try {
644
+ var result = normalizeBoolean(value.call(source));
645
+ if (result != null) {
646
+ return result;
647
+ }
648
+ } catch (unused) {}
649
+ }
650
+ }
651
+ } catch (err) {
652
+ _didIteratorError = true;
653
+ _iteratorError = err;
654
+ } finally{
655
+ try {
656
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
657
+ _iterator.return();
658
+ }
659
+ } finally{
660
+ if (_didIteratorError) {
661
+ throw _iteratorError;
662
+ }
663
+ }
664
+ }
665
+ return void 0;
666
+ }
667
+ function readStoredDeviceId() {
668
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
669
+ try {
670
+ for(var _iterator = DEVICE_ID_STORAGE_KEYS[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
671
+ var key = _step.value;
672
+ var value = readStoredString(key);
673
+ if (value) {
674
+ return value;
675
+ }
676
+ }
677
+ } catch (err) {
678
+ _didIteratorError = true;
679
+ _iteratorError = err;
680
+ } finally{
681
+ try {
682
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
683
+ _iterator.return();
684
+ }
685
+ } finally{
686
+ if (_didIteratorError) {
687
+ throw _iteratorError;
688
+ }
689
+ }
690
+ }
691
+ return void 0;
692
+ }
693
+ function readStoredString(key) {
694
+ if (typeof window === "undefined") {
695
+ return void 0;
696
+ }
697
+ try {
698
+ var _window_localStorage;
699
+ var value = (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.getItem(key);
700
+ return value || void 0;
701
+ } catch (unused) {
702
+ return void 0;
703
+ }
704
+ }
705
+ function normalizeBoolean(value) {
706
+ if (typeof value === "boolean") {
707
+ return value;
708
+ }
709
+ if (typeof value === "number") {
710
+ return value === 1;
711
+ }
712
+ if (typeof value === "string") {
713
+ var normalized = value.toLowerCase();
714
+ if (normalized === "1" || normalized === "true" || normalized === "yes") {
715
+ return true;
716
+ }
717
+ if (normalized === "0" || normalized === "false" || normalized === "no") {
718
+ return false;
719
+ }
720
+ }
721
+ return void 0;
722
+ }
379
723
  // src/utils/tracking.ts
380
724
  var cachedBrowserId = null;
381
725
  function getClientInfo() {
@@ -520,19 +864,12 @@ function getClientInfo() {
520
864
  visibilityState: document.visibilityState
521
865
  };
522
866
  }
523
- function getBrowserID(clientInfo) {
867
+ function sha256Hex(input) {
524
868
  return _async_to_generator(function() {
525
- var _crypto_subtle, fingerprintString, encodedData, utf8, buffer, i, hashBuffer, hashHex, unused, hash, i1, char, fallbackHash, timestamp, random;
869
+ var _crypto_subtle, encodedData, utf8, buffer, i, hashBuffer, unused, hash, i1, char, fallbackHash, timestamp, random;
526
870
  return _ts_generator(this, function(_state) {
527
871
  switch(_state.label){
528
872
  case 0:
529
- if (cachedBrowserId) {
530
- return [
531
- 2,
532
- cachedBrowserId
533
- ];
534
- }
535
- fingerprintString = JSON.stringify(clientInfo);
536
873
  if (!(typeof crypto !== "undefined" && ((_crypto_subtle = crypto.subtle) === null || _crypto_subtle === void 0 ? void 0 : _crypto_subtle.digest))) return [
537
874
  3,
538
875
  5
@@ -556,9 +893,9 @@ function getBrowserID(clientInfo) {
556
893
  case 2:
557
894
  _state.sent();
558
895
  if (typeof TextEncoder !== "undefined") {
559
- encodedData = new TextEncoder().encode(fingerprintString);
896
+ encodedData = new TextEncoder().encode(input);
560
897
  } else {
561
- utf8 = unescape(encodeURIComponent(fingerprintString));
898
+ utf8 = unescape(encodeURIComponent(input));
562
899
  buffer = new Uint8Array(utf8.length);
563
900
  for(i = 0; i < utf8.length; i++){
564
901
  buffer[i] = utf8.charCodeAt(i);
@@ -571,13 +908,11 @@ function getBrowserID(clientInfo) {
571
908
  ];
572
909
  case 3:
573
910
  hashBuffer = _state.sent();
574
- hashHex = Array.from(new Uint8Array(hashBuffer)).map(function(b) {
575
- return b.toString(16).padStart(2, "0");
576
- }).join("");
577
- cachedBrowserId = hashHex;
578
911
  return [
579
912
  2,
580
- hashHex
913
+ Array.from(new Uint8Array(hashBuffer)).map(function(b) {
914
+ return b.toString(16).padStart(2, "0");
915
+ }).join("")
581
916
  ];
582
917
  case 4:
583
918
  unused = _state.sent();
@@ -588,15 +923,50 @@ function getBrowserID(clientInfo) {
588
923
  ];
589
924
  case 5:
590
925
  hash = 0;
591
- for(i1 = 0; i1 < fingerprintString.length; i1++){
592
- char = fingerprintString.charCodeAt(i1);
926
+ for(i1 = 0; i1 < input.length; i1++){
927
+ char = input.charCodeAt(i1);
593
928
  hash = (hash << 5) - hash + char;
594
929
  hash = hash & hash;
595
930
  }
596
931
  fallbackHash = Math.abs(hash).toString(16).padStart(8, "0");
597
932
  timestamp = Date.now().toString(16).padStart(12, "0");
598
933
  random = Math.random().toString(16).substring(2, 14).padStart(12, "0");
599
- cachedBrowserId = (fallbackHash + timestamp + random).padEnd(64, "0");
934
+ return [
935
+ 2,
936
+ (fallbackHash + timestamp + random).padEnd(64, "0")
937
+ ];
938
+ }
939
+ });
940
+ })();
941
+ }
942
+ function resolvePlayerIdentitySeed(clientInfo) {
943
+ var nativeDeviceId = resolveNativeDeviceId();
944
+ if (nativeDeviceId) {
945
+ return "device:".concat(nativeDeviceId);
946
+ }
947
+ var persistedId = getOrCreateStoredUuid(PLAYER_ID_STORAGE_KEY);
948
+ if (persistedId) {
949
+ return "persisted:".concat(persistedId);
950
+ }
951
+ return "fingerprint:".concat(JSON.stringify(clientInfo));
952
+ }
953
+ function getBrowserID(clientInfo) {
954
+ return _async_to_generator(function() {
955
+ return _ts_generator(this, function(_state) {
956
+ switch(_state.label){
957
+ case 0:
958
+ if (cachedBrowserId) {
959
+ return [
960
+ 2,
961
+ cachedBrowserId
962
+ ];
963
+ }
964
+ return [
965
+ 4,
966
+ sha256Hex(resolvePlayerIdentitySeed(clientInfo))
967
+ ];
968
+ case 1:
969
+ cachedBrowserId = _state.sent();
600
970
  return [
601
971
  2,
602
972
  cachedBrowserId