@shivaedev/identity 0.15.0 → 0.17.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.
- package/CHANGELOG.md +26 -0
- package/README.md +105 -52
- package/dist/server/SessionPolicy.d.ts +14 -0
- package/dist/server/SessionPolicy.d.ts.map +1 -0
- package/dist/server/SessionPolicy.js +4 -0
- package/dist/server/SessionPolicy.js.map +1 -0
- package/dist/server/adapters/betterAuthSessions.js +1 -1
- package/dist/server/adapters/betterAuthSessions.js.map +1 -1
- package/dist/server/better-auth/PasswordReset.d.ts +7 -0
- package/dist/server/better-auth/PasswordReset.d.ts.map +1 -0
- package/dist/server/better-auth/PasswordReset.js +2 -0
- package/dist/server/better-auth/PasswordReset.js.map +1 -0
- package/dist/server/better-auth/adapters/emailOptions.d.ts +8 -0
- package/dist/server/better-auth/adapters/emailOptions.d.ts.map +1 -0
- package/dist/server/better-auth/adapters/emailOptions.js +43 -0
- package/dist/server/better-auth/adapters/emailOptions.js.map +1 -0
- package/dist/server/better-auth/adapters/passwordResetOptions.d.ts +6 -0
- package/dist/server/better-auth/adapters/passwordResetOptions.d.ts.map +1 -0
- package/dist/server/better-auth/adapters/passwordResetOptions.js +17 -0
- package/dist/server/better-auth/adapters/passwordResetOptions.js.map +1 -0
- package/dist/server/better-auth/emailWindow.d.ts +3 -0
- package/dist/server/better-auth/emailWindow.d.ts.map +1 -0
- package/dist/server/better-auth/emailWindow.js +23 -0
- package/dist/server/better-auth/emailWindow.js.map +1 -0
- package/dist/server/better-auth/emails.d.ts +31 -0
- package/dist/server/better-auth/emails.d.ts.map +1 -0
- package/dist/server/better-auth/emails.js +2 -0
- package/dist/server/better-auth/emails.js.map +1 -0
- package/dist/server/better-auth/mount.d.ts +4 -0
- package/dist/server/better-auth/mount.d.ts.map +1 -1
- package/dist/server/better-auth/mount.js +5 -2
- package/dist/server/better-auth/mount.js.map +1 -1
- package/dist/server/better-auth/sessionPermissions.js +1 -1
- package/dist/server/better-auth/userProfiles.js +1 -1
- package/dist/server/lookupSession.d.ts +5 -4
- package/dist/server/lookupSession.d.ts.map +1 -1
- package/dist/server/lookupSession.js +8 -4
- package/dist/server/lookupSession.js.map +1 -1
- package/dist/server/permissions.d.ts +4 -4
- package/dist/server/permissions.d.ts.map +1 -1
- package/dist/server/permissions.js +11 -8
- package/dist/server/permissions.js.map +1 -1
- package/dist/server/providerAccountsUser.d.ts +16 -0
- package/dist/server/providerAccountsUser.d.ts.map +1 -0
- package/dist/server/providerAccountsUser.js +12 -0
- package/dist/server/providerAccountsUser.js.map +1 -0
- package/dist/server/recheckSession.d.ts +2 -2
- package/dist/server/recheckSession.d.ts.map +1 -1
- package/dist/server/recheckSession.js +5 -3
- package/dist/server/recheckSession.js.map +1 -1
- package/dist/server/revalidateStream.d.ts +3 -2
- package/dist/server/revalidateStream.d.ts.map +1 -1
- package/dist/server/revalidateStream.js +3 -2
- package/dist/server/revalidateStream.js.map +1 -1
- package/dist/server/session.d.ts +9 -21
- package/dist/server/session.d.ts.map +1 -1
- package/dist/server/session.js +28 -27
- package/dist/server/session.js.map +1 -1
- package/package.json +10 -10
- package/src/server/SessionPolicy.ts +14 -0
- package/src/server/adapters/betterAuthSessions.ts +1 -1
- package/src/server/better-auth/PasswordReset.ts +7 -0
- package/src/server/better-auth/adapters/emailOptions.ts +59 -0
- package/src/server/better-auth/adapters/passwordResetOptions.ts +25 -0
- package/src/server/better-auth/emailWindow.ts +27 -0
- package/src/server/better-auth/emails.ts +23 -0
- package/src/server/better-auth/mount.ts +9 -2
- package/src/server/better-auth/sessionPermissions.ts +1 -1
- package/src/server/better-auth/userProfiles.ts +1 -1
- package/src/server/lookupSession.ts +9 -8
- package/src/server/permissions.ts +29 -21
- package/src/server/providerAccountsUser.ts +16 -0
- package/src/server/recheckSession.ts +5 -4
- package/src/server/revalidateStream.ts +7 -5
- package/src/server/session.ts +87 -85
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.17.0 - 2026-11-01
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Identity's `betterAuthMount` accepts `onPasswordReset`, an Effect callback that runs with the host's context and composes after Better Auth's native reset callback.
|
|
8
|
+
- React's `permissionGuard` accepts `hidden: true` to render TanStack Router's not-found page when a signed-in viewer lacks a required permission.
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- Identity operation spans use the `Identity` prefix, including `Identity.resolveSession` and `Identity.betterAuthSession`. Adjust trace queries that used `Platform` or `PlatformRpc` names.
|
|
13
|
+
|
|
14
|
+
### Breaking
|
|
15
|
+
|
|
16
|
+
- Identity reads `SessionPolicy` from the Effect environment. Import the service from `@shivaedev/identity/server/SessionPolicy.ts` and construct one `Layer.succeed(SessionPolicy, { origin, provider, roles, streamRevalidationInterval })`, omitting optional fields as needed. Replace `SessionPolicy<TSession>` annotations with `SessionPolicy["Service"]`; provider-specific types remain on `SessionProvider<TSession>`. Remove policy arguments from session middleware constructors, `resolveSession`, `withSessionUser`, `permissionLayer`, `permissionRoute`, session lookup, rechecks and stream revalidation; provide the policy Layer to the composed readers. Profiles and provider accounts are decoded at their middleware boundaries from the shared provider.
|
|
17
|
+
- Server's `appHost` `sessions` option accepts that Layer and supplies it to middleware, application routes, sockets and change subscriptions. Wrap the previous policy object in `Layer.succeed(SessionPolicy, policy)`. Remove the session-shape generic from host option and factory types, and remove the policy argument from `hostChanges` and `bearerSocketRpc`.
|
|
18
|
+
- Admin uses identity's `SessionPolicy` directly. Replace `AdminSessions` imports and Layers with the identity service, and provide the policy once through the host instead of separately to admin handlers and documents.
|
|
19
|
+
- MCP's `mcpRoutes` reads `SessionPolicy` from the environment. Remove its `sessions` option and the session-shape generic from `McpOptions`; `betterAuthMcp` now returns `sessions` as a policy Layer, which can be passed to the host or supplied to MCP routes with `HttpRouter.provideRequest(oauth.sessions)` when the host also serves cookie-authenticated RPC.
|
|
20
|
+
|
|
21
|
+
## 0.16.0 - 2026-11-01
|
|
22
|
+
|
|
23
|
+
### Added
|
|
24
|
+
|
|
25
|
+
- 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.
|
|
26
|
+
- Throttle email delivery attempts per account and message kind within a configurable, mount-local window that defaults to one minute.
|
|
27
|
+
- Generated starters wire typed, throttled auth emails and provide application confirmation and password-reset routes.
|
|
28
|
+
|
|
3
29
|
## 0.15.0 - 2026-11-01
|
|
4
30
|
|
|
5
31
|
### Added
|
package/README.md
CHANGED
|
@@ -69,17 +69,19 @@ export const Handlers = Account.toLayer({
|
|
|
69
69
|
|
|
70
70
|
The middleware declaration makes `Identity` available to guarded handlers and adds `Unauthorized`, `AuthUnavailable` and `Forbidden` to the client's failure type. An unguarded handler that requires `Identity` cannot become a service-free handler Layer. Keep the group declaration in the shared module and the handler implementation on the server when organizing application files.
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
Provide one `SessionPolicy` Layer as the host's `sessions` input. Middleware, permission routes and session resolution read that service from the Effect environment. For a Better Auth provider, adapt its existing session lookup:
|
|
73
73
|
|
|
74
74
|
```ts
|
|
75
|
+
import { Layer } from "effect";
|
|
76
|
+
import { SessionPolicy } from "@shivaedev/identity/server/SessionPolicy.ts";
|
|
75
77
|
import { betterAuthSessions } from "@shivaedev/identity/server/adapters/betterAuthSessions.ts";
|
|
76
78
|
import { trustedOrigins } from "@shivaedev/identity/server/origin.ts";
|
|
77
79
|
import { auth } from "./auth.ts";
|
|
78
80
|
|
|
79
|
-
export const sessions = {
|
|
81
|
+
export const sessions = Layer.succeed(SessionPolicy, {
|
|
80
82
|
origin: trustedOrigins({ allow: ["http://localhost:3000"], missing: "allow" }),
|
|
81
83
|
provider: betterAuthSessions((headers) => auth.api.getSession({ headers })),
|
|
82
|
-
};
|
|
84
|
+
});
|
|
83
85
|
```
|
|
84
86
|
|
|
85
87
|
`trustedOrigins({ allow, missing })` accepts an exact allowlist and supports `missing: "reject"` or `"allow"`; a custom `OriginPolicy` can decide from the RPC name or transport headers. A denied policy fails with `Forbidden` before provider lookup. The host's HTTP guard also checks Origin against the local request's Host.
|
|
@@ -170,6 +172,19 @@ Fail a `before` hook with `{ code: "MEMBERS_ONLY", message: "Membership is requi
|
|
|
170
172
|
|
|
171
173
|
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
174
|
|
|
175
|
+
#### Application password-reset hook
|
|
176
|
+
|
|
177
|
+
Pass `onPasswordReset` in the mount's second argument to run an Effect after a password reset. Its `{ user }` argument follows Better Auth's callback; `BetterAuthPasswordReset` lives in `@shivaedev/identity/server/better-auth/PasswordReset.ts`. The callback reads the mounted request's services, or the mount's services for direct `auth.api` calls, so an application can invoke its grant-revocation service without capturing a runtime or the returned auth instance.
|
|
178
|
+
|
|
179
|
+
```ts
|
|
180
|
+
const authentication = (options: BetterAuthOptions) =>
|
|
181
|
+
betterAuthMount(options, {
|
|
182
|
+
onPasswordReset: ({ user }) => Effect.flatMap(SessionAdmission, ({ check }) => check(user.id)),
|
|
183
|
+
});
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
The native `emailAndPassword.onPasswordReset` callback runs first. An Effect failure with `BetterAuthHookError` fields reaches the caller as HTTP 403 with its code and message. This callback follows Better Auth's post-reset lifecycle; a failure does not undo the password change.
|
|
187
|
+
|
|
173
188
|
### Role assignments
|
|
174
189
|
|
|
175
190
|
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.
|
|
@@ -215,7 +230,7 @@ The seed only grants: removing an account from config does not restore its previ
|
|
|
215
230
|
|
|
216
231
|
### Administer signed-in sessions
|
|
217
232
|
|
|
218
|
-
Merge `Sessions` from `@shivaedev/identity/sessions.ts` into the application's RPC group and provide `sessionsHandlers` from `@shivaedev/identity/server/better-auth/sessionsHandlers.ts`. Install `permissionLayer(SessionsPermission
|
|
233
|
+
Merge `Sessions` from `@shivaedev/identity/sessions.ts` into the application's RPC group and provide `sessionsHandlers` from `@shivaedev/identity/server/better-auth/sessionsHandlers.ts`. Install `permissionLayer(SessionsPermission)` using `SessionsPermission` from `@shivaedev/identity/sessionPermissions.ts` and the mounted session policy. Supply the application's Effect `SqlClient`; the handlers use the default Better Auth PostgreSQL user and session tables.
|
|
219
234
|
|
|
220
235
|
Grant `ManageSessions` (`sessions.manage`) from `sessionPermissions.ts` to the roles that manage sessions. The starter grants it to admin and owner. Both operations use the same permission middleware and `Forbidden` refusal as the admin Users page. They require no Better Auth admin plugin.
|
|
221
236
|
|
|
@@ -228,6 +243,8 @@ Grant `ManageSessions` (`sessions.manage`) from `sessionPermissions.ts` to the r
|
|
|
228
243
|
For a Capacitor or similar WebView whose page is served from the app bundle, opt in with the auth host mount's `bearerSessions` option. It installs Better Auth's own `bearer({ requireSignature: true })` plugin from the existing dependency; do not add a second bearer plugin. The option is absent by default. List only bundled-client origins here, and include them in Better Auth's `trustedOrigins` as well.
|
|
229
244
|
|
|
230
245
|
```ts
|
|
246
|
+
import { Layer } from "effect";
|
|
247
|
+
import { SessionPolicy } from "@shivaedev/identity/server/SessionPolicy.ts";
|
|
231
248
|
const nativeOrigins = ["capacitor://localhost", "https://localhost"];
|
|
232
249
|
const mounted = yield* betterAuthMount(
|
|
233
250
|
{
|
|
@@ -238,10 +255,10 @@ const mounted = yield* betterAuthMount(
|
|
|
238
255
|
},
|
|
239
256
|
{ bearerSessions: { origins: nativeOrigins } },
|
|
240
257
|
);
|
|
241
|
-
const sessions = {
|
|
258
|
+
const sessions = Layer.succeed(SessionPolicy, {
|
|
242
259
|
origin: trustedOrigins({ allow: [publicOrigin, ...nativeOrigins], missing: "allow" }),
|
|
243
260
|
provider: mounted.admittedSessions((headers) => mounted.auth.api.getSession({ headers })),
|
|
244
|
-
};
|
|
261
|
+
});
|
|
245
262
|
const host = appHost({ group, handlers, routes: mounted.routes, sessions, nativeOrigins });
|
|
246
263
|
```
|
|
247
264
|
|
|
@@ -262,7 +279,8 @@ Use the WebView's own fetch with `credentials: "omit"` for incremental NDJSON ch
|
|
|
262
279
|
Give the mount a sign-in policy as its second argument, and resolve RPC sessions through `admittedSessions` so a removal ends access on the next request:
|
|
263
280
|
|
|
264
281
|
```ts
|
|
265
|
-
import {
|
|
282
|
+
import { SessionPolicy } from "@shivaedev/identity/server/SessionPolicy.ts";
|
|
283
|
+
import { Effect, Layer } from "effect";
|
|
266
284
|
import { allowedAccounts } from "@shivaedev/identity/server/better-auth/allowedAccounts.ts";
|
|
267
285
|
import { betterAuthDatabase } from "@shivaedev/identity/server/better-auth/adapters/database.ts";
|
|
268
286
|
import { betterAuthMount } from "@shivaedev/identity/server/better-auth/mount.ts";
|
|
@@ -275,10 +293,10 @@ const authentication = Effect.gen(function* () {
|
|
|
275
293
|
{ signIn: { accounts: allowedAccounts, recheckInterval: "5 minutes", rule: inOrganization } },
|
|
276
294
|
);
|
|
277
295
|
yield* mounted.revokeUnadmitted;
|
|
278
|
-
const sessions = {
|
|
296
|
+
const sessions = Layer.succeed(SessionPolicy, {
|
|
279
297
|
origin: trustedOrigins({ allow: ["https://app.example"], missing: "reject" }),
|
|
280
298
|
provider: mounted.admittedSessions((headers) => mounted.auth.api.getSession({ headers })),
|
|
281
|
-
};
|
|
299
|
+
});
|
|
282
300
|
return { ...mounted, sessions };
|
|
283
301
|
});
|
|
284
302
|
```
|
|
@@ -293,11 +311,11 @@ A removal takes effect on the user's next request through `admittedSessions`: th
|
|
|
293
311
|
|
|
294
312
|
`revokeUnadmitted` checks every stored user against the current policy, deletes the sessions of each user it no longer admits and succeeds with `{ users, sessions }`, the number of users and sessions it revoked. Run it at startup, as above, or from an administrative command. It fails with the rule's error or with a `ConfigError`.
|
|
295
313
|
|
|
296
|
-
Without `signIn`, the mount installs no sign-in policy hooks and `revokeUnadmitted` revokes nothing. `admittedSessions(lookup)` returns an Effect `SessionProvider`; use it
|
|
314
|
+
Without `signIn`, the mount installs no sign-in policy hooks and `revokeUnadmitted` revokes nothing. `admittedSessions(lookup)` returns an Effect `SessionProvider`; use it as the `provider` in the `SessionPolicy` Layer. Its policy check runs in the request fiber, preserving request spans, log annotations and interruption. `mounted.sessions` supplies this provider with the mount's roles and the default Better Auth lookup. Supply the application's Config provider to the server Layer so request-time account checks read the same configuration as startup.
|
|
297
315
|
|
|
298
316
|
### Once per feature: identity and typed refusals
|
|
299
317
|
|
|
300
|
-
Use `Authenticated` when the operation needs `Identity`, and `MaybeAuthenticated` with `maybeAuthenticatedLayer(
|
|
318
|
+
Use `Authenticated` when the operation needs `Identity`, and `MaybeAuthenticated` with `maybeAuthenticatedLayer()` when it reads `OptionalIdentity`:
|
|
301
319
|
|
|
302
320
|
```ts
|
|
303
321
|
import { Effect, Option, Schema } from "effect";
|
|
@@ -353,29 +371,31 @@ export const AccountHandlers = Account.toLayer({
|
|
|
353
371
|
Whoami: () => Effect.map(SessionUser, (user) => user),
|
|
354
372
|
});
|
|
355
373
|
|
|
356
|
-
export const AccountServer = Layer.merge(AccountHandlers, authenticatedUserLayer(
|
|
374
|
+
export const AccountServer = Layer.merge(AccountHandlers, authenticatedUserLayer());
|
|
357
375
|
```
|
|
358
376
|
|
|
359
|
-
Here `sessions` is the application's policy from the previous example, with a Better Auth lookup that returns all three user fields. Merge `authenticatedUserLayer(
|
|
377
|
+
Here `sessions` is the application's policy Layer from the previous example, with a Better Auth lookup that returns all three user fields. The host provides it once to middleware and routes; custom hosts provide it with `Layer.provide(sessions)`. Merge `authenticatedUserLayer()` alongside the handler Layer when using `appHost`; the host continues to supply its id-only and optional middleware. A missing session fails with typed `Unauthorized`; rejected origins fail with `Forbidden`, and provider failures remain `AuthUnavailable`. The profile contains id, name and email, plus an optional role when the provider supplies it, without exposing the rest of the provider's user record. Handlers do not query the provider's user table.
|
|
360
378
|
|
|
361
379
|
#### Reading provider account IDs
|
|
362
380
|
|
|
363
|
-
Pass Better Auth's account lookup as the second argument to the mount's `admittedSessions` to combine provider accounts with its sign-in policy and credential selection. Without a mount, `betterAuthSessions` accepts the same two lookups. Declare `AuthenticatedUserWithProviderAccounts` on account-reading RPCs and merge `authenticatedUserWithProviderAccountsLayer(
|
|
381
|
+
Pass Better Auth's account lookup as the second argument to the mount's `admittedSessions` to combine provider accounts with its sign-in policy and credential selection. Without a mount, `betterAuthSessions` accepts the same two lookups. Declare `AuthenticatedUserWithProviderAccounts` on account-reading RPCs and merge `authenticatedUserWithProviderAccountsLayer()` alongside their handlers. This boundary decodes the user profile and requires a `providerAccounts` Effect from the configured provider.
|
|
364
382
|
|
|
365
383
|
```ts
|
|
384
|
+
import { Layer } from "effect";
|
|
385
|
+
import { SessionPolicy } from "@shivaedev/identity/server/SessionPolicy.ts";
|
|
366
386
|
import { SessionUserWithProviderAccounts } from "@shivaedev/identity/identity.ts";
|
|
367
387
|
import { AuthenticatedUserWithProviderAccounts } from "@shivaedev/identity/middleware.ts";
|
|
368
388
|
import { AuthUnavailable, Unauthorized } from "@shivaedev/errors/taxonomy.ts";
|
|
369
389
|
import { authenticatedUserWithProviderAccountsLayer } from "@shivaedev/identity/server/session.ts";
|
|
370
390
|
|
|
371
|
-
const sessions = {
|
|
391
|
+
const sessions = Layer.succeed(SessionPolicy, {
|
|
372
392
|
origin: trustedOrigins({ allow: ["https://app.example"], missing: "reject" }),
|
|
373
393
|
...mounted.sessions,
|
|
374
394
|
provider: mounted.admittedSessions(
|
|
375
395
|
(headers) => mounted.auth.api.getSession({ headers }),
|
|
376
396
|
(headers) => mounted.auth.api.listUserAccounts({ headers }),
|
|
377
397
|
),
|
|
378
|
-
};
|
|
398
|
+
});
|
|
379
399
|
|
|
380
400
|
const githubAccount = Effect.gen(function* () {
|
|
381
401
|
const user = yield* SessionUserWithProviderAccounts;
|
|
@@ -407,6 +427,8 @@ The Effect returns an array of `{ id, name, image }`, with `image: null` when un
|
|
|
407
427
|
Declare application roles with `@shivaedev/access`. Each user row stores one declared role string. Supply the role set once through the existing auth configuration and reuse its returned session policy:
|
|
408
428
|
|
|
409
429
|
```ts
|
|
430
|
+
import { Layer } from "effect";
|
|
431
|
+
import { SessionPolicy } from "@shivaedev/identity/server/SessionPolicy.ts";
|
|
410
432
|
import { permission } from "@shivaedev/access/permission.ts";
|
|
411
433
|
import { role } from "@shivaedev/access/role.ts";
|
|
412
434
|
import { roleSet } from "@shivaedev/access/roleSet.ts";
|
|
@@ -415,11 +437,13 @@ import { betterAuthMount } from "@shivaedev/identity/server/better-auth/mount.ts
|
|
|
415
437
|
const UseTools = permission("tools.use");
|
|
416
438
|
const Access = roleSet(role("member", []), role("operator", [UseTools]));
|
|
417
439
|
const mounted = yield* betterAuthMount(authOptions, { defaultRole: "member", roles: Access });
|
|
418
|
-
const sessions = { ...mounted.sessions, origin: trustedOrigins({ allow: ["https://app.example.com"], missing: "reject" }) };
|
|
440
|
+
const sessions = Layer.succeed(SessionPolicy, { ...mounted.sessions, origin: trustedOrigins({ allow: ["https://app.example.com"], missing: "reject" }) });
|
|
419
441
|
```
|
|
420
442
|
|
|
421
443
|
For another session provider, put `roles: Access` alongside `provider` and `origin` in the host's existing `sessions` policy. The provider must read the current stored role on every invocation. `betterAuthMount`'s returned provider and its existing `/api/auth/get-session` endpoint bypass the cookie cache. That endpoint adds `user.permissions`, an array of `{ name, strength }` grants, and the request-local `SessionUser` exposes the same decoded role and grants. A missing or null stored role refuses access with `Forbidden` (HTTP 403 at the session endpoint) and logs the fix: generate and apply a frozen migration with `defaultRole`, then use `assignRole` for administrators. An undeclared non-null stored role fails as a defect naming that role. RPC request tracing logs it as a defect; `/api/auth/get-session` returns HTTP 500. Correct the stored role or restore its application declaration. Provider outages remain `AuthUnavailable`.
|
|
422
444
|
|
|
445
|
+
React's `authSession` reads the session's grants as typed values while preserving the provider's session and user data. Applications using it need no session permission decoder.
|
|
446
|
+
|
|
423
447
|
### Frozen auth migrations
|
|
424
448
|
|
|
425
449
|
Generate each auth migration once, review its SQL and commit the generated module. `generateBetterAuthMigration(options, roleOptions?)` reads the current PostgreSQL schema through `SqlClient` and returns a TypeScript migration module. It does not apply the migration. The module imports only native Effect and executes fixed SQL on the migrator's transaction connection. Later auth option changes and Better Auth upgrades cannot change its SQL.
|
|
@@ -493,13 +517,13 @@ import { permissionLayer } from "@shivaedev/identity/server/permissions.ts";
|
|
|
493
517
|
class ToolsPermission extends permissionMiddleware<ToolsPermission>()("app/ToolsPermission", UseTools) {}
|
|
494
518
|
const Tools = RpcGroup.make(Rpc.make("tools", { success: Schema.String }).middleware(ToolsPermission));
|
|
495
519
|
const handlers = Tools.toLayer({ tools: () => Effect.map(SessionUser, (user) => user.email) }).pipe(
|
|
496
|
-
Layer.provideMerge(permissionLayer(ToolsPermission
|
|
520
|
+
Layer.provideMerge(permissionLayer(ToolsPermission)),
|
|
497
521
|
);
|
|
498
522
|
```
|
|
499
523
|
|
|
500
524
|
The middleware resolves and checks the session on every request before invoking the handler. It provides `Identity` and `SessionUser`, rejects signed-out callers with `Unauthorized`, and rejects missing grants with `Forbidden` in its declared error channel. Access evaluates an exact permission name: an `any` grant covers an `own` check, while an `own` grant does not cover an `any` check. Open streams recheck their required permission at the session revalidation interval and end with `Forbidden` after its removal.
|
|
501
525
|
|
|
502
|
-
For HTTP routes, use `permissionRoute(
|
|
526
|
+
For HTTP routes, use `permissionRoute(UseTools)` around the handler. It uses the same transport session and Origin policy, returns 401 for missing sessions, 403 for missing grants or refused Origins, and 503 for `AuthUnavailable`. Those rejections carry `Cache-Control: private, no-store`. The handler's response and typed failures pass through unchanged.
|
|
503
527
|
|
|
504
528
|
```ts
|
|
505
529
|
import { HttpRouter, HttpServerResponse } from "effect/http";
|
|
@@ -509,7 +533,7 @@ const routes = HttpRouter.use((router) =>
|
|
|
509
533
|
router.add(
|
|
510
534
|
"GET",
|
|
511
535
|
"/tools",
|
|
512
|
-
permissionRoute(
|
|
536
|
+
permissionRoute(UseTools)(() => Effect.map(SessionUser, (user) => HttpServerResponse.text(user.email))),
|
|
513
537
|
),
|
|
514
538
|
);
|
|
515
539
|
```
|
|
@@ -567,14 +591,16 @@ const authentication = Layer.succeed(MyAuthentication, (effect, { headers, rpc,
|
|
|
567
591
|
|
|
568
592
|
`authenticatedLayer`, `authenticatedUserLayer`, `authenticatedUserWithProviderAccountsLayer`, the role layers and signed-in `maybeAuthenticatedLayer` calls revalidate live RPC streams every 30 seconds by default, using the original transport headers. A signed-out, revoked or expired session ends the stream with `Unauthorized`, including an idle stream and a subscription receiving a change hint. A signed-in viewer whose query read policy now refuses ends the subscription with `QueryReadDenied`. Session intervals use Effect’s Clock, so advancing `TestClock` drives revalidation; batched session lookups do not need another clock advance. With a session store that reflects sign-out immediately, delivery can continue for up to that interval plus the session lookup time after sign-out. Provider cookie caching or secondary storage can add their own delay; keep Better Auth's cookie cache disabled for database-backed revocation.
|
|
569
593
|
|
|
570
|
-
Set `
|
|
594
|
+
Set `streamRevalidationInterval` in the `SessionPolicy` Layer to an Effect `Duration.Input` to change the interval for middleware using that policy:
|
|
571
595
|
|
|
572
596
|
```ts
|
|
573
|
-
|
|
597
|
+
import { Layer } from "effect";
|
|
598
|
+
import { SessionPolicy } from "@shivaedev/identity/server/SessionPolicy.ts";
|
|
599
|
+
const sessions = Layer.succeed(SessionPolicy, {
|
|
574
600
|
origin: trustedOrigins({ allow: ["https://app.example.com"], missing: "reject" }),
|
|
575
601
|
provider: betterAuthSessions((headers) => auth.api.getSession({ headers })),
|
|
576
602
|
streamRevalidationInterval: "5 seconds",
|
|
577
|
-
};
|
|
603
|
+
});
|
|
578
604
|
```
|
|
579
605
|
|
|
580
606
|
An `AuthUnavailable` failure during revalidation ends the stream with `AuthUnavailable`. Initial session lookup failures also reject the subscription. Unary calls resolve their session once per call. `MaybeAuthenticated` streams that start anonymous continue without a session monitor; a signed-in optional stream ends with `Unauthorized` when its session is removed. Callers can subscribe again to continue anonymously.
|
|
@@ -679,6 +705,32 @@ app.it("the member's provider account stores no credentials", [member], function
|
|
|
679
705
|
|
|
680
706
|
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.
|
|
681
707
|
|
|
708
|
+
### Deliver typed auth emails
|
|
709
|
+
|
|
710
|
+
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.
|
|
711
|
+
|
|
712
|
+
```ts
|
|
713
|
+
const mounted = yield* betterAuthMount(options, {
|
|
714
|
+
emails: {
|
|
715
|
+
routes: {
|
|
716
|
+
ConfirmAccount: "https://app.example/confirm-account",
|
|
717
|
+
ApproveEmailChange: "https://app.example/approve-email-change",
|
|
718
|
+
ConfirmNewAddress: "https://app.example/confirm-new-address",
|
|
719
|
+
ResetPassword: "https://app.example/reset-password",
|
|
720
|
+
AccountAlreadyExists: "https://app.example/sign-in",
|
|
721
|
+
},
|
|
722
|
+
deliver: (message) => mailer.deliver(message),
|
|
723
|
+
window: "1 minute",
|
|
724
|
+
},
|
|
725
|
+
});
|
|
726
|
+
```
|
|
727
|
+
|
|
728
|
+
`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.
|
|
729
|
+
|
|
730
|
+
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`.
|
|
731
|
+
|
|
732
|
+
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.
|
|
733
|
+
|
|
682
734
|
### Sweep expired sessions in a worker
|
|
683
735
|
|
|
684
736
|
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.
|
|
@@ -689,38 +741,39 @@ Register the Effect with a worker schedule, as the starter does at midnight UTC.
|
|
|
689
741
|
|
|
690
742
|
Import the module that defines the name; there is no package-root entry. Paths below follow `@shivaedev/identity/`.
|
|
691
743
|
|
|
692
|
-
| Module | Names and purpose
|
|
693
|
-
| -------------------------------------------- |
|
|
694
|
-
| `identity.ts` | `RequestId`, `Identity`, `OptionalIdentity`, `SessionUser`, `SessionUserWithProviderAccounts`, `SessionUserSchema`: request-local services and the shared user schema.
|
|
695
|
-
| `middleware.ts` | `RequestTracing`, `Authenticated`, `AuthenticatedUser`, `AuthenticatedUserWithProviderAccounts`, `MaybeAuthenticated`, `IdentityFailures`: native RPC middleware declarations and their shared failure schema.
|
|
696
|
-
| `server/providerFailure.ts` | `providerFailure(cause)`: log a redacted provider failure and fail with `AuthUnavailable`.
|
|
697
|
-
| `permission.ts` | `permissionMiddleware`, `hasPermission`: native permission middleware declarations and predicates over resolved grants.
|
|
698
|
-
| `server/permissions.ts` | `permissionLayer`, `permissionRoute`: permission middleware Layers and HTTP route guards.
|
|
699
|
-
| `server/session.ts` | `authenticatedLayer`, `maybeAuthenticatedLayer`, `authenticatedUserLayer`, `authenticatedUserWithProviderAccountsLayer`, `withSessionUser`, `resolveSession`: session middleware implementations and the identity boundary.
|
|
700
|
-
| `server/adapters/betterAuthSessions.ts` | `betterAuthSessions(getSession, getProviderAccounts?)`: a session provider from Better Auth lookups.
|
|
701
|
-
| `server/origin.ts` | `trustedOrigins({ allow, missing })`: an exact Origin allowlist.
|
|
702
|
-
| `server/local.ts` | `localRpcGuard`, `loopbackOnly`, `sameOrigin`, `trustedProxyPeer`: loopback and proxy guards.
|
|
703
|
-
| `server/trustedProxyRanges.ts` | `trustedProxyRanges(trustedProxy?)`: normalized proxy ranges.
|
|
704
|
-
| `server/proxyRanges.ts` | `proxyRanges(value)`: parse configured proxy ranges.
|
|
705
|
-
| `server/transportHeaders.ts` | `transportHeaders(rpcHeaders)`: the headers used for a transport-level decision.
|
|
706
|
-
| `server/tracing.ts` | `requestTracingLayer({ header?, sensitive? })`: the `RequestTracing` implementation.
|
|
707
|
-
| `server/sessionKeys.ts` | `resolveChanges`: session-scoped change subscriptions for custom change handlers.
|
|
708
|
-
| `server/commandChanges.ts` | `commandChanges(effect, rpc, payload)`: scoped command invalidation for custom authentication middleware.
|
|
709
|
-
| `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.
|
|
710
|
-
| `server/better-auth/adapters/database.ts` | `betterAuthDatabase()`: Better Auth storage on the application PostgreSQL client.
|
|
711
|
-
| `server/better-auth/
|
|
712
|
-
| `server/better-auth/
|
|
713
|
-
| `server/better-auth/
|
|
714
|
-
| `server/better-auth/
|
|
715
|
-
| `server/better-auth/
|
|
716
|
-
| `server/better-auth/
|
|
717
|
-
| `server/better-auth/
|
|
718
|
-
| `server/better-auth/
|
|
719
|
-
| `server/better-auth/
|
|
744
|
+
| Module | Names and purpose |
|
|
745
|
+
| -------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
746
|
+
| `identity.ts` | `RequestId`, `Identity`, `OptionalIdentity`, `SessionUser`, `SessionUserWithProviderAccounts`, `SessionUserSchema`: request-local services and the shared user schema. |
|
|
747
|
+
| `middleware.ts` | `RequestTracing`, `Authenticated`, `AuthenticatedUser`, `AuthenticatedUserWithProviderAccounts`, `MaybeAuthenticated`, `IdentityFailures`: native RPC middleware declarations and their shared failure schema. |
|
|
748
|
+
| `server/providerFailure.ts` | `providerFailure(cause)`: log a redacted provider failure and fail with `AuthUnavailable`. |
|
|
749
|
+
| `permission.ts` | `permissionMiddleware`, `hasPermission`: native permission middleware declarations and predicates over resolved grants. |
|
|
750
|
+
| `server/permissions.ts` | `permissionLayer`, `permissionRoute`: permission middleware Layers and HTTP route guards. |
|
|
751
|
+
| `server/session.ts` | `authenticatedLayer`, `maybeAuthenticatedLayer`, `authenticatedUserLayer`, `authenticatedUserWithProviderAccountsLayer`, `withSessionUser`, `resolveSession`: session middleware implementations and the identity boundary. |
|
|
752
|
+
| `server/adapters/betterAuthSessions.ts` | `betterAuthSessions(getSession, getProviderAccounts?)`: a session provider from Better Auth lookups. |
|
|
753
|
+
| `server/origin.ts` | `trustedOrigins({ allow, missing })`: an exact Origin allowlist. |
|
|
754
|
+
| `server/local.ts` | `localRpcGuard`, `loopbackOnly`, `sameOrigin`, `trustedProxyPeer`: loopback and proxy guards. |
|
|
755
|
+
| `server/trustedProxyRanges.ts` | `trustedProxyRanges(trustedProxy?)`: normalized proxy ranges. |
|
|
756
|
+
| `server/proxyRanges.ts` | `proxyRanges(value)`: parse configured proxy ranges. |
|
|
757
|
+
| `server/transportHeaders.ts` | `transportHeaders(rpcHeaders)`: the headers used for a transport-level decision. |
|
|
758
|
+
| `server/tracing.ts` | `requestTracingLayer({ header?, sensitive? })`: the `RequestTracing` implementation. |
|
|
759
|
+
| `server/sessionKeys.ts` | `resolveChanges`: session-scoped change subscriptions for custom change handlers. |
|
|
760
|
+
| `server/commandChanges.ts` | `commandChanges(effect, rpc, payload)`: scoped command invalidation for custom authentication middleware. |
|
|
761
|
+
| `server/better-auth/mount.ts` | `betterAuthMount(options, { emails?, onPasswordReset?, signIn?, bearerSessions?, roles?, defaultRole?, roleSeed? })`, returning `{ auth, routes, sessions, admittedSessions, revokeUnadmitted }`: native auth routes and the sign-in policy. |
|
|
762
|
+
| `server/better-auth/adapters/database.ts` | `betterAuthDatabase()`: Better Auth storage on the application PostgreSQL client. |
|
|
763
|
+
| `server/better-auth/emails.ts` | `AuthEmail`, `BetterAuthEmails`: typed delivery messages, app routes and per-account delivery windows for the mount. |
|
|
764
|
+
| `server/better-auth/allowedAccounts.ts` | `ProviderAccounts`, `AllowedAccounts`, `allowedAccounts`: provider-account list Schemas and the non-empty `AUTH_ALLOWED_ACCOUNTS` Config. |
|
|
765
|
+
| `server/better-auth/accountRoleSeed.ts` | `accountRoleSeed(access, role, accounts)`: grant a configured role at boot and sign-in through `assignRole`. |
|
|
766
|
+
| `server/better-auth/signInGate.ts` | `SignInPolicy`: the `accounts`, `rule` and `recheckInterval` of a sign-in policy. |
|
|
767
|
+
| `server/better-auth/revokeUnadmitted.ts` | `RevokedSessions`: the `{ users, sessions }` counts of a revocation. |
|
|
768
|
+
| `server/better-auth/userProfiles.ts` | Public profile lookups for other users. |
|
|
769
|
+
| `server/better-auth/sweepExpiredSessions.ts` | `sweepExpiredSessions`: delete expired sessions through the application's SQL client and return the number removed. |
|
|
770
|
+
| `server/better-auth/userReference.ts` | `userReference`: the default auth user table and id column for application foreign keys. |
|
|
771
|
+
| `server/better-auth/testDatabase.ts` | `authTestDatabase`: test-only identity/session readouts and faults for the default PostgreSQL auth schema. |
|
|
772
|
+
| `server/better-auth/testing.ts` | `signedInUser(auth, fields)`, `passwordUser(auth, fields)`, `storedProviderAccounts(auth, userId)`: test-only users, minted sessions and credential storage observations. |
|
|
720
773
|
|
|
721
774
|
### Install, setup and limits
|
|
722
775
|
|
|
723
|
-
Install `@shivaedev/identity` with `effect` as its peer. Everything outside `server/better-auth/` works with only `effect` installed, including the Promise-based `betterAuthSessions` adapter. Better Auth mounts and test fixtures need the optional peer `better-auth` and the application’s PostgreSQL `SqlClient`; `sweepExpiredSessions` needs only the application's Effect SQL client. Browser code imports
|
|
776
|
+
Install `@shivaedev/identity` with `effect` as its peer. Everything outside `server/better-auth/` works with only `effect` installed, including the Promise-based `betterAuthSessions` adapter. Better Auth mounts and test fixtures need the optional peer `better-auth` and the application’s PostgreSQL `SqlClient`; `sweepExpiredSessions` needs only the application's Effect SQL client. Browser code imports `identity.ts`, `middleware.ts` and `permission.ts`.
|
|
724
777
|
- The package needs Node 24 or newer.
|
|
725
778
|
- Keep the auth provider's configuration, cookie settings and resource authorization in the application. The session adapter takes a session lookup and an optional provider-account lookup and returns a session result; it does not write provider refresh cookies into RPC responses.
|
|
726
779
|
- Without an `HttpServerRequest`, `transportHeaders` falls back to the supplied RPC headers. An application using another transport must decide what headers it can trust.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Context, type Duration } from "effect";
|
|
2
|
+
import type { RoleSet } from "@shivaedev/access/roleSet.ts";
|
|
3
|
+
import type { OriginPolicy } from "./origin.ts";
|
|
4
|
+
import type { SessionProvider, SessionShape } from "./session.ts";
|
|
5
|
+
declare const SessionPolicy_base: Context.ServiceClass<SessionPolicy, "@shivaedev/identity/SessionPolicy", {
|
|
6
|
+
readonly origin: OriginPolicy;
|
|
7
|
+
readonly provider: SessionProvider<SessionShape>;
|
|
8
|
+
readonly roles?: RoleSet;
|
|
9
|
+
readonly streamRevalidationInterval?: Duration.Input | undefined;
|
|
10
|
+
}>;
|
|
11
|
+
export declare class SessionPolicy extends SessionPolicy_base {
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=SessionPolicy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SessionPolicy.d.ts","sourceRoot":"","sources":["../../src/server/SessionPolicy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;;qBAK/C,YAAY;uBACV,eAAe,CAAC,YAAY,CAAC;qBAC/B,OAAO;0CACc,QAAQ,CAAC,KAAK,GAAG,SAAS;;AANlE,qBAAa,aAAc,SAAQ,kBAQK;CAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SessionPolicy.js","sourceRoot":"","sources":["../../src/server/SessionPolicy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAiB,MAAM,QAAQ,CAAC;AAKhD,MAAM,OAAO,aAAc,SAAQ,OAAO,CAAC,OAAO,EAQ/C,CAAC,mCAAmC,CAAC;CAAG"}
|
|
@@ -4,7 +4,7 @@ import { Unauthorized } from "@shivaedev/errors/taxonomy.ts";
|
|
|
4
4
|
import { providerFailure } from "#server/providerFailure.ts";
|
|
5
5
|
const ExpiringSession = Schema.Struct({ session: Schema.Struct({ expiresAt: Schema.Date }) });
|
|
6
6
|
export function betterAuthSessions(getSession, getProviderAccounts) {
|
|
7
|
-
const betterAuthSession = Effect.fn("
|
|
7
|
+
const betterAuthSession = Effect.fn("Identity.betterAuthSession")(function* (headers) {
|
|
8
8
|
const transport = new globalThis.Headers(headers);
|
|
9
9
|
const session = yield* Effect.tryPromise(() => getSession(transport)).pipe(Effect.catch((error) => providerFailure(error.cause)));
|
|
10
10
|
if (Schema.is(ExpiringSession)(session) && session.session.expiresAt.getTime() <= (yield* Clock.currentTimeMillis)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"betterAuthSessions.js","sourceRoot":"","sources":["../../../src/server/adapters/betterAuthSessions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAElE,OAAO,KAAK,UAAU,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAwB,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAEnF,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAG7D,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;AAY9F,MAAM,UAAU,kBAAkB,CAAgC,UAAgC,EAAE,mBAAyC;IAC5I,MAAM,iBAAiB,GAAG,MAAM,CAAC,EAAE,CAAC
|
|
1
|
+
{"version":3,"file":"betterAuthSessions.js","sourceRoot":"","sources":["../../../src/server/adapters/betterAuthSessions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAElE,OAAO,KAAK,UAAU,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAwB,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAEnF,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAG7D,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;AAY9F,MAAM,UAAU,kBAAkB,CAAgC,UAAgC,EAAE,mBAAyC;IAC5I,MAAM,iBAAiB,GAAG,MAAM,CAAC,EAAE,CAAC,4BAA4B,CAAC,CAAC,QAAQ,CAAC,EAAE,OAAwB;QACpG,MAAM,SAAS,GAAG,IAAI,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAClD,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,eAAe,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAClI,IAAI,MAAM,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC,EAAE,CAAC;YACpH,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;QACtB,CAAC;QACD,IAAI,OAAO,KAAK,IAAI,IAAI,mBAAmB,KAAK,SAAS,EAAE,CAAC;YAC3D,OAAO,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QACtC,CAAC;QACD,MAAM,gBAAgB,GAAG,MAAM,CAAC,UAAU,CAAC;YAC1C,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK;YACvB,GAAG,EAAE,GAAG,EAAE,CAAC,mBAAmB,CAAC,SAAS,CAAC;SACzC,CAAC,CAAC,IAAI,CACN,MAAM,CAAC,KAAK,CACX,CAAC,KAAK,EAAwD,EAAE,CAC/D,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,YAAY,CAAC,IAAI,KAAK,CAAC,UAAU,KAAK,UAAU,CAAC,WAAW,CAAC,cAAc,CAAC;YACxG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,YAAY,CAAC,EAAE,OAAO,EAAE,yBAAyB,EAAE,CAAC,CAAC;YACvE,CAAC,CAAC,eAAe,CAAC,KAAK,CAAC,CAC1B,CACD,CAAC;QACF,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,GAAG,OAAO,EAAE,IAAI,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,EAAE,gBAAgB,EAAE,EAAE,CAAC,CAAC;IACjF,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,GAAG,EAAE,iBAAiB,EAAE,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { BetterAuthOptions } from "better-auth";
|
|
2
|
+
import type { Effect } from "effect";
|
|
3
|
+
import type { BetterAuthHookError } from "./databaseHooks.ts";
|
|
4
|
+
type NativePasswordReset = NonNullable<NonNullable<BetterAuthOptions["emailAndPassword"]>["onPasswordReset"]>;
|
|
5
|
+
export type BetterAuthPasswordReset<R = never> = (data: Parameters<NativePasswordReset>[0]) => Effect.Effect<void, BetterAuthHookError, R>;
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=PasswordReset.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PasswordReset.d.ts","sourceRoot":"","sources":["../../../src/server/better-auth/PasswordReset.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,KAAK,mBAAmB,GAAG,WAAW,CAAC,WAAW,CAAC,iBAAiB,CAAC,kBAAkB,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC;AAE9G,MAAM,MAAM,uBAAuB,CAAC,CAAC,GAAG,KAAK,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,mBAAmB,EAAE,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PasswordReset.js","sourceRoot":"","sources":["../../../src/server/better-auth/PasswordReset.ts"],"names":[],"mappings":""}
|
|
@@ -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":"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"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { BetterAuthOptions } from "better-auth";
|
|
2
|
+
import type { Effect } from "effect";
|
|
3
|
+
import type { BetterAuthPasswordReset } from "#server/better-auth/PasswordReset.ts";
|
|
4
|
+
import type { hookRuntime } from "./hookRuntime.ts";
|
|
5
|
+
export declare function passwordResetOptions<TOptions extends BetterAuthOptions, R>(options: TOptions, hook: BetterAuthPasswordReset<R> | undefined, runtime: Effect.Success<ReturnType<typeof hookRuntime<R>>>): TOptions;
|
|
6
|
+
//# sourceMappingURL=passwordResetOptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"passwordResetOptions.d.ts","sourceRoot":"","sources":["../../../../src/server/better-auth/adapters/passwordResetOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AACpF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,wBAAgB,oBAAoB,CAAC,QAAQ,SAAS,iBAAiB,EAAE,CAAC,EACzE,OAAO,EAAE,QAAQ,EACjB,IAAI,EAAE,uBAAuB,CAAC,CAAC,CAAC,GAAG,SAAS,EAC5C,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,GACxD,QAAQ,CAeV"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export function passwordResetOptions(options, hook, runtime) {
|
|
2
|
+
if (hook === undefined) {
|
|
3
|
+
return options;
|
|
4
|
+
}
|
|
5
|
+
return {
|
|
6
|
+
...options,
|
|
7
|
+
emailAndPassword: {
|
|
8
|
+
...options.emailAndPassword,
|
|
9
|
+
enabled: options.emailAndPassword?.enabled ?? false,
|
|
10
|
+
onPasswordReset: async (data, request) => {
|
|
11
|
+
await options.emailAndPassword?.onPasswordReset?.(data, request);
|
|
12
|
+
await runtime.runHook(() => hook(data), request?.signal);
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=passwordResetOptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"passwordResetOptions.js","sourceRoot":"","sources":["../../../../src/server/better-auth/adapters/passwordResetOptions.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,oBAAoB,CACnC,OAAiB,EACjB,IAA4C,EAC5C,OAA0D;IAE1D,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,OAAO,CAAC;IAChB,CAAC;IACD,OAAO;QACN,GAAG,OAAO;QACV,gBAAgB,EAAE;YACjB,GAAG,OAAO,CAAC,gBAAgB;YAC3B,OAAO,EAAE,OAAO,CAAC,gBAAgB,EAAE,OAAO,IAAI,KAAK;YACnD,eAAe,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE;gBACxC,MAAM,OAAO,CAAC,gBAAgB,EAAE,eAAe,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;gBACjE,MAAM,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;YAC1D,CAAC;SACD;KACD,CAAC;AACH,CAAC"}
|
|
@@ -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"}
|