@lunora/auth 1.0.0-alpha.28 → 1.0.0-alpha.280

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/LICENSE.md +233 -104
  2. package/README.md +109 -15
  3. package/dist/adapter.d.mts +4 -43
  4. package/dist/adapter.d.ts +4 -43
  5. package/dist/adapter.mjs +1 -48
  6. package/dist/audit.d.mts +173 -0
  7. package/dist/audit.d.ts +173 -0
  8. package/dist/audit.mjs +1 -0
  9. package/dist/cimd-node.d.mts +1 -0
  10. package/dist/cimd-node.d.ts +1 -0
  11. package/dist/cimd-node.mjs +1 -0
  12. package/dist/cimd-workers.d.mts +64 -0
  13. package/dist/cimd-workers.d.ts +64 -0
  14. package/dist/cimd-workers.mjs +1 -0
  15. package/dist/email-guard.d.mts +143 -0
  16. package/dist/email-guard.d.ts +143 -0
  17. package/dist/email-guard.mjs +1 -0
  18. package/dist/index.d.mts +620 -541
  19. package/dist/index.d.ts +620 -541
  20. package/dist/index.mjs +1 -12
  21. package/dist/middleware.d.mts +165 -155
  22. package/dist/middleware.d.ts +165 -155
  23. package/dist/middleware.mjs +1 -56
  24. package/dist/migrate.d.mts +62 -0
  25. package/dist/migrate.d.ts +62 -0
  26. package/dist/migrate.mjs +1 -0
  27. package/dist/packem_shared/AUTH_DO_AUDIT_PATH-jbpoDPJs.mjs +1 -0
  28. package/dist/packem_shared/DEFAULT_AUTH_BASE_PATH-C3SqYG3N.mjs +1 -0
  29. package/dist/packem_shared/LunoraAuthAdminError-Cg94b5lr.mjs +1 -0
  30. package/dist/packem_shared/adapter-L3XvHnkW.mjs +2 -0
  31. package/dist/packem_shared/adapter.d-BEvPbvSs.d.ts +110 -0
  32. package/dist/packem_shared/adapter.d-RQVSeO5T.d.mts +110 -0
  33. package/dist/packem_shared/api-key-storage-D15k9_CF.mjs +1 -0
  34. package/dist/packem_shared/apiKey-B9uGt5Nc.mjs +1 -0
  35. package/dist/packem_shared/audit-daeExZWv.mjs +12 -0
  36. package/dist/packem_shared/auth-do-JzJM4sBK.mjs +1 -0
  37. package/dist/packem_shared/authAuditBeforeHook-DPRq6mbA.mjs +1 -0
  38. package/dist/packem_shared/authBackfillStatus-ZDUCk4U6.mjs +1 -0
  39. package/dist/packem_shared/authCanonicalEmailColumn-CfhnJ1Wp.mjs +1 -0
  40. package/dist/packem_shared/authCredentialColumns-CnsISHUl.mjs +1 -0
  41. package/dist/packem_shared/authDiscoveryPaths-BtKCs_3V.mjs +1 -0
  42. package/dist/packem_shared/authDoColumnAdditions-UwF3Rl41.mjs +1 -0
  43. package/dist/packem_shared/convertAuthDatesOnce-DE_O-bpx.mjs +1 -0
  44. package/dist/packem_shared/create-auth.d-B8S7aw9O.d.mts +153 -0
  45. package/dist/packem_shared/create-auth.d-B8S7aw9O.d.ts +153 -0
  46. package/dist/packem_shared/createAuth-DFkaeVge.mjs +1 -0
  47. package/dist/packem_shared/createDoAuthWiring-o3mfSSIf.mjs +1 -0
  48. package/dist/packem_shared/createLunoraAuthClient-wzZk9E0m.mjs +1 -0
  49. package/dist/packem_shared/createSignUpInvitation-miwkunlA.mjs +1 -0
  50. package/dist/packem_shared/effectiveCookieCache-JvL6i6YO.mjs +1 -0
  51. package/dist/packem_shared/emailGateDatabaseHooks-Dvyliwxx.mjs +1 -0
  52. package/dist/packem_shared/handleAuthRequest-Id9Vv_Tk.mjs +1 -0
  53. package/dist/packem_shared/identity-claims-hAvIl2wm.mjs +1 -0
  54. package/dist/packem_shared/invitation-email-backfill-DUwurNbV.mjs +1 -0
  55. package/dist/packem_shared/invite-only.d-CsBPLsY1.d.mts +126 -0
  56. package/dist/packem_shared/invite-only.d-JdPDmy_a.d.ts +126 -0
  57. package/dist/packem_shared/isDevEnvironment-yLbPngwn.mjs +1 -0
  58. package/dist/packem_shared/legacyIssuerCleanupStatements-DCL5uV55.mjs +1 -0
  59. package/dist/packem_shared/mcp-CK5XkDFp.mjs +1 -0
  60. package/dist/packem_shared/on-cloudflare-edge-Dx6gFjBO.mjs +1 -0
  61. package/dist/packem_shared/prepareAuthData-CP4M7zk1.mjs +1 -0
  62. package/dist/packem_shared/provision-DWGVCbQD.mjs +1 -0
  63. package/dist/packem_shared/quote-identifier-CGiYFBvY.mjs +1 -0
  64. package/dist/packem_shared/resolveSessionIdentity-EBhckRBW.mjs +1 -0
  65. package/dist/packem_shared/sessionPresets-DQQYAOER.mjs +1 -0
  66. package/dist/packem_shared/sql-store-CFeVqF0V.mjs +1 -0
  67. package/dist/packem_shared/uiConfig-B8pN6pks.mjs +1 -0
  68. package/dist/packem_shared/worker.d-CDnMrB5s.d.mts +912 -0
  69. package/dist/packem_shared/worker.d-CVuhZPM3.d.ts +912 -0
  70. package/dist/plugins-client.d.mts +251 -1
  71. package/dist/plugins-client.d.ts +251 -1
  72. package/dist/plugins-client.mjs +1 -2
  73. package/dist/plugins-enterprise-client.d.mts +13 -0
  74. package/dist/plugins-enterprise-client.d.ts +13 -0
  75. package/dist/plugins-enterprise-client.mjs +1 -0
  76. package/dist/plugins-enterprise.d.mts +1659 -0
  77. package/dist/plugins-enterprise.d.ts +1659 -0
  78. package/dist/plugins-enterprise.mjs +1 -0
  79. package/dist/plugins.d.mts +180 -2
  80. package/dist/plugins.d.ts +180 -2
  81. package/dist/plugins.mjs +1 -22
  82. package/dist/schema.d.mts +47 -39
  83. package/dist/schema.d.ts +47 -39
  84. package/dist/schema.mjs +1 -62
  85. package/dist/sql-store.d.mts +48 -29
  86. package/dist/sql-store.d.ts +48 -29
  87. package/dist/sql-store.mjs +1 -184
  88. package/dist/store.d.mts +65 -47
  89. package/dist/store.d.ts +65 -47
  90. package/dist/store.mjs +1 -183
  91. package/dist/turnstile-middleware.d.mts +73 -55
  92. package/dist/turnstile-middleware.d.ts +73 -55
  93. package/dist/turnstile-middleware.mjs +1 -34
  94. package/dist/turnstile.d.mts +42 -49
  95. package/dist/turnstile.d.ts +42 -49
  96. package/dist/turnstile.mjs +1 -54
  97. package/dist/worker.d.mts +9 -0
  98. package/dist/worker.d.ts +9 -0
  99. package/dist/worker.mjs +1 -0
  100. package/package.json +58 -7
  101. package/dist/packem_shared/DEFAULT_AUTH_BASE_PATH-DjcUWEQl.mjs +0 -11
  102. package/dist/packem_shared/LunoraAuthAdminError-D4L7n6gN.mjs +0 -510
  103. package/dist/packem_shared/compileMigrationsSql-B9bj-mJv.mjs +0 -29
  104. package/dist/packem_shared/create-auth.d-Mwhb4gSc.d.mts +0 -128
  105. package/dist/packem_shared/create-auth.d-Mwhb4gSc.d.ts +0 -128
  106. package/dist/packem_shared/createAuth-BVMMllTm.mjs +0 -87
  107. package/dist/packem_shared/sessionPresets-Dwwd74_J.mjs +0 -38
