@yielded/auth 0.1.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +18 -0
- package/dist/Atom.d.mts +5 -0
- package/dist/Atom.mjs +5 -0
- package/dist/Auth.d.mts +9 -0
- package/dist/Auth.mjs +7 -0
- package/dist/AuthContract.d.mts +4 -0
- package/dist/AuthContract.mjs +4 -0
- package/dist/AuthSession.d.mts +82 -0
- package/dist/AuthSession.mjs +138 -0
- package/dist/AuthSession.mjs.map +1 -0
- package/dist/AuthStore.d.mts +68 -0
- package/dist/AuthStore.mjs +194 -0
- package/dist/AuthStore.mjs.map +1 -0
- package/dist/AuthTokenCodec.d.mts +40 -0
- package/dist/AuthTokenCodec.mjs +104 -0
- package/dist/AuthTokenCodec.mjs.map +1 -0
- package/dist/Client.d.mts +2 -0
- package/dist/Client.mjs +2 -0
- package/dist/Cloudflare.d.mts +89 -0
- package/dist/Cloudflare.mjs +166 -0
- package/dist/Cloudflare.mjs.map +1 -0
- package/dist/Drizzle.d.mts +28 -0
- package/dist/Drizzle.mjs +27 -0
- package/dist/DrizzleD1.d.mts +935 -0
- package/dist/DrizzleD1.mjs +29 -0
- package/dist/DrizzleD1.mjs.map +1 -0
- package/dist/DrizzleLibsql.d.mts +2288 -0
- package/dist/DrizzleLibsql.mjs +85 -0
- package/dist/DrizzleLibsql.mjs.map +1 -0
- package/dist/DrizzleMysql2.d.mts +1809 -0
- package/dist/DrizzleMysql2.mjs +55 -0
- package/dist/DrizzleMysql2.mjs.map +1 -0
- package/dist/DrizzlePglite.d.mts +1808 -0
- package/dist/DrizzlePglite.mjs +45 -0
- package/dist/DrizzlePglite.mjs.map +1 -0
- package/dist/DrizzlePostgres.d.mts +1808 -0
- package/dist/DrizzlePostgres.mjs +45 -0
- package/dist/DrizzlePostgres.mjs.map +1 -0
- package/dist/DrizzleSqliteBun.d.mts +2287 -0
- package/dist/DrizzleSqliteBun.mjs +62 -0
- package/dist/DrizzleSqliteBun.mjs.map +1 -0
- package/dist/DrizzleSqliteDo.d.mts +2343 -0
- package/dist/DrizzleSqliteDo.mjs +105 -0
- package/dist/DrizzleSqliteDo.mjs.map +1 -0
- package/dist/DrizzleSqliteNode.d.mts +2287 -0
- package/dist/DrizzleSqliteNode.mjs +62 -0
- package/dist/DrizzleSqliteNode.mjs.map +1 -0
- package/dist/DrizzleSqliteWasm.d.mts +2287 -0
- package/dist/DrizzleSqliteWasm.mjs +62 -0
- package/dist/DrizzleSqliteWasm.mjs.map +1 -0
- package/dist/Email.d.mts +12 -0
- package/dist/Email.mjs +11 -0
- package/dist/EmailOtp.d.mts +42 -0
- package/dist/EmailOtp.mjs +120 -0
- package/dist/EmailOtp.mjs.map +1 -0
- package/dist/EmailOtpSender.d.mts +22 -0
- package/dist/EmailOtpSender.mjs +18 -0
- package/dist/EmailOtpSender.mjs.map +1 -0
- package/dist/Errors.d.mts +55 -0
- package/dist/Errors.mjs +31 -0
- package/dist/Errors.mjs.map +1 -0
- package/dist/GitHub.d.mts +5 -0
- package/dist/GitHub.mjs +4 -0
- package/dist/Hooks.d.mts +6 -0
- package/dist/Hooks.mjs +6 -0
- package/dist/Http.d.mts +12 -0
- package/dist/Http.mjs +12 -0
- package/dist/HttpServer.d.mts +103 -0
- package/dist/HttpServer.mjs +326 -0
- package/dist/HttpServer.mjs.map +1 -0
- package/dist/Identity.d.mts +9 -0
- package/dist/Identity.mjs +9 -0
- package/dist/IdentityResolver.d.mts +16 -0
- package/dist/IdentityResolver.mjs +12 -0
- package/dist/IdentityResolver.mjs.map +1 -0
- package/dist/OAuth.d.mts +36 -0
- package/dist/OAuth.mjs +35 -0
- package/dist/OpenIdClient.d.mts +3 -0
- package/dist/OpenIdClient.mjs +3 -0
- package/dist/OpenIdClientConnected.d.mts +4 -0
- package/dist/OpenIdClientConnected.mjs +3 -0
- package/dist/OperationHttp.d.mts +3 -0
- package/dist/OperationHttp.mjs +3 -0
- package/dist/OperationHttpClient.d.mts +2 -0
- package/dist/OperationHttpClient.mjs +2 -0
- package/dist/OperationHttpServer.d.mts +5 -0
- package/dist/OperationHttpServer.mjs +4 -0
- package/dist/Operations.d.mts +8 -0
- package/dist/Operations.mjs +8 -0
- package/dist/Passkey.d.mts +12 -0
- package/dist/Passkey.mjs +12 -0
- package/dist/PasskeyBrowser.d.mts +4 -0
- package/dist/PasskeyBrowser.mjs +4 -0
- package/dist/PasskeyContract.d.mts +641 -0
- package/dist/PasskeyContract.mjs +174 -0
- package/dist/PasskeyContract.mjs.map +1 -0
- package/dist/PasskeyPassword.d.mts +412 -0
- package/dist/PasskeyPassword.mjs +174 -0
- package/dist/PasskeyPassword.mjs.map +1 -0
- package/dist/PasskeySimpleWebAuthn.d.mts +3 -0
- package/dist/PasskeySimpleWebAuthn.mjs +3 -0
- package/dist/Password.d.mts +19 -0
- package/dist/Password.mjs +17 -0
- package/dist/PasswordAuth.d.mts +45 -0
- package/dist/PasswordAuth.mjs +79 -0
- package/dist/PasswordAuth.mjs.map +1 -0
- package/dist/PasswordCredentialStore.d.mts +46 -0
- package/dist/PasswordCredentialStore.mjs +62 -0
- package/dist/PasswordCredentialStore.mjs.map +1 -0
- package/dist/PasswordHasher.d.mts +31 -0
- package/dist/PasswordHasher.mjs +76 -0
- package/dist/PasswordHasher.mjs.map +1 -0
- package/dist/PhoneOtp.d.mts +11 -0
- package/dist/PhoneOtp.mjs +11 -0
- package/dist/Policy.d.mts +52 -0
- package/dist/Policy.mjs +36 -0
- package/dist/Policy.mjs.map +1 -0
- package/dist/Proofs.d.mts +14 -0
- package/dist/Proofs.mjs +13 -0
- package/dist/Rpc.d.mts +12 -0
- package/dist/Rpc.mjs +11 -0
- package/dist/Rpc.mjs.map +1 -0
- package/dist/Schema.d.mts +160 -0
- package/dist/Schema.mjs +141 -0
- package/dist/Schema.mjs.map +1 -0
- package/dist/SessionContract.d.mts +3 -0
- package/dist/SessionContract.mjs +3 -0
- package/dist/Sessions.d.mts +14 -0
- package/dist/Sessions.mjs +12 -0
- package/dist/Testing.d.mts +7 -0
- package/dist/Testing.mjs +7 -0
- package/dist/Totp.d.mts +8 -0
- package/dist/Totp.mjs +8 -0
- package/dist/TotpContract.d.mts +318 -0
- package/dist/TotpContract.mjs +119 -0
- package/dist/TotpContract.mjs.map +1 -0
- package/dist/WebCrypto.d.mts +28 -0
- package/dist/WebCrypto.mjs +42 -0
- package/dist/WebCrypto.mjs.map +1 -0
- package/dist/Workflows.d.mts +16 -0
- package/dist/Workflows.mjs +11 -0
- package/dist/Workflows.mjs.map +1 -0
- package/dist/atom/AuthAtomLifetime.d.mts +35 -0
- package/dist/atom/AuthAtomLifetime.mjs +50 -0
- package/dist/atom/AuthAtomLifetime.mjs.map +1 -0
- package/dist/atom/AuthAtomWorkflow.d.mts +17 -0
- package/dist/atom/AuthAtomWorkflow.mjs +9 -0
- package/dist/atom/AuthAtomWorkflow.mjs.map +1 -0
- package/dist/atom/client.d.mts +43 -0
- package/dist/atom/client.mjs +168 -0
- package/dist/atom/client.mjs.map +1 -0
- package/dist/atom/operations.d.mts +35 -0
- package/dist/atom/operations.mjs +58 -0
- package/dist/atom/operations.mjs.map +1 -0
- package/dist/atom/scoped-runtime.mjs +151 -0
- package/dist/atom/scoped-runtime.mjs.map +1 -0
- package/dist/auth/Auth.d.mts +7806 -0
- package/dist/auth/Auth.mjs +141 -0
- package/dist/auth/Auth.mjs.map +1 -0
- package/dist/auth/AuthConfigurationError.d.mts +10 -0
- package/dist/auth/AuthConfigurationError.mjs +14 -0
- package/dist/auth/AuthConfigurationError.mjs.map +1 -0
- package/dist/auth/AuthRequest.d.mts +21 -0
- package/dist/auth/AuthRequest.mjs +10 -0
- package/dist/auth/AuthRequest.mjs.map +1 -0
- package/dist/auth/AuthStrategy.d.mts +23 -0
- package/dist/auth/AuthStrategy.mjs +33 -0
- package/dist/auth/AuthStrategy.mjs.map +1 -0
- package/dist/auth/ConsumeDecision.d.mts +11 -0
- package/dist/auth/actions.d.mts +18 -0
- package/dist/auth/actions.mjs +70 -0
- package/dist/auth/actions.mjs.map +1 -0
- package/dist/auth/defaults.mjs +12 -0
- package/dist/auth/defaults.mjs.map +1 -0
- package/dist/auth/definition.d.mts +46 -0
- package/dist/auth/session.d.mts +27 -0
- package/dist/auth/session.mjs +56 -0
- package/dist/auth/session.mjs.map +1 -0
- package/dist/drizzle/D1BatchStatements.d.mts +11 -0
- package/dist/drizzle/D1BatchStatements.mjs +8 -0
- package/dist/drizzle/D1BatchStatements.mjs.map +1 -0
- package/dist/drizzle/PasswordPreparedPostconditions.mjs +12 -0
- package/dist/drizzle/PasswordPreparedPostconditions.mjs.map +1 -0
- package/dist/drizzle/SuppliedService.d.mts +10 -0
- package/dist/drizzle/d1-emails.d.mts +68 -0
- package/dist/drizzle/d1-emails.mjs +580 -0
- package/dist/drizzle/d1-emails.mjs.map +1 -0
- package/dist/drizzle/d1-generated-statement.mjs +79 -0
- package/dist/drizzle/d1-generated-statement.mjs.map +1 -0
- package/dist/drizzle/d1-identity.d.mts +33 -0
- package/dist/drizzle/d1-identity.mjs +120 -0
- package/dist/drizzle/d1-identity.mjs.map +1 -0
- package/dist/drizzle/d1-oauth.d.mts +316 -0
- package/dist/drizzle/d1-oauth.mjs +79 -0
- package/dist/drizzle/d1-oauth.mjs.map +1 -0
- package/dist/drizzle/d1-passkey.d.mts +52 -0
- package/dist/drizzle/d1-passkey.mjs +97 -0
- package/dist/drizzle/d1-passkey.mjs.map +1 -0
- package/dist/drizzle/d1-password-prepared.d.mts +27 -0
- package/dist/drizzle/d1-password-prepared.mjs +464 -0
- package/dist/drizzle/d1-password-prepared.mjs.map +1 -0
- package/dist/drizzle/d1-passwords.d.mts +96 -0
- package/dist/drizzle/d1-passwords.mjs +1008 -0
- package/dist/drizzle/d1-passwords.mjs.map +1 -0
- package/dist/drizzle/d1-phone.d.mts +29 -0
- package/dist/drizzle/d1-phone.mjs +33 -0
- package/dist/drizzle/d1-phone.mjs.map +1 -0
- package/dist/drizzle/d1-planning.d.mts +12 -0
- package/dist/drizzle/d1-planning.mjs +43 -0
- package/dist/drizzle/d1-planning.mjs.map +1 -0
- package/dist/drizzle/d1-proofs.d.mts +88 -0
- package/dist/drizzle/d1-proofs.mjs +833 -0
- package/dist/drizzle/d1-proofs.mjs.map +1 -0
- package/dist/drizzle/d1-sessions.d.mts +77 -0
- package/dist/drizzle/d1-sessions.mjs +970 -0
- package/dist/drizzle/d1-sessions.mjs.map +1 -0
- package/dist/drizzle/d1-totp.d.mts +27 -0
- package/dist/drizzle/d1-totp.mjs +28 -0
- package/dist/drizzle/d1-totp.mjs.map +1 -0
- package/dist/drizzle/email-model.d.mts +352 -0
- package/dist/drizzle/email-model.mjs +21 -0
- package/dist/drizzle/email-model.mjs.map +1 -0
- package/dist/drizzle/email-registration.d.mts +33 -0
- package/dist/drizzle/email-registration.mjs +238 -0
- package/dist/drizzle/email-registration.mjs.map +1 -0
- package/dist/drizzle/email-sql.d.mts +18 -0
- package/dist/drizzle/email-sql.mjs +473 -0
- package/dist/drizzle/email-sql.mjs.map +1 -0
- package/dist/drizzle/email-target.d.mts +28 -0
- package/dist/drizzle/email-target.mjs +75 -0
- package/dist/drizzle/email-target.mjs.map +1 -0
- package/dist/drizzle/model.d.mts +259 -0
- package/dist/drizzle/model.mjs +81 -0
- package/dist/drizzle/model.mjs.map +1 -0
- package/dist/drizzle/mysql-emails.d.mts +82 -0
- package/dist/drizzle/mysql-emails.mjs +38 -0
- package/dist/drizzle/mysql-emails.mjs.map +1 -0
- package/dist/drizzle/mysql-identity.d.mts +24 -0
- package/dist/drizzle/mysql-identity.mjs +95 -0
- package/dist/drizzle/mysql-identity.mjs.map +1 -0
- package/dist/drizzle/mysql-password-prepared.d.mts +32 -0
- package/dist/drizzle/mysql-password-prepared.mjs +16 -0
- package/dist/drizzle/mysql-password-prepared.mjs.map +1 -0
- package/dist/drizzle/mysql-passwords.d.mts +102 -0
- package/dist/drizzle/mysql-passwords.mjs +38 -0
- package/dist/drizzle/mysql-passwords.mjs.map +1 -0
- package/dist/drizzle/mysql-proofs.d.mts +83 -0
- package/dist/drizzle/mysql-proofs.mjs +23 -0
- package/dist/drizzle/mysql-proofs.mjs.map +1 -0
- package/dist/drizzle/mysql-sessions.d.mts +250 -0
- package/dist/drizzle/mysql-sessions.mjs +53 -0
- package/dist/drizzle/mysql-sessions.mjs.map +1 -0
- package/dist/drizzle/mysql.d.mts +73 -0
- package/dist/drizzle/mysql.mjs +221 -0
- package/dist/drizzle/mysql.mjs.map +1 -0
- package/dist/drizzle/oauth-accounts.mjs +361 -0
- package/dist/drizzle/oauth-accounts.mjs.map +1 -0
- package/dist/drizzle/oauth-connected-access.mjs +210 -0
- package/dist/drizzle/oauth-connected-access.mjs.map +1 -0
- package/dist/drizzle/oauth-connected-collection.mjs +202 -0
- package/dist/drizzle/oauth-connected-collection.mjs.map +1 -0
- package/dist/drizzle/oauth-connected-custody.mjs +146 -0
- package/dist/drizzle/oauth-connected-custody.mjs.map +1 -0
- package/dist/drizzle/oauth-connected-drivers.mjs +78 -0
- package/dist/drizzle/oauth-connected-drivers.mjs.map +1 -0
- package/dist/drizzle/oauth-connected-flow.mjs +248 -0
- package/dist/drizzle/oauth-connected-flow.mjs.map +1 -0
- package/dist/drizzle/oauth-connected-input.mjs +105 -0
- package/dist/drizzle/oauth-connected-input.mjs.map +1 -0
- package/dist/drizzle/oauth-connected-maintenance.mjs +215 -0
- package/dist/drizzle/oauth-connected-maintenance.mjs.map +1 -0
- package/dist/drizzle/oauth-connected-management.mjs +228 -0
- package/dist/drizzle/oauth-connected-management.mjs.map +1 -0
- package/dist/drizzle/oauth-connected-model.d.mts +278 -0
- package/dist/drizzle/oauth-connected-model.mjs +22 -0
- package/dist/drizzle/oauth-connected-model.mjs.map +1 -0
- package/dist/drizzle/oauth-connected-reference.d.mts +17 -0
- package/dist/drizzle/oauth-connected-reference.mjs +53 -0
- package/dist/drizzle/oauth-connected-reference.mjs.map +1 -0
- package/dist/drizzle/oauth-connected-settlement.mjs +117 -0
- package/dist/drizzle/oauth-connected-settlement.mjs.map +1 -0
- package/dist/drizzle/oauth-connected-state.d.mts +16 -0
- package/dist/drizzle/oauth-connected-state.mjs +422 -0
- package/dist/drizzle/oauth-connected-state.mjs.map +1 -0
- package/dist/drizzle/oauth-connected-target.d.mts +114 -0
- package/dist/drizzle/oauth-connected-target.mjs +94 -0
- package/dist/drizzle/oauth-connected-target.mjs.map +1 -0
- package/dist/drizzle/oauth-drivers.mjs +53 -0
- package/dist/drizzle/oauth-drivers.mjs.map +1 -0
- package/dist/drizzle/oauth-flow.d.mts +7 -0
- package/dist/drizzle/oauth-flow.mjs +255 -0
- package/dist/drizzle/oauth-flow.mjs.map +1 -0
- package/dist/drizzle/oauth-input.mjs +130 -0
- package/dist/drizzle/oauth-input.mjs.map +1 -0
- package/dist/drizzle/oauth-model.d.mts +468 -0
- package/dist/drizzle/oauth-model.mjs +49 -0
- package/dist/drizzle/oauth-model.mjs.map +1 -0
- package/dist/drizzle/oauth-mysql.mjs +8 -0
- package/dist/drizzle/oauth-mysql.mjs.map +1 -0
- package/dist/drizzle/oauth-owner.d.mts +4 -0
- package/dist/drizzle/oauth-owner.mjs +10 -0
- package/dist/drizzle/oauth-owner.mjs.map +1 -0
- package/dist/drizzle/oauth-registration.d.mts +8 -0
- package/dist/drizzle/oauth-registration.mjs +375 -0
- package/dist/drizzle/oauth-registration.mjs.map +1 -0
- package/dist/drizzle/oauth-state.mjs +109 -0
- package/dist/drizzle/oauth-state.mjs.map +1 -0
- package/dist/drizzle/oauth-target.d.mts +125 -0
- package/dist/drizzle/oauth-target.mjs +252 -0
- package/dist/drizzle/oauth-target.mjs.map +1 -0
- package/dist/drizzle/passkey-admission.mjs +203 -0
- package/dist/drizzle/passkey-admission.mjs.map +1 -0
- package/dist/drizzle/passkey-credentials.mjs +239 -0
- package/dist/drizzle/passkey-credentials.mjs.map +1 -0
- package/dist/drizzle/passkey-drivers.mjs +34 -0
- package/dist/drizzle/passkey-drivers.mjs.map +1 -0
- package/dist/drizzle/passkey-enrollment.mjs +132 -0
- package/dist/drizzle/passkey-enrollment.mjs.map +1 -0
- package/dist/drizzle/passkey-flow.mjs +436 -0
- package/dist/drizzle/passkey-flow.mjs.map +1 -0
- package/dist/drizzle/passkey-management.mjs +225 -0
- package/dist/drizzle/passkey-management.mjs.map +1 -0
- package/dist/drizzle/passkey-model.d.mts +275 -0
- package/dist/drizzle/passkey-model.mjs +36 -0
- package/dist/drizzle/passkey-model.mjs.map +1 -0
- package/dist/drizzle/passkey-registration-ceremony-model.d.mts +50 -0
- package/dist/drizzle/passkey-registration-ceremony-model.mjs +18 -0
- package/dist/drizzle/passkey-registration-ceremony-model.mjs.map +1 -0
- package/dist/drizzle/passkey-registration-ceremony.mjs +124 -0
- package/dist/drizzle/passkey-registration-ceremony.mjs.map +1 -0
- package/dist/drizzle/passkey-registration-custody.mjs +51 -0
- package/dist/drizzle/passkey-registration-custody.mjs.map +1 -0
- package/dist/drizzle/passkey-registration-write.mjs +205 -0
- package/dist/drizzle/passkey-registration-write.mjs.map +1 -0
- package/dist/drizzle/passkey-state.d.mts +5 -0
- package/dist/drizzle/passkey-state.mjs +207 -0
- package/dist/drizzle/passkey-state.mjs.map +1 -0
- package/dist/drizzle/passkey-target.d.mts +16 -0
- package/dist/drizzle/passkey-target.mjs +174 -0
- package/dist/drizzle/passkey-target.mjs.map +1 -0
- package/dist/drizzle/passkey-write-drivers.mjs +33 -0
- package/dist/drizzle/passkey-write-drivers.mjs.map +1 -0
- package/dist/drizzle/passkey-write-model.d.mts +192 -0
- package/dist/drizzle/passkey-write-model.mjs +13 -0
- package/dist/drizzle/passkey-write-model.mjs.map +1 -0
- package/dist/drizzle/passkey-write-state.mjs +326 -0
- package/dist/drizzle/passkey-write-state.mjs.map +1 -0
- package/dist/drizzle/passkey-write-target.d.mts +14 -0
- package/dist/drizzle/passkey-write-target.mjs +185 -0
- package/dist/drizzle/passkey-write-target.mjs.map +1 -0
- package/dist/drizzle/password-model.d.mts +330 -0
- package/dist/drizzle/password-model.mjs +22 -0
- package/dist/drizzle/password-model.mjs.map +1 -0
- package/dist/drizzle/password-prepared-model.d.mts +93 -0
- package/dist/drizzle/password-prepared-model.mjs +11 -0
- package/dist/drizzle/password-prepared-model.mjs.map +1 -0
- package/dist/drizzle/password-prepared-sql.mjs +394 -0
- package/dist/drizzle/password-prepared-sql.mjs.map +1 -0
- package/dist/drizzle/password-prepared-state.mjs +107 -0
- package/dist/drizzle/password-prepared-state.mjs.map +1 -0
- package/dist/drizzle/password-prepared-target.d.mts +12 -0
- package/dist/drizzle/password-prepared-target.mjs +57 -0
- package/dist/drizzle/password-prepared-target.mjs.map +1 -0
- package/dist/drizzle/password-registration.d.mts +23 -0
- package/dist/drizzle/password-registration.mjs +136 -0
- package/dist/drizzle/password-registration.mjs.map +1 -0
- package/dist/drizzle/password-sql.d.mts +20 -0
- package/dist/drizzle/password-sql.mjs +702 -0
- package/dist/drizzle/password-sql.mjs.map +1 -0
- package/dist/drizzle/password-target.d.mts +25 -0
- package/dist/drizzle/password-target.mjs +63 -0
- package/dist/drizzle/password-target.mjs.map +1 -0
- package/dist/drizzle/pg-emails.d.mts +83 -0
- package/dist/drizzle/pg-emails.mjs +38 -0
- package/dist/drizzle/pg-emails.mjs.map +1 -0
- package/dist/drizzle/pg-password-prepared.d.mts +33 -0
- package/dist/drizzle/pg-password-prepared.mjs +16 -0
- package/dist/drizzle/pg-password-prepared.mjs.map +1 -0
- package/dist/drizzle/pg-passwords.d.mts +103 -0
- package/dist/drizzle/pg-passwords.mjs +38 -0
- package/dist/drizzle/pg-passwords.mjs.map +1 -0
- package/dist/drizzle/pg-proofs.d.mts +84 -0
- package/dist/drizzle/pg-proofs.mjs +22 -0
- package/dist/drizzle/pg-proofs.mjs.map +1 -0
- package/dist/drizzle/pg-sessions.d.mts +251 -0
- package/dist/drizzle/pg-sessions.mjs +53 -0
- package/dist/drizzle/pg-sessions.mjs.map +1 -0
- package/dist/drizzle/pg.d.mts +88 -0
- package/dist/drizzle/pg.mjs +294 -0
- package/dist/drizzle/pg.mjs.map +1 -0
- package/dist/drizzle/phone-model.d.mts +117 -0
- package/dist/drizzle/phone-model.mjs +39 -0
- package/dist/drizzle/phone-model.mjs.map +1 -0
- package/dist/drizzle/phone-state.mjs +426 -0
- package/dist/drizzle/phone-state.mjs.map +1 -0
- package/dist/drizzle/phone-target.d.mts +19 -0
- package/dist/drizzle/phone-target.mjs +171 -0
- package/dist/drizzle/phone-target.mjs.map +1 -0
- package/dist/drizzle/proof-model.d.mts +287 -0
- package/dist/drizzle/proof-model.mjs +17 -0
- package/dist/drizzle/proof-model.mjs.map +1 -0
- package/dist/drizzle/proof-sql.d.mts +16 -0
- package/dist/drizzle/proof-sql.mjs +618 -0
- package/dist/drizzle/proof-sql.mjs.map +1 -0
- package/dist/drizzle/proof-target.d.mts +17 -0
- package/dist/drizzle/proof-target.mjs +38 -0
- package/dist/drizzle/proof-target.mjs.map +1 -0
- package/dist/drizzle/session-model.d.mts +201 -0
- package/dist/drizzle/session-model.mjs +19 -0
- package/dist/drizzle/session-model.mjs.map +1 -0
- package/dist/drizzle/session-sql.mjs +732 -0
- package/dist/drizzle/session-sql.mjs.map +1 -0
- package/dist/drizzle/session-target.d.mts +37 -0
- package/dist/drizzle/session-target.mjs +47 -0
- package/dist/drizzle/session-target.mjs.map +1 -0
- package/dist/drizzle/sqlite-emails.mjs +45 -0
- package/dist/drizzle/sqlite-emails.mjs.map +1 -0
- package/dist/drizzle/sqlite-identity.mjs +92 -0
- package/dist/drizzle/sqlite-identity.mjs.map +1 -0
- package/dist/drizzle/sqlite-password-prepared.mjs +21 -0
- package/dist/drizzle/sqlite-password-prepared.mjs.map +1 -0
- package/dist/drizzle/sqlite-passwords.mjs +49 -0
- package/dist/drizzle/sqlite-passwords.mjs.map +1 -0
- package/dist/drizzle/sqlite-proofs.mjs +29 -0
- package/dist/drizzle/sqlite-proofs.mjs.map +1 -0
- package/dist/drizzle/sqlite-sessions.mjs +74 -0
- package/dist/drizzle/sqlite-sessions.mjs.map +1 -0
- package/dist/drizzle/sqlite.d.mts +81 -0
- package/dist/drizzle/sqlite.mjs +220 -0
- package/dist/drizzle/sqlite.mjs.map +1 -0
- package/dist/drizzle/standalone-guard.mjs +19 -0
- package/dist/drizzle/standalone-guard.mjs.map +1 -0
- package/dist/drizzle/step-up-model.d.mts +65 -0
- package/dist/drizzle/step-up-model.mjs +9 -0
- package/dist/drizzle/step-up-model.mjs.map +1 -0
- package/dist/drizzle/step-up-state.mjs +34 -0
- package/dist/drizzle/step-up-state.mjs.map +1 -0
- package/dist/drizzle/totp-model.d.mts +85 -0
- package/dist/drizzle/totp-model.mjs +13 -0
- package/dist/drizzle/totp-model.mjs.map +1 -0
- package/dist/drizzle/totp-state.d.mts +39 -0
- package/dist/drizzle/totp-state.mjs +288 -0
- package/dist/drizzle/totp-state.mjs.map +1 -0
- package/dist/drizzle/totp-target.d.mts +16 -0
- package/dist/drizzle/totp-target.mjs +83 -0
- package/dist/drizzle/totp-target.mjs.map +1 -0
- package/dist/drizzle/transaction-execution.d.mts +20 -0
- package/dist/drizzle/transaction-execution.mjs +111 -0
- package/dist/drizzle/transaction-execution.mjs.map +1 -0
- package/dist/drizzle/transaction-mysql.mjs +46 -0
- package/dist/drizzle/transaction-mysql.mjs.map +1 -0
- package/dist/drizzle/transaction-owner.d.mts +6 -0
- package/dist/drizzle/transaction-owner.mjs +252 -0
- package/dist/drizzle/transaction-owner.mjs.map +1 -0
- package/dist/email/EmailActionEvidence.d.mts +33 -0
- package/dist/email/EmailActionEvidence.mjs +15 -0
- package/dist/email/EmailActionEvidence.mjs.map +1 -0
- package/dist/email/EmailAddressPersistence.d.mts +63 -0
- package/dist/email/EmailAddressPersistence.mjs +19 -0
- package/dist/email/EmailAddressPersistence.mjs.map +1 -0
- package/dist/email/EmailIdentifierNotifier.d.mts +30 -0
- package/dist/email/EmailIdentifierNotifier.mjs +31 -0
- package/dist/email/EmailIdentifierNotifier.mjs.map +1 -0
- package/dist/email/EmailReturnTargets.d.mts +19 -0
- package/dist/email/EmailReturnTargets.mjs +29 -0
- package/dist/email/EmailReturnTargets.mjs.map +1 -0
- package/dist/email/EmailSignInTargets.d.mts +20 -0
- package/dist/email/EmailSignInTargets.mjs +12 -0
- package/dist/email/EmailSignInTargets.mjs.map +1 -0
- package/dist/email/addresses.d.mts +33 -0
- package/dist/email/addresses.mjs +404 -0
- package/dist/email/addresses.mjs.map +1 -0
- package/dist/email/definition.d.mts +10153 -0
- package/dist/email/definition.mjs +111 -0
- package/dist/email/definition.mjs.map +1 -0
- package/dist/email/errors.d.mts +15 -0
- package/dist/email/errors.mjs +11 -0
- package/dist/email/errors.mjs.map +1 -0
- package/dist/email/magicLink.d.mts +33 -0
- package/dist/email/magicLink.mjs +58 -0
- package/dist/email/magicLink.mjs.map +1 -0
- package/dist/email/models.d.mts +56 -0
- package/dist/email/models.mjs +31 -0
- package/dist/email/models.mjs.map +1 -0
- package/dist/email/module.d.mts +22296 -0
- package/dist/email/module.mjs +415 -0
- package/dist/email/module.mjs.map +1 -0
- package/dist/email/registration.d.mts +28 -0
- package/dist/email/registration.mjs +243 -0
- package/dist/email/registration.mjs.map +1 -0
- package/dist/email/snapshot.mjs +37 -0
- package/dist/email/snapshot.mjs.map +1 -0
- package/dist/hooks/LifecycleHooks.d.mts +34 -0
- package/dist/hooks/LifecycleHooks.mjs +74 -0
- package/dist/hooks/LifecycleHooks.mjs.map +1 -0
- package/dist/hooks/commit.d.mts +66 -0
- package/dist/hooks/commit.mjs +136 -0
- package/dist/hooks/commit.mjs.map +1 -0
- package/dist/hooks/models.d.mts +51 -0
- package/dist/hooks/models.mjs +87 -0
- package/dist/hooks/models.mjs.map +1 -0
- package/dist/hooks/plugins.d.mts +36 -0
- package/dist/hooks/plugins.mjs +60 -0
- package/dist/hooks/plugins.mjs.map +1 -0
- package/dist/hooks/transactions.d.mts +31 -0
- package/dist/hooks/transactions.mjs +38 -0
- package/dist/hooks/transactions.mjs.map +1 -0
- package/dist/http/auth-api.d.mts +9 -0
- package/dist/http/auth-api.mjs +13 -0
- package/dist/http/auth-api.mjs.map +1 -0
- package/dist/http/auth-contract.d.mts +84 -0
- package/dist/http/auth-contract.mjs +75 -0
- package/dist/http/auth-contract.mjs.map +1 -0
- package/dist/http/auth-http.d.mts +216 -0
- package/dist/http/auth-http.mjs +184 -0
- package/dist/http/auth-http.mjs.map +1 -0
- package/dist/http/endpoints/get-session.d.mts +8 -0
- package/dist/http/endpoints/get-session.mjs +12 -0
- package/dist/http/endpoints/get-session.mjs.map +1 -0
- package/dist/http/endpoints/password-sign-in.d.mts +8 -0
- package/dist/http/endpoints/password-sign-in.mjs +18 -0
- package/dist/http/endpoints/password-sign-in.mjs.map +1 -0
- package/dist/http/endpoints/request-email-otp.d.mts +8 -0
- package/dist/http/endpoints/request-email-otp.mjs +17 -0
- package/dist/http/endpoints/request-email-otp.mjs.map +1 -0
- package/dist/http/endpoints/set-password.d.mts +9 -0
- package/dist/http/endpoints/set-password.mjs +19 -0
- package/dist/http/endpoints/set-password.mjs.map +1 -0
- package/dist/http/endpoints/sign-out.d.mts +6 -0
- package/dist/http/endpoints/sign-out.mjs +7 -0
- package/dist/http/endpoints/sign-out.mjs.map +1 -0
- package/dist/http/endpoints/verify-email-otp.d.mts +9 -0
- package/dist/http/endpoints/verify-email-otp.mjs +18 -0
- package/dist/http/endpoints/verify-email-otp.mjs.map +1 -0
- package/dist/http/models.d.mts +49 -0
- package/dist/http/models.mjs +35 -0
- package/dist/http/models.mjs.map +1 -0
- package/dist/http/security.d.mts +91 -0
- package/dist/http/security.mjs +77 -0
- package/dist/http/security.mjs.map +1 -0
- package/dist/http/session-contract.d.mts +303 -0
- package/dist/http/session-contract.mjs +38 -0
- package/dist/http/session-contract.mjs.map +1 -0
- package/dist/http-operation/OperationHttpInvocation.d.mts +16 -0
- package/dist/http-operation/OperationHttpInvocation.mjs +11 -0
- package/dist/http-operation/OperationHttpInvocation.mjs.map +1 -0
- package/dist/http-operation/OperationHttpServerConfig.d.mts +18 -0
- package/dist/http-operation/OperationHttpServerConfig.mjs +72 -0
- package/dist/http-operation/OperationHttpServerConfig.mjs.map +1 -0
- package/dist/http-operation/auth-client.d.mts +75 -0
- package/dist/http-operation/auth-client.mjs +116 -0
- package/dist/http-operation/auth-client.mjs.map +1 -0
- package/dist/http-operation/client.d.mts +50 -0
- package/dist/http-operation/client.mjs +188 -0
- package/dist/http-operation/client.mjs.map +1 -0
- package/dist/http-operation/configuration-schema.mjs +19 -0
- package/dist/http-operation/configuration-schema.mjs.map +1 -0
- package/dist/http-operation/contract.d.mts +40 -0
- package/dist/http-operation/contract.mjs +37 -0
- package/dist/http-operation/contract.mjs.map +1 -0
- package/dist/http-operation/errors.d.mts +13 -0
- package/dist/http-operation/errors.mjs +31 -0
- package/dist/http-operation/errors.mjs.map +1 -0
- package/dist/http-operation/models.d.mts +32 -0
- package/dist/http-operation/models.mjs +14 -0
- package/dist/http-operation/models.mjs.map +1 -0
- package/dist/http-operation/private.mjs +35 -0
- package/dist/http-operation/private.mjs.map +1 -0
- package/dist/http-operation/security.mjs +58 -0
- package/dist/http-operation/security.mjs.map +1 -0
- package/dist/http-operation/server.d.mts +33 -0
- package/dist/http-operation/server.mjs +268 -0
- package/dist/http-operation/server.mjs.map +1 -0
- package/dist/identity/ExternalIdentityMutation.d.mts +15 -0
- package/dist/identity/ExternalIdentityMutation.mjs +11 -0
- package/dist/identity/ExternalIdentityMutation.mjs.map +1 -0
- package/dist/identity/IdentityMutation.d.mts +22 -0
- package/dist/identity/IdentityMutation.mjs +17 -0
- package/dist/identity/IdentityMutation.mjs.map +1 -0
- package/dist/identity/IdentityRepository.d.mts +20 -0
- package/dist/identity/IdentityRepository.mjs +11 -0
- package/dist/identity/IdentityRepository.mjs.map +1 -0
- package/dist/identity/SubjectLifecycle.d.mts +58 -0
- package/dist/identity/SubjectLifecycle.mjs +43 -0
- package/dist/identity/SubjectLifecycle.mjs.map +1 -0
- package/dist/identity/SubjectProvisioner.d.mts +37 -0
- package/dist/identity/SubjectProvisioner.mjs +20 -0
- package/dist/identity/SubjectProvisioner.mjs.map +1 -0
- package/dist/identity/codecs.d.mts +34 -0
- package/dist/identity/codecs.mjs +40 -0
- package/dist/identity/codecs.mjs.map +1 -0
- package/dist/identity/models.d.mts +62 -0
- package/dist/identity/models.mjs +51 -0
- package/dist/identity/models.mjs.map +1 -0
- package/dist/identity/operations.d.mts +118 -0
- package/dist/identity/operations.mjs +124 -0
- package/dist/identity/operations.mjs.map +1 -0
- package/dist/index.d.mts +23 -0
- package/dist/index.mjs +23 -0
- package/dist/internal/AuthStoreDecisions.d.mts +22 -0
- package/dist/internal/AuthStoreDecisions.mjs +8 -0
- package/dist/internal/AuthStoreDecisions.mjs.map +1 -0
- package/dist/internal/CurrentSession.d.mts +9 -0
- package/dist/internal/CurrentSession.mjs +8 -0
- package/dist/internal/CurrentSession.mjs.map +1 -0
- package/dist/internal/diagnostics.mjs +23 -0
- package/dist/internal/diagnostics.mjs.map +1 -0
- package/dist/oauth/GithubOAuthProvider.d.mts +43 -0
- package/dist/oauth/GithubOAuthProvider.mjs +66 -0
- package/dist/oauth/GithubOAuthProvider.mjs.map +1 -0
- package/dist/oauth/OAuth.d.mts +73 -0
- package/dist/oauth/OAuth.mjs +180 -0
- package/dist/oauth/OAuth.mjs.map +1 -0
- package/dist/oauth/OAuthAccountsPersistence.d.mts +109 -0
- package/dist/oauth/OAuthAccountsPersistence.mjs +12 -0
- package/dist/oauth/OAuthAccountsPersistence.mjs.map +1 -0
- package/dist/oauth/OAuthActionEvidence.d.mts +28 -0
- package/dist/oauth/OAuthActionEvidence.mjs +15 -0
- package/dist/oauth/OAuthActionEvidence.mjs.map +1 -0
- package/dist/oauth/OAuthConnectedActionEvidence.d.mts +22 -0
- package/dist/oauth/OAuthConnectedActionEvidence.mjs +9 -0
- package/dist/oauth/OAuthConnectedActionEvidence.mjs.map +1 -0
- package/dist/oauth/OAuthConnectedPersistence.d.mts +129 -0
- package/dist/oauth/OAuthConnectedPersistence.mjs +12 -0
- package/dist/oauth/OAuthConnectedPersistence.mjs.map +1 -0
- package/dist/oauth/OAuthConnectedProtocol.d.mts +41 -0
- package/dist/oauth/OAuthConnectedProtocol.mjs +13 -0
- package/dist/oauth/OAuthConnectedProtocol.mjs.map +1 -0
- package/dist/oauth/OAuthConnectedRevocations.d.mts +167 -0
- package/dist/oauth/OAuthConnectedRevocations.mjs +21 -0
- package/dist/oauth/OAuthConnectedRevocations.mjs.map +1 -0
- package/dist/oauth/OAuthConnectedTokenProtector.d.mts +24 -0
- package/dist/oauth/OAuthConnectedTokenProtector.mjs +153 -0
- package/dist/oauth/OAuthConnectedTokenProtector.mjs.map +1 -0
- package/dist/oauth/OAuthConnectedTransactionProtector.d.mts +23 -0
- package/dist/oauth/OAuthConnectedTransactionProtector.mjs +37 -0
- package/dist/oauth/OAuthConnectedTransactionProtector.mjs.map +1 -0
- package/dist/oauth/OAuthConnectedUseAuthority.d.mts +22 -0
- package/dist/oauth/OAuthConnectedUseAuthority.mjs +10 -0
- package/dist/oauth/OAuthConnectedUseAuthority.mjs.map +1 -0
- package/dist/oauth/OAuthConnectionStore.d.mts +33 -0
- package/dist/oauth/OAuthConnectionStore.mjs +38 -0
- package/dist/oauth/OAuthConnectionStore.mjs.map +1 -0
- package/dist/oauth/OAuthLinkTransactionProtector.d.mts +25 -0
- package/dist/oauth/OAuthLinkTransactionProtector.mjs +39 -0
- package/dist/oauth/OAuthLinkTransactionProtector.mjs.map +1 -0
- package/dist/oauth/OAuthProtocol.d.mts +33 -0
- package/dist/oauth/OAuthProtocol.mjs +16 -0
- package/dist/oauth/OAuthProtocol.mjs.map +1 -0
- package/dist/oauth/OAuthProvider.d.mts +70 -0
- package/dist/oauth/OAuthProvider.mjs +39 -0
- package/dist/oauth/OAuthProvider.mjs.map +1 -0
- package/dist/oauth/OAuthProviders.d.mts +27 -0
- package/dist/oauth/OAuthProviders.mjs +33 -0
- package/dist/oauth/OAuthProviders.mjs.map +1 -0
- package/dist/oauth/OAuthRegistrationIntents.d.mts +87 -0
- package/dist/oauth/OAuthRegistrationIntents.mjs +19 -0
- package/dist/oauth/OAuthRegistrationIntents.mjs.map +1 -0
- package/dist/oauth/OAuthReturnTargets.d.mts +15 -0
- package/dist/oauth/OAuthReturnTargets.mjs +24 -0
- package/dist/oauth/OAuthReturnTargets.mjs.map +1 -0
- package/dist/oauth/OAuthSignInPersistence.d.mts +68 -0
- package/dist/oauth/OAuthSignInPersistence.mjs +12 -0
- package/dist/oauth/OAuthSignInPersistence.mjs.map +1 -0
- package/dist/oauth/OAuthStateDecisions.d.mts +14 -0
- package/dist/oauth/OAuthStateDecisions.mjs +8 -0
- package/dist/oauth/OAuthStateDecisions.mjs.map +1 -0
- package/dist/oauth/OAuthStateStore.d.mts +35 -0
- package/dist/oauth/OAuthStateStore.mjs +64 -0
- package/dist/oauth/OAuthStateStore.mjs.map +1 -0
- package/dist/oauth/OAuthTransactionProtector.d.mts +26 -0
- package/dist/oauth/OAuthTransactionProtector.mjs +78 -0
- package/dist/oauth/OAuthTransactionProtector.mjs.map +1 -0
- package/dist/oauth/accounts.d.mts +29 -0
- package/dist/oauth/accounts.mjs +515 -0
- package/dist/oauth/accounts.mjs.map +1 -0
- package/dist/oauth/accountsModels.d.mts +463 -0
- package/dist/oauth/accountsModels.mjs +155 -0
- package/dist/oauth/accountsModels.mjs.map +1 -0
- package/dist/oauth/connected.d.mts +442 -0
- package/dist/oauth/connected.mjs +526 -0
- package/dist/oauth/connected.mjs.map +1 -0
- package/dist/oauth/connectedAccess.d.mts +20 -0
- package/dist/oauth/connectedAccess.mjs +279 -0
- package/dist/oauth/connectedAccess.mjs.map +1 -0
- package/dist/oauth/connectedMaintenance.d.mts +19 -0
- package/dist/oauth/connectedMaintenance.mjs +133 -0
- package/dist/oauth/connectedMaintenance.mjs.map +1 -0
- package/dist/oauth/connectedModels.d.mts +2023 -0
- package/dist/oauth/connectedModels.mjs +375 -0
- package/dist/oauth/connectedModels.mjs.map +1 -0
- package/dist/oauth/definition.d.mts +4396 -0
- package/dist/oauth/definition.mjs +120 -0
- package/dist/oauth/definition.mjs.map +1 -0
- package/dist/oauth/errors.d.mts +49 -0
- package/dist/oauth/errors.mjs +42 -0
- package/dist/oauth/errors.mjs.map +1 -0
- package/dist/oauth/github/identity.d.mts +8 -0
- package/dist/oauth/github/identity.mjs +24 -0
- package/dist/oauth/github/identity.mjs.map +1 -0
- package/dist/oauth/github/models.d.mts +34 -0
- package/dist/oauth/github/protocol.d.mts +54 -0
- package/dist/oauth/github/protocol.mjs +204 -0
- package/dist/oauth/github/protocol.mjs.map +1 -0
- package/dist/oauth/openid-client/ProviderRevocation.d.mts +4 -0
- package/dist/oauth/openid-client/ProviderRevocation.mjs +11 -0
- package/dist/oauth/openid-client/ProviderRevocation.mjs.map +1 -0
- package/dist/oauth/openid-client/compatibility.d.mts +1 -0
- package/dist/oauth/openid-client/compatibility.mjs +6 -0
- package/dist/oauth/openid-client/compatibility.mjs.map +1 -0
- package/dist/oauth/openid-client/configuration.mjs +305 -0
- package/dist/oauth/openid-client/configuration.mjs.map +1 -0
- package/dist/oauth/openid-client/connected/configuration.mjs +338 -0
- package/dist/oauth/openid-client/connected/configuration.mjs.map +1 -0
- package/dist/oauth/openid-client/connected/models.d.mts +42 -0
- package/dist/oauth/openid-client/connected/protocol.d.mts +16 -0
- package/dist/oauth/openid-client/connected/protocol.mjs +402 -0
- package/dist/oauth/openid-client/connected/protocol.mjs.map +1 -0
- package/dist/oauth/openid-client/models.d.mts +67 -0
- package/dist/oauth/openid-client/models.mjs +16 -0
- package/dist/oauth/openid-client/models.mjs.map +1 -0
- package/dist/oauth/openid-client/protocol.d.mts +27 -0
- package/dist/oauth/openid-client/protocol.mjs +218 -0
- package/dist/oauth/openid-client/protocol.mjs.map +1 -0
- package/dist/oauth/openid-client/transport.mjs +59 -0
- package/dist/oauth/openid-client/transport.mjs.map +1 -0
- package/dist/oauth/policy.d.mts +18 -0
- package/dist/oauth/policy.mjs +16 -0
- package/dist/oauth/policy.mjs.map +1 -0
- package/dist/oauth/registration.d.mts +24 -0
- package/dist/oauth/registration.mjs +177 -0
- package/dist/oauth/registration.mjs.map +1 -0
- package/dist/oauth/registrationModels.d.mts +152 -0
- package/dist/oauth/registrationModels.mjs +93 -0
- package/dist/oauth/registrationModels.mjs.map +1 -0
- package/dist/oauth/registrationSecrets.mjs +70 -0
- package/dist/oauth/registrationSecrets.mjs.map +1 -0
- package/dist/oauth/schema.d.mts +86 -0
- package/dist/oauth/schema.mjs +81 -0
- package/dist/oauth/schema.mjs.map +1 -0
- package/dist/oauth/signInErrors.d.mts +17 -0
- package/dist/oauth/signInErrors.mjs +16 -0
- package/dist/oauth/signInErrors.mjs.map +1 -0
- package/dist/oauth/signInModels.d.mts +343 -0
- package/dist/oauth/signInModels.mjs +181 -0
- package/dist/oauth/signInModels.mjs.map +1 -0
- package/dist/oauth/signInModule.d.mts +1546 -0
- package/dist/oauth/signInModule.mjs +430 -0
- package/dist/oauth/signInModule.mjs.map +1 -0
- package/dist/oauth/signInSnapshot.mjs +29 -0
- package/dist/oauth/signInSnapshot.mjs.map +1 -0
- package/dist/oauth/transactionEncryption.d.mts +14 -0
- package/dist/oauth/transactionEncryption.mjs +129 -0
- package/dist/oauth/transactionEncryption.mjs.map +1 -0
- package/dist/operations/RequestBindingConfig.d.mts +11 -0
- package/dist/operations/RequestBindingConfig.mjs +10 -0
- package/dist/operations/RequestBindingConfig.mjs.map +1 -0
- package/dist/operations/actions.d.mts +947 -0
- package/dist/operations/actions.mjs +148 -0
- package/dist/operations/actions.mjs.map +1 -0
- package/dist/operations/context.d.mts +63 -0
- package/dist/operations/context.mjs +55 -0
- package/dist/operations/context.mjs.map +1 -0
- package/dist/operations/credentials.d.mts +39 -0
- package/dist/operations/credentials.mjs +60 -0
- package/dist/operations/credentials.mjs.map +1 -0
- package/dist/operations/errors.d.mts +24 -0
- package/dist/operations/errors.mjs +31 -0
- package/dist/operations/errors.mjs.map +1 -0
- package/dist/operations/operation.d.mts +124 -0
- package/dist/operations/operation.mjs +220 -0
- package/dist/operations/operation.mjs.map +1 -0
- package/dist/operations/requestBinding.d.mts +46 -0
- package/dist/operations/requestBinding.mjs +130 -0
- package/dist/operations/requestBinding.mjs.map +1 -0
- package/dist/operations/requestBindingModels.d.mts +13 -0
- package/dist/operations/requestBindingModels.mjs +12 -0
- package/dist/operations/requestBindingModels.mjs.map +1 -0
- package/dist/operations/reveals.d.mts +28 -0
- package/dist/operations/reveals.mjs +88 -0
- package/dist/operations/reveals.mjs.map +1 -0
- package/dist/passkey/PasskeyActionEvidence.d.mts +22 -0
- package/dist/passkey/PasskeyActionEvidence.mjs +9 -0
- package/dist/passkey/PasskeyActionEvidence.mjs.map +1 -0
- package/dist/passkey/PasskeyCredentials.d.mts +16 -0
- package/dist/passkey/PasskeyCredentials.mjs +9 -0
- package/dist/passkey/PasskeyCredentials.mjs.map +1 -0
- package/dist/passkey/PasskeyEnrollmentContext.d.mts +22 -0
- package/dist/passkey/PasskeyEnrollmentContext.mjs +9 -0
- package/dist/passkey/PasskeyEnrollmentContext.mjs.map +1 -0
- package/dist/passkey/PasskeyManagementPersistence.d.mts +106 -0
- package/dist/passkey/PasskeyManagementPersistence.mjs +9 -0
- package/dist/passkey/PasskeyManagementPersistence.mjs.map +1 -0
- package/dist/passkey/PasskeyPersistence.d.mts +63 -0
- package/dist/passkey/PasskeyPersistence.mjs +10 -0
- package/dist/passkey/PasskeyPersistence.mjs.map +1 -0
- package/dist/passkey/PasskeyProtocol.d.mts +38 -0
- package/dist/passkey/PasskeyProtocol.mjs +11 -0
- package/dist/passkey/PasskeyProtocol.mjs.map +1 -0
- package/dist/passkey/actions.d.mts +50 -0
- package/dist/passkey/actions.mjs +376 -0
- package/dist/passkey/actions.mjs.map +1 -0
- package/dist/passkey/browser/PasskeyBrowser.d.mts +18 -0
- package/dist/passkey/browser/PasskeyBrowser.mjs +9 -0
- package/dist/passkey/browser/PasskeyBrowser.mjs.map +1 -0
- package/dist/passkey/browser/models.d.mts +38 -0
- package/dist/passkey/browser/models.mjs +41 -0
- package/dist/passkey/browser/models.mjs.map +1 -0
- package/dist/passkey/browser/simplewebauthn.d.mts +17 -0
- package/dist/passkey/browser/simplewebauthn.mjs +411 -0
- package/dist/passkey/browser/simplewebauthn.mjs.map +1 -0
- package/dist/passkey/definition.d.mts +5626 -0
- package/dist/passkey/definition.mjs +114 -0
- package/dist/passkey/definition.mjs.map +1 -0
- package/dist/passkey/errors.d.mts +20 -0
- package/dist/passkey/errors.mjs +20 -0
- package/dist/passkey/errors.mjs.map +1 -0
- package/dist/passkey/management.mjs +276 -0
- package/dist/passkey/management.mjs.map +1 -0
- package/dist/passkey/models.d.mts +1245 -0
- package/dist/passkey/models.mjs +301 -0
- package/dist/passkey/models.mjs.map +1 -0
- package/dist/passkey/module.d.mts +2132 -0
- package/dist/passkey/module.mjs +174 -0
- package/dist/passkey/module.mjs.map +1 -0
- package/dist/passkey/pending.mjs +99 -0
- package/dist/passkey/pending.mjs.map +1 -0
- package/dist/passkey/policy.d.mts +48 -0
- package/dist/passkey/policy.mjs +77 -0
- package/dist/passkey/policy.mjs.map +1 -0
- package/dist/passkey/registration.mjs +107 -0
- package/dist/passkey/registration.mjs.map +1 -0
- package/dist/passkey/simplewebauthn/configuration.mjs +45 -0
- package/dist/passkey/simplewebauthn/configuration.mjs.map +1 -0
- package/dist/passkey/simplewebauthn/models.d.mts +21 -0
- package/dist/passkey/simplewebauthn/models.mjs +8 -0
- package/dist/passkey/simplewebauthn/models.mjs.map +1 -0
- package/dist/passkey/simplewebauthn/protocol.d.mts +62 -0
- package/dist/passkey/simplewebauthn/protocol.mjs +402 -0
- package/dist/passkey/simplewebauthn/protocol.mjs.map +1 -0
- package/dist/passkey/snapshot.mjs +31 -0
- package/dist/passkey/snapshot.mjs.map +1 -0
- package/dist/passkey/stepUp.mjs +101 -0
- package/dist/passkey/stepUp.mjs.map +1 -0
- package/dist/password/CompromisedPasswords.d.mts +26 -0
- package/dist/password/CompromisedPasswords.mjs +23 -0
- package/dist/password/CompromisedPasswords.mjs.map +1 -0
- package/dist/password/NewPasswordCheck.d.mts +21 -0
- package/dist/password/NewPasswordCheck.mjs +39 -0
- package/dist/password/NewPasswordCheck.mjs.map +1 -0
- package/dist/password/PasswordHashing.d.mts +24 -0
- package/dist/password/PasswordHashing.mjs +96 -0
- package/dist/password/PasswordHashing.mjs.map +1 -0
- package/dist/password/PasswordKdfAdmission.d.mts +19 -0
- package/dist/password/PasswordKdfAdmission.mjs +25 -0
- package/dist/password/PasswordKdfAdmission.mjs.map +1 -0
- package/dist/password/configuration.d.mts +43 -0
- package/dist/password/configuration.mjs +64 -0
- package/dist/password/configuration.mjs.map +1 -0
- package/dist/password/defaults.mjs +13 -0
- package/dist/password/defaults.mjs.map +1 -0
- package/dist/password/encoding.mjs +64 -0
- package/dist/password/encoding.mjs.map +1 -0
- package/dist/password/errors.d.mts +28 -0
- package/dist/password/errors.mjs +25 -0
- package/dist/password/errors.mjs.map +1 -0
- package/dist/password/methods/PasswordActionEvidence.d.mts +38 -0
- package/dist/password/methods/PasswordActionEvidence.mjs +22 -0
- package/dist/password/methods/PasswordActionEvidence.mjs.map +1 -0
- package/dist/password/methods/PasswordPersistence.d.mts +102 -0
- package/dist/password/methods/PasswordPersistence.mjs +13 -0
- package/dist/password/methods/PasswordPersistence.mjs.map +1 -0
- package/dist/password/methods/PasswordPreparedPersistence.d.mts +111 -0
- package/dist/password/methods/contracts.d.mts +43 -0
- package/dist/password/methods/contracts.mjs +33 -0
- package/dist/password/methods/contracts.mjs.map +1 -0
- package/dist/password/methods/definition.d.mts +3813 -0
- package/dist/password/methods/definition.mjs +56 -0
- package/dist/password/methods/definition.mjs.map +1 -0
- package/dist/password/methods/errors.d.mts +15 -0
- package/dist/password/methods/errors.mjs +11 -0
- package/dist/password/methods/errors.mjs.map +1 -0
- package/dist/password/methods/models.d.mts +70 -0
- package/dist/password/methods/models.mjs +44 -0
- package/dist/password/methods/models.mjs.map +1 -0
- package/dist/password/methods/module.d.mts +3567 -0
- package/dist/password/methods/module.mjs +553 -0
- package/dist/password/methods/module.mjs.map +1 -0
- package/dist/password/methods/policy.d.mts +84 -0
- package/dist/password/methods/policy.mjs +80 -0
- package/dist/password/methods/policy.mjs.map +1 -0
- package/dist/password/methods/preparation.mjs +54 -0
- package/dist/password/methods/preparation.mjs.map +1 -0
- package/dist/password/methods/prepared.d.mts +53 -0
- package/dist/password/methods/prepared.mjs +610 -0
- package/dist/password/methods/prepared.mjs.map +1 -0
- package/dist/password/methods/preparedModels.d.mts +1295 -0
- package/dist/password/methods/preparedModels.mjs +278 -0
- package/dist/password/methods/preparedModels.mjs.map +1 -0
- package/dist/password/methods/signIn.d.mts +180 -0
- package/dist/password/methods/signIn.mjs +73 -0
- package/dist/password/methods/signIn.mjs.map +1 -0
- package/dist/password/methods/snapshot.mjs +38 -0
- package/dist/password/methods/snapshot.mjs.map +1 -0
- package/dist/password/methods/verification.mjs +138 -0
- package/dist/password/methods/verification.mjs.map +1 -0
- package/dist/password/models.d.mts +13 -0
- package/dist/password/models.mjs +12 -0
- package/dist/password/models.mjs.map +1 -0
- package/dist/password/policy.d.mts +33 -0
- package/dist/password/policy.mjs +37 -0
- package/dist/password/policy.mjs.map +1 -0
- package/dist/phone/PhoneActionEvidence.d.mts +23 -0
- package/dist/phone/PhoneActionEvidence.mjs +10 -0
- package/dist/phone/PhoneActionEvidence.mjs.map +1 -0
- package/dist/phone/PhoneAdmission.d.mts +29 -0
- package/dist/phone/PhoneAdmission.mjs +10 -0
- package/dist/phone/PhoneAdmission.mjs.map +1 -0
- package/dist/phone/PhoneDeliveryEligibility.d.mts +11 -0
- package/dist/phone/PhoneDeliveryEligibility.mjs +8 -0
- package/dist/phone/PhoneDeliveryEligibility.mjs.map +1 -0
- package/dist/phone/PhonePersistence.d.mts +33 -0
- package/dist/phone/PhonePersistence.mjs +10 -0
- package/dist/phone/PhonePersistence.mjs.map +1 -0
- package/dist/phone/PhoneRequestContext.d.mts +10 -0
- package/dist/phone/PhoneRequestContext.mjs +8 -0
- package/dist/phone/PhoneRequestContext.mjs.map +1 -0
- package/dist/phone/PhoneSignInTargets.d.mts +19 -0
- package/dist/phone/PhoneSignInTargets.mjs +13 -0
- package/dist/phone/PhoneSignInTargets.mjs.map +1 -0
- package/dist/phone/definition.d.mts +7190 -0
- package/dist/phone/definition.mjs +28 -0
- package/dist/phone/definition.mjs.map +1 -0
- package/dist/phone/failure.mjs +23 -0
- package/dist/phone/failure.mjs.map +1 -0
- package/dist/phone/lifecycle.mjs +427 -0
- package/dist/phone/lifecycle.mjs.map +1 -0
- package/dist/phone/lifecycleModels.d.mts +164 -0
- package/dist/phone/lifecycleModels.mjs +91 -0
- package/dist/phone/lifecycleModels.mjs.map +1 -0
- package/dist/phone/models.d.mts +41 -0
- package/dist/phone/models.mjs +29 -0
- package/dist/phone/models.mjs.map +1 -0
- package/dist/phone/module.d.mts +6027 -0
- package/dist/phone/module.mjs +293 -0
- package/dist/phone/module.mjs.map +1 -0
- package/dist/proofs/EmailProofDelivery.d.mts +13 -0
- package/dist/proofs/EmailProofDelivery.mjs +11 -0
- package/dist/proofs/EmailProofDelivery.mjs.map +1 -0
- package/dist/proofs/HostIngressLimiter.d.mts +20 -0
- package/dist/proofs/HostIngressLimiter.mjs +13 -0
- package/dist/proofs/HostIngressLimiter.mjs.map +1 -0
- package/dist/proofs/ProofPersistence.d.mts +140 -0
- package/dist/proofs/ProofPersistence.mjs +13 -0
- package/dist/proofs/ProofPersistence.mjs.map +1 -0
- package/dist/proofs/SmsProofDelivery.d.mts +13 -0
- package/dist/proofs/SmsProofDelivery.mjs +11 -0
- package/dist/proofs/SmsProofDelivery.mjs.map +1 -0
- package/dist/proofs/abuse.d.mts +15 -0
- package/dist/proofs/abuse.mjs +12 -0
- package/dist/proofs/abuse.mjs.map +1 -0
- package/dist/proofs/completion.d.mts +22 -0
- package/dist/proofs/crypto.d.mts +196 -0
- package/dist/proofs/crypto.mjs +189 -0
- package/dist/proofs/crypto.mjs.map +1 -0
- package/dist/proofs/definition.d.mts +335 -0
- package/dist/proofs/definition.mjs +10 -0
- package/dist/proofs/definition.mjs.map +1 -0
- package/dist/proofs/delivery.d.mts +30 -0
- package/dist/proofs/delivery.mjs +26 -0
- package/dist/proofs/delivery.mjs.map +1 -0
- package/dist/proofs/dispatch.d.mts +20 -0
- package/dist/proofs/dispatch.mjs +54 -0
- package/dist/proofs/dispatch.mjs.map +1 -0
- package/dist/proofs/errors.d.mts +21 -0
- package/dist/proofs/errors.mjs +25 -0
- package/dist/proofs/errors.mjs.map +1 -0
- package/dist/proofs/models.d.mts +141 -0
- package/dist/proofs/models.mjs +93 -0
- package/dist/proofs/models.mjs.map +1 -0
- package/dist/proofs/module.d.mts +344 -0
- package/dist/proofs/module.mjs +350 -0
- package/dist/proofs/module.mjs.map +1 -0
- package/dist/proofs/policy.d.mts +152 -0
- package/dist/proofs/policy.mjs +51 -0
- package/dist/proofs/policy.mjs.map +1 -0
- package/dist/sessions/AuthenticationAuthority.d.mts +31 -0
- package/dist/sessions/AuthenticationAuthority.mjs +8 -0
- package/dist/sessions/AuthenticationAuthority.mjs.map +1 -0
- package/dist/sessions/PendingAuthentication.d.mts +108 -0
- package/dist/sessions/PendingAuthentication.mjs +40 -0
- package/dist/sessions/PendingAuthentication.mjs.map +1 -0
- package/dist/sessions/SessionStepUpPersistence.d.mts +152 -0
- package/dist/sessions/SessionStepUpPersistence.mjs +63 -0
- package/dist/sessions/SessionStepUpPersistence.mjs.map +1 -0
- package/dist/sessions/assurance.d.mts +163 -0
- package/dist/sessions/assurance.mjs +95 -0
- package/dist/sessions/assurance.mjs.map +1 -0
- package/dist/sessions/commit.d.mts +13 -0
- package/dist/sessions/configuration.d.mts +46 -0
- package/dist/sessions/configuration.mjs +55 -0
- package/dist/sessions/configuration.mjs.map +1 -0
- package/dist/sessions/contract.d.mts +663 -0
- package/dist/sessions/contract.mjs +174 -0
- package/dist/sessions/contract.mjs.map +1 -0
- package/dist/sessions/crypto.d.mts +24 -0
- package/dist/sessions/crypto.mjs +106 -0
- package/dist/sessions/crypto.mjs.map +1 -0
- package/dist/sessions/definition.d.mts +11 -0
- package/dist/sessions/definition.mjs +10 -0
- package/dist/sessions/definition.mjs.map +1 -0
- package/dist/sessions/errors.d.mts +35 -0
- package/dist/sessions/errors.mjs +34 -0
- package/dist/sessions/errors.mjs.map +1 -0
- package/dist/sessions/invalidation.d.mts +23 -0
- package/dist/sessions/invalidation.mjs +33 -0
- package/dist/sessions/invalidation.mjs.map +1 -0
- package/dist/sessions/models.d.mts +143 -0
- package/dist/sessions/models.mjs +94 -0
- package/dist/sessions/models.mjs.map +1 -0
- package/dist/sessions/module.d.mts +1091 -0
- package/dist/sessions/module.mjs +943 -0
- package/dist/sessions/module.mjs.map +1 -0
- package/dist/sessions/persistence.d.mts +93 -0
- package/dist/sessions/policy.d.mts +80 -0
- package/dist/sessions/policy.mjs +66 -0
- package/dist/sessions/policy.mjs.map +1 -0
- package/dist/testing/conformance/AuthStore.d.mts +11 -0
- package/dist/testing/conformance/AuthStore.mjs +173 -0
- package/dist/testing/conformance/AuthStore.mjs.map +1 -0
- package/dist/testing/conformance/OAuthConnectionStore.d.mts +11 -0
- package/dist/testing/conformance/OAuthConnectionStore.mjs +102 -0
- package/dist/testing/conformance/OAuthConnectionStore.mjs.map +1 -0
- package/dist/testing/conformance/OAuthStateStore.d.mts +11 -0
- package/dist/testing/conformance/OAuthStateStore.mjs +45 -0
- package/dist/testing/conformance/OAuthStateStore.mjs.map +1 -0
- package/dist/testing/conformance/PasswordCredentialStore.d.mts +20 -0
- package/dist/testing/conformance/PasswordCredentialStore.mjs +103 -0
- package/dist/testing/conformance/PasswordCredentialStore.mjs.map +1 -0
- package/dist/testing/conformance/support.mjs +17 -0
- package/dist/testing/conformance/support.mjs.map +1 -0
- package/dist/testing/crypto.d.mts +11 -0
- package/dist/testing/crypto.mjs +41 -0
- package/dist/testing/crypto.mjs.map +1 -0
- package/dist/testing/keyring.d.mts +9 -0
- package/dist/testing/keyring.mjs +17 -0
- package/dist/testing/keyring.mjs.map +1 -0
- package/dist/totp/TotpActionEvidence.d.mts +18 -0
- package/dist/totp/TotpActionEvidence.mjs +8 -0
- package/dist/totp/TotpActionEvidence.mjs.map +1 -0
- package/dist/totp/TotpPersistence.d.mts +19 -0
- package/dist/totp/TotpPersistence.mjs +8 -0
- package/dist/totp/TotpPersistence.mjs.map +1 -0
- package/dist/totp/TotpSecretKeys.d.mts +15 -0
- package/dist/totp/TotpSecretKeys.mjs +8 -0
- package/dist/totp/TotpSecretKeys.mjs.map +1 -0
- package/dist/totp/crypto.mjs +96 -0
- package/dist/totp/crypto.mjs.map +1 -0
- package/dist/totp/definition.d.mts +764 -0
- package/dist/totp/definition.mjs +24 -0
- package/dist/totp/definition.mjs.map +1 -0
- package/dist/totp/errors.d.mts +16 -0
- package/dist/totp/errors.mjs +18 -0
- package/dist/totp/errors.mjs.map +1 -0
- package/dist/totp/models.d.mts +377 -0
- package/dist/totp/models.mjs +137 -0
- package/dist/totp/models.mjs.map +1 -0
- package/dist/totp/module.d.mts +737 -0
- package/dist/totp/module.mjs +355 -0
- package/dist/totp/module.mjs.map +1 -0
- package/package.json +1 -0
- package/src/Atom.ts +4 -0
- package/src/Auth.ts +16 -0
- package/src/AuthContract.ts +17 -0
- package/src/AuthSession.ts +298 -0
- package/src/AuthStore.ts +367 -0
- package/src/AuthTokenCodec.ts +226 -0
- package/src/Client.ts +9 -0
- package/src/Cloudflare.ts +345 -0
- package/src/Drizzle.ts +378 -0
- package/src/DrizzleD1.ts +136 -0
- package/src/DrizzleLibsql.ts +288 -0
- package/src/DrizzleMysql2.ts +184 -0
- package/src/DrizzlePglite.ts +160 -0
- package/src/DrizzlePostgres.ts +160 -0
- package/src/DrizzleSqliteBun.ts +244 -0
- package/src/DrizzleSqliteDo.ts +473 -0
- package/src/DrizzleSqliteNode.ts +245 -0
- package/src/DrizzleSqliteWasm.ts +245 -0
- package/src/Email.ts +55 -0
- package/src/EmailOtp.ts +250 -0
- package/src/EmailOtpSender.ts +28 -0
- package/src/Errors.ts +103 -0
- package/src/GitHub.ts +16 -0
- package/src/Hooks.ts +50 -0
- package/src/Http.ts +47 -0
- package/src/HttpServer.ts +742 -0
- package/src/Identity.ts +53 -0
- package/src/IdentityResolver.ts +18 -0
- package/src/OAuth.ts +242 -0
- package/src/OpenIdClient.ts +13 -0
- package/src/OpenIdClientConnected.ts +18 -0
- package/src/OperationHttp.ts +14 -0
- package/src/OperationHttpClient.ts +6 -0
- package/src/OperationHttpServer.ts +15 -0
- package/src/Operations.ts +69 -0
- package/src/Passkey.ts +81 -0
- package/src/PasskeyBrowser.ts +19 -0
- package/src/PasskeyContract.ts +212 -0
- package/src/PasskeyPassword.ts +319 -0
- package/src/PasskeySimpleWebAuthn.ts +6 -0
- package/src/Password.ts +113 -0
- package/src/PasswordAuth.ts +197 -0
- package/src/PasswordCredentialStore.ts +140 -0
- package/src/PasswordHasher.ts +147 -0
- package/src/PhoneOtp.ts +32 -0
- package/src/Policy.ts +95 -0
- package/src/Proofs.ts +71 -0
- package/src/Rpc.ts +15 -0
- package/src/Schema.ts +235 -0
- package/src/SessionContract.ts +2 -0
- package/src/Sessions.ts +105 -0
- package/src/Testing.ts +24 -0
- package/src/Totp.ts +28 -0
- package/src/TotpContract.ts +147 -0
- package/src/WebCrypto.ts +61 -0
- package/src/Workflows.ts +12 -0
- package/src/atom/AuthAtomLifetime.ts +87 -0
- package/src/atom/AuthAtomWorkflow.ts +27 -0
- package/src/atom/client.ts +364 -0
- package/src/atom/operations.ts +183 -0
- package/src/atom/scoped-runtime.ts +249 -0
- package/src/auth/Auth.ts +482 -0
- package/src/auth/AuthConfigurationError.ts +9 -0
- package/src/auth/AuthRequest.ts +21 -0
- package/src/auth/AuthStrategy.ts +116 -0
- package/src/auth/ConsumeDecision.ts +4 -0
- package/src/auth/actions.ts +220 -0
- package/src/auth/defaults.ts +23 -0
- package/src/auth/definition.ts +88 -0
- package/src/auth/session.ts +146 -0
- package/src/drizzle/D1BatchStatements.ts +10 -0
- package/src/drizzle/PasswordPreparedPostconditions.ts +30 -0
- package/src/drizzle/SuppliedService.ts +10 -0
- package/src/drizzle/d1-emails.ts +1808 -0
- package/src/drizzle/d1-generated-statement.ts +129 -0
- package/src/drizzle/d1-identity.ts +374 -0
- package/src/drizzle/d1-oauth.ts +338 -0
- package/src/drizzle/d1-passkey.ts +371 -0
- package/src/drizzle/d1-password-prepared.ts +1273 -0
- package/src/drizzle/d1-passwords.ts +2661 -0
- package/src/drizzle/d1-phone.ts +94 -0
- package/src/drizzle/d1-planning.ts +105 -0
- package/src/drizzle/d1-proofs.ts +2305 -0
- package/src/drizzle/d1-sessions.ts +2867 -0
- package/src/drizzle/d1-totp.ts +79 -0
- package/src/drizzle/email-model.ts +512 -0
- package/src/drizzle/email-registration.ts +696 -0
- package/src/drizzle/email-sql.ts +1468 -0
- package/src/drizzle/email-target.ts +243 -0
- package/src/drizzle/model.ts +492 -0
- package/src/drizzle/mysql-emails.ts +323 -0
- package/src/drizzle/mysql-identity.ts +323 -0
- package/src/drizzle/mysql-password-prepared.ts +206 -0
- package/src/drizzle/mysql-passwords.ts +341 -0
- package/src/drizzle/mysql-proofs.ts +183 -0
- package/src/drizzle/mysql-sessions.ts +742 -0
- package/src/drizzle/mysql.ts +686 -0
- package/src/drizzle/oauth-accounts.ts +801 -0
- package/src/drizzle/oauth-connected-access.ts +354 -0
- package/src/drizzle/oauth-connected-collection.ts +324 -0
- package/src/drizzle/oauth-connected-custody.ts +277 -0
- package/src/drizzle/oauth-connected-drivers.ts +463 -0
- package/src/drizzle/oauth-connected-flow.ts +439 -0
- package/src/drizzle/oauth-connected-input.ts +128 -0
- package/src/drizzle/oauth-connected-maintenance.ts +345 -0
- package/src/drizzle/oauth-connected-management.ts +365 -0
- package/src/drizzle/oauth-connected-model.ts +347 -0
- package/src/drizzle/oauth-connected-reference.ts +112 -0
- package/src/drizzle/oauth-connected-settlement.ts +226 -0
- package/src/drizzle/oauth-connected-state.ts +846 -0
- package/src/drizzle/oauth-connected-target.ts +264 -0
- package/src/drizzle/oauth-drivers.ts +567 -0
- package/src/drizzle/oauth-flow.ts +461 -0
- package/src/drizzle/oauth-input.ts +205 -0
- package/src/drizzle/oauth-model.ts +610 -0
- package/src/drizzle/oauth-mysql.ts +10 -0
- package/src/drizzle/oauth-owner.ts +29 -0
- package/src/drizzle/oauth-registration.ts +638 -0
- package/src/drizzle/oauth-state.ts +213 -0
- package/src/drizzle/oauth-target.ts +751 -0
- package/src/drizzle/passkey-admission.ts +333 -0
- package/src/drizzle/passkey-credentials.ts +465 -0
- package/src/drizzle/passkey-drivers.ts +385 -0
- package/src/drizzle/passkey-enrollment.ts +280 -0
- package/src/drizzle/passkey-flow.ts +983 -0
- package/src/drizzle/passkey-management.ts +369 -0
- package/src/drizzle/passkey-model.ts +350 -0
- package/src/drizzle/passkey-registration-ceremony-model.ts +69 -0
- package/src/drizzle/passkey-registration-ceremony.ts +254 -0
- package/src/drizzle/passkey-registration-custody.ts +82 -0
- package/src/drizzle/passkey-registration-write.ts +378 -0
- package/src/drizzle/passkey-state.ts +307 -0
- package/src/drizzle/passkey-target.ts +528 -0
- package/src/drizzle/passkey-write-drivers.ts +396 -0
- package/src/drizzle/passkey-write-model.ts +265 -0
- package/src/drizzle/passkey-write-state.ts +627 -0
- package/src/drizzle/passkey-write-target.ts +406 -0
- package/src/drizzle/password-model.ts +491 -0
- package/src/drizzle/password-prepared-model.ts +259 -0
- package/src/drizzle/password-prepared-sql.ts +1198 -0
- package/src/drizzle/password-prepared-state.ts +232 -0
- package/src/drizzle/password-prepared-target.ts +158 -0
- package/src/drizzle/password-registration.ts +372 -0
- package/src/drizzle/password-sql.ts +2082 -0
- package/src/drizzle/password-target.ts +223 -0
- package/src/drizzle/pg-emails.ts +323 -0
- package/src/drizzle/pg-password-prepared.ts +207 -0
- package/src/drizzle/pg-passwords.ts +340 -0
- package/src/drizzle/pg-proofs.ts +193 -0
- package/src/drizzle/pg-sessions.ts +751 -0
- package/src/drizzle/pg.ts +982 -0
- package/src/drizzle/phone-model.ts +185 -0
- package/src/drizzle/phone-state.ts +802 -0
- package/src/drizzle/phone-target.ts +471 -0
- package/src/drizzle/proof-model.ts +398 -0
- package/src/drizzle/proof-sql.ts +1912 -0
- package/src/drizzle/proof-target.ts +120 -0
- package/src/drizzle/session-model.ts +368 -0
- package/src/drizzle/session-sql.ts +2152 -0
- package/src/drizzle/session-target.ts +335 -0
- package/src/drizzle/sqlite-emails.ts +368 -0
- package/src/drizzle/sqlite-identity.ts +343 -0
- package/src/drizzle/sqlite-password-prepared.ts +262 -0
- package/src/drizzle/sqlite-passwords.ts +499 -0
- package/src/drizzle/sqlite-proofs.ts +204 -0
- package/src/drizzle/sqlite-sessions.ts +972 -0
- package/src/drizzle/sqlite.ts +704 -0
- package/src/drizzle/standalone-guard.ts +38 -0
- package/src/drizzle/step-up-model.ts +129 -0
- package/src/drizzle/step-up-state.ts +141 -0
- package/src/drizzle/totp-model.ts +91 -0
- package/src/drizzle/totp-state.ts +520 -0
- package/src/drizzle/totp-target.ts +304 -0
- package/src/drizzle/transaction-execution.ts +290 -0
- package/src/drizzle/transaction-mysql.ts +104 -0
- package/src/drizzle/transaction-owner.ts +570 -0
- package/src/email/EmailActionEvidence.ts +37 -0
- package/src/email/EmailAddressPersistence.ts +71 -0
- package/src/email/EmailIdentifierNotifier.ts +48 -0
- package/src/email/EmailReturnTargets.ts +50 -0
- package/src/email/EmailSignInTargets.ts +20 -0
- package/src/email/addresses.ts +630 -0
- package/src/email/definition.ts +309 -0
- package/src/email/errors.ts +23 -0
- package/src/email/magicLink.ts +84 -0
- package/src/email/models.ts +50 -0
- package/src/email/module.ts +664 -0
- package/src/email/registration.ts +415 -0
- package/src/email/snapshot.ts +51 -0
- package/src/hooks/LifecycleHooks.ts +136 -0
- package/src/hooks/commit.ts +271 -0
- package/src/hooks/models.ts +111 -0
- package/src/hooks/plugins.ts +87 -0
- package/src/hooks/transactions.ts +51 -0
- package/src/http/auth-api.ts +17 -0
- package/src/http/auth-contract.ts +148 -0
- package/src/http/auth-http.ts +467 -0
- package/src/http/endpoints/get-session.ts +9 -0
- package/src/http/endpoints/password-sign-in.ts +19 -0
- package/src/http/endpoints/request-email-otp.ts +10 -0
- package/src/http/endpoints/set-password.ts +18 -0
- package/src/http/endpoints/sign-out.ts +5 -0
- package/src/http/endpoints/verify-email-otp.ts +15 -0
- package/src/http/models.ts +80 -0
- package/src/http/security.ts +102 -0
- package/src/http/session-contract.ts +92 -0
- package/src/http-operation/OperationHttpInvocation.ts +39 -0
- package/src/http-operation/OperationHttpServerConfig.ts +124 -0
- package/src/http-operation/auth-client.ts +273 -0
- package/src/http-operation/client.ts +453 -0
- package/src/http-operation/configuration-schema.ts +19 -0
- package/src/http-operation/contract.ts +116 -0
- package/src/http-operation/errors.ts +38 -0
- package/src/http-operation/models.ts +42 -0
- package/src/http-operation/private.ts +50 -0
- package/src/http-operation/security.ts +93 -0
- package/src/http-operation/server.ts +544 -0
- package/src/identity/ExternalIdentityMutation.ts +18 -0
- package/src/identity/IdentityMutation.ts +41 -0
- package/src/identity/IdentityRepository.ts +37 -0
- package/src/identity/SubjectLifecycle.ts +80 -0
- package/src/identity/SubjectProvisioner.ts +40 -0
- package/src/identity/codecs.ts +54 -0
- package/src/identity/models.ts +82 -0
- package/src/identity/operations.ts +182 -0
- package/src/index.ts +23 -0
- package/src/internal/AuthStoreDecisions.ts +23 -0
- package/src/internal/CurrentSession.ts +8 -0
- package/src/internal/diagnostics.ts +71 -0
- package/src/oauth/GithubOAuthProvider.ts +106 -0
- package/src/oauth/OAuth.ts +436 -0
- package/src/oauth/OAuthAccountsPersistence.ts +142 -0
- package/src/oauth/OAuthActionEvidence.ts +31 -0
- package/src/oauth/OAuthConnectedActionEvidence.ts +28 -0
- package/src/oauth/OAuthConnectedPersistence.ts +163 -0
- package/src/oauth/OAuthConnectedProtocol.ts +54 -0
- package/src/oauth/OAuthConnectedRevocations.ts +48 -0
- package/src/oauth/OAuthConnectedTokenProtector.ts +240 -0
- package/src/oauth/OAuthConnectedTransactionProtector.ts +56 -0
- package/src/oauth/OAuthConnectedUseAuthority.ts +26 -0
- package/src/oauth/OAuthConnectionStore.ts +59 -0
- package/src/oauth/OAuthLinkTransactionProtector.ts +58 -0
- package/src/oauth/OAuthProtocol.ts +39 -0
- package/src/oauth/OAuthProvider.ts +126 -0
- package/src/oauth/OAuthProviders.ts +53 -0
- package/src/oauth/OAuthRegistrationIntents.ts +42 -0
- package/src/oauth/OAuthReturnTargets.ts +44 -0
- package/src/oauth/OAuthSignInPersistence.ts +91 -0
- package/src/oauth/OAuthStateDecisions.ts +16 -0
- package/src/oauth/OAuthStateStore.ts +102 -0
- package/src/oauth/OAuthTransactionProtector.ts +103 -0
- package/src/oauth/accounts.ts +987 -0
- package/src/oauth/accountsModels.ts +214 -0
- package/src/oauth/connected.ts +995 -0
- package/src/oauth/connectedAccess.ts +644 -0
- package/src/oauth/connectedMaintenance.ts +248 -0
- package/src/oauth/connectedModels.ts +495 -0
- package/src/oauth/definition.ts +414 -0
- package/src/oauth/errors.ts +78 -0
- package/src/oauth/github/identity.ts +26 -0
- package/src/oauth/github/models.ts +37 -0
- package/src/oauth/github/protocol.ts +329 -0
- package/src/oauth/openid-client/ProviderRevocation.ts +22 -0
- package/src/oauth/openid-client/compatibility.ts +47 -0
- package/src/oauth/openid-client/configuration.ts +472 -0
- package/src/oauth/openid-client/connected/configuration.ts +565 -0
- package/src/oauth/openid-client/connected/models.ts +58 -0
- package/src/oauth/openid-client/connected/protocol.ts +866 -0
- package/src/oauth/openid-client/models.ts +78 -0
- package/src/oauth/openid-client/protocol.ts +437 -0
- package/src/oauth/openid-client/transport.ts +67 -0
- package/src/oauth/policy.ts +26 -0
- package/src/oauth/registration.ts +410 -0
- package/src/oauth/registrationModels.ts +115 -0
- package/src/oauth/registrationSecrets.ts +127 -0
- package/src/oauth/schema.ts +102 -0
- package/src/oauth/signInErrors.ts +23 -0
- package/src/oauth/signInModels.ts +266 -0
- package/src/oauth/signInModule.ts +875 -0
- package/src/oauth/signInSnapshot.ts +37 -0
- package/src/oauth/transactionEncryption.ts +198 -0
- package/src/operations/RequestBindingConfig.ts +12 -0
- package/src/operations/actions.ts +342 -0
- package/src/operations/context.ts +130 -0
- package/src/operations/credentials.ts +121 -0
- package/src/operations/errors.ts +53 -0
- package/src/operations/operation.ts +740 -0
- package/src/operations/requestBinding.ts +237 -0
- package/src/operations/requestBindingModels.ts +18 -0
- package/src/operations/reveals.ts +147 -0
- package/src/passkey/PasskeyActionEvidence.ts +25 -0
- package/src/passkey/PasskeyCredentials.ts +16 -0
- package/src/passkey/PasskeyEnrollmentContext.ts +26 -0
- package/src/passkey/PasskeyManagementPersistence.ts +124 -0
- package/src/passkey/PasskeyPersistence.ts +85 -0
- package/src/passkey/PasskeyProtocol.ts +48 -0
- package/src/passkey/actions.ts +905 -0
- package/src/passkey/browser/PasskeyBrowser.ts +26 -0
- package/src/passkey/browser/models.ts +67 -0
- package/src/passkey/browser/simplewebauthn.ts +621 -0
- package/src/passkey/definition.ts +386 -0
- package/src/passkey/errors.ts +39 -0
- package/src/passkey/management.ts +552 -0
- package/src/passkey/models.ts +414 -0
- package/src/passkey/module.ts +367 -0
- package/src/passkey/pending.ts +203 -0
- package/src/passkey/policy.ts +88 -0
- package/src/passkey/registration.ts +251 -0
- package/src/passkey/simplewebauthn/configuration.ts +97 -0
- package/src/passkey/simplewebauthn/models.ts +9 -0
- package/src/passkey/simplewebauthn/protocol.ts +729 -0
- package/src/passkey/snapshot.ts +48 -0
- package/src/passkey/stepUp.ts +212 -0
- package/src/password/CompromisedPasswords.ts +36 -0
- package/src/password/NewPasswordCheck.ts +89 -0
- package/src/password/PasswordHashing.ts +209 -0
- package/src/password/PasswordKdfAdmission.ts +44 -0
- package/src/password/configuration.ts +52 -0
- package/src/password/defaults.ts +15 -0
- package/src/password/encoding.ts +137 -0
- package/src/password/errors.ts +43 -0
- package/src/password/methods/PasswordActionEvidence.ts +41 -0
- package/src/password/methods/PasswordPersistence.ts +128 -0
- package/src/password/methods/PasswordPreparedPersistence.ts +123 -0
- package/src/password/methods/contracts.ts +47 -0
- package/src/password/methods/definition.ts +199 -0
- package/src/password/methods/errors.ts +26 -0
- package/src/password/methods/models.ts +80 -0
- package/src/password/methods/module.ts +986 -0
- package/src/password/methods/policy.ts +68 -0
- package/src/password/methods/preparation.ts +73 -0
- package/src/password/methods/prepared.ts +1199 -0
- package/src/password/methods/preparedModels.ts +496 -0
- package/src/password/methods/signIn.ts +136 -0
- package/src/password/methods/snapshot.ts +53 -0
- package/src/password/methods/verification.ts +266 -0
- package/src/password/models.ts +15 -0
- package/src/password/policy.ts +41 -0
- package/src/phone/PhoneActionEvidence.ts +26 -0
- package/src/phone/PhoneAdmission.ts +29 -0
- package/src/phone/PhoneDeliveryEligibility.ts +9 -0
- package/src/phone/PhonePersistence.ts +43 -0
- package/src/phone/PhoneRequestContext.ts +7 -0
- package/src/phone/PhoneSignInTargets.ts +19 -0
- package/src/phone/definition.ts +87 -0
- package/src/phone/failure.ts +40 -0
- package/src/phone/lifecycle.ts +662 -0
- package/src/phone/lifecycleModels.ts +108 -0
- package/src/phone/models.ts +41 -0
- package/src/phone/module.ts +433 -0
- package/src/proofs/EmailProofDelivery.ts +19 -0
- package/src/proofs/HostIngressLimiter.ts +20 -0
- package/src/proofs/ProofPersistence.ts +172 -0
- package/src/proofs/SmsProofDelivery.ts +19 -0
- package/src/proofs/abuse.ts +23 -0
- package/src/proofs/completion.ts +23 -0
- package/src/proofs/crypto.ts +326 -0
- package/src/proofs/definition.ts +39 -0
- package/src/proofs/delivery.ts +73 -0
- package/src/proofs/dispatch.ts +99 -0
- package/src/proofs/errors.ts +46 -0
- package/src/proofs/models.ts +131 -0
- package/src/proofs/module.ts +620 -0
- package/src/proofs/policy.ts +77 -0
- package/src/sessions/AuthenticationAuthority.ts +51 -0
- package/src/sessions/PendingAuthentication.ts +121 -0
- package/src/sessions/SessionStepUpPersistence.ts +164 -0
- package/src/sessions/assurance.ts +192 -0
- package/src/sessions/commit.ts +13 -0
- package/src/sessions/configuration.ts +133 -0
- package/src/sessions/contract.ts +203 -0
- package/src/sessions/crypto.ts +181 -0
- package/src/sessions/definition.ts +25 -0
- package/src/sessions/errors.ts +68 -0
- package/src/sessions/invalidation.ts +46 -0
- package/src/sessions/models.ts +138 -0
- package/src/sessions/module.ts +1991 -0
- package/src/sessions/persistence.ts +135 -0
- package/src/sessions/policy.ts +103 -0
- package/src/testing/conformance/AuthStore.ts +314 -0
- package/src/testing/conformance/OAuthConnectionStore.ts +167 -0
- package/src/testing/conformance/OAuthStateStore.ts +105 -0
- package/src/testing/conformance/PasswordCredentialStore.ts +205 -0
- package/src/testing/conformance/support.ts +38 -0
- package/src/testing/crypto.ts +55 -0
- package/src/testing/keyring.ts +17 -0
- package/src/totp/TotpActionEvidence.ts +18 -0
- package/src/totp/TotpPersistence.ts +26 -0
- package/src/totp/TotpSecretKeys.ts +15 -0
- package/src/totp/crypto.ts +160 -0
- package/src/totp/definition.ts +78 -0
- package/src/totp/errors.ts +25 -0
- package/src/totp/models.ts +164 -0
- package/src/totp/module.ts +717 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction-execution.mjs","names":[],"sources":["../../src/drizzle/transaction-execution.ts"],"sourcesContent":["/* oxlint-disable no-explicit-any -- private execution bridge retains exact public driver wrappers. */\nimport { Context, Effect, Option } from \"effect\";\nimport type * as SqlClient from \"effect/unstable/sql/SqlClient\";\nimport type * as SqlError from \"effect/unstable/sql/SqlError\";\nimport type { Statement } from \"effect/unstable/sql/Statement\";\n\nimport { coordinateCommit, hasCommitScope, CurrentCommitJournal } from \"../hooks/commit\";\nimport type { LifecycleHooks } from \"../hooks/LifecycleHooks\";\nimport type { HookConfigurationError } from \"../hooks/models\";\nimport {\n makeTransactionOwner,\n reportTransactionFailure,\n type TransactionNativeDatabase,\n type TransactionOwner,\n} from \"./transaction-owner\";\n\nexport interface TransactionTargetConfiguration<Failure> {\n readonly mode: \"interactive\" | \"synchronous\" | \"batch\";\n readonly dialect: \"pg\" | \"mysql\" | \"sqlite\";\n readonly locking: boolean;\n readonly standaloneGuard: (database: any) => Effect.Effect<void, Failure>;\n readonly transaction?: <A, E, R>(\n database: any,\n body: (transaction: any) => Effect.Effect<A, E, R>,\n ) => Effect.Effect<A, E | SqlError.SqlError | Failure, R>;\n}\n\nexport type TransactionCoordinatorError<E, Failure> =\n | E\n | Failure\n | HookConfigurationError\n | SqlError.SqlError;\n\nexport const sqlClientTransactionStandaloneGuard = <Failure>(\n unavailable: () => Failure,\n database: {\n readonly $client: Pick<SqlClient.SqlClient, \"transactionService\">;\n },\n) =>\n Effect.serviceOption(database.$client.transactionService).pipe(\n Effect.flatMap(\n Option.match({ onNone: () => Effect.void, onSome: () => Effect.fail(unavailable()) }),\n ),\n );\n\nexport interface TransactionBound<Failure> {\n readonly owner: TransactionOwner<Failure>;\n used: boolean;\n poisoned: boolean;\n active: boolean;\n inFlight: number;\n}\n\nexport interface TransactionExecution<Failure, OwnerId, Requirements = LifecycleHooks> {\n readonly bound: boolean;\n readonly active: () => boolean;\n readonly admit: Effect.Effect<void, Failure>;\n readonly poison: () => void;\n readonly run: <A, E, R>(\n body: Effect.Effect<A, E, R>,\n mutation?: boolean,\n ) => Effect.Effect<A, Failure, Exclude<R, OwnerId | CurrentCommitJournal> | Requirements>;\n}\n\nexport const makeTransactionExecution = <Failure, OwnerId>(\n ownerTag: Context.Key<OwnerId, TransactionOwner<Failure>>,\n database: TransactionNativeDatabase,\n configuration: TransactionTargetConfiguration<Failure>,\n unavailable: () => Failure,\n nonce: () => string,\n bound?: TransactionBound<Failure>,\n): TransactionExecution<Failure, OwnerId> => {\n const invariant: (value: unknown) => asserts value = (value) => {\n if (!value) throw unavailable();\n };\n\n return {\n bound: bound !== undefined,\n active: () => bound === undefined || bound.active,\n admit:\n bound !== undefined\n ? Effect.suspend(() => (bound.active ? Effect.void : Effect.fail(unavailable())))\n : Effect.gen(function* () {\n if (yield* hasCommitScope) return yield* Effect.fail(unavailable());\n yield* configuration.standaloneGuard(database);\n }),\n poison: () => {\n if (bound !== undefined) bound.poisoned = true;\n },\n run: <A, E, R>(\n body: Effect.Effect<A, E, R>,\n mutation = true,\n ): Effect.Effect<A, Failure, Exclude<R, OwnerId | CurrentCommitJournal> | LifecycleHooks> => {\n return Effect.suspend(() => {\n let entered = false;\n\n const work =\n bound !== undefined\n ? Effect.gen(function* () {\n if (!bound.active) return yield* Effect.fail(unavailable());\n entered = true;\n bound.inFlight++;\n if (!mutation)\n return yield* Effect.provideContext(\n body,\n Context.make(ownerTag, bound.owner).pipe(\n Context.add(CurrentCommitJournal, bound.owner.journal),\n ),\n );\n invariant(!bound.used && !bound.poisoned);\n bound.used = true;\n\n const result = yield* coordinateCommit(\n (journal) =>\n Effect.gen(function* () {\n bound.owner.guards.push(journal.prepare(undefined));\n\n return yield* Effect.provideContext(\n body,\n Context.make(ownerTag, { ...bound.owner, journal }).pipe(\n Context.add(CurrentCommitJournal, journal),\n ),\n );\n }),\n { mode: configuration.mode },\n );\n\n return result.value;\n }).pipe(\n Effect.onExit((exit) =>\n Effect.sync(() => {\n if (entered) bound.inFlight--;\n if (exit._tag === \"Failure\") bound.poisoned = true;\n }),\n ),\n )\n : Effect.gen(function* () {\n if (yield* hasCommitScope) return yield* Effect.fail(unavailable());\n yield* configuration.standaloneGuard(database);\n const marker = nonce();\n\n const result = yield* coordinateCommit(\n (journal) => {\n const run = (tx: TransactionNativeDatabase) =>\n Effect.gen(function* () {\n const owner = makeTransactionOwner(tx, journal, marker, unavailable, {\n client: database.$client,\n batch: configuration.mode === \"batch\",\n locking: configuration.locking,\n mysql: configuration.dialect === \"mysql\",\n dialect: configuration.dialect,\n });\n\n const value = yield* Effect.provideContext(\n body,\n Context.make(ownerTag, owner).pipe(\n Context.add(CurrentCommitJournal, journal),\n ),\n );\n\n yield* owner.finish();\n if (configuration.mode === \"batch\")\n yield* tx.$client.batch(owner.statements);\n\n return value;\n });\n\n return configuration.mode === \"batch\"\n ? run(database)\n : configuration.transaction !== undefined\n ? configuration.transaction(database, run)\n : database.transaction(run);\n },\n { mode: configuration.mode },\n );\n\n return result.value;\n });\n\n return work.pipe(\n (operation) => reportTransactionFailure(operation, unavailable),\n Effect.mapError(unavailable),\n Effect.catchDefect(() => Effect.fail(unavailable())),\n );\n });\n },\n };\n};\n\nexport const coordinateTransactionOwner = <\n Failure,\n OwnerId,\n Resources,\n AllocationError,\n Services,\n Transaction,\n A,\n E,\n R,\n>(\n database: TransactionNativeDatabase,\n ownerTag: Context.Key<OwnerId, TransactionOwner<Failure>>,\n configuration: TransactionTargetConfiguration<Failure>,\n allocate: Effect.Effect<Resources, AllocationError>,\n unavailable: () => Failure,\n nonce: () => string,\n services: (execution: TransactionExecution<Failure, OwnerId>, resources: Resources) => Services,\n owner: (\n transaction: Transaction,\n services: Services,\n append: (statement: Statement<any>) => void,\n ) => Effect.Effect<A, E, R>,\n): Effect.Effect<\n A,\n TransactionCoordinatorError<E, Failure>,\n Exclude<R, CurrentCommitJournal> | LifecycleHooks\n> => {\n return Effect.gen(function* () {\n if (yield* hasCommitScope) return yield* Effect.fail(unavailable());\n yield* configuration.standaloneGuard(database);\n\n // Allocation is independent of registration data and always precedes the physical owner.\n const resources = yield* allocate.pipe(\n (operation) => reportTransactionFailure(operation, unavailable),\n Effect.mapError(unavailable),\n Effect.catchDefect(() => Effect.fail(unavailable())),\n );\n\n const marker = nonce();\n\n const result = yield* coordinateCommit(\n (journal) => {\n const run = (tx: TransactionNativeDatabase) =>\n Effect.gen(function* () {\n const state = makeTransactionOwner(tx, journal, marker, unavailable, {\n client: database.$client,\n batch: configuration.mode === \"batch\",\n dialect: configuration.dialect,\n mysql: configuration.dialect === \"mysql\",\n locking: configuration.locking,\n });\n\n const bound: TransactionBound<Failure> = {\n owner: state,\n used: false,\n poisoned: false,\n active: true,\n inFlight: 0,\n };\n\n return yield* Effect.gen(function* () {\n const value = yield* owner(\n tx as Transaction,\n services(\n makeTransactionExecution(ownerTag, tx, configuration, unavailable, nonce, bound),\n resources,\n ),\n (statement) => {\n if (!bound.active) throw unavailable();\n state.statements.push(statement);\n },\n );\n\n bound.active = false;\n if (bound.poisoned || bound.inFlight !== 0) return yield* Effect.fail(unavailable());\n yield* state.finish();\n if (configuration.mode === \"batch\") yield* tx.$client.batch(state.statements);\n\n return value;\n }).pipe(\n Effect.ensuring(\n Effect.sync(() => {\n bound.active = false;\n }),\n ),\n );\n });\n\n return configuration.mode === \"batch\"\n ? run(database)\n : configuration.transaction !== undefined\n ? configuration.transaction(database, run)\n : database.transaction(run);\n },\n { mode: configuration.mode },\n );\n\n return result.value as A;\n });\n};\n"],"mappings":";;;;AAiCA,MAAa,uCACX,aACA,aAIA,OAAO,cAAc,SAAS,QAAQ,kBAAkB,CAAC,CAAC,KACxD,OAAO,QACL,OAAO,MAAM;CAAE,cAAc,OAAO;CAAM,cAAc,OAAO,KAAK,YAAY,CAAC;AAAE,CAAC,CACtF,CACF;AAqBF,MAAa,4BACX,UACA,UACA,eACA,aACA,OACA,UAC2C;CAC3C,MAAM,aAAgD,UAAU;EAC9D,IAAI,CAAC,OAAO,MAAM,YAAY;CAChC;CAEA,OAAO;EACL,OAAO,UAAU,KAAA;EACjB,cAAc,UAAU,KAAA,KAAa,MAAM;EAC3C,OACE,UAAU,KAAA,IACN,OAAO,cAAe,MAAM,SAAS,OAAO,OAAO,OAAO,KAAK,YAAY,CAAC,CAAE,IAC9E,OAAO,IAAI,aAAa;GACtB,IAAI,OAAO,gBAAgB,OAAO,OAAO,OAAO,KAAK,YAAY,CAAC;GAClE,OAAO,cAAc,gBAAgB,QAAQ;EAC/C,CAAC;EACP,cAAc;GACZ,IAAI,UAAU,KAAA,GAAW,MAAM,WAAW;EAC5C;EACA,MACE,MACA,WAAW,SACgF;GAC3F,OAAO,OAAO,c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;KACN,UAAU;KACV,QAAQ;KACR,UAAU;IACZ;IAEA,OAAO,OAAO,OAAO,IAAI,aAAa;KACpC,MAAM,QAAQ,OAAO,MACnB,IACA,SACE,yBAAyB,UAAU,IAAI,eAAe,aAAa,OAAO,KAAK,GAC/E,SACF,IACC,cAAc;MACb,IAAI,CAAC,MAAM,QAAQ,MAAM,YAAY;MACrC,MAAM,WAAW,KAAK,SAAS;KACjC,CACF;KAEA,MAAM,SAAS;KACf,IAAI,MAAM,YAAY,MAAM,aAAa,GAAG,OAAO,OAAO,OAAO,KAAK,YAAY,CAAC;KACnF,OAAO,MAAM,OAAO;KACpB,IAAI,cAAc,SAAS,SAAS,OAAO,GAAG,QAAQ,MAAM,MAAM,UAAU;KAE5E,OAAO;IACT,CAAC,CAAC,CAAC,KACD,OAAO,SACL,OAAO,WAAW;KAChB,MAAM,SAAS;IACjB,CAAC,CACH,CACF;GACF,CAAC;GAEH,OAAO,cAAc,SAAS,UAC1B,IAAI,QAAQ,IACZ,cAAc,gBAAgB,KAAA,IAC5B,cAAc,YAAY,UAAU,GAAG,IACvC,SAAS,YAAY,GAAG;EAChC,GACA,EAAE,MAAM,cAAc,KAAK,CAC7B,EAAA,CAEc;CAChB,CAAC;AACH"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { EffectMysql2Transaction } from "drizzle-orm/effect-mysql2";
|
|
3
|
+
import { makeWithTransaction } from "effect/unstable/sql/SqlClient";
|
|
4
|
+
//#region src/drizzle/transaction-mysql.ts
|
|
5
|
+
/** Locking discovery and later SQL policy predicates must see the same current
|
|
6
|
+
* authority. MySQL's default repeatable-read snapshot is unsuitable after a
|
|
7
|
+
* contended authority lock. Own one connection and one-shot transaction mode;
|
|
8
|
+
* the pooled connection's session default is never changed. */
|
|
9
|
+
const mysqlTransaction = (unavailable, database, body) => Effect.scoped(Effect.gen(function* () {
|
|
10
|
+
const client = database.$client;
|
|
11
|
+
const connection = yield* client.reserve;
|
|
12
|
+
const nativeConnection = connection.conn;
|
|
13
|
+
if (typeof nativeConnection?.destroy !== "function" || typeof nativeConnection.release !== "function") return yield* Effect.fail(unavailable());
|
|
14
|
+
const destroy = nativeConnection.destroy.bind(nativeConnection);
|
|
15
|
+
const defaults = yield* connection.executeUnprepared("select @@session.transaction_isolation as isolation", [], void 0);
|
|
16
|
+
const isolation = String(defaults[0]?.isolation).replaceAll("-", " ").toUpperCase();
|
|
17
|
+
if (![
|
|
18
|
+
"READ UNCOMMITTED",
|
|
19
|
+
"READ COMMITTED",
|
|
20
|
+
"REPEATABLE READ",
|
|
21
|
+
"SERIALIZABLE"
|
|
22
|
+
].includes(isolation)) return yield* Effect.fail(unavailable());
|
|
23
|
+
const statement = (source) => Effect.asVoid(connection.executeUnprepared(source, [], void 0));
|
|
24
|
+
const transaction = makeWithTransaction({
|
|
25
|
+
transactionService: client.transactionService,
|
|
26
|
+
spanAttributes: [["db.system", "mysql"], ["effect_auth.owner", "oauth"]],
|
|
27
|
+
acquireConnection: Effect.succeed([void 0, connection]),
|
|
28
|
+
begin: () => statement("SET TRANSACTION ISOLATION LEVEL READ COMMITTED").pipe(Effect.andThen(statement("BEGIN"))),
|
|
29
|
+
commit: () => statement("COMMIT"),
|
|
30
|
+
rollback: () => statement("ROLLBACK"),
|
|
31
|
+
savepoint: (_connection, id) => statement(`SAVEPOINT effect_auth_oauth_${id}`),
|
|
32
|
+
rollbackSavepoint: (_connection, id) => statement(`ROLLBACK TO SAVEPOINT effect_auth_oauth_${id}`)
|
|
33
|
+
});
|
|
34
|
+
class NativeTransaction extends EffectMysql2Transaction {
|
|
35
|
+
transaction(nested) {
|
|
36
|
+
return transaction(Effect.suspend(() => nested(new NativeTransaction(database.dialect, database._.session, database._.relations))));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const native = new NativeTransaction(database.dialect, database._.session, database._.relations);
|
|
40
|
+
const cleanup = statement("ROLLBACK").pipe(Effect.andThen(statement(`SET TRANSACTION ISOLATION LEVEL ${isolation}`)), Effect.onExit((exit) => exit._tag === "Failure" ? Effect.sync(destroy) : Effect.void), Effect.orDie);
|
|
41
|
+
return yield* transaction(Effect.suspend(() => body(native))).pipe(Effect.ensuring(cleanup));
|
|
42
|
+
}));
|
|
43
|
+
//#endregion
|
|
44
|
+
export { mysqlTransaction };
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=transaction-mysql.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction-mysql.mjs","names":[],"sources":["../../src/drizzle/transaction-mysql.ts"],"sourcesContent":["/* oxlint-disable no-explicit-any -- this private acquisition preserves the installed native transaction; public wrappers retain its exact type. */\nimport { EffectMysql2Transaction } from \"drizzle-orm/effect-mysql2\";\nimport { Effect } from \"effect\";\nimport { makeWithTransaction, type SqlClient } from \"effect/unstable/sql/SqlClient\";\n\n/** Locking discovery and later SQL policy predicates must see the same current\n * authority. MySQL's default repeatable-read snapshot is unsuitable after a\n * contended authority lock. Own one connection and one-shot transaction mode;\n * the pooled connection's session default is never changed. */\nexport const mysqlTransaction = <A, E, R, Failure>(\n unavailable: () => Failure,\n database: any,\n body: (transaction: any) => Effect.Effect<A, E, R>,\n) =>\n Effect.scoped(\n Effect.gen(function* () {\n const client: SqlClient = database.$client;\n const connection = yield* client.reserve;\n\n // Installed @effect/sql-mysql2 ConnectionImpl exposes its reserved native\n // PoolConnection as `conn`. Capture only its public disposal method; fail\n // before transaction work if an installed driver no longer provides it.\n const nativeConnection = (\n connection as {\n readonly conn?: { readonly destroy?: () => void; readonly release?: () => void };\n }\n ).conn;\n\n if (\n typeof nativeConnection?.destroy !== \"function\" ||\n typeof nativeConnection.release !== \"function\"\n )\n return yield* Effect.fail(unavailable());\n const destroy = nativeConnection.destroy.bind(nativeConnection);\n\n const defaults = yield* connection.executeUnprepared(\n \"select @@session.transaction_isolation as isolation\",\n [],\n undefined,\n );\n\n const isolation = String(defaults[0]?.isolation).replaceAll(\"-\", \" \").toUpperCase();\n\n if (\n ![\"READ UNCOMMITTED\", \"READ COMMITTED\", \"REPEATABLE READ\", \"SERIALIZABLE\"].includes(\n isolation,\n )\n )\n return yield* Effect.fail(unavailable());\n\n const statement = (source: string) =>\n Effect.asVoid(connection.executeUnprepared(source, [], undefined));\n\n const transaction = makeWithTransaction({\n transactionService: client.transactionService,\n spanAttributes: [\n [\"db.system\", \"mysql\"],\n [\"effect_auth.owner\", \"oauth\"],\n ],\n acquireConnection: Effect.succeed([undefined, connection] as const),\n begin: () =>\n statement(\"SET TRANSACTION ISOLATION LEVEL READ COMMITTED\").pipe(\n Effect.andThen(statement(\"BEGIN\")),\n ),\n commit: () => statement(\"COMMIT\"),\n rollback: () => statement(\"ROLLBACK\"),\n savepoint: (_connection, id) => statement(`SAVEPOINT effect_auth_oauth_${id}`),\n rollbackSavepoint: (_connection, id) =>\n statement(`ROLLBACK TO SAVEPOINT effect_auth_oauth_${id}`),\n });\n\n class NativeTransaction extends EffectMysql2Transaction<any, any> {\n override transaction<A2, E2, R2>(nested: (tx: any) => Effect.Effect<A2, E2, R2>) {\n return transaction(\n Effect.suspend(() =>\n nested(\n new NativeTransaction(database.dialect, database._.session, database._.relations),\n ),\n ),\n );\n }\n }\n\n const native = new NativeTransaction(\n database.dialect,\n database._.session,\n database._.relations,\n );\n\n const cleanup = statement(\"ROLLBACK\").pipe(\n Effect.andThen(statement(`SET TRANSACTION ISOLATION LEVEL ${isolation}`)),\n Effect.onExit((exit) => (exit._tag === \"Failure\" ? Effect.sync(destroy) : Effect.void)),\n Effect.orDie,\n );\n\n return yield* transaction(Effect.suspend(() => body(native))).pipe(\n // BEGIN/COMMIT acknowledgments can be lost after the server acted.\n // Roll back any surviving transaction before resetting one-shot mode.\n // Failed cleanup destroys the connection before its reserve is released;\n // the unknown owner result cannot release a prepared receipt.\n Effect.ensuring(cleanup),\n );\n }),\n );\n"],"mappings":";;;;;;;;AASA,MAAa,oBACX,aACA,UACA,SAEA,OAAO,OACL,OAAO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S,SACT,SAAS,EAAE,SACX,SAAS,EAAE,SACb;CAEA,MAAM,UAAU,UAAU,UAAU,CAAC,CAAC,KACpC,OAAO,QAAQ,UAAU,mCAAmC,WAAW,CAAC,GACxE,OAAO,QAAQ,SAAU,KAAK,SAAS,YAAY,OAAO,KAAK,OAAO,IAAI,OAAO,IAAK,GACtF,OAAO,KACT;CAEA,OAAO,OAAO,YAAY,OAAO,cAAc,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,KAK5D,OAAO,SAAS,OAAO,CACzB;AACF,CAAC,CACH"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import "../hooks/commit.mjs";
|
|
2
|
+
import { Effect } from "effect";
|
|
3
|
+
import { SQL, Table } from "drizzle-orm";
|
|
4
|
+
import "effect/unstable/sql/SqlClient";
|
|
5
|
+
import { SqlError } from "effect/unstable/sql/SqlError";
|
|
6
|
+
import { Statement } from "effect/unstable/sql/Statement";
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import { reportAuthFailure } from "../internal/diagnostics.mjs";
|
|
2
|
+
import { balancedD1And, compactD1GeneratedStatement } from "./d1-generated-statement.mjs";
|
|
3
|
+
import { Cause, Effect } from "effect";
|
|
4
|
+
import { eq, getTableColumns, isNull, sql } from "drizzle-orm";
|
|
5
|
+
//#region src/drizzle/transaction-owner.ts
|
|
6
|
+
const isUnavailableCause = (cause, unavailable) => {
|
|
7
|
+
const expected = unavailable();
|
|
8
|
+
const tag = typeof expected === "object" && expected !== null && "_tag" in expected ? expected._tag : void 0;
|
|
9
|
+
return tag !== void 0 && cause.reasons.length > 0 && cause.reasons.every((reason) => Cause.isFailReason(reason) && typeof reason.error === "object" && reason.error !== null && "_tag" in reason.error && reason.error._tag === tag);
|
|
10
|
+
};
|
|
11
|
+
/** Report once, before an adapter replaces the raw cause with its public
|
|
12
|
+
* unavailable error. Already translated failures stay quiet at outer owners. */
|
|
13
|
+
const reportTransactionFailure = (effect, unavailable) => Effect.catchCause(effect, (cause) => isUnavailableCause(cause, unavailable) ? Effect.failCause(cause) : reportAuthFailure("auth-persistence", cause).pipe(Effect.andThen(Effect.failCause(cause))));
|
|
14
|
+
const both = (...parts) => balancedD1And(...parts) ?? sql`1 = 1`;
|
|
15
|
+
const makeTransactionRows = (unavailable) => {
|
|
16
|
+
const invariant = (value) => {
|
|
17
|
+
if (!value) throw unavailable();
|
|
18
|
+
};
|
|
19
|
+
const col = (table, key) => {
|
|
20
|
+
const value = getTableColumns(table)[key];
|
|
21
|
+
invariant(value !== void 0);
|
|
22
|
+
return value;
|
|
23
|
+
};
|
|
24
|
+
const equal = (table, values) => both(...Object.entries(values).map(([key, value]) => value === null ? isNull(col(table, key)) : eq(col(table, key), value)));
|
|
25
|
+
/** Mapped driver values use plain data, Dates and binary views. Application
|
|
26
|
+
* identity classes are reconstructed by the mapped codecs, never cloned here. */
|
|
27
|
+
const copiedRow = (row) => {
|
|
28
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
29
|
+
const supported = (value) => {
|
|
30
|
+
if (value === null || typeof value !== "object" || seen.has(value)) return;
|
|
31
|
+
seen.add(value);
|
|
32
|
+
if (value instanceof Date || value instanceof ArrayBuffer || ArrayBuffer.isView(value)) return;
|
|
33
|
+
invariant(Array.isArray(value) || Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null);
|
|
34
|
+
for (const item of Object.values(value)) supported(item);
|
|
35
|
+
};
|
|
36
|
+
supported(row);
|
|
37
|
+
return structuredClone(row);
|
|
38
|
+
};
|
|
39
|
+
const nativeKey = (value) => {
|
|
40
|
+
const packed = (tag, text) => tag + text.length + ":" + text;
|
|
41
|
+
if (value instanceof Date) return packed("date", value.toISOString());
|
|
42
|
+
if (typeof value === "bigint") return packed("bigint", value.toString());
|
|
43
|
+
const bytes = value instanceof ArrayBuffer ? new Uint8Array(value) : ArrayBuffer.isView(value) ? new Uint8Array(value.buffer, value.byteOffset, value.byteLength) : void 0;
|
|
44
|
+
if (bytes !== void 0) return packed("bytes", Array.from(bytes).join(","));
|
|
45
|
+
if (value === null || typeof value !== "object") return packed(typeof value, String(value));
|
|
46
|
+
if (Array.isArray(value)) return packed("array", value.map(nativeKey).join(""));
|
|
47
|
+
invariant(Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null);
|
|
48
|
+
return packed("object", Object.entries(value).sort(([a], [b]) => a.localeCompare(b)).map(([name, item]) => nativeKey(name) + nativeKey(item)).join(""));
|
|
49
|
+
};
|
|
50
|
+
const matchesNativeRow = (table, row, key) => Object.entries(key).every(([name, value]) => {
|
|
51
|
+
if (value === null || row[name] === null) return value === row[name];
|
|
52
|
+
const column = col(table, name);
|
|
53
|
+
return nativeKey(column.mapToDriverValue(row[name])) === nativeKey(column.mapToDriverValue(value));
|
|
54
|
+
});
|
|
55
|
+
return {
|
|
56
|
+
col,
|
|
57
|
+
equal,
|
|
58
|
+
copiedRow,
|
|
59
|
+
matchesNativeRow
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
const makeTransactionOwner = (database, journal, marker, unavailable, configuration) => {
|
|
63
|
+
const invariant = (value) => {
|
|
64
|
+
if (!value) throw unavailable();
|
|
65
|
+
};
|
|
66
|
+
const { col, equal, matchesNativeRow } = makeTransactionRows(unavailable);
|
|
67
|
+
let phase = "open";
|
|
68
|
+
let poisoned = false;
|
|
69
|
+
const open = () => invariant(phase === "open" && !poisoned);
|
|
70
|
+
const result = (effect) => effect.pipe((operation) => reportTransactionFailure(operation, unavailable), Effect.mapError(unavailable), Effect.catchDefect(() => Effect.fail(unavailable())), Effect.onExit((exit) => Effect.sync(() => {
|
|
71
|
+
if (exit._tag === "Failure") poisoned = true;
|
|
72
|
+
})));
|
|
73
|
+
const observations = [];
|
|
74
|
+
const statements = [];
|
|
75
|
+
const postconditions = [];
|
|
76
|
+
const guards = [];
|
|
77
|
+
const finalUpdates = [];
|
|
78
|
+
const exactRow = (table, row) => both(...Object.entries(row).map(([key, value]) => {
|
|
79
|
+
if (typeof value !== "string") return equal(table, { [key]: value });
|
|
80
|
+
const column = col(table, key), bound = sql.param(value, column);
|
|
81
|
+
return configuration.dialect === "mysql" ? sql`binary ${column} = binary ${bound}` : configuration.dialect === "pg" ? sql`convert_to(cast(${column} as text), 'UTF8') = convert_to(cast(${bound} as text), 'UTF8')` : sql`cast(${column} as blob) = cast(${bound} as blob)`;
|
|
82
|
+
}));
|
|
83
|
+
const toStatement = (query) => {
|
|
84
|
+
const rendered = query.toSQL();
|
|
85
|
+
const client = configuration.client ?? database.$client;
|
|
86
|
+
return compactD1GeneratedStatement(client, client.unsafe(rendered.sql, rendered.params), unavailable);
|
|
87
|
+
};
|
|
88
|
+
const assertion = (condition) => database.select({ value: sql`case when ${condition} then 1 else json_extract('[]', ${"$[oauth-owner-" + marker + "]"}) end` }).from(sql`(select 1) as oauth_assertion`);
|
|
89
|
+
const observedConditions = (table, where, rows) => [sql`(select count(*) from ${table} where ${where}) = ${rows.length}`, ...rows.map((row) => sql`exists(select 1 from ${table} where ${both(where, exactRow(table, row))})`)];
|
|
90
|
+
const chunks = (conditions) => {
|
|
91
|
+
const output = [];
|
|
92
|
+
let pending = [];
|
|
93
|
+
for (const condition of conditions) {
|
|
94
|
+
const candidate = [...pending, condition];
|
|
95
|
+
const rendered = assertion(both(...candidate)).toSQL();
|
|
96
|
+
if (pending.length > 0 && (rendered.params.length > 96 || new TextEncoder().encode(rendered.sql).length > 48e3)) {
|
|
97
|
+
output.push(both(...pending));
|
|
98
|
+
pending = [condition];
|
|
99
|
+
} else pending = candidate;
|
|
100
|
+
}
|
|
101
|
+
if (pending.length > 0) output.push(both(...pending));
|
|
102
|
+
return output;
|
|
103
|
+
};
|
|
104
|
+
const appendAssertions = (conditions) => {
|
|
105
|
+
for (const condition of chunks(conditions)) statements.push(toStatement(assertion(condition)));
|
|
106
|
+
};
|
|
107
|
+
const observed = (table, where, rows) => {
|
|
108
|
+
const observation = {
|
|
109
|
+
table,
|
|
110
|
+
where,
|
|
111
|
+
rows
|
|
112
|
+
};
|
|
113
|
+
observations.push(observation);
|
|
114
|
+
return observation;
|
|
115
|
+
};
|
|
116
|
+
const queryCondition = (condition) => database.select({ value: sql`case when ${condition} then 1 else 0 end`.mapWith(Number).as("value") }).from(sql`(select 1) as oauth_guard`);
|
|
117
|
+
const conditionHolds = (condition) => Effect.gen(function* () {
|
|
118
|
+
const query = queryCondition(condition);
|
|
119
|
+
const rows = yield* configuration.dialect === "sqlite" ? toStatement(query) : query;
|
|
120
|
+
invariant(rows.length === 1);
|
|
121
|
+
return rows[0].value === 1;
|
|
122
|
+
});
|
|
123
|
+
const guardedQuery = (table, where, values, guard) => {
|
|
124
|
+
invariant(Number.isSafeInteger(guard.rows) && guard.rows > 0 && guard.rows <= 128);
|
|
125
|
+
return {
|
|
126
|
+
query: database.update(table).set(values).where(where),
|
|
127
|
+
guard: { ...guard }
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
const applyGuarded = (entry) => Effect.gen(function* () {
|
|
131
|
+
if (configuration.batch) {
|
|
132
|
+
statements.push(toStatement(entry.query));
|
|
133
|
+
statements.push(toStatement(assertion(sql`changes() = ${entry.guard.rows}`)));
|
|
134
|
+
appendAssertions([entry.guard.postcondition]);
|
|
135
|
+
} else {
|
|
136
|
+
if (configuration.mysql) {
|
|
137
|
+
const changed = yield* entry.query;
|
|
138
|
+
invariant(changed.affectedRows === entry.guard.rows);
|
|
139
|
+
} else {
|
|
140
|
+
const changed = yield* entry.query.returning({ value: sql`1` });
|
|
141
|
+
invariant(changed.length === entry.guard.rows);
|
|
142
|
+
}
|
|
143
|
+
invariant(yield* conditionHolds(entry.guard.postcondition));
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
const owner = {
|
|
147
|
+
database,
|
|
148
|
+
journal,
|
|
149
|
+
marker,
|
|
150
|
+
batch: configuration.batch,
|
|
151
|
+
observations,
|
|
152
|
+
statements,
|
|
153
|
+
postconditions,
|
|
154
|
+
guards,
|
|
155
|
+
exact: exactRow,
|
|
156
|
+
read: (table, where, options = {}) => result(Effect.gen(function* () {
|
|
157
|
+
open();
|
|
158
|
+
const limit = options.limit ?? 64;
|
|
159
|
+
let query = database.select(options.columns === void 0 ? void 0 : Object.fromEntries(options.columns.map((key) => [key, col(table, key)]))).from(table).where(where).limit(options.takeOnly ? limit : limit + 1);
|
|
160
|
+
if (options.orderBy !== void 0) query = query.orderBy(options.orderBy);
|
|
161
|
+
if (options.lock !== false && configuration.locking) query = query.for("update");
|
|
162
|
+
const rows = yield* query;
|
|
163
|
+
invariant(rows.length <= limit);
|
|
164
|
+
if (configuration.batch && (options.observe !== false || options.admissionOnly)) appendAssertions(observedConditions(table, where, rows));
|
|
165
|
+
return options.observe === false || options.admissionOnly ? {
|
|
166
|
+
table,
|
|
167
|
+
where,
|
|
168
|
+
rows
|
|
169
|
+
} : observed(table, where, rows);
|
|
170
|
+
})),
|
|
171
|
+
write: (query) => result(Effect.gen(function* () {
|
|
172
|
+
open();
|
|
173
|
+
if (configuration.batch) statements.push(toStatement(query));
|
|
174
|
+
else yield* query;
|
|
175
|
+
})),
|
|
176
|
+
insert: (table, values, key, absent = false) => result(Effect.gen(function* () {
|
|
177
|
+
open();
|
|
178
|
+
let query = database.insert(table).values(values);
|
|
179
|
+
if (absent) query = configuration.mysql ? query.onDuplicateKeyUpdate({ set: { [Object.keys(key)[0]]: col(table, Object.keys(key)[0]) } }) : query.onConflictDoNothing();
|
|
180
|
+
yield* owner.write(query);
|
|
181
|
+
const where = equal(table, key);
|
|
182
|
+
if (configuration.batch) return observed(table, where, [values]);
|
|
183
|
+
const found = yield* owner.read(table, where, { limit: 1 });
|
|
184
|
+
const markerColumn = Object.keys(values).find((key) => values[key] === marker);
|
|
185
|
+
if (!absent || markerColumn !== void 0 && found.rows[0]?.[markerColumn] === marker) invariant(yield* owner.check(sql`exists(select 1 from ${table} where ${both(where, exactRow(table, values))})`));
|
|
186
|
+
return found;
|
|
187
|
+
})),
|
|
188
|
+
update: (table, key, values) => result(Effect.gen(function* () {
|
|
189
|
+
open();
|
|
190
|
+
yield* owner.write(database.update(table).set(values).where(equal(table, key)));
|
|
191
|
+
for (const observation of observations) if (observation.table === table) observation.rows = observation.rows.map((row) => matchesNativeRow(table, row, key) ? {
|
|
192
|
+
...row,
|
|
193
|
+
...values
|
|
194
|
+
} : row);
|
|
195
|
+
})),
|
|
196
|
+
updateGuarded: (table, where, values, guard) => result(Effect.gen(function* () {
|
|
197
|
+
open();
|
|
198
|
+
const entry = guardedQuery(table, where, values, guard);
|
|
199
|
+
yield* applyGuarded(entry);
|
|
200
|
+
postconditions.push(entry.guard.postcondition);
|
|
201
|
+
})),
|
|
202
|
+
finalUpdate: (table, where, values, guard) => result(Effect.sync(() => {
|
|
203
|
+
open();
|
|
204
|
+
invariant(finalUpdates.length < 128);
|
|
205
|
+
finalUpdates.push(guardedQuery(table, where, values, guard));
|
|
206
|
+
})),
|
|
207
|
+
remove: (table, key) => result(Effect.gen(function* () {
|
|
208
|
+
open();
|
|
209
|
+
yield* owner.write(database.delete(table).where(equal(table, key)));
|
|
210
|
+
for (const observation of observations) if (observation.table === table) observation.rows = observation.rows.filter((row) => !matchesNativeRow(table, row, key));
|
|
211
|
+
})),
|
|
212
|
+
check: (condition) => result(Effect.gen(function* () {
|
|
213
|
+
open();
|
|
214
|
+
const holds = yield* conditionHolds(condition);
|
|
215
|
+
if (configuration.batch) statements.push(toStatement(assertion(holds ? condition : sql`not (${condition})`)));
|
|
216
|
+
return holds;
|
|
217
|
+
})),
|
|
218
|
+
now: (clock) => result(Effect.gen(function* () {
|
|
219
|
+
open();
|
|
220
|
+
const value = (yield* database.select({ value: sql`${clock.engineNowMillis}`.mapWith(Number) }).from(sql`(select 1) as oauth_clock`))[0]?.value;
|
|
221
|
+
invariant(Number.isSafeInteger(value) && value >= 0);
|
|
222
|
+
return value;
|
|
223
|
+
})),
|
|
224
|
+
finish: () => result(Effect.gen(function* () {
|
|
225
|
+
open();
|
|
226
|
+
phase = "finishing";
|
|
227
|
+
Object.freeze(observations);
|
|
228
|
+
Object.freeze(postconditions);
|
|
229
|
+
Object.freeze(guards);
|
|
230
|
+
Object.freeze(finalUpdates);
|
|
231
|
+
const conditions = observations.flatMap((observation) => observedConditions(observation.table, observation.where, observation.rows));
|
|
232
|
+
conditions.push(...postconditions.map((condition) => typeof condition === "function" ? condition() : condition));
|
|
233
|
+
conditions.push(...finalUpdates.map((entry) => entry.guard.postcondition));
|
|
234
|
+
for (const guard of guards) {
|
|
235
|
+
const status = yield* Effect.result(guard.read);
|
|
236
|
+
invariant(status._tag === "Failure" && status.failure._tag === "CommitPending");
|
|
237
|
+
}
|
|
238
|
+
invariant(!poisoned);
|
|
239
|
+
for (const entry of finalUpdates) yield* applyGuarded(entry);
|
|
240
|
+
if (configuration.batch) appendAssertions(conditions);
|
|
241
|
+
else for (const condition of chunks(conditions)) invariant(yield* conditionHolds(condition));
|
|
242
|
+
invariant(!poisoned);
|
|
243
|
+
}).pipe(Effect.ensuring(Effect.sync(() => {
|
|
244
|
+
phase = "finished";
|
|
245
|
+
}))))
|
|
246
|
+
};
|
|
247
|
+
return owner;
|
|
248
|
+
};
|
|
249
|
+
//#endregion
|
|
250
|
+
export { both, makeTransactionOwner, makeTransactionRows, reportTransactionFailure };
|
|
251
|
+
|
|
252
|
+
//# sourceMappingURL=transaction-owner.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction-owner.mjs","names":[],"sources":["../../src/drizzle/transaction-owner.ts"],"sourcesContent":["/* oxlint-disable no-explicit-any -- private SQL kernel; driver wrappers retain table and native ID types. */\nimport { eq, getTableColumns, isNull, sql, type SQL, type Table } from \"drizzle-orm\";\nimport type { EffectDrizzleQueryError } from \"drizzle-orm/effect-core\";\nimport { Cause, Effect } from \"effect\";\nimport type * as SqlClient from \"effect/unstable/sql/SqlClient\";\nimport type { SqlError } from \"effect/unstable/sql/SqlError\";\nimport type { Statement } from \"effect/unstable/sql/Statement\";\n\nimport { type CommitJournal, type PreparedCommit } from \"../hooks/commit\";\nimport { reportAuthFailure } from \"../internal/diagnostics\";\nimport { balancedD1And, compactD1GeneratedStatement } from \"./d1-generated-statement\";\n\nexport type Row = Record<string, any>;\n/** Only query-builder/table shapes are erased here. Installed Effect Drizzle\n * queries have captured clients, and their error channel remains explicit. */\ntype NativeQuery<A> = Effect.Effect<A, EffectDrizzleQueryError | SqlError>;\n\nexport interface TransactionNativeDatabase {\n readonly $client: SqlClient.SqlClient & {\n readonly batch: (statements: ReadonlyArray<Statement<any>>) => Effect.Effect<any, SqlError>;\n };\n readonly transaction: <A, E, R>(\n body: (transaction: any) => Effect.Effect<A, E, R>,\n ) => Effect.Effect<A, E | SqlError, R>;\n}\n\nconst isUnavailableCause = <Failure>(cause: Cause.Cause<unknown>, unavailable: () => Failure) => {\n const expected = unavailable();\n\n const tag =\n typeof expected === \"object\" && expected !== null && \"_tag\" in expected\n ? expected._tag\n : undefined;\n\n return (\n tag !== undefined &&\n cause.reasons.length > 0 &&\n cause.reasons.every(\n (reason) =>\n Cause.isFailReason(reason) &&\n typeof reason.error === \"object\" &&\n reason.error !== null &&\n \"_tag\" in reason.error &&\n reason.error._tag === tag,\n )\n );\n};\n\n/** Report once, before an adapter replaces the raw cause with its public\n * unavailable error. Already translated failures stay quiet at outer owners. */\nexport const reportTransactionFailure = <A, E, R, Failure>(\n effect: Effect.Effect<A, E, R>,\n unavailable: () => Failure,\n): Effect.Effect<A, E, R> =>\n Effect.catchCause(effect, (cause) =>\n isUnavailableCause(cause, unavailable)\n ? Effect.failCause(cause)\n : reportAuthFailure(\"auth-persistence\", cause).pipe(Effect.andThen(Effect.failCause(cause))),\n );\n\nexport const both = (...parts: ReadonlyArray<SQL | undefined>) =>\n balancedD1And(...parts) ?? sql`1 = 1`;\n\nexport const makeTransactionRows = <Failure>(unavailable: () => Failure) => {\n const invariant: (value: unknown) => asserts value = (value) => {\n if (!value) throw unavailable();\n };\n\n const col = (table: Table, key: string) => {\n const value = getTableColumns(table)[key];\n\n invariant(value !== undefined);\n\n return value;\n };\n\n const equal = (table: Table, values: Row) =>\n both(\n ...Object.entries(values).map(([key, value]) =>\n value === null ? isNull(col(table, key)) : eq(col(table, key), value),\n ),\n );\n\n /** Mapped driver values use plain data, Dates and binary views. Application\n * identity classes are reconstructed by the mapped codecs, never cloned here. */\n const copiedRow = (row: Row) => {\n const seen = new WeakSet<object>();\n\n const supported = (value: unknown): void => {\n if (value === null || typeof value !== \"object\" || seen.has(value)) return;\n seen.add(value);\n if (value instanceof Date || value instanceof ArrayBuffer || ArrayBuffer.isView(value))\n return;\n invariant(\n Array.isArray(value) ||\n Object.getPrototypeOf(value) === Object.prototype ||\n Object.getPrototypeOf(value) === null,\n );\n for (const item of Object.values(value)) supported(item);\n };\n\n supported(row);\n\n return structuredClone(row);\n };\n\n const nativeKey = (value: unknown): string => {\n const packed = (tag: string, text: string) => tag + text.length + \":\" + text;\n\n if (value instanceof Date) return packed(\"date\", value.toISOString());\n if (typeof value === \"bigint\") return packed(\"bigint\", value.toString());\n\n const bytes =\n value instanceof ArrayBuffer\n ? new Uint8Array(value)\n : ArrayBuffer.isView(value)\n ? new Uint8Array(value.buffer, value.byteOffset, value.byteLength)\n : undefined;\n\n if (bytes !== undefined) return packed(\"bytes\", Array.from(bytes).join(\",\"));\n if (value === null || typeof value !== \"object\") return packed(typeof value, String(value));\n if (Array.isArray(value)) return packed(\"array\", value.map(nativeKey).join(\"\"));\n invariant(\n Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null,\n );\n\n return packed(\n \"object\",\n Object.entries(value)\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([name, item]) => nativeKey(name) + nativeKey(item))\n .join(\"\"),\n );\n };\n\n const matchesNativeRow = (table: Table, row: Row, key: Row) =>\n Object.entries(key).every(([name, value]) => {\n if (value === null || row[name] === null) return value === row[name];\n const column = col(table, name);\n\n return (\n nativeKey(column.mapToDriverValue(row[name])) === nativeKey(column.mapToDriverValue(value))\n );\n });\n\n return { col, equal, copiedRow, matchesNativeRow };\n};\n\nexport interface Observation {\n readonly table: Table;\n readonly where: SQL;\n rows: ReadonlyArray<Row>;\n}\n\n/** Expressions deliberately do not replace observed values. Read only semantic\n * columns when telemetry changes atomically, and state the physical result. */\nexport interface GuardedUpdate {\n readonly rows: number;\n readonly postcondition: SQL;\n}\n\nexport interface TransactionOwner<Failure> {\n readonly database: any;\n readonly journal: CommitJournal;\n readonly marker: string;\n readonly batch: boolean;\n readonly observations: Observation[];\n readonly postconditions: Array<SQL | (() => SQL)>;\n readonly statements: Statement<any>[];\n readonly guards: PreparedCommit<void>[];\n exact(table: Table, row: Row): SQL;\n read(\n table: Table,\n where: SQL,\n options?: {\n readonly lock?: boolean;\n readonly limit?: number;\n readonly observe?: boolean;\n readonly admissionOnly?: boolean;\n readonly takeOnly?: boolean;\n readonly orderBy?: any;\n readonly columns?: ReadonlyArray<string>;\n },\n ): Effect.Effect<Observation, Failure>;\n write(query: any): Effect.Effect<void, Failure>;\n insert(\n table: Table,\n values: Row,\n key: Row,\n absent?: boolean,\n ): Effect.Effect<Observation, Failure>;\n update(table: Table, key: Row, values: Row): Effect.Effect<void, Failure>;\n updateGuarded(\n table: Table,\n where: SQL,\n values: Row,\n guard: GuardedUpdate,\n ): Effect.Effect<void, Failure>;\n /** Internal SQL only, run once after application work and before final guards. */\n finalUpdate(\n table: Table,\n where: SQL,\n values: Row,\n guard: GuardedUpdate,\n ): Effect.Effect<void, Failure>;\n remove(table: Table, key: Row): Effect.Effect<void, Failure>;\n check(condition: SQL): Effect.Effect<boolean, Failure>;\n now(clock: { readonly engineNowMillis: SQL }): Effect.Effect<number, Failure>;\n finish(): Effect.Effect<void, Failure>;\n}\n\nexport const makeTransactionOwner = <Failure>(\n database: any,\n journal: CommitJournal,\n marker: string,\n unavailable: () => Failure,\n configuration: {\n readonly client?: any;\n readonly batch: boolean;\n readonly locking: boolean;\n readonly mysql: boolean;\n readonly dialect: \"pg\" | \"mysql\" | \"sqlite\";\n },\n): TransactionOwner<Failure> => {\n const invariant: (value: unknown) => asserts value = (value) => {\n if (!value) throw unavailable();\n };\n\n const { col, equal, matchesNativeRow } = makeTransactionRows(unavailable);\n let phase: \"open\" | \"finishing\" | \"finished\" = \"open\";\n let poisoned = false;\n const open = () => invariant(phase === \"open\" && !poisoned);\n\n const result = <A, E>(effect: Effect.Effect<A, E>) =>\n effect.pipe(\n (operation) => reportTransactionFailure(operation, unavailable),\n Effect.mapError(unavailable),\n Effect.catchDefect(() => Effect.fail(unavailable())),\n Effect.onExit((exit) =>\n Effect.sync(() => {\n if (exit._tag === \"Failure\") poisoned = true;\n }),\n ),\n );\n\n const observations: Observation[] = [];\n const statements: Statement<any>[] = [];\n const postconditions: Array<SQL | (() => SQL)> = [];\n const guards: PreparedCommit<void>[] = [];\n const finalUpdates: Array<{ readonly query: any; readonly guard: GuardedUpdate }> = [];\n\n const exactRow = (table: Table, row: Row) =>\n both(\n ...Object.entries(row).map(([key, value]) => {\n if (typeof value !== \"string\") return equal(table, { [key]: value });\n\n const column = col(table, key),\n bound = sql.param(value, column);\n\n return configuration.dialect === \"mysql\"\n ? sql`binary ${column} = binary ${bound}`\n : configuration.dialect === \"pg\"\n ? sql`convert_to(cast(${column} as text), 'UTF8') = convert_to(cast(${bound} as text), 'UTF8')`\n : sql`cast(${column} as blob) = cast(${bound} as blob)`;\n }),\n );\n\n const toStatement = (query: any): Statement<any> => {\n const rendered = query.toSQL();\n const client = configuration.client ?? database.$client;\n\n return compactD1GeneratedStatement(\n client,\n client.unsafe(rendered.sql, rendered.params),\n unavailable,\n );\n };\n\n const assertion = (condition: SQL) =>\n database\n .select({\n value: sql`case when ${condition} then 1 else json_extract('[]', ${\"$[oauth-owner-\" + marker + \"]\"}) end`,\n })\n .from(sql`(select 1) as oauth_assertion`);\n\n const observedConditions = (table: Table, where: SQL, rows: ReadonlyArray<Row>) => [\n sql`(select count(*) from ${table} where ${where}) = ${rows.length}`,\n ...rows.map(\n (row) => sql`exists(select 1 from ${table} where ${both(where, exactRow(table, row))})`,\n ),\n ];\n\n // All chunks remain inside the same native owner or atomic D1 batch. A single\n // wide row is compacted; separate observations cannot accumulate unbounded\n // bind parameters or expression depth in one final SELECT.\n const chunks = (conditions: ReadonlyArray<SQL>) => {\n const output: SQL[] = [];\n let pending: SQL[] = [];\n\n for (const condition of conditions) {\n const candidate = [...pending, condition];\n const rendered = assertion(both(...candidate)).toSQL();\n\n if (\n pending.length > 0 &&\n (rendered.params.length > 96 || new TextEncoder().encode(rendered.sql).length > 48_000)\n ) {\n output.push(both(...pending));\n pending = [condition];\n } else pending = candidate;\n }\n if (pending.length > 0) output.push(both(...pending));\n\n return output;\n };\n\n const appendAssertions = (conditions: ReadonlyArray<SQL>) => {\n for (const condition of chunks(conditions)) statements.push(toStatement(assertion(condition)));\n };\n\n const observed = (table: Table, where: SQL, rows: ReadonlyArray<Row>) => {\n const observation = { table, where, rows };\n\n observations.push(observation);\n\n return observation;\n };\n\n const queryCondition = (condition: SQL) =>\n database\n .select({\n value: sql<number>`case when ${condition} then 1 else 0 end`.mapWith(Number).as(\"value\"),\n })\n .from(sql`(select 1) as oauth_guard`);\n\n const conditionHolds = (condition: SQL) =>\n Effect.gen(function* () {\n const query = queryCondition(condition);\n\n const rows: ReadonlyArray<Row> = yield* configuration.dialect === \"sqlite\"\n ? toStatement(query)\n : (query as NativeQuery<Row[]>);\n\n invariant(rows.length === 1);\n\n return rows[0]!.value === 1;\n });\n\n const guardedQuery = (table: Table, where: SQL, values: Row, guard: GuardedUpdate) => {\n invariant(Number.isSafeInteger(guard.rows) && guard.rows > 0 && guard.rows <= 128);\n\n return { query: database.update(table).set(values).where(where), guard: { ...guard } };\n };\n\n const applyGuarded = (entry: { readonly query: any; readonly guard: GuardedUpdate }) =>\n Effect.gen(function* () {\n if (configuration.batch) {\n statements.push(toStatement(entry.query));\n statements.push(toStatement(assertion(sql`changes() = ${entry.guard.rows}`)));\n appendAssertions([entry.guard.postcondition]);\n } else {\n if (configuration.mysql) {\n // mysql2 reports matched rows (FOUND_ROWS), including a telemetry no-op.\n const changed = yield* entry.query as NativeQuery<{ readonly affectedRows: number }>;\n\n invariant(changed.affectedRows === entry.guard.rows);\n } else {\n const changed = yield* entry.query.returning({ value: sql`1` }) as NativeQuery<\n ReadonlyArray<Row>\n >;\n\n invariant(changed.length === entry.guard.rows);\n }\n invariant(yield* conditionHolds(entry.guard.postcondition));\n }\n });\n\n const owner: TransactionOwner<Failure> = {\n database,\n journal,\n marker,\n batch: configuration.batch,\n observations,\n statements,\n postconditions,\n guards,\n exact: exactRow,\n read: (table, where, options = {}) =>\n result(\n Effect.gen(function* () {\n open();\n const limit = options.limit ?? 64;\n\n let query = database\n .select(\n options.columns === undefined\n ? undefined\n : Object.fromEntries(options.columns.map((key) => [key, col(table, key)])),\n )\n .from(table)\n .where(where)\n .limit(options.takeOnly ? limit : limit + 1);\n\n if (options.orderBy !== undefined) query = query.orderBy(options.orderBy);\n if (options.lock !== false && configuration.locking) query = query.for(\"update\");\n const rows: Row[] = yield* query as NativeQuery<Row[]>;\n\n invariant(rows.length <= limit);\n if (configuration.batch && (options.observe !== false || options.admissionOnly))\n appendAssertions(observedConditions(table, where, rows));\n\n return options.observe === false || options.admissionOnly\n ? { table, where, rows }\n : observed(table, where, rows);\n }),\n ),\n write: (query) =>\n result(\n Effect.gen(function* () {\n open();\n if (configuration.batch) statements.push(toStatement(query));\n else yield* query as NativeQuery<unknown>;\n }),\n ),\n insert: (table, values, key, absent = false) =>\n result(\n Effect.gen(function* () {\n open();\n let query = database.insert(table).values(values);\n\n if (absent)\n query = configuration.mysql\n ? query.onDuplicateKeyUpdate({\n set: { [Object.keys(key)[0]!]: col(table, Object.keys(key)[0]!) },\n })\n : query.onConflictDoNothing();\n yield* owner.write(query);\n const where = equal(table, key);\n\n if (configuration.batch) return observed(table, where, [values]);\n const found = yield* owner.read(table, where, { limit: 1 });\n const markerColumn = Object.keys(values).find((key) => values[key] === marker);\n\n if (!absent || (markerColumn !== undefined && found.rows[0]?.[markerColumn] === marker))\n invariant(\n yield* owner.check(\n sql`exists(select 1 from ${table} where ${both(where, exactRow(table, values))})`,\n ),\n );\n\n return found;\n }),\n ),\n update: (table, key, values) =>\n result(\n Effect.gen(function* () {\n open();\n yield* owner.write(database.update(table).set(values).where(equal(table, key)));\n for (const observation of observations)\n if (observation.table === table)\n observation.rows = observation.rows.map((row) =>\n matchesNativeRow(table, row, key) ? { ...row, ...values } : row,\n );\n }),\n ),\n updateGuarded: (table, where, values, guard) =>\n result(\n Effect.gen(function* () {\n open();\n const entry = guardedQuery(table, where, values, guard);\n\n yield* applyGuarded(entry);\n postconditions.push(entry.guard.postcondition);\n }),\n ),\n finalUpdate: (table, where, values, guard) =>\n result(\n Effect.sync(() => {\n open();\n invariant(finalUpdates.length < 128);\n finalUpdates.push(guardedQuery(table, where, values, guard));\n }),\n ),\n remove: (table, key) =>\n result(\n Effect.gen(function* () {\n open();\n yield* owner.write(database.delete(table).where(equal(table, key)));\n for (const observation of observations)\n if (observation.table === table)\n observation.rows = observation.rows.filter(\n (row) => !matchesNativeRow(table, row, key),\n );\n }),\n ),\n check: (condition) =>\n result(\n Effect.gen(function* () {\n open();\n const holds = yield* conditionHolds(condition);\n\n if (configuration.batch)\n statements.push(toStatement(assertion(holds ? condition : sql`not (${condition})`)));\n\n return holds;\n }),\n ),\n now: (clock) =>\n result(\n Effect.gen(function* () {\n open();\n\n const rows: Row[] = yield* database\n .select({\n value: sql<number>`${clock.engineNowMillis}`.mapWith(Number),\n })\n .from(sql`(select 1) as oauth_clock`) as NativeQuery<Row[]>;\n\n const value = rows[0]?.value;\n\n invariant(Number.isSafeInteger(value) && value >= 0);\n\n return value as number;\n }),\n ),\n finish: () =>\n result(\n Effect.gen(function* () {\n open();\n phase = \"finishing\";\n Object.freeze(observations);\n Object.freeze(postconditions);\n Object.freeze(guards);\n Object.freeze(finalUpdates);\n\n // Close registration before any late-bound SQL predicate is materialized.\n // No callback is invoked after the first final write.\n const conditions = observations.flatMap((observation) =>\n observedConditions(observation.table, observation.where, observation.rows),\n );\n\n conditions.push(\n ...postconditions.map((condition) =>\n typeof condition === \"function\" ? condition() : condition,\n ),\n );\n conditions.push(...finalUpdates.map((entry) => entry.guard.postcondition));\n for (const guard of guards) {\n const status = yield* Effect.result(guard.read);\n\n invariant(status._tag === \"Failure\" && status.failure._tag === \"CommitPending\");\n }\n invariant(!poisoned);\n for (const entry of finalUpdates) yield* applyGuarded(entry);\n if (configuration.batch) appendAssertions(conditions);\n else\n for (const condition of chunks(conditions)) invariant(yield* conditionHolds(condition));\n invariant(!poisoned);\n }).pipe(\n Effect.ensuring(\n Effect.sync(() => {\n phase = \"finished\";\n }),\n ),\n ),\n ),\n };\n\n return owner;\n};\n"],"mappings":";;;;;AA0BA,MAAM,sBAA+B,OAA6B,gBAA+B;CAC/F,MAAM,WAAW,YAAY;CAE7B,MAAM,MACJ,OAAO,aAAa,YAAY,aAAa,QAAQ,UAAU,WAC3D,SAAS,OACT,KAAA;CAEN,OACE,QAAQ,KAAA,KACR,MAAM,QAAQ,SAAS,KACvB,MAAM,QAAQ,OACX,WACC,MAAM,aAAa,MAAM,KACzB,OAAO,OAAO,UAAU,YACxB,OAAO,UAAU,QACjB,UAAU,OAAO,SACjB,OAAO,MAAM,SAAS,GAC1B;AAEJ;;;AAIA,MAAa,4BACX,QACA,gBAEA,OAAO,WAAW,SAAS,UACzB,mBAAmB,OAAO,WAAW,IACjC,OAAO,UAAU,KAAK,IACtB,kBAAkB,oBAAoB,KAAK,CAAC,CAAC,KAAK,OAAO,QAAQ,OAAO,UAAU,KAAK,CAAC,CAAC,CAC/F;AAEF,MAAa,QAAQ,GAAG,UACtB,cAAc,GAAG,KAAK,KAAK,GAAG;AAEhC,MAAa,uBAAgC,gBAA+B;CAC1E,MAAM,aAAgD,UAAU;EAC9D,IAAI,CAAC,OAAO,MAAM,YAAY;CAChC;CAEA,MAAM,OAAO,OAAc,QAAgB;EACzC,MAAM,QAAQ,gBAAgB,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,SACxB,OAAO,EACN,OAAO,GAAW,GAAG,MAAM,kBAAkB,QAAQ,MAAM,EAC7D,CAAC,CAAC,CACD,KAAK,GAAG,2BAA2B,EAAA,CAEnB,EAAE,EAAE;GAEvB,UAAU,OAAO,cAAc,KAAK,KAAK,SAAS,CAAC;GAEnD,OAAO;EACT,CAAC,CACH;EACF,cACE,OACE,OAAO,IAAI,aAAa;GACtB,KAAK;GACL,QAAQ;GACR,OAAO,OAAO,YAAY;GAC1B,OAAO,OAAO,cAAc;GAC5B,OAAO,OAAO,MAAM;GACpB,OAAO,OAAO,YAAY;GAI1B,MAAM,aAAa,aAAa,SAAS,gBACvC,mBAAmB,YAAY,OAAO,YAAY,OAAO,YAAY,IAAI,CAC3E;GAEA,WAAW,KACT,GAAG,eAAe,KAAK,cACrB,OAAO,cAAc,aAAa,UAAU,IAAI,SAClD,CACF;GACA,WAAW,KAAK,GAAG,aAAa,KAAK,UAAU,MAAM,MAAM,aAAa,CAAC;GACzE,KAAK,MAAM,SAAS,QAAQ;IAC1B,MAAM,SAAS,OAAO,OAAO,OAAO,MAAM,IAAI;IAE9C,UAAU,OAAO,SAAS,aAAa,OAAO,QAAQ,SAAS,eAAe;GAChF;GACA,UAAU,CAAC,QAAQ;GACnB,KAAK,MAAM,SAAS,cAAc,OAAO,aAAa,KAAK;GAC3D,IAAI,cAAc,OAAO,iBAAiB,UAAU;QAElD,KAAK,MAAM,aAAa,OAAO,UAAU,GAAG,UAAU,OAAO,eAAe,SAAS,CAAC;GACxF,UAAU,CAAC,QAAQ;EACrB,CAAC,CAAC,CAAC,KACD,OAAO,SACL,OAAO,WAAW;GAChB,QAAQ;EACV,CAAC,CACH,CACF,CACF;CACJ;CAEA,OAAO;AACT"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { AuthInvocation } from "../operations/context.mjs";
|
|
2
|
+
import { AuthenticationEvidence, AuthenticationRequirement } from "../sessions/models.mjs";
|
|
3
|
+
import { EmailActionChallenge } from "./models.mjs";
|
|
4
|
+
import { EmailActionRequired, EmailUnavailable } from "./errors.mjs";
|
|
5
|
+
import { Context, Effect, Redacted } from "effect";
|
|
6
|
+
//#region src/email/EmailActionEvidence.d.ts
|
|
7
|
+
interface EmailActionAuthorization {
|
|
8
|
+
readonly challenge: EmailActionChallenge;
|
|
9
|
+
readonly evidence: AuthenticationEvidence;
|
|
10
|
+
readonly requirement: AuthenticationRequirement;
|
|
11
|
+
}
|
|
12
|
+
declare const EmailActionEvidence_base: Context.ServiceClass<EmailActionEvidence, "effect-auth/EmailActionEvidence", {
|
|
13
|
+
readonly verify: (input: {
|
|
14
|
+
readonly invocation: AuthInvocation;
|
|
15
|
+
readonly challenge: EmailActionChallenge;
|
|
16
|
+
readonly proof?: Redacted.Redacted<string>;
|
|
17
|
+
}) => Effect.Effect<{
|
|
18
|
+
readonly evidence: AuthenticationEvidence;
|
|
19
|
+
readonly requirement: AuthenticationRequirement;
|
|
20
|
+
}, EmailActionRequired | EmailUnavailable>;
|
|
21
|
+
}>;
|
|
22
|
+
/** Current subject/action authority; no default grants mutations. Target email
|
|
23
|
+
* proof and login-pending credentials never satisfy this independent authorization.
|
|
24
|
+
* Consume replay-sensitive factors in their own authority before returning; later
|
|
25
|
+
* identity CAS failure does not refund them. Counter advancement preserves semantic
|
|
26
|
+
* factor revision, while revocation/replacement changes it and wins final CAS.
|
|
27
|
+
* Request/change and completion are separate calls requiring fresh authorization;
|
|
28
|
+
* no promise that a consumed one-time factor can be resubmitted at completion.
|
|
29
|
+
*/
|
|
30
|
+
declare class EmailActionEvidence extends EmailActionEvidence_base {}
|
|
31
|
+
//#endregion
|
|
32
|
+
export { EmailActionAuthorization, EmailActionEvidence };
|
|
33
|
+
//# sourceMappingURL=EmailActionEvidence.d.mts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Context } from "effect";
|
|
2
|
+
//#region src/email/EmailActionEvidence.ts
|
|
3
|
+
/** Current subject/action authority; no default grants mutations. Target email
|
|
4
|
+
* proof and login-pending credentials never satisfy this independent authorization.
|
|
5
|
+
* Consume replay-sensitive factors in their own authority before returning; later
|
|
6
|
+
* identity CAS failure does not refund them. Counter advancement preserves semantic
|
|
7
|
+
* factor revision, while revocation/replacement changes it and wins final CAS.
|
|
8
|
+
* Request/change and completion are separate calls requiring fresh authorization;
|
|
9
|
+
* no promise that a consumed one-time factor can be resubmitted at completion.
|
|
10
|
+
*/
|
|
11
|
+
var EmailActionEvidence = class extends Context.Service()("effect-auth/EmailActionEvidence") {};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { EmailActionEvidence };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=EmailActionEvidence.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmailActionEvidence.mjs","names":[],"sources":["../../src/email/EmailActionEvidence.ts"],"sourcesContent":["import { Context, type Effect, type Redacted } from \"effect\";\n\nimport type { AuthInvocation } from \"../operations/context\";\nimport type { AuthenticationEvidence, AuthenticationRequirement } from \"../sessions/models\";\nimport type { EmailActionRequired, EmailUnavailable } from \"./errors\";\nimport type { EmailActionChallenge } from \"./models\";\n\nexport interface EmailActionAuthorization {\n readonly challenge: EmailActionChallenge;\n readonly evidence: AuthenticationEvidence;\n readonly requirement: AuthenticationRequirement;\n}\n\n/** Current subject/action authority; no default grants mutations. Target email\n * proof and login-pending credentials never satisfy this independent authorization.\n * Consume replay-sensitive factors in their own authority before returning; later\n * identity CAS failure does not refund them. Counter advancement preserves semantic\n * factor revision, while revocation/replacement changes it and wins final CAS.\n * Request/change and completion are separate calls requiring fresh authorization;\n * no promise that a consumed one-time factor can be resubmitted at completion.\n */\nexport class EmailActionEvidence extends Context.Service<\n EmailActionEvidence,\n {\n readonly verify: (input: {\n readonly invocation: AuthInvocation;\n readonly challenge: EmailActionChallenge;\n readonly proof?: Redacted.Redacted<string>;\n }) => Effect.Effect<\n {\n readonly evidence: AuthenticationEvidence;\n readonly requirement: AuthenticationRequirement;\n },\n EmailActionRequired | EmailUnavailable\n >;\n }\n>()(\"effect-auth/EmailActionEvidence\") {}\n"],"mappings":";;;;;;;;;;AAqBA,IAAa,sBAAb,cAAyC,QAAQ,QAe/C,CAAC,CAAC,iCAAiC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { SubjectId } from "../Schema.mjs";
|
|
2
|
+
import { AuthenticationRevision } from "../sessions/models.mjs";
|
|
3
|
+
import { LoginIdentifier } from "../identity/models.mjs";
|
|
4
|
+
import { CommitJournal, PreparedCommit } from "../hooks/commit.mjs";
|
|
5
|
+
import { SessionInvalidationWindow } from "../sessions/invalidation.mjs";
|
|
6
|
+
import { EmailAddressDecision, EmailCommandId, EmailCredentialSnapshot } from "./models.mjs";
|
|
7
|
+
import { ProofCompletionInput } from "../proofs/ProofPersistence.mjs";
|
|
8
|
+
import { ProofCompletionPlan } from "../proofs/completion.mjs";
|
|
9
|
+
import { EmailUnavailable } from "./errors.mjs";
|
|
10
|
+
import { EmailActionAuthorization } from "./EmailActionEvidence.mjs";
|
|
11
|
+
import { Context, Effect } from "effect";
|
|
12
|
+
//#region src/email/EmailAddressPersistence.d.ts
|
|
13
|
+
type PrepareEmailCommit<V, A> = (value: V, journal: CommitJournal) => PreparedCommit<A>;
|
|
14
|
+
interface EmailAddressTarget {
|
|
15
|
+
readonly revision: AuthenticationRevision;
|
|
16
|
+
readonly source?: EmailCredentialSnapshot;
|
|
17
|
+
/** Target absent or same-subject unverified. Conflicts remain privately suppressed. */
|
|
18
|
+
readonly eligible: boolean;
|
|
19
|
+
}
|
|
20
|
+
interface EmailAddressMutation {
|
|
21
|
+
readonly moduleId: string;
|
|
22
|
+
readonly commandId: EmailCommandId;
|
|
23
|
+
readonly target: LoginIdentifier;
|
|
24
|
+
readonly captured: EmailAddressTarget;
|
|
25
|
+
readonly authorization: EmailActionAuthorization;
|
|
26
|
+
readonly completion: ProofCompletionPlan;
|
|
27
|
+
readonly invalidation: SessionInvalidationWindow;
|
|
28
|
+
}
|
|
29
|
+
declare const EmailAddressPersistence_base: Context.ServiceClass<EmailAddressPersistence, "effect-auth/EmailAddressPersistence", {
|
|
30
|
+
readonly target: (input: {
|
|
31
|
+
readonly moduleId: string;
|
|
32
|
+
readonly subjectId: SubjectId;
|
|
33
|
+
readonly target: LoginIdentifier;
|
|
34
|
+
readonly sourceCredentialId?: string;
|
|
35
|
+
}) => Effect.Effect<EmailAddressTarget, EmailUnavailable>;
|
|
36
|
+
/** Nonconsuming authoritative preflight before consuming independent action proof. Final mutation repeats it. */
|
|
37
|
+
readonly checkCompletion: (input: ProofCompletionInput) => Effect.Effect<boolean, EmailUnavailable>;
|
|
38
|
+
readonly verifyWithProof: <A>(input: EmailAddressMutation, prepare: PrepareEmailCommit<EmailAddressDecision, A>) => Effect.Effect<PreparedCommit<A>, EmailUnavailable>;
|
|
39
|
+
readonly changeWithProof: <A>(input: EmailAddressMutation, prepare: PrepareEmailCommit<EmailAddressDecision, A>) => Effect.Effect<PreparedCommit<A>, EmailUnavailable>;
|
|
40
|
+
readonly cleanup: <A>(input: {
|
|
41
|
+
readonly moduleId: string;
|
|
42
|
+
readonly limit: number;
|
|
43
|
+
}, prepare: PrepareEmailCommit<{
|
|
44
|
+
readonly removed: number;
|
|
45
|
+
readonly hasMore: boolean;
|
|
46
|
+
}, A>) => Effect.Effect<PreparedCommit<A>, EmailUnavailable>;
|
|
47
|
+
}>;
|
|
48
|
+
/** Same-authority identity mutations, never generic CRUD. Preparation/crypto/hooks
|
|
49
|
+
* run before locks; plan.commit resolves the actual transaction-bound implementation
|
|
50
|
+
* from Effect context when it executes.
|
|
51
|
+
* Root implementations reject ambient ownership they cannot join before writes.
|
|
52
|
+
* Verify/change consume the exact continuation, enforce current subject/source and
|
|
53
|
+
* factor-policy/fresh-clock predicates, global target uniqueness, write verified
|
|
54
|
+
* identifier + email credential, bump binding/credential/security revisions, and
|
|
55
|
+
* invalidate pending/sessions in ONE physical transaction/batch. A zero-row protected
|
|
56
|
+
* write cannot burn the proof. D1 preplans receipts before its guarded batch; exact
|
|
57
|
+
* guard loss discards that journal before a separate rejected owner. Unknown outcome
|
|
58
|
+
* is unavailable. Generic IdentityMutation remains unmounted without this same join.
|
|
59
|
+
*/
|
|
60
|
+
declare class EmailAddressPersistence extends EmailAddressPersistence_base {}
|
|
61
|
+
//#endregion
|
|
62
|
+
export { EmailAddressMutation, EmailAddressPersistence, EmailAddressTarget, PrepareEmailCommit };
|
|
63
|
+
//# sourceMappingURL=EmailAddressPersistence.d.mts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Context } from "effect";
|
|
2
|
+
//#region src/email/EmailAddressPersistence.ts
|
|
3
|
+
/** Same-authority identity mutations, never generic CRUD. Preparation/crypto/hooks
|
|
4
|
+
* run before locks; plan.commit resolves the actual transaction-bound implementation
|
|
5
|
+
* from Effect context when it executes.
|
|
6
|
+
* Root implementations reject ambient ownership they cannot join before writes.
|
|
7
|
+
* Verify/change consume the exact continuation, enforce current subject/source and
|
|
8
|
+
* factor-policy/fresh-clock predicates, global target uniqueness, write verified
|
|
9
|
+
* identifier + email credential, bump binding/credential/security revisions, and
|
|
10
|
+
* invalidate pending/sessions in ONE physical transaction/batch. A zero-row protected
|
|
11
|
+
* write cannot burn the proof. D1 preplans receipts before its guarded batch; exact
|
|
12
|
+
* guard loss discards that journal before a separate rejected owner. Unknown outcome
|
|
13
|
+
* is unavailable. Generic IdentityMutation remains unmounted without this same join.
|
|
14
|
+
*/
|
|
15
|
+
var EmailAddressPersistence = class extends Context.Service()("effect-auth/EmailAddressPersistence") {};
|
|
16
|
+
//#endregion
|
|
17
|
+
export { EmailAddressPersistence };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=EmailAddressPersistence.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmailAddressPersistence.mjs","names":[],"sources":["../../src/email/EmailAddressPersistence.ts"],"sourcesContent":["import { Context, type Effect } from \"effect\";\n\nimport type { CommitJournal, PreparedCommit } from \"../hooks/commit\";\nimport type { LoginIdentifier } from \"../identity/models\";\nimport type { ProofCompletionPlan } from \"../proofs/completion\";\nimport type { ProofCompletionInput } from \"../proofs/ProofPersistence\";\nimport type { SubjectId } from \"../Schema\";\nimport type { SessionInvalidationWindow } from \"../sessions/invalidation\";\nimport type { AuthenticationRevision } from \"../sessions/models\";\nimport type { EmailActionAuthorization } from \"./EmailActionEvidence\";\nimport type { EmailUnavailable } from \"./errors\";\nimport type { EmailAddressDecision, EmailCommandId, EmailCredentialSnapshot } from \"./models\";\n\nexport type PrepareEmailCommit<V, A> = (value: V, journal: CommitJournal) => PreparedCommit<A>;\n\nexport interface EmailAddressTarget {\n readonly revision: AuthenticationRevision;\n readonly source?: EmailCredentialSnapshot;\n /** Target absent or same-subject unverified. Conflicts remain privately suppressed. */\n readonly eligible: boolean;\n}\n\nexport interface EmailAddressMutation {\n readonly moduleId: string;\n readonly commandId: EmailCommandId;\n readonly target: LoginIdentifier;\n readonly captured: EmailAddressTarget;\n readonly authorization: EmailActionAuthorization;\n readonly completion: ProofCompletionPlan;\n readonly invalidation: SessionInvalidationWindow;\n}\n\n/** Same-authority identity mutations, never generic CRUD. Preparation/crypto/hooks\n * run before locks; plan.commit resolves the actual transaction-bound implementation\n * from Effect context when it executes.\n * Root implementations reject ambient ownership they cannot join before writes.\n * Verify/change consume the exact continuation, enforce current subject/source and\n * factor-policy/fresh-clock predicates, global target uniqueness, write verified\n * identifier + email credential, bump binding/credential/security revisions, and\n * invalidate pending/sessions in ONE physical transaction/batch. A zero-row protected\n * write cannot burn the proof. D1 preplans receipts before its guarded batch; exact\n * guard loss discards that journal before a separate rejected owner. Unknown outcome\n * is unavailable. Generic IdentityMutation remains unmounted without this same join.\n */\nexport class EmailAddressPersistence extends Context.Service<\n EmailAddressPersistence,\n {\n readonly target: (input: {\n readonly moduleId: string;\n readonly subjectId: SubjectId;\n readonly target: LoginIdentifier;\n readonly sourceCredentialId?: string;\n }) => Effect.Effect<EmailAddressTarget, EmailUnavailable>;\n /** Nonconsuming authoritative preflight before consuming independent action proof. Final mutation repeats it. */\n readonly checkCompletion: (\n input: ProofCompletionInput,\n ) => Effect.Effect<boolean, EmailUnavailable>;\n readonly verifyWithProof: <A>(\n input: EmailAddressMutation,\n prepare: PrepareEmailCommit<EmailAddressDecision, A>,\n ) => Effect.Effect<PreparedCommit<A>, EmailUnavailable>;\n readonly changeWithProof: <A>(\n input: EmailAddressMutation,\n prepare: PrepareEmailCommit<EmailAddressDecision, A>,\n ) => Effect.Effect<PreparedCommit<A>, EmailUnavailable>;\n readonly cleanup: <A>(\n input: { readonly moduleId: string; readonly limit: number },\n prepare: PrepareEmailCommit<{ readonly removed: number; readonly hasMore: boolean }, A>,\n ) => Effect.Effect<PreparedCommit<A>, EmailUnavailable>;\n }\n>()(\"effect-auth/EmailAddressPersistence\") {}\n"],"mappings":";;;;;;;;;;;;;;AA4CA,IAAa,0BAAb,cAA6C,QAAQ,QA0BnD,CAAC,CAAC,qCAAqC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { LoginIdentifier } from "../identity/models.mjs";
|
|
2
|
+
import { HookDeliveryFailed, LifecycleEventId } from "../hooks/models.mjs";
|
|
3
|
+
import { HookContributionId, HookHandlers } from "../hooks/LifecycleHooks.mjs";
|
|
4
|
+
import "../Hooks.mjs";
|
|
5
|
+
import { Context, Effect } from "effect";
|
|
6
|
+
//#region src/email/EmailIdentifierNotifier.d.ts
|
|
7
|
+
declare const EmailIdentifierNotifier_base: Context.ServiceClass<EmailIdentifierNotifier, "effect-auth/EmailIdentifierNotifier", {
|
|
8
|
+
readonly notify: (input: {
|
|
9
|
+
readonly eventId: LifecycleEventId;
|
|
10
|
+
readonly oldIdentifier: LoginIdentifier;
|
|
11
|
+
readonly newIdentifier: LoginIdentifier;
|
|
12
|
+
readonly occurredAtMillis: number;
|
|
13
|
+
}) => Effect.Effect<void, HookDeliveryFailed>;
|
|
14
|
+
}>;
|
|
15
|
+
/** Optional explicit notification capability. Vendor failure never rolls back an
|
|
16
|
+
* identifier change. Stable event IDs support consumer idempotency; direct hooks
|
|
17
|
+
* are best effort, not a durable outbox or an exactly-once delivery guarantee.
|
|
18
|
+
*/
|
|
19
|
+
declare class EmailIdentifierNotifier extends EmailIdentifierNotifier_base {}
|
|
20
|
+
declare const emailIdentifierNotifications: <const Id extends string>(moduleId: Id) => Readonly<{
|
|
21
|
+
contribution: Readonly<{
|
|
22
|
+
id: `email/${Id}/old-address-notification`;
|
|
23
|
+
resolve: Effect.Effect<HookHandlers<never, HookDeliveryFailed>, never, HookContributionId<`email/${Id}/old-address-notification`>>;
|
|
24
|
+
layer: <R, E>(handlers: HookHandlers<R, E>) => import("effect/Layer").Layer<HookContributionId<`email/${Id}/old-address-notification`>, never, Exclude<R, import("effect/Scope").Scope>>;
|
|
25
|
+
}>;
|
|
26
|
+
layer: import("effect/Layer").Layer<HookContributionId<`email/${Id}/old-address-notification`>, never, EmailIdentifierNotifier>;
|
|
27
|
+
}>;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { EmailIdentifierNotifier, emailIdentifierNotifications };
|
|
30
|
+
//# sourceMappingURL=EmailIdentifierNotifier.d.mts.map
|