@lunora/auth 1.0.0-alpha.2 → 1.0.0-alpha.200

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 (86) hide show
  1. package/LICENSE.md +38 -0
  2. package/README.md +99 -10
  3. package/__assets__/package-og.svg +1 -1
  4. package/dist/adapter.d.mts +4 -43
  5. package/dist/adapter.d.ts +4 -43
  6. package/dist/adapter.mjs +1 -47
  7. package/dist/audit.d.mts +142 -0
  8. package/dist/audit.d.ts +142 -0
  9. package/dist/audit.mjs +12 -0
  10. package/dist/cimd-node.d.mts +1 -0
  11. package/dist/cimd-node.d.ts +1 -0
  12. package/dist/cimd-node.mjs +1 -0
  13. package/dist/cimd-workers.d.mts +32 -0
  14. package/dist/cimd-workers.d.ts +32 -0
  15. package/dist/cimd-workers.mjs +1 -0
  16. package/dist/email-guard.d.mts +127 -0
  17. package/dist/email-guard.d.ts +127 -0
  18. package/dist/email-guard.mjs +1 -0
  19. package/dist/index.d.mts +935 -147
  20. package/dist/index.d.ts +935 -147
  21. package/dist/index.mjs +1 -12
  22. package/dist/middleware.d.mts +167 -156
  23. package/dist/middleware.d.ts +167 -156
  24. package/dist/middleware.mjs +1 -53
  25. package/dist/packem_shared/AUTH_DO_AUDIT_PATH-CptaQ6ZX.mjs +1 -0
  26. package/dist/packem_shared/DEFAULT_AUTH_BASE_PATH-DneiLGpv.mjs +1 -0
  27. package/dist/packem_shared/LunoraAuthAdminError-uhKG1MgQ.mjs +1 -0
  28. package/dist/packem_shared/adapter-CG0Yv85f.mjs +2 -0
  29. package/dist/packem_shared/adapter.d-CElAPJ1U.d.ts +88 -0
  30. package/dist/packem_shared/adapter.d-CaPwF2v3.d.mts +88 -0
  31. package/dist/packem_shared/auth-do-B2X2lboC.mjs +1 -0
  32. package/dist/packem_shared/authAuditHook-DPTKdjBe.mjs +1 -0
  33. package/dist/packem_shared/authDiscoveryPaths-B14lM14u.mjs +1 -0
  34. package/dist/packem_shared/authDoColumnAdditions-UwF3Rl41.mjs +1 -0
  35. package/dist/packem_shared/compileMigrationsSql-BiYsLz91.mjs +1 -0
  36. package/dist/packem_shared/create-auth.d-D1CKOFWc.d.mts +142 -0
  37. package/dist/packem_shared/create-auth.d-D1CKOFWc.d.ts +142 -0
  38. package/dist/packem_shared/createAuth-BdVltKyf.mjs +1 -0
  39. package/dist/packem_shared/createDoAuthWiring-cqHnqjyh.mjs +1 -0
  40. package/dist/packem_shared/createLunoraAuthClient-DRcFNwp9.mjs +1 -0
  41. package/dist/packem_shared/createSignUpInvitation-DHZL9fNl.mjs +1 -0
  42. package/dist/packem_shared/emailGateDatabaseHooks-CAygR3iq.mjs +1 -0
  43. package/dist/packem_shared/invite-only.d-CsPJWAwM.d.ts +126 -0
  44. package/dist/packem_shared/invite-only.d-DKyHHkkQ.d.mts +126 -0
  45. package/dist/packem_shared/legacyIssuerCleanupStatements-D9Kf8OD1.mjs +1 -0
  46. package/dist/packem_shared/mcp-CgX1hTOv.mjs +1 -0
  47. package/dist/packem_shared/on-cloudflare-edge-Dx6gFjBO.mjs +1 -0
  48. package/dist/packem_shared/quote-identifier-CGiYFBvY.mjs +1 -0
  49. package/dist/packem_shared/sessionPresets-C867Mlo4.mjs +1 -0
  50. package/dist/packem_shared/sql-store-CYa4HJsO.mjs +1 -0
  51. package/dist/packem_shared/uiConfig-B8pN6pks.mjs +1 -0
  52. package/dist/plugins-client.d.mts +250 -1
  53. package/dist/plugins-client.d.ts +250 -1
  54. package/dist/plugins-client.mjs +1 -2
  55. package/dist/plugins-enterprise-client.d.mts +13 -0
  56. package/dist/plugins-enterprise-client.d.ts +13 -0
  57. package/dist/plugins-enterprise-client.mjs +1 -0
  58. package/dist/plugins-enterprise.d.mts +1668 -0
  59. package/dist/plugins-enterprise.d.ts +1668 -0
  60. package/dist/plugins-enterprise.mjs +1 -0
  61. package/dist/plugins.d.mts +167 -2
  62. package/dist/plugins.d.ts +167 -2
  63. package/dist/plugins.mjs +1 -22
  64. package/dist/schema.d.mts +39 -39
  65. package/dist/schema.d.ts +39 -39
  66. package/dist/schema.mjs +1 -62
  67. package/dist/sql-store.d.mts +28 -28
  68. package/dist/sql-store.d.ts +28 -28
  69. package/dist/sql-store.mjs +1 -162
  70. package/dist/store.d.mts +67 -31
  71. package/dist/store.d.ts +67 -31
  72. package/dist/store.mjs +1 -170
  73. package/dist/turnstile-middleware.d.mts +73 -55
  74. package/dist/turnstile-middleware.d.ts +73 -55
  75. package/dist/turnstile-middleware.mjs +1 -45
  76. package/dist/turnstile.d.mts +42 -59
  77. package/dist/turnstile.d.ts +42 -59
  78. package/dist/turnstile.mjs +1 -61
  79. package/package.json +49 -6
  80. package/dist/packem_shared/DEFAULT_AUTH_BASE_PATH-DjcUWEQl.mjs +0 -11
  81. package/dist/packem_shared/LunoraAuthAdminError-BxrfEeA_.mjs +0 -249
  82. package/dist/packem_shared/compileMigrationsSql-wZH3oXDu.mjs +0 -28
  83. package/dist/packem_shared/create-auth.d-M36jwG_Y.d.mts +0 -58
  84. package/dist/packem_shared/create-auth.d-M36jwG_Y.d.ts +0 -58
  85. package/dist/packem_shared/createAuth-B-tvsvQU.mjs +0 -56
  86. package/dist/packem_shared/sessionPresets-B95rXrd8.mjs +0 -35
