Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/gentle-swans-sleep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@asgardeo/javascript': patch
'@asgardeo/react': patch
---

Throw JWT verification errors
3 changes: 3 additions & 0 deletions packages/javascript/src/IsomorphicCrypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ export class IsomorphicCrypto<T = any> {
'ID token validation returned false',
),
);
})
.catch((error: AsgardeoAuthException) => {
return Promise.reject(error);
});
}

Expand Down
20 changes: 14 additions & 6 deletions packages/react/src/contexts/Asgardeo/AsgardeoProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,12 @@ const AsgardeoProvider: FC<PropsWithChildren<AsgardeoProviderProps>> = ({
}
// setError(null);
} catch (error) {
if (error && Object.prototype.hasOwnProperty.call(error, 'code')) {
// setError(error);
}
throw new AsgardeoRuntimeError(
`Sign in failed: ${error instanceof Error ? error.message : String(JSON.stringify(error))}`,
'asgardeo-signIn-Error',
'react',
'An error occurred while trying to sign in.',
);
}
} else {
// TODO: Add a debug log to indicate that the user is not signed in
Expand Down Expand Up @@ -418,7 +421,12 @@ const AsgardeoProvider: FC<PropsWithChildren<AsgardeoProviderProps>> = ({

return response as User;
} catch (error) {
throw new Error(`Error while signing in: ${error instanceof Error ? error.message : String(error)}`);
throw new AsgardeoRuntimeError(
`Sign in failed: ${error instanceof Error ? error.message : String(JSON.stringify(error))}`,
'asgardeo-signIn-Error',
'react',
'An error occurred while trying to sign in.',
);
} finally {
if (!isV2FlowRequest) {
setIsUpdatingSession(false);
Expand All @@ -440,7 +448,7 @@ const AsgardeoProvider: FC<PropsWithChildren<AsgardeoProviderProps>> = ({
return response;
} catch (error) {
throw new AsgardeoRuntimeError(
`Error while signing in silently: ${error.message || error}`,
`Error while signing in silently: ${error instanceof Error ? error.message : String(JSON.stringify(error))}`,
'asgardeo-signInSilently-Error',
'react',
'An error occurred while trying to sign in silently.',
Expand All @@ -462,7 +470,7 @@ const AsgardeoProvider: FC<PropsWithChildren<AsgardeoProviderProps>> = ({
}
} catch (error) {
throw new AsgardeoRuntimeError(
`Failed to switch organization: ${error.message || error}`,
`Failed to switch organization: ${error instanceof Error ? error.message : String(JSON.stringify(error))}`,
'asgardeo-switchOrganization-Error',
'react',
'An error occurred while switching to the specified organization.',
Expand Down
Loading