@yielded/auth-persistence 0.1.0-beta.18 → 0.1.0-beta.20
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 +5 -2
- package/dist/Adapter.d.mts +2 -2
- package/dist/Adapter.mjs +2 -2
- package/dist/internal/configuration.d.mts +4 -3
- package/dist/internal/configuration.mjs.map +1 -1
- package/dist/internal/crypto.mjs +12 -0
- package/dist/internal/crypto.mjs.map +1 -0
- package/dist/internal/passkey/admission.mjs +19 -15
- package/dist/internal/passkey/admission.mjs.map +1 -1
- package/dist/internal/passkey/credentials.mjs +4 -4
- package/dist/internal/passkey/credentials.mjs.map +1 -1
- package/dist/internal/passkey/enrollment.mjs +6 -6
- package/dist/internal/passkey/enrollment.mjs.map +1 -1
- package/dist/internal/passkey/flow.mjs +7 -7
- package/dist/internal/passkey/flow.mjs.map +1 -1
- package/dist/internal/passkey/management.mjs +2 -2
- package/dist/internal/passkey/management.mjs.map +1 -1
- package/dist/internal/passkey/registration-ceremony.mjs +2 -2
- package/dist/internal/passkey/registration-ceremony.mjs.map +1 -1
- package/dist/internal/passkey/registration-custody.mjs +1 -1
- package/dist/internal/passkey/registration-custody.mjs.map +1 -1
- package/dist/internal/passkey/registration-write.mjs +12 -12
- package/dist/internal/passkey/registration-write.mjs.map +1 -1
- package/dist/internal/passkey/state.d.mts +1 -1
- package/dist/internal/passkey/state.mjs +8 -9
- package/dist/internal/passkey/state.mjs.map +1 -1
- package/dist/internal/passkey/target.d.mts +1 -1
- package/dist/internal/passkey/target.mjs.map +1 -1
- package/dist/internal/passkey/write-state.mjs +13 -13
- package/dist/internal/passkey/write-state.mjs.map +1 -1
- package/dist/internal/passkey/write-target.mjs.map +1 -1
- package/dist/internal/passkey-kernel.d.mts +512 -56
- package/dist/internal/passkeys.mjs +32 -14
- package/dist/internal/passkeys.mjs.map +1 -1
- package/dist/internal/password-kernel.d.mts +1 -1
- package/dist/internal/persistence.d.mts +2 -2
- package/dist/internal/persistence.mjs +16 -7
- package/dist/internal/persistence.mjs.map +1 -1
- package/dist/internal/phone-kernel.d.mts +5 -5
- package/dist/internal/phone-kernel.mjs +14 -14
- package/dist/internal/phone-kernel.mjs.map +1 -1
- package/dist/internal/registration.mjs +8 -7
- package/dist/internal/registration.mjs.map +1 -1
- package/dist/internal/storage-mapping.d.mts +5 -4
- package/dist/internal/storage-mapping.mjs +16 -13
- package/dist/internal/storage-mapping.mjs.map +1 -1
- package/dist/internal/storage-validation.d.mts +13 -3
- package/dist/internal/storage-validation.mjs +128 -68
- package/dist/internal/storage-validation.mjs.map +1 -1
- package/dist/internal/transaction-execution-kernel.d.mts +4 -4
- package/dist/internal/transaction-execution-kernel.mjs +7 -5
- package/dist/internal/transaction-execution-kernel.mjs.map +1 -1
- package/package.json +1 -1
- package/src/Adapter.ts +7 -1
- package/src/internal/configuration.ts +4 -2
- package/src/internal/crypto.ts +15 -0
- package/src/internal/passkey/admission.ts +22 -15
- package/src/internal/passkey/credentials.ts +4 -4
- package/src/internal/passkey/enrollment.ts +7 -7
- package/src/internal/passkey/flow.ts +8 -8
- package/src/internal/passkey/management.ts +7 -2
- package/src/internal/passkey/registration-ceremony.ts +2 -2
- package/src/internal/passkey/registration-custody.ts +1 -1
- package/src/internal/passkey/registration-write.ts +12 -12
- package/src/internal/passkey/state.ts +10 -13
- package/src/internal/passkey/target.ts +16 -8
- package/src/internal/passkey/write-state.ts +10 -14
- package/src/internal/passkey/write-target.ts +11 -3
- package/src/internal/passkeys.ts +121 -70
- package/src/internal/persistence.ts +28 -11
- package/src/internal/phone-kernel.ts +26 -17
- package/src/internal/registration.ts +10 -8
- package/src/internal/storage-mapping.ts +21 -13
- package/src/internal/storage-validation.ts +219 -139
- package/src/internal/transaction-execution-kernel.ts +30 -11
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "@yielded/auth/Hooks";
|
|
8
8
|
/* oxlint-disable no-explicit-any -- existing storage kernels erase foreign table shapes; domain errors remain typed. */
|
|
9
9
|
/* oxlint-disable no-explicit-any -- private execution bridge retains exact public driver wrappers. */
|
|
10
|
-
import { Context, Effect } from "effect";
|
|
10
|
+
import { Context, Crypto, Effect, type PlatformError } from "effect";
|
|
11
11
|
import type * as SqlClient from "effect/sql/SqlClient";
|
|
12
12
|
import type * as SqlError from "effect/sql/SqlError";
|
|
13
13
|
import type { Statement } from "effect/sql/Statement";
|
|
@@ -56,7 +56,11 @@ export interface TransactionExecution<Failure, OwnerId, Requirements = Lifecycle
|
|
|
56
56
|
readonly run: <A, E, R>(
|
|
57
57
|
body: Effect.Effect<A, E, R>,
|
|
58
58
|
mutation?: boolean,
|
|
59
|
-
) => Effect.Effect<
|
|
59
|
+
) => Effect.Effect<
|
|
60
|
+
A,
|
|
61
|
+
Failure,
|
|
62
|
+
Exclude<Exclude<R, OwnerId | CurrentCommitJournal>, Crypto.Crypto> | Requirements
|
|
63
|
+
>;
|
|
60
64
|
}
|
|
61
65
|
|
|
62
66
|
export const makeTransactionExecutionKernel = (
|
|
@@ -76,10 +80,15 @@ export const makeTransactionExecutionKernel = (
|
|
|
76
80
|
ownerTag: Context.Key<OwnerId, TransactionOwner<Failure>>,
|
|
77
81
|
configuration: TransactionTargetConfiguration<Failure>,
|
|
78
82
|
unavailable: () => Failure,
|
|
79
|
-
nonce:
|
|
83
|
+
nonce: Effect.Effect<string, PlatformError.PlatformError, Crypto.Crypto>,
|
|
80
84
|
bound?: TransactionBound<Failure>,
|
|
81
|
-
): Effect.fn.Return<
|
|
85
|
+
): Effect.fn.Return<
|
|
86
|
+
TransactionExecution<Failure, OwnerId>,
|
|
87
|
+
never,
|
|
88
|
+
NativeDatabase | Crypto.Crypto
|
|
89
|
+
> {
|
|
82
90
|
const database = yield* NativeDatabase;
|
|
91
|
+
const crypto = yield* Crypto.Crypto;
|
|
83
92
|
|
|
84
93
|
const invariant: (value: unknown) => asserts value = (value) => {
|
|
85
94
|
if (!value) throw unavailable();
|
|
@@ -101,11 +110,19 @@ export const makeTransactionExecutionKernel = (
|
|
|
101
110
|
run: <A, E, R>(
|
|
102
111
|
body: Effect.Effect<A, E, R>,
|
|
103
112
|
mutation = true,
|
|
104
|
-
): Effect.Effect<
|
|
113
|
+
): Effect.Effect<
|
|
114
|
+
A,
|
|
115
|
+
Failure,
|
|
116
|
+
Exclude<Exclude<R, OwnerId | CurrentCommitJournal>, Crypto.Crypto> | LifecycleHooks
|
|
117
|
+
> => {
|
|
105
118
|
return Effect.suspend(() => {
|
|
106
119
|
let entered = false;
|
|
107
120
|
|
|
108
|
-
const work
|
|
121
|
+
const work: Effect.Effect<
|
|
122
|
+
A,
|
|
123
|
+
E | Failure | HookConfigurationError | SqlError.SqlError | PlatformError.PlatformError,
|
|
124
|
+
Exclude<R, OwnerId | CurrentCommitJournal> | LifecycleHooks | Crypto.Crypto
|
|
125
|
+
> =
|
|
109
126
|
bound !== undefined
|
|
110
127
|
? Effect.gen(function* () {
|
|
111
128
|
if (!bound.active) return yield* Effect.fail(unavailable());
|
|
@@ -148,7 +165,7 @@ export const makeTransactionExecutionKernel = (
|
|
|
148
165
|
: Effect.gen(function* () {
|
|
149
166
|
if (yield* hasCommitScope) return yield* Effect.fail(unavailable());
|
|
150
167
|
yield* configuration.standaloneGuard(database.$client.transactionService);
|
|
151
|
-
const marker = nonce
|
|
168
|
+
const marker = yield* nonce;
|
|
152
169
|
|
|
153
170
|
const result = yield* coordinateCommit(
|
|
154
171
|
(journal) => {
|
|
@@ -189,6 +206,7 @@ export const makeTransactionExecutionKernel = (
|
|
|
189
206
|
});
|
|
190
207
|
|
|
191
208
|
return work.pipe(
|
|
209
|
+
Effect.provideService(Crypto.Crypto, crypto),
|
|
192
210
|
(operation) => reportTransactionFailure(operation, unavailable),
|
|
193
211
|
Effect.mapError(unavailable),
|
|
194
212
|
Effect.catchDefect(() => Effect.fail(unavailable())),
|
|
@@ -215,7 +233,7 @@ export const makeTransactionExecutionKernel = (
|
|
|
215
233
|
configuration: TransactionTargetConfiguration<Failure>,
|
|
216
234
|
allocate: Effect.Effect<Resources, AllocationError, AllocationRequirements>,
|
|
217
235
|
unavailable: () => Failure,
|
|
218
|
-
nonce:
|
|
236
|
+
nonce: Effect.Effect<string, PlatformError.PlatformError, Crypto.Crypto>,
|
|
219
237
|
services: (execution: TransactionExecution<Failure, OwnerId>, resources: Resources) => Services,
|
|
220
238
|
owner: (
|
|
221
239
|
transaction: Transaction,
|
|
@@ -225,11 +243,12 @@ export const makeTransactionExecutionKernel = (
|
|
|
225
243
|
): Effect.Effect<
|
|
226
244
|
A,
|
|
227
245
|
TransactionCoordinatorError<E, Failure>,
|
|
228
|
-
Exclude<R, CurrentCommitJournal> | LifecycleHooks | AllocationRequirements
|
|
246
|
+
Exclude<R, CurrentCommitJournal> | LifecycleHooks | AllocationRequirements | Crypto.Crypto
|
|
229
247
|
> => {
|
|
230
248
|
return Effect.gen(function* () {
|
|
231
249
|
if (yield* hasCommitScope) return yield* Effect.fail(unavailable());
|
|
232
250
|
yield* configuration.standaloneGuard(database.$client.transactionService);
|
|
251
|
+
const crypto = yield* Crypto.Crypto;
|
|
233
252
|
|
|
234
253
|
// Allocation is independent of registration data and always precedes the physical owner.
|
|
235
254
|
const resources = yield* allocate.pipe(
|
|
@@ -238,7 +257,7 @@ export const makeTransactionExecutionKernel = (
|
|
|
238
257
|
Effect.catchDefect(() => Effect.fail(unavailable())),
|
|
239
258
|
);
|
|
240
259
|
|
|
241
|
-
const marker = nonce();
|
|
260
|
+
const marker = yield* nonce.pipe(Effect.mapError(unavailable));
|
|
242
261
|
|
|
243
262
|
const result = yield* coordinateCommit(
|
|
244
263
|
(journal) => {
|
|
@@ -293,7 +312,7 @@ export const makeTransactionExecutionKernel = (
|
|
|
293
312
|
}),
|
|
294
313
|
),
|
|
295
314
|
);
|
|
296
|
-
});
|
|
315
|
+
}).pipe(Effect.provideService(Crypto.Crypto, crypto));
|
|
297
316
|
|
|
298
317
|
return configuration.mode === "batch"
|
|
299
318
|
? run(database)
|