@@ -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
+ export {
2
+ /**
3
+ * Close self-serve sign-up to invited addresses only: an account is created only
4
+ * for an email an administrator has invited with `createSignUpInvitation`.
5
+ * Declares the `signUpInvitation` table it reads. Lunora's own, not a better-auth
6
+ * re-export.
7
+ */
8
+ type I as InviteOnlyOptions,
9
+ /**
10
+ * Close self-serve sign-up to invited addresses only: an account is created only
11
+ * for an email an administrator has invited with `createSignUpInvitation`.
12
+ * Declares the `signUpInvitation` table it reads. Lunora's own, not a better-auth
13
+ * re-export.
14
+ */
15
+ type a as IssuedSignUpInvitation,
16
+ /**
17
+ * Close self-serve sign-up to invited addresses only: an account is created only
18
+ * for an email an administrator has invited with `createSignUpInvitation`.
19
+ * Declares the `signUpInvitation` table it reads. Lunora's own, not a better-auth
20
+ * re-export.
21
+ */
22
+ type S as SignUpInvitation, i as inviteOnly } from "./packem_shared/invite-only.d-DKyHHkkQ.mjs";
23
+ import { RequireMcpAuthOptions, McpOptions, mcp as mcp$1, requireMcpAuth as requireMcpAuth$1 } from '@better-auth/mcp';
24
+ export { createMcpProtectedRequestHandler } from '@better-auth/mcp';
25
+ import { BetterAuthPlugin } from 'better-auth';
26
+ export { apiKey } from '@better-auth/api-key';
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,145 @@ 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-D1CKOFWc.mjs";
53
+ /** better-auth's `requireMcpAuth` options, with `resource` required. */
54
+ type LunoraRequireMcpAuthOptions = {
55
+ /**
56
+ * The protected-resource URL tokens must be bound to — the same value passed
57
+ * to `mcp({ resource })`.
58
+ */
59
+ resource: string;
60
+ } & RequireMcpAuthOptions;
61
+ /** The auth instance shape better-auth's `requireMcpAuth` accepts. */
62
+ type McpAuthInstance = Parameters<typeof requireMcpAuth$1>[0];
63
+ /** The protected handler: receives the request and the verified token claims. */
64
+ type McpProtectedHandler = Parameters<typeof requireMcpAuth$1>[1];
65
+ /**
66
+ * The MCP authorization server: better-auth's `oauthProvider` configured for MCP,
67
+ * serving the RFC 9728 protected-resource metadata for `resource`. Lunora's
68
+ * worker serves that document and the authorization-server metadata outside the
69
+ * auth base path on its own; that needs this `mcp`, not `@better-auth/mcp`'s.
70
+ */
71
+ declare const mcp: (options: McpOptions) => ReturnType<typeof mcp$1>;
72
+ /**
73
+ * Protect an MCP route on the same deployment as the authorization server.
74
+ * Verifies the bearer token's signature, issuer, audience and expiry, and hands
75
+ * the verified claims to `handler`.
76
+ * @throws LunoraError when `resource` is missing, empty or not an absolute URL.
77
+ */
78
+ declare const requireMcpAuth: (auth: McpAuthInstance, handler: McpProtectedHandler, options: LunoraRequireMcpAuthOptions) => ((request: Request) => Promise<Response>);
79
+ /**
80
+ * The two `.well-known` paths an MCP client fetches before it authorizes:
81
+ * the RFC 9728 protected-resource metadata for `resource` (where the 401
82
+ * challenge points), then the RFC 8414 authorization-server metadata for the
83
+ * issuer.
84
+ *
85
+ * The Lunora worker already serves both for an `.auth()` declaration with
86
+ * `mcp()`; this is for routing them yourself, e.g. in front of a hand-built
87
+ * worker. Pass `authBasePath` when `createAuth` was given a `basePath` other
88
+ * than `/api/auth`.
89
+ * @throws TypeError when `resource` is not an absolute URL.
90
+ */
91
+ declare const mcpDiscoveryPaths: (resource: string, authBasePath?: string) => ReadonlyArray<string>;
92
+ /** Organization sub-features a UI branches on. */
93
+ interface UiConfigOrganization {
94
+ /** Whether an ordinary user may create one at all. */
95
+ allowUserToCreate: boolean;
96
+ enabled: boolean;
97
+ /** Max invitations per organization, when configured. */
98
+ invitationLimit?: number;
99
+ /** Max organizations one user may belong to, when configured. */
100
+ limit?: number;
101
+ /** Max members per organization, when configured. */
102
+ membershipLimit?: number;
103
+ /** Custom roles / dynamic access control are configured. */
104
+ roles: boolean;
105
+ /** Teams are enabled. */
106
+ teams: boolean;
107
+ }
108
+ /** The public payload `GET {basePath}/ui-config` returns. */
109
+ interface UiConfigPayload {
110
+ /** Whether email + password sign-in is enabled. */
111
+ emailAndPassword: boolean;
112
+ /** Absent when `expose.organization` is false — see {@link UiConfigOptions.expose}. */
113
+ organization?: UiConfigOrganization;
114
+ /** Enabled better-auth plugin ids, sorted. Absent when not disclosed. */
115
+ plugins?: string[];
116
+ /** Whether self-serve sign-up is open. */
117
+ signUp: boolean;
118
+ /** Configured social/OAuth provider ids, sorted. Absent when not disclosed. */
119
+ socialProviders?: string[];
120
+ }
121
+ /** Options for {@link uiConfig}. */
122
+ interface UiConfigOptions {
123
+ /**
124
+ * Omit fields from the payload. Everything is published by default; set a
125
+ * key to `false` for a deployment that would rather not enumerate, say, its
126
+ * plugin set to anonymous callers.
127
+ *
128
+ * The field is **omitted, not emptied**. An empty `plugins: []` is
129
+ * indistinguishable from "this deployment runs no plugins", and the client
130
+ * ANDs the server's answer with its own registration — so emptying it would
131
+ * silently switch off every gated card instead of merely withholding the
132
+ * list. Absent means "not disclosed", and the client falls back to what
133
+ * `client.ts` registered.
134
+ */
135
+ expose?: {
136
+ organization?: boolean;
137
+ plugins?: boolean;
138
+ socialProviders?: boolean;
139
+ };
140
+ /**
141
+ * Extra provider ids to advertise beyond `socialProviders`. Providers wired
142
+ * through the `genericOAuth` plugin live in that plugin's own options rather
143
+ * than in `socialProviders`, so they cannot be derived here — list them if
144
+ * you want buttons for them.
145
+ */
146
+ extraProviders?: string[];
147
+ /**
148
+ * Path the endpoint mounts at, relative to the auth basePath.
149
+ * @default "/ui-config"
150
+ */
151
+ path?: string;
152
+ }
153
+ /**
154
+ * A better-auth server plugin publishing {@link UiConfigPayload} at
155
+ * `GET {basePath}/ui-config`.
156
+ *
157
+ * There is no client half: the payload is fetched with a plain `fetch` by
158
+ * whatever renders your auth screens, so it works before a client exists and
159
+ * from a framework this package knows nothing about.
160
+ *
161
+ * The return type is better-auth's own `BetterAuthPlugin` rather than the precise
162
+ * shape of the endpoint map. That is deliberate: `createAuthEndpoint`'s inferred
163
+ * type is anonymous, and naming it is the difference between a build that emits
164
+ * declarations and one that fails only in the bundler — after `tsc` and the
165
+ * tests have both gone green. `BetterAuthPlugin` is what `createAuth({ plugins })`
166
+ * consumes anyway.
167
+ */
168
+ declare const uiConfig: (options?: UiConfigOptions) => BetterAuthPlugin;
169
+ export { type LunoraRequireMcpAuthOptions,
170
+ /**
171
+ * Publish which plugins and social providers this deployment enabled, at
172
+ * `GET {basePath}/ui-config`, so an auth UI configures itself instead of making
173
+ * you restate the list client-side. Lunora's own, not a better-auth re-export.
174
+ */
175
+ type UiConfigOptions,
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 UiConfigOrganization,
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 UiConfigPayload, mcp, mcpDiscoveryPaths, requireMcpAuth, uiConfig };
package/dist/plugins.d.ts CHANGED
@@ -1,5 +1,35 @@
1
+ export {
2
+ /**
3
+ * Close self-serve sign-up to invited addresses only: an account is created only
4
+ * for an email an administrator has invited with `createSignUpInvitation`.
5
+ * Declares the `signUpInvitation` table it reads. Lunora's own, not a better-auth
6
+ * re-export.
7
+ */
8
+ type I as InviteOnlyOptions,
9
+ /**
10
+ * Close self-serve sign-up to invited addresses only: an account is created only
11
+ * for an email an administrator has invited with `createSignUpInvitation`.
12
+ * Declares the `signUpInvitation` table it reads. Lunora's own, not a better-auth
13
+ * re-export.
14
+ */
15
+ type a as IssuedSignUpInvitation,
16
+ /**
17
+ * Close self-serve sign-up to invited addresses only: an account is created only
18
+ * for an email an administrator has invited with `createSignUpInvitation`.
19
+ * Declares the `signUpInvitation` table it reads. Lunora's own, not a better-auth
20
+ * re-export.
21
+ */
22
+ type S as SignUpInvitation, i as inviteOnly } from "./packem_shared/invite-only.d-CsPJWAwM.js";
23
+ import { RequireMcpAuthOptions, McpOptions, mcp as mcp$1, requireMcpAuth as requireMcpAuth$1 } from '@better-auth/mcp';
24
+ export { createMcpProtectedRequestHandler } from '@better-auth/mcp';
25
+ import { BetterAuthPlugin } from 'better-auth';
26
+ export { apiKey } from '@better-auth/api-key';
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,145 @@ 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-D1CKOFWc.js";
53
+ /** better-auth's `requireMcpAuth` options, with `resource` required. */
54
+ type LunoraRequireMcpAuthOptions = {
55
+ /**
56
+ * The protected-resource URL tokens must be bound to — the same value passed
57
+ * to `mcp({ resource })`.
58
+ */
59
+ resource: string;
60
+ } & RequireMcpAuthOptions;
61
+ /** The auth instance shape better-auth's `requireMcpAuth` accepts. */
62
+ type McpAuthInstance = Parameters<typeof requireMcpAuth$1>[0];
63
+ /** The protected handler: receives the request and the verified token claims. */
64
+ type McpProtectedHandler = Parameters<typeof requireMcpAuth$1>[1];
65
+ /**
66
+ * The MCP authorization server: better-auth's `oauthProvider` configured for MCP,
67
+ * serving the RFC 9728 protected-resource metadata for `resource`. Lunora's
68
+ * worker serves that document and the authorization-server metadata outside the
69
+ * auth base path on its own; that needs this `mcp`, not `@better-auth/mcp`'s.
70
+ */
71
+ declare const mcp: (options: McpOptions) => ReturnType<typeof mcp$1>;
72
+ /**
73
+ * Protect an MCP route on the same deployment as the authorization server.
74
+ * Verifies the bearer token's signature, issuer, audience and expiry, and hands
75
+ * the verified claims to `handler`.
76
+ * @throws LunoraError when `resource` is missing, empty or not an absolute URL.
77
+ */
78
+ declare const requireMcpAuth: (auth: McpAuthInstance, handler: McpProtectedHandler, options: LunoraRequireMcpAuthOptions) => ((request: Request) => Promise<Response>);
79
+ /**
80
+ * The two `.well-known` paths an MCP client fetches before it authorizes:
81
+ * the RFC 9728 protected-resource metadata for `resource` (where the 401
82
+ * challenge points), then the RFC 8414 authorization-server metadata for the
83
+ * issuer.
84
+ *
85
+ * The Lunora worker already serves both for an `.auth()` declaration with
86
+ * `mcp()`; this is for routing them yourself, e.g. in front of a hand-built
87
+ * worker. Pass `authBasePath` when `createAuth` was given a `basePath` other
88
+ * than `/api/auth`.
89
+ * @throws TypeError when `resource` is not an absolute URL.
90
+ */
91
+ declare const mcpDiscoveryPaths: (resource: string, authBasePath?: string) => ReadonlyArray<string>;
92
+ /** Organization sub-features a UI branches on. */
93
+ interface UiConfigOrganization {
94
+ /** Whether an ordinary user may create one at all. */
95
+ allowUserToCreate: boolean;
96
+ enabled: boolean;
97
+ /** Max invitations per organization, when configured. */
98
+ invitationLimit?: number;
99
+ /** Max organizations one user may belong to, when configured. */
100
+ limit?: number;
101
+ /** Max members per organization, when configured. */
102
+ membershipLimit?: number;
103
+ /** Custom roles / dynamic access control are configured. */
104
+ roles: boolean;
105
+ /** Teams are enabled. */
106
+ teams: boolean;
107
+ }
108
+ /** The public payload `GET {basePath}/ui-config` returns. */
109
+ interface UiConfigPayload {
110
+ /** Whether email + password sign-in is enabled. */
111
+ emailAndPassword: boolean;
112
+ /** Absent when `expose.organization` is false — see {@link UiConfigOptions.expose}. */
113
+ organization?: UiConfigOrganization;
114
+ /** Enabled better-auth plugin ids, sorted. Absent when not disclosed. */
115
+ plugins?: string[];
116
+ /** Whether self-serve sign-up is open. */
117
+ signUp: boolean;
118
+ /** Configured social/OAuth provider ids, sorted. Absent when not disclosed. */
119
+ socialProviders?: string[];
120
+ }
121
+ /** Options for {@link uiConfig}. */
122
+ interface UiConfigOptions {
123
+ /**
124
+ * Omit fields from the payload. Everything is published by default; set a
125
+ * key to `false` for a deployment that would rather not enumerate, say, its
126
+ * plugin set to anonymous callers.
127
+ *
128
+ * The field is **omitted, not emptied**. An empty `plugins: []` is
129
+ * indistinguishable from "this deployment runs no plugins", and the client
130
+ * ANDs the server's answer with its own registration — so emptying it would
131
+ * silently switch off every gated card instead of merely withholding the
132
+ * list. Absent means "not disclosed", and the client falls back to what
133
+ * `client.ts` registered.
134
+ */
135
+ expose?: {
136
+ organization?: boolean;
137
+ plugins?: boolean;
138
+ socialProviders?: boolean;
139
+ };
140
+ /**
141
+ * Extra provider ids to advertise beyond `socialProviders`. Providers wired
142
+ * through the `genericOAuth` plugin live in that plugin's own options rather
143
+ * than in `socialProviders`, so they cannot be derived here — list them if
144
+ * you want buttons for them.
145
+ */
146
+ extraProviders?: string[];
147
+ /**
148
+ * Path the endpoint mounts at, relative to the auth basePath.
149
+ * @default "/ui-config"
150
+ */
151
+ path?: string;
152
+ }
153
+ /**
154
+ * A better-auth server plugin publishing {@link UiConfigPayload} at
155
+ * `GET {basePath}/ui-config`.
156
+ *
157
+ * There is no client half: the payload is fetched with a plain `fetch` by
158
+ * whatever renders your auth screens, so it works before a client exists and
159
+ * from a framework this package knows nothing about.
160
+ *
161
+ * The return type is better-auth's own `BetterAuthPlugin` rather than the precise
162
+ * shape of the endpoint map. That is deliberate: `createAuthEndpoint`'s inferred
163
+ * type is anonymous, and naming it is the difference between a build that emits
164
+ * declarations and one that fails only in the bundler — after `tsc` and the
165
+ * tests have both gone green. `BetterAuthPlugin` is what `createAuth({ plugins })`
166
+ * consumes anyway.
167
+ */
168
+ declare const uiConfig: (options?: UiConfigOptions) => BetterAuthPlugin;
169
+ export { type LunoraRequireMcpAuthOptions,
170
+ /**
171
+ * Publish which plugins and social providers this deployment enabled, at
172
+ * `GET {basePath}/ui-config`, so an auth UI configures itself instead of making
173
+ * you restate the list client-side. Lunora's own, not a better-auth re-export.
174
+ */
175
+ type UiConfigOptions,
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 UiConfigOrganization,
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 UiConfigPayload, 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{inviteOnly as e}from"./packem_shared/createSignUpInvitation-DHZL9fNl.mjs";import{mcp as m,mcpDiscoveryPaths as p,requireMcpAuth as f}from"./packem_shared/mcp-CgX1hTOv.mjs";import{uiConfig as x}from"./packem_shared/uiConfig-B8pN6pks.mjs";import{apiKey as a}from"@better-auth/api-key";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 no}from"better-auth/plugins/two-factor";import{username as co}from"better-auth/plugins/username";export{C as admin,I as anonymous,a 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,e as inviteOnly,V as jwt,M as lastLoginMethod,X as magicLink,m as mcp,p 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,f as requireMcpAuth,g as scim,io as siwe,no as twoFactor,x as uiConfig,co as username};
package/dist/schema.d.mts CHANGED
@@ -1,44 +1,44 @@
1
1
  import { TableDefinition } from '@lunora/server';
