@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,2082 @@
|
|
|
1
|
+
/* oxlint-disable no-explicit-any -- the shared dialect kernel intentionally erases consumer Drizzle table types. */
|
|
2
|
+
import { and, eq, gte, inArray, lte, notExists, sql } from "drizzle-orm";
|
|
3
|
+
import type { EffectDrizzleQueryError } from "drizzle-orm/effect-core";
|
|
4
|
+
import { Cause, Context, DateTime, Effect, Option, Redacted, Schema } from "effect";
|
|
5
|
+
import type * as SqlError from "effect/unstable/sql/SqlError";
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
coordinateCommit,
|
|
9
|
+
CurrentCommitJournal,
|
|
10
|
+
hasCommitScope,
|
|
11
|
+
type CommitJournal,
|
|
12
|
+
type PreparedCommit,
|
|
13
|
+
} from "../hooks/commit";
|
|
14
|
+
import { LifecycleHooks } from "../hooks/LifecycleHooks";
|
|
15
|
+
import { HookConfigurationError } from "../hooks/models";
|
|
16
|
+
import type { LoginIdentifier } from "../identity/models";
|
|
17
|
+
import { reportPersistenceFailure } from "../internal/diagnostics";
|
|
18
|
+
import { PasswordUnavailable } from "../password/methods/errors";
|
|
19
|
+
import type {
|
|
20
|
+
PasswordAction,
|
|
21
|
+
PasswordAttemptDecision,
|
|
22
|
+
PasswordCredentialSnapshot,
|
|
23
|
+
PasswordMutationDecision,
|
|
24
|
+
} from "../password/methods/models";
|
|
25
|
+
import {
|
|
26
|
+
PasswordPersistence,
|
|
27
|
+
type PasswordMutationInput,
|
|
28
|
+
} from "../password/methods/PasswordPersistence";
|
|
29
|
+
import type { PasswordAttemptPolicy } from "../password/methods/policy";
|
|
30
|
+
import {
|
|
31
|
+
snapshotPasswordCredential,
|
|
32
|
+
snapshotPasswordRequirement,
|
|
33
|
+
snapshotPasswordRevision,
|
|
34
|
+
} from "../password/methods/snapshot";
|
|
35
|
+
import type { ProofCompletionPlan } from "../proofs/completion";
|
|
36
|
+
import { ProofUnavailable } from "../proofs/errors";
|
|
37
|
+
import type { ProofCompletionInput } from "../proofs/ProofPersistence";
|
|
38
|
+
import { snapshotAuthenticationEvidence } from "../sessions/assurance";
|
|
39
|
+
import type {
|
|
40
|
+
AuthenticationEvidence,
|
|
41
|
+
AuthenticationRequirement,
|
|
42
|
+
SecurityRevision,
|
|
43
|
+
} from "../sessions/models";
|
|
44
|
+
import { column, DrizzleMappingError, updateValues } from "./model";
|
|
45
|
+
import {
|
|
46
|
+
type AnyPasswordPersistenceMapping,
|
|
47
|
+
type PasswordAttemptAction,
|
|
48
|
+
type PasswordRateScopeKind,
|
|
49
|
+
type PasswordScopeKeys,
|
|
50
|
+
requiredPasswordConstraints,
|
|
51
|
+
} from "./password-model";
|
|
52
|
+
import {
|
|
53
|
+
CurrentProofSql,
|
|
54
|
+
type ProofSqlConfiguration,
|
|
55
|
+
type ProofSqlDatabase,
|
|
56
|
+
completeProofPlanIn,
|
|
57
|
+
} from "./proof-sql";
|
|
58
|
+
|
|
59
|
+
type AdapterFailure = EffectDrizzleQueryError | DrizzleMappingError | SqlError.SqlError;
|
|
60
|
+
|
|
61
|
+
export interface PasswordSqlQuery<A = ReadonlyArray<any>> extends Effect.Effect<A, AdapterFailure> {
|
|
62
|
+
readonly getSQL: () => ReturnType<typeof sql>;
|
|
63
|
+
readonly from: (...args: ReadonlyArray<any>) => PasswordSqlQuery<A>;
|
|
64
|
+
readonly where: (...args: ReadonlyArray<any>) => PasswordSqlQuery<A>;
|
|
65
|
+
readonly limit: (...args: ReadonlyArray<any>) => PasswordSqlQuery<A>;
|
|
66
|
+
readonly orderBy: (...args: ReadonlyArray<any>) => PasswordSqlQuery<A>;
|
|
67
|
+
readonly for: (...args: ReadonlyArray<any>) => PasswordSqlQuery<A>;
|
|
68
|
+
readonly set: (...args: ReadonlyArray<any>) => PasswordSqlQuery<A>;
|
|
69
|
+
readonly values: (...args: ReadonlyArray<any>) => PasswordSqlQuery<A>;
|
|
70
|
+
readonly returning: (...args: ReadonlyArray<any>) => PasswordSqlQuery<A>;
|
|
71
|
+
readonly $returningId: (...args: ReadonlyArray<any>) => PasswordSqlQuery<A>;
|
|
72
|
+
readonly onConflictDoNothing: (...args: ReadonlyArray<any>) => PasswordSqlQuery<A>;
|
|
73
|
+
readonly onDuplicateKeyUpdate: (...args: ReadonlyArray<any>) => PasswordSqlQuery<A>;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface PasswordSqlDatabase {
|
|
77
|
+
readonly select: (...args: ReadonlyArray<any>) => PasswordSqlQuery;
|
|
78
|
+
readonly insert: (...args: ReadonlyArray<any>) => PasswordSqlQuery;
|
|
79
|
+
readonly update: (...args: ReadonlyArray<any>) => PasswordSqlQuery;
|
|
80
|
+
readonly delete: (...args: ReadonlyArray<any>) => PasswordSqlQuery;
|
|
81
|
+
readonly transaction: <A, E, R>(
|
|
82
|
+
body: (transaction: PasswordSqlDatabase) => Effect.Effect<A, E, R>,
|
|
83
|
+
) => Effect.Effect<A, E | SqlError.SqlError, R>;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export class CurrentPasswordSql extends Context.Service<CurrentPasswordSql, PasswordSqlDatabase>()(
|
|
87
|
+
"effect-auth/CurrentPasswordSql",
|
|
88
|
+
) {}
|
|
89
|
+
|
|
90
|
+
export interface PasswordSqlConfiguration {
|
|
91
|
+
readonly mode: "interactive" | "synchronous";
|
|
92
|
+
readonly locking: boolean;
|
|
93
|
+
readonly standaloneGuard: Effect.Effect<void, PasswordUnavailable>;
|
|
94
|
+
readonly coordinated?: boolean;
|
|
95
|
+
readonly insertIfAbsent: (
|
|
96
|
+
query: PasswordSqlQuery,
|
|
97
|
+
selfKey: string,
|
|
98
|
+
selfValue: unknown,
|
|
99
|
+
) => PasswordSqlQuery;
|
|
100
|
+
readonly proof?: {
|
|
101
|
+
readonly mapping: any;
|
|
102
|
+
readonly configuration: ProofSqlConfiguration;
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
type Database = PasswordSqlDatabase;
|
|
107
|
+
type Mapping = AnyPasswordPersistenceMapping;
|
|
108
|
+
const unavailable = () => PasswordUnavailable.make({});
|
|
109
|
+
|
|
110
|
+
const translateFailure = <A, E, R>(
|
|
111
|
+
effect: Effect.Effect<A, E, R>,
|
|
112
|
+
): Effect.Effect<A, PasswordUnavailable, R> =>
|
|
113
|
+
reportPersistenceFailure(
|
|
114
|
+
effect,
|
|
115
|
+
(error) =>
|
|
116
|
+
Schema.is(PasswordUnavailable)(error) ||
|
|
117
|
+
Schema.is(ProofUnavailable)(error) ||
|
|
118
|
+
Schema.is(HookConfigurationError)(error),
|
|
119
|
+
).pipe(Effect.catchCause((cause) => Effect.failCause(Cause.map(cause, () => unavailable()))));
|
|
120
|
+
|
|
121
|
+
const nowMillis = DateTime.now.pipe(Effect.map(DateTime.toEpochMillis));
|
|
122
|
+
|
|
123
|
+
const validConstraints = (mapping: Mapping) =>
|
|
124
|
+
Object.entries(requiredPasswordConstraints).every(
|
|
125
|
+
([key, value]) =>
|
|
126
|
+
mapping.constraints[key as keyof typeof requiredPasswordConstraints] === value,
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
const selectRows = (query: PasswordSqlQuery, locking: boolean) =>
|
|
130
|
+
locking && typeof query.for === "function" ? query.for("update") : query;
|
|
131
|
+
|
|
132
|
+
const subjectColumns = (mapping: Mapping) => ({
|
|
133
|
+
id: column(mapping.subject.table, mapping.subject.id),
|
|
134
|
+
status: column(mapping.subject.table, mapping.subject.status),
|
|
135
|
+
securityRevision: column(mapping.subject.table, mapping.subject.securityRevision),
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
const identifierColumns = (mapping: Mapping) => ({
|
|
139
|
+
namespace: column(mapping.identifier.table, mapping.identifier.namespace),
|
|
140
|
+
value: column(mapping.identifier.table, mapping.identifier.value),
|
|
141
|
+
subjectId: column(mapping.identifier.table, mapping.identifier.subjectId),
|
|
142
|
+
verifiedAt: column(mapping.identifier.table, mapping.identifier.verifiedAt),
|
|
143
|
+
bindingRevision: column(mapping.identifier.table, mapping.identifier.bindingRevision),
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
const credentialColumns = (mapping: Mapping) => ({
|
|
147
|
+
moduleId: column(mapping.credential.table, mapping.credential.moduleId),
|
|
148
|
+
subjectId: column(mapping.credential.table, mapping.credential.subjectId),
|
|
149
|
+
credentialId: column(mapping.credential.table, mapping.credential.credentialId),
|
|
150
|
+
credentialRevision: column(mapping.credential.table, mapping.credential.credentialRevision),
|
|
151
|
+
verifierVersion: column(mapping.credential.table, mapping.credential.verifierVersion),
|
|
152
|
+
verifier: column(mapping.credential.table, mapping.credential.verifier),
|
|
153
|
+
normalization: column(mapping.credential.table, mapping.credential.normalization),
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
const authorityCredentialColumns = (mapping: Mapping) => ({
|
|
157
|
+
subjectId: column(mapping.authorityCredential.table, mapping.authorityCredential.subjectId),
|
|
158
|
+
credentialId: column(mapping.authorityCredential.table, mapping.authorityCredential.credentialId),
|
|
159
|
+
revision: column(mapping.authorityCredential.table, mapping.authorityCredential.revision),
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
const attemptColumns = (mapping: Mapping) => ({
|
|
163
|
+
moduleId: column(mapping.attempt.table, mapping.attempt.moduleId),
|
|
164
|
+
action: column(mapping.attempt.table, mapping.attempt.action),
|
|
165
|
+
attemptId: column(mapping.attempt.table, mapping.attempt.attemptId),
|
|
166
|
+
identifierNamespace: column(mapping.attempt.table, mapping.attempt.identifierNamespace),
|
|
167
|
+
identifierValue: column(mapping.attempt.table, mapping.attempt.identifierValue),
|
|
168
|
+
subjectId: column(mapping.attempt.table, mapping.attempt.subjectId),
|
|
169
|
+
credentialId: column(mapping.attempt.table, mapping.attempt.credentialId),
|
|
170
|
+
securityRevision: column(mapping.attempt.table, mapping.attempt.securityRevision),
|
|
171
|
+
credentialRevision: column(mapping.attempt.table, mapping.attempt.credentialRevision),
|
|
172
|
+
verifierVersion: column(mapping.attempt.table, mapping.attempt.verifierVersion),
|
|
173
|
+
identifierBindingRevision: column(
|
|
174
|
+
mapping.attempt.table,
|
|
175
|
+
mapping.attempt.identifierBindingRevision,
|
|
176
|
+
),
|
|
177
|
+
admittedAt: column(mapping.attempt.table, mapping.attempt.admittedAt),
|
|
178
|
+
deadline: column(mapping.attempt.table, mapping.attempt.deadline),
|
|
179
|
+
retentionUntil: column(mapping.attempt.table, mapping.attempt.retentionUntil),
|
|
180
|
+
state: column(mapping.attempt.table, mapping.attempt.state),
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
const scopeColumns = (mapping: Mapping) => ({
|
|
184
|
+
moduleId: column(mapping.rateScope.table, mapping.rateScope.moduleId),
|
|
185
|
+
action: column(mapping.rateScope.table, mapping.rateScope.action),
|
|
186
|
+
scopeKind: column(mapping.rateScope.table, mapping.rateScope.scopeKind),
|
|
187
|
+
scopeKey: column(mapping.rateScope.table, mapping.rateScope.scopeKey),
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
const chargeColumns = (mapping: Mapping) => ({
|
|
191
|
+
moduleId: column(mapping.charge.table, mapping.charge.moduleId),
|
|
192
|
+
action: column(mapping.charge.table, mapping.charge.action),
|
|
193
|
+
scopeKind: column(mapping.charge.table, mapping.charge.scopeKind),
|
|
194
|
+
scopeKey: column(mapping.charge.table, mapping.charge.scopeKey),
|
|
195
|
+
attemptId: column(mapping.charge.table, mapping.charge.attemptId),
|
|
196
|
+
occurredAt: column(mapping.charge.table, mapping.charge.occurredAt),
|
|
197
|
+
retentionUntil: column(mapping.charge.table, mapping.charge.retentionUntil),
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
const commandColumns = (mapping: Mapping) => ({
|
|
201
|
+
moduleId: column(mapping.command.table, mapping.command.moduleId),
|
|
202
|
+
commandId: column(mapping.command.table, mapping.command.commandId),
|
|
203
|
+
action: column(mapping.command.table, mapping.command.action),
|
|
204
|
+
bindingDigest: column(mapping.command.table, mapping.command.bindingDigest),
|
|
205
|
+
decision: column(mapping.command.table, mapping.command.decision),
|
|
206
|
+
retentionUntil: column(mapping.command.table, mapping.command.retentionUntil),
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
const allocate = <A>(
|
|
210
|
+
mode: PasswordSqlConfiguration["mode"],
|
|
211
|
+
asyncValue: Effect.Effect<A, DrizzleMappingError> | undefined,
|
|
212
|
+
syncValue: (() => A) | undefined,
|
|
213
|
+
): Effect.Effect<A, PasswordUnavailable | DrizzleMappingError> => {
|
|
214
|
+
if (mode === "synchronous")
|
|
215
|
+
return syncValue === undefined
|
|
216
|
+
? Effect.fail(unavailable())
|
|
217
|
+
: Effect.try({
|
|
218
|
+
try: syncValue,
|
|
219
|
+
catch: (cause) => new DrizzleMappingError({ operation: "mapping", cause }),
|
|
220
|
+
});
|
|
221
|
+
if (asyncValue !== undefined) return asyncValue;
|
|
222
|
+
|
|
223
|
+
return syncValue === undefined
|
|
224
|
+
? Effect.fail(unavailable())
|
|
225
|
+
: Effect.try({
|
|
226
|
+
try: syncValue,
|
|
227
|
+
catch: (cause) => new DrizzleMappingError({ operation: "mapping", cause }),
|
|
228
|
+
});
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
const allocateNextSecurityRevision = (
|
|
232
|
+
mapping: Mapping,
|
|
233
|
+
mode: PasswordSqlConfiguration["mode"],
|
|
234
|
+
current: SecurityRevision,
|
|
235
|
+
) => {
|
|
236
|
+
const asyncValue = mapping.subject.nextSecurityRevision?.(current);
|
|
237
|
+
|
|
238
|
+
const syncValue =
|
|
239
|
+
mapping.subject.nextSecurityRevisionSync === undefined
|
|
240
|
+
? undefined
|
|
241
|
+
: () => mapping.subject.nextSecurityRevisionSync!(current);
|
|
242
|
+
|
|
243
|
+
return allocate(
|
|
244
|
+
mode,
|
|
245
|
+
asyncValue ?? mapping.allocateRevision,
|
|
246
|
+
syncValue ?? mapping.allocateRevisionSync,
|
|
247
|
+
);
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
const sameIdentifier = (left: LoginIdentifier, right: LoginIdentifier) =>
|
|
251
|
+
left.namespace === right.namespace && left.value === right.value;
|
|
252
|
+
|
|
253
|
+
const sameCredentialSnapshot = (
|
|
254
|
+
left: PasswordCredentialSnapshot,
|
|
255
|
+
right: PasswordCredentialSnapshot,
|
|
256
|
+
) =>
|
|
257
|
+
left.moduleId === right.moduleId &&
|
|
258
|
+
left.revision.subjectId === right.revision.subjectId &&
|
|
259
|
+
left.revision.securityRevision === right.revision.securityRevision &&
|
|
260
|
+
left.credentialId === right.credentialId &&
|
|
261
|
+
left.credentialRevision === right.credentialRevision &&
|
|
262
|
+
left.verifierVersion === right.verifierVersion &&
|
|
263
|
+
left.normalization === right.normalization &&
|
|
264
|
+
left.identifierVerifiedAtMillis === right.identifierVerifiedAtMillis &&
|
|
265
|
+
left.revision.credentials.length === right.revision.credentials.length &&
|
|
266
|
+
left.revision.credentials.every((entry) =>
|
|
267
|
+
right.revision.credentials.some(
|
|
268
|
+
(other) => other.credentialId === entry.credentialId && other.revision === entry.revision,
|
|
269
|
+
),
|
|
270
|
+
) &&
|
|
271
|
+
left.identifierBindingRevision === right.identifierBindingRevision &&
|
|
272
|
+
sameIdentifier(left.identifier, right.identifier) &&
|
|
273
|
+
Redacted.value(left.verifier) === Redacted.value(right.verifier);
|
|
274
|
+
|
|
275
|
+
const evidenceSatisfiedAt = (
|
|
276
|
+
evidence: AuthenticationEvidence,
|
|
277
|
+
requirement: AuthenticationRequirement,
|
|
278
|
+
now: number,
|
|
279
|
+
): boolean => {
|
|
280
|
+
if (evidence.proofs.length > 64 || evidence.revision.credentials.length > 64) return false;
|
|
281
|
+
const revisions = new Map<string, string>();
|
|
282
|
+
|
|
283
|
+
for (const item of evidence.revision.credentials) {
|
|
284
|
+
if (revisions.has(item.credentialId)) return false;
|
|
285
|
+
revisions.set(item.credentialId, item.revision);
|
|
286
|
+
}
|
|
287
|
+
if (evidence.proofs.some((proof) => !revisions.has(proof.credentialId))) return false;
|
|
288
|
+
if (evidence.proofs.some((proof) => now < DateTime.toEpochMillis(proof.verifiedAt))) return false;
|
|
289
|
+
|
|
290
|
+
const eligible = evidence.proofs.filter((proof) => {
|
|
291
|
+
const age = now - DateTime.toEpochMillis(proof.verifiedAt);
|
|
292
|
+
|
|
293
|
+
return age >= 0 && age < requirement.maximumAgeMillis;
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
const factors = new Set(eligible.flatMap((proof) => proof.factors));
|
|
297
|
+
const credentials = new Set(eligible.map((proof) => proof.credentialId));
|
|
298
|
+
|
|
299
|
+
return requirement.alternatives.some(
|
|
300
|
+
(alternative) =>
|
|
301
|
+
alternative.factors.every((factor) => factors.has(factor)) &&
|
|
302
|
+
credentials.size >= alternative.minimumCredentials &&
|
|
303
|
+
eligible.some(
|
|
304
|
+
(proof) =>
|
|
305
|
+
(!alternative.userVerified || proof.userVerified) &&
|
|
306
|
+
(!alternative.phishingResistant || proof.phishingResistant),
|
|
307
|
+
),
|
|
308
|
+
);
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
const snapshotMutationInput = Effect.fn("DrizzlePassword.snapshotMutationInput")(function* (
|
|
312
|
+
input: PasswordMutationInput,
|
|
313
|
+
) {
|
|
314
|
+
const expectedRevision = snapshotPasswordRevision(input.expectedRevision);
|
|
315
|
+
|
|
316
|
+
const evidence = yield* snapshotAuthenticationEvidence(input.authorization.evidence).pipe(
|
|
317
|
+
Effect.mapError(unavailable),
|
|
318
|
+
);
|
|
319
|
+
|
|
320
|
+
const requirement = yield* snapshotPasswordRequirement(input.authorization.requirement);
|
|
321
|
+
|
|
322
|
+
const credential =
|
|
323
|
+
input.credential === undefined
|
|
324
|
+
? undefined
|
|
325
|
+
: yield* snapshotPasswordCredential(input.credential);
|
|
326
|
+
|
|
327
|
+
return Object.freeze({
|
|
328
|
+
...input,
|
|
329
|
+
expectedRevision,
|
|
330
|
+
replacement: Object.freeze({
|
|
331
|
+
verifier: Redacted.make(Redacted.value(input.replacement.verifier)),
|
|
332
|
+
normalization: input.replacement.normalization,
|
|
333
|
+
}),
|
|
334
|
+
invalidation: Object.freeze({ ...input.invalidation }),
|
|
335
|
+
...(credential === undefined ? {} : { credential }),
|
|
336
|
+
authorization: Object.freeze({
|
|
337
|
+
challenge: Object.freeze({
|
|
338
|
+
...input.authorization.challenge,
|
|
339
|
+
revision: snapshotPasswordRevision(input.authorization.challenge.revision),
|
|
340
|
+
}),
|
|
341
|
+
evidence,
|
|
342
|
+
requirement,
|
|
343
|
+
}),
|
|
344
|
+
});
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
const lockSubject = Effect.fn("DrizzlePassword.lockSubject")(function* (
|
|
348
|
+
mapping: Mapping,
|
|
349
|
+
subjectId: string,
|
|
350
|
+
locking: boolean,
|
|
351
|
+
) {
|
|
352
|
+
const database = yield* CurrentPasswordSql;
|
|
353
|
+
|
|
354
|
+
const nativeSubjectId = yield* mapping.subjectId.toNative(subjectId as any);
|
|
355
|
+
const c = subjectColumns(mapping);
|
|
356
|
+
|
|
357
|
+
const rows = yield* selectRows(
|
|
358
|
+
database.select().from(mapping.subject.table).where(eq(c.id, nativeSubjectId)).limit(1),
|
|
359
|
+
locking,
|
|
360
|
+
);
|
|
361
|
+
|
|
362
|
+
return { nativeSubjectId, row: rows[0] };
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
const lockIdentifier = Effect.fn("Drizzle.lockIdentifier")(function* (
|
|
366
|
+
mapping: Mapping,
|
|
367
|
+
identifier: LoginIdentifier,
|
|
368
|
+
locking: boolean,
|
|
369
|
+
) {
|
|
370
|
+
const database = yield* CurrentPasswordSql;
|
|
371
|
+
|
|
372
|
+
const c = identifierColumns(mapping);
|
|
373
|
+
|
|
374
|
+
return yield* selectRows(
|
|
375
|
+
database
|
|
376
|
+
.select()
|
|
377
|
+
.from(mapping.identifier.table)
|
|
378
|
+
.where(and(eq(c.namespace, identifier.namespace), eq(c.value, identifier.value)))
|
|
379
|
+
.limit(1),
|
|
380
|
+
locking,
|
|
381
|
+
);
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
const readPasswordCredential = Effect.fn("Drizzle.readPasswordCredential")(function* (
|
|
385
|
+
mapping: Mapping,
|
|
386
|
+
moduleId: string,
|
|
387
|
+
nativeSubjectId: unknown,
|
|
388
|
+
locking: boolean,
|
|
389
|
+
) {
|
|
390
|
+
const database = yield* CurrentPasswordSql;
|
|
391
|
+
|
|
392
|
+
const c = credentialColumns(mapping);
|
|
393
|
+
|
|
394
|
+
return yield* selectRows(
|
|
395
|
+
database
|
|
396
|
+
.select()
|
|
397
|
+
.from(mapping.credential.table)
|
|
398
|
+
.where(and(eq(c.moduleId, moduleId), eq(c.subjectId, nativeSubjectId)))
|
|
399
|
+
.limit(1),
|
|
400
|
+
locking,
|
|
401
|
+
);
|
|
402
|
+
});
|
|
403
|
+
|
|
404
|
+
const resolveCredential = Effect.fn("DrizzlePassword.resolveCredential")(function* (
|
|
405
|
+
mapping: Mapping,
|
|
406
|
+
moduleId: string,
|
|
407
|
+
identifier: LoginIdentifier,
|
|
408
|
+
requestedSubjectId: string | undefined,
|
|
409
|
+
locking: boolean,
|
|
410
|
+
) {
|
|
411
|
+
const database = yield* CurrentPasswordSql;
|
|
412
|
+
|
|
413
|
+
// The unlocked lookup only discovers the prospective subject. The canonical
|
|
414
|
+
// protected order starts with the subject and then rechecks the identifier.
|
|
415
|
+
const discovered = (yield* lockIdentifier(mapping, identifier, false))[0];
|
|
416
|
+
|
|
417
|
+
if (discovered === undefined || !mapping.identifier.isCurrent(discovered)) return undefined;
|
|
418
|
+
const discoveredNative = discovered[mapping.identifier.subjectId];
|
|
419
|
+
|
|
420
|
+
const subjectRows = yield* selectRows(
|
|
421
|
+
database
|
|
422
|
+
.select()
|
|
423
|
+
.from(mapping.subject.table)
|
|
424
|
+
.where(eq(subjectColumns(mapping).id, discoveredNative))
|
|
425
|
+
.limit(1),
|
|
426
|
+
locking,
|
|
427
|
+
);
|
|
428
|
+
|
|
429
|
+
const subject = subjectRows[0];
|
|
430
|
+
|
|
431
|
+
if (subject === undefined || !mapping.subject.isActiveStatus(subject[mapping.subject.status]))
|
|
432
|
+
return undefined;
|
|
433
|
+
const identifiers = yield* lockIdentifier(mapping, identifier, locking);
|
|
434
|
+
const identifierRow = identifiers[0];
|
|
435
|
+
|
|
436
|
+
if (
|
|
437
|
+
identifierRow === undefined ||
|
|
438
|
+
!mapping.identifier.isCurrent(identifierRow) ||
|
|
439
|
+
!mapping.subjectId.equals(discoveredNative, identifierRow[mapping.identifier.subjectId])
|
|
440
|
+
)
|
|
441
|
+
return undefined;
|
|
442
|
+
const subjectId = yield* mapping.subjectId.toSubject(discoveredNative);
|
|
443
|
+
|
|
444
|
+
if (requestedSubjectId !== undefined && requestedSubjectId !== subjectId) return undefined;
|
|
445
|
+
const credentials = yield* readPasswordCredential(mapping, moduleId, discoveredNative, locking);
|
|
446
|
+
const credential = credentials[0];
|
|
447
|
+
|
|
448
|
+
if (credential === undefined)
|
|
449
|
+
return { nativeSubjectId: discoveredNative, subject, identifier: identifierRow };
|
|
450
|
+
|
|
451
|
+
const snapshot = yield* mapping.credential
|
|
452
|
+
.decode({ moduleId, subject, identifier: identifierRow, credential })
|
|
453
|
+
.pipe(Effect.flatMap(snapshotPasswordCredential));
|
|
454
|
+
|
|
455
|
+
return {
|
|
456
|
+
nativeSubjectId: discoveredNative,
|
|
457
|
+
subject,
|
|
458
|
+
identifier: identifierRow,
|
|
459
|
+
credential,
|
|
460
|
+
snapshot,
|
|
461
|
+
};
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
interface ScopeEntry {
|
|
465
|
+
readonly kind: PasswordRateScopeKind;
|
|
466
|
+
readonly key: string;
|
|
467
|
+
readonly limit: number;
|
|
468
|
+
readonly windowMillis: number;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
const scopeEntries = (
|
|
472
|
+
keys: PasswordScopeKeys,
|
|
473
|
+
policy: PasswordAttemptPolicy,
|
|
474
|
+
): ReadonlyArray<ScopeEntry> => {
|
|
475
|
+
const values: ScopeEntry[] = [
|
|
476
|
+
{ kind: "action", key: keys.action, ...policy.action },
|
|
477
|
+
{ kind: "identifier", key: keys.identifier, ...policy.identifier },
|
|
478
|
+
];
|
|
479
|
+
|
|
480
|
+
if (keys.subject !== undefined)
|
|
481
|
+
values.push({ kind: "subject", key: keys.subject, ...policy.subject });
|
|
482
|
+
|
|
483
|
+
return values;
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
const lockScope = Effect.fn("DrizzlePassword.lockScope")(function* (
|
|
487
|
+
mapping: Mapping,
|
|
488
|
+
configuration: PasswordSqlConfiguration,
|
|
489
|
+
moduleId: string,
|
|
490
|
+
action: PasswordAttemptAction,
|
|
491
|
+
entry: ScopeEntry,
|
|
492
|
+
) {
|
|
493
|
+
const database = yield* CurrentPasswordSql;
|
|
494
|
+
|
|
495
|
+
const query = database.insert(mapping.rateScope.table).values(
|
|
496
|
+
mapping.rateScope.encodeInsert({
|
|
497
|
+
moduleId,
|
|
498
|
+
action,
|
|
499
|
+
scopeKind: entry.kind,
|
|
500
|
+
scopeKey: entry.key,
|
|
501
|
+
}),
|
|
502
|
+
);
|
|
503
|
+
|
|
504
|
+
yield* configuration.insertIfAbsent(query, mapping.rateScope.scopeKey, entry.key);
|
|
505
|
+
const c = scopeColumns(mapping);
|
|
506
|
+
|
|
507
|
+
yield* selectRows(
|
|
508
|
+
database
|
|
509
|
+
.select()
|
|
510
|
+
.from(mapping.rateScope.table)
|
|
511
|
+
.where(
|
|
512
|
+
and(
|
|
513
|
+
eq(c.moduleId, moduleId),
|
|
514
|
+
eq(c.action, action),
|
|
515
|
+
eq(c.scopeKind, entry.kind),
|
|
516
|
+
eq(c.scopeKey, entry.key),
|
|
517
|
+
),
|
|
518
|
+
)
|
|
519
|
+
.limit(1),
|
|
520
|
+
configuration.locking,
|
|
521
|
+
);
|
|
522
|
+
});
|
|
523
|
+
|
|
524
|
+
const scopeAdmits = Effect.fn("DrizzlePassword.scopeAdmits")(function* (
|
|
525
|
+
mapping: Mapping,
|
|
526
|
+
moduleId: string,
|
|
527
|
+
action: PasswordAttemptAction,
|
|
528
|
+
entry: ScopeEntry,
|
|
529
|
+
policy: PasswordAttemptPolicy,
|
|
530
|
+
identifier: LoginIdentifier,
|
|
531
|
+
nativeSubjectId: unknown | undefined,
|
|
532
|
+
now: number,
|
|
533
|
+
) {
|
|
534
|
+
const database = yield* CurrentPasswordSql;
|
|
535
|
+
|
|
536
|
+
const c = chargeColumns(mapping);
|
|
537
|
+
|
|
538
|
+
const charges = yield* selectRows(
|
|
539
|
+
database
|
|
540
|
+
.select({ attemptId: c.attemptId })
|
|
541
|
+
.from(mapping.charge.table)
|
|
542
|
+
.where(
|
|
543
|
+
and(
|
|
544
|
+
eq(c.moduleId, moduleId),
|
|
545
|
+
eq(c.action, action),
|
|
546
|
+
eq(c.scopeKind, entry.kind),
|
|
547
|
+
eq(c.scopeKey, entry.key),
|
|
548
|
+
gte(c.occurredAt, mapping.encodeInstant(now - entry.windowMillis)),
|
|
549
|
+
),
|
|
550
|
+
)
|
|
551
|
+
.limit(entry.limit),
|
|
552
|
+
true,
|
|
553
|
+
);
|
|
554
|
+
|
|
555
|
+
if (charges.length >= entry.limit) return false;
|
|
556
|
+
const a = attemptColumns(mapping);
|
|
557
|
+
|
|
558
|
+
const pendingWhere =
|
|
559
|
+
entry.kind === "action"
|
|
560
|
+
? and(eq(a.moduleId, moduleId), eq(a.action, action), eq(a.state, "pending"))
|
|
561
|
+
: entry.kind === "identifier"
|
|
562
|
+
? and(
|
|
563
|
+
eq(a.moduleId, moduleId),
|
|
564
|
+
eq(a.action, action),
|
|
565
|
+
eq(a.identifierNamespace, identifier.namespace),
|
|
566
|
+
eq(a.identifierValue, identifier.value),
|
|
567
|
+
eq(a.state, "pending"),
|
|
568
|
+
)
|
|
569
|
+
: and(
|
|
570
|
+
eq(a.moduleId, moduleId),
|
|
571
|
+
eq(a.action, action),
|
|
572
|
+
eq(a.subjectId, nativeSubjectId),
|
|
573
|
+
eq(a.state, "pending"),
|
|
574
|
+
);
|
|
575
|
+
|
|
576
|
+
const pending = yield* selectRows(
|
|
577
|
+
database
|
|
578
|
+
.select({ attemptId: a.attemptId })
|
|
579
|
+
.from(mapping.attempt.table)
|
|
580
|
+
.where(pendingWhere)
|
|
581
|
+
.limit(policy.maximumPending),
|
|
582
|
+
true,
|
|
583
|
+
);
|
|
584
|
+
|
|
585
|
+
return pending.length < policy.maximumPending;
|
|
586
|
+
});
|
|
587
|
+
|
|
588
|
+
const insertCharge = Effect.fn("Drizzle.insertCharge")(function* (
|
|
589
|
+
mapping: Mapping,
|
|
590
|
+
moduleId: string,
|
|
591
|
+
action: PasswordAttemptAction,
|
|
592
|
+
entry: ScopeEntry,
|
|
593
|
+
attemptId: any,
|
|
594
|
+
now: number,
|
|
595
|
+
) {
|
|
596
|
+
const database = yield* CurrentPasswordSql;
|
|
597
|
+
|
|
598
|
+
return yield* database.insert(mapping.charge.table).values(
|
|
599
|
+
mapping.charge.encodeInsert({
|
|
600
|
+
moduleId,
|
|
601
|
+
action,
|
|
602
|
+
scopeKind: entry.kind,
|
|
603
|
+
scopeKey: entry.key,
|
|
604
|
+
attemptId,
|
|
605
|
+
occurredAtMillis: now,
|
|
606
|
+
retentionUntilMillis: now + entry.windowMillis,
|
|
607
|
+
}),
|
|
608
|
+
);
|
|
609
|
+
});
|
|
610
|
+
|
|
611
|
+
const owned = <A, E, R>(
|
|
612
|
+
database: Database,
|
|
613
|
+
mapping: Mapping,
|
|
614
|
+
configuration: PasswordSqlConfiguration,
|
|
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(
|
|
623
|
+
Effect.provideService(CurrentPasswordSql, transaction),
|
|
624
|
+
Effect.provideService(CurrentProofSql, transaction as unknown as ProofSqlDatabase),
|
|
625
|
+
),
|
|
626
|
+
),
|
|
627
|
+
{ mode: configuration.mode },
|
|
628
|
+
).pipe(Effect.map((result) => result.value));
|
|
629
|
+
|
|
630
|
+
return configuration.coordinated !== true
|
|
631
|
+
? Effect.gen(function* () {
|
|
632
|
+
if (yield* hasCommitScope) return yield* unavailable();
|
|
633
|
+
yield* configuration.standaloneGuard;
|
|
634
|
+
|
|
635
|
+
return yield* run;
|
|
636
|
+
})
|
|
637
|
+
: run;
|
|
638
|
+
};
|
|
639
|
+
|
|
640
|
+
const safeRead = <A, E, R>(
|
|
641
|
+
database: Database,
|
|
642
|
+
configuration: PasswordSqlConfiguration,
|
|
643
|
+
body: Effect.Effect<A, E, R>,
|
|
644
|
+
) =>
|
|
645
|
+
Effect.gen(function* () {
|
|
646
|
+
if (configuration.coordinated !== true) {
|
|
647
|
+
if (yield* hasCommitScope) return yield* unavailable();
|
|
648
|
+
yield* configuration.standaloneGuard;
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
return yield* database.transaction((transaction) =>
|
|
652
|
+
body.pipe(
|
|
653
|
+
Effect.provideService(CurrentPasswordSql, transaction),
|
|
654
|
+
Effect.provideService(CurrentProofSql, transaction as unknown as ProofSqlDatabase),
|
|
655
|
+
),
|
|
656
|
+
);
|
|
657
|
+
});
|
|
658
|
+
|
|
659
|
+
const proofCompletionMatchesPassword = (
|
|
660
|
+
input: PasswordMutationInput & { readonly completion: ProofCompletionPlan },
|
|
661
|
+
) => {
|
|
662
|
+
const completion = input.completion.input;
|
|
663
|
+
const binding = completion.binding;
|
|
664
|
+
|
|
665
|
+
if (
|
|
666
|
+
completion.moduleId !== `${input.moduleId}/reset` ||
|
|
667
|
+
completion.purpose !== "password-reset" ||
|
|
668
|
+
binding._tag !== "Subject" ||
|
|
669
|
+
input.credential === undefined ||
|
|
670
|
+
binding.revision.subjectId !== input.expectedRevision.subjectId ||
|
|
671
|
+
binding.revision.securityRevision !== input.expectedRevision.securityRevision ||
|
|
672
|
+
!sameIdentifier(binding.identifier, input.credential.identifier)
|
|
673
|
+
)
|
|
674
|
+
return false;
|
|
675
|
+
|
|
676
|
+
const expected = [...input.expectedRevision.credentials].sort((left, right) =>
|
|
677
|
+
left.credentialId.localeCompare(right.credentialId),
|
|
678
|
+
);
|
|
679
|
+
|
|
680
|
+
const actual = [...binding.revision.credentials].sort((left, right) =>
|
|
681
|
+
left.credentialId.localeCompare(right.credentialId),
|
|
682
|
+
);
|
|
683
|
+
|
|
684
|
+
return (
|
|
685
|
+
expected.length === actual.length &&
|
|
686
|
+
expected.every(
|
|
687
|
+
(item, index) =>
|
|
688
|
+
item.credentialId === actual[index]!.credentialId &&
|
|
689
|
+
item.revision === actual[index]!.revision,
|
|
690
|
+
)
|
|
691
|
+
);
|
|
692
|
+
};
|
|
693
|
+
|
|
694
|
+
const probeProofCompletion = Effect.fn("Drizzle.probeProofCompletion")(function* (
|
|
695
|
+
configuration: PasswordSqlConfiguration,
|
|
696
|
+
input: ProofCompletionInput,
|
|
697
|
+
) {
|
|
698
|
+
const database = yield* CurrentPasswordSql;
|
|
699
|
+
|
|
700
|
+
if (configuration.proof === undefined) return yield* Effect.fail(unavailable());
|
|
701
|
+
const validProbe = { _tag: "PasswordProofCompletionValid" } as const;
|
|
702
|
+
|
|
703
|
+
const plan: ProofCompletionPlan = {
|
|
704
|
+
input,
|
|
705
|
+
prepare: (decision, journal, project) => journal.prepare(project(decision)),
|
|
706
|
+
};
|
|
707
|
+
|
|
708
|
+
const probe = coordinateCommit(
|
|
709
|
+
() =>
|
|
710
|
+
database.transaction((transaction) =>
|
|
711
|
+
completeProofPlanIn(
|
|
712
|
+
configuration.proof!.mapping,
|
|
713
|
+
configuration.proof!.configuration,
|
|
714
|
+
plan,
|
|
715
|
+
Effect.fail(validProbe),
|
|
716
|
+
() => false,
|
|
717
|
+
).pipe(Effect.provideService(CurrentProofSql, transaction as unknown as ProofSqlDatabase)),
|
|
718
|
+
),
|
|
719
|
+
{ mode: configuration.mode },
|
|
720
|
+
);
|
|
721
|
+
|
|
722
|
+
if (configuration.coordinated === true || (yield* hasCommitScope)) return yield* unavailable();
|
|
723
|
+
yield* configuration.standaloneGuard;
|
|
724
|
+
|
|
725
|
+
return yield* probe.pipe(
|
|
726
|
+
Effect.as(false),
|
|
727
|
+
Effect.catchCause((cause) => {
|
|
728
|
+
const reason = cause.reasons[0];
|
|
729
|
+
|
|
730
|
+
return cause.reasons.length === 1 &&
|
|
731
|
+
reason !== undefined &&
|
|
732
|
+
Cause.isFailReason(reason) &&
|
|
733
|
+
reason.error === validProbe
|
|
734
|
+
? Effect.succeed(true)
|
|
735
|
+
: Effect.failCause(cause);
|
|
736
|
+
}),
|
|
737
|
+
);
|
|
738
|
+
});
|
|
739
|
+
|
|
740
|
+
const validateMutationAuthority = Effect.fn("DrizzlePassword.validateMutationAuthority")(function* (
|
|
741
|
+
mapping: Mapping,
|
|
742
|
+
configuration: PasswordSqlConfiguration,
|
|
743
|
+
input: PasswordMutationInput,
|
|
744
|
+
action: PasswordAction,
|
|
745
|
+
) {
|
|
746
|
+
const database = yield* CurrentPasswordSql;
|
|
747
|
+
|
|
748
|
+
const locked = yield* lockSubject(
|
|
749
|
+
mapping,
|
|
750
|
+
input.expectedRevision.subjectId,
|
|
751
|
+
configuration.locking,
|
|
752
|
+
);
|
|
753
|
+
|
|
754
|
+
const row = locked.row;
|
|
755
|
+
|
|
756
|
+
if (
|
|
757
|
+
row === undefined ||
|
|
758
|
+
!mapping.subject.isActiveStatus(row[mapping.subject.status]) ||
|
|
759
|
+
row[mapping.subject.securityRevision] !== input.expectedRevision.securityRevision
|
|
760
|
+
)
|
|
761
|
+
return undefined;
|
|
762
|
+
if (
|
|
763
|
+
input.authorization.challenge.moduleId !== input.moduleId ||
|
|
764
|
+
input.authorization.challenge.action !== action ||
|
|
765
|
+
input.authorization.challenge.commandId !== input.commandId ||
|
|
766
|
+
input.authorization.challenge.revision.subjectId !== input.expectedRevision.subjectId ||
|
|
767
|
+
input.authorization.challenge.revision.securityRevision !==
|
|
768
|
+
input.expectedRevision.securityRevision ||
|
|
769
|
+
(input.authorization.evidence.flowId as string) !== (input.commandId as string) ||
|
|
770
|
+
input.authorization.evidence.bindingDigest !== input.authorization.challenge.bindingDigest ||
|
|
771
|
+
input.authorization.evidence.revision.subjectId !== input.expectedRevision.subjectId ||
|
|
772
|
+
input.authorization.evidence.revision.securityRevision !==
|
|
773
|
+
input.expectedRevision.securityRevision ||
|
|
774
|
+
(action === "add-password" &&
|
|
775
|
+
(input.credential !== undefined ||
|
|
776
|
+
input.authorization.challenge.targetCredentialId !== undefined))
|
|
777
|
+
)
|
|
778
|
+
return undefined;
|
|
779
|
+
if (
|
|
780
|
+
input.expectedRevision.credentials.some(
|
|
781
|
+
(expected) =>
|
|
782
|
+
!input.authorization.evidence.revision.credentials.some(
|
|
783
|
+
(actual) =>
|
|
784
|
+
actual.credentialId === expected.credentialId && actual.revision === expected.revision,
|
|
785
|
+
),
|
|
786
|
+
)
|
|
787
|
+
)
|
|
788
|
+
return undefined;
|
|
789
|
+
if (input.credential !== undefined) {
|
|
790
|
+
const identifier = (yield* lockIdentifier(
|
|
791
|
+
mapping,
|
|
792
|
+
input.credential.identifier,
|
|
793
|
+
configuration.locking,
|
|
794
|
+
))[0];
|
|
795
|
+
|
|
796
|
+
if (
|
|
797
|
+
identifier === undefined ||
|
|
798
|
+
!mapping.identifier.isCurrent(identifier) ||
|
|
799
|
+
!mapping.subjectId.equals(identifier[mapping.identifier.subjectId], locked.nativeSubjectId) ||
|
|
800
|
+
identifier[mapping.identifier.bindingRevision] !== input.credential.identifierBindingRevision
|
|
801
|
+
)
|
|
802
|
+
return undefined;
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
const allExpected = [
|
|
806
|
+
...input.expectedRevision.credentials,
|
|
807
|
+
...input.authorization.evidence.revision.credentials,
|
|
808
|
+
];
|
|
809
|
+
|
|
810
|
+
const expected = [...new Map(allExpected.map((item) => [item.credentialId, item])).values()].sort(
|
|
811
|
+
(left, right) => left.credentialId.localeCompare(right.credentialId),
|
|
812
|
+
);
|
|
813
|
+
|
|
814
|
+
const ac = authorityCredentialColumns(mapping);
|
|
815
|
+
|
|
816
|
+
const credentialRows =
|
|
817
|
+
expected.length === 0
|
|
818
|
+
? []
|
|
819
|
+
: yield* selectRows(
|
|
820
|
+
database
|
|
821
|
+
.select()
|
|
822
|
+
.from(mapping.authorityCredential.table)
|
|
823
|
+
.where(
|
|
824
|
+
and(
|
|
825
|
+
eq(ac.subjectId, locked.nativeSubjectId),
|
|
826
|
+
inArray(
|
|
827
|
+
ac.credentialId,
|
|
828
|
+
expected.map((item) => item.credentialId),
|
|
829
|
+
),
|
|
830
|
+
),
|
|
831
|
+
)
|
|
832
|
+
.orderBy(ac.credentialId),
|
|
833
|
+
configuration.locking,
|
|
834
|
+
);
|
|
835
|
+
|
|
836
|
+
if (credentialRows.length !== expected.length) return undefined;
|
|
837
|
+
for (let index = 0; index < credentialRows.length; index++) {
|
|
838
|
+
const actual = credentialRows[index]!;
|
|
839
|
+
const wanted = expected[index]!;
|
|
840
|
+
|
|
841
|
+
if (
|
|
842
|
+
actual[mapping.authorityCredential.credentialId] !== wanted.credentialId ||
|
|
843
|
+
actual[mapping.authorityCredential.revision] !== wanted.revision ||
|
|
844
|
+
(mapping.authorityCredential.status !== undefined &&
|
|
845
|
+
mapping.authorityCredential.isActiveStatus?.(actual[mapping.authorityCredential.status]) !==
|
|
846
|
+
true)
|
|
847
|
+
)
|
|
848
|
+
return undefined;
|
|
849
|
+
}
|
|
850
|
+
if (input.credential !== undefined) {
|
|
851
|
+
const identifier = (yield* lockIdentifier(mapping, input.credential.identifier, false))[0];
|
|
852
|
+
|
|
853
|
+
const credential = (yield* readPasswordCredential(
|
|
854
|
+
mapping,
|
|
855
|
+
input.moduleId,
|
|
856
|
+
locked.nativeSubjectId,
|
|
857
|
+
configuration.locking,
|
|
858
|
+
))[0];
|
|
859
|
+
|
|
860
|
+
if (identifier === undefined || credential === undefined) return undefined;
|
|
861
|
+
|
|
862
|
+
const snapshot = yield* mapping.credential.decode({
|
|
863
|
+
moduleId: input.moduleId,
|
|
864
|
+
subject: row,
|
|
865
|
+
identifier,
|
|
866
|
+
credential,
|
|
867
|
+
});
|
|
868
|
+
|
|
869
|
+
if (!sameCredentialSnapshot(snapshot, input.credential)) return undefined;
|
|
870
|
+
}
|
|
871
|
+
const currentRequirement = yield* mapping.subject.decodeActionRequirement(row, action);
|
|
872
|
+
const now = yield* nowMillis;
|
|
873
|
+
|
|
874
|
+
if (
|
|
875
|
+
!evidenceSatisfiedAt(input.authorization.evidence, input.authorization.requirement, now) ||
|
|
876
|
+
!evidenceSatisfiedAt(input.authorization.evidence, currentRequirement, now)
|
|
877
|
+
)
|
|
878
|
+
return undefined;
|
|
879
|
+
if (
|
|
880
|
+
input.invalidation.existingSessions === "immediate" &&
|
|
881
|
+
mapping.sessionInvalidation !== "same-authority-immediate"
|
|
882
|
+
)
|
|
883
|
+
return undefined;
|
|
884
|
+
|
|
885
|
+
return { ...locked, now };
|
|
886
|
+
});
|
|
887
|
+
|
|
888
|
+
const commandExists = Effect.fn("Drizzle.commandExists")(function* (
|
|
889
|
+
mapping: Mapping,
|
|
890
|
+
moduleId: string,
|
|
891
|
+
commandId: string,
|
|
892
|
+
locking: boolean,
|
|
893
|
+
) {
|
|
894
|
+
const database = yield* CurrentPasswordSql;
|
|
895
|
+
|
|
896
|
+
const c = commandColumns(mapping);
|
|
897
|
+
|
|
898
|
+
return yield* selectRows(
|
|
899
|
+
database
|
|
900
|
+
.select()
|
|
901
|
+
.from(mapping.command.table)
|
|
902
|
+
.where(and(eq(c.moduleId, moduleId), eq(c.commandId, commandId)))
|
|
903
|
+
.limit(1),
|
|
904
|
+
locking,
|
|
905
|
+
);
|
|
906
|
+
});
|
|
907
|
+
|
|
908
|
+
const insertCommand = Effect.fn("Drizzle.insertCommand")(function* (
|
|
909
|
+
mapping: Mapping,
|
|
910
|
+
input: PasswordMutationInput,
|
|
911
|
+
action: PasswordAction,
|
|
912
|
+
now: number,
|
|
913
|
+
) {
|
|
914
|
+
const database = yield* CurrentPasswordSql;
|
|
915
|
+
|
|
916
|
+
return yield* database.insert(mapping.command.table).values(
|
|
917
|
+
mapping.command.encodeInsert({
|
|
918
|
+
moduleId: input.moduleId,
|
|
919
|
+
commandId: input.commandId,
|
|
920
|
+
action,
|
|
921
|
+
bindingDigest: input.authorization.challenge.bindingDigest,
|
|
922
|
+
decision: "changed",
|
|
923
|
+
retentionUntilMillis: now + mapping.commandRetentionMillis,
|
|
924
|
+
}),
|
|
925
|
+
);
|
|
926
|
+
});
|
|
927
|
+
|
|
928
|
+
const mutationPostconditions = Effect.fn("DrizzlePassword.mutationPostconditions")(function* (
|
|
929
|
+
mapping: Mapping,
|
|
930
|
+
input: PasswordMutationInput,
|
|
931
|
+
nativeSubjectId: unknown,
|
|
932
|
+
subject: any,
|
|
933
|
+
authorityCredential: any,
|
|
934
|
+
now: number,
|
|
935
|
+
) {
|
|
936
|
+
if (
|
|
937
|
+
subject === undefined ||
|
|
938
|
+
!mapping.subject.isActiveStatus(subject[mapping.subject.status]) ||
|
|
939
|
+
authorityCredential === undefined ||
|
|
940
|
+
(mapping.authorityCredential.status !== undefined &&
|
|
941
|
+
mapping.authorityCredential.isActiveStatus?.(
|
|
942
|
+
authorityCredential[mapping.authorityCredential.status],
|
|
943
|
+
) !== true)
|
|
944
|
+
)
|
|
945
|
+
return false;
|
|
946
|
+
if (input.credential !== undefined) {
|
|
947
|
+
const identifier = (yield* lockIdentifier(mapping, input.credential.identifier, false))[0];
|
|
948
|
+
|
|
949
|
+
if (
|
|
950
|
+
identifier === undefined ||
|
|
951
|
+
!mapping.identifier.isCurrent(identifier) ||
|
|
952
|
+
!mapping.subjectId.equals(identifier[mapping.identifier.subjectId], nativeSubjectId) ||
|
|
953
|
+
identifier[mapping.identifier.bindingRevision] !== input.credential.identifierBindingRevision
|
|
954
|
+
)
|
|
955
|
+
return false;
|
|
956
|
+
|
|
957
|
+
const credential = (yield* readPasswordCredential(
|
|
958
|
+
mapping,
|
|
959
|
+
input.moduleId,
|
|
960
|
+
nativeSubjectId,
|
|
961
|
+
false,
|
|
962
|
+
))[0];
|
|
963
|
+
|
|
964
|
+
if (credential === undefined) return false;
|
|
965
|
+
|
|
966
|
+
const decoded = yield* mapping.credential.decode({
|
|
967
|
+
moduleId: input.moduleId,
|
|
968
|
+
subject,
|
|
969
|
+
identifier,
|
|
970
|
+
credential,
|
|
971
|
+
});
|
|
972
|
+
|
|
973
|
+
if (decoded.identifierVerifiedAtMillis !== input.credential.identifierVerifiedAtMillis)
|
|
974
|
+
return false;
|
|
975
|
+
}
|
|
976
|
+
const rows = yield* commandExists(mapping, input.moduleId, input.commandId, false);
|
|
977
|
+
const row = rows[0];
|
|
978
|
+
|
|
979
|
+
return (
|
|
980
|
+
rows.length === 1 &&
|
|
981
|
+
row[mapping.command.action] === input.authorization.challenge.action &&
|
|
982
|
+
row[mapping.command.bindingDigest] === input.authorization.challenge.bindingDigest &&
|
|
983
|
+
row[mapping.command.decision] === "changed" &&
|
|
984
|
+
(yield* mapping.decodeInstant(row[mapping.command.retentionUntil])) ===
|
|
985
|
+
now + mapping.commandRetentionMillis
|
|
986
|
+
);
|
|
987
|
+
});
|
|
988
|
+
|
|
989
|
+
const addPasswordIn = Effect.fn("DrizzlePassword.addPasswordIn")(function* (
|
|
990
|
+
mapping: Mapping,
|
|
991
|
+
configuration: PasswordSqlConfiguration,
|
|
992
|
+
input: PasswordMutationInput,
|
|
993
|
+
revisions: {
|
|
994
|
+
readonly credentialId: string;
|
|
995
|
+
readonly credentialRevision: SecurityRevision;
|
|
996
|
+
readonly verifierVersion: SecurityRevision;
|
|
997
|
+
readonly nextSecurityRevision: SecurityRevision;
|
|
998
|
+
},
|
|
999
|
+
commandNow?: number,
|
|
1000
|
+
) {
|
|
1001
|
+
const database = yield* CurrentPasswordSql;
|
|
1002
|
+
|
|
1003
|
+
const { credentialId, credentialRevision, verifierVersion, nextSecurityRevision } = revisions;
|
|
1004
|
+
|
|
1005
|
+
const authority = yield* validateMutationAuthority(mapping, configuration, input, "add-password");
|
|
1006
|
+
|
|
1007
|
+
if (authority === undefined) return false;
|
|
1008
|
+
if ((yield* commandExists(mapping, input.moduleId, input.commandId, true)).length) return false;
|
|
1009
|
+
if (
|
|
1010
|
+
(yield* readPasswordCredential(mapping, input.moduleId, authority.nativeSubjectId, true)).length
|
|
1011
|
+
)
|
|
1012
|
+
return false;
|
|
1013
|
+
|
|
1014
|
+
yield* database.insert(mapping.credential.table).values(
|
|
1015
|
+
mapping.credential.encodeInsert({
|
|
1016
|
+
moduleId: input.moduleId,
|
|
1017
|
+
subjectId: authority.nativeSubjectId,
|
|
1018
|
+
credentialId,
|
|
1019
|
+
credentialRevision,
|
|
1020
|
+
verifierVersion,
|
|
1021
|
+
replacement: input.replacement,
|
|
1022
|
+
}),
|
|
1023
|
+
);
|
|
1024
|
+
yield* database.insert(mapping.authorityCredential.table).values(
|
|
1025
|
+
mapping.authorityCredential.encodeInsert({
|
|
1026
|
+
subjectId: authority.nativeSubjectId,
|
|
1027
|
+
credentialId,
|
|
1028
|
+
revision: credentialRevision,
|
|
1029
|
+
}),
|
|
1030
|
+
);
|
|
1031
|
+
yield* database
|
|
1032
|
+
.update(mapping.subject.table)
|
|
1033
|
+
.set(updateValues([[mapping.subject.securityRevision, nextSecurityRevision]]))
|
|
1034
|
+
.where(
|
|
1035
|
+
and(
|
|
1036
|
+
eq(subjectColumns(mapping).id, authority.nativeSubjectId),
|
|
1037
|
+
eq(subjectColumns(mapping).securityRevision, input.expectedRevision.securityRevision),
|
|
1038
|
+
),
|
|
1039
|
+
);
|
|
1040
|
+
yield* insertCommand(mapping, input, "add-password", commandNow ?? authority.now);
|
|
1041
|
+
|
|
1042
|
+
const inserted = (yield* readPasswordCredential(
|
|
1043
|
+
mapping,
|
|
1044
|
+
input.moduleId,
|
|
1045
|
+
authority.nativeSubjectId,
|
|
1046
|
+
false,
|
|
1047
|
+
))[0];
|
|
1048
|
+
|
|
1049
|
+
const authorityInserted = (yield* database
|
|
1050
|
+
.select()
|
|
1051
|
+
.from(mapping.authorityCredential.table)
|
|
1052
|
+
.where(
|
|
1053
|
+
and(
|
|
1054
|
+
eq(authorityCredentialColumns(mapping).subjectId, authority.nativeSubjectId),
|
|
1055
|
+
eq(authorityCredentialColumns(mapping).credentialId, credentialId),
|
|
1056
|
+
eq(authorityCredentialColumns(mapping).revision, credentialRevision),
|
|
1057
|
+
),
|
|
1058
|
+
)
|
|
1059
|
+
.limit(1))[0];
|
|
1060
|
+
|
|
1061
|
+
const subjectUpdated = (yield* database
|
|
1062
|
+
.select()
|
|
1063
|
+
.from(mapping.subject.table)
|
|
1064
|
+
.where(
|
|
1065
|
+
and(
|
|
1066
|
+
eq(subjectColumns(mapping).id, authority.nativeSubjectId),
|
|
1067
|
+
eq(subjectColumns(mapping).securityRevision, nextSecurityRevision),
|
|
1068
|
+
),
|
|
1069
|
+
)
|
|
1070
|
+
.limit(1))[0];
|
|
1071
|
+
|
|
1072
|
+
if (
|
|
1073
|
+
inserted === undefined ||
|
|
1074
|
+
inserted[mapping.credential.credentialId] !== credentialId ||
|
|
1075
|
+
inserted[mapping.credential.credentialRevision] !== credentialRevision ||
|
|
1076
|
+
inserted[mapping.credential.verifierVersion] !== verifierVersion ||
|
|
1077
|
+
inserted[mapping.credential.verifier] !== Redacted.value(input.replacement.verifier) ||
|
|
1078
|
+
inserted[mapping.credential.normalization] !== input.replacement.normalization ||
|
|
1079
|
+
authorityInserted === undefined ||
|
|
1080
|
+
subjectUpdated === undefined ||
|
|
1081
|
+
!(yield* mutationPostconditions(
|
|
1082
|
+
mapping,
|
|
1083
|
+
input,
|
|
1084
|
+
authority.nativeSubjectId,
|
|
1085
|
+
subjectUpdated,
|
|
1086
|
+
authorityInserted,
|
|
1087
|
+
commandNow ?? authority.now,
|
|
1088
|
+
))
|
|
1089
|
+
)
|
|
1090
|
+
return yield* unavailable();
|
|
1091
|
+
|
|
1092
|
+
return true;
|
|
1093
|
+
});
|
|
1094
|
+
|
|
1095
|
+
export const makeSqlPasswordPersistence = Effect.fn("makeSqlPasswordPersistence")(function* (
|
|
1096
|
+
database: Database,
|
|
1097
|
+
mapping: Mapping,
|
|
1098
|
+
configuration: PasswordSqlConfiguration,
|
|
1099
|
+
): Effect.fn.Return<PasswordPersistence["Service"], never, LifecycleHooks> {
|
|
1100
|
+
const hooks = yield* LifecycleHooks;
|
|
1101
|
+
|
|
1102
|
+
return PasswordPersistence.of({
|
|
1103
|
+
admitAttempt: (input, prepare) =>
|
|
1104
|
+
Effect.gen(function* () {
|
|
1105
|
+
const attemptId = yield* allocate(
|
|
1106
|
+
configuration.mode,
|
|
1107
|
+
mapping.allocateAttemptId,
|
|
1108
|
+
mapping.allocateAttemptIdSync,
|
|
1109
|
+
);
|
|
1110
|
+
|
|
1111
|
+
return yield* owned(
|
|
1112
|
+
database,
|
|
1113
|
+
mapping,
|
|
1114
|
+
configuration,
|
|
1115
|
+
Effect.gen(function* () {
|
|
1116
|
+
const transaction = yield* CurrentPasswordSql;
|
|
1117
|
+
const journal = yield* CurrentCommitJournal;
|
|
1118
|
+
|
|
1119
|
+
const resolved = yield* resolveCredential(
|
|
1120
|
+
mapping,
|
|
1121
|
+
input.moduleId,
|
|
1122
|
+
input.identifier,
|
|
1123
|
+
input.subjectId,
|
|
1124
|
+
configuration.locking,
|
|
1125
|
+
);
|
|
1126
|
+
|
|
1127
|
+
const keys = mapping.scopeKeys({
|
|
1128
|
+
moduleId: input.moduleId,
|
|
1129
|
+
action: input.action,
|
|
1130
|
+
identifier: input.identifier,
|
|
1131
|
+
...(resolved === undefined
|
|
1132
|
+
? {}
|
|
1133
|
+
: { subjectId: resolved.snapshot?.revision.subjectId }),
|
|
1134
|
+
});
|
|
1135
|
+
|
|
1136
|
+
const scopes = scopeEntries(keys, input.policy);
|
|
1137
|
+
const admitted: ScopeEntry[] = [];
|
|
1138
|
+
|
|
1139
|
+
yield* lockScope(mapping, configuration, input.moduleId, input.action, scopes[0]!);
|
|
1140
|
+
let currentNow = yield* nowMillis;
|
|
1141
|
+
|
|
1142
|
+
if (
|
|
1143
|
+
yield* scopeAdmits(
|
|
1144
|
+
mapping,
|
|
1145
|
+
input.moduleId,
|
|
1146
|
+
input.action,
|
|
1147
|
+
scopes[0]!,
|
|
1148
|
+
input.policy,
|
|
1149
|
+
input.identifier,
|
|
1150
|
+
resolved?.nativeSubjectId,
|
|
1151
|
+
currentNow,
|
|
1152
|
+
)
|
|
1153
|
+
)
|
|
1154
|
+
admitted.push(scopes[0]!);
|
|
1155
|
+
if (admitted.length === 1) {
|
|
1156
|
+
for (const entry of scopes.slice(1)) {
|
|
1157
|
+
yield* lockScope(mapping, configuration, input.moduleId, input.action, entry);
|
|
1158
|
+
currentNow = yield* nowMillis;
|
|
1159
|
+
if (
|
|
1160
|
+
yield* scopeAdmits(
|
|
1161
|
+
mapping,
|
|
1162
|
+
input.moduleId,
|
|
1163
|
+
input.action,
|
|
1164
|
+
entry,
|
|
1165
|
+
input.policy,
|
|
1166
|
+
input.identifier,
|
|
1167
|
+
resolved?.nativeSubjectId,
|
|
1168
|
+
currentNow,
|
|
1169
|
+
)
|
|
1170
|
+
)
|
|
1171
|
+
admitted.push(entry);
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
const now = yield* nowMillis;
|
|
1175
|
+
|
|
1176
|
+
for (const entry of admitted)
|
|
1177
|
+
yield* insertCharge(mapping, input.moduleId, input.action, entry, attemptId, now);
|
|
1178
|
+
if (admitted.length !== scopes.length)
|
|
1179
|
+
return prepare({ _tag: "Denied" as const }, journal);
|
|
1180
|
+
const snapshot = resolved?.snapshot;
|
|
1181
|
+
const deadline = now + input.policy.attemptLifetimeMillis;
|
|
1182
|
+
|
|
1183
|
+
const retentionUntil = Math.max(
|
|
1184
|
+
deadline,
|
|
1185
|
+
...scopes.map((entry) => now + entry.windowMillis),
|
|
1186
|
+
);
|
|
1187
|
+
|
|
1188
|
+
yield* transaction.insert(mapping.attempt.table).values(
|
|
1189
|
+
mapping.attempt.encodeInsert(
|
|
1190
|
+
{
|
|
1191
|
+
moduleId: input.moduleId,
|
|
1192
|
+
action: input.action,
|
|
1193
|
+
attemptId,
|
|
1194
|
+
identifier: input.identifier,
|
|
1195
|
+
...(snapshot === undefined
|
|
1196
|
+
? {}
|
|
1197
|
+
: {
|
|
1198
|
+
subjectId: snapshot.revision.subjectId,
|
|
1199
|
+
credentialId: snapshot.credentialId,
|
|
1200
|
+
securityRevision: snapshot.revision.securityRevision,
|
|
1201
|
+
credentialRevision: snapshot.credentialRevision,
|
|
1202
|
+
verifierVersion: snapshot.verifierVersion,
|
|
1203
|
+
identifierBindingRevision: snapshot.identifierBindingRevision,
|
|
1204
|
+
}),
|
|
1205
|
+
admittedAtMillis: now,
|
|
1206
|
+
deadlineMillis: deadline,
|
|
1207
|
+
retentionUntilMillis: retentionUntil,
|
|
1208
|
+
},
|
|
1209
|
+
{
|
|
1210
|
+
...(resolved?.nativeSubjectId === undefined
|
|
1211
|
+
? {}
|
|
1212
|
+
: { nativeSubjectId: resolved.nativeSubjectId }),
|
|
1213
|
+
state: "pending",
|
|
1214
|
+
},
|
|
1215
|
+
),
|
|
1216
|
+
);
|
|
1217
|
+
|
|
1218
|
+
return prepare(
|
|
1219
|
+
{
|
|
1220
|
+
_tag: "Admitted" as const,
|
|
1221
|
+
attemptId,
|
|
1222
|
+
...(snapshot === undefined ? {} : { credential: snapshot }),
|
|
1223
|
+
},
|
|
1224
|
+
journal,
|
|
1225
|
+
);
|
|
1226
|
+
}),
|
|
1227
|
+
);
|
|
1228
|
+
}).pipe(
|
|
1229
|
+
Effect.provideService(CurrentPasswordSql, database),
|
|
1230
|
+
Effect.provideService(LifecycleHooks, hooks),
|
|
1231
|
+
translateFailure,
|
|
1232
|
+
),
|
|
1233
|
+
settleAttempt: (uncaptured, prepare) =>
|
|
1234
|
+
Effect.gen(function* () {
|
|
1235
|
+
const captured =
|
|
1236
|
+
uncaptured.captured === undefined
|
|
1237
|
+
? undefined
|
|
1238
|
+
: yield* snapshotPasswordCredential(uncaptured.captured);
|
|
1239
|
+
|
|
1240
|
+
const input = { ...uncaptured, ...(captured === undefined ? {} : { captured }) };
|
|
1241
|
+
|
|
1242
|
+
return yield* owned(
|
|
1243
|
+
database,
|
|
1244
|
+
mapping,
|
|
1245
|
+
configuration,
|
|
1246
|
+
Effect.gen(function* () {
|
|
1247
|
+
const transaction = yield* CurrentPasswordSql;
|
|
1248
|
+
const journal = yield* CurrentCommitJournal;
|
|
1249
|
+
|
|
1250
|
+
const c = attemptColumns(mapping);
|
|
1251
|
+
|
|
1252
|
+
const discovered = yield* selectRows(
|
|
1253
|
+
transaction
|
|
1254
|
+
.select()
|
|
1255
|
+
.from(mapping.attempt.table)
|
|
1256
|
+
.where(and(eq(c.moduleId, input.moduleId), eq(c.attemptId, input.attemptId)))
|
|
1257
|
+
.limit(1),
|
|
1258
|
+
false,
|
|
1259
|
+
);
|
|
1260
|
+
|
|
1261
|
+
let row = discovered[0];
|
|
1262
|
+
|
|
1263
|
+
if (row === undefined || row[mapping.attempt.state] !== "pending")
|
|
1264
|
+
return prepare("rejected", journal);
|
|
1265
|
+
let decision: PasswordAttemptDecision = "rejected";
|
|
1266
|
+
let current: any;
|
|
1267
|
+
let attemptMatches = false;
|
|
1268
|
+
|
|
1269
|
+
if (input.outcome === "verified" && input.captured !== undefined) {
|
|
1270
|
+
current = yield* resolveCredential(
|
|
1271
|
+
mapping,
|
|
1272
|
+
input.moduleId,
|
|
1273
|
+
input.captured.identifier,
|
|
1274
|
+
input.captured.revision.subjectId,
|
|
1275
|
+
configuration.locking,
|
|
1276
|
+
);
|
|
1277
|
+
attemptMatches =
|
|
1278
|
+
input.captured.moduleId === input.moduleId &&
|
|
1279
|
+
row[mapping.attempt.identifierNamespace] === input.captured.identifier.namespace &&
|
|
1280
|
+
row[mapping.attempt.identifierValue] === input.captured.identifier.value &&
|
|
1281
|
+
mapping.subjectId.equals(
|
|
1282
|
+
row[mapping.attempt.subjectId],
|
|
1283
|
+
current?.nativeSubjectId,
|
|
1284
|
+
) &&
|
|
1285
|
+
row[mapping.attempt.credentialId] === input.captured.credentialId &&
|
|
1286
|
+
row[mapping.attempt.securityRevision] ===
|
|
1287
|
+
input.captured.revision.securityRevision &&
|
|
1288
|
+
row[mapping.attempt.credentialRevision] === input.captured.credentialRevision &&
|
|
1289
|
+
row[mapping.attempt.verifierVersion] === input.captured.verifierVersion &&
|
|
1290
|
+
row[mapping.attempt.identifierBindingRevision] ===
|
|
1291
|
+
input.captured.identifierBindingRevision;
|
|
1292
|
+
}
|
|
1293
|
+
row = (yield* selectRows(
|
|
1294
|
+
transaction
|
|
1295
|
+
.select()
|
|
1296
|
+
.from(mapping.attempt.table)
|
|
1297
|
+
.where(and(eq(c.moduleId, input.moduleId), eq(c.attemptId, input.attemptId)))
|
|
1298
|
+
.limit(1),
|
|
1299
|
+
configuration.locking,
|
|
1300
|
+
))[0];
|
|
1301
|
+
if (row === undefined || row[mapping.attempt.state] !== "pending")
|
|
1302
|
+
return prepare("rejected", journal);
|
|
1303
|
+
const now = yield* nowMillis;
|
|
1304
|
+
const deadline = yield* mapping.decodeInstant(row[mapping.attempt.deadline]);
|
|
1305
|
+
|
|
1306
|
+
if (
|
|
1307
|
+
attemptMatches &&
|
|
1308
|
+
current?.snapshot !== undefined &&
|
|
1309
|
+
input.captured !== undefined &&
|
|
1310
|
+
deadline > now &&
|
|
1311
|
+
sameCredentialSnapshot(current.snapshot, input.captured)
|
|
1312
|
+
)
|
|
1313
|
+
decision = "verified";
|
|
1314
|
+
const prepared = prepare(decision, journal);
|
|
1315
|
+
|
|
1316
|
+
yield* transaction
|
|
1317
|
+
.update(mapping.attempt.table)
|
|
1318
|
+
.set(updateValues([[mapping.attempt.state, decision]]))
|
|
1319
|
+
.where(
|
|
1320
|
+
and(
|
|
1321
|
+
eq(c.moduleId, input.moduleId),
|
|
1322
|
+
eq(c.attemptId, input.attemptId),
|
|
1323
|
+
eq(c.state, "pending"),
|
|
1324
|
+
),
|
|
1325
|
+
);
|
|
1326
|
+
if (
|
|
1327
|
+
decision === "verified" &&
|
|
1328
|
+
input.rehash !== undefined &&
|
|
1329
|
+
current?.snapshot !== undefined
|
|
1330
|
+
) {
|
|
1331
|
+
const cc = credentialColumns(mapping);
|
|
1332
|
+
|
|
1333
|
+
const nextVersion = yield* allocate(
|
|
1334
|
+
configuration.mode,
|
|
1335
|
+
mapping.allocateRevision,
|
|
1336
|
+
mapping.allocateRevisionSync,
|
|
1337
|
+
);
|
|
1338
|
+
|
|
1339
|
+
yield* transaction
|
|
1340
|
+
.update(mapping.credential.table)
|
|
1341
|
+
.set(mapping.credential.encodeVerifier(input.rehash.nextVerifier, nextVersion))
|
|
1342
|
+
.where(
|
|
1343
|
+
and(
|
|
1344
|
+
eq(cc.moduleId, input.moduleId),
|
|
1345
|
+
eq(cc.subjectId, current.nativeSubjectId),
|
|
1346
|
+
eq(cc.credentialId, current.snapshot.credentialId),
|
|
1347
|
+
eq(cc.credentialRevision, current.snapshot.credentialRevision),
|
|
1348
|
+
eq(cc.verifierVersion, input.rehash.expectedVersion),
|
|
1349
|
+
eq(cc.verifier, Redacted.value(input.rehash.expectedVerifier)),
|
|
1350
|
+
),
|
|
1351
|
+
);
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1354
|
+
return prepared;
|
|
1355
|
+
}),
|
|
1356
|
+
);
|
|
1357
|
+
}).pipe(
|
|
1358
|
+
Effect.provideService(CurrentPasswordSql, database),
|
|
1359
|
+
Effect.provideService(LifecycleHooks, hooks),
|
|
1360
|
+
translateFailure,
|
|
1361
|
+
),
|
|
1362
|
+
readForSubject: (input) =>
|
|
1363
|
+
safeRead(
|
|
1364
|
+
database,
|
|
1365
|
+
configuration,
|
|
1366
|
+
Effect.gen(function* () {
|
|
1367
|
+
const transaction = yield* CurrentPasswordSql;
|
|
1368
|
+
|
|
1369
|
+
const locked = yield* lockSubject(mapping, input.subjectId, false);
|
|
1370
|
+
|
|
1371
|
+
if (
|
|
1372
|
+
locked.row === undefined ||
|
|
1373
|
+
!mapping.subject.isActiveStatus(locked.row[mapping.subject.status])
|
|
1374
|
+
)
|
|
1375
|
+
return Option.none();
|
|
1376
|
+
|
|
1377
|
+
const credential = (yield* readPasswordCredential(
|
|
1378
|
+
mapping,
|
|
1379
|
+
input.moduleId,
|
|
1380
|
+
locked.nativeSubjectId,
|
|
1381
|
+
false,
|
|
1382
|
+
))[0];
|
|
1383
|
+
|
|
1384
|
+
if (credential === undefined) return Option.none();
|
|
1385
|
+
const ic = identifierColumns(mapping);
|
|
1386
|
+
|
|
1387
|
+
const identifiers = yield* transaction
|
|
1388
|
+
.select()
|
|
1389
|
+
.from(mapping.identifier.table)
|
|
1390
|
+
.where(eq(ic.subjectId, locked.nativeSubjectId));
|
|
1391
|
+
|
|
1392
|
+
const identifier = identifiers.find((row: any) => mapping.identifier.isCurrent(row));
|
|
1393
|
+
|
|
1394
|
+
if (identifier === undefined) return Option.none();
|
|
1395
|
+
|
|
1396
|
+
const snapshot = yield* mapping.credential
|
|
1397
|
+
.decode({
|
|
1398
|
+
moduleId: input.moduleId,
|
|
1399
|
+
subject: locked.row,
|
|
1400
|
+
identifier,
|
|
1401
|
+
credential,
|
|
1402
|
+
})
|
|
1403
|
+
.pipe(Effect.flatMap(snapshotPasswordCredential));
|
|
1404
|
+
|
|
1405
|
+
return Option.some(snapshot);
|
|
1406
|
+
}),
|
|
1407
|
+
).pipe(
|
|
1408
|
+
Effect.provideService(CurrentPasswordSql, database),
|
|
1409
|
+
Effect.provideService(LifecycleHooks, hooks),
|
|
1410
|
+
translateFailure,
|
|
1411
|
+
),
|
|
1412
|
+
recoveryTarget: (input) =>
|
|
1413
|
+
safeRead(
|
|
1414
|
+
database,
|
|
1415
|
+
configuration,
|
|
1416
|
+
Effect.gen(function* () {
|
|
1417
|
+
const resolved = yield* resolveCredential(
|
|
1418
|
+
mapping,
|
|
1419
|
+
input.moduleId,
|
|
1420
|
+
input.identifier,
|
|
1421
|
+
undefined,
|
|
1422
|
+
false,
|
|
1423
|
+
);
|
|
1424
|
+
|
|
1425
|
+
return resolved?.snapshot === undefined ||
|
|
1426
|
+
resolved.snapshot.identifierVerifiedAtMillis === undefined
|
|
1427
|
+
? Option.none()
|
|
1428
|
+
: Option.some(resolved.snapshot);
|
|
1429
|
+
}),
|
|
1430
|
+
).pipe(
|
|
1431
|
+
Effect.provideService(CurrentPasswordSql, database),
|
|
1432
|
+
Effect.provideService(LifecycleHooks, hooks),
|
|
1433
|
+
translateFailure,
|
|
1434
|
+
),
|
|
1435
|
+
addIfAbsent: (uncaptured, prepare) =>
|
|
1436
|
+
Effect.gen(function* () {
|
|
1437
|
+
const input = yield* snapshotMutationInput(uncaptured);
|
|
1438
|
+
|
|
1439
|
+
const credentialId = yield* allocate(
|
|
1440
|
+
configuration.mode,
|
|
1441
|
+
mapping.allocateCredentialId,
|
|
1442
|
+
mapping.allocateCredentialIdSync,
|
|
1443
|
+
);
|
|
1444
|
+
|
|
1445
|
+
const credentialRevision = yield* allocate(
|
|
1446
|
+
configuration.mode,
|
|
1447
|
+
mapping.allocateRevision,
|
|
1448
|
+
mapping.allocateRevisionSync,
|
|
1449
|
+
);
|
|
1450
|
+
|
|
1451
|
+
const verifierVersion = yield* allocate(
|
|
1452
|
+
configuration.mode,
|
|
1453
|
+
mapping.allocateRevision,
|
|
1454
|
+
mapping.allocateRevisionSync,
|
|
1455
|
+
);
|
|
1456
|
+
|
|
1457
|
+
const nextSecurityRevision = yield* allocateNextSecurityRevision(
|
|
1458
|
+
mapping,
|
|
1459
|
+
configuration.mode,
|
|
1460
|
+
input.expectedRevision.securityRevision,
|
|
1461
|
+
);
|
|
1462
|
+
|
|
1463
|
+
if (nextSecurityRevision === input.expectedRevision.securityRevision)
|
|
1464
|
+
return yield* unavailable();
|
|
1465
|
+
|
|
1466
|
+
return yield* owned(
|
|
1467
|
+
database,
|
|
1468
|
+
mapping,
|
|
1469
|
+
configuration,
|
|
1470
|
+
Effect.gen(function* () {
|
|
1471
|
+
const journal = yield* CurrentCommitJournal;
|
|
1472
|
+
|
|
1473
|
+
const changed = yield* addPasswordIn(mapping, configuration, input, {
|
|
1474
|
+
credentialId,
|
|
1475
|
+
credentialRevision,
|
|
1476
|
+
verifierVersion,
|
|
1477
|
+
nextSecurityRevision,
|
|
1478
|
+
});
|
|
1479
|
+
|
|
1480
|
+
return prepare(changed ? "changed" : "rejected", journal);
|
|
1481
|
+
}),
|
|
1482
|
+
);
|
|
1483
|
+
}).pipe(
|
|
1484
|
+
Effect.provideService(CurrentPasswordSql, database),
|
|
1485
|
+
Effect.provideService(LifecycleHooks, hooks),
|
|
1486
|
+
translateFailure,
|
|
1487
|
+
),
|
|
1488
|
+
replaceIfCurrent: (uncaptured, prepare) =>
|
|
1489
|
+
Effect.gen(function* () {
|
|
1490
|
+
const input = yield* snapshotMutationInput(uncaptured);
|
|
1491
|
+
|
|
1492
|
+
const credentialRevision = yield* allocate(
|
|
1493
|
+
configuration.mode,
|
|
1494
|
+
mapping.allocateRevision,
|
|
1495
|
+
mapping.allocateRevisionSync,
|
|
1496
|
+
);
|
|
1497
|
+
|
|
1498
|
+
const verifierVersion = yield* allocate(
|
|
1499
|
+
configuration.mode,
|
|
1500
|
+
mapping.allocateRevision,
|
|
1501
|
+
mapping.allocateRevisionSync,
|
|
1502
|
+
);
|
|
1503
|
+
|
|
1504
|
+
const nextSecurityRevision = yield* allocateNextSecurityRevision(
|
|
1505
|
+
mapping,
|
|
1506
|
+
configuration.mode,
|
|
1507
|
+
input.expectedRevision.securityRevision,
|
|
1508
|
+
);
|
|
1509
|
+
|
|
1510
|
+
if (
|
|
1511
|
+
nextSecurityRevision === input.expectedRevision.securityRevision ||
|
|
1512
|
+
(input.credential !== undefined &&
|
|
1513
|
+
credentialRevision === input.credential.credentialRevision)
|
|
1514
|
+
)
|
|
1515
|
+
return yield* unavailable();
|
|
1516
|
+
|
|
1517
|
+
return yield* owned(
|
|
1518
|
+
database,
|
|
1519
|
+
mapping,
|
|
1520
|
+
configuration,
|
|
1521
|
+
Effect.gen(function* () {
|
|
1522
|
+
return yield* replaceIn(
|
|
1523
|
+
mapping,
|
|
1524
|
+
configuration,
|
|
1525
|
+
input,
|
|
1526
|
+
"change-password",
|
|
1527
|
+
{ credentialRevision, verifierVersion, nextSecurityRevision },
|
|
1528
|
+
prepare,
|
|
1529
|
+
);
|
|
1530
|
+
}),
|
|
1531
|
+
);
|
|
1532
|
+
}).pipe(
|
|
1533
|
+
Effect.provideService(CurrentPasswordSql, database),
|
|
1534
|
+
Effect.provideService(LifecycleHooks, hooks),
|
|
1535
|
+
translateFailure,
|
|
1536
|
+
),
|
|
1537
|
+
checkReset: (input) =>
|
|
1538
|
+
(configuration.proof === undefined
|
|
1539
|
+
? Effect.fail(unavailable())
|
|
1540
|
+
: Effect.gen(function* () {
|
|
1541
|
+
if (
|
|
1542
|
+
input.moduleId.length <= "/reset".length ||
|
|
1543
|
+
!input.moduleId.endsWith("/reset") ||
|
|
1544
|
+
input.purpose !== "password-reset" ||
|
|
1545
|
+
input.binding._tag !== "Subject"
|
|
1546
|
+
)
|
|
1547
|
+
return false;
|
|
1548
|
+
const binding = input.binding;
|
|
1549
|
+
const passwordModuleId = input.moduleId.slice(0, -"/reset".length);
|
|
1550
|
+
|
|
1551
|
+
const current = yield* safeRead(
|
|
1552
|
+
database,
|
|
1553
|
+
configuration,
|
|
1554
|
+
Effect.gen(function* () {
|
|
1555
|
+
const resolved = yield* resolveCredential(
|
|
1556
|
+
mapping,
|
|
1557
|
+
passwordModuleId,
|
|
1558
|
+
binding.identifier,
|
|
1559
|
+
binding.revision.subjectId,
|
|
1560
|
+
false,
|
|
1561
|
+
);
|
|
1562
|
+
|
|
1563
|
+
return (
|
|
1564
|
+
resolved?.snapshot !== undefined &&
|
|
1565
|
+
resolved.snapshot.revision.securityRevision ===
|
|
1566
|
+
binding.revision.securityRevision &&
|
|
1567
|
+
binding.revision.credentials.every((item) =>
|
|
1568
|
+
resolved.snapshot!.revision.credentials.some(
|
|
1569
|
+
(actual) =>
|
|
1570
|
+
actual.credentialId === item.credentialId &&
|
|
1571
|
+
actual.revision === item.revision,
|
|
1572
|
+
),
|
|
1573
|
+
)
|
|
1574
|
+
);
|
|
1575
|
+
}),
|
|
1576
|
+
);
|
|
1577
|
+
|
|
1578
|
+
return current ? yield* probeProofCompletion(configuration, input) : false;
|
|
1579
|
+
})
|
|
1580
|
+
).pipe(
|
|
1581
|
+
Effect.provideService(CurrentPasswordSql, database),
|
|
1582
|
+
Effect.provideService(LifecycleHooks, hooks),
|
|
1583
|
+
translateFailure,
|
|
1584
|
+
),
|
|
1585
|
+
resetWithProof: (uncaptured, prepare) =>
|
|
1586
|
+
(configuration.proof === undefined
|
|
1587
|
+
? Effect.fail(unavailable())
|
|
1588
|
+
: Effect.gen(function* () {
|
|
1589
|
+
const input = Object.freeze({
|
|
1590
|
+
...(yield* snapshotMutationInput(uncaptured)),
|
|
1591
|
+
completion: uncaptured.completion,
|
|
1592
|
+
});
|
|
1593
|
+
|
|
1594
|
+
const credentialRevision = yield* allocate(
|
|
1595
|
+
configuration.mode,
|
|
1596
|
+
mapping.allocateRevision,
|
|
1597
|
+
mapping.allocateRevisionSync,
|
|
1598
|
+
);
|
|
1599
|
+
|
|
1600
|
+
const verifierVersion = yield* allocate(
|
|
1601
|
+
configuration.mode,
|
|
1602
|
+
mapping.allocateRevision,
|
|
1603
|
+
mapping.allocateRevisionSync,
|
|
1604
|
+
);
|
|
1605
|
+
|
|
1606
|
+
const nextSecurityRevision = yield* allocateNextSecurityRevision(
|
|
1607
|
+
mapping,
|
|
1608
|
+
configuration.mode,
|
|
1609
|
+
input.expectedRevision.securityRevision,
|
|
1610
|
+
);
|
|
1611
|
+
|
|
1612
|
+
if (
|
|
1613
|
+
nextSecurityRevision === input.expectedRevision.securityRevision ||
|
|
1614
|
+
(input.credential !== undefined &&
|
|
1615
|
+
credentialRevision === input.credential.credentialRevision)
|
|
1616
|
+
)
|
|
1617
|
+
return yield* unavailable();
|
|
1618
|
+
|
|
1619
|
+
return yield* owned(
|
|
1620
|
+
database,
|
|
1621
|
+
mapping,
|
|
1622
|
+
configuration,
|
|
1623
|
+
Effect.gen(function* () {
|
|
1624
|
+
const journal = yield* CurrentCommitJournal;
|
|
1625
|
+
|
|
1626
|
+
if (!proofCompletionMatchesPassword(input)) return prepare("rejected", journal);
|
|
1627
|
+
|
|
1628
|
+
const authority = yield* validateMutationAuthority(
|
|
1629
|
+
mapping,
|
|
1630
|
+
configuration,
|
|
1631
|
+
input,
|
|
1632
|
+
"reset-password",
|
|
1633
|
+
);
|
|
1634
|
+
|
|
1635
|
+
if (authority === undefined) return prepare("rejected", journal);
|
|
1636
|
+
if ((yield* commandExists(mapping, input.moduleId, input.commandId, true)).length)
|
|
1637
|
+
return prepare("rejected", journal);
|
|
1638
|
+
|
|
1639
|
+
const current = yield* currentExpectedCredential(
|
|
1640
|
+
mapping,
|
|
1641
|
+
input,
|
|
1642
|
+
authority.nativeSubjectId,
|
|
1643
|
+
);
|
|
1644
|
+
|
|
1645
|
+
if (!current) return prepare("rejected", journal);
|
|
1646
|
+
let passwordReceipt: PreparedCommit<any> | undefined;
|
|
1647
|
+
|
|
1648
|
+
yield* completeProofPlanIn(
|
|
1649
|
+
configuration.proof!.mapping,
|
|
1650
|
+
configuration.proof!.configuration,
|
|
1651
|
+
input.completion,
|
|
1652
|
+
Effect.gen(function* () {
|
|
1653
|
+
return yield* writeReplacement(
|
|
1654
|
+
mapping,
|
|
1655
|
+
input,
|
|
1656
|
+
authority.nativeSubjectId,
|
|
1657
|
+
{ credentialRevision, verifierVersion, nextSecurityRevision },
|
|
1658
|
+
authority.now,
|
|
1659
|
+
);
|
|
1660
|
+
}),
|
|
1661
|
+
(decision) => {
|
|
1662
|
+
passwordReceipt = prepare(
|
|
1663
|
+
decision === "completed" ? "changed" : "rejected",
|
|
1664
|
+
journal,
|
|
1665
|
+
);
|
|
1666
|
+
|
|
1667
|
+
return decision;
|
|
1668
|
+
},
|
|
1669
|
+
);
|
|
1670
|
+
|
|
1671
|
+
return passwordReceipt ?? prepare("rejected", journal);
|
|
1672
|
+
}),
|
|
1673
|
+
);
|
|
1674
|
+
})
|
|
1675
|
+
).pipe(
|
|
1676
|
+
Effect.provideService(CurrentPasswordSql, database),
|
|
1677
|
+
Effect.provideService(LifecycleHooks, hooks),
|
|
1678
|
+
translateFailure,
|
|
1679
|
+
),
|
|
1680
|
+
cleanupAttempts: (input, prepare) =>
|
|
1681
|
+
owned(
|
|
1682
|
+
database,
|
|
1683
|
+
mapping,
|
|
1684
|
+
configuration,
|
|
1685
|
+
Effect.gen(function* () {
|
|
1686
|
+
const transaction = yield* CurrentPasswordSql;
|
|
1687
|
+
const journal = yield* CurrentCommitJournal;
|
|
1688
|
+
|
|
1689
|
+
const now = yield* nowMillis;
|
|
1690
|
+
const nativeNow = mapping.encodeInstant(now);
|
|
1691
|
+
let remaining = input.limit;
|
|
1692
|
+
let hasMore = false;
|
|
1693
|
+
const a = attemptColumns(mapping);
|
|
1694
|
+
const c = chargeColumns(mapping);
|
|
1695
|
+
|
|
1696
|
+
const attempts = yield* selectRows(
|
|
1697
|
+
transaction
|
|
1698
|
+
.select({ attemptId: a.attemptId })
|
|
1699
|
+
.from(mapping.attempt.table)
|
|
1700
|
+
.where(and(eq(a.moduleId, input.moduleId), lte(a.retentionUntil, nativeNow)))
|
|
1701
|
+
.limit(remaining + 1),
|
|
1702
|
+
false,
|
|
1703
|
+
);
|
|
1704
|
+
|
|
1705
|
+
if (attempts.length > remaining) hasMore = true;
|
|
1706
|
+
const attemptCandidates = attempts.slice(0, remaining);
|
|
1707
|
+
|
|
1708
|
+
remaining -= attemptCandidates.length;
|
|
1709
|
+
|
|
1710
|
+
const charges = yield* selectRows(
|
|
1711
|
+
transaction
|
|
1712
|
+
.select({
|
|
1713
|
+
action: c.action,
|
|
1714
|
+
scopeKind: c.scopeKind,
|
|
1715
|
+
scopeKey: c.scopeKey,
|
|
1716
|
+
attemptId: c.attemptId,
|
|
1717
|
+
})
|
|
1718
|
+
.from(mapping.charge.table)
|
|
1719
|
+
.where(and(eq(c.moduleId, input.moduleId), lte(c.retentionUntil, nativeNow)))
|
|
1720
|
+
.limit(remaining + 1),
|
|
1721
|
+
false,
|
|
1722
|
+
);
|
|
1723
|
+
|
|
1724
|
+
if (charges.length > remaining) hasMore = true;
|
|
1725
|
+
const chargeCandidates = charges.slice(0, remaining);
|
|
1726
|
+
|
|
1727
|
+
remaining -= chargeCandidates.length;
|
|
1728
|
+
const sc = scopeColumns(mapping);
|
|
1729
|
+
|
|
1730
|
+
const scopes = yield* selectRows(
|
|
1731
|
+
transaction
|
|
1732
|
+
.select({ action: sc.action, scopeKind: sc.scopeKind, scopeKey: sc.scopeKey })
|
|
1733
|
+
.from(mapping.rateScope.table)
|
|
1734
|
+
.where(
|
|
1735
|
+
and(
|
|
1736
|
+
eq(sc.moduleId, input.moduleId),
|
|
1737
|
+
notExists(
|
|
1738
|
+
transaction
|
|
1739
|
+
.select({ one: sql`1` })
|
|
1740
|
+
.from(mapping.charge.table)
|
|
1741
|
+
.where(
|
|
1742
|
+
and(
|
|
1743
|
+
eq(c.moduleId, sc.moduleId),
|
|
1744
|
+
eq(c.action, sc.action),
|
|
1745
|
+
eq(c.scopeKind, sc.scopeKind),
|
|
1746
|
+
eq(c.scopeKey, sc.scopeKey),
|
|
1747
|
+
),
|
|
1748
|
+
),
|
|
1749
|
+
),
|
|
1750
|
+
),
|
|
1751
|
+
)
|
|
1752
|
+
.limit(remaining + 1),
|
|
1753
|
+
remaining === 0 ? false : configuration.locking,
|
|
1754
|
+
);
|
|
1755
|
+
|
|
1756
|
+
if (scopes.length > remaining) hasMore = true;
|
|
1757
|
+
const selectedScopes = scopes.slice(0, remaining);
|
|
1758
|
+
|
|
1759
|
+
remaining -= selectedScopes.length;
|
|
1760
|
+
const selectedCharges: typeof chargeCandidates = [];
|
|
1761
|
+
|
|
1762
|
+
for (const candidate of chargeCandidates) {
|
|
1763
|
+
const locked = yield* selectRows(
|
|
1764
|
+
transaction
|
|
1765
|
+
.select({
|
|
1766
|
+
action: c.action,
|
|
1767
|
+
scopeKind: c.scopeKind,
|
|
1768
|
+
scopeKey: c.scopeKey,
|
|
1769
|
+
attemptId: c.attemptId,
|
|
1770
|
+
})
|
|
1771
|
+
.from(mapping.charge.table)
|
|
1772
|
+
.where(
|
|
1773
|
+
and(
|
|
1774
|
+
eq(c.moduleId, input.moduleId),
|
|
1775
|
+
eq(c.action, candidate.action),
|
|
1776
|
+
eq(c.scopeKind, candidate.scopeKind),
|
|
1777
|
+
eq(c.scopeKey, candidate.scopeKey),
|
|
1778
|
+
eq(c.attemptId, candidate.attemptId),
|
|
1779
|
+
lte(c.retentionUntil, nativeNow),
|
|
1780
|
+
),
|
|
1781
|
+
)
|
|
1782
|
+
.limit(1),
|
|
1783
|
+
configuration.locking,
|
|
1784
|
+
);
|
|
1785
|
+
|
|
1786
|
+
if (locked[0] !== undefined) selectedCharges.push(locked[0] as any);
|
|
1787
|
+
}
|
|
1788
|
+
const selectedAttempts: typeof attemptCandidates = [];
|
|
1789
|
+
|
|
1790
|
+
for (const candidate of attemptCandidates) {
|
|
1791
|
+
const locked = yield* selectRows(
|
|
1792
|
+
transaction
|
|
1793
|
+
.select({ attemptId: a.attemptId })
|
|
1794
|
+
.from(mapping.attempt.table)
|
|
1795
|
+
.where(
|
|
1796
|
+
and(
|
|
1797
|
+
eq(a.moduleId, input.moduleId),
|
|
1798
|
+
eq(a.attemptId, candidate.attemptId),
|
|
1799
|
+
lte(a.retentionUntil, nativeNow),
|
|
1800
|
+
),
|
|
1801
|
+
)
|
|
1802
|
+
.limit(1),
|
|
1803
|
+
configuration.locking,
|
|
1804
|
+
);
|
|
1805
|
+
|
|
1806
|
+
if (locked[0] !== undefined) selectedAttempts.push(locked[0] as any);
|
|
1807
|
+
}
|
|
1808
|
+
|
|
1809
|
+
const prepared = prepare(
|
|
1810
|
+
{
|
|
1811
|
+
removed: selectedAttempts.length + selectedCharges.length + selectedScopes.length,
|
|
1812
|
+
hasMore,
|
|
1813
|
+
},
|
|
1814
|
+
journal,
|
|
1815
|
+
);
|
|
1816
|
+
|
|
1817
|
+
for (const row of selectedCharges)
|
|
1818
|
+
yield* transaction
|
|
1819
|
+
.delete(mapping.charge.table)
|
|
1820
|
+
.where(
|
|
1821
|
+
and(
|
|
1822
|
+
eq(c.moduleId, input.moduleId),
|
|
1823
|
+
eq(c.action, row.action),
|
|
1824
|
+
eq(c.scopeKind, row.scopeKind),
|
|
1825
|
+
eq(c.scopeKey, row.scopeKey),
|
|
1826
|
+
eq(c.attemptId, row.attemptId),
|
|
1827
|
+
lte(c.retentionUntil, nativeNow),
|
|
1828
|
+
),
|
|
1829
|
+
);
|
|
1830
|
+
if (selectedAttempts.length > 0)
|
|
1831
|
+
yield* transaction.delete(mapping.attempt.table).where(
|
|
1832
|
+
and(
|
|
1833
|
+
eq(a.moduleId, input.moduleId),
|
|
1834
|
+
inArray(
|
|
1835
|
+
a.attemptId,
|
|
1836
|
+
selectedAttempts.map((row: any) => row.attemptId),
|
|
1837
|
+
),
|
|
1838
|
+
lte(a.retentionUntil, nativeNow),
|
|
1839
|
+
),
|
|
1840
|
+
);
|
|
1841
|
+
for (const row of selectedScopes)
|
|
1842
|
+
yield* transaction.delete(mapping.rateScope.table).where(
|
|
1843
|
+
and(
|
|
1844
|
+
eq(sc.moduleId, input.moduleId),
|
|
1845
|
+
eq(sc.action, row.action),
|
|
1846
|
+
eq(sc.scopeKind, row.scopeKind),
|
|
1847
|
+
eq(sc.scopeKey, row.scopeKey),
|
|
1848
|
+
notExists(
|
|
1849
|
+
transaction
|
|
1850
|
+
.select({ one: sql`1` })
|
|
1851
|
+
.from(mapping.charge.table)
|
|
1852
|
+
.where(
|
|
1853
|
+
and(
|
|
1854
|
+
eq(c.moduleId, sc.moduleId),
|
|
1855
|
+
eq(c.action, sc.action),
|
|
1856
|
+
eq(c.scopeKind, sc.scopeKind),
|
|
1857
|
+
eq(c.scopeKey, sc.scopeKey),
|
|
1858
|
+
),
|
|
1859
|
+
),
|
|
1860
|
+
),
|
|
1861
|
+
),
|
|
1862
|
+
);
|
|
1863
|
+
|
|
1864
|
+
return prepared;
|
|
1865
|
+
}),
|
|
1866
|
+
).pipe(
|
|
1867
|
+
Effect.provideService(CurrentPasswordSql, database),
|
|
1868
|
+
Effect.provideService(LifecycleHooks, hooks),
|
|
1869
|
+
translateFailure,
|
|
1870
|
+
),
|
|
1871
|
+
});
|
|
1872
|
+
});
|
|
1873
|
+
|
|
1874
|
+
const currentExpectedCredential = Effect.fn("DrizzlePassword.currentExpectedCredential")(function* (
|
|
1875
|
+
mapping: Mapping,
|
|
1876
|
+
input: PasswordMutationInput,
|
|
1877
|
+
nativeSubjectId: unknown,
|
|
1878
|
+
) {
|
|
1879
|
+
if (input.credential === undefined) return false;
|
|
1880
|
+
const row = (yield* readPasswordCredential(mapping, input.moduleId, nativeSubjectId, true))[0];
|
|
1881
|
+
|
|
1882
|
+
if (row === undefined) return false;
|
|
1883
|
+
|
|
1884
|
+
return (
|
|
1885
|
+
row[mapping.credential.credentialId] === input.credential.credentialId &&
|
|
1886
|
+
row[mapping.credential.credentialRevision] === input.credential.credentialRevision &&
|
|
1887
|
+
row[mapping.credential.verifierVersion] === input.credential.verifierVersion &&
|
|
1888
|
+
row[mapping.credential.verifier] === Redacted.value(input.credential.verifier) &&
|
|
1889
|
+
row[mapping.credential.normalization] === input.credential.normalization &&
|
|
1890
|
+
input.authorization.challenge.targetCredentialId === input.credential.credentialId
|
|
1891
|
+
);
|
|
1892
|
+
});
|
|
1893
|
+
|
|
1894
|
+
const checkMutationApplied = Effect.fn("DrizzlePassword.checkMutationApplied")(function* (
|
|
1895
|
+
mapping: Mapping,
|
|
1896
|
+
input: PasswordMutationInput,
|
|
1897
|
+
nativeSubjectId: unknown,
|
|
1898
|
+
revisions: {
|
|
1899
|
+
readonly credentialId: string;
|
|
1900
|
+
readonly credentialRevision: SecurityRevision;
|
|
1901
|
+
readonly verifierVersion: SecurityRevision;
|
|
1902
|
+
readonly nextSecurityRevision: SecurityRevision;
|
|
1903
|
+
},
|
|
1904
|
+
now: number,
|
|
1905
|
+
) {
|
|
1906
|
+
const database = yield* CurrentPasswordSql;
|
|
1907
|
+
|
|
1908
|
+
const c = credentialColumns(mapping),
|
|
1909
|
+
s = subjectColumns(mapping);
|
|
1910
|
+
|
|
1911
|
+
const credential = (yield* database
|
|
1912
|
+
.select()
|
|
1913
|
+
.from(mapping.credential.table)
|
|
1914
|
+
.where(
|
|
1915
|
+
and(
|
|
1916
|
+
eq(c.moduleId, input.moduleId),
|
|
1917
|
+
eq(c.subjectId, nativeSubjectId),
|
|
1918
|
+
eq(c.credentialId, revisions.credentialId),
|
|
1919
|
+
eq(c.credentialRevision, revisions.credentialRevision),
|
|
1920
|
+
eq(c.verifierVersion, revisions.verifierVersion),
|
|
1921
|
+
eq(c.verifier, Redacted.value(input.replacement.verifier)),
|
|
1922
|
+
eq(c.normalization, input.replacement.normalization),
|
|
1923
|
+
),
|
|
1924
|
+
)
|
|
1925
|
+
.limit(1))[0];
|
|
1926
|
+
|
|
1927
|
+
const subject = (yield* database
|
|
1928
|
+
.select()
|
|
1929
|
+
.from(mapping.subject.table)
|
|
1930
|
+
.where(and(eq(s.id, nativeSubjectId), eq(s.securityRevision, revisions.nextSecurityRevision)))
|
|
1931
|
+
.limit(1))[0];
|
|
1932
|
+
|
|
1933
|
+
const authorityCredential = (yield* database
|
|
1934
|
+
.select()
|
|
1935
|
+
.from(mapping.authorityCredential.table)
|
|
1936
|
+
.where(
|
|
1937
|
+
and(
|
|
1938
|
+
eq(authorityCredentialColumns(mapping).subjectId, nativeSubjectId),
|
|
1939
|
+
eq(authorityCredentialColumns(mapping).credentialId, revisions.credentialId),
|
|
1940
|
+
eq(authorityCredentialColumns(mapping).revision, revisions.credentialRevision),
|
|
1941
|
+
),
|
|
1942
|
+
)
|
|
1943
|
+
.limit(1))[0];
|
|
1944
|
+
|
|
1945
|
+
return (
|
|
1946
|
+
credential !== undefined &&
|
|
1947
|
+
(yield* mutationPostconditions(
|
|
1948
|
+
mapping,
|
|
1949
|
+
input,
|
|
1950
|
+
nativeSubjectId,
|
|
1951
|
+
subject,
|
|
1952
|
+
authorityCredential,
|
|
1953
|
+
now,
|
|
1954
|
+
))
|
|
1955
|
+
);
|
|
1956
|
+
});
|
|
1957
|
+
|
|
1958
|
+
const writeReplacement = Effect.fn("DrizzlePassword.writeReplacement")(function* (
|
|
1959
|
+
mapping: Mapping,
|
|
1960
|
+
input: PasswordMutationInput,
|
|
1961
|
+
nativeSubjectId: unknown,
|
|
1962
|
+
revisions: {
|
|
1963
|
+
readonly credentialRevision: SecurityRevision;
|
|
1964
|
+
readonly verifierVersion: SecurityRevision;
|
|
1965
|
+
readonly nextSecurityRevision: SecurityRevision;
|
|
1966
|
+
},
|
|
1967
|
+
now: number,
|
|
1968
|
+
) {
|
|
1969
|
+
const database = yield* CurrentPasswordSql;
|
|
1970
|
+
|
|
1971
|
+
const c = credentialColumns(mapping);
|
|
1972
|
+
const s = subjectColumns(mapping);
|
|
1973
|
+
|
|
1974
|
+
yield* database
|
|
1975
|
+
.update(mapping.credential.table)
|
|
1976
|
+
.set(
|
|
1977
|
+
mapping.credential.encodeReplacement({
|
|
1978
|
+
replacement: input.replacement,
|
|
1979
|
+
credentialRevision: revisions.credentialRevision,
|
|
1980
|
+
verifierVersion: revisions.verifierVersion,
|
|
1981
|
+
}),
|
|
1982
|
+
)
|
|
1983
|
+
.where(
|
|
1984
|
+
and(
|
|
1985
|
+
eq(c.moduleId, input.moduleId),
|
|
1986
|
+
eq(c.subjectId, nativeSubjectId),
|
|
1987
|
+
eq(c.credentialId, input.credential!.credentialId),
|
|
1988
|
+
eq(c.credentialRevision, input.credential!.credentialRevision),
|
|
1989
|
+
eq(c.verifierVersion, input.credential!.verifierVersion),
|
|
1990
|
+
eq(c.verifier, Redacted.value(input.credential!.verifier)),
|
|
1991
|
+
eq(c.normalization, input.credential!.normalization),
|
|
1992
|
+
),
|
|
1993
|
+
);
|
|
1994
|
+
yield* database
|
|
1995
|
+
.update(mapping.subject.table)
|
|
1996
|
+
.set(updateValues([[mapping.subject.securityRevision, revisions.nextSecurityRevision]]))
|
|
1997
|
+
.where(
|
|
1998
|
+
and(
|
|
1999
|
+
eq(s.id, nativeSubjectId),
|
|
2000
|
+
eq(s.securityRevision, input.expectedRevision.securityRevision),
|
|
2001
|
+
),
|
|
2002
|
+
);
|
|
2003
|
+
yield* database
|
|
2004
|
+
.update(mapping.authorityCredential.table)
|
|
2005
|
+
.set(mapping.authorityCredential.encodeRevision(revisions.credentialRevision))
|
|
2006
|
+
.where(
|
|
2007
|
+
and(
|
|
2008
|
+
eq(authorityCredentialColumns(mapping).subjectId, nativeSubjectId),
|
|
2009
|
+
eq(authorityCredentialColumns(mapping).credentialId, input.credential!.credentialId),
|
|
2010
|
+
eq(authorityCredentialColumns(mapping).revision, input.credential!.credentialRevision),
|
|
2011
|
+
),
|
|
2012
|
+
);
|
|
2013
|
+
yield* insertCommand(mapping, input, input.authorization.challenge.action, now);
|
|
2014
|
+
|
|
2015
|
+
return yield* checkMutationApplied(
|
|
2016
|
+
mapping,
|
|
2017
|
+
input,
|
|
2018
|
+
nativeSubjectId,
|
|
2019
|
+
{
|
|
2020
|
+
...revisions,
|
|
2021
|
+
credentialId: input.credential!.credentialId,
|
|
2022
|
+
},
|
|
2023
|
+
now,
|
|
2024
|
+
);
|
|
2025
|
+
});
|
|
2026
|
+
|
|
2027
|
+
const replaceIn = Effect.fn("Drizzle.replaceIn")(function* <A>(
|
|
2028
|
+
mapping: Mapping,
|
|
2029
|
+
configuration: PasswordSqlConfiguration,
|
|
2030
|
+
input: PasswordMutationInput,
|
|
2031
|
+
action: PasswordAction,
|
|
2032
|
+
revisions: {
|
|
2033
|
+
readonly credentialRevision: SecurityRevision;
|
|
2034
|
+
readonly verifierVersion: SecurityRevision;
|
|
2035
|
+
readonly nextSecurityRevision: SecurityRevision;
|
|
2036
|
+
},
|
|
2037
|
+
prepare: (value: PasswordMutationDecision, journal: CommitJournal) => PreparedCommit<A>,
|
|
2038
|
+
) {
|
|
2039
|
+
const journal = yield* CurrentCommitJournal;
|
|
2040
|
+
|
|
2041
|
+
const authority = yield* validateMutationAuthority(mapping, configuration, input, action);
|
|
2042
|
+
|
|
2043
|
+
if (authority === undefined) return prepare("rejected", journal);
|
|
2044
|
+
if ((yield* commandExists(mapping, input.moduleId, input.commandId, true)).length)
|
|
2045
|
+
return prepare("rejected", journal);
|
|
2046
|
+
if (!(yield* currentExpectedCredential(mapping, input, authority.nativeSubjectId)))
|
|
2047
|
+
return prepare("rejected", journal);
|
|
2048
|
+
const prepared = prepare("changed", journal);
|
|
2049
|
+
|
|
2050
|
+
if (
|
|
2051
|
+
!(yield* writeReplacement(mapping, input, authority.nativeSubjectId, revisions, authority.now))
|
|
2052
|
+
)
|
|
2053
|
+
return yield* unavailable();
|
|
2054
|
+
|
|
2055
|
+
return prepared;
|
|
2056
|
+
});
|
|
2057
|
+
|
|
2058
|
+
/** Internal bound-owner primitives; deliberately not re-exported by driver modules. */
|
|
2059
|
+
export const passwordSqlKernel = {
|
|
2060
|
+
allocate,
|
|
2061
|
+
allocateNextSecurityRevision,
|
|
2062
|
+
owned,
|
|
2063
|
+
safeRead,
|
|
2064
|
+
snapshotMutationInput,
|
|
2065
|
+
lockSubject,
|
|
2066
|
+
lockIdentifier,
|
|
2067
|
+
readPasswordCredential,
|
|
2068
|
+
resolveCredential,
|
|
2069
|
+
validateMutationAuthority,
|
|
2070
|
+
currentExpectedCredential,
|
|
2071
|
+
commandExists,
|
|
2072
|
+
addPasswordIn,
|
|
2073
|
+
checkMutationApplied,
|
|
2074
|
+
writeReplacement,
|
|
2075
|
+
evidenceSatisfiedAt,
|
|
2076
|
+
sameCredentialSnapshot,
|
|
2077
|
+
subjectColumns,
|
|
2078
|
+
identifierColumns,
|
|
2079
|
+
credentialColumns,
|
|
2080
|
+
authorityCredentialColumns,
|
|
2081
|
+
proofCompletionMatchesPassword,
|
|
2082
|
+
};
|