diff --git a/.changeset/slow-colts-beam.md b/.changeset/slow-colts-beam.md new file mode 100644 index 00000000..826cb1f6 --- /dev/null +++ b/.changeset/slow-colts-beam.md @@ -0,0 +1,6 @@ +--- +'@asgardeo/react': patch +'@asgardeo/javascript': patch +--- + +Rename sessionDataKey to authId for V2 diff --git a/packages/javascript/src/api/v2/executeEmbeddedSignInFlowV2.ts b/packages/javascript/src/api/v2/executeEmbeddedSignInFlowV2.ts index 26898e66..630e94d7 100644 --- a/packages/javascript/src/api/v2/executeEmbeddedSignInFlowV2.ts +++ b/packages/javascript/src/api/v2/executeEmbeddedSignInFlowV2.ts @@ -27,7 +27,7 @@ const executeEmbeddedSignInFlowV2 = async ({ url, baseUrl, payload, - sessionDataKey, + authId, ...requestConfig }: EmbeddedFlowExecuteRequestConfigV2): Promise => { if (!payload) { @@ -68,11 +68,11 @@ const executeEmbeddedSignInFlowV2 = async ({ const flowResponse: EmbeddedSignInFlowResponseV2 = await response.json(); // IMPORTANT: Only applicable for Asgardeo V2 platform. - // Check if the flow is complete and has an assertion and sessionDataKey is provided, then call OAuth2 authorize. + // Check if the flow is complete and has an assertion and authId is provided, then call OAuth2 authorize. if ( flowResponse.flowStatus === EmbeddedSignInFlowStatusV2.Complete && (flowResponse as any).assertion && - sessionDataKey + authId ) { try { const oauth2Response: Response = await fetch(`${baseUrl}/oauth2/authorize`, { @@ -84,7 +84,7 @@ const executeEmbeddedSignInFlowV2 = async ({ }, body: JSON.stringify({ assertion: (flowResponse as any).assertion, - sessionDataKey, + authId, }), credentials: 'include', }); diff --git a/packages/javascript/src/api/v2/executeEmbeddedSignUpFlowV2.ts b/packages/javascript/src/api/v2/executeEmbeddedSignUpFlowV2.ts index acb8dfde..d59c642e 100644 --- a/packages/javascript/src/api/v2/executeEmbeddedSignUpFlowV2.ts +++ b/packages/javascript/src/api/v2/executeEmbeddedSignUpFlowV2.ts @@ -27,7 +27,7 @@ const executeEmbeddedSignUpFlowV2 = async ({ url, baseUrl, payload, - sessionDataKey, + authId, ...requestConfig }: EmbeddedFlowExecuteRequestConfigV2): Promise => { if (!payload) { @@ -68,11 +68,11 @@ const executeEmbeddedSignUpFlowV2 = async ({ const flowResponse: EmbeddedSignUpFlowResponseV2 = await response.json(); // IMPORTANT: Only applicable for Asgardeo V2 platform. - // Check if the flow is complete and has an assertion and sessionDataKey is provided, then call OAuth2 authorize. + // Check if the flow is complete and has an assertion and authId is provided, then call OAuth2 authorize. if ( flowResponse.flowStatus === EmbeddedSignUpFlowStatusV2.Complete && (flowResponse as any).assertion && - sessionDataKey + authId ) { try { const oauth2Response: Response = await fetch(`${baseUrl}/oauth2/authorize`, { @@ -84,7 +84,7 @@ const executeEmbeddedSignUpFlowV2 = async ({ }, body: JSON.stringify({ assertion: (flowResponse as any).assertion, - sessionDataKey, + authId, }), credentials: 'include', }); diff --git a/packages/javascript/src/models/v2/embedded-signin-flow-v2.ts b/packages/javascript/src/models/v2/embedded-signin-flow-v2.ts index 33c98ba8..fe9bf1ff 100644 --- a/packages/javascript/src/models/v2/embedded-signin-flow-v2.ts +++ b/packages/javascript/src/models/v2/embedded-signin-flow-v2.ts @@ -94,5 +94,5 @@ export interface EmbeddedSignInFlowRequestV2 extends Partial extends EmbeddedFlowExecuteRequestConfig { - sessionDataKey?: string; + authId?: string; } diff --git a/packages/javascript/src/models/v2/embedded-signup-flow-v2.ts b/packages/javascript/src/models/v2/embedded-signup-flow-v2.ts index fa2be8b7..31ceb93a 100644 --- a/packages/javascript/src/models/v2/embedded-signup-flow-v2.ts +++ b/packages/javascript/src/models/v2/embedded-signup-flow-v2.ts @@ -168,7 +168,7 @@ export interface EmbeddedSignUpFlowRequestV2 extends Partial extends EmbeddedFlowExecuteRequestConfig { - sessionDataKey?: string; + authId?: string; } /** diff --git a/packages/react/src/AsgardeoReactClient.ts b/packages/react/src/AsgardeoReactClient.ts index 30eca37e..b8275d45 100644 --- a/packages/react/src/AsgardeoReactClient.ts +++ b/packages/react/src/AsgardeoReactClient.ts @@ -357,9 +357,9 @@ class AsgardeoReactClient e !isEmpty(arg1) && ('flowId' in arg1 || 'applicationId' in arg1) ) { - const sessionDataKeyFromUrl: string = new URL(window.location.href).searchParams.get('sessionDataKey'); - const sessionDataKeyFromStorage: string = sessionStorage.getItem('asgardeo_session_data_key'); - const sessionDataKey: string = sessionDataKeyFromUrl || sessionDataKeyFromStorage; + const authIdFromUrl: string = new URL(window.location.href).searchParams.get('authId'); + const authIdFromStorage: string = sessionStorage.getItem('asgardeo_auth_id'); + const authId: string = authIdFromUrl || authIdFromStorage; const baseUrlFromStorage: string = sessionStorage.getItem('asgardeo_base_url'); const baseUrl: string = config?.baseUrl || baseUrlFromStorage; @@ -367,7 +367,7 @@ class AsgardeoReactClient e payload: arg1 as EmbeddedSignInFlowHandleRequestPayload, url: arg2?.url, baseUrl, - sessionDataKey, + authId, }); } diff --git a/packages/react/src/components/presentation/SignIn/component-driven/SignIn.tsx b/packages/react/src/components/presentation/SignIn/component-driven/SignIn.tsx index 4c3d8094..97c2069d 100644 --- a/packages/react/src/components/presentation/SignIn/component-driven/SignIn.tsx +++ b/packages/react/src/components/presentation/SignIn/component-driven/SignIn.tsx @@ -197,7 +197,7 @@ const SignIn: FC = ({className, size = 'medium', onSuccess, onError const clearFlowState = (): void => { setFlowId(null); setIsFlowInitialized(false); - sessionStorage.removeItem('asgardeo_session_data_key'); + sessionStorage.removeItem('asgardeo_auth_id'); // Reset refs to allow new flows to start properly oauthCodeProcessedRef.current = false; }; @@ -215,16 +215,16 @@ const SignIn: FC = ({className, size = 'medium', onSuccess, onError nonce: urlParams.get('nonce'), flowId: urlParams.get('flowId'), applicationId: urlParams.get('applicationId'), - sessionDataKey: urlParams.get('sessionDataKey'), + authId: urlParams.get('authId'), }; }; /** - * Handle sessionDataKey from URL and store it in sessionStorage. + * Handle authId from URL and store it in sessionStorage. */ - const handleSessionDataKey = (sessionDataKey: string | null): void => { - if (sessionDataKey) { - sessionStorage.setItem('asgardeo_session_data_key', sessionDataKey); + const handleAuthId = (authId: string | null): void => { + if (authId) { + sessionStorage.setItem('asgardeo_auth_id', authId); } }; @@ -257,14 +257,14 @@ const SignIn: FC = ({className, size = 'medium', onSuccess, onError }; /** - * Clean up flow-related URL parameters (flowId, sessionDataKey) from the browser URL. + * Clean up flow-related URL parameters (flowId, authId) from the browser URL. * Used after flowId is set in state to prevent using invalidated flowId from URL. */ const cleanupFlowUrlParams = (): void => { if (!window?.location?.href) return; const url = new URL(window.location.href); url.searchParams.delete('flowId'); - url.searchParams.delete('sessionDataKey'); + url.searchParams.delete('authId'); url.searchParams.delete('applicationId'); window?.history?.replaceState({}, '', url.toString()); }; @@ -309,7 +309,7 @@ const SignIn: FC = ({className, size = 'medium', onSuccess, onError } const urlParams = getUrlParams(); - handleSessionDataKey(urlParams.sessionDataKey); + handleAuthId(urlParams.authId); window.location.href = redirectURL; return true; @@ -331,7 +331,7 @@ const SignIn: FC = ({className, size = 'medium', onSuccess, onError return; } - handleSessionDataKey(urlParams.sessionDataKey); + handleAuthId(urlParams.authId); // Skip OAuth code processing - let the dedicated OAuth useEffect handle it if (urlParams.code || urlParams.state) { @@ -367,7 +367,7 @@ const SignIn: FC = ({className, size = 'medium', onSuccess, onError // Reset OAuth code processed ref when starting a new flow oauthCodeProcessedRef.current = false; - handleSessionDataKey(urlParams.sessionDataKey); + handleAuthId(urlParams.authId); const effectiveApplicationId = applicationId || urlParams.applicationId; @@ -488,7 +488,7 @@ const SignIn: FC = ({className, size = 'medium', onSuccess, onError setFlowId(null); setIsFlowInitialized(false); sessionStorage.removeItem('asgardeo_flow_id'); - sessionStorage.removeItem('asgardeo_session_data_key'); + sessionStorage.removeItem('asgardeo_auth_id'); // Clean up OAuth URL params before redirect cleanupOAuthUrlParams(true);