@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,116 @@
|
|
|
1
|
+
import { OperationHttpError } from "./errors.mjs";
|
|
2
|
+
import { make as make$1, makeAuthenticationCompletion } from "./client.mjs";
|
|
3
|
+
import { Context, Effect, Layer, Scope, Semaphore } from "effect";
|
|
4
|
+
//#region src/http-operation/auth-client.ts
|
|
5
|
+
const AuthClientTypeId = Symbol.for("effect-auth/Client");
|
|
6
|
+
/** Derive one named client from the shared contract. Each operation makes one
|
|
7
|
+
* attempt. Authentication transitions also notify any scoped Atom consumers. */
|
|
8
|
+
const acquire = Effect.fn("Client.make")(function* (contract, options) {
|
|
9
|
+
const transport = yield* make$1({
|
|
10
|
+
...options,
|
|
11
|
+
csrfHeader: options.csrf?.header ?? "x-effect-auth-csrf",
|
|
12
|
+
csrfValue: options.csrf?.value ?? "1"
|
|
13
|
+
});
|
|
14
|
+
const gate = yield* Semaphore.make(1);
|
|
15
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
16
|
+
let state = {
|
|
17
|
+
subject: null,
|
|
18
|
+
generation: 0
|
|
19
|
+
};
|
|
20
|
+
let closed = false;
|
|
21
|
+
const notify = (event) => Effect.forEach([...listeners], (listener) => listener(event), {
|
|
22
|
+
concurrency: 1,
|
|
23
|
+
discard: true
|
|
24
|
+
});
|
|
25
|
+
const publish = Effect.fn("Client.publishSubject")(function* (subject, action, origin) {
|
|
26
|
+
state = {
|
|
27
|
+
subject,
|
|
28
|
+
generation: state.generation + 1
|
|
29
|
+
};
|
|
30
|
+
yield* notify({
|
|
31
|
+
_tag: "Transition",
|
|
32
|
+
state,
|
|
33
|
+
...action === void 0 ? {} : { action },
|
|
34
|
+
...origin === void 0 ? {} : { origin }
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
const completeAuthentication = makeAuthenticationCompletion(transport, gate, publish);
|
|
38
|
+
const replaceSubject = Effect.fn("Client.replaceSubject")(function* (subject) {
|
|
39
|
+
yield* gate.withPermits(1)(Effect.uninterruptible(Effect.gen(function* () {
|
|
40
|
+
yield* transport.transition;
|
|
41
|
+
yield* publish(subject);
|
|
42
|
+
})));
|
|
43
|
+
});
|
|
44
|
+
const call = Effect.fn("Client.call")(function* (name, input, callOptions) {
|
|
45
|
+
if (closed) return yield* OperationHttpError.make({ reason: "stale-response" });
|
|
46
|
+
const action = contract.actions[name];
|
|
47
|
+
const project = action.subject;
|
|
48
|
+
const started = yield* transport.generation;
|
|
49
|
+
let transitioned = false;
|
|
50
|
+
const value = yield* Effect.gen(function* () {
|
|
51
|
+
if (project !== void 0 && action.mode === "mutation") {
|
|
52
|
+
const generation = state.generation;
|
|
53
|
+
const value = yield* makeAuthenticationCompletion(transport, gate, (subject) => publish(subject, String(name), callOptions?.origin))(action.route, input, (success) => project.fromSuccess(success));
|
|
54
|
+
transitioned = state.generation !== generation;
|
|
55
|
+
return value;
|
|
56
|
+
}
|
|
57
|
+
const value = yield* transport.call(action.route, input);
|
|
58
|
+
if (project !== void 0) yield* gate.withPermits(1)(Effect.uninterruptible(Effect.gen(function* () {
|
|
59
|
+
if ((yield* transport.generation) !== started) return yield* OperationHttpError.make({ reason: "stale-response" });
|
|
60
|
+
const subject = yield* Effect.try({
|
|
61
|
+
try: () => project.fromSuccess(value),
|
|
62
|
+
catch: () => OperationHttpError.make({ reason: "response" })
|
|
63
|
+
});
|
|
64
|
+
if (subject !== void 0 && subject !== state.subject) {
|
|
65
|
+
yield* transport.transition;
|
|
66
|
+
yield* publish(subject);
|
|
67
|
+
}
|
|
68
|
+
})));
|
|
69
|
+
return value;
|
|
70
|
+
});
|
|
71
|
+
if (action.mode === "mutation" && !transitioned && callOptions?.notifyMutation !== false) yield* notify({
|
|
72
|
+
_tag: "Mutation",
|
|
73
|
+
name: String(name)
|
|
74
|
+
});
|
|
75
|
+
return value;
|
|
76
|
+
});
|
|
77
|
+
const controller = {
|
|
78
|
+
actions: contract.actions,
|
|
79
|
+
transport,
|
|
80
|
+
state: Effect.sync(() => state),
|
|
81
|
+
call,
|
|
82
|
+
replaceSubject,
|
|
83
|
+
completeAuthentication,
|
|
84
|
+
subscribe: (listener) => Effect.acquireRelease(gate.withPermits(1)(Effect.gen(function* () {
|
|
85
|
+
yield* listener({
|
|
86
|
+
_tag: "Transition",
|
|
87
|
+
state
|
|
88
|
+
});
|
|
89
|
+
listeners.add(listener);
|
|
90
|
+
})), () => Effect.sync(() => void listeners.delete(listener)))
|
|
91
|
+
};
|
|
92
|
+
yield* Scope.addFinalizer(yield* Effect.scope, gate.withPermits(1)(Effect.gen(function* () {
|
|
93
|
+
closed = true;
|
|
94
|
+
yield* transport.transition;
|
|
95
|
+
listeners.clear();
|
|
96
|
+
})));
|
|
97
|
+
const methods = Object.fromEntries(Object.keys(contract.actions).map((name) => [name, (input) => call(name, input)]));
|
|
98
|
+
Object.defineProperty(methods, AuthClientTypeId, { value: controller });
|
|
99
|
+
return { auth: Object.freeze(methods) };
|
|
100
|
+
});
|
|
101
|
+
/** Define a yieldable client without acquiring resources. Provide its layer once
|
|
102
|
+
* in the application Scope, or yield its make Effect for direct acquisition.
|
|
103
|
+
* Every instance owns its credential settlement and scoped Atom subscriptions. */
|
|
104
|
+
const make = (contract, options) => {
|
|
105
|
+
const service = Context.Service()(`${contract.namespace}/client`);
|
|
106
|
+
const create = acquire(contract, options);
|
|
107
|
+
return Object.assign(service, {
|
|
108
|
+
contract,
|
|
109
|
+
make: create,
|
|
110
|
+
layer: Layer.effect(service, create)
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
//#endregion
|
|
114
|
+
export { AuthClientTypeId, make };
|
|
115
|
+
|
|
116
|
+
//# sourceMappingURL=auth-client.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-client.mjs","names":["makeTransport"],"sources":["../../src/http-operation/auth-client.ts"],"sourcesContent":["import { Context, Effect, Layer, Scope, Semaphore } from \"effect\";\n\nimport type { AnyAuthAction, AuthActions } from \"../operations/actions\";\nimport {\n makeAuthenticationCompletion,\n make as makeTransport,\n type OperationAuthenticationCompletion,\n type OperationFetchClient,\n type OperationFetchOptions,\n} from \"./client\";\nimport type { RouteFailure, RouteInput, RouteSuccess } from \"./contract\";\nimport { OperationHttpError } from \"./errors\";\n\nexport type ClientOptions = Omit<OperationFetchOptions, \"csrfHeader\" | \"csrfValue\"> & {\n readonly csrf?: { readonly header: string; readonly value: string };\n};\n\nexport type ActionDecodeServices<Action extends AnyAuthAction> =\n | Action[\"route\"][\"operation\"][\"rpc\"][\"successSchema\"][\"DecodingServices\"]\n | Action[\"route\"][\"operation\"][\"rpc\"][\"errorSchema\"][\"DecodingServices\"];\n\nexport type ActionArguments<Action extends AnyAuthAction> =\n undefined extends RouteInput<Action[\"route\"]>\n ? readonly [input?: RouteInput<Action[\"route\"]>]\n : readonly [input: RouteInput<Action[\"route\"]>];\n\nexport interface AuthClientState {\n readonly subject: string | null;\n readonly generation: number;\n}\n\nexport type AuthClientEvent =\n | {\n readonly _tag: \"Transition\";\n readonly state: AuthClientState;\n readonly action?: string;\n readonly origin?: object;\n }\n | { readonly _tag: \"Mutation\"; readonly name: string };\n\n/** Internal bridge shared with Atom. Subscriptions belong to their host Scope;\n * transition listeners only dispose and publish state, never call the client. */\nexport interface AuthClientController<Actions extends AuthActions> {\n readonly actions: Actions;\n readonly transport: OperationFetchClient;\n readonly state: Effect.Effect<AuthClientState>;\n readonly subscribe: (\n listener: (event: AuthClientEvent) => Effect.Effect<void>,\n ) => Effect.Effect<void, never, Scope.Scope>;\n readonly replaceSubject: (subject: string | null) => Effect.Effect<void>;\n readonly completeAuthentication: OperationAuthenticationCompletion;\n readonly call: <Name extends keyof Actions>(\n name: Name,\n input: RouteInput<Actions[Name][\"route\"]>,\n options?: { readonly notifyMutation?: boolean; readonly origin?: object },\n ) => Effect.Effect<\n RouteSuccess<Actions[Name][\"route\"]>,\n RouteFailure<Actions[Name][\"route\"]> | OperationHttpError,\n ActionDecodeServices<Actions[Name]>\n >;\n}\n\nexport const AuthClientTypeId: unique symbol = Symbol.for(\"effect-auth/Client\");\n\n/** Named calls return Effects; request credentials and private reveals remain\n * in the configured transport capabilities, outside operation results. */\nexport type AuthClient<Actions extends AuthActions> = {\n readonly [Name in keyof Actions]: (\n ...args: ActionArguments<Actions[Name]>\n ) => Effect.Effect<\n RouteSuccess<Actions[Name][\"route\"]>,\n RouteFailure<Actions[Name][\"route\"]> | OperationHttpError,\n ActionDecodeServices<Actions[Name]>\n >;\n} & { readonly [AuthClientTypeId]: AuthClientController<Actions> };\n\n/** Derive one named client from the shared contract. Each operation makes one\n * attempt. Authentication transitions also notify any scoped Atom consumers. */\nconst acquire = Effect.fn(\"Client.make\")(function* <Actions extends AuthActions>(\n contract: { readonly actions: Actions },\n options: ClientOptions,\n): Effect.fn.Return<{ readonly auth: AuthClient<Actions> }, OperationHttpError, Scope.Scope> {\n const transport = yield* makeTransport({\n ...options,\n csrfHeader: options.csrf?.header ?? \"x-effect-auth-csrf\",\n csrfValue: options.csrf?.value ?? \"1\",\n });\n\n const gate = yield* Semaphore.make(1);\n const listeners = new Set<(event: AuthClientEvent) => Effect.Effect<void>>();\n let state: AuthClientState = { subject: null, generation: 0 };\n let closed = false;\n\n const notify = (event: AuthClientEvent) =>\n Effect.forEach([...listeners], (listener) => listener(event), {\n concurrency: 1,\n discard: true,\n });\n\n const publish = Effect.fn(\"Client.publishSubject\")(function* (\n subject: string | null,\n action?: string,\n origin?: object,\n ) {\n state = { subject, generation: state.generation + 1 };\n yield* notify({\n _tag: \"Transition\",\n state,\n ...(action === undefined ? {} : { action }),\n ...(origin === undefined ? {} : { origin }),\n });\n });\n\n const completeAuthentication = makeAuthenticationCompletion(transport, gate, publish);\n\n const replaceSubject = Effect.fn(\"Client.replaceSubject\")(function* (subject: string | null) {\n yield* gate.withPermits(1)(\n Effect.uninterruptible(\n Effect.gen(function* () {\n yield* transport.transition;\n yield* publish(subject);\n }),\n ),\n );\n });\n\n const call: AuthClientController<Actions>[\"call\"] = Effect.fn(\"Client.call\")(function* <\n Name extends keyof Actions,\n >(\n name: Name,\n input: RouteInput<Actions[Name][\"route\"]>,\n callOptions?: { readonly notifyMutation?: boolean; readonly origin?: object },\n ) {\n if (closed) return yield* OperationHttpError.make({ reason: \"stale-response\" });\n\n const action = contract.actions[name];\n const project = action.subject;\n const started = yield* transport.generation;\n let transitioned = false;\n\n const execute = Effect.gen(function* () {\n if (project !== undefined && action.mode === \"mutation\") {\n const generation = state.generation;\n\n // Notify within credential settlement: disposing an account registry can\n // interrupt the atom that dispatched this call before a later success tap.\n const complete = makeAuthenticationCompletion(transport, gate, (subject) =>\n publish(subject, String(name), callOptions?.origin),\n );\n\n const value = yield* complete<Actions[Name][\"route\"]>(action.route, input, (success) =>\n project.fromSuccess(success),\n );\n\n transitioned = state.generation !== generation;\n\n return value;\n }\n\n const value = yield* transport.call<Actions[Name][\"route\"]>(action.route, input);\n\n if (project !== undefined) {\n yield* gate.withPermits(1)(\n Effect.uninterruptible(\n Effect.gen(function* () {\n if ((yield* transport.generation) !== started)\n return yield* OperationHttpError.make({ reason: \"stale-response\" });\n\n const subject = yield* Effect.try({\n try: () => project.fromSuccess(value),\n catch: () => OperationHttpError.make({ reason: \"response\" }),\n });\n\n if (subject !== undefined && subject !== state.subject) {\n yield* transport.transition;\n yield* publish(subject);\n }\n }),\n ),\n );\n }\n\n return value;\n });\n\n const value = yield* execute;\n\n if (action.mode === \"mutation\" && !transitioned && callOptions?.notifyMutation !== false)\n yield* notify({ _tag: \"Mutation\", name: String(name) });\n\n return value;\n });\n\n const controller: AuthClientController<Actions> = {\n actions: contract.actions,\n transport,\n state: Effect.sync(() => state),\n call,\n replaceSubject,\n completeAuthentication,\n subscribe: (listener) =>\n Effect.acquireRelease(\n gate.withPermits(1)(\n Effect.gen(function* () {\n yield* listener({ _tag: \"Transition\", state });\n listeners.add(listener);\n }),\n ),\n () => Effect.sync(() => void listeners.delete(listener)),\n ),\n };\n\n yield* Scope.addFinalizer(\n yield* Effect.scope,\n gate.withPermits(1)(\n Effect.gen(function* () {\n closed = true;\n yield* transport.transition;\n listeners.clear();\n }),\n ),\n );\n\n const methods = Object.fromEntries(\n Object.keys(contract.actions).map((name) => [\n name,\n (input: RouteInput<Actions[string][\"route\"]>) => call(name, input),\n ]),\n );\n\n Object.defineProperty(methods, AuthClientTypeId, { value: controller });\n\n // Every property delegates to the same named contract entry. This cast restores\n // the mapped key/signature relationship after constructing the property table.\n return { auth: Object.freeze(methods) as AuthClient<Actions> };\n});\n\n/** Identifier for a configured client service, separate from the server service. */\nexport interface ClientService<Id extends string, Actions extends AuthActions> {\n readonly namespace: Id;\n readonly actions: Actions;\n readonly _client: unique symbol;\n}\n\nexport interface ClientDefinition<\n Id extends string,\n Actions extends AuthActions,\n> extends Context.Service<ClientService<Id, Actions>, { readonly auth: AuthClient<Actions> }> {\n readonly contract: { readonly namespace: Id; readonly actions: Actions };\n readonly make: Effect.Effect<\n { readonly auth: AuthClient<Actions> },\n OperationHttpError,\n Scope.Scope\n >;\n readonly layer: Layer.Layer<ClientService<Id, Actions>, OperationHttpError>;\n}\n\n/** Define a yieldable client without acquiring resources. Provide its layer once\n * in the application Scope, or yield its make Effect for direct acquisition.\n * Every instance owns its credential settlement and scoped Atom subscriptions. */\nexport const make = <const Id extends string, Actions extends AuthActions>(\n contract: { readonly namespace: Id; readonly actions: Actions },\n options: ClientOptions,\n): ClientDefinition<Id, Actions> => {\n const service = Context.Service<\n ClientService<Id, Actions>,\n { readonly auth: AuthClient<Actions> }\n >()(`${contract.namespace}/client`);\n\n const create = acquire(contract, options);\n\n return Object.assign(service, { contract, make: create, layer: Layer.effect(service, create) });\n};\n"],"mappings":";;;;AA8DA,MAAa,mBAAkC,OAAO,IAAI,oBAAoB;;;AAgB9E,MAAM,UAAU,OAAO,GAAG,aAAa,CAAC,CAAC,WACvC,UACA,SAC2F;CAC3F,MAAM,YAAY,OAAOA,OAAc;EACrC,GAAG;EACH,YAAY,QAAQ,MAAM,UAAU;EACpC,WAAW,QAAQ,MAAM,SAAS;CACpC,CAAC;CAED,MAAM,OAAO,OAAO,UAAU,KAAK,CAAC;CACpC,MAAM,4BAAY,IAAI,IAAqD;CAC3E,IAAI,QAAyB;EAAE,SAAS;EAAM,YAAY;CAAE;CAC5D,IAAI,SAAS;CAEb,MAAM,UAAU,UACd,OAAO,QAAQ,CAAC,GAAG,SAAS,IAAI,aAAa,SAAS,KAAK,GAAG;EAC5D,aAAa;EACb,SAAS;CACX,CAAC;CAEH,MAAM,UAAU,OAAO,GAAG,uBAAuB,CAAC,CAAC,WACjD,SACA,QACA,QACA;EACA,QAAQ;GAAE;GAAS,YAAY,MAAM,aAAa;EAAE;EACpD,OAAO,OAAO;GACZ,MAAM;GACN;GACA,GAAI,WAAW,KAAA,IAAY,CAAC,I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O;CAExC,OAAO,OAAO,OAAO,SAAS;EAAE;EAAU,MAAM;EAAQ,OAAO,MAAM,OAAO,SAAS,MAAM;CAAE,CAAC;AAChG"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { AuthRevealCommandCollector } from "../operations/reveals.mjs";
|
|
2
|
+
import { AuthCredentialCommand, CredentialSlot } from "../operations/credentials.mjs";
|
|
3
|
+
import { AnyRoute, RouteFailure, RouteInput, RouteSuccess } from "./contract.mjs";
|
|
4
|
+
import { OperationHttpError } from "./errors.mjs";
|
|
5
|
+
import { HttpCredentials } from "./models.mjs";
|
|
6
|
+
import { Effect, Semaphore } from "effect";
|
|
7
|
+
//#region src/http-operation/client.d.ts
|
|
8
|
+
interface OperationFetchOptions {
|
|
9
|
+
readonly baseUrl: string;
|
|
10
|
+
readonly csrfHeader: string;
|
|
11
|
+
readonly csrfValue: string;
|
|
12
|
+
readonly maximumResponseBytes?: number;
|
|
13
|
+
readonly fetch?: typeof globalThis.fetch;
|
|
14
|
+
readonly privateOutput?: AuthRevealCommandCollector & {
|
|
15
|
+
readonly clear: Effect.Effect<void>;
|
|
16
|
+
};
|
|
17
|
+
readonly native?: {
|
|
18
|
+
readonly modeHeader: string;
|
|
19
|
+
readonly requestHeaders: Readonly<Record<CredentialSlot, string>>;
|
|
20
|
+
readonly responseHeaders: Readonly<Record<CredentialSlot, string>>;
|
|
21
|
+
readonly read: Effect.Effect<HttpCredentials, OperationHttpError>;
|
|
22
|
+
readonly accept: (commands: ReadonlyArray<AuthCredentialCommand>) => Effect.Effect<void, OperationHttpError>;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
interface OperationCallOptions<Success = unknown> {
|
|
26
|
+
readonly replaceSubject?: boolean | ((success: Success) => boolean);
|
|
27
|
+
/** Runs inside credential admission after fencing old responses. The callback
|
|
28
|
+
* must not call this client's transition or start another credential call. */
|
|
29
|
+
readonly onTransition?: Effect.Effect<void>;
|
|
30
|
+
}
|
|
31
|
+
interface OperationFetchClient {
|
|
32
|
+
readonly call: <R extends AnyRoute>(route: R, input: RouteInput<R>, options?: OperationCallOptions<RouteSuccess<R>>) => Effect.Effect<RouteSuccess<R>, RouteFailure<R> | OperationHttpError, R["operation"]["rpc"]["successSchema"]["DecodingServices"] | R["operation"]["rpc"]["errorSchema"]["DecodingServices"]>;
|
|
33
|
+
/** Wait for admitted credential responses, then fence old queries and clear reveals.
|
|
34
|
+
* All authenticated subject changes for this client must pass this boundary. */
|
|
35
|
+
readonly transition: Effect.Effect<void>;
|
|
36
|
+
readonly generation: Effect.Effect<number>;
|
|
37
|
+
}
|
|
38
|
+
/** Complete an authentication operation and publish its subject while its
|
|
39
|
+
* credential response remains admitted. Undefined preserves a pending flow. */
|
|
40
|
+
interface OperationAuthenticationCompletion {
|
|
41
|
+
<R extends AnyRoute>(route: R, input: RouteInput<R>, fromSuccess: (success: RouteSuccess<R>) => string | null | undefined, options?: {
|
|
42
|
+
readonly onTransition?: Effect.Effect<void>;
|
|
43
|
+
}): Effect.Effect<RouteSuccess<R>, RouteFailure<R> | OperationHttpError, R["operation"]["rpc"]["successSchema"]["DecodingServices"] | R["operation"]["rpc"]["errorSchema"]["DecodingServices"]>;
|
|
44
|
+
}
|
|
45
|
+
/** One instance owns credential ordering and stale-result fencing. Share it within
|
|
46
|
+
* a browser authentication lifetime; mutations are never automatically retried. */
|
|
47
|
+
declare const make: (options: OperationFetchOptions) => Effect.Effect<OperationFetchClient, OperationHttpError, never>;
|
|
48
|
+
//#endregion
|
|
49
|
+
export { OperationAuthenticationCompletion, OperationCallOptions, OperationFetchClient, OperationFetchOptions, make };
|
|
50
|
+
//# sourceMappingURL=client.d.mts.map
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { snapshotRevealCommands } from "../operations/reveals.mjs";
|
|
2
|
+
import { OperationHttpError } from "./errors.mjs";
|
|
3
|
+
import { credentialSlots } from "./models.mjs";
|
|
4
|
+
import { CredentialWire, RevealWire, decodeRevealWire } from "./private.mjs";
|
|
5
|
+
import { headerName } from "./configuration-schema.mjs";
|
|
6
|
+
import { HttpRequestBody } from "./contract.mjs";
|
|
7
|
+
import { DateTime, Effect, Redacted, Schema, Semaphore } from "effect";
|
|
8
|
+
//#region src/http-operation/client.ts
|
|
9
|
+
/** The caller owns the lifecycle gate and publisher. Publishers must not call
|
|
10
|
+
* the transport: they run under credential admission, before reveal acceptance. */
|
|
11
|
+
const makeAuthenticationCompletion = (client, gate, publishSubject) => Effect.fn("OperationHttpClient.completeAuthentication")(function* (route, input, fromSuccess, options) {
|
|
12
|
+
const started = yield* client.generation;
|
|
13
|
+
return yield* gate.withPermits(1)(Effect.gen(function* () {
|
|
14
|
+
if ((yield* client.generation) !== started) return yield* OperationHttpError.make({ reason: "stale-response" });
|
|
15
|
+
return yield* Effect.uninterruptible(Effect.gen(function* () {
|
|
16
|
+
let nextSubject;
|
|
17
|
+
return yield* client.call(route, input, {
|
|
18
|
+
replaceSubject: (value) => {
|
|
19
|
+
nextSubject = fromSuccess(value);
|
|
20
|
+
return nextSubject !== void 0;
|
|
21
|
+
},
|
|
22
|
+
onTransition: Effect.suspend(() => nextSubject === void 0 ? Effect.void : publishSubject(nextSubject).pipe(Effect.andThen(options?.onTransition ?? Effect.void)))
|
|
23
|
+
});
|
|
24
|
+
}).pipe(Effect.onError(() => Effect.gen(function* () {
|
|
25
|
+
yield* client.transition;
|
|
26
|
+
yield* publishSubject(null);
|
|
27
|
+
yield* options?.onTransition ?? Effect.void;
|
|
28
|
+
}))));
|
|
29
|
+
}));
|
|
30
|
+
});
|
|
31
|
+
const responseCodec = Schema.fromJsonString(Schema.Union([
|
|
32
|
+
Schema.TaggedStruct("Success", {
|
|
33
|
+
value: Schema.optionalKey(Schema.Json),
|
|
34
|
+
private: Schema.optionalKey(Schema.Array(RevealWire))
|
|
35
|
+
}),
|
|
36
|
+
Schema.TaggedStruct("Failure", { error: Schema.Json }),
|
|
37
|
+
Schema.TaggedStruct("TransportFailure", { reason: Schema.String })
|
|
38
|
+
]));
|
|
39
|
+
const credentialCodec = Schema.fromJsonString(CredentialWire);
|
|
40
|
+
const requestCodec = Schema.fromJsonString(HttpRequestBody);
|
|
41
|
+
const readBody = (response, maximum) => Effect.tryPromise({
|
|
42
|
+
try: async (signal) => {
|
|
43
|
+
if (response.body === null) return "";
|
|
44
|
+
const reader = response.body.getReader();
|
|
45
|
+
const chunks = [];
|
|
46
|
+
let size = 0;
|
|
47
|
+
const abort = () => {
|
|
48
|
+
reader.cancel();
|
|
49
|
+
};
|
|
50
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
51
|
+
try {
|
|
52
|
+
while (true) {
|
|
53
|
+
const part = await reader.read();
|
|
54
|
+
if (part.done) break;
|
|
55
|
+
size += part.value.length;
|
|
56
|
+
if (size > maximum) {
|
|
57
|
+
await reader.cancel();
|
|
58
|
+
throw new Error();
|
|
59
|
+
}
|
|
60
|
+
chunks.push(part.value);
|
|
61
|
+
}
|
|
62
|
+
const bytes = new Uint8Array(size);
|
|
63
|
+
let offset = 0;
|
|
64
|
+
for (const chunk of chunks) {
|
|
65
|
+
bytes.set(chunk, offset);
|
|
66
|
+
offset += chunk.length;
|
|
67
|
+
}
|
|
68
|
+
return new TextDecoder("utf-8", { fatal: true }).decode(bytes);
|
|
69
|
+
} finally {
|
|
70
|
+
signal.removeEventListener("abort", abort);
|
|
71
|
+
reader.releaseLock();
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
catch: () => OperationHttpError.make({ reason: "response" })
|
|
75
|
+
});
|
|
76
|
+
/** One instance owns credential ordering and stale-result fencing. Share it within
|
|
77
|
+
* a browser authentication lifetime; mutations are never automatically retried. */
|
|
78
|
+
const make = Effect.fn("OperationHttpClient.make")(function* (options) {
|
|
79
|
+
const base = yield* Effect.try({
|
|
80
|
+
try: () => new URL(options.baseUrl),
|
|
81
|
+
catch: () => OperationHttpError.make({ reason: "request" })
|
|
82
|
+
});
|
|
83
|
+
if (!Number.isSafeInteger(options.maximumResponseBytes ?? 1048576) || (options.maximumResponseBytes ?? 1048576) < 1 || (options.maximumResponseBytes ?? 1048576) > 1048576 || !/^x-[a-z0-9-]{1,61}$/.test(options.csrfHeader) || options.csrfValue.length < 1 || options.csrfValue.length > 128 || !["https:", "http:"].includes(base.protocol) || base.username !== "" || base.password !== "" || base.search !== "" || base.hash !== "") return yield* OperationHttpError.make({ reason: "request" });
|
|
84
|
+
if (options.native !== void 0) {
|
|
85
|
+
const names = [options.native.modeHeader, ...credentialSlots.map((slot) => options.native.requestHeaders[slot])];
|
|
86
|
+
const response = credentialSlots.map((slot) => options.native.responseHeaders[slot]);
|
|
87
|
+
if ([...names, ...response].some((name) => !Schema.is(headerName)(name)) || new Set(names).size !== names.length || new Set(response).size !== response.length || names.includes(options.csrfHeader)) return yield* OperationHttpError.make({ reason: "request" });
|
|
88
|
+
}
|
|
89
|
+
const gate = yield* Semaphore.make(1);
|
|
90
|
+
let generation = 0;
|
|
91
|
+
const advance = Effect.gen(function* () {
|
|
92
|
+
generation++;
|
|
93
|
+
if (options.privateOutput !== void 0) yield* options.privateOutput.clear;
|
|
94
|
+
});
|
|
95
|
+
return {
|
|
96
|
+
call: Effect.fn("OperationHttpClient.call")(function* (route, input, callOptions) {
|
|
97
|
+
const started = generation;
|
|
98
|
+
const services = yield* Effect.context();
|
|
99
|
+
const successSchema = route.operation.rpc.successSchema;
|
|
100
|
+
const errorSchema = route.operation.rpc.errorSchema;
|
|
101
|
+
if (route.operation.reveals.some((kind) => options.privateOutput === void 0 || !options.privateOutput.supportedKinds.includes(kind) || !route.reveals.includes(kind))) return yield* OperationHttpError.make({ reason: "private-output" });
|
|
102
|
+
const work = Effect.gen(function* () {
|
|
103
|
+
if (started !== generation) return yield* OperationHttpError.make({ reason: "stale-response" });
|
|
104
|
+
const payload = input === void 0 ? void 0 : yield* Schema.decodeUnknownEffect(Schema.Json)(input).pipe(Effect.mapError(() => OperationHttpError.make({ reason: "request" })));
|
|
105
|
+
const body = yield* Schema.encodeEffect(requestCodec)(payload === void 0 ? {} : { payload }).pipe(Effect.mapError(() => OperationHttpError.make({ reason: "request" })));
|
|
106
|
+
if (route.method === "GET" && input !== void 0) return yield* OperationHttpError.make({ reason: "request" });
|
|
107
|
+
const headers = new Headers(route.method === "GET" ? {} : {
|
|
108
|
+
"content-type": "application/json",
|
|
109
|
+
[options.csrfHeader]: options.csrfValue
|
|
110
|
+
});
|
|
111
|
+
if (options.native !== void 0) {
|
|
112
|
+
headers.set(options.native.modeHeader, "native");
|
|
113
|
+
const credentials = yield* options.native.read;
|
|
114
|
+
for (const slot of credentialSlots) if (credentials[slot] !== void 0) headers.set(options.native.requestHeaders[slot], Redacted.value(credentials[slot]));
|
|
115
|
+
}
|
|
116
|
+
const destination = new URL(route.path, base);
|
|
117
|
+
const response = yield* Effect.tryPromise({
|
|
118
|
+
try: (signal) => {
|
|
119
|
+
if (started !== generation) throw OperationHttpError.make({ reason: "stale-response" });
|
|
120
|
+
return (options.fetch ?? globalThis.fetch)(destination, {
|
|
121
|
+
method: route.method,
|
|
122
|
+
headers,
|
|
123
|
+
...route.method === "GET" ? {} : { body },
|
|
124
|
+
credentials: options.native === void 0 ? "include" : "omit",
|
|
125
|
+
redirect: "error",
|
|
126
|
+
signal
|
|
127
|
+
});
|
|
128
|
+
},
|
|
129
|
+
catch: (error) => Schema.is(OperationHttpError)(error) ? error : OperationHttpError.make({ reason: "network" })
|
|
130
|
+
});
|
|
131
|
+
if (response.headers.get("content-type")?.split(";")[0]?.trim().toLowerCase() !== "application/json") return yield* OperationHttpError.make({ reason: "response" });
|
|
132
|
+
const envelope = yield* Schema.decodeEffect(responseCodec)(yield* readBody(response, options.maximumResponseBytes ?? 1048576)).pipe(Effect.mapError(() => OperationHttpError.make({ reason: "response" })));
|
|
133
|
+
if (started !== generation) return yield* OperationHttpError.make({ reason: "stale-response" });
|
|
134
|
+
if (envelope._tag === "TransportFailure") return yield* OperationHttpError.make({ reason: envelope.reason === "origin" || envelope.reason === "csrf" || envelope.reason === "credentials" || envelope.reason === "private-output" ? envelope.reason : "response" });
|
|
135
|
+
if (envelope._tag === "Failure") {
|
|
136
|
+
const failure = yield* Schema.decodeEffect(errorSchema)(envelope.error).pipe(Effect.provide(services), Effect.mapError(() => OperationHttpError.make({ reason: "response" })));
|
|
137
|
+
return yield* Effect.fail(failure);
|
|
138
|
+
}
|
|
139
|
+
if (!response.ok) return yield* OperationHttpError.make({ reason: "response" });
|
|
140
|
+
const value = yield* Schema.decodeEffect(successSchema)(envelope.value).pipe(Effect.provide(services), Effect.mapError(() => OperationHttpError.make({ reason: "response" })));
|
|
141
|
+
if (started !== generation) return yield* OperationHttpError.make({ reason: "stale-response" });
|
|
142
|
+
const privateCommands = yield* Effect.try({
|
|
143
|
+
try: () => snapshotRevealCommands((envelope.private ?? []).map(decodeRevealWire), route.reveals),
|
|
144
|
+
catch: () => OperationHttpError.make({ reason: "private-output" })
|
|
145
|
+
});
|
|
146
|
+
const now = DateTime.toEpochMillis(yield* DateTime.now);
|
|
147
|
+
if (privateCommands.some((command) => command.expiresAtMillis <= now || command.expiresAtMillis > now + 3e5)) return yield* OperationHttpError.make({ reason: "private-output" });
|
|
148
|
+
if (privateCommands.length > 0 && options.privateOutput === void 0) return yield* OperationHttpError.make({ reason: "private-output" });
|
|
149
|
+
if (options.native !== void 0) {
|
|
150
|
+
const commands = [];
|
|
151
|
+
for (const slot of credentialSlots) {
|
|
152
|
+
const raw = response.headers.get(options.native.responseHeaders[slot]);
|
|
153
|
+
if (raw === null) continue;
|
|
154
|
+
if (!route.operation.credentials) return yield* OperationHttpError.make({ reason: "credentials" });
|
|
155
|
+
const command = yield* Schema.decodeEffect(credentialCodec)(raw).pipe(Effect.mapError(() => OperationHttpError.make({ reason: "response" })));
|
|
156
|
+
if (command._tag === "Issue" && command.expiresAtMillis <= now) return yield* OperationHttpError.make({ reason: "credentials" });
|
|
157
|
+
commands.push(command._tag === "Clear" ? {
|
|
158
|
+
_tag: "Clear",
|
|
159
|
+
slot
|
|
160
|
+
} : {
|
|
161
|
+
...command,
|
|
162
|
+
slot,
|
|
163
|
+
credential: Redacted.make(command.credential)
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
if (commands.length > 0) yield* options.native.accept(commands);
|
|
167
|
+
}
|
|
168
|
+
const projectSubject = callOptions?.replaceSubject;
|
|
169
|
+
if (typeof projectSubject === "function" ? yield* Effect.try({
|
|
170
|
+
try: () => projectSubject(value),
|
|
171
|
+
catch: () => OperationHttpError.make({ reason: "response" })
|
|
172
|
+
}) : projectSubject === true) {
|
|
173
|
+
yield* advance;
|
|
174
|
+
if (callOptions?.onTransition !== void 0) yield* callOptions.onTransition;
|
|
175
|
+
}
|
|
176
|
+
if (privateCommands.length > 0) yield* options.privateOutput.accept(privateCommands);
|
|
177
|
+
return value;
|
|
178
|
+
});
|
|
179
|
+
return yield* route.operation.credentials || route.operation.reveals.length > 0 || callOptions?.replaceSubject !== void 0 && callOptions.replaceSubject !== false ? gate.withPermits(1)(Effect.uninterruptible(work)) : work;
|
|
180
|
+
}),
|
|
181
|
+
transition: gate.withPermits(1)(advance),
|
|
182
|
+
generation: Effect.sync(() => generation)
|
|
183
|
+
};
|
|
184
|
+
});
|
|
185
|
+
//#endregion
|
|
186
|
+
export { make, makeAuthenticationCompletion };
|
|
187
|
+
|
|
188
|
+
//# sourceMappingURL=client.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.mjs","names":[],"sources":["../../src/http-operation/client.ts"],"sourcesContent":["import { DateTime, Effect, Redacted, Schema, Semaphore } from \"effect\";\n\nimport type { AuthCredentialCommand, CredentialSlot } from \"../operations/credentials\";\nimport { snapshotRevealCommands, type AuthRevealCommandCollector } from \"../operations/reveals\";\nimport { headerName } from \"./configuration-schema\";\nimport {\n type AnyRoute,\n HttpRequestBody,\n type RouteFailure,\n type RouteInput,\n type RouteSuccess,\n} from \"./contract\";\nimport { OperationHttpError } from \"./errors\";\nimport type { HttpCredentials } from \"./models\";\nimport { CredentialWire, RevealWire, credentialSlots, decodeRevealWire } from \"./private\";\n\nexport interface OperationFetchOptions {\n readonly baseUrl: string;\n readonly csrfHeader: string;\n readonly csrfValue: string;\n readonly maximumResponseBytes?: number;\n readonly fetch?: typeof globalThis.fetch;\n readonly privateOutput?: AuthRevealCommandCollector & { readonly clear: Effect.Effect<void> };\n readonly native?: {\n readonly modeHeader: string;\n readonly requestHeaders: Readonly<Record<CredentialSlot, string>>;\n readonly responseHeaders: Readonly<Record<CredentialSlot, string>>;\n readonly read: Effect.Effect<HttpCredentials, OperationHttpError>;\n readonly accept: (\n commands: ReadonlyArray<AuthCredentialCommand>,\n ) => Effect.Effect<void, OperationHttpError>;\n };\n}\n\nexport interface OperationCallOptions<Success = unknown> {\n readonly replaceSubject?: boolean | ((success: Success) => boolean);\n /** Runs inside credential admission after fencing old responses. The callback\n * must not call this client's transition or start another credential call. */\n readonly onTransition?: Effect.Effect<void>;\n}\n\nexport interface OperationFetchClient {\n readonly call: <R extends AnyRoute>(\n route: R,\n input: RouteInput<R>,\n options?: OperationCallOptions<RouteSuccess<R>>,\n ) => Effect.Effect<\n RouteSuccess<R>,\n RouteFailure<R> | OperationHttpError,\n | R[\"operation\"][\"rpc\"][\"successSchema\"][\"DecodingServices\"]\n | R[\"operation\"][\"rpc\"][\"errorSchema\"][\"DecodingServices\"]\n >;\n /** Wait for admitted credential responses, then fence old queries and clear reveals.\n * All authenticated subject changes for this client must pass this boundary. */\n readonly transition: Effect.Effect<void>;\n readonly generation: Effect.Effect<number>;\n}\n\n/** Complete an authentication operation and publish its subject while its\n * credential response remains admitted. Undefined preserves a pending flow. */\nexport interface OperationAuthenticationCompletion {\n <R extends AnyRoute>(\n route: R,\n input: RouteInput<R>,\n fromSuccess: (success: RouteSuccess<R>) => string | null | undefined,\n options?: { readonly onTransition?: Effect.Effect<void> },\n ): Effect.Effect<\n RouteSuccess<R>,\n RouteFailure<R> | OperationHttpError,\n | R[\"operation\"][\"rpc\"][\"successSchema\"][\"DecodingServices\"]\n | R[\"operation\"][\"rpc\"][\"errorSchema\"][\"DecodingServices\"]\n >;\n}\n\n/** The caller owns the lifecycle gate and publisher. Publishers must not call\n * the transport: they run under credential admission, before reveal acceptance. */\nexport const makeAuthenticationCompletion = (\n client: OperationFetchClient,\n gate: Semaphore.Semaphore,\n publishSubject: (subject: string | null) => Effect.Effect<void>,\n): OperationAuthenticationCompletion =>\n Effect.fn(\"OperationHttpClient.completeAuthentication\")(function* <R extends AnyRoute>(\n route: R,\n input: RouteInput<R>,\n fromSuccess: (success: RouteSuccess<R>) => string | null | undefined,\n options?: { readonly onTransition?: Effect.Effect<void> },\n ) {\n const started = yield* client.generation;\n\n return yield* gate.withPermits(1)(\n Effect.gen(function* () {\n if ((yield* client.generation) !== started)\n return yield* OperationHttpError.make({ reason: \"stale-response\" });\n\n return yield* Effect.uninterruptible(\n Effect.gen(function* () {\n let nextSubject: string | null | undefined;\n\n return yield* client.call(route, input, {\n replaceSubject: (value) => {\n nextSubject = fromSuccess(value);\n\n return nextSubject !== undefined;\n },\n onTransition: Effect.suspend(() =>\n nextSubject === undefined\n ? Effect.void\n : publishSubject(nextSubject).pipe(\n Effect.andThen(options?.onTransition ?? Effect.void),\n ),\n ),\n });\n }).pipe(\n // A failed response can follow a cookie already accepted by the\n // browser. Remove the old account state without replaying the call.\n Effect.onError(() =>\n Effect.gen(function* () {\n yield* client.transition;\n yield* publishSubject(null);\n yield* options?.onTransition ?? Effect.void;\n }),\n ),\n ),\n );\n }),\n );\n });\n\nconst responseCodec = Schema.fromJsonString(\n Schema.Union([\n Schema.TaggedStruct(\"Success\", {\n value: Schema.optionalKey(Schema.Json),\n private: Schema.optionalKey(Schema.Array(RevealWire)),\n }),\n Schema.TaggedStruct(\"Failure\", { error: Schema.Json }),\n Schema.TaggedStruct(\"TransportFailure\", { reason: Schema.String }),\n ]),\n);\n\nconst credentialCodec = Schema.fromJsonString(CredentialWire);\nconst requestCodec = Schema.fromJsonString(HttpRequestBody);\n\nconst readBody = (response: Response, maximum: number) =>\n Effect.tryPromise({\n try: async (signal) => {\n if (response.body === null) return \"\";\n const reader = response.body.getReader();\n const chunks: Uint8Array[] = [];\n let size = 0;\n\n const abort = () => {\n void reader.cancel();\n };\n\n signal.addEventListener(\"abort\", abort, { once: true });\n try {\n while (true) {\n const part = await reader.read();\n\n if (part.done) break;\n size += part.value.length;\n if (size > maximum) {\n await reader.cancel();\n throw new Error();\n }\n chunks.push(part.value);\n }\n const bytes = new Uint8Array(size);\n let offset = 0;\n\n for (const chunk of chunks) {\n bytes.set(chunk, offset);\n offset += chunk.length;\n }\n\n return new TextDecoder(\"utf-8\", { fatal: true }).decode(bytes);\n } finally {\n signal.removeEventListener(\"abort\", abort);\n reader.releaseLock();\n }\n },\n catch: () => OperationHttpError.make({ reason: \"response\" }),\n });\n\n/** One instance owns credential ordering and stale-result fencing. Share it within\n * a browser authentication lifetime; mutations are never automatically retried. */\nexport const make = Effect.fn(\"OperationHttpClient.make\")(function* (\n options: OperationFetchOptions,\n): Effect.fn.Return<OperationFetchClient, OperationHttpError> {\n const base = yield* Effect.try({\n try: () => new URL(options.baseUrl),\n catch: () => OperationHttpError.make({ reason: \"request\" }),\n });\n\n if (\n !Number.isSafeInteger(options.maximumResponseBytes ?? 1048576) ||\n (options.maximumResponseBytes ?? 1048576) < 1 ||\n (options.maximumResponseBytes ?? 1048576) > 1048576 ||\n !/^x-[a-z0-9-]{1,61}$/.test(options.csrfHeader) ||\n options.csrfValue.length < 1 ||\n options.csrfValue.length > 128 ||\n ![\"https:\", \"http:\"].includes(base.protocol) ||\n base.username !== \"\" ||\n base.password !== \"\" ||\n base.search !== \"\" ||\n base.hash !== \"\"\n )\n return yield* OperationHttpError.make({ reason: \"request\" });\n if (options.native !== undefined) {\n const names = [\n options.native.modeHeader,\n ...credentialSlots.map((slot) => options.native!.requestHeaders[slot]),\n ];\n\n const response = credentialSlots.map((slot) => options.native!.responseHeaders[slot]);\n\n if (\n [...names, ...response].some((name) => !Schema.is(headerName)(name)) ||\n new Set(names).size !== names.length ||\n new Set(response).size !== response.length ||\n names.includes(options.csrfHeader)\n )\n return yield* OperationHttpError.make({ reason: \"request\" });\n }\n const gate = yield* Semaphore.make(1);\n let generation = 0;\n\n const advance = Effect.gen(function* () {\n generation++;\n if (options.privateOutput !== undefined) yield* options.privateOutput.clear;\n });\n\n const call = Effect.fn(\"OperationHttpClient.call\")(function* <R extends AnyRoute>(\n route: R,\n input: RouteInput<R>,\n callOptions?: OperationCallOptions<RouteSuccess<R>>,\n ): Effect.fn.Return<\n RouteSuccess<R>,\n RouteFailure<R> | OperationHttpError,\n | R[\"operation\"][\"rpc\"][\"successSchema\"][\"DecodingServices\"]\n | R[\"operation\"][\"rpc\"][\"errorSchema\"][\"DecodingServices\"]\n > {\n const started = generation;\n\n const services = yield* Effect.context<\n | R[\"operation\"][\"rpc\"][\"successSchema\"][\"DecodingServices\"]\n | R[\"operation\"][\"rpc\"][\"errorSchema\"][\"DecodingServices\"]\n >();\n\n type DecoderServices =\n | R[\"operation\"][\"rpc\"][\"successSchema\"][\"DecodingServices\"]\n | R[\"operation\"][\"rpc\"][\"errorSchema\"][\"DecodingServices\"];\n\n // The route generic retains the exact schemas while heterogeneous property\n // access widens them to Rpc.AnyWithProps. Restore that relationship locally.\n const successSchema = route.operation.rpc.successSchema as Schema.Codec<\n RouteSuccess<R>,\n unknown,\n DecoderServices,\n unknown\n >;\n\n const errorSchema = route.operation.rpc.errorSchema as Schema.Codec<\n RouteFailure<R>,\n unknown,\n DecoderServices,\n unknown\n >;\n\n if (\n route.operation.reveals.some(\n (kind) =>\n options.privateOutput === undefined ||\n !options.privateOutput.supportedKinds.includes(kind) ||\n !route.reveals.includes(kind),\n )\n )\n return yield* OperationHttpError.make({ reason: \"private-output\" });\n\n const work = Effect.gen(function* () {\n if (started !== generation)\n return yield* OperationHttpError.make({ reason: \"stale-response\" });\n\n const payload =\n input === undefined\n ? undefined\n : // oxlint-disable-next-line no-restricted-properties -- untyped input is validated for JSON transport compatibility.\n yield* Schema.decodeUnknownEffect(Schema.Json)(input).pipe(\n Effect.mapError(() => OperationHttpError.make({ reason: \"request\" })),\n );\n\n const body = yield* Schema.encodeEffect(requestCodec)(\n payload === undefined ? {} : { payload },\n ).pipe(Effect.mapError(() => OperationHttpError.make({ reason: \"request\" })));\n\n if (route.method === \"GET\" && input !== undefined)\n return yield* OperationHttpError.make({ reason: \"request\" });\n\n const headers = new Headers(\n route.method === \"GET\"\n ? {}\n : {\n \"content-type\": \"application/json\",\n [options.csrfHeader]: options.csrfValue,\n },\n );\n\n if (options.native !== undefined) {\n headers.set(options.native.modeHeader, \"native\");\n const credentials = yield* options.native.read;\n\n for (const slot of credentialSlots)\n if (credentials[slot] !== undefined)\n headers.set(options.native.requestHeaders[slot], Redacted.value(credentials[slot]!));\n }\n const destination = new URL(route.path, base);\n\n const response = yield* Effect.tryPromise({\n try: (signal) => {\n // Native credential reads and schema services may suspend. Admission\n // and fetch dispatch share this synchronous check so an old workflow\n // cannot send a write with a newly installed subject's credentials.\n if (started !== generation) throw OperationHttpError.make({ reason: \"stale-response\" });\n\n return (options.fetch ?? globalThis.fetch)(destination, {\n method: route.method,\n headers,\n ...(route.method === \"GET\" ? {} : { body }),\n credentials: options.native === undefined ? \"include\" : \"omit\",\n redirect: \"error\",\n signal,\n });\n },\n catch: (error) =>\n Schema.is(OperationHttpError)(error)\n ? error\n : OperationHttpError.make({ reason: \"network\" }),\n });\n\n if (\n response.headers.get(\"content-type\")?.split(\";\")[0]?.trim().toLowerCase() !==\n \"application/json\"\n )\n return yield* OperationHttpError.make({ reason: \"response\" });\n\n const envelope = yield* Schema.decodeEffect(responseCodec)(\n yield* readBody(response, options.maximumResponseBytes ?? 1048576),\n ).pipe(Effect.mapError(() => OperationHttpError.make({ reason: \"response\" })));\n\n if (started !== generation)\n return yield* OperationHttpError.make({ reason: \"stale-response\" });\n if (envelope._tag === \"TransportFailure\")\n return yield* OperationHttpError.make({\n reason:\n envelope.reason === \"origin\" ||\n envelope.reason === \"csrf\" ||\n envelope.reason === \"credentials\" ||\n envelope.reason === \"private-output\"\n ? envelope.reason\n : \"response\",\n });\n if (envelope._tag === \"Failure\") {\n const failure = yield* Schema.decodeEffect(errorSchema)(envelope.error).pipe(\n Effect.provide(services),\n Effect.mapError(() => OperationHttpError.make({ reason: \"response\" })),\n );\n\n return yield* Effect.fail(failure as RouteFailure<R>);\n }\n if (!response.ok) return yield* OperationHttpError.make({ reason: \"response\" });\n\n const value = yield* Schema.decodeEffect(successSchema)(envelope.value).pipe(\n Effect.provide(services),\n Effect.mapError(() => OperationHttpError.make({ reason: \"response\" })),\n );\n\n if (started !== generation)\n return yield* OperationHttpError.make({ reason: \"stale-response\" });\n\n const privateCommands = yield* Effect.try({\n try: () =>\n snapshotRevealCommands((envelope.private ?? []).map(decodeRevealWire), route.reveals),\n catch: () => OperationHttpError.make({ reason: \"private-output\" }),\n });\n\n const now = DateTime.toEpochMillis(yield* DateTime.now);\n\n if (\n privateCommands.some(\n (command) => command.expiresAtMillis <= now || command.expiresAtMillis > now + 300_000,\n )\n )\n return yield* OperationHttpError.make({ reason: \"private-output\" });\n if (privateCommands.length > 0 && options.privateOutput === undefined)\n return yield* OperationHttpError.make({ reason: \"private-output\" });\n if (options.native !== undefined) {\n const commands: AuthCredentialCommand[] = [];\n\n for (const slot of credentialSlots) {\n const raw = response.headers.get(options.native.responseHeaders[slot]);\n\n if (raw === null) continue;\n if (!route.operation.credentials)\n return yield* OperationHttpError.make({ reason: \"credentials\" });\n\n const command = yield* Schema.decodeEffect(credentialCodec)(raw).pipe(\n Effect.mapError(() => OperationHttpError.make({ reason: \"response\" })),\n );\n\n if (command._tag === \"Issue\" && command.expiresAtMillis <= now)\n return yield* OperationHttpError.make({ reason: \"credentials\" });\n commands.push(\n command._tag === \"Clear\"\n ? { _tag: \"Clear\", slot }\n : { ...command, slot, credential: Redacted.make(command.credential) },\n );\n }\n if (commands.length > 0) yield* options.native.accept(commands);\n }\n const projectSubject = callOptions?.replaceSubject;\n\n const replaceSubject =\n typeof projectSubject === \"function\"\n ? yield* Effect.try({\n try: () => projectSubject(value as RouteSuccess<R>),\n catch: () => OperationHttpError.make({ reason: \"response\" }),\n })\n : projectSubject === true;\n\n if (replaceSubject) {\n yield* advance;\n if (callOptions?.onTransition !== undefined) yield* callOptions.onTransition;\n }\n if (privateCommands.length > 0) yield* options.privateOutput!.accept(privateCommands);\n\n return value as RouteSuccess<R>;\n });\n\n // Once a credential response is admitted it must settle before the lifetime\n // advances: browsers apply Set-Cookie before JavaScript can inspect a response.\n return yield* route.operation.credentials ||\n route.operation.reveals.length > 0 ||\n (callOptions?.replaceSubject !== undefined && callOptions.replaceSubject !== false)\n ? gate.withPermits(1)(Effect.uninterruptible(work))\n : work;\n });\n\n return {\n call,\n transition: gate.withPermits(1)(advance),\n generation: Effect.sync(() => generation),\n };\n});\n"],"mappings":";;;;;;;;;;AA4EA,MAAa,gCACX,QACA,MACA,mBAEA,OAAO,GAAG,4CAA4C,CAAC,CAAC,WACtD,OACA,OACA,aACA,SACA;CACA,MAAM,UAAU,OAAO,OAAO;CAE9B,OAAO,OAAO,KAAK,YAAY,CAAC,CAAC,CAC/B,OAAO,IAAI,aAAa;EACtB,KAAK,OAAO,OAAO,gBAAgB,SACjC,OAAO,OAAO,mBAAmB,KAAK,EAAE,QAAQ,iBAAiB,CAAC;EAEpE,OAAO,OAAO,OAAO,gBACnB,OAAO,IAAI,aAAa;GACtB,IAAI;GAEJ,OAAO,OAAO,OAAO,KAAK,OAAO,OAAO;IACtC,iBAAiB,UAAU;KACzB,cAAc,YAAY,KAAK;KAE/B,OAAO,gBAAgB,KAAA;IACzB;IACA,cAAc,OAAO,cACnB,gBAAgB,KAAA,IACZ,OAAO,OACP,eAAe,WAAW,CAAC,CAAC,KAC1B,OAAO,QAAQ,SAAS,gBAAgB,OAAO,IAAI,CACrD,CACN;GACF,CAAC;EACH,CAAC,CAAC,CAAC,KAGD,OAAO,cACL,OAAO,IAAI,aA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AAY,CAAC,CAAC,CAAC,OAAO,gBAAgB,IAAI,CAAC,IAChD;EACN,CAGK;EACH,YAAY,KAAK,YAAY,CAAC,CAAC,CAAC,OAAO;EACvC,YAAY,OAAO,WAAW,UAAU;CAC1C;AACF,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
//#region src/http-operation/configuration-schema.ts
|
|
3
|
+
const headerName = Schema.String.check(Schema.isPattern(/^x-[a-z0-9-]{1,61}$/));
|
|
4
|
+
const origin = Schema.String.check(Schema.makeFilter((value) => {
|
|
5
|
+
try {
|
|
6
|
+
const url = new URL(value);
|
|
7
|
+
return url.origin === value && (url.protocol === "https:" || url.protocol === "http:" && [
|
|
8
|
+
"localhost",
|
|
9
|
+
"127.0.0.1",
|
|
10
|
+
"[::1]"
|
|
11
|
+
].includes(url.hostname));
|
|
12
|
+
} catch {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
}));
|
|
16
|
+
//#endregion
|
|
17
|
+
export { headerName, origin };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=configuration-schema.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configuration-schema.mjs","names":[],"sources":["../../src/http-operation/configuration-schema.ts"],"sourcesContent":["import { Schema } from \"effect\";\n\nexport const headerName = Schema.String.check(Schema.isPattern(/^x-[a-z0-9-]{1,61}$/));\n\nexport const origin = Schema.String.check(\n Schema.makeFilter((value) => {\n try {\n const url = new URL(value);\n\n return (\n url.origin === value &&\n (url.protocol === \"https:\" ||\n (url.protocol === \"http:\" && [\"localhost\", \"127.0.0.1\", \"[::1]\"].includes(url.hostname)))\n );\n } catch {\n return false;\n }\n }),\n);\n"],"mappings":";;AAEA,MAAa,aAAa,OAAO,OAAO,MAAM,OAAO,UAAU,qBAAqB,CAAC;AAErF,MAAa,SAAS,OAAO,OAAO,MAClC,OAAO,YAAY,UAAU;CAC3B,IAAI;EACF,MAAM,MAAM,IAAI,IAAI,KAAK;EAEzB,OACE,IAAI,WAAW,UACd,IAAI,aAAa,YACf,IAAI,aAAa,WAAW;GAAC;GAAa;GAAa;EAAO,CAAC,CAAC,SAAS,IAAI,QAAQ;CAE5F,QAAQ;EACN,OAAO;CACT;AACF,CAAC,CACH"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { AuthInvocation } from "../operations/context.mjs";
|
|
2
|
+
import { AuthRevealKind } from "../operations/reveals.mjs";
|
|
3
|
+
import { CredentialSlot } from "../operations/credentials.mjs";
|
|
4
|
+
import { OperationExposure, OperationReplay } from "../operations/operation.mjs";
|
|
5
|
+
import { Effect, Schema } from "effect";
|
|
6
|
+
import { Rpc } from "effect/unstable/rpc";
|
|
7
|
+
//#region src/http-operation/contract.d.ts
|
|
8
|
+
interface HttpOperation {
|
|
9
|
+
readonly rpc: Rpc.AnyWithProps;
|
|
10
|
+
readonly exposure: OperationExposure;
|
|
11
|
+
readonly replay: OperationReplay;
|
|
12
|
+
readonly credentials: boolean;
|
|
13
|
+
readonly reveals: ReadonlyArray<AuthRevealKind>;
|
|
14
|
+
readonly invokeUnknown: (invocation: AuthInvocation, input: unknown) => Effect.Effect<unknown, unknown, unknown>;
|
|
15
|
+
}
|
|
16
|
+
type CredentialFields<O extends HttpOperation> = Readonly<Partial<Record<Extract<keyof O["rpc"]["payloadSchema"]["Encoded"], string>, CredentialSlot>>>;
|
|
17
|
+
interface OperationHttpRoute<O extends HttpOperation, Fields extends Readonly<Record<string, CredentialSlot>> = Record<never, never>, Method extends "POST" | "GET" = "POST"> {
|
|
18
|
+
readonly operation: O;
|
|
19
|
+
readonly path: string;
|
|
20
|
+
readonly method: Method;
|
|
21
|
+
readonly credentials: Fields;
|
|
22
|
+
readonly reveals: ReadonlyArray<AuthRevealKind>;
|
|
23
|
+
}
|
|
24
|
+
declare const route: <O extends HttpOperation, const Fields extends Readonly<Record<string, CredentialSlot>> = Record<never, never>>(operation: O, options: {
|
|
25
|
+
readonly path: string;
|
|
26
|
+
readonly credentials?: Fields & Record<Exclude<keyof Fields, Extract<keyof O["rpc"]["payloadSchema"]["Encoded"], string>>, never>;
|
|
27
|
+
readonly allowInternal?: true;
|
|
28
|
+
readonly reveals?: ReadonlyArray<AuthRevealKind>;
|
|
29
|
+
}) => OperationHttpRoute<O, NoInfer<Fields>>;
|
|
30
|
+
type AnyRoute = OperationHttpRoute<HttpOperation, Readonly<Record<string, CredentialSlot>>, "POST" | "GET">;
|
|
31
|
+
type RouteInput<R extends AnyRoute> = keyof R["credentials"] extends never ? R["operation"]["rpc"]["payloadSchema"]["Encoded"] : Omit<R["operation"]["rpc"]["payloadSchema"]["Encoded"], keyof R["credentials"]>;
|
|
32
|
+
type RouteSuccess<R extends AnyRoute> = R["operation"]["rpc"]["successSchema"]["Type"];
|
|
33
|
+
type RouteFailure<R extends AnyRoute> = R["operation"]["rpc"]["errorSchema"]["Type"];
|
|
34
|
+
type RouteRequirements<R extends AnyRoute> = Effect.Services<ReturnType<R["operation"]["invokeUnknown"]>> | R["operation"]["rpc"]["successSchema"]["EncodingServices"] | R["operation"]["rpc"]["errorSchema"]["EncodingServices"];
|
|
35
|
+
declare const make: <const Routes extends Readonly<Record<string, AnyRoute>>>(routes: Routes) => Readonly<{
|
|
36
|
+
routes: Routes;
|
|
37
|
+
}>;
|
|
38
|
+
//#endregion
|
|
39
|
+
export { AnyRoute, CredentialFields, HttpOperation, OperationHttpRoute, RouteFailure, RouteInput, RouteRequirements, RouteSuccess, make, route };
|
|
40
|
+
//# sourceMappingURL=contract.d.mts.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { OperationHttpConfigurationError } from "./errors.mjs";
|
|
2
|
+
import { Schema } from "effect";
|
|
3
|
+
//#region src/http-operation/contract.ts
|
|
4
|
+
const route = (operation, options) => {
|
|
5
|
+
if (!Schema.is(Schema.String.check(Schema.isPattern(/^\/(?:[A-Za-z0-9_-]+\/?)*$/)))(options.path)) throw OperationHttpConfigurationError.make({ reason: "route" });
|
|
6
|
+
if (operation.exposure !== "public" && options.allowInternal !== true) throw OperationHttpConfigurationError.make({ reason: "internal-operation" });
|
|
7
|
+
const reveals = [...options.reveals ?? []];
|
|
8
|
+
if (new Set(reveals).size !== reveals.length || reveals.some((kind) => !operation.reveals.includes(kind))) throw OperationHttpConfigurationError.make({ reason: "credentials" });
|
|
9
|
+
return Object.freeze({
|
|
10
|
+
operation,
|
|
11
|
+
path: options.path,
|
|
12
|
+
method: "POST",
|
|
13
|
+
credentials: Object.freeze({ ...options.credentials }),
|
|
14
|
+
reveals: Object.freeze(reveals)
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
const make = (routes) => {
|
|
18
|
+
const paths = /* @__PURE__ */ new Set();
|
|
19
|
+
const tags = /* @__PURE__ */ new Set();
|
|
20
|
+
for (const value of Object.values(routes)) {
|
|
21
|
+
if (paths.has(value.path)) throw OperationHttpConfigurationError.make({ reason: "duplicate-route" });
|
|
22
|
+
if (tags.has(value.operation.rpc._tag)) throw OperationHttpConfigurationError.make({ reason: "duplicate-operation" });
|
|
23
|
+
paths.add(value.path);
|
|
24
|
+
tags.add(value.operation.rpc._tag);
|
|
25
|
+
}
|
|
26
|
+
return Object.freeze({ routes: Object.freeze({ ...routes }) });
|
|
27
|
+
};
|
|
28
|
+
const HttpRequestBody = Schema.Struct({ payload: Schema.optionalKey(Schema.Json) });
|
|
29
|
+
Schema.Union([
|
|
30
|
+
Schema.TaggedStruct("Success", { value: Schema.optionalKey(Schema.Json) }),
|
|
31
|
+
Schema.TaggedStruct("Failure", { error: Schema.Json }),
|
|
32
|
+
Schema.TaggedStruct("TransportFailure", { reason: Schema.String })
|
|
33
|
+
]);
|
|
34
|
+
//#endregion
|
|
35
|
+
export { HttpRequestBody, make, route };
|
|
36
|
+
|
|
37
|
+
//# sourceMappingURL=contract.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract.mjs","names":[],"sources":["../../src/http-operation/contract.ts"],"sourcesContent":["import type { Effect } from \"effect\";\nimport { Schema } from \"effect\";\nimport type { Rpc } from \"effect/unstable/rpc\";\n\nimport type { AuthInvocation } from \"../operations/context\";\nimport type { CredentialSlot } from \"../operations/credentials\";\nimport type { OperationExposure, OperationReplay } from \"../operations/operation\";\nimport type { AuthRevealKind } from \"../operations/reveals\";\nimport { OperationHttpConfigurationError } from \"./errors\";\n\nexport interface HttpOperation {\n readonly rpc: Rpc.AnyWithProps;\n readonly exposure: OperationExposure;\n readonly replay: OperationReplay;\n readonly credentials: boolean;\n readonly reveals: ReadonlyArray<AuthRevealKind>;\n readonly invokeUnknown: (\n invocation: AuthInvocation,\n input: unknown,\n ) => Effect.Effect<unknown, unknown, unknown>;\n}\n\nexport type CredentialFields<O extends HttpOperation> = Readonly<\n Partial<Record<Extract<keyof O[\"rpc\"][\"payloadSchema\"][\"Encoded\"], string>, CredentialSlot>>\n>;\n\nexport interface OperationHttpRoute<\n O extends HttpOperation,\n Fields extends Readonly<Record<string, CredentialSlot>> = Record<never, never>,\n Method extends \"POST\" | \"GET\" = \"POST\",\n> {\n readonly operation: O;\n readonly path: string;\n readonly method: Method;\n readonly credentials: Fields;\n readonly reveals: ReadonlyArray<AuthRevealKind>;\n}\n\nexport const route = <\n O extends HttpOperation,\n const Fields extends Readonly<Record<string, CredentialSlot>> = Record<never, never>,\n>(\n operation: O,\n options: {\n readonly path: string;\n readonly credentials?: Fields &\n Record<\n Exclude<keyof Fields, Extract<keyof O[\"rpc\"][\"payloadSchema\"][\"Encoded\"], string>>,\n never\n >;\n readonly allowInternal?: true;\n readonly reveals?: ReadonlyArray<AuthRevealKind>;\n },\n): OperationHttpRoute<O, NoInfer<Fields>> => {\n if (!Schema.is(Schema.String.check(Schema.isPattern(/^\\/(?:[A-Za-z0-9_-]+\\/?)*$/)))(options.path))\n throw OperationHttpConfigurationError.make({ reason: \"route\" });\n if (operation.exposure !== \"public\" && options.allowInternal !== true)\n throw OperationHttpConfigurationError.make({ reason: \"internal-operation\" });\n const reveals = [...(options.reveals ?? [])];\n\n if (\n new Set(reveals).size !== reveals.length ||\n reveals.some((kind) => !operation.reveals.includes(kind))\n )\n throw OperationHttpConfigurationError.make({ reason: \"credentials\" });\n\n return Object.freeze({\n operation,\n path: options.path,\n method: \"POST\",\n credentials: Object.freeze({ ...options.credentials }) as Fields,\n reveals: Object.freeze(reveals),\n });\n};\n\nexport type AnyRoute = OperationHttpRoute<\n HttpOperation,\n Readonly<Record<string, CredentialSlot>>,\n \"POST\" | \"GET\"\n>;\n\nexport type RouteInput<R extends AnyRoute> = keyof R[\"credentials\"] extends never\n ? R[\"operation\"][\"rpc\"][\"payloadSchema\"][\"Encoded\"]\n : Omit<R[\"operation\"][\"rpc\"][\"payloadSchema\"][\"Encoded\"], keyof R[\"credentials\"]>;\n\nexport type RouteSuccess<R extends AnyRoute> = R[\"operation\"][\"rpc\"][\"successSchema\"][\"Type\"];\nexport type RouteFailure<R extends AnyRoute> = R[\"operation\"][\"rpc\"][\"errorSchema\"][\"Type\"];\n\nexport type RouteRequirements<R extends AnyRoute> =\n | Effect.Services<ReturnType<R[\"operation\"][\"invokeUnknown\"]>>\n | R[\"operation\"][\"rpc\"][\"successSchema\"][\"EncodingServices\"]\n | R[\"operation\"][\"rpc\"][\"errorSchema\"][\"EncodingServices\"];\n\nexport const make = <const Routes extends Readonly<Record<string, AnyRoute>>>(routes: Routes) => {\n const paths = new Set<string>();\n const tags = new Set<string>();\n\n for (const value of Object.values(routes)) {\n if (paths.has(value.path))\n throw OperationHttpConfigurationError.make({ reason: \"duplicate-route\" });\n if (tags.has(value.operation.rpc._tag))\n throw OperationHttpConfigurationError.make({ reason: \"duplicate-operation\" });\n paths.add(value.path);\n tags.add(value.operation.rpc._tag);\n }\n\n return Object.freeze({ routes: Object.freeze({ ...routes }) as Routes });\n};\n\nexport const HttpRequestBody = Schema.Struct({ payload: Schema.optionalKey(Schema.Json) });\n\nexport const HttpResponseBody = Schema.Union([\n Schema.TaggedStruct(\"Success\", { value: Schema.optionalKey(Schema.Json) }),\n Schema.TaggedStruct(\"Failure\", { error: Schema.Json }),\n Schema.TaggedStruct(\"TransportFailure\", { reason: Schema.String }),\n]);\n"],"mappings":";;;AAsCA,MAAa,SAIX,WACA,YAU2C;CAC3C,IAAI,CAAC,OAAO,GAAG,OAAO,OAAO,MAAM,OAAO,UAAU,4BAA4B,CAAC,CAAC,CAAC,CAAC,QAAQ,IAAI,GAC9F,MAAM,gCAAgC,KAAK,EAAE,QAAQ,QAAQ,CAAC;CAChE,IAAI,UAAU,aAAa,YAAY,QAAQ,kBAAkB,MAC/D,MAAM,gCAAgC,KAAK,EAAE,QAAQ,qBAAqB,CAAC;CAC7E,MAAM,UAAU,CAAC,GAAI,QAAQ,WAAW,CAAC,CAAE;CAE3C,IACE,IAAI,IAAI,OAAO,CAAC,CAAC,SAAS,QAAQ,UAClC,QAAQ,MAAM,SAAS,CAAC,UAAU,QAAQ,SAAS,IAAI,CAAC,GAExD,MAAM,gCAAgC,KAAK,EAAE,QAAQ,cAAc,CAAC;CAEtE,OAAO,OAAO,OAAO;EACnB;EACA,MAAM,QAAQ;EACd,QAAQ;EACR,aAAa,OAAO,OAAO,EAAE,GAAG,QAAQ,YAAY,CAAC;EACrD,SAAS,OAAO,OAAO,OAAO;CAChC,CAAC;AACH;AAoBA,MAAa,QAAiE,WAAmB;CAC/F,MAAM,wBAAQ,IAAI,IAAY;CAC9B,MAAM,uBAAO,IAAI,IAAY;CAE7B,KAAK,MAAM,SAAS,OAAO,OAAO,MAAM,GAAG;EACzC,IAAI,MAAM,IAAI,MAAM,IAAI,GACtB,MAAM,gCAAgC,KAAK,EAAE,QAAQ,kBAAkB,CAAC;EAC1E,IAAI,KAAK,IAAI,MAAM,UAAU,IAAI,IAAI,GACnC,MAAM,gCAAgC,KAAK,EAAE,QAAQ,sBAAsB,CAAC;EAC9E,MAAM,IAAI,MAAM,IAAI;EACpB,KAAK,IAAI,MAAM,UAAU,IAAI,IAAI;CACnC;CAEA,OAAO,OAAO,OAAO,EAAE,QAAQ,OAAO,OAAO,EAAE,GAAG,OAAO,CAAC,EAAY,CAAC;AACzE;AAEA,MAAa,kBAAkB,OAAO,OAAO,EAAE,SAAS,OAAO,YAAY,OAAO,IAAI,EAAE,CAAC;AAEzD,OAAO,MAAM;CAC3C,OAAO,aAAa,WAAW,EAAE,OAAO,OAAO,YAAY,OAAO,IAAI,EAAE,CAAC;CACzE,OAAO,aAAa,WAAW,EAAE,OAAO,OAAO,KAAK,CAAC;CACrD,OAAO,aAAa,oBAAoB,EAAE,QAAQ,OAAO,OAAO,CAAC;AACnE,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
//#region src/http-operation/errors.d.ts
|
|
3
|
+
declare const OperationHttpConfigurationError_base: Schema.Class<OperationHttpConfigurationError, Schema.TaggedStruct<"OperationHttpConfigurationError", {
|
|
4
|
+
readonly reason: Schema.Literals<readonly ["route", "duplicate-route", "duplicate-operation", "internal-operation", "credentials", "cookies", "origin", "callback", "redirect"]>;
|
|
5
|
+
}>, import("effect/Cause").YieldableError>;
|
|
6
|
+
declare class OperationHttpConfigurationError extends OperationHttpConfigurationError_base {}
|
|
7
|
+
declare const OperationHttpError_base: Schema.Class<OperationHttpError, Schema.TaggedStruct<"OperationHttpError", {
|
|
8
|
+
readonly reason: Schema.Literals<readonly ["request", "not-found", "method", "origin", "csrf", "credentials", "too-large", "response", "network", "stale-response", "private-output", "unavailable"]>;
|
|
9
|
+
}>, import("effect/Cause").YieldableError>;
|
|
10
|
+
declare class OperationHttpError extends OperationHttpError_base {}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { OperationHttpConfigurationError, OperationHttpError };
|
|
13
|
+
//# sourceMappingURL=errors.d.mts.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
//#region src/http-operation/errors.ts
|
|
3
|
+
var OperationHttpConfigurationError = class extends Schema.TaggedError()("OperationHttpConfigurationError", { reason: Schema.Literals([
|
|
4
|
+
"route",
|
|
5
|
+
"duplicate-route",
|
|
6
|
+
"duplicate-operation",
|
|
7
|
+
"internal-operation",
|
|
8
|
+
"credentials",
|
|
9
|
+
"cookies",
|
|
10
|
+
"origin",
|
|
11
|
+
"callback",
|
|
12
|
+
"redirect"
|
|
13
|
+
]) }) {};
|
|
14
|
+
var OperationHttpError = class extends Schema.TaggedError()("OperationHttpError", { reason: Schema.Literals([
|
|
15
|
+
"request",
|
|
16
|
+
"not-found",
|
|
17
|
+
"method",
|
|
18
|
+
"origin",
|
|
19
|
+
"csrf",
|
|
20
|
+
"credentials",
|
|
21
|
+
"too-large",
|
|
22
|
+
"response",
|
|
23
|
+
"network",
|
|
24
|
+
"stale-response",
|
|
25
|
+
"private-output",
|
|
26
|
+
"unavailable"
|
|
27
|
+
]) }) {};
|
|
28
|
+
//#endregion
|
|
29
|
+
export { OperationHttpConfigurationError, OperationHttpError };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=errors.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.mjs","names":[],"sources":["../../src/http-operation/errors.ts"],"sourcesContent":["import { Schema } from \"effect\";\n\nexport class OperationHttpConfigurationError extends Schema.TaggedError<OperationHttpConfigurationError>()(\n \"OperationHttpConfigurationError\",\n {\n reason: Schema.Literals([\n \"route\",\n \"duplicate-route\",\n \"duplicate-operation\",\n \"internal-operation\",\n \"credentials\",\n \"cookies\",\n \"origin\",\n \"callback\",\n \"redirect\",\n ]),\n },\n) {}\n\nexport class OperationHttpError extends Schema.TaggedError<OperationHttpError>()(\n \"OperationHttpError\",\n {\n reason: Schema.Literals([\n \"request\",\n \"not-found\",\n \"method\",\n \"origin\",\n \"csrf\",\n \"credentials\",\n \"too-large\",\n \"response\",\n \"network\",\n \"stale-response\",\n \"private-output\",\n \"unavailable\",\n ]),\n },\n) {}\n"],"mappings":";;AAEA,IAAa,kCAAb,cAAqD,OAAO,YAA6C,CAAC,CACxG,mCACA,EACE,QAAQ,OAAO,SAAS;CACtB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,EACH,CACF,CAAC,CAAC,CAAC;AAEH,IAAa,qBAAb,cAAwC,OAAO,YAAgC,CAAC,CAC9E,sBACA,EACE,QAAQ,OAAO,SAAS;CACtB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,EACH,CACF,CAAC,CAAC,CAAC"}
|