playkit-sdk 1.2.12 → 1.2.13
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/playkit-sdk.cjs.js +23 -6
- package/dist/playkit-sdk.cjs.js.map +1 -1
- package/dist/playkit-sdk.d.ts +7 -0
- package/dist/playkit-sdk.esm.js +23 -6
- package/dist/playkit-sdk.esm.js.map +1 -1
- package/dist/playkit-sdk.umd.js +23 -6
- package/dist/playkit-sdk.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/playkit-sdk.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* playkit-sdk v1.2.
|
|
2
|
+
* playkit-sdk v1.2.13
|
|
3
3
|
* PlayKit SDK for JavaScript
|
|
4
4
|
* @license SEE LICENSE IN LICENSE
|
|
5
5
|
*/
|
|
@@ -2430,6 +2430,8 @@ class AuthManager extends EventEmitter {
|
|
|
2430
2430
|
this.logger = Logger.getLogger('AuthManager');
|
|
2431
2431
|
/** Shared promise for current device auth flow - allows multiple callers to await the same result */
|
|
2432
2432
|
this.currentDeviceAuthFlowPromise = null;
|
|
2433
|
+
/** Shared promise for current auth flow (startAuthFlow) - allows multiple callers to await the same result */
|
|
2434
|
+
this.currentAuthFlowPromise = null;
|
|
2433
2435
|
this.config = config;
|
|
2434
2436
|
// Create TokenStorage with appropriate mode for server vs browser environment
|
|
2435
2437
|
this.storage = new TokenStorage({
|
|
@@ -2538,12 +2540,27 @@ class AuthManager extends EventEmitter {
|
|
|
2538
2540
|
* @deprecated 'headless' authentication is deprecated and will be removed in v2.0. Use 'device' instead.
|
|
2539
2541
|
*/
|
|
2540
2542
|
async startAuthFlow(authMethod = 'device') {
|
|
2541
|
-
|
|
2542
|
-
if (this.
|
|
2543
|
-
|
|
2544
|
-
this.
|
|
2545
|
-
return;
|
|
2543
|
+
// If a flow is already in progress, return the shared promise so all callers await the same result
|
|
2544
|
+
if (this.currentAuthFlowPromise) {
|
|
2545
|
+
this.logger.debug('Auth flow already in progress, waiting for existing flow');
|
|
2546
|
+
return this.currentAuthFlowPromise;
|
|
2546
2547
|
}
|
|
2548
|
+
// Store the flow promise so subsequent calls can await the same result
|
|
2549
|
+
const flowPromise = this.executeAuthFlow(authMethod);
|
|
2550
|
+
this.currentAuthFlowPromise = flowPromise;
|
|
2551
|
+
try {
|
|
2552
|
+
return await flowPromise;
|
|
2553
|
+
}
|
|
2554
|
+
finally {
|
|
2555
|
+
this.currentAuthFlowPromise = null;
|
|
2556
|
+
}
|
|
2557
|
+
}
|
|
2558
|
+
/**
|
|
2559
|
+
* Internal method that executes the actual auth flow
|
|
2560
|
+
* @private
|
|
2561
|
+
*/
|
|
2562
|
+
async executeAuthFlow(authMethod = 'device') {
|
|
2563
|
+
var _a, _b;
|
|
2547
2564
|
// Deprecation warning for headless auth
|
|
2548
2565
|
if (authMethod === 'headless') {
|
|
2549
2566
|
this.logger.warn('"headless" authentication is deprecated and will be removed in v2.0. ' +
|