@yielded/auth-persistence 0.1.0-beta.23 → 0.1.0-beta.25

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 (182) hide show
  1. package/README.md +11 -0
  2. package/dist/Adapter.d.mts +12 -6
  3. package/dist/Adapter.mjs +8 -3
  4. package/dist/OAuthPersistence.d.mts +87 -0
  5. package/dist/OAuthPersistence.mjs +125 -0
  6. package/dist/OAuthPersistence.mjs.map +1 -0
  7. package/dist/_virtual/_rolldown/runtime.mjs +13 -0
  8. package/dist/index.d.mts +3 -1
  9. package/dist/index.mjs +3 -1
  10. package/dist/internal/configuration.d.mts +1 -1
  11. package/dist/internal/configuration.mjs.map +1 -1
  12. package/dist/internal/email-kernel.d.mts +1 -1
  13. package/dist/internal/email-kernel.mjs +1 -1
  14. package/dist/internal/email-kernel.mjs.map +1 -1
  15. package/dist/internal/models/oauth-connected-model.d.mts +294 -0
  16. package/dist/internal/models/oauth-connected-model.mjs +22 -0
  17. package/dist/internal/models/oauth-connected-model.mjs.map +1 -0
  18. package/dist/internal/models/oauth-model.d.mts +467 -0
  19. package/dist/internal/models/oauth-model.mjs +49 -0
  20. package/dist/internal/models/oauth-model.mjs.map +1 -0
  21. package/dist/internal/models/password-model.d.mts +6 -48
  22. package/dist/internal/models/password-model.mjs +0 -1
  23. package/dist/internal/models/password-model.mjs.map +1 -1
  24. package/dist/internal/native-sql-table.d.mts +4 -0
  25. package/dist/internal/native-sql-table.mjs +7 -0
  26. package/dist/internal/native-sql-table.mjs.map +1 -1
  27. package/dist/internal/oauth/accounts.d.mts +8 -0
  28. package/dist/internal/oauth/accounts.mjs +379 -0
  29. package/dist/internal/oauth/accounts.mjs.map +1 -0
  30. package/dist/internal/oauth/connected-access.d.mts +9 -0
  31. package/dist/internal/oauth/connected-access.mjs +229 -0
  32. package/dist/internal/oauth/connected-access.mjs.map +1 -0
  33. package/dist/internal/oauth/connected-collection.d.mts +7 -0
  34. package/dist/internal/oauth/connected-collection.mjs +214 -0
  35. package/dist/internal/oauth/connected-collection.mjs.map +1 -0
  36. package/dist/internal/oauth/connected-custody.d.mts +6 -0
  37. package/dist/internal/oauth/connected-custody.mjs +165 -0
  38. package/dist/internal/oauth/connected-custody.mjs.map +1 -0
  39. package/dist/internal/oauth/connected-flow.d.mts +7 -0
  40. package/dist/internal/oauth/connected-flow.mjs +324 -0
  41. package/dist/internal/oauth/connected-flow.mjs.map +1 -0
  42. package/dist/internal/oauth/connected-input.mjs +122 -0
  43. package/dist/internal/oauth/connected-input.mjs.map +1 -0
  44. package/dist/internal/oauth/connected-keys.d.mts +2 -0
  45. package/dist/internal/oauth/connected-keys.mjs +22 -0
  46. package/dist/internal/oauth/connected-keys.mjs.map +1 -0
  47. package/dist/internal/oauth/connected-maintenance.d.mts +9 -0
  48. package/dist/internal/oauth/connected-maintenance.mjs +226 -0
  49. package/dist/internal/oauth/connected-maintenance.mjs.map +1 -0
  50. package/dist/internal/oauth/connected-management.d.mts +9 -0
  51. package/dist/internal/oauth/connected-management.mjs +243 -0
  52. package/dist/internal/oauth/connected-management.mjs.map +1 -0
  53. package/dist/internal/oauth/connected-reference.mjs +63 -0
  54. package/dist/internal/oauth/connected-reference.mjs.map +1 -0
  55. package/dist/internal/oauth/connected-settlement.d.mts +8 -0
  56. package/dist/internal/oauth/connected-settlement.mjs +141 -0
  57. package/dist/internal/oauth/connected-settlement.mjs.map +1 -0
  58. package/dist/internal/oauth/connected-sign-in.d.mts +10 -0
  59. package/dist/internal/oauth/connected-sign-in.mjs +281 -0
  60. package/dist/internal/oauth/connected-sign-in.mjs.map +1 -0
  61. package/dist/internal/oauth/connected-state.d.mts +14 -0
  62. package/dist/internal/oauth/connected-state.mjs +469 -0
  63. package/dist/internal/oauth/connected-state.mjs.map +1 -0
  64. package/dist/internal/oauth/connected-target.d.mts +21 -0
  65. package/dist/internal/oauth/connected-target.mjs +117 -0
  66. package/dist/internal/oauth/connected-target.mjs.map +1 -0
  67. package/dist/internal/oauth/flow.d.mts +5 -0
  68. package/dist/internal/oauth/flow.mjs +279 -0
  69. package/dist/internal/oauth/flow.mjs.map +1 -0
  70. package/dist/internal/oauth/input.mjs +127 -0
  71. package/dist/internal/oauth/input.mjs.map +1 -0
  72. package/dist/internal/oauth/owner.d.mts +10 -0
  73. package/dist/internal/oauth/owner.mjs +10 -0
  74. package/dist/internal/oauth/owner.mjs.map +1 -0
  75. package/dist/internal/oauth/query-compiler.d.mts +7 -0
  76. package/dist/internal/oauth/query-compiler.mjs +9 -0
  77. package/dist/internal/oauth/query-compiler.mjs.map +1 -0
  78. package/dist/internal/oauth/registration.d.mts +7 -0
  79. package/dist/internal/oauth/registration.mjs +393 -0
  80. package/dist/internal/oauth/registration.mjs.map +1 -0
  81. package/dist/internal/oauth/state.mjs +107 -0
  82. package/dist/internal/oauth/state.mjs.map +1 -0
  83. package/dist/internal/oauth/target.d.mts +31 -0
  84. package/dist/internal/oauth/target.mjs +273 -0
  85. package/dist/internal/oauth/target.mjs.map +1 -0
  86. package/dist/internal/oauth-kernel.d.mts +1423 -0
  87. package/dist/internal/oauth-kernel.mjs +187 -0
  88. package/dist/internal/oauth-kernel.mjs.map +1 -0
  89. package/dist/internal/oauth-proxy.d.mts +31 -0
  90. package/dist/internal/oauth-proxy.mjs +129 -0
  91. package/dist/internal/oauth-proxy.mjs.map +1 -0
  92. package/dist/internal/passkey/write-state.mjs +9 -1
  93. package/dist/internal/passkey/write-state.mjs.map +1 -1
  94. package/dist/internal/passkey-kernel.d.mts +9 -9
  95. package/dist/internal/{password-attempts.d.mts → password-credentials.d.mts} +3 -4
  96. package/dist/internal/password-credentials.mjs +121 -0
  97. package/dist/internal/password-credentials.mjs.map +1 -0
  98. package/dist/internal/password-kernel.d.mts +8 -24
  99. package/dist/internal/password-kernel.mjs +5 -43
  100. package/dist/internal/password-kernel.mjs.map +1 -1
  101. package/dist/internal/persistence.d.mts +1 -1
  102. package/dist/internal/persistence.mjs +2 -2
  103. package/dist/internal/persistence.mjs.map +1 -1
  104. package/dist/internal/query-operations.d.mts +2 -0
  105. package/dist/internal/session-kernel.d.mts +2 -2
  106. package/dist/internal/session-kernel.mjs +74 -18
  107. package/dist/internal/session-kernel.mjs.map +1 -1
  108. package/dist/internal/sql-oauth-connected-model.d.mts +29 -0
  109. package/dist/internal/sql-oauth-connected-model.mjs +7 -0
  110. package/dist/internal/sql-oauth-connected-model.mjs.map +1 -0
  111. package/dist/internal/sql-oauth-model.d.mts +60 -0
  112. package/dist/internal/sql-oauth-model.mjs +10 -0
  113. package/dist/internal/sql-oauth-model.mjs.map +1 -0
  114. package/dist/internal/sql-query.d.mts +12 -0
  115. package/dist/internal/sql-query.mjs +15 -18
  116. package/dist/internal/sql-query.mjs.map +1 -1
  117. package/dist/internal/sql-storage-validation.mjs +54 -0
  118. package/dist/internal/sql-storage-validation.mjs.map +1 -0
  119. package/dist/internal/storage-mapping.mjs +1 -37
  120. package/dist/internal/storage-mapping.mjs.map +1 -1
  121. package/dist/internal/storage-plans.d.mts +7 -0
  122. package/dist/internal/storage-plans.mjs +189 -0
  123. package/dist/internal/storage-plans.mjs.map +1 -0
  124. package/dist/internal/storage-tables.d.mts +0 -56
  125. package/dist/internal/storage-tables.mjs +0 -17
  126. package/dist/internal/storage-tables.mjs.map +1 -1
  127. package/dist/internal/storage-validation.d.mts +6 -1
  128. package/dist/internal/storage-validation.mjs +42 -1
  129. package/dist/internal/storage-validation.mjs.map +1 -1
  130. package/dist/internal/transaction-kernel.mjs +3 -2
  131. package/dist/internal/transaction-kernel.mjs.map +1 -1
  132. package/package.json +1 -1
  133. package/src/Adapter.ts +89 -5
  134. package/src/OAuthPersistence.ts +427 -0
  135. package/src/index.ts +3 -0
  136. package/src/internal/configuration.ts +1 -3
  137. package/src/internal/email-kernel.ts +2 -1
  138. package/src/internal/models/oauth-connected-model.ts +396 -0
  139. package/src/internal/models/oauth-model.ts +708 -0
  140. package/src/internal/models/password-model.ts +2 -57
  141. package/src/internal/native-sql-table.ts +14 -0
  142. package/src/internal/oauth/accounts.ts +839 -0
  143. package/src/internal/oauth/connected-access.ts +388 -0
  144. package/src/internal/oauth/connected-collection.ts +345 -0
  145. package/src/internal/oauth/connected-custody.ts +308 -0
  146. package/src/internal/oauth/connected-flow.ts +562 -0
  147. package/src/internal/oauth/connected-input.ts +147 -0
  148. package/src/internal/oauth/connected-keys.ts +31 -0
  149. package/src/internal/oauth/connected-maintenance.ts +379 -0
  150. package/src/internal/oauth/connected-management.ts +391 -0
  151. package/src/internal/oauth/connected-reference.ts +135 -0
  152. package/src/internal/oauth/connected-settlement.ts +278 -0
  153. package/src/internal/oauth/connected-sign-in.ts +472 -0
  154. package/src/internal/oauth/connected-state.ts +924 -0
  155. package/src/internal/oauth/connected-target.ts +307 -0
  156. package/src/internal/oauth/flow.ts +505 -0
  157. package/src/internal/oauth/input.ts +201 -0
  158. package/src/internal/oauth/owner.ts +22 -0
  159. package/src/internal/oauth/query-compiler.ts +15 -0
  160. package/src/internal/oauth/registration.ts +676 -0
  161. package/src/internal/oauth/state.ts +218 -0
  162. package/src/internal/oauth/target.ts +803 -0
  163. package/src/internal/oauth-kernel.ts +294 -0
  164. package/src/internal/oauth-proxy.ts +176 -0
  165. package/src/internal/passkey/write-state.ts +18 -4
  166. package/src/internal/password-credentials.ts +245 -0
  167. package/src/internal/password-kernel.ts +7 -99
  168. package/src/internal/persistence.ts +1 -1
  169. package/src/internal/query-operations.ts +2 -0
  170. package/src/internal/session-kernel.ts +143 -55
  171. package/src/internal/sql-oauth-connected-model.ts +145 -0
  172. package/src/internal/sql-oauth-model.ts +263 -0
  173. package/src/internal/sql-query.ts +16 -13
  174. package/src/internal/sql-storage-validation.ts +64 -0
  175. package/src/internal/storage-mapping.ts +0 -37
  176. package/src/internal/storage-plans.ts +218 -0
  177. package/src/internal/storage-tables.ts +0 -20
  178. package/src/internal/storage-validation.ts +58 -0
  179. package/src/internal/transaction-kernel.ts +6 -2
  180. package/dist/internal/password-attempts.mjs +0 -197
  181. package/dist/internal/password-attempts.mjs.map +0 -1
  182. package/src/internal/password-attempts.ts +0 -466
package/README.md CHANGED
@@ -9,10 +9,21 @@ Drizzle integrations live in `@yielded/auth-persistence-drizzle`; this package h
9
9
  no Drizzle dependency or exports. Core workflows and replaceable service contracts
10
10
  remain in `@yielded/auth`.
11
11
 
