@sparkvault/sdk-js 1.27.4 → 1.27.5

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.
@@ -1160,11 +1160,24 @@ class IdentityApi extends SparkVaultApi {
1160
1160
  /**
1161
1161
  * Get OAuth redirect URL for social provider
1162
1162
  */
1163
- getSocialAuthUrl(provider, redirectUri, state) {
1163
+ getSocialAuthUrl(provider, redirectUri, state, authContext) {
1164
1164
  const params = new URLSearchParams({
1165
1165
  redirect_uri: redirectUri,
1166
1166
  state,
1167
1167
  });
1168
+ if (authContext?.authRequestId) {
1169
+ params.set('auth_request_id', authContext.authRequestId);
1170
+ }
1171
+ if (authContext?.simpleMode) {
1172
+ const simpleMode = authContext.simpleMode.sessionId
1173
+ ? { session_id: authContext.simpleMode.sessionId }
1174
+ : {
1175
+ success_url: authContext.simpleMode.successUrl,
1176
+ failure_url: authContext.simpleMode.failureUrl,
1177
+ state: authContext.simpleMode.state,
1178
+ };
1179
+ params.set('simple_mode', JSON.stringify(simpleMode));
1180
+ }
1168
1181
  return `${this.baseUrl}/social/${provider}?${params}`;
1169
1182
  }
1170
1183
  /**
@@ -5932,7 +5945,7 @@ class IdentityRenderer {
5932
5945
  const redirectUri = window.location.origin + window.location.pathname;
5933
5946
  sessionStorage.setItem('sv_oauth_state', state);
5934
5947
  sessionStorage.setItem('sv_oauth_email', this.recipient);
5935
- const authUrl = this.api.getSocialAuthUrl(provider, redirectUri, state);
5948
+ const authUrl = this.api.getSocialAuthUrl(provider, redirectUri, state, this.verificationState.authContext);
5936
5949
  window.location.href = authUrl;
5937
5950
  }
5938
5951
  normalizeError(error) {
@@ -6772,6 +6785,10 @@ class IdentityModule {
6772
6785
  if (!token) {
6773
6786
  return null;
6774
6787
  }
6788
+ const expectedState = sessionStorage.getItem('sv_oauth_state');
6789
+ if (expectedState && params.get('state') !== expectedState) {
6790
+ throw new ValidationError('Invalid OAuth state');
6791
+ }
6775
6792
  const claims = await this.verifyToken(token);
6776
6793
  const result = {
6777
6794
  token,
@@ -6783,6 +6800,8 @@ class IdentityModule {
6783
6800
  if (typeof window.history?.replaceState === 'function') {
6784
6801
  window.history.replaceState(window.history.state, document.title, `${window.location.pathname}${window.location.search}`);
6785
6802
  }
6803
+ sessionStorage.removeItem('sv_oauth_state');
6804
+ sessionStorage.removeItem('sv_oauth_email');
6786
6805
  return result;
6787
6806
  }
6788
6807
  /**