@@ -0,0 +1 @@
1
+ import{sso as o}from"@better-auth/sso";const n=i=>{i?.domainVerification?.enabled!==!0&&console.warn("@lunora/auth: sso() is installed without `domainVerification: { enabled: true }` — an unverified `domain` still routes sign-in, so any signed-in user can register an identity provider for a domain they do not own. `/sso/register` is also session-only; narrow `providersLimit` if you keep verification off. Pass `domainVerification: { enabled: true }` once your deployment can prove domain ownership.")},r=(i=>(n(i),o(i)));export{r as sso};
@@ -1,5 +1,35 @@
1
+ import { apiKey as apiKey$1 } from '@better-auth/api-key';
2
+ export {
3
+ /**
4
+ * Close self-serve sign-up to invited addresses only: an account is created only
5
+ * for an email an administrator has invited with `createSignUpInvitation`.
6
+ * Declares the `signUpInvitation` table it reads. Lunora's own, not a better-auth
7
+ * re-export.
8
+ */
9
+ type I as InviteOnlyOptions,
10
+ /**
11
+ * Close self-serve sign-up to invited addresses only: an account is created only
12
+ * for an email an administrator has invited with `createSignUpInvitation`.
13
+ * Declares the `signUpInvitation` table it reads. Lunora's own, not a better-auth
14
+ * re-export.
15
+ */
16
+ type a as IssuedSignUpInvitation,
17
+ /**
18
+ * Close self-serve sign-up to invited addresses only: an account is created only
19
+ * for an email an administrator has invited with `createSignUpInvitation`.
20
+ * Declares the `signUpInvitation` table it reads. Lunora's own, not a better-auth
21
+ * re-export.
22
+ */
23
+ type S as SignUpInvitation, i as inviteOnly } from "./packem_shared/invite-only.d-CsBPLsY1.mjs";
24
+ import { RequireMcpAuthOptions, McpOptions, mcp as mcp$1, requireMcpAuth as requireMcpAuth$1 } from '@better-auth/mcp';
25
+ export { createMcpProtectedRequestHandler } from '@better-auth/mcp';
26
+ import { BetterAuthPlugin } from 'better-auth';
27
+ export { cimd } from '@better-auth/cimd';
28
+ export { oauthDeviceAuthorization, oauthProvider } from '@better-auth/oauth-provider';
1
29
  export { passkey } from '@better-auth/passkey';
2
- export { captcha, mcp, withMcpAuth } from 'better-auth/plugins';
30
+ export { scim } from '@better-auth/scim';
31
+ export { createInsufficientScopeError } from 'better-auth/oauth2';
32
+ export { captcha, lastLoginMethod, oneTap } from 'better-auth/plugins';
3
33
  export { createAccessControl } from 'better-auth/plugins/access';
4
34
  export { admin } from 'better-auth/plugins/admin';
5
35
  export { anonymous } from 'better-auth/plugins/anonymous';
@@ -13,10 +43,158 @@ export { jwt } from 'better-auth/plugins/jwt';
13
43
  export { magicLink } from 'better-auth/plugins/magic-link';
14
44
  export { multiSession } from 'better-auth/plugins/multi-session';
15
45
  export { oAuthProxy } from 'better-auth/plugins/oauth-proxy';
16
- export { oidcProvider } from 'better-auth/plugins/oidc-provider';
17
46
  export { oneTimeToken } from 'better-auth/plugins/one-time-token';
18
47
  export { organization } from 'better-auth/plugins/organization';
19
48
  export { phoneNumber } from 'better-auth/plugins/phone-number';
