@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,393 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Signs an app's key authorization as the owner of the user's Tempo Account. The key acts for the
|
|
3
|
+
* account that it names, else the app's selected account, else the user's oldest. An owner with a
|
|
4
|
+
* server signer, such as a Privy wallet, signs on the server. A passkey signs only in the browser,
|
|
5
|
+
* on the approval page: {@link challenge} issues the key's digest as the passkey's challenge, and
|
|
6
|
+
* {@link sign} verifies the assertion over it. Elsewhere its account refuses the key with
|
|
7
|
+
* `webauthn_required`.
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import type { Context } from 'hono'
|
|
11
|
+
import type { KeyAuthorization as ox_KeyAuthorization } from 'ox/tempo'
|
|
12
|
+
import { env } from 'void/env'
|
|
13
|
+
import { Authentication } from 'webauthx/server'
|
|
14
|
+
import * as z from 'zod'
|
|
15
|
+
import * as Authorize from '../../internal/Authorize.js'
|
|
16
|
+
import type { Env } from '../../internal/Env.js'
|
|
17
|
+
import * as ErrorResponse from '../../internal/ErrorResponse.js'
|
|
18
|
+
import * as Log from '../../internal/Log.js'
|
|
19
|
+
import * as KeyAuthorization from '../../internal/KeyAuthorization.js'
|
|
20
|
+
import type * as Owner from '../../internal/Owner.js'
|
|
21
|
+
import * as Passkey from '../../internal/Passkey.js'
|
|
22
|
+
import * as TempoAccount from '../../internal/TempoAccount.js'
|
|
23
|
+
import * as Timing from '../../internal/Timing.js'
|
|
24
|
+
import * as AccountStep from './AccountStep.js'
|
|
25
|
+
import { db } from './Database.js'
|
|
26
|
+
|
|
27
|
+
export namespace schema {
|
|
28
|
+
/** Why approval cannot sign a key, as {@link preview} returns it. */
|
|
29
|
+
export const refusal = z
|
|
30
|
+
.enum(['foreign_account', 'no_account', 'passkey', 'unavailable'])
|
|
31
|
+
.meta({
|
|
32
|
+
description:
|
|
33
|
+
"Why approval cannot sign the key: the key names an account that is not the user's (`foreign_account`), the user holds no account and none can be created (`no_account`), a passkey that this page cannot use owns the account (`passkey`), or the accounts could not be read (`unavailable`). Absent when approval can sign it.",
|
|
34
|
+
examples: ['passkey'],
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Issues the digest of `key` as the challenge of a signature by `owner`'s passkey, for the user with
|
|
40
|
+
* `userId`, and returns the request options for `navigator.credentials.get()`. The options name only
|
|
41
|
+
* that passkey, and require user verification.
|
|
42
|
+
*/
|
|
43
|
+
export async function challenge(
|
|
44
|
+
c: Timing.measure.Context,
|
|
45
|
+
options: challenge.Options,
|
|
46
|
+
) {
|
|
47
|
+
const { account, clientId, key, owner, userId } = options
|
|
48
|
+
// `resolve` returns a passkey owner only with its credential.
|
|
49
|
+
const credential = owner.credential!
|
|
50
|
+
const digest = KeyAuthorization.digest({ key })
|
|
51
|
+
await Timing.measure(
|
|
52
|
+
c,
|
|
53
|
+
Passkey.requestSignature(db, {
|
|
54
|
+
account,
|
|
55
|
+
clientId,
|
|
56
|
+
credential,
|
|
57
|
+
digest,
|
|
58
|
+
userId,
|
|
59
|
+
}),
|
|
60
|
+
'Passkey.requestSignature',
|
|
61
|
+
)
|
|
62
|
+
return Authentication.getOptions({
|
|
63
|
+
challenge: digest,
|
|
64
|
+
credentialId: credential.id,
|
|
65
|
+
rpId: credential.rpId,
|
|
66
|
+
userVerification: 'required',
|
|
67
|
+
}).options
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export declare namespace challenge {
|
|
71
|
+
type Options = {
|
|
72
|
+
/** The account that the key acts for. */
|
|
73
|
+
account: `0x${string}`
|
|
74
|
+
/** The client ID of the app that requests the key. */
|
|
75
|
+
clientId: string
|
|
76
|
+
/** The key authorization whose digest the passkey signs. */
|
|
77
|
+
key: KeyAuthorization.Key
|
|
78
|
+
/** The account's passkey owner, as `resolve` returns it with `passkey`. */
|
|
79
|
+
owner: Owner.Owner
|
|
80
|
+
/** The signed-in user's ID. */
|
|
81
|
+
userId: string
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Returns what an approval page shows of a key before the user decides: the account that approval
|
|
87
|
+
* signs for, and why approval cannot sign it, if it cannot. A key that names a foreign account also
|
|
88
|
+
* returns its refusal as `foreign`. The owners' lookup can call every realm's
|
|
89
|
+
* Privy app, so it counts against the user's `ACCOUNT_LIMIT`, as `GET /v1/account` does. A spent
|
|
90
|
+
* limit or a failed read, such as during a Privy outage, returns `unavailable`. A user who holds no
|
|
91
|
+
* account can approve when the app's first realm creates one on approval.
|
|
92
|
+
*/
|
|
93
|
+
export async function preview(c: Context<Env>, options: preview.Options) {
|
|
94
|
+
const { clientId, sessionId, userId } = options
|
|
95
|
+
const signing = await (async () => {
|
|
96
|
+
const outcome = await Timing.measure(
|
|
97
|
+
c,
|
|
98
|
+
c.env.ACCOUNT_LIMIT.limit({ key: userId }),
|
|
99
|
+
'ratelimit.limit',
|
|
100
|
+
)
|
|
101
|
+
if (!outcome.success) return undefined
|
|
102
|
+
return await Timing.measure(
|
|
103
|
+
c,
|
|
104
|
+
resolve(c, {
|
|
105
|
+
account: options.account,
|
|
106
|
+
clientId,
|
|
107
|
+
cookie: c.req.header('cookie'),
|
|
108
|
+
// The approval page runs the passkey step.
|
|
109
|
+
passkey: true,
|
|
110
|
+
sessionId,
|
|
111
|
+
userId,
|
|
112
|
+
}),
|
|
113
|
+
'KeySigner.resolve',
|
|
114
|
+
).catch((error: unknown) => {
|
|
115
|
+
Log.warn(c, {
|
|
116
|
+
error,
|
|
117
|
+
fields: { clientId },
|
|
118
|
+
message: 'An approval held a key whose account owners failed to load.',
|
|
119
|
+
})
|
|
120
|
+
return undefined
|
|
121
|
+
})
|
|
122
|
+
})()
|
|
123
|
+
|
|
124
|
+
// A user who holds no account receives the first one on approval, when the app's first realm can
|
|
125
|
+
// create it.
|
|
126
|
+
const creates =
|
|
127
|
+
signing instanceof Authorize.RejectedError
|
|
128
|
+
? await Timing.measure(
|
|
129
|
+
c,
|
|
130
|
+
AccountStep.creates(c, { clientId }),
|
|
131
|
+
'AccountStep.creates',
|
|
132
|
+
)
|
|
133
|
+
: false
|
|
134
|
+
const account = (() => {
|
|
135
|
+
if (!signing) return options.account
|
|
136
|
+
if (signing instanceof KeyAuthorization.WebAuthnRequiredError)
|
|
137
|
+
return signing.response.meta?.account as `0x${string}` | undefined
|
|
138
|
+
if (signing instanceof ErrorResponse.ResponseError) return options.account
|
|
139
|
+
return signing.account
|
|
140
|
+
})()
|
|
141
|
+
const refusal = ((): z.output<typeof schema.refusal> | undefined => {
|
|
142
|
+
if (!signing) return 'unavailable'
|
|
143
|
+
if (signing instanceof TempoAccount.ForeignAccountError)
|
|
144
|
+
return 'foreign_account'
|
|
145
|
+
// A passkey signs only at its own relying party, which may not cover this page.
|
|
146
|
+
if (signing instanceof KeyAuthorization.WebAuthnRequiredError)
|
|
147
|
+
return 'passkey'
|
|
148
|
+
if (signing instanceof Authorize.RejectedError && !creates)
|
|
149
|
+
return 'no_account'
|
|
150
|
+
return undefined
|
|
151
|
+
})()
|
|
152
|
+
return {
|
|
153
|
+
account,
|
|
154
|
+
foreign:
|
|
155
|
+
signing instanceof TempoAccount.ForeignAccountError ? signing : undefined,
|
|
156
|
+
refusal,
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export declare namespace preview {
|
|
161
|
+
type Options = {
|
|
162
|
+
/** The account that the key names, if any. */
|
|
163
|
+
account?: `0x${string}` | undefined
|
|
164
|
+
/** The client ID of the app that requests the key. */
|
|
165
|
+
clientId: string
|
|
166
|
+
/** The ID of the signed-in session, which bounds the account step's selection. */
|
|
167
|
+
sessionId: string
|
|
168
|
+
/** The signed-in user's ID. */
|
|
169
|
+
userId: string
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Returns the account that the key acts for and its owner: the account that `account` names, else
|
|
175
|
+
* the one that the `Cookie` header selects for the app within the session, else the user's oldest
|
|
176
|
+
* in the app's realms. With `create`, a user who holds no account and names none first receives a
|
|
177
|
+
* Privy-owned account, as `POST /v1/account` creates it. Returns a refusal when `account` is not the
|
|
178
|
+
* user's, when the user holds no account, or when a passkey owns the account.
|
|
179
|
+
*/
|
|
180
|
+
export async function resolve(
|
|
181
|
+
c: Timing.measure.Context,
|
|
182
|
+
options: resolve.Options,
|
|
183
|
+
): Promise<resolve.ReturnType | ErrorResponse.Instance<typeof resolve.errors>> {
|
|
184
|
+
const { clientId, cookie, sessionId, userId } = options
|
|
185
|
+
// A named account is one the user already holds, so its request creates none.
|
|
186
|
+
const owners =
|
|
187
|
+
options.create && !options.account
|
|
188
|
+
? await Timing.measure(
|
|
189
|
+
c,
|
|
190
|
+
AccountStep.create(c, { clientId, userId }),
|
|
191
|
+
'AccountStep.create',
|
|
192
|
+
)
|
|
193
|
+
: await Timing.measure(
|
|
194
|
+
c,
|
|
195
|
+
AccountStep.held(c, { clientId, userId }),
|
|
196
|
+
'AccountStep.held',
|
|
197
|
+
)
|
|
198
|
+
const listed = owners.map(TempoAccount.serialize)
|
|
199
|
+
|
|
200
|
+
const named = options.account
|
|
201
|
+
const selected = named
|
|
202
|
+
? undefined
|
|
203
|
+
: AccountStep.find(
|
|
204
|
+
listed,
|
|
205
|
+
AccountStep.selected({ clientId, cookie, sessionId }),
|
|
206
|
+
)?.address
|
|
207
|
+
// A user who chose no account, and holds several, signs only on a page that shows the account.
|
|
208
|
+
if (options.single && !named && !selected && listed.length > 1)
|
|
209
|
+
return new Authorize.RejectedError({
|
|
210
|
+
description:
|
|
211
|
+
"Several Tempo Accounts: the user holds more than one account in the app's realms and chose none. Choose the account on the account step, or name it in `key_authorization.account`.",
|
|
212
|
+
})
|
|
213
|
+
const account = (() => {
|
|
214
|
+
if (named) return AccountStep.find(listed, named)?.address
|
|
215
|
+
return selected ?? listed[0]?.address
|
|
216
|
+
})()
|
|
217
|
+
if (named && !account)
|
|
218
|
+
return new TempoAccount.ForeignAccountError({
|
|
219
|
+
account: named,
|
|
220
|
+
field: 'key_authorization.account',
|
|
221
|
+
})
|
|
222
|
+
const owner = account
|
|
223
|
+
? owners.find(
|
|
224
|
+
(entry) =>
|
|
225
|
+
TempoAccount.serialize(entry).address.toLowerCase() ===
|
|
226
|
+
account.toLowerCase(),
|
|
227
|
+
)
|
|
228
|
+
: undefined
|
|
229
|
+
if (!account || !owner)
|
|
230
|
+
return new Authorize.RejectedError({
|
|
231
|
+
description: options.create
|
|
232
|
+
? "No Tempo Account: the user holds no account in the app's realms, and the app's first realm has no Privy app to create one. Authorize without `key_authorization`."
|
|
233
|
+
: "No Tempo Account: the user holds no account in the app's realms, so no owner signs the key. Create the account with `POST /v1/account`, or authorize without `key_authorization`.",
|
|
234
|
+
})
|
|
235
|
+
// A passkey signs only in the browser, on a page that shows the key, at its relying party.
|
|
236
|
+
if (!owner.signer && !(options.passkey && signsHere(owner)))
|
|
237
|
+
return new KeyAuthorization.WebAuthnRequiredError({ account })
|
|
238
|
+
return { account, owner }
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export namespace resolve {
|
|
242
|
+
export type Options = {
|
|
243
|
+
/** The account that the request names, if any. */
|
|
244
|
+
account?: `0x${string}` | undefined
|
|
245
|
+
/** The client ID of the app that requests the key. */
|
|
246
|
+
clientId: string
|
|
247
|
+
/** The request's `Cookie` header, which holds the account step's selection. */
|
|
248
|
+
cookie: string | undefined
|
|
249
|
+
/**
|
|
250
|
+
* Whether a user who holds no account and names none receives a first account. Only an explicit
|
|
251
|
+
* approval on Tempo ID's own page sets it. Defaults to `false`.
|
|
252
|
+
*/
|
|
253
|
+
create?: boolean | undefined
|
|
254
|
+
/**
|
|
255
|
+
* Whether the caller signs with a passkey in the browser, as the approval page does. A passkey
|
|
256
|
+
* owner whose relying party covers Tempo ID's origin then resolves, in place of
|
|
257
|
+
* `webauthn_required`. Defaults to `false`.
|
|
258
|
+
*/
|
|
259
|
+
passkey?: boolean | undefined
|
|
260
|
+
/** The ID of the signed-in session, which bounds the selection. */
|
|
261
|
+
sessionId: string
|
|
262
|
+
/**
|
|
263
|
+
* Whether a user who names no account, selected none, and holds several is refused, in place of
|
|
264
|
+
* the oldest account. A grant that shows no account sets it. Defaults to `false`.
|
|
265
|
+
*/
|
|
266
|
+
single?: boolean | undefined
|
|
267
|
+
/** The signed-in user's ID. */
|
|
268
|
+
userId: string
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export type ReturnType = {
|
|
272
|
+
/** The account that the key acts for. */
|
|
273
|
+
account: `0x${string}`
|
|
274
|
+
/** The account's owner, which signs the key. */
|
|
275
|
+
owner: Owner.Owner
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/** The refusals `resolve` returns. Its return type admits no other. */
|
|
279
|
+
export const errors = [
|
|
280
|
+
...AccountStep.create.errors,
|
|
281
|
+
...AccountStep.held.errors,
|
|
282
|
+
Authorize.RejectedError,
|
|
283
|
+
KeyAuthorization.WebAuthnRequiredError,
|
|
284
|
+
TempoAccount.ForeignAccountError,
|
|
285
|
+
] as const
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Signs `key` as `owner`, the owner of `account`, and returns the signed authorization in the node's
|
|
290
|
+
* RPC format. A passkey owner signs with `assertion`, over the challenge that {@link challenge}
|
|
291
|
+
* issued for the same user, app, account, passkey, and key. Returns
|
|
292
|
+
* `KeyAuthorization.WebAuthnRequiredError` for a passkey owner without an assertion, and
|
|
293
|
+
* `Passkey.WebAuthnRejectedError` for an assertion that does not verify.
|
|
294
|
+
*/
|
|
295
|
+
export async function sign(
|
|
296
|
+
c: Context<Env>,
|
|
297
|
+
options: sign.Options,
|
|
298
|
+
): Promise<sign.ReturnType | ErrorResponse.Instance<typeof sign.errors>> {
|
|
299
|
+
const { account, assertion, key, owner } = options
|
|
300
|
+
if (!owner.signer) {
|
|
301
|
+
if (!assertion || !owner.credential)
|
|
302
|
+
return new KeyAuthorization.WebAuthnRequiredError({ account })
|
|
303
|
+
const credential = owner.credential
|
|
304
|
+
// The challenge is spent before any other check, so a refused assertion cannot be tried again.
|
|
305
|
+
const challenge = await Timing.measure(
|
|
306
|
+
c,
|
|
307
|
+
Passkey.takeSignature(db, {
|
|
308
|
+
account,
|
|
309
|
+
authenticatorData: assertion.metadata.authenticatorData,
|
|
310
|
+
clientId: options.clientId,
|
|
311
|
+
clientDataJSON: assertion.metadata.clientDataJSON,
|
|
312
|
+
credentialId: assertion.id,
|
|
313
|
+
expiry: key.expiry,
|
|
314
|
+
signature: assertion.signature,
|
|
315
|
+
userId: options.userId,
|
|
316
|
+
verify: (challenge) =>
|
|
317
|
+
challenge.account === account.toLowerCase() &&
|
|
318
|
+
challenge.clientId === options.clientId &&
|
|
319
|
+
challenge.credential.id === credential.id &&
|
|
320
|
+
challenge.credential.publicKey === credential.publicKey &&
|
|
321
|
+
assertion.id === credential.id &&
|
|
322
|
+
// The repeated request names the key that the passkey signs, so its signature reaches
|
|
323
|
+
// only a request for that key.
|
|
324
|
+
challenge.digest === KeyAuthorization.digest({ key }) &&
|
|
325
|
+
Passkey.verify(assertion, {
|
|
326
|
+
challenge: challenge.digest,
|
|
327
|
+
origin: new URL(env.URL).origin,
|
|
328
|
+
publicKey: credential.publicKey,
|
|
329
|
+
rpId: credential.rpId,
|
|
330
|
+
}),
|
|
331
|
+
}),
|
|
332
|
+
'Passkey.takeSignature',
|
|
333
|
+
)
|
|
334
|
+
if (!challenge) return new Passkey.WebAuthnRejectedError()
|
|
335
|
+
return await Timing.measure(
|
|
336
|
+
c,
|
|
337
|
+
KeyAuthorization.signWithAssertion(assertion, {
|
|
338
|
+
key,
|
|
339
|
+
publicKey: credential.publicKey,
|
|
340
|
+
}),
|
|
341
|
+
'KeyAuthorization.signWithAssertion',
|
|
342
|
+
)
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
const signer = await Timing.measure(
|
|
346
|
+
c,
|
|
347
|
+
owner.signer(c, { auth: c.var.auth }),
|
|
348
|
+
'Owner.signer',
|
|
349
|
+
)
|
|
350
|
+
return await Timing.measure(
|
|
351
|
+
c,
|
|
352
|
+
KeyAuthorization.sign(signer, { key }),
|
|
353
|
+
'KeyAuthorization.sign',
|
|
354
|
+
)
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
export namespace sign {
|
|
358
|
+
export type Options = {
|
|
359
|
+
/** The account that the key acts for. */
|
|
360
|
+
account: `0x${string}`
|
|
361
|
+
/** The passkey's assertion over the challenge of {@link challenge}, for a passkey owner. */
|
|
362
|
+
assertion?: Passkey.Assertion | undefined
|
|
363
|
+
/** The client ID of the app that requests the key. */
|
|
364
|
+
clientId: string
|
|
365
|
+
/** The key authorization to sign, which the flow's checks accept. */
|
|
366
|
+
key: KeyAuthorization.Key
|
|
367
|
+
/** The account's owner. */
|
|
368
|
+
owner: Owner.Owner
|
|
369
|
+
/** The signed-in user's ID. */
|
|
370
|
+
userId: string
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/** The signed authorization, in the node's RPC format. */
|
|
374
|
+
export type ReturnType = ox_KeyAuthorization.Rpc
|
|
375
|
+
|
|
376
|
+
/** The refusals `sign` returns. Its return type admits no other. */
|
|
377
|
+
export const errors = [
|
|
378
|
+
KeyAuthorization.WebAuthnRequiredError,
|
|
379
|
+
Passkey.WebAuthnRejectedError,
|
|
380
|
+
] as const
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Returns whether `owner`'s passkey signs at Tempo ID's origin: its relying party ID is the host of
|
|
385
|
+
* that origin or a registrable suffix of it, as WebAuthn requires.
|
|
386
|
+
*/
|
|
387
|
+
function signsHere(owner: Owner.Owner) {
|
|
388
|
+
if (!owner.credential) return false
|
|
389
|
+
return (
|
|
390
|
+
Passkey.relyingParty([owner.realm], { origin: env.URL })?.rpId ===
|
|
391
|
+
owner.credential.rpId
|
|
392
|
+
)
|
|
393
|
+
}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The link cookie, which holds a verified wallet.tempo passkey without an email until an emailed
|
|
3
|
+
* code names its user. Only the code sign-in that sends back the email step's nonce, with an
|
|
4
|
+
* assertion of the same passkey, links it. A cookie left in a shared browser thus links nothing for
|
|
5
|
+
* the next person.
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import type { Context } from 'hono'
|
|
9
|
+
import { deleteCookie, getCookie, setCookie } from 'hono/cookie'
|
|
10
|
+
import { Base64, Hex } from 'ox'
|
|
11
|
+
import { env } from 'void/env'
|
|
12
|
+
import type { Env } from '../../internal/Env.js'
|
|
13
|
+
import * as Passkey from '../../internal/Passkey.js'
|
|
14
|
+
import * as Timing from '../../internal/Timing.js'
|
|
15
|
+
import type * as Wallet from '../../internal/Wallet.js'
|
|
16
|
+
|
|
17
|
+
/** Workers' `crypto.subtle`, whose `timingSafeEqual` the project's Node types leave out. */
|
|
18
|
+
type Subtle = SubtleCrypto & {
|
|
19
|
+
timingSafeEqual(a: ArrayBuffer, b: ArrayBuffer): boolean
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** The cookie's name, which the `__Host-` prefix pins to the host that set it with `Path=/`. */
|
|
23
|
+
const name = 'tempo-id-passkey-link'
|
|
24
|
+
|
|
25
|
+
/** The prefix that `hono/cookie` adds, `__Host-`. */
|
|
26
|
+
const prefix = 'host'
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Returns the deferred passkey that the link cookie holds for `nonce`, or `undefined` when there is
|
|
30
|
+
* none, or the cookie or the nonce does not match. The cookie stays until `release`, so a failed
|
|
31
|
+
* write can retry.
|
|
32
|
+
*/
|
|
33
|
+
export async function claim(c: Context<Env>, options: claim.Options) {
|
|
34
|
+
const sealed = getCookie(c, name, prefix)
|
|
35
|
+
if (!sealed) return undefined
|
|
36
|
+
|
|
37
|
+
const link = await Timing.measure(
|
|
38
|
+
c,
|
|
39
|
+
Passkey.unseal(sealed, {
|
|
40
|
+
host: new URL(c.req.url).host,
|
|
41
|
+
secret: env.SECRET,
|
|
42
|
+
}),
|
|
43
|
+
'Passkey.unseal',
|
|
44
|
+
)
|
|
45
|
+
if (!link) return undefined
|
|
46
|
+
|
|
47
|
+
// The nonce is a secret, so it is compared in constant time, through hashes of equal length.
|
|
48
|
+
const [expected, received] = await Timing.measure(
|
|
49
|
+
c,
|
|
50
|
+
Promise.all(
|
|
51
|
+
[link.nonce, options.nonce].map((value) =>
|
|
52
|
+
crypto.subtle.digest('SHA-256', new TextEncoder().encode(value)),
|
|
53
|
+
),
|
|
54
|
+
),
|
|
55
|
+
'crypto.digest',
|
|
56
|
+
)
|
|
57
|
+
return (crypto.subtle as Subtle).timingSafeEqual(expected!, received!)
|
|
58
|
+
? link
|
|
59
|
+
: undefined
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export declare namespace claim {
|
|
63
|
+
type Options = {
|
|
64
|
+
/** The nonce from the email step, which the code sign-in sent back. */
|
|
65
|
+
nonce: string
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Seals a verified wallet.tempo passkey in the link cookie for 5 minutes, and returns the nonce
|
|
71
|
+
* that the email step carries.
|
|
72
|
+
*/
|
|
73
|
+
export async function defer(c: Context<Env>, options: defer.Options) {
|
|
74
|
+
const nonce = Base64.fromBytes(crypto.getRandomValues(new Uint8Array(32)), {
|
|
75
|
+
pad: false,
|
|
76
|
+
url: true,
|
|
77
|
+
})
|
|
78
|
+
const sealed = await Timing.measure(
|
|
79
|
+
c,
|
|
80
|
+
Passkey.seal(
|
|
81
|
+
{
|
|
82
|
+
address: options.credential.address,
|
|
83
|
+
createdAt: options.credential.createdAt,
|
|
84
|
+
expiresAt: Math.floor(Date.now() / 1000) + Passkey.linkLifetime,
|
|
85
|
+
host: new URL(c.req.url).host,
|
|
86
|
+
id: options.id,
|
|
87
|
+
nonce,
|
|
88
|
+
publicKey: options.credential.publicKey,
|
|
89
|
+
rpId: options.rpId,
|
|
90
|
+
},
|
|
91
|
+
{ secret: env.SECRET },
|
|
92
|
+
),
|
|
93
|
+
'Passkey.seal',
|
|
94
|
+
)
|
|
95
|
+
setCookie(c, name, sealed, {
|
|
96
|
+
httpOnly: true,
|
|
97
|
+
maxAge: Passkey.linkLifetime,
|
|
98
|
+
path: '/',
|
|
99
|
+
prefix,
|
|
100
|
+
sameSite: 'Lax',
|
|
101
|
+
secure: true,
|
|
102
|
+
})
|
|
103
|
+
return nonce
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export declare namespace defer {
|
|
107
|
+
type Options = {
|
|
108
|
+
/** The passkey that wallet.tempo returned, which the assertion verified. */
|
|
109
|
+
credential: Wallet.Credential
|
|
110
|
+
/** The credential ID, base64url. */
|
|
111
|
+
id: string
|
|
112
|
+
/** The relying party the challenge was issued for. */
|
|
113
|
+
rpId: string
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Returns the SHA-256 digest of the email step's `nonce`, as hex. A challenge for the link stores
|
|
119
|
+
* the digest, since the nonce is a secret.
|
|
120
|
+
*/
|
|
121
|
+
export async function digest(options: digest.Options) {
|
|
122
|
+
const bytes = await crypto.subtle.digest(
|
|
123
|
+
'SHA-256',
|
|
124
|
+
new TextEncoder().encode(options.nonce),
|
|
125
|
+
)
|
|
126
|
+
return Hex.fromBytes(new Uint8Array(bytes))
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export declare namespace digest {
|
|
130
|
+
type Options = {
|
|
131
|
+
/** The nonce from the email step. */
|
|
132
|
+
nonce: string
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Returns whether the challenge digest `expected` is the digest of `nonce`, compared in constant
|
|
138
|
+
* time.
|
|
139
|
+
*/
|
|
140
|
+
export async function matches(options: matches.Options) {
|
|
141
|
+
if (!options.expected) return false
|
|
142
|
+
const received = await digest({ nonce: options.nonce })
|
|
143
|
+
if (received.length !== options.expected.length) return false
|
|
144
|
+
return (crypto.subtle as Subtle).timingSafeEqual(
|
|
145
|
+
Hex.toBytes(received as Hex.Hex).buffer as ArrayBuffer,
|
|
146
|
+
Hex.toBytes(options.expected as Hex.Hex).buffer as ArrayBuffer,
|
|
147
|
+
)
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export declare namespace matches {
|
|
151
|
+
type Options = {
|
|
152
|
+
/** The digest that the challenge stores, or `undefined` for a sign-in challenge. */
|
|
153
|
+
expected: string | undefined
|
|
154
|
+
/** The nonce that the code sign-in sent back. */
|
|
155
|
+
nonce: string
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** Clears the link cookie. */
|
|
160
|
+
export function release(c: Context<Env>) {
|
|
161
|
+
deleteCookie(c, name, { path: '/', prefix, secure: true })
|
|
162
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads the request's session, and forwards the cookie that Better Auth reissues when it extends the
|
|
3
|
+
* session, so the browser keeps the session as long as the database does.
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import type * as Hono from 'hono'
|
|
7
|
+
import type { Env } from '../../internal/Env.js'
|
|
8
|
+
import * as Timing from '../../internal/Timing.js'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Returns the request's session, or `null` without one. Better Auth extends a session that is older
|
|
12
|
+
* than a day, and the extended cookie goes on the response.
|
|
13
|
+
*/
|
|
14
|
+
export async function get(c: get.Context) {
|
|
15
|
+
const result = await Timing.measure(
|
|
16
|
+
c,
|
|
17
|
+
c.var.auth.api.getSession({
|
|
18
|
+
headers: c.req.raw.headers,
|
|
19
|
+
returnHeaders: true,
|
|
20
|
+
}),
|
|
21
|
+
'auth.getSession',
|
|
22
|
+
)
|
|
23
|
+
for (const cookie of result.headers.getSetCookie())
|
|
24
|
+
c.header('set-cookie', cookie, { append: true })
|
|
25
|
+
return result.response
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export declare namespace get {
|
|
29
|
+
/** A context that carries the request's Better Auth instance and timing, such as a page loader's. */
|
|
30
|
+
type Context = Pick<Hono.Context<Env>, 'header' | 'req'> & {
|
|
31
|
+
/** The request's variables. */
|
|
32
|
+
var: Pick<Env['Variables'], 'auth' | 'timing'>
|
|
33
|
+
}
|
|
34
|
+
}
|