@yielded/auth-persistence-drizzle 0.1.0-beta.14 → 0.1.0-beta.15
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/dist/D1.d.mts +123 -9
- package/dist/Libsql.d.mts +143 -29
- package/dist/Mysql2.d.mts +130 -16
- package/dist/Pglite.d.mts +130 -16
- package/dist/Postgres.d.mts +131 -17
- package/dist/SqliteBun.d.mts +141 -27
- package/dist/SqliteDo.d.mts +145 -31
- package/dist/SqliteNode.d.mts +135 -21
- package/dist/SqliteWasm.d.mts +145 -31
- package/dist/drizzle/d1-emails.d.mts +3 -3
- package/dist/drizzle/d1-emails.mjs +56 -11
- package/dist/drizzle/d1-emails.mjs.map +1 -1
- package/dist/drizzle/d1-identity.mjs +9 -2
- package/dist/drizzle/d1-identity.mjs.map +1 -1
- package/dist/drizzle/d1-oauth.d.mts +8 -8
- package/dist/drizzle/d1-oauth.mjs +8 -8
- package/dist/drizzle/d1-oauth.mjs.map +1 -1
- package/dist/drizzle/d1-passkey.d.mts +2 -1
- package/dist/drizzle/d1-passkey.mjs +10 -8
- package/dist/drizzle/d1-passkey.mjs.map +1 -1
- package/dist/drizzle/d1-password-prepared.d.mts +1 -1
- package/dist/drizzle/d1-password-prepared.mjs +16 -5
- package/dist/drizzle/d1-password-prepared.mjs.map +1 -1
- package/dist/drizzle/d1-passwords.d.mts +2 -2
- package/dist/drizzle/d1-passwords.mjs +19 -6
- package/dist/drizzle/d1-passwords.mjs.map +1 -1
- package/dist/drizzle/d1-phone.d.mts +2 -1
- package/dist/drizzle/d1-phone.mjs +4 -2
- package/dist/drizzle/d1-phone.mjs.map +1 -1
- package/dist/drizzle/d1-proofs.d.mts +1 -1
- package/dist/drizzle/d1-proofs.mjs +18 -7
- package/dist/drizzle/d1-proofs.mjs.map +1 -1
- package/dist/drizzle/d1-sessions.d.mts +6 -5
- package/dist/drizzle/d1-sessions.mjs +29 -19
- package/dist/drizzle/d1-sessions.mjs.map +1 -1
- package/dist/drizzle/d1-totp.d.mts +2 -1
- package/dist/drizzle/d1-totp.mjs +4 -2
- package/dist/drizzle/d1-totp.mjs.map +1 -1
- package/dist/drizzle/email-registration.d.mts +5 -1
- package/dist/drizzle/email-registration.mjs +48 -4
- package/dist/drizzle/email-registration.mjs.map +1 -1
- package/dist/drizzle/email-target.d.mts +1 -0
- package/dist/drizzle/email-target.mjs +9 -0
- package/dist/drizzle/email-target.mjs.map +1 -1
- package/dist/drizzle/mysql-emails.d.mts +4 -4
- package/dist/drizzle/mysql-emails.mjs +8 -7
- package/dist/drizzle/mysql-emails.mjs.map +1 -1
- package/dist/drizzle/mysql-identity.mjs +11 -4
- package/dist/drizzle/mysql-identity.mjs.map +1 -1
- package/dist/drizzle/mysql-password-prepared.d.mts +2 -2
- package/dist/drizzle/mysql-password-prepared.mjs +4 -3
- package/dist/drizzle/mysql-password-prepared.mjs.map +1 -1
- package/dist/drizzle/mysql-passwords.d.mts +3 -3
- package/dist/drizzle/mysql-passwords.mjs +7 -6
- package/dist/drizzle/mysql-passwords.mjs.map +1 -1
- package/dist/drizzle/mysql-proofs.d.mts +2 -2
- package/dist/drizzle/mysql-proofs.mjs +4 -3
- package/dist/drizzle/mysql-proofs.mjs.map +1 -1
- package/dist/drizzle/mysql-sessions.d.mts +6 -6
- package/dist/drizzle/mysql-sessions.mjs +16 -15
- package/dist/drizzle/mysql-sessions.mjs.map +1 -1
- package/dist/drizzle/native-database.mjs +1 -1
- package/dist/drizzle/native-database.mjs.map +1 -1
- package/dist/drizzle/oauth-connected-drivers.mjs +10 -8
- package/dist/drizzle/oauth-connected-drivers.mjs.map +1 -1
- package/dist/drizzle/oauth-connected-flow.mjs +62 -13
- package/dist/drizzle/oauth-connected-flow.mjs.map +1 -1
- package/dist/drizzle/oauth-connected-input.mjs +6 -0
- package/dist/drizzle/oauth-connected-input.mjs.map +1 -1
- package/dist/drizzle/oauth-connected-maintenance.mjs +3 -3
- package/dist/drizzle/oauth-connected-maintenance.mjs.map +1 -1
- package/dist/drizzle/oauth-connected-target.d.mts +116 -2
- package/dist/drizzle/oauth-connected-target.mjs +5 -3
- package/dist/drizzle/oauth-connected-target.mjs.map +1 -1
- package/dist/drizzle/oauth-drivers.mjs +8 -8
- package/dist/drizzle/oauth-drivers.mjs.map +1 -1
- package/dist/drizzle/oauth-target.d.mts +3 -3
- package/dist/drizzle/oauth-target.mjs +8 -6
- package/dist/drizzle/oauth-target.mjs.map +1 -1
- package/dist/drizzle/passkey-drivers.mjs +4 -4
- package/dist/drizzle/passkey-drivers.mjs.map +1 -1
- package/dist/drizzle/passkey-write-drivers.mjs +4 -4
- 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 +5 -0
- package/dist/drizzle/password-prepared-sql.mjs.map +1 -1
- package/dist/drizzle/password-prepared-target.d.mts +2 -1
- package/dist/drizzle/password-prepared-target.mjs +5 -0
- package/dist/drizzle/password-prepared-target.mjs.map +1 -1
- package/dist/drizzle/password-registration.d.mts +1 -1
- package/dist/drizzle/password-registration.mjs +2 -0
- package/dist/drizzle/password-registration.mjs.map +1 -1
- package/dist/drizzle/password-target.d.mts +1 -0
- package/dist/drizzle/password-target.mjs +6 -0
- package/dist/drizzle/password-target.mjs.map +1 -1
- package/dist/drizzle/pg-emails.d.mts +4 -4
- package/dist/drizzle/pg-emails.mjs +8 -7
- package/dist/drizzle/pg-emails.mjs.map +1 -1
- package/dist/drizzle/pg-identity.mjs +12 -5
- package/dist/drizzle/pg-identity.mjs.map +1 -1
- package/dist/drizzle/pg-password-prepared.d.mts +2 -2
- package/dist/drizzle/pg-password-prepared.mjs +4 -3
- package/dist/drizzle/pg-password-prepared.mjs.map +1 -1
- package/dist/drizzle/pg-passwords.d.mts +3 -3
- package/dist/drizzle/pg-passwords.mjs +7 -6
- package/dist/drizzle/pg-passwords.mjs.map +1 -1
- package/dist/drizzle/pg-proofs.d.mts +2 -2
- package/dist/drizzle/pg-proofs.mjs +4 -3
- package/dist/drizzle/pg-proofs.mjs.map +1 -1
- package/dist/drizzle/pg-sessions.d.mts +6 -6
- package/dist/drizzle/pg-sessions.mjs +16 -15
- package/dist/drizzle/pg-sessions.mjs.map +1 -1
- package/dist/drizzle/phone-target.mjs +11 -2
- package/dist/drizzle/phone-target.mjs.map +1 -1
- package/dist/drizzle/proof-target.d.mts +1 -0
- package/dist/drizzle/proof-target.mjs +2 -0
- package/dist/drizzle/proof-target.mjs.map +1 -1
- package/dist/drizzle/query-operations.mjs +2 -0
- package/dist/drizzle/query-operations.mjs.map +1 -1
- package/dist/drizzle/session-target.d.mts +1 -0
- package/dist/drizzle/session-target.mjs +9 -6
- package/dist/drizzle/session-target.mjs.map +1 -1
- package/dist/drizzle/sqlite-emails.mjs +8 -7
- package/dist/drizzle/sqlite-emails.mjs.map +1 -1
- package/dist/drizzle/sqlite-identity.mjs +7 -2
- package/dist/drizzle/sqlite-identity.mjs.map +1 -1
- package/dist/drizzle/sqlite-password-prepared.mjs +4 -3
- package/dist/drizzle/sqlite-password-prepared.mjs.map +1 -1
- package/dist/drizzle/sqlite-passwords.mjs +7 -6
- package/dist/drizzle/sqlite-passwords.mjs.map +1 -1
- package/dist/drizzle/sqlite-proofs.mjs +4 -3
- package/dist/drizzle/sqlite-proofs.mjs.map +1 -1
- package/dist/drizzle/sqlite-sessions.mjs +16 -15
- package/dist/drizzle/sqlite-sessions.mjs.map +1 -1
- package/dist/drizzle/storage-validation.mjs +234 -0
- package/dist/drizzle/storage-validation.mjs.map +1 -0
- package/dist/drizzle/totp-target.mjs +5 -2
- package/dist/drizzle/totp-target.mjs.map +1 -1
- package/dist/drizzle/transaction-mysql.mjs +1 -1
- package/package.json +1 -1
- package/src/drizzle/d1-emails.ts +158 -40
- package/src/drizzle/d1-identity.ts +13 -0
- package/src/drizzle/d1-oauth.ts +8 -8
- package/src/drizzle/d1-passkey.ts +10 -8
- package/src/drizzle/d1-password-prepared.ts +14 -2
- package/src/drizzle/d1-passwords.ts +22 -4
- package/src/drizzle/d1-phone.ts +4 -2
- package/src/drizzle/d1-proofs.ts +55 -3
- package/src/drizzle/d1-sessions.ts +67 -18
- package/src/drizzle/d1-totp.ts +4 -2
- package/src/drizzle/email-registration.ts +160 -12
- package/src/drizzle/email-target.ts +22 -4
- package/src/drizzle/mysql-emails.ts +17 -7
- package/src/drizzle/mysql-identity.ts +13 -0
- package/src/drizzle/mysql-password-prepared.ts +7 -3
- package/src/drizzle/mysql-passwords.ts +13 -6
- package/src/drizzle/mysql-proofs.ts +7 -3
- package/src/drizzle/mysql-sessions.ts +31 -15
- package/src/drizzle/native-database.ts +5 -4
- package/src/drizzle/oauth-connected-drivers.ts +10 -8
- package/src/drizzle/oauth-connected-flow.ts +98 -10
- package/src/drizzle/oauth-connected-input.ts +7 -0
- package/src/drizzle/oauth-connected-maintenance.ts +3 -2
- package/src/drizzle/oauth-connected-target.ts +4 -2
- package/src/drizzle/oauth-drivers.ts +8 -8
- package/src/drizzle/oauth-target.ts +13 -7
- package/src/drizzle/passkey-drivers.ts +4 -4
- package/src/drizzle/passkey-write-drivers.ts +8 -5
- package/src/drizzle/password-prepared-sql.ts +13 -1
- package/src/drizzle/password-prepared-target.ts +7 -1
- package/src/drizzle/password-registration.ts +10 -3
- package/src/drizzle/password-target.ts +22 -4
- package/src/drizzle/pg-emails.ts +17 -7
- package/src/drizzle/pg-identity.ts +13 -0
- package/src/drizzle/pg-password-prepared.ts +7 -3
- package/src/drizzle/pg-passwords.ts +13 -6
- package/src/drizzle/pg-proofs.ts +7 -3
- package/src/drizzle/pg-sessions.ts +31 -15
- package/src/drizzle/phone-target.ts +30 -5
- package/src/drizzle/proof-target.ts +10 -2
- package/src/drizzle/query-operations.ts +2 -0
- package/src/drizzle/session-target.ts +20 -3
- package/src/drizzle/sqlite-emails.ts +17 -7
- package/src/drizzle/sqlite-identity.ts +5 -0
- package/src/drizzle/sqlite-password-prepared.ts +7 -3
- package/src/drizzle/sqlite-passwords.ts +13 -6
- package/src/drizzle/sqlite-proofs.ts +7 -3
- package/src/drizzle/sqlite-sessions.ts +31 -15
- package/src/drizzle/storage-validation.ts +285 -0
- package/src/drizzle/totp-target.ts +16 -4
|
@@ -163,12 +163,15 @@ export const makePasskeyWriteTarget = <
|
|
|
163
163
|
| RSetup
|
|
164
164
|
| DatabaseRequirements
|
|
165
165
|
> {
|
|
166
|
-
return Effect.flatMap(acquire, (database) =>
|
|
166
|
+
return Effect.flatMap(nativeDatabase(acquire), (database) =>
|
|
167
167
|
coordinateTargetPasskeyManagement(
|
|
168
168
|
database,
|
|
169
169
|
options.mapping,
|
|
170
170
|
configuration,
|
|
171
|
-
(
|
|
171
|
+
(
|
|
172
|
+
transaction: TransactionOf<Database>,
|
|
173
|
+
services,
|
|
174
|
+
): Effect.Effect<A, E, Exclude<R, PasskeyPersistence | PasskeyManagementPersistence>> => {
|
|
172
175
|
const context = Context.make(PasskeyPersistence, services.passkeyPersistence).pipe(
|
|
173
176
|
Context.add(PasskeyManagementPersistence, services.passkeyManagementPersistence),
|
|
174
177
|
);
|
|
@@ -179,7 +182,7 @@ export const makePasskeyWriteTarget = <
|
|
|
179
182
|
? work
|
|
180
183
|
: Effect.provideService(work, options.transaction, options.transaction.of(transaction));
|
|
181
184
|
},
|
|
182
|
-
),
|
|
185
|
+
).pipe(Effect.provideService(NativeDatabase, database)),
|
|
183
186
|
);
|
|
184
187
|
}
|
|
185
188
|
|
|
@@ -338,7 +341,7 @@ export const makePasskeyWriteTarget = <
|
|
|
338
341
|
PasskeyCoordinatorError<E> | DatabaseError,
|
|
339
342
|
Exclude<R, PasskeyPersistence | AuthorityId> | LifecycleHooks | RSetup | DatabaseRequirements
|
|
340
343
|
> {
|
|
341
|
-
return Effect.flatMap(acquire, (database) =>
|
|
344
|
+
return Effect.flatMap(nativeDatabase(acquire), (database) =>
|
|
342
345
|
coordinateTargetPasskeyRegistrationWriter(
|
|
343
346
|
database,
|
|
344
347
|
options.mapping,
|
|
@@ -357,7 +360,7 @@ export const makePasskeyWriteTarget = <
|
|
|
357
360
|
? work
|
|
358
361
|
: Effect.provideService(work, options.transaction, options.transaction.of(transaction));
|
|
359
362
|
},
|
|
360
|
-
),
|
|
363
|
+
).pipe(Effect.provideService(NativeDatabase, database)),
|
|
361
364
|
);
|
|
362
365
|
}
|
|
363
366
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
type NativeDatabase,
|
|
2
3
|
CurrentPasswordPreparedTransaction,
|
|
3
4
|
PasswordPreparedPostconditions,
|
|
4
5
|
PasswordPreparedJournalGuards,
|
|
@@ -53,6 +54,7 @@ import {
|
|
|
53
54
|
type PasswordSqlQuery,
|
|
54
55
|
} from "./password-sql";
|
|
55
56
|
import { checkProofCompletionIn, completeProofPlanIn } from "./proof-sql";
|
|
57
|
+
import { validateDrizzleStorage } from "./storage-validation";
|
|
56
58
|
|
|
57
59
|
const translateFailure = <A, E, R>(
|
|
58
60
|
effect: Effect.Effect<A, E, R>,
|
|
@@ -410,8 +412,18 @@ export const makeSqlPasswordPreparedPersistence = Effect.fn("makeSqlPasswordPrep
|
|
|
410
412
|
function* (
|
|
411
413
|
mapping: Mapping,
|
|
412
414
|
configuration: PasswordSqlConfiguration,
|
|
413
|
-
): Effect.fn.Return<
|
|
415
|
+
): Effect.fn.Return<
|
|
416
|
+
PasswordPreparedPersistence,
|
|
417
|
+
PasswordUnavailable,
|
|
418
|
+
LifecycleHooks | CurrentPasswordSql | NativeDatabase
|
|
419
|
+
> {
|
|
414
420
|
const database = yield* CurrentPasswordSql;
|
|
421
|
+
|
|
422
|
+
if (!configuration.coordinated)
|
|
423
|
+
yield* validateDrizzleStorage({
|
|
424
|
+
...mapping,
|
|
425
|
+
proof: configuration.proof?.mapping,
|
|
426
|
+
}).pipe(Effect.mapError(unavailable));
|
|
415
427
|
const hooks = yield* LifecycleHooks;
|
|
416
428
|
|
|
417
429
|
const p = mapping.password,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
type NativeDatabase,
|
|
2
3
|
CurrentPasswordPreparedTransaction,
|
|
3
4
|
PasswordPreparedPostconditions,
|
|
4
5
|
PasswordPreparedJournalGuards,
|
|
@@ -23,6 +24,7 @@ import {
|
|
|
23
24
|
type PasswordTargetConfiguration,
|
|
24
25
|
type PasswordCoordinatorError,
|
|
25
26
|
} from "./password-target";
|
|
27
|
+
import { validateDrizzleStorage } from "./storage-validation";
|
|
26
28
|
|
|
27
29
|
export const makeTargetPasswordPreparedPersistenceServices = (
|
|
28
30
|
mapping: any,
|
|
@@ -51,13 +53,17 @@ export const coordinateTargetPasswordPreparedPersistence = <Transaction, A, E, R
|
|
|
51
53
|
transaction: Transaction,
|
|
52
54
|
services: { readonly passwordPreparedPersistence: PasswordPreparedPersistence },
|
|
53
55
|
) => Effect.Effect<A, E, R>,
|
|
54
|
-
): Effect.Effect<A, PasswordCoordinatorError<E>, R | LifecycleHooks> =>
|
|
56
|
+
): Effect.Effect<A, PasswordCoordinatorError<E>, R | LifecycleHooks | NativeDatabase> =>
|
|
55
57
|
Effect.gen(function* () {
|
|
56
58
|
const hooks = yield* LifecycleHooks;
|
|
57
59
|
|
|
58
60
|
if (yield* hasCommitScope) return yield* PasswordUnavailable.make({});
|
|
59
61
|
yield* configuration.coordinatorGuard ?? configuration.standaloneGuard;
|
|
60
62
|
|
|
63
|
+
yield* validateDrizzleStorage({ ...mapping, proof: proofMapping }).pipe(
|
|
64
|
+
Effect.mapError(() => PasswordUnavailable.make({})),
|
|
65
|
+
);
|
|
66
|
+
|
|
61
67
|
const result = yield* coordinateCommit(
|
|
62
68
|
() =>
|
|
63
69
|
database.transaction((transaction) =>
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
NativeDatabase,
|
|
3
|
+
PasswordRegistrationAuthority,
|
|
4
|
+
} from "@yielded/auth-persistence/Adapter";
|
|
1
5
|
import {
|
|
2
6
|
coordinateCommit,
|
|
3
7
|
CurrentCommitJournal,
|
|
@@ -25,6 +29,7 @@ import {
|
|
|
25
29
|
} from "./password-model";
|
|
26
30
|
import { CurrentPasswordSql, type PasswordSqlQuery } from "./password-sql";
|
|
27
31
|
import { CurrentProofSql, type ProofSqlDatabase } from "./proof-sql";
|
|
32
|
+
import { validateDrizzleStorage } from "./storage-validation";
|
|
28
33
|
|
|
29
34
|
type Mapping<Registration> = AnyPasswordRegistrationMapping<Registration>;
|
|
30
35
|
const unavailable = () => PasswordUnavailable.make({});
|
|
@@ -40,7 +45,6 @@ const translateFailure = <A, E, R>(
|
|
|
40
45
|
Schema.is(HookConfigurationError)(error),
|
|
41
46
|
).pipe(Effect.catchCause((cause) => Effect.failCause(Cause.map(cause, () => unavailable()))));
|
|
42
47
|
|
|
43
|
-
import type { PasswordRegistrationAuthority } from "@yielded/auth-persistence/Adapter";
|
|
44
48
|
export type { PasswordRegistrationAuthority } from "@yielded/auth-persistence/Adapter";
|
|
45
49
|
|
|
46
50
|
export interface PasswordRegistrationConfiguration {
|
|
@@ -218,10 +222,13 @@ export const makeSqlPasswordRegistrationAuthority = Effect.fn(
|
|
|
218
222
|
configuration: PasswordRegistrationConfiguration,
|
|
219
223
|
): Effect.fn.Return<
|
|
220
224
|
PasswordRegistrationAuthority<Registration>,
|
|
221
|
-
|
|
222
|
-
LifecycleHooks | CurrentPasswordSql
|
|
225
|
+
PasswordUnavailable,
|
|
226
|
+
LifecycleHooks | CurrentPasswordSql | NativeDatabase
|
|
223
227
|
> {
|
|
224
228
|
const database = yield* CurrentPasswordSql;
|
|
229
|
+
|
|
230
|
+
if (!configuration.coordinated)
|
|
231
|
+
yield* validateDrizzleStorage(mapping).pipe(Effect.mapError(unavailable));
|
|
225
232
|
const hooks = yield* LifecycleHooks;
|
|
226
233
|
|
|
227
234
|
return {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { NativeDatabase } from "@yielded/auth-persistence/Adapter";
|
|
1
2
|
import {
|
|
2
3
|
coordinateCommit,
|
|
3
4
|
hasCommitScope,
|
|
@@ -23,6 +24,7 @@ import {
|
|
|
23
24
|
} from "./password-sql";
|
|
24
25
|
import type { ProofTargetConfiguration } from "./proof-target";
|
|
25
26
|
import { sqlClientStandaloneGuard, type TransactionService } from "./standalone-guard";
|
|
27
|
+
import { validateDrizzleStorage } from "./storage-validation";
|
|
26
28
|
|
|
27
29
|
export interface PasswordTargetConfiguration {
|
|
28
30
|
readonly mode: "interactive" | "synchronous";
|
|
@@ -133,13 +135,21 @@ export const coordinateTargetPasswordPersistence = <Transaction, A, E, R>(
|
|
|
133
135
|
transaction: Transaction,
|
|
134
136
|
services: { readonly passwordPersistence: PasswordPersistence["Service"] },
|
|
135
137
|
) => Effect.Effect<A, E, R>,
|
|
136
|
-
): Effect.Effect<A, PasswordCoordinatorError<E>, R | LifecycleHooks> =>
|
|
137
|
-
Effect.gen(function* (): Effect.fn.Return<
|
|
138
|
+
): Effect.Effect<A, PasswordCoordinatorError<E>, R | LifecycleHooks | NativeDatabase> =>
|
|
139
|
+
Effect.gen(function* (): Effect.fn.Return<
|
|
140
|
+
A,
|
|
141
|
+
PasswordCoordinatorError<E>,
|
|
142
|
+
R | LifecycleHooks | NativeDatabase
|
|
143
|
+
> {
|
|
138
144
|
const hooks = yield* LifecycleHooks;
|
|
139
145
|
|
|
140
146
|
if (yield* hasCommitScope) return yield* PasswordUnavailable.make({});
|
|
141
147
|
yield* configuration.coordinatorGuard ?? configuration.standaloneGuard;
|
|
142
148
|
|
|
149
|
+
yield* validateDrizzleStorage({ ...mapping, proof: proofMapping }).pipe(
|
|
150
|
+
Effect.mapError(() => PasswordUnavailable.make({})),
|
|
151
|
+
);
|
|
152
|
+
|
|
143
153
|
const result = yield* coordinateCommit(
|
|
144
154
|
() =>
|
|
145
155
|
database.transaction((transaction) =>
|
|
@@ -173,13 +183,21 @@ export const coordinateTargetPasswordRegistration = <Registration, Transaction,
|
|
|
173
183
|
readonly registrationAuthority: PasswordRegistrationAuthority<Registration>;
|
|
174
184
|
},
|
|
175
185
|
) => Effect.Effect<A, E, R>,
|
|
176
|
-
): Effect.Effect<A, PasswordCoordinatorError<E>, R | LifecycleHooks> =>
|
|
177
|
-
Effect.gen(function* (): Effect.fn.Return<
|
|
186
|
+
): Effect.Effect<A, PasswordCoordinatorError<E>, R | LifecycleHooks | NativeDatabase> =>
|
|
187
|
+
Effect.gen(function* (): Effect.fn.Return<
|
|
188
|
+
A,
|
|
189
|
+
PasswordCoordinatorError<E>,
|
|
190
|
+
R | LifecycleHooks | NativeDatabase
|
|
191
|
+
> {
|
|
178
192
|
const hooks = yield* LifecycleHooks;
|
|
179
193
|
|
|
180
194
|
if (yield* hasCommitScope) return yield* PasswordUnavailable.make({});
|
|
181
195
|
yield* configuration.coordinatorGuard ?? configuration.standaloneGuard;
|
|
182
196
|
|
|
197
|
+
yield* validateDrizzleStorage(mapping).pipe(
|
|
198
|
+
Effect.mapError(() => PasswordUnavailable.make({})),
|
|
199
|
+
);
|
|
200
|
+
|
|
183
201
|
const result = yield* coordinateCommit(
|
|
184
202
|
() =>
|
|
185
203
|
database.transaction((transaction) =>
|
package/src/drizzle/pg-emails.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NativeDatabase } from "@yielded/auth-persistence/Adapter";
|
|
1
2
|
import { EmailAddressPersistence, type EmailUnavailable } from "@yielded/auth/Email";
|
|
2
3
|
import type { LifecycleHooks, HookConfigurationError } from "@yielded/auth/Hooks";
|
|
3
4
|
/* oxlint-disable no-explicit-any -- proof mapping tables are independently typed by the proof owner; this driver forwards them unchanged to the shared target. */
|
|
@@ -77,7 +78,10 @@ export const makePgEmailSignInServices = <
|
|
|
77
78
|
Effect.flatMap(
|
|
78
79
|
Effect.map(acquireTransactionService(DatabaseService), configuration),
|
|
79
80
|
(configuration) => makeTargetEmailSignInServices(mapping, configuration),
|
|
80
|
-
).pipe(
|
|
81
|
+
).pipe(
|
|
82
|
+
Effect.provideServiceEffect(CurrentEmailSql, nativeDatabase(DatabaseService)),
|
|
83
|
+
Effect.provideServiceEffect(NativeDatabase, nativeDatabase(DatabaseService)),
|
|
84
|
+
);
|
|
81
85
|
|
|
82
86
|
export const makePgEmailAddressServices = <
|
|
83
87
|
S extends AnyPgTable,
|
|
@@ -93,7 +97,10 @@ export const makePgEmailAddressServices = <
|
|
|
93
97
|
Effect.flatMap(
|
|
94
98
|
Effect.map(acquireTransactionService(DatabaseService), configuration),
|
|
95
99
|
(configuration) => makeTargetEmailAddressServices(mapping, proofMapping, configuration),
|
|
96
|
-
).pipe(
|
|
100
|
+
).pipe(
|
|
101
|
+
Effect.provideServiceEffect(CurrentEmailSql, nativeDatabase(DatabaseService)),
|
|
102
|
+
Effect.provideServiceEffect(NativeDatabase, nativeDatabase(DatabaseService)),
|
|
103
|
+
);
|
|
97
104
|
|
|
98
105
|
export function coordinatePgEmailAddress<
|
|
99
106
|
D extends Database,
|
|
@@ -179,7 +186,7 @@ export function coordinatePgEmailAddress<
|
|
|
179
186
|
E | EmailUnavailable | HookConfigurationError | SqlError | DatabaseError,
|
|
180
187
|
Exclude<R, EmailAddressPersistence> | LifecycleHooks | DatabaseRequirements
|
|
181
188
|
> {
|
|
182
|
-
return Effect.flatMap(acquire, (database) =>
|
|
189
|
+
return Effect.flatMap(nativeDatabase(acquire), (database) =>
|
|
183
190
|
coordinateTargetEmailAddress<TransactionOf<D>, Out, E, Exclude<R, EmailAddressPersistence>>(
|
|
184
191
|
database,
|
|
185
192
|
options.mapping,
|
|
@@ -196,7 +203,7 @@ export function coordinatePgEmailAddress<
|
|
|
196
203
|
? work
|
|
197
204
|
: Effect.provideService(work, options.transaction, options.transaction.of(transaction));
|
|
198
205
|
},
|
|
199
|
-
),
|
|
206
|
+
).pipe(Effect.provideService(NativeDatabase, database)),
|
|
200
207
|
);
|
|
201
208
|
}
|
|
202
209
|
|
|
@@ -216,7 +223,10 @@ export const makePgEmailRegistrationServices = <
|
|
|
216
223
|
Effect.map(acquireTransactionService(DatabaseService), configuration),
|
|
217
224
|
(configuration) =>
|
|
218
225
|
makeTargetEmailRegistrationServices<Registration>(mapping, proofMapping, configuration),
|
|
219
|
-
).pipe(
|
|
226
|
+
).pipe(
|
|
227
|
+
Effect.provideServiceEffect(CurrentEmailSql, nativeDatabase(DatabaseService)),
|
|
228
|
+
Effect.provideServiceEffect(NativeDatabase, nativeDatabase(DatabaseService)),
|
|
229
|
+
);
|
|
220
230
|
|
|
221
231
|
export function coordinatePgEmailRegistration<
|
|
222
232
|
TargetId,
|
|
@@ -311,7 +321,7 @@ export function coordinatePgEmailRegistration<
|
|
|
311
321
|
E | EmailUnavailable | HookConfigurationError | SqlError | DatabaseError,
|
|
312
322
|
Exclude<R, TargetId> | LifecycleHooks | DatabaseRequirements
|
|
313
323
|
> {
|
|
314
|
-
return Effect.flatMap(acquire, (database) =>
|
|
324
|
+
return Effect.flatMap(nativeDatabase(acquire), (database) =>
|
|
315
325
|
coordinateTargetEmailRegistration<Registration, TransactionOf<D>, Out, E, Exclude<R, TargetId>>(
|
|
316
326
|
database,
|
|
317
327
|
options.mapping,
|
|
@@ -328,6 +338,6 @@ export function coordinatePgEmailRegistration<
|
|
|
328
338
|
? work
|
|
329
339
|
: Effect.provideService(work, options.transaction, options.transaction.of(transaction));
|
|
330
340
|
},
|
|
331
|
-
),
|
|
341
|
+
).pipe(Effect.provideService(NativeDatabase, database)),
|
|
332
342
|
);
|
|
333
343
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NativeDatabase } from "@yielded/auth-persistence/Adapter";
|
|
1
2
|
import {
|
|
2
3
|
ExternalIdentityMutation,
|
|
3
4
|
IdentityConflict,
|
|
@@ -24,7 +25,9 @@ import {
|
|
|
24
25
|
type IdentityTables,
|
|
25
26
|
type SubjectProvisioningTables,
|
|
26
27
|
} from "./model";
|
|
28
|
+
import { nativeDatabase } from "./native-database";
|
|
27
29
|
import { Database as DatabaseService } from "./pg-database";
|
|
30
|
+
import { validateDrizzleStorage } from "./storage-validation";
|
|
28
31
|
|
|
29
32
|
type RuntimeDatabase = PgDatabase<any>;
|
|
30
33
|
|
|
@@ -48,6 +51,11 @@ export const makePgSubjectProvisioningServices = Effect.fnUntraced(function* <
|
|
|
48
51
|
>(mapping: SubjectProvisioningTables<Subject, Identifier, Request, NativeId>) {
|
|
49
52
|
const database = yield* DatabaseService;
|
|
50
53
|
|
|
54
|
+
yield* validateDrizzleStorage(mapping).pipe(
|
|
55
|
+
Effect.provideServiceEffect(NativeDatabase, nativeDatabase(DatabaseService)),
|
|
56
|
+
Effect.mapError(() => IdentityUnavailable.make()),
|
|
57
|
+
);
|
|
58
|
+
|
|
51
59
|
const db = database as RuntimeDatabase;
|
|
52
60
|
const requestTable = mapping.provisioningRequest.table;
|
|
53
61
|
const requestIdColumn = column(requestTable, mapping.provisioningRequest.requestId);
|
|
@@ -181,6 +189,11 @@ export const makePgExternalIdentityServices = Effect.fnUntraced(function* <
|
|
|
181
189
|
>(mapping: ExternalIdentityTables<Subject, External, NativeId>) {
|
|
182
190
|
const database = yield* DatabaseService;
|
|
183
191
|
|
|
192
|
+
yield* validateDrizzleStorage(mapping).pipe(
|
|
193
|
+
Effect.provideServiceEffect(NativeDatabase, nativeDatabase(DatabaseService)),
|
|
194
|
+
Effect.mapError(() => IdentityUnavailable.make()),
|
|
195
|
+
);
|
|
196
|
+
|
|
184
197
|
const db = database as RuntimeDatabase;
|
|
185
198
|
const externalTable = mapping.externalIdentity.table;
|
|
186
199
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NativeDatabase } from "@yielded/auth-persistence/Adapter";
|
|
1
2
|
import type { LifecycleHooks, HookConfigurationError } from "@yielded/auth/Hooks";
|
|
2
3
|
import type { PasswordUnavailable, PasswordPreparedPersistence } from "@yielded/auth/Password";
|
|
3
4
|
import type { AnyRelations } from "drizzle-orm";
|
|
@@ -51,7 +52,10 @@ export const makePgPasswordPreparedPersistenceServices = <
|
|
|
51
52
|
Effect.map(acquireTransactionService(DatabaseService), configuration),
|
|
52
53
|
(configuration) =>
|
|
53
54
|
makeTargetPasswordPreparedPersistenceServices(mapping, configuration, proofMapping),
|
|
54
|
-
).pipe(
|
|
55
|
+
).pipe(
|
|
56
|
+
Effect.provideServiceEffect(CurrentPasswordSql, nativeDatabase(DatabaseService)),
|
|
57
|
+
Effect.provideServiceEffect(NativeDatabase, nativeDatabase(DatabaseService)),
|
|
58
|
+
);
|
|
55
59
|
|
|
56
60
|
export function coordinatePgPasswordPreparedPersistence<
|
|
57
61
|
TargetId,
|
|
@@ -185,7 +189,7 @@ export function coordinatePgPasswordPreparedPersistence<
|
|
|
185
189
|
E | PasswordUnavailable | HookConfigurationError | SqlError | DatabaseError,
|
|
186
190
|
Exclude<R, TargetId> | LifecycleHooks | DatabaseRequirements
|
|
187
191
|
> {
|
|
188
|
-
return Effect.flatMap(acquire, (database) =>
|
|
192
|
+
return Effect.flatMap(nativeDatabase(acquire), (database) =>
|
|
189
193
|
coordinateTargetPasswordPreparedPersistence<TransactionOf<D>, Out, E, Exclude<R, TargetId>>(
|
|
190
194
|
database,
|
|
191
195
|
options.mapping,
|
|
@@ -202,6 +206,6 @@ export function coordinatePgPasswordPreparedPersistence<
|
|
|
202
206
|
? work
|
|
203
207
|
: Effect.provideService(work, options.transaction, options.transaction.of(transaction));
|
|
204
208
|
},
|
|
205
|
-
),
|
|
209
|
+
).pipe(Effect.provideService(NativeDatabase, database)),
|
|
206
210
|
);
|
|
207
211
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NativeDatabase } from "@yielded/auth-persistence/Adapter";
|
|
1
2
|
import type { LifecycleHooks, HookConfigurationError } from "@yielded/auth/Hooks";
|
|
2
3
|
import { type PasswordUnavailable, PasswordPersistence } from "@yielded/auth/Password";
|
|
3
4
|
/* oxlint-disable no-explicit-any -- proof mapping tables are independently typed by the proof owner; this driver forwards them unchanged to the shared target. */
|
|
@@ -90,7 +91,10 @@ export const makePgPasswordPersistenceServices = <
|
|
|
90
91
|
Effect.flatMap(
|
|
91
92
|
Effect.map(acquireTransactionService(DatabaseService), configuration),
|
|
92
93
|
(configuration) => makeTargetPasswordPersistenceServices(mapping, configuration, proofMapping),
|
|
93
|
-
).pipe(
|
|
94
|
+
).pipe(
|
|
95
|
+
Effect.provideServiceEffect(CurrentPasswordSql, nativeDatabase(DatabaseService)),
|
|
96
|
+
Effect.provideServiceEffect(NativeDatabase, nativeDatabase(DatabaseService)),
|
|
97
|
+
);
|
|
94
98
|
|
|
95
99
|
export function coordinatePgPasswordPersistence<
|
|
96
100
|
D extends Database,
|
|
@@ -194,7 +198,7 @@ export function coordinatePgPasswordPersistence<
|
|
|
194
198
|
E | PasswordUnavailable | HookConfigurationError | SqlError | DatabaseError,
|
|
195
199
|
Exclude<R, PasswordPersistence> | LifecycleHooks | DatabaseRequirements
|
|
196
200
|
> {
|
|
197
|
-
return Effect.flatMap(acquire, (database) =>
|
|
201
|
+
return Effect.flatMap(nativeDatabase(acquire), (database) =>
|
|
198
202
|
coordinateTargetPasswordPersistence<TransactionOf<D>, Out, E, Exclude<R, PasswordPersistence>>(
|
|
199
203
|
database,
|
|
200
204
|
options.mapping,
|
|
@@ -211,7 +215,7 @@ export function coordinatePgPasswordPersistence<
|
|
|
211
215
|
? work
|
|
212
216
|
: Effect.provideService(work, options.transaction, options.transaction.of(transaction));
|
|
213
217
|
},
|
|
214
|
-
),
|
|
218
|
+
).pipe(Effect.provideService(NativeDatabase, database)),
|
|
215
219
|
);
|
|
216
220
|
}
|
|
217
221
|
|
|
@@ -229,7 +233,10 @@ export const makePgPasswordRegistrationServices = <
|
|
|
229
233
|
Effect.flatMap(
|
|
230
234
|
Effect.map(acquireTransactionService(DatabaseService), configuration),
|
|
231
235
|
(configuration) => makeTargetPasswordRegistrationServices<Registration>(mapping, configuration),
|
|
232
|
-
).pipe(
|
|
236
|
+
).pipe(
|
|
237
|
+
Effect.provideServiceEffect(CurrentPasswordSql, nativeDatabase(DatabaseService)),
|
|
238
|
+
Effect.provideServiceEffect(NativeDatabase, nativeDatabase(DatabaseService)),
|
|
239
|
+
);
|
|
233
240
|
|
|
234
241
|
export function coordinatePgPasswordRegistration<
|
|
235
242
|
TargetId,
|
|
@@ -321,7 +328,7 @@ export function coordinatePgPasswordRegistration<
|
|
|
321
328
|
E | PasswordUnavailable | HookConfigurationError | SqlError | DatabaseError,
|
|
322
329
|
Exclude<R, TargetId> | LifecycleHooks | DatabaseRequirements
|
|
323
330
|
> {
|
|
324
|
-
return Effect.flatMap(acquire, (database) =>
|
|
331
|
+
return Effect.flatMap(nativeDatabase(acquire), (database) =>
|
|
325
332
|
coordinateTargetPasswordRegistration<
|
|
326
333
|
Registration,
|
|
327
334
|
TransactionOf<D>,
|
|
@@ -343,7 +350,7 @@ export function coordinatePgPasswordRegistration<
|
|
|
343
350
|
? work
|
|
344
351
|
: Effect.provideService(work, options.transaction, options.transaction.of(transaction));
|
|
345
352
|
},
|
|
346
|
-
),
|
|
353
|
+
).pipe(Effect.provideService(NativeDatabase, database)),
|
|
347
354
|
);
|
|
348
355
|
}
|
|
349
356
|
|
package/src/drizzle/pg-proofs.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NativeDatabase } from "@yielded/auth-persistence/Adapter";
|
|
1
2
|
import type { LifecycleHooks, HookConfigurationError } from "@yielded/auth/Hooks";
|
|
2
3
|
import { type ProofUnavailable, ProofPersistence } from "@yielded/auth/Proofs";
|
|
3
4
|
import type { AnyRelations } from "drizzle-orm";
|
|
@@ -80,7 +81,10 @@ export const makePgProofPersistenceServices = <
|
|
|
80
81
|
Effect.flatMap(
|
|
81
82
|
Effect.map(acquireTransactionService(DatabaseService), configuration),
|
|
82
83
|
(configuration) => makeTargetProofPersistenceServices(mapping, configuration),
|
|
83
|
-
).pipe(
|
|
84
|
+
).pipe(
|
|
85
|
+
Effect.provideServiceEffect(CurrentProofSql, nativeDatabase(DatabaseService)),
|
|
86
|
+
Effect.provideServiceEffect(NativeDatabase, nativeDatabase(DatabaseService)),
|
|
87
|
+
);
|
|
84
88
|
|
|
85
89
|
export function coordinatePgProofPersistence<
|
|
86
90
|
D extends Database,
|
|
@@ -181,7 +185,7 @@ export function coordinatePgProofPersistence<
|
|
|
181
185
|
E | ProofUnavailable | HookConfigurationError | SqlError | DatabaseError,
|
|
182
186
|
Exclude<R, ProofPersistence> | LifecycleHooks | DatabaseRequirements
|
|
183
187
|
> {
|
|
184
|
-
return Effect.flatMap(acquire, (database) =>
|
|
188
|
+
return Effect.flatMap(nativeDatabase(acquire), (database) =>
|
|
185
189
|
coordinateTargetProofPersistence<TransactionOf<D>, A, E, Exclude<R, ProofPersistence>>(
|
|
186
190
|
database,
|
|
187
191
|
options.mapping,
|
|
@@ -197,6 +201,6 @@ export function coordinatePgProofPersistence<
|
|
|
197
201
|
? work
|
|
198
202
|
: Effect.provideService(work, options.transaction, options.transaction.of(transaction));
|
|
199
203
|
},
|
|
200
|
-
),
|
|
204
|
+
).pipe(Effect.provideService(NativeDatabase, database)),
|
|
201
205
|
);
|
|
202
206
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NativeDatabase } from "@yielded/auth-persistence/Adapter";
|
|
1
2
|
import type { LifecycleHooks, HookConfigurationError } from "@yielded/auth/Hooks";
|
|
2
3
|
import {
|
|
3
4
|
AuthenticationAuthority,
|
|
@@ -73,7 +74,10 @@ export const makePgAuthenticationAuthorityServices = <
|
|
|
73
74
|
Effect.flatMap(
|
|
74
75
|
Effect.map(acquireTransactionService(DatabaseService), configuration),
|
|
75
76
|
(configuration) => makeTargetAuthenticationAuthorityServices<Claims>(mapping, configuration),
|
|
76
|
-
).pipe(
|
|
77
|
+
).pipe(
|
|
78
|
+
Effect.provideServiceEffect(CurrentSessionSql, nativeDatabase(DatabaseService)),
|
|
79
|
+
Effect.provideServiceEffect(NativeDatabase, nativeDatabase(DatabaseService)),
|
|
80
|
+
);
|
|
77
81
|
|
|
78
82
|
export const makePgPendingAuthenticationServices = <
|
|
79
83
|
Claims,
|
|
@@ -95,7 +99,10 @@ export const makePgPendingAuthenticationServices = <
|
|
|
95
99
|
Effect.flatMap(
|
|
96
100
|
Effect.map(acquireTransactionService(DatabaseService), configuration),
|
|
97
101
|
(configuration) => makeTargetPendingAuthenticationServices<Claims>(mapping, configuration),
|
|
98
|
-
).pipe(
|
|
102
|
+
).pipe(
|
|
103
|
+
Effect.provideServiceEffect(CurrentSessionSql, nativeDatabase(DatabaseService)),
|
|
104
|
+
Effect.provideServiceEffect(NativeDatabase, nativeDatabase(DatabaseService)),
|
|
105
|
+
);
|
|
99
106
|
|
|
100
107
|
export const makePgStatefulSessionServices = <
|
|
101
108
|
Claims,
|
|
@@ -121,7 +128,10 @@ export const makePgStatefulSessionServices = <
|
|
|
121
128
|
Effect.flatMap(
|
|
122
129
|
Effect.map(acquireTransactionService(DatabaseService), configuration),
|
|
123
130
|
(configuration) => makeTargetStatefulSessionServices<Claims>(mapping, configuration),
|
|
124
|
-
).pipe(
|
|
131
|
+
).pipe(
|
|
132
|
+
Effect.provideServiceEffect(CurrentSessionSql, nativeDatabase(DatabaseService)),
|
|
133
|
+
Effect.provideServiceEffect(NativeDatabase, nativeDatabase(DatabaseService)),
|
|
134
|
+
);
|
|
125
135
|
|
|
126
136
|
export const makePgSignedSessionValidityServices = <
|
|
127
137
|
Subject extends AnyPgTable,
|
|
@@ -134,7 +144,10 @@ export const makePgSignedSessionValidityServices = <
|
|
|
134
144
|
Effect.flatMap(
|
|
135
145
|
Effect.map(acquireTransactionService(DatabaseService), configuration),
|
|
136
146
|
(configuration) => makeTargetSignedSessionValidityServices(mapping, configuration),
|
|
137
|
-
).pipe(
|
|
147
|
+
).pipe(
|
|
148
|
+
Effect.provideServiceEffect(CurrentSessionSql, nativeDatabase(DatabaseService)),
|
|
149
|
+
Effect.provideServiceEffect(NativeDatabase, nativeDatabase(DatabaseService)),
|
|
150
|
+
);
|
|
138
151
|
|
|
139
152
|
export function coordinatePgAuthenticationAuthority<
|
|
140
153
|
Claims,
|
|
@@ -217,7 +230,7 @@ export function coordinatePgAuthenticationAuthority<
|
|
|
217
230
|
E | SessionUnavailable | HookConfigurationError | SqlError | DatabaseError,
|
|
218
231
|
Exclude<R, AuthenticationAuthority> | LifecycleHooks | DatabaseRequirements
|
|
219
232
|
> {
|
|
220
|
-
return Effect.flatMap(acquire, (database) =>
|
|
233
|
+
return Effect.flatMap(nativeDatabase(acquire), (database) =>
|
|
221
234
|
coordinateTargetAuthenticationAuthority<
|
|
222
235
|
Claims,
|
|
223
236
|
TransactionOf<D>,
|
|
@@ -239,7 +252,7 @@ export function coordinatePgAuthenticationAuthority<
|
|
|
239
252
|
? work
|
|
240
253
|
: Effect.provideService(work, options.transaction, options.transaction.of(transaction));
|
|
241
254
|
},
|
|
242
|
-
),
|
|
255
|
+
).pipe(Effect.provideService(NativeDatabase, database)),
|
|
243
256
|
);
|
|
244
257
|
}
|
|
245
258
|
|
|
@@ -330,7 +343,7 @@ export function coordinatePgPendingAuthentication<
|
|
|
330
343
|
E | SessionUnavailable | HookConfigurationError | SqlError | DatabaseError,
|
|
331
344
|
Exclude<R, TargetId> | LifecycleHooks | DatabaseRequirements
|
|
332
345
|
> {
|
|
333
|
-
return Effect.flatMap(acquire, (database) =>
|
|
346
|
+
return Effect.flatMap(nativeDatabase(acquire), (database) =>
|
|
334
347
|
coordinateTargetPendingAuthentication<Claims, TransactionOf<D>, A, E, Exclude<R, TargetId>>(
|
|
335
348
|
database,
|
|
336
349
|
options.mapping,
|
|
@@ -346,7 +359,7 @@ export function coordinatePgPendingAuthentication<
|
|
|
346
359
|
? work
|
|
347
360
|
: Effect.provideService(work, options.transaction, options.transaction.of(transaction));
|
|
348
361
|
},
|
|
349
|
-
),
|
|
362
|
+
).pipe(Effect.provideService(NativeDatabase, database)),
|
|
350
363
|
);
|
|
351
364
|
}
|
|
352
365
|
|
|
@@ -476,7 +489,7 @@ export function coordinatePgStatefulSessions<
|
|
|
476
489
|
E | SessionUnavailable | HookConfigurationError | SqlError | DatabaseError,
|
|
477
490
|
Exclude<R, PersistenceId | RepositoryId> | LifecycleHooks | DatabaseRequirements
|
|
478
491
|
> {
|
|
479
|
-
return Effect.flatMap(acquire, (database) =>
|
|
492
|
+
return Effect.flatMap(nativeDatabase(acquire), (database) =>
|
|
480
493
|
coordinateTargetStatefulSessions<
|
|
481
494
|
Claims,
|
|
482
495
|
TransactionOf<D>,
|
|
@@ -505,7 +518,7 @@ export function coordinatePgStatefulSessions<
|
|
|
505
518
|
? work
|
|
506
519
|
: Effect.provideService(work, options.transaction, options.transaction.of(transaction));
|
|
507
520
|
},
|
|
508
|
-
),
|
|
521
|
+
).pipe(Effect.provideService(NativeDatabase, database)),
|
|
509
522
|
);
|
|
510
523
|
}
|
|
511
524
|
|
|
@@ -590,7 +603,7 @@ export function coordinatePgSignedSessionValidity<
|
|
|
590
603
|
E | SessionUnavailable | HookConfigurationError | SqlError | DatabaseError,
|
|
591
604
|
Exclude<R, TargetId> | LifecycleHooks | DatabaseRequirements
|
|
592
605
|
> {
|
|
593
|
-
return Effect.flatMap(acquire, (database) =>
|
|
606
|
+
return Effect.flatMap(nativeDatabase(acquire), (database) =>
|
|
594
607
|
coordinateTargetSignedSessionValidity<TransactionOf<D>, A, E, Exclude<R, TargetId>>(
|
|
595
608
|
database,
|
|
596
609
|
options.mapping,
|
|
@@ -606,7 +619,7 @@ export function coordinatePgSignedSessionValidity<
|
|
|
606
619
|
? work
|
|
607
620
|
: Effect.provideService(work, options.transaction, options.transaction.of(transaction));
|
|
608
621
|
},
|
|
609
|
-
),
|
|
622
|
+
).pipe(Effect.provideService(NativeDatabase, database)),
|
|
610
623
|
);
|
|
611
624
|
}
|
|
612
625
|
|
|
@@ -629,7 +642,10 @@ export const makePgSessionStepUpServices = <
|
|
|
629
642
|
Effect.flatMap(
|
|
630
643
|
Effect.map(acquireTransactionService(DatabaseService), configuration),
|
|
631
644
|
(configuration) => makeTargetSessionStepUpServices(mapping, target, configuration),
|
|
632
|
-
).pipe(
|
|
645
|
+
).pipe(
|
|
646
|
+
Effect.provideServiceEffect(CurrentSessionSql, nativeDatabase(DatabaseService)),
|
|
647
|
+
Effect.provideServiceEffect(NativeDatabase, nativeDatabase(DatabaseService)),
|
|
648
|
+
);
|
|
633
649
|
|
|
634
650
|
export function coordinatePgSessionStepUp<
|
|
635
651
|
Claims,
|
|
@@ -751,7 +767,7 @@ export function coordinatePgSessionStepUp<
|
|
|
751
767
|
E | SessionUnavailable | HookConfigurationError | SqlError | DatabaseError,
|
|
752
768
|
Exclude<R, Id> | LifecycleHooks | DatabaseRequirements
|
|
753
769
|
> {
|
|
754
|
-
return Effect.flatMap(acquire, (database) =>
|
|
770
|
+
return Effect.flatMap(nativeDatabase(acquire), (database) =>
|
|
755
771
|
coordinateTargetSessionStepUp<Claims, Id, TransactionOf<D>, A, E, Exclude<R, Id>>(
|
|
756
772
|
database,
|
|
757
773
|
options.mapping,
|
|
@@ -768,6 +784,6 @@ export function coordinatePgSessionStepUp<
|
|
|
768
784
|
? work
|
|
769
785
|
: Effect.provideService(work, options.transaction, options.transaction.of(transaction));
|
|
770
786
|
},
|
|
771
|
-
),
|
|
787
|
+
).pipe(Effect.provideService(NativeDatabase, database)),
|
|
772
788
|
);
|
|
773
789
|
}
|