@yielded/auth-persistence-drizzle 0.1.0-beta.25 → 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 -1266
- package/src/drizzle/d1-passwords.ts +0 -2061
- 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 -1202
- 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,6 +1,7 @@
|
|
|
1
1
|
import type * as Shared from "@yielded/auth-persistence/Adapter";
|
|
2
2
|
import type { SQL, Table } from "drizzle-orm";
|
|
3
3
|
|
|
4
|
+
import type { ClockMapping } from "./native-clock";
|
|
4
5
|
import type { DrizzleTableModel } from "./table-model";
|
|
5
6
|
|
|
6
7
|
export {
|
|
@@ -8,7 +9,6 @@ export {
|
|
|
8
9
|
requiredEmailSignInConstraints,
|
|
9
10
|
type RequiredEmailAddressConstraints,
|
|
10
11
|
requiredEmailAddressConstraints,
|
|
11
|
-
type EmailRegistrationState,
|
|
12
12
|
type EmailRegistrationIntent,
|
|
13
13
|
type RequiredEmailRegistrationConstraints,
|
|
14
14
|
requiredEmailRegistrationConstraints,
|
|
@@ -60,64 +60,37 @@ export type EmailAuthorityCredentialTable<
|
|
|
60
60
|
NativeSubjectId,
|
|
61
61
|
> = Shared.EmailAuthorityCredentialTable<DrizzleTableModel<Credential>, NativeSubjectId>;
|
|
62
62
|
|
|
63
|
-
export type EmailCommandTable<Command extends Table> = Shared.EmailCommandTable<
|
|
64
|
-
DrizzleTableModel<Command>
|
|
65
|
-
>;
|
|
66
|
-
|
|
67
63
|
export type EmailSignInMapping<
|
|
68
64
|
Subject extends Table,
|
|
69
65
|
Identifier extends Table,
|
|
70
66
|
Credential extends Table,
|
|
67
|
+
AuthorityCredential extends Table,
|
|
71
68
|
NativeSubjectId,
|
|
72
69
|
> = Shared.EmailSignInMapping<
|
|
73
70
|
DrizzleTableModel<Subject>,
|
|
74
71
|
DrizzleTableModel<Identifier>,
|
|
75
72
|
DrizzleTableModel<Credential>,
|
|
73
|
+
DrizzleTableModel<AuthorityCredential>,
|
|
76
74
|
NativeSubjectId
|
|
77
75
|
>;
|
|
78
76
|
|
|
79
|
-
export type EmailD1Clock = Shared.EmailD1Clock<SQL>;
|
|
80
|
-
|
|
81
77
|
export type EmailAddressMapping<
|
|
82
78
|
Subject extends Table,
|
|
83
79
|
Identifier extends Table,
|
|
84
80
|
Credential extends Table,
|
|
85
81
|
AuthorityCredential extends Table,
|
|
86
|
-
Command extends Table,
|
|
87
|
-
NativeSubjectId,
|
|
88
|
-
> = Shared.EmailAddressMapping<
|
|
89
|
-
DrizzleTableModel<Subject>,
|
|
90
|
-
DrizzleTableModel<Identifier>,
|
|
91
|
-
DrizzleTableModel<Credential>,
|
|
92
|
-
DrizzleTableModel<AuthorityCredential>,
|
|
93
|
-
DrizzleTableModel<Command>,
|
|
94
82
|
NativeSubjectId,
|
|
95
|
-
|
|
83
|
+
> = ClockMapping<
|
|
84
|
+
Shared.EmailAddressMapping<
|
|
85
|
+
DrizzleTableModel<Subject>,
|
|
86
|
+
DrizzleTableModel<Identifier>,
|
|
87
|
+
DrizzleTableModel<Credential>,
|
|
88
|
+
DrizzleTableModel<AuthorityCredential>,
|
|
89
|
+
NativeSubjectId,
|
|
90
|
+
SQL
|
|
91
|
+
>
|
|
96
92
|
>;
|
|
97
93
|
|
|
98
|
-
export type D1EmailAddressMapping<
|
|
99
|
-
Subject extends Table,
|
|
100
|
-
Identifier extends Table,
|
|
101
|
-
Credential extends Table,
|
|
102
|
-
AuthorityCredential extends Table,
|
|
103
|
-
Command extends Table,
|
|
104
|
-
NativeSubjectId,
|
|
105
|
-
> = Shared.D1EmailAddressMapping<
|
|
106
|
-
DrizzleTableModel<Subject>,
|
|
107
|
-
DrizzleTableModel<Identifier>,
|
|
108
|
-
DrizzleTableModel<Credential>,
|
|
109
|
-
DrizzleTableModel<AuthorityCredential>,
|
|
110
|
-
DrizzleTableModel<Command>,
|
|
111
|
-
NativeSubjectId,
|
|
112
|
-
SQL
|
|
113
|
-
>;
|
|
114
|
-
|
|
115
|
-
export type EmailRegistrationTable<
|
|
116
|
-
Registration,
|
|
117
|
-
Request extends Table,
|
|
118
|
-
NativeSubjectId,
|
|
119
|
-
> = Shared.EmailRegistrationTable<Registration, DrizzleTableModel<Request>, NativeSubjectId>;
|
|
120
|
-
|
|
121
94
|
export type EmailRegistrationProvisioning<
|
|
122
95
|
Registration,
|
|
123
96
|
Subject extends Table,
|
|
@@ -148,29 +121,22 @@ export type EmailRegistrationMapping<
|
|
|
148
121
|
Identifier extends Table,
|
|
149
122
|
Credential extends Table,
|
|
150
123
|
AuthorityCredential extends Table,
|
|
151
|
-
Request extends Table,
|
|
152
124
|
NativeSubjectId,
|
|
153
|
-
> =
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
125
|
+
> = ClockMapping<
|
|
126
|
+
Shared.EmailRegistrationMapping<
|
|
127
|
+
Registration,
|
|
128
|
+
DrizzleTableModel<Subject>,
|
|
129
|
+
DrizzleTableModel<Identifier>,
|
|
130
|
+
DrizzleTableModel<Credential>,
|
|
131
|
+
DrizzleTableModel<AuthorityCredential>,
|
|
132
|
+
NativeSubjectId,
|
|
133
|
+
SQL
|
|
134
|
+
>
|
|
162
135
|
>;
|
|
163
136
|
|
|
164
|
-
export type AnyEmailSignInMapping = EmailSignInMapping<Table, Table, Table, unknown>;
|
|
137
|
+
export type AnyEmailSignInMapping = EmailSignInMapping<Table, Table, Table, Table, unknown>;
|
|
165
138
|
|
|
166
|
-
export type AnyEmailAddressMapping = EmailAddressMapping<
|
|
167
|
-
Table,
|
|
168
|
-
Table,
|
|
169
|
-
Table,
|
|
170
|
-
Table,
|
|
171
|
-
Table,
|
|
172
|
-
unknown
|
|
173
|
-
>;
|
|
139
|
+
export type AnyEmailAddressMapping = EmailAddressMapping<Table, Table, Table, Table, unknown>;
|
|
174
140
|
|
|
175
141
|
export type AnyEmailRegistrationMapping<Registration = unknown> = EmailRegistrationMapping<
|
|
176
142
|
Registration,
|
|
@@ -178,25 +144,5 @@ export type AnyEmailRegistrationMapping<Registration = unknown> = EmailRegistrat
|
|
|
178
144
|
Table,
|
|
179
145
|
Table,
|
|
180
146
|
Table,
|
|
181
|
-
Table,
|
|
182
147
|
unknown
|
|
183
148
|
>;
|
|
184
|
-
|
|
185
|
-
export type D1EmailRegistrationMapping<
|
|
186
|
-
Registration,
|
|
187
|
-
Subject extends Table,
|
|
188
|
-
Identifier extends Table,
|
|
189
|
-
Credential extends Table,
|
|
190
|
-
AuthorityCredential extends Table,
|
|
191
|
-
Request extends Table,
|
|
192
|
-
NativeSubjectId,
|
|
193
|
-
> = Shared.D1EmailRegistrationMapping<
|
|
194
|
-
Registration,
|
|
195
|
-
DrizzleTableModel<Subject>,
|
|
196
|
-
DrizzleTableModel<Identifier>,
|
|
197
|
-
DrizzleTableModel<Credential>,
|
|
198
|
-
DrizzleTableModel<AuthorityCredential>,
|
|
199
|
-
DrizzleTableModel<Request>,
|
|
200
|
-
NativeSubjectId,
|
|
201
|
-
SQL
|
|
202
|
-
>;
|
|
@@ -1,236 +1,125 @@
|
|
|
1
|
-
import type { NativeDatabase } from "@yielded/auth-persistence/Adapter";
|
|
2
|
-
import { EmailAddressPersistence, EmailSignInTargets, EmailUnavailable } from "@yielded/auth/Email";
|
|
3
1
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
makeNativeEmailAddressServices,
|
|
3
|
+
makeNativeEmailSignInServices,
|
|
4
|
+
makeNativeEmailRegistrationServices,
|
|
5
|
+
requireStandalone,
|
|
6
|
+
type AnyEmailAddressMapping as SharedEmailMapping,
|
|
7
|
+
type EmailRegistrationAuthority,
|
|
8
|
+
} from "@yielded/auth-persistence/Adapter";
|
|
9
|
+
import { EmailAddressPersistence, EmailSignInTargets, EmailUnavailable } from "@yielded/auth/Email";
|
|
10
10
|
import { type Context, Effect, Layer } from "effect";
|
|
11
|
-
import type * as SqlError from "effect/sql/SqlError";
|
|
12
11
|
|
|
12
|
+
import type {
|
|
13
|
+
AnyEmailAddressMapping,
|
|
14
|
+
AnyEmailSignInMapping,
|
|
15
|
+
AnyEmailRegistrationMapping,
|
|
16
|
+
} from "./email-model";
|
|
17
|
+
import { nativeClock } from "./native-clock";
|
|
18
|
+
import type { NativeDatabaseHandle } from "./native-database";
|
|
13
19
|
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
type
|
|
17
|
-
} from "./
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
makeSqlEmailAddressPersistence,
|
|
21
|
-
makeSqlEmailSignInTargets,
|
|
22
|
-
type EmailSqlConfiguration,
|
|
23
|
-
type EmailSqlDatabase,
|
|
24
|
-
type EmailSqlQuery,
|
|
25
|
-
} from "./email-sql";
|
|
26
|
-
import type { ProofTargetConfiguration } from "./proof-target";
|
|
27
|
-
import { sqlClientStandaloneGuard, type TransactionService } from "./standalone-guard";
|
|
20
|
+
nativeTarget,
|
|
21
|
+
coordinateNativeTarget,
|
|
22
|
+
type NativeTargetConfiguration,
|
|
23
|
+
} from "./native-target";
|
|
24
|
+
import type { AnyProofPersistenceMapping } from "./proof-model";
|
|
25
|
+
import { nativeProofMapping } from "./proof-target";
|
|
28
26
|
import { validateDrizzleStorage } from "./storage-validation";
|
|
29
27
|
|
|
30
|
-
|
|
31
|
-
readonly mode: "interactive" | "synchronous";
|
|
32
|
-
readonly locking: boolean;
|
|
33
|
-
readonly standaloneGuard: Effect.Effect<void, EmailUnavailable>;
|
|
34
|
-
readonly coordinatorGuard?: Effect.Effect<void, EmailUnavailable>;
|
|
35
|
-
readonly generatedSubjectRows: (query: EmailSqlQuery) => EmailSqlQuery;
|
|
36
|
-
readonly proof: ProofTargetConfiguration;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
interface TransactionOwner<Transaction> {
|
|
40
|
-
readonly transaction: <A, E, R>(
|
|
41
|
-
body: (transaction: Transaction) => Effect.Effect<A, E, R>,
|
|
42
|
-
) => Effect.Effect<A, E | SqlError.SqlError, R>;
|
|
43
|
-
}
|
|
28
|
+
const unavailable = () => EmailUnavailable.make({});
|
|
44
29
|
|
|
45
|
-
export
|
|
46
|
-
|
|
47
|
-
| EmailUnavailable
|
|
48
|
-
| HookConfigurationError
|
|
49
|
-
| SqlError.SqlError;
|
|
30
|
+
export const sqlClientEmailStandaloneGuard = (marker: Parameters<typeof requireStandalone>[1]) =>
|
|
31
|
+
requireStandalone(unavailable, marker);
|
|
50
32
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
sqlClientStandaloneGuard(service, () => EmailUnavailable.make({}));
|
|
55
|
-
|
|
56
|
-
const proofConfiguration = (configuration: EmailTargetConfiguration, coordinated = false) => ({
|
|
57
|
-
mode: configuration.proof.mode,
|
|
58
|
-
locking: configuration.proof.locking,
|
|
59
|
-
|
|
60
|
-
standaloneGuard: Effect.void,
|
|
61
|
-
coordinated,
|
|
62
|
-
insertIfAbsent: configuration.proof.insertIfAbsent,
|
|
33
|
+
const mapped = (value: AnyEmailAddressMapping): SharedEmailMapping => ({
|
|
34
|
+
...value,
|
|
35
|
+
clock: nativeClock(value.clock),
|
|
63
36
|
});
|
|
64
37
|
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
)
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
38
|
+
export const makeTargetEmailAddressServices = Effect.fnUntraced(function* (
|
|
39
|
+
mapping: AnyEmailAddressMapping,
|
|
40
|
+
configuration: NativeTargetConfiguration,
|
|
41
|
+
proofs?: AnyProofPersistenceMapping,
|
|
42
|
+
) {
|
|
43
|
+
yield* validateDrizzleStorage(mapping).pipe(Effect.mapError(unavailable));
|
|
44
|
+
if (proofs !== undefined)
|
|
45
|
+
yield* validateDrizzleStorage(proofs).pipe(Effect.mapError(unavailable));
|
|
46
|
+
if (
|
|
47
|
+
configuration.mode === "batch" &&
|
|
48
|
+
(mapping.d1?.primary !== true || (proofs !== undefined && proofs.d1?.primary !== true))
|
|
49
|
+
)
|
|
50
|
+
return yield* unavailable();
|
|
51
|
+
const target = yield* nativeTarget(configuration);
|
|
52
|
+
|
|
53
|
+
return yield* target.provide(
|
|
54
|
+
makeNativeEmailAddressServices(
|
|
55
|
+
target.tables,
|
|
56
|
+
mapped(mapping),
|
|
57
|
+
proofs === undefined ? undefined : nativeProofMapping(proofs),
|
|
58
|
+
),
|
|
59
|
+
);
|
|
79
60
|
});
|
|
80
61
|
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
)
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
62
|
+
export const makeTargetEmailRegistrationServices = Effect.fnUntraced(function* <Registration>(
|
|
63
|
+
mapping: AnyEmailRegistrationMapping<Registration>,
|
|
64
|
+
configuration: NativeTargetConfiguration,
|
|
65
|
+
proofs: AnyProofPersistenceMapping,
|
|
66
|
+
) {
|
|
67
|
+
yield* validateDrizzleStorage(mapping).pipe(Effect.mapError(unavailable));
|
|
68
|
+
yield* validateDrizzleStorage(proofs).pipe(Effect.mapError(unavailable));
|
|
69
|
+
if (
|
|
70
|
+
configuration.mode === "batch" &&
|
|
71
|
+
(mapping.d1?.primary !== true || proofs.d1?.primary !== true)
|
|
72
|
+
)
|
|
73
|
+
return yield* unavailable();
|
|
74
|
+
const target = yield* nativeTarget(configuration);
|
|
75
|
+
|
|
76
|
+
return yield* target.provide(
|
|
77
|
+
makeNativeEmailRegistrationServices(
|
|
78
|
+
target.tables,
|
|
79
|
+
{
|
|
80
|
+
...mapping,
|
|
81
|
+
clock: nativeClock(mapping.clock),
|
|
82
|
+
},
|
|
83
|
+
nativeProofMapping(proofs),
|
|
84
|
+
target.batch,
|
|
85
|
+
),
|
|
86
|
+
);
|
|
96
87
|
});
|
|
97
88
|
|
|
98
|
-
export const makeTargetEmailSignInServices = (
|
|
99
|
-
mapping: any,
|
|
100
|
-
configuration: EmailTargetConfiguration,
|
|
101
|
-
) =>
|
|
102
|
-
Effect.gen(function* () {
|
|
103
|
-
return {
|
|
104
|
-
emailSignInTargets: yield* makeSqlEmailSignInTargets(mapping, {
|
|
105
|
-
mode: configuration.mode,
|
|
106
|
-
locking: false,
|
|
107
|
-
standaloneGuard: configuration.standaloneGuard,
|
|
108
|
-
}),
|
|
109
|
-
};
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
export const makeTargetEmailAddressServices = (
|
|
113
|
-
mapping: any,
|
|
114
|
-
proofMapping: any,
|
|
115
|
-
configuration: EmailTargetConfiguration,
|
|
116
|
-
) =>
|
|
117
|
-
Effect.gen(function* () {
|
|
118
|
-
return {
|
|
119
|
-
emailAddressPersistence: yield* makeSqlEmailAddressPersistence(
|
|
120
|
-
mapping,
|
|
121
|
-
addressOptions(configuration, proofMapping),
|
|
122
|
-
),
|
|
123
|
-
};
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
export const makeTargetEmailRegistrationServices = <Registration>(
|
|
127
|
-
mapping: any,
|
|
128
|
-
proofMapping: any,
|
|
129
|
-
configuration: EmailTargetConfiguration,
|
|
130
|
-
) =>
|
|
131
|
-
Effect.gen(function* () {
|
|
132
|
-
return {
|
|
133
|
-
registrationAuthority: yield* makeSqlEmailRegistrationAuthority<Registration>(
|
|
134
|
-
mapping,
|
|
135
|
-
registrationOptions(configuration, proofMapping),
|
|
136
|
-
),
|
|
137
|
-
};
|
|
138
|
-
});
|
|
139
|
-
|
|
140
89
|
export const coordinateTargetEmailAddress = <Transaction, A, E, R>(
|
|
141
|
-
database:
|
|
142
|
-
mapping:
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
owner: (
|
|
90
|
+
database: NativeDatabaseHandle,
|
|
91
|
+
mapping: AnyEmailAddressMapping,
|
|
92
|
+
configuration: NativeTargetConfiguration,
|
|
93
|
+
body: (
|
|
146
94
|
transaction: Transaction,
|
|
147
95
|
services: { readonly emailAddressPersistence: EmailAddressPersistence["Service"] },
|
|
148
96
|
) => Effect.Effect<A, E, R>,
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
yield* configuration.coordinatorGuard ?? configuration.standaloneGuard;
|
|
159
|
-
|
|
160
|
-
yield* validateDrizzleStorage({ ...mapping, proof: proofMapping }).pipe(
|
|
161
|
-
Effect.mapError(() => EmailUnavailable.make({})),
|
|
162
|
-
);
|
|
163
|
-
|
|
164
|
-
const result = yield* coordinateCommit(
|
|
165
|
-
() =>
|
|
166
|
-
database.transaction((transaction) =>
|
|
167
|
-
Effect.gen(function* () {
|
|
168
|
-
return yield* owner(transaction, {
|
|
169
|
-
emailAddressPersistence: yield* makeSqlEmailAddressPersistence(
|
|
170
|
-
mapping,
|
|
171
|
-
addressOptions(configuration, proofMapping, true),
|
|
172
|
-
).pipe(
|
|
173
|
-
Effect.provideService(CurrentEmailSql, transaction as unknown as EmailSqlDatabase),
|
|
174
|
-
),
|
|
175
|
-
});
|
|
176
|
-
}),
|
|
177
|
-
),
|
|
178
|
-
{ mode: configuration.mode },
|
|
179
|
-
).pipe(Effect.provideService(LifecycleHooks, hooks));
|
|
180
|
-
|
|
181
|
-
return result.value;
|
|
182
|
-
});
|
|
97
|
+
proofs?: AnyProofPersistenceMapping,
|
|
98
|
+
) =>
|
|
99
|
+
coordinateNativeTarget(
|
|
100
|
+
unavailable,
|
|
101
|
+
database,
|
|
102
|
+
configuration,
|
|
103
|
+
makeTargetEmailAddressServices(mapping, configuration, proofs),
|
|
104
|
+
body,
|
|
105
|
+
);
|
|
183
106
|
|
|
184
107
|
export const coordinateTargetEmailRegistration = <Registration, Transaction, A, E, R>(
|
|
185
|
-
database:
|
|
186
|
-
mapping:
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
108
|
+
database: NativeDatabaseHandle,
|
|
109
|
+
mapping: AnyEmailRegistrationMapping<Registration>,
|
|
110
|
+
configuration: NativeTargetConfiguration,
|
|
111
|
+
proofs: AnyProofPersistenceMapping,
|
|
112
|
+
body: (
|
|
190
113
|
transaction: Transaction,
|
|
191
114
|
services: { readonly registrationAuthority: EmailRegistrationAuthority<Registration> },
|
|
192
115
|
) => Effect.Effect<A, E, R>,
|
|
193
|
-
): Effect.Effect<A, EmailCoordinatorError<E>, R | LifecycleHooks | NativeDatabase> =>
|
|
194
|
-
Effect.gen(function* (): Effect.fn.Return<
|
|
195
|
-
A,
|
|
196
|
-
EmailCoordinatorError<E>,
|
|
197
|
-
R | LifecycleHooks | NativeDatabase
|
|
198
|
-
> {
|
|
199
|
-
const hooks = yield* LifecycleHooks;
|
|
200
|
-
|
|
201
|
-
if (yield* hasCommitScope) return yield* EmailUnavailable.make({});
|
|
202
|
-
yield* configuration.coordinatorGuard ?? configuration.standaloneGuard;
|
|
203
|
-
|
|
204
|
-
yield* validateDrizzleStorage({ ...mapping, proof: proofMapping }).pipe(
|
|
205
|
-
Effect.mapError(() => EmailUnavailable.make({})),
|
|
206
|
-
);
|
|
207
|
-
|
|
208
|
-
const result = yield* coordinateCommit(
|
|
209
|
-
() =>
|
|
210
|
-
database.transaction((transaction) =>
|
|
211
|
-
Effect.gen(function* () {
|
|
212
|
-
return yield* owner(transaction, {
|
|
213
|
-
registrationAuthority: yield* makeSqlEmailRegistrationAuthority<Registration>(
|
|
214
|
-
mapping,
|
|
215
|
-
registrationOptions(configuration, proofMapping, true),
|
|
216
|
-
).pipe(
|
|
217
|
-
Effect.provideService(CurrentEmailSql, transaction as unknown as EmailSqlDatabase),
|
|
218
|
-
),
|
|
219
|
-
});
|
|
220
|
-
}),
|
|
221
|
-
),
|
|
222
|
-
{ mode: configuration.mode },
|
|
223
|
-
).pipe(Effect.provideService(LifecycleHooks, hooks));
|
|
224
|
-
|
|
225
|
-
return result.value;
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
export const emailSignInTargetsLayer = <E, R>(
|
|
229
|
-
services: Effect.Effect<{ readonly emailSignInTargets: EmailSignInTargets["Service"] }, E, R>,
|
|
230
116
|
) =>
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
117
|
+
coordinateNativeTarget(
|
|
118
|
+
unavailable,
|
|
119
|
+
database,
|
|
120
|
+
configuration,
|
|
121
|
+
makeTargetEmailRegistrationServices(mapping, configuration, proofs),
|
|
122
|
+
body,
|
|
234
123
|
);
|
|
235
124
|
|
|
236
125
|
export const emailAddressPersistenceLayer = <E, R>(
|
|
@@ -246,7 +135,7 @@ export const emailAddressPersistenceLayer = <E, R>(
|
|
|
246
135
|
);
|
|
247
136
|
|
|
248
137
|
export const emailRegistrationLayer = <Id, Registration, E, R>(
|
|
249
|
-
|
|
138
|
+
target: Context.Key<Id, EmailRegistrationAuthority<Registration>>,
|
|
250
139
|
services: Effect.Effect<
|
|
251
140
|
{ readonly registrationAuthority: EmailRegistrationAuthority<Registration> },
|
|
252
141
|
E,
|
|
@@ -254,6 +143,24 @@ export const emailRegistrationLayer = <Id, Registration, E, R>(
|
|
|
254
143
|
>,
|
|
255
144
|
) =>
|
|
256
145
|
Layer.effect(
|
|
257
|
-
|
|
146
|
+
target,
|
|
258
147
|
Effect.map(services, (value) => value.registrationAuthority),
|
|
259
148
|
);
|
|
149
|
+
|
|
150
|
+
export const makeTargetEmailSignInServices = Effect.fnUntraced(function* (
|
|
151
|
+
mapping: AnyEmailSignInMapping,
|
|
152
|
+
configuration: NativeTargetConfiguration,
|
|
153
|
+
) {
|
|
154
|
+
yield* validateDrizzleStorage(mapping).pipe(Effect.mapError(unavailable));
|
|
155
|
+
const target = yield* nativeTarget(configuration);
|
|
156
|
+
|
|
157
|
+
return yield* target.provide(makeNativeEmailSignInServices(target.tables, mapping));
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
export const emailSignInTargetsLayer = <E, R>(
|
|
161
|
+
services: Effect.Effect<{ readonly emailSignInTargets: EmailSignInTargets["Service"] }, E, R>,
|
|
162
|
+
) =>
|
|
163
|
+
Layer.effect(
|
|
164
|
+
EmailSignInTargets,
|
|
165
|
+
Effect.map(services, (value) => value.emailSignInTargets),
|
|
166
|
+
);
|
package/src/drizzle/model.ts
CHANGED
|
@@ -8,8 +8,6 @@ import {
|
|
|
8
8
|
import { getTableColumns, type AnyColumn, type InferInsertModel, type Table } from "drizzle-orm";
|
|
9
9
|
import { Context, DateTime, Effect, Layer } from "effect";
|
|
10
10
|
|
|
11
|
-
export type CommitMode = "interactive" | "synchronous" | "batch";
|
|
12
|
-
|
|
13
11
|
export {
|
|
14
12
|
PersistenceMappingError,
|
|
15
13
|
isMappedConstraintConflict,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { withStorageValidation
|
|
1
|
+
import { withStorageValidation } from "@yielded/auth-persistence/Adapter";
|
|
2
2
|
import {
|
|
3
3
|
ExternalIdentityMutation,
|
|
4
4
|
type ExternalIdentity,
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
type SubjectProvisioningTables,
|
|
27
27
|
} from "./model";
|
|
28
28
|
import { Database as DatabaseService } from "./mysql-database";
|
|
29
|
-
import { nativeDatabase } from "./native-database";
|
|
29
|
+
import { NativeDatabase, nativeDatabase } from "./native-database";
|
|
30
30
|
import { validateDrizzleStorage } from "./storage-validation";
|
|
31
31
|
|
|
32
32
|
type RuntimeDatabase = EffectMysql2Database<any>;
|
|
@@ -75,13 +75,6 @@ export const makeMysqlSubjectProvisioningServices = Effect.fnUntraced(function*
|
|
|
75
75
|
|
|
76
76
|
const identifierTable = mapping.identifier.table;
|
|
77
77
|
|
|
78
|
-
const identifierNamespaceColumn = column(
|
|
79
|
-
identifierTable,
|
|
80
|
-
mapping.identifier.namespace,
|
|
81
|
-
) as MySqlColumn;
|
|
82
|
-
|
|
83
|
-
const identifierValueColumn = column(identifierTable, mapping.identifier.value) as MySqlColumn;
|
|
84
|
-
|
|
85
78
|
const findReceipt = Effect.fn("DrizzleMysqlIdentity.findReceipt")(function* (requestId: string) {
|
|
86
79
|
const rows = yield* db
|
|
87
80
|
.select({ fingerprint: requestFingerprintColumn, subjectId: requestSubjectColumn })
|
|
@@ -170,21 +163,8 @@ export const makeMysqlSubjectProvisioningServices = Effect.fnUntraced(function*
|
|
|
170
163
|
Effect.flatMap((receipt) => {
|
|
171
164
|
if (receipt !== undefined && receipt.fingerprint === fingerprint)
|
|
172
165
|
return Effect.succeed(receipt.subjectId as NativeId);
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
return db
|
|
176
|
-
.select({
|
|
177
|
-
subjectId: column(identifierTable, mapping.identifier.subjectId) as MySqlColumn,
|
|
178
|
-
})
|
|
179
|
-
.from(identifierTable as any)
|
|
180
|
-
.where(
|
|
181
|
-
and(
|
|
182
|
-
eq(identifierNamespaceColumn, input.identifier.namespace),
|
|
183
|
-
eq(identifierValueColumn, input.identifier.value),
|
|
184
|
-
),
|
|
185
|
-
)
|
|
186
|
-
.limit(1)
|
|
187
|
-
.pipe(Effect.flatMap(() => IdentityConflict.make()));
|
|
166
|
+
|
|
167
|
+
return IdentityConflict.make();
|
|
188
168
|
}),
|
|
189
169
|
);
|
|
190
170
|
},
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ProofClock, SqlExpression } from "@yielded/auth-persistence/Adapter";
|
|
2
|
+
import { is, SQL, sql } from "drizzle-orm";
|
|
3
|
+
|
|
4
|
+
export type MappedClock = ProofClock<SQL> | ProofClock<SqlExpression>;
|
|
5
|
+
export type ClockMapping<M> = Omit<M, "clock"> & { readonly clock: MappedClock };
|
|
6
|
+
|
|
7
|
+
/** Shared storage mappings already accept native expressions. Only a clock
|
|
8
|
+
* declared with a real Drizzle SQL expression needs the foreign parameter bridge.
|
|
9
|
+
* Never probe callbacks by executing and retrying them with another representation. */
|
|
10
|
+
export const nativeClock = (clock: MappedClock): ProofClock<SqlExpression> => {
|
|
11
|
+
if (!is(clock.engineNowMillis, SQL)) return clock as ProofClock<SqlExpression>;
|
|
12
|
+
// The physical expression identifies the callback family. This erases only
|
|
13
|
+
// foreign compiler variance; persisted times still use the declared codecs.
|
|
14
|
+
const drizzle = clock as ProofClock<SQL>;
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
...drizzle,
|
|
18
|
+
toMillis: (value) => drizzle.toMillis(sql`${sql.param(value)}`),
|
|
19
|
+
fromMillis: (value) => drizzle.fromMillis(sql`${sql.param(value)}`),
|
|
20
|
+
};
|
|
21
|
+
};
|