stormcloud-video-player 0.8.22 → 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.
@@ -336,6 +336,350 @@ function publishMQTT(topic, payload) {
336
336
  return false;
337
337
  }
338
338
  }
339
+ // src/utils/vastEnvironmentSignals.ts
340
+ var PLAYER_ID_STORAGE_KEY = "stormcloud.player.id";
341
+ var DEVICE_ID_STORAGE_KEYS = [
342
+ "rdid",
343
+ "ifa",
344
+ "advertisingId",
345
+ "advertising_id",
346
+ "deviceAdvertisingId",
347
+ "aaid",
348
+ "adid",
349
+ "rida",
350
+ "tifa",
351
+ "lgudid"
352
+ ];
353
+ function inferDeviceIdType() {
354
+ if (typeof navigator === "undefined") {
355
+ return void 0;
356
+ }
357
+ var ua = navigator.userAgent;
358
+ if (/Roku/i.test(ua)) return "rida";
359
+ if (/Tizen|Samsung/i.test(ua)) return "tifa";
360
+ if (/AppleTV|Apple TV/i.test(ua)) return "tvOS";
361
+ if (/AFT|Fire TV|Amazon/i.test(ua)) return "afai";
362
+ if (/Web0S|webOS|LG Browser|LGSTB|LGE/i.test(ua)) return "lgudid";
363
+ if (/Android|Google TV/i.test(ua)) return "aaid";
364
+ if (/iPhone|iPad|iPod/i.test(ua)) return "idfa";
365
+ return void 0;
366
+ }
367
+ function resolveNativeDeviceId() {
368
+ var bridgeSignals = readNativeBridgeSignals();
369
+ var platformDevice = readPlatformNativeDeviceId();
370
+ var deviceId = bridgeSignals.deviceId || readStoredDeviceId() || platformDevice.deviceId;
371
+ if (!deviceId || isMacroPlaceholder(deviceId) || isZeroedAdId(deviceId)) {
372
+ return void 0;
373
+ }
374
+ return deviceId;
375
+ }
376
+ function getOrCreateStoredUuid(storageKey) {
377
+ if (typeof window === "undefined") {
378
+ return void 0;
379
+ }
380
+ var existing = readStoredString(storageKey);
381
+ if (existing) {
382
+ return existing;
383
+ }
384
+ var id = createUuid();
385
+ try {
386
+ var _window_localStorage;
387
+ (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.setItem(storageKey, id);
388
+ } catch (unused) {}
389
+ return id;
390
+ }
391
+ function createUuid() {
392
+ if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
393
+ return crypto.randomUUID();
394
+ }
395
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(char) {
396
+ var value = Math.floor(Math.random() * 16);
397
+ var nibble = char === "x" ? value : value & 3 | 8;
398
+ return nibble.toString(16);
399
+ });
400
+ }
401
+ function readPlatformNativeDeviceId() {
402
+ if (typeof window === "undefined") return {};
403
+ try {
404
+ var _window_webapis;
405
+ var adinfo = (_window_webapis = window.webapis) === null || _window_webapis === void 0 ? void 0 : _window_webapis.adinfo;
406
+ if (adinfo) {
407
+ var tifa = typeof adinfo.getTIFA === "function" ? adinfo.getTIFA() : adinfo.tifa;
408
+ if (typeof tifa === "string" && tifa && !isMacroPlaceholder(tifa)) {
409
+ var lat = typeof adinfo.isLATEnabled === "function" ? adinfo.isLATEnabled() : void 0;
410
+ return _object_spread({
411
+ deviceId: tifa,
412
+ deviceIdType: "tifa"
413
+ }, typeof lat === "boolean" ? {
414
+ limitAdTracking: lat
415
+ } : {});
416
+ }
417
+ }
418
+ } catch (unused) {}
419
+ try {
420
+ var webOSDev = window.webOSDev;
421
+ if (webOSDev) {
422
+ var _webOSDev_lgudid;
423
+ var lgudid = typeof webOSDev.LGUDID === "function" ? webOSDev.LGUDID() : (_webOSDev_lgudid = webOSDev.lgudid) !== null && _webOSDev_lgudid !== void 0 ? _webOSDev_lgudid : webOSDev.LGUDID;
424
+ if (typeof lgudid === "string" && lgudid) {
425
+ if (isZeroedAdId(lgudid)) {
426
+ return {
427
+ deviceIdType: "lgudid",
428
+ limitAdTracking: true
429
+ };
430
+ }
431
+ if (!isMacroPlaceholder(lgudid)) {
432
+ return {
433
+ deviceId: lgudid,
434
+ deviceIdType: "lgudid",
435
+ limitAdTracking: false
436
+ };
437
+ }
438
+ }
439
+ }
440
+ } catch (unused) {}
441
+ try {
442
+ var roku = window.Roku;
443
+ if (roku) {
444
+ var rida = typeof roku.getPublisherUniqueId === "function" ? roku.getPublisherUniqueId() : roku.rida;
445
+ if (typeof rida === "string" && rida && !isMacroPlaceholder(rida)) {
446
+ return {
447
+ deviceId: rida,
448
+ deviceIdType: "rida",
449
+ limitAdTracking: false
450
+ };
451
+ }
452
+ }
453
+ } catch (unused) {}
454
+ return {};
455
+ }
456
+ var ZEROED_AD_ID_PATTERNS = /* @__PURE__ */ new Set([
457
+ "38400000-8cf0-11bd-b23e-10b96e40000d",
458
+ "00000000-0000-0000-0000-000000000000"
459
+ ]);
460
+ function isMacroPlaceholder(value) {
461
+ var t = value.trim();
462
+ return !t || /^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%)$/.test(t) || /^(unknown|null|undefined|none|n\/a|\$\{[^}]+\})$/i.test(t) || ZEROED_AD_ID_PATTERNS.has(t.toLowerCase());
463
+ }
464
+ function isZeroedAdId(value) {
465
+ return ZEROED_AD_ID_PATTERNS.has(value.trim().toLowerCase());
466
+ }
467
+ function readNativeBridgeSignals() {
468
+ if (typeof window === "undefined") {
469
+ return {};
470
+ }
471
+ var candidates = [
472
+ window.__STORMCLOUD_CTV_AD_INFO__,
473
+ window.__STORMCLOUD_CTV__,
474
+ window.stormcloudCtv,
475
+ window.AiryTV,
476
+ window.Android,
477
+ window.webOS,
478
+ window.tizen,
479
+ window.amazon
480
+ ].filter(Boolean);
481
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
482
+ try {
483
+ for(var _iterator = candidates[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
484
+ var source = _step.value;
485
+ var contentUrl = readBridgeValue(source, [
486
+ "contentUrl",
487
+ "url",
488
+ "videoUrl",
489
+ "canonicalUrl"
490
+ ]) || void 0;
491
+ var appId = readBridgeValue(source, [
492
+ "appId",
493
+ "msid",
494
+ "applicationId",
495
+ "packageName"
496
+ ]) || void 0;
497
+ var appName = readBridgeValue(source, [
498
+ "appName",
499
+ "an",
500
+ "applicationName"
501
+ ]) || void 0;
502
+ var deviceId = readBridgeValue(source, [
503
+ "rdid",
504
+ "ifa",
505
+ "advertisingId",
506
+ "adId",
507
+ "deviceId",
508
+ "lgudid",
509
+ "LGUDID",
510
+ "tifa",
511
+ "rida",
512
+ "afai",
513
+ "aaid"
514
+ ]) || void 0;
515
+ if (!contentUrl && !deviceId && !appId && !appName) continue;
516
+ var deviceIdType = readBridgeValue(source, [
517
+ "idtype",
518
+ "deviceIdType",
519
+ "advertisingIdType",
520
+ "idType"
521
+ ]) || inferDeviceIdType();
522
+ var limitAdTracking = readBridgeBoolean(source, [
523
+ "is_lat",
524
+ "limitAdTracking",
525
+ "limitedAdTracking",
526
+ "lat"
527
+ ]);
528
+ return _object_spread({}, contentUrl ? {
529
+ contentUrl: contentUrl
530
+ } : {}, appId ? {
531
+ appId: appId
532
+ } : {}, appName ? {
533
+ appName: appName
534
+ } : {}, deviceId ? {
535
+ deviceId: deviceId
536
+ } : {}, deviceId && deviceIdType ? {
537
+ deviceIdType: deviceIdType
538
+ } : {}, deviceId && limitAdTracking != null ? {
539
+ limitAdTracking: limitAdTracking
540
+ } : {});
541
+ }
542
+ } catch (err) {
543
+ _didIteratorError = true;
544
+ _iteratorError = err;
545
+ } finally{
546
+ try {
547
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
548
+ _iterator.return();
549
+ }
550
+ } finally{
551
+ if (_didIteratorError) {
552
+ throw _iteratorError;
553
+ }
554
+ }
555
+ }
556
+ return {};
557
+ }
558
+ function readBridgeValue(source, keys) {
559
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
560
+ try {
561
+ for(var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
562
+ var key = _step.value;
563
+ var value = source === null || source === void 0 ? void 0 : source[key];
564
+ if (typeof value === "string" && value) {
565
+ return value;
566
+ }
567
+ if (typeof value === "function") {
568
+ try {
569
+ var result = value.call(source);
570
+ if (typeof result === "string" && result) {
571
+ return result;
572
+ }
573
+ } catch (unused) {}
574
+ }
575
+ }
576
+ } catch (err) {
577
+ _didIteratorError = true;
578
+ _iteratorError = err;
579
+ } finally{
580
+ try {
581
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
582
+ _iterator.return();
583
+ }
584
+ } finally{
585
+ if (_didIteratorError) {
586
+ throw _iteratorError;
587
+ }
588
+ }
589
+ }
590
+ return void 0;
591
+ }
592
+ function readBridgeBoolean(source, keys) {
593
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
594
+ try {
595
+ for(var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
596
+ var key = _step.value;
597
+ var value = source === null || source === void 0 ? void 0 : source[key];
598
+ var normalized = normalizeBoolean(value);
599
+ if (normalized != null) {
600
+ return normalized;
601
+ }
602
+ if (typeof value === "function") {
603
+ try {
604
+ var result = normalizeBoolean(value.call(source));
605
+ if (result != null) {
606
+ return result;
607
+ }
608
+ } catch (unused) {}
609
+ }
610
+ }
611
+ } catch (err) {
612
+ _didIteratorError = true;
613
+ _iteratorError = err;
614
+ } finally{
615
+ try {
616
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
617
+ _iterator.return();
618
+ }
619
+ } finally{
620
+ if (_didIteratorError) {
621
+ throw _iteratorError;
622
+ }
623
+ }
624
+ }
625
+ return void 0;
626
+ }
627
+ function readStoredDeviceId() {
628
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
629
+ try {
630
+ for(var _iterator = DEVICE_ID_STORAGE_KEYS[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
631
+ var key = _step.value;
632
+ var value = readStoredString(key);
633
+ if (value) {
634
+ return value;
635
+ }
636
+ }
637
+ } catch (err) {
638
+ _didIteratorError = true;
639
+ _iteratorError = err;
640
+ } finally{
641
+ try {
642
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
643
+ _iterator.return();
644
+ }
645
+ } finally{
646
+ if (_didIteratorError) {
647
+ throw _iteratorError;
648
+ }
649
+ }
650
+ }
651
+ return void 0;
652
+ }
653
+ function readStoredString(key) {
654
+ if (typeof window === "undefined") {
655
+ return void 0;
656
+ }
657
+ try {
658
+ var _window_localStorage;
659
+ var value = (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.getItem(key);
660
+ return value || void 0;
661
+ } catch (unused) {
662
+ return void 0;
663
+ }
664
+ }
665
+ function normalizeBoolean(value) {
666
+ if (typeof value === "boolean") {
667
+ return value;
668
+ }
669
+ if (typeof value === "number") {
670
+ return value === 1;
671
+ }
672
+ if (typeof value === "string") {
673
+ var normalized = value.toLowerCase();
674
+ if (normalized === "1" || normalized === "true" || normalized === "yes") {
675
+ return true;
676
+ }
677
+ if (normalized === "0" || normalized === "false" || normalized === "no") {
678
+ return false;
679
+ }
680
+ }
681
+ return void 0;
682
+ }
339
683
  // src/utils/tracking.ts
340
684
  var cachedBrowserId = null;
341
685
  function getClientInfo() {
@@ -480,19 +824,12 @@ function getClientInfo() {
480
824
  visibilityState: document.visibilityState
481
825
  };
482
826
  }
483
- function getBrowserID(clientInfo) {
827
+ function sha256Hex(input) {
484
828
  return _async_to_generator(function() {
485
- var _crypto_subtle, fingerprintString, encodedData, utf8, buffer, i, hashBuffer, hashHex, unused, hash, i1, char, fallbackHash, timestamp, random;
829
+ var _crypto_subtle, encodedData, utf8, buffer, i, hashBuffer, unused, hash, i1, char, fallbackHash, timestamp, random;
486
830
  return _ts_generator(this, function(_state) {
487
831
  switch(_state.label){
488
832
  case 0:
489
- if (cachedBrowserId) {
490
- return [
491
- 2,
492
- cachedBrowserId
493
- ];
494
- }
495
- fingerprintString = JSON.stringify(clientInfo);
496
833
  if (!(typeof crypto !== "undefined" && ((_crypto_subtle = crypto.subtle) === null || _crypto_subtle === void 0 ? void 0 : _crypto_subtle.digest))) return [
497
834
  3,
498
835
  5
@@ -516,9 +853,9 @@ function getBrowserID(clientInfo) {
516
853
  case 2:
517
854
  _state.sent();
518
855
  if (typeof TextEncoder !== "undefined") {
519
- encodedData = new TextEncoder().encode(fingerprintString);
856
+ encodedData = new TextEncoder().encode(input);
520
857
  } else {
521
- utf8 = unescape(encodeURIComponent(fingerprintString));
858
+ utf8 = unescape(encodeURIComponent(input));
522
859
  buffer = new Uint8Array(utf8.length);
523
860
  for(i = 0; i < utf8.length; i++){
524
861
  buffer[i] = utf8.charCodeAt(i);
@@ -531,13 +868,11 @@ function getBrowserID(clientInfo) {
531
868
  ];
532
869
  case 3:
533
870
  hashBuffer = _state.sent();
534
- hashHex = Array.from(new Uint8Array(hashBuffer)).map(function(b) {
535
- return b.toString(16).padStart(2, "0");
536
- }).join("");
537
- cachedBrowserId = hashHex;
538
871
  return [
539
872
  2,
540
- hashHex
873
+ Array.from(new Uint8Array(hashBuffer)).map(function(b) {
874
+ return b.toString(16).padStart(2, "0");
875
+ }).join("")
541
876
  ];
542
877
  case 4:
543
878
  unused = _state.sent();
@@ -548,15 +883,50 @@ function getBrowserID(clientInfo) {
548
883
  ];
549
884
  case 5:
550
885
  hash = 0;
551
- for(i1 = 0; i1 < fingerprintString.length; i1++){
552
- char = fingerprintString.charCodeAt(i1);
886
+ for(i1 = 0; i1 < input.length; i1++){
887
+ char = input.charCodeAt(i1);
553
888
  hash = (hash << 5) - hash + char;
554
889
  hash = hash & hash;
555
890
  }
556
891
  fallbackHash = Math.abs(hash).toString(16).padStart(8, "0");
557
892
  timestamp = Date.now().toString(16).padStart(12, "0");
558
893
  random = Math.random().toString(16).substring(2, 14).padStart(12, "0");
559
- cachedBrowserId = (fallbackHash + timestamp + random).padEnd(64, "0");
894
+ return [
895
+ 2,
896
+ (fallbackHash + timestamp + random).padEnd(64, "0")
897
+ ];
898
+ }
899
+ });
900
+ })();
901
+ }
902
+ function resolvePlayerIdentitySeed(clientInfo) {
903
+ var nativeDeviceId = resolveNativeDeviceId();
904
+ if (nativeDeviceId) {
905
+ return "device:".concat(nativeDeviceId);
906
+ }
907
+ var persistedId = getOrCreateStoredUuid(PLAYER_ID_STORAGE_KEY);
908
+ if (persistedId) {
909
+ return "persisted:".concat(persistedId);
910
+ }
911
+ return "fingerprint:".concat(JSON.stringify(clientInfo));
912
+ }
913
+ function getBrowserID(clientInfo) {
914
+ return _async_to_generator(function() {
915
+ return _ts_generator(this, function(_state) {
916
+ switch(_state.label){
917
+ case 0:
918
+ if (cachedBrowserId) {
919
+ return [
920
+ 2,
921
+ cachedBrowserId
922
+ ];
923
+ }
924
+ return [
925
+ 4,
926
+ sha256Hex(resolvePlayerIdentitySeed(clientInfo))
927
+ ];
928
+ case 1:
929
+ cachedBrowserId = _state.sent();
560
930
  return [
561
931
  2,
562
932
  cachedBrowserId