20
49
  export { siwe } from 'better-auth/plugins/siwe';
21
50
  export { twoFactor } from 'better-auth/plugins/two-factor';
22
51
  export { username } from 'better-auth/plugins/username';
52
+ import "./packem_shared/create-auth.d-B8S7aw9O.mjs";
53
+ /**
54
+ * The better-auth `apiKey()` plugin, with its storage configuration recorded on the plugin
55
+ * so `createAuthAdmin().deleteApiKey` can tell a key it can fully revoke from one the
56
+ * plugin also holds in secondary or custom storage.
57
+ */
58
+ declare const apiKey: (...parameters: Parameters<typeof apiKey$1>) => ReturnType<typeof apiKey$1>;
59
+ /** better-auth's `requireMcpAuth` options, with `resource` required. */
60
+ type LunoraRequireMcpAuthOptions = {
61
+ /**
62
+ * The protected-resource URL tokens must be bound to — the same value passed
63
+ * to `mcp({ resource })`.
64
+ */
65
+ resource: string;
66
+ } & RequireMcpAuthOptions;
67
+ /** The auth instance shape better-auth's `requireMcpAuth` accepts. */
68
+ type McpAuthInstance = Parameters<typeof requireMcpAuth$1>[0];
69
+ /** The protected handler: receives the request and the verified token claims. */
70
+ type McpProtectedHandler = Parameters<typeof requireMcpAuth$1>[1];
71
+ /**
72
+ * The MCP authorization server: better-auth's `oauthProvider` configured for MCP,
73
+ * serving the RFC 9728 protected-resource metadata for `resource`. Lunora's
74
+ * worker serves that document and the authorization-server metadata outside the
75
+ * auth base path on its own; that needs this `mcp`, not `@better-auth/mcp`'s.
76
+ */
77
+ declare const mcp: (options: McpOptions) => ReturnType<typeof mcp$1>;
78
+ /**
79
+ * Protect an MCP route on the same deployment as the authorization server.
80
+ * Verifies the bearer token's signature, issuer, audience and expiry, and hands
81
+ * the verified claims to `handler`.
82
+ * @throws LunoraError when `resource` is missing, empty or not an absolute URL.
83
+ */
84
+ declare const requireMcpAuth: (auth: McpAuthInstance, handler: McpProtectedHandler, options: LunoraRequireMcpAuthOptions) => ((request: Request) => Promise<Response>);
85
+ /**
86
+ * The two `.well-known` paths an MCP client fetches before it authorizes:
87
+ * the RFC 9728 protected-resource metadata for `resource` (where the 401
88
+ * challenge points), then the RFC 8414 authorization-server metadata for the
89
+ * issuer.
90
+ *
91
+ * The Lunora worker already serves both for an `.auth()` declaration with
92
+ * `mcp()`; this is for routing them yourself, e.g. in front of a hand-built
93
+ * worker. Pass `authBasePath` when `createAuth` was given a `basePath` other
94
+ * than `/api/auth`.
95
+ * @throws TypeError when `resource` is not an absolute URL.
96
+ */
97
+ declare const mcpDiscoveryPaths: (resource: string, authBasePath?: string) => ReadonlyArray<string>;
98
+ /** Organization sub-features a UI branches on. */
99
+ interface UiConfigOrganization {
100
+ /** Whether an ordinary user may create one at all. */
101
+ allowUserToCreate: boolean;
102
+ enabled: boolean;
103
+ /** Max invitations per organization, when configured. */
104
+ invitationLimit?: number;
105
+ /** Max organizations one user may belong to, when configured. */
106
+ limit?: number;
107
+ /** Max members per organization, when configured. */
108
+ membershipLimit?: number;
109
+ /** Custom roles / dynamic access control are configured. */
110
+ roles: boolean;
111
+ /** Teams are enabled. */
112
+ teams: boolean;
113
+ }
114
+ /** The public payload `GET {basePath}/ui-config` returns. */
115
+ interface UiConfigPayload {
116
+ /** Whether email + password sign-in is enabled. */
117
+ emailAndPassword: boolean;
118
+ /** Absent when `expose.organization` is false — see {@link UiConfigOptions.expose}. */
119
+ organization?: UiConfigOrganization;
120
+ /** Enabled better-auth plugin ids, sorted. Absent when not disclosed. */
121
+ plugins?: string[];
122
+ /** Whether self-serve sign-up is open. */
123
+ signUp: boolean;
124
+ /** Configured social/OAuth provider ids, sorted. Absent when not disclosed. */
125
+ socialProviders?: string[];
126
+ }
127
+ /** Options for {@link uiConfig}. */
128
+ interface UiConfigOptions {
129
+ /**
130
+ * Omit fields from the payload. Everything is published by default; set a
131
+ * key to `false` for a deployment that would rather not enumerate, say, its
132
+ * plugin set to anonymous callers.
133
+ *
134
+ * The field is **omitted, not emptied**. An empty `plugins: []` is
135
+ * indistinguishable from "this deployment runs no plugins", and the client
136
+ * ANDs the server's answer with its own registration — so emptying it would
137
+ * silently switch off every gated card instead of merely withholding the
138
+ * list. Absent means "not disclosed", and the client falls back to what
139
+ * `client.ts` registered.
140
+ */
141
+ expose?: {
142
+ organization?: boolean;
143
+ plugins?: boolean;
144
+ socialProviders?: boolean;
145
+ };
146
+ /**
147
+ * Extra provider ids to advertise beyond `socialProviders`. Providers wired
148
+ * through the `genericOAuth` plugin live in that plugin's own options rather
149
+ * than in `socialProviders`, so they cannot be derived here — list them if
150
+ * you want buttons for them.
151
+ */
152
+ extraProviders?: string[];
153
+ /**
154
+ * Path the endpoint mounts at, relative to the auth basePath.
155
+ * @default "/ui-config"
156
+ */
157
+ path?: string;
158
+ }
159
+ /**
160
+ * A better-auth server plugin publishing {@link UiConfigPayload} at
161
+ * `GET {basePath}/ui-config`.
162
+ *
163
+ * There is no client half: the payload is fetched with a plain `fetch` by
164
+ * whatever renders your auth screens, so it works before a client exists and
165
+ * from a framework this package knows nothing about.
166
+ *
167
+ * The return type is better-auth's own `BetterAuthPlugin` rather than the precise
168
+ * shape of the endpoint map. That is deliberate: `createAuthEndpoint`'s inferred
169
+ * type is anonymous, and naming it is the difference between a build that emits
170
+ * declarations and one that fails only in the bundler — after `tsc` and the
171
+ * tests have both gone green. `BetterAuthPlugin` is what `createAuth({ plugins })`
172
+ * consumes anyway.
173
+ */
174
+ declare const uiConfig: (options?: UiConfigOptions) => BetterAuthPlugin;
175
+ export { type LunoraRequireMcpAuthOptions,
176
+ /**
177
+ * Publish which plugins and social providers this deployment enabled, at
178
+ * `GET {basePath}/ui-config`, so an auth UI configures itself instead of making
179
+ * you restate the list client-side. Lunora's own, not a better-auth re-export.
180
+ */
181
+ type UiConfigOptions,
182
+ /**
183
+ * Publish which plugins and social providers this deployment enabled, at
184
+ * `GET {basePath}/ui-config`, so an auth UI configures itself instead of making
185
+ * you restate the list client-side. Lunora's own, not a better-auth re-export.
186
+ */
187
+ type UiConfigOrganization,
188
+ /**
189
+ * Publish which plugins and social providers this deployment enabled, at
190
+ * `GET {basePath}/ui-config`, so an auth UI configures itself instead of making
191
+ * you restate the list client-side. Lunora's own, not a better-auth re-export.
192
+ */
193
+ type UiConfigPayload,
194
+ /**
195
+ * SCIM 2.0 server — directory-driven user provisioning, so an enterprise IdP can
196
+ * create/update/deactivate users without anyone signing in. Users only (no
197
+ * `/Groups`), and deactivation needs the `admin` plugin. See the package docs for
198
+ * the setup and its security-relevant defaults.
199
+ */
200
+ apiKey, mcp, mcpDiscoveryPaths, requireMcpAuth, uiConfig };
package/dist/plugins.d.ts CHANGED
@@ -1,5 +1,35 @@
1
+ import { apiKey as apiKey$1 } from '@better-auth/api-key';
2
+ export {
3
+ /**
4
+ * Close self-serve sign-up to invited addresses only: an account is created only
5
+ * for an email an administrator has invited with `createSignUpInvitation`.
6
+ * Declares the `signUpInvitation` table it reads. Lunora's own, not a better-auth
7
+ * re-export.
8
+ */
9
+ type I as InviteOnlyOptions,
10
+ /**
11
+ * Close self-serve sign-up to invited addresses only: an account is created only
12
+ * for an email an administrator has invited with `createSignUpInvitation`.
13
+ * Declares the `signUpInvitation` table it reads. Lunora's own, not a better-auth
14
+ * re-export.
15
+ */
16
+ type a as IssuedSignUpInvitation,
17
+ /**
18
+ * Close self-serve sign-up to invited addresses only: an account is created only
19
+ * for an email an administrator has invited with `createSignUpInvitation`.
20
+ * Declares the `signUpInvitation` table it reads. Lunora's own, not a better-auth
21
+ * re-export.
22
+ */
23
+ type S as SignUpInvitation, i as inviteOnly } from "./packem_shared/invite-only.d-JdPDmy_a.js";
24
+ import { RequireMcpAuthOptions, McpOptions, mcp as mcp$1, requireMcpAuth as requireMcpAuth$1 } from '@better-auth/mcp';
25
+ export { createMcpProtectedRequestHandler } from '@better-auth/mcp';
26
+ import { BetterAuthPlugin } from 'better-auth';
27
+ export { cimd } from '@better-auth/cimd';
28
+ export { oauthDeviceAuthorization, oauthProvider } from '@better-auth/oauth-provider';
1
29
  export { passkey } from '@better-auth/passkey';
