@yielded/auth-persistence-drizzle 0.1.0-beta.24 → 0.1.0-beta.26
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 +4 -2
- package/dist/D1.d.mts +495 -1151
- package/dist/D1.mjs +41 -19
- package/dist/D1.mjs.map +1 -1
- package/dist/Libsql.d.mts +385 -1996
- package/dist/Libsql.mjs +43 -47
- package/dist/Libsql.mjs.map +1 -1
- package/dist/Mysql2.d.mts +397 -1743
- package/dist/Mysql2.mjs +35 -41
- package/dist/Mysql2.mjs.map +1 -1
- package/dist/Pglite.d.mts +397 -1743
- package/dist/Pglite.mjs +42 -31
- package/dist/Pglite.mjs.map +1 -1
- package/dist/Postgres.d.mts +397 -1743
- package/dist/Postgres.mjs +42 -31
- package/dist/Postgres.mjs.map +1 -1
- package/dist/SqliteBun.d.mts +385 -1992
- package/dist/SqliteBun.mjs +43 -43
- package/dist/SqliteBun.mjs.map +1 -1
- package/dist/SqliteDo.d.mts +385 -1991
- package/dist/SqliteDo.mjs +42 -41
- package/dist/SqliteDo.mjs.map +1 -1
- package/dist/SqliteNode.d.mts +385 -1992
- package/dist/SqliteNode.mjs +43 -43
- package/dist/SqliteNode.mjs.map +1 -1
- package/dist/SqliteWasm.d.mts +385 -1992
- package/dist/SqliteWasm.mjs +43 -43
- package/dist/SqliteWasm.mjs.map +1 -1
- package/dist/drizzle/d1-identity.mjs +2 -2
- package/dist/drizzle/d1-identity.mjs.map +1 -1
- package/dist/drizzle/driver-types.d.mts +15 -0
- package/dist/drizzle/email-drivers.mjs +32 -0
- package/dist/drizzle/email-drivers.mjs.map +1 -0
- package/dist/drizzle/email-model.d.mts +9 -13
- package/dist/drizzle/email-target.d.mts +10 -11
- package/dist/drizzle/email-target.mjs +33 -70
- package/dist/drizzle/email-target.mjs.map +1 -1
- package/dist/drizzle/model.d.mts +1 -10
- package/dist/drizzle/model.mjs +1 -2
- package/dist/drizzle/model.mjs.map +1 -1
- package/dist/drizzle/mysql-identity.mjs +3 -6
- package/dist/drizzle/mysql-identity.mjs.map +1 -1
- package/dist/drizzle/native-clock.d.mts +9 -0
- package/dist/drizzle/native-clock.mjs +18 -0
- package/dist/drizzle/native-clock.mjs.map +1 -0
- package/dist/drizzle/native-database.d.mts +46 -0
- package/dist/drizzle/native-database.mjs +6 -5
- package/dist/drizzle/native-database.mjs.map +1 -1
- package/dist/drizzle/native-sql-table.mjs +13 -5
- package/dist/drizzle/native-sql-table.mjs.map +1 -1
- package/dist/drizzle/native-target.d.mts +6 -0
- package/dist/drizzle/native-target.mjs +44 -0
- package/dist/drizzle/native-target.mjs.map +1 -0
- package/dist/drizzle/oauth-connected-drivers.mjs +4 -56
- package/dist/drizzle/oauth-connected-drivers.mjs.map +1 -1
- package/dist/drizzle/oauth-connected-model.d.mts +5 -22
- package/dist/drizzle/oauth-connected-model.mjs +1 -7
- package/dist/drizzle/oauth-connected-reference.d.mts +5 -7
- package/dist/drizzle/oauth-connected-reference.mjs +11 -3
- package/dist/drizzle/oauth-connected-reference.mjs.map +1 -1
- package/dist/drizzle/oauth-drivers.mjs +1 -2
- package/dist/drizzle/oauth-drivers.mjs.map +1 -1
- package/dist/drizzle/oauth-model.d.mts +11 -37
- package/dist/drizzle/oauth-model.mjs +3 -4
- package/dist/drizzle/oauth-model.mjs.map +1 -1
- package/dist/drizzle/oauth-proxy.d.mts +1 -1
- package/dist/drizzle/oauth-proxy.mjs +1 -1
- package/dist/drizzle/oauth-target.d.mts +9 -6
- package/dist/drizzle/oauth-target.mjs +47 -15
- package/dist/drizzle/oauth-target.mjs.map +1 -1
- package/dist/drizzle/passkey/target.d.mts +14 -0
- package/dist/drizzle/passkey/target.mjs +52 -0
- package/dist/drizzle/passkey/target.mjs.map +1 -0
- package/dist/drizzle/passkey/write-target.d.mts +11 -0
- package/dist/drizzle/passkey/write-target.mjs +28 -0
- package/dist/drizzle/passkey/write-target.mjs.map +1 -0
- package/dist/drizzle/passkey-drivers.mjs +2 -4
- package/dist/drizzle/passkey-drivers.mjs.map +1 -1
- package/dist/drizzle/passkey-model.d.mts +5 -26
- package/dist/drizzle/passkey-model.mjs +2 -8
- package/dist/drizzle/passkey-registration-ceremony-model.d.mts +3 -6
- package/dist/drizzle/passkey-write-drivers.mjs +2 -3
- package/dist/drizzle/passkey-write-drivers.mjs.map +1 -1
- package/dist/drizzle/passkey-write-model.d.mts +7 -9
- package/dist/drizzle/passkey-write-model.mjs +1 -3
- package/dist/drizzle/passkey-write-model.mjs.map +1 -1
- package/dist/drizzle/password-drivers.mjs +31 -0
- package/dist/drizzle/password-drivers.mjs.map +1 -0
- package/dist/drizzle/password-model.d.mts +7 -10
- package/dist/drizzle/password-target.d.mts +7 -8
- package/dist/drizzle/password-target.mjs +23 -68
- package/dist/drizzle/password-target.mjs.map +1 -1
- package/dist/drizzle/pg-identity.mjs +3 -6
- package/dist/drizzle/pg-identity.mjs.map +1 -1
- package/dist/drizzle/phone-drivers.mjs +24 -0
- package/dist/drizzle/phone-drivers.mjs.map +1 -0
- package/dist/drizzle/phone-model.d.mts +13 -104
- package/dist/drizzle/phone-model.mjs +5 -33
- package/dist/drizzle/phone-model.mjs.map +1 -1
- package/dist/drizzle/phone-target.mjs +22 -171
- package/dist/drizzle/phone-target.mjs.map +1 -1
- package/dist/drizzle/proof-drivers.mjs +24 -0
- package/dist/drizzle/proof-drivers.mjs.map +1 -0
- package/dist/drizzle/proof-model.d.mts +7 -15
- package/dist/drizzle/proof-target.d.mts +5 -5
- package/dist/drizzle/proof-target.mjs +14 -28
- package/dist/drizzle/proof-target.mjs.map +1 -1
- package/dist/drizzle/session-drivers.mjs +97 -0
- package/dist/drizzle/session-drivers.mjs.map +1 -0
- package/dist/drizzle/session-model.d.mts +11 -22
- package/dist/drizzle/sqlite-do-database.d.mts +3 -3
- package/dist/drizzle/sqlite-do-database.mjs +6 -1
- package/dist/drizzle/sqlite-do-database.mjs.map +1 -1
- package/dist/drizzle/sqlite-identity.mjs +3 -5
- package/dist/drizzle/sqlite-identity.mjs.map +1 -1
- package/dist/drizzle/step-up-model.d.mts +2 -5
- package/dist/drizzle/storage-validation.mjs +2 -1
- package/dist/drizzle/storage-validation.mjs.map +1 -1
- package/dist/drizzle/totp-model.d.mts +7 -74
- package/dist/drizzle/totp-model.mjs +1 -5
- package/dist/drizzle/totp-model.mjs.map +1 -1
- package/dist/drizzle/totp-target.mjs +39 -75
- package/dist/drizzle/totp-target.mjs.map +1 -1
- package/dist/drizzle/transaction-handle.mjs +13 -0
- package/dist/drizzle/transaction-handle.mjs.map +1 -0
- package/dist/drizzle/transaction-mysql.mjs +43 -12
- package/dist/drizzle/transaction-mysql.mjs.map +1 -1
- package/dist/index.d.mts +17 -22
- package/dist/index.mjs +10 -16
- package/dist/internal/drizzle-postgres.mjs +4 -6
- package/dist/internal/drizzle-postgres.mjs.map +1 -1
- package/dist/internal/drizzle-sqlite.mjs +4 -6
- package/dist/internal/drizzle-sqlite.mjs.map +1 -1
- package/package.json +1 -1
- package/src/D1.ts +77 -74
- package/src/Libsql.ts +65 -105
- package/src/Mysql2.ts +52 -87
- package/src/Pglite.ts +74 -81
- package/src/Postgres.ts +74 -81
- package/src/SqliteBun.ts +65 -113
- package/src/SqliteDo.ts +58 -106
- package/src/SqliteNode.ts +65 -113
- package/src/SqliteWasm.ts +65 -113
- package/src/drizzle/d1-identity.ts +2 -2
- package/src/drizzle/driver-types.ts +26 -0
- package/src/drizzle/email-drivers.ts +320 -0
- package/src/drizzle/email-model.ts +24 -78
- package/src/drizzle/email-target.ts +118 -211
- package/src/drizzle/model.ts +0 -2
- package/src/drizzle/mysql-identity.ts +4 -24
- package/src/drizzle/native-clock.ts +21 -0
- package/src/drizzle/native-database.ts +59 -18
- package/src/drizzle/native-sql-table.ts +104 -87
- package/src/drizzle/native-target.ts +120 -0
- package/src/drizzle/oauth-connected-drivers.ts +24 -233
- package/src/drizzle/oauth-connected-model.ts +3 -93
- package/src/drizzle/oauth-connected-reference.ts +16 -25
- package/src/drizzle/oauth-drivers.ts +58 -99
- package/src/drizzle/oauth-model.ts +27 -132
- package/src/drizzle/oauth-target.ts +250 -33
- package/src/drizzle/passkey/target.ts +205 -0
- package/src/drizzle/passkey/write-target.ts +91 -0
- package/src/drizzle/passkey-drivers.ts +35 -133
- package/src/drizzle/passkey-model.ts +3 -81
- package/src/drizzle/passkey-registration-ceremony-model.ts +5 -25
- package/src/drizzle/passkey-write-drivers.ts +32 -102
- package/src/drizzle/passkey-write-model.ts +10 -44
- package/src/drizzle/password-drivers.ts +286 -0
- package/src/drizzle/password-model.ts +10 -44
- package/src/drizzle/password-target.ts +85 -239
- package/src/drizzle/pg-identity.ts +4 -19
- package/src/drizzle/phone-drivers.ts +142 -0
- package/src/drizzle/phone-model.ts +22 -162
- package/src/drizzle/phone-target.ts +51 -493
- package/src/drizzle/proof-drivers.ts +123 -0
- package/src/drizzle/proof-model.ts +12 -123
- package/src/drizzle/proof-target.ts +38 -102
- package/src/drizzle/session-drivers.ts +696 -0
- package/src/drizzle/session-model.ts +54 -118
- package/src/drizzle/sqlite-do-database.ts +8 -0
- package/src/drizzle/sqlite-identity.ts +4 -22
- package/src/drizzle/step-up-model.ts +13 -37
- package/src/drizzle/storage-validation.ts +2 -1
- package/src/drizzle/totp-model.ts +20 -77
- package/src/drizzle/totp-target.ts +121 -261
- package/src/drizzle/transaction-handle.ts +41 -0
- package/src/drizzle/transaction-mysql.ts +90 -25
- package/src/index.ts +7 -122
- package/src/internal/drizzle-postgres.ts +4 -7
- package/src/internal/drizzle-sqlite.ts +4 -7
- package/dist/drizzle/crypto.mjs +0 -11
- package/dist/drizzle/crypto.mjs.map +0 -1
- package/dist/drizzle/d1-emails.d.mts +0 -62
- package/dist/drizzle/d1-emails.mjs +0 -626
- package/dist/drizzle/d1-emails.mjs.map +0 -1
- package/dist/drizzle/d1-generated-statement.mjs +0 -79
- package/dist/drizzle/d1-generated-statement.mjs.map +0 -1
- package/dist/drizzle/d1-oauth.d.mts +0 -331
- package/dist/drizzle/d1-oauth.mjs +0 -79
- package/dist/drizzle/d1-oauth.mjs.map +0 -1
- package/dist/drizzle/d1-passkey.d.mts +0 -37
- package/dist/drizzle/d1-passkey.mjs +0 -98
- package/dist/drizzle/d1-passkey.mjs.map +0 -1
- package/dist/drizzle/d1-password-prepared.d.mts +0 -25
- package/dist/drizzle/d1-password-prepared.mjs +0 -473
- package/dist/drizzle/d1-password-prepared.mjs.map +0 -1
- package/dist/drizzle/d1-passwords.d.mts +0 -70
- package/dist/drizzle/d1-passwords.mjs +0 -808
- package/dist/drizzle/d1-passwords.mjs.map +0 -1
- package/dist/drizzle/d1-phone.d.mts +0 -23
- package/dist/drizzle/d1-phone.mjs +0 -33
- package/dist/drizzle/d1-phone.mjs.map +0 -1
- package/dist/drizzle/d1-planning.d.mts +0 -11
- package/dist/drizzle/d1-planning.mjs +0 -43
- package/dist/drizzle/d1-planning.mjs.map +0 -1
- package/dist/drizzle/d1-proofs.d.mts +0 -80
- package/dist/drizzle/d1-proofs.mjs +0 -842
- package/dist/drizzle/d1-proofs.mjs.map +0 -1
- package/dist/drizzle/d1-sessions.d.mts +0 -68
- package/dist/drizzle/d1-sessions.mjs +0 -987
- package/dist/drizzle/d1-sessions.mjs.map +0 -1
- package/dist/drizzle/d1-totp.d.mts +0 -23
- package/dist/drizzle/d1-totp.mjs +0 -30
- package/dist/drizzle/d1-totp.mjs.map +0 -1
- package/dist/drizzle/email-registration.d.mts +0 -33
- package/dist/drizzle/email-registration.mjs +0 -281
- package/dist/drizzle/email-registration.mjs.map +0 -1
- package/dist/drizzle/email-sql.d.mts +0 -1
- package/dist/drizzle/email-sql.mjs +0 -9
- package/dist/drizzle/email-sql.mjs.map +0 -1
- package/dist/drizzle/mysql-emails.d.mts +0 -71
- package/dist/drizzle/mysql-emails.mjs +0 -43
- package/dist/drizzle/mysql-emails.mjs.map +0 -1
- package/dist/drizzle/mysql-password-prepared.d.mts +0 -30
- package/dist/drizzle/mysql-password-prepared.mjs +0 -21
- package/dist/drizzle/mysql-password-prepared.mjs.map +0 -1
- package/dist/drizzle/mysql-passwords.d.mts +0 -71
- package/dist/drizzle/mysql-passwords.mjs +0 -43
- package/dist/drizzle/mysql-passwords.mjs.map +0 -1
- package/dist/drizzle/mysql-proofs.d.mts +0 -75
- package/dist/drizzle/mysql-proofs.mjs +0 -28
- package/dist/drizzle/mysql-proofs.mjs.map +0 -1
- package/dist/drizzle/mysql-sessions.d.mts +0 -92
- package/dist/drizzle/mysql-sessions.mjs +0 -58
- package/dist/drizzle/mysql-sessions.mjs.map +0 -1
- package/dist/drizzle/oauth-connected-model.mjs.map +0 -1
- package/dist/drizzle/oauth-connected-target.d.mts +0 -6
- package/dist/drizzle/oauth-connected-target.mjs +0 -12
- package/dist/drizzle/oauth-connected-target.mjs.map +0 -1
- package/dist/drizzle/oauth-kernel.mjs +0 -11
- package/dist/drizzle/oauth-kernel.mjs.map +0 -1
- package/dist/drizzle/oauth-mysql.mjs +0 -8
- package/dist/drizzle/oauth-mysql.mjs.map +0 -1
- package/dist/drizzle/passkey-kernel.mjs +0 -8
- package/dist/drizzle/passkey-kernel.mjs.map +0 -1
- package/dist/drizzle/passkey-model.mjs.map +0 -1
- package/dist/drizzle/passkey-registration-ceremony-model.mjs +0 -2
- package/dist/drizzle/passkey-state.mjs +0 -7
- package/dist/drizzle/passkey-state.mjs.map +0 -1
- package/dist/drizzle/passkey-target.d.mts +0 -2
- package/dist/drizzle/passkey-target.mjs +0 -7
- package/dist/drizzle/passkey-target.mjs.map +0 -1
- package/dist/drizzle/passkey-write-target.d.mts +0 -5
- package/dist/drizzle/passkey-write-target.mjs +0 -7
- package/dist/drizzle/passkey-write-target.mjs.map +0 -1
- package/dist/drizzle/password-prepared-model.d.mts +0 -92
- package/dist/drizzle/password-prepared-model.mjs +0 -11
- package/dist/drizzle/password-prepared-model.mjs.map +0 -1
- package/dist/drizzle/password-prepared-sql.mjs +0 -395
- package/dist/drizzle/password-prepared-sql.mjs.map +0 -1
- package/dist/drizzle/password-prepared-state.mjs +0 -104
- package/dist/drizzle/password-prepared-state.mjs.map +0 -1
- package/dist/drizzle/password-prepared-target.d.mts +0 -13
- package/dist/drizzle/password-prepared-target.mjs +0 -62
- package/dist/drizzle/password-prepared-target.mjs.map +0 -1
- package/dist/drizzle/password-registration.d.mts +0 -7
- package/dist/drizzle/password-registration.mjs +0 -137
- package/dist/drizzle/password-registration.mjs.map +0 -1
- package/dist/drizzle/password-sql.d.mts +0 -1
- package/dist/drizzle/password-sql.mjs +0 -10
- package/dist/drizzle/password-sql.mjs.map +0 -1
- package/dist/drizzle/pg-emails.d.mts +0 -72
- package/dist/drizzle/pg-emails.mjs +0 -43
- package/dist/drizzle/pg-emails.mjs.map +0 -1
- package/dist/drizzle/pg-password-prepared.d.mts +0 -31
- package/dist/drizzle/pg-password-prepared.mjs +0 -21
- package/dist/drizzle/pg-password-prepared.mjs.map +0 -1
- package/dist/drizzle/pg-passwords.d.mts +0 -72
- package/dist/drizzle/pg-passwords.mjs +0 -43
- package/dist/drizzle/pg-passwords.mjs.map +0 -1
- package/dist/drizzle/pg-proofs.d.mts +0 -76
- package/dist/drizzle/pg-proofs.mjs +0 -27
- package/dist/drizzle/pg-proofs.mjs.map +0 -1
- package/dist/drizzle/pg-sessions.d.mts +0 -93
- package/dist/drizzle/pg-sessions.mjs +0 -58
- package/dist/drizzle/pg-sessions.mjs.map +0 -1
- package/dist/drizzle/phone-state.mjs +0 -14
- package/dist/drizzle/phone-state.mjs.map +0 -1
- package/dist/drizzle/phone-target.d.mts +0 -15
- package/dist/drizzle/proof-sql.d.mts +0 -1
- package/dist/drizzle/proof-sql.mjs +0 -8
- package/dist/drizzle/proof-sql.mjs.map +0 -1
- package/dist/drizzle/query-operations.mjs +0 -31
- package/dist/drizzle/query-operations.mjs.map +0 -1
- package/dist/drizzle/session-sql.d.mts +0 -1
- package/dist/drizzle/session-sql.mjs +0 -9
- package/dist/drizzle/session-sql.mjs.map +0 -1
- package/dist/drizzle/session-target.d.mts +0 -30
- package/dist/drizzle/session-target.mjs +0 -49
- package/dist/drizzle/session-target.mjs.map +0 -1
- package/dist/drizzle/sqlite-emails.mjs +0 -50
- package/dist/drizzle/sqlite-emails.mjs.map +0 -1
- package/dist/drizzle/sqlite-password-prepared.mjs +0 -26
- package/dist/drizzle/sqlite-password-prepared.mjs.map +0 -1
- package/dist/drizzle/sqlite-passwords.mjs +0 -54
- package/dist/drizzle/sqlite-passwords.mjs.map +0 -1
- package/dist/drizzle/sqlite-proofs.mjs +0 -34
- package/dist/drizzle/sqlite-proofs.mjs.map +0 -1
- package/dist/drizzle/sqlite-sessions.mjs +0 -79
- package/dist/drizzle/sqlite-sessions.mjs.map +0 -1
- package/dist/drizzle/standalone-guard.d.mts +0 -2
- package/dist/drizzle/standalone-guard.mjs +0 -21
- package/dist/drizzle/standalone-guard.mjs.map +0 -1
- package/dist/drizzle/totp-state.d.mts +0 -37
- package/dist/drizzle/totp-state.mjs +0 -287
- package/dist/drizzle/totp-state.mjs.map +0 -1
- package/dist/drizzle/totp-target.d.mts +0 -15
- package/dist/drizzle/transaction-execution.d.mts +0 -2
- package/dist/drizzle/transaction-execution.mjs +0 -11
- package/dist/drizzle/transaction-execution.mjs.map +0 -1
- package/dist/drizzle/transaction-owner.d.mts +0 -1
- package/dist/drizzle/transaction-owner.mjs +0 -8
- package/dist/drizzle/transaction-owner.mjs.map +0 -1
- package/src/drizzle/crypto.ts +0 -14
- package/src/drizzle/d1-emails.ts +0 -1945
- package/src/drizzle/d1-generated-statement.ts +0 -129
- package/src/drizzle/d1-oauth.ts +0 -360
- package/src/drizzle/d1-passkey.ts +0 -383
- package/src/drizzle/d1-password-prepared.ts +0 -1265
- package/src/drizzle/d1-passwords.ts +0 -2060
- package/src/drizzle/d1-phone.ts +0 -103
- package/src/drizzle/d1-planning.ts +0 -104
- package/src/drizzle/d1-proofs.ts +0 -2354
- package/src/drizzle/d1-sessions.ts +0 -2940
- package/src/drizzle/d1-totp.ts +0 -88
- package/src/drizzle/email-registration.ts +0 -850
- package/src/drizzle/email-sql.ts +0 -25
- package/src/drizzle/mysql-emails.ts +0 -343
- package/src/drizzle/mysql-password-prepared.ts +0 -198
- package/src/drizzle/mysql-passwords.ts +0 -343
- package/src/drizzle/mysql-proofs.ts +0 -196
- package/src/drizzle/mysql-sessions.ts +0 -780
- package/src/drizzle/oauth-connected-target.ts +0 -21
- package/src/drizzle/oauth-kernel.ts +0 -10
- package/src/drizzle/oauth-mysql.ts +0 -10
- package/src/drizzle/passkey-kernel.ts +0 -4
- package/src/drizzle/passkey-state.ts +0 -3
- package/src/drizzle/passkey-target.ts +0 -23
- package/src/drizzle/passkey-write-target.ts +0 -9
- package/src/drizzle/password-prepared-model.ts +0 -241
- package/src/drizzle/password-prepared-sql.ts +0 -1201
- package/src/drizzle/password-prepared-state.ts +0 -231
- package/src/drizzle/password-prepared-target.ts +0 -169
- package/src/drizzle/password-registration.ts +0 -369
- package/src/drizzle/password-sql.ts +0 -16
- package/src/drizzle/pg-emails.ts +0 -343
- package/src/drizzle/pg-password-prepared.ts +0 -199
- package/src/drizzle/pg-passwords.ts +0 -342
- package/src/drizzle/pg-proofs.ts +0 -206
- package/src/drizzle/pg-sessions.ts +0 -789
- package/src/drizzle/phone-state.ts +0 -21
- package/src/drizzle/proof-sql.ts +0 -10
- package/src/drizzle/query-operations.ts +0 -49
- package/src/drizzle/session-sql.ts +0 -15
- package/src/drizzle/session-target.ts +0 -337
- package/src/drizzle/sqlite-emails.ts +0 -393
- package/src/drizzle/sqlite-password-prepared.ts +0 -230
- package/src/drizzle/sqlite-passwords.ts +0 -497
- package/src/drizzle/sqlite-proofs.ts +0 -229
- package/src/drizzle/sqlite-sessions.ts +0 -1013
- package/src/drizzle/totp-state.ts +0 -525
- package/src/drizzle/transaction-execution.ts +0 -13
- package/src/drizzle/transaction-owner.ts +0 -11
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { CurrentSessionSql } from "./session-sql.mjs";
|
|
2
|
-
import { acquireTransactionService, transactionService } from "./standalone-guard.mjs";
|
|
3
|
-
import { coordinateTargetAuthenticationAuthority, coordinateTargetPendingAuthentication, coordinateTargetSessionStepUp, coordinateTargetSignedSessionValidity, coordinateTargetStatefulSessions, makeTargetAuthenticationAuthorityServices, makeTargetPendingAuthenticationServices, makeTargetSessionStepUpServices, makeTargetSignedSessionValidityServices, makeTargetStatefulSessionServices } from "./session-target.mjs";
|
|
4
|
-
import { nativeDatabase } from "./native-database.mjs";
|
|
5
|
-
import { NativeDatabase } from "@yielded/auth-persistence/Adapter";
|
|
6
|
-
import { Context, Effect } from "effect";
|
|
7
|
-
import { AuthenticationAuthority } from "@yielded/auth/Sessions";
|
|
8
|
-
//#region src/drizzle/sqlite-sessions.ts
|
|
9
|
-
const sqliteSessionConfiguration = (mode, standaloneGuard, coordinatorGuard) => ({
|
|
10
|
-
mode,
|
|
11
|
-
locking: false,
|
|
12
|
-
standaloneGuard,
|
|
13
|
-
...coordinatorGuard === void 0 ? {} : { coordinatorGuard }
|
|
14
|
-
});
|
|
15
|
-
const makeSqliteAuthenticationAuthorityServices = (mapping, configuration) => makeTargetAuthenticationAuthorityServices(mapping, configuration);
|
|
16
|
-
const makeSqlitePendingAuthenticationServices = (mapping, configuration) => makeTargetPendingAuthenticationServices(mapping, configuration);
|
|
17
|
-
const makeSqliteStatefulSessionServices = (mapping, configuration) => makeTargetStatefulSessionServices(mapping, configuration);
|
|
18
|
-
const makeSqliteSignedSessionValidityServices = (mapping, configuration) => makeTargetSignedSessionValidityServices(mapping, configuration);
|
|
19
|
-
const coordinateSqliteAuthenticationAuthority = (database, mapping, configuration, owner) => coordinateTargetAuthenticationAuthority(database, mapping, configuration, owner);
|
|
20
|
-
const coordinateSqlitePendingAuthentication = (database, mapping, configuration, owner) => coordinateTargetPendingAuthentication(database, mapping, configuration, owner);
|
|
21
|
-
const coordinateSqliteStatefulSessions = (database, mapping, configuration, owner) => coordinateTargetStatefulSessions(database, mapping, configuration, owner);
|
|
22
|
-
const coordinateSqliteSignedSessionValidity = (database, mapping, configuration, owner) => coordinateTargetSignedSessionValidity(database, mapping, configuration, owner);
|
|
23
|
-
const makeSqliteSessionTarget = (databaseService, configuration) => {
|
|
24
|
-
const configurationFor = (database) => typeof configuration === "function" ? configuration(transactionService(database)) : configuration;
|
|
25
|
-
const standaloneConfiguration = typeof configuration === "function" ? Effect.map(acquireTransactionService(databaseService), configuration) : Effect.succeed(configuration);
|
|
26
|
-
function coordinateSessionStepUp(acquire, options, body) {
|
|
27
|
-
return Effect.flatMap(nativeDatabase(acquire), (database) => coordinateSqliteSessionStepUp(database, options.mapping, options.target, configurationFor(database), (transaction, services) => {
|
|
28
|
-
const provided = Context.make(options.target, services.sessionStepUpPersistence);
|
|
29
|
-
const work = Effect.provideContext(body, provided);
|
|
30
|
-
return options.transaction === void 0 ? work : Effect.provideService(work, options.transaction, options.transaction.of(transaction));
|
|
31
|
-
}).pipe(Effect.provideService(NativeDatabase, database)));
|
|
32
|
-
}
|
|
33
|
-
function coordinateAuthenticationAuthority(acquire, options, body) {
|
|
34
|
-
return Effect.flatMap(nativeDatabase(acquire), (database) => coordinateSqliteAuthenticationAuthority(database, options.mapping, configurationFor(database), (transaction, services) => {
|
|
35
|
-
const provided = Context.make(AuthenticationAuthority, services.authenticationAuthority);
|
|
36
|
-
const work = Effect.provideContext(body, provided);
|
|
37
|
-
return options.transaction === void 0 ? work : Effect.provideService(work, options.transaction, options.transaction.of(transaction));
|
|
38
|
-
}).pipe(Effect.provideService(NativeDatabase, database)));
|
|
39
|
-
}
|
|
40
|
-
function coordinatePendingAuthentication(acquire, options, body) {
|
|
41
|
-
return Effect.flatMap(nativeDatabase(acquire), (database) => coordinateSqlitePendingAuthentication(database, options.mapping, configurationFor(database), (transaction, services) => {
|
|
42
|
-
const provided = Context.make(options.target, services.pendingAuthentication);
|
|
43
|
-
const work = Effect.provideContext(body, provided);
|
|
44
|
-
return options.transaction === void 0 ? work : Effect.provideService(work, options.transaction, options.transaction.of(transaction));
|
|
45
|
-
}).pipe(Effect.provideService(NativeDatabase, database)));
|
|
46
|
-
}
|
|
47
|
-
function coordinateStatefulSessions(acquire, options, body) {
|
|
48
|
-
return Effect.flatMap(nativeDatabase(acquire), (database) => coordinateSqliteStatefulSessions(database, options.mapping, configurationFor(database), (transaction, services) => {
|
|
49
|
-
const provided = Context.make(options.persistence, services.statefulSessionPersistence).pipe(Context.add(options.repository, services.sessionRepository));
|
|
50
|
-
const work = Effect.provideContext(body, provided);
|
|
51
|
-
return options.transaction === void 0 ? work : Effect.provideService(work, options.transaction, options.transaction.of(transaction));
|
|
52
|
-
}).pipe(Effect.provideService(NativeDatabase, database)));
|
|
53
|
-
}
|
|
54
|
-
function coordinateSignedSessionValidity(acquire, options, body) {
|
|
55
|
-
return Effect.flatMap(nativeDatabase(acquire), (database) => coordinateSqliteSignedSessionValidity(database, options.mapping, configurationFor(database), (transaction, services) => {
|
|
56
|
-
const provided = Context.make(options.target, services.signedSessionValidity);
|
|
57
|
-
const work = Effect.provideContext(body, provided);
|
|
58
|
-
return options.transaction === void 0 ? work : Effect.provideService(work, options.transaction, options.transaction.of(transaction));
|
|
59
|
-
}).pipe(Effect.provideService(NativeDatabase, database)));
|
|
60
|
-
}
|
|
61
|
-
return {
|
|
62
|
-
makeSessionStepUpServices: (mapping, target) => Effect.flatMap(standaloneConfiguration, (configuration) => makeSqliteSessionStepUpServices(mapping, target, configuration)).pipe(Effect.provideServiceEffect(CurrentSessionSql, nativeDatabase(databaseService)), Effect.provideServiceEffect(NativeDatabase, nativeDatabase(databaseService))),
|
|
63
|
-
coordinateSessionStepUp,
|
|
64
|
-
makeAuthenticationAuthorityServices: (mapping) => Effect.flatMap(standaloneConfiguration, (configuration) => makeSqliteAuthenticationAuthorityServices(mapping, configuration)).pipe(Effect.provideServiceEffect(CurrentSessionSql, nativeDatabase(databaseService)), Effect.provideServiceEffect(NativeDatabase, nativeDatabase(databaseService))),
|
|
65
|
-
makePendingAuthenticationServices: (mapping) => Effect.flatMap(standaloneConfiguration, (configuration) => makeSqlitePendingAuthenticationServices(mapping, configuration)).pipe(Effect.provideServiceEffect(CurrentSessionSql, nativeDatabase(databaseService)), Effect.provideServiceEffect(NativeDatabase, nativeDatabase(databaseService))),
|
|
66
|
-
makeStatefulSessionServices: (mapping) => Effect.flatMap(standaloneConfiguration, (configuration) => makeSqliteStatefulSessionServices(mapping, configuration)).pipe(Effect.provideServiceEffect(CurrentSessionSql, nativeDatabase(databaseService)), Effect.provideServiceEffect(NativeDatabase, nativeDatabase(databaseService))),
|
|
67
|
-
makeSignedSessionValidityServices: (mapping) => Effect.flatMap(standaloneConfiguration, (configuration) => makeSqliteSignedSessionValidityServices(mapping, configuration)).pipe(Effect.provideServiceEffect(CurrentSessionSql, nativeDatabase(databaseService)), Effect.provideServiceEffect(NativeDatabase, nativeDatabase(databaseService))),
|
|
68
|
-
coordinateAuthenticationAuthority,
|
|
69
|
-
coordinatePendingAuthentication,
|
|
70
|
-
coordinateStatefulSessions,
|
|
71
|
-
coordinateSignedSessionValidity
|
|
72
|
-
};
|
|
73
|
-
};
|
|
74
|
-
const makeSqliteSessionStepUpServices = (mapping, target, configuration) => makeTargetSessionStepUpServices(mapping, target, configuration);
|
|
75
|
-
const coordinateSqliteSessionStepUp = (database, mapping, target, configuration, owner) => coordinateTargetSessionStepUp(database, mapping, target, configuration, owner);
|
|
76
|
-
//#endregion
|
|
77
|
-
export { coordinateSqliteAuthenticationAuthority, coordinateSqlitePendingAuthentication, coordinateSqliteSessionStepUp, coordinateSqliteSignedSessionValidity, coordinateSqliteStatefulSessions, makeSqliteAuthenticationAuthorityServices, makeSqlitePendingAuthenticationServices, makeSqliteSessionStepUpServices, makeSqliteSessionTarget, makeSqliteSignedSessionValidityServices, makeSqliteStatefulSessionServices, sqliteSessionConfiguration };
|
|
78
|
-
|
|
79
|
-
//# sourceMappingURL=sqlite-sessions.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sqlite-sessions.mjs","names":[],"sources":["../../src/drizzle/sqlite-sessions.ts"],"sourcesContent":["import { NativeDatabase } from \"@yielded/auth-persistence/Adapter\";\nimport type { LifecycleHooks, HookConfigurationError } from \"@yielded/auth/Hooks\";\nimport {\n AuthenticationAuthority,\n type SessionUnavailable,\n type PendingAuthentication,\n type SessionRepository,\n type SignedSessionValidity,\n type StatefulSessionPersistence,\n type SessionStepUpPersistence,\n} from \"@yielded/auth/Sessions\";\nimport type { AnyRelations } from \"drizzle-orm\";\nimport type { EffectLibsqlDatabase } from \"drizzle-orm/effect-libsql\";\nimport type { EffectSQLiteBunDatabase } from \"drizzle-orm/effect-sqlite-bun\";\nimport type { EffectSQLiteNodeDatabase } from \"drizzle-orm/effect-sqlite-node\";\nimport type { EffectSQLiteWasmDatabase } from \"drizzle-orm/effect-sqlite-wasm\";\nimport type { AnySQLiteTable } from \"drizzle-orm/sqlite-core\";\nimport { Context, Effect } from \"effect\";\nimport type { SqlError } from \"effect/sql/SqlError\";\n\nimport { nativeDatabase } from \"./native-database\";\nimport type {\n AuthenticationAuthorityMapping,\n PendingAuthenticationMapping,\n SignedSessionValidityMapping,\n StatefulSessionMapping,\n} from \"./session-model\";\nimport { CurrentSessionSql } from \"./session-sql\";\nimport {\n coordinateTargetAuthenticationAuthority,\n coordinateTargetPendingAuthentication,\n coordinateTargetSignedSessionValidity,\n coordinateTargetStatefulSessions,\n makeTargetAuthenticationAuthorityServices,\n makeTargetPendingAuthenticationServices,\n makeTargetSignedSessionValidityServices,\n makeTargetStatefulSessionServices,\n type SessionTargetConfiguration,\n makeTargetSessionStepUpServices,\n coordinateTargetSessionStepUp,\n} from \"./session-target\";\nimport type { DatabaseValue } from \"./sqlite-do-database\";\nimport {\n type TransactionService,\n acquireTransactionService,\n transactionService,\n} from \"./standalone-guard\";\nimport type { SuppliedService } from \"./SuppliedService\";\n\ntype Database =\n | EffectLibsqlDatabase<AnyRelations>\n | EffectSQLiteBunDatabase<AnyRelations>\n | DatabaseValue<AnyRelations>\n | EffectSQLiteNodeDatabase<AnyRelations>\n | EffectSQLiteWasmDatabase<AnyRelations>;\ntype TransactionOf<D extends Database> = Parameters<Parameters<D[\"transaction\"]>[0]>[0];\n\nexport const sqliteSessionConfiguration = (\n mode: \"interactive\" | \"synchronous\",\n standaloneGuard: Effect.Effect<void, SessionUnavailable>,\n coordinatorGuard?: Effect.Effect<void, SessionUnavailable>,\n): SessionTargetConfiguration => ({\n mode,\n locking: false,\n standaloneGuard,\n ...(coordinatorGuard === undefined ? {} : { coordinatorGuard }),\n});\n\nexport const makeSqliteAuthenticationAuthorityServices = <\n Claims,\n S extends AnySQLiteTable,\n C extends AnySQLiteTable,\n F extends AnySQLiteTable,\n P extends AnySQLiteTable,\n NativeId,\n>(\n mapping: AuthenticationAuthorityMapping<Claims, S, C, F, P, NativeId>,\n configuration: SessionTargetConfiguration,\n) => makeTargetAuthenticationAuthorityServices<Claims>(mapping, configuration);\n\nexport const makeSqlitePendingAuthenticationServices = <\n Claims,\n S extends AnySQLiteTable,\n C extends AnySQLiteTable,\n P extends AnySQLiteTable,\n F extends AnySQLiteTable,\n NativeId,\n>(\n mapping: PendingAuthenticationMapping<Claims, S, C, P, F, NativeId>,\n configuration: SessionTargetConfiguration,\n) => makeTargetPendingAuthenticationServices<Claims>(mapping, configuration);\n\nexport const makeSqliteStatefulSessionServices = <\n Claims,\n S extends AnySQLiteTable,\n C extends AnySQLiteTable,\n Session extends AnySQLiteTable,\n F extends AnySQLiteTable,\n P extends AnySQLiteTable,\n NativeId,\n NativeSessionId,\n>(\n mapping: StatefulSessionMapping<Claims, S, C, Session, F, P, NativeId, NativeSessionId>,\n configuration: SessionTargetConfiguration,\n) => makeTargetStatefulSessionServices<Claims>(mapping, configuration);\n\nexport const makeSqliteSignedSessionValidityServices = <\n S extends AnySQLiteTable,\n T extends AnySQLiteTable,\n NativeId,\n NativeSessionId,\n>(\n mapping: SignedSessionValidityMapping<S, T, NativeId, NativeSessionId>,\n configuration: SessionTargetConfiguration,\n) => makeTargetSignedSessionValidityServices(mapping, configuration);\n\nexport const coordinateSqliteAuthenticationAuthority = <\n Claims,\n D extends Database,\n S extends AnySQLiteTable,\n C extends AnySQLiteTable,\n F extends AnySQLiteTable,\n P extends AnySQLiteTable,\n NativeId,\n A,\n E,\n R,\n>(\n database: D,\n mapping: AuthenticationAuthorityMapping<Claims, S, C, F, P, NativeId>,\n configuration: SessionTargetConfiguration,\n owner: (\n transaction: TransactionOf<D>,\n services: { readonly authenticationAuthority: AuthenticationAuthority[\"Service\"] },\n ) => Effect.Effect<A, E, R>,\n) =>\n coordinateTargetAuthenticationAuthority<Claims, TransactionOf<D>, A, E, R>(\n database,\n mapping,\n configuration,\n owner,\n );\n\nexport const coordinateSqlitePendingAuthentication = <\n Claims,\n D extends Database,\n S extends AnySQLiteTable,\n C extends AnySQLiteTable,\n P extends AnySQLiteTable,\n F extends AnySQLiteTable,\n NativeId,\n A,\n E,\n R,\n>(\n database: D,\n mapping: PendingAuthenticationMapping<Claims, S, C, P, F, NativeId>,\n configuration: SessionTargetConfiguration,\n owner: (\n transaction: TransactionOf<D>,\n services: { readonly pendingAuthentication: PendingAuthentication<Claims> },\n ) => Effect.Effect<A, E, R>,\n) =>\n coordinateTargetPendingAuthentication<Claims, TransactionOf<D>, A, E, R>(\n database,\n mapping,\n configuration,\n owner,\n );\n\nexport const coordinateSqliteStatefulSessions = <\n Claims,\n D extends Database,\n S extends AnySQLiteTable,\n C extends AnySQLiteTable,\n Session extends AnySQLiteTable,\n F extends AnySQLiteTable,\n P extends AnySQLiteTable,\n NativeId,\n NativeSessionId,\n A,\n E,\n R,\n>(\n database: D,\n mapping: StatefulSessionMapping<Claims, S, C, Session, F, P, NativeId, NativeSessionId>,\n configuration: SessionTargetConfiguration,\n owner: (\n transaction: TransactionOf<D>,\n services: {\n readonly statefulSessionPersistence: StatefulSessionPersistence<Claims>;\n readonly sessionRepository: SessionRepository;\n },\n ) => Effect.Effect<A, E, R>,\n) =>\n coordinateTargetStatefulSessions<Claims, TransactionOf<D>, A, E, R>(\n database,\n mapping,\n configuration,\n owner,\n );\n\nexport const coordinateSqliteSignedSessionValidity = <\n D extends Database,\n S extends AnySQLiteTable,\n T extends AnySQLiteTable,\n NativeId,\n NativeSessionId,\n A,\n E,\n R,\n>(\n database: D,\n mapping: SignedSessionValidityMapping<S, T, NativeId, NativeSessionId>,\n configuration: SessionTargetConfiguration,\n owner: (\n transaction: TransactionOf<D>,\n services: { readonly signedSessionValidity: SignedSessionValidity },\n ) => Effect.Effect<A, E, R>,\n) =>\n coordinateTargetSignedSessionValidity<TransactionOf<D>, A, E, R>(\n database,\n mapping,\n configuration,\n owner,\n );\n\nexport const makeSqliteSessionTarget = <\n DatabaseId,\n D extends Database,\n Synchronous extends boolean = false,\n>(\n databaseService: Context.Service<DatabaseId, D>,\n configuration:\n | SessionTargetConfiguration\n | ((service: TransactionService | undefined) => SessionTargetConfiguration),\n) => {\n const configurationFor = (database: D) =>\n typeof configuration === \"function\"\n ? configuration(transactionService(database))\n : configuration;\n\n const standaloneConfiguration =\n typeof configuration === \"function\"\n ? Effect.map(acquireTransactionService(databaseService), configuration)\n : Effect.succeed(configuration);\n\n function coordinateSessionStepUp<\n Database extends D,\n Claims,\n Id,\n S extends AnySQLiteTable,\n C extends AnySQLiteTable,\n I extends AnySQLiteTable,\n Session extends AnySQLiteTable,\n T extends AnySQLiteTable,\n NativeId,\n NativeSessionId,\n A,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: SessionStepUpMapping<\n NoInfer<Claims>,\n S,\n C,\n I,\n Session,\n T,\n NativeId,\n NativeSessionId\n >;\n readonly target: SuppliedService<Id, SessionStepUpPersistence<Claims>>;\n readonly transaction?: never;\n },\n body: Effect.Effect<A, E, Synchronous extends true ? NoInfer<Id> : R>,\n ): Effect.Effect<\n A,\n E | SessionUnavailable | HookConfigurationError | SqlError | DatabaseError,\n (Synchronous extends true ? never : Exclude<R, Id>) | LifecycleHooks | DatabaseRequirements\n >;\n function coordinateSessionStepUp<\n Database extends D,\n Claims,\n Id,\n S extends AnySQLiteTable,\n C extends AnySQLiteTable,\n I extends AnySQLiteTable,\n Session extends AnySQLiteTable,\n T extends AnySQLiteTable,\n NativeId,\n NativeSessionId,\n A,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n TxId,\n TxShape,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: SessionStepUpMapping<\n NoInfer<Claims>,\n S,\n C,\n I,\n Session,\n T,\n NativeId,\n NativeSessionId\n >;\n readonly target: SuppliedService<Id, SessionStepUpPersistence<Claims>>;\n readonly transaction: SuppliedService<TxId, NoInfer<TransactionOf<Database>>, TxShape>;\n },\n body: Effect.Effect<A, E, Synchronous extends true ? NoInfer<Id | TxId> : R>,\n ): Effect.Effect<\n A,\n E | SessionUnavailable | HookConfigurationError | SqlError | DatabaseError,\n | (Synchronous extends true ? never : Exclude<R, Id | TxId>)\n | LifecycleHooks\n | DatabaseRequirements\n >;\n function coordinateSessionStepUp<\n Database extends D,\n Claims,\n Id,\n S extends AnySQLiteTable,\n C extends AnySQLiteTable,\n I extends AnySQLiteTable,\n Session extends AnySQLiteTable,\n T extends AnySQLiteTable,\n NativeId,\n NativeSessionId,\n A,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n TxId,\n TxShape,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: SessionStepUpMapping<\n NoInfer<Claims>,\n S,\n C,\n I,\n Session,\n T,\n NativeId,\n NativeSessionId\n >;\n readonly target: SuppliedService<Id, SessionStepUpPersistence<Claims>>;\n readonly transaction?: SuppliedService<TxId, NoInfer<TransactionOf<Database>>, TxShape>;\n },\n body: Effect.Effect<A, E, R>,\n ): Effect.Effect<\n A,\n E | SessionUnavailable | HookConfigurationError | SqlError | DatabaseError,\n Exclude<R, Id> | LifecycleHooks | DatabaseRequirements\n > {\n return Effect.flatMap(nativeDatabase(acquire), (database) =>\n coordinateSqliteSessionStepUp(\n database,\n options.mapping,\n options.target,\n configurationFor(database),\n (\n transaction: TransactionOf<Database>,\n services: { readonly sessionStepUpPersistence: SessionStepUpPersistence<Claims> },\n ) => {\n const provided = Context.make(options.target, services.sessionStepUpPersistence);\n const work = Effect.provideContext(body, provided);\n\n return options.transaction === undefined\n ? work\n : Effect.provideService(work, options.transaction, options.transaction.of(transaction));\n },\n ).pipe(Effect.provideService(NativeDatabase, database)),\n );\n }\n function coordinateAuthenticationAuthority<\n Database extends D,\n Claims,\n S extends AnySQLiteTable,\n C extends AnySQLiteTable,\n F extends AnySQLiteTable,\n P extends AnySQLiteTable,\n NativeId,\n A,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: AuthenticationAuthorityMapping<Claims, S, C, F, P, NativeId>;\n readonly transaction?: never;\n },\n body: Effect.Effect<A, E, Synchronous extends true ? NoInfer<AuthenticationAuthority> : R>,\n ): Effect.Effect<\n A,\n E | SessionUnavailable | HookConfigurationError | SqlError | DatabaseError,\n | (Synchronous extends true ? never : Exclude<R, AuthenticationAuthority>)\n | LifecycleHooks\n | DatabaseRequirements\n >;\n function coordinateAuthenticationAuthority<\n Database extends D,\n Claims,\n S extends AnySQLiteTable,\n C extends AnySQLiteTable,\n F extends AnySQLiteTable,\n P extends AnySQLiteTable,\n NativeId,\n A,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n TxId,\n TxShape,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: AuthenticationAuthorityMapping<Claims, S, C, F, P, NativeId>;\n readonly transaction: SuppliedService<TxId, NoInfer<TransactionOf<Database>>, TxShape>;\n },\n body: Effect.Effect<\n A,\n E,\n Synchronous extends true ? NoInfer<AuthenticationAuthority | TxId> : R\n >,\n ): Effect.Effect<\n A,\n E | SessionUnavailable | HookConfigurationError | SqlError | DatabaseError,\n | (Synchronous extends true ? never : Exclude<R, AuthenticationAuthority | TxId>)\n | LifecycleHooks\n | DatabaseRequirements\n >;\n function coordinateAuthenticationAuthority<\n Database extends D,\n Claims,\n S extends AnySQLiteTable,\n C extends AnySQLiteTable,\n F extends AnySQLiteTable,\n P extends AnySQLiteTable,\n NativeId,\n A,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n TxId,\n TxShape,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: AuthenticationAuthorityMapping<Claims, S, C, F, P, NativeId>;\n readonly transaction?: SuppliedService<TxId, NoInfer<TransactionOf<Database>>, TxShape>;\n },\n body: Effect.Effect<A, E, R>,\n ): Effect.Effect<\n A,\n E | SessionUnavailable | HookConfigurationError | SqlError | DatabaseError,\n Exclude<R, AuthenticationAuthority> | LifecycleHooks | DatabaseRequirements\n > {\n return Effect.flatMap(nativeDatabase(acquire), (database) =>\n coordinateSqliteAuthenticationAuthority(\n database,\n options.mapping,\n configurationFor(database),\n (\n transaction: TransactionOf<Database>,\n services: { readonly authenticationAuthority: AuthenticationAuthority[\"Service\"] },\n ) => {\n const provided = Context.make(AuthenticationAuthority, services.authenticationAuthority);\n const work = Effect.provideContext(body, provided);\n\n return options.transaction === undefined\n ? work\n : Effect.provideService(work, options.transaction, options.transaction.of(transaction));\n },\n ).pipe(Effect.provideService(NativeDatabase, database)),\n );\n }\n function coordinatePendingAuthentication<\n Database extends D,\n TargetId,\n Claims,\n S extends AnySQLiteTable,\n C extends AnySQLiteTable,\n P extends AnySQLiteTable,\n F extends AnySQLiteTable,\n NativeId,\n A,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: PendingAuthenticationMapping<NoInfer<Claims>, S, C, P, F, NativeId>;\n readonly target: SuppliedService<TargetId, PendingAuthentication<Claims>>;\n readonly transaction?: never;\n },\n body: Effect.Effect<A, E, Synchronous extends true ? NoInfer<TargetId> : R>,\n ): Effect.Effect<\n A,\n E | SessionUnavailable | HookConfigurationError | SqlError | DatabaseError,\n | (Synchronous extends true ? never : Exclude<R, TargetId>)\n | LifecycleHooks\n | DatabaseRequirements\n >;\n function coordinatePendingAuthentication<\n Database extends D,\n TargetId,\n Claims,\n S extends AnySQLiteTable,\n C extends AnySQLiteTable,\n P extends AnySQLiteTable,\n F extends AnySQLiteTable,\n NativeId,\n A,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n TxId,\n TxShape,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: PendingAuthenticationMapping<NoInfer<Claims>, S, C, P, F, NativeId>;\n readonly target: SuppliedService<TargetId, PendingAuthentication<Claims>>;\n readonly transaction: SuppliedService<TxId, NoInfer<TransactionOf<Database>>, TxShape>;\n },\n body: Effect.Effect<A, E, Synchronous extends true ? NoInfer<TargetId | TxId> : R>,\n ): Effect.Effect<\n A,\n E | SessionUnavailable | HookConfigurationError | SqlError | DatabaseError,\n | (Synchronous extends true ? never : Exclude<R, TargetId | TxId>)\n | LifecycleHooks\n | DatabaseRequirements\n >;\n function coordinatePendingAuthentication<\n Database extends D,\n TargetId,\n Claims,\n S extends AnySQLiteTable,\n C extends AnySQLiteTable,\n P extends AnySQLiteTable,\n F extends AnySQLiteTable,\n NativeId,\n A,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n TxId,\n TxShape,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: PendingAuthenticationMapping<NoInfer<Claims>, S, C, P, F, NativeId>;\n readonly target: SuppliedService<TargetId, PendingAuthentication<Claims>>;\n readonly transaction?: SuppliedService<TxId, NoInfer<TransactionOf<Database>>, TxShape>;\n },\n body: Effect.Effect<A, E, R>,\n ): Effect.Effect<\n A,\n E | SessionUnavailable | HookConfigurationError | SqlError | DatabaseError,\n Exclude<R, TargetId> | LifecycleHooks | DatabaseRequirements\n > {\n return Effect.flatMap(nativeDatabase(acquire), (database) =>\n coordinateSqlitePendingAuthentication(\n database,\n options.mapping,\n configurationFor(database),\n (\n transaction: TransactionOf<Database>,\n services: { readonly pendingAuthentication: PendingAuthentication<Claims> },\n ) => {\n const provided = Context.make(options.target, services.pendingAuthentication);\n const work = Effect.provideContext(body, provided);\n\n return options.transaction === undefined\n ? work\n : Effect.provideService(work, options.transaction, options.transaction.of(transaction));\n },\n ).pipe(Effect.provideService(NativeDatabase, database)),\n );\n }\n function coordinateStatefulSessions<\n Database extends D,\n PersistenceId,\n RepositoryId,\n Claims,\n S extends AnySQLiteTable,\n C extends AnySQLiteTable,\n Session extends AnySQLiteTable,\n F extends AnySQLiteTable,\n P extends AnySQLiteTable,\n NativeId,\n NativeSessionId,\n A,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: StatefulSessionMapping<\n NoInfer<Claims>,\n S,\n C,\n Session,\n F,\n P,\n NativeId,\n NativeSessionId\n >;\n readonly persistence: SuppliedService<PersistenceId, StatefulSessionPersistence<Claims>>;\n readonly repository: SuppliedService<RepositoryId, SessionRepository>;\n readonly transaction?: never;\n },\n body: Effect.Effect<A, E, Synchronous extends true ? NoInfer<PersistenceId | RepositoryId> : R>,\n ): Effect.Effect<\n A,\n E | SessionUnavailable | HookConfigurationError | SqlError | DatabaseError,\n | (Synchronous extends true ? never : Exclude<R, PersistenceId | RepositoryId>)\n | LifecycleHooks\n | DatabaseRequirements\n >;\n function coordinateStatefulSessions<\n Database extends D,\n PersistenceId,\n RepositoryId,\n Claims,\n S extends AnySQLiteTable,\n C extends AnySQLiteTable,\n Session extends AnySQLiteTable,\n F extends AnySQLiteTable,\n P extends AnySQLiteTable,\n NativeId,\n NativeSessionId,\n A,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n TxId,\n TxShape,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: StatefulSessionMapping<\n NoInfer<Claims>,\n S,\n C,\n Session,\n F,\n P,\n NativeId,\n NativeSessionId\n >;\n readonly persistence: SuppliedService<PersistenceId, StatefulSessionPersistence<Claims>>;\n readonly repository: SuppliedService<RepositoryId, SessionRepository>;\n readonly transaction: SuppliedService<TxId, NoInfer<TransactionOf<Database>>, TxShape>;\n },\n body: Effect.Effect<\n A,\n E,\n Synchronous extends true ? NoInfer<PersistenceId | RepositoryId | TxId> : R\n >,\n ): Effect.Effect<\n A,\n E | SessionUnavailable | HookConfigurationError | SqlError | DatabaseError,\n | (Synchronous extends true ? never : Exclude<R, PersistenceId | RepositoryId | TxId>)\n | LifecycleHooks\n | DatabaseRequirements\n >;\n function coordinateStatefulSessions<\n Database extends D,\n PersistenceId,\n RepositoryId,\n Claims,\n S extends AnySQLiteTable,\n C extends AnySQLiteTable,\n Session extends AnySQLiteTable,\n F extends AnySQLiteTable,\n P extends AnySQLiteTable,\n NativeId,\n NativeSessionId,\n A,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n TxId,\n TxShape,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: StatefulSessionMapping<\n NoInfer<Claims>,\n S,\n C,\n Session,\n F,\n P,\n NativeId,\n NativeSessionId\n >;\n readonly persistence: SuppliedService<PersistenceId, StatefulSessionPersistence<Claims>>;\n readonly repository: SuppliedService<RepositoryId, SessionRepository>;\n readonly transaction?: SuppliedService<TxId, NoInfer<TransactionOf<Database>>, TxShape>;\n },\n body: Effect.Effect<A, E, R>,\n ): Effect.Effect<\n A,\n E | SessionUnavailable | HookConfigurationError | SqlError | DatabaseError,\n Exclude<R, PersistenceId | RepositoryId> | LifecycleHooks | DatabaseRequirements\n > {\n return Effect.flatMap(nativeDatabase(acquire), (database) =>\n coordinateSqliteStatefulSessions(\n database,\n options.mapping,\n configurationFor(database),\n (\n transaction: TransactionOf<Database>,\n services: {\n readonly statefulSessionPersistence: StatefulSessionPersistence<Claims>;\n readonly sessionRepository: SessionRepository;\n },\n ) => {\n const provided = Context.make(\n options.persistence,\n services.statefulSessionPersistence,\n ).pipe(Context.add(options.repository, services.sessionRepository));\n\n const work = Effect.provideContext(body, provided);\n\n return options.transaction === undefined\n ? work\n : Effect.provideService(work, options.transaction, options.transaction.of(transaction));\n },\n ).pipe(Effect.provideService(NativeDatabase, database)),\n );\n }\n function coordinateSignedSessionValidity<\n Database extends D,\n TargetId,\n S extends AnySQLiteTable,\n T extends AnySQLiteTable,\n NativeId,\n NativeSessionId,\n A,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: SignedSessionValidityMapping<S, T, NativeId, NativeSessionId>;\n readonly target: SuppliedService<TargetId, SignedSessionValidity>;\n readonly transaction?: never;\n },\n body: Effect.Effect<A, E, Synchronous extends true ? NoInfer<TargetId> : R>,\n ): Effect.Effect<\n A,\n E | SessionUnavailable | HookConfigurationError | SqlError | DatabaseError,\n | (Synchronous extends true ? never : Exclude<R, TargetId>)\n | LifecycleHooks\n | DatabaseRequirements\n >;\n function coordinateSignedSessionValidity<\n Database extends D,\n TargetId,\n S extends AnySQLiteTable,\n T extends AnySQLiteTable,\n NativeId,\n NativeSessionId,\n A,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n TxId,\n TxShape,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: SignedSessionValidityMapping<S, T, NativeId, NativeSessionId>;\n readonly target: SuppliedService<TargetId, SignedSessionValidity>;\n readonly transaction: SuppliedService<TxId, NoInfer<TransactionOf<Database>>, TxShape>;\n },\n body: Effect.Effect<A, E, Synchronous extends true ? NoInfer<TargetId | TxId> : R>,\n ): Effect.Effect<\n A,\n E | SessionUnavailable | HookConfigurationError | SqlError | DatabaseError,\n | (Synchronous extends true ? never : Exclude<R, TargetId | TxId>)\n | LifecycleHooks\n | DatabaseRequirements\n >;\n function coordinateSignedSessionValidity<\n Database extends D,\n TargetId,\n S extends AnySQLiteTable,\n T extends AnySQLiteTable,\n NativeId,\n NativeSessionId,\n A,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n TxId,\n TxShape,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: SignedSessionValidityMapping<S, T, NativeId, NativeSessionId>;\n readonly target: SuppliedService<TargetId, SignedSessionValidity>;\n readonly transaction?: SuppliedService<TxId, NoInfer<TransactionOf<Database>>, TxShape>;\n },\n body: Effect.Effect<A, E, R>,\n ): Effect.Effect<\n A,\n E | SessionUnavailable | HookConfigurationError | SqlError | DatabaseError,\n Exclude<R, TargetId> | LifecycleHooks | DatabaseRequirements\n > {\n return Effect.flatMap(nativeDatabase(acquire), (database) =>\n coordinateSqliteSignedSessionValidity(\n database,\n options.mapping,\n configurationFor(database),\n (\n transaction: TransactionOf<Database>,\n services: { readonly signedSessionValidity: SignedSessionValidity },\n ) => {\n const provided = Context.make(options.target, services.signedSessionValidity);\n const work = Effect.provideContext(body, provided);\n\n return options.transaction === undefined\n ? work\n : Effect.provideService(work, options.transaction, options.transaction.of(transaction));\n },\n ).pipe(Effect.provideService(NativeDatabase, database)),\n );\n }\n\n return {\n makeSessionStepUpServices: <\n Claims,\n Id,\n S extends AnySQLiteTable,\n C extends AnySQLiteTable,\n I extends AnySQLiteTable,\n Session extends AnySQLiteTable,\n T extends AnySQLiteTable,\n NativeId,\n NativeSessionId,\n >(\n mapping: SessionStepUpMapping<\n NoInfer<Claims>,\n S,\n C,\n I,\n Session,\n T,\n NativeId,\n NativeSessionId\n >,\n target: Context.Service<Id, SessionStepUpPersistence<Claims>>,\n ) =>\n Effect.flatMap(standaloneConfiguration, (configuration) =>\n makeSqliteSessionStepUpServices(mapping, target, configuration),\n ).pipe(\n Effect.provideServiceEffect(CurrentSessionSql, nativeDatabase(databaseService)),\n Effect.provideServiceEffect(NativeDatabase, nativeDatabase(databaseService)),\n ),\n coordinateSessionStepUp,\n makeAuthenticationAuthorityServices: <\n Claims,\n S extends AnySQLiteTable,\n C extends AnySQLiteTable,\n F extends AnySQLiteTable,\n P extends AnySQLiteTable,\n NativeId,\n >(\n mapping: AuthenticationAuthorityMapping<Claims, S, C, F, P, NativeId>,\n ) =>\n Effect.flatMap(standaloneConfiguration, (configuration) =>\n makeSqliteAuthenticationAuthorityServices(mapping, configuration),\n ).pipe(\n Effect.provideServiceEffect(CurrentSessionSql, nativeDatabase(databaseService)),\n Effect.provideServiceEffect(NativeDatabase, nativeDatabase(databaseService)),\n ),\n makePendingAuthenticationServices: <\n Claims,\n S extends AnySQLiteTable,\n C extends AnySQLiteTable,\n P extends AnySQLiteTable,\n F extends AnySQLiteTable,\n NativeId,\n >(\n mapping: PendingAuthenticationMapping<Claims, S, C, P, F, NativeId>,\n ) =>\n Effect.flatMap(standaloneConfiguration, (configuration) =>\n makeSqlitePendingAuthenticationServices(mapping, configuration),\n ).pipe(\n Effect.provideServiceEffect(CurrentSessionSql, nativeDatabase(databaseService)),\n Effect.provideServiceEffect(NativeDatabase, nativeDatabase(databaseService)),\n ),\n makeStatefulSessionServices: <\n Claims,\n S extends AnySQLiteTable,\n C extends AnySQLiteTable,\n Session extends AnySQLiteTable,\n F extends AnySQLiteTable,\n P extends AnySQLiteTable,\n NativeId,\n NativeSessionId,\n >(\n mapping: StatefulSessionMapping<Claims, S, C, Session, F, P, NativeId, NativeSessionId>,\n ) =>\n Effect.flatMap(standaloneConfiguration, (configuration) =>\n makeSqliteStatefulSessionServices(mapping, configuration),\n ).pipe(\n Effect.provideServiceEffect(CurrentSessionSql, nativeDatabase(databaseService)),\n Effect.provideServiceEffect(NativeDatabase, nativeDatabase(databaseService)),\n ),\n makeSignedSessionValidityServices: <\n S extends AnySQLiteTable,\n T extends AnySQLiteTable,\n NativeId,\n NativeSessionId,\n >(\n mapping: SignedSessionValidityMapping<S, T, NativeId, NativeSessionId>,\n ) =>\n Effect.flatMap(standaloneConfiguration, (configuration) =>\n makeSqliteSignedSessionValidityServices(mapping, configuration),\n ).pipe(\n Effect.provideServiceEffect(CurrentSessionSql, nativeDatabase(databaseService)),\n Effect.provideServiceEffect(NativeDatabase, nativeDatabase(databaseService)),\n ),\n coordinateAuthenticationAuthority,\n coordinatePendingAuthentication,\n coordinateStatefulSessions,\n coordinateSignedSessionValidity,\n };\n};\n\nimport type { SessionStepUpMapping } from \"./step-up-model\";\n\nexport const makeSqliteSessionStepUpServices = <\n Claims,\n Id,\n S extends AnySQLiteTable,\n C extends AnySQLiteTable,\n I extends AnySQLiteTable,\n Session extends AnySQLiteTable,\n T extends AnySQLiteTable,\n NativeId,\n NativeSessionId,\n>(\n mapping: SessionStepUpMapping<NoInfer<Claims>, S, C, I, Session, T, NativeId, NativeSessionId>,\n target: Context.Service<Id, SessionStepUpPersistence<Claims>>,\n configuration: SessionTargetConfiguration,\n) => makeTargetSessionStepUpServices(mapping, target, configuration);\n\nexport const coordinateSqliteSessionStepUp = <\n Claims,\n Id,\n S extends AnySQLiteTable,\n C extends AnySQLiteTable,\n I extends AnySQLiteTable,\n Session extends AnySQLiteTable,\n T extends AnySQLiteTable,\n NativeId,\n NativeSessionId,\n D extends Database,\n A,\n E,\n R,\n>(\n database: D,\n mapping: SessionStepUpMapping<NoInfer<Claims>, S, C, I, Session, T, NativeId, NativeSessionId>,\n target: Context.Service<Id, SessionStepUpPersistence<Claims>>,\n configuration: SessionTargetConfiguration,\n owner: (\n transaction: TransactionOf<D>,\n services: { readonly sessionStepUpPersistence: SessionStepUpPersistence<Claims> },\n ) => Effect.Effect<A, E, R>,\n) =>\n coordinateTargetSessionStepUp<Claims, Id, TransactionOf<D>, A, E, R>(\n database,\n mapping,\n target,\n configuration,\n owner,\n );\n"],"mappings":";;;;;;;;AAyDA,MAAa,8BACX,MACA,iBAC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AmB,eAAe,eAAe,CAAC,GAC9E,OAAO,qBAAqB,gBAAgB,eAAe,eAAe,CAAC,CAC7E;EACF,oCAME,YAEA,OAAO,QAAQ,0BAA0B,kBACvC,wCAAwC,SAAS,aAAa,CAChE,CAAC,CAAC,KACA,OAAO,qBAAqB,mBAAmB,eAAe,eAAe,CAAC,GAC9E,OAAO,qBAAqB,gBAAgB,eAAe,eAAe,CAAC,CAC7E;EACF;EACA;EACA;EACA;CACF;AACF;AAIA,MAAa,mCAWX,SACA,QACA,kBACG,gCAAgC,SAAS,QAAQ,aAAa;AAEnE,MAAa,iCAeX,UACA,SACA,QACA,eACA,UAKA,8BACE,UACA,SACA,QACA,eACA,KACF"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { requireStandalone } from "@yielded/auth-persistence/Adapter";
|
|
2
|
-
import { Context, Effect, Predicate } from "effect";
|
|
3
|
-
//#region src/drizzle/standalone-guard.ts
|
|
4
|
-
const transactionService = (database) => {
|
|
5
|
-
if (!Predicate.hasProperty(database, "$client") || !Predicate.hasProperty(database.$client, "transactionService") || !Context.isKey(database.$client.transactionService)) return;
|
|
6
|
-
return database.$client.transactionService;
|
|
7
|
-
};
|
|
8
|
-
/** Capture the foreign client's marker while acquiring standalone services. */
|
|
9
|
-
const acquireTransactionService = (service) => Effect.map(Effect.service(service), (database) => {
|
|
10
|
-
if (!Predicate.hasProperty(database, "$client") || !Predicate.hasProperty(database.$client, "transactionService") || !Context.isKey(database.$client.transactionService)) return;
|
|
11
|
-
return database.$client.transactionService;
|
|
12
|
-
});
|
|
13
|
-
/** Bind the client-specific transaction marker at foreign adapter construction. */
|
|
14
|
-
const sqlClientStandaloneGuard = (service, unavailable) => {
|
|
15
|
-
if (service === void 0) return Effect.suspend(() => Effect.fail(unavailable()));
|
|
16
|
-
return requireStandalone(unavailable, service);
|
|
17
|
-
};
|
|
18
|
-
//#endregion
|
|
19
|
-
export { acquireTransactionService, sqlClientStandaloneGuard, transactionService };
|
|
20
|
-
|
|
21
|
-
//# sourceMappingURL=standalone-guard.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"standalone-guard.mjs","names":[],"sources":["../../src/drizzle/standalone-guard.ts"],"sourcesContent":["import { requireStandalone } from \"@yielded/auth-persistence/Adapter\";\nimport { Context, Effect, Predicate } from \"effect\";\nimport type * as SqlClient from \"effect/sql/SqlClient\";\n\nexport type TransactionService = Context.Key<\n SqlClient.TransactionConnection,\n SqlClient.TransactionConnection.Service\n>;\n\nexport const transactionService = (database: unknown): TransactionService | undefined => {\n if (\n !Predicate.hasProperty(database, \"$client\") ||\n !Predicate.hasProperty(database.$client, \"transactionService\") ||\n !Context.isKey(database.$client.transactionService)\n ) {\n return undefined;\n }\n\n return database.$client.transactionService;\n};\n\n/** Capture the foreign client's marker while acquiring standalone services. */\nexport const acquireTransactionService = <Id, Database>(service: Context.Key<Id, Database>) =>\n Effect.map(Effect.service(service), (database): TransactionService | undefined => {\n if (\n !Predicate.hasProperty(database, \"$client\") ||\n !Predicate.hasProperty(database.$client, \"transactionService\") ||\n !Context.isKey(database.$client.transactionService)\n ) {\n return undefined;\n }\n\n return database.$client.transactionService;\n });\n\n/** Bind the client-specific transaction marker at foreign adapter construction. */\nexport const sqlClientStandaloneGuard = <Failure>(\n service: TransactionService | undefined,\n unavailable: () => Failure,\n): Effect.Effect<void, Failure> => {\n if (service === undefined) return Effect.suspend(() => Effect.fail(unavailable()));\n\n return requireStandalone(unavailable, service);\n};\n"],"mappings":";;;AASA,MAAa,sBAAsB,aAAsD;CACvF,IACE,CAAC,UAAU,YAAY,UAAU,SAAS,KAC1C,CAAC,UAAU,YAAY,SAAS,SAAS,oBAAoB,KAC7D,CAAC,QAAQ,MAAM,SAAS,QAAQ,kBAAkB,GAElD;CAGF,OAAO,SAAS,QAAQ;AAC1B;;AAGA,MAAa,6BAA2C,YACtD,OAAO,IAAI,OAAO,QAAQ,OAAO,IAAI,aAA6C;CAChF,IACE,CAAC,UAAU,YAAY,UAAU,SAAS,KAC1C,CAAC,UAAU,YAAY,SAAS,SAAS,oBAAoB,KAC7D,CAAC,QAAQ,MAAM,SAAS,QAAQ,kBAAkB,GAElD;CAGF,OAAO,SAAS,QAAQ;AAC1B,CAAC;;AAGH,MAAa,4BACX,SACA,gBACiC;CACjC,IAAI,YAAY,KAAA,GAAW,OAAO,OAAO,cAAc,OAAO,KAAK,YAAY,CAAC,CAAC;CAEjF,OAAO,kBAAkB,aAAa,OAAO;AAC/C"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import "./transaction-owner.mjs";
|
|
2
|
-
import { SQL } from "drizzle-orm";
|
|
3
|
-
import { Context, Effect } from "effect";
|
|
4
|
-
import { TotpRecord, TotpUnavailable } from "@yielded/auth/Totp";
|
|
5
|
-
//#region src/drizzle/totp-state.d.ts
|
|
6
|
-
export declare const encodeTotpRecord: (record: TotpRecord) => string;
|
|
7
|
-
export declare const decodeTotpRecord: (state: string) => {
|
|
8
|
-
readonly moduleId: string;
|
|
9
|
-
readonly subjectId: string & import("effect/Brand").Brand<"effect-auth/SubjectId">;
|
|
10
|
-
readonly credentialId: string;
|
|
11
|
-
readonly revision: string;
|
|
12
|
-
readonly version: string;
|
|
13
|
-
readonly secret: {
|
|
14
|
-
readonly keyId: string;
|
|
15
|
-
readonly nonce: string;
|
|
16
|
-
readonly ciphertext: string;
|
|
17
|
-
readonly revision: string;
|
|
18
|
-
} | null;
|
|
19
|
-
readonly pending: {
|
|
20
|
-
readonly revision: string;
|
|
21
|
-
readonly enrollmentId: string;
|
|
22
|
-
readonly secret: {
|
|
23
|
-
readonly keyId: string;
|
|
24
|
-
readonly nonce: string;
|
|
25
|
-
readonly ciphertext: string;
|
|
26
|
-
readonly revision: string;
|
|
27
|
-
};
|
|
28
|
-
readonly expiresAtMillis: number;
|
|
29
|
-
readonly failedAttempts: number;
|
|
30
|
-
} | null;
|
|
31
|
-
readonly recoveryDigests: readonly (string & import("effect/Brand").Brand<"effect-auth/TokenDigest">)[];
|
|
32
|
-
readonly acceptedStep: number;
|
|
33
|
-
readonly attemptWindow: number;
|
|
34
|
-
readonly failedAttempts: number;
|
|
35
|
-
};
|
|
36
|
-
//#endregion
|
|
37
|
-
//# sourceMappingURL=totp-state.d.mts.map
|
|
@@ -1,287 +0,0 @@
|
|
|
1
|
-
import { digest, randomId } from "./crypto.mjs";
|
|
2
|
-
import { both, makeTransactionRows } from "./transaction-owner.mjs";
|
|
3
|
-
import { sql } from "drizzle-orm";
|
|
4
|
-
import { Context, Effect, Schema } from "effect";
|
|
5
|
-
import { AuthenticationRequirement, SecurityRevision } from "@yielded/auth/Sessions";
|
|
6
|
-
import { TotpPolicy, TotpRecord, TotpUnavailable } from "@yielded/auth/Totp";
|
|
7
|
-
//#region src/drizzle/totp-state.ts
|
|
8
|
-
const unavailable = () => TotpUnavailable.make({});
|
|
9
|
-
const invariant = (condition) => {
|
|
10
|
-
if (!condition) throw unavailable();
|
|
11
|
-
};
|
|
12
|
-
var CurrentTotpTransaction = class extends Context.Service()("effect-auth/drizzle/CurrentTotpTransaction") {};
|
|
13
|
-
const { equal, col, copiedRow } = makeTransactionRows(unavailable);
|
|
14
|
-
const codec = Schema.fromJsonString(TotpRecord);
|
|
15
|
-
const encodeTotpRecord = (record) => Schema.encodeSync(codec)(record);
|
|
16
|
-
const decodeTotpRecord = (state) => Schema.decodeSync(codec)(state);
|
|
17
|
-
const scopeFor = (moduleId, subjectId) => digest(`effect-auth/totp/scope/v1/${moduleId.length}:${moduleId}/${subjectId}`);
|
|
18
|
-
const captureTotp = Effect.fn("TotpNative.capture")(function* (mapping, subjectId) {
|
|
19
|
-
const owner = yield* CurrentTotpTransaction, subject = mapping.subject, factor = mapping.factor, nativeId = mapping.subjectIds.toNative(subjectId);
|
|
20
|
-
invariant(mapping.subjectIds.toSubject(nativeId) === subjectId);
|
|
21
|
-
const subjectRow = (yield* owner.read(subject.table, equal(subject.table, { [subject.id]: nativeId }), { limit: 1 })).rows[0];
|
|
22
|
-
if (subjectRow === void 0 || !(yield* owner.check(sql`exists(select 1 from ${subject.table} where ${both(owner.exact(subject.table, subjectRow), subject.activeCondition)})`))) return void 0;
|
|
23
|
-
const scope = yield* scopeFor(mapping.moduleId, subjectId), found = yield* owner.read(factor.table, equal(factor.table, { [factor.scope]: scope }), { limit: 1 }), row = found.rows[0];
|
|
24
|
-
const record = row === void 0 ? null : decodeTotpRecord(row[factor.state]);
|
|
25
|
-
invariant(record === null || (record.secret === null || record.secret.revision === record.revision) && (record.pending === null || record.pending.secret.revision === record.pending.revision));
|
|
26
|
-
invariant(record === null || record.moduleId === mapping.moduleId && record.subjectId === subjectId && record.version === row[factor.version]);
|
|
27
|
-
return {
|
|
28
|
-
nativeId,
|
|
29
|
-
subjectRow,
|
|
30
|
-
factorRow: row,
|
|
31
|
-
factorObservation: found,
|
|
32
|
-
scope,
|
|
33
|
-
snapshot: {
|
|
34
|
-
revision: {
|
|
35
|
-
subjectId,
|
|
36
|
-
securityRevision: SecurityRevision.make(subjectRow[subject.securityRevision]),
|
|
37
|
-
credentials: record === null || record.secret === null ? [] : [{
|
|
38
|
-
credentialId: record.credentialId,
|
|
39
|
-
revision: SecurityRevision.make(record.revision)
|
|
40
|
-
}]
|
|
41
|
-
},
|
|
42
|
-
record
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
});
|
|
46
|
-
const reject = { _tag: "Rejected" };
|
|
47
|
-
const mutateTotp = Effect.fn("TotpNative.mutate")(function* (mapping, input) {
|
|
48
|
-
const owner = yield* CurrentTotpTransaction;
|
|
49
|
-
invariant(input.moduleId === mapping.moduleId && Schema.encodeSync(Schema.fromJsonString(TotpPolicy))(input.policy) === Schema.encodeSync(Schema.fromJsonString(TotpPolicy))(mapping.policy));
|
|
50
|
-
const captured = yield* captureTotp(mapping, input.subjectId);
|
|
51
|
-
if (captured === void 0) return reject;
|
|
52
|
-
const { snapshot, subjectRow, factorRow, factorObservation, scope, nativeId } = captured, current = snapshot.record, policy = input.policy, action = input.action;
|
|
53
|
-
if (snapshot.revision.securityRevision !== input.snapshot.revision.securityRevision || (current?.version ?? null) !== (input.snapshot.record?.version ?? null)) return reject;
|
|
54
|
-
if (current === null !== (input.snapshot.record === null) || current !== null && encodeTotpRecord(current) !== encodeTotpRecord(input.snapshot.record)) return reject;
|
|
55
|
-
const now = yield* owner.now({ engineNowMillis: mapping.engineNowMillis });
|
|
56
|
-
const guards = [];
|
|
57
|
-
const credentialGuards = [];
|
|
58
|
-
const commandScope = yield* digest(`effect-auth/totp/command/v1/${mapping.moduleId.length}:${mapping.moduleId}/${input.subjectId.length}:${input.subjectId}/${input.commandId}`);
|
|
59
|
-
const commandObservation = [
|
|
60
|
-
"Enroll",
|
|
61
|
-
"Confirm",
|
|
62
|
-
"Disable",
|
|
63
|
-
"Regenerate"
|
|
64
|
-
].includes(action._tag) ? yield* owner.read(mapping.factor.table, equal(mapping.factor.table, { [mapping.factor.scope]: commandScope }), { limit: 1 }) : void 0;
|
|
65
|
-
if (commandObservation !== void 0 && commandObservation.rows.length !== 0) return reject;
|
|
66
|
-
const timeGuards = [];
|
|
67
|
-
const timeBound = (start, end) => {
|
|
68
|
-
timeGuards.push(sql`${mapping.engineNowMillis} >= ${start} and ${mapping.engineNowMillis} < ${end}`);
|
|
69
|
-
};
|
|
70
|
-
if (action._tag === "Enroll" || action._tag === "Confirm" || action._tag === "Disable" || action._tag === "Regenerate") {
|
|
71
|
-
const authorization = input.authorization;
|
|
72
|
-
if (authorization === void 0) return reject;
|
|
73
|
-
const { challenge, evidence } = authorization;
|
|
74
|
-
const expectedAction = {
|
|
75
|
-
Enroll: "enroll",
|
|
76
|
-
Confirm: "confirm",
|
|
77
|
-
Disable: "disable",
|
|
78
|
-
Regenerate: "regenerate"
|
|
79
|
-
}[action._tag];
|
|
80
|
-
if (challenge.action !== expectedAction || challenge.moduleId !== mapping.moduleId || challenge.commandId !== input.commandId || challenge.revision.subjectId !== input.subjectId || challenge.revision.securityRevision !== snapshot.revision.securityRevision || evidence.flowId !== challenge.flowId || evidence.bindingDigest !== challenge.bindingDigest || evidence.revision.subjectId !== input.subjectId || evidence.revision.securityRevision !== snapshot.revision.securityRevision) return reject;
|
|
81
|
-
const auth = mapping.credential;
|
|
82
|
-
for (const revision of [...evidence.revision.credentials].sort((a, b) => a.credentialId.localeCompare(b.credentialId))) {
|
|
83
|
-
const row = (yield* owner.read(auth.table, equal(auth.table, {
|
|
84
|
-
[auth.id]: revision.credentialId,
|
|
85
|
-
[auth.subjectId]: nativeId
|
|
86
|
-
}), { limit: 1 })).rows[0];
|
|
87
|
-
if (row === void 0 || row[auth.revision] !== revision.revision) return reject;
|
|
88
|
-
const condition = sql`exists(select 1 from ${auth.table} where ${both(owner.exact(auth.table, row), auth.activeCondition)})`;
|
|
89
|
-
if (!(yield* owner.check(condition))) return reject;
|
|
90
|
-
credentialGuards.push({
|
|
91
|
-
credentialId: revision.credentialId,
|
|
92
|
-
condition
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
const eligible = evidence.proofs.filter((proof) => evidence.revision.credentials.some((revision) => revision.credentialId === proof.credentialId));
|
|
96
|
-
if (eligible.length !== evidence.proofs.length || eligible.length === 0) return reject;
|
|
97
|
-
const requirements = [authorization.requirement, Schema.decodeSync(AuthenticationRequirement)(mapping.subject.decodeRequirement(copiedRow(subjectRow)))];
|
|
98
|
-
const maximumAge = Math.min(policy.maximumEvidenceAgeMillis, ...requirements.map((requirement) => requirement.maximumAgeMillis));
|
|
99
|
-
const evidenceFactors = new Set(eligible.flatMap((proof) => proof.factors));
|
|
100
|
-
const evidenceCredentials = new Set(eligible.map((proof) => proof.credentialId));
|
|
101
|
-
for (const requirement of requirements) if (!requirement.alternatives.some((alternative) => alternative.factors.every((factor) => evidenceFactors.has(factor)) && evidenceCredentials.size >= alternative.minimumCredentials && eligible.some((proof) => (!alternative.userVerified || proof.userVerified) && (!alternative.phishingResistant || proof.phishingResistant)))) return reject;
|
|
102
|
-
for (const proof of eligible) {
|
|
103
|
-
const verifiedAt = proof.verifiedAt.epochMilliseconds;
|
|
104
|
-
if (verifiedAt > now || now - verifiedAt >= maximumAge) return reject;
|
|
105
|
-
timeBound(verifiedAt, verifiedAt + maximumAge);
|
|
106
|
-
}
|
|
107
|
-
if (current !== null && current.secret !== null || action._tag === "Disable" || action._tag === "Regenerate") {
|
|
108
|
-
const factors = new Set(eligible.flatMap((proof) => proof.factors));
|
|
109
|
-
if (!(eligible.some((proof) => proof.userVerified && proof.phishingResistant && proof.factors.includes("possession")) || factors.has("knowledge") && factors.has("possession") && new Set(eligible.map((proof) => proof.credentialId)).size >= 2)) return reject;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
if (action._tag === "Recovery" && action.reset) {
|
|
113
|
-
const target = action.pending;
|
|
114
|
-
if (target === void 0 || mapping.pendingCondition === void 0 || target.revision.subjectId !== input.subjectId || target.revision.securityRevision !== snapshot.revision.securityRevision || target.expiresAtMillis <= now) return reject;
|
|
115
|
-
const condition = mapping.pendingCondition(target, nativeId);
|
|
116
|
-
if (!(yield* owner.check(condition))) return reject;
|
|
117
|
-
guards.push(condition);
|
|
118
|
-
timeBound(0, target.expiresAtMillis);
|
|
119
|
-
}
|
|
120
|
-
let next, semantic = false, accepted = true;
|
|
121
|
-
if (action._tag === "Enroll") {
|
|
122
|
-
const candidate = action.record;
|
|
123
|
-
if (candidate.subjectId !== input.subjectId || candidate.moduleId !== input.moduleId || candidate.pending === null || candidate.pending.expiresAtMillis <= now || candidate.pending.expiresAtMillis > now + policy.enrollmentLifetimeMillis || candidate.pending.failedAttempts !== 0 || candidate.pending.secret.revision !== candidate.pending.revision) return reject;
|
|
124
|
-
if (current !== null && current.pending !== null && current.pending.expiresAtMillis > now) return reject;
|
|
125
|
-
if (current !== null && (candidate.credentialId !== current.credentialId || encodeTotpRecord({
|
|
126
|
-
...candidate,
|
|
127
|
-
pending: current.pending
|
|
128
|
-
}) !== encodeTotpRecord(current))) return reject;
|
|
129
|
-
if (current === null && (candidate.secret !== null || candidate.recoveryDigests.length !== 0 || candidate.acceptedStep !== -1 || candidate.failedAttempts !== 0)) return reject;
|
|
130
|
-
next = candidate;
|
|
131
|
-
timeBound(0, candidate.pending.expiresAtMillis);
|
|
132
|
-
} else {
|
|
133
|
-
if (current === null) return reject;
|
|
134
|
-
next = { ...current };
|
|
135
|
-
if (action._tag === "Confirm") {
|
|
136
|
-
const pending = current.pending;
|
|
137
|
-
if (pending === null || pending.enrollmentId !== action.enrollmentId || pending.expiresAtMillis <= now || pending.failedAttempts >= policy.attemptLimit) return reject;
|
|
138
|
-
timeBound(0, pending.expiresAtMillis);
|
|
139
|
-
if (action.matchedStep === null || Math.abs(Math.floor(now / 3e4) - action.matchedStep) > policy.clockSkewSteps) {
|
|
140
|
-
next = {
|
|
141
|
-
...current,
|
|
142
|
-
pending: {
|
|
143
|
-
...pending,
|
|
144
|
-
failedAttempts: pending.failedAttempts + 1
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
accepted = false;
|
|
148
|
-
} else {
|
|
149
|
-
if (new Set(action.recoveryDigests).size !== 10) return reject;
|
|
150
|
-
next = {
|
|
151
|
-
...current,
|
|
152
|
-
secret: pending.secret,
|
|
153
|
-
revision: pending.secret.revision,
|
|
154
|
-
pending: null,
|
|
155
|
-
recoveryDigests: action.recoveryDigests,
|
|
156
|
-
acceptedStep: action.matchedStep,
|
|
157
|
-
attemptWindow: now,
|
|
158
|
-
failedAttempts: 0
|
|
159
|
-
};
|
|
160
|
-
semantic = true;
|
|
161
|
-
timeBound(Math.max(0, (action.matchedStep - policy.clockSkewSteps) * 3e4), (action.matchedStep + policy.clockSkewSteps + 1) * 3e4);
|
|
162
|
-
}
|
|
163
|
-
} else if (action._tag === "Verify" || action._tag === "Recovery") {
|
|
164
|
-
if (current.secret === null) return reject;
|
|
165
|
-
const expired = now >= current.attemptWindow + policy.attemptWindowMillis, attempts = expired ? 0 : current.failedAttempts, start = expired ? now : current.attemptWindow;
|
|
166
|
-
if (attempts >= policy.attemptLimit) return reject;
|
|
167
|
-
next = {
|
|
168
|
-
...current,
|
|
169
|
-
attemptWindow: start,
|
|
170
|
-
failedAttempts: attempts + 1
|
|
171
|
-
};
|
|
172
|
-
if (action._tag === "Verify") {
|
|
173
|
-
if (action.matchedStep === null || action.matchedStep <= current.acceptedStep || Math.abs(Math.floor(now / 3e4) - action.matchedStep) > policy.clockSkewSteps) accepted = false;
|
|
174
|
-
else {
|
|
175
|
-
next = {
|
|
176
|
-
...next,
|
|
177
|
-
acceptedStep: action.matchedStep,
|
|
178
|
-
failedAttempts: 0
|
|
179
|
-
};
|
|
180
|
-
timeBound(Math.max(0, (action.matchedStep - policy.clockSkewSteps) * 3e4), (action.matchedStep + policy.clockSkewSteps + 1) * 3e4);
|
|
181
|
-
}
|
|
182
|
-
} else if ((action.reset ? policy.lostFactorRecovery !== "reset-with-recovery-code" : !policy.allowRecoveryCodeForPending) || !current.recoveryDigests.includes(action.digest)) accepted = false;
|
|
183
|
-
else {
|
|
184
|
-
next = {
|
|
185
|
-
...next,
|
|
186
|
-
recoveryDigests: current.recoveryDigests.filter((value) => value !== action.digest),
|
|
187
|
-
failedAttempts: 0
|
|
188
|
-
};
|
|
189
|
-
if (action.reset) {
|
|
190
|
-
next = {
|
|
191
|
-
...next,
|
|
192
|
-
secret: null,
|
|
193
|
-
pending: null,
|
|
194
|
-
recoveryDigests: [],
|
|
195
|
-
revision: yield* randomId
|
|
196
|
-
};
|
|
197
|
-
semantic = true;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
} else {
|
|
201
|
-
if (current.secret === null) return reject;
|
|
202
|
-
semantic = true;
|
|
203
|
-
if (action._tag === "Disable") next = {
|
|
204
|
-
...current,
|
|
205
|
-
secret: null,
|
|
206
|
-
pending: null,
|
|
207
|
-
recoveryDigests: [],
|
|
208
|
-
revision: yield* randomId
|
|
209
|
-
};
|
|
210
|
-
else {
|
|
211
|
-
if (new Set(action.recoveryDigests).size !== 10) return reject;
|
|
212
|
-
next = {
|
|
213
|
-
...current,
|
|
214
|
-
recoveryDigests: action.recoveryDigests
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
next = {
|
|
220
|
-
...next,
|
|
221
|
-
version: yield* randomId
|
|
222
|
-
};
|
|
223
|
-
const subject = mapping.subject, factor = mapping.factor, auth = mapping.credential;
|
|
224
|
-
const subjectKey = { [subject.id]: nativeId };
|
|
225
|
-
if (semantic) {
|
|
226
|
-
const revision = yield* randomId, updates = {
|
|
227
|
-
[subject.securityRevision]: revision,
|
|
228
|
-
[subject.factorEnabled]: subject.encodeEnabled(next.secret !== null)
|
|
229
|
-
};
|
|
230
|
-
yield* owner.update(subject.table, subjectKey, updates);
|
|
231
|
-
const idKey = {
|
|
232
|
-
[auth.id]: next.credentialId,
|
|
233
|
-
[auth.subjectId]: nativeId
|
|
234
|
-
};
|
|
235
|
-
const existing = yield* owner.read(auth.table, equal(auth.table, idKey), { limit: 1 });
|
|
236
|
-
if (existing.rows.length === 0) {
|
|
237
|
-
const values = {
|
|
238
|
-
...auth.encodeInsert({
|
|
239
|
-
credentialId: next.credentialId,
|
|
240
|
-
subjectId: nativeId,
|
|
241
|
-
revision: next.revision,
|
|
242
|
-
active: next.secret !== null
|
|
243
|
-
}),
|
|
244
|
-
[auth.id]: next.credentialId,
|
|
245
|
-
[auth.subjectId]: nativeId,
|
|
246
|
-
[auth.revision]: next.revision,
|
|
247
|
-
[auth.status]: auth.encodeStatus(next.secret !== null)
|
|
248
|
-
};
|
|
249
|
-
existing.rows = (yield* owner.insert(auth.table, values, { [auth.id]: next.credentialId })).rows;
|
|
250
|
-
} else yield* owner.update(auth.table, idKey, {
|
|
251
|
-
[auth.revision]: next.revision,
|
|
252
|
-
[auth.status]: auth.encodeStatus(next.secret !== null)
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
const state = encodeTotpRecord(next), values = {
|
|
256
|
-
[factor.state]: state,
|
|
257
|
-
[factor.version]: next.version
|
|
258
|
-
};
|
|
259
|
-
if (factorRow === void 0) {
|
|
260
|
-
const insert = factor.encodeInsert({
|
|
261
|
-
scope,
|
|
262
|
-
state,
|
|
263
|
-
version: next.version
|
|
264
|
-
});
|
|
265
|
-
invariant(insert[factor.scope] === scope && insert[factor.state] === state && insert[factor.version] === next.version);
|
|
266
|
-
factorObservation.rows = (yield* owner.insert(factor.table, insert, { [factor.scope]: scope })).rows;
|
|
267
|
-
} else yield* owner.update(factor.table, { [factor.scope]: scope }, values);
|
|
268
|
-
if (commandObservation !== void 0) {
|
|
269
|
-
const values = factor.encodeInsert({
|
|
270
|
-
scope: commandScope,
|
|
271
|
-
state: "totp-command/v1",
|
|
272
|
-
version: yield* randomId
|
|
273
|
-
});
|
|
274
|
-
invariant(values[factor.scope] === commandScope && values[factor.state] === "totp-command/v1");
|
|
275
|
-
commandObservation.rows = (yield* owner.insert(factor.table, values, { [factor.scope]: commandScope })).rows;
|
|
276
|
-
}
|
|
277
|
-
guards.push(sql`exists(select 1 from ${subject.table} where ${both(equal(subject.table, subjectKey), subject.activeCondition)})`);
|
|
278
|
-
owner.postconditions.push(...guards, ...timeGuards, ...credentialGuards.filter((guard) => !semantic || guard.credentialId !== next.credentialId).map((guard) => guard.condition));
|
|
279
|
-
return accepted ? {
|
|
280
|
-
_tag: "Accepted",
|
|
281
|
-
record: next
|
|
282
|
-
} : reject;
|
|
283
|
-
});
|
|
284
|
-
//#endregion
|
|
285
|
-
export { CurrentTotpTransaction, captureTotp, copiedRow, decodeTotpRecord, encodeTotpRecord, equal, invariant, mutateTotp, unavailable };
|
|
286
|
-
|
|
287
|
-
//# sourceMappingURL=totp-state.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"totp-state.mjs","names":[],"sources":["../../src/drizzle/totp-state.ts"],"sourcesContent":["import { AuthenticationRequirement, SecurityRevision } from \"@yielded/auth/Sessions\";\nimport {\n TotpUnavailable,\n type TotpMutation,\n TotpPolicy,\n TotpRecord,\n type TotpDecision,\n} from \"@yielded/auth/Totp\";\n/* oxlint-disable no-explicit-any -- private native driver bridge; public makers preserve table and ID types. */\nimport { sql, type SQL } from \"drizzle-orm\";\nimport { Context, Effect, Schema } from \"effect\";\n\nimport { randomId, digest } from \"./crypto\";\nimport { both, makeTransactionRows, type TransactionOwner } from \"./transaction-owner\";\nexport const unavailable = () => TotpUnavailable.make({});\n\nexport const invariant: (condition: unknown) => asserts condition = (condition) => {\n if (!condition) throw unavailable();\n};\n\nexport class CurrentTotpTransaction extends Context.Service<\n CurrentTotpTransaction,\n TransactionOwner<TotpUnavailable>\n>()(\"effect-auth/drizzle/CurrentTotpTransaction\") {}\n\nexport const { equal, col, copiedRow } = makeTransactionRows(unavailable);\nconst codec = Schema.fromJsonString(TotpRecord);\n\nexport const encodeTotpRecord = (record: TotpRecord) => Schema.encodeSync(codec)(record);\nexport const decodeTotpRecord = (state: string) => Schema.decodeSync(codec)(state);\n\nconst scopeFor = (moduleId: string, subjectId: string) =>\n digest(`effect-auth/totp/scope/v1/${moduleId.length}:${moduleId}/${subjectId}`);\n\nexport const captureTotp = Effect.fn(\"TotpNative.capture\")(function* (\n mapping: any,\n subjectId: typeof TotpRecord.Type.subjectId,\n) {\n const owner = yield* CurrentTotpTransaction,\n subject = mapping.subject,\n factor = mapping.factor,\n nativeId = mapping.subjectIds.toNative(subjectId);\n\n invariant(mapping.subjectIds.toSubject(nativeId) === subjectId);\n\n const selected = yield* owner.read(\n subject.table,\n equal(subject.table, { [subject.id]: nativeId }),\n { limit: 1 },\n );\n\n const subjectRow = selected.rows[0];\n\n if (\n subjectRow === undefined ||\n !(yield* owner.check(\n sql`exists(select 1 from ${subject.table} where ${both(owner.exact(subject.table, subjectRow), subject.activeCondition)})`,\n ))\n )\n return undefined;\n\n const scope = yield* scopeFor(mapping.moduleId, subjectId),\n found = yield* owner.read(factor.table, equal(factor.table, { [factor.scope]: scope }), {\n limit: 1,\n }),\n row = found.rows[0];\n\n const record = row === undefined ? null : decodeTotpRecord(row[factor.state] as string);\n\n invariant(\n record === null ||\n ((record.secret === null || record.secret.revision === record.revision) &&\n (record.pending === null || record.pending.secret.revision === record.pending.revision)),\n );\n invariant(\n record === null ||\n (record.moduleId === mapping.moduleId &&\n record.subjectId === subjectId &&\n record.version === row![factor.version]),\n );\n\n return {\n nativeId,\n subjectRow,\n factorRow: row,\n factorObservation: found,\n scope,\n snapshot: {\n revision: {\n subjectId,\n securityRevision: SecurityRevision.make(subjectRow[subject.securityRevision] as string),\n credentials:\n record === null || record.secret === null\n ? []\n : [\n {\n credentialId: record.credentialId,\n revision: SecurityRevision.make(record.revision),\n },\n ],\n },\n record,\n },\n };\n});\n\nconst reject: TotpDecision = { _tag: \"Rejected\" };\n\nexport const mutateTotp = Effect.fn(\"TotpNative.mutate\")(function* (\n mapping: any,\n input: TotpMutation,\n) {\n const owner = yield* CurrentTotpTransaction;\n\n invariant(\n input.moduleId === mapping.moduleId &&\n Schema.encodeSync(Schema.fromJsonString(TotpPolicy))(input.policy) ===\n Schema.encodeSync(Schema.fromJsonString(TotpPolicy))(mapping.policy),\n );\n const captured = yield* captureTotp(mapping, input.subjectId);\n\n if (captured === undefined) return reject;\n\n const { snapshot, subjectRow, factorRow, factorObservation, scope, nativeId } = captured,\n current = snapshot.record,\n policy = input.policy,\n action = input.action;\n\n if (\n snapshot.revision.securityRevision !== input.snapshot.revision.securityRevision ||\n (current?.version ?? null) !== (input.snapshot.record?.version ?? null)\n )\n return reject;\n if (\n (current === null) !== (input.snapshot.record === null) ||\n (current !== null && encodeTotpRecord(current) !== encodeTotpRecord(input.snapshot.record!))\n )\n return reject;\n const now = yield* owner.now({ engineNowMillis: mapping.engineNowMillis });\n const guards: SQL[] = [];\n const credentialGuards: { credentialId: string; condition: SQL }[] = [];\n\n const commandScope = yield* digest(\n `effect-auth/totp/command/v1/${mapping.moduleId.length}:${mapping.moduleId}/${input.subjectId.length}:${input.subjectId}/${input.commandId}`,\n );\n\n const management = [\"Enroll\", \"Confirm\", \"Disable\", \"Regenerate\"].includes(action._tag);\n\n const commandObservation = management\n ? yield* owner.read(\n mapping.factor.table,\n equal(mapping.factor.table, { [mapping.factor.scope]: commandScope }),\n { limit: 1 },\n )\n : undefined;\n\n if (commandObservation !== undefined && commandObservation.rows.length !== 0) return reject;\n const timeGuards: SQL[] = [];\n\n const timeBound = (start: number, end: number) => {\n timeGuards.push(\n sql`${mapping.engineNowMillis} >= ${start} and ${mapping.engineNowMillis} < ${end}`,\n );\n };\n\n if (\n action._tag === \"Enroll\" ||\n action._tag === \"Confirm\" ||\n action._tag === \"Disable\" ||\n action._tag === \"Regenerate\"\n ) {\n const authorization = input.authorization;\n\n if (authorization === undefined) return reject;\n const { challenge, evidence } = authorization;\n\n const expectedAction = {\n Enroll: \"enroll\",\n Confirm: \"confirm\",\n Disable: \"disable\",\n Regenerate: \"regenerate\",\n }[action._tag];\n\n if (\n challenge.action !== expectedAction ||\n challenge.moduleId !== mapping.moduleId ||\n challenge.commandId !== input.commandId ||\n challenge.revision.subjectId !== input.subjectId ||\n challenge.revision.securityRevision !== snapshot.revision.securityRevision ||\n evidence.flowId !== challenge.flowId ||\n evidence.bindingDigest !== challenge.bindingDigest ||\n evidence.revision.subjectId !== input.subjectId ||\n evidence.revision.securityRevision !== snapshot.revision.securityRevision\n )\n return reject;\n const auth = mapping.credential;\n\n for (const revision of [...evidence.revision.credentials].sort((a, b) =>\n a.credentialId.localeCompare(b.credentialId),\n )) {\n const found = yield* owner.read(\n auth.table,\n equal(auth.table, { [auth.id]: revision.credentialId, [auth.subjectId]: nativeId }),\n { limit: 1 },\n );\n\n const row = found.rows[0];\n\n if (row === undefined || row[auth.revision] !== revision.revision) return reject;\n const condition = sql`exists(select 1 from ${auth.table} where ${both(owner.exact(auth.table, row), auth.activeCondition)})`;\n\n if (!(yield* owner.check(condition))) return reject;\n credentialGuards.push({ credentialId: revision.credentialId, condition });\n }\n\n const eligible = evidence.proofs.filter((proof) =>\n evidence.revision.credentials.some(\n (revision) => revision.credentialId === proof.credentialId,\n ),\n );\n\n if (eligible.length !== evidence.proofs.length || eligible.length === 0) return reject;\n\n const requirements = [\n authorization.requirement,\n Schema.decodeSync(AuthenticationRequirement)(\n mapping.subject.decodeRequirement(copiedRow(subjectRow)),\n ),\n ];\n\n const maximumAge = Math.min(\n policy.maximumEvidenceAgeMillis,\n ...requirements.map((requirement) => requirement.maximumAgeMillis),\n );\n\n const evidenceFactors = new Set(eligible.flatMap((proof) => proof.factors));\n const evidenceCredentials = new Set(eligible.map((proof) => proof.credentialId));\n\n for (const requirement of requirements) {\n if (\n !requirement.alternatives.some(\n (alternative) =>\n alternative.factors.every((factor) => evidenceFactors.has(factor)) &&\n evidenceCredentials.size >= alternative.minimumCredentials &&\n eligible.some(\n (proof) =>\n (!alternative.userVerified || proof.userVerified) &&\n (!alternative.phishingResistant || proof.phishingResistant),\n ),\n )\n )\n return reject;\n }\n for (const proof of eligible) {\n const verifiedAt = proof.verifiedAt.epochMilliseconds;\n\n if (verifiedAt > now || now - verifiedAt >= maximumAge) return reject;\n timeBound(verifiedAt, verifiedAt + maximumAge);\n }\n if (\n (current !== null && current.secret !== null) ||\n action._tag === \"Disable\" ||\n action._tag === \"Regenerate\"\n ) {\n const factors = new Set(eligible.flatMap((proof) => proof.factors));\n\n if (\n !(\n eligible.some(\n (proof) =>\n proof.userVerified && proof.phishingResistant && proof.factors.includes(\"possession\"),\n ) ||\n (factors.has(\"knowledge\") &&\n factors.has(\"possession\") &&\n new Set(eligible.map((proof) => proof.credentialId)).size >= 2)\n )\n )\n return reject;\n }\n }\n if (action._tag === \"Recovery\" && action.reset) {\n const target = action.pending;\n\n if (\n target === undefined ||\n mapping.pendingCondition === undefined ||\n target.revision.subjectId !== input.subjectId ||\n target.revision.securityRevision !== snapshot.revision.securityRevision ||\n target.expiresAtMillis <= now\n )\n return reject;\n const condition = mapping.pendingCondition(target, nativeId);\n\n if (!(yield* owner.check(condition))) return reject;\n guards.push(condition);\n timeBound(0, target.expiresAtMillis);\n }\n\n let next: TotpRecord,\n semantic = false,\n accepted = true;\n\n if (action._tag === \"Enroll\") {\n const candidate = action.record;\n\n if (\n candidate.subjectId !== input.subjectId ||\n candidate.moduleId !== input.moduleId ||\n candidate.pending === null ||\n candidate.pending.expiresAtMillis <= now ||\n candidate.pending.expiresAtMillis > now + policy.enrollmentLifetimeMillis ||\n candidate.pending.failedAttempts !== 0 ||\n candidate.pending.secret.revision !== candidate.pending.revision\n )\n return reject;\n // Reissuing cannot erase the confirmation budget during its current enrollment lifetime.\n if (current !== null && current.pending !== null && current.pending.expiresAtMillis > now)\n return reject;\n if (\n current !== null &&\n (candidate.credentialId !== current.credentialId ||\n encodeTotpRecord({ ...candidate, pending: current.pending }) !== encodeTotpRecord(current))\n )\n return reject;\n if (\n current === null &&\n (candidate.secret !== null ||\n candidate.recoveryDigests.length !== 0 ||\n candidate.acceptedStep !== -1 ||\n candidate.failedAttempts !== 0)\n )\n return reject;\n next = candidate;\n timeBound(0, candidate.pending.expiresAtMillis);\n } else {\n if (current === null) return reject;\n next = { ...current };\n if (action._tag === \"Confirm\") {\n const pending = current.pending;\n\n if (\n pending === null ||\n pending.enrollmentId !== action.enrollmentId ||\n pending.expiresAtMillis <= now ||\n pending.failedAttempts >= policy.attemptLimit\n )\n return reject;\n timeBound(0, pending.expiresAtMillis);\n if (\n action.matchedStep === null ||\n Math.abs(Math.floor(now / 30000) - action.matchedStep) > policy.clockSkewSteps\n ) {\n next = { ...current, pending: { ...pending, failedAttempts: pending.failedAttempts + 1 } };\n accepted = false;\n } else {\n if (new Set(action.recoveryDigests).size !== 10) return reject;\n next = {\n ...current,\n secret: pending.secret,\n revision: pending.secret.revision,\n pending: null,\n recoveryDigests: action.recoveryDigests,\n acceptedStep: action.matchedStep,\n attemptWindow: now,\n failedAttempts: 0,\n };\n semantic = true;\n timeBound(\n Math.max(0, (action.matchedStep - policy.clockSkewSteps) * 30000),\n (action.matchedStep + policy.clockSkewSteps + 1) * 30000,\n );\n }\n } else if (action._tag === \"Verify\" || action._tag === \"Recovery\") {\n if (current.secret === null) return reject;\n\n const expired = now >= current.attemptWindow + policy.attemptWindowMillis,\n attempts = expired ? 0 : current.failedAttempts,\n start = expired ? now : current.attemptWindow;\n\n if (attempts >= policy.attemptLimit) return reject;\n next = { ...current, attemptWindow: start, failedAttempts: attempts + 1 };\n if (action._tag === \"Verify\") {\n if (\n action.matchedStep === null ||\n action.matchedStep <= current.acceptedStep ||\n Math.abs(Math.floor(now / 30000) - action.matchedStep) > policy.clockSkewSteps\n )\n accepted = false;\n else {\n next = { ...next, acceptedStep: action.matchedStep, failedAttempts: 0 };\n timeBound(\n Math.max(0, (action.matchedStep - policy.clockSkewSteps) * 30000),\n (action.matchedStep + policy.clockSkewSteps + 1) * 30000,\n );\n }\n } else {\n if (\n (action.reset\n ? policy.lostFactorRecovery !== \"reset-with-recovery-code\"\n : !policy.allowRecoveryCodeForPending) ||\n !current.recoveryDigests.includes(action.digest)\n )\n accepted = false;\n else {\n next = {\n ...next,\n recoveryDigests: current.recoveryDigests.filter((value) => value !== action.digest),\n failedAttempts: 0,\n };\n if (action.reset) {\n next = {\n ...next,\n secret: null,\n pending: null,\n recoveryDigests: [],\n revision: yield* randomId,\n };\n semantic = true;\n }\n }\n }\n } else {\n if (current.secret === null) return reject;\n semantic = true;\n if (action._tag === \"Disable\")\n next = {\n ...current,\n secret: null,\n pending: null,\n recoveryDigests: [],\n revision: yield* randomId,\n };\n else {\n if (new Set(action.recoveryDigests).size !== 10) return reject;\n next = { ...current, recoveryDigests: action.recoveryDigests };\n }\n }\n }\n next = { ...next, version: yield* randomId };\n\n const subject = mapping.subject,\n factor = mapping.factor,\n auth = mapping.credential;\n\n const subjectKey = { [subject.id]: nativeId };\n\n if (semantic) {\n const revision = yield* randomId,\n updates = {\n [subject.securityRevision]: revision,\n [subject.factorEnabled]: subject.encodeEnabled(next.secret !== null),\n };\n\n yield* owner.update(subject.table, subjectKey, updates);\n const idKey = { [auth.id]: next.credentialId, [auth.subjectId]: nativeId };\n const existing = yield* owner.read(auth.table, equal(auth.table, idKey), { limit: 1 });\n\n if (existing.rows.length === 0) {\n const values = {\n ...auth.encodeInsert({\n credentialId: next.credentialId,\n subjectId: nativeId,\n revision: next.revision,\n active: next.secret !== null,\n }),\n [auth.id]: next.credentialId,\n [auth.subjectId]: nativeId,\n [auth.revision]: next.revision,\n [auth.status]: auth.encodeStatus(next.secret !== null),\n };\n\n existing.rows = (yield* owner.insert(auth.table, values, {\n [auth.id]: next.credentialId,\n })).rows;\n } else\n yield* owner.update(auth.table, idKey, {\n [auth.revision]: next.revision,\n [auth.status]: auth.encodeStatus(next.secret !== null),\n });\n // Management proof observations precede its own credential/revision mutation.\n // Retain all unrelated credential authority checks at final commit.\n }\n\n const state = encodeTotpRecord(next),\n values = { [factor.state]: state, [factor.version]: next.version };\n\n if (factorRow === undefined) {\n const insert = factor.encodeInsert({ scope, state, version: next.version });\n\n invariant(\n insert[factor.scope] === scope &&\n insert[factor.state] === state &&\n insert[factor.version] === next.version,\n );\n factorObservation.rows = (yield* owner.insert(factor.table, insert, {\n [factor.scope]: scope,\n })).rows;\n } else yield* owner.update(factor.table, { [factor.scope]: scope }, values);\n if (commandObservation !== undefined) {\n const values = factor.encodeInsert({\n scope: commandScope,\n state: \"totp-command/v1\",\n version: yield* randomId,\n });\n\n invariant(values[factor.scope] === commandScope && values[factor.state] === \"totp-command/v1\");\n commandObservation.rows = (yield* owner.insert(factor.table, values, {\n [factor.scope]: commandScope,\n })).rows;\n }\n // Exact pre-write observations plus final readback are asserted by the common owner.\n // Include active subject and native time at finalization, including on rejection commits.\n guards.push(\n sql`exists(select 1 from ${subject.table} where ${both(equal(subject.table, subjectKey), subject.activeCondition)})`,\n );\n owner.postconditions.push(\n ...guards,\n ...timeGuards,\n ...credentialGuards\n .filter((guard) => !semantic || guard.credentialId !== next.credentialId)\n .map((guard) => guard.condition),\n );\n\n return accepted ? { _tag: \"Accepted\" as const, record: next } : reject;\n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}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { PersistenceMappingError as PersistenceMappingError$1 } from "./model.mjs";
|
|
2
|
-
import "./totp-model.mjs";
|
|
3
|
-
import "./transaction-owner.mjs";
|
|
4
|
-
import "./SuppliedService.mjs";
|
|
5
|
-
import { TransactionCoordinatorError } from "./transaction-execution.mjs";
|
|
6
|
-
import { NativeDatabase } from "@yielded/auth-persistence/Adapter";
|
|
7
|
-
import { Table } from "drizzle-orm";
|
|
8
|
-
import { Context, Crypto, Effect } from "effect";
|
|
9
|
-
import { LifecycleHooks } from "@yielded/auth/Hooks";
|
|
10
|
-
import { Statement } from "effect/sql/Statement";
|
|
11
|
-
import { TotpConfigurationError, TotpPersistence, TotpUnavailable } from "@yielded/auth/Totp";
|
|
12
|
-
//#region src/drizzle/totp-target.d.ts
|
|
13
|
-
export type TotpCoordinatorError<E> = TransactionCoordinatorError<E, TotpUnavailable> | TotpConfigurationError | PersistenceMappingError$1;
|
|
14
|
-
//#endregion
|
|
15
|
-
//# sourceMappingURL=totp-target.d.mts.map
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { makeTransactionOwner, reportTransactionFailure } from "./transaction-owner.mjs";
|
|
2
|
-
import { makeTransactionExecutionKernel } from "@yielded/auth-persistence/Adapter";
|
|
3
|
-
//#region src/drizzle/transaction-execution.ts
|
|
4
|
-
const { sqlClientTransactionStandaloneGuard, makeTransactionExecution, coordinateTransactionOwner } = makeTransactionExecutionKernel({
|
|
5
|
-
makeTransactionOwner,
|
|
6
|
-
reportTransactionFailure
|
|
7
|
-
});
|
|
8
|
-
//#endregion
|
|
9
|
-
export { coordinateTransactionOwner, makeTransactionExecution, sqlClientTransactionStandaloneGuard };
|
|
10
|
-
|
|
11
|
-
//# sourceMappingURL=transaction-execution.mjs.map
|