docs(two-factor): mark viewBackupCodes as server-only in its API comment (#9822)

This commit is contained in:
Gustavo Valverde
2026-05-30 23:52:38 +01:00
committed by GitHub
parent a1028d9f1f
commit 9c8ded67b1
2 changed files with 11 additions and 3 deletions
@@ -0,0 +1,7 @@
---
"better-auth": patch
---
Document `viewBackupCodes` as a server-only function so its API comment no longer reads like an HTTP route.
The JSDoc above `auth.api.viewBackupCodes` advertised `POST /two-factor/view-backup-codes`, but the endpoint is server-only: it is not registered on the HTTP router and has no client method. The comment now states that it is callable only from trusted server code and that the `userId` should come from an authenticated session.
@@ -507,9 +507,10 @@ export const backupCode2fa = (opts: BackupCodeOptions) => {
},
),
/**
* ### Endpoint
*
* POST `/two-factor/view-backup-codes`
* A server-only function that returns a user's decrypted two-factor
* backup codes. It is not exposed over HTTP and has no client method;
* call it from trusted server code with a `userId` taken from an
* authenticated session.
*
* ### API Methods
*