2
- export { captcha, mcp, withMcpAuth } from 'better-auth/plugins';
30
+ export { scim } from '@better-auth/scim';
31
+ export { createInsufficientScopeError } from 'better-auth/oauth2';
32
+ export { captcha, lastLoginMethod, oneTap } from 'better-auth/plugins';
3
33
  export { createAccessControl } from 'better-auth/plugins/access';
4
34
  export { admin } from 'better-auth/plugins/admin';
5
35
  export { anonymous } from 'better-auth/plugins/anonymous';
@@ -13,10 +43,158 @@ export { jwt } from 'better-auth/plugins/jwt';
13
43
  export { magicLink } from 'better-auth/plugins/magic-link';
14
44
  export { multiSession } from 'better-auth/plugins/multi-session';
15
45
  export { oAuthProxy } from 'better-auth/plugins/oauth-proxy';
16
- export { oidcProvider } from 'better-auth/plugins/oidc-provider';
17
46
  export { oneTimeToken } from 'better-auth/plugins/one-time-token';
18
47
  export { organization } from 'better-auth/plugins/organization';
19
48
  export { phoneNumber } from 'better-auth/plugins/phone-number';
20
49
  export { siwe } from 'better-auth/plugins/siwe';
21
50
  export { twoFactor } from 'better-auth/plugins/two-factor';
22
51
  export { username } from 'better-auth/plugins/username';
