@yielded/auth-persistence-drizzle 0.1.0-beta.0 → 0.1.0-beta.12
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/README.md +6 -1
- package/dist/D1.d.mts +155 -40
- package/dist/D1.mjs +10 -6
- package/dist/D1.mjs.map +1 -1
- package/dist/Libsql.d.mts +251 -129
- package/dist/Libsql.mjs +20 -21
- package/dist/Libsql.mjs.map +1 -1
- package/dist/Mysql2.d.mts +208 -56
- package/dist/Mysql2.mjs +13 -8
- package/dist/Mysql2.mjs.map +1 -1
- package/dist/Pglite.d.mts +209 -57
- package/dist/Pglite.mjs +13 -9
- package/dist/Pglite.mjs.map +1 -1
- package/dist/Postgres.d.mts +207 -55
- package/dist/Postgres.mjs +13 -9
- package/dist/Postgres.mjs.map +1 -1
- package/dist/SqliteBun.d.mts +249 -126
- package/dist/SqliteBun.mjs +20 -18
- package/dist/SqliteBun.mjs.map +1 -1
- package/dist/SqliteDo.d.mts +248 -158
- package/dist/SqliteDo.mjs +26 -44
- package/dist/SqliteDo.mjs.map +1 -1
- package/dist/SqliteNode.d.mts +247 -124
- package/dist/SqliteNode.mjs +20 -18
- package/dist/SqliteNode.mjs.map +1 -1
- package/dist/SqliteWasm.d.mts +251 -128
- package/dist/SqliteWasm.mjs +20 -18
- package/dist/SqliteWasm.mjs.map +1 -1
- package/dist/drizzle/D1BatchStatements.d.mts +1 -1
- package/dist/drizzle/D1BatchStatements.mjs.map +1 -1
- package/dist/drizzle/d1-database.d.mts +11 -0
- package/dist/drizzle/d1-database.mjs +8 -0
- package/dist/drizzle/d1-database.mjs.map +1 -0
- package/dist/drizzle/d1-emails.d.mts +8 -7
- package/dist/drizzle/d1-emails.mjs +7 -4
- package/dist/drizzle/d1-emails.mjs.map +1 -1
- package/dist/drizzle/d1-generated-statement.mjs.map +1 -1
- package/dist/drizzle/d1-identity.mjs +12 -9
- package/dist/drizzle/d1-identity.mjs.map +1 -1
- package/dist/drizzle/d1-oauth.d.mts +41 -10
- package/dist/drizzle/d1-oauth.mjs +8 -5
- package/dist/drizzle/d1-oauth.mjs.map +1 -1
- package/dist/drizzle/d1-passkey.d.mts +3 -14
- package/dist/drizzle/d1-passkey.mjs +2 -1
- package/dist/drizzle/d1-passkey.mjs.map +1 -1
- package/dist/drizzle/d1-password-prepared.d.mts +4 -3
- package/dist/drizzle/d1-password-prepared.mjs +3 -1
- package/dist/drizzle/d1-password-prepared.mjs.map +1 -1
- package/dist/drizzle/d1-passwords.d.mts +7 -6
- package/dist/drizzle/d1-passwords.mjs +5 -2
- package/dist/drizzle/d1-passwords.mjs.map +1 -1
- package/dist/drizzle/d1-phone.d.mts +3 -4
- package/dist/drizzle/d1-phone.mjs +2 -1
- package/dist/drizzle/d1-phone.mjs.map +1 -1
- package/dist/drizzle/d1-planning.d.mts +1 -1
- package/dist/drizzle/d1-proofs.d.mts +5 -4
- package/dist/drizzle/d1-proofs.mjs +3 -1
- package/dist/drizzle/d1-proofs.mjs.map +1 -1
- package/dist/drizzle/d1-sessions.d.mts +14 -13
- package/dist/drizzle/d1-sessions.mjs +15 -9
- package/dist/drizzle/d1-sessions.mjs.map +1 -1
- package/dist/drizzle/d1-totp.d.mts +3 -4
- package/dist/drizzle/d1-totp.mjs +2 -1
- package/dist/drizzle/d1-totp.mjs.map +1 -1
- package/dist/drizzle/email-registration.d.mts +1 -1
- package/dist/drizzle/email-registration.mjs +2 -1
- package/dist/drizzle/email-registration.mjs.map +1 -1
- package/dist/drizzle/email-target.d.mts +8 -7
- package/dist/drizzle/email-target.mjs +10 -10
- package/dist/drizzle/email-target.mjs.map +1 -1
- package/dist/drizzle/model.d.mts +2 -126
- package/dist/drizzle/model.mjs +2 -21
- package/dist/drizzle/model.mjs.map +1 -1
- package/dist/drizzle/mysql-database.d.mts +8 -0
- package/dist/drizzle/mysql-database.mjs +8 -0
- package/dist/drizzle/mysql-database.mjs.map +1 -0
- package/dist/drizzle/mysql-emails.d.mts +8 -7
- package/dist/drizzle/mysql-emails.mjs +12 -8
- package/dist/drizzle/mysql-emails.mjs.map +1 -1
- package/dist/drizzle/mysql-identity.mjs +12 -9
- package/dist/drizzle/mysql-identity.mjs.map +1 -1
- package/dist/drizzle/mysql-password-prepared.d.mts +4 -3
- package/dist/drizzle/mysql-password-prepared.mjs +6 -2
- package/dist/drizzle/mysql-password-prepared.mjs.map +1 -1
- package/dist/drizzle/mysql-passwords.d.mts +7 -5
- package/dist/drizzle/mysql-passwords.mjs +11 -7
- package/dist/drizzle/mysql-passwords.mjs.map +1 -1
- package/dist/drizzle/mysql-proofs.d.mts +4 -3
- package/dist/drizzle/mysql-proofs.mjs +8 -4
- package/dist/drizzle/mysql-proofs.mjs.map +1 -1
- package/dist/drizzle/mysql-sessions.d.mts +12 -11
- package/dist/drizzle/mysql-sessions.mjs +16 -12
- package/dist/drizzle/mysql-sessions.mjs.map +1 -1
- package/dist/drizzle/native-database.mjs +10 -0
- package/dist/drizzle/native-database.mjs.map +1 -0
- package/dist/drizzle/oauth-accounts.mjs +1 -1
- package/dist/drizzle/oauth-connected-access.mjs +14 -12
- package/dist/drizzle/oauth-connected-access.mjs.map +1 -1
- package/dist/drizzle/oauth-connected-custody.mjs +2 -2
- package/dist/drizzle/oauth-connected-drivers.mjs +11 -6
- package/dist/drizzle/oauth-connected-drivers.mjs.map +1 -1
- package/dist/drizzle/oauth-connected-flow.mjs +2 -2
- package/dist/drizzle/oauth-connected-input.mjs +14 -1
- package/dist/drizzle/oauth-connected-input.mjs.map +1 -1
- package/dist/drizzle/oauth-connected-maintenance.mjs +1 -1
- package/dist/drizzle/oauth-connected-management.mjs +2 -2
- package/dist/drizzle/oauth-connected-model.d.mts +17 -3
- package/dist/drizzle/oauth-connected-model.mjs.map +1 -1
- package/dist/drizzle/oauth-connected-settlement.mjs +51 -41
- package/dist/drizzle/oauth-connected-settlement.mjs.map +1 -1
- package/dist/drizzle/oauth-connected-sign-in.mjs +263 -0
- package/dist/drizzle/oauth-connected-sign-in.mjs.map +1 -0
- package/dist/drizzle/oauth-connected-state.d.mts +110 -2
- package/dist/drizzle/oauth-connected-state.mjs +9 -4
- package/dist/drizzle/oauth-connected-state.mjs.map +1 -1
- package/dist/drizzle/oauth-connected-target.d.mts +142 -15
- package/dist/drizzle/oauth-connected-target.mjs +9 -6
- package/dist/drizzle/oauth-connected-target.mjs.map +1 -1
- package/dist/drizzle/oauth-drivers.mjs +9 -7
- package/dist/drizzle/oauth-drivers.mjs.map +1 -1
- package/dist/drizzle/oauth-flow.d.mts +1 -1
- package/dist/drizzle/oauth-flow.mjs +1 -1
- package/dist/drizzle/oauth-input.mjs +1 -1
- package/dist/drizzle/oauth-model.d.mts +1 -1
- package/dist/drizzle/oauth-owner.d.mts +1 -1
- package/dist/drizzle/oauth-registration.d.mts +2 -2
- package/dist/drizzle/oauth-registration.mjs +1 -1
- package/dist/drizzle/oauth-state.mjs +5 -4
- package/dist/drizzle/oauth-state.mjs.map +1 -1
- package/dist/drizzle/oauth-target.d.mts +14 -13
- package/dist/drizzle/oauth-target.mjs +14 -13
- package/dist/drizzle/oauth-target.mjs.map +1 -1
- package/dist/drizzle/passkey-drivers.mjs +8 -6
- package/dist/drizzle/passkey-drivers.mjs.map +1 -1
- package/dist/drizzle/passkey-write-drivers.mjs +5 -3
- package/dist/drizzle/passkey-write-drivers.mjs.map +1 -1
- package/dist/drizzle/passkey-write-target.d.mts +1 -1
- package/dist/drizzle/password-prepared-sql.mjs +2 -1
- package/dist/drizzle/password-prepared-sql.mjs.map +1 -1
- package/dist/drizzle/password-prepared-state.mjs +1 -1
- package/dist/drizzle/password-prepared-target.d.mts +4 -3
- package/dist/drizzle/password-prepared-target.mjs +4 -3
- package/dist/drizzle/password-prepared-target.mjs.map +1 -1
- package/dist/drizzle/password-registration.mjs +2 -1
- package/dist/drizzle/password-registration.mjs.map +1 -1
- package/dist/drizzle/password-target.d.mts +6 -5
- package/dist/drizzle/password-target.mjs +8 -8
- package/dist/drizzle/password-target.mjs.map +1 -1
- package/dist/drizzle/pg-database.d.mts +9 -0
- package/dist/drizzle/pg-database.mjs +8 -0
- package/dist/drizzle/pg-database.mjs.map +1 -0
- package/dist/drizzle/pg-emails.d.mts +8 -7
- package/dist/drizzle/pg-emails.mjs +12 -8
- package/dist/drizzle/pg-emails.mjs.map +1 -1
- package/dist/drizzle/pg-identity.mjs +92 -0
- package/dist/drizzle/pg-identity.mjs.map +1 -0
- package/dist/drizzle/pg-password-prepared.d.mts +4 -3
- package/dist/drizzle/pg-password-prepared.mjs +6 -2
- package/dist/drizzle/pg-password-prepared.mjs.map +1 -1
- package/dist/drizzle/pg-passwords.d.mts +7 -5
- package/dist/drizzle/pg-passwords.mjs +11 -7
- package/dist/drizzle/pg-passwords.mjs.map +1 -1
- package/dist/drizzle/pg-proofs.d.mts +4 -3
- package/dist/drizzle/pg-proofs.mjs +8 -4
- package/dist/drizzle/pg-proofs.mjs.map +1 -1
- package/dist/drizzle/pg-sessions.d.mts +12 -11
- package/dist/drizzle/pg-sessions.mjs +16 -12
- package/dist/drizzle/pg-sessions.mjs.map +1 -1
- package/dist/drizzle/phone-model.d.mts +1 -1
- package/dist/drizzle/phone-target.d.mts +5 -4
- package/dist/drizzle/phone-target.mjs +12 -11
- package/dist/drizzle/phone-target.mjs.map +1 -1
- package/dist/drizzle/proof-target.d.mts +4 -3
- package/dist/drizzle/proof-target.mjs +5 -5
- package/dist/drizzle/proof-target.mjs.map +1 -1
- package/dist/drizzle/session-sql.d.mts +1 -0
- package/dist/drizzle/session-target.d.mts +11 -9
- package/dist/drizzle/session-target.mjs +11 -11
- package/dist/drizzle/session-target.mjs.map +1 -1
- package/dist/drizzle/sqlite-emails.mjs +9 -5
- package/dist/drizzle/sqlite-emails.mjs.map +1 -1
- package/dist/drizzle/sqlite-identity.mjs +14 -11
- package/dist/drizzle/sqlite-identity.mjs.map +1 -1
- package/dist/drizzle/sqlite-password-prepared.mjs +7 -3
- package/dist/drizzle/sqlite-password-prepared.mjs.map +1 -1
- package/dist/drizzle/sqlite-passwords.mjs +10 -6
- package/dist/drizzle/sqlite-passwords.mjs.map +1 -1
- package/dist/drizzle/sqlite-proofs.mjs +7 -3
- package/dist/drizzle/sqlite-proofs.mjs.map +1 -1
- package/dist/drizzle/sqlite-sessions.mjs +16 -12
- package/dist/drizzle/sqlite-sessions.mjs.map +1 -1
- package/dist/drizzle/standalone-guard.d.mts +2 -0
- package/dist/drizzle/standalone-guard.mjs +8 -4
- package/dist/drizzle/standalone-guard.mjs.map +1 -1
- package/dist/drizzle/totp-model.d.mts +1 -1
- package/dist/drizzle/totp-target.d.mts +5 -4
- package/dist/drizzle/totp-target.mjs +31 -28
- package/dist/drizzle/totp-target.mjs.map +1 -1
- package/dist/drizzle/transaction-mysql.mjs +1 -1
- package/dist/drizzle/transaction-mysql.mjs.map +1 -1
- package/dist/index.d.mts +2 -4
- package/dist/index.mjs +2 -4
- package/dist/internal/drizzle-postgres.mjs.map +1 -1
- package/dist/internal/drizzle-sqlite.mjs.map +1 -1
- package/package.json +1 -1
- package/src/D1.ts +37 -26
- package/src/Libsql.ts +45 -61
- package/src/Mysql2.ts +39 -35
- package/src/Pglite.ts +48 -30
- package/src/Postgres.ts +48 -30
- package/src/SqliteBun.ts +59 -68
- package/src/SqliteDo.ts +61 -274
- package/src/SqliteNode.ts +56 -66
- package/src/SqliteWasm.ts +56 -66
- package/src/drizzle/D1BatchStatements.ts +1 -1
- package/src/drizzle/d1-database.ts +10 -0
- package/src/drizzle/d1-emails.ts +86 -88
- package/src/drizzle/d1-generated-statement.ts +1 -1
- package/src/drizzle/d1-identity.ts +17 -20
- package/src/drizzle/d1-oauth.ts +19 -8
- package/src/drizzle/d1-passkey.ts +5 -1
- package/src/drizzle/d1-password-prepared.ts +40 -42
- package/src/drizzle/d1-passwords.ts +76 -80
- package/src/drizzle/d1-phone.ts +5 -1
- package/src/drizzle/d1-proofs.ts +31 -34
- package/src/drizzle/d1-sessions.ts +53 -40
- package/src/drizzle/d1-totp.ts +5 -1
- package/src/drizzle/email-registration.ts +6 -2
- package/src/drizzle/email-target.ts +18 -20
- package/src/drizzle/model.ts +1 -208
- package/src/drizzle/mysql-database.ts +8 -0
- package/src/drizzle/mysql-emails.ts +29 -17
- package/src/drizzle/mysql-identity.ts +18 -21
- package/src/drizzle/mysql-password-prepared.ts +11 -9
- package/src/drizzle/mysql-passwords.ts +22 -10
- package/src/drizzle/mysql-proofs.ts +17 -6
- package/src/drizzle/mysql-sessions.ts +41 -18
- package/src/drizzle/native-database.ts +22 -0
- package/src/drizzle/oauth-connected-access.ts +8 -1
- package/src/drizzle/oauth-connected-drivers.ts +21 -6
- package/src/drizzle/oauth-connected-input.ts +13 -0
- package/src/drizzle/oauth-connected-model.ts +17 -0
- package/src/drizzle/oauth-connected-settlement.ts +65 -42
- package/src/drizzle/oauth-connected-sign-in.ts +438 -0
- package/src/drizzle/oauth-connected-state.ts +19 -7
- package/src/drizzle/oauth-connected-target.ts +26 -18
- package/src/drizzle/oauth-drivers.ts +26 -10
- package/src/drizzle/oauth-state.ts +5 -4
- package/src/drizzle/oauth-target.ts +31 -43
- package/src/drizzle/passkey-drivers.ts +21 -13
- package/src/drizzle/passkey-write-drivers.ts +11 -6
- package/src/drizzle/password-prepared-sql.ts +2 -4
- package/src/drizzle/password-prepared-target.ts +10 -7
- package/src/drizzle/password-registration.ts +7 -8
- package/src/drizzle/password-target.ts +20 -19
- package/src/drizzle/pg-database.ts +10 -0
- package/src/drizzle/pg-emails.ts +29 -17
- package/src/drizzle/pg-identity.ts +297 -0
- package/src/drizzle/pg-password-prepared.ts +11 -9
- package/src/drizzle/pg-passwords.ts +22 -10
- package/src/drizzle/pg-proofs.ts +17 -6
- package/src/drizzle/pg-sessions.ts +41 -18
- package/src/drizzle/phone-target.ts +23 -18
- package/src/drizzle/proof-target.ts +10 -13
- package/src/drizzle/session-target.ts +33 -51
- package/src/drizzle/sqlite-emails.ts +31 -14
- package/src/drizzle/sqlite-identity.ts +22 -42
- package/src/drizzle/sqlite-password-prepared.ts +24 -10
- package/src/drizzle/sqlite-passwords.ts +30 -16
- package/src/drizzle/sqlite-proofs.ts +29 -6
- package/src/drizzle/sqlite-sessions.ts +50 -24
- package/src/drizzle/standalone-guard.ts +19 -7
- package/src/drizzle/totp-target.ts +62 -61
- package/src/drizzle/transaction-mysql.ts +1 -1
- package/src/index.ts +0 -24
- package/src/internal/drizzle-postgres.ts +1 -1
- package/src/internal/drizzle-sqlite.ts +1 -1
- package/dist/drizzle/d1-identity.d.mts +0 -30
- package/dist/drizzle/mysql-identity.d.mts +0 -21
- package/dist/drizzle/mysql.d.mts +0 -69
- package/dist/drizzle/mysql.mjs +0 -218
- package/dist/drizzle/mysql.mjs.map +0 -1
- package/dist/drizzle/pg.d.mts +0 -80
- package/dist/drizzle/pg.mjs +0 -289
- package/dist/drizzle/pg.mjs.map +0 -1
- package/dist/drizzle/sqlite.d.mts +0 -77
- package/dist/drizzle/sqlite.mjs +0 -217
- package/dist/drizzle/sqlite.mjs.map +0 -1
- package/src/drizzle/mysql.ts +0 -687
- package/src/drizzle/pg.ts +0 -984
- package/src/drizzle/sqlite.ts +0 -705
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { NativeDatabase } from "@yielded/auth-persistence/Adapter";
|
|
1
2
|
import { LifecycleHooks } from "@yielded/auth/Hooks";
|
|
2
3
|
import {
|
|
3
4
|
OAuthAccountRevision,
|
|
@@ -28,7 +29,7 @@ import type { SecurityRevision } from "@yielded/auth/Sessions";
|
|
|
28
29
|
/* oxlint-disable no-explicit-any -- concrete driver entry points restore table/database generics. */
|
|
29
30
|
import { eq, sql } from "drizzle-orm";
|
|
30
31
|
import { type Context, Effect, Layer } from "effect";
|
|
31
|
-
import type { Statement } from "effect/
|
|
32
|
+
import type { Statement } from "effect/sql/Statement";
|
|
32
33
|
|
|
33
34
|
import type { PersistenceMappingError } from "./model";
|
|
34
35
|
import {
|
|
@@ -83,17 +84,16 @@ export type OAuthCoordinatorError<E> = TransactionCoordinatorError<E, OAuthUnava
|
|
|
83
84
|
export type OAuthExecution = TransactionExecution<OAuthUnavailable, CurrentOAuthTransaction, never>;
|
|
84
85
|
|
|
85
86
|
export const sqlClientOAuthStandaloneGuard = (
|
|
86
|
-
|
|
87
|
-
) => sqlClientTransactionStandaloneGuard(unavailable,
|
|
87
|
+
service: Parameters<typeof sqlClientTransactionStandaloneGuard>[1],
|
|
88
|
+
) => sqlClientTransactionStandaloneGuard(unavailable, service);
|
|
88
89
|
|
|
89
|
-
export const makeOAuthExecution = (
|
|
90
|
-
database: OAuthNativeDatabase,
|
|
91
|
-
hooks: LifecycleHooks["Service"],
|
|
90
|
+
export const makeOAuthExecution = Effect.fnUntraced(function* (
|
|
92
91
|
configuration: OAuthTargetConfiguration,
|
|
93
|
-
): OAuthExecution
|
|
94
|
-
const
|
|
92
|
+
): Effect.fn.Return<OAuthExecution, never, LifecycleHooks | NativeDatabase> {
|
|
93
|
+
const hooks = yield* LifecycleHooks;
|
|
94
|
+
|
|
95
|
+
const execution = yield* makeTransactionExecution(
|
|
95
96
|
CurrentOAuthTransaction,
|
|
96
|
-
database,
|
|
97
97
|
configuration,
|
|
98
98
|
unavailable,
|
|
99
99
|
nonce,
|
|
@@ -104,7 +104,7 @@ export const makeOAuthExecution = (
|
|
|
104
104
|
run: (operation, mutation) =>
|
|
105
105
|
execution.run(operation, mutation).pipe(Effect.provideService(LifecycleHooks, hooks)),
|
|
106
106
|
};
|
|
107
|
-
};
|
|
107
|
+
});
|
|
108
108
|
|
|
109
109
|
const prepareValue = <Value, A>(value: Value, prepare: PrepareOAuthCommit<Value, A>) =>
|
|
110
110
|
Effect.flatMap(CurrentOAuthTransaction, (owner) =>
|
|
@@ -388,47 +388,35 @@ export const makeOAuthRegistration = <Registration>(
|
|
|
388
388
|
);
|
|
389
389
|
|
|
390
390
|
export const makeTargetOAuthSignInServices = (
|
|
391
|
-
database: any,
|
|
392
391
|
mapping: any,
|
|
393
392
|
configuration: OAuthTargetConfiguration,
|
|
394
393
|
) => {
|
|
395
394
|
const captured = captureOAuthMapping(mapping);
|
|
396
395
|
|
|
397
|
-
return Effect.map(
|
|
398
|
-
oauthSignInPersistence: makeOAuthSignIn(
|
|
399
|
-
captured,
|
|
400
|
-
makeOAuthExecution(database, hooks, configuration),
|
|
401
|
-
),
|
|
396
|
+
return Effect.map(makeOAuthExecution(configuration), (execution) => ({
|
|
397
|
+
oauthSignInPersistence: makeOAuthSignIn(captured, execution),
|
|
402
398
|
}));
|
|
403
399
|
};
|
|
404
400
|
|
|
405
401
|
export const makeTargetOAuthRegistrationIntentServices = (
|
|
406
|
-
database: any,
|
|
407
402
|
mapping: any,
|
|
408
403
|
configuration: OAuthTargetConfiguration,
|
|
409
404
|
) => {
|
|
410
405
|
const captured = captureOAuthMapping(mapping);
|
|
411
406
|
|
|
412
|
-
return Effect.map(
|
|
413
|
-
oauthRegistrationIntents: makeOAuthRegistrationIntents(
|
|
414
|
-
captured,
|
|
415
|
-
makeOAuthExecution(database, hooks, configuration),
|
|
416
|
-
),
|
|
407
|
+
return Effect.map(makeOAuthExecution(configuration), (execution) => ({
|
|
408
|
+
oauthRegistrationIntents: makeOAuthRegistrationIntents(captured, execution),
|
|
417
409
|
}));
|
|
418
410
|
};
|
|
419
411
|
|
|
420
412
|
export const makeTargetOAuthRegistrationServices = <Registration>(
|
|
421
|
-
database: any,
|
|
422
413
|
mapping: any,
|
|
423
414
|
configuration: OAuthTargetConfiguration,
|
|
424
415
|
) => {
|
|
425
416
|
const captured = captureOAuthMapping(mapping);
|
|
426
417
|
|
|
427
|
-
return Effect.map(
|
|
428
|
-
registrationAuthority: makeOAuthRegistration<Registration>(
|
|
429
|
-
captured,
|
|
430
|
-
makeOAuthExecution(database, hooks, configuration),
|
|
431
|
-
),
|
|
418
|
+
return Effect.map(makeOAuthExecution(configuration), (execution) => ({
|
|
419
|
+
registrationAuthority: makeOAuthRegistration<Registration>(captured, execution),
|
|
432
420
|
}));
|
|
433
421
|
};
|
|
434
422
|
|
|
@@ -698,50 +686,50 @@ export const makeOAuthAccounts = (
|
|
|
698
686
|
);
|
|
699
687
|
|
|
700
688
|
export const makeTargetOAuthAccountsServices = (
|
|
701
|
-
database: any,
|
|
702
689
|
mapping: any,
|
|
703
690
|
configuration: OAuthTargetConfiguration,
|
|
704
691
|
) => {
|
|
705
692
|
const captured = captureOAuthMapping(mapping);
|
|
706
693
|
|
|
707
|
-
return Effect.map(
|
|
708
|
-
oauthAccountsPersistence: makeOAuthAccounts(
|
|
709
|
-
captured,
|
|
710
|
-
makeOAuthExecution(database, hooks, configuration),
|
|
711
|
-
),
|
|
694
|
+
return Effect.map(makeOAuthExecution(configuration), (execution) => ({
|
|
695
|
+
oauthAccountsPersistence: makeOAuthAccounts(captured, execution),
|
|
712
696
|
}));
|
|
713
697
|
};
|
|
714
698
|
|
|
715
|
-
export const oauthAccountsPersistenceLayer = (
|
|
716
|
-
services: ReturnType<typeof makeTargetOAuthAccountsServices>,
|
|
699
|
+
export const oauthAccountsPersistenceLayer = <E, R>(
|
|
700
|
+
services: Effect.Effect<Effect.Success<ReturnType<typeof makeTargetOAuthAccountsServices>>, E, R>,
|
|
717
701
|
) =>
|
|
718
702
|
Layer.effect(
|
|
719
703
|
OAuthAccountsPersistence,
|
|
720
704
|
Effect.map(services, (value) => value.oauthAccountsPersistence),
|
|
721
705
|
);
|
|
722
706
|
|
|
723
|
-
export const oauthSignInPersistenceLayer = (
|
|
724
|
-
services: ReturnType<typeof makeTargetOAuthSignInServices>,
|
|
707
|
+
export const oauthSignInPersistenceLayer = <E, R>(
|
|
708
|
+
services: Effect.Effect<Effect.Success<ReturnType<typeof makeTargetOAuthSignInServices>>, E, R>,
|
|
725
709
|
) =>
|
|
726
710
|
Layer.effect(
|
|
727
711
|
OAuthSignInPersistence,
|
|
728
712
|
Effect.map(services, (value) => value.oauthSignInPersistence),
|
|
729
713
|
);
|
|
730
714
|
|
|
731
|
-
export const oauthRegistrationIntentsLayer = (
|
|
732
|
-
services:
|
|
715
|
+
export const oauthRegistrationIntentsLayer = <E, R>(
|
|
716
|
+
services: Effect.Effect<
|
|
717
|
+
Effect.Success<ReturnType<typeof makeTargetOAuthRegistrationIntentServices>>,
|
|
718
|
+
E,
|
|
719
|
+
R
|
|
720
|
+
>,
|
|
733
721
|
) =>
|
|
734
722
|
Layer.effect(
|
|
735
723
|
OAuthRegistrationIntents,
|
|
736
724
|
Effect.map(services, (value) => value.oauthRegistrationIntents),
|
|
737
725
|
);
|
|
738
726
|
|
|
739
|
-
export const oauthRegistrationAuthorityLayer = <Id, Registration>(
|
|
727
|
+
export const oauthRegistrationAuthorityLayer = <Id, Registration, E, R>(
|
|
740
728
|
tag: Context.Key<Id, OAuthRegistrationAuthority<Registration>>,
|
|
741
729
|
services: Effect.Effect<
|
|
742
730
|
{ readonly registrationAuthority: OAuthRegistrationAuthority<Registration> },
|
|
743
|
-
|
|
744
|
-
|
|
731
|
+
E,
|
|
732
|
+
R
|
|
745
733
|
>,
|
|
746
734
|
) =>
|
|
747
735
|
Layer.effect(
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { NativeDatabase } from "@yielded/auth-persistence/Adapter";
|
|
1
2
|
import type { LifecycleHooks } from "@yielded/auth/Hooks";
|
|
2
3
|
import { PasskeyPersistence } from "@yielded/auth/Passkey";
|
|
3
4
|
import type { Table } from "drizzle-orm";
|
|
4
5
|
import { Effect, Context } from "effect";
|
|
5
6
|
|
|
7
|
+
import { nativeDatabase } from "./native-database";
|
|
6
8
|
import type {
|
|
7
9
|
PasskeyCredentialMapping,
|
|
8
10
|
PasskeyEnrollmentContextMapping,
|
|
@@ -33,11 +35,13 @@ type TransactionOf<D> = D extends { readonly transaction: (...args: any[]) => an
|
|
|
33
35
|
: never;
|
|
34
36
|
|
|
35
37
|
export const makePasskeyTarget = <
|
|
38
|
+
DatabaseId,
|
|
36
39
|
D,
|
|
37
40
|
T extends Table,
|
|
38
41
|
Extra = unknown,
|
|
39
42
|
Synchronous extends boolean = false,
|
|
40
43
|
>(
|
|
44
|
+
databaseService: Context.Service<DatabaseId, D>,
|
|
41
45
|
configuration: PasskeyTargetConfiguration,
|
|
42
46
|
) => {
|
|
43
47
|
function coordinatePasskeyPersistence<
|
|
@@ -304,9 +308,8 @@ export const makePasskeyTarget = <
|
|
|
304
308
|
}
|
|
305
309
|
|
|
306
310
|
return {
|
|
307
|
-
...makePasskeyWriteTarget<D, T, Extra, Synchronous>(configuration),
|
|
311
|
+
...makePasskeyWriteTarget<DatabaseId, D, T, Extra, Synchronous>(databaseService, configuration),
|
|
308
312
|
makePasskeyCredentialServices: <
|
|
309
|
-
Database extends D,
|
|
310
313
|
S extends T,
|
|
311
314
|
C extends T,
|
|
312
315
|
F extends T,
|
|
@@ -315,11 +318,12 @@ export const makePasskeyTarget = <
|
|
|
315
318
|
N,
|
|
316
319
|
RSetup = never,
|
|
317
320
|
>(
|
|
318
|
-
database: Database,
|
|
319
321
|
mapping: PasskeyMappingSource<PasskeyCredentialMapping<S, C, F, O, H, N> & Extra, RSetup>,
|
|
320
|
-
) =>
|
|
322
|
+
) =>
|
|
323
|
+
makeTargetPasskeyCredentials(mapping, configuration).pipe(
|
|
324
|
+
Effect.provideServiceEffect(NativeDatabase, nativeDatabase(databaseService)),
|
|
325
|
+
),
|
|
321
326
|
makePasskeyEnrollmentContextServices: <
|
|
322
|
-
Database extends D,
|
|
323
327
|
S extends T,
|
|
324
328
|
C extends T,
|
|
325
329
|
F extends T,
|
|
@@ -329,14 +333,15 @@ export const makePasskeyTarget = <
|
|
|
329
333
|
N,
|
|
330
334
|
RSetup = never,
|
|
331
335
|
>(
|
|
332
|
-
database: Database,
|
|
333
336
|
mapping: PasskeyMappingSource<
|
|
334
337
|
PasskeyEnrollmentContextMapping<PasskeyCredentialMapping<S, C, F, O, H, N>, M, N> & Extra,
|
|
335
338
|
RSetup
|
|
336
339
|
>,
|
|
337
|
-
) =>
|
|
340
|
+
) =>
|
|
341
|
+
makeTargetPasskeyEnrollmentContext(mapping, configuration).pipe(
|
|
342
|
+
Effect.provideServiceEffect(NativeDatabase, nativeDatabase(databaseService)),
|
|
343
|
+
),
|
|
338
344
|
makePasskeyPersistenceServices: <
|
|
339
|
-
Database extends D,
|
|
340
345
|
S extends T,
|
|
341
346
|
C extends T,
|
|
342
347
|
F extends T,
|
|
@@ -349,7 +354,6 @@ export const makePasskeyTarget = <
|
|
|
349
354
|
N,
|
|
350
355
|
RSetup = never,
|
|
351
356
|
>(
|
|
352
|
-
database: Database,
|
|
353
357
|
mapping: PasskeyMappingSource<
|
|
354
358
|
PasskeyPersistenceMapping<
|
|
355
359
|
PasskeyCredentialMapping<S, C, F, O, H, N>,
|
|
@@ -362,9 +366,11 @@ export const makePasskeyTarget = <
|
|
|
362
366
|
Extra,
|
|
363
367
|
RSetup
|
|
364
368
|
>,
|
|
365
|
-
) =>
|
|
369
|
+
) =>
|
|
370
|
+
makeTargetPasskeyPersistence(mapping, configuration).pipe(
|
|
371
|
+
Effect.provideServiceEffect(NativeDatabase, nativeDatabase(databaseService)),
|
|
372
|
+
),
|
|
366
373
|
makePasskeyRegistrationCeremonyServices: <
|
|
367
|
-
Database extends D,
|
|
368
374
|
M extends T,
|
|
369
375
|
Flow extends T,
|
|
370
376
|
Admission extends T,
|
|
@@ -373,12 +379,14 @@ export const makePasskeyTarget = <
|
|
|
373
379
|
H extends T,
|
|
374
380
|
RSetup = never,
|
|
375
381
|
>(
|
|
376
|
-
database: Database,
|
|
377
382
|
mapping: PasskeyMappingSource<
|
|
378
383
|
PasskeyRegistrationCeremonyMapping<M, Flow, Admission, Charge, Intent, H> & Extra,
|
|
379
384
|
RSetup
|
|
380
385
|
>,
|
|
381
|
-
) =>
|
|
386
|
+
) =>
|
|
387
|
+
makeTargetPasskeyRegistration(mapping, configuration).pipe(
|
|
388
|
+
Effect.provideServiceEffect(NativeDatabase, nativeDatabase(databaseService)),
|
|
389
|
+
),
|
|
382
390
|
coordinatePasskeyPersistence,
|
|
383
391
|
coordinatePasskeyRegistrationCeremony,
|
|
384
392
|
};
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { NativeDatabase } from "@yielded/auth-persistence/Adapter";
|
|
1
2
|
import type { LifecycleHooks } from "@yielded/auth/Hooks";
|
|
2
3
|
import { PasskeyManagementPersistence, PasskeyPersistence } from "@yielded/auth/Passkey";
|
|
3
4
|
import type { Table } from "drizzle-orm";
|
|
4
5
|
import { Context, Effect } from "effect";
|
|
5
6
|
|
|
7
|
+
import { nativeDatabase } from "./native-database";
|
|
6
8
|
import type { PasskeyMappingSource } from "./passkey-model";
|
|
7
9
|
import type { PasskeyCoordinatorError, PasskeyTargetConfiguration } from "./passkey-target";
|
|
8
10
|
import type {
|
|
@@ -23,11 +25,13 @@ type TransactionOf<D> = D extends { readonly transaction: (...args: any[]) => an
|
|
|
23
25
|
: never;
|
|
24
26
|
|
|
25
27
|
export const makePasskeyWriteTarget = <
|
|
28
|
+
DatabaseId,
|
|
26
29
|
D,
|
|
27
30
|
T extends Table,
|
|
28
31
|
Extra = unknown,
|
|
29
32
|
Synchronous extends boolean = false,
|
|
30
33
|
>(
|
|
34
|
+
databaseService: Context.Service<DatabaseId, D>,
|
|
31
35
|
configuration: PasskeyTargetConfiguration,
|
|
32
36
|
) => {
|
|
33
37
|
function coordinatePasskeyManagement<
|
|
@@ -180,7 +184,6 @@ export const makePasskeyWriteTarget = <
|
|
|
180
184
|
}
|
|
181
185
|
|
|
182
186
|
const makePasskeyManagementServices = <
|
|
183
|
-
Database extends D,
|
|
184
187
|
S extends T,
|
|
185
188
|
C extends T,
|
|
186
189
|
F extends T,
|
|
@@ -194,12 +197,14 @@ export const makePasskeyWriteTarget = <
|
|
|
194
197
|
N,
|
|
195
198
|
RSetup = never,
|
|
196
199
|
>(
|
|
197
|
-
database: Database,
|
|
198
200
|
mapping: PasskeyMappingSource<
|
|
199
201
|
PasskeyManagementMapping<S, C, F, O, H, M, Flow, Admission, Charge, Command, N> & Extra,
|
|
200
202
|
RSetup
|
|
201
203
|
>,
|
|
202
|
-
) =>
|
|
204
|
+
) =>
|
|
205
|
+
makeTargetPasskeyManagement(mapping, configuration).pipe(
|
|
206
|
+
Effect.provideServiceEffect(NativeDatabase, nativeDatabase(databaseService)),
|
|
207
|
+
);
|
|
203
208
|
|
|
204
209
|
function coordinatePasskeyRegistration<
|
|
205
210
|
Database extends D,
|
|
@@ -357,7 +362,6 @@ export const makePasskeyWriteTarget = <
|
|
|
357
362
|
}
|
|
358
363
|
|
|
359
364
|
const makePasskeyRegistrationServices = <
|
|
360
|
-
Database extends D,
|
|
361
365
|
S extends T,
|
|
362
366
|
C extends T,
|
|
363
367
|
F extends T,
|
|
@@ -372,7 +376,6 @@ export const makePasskeyWriteTarget = <
|
|
|
372
376
|
Value,
|
|
373
377
|
RSetup = never,
|
|
374
378
|
>(
|
|
375
|
-
database: Database,
|
|
376
379
|
mapping: PasskeyMappingSource<
|
|
377
380
|
PasskeyRegistrationMapping<S, C, F, O, H, M, Flow, Admission, Charge, Intent, N, Value> &
|
|
378
381
|
Extra,
|
|
@@ -384,7 +387,9 @@ export const makePasskeyWriteTarget = <
|
|
|
384
387
|
Extra,
|
|
385
388
|
Value,
|
|
386
389
|
RSetup
|
|
387
|
-
>(
|
|
390
|
+
>(mapping, configuration).pipe(
|
|
391
|
+
Effect.provideServiceEffect(NativeDatabase, nativeDatabase(databaseService)),
|
|
392
|
+
);
|
|
388
393
|
|
|
389
394
|
return {
|
|
390
395
|
makePasskeyManagementServices,
|
|
@@ -50,7 +50,6 @@ import {
|
|
|
50
50
|
CurrentPasswordSql,
|
|
51
51
|
passwordSqlKernel as kernel,
|
|
52
52
|
type PasswordSqlConfiguration,
|
|
53
|
-
type PasswordSqlDatabase,
|
|
54
53
|
type PasswordSqlQuery,
|
|
55
54
|
} from "./password-sql";
|
|
56
55
|
import { checkProofCompletionIn, completeProofPlanIn } from "./proof-sql";
|
|
@@ -85,7 +84,6 @@ const translateContextFailure = <A, E, R>(
|
|
|
85
84
|
);
|
|
86
85
|
|
|
87
86
|
type Mapping = AnyPasswordPreparedPersistenceMapping;
|
|
88
|
-
type Database = PasswordSqlDatabase;
|
|
89
87
|
const nowMillis = DateTime.now.pipe(Effect.map(DateTime.toEpochMillis));
|
|
90
88
|
|
|
91
89
|
const read = (query: PasswordSqlQuery, locking: boolean) =>
|
|
@@ -410,10 +408,10 @@ const terminal = Effect.fn("DrizzlePasswordPrepared.terminal")(function* (
|
|
|
410
408
|
|
|
411
409
|
export const makeSqlPasswordPreparedPersistence = Effect.fn("makeSqlPasswordPreparedPersistence")(
|
|
412
410
|
function* (
|
|
413
|
-
database: Database,
|
|
414
411
|
mapping: Mapping,
|
|
415
412
|
configuration: PasswordSqlConfiguration,
|
|
416
|
-
): Effect.fn.Return<PasswordPreparedPersistence, never, LifecycleHooks> {
|
|
413
|
+
): Effect.fn.Return<PasswordPreparedPersistence, never, LifecycleHooks | CurrentPasswordSql> {
|
|
414
|
+
const database = yield* CurrentPasswordSql;
|
|
417
415
|
const hooks = yield* LifecycleHooks;
|
|
418
416
|
|
|
419
417
|
const p = mapping.password,
|
|
@@ -13,9 +13,10 @@ import {
|
|
|
13
13
|
import { PasswordUnavailable, type PasswordPreparedPersistence } from "@yielded/auth/Password";
|
|
14
14
|
/* oxlint-disable no-explicit-any -- concrete driver modules restore native table/database types. */
|
|
15
15
|
import { type Context, Cause, Effect, Layer } from "effect";
|
|
16
|
-
import type * as SqlError from "effect/
|
|
16
|
+
import type * as SqlError from "effect/sql/SqlError";
|
|
17
17
|
|
|
18
18
|
import { makeSqlPasswordPreparedPersistence } from "./password-prepared-sql";
|
|
19
|
+
import { CurrentPasswordSql } from "./password-sql";
|
|
19
20
|
import type { PasswordSqlDatabase } from "./password-sql";
|
|
20
21
|
import {
|
|
21
22
|
passwordOptions,
|
|
@@ -24,7 +25,6 @@ import {
|
|
|
24
25
|
} from "./password-target";
|
|
25
26
|
|
|
26
27
|
export const makeTargetPasswordPreparedPersistenceServices = (
|
|
27
|
-
database: any,
|
|
28
28
|
mapping: any,
|
|
29
29
|
configuration: PasswordTargetConfiguration,
|
|
30
30
|
proofMapping?: any,
|
|
@@ -32,7 +32,6 @@ export const makeTargetPasswordPreparedPersistenceServices = (
|
|
|
32
32
|
Effect.gen(function* () {
|
|
33
33
|
return {
|
|
34
34
|
passwordPreparedPersistence: yield* makeSqlPasswordPreparedPersistence(
|
|
35
|
-
database,
|
|
36
35
|
mapping,
|
|
37
36
|
passwordOptions(configuration, proofMapping),
|
|
38
37
|
),
|
|
@@ -69,9 +68,13 @@ export const coordinateTargetPasswordPreparedPersistence = <Transaction, A, E, R
|
|
|
69
68
|
let acceptingPostconditions = true;
|
|
70
69
|
|
|
71
70
|
const services = yield* makeSqlPasswordPreparedPersistence(
|
|
72
|
-
transaction as unknown as PasswordSqlDatabase,
|
|
73
71
|
mapping,
|
|
74
72
|
passwordOptions(configuration, proofMapping, true),
|
|
73
|
+
).pipe(
|
|
74
|
+
Effect.provideService(
|
|
75
|
+
CurrentPasswordSql,
|
|
76
|
+
transaction as unknown as PasswordSqlDatabase,
|
|
77
|
+
),
|
|
75
78
|
);
|
|
76
79
|
|
|
77
80
|
const protect = <Out, Err, Env>(effect: Effect.Effect<Out, Err, Env>) =>
|
|
@@ -146,12 +149,12 @@ export const coordinateTargetPasswordPreparedPersistence = <Transaction, A, E, R
|
|
|
146
149
|
return result.value;
|
|
147
150
|
});
|
|
148
151
|
|
|
149
|
-
export const passwordPreparedPersistenceLayer = <Id>(
|
|
152
|
+
export const passwordPreparedPersistenceLayer = <Id, E, R>(
|
|
150
153
|
tag: Context.Key<Id, PasswordPreparedPersistence>,
|
|
151
154
|
services: Effect.Effect<
|
|
152
155
|
{ readonly passwordPreparedPersistence: PasswordPreparedPersistence },
|
|
153
|
-
|
|
154
|
-
|
|
156
|
+
E,
|
|
157
|
+
R
|
|
155
158
|
>,
|
|
156
159
|
) =>
|
|
157
160
|
Layer.effect(
|
|
@@ -23,14 +23,9 @@ import {
|
|
|
23
23
|
type AnyPasswordRegistrationMapping,
|
|
24
24
|
requiredPasswordRegistrationConstraints,
|
|
25
25
|
} from "./password-model";
|
|
26
|
-
import {
|
|
27
|
-
CurrentPasswordSql,
|
|
28
|
-
type PasswordSqlDatabase,
|
|
29
|
-
type PasswordSqlQuery,
|
|
30
|
-
} from "./password-sql";
|
|
26
|
+
import { CurrentPasswordSql, type PasswordSqlQuery } from "./password-sql";
|
|
31
27
|
import { CurrentProofSql, type ProofSqlDatabase } from "./proof-sql";
|
|
32
28
|
|
|
33
|
-
type Database = PasswordSqlDatabase;
|
|
34
29
|
type Mapping<Registration> = AnyPasswordRegistrationMapping<Registration>;
|
|
35
30
|
const unavailable = () => PasswordUnavailable.make({});
|
|
36
31
|
|
|
@@ -219,10 +214,14 @@ const registerIn = Effect.fn("DrizzlePasswordRegistration.registerIn")(function*
|
|
|
219
214
|
export const makeSqlPasswordRegistrationAuthority = Effect.fn(
|
|
220
215
|
"makeSqlPasswordRegistrationAuthority",
|
|
221
216
|
)(function* <Registration>(
|
|
222
|
-
database: Database,
|
|
223
217
|
mapping: Mapping<Registration>,
|
|
224
218
|
configuration: PasswordRegistrationConfiguration,
|
|
225
|
-
): Effect.fn.Return<
|
|
219
|
+
): Effect.fn.Return<
|
|
220
|
+
PasswordRegistrationAuthority<Registration>,
|
|
221
|
+
never,
|
|
222
|
+
LifecycleHooks | CurrentPasswordSql
|
|
223
|
+
> {
|
|
224
|
+
const database = yield* CurrentPasswordSql;
|
|
226
225
|
const hooks = yield* LifecycleHooks;
|
|
227
226
|
|
|
228
227
|
return {
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
import { PasswordUnavailable, PasswordPersistence } from "@yielded/auth/Password";
|
|
8
8
|
/* oxlint-disable no-explicit-any -- public driver wrappers restore concrete Drizzle generics. */
|
|
9
9
|
import { type Context, Effect, Layer } from "effect";
|
|
10
|
-
import type * as SqlError from "effect/
|
|
10
|
+
import type * as SqlError from "effect/sql/SqlError";
|
|
11
11
|
|
|
12
12
|
import {
|
|
13
13
|
makeSqlPasswordRegistrationAuthority,
|
|
@@ -15,13 +15,14 @@ import {
|
|
|
15
15
|
type PasswordRegistrationConfiguration,
|
|
16
16
|
} from "./password-registration";
|
|
17
17
|
import {
|
|
18
|
+
CurrentPasswordSql,
|
|
18
19
|
makeSqlPasswordPersistence,
|
|
19
20
|
type PasswordSqlConfiguration,
|
|
20
21
|
type PasswordSqlDatabase,
|
|
21
22
|
type PasswordSqlQuery,
|
|
22
23
|
} from "./password-sql";
|
|
23
24
|
import type { ProofTargetConfiguration } from "./proof-target";
|
|
24
|
-
import { sqlClientStandaloneGuard } from "./standalone-guard";
|
|
25
|
+
import { sqlClientStandaloneGuard, type TransactionService } from "./standalone-guard";
|
|
25
26
|
|
|
26
27
|
export interface PasswordTargetConfiguration {
|
|
27
28
|
readonly mode: "interactive" | "synchronous";
|
|
@@ -50,9 +51,9 @@ export type PasswordCoordinatorError<E> =
|
|
|
50
51
|
| SqlError.SqlError;
|
|
51
52
|
|
|
52
53
|
export const sqlClientPasswordStandaloneGuard = (
|
|
53
|
-
|
|
54
|
+
service: TransactionService | undefined,
|
|
54
55
|
): Effect.Effect<void, PasswordUnavailable> =>
|
|
55
|
-
sqlClientStandaloneGuard(
|
|
56
|
+
sqlClientStandaloneGuard(service, () => PasswordUnavailable.make({}));
|
|
56
57
|
|
|
57
58
|
export const passwordOptions = (
|
|
58
59
|
configuration: PasswordTargetConfiguration,
|
|
@@ -96,7 +97,6 @@ const registrationOptions = (
|
|
|
96
97
|
});
|
|
97
98
|
|
|
98
99
|
export const makeTargetPasswordPersistenceServices = (
|
|
99
|
-
database: any,
|
|
100
100
|
mapping: any,
|
|
101
101
|
configuration: PasswordTargetConfiguration,
|
|
102
102
|
proofMapping?: any,
|
|
@@ -104,7 +104,6 @@ export const makeTargetPasswordPersistenceServices = (
|
|
|
104
104
|
Effect.gen(function* () {
|
|
105
105
|
return {
|
|
106
106
|
passwordPersistence: yield* makeSqlPasswordPersistence(
|
|
107
|
-
database,
|
|
108
107
|
mapping,
|
|
109
108
|
passwordOptions(configuration, proofMapping),
|
|
110
109
|
),
|
|
@@ -112,14 +111,12 @@ export const makeTargetPasswordPersistenceServices = (
|
|
|
112
111
|
});
|
|
113
112
|
|
|
114
113
|
export const makeTargetPasswordRegistrationServices = <Registration>(
|
|
115
|
-
database: any,
|
|
116
114
|
mapping: any,
|
|
117
115
|
configuration: PasswordTargetConfiguration,
|
|
118
116
|
) =>
|
|
119
117
|
Effect.gen(function* () {
|
|
120
118
|
return {
|
|
121
119
|
registrationAuthority: yield* makeSqlPasswordRegistrationAuthority<Registration>(
|
|
122
|
-
database,
|
|
123
120
|
mapping,
|
|
124
121
|
registrationOptions(configuration),
|
|
125
122
|
),
|
|
@@ -149,9 +146,13 @@ export const coordinateTargetPasswordPersistence = <Transaction, A, E, R>(
|
|
|
149
146
|
Effect.gen(function* () {
|
|
150
147
|
return yield* owner(transaction, {
|
|
151
148
|
passwordPersistence: yield* makeSqlPasswordPersistence(
|
|
152
|
-
transaction as unknown as PasswordSqlDatabase,
|
|
153
149
|
mapping,
|
|
154
150
|
passwordOptions(configuration, proofMapping, true),
|
|
151
|
+
).pipe(
|
|
152
|
+
Effect.provideService(
|
|
153
|
+
CurrentPasswordSql,
|
|
154
|
+
transaction as unknown as PasswordSqlDatabase,
|
|
155
|
+
),
|
|
155
156
|
),
|
|
156
157
|
});
|
|
157
158
|
}),
|
|
@@ -185,9 +186,13 @@ export const coordinateTargetPasswordRegistration = <Registration, Transaction,
|
|
|
185
186
|
Effect.gen(function* () {
|
|
186
187
|
return yield* owner(transaction, {
|
|
187
188
|
registrationAuthority: yield* makeSqlPasswordRegistrationAuthority<Registration>(
|
|
188
|
-
transaction as unknown as PasswordSqlDatabase,
|
|
189
189
|
mapping,
|
|
190
190
|
registrationOptions(configuration, true),
|
|
191
|
+
).pipe(
|
|
192
|
+
Effect.provideService(
|
|
193
|
+
CurrentPasswordSql,
|
|
194
|
+
transaction as unknown as PasswordSqlDatabase,
|
|
195
|
+
),
|
|
191
196
|
),
|
|
192
197
|
});
|
|
193
198
|
}),
|
|
@@ -198,24 +203,20 @@ export const coordinateTargetPasswordRegistration = <Registration, Transaction,
|
|
|
198
203
|
return result.value;
|
|
199
204
|
});
|
|
200
205
|
|
|
201
|
-
export const passwordPersistenceLayer = (
|
|
202
|
-
services: Effect.Effect<
|
|
203
|
-
{ readonly passwordPersistence: PasswordPersistence["Service"] },
|
|
204
|
-
never,
|
|
205
|
-
LifecycleHooks
|
|
206
|
-
>,
|
|
206
|
+
export const passwordPersistenceLayer = <E, R>(
|
|
207
|
+
services: Effect.Effect<{ readonly passwordPersistence: PasswordPersistence["Service"] }, E, R>,
|
|
207
208
|
) =>
|
|
208
209
|
Layer.effect(
|
|
209
210
|
PasswordPersistence,
|
|
210
211
|
Effect.map(services, (value) => value.passwordPersistence),
|
|
211
212
|
);
|
|
212
213
|
|
|
213
|
-
export const passwordRegistrationLayer = <Id, Registration>(
|
|
214
|
+
export const passwordRegistrationLayer = <Id, Registration, E, R>(
|
|
214
215
|
tag: Context.Key<Id, PasswordRegistrationAuthority<Registration>>,
|
|
215
216
|
services: Effect.Effect<
|
|
216
217
|
{ readonly registrationAuthority: PasswordRegistrationAuthority<Registration> },
|
|
217
|
-
|
|
218
|
-
|
|
218
|
+
E,
|
|
219
|
+
R
|
|
219
220
|
>,
|
|
220
221
|
) =>
|
|
221
222
|
Layer.effect(
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AnyRelations } from "drizzle-orm";
|
|
2
|
+
import type { EffectPgDatabase as PgliteDatabase } from "drizzle-orm/effect-pglite";
|
|
3
|
+
import type { EffectPgDatabase as PostgresDatabase } from "drizzle-orm/effect-postgres";
|
|
4
|
+
import { Context } from "effect";
|
|
5
|
+
|
|
6
|
+
/** Application-owned PostgreSQL database; Postgres and Pglite share this service. */
|
|
7
|
+
export class Database extends Context.Service<
|
|
8
|
+
Database,
|
|
9
|
+
PostgresDatabase<AnyRelations> | PgliteDatabase<AnyRelations>
|
|
10
|
+
>()("effect-auth/persistence-drizzle/Postgres/Database") {}
|