@yielded/auth-persistence 0.1.0-beta.7
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/README.md +21 -0
- package/dist/Drizzle.d.mts +28 -0
- package/dist/Drizzle.mjs +28 -0
- package/dist/DrizzleD1.d.mts +963 -0
- package/dist/DrizzleD1.mjs +29 -0
- package/dist/DrizzleD1.mjs.map +1 -0
- package/dist/DrizzleLibsql.d.mts +2284 -0
- package/dist/DrizzleLibsql.mjs +92 -0
- package/dist/DrizzleLibsql.mjs.map +1 -0
- package/dist/DrizzleMysql2.d.mts +1820 -0
- package/dist/DrizzleMysql2.mjs +55 -0
- package/dist/DrizzleMysql2.mjs.map +1 -0
- package/dist/DrizzlePglite.d.mts +1826 -0
- package/dist/DrizzlePglite.mjs +53 -0
- package/dist/DrizzlePglite.mjs.map +1 -0
- package/dist/DrizzlePostgres.d.mts +1826 -0
- package/dist/DrizzlePostgres.mjs +53 -0
- package/dist/DrizzlePostgres.mjs.map +1 -0
- package/dist/DrizzleSqliteBun.d.mts +2279 -0
- package/dist/DrizzleSqliteBun.mjs +70 -0
- package/dist/DrizzleSqliteBun.mjs.map +1 -0
- package/dist/DrizzleSqliteDo.d.mts +2329 -0
- package/dist/DrizzleSqliteDo.mjs +105 -0
- package/dist/DrizzleSqliteDo.mjs.map +1 -0
- package/dist/DrizzleSqliteNode.d.mts +2279 -0
- package/dist/DrizzleSqliteNode.mjs +70 -0
- package/dist/DrizzleSqliteNode.mjs.map +1 -0
- package/dist/DrizzleSqliteWasm.d.mts +2282 -0
- package/dist/DrizzleSqliteWasm.mjs +70 -0
- package/dist/DrizzleSqliteWasm.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 +62 -0
- package/dist/drizzle/d1-emails.mjs +580 -0
- package/dist/drizzle/d1-emails.mjs.map +1 -0
- package/dist/drizzle/d1-generated-statement.d.mts +2 -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 +31 -0
- package/dist/drizzle/d1-identity.mjs +119 -0
- package/dist/drizzle/d1-identity.mjs.map +1 -0
- package/dist/drizzle/d1-oauth.d.mts +301 -0
- package/dist/drizzle/d1-oauth.mjs +76 -0
- package/dist/drizzle/d1-oauth.mjs.map +1 -0
- package/dist/drizzle/d1-passkey.d.mts +51 -0
- package/dist/drizzle/d1-passkey.mjs +95 -0
- package/dist/drizzle/d1-passkey.mjs.map +1 -0
- package/dist/drizzle/d1-password-prepared.d.mts +25 -0
- package/dist/drizzle/d1-password-prepared.mjs +461 -0
- package/dist/drizzle/d1-password-prepared.mjs.map +1 -0
- package/dist/drizzle/d1-passwords.d.mts +87 -0
- package/dist/drizzle/d1-passwords.mjs +1004 -0
- package/dist/drizzle/d1-passwords.mjs.map +1 -0
- package/dist/drizzle/d1-phone.d.mts +26 -0
- package/dist/drizzle/d1-phone.mjs +30 -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 +80 -0
- package/dist/drizzle/d1-proofs.mjs +830 -0
- package/dist/drizzle/d1-proofs.mjs.map +1 -0
- package/dist/drizzle/d1-sessions.d.mts +67 -0
- package/dist/drizzle/d1-sessions.mjs +966 -0
- package/dist/drizzle/d1-sessions.mjs.map +1 -0
- package/dist/drizzle/d1-totp.d.mts +26 -0
- package/dist/drizzle/d1-totp.mjs +27 -0
- package/dist/drizzle/d1-totp.mjs.map +1 -0
- package/dist/drizzle/email-model.d.mts +354 -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 +30 -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 +4 -0
- package/dist/drizzle/email-sql.mjs +9 -0
- package/dist/drizzle/email-sql.mjs.map +1 -0
- package/dist/drizzle/email-target.d.mts +20 -0
- package/dist/drizzle/email-target.mjs +72 -0
- package/dist/drizzle/email-target.mjs.map +1 -0
- package/dist/drizzle/model.d.mts +250 -0
- package/dist/drizzle/model.mjs +58 -0
- package/dist/drizzle/model.mjs.map +1 -0
- package/dist/drizzle/mysql-emails.d.mts +71 -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 +22 -0
- package/dist/drizzle/mysql-identity.mjs +94 -0
- package/dist/drizzle/mysql-identity.mjs.map +1 -0
- package/dist/drizzle/mysql-password-prepared.d.mts +30 -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 +86 -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 +75 -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 +237 -0
- package/dist/drizzle/mysql-sessions.mjs +53 -0
- package/dist/drizzle/mysql-sessions.mjs.map +1 -0
- package/dist/drizzle/mysql.d.mts +70 -0
- package/dist/drizzle/mysql.mjs +218 -0
- package/dist/drizzle/mysql.mjs.map +1 -0
- package/dist/drizzle/oauth-accounts.mjs +358 -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 +76 -0
- package/dist/drizzle/oauth-connected-drivers.mjs.map +1 -0
- package/dist/drizzle/oauth-connected-flow.mjs +247 -0
- package/dist/drizzle/oauth-connected-flow.mjs.map +1 -0
- package/dist/drizzle/oauth-connected-input.mjs +103 -0
- package/dist/drizzle/oauth-connected-input.mjs.map +1 -0
- package/dist/drizzle/oauth-connected-maintenance.mjs +214 -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 +14 -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 +753 -0
- package/dist/drizzle/oauth-connected-target.mjs +91 -0
- package/dist/drizzle/oauth-connected-target.mjs.map +1 -0
- package/dist/drizzle/oauth-drivers.mjs +51 -0
- package/dist/drizzle/oauth-drivers.mjs.map +1 -0
- package/dist/drizzle/oauth-flow.d.mts +5 -0
- package/dist/drizzle/oauth-flow.mjs +253 -0
- package/dist/drizzle/oauth-flow.mjs.map +1 -0
- package/dist/drizzle/oauth-input.mjs +127 -0
- package/dist/drizzle/oauth-input.mjs.map +1 -0
- package/dist/drizzle/oauth-model.d.mts +463 -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 +6 -0
- package/dist/drizzle/oauth-registration.mjs +374 -0
- package/dist/drizzle/oauth-registration.mjs.map +1 -0
- package/dist/drizzle/oauth-state.mjs +107 -0
- package/dist/drizzle/oauth-state.mjs.map +1 -0
- package/dist/drizzle/oauth-target.d.mts +111 -0
- package/dist/drizzle/oauth-target.mjs +246 -0
- package/dist/drizzle/oauth-target.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-kernel.mjs +8 -0
- package/dist/drizzle/passkey-kernel.mjs.map +1 -0
- package/dist/drizzle/passkey-model.d.mts +272 -0
- package/dist/drizzle/passkey-model.mjs +34 -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-state.mjs +7 -0
- package/dist/drizzle/passkey-state.mjs.map +1 -0
- package/dist/drizzle/passkey-target.d.mts +9 -0
- package/dist/drizzle/passkey-target.mjs +7 -0
- package/dist/drizzle/passkey-target.mjs.map +1 -0
- package/dist/drizzle/passkey-write-drivers.mjs +32 -0
- package/dist/drizzle/passkey-write-drivers.mjs.map +1 -0
- package/dist/drizzle/passkey-write-model.d.mts +190 -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-target.d.mts +11 -0
- package/dist/drizzle/passkey-write-target.mjs +7 -0
- package/dist/drizzle/passkey-write-target.mjs.map +1 -0
- package/dist/drizzle/password-model.d.mts +329 -0
- package/dist/drizzle/password-model.mjs +23 -0
- package/dist/drizzle/password-model.mjs.map +1 -0
- package/dist/drizzle/password-prepared-model.d.mts +94 -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 +390 -0
- package/dist/drizzle/password-prepared-sql.mjs.map +1 -0
- package/dist/drizzle/password-prepared-state.mjs +104 -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 +56 -0
- package/dist/drizzle/password-prepared-target.mjs.map +1 -0
- package/dist/drizzle/password-registration.d.mts +19 -0
- package/dist/drizzle/password-registration.mjs +135 -0
- package/dist/drizzle/password-registration.mjs.map +1 -0
- package/dist/drizzle/password-sql.d.mts +5 -0
- package/dist/drizzle/password-sql.mjs +9 -0
- package/dist/drizzle/password-sql.mjs.map +1 -0
- package/dist/drizzle/password-target.d.mts +17 -0
- package/dist/drizzle/password-target.mjs +61 -0
- package/dist/drizzle/password-target.mjs.map +1 -0
- package/dist/drizzle/pg-emails.d.mts +72 -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 +31 -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 +87 -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 +76 -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 +238 -0
- package/dist/drizzle/pg-sessions.mjs +53 -0
- package/dist/drizzle/pg-sessions.mjs.map +1 -0
- package/dist/drizzle/pg.d.mts +81 -0
- package/dist/drizzle/pg.mjs +290 -0
- package/dist/drizzle/pg.mjs.map +1 -0
- package/dist/drizzle/phone-model.d.mts +115 -0
- package/dist/drizzle/phone-model.mjs +39 -0
- package/dist/drizzle/phone-model.mjs.map +1 -0
- package/dist/drizzle/phone-state.mjs +16 -0
- package/dist/drizzle/phone-state.mjs.map +1 -0
- package/dist/drizzle/phone-target.d.mts +17 -0
- package/dist/drizzle/phone-target.mjs +170 -0
- package/dist/drizzle/phone-target.mjs.map +1 -0
- package/dist/drizzle/proof-model.d.mts +286 -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 +4 -0
- package/dist/drizzle/proof-sql.mjs +8 -0
- package/dist/drizzle/proof-sql.mjs.map +1 -0
- package/dist/drizzle/proof-target.d.mts +12 -0
- package/dist/drizzle/proof-target.mjs +36 -0
- package/dist/drizzle/proof-target.mjs.map +1 -0
- package/dist/drizzle/query-operations.mjs +26 -0
- package/dist/drizzle/query-operations.mjs.map +1 -0
- package/dist/drizzle/session-model.d.mts +200 -0
- package/dist/drizzle/session-model.mjs +20 -0
- package/dist/drizzle/session-model.mjs.map +1 -0
- package/dist/drizzle/session-sql.mjs +8 -0
- package/dist/drizzle/session-sql.mjs.map +1 -0
- package/dist/drizzle/session-target.d.mts +28 -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 +91 -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 +78 -0
- package/dist/drizzle/sqlite.mjs +217 -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 +32 -0
- package/dist/drizzle/step-up-state.mjs.map +1 -0
- package/dist/drizzle/totp-model.d.mts +84 -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 +38 -0
- package/dist/drizzle/totp-state.mjs +287 -0
- package/dist/drizzle/totp-state.mjs.map +1 -0
- package/dist/drizzle/totp-target.d.mts +17 -0
- package/dist/drizzle/totp-target.mjs +81 -0
- package/dist/drizzle/totp-target.mjs.map +1 -0
- package/dist/drizzle/transaction-execution.d.mts +4 -0
- package/dist/drizzle/transaction-execution.mjs +11 -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 +2 -0
- package/dist/drizzle/transaction-owner.mjs +8 -0
- package/dist/drizzle/transaction-owner.mjs.map +1 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.mjs +5 -0
- package/dist/internal/configuration.d.mts +174 -0
- package/dist/internal/configuration.mjs +7 -0
- package/dist/internal/configuration.mjs.map +1 -0
- package/dist/internal/drizzle-migrations.mjs +19 -0
- package/dist/internal/drizzle-migrations.mjs.map +1 -0
- package/dist/internal/drizzle-postgres.mjs +39 -0
- package/dist/internal/drizzle-postgres.mjs.map +1 -0
- package/dist/internal/drizzle-sqlite.mjs +37 -0
- package/dist/internal/drizzle-sqlite.mjs.map +1 -0
- package/dist/internal/email-kernel.d.mts +13 -0
- package/dist/internal/email-kernel.mjs +487 -0
- package/dist/internal/email-kernel.mjs.map +1 -0
- package/dist/internal/mapping-error.d.mts +11 -0
- package/dist/internal/mapping-error.mjs +30 -0
- package/dist/internal/mapping-error.mjs.map +1 -0
- package/dist/internal/passkey/admission.d.mts +7 -0
- package/dist/internal/passkey/admission.mjs +216 -0
- package/dist/internal/passkey/admission.mjs.map +1 -0
- package/dist/internal/passkey/credentials.d.mts +6 -0
- package/dist/internal/passkey/credentials.mjs +249 -0
- package/dist/internal/passkey/credentials.mjs.map +1 -0
- package/dist/internal/passkey/enrollment.mjs +138 -0
- package/dist/internal/passkey/enrollment.mjs.map +1 -0
- package/dist/internal/passkey/flow.d.mts +10 -0
- package/dist/internal/passkey/flow.mjs +452 -0
- package/dist/internal/passkey/flow.mjs.map +1 -0
- package/dist/internal/passkey/management.mjs +231 -0
- package/dist/internal/passkey/management.mjs.map +1 -0
- package/dist/internal/passkey/registration-ceremony.d.mts +9 -0
- package/dist/internal/passkey/registration-ceremony.mjs +129 -0
- package/dist/internal/passkey/registration-ceremony.mjs.map +1 -0
- package/dist/internal/passkey/registration-custody.d.mts +2 -0
- package/dist/internal/passkey/registration-custody.mjs +52 -0
- package/dist/internal/passkey/registration-custody.mjs.map +1 -0
- package/dist/internal/passkey/registration-write.mjs +211 -0
- package/dist/internal/passkey/registration-write.mjs.map +1 -0
- package/dist/internal/passkey/state.d.mts +5 -0
- package/dist/internal/passkey/state.mjs +234 -0
- package/dist/internal/passkey/state.mjs.map +1 -0
- package/dist/internal/passkey/target.d.mts +19 -0
- package/dist/internal/passkey/target.mjs +190 -0
- package/dist/internal/passkey/target.mjs.map +1 -0
- package/dist/internal/passkey/write-state.mjs +345 -0
- package/dist/internal/passkey/write-state.mjs.map +1 -0
- package/dist/internal/passkey/write-target.mjs +192 -0
- package/dist/internal/passkey/write-target.mjs.map +1 -0
- package/dist/internal/passkey-kernel.mjs +49 -0
- package/dist/internal/passkey-kernel.mjs.map +1 -0
- package/dist/internal/passkeys.mjs +367 -0
- package/dist/internal/passkeys.mjs.map +1 -0
- package/dist/internal/password-kernel.d.mts +13 -0
- package/dist/internal/password-kernel.mjs +704 -0
- package/dist/internal/password-kernel.mjs.map +1 -0
- package/dist/internal/persistence.mjs +289 -0
- package/dist/internal/persistence.mjs.map +1 -0
- package/dist/internal/phone-kernel.mjs +434 -0
- package/dist/internal/phone-kernel.mjs.map +1 -0
- package/dist/internal/proof-kernel.d.mts +9 -0
- package/dist/internal/proof-kernel.mjs +619 -0
- package/dist/internal/proof-kernel.mjs.map +1 -0
- package/dist/internal/query-operations.d.mts +3 -0
- package/dist/internal/registration.mjs +65 -0
- package/dist/internal/registration.mjs.map +1 -0
- package/dist/internal/session-kernel.mjs +737 -0
- package/dist/internal/session-kernel.mjs.map +1 -0
- package/dist/internal/sql-persistence.d.mts +11 -0
- package/dist/internal/sql-persistence.mjs +37 -0
- package/dist/internal/sql-persistence.mjs.map +1 -0
- package/dist/internal/sql-query.mjs +207 -0
- package/dist/internal/sql-query.mjs.map +1 -0
- package/dist/internal/sql-table.d.mts +37 -0
- package/dist/internal/sql-table.mjs +71 -0
- package/dist/internal/sql-table.mjs.map +1 -0
- package/dist/internal/storage-mapping.mjs +687 -0
- package/dist/internal/storage-mapping.mjs.map +1 -0
- package/dist/internal/storage-tables.d.mts +914 -0
- package/dist/internal/storage-tables.mjs +387 -0
- package/dist/internal/storage-tables.mjs.map +1 -0
- package/dist/internal/storage-validation.mjs +58 -0
- package/dist/internal/storage-validation.mjs.map +1 -0
- package/dist/internal/transaction-execution-kernel.d.mts +18 -0
- package/dist/internal/transaction-execution-kernel.mjs +118 -0
- package/dist/internal/transaction-execution-kernel.mjs.map +1 -0
- package/dist/internal/transaction-kernel.d.mts +7 -0
- package/dist/internal/transaction-kernel.mjs +260 -0
- package/dist/internal/transaction-kernel.mjs.map +1 -0
- package/package.json +1 -0
- package/src/Drizzle.ts +378 -0
- package/src/DrizzleD1.ts +136 -0
- package/src/DrizzleLibsql.ts +301 -0
- package/src/DrizzleMysql2.ts +184 -0
- package/src/DrizzlePglite.ts +174 -0
- package/src/DrizzlePostgres.ts +174 -0
- package/src/DrizzleSqliteBun.ts +258 -0
- package/src/DrizzleSqliteDo.ts +473 -0
- package/src/DrizzleSqliteNode.ts +259 -0
- package/src/DrizzleSqliteWasm.ts +263 -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 +1829 -0
- package/src/drizzle/d1-generated-statement.ts +129 -0
- package/src/drizzle/d1-identity.ts +375 -0
- package/src/drizzle/d1-oauth.ts +340 -0
- package/src/drizzle/d1-passkey.ts +373 -0
- package/src/drizzle/d1-password-prepared.ts +1270 -0
- package/src/drizzle/d1-passwords.ts +2656 -0
- package/src/drizzle/d1-phone.ts +96 -0
- package/src/drizzle/d1-planning.ts +104 -0
- package/src/drizzle/d1-proofs.ts +2305 -0
- package/src/drizzle/d1-sessions.ts +2857 -0
- package/src/drizzle/d1-totp.ts +78 -0
- package/src/drizzle/email-model.ts +516 -0
- package/src/drizzle/email-registration.ts +698 -0
- package/src/drizzle/email-sql.ts +24 -0
- package/src/drizzle/email-target.ts +243 -0
- package/src/drizzle/model.ts +463 -0
- package/src/drizzle/mysql-emails.ts +321 -0
- package/src/drizzle/mysql-identity.ts +324 -0
- package/src/drizzle/mysql-password-prepared.ts +204 -0
- package/src/drizzle/mysql-passwords.ts +339 -0
- package/src/drizzle/mysql-proofs.ts +181 -0
- package/src/drizzle/mysql-sessions.ts +741 -0
- package/src/drizzle/mysql.ts +687 -0
- package/src/drizzle/oauth-accounts.ts +804 -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 +465 -0
- package/src/drizzle/oauth-connected-flow.ts +441 -0
- package/src/drizzle/oauth-connected-input.ts +127 -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 +845 -0
- package/src/drizzle/oauth-connected-target.ts +264 -0
- package/src/drizzle/oauth-drivers.ts +569 -0
- package/src/drizzle/oauth-flow.ts +462 -0
- package/src/drizzle/oauth-input.ts +201 -0
- package/src/drizzle/oauth-model.ts +617 -0
- package/src/drizzle/oauth-mysql.ts +10 -0
- package/src/drizzle/oauth-owner.ts +29 -0
- package/src/drizzle/oauth-registration.ts +640 -0
- package/src/drizzle/oauth-state.ts +215 -0
- package/src/drizzle/oauth-target.ts +750 -0
- package/src/drizzle/passkey-drivers.ts +385 -0
- package/src/drizzle/passkey-kernel.ts +3 -0
- package/src/drizzle/passkey-model.ts +353 -0
- package/src/drizzle/passkey-registration-ceremony-model.ts +69 -0
- package/src/drizzle/passkey-state.ts +3 -0
- package/src/drizzle/passkey-target.ts +23 -0
- package/src/drizzle/passkey-write-drivers.ts +395 -0
- package/src/drizzle/passkey-write-model.ts +271 -0
- package/src/drizzle/passkey-write-target.ts +9 -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 +1191 -0
- package/src/drizzle/password-prepared-state.ts +231 -0
- package/src/drizzle/password-prepared-target.ts +160 -0
- package/src/drizzle/password-registration.ts +374 -0
- package/src/drizzle/password-sql.ts +12 -0
- package/src/drizzle/password-target.ts +224 -0
- package/src/drizzle/pg-emails.ts +321 -0
- package/src/drizzle/pg-password-prepared.ts +205 -0
- package/src/drizzle/pg-passwords.ts +338 -0
- package/src/drizzle/pg-proofs.ts +191 -0
- package/src/drizzle/pg-sessions.ts +750 -0
- package/src/drizzle/pg.ts +984 -0
- package/src/drizzle/phone-model.ts +190 -0
- package/src/drizzle/phone-state.ts +21 -0
- package/src/drizzle/phone-target.ts +472 -0
- package/src/drizzle/proof-model.ts +398 -0
- package/src/drizzle/proof-sql.ts +9 -0
- package/src/drizzle/proof-target.ts +122 -0
- package/src/drizzle/query-operations.ts +37 -0
- package/src/drizzle/session-model.ts +370 -0
- package/src/drizzle/session-sql.ts +13 -0
- package/src/drizzle/session-target.ts +338 -0
- package/src/drizzle/sqlite-emails.ts +366 -0
- package/src/drizzle/sqlite-identity.ts +344 -0
- package/src/drizzle/sqlite-password-prepared.ts +260 -0
- package/src/drizzle/sqlite-passwords.ts +497 -0
- package/src/drizzle/sqlite-proofs.ts +202 -0
- package/src/drizzle/sqlite-sessions.ts +971 -0
- package/src/drizzle/sqlite.ts +705 -0
- package/src/drizzle/standalone-guard.ts +38 -0
- package/src/drizzle/step-up-model.ts +128 -0
- package/src/drizzle/step-up-state.ts +139 -0
- package/src/drizzle/totp-model.ts +92 -0
- package/src/drizzle/totp-state.ts +525 -0
- package/src/drizzle/totp-target.ts +308 -0
- package/src/drizzle/transaction-execution.ts +12 -0
- package/src/drizzle/transaction-mysql.ts +104 -0
- package/src/drizzle/transaction-owner.ts +10 -0
- package/src/index.ts +4 -0
- package/src/internal/configuration.ts +282 -0
- package/src/internal/drizzle-migrations.ts +30 -0
- package/src/internal/drizzle-postgres.ts +81 -0
- package/src/internal/drizzle-sqlite.ts +79 -0
- package/src/internal/email-kernel.ts +1532 -0
- package/src/internal/mapping-error.ts +36 -0
- package/src/internal/passkey/admission.ts +362 -0
- package/src/internal/passkey/credentials.ts +511 -0
- package/src/internal/passkey/enrollment.ts +326 -0
- package/src/internal/passkey/flow.ts +1062 -0
- package/src/internal/passkey/management.ts +422 -0
- package/src/internal/passkey/registration-ceremony.ts +283 -0
- package/src/internal/passkey/registration-custody.ts +91 -0
- package/src/internal/passkey/registration-write.ts +426 -0
- package/src/internal/passkey/state.ts +354 -0
- package/src/internal/passkey/target.ts +586 -0
- package/src/internal/passkey/write-state.ts +681 -0
- package/src/internal/passkey/write-target.ts +452 -0
- package/src/internal/passkey-kernel.ts +102 -0
- package/src/internal/passkeys.ts +597 -0
- package/src/internal/password-kernel.ts +2122 -0
- package/src/internal/persistence.ts +590 -0
- package/src/internal/phone-kernel.ts +843 -0
- package/src/internal/proof-kernel.ts +1949 -0
- package/src/internal/query-operations.ts +26 -0
- package/src/internal/registration.ts +160 -0
- package/src/internal/session-kernel.ts +2210 -0
- package/src/internal/sql-persistence.ts +45 -0
- package/src/internal/sql-query.ts +298 -0
- package/src/internal/sql-table.ts +89 -0
- package/src/internal/storage-mapping.ts +706 -0
- package/src/internal/storage-tables.ts +408 -0
- package/src/internal/storage-validation.ts +117 -0
- package/src/internal/transaction-execution-kernel.ts +317 -0
- package/src/internal/transaction-kernel.ts +582 -0
|
@@ -0,0 +1,804 @@
|
|
|
1
|
+
import {
|
|
2
|
+
OAuthAccountRevision,
|
|
3
|
+
OAuthActionAuthorization,
|
|
4
|
+
OAuthLinkAccess,
|
|
5
|
+
OAuthLinkClaim,
|
|
6
|
+
OAuthLinkPendingFlow,
|
|
7
|
+
OAuthLinkTransactionContext,
|
|
8
|
+
OAuthUnlinked,
|
|
9
|
+
OAuthCredentialSnapshot,
|
|
10
|
+
snapshotOAuthSync,
|
|
11
|
+
} from "@yielded/auth/OAuth";
|
|
12
|
+
import {
|
|
13
|
+
SessionInvalidationWindow,
|
|
14
|
+
AuthenticationRequirement,
|
|
15
|
+
SecurityRevision,
|
|
16
|
+
} from "@yielded/auth/Sessions";
|
|
17
|
+
/* oxlint-disable no-explicit-any -- private owner implementation; public mappings retain native IDs. */
|
|
18
|
+
import { eq, sql } from "drizzle-orm";
|
|
19
|
+
import { DateTime, Effect } from "effect";
|
|
20
|
+
|
|
21
|
+
import type { SubjectIdCodec } from "./model";
|
|
22
|
+
import {
|
|
23
|
+
claimFlow,
|
|
24
|
+
credentialStorage,
|
|
25
|
+
currentSubject,
|
|
26
|
+
exactClaim,
|
|
27
|
+
issueFlow,
|
|
28
|
+
linkStorage,
|
|
29
|
+
matchesAccess,
|
|
30
|
+
readFlow,
|
|
31
|
+
terminalFlow,
|
|
32
|
+
} from "./oauth-flow";
|
|
33
|
+
import type { OAuthEligibilityFact } from "./oauth-model";
|
|
34
|
+
import { both, col, copiedRow, equal, CurrentOAuthTransaction } from "./oauth-owner";
|
|
35
|
+
import { acquireTuple, readTuple } from "./oauth-registration";
|
|
36
|
+
import {
|
|
37
|
+
invariant,
|
|
38
|
+
oauthIdentityKey,
|
|
39
|
+
sameRevision,
|
|
40
|
+
satisfies,
|
|
41
|
+
storage,
|
|
42
|
+
validAction,
|
|
43
|
+
} from "./oauth-state";
|
|
44
|
+
|
|
45
|
+
const contextStorage = storage(OAuthLinkTransactionContext);
|
|
46
|
+
const unlinkedStorage = storage(OAuthUnlinked);
|
|
47
|
+
|
|
48
|
+
export const accountCurrent = (mapping: any, subjectId: OAuthAccountRevision["subjectId"]) =>
|
|
49
|
+
Effect.gen(function* () {
|
|
50
|
+
const native = yield* (mapping.subjectId as SubjectIdCodec<unknown>).toNative(subjectId);
|
|
51
|
+
|
|
52
|
+
return yield* currentSubject(mapping, native);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const authorization = (
|
|
56
|
+
mapping: any,
|
|
57
|
+
current: any,
|
|
58
|
+
auth: OAuthActionAuthorization,
|
|
59
|
+
action: OAuthActionAuthorization["challenge"]["action"],
|
|
60
|
+
flowId: string,
|
|
61
|
+
commandId: string,
|
|
62
|
+
intent: string,
|
|
63
|
+
maximumAge: number,
|
|
64
|
+
) =>
|
|
65
|
+
Effect.flatMap(CurrentOAuthTransaction, (owner) =>
|
|
66
|
+
Effect.gen(function* () {
|
|
67
|
+
const now = yield* owner.now(mapping.clock);
|
|
68
|
+
|
|
69
|
+
const currentRequirement = snapshotOAuthSync(
|
|
70
|
+
AuthenticationRequirement,
|
|
71
|
+
mapping.subject.decodeActionRequirement(copiedRow(current.row), action),
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
const accepted = validAction(
|
|
75
|
+
auth,
|
|
76
|
+
{
|
|
77
|
+
moduleId: auth.challenge.moduleId,
|
|
78
|
+
action,
|
|
79
|
+
flowId,
|
|
80
|
+
commandId,
|
|
81
|
+
revision: current.revision,
|
|
82
|
+
intent,
|
|
83
|
+
},
|
|
84
|
+
currentRequirement,
|
|
85
|
+
now,
|
|
86
|
+
maximumAge,
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
if (!accepted) return false;
|
|
90
|
+
|
|
91
|
+
const age = Math.min(
|
|
92
|
+
maximumAge,
|
|
93
|
+
auth.requirement.maximumAgeMillis,
|
|
94
|
+
currentRequirement.maximumAgeMillis,
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
const fresh = auth.evidence.proofs.filter(
|
|
98
|
+
(proof) => now - DateTime.toEpochMillis(proof.verifiedAt) < age,
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
invariant(fresh.length > 0);
|
|
102
|
+
|
|
103
|
+
const deadline = Math.min(
|
|
104
|
+
...fresh.map((proof) => DateTime.toEpochMillis(proof.verifiedAt) + age),
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
owner.postconditions.push(
|
|
108
|
+
sql`${mapping.clock.engineNowMillis} >= ${now} and ${mapping.clock.engineNowMillis} < ${deadline}`,
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
return true;
|
|
112
|
+
}),
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
const currentLink = (mapping: any, flow: typeof OAuthLinkPendingFlow.Type) =>
|
|
116
|
+
Effect.gen(function* () {
|
|
117
|
+
const current = yield* accountCurrent(mapping, flow.context.revision.subjectId);
|
|
118
|
+
|
|
119
|
+
return current !== undefined && sameRevision(current.revision, flow.context.revision)
|
|
120
|
+
? current
|
|
121
|
+
: undefined;
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
export const issueLink = (mapping: any, input: any) =>
|
|
125
|
+
Effect.gen(function* () {
|
|
126
|
+
const flow = snapshotOAuthSync(OAuthLinkPendingFlow, input.flow),
|
|
127
|
+
c = flow.context;
|
|
128
|
+
|
|
129
|
+
const current = yield* currentLink(mapping, flow);
|
|
130
|
+
const auth = snapshotOAuthSync(OAuthActionAuthorization, input.authorization);
|
|
131
|
+
|
|
132
|
+
if (
|
|
133
|
+
current === undefined ||
|
|
134
|
+
auth.challenge.moduleId !== c.moduleId ||
|
|
135
|
+
!(yield* authorization(
|
|
136
|
+
mapping,
|
|
137
|
+
current,
|
|
138
|
+
auth,
|
|
139
|
+
"link-begin",
|
|
140
|
+
c.flowId,
|
|
141
|
+
c.commandId,
|
|
142
|
+
contextStorage.encode(c),
|
|
143
|
+
c.maximumEvidenceAgeMillis,
|
|
144
|
+
))
|
|
145
|
+
)
|
|
146
|
+
return { _tag: "Rejected" } as const;
|
|
147
|
+
|
|
148
|
+
return yield* issueFlow(mapping, flow, "link");
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
export const preflightLink = (mapping: any, original: typeof OAuthLinkAccess.Type) =>
|
|
152
|
+
Effect.flatMap(CurrentOAuthTransaction, (owner) =>
|
|
153
|
+
Effect.gen(function* () {
|
|
154
|
+
const input = snapshotOAuthSync(OAuthLinkAccess, original);
|
|
155
|
+
// The authenticated subject is known before discovering/locking any flow.
|
|
156
|
+
const current = yield* accountCurrent(mapping, input.subjectId);
|
|
157
|
+
const found = yield* readFlow(mapping, input, "link");
|
|
158
|
+
const now = yield* owner.now(mapping.clock);
|
|
159
|
+
|
|
160
|
+
if (
|
|
161
|
+
current === undefined ||
|
|
162
|
+
found.flow === undefined ||
|
|
163
|
+
found.row?.[mapping.flow.state] !== "Pending" ||
|
|
164
|
+
!matchesAccess(found.flow, input)
|
|
165
|
+
)
|
|
166
|
+
return undefined;
|
|
167
|
+
|
|
168
|
+
const flow = snapshotOAuthSync(OAuthLinkPendingFlow, found.flow as never),
|
|
169
|
+
c = flow.context;
|
|
170
|
+
|
|
171
|
+
if (
|
|
172
|
+
c.revision.subjectId !== input.subjectId ||
|
|
173
|
+
!sameRevision(current.revision, c.revision) ||
|
|
174
|
+
now < c.issuedAtMillis ||
|
|
175
|
+
now >= c.expiresAtMillis
|
|
176
|
+
)
|
|
177
|
+
return undefined;
|
|
178
|
+
owner.postconditions.push(
|
|
179
|
+
sql`${mapping.clock.engineNowMillis} >= ${c.issuedAtMillis} and ${mapping.clock.engineNowMillis} < ${c.expiresAtMillis}`,
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
return { current, flow, row: found.row };
|
|
183
|
+
}),
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
export const claimLink = (mapping: any, input: any) =>
|
|
187
|
+
Effect.gen(function* () {
|
|
188
|
+
const found = yield* preflightLink(mapping, input.access);
|
|
189
|
+
const flow = snapshotOAuthSync(OAuthLinkPendingFlow, input.flow);
|
|
190
|
+
|
|
191
|
+
const auth = snapshotOAuthSync(OAuthActionAuthorization, input.authorization),
|
|
192
|
+
c = flow.context;
|
|
193
|
+
|
|
194
|
+
if (
|
|
195
|
+
found === undefined ||
|
|
196
|
+
linkStorage.encode(found.flow) !== linkStorage.encode(flow) ||
|
|
197
|
+
auth.challenge.moduleId !== c.moduleId ||
|
|
198
|
+
!(yield* authorization(
|
|
199
|
+
mapping,
|
|
200
|
+
found.current,
|
|
201
|
+
auth,
|
|
202
|
+
"link-complete",
|
|
203
|
+
c.flowId,
|
|
204
|
+
c.commandId,
|
|
205
|
+
contextStorage.encode(c),
|
|
206
|
+
c.maximumEvidenceAgeMillis,
|
|
207
|
+
))
|
|
208
|
+
)
|
|
209
|
+
return { _tag: "Rejected" } as const;
|
|
210
|
+
const claim = yield* claimFlow(mapping, { row: found.row!, flow }, input.claimId);
|
|
211
|
+
|
|
212
|
+
return claim === undefined
|
|
213
|
+
? ({ _tag: "Rejected" } as const)
|
|
214
|
+
: ({ _tag: "Claimed", claim } as const);
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
const checkInvalidation = (mapping: any, original: SessionInvalidationWindow) => {
|
|
218
|
+
const value = snapshotOAuthSync(SessionInvalidationWindow, original);
|
|
219
|
+
|
|
220
|
+
invariant(
|
|
221
|
+
value.trigger === "credential-change" &&
|
|
222
|
+
value.oldAuthenticationEvidence === "rejected" &&
|
|
223
|
+
(mapping.sessionInvalidation === "same-authority-immediate"
|
|
224
|
+
? value.existingSessions === "immediate" && value.maximumExposureMillis === 0
|
|
225
|
+
: value.existingSessions === "original-absolute-expiry"),
|
|
226
|
+
);
|
|
227
|
+
|
|
228
|
+
return value;
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
const advance = (mapping: any, current: any, removed?: string) =>
|
|
232
|
+
Effect.flatMap(CurrentOAuthTransaction, (owner) =>
|
|
233
|
+
Effect.gen(function* () {
|
|
234
|
+
const revision = mapping.subject.nextSecurityRevision(current.revision.securityRevision);
|
|
235
|
+
|
|
236
|
+
invariant(
|
|
237
|
+
typeof revision === "string" &&
|
|
238
|
+
revision.length > 0 &&
|
|
239
|
+
revision.length <= 256 &&
|
|
240
|
+
revision !== current.revision.securityRevision,
|
|
241
|
+
);
|
|
242
|
+
const subject = mapping.subject;
|
|
243
|
+
|
|
244
|
+
yield* owner.update(
|
|
245
|
+
subject.table,
|
|
246
|
+
{ [subject.id]: current.nativeId },
|
|
247
|
+
{ [subject.securityRevision]: revision },
|
|
248
|
+
);
|
|
249
|
+
for (const cleanup of mapping.cleanup) {
|
|
250
|
+
const condition = both(
|
|
251
|
+
eq(col(cleanup.table, cleanup.subjectId), current.nativeId),
|
|
252
|
+
cleanup.condition({
|
|
253
|
+
subjectId: current.nativeId,
|
|
254
|
+
revision: snapshotOAuthSync(OAuthAccountRevision, current.revision),
|
|
255
|
+
...(removed === undefined ? {} : { removedCredentialId: removed }),
|
|
256
|
+
}),
|
|
257
|
+
);
|
|
258
|
+
|
|
259
|
+
yield* owner.write(owner.database.delete(cleanup.table).where(condition));
|
|
260
|
+
owner.postconditions.push(
|
|
261
|
+
sql`not exists(select 1 from ${cleanup.table} where ${condition})`,
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
return SecurityRevision.make(revision);
|
|
266
|
+
}),
|
|
267
|
+
);
|
|
268
|
+
|
|
269
|
+
export const settleLink = (
|
|
270
|
+
mapping: any,
|
|
271
|
+
input: any,
|
|
272
|
+
allocated: { readonly credentialId: string; readonly revision: SecurityRevision },
|
|
273
|
+
) =>
|
|
274
|
+
Effect.flatMap(CurrentOAuthTransaction, (owner) =>
|
|
275
|
+
Effect.gen(function* () {
|
|
276
|
+
const claim = snapshotOAuthSync(OAuthLinkClaim, input.claim),
|
|
277
|
+
flow = claim.flow,
|
|
278
|
+
c = flow.context;
|
|
279
|
+
|
|
280
|
+
const current = yield* currentLink(mapping, flow);
|
|
281
|
+
|
|
282
|
+
// Known subject is always locked before tuple/flow; even a rejected outcome
|
|
283
|
+
// settles its exact original claim without adopting a newer revision.
|
|
284
|
+
const identity =
|
|
285
|
+
input.outcome._tag === "Verified" ? input.outcome.identity.identity : undefined;
|
|
286
|
+
|
|
287
|
+
if (identity !== undefined)
|
|
288
|
+
invariant(identity.provider === c.provider && identity.issuer === c.issuer);
|
|
289
|
+
|
|
290
|
+
const tuple =
|
|
291
|
+
identity !== undefined && current !== undefined
|
|
292
|
+
? yield* readTuple(mapping.ownership, identity)
|
|
293
|
+
: undefined;
|
|
294
|
+
|
|
295
|
+
const exact = yield* exactClaim(mapping, claim, "link");
|
|
296
|
+
|
|
297
|
+
if (exact === undefined) return { _tag: "Rejected" } as const;
|
|
298
|
+
let decision: any = { _tag: input.outcome._tag };
|
|
299
|
+
|
|
300
|
+
if (input.outcome._tag === "Verified") {
|
|
301
|
+
decision = { _tag: "Rejected" };
|
|
302
|
+
const auth = snapshotOAuthSync(OAuthActionAuthorization, input.authorization);
|
|
303
|
+
|
|
304
|
+
if (
|
|
305
|
+
current !== undefined &&
|
|
306
|
+
tuple !== undefined &&
|
|
307
|
+
auth.challenge.moduleId === c.moduleId &&
|
|
308
|
+
(yield* authorization(
|
|
309
|
+
mapping,
|
|
310
|
+
current,
|
|
311
|
+
auth,
|
|
312
|
+
"link-complete",
|
|
313
|
+
c.flowId,
|
|
314
|
+
c.commandId,
|
|
315
|
+
contextStorage.encode(c),
|
|
316
|
+
c.maximumEvidenceAgeMillis,
|
|
317
|
+
))
|
|
318
|
+
) {
|
|
319
|
+
const t = mapping.ownership.tuple,
|
|
320
|
+
cr = mapping.credential,
|
|
321
|
+
a = mapping.authority;
|
|
322
|
+
|
|
323
|
+
const login = yield* owner.read(cr.table, eq(col(cr.table, cr.identityKey), tuple.key), {
|
|
324
|
+
limit: 1,
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
const previous = login.rows[0];
|
|
328
|
+
|
|
329
|
+
if (
|
|
330
|
+
tuple.row[t.state] === "Reserved" ||
|
|
331
|
+
(tuple.row[t.state] === "Owned" &&
|
|
332
|
+
!mapping.subjectId.equals(tuple.row[t.subjectId], current.nativeId)) ||
|
|
333
|
+
(previous !== undefined &&
|
|
334
|
+
(previous[cr.moduleId] !== c.moduleId ||
|
|
335
|
+
!mapping.subjectId.equals(previous[cr.subjectId], current.nativeId) ||
|
|
336
|
+
!cr.isActiveStatus(previous[cr.status])))
|
|
337
|
+
)
|
|
338
|
+
decision = { _tag: "Conflict" };
|
|
339
|
+
else if (previous !== undefined) {
|
|
340
|
+
const shared = current.revision.credentials.find(
|
|
341
|
+
(item: any) => item.credentialId === previous[cr.credentialId],
|
|
342
|
+
);
|
|
343
|
+
|
|
344
|
+
if (
|
|
345
|
+
tuple.row[t.state] !== "Owned" ||
|
|
346
|
+
shared?.revision !== previous[cr.credentialRevision] ||
|
|
347
|
+
!(yield* owner.check(
|
|
348
|
+
sql`exists(select 1 from ${cr.table} where ${both(eq(col(cr.table, cr.identityKey), tuple.key), cr.activeCondition)})`,
|
|
349
|
+
))
|
|
350
|
+
)
|
|
351
|
+
decision = { _tag: "Conflict" };
|
|
352
|
+
else
|
|
353
|
+
decision = {
|
|
354
|
+
_tag: "Linked",
|
|
355
|
+
changed: false,
|
|
356
|
+
credential: snapshotOAuthSync(OAuthCredentialSnapshot, {
|
|
357
|
+
moduleId: c.moduleId,
|
|
358
|
+
identity,
|
|
359
|
+
credentialId: previous[cr.credentialId],
|
|
360
|
+
credentialRevision: previous[cr.credentialRevision],
|
|
361
|
+
revision: current.revision,
|
|
362
|
+
}),
|
|
363
|
+
};
|
|
364
|
+
} else {
|
|
365
|
+
checkInvalidation(mapping, input.invalidation);
|
|
366
|
+
|
|
367
|
+
const values = {
|
|
368
|
+
...cr.encodeInsert({
|
|
369
|
+
moduleId: c.moduleId,
|
|
370
|
+
subjectId: current.nativeId,
|
|
371
|
+
identityKey: tuple.key,
|
|
372
|
+
credentialId: allocated.credentialId,
|
|
373
|
+
credentialRevision: allocated.revision,
|
|
374
|
+
}),
|
|
375
|
+
[cr.moduleId]: c.moduleId,
|
|
376
|
+
[cr.subjectId]: current.nativeId,
|
|
377
|
+
[cr.identityKey]: tuple.key,
|
|
378
|
+
[cr.credentialId]: allocated.credentialId,
|
|
379
|
+
[cr.credentialRevision]: allocated.revision,
|
|
380
|
+
};
|
|
381
|
+
|
|
382
|
+
invariant(cr.isActiveStatus(values[cr.status]));
|
|
383
|
+
|
|
384
|
+
const inserted = yield* owner.insert(cr.table, values, {
|
|
385
|
+
[cr.credentialId]: allocated.credentialId,
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
login.rows = inserted.rows;
|
|
389
|
+
|
|
390
|
+
const sharedValues = {
|
|
391
|
+
...a.encodeInsert({
|
|
392
|
+
subjectId: current.nativeId,
|
|
393
|
+
credentialId: allocated.credentialId,
|
|
394
|
+
revision: allocated.revision,
|
|
395
|
+
}),
|
|
396
|
+
[a.subjectId]: current.nativeId,
|
|
397
|
+
[a.credentialId]: allocated.credentialId,
|
|
398
|
+
[a.revision]: allocated.revision,
|
|
399
|
+
};
|
|
400
|
+
|
|
401
|
+
invariant(a.isActiveStatus(sharedValues[a.status]));
|
|
402
|
+
|
|
403
|
+
const shared = yield* owner.insert(a.table, sharedValues, {
|
|
404
|
+
[a.subjectId]: current.nativeId,
|
|
405
|
+
[a.credentialId]: allocated.credentialId,
|
|
406
|
+
});
|
|
407
|
+
|
|
408
|
+
current.authorities.rows = [...current.authorities.rows, ...shared.rows];
|
|
409
|
+
owner.postconditions.push(
|
|
410
|
+
sql`exists(select 1 from ${cr.table} where ${both(
|
|
411
|
+
eq(col(cr.table, cr.credentialId), allocated.credentialId),
|
|
412
|
+
cr.activeCondition,
|
|
413
|
+
)})`,
|
|
414
|
+
sql`exists(select 1 from ${a.table} where ${both(
|
|
415
|
+
eq(col(a.table, a.subjectId), current.nativeId),
|
|
416
|
+
eq(col(a.table, a.credentialId), allocated.credentialId),
|
|
417
|
+
a.activeCondition,
|
|
418
|
+
)})`,
|
|
419
|
+
);
|
|
420
|
+
if (tuple.row[t.state] === "Unowned")
|
|
421
|
+
yield* acquireTuple(mapping.ownership, identity, tuple.key, current.nativeId);
|
|
422
|
+
const next = yield* advance(mapping, current);
|
|
423
|
+
|
|
424
|
+
const revision = snapshotOAuthSync(OAuthAccountRevision, {
|
|
425
|
+
...current.revision,
|
|
426
|
+
securityRevision: next,
|
|
427
|
+
credentials: [
|
|
428
|
+
...current.revision.credentials,
|
|
429
|
+
{ credentialId: allocated.credentialId, revision: allocated.revision },
|
|
430
|
+
],
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
decision = {
|
|
434
|
+
_tag: "Linked",
|
|
435
|
+
changed: true,
|
|
436
|
+
credential: snapshotOAuthSync(OAuthCredentialSnapshot, {
|
|
437
|
+
moduleId: c.moduleId,
|
|
438
|
+
identity,
|
|
439
|
+
credentialId: allocated.credentialId,
|
|
440
|
+
credentialRevision: allocated.revision as never,
|
|
441
|
+
revision,
|
|
442
|
+
}),
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
yield* terminalFlow(mapping, flow, decision._tag);
|
|
448
|
+
|
|
449
|
+
return decision;
|
|
450
|
+
}),
|
|
451
|
+
);
|
|
452
|
+
|
|
453
|
+
const targetCredential = (mapping: any, moduleId: string, credentialId: string, current: any) =>
|
|
454
|
+
Effect.flatMap(CurrentOAuthTransaction, (owner) =>
|
|
455
|
+
Effect.gen(function* () {
|
|
456
|
+
const cr = mapping.credential;
|
|
457
|
+
|
|
458
|
+
const found = yield* owner.read(cr.table, eq(col(cr.table, cr.credentialId), credentialId), {
|
|
459
|
+
limit: 1,
|
|
460
|
+
});
|
|
461
|
+
|
|
462
|
+
const row = found.rows[0];
|
|
463
|
+
|
|
464
|
+
if (
|
|
465
|
+
row === undefined ||
|
|
466
|
+
row[cr.moduleId] !== moduleId ||
|
|
467
|
+
!mapping.subjectId.equals(row[cr.subjectId], current.nativeId) ||
|
|
468
|
+
!cr.isActiveStatus(row[cr.status])
|
|
469
|
+
)
|
|
470
|
+
return undefined;
|
|
471
|
+
const t = mapping.ownership.tuple;
|
|
472
|
+
|
|
473
|
+
const tuple = yield* owner.read(
|
|
474
|
+
t.table,
|
|
475
|
+
eq(col(t.table, t.identityKey), row[cr.identityKey]),
|
|
476
|
+
{
|
|
477
|
+
limit: 1,
|
|
478
|
+
},
|
|
479
|
+
);
|
|
480
|
+
|
|
481
|
+
const ownership = tuple.rows[0];
|
|
482
|
+
|
|
483
|
+
if (
|
|
484
|
+
ownership === undefined ||
|
|
485
|
+
ownership[t.state] !== "Owned" ||
|
|
486
|
+
!mapping.subjectId.equals(ownership[t.subjectId], current.nativeId)
|
|
487
|
+
)
|
|
488
|
+
return undefined;
|
|
489
|
+
|
|
490
|
+
const identity = {
|
|
491
|
+
provider: ownership[t.provider],
|
|
492
|
+
issuer: ownership[t.issuer],
|
|
493
|
+
subject: ownership[t.externalSubject],
|
|
494
|
+
};
|
|
495
|
+
|
|
496
|
+
invariant(oauthIdentityKey(identity) === row[cr.identityKey]);
|
|
497
|
+
|
|
498
|
+
const shared = current.revision.credentials.find(
|
|
499
|
+
(item: any) => item.credentialId === credentialId,
|
|
500
|
+
);
|
|
501
|
+
|
|
502
|
+
if (
|
|
503
|
+
shared?.revision !== row[cr.credentialRevision] ||
|
|
504
|
+
!(yield* owner.check(
|
|
505
|
+
sql`exists(select 1 from ${cr.table} where ${both(eq(col(cr.table, cr.credentialId), credentialId), cr.activeCondition)})`,
|
|
506
|
+
))
|
|
507
|
+
)
|
|
508
|
+
return undefined;
|
|
509
|
+
|
|
510
|
+
return snapshotOAuthSync(OAuthCredentialSnapshot, {
|
|
511
|
+
moduleId: moduleId as never,
|
|
512
|
+
identity,
|
|
513
|
+
credentialId,
|
|
514
|
+
credentialRevision: row[cr.credentialRevision],
|
|
515
|
+
revision: current.revision,
|
|
516
|
+
});
|
|
517
|
+
}),
|
|
518
|
+
);
|
|
519
|
+
|
|
520
|
+
const unlinkCommand = (mapping: any, moduleId: string, commandId: string) =>
|
|
521
|
+
Effect.flatMap(CurrentOAuthTransaction, (owner) =>
|
|
522
|
+
owner.read(
|
|
523
|
+
mapping.command.table,
|
|
524
|
+
equal(mapping.command.table, {
|
|
525
|
+
[mapping.command.moduleId]: moduleId,
|
|
526
|
+
[mapping.command.commandId]: commandId,
|
|
527
|
+
}),
|
|
528
|
+
{ limit: 1 },
|
|
529
|
+
),
|
|
530
|
+
);
|
|
531
|
+
|
|
532
|
+
export const inspectUnlink = (mapping: any, input: any) =>
|
|
533
|
+
Effect.flatMap(CurrentOAuthTransaction, (owner) =>
|
|
534
|
+
Effect.gen(function* () {
|
|
535
|
+
const current = yield* accountCurrent(mapping, input.subjectId);
|
|
536
|
+
|
|
537
|
+
if (current === undefined) return { _tag: "Rejected" } as const;
|
|
538
|
+
|
|
539
|
+
const command = yield* unlinkCommand(mapping, input.moduleId, input.commandId),
|
|
540
|
+
r = mapping.command;
|
|
541
|
+
|
|
542
|
+
const old = command.rows[0];
|
|
543
|
+
|
|
544
|
+
if (old !== undefined) {
|
|
545
|
+
const intent = credentialStorage.decode(old[r.intentSnapshot]);
|
|
546
|
+
|
|
547
|
+
if (
|
|
548
|
+
intent.moduleId !== input.moduleId ||
|
|
549
|
+
intent.revision.subjectId !== input.subjectId ||
|
|
550
|
+
intent.credentialId !== input.credentialId ||
|
|
551
|
+
!mapping.subjectId.equals(old[r.subjectId], current.nativeId) ||
|
|
552
|
+
old[r.credentialId] !== input.credentialId
|
|
553
|
+
)
|
|
554
|
+
return { _tag: "Conflict" } as const;
|
|
555
|
+
const metadata = mapping.metadata.condition(current.nativeId);
|
|
556
|
+
|
|
557
|
+
if (!(yield* owner.check(metadata))) return { _tag: "Rejected" } as const;
|
|
558
|
+
owner.postconditions.push(metadata);
|
|
559
|
+
|
|
560
|
+
return { _tag: "Replay", result: unlinkedStorage.decode(old[r.decision]) } as const;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
const credential = yield* targetCredential(
|
|
564
|
+
mapping,
|
|
565
|
+
input.moduleId,
|
|
566
|
+
input.credentialId,
|
|
567
|
+
current,
|
|
568
|
+
);
|
|
569
|
+
|
|
570
|
+
return credential === undefined
|
|
571
|
+
? ({ _tag: "Rejected" } as const)
|
|
572
|
+
: ({ _tag: "Target", credential } as const);
|
|
573
|
+
}),
|
|
574
|
+
);
|
|
575
|
+
|
|
576
|
+
const remainingEligibility = (mapping: any, current: any, removed: string) =>
|
|
577
|
+
Effect.flatMap(CurrentOAuthTransaction, (owner) =>
|
|
578
|
+
Effect.gen(function* () {
|
|
579
|
+
invariant(mapping.eligibility.length > 0 && mapping.eligibility.length <= 32);
|
|
580
|
+
const facts = new Map<string, OAuthEligibilityFact>();
|
|
581
|
+
|
|
582
|
+
const revisions = new Map(
|
|
583
|
+
current.revision.credentials.map((item: any) => [item.credentialId, item.revision]),
|
|
584
|
+
);
|
|
585
|
+
|
|
586
|
+
for (const descriptor of mapping.eligibility) {
|
|
587
|
+
const observed = yield* owner.read(
|
|
588
|
+
descriptor.table,
|
|
589
|
+
both(
|
|
590
|
+
eq(col(descriptor.table, descriptor.subjectId), current.nativeId),
|
|
591
|
+
descriptor.condition(current.nativeId),
|
|
592
|
+
),
|
|
593
|
+
{ orderBy: col(descriptor.table, descriptor.credentialId) },
|
|
594
|
+
);
|
|
595
|
+
|
|
596
|
+
for (const row of observed.rows) {
|
|
597
|
+
const fact = descriptor.decode(copiedRow(row)) as OAuthEligibilityFact | undefined;
|
|
598
|
+
|
|
599
|
+
if (fact === undefined || fact.credentialId === removed) continue;
|
|
600
|
+
invariant(
|
|
601
|
+
fact.credentialId === row[descriptor.credentialId] &&
|
|
602
|
+
fact.revision === row[descriptor.revision] &&
|
|
603
|
+
revisions.get(fact.credentialId) === fact.revision &&
|
|
604
|
+
fact.factors.length <= 8 &&
|
|
605
|
+
fact.factors.every((factor) =>
|
|
606
|
+
["knowledge", "possession", "inherence"].includes(factor),
|
|
607
|
+
),
|
|
608
|
+
);
|
|
609
|
+
invariant(
|
|
610
|
+
typeof fact.usablePrimary === "boolean" &&
|
|
611
|
+
typeof fact.userVerified === "boolean" &&
|
|
612
|
+
typeof fact.phishingResistant === "boolean",
|
|
613
|
+
);
|
|
614
|
+
|
|
615
|
+
const normalized = {
|
|
616
|
+
credentialId: fact.credentialId,
|
|
617
|
+
revision: fact.revision,
|
|
618
|
+
usablePrimary: fact.usablePrimary,
|
|
619
|
+
factors: [...new Set(fact.factors)].sort(),
|
|
620
|
+
userVerified: fact.userVerified,
|
|
621
|
+
phishingResistant: fact.phishingResistant,
|
|
622
|
+
};
|
|
623
|
+
|
|
624
|
+
const prior = facts.get(fact.credentialId);
|
|
625
|
+
|
|
626
|
+
// oxlint-disable-next-line no-restricted-properties -- Canonical bounded eligibility fact fingerprint rejects contradictory duplicate IDs.
|
|
627
|
+
invariant(prior === undefined || JSON.stringify(prior) === JSON.stringify(normalized));
|
|
628
|
+
facts.set(fact.credentialId, normalized);
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
const available = [...facts.values()];
|
|
632
|
+
|
|
633
|
+
const requirement = snapshotOAuthSync(
|
|
634
|
+
AuthenticationRequirement,
|
|
635
|
+
mapping.subject.decodeAuthenticationRequirement(copiedRow(current.row)),
|
|
636
|
+
);
|
|
637
|
+
|
|
638
|
+
return available.some((fact) => fact.usablePrimary) && satisfies(available, requirement);
|
|
639
|
+
}),
|
|
640
|
+
);
|
|
641
|
+
|
|
642
|
+
export const unlink = (mapping: any, input: any) =>
|
|
643
|
+
Effect.flatMap(CurrentOAuthTransaction, (owner) =>
|
|
644
|
+
Effect.gen(function* () {
|
|
645
|
+
const expected = snapshotOAuthSync(OAuthCredentialSnapshot, input.credential);
|
|
646
|
+
|
|
647
|
+
invariant(expected.moduleId === input.moduleId);
|
|
648
|
+
const current = yield* accountCurrent(mapping, expected.revision.subjectId);
|
|
649
|
+
|
|
650
|
+
if (current === undefined) return { _tag: "Rejected" } as const;
|
|
651
|
+
const guards = mapping.connectedReferenceGuards ?? [];
|
|
652
|
+
|
|
653
|
+
invariant(guards.length <= 32);
|
|
654
|
+
let referencesGuarded = mapping.connectedReference !== undefined && guards.length > 0;
|
|
655
|
+
|
|
656
|
+
if (mapping.connectedReference !== undefined)
|
|
657
|
+
for (const guard of guards) {
|
|
658
|
+
const read = yield* owner.read(
|
|
659
|
+
guard.table,
|
|
660
|
+
guard.condition({
|
|
661
|
+
identity: snapshotOAuthSync(
|
|
662
|
+
OAuthCredentialSnapshot.fields.identity,
|
|
663
|
+
expected.identity,
|
|
664
|
+
),
|
|
665
|
+
identityKey: oauthIdentityKey(expected.identity),
|
|
666
|
+
subjectId: copiedRow({ value: current.nativeId }).value,
|
|
667
|
+
}),
|
|
668
|
+
{ orderBy: col(guard.table, guard.orderBy) },
|
|
669
|
+
);
|
|
670
|
+
|
|
671
|
+
if (read.rows.length === 0) referencesGuarded = false;
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
const command = yield* unlinkCommand(mapping, input.moduleId, input.commandId),
|
|
675
|
+
r = mapping.command;
|
|
676
|
+
|
|
677
|
+
const previous = command.rows[0];
|
|
678
|
+
|
|
679
|
+
if (previous !== undefined) {
|
|
680
|
+
if (
|
|
681
|
+
previous[r.intentSnapshot] !== credentialStorage.encode(expected) ||
|
|
682
|
+
previous[r.credentialId] !== expected.credentialId ||
|
|
683
|
+
!mapping.subjectId.equals(previous[r.subjectId], current.nativeId)
|
|
684
|
+
)
|
|
685
|
+
return { _tag: "Conflict" } as const;
|
|
686
|
+
const metadata = mapping.metadata.condition(current.nativeId);
|
|
687
|
+
|
|
688
|
+
if (!(yield* owner.check(metadata))) return { _tag: "Rejected" } as const;
|
|
689
|
+
owner.postconditions.push(metadata);
|
|
690
|
+
|
|
691
|
+
return {
|
|
692
|
+
_tag: "Unlinked",
|
|
693
|
+
replayed: true,
|
|
694
|
+
result: unlinkedStorage.decode(previous[r.decision]),
|
|
695
|
+
} as const;
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
const actual = yield* targetCredential(
|
|
699
|
+
mapping,
|
|
700
|
+
input.moduleId,
|
|
701
|
+
expected.credentialId,
|
|
702
|
+
current,
|
|
703
|
+
);
|
|
704
|
+
|
|
705
|
+
if (
|
|
706
|
+
actual === undefined ||
|
|
707
|
+
credentialStorage.encode(actual) !== credentialStorage.encode(expected)
|
|
708
|
+
)
|
|
709
|
+
return { _tag: "Rejected" } as const;
|
|
710
|
+
const auth = snapshotOAuthSync(OAuthActionAuthorization, input.authorization);
|
|
711
|
+
|
|
712
|
+
if (
|
|
713
|
+
auth.challenge.moduleId !== input.moduleId ||
|
|
714
|
+
!(yield* authorization(
|
|
715
|
+
mapping,
|
|
716
|
+
current,
|
|
717
|
+
auth,
|
|
718
|
+
"unlink",
|
|
719
|
+
input.commandId,
|
|
720
|
+
input.commandId,
|
|
721
|
+
credentialStorage.encode(expected),
|
|
722
|
+
auth.requirement.maximumAgeMillis,
|
|
723
|
+
))
|
|
724
|
+
)
|
|
725
|
+
return { _tag: "Rejected" } as const;
|
|
726
|
+
if (!(yield* remainingEligibility(mapping, current, expected.credentialId)))
|
|
727
|
+
return { _tag: "LastSignInMethod" } as const;
|
|
728
|
+
|
|
729
|
+
const invalidation = checkInvalidation(mapping, input.invalidation),
|
|
730
|
+
cr = mapping.credential,
|
|
731
|
+
a = mapping.authority;
|
|
732
|
+
|
|
733
|
+
const key = oauthIdentityKey(expected.identity),
|
|
734
|
+
t = mapping.ownership.tuple;
|
|
735
|
+
|
|
736
|
+
const connected = mapping.connectedReference?.({
|
|
737
|
+
identityKey: key,
|
|
738
|
+
subjectId: copiedRow({ value: current.nativeId }).value,
|
|
739
|
+
});
|
|
740
|
+
|
|
741
|
+
const retain =
|
|
742
|
+
connected !== undefined && (!referencesGuarded || (yield* owner.check(connected)));
|
|
743
|
+
|
|
744
|
+
if (connected !== undefined && referencesGuarded)
|
|
745
|
+
owner.postconditions.push(retain ? connected : sql`not (${connected})`);
|
|
746
|
+
yield* owner.remove(cr.table, { [cr.credentialId]: expected.credentialId });
|
|
747
|
+
yield* owner.remove(a.table, {
|
|
748
|
+
[a.subjectId]: current.nativeId,
|
|
749
|
+
[a.credentialId]: expected.credentialId,
|
|
750
|
+
});
|
|
751
|
+
if (!retain) {
|
|
752
|
+
yield* owner.update(
|
|
753
|
+
t.table,
|
|
754
|
+
{ [t.identityKey]: key },
|
|
755
|
+
{
|
|
756
|
+
[t.state]: "Unowned",
|
|
757
|
+
[t.subjectId]: null,
|
|
758
|
+
[t.reservation]: null,
|
|
759
|
+
[t.version]: owner.marker,
|
|
760
|
+
},
|
|
761
|
+
);
|
|
762
|
+
if (mapping.ownership.mode === "separate")
|
|
763
|
+
yield* owner.remove(mapping.ownership.external.table, {
|
|
764
|
+
[mapping.ownership.external.identityKey]: key,
|
|
765
|
+
});
|
|
766
|
+
}
|
|
767
|
+
yield* advance(mapping, current, expected.credentialId);
|
|
768
|
+
|
|
769
|
+
const result = snapshotOAuthSync(OAuthUnlinked, {
|
|
770
|
+
_tag: "Unlinked",
|
|
771
|
+
credentialId: expected.credentialId,
|
|
772
|
+
invalidation,
|
|
773
|
+
});
|
|
774
|
+
|
|
775
|
+
const now = yield* owner.now(mapping.clock);
|
|
776
|
+
|
|
777
|
+
invariant(
|
|
778
|
+
Number.isSafeInteger(input.retentionUntilMillis) &&
|
|
779
|
+
input.retentionUntilMillis > now &&
|
|
780
|
+
input.retentionUntilMillis >= input.nowMillis + 120000,
|
|
781
|
+
);
|
|
782
|
+
const commandKey = { [r.moduleId]: input.moduleId, [r.commandId]: input.commandId };
|
|
783
|
+
|
|
784
|
+
const values = {
|
|
785
|
+
...r.encodeInsert({
|
|
786
|
+
moduleId: input.moduleId,
|
|
787
|
+
commandId: input.commandId,
|
|
788
|
+
credential: snapshotOAuthSync(OAuthCredentialSnapshot, expected),
|
|
789
|
+
}),
|
|
790
|
+
...commandKey,
|
|
791
|
+
[r.subjectId]: current.nativeId,
|
|
792
|
+
[r.credentialId]: expected.credentialId,
|
|
793
|
+
[r.intentSnapshot]: credentialStorage.encode(expected),
|
|
794
|
+
[r.decision]: unlinkedStorage.encode(result),
|
|
795
|
+
[r.retentionUntil]: mapping.clock.encodeInstant(input.retentionUntilMillis),
|
|
796
|
+
};
|
|
797
|
+
|
|
798
|
+
const inserted = yield* owner.insert(r.table, values, commandKey);
|
|
799
|
+
|
|
800
|
+
command.rows = inserted.rows;
|
|
801
|
+
|
|
802
|
+
return { _tag: "Unlinked", result, replayed: false } as const;
|
|
803
|
+
}),
|
|
804
|
+
);
|