@lunora/auth 1.0.0-alpha.23 → 1.0.0-alpha.230

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 (88) hide show
  1. package/LICENSE.md +32 -0
  2. package/README.md +101 -11
  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 +142 -0
  7. package/dist/audit.d.ts +142 -0
  8. package/dist/audit.mjs +12 -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 +32 -0
  13. package/dist/cimd-workers.d.ts +32 -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 +751 -179
  19. package/dist/index.d.ts +751 -179
  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 +47 -0
  25. package/dist/migrate.d.ts +47 -0
  26. package/dist/migrate.mjs +1 -0
  27. package/dist/packem_shared/AUTH_DO_AUDIT_PATH-DNM3G5GI.mjs +1 -0
  28. package/dist/packem_shared/DEFAULT_AUTH_BASE_PATH-DneiLGpv.mjs +1 -0
  29. package/dist/packem_shared/LunoraAuthAdminError-uhKG1MgQ.mjs +1 -0
  30. package/dist/packem_shared/adapter-CBZ17jKi.mjs +2 -0
  31. package/dist/packem_shared/adapter.d-CElAPJ1U.d.ts +88 -0
  32. package/dist/packem_shared/adapter.d-CaPwF2v3.d.mts +88 -0
  33. package/dist/packem_shared/auth-do-nKx0bUTe.mjs +1 -0
  34. package/dist/packem_shared/authAuditHook-DPTKdjBe.mjs +1 -0
  35. package/dist/packem_shared/authDiscoveryPaths-B14lM14u.mjs +1 -0
  36. package/dist/packem_shared/authDoColumnAdditions-UwF3Rl41.mjs +1 -0
  37. package/dist/packem_shared/create-auth.d-D1CKOFWc.d.mts +142 -0
  38. package/dist/packem_shared/create-auth.d-D1CKOFWc.d.ts +142 -0
  39. package/dist/packem_shared/createAuth-B-Pq7nmN.mjs +1 -0
  40. package/dist/packem_shared/createDoAuthWiring-az8FcbYw.mjs +1 -0
  41. package/dist/packem_shared/createLunoraAuthClient-DRcFNwp9.mjs +1 -0
  42. package/dist/packem_shared/createSignUpInvitation-DHZL9fNl.mjs +1 -0
  43. package/dist/packem_shared/emailGateDatabaseHooks-BYLUpiN_.mjs +1 -0
  44. package/dist/packem_shared/invite-only.d-CsPJWAwM.d.ts +126 -0
  45. package/dist/packem_shared/invite-only.d-DKyHHkkQ.d.mts +126 -0
  46. package/dist/packem_shared/isDevEnvironment-yLbPngwn.mjs +1 -0
  47. package/dist/packem_shared/legacyIssuerCleanupStatements-D9Kf8OD1.mjs +1 -0
  48. package/dist/packem_shared/mcp-CgX1hTOv.mjs +1 -0
  49. package/dist/packem_shared/on-cloudflare-edge-Dx6gFjBO.mjs +1 -0
  50. package/dist/packem_shared/quote-identifier-CGiYFBvY.mjs +1 -0
  51. package/dist/packem_shared/sessionPresets-C867Mlo4.mjs +1 -0
  52. package/dist/packem_shared/sql-store-uMubPYI9.mjs +1 -0
  53. package/dist/packem_shared/uiConfig-B8pN6pks.mjs +1 -0
  54. package/dist/plugins-client.d.mts +250 -1
  55. package/dist/plugins-client.d.ts +250 -1
  56. package/dist/plugins-client.mjs +1 -2
  57. package/dist/plugins-enterprise-client.d.mts +13 -0
  58. package/dist/plugins-enterprise-client.d.ts +13 -0
  59. package/dist/plugins-enterprise-client.mjs +1 -0
  60. package/dist/plugins-enterprise.d.mts +1668 -0
  61. package/dist/plugins-enterprise.d.ts +1668 -0
  62. package/dist/plugins-enterprise.mjs +1 -0
  63. package/dist/plugins.d.mts +167 -2
  64. package/dist/plugins.d.ts +167 -2
  65. package/dist/plugins.mjs +1 -22
  66. package/dist/schema.d.mts +39 -39
  67. package/dist/schema.d.ts +39 -39
  68. package/dist/schema.mjs +1 -62
  69. package/dist/sql-store.d.mts +43 -28
  70. package/dist/sql-store.d.ts +43 -28
  71. package/dist/sql-store.mjs +1 -184
  72. package/dist/store.d.mts +65 -47
  73. package/dist/store.d.ts +65 -47
  74. package/dist/store.mjs +1 -183
  75. package/dist/turnstile-middleware.d.mts +73 -55
  76. package/dist/turnstile-middleware.d.ts +73 -55
  77. package/dist/turnstile-middleware.mjs +1 -45
  78. package/dist/turnstile.d.mts +42 -59
  79. package/dist/turnstile.d.ts +42 -59
  80. package/dist/turnstile.mjs +1 -61
  81. package/package.json +53 -6
  82. package/dist/packem_shared/DEFAULT_AUTH_BASE_PATH-DjcUWEQl.mjs +0 -11
  83. package/dist/packem_shared/LunoraAuthAdminError-D4L7n6gN.mjs +0 -510
  84. package/dist/packem_shared/compileMigrationsSql-B9bj-mJv.mjs +0 -29
  85. package/dist/packem_shared/create-auth.d-Mwhb4gSc.d.mts +0 -128
  86. package/dist/packem_shared/create-auth.d-Mwhb4gSc.d.ts +0 -128
  87. package/dist/packem_shared/createAuth-BVMMllTm.mjs +0 -87
  88. package/dist/packem_shared/sessionPresets-Dwwd74_J.mjs +0 -38
