From b6e583841f5fad177d580349e29cc09be10d3046 Mon Sep 17 00:00:00 2001 From: Brion Date: Mon, 30 Jun 2025 12:17:33 +0530 Subject: [PATCH 1/3] Fix NPEs --- .../presentation/SignIn/BaseSignIn.tsx | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/packages/react/src/components/presentation/SignIn/BaseSignIn.tsx b/packages/react/src/components/presentation/SignIn/BaseSignIn.tsx index c25fe78f..cc51086b 100644 --- a/packages/react/src/components/presentation/SignIn/BaseSignIn.tsx +++ b/packages/react/src/components/presentation/SignIn/BaseSignIn.tsx @@ -424,7 +424,7 @@ const BaseSignInContent: FC = ({ */ const handleRedirectionIfNeeded = (response: EmbeddedSignInFlowHandleResponse): boolean => { if ( - 'nextStep' in response && + response && 'nextStep' in response && response.nextStep && (response.nextStep as any).stepType === EmbeddedSignInFlowStepType.AuthenticatorPrompt && (response.nextStep as any).authenticators && @@ -563,7 +563,7 @@ const BaseSignInContent: FC = ({ onFlowChange?.(response); - if (response.flowStatus === EmbeddedSignInFlowStatus.SuccessCompleted) { + if (response?.flowStatus === EmbeddedSignInFlowStatus.SuccessCompleted) { onSuccess?.(response.authData); } } @@ -618,14 +618,14 @@ const BaseSignInContent: FC = ({ }); onFlowChange?.(response); - if (response.flowStatus === EmbeddedSignInFlowStatus.SuccessCompleted) { + if (response?.flowStatus === EmbeddedSignInFlowStatus.SuccessCompleted) { onSuccess?.(response.authData); return; } if ( - response.flowStatus === EmbeddedSignInFlowStatus.FailCompleted || - response.flowStatus === EmbeddedSignInFlowStatus.FailIncomplete + response?.flowStatus === EmbeddedSignInFlowStatus.FailCompleted || + response?.flowStatus === EmbeddedSignInFlowStatus.FailIncomplete ) { setError(t('errors.sign.in.flow.completion.failure')); return; @@ -636,7 +636,7 @@ const BaseSignInContent: FC = ({ return; } - if ('flowId' in response && 'nextStep' in response) { + if (response && 'flowId' in response && 'nextStep' in response) { const nextStepResponse = response as any; setCurrentFlow(nextStepResponse); @@ -718,21 +718,21 @@ const BaseSignInContent: FC = ({ }); onFlowChange?.(response); - if (response.flowStatus === EmbeddedSignInFlowStatus.SuccessCompleted) { + if (response?.flowStatus === EmbeddedSignInFlowStatus.SuccessCompleted) { onSuccess?.(response.authData); return; } if ( - response.flowStatus === EmbeddedSignInFlowStatus.FailCompleted || - response.flowStatus === EmbeddedSignInFlowStatus.FailIncomplete + response?.flowStatus === EmbeddedSignInFlowStatus.FailCompleted || + response?.flowStatus === EmbeddedSignInFlowStatus.FailIncomplete ) { setError(t('errors.sign.in.flow.passkeys.completion.failure')); return; } // Handle next step if authentication is not complete - if ('flowId' in response && 'nextStep' in response) { + if (response && 'flowId' in response && 'nextStep' in response) { const nextStepResponse = response as any; setCurrentFlow(nextStepResponse); @@ -795,7 +795,7 @@ const BaseSignInContent: FC = ({ }); onFlowChange?.(response); - if (response.flowStatus === EmbeddedSignInFlowStatus.SuccessCompleted) { + if (response?.flowStatus === EmbeddedSignInFlowStatus.SuccessCompleted) { onSuccess?.(response.authData); return; } @@ -823,14 +823,14 @@ const BaseSignInContent: FC = ({ }); onFlowChange?.(response); - if (response.flowStatus === EmbeddedSignInFlowStatus.SuccessCompleted) { + if (response?.flowStatus === EmbeddedSignInFlowStatus.SuccessCompleted) { onSuccess?.(response.authData); return; } if ( - response.flowStatus === EmbeddedSignInFlowStatus.FailCompleted || - response.flowStatus === EmbeddedSignInFlowStatus.FailIncomplete + response?.flowStatus === EmbeddedSignInFlowStatus.FailCompleted || + response?.flowStatus === EmbeddedSignInFlowStatus.FailIncomplete ) { setError('Authentication failed. Please check your credentials and try again.'); return; @@ -841,7 +841,7 @@ const BaseSignInContent: FC = ({ return; } - if ('flowId' in response && 'nextStep' in response) { + if (response && 'flowId' in response && 'nextStep' in response) { const nextStepResponse = response as any; setCurrentFlow(nextStepResponse); @@ -894,14 +894,14 @@ const BaseSignInContent: FC = ({ }); onFlowChange?.(response); - if (response.flowStatus === EmbeddedSignInFlowStatus.SuccessCompleted) { + if (response?.flowStatus === EmbeddedSignInFlowStatus.SuccessCompleted) { onSuccess?.(response.authData); return; } if ( - response.flowStatus === EmbeddedSignInFlowStatus.FailCompleted || - response.flowStatus === EmbeddedSignInFlowStatus.FailIncomplete + response?.flowStatus === EmbeddedSignInFlowStatus.FailCompleted || + response?.flowStatus === EmbeddedSignInFlowStatus.FailIncomplete ) { setError('Authentication failed. Please try again.'); return; @@ -912,7 +912,7 @@ const BaseSignInContent: FC = ({ return; } - if ('flowId' in response && 'nextStep' in response) { + if (response && 'flowId' in response && 'nextStep' in response) { const nextStepResponse = response as any; setCurrentFlow(nextStepResponse); @@ -952,7 +952,7 @@ const BaseSignInContent: FC = ({ } } } catch (err) { - const errorMessage = err instanceof AsgardeoAPIError ? err.message : 'Authenticator selection failed'; + const errorMessage = err instanceof AsgardeoAPIError ? err?.message : 'Authenticator selection failed'; setError(errorMessage); onError?.(err as Error); } finally { From 11fac1d70d9ff2d2d7cd7449eb932635cc28b453 Mon Sep 17 00:00:00 2001 From: Brion Date: Mon, 30 Jun 2025 13:08:06 +0530 Subject: [PATCH 2/3] Refactor exports in index files for better organization and clarity --- packages/browser/src/index.ts | 1 + packages/javascript/src/index.ts | 26 ++++++++++++++------------ packages/react/src/index.ts | 22 +++++++--------------- 3 files changed, 22 insertions(+), 27 deletions(-) diff --git a/packages/browser/src/index.ts b/packages/browser/src/index.ts index a3c19e5d..8ad5581a 100644 --- a/packages/browser/src/index.ts +++ b/packages/browser/src/index.ts @@ -49,4 +49,5 @@ export {default as hasAuthParamsInUrl} from './utils/hasAuthParamsInUrl'; export {default as AsgardeoBrowserClient} from './AsgardeoBrowserClient'; +// Re-export everything from the JavaScript package export * from '@asgardeo/javascript'; diff --git a/packages/javascript/src/index.ts b/packages/javascript/src/index.ts index 6c1aa6e2..5813533f 100644 --- a/packages/javascript/src/index.ts +++ b/packages/javascript/src/index.ts @@ -27,18 +27,20 @@ export {default as executeEmbeddedSignUpFlow} from './api/executeEmbeddedSignUpF export {default as getUserInfo} from './api/getUserInfo'; export {default as getScim2Me, GetScim2MeConfig} from './api/getScim2Me'; export {default as getSchemas, GetSchemasConfig} from './api/getSchemas'; -export {default as getAllOrganizations} from './api/getAllOrganizations'; -export {default as createOrganization} from './api/createOrganization'; -export {default as getMeOrganizations} from './api/getMeOrganizations'; -export {default as getOrganization} from './api/getOrganization'; -export {default as updateOrganization, createPatchOperations} from './api/updateOrganization'; -export {default as updateMeProfile} from './api/updateMeProfile'; -export type {PaginatedOrganizationsResponse, GetAllOrganizationsConfig} from './api/getAllOrganizations'; -export type {CreateOrganizationPayload, CreateOrganizationConfig} from './api/createOrganization'; -export type {GetMeOrganizationsConfig} from './api/getMeOrganizations'; -export type {OrganizationDetails, GetOrganizationConfig} from './api/getOrganization'; -export type {UpdateOrganizationConfig} from './api/updateOrganization'; -export type {UpdateMeProfileConfig} from './api/updateMeProfile'; +export { + default as getAllOrganizations, + PaginatedOrganizationsResponse, + GetAllOrganizationsConfig, +} from './api/getAllOrganizations'; +export { + default as createOrganization, + CreateOrganizationPayload, + CreateOrganizationConfig, +} from './api/createOrganization'; +export {default as getMeOrganizations, GetMeOrganizationsConfig} from './api/getMeOrganizations'; +export {default as getOrganization, OrganizationDetails, GetOrganizationConfig} from './api/getOrganization'; +export {default as updateOrganization, createPatchOperations, UpdateOrganizationConfig} from './api/updateOrganization'; +export {default as updateMeProfile, UpdateMeProfileConfig} from './api/updateMeProfile'; export {default as ApplicationNativeAuthenticationConstants} from './constants/ApplicationNativeAuthenticationConstants'; export {default as TokenConstants} from './constants/TokenConstants'; diff --git a/packages/react/src/index.ts b/packages/react/src/index.ts index a0205b60..d255ba4b 100644 --- a/packages/react/src/index.ts +++ b/packages/react/src/index.ts @@ -243,20 +243,12 @@ export type {FlowStep, FlowMessage, FlowContextValue} from './contexts/Flow/Flow export type {FlowProviderProps} from './contexts/Flow/FlowProvider'; - -export {default as getAllOrganizations} from './api/getAllOrganizations'; -export {default as createOrganization} from './api/createOrganization'; -export {default as getMeOrganizations} from './api/getMeOrganizations'; -export {default as getOrganization} from './api/getOrganization'; -export {default as updateOrganization, createPatchOperations} from './api/updateOrganization'; -export {default as getSchemas} from './api/getSchemas'; -export {default as updateMeProfile} from './api/updateMeProfile'; -export type {GetAllOrganizationsConfig} from './api/getAllOrganizations'; -export type {CreateOrganizationConfig} from './api/createOrganization'; -export type {GetMeOrganizationsConfig} from './api/getMeOrganizations'; -export type {GetOrganizationConfig} from './api/getOrganization'; -export type {UpdateOrganizationConfig} from './api/updateOrganization'; -export type {GetSchemasConfig} from './api/getSchemas'; -export type {UpdateMeProfileConfig} from './api/updateMeProfile'; +export {default as getAllOrganizations, GetAllOrganizationsConfig} from './api/getAllOrganizations'; +export {default as createOrganization, CreateOrganizationConfig} from './api/createOrganization'; +export {default as getMeOrganizations, GetMeOrganizationsConfig} from './api/getMeOrganizations'; +export {default as getOrganization, GetOrganizationConfig} from './api/getOrganization'; +export {default as updateOrganization, createPatchOperations, UpdateOrganizationConfig} from './api/updateOrganization'; +export {default as getSchemas, GetSchemasConfig} from './api/getSchemas'; +export {default as updateMeProfile, UpdateMeProfileConfig} from './api/updateMeProfile'; export {default as getMeProfile} from './api/getScim2Me'; export * from './api/getScim2Me'; From 3851019dfb8b2cd1e77ae40943f393de4d799c41 Mon Sep 17 00:00:00 2001 From: Brion Date: Mon, 30 Jun 2025 13:24:44 +0530 Subject: [PATCH 3/3] Add changeset for patch updates to @asgardeo/nextjs and @asgardeo/react, fixing NPEs --- .changeset/olive-doodles-allow.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/olive-doodles-allow.md diff --git a/.changeset/olive-doodles-allow.md b/.changeset/olive-doodles-allow.md new file mode 100644 index 00000000..5c2ff251 --- /dev/null +++ b/.changeset/olive-doodles-allow.md @@ -0,0 +1,6 @@ +--- +'@asgardeo/nextjs': patch +'@asgardeo/react': patch +--- + +Fix NPEs