@shivaedev/identity 0.14.0 → 0.16.0

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 (53) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +66 -2
  3. package/dist/server/better-auth/adapters/effectHookOptions.d.ts +6 -0
  4. package/dist/server/better-auth/adapters/effectHookOptions.d.ts.map +1 -0
  5. package/dist/server/better-auth/adapters/effectHookOptions.js +62 -0
  6. package/dist/server/better-auth/adapters/effectHookOptions.js.map +1 -0
  7. package/dist/server/better-auth/adapters/emailOptions.d.ts +8 -0
  8. package/dist/server/better-auth/adapters/emailOptions.d.ts.map +1 -0
  9. package/dist/server/better-auth/adapters/emailOptions.js +43 -0
  10. package/dist/server/better-auth/adapters/emailOptions.js.map +1 -0
  11. package/dist/server/better-auth/adapters/hookRuntime.d.ts +7 -0
  12. package/dist/server/better-auth/adapters/hookRuntime.d.ts.map +1 -0
  13. package/dist/server/better-auth/adapters/hookRuntime.js +37 -0
  14. package/dist/server/better-auth/adapters/hookRuntime.js.map +1 -0
  15. package/dist/server/better-auth/adapters/response.d.ts +23 -0
  16. package/dist/server/better-auth/adapters/response.d.ts.map +1 -0
  17. package/dist/server/better-auth/adapters/response.js +41 -0
  18. package/dist/server/better-auth/adapters/response.js.map +1 -0
  19. package/dist/server/better-auth/databaseHooks.d.ts +12 -0
  20. package/dist/server/better-auth/databaseHooks.d.ts.map +1 -0
  21. package/dist/server/better-auth/databaseHooks.js +2 -0
  22. package/dist/server/better-auth/databaseHooks.js.map +1 -0
  23. package/dist/server/better-auth/emailWindow.d.ts +3 -0
  24. package/dist/server/better-auth/emailWindow.d.ts.map +1 -0
  25. package/dist/server/better-auth/emailWindow.js +23 -0
  26. package/dist/server/better-auth/emailWindow.js.map +1 -0
  27. package/dist/server/better-auth/emails.d.ts +31 -0
  28. package/dist/server/better-auth/emails.d.ts.map +1 -0
  29. package/dist/server/better-auth/emails.js +2 -0
  30. package/dist/server/better-auth/emails.js.map +1 -0
  31. package/dist/server/better-auth/mount.d.ts +4 -0
  32. package/dist/server/better-auth/mount.d.ts.map +1 -1
  33. package/dist/server/better-auth/mount.js +7 -1
  34. package/dist/server/better-auth/mount.js.map +1 -1
  35. package/dist/server/better-auth/mountRoutes.d.ts +1 -20
  36. package/dist/server/better-auth/mountRoutes.d.ts.map +1 -1
  37. package/dist/server/better-auth/mountRoutes.js +2 -39
  38. package/dist/server/better-auth/mountRoutes.js.map +1 -1
  39. package/dist/server/better-auth/testing.d.ts +18 -0
  40. package/dist/server/better-auth/testing.d.ts.map +1 -1
  41. package/dist/server/better-auth/testing.js +6 -2
  42. package/dist/server/better-auth/testing.js.map +1 -1
  43. package/package.json +10 -10
  44. package/src/server/better-auth/adapters/effectHookOptions.ts +87 -0
  45. package/src/server/better-auth/adapters/emailOptions.ts +59 -0
  46. package/src/server/better-auth/adapters/hookRuntime.ts +41 -0
  47. package/src/server/better-auth/adapters/response.ts +56 -0
  48. package/src/server/better-auth/databaseHooks.ts +15 -0
  49. package/src/server/better-auth/emailWindow.ts +27 -0
  50. package/src/server/better-auth/emails.ts +23 -0
  51. package/src/server/better-auth/mount.ts +11 -1
  52. package/src/server/better-auth/mountRoutes.ts +2 -53
  53. package/src/server/better-auth/testing.ts +10 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.16.0 - 2026-11-01
4
+
5
+ ### Added
6
+
7
+ - Wire Better Auth's four email callbacks through one `emails` mount option. Deliver typed account confirmation, email-change approval, new-address confirmation, password-reset and existing-account messages with application route links and decoded new addresses.
8
+ - Throttle email delivery attempts per account and message kind within a configurable, mount-local window that defaults to one minute.
9
+ - Generated starters wire typed, throttled auth emails and provide application confirmation and password-reset routes.
10
+
11
+ ## 0.15.0 - 2026-11-01
12
+
13
+ ### Added
14
+
15
+ - Applications supply Better Auth database hooks as Effects through `betterAuthMount`'s `databaseHooks` option. Mounted requests provide their services, tracing and interruption; typed failures carry an application code and message, and defects remain request defects.
16
+ - Identity exposes `signInAgain(auth, userId)` to mint a fresh test session for an existing user using the caller's Effect Clock and Better Auth's configured lifetime.
17
+ - Generated apps provide session renewal verbs for HTTP visitors and browser cookies after long story clock jumps.
18
+
19
+ ### Changed
20
+
21
+ - The starter's app and cookie story kits start TestClock at the present by default so Better Auth's wall-clock endpoints accept minted sessions. Stories can still choose an explicit clock.
22
+
3
23
  ## 0.14.0 - 2026-10-31
4
24
 
5
25
  ### Fixed
