[PR #5926] feat(phone-number): allow custom verifyOTP implementation #14576

Closed
opened 2026-04-13 09:31:58 -05:00 by GiteaMirror · 0 comments
Owner

Original Pull Request: https://github.com/better-auth/better-auth/pull/5926

State: closed
Merged: Yes


This PR is based on #1576 by @zain

Tasks

  • Refactor phone number plugin folder
  • Add verifyOTP feature
  • Add unit tests for new API
  • Refactor existing test codes to use proper test instances
  • Update documentation

Closes https://github.com/better-auth/better-auth/issues/1159


Summary by cubic

Adds a custom verifyOTP option to the phone-number plugin so apps can use external OTP verification providers while keeping the existing default flow unchanged. Also refactors the plugin structure and updates tests.

  • New Features

    • Added options.verifyOTP to override internal OTP checks; used in verify and updatePhoneNumber flows.
    • Default OTP logic (expiry and attempt limits) still applies when verifyOTP is not provided.
    • Standardized error exposure via $ERROR_CODES backed by PHONE_NUMBER_ERROR_CODES.
  • Refactors

    • Moved schema to schema.ts and types to types.ts; trimmed index.ts.
    • Renamed ERROR_CODES to PHONE_NUMBER_ERROR_CODES and updated imports.
    • Updated tests to use getTestInstance and added coverage for custom verifyOTP.

Written for commit 04e5df705f. Summary will update automatically on new commits.

**Original Pull Request:** https://github.com/better-auth/better-auth/pull/5926 **State:** closed **Merged:** Yes --- This PR is based on #1576 by @zain ### Tasks - [x] Refactor phone number plugin folder - [x] Add verifyOTP feature - [x] Add unit tests for new API - [x] Refactor existing test codes to use proper test instances - [x] Update documentation Closes https://github.com/better-auth/better-auth/issues/1159 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Adds a custom verifyOTP option to the phone-number plugin so apps can use external OTP verification providers while keeping the existing default flow unchanged. Also refactors the plugin structure and updates tests. - **New Features** - Added options.verifyOTP to override internal OTP checks; used in verify and updatePhoneNumber flows. - Default OTP logic (expiry and attempt limits) still applies when verifyOTP is not provided. - Standardized error exposure via $ERROR_CODES backed by PHONE_NUMBER_ERROR_CODES. - **Refactors** - Moved schema to schema.ts and types to types.ts; trimmed index.ts. - Renamed ERROR_CODES to PHONE_NUMBER_ERROR_CODES and updated imports. - Updated tests to use getTestInstance and added coverage for custom verifyOTP. <sup>Written for commit 04e5df705fb846f7be247931333f924b1eaea32c. Summary will update automatically on new commits.</sup> <!-- End of auto-generated description by cubic. -->
GiteaMirror added the pull-request label 2026-04-13 09:31:58 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#14576