2
- import { a as LunoraAuthOptions } from "./packem_shared/create-auth.d-M36jwG_Y.mjs";
2
+ import { a as LunoraAuthOptions } from "./packem_shared/create-auth.d-D1CKOFWc.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
43
  declare const authTables: (options: LunoraAuthOptions) => Record<string, TableDefinition>;
44
44
  export { authTables as default };
package/dist/schema.d.ts CHANGED
@@ -1,44 +1,44 @@
1
1
  import { TableDefinition } from '@lunora/server';
2
- import { a as LunoraAuthOptions } from "./packem_shared/create-auth.d-M36jwG_Y.js";
2
+ import { a as LunoraAuthOptions } from "./packem_shared/create-auth.d-D1CKOFWc.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
43
  declare const authTables: (options: LunoraAuthOptions) => Record<string, TableDefinition>;
44
44
  export { authTables as default };
package/dist/schema.mjs CHANGED
@@ -1,62 +1 @@
1
- import { defineTable } from '@lunora/server';
2
- import { v } from '@lunora/values';
3
- import { getAuthTables } from 'better-auth/db';
4
-
5
- const baseValidator = (attribute) => {
6
- if (attribute.references) {
7
- return v.id(attribute.references.model);
8
- }
9
- const { type } = attribute;
10
- if (Array.isArray(type)) {
11
- return v.string();
12
- }
13
- switch (type) {
14
- case "boolean": {
15
- return v.boolean();
16
- }
17
- case "date": {
18
- return v.date();
19
- }
20
- case "number": {
21
- return v.number();
22
- }
23
- case "number[]": {
24
- return v.array(v.number());
25
- }
26
- case "string": {
27
- return v.string();
28
- }
29
- case "string[]": {
30
- return v.array(v.string());
31
- }
32
- // "json" and anything unrecognised: keep the row shape permissive rather
33
- // than fail schema generation on a plugin's exotic column type.
34
- default: {
35
- return v.any();
36
- }
37
- }
38
- };
39
- const fieldValidator = (attribute) => {
40
- let validator = baseValidator(attribute);
41
- if (attribute.required === false) {
42
- validator = validator.nullable();
43
- }
44
- if (attribute.unique === true) {
45
- validator = validator.unique();
46
- }
47
- return validator;
48
- };
49
- const authTables = (options) => {
50
- const tables = getAuthTables(options);
51
- const schema = {};
52
- for (const table of Object.values(tables)) {
53
- const shape = {};
54
- for (const [fieldKey, attribute] of Object.entries(table.fields)) {
55
- shape[attribute.fieldName ?? fieldKey] = fieldValidator(attribute);
56
- }
57
- schema[table.modelName] = defineTable(shape).externallyManaged();
58
- }
59
- return schema;
60
- };
61
-
62
- export { authTables as default };
1
+ import{defineTable as i}from"@lunora/server";import{v as e}from"@lunora/values";import{getAuthTables as u}from"better-auth/db";const c=n=>{if(n.references)return e.id(n.references.model);const{type:r}=n;if(Array.isArray(r))return e.string();switch(r){case"boolean":return e.boolean();case"date":return e.date();case"number":return e.number();case"number[]":return e.array(e.number());case"string":return e.string();case"string[]":return e.array(e.string());default:return e.any()}},f=n=>{let r=c(n);return n.required===!1&&(r=r.nullable()),n.unique===!0&&(r=r.unique()),r},y=n=>{const r=u(n),a={};for(const t of Object.values(r)){const s={};for(const[l,o]of Object.entries(t.fields))s[o.fieldName??l]=f(o);a[t.modelName]=i(s).externallyManaged()}return a};export{y as default};