@yielded/auth-persistence 0.1.0-beta.7 → 0.1.0-beta.9

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.
Files changed (119) hide show
  1. package/README.md +9 -0
  2. package/dist/DrizzleD1.d.mts +9 -9
  3. package/dist/DrizzleLibsql.d.mts +25 -25
  4. package/dist/DrizzleLibsql.mjs +7 -22
  5. package/dist/DrizzleLibsql.mjs.map +1 -1
  6. package/dist/DrizzleMysql2.d.mts +15 -15
  7. package/dist/DrizzlePglite.d.mts +9 -9
  8. package/dist/DrizzlePostgres.d.mts +15 -15
  9. package/dist/DrizzleSqliteBun.d.mts +18 -18
  10. package/dist/DrizzleSqliteDo.d.mts +29 -29
  11. package/dist/DrizzleSqliteNode.d.mts +24 -24
  12. package/dist/DrizzleSqliteWasm.d.mts +24 -24
  13. package/dist/_virtual/_rolldown/runtime.mjs +13 -0
  14. package/dist/drizzle/D1BatchStatements.d.mts +1 -2
  15. package/dist/drizzle/SuppliedService.d.mts +1 -2
  16. package/dist/drizzle/d1-emails.d.mts +5 -6
  17. package/dist/drizzle/d1-identity.d.mts +2 -3
  18. package/dist/drizzle/d1-oauth.d.mts +10 -11
  19. package/dist/drizzle/d1-passkey.d.mts +5 -6
  20. package/dist/drizzle/d1-password-prepared.d.mts +2 -3
  21. package/dist/drizzle/d1-passwords.d.mts +4 -5
  22. package/dist/drizzle/d1-phone.d.mts +2 -3
  23. package/dist/drizzle/d1-planning.d.mts +1 -2
  24. package/dist/drizzle/d1-proofs.d.mts +2 -3
  25. package/dist/drizzle/d1-sessions.d.mts +10 -11
  26. package/dist/drizzle/d1-totp.d.mts +2 -3
  27. package/dist/drizzle/email-model.d.mts +30 -31
  28. package/dist/drizzle/email-registration.d.mts +1 -2
  29. package/dist/drizzle/email-target.d.mts +3 -4
  30. package/dist/drizzle/model.d.mts +42 -42
  31. package/dist/drizzle/model.mjs +4 -6
  32. package/dist/drizzle/model.mjs.map +1 -1
  33. package/dist/drizzle/mysql-emails.d.mts +7 -8
  34. package/dist/drizzle/mysql-identity.d.mts +2 -3
  35. package/dist/drizzle/mysql-password-prepared.d.mts +3 -4
  36. package/dist/drizzle/mysql-passwords.d.mts +6 -7
  37. package/dist/drizzle/mysql-proofs.d.mts +3 -4
  38. package/dist/drizzle/mysql-sessions.d.mts +15 -16
  39. package/dist/drizzle/mysql.d.mts +9 -10
  40. package/dist/drizzle/mysql.mjs +1 -1
  41. package/dist/drizzle/oauth-connected-model.d.mts +21 -22
  42. package/dist/drizzle/oauth-connected-reference.d.mts +1 -2
  43. package/dist/drizzle/oauth-connected-state.d.mts +1950 -7
  44. package/dist/drizzle/oauth-connected-target.d.mts +9 -10
  45. package/dist/drizzle/oauth-flow.d.mts +22 -2
  46. package/dist/drizzle/oauth-model.d.mts +45 -46
  47. package/dist/drizzle/oauth-owner.d.mts +10 -2
  48. package/dist/drizzle/oauth-target.d.mts +9 -10
  49. package/dist/drizzle/passkey-model.d.mts +34 -35
  50. package/dist/drizzle/passkey-registration-ceremony-model.d.mts +5 -6
  51. package/dist/drizzle/passkey-write-model.d.mts +13 -14
  52. package/dist/drizzle/password-model.d.mts +29 -30
  53. package/dist/drizzle/password-prepared-model.d.mts +10 -11
  54. package/dist/drizzle/password-prepared-target.d.mts +1 -2
  55. package/dist/drizzle/password-registration.d.mts +1 -2
  56. package/dist/drizzle/password-target.d.mts +2 -3
  57. package/dist/drizzle/pg-emails.d.mts +7 -8
  58. package/dist/drizzle/pg-password-prepared.d.mts +3 -4
  59. package/dist/drizzle/pg-passwords.d.mts +6 -7
  60. package/dist/drizzle/pg-proofs.d.mts +3 -4
  61. package/dist/drizzle/pg-sessions.d.mts +15 -16
  62. package/dist/drizzle/pg.d.mts +11 -12
  63. package/dist/drizzle/pg.mjs +1 -1
  64. package/dist/drizzle/phone-model.d.mts +9 -10
  65. package/dist/drizzle/phone-target.d.mts +1 -2
  66. package/dist/drizzle/proof-model.d.mts +25 -26
  67. package/dist/drizzle/proof-target.d.mts +1 -2
  68. package/dist/drizzle/session-model.d.mts +25 -26
  69. package/dist/drizzle/session-target.d.mts +4 -5
  70. package/dist/drizzle/sqlite.d.mts +9 -10
  71. package/dist/drizzle/sqlite.mjs +1 -1
  72. package/dist/drizzle/standalone-guard.mjs +3 -5
  73. package/dist/drizzle/standalone-guard.mjs.map +1 -1
  74. package/dist/drizzle/step-up-model.d.mts +6 -7
  75. package/dist/drizzle/totp-model.d.mts +7 -8
  76. package/dist/drizzle/totp-state.d.mts +2 -3
  77. package/dist/drizzle/totp-target.d.mts +1 -2
  78. package/dist/drizzle/transaction-mysql.mjs +1 -0
  79. package/dist/drizzle/transaction-mysql.mjs.map +1 -1
  80. package/dist/drizzle/transaction-owner.d.mts +3 -2
  81. package/dist/index.d.mts +3 -1
  82. package/dist/index.mjs +3 -1
  83. package/dist/internal/configuration.d.mts +19 -19
  84. package/dist/internal/mapping-error.d.mts +2 -3
  85. package/dist/internal/oauth-app.d.mts +11 -0
  86. package/dist/internal/oauth-app.mjs +57 -0
  87. package/dist/internal/oauth-app.mjs.map +1 -0
  88. package/dist/internal/oauth-server.d.mts +10 -0
  89. package/dist/internal/oauth-server.mjs +66 -0
  90. package/dist/internal/oauth-server.mjs.map +1 -0
  91. package/dist/internal/passkey/target.d.mts +2 -3
  92. package/dist/internal/passkeys.mjs +2 -1
  93. package/dist/internal/passkeys.mjs.map +1 -1
  94. package/dist/internal/persistence.mjs +3 -2
  95. package/dist/internal/persistence.mjs.map +1 -1
  96. package/dist/internal/sql-persistence.d.mts +1 -2
  97. package/dist/internal/sql-table.d.mts +6 -7
  98. package/dist/internal/sql-table.mjs +12 -2
  99. package/dist/internal/sql-table.mjs.map +1 -1
  100. package/dist/internal/standalone.mjs +13 -0
  101. package/dist/internal/standalone.mjs.map +1 -0
  102. package/dist/internal/storage-tables.d.mts +5 -6
  103. package/dist/internal/transaction-execution-kernel.d.mts +2 -3
  104. package/dist/internal/transaction-execution-kernel.mjs +3 -5
  105. package/dist/internal/transaction-execution-kernel.mjs.map +1 -1
  106. package/dist/internal/transaction-kernel.d.mts +49 -2
  107. package/package.json +1 -1
  108. package/src/DrizzleLibsql.ts +10 -54
  109. package/src/drizzle/model.ts +8 -10
  110. package/src/drizzle/standalone-guard.ts +4 -9
  111. package/src/drizzle/transaction-mysql.ts +2 -0
  112. package/src/index.ts +2 -0
  113. package/src/internal/oauth-app.ts +82 -0
  114. package/src/internal/oauth-server.ts +89 -0
  115. package/src/internal/passkeys.ts +2 -6
  116. package/src/internal/persistence.ts +3 -5
  117. package/src/internal/sql-table.ts +17 -2
  118. package/src/internal/standalone.ts +30 -0
  119. package/src/internal/transaction-execution-kernel.ts +3 -7
