@mastra/auth-cloud 1.2.2 → 1.2.3-alpha.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/dist/index.js CHANGED
@@ -615,7 +615,7 @@ var MastraBase = class {
615
615
  }
616
616
  };
617
617
 
618
- // ../../packages/_internals/auth/dist/chunk-7GLKLOU3.js
618
+ // ../../packages/_internals/auth/dist/chunk-NJOKT6V5.js
619
619
  var MastraAuthProvider = class extends MastraBase {
620
620
  protected;
621
621
  public;
@@ -725,10 +725,11 @@ var MastraCloudAuthProvider = class extends MastraAuthProvider {
725
725
  // ISSOProvider Implementation
726
726
  // ============================================================================
727
727
  /**
728
- * Cached login result for getLoginCookies() to retrieve cookies.
728
+ * Cached login results for getLoginCookies() to retrieve cookies.
729
+ * Keyed by the OAuth state parameter to prevent race conditions.
729
730
  * @internal
730
731
  */
731
- _lastLoginResult = null;
732
+ _loginResults = /* @__PURE__ */ new Map();
732
733
  /**
733
734
  * Get URL to redirect user to for SSO login.
734
735
  *
@@ -755,19 +756,28 @@ var MastraCloudAuthProvider = class extends MastraAuthProvider {
755
756
  returnTo: postLoginRedirect,
756
757
  requestOrigin: origin
757
758
  });
758
- this._lastLoginResult = result;
759
+ if (this._loginResults.size > 100) {
760
+ const firstKey = this._loginResults.keys().next().value;
761
+ if (firstKey) this._loginResults.delete(firstKey);
762
+ }
763
+ this._loginResults.set(state, result);
759
764
  return result.url;
760
765
  }
761
766
  /**
762
767
  * Get cookies to set during login redirect (PKCE verifier).
763
768
  * Must be called after getLoginUrl() in same request.
764
769
  *
770
+ * @param _redirectUri - OAuth callback URL
771
+ * @param state - State parameter
765
772
  * @returns Array of Set-Cookie header values
766
773
  */
767
- getLoginCookies() {
768
- const cookies = this._lastLoginResult?.cookies;
769
- this._lastLoginResult = null;
770
- return cookies;
774
+ getLoginCookies(_redirectUri, state) {
775
+ const result = this._loginResults.get(state);
776
+ if (result) {
777
+ this._loginResults.delete(state);
778
+ return result.cookies;
779
+ }
780
+ return void 0;
771
781
  }
772
782
  /**
773
783
  * Handle OAuth callback, exchange code for tokens and user.
@@ -934,7 +944,7 @@ var MastraCloudAuthProvider = class extends MastraAuthProvider {
934
944
  }
935
945
  };
936
946
 
937
- // ../../packages/_internals/auth/dist/chunk-GVS7OL46.js
947
+ // ../../packages/_internals/auth/dist/chunk-LZCWL5CT.js
938
948
  var RESOURCE_EXPANSIONS = {
939
949
  stored: [
940
950
  "stored-agents",