@lunora/auth 1.0.0-alpha.13 → 1.0.0-alpha.130

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 (75) hide show
  1. package/LICENSE.md +38 -0
  2. package/README.md +99 -10
  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 +131 -0
  7. package/dist/audit.d.ts +131 -0
  8. package/dist/audit.mjs +12 -0
  9. package/dist/email-guard.d.mts +127 -0
  10. package/dist/email-guard.d.ts +127 -0
  11. package/dist/email-guard.mjs +1 -0
  12. package/dist/index.d.mts +801 -157
  13. package/dist/index.d.ts +801 -157
  14. package/dist/index.mjs +1 -12
  15. package/dist/middleware.d.mts +167 -156
  16. package/dist/middleware.d.ts +167 -156
  17. package/dist/middleware.mjs +1 -53
  18. package/dist/packem_shared/AUTH_DO_AUDIT_PATH-ucS0M60j.mjs +1 -0
  19. package/dist/packem_shared/DEFAULT_AUTH_BASE_PATH-DneiLGpv.mjs +1 -0
  20. package/dist/packem_shared/LunoraAuthAdminError-4r29Kj_y.mjs +1 -0
  21. package/dist/packem_shared/adapter-DA8DdALX.mjs +1 -0
  22. package/dist/packem_shared/adapter.d-2a61HAY2.d.ts +76 -0
  23. package/dist/packem_shared/adapter.d-DrD3bb1u.d.mts +76 -0
  24. package/dist/packem_shared/authAuditHook-C9Gt2iYp.mjs +1 -0
  25. package/dist/packem_shared/authDoColumnAdditions-UwF3Rl41.mjs +1 -0
  26. package/dist/packem_shared/compileMigrationsSql-ByVJhjR6.mjs +1 -0
  27. package/dist/packem_shared/create-auth.d-D1CKOFWc.d.mts +142 -0
  28. package/dist/packem_shared/create-auth.d-D1CKOFWc.d.ts +142 -0
  29. package/dist/packem_shared/createAuth-8aUw8v8D.mjs +1 -0
  30. package/dist/packem_shared/createDoAuthWiring-68YJP-VM.mjs +1 -0
  31. package/dist/packem_shared/createLunoraAuthClient-DhjhCwmM.mjs +1 -0
  32. package/dist/packem_shared/createSignUpInvitation-ClvskwuB.mjs +1 -0
  33. package/dist/packem_shared/emailGateDatabaseHooks-CAygR3iq.mjs +1 -0
  34. package/dist/packem_shared/invite-only.d-CsPJWAwM.d.ts +126 -0
  35. package/dist/packem_shared/invite-only.d-DKyHHkkQ.d.mts +126 -0
  36. package/dist/packem_shared/legacyIssuerCleanupStatements-D9Kf8OD1.mjs +1 -0
  37. package/dist/packem_shared/on-cloudflare-edge-Dx6gFjBO.mjs +1 -0
  38. package/dist/packem_shared/quote-identifier-CGiYFBvY.mjs +1 -0
  39. package/dist/packem_shared/sessionPresets-C867Mlo4.mjs +1 -0
  40. package/dist/packem_shared/uiConfig-B8pN6pks.mjs +1 -0
  41. package/dist/plugins-client.d.mts +165 -1
  42. package/dist/plugins-client.d.ts +165 -1
  43. package/dist/plugins-client.mjs +1 -2
  44. package/dist/plugins-enterprise-client.d.mts +15 -0
  45. package/dist/plugins-enterprise-client.d.ts +15 -0
  46. package/dist/plugins-enterprise-client.mjs +1 -0
  47. package/dist/plugins-enterprise.d.mts +1670 -0
  48. package/dist/plugins-enterprise.d.ts +1670 -0
  49. package/dist/plugins-enterprise.mjs +1 -0
  50. package/dist/plugins.d.mts +125 -2
  51. package/dist/plugins.d.ts +125 -2
  52. package/dist/plugins.mjs +1 -22
  53. package/dist/schema.d.mts +39 -39
  54. package/dist/schema.d.ts +39 -39
  55. package/dist/schema.mjs +1 -62
  56. package/dist/sql-store.d.mts +28 -28
  57. package/dist/sql-store.d.ts +28 -28
  58. package/dist/sql-store.mjs +1 -184
  59. package/dist/store.d.mts +65 -47
  60. package/dist/store.d.ts +65 -47
  61. package/dist/store.mjs +1 -183
  62. package/dist/turnstile-middleware.d.mts +66 -55
  63. package/dist/turnstile-middleware.d.ts +66 -55
  64. package/dist/turnstile-middleware.mjs +1 -45
  65. package/dist/turnstile.d.mts +42 -59
  66. package/dist/turnstile.d.ts +42 -59
  67. package/dist/turnstile.mjs +1 -61
  68. package/package.json +39 -5
  69. package/dist/packem_shared/DEFAULT_AUTH_BASE_PATH-DjcUWEQl.mjs +0 -11
  70. package/dist/packem_shared/LunoraAuthAdminError-BxrfEeA_.mjs +0 -249
  71. package/dist/packem_shared/compileMigrationsSql-cyE5U18R.mjs +0 -29
  72. package/dist/packem_shared/create-auth.d-Mwhb4gSc.d.mts +0 -128
  73. package/dist/packem_shared/create-auth.d-Mwhb4gSc.d.ts +0 -128
  74. package/dist/packem_shared/createAuth-hRGxUJ9w.mjs +0 -85
  75. 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,32 @@
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 { BetterAuthPlugin } from 'better-auth';
24
+ export { apiKey } from '@better-auth/api-key';
25
+ export { createMcpProtectedRequestHandler, mcp, requireMcpAuth } from '@better-auth/mcp';
26
+ export { oauthDeviceAuthorization, oauthProvider } from '@better-auth/oauth-provider';
1
27
  export { passkey } from '@better-auth/passkey';