package/README.md CHANGED
@@ -135,6 +135,41 @@ The auth HTTP server span records the resolved rate-limit address in `auth.rate_
135
135
 
136
136
  For email sign-in through `appHost`, the session record's `ipAddress` follows the same rule. With a trusted peer, `AUTH_CLIENT_IP_HEADER=x-real-ip` stores `X-Real-IP` even if `X-Forwarded-For` supplies a different address; the default header selects the rightmost untrusted address in the `X-Forwarded-For` chain, ignoring trusted proxy hops on the right. With an untrusted peer, neither header can supply the stored address. Sign-in attempts from an untrusted peer share one bucket per path; with a trusted peer and `x-real-ip`, changing `X-Forwarded-For` does not change the bucket, while changing `X-Real-IP` does.
137
137
 
138
+ #### Application database hooks
139
+
140
+ Pass Effect hooks in the mount's second argument under `databaseHooks`. The shape, arguments and successful results match Better Auth's database hooks; each callback returns an Effect instead of a Promise. `BetterAuthDatabaseHooks` and the structural `BetterAuthHookError` type live in `@shivaedev/identity/server/better-auth/databaseHooks.ts`.
141
+
142
+ ```ts
143
+ import type { BetterAuthOptions } from "better-auth";
144
+ import { Context, Effect } from "effect";
145
+ import type { BetterAuthHookError } from "@shivaedev/identity/server/better-auth/databaseHooks.ts";
146
+ import { betterAuthMount } from "@shivaedev/identity/server/better-auth/mount.ts";
147
+
148
+ class SessionAdmission extends Context.Service<
149
+ SessionAdmission,
150
+ {
151
+ readonly check: (userId: string) => Effect.Effect<void, BetterAuthHookError>;
152
+ }
153
+ >()("app/SessionAdmission") {}
154
+
155
+ const authentication = (options: BetterAuthOptions) =>
156
+ betterAuthMount(options, {
157
+ databaseHooks: {
158
+ session: {
159
+ create: {
160
+ before: (session) => Effect.flatMap(SessionAdmission, ({ check }) => check(session.userId)),
161
+ },
162
+ },
163
+ },
164
+ });
165
+ ```
166
+
167
+ Provide the hook's services when building the mount. Mounted HTTP requests run hooks with the request's services, spans, log annotations and cancellation signal; request services override the mount's services. A direct call through `auth.api` uses the mount's services and the endpoint request's signal when present.
168
+
169
+ Fail a `before` hook with `{ code: "MEMBERS_ONLY", message: "Membership is required" }`, or an application tagged error with those fields, to refuse the operation with HTTP 403 and that code and message. Defects remain defects in the mounted request, even when Better Auth catches the callback rejection. Hooks follow Better Auth's lifecycle: use `before` to refuse a write; `after` runs after the write and does not undo it.
170
+
171
+ Native callbacks in the first argument run before the corresponding Effect callbacks. A native `before` returning `false` stops the Effect callback too. Data changes compose in order. Identity's sign-in policy still runs after the application's session hook.
172
+
138
173
  ### Role assignments
139
174
 
140
175
  Pass `{ defaultRole: "member", roles: AppAccess }` as the second argument to `betterAuthMount`. Identity adds `/admin/set-role`, `/admin/update-user` and `/admin/create-user` to the disabled HTTP paths and sets the Better Auth admin plugin's `adminRoles` to `[]`. Existing disabled paths remain in effect. The admin Users page remains the application path for role changes.
@@ -603,10 +638,12 @@ const { user, headers, cookies } = await Effect.runPromise(
603
638
  );
604
639
  ```
605
640
 
606
- `options` is the application's auth configuration. `signedInUser` saves the supplied user fields, creates each optional `providerAccounts` entry for that user through Better Auth's internal adapter, and mints one session through Better Auth's `testUtils`, without OAuth or password hashing. The accounts carry no tokens or password. Omitting `providerAccounts` creates only the user and session. It returns an Effect containing Better Auth's login result: the user, session, signed request headers, browser cookies and token. In a story, call `yield* signedInUser(auth, fields)` so minting uses that story's TestClock. If the story also calls Better Auth's auth endpoints, start its TestClock at the present or a future date because those endpoints still check the provider's wall clock. To mint users with roles, use the auth instance returned by `betterAuthMount(options, { defaultRole: "member", roles: Access })`. Send `headers` to the real host, or pass `cookies` to test-story's `seedCookies` in a DOM story after setting its host location with `domFetch`. Keep a real sign-in story for each sign-in flow; feature stories start from the minted precondition.
641
+ `options` is the application's auth configuration. `signedInUser` saves the supplied user fields, creates each optional `providerAccounts` entry for that user through Better Auth's internal adapter, and mints one session through Better Auth's `testUtils`, without OAuth or password hashing. The accounts carry no tokens or password. Omitting `providerAccounts` creates only the user and session. It returns an Effect containing Better Auth's login result: the user, session, signed request headers, browser cookies and token. In a story, call `yield* signedInUser(auth, fields)` so minting uses that story's TestClock. If the story also calls Better Auth's auth endpoints, start its TestClock at the present because those endpoints still check the provider's wall clock. The starter’s app and cookie story kits select that default; stories can still pass an explicit `clock`. To mint users with roles, use the auth instance returned by `betterAuthMount(options, { defaultRole: "member", roles: Access })`. Send `headers` to the real host, or pass `cookies` to test-story's `seedCookies` in a DOM story after setting its host location with `domFetch`. Keep a real sign-in story for each sign-in flow; feature stories start from the minted precondition.
607
642
 
608
643
  `passwordUser(auth, { email, password, ...fields })` from the same testing module saves a user and a credential account using Better Auth's configured password hasher, and returns an Effect containing the user without minting a session. Use it for the one story that signs in through `/api/auth/sign-in/email`; keep feature stories on `signedInUser` so they avoid password hashing.
609
644
 
645
+ Call `yield* signInAgain(auth, userId)` from `server/better-auth/testing.ts` to mint a fresh session for an existing user after a long story clock jump. It returns the same login shape as `signedInUser` and sets expiry from the caller’s Effect Clock and the configured session lifetime. Replace the visitor’s request headers or seed the returned browser cookies.
646
+
610
647
  Use `storedProviderAccounts(auth, userId)` to observe credential storage through Better Auth's internal adapter. It returns account and provider IDs with `hasAccessToken`, `hasRefreshToken`, `hasIdToken` and `hasPassword` booleans. It never returns token values, passwords or password hashes. A DOM story kit that exposes its test auth instance and a session readout can use both helpers:
