Skip to content

Commit 34edeb9

Browse files
committed
test(plugin-auth): account for the one-time-token plugin in both auth-manager plugin inventories
Claude-Session: https://claude.ai/code/session_01JQwxbZkE4E6sE72j23Afwx Co-authored-by: Claude <noreply@anthropic.com>
1 parent 766bb72 commit 34edeb9

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

‎packages/plugins/plugin-auth/src/better-auth-schema-parity.test.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ import { magicLink } from 'better-auth/plugins/magic-link';
102102
import { phoneNumber } from 'better-auth/plugins/phone-number';
103103
import { jwt } from 'better-auth/plugins/jwt';
104104
import { deviceAuthorization } from 'better-auth/plugins/device-authorization';
105+
import { oneTimeToken } from 'better-auth/plugins/one-time-token';
106+
import { ONE_TIME_TOKEN_EXPIRES_IN_MINUTES, oneTimeTokenStoreHasher } from './one-time-token-handoff.js';
105107
import { sso } from '@better-auth/sso';
106108
import { scim } from '@better-auth/scim';
107109
import {
@@ -244,6 +246,18 @@ const AUTH_MANAGER_PLUGINS: Record<string, { construct: () => unknown } | { skip
244246
deviceAuthorization: {
245247
construct: () => deviceAuthorization({ schema: buildDeviceAuthorizationPluginSchema() }),
246248
},
249+
// The options the plugin list passes. The plugin stores its tokens in the
250+
// core `verification` model and declares no model or column of its own;
251+
// it is constructed anyway, so a version bump that gives it one is
252+
// compared the day it lands.
253+
oneTimeToken: {
254+
construct: () =>
255+
oneTimeToken({
256+
expiresIn: ONE_TIME_TOKEN_EXPIRES_IN_MINUTES,
257+
disableClientRequest: true,
258+
storeToken: { type: 'custom-hasher', hash: oneTimeTokenStoreHasher },
259+
}),
260+
},
247261
customSession: {
248262
construct: () =>
249263
customSession(async ({ user, session }: { user: unknown; session: unknown }) => ({

‎packages/plugins/plugin-auth/src/managed-extension-fields.test.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ import { admin } from 'better-auth/plugins/admin';
107107
import { bearer } from 'better-auth/plugins/bearer';
108108
import { customSession } from 'better-auth/plugins/custom-session';
109109
import { deviceAuthorization } from 'better-auth/plugins/device-authorization';
110+
import { oneTimeToken } from 'better-auth/plugins/one-time-token';
111+
import { ONE_TIME_TOKEN_EXPIRES_IN_MINUTES, oneTimeTokenStoreHasher } from './one-time-token-handoff.js';
110112
import { genericOAuth } from 'better-auth/plugins/generic-oauth';
111113
import { haveIBeenPwned } from 'better-auth/plugins/haveibeenpwned';
112114
import { magicLink } from 'better-auth/plugins/magic-link';
@@ -507,6 +509,18 @@ const AUTH_MANAGER_PLUGINS: Record<string, { construct: () => unknown } | { skip
507509
genericOAuth: { construct: () => genericOAuth({ config: [] }) },
508510
jwt: { construct: () => jwt() },
509511
deviceAuthorization: { construct: () => deviceAuthorization() },
512+
// The options the plugin list passes. The plugin stores its tokens in the
513+
// core `verification` model and declares no model or column of its own;
514+
// it is constructed anyway, so a version bump that gives it one is
515+
// compared the day it lands.
516+
oneTimeToken: {
517+
construct: () =>
518+
oneTimeToken({
519+
expiresIn: ONE_TIME_TOKEN_EXPIRES_IN_MINUTES,
520+
disableClientRequest: true,
521+
storeToken: { type: 'custom-hasher', hash: oneTimeTokenStoreHasher },
522+
}),
523+
},
510524
customSession: {
511525
construct: () =>
512526
customSession(async ({ user, session }: { user: unknown; session: unknown }) => ({

0 commit comments

Comments
 (0)