@codenkay/video-nsgplayer-core 3.0.0 → 3.0.2

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.cts CHANGED
@@ -151,6 +151,12 @@ type StreamingConfig = {
151
151
  * Use when the BFF cannot reach Appextech (Cloudflare challenge on server IP).
152
152
  */
153
153
  getKeyAccessToken?: () => string | null | undefined;
154
+ /**
155
+ * Max same-origin key-proxy failures before the session permanently switches
156
+ * to browser Bearer / signed-query (default 2). Prevents hls.js from hammering
157
+ * a Cloudflare-blocked BFF (9–10× 502s).
158
+ */
159
+ keyProxyMaxFailures?: number;
154
160
  };
155
161
  type LoggingConfig = {
156
162
  enabled?: boolean;
@@ -198,6 +204,7 @@ type PlayerConfig = Required<{
198
204
  hls: Required<NonNullable<StreamingConfig["hls"]>>;
199
205
  keyProxyUrlBuilder?: StreamingConfig["keyProxyUrlBuilder"];
200
206
  getKeyAccessToken?: StreamingConfig["getKeyAccessToken"];
207
+ keyProxyMaxFailures?: StreamingConfig["keyProxyMaxFailures"];
201
208
  };
202
209
  logging: Required<LoggingConfig>;
203
210
  debug: Required<DebugConfig>;
@@ -279,7 +286,7 @@ type PlayerEventMap = {
279
286
  };
280
287
 
281
288
  declare const PLAYBACK_RATES: readonly [0.5, 0.75, 1, 1.25, 1.5, 2];
282
- declare const PACKAGE_VERSION = "2.0.1";
289
+ declare const PACKAGE_VERSION = "3.0.2";
283
290
  declare const DEFAULT_PLAYER_BEHAVIOR: Required<PlayerBehaviorConfig>;
284
291
  declare const DEFAULT_CONTROLS: Required<ControlsConfig>;
285
292
  declare const DEFAULT_THEME: Required<ThemeConfig>;
@@ -312,6 +319,7 @@ type PlayerConfigPartial = Partial<{
312
319
  hls?: Partial<PlayerConfig["streaming"]["hls"]>;
313
320
  keyProxyUrlBuilder?: PlayerConfig["streaming"]["keyProxyUrlBuilder"];
314
321
  getKeyAccessToken?: PlayerConfig["streaming"]["getKeyAccessToken"];
322
+ keyProxyMaxFailures?: PlayerConfig["streaming"]["keyProxyMaxFailures"];
315
323
  };
316
324
  logging: Partial<PlayerConfig["logging"]>;
317
325
  debug: Partial<PlayerConfig["debug"]>;
@@ -431,6 +439,7 @@ type HlsEngineOptions = {
431
439
  videoId?: string;
432
440
  keyProxyUrlBuilder?: StreamingConfig["keyProxyUrlBuilder"];
433
441
  getKeyAccessToken?: StreamingConfig["getKeyAccessToken"];
442
+ keyProxyMaxFailures?: StreamingConfig["keyProxyMaxFailures"];
434
443
  hlsConfig: {
435
444
  enableWorker: boolean;
436
445
  lowLatencyMode: boolean;
@@ -447,7 +456,8 @@ type HlsEngineOptions = {
447
456
  * (playlists, segments, and AES `enc.key` on CDN hosts).
448
457
  *
449
458
  * Optional `streaming.keyProxyUrlBuilder` (same-origin BFF) or
450
- * `streaming.getKeyAccessToken` (browser Bearer) for Video API–origin keys
459
+ * `streaming.getKeyAccessToken` (Bearer only after signed-query 401/403).
460
+ * CDN keys prefer signed query without Authorization (no CORS preflight).
451
461
  * when query-signed CDN access is insufficient.
452
462
  */
453
463
  declare class HlsEngine {
@@ -646,44 +656,37 @@ declare class RefreshManager {
646
656
 
647
657
  type HlsLoaderInstance = {
648
658
  stats: LoaderStats;
659
+ context: LoaderContext | null;
649
660
  load(context: LoaderContext, config: LoaderConfiguration, callbacks: LoaderCallbacks<LoaderContext>): void;
650
661
  destroy(): void;
651
- abort?: () => void;
662
+ abort(): void;
652
663
  };
653
- type HlsLoader = new (config: object) => HlsLoaderInstance;
664
+ /** Constructor shape compatible with `Hls.DefaultConfig.loader`. */
665
+ type HlsLoaderConstructor = new (config: object) => HlsLoaderInstance;
666
+ /** Max same-origin BFF key attempts before the session circuit opens. */
667
+ declare const KEY_PROXY_MAX_FAILURES = 2;
654
668
  type AuthParamsLoaderOptions = {
655
669
  videoId?: string;
656
670
  keyProxyUrlBuilder?: StreamingConfig["keyProxyUrlBuilder"];
657
671
  getKeyAccessToken?: StreamingConfig["getKeyAccessToken"];
672
+ /** Override max BFF key failures before permanent browser fallback (default 2). */
673
+ keyProxyMaxFailures?: number;
658
674
  };
659
675
  declare function isEncryptionKeyUrl(rawUrl: string, baseOrigin?: string): boolean;
660
676
  /**
661
- * Always resolve a builtin hls.js loader (XhrLoader).
662
- *
663
- * Never trust `Hls.DefaultConfig.loader` alone — if it was reassigned to a
664
- * custom wrapper, `extends` / nested `inner.load()` chains blow Firefox's
665
- * stack (`InternalError: too much recursion`).
677
+ * Resolve the builtin loader from the **same** `hls.js` module instance the
678
+ * engine loaded. Never statically import `XhrLoader` — that can pull a second
679
+ * hls.js copy into the app bundle after npm pack/publish and break key loads.
666
680
  */
667
- declare function resolveBuiltinHlsLoader(HlsClass: typeof Hls): HlsLoader;
681
+ declare function resolveBuiltinHlsLoader(HlsClass: typeof Hls): HlsLoaderConstructor;
668
682
  /**
669
683
  * Rewrites an HLS request URL so signed auth query params are present.
670
- *
671
- * AES `enc.key` handling (enterprise priority order):
672
- * 1. `keyProxyUrlBuilder` — same-origin BFF (production; server IP must pass CDN/WAF)
673
- * 2. Otherwise keep CDN/API URL and apply signed `token`/`expires` (and related) query
674
- * params — same auth model as segments on Appextech CDN hosts
675
- * 3. Optional `getKeyAccessToken` is applied at load-time (Bearer), not in this rewrite
676
684
  */
677
685
  declare function rewriteHlsRequestUrl(rawUrl: string, store: AuthParamsStore, options?: AuthParamsLoaderOptions, baseOrigin?: string): string;
678
686
  /**
679
- * hls.js loader that:
680
- * - Re-applies signed auth query params on every media request
681
- * - Loads AES `enc.key` via BFF / optional Bearer fetch / signed-query XHR
682
- *
683
- * Uses composition (not `extends DefaultConfig.loader`) so repeated mounts,
684
- * HMR, or a polluted DefaultConfig cannot nest `super.load()` into recursion.
687
+ * hls.js loader: auth query rewrite + enterprise AES key loading.
685
688
  */
686
- declare function createAuthParamsLoader(HlsClass: typeof Hls, store: AuthParamsStore, options?: AuthParamsLoaderOptions): HlsLoader;
689
+ declare function createAuthParamsLoader(HlsClass: typeof Hls, store: AuthParamsStore, options?: AuthParamsLoaderOptions): HlsLoaderConstructor;
687
690
 
688
691
  declare function redactValue(key: string, value: unknown, seen?: WeakSet<object>, depth?: number): unknown;
689
692
  /**
@@ -692,4 +695,4 @@ declare function redactValue(key: string, value: unknown, seen?: WeakSet<object>
692
695
  */
693
696
  declare function redactObject(obj: Record<string, unknown>, seen?: WeakSet<object>, depth?: number): Record<string, unknown>;
694
697
 
695
- export { type AccessibilityConfig, type AnalyticsConfig, type AuthConfig, AuthManager, AuthParamsStore, type AuthToken, type AuthTokenProviderContext, type BufferedRange, type ControlsConfig, type CreateVideoPlayerOptions, DEFAULT_CONTROLS, DEFAULT_LIVE_EDGE_TOLERANCE_SECONDS, DEFAULT_PLAYER_BEHAVIOR, DEFAULT_PLAYER_CONFIG, DEFAULT_THEME, DEFAULT_WATERMARK, type DebugConfig, EventEmitter, type HlsQualityLevel, type HlsSupportMode, type LiveMediaSnapshot, type LoggingConfig, PACKAGE_VERSION, PLAYBACK_RATES, type PlayIconPreset, type PlaybackCredentialConfig, type PlaybackRate, type PlaybackSource, type PlaybackSourceContext, PlaybackSourceManager, type PlayerAudioTrack, type PlayerBehaviorConfig, type PlayerConfig, type PlayerDiagnostics, type PlayerError, PlayerErrorCode, type PlayerEventMap, type PlayerSkipSeconds, type PlayerState, type PlayerTextTrack, type PlayerZoomLevel, type QualitySelection, RefreshManager, SECRET_SCAN_MAX_DEPTH, type SeekToLiveResult, type StreamingConfig, type TextTrackSelection, type ThemeConfig, type VideoPlayer, type WatermarkConfig, assertNoSecretsInConfig, createAuthParamsLoader, createPlayerError, createVideoPlayer, getLiveEdgeTime, isAtLiveEdge, isEncryptionKeyUrl, isPlainObject, mergePlayerConfig, redactObject, redactSensitive, redactValue, resolveBuiltinHlsLoader, rewriteHlsRequestUrl, seekToLiveEdge, themeToCssVars };
698
+ export { type AccessibilityConfig, type AnalyticsConfig, type AuthConfig, AuthManager, AuthParamsStore, type AuthToken, type AuthTokenProviderContext, type BufferedRange, type ControlsConfig, type CreateVideoPlayerOptions, DEFAULT_CONTROLS, DEFAULT_LIVE_EDGE_TOLERANCE_SECONDS, DEFAULT_PLAYER_BEHAVIOR, DEFAULT_PLAYER_CONFIG, DEFAULT_THEME, DEFAULT_WATERMARK, type DebugConfig, EventEmitter, type HlsQualityLevel, type HlsSupportMode, KEY_PROXY_MAX_FAILURES, type LiveMediaSnapshot, type LoggingConfig, PACKAGE_VERSION, PLAYBACK_RATES, type PlayIconPreset, type PlaybackCredentialConfig, type PlaybackRate, type PlaybackSource, type PlaybackSourceContext, PlaybackSourceManager, type PlayerAudioTrack, type PlayerBehaviorConfig, type PlayerConfig, type PlayerDiagnostics, type PlayerError, PlayerErrorCode, type PlayerEventMap, type PlayerSkipSeconds, type PlayerState, type PlayerTextTrack, type PlayerZoomLevel, type QualitySelection, RefreshManager, SECRET_SCAN_MAX_DEPTH, type SeekToLiveResult, type StreamingConfig, type TextTrackSelection, type ThemeConfig, type VideoPlayer, type WatermarkConfig, assertNoSecretsInConfig, createAuthParamsLoader, createPlayerError, createVideoPlayer, getLiveEdgeTime, isAtLiveEdge, isEncryptionKeyUrl, isPlainObject, mergePlayerConfig, redactObject, redactSensitive, redactValue, resolveBuiltinHlsLoader, rewriteHlsRequestUrl, seekToLiveEdge, themeToCssVars };
package/dist/index.d.ts CHANGED
@@ -151,6 +151,12 @@ type StreamingConfig = {
151
151
  * Use when the BFF cannot reach Appextech (Cloudflare challenge on server IP).
152
152
  */
153
153
  getKeyAccessToken?: () => string | null | undefined;
154
+ /**
155
+ * Max same-origin key-proxy failures before the session permanently switches
156
+ * to browser Bearer / signed-query (default 2). Prevents hls.js from hammering
157
+ * a Cloudflare-blocked BFF (9–10× 502s).
158
+ */
159
+ keyProxyMaxFailures?: number;
154
160
  };
155
161
  type LoggingConfig = {
156
162
  enabled?: boolean;
@@ -198,6 +204,7 @@ type PlayerConfig = Required<{
198
204
  hls: Required<NonNullable<StreamingConfig["hls"]>>;
199
205
  keyProxyUrlBuilder?: StreamingConfig["keyProxyUrlBuilder"];
200
206
  getKeyAccessToken?: StreamingConfig["getKeyAccessToken"];
207
+ keyProxyMaxFailures?: StreamingConfig["keyProxyMaxFailures"];
201
208
  };
202
209
  logging: Required<LoggingConfig>;
203
210
  debug: Required<DebugConfig>;
@@ -279,7 +286,7 @@ type PlayerEventMap = {
279
286
  };
280
287
 
281
288
  declare const PLAYBACK_RATES: readonly [0.5, 0.75, 1, 1.25, 1.5, 2];
282
- declare const PACKAGE_VERSION = "2.0.1";
289
+ declare const PACKAGE_VERSION = "3.0.2";
283
290
  declare const DEFAULT_PLAYER_BEHAVIOR: Required<PlayerBehaviorConfig>;
284
291
  declare const DEFAULT_CONTROLS: Required<ControlsConfig>;
285
292
  declare const DEFAULT_THEME: Required<ThemeConfig>;
@@ -312,6 +319,7 @@ type PlayerConfigPartial = Partial<{
312
319
  hls?: Partial<PlayerConfig["streaming"]["hls"]>;
313
320
  keyProxyUrlBuilder?: PlayerConfig["streaming"]["keyProxyUrlBuilder"];
314
321
  getKeyAccessToken?: PlayerConfig["streaming"]["getKeyAccessToken"];
322
+ keyProxyMaxFailures?: PlayerConfig["streaming"]["keyProxyMaxFailures"];
315
323
  };
316
324
  logging: Partial<PlayerConfig["logging"]>;
317
325
  debug: Partial<PlayerConfig["debug"]>;
@@ -431,6 +439,7 @@ type HlsEngineOptions = {
431
439
  videoId?: string;
432
440
  keyProxyUrlBuilder?: StreamingConfig["keyProxyUrlBuilder"];
433
441
  getKeyAccessToken?: StreamingConfig["getKeyAccessToken"];
442
+ keyProxyMaxFailures?: StreamingConfig["keyProxyMaxFailures"];
434
443
  hlsConfig: {
435
444
  enableWorker: boolean;
436
445
  lowLatencyMode: boolean;
@@ -447,7 +456,8 @@ type HlsEngineOptions = {
447
456
  * (playlists, segments, and AES `enc.key` on CDN hosts).
448
457
  *
449
458
  * Optional `streaming.keyProxyUrlBuilder` (same-origin BFF) or
450
- * `streaming.getKeyAccessToken` (browser Bearer) for Video API–origin keys
459
+ * `streaming.getKeyAccessToken` (Bearer only after signed-query 401/403).
460
+ * CDN keys prefer signed query without Authorization (no CORS preflight).
451
461
  * when query-signed CDN access is insufficient.
452
462
  */
453
463
  declare class HlsEngine {
@@ -646,44 +656,37 @@ declare class RefreshManager {
646
656
 
647
657
  type HlsLoaderInstance = {
648
658
  stats: LoaderStats;
659
+ context: LoaderContext | null;
649
660
  load(context: LoaderContext, config: LoaderConfiguration, callbacks: LoaderCallbacks<LoaderContext>): void;
650
661
  destroy(): void;
651
- abort?: () => void;
662
+ abort(): void;
652
663
  };
653
- type HlsLoader = new (config: object) => HlsLoaderInstance;
664
+ /** Constructor shape compatible with `Hls.DefaultConfig.loader`. */
665
+ type HlsLoaderConstructor = new (config: object) => HlsLoaderInstance;
666
+ /** Max same-origin BFF key attempts before the session circuit opens. */
667
+ declare const KEY_PROXY_MAX_FAILURES = 2;
654
668
  type AuthParamsLoaderOptions = {
655
669
  videoId?: string;
656
670
  keyProxyUrlBuilder?: StreamingConfig["keyProxyUrlBuilder"];
657
671
  getKeyAccessToken?: StreamingConfig["getKeyAccessToken"];
672
+ /** Override max BFF key failures before permanent browser fallback (default 2). */
673
+ keyProxyMaxFailures?: number;
658
674
  };
659
675
  declare function isEncryptionKeyUrl(rawUrl: string, baseOrigin?: string): boolean;
660
676
  /**
661
- * Always resolve a builtin hls.js loader (XhrLoader).
662
- *
663
- * Never trust `Hls.DefaultConfig.loader` alone — if it was reassigned to a
664
- * custom wrapper, `extends` / nested `inner.load()` chains blow Firefox's
665
- * stack (`InternalError: too much recursion`).
677
+ * Resolve the builtin loader from the **same** `hls.js` module instance the
678
+ * engine loaded. Never statically import `XhrLoader` — that can pull a second
679
+ * hls.js copy into the app bundle after npm pack/publish and break key loads.
666
680
  */
667
- declare function resolveBuiltinHlsLoader(HlsClass: typeof Hls): HlsLoader;
681
+ declare function resolveBuiltinHlsLoader(HlsClass: typeof Hls): HlsLoaderConstructor;
668
682
  /**
669
683
  * Rewrites an HLS request URL so signed auth query params are present.
670
- *
671
- * AES `enc.key` handling (enterprise priority order):
672
- * 1. `keyProxyUrlBuilder` — same-origin BFF (production; server IP must pass CDN/WAF)
673
- * 2. Otherwise keep CDN/API URL and apply signed `token`/`expires` (and related) query
674
- * params — same auth model as segments on Appextech CDN hosts
675
- * 3. Optional `getKeyAccessToken` is applied at load-time (Bearer), not in this rewrite
676
684
  */
677
685
  declare function rewriteHlsRequestUrl(rawUrl: string, store: AuthParamsStore, options?: AuthParamsLoaderOptions, baseOrigin?: string): string;
678
686
  /**
679
- * hls.js loader that:
680
- * - Re-applies signed auth query params on every media request
681
- * - Loads AES `enc.key` via BFF / optional Bearer fetch / signed-query XHR
682
- *
683
- * Uses composition (not `extends DefaultConfig.loader`) so repeated mounts,
684
- * HMR, or a polluted DefaultConfig cannot nest `super.load()` into recursion.
687
+ * hls.js loader: auth query rewrite + enterprise AES key loading.
685
688
  */
686
- declare function createAuthParamsLoader(HlsClass: typeof Hls, store: AuthParamsStore, options?: AuthParamsLoaderOptions): HlsLoader;
689
+ declare function createAuthParamsLoader(HlsClass: typeof Hls, store: AuthParamsStore, options?: AuthParamsLoaderOptions): HlsLoaderConstructor;
687
690
 
688
691
  declare function redactValue(key: string, value: unknown, seen?: WeakSet<object>, depth?: number): unknown;
689
692
  /**
@@ -692,4 +695,4 @@ declare function redactValue(key: string, value: unknown, seen?: WeakSet<object>
692
695
  */
693
696
  declare function redactObject(obj: Record<string, unknown>, seen?: WeakSet<object>, depth?: number): Record<string, unknown>;
694
697
 
695
- export { type AccessibilityConfig, type AnalyticsConfig, type AuthConfig, AuthManager, AuthParamsStore, type AuthToken, type AuthTokenProviderContext, type BufferedRange, type ControlsConfig, type CreateVideoPlayerOptions, DEFAULT_CONTROLS, DEFAULT_LIVE_EDGE_TOLERANCE_SECONDS, DEFAULT_PLAYER_BEHAVIOR, DEFAULT_PLAYER_CONFIG, DEFAULT_THEME, DEFAULT_WATERMARK, type DebugConfig, EventEmitter, type HlsQualityLevel, type HlsSupportMode, type LiveMediaSnapshot, type LoggingConfig, PACKAGE_VERSION, PLAYBACK_RATES, type PlayIconPreset, type PlaybackCredentialConfig, type PlaybackRate, type PlaybackSource, type PlaybackSourceContext, PlaybackSourceManager, type PlayerAudioTrack, type PlayerBehaviorConfig, type PlayerConfig, type PlayerDiagnostics, type PlayerError, PlayerErrorCode, type PlayerEventMap, type PlayerSkipSeconds, type PlayerState, type PlayerTextTrack, type PlayerZoomLevel, type QualitySelection, RefreshManager, SECRET_SCAN_MAX_DEPTH, type SeekToLiveResult, type StreamingConfig, type TextTrackSelection, type ThemeConfig, type VideoPlayer, type WatermarkConfig, assertNoSecretsInConfig, createAuthParamsLoader, createPlayerError, createVideoPlayer, getLiveEdgeTime, isAtLiveEdge, isEncryptionKeyUrl, isPlainObject, mergePlayerConfig, redactObject, redactSensitive, redactValue, resolveBuiltinHlsLoader, rewriteHlsRequestUrl, seekToLiveEdge, themeToCssVars };
698
+ export { type AccessibilityConfig, type AnalyticsConfig, type AuthConfig, AuthManager, AuthParamsStore, type AuthToken, type AuthTokenProviderContext, type BufferedRange, type ControlsConfig, type CreateVideoPlayerOptions, DEFAULT_CONTROLS, DEFAULT_LIVE_EDGE_TOLERANCE_SECONDS, DEFAULT_PLAYER_BEHAVIOR, DEFAULT_PLAYER_CONFIG, DEFAULT_THEME, DEFAULT_WATERMARK, type DebugConfig, EventEmitter, type HlsQualityLevel, type HlsSupportMode, KEY_PROXY_MAX_FAILURES, type LiveMediaSnapshot, type LoggingConfig, PACKAGE_VERSION, PLAYBACK_RATES, type PlayIconPreset, type PlaybackCredentialConfig, type PlaybackRate, type PlaybackSource, type PlaybackSourceContext, PlaybackSourceManager, type PlayerAudioTrack, type PlayerBehaviorConfig, type PlayerConfig, type PlayerDiagnostics, type PlayerError, PlayerErrorCode, type PlayerEventMap, type PlayerSkipSeconds, type PlayerState, type PlayerTextTrack, type PlayerZoomLevel, type QualitySelection, RefreshManager, SECRET_SCAN_MAX_DEPTH, type SeekToLiveResult, type StreamingConfig, type TextTrackSelection, type ThemeConfig, type VideoPlayer, type WatermarkConfig, assertNoSecretsInConfig, createAuthParamsLoader, createPlayerError, createVideoPlayer, getLiveEdgeTime, isAtLiveEdge, isEncryptionKeyUrl, isPlainObject, mergePlayerConfig, redactObject, redactSensitive, redactValue, resolveBuiltinHlsLoader, rewriteHlsRequestUrl, seekToLiveEdge, themeToCssVars };