@shivaedev/identity 0.41.0 → 0.43.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 +22 -0
- package/README.md +39 -3
- package/dist/Account.d.ts +18 -0
- package/dist/Account.d.ts.map +1 -0
- package/dist/Account.js +19 -0
- package/dist/Account.js.map +1 -0
- package/dist/generated/Account.d.ts +28 -0
- package/dist/generated/Account.d.ts.map +1 -0
- package/dist/generated/Account.js +18 -0
- package/dist/generated/Account.js.map +1 -0
- package/dist/identity.d.ts +2 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +1 -0
- package/dist/identity.js.map +1 -1
- package/dist/server/AccountDeletion.d.ts +12 -0
- package/dist/server/AccountDeletion.d.ts.map +1 -0
- package/dist/server/AccountDeletion.js +5 -0
- package/dist/server/AccountDeletion.js.map +1 -0
- package/dist/server/better-auth/AccountDeletionPolicy.d.ts +10 -0
- package/dist/server/better-auth/AccountDeletionPolicy.d.ts.map +1 -0
- package/dist/server/better-auth/AccountDeletionPolicy.js +4 -0
- package/dist/server/better-auth/AccountDeletionPolicy.js.map +1 -0
- package/dist/server/better-auth/accountDeletion.d.ts +14 -0
- package/dist/server/better-auth/accountDeletion.d.ts.map +1 -0
- package/dist/server/better-auth/accountDeletion.js +24 -0
- package/dist/server/better-auth/accountDeletion.js.map +1 -0
- package/dist/server/better-auth/adapters/oauthGrants.d.ts.map +1 -1
- package/dist/server/better-auth/adapters/oauthGrants.js +7 -1
- package/dist/server/better-auth/adapters/oauthGrants.js.map +1 -1
- package/dist/server/better-auth/adapters/passwordMatches.d.ts +4 -0
- package/dist/server/better-auth/adapters/passwordMatches.d.ts.map +1 -0
- package/dist/server/better-auth/adapters/passwordMatches.js +9 -0
- package/dist/server/better-auth/adapters/passwordMatches.js.map +1 -0
- package/dist/server/better-auth/closeAccountDeletion.d.ts +3 -0
- package/dist/server/better-auth/closeAccountDeletion.d.ts.map +1 -0
- package/dist/server/better-auth/closeAccountDeletion.js +5 -0
- package/dist/server/better-auth/closeAccountDeletion.js.map +1 -0
- package/dist/server/better-auth/confirmPassword.d.ts +7 -0
- package/dist/server/better-auth/confirmPassword.d.ts.map +1 -0
- package/dist/server/better-auth/confirmPassword.js +34 -0
- package/dist/server/better-auth/confirmPassword.js.map +1 -0
- package/dist/server/better-auth/deleteAccount.d.ts +5 -0
- package/dist/server/better-auth/deleteAccount.d.ts.map +1 -0
- package/dist/server/better-auth/deleteAccount.js +28 -0
- package/dist/server/better-auth/deleteAccount.js.map +1 -0
- package/dist/server/better-auth/deleteUserRows.d.ts +6 -0
- package/dist/server/better-auth/deleteUserRows.d.ts.map +1 -0
- package/dist/server/better-auth/deleteUserRows.js +20 -0
- package/dist/server/better-auth/deleteUserRows.js.map +1 -0
- package/dist/server/better-auth/mount.d.ts.map +1 -1
- package/dist/server/better-auth/mount.js +3 -1
- package/dist/server/better-auth/mount.js.map +1 -1
- package/dist/server/better-auth/seedUsers.js +1 -1
- package/dist/server/better-auth/seedUsers.js.map +1 -1
- package/dist/server/localOwner.d.ts +2 -0
- package/dist/server/localOwner.d.ts.map +1 -1
- package/dist/server/localOwner.js +3 -1
- package/dist/server/localOwner.js.map +1 -1
- package/dist/server/machineTokens.d.ts +2 -0
- package/dist/server/machineTokens.d.ts.map +1 -1
- package/dist/server/machineTokens.js +1 -1
- package/dist/server/machineTokens.js.map +1 -1
- package/dist/server/providerAccountsUser.d.ts +1 -0
- package/dist/server/providerAccountsUser.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/Account.ts +20 -0
- package/src/generated/Account.ts +23 -0
- package/src/identity.ts +1 -0
- package/src/server/AccountDeletion.ts +19 -0
- package/src/server/better-auth/AccountDeletionPolicy.ts +10 -0
- package/src/server/better-auth/accountDeletion.ts +44 -0
- package/src/server/better-auth/adapters/oauthGrants.ts +7 -1
- package/src/server/better-auth/adapters/passwordMatches.ts +10 -0
- package/src/server/better-auth/closeAccountDeletion.ts +6 -0
- package/src/server/better-auth/confirmPassword.ts +37 -0
- package/src/server/better-auth/deleteAccount.ts +28 -0
- package/src/server/better-auth/deleteUserRows.ts +21 -0
- package/src/server/better-auth/mount.ts +3 -1
- package/src/server/better-auth/seedUsers.ts +1 -1
- package/src/server/localOwner.ts +3 -1
- package/src/server/machineTokens.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.43.0 - 2026-11-21
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- The account `delete` command admits three attempts per person in ten seconds, the budget Better Auth gives `/change-email`, through `@shivaedev/rate-limit`, and refuses a further attempt with `TooManyRequests`, which a form hook shows as a notice.
|
|
8
|
+
- `SessionUser` carries `emailVerified`, whether the signed-in person has confirmed their email address. An operation reads it from the session lookup Platform already makes, so it learns the flag with no second session read, and a `defineSeed` run reads the seeded persona's stored flag. An account that has not confirmed reads `false`; the first lookup after the person follows the confirmation link reads `true`.
|
|
9
|
+
|
|
10
|
+
### Breaking
|
|
11
|
+
|
|
12
|
+
- `accountDeletion` requires a rate-limit `Store` from `@shivaedev/rate-limit/Store.ts`. An application whose registrations provide none adds one to one registration's `ports`, such as `ports: memoryStore` with `memoryStore` from `@shivaedev/rate-limit/memoryStore.ts`.
|
|
13
|
+
- `SessionUserSchema`, `SessionUserValue` and `UserSessionShape` require `emailVerified: boolean`. A custom session provider adds `emailVerified` to the `user` it returns, and a test fixture that builds a `SessionUser` value or a provider's session user adds the field too, such as `Effect.provideService(SessionUser, { email, emailVerified: true, id, name })`. A provider without it still compiles, because `SessionPolicy.provider` requires only `user.id`: every operation behind `AuthenticatedUser`, `AuthenticatedUserWithProviderAccounts`, permission middleware, a subject resolver or `mcpRoutes` then fails as a defect when it reads the session user, while the person stays signed in. Operations behind `Authenticated` alone keep working. An application on Better Auth changes nothing, because Better Auth always supplies the field.
|
|
14
|
+
|
|
15
|
+
## 0.42.0 - 2026-11-21
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- `Account` from `@shivaedev/identity/Account.ts` deletes the signed-in person's account through its `identity.account.delete({ password })` command. It confirms the current password with the declaration's configured verifier, then runs the application's hand-over, erases the person's owned rows and deletes their auth rows in one transaction, so a failure anywhere leaves them able to sign in with every row in place. Register it as `module: Account` with `services: accountDeletion(AppAuth)` from `@shivaedev/identity/server/better-auth/accountDeletion.ts`; an application that hands rows over to other people passes its hand-over service, written with `defineService` and providing `handOver(userId)`, as `accountDeletion(AppAuth, { handOver: HandOver })` and provides `HandOver.layer`. Browser code imports the client contract from `@shivaedev/identity/generated/Account.ts`.
|
|
20
|
+
|
|
21
|
+
### Breaking
|
|
22
|
+
|
|
23
|
+
- The mount closes Better Auth's `/delete-user` and `/delete-user/callback`, even when the options enable `user.deleteUser`, and the admin plugin's `/admin/remove-user`. An application that deleted accounts through `/delete-user` with a `user.delete.before` hook moves the hook's body into a hand-over service's `handOver(userId)` operation, passes that service to `accountDeletion`, registers the `Account` module and calls `identity.account.delete({ password })` from its client instead of Better Auth's `deleteUser`. An application that removed users through `/admin/remove-user` has no HTTP route for it any more; the person deletes their own account with the command.
|
|
24
|
+
|
|
3
25
|
## 0.41.0 - 2026-11-21
|
|
4
26
|
|
|
5
27
|
### Breaking
|
package/README.md
CHANGED
|
@@ -676,7 +676,7 @@ Declare expected refusals with the shared tagged error schemas from [`@shivaedev
|
|
|
676
676
|
|
|
677
677
|
### Reading the signed-in user
|
|
678
678
|
|
|
679
|
-
When a handler needs the current user's name and email, declare `AuthenticatedUser` and read `SessionUser`. `Identity` keeps its `{ id }` shape; `AuthenticatedUser` supplies both services for that invocation. Its provider must return `user: { id, name, email }`, described by `UserSessionShape`.
|
|
679
|
+
When a handler needs the current user's name and email, declare `AuthenticatedUser` and read `SessionUser`. `Identity` keeps its `{ id }` shape; `AuthenticatedUser` supplies both services for that invocation. Its provider must return `user: { id, name, email, emailVerified }`, described by `UserSessionShape`. `SessionUser.emailVerified` says whether the person has confirmed their address. Better Auth's provider reads it from the session lookup the request already makes, so a screen or operation that shows "confirm your email" or gates a feature on a confirmed address needs no second session read: an account that has not confirmed reads `false`, and the first lookup after the person follows the confirmation link reads `true`. The browser's remembered session keeps only the session, user id and grants, so an application serves the flag from its own profile query.
|
|
680
680
|
|
|
681
681
|
```ts
|
|
682
682
|
import { Effect, Layer, Schema } from "effect";
|
|
@@ -698,7 +698,7 @@ export const AccountHandlers = Account.toLayer({
|
|
|
698
698
|
export const AccountServer = Layer.merge(AccountHandlers, authenticatedUserLayer());
|
|
699
699
|
```
|
|
700
700
|
|
|
701
|
-
Here `sessions` is the application's policy Layer from the previous example, with a Better Auth lookup that returns all
|
|
701
|
+
Here `sessions` is the application's policy Layer from the previous example, with a Better Auth lookup that returns all four 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, email and `emailVerified`, plus an optional role and permissions when the provider supplies them, without exposing the rest of the provider's user record. Handlers do not query the provider's user table.
|
|
702
702
|
|
|
703
703
|
#### Reading provider account IDs
|
|
704
704
|
|
|
@@ -1081,7 +1081,7 @@ const eraseOwnedRows = data.eraseOwnedRows;
|
|
|
1081
1081
|
|
|
1082
1082
|
`exportAccount(userId)` returns `{ account, owned }`. `account` holds the person's profile fields, linked-account identifiers and session metadata from Better Auth's tables, with timestamps as native Effect UTC values; passwords, access tokens, refresh tokens and session tokens are left out by explicit field selection. `owned` holds one `{ table, rows }` entry per owned model, ordered by table, with every row whose owner field holds the user id, encoded through the model's `json` variant. A field without a JSON variant, such as a `serverOnly` field, is never read, so it cannot reach the export. A table with none of the person's rows keeps its empty entry. Identity's own account preferences are an owned model too.
|
|
1083
1083
|
|
|
1084
|
-
`eraseOwnedRows(userId)` deletes every owned row of the person. It reads PostgreSQL's foreign keys between the owned tables and deletes the rows that reference a table before the rows they reference, so `RESTRICT` and `NO ACTION` keys between owned tables need no hand-kept order. It opens no transaction of its own: run it inside the caller's `transact` from `@shivaedev/sql/transact.ts`, and a failure anywhere in that transaction leaves every row in place. When `RESTRICT` or `NO ACTION` keys between owned tables form a cycle, it fails with `OwnedTableCycle` from `server/account-data/OwnedTableCycle.ts`, naming the tables as `schema.table`, before it deletes anything. It erases owned rows only; the auth user and Better Auth's own tables stay for the account deletion that runs after it.
|
|
1084
|
+
`eraseOwnedRows(userId)` deletes every owned row of the person. It reads PostgreSQL's foreign keys between the owned tables and deletes the rows that reference a table before the rows they reference, so `RESTRICT` and `NO ACTION` keys between owned tables need no hand-kept order. It opens no transaction of its own: run it inside the caller's `transact` from `@shivaedev/sql/transact.ts`, and a failure anywhere in that transaction leaves every row in place. When `RESTRICT` or `NO ACTION` keys between owned tables form a cycle, it fails with `OwnedTableCycle` from `server/account-data/OwnedTableCycle.ts`, naming the tables as `schema.table`, before it deletes anything. It erases owned rows only; the auth user and Better Auth's own tables stay for the [account deletion](#delete-an-account) that runs after it.
|
|
1085
1085
|
|
|
1086
1086
|
`check` fails with `UncoveredUserColumns` from `server/account-data/UncoveredUserColumns.ts` when a column refers to the person but nothing covers it. A column refers to the person when its foreign key points at the auth user's id or at an owned model's owner column. It is covered when it is an owned model's owner column, when its foreign key is `ON DELETE SET NULL` (such a row, an authored-by row for example, is not the person's: it stays without them and is not in their export), or when it belongs to one of Better Auth's tables. The error's `columns` names each `{ schema, table, column }` once, from every schema. `exportAccount` and `eraseOwnedRows` run the check first, so a new column whose foreign key points directly at the person, or at an owned model's owner column, fails them until an owner mark or a `SET NULL` key covers it. Run `check` against the migrated database in a startup check or a PostgreSQL story too, after the application's repositories are built under `collectRepositoryModels` from `@shivaedev/sql/RepositoryModels.ts`; `appHost` provides that collector, so an operation it serves sees every owned model.
|
|
1087
1087
|
|
|
@@ -1095,6 +1095,39 @@ Outside a host, a job or script must provide `collectRepositoryModels` itself an
|
|
|
1095
1095
|
|
|
1096
1096
|
PostgreSQL sees only foreign keys, so a table whose owner column has none is covered by its owner mark alone, and a table the application reaches only through raw SQL needs a repository on a model with an owner mark to be exported and erased. The user reference is the auth declaration's user table, so a customized `user.modelName` needs nothing more, and its `id` column in the `public` schema; when the user's id lives elsewhere, pass that `{ schema, table, column }` as the second argument to `accountData`. The account handler supplies the authorized user's id; these server APIs do not authenticate callers.
|
|
1097
1097
|
|
|
1098
|
+
### Delete an account
|
|
1099
|
+
|
|
1100
|
+
`Account` from `@shivaedev/identity/Account.ts` is a defined module, which is server code: register it as `module: Account` with `services: accountDeletion(AppAuth)`, using `accountDeletion` from `@shivaedev/identity/server/better-auth/accountDeletion.ts`. Its `identity.account.delete({ password })` command deletes the signed-in person's account; it needs the `AuthenticatedUser` middleware, the application's `SqlClient` and `Reactivity`, which `appHost` provides, the rate-limit `Store` the application declares once in one registration's `ports`, and the owned models the host collects. Browser code imports the client contract under the same name from `@shivaedev/identity/generated/Account.ts`; give the command to a form hook such as React's `useCreate`, so a refused password shows on the password field.
|
|
1101
|
+
|
|
1102
|
+
The command runs these steps in order:
|
|
1103
|
+
|
|
1104
|
+
1. It admits three attempts per person in ten seconds through [`@shivaedev/rate-limit`](https://github.com/ShivaeDev/platform/tree/main/packages/rate-limit#readme), in that one store, the budget Better Auth gives `/change-email` and its other password-checked routes. A further attempt is refused with `TooManyRequests` before the password is checked, and a form hook shows its message, `Too many attempts. Wait a moment and try again.`, as a notice. The window starts at the first attempt and every attempt counts, so a correct password within the budget still deletes.
|
|
1105
|
+
2. It checks the person's current password with the verifier the declaration's options configure, Better Auth's own unless `emailAndPassword.password.verify` replaces it. A missing, overlong or wrong password is refused with `BadRequest` on the `password` field, and an account without a credential password with `PreconditionFailed`; nothing is deleted.
|
|
1106
|
+
3. One `transact` runs the application's hand-over, then [`eraseOwnedRows`](#export-and-erase-a-persons-data), then deletes the person's auth rows: the user row, whose `ON DELETE CASCADE` keys remove their sessions and sign-in accounts, and the verification rows Better Auth writes for them. Those are the rows whose value is their id, such as a password-reset token, the `email-verification`, `sign-in` and `forget-password` codes of their exact address, and the change-email and two-factor codes that start with their id.
|
|
1107
|
+
4. On commit it announces `userKeys` and `sessionKeys`, so live readers refresh. The person's next session check answers signed out, which makes a remembered session forget itself, and their next protected request is refused with `Unauthorized`.
|
|
1108
|
+
|
|
1109
|
+
The hand-over is the application's policy for rows that other people keep, such as a shared household that passes to another member. It is an application service written with `defineService` whose `handOver(userId)` operation yields its own dependencies; pass its tag to `accountDeletion` and provide its Layer, and leave both out when nothing is handed over. The deletion calls it inside its transaction, so its writes commit or roll back with the rest:
|
|
1110
|
+
|
|
1111
|
+
```ts
|
|
1112
|
+
import { Layer } from "effect";
|
|
1113
|
+
import { Account } from "@shivaedev/identity/Account.ts";
|
|
1114
|
+
import { accountDeletion } from "@shivaedev/identity/server/better-auth/accountDeletion.ts";
|
|
1115
|
+
import type { AppModule } from "@shivaedev/server/AppModule.ts";
|
|
1116
|
+
import { AppAuth } from "#server/AppAuth.ts";
|
|
1117
|
+
import { HouseholdHandOver } from "#server/households/handOver/service.ts";
|
|
1118
|
+
|
|
1119
|
+
export const accountRegistration = {
|
|
1120
|
+
module: Account,
|
|
1121
|
+
services: accountDeletion(AppAuth, { handOver: HouseholdHandOver }).pipe(Layer.provide(HouseholdHandOver.layer)),
|
|
1122
|
+
} satisfies AppModule;
|
|
1123
|
+
```
|
|
1124
|
+
|
|
1125
|
+
A failing hand-over, a failing erase or a failing auth delete rolls everything back: the person keeps every row and still signs in with the same password. The command answers `InternalServerError` and the host reports the cause, because these failures are the application's to fix rather than the person's.
|
|
1126
|
+
|
|
1127
|
+
The mount closes Better Auth's `/delete-user` and `/delete-user/callback`, even when the options enable `user.deleteUser`, and the admin plugin's `/admin/remove-user`, so this command is the one HTTP route that deletes an account. Better Auth deletes outside any transaction and erases no owned rows, and its `user.delete.before` hooks do not run here: move such a hook's body into the hand-over. Server code that calls Better Auth's `auth.api` directly is not covered by the closed routes.
|
|
1128
|
+
|
|
1129
|
+
The deletion reads and writes Better Auth's tables through the application's SQL client. It removes database sessions only; sessions kept in a cookie cache or secondary storage stay valid until they expire. Accounts that sign in only through a provider have no password to confirm with and are refused.
|
|
1130
|
+
|
|
1098
1131
|
### Signed-in story preconditions
|
|
1099
1132
|
|
|
1100
1133
|
A feature story starts signed in with `mintUser` from `@shivaedev/test-kits/identity/adapters/betterAuth.ts`. It reads the application's auth declaration, so the minted user lives under the same options and roles as production:
|
|
@@ -1234,6 +1267,9 @@ Import the module that defines the name; there is no package-root entry. Paths b
|
|
|
1234
1267
|
| `server/better-auth/adapters/revokeUnadmitted.ts` | `RevokedSessions`: the `{ users, sessions }` counts of a revocation. |
|
|
1235
1268
|
| `server/better-auth/userProfiles.ts` | Public profile lookups for other users. |
|
|
1236
1269
|
| `server/better-auth/sweepExpiredSessions.ts` | `sweepExpiredSessions`: delete expired sessions through the application's SQL client and return the number removed. |
|
|
1270
|
+
| `Account.ts` | `Account`: the defined module whose `delete` command deletes the signed-in person's account after confirming their password. |
|
|
1271
|
+
| `server/AccountDeletion.ts` | `AccountDeletion`: the port the account module's `delete` command calls. |
|
|
1272
|
+
| `server/better-auth/accountDeletion.ts` | `accountDeletion(declaration, { handOver? })`, `AccountHandOver`: the Better Auth `AccountDeletion` Layer and the shape of the application's hand-over service. |
|
|
1237
1273
|
| `server/better-auth/accountData.ts` | `accountData(declaration, reference?)`, returning `{ check, exportAccount, eraseOwnedRows }`: a person's account export, owned-row erasure and the coverage check, from the owned models the host reports. |
|
|
1238
1274
|
| `server/account-data/UncoveredUserColumns.ts` | `UncoveredUserColumns`: the coverage failure naming each column that refers to a person without an owned model to cover it. |
|
|
1239
1275
|
| `server/account-data/OwnedModelsUncollected.ts` | `OwnedModelsUncollected`: the failure of export, erase and check when no collector records the owned models. |
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { AuthenticatedUser } from "#middleware.ts";
|
|
3
|
+
import { AccountDeletion } from "#server/AccountDeletion.ts";
|
|
4
|
+
export declare const Account: import("@shivaedev/contract/defineModule.ts").Module<"identity.account", readonly [import("@shivaedev/contract/servedOperation.ts").ServedCommand<"delete", Schema.Struct<{
|
|
5
|
+
password: Schema.String;
|
|
6
|
+
}>, Schema.Void, {
|
|
7
|
+
readonly InternalServerError: typeof import("@shivaedev/errors/taxonomy.ts").InternalServerError;
|
|
8
|
+
readonly ServiceUnavailable: typeof import("@shivaedev/errors/taxonomy.ts").ServiceUnavailable;
|
|
9
|
+
readonly AuthUnavailable: typeof import("@shivaedev/errors/taxonomy.ts").AuthUnavailable;
|
|
10
|
+
readonly BadRequest: typeof import("@shivaedev/errors/taxonomy.ts").BadRequest;
|
|
11
|
+
readonly PreconditionFailed: typeof import("@shivaedev/errors/taxonomy.ts").PreconditionFailed;
|
|
12
|
+
readonly TooManyRequests: typeof import("@shivaedev/errors/taxonomy.ts").TooManyRequests;
|
|
13
|
+
}, import("effect/Effect").Effect<void, import("@shivaedev/errors/taxonomy.ts").AuthUnavailable | import("@shivaedev/errors/taxonomy.ts").BadRequest | import("@shivaedev/errors/taxonomy.ts").PreconditionFailed | Schema.SchemaError | import("effect/sql/SqlError").SqlError | import("@shivaedev/rate-limit/Store.ts").StoreError | import("@shivaedev/errors/taxonomy.ts").TooManyRequests, AccountDeletion | import("./identity.ts").SessionUser>>] & readonly import("@shivaedev/contract/defineModule.ts").ModuleOperation[], import("@shivaedev/contract/moduleProof.ts").ModuleRequirements<readonly [import("@shivaedev/contract/servedOperation.ts").ServedCommandOf<"delete", {
|
|
14
|
+
password: Schema.String;
|
|
15
|
+
}, import("effect/Effect").Effect<void, import("@shivaedev/errors/taxonomy.ts").AuthUnavailable | import("@shivaedev/errors/taxonomy.ts").BadRequest | import("@shivaedev/errors/taxonomy.ts").PreconditionFailed | Schema.SchemaError | import("effect/sql/SqlError").SqlError | import("@shivaedev/rate-limit/Store.ts").StoreError | import("@shivaedev/errors/taxonomy.ts").TooManyRequests, import("./identity.ts").SessionUser> | import("effect/Effect").Effect<{
|
|
16
|
+
readonly delete: (password: string) => import("effect/Effect").Effect<void, import("@shivaedev/errors/taxonomy.ts").AuthUnavailable | import("@shivaedev/errors/taxonomy.ts").BadRequest | import("@shivaedev/errors/taxonomy.ts").PreconditionFailed | Schema.SchemaError | import("effect/sql/SqlError").SqlError | import("@shivaedev/rate-limit/Store.ts").StoreError | import("@shivaedev/errors/taxonomy.ts").TooManyRequests, import("./identity.ts").SessionUser>;
|
|
17
|
+
}, never, AccountDeletion>, void>], typeof AuthenticatedUser, undefined>, typeof AuthenticatedUser, undefined, undefined>;
|
|
18
|
+
//# sourceMappingURL=Account.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Account.d.ts","sourceRoot":"","sources":["../src/Account.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAS7D,eAAO,MAAM,OAAO;;;;;;;;;;;;;yHAKlB,CAAC"}
|
package/dist/Account.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { defineModule } from "@shivaedev/contract/defineModule.ts";
|
|
3
|
+
import { command } from "@shivaedev/contract/operation.ts";
|
|
4
|
+
import { identityAccountWire } from "#generated/Account.ts";
|
|
5
|
+
import { AuthenticatedUser } from "#middleware.ts";
|
|
6
|
+
import { AccountDeletion } from "#server/AccountDeletion.ts";
|
|
7
|
+
const DeleteAccount = command("delete", {
|
|
8
|
+
payload: { password: Schema.String },
|
|
9
|
+
*run({ password }) {
|
|
10
|
+
yield* (yield* AccountDeletion).delete(password);
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
export const Account = defineModule({
|
|
14
|
+
middleware: AuthenticatedUser,
|
|
15
|
+
name: "identity.account",
|
|
16
|
+
operations: [DeleteAccount],
|
|
17
|
+
wire: identityAccountWire,
|
|
18
|
+
});
|
|
19
|
+
//# sourceMappingURL=Account.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Account.js","sourceRoot":"","sources":["../src/Account.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D,MAAM,aAAa,GAAG,OAAO,CAAC,QAAQ,EAAE;IACvC,OAAO,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE;IACpC,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE;QAChB,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAClD,CAAC;CACD,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,YAAY,CAAC;IACnC,UAAU,EAAE,iBAAiB;IAC7B,IAAI,EAAE,kBAAkB;IACxB,UAAU,EAAE,CAAC,aAAa,CAAC;IAC3B,IAAI,EAAE,mBAAmB;CACzB,CAAC,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Account as AccountModule } from "#Account.ts";
|
|
2
|
+
import { AuthenticatedUser } from "#middleware.ts";
|
|
3
|
+
import type { ClientMatchesModule } from "@shivaedev/contract/clientMatchesModule.ts";
|
|
4
|
+
import { AuthUnavailable, BadRequest, PreconditionFailed, TooManyRequests } from "@shivaedev/errors/taxonomy.ts";
|
|
5
|
+
import { Schema } from "effect";
|
|
6
|
+
export declare const identityAccountWire: {
|
|
7
|
+
readonly delete: {
|
|
8
|
+
readonly rejections: {
|
|
9
|
+
readonly AuthUnavailable: typeof AuthUnavailable;
|
|
10
|
+
readonly BadRequest: typeof BadRequest;
|
|
11
|
+
readonly PreconditionFailed: typeof PreconditionFailed;
|
|
12
|
+
readonly TooManyRequests: typeof TooManyRequests;
|
|
13
|
+
};
|
|
14
|
+
readonly success: Schema.Void;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export declare const Account: import("@shivaedev/contract/defineModule.ts").ModuleContract<"identity.account", readonly import("@shivaedev/contract/operation.ts").Command<"delete", Schema.Struct<{
|
|
18
|
+
readonly password: Schema.String;
|
|
19
|
+
}>, Schema.Void, {
|
|
20
|
+
readonly InternalServerError: typeof import("@shivaedev/errors/taxonomy.ts").InternalServerError;
|
|
21
|
+
readonly ServiceUnavailable: typeof import("@shivaedev/errors/taxonomy.ts").ServiceUnavailable;
|
|
22
|
+
readonly AuthUnavailable: typeof AuthUnavailable;
|
|
23
|
+
readonly BadRequest: typeof BadRequest;
|
|
24
|
+
readonly PreconditionFailed: typeof PreconditionFailed;
|
|
25
|
+
readonly TooManyRequests: typeof TooManyRequests;
|
|
26
|
+
}>[], typeof AuthenticatedUser, undefined, undefined>;
|
|
27
|
+
export declare const identityAccountMatchModule: ClientMatchesModule<typeof Account, typeof AccountModule>;
|
|
28
|
+
//# sourceMappingURL=Account.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Account.d.ts","sourceRoot":"","sources":["../../src/generated/Account.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4CAA4C,CAAC;AACtF,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACjH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,eAAO,MAAM,mBAAmB;;;;;;;;;;CAEtB,CAAC;AAEX,eAAO,MAAM,OAAO;;;;;;;;;qDAQlB,CAAC;AAEH,eAAO,MAAM,0BAA0B,EAAE,mBAAmB,CAAC,OAAO,OAAO,EAAE,OAAO,aAAa,CAAQ,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AuthenticatedUser } from "#middleware.ts";
|
|
2
|
+
import { clientContract } from "@shivaedev/contract/clientContract.ts";
|
|
3
|
+
import { AuthUnavailable, BadRequest, PreconditionFailed, TooManyRequests } from "@shivaedev/errors/taxonomy.ts";
|
|
4
|
+
import { Schema } from "effect";
|
|
5
|
+
export const identityAccountWire = {
|
|
6
|
+
delete: { rejections: { AuthUnavailable, BadRequest, PreconditionFailed, TooManyRequests }, success: Schema.Void },
|
|
7
|
+
};
|
|
8
|
+
export const Account = clientContract({
|
|
9
|
+
commands: ["delete"],
|
|
10
|
+
middleware: AuthenticatedUser,
|
|
11
|
+
name: "identity.account",
|
|
12
|
+
payloads: {
|
|
13
|
+
delete: { password: Schema.String },
|
|
14
|
+
},
|
|
15
|
+
wire: identityAccountWire,
|
|
16
|
+
});
|
|
17
|
+
export const identityAccountMatchModule = true;
|
|
18
|
+
//# sourceMappingURL=Account.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Account.js","sourceRoot":"","sources":["../../src/generated/Account.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAEvE,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACjH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,MAAM,CAAC,MAAM,mBAAmB,GAAG;IAClC,MAAM,EAAE,EAAE,UAAU,EAAE,EAAE,eAAe,EAAE,UAAU,EAAE,kBAAkB,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,IAAI,EAAE;CACzG,CAAC;AAEX,MAAM,CAAC,MAAM,OAAO,GAAG,cAAc,CAAC;IACrC,QAAQ,EAAE,CAAC,QAAQ,CAAC;IACpB,UAAU,EAAE,iBAAiB;IAC7B,IAAI,EAAE,kBAAkB;IACxB,QAAQ,EAAE;QACT,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE;KACnC;IACD,IAAI,EAAE,mBAAmB;CACzB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,0BAA0B,GAA8D,IAAI,CAAC"}
|
package/dist/identity.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export interface ProviderAccountValue {
|
|
|
18
18
|
}
|
|
19
19
|
export declare const SessionUserSchema: Schema.Struct<{
|
|
20
20
|
readonly email: Schema.String;
|
|
21
|
+
readonly emailVerified: Schema.Boolean;
|
|
21
22
|
readonly id: Schema.String;
|
|
22
23
|
readonly name: Schema.String;
|
|
23
24
|
readonly permissions: Schema.optionalKey<Schema.$Array<Schema.Struct<{
|
|
@@ -29,6 +30,7 @@ export declare const SessionUserSchema: Schema.Struct<{
|
|
|
29
30
|
export type SessionUserValue = typeof SessionUserSchema.Type;
|
|
30
31
|
declare const SessionUser_base: Context.ServiceClass<SessionUser, "@shivaedev/identity/SessionUser", {
|
|
31
32
|
readonly email: string;
|
|
33
|
+
readonly emailVerified: boolean;
|
|
32
34
|
readonly id: string;
|
|
33
35
|
readonly name: string;
|
|
34
36
|
readonly permissions?: readonly {
|
package/dist/identity.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names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,WAAY,SAAQ,gBAAmF;CAAG;AACvH,MAAM,WAAW,oCAAqC,SAAQ,gBAAgB;IAC7E,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC,MAAM,CAAC,SAAS,oBAAoB,EAAE,EAAE,eAAe,GAAG,YAAY,CAAC,CAAC;CAC1G;;AACD,qBAAa,+BAAgC,SAAQ,oCAEpD;CAAG"}
|
package/dist/identity.js
CHANGED
|
@@ -8,6 +8,7 @@ export class OptionalIdentity extends Context.Service()("@shivaedev/identity/Opt
|
|
|
8
8
|
}
|
|
9
9
|
export const SessionUserSchema = Schema.Struct({
|
|
10
10
|
email: Schema.String,
|
|
11
|
+
emailVerified: Schema.Boolean,
|
|
11
12
|
id: Schema.String,
|
|
12
13
|
name: Schema.String,
|
|
13
14
|
permissions: Schema.optionalKey(Schema.Array(Permission)),
|
package/dist/identity.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAA4B,MAAM,EAAE,MAAM,QAAQ,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAE7D,MAAM,OAAO,SAAU,SAAQ,OAAO,CAAC,OAAO,EAAqB,CAAC,+BAA+B,CAAC;CAAG;AAIvG,MAAM,OAAO,QAAS,SAAQ,OAAO,CAAC,OAAO,EAA2B,CAAC,8BAA8B,CAAC;CAAG;AAC3G,MAAM,OAAO,gBAAiB,SAAQ,OAAO,CAAC,OAAO,EAAkD,CAAC,sCAAsC,CAAC;CAAG;AAKlJ,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC9C,KAAK,EAAE,MAAM,CAAC,MAAM;IACpB,EAAE,EAAE,MAAM,CAAC,MAAM;IACjB,IAAI,EAAE,MAAM,CAAC,MAAM;IACnB,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,K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CAAiC,CAAC;CAAG;AAIvH,MAAM,OAAO,+BAAgC,SAAQ,OAAO,CAAC,OAAO,EAAyE,CAC5I,qDAAqD,CACrD;CAAG"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Context, type Effect, type Schema } from "effect";
|
|
2
|
+
import type { SqlError } from "effect/sql/SqlError";
|
|
3
|
+
import type { AuthUnavailable, BadRequest, PreconditionFailed, TooManyRequests } from "@shivaedev/errors/taxonomy.ts";
|
|
4
|
+
import type { StoreError } from "@shivaedev/rate-limit/Store.ts";
|
|
5
|
+
import type { SessionUser } from "#identity.ts";
|
|
6
|
+
declare const AccountDeletion_base: Context.ServiceClass<AccountDeletion, "@shivaedev/identity/AccountDeletion", {
|
|
7
|
+
readonly delete: (password: string) => Effect.Effect<void, AuthUnavailable | BadRequest | PreconditionFailed | Schema.SchemaError | SqlError | StoreError | TooManyRequests, SessionUser>;
|
|
8
|
+
}>;
|
|
9
|
+
export declare class AccountDeletion extends AccountDeletion_base {
|
|
10
|
+
}
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=AccountDeletion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccountDeletion.d.ts","sourceRoot":"","sources":["../../src/server/AccountDeletion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC3D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACtH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;;qBAM7B,CAChB,QAAQ,EAAE,MAAM,KACZ,MAAM,CAAC,MAAM,CACjB,IAAI,EACJ,eAAe,GAAG,UAAU,GAAG,kBAAkB,GAAG,MAAM,CAAC,WAAW,GAAG,QAAQ,GAAG,UAAU,GAAG,eAAe,EAChH,WAAW,CACX;;AATH,qBAAa,eAAgB,SAAQ,oBAWK;CAAG"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Context } from "effect";
|
|
2
|
+
// The account module's port, so the module stays free of the provider that implements the deletion.
|
|
3
|
+
export class AccountDeletion extends Context.Service()("@shivaedev/identity/AccountDeletion") {
|
|
4
|
+
}
|
|
5
|
+
//# sourceMappingURL=AccountDeletion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccountDeletion.js","sourceRoot":"","sources":["../../src/server/AccountDeletion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAA4B,MAAM,QAAQ,CAAC;AAM3D,oGAAoG;AACpG,MAAM,OAAO,eAAgB,SAAQ,OAAO,CAAC,OAAO,EAWjD,CAAC,qCAAqC,CAAC;CAAG"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Context, type Effect } from "effect";
|
|
2
|
+
import type { AuthSchemaDeclaration } from "#server/better-auth/define.ts";
|
|
3
|
+
declare const AccountDeletionPolicy_base: Context.ServiceClass<AccountDeletionPolicy, "@shivaedev/identity/AccountDeletionPolicy", {
|
|
4
|
+
readonly auth: Pick<AuthSchemaDeclaration, "options">;
|
|
5
|
+
readonly handOver: (userId: string) => Effect.Effect<void>;
|
|
6
|
+
}>;
|
|
7
|
+
export declare class AccountDeletionPolicy extends AccountDeletionPolicy_base {
|
|
8
|
+
}
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=AccountDeletionPolicy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccountDeletionPolicy.d.ts","sourceRoot":"","sources":["../../../src/server/better-auth/AccountDeletionPolicy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;;mBAK1D,IAAI,CAAC,qBAAqB,EAAE,SAAS,CAAC;uBAClC,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;;AAJ5D,qBAAa,qBAAsB,SAAQ,0BAMK;CAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccountDeletionPolicy.js","sourceRoot":"","sources":["../../../src/server/better-auth/AccountDeletionPolicy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAe,MAAM,QAAQ,CAAC;AAG9C,MAAM,OAAO,qBAAsB,SAAQ,OAAO,CAAC,OAAO,EAMvD,CAAC,2CAA2C,CAAC;CAAG"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type Context, Effect, Layer } from "effect";
|
|
2
|
+
import * as Reactivity from "effect/reactivity/Reactivity";
|
|
3
|
+
import { SqlClient } from "effect/sql";
|
|
4
|
+
import { Store } from "@shivaedev/rate-limit/Store.ts";
|
|
5
|
+
import { AccountDeletion } from "#server/AccountDeletion.ts";
|
|
6
|
+
import type { AuthSchemaDeclaration } from "#server/better-auth/define.ts";
|
|
7
|
+
export interface AccountHandOver<E> {
|
|
8
|
+
readonly handOver: (userId: string) => Effect.Effect<void, E>;
|
|
9
|
+
}
|
|
10
|
+
export interface AccountDeletionOptions<TIdentifier, E> {
|
|
11
|
+
readonly handOver?: Context.Service<TIdentifier, AccountHandOver<E>> | undefined;
|
|
12
|
+
}
|
|
13
|
+
export declare function accountDeletion<TIdentifier = never, E = never>(auth: Pick<AuthSchemaDeclaration, "options">, options?: AccountDeletionOptions<TIdentifier, E>): Layer.Layer<AccountDeletion, never, Reactivity.Reactivity | SqlClient.SqlClient | Store | Exclude<TIdentifier, import("effect/Scope").Scope>>;
|
|
14
|
+
//# sourceMappingURL=accountDeletion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accountDeletion.d.ts","sourceRoot":"","sources":["../../../src/server/better-auth/accountDeletion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AACrD,OAAO,KAAK,UAAU,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAG3E,MAAM,WAAW,eAAe,CAAC,CAAC;IACjC,QAAQ,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;CAC9D;AAED,MAAM,WAAW,sBAAsB,CAAC,WAAW,EAAE,CAAC;IACrD,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;CACjF;AAGD,wBAAgB,eAAe,CAAC,WAAW,GAAG,KAAK,EAAE,CAAC,GAAG,KAAK,EAC7D,IAAI,EAAE,IAAI,CAAC,qBAAqB,EAAE,SAAS,CAAC,EAC5C,OAAO,GAAE,sBAAsB,CAAC,WAAW,EAAE,CAAC,CAAM,iJAuBpD"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Effect, Layer } from "effect";
|
|
2
|
+
import * as Reactivity from "effect/reactivity/Reactivity";
|
|
3
|
+
import { SqlClient } from "effect/sql";
|
|
4
|
+
import { Store } from "@shivaedev/rate-limit/Store.ts";
|
|
5
|
+
import { AccountDeletion } from "#server/AccountDeletion.ts";
|
|
6
|
+
import { AccountDeletionPolicy } from "#server/better-auth/AccountDeletionPolicy.ts";
|
|
7
|
+
import { deleteAccount } from "#server/better-auth/deleteAccount.ts";
|
|
8
|
+
// A hand-over's failure is the application's to fix, so it is reported rather than answered to the person.
|
|
9
|
+
export function accountDeletion(auth, options = {}) {
|
|
10
|
+
return Layer.effect(AccountDeletion)(Effect.gen(function* () {
|
|
11
|
+
const sql = yield* SqlClient.SqlClient;
|
|
12
|
+
const reactivity = yield* Reactivity.Reactivity;
|
|
13
|
+
const store = yield* Store;
|
|
14
|
+
const service = options.handOver === undefined ? undefined : yield* options.handOver;
|
|
15
|
+
const policy = {
|
|
16
|
+
auth,
|
|
17
|
+
handOver: (userId) => (service === undefined ? Effect.void : Effect.orDie(service.handOver(userId))),
|
|
18
|
+
};
|
|
19
|
+
return AccountDeletion.of({
|
|
20
|
+
delete: (password) => deleteAccount(password).pipe(Effect.provideService(AccountDeletionPolicy, policy), Effect.provideService(SqlClient.SqlClient, sql), Effect.provideService(Reactivity.Reactivity, reactivity), Effect.provideService(Store, store)),
|
|
21
|
+
});
|
|
22
|
+
}));
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=accountDeletion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accountDeletion.js","sourceRoot":"","sources":["../../../src/server/better-auth/accountDeletion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AACrD,OAAO,KAAK,UAAU,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAErF,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAUrE,2GAA2G;AAC3G,MAAM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../../../../src/server/better-auth/adapters/oauthGrants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAS,MAAM,EAAE,KAAK,EAAkB,MAAM,QAAQ,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAc,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAEjE,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;QAC1B,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,SAAS,GAAG,UAAU,CAAC,GAAG;YACxE,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,YAAY,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;SAClH,CAAC;QACF,QAAQ,CAAC,eAAe,EAAE,IAAI,CAAC,WAAW,CAAC,iBAAiB,CAAC,EAAE,cAAc,CAAC,CAAC;KAC/E,CAAC,CAAC;CACH;AAMD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE;IAC9C,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;CACjF,
|
|
1
|
+
{"version":3,"file":"oauthGrants.d.ts","sourceRoot":"","sources":["../../../../src/server/better-auth/adapters/oauthGrants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAS,MAAM,EAAE,KAAK,EAAkB,MAAM,QAAQ,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAc,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAEjE,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;QAC1B,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,SAAS,GAAG,UAAU,CAAC,GAAG;YACxE,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,YAAY,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;SAClH,CAAC;QACF,QAAQ,CAAC,eAAe,EAAE,IAAI,CAAC,WAAW,CAAC,iBAAiB,CAAC,EAAE,cAAc,CAAC,CAAC;KAC/E,CAAC,CAAC;CACH;AAMD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE;IAC9C,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;CACjF,0CA4EA"}
|
|
@@ -68,7 +68,13 @@ export function betterAuthOauthGrants(options) {
|
|
|
68
68
|
const grant = yield* Schema.decodeUnknownEffect(OauthGrant)(subject.consent).pipe(Effect.mapError(unavailable));
|
|
69
69
|
return Option.some({
|
|
70
70
|
scopes: grant.scopes,
|
|
71
|
-
user: {
|
|
71
|
+
user: {
|
|
72
|
+
email: subject.user.email,
|
|
73
|
+
emailVerified: subject.user.emailVerified,
|
|
74
|
+
id: subject.user.id,
|
|
75
|
+
name: subject.user.name,
|
|
76
|
+
...(typeof role === "string" ? { role } : {}),
|
|
77
|
+
},
|
|
72
78
|
});
|
|
73
79
|
}),
|
|
74
80
|
revokeAllClients: (userId) => revoke(userId),
|
|
@@ -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E,CAAC,MAAM,CAAC,MAAM,CAAC;QAC5C,YAAY,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC;KAC5D,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { BetterAuthOptions } from "better-auth";
|
|
2
|
+
import { Effect } from "effect";
|
|
3
|
+
export declare function passwordMatches(options: BetterAuthOptions, hash: string, password: string): Effect.Effect<boolean, import("@shivaedev/errors/taxonomy.ts").AuthUnavailable, never>;
|
|
4
|
+
//# sourceMappingURL=passwordMatches.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"passwordMatches.d.ts","sourceRoot":"","sources":["../../../../src/server/better-auth/adapters/passwordMatches.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhC,wBAAgB,eAAe,CAAC,OAAO,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,0FAGzF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { verifyPassword } from "better-auth/crypto";
|
|
2
|
+
import { Effect } from "effect";
|
|
3
|
+
import { providerFailure } from "#server/providerFailure.ts";
|
|
4
|
+
// Better Auth's context resolves the verifier the same way, so a custom hash in the options is checked by its own verify.
|
|
5
|
+
export function passwordMatches(options, hash, password) {
|
|
6
|
+
const verify = options.emailAndPassword?.password?.verify ?? verifyPassword;
|
|
7
|
+
return Effect.tryPromise(() => verify({ hash, password })).pipe(Effect.catch(providerFailure));
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=passwordMatches.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"passwordMatches.js","sourceRoot":"","sources":["../../../../src/server/better-auth/adapters/passwordMatches.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D,0HAA0H;AAC1H,MAAM,UAAU,eAAe,CAAC,OAA0B,EAAE,IAAY,EAAE,QAAgB;IACzF,MAAM,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,QAAQ,EAAE,MAAM,IAAI,cAAc,CAAC;IAC5E,OAAO,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC;AAChG,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"closeAccountDeletion.d.ts","sourceRoot":"","sources":["../../../src/server/better-auth/closeAccountDeletion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGrD,wBAAgB,oBAAoB,CAAC,QAAQ,SAAS,iBAAiB,EAAE,OAAO,EAAE,QAAQ,GAAG,QAAQ,CAEpG"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Identity's account module is the one way to delete an account, because Better Auth's deletion runs outside any transaction.
|
|
2
|
+
export function closeAccountDeletion(options) {
|
|
3
|
+
return { ...options, disabledPaths: [...(options.disabledPaths ?? []), "/delete-user", "/delete-user/callback", "/admin/remove-user"] };
|
|
4
|
+
}
|
|
5
|
+
//# sourceMappingURL=closeAccountDeletion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"closeAccountDeletion.js","sourceRoot":"","sources":["../../../src/server/better-auth/closeAccountDeletion.ts"],"names":[],"mappings":"AAEA,8HAA8H;AAC9H,MAAM,UAAU,oBAAoB,CAAqC,OAAiB;IACzF,OAAO,EAAE,GAAG,OAAO,EAAE,aAAa,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,aAAa,IAAI,EAAE,CAAC,EAAE,cAAc,EAAE,uBAAuB,EAAE,oBAAoB,CAAC,EAAE,CAAC;AACzI,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { BetterAuthOptions } from "better-auth";
|
|
2
|
+
import { Effect, Schema } from "effect";
|
|
3
|
+
import { SqlClient } from "effect/sql";
|
|
4
|
+
import { BadRequest, PreconditionFailed } from "@shivaedev/errors/taxonomy.ts";
|
|
5
|
+
import { SessionUser } from "#identity.ts";
|
|
6
|
+
export declare const confirmPassword: (options: BetterAuthOptions, password: string) => Effect.Effect<undefined, import("@shivaedev/errors/taxonomy.ts").AuthUnavailable | BadRequest | PreconditionFailed | Schema.SchemaError | import("effect/sql/SqlError").SqlError, SessionUser | SqlClient.SqlClient>;
|
|
7
|
+
//# sourceMappingURL=confirmPassword.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"confirmPassword.d.ts","sourceRoot":"","sources":["../../../src/server/better-auth/confirmPassword.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,OAAO,EAAE,MAAM,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,SAAS,EAAa,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAQ3C,eAAO,MAAM,eAAe,wQAuB1B,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { getAuthTables } from "better-auth/db";
|
|
2
|
+
import { Effect, Option, Schema } from "effect";
|
|
3
|
+
import { SqlClient, SqlSchema } from "effect/sql";
|
|
4
|
+
import { BadRequest, PreconditionFailed } from "@shivaedev/errors/taxonomy.ts";
|
|
5
|
+
import { SessionUser } from "#identity.ts";
|
|
6
|
+
import { passwordMatches } from "#server/better-auth/adapters/passwordMatches.ts";
|
|
7
|
+
// Better Auth's own limit when the options set none; a longer input is refused before it reaches the hash.
|
|
8
|
+
const MAX_PASSWORD_LENGTH = 128;
|
|
9
|
+
const Credential = Schema.Struct({ password: Schema.String });
|
|
10
|
+
export const confirmPassword = Effect.fn("Identity.confirmPassword")(function* (options, password) {
|
|
11
|
+
const { id: userId } = yield* SessionUser;
|
|
12
|
+
const { account } = getAuthTables(options);
|
|
13
|
+
const sql = (yield* SqlClient.SqlClient).withoutTransforms();
|
|
14
|
+
function column(field) {
|
|
15
|
+
return sql(account?.fields[field]?.fieldName ?? field);
|
|
16
|
+
}
|
|
17
|
+
const credential = yield* SqlSchema.findOneOption({
|
|
18
|
+
execute: (id) => sql `select ${column("password")} as password from ${sql(account?.modelName ?? "account")}
|
|
19
|
+
where ${column("userId")} = ${id} and ${column("providerId")} = 'credential' and ${column("password")} is not null`,
|
|
20
|
+
Request: Schema.String,
|
|
21
|
+
Result: Credential,
|
|
22
|
+
})(userId);
|
|
23
|
+
if (Option.isNone(credential)) {
|
|
24
|
+
return yield* new PreconditionFailed({ message: "This account has no password to confirm its deletion with." });
|
|
25
|
+
}
|
|
26
|
+
const maximum = options.emailAndPassword?.maxPasswordLength ?? MAX_PASSWORD_LENGTH;
|
|
27
|
+
if (password.length === 0 || password.length > maximum) {
|
|
28
|
+
return yield* new BadRequest({ field: "password", message: "Enter your current password." });
|
|
29
|
+
}
|
|
30
|
+
if (!(yield* passwordMatches(options, credential.value.password, password))) {
|
|
31
|
+
return yield* new BadRequest({ field: "password", message: "The password is incorrect." });
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
//# sourceMappingURL=confirmPassword.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"confirmPassword.js","sourceRoot":"","sources":["../../../src/server/better-auth/confirm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AS,IAAI,SAAS,CAAC;WAChG,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,MAAM,CAAC,YAAY,CAAC,uBAAuB,MAAM,CAAC,UAAU,CAAC,cAAc;QACpH,OAAO,EAAE,MAAM,CAAC,MAAM;QACtB,MAAM,EAAE,UAAU;KAClB,CAAC,CAAC,MAAM,CAAC,CAAC;IACX,IAAI,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;QAC/B,OAAO,KAAK,CAAC,CAAC,IAAI,kBAAkB,CAAC,EAAE,OAAO,EAAE,4DAA4D,EAAE,CAAC,CAAC;IACjH,CAAC;IACD,MAAM,OAAO,GAAG,OAAO,CAAC,gBAAgB,EAAE,iBAAiB,IAAI,mBAAmB,CAAC;IACnF,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,IAAI,QAAQ,CAAC,MAAM,GAAG,OAAO,EAAE,CAAC;QACxD,OAAO,KAAK,CAAC,CAAC,IAAI,UAAU,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,8BAA8B,EAAE,CAAC,CAAC;IAC9F,CAAC;IACD,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,eAAe,CAAC,OAAO,EAAE,UAAU,CAAC,KAAK,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC;QAC7E,OAAO,KAAK,CAAC,CAAC,IAAI,UAAU,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,4BAA4B,EAAE,CAAC,CAAC;IAC5F,CAAC;AACF,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { SessionUser } from "#identity.ts";
|
|
3
|
+
import { AccountDeletionPolicy } from "#server/better-auth/AccountDeletionPolicy.ts";
|
|
4
|
+
export declare const deleteAccount: (password: string) => Effect.Effect<void, import("@shivaedev/errors/taxonomy.ts").AuthUnavailable | import("@shivaedev/errors/taxonomy.ts").BadRequest | import("@shivaedev/errors/taxonomy.ts").PreconditionFailed | import("effect/Schema").SchemaError | import("effect/sql/SqlError").SqlError | import("@shivaedev/rate-limit/Store.ts").StoreError | import("@shivaedev/errors/taxonomy.ts").TooManyRequests, AccountDeletionPolicy | SessionUser | import("@shivaedev/rate-limit/Store.ts").Store | (import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient)>;
|
|
5
|
+
//# sourceMappingURL=deleteAccount.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deleteAccount.d.ts","sourceRoot":"","sources":["../../../src/server/better-auth/deleteAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAQrF,eAAO,MAAM,aAAa,4kBAcxB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { invalidationKeys } from "@shivaedev/changes/keys.ts";
|
|
3
|
+
import { rateLimit } from "@shivaedev/rate-limit/rateLimit.ts";
|
|
4
|
+
import { invalidateOnCommit, transact } from "@shivaedev/sql/transact.ts";
|
|
5
|
+
import { SessionUser } from "#identity.ts";
|
|
6
|
+
import { AccountDeletionPolicy } from "#server/better-auth/AccountDeletionPolicy.ts";
|
|
7
|
+
import { accountData } from "#server/better-auth/accountData.ts";
|
|
8
|
+
import { confirmPassword } from "#server/better-auth/confirmPassword.ts";
|
|
9
|
+
import { deleteUserRows } from "#server/better-auth/deleteUserRows.ts";
|
|
10
|
+
import { sessionKeys } from "#signedInSessions.ts";
|
|
11
|
+
import { userKeys } from "#users.ts";
|
|
12
|
+
// An erase that cannot run is the operator's to fix, so its failure is reported with its tables rather than answered to the person.
|
|
13
|
+
export const deleteAccount = Effect.fn("Identity.deleteAccount")(function* (password) {
|
|
14
|
+
const { id } = yield* SessionUser;
|
|
15
|
+
const { auth, handOver } = yield* AccountDeletionPolicy;
|
|
16
|
+
// Better Auth's own budget for its password-checked routes such as /change-email, kept per person rather than per address.
|
|
17
|
+
yield* rateLimit({ key: `identity.account.delete:${id}`, per: 3, window: "10 seconds" });
|
|
18
|
+
yield* confirmPassword(auth.options, password);
|
|
19
|
+
yield* Effect.gen(function* () {
|
|
20
|
+
yield* handOver(id);
|
|
21
|
+
yield* accountData(auth)
|
|
22
|
+
.eraseOwnedRows(id)
|
|
23
|
+
.pipe(Effect.catchTags({ OwnedModelsUncollected: Effect.die, OwnedTableCycle: Effect.die, UncoveredUserColumns: Effect.die }));
|
|
24
|
+
yield* deleteUserRows(auth.options);
|
|
25
|
+
yield* invalidateOnCommit(invalidationKeys([userKeys.item(id), sessionKeys.list]));
|
|
26
|
+
}).pipe(transact());
|
|
27
|
+
});
|
|
28
|
+
//# sourceMappingURL=deleteAccount.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deleteAccount.js","sourceRoot":"","sources":["../../../src/server/better-auth/deleteAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,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AAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { BetterAuthOptions } from "better-auth";
|
|
2
|
+
import { Effect } from "effect";
|
|
3
|
+
import { SqlClient } from "effect/sql";
|
|
4
|
+
import { SessionUser } from "#identity.ts";
|
|
5
|
+
export declare const deleteUserRows: (options: BetterAuthOptions) => Effect.Effect<void, import("effect/sql/SqlError").SqlError, SessionUser | SqlClient.SqlClient>;
|
|
6
|
+
//# sourceMappingURL=deleteUserRows.d.ts.map
|