Skip to content

Commit 326d142

Browse files
committed
Update flowId renaming
1 parent c8ae27c commit 326d142

File tree

8 files changed

+51
-51
lines changed

8 files changed

+51
-51
lines changed

packages/react/src/components/presentation/auth/AcceptInvite/v2/AcceptInvite.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ const getUrlParams = (): { flowExecId?: string; inviteToken?: string } => {
118118
*
119119
* This component is designed for end users accessing the thunder-gate app via an invite link.
120120
* It automatically:
121-
* 1. Extracts flowId and inviteToken from URL query parameters
121+
* 1. Extracts flowExecId and inviteToken from URL query parameters
122122
* 2. Validates the invite token with the backend
123123
* 3. Displays the password form if token is valid
124124
* 4. Completes the accept invite when password is set
@@ -127,7 +127,7 @@ const getUrlParams = (): { flowExecId?: string; inviteToken?: string } => {
127127
* ```tsx
128128
* import { AcceptInvite } from '@asgardeo/react';
129129
*
130-
* // URL: /invite?flowId=xxx&inviteToken=yyy
130+
* // URL: /invite?flowExecId=xxx&inviteToken=yyy
131131
*
132132
* const AcceptInvitePage = () => {
133133
* return (

packages/react/src/components/presentation/auth/AcceptInvite/v2/BaseAcceptInvite.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ const BaseAcceptInvite: FC<BaseAcceptInviteProps> = ({
547547
if (!flowExecId || !inviteToken) {
548548
setIsValidatingToken(false);
549549
setIsTokenInvalid(true);
550-
handleError(new Error('Invalid invite link. Missing flowId or inviteToken.'));
550+
handleError(new Error('Invalid invite link. Missing flowExecId or inviteToken.'));
551551
return;
552552
}
553553

@@ -558,7 +558,7 @@ const BaseAcceptInvite: FC<BaseAcceptInviteProps> = ({
558558
setApiError(null);
559559

560560
try {
561-
// Store flowId in sessionStorage for OAuth callback
561+
// Store flowExecId in sessionStorage for OAuth callback
562562
if (flowExecId) {
563563
sessionStorage.setItem('asgardeo_flow_id', flowExecId);
564564
}

packages/react/src/components/presentation/auth/InviteUser/v2/BaseInviteUser.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export interface BaseInviteUserRenderProps {
7979
fieldErrors: Record<string, string>;
8080

8181
/**
82-
* Current flow ID.
82+
* Current flow execution ID.
8383
*/
8484
flowExecId?: string;
8585

packages/react/src/components/presentation/auth/InviteUser/v2/InviteUser.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export interface InviteUserProps {
9898
*
9999
* return (
100100
* <InviteUser
101-
* onInviteLinkGenerated={(link, flowId) => setInviteLink(link)}
101+
* onInviteLinkGenerated={(link, flowExecId) => setInviteLink(link)}
102102
* onError={(error) => console.error(error)}
103103
* >
104104
* {({ values, components, isLoading, handleInputChange, handleSubmit, inviteLink, isInviteGenerated }) => (

packages/react/src/components/presentation/auth/SignIn/v2/SignIn.tsx

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ const SignIn: FC<SignInProps> = ({
222222
// State management for the flow
223223
const [components, setComponents] = useState<EmbeddedFlowComponent[]>([]);
224224
const [additionalData, setAdditionalData] = useState<Record<string, any>>({});
225-
const [currentFlowId, setCurrentFlowId] = useState<string | null>(null);
225+
const [currentFlowExecId, setCurrentFlowExecId] = useState<string | null>(null);
226226
const [isFlowInitialized, setIsFlowInitialized] = useState(false);
227227
const [flowError, setFlowError] = useState<Error | null>(null);
228228
const [isSubmitting, setIsSubmitting] = useState(false);
@@ -239,11 +239,11 @@ const SignIn: FC<SignInProps> = ({
239239
const oauthCodeProcessedRef: any = useRef(false);
240240
const passkeyProcessedRef: any = useRef(false);
241241
/**
242-
* Sets flowId between sessionStorage and state.
242+
* Sets flowExecId between sessionStorage and state.
243243
* This ensures both are always in sync.
244244
*/
245-
const setFlowId = (flowExecId: string | null): void => {
246-
setCurrentFlowId(flowExecId);
245+
const setFlowExecId = (flowExecId: string | null): void => {
246+
setCurrentFlowExecId(flowExecId);
247247
if (flowExecId) {
248248
sessionStorage.setItem('asgardeo_flow_id', flowExecId);
249249
} else {
@@ -255,7 +255,7 @@ const SignIn: FC<SignInProps> = ({
255255
* Clear all flow-related storage and state.
256256
*/
257257
const clearFlowState = (): void => {
258-
setFlowId(null);
258+
setFlowExecId(null);
259259
setIsFlowInitialized(false);
260260
sessionStorage.removeItem('asgardeo_auth_id');
261261
setIsTimeoutDisabled(false);
@@ -350,7 +350,7 @@ const SignIn: FC<SignInProps> = ({
350350

351351
if (redirectURL && window?.location) {
352352
if (response.flowExecId) {
353-
setFlowId(response.flowExecId);
353+
setFlowExecId(response.flowExecId);
354354
}
355355

356356
const urlParams: any = getUrlParams();
@@ -365,7 +365,7 @@ const SignIn: FC<SignInProps> = ({
365365

366366
/**
367367
* Initialize the authentication flow.
368-
* Priority: flowId > applicationId (from context) > applicationId (from URL)
368+
* Priority: flowExecId > applicationId (from context) > applicationId (from URL)
369369
*/
370370
const initializeFlow = async (): Promise<void> => {
371371
const urlParams: any = getUrlParams();
@@ -408,7 +408,7 @@ const SignIn: FC<SignInProps> = ({
408408
}
409409

410410
const {
411-
flowExecId: normalizedFlowId,
411+
flowExecId: normalizedFlowExecId,
412412
components: normalizedComponents,
413413
additionalData: normalizedAdditionalData,
414414
} = normalizeFlowResponse(
@@ -420,13 +420,13 @@ const SignIn: FC<SignInProps> = ({
420420
meta,
421421
);
422422

423-
if (normalizedFlowId && normalizedComponents) {
424-
setFlowId(normalizedFlowId);
423+
if (normalizedFlowExecId && normalizedComponents) {
424+
setFlowExecId(normalizedFlowExecId);
425425
setComponents(normalizedComponents);
426426
setAdditionalData(normalizedAdditionalData ?? {});
427427
setIsFlowInitialized(true);
428428
setIsTimeoutDisabled(false);
429-
// Clean up flowId from URL after setting it in state
429+
// Clean up flowExecId from URL after setting it in state
430430
cleanupFlowUrlParams();
431431
}
432432
} catch (error) {
@@ -468,7 +468,7 @@ const SignIn: FC<SignInProps> = ({
468468
!isLoading &&
469469
!isFlowInitialized &&
470470
!initializationAttemptedRef.current &&
471-
!currentFlowId &&
471+
!currentFlowExecId &&
472472
!currentUrlParams.code &&
473473
!currentUrlParams.state &&
474474
!isSubmitting &&
@@ -477,7 +477,7 @@ const SignIn: FC<SignInProps> = ({
477477
initializationAttemptedRef.current = true;
478478
initializeFlow();
479479
}
480-
}, [isInitialized, isLoading, isFlowInitialized, currentFlowId]);
480+
}, [isInitialized, isLoading, isFlowInitialized, currentFlowExecId]);
481481

482482
/**
483483
* Handle step timeout if configured in additionalData.
@@ -513,10 +513,10 @@ const SignIn: FC<SignInProps> = ({
513513
* Handle form submission from BaseSignIn or render props.
514514
*/
515515
const handleSubmit = async (payload: EmbeddedSignInFlowRequestV2): Promise<void> => {
516-
// Use flowExecId from payload if available, otherwise fall back to currentFlowId
517-
const effectiveFlowId: any = payload.flowExecId || currentFlowId;
516+
// Use flowExecId from payload if available, otherwise fall back to currentFlowExecId
517+
const effectiveFlowExecId: any = payload.flowExecId || currentFlowExecId;
518518

519-
if (!effectiveFlowId) {
519+
if (!effectiveFlowExecId) {
520520
throw new Error('No active flow ID');
521521
}
522522

@@ -592,7 +592,7 @@ const SignIn: FC<SignInProps> = ({
592592
setFlowError(null);
593593

594594
const response: EmbeddedSignInFlowResponseV2 = (await signIn({
595-
flowExecId: effectiveFlowId,
595+
flowExecId: effectiveFlowExecId,
596596
...payload,
597597
inputs: processedInputs,
598598
})) as EmbeddedSignInFlowResponseV2;
@@ -605,7 +605,7 @@ const SignIn: FC<SignInProps> = ({
605605
response.data?.additionalData?.['passkeyCreationOptions']
606606
) {
607607
const { passkeyChallenge, passkeyCreationOptions }: any = response.data.additionalData;
608-
const effectiveFlowIdForPasskey: any = response.flowExecId || effectiveFlowId;
608+
const effectiveFlowExecIdForPasskey: any = response.flowExecId || effectiveFlowExecId;
609609

610610
// Reset passkey processed ref to allow processing
611611
passkeyProcessedRef.current = false;
@@ -616,7 +616,7 @@ const SignIn: FC<SignInProps> = ({
616616
challenge: passkeyChallenge,
617617
creationOptions: passkeyCreationOptions,
618618
error: null,
619-
flowExecId: effectiveFlowIdForPasskey,
619+
flowExecId: effectiveFlowExecIdForPasskey,
620620
isActive: true,
621621
});
622622
setIsSubmitting(false);
@@ -625,7 +625,7 @@ const SignIn: FC<SignInProps> = ({
625625
}
626626

627627
const {
628-
flowExecId: normalizedFlowId,
628+
flowExecId: normalizedFlowExecId,
629629
components: normalizedComponents,
630630
additionalData: normalizedAdditionalData,
631631
} = normalizeFlowResponse(
@@ -659,7 +659,7 @@ const SignIn: FC<SignInProps> = ({
659659
setIsSubmitting(false);
660660

661661
// Clear all OAuth-related storage on successful completion
662-
setFlowId(null);
662+
setFlowExecId(null);
663663
setIsFlowInitialized(false);
664664
sessionStorage.removeItem('asgardeo_flow_id');
665665
sessionStorage.removeItem('asgardeo_auth_id');
@@ -681,15 +681,15 @@ const SignIn: FC<SignInProps> = ({
681681
return;
682682
}
683683

684-
// Update flowId if response contains a new one
685-
if (normalizedFlowId && normalizedComponents) {
686-
setFlowId(normalizedFlowId);
684+
// Update flowExecId if response contains a new one
685+
if (normalizedFlowExecId && normalizedComponents) {
686+
setFlowExecId(normalizedFlowExecId);
687687
setComponents(normalizedComponents);
688688
setAdditionalData(normalizedAdditionalData ?? {});
689689
setIsTimeoutDisabled(false);
690690
// Ensure flow is marked as initialized when we have components
691691
setIsFlowInitialized(true);
692-
// Clean up flowId from URL after setting it in state
692+
// Clean up flowExecId from URL after setting it in state
693693
cleanupFlowUrlParams();
694694

695695
// Display failure reason from INCOMPLETE response
@@ -719,7 +719,7 @@ const SignIn: FC<SignInProps> = ({
719719
};
720720

721721
useOAuthCallback({
722-
currentFlowExecId: currentFlowId,
722+
currentFlowExecId: currentFlowExecId,
723723
isInitialized: isInitialized && !isLoading,
724724
isSubmitting,
725725
onError: (err: any) => {
@@ -728,7 +728,7 @@ const SignIn: FC<SignInProps> = ({
728728
},
729729
onSubmit: async (payload: any) => handleSubmit({ flowExecId: payload.flowExecId, inputs: payload.inputs }),
730730
processedRef: oauthCodeProcessedRef,
731-
setFlowId,
731+
setFlowExecId: setFlowExecId,
732732
});
733733

734734
/**

packages/react/src/components/presentation/auth/SignUp/v2/BaseSignUp.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ const BaseSignUpContent: FC<BaseSignUpProps> = ({
694694

695695
if (response.data?.additionalData?.['passkeyCreationOptions']) {
696696
const {passkeyCreationOptions}: any = response.data.additionalData;
697-
const effectiveFlowIdForPasskey: any = response.flowExecId || (currentFlow as any)?.flowExecId;
697+
const effectiveFlowExecIdForPasskey: any = response.flowExecId || (currentFlow as any)?.flowExecId;
698698

699699
// Reset passkey processed ref to allow processing
700700
passkeyProcessedRef.current = false;
@@ -704,7 +704,7 @@ const BaseSignUpContent: FC<BaseSignUpProps> = ({
704704
actionId: component.id || 'submit',
705705
creationOptions: passkeyCreationOptions,
706706
error: null,
707-
flowExecId: effectiveFlowIdForPasskey,
707+
flowExecId: effectiveFlowExecIdForPasskey,
708708
isActive: true,
709709
});
710710
setIsLoading(false);

packages/react/src/hooks/v2/useOAuthCallback.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export interface UseOAuthCallbackOptions {
2727
/**
2828
* SessionStorage key for flowExecId (defaults to 'asgardeo_flow_id')
2929
*/
30-
flowIdStorageKey?: string;
30+
flowExecIdStorageKey?: string;
3131

3232
/**
3333
* Whether the component is initialized and ready to process OAuth callback
@@ -71,9 +71,9 @@ export interface UseOAuthCallbackOptions {
7171
processedRef?: RefObject<boolean>;
7272

7373
/**
74-
* Additional handler for setting state (e.g., setFlowId)
74+
* Additional handler for setting state (e.g., setFlowExecId)
7575
*/
76-
setFlowId?: (flowExecId: string) => void;
76+
setFlowExecId?: (flowExecId: string) => void;
7777

7878
/**
7979
* Ref to mark that token validation was attempted (prevents duplicate validation)
@@ -109,7 +109,7 @@ function cleanupUrlParams(): void {
109109
*/
110110
export function useOAuthCallback({
111111
currentFlowExecId: currentFlowExecId,
112-
flowIdStorageKey = 'asgardeo_flow_id',
112+
flowExecIdStorageKey: flowExecIdStorageKey = 'asgardeo_flow_id',
113113
isInitialized,
114114
isSubmitting = false,
115115
onComplete,
@@ -118,7 +118,7 @@ export function useOAuthCallback({
118118
onProcessingStart,
119119
onSubmit,
120120
processedRef,
121-
setFlowId,
121+
setFlowExecId: setExecFlowExecId,
122122
tokenValidationAttemptedRef,
123123
}: UseOAuthCallbackOptions): void {
124124
const internalRef: any = useRef(false);
@@ -133,7 +133,7 @@ export function useOAuthCallback({
133133
const code: string | null = urlParams.get('code');
134134
const nonce: string | null = urlParams.get('nonce');
135135
const state: string | null = urlParams.get('state');
136-
const flowIdFromUrl: string | null = urlParams.get('flowExecId');
136+
const flowExecIdFromUrl: string | null = urlParams.get('flowExecId');
137137
const error: string | null = urlParams.get('error');
138138
const errorDescription: string | null = urlParams.get('error_description');
139139

@@ -156,10 +156,10 @@ export function useOAuthCallback({
156156
return;
157157
}
158158

159-
const storedFlowId: string | null = sessionStorage.getItem(flowIdStorageKey);
160-
const flowIdToUse: string | null = currentFlowExecId || storedFlowId || flowIdFromUrl || state || null;
159+
const storedFlowExecId: string | null = sessionStorage.getItem(flowExecIdStorageKey);
160+
const flowExecIdToUse: string | null = currentFlowExecId || storedFlowExecId || flowExecIdFromUrl || state || null;
161161

162-
if (!flowIdToUse) {
162+
if (!flowExecIdToUse) {
163163
oauthCodeProcessedRef.current = true;
164164
onError?.(new Error('Invalid flow. Missing flowExecId.'));
165165
cleanupUrlParams();
@@ -175,14 +175,14 @@ export function useOAuthCallback({
175175

176176
onProcessingStart?.();
177177

178-
if (!currentFlowExecId && setFlowId) {
179-
setFlowId(flowIdToUse);
178+
if (!currentFlowExecId && setExecFlowExecId) {
179+
setExecFlowExecId(flowExecIdToUse);
180180
}
181181

182182
(async (): Promise<void> => {
183183
try {
184184
const payload: OAuthCallbackPayload = {
185-
flowExecId: flowIdToUse,
185+
flowExecId: flowExecIdToUse,
186186
inputs: {
187187
code,
188188
...(nonce && { nonce }),
@@ -215,7 +215,7 @@ export function useOAuthCallback({
215215
onComplete,
216216
onError,
217217
onFlowChange,
218-
setFlowId,
219-
flowIdStorageKey,
218+
setExecFlowExecId,
219+
flowExecIdStorageKey,
220220
]);
221221
}

packages/react/src/utils/v2/flowTransformer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
* ```typescript
3434
* import { normalizeFlowResponse } from '../../../utils/v2/flowTransformer';
3535
*
36-
* const { flowId, components } = normalizeFlowResponse(apiResponse, t, {
36+
* const { flowExecId, components } = normalizeFlowResponse(apiResponse, t, {
3737
* defaultErrorKey: 'components.signIn.errors.generic'
3838
* });
3939
* ```
@@ -286,7 +286,7 @@ export const checkForErrorResponse = (
286286
* @param response - The raw flow response from the API
287287
* @param t - Translation function from useTranslation hook
288288
* @param options - Configuration options for transformation behavior
289-
* @returns Normalized flow response with flowId and transformed components
289+
* @returns Normalized flow response with flowExecId and transformed components
290290
* @throws {any} The original response if it's an error and throwOnError is true
291291
*/
292292
export const normalizeFlowResponse = (

0 commit comments

Comments
 (0)