@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,1808 @@
|
|
|
1
|
+
/* oxlint-disable no-explicit-any -- D1 batches bridge consumer-owned Drizzle tables. */
|
|
2
|
+
import type { D1Client } from "@effect/sql-d1/D1Client";
|
|
3
|
+
import { and, eq, inArray, lte, sql, type AnyRelations, type SQL, type Table } from "drizzle-orm";
|
|
4
|
+
import type { EffectDrizzleQueryError } from "drizzle-orm/effect-core";
|
|
5
|
+
import type { EffectSQLiteD1Database } from "drizzle-orm/effect-d1";
|
|
6
|
+
import type { AnySQLiteTable } from "drizzle-orm/sqlite-core";
|
|
7
|
+
import { Schema, Cause, DateTime, Effect, Option, Context } from "effect";
|
|
8
|
+
import type { Statement } from "effect/unstable/sql/Statement";
|
|
9
|
+
|
|
10
|
+
import { EmailAddressPersistence } from "../email/EmailAddressPersistence";
|
|
11
|
+
import { EmailSignInTargets } from "../email/EmailSignInTargets";
|
|
12
|
+
import { EmailUnavailable } from "../email/errors";
|
|
13
|
+
import type { EmailAction, EmailAddressDecision, EmailRegistrationDecision } from "../email/models";
|
|
14
|
+
import {
|
|
15
|
+
coordinateCommit,
|
|
16
|
+
CurrentCommitJournal,
|
|
17
|
+
hasCommitScope,
|
|
18
|
+
type CommitJournal,
|
|
19
|
+
type PreparedCommit,
|
|
20
|
+
} from "../hooks/commit";
|
|
21
|
+
import { LifecycleHooks } from "../hooks/LifecycleHooks";
|
|
22
|
+
import { HookConfigurationError } from "../hooks/models";
|
|
23
|
+
import type { LoginIdentifier } from "../identity/models";
|
|
24
|
+
import { reportPersistenceFailure } from "../internal/diagnostics";
|
|
25
|
+
import type { ProofCompletionPlan } from "../proofs/completion";
|
|
26
|
+
import { ProofUnavailable } from "../proofs/errors";
|
|
27
|
+
import type { ProofCompletionInput } from "../proofs/ProofPersistence";
|
|
28
|
+
import type { TokenDigest } from "../Schema";
|
|
29
|
+
import { assessAuthentication } from "../sessions/assurance";
|
|
30
|
+
import type { AuthenticationRequirement, SecurityRevision } from "../sessions/models";
|
|
31
|
+
import { CurrentD1PlanningDatabase, makeD1Owner } from "./d1-planning";
|
|
32
|
+
import { compileD1ProofCompletionPlan } from "./d1-proofs";
|
|
33
|
+
import { D1BatchStatements } from "./D1BatchStatements";
|
|
34
|
+
import {
|
|
35
|
+
requiredEmailAddressConstraints,
|
|
36
|
+
requiredEmailRegistrationConstraints,
|
|
37
|
+
type D1EmailAddressMapping,
|
|
38
|
+
type D1EmailRegistrationMapping,
|
|
39
|
+
type EmailRegistrationMapping,
|
|
40
|
+
type EmailSignInMapping,
|
|
41
|
+
} from "./email-model";
|
|
42
|
+
import type { EmailRegistrationAuthority } from "./email-registration";
|
|
43
|
+
import {
|
|
44
|
+
CurrentEmailSql,
|
|
45
|
+
currentAddress,
|
|
46
|
+
decodeEmailSnapshot,
|
|
47
|
+
emailLookupQuery,
|
|
48
|
+
sameEmailRevision,
|
|
49
|
+
snapshotEmailMutation,
|
|
50
|
+
validEmailSignInConstraints,
|
|
51
|
+
validateEmailAuthority,
|
|
52
|
+
type CurrentAddress,
|
|
53
|
+
type EmailSqlDatabase,
|
|
54
|
+
} from "./email-sql";
|
|
55
|
+
import { column, isMappedConstraintConflict, DrizzleMappingError, updateValues } from "./model";
|
|
56
|
+
import type { D1ProofPersistenceMapping } from "./proof-model";
|
|
57
|
+
import type { SuppliedService } from "./SuppliedService";
|
|
58
|
+
|
|
59
|
+
type PlanPrepare<Method extends (...args: any[]) => any, A> = (
|
|
60
|
+
value: Parameters<Parameters<Method>[1]>[0],
|
|
61
|
+
journal: CommitJournal,
|
|
62
|
+
) => PreparedCommit<A>;
|
|
63
|
+
|
|
64
|
+
type Database = EffectSQLiteD1Database<AnyRelations> & { readonly $client: D1Client };
|
|
65
|
+
type AddressMapping = D1EmailAddressMapping<Table, Table, Table, Table, Table, unknown>;
|
|
66
|
+
type RegistrationMapping<Registration> = EmailRegistrationMapping<
|
|
67
|
+
Registration,
|
|
68
|
+
Table,
|
|
69
|
+
Table,
|
|
70
|
+
Table,
|
|
71
|
+
Table,
|
|
72
|
+
Table,
|
|
73
|
+
unknown
|
|
74
|
+
>;
|
|
75
|
+
type ProofMapping = D1ProofPersistenceMapping<
|
|
76
|
+
any,
|
|
77
|
+
any,
|
|
78
|
+
any,
|
|
79
|
+
any,
|
|
80
|
+
any,
|
|
81
|
+
any,
|
|
82
|
+
any,
|
|
83
|
+
any,
|
|
84
|
+
any,
|
|
85
|
+
any,
|
|
86
|
+
any,
|
|
87
|
+
any
|
|
88
|
+
>;
|
|
89
|
+
|
|
90
|
+
const emailLookupRows = Effect.fn("DrizzleD1.emailLookupRows")(function* (
|
|
91
|
+
mapping: EmailSignInMapping<Table, Table, Table, unknown>,
|
|
92
|
+
moduleId: string,
|
|
93
|
+
identifier: LoginIdentifier,
|
|
94
|
+
) {
|
|
95
|
+
const database = yield* CurrentD1PlanningDatabase;
|
|
96
|
+
const query = emailLookupQuery(mapping, moduleId, identifier);
|
|
97
|
+
|
|
98
|
+
return yield* database
|
|
99
|
+
.select(query.fields)
|
|
100
|
+
.from(query.from)
|
|
101
|
+
.innerJoin(query.subjectTable, query.subjectJoin)
|
|
102
|
+
.innerJoin(query.credentialTable, query.credentialJoin)
|
|
103
|
+
.where(query.predicate)
|
|
104
|
+
.limit(query.limit);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
const unavailable = () => EmailUnavailable.make({});
|
|
108
|
+
|
|
109
|
+
const everyFailureMatches = (
|
|
110
|
+
cause: Cause.Cause<unknown>,
|
|
111
|
+
classify: ((cause: unknown) => boolean) | undefined,
|
|
112
|
+
): boolean =>
|
|
113
|
+
classify !== undefined &&
|
|
114
|
+
cause.reasons.length > 0 &&
|
|
115
|
+
cause.reasons.every((reason) => Cause.isFailReason(reason) && classify(Cause.fail(reason.error)));
|
|
116
|
+
|
|
117
|
+
interface Planned<A> {
|
|
118
|
+
readonly receipt: A;
|
|
119
|
+
readonly statements: ReadonlyArray<Statement<any>>;
|
|
120
|
+
readonly retryable?: (cause: unknown) => boolean;
|
|
121
|
+
readonly journalGuard?: PreparedCommit<void>;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const statement = Effect.fn(function* (query: {
|
|
125
|
+
readonly toSQL: () => { readonly sql: string; readonly params: unknown[] };
|
|
126
|
+
}) {
|
|
127
|
+
const database = yield* CurrentD1PlanningDatabase;
|
|
128
|
+
const rendered = query.toSQL();
|
|
129
|
+
|
|
130
|
+
return database.$client.unsafe(rendered.sql, rendered.params);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
const containsFailure = (failure: unknown, predicate: (value: unknown) => boolean): boolean => {
|
|
134
|
+
const pending: unknown[] = [failure];
|
|
135
|
+
const seen = new Set<unknown>();
|
|
136
|
+
|
|
137
|
+
for (let index = 0; index < 32 && pending.length > 0; index++) {
|
|
138
|
+
const value = pending.shift();
|
|
139
|
+
|
|
140
|
+
if (value === null || value === undefined || seen.has(value)) continue;
|
|
141
|
+
seen.add(value);
|
|
142
|
+
if (predicate(value)) return true;
|
|
143
|
+
if (Cause.isCause(value)) {
|
|
144
|
+
for (const reason of value.reasons) {
|
|
145
|
+
if (Cause.isFailReason(reason)) pending.push(reason.error);
|
|
146
|
+
else if (Cause.isDieReason(reason)) pending.push(reason.defect);
|
|
147
|
+
}
|
|
148
|
+
} else if (typeof value === "object") {
|
|
149
|
+
const wrapped = value as {
|
|
150
|
+
readonly cause?: unknown;
|
|
151
|
+
readonly reason?: unknown;
|
|
152
|
+
readonly message?: unknown;
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
if (wrapped.cause !== undefined) pending.push(wrapped.cause);
|
|
156
|
+
if (wrapped.reason !== undefined) pending.push(wrapped.reason);
|
|
157
|
+
if (wrapped.message !== undefined) pending.push(wrapped.message);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return false;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
const guardFailure = (cause: unknown, marker: string) => {
|
|
165
|
+
const path = `$[${marker.replaceAll("'", "''")}]`;
|
|
166
|
+
const native = `bad JSON path: '${path}': SQLITE_ERROR`;
|
|
167
|
+
|
|
168
|
+
return containsFailure(cause, (value) => value === native || value === `D1_ERROR: ${native}`);
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
const assertion = Effect.fn(function* (condition: SQL, marker: string) {
|
|
172
|
+
const database = yield* CurrentD1PlanningDatabase;
|
|
173
|
+
|
|
174
|
+
return yield* statement(
|
|
175
|
+
database
|
|
176
|
+
.select({
|
|
177
|
+
ok: sql`case when ${condition} then 1 else json_extract('[]', ${`$[${marker}]`}) end`.as(
|
|
178
|
+
"ok",
|
|
179
|
+
),
|
|
180
|
+
})
|
|
181
|
+
.from(sql`(select 1)`),
|
|
182
|
+
);
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
const existsSql = (query: SQL) => sql`exists(${query})`;
|
|
186
|
+
const notExistsSql = (query: SQL) => sql`not exists(${query})`;
|
|
187
|
+
|
|
188
|
+
const readEngineNowMillis = Effect.fn("Drizzle.readEngineNowMillis")(function* (
|
|
189
|
+
clock: AddressMapping["d1"],
|
|
190
|
+
) {
|
|
191
|
+
const database = yield* CurrentD1PlanningDatabase;
|
|
192
|
+
|
|
193
|
+
return yield* awaitRows(
|
|
194
|
+
database
|
|
195
|
+
.select({
|
|
196
|
+
value: sql<number>`${clock.engineNowMillis}`.mapWith(Number),
|
|
197
|
+
})
|
|
198
|
+
.from(sql`(select 1)`),
|
|
199
|
+
).pipe(
|
|
200
|
+
Effect.flatMap((rows) =>
|
|
201
|
+
typeof rows[0]?.value === "number" && Number.isFinite(rows[0].value)
|
|
202
|
+
? Effect.succeed(rows[0].value)
|
|
203
|
+
: Effect.fail(unavailable()),
|
|
204
|
+
),
|
|
205
|
+
);
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
const driverValues = (values: object, entries: ReadonlyArray<readonly [string, unknown]>) => ({
|
|
209
|
+
...values,
|
|
210
|
+
...Object.fromEntries(entries),
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
const allocate = <A>(
|
|
214
|
+
asynchronous: Effect.Effect<A, DrizzleMappingError> | undefined,
|
|
215
|
+
synchronous: (() => A) | undefined,
|
|
216
|
+
) =>
|
|
217
|
+
asynchronous !== undefined
|
|
218
|
+
? asynchronous
|
|
219
|
+
: synchronous === undefined
|
|
220
|
+
? Effect.fail(unavailable())
|
|
221
|
+
: Effect.try({
|
|
222
|
+
try: synchronous,
|
|
223
|
+
catch: (cause) => new DrizzleMappingError({ operation: "mapping", cause }),
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
const validAddress = (mapping: AddressMapping) =>
|
|
227
|
+
Object.entries(requiredEmailAddressConstraints).every(
|
|
228
|
+
([key, value]) =>
|
|
229
|
+
mapping.constraints[key as keyof typeof requiredEmailAddressConstraints] === value,
|
|
230
|
+
);
|
|
231
|
+
|
|
232
|
+
const evidenceCondition = (
|
|
233
|
+
mapping: AddressMapping,
|
|
234
|
+
evidence: Parameters<typeof assessAuthentication>[0],
|
|
235
|
+
requirement: AuthenticationRequirement,
|
|
236
|
+
) => {
|
|
237
|
+
const fresh = (proof: (typeof evidence.proofs)[number]) => {
|
|
238
|
+
const verified = DateTime.toEpochMillis(proof.verifiedAt);
|
|
239
|
+
|
|
240
|
+
return sql`${mapping.d1.engineNowMillis} >= ${verified} and ${mapping.d1.engineNowMillis} - ${verified} < ${requirement.maximumAgeMillis}`;
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
const alternatives = requirement.alternatives.flatMap((alternative) => {
|
|
244
|
+
const byCredential = new Map<string, SQL[]>();
|
|
245
|
+
|
|
246
|
+
for (const proof of evidence.proofs)
|
|
247
|
+
byCredential.set(proof.credentialId, [
|
|
248
|
+
...(byCredential.get(proof.credentialId) ?? []),
|
|
249
|
+
fresh(proof),
|
|
250
|
+
]);
|
|
251
|
+
|
|
252
|
+
const credentials = [...byCredential.values()].map(
|
|
253
|
+
(conditions) => sql`(${sql.join(conditions, sql` or `)})`,
|
|
254
|
+
);
|
|
255
|
+
|
|
256
|
+
const factors = alternative.factors.map((factor) => {
|
|
257
|
+
const matches = evidence.proofs.filter((proof) => proof.factors.includes(factor)).map(fresh);
|
|
258
|
+
|
|
259
|
+
return matches.length === 0 ? sql`false` : sql`(${sql.join(matches, sql` or `)})`;
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
const assurance = evidence.proofs
|
|
263
|
+
.filter(
|
|
264
|
+
(proof) =>
|
|
265
|
+
(!alternative.userVerified || proof.userVerified) &&
|
|
266
|
+
(!alternative.phishingResistant || proof.phishingResistant),
|
|
267
|
+
)
|
|
268
|
+
.map(fresh);
|
|
269
|
+
|
|
270
|
+
if (assurance.length === 0 || credentials.length < alternative.minimumCredentials) return [];
|
|
271
|
+
|
|
272
|
+
const minimum =
|
|
273
|
+
alternative.minimumCredentials === 0
|
|
274
|
+
? sql`true`
|
|
275
|
+
: sql`(${sql.join(
|
|
276
|
+
credentials.map((condition) => sql`case when ${condition} then 1 else 0 end`),
|
|
277
|
+
sql` + `,
|
|
278
|
+
)}) >= ${alternative.minimumCredentials}`;
|
|
279
|
+
|
|
280
|
+
return [and(...factors, sql`(${sql.join(assurance, sql` or `)})`, minimum)!];
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
const noFuture = evidence.proofs.map(
|
|
284
|
+
(proof) => sql`${mapping.d1.engineNowMillis} >= ${DateTime.toEpochMillis(proof.verifiedAt)}`,
|
|
285
|
+
);
|
|
286
|
+
|
|
287
|
+
return alternatives.length === 0
|
|
288
|
+
? sql`false`
|
|
289
|
+
: and(...noFuture, sql`(${sql.join(alternatives, sql` or `)})`)!;
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
const subjectCondition = (
|
|
293
|
+
mapping: AddressMapping,
|
|
294
|
+
current: CurrentAddress,
|
|
295
|
+
revision: SecurityRevision,
|
|
296
|
+
) => {
|
|
297
|
+
const id = column(mapping.subject.table, mapping.subject.id);
|
|
298
|
+
const status = column(mapping.subject.table, mapping.subject.status);
|
|
299
|
+
const security = column(mapping.subject.table, mapping.subject.securityRevision);
|
|
300
|
+
|
|
301
|
+
return existsSql(
|
|
302
|
+
sql`select 1 from ${mapping.subject.table} where ${id}=${sql.param(current.nativeSubjectId, id)} and ${status}=${sql.param(mapping.subject.d1ActiveStatusValue, status)} and ${security}=${sql.param(revision, security)}`,
|
|
303
|
+
);
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
const authorityRevisionCondition = (mapping: AddressMapping, current: CurrentAddress) => {
|
|
307
|
+
const a = mapping.authorityCredential;
|
|
308
|
+
const subject = column(a.table, a.subjectId);
|
|
309
|
+
const credential = column(a.table, a.credentialId);
|
|
310
|
+
const revision = column(a.table, a.revision);
|
|
311
|
+
const status = column(a.table, a.status);
|
|
312
|
+
const expected = current.revision.credentials;
|
|
313
|
+
|
|
314
|
+
const matches = expected.map((item) =>
|
|
315
|
+
existsSql(
|
|
316
|
+
sql`select 1 from ${a.table} where ${subject}=${sql.param(current.nativeSubjectId, subject)} and ${credential}=${sql.param(item.credentialId, credential)} and ${revision}=${sql.param(item.revision, revision)} and ${status}=${sql.param(a.d1ActiveStatusValue, status)}`,
|
|
317
|
+
),
|
|
318
|
+
);
|
|
319
|
+
|
|
320
|
+
return and(
|
|
321
|
+
...matches,
|
|
322
|
+
sql`(select count(*) from ${a.table} where ${subject}=${sql.param(current.nativeSubjectId, subject)} and ${status}=${sql.param(a.d1ActiveStatusValue, status)})=${expected.length}`,
|
|
323
|
+
)!;
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
const mutationPlan = Effect.fn("Drizzle.mutationPlan")(function* <A>(
|
|
327
|
+
mapping: AddressMapping,
|
|
328
|
+
proofMapping: ProofMapping,
|
|
329
|
+
uncaptured: Parameters<EmailAddressPersistence["Service"]["verifyWithProof"]>[0],
|
|
330
|
+
action: EmailAction,
|
|
331
|
+
prepare: (value: EmailAddressDecision, journal: CommitJournal) => PreparedCommit<A>,
|
|
332
|
+
) {
|
|
333
|
+
const database = yield* CurrentD1PlanningDatabase;
|
|
334
|
+
|
|
335
|
+
const journal = yield* CurrentCommitJournal;
|
|
336
|
+
|
|
337
|
+
if (!validAddress(mapping)) return yield* unavailable();
|
|
338
|
+
const input = yield* snapshotEmailMutation(uncaptured).pipe(Effect.mapError(unavailable));
|
|
339
|
+
|
|
340
|
+
const current = yield* validateEmailAuthority(
|
|
341
|
+
mapping,
|
|
342
|
+
{ mode: "interactive", locking: false, standaloneGuard: Effect.void },
|
|
343
|
+
input,
|
|
344
|
+
action,
|
|
345
|
+
);
|
|
346
|
+
|
|
347
|
+
if (current === undefined) return { receipt: prepare("rejected", journal), statements: [] };
|
|
348
|
+
|
|
349
|
+
const existingCommand = awaitRows(
|
|
350
|
+
database
|
|
351
|
+
.select()
|
|
352
|
+
.from(mapping.command.table)
|
|
353
|
+
.where(
|
|
354
|
+
and(
|
|
355
|
+
eq(column(mapping.command.table, mapping.command.moduleId), input.moduleId),
|
|
356
|
+
eq(column(mapping.command.table, mapping.command.commandId), input.commandId),
|
|
357
|
+
),
|
|
358
|
+
)
|
|
359
|
+
.limit(1),
|
|
360
|
+
);
|
|
361
|
+
|
|
362
|
+
if ((yield* existingCommand).length > 0)
|
|
363
|
+
return { receipt: prepare("rejected", journal), statements: [] };
|
|
364
|
+
const requirement = yield* mapping.subject.decodeActionRequirement(current.subject, action);
|
|
365
|
+
|
|
366
|
+
const original = yield* assessAuthentication(
|
|
367
|
+
input.authorization.evidence,
|
|
368
|
+
input.authorization.requirement,
|
|
369
|
+
).pipe(Effect.mapError(unavailable));
|
|
370
|
+
|
|
371
|
+
const configured = yield* assessAuthentication(input.authorization.evidence, requirement).pipe(
|
|
372
|
+
Effect.mapError(unavailable),
|
|
373
|
+
);
|
|
374
|
+
|
|
375
|
+
if (!original.satisfied || !configured.satisfied)
|
|
376
|
+
return { receipt: prepare("rejected", journal), statements: [] };
|
|
377
|
+
const transitionMillis = yield* readEngineNowMillis(mapping.d1);
|
|
378
|
+
const transitionInstant = mapping.encodeInstant(transitionMillis);
|
|
379
|
+
|
|
380
|
+
const targetCredentialId =
|
|
381
|
+
current.targetCredential?.[mapping.credential.credentialId] ??
|
|
382
|
+
(yield* allocate(mapping.allocateCredentialId, mapping.allocateCredentialIdSync));
|
|
383
|
+
|
|
384
|
+
const targetIdentifierRevision = yield* allocate(
|
|
385
|
+
mapping.allocateRevision,
|
|
386
|
+
mapping.allocateRevisionSync,
|
|
387
|
+
);
|
|
388
|
+
|
|
389
|
+
const targetCredentialRevision = yield* allocate(
|
|
390
|
+
mapping.allocateRevision,
|
|
391
|
+
mapping.allocateRevisionSync,
|
|
392
|
+
);
|
|
393
|
+
|
|
394
|
+
const sourceIdentifierRevision = yield* allocate(
|
|
395
|
+
mapping.allocateRevision,
|
|
396
|
+
mapping.allocateRevisionSync,
|
|
397
|
+
);
|
|
398
|
+
|
|
399
|
+
const sourceCredentialRevision = yield* allocate(
|
|
400
|
+
mapping.allocateRevision,
|
|
401
|
+
mapping.allocateRevisionSync,
|
|
402
|
+
);
|
|
403
|
+
|
|
404
|
+
const nextRevision = yield* allocate(
|
|
405
|
+
mapping.subject.nextSecurityRevision?.(input.captured.revision.securityRevision) ??
|
|
406
|
+
mapping.allocateRevision,
|
|
407
|
+
mapping.subject.nextSecurityRevisionSync === undefined
|
|
408
|
+
? mapping.allocateRevisionSync
|
|
409
|
+
: () => mapping.subject.nextSecurityRevisionSync!(input.captured.revision.securityRevision),
|
|
410
|
+
);
|
|
411
|
+
|
|
412
|
+
if (
|
|
413
|
+
nextRevision === input.captured.revision.securityRevision ||
|
|
414
|
+
(current.targetIdentifier !== undefined &&
|
|
415
|
+
targetIdentifierRevision === current.targetIdentifier[mapping.identifier.bindingRevision]) ||
|
|
416
|
+
(current.targetCredential !== undefined &&
|
|
417
|
+
targetCredentialRevision ===
|
|
418
|
+
current.targetCredential[mapping.credential.credentialRevision]) ||
|
|
419
|
+
(current.source !== undefined &&
|
|
420
|
+
(sourceIdentifierRevision === current.source.snapshot.identifierRevision ||
|
|
421
|
+
sourceCredentialRevision === current.source.snapshot.credentialRevision))
|
|
422
|
+
)
|
|
423
|
+
return yield* unavailable();
|
|
424
|
+
const statements: Statement<any>[] = [];
|
|
425
|
+
const i = mapping.identifier;
|
|
426
|
+
const c = mapping.credential;
|
|
427
|
+
const a = mapping.authorityCredential;
|
|
428
|
+
const sc = current.source;
|
|
429
|
+
const authorityMarker = `effect-auth-email-guard:authority:${input.commandId}`;
|
|
430
|
+
|
|
431
|
+
const targetIdentifierPrecondition =
|
|
432
|
+
current.targetIdentifier === undefined
|
|
433
|
+
? notExistsSql(
|
|
434
|
+
sql`select 1 from ${i.table} where ${column(i.table, i.namespace)}=${sql.param(input.target.namespace, column(i.table, i.namespace))} and ${column(i.table, i.value)}=${sql.param(input.target.value, column(i.table, i.value))}`,
|
|
435
|
+
)
|
|
436
|
+
: existsSql(
|
|
437
|
+
sql`select 1 from ${i.table} where ${i.d1MutableTargetCondition({
|
|
438
|
+
identifier: input.target,
|
|
439
|
+
nativeSubjectId: current.nativeSubjectId,
|
|
440
|
+
})}`,
|
|
441
|
+
);
|
|
442
|
+
|
|
443
|
+
const targetCredentialPrecondition =
|
|
444
|
+
current.targetCredential === undefined
|
|
445
|
+
? notExistsSql(
|
|
446
|
+
sql`select 1 from ${c.table} where ${column(c.table, c.moduleId)}=${sql.param(input.moduleId, column(c.table, c.moduleId))} and ${column(c.table, c.identifierNamespace)}=${sql.param(input.target.namespace, column(c.table, c.identifierNamespace))} and ${column(c.table, c.identifierValue)}=${sql.param(input.target.value, column(c.table, c.identifierValue))}`,
|
|
447
|
+
)
|
|
448
|
+
: existsSql(
|
|
449
|
+
sql`select 1 from ${c.table} where ${column(c.table, c.moduleId)}=${sql.param(input.moduleId, column(c.table, c.moduleId))} and ${column(c.table, c.credentialId)}=${sql.param(current.targetCredential[c.credentialId], column(c.table, c.credentialId))} and ${column(c.table, c.subjectId)}=${sql.param(current.nativeSubjectId, column(c.table, c.subjectId))} and ${column(c.table, c.credentialRevision)}=${sql.param(current.targetCredential[c.credentialRevision], column(c.table, c.credentialRevision))} and ${column(c.table, c.status)}<>${sql.param(c.d1ActiveStatusValue, column(c.table, c.status))}`,
|
|
450
|
+
);
|
|
451
|
+
|
|
452
|
+
const sourcePrecondition =
|
|
453
|
+
action === "verify-address"
|
|
454
|
+
? sql`true`
|
|
455
|
+
: and(
|
|
456
|
+
existsSql(
|
|
457
|
+
sql`select 1 from ${i.table} where ${i.d1CurrentCondition({
|
|
458
|
+
identifier: sc!.snapshot.identifier,
|
|
459
|
+
nativeSubjectId: current.nativeSubjectId,
|
|
460
|
+
bindingRevision: sc!.snapshot.identifierRevision,
|
|
461
|
+
})}`,
|
|
462
|
+
),
|
|
463
|
+
existsSql(
|
|
464
|
+
sql`select 1 from ${c.table} where ${column(c.table, c.moduleId)}=${sql.param(input.moduleId, column(c.table, c.moduleId))} and ${column(c.table, c.credentialId)}=${sql.param(sc!.snapshot.credentialId, column(c.table, c.credentialId))} and ${column(c.table, c.subjectId)}=${sql.param(current.nativeSubjectId, column(c.table, c.subjectId))} and ${column(c.table, c.credentialRevision)}=${sql.param(sc!.snapshot.credentialRevision, column(c.table, c.credentialRevision))} and ${column(c.table, c.status)}=${sql.param(c.d1ActiveStatusValue, column(c.table, c.status))}`,
|
|
465
|
+
),
|
|
466
|
+
)!;
|
|
467
|
+
|
|
468
|
+
statements.push(
|
|
469
|
+
yield* assertion(
|
|
470
|
+
and(
|
|
471
|
+
subjectCondition(mapping, current, input.captured.revision.securityRevision),
|
|
472
|
+
authorityRevisionCondition(mapping, current),
|
|
473
|
+
targetIdentifierPrecondition,
|
|
474
|
+
targetCredentialPrecondition,
|
|
475
|
+
sourcePrecondition,
|
|
476
|
+
evidenceCondition(mapping, input.authorization.evidence, input.authorization.requirement),
|
|
477
|
+
evidenceCondition(mapping, input.authorization.evidence, requirement),
|
|
478
|
+
)!,
|
|
479
|
+
authorityMarker,
|
|
480
|
+
),
|
|
481
|
+
);
|
|
482
|
+
|
|
483
|
+
if (action === "change-address") {
|
|
484
|
+
statements.push(
|
|
485
|
+
yield* statement(
|
|
486
|
+
database
|
|
487
|
+
.update(i.table)
|
|
488
|
+
.set(
|
|
489
|
+
i.encodeRetirement({
|
|
490
|
+
source: sc!.snapshot.identifier,
|
|
491
|
+
bindingRevision: sourceIdentifierRevision,
|
|
492
|
+
}),
|
|
493
|
+
)
|
|
494
|
+
.where(
|
|
495
|
+
and(
|
|
496
|
+
eq(column(i.table, i.namespace), sc!.snapshot.identifier.namespace),
|
|
497
|
+
eq(column(i.table, i.value), sc!.snapshot.identifier.value),
|
|
498
|
+
eq(column(i.table, i.subjectId), current.nativeSubjectId),
|
|
499
|
+
eq(column(i.table, i.bindingRevision), sc!.snapshot.identifierRevision),
|
|
500
|
+
),
|
|
501
|
+
),
|
|
502
|
+
),
|
|
503
|
+
);
|
|
504
|
+
statements.push(
|
|
505
|
+
yield* statement(
|
|
506
|
+
database
|
|
507
|
+
.update(c.table)
|
|
508
|
+
.set(
|
|
509
|
+
c.encodeRetirement({
|
|
510
|
+
source: sc!.snapshot.identifier,
|
|
511
|
+
credentialRevision: sourceCredentialRevision,
|
|
512
|
+
}),
|
|
513
|
+
)
|
|
514
|
+
.where(
|
|
515
|
+
and(
|
|
516
|
+
eq(column(c.table, c.moduleId), input.moduleId),
|
|
517
|
+
eq(column(c.table, c.credentialId), sc!.snapshot.credentialId),
|
|
518
|
+
eq(column(c.table, c.subjectId), current.nativeSubjectId),
|
|
519
|
+
eq(column(c.table, c.credentialRevision), sc!.snapshot.credentialRevision),
|
|
520
|
+
),
|
|
521
|
+
),
|
|
522
|
+
),
|
|
523
|
+
);
|
|
524
|
+
statements.push(
|
|
525
|
+
yield* statement(
|
|
526
|
+
database
|
|
527
|
+
.update(a.table)
|
|
528
|
+
.set(a.encodeRetirement(sourceCredentialRevision))
|
|
529
|
+
.where(
|
|
530
|
+
and(
|
|
531
|
+
eq(column(a.table, a.subjectId), current.nativeSubjectId),
|
|
532
|
+
eq(column(a.table, a.credentialId), sc!.snapshot.credentialId),
|
|
533
|
+
eq(column(a.table, a.revision), sc!.snapshot.credentialRevision),
|
|
534
|
+
),
|
|
535
|
+
),
|
|
536
|
+
),
|
|
537
|
+
);
|
|
538
|
+
}
|
|
539
|
+
if (current.targetIdentifier === undefined)
|
|
540
|
+
statements.push(
|
|
541
|
+
yield* statement(
|
|
542
|
+
database.insert(i.table).values(
|
|
543
|
+
driverValues(
|
|
544
|
+
i.encodeVerifiedInsert({
|
|
545
|
+
identifier: input.target,
|
|
546
|
+
subjectId: current.nativeSubjectId,
|
|
547
|
+
verifiedAtMillis: transitionMillis,
|
|
548
|
+
bindingRevision: targetIdentifierRevision,
|
|
549
|
+
}),
|
|
550
|
+
[[i.verifiedAt, transitionInstant]],
|
|
551
|
+
),
|
|
552
|
+
),
|
|
553
|
+
),
|
|
554
|
+
);
|
|
555
|
+
else
|
|
556
|
+
statements.push(
|
|
557
|
+
yield* statement(
|
|
558
|
+
database
|
|
559
|
+
.update(i.table)
|
|
560
|
+
.set(
|
|
561
|
+
driverValues(
|
|
562
|
+
i.encodeVerification({
|
|
563
|
+
verifiedAtMillis: transitionMillis,
|
|
564
|
+
bindingRevision: targetIdentifierRevision,
|
|
565
|
+
}),
|
|
566
|
+
[[i.verifiedAt, transitionInstant]],
|
|
567
|
+
),
|
|
568
|
+
)
|
|
569
|
+
.where(
|
|
570
|
+
and(
|
|
571
|
+
eq(column(i.table, i.namespace), input.target.namespace),
|
|
572
|
+
eq(column(i.table, i.value), input.target.value),
|
|
573
|
+
eq(column(i.table, i.subjectId), current.nativeSubjectId),
|
|
574
|
+
eq(column(i.table, i.bindingRevision), current.targetIdentifier![i.bindingRevision]),
|
|
575
|
+
),
|
|
576
|
+
),
|
|
577
|
+
),
|
|
578
|
+
);
|
|
579
|
+
if (current.targetCredential === undefined) {
|
|
580
|
+
statements.push(
|
|
581
|
+
yield* statement(
|
|
582
|
+
database.insert(c.table).values(
|
|
583
|
+
c.encodeVerifiedInsert({
|
|
584
|
+
moduleId: input.moduleId,
|
|
585
|
+
subjectId: current.nativeSubjectId,
|
|
586
|
+
credentialId: targetCredentialId,
|
|
587
|
+
identifier: input.target,
|
|
588
|
+
credentialRevision: targetCredentialRevision,
|
|
589
|
+
}),
|
|
590
|
+
),
|
|
591
|
+
),
|
|
592
|
+
);
|
|
593
|
+
statements.push(
|
|
594
|
+
yield* statement(
|
|
595
|
+
database.insert(a.table).values(
|
|
596
|
+
a.encodeInsert({
|
|
597
|
+
subjectId: current.nativeSubjectId,
|
|
598
|
+
credentialId: targetCredentialId,
|
|
599
|
+
revision: targetCredentialRevision,
|
|
600
|
+
}),
|
|
601
|
+
),
|
|
602
|
+
),
|
|
603
|
+
);
|
|
604
|
+
} else {
|
|
605
|
+
const oldRevision = current.targetCredential[c.credentialRevision];
|
|
606
|
+
|
|
607
|
+
statements.push(
|
|
608
|
+
yield* statement(
|
|
609
|
+
database
|
|
610
|
+
.update(c.table)
|
|
611
|
+
.set(
|
|
612
|
+
c.encodeActivation({
|
|
613
|
+
identifier: input.target,
|
|
614
|
+
credentialRevision: targetCredentialRevision,
|
|
615
|
+
}),
|
|
616
|
+
)
|
|
617
|
+
.where(
|
|
618
|
+
and(
|
|
619
|
+
eq(column(c.table, c.moduleId), input.moduleId),
|
|
620
|
+
eq(column(c.table, c.credentialId), targetCredentialId),
|
|
621
|
+
eq(column(c.table, c.subjectId), current.nativeSubjectId),
|
|
622
|
+
eq(column(c.table, c.credentialRevision), oldRevision),
|
|
623
|
+
),
|
|
624
|
+
),
|
|
625
|
+
),
|
|
626
|
+
);
|
|
627
|
+
statements.push(
|
|
628
|
+
yield* statement(
|
|
629
|
+
database
|
|
630
|
+
.update(a.table)
|
|
631
|
+
.set(a.encodeActivation(targetCredentialRevision))
|
|
632
|
+
.where(
|
|
633
|
+
and(
|
|
634
|
+
eq(column(a.table, a.subjectId), current.nativeSubjectId),
|
|
635
|
+
eq(column(a.table, a.credentialId), targetCredentialId),
|
|
636
|
+
eq(column(a.table, a.revision), oldRevision),
|
|
637
|
+
),
|
|
638
|
+
),
|
|
639
|
+
),
|
|
640
|
+
);
|
|
641
|
+
}
|
|
642
|
+
statements.push(
|
|
643
|
+
yield* statement(
|
|
644
|
+
database
|
|
645
|
+
.update(mapping.subject.table)
|
|
646
|
+
.set(updateValues<any>([[mapping.subject.securityRevision, nextRevision]]))
|
|
647
|
+
.where(
|
|
648
|
+
and(
|
|
649
|
+
eq(column(mapping.subject.table, mapping.subject.id), current.nativeSubjectId),
|
|
650
|
+
eq(
|
|
651
|
+
column(mapping.subject.table, mapping.subject.securityRevision),
|
|
652
|
+
input.captured.revision.securityRevision,
|
|
653
|
+
),
|
|
654
|
+
),
|
|
655
|
+
),
|
|
656
|
+
),
|
|
657
|
+
);
|
|
658
|
+
statements.push(
|
|
659
|
+
yield* statement(
|
|
660
|
+
database.insert(mapping.command.table).values(
|
|
661
|
+
driverValues(
|
|
662
|
+
mapping.command.encodeInsert({
|
|
663
|
+
moduleId: input.moduleId,
|
|
664
|
+
commandId: input.commandId,
|
|
665
|
+
action,
|
|
666
|
+
bindingDigest: input.authorization.challenge.bindingDigest,
|
|
667
|
+
retentionUntilMillis: transitionMillis + mapping.commandRetentionMillis,
|
|
668
|
+
}),
|
|
669
|
+
[
|
|
670
|
+
[
|
|
671
|
+
mapping.command.retentionUntil,
|
|
672
|
+
mapping.encodeInstant(transitionMillis + mapping.commandRetentionMillis),
|
|
673
|
+
],
|
|
674
|
+
],
|
|
675
|
+
),
|
|
676
|
+
),
|
|
677
|
+
),
|
|
678
|
+
);
|
|
679
|
+
|
|
680
|
+
const targetExists = existsSql(
|
|
681
|
+
sql`select 1 from ${i.table} where ${column(i.table, i.bindingRevision)}=${sql.param(targetIdentifierRevision, column(i.table, i.bindingRevision))} and ${column(i.table, i.verifiedAt)}=${sql.param(transitionInstant, column(i.table, i.verifiedAt))} and ${i.d1CurrentCondition({ identifier: input.target, nativeSubjectId: current.nativeSubjectId, bindingRevision: targetIdentifierRevision })}`,
|
|
682
|
+
);
|
|
683
|
+
|
|
684
|
+
const credentialExists = existsSql(
|
|
685
|
+
sql`select 1 from ${c.table} where ${column(c.table, c.moduleId)}=${sql.param(input.moduleId, column(c.table, c.moduleId))} and ${column(c.table, c.credentialId)}=${sql.param(targetCredentialId, column(c.table, c.credentialId))} and ${column(c.table, c.subjectId)}=${sql.param(current.nativeSubjectId, column(c.table, c.subjectId))} and ${column(c.table, c.identifierNamespace)}=${sql.param(input.target.namespace, column(c.table, c.identifierNamespace))} and ${column(c.table, c.identifierValue)}=${sql.param(input.target.value, column(c.table, c.identifierValue))} and ${column(c.table, c.credentialRevision)}=${sql.param(targetCredentialRevision, column(c.table, c.credentialRevision))} and ${column(c.table, c.status)}=${sql.param(c.d1ActiveStatusValue, column(c.table, c.status))}`,
|
|
686
|
+
);
|
|
687
|
+
|
|
688
|
+
const authorityExists = existsSql(
|
|
689
|
+
sql`select 1 from ${a.table} where ${column(a.table, a.subjectId)}=${sql.param(current.nativeSubjectId, column(a.table, a.subjectId))} and ${column(a.table, a.credentialId)}=${sql.param(targetCredentialId, column(a.table, a.credentialId))} and ${column(a.table, a.revision)}=${sql.param(targetCredentialRevision, column(a.table, a.revision))} and ${column(a.table, a.status)}=${sql.param(a.d1ActiveStatusValue, column(a.table, a.status))}`,
|
|
690
|
+
);
|
|
691
|
+
|
|
692
|
+
const commandExists = existsSql(
|
|
693
|
+
sql`select 1 from ${mapping.command.table} where ${column(mapping.command.table, mapping.command.moduleId)}=${sql.param(input.moduleId, column(mapping.command.table, mapping.command.moduleId))} and ${column(mapping.command.table, mapping.command.commandId)}=${sql.param(input.commandId, column(mapping.command.table, mapping.command.commandId))} and ${column(mapping.command.table, mapping.command.action)}=${sql.param(action, column(mapping.command.table, mapping.command.action))} and ${column(mapping.command.table, mapping.command.bindingDigest)}=${sql.param(input.authorization.challenge.bindingDigest, column(mapping.command.table, mapping.command.bindingDigest))} and ${column(mapping.command.table, mapping.command.retentionUntil)}=${sql.param(mapping.encodeInstant(transitionMillis + mapping.commandRetentionMillis), column(mapping.command.table, mapping.command.retentionUntil))}`,
|
|
694
|
+
);
|
|
695
|
+
|
|
696
|
+
const sourceRetired =
|
|
697
|
+
action === "verify-address"
|
|
698
|
+
? sql`true`
|
|
699
|
+
: and(
|
|
700
|
+
existsSql(
|
|
701
|
+
sql`select 1 from ${i.table} where ${column(i.table, i.namespace)}=${sql.param(sc!.snapshot.identifier.namespace, column(i.table, i.namespace))} and ${column(i.table, i.value)}=${sql.param(sc!.snapshot.identifier.value, column(i.table, i.value))} and ${column(i.table, i.subjectId)}=${sql.param(current.nativeSubjectId, column(i.table, i.subjectId))} and ${column(i.table, i.bindingRevision)}=${sql.param(sourceIdentifierRevision, column(i.table, i.bindingRevision))} and not (${i.d1CurrentCondition({ identifier: sc!.snapshot.identifier, nativeSubjectId: current.nativeSubjectId, bindingRevision: sourceIdentifierRevision })})`,
|
|
702
|
+
),
|
|
703
|
+
existsSql(
|
|
704
|
+
sql`select 1 from ${c.table} where ${column(c.table, c.moduleId)}=${sql.param(input.moduleId, column(c.table, c.moduleId))} and ${column(c.table, c.credentialId)}=${sql.param(sc!.snapshot.credentialId, column(c.table, c.credentialId))} and ${column(c.table, c.subjectId)}=${sql.param(current.nativeSubjectId, column(c.table, c.subjectId))} and ${column(c.table, c.identifierNamespace)}=${sql.param(sc!.snapshot.identifier.namespace, column(c.table, c.identifierNamespace))} and ${column(c.table, c.identifierValue)}=${sql.param(sc!.snapshot.identifier.value, column(c.table, c.identifierValue))} and ${column(c.table, c.credentialRevision)}=${sql.param(sourceCredentialRevision, column(c.table, c.credentialRevision))} and ${column(c.table, c.status)}<>${sql.param(c.d1ActiveStatusValue, column(c.table, c.status))}`,
|
|
705
|
+
),
|
|
706
|
+
existsSql(
|
|
707
|
+
sql`select 1 from ${a.table} where ${column(a.table, a.subjectId)}=${sql.param(current.nativeSubjectId, column(a.table, a.subjectId))} and ${column(a.table, a.credentialId)}=${sql.param(sc!.snapshot.credentialId, column(a.table, a.credentialId))} and ${column(a.table, a.revision)}=${sql.param(sourceCredentialRevision, column(a.table, a.revision))} and ${column(a.table, a.status)}<>${sql.param(a.d1ActiveStatusValue, column(a.table, a.status))}`,
|
|
708
|
+
),
|
|
709
|
+
)!;
|
|
710
|
+
|
|
711
|
+
const applied = and(
|
|
712
|
+
subjectCondition(mapping, current, nextRevision),
|
|
713
|
+
targetExists,
|
|
714
|
+
credentialExists,
|
|
715
|
+
authorityExists,
|
|
716
|
+
commandExists,
|
|
717
|
+
sourceRetired,
|
|
718
|
+
evidenceCondition(mapping, input.authorization.evidence, input.authorization.requirement),
|
|
719
|
+
evidenceCondition(mapping, input.authorization.evidence, requirement),
|
|
720
|
+
)!;
|
|
721
|
+
|
|
722
|
+
const compiled = yield* compileD1ProofCompletionPlan(
|
|
723
|
+
proofMapping,
|
|
724
|
+
input.completion,
|
|
725
|
+
{ statements, appliedCondition: applied },
|
|
726
|
+
(decision) => decision,
|
|
727
|
+
);
|
|
728
|
+
|
|
729
|
+
const marker = `effect-auth-proof-guard:protected:${input.completion.input.continuationId}`;
|
|
730
|
+
|
|
731
|
+
return {
|
|
732
|
+
receipt: prepare(compiled.statements.length === 0 ? "rejected" : "changed", journal),
|
|
733
|
+
statements: compiled.statements,
|
|
734
|
+
retryable: (cause: unknown) =>
|
|
735
|
+
guardFailure(cause, marker) ||
|
|
736
|
+
guardFailure(cause, authorityMarker) ||
|
|
737
|
+
isMappedConstraintConflict(mapping.isCommandConflict, cause) ||
|
|
738
|
+
isMappedConstraintConflict(mapping.isIdentifierConflict, cause) ||
|
|
739
|
+
isMappedConstraintConflict(mapping.isCredentialConflict, cause),
|
|
740
|
+
};
|
|
741
|
+
});
|
|
742
|
+
|
|
743
|
+
const awaitRows = <A>(effect: Effect.Effect<A, DrizzleMappingError | EffectDrizzleQueryError>) =>
|
|
744
|
+
effect;
|
|
745
|
+
|
|
746
|
+
const probeCompletion = Effect.fn("DrizzleD1.probeCompletion")(function* (
|
|
747
|
+
proofMapping: ProofMapping,
|
|
748
|
+
input: ProofCompletionInput,
|
|
749
|
+
) {
|
|
750
|
+
const database = yield* CurrentD1PlanningDatabase;
|
|
751
|
+
|
|
752
|
+
const plan: ProofCompletionPlan = {
|
|
753
|
+
input,
|
|
754
|
+
prepare: (decision, journal, project) => journal.prepare(project(decision)),
|
|
755
|
+
};
|
|
756
|
+
|
|
757
|
+
const marker = `effect-auth-proof-guard:protected:${input.continuationId}`;
|
|
758
|
+
|
|
759
|
+
const once = coordinateCommit(
|
|
760
|
+
() =>
|
|
761
|
+
Effect.gen(function* () {
|
|
762
|
+
const compiled = yield* compileD1ProofCompletionPlan(
|
|
763
|
+
proofMapping,
|
|
764
|
+
plan,
|
|
765
|
+
{ statements: [], appliedCondition: sql`false` },
|
|
766
|
+
() => false,
|
|
767
|
+
);
|
|
768
|
+
|
|
769
|
+
if (compiled.statements.length === 0) return false;
|
|
770
|
+
yield* database.$client.batch(compiled.statements);
|
|
771
|
+
|
|
772
|
+
return false;
|
|
773
|
+
}),
|
|
774
|
+
{ mode: "batch" },
|
|
775
|
+
);
|
|
776
|
+
|
|
777
|
+
return yield* once.pipe(
|
|
778
|
+
Effect.as(false),
|
|
779
|
+
Effect.catchCause((cause) =>
|
|
780
|
+
guardFailure(cause, marker) ? Effect.succeed(true) : Effect.failCause(cause),
|
|
781
|
+
),
|
|
782
|
+
);
|
|
783
|
+
});
|
|
784
|
+
|
|
785
|
+
const makeAddressPlans = (mapping: AddressMapping, proofMapping: ProofMapping) => ({
|
|
786
|
+
target: (input: Parameters<EmailAddressPersistence["Service"]["target"]>[0]) =>
|
|
787
|
+
currentAddress(mapping, input, false).pipe(
|
|
788
|
+
Effect.flatMap((current) =>
|
|
789
|
+
current === undefined
|
|
790
|
+
? Effect.fail(unavailable())
|
|
791
|
+
: Effect.succeed({
|
|
792
|
+
revision: current.revision,
|
|
793
|
+
eligible: current.eligible,
|
|
794
|
+
...(current.source === undefined ? {} : { source: current.source.snapshot }),
|
|
795
|
+
}),
|
|
796
|
+
),
|
|
797
|
+
),
|
|
798
|
+
checkCompletion: (
|
|
799
|
+
input: Parameters<EmailAddressPersistence["Service"]["checkCompletion"]>[0],
|
|
800
|
+
) => {
|
|
801
|
+
if (input.binding._tag !== "IdentifierChange") return Effect.succeed(false);
|
|
802
|
+
const binding = input.binding;
|
|
803
|
+
|
|
804
|
+
const action: EmailAction | undefined =
|
|
805
|
+
input.moduleId.endsWith("/verify-address") && input.purpose === "email-address-verification"
|
|
806
|
+
? "verify-address"
|
|
807
|
+
: input.moduleId.endsWith("/change-address") && input.purpose === "email-address-change"
|
|
808
|
+
? "change-address"
|
|
809
|
+
: undefined;
|
|
810
|
+
|
|
811
|
+
if (action === undefined) return Effect.succeed(false);
|
|
812
|
+
const moduleId = input.moduleId.slice(0, -`/${action}`.length);
|
|
813
|
+
|
|
814
|
+
return currentAddress(
|
|
815
|
+
mapping,
|
|
816
|
+
{
|
|
817
|
+
moduleId,
|
|
818
|
+
subjectId: binding.revision.subjectId,
|
|
819
|
+
target: binding.identifier,
|
|
820
|
+
},
|
|
821
|
+
false,
|
|
822
|
+
).pipe(
|
|
823
|
+
Effect.flatMap((current) =>
|
|
824
|
+
current !== undefined && sameEmailRevision(current.revision, binding.revision)
|
|
825
|
+
? probeCompletion(proofMapping, input)
|
|
826
|
+
: Effect.succeed(false),
|
|
827
|
+
),
|
|
828
|
+
);
|
|
829
|
+
},
|
|
830
|
+
verifyWithProof: <A>(
|
|
831
|
+
input: Parameters<EmailAddressPersistence["Service"]["verifyWithProof"]>[0],
|
|
832
|
+
prepare: PlanPrepare<EmailAddressPersistence["Service"]["verifyWithProof"], A>,
|
|
833
|
+
) => mutationPlan(mapping, proofMapping, input, "verify-address", prepare),
|
|
834
|
+
changeWithProof: <A>(
|
|
835
|
+
input: Parameters<EmailAddressPersistence["Service"]["changeWithProof"]>[0],
|
|
836
|
+
prepare: PlanPrepare<EmailAddressPersistence["Service"]["changeWithProof"], A>,
|
|
837
|
+
) => mutationPlan(mapping, proofMapping, input, "change-address", prepare),
|
|
838
|
+
cleanup: <A>(
|
|
839
|
+
input: Parameters<EmailAddressPersistence["Service"]["cleanup"]>[0],
|
|
840
|
+
prepare: PlanPrepare<EmailAddressPersistence["Service"]["cleanup"], A>,
|
|
841
|
+
) =>
|
|
842
|
+
Effect.gen(function* () {
|
|
843
|
+
const database = yield* CurrentD1PlanningDatabase;
|
|
844
|
+
|
|
845
|
+
const journal = yield* CurrentCommitJournal;
|
|
846
|
+
|
|
847
|
+
const module = column(mapping.command.table, mapping.command.moduleId);
|
|
848
|
+
const id = column(mapping.command.table, mapping.command.commandId);
|
|
849
|
+
const retention = column(mapping.command.table, mapping.command.retentionUntil);
|
|
850
|
+
|
|
851
|
+
const rows = yield* awaitRows(
|
|
852
|
+
database
|
|
853
|
+
.select({ commandId: id })
|
|
854
|
+
.from(mapping.command.table)
|
|
855
|
+
.where(and(eq(module, input.moduleId), lte(retention, mapping.d1.engineNow)))
|
|
856
|
+
.limit(input.limit + 1),
|
|
857
|
+
);
|
|
858
|
+
|
|
859
|
+
const selected = rows.slice(0, input.limit);
|
|
860
|
+
const marker = `effect-auth-email-guard:cleanup:${input.moduleId}`;
|
|
861
|
+
const selectedIds = selected.map((row: any) => row.commandId);
|
|
862
|
+
|
|
863
|
+
const selectedWhere = and(
|
|
864
|
+
eq(module, input.moduleId),
|
|
865
|
+
inArray(id, selectedIds),
|
|
866
|
+
lte(retention, mapping.d1.engineNow),
|
|
867
|
+
);
|
|
868
|
+
|
|
869
|
+
const statements =
|
|
870
|
+
selected.length === 0
|
|
871
|
+
? []
|
|
872
|
+
: [
|
|
873
|
+
yield* assertion(
|
|
874
|
+
sql`(select count(*) from ${mapping.command.table} where ${selectedWhere})=${selected.length}`,
|
|
875
|
+
marker,
|
|
876
|
+
),
|
|
877
|
+
yield* statement(database.delete(mapping.command.table).where(selectedWhere)),
|
|
878
|
+
];
|
|
879
|
+
|
|
880
|
+
return {
|
|
881
|
+
receipt: prepare({ removed: selected.length, hasMore: rows.length > input.limit }, journal),
|
|
882
|
+
statements,
|
|
883
|
+
retryable: (cause: unknown) => guardFailure(cause, marker),
|
|
884
|
+
};
|
|
885
|
+
}),
|
|
886
|
+
});
|
|
887
|
+
|
|
888
|
+
const registrationRows = Effect.fn("Drizzle.registrationRows")(function* <Registration>(
|
|
889
|
+
mapping: RegistrationMapping<Registration>,
|
|
890
|
+
moduleId: string,
|
|
891
|
+
commandId: string,
|
|
892
|
+
) {
|
|
893
|
+
const database = yield* CurrentD1PlanningDatabase;
|
|
894
|
+
|
|
895
|
+
return yield* awaitRows(
|
|
896
|
+
database
|
|
897
|
+
.select()
|
|
898
|
+
.from(mapping.registration.table)
|
|
899
|
+
.where(
|
|
900
|
+
and(
|
|
901
|
+
eq(column(mapping.registration.table, mapping.registration.moduleId), moduleId),
|
|
902
|
+
eq(column(mapping.registration.table, mapping.registration.commandId), commandId),
|
|
903
|
+
),
|
|
904
|
+
)
|
|
905
|
+
.limit(1),
|
|
906
|
+
);
|
|
907
|
+
});
|
|
908
|
+
|
|
909
|
+
const sameIdentifier = (left: LoginIdentifier, right: LoginIdentifier) =>
|
|
910
|
+
left.namespace === right.namespace && left.value === right.value;
|
|
911
|
+
|
|
912
|
+
const registrationCompletionMatches = <Registration>(
|
|
913
|
+
mapping: RegistrationMapping<Registration>,
|
|
914
|
+
input: {
|
|
915
|
+
readonly moduleId: string;
|
|
916
|
+
readonly identifier: LoginIdentifier;
|
|
917
|
+
readonly completion: ProofCompletionPlan;
|
|
918
|
+
},
|
|
919
|
+
) =>
|
|
920
|
+
input.completion.input.moduleId === `${input.moduleId}/registration` &&
|
|
921
|
+
input.completion.input.purpose === "email-code-registration" &&
|
|
922
|
+
input.completion.input.binding._tag === "Identifier" &&
|
|
923
|
+
sameIdentifier(input.completion.input.binding.identifier, input.identifier) &&
|
|
924
|
+
mapping.constraints.request === requiredEmailRegistrationConstraints.request &&
|
|
925
|
+
mapping.constraints.pendingReference === requiredEmailRegistrationConstraints.pendingReference &&
|
|
926
|
+
(mapping.mode === "pending" ||
|
|
927
|
+
Object.entries(requiredEmailRegistrationConstraints).every(
|
|
928
|
+
([key, value]) =>
|
|
929
|
+
mapping.constraints[key as keyof typeof requiredEmailRegistrationConstraints] === value,
|
|
930
|
+
));
|
|
931
|
+
|
|
932
|
+
const registrationPlan = Effect.fn("Drizzle.registrationPlan")(function* <Registration, A>(
|
|
933
|
+
mapping: RegistrationMapping<Registration> & { readonly d1: AddressMapping["d1"] },
|
|
934
|
+
proofMapping: ProofMapping,
|
|
935
|
+
input: {
|
|
936
|
+
readonly moduleId: string;
|
|
937
|
+
readonly commandId: string;
|
|
938
|
+
readonly identifier: LoginIdentifier;
|
|
939
|
+
readonly registration: Registration;
|
|
940
|
+
readonly fingerprint: TokenDigest;
|
|
941
|
+
readonly completion: ProofCompletionPlan;
|
|
942
|
+
},
|
|
943
|
+
inspected: { readonly fingerprint: TokenDigest; readonly eligible: boolean },
|
|
944
|
+
allocated: {
|
|
945
|
+
readonly credentialId?: string;
|
|
946
|
+
readonly securityRevision?: SecurityRevision;
|
|
947
|
+
readonly identifierRevision?: SecurityRevision;
|
|
948
|
+
readonly credentialRevision?: SecurityRevision;
|
|
949
|
+
readonly nativeSubjectId?: unknown;
|
|
950
|
+
readonly pendingReference?: string;
|
|
951
|
+
},
|
|
952
|
+
prepare: (value: EmailRegistrationDecision, journal: CommitJournal) => PreparedCommit<A>,
|
|
953
|
+
) {
|
|
954
|
+
const database = yield* CurrentD1PlanningDatabase;
|
|
955
|
+
|
|
956
|
+
const journal = yield* CurrentCommitJournal;
|
|
957
|
+
|
|
958
|
+
const existing = (yield* registrationRows(mapping, input.moduleId, input.commandId))[0];
|
|
959
|
+
|
|
960
|
+
if (existing !== undefined) {
|
|
961
|
+
const decision =
|
|
962
|
+
existing[mapping.registration.fingerprint] !== input.fingerprint
|
|
963
|
+
? ({ _tag: "Rejected" } as const)
|
|
964
|
+
: yield* mapping.registration.decodeReplay(existing);
|
|
965
|
+
|
|
966
|
+
return { receipt: prepare(decision, journal), statements: [] };
|
|
967
|
+
}
|
|
968
|
+
if (
|
|
969
|
+
!registrationCompletionMatches(mapping, input) ||
|
|
970
|
+
!inspected.eligible ||
|
|
971
|
+
inspected.fingerprint !== input.fingerprint ||
|
|
972
|
+
(mapping.mode === "atomic" &&
|
|
973
|
+
(mapping.provisioning.idMode === "generated" ||
|
|
974
|
+
mapping.subject.d1ActiveStatusValue === undefined ||
|
|
975
|
+
mapping.identifier.d1CurrentCondition === undefined ||
|
|
976
|
+
mapping.credential.d1ActiveStatusValue === undefined ||
|
|
977
|
+
mapping.authorityCredential.d1ActiveStatusValue === undefined))
|
|
978
|
+
)
|
|
979
|
+
return { receipt: prepare({ _tag: "Rejected" }, journal), statements: [] };
|
|
980
|
+
|
|
981
|
+
const intent = {
|
|
982
|
+
moduleId: input.moduleId,
|
|
983
|
+
commandId: input.commandId,
|
|
984
|
+
identifier: input.identifier,
|
|
985
|
+
registration: input.registration,
|
|
986
|
+
fingerprint: input.fingerprint,
|
|
987
|
+
completion: {
|
|
988
|
+
moduleId: input.completion.input.moduleId,
|
|
989
|
+
purpose: input.completion.input.purpose,
|
|
990
|
+
continuationId: input.completion.input.continuationId,
|
|
991
|
+
binding: input.completion.input.binding,
|
|
992
|
+
},
|
|
993
|
+
};
|
|
994
|
+
|
|
995
|
+
const transitionMillis = yield* readEngineNowMillis(mapping.d1);
|
|
996
|
+
const retentionInstant = mapping.encodeInstant(transitionMillis + mapping.retentionMillis);
|
|
997
|
+
const statements: Statement<any>[] = [];
|
|
998
|
+
let applied: SQL;
|
|
999
|
+
let desired: EmailRegistrationDecision;
|
|
1000
|
+
const registrationModule = column(mapping.registration.table, mapping.registration.moduleId);
|
|
1001
|
+
const registrationCommand = column(mapping.registration.table, mapping.registration.commandId);
|
|
1002
|
+
|
|
1003
|
+
const registrationFingerprint = column(
|
|
1004
|
+
mapping.registration.table,
|
|
1005
|
+
mapping.registration.fingerprint,
|
|
1006
|
+
);
|
|
1007
|
+
|
|
1008
|
+
const registrationState = column(mapping.registration.table, mapping.registration.state);
|
|
1009
|
+
|
|
1010
|
+
if (mapping.mode === "pending") {
|
|
1011
|
+
if (allocated.pendingReference === undefined)
|
|
1012
|
+
return { receipt: prepare({ _tag: "Rejected" }, journal), statements: [] };
|
|
1013
|
+
desired = { _tag: "ProvisioningPending", reference: allocated.pendingReference };
|
|
1014
|
+
statements.push(
|
|
1015
|
+
yield* statement(
|
|
1016
|
+
database.insert(mapping.registration.table).values(
|
|
1017
|
+
driverValues(
|
|
1018
|
+
mapping.registration.encodeInsert(intent, {
|
|
1019
|
+
state: "pending",
|
|
1020
|
+
pendingReference: allocated.pendingReference,
|
|
1021
|
+
retentionUntilMillis: transitionMillis + mapping.retentionMillis,
|
|
1022
|
+
}),
|
|
1023
|
+
[[mapping.registration.retentionUntil, retentionInstant]],
|
|
1024
|
+
),
|
|
1025
|
+
),
|
|
1026
|
+
),
|
|
1027
|
+
);
|
|
1028
|
+
applied = existsSql(
|
|
1029
|
+
sql`select 1 from ${mapping.registration.table} where ${registrationModule}=${sql.param(input.moduleId, registrationModule)} and ${registrationCommand}=${sql.param(input.commandId, registrationCommand)} and ${registrationFingerprint}=${sql.param(input.fingerprint, registrationFingerprint)} and ${registrationState}='pending' and ${column(mapping.registration.table, mapping.registration.pendingReference)}=${sql.param(allocated.pendingReference, column(mapping.registration.table, mapping.registration.pendingReference))} and ${column(mapping.registration.table, mapping.registration.subjectId)} is null and ${column(mapping.registration.table, mapping.registration.retentionUntil)}=${sql.param(retentionInstant, column(mapping.registration.table, mapping.registration.retentionUntil))}`,
|
|
1030
|
+
);
|
|
1031
|
+
} else {
|
|
1032
|
+
if (
|
|
1033
|
+
allocated.nativeSubjectId === undefined ||
|
|
1034
|
+
allocated.credentialId === undefined ||
|
|
1035
|
+
allocated.securityRevision === undefined ||
|
|
1036
|
+
allocated.identifierRevision === undefined ||
|
|
1037
|
+
allocated.credentialRevision === undefined
|
|
1038
|
+
)
|
|
1039
|
+
return { receipt: prepare({ _tag: "Rejected" }, journal), statements: [] };
|
|
1040
|
+
const nativeSubjectId = allocated.nativeSubjectId;
|
|
1041
|
+
|
|
1042
|
+
desired = { _tag: "Registered" };
|
|
1043
|
+
statements.push(
|
|
1044
|
+
yield* statement(
|
|
1045
|
+
database.insert(mapping.subject.table).values(
|
|
1046
|
+
mapping.provisioning.encodeSubjectInsert(intent, {
|
|
1047
|
+
nativeSubjectId,
|
|
1048
|
+
securityRevision: allocated.securityRevision,
|
|
1049
|
+
}),
|
|
1050
|
+
),
|
|
1051
|
+
),
|
|
1052
|
+
yield* statement(
|
|
1053
|
+
database.insert(mapping.identifier.table).values(
|
|
1054
|
+
driverValues(
|
|
1055
|
+
mapping.identifier.encodeVerifiedInsert({
|
|
1056
|
+
identifier: input.identifier,
|
|
1057
|
+
subjectId: nativeSubjectId,
|
|
1058
|
+
verifiedAtMillis: transitionMillis,
|
|
1059
|
+
bindingRevision: allocated.identifierRevision,
|
|
1060
|
+
}),
|
|
1061
|
+
[[mapping.identifier.verifiedAt, mapping.encodeInstant(transitionMillis)]],
|
|
1062
|
+
),
|
|
1063
|
+
),
|
|
1064
|
+
),
|
|
1065
|
+
yield* statement(
|
|
1066
|
+
database.insert(mapping.credential.table).values(
|
|
1067
|
+
mapping.credential.encodeVerifiedInsert({
|
|
1068
|
+
moduleId: input.moduleId,
|
|
1069
|
+
subjectId: nativeSubjectId,
|
|
1070
|
+
credentialId: allocated.credentialId,
|
|
1071
|
+
identifier: input.identifier,
|
|
1072
|
+
credentialRevision: allocated.credentialRevision,
|
|
1073
|
+
}),
|
|
1074
|
+
),
|
|
1075
|
+
),
|
|
1076
|
+
yield* statement(
|
|
1077
|
+
database.insert(mapping.authorityCredential.table).values(
|
|
1078
|
+
mapping.authorityCredential.encodeInsert({
|
|
1079
|
+
subjectId: nativeSubjectId,
|
|
1080
|
+
credentialId: allocated.credentialId,
|
|
1081
|
+
revision: allocated.credentialRevision,
|
|
1082
|
+
}),
|
|
1083
|
+
),
|
|
1084
|
+
),
|
|
1085
|
+
yield* statement(
|
|
1086
|
+
database.insert(mapping.registration.table).values(
|
|
1087
|
+
driverValues(
|
|
1088
|
+
mapping.registration.encodeInsert(intent, {
|
|
1089
|
+
state: "registered",
|
|
1090
|
+
nativeSubjectId,
|
|
1091
|
+
retentionUntilMillis: transitionMillis + mapping.retentionMillis,
|
|
1092
|
+
}),
|
|
1093
|
+
[[mapping.registration.retentionUntil, retentionInstant]],
|
|
1094
|
+
),
|
|
1095
|
+
),
|
|
1096
|
+
),
|
|
1097
|
+
);
|
|
1098
|
+
const sId = column(mapping.subject.table, mapping.subject.id);
|
|
1099
|
+
const sStatus = column(mapping.subject.table, mapping.subject.status);
|
|
1100
|
+
const sRevision = column(mapping.subject.table, mapping.subject.securityRevision);
|
|
1101
|
+
const iNamespace = column(mapping.identifier.table, mapping.identifier.namespace);
|
|
1102
|
+
const iValue = column(mapping.identifier.table, mapping.identifier.value);
|
|
1103
|
+
const iSubject = column(mapping.identifier.table, mapping.identifier.subjectId);
|
|
1104
|
+
const iVerifiedAt = column(mapping.identifier.table, mapping.identifier.verifiedAt);
|
|
1105
|
+
const iRevision = column(mapping.identifier.table, mapping.identifier.bindingRevision);
|
|
1106
|
+
const cModule = column(mapping.credential.table, mapping.credential.moduleId);
|
|
1107
|
+
const cSubject = column(mapping.credential.table, mapping.credential.subjectId);
|
|
1108
|
+
const cId = column(mapping.credential.table, mapping.credential.credentialId);
|
|
1109
|
+
const cNamespace = column(mapping.credential.table, mapping.credential.identifierNamespace);
|
|
1110
|
+
const cValue = column(mapping.credential.table, mapping.credential.identifierValue);
|
|
1111
|
+
const cRevision = column(mapping.credential.table, mapping.credential.credentialRevision);
|
|
1112
|
+
|
|
1113
|
+
const aSubject = column(
|
|
1114
|
+
mapping.authorityCredential.table,
|
|
1115
|
+
mapping.authorityCredential.subjectId,
|
|
1116
|
+
);
|
|
1117
|
+
|
|
1118
|
+
const aId = column(mapping.authorityCredential.table, mapping.authorityCredential.credentialId);
|
|
1119
|
+
|
|
1120
|
+
const aRevision = column(
|
|
1121
|
+
mapping.authorityCredential.table,
|
|
1122
|
+
mapping.authorityCredential.revision,
|
|
1123
|
+
);
|
|
1124
|
+
|
|
1125
|
+
applied = and(
|
|
1126
|
+
existsSql(
|
|
1127
|
+
sql`select 1 from ${mapping.subject.table} where ${sId}=${sql.param(nativeSubjectId, sId)} and ${sStatus}=${sql.param(mapping.subject.d1ActiveStatusValue, sStatus)} and ${sRevision}=${sql.param(allocated.securityRevision, sRevision)}`,
|
|
1128
|
+
),
|
|
1129
|
+
existsSql(
|
|
1130
|
+
sql`select 1 from ${mapping.identifier.table} where ${iNamespace}=${sql.param(input.identifier.namespace, iNamespace)} and ${iValue}=${sql.param(input.identifier.value, iValue)} and ${iSubject}=${sql.param(nativeSubjectId, iSubject)} and ${iVerifiedAt}=${sql.param(mapping.encodeInstant(transitionMillis), iVerifiedAt)} and ${iRevision}=${sql.param(allocated.identifierRevision, iRevision)} and ${mapping.identifier.d1CurrentCondition!({ identifier: input.identifier, nativeSubjectId, bindingRevision: allocated.identifierRevision })}`,
|
|
1131
|
+
),
|
|
1132
|
+
existsSql(
|
|
1133
|
+
sql`select 1 from ${mapping.credential.table} where ${cModule}=${sql.param(input.moduleId, cModule)} and ${cSubject}=${sql.param(nativeSubjectId, cSubject)} and ${cId}=${sql.param(allocated.credentialId, cId)} and ${cNamespace}=${sql.param(input.identifier.namespace, cNamespace)} and ${cValue}=${sql.param(input.identifier.value, cValue)} and ${cRevision}=${sql.param(allocated.credentialRevision, cRevision)} and ${column(mapping.credential.table, mapping.credential.status)}=${sql.param(mapping.credential.d1ActiveStatusValue, column(mapping.credential.table, mapping.credential.status))}`,
|
|
1134
|
+
),
|
|
1135
|
+
existsSql(
|
|
1136
|
+
sql`select 1 from ${mapping.authorityCredential.table} where ${aSubject}=${sql.param(nativeSubjectId, aSubject)} and ${aId}=${sql.param(allocated.credentialId, aId)} and ${aRevision}=${sql.param(allocated.credentialRevision, aRevision)} and ${column(mapping.authorityCredential.table, mapping.authorityCredential.status)}=${sql.param(mapping.authorityCredential.d1ActiveStatusValue, column(mapping.authorityCredential.table, mapping.authorityCredential.status))}`,
|
|
1137
|
+
),
|
|
1138
|
+
existsSql(
|
|
1139
|
+
sql`select 1 from ${mapping.registration.table} where ${registrationModule}=${sql.param(input.moduleId, registrationModule)} and ${registrationCommand}=${sql.param(input.commandId, registrationCommand)} and ${registrationFingerprint}=${sql.param(input.fingerprint, registrationFingerprint)} and ${registrationState}='registered' and ${column(mapping.registration.table, mapping.registration.subjectId)}=${sql.param(nativeSubjectId, column(mapping.registration.table, mapping.registration.subjectId))} and ${column(mapping.registration.table, mapping.registration.pendingReference)} is null and ${column(mapping.registration.table, mapping.registration.retentionUntil)}=${sql.param(retentionInstant, column(mapping.registration.table, mapping.registration.retentionUntil))}`,
|
|
1140
|
+
),
|
|
1141
|
+
)!;
|
|
1142
|
+
}
|
|
1143
|
+
let receipt: PreparedCommit<A> | undefined;
|
|
1144
|
+
|
|
1145
|
+
const compiled = yield* compileD1ProofCompletionPlan(
|
|
1146
|
+
proofMapping,
|
|
1147
|
+
input.completion,
|
|
1148
|
+
{ statements, appliedCondition: applied },
|
|
1149
|
+
(completion) => {
|
|
1150
|
+
receipt = prepare(completion === "completed" ? desired : { _tag: "Rejected" }, journal);
|
|
1151
|
+
|
|
1152
|
+
return completion;
|
|
1153
|
+
},
|
|
1154
|
+
);
|
|
1155
|
+
|
|
1156
|
+
const marker = `effect-auth-proof-guard:protected:${input.completion.input.continuationId}`;
|
|
1157
|
+
|
|
1158
|
+
return {
|
|
1159
|
+
receipt: receipt ?? prepare({ _tag: "Rejected" }, journal),
|
|
1160
|
+
statements: compiled.statements,
|
|
1161
|
+
retryable: (cause: unknown) =>
|
|
1162
|
+
guardFailure(cause, marker) ||
|
|
1163
|
+
isMappedConstraintConflict(mapping.isRequestConflict, cause) ||
|
|
1164
|
+
(mapping.mode === "atomic" &&
|
|
1165
|
+
(isMappedConstraintConflict(mapping.isIdentifierConflict, cause) ||
|
|
1166
|
+
isMappedConstraintConflict(mapping.isCredentialConflict, cause))),
|
|
1167
|
+
};
|
|
1168
|
+
});
|
|
1169
|
+
|
|
1170
|
+
const makeRegistrationPlans = <Registration>(
|
|
1171
|
+
mapping: RegistrationMapping<Registration> & { readonly d1: AddressMapping["d1"] },
|
|
1172
|
+
proofMapping: ProofMapping,
|
|
1173
|
+
) => ({
|
|
1174
|
+
inspect: (input: Parameters<EmailRegistrationAuthority<Registration>["inspect"]>[0]) =>
|
|
1175
|
+
mapping.inspect(input),
|
|
1176
|
+
registerWithProof: <A>(
|
|
1177
|
+
uncaptured: Parameters<EmailRegistrationAuthority<Registration>["registerWithProof"]>[0],
|
|
1178
|
+
prepare: PlanPrepare<EmailRegistrationAuthority<Registration>["registerWithProof"], A>,
|
|
1179
|
+
) =>
|
|
1180
|
+
Effect.gen(function* () {
|
|
1181
|
+
const registration = yield* mapping.snapshotRegistration(uncaptured.registration);
|
|
1182
|
+
const inspectionRegistration = yield* mapping.snapshotRegistration(uncaptured.registration);
|
|
1183
|
+
|
|
1184
|
+
const input = Object.freeze({
|
|
1185
|
+
...uncaptured,
|
|
1186
|
+
identifier: Object.freeze({ ...uncaptured.identifier }),
|
|
1187
|
+
registration,
|
|
1188
|
+
});
|
|
1189
|
+
|
|
1190
|
+
const inspected = yield* mapping.inspect({
|
|
1191
|
+
identifier: input.identifier,
|
|
1192
|
+
registration: inspectionRegistration,
|
|
1193
|
+
});
|
|
1194
|
+
|
|
1195
|
+
const atomic = mapping.mode === "atomic";
|
|
1196
|
+
|
|
1197
|
+
const credentialId = atomic
|
|
1198
|
+
? yield* allocate(mapping.allocateCredentialId, mapping.allocateCredentialIdSync)
|
|
1199
|
+
: undefined;
|
|
1200
|
+
|
|
1201
|
+
const securityRevision = atomic
|
|
1202
|
+
? yield* allocate(mapping.allocateRevision, mapping.allocateRevisionSync)
|
|
1203
|
+
: undefined;
|
|
1204
|
+
|
|
1205
|
+
const identifierRevision = atomic
|
|
1206
|
+
? yield* allocate(mapping.allocateRevision, mapping.allocateRevisionSync)
|
|
1207
|
+
: undefined;
|
|
1208
|
+
|
|
1209
|
+
const credentialRevision = atomic
|
|
1210
|
+
? yield* allocate(mapping.allocateRevision, mapping.allocateRevisionSync)
|
|
1211
|
+
: undefined;
|
|
1212
|
+
|
|
1213
|
+
const nativeSubjectId =
|
|
1214
|
+
atomic && mapping.provisioning.idMode !== "generated"
|
|
1215
|
+
? yield* allocate(
|
|
1216
|
+
mapping.provisioning.allocateSubjectId,
|
|
1217
|
+
mapping.provisioning.allocateSubjectIdSync,
|
|
1218
|
+
)
|
|
1219
|
+
: undefined;
|
|
1220
|
+
|
|
1221
|
+
const pendingReference =
|
|
1222
|
+
mapping.mode === "pending"
|
|
1223
|
+
? yield* allocate(mapping.allocatePendingReference, mapping.allocatePendingReferenceSync)
|
|
1224
|
+
: undefined;
|
|
1225
|
+
|
|
1226
|
+
return yield* registrationPlan(
|
|
1227
|
+
mapping,
|
|
1228
|
+
proofMapping,
|
|
1229
|
+
input,
|
|
1230
|
+
inspected,
|
|
1231
|
+
{
|
|
1232
|
+
...(credentialId === undefined ? {} : { credentialId }),
|
|
1233
|
+
...(securityRevision === undefined ? {} : { securityRevision }),
|
|
1234
|
+
...(identifierRevision === undefined ? {} : { identifierRevision }),
|
|
1235
|
+
...(credentialRevision === undefined ? {} : { credentialRevision }),
|
|
1236
|
+
...(nativeSubjectId === undefined ? {} : { nativeSubjectId }),
|
|
1237
|
+
...(pendingReference === undefined ? {} : { pendingReference }),
|
|
1238
|
+
},
|
|
1239
|
+
prepare,
|
|
1240
|
+
);
|
|
1241
|
+
}),
|
|
1242
|
+
});
|
|
1243
|
+
|
|
1244
|
+
export const makeD1EmailSignInServices = <
|
|
1245
|
+
S extends AnySQLiteTable,
|
|
1246
|
+
I extends AnySQLiteTable,
|
|
1247
|
+
C extends AnySQLiteTable,
|
|
1248
|
+
NativeId,
|
|
1249
|
+
>(
|
|
1250
|
+
database: Database,
|
|
1251
|
+
mapping: EmailSignInMapping<S, I, C, NativeId>,
|
|
1252
|
+
) =>
|
|
1253
|
+
Effect.succeed({
|
|
1254
|
+
emailSignInTargets: EmailSignInTargets.of({
|
|
1255
|
+
lookup: (input) => {
|
|
1256
|
+
if (!validEmailSignInConstraints(mapping as any)) return Effect.fail(unavailable());
|
|
1257
|
+
|
|
1258
|
+
return emailLookupRows(mapping as any, input.moduleId, input.identifier).pipe(
|
|
1259
|
+
Effect.flatMap((rows) => {
|
|
1260
|
+
const row = rows[0];
|
|
1261
|
+
|
|
1262
|
+
if (row === undefined) return Effect.succeed(Option.none());
|
|
1263
|
+
|
|
1264
|
+
return decodeEmailSnapshot(mapping as any, input.moduleId, input.identifier, row).pipe(
|
|
1265
|
+
Effect.map((snapshot) =>
|
|
1266
|
+
snapshot === undefined ? Option.none() : Option.some(snapshot),
|
|
1267
|
+
),
|
|
1268
|
+
);
|
|
1269
|
+
}),
|
|
1270
|
+
Effect.provideService(CurrentD1PlanningDatabase, database),
|
|
1271
|
+
translateFailure,
|
|
1272
|
+
);
|
|
1273
|
+
},
|
|
1274
|
+
}),
|
|
1275
|
+
});
|
|
1276
|
+
|
|
1277
|
+
export const makeD1EmailAddressServices = <
|
|
1278
|
+
S extends AnySQLiteTable,
|
|
1279
|
+
I extends AnySQLiteTable,
|
|
1280
|
+
C extends AnySQLiteTable,
|
|
1281
|
+
AC extends AnySQLiteTable,
|
|
1282
|
+
M extends AnySQLiteTable,
|
|
1283
|
+
NativeId,
|
|
1284
|
+
PRq extends AnySQLiteTable,
|
|
1285
|
+
PS extends AnySQLiteTable,
|
|
1286
|
+
PG extends AnySQLiteTable,
|
|
1287
|
+
PCn extends AnySQLiteTable,
|
|
1288
|
+
PRs extends AnySQLiteTable,
|
|
1289
|
+
PAev extends AnySQLiteTable,
|
|
1290
|
+
PF extends AnySQLiteTable,
|
|
1291
|
+
PC extends AnySQLiteTable,
|
|
1292
|
+
PSub extends AnySQLiteTable,
|
|
1293
|
+
PI extends AnySQLiteTable,
|
|
1294
|
+
PCr extends AnySQLiteTable,
|
|
1295
|
+
PNativeId,
|
|
1296
|
+
>(
|
|
1297
|
+
database: Database,
|
|
1298
|
+
mapping: D1EmailAddressMapping<S, I, C, AC, M, NativeId>,
|
|
1299
|
+
proofMapping: D1ProofPersistenceMapping<
|
|
1300
|
+
PRq,
|
|
1301
|
+
PS,
|
|
1302
|
+
PG,
|
|
1303
|
+
PCn,
|
|
1304
|
+
PRs,
|
|
1305
|
+
PAev,
|
|
1306
|
+
PF,
|
|
1307
|
+
PC,
|
|
1308
|
+
PSub,
|
|
1309
|
+
PI,
|
|
1310
|
+
PCr,
|
|
1311
|
+
PNativeId
|
|
1312
|
+
>,
|
|
1313
|
+
) =>
|
|
1314
|
+
Effect.gen(function* () {
|
|
1315
|
+
const hooks = yield* LifecycleHooks;
|
|
1316
|
+
|
|
1317
|
+
const plans = makeAddressPlans(
|
|
1318
|
+
mapping as unknown as AddressMapping,
|
|
1319
|
+
proofMapping as unknown as ProofMapping,
|
|
1320
|
+
);
|
|
1321
|
+
|
|
1322
|
+
const run = <Out, Err, Env>(plan: Effect.Effect<Planned<Out>, Err, Env>) =>
|
|
1323
|
+
Effect.gen(function* () {
|
|
1324
|
+
if (yield* hasCommitScope) return yield* unavailable();
|
|
1325
|
+
|
|
1326
|
+
return yield* executeStandalone(plan, 2);
|
|
1327
|
+
}).pipe(
|
|
1328
|
+
Effect.provideService(CurrentD1PlanningDatabase, database),
|
|
1329
|
+
Effect.provideService(CurrentEmailSql, database as unknown as EmailSqlDatabase),
|
|
1330
|
+
Effect.provideService(LifecycleHooks, hooks),
|
|
1331
|
+
);
|
|
1332
|
+
|
|
1333
|
+
const service: EmailAddressPersistence["Service"] = {
|
|
1334
|
+
target: (input) =>
|
|
1335
|
+
plans
|
|
1336
|
+
.target(input)
|
|
1337
|
+
.pipe(
|
|
1338
|
+
Effect.provideService(CurrentD1PlanningDatabase, database),
|
|
1339
|
+
Effect.provideService(CurrentEmailSql, database as unknown as EmailSqlDatabase),
|
|
1340
|
+
Effect.provideService(LifecycleHooks, hooks),
|
|
1341
|
+
translateFailure,
|
|
1342
|
+
),
|
|
1343
|
+
checkCompletion: (input) =>
|
|
1344
|
+
plans
|
|
1345
|
+
.checkCompletion(input)
|
|
1346
|
+
.pipe(
|
|
1347
|
+
Effect.provideService(CurrentD1PlanningDatabase, database),
|
|
1348
|
+
Effect.provideService(CurrentEmailSql, database as unknown as EmailSqlDatabase),
|
|
1349
|
+
Effect.provideService(LifecycleHooks, hooks),
|
|
1350
|
+
translateFailure,
|
|
1351
|
+
),
|
|
1352
|
+
verifyWithProof: (input, prepare) =>
|
|
1353
|
+
run(plans.verifyWithProof(input, prepare)).pipe(translateFailure),
|
|
1354
|
+
changeWithProof: (input, prepare) =>
|
|
1355
|
+
run(plans.changeWithProof(input, prepare)).pipe(translateFailure),
|
|
1356
|
+
cleanup: (input, prepare) => run(plans.cleanup(input, prepare)).pipe(translateFailure),
|
|
1357
|
+
};
|
|
1358
|
+
|
|
1359
|
+
return { emailAddressPersistence: service };
|
|
1360
|
+
});
|
|
1361
|
+
|
|
1362
|
+
export const makeD1EmailRegistrationServices = <
|
|
1363
|
+
Registration,
|
|
1364
|
+
S extends AnySQLiteTable,
|
|
1365
|
+
I extends AnySQLiteTable,
|
|
1366
|
+
C extends AnySQLiteTable,
|
|
1367
|
+
AC extends AnySQLiteTable,
|
|
1368
|
+
Rq extends AnySQLiteTable,
|
|
1369
|
+
NativeId,
|
|
1370
|
+
PRq extends AnySQLiteTable,
|
|
1371
|
+
PS extends AnySQLiteTable,
|
|
1372
|
+
PG extends AnySQLiteTable,
|
|
1373
|
+
PCn extends AnySQLiteTable,
|
|
1374
|
+
PRs extends AnySQLiteTable,
|
|
1375
|
+
PAev extends AnySQLiteTable,
|
|
1376
|
+
PF extends AnySQLiteTable,
|
|
1377
|
+
PC extends AnySQLiteTable,
|
|
1378
|
+
PSub extends AnySQLiteTable,
|
|
1379
|
+
PI extends AnySQLiteTable,
|
|
1380
|
+
PCr extends AnySQLiteTable,
|
|
1381
|
+
PNativeId,
|
|
1382
|
+
>(
|
|
1383
|
+
database: Database,
|
|
1384
|
+
mapping: D1EmailRegistrationMapping<Registration, S, I, C, AC, Rq, NativeId>,
|
|
1385
|
+
proofMapping: D1ProofPersistenceMapping<
|
|
1386
|
+
PRq,
|
|
1387
|
+
PS,
|
|
1388
|
+
PG,
|
|
1389
|
+
PCn,
|
|
1390
|
+
PRs,
|
|
1391
|
+
PAev,
|
|
1392
|
+
PF,
|
|
1393
|
+
PC,
|
|
1394
|
+
PSub,
|
|
1395
|
+
PI,
|
|
1396
|
+
PCr,
|
|
1397
|
+
PNativeId
|
|
1398
|
+
>,
|
|
1399
|
+
) =>
|
|
1400
|
+
Effect.gen(function* () {
|
|
1401
|
+
const hooks = yield* LifecycleHooks;
|
|
1402
|
+
|
|
1403
|
+
const plans = makeRegistrationPlans(
|
|
1404
|
+
mapping as unknown as RegistrationMapping<Registration> & {
|
|
1405
|
+
readonly d1: AddressMapping["d1"];
|
|
1406
|
+
},
|
|
1407
|
+
proofMapping as unknown as ProofMapping,
|
|
1408
|
+
);
|
|
1409
|
+
|
|
1410
|
+
const run = <Out, Err, Env>(plan: Effect.Effect<Planned<Out>, Err, Env>) =>
|
|
1411
|
+
Effect.gen(function* () {
|
|
1412
|
+
if (yield* hasCommitScope) return yield* unavailable();
|
|
1413
|
+
|
|
1414
|
+
return yield* executeStandalone(plan, 2);
|
|
1415
|
+
}).pipe(
|
|
1416
|
+
Effect.provideService(CurrentD1PlanningDatabase, database),
|
|
1417
|
+
Effect.provideService(CurrentEmailSql, database as unknown as EmailSqlDatabase),
|
|
1418
|
+
Effect.provideService(LifecycleHooks, hooks),
|
|
1419
|
+
);
|
|
1420
|
+
|
|
1421
|
+
const service: EmailRegistrationAuthority<Registration> = {
|
|
1422
|
+
inspect: (input) =>
|
|
1423
|
+
plans
|
|
1424
|
+
.inspect(input)
|
|
1425
|
+
.pipe(
|
|
1426
|
+
Effect.provideService(CurrentD1PlanningDatabase, database),
|
|
1427
|
+
Effect.provideService(CurrentEmailSql, database as unknown as EmailSqlDatabase),
|
|
1428
|
+
Effect.provideService(LifecycleHooks, hooks),
|
|
1429
|
+
translateFailure,
|
|
1430
|
+
),
|
|
1431
|
+
registerWithProof: (input, prepare) =>
|
|
1432
|
+
run(plans.registerWithProof(input, prepare)).pipe(translateFailure),
|
|
1433
|
+
};
|
|
1434
|
+
|
|
1435
|
+
return { registrationAuthority: service };
|
|
1436
|
+
});
|
|
1437
|
+
|
|
1438
|
+
type CoordinatorError<E> = E | EmailUnavailable | HookConfigurationError;
|
|
1439
|
+
|
|
1440
|
+
export function coordinateD1EmailAddress<
|
|
1441
|
+
S extends AnySQLiteTable,
|
|
1442
|
+
I extends AnySQLiteTable,
|
|
1443
|
+
C extends AnySQLiteTable,
|
|
1444
|
+
AC extends AnySQLiteTable,
|
|
1445
|
+
M extends AnySQLiteTable,
|
|
1446
|
+
NativeId,
|
|
1447
|
+
PRq extends AnySQLiteTable,
|
|
1448
|
+
PS extends AnySQLiteTable,
|
|
1449
|
+
PG extends AnySQLiteTable,
|
|
1450
|
+
PCn extends AnySQLiteTable,
|
|
1451
|
+
PRs extends AnySQLiteTable,
|
|
1452
|
+
PAev extends AnySQLiteTable,
|
|
1453
|
+
PF extends AnySQLiteTable,
|
|
1454
|
+
PC extends AnySQLiteTable,
|
|
1455
|
+
PSub extends AnySQLiteTable,
|
|
1456
|
+
PI extends AnySQLiteTable,
|
|
1457
|
+
PCr extends AnySQLiteTable,
|
|
1458
|
+
PNativeId,
|
|
1459
|
+
A,
|
|
1460
|
+
E,
|
|
1461
|
+
R,
|
|
1462
|
+
DatabaseError,
|
|
1463
|
+
DatabaseRequirements,
|
|
1464
|
+
>(
|
|
1465
|
+
acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,
|
|
1466
|
+
options: {
|
|
1467
|
+
readonly mapping: D1EmailAddressMapping<S, I, C, AC, M, NativeId>;
|
|
1468
|
+
readonly proofMapping: D1ProofPersistenceMapping<
|
|
1469
|
+
PRq,
|
|
1470
|
+
PS,
|
|
1471
|
+
PG,
|
|
1472
|
+
PCn,
|
|
1473
|
+
PRs,
|
|
1474
|
+
PAev,
|
|
1475
|
+
PF,
|
|
1476
|
+
PC,
|
|
1477
|
+
PSub,
|
|
1478
|
+
PI,
|
|
1479
|
+
PCr,
|
|
1480
|
+
PNativeId
|
|
1481
|
+
>;
|
|
1482
|
+
},
|
|
1483
|
+
body: Effect.Effect<A, E, R>,
|
|
1484
|
+
): Effect.Effect<
|
|
1485
|
+
A,
|
|
1486
|
+
CoordinatorError<E> | DatabaseError,
|
|
1487
|
+
Exclude<R, EmailAddressPersistence | D1BatchStatements> | LifecycleHooks | DatabaseRequirements
|
|
1488
|
+
> {
|
|
1489
|
+
return Effect.flatMap(acquire, (database) =>
|
|
1490
|
+
Effect.gen(function* () {
|
|
1491
|
+
const hooks = yield* LifecycleHooks;
|
|
1492
|
+
|
|
1493
|
+
if (yield* hasCommitScope) return yield* unavailable();
|
|
1494
|
+
|
|
1495
|
+
const result = yield* coordinateCommit(
|
|
1496
|
+
() =>
|
|
1497
|
+
Effect.gen(function* () {
|
|
1498
|
+
const statements: Statement<any>[] = [];
|
|
1499
|
+
let mutation: Planned<any> | undefined;
|
|
1500
|
+
|
|
1501
|
+
const nativeCollector = D1BatchStatements.of({
|
|
1502
|
+
append: (statement) => Effect.sync(() => statements.push(statement)),
|
|
1503
|
+
});
|
|
1504
|
+
|
|
1505
|
+
const owner = yield* makeD1Owner(unavailable()).pipe(
|
|
1506
|
+
Effect.provideService(D1BatchStatements, nativeCollector),
|
|
1507
|
+
);
|
|
1508
|
+
|
|
1509
|
+
const plans = makeAddressPlans(
|
|
1510
|
+
options.mapping as unknown as AddressMapping,
|
|
1511
|
+
options.proofMapping as unknown as ProofMapping,
|
|
1512
|
+
);
|
|
1513
|
+
|
|
1514
|
+
const run = <Out, Err, Env>(plan: Effect.Effect<Planned<Out>, Err, Env>) =>
|
|
1515
|
+
coordinateCommit(
|
|
1516
|
+
() =>
|
|
1517
|
+
Effect.gen(function* () {
|
|
1518
|
+
const journal = yield* CurrentCommitJournal;
|
|
1519
|
+
const planned = yield* plan;
|
|
1520
|
+
|
|
1521
|
+
yield* owner.check;
|
|
1522
|
+
if (mutation !== undefined) return yield* unavailable();
|
|
1523
|
+
const guarded = { ...planned, journalGuard: journal.prepare(undefined) };
|
|
1524
|
+
|
|
1525
|
+
mutation = guarded;
|
|
1526
|
+
statements.push(...guarded.statements);
|
|
1527
|
+
|
|
1528
|
+
return guarded.receipt;
|
|
1529
|
+
}),
|
|
1530
|
+
{ mode: "batch" },
|
|
1531
|
+
).pipe(
|
|
1532
|
+
Effect.map((result) => result.value),
|
|
1533
|
+
Effect.provideService(CurrentD1PlanningDatabase, database),
|
|
1534
|
+
Effect.provideService(CurrentEmailSql, database as unknown as EmailSqlDatabase),
|
|
1535
|
+
Effect.provideService(LifecycleHooks, hooks),
|
|
1536
|
+
);
|
|
1537
|
+
|
|
1538
|
+
const service: EmailAddressPersistence["Service"] = {
|
|
1539
|
+
target: (input) =>
|
|
1540
|
+
owner.run(
|
|
1541
|
+
plans
|
|
1542
|
+
.target(input)
|
|
1543
|
+
.pipe(
|
|
1544
|
+
Effect.provideService(CurrentD1PlanningDatabase, database),
|
|
1545
|
+
Effect.provideService(
|
|
1546
|
+
CurrentEmailSql,
|
|
1547
|
+
database as unknown as EmailSqlDatabase,
|
|
1548
|
+
),
|
|
1549
|
+
Effect.provideService(LifecycleHooks, hooks),
|
|
1550
|
+
translateFailure,
|
|
1551
|
+
),
|
|
1552
|
+
),
|
|
1553
|
+
checkCompletion: (input) =>
|
|
1554
|
+
owner.run(
|
|
1555
|
+
plans
|
|
1556
|
+
.checkCompletion(input)
|
|
1557
|
+
.pipe(
|
|
1558
|
+
Effect.provideService(CurrentD1PlanningDatabase, database),
|
|
1559
|
+
Effect.provideService(
|
|
1560
|
+
CurrentEmailSql,
|
|
1561
|
+
database as unknown as EmailSqlDatabase,
|
|
1562
|
+
),
|
|
1563
|
+
Effect.provideService(LifecycleHooks, hooks),
|
|
1564
|
+
translateFailure,
|
|
1565
|
+
),
|
|
1566
|
+
),
|
|
1567
|
+
verifyWithProof: (input, prepare) =>
|
|
1568
|
+
owner.run(run(plans.verifyWithProof(input, prepare)).pipe(translateFailure)),
|
|
1569
|
+
changeWithProof: (input, prepare) =>
|
|
1570
|
+
owner.run(run(plans.changeWithProof(input, prepare)).pipe(translateFailure)),
|
|
1571
|
+
cleanup: (input, prepare) =>
|
|
1572
|
+
owner.run(run(plans.cleanup(input, prepare)).pipe(translateFailure)),
|
|
1573
|
+
};
|
|
1574
|
+
|
|
1575
|
+
const provided = Context.make(EmailAddressPersistence, service).pipe(
|
|
1576
|
+
Context.add(D1BatchStatements, owner.collector),
|
|
1577
|
+
);
|
|
1578
|
+
|
|
1579
|
+
const value = yield* owner.close(Effect.provideContext(body, provided));
|
|
1580
|
+
|
|
1581
|
+
if (mutation?.journalGuard !== undefined) {
|
|
1582
|
+
const status = yield* Effect.result(mutation.journalGuard.read);
|
|
1583
|
+
|
|
1584
|
+
if (status._tag === "Success" || status.failure._tag !== "CommitPending")
|
|
1585
|
+
return yield* unavailable();
|
|
1586
|
+
}
|
|
1587
|
+
yield* database.$client.batch(statements).pipe(
|
|
1588
|
+
Effect.catchCause((cause) =>
|
|
1589
|
+
Effect.failCause(
|
|
1590
|
+
Cause.map(cause, (error) =>
|
|
1591
|
+
everyFailureMatches(cause, mutation?.retryable) ? unavailable() : error,
|
|
1592
|
+
),
|
|
1593
|
+
),
|
|
1594
|
+
),
|
|
1595
|
+
translateFailure,
|
|
1596
|
+
);
|
|
1597
|
+
|
|
1598
|
+
return value;
|
|
1599
|
+
}),
|
|
1600
|
+
{ mode: "batch" },
|
|
1601
|
+
).pipe(Effect.provideService(LifecycleHooks, hooks));
|
|
1602
|
+
|
|
1603
|
+
return result.value;
|
|
1604
|
+
}),
|
|
1605
|
+
);
|
|
1606
|
+
}
|
|
1607
|
+
|
|
1608
|
+
export function coordinateD1EmailRegistration<
|
|
1609
|
+
TargetId,
|
|
1610
|
+
Registration,
|
|
1611
|
+
S extends AnySQLiteTable,
|
|
1612
|
+
I extends AnySQLiteTable,
|
|
1613
|
+
C extends AnySQLiteTable,
|
|
1614
|
+
AC extends AnySQLiteTable,
|
|
1615
|
+
Rq extends AnySQLiteTable,
|
|
1616
|
+
NativeId,
|
|
1617
|
+
PRq extends AnySQLiteTable,
|
|
1618
|
+
PS extends AnySQLiteTable,
|
|
1619
|
+
PG extends AnySQLiteTable,
|
|
1620
|
+
PCn extends AnySQLiteTable,
|
|
1621
|
+
PRs extends AnySQLiteTable,
|
|
1622
|
+
PAev extends AnySQLiteTable,
|
|
1623
|
+
PF extends AnySQLiteTable,
|
|
1624
|
+
PC extends AnySQLiteTable,
|
|
1625
|
+
PSub extends AnySQLiteTable,
|
|
1626
|
+
PI extends AnySQLiteTable,
|
|
1627
|
+
PCr extends AnySQLiteTable,
|
|
1628
|
+
PNativeId,
|
|
1629
|
+
A,
|
|
1630
|
+
E,
|
|
1631
|
+
R,
|
|
1632
|
+
DatabaseError,
|
|
1633
|
+
DatabaseRequirements,
|
|
1634
|
+
>(
|
|
1635
|
+
acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,
|
|
1636
|
+
options: {
|
|
1637
|
+
readonly mapping: D1EmailRegistrationMapping<NoInfer<Registration>, S, I, C, AC, Rq, NativeId>;
|
|
1638
|
+
readonly proofMapping: D1ProofPersistenceMapping<
|
|
1639
|
+
PRq,
|
|
1640
|
+
PS,
|
|
1641
|
+
PG,
|
|
1642
|
+
PCn,
|
|
1643
|
+
PRs,
|
|
1644
|
+
PAev,
|
|
1645
|
+
PF,
|
|
1646
|
+
PC,
|
|
1647
|
+
PSub,
|
|
1648
|
+
PI,
|
|
1649
|
+
PCr,
|
|
1650
|
+
PNativeId
|
|
1651
|
+
>;
|
|
1652
|
+
readonly target: SuppliedService<TargetId, EmailRegistrationAuthority<Registration>>;
|
|
1653
|
+
},
|
|
1654
|
+
body: Effect.Effect<A, E, R>,
|
|
1655
|
+
): Effect.Effect<
|
|
1656
|
+
A,
|
|
1657
|
+
CoordinatorError<E> | DatabaseError,
|
|
1658
|
+
Exclude<R, TargetId | D1BatchStatements> | LifecycleHooks | DatabaseRequirements
|
|
1659
|
+
> {
|
|
1660
|
+
return Effect.flatMap(acquire, (database) =>
|
|
1661
|
+
Effect.gen(function* () {
|
|
1662
|
+
const hooks = yield* LifecycleHooks;
|
|
1663
|
+
|
|
1664
|
+
if (yield* hasCommitScope) return yield* unavailable();
|
|
1665
|
+
|
|
1666
|
+
const result = yield* coordinateCommit(
|
|
1667
|
+
() =>
|
|
1668
|
+
Effect.gen(function* () {
|
|
1669
|
+
const statements: Statement<any>[] = [];
|
|
1670
|
+
let mutation: Planned<any> | undefined;
|
|
1671
|
+
|
|
1672
|
+
const nativeCollector = D1BatchStatements.of({
|
|
1673
|
+
append: (statement) => Effect.sync(() => statements.push(statement)),
|
|
1674
|
+
});
|
|
1675
|
+
|
|
1676
|
+
const owner = yield* makeD1Owner(unavailable()).pipe(
|
|
1677
|
+
Effect.provideService(D1BatchStatements, nativeCollector),
|
|
1678
|
+
);
|
|
1679
|
+
|
|
1680
|
+
const plans = makeRegistrationPlans(
|
|
1681
|
+
options.mapping as unknown as RegistrationMapping<Registration> & {
|
|
1682
|
+
readonly d1: AddressMapping["d1"];
|
|
1683
|
+
},
|
|
1684
|
+
options.proofMapping as unknown as ProofMapping,
|
|
1685
|
+
);
|
|
1686
|
+
|
|
1687
|
+
const run = <Out, Err, Env>(plan: Effect.Effect<Planned<Out>, Err, Env>) =>
|
|
1688
|
+
coordinateCommit(
|
|
1689
|
+
() =>
|
|
1690
|
+
Effect.gen(function* () {
|
|
1691
|
+
const journal = yield* CurrentCommitJournal;
|
|
1692
|
+
const planned = yield* plan;
|
|
1693
|
+
|
|
1694
|
+
yield* owner.check;
|
|
1695
|
+
if (mutation !== undefined) return yield* unavailable();
|
|
1696
|
+
const guarded = { ...planned, journalGuard: journal.prepare(undefined) };
|
|
1697
|
+
|
|
1698
|
+
mutation = guarded;
|
|
1699
|
+
statements.push(...guarded.statements);
|
|
1700
|
+
|
|
1701
|
+
return guarded.receipt;
|
|
1702
|
+
}),
|
|
1703
|
+
{ mode: "batch" },
|
|
1704
|
+
).pipe(
|
|
1705
|
+
Effect.map((result) => result.value),
|
|
1706
|
+
Effect.provideService(CurrentD1PlanningDatabase, database),
|
|
1707
|
+
Effect.provideService(CurrentEmailSql, database as unknown as EmailSqlDatabase),
|
|
1708
|
+
Effect.provideService(LifecycleHooks, hooks),
|
|
1709
|
+
);
|
|
1710
|
+
|
|
1711
|
+
const service: EmailRegistrationAuthority<Registration> = {
|
|
1712
|
+
inspect: (input) =>
|
|
1713
|
+
owner.run(
|
|
1714
|
+
plans
|
|
1715
|
+
.inspect(input)
|
|
1716
|
+
.pipe(
|
|
1717
|
+
Effect.provideService(CurrentD1PlanningDatabase, database),
|
|
1718
|
+
Effect.provideService(
|
|
1719
|
+
CurrentEmailSql,
|
|
1720
|
+
database as unknown as EmailSqlDatabase,
|
|
1721
|
+
),
|
|
1722
|
+
Effect.provideService(LifecycleHooks, hooks),
|
|
1723
|
+
translateFailure,
|
|
1724
|
+
),
|
|
1725
|
+
),
|
|
1726
|
+
registerWithProof: (input, prepare) =>
|
|
1727
|
+
owner.run(run(plans.registerWithProof(input, prepare)).pipe(translateFailure)),
|
|
1728
|
+
};
|
|
1729
|
+
|
|
1730
|
+
const provided = Context.make(options.target, service).pipe(
|
|
1731
|
+
Context.add(D1BatchStatements, owner.collector),
|
|
1732
|
+
);
|
|
1733
|
+
|
|
1734
|
+
const value = yield* owner.close(Effect.provideContext(body, provided));
|
|
1735
|
+
|
|
1736
|
+
if (mutation?.journalGuard !== undefined) {
|
|
1737
|
+
const status = yield* Effect.result(mutation.journalGuard.read);
|
|
1738
|
+
|
|
1739
|
+
if (status._tag === "Success" || status.failure._tag !== "CommitPending")
|
|
1740
|
+
return yield* unavailable();
|
|
1741
|
+
}
|
|
1742
|
+
yield* database.$client.batch(statements).pipe(
|
|
1743
|
+
Effect.catchCause((cause) =>
|
|
1744
|
+
Effect.failCause(
|
|
1745
|
+
Cause.map(cause, (error) =>
|
|
1746
|
+
everyFailureMatches(cause, mutation?.retryable) ? unavailable() : error,
|
|
1747
|
+
),
|
|
1748
|
+
),
|
|
1749
|
+
),
|
|
1750
|
+
translateFailure,
|
|
1751
|
+
);
|
|
1752
|
+
|
|
1753
|
+
return value;
|
|
1754
|
+
}),
|
|
1755
|
+
{ mode: "batch" },
|
|
1756
|
+
).pipe(Effect.provideService(LifecycleHooks, hooks));
|
|
1757
|
+
|
|
1758
|
+
return result.value;
|
|
1759
|
+
}),
|
|
1760
|
+
);
|
|
1761
|
+
}
|
|
1762
|
+
|
|
1763
|
+
const translateFailure = <A, E, R>(
|
|
1764
|
+
effect: Effect.Effect<A, E, R>,
|
|
1765
|
+
): Effect.Effect<A, EmailUnavailable, R> =>
|
|
1766
|
+
reportPersistenceFailure(
|
|
1767
|
+
effect,
|
|
1768
|
+
(error) =>
|
|
1769
|
+
Schema.is(EmailUnavailable)(error) ||
|
|
1770
|
+
Schema.is(ProofUnavailable)(error) ||
|
|
1771
|
+
Schema.is(HookConfigurationError)(error),
|
|
1772
|
+
).pipe(Effect.catchCause((cause) => Effect.failCause(Cause.map(cause, () => unavailable()))));
|
|
1773
|
+
|
|
1774
|
+
const executeStandalone = <A, E, R>(
|
|
1775
|
+
plan: Effect.Effect<Planned<A>, E, R>,
|
|
1776
|
+
retries = 2,
|
|
1777
|
+
): Effect.Effect<
|
|
1778
|
+
A,
|
|
1779
|
+
| E
|
|
1780
|
+
| import("../hooks/models").HookConfigurationError
|
|
1781
|
+
| import("effect/unstable/sql/SqlError").SqlError,
|
|
1782
|
+
Exclude<R, CurrentCommitJournal> | CurrentD1PlanningDatabase | LifecycleHooks
|
|
1783
|
+
> =>
|
|
1784
|
+
Effect.suspend(() => {
|
|
1785
|
+
let retryable: ((cause: unknown) => boolean) | undefined;
|
|
1786
|
+
|
|
1787
|
+
const once = coordinateCommit(
|
|
1788
|
+
() =>
|
|
1789
|
+
Effect.gen(function* () {
|
|
1790
|
+
const database = yield* CurrentD1PlanningDatabase;
|
|
1791
|
+
const planned = yield* plan;
|
|
1792
|
+
|
|
1793
|
+
retryable = planned.retryable;
|
|
1794
|
+
yield* database.$client.batch(planned.statements);
|
|
1795
|
+
|
|
1796
|
+
return planned.receipt;
|
|
1797
|
+
}),
|
|
1798
|
+
{ mode: "batch" },
|
|
1799
|
+
).pipe(Effect.map((result) => result.value));
|
|
1800
|
+
|
|
1801
|
+
return once.pipe(
|
|
1802
|
+
Effect.catchCause((cause) =>
|
|
1803
|
+
retries > 0 && everyFailureMatches(cause, retryable)
|
|
1804
|
+
? executeStandalone(plan, retries - 1)
|
|
1805
|
+
: Effect.failCause(cause),
|
|
1806
|
+
),
|
|
1807
|
+
);
|
|
1808
|
+
});
|