Skip to content

Commit

Permalink
fix(shared): Use session_reverification_required as api error code (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
panteliselef authored Dec 3, 2024
1 parent 30f8e82 commit 235eaae
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/small-buckets-peel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/shared': minor
---

Replace `session_step_up_verification_required` with `session_reverification_required` as the Clerk API error code used for reverification.
4 changes: 3 additions & 1 deletion packages/shared/src/react/hooks/useReverification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { createDeferredPromise } from '../../utils/createDeferredPromise';
import { useClerk } from './useClerk';
import { useSafeLayoutEffect } from './useSafeLayoutEffect';

const CLERK_API_REVERIFICATION_ERROR_CODE = 'session_reverification_required';

async function resolveResult<T>(result: Promise<T> | T): Promise<T | ReturnType<typeof reverificationError>> {
try {
const r = await result;
Expand All @@ -17,7 +19,7 @@ async function resolveResult<T>(result: Promise<T> | T): Promise<T | ReturnType<
return r;
} catch (e) {
// Treat fapi assurance as an assurance hint
if (isClerkAPIResponseError(e) && e.errors.find(({ code }) => code == 'session_step_up_verification_required')) {
if (isClerkAPIResponseError(e) && e.errors.find(({ code }) => code === CLERK_API_REVERIFICATION_ERROR_CODE)) {
return reverificationError();
}

Expand Down

0 comments on commit 235eaae

Please sign in to comment.