2
- export { captcha, mcp, withMcpAuth } from 'better-auth/plugins';
28
+ export { scim } from '@better-auth/scim';
29
+ export { captcha, lastLoginMethod, oneTap } from 'better-auth/plugins';
3
30
  export { createAccessControl } from 'better-auth/plugins/access';
4
31
  export { admin } from 'better-auth/plugins/admin';
5
32
  export { anonymous } from 'better-auth/plugins/anonymous';
@@ -13,10 +40,106 @@ export { jwt } from 'better-auth/plugins/jwt';
13
40
  export { magicLink } from 'better-auth/plugins/magic-link';
14
41
  export { multiSession } from 'better-auth/plugins/multi-session';
15
42
  export { oAuthProxy } from 'better-auth/plugins/oauth-proxy';
16
- export { oidcProvider } from 'better-auth/plugins/oidc-provider';
17
43
  export { oneTimeToken } from 'better-auth/plugins/one-time-token';
18
44
  export { organization } from 'better-auth/plugins/organization';
19
45
  export { phoneNumber } from 'better-auth/plugins/phone-number';
20
46
  export { siwe } from 'better-auth/plugins/siwe';
21
47
  export { twoFactor } from 'better-auth/plugins/two-factor';
22
48
  export { username } from 'better-auth/plugins/username';
