@shivaedev/identity 0.40.0 → 0.42.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 +16 -0
- package/README.md +47 -8
- package/dist/Account.d.ts +17 -0
- package/dist/Account.d.ts.map +1 -0
- package/dist/Account.js +19 -0
- package/dist/Account.js.map +1 -0
- package/dist/accountPreferenceHeaders.d.ts +5 -0
- package/dist/accountPreferenceHeaders.d.ts.map +1 -0
- package/dist/accountPreferenceHeaders.js +5 -0
- package/dist/accountPreferenceHeaders.js.map +1 -0
- package/dist/client/preferencesPlugin.d.ts +17 -0
- package/dist/client/preferencesPlugin.d.ts.map +1 -0
- package/dist/{server/better-auth/preferencesClient.js → client/preferencesPlugin.js} +7 -7
- package/dist/client/preferencesPlugin.js.map +1 -0
- package/dist/generated/Account.d.ts +26 -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/server/AccountDeletion.d.ts +11 -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 +13 -0
- package/dist/server/better-auth/accountDeletion.d.ts.map +1 -0
- package/dist/server/better-auth/accountDeletion.js +22 -0
- package/dist/server/better-auth/accountDeletion.js.map +1 -0
- package/dist/server/better-auth/adapters/accountPreferenceOptions.d.ts.map +1 -1
- package/dist/server/better-auth/adapters/accountPreferenceOptions.js +3 -2
- package/dist/server/better-auth/adapters/accountPreferenceOptions.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 +25 -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/package.json +6 -6
- package/src/Account.ts +20 -0
- package/src/accountPreferenceHeaders.ts +4 -0
- package/src/client/preferencesPlugin.ts +40 -0
- package/src/generated/Account.ts +23 -0
- package/src/server/AccountDeletion.ts +14 -0
- package/src/server/better-auth/AccountDeletionPolicy.ts +10 -0
- package/src/server/better-auth/accountDeletion.ts +41 -0
- package/src/server/better-auth/adapters/accountPreferenceOptions.ts +3 -2
- 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 +25 -0
- package/src/server/better-auth/deleteUserRows.ts +21 -0
- package/src/server/better-auth/mount.ts +3 -1
- package/dist/server/better-auth/preferencesClient.d.ts +0 -3
- package/dist/server/better-auth/preferencesClient.d.ts.map +0 -1
- package/dist/server/better-auth/preferencesClient.js.map +0 -1
- package/src/server/better-auth/preferencesClient.ts +0 -25
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.42.0 - 2026-11-21
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- `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`.
|
|
8
|
+
|
|
9
|
+
### Breaking
|
|
10
|
+
|
|
11
|
+
- 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.
|
|
12
|
+
|
|
13
|
+
## 0.41.0 - 2026-11-21
|
|
14
|
+
|
|
15
|
+
### Breaking
|
|
16
|
+
|
|
17
|
+
- The account preferences plugin moves to a browser-safe path and a new name. Replace `import { preferencesClient } from "@shivaedev/identity/server/better-auth/preferencesClient.ts"` with `import { preferencesPlugin } from "@shivaedev/identity/client/preferencesPlugin.ts"` and call `preferencesPlugin()` where you called `preferencesClient()`. Its header names come from `accountPreferenceHeaders` in `@shivaedev/identity/accountPreferenceHeaders.ts`.
|
|
18
|
+
|
|
3
19
|
## 0.40.0 - 2026-11-21
|
|
4
20
|
|
|
5
21
|
### Added
|
package/README.md
CHANGED
|
@@ -145,16 +145,16 @@ export const preferencesModule = {
|
|
|
145
145
|
} satisfies AppModule;
|
|
146
146
|
```
|
|
147
147
|
|
|
148
|
-
To capture
|
|
148
|
+
To capture a client's defaults, enable `{ accountPreferences: true }` in `betterAuthMount` and install the Better Auth client plugin from `@shivaedev/identity/client/preferencesPlugin.ts`, which holds no server code:
|
|
149
149
|
|
|
150
150
|
```ts
|
|
151
151
|
import { createAuthClient } from "better-auth/client";
|
|
152
|
-
import {
|
|
152
|
+
import { preferencesPlugin } from "@shivaedev/identity/client/preferencesPlugin.ts";
|
|
153
153
|
|
|
154
|
-
export const auth = createAuthClient({ plugins: [
|
|
154
|
+
export const auth = createAuthClient({ plugins: [preferencesPlugin()] });
|
|
155
155
|
```
|
|
156
156
|
|
|
157
|
-
The
|
|
157
|
+
The client sends its `Intl.DateTimeFormat` timezone and locale to the auth mount in the `x-platform-account-timezone` and `x-platform-account-locale` headers, whose names `accountPreferenceHeaders` from `@shivaedev/identity/accountPreferenceHeaders.ts` exports. It sends them only where a global `window` exists, as in a browser, a WebView or React Native, so a server-side auth call does not report the server's zone. A successful first sign-in captures those values with metric units. After redirect-based sign-in, the client's first `getSession` captures them. Missing or invalid timezone data leaves preferences uncaptured; a later session can capture them. A bundled native shell installs the same plugin (see [Bundled native clients](#bundled-native-clients)). Clients without a Better Auth client can call the `capture` contract with their own defaults.
|
|
158
158
|
|
|
159
159
|
`AccountClock` from `@shivaedev/identity/server/account-clock/service.ts` is a per-request service. Its Layer requires `Subject`, and its initializer captures that subject's saved timezone. Register that Layer in the host's `requestServices` slot and `accountPreferencesStore` in global `services`. Each new request sees the current saved timezone. Configure `AccountDayStart` from `@shivaedev/identity/server/account-clock/settings.ts` in minutes after local midnight; it defaults to zero and accepts integers from 0 through 1439. The same module exports `LogicalDay`.
|
|
160
160
|
|
|
@@ -559,16 +559,20 @@ export const secureCredential = Layer.succeed(SessionCredential, {
|
|
|
559
559
|
});
|
|
560
560
|
```
|
|
561
561
|
|
|
562
|
-
Pass that Layer to the Better Auth client as a plugin, and to `makeClient` through `storedCredential
|
|
562
|
+
Pass that Layer to the Better Auth client as a plugin, and to `makeClient` through `storedCredential`. When the mount captures [account preferences](#account-preferences-and-logical-days), install the same `preferencesPlugin()` the browser uses on the native auth client too, so the device's timezone and locale are captured at sign-in:
|
|
563
563
|
|
|
564
564
|
```ts
|
|
565
565
|
import { createAuthClient } from "better-auth/client";
|
|
566
566
|
import { Effect } from "effect";
|
|
567
567
|
import { makeClient } from "@shivaedev/contract/makeClient.ts";
|
|
568
568
|
import { sessionCredentialPlugin } from "@shivaedev/identity/client/adapters/sessionCredentialPlugin.ts";
|
|
569
|
+
import { preferencesPlugin } from "@shivaedev/identity/client/preferencesPlugin.ts";
|
|
569
570
|
import { storedCredential } from "@shivaedev/identity/client/SessionCredential.ts";
|
|
570
571
|
|
|
571
|
-
export const authClient = createAuthClient({
|
|
572
|
+
export const authClient = createAuthClient({
|
|
573
|
+
baseURL: publicOrigin,
|
|
574
|
+
plugins: [sessionCredentialPlugin(secureCredential), preferencesPlugin()],
|
|
575
|
+
});
|
|
572
576
|
const client = makeClient(contracts, { bearerToken: Effect.provide(storedCredential, secureCredential), registry, url: `${publicOrigin}/rpc` });
|
|
573
577
|
```
|
|
574
578
|
|
|
@@ -578,7 +582,7 @@ Native sign-out revokes the stored session. Signing in again while sending the c
|
|
|
578
582
|
|
|
579
583
|
Use `nativeOrigins` for bundled clients so their transport remains credential-free; other declared origins follow the sibling browser policy above.
|
|
580
584
|
|
|
581
|
-
The host answers native preflights with POST for RPC, GET and POST for auth
|
|
585
|
+
The host answers native preflights with POST for RPC, GET and POST for auth. RPC allows only the `Authorization` and `Content-Type` headers; auth also allows the two account preference headers, for native and sibling browser origins alike. Native responses echo the allowed origin exactly with `Vary: Origin`; auth responses expose `set-auth-token`. Native responses never enable CORS credentials. It strips cookies from admitted native requests before auth or RPC session resolution, so only the signed bearer session can authenticate them. This prevents native access from opening a cookie CSRF path, even if a caller sends a cookie. Resource authorization remains app-owned.
|
|
582
586
|
|
|
583
587
|
A WebView's live queries subscribe over the shared WebSocket client. `storedCredential` reads the port each time the socket connects: contract's `makeClient` sends the credential stored then as the socket's first frame, as the [contract guide](https://github.com/ShivaeDev/platform/blob/main/packages/contract/README.md#build-a-shared-websocket-client) describes, and connects without one when none is stored. A new client after each sign-in, sign-out or second sign-in, as React's `SessionBoundary` makes one per session, therefore carries the current credential. The host refuses a query's change stream over HTTP with `WebSocketRequired`. Over HTTP, use the WebView's own fetch with `credentials: "omit"` for commands, one-off reads and explicit NDJSON streams, and abort a stream's request to release server work; a buffering native HTTP bridge cannot deliver a stream incrementally. The host still validates trusted proxy peers and forwarded authority, enforces NDJSON and body limits, uses only transport credentials, redacts diagnostics and authorizes sessions. Native HTTP callers without an Origin can exercise bearer RPC with an origin policy that explicitly permits missing Origins.
|
|
584
588
|
|
|
@@ -1077,7 +1081,7 @@ const eraseOwnedRows = data.eraseOwnedRows;
|
|
|
1077
1081
|
|
|
1078
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.
|
|
1079
1083
|
|
|
1080
|
-
`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.
|
|
1081
1085
|
|
|
1082
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.
|
|
1083
1087
|
|
|
@@ -1091,6 +1095,38 @@ Outside a host, a job or script must provide `collectRepositoryModels` itself an
|
|
|
1091
1095
|
|
|
1092
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.
|
|
1093
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, 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 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.
|
|
1105
|
+
2. 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.
|
|
1106
|
+
3. 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`.
|
|
1107
|
+
|
|
1108
|
+
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:
|
|
1109
|
+
|
|
1110
|
+
```ts
|
|
1111
|
+
import { Layer } from "effect";
|
|
1112
|
+
import { Account } from "@shivaedev/identity/Account.ts";
|
|
1113
|
+
import { accountDeletion } from "@shivaedev/identity/server/better-auth/accountDeletion.ts";
|
|
1114
|
+
import type { AppModule } from "@shivaedev/server/AppModule.ts";
|
|
1115
|
+
import { AppAuth } from "#server/AppAuth.ts";
|
|
1116
|
+
import { HouseholdHandOver } from "#server/households/handOver/service.ts";
|
|
1117
|
+
|
|
1118
|
+
export const accountRegistration = {
|
|
1119
|
+
module: Account,
|
|
1120
|
+
services: accountDeletion(AppAuth, { handOver: HouseholdHandOver }).pipe(Layer.provide(HouseholdHandOver.layer)),
|
|
1121
|
+
} satisfies AppModule;
|
|
1122
|
+
```
|
|
1123
|
+
|
|
1124
|
+
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.
|
|
1125
|
+
|
|
1126
|
+
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.
|
|
1127
|
+
|
|
1128
|
+
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.
|
|
1129
|
+
|
|
1094
1130
|
### Signed-in story preconditions
|
|
1095
1131
|
|
|
1096
1132
|
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:
|
|
@@ -1230,6 +1266,9 @@ Import the module that defines the name; there is no package-root entry. Paths b
|
|
|
1230
1266
|
| `server/better-auth/adapters/revokeUnadmitted.ts` | `RevokedSessions`: the `{ users, sessions }` counts of a revocation. |
|
|
1231
1267
|
| `server/better-auth/userProfiles.ts` | Public profile lookups for other users. |
|
|
1232
1268
|
| `server/better-auth/sweepExpiredSessions.ts` | `sweepExpiredSessions`: delete expired sessions through the application's SQL client and return the number removed. |
|
|
1269
|
+
| `Account.ts` | `Account`: the defined module whose `delete` command deletes the signed-in person's account after confirming their password. |
|
|
1270
|
+
| `server/AccountDeletion.ts` | `AccountDeletion`: the port the account module's `delete` command calls. |
|
|
1271
|
+
| `server/better-auth/accountDeletion.ts` | `accountDeletion(declaration, { handOver? })`, `AccountHandOver`: the Better Auth `AccountDeletion` Layer and the shape of the application's hand-over service. |
|
|
1233
1272
|
| `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. |
|
|
1234
1273
|
| `server/account-data/UncoveredUserColumns.ts` | `UncoveredUserColumns`: the coverage failure naming each column that refers to a person without an owned model to cover it. |
|
|
1235
1274
|
| `server/account-data/OwnedModelsUncollected.ts` | `OwnedModelsUncollected`: the failure of export, erase and check when no collector records the owned models. |
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
}, 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, 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", {
|
|
13
|
+
password: Schema.String;
|
|
14
|
+
}, 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("./identity.ts").SessionUser> | import("effect/Effect").Effect<{
|
|
15
|
+
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("./identity.ts").SessionUser>;
|
|
16
|
+
}, never, AccountDeletion>, void>], typeof AuthenticatedUser, undefined>, typeof AuthenticatedUser, undefined, undefined>;
|
|
17
|
+
//# 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 @@
|
|
|
1
|
+
{"version":3,"file":"accountPreferenceHeaders.d.ts","sourceRoot":"","sources":["../src/accountPreferenceHeaders.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,wBAAwB;aACpC,MAAM,EAAE,2BAA2B;aACnC,QAAQ,EAAE,6BAA6B;CAC9B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accountPreferenceHeaders.js","sourceRoot":"","sources":["../src/accountPreferenceHeaders.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACvC,MAAM,EAAE,2BAA2B;IACnC,QAAQ,EAAE,6BAA6B;CAC9B,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
interface PreferenceRequest {
|
|
2
|
+
readonly headers: Headers;
|
|
3
|
+
}
|
|
4
|
+
interface PreferenceFetchPlugin {
|
|
5
|
+
readonly hooks: {
|
|
6
|
+
readonly onRequest: (context: PreferenceRequest) => void;
|
|
7
|
+
};
|
|
8
|
+
readonly id: string;
|
|
9
|
+
readonly name: string;
|
|
10
|
+
}
|
|
11
|
+
export interface PreferencesPlugin {
|
|
12
|
+
readonly fetchPlugins: PreferenceFetchPlugin[];
|
|
13
|
+
readonly id: "identity-account-preferences";
|
|
14
|
+
}
|
|
15
|
+
export declare function preferencesPlugin(): PreferencesPlugin;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=preferencesPlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preferencesPlugin.d.ts","sourceRoot":"","sources":["../../src/client/preferencesPlugin.ts"],"names":[],"mappings":"AAGA,UAAU,iBAAiB;IAC1B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC1B;AAED,UAAU,qBAAqB;IAC9B,QAAQ,CAAC,KAAK,EAAE;QAAE,QAAQ,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,IAAI,CAAA;KAAE,CAAC;IAC7E,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,iBAAiB;IACjC,QAAQ,CAAC,YAAY,EAAE,qBAAqB,EAAE,CAAC;IAC/C,QAAQ,CAAC,EAAE,EAAE,8BAA8B,CAAC;CAC5C;AAED,wBAAgB,iBAAiB,IAAI,iBAAiB,CAqBrD"}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
import { accountPreferenceHeaders } from "#accountPreferenceHeaders.ts";
|
|
2
|
+
export function preferencesPlugin() {
|
|
2
3
|
return {
|
|
3
4
|
fetchPlugins: [
|
|
4
5
|
{
|
|
5
6
|
hooks: {
|
|
6
7
|
onRequest(context) {
|
|
8
|
+
// A server-rendered auth call would send the server's zone, so only a page or app shell sends one.
|
|
7
9
|
if (!("window" in globalThis)) {
|
|
8
|
-
return
|
|
10
|
+
return;
|
|
9
11
|
}
|
|
10
12
|
const { locale, timeZone } = new Intl.DateTimeFormat().resolvedOptions();
|
|
11
|
-
|
|
12
|
-
headers.set(
|
|
13
|
-
headers.set("x-platform-account-locale", locale);
|
|
14
|
-
return { ...context, headers };
|
|
13
|
+
context.headers.set(accountPreferenceHeaders.timezone, timeZone);
|
|
14
|
+
context.headers.set(accountPreferenceHeaders.locale, locale);
|
|
15
15
|
},
|
|
16
16
|
},
|
|
17
17
|
id: "identity-account-preferences",
|
|
@@ -21,4 +21,4 @@ export function preferencesClient() {
|
|
|
21
21
|
id: "identity-account-preferences",
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
-
//# sourceMappingURL=
|
|
24
|
+
//# sourceMappingURL=preferencesPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preferencesPlugin.js","sourceRoot":"","sources":["../../src/client/preferencesPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAkBxE,MAAM,UAAU,iBAAiB;IAChC,OAAO;QACN,YAAY,EAAE;YACb;gBACC,KAAK,EAAE;oBACN,SAAS,CAAC,OAAO;wBAChB,mGAAmG;wBACnG,IAAI,CAAC,CAAC,QAAQ,IAAI,UAAU,CAAC,EAAE,CAAC;4BAC/B,OAAO;wBACR,CAAC;wBACD,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC,eAAe,EAAE,CAAC;wBACzE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;wBACjE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;oBAC9D,CAAC;iBACD;gBACD,EAAE,EAAE,8BAA8B;gBAClC,IAAI,EAAE,8BAA8B;aACpC;SACD;QACD,EAAE,EAAE,8BAA8B;KAClC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
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 } 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
|
+
};
|
|
13
|
+
readonly success: Schema.Void;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export declare const Account: import("@shivaedev/contract/defineModule.ts").ModuleContract<"identity.account", readonly import("@shivaedev/contract/operation.ts").Command<"delete", Schema.Struct<{
|
|
17
|
+
readonly password: Schema.String;
|
|
18
|
+
}>, Schema.Void, {
|
|
19
|
+
readonly InternalServerError: typeof import("@shivaedev/errors/taxonomy.ts").InternalServerError;
|
|
20
|
+
readonly ServiceUnavailable: typeof import("@shivaedev/errors/taxonomy.ts").ServiceUnavailable;
|
|
21
|
+
readonly AuthUnavailable: typeof AuthUnavailable;
|
|
22
|
+
readonly BadRequest: typeof BadRequest;
|
|
23
|
+
readonly PreconditionFailed: typeof PreconditionFailed;
|
|
24
|
+
}>[], typeof AuthenticatedUser, undefined, undefined>;
|
|
25
|
+
export declare const identityAccountMatchModule: ClientMatchesModule<typeof Account, typeof AccountModule>;
|
|
26
|
+
//# 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,MAAM,+BAA+B,CAAC;AAChG,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 } from "@shivaedev/errors/taxonomy.ts";
|
|
4
|
+
import { Schema } from "effect";
|
|
5
|
+
export const identityAccountWire = {
|
|
6
|
+
delete: { rejections: { AuthUnavailable, BadRequest, PreconditionFailed }, 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,MAAM,+BAA+B,CAAC;AAChG,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,OAAO,EAAE,MAAM,CAAC,IAAI,EAAE;CACxF,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"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Context, type Effect, type Schema } from "effect";
|
|
2
|
+
import type { SqlError } from "effect/sql/SqlError";
|
|
3
|
+
import type { AuthUnavailable, BadRequest, PreconditionFailed } from "@shivaedev/errors/taxonomy.ts";
|
|
4
|
+
import type { SessionUser } from "#identity.ts";
|
|
5
|
+
declare const AccountDeletion_base: Context.ServiceClass<AccountDeletion, "@shivaedev/identity/AccountDeletion", {
|
|
6
|
+
readonly delete: (password: string) => Effect.Effect<void, AuthUnavailable | BadRequest | PreconditionFailed | Schema.SchemaError | SqlError, SessionUser>;
|
|
7
|
+
}>;
|
|
8
|
+
export declare class AccountDeletion extends AccountDeletion_base {
|
|
9
|
+
}
|
|
10
|
+
export {};
|
|
11
|
+
//# 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,MAAM,+BAA+B,CAAC;AACrG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;;qBAM7B,CAChB,QAAQ,EAAE,MAAM,KACZ,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,eAAe,GAAG,UAAU,GAAG,kBAAkB,GAAG,MAAM,CAAC,WAAW,GAAG,QAAQ,EAAE,WAAW,CAAC;;AAL1H,qBAAa,eAAgB,SAAQ,oBAOK;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;AAK3D,oGAAoG;AACpG,MAAM,OAAO,eAAgB,SAAQ,OAAO,CAAC,OAAO,EAOjD,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,13 @@
|
|
|
1
|
+
import { type Context, Effect, Layer } from "effect";
|
|
2
|
+
import * as Reactivity from "effect/reactivity/Reactivity";
|
|
3
|
+
import { SqlClient } from "effect/sql";
|
|
4
|
+
import { AccountDeletion } from "#server/AccountDeletion.ts";
|
|
5
|
+
import type { AuthSchemaDeclaration } from "#server/better-auth/define.ts";
|
|
6
|
+
export interface AccountHandOver<E> {
|
|
7
|
+
readonly handOver: (userId: string) => Effect.Effect<void, E>;
|
|
8
|
+
}
|
|
9
|
+
export interface AccountDeletionOptions<TIdentifier, E> {
|
|
10
|
+
readonly handOver?: Context.Service<TIdentifier, AccountHandOver<E>> | undefined;
|
|
11
|
+
}
|
|
12
|
+
export declare function accountDeletion<TIdentifier = never, E = never>(auth: Pick<AuthSchemaDeclaration, "options">, options?: AccountDeletionOptions<TIdentifier, E>): Layer.Layer<AccountDeletion, never, Reactivity.Reactivity | SqlClient.SqlClient | Exclude<TIdentifier, import("effect/Scope").Scope>>;
|
|
13
|
+
//# 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,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,yIAqBpD"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Effect, Layer } from "effect";
|
|
2
|
+
import * as Reactivity from "effect/reactivity/Reactivity";
|
|
3
|
+
import { SqlClient } from "effect/sql";
|
|
4
|
+
import { AccountDeletion } from "#server/AccountDeletion.ts";
|
|
5
|
+
import { AccountDeletionPolicy } from "#server/better-auth/AccountDeletionPolicy.ts";
|
|
6
|
+
import { deleteAccount } from "#server/better-auth/deleteAccount.ts";
|
|
7
|
+
// A hand-over's failure is the application's to fix, so it is reported rather than answered to the person.
|
|
8
|
+
export function accountDeletion(auth, options = {}) {
|
|
9
|
+
return Layer.effect(AccountDeletion)(Effect.gen(function* () {
|
|
10
|
+
const sql = yield* SqlClient.SqlClient;
|
|
11
|
+
const reactivity = yield* Reactivity.Reactivity;
|
|
12
|
+
const service = options.handOver === undefined ? undefined : yield* options.handOver;
|
|
13
|
+
const policy = {
|
|
14
|
+
auth,
|
|
15
|
+
handOver: (userId) => (service === undefined ? Effect.void : Effect.orDie(service.handOver(userId))),
|
|
16
|
+
};
|
|
17
|
+
return AccountDeletion.of({
|
|
18
|
+
delete: (password) => deleteAccount(password).pipe(Effect.provideService(AccountDeletionPolicy, policy), Effect.provideService(SqlClient.SqlClient, sql), Effect.provideService(Reactivity.Reactivity, reactivity)),
|
|
19
|
+
});
|
|
20
|
+
}));
|
|
21
|
+
}
|
|
22
|
+
//# 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,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,UAAU,eAAe,CAC9B,IAA4C,EAC5C,OAAO,GAA2C,EAAE;IAEpD,OAAO,KAAK,CAAC,MAAM,CAAC,eAAe,CAAC,CACnC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QACnB,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC;QACvC,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC;QAChD,MAAM,OAAO,GAAG,OAAO,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;QACrF,MAAM,MAAM,GAAG;YACd,IAAI;YACJ,QAAQ,EAAE,CAAC,MAAc,EAAE,EAAE,CAAC,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;SAC5G,CAAC;QACF,OAAO,eAAe,CAAC,EAAE,CAAC;YACzB,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE,CACpB,aAAa,CAAC,QAAQ,CAAC,CAAC,IAAI,CAC3B,MAAM,CAAC,cAAc,CAAC,qBAAqB,EAAE,MAAM,CAAC,EACpD,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC,SAAS,EAAE,GAAG,CAAC,EAC/C,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,UAAU,EAAE,UAAU,CAAC,CACxD;SACF,CAAC,CAAC;IACJ,CAAC,CAAC,CACF,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accountPreferenceOptions.d.ts","sourceRoot":"","sources":["../../../../src/server/better-auth/adapters/accountPreferenceOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEvE,OAAO,EAAE,MAAM,EAAkB,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"accountPreferenceOptions.d.ts","sourceRoot":"","sources":["../../../../src/server/better-auth/adapters/accountPreferenceOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEvE,OAAO,EAAE,MAAM,EAAkB,MAAM,QAAQ,CAAC;AAKhD,eAAO,MAAM,wBAAwB,GAAgC,QAAQ,SAAS,iBAAiB;;;;;;;;;;wDA0BrG,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createAuthMiddleware } from "better-auth/api";
|
|
2
2
|
import { Effect, Option, Schema } from "effect";
|
|
3
|
+
import { accountPreferenceHeaders } from "#accountPreferenceHeaders.ts";
|
|
3
4
|
import { AccountPreferenceValues } from "#accountPreferenceValues.ts";
|
|
4
5
|
import { AccountPreferencesStore } from "#server/account-preferences/service.ts";
|
|
5
6
|
export const accountPreferenceOptions = Effect.fnUntraced(function* (options) {
|
|
@@ -8,8 +9,8 @@ export const accountPreferenceOptions = Effect.fnUntraced(function* (options) {
|
|
|
8
9
|
const capture = createAuthMiddleware(async (context) => {
|
|
9
10
|
const session = context.context.newSession ?? context.context.session;
|
|
10
11
|
const values = Schema.decodeUnknownOption(AccountPreferenceValues)({
|
|
11
|
-
locale: context.headers?.get(
|
|
12
|
-
timezone: context.headers?.get(
|
|
12
|
+
locale: context.headers?.get(accountPreferenceHeaders.locale),
|
|
13
|
+
timezone: context.headers?.get(accountPreferenceHeaders.timezone),
|
|
13
14
|
units: "metric",
|
|
14
15
|
});
|
|
15
16
|
if (session !== null && session !== undefined && Option.isSome(values)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accountPreferenceOptions.js","sourceRoot":"","sources":["../../../../src/server/better-auth/adapters/accountPreferenceOptions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AAEjF,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAsC,OAAiB;IACzH,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,uBAAuB,CAAC;IAC7C,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,EAAS,CAAC;IAChD,MAAM,OAAO,GAAG,oBAAoB,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;QACtD,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC;QACtE,MAAM,MAAM,GAAG,MAAM,CAAC,mBAAmB,CAAC,uBAAuB,CAAC,CAAC;YAClE,MAAM,EAAE,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"accountPreferenceOptions.js","sourceRoot":"","sources":["../../../../src/server/better-auth/adapters/accountPreferenceOptions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AAEjF,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAsC,OAAiB;IACzH,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,uBAAuB,CAAC;IAC7C,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,EAAS,CAAC;IAChD,MAAM,OAAO,GAAG,oBAAoB,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;QACtD,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC;QACtE,MAAM,MAAM,GAAG,MAAM,CAAC,mBAAmB,CAAC,uBAAuB,CAAC,CAAC;YAClE,MAAM,EAAE,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,wBAAwB,CAAC,MAAM,CAAC;YAC7D,QAAQ,EAAE,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,wBAAwB,CAAC,QAAQ,CAAC;YACjE,KAAK,EAAE,QAAQ;SACf,CAAC,CAAC;QACH,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,SAAS,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;YACxE,MAAM,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;QAC1H,CAAC;IACF,CAAC,CAAC,CAAC;IACH,MAAM,MAAM,GAAG;QACd,KAAK,EAAE;YACN,KAAK,EAAE;gBACN;oBACC,OAAO,EAAE,OAAO;oBAChB,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,cAAc,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,KAAK,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC,UAAU,KAAK,SAAS,CAAC;iBAC1I;aACD;SACD;QACD,EAAE,EAAE,8BAA8B;KACP,CAAC;IAC7B,OAAO,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,EAAE,MAAM,CAAC,EAA8B,CAAC;AAClG,CAAC,CAAC,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/confirmPassword.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,iDAAiD,CAAC;AAElF,2GAA2G;AAC3G,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAEhC,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;AAE9D,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,EAAE,CAAC,0BAA0B,CAAC,CAAC,QAAQ,CAAC,EAAE,OAA0B,EAAE,QAAgB;IAC3H,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,WAAW,CAAC;IAC1C,MAAM,EAAE,OAAO,EAAE,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IAC3C,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,iBAAiB,EAAE,CAAC;IAC7D,SAAS,MAAM,CAAC,KAA2C;QAC1D,OAAO,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,SAAS,IAAI,KAAK,CAAC,CAAC;IACxD,CAAC;IACD,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,SAAS,CAAC,aAAa,CAAC;QACjD,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,CAAA,UAAU,MAAM,CAAC,UAAU,CAAC,qBAAqB,GAAG,CAAC,OAAO,EAAE,SAAS,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, AccountDeletionPolicy | SessionUser | (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;AAGhC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAQrF,eAAO,MAAM,aAAa,2aAYxB,CAAC"}
|