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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * playkit-sdk v1.2.12
2
+ * playkit-sdk v1.2.13
3
3
  * PlayKit SDK for JavaScript
4
4
  * @license SEE LICENSE IN LICENSE
5
5
  */
@@ -2777,6 +2777,8 @@
2777
2777
  this.logger = Logger.getLogger('AuthManager');
2778
2778
  /** Shared promise for current device auth flow - allows multiple callers to await the same result */
2779
2779
  this.currentDeviceAuthFlowPromise = null;
2780
+ /** Shared promise for current auth flow (startAuthFlow) - allows multiple callers to await the same result */
2781
+ this.currentAuthFlowPromise = null;
2780
2782
  this.config = config;
2781
2783
  // Create TokenStorage with appropriate mode for server vs browser environment
2782
2784
  this.storage = new TokenStorage({
@@ -2885,12 +2887,27 @@
2885
2887
  * @deprecated 'headless' authentication is deprecated and will be removed in v2.0. Use 'device' instead.
2886
2888
  */
2887
2889
  async startAuthFlow(authMethod = 'device') {
2888
- var _a, _b;
2889
- if (this.authFlowManager || this.deviceAuthFlowManager) {
2890
- // Already in progress
2891
- this.logger.warn('Auth flow already in progress, ignoring duplicate call');
2892
- return;
2890
+ // If a flow is already in progress, return the shared promise so all callers await the same result
2891
+ if (this.currentAuthFlowPromise) {
2892
+ this.logger.debug('Auth flow already in progress, waiting for existing flow');
2893
+ return this.currentAuthFlowPromise;
2893
2894
  }
2895
+ // Store the flow promise so subsequent calls can await the same result
2896
+ const flowPromise = this.executeAuthFlow(authMethod);
2897
+ this.currentAuthFlowPromise = flowPromise;
2898
+ try {
2899
+ return await flowPromise;
2900
+ }
2901
+ finally {
2902
+ this.currentAuthFlowPromise = null;
2903
+ }
2904
+ }
2905
+ /**
2906
+ * Internal method that executes the actual auth flow
2907
+ * @private
2908
+ */
2909
+ async executeAuthFlow(authMethod = 'device') {
2910
+ var _a, _b;
2894
2911
  // Deprecation warning for headless auth
2895
2912
  if (authMethod === 'headless') {
2896
2913
  this.logger.warn('"headless" authentication is deprecated and will be removed in v2.0. ' +