@tempoxyz/id 0.0.0-pr-187.sha-eed04d3
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 +81 -0
- package/dist/App.d.ts +20 -0
- package/dist/App.d.ts.map +1 -0
- package/dist/App.js +26 -0
- package/dist/App.js.map +1 -0
- package/dist/app/client/.assetsignore +2 -0
- package/dist/app/client/assets/BRLA-CZvVDNYr.png +0 -0
- package/dist/app/client/assets/CHFAU-DCedc4aH.png +0 -0
- package/dist/app/client/assets/DLUSD-BnRXm3EI.png +0 -0
- package/dist/app/client/assets/PRIME-CiFp2-3e.svg +14 -0
- package/dist/app/client/assets/Pilat-Bold-C1t1eIrF.woff2 +0 -0
- package/dist/app/client/assets/Pilat-Book-CbS8ofT8.woff2 +0 -0
- package/dist/app/client/assets/Pilat-Demi-CADSbPAt.woff2 +0 -0
- package/dist/app/client/assets/Pilat-Regular-Bx8vzE7q.woff2 +0 -0
- package/dist/app/client/assets/USD1-COVcO_PB.svg +30 -0
- package/dist/app/client/assets/YLDS-CRh8Zw0g.svg +3 -0
- package/dist/app/client/assets/ccip-Cq1mMiVl.js +1 -0
- package/dist/app/client/assets/frxUSD-n9pTpinR.svg +1 -0
- package/dist/app/client/assets/geist-mono-latin-wght-normal-XN7g48iV.woff2 +0 -0
- package/dist/app/client/assets/index-B7YJVP00.css +1 -0
- package/dist/app/client/assets/index-UXTxXCLk.js +55 -0
- package/dist/app/client/assets/pathUSD-BvaO6ooS.svg +25 -0
- package/dist/app/client/assets/reset-co-CHrff.css +1 -0
- package/dist/app/client/assets/wYLDS-CaCKDrO-.svg +10 -0
- package/dist/app/db/auth.d.ts +3207 -0
- package/dist/app/db/auth.d.ts.map +1 -0
- package/dist/app/db/auth.js +330 -0
- package/dist/app/db/auth.js.map +1 -0
- package/dist/app/db/schema.d.ts +932 -0
- package/dist/app/db/schema.d.ts.map +1 -0
- package/dist/app/db/schema.js +171 -0
- package/dist/app/db/schema.js.map +1 -0
- package/dist/app/server/.vite/manifest.json +489 -0
- package/dist/app/server/assets/BRLA-CZvVDNYr.png +0 -0
- package/dist/app/server/assets/CHFAU-DCedc4aH.png +0 -0
- package/dist/app/server/assets/DLUSD-BnRXm3EI.png +0 -0
- package/dist/app/server/assets/PRIME-CiFp2-3e.svg +14 -0
- package/dist/app/server/assets/Pilat-Bold-C1t1eIrF.woff2 +0 -0
- package/dist/app/server/assets/Pilat-Book-CbS8ofT8.woff2 +0 -0
- package/dist/app/server/assets/Pilat-Demi-CADSbPAt.woff2 +0 -0
- package/dist/app/server/assets/Pilat-Regular-Bx8vzE7q.woff2 +0 -0
- package/dist/app/server/assets/USD1-COVcO_PB.svg +30 -0
- package/dist/app/server/assets/YLDS-CRh8Zw0g.svg +3 -0
- package/dist/app/server/assets/_tanstack-start-manifest_v-DjQNeRZp.js +1 -0
- package/dist/app/server/assets/arktype-aI7TBD0R-D1R3Byo5.js +2 -0
- package/dist/app/server/assets/arktype-aI7TBD0R-D1R3Byo5.js.map +1 -0
- package/dist/app/server/assets/authorize-C95F-9E1-CbESJKGU.js +31 -0
- package/dist/app/server/assets/authorize-C95F-9E1-CbESJKGU.js.map +1 -0
- package/dist/app/server/assets/bun-sqlite-dialect-DoOVo4ja-CtyBkVMb.js +2 -0
- package/dist/app/server/assets/bun-sqlite-dialect-DoOVo4ja-CtyBkVMb.js.map +1 -0
- package/dist/app/server/assets/call-UQamaCKN.js +32 -0
- package/dist/app/server/assets/call-UQamaCKN.js.map +1 -0
- package/dist/app/server/assets/ccip-CbNKFO4n.js +2 -0
- package/dist/app/server/assets/ccip-CbNKFO4n.js.map +1 -0
- package/dist/app/server/assets/compiled-query-Ds2NVcFT.js +2 -0
- package/dist/app/server/assets/compiled-query-Ds2NVcFT.js.map +1 -0
- package/dist/app/server/assets/convert-BIC8n32x.js +2 -0
- package/dist/app/server/assets/convert-BIC8n32x.js.map +1 -0
- package/dist/app/server/assets/cookie-CS900nSP.css +1 -0
- package/dist/app/server/assets/cookie-Cce9CrIP.js +10 -0
- package/dist/app/server/assets/cookie-Cce9CrIP.js.map +1 -0
- package/dist/app/server/assets/core-B1HCXUmx.js +56 -0
- package/dist/app/server/assets/core-B1HCXUmx.js.map +1 -0
- package/dist/app/server/assets/d1-sqlite-dialect-m0f01-4z-Cv-csE1u.js +2 -0
- package/dist/app/server/assets/d1-sqlite-dialect-m0f01-4z-Cv-csE1u.js.map +1 -0
- package/dist/app/server/assets/default-u_dwuiYb-BJJ9PwCi.js +2 -0
- package/dist/app/server/assets/default-u_dwuiYb-BJJ9PwCi.js.map +1 -0
- package/dist/app/server/assets/dist-BxSwugSY.js +1 -0
- package/dist/app/server/assets/dist-CZGFhmQd.js +2 -0
- package/dist/app/server/assets/dist-CZGFhmQd.js.map +1 -0
- package/dist/app/server/assets/dist-Dg3PQqiW.js +15 -0
- package/dist/app/server/assets/dist-Dg3PQqiW.js.map +1 -0
- package/dist/app/server/assets/effect-QlVUlMFu-2tSPDT2b.js +2 -0
- package/dist/app/server/assets/effect-QlVUlMFu-2tSPDT2b.js.map +1 -0
- package/dist/app/server/assets/empty-plugin-adapters-BaGcmrjC.js +2 -0
- package/dist/app/server/assets/empty-plugin-adapters-BaGcmrjC.js.map +1 -0
- package/dist/app/server/assets/factory-ipHlJXZY.js +5 -0
- package/dist/app/server/assets/factory-ipHlJXZY.js.map +1 -0
- package/dist/app/server/assets/frxUSD-n9pTpinR.svg +1 -0
- package/dist/app/server/assets/geist-mono-latin-wght-normal-XN7g48iV.woff2 +0 -0
- package/dist/app/server/assets/get-id-field-B0x109VU.js +6 -0
- package/dist/app/server/assets/get-id-field-B0x109VU.js.map +1 -0
- package/dist/app/server/assets/index-CLddUTqr-xpSuLpBt.js +2 -0
- package/dist/app/server/assets/index-CLddUTqr-xpSuLpBt.js.map +1 -0
- package/dist/app/server/assets/index-DZEfthgZ-8Uq5s5Pt.js +2 -0
- package/dist/app/server/assets/index-DZEfthgZ-8Uq5s5Pt.js.map +1 -0
- package/dist/app/server/assets/kysely-adapter-MkHAI9Jk.js +1 -0
- package/dist/app/server/assets/node-sqlite-dialect-BowWLXvK.js +2 -0
- package/dist/app/server/assets/node-sqlite-dialect-BowWLXvK.js.map +1 -0
- package/dist/app/server/assets/pathUSD-BvaO6ooS.svg +25 -0
- package/dist/app/server/assets/reset-co-CHrff.css +1 -0
- package/dist/app/server/assets/rolldown-runtime-B0Z9INg1.js +1 -0
- package/dist/app/server/assets/router-CcbyBCI4.css +1 -0
- package/dist/app/server/assets/router-xjZtEeaI.js +7 -0
- package/dist/app/server/assets/router-xjZtEeaI.js.map +1 -0
- package/dist/app/server/assets/schema-check-Cf7QOZZD.js +9 -0
- package/dist/app/server/assets/schema-check-Cf7QOZZD.js.map +1 -0
- package/dist/app/server/assets/schemas-C2lCYmR5.js +2 -0
- package/dist/app/server/assets/schemas-C2lCYmR5.js.map +1 -0
- package/dist/app/server/assets/secp256k1-buM5g4AL.js +2 -0
- package/dist/app/server/assets/secp256k1-buM5g4AL.js.map +1 -0
- package/dist/app/server/assets/sqlite-adapter-C_LAV4e3.js +2 -0
- package/dist/app/server/assets/sqlite-adapter-C_LAV4e3.js.map +1 -0
- package/dist/app/server/assets/sqlite-introspector-DSCAP82F-Crx7Ny14.js +6 -0
- package/dist/app/server/assets/sqlite-introspector-DSCAP82F-Crx7Ny14.js.map +1 -0
- package/dist/app/server/assets/standard-json-Cg1N07hM.js +2 -0
- package/dist/app/server/assets/standard-json-Cg1N07hM.js.map +1 -0
- package/dist/app/server/assets/standard-json-DY77efq0.js +2 -0
- package/dist/app/server/assets/standard-json-DY77efq0.js.map +1 -0
- package/dist/app/server/assets/standard-json-ig2t0wRt.js +2 -0
- package/dist/app/server/assets/standard-json-ig2t0wRt.js.map +1 -0
- package/dist/app/server/assets/standard-json-t-LNckA6.js +2 -0
- package/dist/app/server/assets/standard-json-t-LNckA6.js.map +1 -0
- package/dist/app/server/assets/standard-openapi-CONmVRl8.js +2 -0
- package/dist/app/server/assets/standard-openapi-CONmVRl8.js.map +1 -0
- package/dist/app/server/assets/start-C63VetBp.js +2 -0
- package/dist/app/server/assets/start-C63VetBp.js.map +1 -0
- package/dist/app/server/assets/sury-CWZTCd75-xt1mWc9f.js +2 -0
- package/dist/app/server/assets/sury-CWZTCd75-xt1mWc9f.js.map +1 -0
- package/dist/app/server/assets/typebox-Dei93FPO-D_lCVdAz.js +2 -0
- package/dist/app/server/assets/typebox-Dei93FPO-D_lCVdAz.js.map +1 -0
- package/dist/app/server/assets/utils-C4ZXZIZW.js +2 -0
- package/dist/app/server/assets/utils-C4ZXZIZW.js.map +1 -0
- package/dist/app/server/assets/valibot--1zFm7rT-NSoY2xTp.js +2 -0
- package/dist/app/server/assets/valibot--1zFm7rT-NSoY2xTp.js.map +1 -0
- package/dist/app/server/assets/valibot-D_HTw1Gn-CJwWeOUE.js +2 -0
- package/dist/app/server/assets/valibot-D_HTw1Gn-CJwWeOUE.js.map +1 -0
- package/dist/app/server/assets/wYLDS-CaCKDrO-.svg +10 -0
- package/dist/app/server/assets/zod-Bwrt9trS-CV38yPnQ.js +2 -0
- package/dist/app/server/assets/zod-Bwrt9trS-CV38yPnQ.js.map +1 -0
- package/dist/app/server/assets/zod-DSgpEGAE-BvlnBE2L.js +2 -0
- package/dist/app/server/assets/zod-DSgpEGAE-BvlnBE2L.js.map +1 -0
- package/dist/app/server/index.js +574 -0
- package/dist/app/server/index.js.map +1 -0
- package/dist/app/server/wrangler.json +1 -0
- package/dist/cli/Admin.d.ts +38 -0
- package/dist/cli/Admin.d.ts.map +1 -0
- package/dist/cli/Admin.js +62 -0
- package/dist/cli/Admin.js.map +1 -0
- package/dist/cli/Apps.d.ts +9 -0
- package/dist/cli/Apps.d.ts.map +1 -0
- package/dist/cli/Apps.js +36 -0
- package/dist/cli/Apps.js.map +1 -0
- package/dist/cli/Cli.d.ts +14 -0
- package/dist/cli/Cli.d.ts.map +1 -0
- package/dist/cli/Cli.js +27 -0
- package/dist/cli/Cli.js.map +1 -0
- package/dist/cli/Project.d.ts +20 -0
- package/dist/cli/Project.d.ts.map +1 -0
- package/dist/cli/Project.js +88 -0
- package/dist/cli/Project.js.map +1 -0
- package/dist/cli/Realms.d.ts +24 -0
- package/dist/cli/Realms.d.ts.map +1 -0
- package/dist/cli/Realms.js +49 -0
- package/dist/cli/Realms.js.map +1 -0
- package/dist/cli/Session.d.ts +85 -0
- package/dist/cli/Session.d.ts.map +1 -0
- package/dist/cli/Session.js +178 -0
- package/dist/cli/Session.js.map +1 -0
- package/dist/cli/User.d.ts +29 -0
- package/dist/cli/User.d.ts.map +1 -0
- package/dist/cli/User.js +39 -0
- package/dist/cli/User.js.map +1 -0
- package/dist/cli/V1.d.ts +35 -0
- package/dist/cli/V1.d.ts.map +1 -0
- package/dist/cli/V1.js +41 -0
- package/dist/cli/V1.js.map +1 -0
- package/dist/cli/bin.d.ts +3 -0
- package/dist/cli/bin.d.ts.map +1 -0
- package/dist/cli/bin.js +46 -0
- package/dist/cli/bin.js.map +1 -0
- package/dist/cli/commands/admin/apps/create.d.ts +23 -0
- package/dist/cli/commands/admin/apps/create.d.ts.map +1 -0
- package/dist/cli/commands/admin/apps/create.js +89 -0
- package/dist/cli/commands/admin/apps/create.js.map +1 -0
- package/dist/cli/commands/admin/apps/delete.d.ts +14 -0
- package/dist/cli/commands/admin/apps/delete.d.ts.map +1 -0
- package/dist/cli/commands/admin/apps/delete.js +41 -0
- package/dist/cli/commands/admin/apps/delete.js.map +1 -0
- package/dist/cli/commands/admin/apps/index.d.ts +5 -0
- package/dist/cli/commands/admin/apps/index.d.ts.map +1 -0
- package/dist/cli/commands/admin/apps/index.js +14 -0
- package/dist/cli/commands/admin/apps/index.js.map +1 -0
- package/dist/cli/commands/admin/apps/list.d.ts +9 -0
- package/dist/cli/commands/admin/apps/list.d.ts.map +1 -0
- package/dist/cli/commands/admin/apps/list.js +26 -0
- package/dist/cli/commands/admin/apps/list.js.map +1 -0
- package/dist/cli/commands/admin/apps/rotate-secret.d.ts +16 -0
- package/dist/cli/commands/admin/apps/rotate-secret.d.ts.map +1 -0
- package/dist/cli/commands/admin/apps/rotate-secret.js +47 -0
- package/dist/cli/commands/admin/apps/rotate-secret.js.map +1 -0
- package/dist/cli/commands/admin/apps/update.d.ts +20 -0
- package/dist/cli/commands/admin/apps/update.d.ts.map +1 -0
- package/dist/cli/commands/admin/apps/update.js +76 -0
- package/dist/cli/commands/admin/apps/update.js.map +1 -0
- package/dist/cli/commands/admin/index.d.ts +5 -0
- package/dist/cli/commands/admin/index.d.ts.map +1 -0
- package/dist/cli/commands/admin/index.js +13 -0
- package/dist/cli/commands/admin/index.js.map +1 -0
- package/dist/cli/commands/admin/migrate.d.ts +9 -0
- package/dist/cli/commands/admin/migrate.d.ts.map +1 -0
- package/dist/cli/commands/admin/migrate.js +17 -0
- package/dist/cli/commands/admin/migrate.js.map +1 -0
- package/dist/cli/commands/admin/realms/add.d.ts +12 -0
- package/dist/cli/commands/admin/realms/add.d.ts.map +1 -0
- package/dist/cli/commands/admin/realms/add.js +42 -0
- package/dist/cli/commands/admin/realms/add.js.map +1 -0
- package/dist/cli/commands/admin/realms/index.d.ts +5 -0
- package/dist/cli/commands/admin/realms/index.d.ts.map +1 -0
- package/dist/cli/commands/admin/realms/index.js +13 -0
- package/dist/cli/commands/admin/realms/index.js.map +1 -0
- package/dist/cli/commands/admin/realms/list.d.ts +13 -0
- package/dist/cli/commands/admin/realms/list.d.ts.map +1 -0
- package/dist/cli/commands/admin/realms/list.js +36 -0
- package/dist/cli/commands/admin/realms/list.js.map +1 -0
- package/dist/cli/commands/admin/realms/passkeys/index.d.ts +5 -0
- package/dist/cli/commands/admin/realms/passkeys/index.d.ts.map +1 -0
- package/dist/cli/commands/admin/realms/passkeys/index.js +13 -0
- package/dist/cli/commands/admin/realms/passkeys/index.js.map +1 -0
- package/dist/cli/commands/admin/realms/passkeys/set.d.ts +16 -0
- package/dist/cli/commands/admin/realms/passkeys/set.d.ts.map +1 -0
- package/dist/cli/commands/admin/realms/passkeys/set.js +46 -0
- package/dist/cli/commands/admin/realms/passkeys/set.js.map +1 -0
- package/dist/cli/commands/admin/realms/privy/index.d.ts +5 -0
- package/dist/cli/commands/admin/realms/privy/index.d.ts.map +1 -0
- package/dist/cli/commands/admin/realms/privy/index.js +13 -0
- package/dist/cli/commands/admin/realms/privy/index.js.map +1 -0
- package/dist/cli/commands/admin/realms/privy/set.d.ts +18 -0
- package/dist/cli/commands/admin/realms/privy/set.d.ts.map +1 -0
- package/dist/cli/commands/admin/realms/privy/set.js +66 -0
- package/dist/cli/commands/admin/realms/privy/set.js.map +1 -0
- package/dist/cli/commands/admin/realms/remove.d.ts +11 -0
- package/dist/cli/commands/admin/realms/remove.d.ts.map +1 -0
- package/dist/cli/commands/admin/realms/remove.js +35 -0
- package/dist/cli/commands/admin/realms/remove.js.map +1 -0
- package/dist/cli/commands/admin/realms/secp256k1/disable.d.ts +15 -0
- package/dist/cli/commands/admin/realms/secp256k1/disable.d.ts.map +1 -0
- package/dist/cli/commands/admin/realms/secp256k1/disable.js +42 -0
- package/dist/cli/commands/admin/realms/secp256k1/disable.js.map +1 -0
- package/dist/cli/commands/admin/realms/secp256k1/enable.d.ts +15 -0
- package/dist/cli/commands/admin/realms/secp256k1/enable.d.ts.map +1 -0
- package/dist/cli/commands/admin/realms/secp256k1/enable.js +42 -0
- package/dist/cli/commands/admin/realms/secp256k1/enable.js.map +1 -0
- package/dist/cli/commands/admin/realms/secp256k1/index.d.ts +9 -0
- package/dist/cli/commands/admin/realms/secp256k1/index.d.ts.map +1 -0
- package/dist/cli/commands/admin/realms/secp256k1/index.js +17 -0
- package/dist/cli/commands/admin/realms/secp256k1/index.js.map +1 -0
- package/dist/cli/commands/admin/realms/set.d.ts +16 -0
- package/dist/cli/commands/admin/realms/set.d.ts.map +1 -0
- package/dist/cli/commands/admin/realms/set.js +46 -0
- package/dist/cli/commands/admin/realms/set.js.map +1 -0
- package/dist/cli/commands/admin/rotate-key.d.ts +15 -0
- package/dist/cli/commands/admin/rotate-key.d.ts.map +1 -0
- package/dist/cli/commands/admin/rotate-key.js +46 -0
- package/dist/cli/commands/admin/rotate-key.js.map +1 -0
- package/dist/cli/commands/init.d.ts +11 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +34 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/login.d.ts +12 -0
- package/dist/cli/commands/login.d.ts.map +1 -0
- package/dist/cli/commands/login.js +29 -0
- package/dist/cli/commands/login.js.map +1 -0
- package/dist/cli/commands/logout.d.ts +8 -0
- package/dist/cli/commands/logout.d.ts.map +1 -0
- package/dist/cli/commands/logout.js +19 -0
- package/dist/cli/commands/logout.js.map +1 -0
- package/dist/cli/commands/whoami.d.ts +12 -0
- package/dist/cli/commands/whoami.d.ts.map +1 -0
- package/dist/cli/commands/whoami.js +24 -0
- package/dist/cli/commands/whoami.js.map +1 -0
- package/dist/client/Actions.d.ts +101 -0
- package/dist/client/Actions.d.ts.map +1 -0
- package/dist/client/Actions.js +90 -0
- package/dist/client/Actions.js.map +1 -0
- package/dist/client/Auth.d.ts +161 -0
- package/dist/client/Auth.d.ts.map +1 -0
- package/dist/client/Auth.js +113 -0
- package/dist/client/Auth.js.map +1 -0
- package/dist/client/Authorization.d.ts +29 -0
- package/dist/client/Authorization.d.ts.map +1 -0
- package/dist/client/Authorization.js +12 -0
- package/dist/client/Authorization.js.map +1 -0
- package/dist/client/Decorator.d.ts +170 -0
- package/dist/client/Decorator.d.ts.map +1 -0
- package/dist/client/Decorator.js +227 -0
- package/dist/client/Decorator.js.map +1 -0
- package/dist/client/Key.d.ts +85 -0
- package/dist/client/Key.d.ts.map +1 -0
- package/dist/client/Key.js +83 -0
- package/dist/client/Key.js.map +1 -0
- package/dist/client/Pending.d.ts +39 -0
- package/dist/client/Pending.d.ts.map +1 -0
- package/dist/client/Pending.js +12 -0
- package/dist/client/Pending.js.map +1 -0
- package/dist/client/Permissions.d.ts +34 -0
- package/dist/client/Permissions.d.ts.map +1 -0
- package/dist/client/Permissions.js +16 -0
- package/dist/client/Permissions.js.map +1 -0
- package/dist/client/Provider.d.ts +16 -0
- package/dist/client/Provider.d.ts.map +1 -0
- package/dist/client/Provider.js +12 -0
- package/dist/client/Provider.js.map +1 -0
- package/dist/client/Step.d.ts +21 -0
- package/dist/client/Step.d.ts.map +1 -0
- package/dist/client/Step.js +16 -0
- package/dist/client/Step.js.map +1 -0
- package/dist/client/Storage.d.ts +27 -0
- package/dist/client/Storage.d.ts.map +1 -0
- package/dist/client/Storage.js +16 -0
- package/dist/client/Storage.js.map +1 -0
- package/dist/client/TempoAccount.d.ts +40 -0
- package/dist/client/TempoAccount.d.ts.map +1 -0
- package/dist/client/TempoAccount.js +16 -0
- package/dist/client/TempoAccount.js.map +1 -0
- package/dist/client/Tokens.d.ts +25 -0
- package/dist/client/Tokens.d.ts.map +1 -0
- package/dist/client/Tokens.js +12 -0
- package/dist/client/Tokens.js.map +1 -0
- package/dist/client/User.d.ts +21 -0
- package/dist/client/User.d.ts.map +1 -0
- package/dist/client/User.js +12 -0
- package/dist/client/User.js.map +1 -0
- package/dist/client/actions/account.d.ts +25 -0
- package/dist/client/actions/account.d.ts.map +1 -0
- package/dist/client/actions/account.js +34 -0
- package/dist/client/actions/account.js.map +1 -0
- package/dist/client/actions/device.d.ts +53 -0
- package/dist/client/actions/device.d.ts.map +1 -0
- package/dist/client/actions/device.js +79 -0
- package/dist/client/actions/device.js.map +1 -0
- package/dist/client/actions/email.d.ts +84 -0
- package/dist/client/actions/email.d.ts.map +1 -0
- package/dist/client/actions/email.js +63 -0
- package/dist/client/actions/email.js.map +1 -0
- package/dist/client/actions/oauth.d.ts +115 -0
- package/dist/client/actions/oauth.d.ts.map +1 -0
- package/dist/client/actions/oauth.js +105 -0
- package/dist/client/actions/oauth.js.map +1 -0
- package/dist/client/actions/passkey.d.ts +88 -0
- package/dist/client/actions/passkey.d.ts.map +1 -0
- package/dist/client/actions/passkey.js +60 -0
- package/dist/client/actions/passkey.js.map +1 -0
- package/dist/client/actions/provider.d.ts +49 -0
- package/dist/client/actions/provider.d.ts.map +1 -0
- package/dist/client/actions/provider.js +34 -0
- package/dist/client/actions/provider.js.map +1 -0
- package/dist/client/actions/realm.d.ts +24 -0
- package/dist/client/actions/realm.d.ts.map +1 -0
- package/dist/client/actions/realm.js +15 -0
- package/dist/client/actions/realm.js.map +1 -0
- package/dist/client/actions/redirect.d.ts +153 -0
- package/dist/client/actions/redirect.d.ts.map +1 -0
- package/dist/client/actions/redirect.js +236 -0
- package/dist/client/actions/redirect.js.map +1 -0
- package/dist/client/internal/accessKey.d.ts +21 -0
- package/dist/client/internal/accessKey.d.ts.map +1 -0
- package/dist/client/internal/accessKey.js +38 -0
- package/dist/client/internal/accessKey.js.map +1 -0
- package/dist/client/internal/account.d.ts +14 -0
- package/dist/client/internal/account.d.ts.map +1 -0
- package/dist/client/internal/account.js +3 -0
- package/dist/client/internal/account.js.map +1 -0
- package/dist/client/internal/api.d.ts +106 -0
- package/dist/client/internal/api.d.ts.map +1 -0
- package/dist/client/internal/api.js +129 -0
- package/dist/client/internal/api.js.map +1 -0
- package/dist/client/internal/headless.d.ts +33 -0
- package/dist/client/internal/headless.d.ts.map +1 -0
- package/dist/client/internal/headless.js +46 -0
- package/dist/client/internal/headless.js.map +1 -0
- package/dist/client/internal/indexedDb.d.ts +9 -0
- package/dist/client/internal/indexedDb.d.ts.map +1 -0
- package/dist/client/internal/indexedDb.js +32 -0
- package/dist/client/internal/indexedDb.js.map +1 -0
- package/dist/client/internal/request.d.ts +58 -0
- package/dist/client/internal/request.d.ts.map +1 -0
- package/dist/client/internal/request.js +45 -0
- package/dist/client/internal/request.js.map +1 -0
- package/dist/client/internal/store.d.ts +12 -0
- package/dist/client/internal/store.d.ts.map +1 -0
- package/dist/client/internal/store.js +15 -0
- package/dist/client/internal/store.js.map +1 -0
- package/dist/client.d.ts +20 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +20 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/Apps.d.ts +3051 -0
- package/dist/internal/Apps.d.ts.map +1 -0
- package/dist/internal/Apps.js +472 -0
- package/dist/internal/Apps.js.map +1 -0
- package/dist/internal/Auth.d.ts +4058 -0
- package/dist/internal/Auth.d.ts.map +1 -0
- package/dist/internal/Auth.js +137 -0
- package/dist/internal/Auth.js.map +1 -0
- package/dist/internal/Authorize.d.ts +532 -0
- package/dist/internal/Authorize.d.ts.map +1 -0
- package/dist/internal/Authorize.js +326 -0
- package/dist/internal/Authorize.js.map +1 -0
- package/dist/internal/Device.d.ts +371 -0
- package/dist/internal/Device.d.ts.map +1 -0
- package/dist/internal/Device.js +271 -0
- package/dist/internal/Device.js.map +1 -0
- package/dist/internal/Env.d.ts +57 -0
- package/dist/internal/Env.d.ts.map +1 -0
- package/dist/internal/Env.js +2 -0
- package/dist/internal/Env.js.map +1 -0
- package/dist/internal/ErrorResponse.d.ts +609 -0
- package/dist/internal/ErrorResponse.d.ts.map +1 -0
- package/dist/internal/ErrorResponse.js +679 -0
- package/dist/internal/ErrorResponse.js.map +1 -0
- package/dist/internal/Id.d.ts +10 -0
- package/dist/internal/Id.d.ts.map +1 -0
- package/dist/internal/Id.js +34 -0
- package/dist/internal/Id.js.map +1 -0
- package/dist/internal/KeyAuthorization.d.ts +1456 -0
- package/dist/internal/KeyAuthorization.d.ts.map +1 -0
- package/dist/internal/KeyAuthorization.js +1030 -0
- package/dist/internal/KeyAuthorization.js.map +1 -0
- package/dist/internal/Limits.d.ts +65 -0
- package/dist/internal/Limits.d.ts.map +1 -0
- package/dist/internal/Limits.js +35 -0
- package/dist/internal/Limits.js.map +1 -0
- package/dist/internal/Log.d.ts +49 -0
- package/dist/internal/Log.d.ts.map +1 -0
- package/dist/internal/Log.js +101 -0
- package/dist/internal/Log.js.map +1 -0
- package/dist/internal/LogLine.d.ts +33 -0
- package/dist/internal/LogLine.d.ts.map +1 -0
- package/dist/internal/LogLine.js +56 -0
- package/dist/internal/LogLine.js.map +1 -0
- package/dist/internal/Migrations.d.ts +19 -0
- package/dist/internal/Migrations.d.ts.map +1 -0
- package/dist/internal/Migrations.js +57 -0
- package/dist/internal/Migrations.js.map +1 -0
- package/dist/internal/Owner.d.ts +146 -0
- package/dist/internal/Owner.d.ts.map +1 -0
- package/dist/internal/Owner.js +65 -0
- package/dist/internal/Owner.js.map +1 -0
- package/dist/internal/Passkey.d.ts +528 -0
- package/dist/internal/Passkey.d.ts.map +1 -0
- package/dist/internal/Passkey.js +658 -0
- package/dist/internal/Passkey.js.map +1 -0
- package/dist/internal/PendingKey.d.ts +49 -0
- package/dist/internal/PendingKey.d.ts.map +1 -0
- package/dist/internal/PendingKey.js +58 -0
- package/dist/internal/PendingKey.js.map +1 -0
- package/dist/internal/Privy.d.ts +105 -0
- package/dist/internal/Privy.d.ts.map +1 -0
- package/dist/internal/Privy.js +224 -0
- package/dist/internal/Privy.js.map +1 -0
- package/dist/internal/RateLimit.d.ts +190 -0
- package/dist/internal/RateLimit.d.ts.map +1 -0
- package/dist/internal/RateLimit.js +148 -0
- package/dist/internal/RateLimit.js.map +1 -0
- package/dist/internal/Realm.d.ts +281 -0
- package/dist/internal/Realm.d.ts.map +1 -0
- package/dist/internal/Realm.js +477 -0
- package/dist/internal/Realm.js.map +1 -0
- package/dist/internal/RequestId.d.ts +16 -0
- package/dist/internal/RequestId.d.ts.map +1 -0
- package/dist/internal/RequestId.js +78 -0
- package/dist/internal/RequestId.js.map +1 -0
- package/dist/internal/SigningKey.d.ts +115 -0
- package/dist/internal/SigningKey.d.ts.map +1 -0
- package/dist/internal/SigningKey.js +197 -0
- package/dist/internal/SigningKey.js.map +1 -0
- package/dist/internal/TestInbox.d.ts +42 -0
- package/dist/internal/TestInbox.d.ts.map +1 -0
- package/dist/internal/TestInbox.js +20 -0
- package/dist/internal/TestInbox.js.map +1 -0
- package/dist/internal/Timing.d.ts +51 -0
- package/dist/internal/Timing.d.ts.map +1 -0
- package/dist/internal/Timing.js +103 -0
- package/dist/internal/Timing.js.map +1 -0
- package/dist/internal/Validation.d.ts +52 -0
- package/dist/internal/Validation.d.ts.map +1 -0
- package/dist/internal/Validation.js +22 -0
- package/dist/internal/Validation.js.map +1 -0
- package/dist/internal/Wallet.d.ts +37 -0
- package/dist/internal/Wallet.d.ts.map +1 -0
- package/dist/internal/Wallet.js +43 -0
- package/dist/internal/Wallet.js.map +1 -0
- package/dist/worker.d.ts +12 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +12 -0
- package/dist/worker.js.map +1 -0
- package/package.json +82 -0
- package/src/Api.ts +151 -0
- package/src/App.ts +56 -0
- package/src/api/account.ts +311 -0
- package/src/api/authenticate.ts +1290 -0
- package/src/api/authorize.ts +1030 -0
- package/src/api/device.ts +874 -0
- package/src/api/health.ts +72 -0
- package/src/api/lib/AccountStep.ts +335 -0
- package/src/api/lib/Auth.ts +134 -0
- package/src/api/lib/Consent.ts +339 -0
- package/src/api/lib/Cors.ts +107 -0
- package/src/api/lib/Database.ts +10 -0
- package/src/api/lib/DeviceRequest.ts +265 -0
- package/src/api/lib/FirstAccount.ts +90 -0
- package/src/api/lib/KeySigner.ts +393 -0
- package/src/api/lib/PasskeyLink.ts +162 -0
- package/src/api/lib/Session.ts +34 -0
- package/src/api/lib/SignInConsent.ts +316 -0
- package/src/api/oauth.ts +1282 -0
- package/src/api/provider.ts +441 -0
- package/src/app/components/Button.tsx +128 -0
- package/src/app/components/CodeInput.tsx +186 -0
- package/src/app/components/ErrorMessage.tsx +66 -0
- package/src/app/components/Grant.tsx +323 -0
- package/src/app/components/Input.tsx +48 -0
- package/src/app/components/Tooltip.tsx +45 -0
- package/src/app/components/icons/BRLA.png +0 -0
- package/src/app/components/icons/BRZ.svg +1 -0
- package/src/app/components/icons/CHFAU.png +0 -0
- package/src/app/components/icons/DLUSD.png +0 -0
- package/src/app/components/icons/EURAU.svg +1 -0
- package/src/app/components/icons/EURC.e.svg +1 -0
- package/src/app/components/icons/GBPA.svg +4 -0
- package/src/app/components/icons/GUSD.svg +1 -0
- package/src/app/components/icons/MACH.svg +4 -0
- package/src/app/components/icons/OUSD.svg +5 -0
- package/src/app/components/icons/PRIME.svg +14 -0
- package/src/app/components/icons/SBC.svg +1 -0
- package/src/app/components/icons/SEKAU.svg +5 -0
- package/src/app/components/icons/USD1.svg +30 -0
- package/src/app/components/icons/USDB.svg +11 -0
- package/src/app/components/icons/USDC.e.svg +1 -0
- package/src/app/components/icons/USDT0.svg +1 -0
- package/src/app/components/icons/USDY.svg +16 -0
- package/src/app/components/icons/USDe.svg +1 -0
- package/src/app/components/icons/YLDS.svg +3 -0
- package/src/app/components/icons/alphaUSD.svg +1 -0
- package/src/app/components/icons/betaUSD.svg +1 -0
- package/src/app/components/icons/cUSD.svg +1 -0
- package/src/app/components/icons/cbBTC.svg +1 -0
- package/src/app/components/icons/frxUSD.svg +1 -0
- package/src/app/components/icons/goUSD.svg +5 -0
- package/src/app/components/icons/iUSD.svg +1 -0
- package/src/app/components/icons/pathUSD.svg +25 -0
- package/src/app/components/icons/rUSD.svg +1 -0
- package/src/app/components/icons/reUSD.svg +1 -0
- package/src/app/components/icons/sUSDe.svg +1 -0
- package/src/app/components/icons/siUSD.svg +1 -0
- package/src/app/components/icons/stcUSD.svg +1 -0
- package/src/app/components/icons/syrupUSDC.svg +5 -0
- package/src/app/components/icons/thetaUSD.svg +1 -0
- package/src/app/components/icons/wYLDS.svg +10 -0
- package/src/app/components/icons/wsrUSD.svg +1 -0
- package/src/app/components/logos/OUSD.dark.svg +17 -0
- package/src/app/components/logos/OUSD.light.svg +17 -0
- package/src/app/crons/cleanup.ts +42 -0
- package/src/app/db/auth.ts +416 -0
- package/src/app/db/migrations/0000_better_auth.sql +53 -0
- package/src/app/db/migrations/0001_oauth_provider.sql +162 -0
- package/src/app/db/migrations/0002_device_code.sql +17 -0
- package/src/app/db/migrations/0003_realms.sql +27 -0
- package/src/app/db/migrations/0004_default_realm.sql +2 -0
- package/src/app/db/migrations/0005_passkeys.sql +30 -0
- package/src/app/db/migrations/0006_first_accounts.sql +9 -0
- package/src/app/db/migrations/0007_pending_keys.sql +13 -0
- package/src/app/db/migrations/0008_secp256k1_owners.sql +18 -0
- package/src/app/db/migrations/0009_device_requests.sql +8 -0
- package/src/app/db/migrations/0010_device_keys.sql +4 -0
- package/src/app/db/migrations/meta/0000_snapshot.json +362 -0
- package/src/app/db/migrations/meta/0001_snapshot.json +1487 -0
- package/src/app/db/migrations/meta/0002_snapshot.json +1603 -0
- package/src/app/db/migrations/meta/0003_snapshot.json +1760 -0
- package/src/app/db/migrations/meta/0004_snapshot.json +1760 -0
- package/src/app/db/migrations/meta/0005_snapshot.json +1911 -0
- package/src/app/db/migrations/meta/0006_snapshot.json +1967 -0
- package/src/app/db/migrations/meta/0007_snapshot.json +2047 -0
- package/src/app/db/migrations/meta/0008_snapshot.json +2157 -0
- package/src/app/db/migrations/meta/0009_snapshot.json +2207 -0
- package/src/app/db/migrations/meta/0010_snapshot.json +2231 -0
- package/src/app/db/migrations/meta/_journal.json +83 -0
- package/src/app/db/schema.ts +218 -0
- package/src/app/env.ts +49 -0
- package/src/app/lib/Client.ts +82 -0
- package/src/app/lib/Loader.ts +24 -0
- package/src/app/package.json +8 -0
- package/src/app/routeTree.gen.ts +198 -0
- package/src/app/router.tsx +48 -0
- package/src/app/routes/[_].flows.tsx +3001 -0
- package/src/app/routes/__root.tsx +91 -0
- package/src/app/routes/authorize.tsx +197 -0
- package/src/app/routes/choose-account.tsx +111 -0
- package/src/app/routes/deposit.tsx +105 -0
- package/src/app/routes/device.tsx +227 -0
- package/src/app/routes/index.tsx +115 -0
- package/src/app/routes/login.tsx +506 -0
- package/src/app/screens/Account.tsx +347 -0
- package/src/app/screens/Approval.tsx +276 -0
- package/src/app/screens/ChooseAccount.tsx +240 -0
- package/src/app/screens/Deposit.tsx +762 -0
- package/src/app/screens/DeviceApproval.tsx +480 -0
- package/src/app/screens/SignIn.tsx +362 -0
- package/src/app/screens/chains/base.svg +3 -0
- package/src/app/screens/chains/ethereum.svg +11 -0
- package/src/app/screens/chains/solana.svg +4 -0
- package/src/app/screens/chains/tempo.svg +4 -0
- package/src/app/server.ts +204 -0
- package/src/app/vite.config.ts +95 -0
- package/src/app/void.config.ts +29 -0
- package/src/app/zyzz.config.ts +274 -0
- package/src/cli/Admin.ts +73 -0
- package/src/cli/Apps.ts +29 -0
- package/src/cli/Cli.ts +42 -0
- package/src/cli/Project.ts +117 -0
- package/src/cli/Realms.ts +50 -0
- package/src/cli/Session.ts +239 -0
- package/src/cli/User.ts +45 -0
- package/src/cli/V1.ts +57 -0
- package/src/cli/bin.ts +44 -0
- package/src/cli/commands/admin/apps/create.ts +101 -0
- package/src/cli/commands/admin/apps/delete.ts +38 -0
- package/src/cli/commands/admin/apps/index.ts +15 -0
- package/src/cli/commands/admin/apps/list.ts +25 -0
- package/src/cli/commands/admin/apps/rotate-secret.ts +47 -0
- package/src/cli/commands/admin/apps/update.ts +86 -0
- package/src/cli/commands/admin/index.ts +14 -0
- package/src/cli/commands/admin/migrate.ts +16 -0
- package/src/cli/commands/admin/realms/add.ts +40 -0
- package/src/cli/commands/admin/realms/index.ts +14 -0
- package/src/cli/commands/admin/realms/list.ts +38 -0
- package/src/cli/commands/admin/realms/passkeys/index.ts +15 -0
- package/src/cli/commands/admin/realms/passkeys/set.ts +44 -0
- package/src/cli/commands/admin/realms/privy/index.ts +14 -0
- package/src/cli/commands/admin/realms/privy/set.ts +69 -0
- package/src/cli/commands/admin/realms/remove.ts +33 -0
- package/src/cli/commands/admin/realms/secp256k1/disable.ts +40 -0
- package/src/cli/commands/admin/realms/secp256k1/enable.ts +40 -0
- package/src/cli/commands/admin/realms/secp256k1/index.ts +19 -0
- package/src/cli/commands/admin/realms/set.ts +46 -0
- package/src/cli/commands/admin/rotate-key.ts +47 -0
- package/src/cli/commands/init.ts +42 -0
- package/src/cli/commands/login.ts +32 -0
- package/src/cli/commands/logout.ts +19 -0
- package/src/cli/commands/whoami.ts +23 -0
- package/src/client/Actions.ts +168 -0
- package/src/client/Auth.ts +285 -0
- package/src/client/Authorization.ts +34 -0
- package/src/client/Decorator.ts +410 -0
- package/src/client/Key.ts +140 -0
- package/src/client/Pending.ts +46 -0
- package/src/client/Permissions.ts +39 -0
- package/src/client/Provider.ts +18 -0
- package/src/client/Step.ts +24 -0
- package/src/client/Storage.ts +29 -0
- package/src/client/TempoAccount.ts +42 -0
- package/src/client/Tokens.ts +27 -0
- package/src/client/User.ts +23 -0
- package/src/client/actions/account.ts +57 -0
- package/src/client/actions/device.ts +151 -0
- package/src/client/actions/email.ts +141 -0
- package/src/client/actions/oauth.ts +182 -0
- package/src/client/actions/passkey.ts +141 -0
- package/src/client/actions/provider.ts +70 -0
- package/src/client/actions/realm.ts +36 -0
- package/src/client/actions/redirect.ts +408 -0
- package/src/client/internal/accessKey.ts +54 -0
- package/src/client/internal/account.ts +15 -0
- package/src/client/internal/api.ts +224 -0
- package/src/client/internal/headless.ts +77 -0
- package/src/client/internal/indexedDb.ts +44 -0
- package/src/client/internal/request.ts +71 -0
- package/src/client/internal/store.ts +20 -0
- package/src/client.ts +19 -0
- package/src/index.ts +6 -0
- package/src/internal/Apps.ts +718 -0
- package/src/internal/Auth.ts +203 -0
- package/src/internal/Authorize.ts +424 -0
- package/src/internal/Balance.ts +168 -0
- package/src/internal/BodyLimit.ts +36 -0
- package/src/internal/Chain.ts +16 -0
- package/src/internal/Device.ts +469 -0
- package/src/internal/Env.ts +58 -0
- package/src/internal/ErrorResponse.ts +854 -0
- package/src/internal/Id.ts +41 -0
- package/src/internal/KeyAuthorization.ts +1339 -0
- package/src/internal/Limits.ts +39 -0
- package/src/internal/Log.ts +178 -0
- package/src/internal/LogLine.ts +87 -0
- package/src/internal/Logout.ts +336 -0
- package/src/internal/Migrations.ts +86 -0
- package/src/internal/OpenApi.ts +300 -0
- package/src/internal/Owner.ts +211 -0
- package/src/internal/Passkey.ts +1052 -0
- package/src/internal/PendingKey.ts +104 -0
- package/src/internal/Privy.ts +402 -0
- package/src/internal/Provider.ts +125 -0
- package/src/internal/RateLimit.ts +259 -0
- package/src/internal/Realm.ts +768 -0
- package/src/internal/RequestId.ts +118 -0
- package/src/internal/SignInGrant.ts +168 -0
- package/src/internal/SigningKey.ts +286 -0
- package/src/internal/TempoAccount.ts +342 -0
- package/src/internal/TestInbox.ts +51 -0
- package/src/internal/Timing.ts +158 -0
- package/src/internal/Validation.ts +52 -0
- package/src/internal/Wallet.ts +62 -0
- package/src/internal/owners/Passkey.ts +72 -0
- package/src/internal/owners/Privy.ts +81 -0
- package/src/internal/owners/Secp256k1.ts +143 -0
- package/src/types/app.d.ts +19 -0
- package/src/worker.ts +11 -0
|
@@ -0,0 +1,658 @@
|
|
|
1
|
+
import { createAuthEndpoint } from 'better-auth/api';
|
|
2
|
+
import { setSessionCookie } from 'better-auth/cookies';
|
|
3
|
+
import { symmetricDecrypt, symmetricEncrypt } from 'better-auth/crypto';
|
|
4
|
+
import { and, eq, gt, sql } from 'drizzle-orm';
|
|
5
|
+
import { Base64, Hash, Hex } from 'ox';
|
|
6
|
+
import { Authentication } from 'webauthx/server';
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
import * as Schema from '../app/db/schema.js';
|
|
9
|
+
import * as Authorize from './Authorize.js';
|
|
10
|
+
import * as ErrorResponse from './ErrorResponse.js';
|
|
11
|
+
import * as KeyAuthorization from './KeyAuthorization.js';
|
|
12
|
+
import * as Owner from './Owner.js';
|
|
13
|
+
/**
|
|
14
|
+
* The email step's link to a wallet.tempo passkey expired, or the browser holds no link cookie for it.
|
|
15
|
+
* The refusal comes before the code is checked, so the code stays valid for a sign-in without the
|
|
16
|
+
* passkey.
|
|
17
|
+
*/
|
|
18
|
+
export class LinkExpiredError extends ErrorResponse.define('passkey_link_expired') {
|
|
19
|
+
name = 'Passkey.LinkExpiredError';
|
|
20
|
+
constructor() {
|
|
21
|
+
super({
|
|
22
|
+
error_description: 'Expired passkey sign-in: the link from the passkey step is no longer valid. Enter the code again to sign in with email only, or sign in with the passkey again.',
|
|
23
|
+
field: 'link',
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* A passkey sign-in names an app, or reaches a realm, that holds no passkeys for Tempo ID, or no
|
|
29
|
+
* passkeys whose relying party covers the app's page.
|
|
30
|
+
*/
|
|
31
|
+
export class NotPermittedError extends ErrorResponse.define('passkey_not_permitted') {
|
|
32
|
+
name = 'Passkey.NotPermittedError';
|
|
33
|
+
constructor(options = {}) {
|
|
34
|
+
const { clientId, origin } = options;
|
|
35
|
+
super((() => {
|
|
36
|
+
if (clientId && origin)
|
|
37
|
+
return {
|
|
38
|
+
error_description: `Passkey not permitted: no realm of the app ${clientId} holds passkeys for ${origin}. Sign in with an emailed code.`,
|
|
39
|
+
meta: { client_id: clientId, origin },
|
|
40
|
+
};
|
|
41
|
+
if (clientId)
|
|
42
|
+
return {
|
|
43
|
+
error_description: `Passkey not permitted: the app ${clientId} holds no passkeys. Sign in with an emailed code.`,
|
|
44
|
+
meta: { client_id: clientId },
|
|
45
|
+
};
|
|
46
|
+
return {
|
|
47
|
+
error_description: 'Passkey not permitted: no realm holds passkeys for this sign-in. Sign in with an emailed code.',
|
|
48
|
+
};
|
|
49
|
+
})());
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* A passkey ceremony failed: its challenge is unknown, spent, or expired, or the response does not
|
|
54
|
+
* verify. One refusal covers every case, so it reveals neither which check failed nor whether a
|
|
55
|
+
* credential exists.
|
|
56
|
+
*/
|
|
57
|
+
export class WebAuthnRejectedError extends ErrorResponse.define('webauthn_rejected') {
|
|
58
|
+
name = 'Passkey.WebAuthnRejectedError';
|
|
59
|
+
constructor() {
|
|
60
|
+
super({
|
|
61
|
+
error_description: 'Passkey rejected. Request new options, then try again with the same passkey or another one.',
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/** Seconds a challenge lasts. */
|
|
66
|
+
export const lifetime = 5 * 60;
|
|
67
|
+
/** Seconds a deferred link lasts. */
|
|
68
|
+
export const linkLifetime = 5 * 60;
|
|
69
|
+
/** The prefix of a challenge's `verification` identifier, which its hex value follows. */
|
|
70
|
+
const prefix = 'passkey-challenge:';
|
|
71
|
+
/**
|
|
72
|
+
* The prefix of a signature challenge's `verification` identifier, which {@link signatureIdentifier}
|
|
73
|
+
* completes. It differs from {@link prefix}, so a sign-in never spends a signature challenge.
|
|
74
|
+
*/
|
|
75
|
+
const signaturePrefix = 'passkey-signature:';
|
|
76
|
+
/**
|
|
77
|
+
* The longest a spent signature's record lasts, in seconds: a year, the longest a headless key
|
|
78
|
+
* lasts. A redirect's key can name a much later expiry, so the record does not follow it, and each
|
|
79
|
+
* user's approvals add rows that the cleanup cron removes within the year.
|
|
80
|
+
*/
|
|
81
|
+
const spentLifetime = KeyAuthorization.lifetime;
|
|
82
|
+
/**
|
|
83
|
+
* The prefix of a spent signature's `verification` identifier, which the SHA-256 digest of the
|
|
84
|
+
* assertion's authenticator data and signature follows.
|
|
85
|
+
*/
|
|
86
|
+
const spentPrefix = 'passkey-signature-spent:';
|
|
87
|
+
/** Zod schemas for passkey ceremonies. */
|
|
88
|
+
export var schema;
|
|
89
|
+
(function (schema) {
|
|
90
|
+
const base64url = z.string().regex(/^[A-Za-z0-9_-]+$/);
|
|
91
|
+
const hex = z.templateLiteral(['0x', z.string().regex(/^[0-9a-fA-F]*$/)]);
|
|
92
|
+
/**
|
|
93
|
+
* A credential ID in canonical unpadded base64url, of at most 1,023 bytes, as WebAuthn bounds it:
|
|
94
|
+
* 1,364 characters.
|
|
95
|
+
*/
|
|
96
|
+
schema.credentialId = base64url.min(1).max(1364);
|
|
97
|
+
/** A passkey assertion, as `webauthx/client`'s `Authentication.sign` serializes it. */
|
|
98
|
+
schema.assertion = z
|
|
99
|
+
.object({
|
|
100
|
+
id: schema.credentialId.meta({
|
|
101
|
+
description: 'The credential ID of the passkey that signed, base64url.',
|
|
102
|
+
examples: ['KEbWNCc7NgaYnUyrNeFGX9_3Y-8'],
|
|
103
|
+
}),
|
|
104
|
+
metadata: z
|
|
105
|
+
.object({
|
|
106
|
+
authenticatorData: hex.meta({
|
|
107
|
+
description: 'The authenticator data the passkey signed, as hex: the relying party ID hash, flags, and signature counter.',
|
|
108
|
+
examples: [
|
|
109
|
+
'0x49960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97630500000000',
|
|
110
|
+
],
|
|
111
|
+
}),
|
|
112
|
+
challengeIndex: z
|
|
113
|
+
.number()
|
|
114
|
+
.int()
|
|
115
|
+
.nonnegative()
|
|
116
|
+
.optional()
|
|
117
|
+
.meta({
|
|
118
|
+
description: 'The character offset of `"challenge"` in `clientDataJSON`. Absent, verification searches for it.',
|
|
119
|
+
examples: [23],
|
|
120
|
+
}),
|
|
121
|
+
clientDataJSON: z
|
|
122
|
+
.string()
|
|
123
|
+
.max(4096)
|
|
124
|
+
.meta({
|
|
125
|
+
description: 'The client data the browser collected, as a JSON string, which holds the type, challenge, and origin.',
|
|
126
|
+
examples: [
|
|
127
|
+
'{"type":"webauthn.get","challenge":"9jEFijuhEWrM4SOW-tChJbUEHEP44VcjcJ-Bqo1fTM8","origin":"https://id.tempo.xyz","crossOrigin":false}',
|
|
128
|
+
],
|
|
129
|
+
}),
|
|
130
|
+
typeIndex: z
|
|
131
|
+
.number()
|
|
132
|
+
.int()
|
|
133
|
+
.nonnegative()
|
|
134
|
+
.optional()
|
|
135
|
+
.meta({
|
|
136
|
+
description: 'The character offset of `"type"` in `clientDataJSON`. Absent, verification searches for it.',
|
|
137
|
+
examples: [1],
|
|
138
|
+
}),
|
|
139
|
+
userVerificationRequired: z
|
|
140
|
+
.boolean()
|
|
141
|
+
.optional()
|
|
142
|
+
.meta({
|
|
143
|
+
description: 'Whether the client required user verification. Verification ignores it and always requires user verification.',
|
|
144
|
+
examples: [true],
|
|
145
|
+
}),
|
|
146
|
+
})
|
|
147
|
+
.meta({
|
|
148
|
+
description: 'The signed data that verification reads with `signature`, decoded from the browser response.',
|
|
149
|
+
}),
|
|
150
|
+
raw: z
|
|
151
|
+
.object({
|
|
152
|
+
authenticatorAttachment: z
|
|
153
|
+
.string()
|
|
154
|
+
.nullable()
|
|
155
|
+
.default(null)
|
|
156
|
+
.meta({
|
|
157
|
+
description: 'How the authenticator attaches to the client, such as `platform` or `cross-platform`. Defaults to `null` when the browser reports none.',
|
|
158
|
+
examples: ['platform'],
|
|
159
|
+
}),
|
|
160
|
+
id: base64url.meta({
|
|
161
|
+
description: 'The credential ID, base64url, as the browser returns it.',
|
|
162
|
+
examples: ['KEbWNCc7NgaYnUyrNeFGX9_3Y-8'],
|
|
163
|
+
}),
|
|
164
|
+
rawId: base64url.meta({
|
|
165
|
+
description: 'The bytes of the credential ID, base64url.',
|
|
166
|
+
examples: ['KEbWNCc7NgaYnUyrNeFGX9_3Y-8'],
|
|
167
|
+
}),
|
|
168
|
+
// Verification reads the top-level `metadata` and `signature`, so other fields are dropped.
|
|
169
|
+
response: z
|
|
170
|
+
.object({
|
|
171
|
+
clientDataJSON: base64url.meta({
|
|
172
|
+
description: 'The client data JSON, base64url.',
|
|
173
|
+
examples: [
|
|
174
|
+
'eyJ0eXBlIjoid2ViYXV0aG4uZ2V0IiwiY2hhbGxlbmdlIjoiOWpFRmlqdWhFV3JNNFNPVy10Q2hKYlVFSEVQNDRWY2pjSi1CcW8xZlRNOCIsIm9yaWdpbiI6Imh0dHBzOi8vaWQudGVtcG8ueHl6IiwiY3Jvc3NPcmlnaW4iOmZhbHNlfQ',
|
|
175
|
+
],
|
|
176
|
+
}),
|
|
177
|
+
})
|
|
178
|
+
.meta({
|
|
179
|
+
description: "The authenticator's response. Verification keeps only `clientDataJSON` and drops other fields.",
|
|
180
|
+
}),
|
|
181
|
+
type: z.string().meta({
|
|
182
|
+
description: 'The credential type.',
|
|
183
|
+
examples: ['public-key'],
|
|
184
|
+
}),
|
|
185
|
+
})
|
|
186
|
+
.meta({
|
|
187
|
+
description: 'The `PublicKeyCredential` that `navigator.credentials.get()` returns, serialized as JSON.',
|
|
188
|
+
}),
|
|
189
|
+
signature: hex.meta({
|
|
190
|
+
description: 'The P-256 signature over the authenticator data and the client data hash, as 64-byte hex: `r` then `s`.',
|
|
191
|
+
examples: [
|
|
192
|
+
'0x6c3f1e0a9b7d24f58e1c3a6b9d0f2e4a7c5b8d1e3f6a9c2b4d7e0f1a3c5b8d9e1f2a7c4b6d8e0f3a5c7b9d1e4f6a8c0b2d5e7f9a1c3b6d8e0f2a4c7b9d1e3f5a',
|
|
193
|
+
],
|
|
194
|
+
}),
|
|
195
|
+
})
|
|
196
|
+
.meta({
|
|
197
|
+
description: 'The assertion, serialized as `webauthx/client` returns it.',
|
|
198
|
+
id: 'PasskeyAssertion',
|
|
199
|
+
});
|
|
200
|
+
/** The client data fields that `take` and `verify` read. */
|
|
201
|
+
schema.clientData = z.object({
|
|
202
|
+
challenge: base64url,
|
|
203
|
+
crossOrigin: z.boolean().optional(),
|
|
204
|
+
});
|
|
205
|
+
/** A deferred link, as `seal` encrypts it. */
|
|
206
|
+
schema.link = z.object({
|
|
207
|
+
address: z.string(),
|
|
208
|
+
createdAt: z.number().nullable(),
|
|
209
|
+
/** When the link expires, in seconds. */
|
|
210
|
+
expiresAt: z.number(),
|
|
211
|
+
/** The host that sealed it. Another host that shares the secret does not accept it. */
|
|
212
|
+
host: z.string(),
|
|
213
|
+
id: z.string(),
|
|
214
|
+
/** The value that the email step carries, which the emailed-code sign-in sends back. */
|
|
215
|
+
nonce: z.string(),
|
|
216
|
+
publicKey: z.templateLiteral(['0x', z.string()]),
|
|
217
|
+
rpId: z.string(),
|
|
218
|
+
});
|
|
219
|
+
/** A signature challenge's `verification` value. */
|
|
220
|
+
schema.signature = z.object({
|
|
221
|
+
account: z.string(),
|
|
222
|
+
clientId: z.string(),
|
|
223
|
+
credential: z.object({
|
|
224
|
+
id: z.string(),
|
|
225
|
+
publicKey: hex,
|
|
226
|
+
rpId: z.string(),
|
|
227
|
+
}),
|
|
228
|
+
});
|
|
229
|
+
/** The passkey step, which an approval of a key for a passkey-owned account returns. */
|
|
230
|
+
schema.step = z
|
|
231
|
+
.object({
|
|
232
|
+
step: z
|
|
233
|
+
.object({
|
|
234
|
+
options: z
|
|
235
|
+
.object({
|
|
236
|
+
publicKey: z
|
|
237
|
+
.object({
|
|
238
|
+
allowCredentials: z
|
|
239
|
+
.array(z
|
|
240
|
+
.object({
|
|
241
|
+
id: schema.credentialId.meta({
|
|
242
|
+
description: "The credential ID of the account's passkey, base64url.",
|
|
243
|
+
examples: ['KEbWNCc7NgaYnUyrNeFGX9_3Y-8'],
|
|
244
|
+
}),
|
|
245
|
+
type: z.literal('public-key').meta({
|
|
246
|
+
description: 'The credential type.',
|
|
247
|
+
}),
|
|
248
|
+
})
|
|
249
|
+
.meta({
|
|
250
|
+
description: 'The passkey that must sign.',
|
|
251
|
+
}))
|
|
252
|
+
.meta({
|
|
253
|
+
description: "The account's passkey, the only one the browser offers.",
|
|
254
|
+
}),
|
|
255
|
+
challenge: z.templateLiteral(['0x', z.string()]).meta({
|
|
256
|
+
description: "The key authorization's digest, as hex. It is single-use, and expires after 5 minutes.",
|
|
257
|
+
examples: [
|
|
258
|
+
'0xf6310589abb21116acc6e123967ed0a125b5041c43f8e157237093e07eaa354c',
|
|
259
|
+
],
|
|
260
|
+
}),
|
|
261
|
+
rpId: z.string().meta({
|
|
262
|
+
description: "The relying party ID of the account's passkey.",
|
|
263
|
+
examples: ['tempo.xyz'],
|
|
264
|
+
}),
|
|
265
|
+
userVerification: z.literal('required').meta({
|
|
266
|
+
description: 'Every passkey signature requires user verification.',
|
|
267
|
+
}),
|
|
268
|
+
})
|
|
269
|
+
.meta({
|
|
270
|
+
description: 'The `PublicKeyCredentialRequestOptions`, serialized with the challenge as hex.',
|
|
271
|
+
}),
|
|
272
|
+
})
|
|
273
|
+
.meta({
|
|
274
|
+
description: 'The options for `navigator.credentials.get()`.',
|
|
275
|
+
}),
|
|
276
|
+
type: z.literal('passkey').meta({
|
|
277
|
+
description: 'Sign the options with the passkey, then repeat the approval with `passkey: { assertion }`.',
|
|
278
|
+
}),
|
|
279
|
+
})
|
|
280
|
+
.meta({
|
|
281
|
+
description: "The next step: the passkey's signature over the key authorization's digest.",
|
|
282
|
+
}),
|
|
283
|
+
})
|
|
284
|
+
.meta({
|
|
285
|
+
description: 'An approval that continues when the passkey signs the key authorization.',
|
|
286
|
+
id: 'PasskeyStep',
|
|
287
|
+
});
|
|
288
|
+
/** A challenge's `verification` value. */
|
|
289
|
+
schema.value = z.object({
|
|
290
|
+
clientId: z.string().nullable(),
|
|
291
|
+
link: z.string().optional(),
|
|
292
|
+
// A challenge without an origin runs at Tempo ID's own page.
|
|
293
|
+
origin: z.string().optional(),
|
|
294
|
+
// A stored challenge can name no realm. It verifies against stored passkeys only.
|
|
295
|
+
realmId: z.string().optional(),
|
|
296
|
+
rpId: z.string(),
|
|
297
|
+
// A one-tap challenge is the digest of a key authorization with this witness.
|
|
298
|
+
witness: z.templateLiteral(['0x', z.string()]).optional(),
|
|
299
|
+
});
|
|
300
|
+
})(schema || (schema = {}));
|
|
301
|
+
/**
|
|
302
|
+
* Issues a challenge for a sign-in at `rpId`, stores it until it expires, and returns it as hex. The
|
|
303
|
+
* challenge is random, or the digest of a key authorization for a one-tap sign-in, which stores its
|
|
304
|
+
* witness beside it.
|
|
305
|
+
*/
|
|
306
|
+
export async function challenge(db, options) {
|
|
307
|
+
const value = (options.oneTap?.digest ??
|
|
308
|
+
Hex.fromBytes(crypto.getRandomValues(new Uint8Array(32)))).toLowerCase();
|
|
309
|
+
await db.insert(Schema.verification).values({
|
|
310
|
+
expiresAt: new Date(Date.now() + lifetime * 1000),
|
|
311
|
+
id: crypto.randomUUID(),
|
|
312
|
+
identifier: prefix + value,
|
|
313
|
+
value: JSON.stringify(schema.value.parse({
|
|
314
|
+
clientId: options.clientId,
|
|
315
|
+
link: options.link,
|
|
316
|
+
origin: options.origin,
|
|
317
|
+
realmId: options.realmId,
|
|
318
|
+
rpId: options.rpId,
|
|
319
|
+
witness: options.oneTap?.witness,
|
|
320
|
+
})),
|
|
321
|
+
});
|
|
322
|
+
return value;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Returns why Tempo ID refuses a passkey ceremony on an app's page, or `undefined` when the page may
|
|
326
|
+
* run one. Tempo ID verifies the assertion for the page's origin, so only a first-party web app's
|
|
327
|
+
* page, at the origin of one of its redirect URIs, runs a ceremony:
|
|
328
|
+
*
|
|
329
|
+
* - A page sends the app's `client_id`, and the app must exist, be enabled, and skip consent.
|
|
330
|
+
* - A native app's request proves no app, so it signs in through an authentication sheet.
|
|
331
|
+
* - The request's `Origin` must be the origin of one of the app's redirect URIs.
|
|
332
|
+
*/
|
|
333
|
+
export function checkPage(options) {
|
|
334
|
+
const { app, clientId, origin } = options;
|
|
335
|
+
if (!clientId)
|
|
336
|
+
return new Authorize.InvalidOriginError({
|
|
337
|
+
error_description: `Invalid \`Origin\`: ${origin ?? 'none'}. A passkey sign-in from an app's page sends the app's \`client_id\`.`,
|
|
338
|
+
field: 'Origin',
|
|
339
|
+
...(origin ? { meta: { origin } } : {}),
|
|
340
|
+
});
|
|
341
|
+
if (!app || !app.skipConsent)
|
|
342
|
+
return new Authorize.RejectedError({
|
|
343
|
+
description: `Passkey sign-in refused: ${clientId} is not a first-party app. Send the user to \`/oauth2/authorize\`, which offers passkey sign-in.`,
|
|
344
|
+
});
|
|
345
|
+
if (app.type === 'native')
|
|
346
|
+
return new Authorize.RejectedError({
|
|
347
|
+
description: "Passkey sign-in refused: a native app's request does not prove which app sends it. Open `/oauth2/authorize` in an authentication sheet.",
|
|
348
|
+
});
|
|
349
|
+
const origins = app.redirectUris.flatMap((uri) => {
|
|
350
|
+
const url = URL.parse(uri);
|
|
351
|
+
return url?.protocol === 'https:' || url?.protocol === 'http:'
|
|
352
|
+
? [url.origin]
|
|
353
|
+
: [];
|
|
354
|
+
});
|
|
355
|
+
if (!origin || !origins.includes(origin))
|
|
356
|
+
return new Authorize.InvalidOriginError({
|
|
357
|
+
error_description: `Invalid \`Origin\`: ${origin ?? 'none'}. Passkey sign-in for ${clientId} must come from the origin of one of its redirect URIs.`,
|
|
358
|
+
field: 'Origin',
|
|
359
|
+
...(origin ? { meta: { origin } } : {}),
|
|
360
|
+
});
|
|
361
|
+
return undefined;
|
|
362
|
+
}
|
|
363
|
+
(function (checkPage) {
|
|
364
|
+
/** The refusals `checkPage` returns. Its return type admits no other. */
|
|
365
|
+
checkPage.errors = [
|
|
366
|
+
Authorize.InvalidOriginError,
|
|
367
|
+
Authorize.RejectedError,
|
|
368
|
+
];
|
|
369
|
+
})(checkPage || (checkPage = {}));
|
|
370
|
+
/**
|
|
371
|
+
* Returns the passkey with the credential `id` that belongs to `rpId`, or `undefined` when Tempo ID
|
|
372
|
+
* stores none.
|
|
373
|
+
*/
|
|
374
|
+
export async function get(db, options) {
|
|
375
|
+
const [key] = await db
|
|
376
|
+
.select()
|
|
377
|
+
.from(Schema.keys)
|
|
378
|
+
.where(and(eq(Schema.keys.id, options.id), eq(Schema.keys.rpId, options.rpId)));
|
|
379
|
+
return key;
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* Stores a verified wallet.tempo passkey for `userId`, and returns the user the passkey's row names.
|
|
383
|
+
* A concurrent first sign-in of the same passkey can store the row first, so the row decides.
|
|
384
|
+
* Returns `undefined` when another passkey holds the address.
|
|
385
|
+
*/
|
|
386
|
+
export async function link(db, options) {
|
|
387
|
+
const { credential, id, rpId, userId } = options;
|
|
388
|
+
// `TempoAccount.create` takes the same lock to claim the realm of a first account, so a link
|
|
389
|
+
// either commits before the claim, and the claim gives way to it, or after it. A link after the
|
|
390
|
+
// claim adds the passkey's account beside the created one, as a link after its creation does.
|
|
391
|
+
return await db.transaction(async (tx) => {
|
|
392
|
+
await Owner.lock(tx, { userId });
|
|
393
|
+
// The `default` realm without a row signs in with a relying party that `Realm.withDefaults`
|
|
394
|
+
// derives. The first linked passkey stores it, so the unique `rp_id` keeps another realm from
|
|
395
|
+
// taking it, and a later change to `URL` keeps the passkeys that exist. A row already stored
|
|
396
|
+
// for `default`, or for this relying party, leaves the insert without effect.
|
|
397
|
+
await tx
|
|
398
|
+
.insert(Schema.realmPasskeys)
|
|
399
|
+
.values({ realmId: 'default', rpId })
|
|
400
|
+
.onConflictDoNothing();
|
|
401
|
+
const [inserted] = await tx
|
|
402
|
+
.insert(Schema.keys)
|
|
403
|
+
.values({
|
|
404
|
+
address: credential.address.toLowerCase(),
|
|
405
|
+
...(credential.createdAt === null
|
|
406
|
+
? {}
|
|
407
|
+
: { createdAt: new Date(credential.createdAt) }),
|
|
408
|
+
id,
|
|
409
|
+
publicKey: credential.publicKey,
|
|
410
|
+
rpId,
|
|
411
|
+
source: 'wallet',
|
|
412
|
+
type: 'passkey',
|
|
413
|
+
userId,
|
|
414
|
+
})
|
|
415
|
+
.onConflictDoNothing()
|
|
416
|
+
.returning({ userId: Schema.keys.userId });
|
|
417
|
+
if (inserted)
|
|
418
|
+
return inserted.userId;
|
|
419
|
+
const existing = await get(tx, { id, rpId });
|
|
420
|
+
return existing?.userId;
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* Derives the link cookie's own key from `secret` with HKDF-SHA256, as hex. The cookie thus shares
|
|
425
|
+
* no key with anything else that `SECRET` encrypts, such as the signing keys.
|
|
426
|
+
*/
|
|
427
|
+
async function linkKey(secret) {
|
|
428
|
+
const encoder = new TextEncoder();
|
|
429
|
+
const material = await crypto.subtle.importKey('raw', encoder.encode(secret), 'HKDF', false, ['deriveBits']);
|
|
430
|
+
const bits = await crypto.subtle.deriveBits({
|
|
431
|
+
hash: 'SHA-256',
|
|
432
|
+
info: encoder.encode('tempo-id:passkey-link:v1'),
|
|
433
|
+
name: 'HKDF',
|
|
434
|
+
salt: new Uint8Array(),
|
|
435
|
+
}, material, 256);
|
|
436
|
+
return Hex.fromBytes(new Uint8Array(bits));
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Instantiates a passkey sign-in plugin for Better Auth. Its server-only `signInPasskey` endpoint
|
|
440
|
+
* creates a session for a user whose assertion a route verified, and sets the session cookie. Like
|
|
441
|
+
* every sign-in, it continues an app's authorization that `oauth_query` names.
|
|
442
|
+
*/
|
|
443
|
+
export function plugin() {
|
|
444
|
+
return {
|
|
445
|
+
endpoints: {
|
|
446
|
+
signInPasskey: createAuthEndpoint.serverOnly({
|
|
447
|
+
body: z.object({
|
|
448
|
+
oauth_query: z.string().optional(),
|
|
449
|
+
userId: z.string(),
|
|
450
|
+
}),
|
|
451
|
+
method: 'POST',
|
|
452
|
+
}, async (ctx) => {
|
|
453
|
+
const user = await ctx.context.internalAdapter.findUserById(ctx.body.userId);
|
|
454
|
+
if (!user)
|
|
455
|
+
throw new Error('The passkey user is missing.');
|
|
456
|
+
const session = await ctx.context.internalAdapter.createSession(user.id);
|
|
457
|
+
await setSessionCookie(ctx, { session, user });
|
|
458
|
+
return ctx.json({ user: { email: user.email, id: user.id } });
|
|
459
|
+
}),
|
|
460
|
+
},
|
|
461
|
+
id: 'tempo-id-passkey',
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Returns the first of `realms` that holds passkeys which can sign in at `origin`, and at `page`
|
|
466
|
+
* when given, with its relying party ID, or `undefined` when none can. A WebAuthn ceremony runs
|
|
467
|
+
* only at an origin whose host is the relying party ID or one of its subdomains.
|
|
468
|
+
*/
|
|
469
|
+
export function relyingParty(realms, options) {
|
|
470
|
+
const hosts = [options.origin, options.page].flatMap((origin) => origin ? [new URL(origin).hostname] : []);
|
|
471
|
+
for (const realm of realms) {
|
|
472
|
+
const rpId = realm.passkeys?.rpId;
|
|
473
|
+
if (rpId !== undefined &&
|
|
474
|
+
hosts.every((host) => host === rpId || host.endsWith(`.${rpId}`)))
|
|
475
|
+
return { realmId: realm.id, rpId };
|
|
476
|
+
}
|
|
477
|
+
return undefined;
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Stores the digest of a key authorization as the challenge of a signature by `credential`, until it
|
|
481
|
+
* expires. Only the user with `userId` spends it, for the same account, app, and passkey.
|
|
482
|
+
*/
|
|
483
|
+
export async function requestSignature(db, options) {
|
|
484
|
+
const { account, clientId, credential, digest, userId } = options;
|
|
485
|
+
await db.insert(Schema.verification).values({
|
|
486
|
+
expiresAt: new Date(Date.now() + lifetime * 1000),
|
|
487
|
+
id: crypto.randomUUID(),
|
|
488
|
+
identifier: signatureIdentifier({
|
|
489
|
+
account,
|
|
490
|
+
clientId,
|
|
491
|
+
credentialId: credential.id,
|
|
492
|
+
digest,
|
|
493
|
+
userId,
|
|
494
|
+
}),
|
|
495
|
+
value: JSON.stringify(schema.signature.parse({
|
|
496
|
+
account: account.toLowerCase(),
|
|
497
|
+
clientId,
|
|
498
|
+
credential,
|
|
499
|
+
})),
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* Encrypts a deferred link with a key derived from `secret`, for the link cookie. The cookie cannot
|
|
504
|
+
* be read, changed, or forged without the secret.
|
|
505
|
+
*/
|
|
506
|
+
export async function seal(value, options) {
|
|
507
|
+
return await symmetricEncrypt({
|
|
508
|
+
data: JSON.stringify(schema.link.parse(value)),
|
|
509
|
+
key: await linkKey(options.secret),
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* Spends the challenge that `clientDataJSON` names, and returns it, or `undefined` when it is
|
|
514
|
+
* unknown, spent, or expired. One statement deletes and returns the row, so two concurrent
|
|
515
|
+
* assertions over one challenge cannot both spend it.
|
|
516
|
+
*/
|
|
517
|
+
export async function take(db, options) {
|
|
518
|
+
const challenge = (() => {
|
|
519
|
+
try {
|
|
520
|
+
const data = schema.clientData.parse(JSON.parse(options.clientDataJSON));
|
|
521
|
+
return Base64.toHex(data.challenge);
|
|
522
|
+
}
|
|
523
|
+
catch {
|
|
524
|
+
return undefined;
|
|
525
|
+
}
|
|
526
|
+
})();
|
|
527
|
+
if (!challenge)
|
|
528
|
+
return undefined;
|
|
529
|
+
const [row] = await db
|
|
530
|
+
.delete(Schema.verification)
|
|
531
|
+
.where(and(eq(Schema.verification.identifier, prefix + challenge.toLowerCase()), gt(Schema.verification.expiresAt, new Date())))
|
|
532
|
+
.returning({ value: Schema.verification.value });
|
|
533
|
+
if (!row)
|
|
534
|
+
return undefined;
|
|
535
|
+
const value = schema.value.parse(JSON.parse(row.value));
|
|
536
|
+
return {
|
|
537
|
+
challenge,
|
|
538
|
+
clientId: value.clientId,
|
|
539
|
+
link: value.link,
|
|
540
|
+
origin: value.origin,
|
|
541
|
+
realmId: value.realmId,
|
|
542
|
+
rpId: value.rpId,
|
|
543
|
+
witness: value.witness,
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* Spends the signature challenge that `clientDataJSON` names, for the user, app, account, and
|
|
548
|
+
* passkey of `options`, and returns it, or `undefined` when it is unknown, spent, or expired. One
|
|
549
|
+
* statement deletes and returns the rows, so two concurrent assertions over one challenge cannot
|
|
550
|
+
* both spend it, and an approval for another app, account, or passkey spends none of its rows.
|
|
551
|
+
*
|
|
552
|
+
* Returns the challenge only when `verify` accepts it with the assertion. Every step for the same
|
|
553
|
+
* key issues the same digest, so the transaction then records the assertion as spent until
|
|
554
|
+
* `expiry`, for a year at most, and returns `undefined` for an assertion that it recorded before. A captured assertion
|
|
555
|
+
* thus signs no second approval, and an assertion that does not verify leaves no record.
|
|
556
|
+
*/
|
|
557
|
+
export async function takeSignature(db, options) {
|
|
558
|
+
const digest = (() => {
|
|
559
|
+
try {
|
|
560
|
+
const data = schema.clientData.parse(JSON.parse(options.clientDataJSON));
|
|
561
|
+
return Base64.toHex(data.challenge);
|
|
562
|
+
}
|
|
563
|
+
catch {
|
|
564
|
+
return undefined;
|
|
565
|
+
}
|
|
566
|
+
})();
|
|
567
|
+
if (!digest)
|
|
568
|
+
return undefined;
|
|
569
|
+
const spent = spentPrefix +
|
|
570
|
+
Hash.sha256(Hex.concat(options.authenticatorData, options.signature));
|
|
571
|
+
return await db.transaction(async (tx) => {
|
|
572
|
+
// The lock serializes requests with one assertion, so only the first records it.
|
|
573
|
+
await tx.execute(sql `select pg_advisory_xact_lock(hashtextextended(${spent}, 0))`);
|
|
574
|
+
const [used] = await tx
|
|
575
|
+
.select({ id: Schema.verification.id })
|
|
576
|
+
.from(Schema.verification)
|
|
577
|
+
.where(and(eq(Schema.verification.identifier, spent), gt(Schema.verification.expiresAt, new Date())));
|
|
578
|
+
// Each approval of one request issues the same digest, so every row that it names is spent.
|
|
579
|
+
// A replayed assertion spends the challenge too, so the step must run again.
|
|
580
|
+
const [row] = await tx
|
|
581
|
+
.delete(Schema.verification)
|
|
582
|
+
.where(and(eq(Schema.verification.identifier, signatureIdentifier({ ...options, digest })), gt(Schema.verification.expiresAt, new Date())))
|
|
583
|
+
.returning({ value: Schema.verification.value });
|
|
584
|
+
if (!row || used)
|
|
585
|
+
return undefined;
|
|
586
|
+
const value = { ...schema.signature.parse(JSON.parse(row.value)), digest };
|
|
587
|
+
if (!options.verify(value))
|
|
588
|
+
return undefined;
|
|
589
|
+
// A signed request with the same key can reach a new step until the key expires.
|
|
590
|
+
await tx.insert(Schema.verification).values({
|
|
591
|
+
expiresAt: new Date(Math.min(Math.max(options.expiry * 1000, Date.now() + lifetime * 1000), Date.now() + spentLifetime * 1000)),
|
|
592
|
+
id: crypto.randomUUID(),
|
|
593
|
+
identifier: spent,
|
|
594
|
+
value: '{}',
|
|
595
|
+
});
|
|
596
|
+
return value;
|
|
597
|
+
});
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* Returns the `verification` identifier of a signature challenge, which names its user, app,
|
|
601
|
+
* account, passkey, and digest. JSON keeps each value apart, whatever characters it holds.
|
|
602
|
+
*/
|
|
603
|
+
function signatureIdentifier(options) {
|
|
604
|
+
return (signaturePrefix +
|
|
605
|
+
JSON.stringify([
|
|
606
|
+
options.userId,
|
|
607
|
+
options.clientId,
|
|
608
|
+
options.account.toLowerCase(),
|
|
609
|
+
options.credentialId,
|
|
610
|
+
options.digest.toLowerCase(),
|
|
611
|
+
]));
|
|
612
|
+
}
|
|
613
|
+
/**
|
|
614
|
+
* Decrypts the link cookie's value, and returns the deferred link, or `undefined` when the value
|
|
615
|
+
* does not decrypt with `secret`, has another shape, came from another host, or expired.
|
|
616
|
+
*/
|
|
617
|
+
export async function unseal(sealed, options) {
|
|
618
|
+
const value = await symmetricDecrypt({
|
|
619
|
+
data: sealed,
|
|
620
|
+
key: await linkKey(options.secret),
|
|
621
|
+
})
|
|
622
|
+
.then((data) => schema.link.safeParse(JSON.parse(data)))
|
|
623
|
+
.catch(() => undefined);
|
|
624
|
+
if (!value?.success)
|
|
625
|
+
return undefined;
|
|
626
|
+
if (value.data.host !== options.host)
|
|
627
|
+
return undefined;
|
|
628
|
+
if (value.data.expiresAt <= Date.now() / 1000)
|
|
629
|
+
return undefined;
|
|
630
|
+
return value.data;
|
|
631
|
+
}
|
|
632
|
+
/**
|
|
633
|
+
* Returns whether `assertion` signs `challenge` with `publicKey`, at `origin`, for `rpId`, with the
|
|
634
|
+
* user present and verified, outside a cross-origin iframe. The client cannot waive user
|
|
635
|
+
* verification.
|
|
636
|
+
*/
|
|
637
|
+
export function verify(assertion, options) {
|
|
638
|
+
try {
|
|
639
|
+
// WebAuthn verification leaves `crossOrigin` to the relying party. A frame on another site
|
|
640
|
+
// could otherwise run the ceremony for Tempo ID's origin.
|
|
641
|
+
const data = schema.clientData.parse(JSON.parse(assertion.metadata.clientDataJSON));
|
|
642
|
+
if (data.crossOrigin)
|
|
643
|
+
return false;
|
|
644
|
+
return Authentication.verify({
|
|
645
|
+
...assertion,
|
|
646
|
+
metadata: { ...assertion.metadata, userVerificationRequired: true },
|
|
647
|
+
}, {
|
|
648
|
+
challenge: options.challenge,
|
|
649
|
+
origin: options.origin,
|
|
650
|
+
publicKey: options.publicKey,
|
|
651
|
+
rpId: options.rpId,
|
|
652
|
+
});
|
|
653
|
+
}
|
|
654
|
+
catch {
|
|
655
|
+
return false;
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
//# sourceMappingURL=Passkey.js.map
|