611
648
 
612
649
  ```ts
@@ -642,6 +679,32 @@ app.it("the member's provider account stores no credentials", [member], function
642
679
 
643
680
  With database-backed sessions and cookie caching disabled, revocation rejects that same minted session on the next protected HTTP or RPC request. Cookie caching and secondary storage can change revocation timing.
644
681
 
682
+ ### Deliver typed auth emails
683
+
684
+ Give `betterAuthMount` one `emails` configuration instead of four Better Auth callbacks. The application supplies absolute route URLs and a delivery Effect; it owns the transport and message text.
685
+
686
+ ```ts
687
+ const mounted = yield* betterAuthMount(options, {
688
+ emails: {
689
+ routes: {
690
+ ConfirmAccount: "https://app.example/confirm-account",
691
+ ApproveEmailChange: "https://app.example/approve-email-change",
692
+ ConfirmNewAddress: "https://app.example/confirm-new-address",
693
+ ResetPassword: "https://app.example/reset-password",
694
+ AccountAlreadyExists: "https://app.example/sign-in",
695
+ },
696
+ deliver: (message) => mailer.deliver(message),
697
+ window: "1 minute",
698
+ },
699
+ });
700
+ ```
701
+
702
+ `AuthEmail` from `server/better-auth/emails.ts` is a union discriminated by `_tag`: `ConfirmAccount`, `ApproveEmailChange`, `ConfirmNewAddress`, `ResetPassword` and `AccountAlreadyExists`. Each message carries `user` and `url`. All except `AccountAlreadyExists` carry `token`; both change messages also carry `newEmail`, decoded inside identity for the reused verification callback. The new-address message's `user.email` is the destination address. The app URL preserves its own query parameters and receives the token in a `token` query parameter. A confirmation route passes that token to Better Auth's verification API; a reset page submits it with the new password to its reset API.
703
+
704
+ The wiring replaces the four delivery callbacks and preserves the other Better Auth settings. Enable the flows through native options: `emailAndPassword.enabled`, `emailVerification.sendOnSignUp` or `emailAndPassword.requireEmailVerification`, and `user.changeEmail.enabled`. Better Auth calls `onExistingUserSignUp` only with its generic duplicate-signup response enabled, such as with `requireEmailVerification`.
705
+
706
+ Each mount reserves one delivery attempt per account id and message kind for one minute by default. `window` accepts an Effect Duration input. Different accounts and different kinds have separate windows; changing the destination address does not change the account key. Concurrent requests share the reservation, and another delivery is allowed at expiry. Suppressed requests return normally. A failed delivery keeps its reservation until expiry. The window uses the Effect Clock, lives in the mount's scope, and is held in memory; separate processes or mounts have separate windows. It complements Better Auth's request rate limits. Delivery Effects use the same `BetterAuthHookError` and request runtime as database hooks.
707
+
645
708
  ### Sweep expired sessions in a worker
646
709
 
647
710
  Better Auth removes an expired session when it is presented. Use `sweepExpiredSessions` from `@shivaedev/identity/server/better-auth/sweepExpiredSessions.ts` to remove expired rows that are never presented again. The Effect reads the application's `SqlClient`, deletes sessions whose `expiresAt` is at or before Effect's current time, and returns the number removed. It preserves live sessions and needs no Better Auth mount or auth pool. It assumes the default Better Auth PostgreSQL table and column mappings.
@@ -669,8 +732,9 @@ Import the module that defines the name; there is no package-root entry. Paths b
669
732
  | `server/tracing.ts` | `requestTracingLayer({ header?, sensitive? })`: the `RequestTracing` implementation. |
670
733
  | `server/sessionKeys.ts` | `resolveChanges`: session-scoped change subscriptions for custom change handlers. |
671
734
  | `server/commandChanges.ts` | `commandChanges(effect, rpc, payload)`: scoped command invalidation for custom authentication middleware. |
672
- | `server/better-auth/mount.ts` | `betterAuthMount(options, { signIn?, bearerSessions?, roles?, defaultRole?, roleSeed? })`, returning `{ auth, routes, sessions, admittedSessions, revokeUnadmitted }`: native auth routes and the sign-in policy. |
735
+ | `server/better-auth/mount.ts` | `betterAuthMount(options, { emails?, signIn?, bearerSessions?, roles?, defaultRole?, roleSeed? })`, returning `{ auth, routes, sessions, admittedSessions, revokeUnadmitted }`: native auth routes and the sign-in policy. |
673
736
  | `server/better-auth/adapters/database.ts` | `betterAuthDatabase()`: Better Auth storage on the application PostgreSQL client. |
737
+ | `server/better-auth/emails.ts` | `AuthEmail`, `BetterAuthEmails`: typed delivery messages, app routes and per-account delivery windows for the mount. |
674
738
  | `server/better-auth/allowedAccounts.ts` | `ProviderAccounts`, `AllowedAccounts`, `allowedAccounts`: provider-account list Schemas and the non-empty `AUTH_ALLOWED_ACCOUNTS` Config. |
675
739
  | `server/better-auth/accountRoleSeed.ts` | `accountRoleSeed(access, role, accounts)`: grant a configured role at boot and sign-in through `assignRole`. |
676
740
  | `server/better-auth/signInGate.ts` | `SignInPolicy`: the `accounts`, `rule` and `recheckInterval` of a sign-in policy. |
@@ -0,0 +1,6 @@
1
+ import type { BetterAuthOptions } from "better-auth";
2
+ import type { Effect } from "effect";
3
+ import type { BetterAuthDatabaseHooks } from "#server/better-auth/databaseHooks.ts";
4
+ import type { hookRuntime } from "./hookRuntime.ts";
5
+ export declare function effectHookOptions<TOptions extends BetterAuthOptions, R>(options: TOptions, hooks: BetterAuthDatabaseHooks<R> | undefined, runtime: Effect.Success<ReturnType<typeof hookRuntime<R>>>): TOptions;
6
+ //# sourceMappingURL=effectHookOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"effectHookOptions.d.ts","sourceRoot":"","sources":["../../../../src/server/better-auth/adapters/effectHookOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAA0B,MAAM,aAAa,CAAC;AAC7E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EAAE,uBAAuB,EAAuB,MAAM,sCAAsC,CAAC;AACzG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAsBpD,wBAAgB,iBAAiB,CAAC,QAAQ,SAAS,iBAAiB,EAAE,CAAC,EACtE,OAAO,EAAE,QAAQ,EACjB,KAAK,EAAE,uBAAuB,CAAC,CAAC,CAAC,GAAG,SAAS,EAC7C,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,GACxD,QAAQ,CAyDV"}
@@ -0,0 +1,62 @@
1
+ function mergeResult(previous, next) {
2
+ if (typeof previous === "object" && typeof next === "object") {
3
+ return { ...next, data: { ...previous.data, ...next.data } };
4
+ }
5
+ return next === undefined || next === true ? (previous ?? next) : next;
6
+ }
7
+ export function effectHookOptions(options, hooks, runtime) {
8
+ function composeBefore(hook, own) {
9
+ return async (data, endpoint) => {
10
+ const previous = await own?.(data, endpoint);
11
+ if (previous === false) {
12
+ return previous;
13
+ }
14
+ const input = typeof previous === "object" ? { ...data, ...previous.data } : data;
15
+ const next = await runtime.runHook(() => hook(input, endpoint), endpoint?.request?.signal);
16
+ return mergeResult(previous, next);
17
+ };
18
+ }
19
+ function composeAfter(hook, own) {
20
+ return async (data, endpoint) => {
21
+ await own?.(data, endpoint);
22
+ await runtime.runHook(() => hook(data, endpoint), endpoint?.request?.signal);
23
+ };
24
+ }
25
+ function operation(own, application) {
26
+ return {
27
+ ...own,
28
+ ...(application?.before === undefined ? {} : { before: composeBefore(application.before, own?.before) }),
29
+ ...(application?.after === undefined ? {} : { after: composeAfter(application.after, own?.after) }),
30
+ };
31
+ }
32
+ if (hooks === undefined) {
33
+ return options;
34
+ }
35
+ const native = options.databaseHooks;
36
+ return {
37
+ ...options,
38
+ databaseHooks: {
39
+ account: {
40
+ create: operation(native?.account?.create, hooks.account?.create),
41
+ delete: operation(native?.account?.delete, hooks.account?.delete),
42
+ update: operation(native?.account?.update, hooks.account?.update),
43
+ },
44
+ session: {
45
+ create: operation(native?.session?.create, hooks.session?.create),
46
+ delete: operation(native?.session?.delete, hooks.session?.delete),
47
+ update: operation(native?.session?.update, hooks.session?.update),
48
+ },
49
+ user: {
50
+ create: operation(native?.user?.create, hooks.user?.create),
51
+ delete: operation(native?.user?.delete, hooks.user?.delete),
52
+ update: operation(native?.user?.update, hooks.user?.update),
53
+ },
54
+ verification: {
55
+ create: operation(native?.verification?.create, hooks.verification?.create),
56
+ delete: operation(native?.verification?.delete, hooks.verification?.delete),
57
+ update: operation(native?.verification?.update, hooks.verification?.update),
58
+ },
59
+ },
60
+ };
61
+ }
62
+ //# sourceMappingURL=effectHookOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"effectHookOptions.js","sourceRoot":"","sources":["../../../../src/server/better-auth/adapters/effectHookOptions.ts"],"names":[],"mappings":"AAkBA,SAAS,WAAW,CAAuB,QAAuB,EAAE,IAAO;IAC1E,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC9D,OAAO,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,EAAE,GAAG,QAAQ,CAAC,IAAI,EAAE,GAAG,I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AC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC;aACjE;YACD,IAAI,EAAE;gBACL,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC;gBAC3D,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC;gBAC3D,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC;aAC3D;YACD,YAAY,EAAE;gBACb,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,CAAC,YAAY,EAAE,MAAM,CAAC;gBAC3E,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,CAAC,YAAY,EAAE,MAAM,CAAC;gBAC3E,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,CAAC,YAAY,EAAE,MAAM,CAAC;aAC3E;SACD;KACD,CAAC;AACH,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { BetterAuthOptions } from "better-auth";
2
+ import { Effect } from "effect";
3
+ import type { BetterAuthEmails } from "#server/better-auth/emails.ts";
4
+ export declare const emailOptions: <TOptions extends BetterAuthOptions, R>(options: TOptions, emails: BetterAuthEmails<R> | undefined, runtime: {
5
+ runHook: <A>(hook: () => Effect.Effect<A, import("../databaseHooks.ts").BetterAuthHookError, R>, signal: AbortSignal | undefined) => Promise<A>;
6
+ runRequest: <A>(request: (signal: AbortSignal) => Promise<A>) => Effect.Effect<A, import("effect/Cause").UnknownError, never>;
7
+ }) => Effect.Effect<TOptions, never, import("effect/Scope").Scope>;
8
+ //# sourceMappingURL=emailOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emailOptions.d.ts","sourceRoot":"","sources":["../../../../src/server/better-auth/adapters/emailOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AACxC,OAAO,KAAK,EAAa,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAQjF,eAAO,MAAM,YAAY,GAAgC,QAAQ,SAAS,iBAAiB,EAAE,CAAC;;;kEAgD5F,CAAC"}
@@ -0,0 +1,43 @@
1
+ import { Effect, Schema } from "effect";
2
+ import { emailWindow } from "#server/better-auth/emailWindow.ts";
3
+ const Verification = Schema.Struct({ updateTo: Schema.optionalKey(Schema.String) });
4
+ export const emailOptions = Effect.fnUntraced(function* (options, emails, runtime) {
5
+ if (emails === undefined) {
6
+ return options;
7
+ }
8
+ const { routes, deliver } = emails;
9
+ const claim = yield* emailWindow(emails.window);
10
+ function send(message, request) {
11
+ const url = new URL(routes[message._tag]);
12
+ if ("token" in message) {
13
+ url.searchParams.set("token", message.token);
14
+ }
15
+ return runtime.runHook(() => claim(message.user.id, message._tag).pipe(Effect.flatMap((allowed) => (allowed ? deliver({ ...message, url: url.href }) : Effect.void))), request?.signal);
16
+ }
17
+ return {
18
+ ...options,
19
+ emailAndPassword: {
20
+ ...options.emailAndPassword,
21
+ enabled: options.emailAndPassword?.enabled ?? false,
22
+ onExistingUserSignUp: ({ user }, request) => send({ _tag: "AccountAlreadyExists", user }, request),
23
+ sendResetPassword: ({ user, token }, request) => send({ _tag: "ResetPassword", token, user }, request),
24
+ },
25
+ emailVerification: {
26
+ ...options.emailVerification,
27
+ sendVerificationEmail: ({ user, token }, request) => {
28
+ const payload = token.split(".")[1] ?? "";
29
+ const { updateTo } = Schema.decodeUnknownSync(Schema.fromJsonString(Verification))(Buffer.from(payload, "base64url").toString("utf8"));
30
+ return send(updateTo === undefined ? { _tag: "ConfirmAccount", token, user } : { _tag: "ConfirmNewAddress", newEmail: updateTo, token, user }, request);
31
+ },
32
+ },
33
+ user: {
34
+ ...options.user,
35
+ changeEmail: {
36
+ ...options.user?.changeEmail,
37
+ enabled: options.user?.changeEmail?.enabled ?? false,
38
+ sendChangeEmailConfirmation: ({ user, newEmail, token }, request) => send({ _tag: "ApproveEmailChange", newEmail, token, user }, request),
39
+ },
40
+ },
41
+ };
42
+ });
43
+ //# sourceMappingURL=emailOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emailOptions.js","sourceRoot":"","sources":["../../../../src/server/better-auth/adapters/emailOptions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAExC,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAKjE,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAEpF,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EACtD,OAAiB,EACjB,MAAuC,EACvC,OAA0D;IAE1D,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,OAAO,CAAC;IAChB,CAAC;IACD,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;IACnC,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAChD,SAAS,IAAI,CAAC,OAAiB,EAAE,OAAiB;QACjD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QAC1C,IAAI,OAAO,IAAI,OAAO,EAAE,CAAC;YACxB,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,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C,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;gBACvI,OAAO,IAAI,CACV,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,EACjI,OAAO,CACP,CAAC;YACH,CAAC;SACD;QACD,IAAI,EAAE;YACL,GAAG,OAAO,CAAC,IAAI;YACf,WAAW,EAAE;gBACZ,GAAG,OAAO,CAAC,IAAI,EAAE,WAAW;gBAC5B,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,IAAI,KAAK;gBACpD,2BAA2B,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,oBAAoB,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,OAAO,CAAC;aACzI;SACD;KAC2B,CAAC;AAC/B,CAAC,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { type Cause, Effect } from "effect";
2
+ import type { BetterAuthHookError } from "#server/better-auth/databaseHooks.ts";
3
+ export declare const hookRuntime: <R>() => Effect.Effect<{
4
+ runHook: <A>(hook: () => Effect.Effect<A, BetterAuthHookError, R>, signal: AbortSignal | undefined) => Promise<A>;
5
+ runRequest: <A>(request: (signal: AbortSignal) => Promise<A>) => Effect.Effect<A, Cause.UnknownError, never>;
6
+ }, never, R>;
7
+ //# sourceMappingURL=hookRuntime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hookRuntime.d.ts","sourceRoot":"","sources":["../../../../src/server/better-auth/adapters/hookRuntime.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,KAAK,EAAW,MAAM,EAAU,MAAM,QAAQ,CAAC;AAC7D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAEhF,eAAO,MAAM,WAAW,GAAgC,CAAC;cAIvC,CAAC,QAAQ,MAAM,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,mBAAmB,EAAE,CAAC,CAAC,UAAU,WAAW,GAAG,SAAS,KAAG,OAAO,CAAC,CAAC,CAAC;iBAiBxG,CAAC,WAAW,CAAC,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC;YAc5D,CAAC"}
@@ -0,0 +1,37 @@
1
+ import { AsyncLocalStorage } from "node:async_hooks";
2
+ import { APIError } from "better-auth/api";
3
+ import { Context, Effect, Result } from "effect";
4
+ export const hookRuntime = Effect.fnUntraced(function* () {
5
+ const context = yield* Effect.context();
6
+ const requests = new AsyncLocalStorage();
7
+ return {
8
+ runHook: async (hook, signal) => {
9
+ const request = requests.getStore();
10
+ function remember(cause) {
11
+ return Effect.sync(() => {
12
+ if (request !== undefined) {
13
+ request.cause = cause;
14
+ }
15
+ });
16
+ }
17
+ const result = await Effect.runPromiseWith(request?.context ?? context)(Effect.suspend(hook).pipe(Effect.result, Effect.tapCause(remember)), {
18
+ signal,
19
+ });
20
+ if (Result.isFailure(result)) {
21
+ throw new APIError("FORBIDDEN", { code: result.failure.code, message: result.failure.message });
22
+ }
23
+ return result.success;
24
+ },
25
+ runRequest: (request) => Effect.withFiber((fiber) => Effect.gen(function* () {
26
+ const state = {
27
+ context: Context.merge(context, fiber.context),
28
+ };
29
+ const exit = yield* Effect.exit(Effect.tryPromise((signal) => requests.run(state, () => request(signal))));
30
+ if (state.cause !== undefined) {
31
+ return yield* Effect.failCause(state.cause);
32
+ }
33
+ return yield* exit;
34
+ })),
35
+ };
36
+ });
37
+ //# sourceMappingURL=hookRuntime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hookRuntime.js","sourceRo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CAAC,OAAO,EAAE,CAAC,CAAC;YACjG,CAAC;YACD,OAAO,MAAM,CAAC,OAAO,CAAC;QACvB,CAAC;QACD,UAAU,EAAE,CAAI,OAA4C,EAAE,EAAE,CAC/D,MAAM,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAC1B,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;YACnB,MAAM,KAAK,GAAyE;gBACnF,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC;aAC9C,CAAC;YACF,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;YAC3G,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;gBAC/B,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YAC7C,CAAC;YACD,OAAO,KAAK,CAAC,CAAC,IAAI,CAAC;QACpB,CAAC,CAAC,CACF;KACF,CAAC;AACH,CAAC,CAAC,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { type Cause, Effect } from "effect";
2
+ import type { RoleSet } from "@shivaedev/access/roleSet.ts";
3
+ import { type BearerSessionsOptions } from "#server/better-auth/bearerSessions.ts";
4
+ export interface MountedAuth {
5
+ readonly $context: Promise<{
6
+ readonly authCookies: {
7
+ readonly sessionToken: {
8
+ readonly name: string;
9
+ };
10
+ };
11
+ }>;
12
+ readonly handler: (request: Request) => Promise<Response>;
13
+ }
14
+ export interface MountRouteOptions {
15
+ readonly bearerSessions?: BearerSessionsOptions | undefined;
16
+ readonly clientIpHeader: string;
17
+ readonly ipv6Subnet?: number | undefined;
18
+ readonly roles?: RoleSet | undefined;
19
+ readonly runRequest?: (<A>(request: (signal: AbortSignal) => Promise<A>) => Effect.Effect<A, Cause.UnknownError>) | undefined;
20
+ readonly trustedProxy?: string | undefined;
21
+ }
22
+ export declare const response: (auth: MountedAuth, web: Request, options: MountRouteOptions) => Effect.Effect<Response, import("@shivaedev/errors/taxonomy.ts").Forbidden | import("effect/Schema").SchemaError | Cause.UnknownError, never>;
23
+ //# sourceMappingURL=response.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../../../src/server/better-auth/adapters/response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,KAAK,qBAAqB,EAA2D,MAAM,uCAAuC,CAAC;AAG5I,MAAM,WAAW,WAAW;IAC3B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;QAAE,QAAQ,CAAC,WAAW,EAAE;YAAE,QAAQ,CAAC,YAAY,EAAE;gBAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;aAAE,CAAA;SAAE,CAAA;KAAE,CAAC,CAAC;IAC3G,QAAQ,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;CAC1D;AACD,MAAM,WAAW,iBAAiB;IACjC,QAAQ,CAAC,cAAc,CAAC,EAAE,qBAAqB,GAAG,SAAS,CAAC;IAC5D,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,GAAG,SAAS,CAAC;IAC9H,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3C;AA6BD,eAAO,MAAM,QAAQ,+MAUnB,CAAC"}
@@ -0,0 +1,41 @@
1
+ import { Effect } from "effect";
2
+ import { cookieSessionResponse, hasSessionCookie, sessionHeaders } from "#server/better-auth/bearerSessions.ts";
3
+ import { sessionPermissions } from "#server/better-auth/sessionPermissions.ts";
4
+ function replacesSession(request, reply, native) {
5
+ return (native
6
+ && reply.ok
7
+ && reply.headers.has("set-auth-token")
8
+ && request.headers.has("authorization")
9
+ && new URL(request.url).pathname.startsWith("/api/auth/sign-in/"));
10
+ }
11
+ async function providerResponse(auth, web, options) {
12
+ if (options.bearerSessions === undefined) {
13
+ return auth.handler(web);
14
+ }
15
+ const { authCookies } = await auth.$context;
16
+ const cookieName = authCookies.sessionToken.name;
17
+ const headers = sessionHeaders(web.headers, cookieName);
18
+ const native = options.bearerSessions.origins.includes(web.headers.get("origin") ?? "") && !hasSessionCookie(web.headers, cookieName);
19
+ const request = new Request(web, { headers });
20
+ const reply = await auth.handler(request);
21
+ if (replacesSession(request, reply, native)) {
22
+ const revoked = await auth.handler(new Request(new URL("/api/auth/sign-out", web.url), { body: "{}", headers, method: "POST" }));
23
+ await revoked.body?.cancel();
24
+ if (!revoked.ok) {
25
+ throw new Error("Session replacement failed");
26
+ }
27
+ }
28
+ return native ? reply : cookieSessionResponse(reply);
29
+ }
30
+ export const response = Effect.fnUntraced(function* (auth, web, options) {
31
+ const sessionRequest = options.roles !== undefined && new URL(web.url).pathname === "/api/auth/get-session";
32
+ const url = new URL(web.url);
33
+ if (sessionRequest) {
34
+ url.searchParams.set("disableCookieCache", "true");
35
+ }
36
+ const request = sessionRequest ? new Request(url, web) : web;
37
+ const runRequest = options.runRequest ?? Effect.tryPromise;
38
+ const reply = yield* runRequest((signal) => providerResponse(auth, new Request(request, { signal }), options));
39
+ return sessionRequest && reply.ok && options.roles !== undefined ? yield* sessionPermissions(reply, options.roles) : reply;
40
+ });
41
+ //# sourceMappingURL=response.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response.js","sourceRoot":"","sources":["../../../../src/server/better-auth/adapters/response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE5C,OAAO,EAA8B,qBAAqB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAC5I,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAc/E,SAAS,eAAe,CAAC,OAAgB,EAAE,KAAe,EAAE,MAAe;IAC1E,OAAO,CACN,MAAM;WACH,KAAK,CAAC,EAAE;WACR,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC;WACnC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;WACpC,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,oBAAoB,CAAC,CACjE,CAAC;AACH,CAAC;AACD,KAAK,UAAU,gBAAgB,CAAC,IAAiB,EAAE,GAAY,EAAE,OAA0B;IAC1F,IAAI,OAAO,CAAC,cAAc,KAAK,SAAS,EAAE,CAAC;QAC1C,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;IACD,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC;IAC5C,MAAM,UAAU,GAAG,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC;IACjD,MAAM,OAAO,GAAG,cAAc,CAAC,GAAG,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IACxD,MAAM,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,Q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C;QACpB,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC;IACpD,CAAC;IACD,MAAM,OAAO,GAAG,cAAc,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IAC7D,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,MAAM,CAAC,UAAU,CAAC;IAC3D,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,UAAU,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAI,EAAE,IAAI,OAAO,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;IAC/G,OAAO,cAAc,IAAI,KAAK,CAAC,EAAE,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,kBAAkB,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAC5H,CAAC,CAAC,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { BetterAuthOptions } from "better-auth";
2
+ import type { Effect } from "effect";
3
+ export interface BetterAuthHookError {
4
+ readonly code: string;
5
+ readonly message: string;
6
+ }
7
+ type EffectHooks<T, R> = {
8
+ readonly [TKey in keyof T]: NonNullable<T[TKey]> extends (...args: infer TArgs) => infer TResult ? (...args: TArgs) => Effect.Effect<Awaited<TResult>, BetterAuthHookError, R> : EffectHooks<NonNullable<T[TKey]>, R>;
9
+ };
10
+ export type BetterAuthDatabaseHooks<R = never> = EffectHooks<NonNullable<BetterAuthOptions["databaseHooks"]>, R>;
11
+ export {};
12
+ //# sourceMappingURL=databaseHooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"databaseHooks.d.ts","sourceRoot":"","sources":["../../../src/server/better-auth/databaseHooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,MAAM,WAAW,mBAAmB;IACnC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CACzB;AAED,KAAK,WAAW,CAAC,CAAC,EAAE,CAAC,IAAI;IACxB,QAAQ,EAAE,IAAI,IAAI,MAAM,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,MAAM,KAAK,KAAK,MAAM,OAAO,GAC7F,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,mBAAmB,EAAE,CAAC,CAAC,GAC3E,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,uBAAuB,CAAC,CAAC,GAAG,KAAK,IAAI,WAAW,CAAC,WAAW,CAAC,iBAAiB,CAAC,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=databaseHooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"databaseHooks.js","sourceRoot":"","sources":["../../../src/server/better-auth/databaseHooks.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ import { Duration, Effect } from "effect";
2
+ export declare const emailWindow: (window?: Duration.Input | undefined) => Effect.Effect<(account: string, kind: string) => Effect.Effect<boolean, never, never>, never, import("effect/Scope").Scope>;
3
+ //# sourceMappingURL=emailWindow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emailWindow.d.ts","sourceRoot":"","sources":["../../../src/server/better-auth/emailWindow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEjD,eAAO,MAAM,WAAW,mEAMN,MAAM,QAAQ,MAAM,+EAkBpC,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { Clock, Duration, Effect } from "effect";
2
+ export const emailWindow = Effect.fnUntraced(function* (window = "1 minute") {
3
+ const milliseconds = Duration.toMillis(Duration.fromInputUnsafe(window));
4
+ const entries = yield* Effect.acquireRelease(Effect.sync(() => new Map()), (map) => Effect.sync(() => map.clear()));
5
+ return (account, kind) => Effect.gen(function* () {
6
+ const now = yield* Clock.currentTimeMillis;
7
+ for (const [entryKey, expiry] of entries) {
8
+ if (expiry > now) {
9
+ break;
10
+ }
11
+ entries.delete(entryKey);
12
+ }
13
+ const key = `${account}:${kind}`;
14
+ const reservedUntil = entries.get(key);
15
+ if (reservedUntil !== undefined && reservedUntil > now) {
16
+ return false;
17
+ }
18
+ entries.delete(key);
19
+ entries.set(key, now + milliseconds);
20
+ return true;
21
+ });
22
+ });
23
+ //# sourceMappingURL=emailWindow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emailWindow.js","sourceRoot":"","sources":["../../../src/server/better-auth/emailWindow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEjD,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAmB,UAAU;IAC1F,MAAM,YAAY,GAAG,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC;IACzE,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,cAAc,CAC3C,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,GAAG,EAAkB,CAAC,EAC5C,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,CACvC,CAAC;IACF,OAAO,CAAC,OAAe,EAAE,IAAY,EAAE,EAAE,CACxC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QACnB,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC;QAC3C,KAAK,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;YAC1C,IAAI,MAAM,GAAG,GAAG,EAAE,CAAC;gBAClB,MAAM;YACP,CAAC;YACD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC1B,CAAC;QACD,MAAM,GAAG,GAAG,GAAG,OAAO,IAAI,IAAI,EAAE,CAAC;QACjC,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACvC,IAAI,aAAa,KAAK,SAAS,IAAI,aAAa,GAAG,GAAG,EAAE,CAAC;YACxD,OAAO,KAAK,CAAC;QACd,CAAC;QACD,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACpB,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,GAAG,YAAY,CAAC,CAAC;QACrC,OAAO,IAAI,CAAC;IACb,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,31 @@
1
+ import type { User } from "better-auth";
2
+ import type { Duration, Effect } from "effect";
3
+ import type { BetterAuthHookError } from "./databaseHooks.ts";
4
+ interface Message {
5
+ readonly url: string;
6
+ readonly user: Pick<User, "id" | "email" | "name">;
7
+ }
8
+ export type AuthEmail = Message & ({
9
+ readonly _tag: "ConfirmAccount";
10
+ readonly token: string;
11
+ } | {
12
+ readonly _tag: "ApproveEmailChange";
13
+ readonly token: string;
14
+ readonly newEmail: string;
15
+ } | {
16
+ readonly _tag: "ConfirmNewAddress";
17
+ readonly token: string;
18
+ readonly newEmail: string;
19
+ } | {
20
+ readonly _tag: "ResetPassword";
21
+ readonly token: string;
22
+ } | {
23
+ readonly _tag: "AccountAlreadyExists";
24
+ });
25
+ export interface BetterAuthEmails<R = never> {
26
+ readonly deliver: (message: AuthEmail) => Effect.Effect<void, BetterAuthHookError, R>;
27
+ readonly routes: Readonly<Record<AuthEmail["_tag"], string>>;
28
+ readonly window?: Duration.Input;
29
+ }
30
+ export {};
31
+ //# sourceMappingURL=emails.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emails.d.ts","sourceRoot":"","sources":["../../../src/server/better-auth/emails.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,UAAU,OAAO;IAChB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,GAAG,MAAM,CAAC,CAAC;CACnD;AAED,MAAM,MAAM,SAAS,GAAG,OAAO,GAC9B,CACG;IAAE,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC3D;IAAE,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAC1F;IAAE,QAAQ,CAAC,IAAI,EAAE,mBAAmB,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GACzF;IAAE,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC1D;IAAE,QAAQ,CAAC,IAAI,EAAE,sBAAsB,CAAA;CAAE,CAC3C,CAAC;AAEH,MAAM,WAAW,gBAAgB,CAAC,CAAC,GAAG,KAAK;IAC1C,QAAQ,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,SAAS,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,mBAAmB,EAAE,CAAC,CAAC,CAAC;IACtF,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IAC7D,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC;CACjC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=emails.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emails.js","sourceRoot":"","sources":["../../../src/server/better-auth/emails.ts"],"names":[],"mappings":""}
@@ -6,8 +6,12 @@ import { type StoredRoleOptions } from "#server/better-auth/adapters/storedRoleO
6
6
  import { type BearerSessionsOptions } from "#server/better-auth/bearerSessions.ts";
7
7
  import { type SignInPolicy } from "#server/better-auth/signInGate.ts";
8
8
  import type { AccountRoleSeed } from "./accountRoleSeed.ts";
9
+ import type { BetterAuthDatabaseHooks } from "./databaseHooks.ts";
10
+ import type { BetterAuthEmails } from "./emails.ts";
9
11
  export type BetterAuthMountOptions<E = never, R = never> = {
10
12
  readonly bearerSessions?: BearerSessionsOptions | undefined;
13
+ readonly databaseHooks?: BetterAuthDatabaseHooks<R> | undefined;
14
+ readonly emails?: BetterAuthEmails<R> | undefined;
11
15
  readonly hardening?: BetterAuthHardeningOptions;
12
16
  readonly signIn?: SignInPolicy<E, R> | undefined;
13
17
  } & ({
@@ -1 +1 @@
1
- {"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../../../src/server/better-auth/mount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,E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SAAS,CAAC,EAAE,0BAA0B,CAAC;IAChD,QAAQ,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC;CACjD,GAAG,CACD;IAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAE,GAC7D,CAAC,iBAAiB,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;CAAE,CAAC,CAChH,CAAC;AAEF,eAAO,MAAM,eAAe,SAA0D,QAAQ,SAAS,iBAAiB,EAAE,CAAC,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4DAiEpI,CAAC"}
@@ -1,6 +1,9 @@
1
1
  import { betterAuth } from "better-auth";
2
2
  import { Config, Effect, Option, Redacted } from "effect";
3
+ import { effectHookOptions } from "#server/better-auth/adapters/effectHookOptions.ts";
4
+ import { emailOptions } from "#server/better-auth/adapters/emailOptions.ts";
3
5
  import { withHardening } from "#server/better-auth/adapters/hardening.ts";
6
+ import { hookRuntime } from "#server/better-auth/adapters/hookRuntime.ts";
4
7
  import { roleSeedOptions } from "#server/better-auth/adapters/roleSeedOptions.ts";
5
8
  import { signInPolicyOptions } from "#server/better-auth/adapters/signInPolicyOptions.ts";
6
9
  import { storedRoleOptions } from "#server/better-auth/adapters/storedRoleOptions.ts";
@@ -25,7 +28,9 @@ export const betterAuthMount = Effect.fn("Platform.betterAuthMount")(function* (
25
28
  yield* policy.accounts;
26
29
  }
27
30
  const gate = yield* signInGate(policy);
28
- const configured = mount.roles === undefined ? options : storedRoleOptions(closeRoleEndpoints(options), mount);
31
+ const runtime = yield* hookRuntime();
32
+ const hooked = effectHookOptions(yield* emailOptions(options, mount.emails, runtime), mount.databaseHooks, runtime);
33
+ const configured = mount.roles === undefined ? hooked : storedRoleOptions(closeRoleEndpoints(hooked), mount);
29
34
  const gated = yield* signInPolicyOptions(configured, gate, () => auth.$context);
30
35
  const seed = mount.roleSeed === undefined ? undefined : yield* mount.roleSeed;
31
36
  const seeded = roleSeedOptions(gate.active ? { ...configured, ...gated } : configured, seed);
@@ -62,6 +67,7 @@ export const betterAuthMount = Effect.fn("Platform.betterAuthMount")(function* (
62
67
  clientIpHeader,
63
68
  ipv6Subnet: options.advanced?.ipAddress?.ipv6Subnet,
64
69
  roles: mount.roles,
70
+ runRequest: runtime.runRequest,
65
71
  trustedProxy,
66
72
  });
67
73
  const admit = admittedSessions(gate, () => auth.$context, mount.bearerSessions);
@@ -1 +1 @@
1
- {"version":3,"file":"mount.js","sourceRoot":"","sources":["../../../src/server/better-auth/mount.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,UAAU,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAE1D,OAAO,EAAmC,aAAa,EAAE,MAAM,2CAA2C,CAAC;AAC3G,OAAO,EAAE,eAAe,EAAE,MAAM,iDAAiD,CAAC;AAClF,OAAO,EAAE,mBAAmB,EAAE,MAAM,qDAAqD,CAAC;AAC1F,OAAO,EAA0B,iBAAiB,EAAE,MAAM,mDAAmD,CAAC;AAC9G,OAAO,EAA8B,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AACvG,OAA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