49
+ import "./packem_shared/create-auth.d-D1CKOFWc.mjs";
50
+ /** Organization sub-features a UI branches on. */
51
+ interface UiConfigOrganization {
52
+ /** Whether an ordinary user may create one at all. */
53
+ allowUserToCreate: boolean;
54
+ enabled: boolean;
55
+ /** Max invitations per organization, when configured. */
56
+ invitationLimit?: number;
57
+ /** Max organizations one user may belong to, when configured. */
58
+ limit?: number;
59
+ /** Max members per organization, when configured. */
60
+ membershipLimit?: number;
61
+ /** Custom roles / dynamic access control are configured. */
62
+ roles: boolean;
63
+ /** Teams are enabled. */
64
+ teams: boolean;
65
+ }
66
+ /** The public payload `GET {basePath}/ui-config` returns. */
67
+ interface UiConfigPayload {
68
+ /** Whether email + password sign-in is enabled. */
69
+ emailAndPassword: boolean;
70
+ /** Absent when `expose.organization` is false — see {@link UiConfigOptions.expose}. */
71
+ organization?: UiConfigOrganization;
72
+ /** Enabled better-auth plugin ids, sorted. Absent when not disclosed. */
73
+ plugins?: string[];
74
+ /** Whether self-serve sign-up is open. */
75
+ signUp: boolean;
76
+ /** Configured social/OAuth provider ids, sorted. Absent when not disclosed. */
77
+ socialProviders?: string[];
78
+ }
79
+ /** Options for {@link uiConfig}. */
80
+ interface UiConfigOptions {
81
+ /**
82
+ * Omit fields from the payload. Everything is published by default; set a
83
+ * key to `false` for a deployment that would rather not enumerate, say, its
84
+ * plugin set to anonymous callers.
85
+ *
86
+ * The field is **omitted, not emptied**. An empty `plugins: []` is
87
+ * indistinguishable from "this deployment runs no plugins", and the client
88
+ * ANDs the server's answer with its own registration — so emptying it would
89
+ * silently switch off every gated card instead of merely withholding the
90
+ * list. Absent means "not disclosed", and the client falls back to what
91
+ * `client.ts` registered.
92
+ */
93
+ expose?: {
94
+ organization?: boolean;
95
+ plugins?: boolean;
96
+ socialProviders?: boolean;
97
+ };
98
+ /**
99
+ * Extra provider ids to advertise beyond `socialProviders`. Providers wired
100
+ * through the `genericOAuth` plugin live in that plugin's own options rather
101
+ * than in `socialProviders`, so they cannot be derived here — list them if
102
+ * you want buttons for them.
103
+ */
104
+ extraProviders?: string[];
105
+ /**
106
+ * Path the endpoint mounts at, relative to the auth basePath.
107
+ * @default "/ui-config"
108
+ */
109
+ path?: string;
110
+ }
111
+ /**
112
+ * A better-auth server plugin publishing {@link UiConfigPayload} at
113
+ * `GET {basePath}/ui-config`.
114
+ *
115
+ * There is no client half: the payload is fetched with a plain `fetch` by
116
+ * whatever renders your auth screens, so it works before a client exists and
117
+ * from a framework this package knows nothing about.
118
+ *
119
+ * The return type is better-auth's own `BetterAuthPlugin` rather than the precise
120
+ * shape of the endpoint map. That is deliberate: `createAuthEndpoint`'s inferred
121
+ * type is anonymous, and naming it is the difference between a build that emits
122
+ * declarations and one that fails only in the bundler — after `tsc` and the
123
+ * tests have both gone green. `BetterAuthPlugin` is what `createAuth({ plugins })`
124
+ * consumes anyway.
125
+ */
126
+ declare const uiConfig: (options?: UiConfigOptions) => BetterAuthPlugin;
127
+ export {
128
+ /**
129
+ * Publish which plugins and social providers this deployment enabled, at
130
+ * `GET {basePath}/ui-config`, so an auth UI configures itself instead of making
131
+ * you restate the list client-side. Lunora's own, not a better-auth re-export.
132
+ */
133
+ type UiConfigOptions,
134
+ /**
135
+ * Publish which plugins and social providers this deployment enabled, at
136
+ * `GET {basePath}/ui-config`, so an auth UI configures itself instead of making
137
+ * you restate the list client-side. Lunora's own, not a better-auth re-export.
138
+ */
139
+ type UiConfigOrganization,
140
+ /**
141
+ * Publish which plugins and social providers this deployment enabled, at
142
+ * `GET {basePath}/ui-config`, so an auth UI configures itself instead of making
143
+ * you restate the list client-side. Lunora's own, not a better-auth re-export.
144
+ */
145
+ type UiConfigPayload, uiConfig };
package/dist/plugins.d.ts CHANGED
@@ -1,5 +1,32 @@
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 { BetterAuthPlugin } from 'better-auth';
24
+ export { apiKey } from '@better-auth/api-key';
25
+ export { createMcpProtectedRequestHandler, mcp, requireMcpAuth } from '@better-auth/mcp';
26
+ export { oauthDeviceAuthorization, oauthProvider } from '@better-auth/oauth-provider';
1
27
  export { passkey } from '@better-auth/passkey';
2
- export { captcha, mcp, withMcpAuth } from 'better-auth/plugins';
28
+ export { scim } from '@better-auth/scim';
29
+ export { captcha, lastLoginMethod, oneTap } from 'better-auth/plugins';
3
30
  export { createAccessControl } from 'better-auth/plugins/access';