@@ -1,2 +1,251 @@
1
+ import { organizationClient } from 'better-auth/client/plugins';
2
+ export { adminClient, anonymousClient, customSessionClient, deviceAuthorizationClient, emailOTPClient, inferAdditionalFields, inferOrgAdditionalFields, jwtClient, lastLoginMethodClient, magicLinkClient, multiSessionClient, oneTapClient, oneTimeTokenClient, organizationClient, phoneNumberClient, siweClient, twoFactorClient, usernameClient } from 'better-auth/client/plugins';
3
+ export { apiKeyClient } from '@better-auth/api-key/client';
4
+ export { oauthDeviceAuthorizationClient, oauthProviderClient } from '@better-auth/oauth-provider/client';
1
5
  export { passkeyClient } from '@better-auth/passkey/client';
2
- export { adminClient, anonymousClient, customSessionClient, deviceAuthorizationClient, emailOTPClient, genericOAuthClient, inferAdditionalFields, inferOrgAdditionalFields, jwtClient, lastLoginMethodClient, magicLinkClient, multiSessionClient, oidcClient, oneTimeTokenClient, organizationClient, phoneNumberClient, siweClient, twoFactorClient, usernameClient } from 'better-auth/client/plugins';
6
+ /**
7
+ * Which client plugins to include. Each defaults to `false`.
8
+ *
9
+ * These are the same names `@lunora/auth-ui` gates its cards on, so one object
10
+ * can drive both `createLunoraAuthClient` and `registerAuthClientPlugins` — a
11
+ * flow the UI can show but this cannot install would be a card that renders and
12
+ * then fails at call time.
13
+ *
14
+ * `oneTap` is absent on purpose: Google One Tap needs a client id, not a
15
+ * boolean, so it comes in through {@link CreateLunoraAuthClientOptions.oneTapClientId}.
16
+ */
17
+ interface LunoraAuthPluginToggles {
18
+ admin?: boolean;
19
+ anonymous?: boolean;
20
+ deviceAuthorization?: boolean;
21
+ emailOtp?: boolean;
22
+ lastLoginMethod?: boolean;
23
+ magicLink?: boolean;
24
+ multiSession?: boolean;
25
+ oauthProvider?: boolean;
26
+ organization?: boolean;
27
+ passkey?: boolean;
28
+ phoneNumber?: boolean;
29
+ twoFactor?: boolean;
30
+ username?: boolean;
31
+ }
32
+ type LunoraAuthClientPlugin = ReturnType<typeof organizationClient>;
33
+ declare const lunoraAuthPlugins: (toggles?: LunoraAuthPluginToggles) => LunoraAuthClientPlugin[];
34
+ /** Options for {@link createLunoraAuthClient}; anything else is forwarded to `createAuthClient`. */
35
+ interface CreateLunoraAuthClientOptions {
36
+ [option: string]: unknown;
37
+ /** Defaults to the current origin, which is right for a same-origin app. */
38
+ baseURL?: string;
39
+ /** Your own client plugins, appended after the standard set. */
40
+ extraPlugins?: LunoraAuthClientPlugin[];
41
+ /**
42
+ * Google OAuth client id. Setting it installs the One Tap client plugin —
43
+ * a boolean toggle can't, because the prompt is Google's and needs the id.
44
+ */
45
+ oneTapClientId?: string;
46
+ /** Which standard client plugins to include. */
47
+ plugins?: LunoraAuthPluginToggles;
48
+ }
49
+ /**
50
+ * What {@link lunoraSessionSync} returns: a better-auth client plugin, typed
51
+ * narrowly rather than as `BetterAuthClientPlugin` — widening a plugin to that
52
+ * type collapses better-auth's session inference on the client it joins.
53
+ */
54
+ interface LunoraSessionSyncPlugin {
55
+ fetchPlugins: {
56
+ hooks: {
57
+ onSuccess: (context: {
58
+ request: {
59
+ method?: string;
60
+ };
61
+ }) => void;
62
+ };
63
+ id: string;
64
+ name: string;
65
+ }[];
66
+ id: "lunora-session-sync";
67
+ }
68
+ /**
69
+ * Tell every `LunoraClient` in the page, and in the browser's other tabs on the
70
+ * same origin, that the auth session may have changed, so each asks
71
+ * `/get-session` who is signed in now. A tab on another origin that shares the
72
+ * cookie is not reached: it switches on its next socket reconnect, and the
73
+ * worker's replay check keeps its writes safe meanwhile.
74
+ *
75
+ * Needed for a **cookie** session: a sign-in or sign-out sets or clears an
76
+ * `HttpOnly` cookie in a request the Lunora client never sees, and nothing it
77
+ * can observe changes. Until it re-resolves, its live queries keep showing the
78
+ * previous user's rows over a socket still authenticated as them.
79
+ * {@link lunoraSessionSync} (installed by {@link createLunoraAuthClient}) and
80
+ * `@lunora/auth-ui` call it for you; call it yourself after a session change
81
+ * made any other way.
82
+ *
83
+ * Resolves once every client in this tab has re-resolved (or failed to), so
84
+ * code that reads `client.currentIdentity()` next can `await` it; the other
85
+ * tabs re-resolve on their own. Never rejects.
86
+ */
87
+ declare const notifyLunoraSessionChange: () => Promise<void>;
88
+ /**
89
+ * A better-auth client plugin that, after every successful auth request that
90
+ * can change the session (anything but a `GET` — sign-in, sign-up, sign-out,
91
+ * 2FA, account switch, session revocation), calls
92
+ * {@link notifyLunoraSessionChange}.
93
+ *
94
+ * {@link createLunoraAuthClient} always installs it. Add it yourself when you
95
+ * call `createAuthClient` directly:
96
+ *
97
+ * ```ts
98
+ * export const authClient = createAuthClient({ plugins: [lunoraSessionSync()] });
99
+ * ```
100
+ */
101
+ declare const lunoraSessionSync: () => LunoraSessionSyncPlugin;
102
+ /**
103
+ * Build a better-auth client with Lunora's standard plugin set from toggles.
104
+ *
105
+ * You pass your framework's `createAuthClient` in — `better-auth/react`,
106
+ * `/vue`, `/svelte`, or `/solid` — because the variant has to match the UI
107
+ * framework, and a helper that picked for you would either guess wrong or drag
108
+ * every variant into your bundle.
109
+ *
110
+ * ```ts
111
+ * import { createAuthClient } from "better-auth/react";
112
+ * import { createLunoraAuthClient } from "@lunora/auth/plugins/client";
113
+ *
114
+ * export const authClient = createLunoraAuthClient(createAuthClient, {
115
+ * plugins: { organization: true, passkey: true, twoFactor: true },
116
+ * });
117
+ * ```
118
+ *
119
+ * Reach for {@link lunoraAuthPlugins} instead when you want to own the
120
+ * `createAuthClient` call and only borrow the plugin array.
121
+ */
122
+ declare const createLunoraAuthClient: <TClient>(createAuthClient: (options: Record<string, unknown>) => TClient, options?: CreateLunoraAuthClientOptions) => TClient;
123
+ export {
124
+ /**
125
+ * Client-side counterparts to the server plugins re-exported from
126
+ * `@lunora/auth/plugins`, surfaced under `@lunora/auth/plugins/client`.
127
+ *
128
+ * better-auth plugins come in two halves: a **server** plugin you pass to
129
+ * `betterAuth()` (re-exported from `@lunora/auth/plugins`) and a **client**
130
+ * plugin you pass to `createAuthClient()`. Both halves must be registered for a
131
+ * plugin's endpoints, inferred types, and client actions (e.g.
132
+ * `authClient.twoFactor.*`, `authClient.organization.*`, the `twoFactorRedirect`
133
+ * sign-in flow) to exist. This module is the client half so consumers don't have
134
+ * to reach into better-auth's `better-auth/client/plugins` subpath directly.
135
+ *
136
+ * # Wiring
137
+ *
138
+ * ```ts
139
+ * import { createAuthClient } from "better-auth/client"; // or a framework adapter
140
+ * import { organizationClient, twoFactorClient } from "@lunora/auth/plugins/client";
141
+ *
142
+ * export const authClient = createAuthClient({
143
+ * baseURL: import.meta.env.VITE_AUTH_URL,
144
+ * plugins: [
145
+ * organizationClient(),
146
+ * twoFactorClient({ onTwoFactorRedirect: () => location.assign("/2fa") }),
147
+ * ],
148
+ * });
149
+ * ```
150
+ *
151
+ * Keep the client plugin list in parity with the server `plugins` array passed
152
+ * to `createAuth`: a server plugin without its client counterpart leaves
153
+ * those actions untyped/unavailable, and vice-versa.
154
+ */
155
+ type CreateLunoraAuthClientOptions,
156
+ /**
157
+ * Client-side counterparts to the server plugins re-exported from
158
+ * `@lunora/auth/plugins`, surfaced under `@lunora/auth/plugins/client`.
159
+ *
160
+ * better-auth plugins come in two halves: a **server** plugin you pass to
161
+ * `betterAuth()` (re-exported from `@lunora/auth/plugins`) and a **client**
162
+ * plugin you pass to `createAuthClient()`. Both halves must be registered for a
163
+ * plugin's endpoints, inferred types, and client actions (e.g.
164
+ * `authClient.twoFactor.*`, `authClient.organization.*`, the `twoFactorRedirect`
165
+ * sign-in flow) to exist. This module is the client half so consumers don't have
166
+ * to reach into better-auth's `better-auth/client/plugins` subpath directly.
167
+ *
168
+ * # Wiring
169
+ *
170
+ * ```ts
171
+ * import { createAuthClient } from "better-auth/client"; // or a framework adapter
172
+ * import { organizationClient, twoFactorClient } from "@lunora/auth/plugins/client";
173
+ *
174
+ * export const authClient = createAuthClient({
175
+ * baseURL: import.meta.env.VITE_AUTH_URL,
176
+ * plugins: [
177
+ * organizationClient(),
178
+ * twoFactorClient({ onTwoFactorRedirect: () => location.assign("/2fa") }),
179
+ * ],
180
+ * });
181
+ * ```
182
+ *
183
+ * Keep the client plugin list in parity with the server `plugins` array passed
184
+ * to `createAuth`: a server plugin without its client counterpart leaves
185
+ * those actions untyped/unavailable, and vice-versa.
186
+ */
187
+ type LunoraAuthClientPlugin,
188
+ /**
189
+ * Client-side counterparts to the server plugins re-exported from
190
+ * `@lunora/auth/plugins`, surfaced under `@lunora/auth/plugins/client`.
191
+ *
192
+ * better-auth plugins come in two halves: a **server** plugin you pass to
193
+ * `betterAuth()` (re-exported from `@lunora/auth/plugins`) and a **client**
194
+ * plugin you pass to `createAuthClient()`. Both halves must be registered for a
195
+ * plugin's endpoints, inferred types, and client actions (e.g.
196
+ * `authClient.twoFactor.*`, `authClient.organization.*`, the `twoFactorRedirect`
197
+ * sign-in flow) to exist. This module is the client half so consumers don't have
198
+ * to reach into better-auth's `better-auth/client/plugins` subpath directly.
199
+ *
200
+ * # Wiring
201
+ *
202
+ * ```ts
203
+ * import { createAuthClient } from "better-auth/client"; // or a framework adapter
204
+ * import { organizationClient, twoFactorClient } from "@lunora/auth/plugins/client";
205
+ *
206
+ * export const authClient = createAuthClient({
207
+ * baseURL: import.meta.env.VITE_AUTH_URL,
208
+ * plugins: [
209
+ * organizationClient(),
210
+ * twoFactorClient({ onTwoFactorRedirect: () => location.assign("/2fa") }),
211
+ * ],
212
+ * });
213
+ * ```
214
+ *
215
+ * Keep the client plugin list in parity with the server `plugins` array passed
216
+ * to `createAuth`: a server plugin without its client counterpart leaves
217
+ * those actions untyped/unavailable, and vice-versa.
218
+ */
219
+ type LunoraAuthPluginToggles,
220
+ /**
221
+ * Client-side counterparts to the server plugins re-exported from
222
+ * `@lunora/auth/plugins`, surfaced under `@lunora/auth/plugins/client`.
223
+ *
224
+ * better-auth plugins come in two halves: a **server** plugin you pass to
225
+ * `betterAuth()` (re-exported from `@lunora/auth/plugins`) and a **client**
226
+ * plugin you pass to `createAuthClient()`. Both halves must be registered for a
227
+ * plugin's endpoints, inferred types, and client actions (e.g.
228
+ * `authClient.twoFactor.*`, `authClient.organization.*`, the `twoFactorRedirect`
229
+ * sign-in flow) to exist. This module is the client half so consumers don't have
230
+ * to reach into better-auth's `better-auth/client/plugins` subpath directly.
231
+ *
232
+ * # Wiring
233
+ *
234
+ * ```ts
235
+ * import { createAuthClient } from "better-auth/client"; // or a framework adapter
236
+ * import { organizationClient, twoFactorClient } from "@lunora/auth/plugins/client";
237
+ *
238
+ * export const authClient = createAuthClient({
239
+ * baseURL: import.meta.env.VITE_AUTH_URL,
240
+ * plugins: [
241
+ * organizationClient(),
242
+ * twoFactorClient({ onTwoFactorRedirect: () => location.assign("/2fa") }),
243
+ * ],
244
+ * });
245
+ * ```
246
+ *
247
+ * Keep the client plugin list in parity with the server `plugins` array passed
248
+ * to `createAuth`: a server plugin without its client counterpart leaves
249
+ * those actions untyped/unavailable, and vice-versa.
250
+ */
251
+ type LunoraSessionSyncPlugin, createLunoraAuthClient, lunoraAuthPlugins, lunoraSessionSync, notifyLunoraSessionChange };
@@ -1,2 +1 @@
1
- export { passkeyClient } from '@better-auth/passkey/client';
2
- export { adminClient, anonymousClient, customSessionClient, deviceAuthorizationClient, emailOTPClient, genericOAuthClient, inferAdditionalFields, inferOrgAdditionalFields, jwtClient, lastLoginMethodClient, magicLinkClient, multiSessionClient, oidcClient, oneTimeTokenClient, organizationClient, phoneNumberClient, siweClient, twoFactorClient, usernameClient } from 'better-auth/client/plugins';
1
+ import{createLunoraAuthClient as n,lunoraAuthPlugins as t,lunoraSessionSync as o,notifyLunoraSessionChange as l}from"./packem_shared/createLunoraAuthClient-DRcFNwp9.mjs";import{apiKeyClient as a}from"@better-auth/api-key/client";import{oauthDeviceAuthorizationClient as s,oauthProviderClient as u}from"@better-auth/oauth-provider/client";import{passkeyClient as d}from"@better-auth/passkey/client";import{adminClient as p,anonymousClient as f,customSessionClient as c,deviceAuthorizationClient as g,emailOTPClient as A,inferAdditionalFields as x,inferOrgAdditionalFields as y,jwtClient as S,lastLoginMethodClient as L,magicLinkClient as T,multiSessionClient as k,oneTapClient as v,oneTimeTokenClient as w,organizationClient as z,phoneNumberClient as F,siweClient as P,twoFactorClient as O,usernameClient as b}from"better-auth/client/plugins";export{p as adminClient,f as anonymousClient,a as apiKeyClient,n as createLunoraAuthClient,c as customSessionClient,g as deviceAuthorizationClient,A as emailOTPClient,x as inferAdditionalFields,y as inferOrgAdditionalFields,S as jwtClient,L as lastLoginMethodClient,t as lunoraAuthPlugins,o as lunoraSessionSync,T as magicLinkClient,k as multiSessionClient,l as notifyLunoraSessionChange,s as oauthDeviceAuthorizationClient,u as oauthProviderClient,v as oneTapClient,w as oneTimeTokenClient,z as organizationClient,d as passkeyClient,F as phoneNumberClient,P as siweClient,O as twoFactorClient,b as usernameClient};
@@ -0,0 +1,13 @@
1
+ import { ssoClient } from '@better-auth/sso/client';
2
+ export type {
3
+ /**
4
+ * Adds `authClient.signIn.sso({ email | domain | providerId })`. Registering the
5
+ * server `sso` plugin without this leaves those actions unavailable and untyped.
6
+ */
7
+ ssoClient } from '@better-auth/sso/client';
8
+ /**
9
+ * The plugin instance `ssoClient()` returns. Exported so an app can type the array it
10
+ * passes to `createAuthClient` when it assembles plugins conditionally.
11
+ */
12
+ type SSOClientPlugin = ReturnType<typeof ssoClient>;
13
+ export { SSOClientPlugin };
@@ -0,0 +1,13 @@
1
+ import { ssoClient } from '@better-auth/sso/client';
2
+ export type {
3
+ /**
4
+ * Adds `authClient.signIn.sso({ email | domain | providerId })`. Registering the
5
+ * server `sso` plugin without this leaves those actions unavailable and untyped.
6
+ */
7
+ ssoClient } from '@better-auth/sso/client';
8
+ /**
9
+ * The plugin instance `ssoClient()` returns. Exported so an app can type the array it
10
+ * passes to `createAuthClient` when it assembles plugins conditionally.
11
+ */
12
+ type SSOClientPlugin = ReturnType<typeof ssoClient>;
13
+ export { SSOClientPlugin };
@@ -0,0 +1 @@
1
+ import{ssoClient as r}from"@better-auth/sso/client";export{r as ssoClient};