[GH-ISSUE #2317] [phone number] Allow for phone verification providers which don't allow OTP customization #9144

Closed
opened 2026-04-13 04:30:04 -05:00 by GiteaMirror · 7 comments
Owner

Originally created by @kevcube on GitHub (Apr 16, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/2317

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

I am using Telegram Gateway to verify phone numbers - this platform allows me to send an OTP which is managed by the platform, and allows me to check the user's input against the OTP via API.

The phone number plugin should allow for passing a custom function which sends the OTP, and also passing a custom function which performs validation of the input OTP.

Additionally, telegram gateway will return a request_id which is linked to that OTP, and supports revocation of OTPs.

https://core.telegram.org/gateway/api

Current vs. Expected behavior

current phone number plugin expects the server to set the OTP, when in Telegram Gateway the app's server is never aware of the true OTP. This is also presumably better for security because it limits one way that a backend admin could perform account takeover of a user.

What version of Better Auth are you using?

latest

Provide environment information

- n/a

Which area(s) are affected? (Select all that apply)

Package

Auth config (if applicable)


Additional context

No response

Originally created by @kevcube on GitHub (Apr 16, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/2317 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce I am using Telegram Gateway to verify phone numbers - this platform allows me to send an OTP which is managed by the platform, and allows me to check the user's input against the OTP via API. The phone number plugin should allow for passing a custom function which sends the OTP, and also passing a custom function which performs validation of the input OTP. Additionally, telegram gateway will return a request_id which is linked to that OTP, and supports revocation of OTPs. https://core.telegram.org/gateway/api ### Current vs. Expected behavior current phone number plugin expects the server to set the OTP, when in Telegram Gateway the app's server is never aware of the true OTP. This is also presumably better for security because it limits one way that a backend admin could perform account takeover of a user. ### What version of Better Auth are you using? latest ### Provide environment information ```bash - n/a ``` ### Which area(s) are affected? (Select all that apply) Package ### Auth config (if applicable) ```typescript ``` ### Additional context _No response_
GiteaMirror added the enhancementlocked labels 2026-04-13 04:30:04 -05:00
Author
Owner

@catpddo commented on GitHub (Apr 20, 2025):

I noticed that the Telegram Gateway API allows passing a 'code' parameter.
Documentation
The verification code. Use this parameter if you want to set the verification code yourself. Only fully numeric strings between 4 and 8 characters in length are supported. If this parameter is set, code_length is ignored.

Better Auth uses phone number validation and can also use a custom function to send the code.
Documentation

<!-- gh-comment-id:2816963319 --> @catpddo commented on GitHub (Apr 20, 2025): I noticed that the Telegram Gateway API allows passing a 'code' parameter. [Documentation](https://core.telegram.org/gateway/api#sendverificationmessage) `The verification code. Use this parameter if you want to set the verification code yourself. Only fully numeric strings between 4 and 8 characters in length are supported. If this parameter is set, code_length is ignored.` Better Auth uses phone number validation and can also use a custom function to send the code. [Documentation](https://www.better-auth.com/docs/plugins/phone-number#allow-sign-up-with-phone-number)
Author
Owner

@kevcube commented on GitHub (Apr 20, 2025):

@catpddo you’re right, and I switched to using custom codes. I also use phone verification. But it would still be nice to be able to pass a custom verification function, because I prefer telegram gateway’s method of black-box OTP code sending and verification.

<!-- gh-comment-id:2817063667 --> @kevcube commented on GitHub (Apr 20, 2025): @catpddo you’re right, and I switched to using custom codes. I also use phone verification. But it would still be nice to be able to pass a custom verification function, because I prefer telegram gateway’s method of black-box OTP code sending and verification.
Author
Owner

@dosubot[bot] commented on GitHub (Jul 20, 2025):

Hi, @kevcube. I'm Dosu, and I'm helping the better-auth team manage their backlog. I'm marking this issue as stale.

Issue Summary:

  • You suggested enhancing the phone number plugin to support providers like Telegram Gateway by allowing custom functions for OTP handling.
  • @Catpddo noted that Telegram Gateway API supports custom verification codes and referenced Better Auth's documentation.
  • You acknowledged this but prefer Telegram Gateway's black-box approach for security reasons.
  • @Ninest reacted positively to your comment.

Next Steps:

  • Please confirm if this issue is still relevant to the latest version of the better-auth repository by commenting here.
  • If no updates are provided, the issue will be automatically closed in 7 days.

Thank you for your understanding and contribution!

<!-- gh-comment-id:3094620399 --> @dosubot[bot] commented on GitHub (Jul 20, 2025): Hi, @kevcube. I'm [Dosu](https://dosu.dev), and I'm helping the better-auth team manage their backlog. I'm marking this issue as stale. **Issue Summary:** - You suggested enhancing the phone number plugin to support providers like Telegram Gateway by allowing custom functions for OTP handling. - @Catpddo noted that Telegram Gateway API supports custom verification codes and referenced Better Auth's documentation. - You acknowledged this but prefer Telegram Gateway's black-box approach for security reasons. - @Ninest reacted positively to your comment. **Next Steps:** - Please confirm if this issue is still relevant to the latest version of the better-auth repository by commenting here. - If no updates are provided, the issue will be automatically closed in 7 days. Thank you for your understanding and contribution!
Author
Owner

@Yarmeli commented on GitHub (Jul 24, 2025):

+1

This was also requested a few months ago in #1159 with a fix and a PR attached to it

<!-- gh-comment-id:3111779409 --> @Yarmeli commented on GitHub (Jul 24, 2025): +1 This was also requested a few months ago in #1159 with a fix and a PR attached to it
Author
Owner

@dosubot[bot] commented on GitHub (Oct 23, 2025):

Hi, @kevcube. I'm Dosu, and I'm helping the better-auth team manage their backlog and am marking this issue as stale.

Issue Summary:

  • You requested the phone number plugin to support providers like Telegram Gateway that handle OTPs internally, suggesting custom functions for sending and validating OTPs to improve security.
  • A contributor noted Telegram Gateway's API supports custom verification codes and referenced Better Auth's existing documentation.
  • You acknowledged the documentation but expressed a preference for a black-box OTP approach.
  • The issue remains unresolved with interest shown but no implemented solution yet.
  • A related PR was mentioned in issue #1159 by another user.

Next Steps:

  • Please let me know if this issue is still relevant to the latest version of better-auth by commenting here to keep the discussion open.
  • Otherwise, this issue will be automatically closed in 7 days.

Thanks for your understanding and contribution!

<!-- gh-comment-id:3437838668 --> @dosubot[bot] commented on GitHub (Oct 23, 2025): Hi, @kevcube. I'm [Dosu](https://dosu.dev), and I'm helping the better-auth team manage their backlog and am marking this issue as stale. **Issue Summary:** - You requested the phone number plugin to support providers like Telegram Gateway that handle OTPs internally, suggesting custom functions for sending and validating OTPs to improve security. - A contributor noted Telegram Gateway's API supports custom verification codes and referenced Better Auth's existing documentation. - You acknowledged the documentation but expressed a preference for a black-box OTP approach. - The issue remains unresolved with interest shown but no implemented solution yet. - A related PR was mentioned in issue #1159 by another user. **Next Steps:** - Please let me know if this issue is still relevant to the latest version of better-auth by commenting here to keep the discussion open. - Otherwise, this issue will be automatically closed in 7 days. Thanks for your understanding and contribution!
Author
Owner

@kevcube commented on GitHub (Oct 23, 2025):

Not stale afaikOn Oct 24, 2025, at 00:04, dosubot[bot] @.***> wrote:dosubot[bot] left a comment (better-auth/better-auth#2317)
Hi, @kevcube. I'm Dosu, and I'm helping the better-auth team manage their backlog and am marking this issue as stale.
Issue Summary:

You requested the phone number plugin to support providers like Telegram Gateway that handle OTPs internally, suggesting custom functions for sending and validating OTPs to improve security.
A contributor noted Telegram Gateway's API supports custom verification codes and referenced Better Auth's existing documentation.
You acknowledged the documentation but expressed a preference for a black-box OTP approach.
The issue remains unresolved with interest shown but no implemented solution yet.
A related PR was mentioned in issue #1159 by another user.

Next Steps:

Please let me know if this issue is still relevant to the latest version of better-auth by commenting here to keep the discussion open.
Otherwise, this issue will be automatically closed in 7 days.

Thanks for your understanding and contribution!

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

<!-- gh-comment-id:3437912003 --> @kevcube commented on GitHub (Oct 23, 2025): Not stale afaikOn Oct 24, 2025, at 00:04, dosubot[bot] ***@***.***> wrote:dosubot[bot] left a comment (better-auth/better-auth#2317) Hi, @kevcube. I'm Dosu, and I'm helping the better-auth team manage their backlog and am marking this issue as stale. Issue Summary: You requested the phone number plugin to support providers like Telegram Gateway that handle OTPs internally, suggesting custom functions for sending and validating OTPs to improve security. A contributor noted Telegram Gateway's API supports custom verification codes and referenced Better Auth's existing documentation. You acknowledged the documentation but expressed a preference for a black-box OTP approach. The issue remains unresolved with interest shown but no implemented solution yet. A related PR was mentioned in issue #1159 by another user. Next Steps: Please let me know if this issue is still relevant to the latest version of better-auth by commenting here to keep the discussion open. Otherwise, this issue will be automatically closed in 7 days. Thanks for your understanding and contribution! —Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>
Author
Owner

@dosubot[bot] commented on GitHub (Jan 22, 2026):

Hi, @kevcube. I'm Dosu, and I'm helping the better-auth team manage their backlog and am marking this issue as stale.

Issue Summary:

  • You requested the phone number plugin to support OTP providers like Telegram Gateway that handle OTPs internally.
  • You suggested adding the ability to pass custom functions for sending and validating OTPs to improve security.
  • A contributor noted Telegram Gateway's API supports custom verification codes and referenced existing documentation.
  • You prefer Telegram's black-box OTP approach over custom verification.
  • The issue remains open with interest from other users and references to related PRs, but no resolution yet.

Next Steps:

  • Please confirm if this issue is still relevant to the latest version of better-auth by commenting here.
  • If no response is received within 7 days, I will automatically close the issue.

Thank you for your understanding and contribution!

<!-- gh-comment-id:3785267817 --> @dosubot[bot] commented on GitHub (Jan 22, 2026): Hi, @kevcube. I'm [Dosu](https://dosu.dev), and I'm helping the better-auth team manage their backlog and am marking this issue as stale. **Issue Summary:** - You requested the phone number plugin to support OTP providers like Telegram Gateway that handle OTPs internally. - You suggested adding the ability to pass custom functions for sending and validating OTPs to improve security. - A contributor noted Telegram Gateway's API supports custom verification codes and referenced existing documentation. - You prefer Telegram's black-box OTP approach over custom verification. - The issue remains open with interest from other users and references to related PRs, but no resolution yet. **Next Steps:** - Please confirm if this issue is still relevant to the latest version of better-auth by commenting here. - If no response is received within 7 days, I will automatically close the issue. Thank you for your understanding and contribution!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#9144