This commit is contained in:
2026-09-28 16:01:03 +02:00
parent 471ec4b12a
commit 4627266577
4 changed files with 26 additions and 7 deletions
+13 -3
View File
@@ -77,10 +77,20 @@ export const ipalKit = (options: IpalOptions): Plugin => {
// node_modules). Avoids TS2307 without @ts-expect-error; the module
// exists at runtime in projects that installed it.
const pkg = '@clocklimited/payload-2fa'
const { totpPlugin } = (await import(pkg)) as {
totpPlugin: (opts: Record<string, unknown>) => Plugin
const mod = (await import(pkg)) as {
payloadTotp?: (opts: Record<string, unknown>) => Plugin
totpPlugin?: (opts: Record<string, unknown>) => Plugin
}
config = await totpPlugin({
// The package exports `payloadTotp`; older/other builds may use
// `totpPlugin`. Accept either so a rename doesn't break us.
const totp = mod.payloadTotp ?? mod.totpPlugin
if (typeof totp !== 'function') {
throw new Error(
'expected export payloadTotp (or totpPlugin) to be a function — ' +
'check the installed @clocklimited/payload-2fa version',
)
}
config = await totp({
collection: tf.collectionSlug ?? 'users',
forceSetup: true, // ENFORCED — every user must set up TOTP; no opt-out
totp: { issuer: tf.issuer },