Skip to content

fix(expo): throw the verification error when Apple sign-in needs email verification - #10644

Merged
mikepitre merged 1 commit into
mainfrom
mike/expo-apple-verification-error
Nov 4, 2026
Merged

mikepitre merged 1 commit into
mainfrom
mike/expo-apple-verification-error

Conversation

@mikepitre

@mikepitre mikepitre commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Description

On instances that restrict sign-ups, useSignInWithApple falls back to signIn.create({ strategy: 'oauth_token_apple' }). When the server needs the user to verify their email address before the Apple account can be used, that sign-in comes back as needs_first_factor with the error on firstFactorVerification (external_account_email_address_verification_required). The hook returned createdSessionId: null and no error, so the app had no way to tell the user what happened.

The hook now throws that error as a ClerkAPIResponseError, so apps can catch it with isClerkAPIResponseError and read errors[0].code. This matches clerk-ios, which throws the first-factor verification error from signInWithApple. The server returned a 200 for this response, so the thrown error uses status 422. The normal sign-up and transfer path is unchanged.

Verified on an iOS simulator with the verify-clerk-expo skill, spec specs/explored/apple-verification-error.e2e.ts: before run r20261104-100014-16fe on main's hook, after run r20261104-100054-902a on this branch. No test user can reach this state, because the simulator has no Apple ID for Sign in with Apple and the server checks the Apple identity token's signature. So both runs used the same local patch to the expo-native test app, which is not committed. It adds a Sign in with Apple button to the Native modules screen. It replaces expo-apple-authentication and expo-crypto with stubs that return a fake identity token. It also answers the two oauth_token_apple requests in the app's fetch: sign-up with sign_up_mode_restricted (403), and sign-in with needs_first_factor and external_account_email_address_verification_required on first_factor_verification. The hook itself is unpatched. Android is not covered because this hook is iOS only. The new unit test fails on main and passes with the change.

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

🤖 Generated with Claude Code

Verified on an iOS simulator. Run r20261104-100054-902a on verify-ios-1 at 79052077fe8c, 1 of 1 passed. Before is run r20261104-100014-16fe at 79052077fe8c, 0 of 1 passed.

Before After
evidence-1f46ee6fc713564d-2.mp4
evidence-1f46ee6fc713564d-1.mp4

…l verification

On instances with restricted sign-ups, useSignInWithApple falls back to
signIn.create with the Apple token. When the server asks for email
re-verification, the sign-in comes back as needs_first_factor with the
error on firstFactorVerification, and the hook returned no session and no
error. It now throws that error as a ClerkAPIResponseError, matching
clerk-ios.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
clerk-js-sandbox Ready Ready Preview Nov 4, 2026 2:15pm UTC
swingset Ready Ready Preview Nov 4, 2026 2:15pm UTC

Request Review

@changeset-bot

changeset-bot Bot commented Nov 4, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7905207

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@clerk/expo Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The restricted-sign-up fallback in useSignInWithApple now checks for a first-factor verification error after fallback sign-in. If an error exists, the flow throws a 422 ClerkAPIResponseError with the verification error’s code and messages. Otherwise, it returns the existing sign-in result. A test covers the error response, and a patch changeset records the change.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: wobsoriano

Merge Risk: Minimal · up to 79052

Apple sign-in now reports the verification error instead of silently returning without a session. No merge-blocking risk was established.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title names the main change: the Expo Apple sign-in hook now throws the email verification error when sign-in needs email verification. It matches the changeset, which adds a ClerkAPIResponseError…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description states the bug and the fix. It names the hook (useSignInWithApple), the server response (needs_first_factor with external_account_email_address_verification_required), and the ne…
Full details: Title check

Explanation

The title names the main change: the Expo Apple sign-in hook now throws the email verification error when sign-in needs email verification. It matches the changeset, which adds a ClerkAPIResponseError path in useSignInWithApple.ios.ts with a matching test.

Full details: Description check

Explanation

The description states the bug and the fix. It names the hook (useSignInWithApple), the server response (needs_first_factor with external_account_email_address_verification_required), and the new behavior (a ClerkAPIResponseError with status 422). It also describes the verification steps and the test that fails on main. It is directly related to the changeset.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 2 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Linked repositories: Some configured repositories could not be included in this review. Cross-repository analysis may be incomplete. Please check linked-repository access and settings.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: clerk/javascript
  • Branch: main
  • File: .coderabbit.yaml
  • Commit: 794cd47
  • Layers: Repository YAML (base), Organization UI (inherited)
  • Review profile: ASSERTIVE
  • Plan: Team
  • Run ID: 49d241d2-04f6-4eed-bbc2-12fd84ac95a0
Commits

Reviewing files that changed from the base of the PR and between 794cd47 and 7905207.

Files selected for processing: 3
  • .changeset/expo-apple-verification-error.md
  • packages/expo/src/hooks/__tests__/useSignInWithApple.test.ts
  • packages/expo/src/hooks/useSignInWithApple.ios.ts
Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

Included review availability: This review used your included allowance. 2 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 4 reviews per hour.

@pkg-pr-new

pkg-pr-new Bot commented Nov 4, 2026

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@10644

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@10644

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@10644

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@10644

@clerk/electron

npm i https://pkg.pr.new/@clerk/electron@10644

@clerk/electron-passkeys

npm i https://pkg.pr.new/@clerk/electron-passkeys@10644

@clerk/eslint-plugin

npm i https://pkg.pr.new/@clerk/eslint-plugin@10644

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@10644

@clerk/expo-biometrics

npm i https://pkg.pr.new/@clerk/expo-biometrics@10644

@clerk/expo-google-signin

npm i https://pkg.pr.new/@clerk/expo-google-signin@10644

@clerk/expo-native-components

npm i https://pkg.pr.new/@clerk/expo-native-components@10644

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@10644

@clerk/express

npm i https://pkg.pr.new/@clerk/express@10644

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@10644

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@10644

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@10644

@clerk/mosaic

npm i https://pkg.pr.new/@clerk/mosaic@10644

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@10644

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@10644

@clerk/react

npm i https://pkg.pr.new/@clerk/react@10644

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@10644

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@10644

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@10644

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@10644

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@10644

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@10644

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@10644

commit: 7905207

@blacksmith-sh

blacksmith-sh Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Matches Apple fallback sign-in throws verification error

Before, the hook returned no session and no error; after, it throws a ClerkAPIResponseError with status 422 that isClerkAPIResponseError accepts, carrying the verification code and long message.

Merge-base

Returns null silently

This PR 79052077

Throws verification error

Also checked · 1 match

Matches Other Apple paths unchanged

Proof on 79052077 · Did Proof get it right? Yes · No

View full Proof report

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

API Changes Report

Generated by Break Check on 2026-11-04T14:17:03.803Z

Summary

Metric Count
Packages analyzed 20
Packages with changes 0
🔴 Breaking changes 0
🟡 Non-breaking changes 0
🟢 Additions 0

No API Changes Detected

All packages have stable APIs with no detected changes.


Report generated by Break Check

Last ran on 7905207.

@mikepitre
mikepitre requested a review from wobsoriano November 4, 2026 14:18
@mikepitre
mikepitre merged commit 6acfb99 into main Nov 4, 2026
69 checks passed
@mikepitre
mikepitre deleted the mike/expo-apple-verification-error branch November 4, 2026 15:04

This branch was successfully deployed

2 active deployments
Preview – swingset — 79052077 Deployed Nov 4, 2026 by vercel[bot]
Preview – clerk-js-sandbox — 79052077 Deployed Nov 4, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants