@shivaedev/identity 0.24.0 → 0.26.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 +68 -2
- package/dist/accountPreferences.d.ts +27 -27
- package/dist/accountPreferences.d.ts.map +1 -1
- package/dist/server/UserProvisioning.d.ts +15 -0
- package/dist/server/UserProvisioning.d.ts.map +1 -0
- package/dist/server/UserProvisioning.js +4 -0
- package/dist/server/UserProvisioning.js.map +1 -0
- package/dist/server/account-export/check.d.ts +15 -0
- package/dist/server/account-export/check.d.ts.map +1 -0
- package/dist/server/account-export/check.js +33 -0
- package/dist/server/account-export/check.js.map +1 -0
- package/dist/server/accountExport.d.ts +14 -0
- package/dist/server/accountExport.d.ts.map +1 -0
- package/dist/server/accountExport.js +15 -0
- package/dist/server/accountExport.js.map +1 -0
- package/dist/server/better-auth/adapters/SeedOptions.d.ts +14 -0
- package/dist/server/better-auth/adapters/SeedOptions.d.ts.map +1 -0
- package/dist/server/better-auth/adapters/SeedOptions.js +2 -0
- package/dist/server/better-auth/adapters/SeedOptions.js.map +1 -0
- package/dist/server/better-auth/adapters/acquire.d.ts +37 -1
- package/dist/server/better-auth/adapters/acquire.d.ts.map +1 -1
- package/dist/server/better-auth/adapters/acquire.js +4 -1
- package/dist/server/better-auth/adapters/acquire.js.map +1 -1
- package/dist/server/better-auth/adapters/assertSeedDatabase.d.ts +10 -0
- package/dist/server/better-auth/adapters/assertSeedDatabase.d.ts.map +1 -0
- package/dist/server/better-auth/adapters/assertSeedDatabase.js +12 -0
- package/dist/server/better-auth/adapters/assertSeedDatabase.js.map +1 -0
- package/dist/server/better-auth/adapters/defineSeed.d.ts +4 -0
- package/dist/server/better-auth/adapters/defineSeed.d.ts.map +1 -0
- package/dist/server/better-auth/adapters/defineSeed.js +19 -0
- package/dist/server/better-auth/adapters/defineSeed.js.map +1 -0
- package/dist/server/better-auth/adapters/emailOptions.d.ts.map +1 -1
- package/dist/server/better-auth/adapters/emailOptions.js +19 -8
- package/dist/server/better-auth/adapters/emailOptions.js.map +1 -1
- package/dist/server/better-auth/adapters/mount.d.ts +37 -0
- package/dist/server/better-auth/adapters/mount.d.ts.map +1 -1
- package/dist/server/better-auth/adapters/mount.js +1 -1
- package/dist/server/better-auth/adapters/mount.js.map +1 -1
- package/dist/server/better-auth/adapters/mountSettings.d.ts +1 -1
- package/dist/server/better-auth/adapters/mountSettings.d.ts.map +1 -1
- package/dist/server/better-auth/adapters/mountSettings.js +2 -2
- package/dist/server/better-auth/adapters/mountSettings.js.map +1 -1
- package/dist/server/better-auth/adapters/userDataExport.d.ts +38 -0
- package/dist/server/better-auth/adapters/userDataExport.d.ts.map +1 -0
- package/dist/server/better-auth/adapters/userDataExport.js +55 -0
- package/dist/server/better-auth/adapters/userDataExport.js.map +1 -0
- package/dist/server/better-auth/adapters/userProvisioning.d.ts +9 -0
- package/dist/server/better-auth/adapters/userProvisioning.d.ts.map +1 -0
- package/dist/server/better-auth/adapters/userProvisioning.js +22 -0
- package/dist/server/better-auth/adapters/userProvisioning.js.map +1 -0
- package/dist/server/better-auth/emails.d.ts +1 -0
- package/dist/server/better-auth/emails.d.ts.map +1 -1
- package/dist/server/better-auth/seedUsers.d.ts +6 -0
- package/dist/server/better-auth/seedUsers.d.ts.map +1 -0
- package/dist/server/better-auth/seedUsers.js +15 -0
- package/dist/server/better-auth/seedUsers.js.map +1 -0
- package/dist/server/better-auth/testDatabase.d.ts.map +1 -1
- package/dist/server/better-auth/testDatabase.js +4 -1
- package/dist/server/better-auth/testDatabase.js.map +1 -1
- package/dist/server/userDataExport.d.ts +13 -0
- package/dist/server/userDataExport.d.ts.map +1 -0
- package/dist/server/userDataExport.js +2 -0
- package/dist/server/userDataExport.js.map +1 -0
- package/dist/sessions.d.ts +4 -4
- package/dist/sessions.d.ts.map +1 -1
- package/package.json +18 -18
- package/src/server/UserProvisioning.ts +16 -0
- package/src/server/account-export/check.ts +38 -0
- package/src/server/accountExport.ts +40 -0
- package/src/server/better-auth/adapters/SeedOptions.ts +12 -0
- package/src/server/better-auth/adapters/acquire.ts +4 -1
- package/src/server/better-auth/adapters/assertSeedDatabase.ts +15 -0
- package/src/server/better-auth/adapters/defineSeed.ts +23 -0
- package/src/server/better-auth/adapters/emailOptions.ts +27 -8
- package/src/server/better-auth/adapters/mount.ts +2 -1
- package/src/server/better-auth/adapters/mountSettings.ts +3 -2
- package/src/server/better-auth/adapters/userDataExport.ts +57 -0
- package/src/server/better-auth/adapters/userProvisioning.ts +25 -0
- package/src/server/better-auth/emails.ts +1 -0
- package/src/server/better-auth/seedUsers.ts +21 -0
- package/src/server/better-auth/testDatabase.ts +4 -3
- package/src/server/userDataExport.ts +15 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.26.0 - 2026-11-04
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- `betterAuthMount` accepts `{ clientIp: "railway" }` to select `X-Real-IP` for session addresses and auth rate limiting, ignoring `X-Forwarded-For` and overriding `AUTH_CLIENT_IP_HEADER`. Forwarded addresses still require a peer allowed by `TRUSTED_PROXY`; otherwise, or without `X-Real-IP`, the connection address is used.
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
- Require Effect 4.0.7 and its matching companion packages. Install the 4.0.7 Effect stack together.
|
|
12
|
+
|
|
13
|
+
## 0.25.0 - 2026-11-04
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
- Auth emails accept per-kind `windows` overrides, falling back to the existing `window` and its one-minute default.
|
|
18
|
+
- Declare local demo personas with `defineSeed`: find or create password users, assign their application roles and run an Effect as each user. Non-local database URLs are refused before connecting.
|
|
19
|
+
- Provision password users through `UserProvisioning` and `betterAuthUserProvisioning`, reusing accounts by email without replacing their profile or password.
|
|
20
|
+
- Compose domain-owned user data export registrations into one typed account export. Check PostgreSQL foreign keys before exporting and report user-referencing tables that have no registration.
|
|
21
|
+
- Register Better Auth profile, linked-account and session data for export without passwords or authentication tokens.
|
|
22
|
+
|
|
23
|
+
### Fixed
|
|
24
|
+
|
|
25
|
+
- Preserve Better Auth email continuations in the app link's `callbackURL`, accepting only continuations on the configured app route's origin.
|
|
26
|
+
- Expire auth test sessions relative to the Effect clock so controlled-clock stories agree with session sweeps and the auth provider.
|
|
27
|
+
- Enable native Better Auth database joins by default so interrupted session lookups release PostgreSQL queries without fallback join console errors or account ids. Explicit `advanced.database.joins` options still take precedence.
|
|
28
|
+
|
|
3
29
|
## 0.24.0 - 2026-11-04
|
|
4
30
|
|
|
5
31
|
### Added
|
package/README.md
CHANGED
|
@@ -184,6 +184,8 @@ const authentication = Effect.gen(function* () {
|
|
|
184
184
|
|
|
185
185
|
`betterAuthDatabase()` reads the application’s `SqlClient` and reserves connections from its PostgreSQL pool. Build it inside `appHost`’s `application` Effect, or provide sql’s `postgresLayer` for a standalone process. Set `maxConnections` and `applicationName` on the application SQL Layer. The mount does not run migrations or require identity's migration history. Use frozen numbered auth migrations as described below, or keep an existing migrator during the transition described in [Auth tables owned by another migrator](#auth-tables-owned-by-another-migrator). The application SQL Layer owns shutdown.
|
|
186
186
|
|
|
187
|
+
`betterAuthMount` enables Better Auth's native database joins by default. Session lookups through the Effect provider and mounted HTTP routes cancel their PostgreSQL queries quietly when interrupted, including when the user table is locked. This avoids Better Auth's fallback join error output and account ids in the console. An explicit `advanced.database.joins` option overrides the default.
|
|
188
|
+
|
|
187
189
|
The adapter captures the SQL transaction at creation. An adapter created at startup does not join a later `transact` around an `auth.api` call: its auth writes commit independently and survive the application's rollback. For a shared boundary, create the adapter inside `transact`, and use it only within that transaction. Create the mount there too when its Effect hooks must share the application transaction:
|
|
188
190
|
|
|
189
191
|
```ts
|
|
@@ -226,6 +228,12 @@ Password resets revoke existing sessions by default. Set `emailAndPassword.revok
|
|
|
226
228
|
|
|
227
229
|
`TRUSTED_PROXY` supplies the same address and CIDR policy used by the host. An untrusted transport peer loses `x-forwarded-for` and the configured client-IP header before Better Auth sees the request. `AUTH_CLIENT_IP_HEADER` defaults to `x-forwarded-for`. Without a trusted proxy, auth rate limiting uses the connection peer address, so different peers have separate buckets and Better Auth receives a client IP without a missing-IP warning. A trusted peer's configured forwarded header takes precedence over the peer address.
|
|
228
230
|
|
|
231
|
+
On Railway, pass `{ clientIp: "railway" }` as the second argument to `betterAuthMount` and set `TRUSTED_PROXY=100.64.0.0/10`. The preset selects Railway's edge-written `X-Real-IP` for session addresses and auth rate limiting, ignoring client-sent `X-Forwarded-For` even when `AUTH_CLIENT_IP_HEADER` selects that header. Proxy trust still applies: an untrusted peer or a trusted peer without `X-Real-IP` uses its connection address.
|
|
232
|
+
|
|
233
|
+
```ts
|
|
234
|
+
const mounted = yield* betterAuthMount(authOptions, { clientIp: "railway" });
|
|
235
|
+
```
|
|
236
|
+
|
|
229
237
|
The auth HTTP server span records the resolved rate-limit address in `auth.rate_limit.address` and its source in `auth.rate_limit.address_source`: `forwarded` for the trusted proxy's configured header, or `peer` for the connection address. These attributes accompany counted sign-in attempts and HTTP 429 refusals, so operators can inspect the choice directly. The recorded address follows Better Auth's normalization, including IPv6 subnet grouping; a trusted peer without a forwarded header records `peer`.
|
|
230
238
|
|
|
231
239
|
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.
|
|
@@ -280,6 +288,33 @@ const authentication = (options: BetterAuthOptions) =>
|
|
|
280
288
|
|
|
281
289
|
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.
|
|
282
290
|
|
|
291
|
+
### Seed local demo users
|
|
292
|
+
|
|
293
|
+
`defineSeed` builds the PostgreSQL and Better Auth layers from `DATABASE_URL`, finds or creates each persona by email, assigns its role through `assignRole`, then evaluates `run` with that user's `Identity`, `SessionUser` and query viewer. The database must already be migrated. Only PostgreSQL URLs on `localhost`, `127.0.0.1` or `[::1]` are accepted; connection host overrides are refused before connecting.
|
|
294
|
+
|
|
295
|
+
```ts
|
|
296
|
+
import { Effect, Redacted } from "effect";
|
|
297
|
+
import { role } from "@shivaedev/access/role.ts";
|
|
298
|
+
import { roleSet } from "@shivaedev/access/roleSet.ts";
|
|
299
|
+
import { SessionUser } from "@shivaedev/identity/identity.ts";
|
|
300
|
+
import { defineSeed } from "@shivaedev/identity/server/better-auth/adapters/defineSeed.ts";
|
|
301
|
+
|
|
302
|
+
const roles = roleSet(role("member", []));
|
|
303
|
+
const seed = defineSeed({
|
|
304
|
+
defaultRole: "member",
|
|
305
|
+
roles,
|
|
306
|
+
users: [{ email: "alice@demo.test", name: "alice", password: Redacted.make("local-demo-password"), role: "member" }],
|
|
307
|
+
run: Effect.gen(function* () {
|
|
308
|
+
const user = yield* SessionUser;
|
|
309
|
+
yield* Effect.logInfo(`Seed application data for ${user.email}`);
|
|
310
|
+
}),
|
|
311
|
+
});
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
Pass the application's Better Auth settings as `auth` when it customizes user tables or authentication options. Existing emails reuse the same user ID, profile and password; each seed run assigns the declared role and runs the application Effect again, so application data seeding should itself be repeatable. New users receive password credentials and can sign in with the declared password.
|
|
315
|
+
|
|
316
|
+
For provisioning outside a seed, provide `betterAuthUserProvisioning(auth)` from `@shivaedev/identity/server/better-auth/adapters/userProvisioning.ts` and call `(yield* UserProvisioning).findOrCreateUser({ email, name, password })`, importing `UserProvisioning` from `@shivaedev/identity/server/UserProvisioning.ts`. This shares the seed's email-based reuse behavior without the seed's local database restriction.
|
|
317
|
+
|
|
283
318
|
### User directory
|
|
284
319
|
|
|
285
320
|
Applications use the `UserDirectory` port from `@shivaedev/identity/server/UserDirectory.ts` instead of reading auth tables. Provide `betterAuthUserDirectory(AppAccess, authOptions)` from `@shivaedev/identity/server/better-auth/adapters/userDirectory.ts` with the application's SQL Layer. Setting `authOptions.user.modelName` to `"users"` directs directory reads to that table, including the admin Users view and its pagination. The adapter follows Better Auth's configured user model, name, email, creation and modification columns, and additional-field or plugin role mapping. It shares an existing Reactivity service when supplied and creates one otherwise.
|
|
@@ -838,6 +873,36 @@ export default Effect.gen(function* () {
|
|
|
838
873
|
|
|
839
874
|
Run the auth schema migration before the app migration. Use `ON DELETE CASCADE` to delete owned rows with their user, or a nullable `user_id` and `ON DELETE SET NULL` to retain rows without an owner. `userReference` describes the default PostgreSQL mapping, so an application that customizes Better Auth's user table or id column must use its own mapping. Account reads and writes still go through identity; the foreign key grants no access to auth data. Quality's `boundaries/auth-sql` accepts these references while rejecting other auth SQL outside the configured owners.
|
|
840
875
|
|
|
876
|
+
### Register user data exports
|
|
877
|
+
|
|
878
|
+
Each domain supplies a `UserDataExport` from `server/userDataExport.ts`: the schema-qualified tables it owns and an `export(userId)` Effect that reads that user's rows. Keep filtering and the choice of exported fields in the domain. Compose the registrations once in the application's account module:
|
|
879
|
+
|
|
880
|
+
```ts
|
|
881
|
+
import { Effect } from "effect";
|
|
882
|
+
import { SqlClient } from "effect/sql";
|
|
883
|
+
import { accountExport } from "@shivaedev/identity/server/accountExport.ts";
|
|
884
|
+
import { betterAuthUserDataExport } from "@shivaedev/identity/server/better-auth/adapters/userDataExport.ts";
|
|
885
|
+
|
|
886
|
+
const notesExport = {
|
|
887
|
+
tables: [{ schema: "public", table: "notes" }],
|
|
888
|
+
export: Effect.fn(function* (userId: string) {
|
|
889
|
+
const sql = yield* SqlClient.SqlClient;
|
|
890
|
+
return yield* sql<{ title: string }>`select title from notes where user_id = ${userId} order by title`;
|
|
891
|
+
}),
|
|
892
|
+
};
|
|
893
|
+
|
|
894
|
+
const exports = accountExport({ account: betterAuthUserDataExport(), notes: notesExport });
|
|
895
|
+
|
|
896
|
+
const checkExportCoverage = exports.check;
|
|
897
|
+
const exportUser = exports.exportUser;
|
|
898
|
+
```
|
|
899
|
+
|
|
900
|
+
`exportUser(userId)` checks coverage, enumerates every registration and returns one object keyed by domain, preserving each domain's result type, Effect dependencies and failures. Empty domain results remain in the export. The account handler supplies the authorized user's id; this server API does not authenticate callers. Application-owned tables with no foreign key need explicit registration too: PostgreSQL cannot discover their ownership.
|
|
901
|
+
|
|
902
|
+
Run `check` against the migrated application database in a startup check or PostgreSQL story. It reads PostgreSQL's foreign-key catalog and fails with `UnregisteredUserExportTables` from `server/account-export/check.ts` when any table referencing the user id lacks a registration. The error's `tables` names each missing `{ schema, table }` once, including references from other schemas. A registration covers its named table; the domain remains responsible for exporting the right rows and fields, which its stories should prove. An export runs the same check before reading domain data, so a newly added foreign key cannot silently leave a table out.
|
|
903
|
+
|
|
904
|
+
The default reference is `public.user(id)`. For a customized auth mapping, pass `{ schema, table, column }` as the second argument to `accountExport`. Pass the same Better Auth options to `betterAuthUserDataExport(options)`; its optional second argument selects the PostgreSQL schema. The built-in registration exports profile fields, linked-account identifiers and session metadata for that user, with timestamps as native Effect UTC values. Passwords, access tokens, refresh tokens and session tokens are excluded by explicit field selection. Add registrations for application fields and plugin-owned tables that the built-in registration does not cover.
|
|
905
|
+
|
|
841
906
|
### Signed-in story preconditions
|
|
842
907
|
|
|
843
908
|
Use `testUtils()` from `better-auth/plugins` in a test-only Better Auth instance with the host's database, secret and cookie policy. Keep the plugin out of production auth options.
|
|
@@ -922,15 +987,16 @@ const mounted = yield* betterAuthMount(options, {
|
|
|
922
987
|
},
|
|
923
988
|
deliver: (message) => mailer.deliver(message),
|
|
924
989
|
window: "1 minute",
|
|
990
|
+
windows: { ConfirmAccount: "2 minutes", ResetPassword: "5 minutes" },
|
|
925
991
|
},
|
|
926
992
|
});
|
|
927
993
|
```
|
|
928
994
|
|
|
929
|
-
`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`. The `url` and every `token` are `Redacted<string>` so delivered messages keep their links and tokens hidden in logs and traces. Read them with `Redacted.value(message.url)` or `Redacted.value(message.token)` only when rendering the email or submitting the token. 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.
|
|
995
|
+
`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`. The `url` and every `token` are `Redacted<string>` so delivered messages keep their links and tokens hidden in logs and traces. Read them with `Redacted.value(message.url)` or `Redacted.value(message.token)` only when rendering the email or submitting the token. 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. When Better Auth supplies a continuation in its email link, identity copies it into `callbackURL` on the app link, replacing a configured `callbackURL` only when the continuation resolves to that app route's origin. Relative and absolute same-origin continuations are accepted; off-origin continuations are omitted even when Better Auth trusts that origin. Duplicate sign-up emails read `callbackURL` from the sign-up request supplied by Better Auth; server-side calls without a request keep their configured sign-in route. A confirmation page forwards both `token` and `callbackURL` to Better Auth's verification API so verification continues to the requested page, such as an invitation. A reset page submits the token with the new password to the reset API and uses the continuation after success.
|
|
930
996
|
|
|
931
997
|
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`.
|
|
932
998
|
|
|
933
|
-
Auth emails reserve one delivery attempt per account id and message kind for one minute by default in PostgreSQL. Provide the application's PostgreSQL Layer (`SqlClient` and `Reactivity`) to the mount. Include `postgresMigration` from `@shivaedev/rate-limit/adapters/postgresMigration.ts` in the application's numbered migration loader before enabling `emails`. `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 database time and survives mount rebuilds and process restarts. Mounts sharing a database share the reservation, regardless of the `Store` supplied for request rate limits. It complements Better Auth's request rate limits. Delivery Effects use the same `BetterAuthHookError` and request runtime as database hooks.
|
|
999
|
+
Auth emails reserve one delivery attempt per account id and message kind for one minute by default in PostgreSQL. Provide the application's PostgreSQL Layer (`SqlClient` and `Reactivity`) to the mount. Include `postgresMigration` from `@shivaedev/rate-limit/adapters/postgresMigration.ts` in the application's numbered migration loader before enabling `emails`. `window` accepts an Effect Duration input and remains the default for every kind. The optional `windows` map overrides that duration by `AuthEmail["_tag"]`; omitted kinds still use `window`, or one minute when it is absent. 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 database time and survives mount rebuilds and process restarts. Mounts sharing a database share the reservation, regardless of the `Store` supplied for request rate limits. It complements Better Auth's request rate limits. Delivery Effects use the same `BetterAuthHookError` and request runtime as database hooks.
|
|
934
1000
|
|
|
935
1001
|
### Sweep expired sessions in a worker
|
|
936
1002
|
|
|
@@ -25,31 +25,7 @@ export declare const AccountPreferences: import("@shivaedev/contract/contract.ts
|
|
|
25
25
|
readonly units: Schema.Literals<readonly ["metric", "imperial"]>;
|
|
26
26
|
}>, Schema.Void, {
|
|
27
27
|
readonly AuthUnavailable: typeof AuthUnavailable;
|
|
28
|
-
}>>], import("effect/rpc/Rpc").Rpc<"identity.accountPreferences
|
|
29
|
-
readonly locale: Schema.NonEmptyString;
|
|
30
|
-
readonly timezone: Schema.String;
|
|
31
|
-
readonly units: Schema.Literals<readonly ["metric", "imperial"]>;
|
|
32
|
-
}>, Schema.Void, Schema.Union<readonly (typeof AuthUnavailable)[]>, import("effect/rpc/RpcMiddleware").ServiceClass<import("@shivaedev/contract/internal/subjectMiddleware.ts").SubjectMiddleware<{
|
|
33
|
-
error: Schema.Union<readonly [typeof import("@shivaedev/errors/taxonomy.ts").Unauthorized, typeof AuthUnavailable, typeof import("@shivaedev/errors/taxonomy.ts").Forbidden, typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>;
|
|
34
|
-
middleware: Effect.Effect<import("#subject.ts").SubjectMiddleware<never, never>, never, import("#subject.ts").SubjectResolver>;
|
|
35
|
-
}>, `@shivaedev/contract/Subject/${string}`, import("./identity.ts").Identity | import("./identity.ts").SessionUser | import("#subject.ts").Subject, Schema.Union<readonly [typeof import("@shivaedev/errors/taxonomy.ts").Unauthorized, typeof AuthUnavailable, typeof import("@shivaedev/errors/taxonomy.ts").Forbidden, typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, never, never, false> & {
|
|
36
|
-
"@shivaedev/contract/SubjectDeclaration": {
|
|
37
|
-
error: Schema.Union<readonly [typeof import("@shivaedev/errors/taxonomy.ts").Unauthorized, typeof AuthUnavailable, typeof import("@shivaedev/errors/taxonomy.ts").Forbidden, typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>;
|
|
38
|
-
middleware: Effect.Effect<import("#subject.ts").SubjectMiddleware<never, never>, never, import("#subject.ts").SubjectResolver>;
|
|
39
|
-
};
|
|
40
|
-
}, never> | import("effect/rpc/Rpc").Rpc<"identity.accountPreferences.set", Schema.Struct<{
|
|
41
|
-
readonly locale: Schema.NonEmptyString;
|
|
42
|
-
readonly timezone: Schema.String;
|
|
43
|
-
readonly units: Schema.Literals<readonly ["metric", "imperial"]>;
|
|
44
|
-
}>, Schema.Void, Schema.Union<readonly (typeof AuthUnavailable)[]>, import("effect/rpc/RpcMiddleware").ServiceClass<import("@shivaedev/contract/internal/subjectMiddleware.ts").SubjectMiddleware<{
|
|
45
|
-
error: Schema.Union<readonly [typeof import("@shivaedev/errors/taxonomy.ts").Unauthorized, typeof AuthUnavailable, typeof import("@shivaedev/errors/taxonomy.ts").Forbidden, typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>;
|
|
46
|
-
middleware: Effect.Effect<import("#subject.ts").SubjectMiddleware<never, never>, never, import("#subject.ts").SubjectResolver>;
|
|
47
|
-
}>, `@shivaedev/contract/Subject/${string}`, import("./identity.ts").Identity | import("./identity.ts").SessionUser | import("#subject.ts").Subject, Schema.Union<readonly [typeof import("@shivaedev/errors/taxonomy.ts").Unauthorized, typeof AuthUnavailable, typeof import("@shivaedev/errors/taxonomy.ts").Forbidden, typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, never, never, false> & {
|
|
48
|
-
"@shivaedev/contract/SubjectDeclaration": {
|
|
49
|
-
error: Schema.Union<readonly [typeof import("@shivaedev/errors/taxonomy.ts").Unauthorized, typeof AuthUnavailable, typeof import("@shivaedev/errors/taxonomy.ts").Forbidden, typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>;
|
|
50
|
-
middleware: Effect.Effect<import("#subject.ts").SubjectMiddleware<never, never>, never, import("#subject.ts").SubjectResolver>;
|
|
51
|
-
};
|
|
52
|
-
}, never> | import("effect/rpc/Rpc").Rpc<"identity.accountPreferences.$changes", Schema.Struct<{
|
|
28
|
+
}>>], import("effect/rpc/Rpc").Rpc<"identity.accountPreferences.$changes", Schema.Struct<{
|
|
53
29
|
queries: Schema.$Array<Schema.Union<readonly Schema.Struct<{
|
|
54
30
|
query: Schema.Literal<"get">;
|
|
55
31
|
payload: Schema.Void;
|
|
@@ -88,7 +64,19 @@ export declare const AccountPreferences: import("@shivaedev/contract/contract.ts
|
|
|
88
64
|
error: Schema.Union<readonly [typeof import("@shivaedev/errors/taxonomy.ts").Unauthorized, typeof AuthUnavailable, typeof import("@shivaedev/errors/taxonomy.ts").Forbidden, typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>;
|
|
89
65
|
middleware: Effect.Effect<import("#subject.ts").SubjectMiddleware<never, never>, never, import("#subject.ts").SubjectResolver>;
|
|
90
66
|
};
|
|
91
|
-
}), never> | import("effect/rpc/Rpc").Rpc<"identity.accountPreferences.
|
|
67
|
+
}), never> | import("effect/rpc/Rpc").Rpc<"identity.accountPreferences.capture", Schema.Struct<{
|
|
68
|
+
readonly locale: Schema.NonEmptyString;
|
|
69
|
+
readonly timezone: Schema.String;
|
|
70
|
+
readonly units: Schema.Literals<readonly ["metric", "imperial"]>;
|
|
71
|
+
}>, Schema.Void, Schema.Union<readonly (typeof AuthUnavailable)[]>, import("effect/rpc/RpcMiddleware").ServiceClass<import("@shivaedev/contract/internal/subjectMiddleware.ts").SubjectMiddleware<{
|
|
72
|
+
error: Schema.Union<readonly [typeof import("@shivaedev/errors/taxonomy.ts").Unauthorized, typeof AuthUnavailable, typeof import("@shivaedev/errors/taxonomy.ts").Forbidden, typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>;
|
|
73
|
+
middleware: Effect.Effect<import("#subject.ts").SubjectMiddleware<never, never>, never, import("#subject.ts").SubjectResolver>;
|
|
74
|
+
}>, `@shivaedev/contract/Subject/${string}`, import("./identity.ts").Identity | import("./identity.ts").SessionUser | import("#subject.ts").Subject, Schema.Union<readonly [typeof import("@shivaedev/errors/taxonomy.ts").Unauthorized, typeof AuthUnavailable, typeof import("@shivaedev/errors/taxonomy.ts").Forbidden, typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, never, never, false> & {
|
|
75
|
+
"@shivaedev/contract/SubjectDeclaration": {
|
|
76
|
+
error: Schema.Union<readonly [typeof import("@shivaedev/errors/taxonomy.ts").Unauthorized, typeof AuthUnavailable, typeof import("@shivaedev/errors/taxonomy.ts").Forbidden, typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>;
|
|
77
|
+
middleware: Effect.Effect<import("#subject.ts").SubjectMiddleware<never, never>, never, import("#subject.ts").SubjectResolver>;
|
|
78
|
+
};
|
|
79
|
+
}, never> | import("effect/rpc/Rpc").Rpc<"identity.accountPreferences.get", Schema.Void, Schema.Struct<{
|
|
92
80
|
readonly locale: Schema.NonEmptyString;
|
|
93
81
|
readonly timezone: Schema.String;
|
|
94
82
|
readonly units: Schema.Literals<readonly ["metric", "imperial"]>;
|
|
@@ -108,5 +96,17 @@ export declare const AccountPreferences: import("@shivaedev/contract/contract.ts
|
|
|
108
96
|
error: Schema.Union<readonly [typeof import("@shivaedev/errors/taxonomy.ts").Unauthorized, typeof AuthUnavailable, typeof import("@shivaedev/errors/taxonomy.ts").Forbidden, typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>;
|
|
109
97
|
middleware: Effect.Effect<import("#subject.ts").SubjectMiddleware<never, never>, never, import("#subject.ts").SubjectResolver>;
|
|
110
98
|
};
|
|
111
|
-
}), never
|
|
99
|
+
}), never> | import("effect/rpc/Rpc").Rpc<"identity.accountPreferences.set", Schema.Struct<{
|
|
100
|
+
readonly locale: Schema.NonEmptyString;
|
|
101
|
+
readonly timezone: Schema.String;
|
|
102
|
+
readonly units: Schema.Literals<readonly ["metric", "imperial"]>;
|
|
103
|
+
}>, Schema.Void, Schema.Union<readonly (typeof AuthUnavailable)[]>, import("effect/rpc/RpcMiddleware").ServiceClass<import("@shivaedev/contract/internal/subjectMiddleware.ts").SubjectMiddleware<{
|
|
104
|
+
error: Schema.Union<readonly [typeof import("@shivaedev/errors/taxonomy.ts").Unauthorized, typeof AuthUnavailable, typeof import("@shivaedev/errors/taxonomy.ts").Forbidden, typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>;
|
|
105
|
+
middleware: Effect.Effect<import("#subject.ts").SubjectMiddleware<never, never>, never, import("#subject.ts").SubjectResolver>;
|
|
106
|
+
}>, `@shivaedev/contract/Subject/${string}`, import("./identity.ts").Identity | import("./identity.ts").SessionUser | import("#subject.ts").Subject, Schema.Union<readonly [typeof import("@shivaedev/errors/taxonomy.ts").Unauthorized, typeof AuthUnavailable, typeof import("@shivaedev/errors/taxonomy.ts").Forbidden, typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, never, never, false> & {
|
|
107
|
+
"@shivaedev/contract/SubjectDeclaration": {
|
|
108
|
+
error: Schema.Union<readonly [typeof import("@shivaedev/errors/taxonomy.ts").Unauthorized, typeof AuthUnavailable, typeof import("@shivaedev/errors/taxonomy.ts").Forbidden, typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>;
|
|
109
|
+
middleware: Effect.Effect<import("#subject.ts").SubjectMiddleware<never, never>, never, import("#subject.ts").SubjectResolver>;
|
|
110
|
+
};
|
|
111
|
+
}, never>, readonly [], undefined>;
|
|
112
112
|
//# sourceMappingURL=accountPreferences.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accountPreferences.d.ts","sourceRoot":"","sources":["../src/accountPreferences.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,MAAM,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAC;AAI1D,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAGhE,eAAO,MAAM,eAAe,eAE3B,CAAC;AAEF,eAAO,MAAM,uBAAuB;;;;EAIlC,CAAC;AAEH,eAAO,MAAM,qBAAqB,8GAA2D,CAAC;AAE9F,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"accountPreferences.d.ts","sourceRoot":"","sources":["../src/accountPreferences.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,MAAM,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAC;AAI1D,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAGhE,eAAO,MAAM,eAAe,eAE3B,CAAC;AAEF,eAAO,MAAM,uBAAuB;;;;EAIlC,CAAC;AAEH,eAAO,MAAM,qBAAqB,8GAA2D,CAAC;AAE9F,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kCAsB7B,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Context, type Effect, type Redacted } from "effect";
|
|
2
|
+
import type { AuthUnavailable } from "@shivaedev/errors/taxonomy.ts";
|
|
3
|
+
import type { SessionUserValue } from "#identity.ts";
|
|
4
|
+
export interface PasswordUser {
|
|
5
|
+
readonly email: string;
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly password: Redacted.Redacted<string>;
|
|
8
|
+
}
|
|
9
|
+
declare const UserProvisioning_base: Context.ServiceClass<UserProvisioning, "@shivaedev/identity/UserProvisioning", {
|
|
10
|
+
readonly findOrCreateUser: (user: PasswordUser) => Effect.Effect<Pick<SessionUserValue, "id" | "email" | "name">, AuthUnavailable>;
|
|
11
|
+
}>;
|
|
12
|
+
export declare class UserProvisioning extends UserProvisioning_base {
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=UserProvisioning.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UserProvisioning.d.ts","sourceRoot":"","sources":["../../src/server/UserProvisioning.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;CAC7C;;+BAK4B,CAAC,IAAI,EAAE,YAAY,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,GAAG,OAAO,GAAG,MAAM,CAAC,EAAE,eAAe,CAAC;;AAHpI,qBAAa,gBAAiB,SAAQ,qBAKK;CAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UserProvisioning.js","sourceRoot":"","sources":["../../src/server/UserProvisioning.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAA8B,MAAM,QAAQ,CAAC;AAU7D,MAAM,OAAO,gBAAiB,SAAQ,OAAO,CAAC,OAAO,EAKlD,CAAC,sCAAsC,CAAC;CAAG"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Effect, Schema } from "effect";
|
|
2
|
+
import { SqlClient } from "effect/sql";
|
|
3
|
+
import type { UserDataExport, UserExportReference } from "#server/userDataExport.ts";
|
|
4
|
+
declare const UnregisteredUserExportTables_base: Schema.Class<UnregisteredUserExportTables, Schema.TaggedStruct<"UnregisteredUserExportTables", {
|
|
5
|
+
readonly tables: Schema.$Array<Schema.Struct<{
|
|
6
|
+
readonly schema: Schema.String;
|
|
7
|
+
readonly table: Schema.String;
|
|
8
|
+
}>>;
|
|
9
|
+
}>, import("effect/Cause").YieldableError>;
|
|
10
|
+
export declare class UnregisteredUserExportTables extends UnregisteredUserExportTables_base {
|
|
11
|
+
get message(): string;
|
|
12
|
+
}
|
|
13
|
+
export declare const checkUserDataExports: (registrations: Readonly<Record<string, UserDataExport>>, reference: UserExportReference) => Effect.Effect<undefined, Schema.SchemaError | import("effect/sql/SqlError").SqlError | UnregisteredUserExportTables, SqlClient.SqlClient>;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=check.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../../src/server/account-export/check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,SAAS,EAAa,MAAM,YAAY,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;;;;;;;AAErF,qBAAa,4BAA6B,SAAQ,iCAEhD;IACD,IAAa,OAAO,WAEnB;CACD;AAED,eAAO,MAAM,oBAAoB,wOAyB/B,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Effect, Schema } from "effect";
|
|
2
|
+
import { SqlClient, SqlSchema } from "effect/sql";
|
|
3
|
+
export class UnregisteredUserExportTables extends Schema.TaggedError()("UnregisteredUserExportTables", {
|
|
4
|
+
tables: Schema.Array(Schema.Struct({ schema: Schema.String, table: Schema.String })),
|
|
5
|
+
}) {
|
|
6
|
+
get message() {
|
|
7
|
+
return `User data export registrations are missing for: ${this.tables.map(({ schema, table }) => `${schema}.${table}`).join(", ")}`;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export const checkUserDataExports = Effect.fn("Identity.checkUserDataExports")(function* (registrations, reference) {
|
|
11
|
+
const sql = (yield* SqlClient.SqlClient).withoutTransforms();
|
|
12
|
+
const tables = yield* SqlSchema.findAll({
|
|
13
|
+
execute: () => sql `
|
|
14
|
+
select distinct source_schema.nspname as schema, source.relname as table
|
|
15
|
+
from pg_catalog.pg_constraint fk
|
|
16
|
+
join pg_catalog.pg_class source on source.oid = fk.conrelid
|
|
17
|
+
join pg_catalog.pg_namespace source_schema on source_schema.oid = source.relnamespace
|
|
18
|
+
join pg_catalog.pg_class target on target.oid = fk.confrelid
|
|
19
|
+
join pg_catalog.pg_namespace target_schema on target_schema.oid = target.relnamespace
|
|
20
|
+
join pg_catalog.pg_attribute target_column on target_column.attrelid = target.oid and target_column.attnum = any(fk.confkey)
|
|
21
|
+
where fk.contype = 'f' and target_schema.nspname = ${reference.schema}
|
|
22
|
+
and target.relname = ${reference.table} and target_column.attname = ${reference.column}
|
|
23
|
+
order by schema, "table"`,
|
|
24
|
+
Request: Schema.Void,
|
|
25
|
+
Result: Schema.Struct({ schema: Schema.String, table: Schema.String }),
|
|
26
|
+
})(undefined);
|
|
27
|
+
const registered = Object.values(registrations).flatMap((registration) => registration.tables);
|
|
28
|
+
const missing = tables.filter((table) => !registered.some((entry) => entry.schema === table.schema && entry.table === table.table));
|
|
29
|
+
if (missing.length > 0) {
|
|
30
|
+
return yield* new UnregisteredUserExportTables({ tables: missing });
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=check.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check.js","sourceRoot":"","sources":["../../../src/server/account-export/check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGlD,MAAM,OAAO,4BAA6B,SAAQ,MAAM,CAAC,WAAW,EAAgC,CAAC,8BAA8B,EAAE;IACpI,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;CACpF,CAAC;IACD,IAAa,OAAO;QACnB,OAAO,mDAAmD,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,GAAG,MAAM,IAAI,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;IACrI,CAAC;CACD;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,EAAE,CAAC,+BAA+B,CAAC,CAAC,QAAQ,CAAC,EACvF,aAAuD,EACvD,SAA8B;IAE9B,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,iBAAiB,EAAE,CAAC;IAC7D,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC;QACvC,OAAO,EAAE,GAAG,EAAE,CAAC,GAAG,CAAA;;;;;;;;uDAQmC,SAAS,CAAC,MAAM;0BAC7C,SAAS,CAAC,KAAK,gCAAgC,SAAS,CAAC,MAAM;2BAC9D;QACzB,OAAO,EAAE,MAAM,CAAC,IAAI;QACpB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;KACtE,CAAC,CAAC,SAAS,CAAC,CAAC;IACd,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,CAAC,YAAY,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IAC/F,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,KAAK,KAAK,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IACpI,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxB,OAAO,KAAK,CAAC,CAAC,IAAI,4BAA4B,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;IACrE,CAAC;AACF,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { checkUserDataExports } from "#server/account-export/check.ts";
|
|
3
|
+
import type { UserDataExport, UserExportReference } from "#server/userDataExport.ts";
|
|
4
|
+
type ExportEffects<T extends Readonly<Record<string, UserDataExport>>> = ReturnType<T[keyof T]["export"]>;
|
|
5
|
+
type ExportCoverage = ReturnType<typeof checkUserDataExports>;
|
|
6
|
+
type ExportData<T extends Readonly<Record<string, UserDataExport>>> = {
|
|
7
|
+
readonly [TDomain in keyof T]: Effect.Success<ReturnType<T[TDomain]["export"]>>;
|
|
8
|
+
};
|
|
9
|
+
export declare function accountExport<const T extends Readonly<Record<string, UserDataExport>>>(registrations: T, reference?: UserExportReference): {
|
|
10
|
+
readonly check: ExportCoverage;
|
|
11
|
+
readonly exportUser: (userId: string) => Effect.Effect<ExportData<T>, Effect.Error<ExportEffects<T>> | Effect.Error<ExportCoverage>, Effect.Services<ExportEffects<T>> | Effect.Services<ExportCoverage>>;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=accountExport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accountExport.d.ts","sourceRoot":"","sources":["../../src/server/accountExport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAEvE,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErF,KAAK,aAAa,CAAC,CAAC,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC1G,KAAK,cAAc,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAC9D,KAAK,UAAU,CAAC,CAAC,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,IAAI;IACrE,QAAQ,EAAE,OAAO,IAAI,MAAM,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;CAC/E,CAAC;AAEF,wBAAgB,aAAa,CAAC,KAAK,CAAC,CAAC,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,EACrF,aAAa,EAAE,CAAC,EAChB,SAAS,CAAC,EAAE,mBAAmB,GAC7B;IACF,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;IAC/B,QAAQ,CAAC,UAAU,EAAE,CACpB,MAAM,EAAE,MAAM,KACV,MAAM,CAAC,MAAM,CACjB,UAAU,CAAC,CAAC,CAAC,EACb,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,EAC7D,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,CACnE,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { checkUserDataExports } from "#server/account-export/check.ts";
|
|
3
|
+
import { userReference } from "#server/better-auth/userReference.ts";
|
|
4
|
+
export function accountExport(registrations, reference = { ...userReference, schema: "public" }) {
|
|
5
|
+
const check = checkUserDataExports(registrations, reference);
|
|
6
|
+
return {
|
|
7
|
+
check,
|
|
8
|
+
exportUser: Effect.fn("Identity.exportUser")(function* (userId) {
|
|
9
|
+
yield* check;
|
|
10
|
+
const entries = yield* Effect.forEach(Object.entries(registrations), ([domain, registration]) => registration.export(userId).pipe(Effect.map((data) => [domain, data])));
|
|
11
|
+
return Object.fromEntries(entries);
|
|
12
|
+
}),
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=accountExport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accountExport.js","sourceRoot":"","sources":["../../src/server/accountExport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAsBrE,MAAM,UAAU,aAAa,CAC5B,aAAuD,EACvD,SAAS,GAAwB,EAAE,GAAG,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE;IAEvE,MAAM,KAAK,GAAG,oBAAoB,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;IAC7D,OAAO;QACN,KAAK;QACL,UAAU,EAAE,MAAM,CAAC,EAAE,CAAC,qBAAqB,CAAC,CAAC,QAAQ,CAAC,EAAE,MAAc;YACrE,KAAK,CAAC,CAAC,KAAK,CAAC;YACb,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,YAAY,CAAC,EAAE,EAAE,CAC/F,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,IAAI,CAAU,CAAC,CAAC,CAC/E,CAAC;YACF,OAAO,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QACpC,CAAC,CAAC;KACF,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { BetterAuthOptions } from "better-auth";
|
|
2
|
+
import type { Effect } from "effect";
|
|
3
|
+
import type { AccessPolicy } from "@shivaedev/access/roleSet.ts";
|
|
4
|
+
import type { PasswordUser } from "#server/UserProvisioning.ts";
|
|
5
|
+
export interface SeedOptions<TRole extends string, E, R> {
|
|
6
|
+
readonly auth?: Omit<BetterAuthOptions, "database">;
|
|
7
|
+
readonly defaultRole: NoInfer<TRole>;
|
|
8
|
+
readonly roles: AccessPolicy<TRole>;
|
|
9
|
+
readonly run: Effect.Effect<unknown, E, R>;
|
|
10
|
+
readonly users: readonly (PasswordUser & {
|
|
11
|
+
readonly role: NoInfer<TRole>;
|
|
12
|
+
})[];
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=SeedOptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SeedOptions.d.ts","sourceRoot":"","sources":["../../../../src/server/better-auth/adapters/SeedOptions.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,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,MAAM,WAAW,WAAW,CAAC,KAAK,SAAS,MAAM,EAAE,CAAC,EAAE,CAAC;IACtD,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC;IACpD,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IACrC,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC;IACpC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC3C,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,YAAY,GAAG;QAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,CAAA;KAAE,CAAC,EAAE,CAAC;CAC9E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SeedOptions.js","sourceRoot":"","sources":["../../../../src/server/better-auth/adapters/SeedOptions.ts"],"names":[],"mappings":""}
|
|
@@ -1,7 +1,43 @@
|
|
|
1
1
|
import { type BetterAuthOptions } from "better-auth";
|
|
2
2
|
import { Effect } from "effect";
|
|
3
3
|
export declare const acquireAuth: <TOptions extends BetterAuthOptions>(options: TOptions) => Effect.Effect<{
|
|
4
|
-
auth: import("better-auth").Auth<TOptions
|
|
4
|
+
auth: import("better-auth").Auth<TOptions & {
|
|
5
|
+
advanced: {
|
|
6
|
+
ipAddress?: {
|
|
7
|
+
ipAddressHeaders?: string[];
|
|
8
|
+
disableIpTracking?: boolean;
|
|
9
|
+
ipv6Subnet?: number;
|
|
10
|
+
trustedProxies?: string[];
|
|
11
|
+
} | undefined;
|
|
12
|
+
useSecureCookies?: boolean | undefined;
|
|
13
|
+
disableCSRFCheck?: boolean | undefined;
|
|
14
|
+
disableOriginCheck?: boolean | undefined;
|
|
15
|
+
crossSubDomainCookies?: {
|
|
16
|
+
enabled: boolean;
|
|
17
|
+
additionalCookies?: string[];
|
|
18
|
+
domain?: string;
|
|
19
|
+
} | undefined;
|
|
20
|
+
cookies?: {
|
|
21
|
+
[key: string]: {
|
|
22
|
+
name?: string;
|
|
23
|
+
attributes?: import("better-auth").CookieOptions;
|
|
24
|
+
};
|
|
25
|
+
} | undefined;
|
|
26
|
+
defaultCookieAttributes?: import("better-auth").CookieOptions | undefined;
|
|
27
|
+
cookiePrefix?: string | undefined;
|
|
28
|
+
trustedProxyHeaders?: boolean | undefined;
|
|
29
|
+
backgroundTasks?: {
|
|
30
|
+
handler: (promise: Promise<unknown>) => void;
|
|
31
|
+
};
|
|
32
|
+
skipTrailingSlashes?: boolean;
|
|
33
|
+
database: {
|
|
34
|
+
defaultFindManyLimit?: number;
|
|
35
|
+
generateId?: import("better-auth").GenerateIdFn | false | "serial" | "uuid";
|
|
36
|
+
validateSchema?: boolean;
|
|
37
|
+
joins: boolean;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
}>;
|
|
5
41
|
profiles: import("../userProfiles.ts").UserProfileStorage;
|
|
6
42
|
}, import("@shivaedev/errors/taxonomy.ts").AuthUnavailable, never>;
|
|
7
43
|
//# sourceMappingURL=acquire.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acquire.d.ts","sourceRoot":"","sources":["../../../../src/server/better-auth/adapters/acquire.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAc,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhC,eAAO,MAAM,WAAW,GAAgC,QAAQ,SAAS,iBAAiB
|
|
1
|
+
{"version":3,"file":"acquire.d.ts","sourceRoot":"","sources":["../../../../src/server/better-auth/adapters/acquire.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAc,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhC,eAAO,MAAM,WAAW,GAAgC,QAAQ,SAAS,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kEAcxF,CAAC"}
|
|
@@ -3,7 +3,10 @@ import { Effect } from "effect";
|
|
|
3
3
|
import { providerFailure } from "#server/providerFailure.ts";
|
|
4
4
|
import { profileStorage } from "./profileStorage.js";
|
|
5
5
|
export const acquireAuth = Effect.fnUntraced(function* (options) {
|
|
6
|
-
const auth = betterAuth(
|
|
6
|
+
const auth = betterAuth({
|
|
7
|
+
...options,
|
|
8
|
+
advanced: { ...options.advanced, database: { joins: true, ...options.advanced?.database } },
|
|
9
|
+
});
|
|
7
10
|
const context = yield* Effect.tryPromise(async () => {
|
|
8
11
|
const ready = await auth.$context;
|
|
9
12
|
await ready.checkSchema?.();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acquire.js","sourceRoot":"","sources":["../../../../src/server/better-auth/adapters/acquire.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,UAAU,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAsC,OAAiB;IAC5G,MAAM,IAAI,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"acquire.js","sourceRoot":"","sources":["../../../../src/server/better-auth/adapters/acquire.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,UAAU,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAsC,OAAiB;IAC5G,MAAM,IAAI,GAAG,UAAU,CAAC;QACvB,GAAG,OAAO;QACV,QAAQ,EAAE,EAAE,GAAG,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE;KAC3F,CAAC,CAAC;IACH,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,IAAI,EAAE;QACnD,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC;QAClC,MAAM,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;QAC5B,OAAO,KAAK,CAAC;IACd,CAAC,CAAC,CAAC,IAAI,CACN,MAAM,CAAC,eAAe,EACtB,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,eAAe,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CACrD,CAAC;IACF,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC;AACpD,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Effect, Redacted } from "effect";
|
|
2
|
+
declare const NonLocalSeedDatabase_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
3
|
+
readonly _tag: "NonLocalSeedDatabase";
|
|
4
|
+
} & Readonly<A>;
|
|
5
|
+
export declare class NonLocalSeedDatabase extends NonLocalSeedDatabase_base {
|
|
6
|
+
readonly message = "Demo seeding requires a local PostgreSQL database URL";
|
|
7
|
+
}
|
|
8
|
+
export declare const assertSeedDatabase: (value: Redacted.Redacted<string>) => Effect.Effect<undefined, NonLocalSeedDatabase, never>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=assertSeedDatabase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assertSeedDatabase.d.ts","sourceRoot":"","sources":["../../../../src/server/better-auth/adapters/assertSeedDatabase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,MAAM,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;;;;AAEhD,qBAAa,oBAAqB,SAAQ,yBAAwC;IACjF,SAAkB,OAAO,2DAA2D;CACpF;AAED,eAAO,MAAM,kBAAkB,6FAQ7B,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Data, Effect, Redacted } from "effect";
|
|
2
|
+
export class NonLocalSeedDatabase extends Data.TaggedError("NonLocalSeedDatabase") {
|
|
3
|
+
message = "Demo seeding requires a local PostgreSQL database URL";
|
|
4
|
+
}
|
|
5
|
+
export const assertSeedDatabase = Effect.fnUntraced(function* (value) {
|
|
6
|
+
const url = yield* Effect.try({ catch: () => new NonLocalSeedDatabase(), try: () => new URL(Redacted.value(value)) });
|
|
7
|
+
if (!(["postgres:", "postgresql:"].includes(url.protocol) && ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname))
|
|
8
|
+
|| [...url.searchParams.keys()].some((key) => ["host", "hostaddr", "service"].includes(key.toLowerCase()))) {
|
|
9
|
+
return yield* new NonLocalSeedDatabase();
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
//# sourceMappingURL=assertSeedDatabase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assertSeedDatabase.js","sourceRoot":"","sources":["../../../../src/server/better-auth/adapters/assertSeedDatabase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAEhD,MAAM,OAAO,oBAAqB,SAAQ,IAAI,CAAC,WAAW,CAAC,sBAAsB,CAAC;IAC/D,OAAO,GAAG,uDAAuD,CAAC;CACpF;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,KAAgC;IAC9F,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,IAAI,oBAAoB,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;IACtH,IACC,CAAC,CAAC,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;WACjH,CAAC,GAAG,GAAG,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC,EACzG,CAAC;QACF,OAAO,KAAK,CAAC,CAAC,IAAI,oBAAoB,EAAE,CAAC;IAC1C,CAAC;AACF,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Config, Effect } from "effect";
|
|
2
|
+
import type { SeedOptions } from "./SeedOptions.ts";
|
|
3
|
+
export declare function defineSeed<TRole extends string, E, R>(options: SeedOptions<TRole, E, R>): Effect.Effect<void, E | import("@shivaedev/errors/taxonomy.ts").AuthUnavailable | import("@shivaedev/sql/repositoryCollection.ts").BucketRegistrationError | Config.ConfigError | import("../../../roles.ts").LastRoleAssigner | import("./assertSeedDatabase.ts").NonLocalSeedDatabase | import("@shivaedev/errors/taxonomy.ts").NotFound | import("effect/Schema").SchemaError | import("effect/sql/SqlError").SqlError | import("../UndeclaredDefaultRole.ts").UndeclaredDefaultRole, Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<R, import("../../../identity.ts").Identity>, import("../../../identity.ts").SessionUser>, never>, import("../../UserProvisioning.ts").UserProvisioning>, import("@effect/sql-pg/PgClient").PgClient | import("@effect/sql-pg/PgPool").PgPool | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient>, import("effect/Scope").Scope>>;
|
|
4
|
+
//# sourceMappingURL=defineSeed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defineSeed.d.ts","sourceRoot":"","sources":["../../../../src/server/better-auth/adapters/defineSeed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAOxC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAGpD,wBAAgB,UAAU,CAAC,KAAK,SAAS,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,WAAW,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,y3BAYvF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Config, Effect } from "effect";
|
|
2
|
+
import { memoryStore } from "@shivaedev/rate-limit/memoryStore.ts";
|
|
3
|
+
import { postgresLayer } from "@shivaedev/sql/postgresLayer.ts";
|
|
4
|
+
import { seedUsers } from "#server/better-auth/seedUsers.ts";
|
|
5
|
+
import { assertSeedDatabase } from "./assertSeedDatabase.js";
|
|
6
|
+
import { betterAuthDatabase } from "./database.js";
|
|
7
|
+
import { betterAuthMount } from "./mount.js";
|
|
8
|
+
import { betterAuthUserProvisioning } from "./userProvisioning.js";
|
|
9
|
+
export function defineSeed(options) {
|
|
10
|
+
return Effect.gen(function* () {
|
|
11
|
+
const url = yield* Config.Redacted("DATABASE_URL");
|
|
12
|
+
yield* assertSeedDatabase(url);
|
|
13
|
+
return yield* Effect.gen(function* () {
|
|
14
|
+
const { auth } = yield* betterAuthMount({ emailAndPassword: { enabled: true }, ...options.auth, database: yield* betterAuthDatabase() }, { defaultRole: options.defaultRole, roles: options.roles }).pipe(Effect.provide(memoryStore));
|
|
15
|
+
return yield* seedUsers(options).pipe(Effect.provide(betterAuthUserProvisioning(auth)));
|
|
16
|
+
}).pipe(Effect.provide(postgresLayer(url)));
|
|
17
|
+
}).pipe(Effect.scoped);
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=defineSeed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defineSeed.js","sourceRoot":"","sources":["../../../../src/server/better-auth/adapters/defineSeed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAEnE,MAAM,UAAU,UAAU,CAA6B,OAAiC;IACvF,OAAO,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QAC1B,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;QACnD,KAAK,CAAC,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC;QAC/B,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;YACjC,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,CAAC,eAAe,CACtC,EAAE,gBAAgB,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC,kBAAkB,EAAE,EAAE,EAC/F,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAC1D,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;YACpC,OAAO,KAAK,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,0BAA0B,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACzF,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AACxB,CAAC"}
|
|
@@ -1 +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,EAAoB,MAAM,QAAQ,CAAC;AAIlD,OAAO,KAAK,EAAa,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;
|
|
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,EAAoB,MAAM,QAAQ,CAAC;AAIlD,OAAO,KAAK,EAAa,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAYjF,eAAO,MAAM,YAAY,GAAgC,QAAQ,SAAS,iBAAiB,EAAE,CAAC;;;kIAwE5F,CAAC"}
|