@tempoxyz/id 0.0.0-stage → 0.0.0
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 +80 -2
- 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-11GtFGrq.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 +79 -3
- 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,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The balance of a Tempo Account: its holdings of the USD tokens that Viem's token list names on a
|
|
3
|
+
* chain, summed in USD. Viem reads each token's TIP-20 `balanceOf` from the chain's node, in one
|
|
4
|
+
* batched request.
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import type { Context } from 'hono'
|
|
8
|
+
import { Value } from 'ox'
|
|
9
|
+
import {
|
|
10
|
+
BaseError,
|
|
11
|
+
ContractFunctionRevertedError,
|
|
12
|
+
createClient,
|
|
13
|
+
http,
|
|
14
|
+
} from 'viem'
|
|
15
|
+
import { readContract } from 'viem/actions'
|
|
16
|
+
import { Actions } from 'viem/tempo'
|
|
17
|
+
import { z } from 'zod'
|
|
18
|
+
import type { Env } from './Env.js'
|
|
19
|
+
import * as KeyAuthorization from './KeyAuthorization.js'
|
|
20
|
+
import * as Log from './Log.js'
|
|
21
|
+
import * as Timing from './Timing.js'
|
|
22
|
+
|
|
23
|
+
/** The chain is not a Tempo chain, so no token list names its tokens. */
|
|
24
|
+
export class UnknownChainError extends Error {
|
|
25
|
+
override readonly name = 'Balance.UnknownChainError'
|
|
26
|
+
|
|
27
|
+
constructor(options: UnknownChainError.Options) {
|
|
28
|
+
super(`Unknown chain: ${options.chainId}.`)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export declare namespace UnknownChainError {
|
|
33
|
+
type Options = {
|
|
34
|
+
/** The chain's ID. */
|
|
35
|
+
chainId: number
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** How long a read waits for the node, in milliseconds. A slower read fails, and the page continues. */
|
|
40
|
+
const timeout = 3_000
|
|
41
|
+
|
|
42
|
+
export namespace schema {
|
|
43
|
+
/** A balance, as the API returns it. */
|
|
44
|
+
export const balance = z
|
|
45
|
+
.object({
|
|
46
|
+
amount: z.string().meta({
|
|
47
|
+
description: 'The sum in USD, as a decimal string.',
|
|
48
|
+
examples: ['12.5'],
|
|
49
|
+
}),
|
|
50
|
+
currency: z
|
|
51
|
+
.literal('USD')
|
|
52
|
+
.meta({ description: 'The currency of `amount`.' }),
|
|
53
|
+
})
|
|
54
|
+
.meta({
|
|
55
|
+
description: "An account's holdings of USD tokens.",
|
|
56
|
+
id: 'Balance',
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Returns the balance of the account at `address` on the chain with `chainId`, in USD. A token that
|
|
62
|
+
* the chain has not initialized holds nothing. Rejects when the chain is not a Tempo chain, or when
|
|
63
|
+
* the node fails or is slower than 3 seconds.
|
|
64
|
+
*/
|
|
65
|
+
export async function get(options: get.Options): Promise<get.ReturnType> {
|
|
66
|
+
const { address, chainId } = options
|
|
67
|
+
const chain = KeyAuthorization.chains.find((entry) => entry.id === chainId)
|
|
68
|
+
if (!chain) throw new UnknownChainError({ chainId })
|
|
69
|
+
|
|
70
|
+
const client = createClient({
|
|
71
|
+
chain,
|
|
72
|
+
transport: http(options.rpcUrl, { batch: true, retryCount: 0, timeout }),
|
|
73
|
+
})
|
|
74
|
+
const tokens = KeyAuthorization.listings({ chainId }).filter(
|
|
75
|
+
(token) => token.currency === 'USD',
|
|
76
|
+
)
|
|
77
|
+
const amounts = await Promise.all(
|
|
78
|
+
tokens.map(async (token) =>
|
|
79
|
+
readContract(
|
|
80
|
+
client,
|
|
81
|
+
Actions.token.getBalance.call({
|
|
82
|
+
account: address,
|
|
83
|
+
token: token.address,
|
|
84
|
+
}),
|
|
85
|
+
).catch((error: unknown) => {
|
|
86
|
+
if (uninitialized(error)) return 0n
|
|
87
|
+
throw error
|
|
88
|
+
}),
|
|
89
|
+
),
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
// The tokens can differ in decimals, so each amount scales to the largest before they add up.
|
|
93
|
+
const decimals = Math.max(0, ...tokens.map((token) => token.decimals))
|
|
94
|
+
const total = tokens.reduce(
|
|
95
|
+
(sum, token, index) =>
|
|
96
|
+
sum + amounts[index]! * 10n ** BigInt(decimals - token.decimals),
|
|
97
|
+
0n,
|
|
98
|
+
)
|
|
99
|
+
return { amount: Value.format(total, decimals), currency: 'USD' }
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export declare namespace get {
|
|
103
|
+
type Options = {
|
|
104
|
+
/** The account's address. */
|
|
105
|
+
address: `0x${string}`
|
|
106
|
+
/** The ID of the chain to read. */
|
|
107
|
+
chainId: number
|
|
108
|
+
/** The RPC URL that replaces the chain's own, if any. */
|
|
109
|
+
rpcUrl?: string | undefined
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
type ReturnType = {
|
|
113
|
+
/** The sum in USD, as a decimal string, such as `12.5`. */
|
|
114
|
+
amount: string
|
|
115
|
+
/** The currency of `amount`: always `USD`. */
|
|
116
|
+
currency: 'USD'
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** Returns whether `error` is the TIP-20 `Uninitialized` revert of a token that the chain does not hold. */
|
|
121
|
+
function uninitialized(error: unknown) {
|
|
122
|
+
if (!(error instanceof BaseError)) return false
|
|
123
|
+
const reverted = error.walk(
|
|
124
|
+
(cause) => cause instanceof ContractFunctionRevertedError,
|
|
125
|
+
)
|
|
126
|
+
return (
|
|
127
|
+
reverted instanceof ContractFunctionRevertedError &&
|
|
128
|
+
reverted.data?.errorName === 'Uninitialized'
|
|
129
|
+
)
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Returns the balance of each account in `accounts` on the chain with `chainId`, in order, as
|
|
134
|
+
* {@link get} reads it. A failed or slow read logs, and returns `null` for its account.
|
|
135
|
+
*/
|
|
136
|
+
export function list(c: Context<Env>, options: list.Options) {
|
|
137
|
+
const { accounts, chainId, rpcUrl } = options
|
|
138
|
+
return Promise.all(
|
|
139
|
+
accounts.map((account) =>
|
|
140
|
+
Timing.measure(
|
|
141
|
+
c,
|
|
142
|
+
get({ address: account.address, chainId, rpcUrl }),
|
|
143
|
+
'Balance.get',
|
|
144
|
+
).catch((error: unknown) => {
|
|
145
|
+
Log.warn(c, {
|
|
146
|
+
error,
|
|
147
|
+
fields: { chainId },
|
|
148
|
+
message: 'A balance failed to load.',
|
|
149
|
+
})
|
|
150
|
+
return null
|
|
151
|
+
}),
|
|
152
|
+
),
|
|
153
|
+
)
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export declare namespace list {
|
|
157
|
+
type Options = {
|
|
158
|
+
/** The accounts, each by its address. */
|
|
159
|
+
accounts: readonly {
|
|
160
|
+
/** The account's address. */
|
|
161
|
+
address: `0x${string}`
|
|
162
|
+
}[]
|
|
163
|
+
/** The ID of the chain to read. */
|
|
164
|
+
chainId: number
|
|
165
|
+
/** The RPC URL that replaces the chain's own, if any. */
|
|
166
|
+
rpcUrl?: string | undefined
|
|
167
|
+
}
|
|
168
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Caps request bodies before a validator or route reads them, and refuses a larger body with an
|
|
3
|
+
* OAuth error response. The largest legitimate body, an authorization request whose key limits
|
|
4
|
+
* every Tempo token, is under 20 KB, far below the cap.
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import { bodyLimit } from 'hono/body-limit'
|
|
8
|
+
import * as ErrorResponse from './ErrorResponse.js'
|
|
9
|
+
|
|
10
|
+
/** The request body exceeds {@link maxSize}. */
|
|
11
|
+
export class BodyTooLargeError extends ErrorResponse.define('body_too_large') {
|
|
12
|
+
override readonly name = 'BodyLimit.BodyTooLargeError'
|
|
13
|
+
|
|
14
|
+
constructor() {
|
|
15
|
+
super({
|
|
16
|
+
error_description: `Invalid request body: exceeds the ${maxSize}-byte maximum. Send a body of ${maxSize} bytes or fewer.`,
|
|
17
|
+
meta: { maximum: maxSize },
|
|
18
|
+
})
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** The refusals {@link middleware} returns. */
|
|
23
|
+
export const errors = [BodyTooLargeError] as const
|
|
24
|
+
|
|
25
|
+
/** The largest body the API reads, in bytes. */
|
|
26
|
+
export const maxSize = 64 * 1024
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Refuses a body over {@link maxSize} with `body_too_large`. It checks `Content-Length` when the
|
|
30
|
+
* request sends one. Otherwise it counts the streamed bytes as it buffers them for the route, which
|
|
31
|
+
* reads the buffered copy once.
|
|
32
|
+
*/
|
|
33
|
+
export const middleware = bodyLimit({
|
|
34
|
+
maxSize,
|
|
35
|
+
onError: (c) => ErrorResponse.json(c, new BodyTooLargeError()),
|
|
36
|
+
})
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Tempo chains whose balances Tempo ID reads, by the name that the `chain` parameter carries.
|
|
3
|
+
* The pages keep the parameter, so a chosen chain stays as the browser moves between them.
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { tempo, tempoTestnet } from 'viem/tempo/chains'
|
|
7
|
+
import { z } from 'zod'
|
|
8
|
+
|
|
9
|
+
/** Each chain's ID, by its name. */
|
|
10
|
+
export const ids = { mainnet: tempo.id, testnet: tempoTestnet.id } as const
|
|
11
|
+
|
|
12
|
+
/** A chain's name: `mainnet` or `testnet`. */
|
|
13
|
+
export const schema = z.enum(['mainnet', 'testnet'])
|
|
14
|
+
|
|
15
|
+
/** A chain's name: `mainnet` or `testnet`. */
|
|
16
|
+
export type Chain = z.output<typeof schema>
|
|
@@ -0,0 +1,469 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The device grant (RFC 8628) for CLIs, on Better Auth's device plugin. A CLI requests a code, a
|
|
3
|
+
* signed-in user approves it on the device page from any browser, and the CLI polls until it
|
|
4
|
+
* receives tokens. Better Auth holds each code's state in `device_code`, and `device_requests` holds
|
|
5
|
+
* what the CLI reported and the key that it requested, which the page shows. Approval signs the key
|
|
6
|
+
* and holds it in the same row, and the first redemption of the device code takes it.
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import { and, eq, exists, gt, isNull, sql } from 'drizzle-orm'
|
|
10
|
+
import { Hex } from 'ox'
|
|
11
|
+
import * as Schema from '../app/db/schema.js'
|
|
12
|
+
import * as Authorize from './Authorize.js'
|
|
13
|
+
import * as ErrorResponse from './ErrorResponse.js'
|
|
14
|
+
import type * as KeyAuthorization from './KeyAuthorization.js'
|
|
15
|
+
import type * as PendingKey from './PendingKey.js'
|
|
16
|
+
import type * as Realm from './Realm.js'
|
|
17
|
+
|
|
18
|
+
/** The user code was already approved or denied. */
|
|
19
|
+
export class AlreadyDecidedError extends ErrorResponse.define(
|
|
20
|
+
'already_decided',
|
|
21
|
+
) {
|
|
22
|
+
override readonly name = 'Device.AlreadyDecidedError'
|
|
23
|
+
|
|
24
|
+
constructor() {
|
|
25
|
+
super({
|
|
26
|
+
error_description: 'Code already approved or denied.',
|
|
27
|
+
field: 'code',
|
|
28
|
+
})
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** The user did not decide the device code yet. */
|
|
33
|
+
export class ApprovalPendingError extends ErrorResponse.define(
|
|
34
|
+
'approval_pending',
|
|
35
|
+
) {
|
|
36
|
+
override readonly name = 'Device.ApprovalPendingError'
|
|
37
|
+
|
|
38
|
+
constructor() {
|
|
39
|
+
super({
|
|
40
|
+
error_description:
|
|
41
|
+
'Approval pending. Poll again after `interval` seconds.',
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** The device code is unknown, expired, or already redeemed. */
|
|
47
|
+
export class DeviceCodeExpiredError extends ErrorResponse.define(
|
|
48
|
+
'device_code_expired',
|
|
49
|
+
) {
|
|
50
|
+
override readonly name = 'Device.DeviceCodeExpiredError'
|
|
51
|
+
|
|
52
|
+
constructor() {
|
|
53
|
+
super({ error_description: 'Device code expired. Request a new code.' })
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** The device polled before its interval passed. */
|
|
58
|
+
export class PollingTooFastError extends ErrorResponse.define(
|
|
59
|
+
'polling_too_fast',
|
|
60
|
+
) {
|
|
61
|
+
override readonly name = 'Device.PollingTooFastError'
|
|
62
|
+
|
|
63
|
+
constructor() {
|
|
64
|
+
super({
|
|
65
|
+
error_description: 'Polling too fast. Add 5 seconds to `interval`.',
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** The user denied the device code. */
|
|
71
|
+
export class RequestDeniedError extends ErrorResponse.define('request_denied') {
|
|
72
|
+
override readonly name = 'Device.RequestDeniedError'
|
|
73
|
+
|
|
74
|
+
constructor() {
|
|
75
|
+
super({ error_description: 'The user denied the request.' })
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** The user code is wrong or expired. */
|
|
80
|
+
export class UnknownCodeError extends ErrorResponse.define('unknown_code') {
|
|
81
|
+
override readonly name = 'Device.UnknownCodeError'
|
|
82
|
+
|
|
83
|
+
constructor() {
|
|
84
|
+
super({
|
|
85
|
+
error_description:
|
|
86
|
+
'Invalid or expired code. Check the code in the terminal.',
|
|
87
|
+
field: 'code',
|
|
88
|
+
})
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** What the CLI reported with a device code, and the code's state, as the device page shows them. */
|
|
93
|
+
export type Request = {
|
|
94
|
+
/** The message whose EIP-191 hash is the key's witness. Absent for a request without one. */
|
|
95
|
+
challenge?: string | undefined
|
|
96
|
+
/** The client ID of the app that requested the code. */
|
|
97
|
+
clientId: string
|
|
98
|
+
/** When the CLI requested the code. */
|
|
99
|
+
createdAt: Date
|
|
100
|
+
/**
|
|
101
|
+
* The name that the CLI reported, such as its hostname. Absent for a code from `POST /device/code`,
|
|
102
|
+
* which reports none.
|
|
103
|
+
*/
|
|
104
|
+
device?: string | undefined
|
|
105
|
+
/** The ID of the `device_code` row. */
|
|
106
|
+
id: string
|
|
107
|
+
/** The CLI's IP address. Absent when it is unknown. */
|
|
108
|
+
ip?: string | undefined
|
|
109
|
+
/**
|
|
110
|
+
* The key that the CLI requested, with every default filled and the challenge bound as its
|
|
111
|
+
* witness. Absent for a request without a key.
|
|
112
|
+
*/
|
|
113
|
+
key?: KeyAuthorization.Key | undefined
|
|
114
|
+
/** The CLI's city and country, from its IP address. Absent when they are unknown. */
|
|
115
|
+
location?: string | undefined
|
|
116
|
+
/** Whether the user approved or denied the code. `pending` until the user decides. */
|
|
117
|
+
status: 'approved' | 'denied' | 'pending'
|
|
118
|
+
/** The user code, as the pages show it, such as `BCDF-GHJK`. */
|
|
119
|
+
userCode: string
|
|
120
|
+
/** The ID of the user whom the code is bound to, the first to read or decide it. Absent until then. */
|
|
121
|
+
userId?: string | undefined
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* The client ID of the app that a device grant of `/v1/device/authorize` signs in to without a
|
|
126
|
+
* `client_id`. `tempo-id login` uses it.
|
|
127
|
+
*/
|
|
128
|
+
export const clientId = 'tempo-cli'
|
|
129
|
+
|
|
130
|
+
/** The scopes of every device grant of `/v1/device/authorize`. */
|
|
131
|
+
export const scope = 'openid email offline_access'
|
|
132
|
+
|
|
133
|
+
/** Seconds that a device code lasts. */
|
|
134
|
+
export const lifetime = 10 * 60
|
|
135
|
+
|
|
136
|
+
/** Seconds that a CLI waits between polls. */
|
|
137
|
+
export const interval = 5
|
|
138
|
+
|
|
139
|
+
/** Consonants only, so codes spell no words and survive being read aloud. */
|
|
140
|
+
const consonants = 'BCDFGHJKLMNPQRSTVWXZ'
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Returns the client ID of the app that requested the live user code `userCode`, as
|
|
144
|
+
* {@link normalize} returns it, while the code is pending and bound to no user. Returns `undefined`
|
|
145
|
+
* for any other code, so a sign-in that returns to the device page reveals nothing about a code that
|
|
146
|
+
* is unknown, expired, decided, or held. The read binds nothing.
|
|
147
|
+
*/
|
|
148
|
+
export async function client(db: Realm.Database, options: client.Options) {
|
|
149
|
+
const found = await get(db, options)
|
|
150
|
+
if (!found || found.status !== 'pending' || found.userId) return undefined
|
|
151
|
+
return found.clientId
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export declare namespace client {
|
|
155
|
+
type Options = {
|
|
156
|
+
/** The user code, as {@link normalize} returns it. */
|
|
157
|
+
userCode: string
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Stores what the CLI reported with the device code whose row has `id`, and the key that it
|
|
163
|
+
* requested, until the code expires at `expiresAt`.
|
|
164
|
+
*/
|
|
165
|
+
export async function create(db: Realm.Database, options: create.Options) {
|
|
166
|
+
const { challenge, device, expiresAt, id, ip, location } = options
|
|
167
|
+
// The key's bigints are stored as hex quantities, which the request schema parses back.
|
|
168
|
+
const key = options.key
|
|
169
|
+
? (JSON.parse(
|
|
170
|
+
JSON.stringify(options.key, (_, value: unknown) =>
|
|
171
|
+
typeof value === 'bigint' ? Hex.fromNumber(value) : value,
|
|
172
|
+
),
|
|
173
|
+
) as unknown)
|
|
174
|
+
: null
|
|
175
|
+
await db
|
|
176
|
+
.insert(Schema.deviceRequests)
|
|
177
|
+
.values({ challenge, device, expiresAt, id, ip, key, location })
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export declare namespace create {
|
|
181
|
+
type Options = {
|
|
182
|
+
/** The message whose hash becomes the key's witness. Null for a request without one. */
|
|
183
|
+
challenge: string | null
|
|
184
|
+
/** The name that the CLI reported, such as its hostname. Null for a code from `POST /device/code`. */
|
|
185
|
+
device: string | null
|
|
186
|
+
/** When the device code expires. */
|
|
187
|
+
expiresAt: Date
|
|
188
|
+
/** The ID of the device code's `device_code` row. */
|
|
189
|
+
id: string
|
|
190
|
+
/** The CLI's IP address. Null when it is unknown. */
|
|
191
|
+
ip: string | null
|
|
192
|
+
/**
|
|
193
|
+
* The key that the CLI requested, with every default filled, before the challenge is bound.
|
|
194
|
+
* Null for a request without a key.
|
|
195
|
+
*/
|
|
196
|
+
key: KeyAuthorization.Key | null
|
|
197
|
+
/** The CLI's city and country. Null when they are unknown. */
|
|
198
|
+
location: string | null
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Returns `userCode` as the pages show it, in two groups of four, such as `BCDF-GHJK`. Better Auth
|
|
204
|
+
* stores the code without the hyphen.
|
|
205
|
+
*/
|
|
206
|
+
export function format(userCode: string) {
|
|
207
|
+
return `${userCode.slice(0, 4)}-${userCode.slice(4)}`
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Returns the request of the live device code `userCode`, as {@link normalize} returns it, with the
|
|
212
|
+
* code's state. Returns `undefined` for an unknown or expired code.
|
|
213
|
+
*/
|
|
214
|
+
export async function get(
|
|
215
|
+
db: Realm.Database,
|
|
216
|
+
options: get.Options,
|
|
217
|
+
): Promise<Request | undefined> {
|
|
218
|
+
const [row] = await db
|
|
219
|
+
.select({
|
|
220
|
+
challenge: Schema.deviceRequests.challenge,
|
|
221
|
+
clientId: Schema.deviceCode.clientId,
|
|
222
|
+
createdAt: Schema.deviceRequests.createdAt,
|
|
223
|
+
device: Schema.deviceRequests.device,
|
|
224
|
+
expiresAt: Schema.deviceCode.expiresAt,
|
|
225
|
+
id: Schema.deviceCode.id,
|
|
226
|
+
ip: Schema.deviceRequests.ip,
|
|
227
|
+
key: Schema.deviceRequests.key,
|
|
228
|
+
location: Schema.deviceRequests.location,
|
|
229
|
+
status: Schema.deviceCode.status,
|
|
230
|
+
userCode: Schema.deviceCode.userCode,
|
|
231
|
+
userId: Schema.deviceCode.userId,
|
|
232
|
+
})
|
|
233
|
+
.from(Schema.deviceCode)
|
|
234
|
+
.leftJoin(
|
|
235
|
+
Schema.deviceRequests,
|
|
236
|
+
eq(Schema.deviceRequests.id, Schema.deviceCode.id),
|
|
237
|
+
)
|
|
238
|
+
.where(
|
|
239
|
+
and(
|
|
240
|
+
eq(Schema.deviceCode.userCode, options.userCode),
|
|
241
|
+
gt(Schema.deviceCode.expiresAt, new Date()),
|
|
242
|
+
),
|
|
243
|
+
)
|
|
244
|
+
// Better Auth sets the client ID of every code that an app requests.
|
|
245
|
+
if (!row?.clientId) return undefined
|
|
246
|
+
// The stored key passed the same schema when the CLI requested it.
|
|
247
|
+
const key = row.key
|
|
248
|
+
? Authorize.schema.redirect.parse({
|
|
249
|
+
challenge: row.challenge ?? undefined,
|
|
250
|
+
key_authorization: row.key,
|
|
251
|
+
})
|
|
252
|
+
: undefined
|
|
253
|
+
return {
|
|
254
|
+
...(row.challenge ? { challenge: row.challenge } : {}),
|
|
255
|
+
clientId: row.clientId,
|
|
256
|
+
// Tempo ID stores each code's request just after Better Auth issues the code, so a read between
|
|
257
|
+
// the two finds none. Every code lasts `lifetime` seconds.
|
|
258
|
+
createdAt:
|
|
259
|
+
row.createdAt ?? new Date(row.expiresAt.getTime() - lifetime * 1000),
|
|
260
|
+
...(row.device ? { device: row.device } : {}),
|
|
261
|
+
id: row.id,
|
|
262
|
+
...(row.ip ? { ip: row.ip } : {}),
|
|
263
|
+
...(key ? { key } : {}),
|
|
264
|
+
...(row.location ? { location: row.location } : {}),
|
|
265
|
+
status: status(row.status),
|
|
266
|
+
userCode: format(row.userCode),
|
|
267
|
+
...(row.userId ? { userId: row.userId } : {}),
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export declare namespace get {
|
|
272
|
+
type Options = {
|
|
273
|
+
/** The user code, as {@link normalize} returns it. */
|
|
274
|
+
userCode: string
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Holds `key`, which approval signed, in the request of the device code whose row has `id`, until
|
|
280
|
+
* the first redemption of the code takes it. Holds it only while the code is pending, bound to the
|
|
281
|
+
* user with `userId`, and holds no key yet, and returns whether it did. Of concurrent approvals, only
|
|
282
|
+
* the one that holds its key goes on to approve the code.
|
|
283
|
+
*/
|
|
284
|
+
export async function hold(db: Realm.Database, options: hold.Options) {
|
|
285
|
+
const { id, key, userId } = options
|
|
286
|
+
const rows = await db
|
|
287
|
+
.update(Schema.deviceRequests)
|
|
288
|
+
.set({ account: key.account, keyAuthorization: key.keyAuthorization })
|
|
289
|
+
.where(
|
|
290
|
+
and(
|
|
291
|
+
eq(Schema.deviceRequests.id, id),
|
|
292
|
+
isNull(Schema.deviceRequests.keyAuthorization),
|
|
293
|
+
exists(
|
|
294
|
+
db
|
|
295
|
+
.select({ id: Schema.deviceCode.id })
|
|
296
|
+
.from(Schema.deviceCode)
|
|
297
|
+
.where(
|
|
298
|
+
and(
|
|
299
|
+
eq(Schema.deviceCode.id, id),
|
|
300
|
+
eq(Schema.deviceCode.status, 'pending'),
|
|
301
|
+
eq(Schema.deviceCode.userId, userId),
|
|
302
|
+
gt(Schema.deviceCode.expiresAt, new Date()),
|
|
303
|
+
),
|
|
304
|
+
),
|
|
305
|
+
),
|
|
306
|
+
),
|
|
307
|
+
)
|
|
308
|
+
.returning({ id: Schema.deviceRequests.id })
|
|
309
|
+
return rows.length > 0
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
export declare namespace hold {
|
|
313
|
+
type Options = {
|
|
314
|
+
/** The ID of the device code's `device_code` row. */
|
|
315
|
+
id: string
|
|
316
|
+
/** The signed key authorization, and the account that it acts for. */
|
|
317
|
+
key: PendingKey.PendingKey
|
|
318
|
+
/** The ID of the user who approves the code, whom the code must be bound to. */
|
|
319
|
+
userId: string
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Releases `key`, which `hold` held for the device code whose row has `id`, while the code is
|
|
325
|
+
* still pending, so the approving user can approve again after a failed approval. Another
|
|
326
|
+
* approval's key stays.
|
|
327
|
+
*/
|
|
328
|
+
export async function release(db: Realm.Database, options: release.Options) {
|
|
329
|
+
const { id, key } = options
|
|
330
|
+
await db
|
|
331
|
+
.update(Schema.deviceRequests)
|
|
332
|
+
.set({ account: null, keyAuthorization: null })
|
|
333
|
+
.where(
|
|
334
|
+
and(
|
|
335
|
+
eq(Schema.deviceRequests.id, id),
|
|
336
|
+
sql`${Schema.deviceRequests.keyAuthorization} = ${JSON.stringify(key.keyAuthorization)}::jsonb`,
|
|
337
|
+
exists(
|
|
338
|
+
db
|
|
339
|
+
.select({ id: Schema.deviceCode.id })
|
|
340
|
+
.from(Schema.deviceCode)
|
|
341
|
+
.where(
|
|
342
|
+
and(
|
|
343
|
+
eq(Schema.deviceCode.id, id),
|
|
344
|
+
eq(Schema.deviceCode.status, 'pending'),
|
|
345
|
+
),
|
|
346
|
+
),
|
|
347
|
+
),
|
|
348
|
+
),
|
|
349
|
+
)
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
export declare namespace release {
|
|
353
|
+
type Options = {
|
|
354
|
+
/** The ID of the device code's `device_code` row. */
|
|
355
|
+
id: string
|
|
356
|
+
/** The key that `hold` held. */
|
|
357
|
+
key: PendingKey.PendingKey
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Returns the ID of the `device_code` row of `deviceCode`, the CLI's secret code, or `undefined`
|
|
363
|
+
* when no row holds it.
|
|
364
|
+
*/
|
|
365
|
+
export async function id(db: Realm.Database, options: id.Options) {
|
|
366
|
+
const [row] = await db
|
|
367
|
+
.select({ id: Schema.deviceCode.id })
|
|
368
|
+
.from(Schema.deviceCode)
|
|
369
|
+
.where(eq(Schema.deviceCode.deviceCode, options.deviceCode))
|
|
370
|
+
return row?.id
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
export declare namespace id {
|
|
374
|
+
type Options = {
|
|
375
|
+
/** The device code that the CLI holds. */
|
|
376
|
+
deviceCode: string
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Returns what a user typed as a user code, in the form that Better Auth stores: eight consonants in
|
|
382
|
+
* upper case, without the hyphen. Returns `undefined` when the value cannot be a user code.
|
|
383
|
+
*/
|
|
384
|
+
export function normalize(value: string) {
|
|
385
|
+
const characters = value.toUpperCase().replace(/[^A-Z]/g, '')
|
|
386
|
+
if (
|
|
387
|
+
characters.length !== 8 ||
|
|
388
|
+
[...characters].some((character) => !consonants.includes(character))
|
|
389
|
+
)
|
|
390
|
+
return undefined
|
|
391
|
+
return characters
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/** The path of the device page, the verification URI. */
|
|
395
|
+
export const page = '/device'
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* Returns the device page that sign-in returns the browser to, from the `return_to` value `value`:
|
|
399
|
+
* the exact path `/device`, with at most one query parameter, the user code, as `code` or
|
|
400
|
+
* `user_code`. Parses `value` against Tempo ID's own `origin`, and rebuilds the path from the
|
|
401
|
+
* normalized code. Returns `undefined` for any other value, such as another path, host, or scheme, a
|
|
402
|
+
* protocol-relative or backslash form, or another parameter, so sign-in redirects only to the
|
|
403
|
+
* device page.
|
|
404
|
+
*/
|
|
405
|
+
export function returnTo(
|
|
406
|
+
value: string | null | undefined,
|
|
407
|
+
options: returnTo.Options,
|
|
408
|
+
) {
|
|
409
|
+
// Only a path-absolute value names Tempo ID's own page. `//` and `/\` name another host.
|
|
410
|
+
if (!value || !value.startsWith('/') || /^\/[/\\]/.test(value))
|
|
411
|
+
return undefined
|
|
412
|
+
const base = new URL(options.origin)
|
|
413
|
+
const url = URL.parse(value, base)
|
|
414
|
+
if (!url || url.origin !== base.origin || url.pathname !== page || url.hash)
|
|
415
|
+
return undefined
|
|
416
|
+
|
|
417
|
+
const keys = [...url.searchParams.keys()]
|
|
418
|
+
if (keys.length === 0) return page
|
|
419
|
+
const [key] = keys
|
|
420
|
+
if (keys.length > 1 || (key !== 'code' && key !== 'user_code'))
|
|
421
|
+
return undefined
|
|
422
|
+
const userCode = normalize(url.searchParams.get(key) ?? '')
|
|
423
|
+
if (!userCode) return undefined
|
|
424
|
+
return `${page}?${new URLSearchParams({ code: format(userCode) })}`
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
export declare namespace returnTo {
|
|
428
|
+
type Options = {
|
|
429
|
+
/** Tempo ID's origin, such as `https://id.tempo.xyz`, which the path resolves against. */
|
|
430
|
+
origin: string
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* Deletes the request of the device code whose row has `id`, once its redemption issued tokens, and
|
|
436
|
+
* returns the signed key that approval held in it. Returns `undefined` when it holds none, or when
|
|
437
|
+
* another redemption took it.
|
|
438
|
+
*/
|
|
439
|
+
export async function take(
|
|
440
|
+
db: Realm.Database,
|
|
441
|
+
options: take.Options,
|
|
442
|
+
): Promise<PendingKey.PendingKey | undefined> {
|
|
443
|
+
const [row] = await db
|
|
444
|
+
.delete(Schema.deviceRequests)
|
|
445
|
+
.where(eq(Schema.deviceRequests.id, options.id))
|
|
446
|
+
.returning({
|
|
447
|
+
account: Schema.deviceRequests.account,
|
|
448
|
+
keyAuthorization: Schema.deviceRequests.keyAuthorization,
|
|
449
|
+
})
|
|
450
|
+
if (!row?.account || !row.keyAuthorization) return undefined
|
|
451
|
+
return {
|
|
452
|
+
account: row.account as `0x${string}`,
|
|
453
|
+
keyAuthorization:
|
|
454
|
+
row.keyAuthorization as PendingKey.PendingKey['keyAuthorization'],
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
export declare namespace take {
|
|
459
|
+
type Options = {
|
|
460
|
+
/** The ID of the redeemed device code's `device_code` row. */
|
|
461
|
+
id: string
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
/** Returns the state that Better Auth stores in `device_code.status`. */
|
|
466
|
+
function status(value: string): Request['status'] {
|
|
467
|
+
if (value === 'approved' || value === 'denied') return value
|
|
468
|
+
return 'pending'
|
|
469
|
+
}
|