stormcloud-video-player 0.8.82 → 0.8.83
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/stormcloud-vp.min.js +1 -1
- package/lib/StormcloudPlayer.cjs +66 -3
- package/lib/StormcloudPlayer.cjs.map +1 -1
- package/lib/index.cjs +66 -3
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +66 -3
- package/lib/index.js.map +1 -1
- package/lib/player/AdConfigManager.cjs +47 -1
- package/lib/player/AdConfigManager.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +66 -3
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +2 -0
- package/lib/players/HlsPlayer.cjs +66 -3
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +66 -3
- package/lib/players/index.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +66 -3
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/utils/__tests__/adSignals.test.cjs +24 -1
- package/lib/utils/__tests__/adSignals.test.cjs.map +1 -1
- package/lib/utils/adIdentity.cjs +34 -1
- package/lib/utils/adIdentity.cjs.map +1 -1
- package/lib/utils/adIdentity.d.cts +2 -1
- package/lib/utils/partnerSignals.cjs +10 -1
- package/lib/utils/partnerSignals.cjs.map +1 -1
- package/lib/utils/partnerSignals.d.cts +2 -1
- package/lib/utils/vastMacros.cjs +1 -0
- package/lib/utils/vastMacros.cjs.map +1 -1
- package/lib/utils/vastMacros.d.cts +1 -0
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -362,6 +362,7 @@ declare class StormcloudVideoPlayer {
|
|
|
362
362
|
private edgePodBaseUrl;
|
|
363
363
|
private lastPalOptions;
|
|
364
364
|
private palSessionId;
|
|
365
|
+
private palPpid;
|
|
365
366
|
private palRefreshTimer;
|
|
366
367
|
constructor(config: StormcloudVideoPlayerConfig);
|
|
367
368
|
private get debug();
|
|
@@ -378,6 +379,7 @@ declare class StormcloudVideoPlayer {
|
|
|
378
379
|
load(): Promise<void>;
|
|
379
380
|
private startPalNonceRefresh;
|
|
380
381
|
private refreshPalNonceIfStale;
|
|
382
|
+
private currentPpid;
|
|
381
383
|
setAdIdentity(identity: HostAdIdentity | null): void;
|
|
382
384
|
resetAdIdentity(): void;
|
|
383
385
|
setContentMetadata(meta: ContentMetadataUpdate): void;
|
package/lib/index.js
CHANGED
|
@@ -365,6 +365,9 @@ var DEFAULT_LGUDID_TIMEOUT_MS = 1500;
|
|
|
365
365
|
var FALLBACK_DEVICE_ID_KEY = "stormcloud.ad.dpid.v2";
|
|
366
366
|
var SESSION_ID_KEY = "stormcloud.ad.sid.v2";
|
|
367
367
|
var LEGACY_SESSION_KEY = "stormcloud.ctv.sid";
|
|
368
|
+
var STAY_ID_KEY = "stormcloud.ad.stay.v1";
|
|
369
|
+
var HOST_ID_KEY = "stormcloud.ad.host.v1";
|
|
370
|
+
var memoryMarkers = {};
|
|
368
371
|
var ZEROED_IDS = /* @__PURE__ */ new Set([
|
|
369
372
|
"00000000-0000-0000-0000-000000000000",
|
|
370
373
|
"38400000-8cf0-11bd-b23e-10b96e40000d"
|
|
@@ -467,7 +470,7 @@ function setHostAdIdentity(identity) {
|
|
|
467
470
|
return;
|
|
468
471
|
}
|
|
469
472
|
var deviceId = identity.deviceId.trim();
|
|
470
|
-
var changed =
|
|
473
|
+
var changed = writeMarkerIfChanged(HOST_ID_KEY, deviceId);
|
|
471
474
|
hostIdentity = _object_spread({
|
|
472
475
|
deviceId: deviceId,
|
|
473
476
|
deviceIdType: (_normalizeIdType = normalizeIdType(identity.deviceIdType)) !== null && _normalizeIdType !== void 0 ? _normalizeIdType : "dpid"
|
|
@@ -486,6 +489,31 @@ function resetAdIdentity() {
|
|
|
486
489
|
removeStored(SESSION_ID_KEY);
|
|
487
490
|
removeStored(FALLBACK_DEVICE_ID_KEY);
|
|
488
491
|
}
|
|
492
|
+
function writeMarkerIfChanged(key, value) {
|
|
493
|
+
var _memoryMarkers_key;
|
|
494
|
+
var previous = (_memoryMarkers_key = memoryMarkers[key]) !== null && _memoryMarkers_key !== void 0 ? _memoryMarkers_key : "";
|
|
495
|
+
try {
|
|
496
|
+
var _window_localStorage;
|
|
497
|
+
var stored = typeof window !== "undefined" ? (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.getItem(key) : null;
|
|
498
|
+
if (typeof stored === "string") previous = stored;
|
|
499
|
+
} catch (unused) {}
|
|
500
|
+
if (value === previous) return false;
|
|
501
|
+
memoryMarkers[key] = value;
|
|
502
|
+
try {
|
|
503
|
+
if (typeof window !== "undefined") {
|
|
504
|
+
var _window_localStorage1, _window_localStorage2;
|
|
505
|
+
if (value) (_window_localStorage1 = window.localStorage) === null || _window_localStorage1 === void 0 ? void 0 : _window_localStorage1.setItem(key, value);
|
|
506
|
+
else (_window_localStorage2 = window.localStorage) === null || _window_localStorage2 === void 0 ? void 0 : _window_localStorage2.removeItem(key);
|
|
507
|
+
}
|
|
508
|
+
} catch (unused) {}
|
|
509
|
+
return true;
|
|
510
|
+
}
|
|
511
|
+
function noteStayId(stayId) {
|
|
512
|
+
if (!writeMarkerIfChanged(STAY_ID_KEY, stayId ? stayId.trim() : "")) return false;
|
|
513
|
+
removeStored(SESSION_ID_KEY);
|
|
514
|
+
removeStored(FALLBACK_DEVICE_ID_KEY);
|
|
515
|
+
return true;
|
|
516
|
+
}
|
|
489
517
|
function readSamsungTifa() {
|
|
490
518
|
try {
|
|
491
519
|
var _window_webapis;
|
|
@@ -1525,6 +1553,11 @@ function sanitizePublicIp(value) {
|
|
|
1525
1553
|
if (cleaned.includes(".")) return isPublicIpv4(cleaned) ? cleaned : void 0;
|
|
1526
1554
|
return isPublicIpv6(cleaned) ? cleaned : void 0;
|
|
1527
1555
|
}
|
|
1556
|
+
var PPID_PATTERN = /^[0-9a-zA-Z+.=\/_\-$,{}]{22,150}$/;
|
|
1557
|
+
function toPpid(userId, limitAdTracking) {
|
|
1558
|
+
if (!userId || limitAdTracking === true) return void 0;
|
|
1559
|
+
return PPID_PATTERN.test(userId) ? userId : void 0;
|
|
1560
|
+
}
|
|
1528
1561
|
function resolveUserId(configValue) {
|
|
1529
1562
|
var _sanitizeUserId;
|
|
1530
1563
|
return (_sanitizeUserId = sanitizeUserId(configValue)) !== null && _sanitizeUserId !== void 0 ? _sanitizeUserId : readBridgeValue2([
|
|
@@ -1933,6 +1966,7 @@ function resolveScvpMacroValues(ctx) {
|
|
|
1933
1966
|
set("UA", ctx.userAgent);
|
|
1934
1967
|
set("IP", ctx.ipAddress);
|
|
1935
1968
|
set("UID", ctx.userId);
|
|
1969
|
+
set("PPID", ctx.ppid);
|
|
1936
1970
|
set("CT-TYPE", ctx.contentType);
|
|
1937
1971
|
set("CT-CATEGORY", ctx.contentCategory);
|
|
1938
1972
|
set("CT-GENRE", ctx.contentGenre);
|
|
@@ -9577,6 +9611,8 @@ var AdConfigManager = /*#__PURE__*/ function() {
|
|
|
9577
9611
|
value: function generatePodVastUrl(baseUrl, adPlayer, palNonce, inAdBreak) {
|
|
9578
9612
|
var _content_contentDurationSeconds;
|
|
9579
9613
|
var adWillPlayMuted = inAdBreak ? adPlayer.getOriginalMutedState() : this.video.muted;
|
|
9614
|
+
var stayUserId = resolveUserId(this.config.adUserId);
|
|
9615
|
+
noteStayId(stayUserId);
|
|
9580
9616
|
var envSignals = resolveVastEnvironmentSignals(!!this.config.ctvAdRequest, {
|
|
9581
9617
|
fallbackDeviceIdMaxAgeMs: this.config.fallbackDeviceIdMaxAgeMs,
|
|
9582
9618
|
sessionIdMaxAgeMs: this.config.sessionIdMaxAgeMs
|
|
@@ -9587,7 +9623,8 @@ var AdConfigManager = /*#__PURE__*/ function() {
|
|
|
9587
9623
|
var playerSize = resolvePlayerSize(this.video);
|
|
9588
9624
|
var videoDuration = this.video.duration;
|
|
9589
9625
|
var contentDurationSeconds = (_content_contentDurationSeconds = content.contentDurationSeconds) !== null && _content_contentDurationSeconds !== void 0 ? _content_contentDurationSeconds : !isLive && Number.isFinite(videoDuration) && videoDuration > 0 ? Math.round(videoDuration) : void 0;
|
|
9590
|
-
var userId =
|
|
9626
|
+
var userId = envSignals.limitAdTracking === true ? void 0 : stayUserId;
|
|
9627
|
+
var ppid = toPpid(stayUserId, envSignals.limitAdTracking);
|
|
9591
9628
|
var ipAddress = resolveClientIp(this.config.clientIpAddress);
|
|
9592
9629
|
var userAgent2 = typeof navigator !== "undefined" && navigator.userAgent ? navigator.userAgent : void 0;
|
|
9593
9630
|
var macroContext = _object_spread(_object_spread_props(_object_spread(_object_spread_props(_object_spread({
|
|
@@ -9633,6 +9670,8 @@ var AdConfigManager = /*#__PURE__*/ function() {
|
|
|
9633
9670
|
ipAddress: ipAddress
|
|
9634
9671
|
} : {}, userId ? {
|
|
9635
9672
|
userId: userId
|
|
9673
|
+
} : {}, ppid ? {
|
|
9674
|
+
ppid: ppid
|
|
9636
9675
|
} : {}, content.contentType ? {
|
|
9637
9676
|
contentType: content.contentType
|
|
9638
9677
|
} : {}, content.contentCategory ? {
|
|
@@ -9680,6 +9719,7 @@ var AdConfigManager = /*#__PURE__*/ function() {
|
|
|
9680
9719
|
isLat: envSignals.limitAdTracking,
|
|
9681
9720
|
dth: envSignals.deviceTypeHint,
|
|
9682
9721
|
sidTail: envSignals.sessionId ? envSignals.sessionId.slice(-4) : void 0,
|
|
9722
|
+
ppidTail: ppid ? ppid.slice(-4) : void 0,
|
|
9683
9723
|
ct_ch: content.channelName,
|
|
9684
9724
|
ct_ti: content.programTitle,
|
|
9685
9725
|
ct_ne: content.contentNetwork,
|
|
@@ -14153,6 +14193,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
14153
14193
|
var _this_config_palContinuousPlayback, _this_config_lowLatencyMode, _this_config_palIconsSupported, _this_config_palSupportedApiFrameworks;
|
|
14154
14194
|
_this.adConfig.consentSignals = signals;
|
|
14155
14195
|
var muted = _this.video.muted;
|
|
14196
|
+
var palPpid = _this.currentPpid();
|
|
14156
14197
|
var palSessionId = _this.config.ctvAdRequest ? getOrRotateSessionId(_this.config.sessionIdMaxAgeMs) : void 0;
|
|
14157
14198
|
var palOptions = _object_spread({
|
|
14158
14199
|
videoWidth: _this.video.offsetWidth || _this.video.clientWidth || 640,
|
|
@@ -14169,9 +14210,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
14169
14210
|
allowStorage: signals.storageAllowed
|
|
14170
14211
|
} : {}, palSessionId ? {
|
|
14171
14212
|
sessionId: palSessionId
|
|
14213
|
+
} : {}, palPpid ? {
|
|
14214
|
+
ppid: palPpid
|
|
14172
14215
|
} : {});
|
|
14173
14216
|
_this.lastPalOptions = palOptions;
|
|
14174
14217
|
_this.palSessionId = palSessionId;
|
|
14218
|
+
_this.palPpid = palPpid;
|
|
14175
14219
|
_this.startPalNonceRefresh();
|
|
14176
14220
|
return _this.palNonce.generateNonce(palOptions);
|
|
14177
14221
|
}).catch(function() {});
|
|
@@ -14230,26 +14274,44 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
14230
14274
|
if (!options) return;
|
|
14231
14275
|
var maxAgeMs = (_this_config_palNonceMaxAgeMs = this.config.palNonceMaxAgeMs) !== null && _this_config_palNonceMaxAgeMs !== void 0 ? _this_config_palNonceMaxAgeMs : DEFAULT_PAL_NONCE_MAX_AGE_MS;
|
|
14232
14276
|
var ageMs = this.palNonce.getNonceAgeMs();
|
|
14277
|
+
var ppid = this.currentPpid();
|
|
14278
|
+
var ppidChanged = ppid !== this.palPpid;
|
|
14233
14279
|
var sessionId = this.config.ctvAdRequest ? getOrRotateSessionId(this.config.sessionIdMaxAgeMs) : void 0;
|
|
14234
14280
|
var sessionChanged = sessionId !== this.palSessionId;
|
|
14235
14281
|
var stale = ageMs === void 0 || ageMs >= maxAgeMs;
|
|
14236
|
-
if (!force && !stale && !sessionChanged) return;
|
|
14282
|
+
if (!force && !stale && !sessionChanged && !ppidChanged) return;
|
|
14237
14283
|
var next = _object_spread({}, options);
|
|
14238
14284
|
if (sessionId) next.sessionId = sessionId;
|
|
14239
14285
|
else delete next.sessionId;
|
|
14286
|
+
if (ppid) next.ppid = ppid;
|
|
14287
|
+
else delete next.ppid;
|
|
14240
14288
|
this.lastPalOptions = next;
|
|
14241
14289
|
this.palSessionId = sessionId;
|
|
14290
|
+
this.palPpid = ppid;
|
|
14242
14291
|
if (this.debug) {
|
|
14243
14292
|
console.log("[PAL] Regenerating nonce", {
|
|
14244
14293
|
force: force,
|
|
14245
14294
|
stale: stale,
|
|
14246
14295
|
sessionChanged: sessionChanged,
|
|
14296
|
+
ppidChanged: ppidChanged,
|
|
14247
14297
|
ageMs: ageMs
|
|
14248
14298
|
});
|
|
14249
14299
|
}
|
|
14250
14300
|
this.palNonce.generateNonce(next).catch(function() {});
|
|
14251
14301
|
}
|
|
14252
14302
|
},
|
|
14303
|
+
{
|
|
14304
|
+
key: "currentPpid",
|
|
14305
|
+
value: function currentPpid() {
|
|
14306
|
+
var userId = resolveUserId(this.config.adUserId);
|
|
14307
|
+
noteStayId(userId);
|
|
14308
|
+
var signals = resolveVastEnvironmentSignals(!!this.config.ctvAdRequest, {
|
|
14309
|
+
fallbackDeviceIdMaxAgeMs: this.config.fallbackDeviceIdMaxAgeMs,
|
|
14310
|
+
sessionIdMaxAgeMs: this.config.sessionIdMaxAgeMs
|
|
14311
|
+
});
|
|
14312
|
+
return toPpid(userId, signals.limitAdTracking);
|
|
14313
|
+
}
|
|
14314
|
+
},
|
|
14253
14315
|
{
|
|
14254
14316
|
key: "setAdIdentity",
|
|
14255
14317
|
value: function setAdIdentity(identity) {
|
|
@@ -14281,6 +14343,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
14281
14343
|
if (signals.ipAddress) this.config.clientIpAddress = signals.ipAddress;
|
|
14282
14344
|
else delete this.config.clientIpAddress;
|
|
14283
14345
|
}
|
|
14346
|
+
if (signals.userId !== void 0) this.refreshPalNonceIfStale();
|
|
14284
14347
|
}
|
|
14285
14348
|
},
|
|
14286
14349
|
{
|