12
+ `OAuthPersistence` supplies upstream provider sign-in, registration, login linking and
13
+ unlinking, and retained grants through explicit table mappings on PostgreSQL and
14
+ SQLite with interactive transactions. Provide `SqlClient`, Effect `Crypto`, and
15
+ lifecycle hooks; applications own subjects, policies, keys, and migrations. See the
16
+ [OAuth adapter reference](../../docs/src/content/docs/reference/adapters.md#oauth)
17
+ and [runnable Effect SQL consumer](../../examples/persistence-sql).
18
+
12
19
  `OAuthServerPersistence` supplies independent, single-table consent and grant
13
20
  storage for [MCP authorization](../../docs/src/content/docs/guide/oauth.mdx#authorize-mcp-clients).
14
21
  Its conditional writes and monotonic revocation require standalone commits.
15
22
 
23
+ `OAuthProxyPersistence` stores encrypted attempts for the
24
+ [OAuth callback proxy](../../docs/src/content/docs/reference/oauth.md#callback-proxy)
25
+ on SQLite/D1 or PostgreSQL. Its operations require standalone commits.
26
+
16
27
  Applications own subject provisioning, policy, claims, delivery, and their database
17
28
  connection and migration runner.
18
29
 
@@ -6,11 +6,12 @@ import { AnyEmailAddressMapping, AnyEmailRegistrationMapping, AnyEmailSignInMapp
6
6
  import { D1PasskeyMapping, PasskeyAdmissionTable, PasskeyCeremonyMapping, PasskeyChargeInsert, PasskeyChargeKind, PasskeyChargeTable, PasskeyClock, PasskeyColumn, PasskeyCredentialMapping, PasskeyCredentialOwnershipTable, PasskeyCredentialReadTable, PasskeyCredentialServices, PasskeyEnrollmentContextMapping, PasskeyEnrollmentContextServices, PasskeyFactorReadTable, PasskeyFlowInsert, PasskeyFlowState, PasskeyFlowTable, PasskeyHandleOwnershipTable, PasskeyHandleReadTable, PasskeyHandleReservationTable, PasskeyMappingSource, PasskeyModuleTable, PasskeyPersistenceMapping, PasskeyPersistenceServices, PasskeyPolicyGuard, PasskeySubjectIdCodec, PasskeySubjectReadTable, passkeyCredentialsLayer, passkeyEnrollmentContextLayer, passkeyPersistenceLayer, passkeyPolicyGuard, requiredPasskeyCredentialConstraints, requiredPasskeyPersistenceConstraints } from "./internal/models/passkey-model.mjs";
7
7
  import { PasskeyRegistrationCeremonyCapabilities, PasskeyRegistrationCeremonyMapping, PasskeyRegistrationCeremonyServices, PasskeyRegistrationIntentReadTable, requiredPasskeyRegistrationCeremonyConstraints } from "./internal/models/passkey-registration-ceremony-model.mjs";
8
8
  import { PasskeyCommandTable, PasskeyCredentialInsert, PasskeyInvalidationInput, PasskeyInvalidationMutation, PasskeyManagementMapping, PasskeyManagementServices, PasskeyRegistrationMapping, PasskeyRegistrationServices, PasskeyRegistrationWriter, PasskeyWriteTables, passkeyInvalidationMutation, requiredPasskeyManagementConstraints, requiredPasskeyRegistrationWriteConstraints } from "./internal/models/passkey-write-model.mjs";
9
- import { AnyPasswordPersistenceMapping, AnyPasswordRegistrationMapping, D1PasswordPersistenceMapping, PasswordAttemptAction, PasswordAttemptRecord, PasswordAttemptState, PasswordAttemptTable, PasswordAuthorityCredentialTable, PasswordCommandTable, PasswordConstraintClassifier, PasswordCredentialTable, PasswordD1Clock, PasswordIdentifierTable, PasswordPersistenceMapping, PasswordRegistrationConstraintClassifier, PasswordRegistrationIntent, PasswordRegistrationMapping, PasswordRegistrationProvisioning, PasswordRegistrationState, PasswordRegistrationTable, PasswordSubjectTable, RequiredPasswordConstraints, RequiredPasswordRegistrationConstraints, requiredPasswordConstraints, requiredPasswordRegistrationConstraints } from "./internal/models/password-model.mjs";
9
+ import { AnyPasswordPersistenceMapping, AnyPasswordRegistrationMapping, D1PasswordPersistenceMapping, PasswordAuthorityCredentialTable, PasswordCommandTable, PasswordConstraintClassifier, PasswordCredentialTable, PasswordD1Clock, PasswordIdentifierTable, PasswordPersistenceMapping, PasswordRegistrationConstraintClassifier, PasswordRegistrationIntent, PasswordRegistrationMapping, PasswordRegistrationProvisioning, PasswordRegistrationState, PasswordRegistrationTable, PasswordSubjectTable, RequiredPasswordConstraints, RequiredPasswordRegistrationConstraints, requiredPasswordConstraints, requiredPasswordRegistrationConstraints } from "./internal/models/password-model.mjs";
10
10
  import { 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 } from "./internal/models/proof-model.mjs";
11
11
  import { 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 } from "./internal/models/session-model.mjs";
12
12
  import { D1SessionStepUpMapping, RequiredSessionStepUpConstraints, SessionStepUpIntentTables, SessionStepUpMapping, SessionStepUpSourceTables, requiredSessionStepUpConstraints } from "./internal/models/step-up-model.mjs";
13
13
  import { requireStandalone } from "./internal/standalone.mjs";
14
+ import { OAuthProxySqlTable, makeOAuthProxyPersistence, oauthProxyColumns } from "./internal/oauth-proxy.mjs";
14
15
  import { decodeStepUpIntent, encodeStepUpIntent, stepUpIntentLive, validateStepUpPlan } from "./internal/step-up-state.mjs";
15
16
  import { CurrentProofSql, ProofSqlConfiguration, ProofSqlDatabase, ProofSqlQuery, makeProofKernel } from "./internal/proof-kernel.mjs";
16
17
  import { CurrentAddress, CurrentEmailSql, EmailSqlConfiguration, EmailSqlDatabase, EmailSqlQuery, makeEmailKernel } from "./internal/email-kernel.mjs";
@@ -18,17 +19,22 @@ import { CurrentPasskeyTransaction, PasskeyOwner } from "./internal/passkey/stat
18
19
  import { TransactionBound, TransactionCoordinatorError, TransactionExecution, TransactionTargetConfiguration, makeTransactionExecutionKernel } from "./internal/transaction-execution-kernel.mjs";
19
20
  import { PasskeyCoordinatorError, PasskeyExecution, PasskeyTargetConfiguration } from "./internal/passkey/target.mjs";
20
21
  import { PasskeyKernel, makePasskeyKernel } from "./internal/passkey-kernel.mjs";
22
+ import { StorageTable } from "./internal/storage-tables.mjs";
23
+ import { BoundPersistence, ClaimsCodec, Definition, PersistenceApi, PersistenceConfigurationError } from "./internal/configuration.mjs";
24
+ import { PhysicalStorageTable, StorageValidation, validateStorage, validateStorageBatch, withStorageValidation } from "./internal/storage-validation.mjs";
21
25
  import { NativeSqlTables, SqlTable, makeNativeSqlTables, nativeSqlAlias } from "./internal/native-sql-table.mjs";
22
- import { samePasswordCredentialSnapshot } from "./internal/password-attempts.mjs";
26
+ import { samePasswordCredentialSnapshot } from "./internal/password-credentials.mjs";
23
27
  import { CurrentPasswordSql, PasswordSqlConfiguration, PasswordSqlDatabase, PasswordSqlQuery, makePasswordKernel } from "./internal/password-kernel.mjs";
24
28
  import { CurrentPasswordPreparedTransaction, PasswordPreparedJournalGuards, PasswordPreparedPostcondition, PasswordPreparedPostconditions } from "./internal/PasswordPreparedPostconditions.mjs";
25
29
  import { CurrentPhoneTransaction, makePhoneKernel } from "./internal/phone-kernel.mjs";
26
30
  import { CurrentSessionSql, SessionSqlDatabase, SessionSqlOptions, makeSessionKernel } from "./internal/session-kernel.mjs";
27
- import { StorageTable } from "./internal/storage-tables.mjs";
28
- import { BoundPersistence, ClaimsCodec, Definition, PersistenceApi, PersistenceConfigurationError } from "./internal/configuration.mjs";
29
31
  import { createPersistence } from "./internal/persistence.mjs";
30
32
  import { makeComposedPasskeys } from "./internal/passkeys.mjs";
31
33
  import { makeMappings } from "./internal/storage-mapping.mjs";
32
34
  import { PasswordRegistrationAuthority } from "./internal/registration-contract.mjs";
33
- import { PhysicalStorageTable, StorageValidation, validateStorage, validateStorageBatch, withStorageValidation } from "./internal/storage-validation.mjs";
34
- export { type AnyEmailAddressMapping, type AnyEmailRegistrationMapping, type AnyEmailSignInMapping, type AnyPasswordPersistenceMapping, type AnyPasswordRegistrationMapping, type AnyProofPersistenceMapping, type AuthenticationAuthorityMapping, type BoundPersistence, type ClaimsCodec, type CurrentAddress, CurrentEmailSql, CurrentPasskeyTransaction, CurrentPasswordPreparedTransaction, CurrentPasswordSql, CurrentPhoneTransaction, CurrentProofSql, CurrentSessionSql, type D1AuthenticationAuthorityMapping, type D1EmailAddressMapping, type D1EmailRegistrationMapping, type D1PasskeyMapping, type D1PasswordPersistenceMapping, type D1PendingAuthenticationMapping, type D1ProofPersistenceMapping, type D1SessionClockMapping, type D1SessionStepUpMapping, type D1SignedSessionValidityMapping, type D1StatefulSessionMapping, type Definition, type EmailAddressMapping, type EmailAuthorityCredentialTable, type EmailCommandTable, type EmailCredentialReadTable, type EmailCredentialTable, type EmailD1Clock, type EmailIdentifierReadTable, type EmailIdentifierTable, type EmailRegistrationAuthorityCredentialTable, type EmailRegistrationCredentialTable, type EmailRegistrationIdentifierTable, type EmailRegistrationIntent, type EmailRegistrationMapping, type EmailRegistrationProvisioning, type EmailRegistrationState, type EmailRegistrationTable, type EmailSignInMapping, type EmailSqlConfiguration, type EmailSqlDatabase, type EmailSqlQuery, type EmailSubjectReadTable, type EmailSubjectTable, type GuardedUpdate, NativeDatabase, type NativeSqlTables, type Observation, type PasskeyAdmissionTable, type PasskeyCeremonyMapping, type PasskeyChargeInsert, type PasskeyChargeKind, type PasskeyChargeTable, type PasskeyClock, type PasskeyColumn, type PasskeyCommandTable, type PasskeyCoordinatorError, type PasskeyCredentialInsert, type PasskeyCredentialMapping, type PasskeyCredentialOwnershipTable, type PasskeyCredentialReadTable, type PasskeyCredentialServices, type PasskeyEnrollmentContextMapping, type PasskeyEnrollmentContextServices, type PasskeyExecution, type PasskeyFactorReadTable, type PasskeyFlowInsert, type PasskeyFlowState, type PasskeyFlowTable, type PasskeyHandleOwnershipTable, type PasskeyHandleReadTable, type PasskeyHandleReservationTable, type PasskeyInvalidationInput, type PasskeyInvalidationMutation, type PasskeyKernel, type PasskeyManagementMapping, type PasskeyManagementServices, type PasskeyMappingSource, type PasskeyModuleTable, type PasskeyOwner, type PasskeyPersistenceMapping, type PasskeyPersistenceServices, type PasskeyPolicyGuard, type PasskeyRegistrationCeremonyCapabilities, type PasskeyRegistrationCeremonyMapping, type PasskeyRegistrationCeremonyServices, type PasskeyRegistrationIntentReadTable, type PasskeyRegistrationMapping, type PasskeyRegistrationServices, type PasskeyRegistrationWriter, type PasskeySubjectIdCodec, type PasskeySubjectReadTable, type PasskeyTargetConfiguration, type PasskeyWriteTables, type PasswordAttemptAction, type PasswordAttemptRecord, type PasswordAttemptState, type PasswordAttemptTable, type PasswordAuthorityCredentialTable, type PasswordCommandTable, type PasswordConstraintClassifier, type PasswordCredentialTable, type PasswordD1Clock, type PasswordIdentifierTable, type PasswordPersistenceMapping, PasswordPreparedJournalGuards, type PasswordPreparedPostcondition, PasswordPreparedPostconditions, type PasswordRegistrationAuthority, type PasswordRegistrationConstraintClassifier, type PasswordRegistrationIntent, type PasswordRegistrationMapping, type PasswordRegistrationProvisioning, type PasswordRegistrationState, type PasswordRegistrationTable, type PasswordSqlConfiguration, type PasswordSqlDatabase, type PasswordSqlQuery, type PasswordSubjectTable, type PendingAuthenticationMapping, type PendingAuthenticationTables, type PersistenceApi, PersistenceConfigurationError, PersistenceMappingError, type PhysicalStorageTable, type ProofAbuseEventTable, type ProofAction, type ProofAuthorityInput, type ProofAuthorityTables, type ProofCommandDecision, type ProofCommandKind, type ProofCommandTable, type ProofConstraintClassifier, type ProofContinuationRecord, type ProofContinuationTable, type ProofD1Clock, type ProofDeliveryState, type ProofFailureEventTable, type ProofGenerationState, type ProofGenerationTable, type ProofPersistenceMapping, type ProofRateScopeTable, type ProofRequestTable, type ProofScopeKeys, type ProofScopeKind, type ProofSeriesTable, type ProofSqlConfiguration, type ProofSqlDatabase, type ProofSqlQuery, type QueryFailure, type QueryOperations, type RequiredEmailAddressConstraints, type RequiredEmailRegistrationConstraints, type RequiredEmailSignInConstraints, type RequiredPasswordConstraints, type RequiredPasswordRegistrationConstraints, type RequiredPendingAuthenticationConstraints, type RequiredProofConstraints, type RequiredSessionConstraints, type RequiredSessionStepUpConstraints, type RequiredSignedValidityConstraints, type RequiredStatefulPendingConstraints, type Row, type SessionAuthorityTables, type SessionConstraintClassifier, type SessionFlowTables, type SessionIdCodec, type SessionSqlDatabase, type SessionSqlOptions, type SessionStepUpIntentTables, type SessionStepUpMapping, type SessionStepUpSourceTables, type SessionSubjectTables, type SignedSessionValidityMapping, type SignedSessionValidityTables, type SqlColumn, type SqlExpression, type SqlFragment, type SqlTable, type StatefulSessionMapping, type StatefulSessionTables, type StorageTable, type StorageValidation, type SubjectIdCodec, type TableModel, type TransactionBound, type TransactionCoordinatorError, type TransactionExecution, type TransactionNativeDatabase, type TransactionOwner, type TransactionTargetConfiguration, createPersistence, decodeStepUpIntent, encodeStepUpIntent, isMappedConstraintConflict, makeComposedPasskeys, makeEmailKernel, makeNativeSqlTables, makePasskeyKernel, makePasswordKernel, makePhoneKernel, makeProofKernel, makeSessionKernel, makeMappings as makeStorageMappings, makeTransactionExecutionKernel, makeTransactionKernel, nativeSqlAlias, passkeyCredentialsLayer, passkeyEnrollmentContextLayer, passkeyInvalidationMutation, passkeyPersistenceLayer, passkeyPolicyGuard, requireStandalone, requiredEmailAddressConstraints, requiredEmailRegistrationConstraints, requiredEmailSignInConstraints, requiredPasskeyCredentialConstraints, requiredPasskeyManagementConstraints, requiredPasskeyPersistenceConstraints, requiredPasskeyRegistrationCeremonyConstraints, requiredPasskeyRegistrationWriteConstraints, requiredPasswordConstraints, requiredPasswordRegistrationConstraints, requiredPendingAuthenticationConstraints, requiredProofConstraints, requiredSessionConstraints, requiredSessionStepUpConstraints, requiredSignedValidityConstraints, requiredStatefulPendingConstraints, samePasswordCredentialSnapshot, stepUpIntentLive, validateStepUpPlan, validateStorage, validateStorageBatch, withStorageValidation };
35
+ import { OAuthAccountsMapping, OAuthAction, OAuthAuthorityReadTable, OAuthAuthorityTable, OAuthCleanupDescriptor, OAuthCleanupTable, OAuthClock, OAuthCredentialReadTable, OAuthCredentialTable, OAuthD1Mapping, OAuthEligibilityDescriptor, OAuthEligibilityFact, OAuthEligibilityTable, OAuthFlowState, OAuthFlowTable, OAuthMetadataPolicy, OAuthOwnershipMutation, OAuthOwnershipReadTable, OAuthOwnershipTable, OAuthReferenceGuardDescriptor, OAuthReferenceGuardTable, OAuthRegistrationAuthority, OAuthRegistrationBase, OAuthRegistrationCommandTable, OAuthRegistrationEligibility, OAuthRegistrationGuardDescriptor, OAuthRegistrationGuardTable, OAuthRegistrationIntentMapping, OAuthRegistrationIntentTable, OAuthRegistrationMapping, OAuthRegistrationState, OAuthSignInMapping, OAuthSubjectReadTable, OAuthSubjectTable, OAuthTupleAuthorityTable, OAuthTupleState, OAuthUnlinkCommandTable, oauthCleanupTable, oauthEligibilityTable, oauthReferenceGuardTable, oauthRegistrationGuardTable, requiredOAuthAccountsConstraints, requiredOAuthRegistrationConstraints, requiredOAuthSignInConstraints, requiredOAuthTupleConstraints } from "./internal/models/oauth-model.mjs";
36
+ import { OAuthConnectedAction, OAuthConnectedAdmissionTable, OAuthConnectedAuthorityMapping, OAuthConnectedClientRegistrationTable, OAuthConnectedCohortTable, OAuthConnectedCommandTable, OAuthConnectedFlowTable, OAuthConnectedGrantTable, OAuthConnectedMapping, OAuthConnectedOrderCodec, OAuthConnectedOwnershipRead, OAuthConnectedPolicyGuard, OAuthConnectedPolicyGuardTable, OAuthConnectedPolicyInput, OAuthConnectedRevocationJobTable, OAuthConnectedRevocationMapping, OAuthConnectedSqlPolicy, OAuthConnectedSubjectTable, oauthConnectedPolicyGuard, requiredOAuthConnectedConstraints, requiredOAuthConnectedRevocationConstraints } from "./internal/models/oauth-connected-model.mjs";
37
+ import { OAuthCoordinatorError, OAuthExecution, OAuthTargetConfiguration } from "./internal/oauth/target.mjs";
38
+ import { OAuthKernel, makeOAuthKernel } from "./internal/oauth-kernel.mjs";
39
+ import { storageKeyPlans } from "./internal/storage-plans.mjs";
40
+ export { type AnyEmailAddressMapping, type AnyEmailRegistrationMapping, type AnyEmailSignInMapping, type AnyPasswordPersistenceMapping, type AnyPasswordRegistrationMapping, type AnyProofPersistenceMapping, type AuthenticationAuthorityMapping, type BoundPersistence, type ClaimsCodec, type CurrentAddress, CurrentEmailSql, CurrentPasskeyTransaction, CurrentPasswordPreparedTransaction, CurrentPasswordSql, CurrentPhoneTransaction, CurrentProofSql, CurrentSessionSql, type D1AuthenticationAuthorityMapping, type D1EmailAddressMapping, type D1EmailRegistrationMapping, type D1PasskeyMapping, type D1PasswordPersistenceMapping, type D1PendingAuthenticationMapping, type D1ProofPersistenceMapping, type D1SessionClockMapping, type D1SessionStepUpMapping, type D1SignedSessionValidityMapping, type D1StatefulSessionMapping, type Definition, type EmailAddressMapping, type EmailAuthorityCredentialTable, type EmailCommandTable, type EmailCredentialReadTable, type EmailCredentialTable, type EmailD1Clock, type EmailIdentifierReadTable, type EmailIdentifierTable, type EmailRegistrationAuthorityCredentialTable, type EmailRegistrationCredentialTable, type EmailRegistrationIdentifierTable, type EmailRegistrationIntent, type EmailRegistrationMapping, type EmailRegistrationProvisioning, type EmailRegistrationState, type EmailRegistrationTable, type EmailSignInMapping, type EmailSqlConfiguration, type EmailSqlDatabase, type EmailSqlQuery, type EmailSubjectReadTable, type EmailSubjectTable, type GuardedUpdate, NativeDatabase, type NativeSqlTables, type OAuthAccountsMapping, type OAuthAction, type OAuthAuthorityReadTable, type OAuthAuthorityTable, type OAuthCleanupDescriptor, type OAuthCleanupTable, type OAuthClock, type OAuthConnectedAction, type OAuthConnectedAdmissionTable, type OAuthConnectedAuthorityMapping, type OAuthConnectedClientRegistrationTable, type OAuthConnectedCohortTable, type OAuthConnectedCommandTable, type OAuthConnectedFlowTable, type OAuthConnectedGrantTable, type OAuthConnectedMapping, type OAuthConnectedOrderCodec, type OAuthConnectedOwnershipRead, type OAuthConnectedPolicyGuard, type OAuthConnectedPolicyGuardTable, type OAuthConnectedPolicyInput, type OAuthConnectedRevocationJobTable, type OAuthConnectedRevocationMapping, type OAuthConnectedSqlPolicy, type OAuthConnectedSubjectTable, type OAuthCoordinatorError, type OAuthCredentialReadTable, type OAuthCredentialTable, type OAuthD1Mapping, type OAuthEligibilityDescriptor, type OAuthEligibilityFact, type OAuthEligibilityTable, type OAuthExecution, type OAuthFlowState, type OAuthFlowTable, type OAuthKernel, type OAuthMetadataPolicy, type OAuthOwnershipMutation, type OAuthOwnershipReadTable, type OAuthOwnershipTable, type OAuthProxySqlTable, type OAuthReferenceGuardDescriptor, type OAuthReferenceGuardTable, type OAuthRegistrationAuthority, type OAuthRegistrationBase, type OAuthRegistrationCommandTable, type OAuthRegistrationEligibility, type OAuthRegistrationGuardDescriptor, type OAuthRegistrationGuardTable, type OAuthRegistrationIntentMapping, type OAuthRegistrationIntentTable, type OAuthRegistrationMapping, type OAuthRegistrationState, type OAuthSignInMapping, type OAuthSubjectReadTable, type OAuthSubjectTable, type OAuthTargetConfiguration, type OAuthTupleAuthorityTable, type OAuthTupleState, type OAuthUnlinkCommandTable, type Observation, type PasskeyAdmissionTable, type PasskeyCeremonyMapping, type PasskeyChargeInsert, type PasskeyChargeKind, type PasskeyChargeTable, type PasskeyClock, type PasskeyColumn, type PasskeyCommandTable, type PasskeyCoordinatorError, type PasskeyCredentialInsert, type PasskeyCredentialMapping, type PasskeyCredentialOwnershipTable, type PasskeyCredentialReadTable, type PasskeyCredentialServices, type PasskeyEnrollmentContextMapping, type PasskeyEnrollmentContextServices, type PasskeyExecution, type PasskeyFactorReadTable, type PasskeyFlowInsert, type PasskeyFlowState, type PasskeyFlowTable, type PasskeyHandleOwnershipTable, type PasskeyHandleReadTable, type PasskeyHandleReservationTable, type PasskeyInvalidationInput, type PasskeyInvalidationMutation, type PasskeyKernel, type PasskeyManagementMapping, type PasskeyManagementServices, type PasskeyMappingSource, type PasskeyModuleTable, type PasskeyOwner, type PasskeyPersistenceMapping, type PasskeyPersistenceServices, type PasskeyPolicyGuard, type PasskeyRegistrationCeremonyCapabilities, type PasskeyRegistrationCeremonyMapping, type PasskeyRegistrationCeremonyServices, type PasskeyRegistrationIntentReadTable, type PasskeyRegistrationMapping, type PasskeyRegistrationServices, type PasskeyRegistrationWriter, type PasskeySubjectIdCodec, type PasskeySubjectReadTable, type PasskeyTargetConfiguration, type PasskeyWriteTables, type PasswordAuthorityCredentialTable, type PasswordCommandTable, type PasswordConstraintClassifier, type PasswordCredentialTable, type PasswordD1Clock, type PasswordIdentifierTable, type PasswordPersistenceMapping, PasswordPreparedJournalGuards, type PasswordPreparedPostcondition, PasswordPreparedPostconditions, type PasswordRegistrationAuthority, type PasswordRegistrationConstraintClassifier, type PasswordRegistrationIntent, type PasswordRegistrationMapping, type PasswordRegistrationProvisioning, type PasswordRegistrationState, type PasswordRegistrationTable, type PasswordSqlConfiguration, type PasswordSqlDatabase, type PasswordSqlQuery, type PasswordSubjectTable, type PendingAuthenticationMapping, type PendingAuthenticationTables, type PersistenceApi, PersistenceConfigurationError, PersistenceMappingError, type PhysicalStorageTable, type ProofAbuseEventTable, type ProofAction, type ProofAuthorityInput, type ProofAuthorityTables, type ProofCommandDecision, type ProofCommandKind, type ProofCommandTable, type ProofConstraintClassifier, type ProofContinuationRecord, type ProofContinuationTable, type ProofD1Clock, type ProofDeliveryState, type ProofFailureEventTable, type ProofGenerationState, type ProofGenerationTable, type ProofPersistenceMapping, type ProofRateScopeTable, type ProofRequestTable, type ProofScopeKeys, type ProofScopeKind, type ProofSeriesTable, type ProofSqlConfiguration, type ProofSqlDatabase, type ProofSqlQuery, type QueryFailure, type QueryOperations, type RequiredEmailAddressConstraints, type RequiredEmailRegistrationConstraints, type RequiredEmailSignInConstraints, type RequiredPasswordConstraints, type RequiredPasswordRegistrationConstraints, type RequiredPendingAuthenticationConstraints, type RequiredProofConstraints, type RequiredSessionConstraints, type RequiredSessionStepUpConstraints, type RequiredSignedValidityConstraints, type RequiredStatefulPendingConstraints, type Row, type SessionAuthorityTables, type SessionConstraintClassifier, type SessionFlowTables, type SessionIdCodec, type SessionSqlDatabase, type SessionSqlOptions, type SessionStepUpIntentTables, type SessionStepUpMapping, type SessionStepUpSourceTables, type SessionSubjectTables, type SignedSessionValidityMapping, type SignedSessionValidityTables, type SqlColumn, type SqlExpression, type SqlFragment, type SqlTable, type StatefulSessionMapping, type StatefulSessionTables, type StorageTable, type StorageValidation, type SubjectIdCodec, type TableModel, type TransactionBound, type TransactionCoordinatorError, type TransactionExecution, type TransactionNativeDatabase, type TransactionOwner, type TransactionTargetConfiguration, createPersistence, decodeStepUpIntent, encodeStepUpIntent, isMappedConstraintConflict, makeComposedPasskeys, makeEmailKernel, makeNativeSqlTables, makeOAuthKernel, makeOAuthProxyPersistence, makePasskeyKernel, makePasswordKernel, makePhoneKernel, makeProofKernel, makeSessionKernel, makeMappings as makeStorageMappings, makeTransactionExecutionKernel, makeTransactionKernel, nativeSqlAlias, oauthCleanupTable, oauthConnectedPolicyGuard, oauthEligibilityTable, oauthProxyColumns, oauthReferenceGuardTable, oauthRegistrationGuardTable, passkeyCredentialsLayer, passkeyEnrollmentContextLayer, passkeyInvalidationMutation, passkeyPersistenceLayer, passkeyPolicyGuard, requireStandalone, requiredEmailAddressConstraints, requiredEmailRegistrationConstraints, requiredEmailSignInConstraints, requiredOAuthAccountsConstraints, requiredOAuthConnectedConstraints, requiredOAuthConnectedRevocationConstraints, requiredOAuthRegistrationConstraints, requiredOAuthSignInConstraints, requiredOAuthTupleConstraints, requiredPasskeyCredentialConstraints, requiredPasskeyManagementConstraints, requiredPasskeyPersistenceConstraints, requiredPasskeyRegistrationCeremonyConstraints, requiredPasskeyRegistrationWriteConstraints, requiredPasswordConstraints, requiredPasswordRegistrationConstraints, requiredPendingAuthenticationConstraints, requiredProofConstraints, requiredSessionConstraints, requiredSessionStepUpConstraints, requiredSignedValidityConstraints, requiredStatefulPendingConstraints, samePasswordCredentialSnapshot, stepUpIntentLive, storageKeyPlans, validateStepUpPlan, validateStorage, validateStorageBatch, withStorageValidation };
package/dist/Adapter.mjs CHANGED
@@ -16,14 +16,19 @@ import { makeComposedPasskeys } from "./internal/passkeys.mjs";
16
16
  import { requiredEmailAddressConstraints, requiredEmailRegistrationConstraints, requiredEmailSignInConstraints } from "./internal/models/email-model.mjs";
17
17
  import { CurrentEmailSql, makeEmailKernel } from "./internal/email-kernel.mjs";
18
18
  import { requiredPasswordConstraints, requiredPasswordRegistrationConstraints } from "./internal/models/password-model.mjs";
19
- import { samePasswordCredentialSnapshot } from "./internal/password-attempts.mjs";
19
+ import { samePasswordCredentialSnapshot } from "./internal/password-credentials.mjs";
20
20
  import { CurrentPasswordSql, makePasswordKernel } from "./internal/password-kernel.mjs";
21
21
  import { CurrentPhoneTransaction, makePhoneKernel } from "./internal/phone-kernel.mjs";
22
22
  import { decodeStepUpIntent, encodeStepUpIntent, stepUpIntentLive, validateStepUpPlan } from "./internal/step-up-state.mjs";
23
+ import { validateStorage, validateStorageBatch, withStorageValidation } from "./internal/storage-validation.mjs";
23
24
  import { CurrentSessionSql, makeSessionKernel } from "./internal/session-kernel.mjs";
24
25
  import { makeMappings } from "./internal/storage-mapping.mjs";
25
- import { validateStorage, validateStorageBatch, withStorageValidation } from "./internal/storage-validation.mjs";
26
26
  import { createPersistence } from "./internal/persistence.mjs";
27
+ import { makeOAuthProxyPersistence, oauthProxyColumns } from "./internal/oauth-proxy.mjs";
28
+ import { oauthCleanupTable, oauthEligibilityTable, oauthReferenceGuardTable, oauthRegistrationGuardTable, requiredOAuthAccountsConstraints, requiredOAuthRegistrationConstraints, requiredOAuthSignInConstraints, requiredOAuthTupleConstraints } from "./internal/models/oauth-model.mjs";
29
+ import { makeOAuthKernel } from "./internal/oauth-kernel.mjs";
30
+ import { storageKeyPlans } from "./internal/storage-plans.mjs";
31
+ import { oauthConnectedPolicyGuard, requiredOAuthConnectedConstraints, requiredOAuthConnectedRevocationConstraints } from "./internal/models/oauth-connected-model.mjs";
27
32
  import { requiredPendingAuthenticationConstraints, requiredSessionConstraints, requiredSignedValidityConstraints, requiredStatefulPendingConstraints } from "./internal/models/session-model.mjs";
28
33
  import { requiredSessionStepUpConstraints } from "./internal/models/step-up-model.mjs";
29
- export { CurrentEmailSql, CurrentPasskeyTransaction, CurrentPasswordPreparedTransaction, CurrentPasswordSql, CurrentPhoneTransaction, CurrentProofSql, CurrentSessionSql, NativeDatabase, PasswordPreparedJournalGuards, PasswordPreparedPostconditions, PersistenceConfigurationError, PersistenceMappingError, createPersistence, decodeStepUpIntent, encodeStepUpIntent, isMappedConstraintConflict, makeComposedPasskeys, makeEmailKernel, makeNativeSqlTables, makePasskeyKernel, makePasswordKernel, makePhoneKernel, makeProofKernel, makeSessionKernel, makeMappings as makeStorageMappings, makeTransactionExecutionKernel, makeTransactionKernel, nativeSqlAlias, passkeyCredentialsLayer, passkeyEnrollmentContextLayer, passkeyInvalidationMutation, passkeyPersistenceLayer, passkeyPolicyGuard, requireStandalone, requiredEmailAddressConstraints, requiredEmailRegistrationConstraints, requiredEmailSignInConstraints, requiredPasskeyCredentialConstraints, requiredPasskeyManagementConstraints, requiredPasskeyPersistenceConstraints, requiredPasskeyRegistrationCeremonyConstraints, requiredPasskeyRegistrationWriteConstraints, requiredPasswordConstraints, requiredPasswordRegistrationConstraints, requiredPendingAuthenticationConstraints, requiredProofConstraints, requiredSessionConstraints, requiredSessionStepUpConstraints, requiredSignedValidityConstraints, requiredStatefulPendingConstraints, samePasswordCredentialSnapshot, stepUpIntentLive, validateStepUpPlan, validateStorage, validateStorageBatch, withStorageValidation };
34
+ export { CurrentEmailSql, CurrentPasskeyTransaction, CurrentPasswordPreparedTransaction, CurrentPasswordSql, CurrentPhoneTransaction, CurrentProofSql, CurrentSessionSql, NativeDatabase, PasswordPreparedJournalGuards, PasswordPreparedPostconditions, PersistenceConfigurationError, PersistenceMappingError, createPersistence, decodeStepUpIntent, encodeStepUpIntent, isMappedConstraintConflict, makeComposedPasskeys, makeEmailKernel, makeNativeSqlTables, makeOAuthKernel, makeOAuthProxyPersistence, makePasskeyKernel, makePasswordKernel, makePhoneKernel, makeProofKernel, makeSessionKernel, makeMappings as makeStorageMappings, makeTransactionExecutionKernel, makeTransactionKernel, nativeSqlAlias, oauthCleanupTable, oauthConnectedPolicyGuard, oauthEligibilityTable, oauthProxyColumns, oauthReferenceGuardTable, oauthRegistrationGuardTable, passkeyCredentialsLayer, passkeyEnrollmentContextLayer, passkeyInvalidationMutation, passkeyPersistenceLayer, passkeyPolicyGuard, requireStandalone, requiredEmailAddressConstraints, requiredEmailRegistrationConstraints, requiredEmailSignInConstraints, requiredOAuthAccountsConstraints, requiredOAuthConnectedConstraints, requiredOAuthConnectedRevocationConstraints, requiredOAuthRegistrationConstraints, requiredOAuthSignInConstraints, requiredOAuthTupleConstraints, requiredPasskeyCredentialConstraints, requiredPasskeyManagementConstraints, requiredPasskeyPersistenceConstraints, requiredPasskeyRegistrationCeremonyConstraints, requiredPasskeyRegistrationWriteConstraints, requiredPasswordConstraints, requiredPasswordRegistrationConstraints, requiredPendingAuthenticationConstraints, requiredProofConstraints, requiredSessionConstraints, requiredSessionStepUpConstraints, requiredSignedValidityConstraints, requiredStatefulPendingConstraints, samePasswordCredentialSnapshot, stepUpIntentLive, storageKeyPlans, validateStepUpPlan, validateStorage, validateStorageBatch, withStorageValidation };
@@ -0,0 +1,87 @@
1
+ import { AuthenticationAuthorityMapping } from "./internal/models/session-model.mjs";
2
+ import { StorageTable } from "./internal/storage-tables.mjs";
3
+ import { PersistenceConfigurationError } from "./internal/configuration.mjs";
4
+ import { OAuthAction, OAuthD1Mapping, OAuthEligibilityFact, OAuthFlowState, OAuthRegistrationAuthority, OAuthRegistrationState, OAuthTupleState, requiredOAuthAccountsConstraints, requiredOAuthRegistrationConstraints, requiredOAuthSignInConstraints, requiredOAuthTupleConstraints } from "./internal/models/oauth-model.mjs";
5
+ import { OAuthConnectedAction, OAuthConnectedOrderCodec, OAuthConnectedPolicyInput, requiredOAuthConnectedConstraints, requiredOAuthConnectedRevocationConstraints } from "./internal/models/oauth-connected-model.mjs";
6
+ import { OAuthCoordinatorError, oauthAccountsPersistenceLayer as oauthAccountsPersistenceLayer$1, oauthRegistrationAuthorityLayer as oauthRegistrationAuthorityLayer$1, oauthRegistrationIntentsLayer as oauthRegistrationIntentsLayer$1, oauthSignInPersistenceLayer as oauthSignInPersistenceLayer$1 } from "./internal/oauth/target.mjs";
7
+ import { Fragment, Table } from "./internal/sql-table.mjs";
8
+ import { OAuthAccountsMapping, OAuthAuthorityReadTable, OAuthAuthorityTable, OAuthCleanupDescriptor, OAuthCleanupTable, OAuthClock, OAuthCredentialReadTable, OAuthCredentialTable, OAuthEligibilityDescriptor, OAuthEligibilityTable, OAuthFlowTable, OAuthMetadataPolicy, OAuthOwnershipMutation, OAuthOwnershipReadTable, OAuthOwnershipTable, OAuthReferenceGuardDescriptor, OAuthReferenceGuardTable, OAuthRegistrationBase, OAuthRegistrationCommandTable, OAuthRegistrationEligibility, OAuthRegistrationGuardDescriptor, OAuthRegistrationGuardTable, OAuthRegistrationIntentMapping, OAuthRegistrationIntentTable, OAuthRegistrationMapping, OAuthSignInMapping, OAuthSubjectReadTable, OAuthSubjectTable, OAuthTupleAuthorityTable, OAuthUnlinkCommandTable, SqlTableModel, oauthCleanupTable, oauthEligibilityTable, oauthReferenceGuardTable, oauthRegistrationGuardTable } from "./internal/sql-oauth-model.mjs";
9
+ import { oauthConnectedPersistenceLayer as oauthConnectedPersistenceLayer$1, oauthConnectedRevocationsLayer as oauthConnectedRevocationsLayer$1 } from "./internal/oauth/connected-target.mjs";
10
+ import { OAuthConnectedAdmissionTable, OAuthConnectedAuthorityMapping, OAuthConnectedClientRegistrationTable, OAuthConnectedCohortTable, OAuthConnectedCommandTable, OAuthConnectedFlowTable, OAuthConnectedGrantTable, OAuthConnectedMapping, OAuthConnectedOwnershipRead, OAuthConnectedPolicyGuard, OAuthConnectedPolicyGuardTable, OAuthConnectedRevocationJobTable, OAuthConnectedRevocationMapping, OAuthConnectedSqlPolicy, OAuthConnectedSubjectTable, oauthConnectedPolicyGuard } from "./internal/sql-oauth-connected-model.mjs";
11
+ import { and, eq, sql } from "./internal/sql-query.mjs";
12
+ import { Context, Crypto, Effect } from "effect";
13
+ import { SqlClient } from "effect/sql";
14
+ import { LifecycleHooks } from "@yielded/auth/Hooks";
15
+ import { AuthenticationAuthority, SessionUnavailable } from "@yielded/auth/Sessions";
16
+ import { OAuthAccountsPersistence, OAuthConnectedPersistence, OAuthConnectedRevocations, OAuthRegistrationIntents, OAuthSignInPersistence, OAuthUnavailable } from "@yielded/auth/OAuth";
17
+ declare namespace OAuthPersistence_d_exports {
18
+ export { OAuthAccountsMapping, OAuthAction, OAuthAuthorityReadTable, OAuthAuthorityTable, OAuthCleanupDescriptor, OAuthCleanupTable, OAuthClock, OAuthConnectedAction, OAuthConnectedAdmissionTable, OAuthConnectedAuthorityMapping, OAuthConnectedClientRegistrationTable, OAuthConnectedCohortTable, OAuthConnectedCommandTable, OAuthConnectedFlowTable, OAuthConnectedGrantTable, OAuthConnectedMapping, OAuthConnectedOrderCodec, OAuthConnectedOwnershipRead, OAuthConnectedPolicyGuard, OAuthConnectedPolicyGuardTable, OAuthConnectedPolicyInput, OAuthConnectedRevocationJobTable, OAuthConnectedRevocationMapping, OAuthConnectedSqlPolicy, OAuthConnectedSubjectTable, OAuthCredentialReadTable, OAuthCredentialTable, OAuthD1Mapping, OAuthEligibilityDescriptor, OAuthEligibilityFact, OAuthEligibilityTable, OAuthFlowState, OAuthFlowTable, OAuthMetadataPolicy, OAuthOwnershipMutation, OAuthOwnershipReadTable, OAuthOwnershipTable, OAuthReferenceGuardDescriptor, OAuthReferenceGuardTable, OAuthRegistrationAuthority, OAuthRegistrationBase, OAuthRegistrationCommandTable, OAuthRegistrationEligibility, OAuthRegistrationGuardDescriptor, OAuthRegistrationGuardTable, OAuthRegistrationIntentMapping, OAuthRegistrationIntentTable, OAuthRegistrationMapping, OAuthRegistrationState, OAuthSignInMapping, OAuthSubjectReadTable, OAuthSubjectTable, OAuthTupleAuthorityTable, OAuthTupleState, OAuthUnlinkCommandTable, SqlTableModel, and, clock, coordinateOAuthAccounts, coordinateOAuthConnected, coordinateOAuthConnectedRevocations, coordinateOAuthRegistration, coordinateOAuthRegistrationIntents, coordinateOAuthSignIn, eq, makeAuthenticationAuthorityServices, makeOAuthAccountsServices, makeOAuthConnectedRevocationServices, makeOAuthConnectedServices, makeOAuthRegistrationIntentServices, makeOAuthRegistrationServices, makeOAuthSignInServices, oauthAccountsPersistenceLayer, oauthCleanupTable, oauthConnectedOwnershipReferences, oauthConnectedPersistenceLayer, oauthConnectedPolicyGuard, oauthConnectedRevocationsLayer, oauthEligibilityTable, oauthReferenceGuardTable, oauthRegistrationAuthorityLayer, oauthRegistrationGuardTable, oauthRegistrationIntentsLayer, oauthSignInPersistenceLayer, requiredOAuthAccountsConstraints, requiredOAuthConnectedConstraints, requiredOAuthConnectedRevocationConstraints, requiredOAuthRegistrationConstraints, requiredOAuthSignInConstraints, requiredOAuthTupleConstraints, sql, table };
19
+ }
20
+ /** Physical identifiers and representations only; applications own migrations. */
21
+ export declare const table: (definition: StorageTable) => Table;
22
+ /** Integer-millisecond engine clock, sampled after locks on either supported dialect. */
23
+ export declare const clock: {
24
+ encodeInstant: (input: number, options?: import("effect/SchemaAST").ParseOptions) => number;
25
+ decodeInstant: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => number;
26
+ engineNowMillis: Fragment;
27
+ };
28
+ export declare const makeOAuthSignInServices: <N>(mapping: OAuthSignInMapping<Table, Table, Table, Table, Table, N>) => Effect.Effect<{
29
+ readonly oauthSignInPersistence: OAuthSignInPersistence["Service"];
30
+ }, OAuthUnavailable | PersistenceConfigurationError, Crypto.Crypto | LifecycleHooks | SqlClient.SqlClient>;
31
+ /** Run auth and application SQL in one adapter-owned transaction and commit journal. */
32
+ export declare const coordinateOAuthSignIn: <N, A, E, R>(options: {
33
+ readonly mapping: OAuthSignInMapping<Table, Table, Table, Table, Table, N>;
34
+ }, body: Effect.Effect<A, E, R>) => Effect.Effect<A, OAuthCoordinatorError<E> | PersistenceConfigurationError, Exclude<R, OAuthSignInPersistence> | Crypto.Crypto | LifecycleHooks | SqlClient.SqlClient>;
35
+ export declare const makeOAuthRegistrationIntentServices: <N>(mapping: OAuthRegistrationIntentMapping<Table, Table, Table, Table, Table, Table, Table, N>) => Effect.Effect<{
36
+ readonly oauthRegistrationIntents: OAuthRegistrationIntents["Service"];
37
+ }, OAuthUnavailable | PersistenceConfigurationError, Crypto.Crypto | LifecycleHooks | SqlClient.SqlClient>;
38
+ /** Run auth and application SQL in one adapter-owned transaction and commit journal. */
39
+ export declare const coordinateOAuthRegistrationIntents: <N, A, E, R>(options: {
40
+ readonly mapping: OAuthRegistrationIntentMapping<Table, Table, Table, Table, Table, Table, Table, N>;
41
+ }, body: Effect.Effect<A, E, R>) => Effect.Effect<A, OAuthCoordinatorError<E> | PersistenceConfigurationError, Exclude<R, OAuthRegistrationIntents> | Crypto.Crypto | LifecycleHooks | SqlClient.SqlClient>;
42
+ export declare const makeOAuthAccountsServices: <N>(mapping: OAuthAccountsMapping<Table, Table, Table, Table, Table, Table, Table, N>) => Effect.Effect<{
43
+ readonly oauthAccountsPersistence: OAuthAccountsPersistence["Service"];
44
+ }, OAuthUnavailable | PersistenceConfigurationError, Crypto.Crypto | LifecycleHooks | SqlClient.SqlClient>;
45
+ /** Run auth and application SQL in one adapter-owned transaction and commit journal. */
46
+ export declare const coordinateOAuthAccounts: <N, A, E, R>(options: {
47
+ readonly mapping: OAuthAccountsMapping<Table, Table, Table, Table, Table, Table, Table, N>;
48
+ }, body: Effect.Effect<A, E, R>) => Effect.Effect<A, OAuthCoordinatorError<E> | PersistenceConfigurationError, Exclude<R, OAuthAccountsPersistence> | Crypto.Crypto | LifecycleHooks | SqlClient.SqlClient>;
49
+ export declare const makeOAuthConnectedServices: <N>(mapping: OAuthConnectedMapping<Table, Table, Table, Table, Table, Table, Table, Table, Table, Table, N, Table>) => Effect.Effect<{
50
+ readonly oauthConnectedPersistence: OAuthConnectedPersistence["Service"];
51
+ }, OAuthUnavailable | PersistenceConfigurationError, Crypto.Crypto | LifecycleHooks | SqlClient.SqlClient>;
52
+ /** Run auth and application SQL in one adapter-owned transaction and commit journal. */
53
+ export declare const coordinateOAuthConnected: <N, A, E, R>(options: {
54
+ readonly mapping: OAuthConnectedMapping<Table, Table, Table, Table, Table, Table, Table, Table, Table, Table, N, Table>;
55
+ }, body: Effect.Effect<A, E, R>) => Effect.Effect<A, OAuthCoordinatorError<E> | PersistenceConfigurationError, Exclude<R, OAuthConnectedPersistence> | Crypto.Crypto | LifecycleHooks | SqlClient.SqlClient>;
56
+ export declare const makeOAuthConnectedRevocationServices: <N>(mapping: OAuthConnectedRevocationMapping<Table, Table, Table, Table, Table, Table, Table, N>) => Effect.Effect<{
57
+ readonly oauthConnectedRevocations: OAuthConnectedRevocations["Service"];
58
+ }, OAuthUnavailable | PersistenceConfigurationError, Crypto.Crypto | LifecycleHooks | SqlClient.SqlClient>;
59
+ /** Run auth and application SQL in one adapter-owned transaction and commit journal. */
60
+ export declare const coordinateOAuthConnectedRevocations: <N, A, E, R>(options: {
61
+ readonly mapping: OAuthConnectedRevocationMapping<Table, Table, Table, Table, Table, Table, Table, N>;
62
+ }, body: Effect.Effect<A, E, R>) => Effect.Effect<A, OAuthCoordinatorError<E> | PersistenceConfigurationError, Exclude<R, OAuthConnectedRevocations> | Crypto.Crypto | LifecycleHooks | SqlClient.SqlClient>;
63
+ export declare const makeOAuthRegistrationServices: <Registration, N>(mapping: OAuthRegistrationMapping<Registration, Table, Table, Table, Table, Table, Table, Table, N>) => Effect.Effect<{
64
+ readonly registrationAuthority: OAuthRegistrationAuthority<Registration>;
65
+ }, OAuthUnavailable | PersistenceConfigurationError, Crypto.Crypto | LifecycleHooks | SqlClient.SqlClient>;
66
+ export declare const coordinateOAuthRegistration: <Id, Registration, N, A, E, R>(options: {
67
+ readonly mapping: OAuthRegistrationMapping<NoInfer<Registration>, Table, Table, Table, Table, Table, Table, Table, N>;
68
+ readonly target: Context.Key<Id, OAuthRegistrationAuthority<Registration>>;
69
+ }, body: Effect.Effect<A, E, R>) => Effect.Effect<A, OAuthCoordinatorError<E> | PersistenceConfigurationError, Exclude<R, Id> | Crypto.Crypto | LifecycleHooks | SqlClient.SqlClient>;
70
+ /** Include these guards when login ownership may also hold retained grants. */
71
+ export declare const oauthConnectedOwnershipReferences: <N>(mapping: OAuthConnectedMapping<Table, Table, Table, Table, Table, Table, Table, Table, Table, Table, N, Table>, dialect: "pg" | "sqlite") => {
72
+ readonly connectedReferenceGuards: ReadonlyArray<OAuthReferenceGuardDescriptor<N>>;
73
+ readonly connectedReference: (input: {
74
+ readonly identityKey: string;
75
+ readonly subjectId: N;
76
+ }) => Fragment;
77
+ };
78
+ export declare const oauthAccountsPersistenceLayer: typeof oauthAccountsPersistenceLayer$1, oauthSignInPersistenceLayer: typeof oauthSignInPersistenceLayer$1, oauthRegistrationIntentsLayer: typeof oauthRegistrationIntentsLayer$1, oauthRegistrationAuthorityLayer: typeof oauthRegistrationAuthorityLayer$1;
79
+ export declare const oauthConnectedPersistenceLayer: typeof oauthConnectedPersistenceLayer$1, oauthConnectedRevocationsLayer: typeof oauthConnectedRevocationsLayer$1;
80
+ /** Shared session issuance must validate the same subject and credential authority
81
+ * as OAuth. Supply this service when it is not already provided by session storage. */
82
+ export declare const makeAuthenticationAuthorityServices: <Claims, N>(mapping: AuthenticationAuthorityMapping<Claims, SqlTableModel, SqlTableModel, SqlTableModel, SqlTableModel, N>) => Effect.Effect<{
83
+ readonly authenticationAuthority: AuthenticationAuthority["Service"];
84
+ }, SessionUnavailable | PersistenceConfigurationError, LifecycleHooks | SqlClient.SqlClient>;
85
+ //#endregion
86
+ export { OAuthAccountsMapping, type OAuthAction, OAuthAuthorityReadTable, OAuthAuthorityTable, OAuthCleanupDescriptor, OAuthCleanupTable, OAuthClock, type OAuthConnectedAction, OAuthConnectedAdmissionTable, OAuthConnectedAuthorityMapping, OAuthConnectedClientRegistrationTable, OAuthConnectedCohortTable, OAuthConnectedCommandTable, OAuthConnectedFlowTable, OAuthConnectedGrantTable, OAuthConnectedMapping, type OAuthConnectedOrderCodec, OAuthConnectedOwnershipRead, OAuthConnectedPolicyGuard, OAuthConnectedPolicyGuardTable, type OAuthConnectedPolicyInput, OAuthConnectedRevocationJobTable, OAuthConnectedRevocationMapping, OAuthConnectedSqlPolicy, OAuthConnectedSubjectTable, OAuthCredentialReadTable, OAuthCredentialTable, type OAuthD1Mapping, OAuthEligibilityDescriptor, type OAuthEligibilityFact, OAuthEligibilityTable, type OAuthFlowState, OAuthFlowTable, OAuthMetadataPolicy, OAuthOwnershipMutation, OAuthOwnershipReadTable, OAuthOwnershipTable, OAuthPersistence_d_exports, OAuthReferenceGuardDescriptor, OAuthReferenceGuardTable, type OAuthRegistrationAuthority, OAuthRegistrationBase, OAuthRegistrationCommandTable, OAuthRegistrationEligibility, OAuthRegistrationGuardDescriptor, OAuthRegistrationGuardTable, OAuthRegistrationIntentMapping, OAuthRegistrationIntentTable, OAuthRegistrationMapping, type OAuthRegistrationState, OAuthSignInMapping, OAuthSubjectReadTable, OAuthSubjectTable, OAuthTupleAuthorityTable, type OAuthTupleState, OAuthUnlinkCommandTable, SqlTableModel, and, eq, oauthCleanupTable, oauthConnectedPolicyGuard, oauthEligibilityTable, oauthReferenceGuardTable, oauthRegistrationGuardTable, requiredOAuthAccountsConstraints, requiredOAuthConnectedConstraints, requiredOAuthConnectedRevocationConstraints, requiredOAuthRegistrationConstraints, requiredOAuthSignInConstraints, requiredOAuthTupleConstraints, sql };
87
+ //# sourceMappingURL=OAuthPersistence.d.mts.map
@@ -0,0 +1,125 @@
1
+ import { __exportAll } from "./_virtual/_rolldown/runtime.mjs";
2
+ import { PersistenceConfigurationError } from "./internal/configuration.mjs";
3
+ import { Fragment, Table } from "./internal/sql-table.mjs";
4
+ import { makeNativeSqlTables } from "./internal/native-sql-table.mjs";
5
+ import { requireStandalone } from "./internal/standalone.mjs";
6
+ import { NativeDatabase } from "./internal/transaction-kernel.mjs";
7
+ import { CurrentSessionSql, makeSessionKernel } from "./internal/session-kernel.mjs";
8
+ import { and, eq, makeSqlDatabase, sql, sqlQueryOperations } from "./internal/sql-query.mjs";
9
+ import { requiredOAuthAccountsConstraints, requiredOAuthRegistrationConstraints, requiredOAuthSignInConstraints, requiredOAuthTupleConstraints } from "./internal/models/oauth-model.mjs";
10
+ import { makeOAuthKernel } from "./internal/oauth-kernel.mjs";
11
+ import { validateSqlStorage } from "./internal/sql-storage-validation.mjs";
12
+ import { oauthCleanupTable, oauthEligibilityTable, oauthReferenceGuardTable, oauthRegistrationGuardTable } from "./internal/sql-oauth-model.mjs";
13
+ import { requiredOAuthConnectedConstraints, requiredOAuthConnectedRevocationConstraints } from "./internal/models/oauth-connected-model.mjs";
14
+ import { oauthConnectedPolicyGuard } from "./internal/sql-oauth-connected-model.mjs";
15
+ import { Effect, Predicate, Schema } from "effect";
16
+ import { SqlClient } from "effect/sql";
17
+ import { SessionUnavailable } from "@yielded/auth/Sessions";
18
+ import { OAuthAccountsPersistence, OAuthConnectedPersistence, OAuthConnectedRevocations, OAuthRegistrationIntents, OAuthSignInPersistence, OAuthUnavailable } from "@yielded/auth/OAuth";
19
+ //#region src/OAuthPersistence.ts
20
+ var OAuthPersistence_exports = /* @__PURE__ */ __exportAll({
21
+ and: () => and,
22
+ clock: () => clock,
23
+ coordinateOAuthAccounts: () => coordinateOAuthAccounts,
24
+ coordinateOAuthConnected: () => coordinateOAuthConnected,
25
+ coordinateOAuthConnectedRevocations: () => coordinateOAuthConnectedRevocations,
26
+ coordinateOAuthRegistration: () => coordinateOAuthRegistration,
27
+ coordinateOAuthRegistrationIntents: () => coordinateOAuthRegistrationIntents,
28
+ coordinateOAuthSignIn: () => coordinateOAuthSignIn,
29
+ eq: () => eq,
30
+ makeAuthenticationAuthorityServices: () => makeAuthenticationAuthorityServices,
31
+ makeOAuthAccountsServices: () => makeOAuthAccountsServices,
32
+ makeOAuthConnectedRevocationServices: () => makeOAuthConnectedRevocationServices,
33
+ makeOAuthConnectedServices: () => makeOAuthConnectedServices,
34
+ makeOAuthRegistrationIntentServices: () => makeOAuthRegistrationIntentServices,
35
+ makeOAuthRegistrationServices: () => makeOAuthRegistrationServices,
36
+ makeOAuthSignInServices: () => makeOAuthSignInServices,
37
+ oauthAccountsPersistenceLayer: () => oauthAccountsPersistenceLayer,
38
+ oauthCleanupTable: () => oauthCleanupTable,
39
+ oauthConnectedOwnershipReferences: () => oauthConnectedOwnershipReferences,
40
+ oauthConnectedPersistenceLayer: () => oauthConnectedPersistenceLayer,
41
+ oauthConnectedPolicyGuard: () => oauthConnectedPolicyGuard,
42
+ oauthConnectedRevocationsLayer: () => oauthConnectedRevocationsLayer,
43
+ oauthEligibilityTable: () => oauthEligibilityTable,
44
+ oauthReferenceGuardTable: () => oauthReferenceGuardTable,
45
+ oauthRegistrationAuthorityLayer: () => oauthRegistrationAuthorityLayer,
46
+ oauthRegistrationGuardTable: () => oauthRegistrationGuardTable,
47
+ oauthRegistrationIntentsLayer: () => oauthRegistrationIntentsLayer,
48
+ oauthSignInPersistenceLayer: () => oauthSignInPersistenceLayer,
49
+ requiredOAuthAccountsConstraints: () => requiredOAuthAccountsConstraints,
50
+ requiredOAuthConnectedConstraints: () => requiredOAuthConnectedConstraints,
51
+ requiredOAuthConnectedRevocationConstraints: () => requiredOAuthConnectedRevocationConstraints,
52
+ requiredOAuthRegistrationConstraints: () => requiredOAuthRegistrationConstraints,
53
+ requiredOAuthSignInConstraints: () => requiredOAuthSignInConstraints,
54
+ requiredOAuthTupleConstraints: () => requiredOAuthTupleConstraints,
55
+ sql: () => sql,
56
+ table: () => table
57
+ });
58
+ /** Physical identifiers and representations only; applications own migrations. */
59
+ const table = (definition) => new Table(definition.name, definition.columns, definition.unique, definition.schema);
60
+ /** Integer-millisecond engine clock, sampled after locks on either supported dialect. */
61
+ const clock = {
62
+ encodeInstant: Schema.encodeSync(Schema.Int),
63
+ decodeInstant: Schema.decodeUnknownSync(Schema.Int),
64
+ engineNowMillis: new Fragment((compiler) => compiler.dialect === "pg" ? "cast(extract(epoch from clock_timestamp()) * 1000 as bigint)" : "cast(round((julianday('now') - 2440587.5) * 86400000) as integer)")
65
+ };
66
+ const operations = {
67
+ ...sqlQueryOperations,
68
+ validateStorage: validateSqlStorage
69
+ };
70
+ const kernels = {
71
+ pg: makeOAuthKernel(operations, () => "pg"),
72
+ sqlite: makeOAuthKernel(operations, () => "sqlite")
73
+ };
74
+ const acquire = Effect.gen(function* () {
75
+ const client = yield* SqlClient.SqlClient;
76
+ const dialect = client.onDialectOrElse({
77
+ pg: () => "pg",
78
+ sqlite: () => "sqlite",
79
+ orElse: () => void 0
80
+ });
81
+ if (dialect === void 0 || Predicate.hasProperty(client, "~@effect/sql-d1/D1Client")) return yield* PersistenceConfigurationError.make({ reason: "OAuth persistence requires PostgreSQL or SQLite with interactive transactions" });
82
+ return {
83
+ database: yield* makeSqlDatabase(dialect),
84
+ configuration: {
85
+ mode: "interactive",
86
+ dialect,
87
+ locking: dialect === "pg",
88
+ standaloneGuard: (service) => requireStandalone(() => OAuthUnavailable.make({}), service)
89
+ },
90
+ kernel: kernels[dialect]
91
+ };
92
+ });
93
+ const using = (body) => Effect.flatMap(acquire, (input) => body(input).pipe(Effect.provideService(NativeDatabase, input.database)));
94
+ const makeOAuthSignInServices = (mapping) => using(({ kernel, configuration }) => kernel.target.makeTargetOAuthSignInServices(mapping, configuration));
95
+ /** Run auth and application SQL in one adapter-owned transaction and commit journal. */
96
+ const coordinateOAuthSignIn = (options, body) => using(({ kernel, configuration, database }) => kernel.target.coordinateTargetOAuthSignIn(database, options.mapping, configuration, (_transaction, services) => Effect.provideService(body, OAuthSignInPersistence, services.oauthSignInPersistence)));
97
+ const makeOAuthRegistrationIntentServices = (mapping) => using(({ kernel, configuration }) => kernel.target.makeTargetOAuthRegistrationIntentServices(mapping, configuration));
98
+ /** Run auth and application SQL in one adapter-owned transaction and commit journal. */
99
+ const coordinateOAuthRegistrationIntents = (options, body) => using(({ kernel, configuration, database }) => kernel.target.coordinateTargetOAuthRegistrationIntents(database, options.mapping, configuration, (_transaction, services) => Effect.provideService(body, OAuthRegistrationIntents, services.oauthRegistrationIntents)));
100
+ const makeOAuthAccountsServices = (mapping) => using(({ kernel, configuration }) => kernel.target.makeTargetOAuthAccountsServices(mapping, configuration));
101
+ /** Run auth and application SQL in one adapter-owned transaction and commit journal. */
102
+ const coordinateOAuthAccounts = (options, body) => using(({ kernel, configuration, database }) => kernel.target.coordinateTargetOAuthAccounts(database, options.mapping, configuration, (_transaction, services) => Effect.provideService(body, OAuthAccountsPersistence, services.oauthAccountsPersistence)));
103
+ const makeOAuthConnectedServices = (mapping) => using(({ kernel, configuration }) => kernel.connectedTarget.makeTargetOAuthConnectedServices(mapping, configuration));
104
+ /** Run auth and application SQL in one adapter-owned transaction and commit journal. */
105
+ const coordinateOAuthConnected = (options, body) => using(({ kernel, configuration, database }) => kernel.connectedTarget.coordinateTargetOAuthConnected(database, options.mapping, configuration, (_transaction, services) => Effect.provideService(body, OAuthConnectedPersistence, services.oauthConnectedPersistence)));
106
+ const makeOAuthConnectedRevocationServices = (mapping) => using(({ kernel, configuration }) => kernel.connectedTarget.makeTargetOAuthConnectedRevocationServices(mapping, configuration));
107
+ /** Run auth and application SQL in one adapter-owned transaction and commit journal. */
108
+ const coordinateOAuthConnectedRevocations = (options, body) => using(({ kernel, configuration, database }) => kernel.connectedTarget.coordinateTargetOAuthConnectedRevocations(database, options.mapping, configuration, (_transaction, services) => Effect.provideService(body, OAuthConnectedRevocations, services.oauthConnectedRevocations)));
109
+ const makeOAuthRegistrationServices = (mapping) => using(({ kernel, configuration }) => kernel.target.makeTargetOAuthRegistrationServices(mapping, configuration));
110
+ const coordinateOAuthRegistration = (options, body) => using(({ kernel, configuration, database }) => kernel.target.coordinateTargetOAuthRegistration(database, options.mapping, configuration, (_transaction, services) => Effect.provideService(body, options.target, services.registrationAuthority)));
111
+ /** Include these guards when login ownership may also hold retained grants. */
112
+ const oauthConnectedOwnershipReferences = (mapping, dialect) => kernels[dialect].connectedReference.oauthConnectedOwnershipReferences(mapping);
113
+ const { oauthAccountsPersistenceLayer, oauthSignInPersistenceLayer, oauthRegistrationIntentsLayer, oauthRegistrationAuthorityLayer } = kernels.sqlite.target;
114
+ const { oauthConnectedPersistenceLayer, oauthConnectedRevocationsLayer } = kernels.sqlite.connectedTarget;
115
+ /** Shared session issuance must validate the same subject and credential authority
116
+ * as OAuth. Supply this service when it is not already provided by session storage. */
117
+ const makeAuthenticationAuthorityServices = (mapping) => using(({ database, configuration }) => makeSessionKernel(operations, (client) => makeNativeSqlTables(client)).makeSqlAuthenticationAuthority(mapping, {
118
+ mode: "interactive",
119
+ locking: configuration.locking,
120
+ standaloneGuard: requireStandalone(() => SessionUnavailable.make({}), database.$client.transactionService)
121
+ }).pipe(Effect.provideService(CurrentSessionSql, database), Effect.map((authenticationAuthority) => ({ authenticationAuthority }))));
122
+ //#endregion
123
+ export { OAuthPersistence_exports, and, clock, coordinateOAuthAccounts, coordinateOAuthConnected, coordinateOAuthConnectedRevocations, coordinateOAuthRegistration, coordinateOAuthRegistrationIntents, coordinateOAuthSignIn, eq, makeAuthenticationAuthorityServices, makeOAuthAccountsServices, makeOAuthConnectedRevocationServices, makeOAuthConnectedServices, makeOAuthRegistrationIntentServices, makeOAuthRegistrationServices, makeOAuthSignInServices, oauthAccountsPersistenceLayer, oauthCleanupTable, oauthConnectedOwnershipReferences, oauthConnectedPersistenceLayer, oauthConnectedPolicyGuard, oauthConnectedRevocationsLayer, oauthEligibilityTable, oauthReferenceGuardTable, oauthRegistrationAuthorityLayer, oauthRegistrationGuardTable, oauthRegistrationIntentsLayer, oauthSignInPersistenceLayer, requiredOAuthAccountsConstraints, requiredOAuthConnectedConstraints, requiredOAuthConnectedRevocationConstraints, requiredOAuthRegistrationConstraints, requiredOAuthSignInConstraints, requiredOAuthTupleConstraints, sql, table };
124
+
125
+ //# sourceMappingURL=OAuthPersistence.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OAuthPersistence.mjs","names":[],"sources":["../src/OAuthPersistence.ts"],"sourcesContent":["/** Direct Effect SQL persistence for upstream OAuth accounts. PostgreSQL and SQLite\n * require interactive transactions; provider exchanges occur outside coordinators. */\nimport type { LifecycleHooks } from \"@yielded/auth/Hooks\";\nimport {\n OAuthAccountsPersistence,\n OAuthSignInPersistence,\n OAuthRegistrationIntents,\n OAuthConnectedPersistence,\n OAuthConnectedRevocations,\n OAuthUnavailable,\n} from \"@yielded/auth/OAuth\";\nimport type { AuthenticationAuthority } from \"@yielded/auth/Sessions\";\nimport { SessionUnavailable } from \"@yielded/auth/Sessions\";\nimport { type Context, type Crypto, Effect, Predicate, Schema } from \"effect\";\nimport { SqlClient } from \"effect/sql\";\n\nimport { PersistenceConfigurationError } from \"./internal/configuration\";\nimport type { AuthenticationAuthorityMapping as AuthorityMapping } from \"./internal/models/session-model\";\nimport { makeNativeSqlTables } from \"./internal/native-sql-table\";\nimport { makeOAuthKernel } from \"./internal/oauth-kernel\";\nimport type { OAuthCoordinatorError, OAuthTargetConfiguration } from \"./internal/oauth/target\";\nimport {\n CurrentSessionSql,\n makeSessionKernel,\n type SessionSqlDatabase,\n} from \"./internal/session-kernel\";\nimport type {\n OAuthConnectedMapping,\n OAuthConnectedRevocationMapping,\n} from \"./internal/sql-oauth-connected-model\";\nimport type {\n SqlTableModel,\n OAuthAccountsMapping,\n OAuthSignInMapping,\n OAuthRegistrationIntentMapping,\n OAuthRegistrationMapping,\n OAuthRegistrationAuthority,\n OAuthReferenceGuardDescriptor,\n} from \"./internal/sql-oauth-model\";\nimport { makeSqlDatabase, sqlQueryOperations, sql } from \"./internal/sql-query\";\nimport { validateSqlStorage } from \"./internal/sql-storage-validation\";\nimport { Table, Fragment } from \"./internal/sql-table\";\nimport { requireStandalone } from \"./internal/standalone\";\nimport type { StorageTable } from \"./internal/storage-tables\";\nimport { NativeDatabase } from \"./internal/transaction-kernel\";\nimport type { TransactionNativeDatabase } from \"./internal/transaction-kernel\";\nexport * from \"./internal/sql-oauth-model\";\nexport * from \"./internal/sql-oauth-connected-model\";\nexport { sql };\nexport { and, eq } from \"./internal/sql-query\";\n\n/** Physical identifiers and representations only; applications own migrations. */\nexport const table = (definition: StorageTable) =>\n new Table(definition.name, definition.columns, definition.unique, definition.schema);\n\n/** Integer-millisecond engine clock, sampled after locks on either supported dialect. */\nexport const clock = {\n encodeInstant: Schema.encodeSync(Schema.Int),\n decodeInstant: Schema.decodeUnknownSync(Schema.Int),\n engineNowMillis: new Fragment((compiler) =>\n compiler.dialect === \"pg\"\n ? \"cast(extract(epoch from clock_timestamp()) * 1000 as bigint)\"\n : \"cast(round((julianday('now') - 2440587.5) * 86400000) as integer)\",\n ),\n};\n\nconst operations = { ...sqlQueryOperations, validateStorage: validateSqlStorage };\n\nconst kernels = {\n pg: makeOAuthKernel(operations, () => \"pg\"),\n sqlite: makeOAuthKernel(operations, () => \"sqlite\"),\n};\n\nconst acquire = Effect.gen(function* () {\n const client = yield* SqlClient.SqlClient;\n\n const dialect = client.onDialectOrElse({\n pg: () => \"pg\" as const,\n sqlite: () => \"sqlite\" as const,\n orElse: () => undefined,\n });\n\n // D1 exposes the SQLite compiler but its public driver brand identifies a\n // batch-only client. Keep the default package free of a D1 runtime dependency.\n if (dialect === undefined || Predicate.hasProperty(client, \"~@effect/sql-d1/D1Client\"))\n return yield* PersistenceConfigurationError.make({\n reason: \"OAuth persistence requires PostgreSQL or SQLite with interactive transactions\",\n });\n\n const database = yield* makeSqlDatabase(dialect);\n\n const configuration: OAuthTargetConfiguration = {\n mode: \"interactive\",\n dialect,\n locking: dialect === \"pg\",\n standaloneGuard: (service) => requireStandalone(() => OAuthUnavailable.make({}), service),\n };\n\n // Erase only the query-builder handle; batch methods are never selected by this adapter.\n return {\n database: database as unknown as TransactionNativeDatabase,\n configuration,\n kernel: kernels[dialect],\n };\n});\n\nconst using = <A, E, R>(body: (input: Effect.Success<typeof acquire>) => Effect.Effect<A, E, R>) =>\n Effect.flatMap(acquire, (input) =>\n body(input).pipe(Effect.provideService(NativeDatabase, input.database)),\n );\n\nexport const makeOAuthSignInServices = <N>(\n mapping: OAuthSignInMapping<Table, Table, Table, Table, Table, N>,\n): Effect.Effect<\n { readonly oauthSignInPersistence: OAuthSignInPersistence[\"Service\"] },\n OAuthUnavailable | PersistenceConfigurationError,\n Crypto.Crypto | LifecycleHooks | SqlClient.SqlClient\n> =>\n using(({ kernel, configuration }) =>\n kernel.target.makeTargetOAuthSignInServices(mapping, configuration),\n );\n\n/** Run auth and application SQL in one adapter-owned transaction and commit journal. */\nexport const coordinateOAuthSignIn = <N, A, E, R>(\n options: { readonly mapping: OAuthSignInMapping<Table, Table, Table, Table, Table, N> },\n body: Effect.Effect<A, E, R>,\n): Effect.Effect<\n A,\n OAuthCoordinatorError<E> | PersistenceConfigurationError,\n Exclude<R, OAuthSignInPersistence> | Crypto.Crypto | LifecycleHooks | SqlClient.SqlClient\n> =>\n using(({ kernel, configuration, database }) =>\n kernel.target.coordinateTargetOAuthSignIn(\n database,\n options.mapping,\n configuration,\n (_transaction, services) =>\n Effect.provideService(body, OAuthSignInPersistence, services.oauthSignInPersistence),\n ),\n );\n\nexport const makeOAuthRegistrationIntentServices = <N>(\n mapping: OAuthRegistrationIntentMapping<Table, Table, Table, Table, Table, Table, Table, N>,\n): Effect.Effect<\n { readonly oauthRegistrationIntents: OAuthRegistrationIntents[\"Service\"] },\n OAuthUnavailable | PersistenceConfigurationError,\n Crypto.Crypto | LifecycleHooks | SqlClient.SqlClient\n> =>\n using(({ kernel, configuration }) =>\n kernel.target.makeTargetOAuthRegistrationIntentServices(mapping, configuration),\n );\n\n/** Run auth and application SQL in one adapter-owned transaction and commit journal. */\nexport const coordinateOAuthRegistrationIntents = <N, A, E, R>(\n options: {\n readonly mapping: OAuthRegistrationIntentMapping<\n Table,\n Table,\n Table,\n Table,\n Table,\n Table,\n Table,\n N\n >;\n },\n body: Effect.Effect<A, E, R>,\n): Effect.Effect<\n A,\n OAuthCoordinatorError<E> | PersistenceConfigurationError,\n Exclude<R, OAuthRegistrationIntents> | Crypto.Crypto | LifecycleHooks | SqlClient.SqlClient\n> =>\n using(({ kernel, configuration, database }) =>\n kernel.target.coordinateTargetOAuthRegistrationIntents(\n database,\n options.mapping,\n configuration,\n (_transaction, services) =>\n Effect.provideService(body, OAuthRegistrationIntents, services.oauthRegistrationIntents),\n ),\n );\n\nexport const makeOAuthAccountsServices = <N>(\n mapping: OAuthAccountsMapping<Table, Table, Table, Table, Table, Table, Table, N>,\n): Effect.Effect<\n { readonly oauthAccountsPersistence: OAuthAccountsPersistence[\"Service\"] },\n OAuthUnavailable | PersistenceConfigurationError,\n Crypto.Crypto | LifecycleHooks | SqlClient.SqlClient\n> =>\n using(({ kernel, configuration }) =>\n kernel.target.makeTargetOAuthAccountsServices(mapping, configuration),\n );\n\n/** Run auth and application SQL in one adapter-owned transaction and commit journal. */\nexport const coordinateOAuthAccounts = <N, A, E, R>(\n options: {\n readonly mapping: OAuthAccountsMapping<Table, Table, Table, Table, Table, Table, Table, N>;\n },\n body: Effect.Effect<A, E, R>,\n): Effect.Effect<\n A,\n OAuthCoordinatorError<E> | PersistenceConfigurationError,\n Exclude<R, OAuthAccountsPersistence> | Crypto.Crypto | LifecycleHooks | SqlClient.SqlClient\n> =>\n using(({ kernel, configuration, database }) =>\n kernel.target.coordinateTargetOAuthAccounts(\n database,\n options.mapping,\n configuration,\n (_transaction, services) =>\n Effect.provideService(body, OAuthAccountsPersistence, services.oauthAccountsPersistence),\n ),\n );\n\nexport const makeOAuthConnectedServices = <N>(\n mapping: OAuthConnectedMapping<\n Table,\n Table,\n Table,\n Table,\n Table,\n Table,\n Table,\n Table,\n Table,\n Table,\n N,\n Table\n >,\n): Effect.Effect<\n { readonly oauthConnectedPersistence: OAuthConnectedPersistence[\"Service\"] },\n OAuthUnavailable | PersistenceConfigurationError,\n Crypto.Crypto | LifecycleHooks | SqlClient.SqlClient\n> =>\n using(({ kernel, configuration }) =>\n kernel.connectedTarget.makeTargetOAuthConnectedServices(mapping, configuration),\n );\n\n/** Run auth and application SQL in one adapter-owned transaction and commit journal. */\nexport const coordinateOAuthConnected = <N, A, E, R>(\n options: {\n readonly mapping: OAuthConnectedMapping<\n Table,\n Table,\n Table,\n Table,\n Table,\n Table,\n Table,\n Table,\n Table,\n Table,\n N,\n Table\n >;\n },\n body: Effect.Effect<A, E, R>,\n): Effect.Effect<\n A,\n OAuthCoordinatorError<E> | PersistenceConfigurationError,\n Exclude<R, OAuthConnectedPersistence> | Crypto.Crypto | LifecycleHooks | SqlClient.SqlClient\n> =>\n using(({ kernel, configuration, database }) =>\n kernel.connectedTarget.coordinateTargetOAuthConnected(\n database,\n options.mapping,\n configuration,\n (_transaction, services) =>\n Effect.provideService(body, OAuthConnectedPersistence, services.oauthConnectedPersistence),\n ),\n );\n\nexport const makeOAuthConnectedRevocationServices = <N>(\n mapping: OAuthConnectedRevocationMapping<Table, Table, Table, Table, Table, Table, Table, N>,\n): Effect.Effect<\n { readonly oauthConnectedRevocations: OAuthConnectedRevocations[\"Service\"] },\n OAuthUnavailable | PersistenceConfigurationError,\n Crypto.Crypto | LifecycleHooks | SqlClient.SqlClient\n> =>\n using(({ kernel, configuration }) =>\n kernel.connectedTarget.makeTargetOAuthConnectedRevocationServices(mapping, configuration),\n );\n\n/** Run auth and application SQL in one adapter-owned transaction and commit journal. */\nexport const coordinateOAuthConnectedRevocations = <N, A, E, R>(\n options: {\n readonly mapping: OAuthConnectedRevocationMapping<\n Table,\n Table,\n Table,\n Table,\n Table,\n Table,\n Table,\n N\n >;\n },\n body: Effect.Effect<A, E, R>,\n): Effect.Effect<\n A,\n OAuthCoordinatorError<E> | PersistenceConfigurationError,\n Exclude<R, OAuthConnectedRevocations> | Crypto.Crypto | LifecycleHooks | SqlClient.SqlClient\n> =>\n using(({ kernel, configuration, database }) =>\n kernel.connectedTarget.coordinateTargetOAuthConnectedRevocations(\n database,\n options.mapping,\n configuration,\n (_transaction, services) =>\n Effect.provideService(body, OAuthConnectedRevocations, services.oauthConnectedRevocations),\n ),\n );\n\nexport const makeOAuthRegistrationServices = <Registration, N>(\n mapping: OAuthRegistrationMapping<\n Registration,\n Table,\n Table,\n Table,\n Table,\n Table,\n Table,\n Table,\n N\n >,\n): Effect.Effect<\n { readonly registrationAuthority: OAuthRegistrationAuthority<Registration> },\n OAuthUnavailable | PersistenceConfigurationError,\n Crypto.Crypto | LifecycleHooks | SqlClient.SqlClient\n> =>\n using(({ kernel, configuration }) =>\n kernel.target.makeTargetOAuthRegistrationServices<Registration>(mapping, configuration),\n );\n\nexport const coordinateOAuthRegistration = <Id, Registration, N, A, E, R>(\n options: {\n readonly mapping: OAuthRegistrationMapping<\n NoInfer<Registration>,\n Table,\n Table,\n Table,\n Table,\n Table,\n Table,\n Table,\n N\n >;\n readonly target: Context.Key<Id, OAuthRegistrationAuthority<Registration>>;\n },\n body: Effect.Effect<A, E, R>,\n): Effect.Effect<\n A,\n OAuthCoordinatorError<E> | PersistenceConfigurationError,\n Exclude<R, Id> | Crypto.Crypto | LifecycleHooks | SqlClient.SqlClient\n> =>\n using(({ kernel, configuration, database }) =>\n kernel.target.coordinateTargetOAuthRegistration<Registration, unknown, A, E, Exclude<R, Id>>(\n database,\n options.mapping,\n configuration,\n (_transaction, services) =>\n Effect.provideService(body, options.target, services.registrationAuthority),\n ),\n );\n\n/** Include these guards when login ownership may also hold retained grants. */\nexport const oauthConnectedOwnershipReferences = <N>(\n mapping: OAuthConnectedMapping<\n Table,\n Table,\n Table,\n Table,\n Table,\n Table,\n Table,\n Table,\n Table,\n Table,\n N,\n Table\n >,\n dialect: \"pg\" | \"sqlite\",\n) =>\n // The selected compiler supplies Fragment handles; domain values retain their codecs.\n kernels[dialect].connectedReference.oauthConnectedOwnershipReferences(mapping) as {\n readonly connectedReferenceGuards: ReadonlyArray<OAuthReferenceGuardDescriptor<N>>;\n readonly connectedReference: (input: {\n readonly identityKey: string;\n readonly subjectId: N;\n }) => Fragment;\n };\n\nexport const {\n oauthAccountsPersistenceLayer,\n oauthSignInPersistenceLayer,\n oauthRegistrationIntentsLayer,\n oauthRegistrationAuthorityLayer,\n} = kernels.sqlite.target;\n\nexport const { oauthConnectedPersistenceLayer, oauthConnectedRevocationsLayer } =\n kernels.sqlite.connectedTarget;\n\n/** Shared session issuance must validate the same subject and credential authority\n * as OAuth. Supply this service when it is not already provided by session storage. */\nexport const makeAuthenticationAuthorityServices = <Claims, N>(\n mapping: AuthorityMapping<Claims, SqlTableModel, SqlTableModel, SqlTableModel, SqlTableModel, N>,\n): Effect.Effect<\n { readonly authenticationAuthority: AuthenticationAuthority[\"Service\"] },\n SessionUnavailable | PersistenceConfigurationError,\n LifecycleHooks | SqlClient.SqlClient\n> =>\n using(({ database, configuration }) =>\n makeSessionKernel(operations, (client) => makeNativeSqlTables(client))\n .makeSqlAuthenticationAuthority(mapping, {\n mode: \"interactive\",\n locking: configuration.locking,\n standaloneGuard: requireStandalone(\n () => SessionUnavailable.make({}),\n database.$client.transactionService,\n ),\n })\n .pipe(\n // Both kernels capture the same raw SQL query-builder handle and client.\n Effect.provideService(CurrentSessionSql, database as unknown as SessionSqlDatabase),\n Effect.map((authenticationAuthority) => ({ authenticationAuthority })),\n ),\n );\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDA,MAAa,SAAS,eACpB,IAAI,MAAM,WAAW,MAAM,WAAW,SAAS,WAAW,QAAQ,WAAW,MAAM;;AAGrF,MAAa,QAAQ;CACnB,eAAe,OAAO,WAAW,OAAO,GAAG;CAC3C,eAAe,OAAO,kBAAkB,OAAO,GAAG;CAClD,iBAAiB,IAAI,UAAU,aAC7B,SAAS,YAAY,OACjB,iEACA,mEACN;AACF;AAEA,MAAM,aAAa;CAAE,GAAG;CAAoB,iBAAiB;AAAmB;AAEhF,MAAM,UAAU;CACd,IAAI,gBAAgB,kBAAkB,IAAI;CAC1C,QAAQ,gBAAgB,kBAAkB,QAAQ;AACpD;AAEA,MAAM,UAAU,OAAO,IAAI,aAAa;CACtC,MAAM,SAAS,OAAO,UAAU;CAEhC,MAAM,UAAU,OAAO,gBAAgB;EACrC,UAAU;EACV,cAAc;EACd,cAAc,KAAA;CAChB,CAAC;CAID,IAAI,YAAY,KAAA,KAAa,UAAU,YAAY,QAAQ,0BAA0B,GACnF,OAAO,OAAO,8BAA8B,KAAK,EAC/C,QAAQ,gFACV,CAAC;CAYH,OAAO;EACL,UAAU,OAXY,gBAAgB,OAAO;EAY7C,eAAA;GATA,MAAM;GACN;GACA,SAAS,YAAY;GACrB,kBAAkB,YAAY,wBAAwB,iBAAiB,KAAK,CAAC,CAAC,GAAG,OAAO;EAM5E;EACZ,QAAQ,QAAQ;CAClB;AACF,CAAC;AAED,MAAM,SAAkB,SACtB,OAAO,QAAQ,UAAU,UACvB,KAAK,KAAK,CAAC,CAAC,KAAK,OAAO,eAAe,gBAAgB,MAAM,QAAQ,CAAC,CACxE;AAEF,MAAa,2BACX,YAMA,OAAO,EAAE,QAAQ,oBACf,OAAO,OAAO,8BAA8B,SAAS,aAAa,CACpE;;AAGF,MAAa,yBACX,SACA,SAMA,OAAO,EAAE,QAAQ,eAAe,eAC9B,OAAO,OAAO,4BACZ,UACA,QAAQ,SACR,gBACC,cAAc,aACb,OAAO,eAAe,MAAM,wBAAwB,SAAS,sBAAsB,CACvF,CACF;AAEF,MAAa,uCACX,YAMA,OAAO,EAAE,QAAQ,oBACf,OAAO,OAAO,0CAA0C,SAAS,aAAa,CAChF;;AAGF,MAAa,sCACX,SAYA,SAMA,OAAO,EAAE,QAAQ,eAAe,eAC9B,OAAO,OAAO,yCACZ,UACA,QAAQ,SACR,gBACC,cAAc,aACb,OAAO,eAAe,MAAM,0BAA0B,SAAS,wBAAwB,CAC3F,CACF;AAEF,MAAa,6BACX,YAMA,OAAO,EAAE,QAAQ,oBACf,OAAO,OAAO,gCAAgC,SAAS,aAAa,CACtE;;AAGF,MAAa,2BACX,SAGA,SAMA,OAAO,EAAE,QAAQ,eAAe,eAC9B,OAAO,OAAO,8BACZ,UACA,QAAQ,SACR,gBACC,cAAc,aACb,OAAO,eAAe,MAAM,0BAA0B,SAAS,wBAAwB,CAC3F,CACF;AAEF,MAAa,8BACX,YAmBA,OAAO,EAAE,QAAQ,oBACf,OAAO,gBAAgB,iCAAiC,SAAS,aAAa,CAChF;;AAGF,MAAa,4BACX,SAgBA,SAMA,OAAO,EAAE,QAAQ,eAAe,eAC9B,OAAO,gBAAgB,+BACrB,UACA,QAAQ,SACR,gBACC,cAAc,aACb,OAAO,eAAe,MAAM,2BAA2B,SAAS,yBAAyB,CAC7F,CACF;AAEF,MAAa,wCACX,YAMA,OAAO,EAAE,QAAQ,oBACf,OAAO,gBAAgB,2CAA2C,SAAS,aAAa,CAC1F;;AAGF,MAAa,uCACX,SAYA,SAMA,OAAO,EAAE,QAAQ,eAAe,eAC9B,OAAO,gBAAgB,0CACrB,UACA,QAAQ,SACR,gBACC,cAAc,aACb,OAAO,eAAe,MAAM,2BAA2B,SAAS,yBAAyB,CAC7F,CACF;AAEF,MAAa,iCACX,YAgBA,OAAO,EAAE,QAAQ,oBACf,OAAO,OAAO,oCAAkD,SAAS,aAAa,CACxF;AAEF,MAAa,+BACX,SAcA,SAMA,OAAO,EAAE,QAAQ,eAAe,eAC9B,OAAO,OAAO,kCACZ,UACA,QAAQ,SACR,gBACC,cAAc,aACb,OAAO,eAAe,MAAM,QAAQ,QAAQ,SAAS,qBAAqB,CAC9E,CACF;;AAGF,MAAa,qCACX,SAcA,YAGA,QAAQ,QAAQ,CAAC,mBAAmB,kCAAkC,OAAO;AAQ/E,MAAa,EACX,+BACA,6BACA,+BACA,oCACE,QAAQ,OAAO;AAEnB,MAAa,EAAE,gCAAgC,mCAC7C,QAAQ,OAAO;;;AAIjB,MAAa,uCACX,YAMA,OAAO,EAAE,UAAU,oBACjB,kBAAkB,aAAa,WAAW,oBAAoB,MAAM,CAAC,CAAC,CACnE,+BAA+B,SAAS;CACvC,MAAM;CACN,SAAS,cAAc;CACvB,iBAAiB,wBACT,mBAAmB,KAAK,CAAC,CAAC,GAChC,SAAS,QAAQ,kBACnB;AACF,CAAC,CAAC,CACD,KAEC,OAAO,eAAe,mBAAmB,QAAyC,GAClF,OAAO,KAAK,6BAA6B,EAAE,wBAAwB,EAAE,CACvE,CACJ"}
@@ -0,0 +1,13 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __defProp = Object.defineProperty;
3
+ var __exportAll = (all, no_symbols) => {
4
+ let target = {};
5
+ for (var name in all) __defProp(target, name, {
6
+ get: all[name],
7
+ enumerable: true
8
+ });
9
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
10
+ return target;
11
+ };
12
+ //#endregion
13
+ export { __exportAll };
package/dist/index.d.mts CHANGED
@@ -1,7 +1,9 @@
1
1
  import { PersistenceMappingError } from "./internal/mapping-error.mjs";
2
+ import { OAuthProxyPersistence } from "./internal/oauth-proxy.mjs";
2
3
  import { StorageColumn, StorageTable } from "./internal/storage-tables.mjs";
3
4
  import { PersistenceConfigurationError } from "./internal/configuration.mjs";
5
+ import { OAuthPersistence_d_exports } from "./OAuthPersistence.mjs";
4
6
  import { AuthPersistence } from "./internal/sql-persistence.mjs";
5
7
  import { OAuthServerPersistence } from "./internal/oauth-server.mjs";
6
8
  import { BrowserLoginPersistence } from "./internal/browser-login.mjs";
7
- export { AuthPersistence, BrowserLoginPersistence, OAuthServerPersistence, PersistenceConfigurationError, PersistenceMappingError, StorageColumn, StorageTable };
9
+ export { AuthPersistence, BrowserLoginPersistence, OAuthPersistence_d_exports as OAuthPersistence, OAuthProxyPersistence, OAuthServerPersistence, PersistenceConfigurationError, PersistenceMappingError, StorageColumn, StorageTable };
package/dist/index.mjs CHANGED
@@ -3,5 +3,7 @@ import { PersistenceMappingError } from "./internal/mapping-error.mjs";
3
3
  import { StorageColumn, StorageTable } from "./internal/storage-tables.mjs";
4
4
  import { AuthPersistence } from "./internal/sql-persistence.mjs";
5
5
  import { OAuthServerPersistence } from "./internal/oauth-server.mjs";
6
+ import { OAuthProxyPersistence } from "./internal/oauth-proxy.mjs";
6
7
  import { BrowserLoginPersistence } from "./internal/browser-login.mjs";
7
- export { AuthPersistence, BrowserLoginPersistence, OAuthServerPersistence, PersistenceConfigurationError, PersistenceMappingError, StorageColumn, StorageTable };
8
+ import { OAuthPersistence_exports } from "./OAuthPersistence.mjs";
9
+ export { AuthPersistence, BrowserLoginPersistence, OAuthPersistence_exports as OAuthPersistence, OAuthProxyPersistence, OAuthServerPersistence, PersistenceConfigurationError, PersistenceMappingError, StorageColumn, StorageTable };
@@ -98,7 +98,7 @@ type UsesProofs<A extends {
98
98
  readonly strategies: Readonly<Record<string, Strategy>>;
99
99
  }> = Enabled<A, "phone"> | Enabled<A, "email"> | ManagedPassword<A>;
100
100
  export type Ports<C extends ClaimsCodec, Id extends string, A extends Definition<C, Id>> = AuthenticationAuthority | KeyId<A["sessions"]["StatefulSessionPersistence"]> | KeyId<A["sessions"]["SessionRepository"]> | (Enabled<A, "password"> extends never ? never : PasswordPersistence) | KeyId<RegistrationKey<ManagedPassword<A>>> | (Enabled<A, "passkey"> extends never ? never : PasskeyPersistence | PasskeyCredentials) | (ManagedPasskey<A> extends never ? never : PasskeyManagementPersistence | PasskeyEnrollmentContext) | (Enabled<A, "email"> extends never ? never : EmailAddressPersistence) | (UsesProofs<A> extends never ? never : ProofPersistence) | (Enabled<A, "phone"> extends never ? never : PhoneAdmission | PhoneSignInTargets);
101
- export type Roles<C extends ClaimsCodec, Id extends string, A extends Definition<C, Id>> = "identifiers" | "credentials" | "sessions" | "sessionFlows" | (Enabled<A, "password"> extends never ? never : "passwords" | "passwordAttempts" | "passwordCommands") | (ManagedPassword<A> extends never ? never : "passwordRegistrations") | (Enabled<A, "phone"> extends never ? never : "phoneState") | (Enabled<A, "email"> extends never ? never : "emailCredentials" | "emailCommands") | (Enabled<A, "passkey"> extends never ? never : "passkeyCredentials" | "passkeyOwnership" | "passkeyHandles" | "passkeyModules" | "passkeyFlows" | "passkeyAdmissions" | "passkeyCharges") | (ManagedPasskey<A> extends never ? never : "passkeyCommands") | (UsesProofs<A> extends never ? never : ProofRoles);
101
+ export type Roles<C extends ClaimsCodec, Id extends string, A extends Definition<C, Id>> = "identifiers" | "credentials" | "sessions" | "sessionFlows" | (Enabled<A, "password"> extends never ? never : "passwords" | "passwordCommands") | (ManagedPassword<A> extends never ? never : "passwordRegistrations") | (Enabled<A, "phone"> extends never ? never : "phoneState") | (Enabled<A, "email"> extends never ? never : "emailCredentials" | "emailCommands") | (Enabled<A, "passkey"> extends never ? never : "passkeyCredentials" | "passkeyOwnership" | "passkeyHandles" | "passkeyModules" | "passkeyFlows" | "passkeyAdmissions" | "passkeyCharges") | (ManagedPasskey<A> extends never ? never : "passkeyCommands") | (UsesProofs<A> extends never ? never : ProofRoles);
102
102
  export interface SubjectOptions<T extends object, NativeId> {
103
103
  readonly table: T;
104
104
  readonly id: string;
@@ -1 +1 @@
1
- {"version":3,"file":"configuration.mjs","names":[],"sources":["../../src/internal/configuration.ts"],"sourcesContent":["import type { EmailAction, EmailAddressPersistence } from \"@yielded/auth/Email\";\nimport type { LoginIdentifier } from \"@yielded/auth/Identity\";\nimport type {\n PasskeyActionChallenge,\n PasskeyConfig,\n PasskeyCredentials,\n PasskeyEnrollmentContext,\n PasskeyManagementPersistence,\n PasskeyManagementPolicy,\n PasskeyMethodPolicy,\n PasskeyPersistence,\n PasskeyConfigurationError,\n} from \"@yielded/auth/Passkey\";\nimport type {\n PasswordAction,\n PasswordPersistence,\n PasswordUnavailable,\n} from \"@yielded/auth/Password\";\nimport type { PhoneAdmission, PhoneSignInTargets } from \"@yielded/auth/PhoneOtp\";\nimport type { ProofPersistence } from \"@yielded/auth/Proofs\";\nimport type { SubjectId } from \"@yielded/auth/Schema\";\nimport type {\n AuthenticationAuthority,\n AuthenticationRequirement,\n make as makeSessions,\n} from \"@yielded/auth/Sessions\";\nimport { type Context, type Crypto, type Effect, type Layer, Schema } from \"effect\";\nimport type { SqlClient } from \"effect/sql\";\n\nimport type { PersistenceMappingError } from \"./mapping-error\";\nimport type { StorageRole } from \"./storage-tables\";\n\nexport class PersistenceConfigurationError extends Schema.TaggedError<PersistenceConfigurationError>()(\n \"PersistenceConfigurationError\",\n { reason: Schema.String },\n) {}\n\nexport type ClaimsCodec = Schema.Codec<unknown, unknown, never, never>;\n\nexport interface PasskeyFeature {\n readonly kind: \"passkey\";\n readonly moduleId: string;\n readonly policy: Effect.Effect<PasskeyMethodPolicy, PasskeyConfigurationError, PasskeyConfig>;\n readonly management?: boolean;\n readonly managementPolicy?: PasskeyManagementPolicy;\n}\n\nexport interface Strategy {\n readonly strategy: object;\n readonly persistence?:\n | PasskeyFeature\n | {\n readonly kind: \"password\" | \"phone\" | \"email\";\n readonly moduleId: string;\n readonly lifecycle?: boolean;\n readonly management?: boolean;\n readonly addresses?: boolean;\n };\n readonly RegistrationAuthority?: Context.Key<unknown, unknown>;\n}\n\nexport interface Definition<C extends ClaimsCodec, Id extends string> {\n readonly namespace: string;\n readonly claims: C;\n readonly sessionMode?: string | undefined;\n readonly sessions: ReturnType<typeof makeSessions<C, Id>>;\n readonly strategies: Readonly<Record<string, Strategy>>;\n}\n\ntype KeyId<T> = T extends Context.Key<infer Id, infer _Service> ? Id : never;\ntype Enabled<\n A extends { readonly strategies: Readonly<Record<string, Strategy>> },\n Kind extends \"password\" | \"phone\" | \"email\" | \"passkey\",\n> = Extract<A[\"strategies\"][keyof A[\"strategies\"]], { persistence: { kind: Kind } }>;\n\ntype ManagedPassword<A extends { readonly strategies: Readonly<Record<string, Strategy>> }> =\n Extract<Enabled<A, \"password\">, { persistence: { management: true } }>;\n\ntype ManagedPasskey<A extends { readonly strategies: Readonly<Record<string, Strategy>> }> =\n Extract<Enabled<A, \"passkey\">, { persistence: { management: true } }>;\n\nexport type PasskeyRequirement<\n A extends { readonly strategies: Readonly<Record<string, Strategy>> },\n> = Enabled<A, \"passkey\"> extends never ? never : PasskeyConfig;\n\ntype RegistrationKey<S> = S extends { readonly RegistrationAuthority: infer K } ? K : never;\ntype Registration<S> =\n RegistrationKey<S> extends Context.Key<infer _Id, infer Service>\n ? Service extends { readonly register: (input: infer Input, ...args: never[]) => unknown }\n ? Input extends { readonly registration: infer Value }\n ? Value\n : never\n : never\n : never;\n\nexport interface ProvisioningId<Id extends string> {\n readonly authNamespace: Id;\n readonly service: \"PersistenceProvisioning\";\n}\n\nexport type Provisioning<A extends { readonly strategies: Readonly<Record<string, Strategy>> }> = {\n readonly [\n K in keyof A[\"strategies\"] as A[\"strategies\"][K] extends {\n persistence: { kind: \"password\"; management: true };\n }\n ? K\n : never\n ]: (input: {\n readonly identifier: LoginIdentifier;\n readonly registration: Registration<A[\"strategies\"][K]>;\n }) => Effect.Effect<SubjectId, PasswordUnavailable>;\n};\n\nexport type ProvisioningRequirement<\n A extends { readonly namespace: string; readonly strategies: Readonly<Record<string, Strategy>> },\n> = ManagedPassword<A> extends never ? never : ProvisioningId<A[\"namespace\"]>;\n\ntype ProofRoles =\n | \"proofRequests\"\n | \"proofSeries\"\n | \"proofGenerations\"\n | \"proofContinuations\"\n | \"proofScopes\"\n | \"proofAbuse\"\n | \"proofFailures\"\n | \"proofCommands\";\n\ntype UsesProofs<A extends { readonly strategies: Readonly<Record<string, Strategy>> }> =\n | Enabled<A, \"phone\">\n | Enabled<A, \"email\">\n | ManagedPassword<A>;\n\nexport type Ports<C extends ClaimsCodec, Id extends string, A extends Definition<C, Id>> =\n | AuthenticationAuthority\n | KeyId<A[\"sessions\"][\"StatefulSessionPersistence\"]>\n | KeyId<A[\"sessions\"][\"SessionRepository\"]>\n | (Enabled<A, \"password\"> extends never ? never : PasswordPersistence)\n | KeyId<RegistrationKey<ManagedPassword<A>>>\n | (Enabled<A, \"passkey\"> extends never ? never : PasskeyPersistence | PasskeyCredentials)\n | (ManagedPasskey<A> extends never\n ? never\n : PasskeyManagementPersistence | PasskeyEnrollmentContext)\n | (Enabled<A, \"email\"> extends never ? never : EmailAddressPersistence)\n | (UsesProofs<A> extends never ? never : ProofPersistence)\n | (Enabled<A, \"phone\"> extends never ? never : PhoneAdmission | PhoneSignInTargets);\n\nexport type Roles<C extends ClaimsCodec, Id extends string, A extends Definition<C, Id>> =\n | \"identifiers\"\n | \"credentials\"\n | \"sessions\"\n | \"sessionFlows\"\n | (Enabled<A, \"password\"> extends never\n ? never\n : \"passwords\" | \"passwordAttempts\" | \"passwordCommands\")\n | (ManagedPassword<A> extends never ? never : \"passwordRegistrations\")\n | (Enabled<A, \"phone\"> extends never ? never : \"phoneState\")\n | (Enabled<A, \"email\"> extends never ? never : \"emailCredentials\" | \"emailCommands\")\n | (Enabled<A, \"passkey\"> extends never\n ? never\n :\n | \"passkeyCredentials\"\n | \"passkeyOwnership\"\n | \"passkeyHandles\"\n | \"passkeyModules\"\n | \"passkeyFlows\"\n | \"passkeyAdmissions\"\n | \"passkeyCharges\")\n | (ManagedPasskey<A> extends never ? never : \"passkeyCommands\")\n | (UsesProofs<A> extends never ? never : ProofRoles);\n\nexport interface SubjectOptions<T extends object, NativeId> {\n readonly table: T;\n readonly id: string;\n readonly status: string;\n readonly activeValue: unknown;\n readonly securityRevision: string;\n readonly idCodec: Schema.Codec<SubjectId, NativeId>;\n readonly requirements: (\n row: Readonly<Record<string, unknown>>,\n ) => Effect.Effect<AuthenticationRequirement, PersistenceMappingError>;\n /** Defaults to sign-in requirements. Recovery can have a distinct application policy. */\n readonly actionRequirements?: (\n row: Readonly<Record<string, unknown>>,\n action: PasswordAction | EmailAction | PasskeyActionChallenge[\"action\"],\n ) => Effect.Effect<AuthenticationRequirement, PersistenceMappingError>;\n}\n\n/** Codecs at the application-owned subject and timestamp boundary. */\nexport interface SubjectMapping {\n readonly table: object;\n readonly id: string;\n readonly status: string;\n readonly securityRevision: string;\n readonly activeValue: unknown;\n readonly requirements: SubjectOptions<object, unknown>[\"requirements\"];\n readonly actionRequirements: NonNullable<SubjectOptions<object, unknown>[\"actionRequirements\"]>;\n readonly toSubject: (value: unknown) => Effect.Effect<SubjectId, PersistenceMappingError>;\n readonly toNative: (value: SubjectId) => Effect.Effect<unknown, PersistenceMappingError>;\n readonly toSubjectSync: (value: unknown) => SubjectId;\n readonly toNativeSync: (value: SubjectId) => unknown;\n}\n\nexport interface MappingInput {\n readonly tables: Partial<Record<StorageRole, object>>;\n readonly subjects: SubjectMapping;\n readonly encodeInstant: (millis: number) => unknown;\n readonly decodeInstant: (value: unknown) => Effect.Effect<number, PersistenceMappingError>;\n readonly decodeInstantSync: (value: unknown) => number;\n}\n\nexport interface StorageLayout<\n T extends object,\n Role extends StorageRole = StorageRole,\n> extends MappingInput {\n readonly namespace: string;\n readonly schema: Readonly<Record<Role, T>>;\n}\n\nexport interface ConfigId<Id extends string> {\n readonly authNamespace: Id;\n readonly service: \"PersistenceConfig\";\n}\n\nexport interface TimestampOptions<Instant> {\n readonly type: \"text\" | \"integer\";\n readonly codec: Schema.Codec<number, Instant>;\n}\n\nexport interface BoundPersistence<\n T extends object,\n R,\n C extends ClaimsCodec,\n Id extends string,\n A extends Definition<C, Id>,\n> {\n readonly Config: Context.Service<ConfigId<A[\"namespace\"]>, StorageLayout<T, Roles<C, Id, A>>> & {\n readonly layer: (\n value: StorageLayout<T, Roles<C, Id, A>>,\n ) => Layer.Layer<ConfigId<A[\"namespace\"]>>;\n };\n /** Create only the application subject. Runs inside the owning auth SQL transaction;\n * use that SqlClient (including Drizzle over it), and return the new subject ID.\n * Do not perform external side effects or open an independent transaction here.\n */\n readonly Provisioning: Context.Service<ProvisioningRequirement<A>, Provisioning<A>>;\n readonly layer: Layer.Layer<\n Ports<C, Id, A>,\n PersistenceConfigurationError,\n | Crypto.Crypto\n | ConfigId<A[\"namespace\"]>\n | ProvisioningRequirement<A>\n | PasskeyRequirement<A>\n | SqlClient.SqlClient\n | R\n >;\n readonly managed: <N, Instant = number>(options: {\n readonly subjects: SubjectOptions<T, N>;\n readonly tables?: Partial<Record<Roles<C, Id, A>, T>>;\n /** Stable SQL identifier prefix; reuse the deployed prefix for existing tables. */\n readonly prefix: string;\n readonly timestamps?: TimestampOptions<Instant>;\n }) => StorageLayout<T, Roles<C, Id, A>>;\n readonly map: <N, Instant = number>(options: {\n readonly subjects: SubjectOptions<T, N>;\n readonly tables: Readonly<Record<Roles<C, Id, A>, T>>;\n readonly timestamps?: TimestampOptions<Instant>;\n }) => StorageLayout<T, Roles<C, Id, A>>;\n}\n\n/** Shared configuration shape. The backend chooses table types and service requirements. */\nexport interface PersistenceApi<T extends object, R = never> {\n readonly make: <\n C extends ClaimsCodec,\n const Id extends string,\n const A extends Definition<C, Id>,\n >(\n auth: A & Definition<C, Id>,\n ) => BoundPersistence<T, R, C, Id, A>;\n}\n"],"mappings":";;AAgCA,IAAa,gCAAb,cAAmD,OAAO,YAA2C,CAAC,CACpG,iCACA,EAAE,QAAQ,OAAO,OAAO,CAC1B,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"configuration.mjs","names":[],"sources":["../../src/internal/configuration.ts"],"sourcesContent":["import type { EmailAction, EmailAddressPersistence } from \"@yielded/auth/Email\";\nimport type { LoginIdentifier } from \"@yielded/auth/Identity\";\nimport type {\n PasskeyActionChallenge,\n PasskeyConfig,\n PasskeyCredentials,\n PasskeyEnrollmentContext,\n PasskeyManagementPersistence,\n PasskeyManagementPolicy,\n PasskeyMethodPolicy,\n PasskeyPersistence,\n PasskeyConfigurationError,\n} from \"@yielded/auth/Passkey\";\nimport type {\n PasswordAction,\n PasswordPersistence,\n PasswordUnavailable,\n} from \"@yielded/auth/Password\";\nimport type { PhoneAdmission, PhoneSignInTargets } from \"@yielded/auth/PhoneOtp\";\nimport type { ProofPersistence } from \"@yielded/auth/Proofs\";\nimport type { SubjectId } from \"@yielded/auth/Schema\";\nimport type {\n AuthenticationAuthority,\n AuthenticationRequirement,\n make as makeSessions,\n} from \"@yielded/auth/Sessions\";\nimport { type Context, type Crypto, type Effect, type Layer, Schema } from \"effect\";\nimport type { SqlClient } from \"effect/sql\";\n\nimport type { PersistenceMappingError } from \"./mapping-error\";\nimport type { StorageRole } from \"./storage-tables\";\n\nexport class PersistenceConfigurationError extends Schema.TaggedError<PersistenceConfigurationError>()(\n \"PersistenceConfigurationError\",\n { reason: Schema.String },\n) {}\n\nexport type ClaimsCodec = Schema.Codec<unknown, unknown, never, never>;\n\nexport interface PasskeyFeature {\n readonly kind: \"passkey\";\n readonly moduleId: string;\n readonly policy: Effect.Effect<PasskeyMethodPolicy, PasskeyConfigurationError, PasskeyConfig>;\n readonly management?: boolean;\n readonly managementPolicy?: PasskeyManagementPolicy;\n}\n\nexport interface Strategy {\n readonly strategy: object;\n readonly persistence?:\n | PasskeyFeature\n | {\n readonly kind: \"password\" | \"phone\" | \"email\";\n readonly moduleId: string;\n readonly lifecycle?: boolean;\n readonly management?: boolean;\n readonly addresses?: boolean;\n };\n readonly RegistrationAuthority?: Context.Key<unknown, unknown>;\n}\n\nexport interface Definition<C extends ClaimsCodec, Id extends string> {\n readonly namespace: string;\n readonly claims: C;\n readonly sessionMode?: string | undefined;\n readonly sessions: ReturnType<typeof makeSessions<C, Id>>;\n readonly strategies: Readonly<Record<string, Strategy>>;\n}\n\ntype KeyId<T> = T extends Context.Key<infer Id, infer _Service> ? Id : never;\ntype Enabled<\n A extends { readonly strategies: Readonly<Record<string, Strategy>> },\n Kind extends \"password\" | \"phone\" | \"email\" | \"passkey\",\n> = Extract<A[\"strategies\"][keyof A[\"strategies\"]], { persistence: { kind: Kind } }>;\n\ntype ManagedPassword<A extends { readonly strategies: Readonly<Record<string, Strategy>> }> =\n Extract<Enabled<A, \"password\">, { persistence: { management: true } }>;\n\ntype ManagedPasskey<A extends { readonly strategies: Readonly<Record<string, Strategy>> }> =\n Extract<Enabled<A, \"passkey\">, { persistence: { management: true } }>;\n\nexport type PasskeyRequirement<\n A extends { readonly strategies: Readonly<Record<string, Strategy>> },\n> = Enabled<A, \"passkey\"> extends never ? never : PasskeyConfig;\n\ntype RegistrationKey<S> = S extends { readonly RegistrationAuthority: infer K } ? K : never;\ntype Registration<S> =\n RegistrationKey<S> extends Context.Key<infer _Id, infer Service>\n ? Service extends { readonly register: (input: infer Input, ...args: never[]) => unknown }\n ? Input extends { readonly registration: infer Value }\n ? Value\n : never\n : never\n : never;\n\nexport interface ProvisioningId<Id extends string> {\n readonly authNamespace: Id;\n readonly service: \"PersistenceProvisioning\";\n}\n\nexport type Provisioning<A extends { readonly strategies: Readonly<Record<string, Strategy>> }> = {\n readonly [\n K in keyof A[\"strategies\"] as A[\"strategies\"][K] extends {\n persistence: { kind: \"password\"; management: true };\n }\n ? K\n : never\n ]: (input: {\n readonly identifier: LoginIdentifier;\n readonly registration: Registration<A[\"strategies\"][K]>;\n }) => Effect.Effect<SubjectId, PasswordUnavailable>;\n};\n\nexport type ProvisioningRequirement<\n A extends { readonly namespace: string; readonly strategies: Readonly<Record<string, Strategy>> },\n> = ManagedPassword<A> extends never ? never : ProvisioningId<A[\"namespace\"]>;\n\ntype ProofRoles =\n | \"proofRequests\"\n | \"proofSeries\"\n | \"proofGenerations\"\n | \"proofContinuations\"\n | \"proofScopes\"\n | \"proofAbuse\"\n | \"proofFailures\"\n | \"proofCommands\";\n\ntype UsesProofs<A extends { readonly strategies: Readonly<Record<string, Strategy>> }> =\n | Enabled<A, \"phone\">\n | Enabled<A, \"email\">\n | ManagedPassword<A>;\n\nexport type Ports<C extends ClaimsCodec, Id extends string, A extends Definition<C, Id>> =\n | AuthenticationAuthority\n | KeyId<A[\"sessions\"][\"StatefulSessionPersistence\"]>\n | KeyId<A[\"sessions\"][\"SessionRepository\"]>\n | (Enabled<A, \"password\"> extends never ? never : PasswordPersistence)\n | KeyId<RegistrationKey<ManagedPassword<A>>>\n | (Enabled<A, \"passkey\"> extends never ? never : PasskeyPersistence | PasskeyCredentials)\n | (ManagedPasskey<A> extends never\n ? never\n : PasskeyManagementPersistence | PasskeyEnrollmentContext)\n | (Enabled<A, \"email\"> extends never ? never : EmailAddressPersistence)\n | (UsesProofs<A> extends never ? never : ProofPersistence)\n | (Enabled<A, \"phone\"> extends never ? never : PhoneAdmission | PhoneSignInTargets);\n\nexport type Roles<C extends ClaimsCodec, Id extends string, A extends Definition<C, Id>> =\n | \"identifiers\"\n | \"credentials\"\n | \"sessions\"\n | \"sessionFlows\"\n | (Enabled<A, \"password\"> extends never ? never : \"passwords\" | \"passwordCommands\")\n | (ManagedPassword<A> extends never ? never : \"passwordRegistrations\")\n | (Enabled<A, \"phone\"> extends never ? never : \"phoneState\")\n | (Enabled<A, \"email\"> extends never ? never : \"emailCredentials\" | \"emailCommands\")\n | (Enabled<A, \"passkey\"> extends never\n ? never\n :\n | \"passkeyCredentials\"\n | \"passkeyOwnership\"\n | \"passkeyHandles\"\n | \"passkeyModules\"\n | \"passkeyFlows\"\n | \"passkeyAdmissions\"\n | \"passkeyCharges\")\n | (ManagedPasskey<A> extends never ? never : \"passkeyCommands\")\n | (UsesProofs<A> extends never ? never : ProofRoles);\n\nexport interface SubjectOptions<T extends object, NativeId> {\n readonly table: T;\n readonly id: string;\n readonly status: string;\n readonly activeValue: unknown;\n readonly securityRevision: string;\n readonly idCodec: Schema.Codec<SubjectId, NativeId>;\n readonly requirements: (\n row: Readonly<Record<string, unknown>>,\n ) => Effect.Effect<AuthenticationRequirement, PersistenceMappingError>;\n /** Defaults to sign-in requirements. Recovery can have a distinct application policy. */\n readonly actionRequirements?: (\n row: Readonly<Record<string, unknown>>,\n action: PasswordAction | EmailAction | PasskeyActionChallenge[\"action\"],\n ) => Effect.Effect<AuthenticationRequirement, PersistenceMappingError>;\n}\n\n/** Codecs at the application-owned subject and timestamp boundary. */\nexport interface SubjectMapping {\n readonly table: object;\n readonly id: string;\n readonly status: string;\n readonly securityRevision: string;\n readonly activeValue: unknown;\n readonly requirements: SubjectOptions<object, unknown>[\"requirements\"];\n readonly actionRequirements: NonNullable<SubjectOptions<object, unknown>[\"actionRequirements\"]>;\n readonly toSubject: (value: unknown) => Effect.Effect<SubjectId, PersistenceMappingError>;\n readonly toNative: (value: SubjectId) => Effect.Effect<unknown, PersistenceMappingError>;\n readonly toSubjectSync: (value: unknown) => SubjectId;\n readonly toNativeSync: (value: SubjectId) => unknown;\n}\n\nexport interface MappingInput {\n readonly tables: Partial<Record<StorageRole, object>>;\n readonly subjects: SubjectMapping;\n readonly encodeInstant: (millis: number) => unknown;\n readonly decodeInstant: (value: unknown) => Effect.Effect<number, PersistenceMappingError>;\n readonly decodeInstantSync: (value: unknown) => number;\n}\n\nexport interface StorageLayout<\n T extends object,\n Role extends StorageRole = StorageRole,\n> extends MappingInput {\n readonly namespace: string;\n readonly schema: Readonly<Record<Role, T>>;\n}\n\nexport interface ConfigId<Id extends string> {\n readonly authNamespace: Id;\n readonly service: \"PersistenceConfig\";\n}\n\nexport interface TimestampOptions<Instant> {\n readonly type: \"text\" | \"integer\";\n readonly codec: Schema.Codec<number, Instant>;\n}\n\nexport interface BoundPersistence<\n T extends object,\n R,\n C extends ClaimsCodec,\n Id extends string,\n A extends Definition<C, Id>,\n> {\n readonly Config: Context.Service<ConfigId<A[\"namespace\"]>, StorageLayout<T, Roles<C, Id, A>>> & {\n readonly layer: (\n value: StorageLayout<T, Roles<C, Id, A>>,\n ) => Layer.Layer<ConfigId<A[\"namespace\"]>>;\n };\n /** Create only the application subject. Runs inside the owning auth SQL transaction;\n * use that SqlClient (including Drizzle over it), and return the new subject ID.\n * Do not perform external side effects or open an independent transaction here.\n */\n readonly Provisioning: Context.Service<ProvisioningRequirement<A>, Provisioning<A>>;\n readonly layer: Layer.Layer<\n Ports<C, Id, A>,\n PersistenceConfigurationError,\n | Crypto.Crypto\n | ConfigId<A[\"namespace\"]>\n | ProvisioningRequirement<A>\n | PasskeyRequirement<A>\n | SqlClient.SqlClient\n | R\n >;\n readonly managed: <N, Instant = number>(options: {\n readonly subjects: SubjectOptions<T, N>;\n readonly tables?: Partial<Record<Roles<C, Id, A>, T>>;\n /** Stable SQL identifier prefix; reuse the deployed prefix for existing tables. */\n readonly prefix: string;\n readonly timestamps?: TimestampOptions<Instant>;\n }) => StorageLayout<T, Roles<C, Id, A>>;\n readonly map: <N, Instant = number>(options: {\n readonly subjects: SubjectOptions<T, N>;\n readonly tables: Readonly<Record<Roles<C, Id, A>, T>>;\n readonly timestamps?: TimestampOptions<Instant>;\n }) => StorageLayout<T, Roles<C, Id, A>>;\n}\n\n/** Shared configuration shape. The backend chooses table types and service requirements. */\nexport interface PersistenceApi<T extends object, R = never> {\n readonly make: <\n C extends ClaimsCodec,\n const Id extends string,\n const A extends Definition<C, Id>,\n >(\n auth: A & Definition<C, Id>,\n ) => BoundPersistence<T, R, C, Id, A>;\n}\n"],"mappings":";;AAgCA,IAAa,gCAAb,cAAmD,OAAO,YAA2C,CAAC,CACpG,iCACA,EAAE,QAAQ,OAAO,OAAO,CAC1B,CAAC,CAAC,CAAC"}
@@ -132,7 +132,7 @@ export declare const makeEmailKernel: <Fragment extends SqlFragment = SqlFragmen
132
132
  completion: import("@yielded/auth/Proofs").ProofCompletionPlan;
133
133
  invalidation?: Readonly<{
134
134
  trigger: "all-session-revocation" | "credential-change" | "factor-reset" | "identifier-change" | "password-reset" | "subject-delete" | "subject-disable";
135
- existingSessions: "immediate" | "original-absolute-expiry";
135
+ existingSessions: "cache-expiry" | "immediate" | "original-absolute-expiry";
136
136
  maximumExposureMillis: number;
137
137
  oldAuthenticationEvidence: "rejected";
138
138
  }>;
@@ -279,7 +279,7 @@ const makeEmailKernel = (operations, proofs) => {
279
279
  });
280
280
  const validateEmailAuthority = Effect.fn("DrizzleEmail.validateAuthority")(function* (mapping, configuration, input, action) {
281
281
  const confirmsExisting = action === "verify-address" && input.captured.targetIdentifierRevision !== void 0;
282
- if (!input.captured.eligible || !completionMatches(input, action) || input.authorization.challenge.moduleId !== input.moduleId || input.authorization.challenge.action !== action || input.authorization.challenge.commandId !== input.commandId || !sameIdentifier(input.authorization.challenge.target, input.target) || input.authorization.challenge.sourceCredentialId !== input.captured.source?.credentialId || !sameEmailRevision(input.authorization.challenge.revision, input.captured.revision) || input.authorization.challenge.targetIdentifierRevision !== input.captured.targetIdentifierRevision || input.authorization.evidence.flowId !== input.commandId || input.authorization.evidence.bindingDigest !== input.authorization.challenge.bindingDigest || !sameEmailRevision(input.authorization.evidence.revision, input.captured.revision) || action === "verify-address" && input.captured.source !== void 0 || action === "change-address" && input.captured.source === void 0 || confirmsExisting !== (input.invalidation === void 0) || input.invalidation?.existingSessions === "immediate" && mapping.sessionInvalidation !== "same-authority-immediate") return void 0;
282
+ if (!input.captured.eligible || !completionMatches(input, action) || input.authorization.challenge.moduleId !== input.moduleId || input.authorization.challenge.action !== action || input.authorization.challenge.commandId !== input.commandId || !sameIdentifier(input.authorization.challenge.target, input.target) || input.authorization.challenge.sourceCredentialId !== input.captured.source?.credentialId || !sameEmailRevision(input.authorization.challenge.revision, input.captured.revision) || input.authorization.challenge.targetIdentifierRevision !== input.captured.targetIdentifierRevision || input.authorization.evidence.flowId !== input.commandId || input.authorization.evidence.bindingDigest !== input.authorization.challenge.bindingDigest || !sameEmailRevision(input.authorization.evidence.revision, input.captured.revision) || action === "verify-address" && input.captured.source !== void 0 || action === "change-address" && input.captured.source === void 0 || confirmsExisting !== (input.invalidation === void 0) || (input.invalidation?.existingSessions === "immediate" || input.invalidation?.existingSessions === "cache-expiry") && mapping.sessionInvalidation !== "same-authority-immediate") return void 0;
283
283
  const current = yield* currentAddress(mapping, {
284
284
  moduleId: input.moduleId,
285
285
  subjectId: input.captured.revision.subjectId,