4
31
  export { admin } from 'better-auth/plugins/admin';
5
32
  export { anonymous } from 'better-auth/plugins/anonymous';
@@ -13,10 +40,106 @@ export { jwt } from 'better-auth/plugins/jwt';
13
40
  export { magicLink } from 'better-auth/plugins/magic-link';
14
41
  export { multiSession } from 'better-auth/plugins/multi-session';
15
42
  export { oAuthProxy } from 'better-auth/plugins/oauth-proxy';
16
- export { oidcProvider } from 'better-auth/plugins/oidc-provider';
17
43
  export { oneTimeToken } from 'better-auth/plugins/one-time-token';
18
44
  export { organization } from 'better-auth/plugins/organization';
19
45
  export { phoneNumber } from 'better-auth/plugins/phone-number';
20
46
  export { siwe } from 'better-auth/plugins/siwe';
21
47
  export { twoFactor } from 'better-auth/plugins/two-factor';
22
48
  export { username } from 'better-auth/plugins/username';
49
+ import "./packem_shared/create-auth.d-D1CKOFWc.js";
50
+ /** Organization sub-features a UI branches on. */
51
+ interface UiConfigOrganization {
52
+ /** Whether an ordinary user may create one at all. */
53
+ allowUserToCreate: boolean;
54
+ enabled: boolean;
55
+ /** Max invitations per organization, when configured. */
56
+ invitationLimit?: number;
57
+ /** Max organizations one user may belong to, when configured. */
58
+ limit?: number;
59
+ /** Max members per organization, when configured. */
60
+ membershipLimit?: number;
61
+ /** Custom roles / dynamic access control are configured. */
62
+ roles: boolean;
63
+ /** Teams are enabled. */
64
+ teams: boolean;
65
+ }
66
+ /** The public payload `GET {basePath}/ui-config` returns. */
67
+ interface UiConfigPayload {
68
+ /** Whether email + password sign-in is enabled. */
69
+ emailAndPassword: boolean;
70
+ /** Absent when `expose.organization` is false — see {@link UiConfigOptions.expose}. */
71
+ organization?: UiConfigOrganization;
72
+ /** Enabled better-auth plugin ids, sorted. Absent when not disclosed. */
73
+ plugins?: string[];
74
+ /** Whether self-serve sign-up is open. */
75
+ signUp: boolean;
76
+ /** Configured social/OAuth provider ids, sorted. Absent when not disclosed. */
77
+ socialProviders?: string[];
78
+ }
79
+ /** Options for {@link uiConfig}. */
80
+ interface UiConfigOptions {
81
+ /**
82
+ * Omit fields from the payload. Everything is published by default; set a
83
+ * key to `false` for a deployment that would rather not enumerate, say, its
84
+ * plugin set to anonymous callers.
85
+ *
86
+ * The field is **omitted, not emptied**. An empty `plugins: []` is
87
+ * indistinguishable from "this deployment runs no plugins", and the client
88
+ * ANDs the server's answer with its own registration — so emptying it would
89
+ * silently switch off every gated card instead of merely withholding the
90
+ * list. Absent means "not disclosed", and the client falls back to what
91
+ * `client.ts` registered.
92
+ */
93
+ expose?: {
94
+ organization?: boolean;
95
+ plugins?: boolean;
96
+ socialProviders?: boolean;
97
+ };
98
+ /**
99
+ * Extra provider ids to advertise beyond `socialProviders`. Providers wired
100
+ * through the `genericOAuth` plugin live in that plugin's own options rather
101
+ * than in `socialProviders`, so they cannot be derived here — list them if
102
+ * you want buttons for them.
103
+ */
104
+ extraProviders?: string[];
105
+ /**
106
+ * Path the endpoint mounts at, relative to the auth basePath.
107
+ * @default "/ui-config"
108
+ */
109
+ path?: string;
110
+ }
111
+ /**
112
+ * A better-auth server plugin publishing {@link UiConfigPayload} at
113
+ * `GET {basePath}/ui-config`.
114
+ *
115
+ * There is no client half: the payload is fetched with a plain `fetch` by
116
+ * whatever renders your auth screens, so it works before a client exists and
117
+ * from a framework this package knows nothing about.
118
+ *
119
+ * The return type is better-auth's own `BetterAuthPlugin` rather than the precise
120
+ * shape of the endpoint map. That is deliberate: `createAuthEndpoint`'s inferred
121
+ * type is anonymous, and naming it is the difference between a build that emits
122
+ * declarations and one that fails only in the bundler — after `tsc` and the
123
+ * tests have both gone green. `BetterAuthPlugin` is what `createAuth({ plugins })`
124
+ * consumes anyway.
125
+ */
126
+ declare const uiConfig: (options?: UiConfigOptions) => BetterAuthPlugin;
127
+ export {
128
+ /**
129
+ * Publish which plugins and social providers this deployment enabled, at
130
+ * `GET {basePath}/ui-config`, so an auth UI configures itself instead of making
131
+ * you restate the list client-side. Lunora's own, not a better-auth re-export.
132
+ */
133
+ type UiConfigOptions,
134
+ /**
135
+ * Publish which plugins and social providers this deployment enabled, at
136
+ * `GET {basePath}/ui-config`, so an auth UI configures itself instead of making
137
+ * you restate the list client-side. Lunora's own, not a better-auth re-export.
138
+ */
139
+ type UiConfigOrganization,
140
+ /**
141
+ * Publish which plugins and social providers this deployment enabled, at
142
+ * `GET {basePath}/ui-config`, so an auth UI configures itself instead of making
143
+ * you restate the list client-side. Lunora's own, not a better-auth re-export.
144
+ */
145
+ type UiConfigPayload, 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-ClvskwuB.mjs";import{uiConfig as m}from"./packem_shared/uiConfig-B8pN6pks.mjs";import{apiKey as f}from"@better-auth/api-key";import{createMcpProtectedRequestHandler as i,mcp as n,requireMcpAuth as a}from"@better-auth/mcp";import{oauthDeviceAuthorization as s,oauthProvider as u}from"@better-auth/oauth-provider";import{passkey as d}from"@better-auth/passkey";import{scim as A}from"@better-auth/scim";import{captcha as v,lastLoginMethod as y,oneTap as P}from"better-auth/plugins";import{createAccessControl as T}from"better-auth/plugins/access";import{admin as z}from"better-auth/plugins/admin";import{anonymous as O}from"better-auth/plugins/anonymous";import{bearer as q}from"better-auth/plugins/bearer";import{customSession as L}from"better-auth/plugins/custom-session";import{deviceAuthorization as j}from"better-auth/plugins/device-authorization";import{emailOTP as D}from"better-auth/plugins/email-otp";import{genericOAuth as H}from"better-auth/plugins/generic-oauth";import{haveIBeenPwned as K}from"better-auth/plugins/haveibeenpwned";import{jwt as R}from"better-auth/plugins/jwt";import{magicLink as G}from"better-auth/plugins/magic-link";import{multiSession as Q}from"better-auth/plugins/multi-session";import{oAuthProxy as V}from"better-auth/plugins/oauth-proxy";import{oneTimeToken as X}from"better-auth/plugins/one-time-token";import{organization as Z}from"better-auth/plugins/organization";import{phoneNumber as $}from"better-auth/plugins/phone-number";import{siwe as ro}from"better-auth/plugins/siwe";import{twoFactor as to}from"better-auth/plugins/two-factor";import{username as po}from"better-auth/plugins/username";export{z as admin,O as anonymous,f as apiKey,q as bearer,v as captcha,T as createAccessControl,i as createMcpProtectedRequestHandler,L as customSession,j as deviceAuthorization,D as emailOTP,H as genericOAuth,K as haveIBeenPwned,e as inviteOnly,R as jwt,y as lastLoginMethod,G as magicLink,n as mcp,Q as multiSession,V as oAuthProxy,s as oauthDeviceAuthorization,u as oauthProvider,P as oneTap,X as oneTimeToken,Z as organization,d as passkey,$ as phoneNumber,a as requireMcpAuth,A as scim,ro as siwe,to as twoFactor,m as uiConfig,po 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-Mwhb4gSc.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-Mwhb4gSc.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};
@@ -12,40 +12,40 @@ interface D1Like {
12
12
  };
13
13
  }
