@codenkay/video-nsgplayer-core 2.0.0 → 3.0.0
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/CHANGELOG.md +12 -0
- package/dist/index.cjs +51 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +51 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 3.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- Fix minor issues
|
|
8
|
+
|
|
9
|
+
## 2.0.1
|
|
10
|
+
|
|
11
|
+
- Auto-wire `AuthManager.getAccessToken()` as default `streaming.getKeyAccessToken` so AES `enc.key` can load with Bearer when no BFF key proxy is configured.
|
|
12
|
+
- When `keyProxyUrlBuilder` returns 401/403/502/CORS (e.g. Cloudflare-blocked BFF), automatically fall back to browser Bearer `enc.key` fetch.
|
|
13
|
+
- On Bearer `enc.key` fetch network/CORS failure, fall back to signed-query XHR (CDN hosts).
|
|
14
|
+
|
|
3
15
|
## 2.0.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/dist/index.cjs
CHANGED
|
@@ -212,7 +212,7 @@ var AuthManager = class {
|
|
|
212
212
|
|
|
213
213
|
// src/config/defaults.ts
|
|
214
214
|
var PLAYBACK_RATES = [0.5, 0.75, 1, 1.25, 1.5, 2];
|
|
215
|
-
var PACKAGE_VERSION = "0.1
|
|
215
|
+
var PACKAGE_VERSION = "2.0.1";
|
|
216
216
|
var DEFAULT_PLAYER_BEHAVIOR = {
|
|
217
217
|
autoplay: true,
|
|
218
218
|
startMuted: true,
|
|
@@ -981,9 +981,48 @@ function createAuthParamsLoader(HlsClass, store, options = {}) {
|
|
|
981
981
|
const usingKeyProxy = Boolean(
|
|
982
982
|
isKey && options.keyProxyUrlBuilder && options.videoId
|
|
983
983
|
);
|
|
984
|
+
const signedKeyUrl = isKey ? rewriteHlsRequestUrl(originalUrl, store, {
|
|
985
|
+
...options,
|
|
986
|
+
keyProxyUrlBuilder: void 0
|
|
987
|
+
}) : context.url;
|
|
984
988
|
context.url = rewriteHlsRequestUrl(originalUrl, store, options);
|
|
985
989
|
if (usingKeyProxy) {
|
|
986
|
-
|
|
990
|
+
const accessToken = options.getKeyAccessToken?.() ?? null;
|
|
991
|
+
if (!accessToken) {
|
|
992
|
+
this.inner.load(context, config, callbacks);
|
|
993
|
+
return;
|
|
994
|
+
}
|
|
995
|
+
const proxyCallbacks = {
|
|
996
|
+
...callbacks,
|
|
997
|
+
onError: (error, errContext, networkDetails, stats) => {
|
|
998
|
+
const code = error?.code;
|
|
999
|
+
const retryable = code === 0 || code === 502 || code === 403 || code === 401 || /Cloudflare|HTML|DOCTYPE|blocked/i.test(error?.text ?? "");
|
|
1000
|
+
if (!retryable) {
|
|
1001
|
+
callbacks.onError(error, errContext, networkDetails, stats);
|
|
1002
|
+
return;
|
|
1003
|
+
}
|
|
1004
|
+
this.keyAbort?.abort();
|
|
1005
|
+
this.keyAbort = new AbortController();
|
|
1006
|
+
const bearerContext = { ...context, url: signedKeyUrl };
|
|
1007
|
+
void loadEncryptionKeyWithFetch(
|
|
1008
|
+
bearerContext,
|
|
1009
|
+
callbacks,
|
|
1010
|
+
accessToken,
|
|
1011
|
+
this.keyAbort.signal
|
|
1012
|
+
).catch((fetchError) => {
|
|
1013
|
+
callbacks.onError(
|
|
1014
|
+
{
|
|
1015
|
+
code: 0,
|
|
1016
|
+
text: fetchError instanceof Error ? fetchError.message : error.text || "enc.key proxy and Bearer fetch failed"
|
|
1017
|
+
},
|
|
1018
|
+
bearerContext,
|
|
1019
|
+
null,
|
|
1020
|
+
stats
|
|
1021
|
+
);
|
|
1022
|
+
});
|
|
1023
|
+
}
|
|
1024
|
+
};
|
|
1025
|
+
this.inner.load(context, config, proxyCallbacks);
|
|
987
1026
|
return;
|
|
988
1027
|
}
|
|
989
1028
|
if (isKey && typeof options.getKeyAccessToken === "function") {
|
|
@@ -1001,6 +1040,10 @@ function createAuthParamsLoader(HlsClass, store, options = {}) {
|
|
|
1001
1040
|
).catch((error) => {
|
|
1002
1041
|
const stats = createLoaderStats();
|
|
1003
1042
|
const aborted = error instanceof DOMException && error.name === "AbortError";
|
|
1043
|
+
if (!aborted && (error instanceof TypeError || error instanceof Error && /Failed to fetch|NetworkError|CORS/i.test(error.message))) {
|
|
1044
|
+
this.inner.load(context, config, callbacks);
|
|
1045
|
+
return;
|
|
1046
|
+
}
|
|
1004
1047
|
callbacks.onError(
|
|
1005
1048
|
{
|
|
1006
1049
|
code: 0,
|
|
@@ -1509,12 +1552,11 @@ function createVideoPlayer(options) {
|
|
|
1509
1552
|
volume: config.player.volume,
|
|
1510
1553
|
videoId: options.videoId,
|
|
1511
1554
|
keyProxyUrlBuilder: config.streaming.keyProxyUrlBuilder,
|
|
1512
|
-
//
|
|
1513
|
-
//
|
|
1514
|
-
//
|
|
1515
|
-
//
|
|
1516
|
-
|
|
1517
|
-
getKeyAccessToken: config.streaming.getKeyAccessToken,
|
|
1555
|
+
// Enterprise AES key auth:
|
|
1556
|
+
// 1) keyProxyUrlBuilder (same-origin BFF) when configured
|
|
1557
|
+
// 2) else getKeyAccessToken / AuthManager Bearer via browser fetch
|
|
1558
|
+
// 3) else signed query + XHR (CDN hosts)
|
|
1559
|
+
getKeyAccessToken: config.streaming.getKeyAccessToken ?? (() => authManager.getAccessToken()),
|
|
1518
1560
|
hlsConfig: config.streaming.hls,
|
|
1519
1561
|
logger,
|
|
1520
1562
|
callbacks: {
|
|
@@ -1832,7 +1874,7 @@ function createVideoPlayer(options) {
|
|
|
1832
1874
|
engine: "hls",
|
|
1833
1875
|
hls: { ...config.streaming.hls, ...partial?.streaming?.hls },
|
|
1834
1876
|
keyProxyUrlBuilder: partial?.streaming?.keyProxyUrlBuilder ?? config.streaming.keyProxyUrlBuilder,
|
|
1835
|
-
getKeyAccessToken: partial?.streaming?.getKeyAccessToken ?? config.streaming.getKeyAccessToken
|
|
1877
|
+
getKeyAccessToken: partial?.streaming?.getKeyAccessToken ?? config.streaming.getKeyAccessToken ?? (() => authManager.getAccessToken())
|
|
1836
1878
|
},
|
|
1837
1879
|
logging: { ...config.logging, ...partial?.logging },
|
|
1838
1880
|
debug: { ...config.debug, ...partial?.debug },
|