@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,1912 @@
|
|
|
1
|
+
/* oxlint-disable no-explicit-any -- Drizzle erases consumer table types inside the shared dialect kernel. */
|
|
2
|
+
import { and, eq, gte, inArray, isNull, lte, notExists, sql, type Table } from "drizzle-orm";
|
|
3
|
+
import type { EffectDrizzleQueryError } from "drizzle-orm/effect-core";
|
|
4
|
+
import { Cause, Context, DateTime, Effect, Option, Schema } from "effect";
|
|
5
|
+
import type * as SqlError from "effect/unstable/sql/SqlError";
|
|
6
|
+
|
|
7
|
+
import { coordinateCommit, CurrentCommitJournal, hasCommitScope } from "../hooks/commit";
|
|
8
|
+
import { LifecycleHooks } from "../hooks/LifecycleHooks";
|
|
9
|
+
import { HookConfigurationError } from "../hooks/models";
|
|
10
|
+
import { reportPersistenceFailure } from "../internal/diagnostics";
|
|
11
|
+
import type { ProofCompletionPlan } from "../proofs/completion";
|
|
12
|
+
import { ProofRequestConflict, ProofUnavailable } from "../proofs/errors";
|
|
13
|
+
import {
|
|
14
|
+
ProofBinding,
|
|
15
|
+
type ProofAttemptDecision,
|
|
16
|
+
type ProofCleanupResult,
|
|
17
|
+
type ProofCompletionDecision,
|
|
18
|
+
type ProofDeliveryOutcome,
|
|
19
|
+
type ProofVersion,
|
|
20
|
+
} from "../proofs/models";
|
|
21
|
+
import type { ProofBudget, ProofPolicy } from "../proofs/policy";
|
|
22
|
+
import { ProofPersistence, type ProofDeliveryClaim } from "../proofs/ProofPersistence";
|
|
23
|
+
import { column, DrizzleMappingError, updateValues } from "./model";
|
|
24
|
+
import {
|
|
25
|
+
CurrentPasswordPreparedTransaction,
|
|
26
|
+
PasswordPreparedPostconditions,
|
|
27
|
+
} from "./PasswordPreparedPostconditions";
|
|
28
|
+
import {
|
|
29
|
+
type AnyProofPersistenceMapping,
|
|
30
|
+
requiredProofConstraints,
|
|
31
|
+
type ProofPersistenceMapping,
|
|
32
|
+
type ProofAction,
|
|
33
|
+
type ProofCommandDecision,
|
|
34
|
+
type ProofContinuationRecord,
|
|
35
|
+
type ProofScopeKeys,
|
|
36
|
+
type ProofScopeKind,
|
|
37
|
+
} from "./proof-model";
|
|
38
|
+
|
|
39
|
+
type AdapterFailure = EffectDrizzleQueryError | DrizzleMappingError | SqlError.SqlError;
|
|
40
|
+
|
|
41
|
+
export interface ProofSqlQuery<A = ReadonlyArray<any>> extends Effect.Effect<A, AdapterFailure> {
|
|
42
|
+
readonly getSQL: () => ReturnType<typeof sql>;
|
|
43
|
+
readonly from: (...args: ReadonlyArray<any>) => ProofSqlQuery<A>;
|
|
44
|
+
readonly where: (...args: ReadonlyArray<any>) => ProofSqlQuery<A>;
|
|
45
|
+
readonly limit: (...args: ReadonlyArray<any>) => ProofSqlQuery<A>;
|
|
46
|
+
readonly orderBy: (...args: ReadonlyArray<any>) => ProofSqlQuery<A>;
|
|
47
|
+
readonly for: (...args: ReadonlyArray<any>) => ProofSqlQuery<A>;
|
|
48
|
+
readonly set: (...args: ReadonlyArray<any>) => ProofSqlQuery<A>;
|
|
49
|
+
readonly values: (...args: ReadonlyArray<any>) => ProofSqlQuery<A>;
|
|
50
|
+
readonly onConflictDoNothing: (...args: ReadonlyArray<any>) => ProofSqlQuery<A>;
|
|
51
|
+
readonly onDuplicateKeyUpdate: (...args: ReadonlyArray<any>) => ProofSqlQuery<A>;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface ProofSqlDatabase {
|
|
55
|
+
readonly select: (...args: ReadonlyArray<any>) => ProofSqlQuery;
|
|
56
|
+
readonly insert: (...args: ReadonlyArray<any>) => ProofSqlQuery;
|
|
57
|
+
readonly update: (...args: ReadonlyArray<any>) => ProofSqlQuery;
|
|
58
|
+
readonly delete: (...args: ReadonlyArray<any>) => ProofSqlQuery;
|
|
59
|
+
readonly transaction: <A, E, R>(
|
|
60
|
+
body: (transaction: ProofSqlDatabase) => Effect.Effect<A, E, R>,
|
|
61
|
+
) => Effect.Effect<A, E | SqlError.SqlError, R>;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export class CurrentProofSql extends Context.Service<CurrentProofSql, ProofSqlDatabase>()(
|
|
65
|
+
"effect-auth/CurrentProofSql",
|
|
66
|
+
) {}
|
|
67
|
+
|
|
68
|
+
export interface ProofSqlConfiguration {
|
|
69
|
+
readonly mode: "interactive" | "synchronous";
|
|
70
|
+
readonly locking: boolean;
|
|
71
|
+
readonly standaloneGuard: Effect.Effect<void, ProofUnavailable>;
|
|
72
|
+
readonly coordinated?: boolean;
|
|
73
|
+
/** Dialect-native insert-if-absent used to create serialization anchors. */
|
|
74
|
+
readonly insertIfAbsent: (
|
|
75
|
+
query: ProofSqlQuery,
|
|
76
|
+
selfKey: string,
|
|
77
|
+
selfValue: unknown,
|
|
78
|
+
) => ProofSqlQuery;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
type Database = ProofSqlDatabase;
|
|
82
|
+
type Mapping = AnyProofPersistenceMapping;
|
|
83
|
+
const unavailable = () => ProofUnavailable.make({});
|
|
84
|
+
|
|
85
|
+
const translateFailure = <A, E, R>(
|
|
86
|
+
effect: Effect.Effect<A, E, R>,
|
|
87
|
+
): Effect.Effect<A, ProofUnavailable, R> =>
|
|
88
|
+
reportPersistenceFailure(
|
|
89
|
+
effect,
|
|
90
|
+
(error) => Schema.is(ProofUnavailable)(error) || Schema.is(HookConfigurationError)(error),
|
|
91
|
+
).pipe(Effect.catchCause((cause) => Effect.failCause(Cause.map(cause, () => unavailable()))));
|
|
92
|
+
|
|
93
|
+
const translateIssueFailure = <A, E, R>(
|
|
94
|
+
effect: Effect.Effect<A, E, R>,
|
|
95
|
+
): Effect.Effect<A, ProofUnavailable | ProofRequestConflict, R> =>
|
|
96
|
+
reportPersistenceFailure(
|
|
97
|
+
effect,
|
|
98
|
+
(error) =>
|
|
99
|
+
Schema.is(ProofUnavailable)(error) ||
|
|
100
|
+
Schema.is(ProofRequestConflict)(error) ||
|
|
101
|
+
Schema.is(HookConfigurationError)(error),
|
|
102
|
+
).pipe(
|
|
103
|
+
Effect.catchCause((cause) =>
|
|
104
|
+
Effect.failCause(
|
|
105
|
+
Cause.map(cause, (error) =>
|
|
106
|
+
Schema.is(ProofRequestConflict)(error) ? error : unavailable(),
|
|
107
|
+
),
|
|
108
|
+
),
|
|
109
|
+
),
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
const conflict = () => ProofRequestConflict.make({});
|
|
113
|
+
|
|
114
|
+
const validConstraints = (mapping: Mapping) =>
|
|
115
|
+
Object.entries(requiredProofConstraints).every(
|
|
116
|
+
([key, value]) => mapping.constraints[key as keyof typeof requiredProofConstraints] === value,
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
const selectRows = (query: ProofSqlQuery, locking: boolean) =>
|
|
120
|
+
locking && typeof query.for === "function" ? query.for("update") : query;
|
|
121
|
+
|
|
122
|
+
const allocateVersion = (
|
|
123
|
+
mapping: Mapping,
|
|
124
|
+
mode: ProofSqlConfiguration["mode"],
|
|
125
|
+
): Effect.Effect<ProofVersion, ProofUnavailable | DrizzleMappingError> => {
|
|
126
|
+
if (mode === "synchronous")
|
|
127
|
+
return mapping.allocateVersionSync === undefined
|
|
128
|
+
? Effect.fail(unavailable())
|
|
129
|
+
: Effect.try({
|
|
130
|
+
try: mapping.allocateVersionSync,
|
|
131
|
+
catch: (cause) => new DrizzleMappingError({ operation: "mapping", cause }),
|
|
132
|
+
});
|
|
133
|
+
if (mapping.allocateVersion !== undefined) return mapping.allocateVersion;
|
|
134
|
+
|
|
135
|
+
return mapping.allocateVersionSync === undefined
|
|
136
|
+
? Effect.fail(unavailable())
|
|
137
|
+
: Effect.try({
|
|
138
|
+
try: mapping.allocateVersionSync,
|
|
139
|
+
catch: (cause) => new DrizzleMappingError({ operation: "mapping", cause }),
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
const canonicalBinding = Schema.encodeSync(Schema.fromJsonString(ProofBinding));
|
|
144
|
+
|
|
145
|
+
const sameBinding = (left: ProofBinding, right: ProofBinding): boolean =>
|
|
146
|
+
canonicalBinding(left) === canonicalBinding(right);
|
|
147
|
+
|
|
148
|
+
const requestColumns = (mapping: Mapping) => ({
|
|
149
|
+
moduleId: column(mapping.request.table, mapping.request.moduleId),
|
|
150
|
+
requestId: column(mapping.request.table, mapping.request.requestId),
|
|
151
|
+
fingerprint: column(mapping.request.table, mapping.request.fingerprint),
|
|
152
|
+
proofId: column(mapping.request.table, mapping.request.proofId),
|
|
153
|
+
retentionUntil: column(mapping.request.table, mapping.request.retentionUntil),
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
const seriesColumns = (mapping: Mapping) => ({
|
|
157
|
+
moduleId: column(mapping.series.table, mapping.series.moduleId),
|
|
158
|
+
purpose: column(mapping.series.table, mapping.series.purpose),
|
|
159
|
+
scopeKey: column(mapping.series.table, mapping.series.scopeKey),
|
|
160
|
+
activeProofId: column(mapping.series.table, mapping.series.activeProofId),
|
|
161
|
+
lastIssueAt: column(mapping.series.table, mapping.series.lastIssueAt),
|
|
162
|
+
version: column(mapping.series.table, mapping.series.version),
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
const generationColumns = (mapping: Mapping) => ({
|
|
166
|
+
moduleId: column(mapping.generation.table, mapping.generation.moduleId),
|
|
167
|
+
purpose: column(mapping.generation.table, mapping.generation.purpose),
|
|
168
|
+
proofId: column(mapping.generation.table, mapping.generation.proofId),
|
|
169
|
+
requestId: column(mapping.generation.table, mapping.generation.requestId),
|
|
170
|
+
seriesKey: column(mapping.generation.table, mapping.generation.seriesKey),
|
|
171
|
+
deliveryId: column(mapping.generation.table, mapping.generation.deliveryId),
|
|
172
|
+
verifierKeyId: column(mapping.generation.table, mapping.generation.verifierKeyId),
|
|
173
|
+
verifierDigest: column(mapping.generation.table, mapping.generation.verifierDigest),
|
|
174
|
+
issuedAt: column(mapping.generation.table, mapping.generation.issuedAt),
|
|
175
|
+
expiresAt: column(mapping.generation.table, mapping.generation.expiresAt),
|
|
176
|
+
version: column(mapping.generation.table, mapping.generation.version),
|
|
177
|
+
state: column(mapping.generation.table, mapping.generation.state),
|
|
178
|
+
sendCount: column(mapping.generation.table, mapping.generation.sendCount),
|
|
179
|
+
deliveryState: column(mapping.generation.table, mapping.generation.deliveryState),
|
|
180
|
+
claimVersion: column(mapping.generation.table, mapping.generation.claimVersion),
|
|
181
|
+
claimDeadline: column(mapping.generation.table, mapping.generation.claimDeadline),
|
|
182
|
+
retryAt: column(mapping.generation.table, mapping.generation.retryAt),
|
|
183
|
+
deliveryRetryMillis: column(mapping.generation.table, mapping.generation.deliveryRetryMillis),
|
|
184
|
+
retentionUntil: column(mapping.generation.table, mapping.generation.retentionUntil),
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
const continuationColumns = (mapping: Mapping) => ({
|
|
188
|
+
moduleId: column(mapping.continuation.table, mapping.continuation.moduleId),
|
|
189
|
+
purpose: column(mapping.continuation.table, mapping.continuation.purpose),
|
|
190
|
+
continuationId: column(mapping.continuation.table, mapping.continuation.continuationId),
|
|
191
|
+
digest: column(mapping.continuation.table, mapping.continuation.digest),
|
|
192
|
+
proofId: column(mapping.continuation.table, mapping.continuation.proofId),
|
|
193
|
+
seriesKey: column(mapping.continuation.table, mapping.continuation.seriesKey),
|
|
194
|
+
expiresAt: column(mapping.continuation.table, mapping.continuation.expiresAt),
|
|
195
|
+
consumed: column(mapping.continuation.table, mapping.continuation.consumed),
|
|
196
|
+
version: column(mapping.continuation.table, mapping.continuation.version),
|
|
197
|
+
retentionUntil: column(mapping.continuation.table, mapping.continuation.retentionUntil),
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
const scopeColumns = (mapping: Mapping) => ({
|
|
201
|
+
moduleId: column(mapping.rateScope.table, mapping.rateScope.moduleId),
|
|
202
|
+
purpose: column(mapping.rateScope.table, mapping.rateScope.purpose),
|
|
203
|
+
action: column(mapping.rateScope.table, mapping.rateScope.action),
|
|
204
|
+
scopeKind: column(mapping.rateScope.table, mapping.rateScope.scopeKind),
|
|
205
|
+
scopeKey: column(mapping.rateScope.table, mapping.rateScope.scopeKey),
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
const abuseColumns = (mapping: Mapping) => ({
|
|
209
|
+
moduleId: column(mapping.abuseEvent.table, mapping.abuseEvent.moduleId),
|
|
210
|
+
purpose: column(mapping.abuseEvent.table, mapping.abuseEvent.purpose),
|
|
211
|
+
action: column(mapping.abuseEvent.table, mapping.abuseEvent.action),
|
|
212
|
+
scopeKind: column(mapping.abuseEvent.table, mapping.abuseEvent.scopeKind),
|
|
213
|
+
scopeKey: column(mapping.abuseEvent.table, mapping.abuseEvent.scopeKey),
|
|
214
|
+
commandId: column(mapping.abuseEvent.table, mapping.abuseEvent.commandId),
|
|
215
|
+
occurredAt: column(mapping.abuseEvent.table, mapping.abuseEvent.occurredAt),
|
|
216
|
+
retentionUntil: column(mapping.abuseEvent.table, mapping.abuseEvent.retentionUntil),
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
const failureColumns = (mapping: Mapping) => ({
|
|
220
|
+
moduleId: column(mapping.failureEvent.table, mapping.failureEvent.moduleId),
|
|
221
|
+
purpose: column(mapping.failureEvent.table, mapping.failureEvent.purpose),
|
|
222
|
+
seriesKey: column(mapping.failureEvent.table, mapping.failureEvent.seriesKey),
|
|
223
|
+
commandId: column(mapping.failureEvent.table, mapping.failureEvent.commandId),
|
|
224
|
+
occurredAt: column(mapping.failureEvent.table, mapping.failureEvent.occurredAt),
|
|
225
|
+
retentionUntil: column(mapping.failureEvent.table, mapping.failureEvent.retentionUntil),
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
const commandColumns = (mapping: Mapping) => ({
|
|
229
|
+
moduleId: column(mapping.command.table, mapping.command.moduleId),
|
|
230
|
+
commandId: column(mapping.command.table, mapping.command.commandId),
|
|
231
|
+
kind: column(mapping.command.table, mapping.command.kind),
|
|
232
|
+
decision: column(mapping.command.table, mapping.command.decision),
|
|
233
|
+
retentionUntil: column(mapping.command.table, mapping.command.retentionUntil),
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
const nowMillis = DateTime.now.pipe(Effect.map(DateTime.toEpochMillis));
|
|
237
|
+
|
|
238
|
+
const lockAuthority = Effect.fn("DrizzleProof.lockAuthority")(function* (
|
|
239
|
+
mapping: Mapping,
|
|
240
|
+
moduleId: string,
|
|
241
|
+
purpose: any,
|
|
242
|
+
binding: ProofBinding,
|
|
243
|
+
locking: boolean,
|
|
244
|
+
) {
|
|
245
|
+
const database = yield* CurrentProofSql;
|
|
246
|
+
|
|
247
|
+
const authority = mapping.authority;
|
|
248
|
+
let nativeSubjectId: unknown | undefined;
|
|
249
|
+
|
|
250
|
+
// Canonical order: subject, identifier rows, credentials sorted by ID.
|
|
251
|
+
if (binding._tag !== "Identifier") {
|
|
252
|
+
if (
|
|
253
|
+
authority.subject === undefined ||
|
|
254
|
+
authority.credential === undefined ||
|
|
255
|
+
authority.subjectId === undefined
|
|
256
|
+
)
|
|
257
|
+
return yield* unavailable();
|
|
258
|
+
nativeSubjectId = yield* authority.subjectId.toNative(binding.revision.subjectId);
|
|
259
|
+
const subject = authority.subject;
|
|
260
|
+
|
|
261
|
+
const rows = yield* selectRows(
|
|
262
|
+
database
|
|
263
|
+
.select()
|
|
264
|
+
.from(subject.table)
|
|
265
|
+
.where(eq(column(subject.table, subject.id), nativeSubjectId))
|
|
266
|
+
.limit(1),
|
|
267
|
+
locking,
|
|
268
|
+
);
|
|
269
|
+
|
|
270
|
+
const row = rows[0];
|
|
271
|
+
|
|
272
|
+
if (
|
|
273
|
+
row === undefined ||
|
|
274
|
+
!subject.isActiveStatus(row[subject.status]) ||
|
|
275
|
+
row[subject.securityRevision] !== binding.revision.securityRevision
|
|
276
|
+
)
|
|
277
|
+
return false;
|
|
278
|
+
}
|
|
279
|
+
const identifier = authority.identifier;
|
|
280
|
+
|
|
281
|
+
const identifierRows = yield* selectRows(
|
|
282
|
+
database
|
|
283
|
+
.select()
|
|
284
|
+
.from(identifier.table)
|
|
285
|
+
.where(
|
|
286
|
+
and(
|
|
287
|
+
eq(column(identifier.table, identifier.namespace), binding.identifier.namespace),
|
|
288
|
+
eq(column(identifier.table, identifier.value), binding.identifier.value),
|
|
289
|
+
),
|
|
290
|
+
),
|
|
291
|
+
locking,
|
|
292
|
+
);
|
|
293
|
+
|
|
294
|
+
if (
|
|
295
|
+
!identifier.isCurrent(
|
|
296
|
+
{ moduleId, purpose, binding, ...(nativeSubjectId === undefined ? {} : { nativeSubjectId }) },
|
|
297
|
+
identifierRows,
|
|
298
|
+
)
|
|
299
|
+
)
|
|
300
|
+
return false;
|
|
301
|
+
if (binding._tag === "Identifier") return true;
|
|
302
|
+
const credential = authority.credential!;
|
|
303
|
+
|
|
304
|
+
const expected = [...binding.revision.credentials].sort((a, b) =>
|
|
305
|
+
a.credentialId.localeCompare(b.credentialId),
|
|
306
|
+
);
|
|
307
|
+
|
|
308
|
+
const rows =
|
|
309
|
+
expected.length === 0
|
|
310
|
+
? []
|
|
311
|
+
: yield* selectRows(
|
|
312
|
+
database
|
|
313
|
+
.select()
|
|
314
|
+
.from(credential.table)
|
|
315
|
+
.where(
|
|
316
|
+
and(
|
|
317
|
+
eq(column(credential.table, credential.subjectId), nativeSubjectId),
|
|
318
|
+
inArray(
|
|
319
|
+
column(credential.table, credential.credentialId),
|
|
320
|
+
expected.map((item) => item.credentialId),
|
|
321
|
+
),
|
|
322
|
+
),
|
|
323
|
+
),
|
|
324
|
+
locking,
|
|
325
|
+
);
|
|
326
|
+
|
|
327
|
+
if (rows.length !== expected.length) return false;
|
|
328
|
+
|
|
329
|
+
const actual = rows
|
|
330
|
+
.map((row: any) => ({
|
|
331
|
+
credentialId: row[credential.credentialId] as string,
|
|
332
|
+
revision: row[credential.revision],
|
|
333
|
+
active:
|
|
334
|
+
credential.status === undefined ||
|
|
335
|
+
credential.isActiveStatus?.(row[credential.status]) === true,
|
|
336
|
+
}))
|
|
337
|
+
.sort((a: any, b: any) => a.credentialId.localeCompare(b.credentialId));
|
|
338
|
+
|
|
339
|
+
return actual.every(
|
|
340
|
+
(item: any, index: number) =>
|
|
341
|
+
item.active &&
|
|
342
|
+
item.credentialId === expected[index]?.credentialId &&
|
|
343
|
+
item.revision === expected[index]?.revision,
|
|
344
|
+
);
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
interface ScopeEntry {
|
|
348
|
+
readonly kind: ProofScopeKind;
|
|
349
|
+
readonly key: string;
|
|
350
|
+
readonly budget: ProofBudget;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
const scopeEntries = (
|
|
354
|
+
keys: ProofScopeKeys,
|
|
355
|
+
binding: ProofBinding,
|
|
356
|
+
action: ProofAction,
|
|
357
|
+
policy: ProofPolicy,
|
|
358
|
+
): ReadonlyArray<ScopeEntry> => {
|
|
359
|
+
const suffix = action === "issue" ? "Issues" : "Attempts";
|
|
360
|
+
const simple = action === "issue" ? "issues" : "attempts";
|
|
361
|
+
|
|
362
|
+
const entries: ScopeEntry[] = [
|
|
363
|
+
{ kind: "action", key: "*", budget: policy.abuse[`action${suffix}`] },
|
|
364
|
+
{ kind: "identifier", key: keys.identifier, budget: policy.abuse[simple] },
|
|
365
|
+
];
|
|
366
|
+
|
|
367
|
+
if (binding._tag !== "Identifier")
|
|
368
|
+
entries.push({
|
|
369
|
+
kind: "subject",
|
|
370
|
+
key: keys.subject,
|
|
371
|
+
budget: policy.abuse[`subject${suffix}`],
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
return entries;
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
const lockScopes = Effect.fn("DrizzleProof.lockScopes")(function* (
|
|
378
|
+
mapping: Mapping,
|
|
379
|
+
configuration: ProofSqlConfiguration,
|
|
380
|
+
moduleId: string,
|
|
381
|
+
purpose: any,
|
|
382
|
+
action: ProofAction,
|
|
383
|
+
entries: ReadonlyArray<ScopeEntry>,
|
|
384
|
+
) {
|
|
385
|
+
const database = yield* CurrentProofSql;
|
|
386
|
+
|
|
387
|
+
const c = scopeColumns(mapping);
|
|
388
|
+
|
|
389
|
+
for (const entry of entries) {
|
|
390
|
+
const values = mapping.rateScope.encodeInsert({
|
|
391
|
+
moduleId,
|
|
392
|
+
purpose,
|
|
393
|
+
action,
|
|
394
|
+
scopeKind: entry.kind,
|
|
395
|
+
scopeKey: entry.key,
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
const query = database.insert(mapping.rateScope.table).values(values);
|
|
399
|
+
|
|
400
|
+
yield* configuration.insertIfAbsent(query, mapping.rateScope.scopeKey, entry.key);
|
|
401
|
+
yield* selectRows(
|
|
402
|
+
database
|
|
403
|
+
.select()
|
|
404
|
+
.from(mapping.rateScope.table)
|
|
405
|
+
.where(
|
|
406
|
+
and(
|
|
407
|
+
eq(c.moduleId, moduleId),
|
|
408
|
+
eq(c.purpose, purpose),
|
|
409
|
+
eq(c.action, action),
|
|
410
|
+
eq(c.scopeKind, entry.kind),
|
|
411
|
+
eq(c.scopeKey, entry.key),
|
|
412
|
+
),
|
|
413
|
+
)
|
|
414
|
+
.limit(1),
|
|
415
|
+
configuration.locking,
|
|
416
|
+
);
|
|
417
|
+
}
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
const admittedScopes = Effect.fn("DrizzleProof.admittedScopes")(function* (
|
|
421
|
+
mapping: Mapping,
|
|
422
|
+
moduleId: string,
|
|
423
|
+
purpose: any,
|
|
424
|
+
action: ProofAction,
|
|
425
|
+
entries: ReadonlyArray<ScopeEntry>,
|
|
426
|
+
now: number,
|
|
427
|
+
) {
|
|
428
|
+
const database = yield* CurrentProofSql;
|
|
429
|
+
|
|
430
|
+
const c = abuseColumns(mapping);
|
|
431
|
+
const admitted: ScopeEntry[] = [];
|
|
432
|
+
|
|
433
|
+
for (const entry of entries) {
|
|
434
|
+
const rows = yield* selectRows(
|
|
435
|
+
database
|
|
436
|
+
.select({ commandId: c.commandId })
|
|
437
|
+
.from(mapping.abuseEvent.table)
|
|
438
|
+
.where(
|
|
439
|
+
and(
|
|
440
|
+
eq(c.moduleId, moduleId),
|
|
441
|
+
eq(c.purpose, purpose),
|
|
442
|
+
eq(c.action, action),
|
|
443
|
+
eq(c.scopeKind, entry.kind),
|
|
444
|
+
eq(c.scopeKey, entry.key),
|
|
445
|
+
gte(c.occurredAt, mapping.encodeInstant(now - entry.budget.windowMillis)),
|
|
446
|
+
),
|
|
447
|
+
)
|
|
448
|
+
.limit(entry.budget.limit),
|
|
449
|
+
true,
|
|
450
|
+
);
|
|
451
|
+
|
|
452
|
+
if (rows.length < entry.budget.limit) admitted.push(entry);
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
return admitted;
|
|
456
|
+
});
|
|
457
|
+
|
|
458
|
+
const insertScopeEvents = Effect.fn("Drizzle.insertScopeEvents")(function* (
|
|
459
|
+
mapping: Mapping,
|
|
460
|
+
moduleId: string,
|
|
461
|
+
purpose: any,
|
|
462
|
+
action: ProofAction,
|
|
463
|
+
commandId: string,
|
|
464
|
+
entries: ReadonlyArray<ScopeEntry>,
|
|
465
|
+
now: number,
|
|
466
|
+
retentionUntil: number,
|
|
467
|
+
) {
|
|
468
|
+
const database = yield* CurrentProofSql;
|
|
469
|
+
|
|
470
|
+
return yield* Effect.forEach(
|
|
471
|
+
entries,
|
|
472
|
+
(entry) =>
|
|
473
|
+
database.insert(mapping.abuseEvent.table).values(
|
|
474
|
+
mapping.abuseEvent.encodeInsert({
|
|
475
|
+
moduleId,
|
|
476
|
+
purpose,
|
|
477
|
+
action,
|
|
478
|
+
scopeKind: entry.kind,
|
|
479
|
+
scopeKey: entry.key,
|
|
480
|
+
commandId,
|
|
481
|
+
occurredAtMillis: now,
|
|
482
|
+
retentionUntilMillis: retentionUntil,
|
|
483
|
+
}),
|
|
484
|
+
),
|
|
485
|
+
{ discard: true },
|
|
486
|
+
);
|
|
487
|
+
});
|
|
488
|
+
|
|
489
|
+
const ensureSeries = Effect.fn("DrizzleProof.ensureSeries")(function* (
|
|
490
|
+
mapping: Mapping,
|
|
491
|
+
configuration: ProofSqlConfiguration,
|
|
492
|
+
moduleId: string,
|
|
493
|
+
purpose: any,
|
|
494
|
+
scopeKey: string,
|
|
495
|
+
) {
|
|
496
|
+
const database = yield* CurrentProofSql;
|
|
497
|
+
|
|
498
|
+
const c = seriesColumns(mapping);
|
|
499
|
+
const initialVersion = yield* allocateVersion(mapping, configuration.mode);
|
|
500
|
+
|
|
501
|
+
const query = database
|
|
502
|
+
.insert(mapping.series.table)
|
|
503
|
+
.values(mapping.series.encodeInsert({ moduleId, purpose, scopeKey, version: initialVersion }));
|
|
504
|
+
|
|
505
|
+
yield* configuration.insertIfAbsent(query, mapping.series.scopeKey, scopeKey);
|
|
506
|
+
|
|
507
|
+
const rows = yield* selectRows(
|
|
508
|
+
database
|
|
509
|
+
.select()
|
|
510
|
+
.from(mapping.series.table)
|
|
511
|
+
.where(and(eq(c.moduleId, moduleId), eq(c.purpose, purpose), eq(c.scopeKey, scopeKey)))
|
|
512
|
+
.limit(1),
|
|
513
|
+
configuration.locking,
|
|
514
|
+
);
|
|
515
|
+
|
|
516
|
+
return rows[0] ?? (yield* unavailable());
|
|
517
|
+
});
|
|
518
|
+
|
|
519
|
+
const readGeneration = Effect.fn("Drizzle.readGeneration")(function* (
|
|
520
|
+
mapping: Mapping,
|
|
521
|
+
moduleId: string,
|
|
522
|
+
proofId: string,
|
|
523
|
+
locking: boolean,
|
|
524
|
+
) {
|
|
525
|
+
const database = yield* CurrentProofSql;
|
|
526
|
+
|
|
527
|
+
const c = generationColumns(mapping);
|
|
528
|
+
|
|
529
|
+
return yield* selectRows(
|
|
530
|
+
database
|
|
531
|
+
.select()
|
|
532
|
+
.from(mapping.generation.table)
|
|
533
|
+
.where(and(eq(c.moduleId, moduleId), eq(c.proofId, proofId)))
|
|
534
|
+
.limit(1),
|
|
535
|
+
locking,
|
|
536
|
+
);
|
|
537
|
+
});
|
|
538
|
+
|
|
539
|
+
const failureCount = Effect.fn("DrizzleProof.failureCount")(function* (
|
|
540
|
+
mapping: Mapping,
|
|
541
|
+
moduleId: string,
|
|
542
|
+
purpose: any,
|
|
543
|
+
seriesKey: string,
|
|
544
|
+
now: number,
|
|
545
|
+
policy: ProofPolicy,
|
|
546
|
+
) {
|
|
547
|
+
const database = yield* CurrentProofSql;
|
|
548
|
+
|
|
549
|
+
const c = failureColumns(mapping);
|
|
550
|
+
|
|
551
|
+
const rows = yield* selectRows(
|
|
552
|
+
database
|
|
553
|
+
.select({ commandId: c.commandId })
|
|
554
|
+
.from(mapping.failureEvent.table)
|
|
555
|
+
.where(
|
|
556
|
+
and(
|
|
557
|
+
eq(c.moduleId, moduleId),
|
|
558
|
+
eq(c.purpose, purpose),
|
|
559
|
+
eq(c.seriesKey, seriesKey),
|
|
560
|
+
gte(c.occurredAt, mapping.encodeInstant(now - policy.abuse.attempts.windowMillis)),
|
|
561
|
+
),
|
|
562
|
+
)
|
|
563
|
+
.limit(policy.maximumFailedAttempts),
|
|
564
|
+
true,
|
|
565
|
+
);
|
|
566
|
+
|
|
567
|
+
return rows.length;
|
|
568
|
+
});
|
|
569
|
+
|
|
570
|
+
const commandRow = Effect.fn("Drizzle.commandRow")(function* (
|
|
571
|
+
mapping: Mapping,
|
|
572
|
+
moduleId: string,
|
|
573
|
+
commandId: string,
|
|
574
|
+
locking: boolean,
|
|
575
|
+
) {
|
|
576
|
+
const database = yield* CurrentProofSql;
|
|
577
|
+
|
|
578
|
+
const c = commandColumns(mapping);
|
|
579
|
+
|
|
580
|
+
return yield* selectRows(
|
|
581
|
+
database
|
|
582
|
+
.select()
|
|
583
|
+
.from(mapping.command.table)
|
|
584
|
+
.where(and(eq(c.moduleId, moduleId), eq(c.commandId, commandId)))
|
|
585
|
+
.limit(1),
|
|
586
|
+
locking,
|
|
587
|
+
);
|
|
588
|
+
});
|
|
589
|
+
|
|
590
|
+
const insertCommand = Effect.fn("Drizzle.insertCommand")(function* (
|
|
591
|
+
mapping: Mapping,
|
|
592
|
+
moduleId: string,
|
|
593
|
+
commandId: string,
|
|
594
|
+
kind: "attempt" | "complete",
|
|
595
|
+
decision: ProofCommandDecision,
|
|
596
|
+
retentionUntil: number,
|
|
597
|
+
) {
|
|
598
|
+
const database = yield* CurrentProofSql;
|
|
599
|
+
|
|
600
|
+
return yield* database.insert(mapping.command.table).values(
|
|
601
|
+
mapping.command.encodeInsert({
|
|
602
|
+
moduleId,
|
|
603
|
+
commandId,
|
|
604
|
+
kind,
|
|
605
|
+
decision,
|
|
606
|
+
retentionUntilMillis: retentionUntil,
|
|
607
|
+
}),
|
|
608
|
+
);
|
|
609
|
+
});
|
|
610
|
+
|
|
611
|
+
const owned = <A, E, R>(
|
|
612
|
+
database: Database,
|
|
613
|
+
mapping: Mapping,
|
|
614
|
+
configuration: ProofSqlConfiguration,
|
|
615
|
+
body: Effect.Effect<A, E, R>,
|
|
616
|
+
) => {
|
|
617
|
+
if (!validConstraints(mapping)) return Effect.fail(unavailable());
|
|
618
|
+
|
|
619
|
+
const run = coordinateCommit(
|
|
620
|
+
() =>
|
|
621
|
+
database.transaction((transaction) =>
|
|
622
|
+
body.pipe(Effect.provideService(CurrentProofSql, transaction)),
|
|
623
|
+
),
|
|
624
|
+
{ mode: configuration.mode },
|
|
625
|
+
).pipe(Effect.map((result) => result.value));
|
|
626
|
+
|
|
627
|
+
return configuration.coordinated !== true
|
|
628
|
+
? Effect.gen(function* () {
|
|
629
|
+
if (yield* hasCommitScope) return yield* unavailable();
|
|
630
|
+
yield* configuration.standaloneGuard;
|
|
631
|
+
|
|
632
|
+
return yield* run;
|
|
633
|
+
})
|
|
634
|
+
: run;
|
|
635
|
+
};
|
|
636
|
+
|
|
637
|
+
export const makeSqlProofPersistence = Effect.fn("makeSqlProofPersistence")(function* (
|
|
638
|
+
database: Database,
|
|
639
|
+
mapping: Mapping,
|
|
640
|
+
configuration: ProofSqlConfiguration,
|
|
641
|
+
): Effect.fn.Return<ProofPersistence["Service"], never, LifecycleHooks> {
|
|
642
|
+
const hooks = yield* LifecycleHooks;
|
|
643
|
+
|
|
644
|
+
return ProofPersistence.of({
|
|
645
|
+
issue: (input, prepare) =>
|
|
646
|
+
owned(
|
|
647
|
+
database,
|
|
648
|
+
mapping,
|
|
649
|
+
configuration,
|
|
650
|
+
Effect.gen(function* () {
|
|
651
|
+
const transaction = yield* CurrentProofSql;
|
|
652
|
+
const journal = yield* CurrentCommitJournal;
|
|
653
|
+
|
|
654
|
+
const keys = mapping.scopeKeys({
|
|
655
|
+
moduleId: input.record.moduleId,
|
|
656
|
+
purpose: input.record.purpose,
|
|
657
|
+
binding: input.record.binding,
|
|
658
|
+
});
|
|
659
|
+
|
|
660
|
+
const authorityCurrent = yield* lockAuthority(
|
|
661
|
+
mapping,
|
|
662
|
+
input.record.moduleId,
|
|
663
|
+
input.record.purpose,
|
|
664
|
+
input.record.binding,
|
|
665
|
+
configuration.locking,
|
|
666
|
+
);
|
|
667
|
+
|
|
668
|
+
const scopes = scopeEntries(keys, input.record.binding, "issue", input.policy);
|
|
669
|
+
|
|
670
|
+
yield* lockScopes(
|
|
671
|
+
mapping,
|
|
672
|
+
configuration,
|
|
673
|
+
input.record.moduleId,
|
|
674
|
+
input.record.purpose,
|
|
675
|
+
"issue",
|
|
676
|
+
scopes.slice(0, 1),
|
|
677
|
+
);
|
|
678
|
+
const actionNow = yield* nowMillis;
|
|
679
|
+
|
|
680
|
+
const actionOpen =
|
|
681
|
+
(yield* admittedScopes(
|
|
682
|
+
mapping,
|
|
683
|
+
input.record.moduleId,
|
|
684
|
+
input.record.purpose,
|
|
685
|
+
"issue",
|
|
686
|
+
scopes.slice(0, 1),
|
|
687
|
+
actionNow,
|
|
688
|
+
)).length === 1;
|
|
689
|
+
|
|
690
|
+
if (actionOpen)
|
|
691
|
+
yield* lockScopes(
|
|
692
|
+
mapping,
|
|
693
|
+
configuration,
|
|
694
|
+
input.record.moduleId,
|
|
695
|
+
input.record.purpose,
|
|
696
|
+
"issue",
|
|
697
|
+
scopes.slice(1),
|
|
698
|
+
);
|
|
699
|
+
|
|
700
|
+
const series = actionOpen
|
|
701
|
+
? yield* ensureSeries(
|
|
702
|
+
mapping,
|
|
703
|
+
configuration,
|
|
704
|
+
input.record.moduleId,
|
|
705
|
+
input.record.purpose,
|
|
706
|
+
keys.series,
|
|
707
|
+
)
|
|
708
|
+
: undefined;
|
|
709
|
+
|
|
710
|
+
const now = yield* nowMillis;
|
|
711
|
+
const retentionUntil = now + input.policy.requestRetentionMillis;
|
|
712
|
+
const rc = requestColumns(mapping);
|
|
713
|
+
|
|
714
|
+
let requestRows = yield* selectRows(
|
|
715
|
+
transaction
|
|
716
|
+
.select()
|
|
717
|
+
.from(mapping.request.table)
|
|
718
|
+
.where(
|
|
719
|
+
and(
|
|
720
|
+
eq(rc.moduleId, input.record.moduleId),
|
|
721
|
+
eq(rc.requestId, input.record.requestId),
|
|
722
|
+
),
|
|
723
|
+
)
|
|
724
|
+
.limit(1),
|
|
725
|
+
configuration.locking,
|
|
726
|
+
);
|
|
727
|
+
|
|
728
|
+
let request = requestRows[0];
|
|
729
|
+
|
|
730
|
+
if (request !== undefined) {
|
|
731
|
+
const retainedUntil = yield* mapping.decodeInstant(
|
|
732
|
+
request[mapping.request.retentionUntil],
|
|
733
|
+
);
|
|
734
|
+
|
|
735
|
+
if (retainedUntil > now) {
|
|
736
|
+
if (request[mapping.request.fingerprint] !== input.record.fingerprint)
|
|
737
|
+
return yield* conflict();
|
|
738
|
+
const receipt = yield* mapping.request.decodeReceipt(request);
|
|
739
|
+
|
|
740
|
+
return prepare({ _tag: "Existing", receipt }, journal);
|
|
741
|
+
}
|
|
742
|
+
yield* transaction
|
|
743
|
+
.delete(mapping.request.table)
|
|
744
|
+
.where(
|
|
745
|
+
and(
|
|
746
|
+
eq(rc.moduleId, input.record.moduleId),
|
|
747
|
+
eq(rc.requestId, input.record.requestId),
|
|
748
|
+
lte(rc.retentionUntil, mapping.encodeInstant(now)),
|
|
749
|
+
),
|
|
750
|
+
);
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
const requestInsert = mapping.request.encodeInsert({
|
|
754
|
+
record: input.record,
|
|
755
|
+
createdAtMillis: now,
|
|
756
|
+
retentionUntilMillis: retentionUntil,
|
|
757
|
+
});
|
|
758
|
+
|
|
759
|
+
const requestQuery = transaction.insert(mapping.request.table).values(requestInsert);
|
|
760
|
+
|
|
761
|
+
yield* configuration.insertIfAbsent(
|
|
762
|
+
requestQuery,
|
|
763
|
+
mapping.request.requestId,
|
|
764
|
+
input.record.requestId,
|
|
765
|
+
);
|
|
766
|
+
requestRows = yield* selectRows(
|
|
767
|
+
transaction
|
|
768
|
+
.select()
|
|
769
|
+
.from(mapping.request.table)
|
|
770
|
+
.where(
|
|
771
|
+
and(
|
|
772
|
+
eq(rc.moduleId, input.record.moduleId),
|
|
773
|
+
eq(rc.requestId, input.record.requestId),
|
|
774
|
+
),
|
|
775
|
+
)
|
|
776
|
+
.limit(1),
|
|
777
|
+
configuration.locking,
|
|
778
|
+
);
|
|
779
|
+
request = requestRows[0];
|
|
780
|
+
|
|
781
|
+
if (request === undefined) return yield* unavailable();
|
|
782
|
+
if (request[mapping.request.fingerprint] !== input.record.fingerprint)
|
|
783
|
+
return yield* conflict();
|
|
784
|
+
if (request[mapping.request.proofId] !== input.record.proofId) {
|
|
785
|
+
const receipt = yield* mapping.request.decodeReceipt(request);
|
|
786
|
+
|
|
787
|
+
return prepare({ _tag: "Existing", receipt }, journal);
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
const admitted = actionOpen
|
|
791
|
+
? yield* admittedScopes(
|
|
792
|
+
mapping,
|
|
793
|
+
input.record.moduleId,
|
|
794
|
+
input.record.purpose,
|
|
795
|
+
"issue",
|
|
796
|
+
scopes,
|
|
797
|
+
now,
|
|
798
|
+
)
|
|
799
|
+
: [];
|
|
800
|
+
|
|
801
|
+
const sc = seriesColumns(mapping);
|
|
802
|
+
|
|
803
|
+
const lastIssueAt =
|
|
804
|
+
series?.[mapping.series.lastIssueAt] === null ||
|
|
805
|
+
series?.[mapping.series.lastIssueAt] === undefined
|
|
806
|
+
? undefined
|
|
807
|
+
: yield* mapping.decodeInstant(series[mapping.series.lastIssueAt]);
|
|
808
|
+
|
|
809
|
+
const activeProofId = series?.[mapping.series.activeProofId] as string | null | undefined;
|
|
810
|
+
|
|
811
|
+
const supersedesCurrent =
|
|
812
|
+
input.supersedes === undefined || input.supersedes === activeProofId;
|
|
813
|
+
|
|
814
|
+
const allowed =
|
|
815
|
+
authorityCurrent &&
|
|
816
|
+
input.eligible &&
|
|
817
|
+
admitted.length === scopes.length &&
|
|
818
|
+
input.record.issuedAtMillis <= now &&
|
|
819
|
+
input.record.expiresAtMillis > now &&
|
|
820
|
+
supersedesCurrent &&
|
|
821
|
+
(lastIssueAt === undefined ||
|
|
822
|
+
now - lastIssueAt >= input.policy.abuse.resendCooldownMillis);
|
|
823
|
+
|
|
824
|
+
const receipt = {
|
|
825
|
+
requestId: input.record.requestId,
|
|
826
|
+
reference: {
|
|
827
|
+
proofId: input.record.proofId,
|
|
828
|
+
purpose: input.record.purpose,
|
|
829
|
+
keyId: input.record.verifier.keyId,
|
|
830
|
+
},
|
|
831
|
+
};
|
|
832
|
+
|
|
833
|
+
const prepared = prepare(
|
|
834
|
+
allowed
|
|
835
|
+
? ({ _tag: "Issued", record: input.record } as const)
|
|
836
|
+
: ({ _tag: "Suppressed", receipt } as const),
|
|
837
|
+
journal,
|
|
838
|
+
);
|
|
839
|
+
|
|
840
|
+
if (admitted.length > 0)
|
|
841
|
+
yield* insertScopeEvents(
|
|
842
|
+
mapping,
|
|
843
|
+
input.record.moduleId,
|
|
844
|
+
input.record.purpose,
|
|
845
|
+
"issue",
|
|
846
|
+
input.record.requestId,
|
|
847
|
+
admitted,
|
|
848
|
+
now,
|
|
849
|
+
retentionUntil,
|
|
850
|
+
);
|
|
851
|
+
if (!allowed) return prepared;
|
|
852
|
+
if (activeProofId !== null && activeProofId !== undefined)
|
|
853
|
+
yield* transaction
|
|
854
|
+
.update(mapping.generation.table)
|
|
855
|
+
.set(updateValues<any>([[mapping.generation.state, "superseded"]]))
|
|
856
|
+
.where(
|
|
857
|
+
and(
|
|
858
|
+
eq(generationColumns(mapping).moduleId, input.record.moduleId),
|
|
859
|
+
eq(generationColumns(mapping).proofId, activeProofId),
|
|
860
|
+
eq(generationColumns(mapping).state, "active"),
|
|
861
|
+
),
|
|
862
|
+
);
|
|
863
|
+
yield* transaction.insert(mapping.generation.table).values(
|
|
864
|
+
mapping.generation.encodeInsert({
|
|
865
|
+
record: input.record,
|
|
866
|
+
seriesKey: keys.series,
|
|
867
|
+
retentionUntilMillis: retentionUntil,
|
|
868
|
+
state: "active",
|
|
869
|
+
deliveryState: "new",
|
|
870
|
+
policy: input.policy,
|
|
871
|
+
}),
|
|
872
|
+
);
|
|
873
|
+
const nextVersion = yield* allocateVersion(mapping, configuration.mode);
|
|
874
|
+
|
|
875
|
+
yield* transaction
|
|
876
|
+
.update(mapping.series.table)
|
|
877
|
+
.set(
|
|
878
|
+
updateValues<any>([
|
|
879
|
+
[mapping.series.activeProofId, input.record.proofId],
|
|
880
|
+
[mapping.series.lastIssueAt, mapping.encodeInstant(now)],
|
|
881
|
+
[mapping.series.version, nextVersion],
|
|
882
|
+
]),
|
|
883
|
+
)
|
|
884
|
+
.where(
|
|
885
|
+
and(
|
|
886
|
+
eq(sc.moduleId, input.record.moduleId),
|
|
887
|
+
eq(sc.purpose, input.record.purpose),
|
|
888
|
+
eq(sc.scopeKey, keys.series),
|
|
889
|
+
),
|
|
890
|
+
);
|
|
891
|
+
|
|
892
|
+
return prepared;
|
|
893
|
+
}),
|
|
894
|
+
).pipe(
|
|
895
|
+
Effect.provideService(CurrentProofSql, database),
|
|
896
|
+
Effect.provideService(LifecycleHooks, hooks),
|
|
897
|
+
translateIssueFailure,
|
|
898
|
+
),
|
|
899
|
+
attempt: (input, prepare) =>
|
|
900
|
+
owned(
|
|
901
|
+
database,
|
|
902
|
+
mapping,
|
|
903
|
+
configuration,
|
|
904
|
+
Effect.gen(function* () {
|
|
905
|
+
const transaction = yield* CurrentProofSql;
|
|
906
|
+
const journal = yield* CurrentCommitJournal;
|
|
907
|
+
|
|
908
|
+
const keys = mapping.scopeKeys({
|
|
909
|
+
moduleId: input.moduleId,
|
|
910
|
+
purpose: input.purpose,
|
|
911
|
+
binding: input.binding,
|
|
912
|
+
});
|
|
913
|
+
|
|
914
|
+
const authorityCurrent = yield* lockAuthority(
|
|
915
|
+
mapping,
|
|
916
|
+
input.moduleId,
|
|
917
|
+
input.purpose,
|
|
918
|
+
input.binding,
|
|
919
|
+
configuration.locking,
|
|
920
|
+
);
|
|
921
|
+
|
|
922
|
+
const scopes = scopeEntries(keys, input.binding, "attempt", input.policy);
|
|
923
|
+
|
|
924
|
+
yield* lockScopes(
|
|
925
|
+
mapping,
|
|
926
|
+
configuration,
|
|
927
|
+
input.moduleId,
|
|
928
|
+
input.purpose,
|
|
929
|
+
"attempt",
|
|
930
|
+
scopes.slice(0, 1),
|
|
931
|
+
);
|
|
932
|
+
const actionNow = yield* nowMillis;
|
|
933
|
+
|
|
934
|
+
const actionOpen =
|
|
935
|
+
(yield* admittedScopes(
|
|
936
|
+
mapping,
|
|
937
|
+
input.moduleId,
|
|
938
|
+
input.purpose,
|
|
939
|
+
"attempt",
|
|
940
|
+
scopes.slice(0, 1),
|
|
941
|
+
actionNow,
|
|
942
|
+
)).length === 1;
|
|
943
|
+
|
|
944
|
+
if (actionOpen)
|
|
945
|
+
yield* lockScopes(
|
|
946
|
+
mapping,
|
|
947
|
+
configuration,
|
|
948
|
+
input.moduleId,
|
|
949
|
+
input.purpose,
|
|
950
|
+
"attempt",
|
|
951
|
+
scopes.slice(1),
|
|
952
|
+
);
|
|
953
|
+
|
|
954
|
+
const series = actionOpen
|
|
955
|
+
? yield* ensureSeries(
|
|
956
|
+
mapping,
|
|
957
|
+
configuration,
|
|
958
|
+
input.moduleId,
|
|
959
|
+
input.purpose,
|
|
960
|
+
keys.series,
|
|
961
|
+
)
|
|
962
|
+
: undefined;
|
|
963
|
+
|
|
964
|
+
const generation = (yield* readGeneration(
|
|
965
|
+
mapping,
|
|
966
|
+
input.moduleId,
|
|
967
|
+
input.proofId,
|
|
968
|
+
configuration.locking,
|
|
969
|
+
))[0];
|
|
970
|
+
|
|
971
|
+
const existingCommand = (yield* commandRow(
|
|
972
|
+
mapping,
|
|
973
|
+
input.moduleId,
|
|
974
|
+
input.continuationId,
|
|
975
|
+
configuration.locking,
|
|
976
|
+
))[0];
|
|
977
|
+
|
|
978
|
+
if (existingCommand !== undefined) {
|
|
979
|
+
if (existingCommand[mapping.command.decision] === "rejected")
|
|
980
|
+
return prepare({ _tag: "Rejected" }, journal);
|
|
981
|
+
|
|
982
|
+
return yield* unavailable();
|
|
983
|
+
}
|
|
984
|
+
const now = yield* nowMillis;
|
|
985
|
+
|
|
986
|
+
const admitted = actionOpen
|
|
987
|
+
? yield* admittedScopes(mapping, input.moduleId, input.purpose, "attempt", scopes, now)
|
|
988
|
+
: [];
|
|
989
|
+
|
|
990
|
+
const failures = yield* failureCount(
|
|
991
|
+
mapping,
|
|
992
|
+
input.moduleId,
|
|
993
|
+
input.purpose,
|
|
994
|
+
keys.series,
|
|
995
|
+
now,
|
|
996
|
+
input.policy,
|
|
997
|
+
);
|
|
998
|
+
|
|
999
|
+
const gc = generationColumns(mapping);
|
|
1000
|
+
const activeProofId = series?.[mapping.series.activeProofId];
|
|
1001
|
+
|
|
1002
|
+
const storedBinding =
|
|
1003
|
+
generation === undefined
|
|
1004
|
+
? undefined
|
|
1005
|
+
: yield* mapping.generation.decodeBinding(generation);
|
|
1006
|
+
|
|
1007
|
+
const candidateMatches =
|
|
1008
|
+
generation !== undefined &&
|
|
1009
|
+
input.candidate !== undefined &&
|
|
1010
|
+
generation[mapping.generation.verifierKeyId] === input.candidate.keyId &&
|
|
1011
|
+
generation[mapping.generation.verifierDigest] === input.candidate.digest;
|
|
1012
|
+
|
|
1013
|
+
const currentGeneration =
|
|
1014
|
+
generation !== undefined &&
|
|
1015
|
+
generation[mapping.generation.purpose] === input.purpose &&
|
|
1016
|
+
generation[mapping.generation.state] === "active" &&
|
|
1017
|
+
activeProofId === input.proofId &&
|
|
1018
|
+
storedBinding !== undefined &&
|
|
1019
|
+
sameBinding(storedBinding, input.binding) &&
|
|
1020
|
+
Number(yield* mapping.decodeInstant(generation[mapping.generation.expiresAt])) > now;
|
|
1021
|
+
|
|
1022
|
+
const accepted =
|
|
1023
|
+
authorityCurrent &&
|
|
1024
|
+
currentGeneration &&
|
|
1025
|
+
candidateMatches &&
|
|
1026
|
+
admitted.length === scopes.length &&
|
|
1027
|
+
failures < input.policy.maximumFailedAttempts;
|
|
1028
|
+
|
|
1029
|
+
const retentionUntil = now + input.policy.requestRetentionMillis;
|
|
1030
|
+
|
|
1031
|
+
if (!accepted) {
|
|
1032
|
+
const prepared = prepare({ _tag: "Rejected" }, journal);
|
|
1033
|
+
|
|
1034
|
+
yield* insertCommand(
|
|
1035
|
+
mapping,
|
|
1036
|
+
input.moduleId,
|
|
1037
|
+
input.continuationId,
|
|
1038
|
+
"attempt",
|
|
1039
|
+
"rejected",
|
|
1040
|
+
retentionUntil,
|
|
1041
|
+
);
|
|
1042
|
+
yield* insertScopeEvents(
|
|
1043
|
+
mapping,
|
|
1044
|
+
input.moduleId,
|
|
1045
|
+
input.purpose,
|
|
1046
|
+
"attempt",
|
|
1047
|
+
input.continuationId,
|
|
1048
|
+
admitted,
|
|
1049
|
+
now,
|
|
1050
|
+
retentionUntil,
|
|
1051
|
+
);
|
|
1052
|
+
if (
|
|
1053
|
+
admitted.length === scopes.length &&
|
|
1054
|
+
currentGeneration &&
|
|
1055
|
+
!candidateMatches &&
|
|
1056
|
+
failures < input.policy.maximumFailedAttempts
|
|
1057
|
+
)
|
|
1058
|
+
yield* transaction.insert(mapping.failureEvent.table).values(
|
|
1059
|
+
mapping.failureEvent.encodeInsert({
|
|
1060
|
+
moduleId: input.moduleId,
|
|
1061
|
+
purpose: input.purpose,
|
|
1062
|
+
seriesKey: keys.series,
|
|
1063
|
+
commandId: input.continuationId,
|
|
1064
|
+
occurredAtMillis: now,
|
|
1065
|
+
retentionUntilMillis: retentionUntil,
|
|
1066
|
+
}),
|
|
1067
|
+
);
|
|
1068
|
+
|
|
1069
|
+
return prepared;
|
|
1070
|
+
}
|
|
1071
|
+
const version = yield* allocateVersion(mapping, configuration.mode);
|
|
1072
|
+
|
|
1073
|
+
const expiresAt = Math.min(
|
|
1074
|
+
Number(yield* mapping.decodeInstant(generation![mapping.generation.expiresAt])),
|
|
1075
|
+
now + input.policy.continuationLifetimeMillis,
|
|
1076
|
+
);
|
|
1077
|
+
|
|
1078
|
+
const continuation: ProofContinuationRecord = {
|
|
1079
|
+
moduleId: input.moduleId,
|
|
1080
|
+
purpose: input.purpose,
|
|
1081
|
+
continuationId: input.continuationId,
|
|
1082
|
+
digest: input.continuationDigest,
|
|
1083
|
+
proofId: input.proofId,
|
|
1084
|
+
seriesKey: keys.series,
|
|
1085
|
+
binding: input.binding,
|
|
1086
|
+
expiresAtMillis: expiresAt,
|
|
1087
|
+
version,
|
|
1088
|
+
};
|
|
1089
|
+
|
|
1090
|
+
const decision: ProofAttemptDecision = {
|
|
1091
|
+
_tag: "Accepted",
|
|
1092
|
+
continuation: {
|
|
1093
|
+
continuationId: input.continuationId,
|
|
1094
|
+
purpose: input.purpose,
|
|
1095
|
+
expiresAtMillis: expiresAt,
|
|
1096
|
+
},
|
|
1097
|
+
};
|
|
1098
|
+
|
|
1099
|
+
const prepared = prepare(decision, journal);
|
|
1100
|
+
|
|
1101
|
+
yield* insertCommand(
|
|
1102
|
+
mapping,
|
|
1103
|
+
input.moduleId,
|
|
1104
|
+
input.continuationId,
|
|
1105
|
+
"attempt",
|
|
1106
|
+
"accepted",
|
|
1107
|
+
retentionUntil,
|
|
1108
|
+
);
|
|
1109
|
+
yield* insertScopeEvents(
|
|
1110
|
+
mapping,
|
|
1111
|
+
input.moduleId,
|
|
1112
|
+
input.purpose,
|
|
1113
|
+
"attempt",
|
|
1114
|
+
input.continuationId,
|
|
1115
|
+
scopes,
|
|
1116
|
+
now,
|
|
1117
|
+
retentionUntil,
|
|
1118
|
+
);
|
|
1119
|
+
yield* transaction
|
|
1120
|
+
.update(mapping.generation.table)
|
|
1121
|
+
.set(updateValues<any>([[mapping.generation.state, "consumed"]]))
|
|
1122
|
+
.where(
|
|
1123
|
+
and(
|
|
1124
|
+
eq(gc.moduleId, input.moduleId),
|
|
1125
|
+
eq(gc.proofId, input.proofId),
|
|
1126
|
+
eq(gc.state, "active"),
|
|
1127
|
+
),
|
|
1128
|
+
);
|
|
1129
|
+
yield* transaction.insert(mapping.continuation.table).values(
|
|
1130
|
+
mapping.continuation.encodeInsert({
|
|
1131
|
+
...continuation,
|
|
1132
|
+
retentionUntilMillis: retentionUntil,
|
|
1133
|
+
}),
|
|
1134
|
+
);
|
|
1135
|
+
|
|
1136
|
+
return prepared;
|
|
1137
|
+
}),
|
|
1138
|
+
).pipe(
|
|
1139
|
+
Effect.provideService(CurrentProofSql, database),
|
|
1140
|
+
Effect.provideService(LifecycleHooks, hooks),
|
|
1141
|
+
translateFailure,
|
|
1142
|
+
),
|
|
1143
|
+
complete: (input, prepare) =>
|
|
1144
|
+
owned(
|
|
1145
|
+
database,
|
|
1146
|
+
mapping,
|
|
1147
|
+
configuration,
|
|
1148
|
+
Effect.gen(function* () {
|
|
1149
|
+
const journal = yield* CurrentCommitJournal;
|
|
1150
|
+
|
|
1151
|
+
return yield* completeIn(mapping, configuration, input, (decision) =>
|
|
1152
|
+
prepare(decision, journal),
|
|
1153
|
+
);
|
|
1154
|
+
}),
|
|
1155
|
+
).pipe(
|
|
1156
|
+
Effect.provideService(CurrentProofSql, database),
|
|
1157
|
+
Effect.provideService(LifecycleHooks, hooks),
|
|
1158
|
+
translateFailure,
|
|
1159
|
+
),
|
|
1160
|
+
claimDelivery: (input, prepare) =>
|
|
1161
|
+
owned(
|
|
1162
|
+
database,
|
|
1163
|
+
mapping,
|
|
1164
|
+
configuration,
|
|
1165
|
+
Effect.gen(function* () {
|
|
1166
|
+
const transaction = yield* CurrentProofSql;
|
|
1167
|
+
const journal = yield* CurrentCommitJournal;
|
|
1168
|
+
|
|
1169
|
+
const rows = yield* readGeneration(
|
|
1170
|
+
mapping,
|
|
1171
|
+
input.moduleId,
|
|
1172
|
+
input.proofId,
|
|
1173
|
+
configuration.locking,
|
|
1174
|
+
);
|
|
1175
|
+
|
|
1176
|
+
const row = rows[0];
|
|
1177
|
+
const now = yield* nowMillis;
|
|
1178
|
+
|
|
1179
|
+
if (row === undefined) return prepare({ _tag: "Declined" }, journal);
|
|
1180
|
+
const c = generationColumns(mapping);
|
|
1181
|
+
const expiresAt = yield* mapping.decodeInstant(row[mapping.generation.expiresAt]);
|
|
1182
|
+
|
|
1183
|
+
const claimDeadline =
|
|
1184
|
+
row[mapping.generation.claimDeadline] === null ||
|
|
1185
|
+
row[mapping.generation.claimDeadline] === undefined
|
|
1186
|
+
? undefined
|
|
1187
|
+
: yield* mapping.decodeInstant(row[mapping.generation.claimDeadline]);
|
|
1188
|
+
|
|
1189
|
+
const retryAt =
|
|
1190
|
+
row[mapping.generation.retryAt] === null ||
|
|
1191
|
+
row[mapping.generation.retryAt] === undefined
|
|
1192
|
+
? undefined
|
|
1193
|
+
: yield* mapping.decodeInstant(row[mapping.generation.retryAt]);
|
|
1194
|
+
|
|
1195
|
+
let state = row[mapping.generation.deliveryState] as string;
|
|
1196
|
+
|
|
1197
|
+
if (state === "claimed" && claimDeadline !== undefined && claimDeadline <= now) {
|
|
1198
|
+
state = "ambiguous";
|
|
1199
|
+
yield* transaction
|
|
1200
|
+
.update(mapping.generation.table)
|
|
1201
|
+
.set(updateValues<any>([[mapping.generation.deliveryState, "ambiguous"]]))
|
|
1202
|
+
.where(and(eq(c.moduleId, input.moduleId), eq(c.proofId, input.proofId)));
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
const canClaim =
|
|
1206
|
+
row[mapping.generation.version] === input.version &&
|
|
1207
|
+
row[mapping.generation.deliveryId] === input.deliveryId &&
|
|
1208
|
+
row[mapping.generation.state] === "active" &&
|
|
1209
|
+
expiresAt > now &&
|
|
1210
|
+
Number(row[mapping.generation.sendCount]) < input.policy.maximumDeliveryAttempts &&
|
|
1211
|
+
(state === "new" ||
|
|
1212
|
+
(state === "ambiguous" &&
|
|
1213
|
+
input.allowAmbiguousRetry &&
|
|
1214
|
+
(retryAt === undefined || retryAt <= now)));
|
|
1215
|
+
|
|
1216
|
+
if (!canClaim) return prepare({ _tag: "Declined" }, journal);
|
|
1217
|
+
const claimVersion = yield* allocateVersion(mapping, configuration.mode);
|
|
1218
|
+
const decision: ProofDeliveryClaim = { _tag: "Claimed", claimVersion };
|
|
1219
|
+
const prepared = prepare(decision, journal);
|
|
1220
|
+
|
|
1221
|
+
yield* transaction
|
|
1222
|
+
.update(mapping.generation.table)
|
|
1223
|
+
.set(
|
|
1224
|
+
updateValues<any>([
|
|
1225
|
+
[mapping.generation.sendCount, Number(row[mapping.generation.sendCount]) + 1],
|
|
1226
|
+
[mapping.generation.deliveryState, "claimed"],
|
|
1227
|
+
[mapping.generation.claimVersion, claimVersion],
|
|
1228
|
+
[
|
|
1229
|
+
mapping.generation.claimDeadline,
|
|
1230
|
+
mapping.encodeInstant(now + input.policy.deliveryClaimMillis),
|
|
1231
|
+
],
|
|
1232
|
+
[
|
|
1233
|
+
mapping.generation.retryAt,
|
|
1234
|
+
mapping.encodeInstant(now + input.policy.deliveryRetryMillis),
|
|
1235
|
+
],
|
|
1236
|
+
]),
|
|
1237
|
+
)
|
|
1238
|
+
.where(and(eq(c.moduleId, input.moduleId), eq(c.proofId, input.proofId)));
|
|
1239
|
+
|
|
1240
|
+
return prepared;
|
|
1241
|
+
}),
|
|
1242
|
+
).pipe(
|
|
1243
|
+
Effect.provideService(CurrentProofSql, database),
|
|
1244
|
+
Effect.provideService(LifecycleHooks, hooks),
|
|
1245
|
+
translateFailure,
|
|
1246
|
+
),
|
|
1247
|
+
settleDelivery: (input, prepare) =>
|
|
1248
|
+
owned(
|
|
1249
|
+
database,
|
|
1250
|
+
mapping,
|
|
1251
|
+
configuration,
|
|
1252
|
+
Effect.gen(function* () {
|
|
1253
|
+
const transaction = yield* CurrentProofSql;
|
|
1254
|
+
const journal = yield* CurrentCommitJournal;
|
|
1255
|
+
|
|
1256
|
+
const initial = (yield* readGeneration(mapping, input.moduleId, input.proofId, false))[0];
|
|
1257
|
+
|
|
1258
|
+
if (initial === undefined) return prepare(undefined, journal);
|
|
1259
|
+
const keys = initial[mapping.generation.seriesKey] as string;
|
|
1260
|
+
|
|
1261
|
+
yield* ensureSeries(
|
|
1262
|
+
mapping,
|
|
1263
|
+
configuration,
|
|
1264
|
+
input.moduleId,
|
|
1265
|
+
initial[mapping.generation.purpose],
|
|
1266
|
+
keys,
|
|
1267
|
+
);
|
|
1268
|
+
|
|
1269
|
+
const row = (yield* readGeneration(
|
|
1270
|
+
mapping,
|
|
1271
|
+
input.moduleId,
|
|
1272
|
+
input.proofId,
|
|
1273
|
+
configuration.locking,
|
|
1274
|
+
))[0];
|
|
1275
|
+
|
|
1276
|
+
const prepared = prepare(undefined, journal);
|
|
1277
|
+
|
|
1278
|
+
if (
|
|
1279
|
+
row === undefined ||
|
|
1280
|
+
row[mapping.generation.version] !== input.version ||
|
|
1281
|
+
row[mapping.generation.deliveryId] !== input.deliveryId ||
|
|
1282
|
+
row[mapping.generation.claimVersion] !== input.claimVersion ||
|
|
1283
|
+
row[mapping.generation.deliveryState] !== "claimed"
|
|
1284
|
+
)
|
|
1285
|
+
return prepared;
|
|
1286
|
+
const c = generationColumns(mapping);
|
|
1287
|
+
const outcome: ProofDeliveryOutcome = input.outcome;
|
|
1288
|
+
|
|
1289
|
+
const state =
|
|
1290
|
+
outcome._tag === "Accepted"
|
|
1291
|
+
? "accepted"
|
|
1292
|
+
: outcome._tag === "DefiniteFailure"
|
|
1293
|
+
? "failed"
|
|
1294
|
+
: "ambiguous";
|
|
1295
|
+
|
|
1296
|
+
const values: Array<readonly [string, unknown]> = [
|
|
1297
|
+
[mapping.generation.deliveryState, state],
|
|
1298
|
+
[mapping.generation.claimDeadline, null],
|
|
1299
|
+
];
|
|
1300
|
+
|
|
1301
|
+
if (outcome._tag === "Ambiguous")
|
|
1302
|
+
values.push([
|
|
1303
|
+
mapping.generation.retryAt,
|
|
1304
|
+
mapping.encodeInstant(
|
|
1305
|
+
(yield* nowMillis) + Number(row[mapping.generation.deliveryRetryMillis]),
|
|
1306
|
+
),
|
|
1307
|
+
]);
|
|
1308
|
+
if (outcome._tag === "DefiniteFailure")
|
|
1309
|
+
values.push([mapping.generation.state, "cancelled"]);
|
|
1310
|
+
yield* transaction
|
|
1311
|
+
.update(mapping.generation.table)
|
|
1312
|
+
.set(updateValues<any>(values))
|
|
1313
|
+
.where(and(eq(c.moduleId, input.moduleId), eq(c.proofId, input.proofId)));
|
|
1314
|
+
if (outcome._tag === "DefiniteFailure") {
|
|
1315
|
+
const sc = seriesColumns(mapping);
|
|
1316
|
+
|
|
1317
|
+
yield* transaction
|
|
1318
|
+
.update(mapping.series.table)
|
|
1319
|
+
.set(updateValues<any>([[mapping.series.activeProofId, null]]))
|
|
1320
|
+
.where(
|
|
1321
|
+
and(
|
|
1322
|
+
eq(sc.moduleId, input.moduleId),
|
|
1323
|
+
eq(sc.purpose, row[mapping.generation.purpose]),
|
|
1324
|
+
eq(sc.scopeKey, keys),
|
|
1325
|
+
eq(sc.activeProofId, input.proofId),
|
|
1326
|
+
),
|
|
1327
|
+
);
|
|
1328
|
+
}
|
|
1329
|
+
|
|
1330
|
+
return prepared;
|
|
1331
|
+
}),
|
|
1332
|
+
).pipe(
|
|
1333
|
+
Effect.provideService(CurrentProofSql, database),
|
|
1334
|
+
Effect.provideService(LifecycleHooks, hooks),
|
|
1335
|
+
translateFailure,
|
|
1336
|
+
),
|
|
1337
|
+
cancel: (input, prepare) =>
|
|
1338
|
+
owned(
|
|
1339
|
+
database,
|
|
1340
|
+
mapping,
|
|
1341
|
+
configuration,
|
|
1342
|
+
Effect.gen(function* () {
|
|
1343
|
+
const transaction = yield* CurrentProofSql;
|
|
1344
|
+
const journal = yield* CurrentCommitJournal;
|
|
1345
|
+
|
|
1346
|
+
const authorityCurrent = yield* lockAuthority(
|
|
1347
|
+
mapping,
|
|
1348
|
+
input.moduleId,
|
|
1349
|
+
input.purpose,
|
|
1350
|
+
input.binding,
|
|
1351
|
+
configuration.locking,
|
|
1352
|
+
);
|
|
1353
|
+
|
|
1354
|
+
const keys = mapping.scopeKeys({
|
|
1355
|
+
moduleId: input.moduleId,
|
|
1356
|
+
purpose: input.purpose,
|
|
1357
|
+
binding: input.binding,
|
|
1358
|
+
});
|
|
1359
|
+
|
|
1360
|
+
const series = yield* ensureSeries(
|
|
1361
|
+
mapping,
|
|
1362
|
+
configuration,
|
|
1363
|
+
input.moduleId,
|
|
1364
|
+
input.purpose,
|
|
1365
|
+
keys.series,
|
|
1366
|
+
);
|
|
1367
|
+
|
|
1368
|
+
const active = series[mapping.series.activeProofId] as string | undefined | null;
|
|
1369
|
+
const prepared = prepare(undefined, journal);
|
|
1370
|
+
|
|
1371
|
+
if (authorityCurrent && active !== undefined && active !== null) {
|
|
1372
|
+
const gc = generationColumns(mapping);
|
|
1373
|
+
const sc = seriesColumns(mapping);
|
|
1374
|
+
|
|
1375
|
+
const row = (yield* readGeneration(
|
|
1376
|
+
mapping,
|
|
1377
|
+
input.moduleId,
|
|
1378
|
+
active,
|
|
1379
|
+
configuration.locking,
|
|
1380
|
+
))[0];
|
|
1381
|
+
|
|
1382
|
+
const storedBinding =
|
|
1383
|
+
row === undefined ? undefined : yield* mapping.generation.decodeBinding(row);
|
|
1384
|
+
|
|
1385
|
+
if (storedBinding === undefined || !sameBinding(storedBinding, input.binding))
|
|
1386
|
+
return prepared;
|
|
1387
|
+
|
|
1388
|
+
yield* transaction
|
|
1389
|
+
.update(mapping.generation.table)
|
|
1390
|
+
.set(updateValues<any>([[mapping.generation.state, "cancelled"]]))
|
|
1391
|
+
.where(and(eq(gc.moduleId, input.moduleId), eq(gc.proofId, active)));
|
|
1392
|
+
yield* transaction
|
|
1393
|
+
.update(mapping.series.table)
|
|
1394
|
+
.set(updateValues<any>([[mapping.series.activeProofId, null]]))
|
|
1395
|
+
.where(
|
|
1396
|
+
and(
|
|
1397
|
+
eq(sc.moduleId, input.moduleId),
|
|
1398
|
+
eq(sc.purpose, input.purpose),
|
|
1399
|
+
eq(sc.scopeKey, keys.series),
|
|
1400
|
+
eq(sc.activeProofId, active),
|
|
1401
|
+
),
|
|
1402
|
+
);
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1405
|
+
return prepared;
|
|
1406
|
+
}),
|
|
1407
|
+
).pipe(
|
|
1408
|
+
Effect.provideService(CurrentProofSql, database),
|
|
1409
|
+
Effect.provideService(LifecycleHooks, hooks),
|
|
1410
|
+
translateFailure,
|
|
1411
|
+
),
|
|
1412
|
+
cleanup: (input, prepare) =>
|
|
1413
|
+
owned(
|
|
1414
|
+
database,
|
|
1415
|
+
mapping,
|
|
1416
|
+
configuration,
|
|
1417
|
+
Effect.gen(function* () {
|
|
1418
|
+
const transaction = yield* CurrentProofSql;
|
|
1419
|
+
const journal = yield* CurrentCommitJournal;
|
|
1420
|
+
|
|
1421
|
+
const now = yield* nowMillis;
|
|
1422
|
+
const nativeNow = mapping.encodeInstant(now);
|
|
1423
|
+
const gc = generationColumns(mapping);
|
|
1424
|
+
const cc = continuationColumns(mapping);
|
|
1425
|
+
const rc = requestColumns(mapping);
|
|
1426
|
+
const ac = abuseColumns(mapping);
|
|
1427
|
+
const fc = failureColumns(mapping);
|
|
1428
|
+
const mc = commandColumns(mapping);
|
|
1429
|
+
const sc = seriesColumns(mapping);
|
|
1430
|
+
const rsc = scopeColumns(mapping);
|
|
1431
|
+
let remaining = input.limit;
|
|
1432
|
+
let hasMore = false;
|
|
1433
|
+
|
|
1434
|
+
const take = <A>(query: ProofSqlQuery<ReadonlyArray<A>>) =>
|
|
1435
|
+
selectRows(query.limit(remaining + 1), configuration.locking).pipe(
|
|
1436
|
+
Effect.map((rows) => {
|
|
1437
|
+
if (rows.length > remaining) hasMore = true;
|
|
1438
|
+
const selected = rows.slice(0, remaining);
|
|
1439
|
+
|
|
1440
|
+
remaining -= selected.length;
|
|
1441
|
+
|
|
1442
|
+
return selected;
|
|
1443
|
+
}),
|
|
1444
|
+
);
|
|
1445
|
+
|
|
1446
|
+
// Child rows and secret-bearing generations are removed before their
|
|
1447
|
+
// retained request/decision records. Every selected row counts toward
|
|
1448
|
+
// one caller-wide limit and is locked until this owner commits.
|
|
1449
|
+
const continuations = yield* take(
|
|
1450
|
+
transaction
|
|
1451
|
+
.select({ continuationId: cc.continuationId })
|
|
1452
|
+
.from(mapping.continuation.table)
|
|
1453
|
+
.where(and(eq(cc.moduleId, input.moduleId), lte(cc.retentionUntil, nativeNow)))
|
|
1454
|
+
.orderBy(cc.retentionUntil),
|
|
1455
|
+
);
|
|
1456
|
+
|
|
1457
|
+
const generations = yield* take(
|
|
1458
|
+
transaction
|
|
1459
|
+
.select({ proofId: gc.proofId })
|
|
1460
|
+
.from(mapping.generation.table)
|
|
1461
|
+
.where(and(eq(gc.moduleId, input.moduleId), lte(gc.retentionUntil, nativeNow)))
|
|
1462
|
+
.orderBy(gc.retentionUntil),
|
|
1463
|
+
);
|
|
1464
|
+
|
|
1465
|
+
const requests = yield* take(
|
|
1466
|
+
transaction
|
|
1467
|
+
.select({ requestId: rc.requestId })
|
|
1468
|
+
.from(mapping.request.table)
|
|
1469
|
+
.where(and(eq(rc.moduleId, input.moduleId), lte(rc.retentionUntil, nativeNow)))
|
|
1470
|
+
.orderBy(rc.retentionUntil),
|
|
1471
|
+
);
|
|
1472
|
+
|
|
1473
|
+
const abuse = yield* take(
|
|
1474
|
+
transaction
|
|
1475
|
+
.select({
|
|
1476
|
+
action: ac.action,
|
|
1477
|
+
scopeKind: ac.scopeKind,
|
|
1478
|
+
scopeKey: ac.scopeKey,
|
|
1479
|
+
commandId: ac.commandId,
|
|
1480
|
+
})
|
|
1481
|
+
.from(mapping.abuseEvent.table)
|
|
1482
|
+
.where(and(eq(ac.moduleId, input.moduleId), lte(ac.retentionUntil, nativeNow)))
|
|
1483
|
+
.orderBy(ac.retentionUntil),
|
|
1484
|
+
);
|
|
1485
|
+
|
|
1486
|
+
const failures = yield* take(
|
|
1487
|
+
transaction
|
|
1488
|
+
.select({ seriesKey: fc.seriesKey, commandId: fc.commandId })
|
|
1489
|
+
.from(mapping.failureEvent.table)
|
|
1490
|
+
.where(and(eq(fc.moduleId, input.moduleId), lte(fc.retentionUntil, nativeNow)))
|
|
1491
|
+
.orderBy(fc.retentionUntil),
|
|
1492
|
+
);
|
|
1493
|
+
|
|
1494
|
+
const commands = yield* take(
|
|
1495
|
+
transaction
|
|
1496
|
+
.select({ commandId: mc.commandId })
|
|
1497
|
+
.from(mapping.command.table)
|
|
1498
|
+
.where(and(eq(mc.moduleId, input.moduleId), lte(mc.retentionUntil, nativeNow)))
|
|
1499
|
+
.orderBy(mc.retentionUntil),
|
|
1500
|
+
);
|
|
1501
|
+
|
|
1502
|
+
const series = yield* take(
|
|
1503
|
+
transaction
|
|
1504
|
+
.select({ purpose: sc.purpose, scopeKey: sc.scopeKey })
|
|
1505
|
+
.from(mapping.series.table)
|
|
1506
|
+
.where(
|
|
1507
|
+
and(
|
|
1508
|
+
eq(sc.moduleId, input.moduleId),
|
|
1509
|
+
isNull(sc.activeProofId),
|
|
1510
|
+
notExists(
|
|
1511
|
+
transaction
|
|
1512
|
+
.select({ one: sql`1` })
|
|
1513
|
+
.from(mapping.generation.table)
|
|
1514
|
+
.where(
|
|
1515
|
+
and(
|
|
1516
|
+
eq(gc.moduleId, sc.moduleId),
|
|
1517
|
+
eq(gc.purpose, sc.purpose),
|
|
1518
|
+
eq(gc.seriesKey, sc.scopeKey),
|
|
1519
|
+
),
|
|
1520
|
+
),
|
|
1521
|
+
),
|
|
1522
|
+
notExists(
|
|
1523
|
+
transaction
|
|
1524
|
+
.select({ one: sql`1` })
|
|
1525
|
+
.from(mapping.failureEvent.table)
|
|
1526
|
+
.where(
|
|
1527
|
+
and(
|
|
1528
|
+
eq(fc.moduleId, sc.moduleId),
|
|
1529
|
+
eq(fc.purpose, sc.purpose),
|
|
1530
|
+
eq(fc.seriesKey, sc.scopeKey),
|
|
1531
|
+
),
|
|
1532
|
+
),
|
|
1533
|
+
),
|
|
1534
|
+
),
|
|
1535
|
+
),
|
|
1536
|
+
);
|
|
1537
|
+
|
|
1538
|
+
const rateScopes = yield* take(
|
|
1539
|
+
transaction
|
|
1540
|
+
.select({
|
|
1541
|
+
purpose: rsc.purpose,
|
|
1542
|
+
action: rsc.action,
|
|
1543
|
+
scopeKind: rsc.scopeKind,
|
|
1544
|
+
scopeKey: rsc.scopeKey,
|
|
1545
|
+
})
|
|
1546
|
+
.from(mapping.rateScope.table)
|
|
1547
|
+
.where(
|
|
1548
|
+
and(
|
|
1549
|
+
eq(rsc.moduleId, input.moduleId),
|
|
1550
|
+
notExists(
|
|
1551
|
+
transaction
|
|
1552
|
+
.select({ one: sql`1` })
|
|
1553
|
+
.from(mapping.abuseEvent.table)
|
|
1554
|
+
.where(
|
|
1555
|
+
and(
|
|
1556
|
+
eq(ac.moduleId, rsc.moduleId),
|
|
1557
|
+
eq(ac.purpose, rsc.purpose),
|
|
1558
|
+
eq(ac.action, rsc.action),
|
|
1559
|
+
eq(ac.scopeKind, rsc.scopeKind),
|
|
1560
|
+
eq(ac.scopeKey, rsc.scopeKey),
|
|
1561
|
+
),
|
|
1562
|
+
),
|
|
1563
|
+
),
|
|
1564
|
+
),
|
|
1565
|
+
),
|
|
1566
|
+
);
|
|
1567
|
+
|
|
1568
|
+
// Removing the final history row can make an anchor eligible only after this
|
|
1569
|
+
// transaction/batch commits. One extra page lets the caller reclaim it.
|
|
1570
|
+
hasMore ||= generations.length > 0 || failures.length > 0 || abuse.length > 0;
|
|
1571
|
+
const removed = input.limit - remaining;
|
|
1572
|
+
const prepared = prepare({ removed, hasMore } satisfies ProofCleanupResult, journal);
|
|
1573
|
+
|
|
1574
|
+
if (continuations.length > 0)
|
|
1575
|
+
yield* transaction.delete(mapping.continuation.table).where(
|
|
1576
|
+
and(
|
|
1577
|
+
eq(cc.moduleId, input.moduleId),
|
|
1578
|
+
inArray(
|
|
1579
|
+
cc.continuationId,
|
|
1580
|
+
continuations.map((row: any) => row.continuationId),
|
|
1581
|
+
),
|
|
1582
|
+
lte(cc.retentionUntil, nativeNow),
|
|
1583
|
+
),
|
|
1584
|
+
);
|
|
1585
|
+
if (generations.length > 0)
|
|
1586
|
+
yield* transaction
|
|
1587
|
+
.update(mapping.series.table)
|
|
1588
|
+
.set(updateValues<any>([[mapping.series.activeProofId, null]]))
|
|
1589
|
+
.where(
|
|
1590
|
+
and(
|
|
1591
|
+
eq(sc.moduleId, input.moduleId),
|
|
1592
|
+
inArray(
|
|
1593
|
+
sc.activeProofId,
|
|
1594
|
+
generations.map((row: any) => row.proofId),
|
|
1595
|
+
),
|
|
1596
|
+
),
|
|
1597
|
+
);
|
|
1598
|
+
if (generations.length > 0)
|
|
1599
|
+
yield* transaction.delete(mapping.generation.table).where(
|
|
1600
|
+
and(
|
|
1601
|
+
eq(gc.moduleId, input.moduleId),
|
|
1602
|
+
inArray(
|
|
1603
|
+
gc.proofId,
|
|
1604
|
+
generations.map((row: any) => row.proofId),
|
|
1605
|
+
),
|
|
1606
|
+
lte(gc.retentionUntil, nativeNow),
|
|
1607
|
+
),
|
|
1608
|
+
);
|
|
1609
|
+
if (requests.length > 0)
|
|
1610
|
+
yield* transaction.delete(mapping.request.table).where(
|
|
1611
|
+
and(
|
|
1612
|
+
eq(rc.moduleId, input.moduleId),
|
|
1613
|
+
inArray(
|
|
1614
|
+
rc.requestId,
|
|
1615
|
+
requests.map((row: any) => row.requestId),
|
|
1616
|
+
),
|
|
1617
|
+
lte(rc.retentionUntil, nativeNow),
|
|
1618
|
+
),
|
|
1619
|
+
);
|
|
1620
|
+
for (const row of abuse)
|
|
1621
|
+
yield* transaction
|
|
1622
|
+
.delete(mapping.abuseEvent.table)
|
|
1623
|
+
.where(
|
|
1624
|
+
and(
|
|
1625
|
+
eq(ac.moduleId, input.moduleId),
|
|
1626
|
+
eq(ac.action, row.action),
|
|
1627
|
+
eq(ac.scopeKind, row.scopeKind),
|
|
1628
|
+
eq(ac.scopeKey, row.scopeKey),
|
|
1629
|
+
eq(ac.commandId, row.commandId),
|
|
1630
|
+
lte(ac.retentionUntil, nativeNow),
|
|
1631
|
+
),
|
|
1632
|
+
);
|
|
1633
|
+
for (const row of failures)
|
|
1634
|
+
yield* transaction
|
|
1635
|
+
.delete(mapping.failureEvent.table)
|
|
1636
|
+
.where(
|
|
1637
|
+
and(
|
|
1638
|
+
eq(fc.moduleId, input.moduleId),
|
|
1639
|
+
eq(fc.seriesKey, row.seriesKey),
|
|
1640
|
+
eq(fc.commandId, row.commandId),
|
|
1641
|
+
lte(fc.retentionUntil, nativeNow),
|
|
1642
|
+
),
|
|
1643
|
+
);
|
|
1644
|
+
if (commands.length > 0)
|
|
1645
|
+
yield* transaction.delete(mapping.command.table).where(
|
|
1646
|
+
and(
|
|
1647
|
+
eq(mc.moduleId, input.moduleId),
|
|
1648
|
+
inArray(
|
|
1649
|
+
mc.commandId,
|
|
1650
|
+
commands.map((row: any) => row.commandId),
|
|
1651
|
+
),
|
|
1652
|
+
lte(mc.retentionUntil, nativeNow),
|
|
1653
|
+
),
|
|
1654
|
+
);
|
|
1655
|
+
for (const row of series)
|
|
1656
|
+
yield* transaction.delete(mapping.series.table).where(
|
|
1657
|
+
and(
|
|
1658
|
+
eq(sc.moduleId, input.moduleId),
|
|
1659
|
+
eq(sc.purpose, row.purpose),
|
|
1660
|
+
eq(sc.scopeKey, row.scopeKey),
|
|
1661
|
+
isNull(sc.activeProofId),
|
|
1662
|
+
notExists(
|
|
1663
|
+
transaction
|
|
1664
|
+
.select({ one: sql`1` })
|
|
1665
|
+
.from(mapping.generation.table)
|
|
1666
|
+
.where(
|
|
1667
|
+
and(
|
|
1668
|
+
eq(gc.moduleId, sc.moduleId),
|
|
1669
|
+
eq(gc.purpose, sc.purpose),
|
|
1670
|
+
eq(gc.seriesKey, sc.scopeKey),
|
|
1671
|
+
),
|
|
1672
|
+
),
|
|
1673
|
+
),
|
|
1674
|
+
),
|
|
1675
|
+
);
|
|
1676
|
+
for (const row of rateScopes)
|
|
1677
|
+
yield* transaction.delete(mapping.rateScope.table).where(
|
|
1678
|
+
and(
|
|
1679
|
+
eq(rsc.moduleId, input.moduleId),
|
|
1680
|
+
eq(rsc.purpose, row.purpose),
|
|
1681
|
+
eq(rsc.action, row.action),
|
|
1682
|
+
eq(rsc.scopeKind, row.scopeKind),
|
|
1683
|
+
eq(rsc.scopeKey, row.scopeKey),
|
|
1684
|
+
notExists(
|
|
1685
|
+
transaction
|
|
1686
|
+
.select({ one: sql`1` })
|
|
1687
|
+
.from(mapping.abuseEvent.table)
|
|
1688
|
+
.where(
|
|
1689
|
+
and(
|
|
1690
|
+
eq(ac.moduleId, rsc.moduleId),
|
|
1691
|
+
eq(ac.purpose, rsc.purpose),
|
|
1692
|
+
eq(ac.action, rsc.action),
|
|
1693
|
+
eq(ac.scopeKind, rsc.scopeKind),
|
|
1694
|
+
eq(ac.scopeKey, rsc.scopeKey),
|
|
1695
|
+
),
|
|
1696
|
+
),
|
|
1697
|
+
),
|
|
1698
|
+
),
|
|
1699
|
+
);
|
|
1700
|
+
|
|
1701
|
+
return prepared;
|
|
1702
|
+
}),
|
|
1703
|
+
).pipe(
|
|
1704
|
+
Effect.provideService(CurrentProofSql, database),
|
|
1705
|
+
Effect.provideService(LifecycleHooks, hooks),
|
|
1706
|
+
translateFailure,
|
|
1707
|
+
),
|
|
1708
|
+
});
|
|
1709
|
+
});
|
|
1710
|
+
|
|
1711
|
+
const inspectCompletionIn = Effect.fn("DrizzleProof.inspectCompletionIn")(function* (
|
|
1712
|
+
mapping: Mapping,
|
|
1713
|
+
configuration: ProofSqlConfiguration,
|
|
1714
|
+
input: ProofCompletionPlan["input"],
|
|
1715
|
+
ensure: boolean,
|
|
1716
|
+
) {
|
|
1717
|
+
const database = yield* CurrentProofSql;
|
|
1718
|
+
|
|
1719
|
+
const authorityCurrent = yield* lockAuthority(
|
|
1720
|
+
mapping,
|
|
1721
|
+
input.moduleId,
|
|
1722
|
+
input.purpose,
|
|
1723
|
+
input.binding,
|
|
1724
|
+
configuration.locking,
|
|
1725
|
+
);
|
|
1726
|
+
|
|
1727
|
+
const keys = mapping.scopeKeys({
|
|
1728
|
+
moduleId: input.moduleId,
|
|
1729
|
+
purpose: input.purpose,
|
|
1730
|
+
binding: input.binding,
|
|
1731
|
+
});
|
|
1732
|
+
|
|
1733
|
+
if (ensure)
|
|
1734
|
+
yield* ensureSeries(mapping, configuration, input.moduleId, input.purpose, keys.series);
|
|
1735
|
+
const c = continuationColumns(mapping);
|
|
1736
|
+
|
|
1737
|
+
const rows = yield* selectRows(
|
|
1738
|
+
database
|
|
1739
|
+
.select()
|
|
1740
|
+
.from(mapping.continuation.table)
|
|
1741
|
+
.where(and(eq(c.moduleId, input.moduleId), eq(c.continuationId, input.continuationId)))
|
|
1742
|
+
.limit(1),
|
|
1743
|
+
configuration.locking,
|
|
1744
|
+
);
|
|
1745
|
+
|
|
1746
|
+
const row = rows[0];
|
|
1747
|
+
const now = yield* nowMillis;
|
|
1748
|
+
const record = row === undefined ? undefined : yield* mapping.continuation.decode(row);
|
|
1749
|
+
|
|
1750
|
+
const completed =
|
|
1751
|
+
authorityCurrent &&
|
|
1752
|
+
row !== undefined &&
|
|
1753
|
+
record !== undefined &&
|
|
1754
|
+
record.moduleId === input.moduleId &&
|
|
1755
|
+
record.continuationId === input.continuationId &&
|
|
1756
|
+
record.purpose === input.purpose &&
|
|
1757
|
+
record.digest === input.continuationDigest &&
|
|
1758
|
+
record.seriesKey === keys.series &&
|
|
1759
|
+
sameBinding(record.binding, input.binding) &&
|
|
1760
|
+
row[mapping.continuation.consumed] === false &&
|
|
1761
|
+
record.expiresAtMillis > now;
|
|
1762
|
+
|
|
1763
|
+
return completed ? { record: record!, row, columns: c } : undefined;
|
|
1764
|
+
});
|
|
1765
|
+
|
|
1766
|
+
/** Nonconsuming same-owner preflight; it never inserts a series or changes expiry. */
|
|
1767
|
+
export const checkProofCompletionIn = Effect.fn("Drizzle.checkProofCompletionIn")(function* (
|
|
1768
|
+
mapping: Mapping,
|
|
1769
|
+
configuration: ProofSqlConfiguration,
|
|
1770
|
+
input: ProofCompletionPlan["input"],
|
|
1771
|
+
) {
|
|
1772
|
+
return yield* inspectCompletionIn(mapping, configuration, input, false).pipe(
|
|
1773
|
+
Effect.map((value) => value !== undefined),
|
|
1774
|
+
);
|
|
1775
|
+
});
|
|
1776
|
+
|
|
1777
|
+
const completeIn = Effect.fn("DrizzleProof.completeIn")(function* <A, E = never, R = never>(
|
|
1778
|
+
mapping: Mapping,
|
|
1779
|
+
configuration: ProofSqlConfiguration,
|
|
1780
|
+
input: ProofCompletionPlan["input"],
|
|
1781
|
+
prepare: (decision: ProofCompletionDecision) => A,
|
|
1782
|
+
protectedMutation?: Effect.Effect<boolean, E, R>,
|
|
1783
|
+
) {
|
|
1784
|
+
const database = yield* CurrentProofSql;
|
|
1785
|
+
|
|
1786
|
+
const accepted = yield* inspectCompletionIn(mapping, configuration, input, true);
|
|
1787
|
+
|
|
1788
|
+
if (accepted === undefined) return prepare("rejected");
|
|
1789
|
+
const { record, row: original, columns: c } = accepted;
|
|
1790
|
+
|
|
1791
|
+
if (protectedMutation !== undefined && !(yield* protectedMutation)) return yield* unavailable();
|
|
1792
|
+
const value = prepare("completed");
|
|
1793
|
+
|
|
1794
|
+
yield* database
|
|
1795
|
+
.update(mapping.continuation.table)
|
|
1796
|
+
.set(updateValues<any>([[mapping.continuation.consumed, true]]))
|
|
1797
|
+
.where(
|
|
1798
|
+
and(
|
|
1799
|
+
eq(c.moduleId, input.moduleId),
|
|
1800
|
+
eq(c.continuationId, input.continuationId),
|
|
1801
|
+
eq(c.digest, input.continuationDigest),
|
|
1802
|
+
eq(c.consumed, false),
|
|
1803
|
+
),
|
|
1804
|
+
);
|
|
1805
|
+
yield* insertCommand(
|
|
1806
|
+
mapping,
|
|
1807
|
+
input.moduleId,
|
|
1808
|
+
input.continuationDigest,
|
|
1809
|
+
"complete",
|
|
1810
|
+
"completed",
|
|
1811
|
+
record.expiresAtMillis,
|
|
1812
|
+
);
|
|
1813
|
+
|
|
1814
|
+
const assertApplied = Effect.flatMap(CurrentPasswordPreparedTransaction, (currentTransaction) =>
|
|
1815
|
+
Effect.gen(function* () {
|
|
1816
|
+
const persisted = (yield* selectRows(
|
|
1817
|
+
currentTransaction
|
|
1818
|
+
.select()
|
|
1819
|
+
.from(mapping.continuation.table)
|
|
1820
|
+
.where(and(eq(c.moduleId, input.moduleId), eq(c.continuationId, input.continuationId)))
|
|
1821
|
+
.limit(1),
|
|
1822
|
+
false,
|
|
1823
|
+
))[0];
|
|
1824
|
+
|
|
1825
|
+
const command = (yield* commandRow(
|
|
1826
|
+
mapping,
|
|
1827
|
+
input.moduleId,
|
|
1828
|
+
input.continuationDigest,
|
|
1829
|
+
false,
|
|
1830
|
+
))[0];
|
|
1831
|
+
|
|
1832
|
+
const decoded =
|
|
1833
|
+
persisted === undefined ? undefined : yield* mapping.continuation.decode(persisted);
|
|
1834
|
+
|
|
1835
|
+
const immutable = [
|
|
1836
|
+
mapping.continuation.moduleId,
|
|
1837
|
+
mapping.continuation.purpose,
|
|
1838
|
+
mapping.continuation.continuationId,
|
|
1839
|
+
mapping.continuation.digest,
|
|
1840
|
+
mapping.continuation.proofId,
|
|
1841
|
+
mapping.continuation.seriesKey,
|
|
1842
|
+
mapping.continuation.version,
|
|
1843
|
+
];
|
|
1844
|
+
|
|
1845
|
+
if (
|
|
1846
|
+
persisted === undefined ||
|
|
1847
|
+
decoded === undefined ||
|
|
1848
|
+
!sameBinding(decoded.binding, record.binding) ||
|
|
1849
|
+
persisted[mapping.continuation.consumed] !== true ||
|
|
1850
|
+
immutable.some((key) => persisted[key] !== original[key]) ||
|
|
1851
|
+
(yield* mapping.decodeInstant(persisted[mapping.continuation.expiresAt])) !==
|
|
1852
|
+
record.expiresAtMillis ||
|
|
1853
|
+
(yield* mapping.decodeInstant(persisted[mapping.continuation.retentionUntil])) !==
|
|
1854
|
+
(yield* mapping.decodeInstant(original[mapping.continuation.retentionUntil])) ||
|
|
1855
|
+
command === undefined ||
|
|
1856
|
+
command[mapping.command.kind] !== "complete" ||
|
|
1857
|
+
command[mapping.command.decision] !== "completed" ||
|
|
1858
|
+
(yield* mapping.decodeInstant(command[mapping.command.retentionUntil])) !==
|
|
1859
|
+
record.expiresAtMillis
|
|
1860
|
+
)
|
|
1861
|
+
return yield* unavailable();
|
|
1862
|
+
|
|
1863
|
+
if (record.expiresAtMillis <= (yield* nowMillis)) return yield* unavailable();
|
|
1864
|
+
}).pipe(Effect.provideService(CurrentProofSql, currentTransaction)),
|
|
1865
|
+
);
|
|
1866
|
+
|
|
1867
|
+
yield* assertApplied.pipe(Effect.provideService(CurrentPasswordPreparedTransaction, database));
|
|
1868
|
+
const postconditions = yield* Effect.serviceOption(PasswordPreparedPostconditions);
|
|
1869
|
+
|
|
1870
|
+
if (
|
|
1871
|
+
Option.isSome(postconditions) &&
|
|
1872
|
+
!postconditions.value.register(assertApplied.pipe(translateFailure))
|
|
1873
|
+
)
|
|
1874
|
+
return yield* unavailable();
|
|
1875
|
+
|
|
1876
|
+
return value;
|
|
1877
|
+
});
|
|
1878
|
+
|
|
1879
|
+
/** Private same-owner seam for password and identifier mutations. */
|
|
1880
|
+
export const completeProofPlanIn = Effect.fn("Drizzle.completeProofPlanIn")(function* <
|
|
1881
|
+
Rq extends Table,
|
|
1882
|
+
S extends Table,
|
|
1883
|
+
G extends Table,
|
|
1884
|
+
Cn extends Table,
|
|
1885
|
+
Rs extends Table,
|
|
1886
|
+
Aev extends Table,
|
|
1887
|
+
F extends Table,
|
|
1888
|
+
C extends Table,
|
|
1889
|
+
Sub extends Table,
|
|
1890
|
+
I extends Table,
|
|
1891
|
+
Cr extends Table,
|
|
1892
|
+
NativeId,
|
|
1893
|
+
A,
|
|
1894
|
+
E,
|
|
1895
|
+
R,
|
|
1896
|
+
>(
|
|
1897
|
+
mapping: ProofPersistenceMapping<Rq, S, G, Cn, Rs, Aev, F, C, Sub, I, Cr, NativeId>,
|
|
1898
|
+
configuration: ProofSqlConfiguration,
|
|
1899
|
+
plan: ProofCompletionPlan,
|
|
1900
|
+
protectedMutation: Effect.Effect<boolean, E, R>,
|
|
1901
|
+
project: (decision: ProofCompletionDecision) => A,
|
|
1902
|
+
) {
|
|
1903
|
+
const journal = yield* CurrentCommitJournal;
|
|
1904
|
+
|
|
1905
|
+
return yield* completeIn(
|
|
1906
|
+
mapping as unknown as Mapping,
|
|
1907
|
+
configuration,
|
|
1908
|
+
plan.input,
|
|
1909
|
+
(decision) => plan.prepare(decision, journal, project),
|
|
1910
|
+
protectedMutation,
|
|
1911
|
+
);
|
|
1912
|
+
});
|