14
14
  /**
15
- * The minimal SQL seam a {@link createSqlAuthStore} runs on — structurally the
16
- * same `{ all, run }` contract as `@lunora/d1`'s `D1Exec`, so a Lunora D1 binding
17
- * satisfies it directly (see {@link d1Executor}) and a `node:sqlite` handle does
18
- * too in tests. `all` runs reads and returns rows; `run` runs writes.
19
- */
15
+ * The minimal SQL seam a {@link createSqlAuthStore} runs on — structurally the
16
+ * same `{ all, run }` contract as `@lunora/d1`'s `D1Exec`, so a Lunora D1 binding
17
+ * satisfies it directly (see {@link d1Executor}) and a `node:sqlite` handle does
18
+ * too in tests. `all` runs reads and returns rows; `run` runs writes.
19
+ */
20
20
  interface SqlExecutor {
21
21
  all: (sql: string, parameters: ReadonlyArray<unknown>) => Promise<Record<string, unknown>[]>;
22
22
  run: (sql: string, parameters: ReadonlyArray<unknown>) => Promise<void>;
23
23
  }
24
24
  /**
25
- * An {@link AuthStore} backed by a SQL database through the {@link SqlExecutor}
26
- * seam — the production counterpart to `createMemoryAuthStore`. Point it at the
27
- * same database that hosts Lunora's global (D1) tables (the ones `authTables(...)`
28
- * generates) and better-auth's reads/writes land there as ordinary rows Lunora
29
- * can also query. Assumes the auth tables already exist (Lunora owns the schema /
30
- * migrations); it never issues DDL.
31
- *
32
- * ```ts
33
- * const store = createSqlAuthStore(d1Executor(env.DB));
34
- * const auth = createAuth({ secret: env.AUTH_SECRET, database: lunoraAuthAdapter(store) });
35
- * ```
36
- *
37
- * Clause semantics match `createMemoryAuthStore` (operator parity is
38
- * covered by a cross-store agreement test) with one unavoidable caveat:
39
- * case-**insensitive** matching uses SQLite's ASCII-only `LOWER()`, whereas the
40
- * in-memory store uses JS full-Unicode `toLowerCase()`. They agree on ASCII
41
- * (emails, ids, tokens — the credential path); they can differ only for
42
- * case-insensitive comparison of non-ASCII text.
43
- */
25
+ * An {@link AuthStore} backed by a SQL database through the {@link SqlExecutor}
26
+ * seam — the production counterpart to `createMemoryAuthStore`. Point it at the
27
+ * same database that hosts Lunora's global (D1) tables (the ones `authTables(...)`
28
+ * generates) and better-auth's reads/writes land there as ordinary rows Lunora
29
+ * can also query. Assumes the auth tables already exist (Lunora owns the schema /
30
+ * migrations); it never issues DDL.
31
+ *
32
+ * ```ts
33
+ * const store = createSqlAuthStore(d1Executor(env.DB));
34
+ * const auth = createAuth({ secret: env.AUTH_SECRET, database: lunoraAuthAdapter(store) });
35
+ * ```
36
+ *
37
+ * Clause semantics match `createMemoryAuthStore` (operator parity is
38
+ * covered by a cross-store agreement test) with one unavoidable caveat:
39
+ * case-**insensitive** matching uses SQLite's ASCII-only `LOWER()`, whereas the
40
+ * in-memory store uses JS full-Unicode `toLowerCase()`. They agree on ASCII
41
+ * (emails, ids, tokens — the credential path); they can differ only for
42
+ * case-insensitive comparison of non-ASCII text.
43
+ */
44
44
  declare const createSqlAuthStore: (executor: SqlExecutor) => AuthStore;
45
45
  /**
46
- * Wrap a Cloudflare D1 binding (`env.DB`) as a {@link SqlExecutor}, so
47
- * `createSqlAuthStore(d1Executor(env.DB))` routes better-auth onto D1 — the same
48
- * binding Lunora's `.global()` tables use.
49
- */
46
+ * Wrap a Cloudflare D1 binding (`env.DB`) as a {@link SqlExecutor}, so
47
+ * `createSqlAuthStore(d1Executor(env.DB))` routes better-auth onto D1 — the same
48
+ * binding Lunora's `.global()` tables use.
49
+ */
50
50
  declare const d1Executor: (database: D1Like) => SqlExecutor;
51
51
  export { SqlExecutor, createSqlAuthStore, d1Executor };