52
+ import "./packem_shared/create-auth.d-B8S7aw9O.js";
53
+ /**
54
+ * The better-auth `apiKey()` plugin, with its storage configuration recorded on the plugin
55
+ * so `createAuthAdmin().deleteApiKey` can tell a key it can fully revoke from one the
56
+ * plugin also holds in secondary or custom storage.
57
+ */
58
+ declare const apiKey: (...parameters: Parameters<typeof apiKey$1>) => ReturnType<typeof apiKey$1>;
59
+ /** better-auth's `requireMcpAuth` options, with `resource` required. */
60
+ type LunoraRequireMcpAuthOptions = {
61
+ /**
62
+ * The protected-resource URL tokens must be bound to — the same value passed
63
+ * to `mcp({ resource })`.
64
+ */
65
+ resource: string;
66
+ } & RequireMcpAuthOptions;
67
+ /** The auth instance shape better-auth's `requireMcpAuth` accepts. */
68
+ type McpAuthInstance = Parameters<typeof requireMcpAuth$1>[0];
69
+ /** The protected handler: receives the request and the verified token claims. */
70
+ type McpProtectedHandler = Parameters<typeof requireMcpAuth$1>[1];
71
+ /**
72
+ * The MCP authorization server: better-auth's `oauthProvider` configured for MCP,
73
+ * serving the RFC 9728 protected-resource metadata for `resource`. Lunora's
74
+ * worker serves that document and the authorization-server metadata outside the
75
+ * auth base path on its own; that needs this `mcp`, not `@better-auth/mcp`'s.
76
+ */
77
+ declare const mcp: (options: McpOptions) => ReturnType<typeof mcp$1>;
78
+ /**
79
+ * Protect an MCP route on the same deployment as the authorization server.
80
+ * Verifies the bearer token's signature, issuer, audience and expiry, and hands
81
+ * the verified claims to `handler`.
82
+ * @throws LunoraError when `resource` is missing, empty or not an absolute URL.
83
+ */
84
+ declare const requireMcpAuth: (auth: McpAuthInstance, handler: McpProtectedHandler, options: LunoraRequireMcpAuthOptions) => ((request: Request) => Promise<Response>);
85
+ /**
86
+ * The two `.well-known` paths an MCP client fetches before it authorizes:
87
+ * the RFC 9728 protected-resource metadata for `resource` (where the 401
88
+ * challenge points), then the RFC 8414 authorization-server metadata for the
89
+ * issuer.
90
+ *
91
+ * The Lunora worker already serves both for an `.auth()` declaration with
92
+ * `mcp()`; this is for routing them yourself, e.g. in front of a hand-built
93
+ * worker. Pass `authBasePath` when `createAuth` was given a `basePath` other
94
+ * than `/api/auth`.
95
+ * @throws TypeError when `resource` is not an absolute URL.
96
+ */
97
+ declare const mcpDiscoveryPaths: (resource: string, authBasePath?: string) => ReadonlyArray<string>;
98
+ /** Organization sub-features a UI branches on. */
99
+ interface UiConfigOrganization {
100
+ /** Whether an ordinary user may create one at all. */
101
+ allowUserToCreate: boolean;
102
+ enabled: boolean;
103
+ /** Max invitations per organization, when configured. */
104
+ invitationLimit?: number;
105
+ /** Max organizations one user may belong to, when configured. */
106
+ limit?: number;
107
+ /** Max members per organization, when configured. */
108
+ membershipLimit?: number;
109
+ /** Custom roles / dynamic access control are configured. */
110
+ roles: boolean;
111
+ /** Teams are enabled. */
112
+ teams: boolean;
113
+ }
114
+ /** The public payload `GET {basePath}/ui-config` returns. */
115
+ interface UiConfigPayload {
116
+ /** Whether email + password sign-in is enabled. */
117
+ emailAndPassword: boolean;
118
+ /** Absent when `expose.organization` is false — see {@link UiConfigOptions.expose}. */
119
+ organization?: UiConfigOrganization;
120
+ /** Enabled better-auth plugin ids, sorted. Absent when not disclosed. */
121
+ plugins?: string[];
122
+ /** Whether self-serve sign-up is open. */
123
+ signUp: boolean;
124
+ /** Configured social/OAuth provider ids, sorted. Absent when not disclosed. */
125
+ socialProviders?: string[];
126
+ }
127
+ /** Options for {@link uiConfig}. */
128
+ interface UiConfigOptions {
129
+ /**
130
+ * Omit fields from the payload. Everything is published by default; set a
131
+ * key to `false` for a deployment that would rather not enumerate, say, its
132
+ * plugin set to anonymous callers.
133
+ *
134
+ * The field is **omitted, not emptied**. An empty `plugins: []` is
135
+ * indistinguishable from "this deployment runs no plugins", and the client
136
+ * ANDs the server's answer with its own registration — so emptying it would
137
+ * silently switch off every gated card instead of merely withholding the
138
+ * list. Absent means "not disclosed", and the client falls back to what
139
+ * `client.ts` registered.
140
+ */
141
+ expose?: {
142
+ organization?: boolean;
143
+ plugins?: boolean;
144
+ socialProviders?: boolean;
145
+ };
146
+ /**
147
+ * Extra provider ids to advertise beyond `socialProviders`. Providers wired
148
+ * through the `genericOAuth` plugin live in that plugin's own options rather
149
+ * than in `socialProviders`, so they cannot be derived here — list them if
150
+ * you want buttons for them.
151
+ */
152
+ extraProviders?: string[];
153
+ /**
154
+ * Path the endpoint mounts at, relative to the auth basePath.
155
+ * @default "/ui-config"
156
+ */
157
+ path?: string;
158
+ }
159
+ /**
160
+ * A better-auth server plugin publishing {@link UiConfigPayload} at
161
+ * `GET {basePath}/ui-config`.
162
+ *
163
+ * There is no client half: the payload is fetched with a plain `fetch` by
164
+ * whatever renders your auth screens, so it works before a client exists and
165
+ * from a framework this package knows nothing about.
166
+ *
167
+ * The return type is better-auth's own `BetterAuthPlugin` rather than the precise
168
+ * shape of the endpoint map. That is deliberate: `createAuthEndpoint`'s inferred
169
+ * type is anonymous, and naming it is the difference between a build that emits
170
+ * declarations and one that fails only in the bundler — after `tsc` and the
171
+ * tests have both gone green. `BetterAuthPlugin` is what `createAuth({ plugins })`
172
+ * consumes anyway.
173
+ */
174
+ declare const uiConfig: (options?: UiConfigOptions) => BetterAuthPlugin;
175
+ export { type LunoraRequireMcpAuthOptions,
176
+ /**
177
+ * Publish which plugins and social providers this deployment enabled, at
178
+ * `GET {basePath}/ui-config`, so an auth UI configures itself instead of making
179
+ * you restate the list client-side. Lunora's own, not a better-auth re-export.
180
+ */
181
+ type UiConfigOptions,
182
+ /**
183
+ * Publish which plugins and social providers this deployment enabled, at
184
+ * `GET {basePath}/ui-config`, so an auth UI configures itself instead of making
185
+ * you restate the list client-side. Lunora's own, not a better-auth re-export.
186
+ */
187
+ type UiConfigOrganization,
188
+ /**
189
+ * Publish which plugins and social providers this deployment enabled, at
190
+ * `GET {basePath}/ui-config`, so an auth UI configures itself instead of making
191
+ * you restate the list client-side. Lunora's own, not a better-auth re-export.
192
+ */
193
+ type UiConfigPayload,
194
+ /**
195
+ * SCIM 2.0 server — directory-driven user provisioning, so an enterprise IdP can
196
+ * create/update/deactivate users without anyone signing in. Users only (no
197
+ * `/Groups`), and deactivation needs the `admin` plugin. See the package docs for
198
+ * the setup and its security-relevant defaults.
199
+ */
200
+ apiKey, mcp, mcpDiscoveryPaths, requireMcpAuth, uiConfig };
package/dist/plugins.mjs CHANGED
@@ -1,22 +1 @@
1
- export { passkey } from '@better-auth/passkey';
2
- export { captcha, mcp, withMcpAuth } from 'better-auth/plugins';
3
- export { createAccessControl } from 'better-auth/plugins/access';
4
- export { admin } from 'better-auth/plugins/admin';
5
- export { anonymous } from 'better-auth/plugins/anonymous';
6
- export { bearer } from 'better-auth/plugins/bearer';
7
- export { customSession } from 'better-auth/plugins/custom-session';
8
- export { deviceAuthorization } from 'better-auth/plugins/device-authorization';
9
- export { emailOTP } from 'better-auth/plugins/email-otp';
10
- export { genericOAuth } from 'better-auth/plugins/generic-oauth';
11
- export { haveIBeenPwned } from 'better-auth/plugins/haveibeenpwned';
12
- export { jwt } from 'better-auth/plugins/jwt';
13
- export { magicLink } from 'better-auth/plugins/magic-link';
14
- export { multiSession } from 'better-auth/plugins/multi-session';
15
- export { oAuthProxy } from 'better-auth/plugins/oauth-proxy';
16
- export { oidcProvider } from 'better-auth/plugins/oidc-provider';
17
- export { oneTimeToken } from 'better-auth/plugins/one-time-token';
18
- export { organization } from 'better-auth/plugins/organization';
19
- export { phoneNumber } from 'better-auth/plugins/phone-number';
20
- export { siwe } from 'better-auth/plugins/siwe';
21
- export { twoFactor } from 'better-auth/plugins/two-factor';
22
- export { username } from 'better-auth/plugins/username';
1
+ import{default as e}from"./packem_shared/apiKey-B9uGt5Nc.mjs";import{inviteOnly as m}from"./packem_shared/createSignUpInvitation-miwkunlA.mjs";import{mcp as f,mcpDiscoveryPaths as i,requireMcpAuth as x}from"./packem_shared/mcp-CK5XkDFp.mjs";import{uiConfig as n}from"./packem_shared/uiConfig-B8pN6pks.mjs";import{cimd as s}from"@better-auth/cimd";import{createMcpProtectedRequestHandler as h}from"@better-auth/mcp";import{oauthDeviceAuthorization as l,oauthProvider as v}from"@better-auth/oauth-provider";import{passkey as A}from"@better-auth/passkey";import{scim as g}from"@better-auth/scim";import{createInsufficientScopeError as T}from"better-auth/oauth2";import{captcha as z,lastLoginMethod as M,oneTap as O}from"better-auth/plugins";import{createAccessControl as b}from"better-auth/plugins/access";import{admin as C}from"better-auth/plugins/admin";import{anonymous as I}from"better-auth/plugins/anonymous";import{bearer as j}from"better-auth/plugins/bearer";import{customSession as E}from"better-auth/plugins/custom-session";import{deviceAuthorization as H}from"better-auth/plugins/device-authorization";import{emailOTP as N}from"better-auth/plugins/email-otp";import{genericOAuth as G}from"better-auth/plugins/generic-oauth";import{haveIBeenPwned as Q}from"better-auth/plugins/haveibeenpwned";import{jwt as V}from"better-auth/plugins/jwt";import{magicLink as X}from"better-auth/plugins/magic-link";import{multiSession as Z}from"better-auth/plugins/multi-session";import{oAuthProxy as $}from"better-auth/plugins/oauth-proxy";import{oneTimeToken as ro}from"better-auth/plugins/one-time-token";import{organization as to}from"better-auth/plugins/organization";import{phoneNumber as po}from"better-auth/plugins/phone-number";import{siwe as io}from"better-auth/plugins/siwe";import{twoFactor as ao}from"better-auth/plugins/two-factor";import{username as co}from"better-auth/plugins/username";export{C as admin,I as anonymous,e as apiKey,j as bearer,z as captcha,s as cimd,b as createAccessControl,T as createInsufficientScopeError,h as createMcpProtectedRequestHandler,E as customSession,H as deviceAuthorization,N as emailOTP,G as genericOAuth,Q as haveIBeenPwned,m as inviteOnly,V as jwt,M as lastLoginMethod,X as magicLink,f as mcp,i as mcpDiscoveryPaths,Z as multiSession,$ as oAuthProxy,l as oauthDeviceAuthorization,v as oauthProvider,O as oneTap,ro as oneTimeToken,to as organization,A as passkey,po as phoneNumber,x as requireMcpAuth,g as scim,io as siwe,ao as twoFactor,n as uiConfig,co as username};
package/dist/schema.d.mts CHANGED
@@ -1,44 +1,52 @@
1
1
  import { TableDefinition } from '@lunora/server';
