2FA fixed
This commit is contained in:
+15
-12
@@ -1,11 +1,14 @@
|
||||
import type { Field, Plugin } from 'payload'
|
||||
import type { CollectionSlug, Field, Plugin } from 'payload'
|
||||
|
||||
/**
|
||||
* Factory shape of @clocklimited/payload-2fa's `payloadTotp` export — injected
|
||||
* so the plugin never imports the optional peer itself.
|
||||
* so the plugin never imports the optional peer itself. `collection` is
|
||||
* `CollectionSlug` (not `string`): payloadTotp requires it, and in a project
|
||||
* with generated payload-types it's a narrowed union — `string` would make
|
||||
* `plugin: payloadTotp` fail to type-check.
|
||||
*/
|
||||
export type TotpPluginFactory = (options: {
|
||||
collection: string
|
||||
collection: CollectionSlug
|
||||
forceSetup: boolean
|
||||
totp: { issuer: string }
|
||||
}) => Plugin
|
||||
@@ -90,19 +93,19 @@ export type IpalOptions = {
|
||||
twoFactor?:
|
||||
| {
|
||||
/** Auth collection slug. Defaults to 'users'. */
|
||||
collectionSlug?: string
|
||||
collectionSlug?: CollectionSlug
|
||||
/** Name shown in the authenticator app (e.g. company/site name). */
|
||||
issuer: string
|
||||
/**
|
||||
* The 2FA plugin factory, INJECTED from the project:
|
||||
* `import { payloadTotp } from '@clocklimited/payload-2fa'`. Strongly
|
||||
* recommended — injecting it (the same pattern as NextResponse /
|
||||
* revalidatePath) means the plugin never dynamically imports the
|
||||
* optional peer, which Next can fail to bundle into the server chunks
|
||||
* ("Cannot find module '@clocklimited/payload-2fa'" at runtime, even on
|
||||
* public frontend pages). If omitted, the plugin falls back to a dynamic
|
||||
* import and you MUST add '@clocklimited/payload-2fa' to
|
||||
* serverExternalPackages in next.config. See docs/security.md.
|
||||
* `import { payloadTotp } from '@clocklimited/payload-2fa'`. REQUIRED in
|
||||
* Next — injecting it (the same pattern as NextResponse / revalidatePath)
|
||||
* means the plugin never dynamically imports the optional peer, which
|
||||
* Next can't bundle ("Cannot find module '@clocklimited/payload-2fa'",
|
||||
* even on public frontend pages). serverExternalPackages is no fix: the
|
||||
* package imports its own .css, which Node can't load. If omitted, the
|
||||
* plugin falls back to a dynamic import — works only outside Next
|
||||
* (payload CLI). See docs/security.md.
|
||||
*/
|
||||
plugin?: TotpPluginFactory
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user