@@ -6,27 +6,27 @@ import { ProofBinding, ProofContinuationId, ProofId, ProofPolicy, ProofPurpose,
6
6
  import { InferInsertModel, InferSelectModel, SQL, Table } from "drizzle-orm";
7
7
  //#region src/drizzle/proof-model.d.ts
8
8
  type ColumnKey<T extends Table> = Extract<keyof T["_"]["columns"], string>;
9
- type ProofAction = "issue" | "attempt";
10
- type ProofScopeKind = "action" | "identifier" | "subject";
11
- type ProofGenerationState = "active" | "consumed" | "cancelled" | "superseded";
12
- type ProofDeliveryState = "new" | "claimed" | "accepted" | "failed" | "ambiguous";
13
- type ProofCommandKind = "attempt" | "complete";
14
- type ProofCommandDecision = "accepted" | "rejected" | "completed";
15
- interface ProofScopeKeys {
9
+ export type ProofAction = "issue" | "attempt";
10
+ export type ProofScopeKind = "action" | "identifier" | "subject";
11
+ export type ProofGenerationState = "active" | "consumed" | "cancelled" | "superseded";
12
+ export type ProofDeliveryState = "new" | "claimed" | "accepted" | "failed" | "ambiguous";
13
+ export type ProofCommandKind = "attempt" | "complete";
14
+ export type ProofCommandDecision = "accepted" | "rejected" | "completed";
15
+ export interface ProofScopeKeys {
16
16
  /** Stable across flow/context/request changes and bounded by the consumer codec. */
17
17
  readonly series: string;
18
18
  readonly identifier: string;
19
19
  /** A tagged non-null value; use a stable sentinel when the binding has no subject. */
20
20
  readonly subject: string;
21
21
  }
22
- interface ProofAuthorityInput<NativeSubjectId> {
22
+ export interface ProofAuthorityInput<NativeSubjectId> {
23
23
  readonly moduleId: string;
24
24
  readonly purpose: ProofPurpose;
25
25
  readonly binding: ProofBinding;
26
26
  /** Resolved by Effect preplanning before an interactive check or D1 predicate compile. */
27
27
  readonly nativeSubjectId?: NativeSubjectId;
28
28
  }
29
- interface ProofAuthorityTables<Subject extends Table, Identifier extends Table, Credential extends Table, NativeSubjectId> {
29
+ export interface ProofAuthorityTables<Subject extends Table, Identifier extends Table, Credential extends Table, NativeSubjectId> {
30
30
  readonly identifier: {
31
31
  readonly table: Identifier;
32
32
  readonly namespace: ColumnKey<Identifier>;
@@ -55,7 +55,7 @@ interface ProofAuthorityTables<Subject extends Table, Identifier extends Table,
55
55
  };
56
56
  readonly subjectId?: SubjectIdCodec<NativeSubjectId>;
57
57
  }
58
- interface ProofRequestTable<Request extends Table> {
58
+ export interface ProofRequestTable<Request extends Table> {
59
59
  readonly table: Request;
60
60
  readonly moduleId: ColumnKey<Request>;
61
61
  readonly requestId: ColumnKey<Request>;
@@ -72,7 +72,7 @@ interface ProofRequestTable<Request extends Table> {
72
72
  }) => InferInsertModel<Request>;
73
73
  readonly decodeReceipt: (row: InferSelectModel<Request>) => Effect.Effect<ProofRequestReceipt, PersistenceMappingError>;
74
74
  }
75
- interface ProofSeriesTable<Series extends Table> {
75
+ export interface ProofSeriesTable<Series extends Table> {
76
76
  readonly table: Series;
77
77
  readonly moduleId: ColumnKey<Series>;
78
78
  readonly purpose: ColumnKey<Series>;
@@ -87,7 +87,7 @@ interface ProofSeriesTable<Series extends Table> {
87
87
  readonly version: ProofVersion;
88
88
  }) => InferInsertModel<Series>;
89
89
  }
90
- interface ProofGenerationTable<Generation extends Table> {
90
+ export interface ProofGenerationTable<Generation extends Table> {
91
91
  readonly table: Generation;
92
92
  readonly moduleId: ColumnKey<Generation>;
93
93
  readonly purpose: ColumnKey<Generation>;
@@ -120,7 +120,7 @@ interface ProofGenerationTable<Generation extends Table> {
120
120
  readonly decodeRecord: (row: InferSelectModel<Generation>) => Effect.Effect<ProofRecord, PersistenceMappingError>;
121
121
  readonly decodeBinding: (row: InferSelectModel<Generation>) => Effect.Effect<ProofBinding, PersistenceMappingError>;
122
122
  }
123
- interface ProofContinuationRecord {
123
+ export interface ProofContinuationRecord {
124
124
  readonly moduleId: string;
125
125
  readonly purpose: ProofPurpose;
126
126
  readonly continuationId: ProofContinuationId;
@@ -131,7 +131,7 @@ interface ProofContinuationRecord {
131
131
  readonly expiresAtMillis: number;
132
132
  readonly version: ProofVersion;
133
133
  }
134
- interface ProofContinuationTable<Continuation extends Table> {
134
+ export interface ProofContinuationTable<Continuation extends Table> {
135
135
  readonly table: Continuation;
136
136
  readonly moduleId: ColumnKey<Continuation>;
137
137
  readonly purpose: ColumnKey<Continuation>;
@@ -149,7 +149,7 @@ interface ProofContinuationTable<Continuation extends Table> {
149
149
  }) => InferInsertModel<Continuation>;
150
150
  readonly decode: (row: InferSelectModel<Continuation>) => Effect.Effect<ProofContinuationRecord, PersistenceMappingError>;
151
151
  }
152
- interface ProofRateScopeTable<RateScope extends Table> {
152
+ export interface ProofRateScopeTable<RateScope extends Table> {
153
153
  readonly table: RateScope;
154
154
  readonly moduleId: ColumnKey<RateScope>;
155
155
  readonly purpose: ColumnKey<RateScope>;
@@ -164,7 +164,7 @@ interface ProofRateScopeTable<RateScope extends Table> {
164
164
  readonly scopeKey: string;
165
165
  }) => InferInsertModel<RateScope>;
166
166
  }
167
- interface ProofAbuseEventTable<AbuseEvent extends Table> {
167
+ export interface ProofAbuseEventTable<AbuseEvent extends Table> {
168
168
  readonly table: AbuseEvent;
169
169
  readonly moduleId: ColumnKey<AbuseEvent>;
170
170
  readonly purpose: ColumnKey<AbuseEvent>;
@@ -185,7 +185,7 @@ interface ProofAbuseEventTable<AbuseEvent extends Table> {
185
185
  readonly retentionUntilMillis: number;
186
186
  }) => InferInsertModel<AbuseEvent>;
187
187
  }
188
- interface ProofFailureEventTable<FailureEvent extends Table> {
188
+ export interface ProofFailureEventTable<FailureEvent extends Table> {
189
189
  readonly table: FailureEvent;
190
190
  readonly moduleId: ColumnKey<FailureEvent>;
191
191
  readonly purpose: ColumnKey<FailureEvent>;
@@ -202,7 +202,7 @@ interface ProofFailureEventTable<FailureEvent extends Table> {
202
202
  readonly retentionUntilMillis: number;
203
203
  }) => InferInsertModel<FailureEvent>;
204
204
  }
205
- interface ProofCommandTable<Command extends Table> {
205
+ export interface ProofCommandTable<Command extends Table> {
206
206
  readonly table: Command;
207
207
  readonly moduleId: ColumnKey<Command>;
208
208
  readonly commandId: ColumnKey<Command>;
@@ -217,7 +217,7 @@ interface ProofCommandTable<Command extends Table> {
217
217
  readonly retentionUntilMillis: number;
218
218
  }) => InferInsertModel<Command>;
219
219
  }
220
- interface RequiredProofConstraints {
220
+ export interface RequiredProofConstraints {
221
221
  readonly request: "unique(request.moduleId,request.requestId)";
222
222
  readonly series: "unique(series.moduleId,series.purpose,series.scopeKey)";
223
223
  readonly proof: "unique(generation.moduleId,generation.proofId)";
@@ -229,8 +229,8 @@ interface RequiredProofConstraints {
229
229
  readonly failureEvent: "unique(failureEvent.moduleId,failureEvent.seriesKey,failureEvent.commandId)";
230
230
  readonly command: "unique(command.moduleId,command.commandId)";
231
231
  }
232
- declare const requiredProofConstraints: RequiredProofConstraints;
233
- interface ProofConstraintClassifier {
232
+ export declare const requiredProofConstraints: RequiredProofConstraints;
233
+ export interface ProofConstraintClassifier {
234
234
  /** Match only the declared request uniqueness constraint, including wrapped driver errors. */
235
235
  readonly isRequestConflict: (cause: unknown) => boolean;
236
236
  /** Match only the declared series uniqueness constraint, including wrapped driver errors. */
@@ -238,7 +238,7 @@ interface ProofConstraintClassifier {
238
238
  /** Match only the declared command uniqueness constraint, including wrapped driver errors. */
239
239
  readonly isCommandConflict: (cause: unknown) => boolean;
240
240
  }
241
- interface ProofD1Clock {
241
+ export interface ProofD1Clock {
242
242
  /** Native instant expression evaluated by SQLite inside the submitted batch. */
243
243
  readonly engineNow: SQL;
244
244
  /** Integer Unix milliseconds expression evaluated inside the submitted batch. */
@@ -248,7 +248,7 @@ interface ProofD1Clock {
248
248
  /** Native instant expression for a retention/lease deadline from engine time. */
249
249
  readonly engineInstantPlus: (millis: number) => SQL;
250
250
  }
251
- interface ProofPersistenceMapping<Request extends Table, Series extends Table, Generation extends Table, Continuation extends Table, RateScope extends Table, AbuseEvent extends Table, FailureEvent extends Table, Command extends Table, Subject extends Table, Identifier extends Table, Credential extends Table, NativeSubjectId> extends ProofConstraintClassifier {
251
+ export interface ProofPersistenceMapping<Request extends Table, Series extends Table, Generation extends Table, Continuation extends Table, RateScope extends Table, AbuseEvent extends Table, FailureEvent extends Table, Command extends Table, Subject extends Table, Identifier extends Table, Credential extends Table, NativeSubjectId> extends ProofConstraintClassifier {
252
252
  readonly request: ProofRequestTable<Request>;
253
253
  readonly series: ProofSeriesTable<Series>;
254
254
  readonly generation: ProofGenerationTable<Generation>;
@@ -271,7 +271,7 @@ interface ProofPersistenceMapping<Request extends Table, Series extends Table, G
271
271
  /** Required by D1 mappings and ignored by interactive targets. */
272
272
  readonly d1?: ProofD1Clock;
273
273
  }
274
- type D1ProofPersistenceMapping<Request extends Table, Series extends Table, Generation extends Table, Continuation extends Table, RateScope extends Table, AbuseEvent extends Table, FailureEvent extends Table, Command extends Table, Subject extends Table, Identifier extends Table, Credential extends Table, NativeSubjectId> = ProofPersistenceMapping<Request, Series, Generation, Continuation, RateScope, AbuseEvent, FailureEvent, Command, Subject, Identifier, Credential, NativeSubjectId> & {
274
+ export type D1ProofPersistenceMapping<Request extends Table, Series extends Table, Generation extends Table, Continuation extends Table, RateScope extends Table, AbuseEvent extends Table, FailureEvent extends Table, Command extends Table, Subject extends Table, Identifier extends Table, Credential extends Table, NativeSubjectId> = ProofPersistenceMapping<Request, Series, Generation, Continuation, RateScope, AbuseEvent, FailureEvent, Command, Subject, Identifier, Credential, NativeSubjectId> & {
275
275
  readonly d1: ProofD1Clock;
276
276
  readonly authority: ProofAuthorityTables<Subject, Identifier, Credential, NativeSubjectId> & {
277
277
  readonly identifier: ProofAuthorityTables<Subject, Identifier, Credential, NativeSubjectId>["identifier"] & {
@@ -280,7 +280,6 @@ type D1ProofPersistenceMapping<Request extends Table, Series extends Table, Gene
280
280
  };
281
281
  };
282
282
  };
283
- type AnyProofPersistenceMapping = ProofPersistenceMapping<Table, Table, Table, Table, Table, Table, Table, Table, Table, Table, Table, unknown>;
283
+ export type AnyProofPersistenceMapping = ProofPersistenceMapping<Table, Table, Table, Table, Table, Table, Table, Table, Table, Table, Table, unknown>;
284
284
  //#endregion
285
- export { AnyProofPersistenceMapping, D1ProofPersistenceMapping, ProofAbuseEventTable, ProofAction, ProofAuthorityInput, ProofAuthorityTables, ProofCommandDecision, ProofCommandKind, ProofCommandTable, ProofConstraintClassifier, ProofContinuationRecord, ProofContinuationTable, ProofD1Clock, ProofDeliveryState, ProofFailureEventTable, ProofGenerationState, ProofGenerationTable, ProofPersistenceMapping, ProofRateScopeTable, ProofRequestTable, ProofScopeKeys, ProofScopeKind, ProofSeriesTable, RequiredProofConstraints, requiredProofConstraints };
286
285
  //# sourceMappingURL=proof-model.d.mts.map
@@ -4,9 +4,8 @@ import { HookConfigurationError, LifecycleHooks } from "@yielded/auth/Hooks";
4
4
  import { ProofPersistence, ProofUnavailable } from "@yielded/auth/Proofs";
5
5
  import "effect/unstable/sql/SqlError";
6
6
  //#region src/drizzle/proof-target.d.ts
7
- declare const proofPersistenceLayer: (services: Effect.Effect<{
7
+ export declare const proofPersistenceLayer: (services: Effect.Effect<{
8
8
  readonly proofPersistence: ProofPersistence["Service"];
9
9
  }, never, LifecycleHooks>) => Layer.Layer<ProofPersistence, never, LifecycleHooks>;
10
10
  //#endregion
11
- export { proofPersistenceLayer };
12
11
  //# sourceMappingURL=proof-target.d.mts.map
@@ -6,12 +6,12 @@ import { AuthenticationEvidence, AuthenticationRequirement, PendingAuthenticatio
6
6
  import { InferInsertModel, InferSelectModel, SQL, Table } from "drizzle-orm";
7
7
  //#region src/drizzle/session-model.d.ts
8
8
  type ColumnKey<T extends Table> = Extract<keyof T["_"]["columns"], string>;
9
- interface SessionIdCodec<NativeId> {
9
+ export interface SessionIdCodec<NativeId> {
10
10
  readonly toNative: (id: SessionId) => Effect.Effect<NativeId, PersistenceMappingError>;
11
11
  readonly toSession: (id: NativeId) => Effect.Effect<SessionId, PersistenceMappingError>;
12
12
  readonly equals: (left: NativeId, right: NativeId) => boolean;
13
13
  }
14
- interface SessionSubjectTables<Subject extends Table, NativeId> {
14
+ export interface SessionSubjectTables<Subject extends Table, NativeId> {
15
15
  readonly subject: {
16
16
  readonly table: Subject;
17
17
  readonly id: ColumnKey<Subject>;
@@ -24,7 +24,7 @@ interface SessionSubjectTables<Subject extends Table, NativeId> {
24
24
  };
25
25
  readonly subjectId: SubjectIdCodec<NativeId>;
26
26
  }
27
- interface SessionAuthorityTables<Subject extends Table, Credential extends Table, NativeId> extends SessionSubjectTables<Subject, NativeId> {
27
+ export interface SessionAuthorityTables<Subject extends Table, Credential extends Table, NativeId> extends SessionSubjectTables<Subject, NativeId> {
28
28
  readonly credential: {
29
29
  readonly table: Credential;
30
30
  readonly subjectId: ColumnKey<Credential>;
@@ -35,7 +35,7 @@ interface SessionAuthorityTables<Subject extends Table, Credential extends Table
35
35
  readonly isActiveStatus?: (value: unknown) => boolean;
36
36
  };
37
37
  }
38
- interface SessionFlowTables<Flow extends Table, NativeSubjectId> {
38
+ export interface SessionFlowTables<Flow extends Table, NativeSubjectId> {
39
39
  readonly flow: {
40
40
  readonly table: Flow;
41
41
  readonly flowId: ColumnKey<Flow>;
@@ -60,7 +60,7 @@ interface SessionFlowTables<Flow extends Table, NativeSubjectId> {
60
60
  }) => InferInsertModel<Flow>;
61
61
  };
62
62
  }
63
- interface StatefulSessionTables<Claims, Session extends Table, Flow extends Table, NativeSubjectId, NativeSessionId> extends SessionFlowTables<Flow, NativeSubjectId> {
63
+ export interface StatefulSessionTables<Claims, Session extends Table, Flow extends Table, NativeSubjectId, NativeSessionId> extends SessionFlowTables<Flow, NativeSubjectId> {
64
64
  readonly session: {
65
65
  readonly table: Session;
66
66
  readonly sessionId: ColumnKey<Session>;
@@ -86,7 +86,7 @@ interface StatefulSessionTables<Claims, Session extends Table, Flow extends Tabl
86
86
  };
87
87
  readonly sessionId: SessionIdCodec<NativeSessionId>;
88
88
  }
89
- interface PendingAuthenticationTables<Claims, Pending extends Table, Flow extends Table, NativeSubjectId> extends SessionFlowTables<Flow, NativeSubjectId> {
89
+ export interface PendingAuthenticationTables<Claims, Pending extends Table, Flow extends Table, NativeSubjectId> extends SessionFlowTables<Flow, NativeSubjectId> {
90
90
  readonly pending: {
91
91
  readonly table: Pending;
92
92
  readonly digest: ColumnKey<Pending>;
@@ -112,7 +112,7 @@ interface PendingAuthenticationTables<Claims, Pending extends Table, Flow extend
112
112
  readonly allocateVersionSync?: () => SecurityRevision;
113
113
  };
114
114
  }
115
- interface SignedSessionValidityTables<Tombstone extends Table, NativeSubjectId, NativeSessionId> {
115
+ export interface SignedSessionValidityTables<Tombstone extends Table, NativeSubjectId, NativeSessionId> {
116
116
  readonly tombstone: {
117
117
  readonly table: Tombstone;
118
118
  readonly subjectId: ColumnKey<Tombstone>;
@@ -128,24 +128,24 @@ interface SignedSessionValidityTables<Tombstone extends Table, NativeSubjectId,
128
128
  };
129
129
  readonly sessionId: SessionIdCodec<NativeSessionId>;
130
130
  }
131
- interface RequiredSessionConstraints {
131
+ export interface RequiredSessionConstraints {
132
132
  readonly sessionDigest: "unique(session.digest)";
133
133
  readonly flowId: "unique(flow.flowId)";
134
134
  }
135
- interface RequiredPendingAuthenticationConstraints {
135
+ export interface RequiredPendingAuthenticationConstraints {
136
136
  readonly pendingDigest: "unique(pending.digest)";
137
137
  readonly pendingFlow: "unique(pending.flowId)";
138
138
  readonly flowId: "unique(flow.flowId)";
139
139
  }
140
- interface RequiredStatefulPendingConstraints extends RequiredSessionConstraints, RequiredPendingAuthenticationConstraints {}
141
- interface RequiredSignedValidityConstraints {
140
+ export interface RequiredStatefulPendingConstraints extends RequiredSessionConstraints, RequiredPendingAuthenticationConstraints {}
141
+ export interface RequiredSignedValidityConstraints {
142
142
  readonly tombstoneOwner: "unique(tombstone.subjectId,tombstone.sessionId)";
143
143
  }
144
- declare const requiredSessionConstraints: RequiredSessionConstraints;
145
- declare const requiredPendingAuthenticationConstraints: RequiredPendingAuthenticationConstraints;
146
- declare const requiredStatefulPendingConstraints: RequiredStatefulPendingConstraints;
147
- declare const requiredSignedValidityConstraints: RequiredSignedValidityConstraints;
148
- interface SessionConstraintClassifier {
144
+ export declare const requiredSessionConstraints: RequiredSessionConstraints;
145
+ export declare const requiredPendingAuthenticationConstraints: RequiredPendingAuthenticationConstraints;
146
+ export declare const requiredStatefulPendingConstraints: RequiredStatefulPendingConstraints;
147
+ export declare const requiredSignedValidityConstraints: RequiredSignedValidityConstraints;
148
+ export interface SessionConstraintClassifier {
149
149
  /**
150
150
  * Match only the named unique constraints declared by this mapping. Broad
151
151
  * SQL/constraint classifiers can relabel application or NOT NULL failures as
@@ -153,14 +153,14 @@ interface SessionConstraintClassifier {
153
153
  */
154
154
  readonly isConstraintConflict: (cause: unknown) => boolean;
155
155
  }
156
- type AuthenticationAuthorityMapping<Claims, Subject extends Table, Credential extends Table, Flow extends Table, Pending extends Table, NativeSubjectId> = SessionAuthorityTables<Subject, Credential, NativeSubjectId> & SessionConstraintClassifier & ({
156
+ export type AuthenticationAuthorityMapping<Claims, Subject extends Table, Credential extends Table, Flow extends Table, Pending extends Table, NativeSubjectId> = SessionAuthorityTables<Subject, Credential, NativeSubjectId> & SessionConstraintClassifier & ({
157
157
  /** Omit for single-factor authority installations. Pending input then fails closed. */
158
158
  readonly pending?: undefined;
159
159
  } | {
160
160
  readonly pending: PendingAuthenticationTables<Claims, Pending, Flow, NativeSubjectId>;
161
161
  readonly constraints: RequiredPendingAuthenticationConstraints;
162
162
  });
163
- type StatefulSessionMapping<Claims, Subject extends Table, Credential extends Table, Session extends Table, Flow extends Table, Pending extends Table, NativeSubjectId, NativeSessionId> = SessionAuthorityTables<Subject, Credential, NativeSubjectId> & StatefulSessionTables<Claims, Session, Flow, NativeSubjectId, NativeSessionId> & SessionConstraintClassifier & ({
163
+ export type StatefulSessionMapping<Claims, Subject extends Table, Credential extends Table, Session extends Table, Flow extends Table, Pending extends Table, NativeSubjectId, NativeSessionId> = SessionAuthorityTables<Subject, Credential, NativeSubjectId> & StatefulSessionTables<Claims, Session, Flow, NativeSubjectId, NativeSessionId> & SessionConstraintClassifier & ({
164
164
  /** Omit when this session module does not support pending MFA completion. */
165
165
  readonly pending?: undefined;
166
166
  readonly constraints: RequiredSessionConstraints;
@@ -168,10 +168,10 @@ type StatefulSessionMapping<Claims, Subject extends Table, Credential extends Ta
168
168
  readonly pending: PendingAuthenticationTables<Claims, Pending, Flow, NativeSubjectId>["pending"];
169
169
  readonly constraints: RequiredStatefulPendingConstraints;
170
170
  });
171
- type PendingAuthenticationMapping<Claims, Subject extends Table, Credential extends Table, Pending extends Table, Flow extends Table, NativeSubjectId> = SessionAuthorityTables<Subject, Credential, NativeSubjectId> & PendingAuthenticationTables<Claims, Pending, Flow, NativeSubjectId> & SessionConstraintClassifier & {
171
+ export type PendingAuthenticationMapping<Claims, Subject extends Table, Credential extends Table, Pending extends Table, Flow extends Table, NativeSubjectId> = SessionAuthorityTables<Subject, Credential, NativeSubjectId> & PendingAuthenticationTables<Claims, Pending, Flow, NativeSubjectId> & SessionConstraintClassifier & {
172
172
  readonly constraints: RequiredPendingAuthenticationConstraints;
173
173
  };
174
- type SignedSessionValidityMapping<Subject extends Table, Tombstone extends Table, NativeSubjectId, NativeSessionId> = SessionSubjectTables<Subject, NativeSubjectId> & SignedSessionValidityTables<Tombstone, NativeSubjectId, NativeSessionId> & SessionConstraintClassifier & {
174
+ export type SignedSessionValidityMapping<Subject extends Table, Tombstone extends Table, NativeSubjectId, NativeSessionId> = SessionSubjectTables<Subject, NativeSubjectId> & SignedSessionValidityTables<Tombstone, NativeSubjectId, NativeSessionId> & SessionConstraintClassifier & {
175
175
  readonly constraints: RequiredSignedValidityConstraints;
176
176
  };
177
177
  /** D1 evaluates these expressions inside the atomic batch, after queueing delay.
@@ -182,7 +182,7 @@ type SignedSessionValidityMapping<Subject extends Table, Tombstone extends Table
182
182
  * `withSession` handle, because verification and security revision reads must
183
183
  * observe completed revocation writes across clients.
184
184
  */
185
- interface D1SessionClockMapping {
185
+ export interface D1SessionClockMapping {
186
186
  readonly d1: {
187
187
  readonly engineNow: SQL;
188
188
  readonly engineNowMillis: SQL;
@@ -191,10 +191,9 @@ interface D1SessionClockMapping {
191
191
  readonly activeCredentialStatusValue?: unknown;
192
192
  };
193
193
  }
194
- type D1AuthenticationAuthorityMapping<Claims, Subject extends Table, Credential extends Table, Flow extends Table, Pending extends Table, NativeSubjectId> = AuthenticationAuthorityMapping<Claims, Subject, Credential, Flow, Pending, NativeSubjectId> & D1SessionClockMapping;
195
- type D1PendingAuthenticationMapping<Claims, Subject extends Table, Credential extends Table, Pending extends Table, Flow extends Table, NativeSubjectId> = PendingAuthenticationMapping<Claims, Subject, Credential, Pending, Flow, NativeSubjectId> & D1SessionClockMapping;
196
- type D1StatefulSessionMapping<Claims, Subject extends Table, Credential extends Table, Session extends Table, Flow extends Table, Pending extends Table, NativeSubjectId, NativeSessionId> = StatefulSessionMapping<Claims, Subject, Credential, Session, Flow, Pending, NativeSubjectId, NativeSessionId> & D1SessionClockMapping;
197
- type D1SignedSessionValidityMapping<Subject extends Table, Tombstone extends Table, NativeSubjectId, NativeSessionId> = SignedSessionValidityMapping<Subject, Tombstone, NativeSubjectId, NativeSessionId> & D1SessionClockMapping;
194
+ export type D1AuthenticationAuthorityMapping<Claims, Subject extends Table, Credential extends Table, Flow extends Table, Pending extends Table, NativeSubjectId> = AuthenticationAuthorityMapping<Claims, Subject, Credential, Flow, Pending, NativeSubjectId> & D1SessionClockMapping;
195
+ export type D1PendingAuthenticationMapping<Claims, Subject extends Table, Credential extends Table, Pending extends Table, Flow extends Table, NativeSubjectId> = PendingAuthenticationMapping<Claims, Subject, Credential, Pending, Flow, NativeSubjectId> & D1SessionClockMapping;
196
+ export type D1StatefulSessionMapping<Claims, Subject extends Table, Credential extends Table, Session extends Table, Flow extends Table, Pending extends Table, NativeSubjectId, NativeSessionId> = StatefulSessionMapping<Claims, Subject, Credential, Session, Flow, Pending, NativeSubjectId, NativeSessionId> & D1SessionClockMapping;
197
+ export type D1SignedSessionValidityMapping<Subject extends Table, Tombstone extends Table, NativeSubjectId, NativeSessionId> = SignedSessionValidityMapping<Subject, Tombstone, NativeSubjectId, NativeSessionId> & D1SessionClockMapping;
198
198
  //#endregion
199
- export { AuthenticationAuthorityMapping, D1AuthenticationAuthorityMapping, D1PendingAuthenticationMapping, D1SessionClockMapping, D1SignedSessionValidityMapping, D1StatefulSessionMapping, PendingAuthenticationMapping, PendingAuthenticationTables, RequiredPendingAuthenticationConstraints, RequiredSessionConstraints, RequiredSignedValidityConstraints, RequiredStatefulPendingConstraints, SessionAuthorityTables, SessionConstraintClassifier, SessionFlowTables, SessionIdCodec, SessionSubjectTables, SignedSessionValidityMapping, SignedSessionValidityTables, StatefulSessionMapping, StatefulSessionTables, requiredPendingAuthenticationConstraints, requiredSessionConstraints, requiredSignedValidityConstraints, requiredStatefulPendingConstraints };
200
199
  //# sourceMappingURL=session-model.d.mts.map
@@ -3,26 +3,25 @@ import { HookConfigurationError, LifecycleHooks } from "@yielded/auth/Hooks";
3
3
  import { AuthenticationAuthority, PendingAuthentication, SessionRepository, SessionStepUpPersistence, SessionUnavailable, SignedSessionValidity, StatefulSessionPersistence } from "@yielded/auth/Sessions";
4
4
  import "effect/unstable/sql/SqlError";
5
5
  //#region src/drizzle/session-target.d.ts
6
- declare const authenticationAuthorityLayer: (services: Effect.Effect<{
6
+ export declare const authenticationAuthorityLayer: (services: Effect.Effect<{
7
7
  readonly authenticationAuthority: AuthenticationAuthority["Service"];
8
8
  }, never, LifecycleHooks>) => Layer.Layer<AuthenticationAuthority, never, LifecycleHooks>;
9
- declare const statefulSessionLayers: <Claims>(module: {
9
+ export declare const statefulSessionLayers: <Claims>(module: {
10
10
  readonly StatefulSessionPersistence: any;
11
11
  readonly SessionRepository: any;
12
12
  }, services: Effect.Effect<{
13
13
  readonly statefulSessionPersistence: StatefulSessionPersistence<Claims>;
14
14
  readonly sessionRepository: SessionRepository;
15
15
  }, never, LifecycleHooks>) => Layer.Layer<unknown, never, LifecycleHooks>;
16
- declare const pendingAuthenticationLayer: <Claims>(module: {
16
+ export declare const pendingAuthenticationLayer: <Claims>(module: {
17
17
  readonly PendingAuthentication: any;
18
18
  }, services: Effect.Effect<{
19
19
  readonly pendingAuthentication: PendingAuthentication<Claims>;
20
20
  }, never, LifecycleHooks>) => Layer.Layer<unknown, never, LifecycleHooks>;
21
- declare const signedSessionValidityLayer: (module: {
21
+ export declare const signedSessionValidityLayer: (module: {
22
22
  readonly SignedSessionValidity: any;
23
23
  }, services: Effect.Effect<{
24
24
  readonly signedSessionValidity: SignedSessionValidity;
25
25
  }, never, LifecycleHooks>) => Layer.Layer<unknown, never, LifecycleHooks>;
26
26
  //#endregion
27
- export { authenticationAuthorityLayer, pendingAuthenticationLayer, signedSessionValidityLayer, statefulSessionLayers };
28
27
  //# sourceMappingURL=session-target.d.mts.map
@@ -3,9 +3,9 @@ import { SuppliedService } from "./SuppliedService.mjs";
3
3
  import { Effect } from "effect";
4
4
  import { AuthStoreDecisions } from "@yielded/auth/Persistence";
5
5
  import { ConsumeChallenge, ConsumeRegistration, NewChallenge, NewRegistration, TokenDigest, VerifiedEmail } from "@yielded/auth/Schema";
6
+ import { InvalidOAuthState, OAuthState, OAuthStateDecisions } from "@yielded/auth/OAuth";
6
7
  import { EmailOtpRejected } from "@yielded/auth/AuthStore";
7
8
  import { AuthStoreError, InvalidRegistration } from "@yielded/auth/Errors";
8
- import { InvalidOAuthState, OAuthState, OAuthStateDecisions } from "@yielded/auth/OAuth";
9
9
  import { AnyRelations } from "drizzle-orm";
10
10
  import { AnySQLiteTable } from "drizzle-orm/sqlite-core";
11
11
  import { SqlError } from "effect/unstable/sql/SqlError";
@@ -23,7 +23,7 @@ type TransactionOf<D extends AnyDatabase> = Parameters<Parameters<D["transaction
23
23
  * unsupported interactive transaction and Durable Objects never suspend in a
24
24
  * transactionSync callback.
25
25
  */
26
- declare const makeSqliteAuthStoreServices: <C extends AnySQLiteTable, R extends AnySQLiteTable, HKT extends ClosedQueryEffectHKT = ClosedQueryEffectHKT, RunResult = unknown>(database: SQLiteEffectDatabase<HKT, RunResult, AnyRelations>, mapping: AuthStoreTables<C, R>, standaloneGuard?: Effect.Effect<void, AuthStoreError>) => {
26
+ export declare const makeSqliteAuthStoreServices: <C extends AnySQLiteTable, R extends AnySQLiteTable, HKT extends ClosedQueryEffectHKT = ClosedQueryEffectHKT, RunResult = unknown>(database: SQLiteEffectDatabase<HKT, RunResult, AnyRelations>, mapping: AuthStoreTables<C, R>, standaloneGuard?: Effect.Effect<void, AuthStoreError>) => {
27
27
  readonly authStore: {
28
28
  readonly issueChallenge: (input: NewChallenge) => Effect.Effect<void, import("@yielded/auth/AuthStore").IssueChallengeError>;
29
29
  readonly consumeChallenge: (input: ConsumeChallenge) => Effect.Effect<VerifiedEmail, EmailOtpRejected | AuthStoreError>;
@@ -36,7 +36,7 @@ declare const makeSqliteAuthStoreServices: <C extends AnySQLiteTable, R extends
36
36
  readonly consumeRegistration: (input: ConsumeRegistration) => Effect.Effect<ConsumeDecision<void>, AuthStoreError, never>;
37
37
  };
38
38
  };
39
- declare const makeSqliteOAuthStateServices: <S extends AnySQLiteTable, HKT extends ClosedQueryEffectHKT = ClosedQueryEffectHKT, RunResult = unknown>(database: SQLiteEffectDatabase<HKT, RunResult, AnyRelations>, mapping: OAuthStateTables<S>, standaloneGuard?: Effect.Effect<void, AuthStoreError>) => {
39
+ export declare const makeSqliteOAuthStateServices: <S extends AnySQLiteTable, HKT extends ClosedQueryEffectHKT = ClosedQueryEffectHKT, RunResult = unknown>(database: SQLiteEffectDatabase<HKT, RunResult, AnyRelations>, mapping: OAuthStateTables<S>, standaloneGuard?: Effect.Effect<void, AuthStoreError>) => {
40
40
  readonly oauthStateStore: {
41
41
  readonly issue: (state: OAuthState) => Effect.Effect<void, AuthStoreError>;
42
42
  readonly consume: (stateDigest: TokenDigest) => Effect.Effect<OAuthState, InvalidOAuthState | AuthStoreError>;
@@ -49,30 +49,29 @@ declare const makeSqliteOAuthStateServices: <S extends AnySQLiteTable, HKT exten
49
49
  * Owns the native outer commit for interactive SQLite targets. Keep rejection
50
50
  * as a decision value inside the owner; interruption before commit rolls back.
51
51
  */
52
- declare function coordinateSqliteAuthStoreTransaction<D extends AnyDatabase, C extends AnySQLiteTable, R extends AnySQLiteTable, A, E, Requirements, DatabaseError, DatabaseRequirements>(acquire: Effect.Effect<D, DatabaseError, DatabaseRequirements>, options: {
52
+ export declare function coordinateSqliteAuthStoreTransaction<D extends AnyDatabase, C extends AnySQLiteTable, R extends AnySQLiteTable, A, E, Requirements, DatabaseError, DatabaseRequirements>(acquire: Effect.Effect<D, DatabaseError, DatabaseRequirements>, options: {
53
53
  readonly mapping: AuthStoreTables<C, R>;
54
54
  readonly transaction?: never;
55
55
  }, body: Effect.Effect<A, E, Requirements>): Effect.Effect<A, E | DatabaseError | SqlError, Exclude<Requirements, AuthStoreDecisions> | DatabaseRequirements>;
56
- declare function coordinateSqliteAuthStoreTransaction<D extends AnyDatabase, C extends AnySQLiteTable, R extends AnySQLiteTable, A, E, Requirements, DatabaseError, DatabaseRequirements, TxId, TxShape>(acquire: Effect.Effect<D, DatabaseError, DatabaseRequirements>, options: {
56
+ export declare function coordinateSqliteAuthStoreTransaction<D extends AnyDatabase, C extends AnySQLiteTable, R extends AnySQLiteTable, A, E, Requirements, DatabaseError, DatabaseRequirements, TxId, TxShape>(acquire: Effect.Effect<D, DatabaseError, DatabaseRequirements>, options: {
57
57
  readonly mapping: AuthStoreTables<C, R>;
58
58
  readonly transaction: SuppliedService<TxId, NoInfer<TransactionOf<D>>, TxShape>;
59
59
  }, body: Effect.Effect<A, E, Requirements>): Effect.Effect<A, E | DatabaseError | SqlError, Exclude<Requirements, AuthStoreDecisions | TxId> | DatabaseRequirements>;
60
- declare function coordinateSqliteOAuthStateTransaction<D extends AnyDatabase, S extends AnySQLiteTable, A, E, Requirements, DatabaseError, DatabaseRequirements>(acquire: Effect.Effect<D, DatabaseError, DatabaseRequirements>, options: {
60
+ export declare function coordinateSqliteOAuthStateTransaction<D extends AnyDatabase, S extends AnySQLiteTable, A, E, Requirements, DatabaseError, DatabaseRequirements>(acquire: Effect.Effect<D, DatabaseError, DatabaseRequirements>, options: {
61
61
  readonly mapping: OAuthStateTables<S>;
62
62
  readonly transaction?: never;
63
63
  }, body: Effect.Effect<A, E, Requirements>): Effect.Effect<A, E | DatabaseError | SqlError, Exclude<Requirements, OAuthStateDecisions> | DatabaseRequirements>;
64
- declare function coordinateSqliteOAuthStateTransaction<D extends AnyDatabase, S extends AnySQLiteTable, A, E, Requirements, DatabaseError, DatabaseRequirements, TxId, TxShape>(acquire: Effect.Effect<D, DatabaseError, DatabaseRequirements>, options: {
64
+ export declare function coordinateSqliteOAuthStateTransaction<D extends AnyDatabase, S extends AnySQLiteTable, A, E, Requirements, DatabaseError, DatabaseRequirements, TxId, TxShape>(acquire: Effect.Effect<D, DatabaseError, DatabaseRequirements>, options: {
65
65
  readonly mapping: OAuthStateTables<S>;
66
66
  readonly transaction: SuppliedService<TxId, NoInfer<TransactionOf<D>>, TxShape>;
67
67
  }, body: Effect.Effect<A, E, Requirements>): Effect.Effect<A, E | DatabaseError | SqlError, Exclude<Requirements, OAuthStateDecisions | TxId> | DatabaseRequirements>;
68
- declare function coordinateSqliteAuthTransaction<D extends AnyDatabase, C extends AnySQLiteTable, R extends AnySQLiteTable, S extends AnySQLiteTable, A, E, Requirements, DatabaseError, DatabaseRequirements>(acquire: Effect.Effect<D, DatabaseError, DatabaseRequirements>, options: {
68
+ export declare function coordinateSqliteAuthTransaction<D extends AnyDatabase, C extends AnySQLiteTable, R extends AnySQLiteTable, S extends AnySQLiteTable, A, E, Requirements, DatabaseError, DatabaseRequirements>(acquire: Effect.Effect<D, DatabaseError, DatabaseRequirements>, options: {
69
69
  readonly mapping: AuthTables<C, R, S>;
70
70
  readonly transaction?: never;
71
71
  }, body: Effect.Effect<A, E, Requirements>): Effect.Effect<A, E | DatabaseError | SqlError, Exclude<Requirements, AuthStoreDecisions | OAuthStateDecisions> | DatabaseRequirements>;
72
- declare function coordinateSqliteAuthTransaction<D extends AnyDatabase, C extends AnySQLiteTable, R extends AnySQLiteTable, S extends AnySQLiteTable, A, E, Requirements, DatabaseError, DatabaseRequirements, TxId, TxShape>(acquire: Effect.Effect<D, DatabaseError, DatabaseRequirements>, options: {
72
+ export declare function coordinateSqliteAuthTransaction<D extends AnyDatabase, C extends AnySQLiteTable, R extends AnySQLiteTable, S extends AnySQLiteTable, A, E, Requirements, DatabaseError, DatabaseRequirements, TxId, TxShape>(acquire: Effect.Effect<D, DatabaseError, DatabaseRequirements>, options: {
73
73
  readonly mapping: AuthTables<C, R, S>;
74
74
  readonly transaction: SuppliedService<TxId, NoInfer<TransactionOf<D>>, TxShape>;
75
75
  }, body: Effect.Effect<A, E, Requirements>): Effect.Effect<A, E | DatabaseError | SqlError, Exclude<Requirements, AuthStoreDecisions | OAuthStateDecisions | TxId> | DatabaseRequirements>;
76
76
  //#endregion
77
- export { coordinateSqliteAuthStoreTransaction, coordinateSqliteAuthTransaction, coordinateSqliteOAuthStateTransaction, makeSqliteAuthStoreServices, makeSqliteOAuthStateServices };
78
77
  //# sourceMappingURL=sqlite.d.mts.map
@@ -2,9 +2,9 @@ import { column, requireStandaloneConsume, updateValues } from "./model.mjs";
2
2
  import { Cause, Context, DateTime, Duration, Effect, Schema } from "effect";
3
3
  import { AuthStoreDecisions, reportPersistenceFailure } from "@yielded/auth/Persistence";
4
4
  import { VerifiedEmail } from "@yielded/auth/Schema";
5
+ import { InvalidOAuthState, OAuthStateDecisions, OAuthStateStore } from "@yielded/auth/OAuth";
5
6
  import { AuthStore, EmailOtpRejected } from "@yielded/auth/AuthStore";
6
7
  import { AuthRateLimited, AuthStoreError, InvalidRegistration } from "@yielded/auth/Errors";
7
- import { InvalidOAuthState, OAuthStateDecisions, OAuthStateStore } from "@yielded/auth/OAuth";
8
8
  import { and, eq, gt, lt, lte, ne, or, sql } from "drizzle-orm";
9
9
  //#region src/drizzle/sqlite.ts
10
10
  const storeReadError = () => AuthStoreError.make({ message: "Auth store read failed" });
@@ -1,4 +1,5 @@
1
- import { Context, Effect, Option, Predicate } from "effect";
1
+ import { requireStandalone } from "../internal/standalone.mjs";
2
+ import { Context, Effect, Predicate } from "effect";
2
3
  //#region src/drizzle/standalone-guard.ts
3
4
  const transactionService = (database) => {
4
5
  if (!Predicate.hasProperty(database, "$client") || !Predicate.hasProperty(database.$client, "transactionService") || !Context.isKey(database.$client.transactionService)) return;
@@ -8,10 +9,7 @@ const transactionService = (database) => {
8
9
  const sqlClientStandaloneGuard = (database, unavailable) => {
9
10
  const service = transactionService(database);
10
11
  if (service === void 0) return Effect.suspend(() => Effect.fail(unavailable()));
11
- return Effect.serviceOption(service).pipe(Effect.flatMap(Option.match({
12
- onNone: () => Effect.void,
13
- onSome: () => Effect.fail(unavailable())
14
- })));
12
+ return requireStandalone(unavailable, { transactionService: service });
15
13
  };
16
14
  //#endregion
17
15
  export { sqlClientStandaloneGuard };
@@ -1 +1 @@
1
- {"version":3,"file":"standalone-guard.mjs","names":[],"sources":["../../src/drizzle/standalone-guard.ts"],"sourcesContent":["import { Context, Effect, Option, Predicate } from \"effect\";\nimport type * as SqlClient from \"effect/unstable/sql/SqlClient\";\n\ntype TransactionService = Context.Key<\n SqlClient.TransactionConnection,\n SqlClient.TransactionConnection.Service\n>;\n\nconst transactionService = (database: unknown): TransactionService | undefined => {\n if (\n !Predicate.hasProperty(database, \"$client\") ||\n !Predicate.hasProperty(database.$client, \"transactionService\") ||\n !Context.isKey(database.$client.transactionService)\n ) {\n return undefined;\n }\n\n return database.$client.transactionService;\n};\n\n/** Bind the client-specific transaction marker at foreign adapter construction. */\nexport const sqlClientStandaloneGuard = <Failure>(\n database: unknown,\n unavailable: () => Failure,\n): Effect.Effect<void, Failure> => {\n const service = transactionService(database);\n\n if (service === undefined) return Effect.suspend(() => Effect.fail(unavailable()));\n\n return Effect.serviceOption(service).pipe(\n Effect.flatMap(\n Option.match({\n onNone: () => Effect.void,\n onSome: () => Effect.fail(unavailable()),\n }),\n ),\n );\n};\n"],"mappings":";;AAQA,MAAM,sBAAsB,aAAsD;CAChF,IACE,CAAC,UAAU,YAAY,UAAU,SAAS,KAC1C,CAAC,UAAU,YAAY,SAAS,SAAS,oBAAoB,KAC7D,CAAC,QAAQ,MAAM,SAAS,QAAQ,kBAAkB,GAElD;CAGF,OAAO,SAAS,QAAQ;AAC1B;;AAGA,MAAa,4BACX,UACA,gBACiC;CACjC,MAAM,UAAU,mBAAmB,QAAQ;CAE3C,IAAI,YAAY,KAAA,GAAW,OAAO,OAAO,cAAc,OAAO,KAAK,YAAY,CAAC,CAAC;CAEjF,OAAO,OAAO,cAAc,OAAO,CAAC,CAAC,KACnC,OAAO,QACL,OAAO,MAAM;EACX,cAAc,OAAO;EACrB,cAAc,OAAO,KAAK,YAAY,CAAC;CACzC,CAAC,CACH,CACF;AACF"}
1
+ {"version":3,"file":"standalone-guard.mjs","names":[],"sources":["../../src/drizzle/standalone-guard.ts"],"sourcesContent":["import { Context, Effect, Predicate } from \"effect\";\nimport type * as SqlClient from \"effect/unstable/sql/SqlClient\";\n\nimport { requireStandalone } from \"../internal/standalone\";\n\ntype TransactionService = Context.Key<\n SqlClient.TransactionConnection,\n SqlClient.TransactionConnection.Service\n>;\n\nconst transactionService = (database: unknown): TransactionService | undefined => {\n if (\n !Predicate.hasProperty(database, \"$client\") ||\n !Predicate.hasProperty(database.$client, \"transactionService\") ||\n !Context.isKey(database.$client.transactionService)\n ) {\n return undefined;\n }\n\n return database.$client.transactionService;\n};\n\n/** Bind the client-specific transaction marker at foreign adapter construction. */\nexport const sqlClientStandaloneGuard = <Failure>(\n database: unknown,\n unavailable: () => Failure,\n): Effect.Effect<void, Failure> => {\n const service = transactionService(database);\n\n if (service === undefined) return Effect.suspend(() => Effect.fail(unavailable()));\n\n return requireStandalone(unavailable, { transactionService: service });\n};\n"],"mappings":";;;AAUA,MAAM,sBAAsB,aAAsD;CAChF,IACE,CAAC,UAAU,YAAY,UAAU,SAAS,KAC1C,CAAC,UAAU,YAAY,SAAS,SAAS,oBAAoB,KAC7D,CAAC,QAAQ,MAAM,SAAS,QAAQ,kBAAkB,GAElD;CAGF,OAAO,SAAS,QAAQ;AAC1B;;AAGA,MAAa,4BACX,UACA,gBACiC;CACjC,MAAM,UAAU,mBAAmB,QAAQ;CAE3C,IAAI,YAAY,KAAA,GAAW,OAAO,OAAO,cAAc,OAAO,KAAK,YAAY,CAAC,CAAC;CAEjF,OAAO,kBAAkB,aAAa,EAAE,oBAAoB,QAAQ,CAAC;AACvE"}
@@ -8,7 +8,7 @@ import { InferInsertModel, Table } from "drizzle-orm";
8
8
  type ColumnKey<T extends Table> = Extract<keyof T["_"]["columns"], string>;
9
9
  /** Distinct from login-pending storage. Snapshot is TEXT encoded by the core's
10
10
  * SessionStepUpIntent schema; it contains no Claims and needs no consumer decoder. */
11
- interface SessionStepUpIntentTables<Intent extends Table, NativeSubjectId> {
11
+ export interface SessionStepUpIntentTables<Intent extends Table, NativeSubjectId> {
12
12
  readonly intent: {
13
13
  readonly table: Intent;
14
14
  readonly digest: ColumnKey<Intent>;
@@ -30,14 +30,14 @@ interface SessionStepUpIntentTables<Intent extends Table, NativeSubjectId> {
30
30
  readonly allocateVersionSync?: () => SecurityRevision;
31
31
  };
32
32
  }
33
- interface RequiredSessionStepUpConstraints {
33
+ export interface RequiredSessionStepUpConstraints {
34
34
  readonly intentDigest: "unique(intent.digest)";
35
35
  readonly intentFlow: "unique(intent.flowId)";
36
36
  }
37
- declare const requiredSessionStepUpConstraints: RequiredSessionStepUpConstraints;
37
+ export declare const requiredSessionStepUpConstraints: RequiredSessionStepUpConstraints;
38
38
  /** Fixed source discriminator is checked against every stored intent. A minimal
39
39
  * pure-signed installation does not provide dummy session or tombstone tables. */
40
- type SessionStepUpSourceTables<Claims, Session extends Table, Tombstone extends Table, NativeSubjectId, NativeSessionId> = {
40
+ export type SessionStepUpSourceTables<Claims, Session extends Table, Tombstone extends Table, NativeSubjectId, NativeSessionId> = {
41
41
  readonly kind: "StatelessSigned";
42
42
  } | ({
43
43
  readonly kind: "StateAssistedSigned";
@@ -55,11 +55,10 @@ type SessionStepUpSourceTables<Claims, Session extends Table, Tombstone extends
55
55
  readonly authenticatedAt: ColumnKey<Session>;
56
56
  };
57
57
  };
58
- type SessionStepUpMapping<Claims, Subject extends Table, Credential extends Table, Intent extends Table, Session extends Table, Tombstone extends Table, NativeSubjectId, NativeSessionId> = SessionAuthorityTables<Subject, Credential, NativeSubjectId> & SessionStepUpIntentTables<Intent, NativeSubjectId> & SessionConstraintClassifier & {
58
+ export type SessionStepUpMapping<Claims, Subject extends Table, Credential extends Table, Intent extends Table, Session extends Table, Tombstone extends Table, NativeSubjectId, NativeSessionId> = SessionAuthorityTables<Subject, Credential, NativeSubjectId> & SessionStepUpIntentTables<Intent, NativeSubjectId> & SessionConstraintClassifier & {
59
59
  readonly source: SessionStepUpSourceTables<Claims, Session, Tombstone, NativeSubjectId, NativeSessionId>;
60
60
  readonly constraints: RequiredSessionStepUpConstraints;
61
61
  };
62
- type D1SessionStepUpMapping<Claims, Subject extends Table, Credential extends Table, Intent extends Table, Session extends Table, Tombstone extends Table, NativeSubjectId, NativeSessionId> = SessionStepUpMapping<Claims, Subject, Credential, Intent, Session, Tombstone, NativeSubjectId, NativeSessionId> & D1SessionClockMapping;
62
+ export type D1SessionStepUpMapping<Claims, Subject extends Table, Credential extends Table, Intent extends Table, Session extends Table, Tombstone extends Table, NativeSubjectId, NativeSessionId> = SessionStepUpMapping<Claims, Subject, Credential, Intent, Session, Tombstone, NativeSubjectId, NativeSessionId> & D1SessionClockMapping;
63
63
  //#endregion
64
- export { D1SessionStepUpMapping, RequiredSessionStepUpConstraints, SessionStepUpIntentTables, SessionStepUpMapping, SessionStepUpSourceTables, requiredSessionStepUpConstraints };
65
64
  //# sourceMappingURL=step-up-model.d.mts.map
@@ -6,9 +6,9 @@ import { AuthenticationRequirement, PendingAuthenticationContext } from "@yielde
6
6
  import { InferInsertModel, InferSelectModel, SQL, Table } from "drizzle-orm";
7
7
  import { TotpPersistence, TotpPolicy } from "@yielded/auth/Totp";
8
8
  //#region src/drizzle/totp-model.d.ts
9
- type TotpColumn<T extends Table> = Extract<keyof T["_"]["columns"], string>;
10
- type TotpMappingSource<M, R = never> = M | Effect.Effect<M, PersistenceMappingError, R>;
11
- declare const requiredTotpConstraints: {
9
+ export type TotpColumn<T extends Table> = Extract<keyof T["_"]["columns"], string>;
10
+ export type TotpMappingSource<M, R = never> = M | Effect.Effect<M, PersistenceMappingError, R>;
11
+ export declare const requiredTotpConstraints: {
12
12
  readonly factor: "unique(scope)";
13
13
  readonly credential: "unique(credentialId)";
14
14
  readonly subject: "unique(id)";
@@ -20,7 +20,7 @@ declare const requiredTotpConstraints: {
20
20
  * domain-separated management command tombstones; retain them while command IDs
21
21
  * can be replayed. Encoders and current requirement decoding cannot suspend.
22
22
  */
23
- interface TotpMapping<S extends Table, F extends Table, C extends Table, N> {
23
+ export interface TotpMapping<S extends Table, F extends Table, C extends Table, N> {
24
24
  readonly moduleId: string;
25
25
  readonly policy: TotpPolicy;
26
26
  readonly constraints: typeof requiredTotpConstraints;
@@ -70,15 +70,14 @@ interface TotpMapping<S extends Table, F extends Table, C extends Table, N> {
70
70
  * revisions. No request-supplied SQL or external I/O is accepted. */
71
71
  readonly pendingCondition?: (target: PendingAuthenticationContext, subjectId: N) => SQL;
72
72
  }
73
- interface D1TotpMapping {
73
+ export interface D1TotpMapping {
74
74
  readonly d1: {
75
75
  readonly primary: true;
76
76
  };
77
77
  }
78
- interface TotpPersistenceServices {
78
+ export interface TotpPersistenceServices {
79
79
  readonly totpPersistence: TotpPersistence["Service"];
80
80
  }
81
- declare const totpPersistenceLayer: <E, R>(services: Effect.Effect<TotpPersistenceServices, E, R>) => Layer.Layer<TotpPersistence, E, Exclude<R, import("effect/Scope").Scope>>;
81
+ export declare const totpPersistenceLayer: <E, R>(services: Effect.Effect<TotpPersistenceServices, E, R>) => Layer.Layer<TotpPersistence, E, Exclude<R, import("effect/Scope").Scope>>;
82
82
  //#endregion
83
- export { D1TotpMapping, TotpColumn, TotpMapping, TotpMappingSource, TotpPersistenceServices, requiredTotpConstraints, totpPersistenceLayer };
84
83
  //# sourceMappingURL=totp-model.d.mts.map
@@ -3,8 +3,8 @@ import { Context, Effect } from "effect";
3
3
  import { SQL } from "drizzle-orm";
4
4
  import { TotpRecord, TotpUnavailable } from "@yielded/auth/Totp";
5
5
  //#region src/drizzle/totp-state.d.ts
6
- declare const encodeTotpRecord: (record: TotpRecord) => string;
7
- declare const decodeTotpRecord: (state: string) => {
6
+ export declare const encodeTotpRecord: (record: TotpRecord) => string;
7
+ export declare const decodeTotpRecord: (state: string) => {
8
8
  readonly moduleId: string;
9
9
  readonly subjectId: string & import("effect/Brand").Brand<"effect-auth/SubjectId">;
10
10
  readonly credentialId: string;
@@ -34,5 +34,4 @@ declare const decodeTotpRecord: (state: string) => {
34
34
  readonly failedAttempts: number;
35
35
  };
36
36
  //#endregion
37
- export { decodeTotpRecord, encodeTotpRecord };
38
37
  //# sourceMappingURL=totp-state.d.mts.map
@@ -11,7 +11,6 @@ import { Table } from "drizzle-orm";
11
11
  import { TotpConfigurationError, TotpPersistence, TotpUnavailable } from "@yielded/auth/Totp";
12
12
  import { Statement } from "effect/unstable/sql/Statement";
13
13
  //#region src/drizzle/totp-target.d.ts
14
- type TotpCoordinatorError<E> = TransactionCoordinatorError<E, TotpUnavailable> | TotpConfigurationError | PersistenceMappingError;
14
+ export type TotpCoordinatorError<E> = TransactionCoordinatorError<E, TotpUnavailable> | TotpConfigurationError | PersistenceMappingError;
15
15
  //#endregion
16
- export { TotpCoordinatorError };
17
16
  //# sourceMappingURL=totp-target.d.mts.map
@@ -29,6 +29,7 @@ const mysqlTransaction = (unavailable, database, body) => Effect.scoped(Effect.g
29
29
  commit: () => statement("COMMIT"),
30
30
  rollback: () => statement("ROLLBACK"),
31
31
  savepoint: (_connection, id) => statement(`SAVEPOINT effect_auth_oauth_${id}`),
32
+ releaseSavepoint: (_connection, id) => statement(`RELEASE SAVEPOINT effect_auth_oauth_${id}`),
32
33
  rollbackSavepoint: (_connection, id) => statement(`ROLLBACK TO SAVEPOINT effect_auth_oauth_${id}`)
33
34
  });
34
35
  class NativeTransaction extends EffectMysql2Transaction {