2
- import { a as LunoraAuthOptions } from "./packem_shared/create-auth.d-Mwhb4gSc.mjs";
2
+ import { a as LunoraAuthOptions } from "./packem_shared/create-auth.d-B8S7aw9O.mjs";
3
3
  import 'better-auth';
4
4
  /**
5
- * Derive Lunora table definitions from a better-auth config — the bridge that
6
- * makes the **full** better-auth plugin ecosystem first-class Lunora data.
7
- *
8
- * better-auth's own `getAuthTables(options)` already merges every configured
9
- * plugin's `schema` into one table map (core `user`/`session`/`account`/
10
- * `verification`, plus whatever the plugins on `options.plugins` add —
11
- * `organization`/`member`/`invitation`/`team`/`teamMember` from the
12
- * organization plugin, `role`/`banned`/… columns from admin, `passkey`,
13
- * `twoFactor`, `jwks`, …). This walks that map and emits an equivalent
14
- * `defineTable` for each, so adding a plugin to `options.plugins` automatically
15
- * surfaces its tables in the Lunora schema — no hand-written table definitions
16
- * to keep in sync.
17
- *
18
- * Spread the result into `defineSchema` alongside your app tables (the keys are
19
- * better-auth's real table names — `user`, `session`, … — left **unprefixed**
20
- * because better-auth's adapter addresses them by exactly those names). Because
21
- * the names are unprefixed, do **not** declare an app table that reuses one of
22
- * better-auth's reserved names in the same `defineSchema` — JS spread order
23
- * would let the later key win silently (unlike the plugin-extension path, which
24
- * throws on collision):
25
- *
26
- * ```ts
27
- * import { authTables } from "@lunora/auth";
28
- * const authOptions = { emailAndPassword: { enabled: true }, plugins: [organization(), admin()] };
29
- * export const schema = defineSchema({
30
- * ...authTables(authOptions),
31
- * todos: defineTable({ title: v.string() }),
32
- * });
33
- * ```
34
- *
35
- * Scope: this emits the table **shapes** (columns + types + nullability +
36
- * uniqueness + FK ids). It deliberately does not carry better-auth's
37
- * `defaultValue`/`onUpdate` (filled by better-auth's own write layer), `index`
38
- * hints, or `bigint` precision (`bigint` fields map to `v.number()`). Those only
39
- * matter once better-auth's writes are routed through Lunora's ORM — a separate
40
- * adapter follow-up; today the auth rows are still written by better-auth's D1
41
- * adapter and these tables make them typed + queryable via `ctx.db`.
42
- */
5
+ * Derive Lunora table definitions from a better-auth config — the bridge that
6
+ * makes the **full** better-auth plugin ecosystem first-class Lunora data.
7
+ *
8
+ * better-auth's own `getAuthTables(options)` already merges every configured
9
+ * plugin's `schema` into one table map (core `user`/`session`/`account`/
10
+ * `verification`, plus whatever the plugins on `options.plugins` add —
11
+ * `organization`/`member`/`invitation`/`team`/`teamMember` from the
12
+ * organization plugin, `role`/`banned`/… columns from admin, `passkey`,
13
+ * `twoFactor`, `jwks`, …). This walks that map and emits an equivalent
14
+ * `defineTable` for each, so adding a plugin to `options.plugins` automatically
15
+ * surfaces its tables in the Lunora schema — no hand-written table definitions
16
+ * to keep in sync.
17
+ *
18
+ * Spread the result into `defineSchema` alongside your app tables (the keys are
19
+ * better-auth's real table names — `user`, `session`, … — left **unprefixed**
20
+ * because better-auth's adapter addresses them by exactly those names). Because
21
+ * the names are unprefixed, do **not** declare an app table that reuses one of
22
+ * better-auth's reserved names in the same `defineSchema` — JS spread order
23
+ * would let the later key win silently (unlike the plugin-extension path, which
24
+ * throws on collision):
25
+ *
26
+ * ```ts
27
+ * import { authTables } from "@lunora/auth";
28
+ * const authOptions = { emailAndPassword: { enabled: true }, plugins: [organization(), admin()] };
29
+ * export const schema = defineSchema({
30
+ * ...authTables(authOptions),
31
+ * todos: defineTable({ title: v.string() }),
32
+ * });
33
+ * ```
34
+ *
35
+ * Scope: this emits the table **shapes** (columns + types + nullability +
36
+ * uniqueness + FK ids). It deliberately does not carry better-auth's
37
+ * `defaultValue`/`onUpdate` (filled by better-auth's own write layer), `index`
38
+ * hints, or `bigint` precision (`bigint` fields map to `v.number()`). Those only
39
+ * matter once better-auth's writes are routed through Lunora's ORM — a separate
40
+ * adapter follow-up; today the auth rows are still written by better-auth's D1
41
+ * adapter and these tables make them typed + queryable via `ctx.db`.
42
+ *
43
+ * `user.emailCanonical` is among the columns: Lunora's uniquely indexed, case- and
44
+ * Unicode-folded copy of `email`, which the admin plane's duplicate-address check matches
45
+ * on. Because these tables are ordinary schema tables, the admin-token import writes their
46
+ * rows as given, and that includes `emailCanonical`. Such an import is trusted operator
47
+ * input. A `NULL` value is refilled from `email` by the backfill (Durable Object, `ensureMigrated`),
48
+ * which reads `IS NULL` only: an empty string is kept, so supply `null` for a missing value. A value
49
+ * that does not match its `email` is kept too, and the duplicate check then trusts it. The auth data port's own import recomputes the value instead.
50
+ */
43
51
  declare const authTables: (options: LunoraAuthOptions) => Record<string, TableDefinition>;
44
52
  export { authTables as default };
package/dist/schema.d.ts CHANGED
@@ -1,44 +1,52 @@
1
1
  import { TableDefinition } from '@lunora/server';
2
- import { a as LunoraAuthOptions } from "./packem_shared/create-auth.d-Mwhb4gSc.js";
2
+ import { a as LunoraAuthOptions } from "./packem_shared/create-auth.d-B8S7aw9O.js";
3
3
  import 'better-auth';
4
4
  /**
5
- * Derive Lunora table definitions from a better-auth config — the bridge that
6
- * makes the **full** better-auth plugin ecosystem first-class Lunora data.
7
- *
8
- * better-auth's own `getAuthTables(options)` already merges every configured
9
- * plugin's `schema` into one table map (core `user`/`session`/`account`/
10
- * `verification`, plus whatever the plugins on `options.plugins` add —
11
- * `organization`/`member`/`invitation`/`team`/`teamMember` from the
12
- * organization plugin, `role`/`banned`/… columns from admin, `passkey`,
13
- * `twoFactor`, `jwks`, …). This walks that map and emits an equivalent
14
- * `defineTable` for each, so adding a plugin to `options.plugins` automatically
15
- * surfaces its tables in the Lunora schema — no hand-written table definitions
16
- * to keep in sync.
17
- *
18
- * Spread the result into `defineSchema` alongside your app tables (the keys are
19
- * better-auth's real table names — `user`, `session`, … — left **unprefixed**
20
- * because better-auth's adapter addresses them by exactly those names). Because
21
- * the names are unprefixed, do **not** declare an app table that reuses one of
22
- * better-auth's reserved names in the same `defineSchema` — JS spread order
23
- * would let the later key win silently (unlike the plugin-extension path, which
24
- * throws on collision):
25
- *
26
- * ```ts
27
- * import { authTables } from "@lunora/auth";
28
- * const authOptions = { emailAndPassword: { enabled: true }, plugins: [organization(), admin()] };
29
- * export const schema = defineSchema({
30
- * ...authTables(authOptions),
31
- * todos: defineTable({ title: v.string() }),
32
- * });
33
- * ```
34
- *
35
- * Scope: this emits the table **shapes** (columns + types + nullability +
36
- * uniqueness + FK ids). It deliberately does not carry better-auth's
37
- * `defaultValue`/`onUpdate` (filled by better-auth's own write layer), `index`
38
- * hints, or `bigint` precision (`bigint` fields map to `v.number()`). Those only
39
- * matter once better-auth's writes are routed through Lunora's ORM — a separate
40
- * adapter follow-up; today the auth rows are still written by better-auth's D1
41
- * adapter and these tables make them typed + queryable via `ctx.db`.
42
- */
5
+ * Derive Lunora table definitions from a better-auth config — the bridge that
6
+ * makes the **full** better-auth plugin ecosystem first-class Lunora data.
7
+ *
8
+ * better-auth's own `getAuthTables(options)` already merges every configured
9
+ * plugin's `schema` into one table map (core `user`/`session`/`account`/
10
+ * `verification`, plus whatever the plugins on `options.plugins` add —
11
+ * `organization`/`member`/`invitation`/`team`/`teamMember` from the
12
+ * organization plugin, `role`/`banned`/… columns from admin, `passkey`,
13
+ * `twoFactor`, `jwks`, …). This walks that map and emits an equivalent
14
+ * `defineTable` for each, so adding a plugin to `options.plugins` automatically
15
+ * surfaces its tables in the Lunora schema — no hand-written table definitions
16
+ * to keep in sync.
17
+ *
18
+ * Spread the result into `defineSchema` alongside your app tables (the keys are
19
+ * better-auth's real table names — `user`, `session`, … — left **unprefixed**
20
+ * because better-auth's adapter addresses them by exactly those names). Because
21
+ * the names are unprefixed, do **not** declare an app table that reuses one of
22
+ * better-auth's reserved names in the same `defineSchema` — JS spread order
23
+ * would let the later key win silently (unlike the plugin-extension path, which
24
+ * throws on collision):
25
+ *
26
+ * ```ts
27
+ * import { authTables } from "@lunora/auth";
28
+ * const authOptions = { emailAndPassword: { enabled: true }, plugins: [organization(), admin()] };
29
+ * export const schema = defineSchema({
30
+ * ...authTables(authOptions),
31
+ * todos: defineTable({ title: v.string() }),
32
+ * });
33
+ * ```
34
+ *
35
+ * Scope: this emits the table **shapes** (columns + types + nullability +
36
+ * uniqueness + FK ids). It deliberately does not carry better-auth's
37
+ * `defaultValue`/`onUpdate` (filled by better-auth's own write layer), `index`
38
+ * hints, or `bigint` precision (`bigint` fields map to `v.number()`). Those only
39
+ * matter once better-auth's writes are routed through Lunora's ORM — a separate
40
+ * adapter follow-up; today the auth rows are still written by better-auth's D1
41
+ * adapter and these tables make them typed + queryable via `ctx.db`.
42
+ *
43
+ * `user.emailCanonical` is among the columns: Lunora's uniquely indexed, case- and
44
+ * Unicode-folded copy of `email`, which the admin plane's duplicate-address check matches
45
+ * on. Because these tables are ordinary schema tables, the admin-token import writes their
46
+ * rows as given, and that includes `emailCanonical`. Such an import is trusted operator
47
+ * input. A `NULL` value is refilled from `email` by the backfill (Durable Object, `ensureMigrated`),
48
+ * which reads `IS NULL` only: an empty string is kept, so supply `null` for a missing value. A value
49
+ * that does not match its `email` is kept too, and the duplicate check then trusts it. The auth data port's own import recomputes the value instead.
50
+ */
43
51
  declare const authTables: (options: LunoraAuthOptions) => Record<string, TableDefinition>;
44
52
  export { authTables as default };