@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,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Workers rate limits that the app reads, by binding name. `void.config.ts` and `tempo-id init`
|
|
3
|
+
* declare a binding for each, and `RateLimit` reports each in `RateLimit-Policy`. The module imports
|
|
4
|
+
* nothing, since Void loads `void.config.ts` in Node.
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Each rate limit by its binding name. Each limit counts per Cloudflare location over `period`
|
|
10
|
+
* seconds, and a binding cannot report its own configuration, so the app reads it here.
|
|
11
|
+
*/
|
|
12
|
+
export const limits = {
|
|
13
|
+
/** Account reads per signed-in user, each of which can read every Privy app of the app's realms. */
|
|
14
|
+
ACCOUNT_LIMIT: { limit: 60, namespace: '1007', period: 60 },
|
|
15
|
+
/** Headless authorizations per signed-in user. */
|
|
16
|
+
AUTHORIZE_LIMIT: { limit: 60, namespace: '1001', period: 60 },
|
|
17
|
+
/** Device code requests per IP address. */
|
|
18
|
+
DEVICE_LIMIT: { limit: 10, namespace: '1002', period: 60 },
|
|
19
|
+
/** Code sends per email address. */
|
|
20
|
+
SIGN_IN_CODE_LIMIT: { limit: 5, namespace: '1003', period: 60 },
|
|
21
|
+
/** Code sends, code verifications, and redirects to a provider together, per IP address. */
|
|
22
|
+
SIGN_IN_IP_LIMIT: { limit: 100, namespace: '1004', period: 60 },
|
|
23
|
+
/**
|
|
24
|
+
* Token requests per app with a client secret, counted only once the request's secret matches, so
|
|
25
|
+
* a caller cannot spend another app's quota by naming its client ID.
|
|
26
|
+
*/
|
|
27
|
+
TOKEN_APP_LIMIT: { limit: 600, namespace: '1008', period: 60 },
|
|
28
|
+
/** Token requests per IP address. */
|
|
29
|
+
TOKEN_LIMIT: { limit: 300, namespace: '1006', period: 60 },
|
|
30
|
+
} as const
|
|
31
|
+
|
|
32
|
+
/** A rate limit's binding name, such as `TOKEN_LIMIT`. */
|
|
33
|
+
export type Limit = keyof typeof limits
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The limits that a deployment's Wrangler config can lack, since they came after the config. A
|
|
37
|
+
* missing binding skips such a limit, and fails the request for any other limit.
|
|
38
|
+
*/
|
|
39
|
+
export const optional: readonly Limit[] = ['TOKEN_APP_LIMIT']
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured logs for the Worker. Each entry is one object on the console at its level, which
|
|
3
|
+
* Workers Logs indexes by field. An entry holds a fixed message and chosen fields. It also holds the
|
|
4
|
+
* request's ID, method, and route when a context is given, and an error's name, message, and stack
|
|
5
|
+
* frames. Headers, bodies, query strings, path parameters, and other error properties never reach a
|
|
6
|
+
* log. The Vite dev server prints each entry as one condensed line instead of an object.
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import type { Context } from 'hono'
|
|
10
|
+
import * as LogLine from './LogLine.js'
|
|
11
|
+
|
|
12
|
+
/** What a log entry records. */
|
|
13
|
+
export type Options = {
|
|
14
|
+
/** The error behind the entry. */
|
|
15
|
+
error?: unknown
|
|
16
|
+
/** Extra fields to index, such as an app's client ID. Never secrets, tokens, or personal data. */
|
|
17
|
+
fields?: Record<string, boolean | number | string | undefined> | undefined
|
|
18
|
+
/** A fixed sentence naming what happened. Occurrences group by it, so it never interpolates values. */
|
|
19
|
+
message: string
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Returns whether the module runs on the Vite dev server, which sets `import.meta.env.DEV`. A build
|
|
24
|
+
* replaces the expression, and a runtime without Vite leaves `import.meta.env` undefined.
|
|
25
|
+
*/
|
|
26
|
+
export function dev() {
|
|
27
|
+
return (import.meta as Meta).env?.DEV === true
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Logs an unexpected failure. Pass the context of the request being served, or only the options
|
|
32
|
+
* outside a request, such as in a cron trigger.
|
|
33
|
+
*/
|
|
34
|
+
export function error(c: Context, options: Options): void
|
|
35
|
+
export function error(options: Options): void
|
|
36
|
+
export function error(...parameters: [Context, Options] | [Options]) {
|
|
37
|
+
console.error(print(entry(...parameters), { level: 'error' }))
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Logs a routine event worth keeping, such as a configuration change. Pass the context of the
|
|
42
|
+
* request being served, or only the options outside a request.
|
|
43
|
+
*/
|
|
44
|
+
export function info(c: Context, options: Options): void
|
|
45
|
+
export function info(options: Options): void
|
|
46
|
+
export function info(...parameters: [Context, Options] | [Options]) {
|
|
47
|
+
console.info(print(entry(...parameters), { level: 'info' }))
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Returns the pattern of the first matched route without a wildcard, such as
|
|
52
|
+
* `/v1/device/requests/:code`, which hides path parameters like a user code. A request that no
|
|
53
|
+
* such route matches returns `/*`, since its path is the caller's and can carry a code. Such a
|
|
54
|
+
* request can be a page, a path that no route declares, or a method that a route does not accept.
|
|
55
|
+
*/
|
|
56
|
+
export function route(c: Context) {
|
|
57
|
+
// The `hono/route` helper reads a symbol of its own Hono copy, and the Vite dev server loads Void's
|
|
58
|
+
// Hono as another copy. The request's own getter works with either.
|
|
59
|
+
return (
|
|
60
|
+
c.req.matchedRoutes.find((entry) => !entry.path.includes('*'))?.path ?? '/*'
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Logs a recoverable problem that needs attention but did not fail the request. Pass the context of
|
|
66
|
+
* the request being served, or only the options outside a request.
|
|
67
|
+
*/
|
|
68
|
+
export function warn(c: Context, options: Options): void
|
|
69
|
+
export function warn(options: Options): void
|
|
70
|
+
export function warn(...parameters: [Context, Options] | [Options]) {
|
|
71
|
+
console.warn(print(entry(...parameters), { level: 'warn' }))
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** The part of `import.meta` that Vite fills. */
|
|
75
|
+
type Meta = ImportMeta & {
|
|
76
|
+
/** The variables Vite defines. Absent outside Vite. */
|
|
77
|
+
env?:
|
|
78
|
+
| {
|
|
79
|
+
/** Whether the module runs on the Vite dev server. */
|
|
80
|
+
DEV?: boolean | undefined
|
|
81
|
+
}
|
|
82
|
+
| undefined
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Returns an object without its `undefined` properties. */
|
|
86
|
+
function compact(value: Record<string, unknown>) {
|
|
87
|
+
return Object.fromEntries(
|
|
88
|
+
Object.entries(value).filter((pair) => pair[1] !== undefined),
|
|
89
|
+
)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** The parts of an error that are safe to log, with its causes up to three deep. */
|
|
93
|
+
function describe(
|
|
94
|
+
error: unknown,
|
|
95
|
+
options: describe.Options = { depth: 0 },
|
|
96
|
+
): Record<string, unknown> {
|
|
97
|
+
// A thrown value that is not an `Error` can be anything, including a secret.
|
|
98
|
+
if (!(error instanceof Error)) return { name: 'NonError', type: typeof error }
|
|
99
|
+
|
|
100
|
+
// Viem and ox put request arguments, which can hold ID tokens and proofs, in `message`, and a
|
|
101
|
+
// summary in `shortMessage`. Drizzle puts a failed query's parameters, which can hold an email
|
|
102
|
+
// address or a code, in `message`, and the query alone in `query`. The stack repeats the message,
|
|
103
|
+
// so only its frames are kept.
|
|
104
|
+
const message = (() => {
|
|
105
|
+
const shortMessage = read(error, { key: 'shortMessage' })
|
|
106
|
+
if (typeof shortMessage === 'string') return shortMessage
|
|
107
|
+
const query = read(error, { key: 'query' })
|
|
108
|
+
if (
|
|
109
|
+
typeof query === 'string' &&
|
|
110
|
+
Array.isArray(Reflect.get(error, 'params'))
|
|
111
|
+
)
|
|
112
|
+
return `Failed query: ${query}`
|
|
113
|
+
return error.message
|
|
114
|
+
})()
|
|
115
|
+
const status = read(error, { key: 'status' })
|
|
116
|
+
return compact({
|
|
117
|
+
cause:
|
|
118
|
+
error.cause !== undefined && options.depth < 3
|
|
119
|
+
? describe(error.cause, { depth: options.depth + 1 })
|
|
120
|
+
: undefined,
|
|
121
|
+
code: read(error, { key: 'code' }),
|
|
122
|
+
message,
|
|
123
|
+
name: error.name,
|
|
124
|
+
stack: error.stack
|
|
125
|
+
?.split('\n')
|
|
126
|
+
.filter((line) => /^\s+at /.test(line))
|
|
127
|
+
.map((line) => line.trim())
|
|
128
|
+
.join('\n'),
|
|
129
|
+
status: typeof status === 'number' ? status : undefined,
|
|
130
|
+
})
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
declare namespace describe {
|
|
134
|
+
type Options = {
|
|
135
|
+
/** How many causes deep this error is. */
|
|
136
|
+
depth: number
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** Builds the logged object, leaving out absent fields. */
|
|
141
|
+
function entry(...parameters: [Context, Options] | [Options]) {
|
|
142
|
+
const [c, options] =
|
|
143
|
+
parameters.length === 2 ? parameters : [undefined, parameters[0]]
|
|
144
|
+
const { error, fields, message } = options
|
|
145
|
+
return compact({
|
|
146
|
+
// Fields come first, so they never replace the entry's own keys.
|
|
147
|
+
...fields,
|
|
148
|
+
error: error === undefined ? undefined : describe(error),
|
|
149
|
+
message,
|
|
150
|
+
request: c
|
|
151
|
+
? compact({
|
|
152
|
+
id: c.get('requestId'),
|
|
153
|
+
method: c.req.method,
|
|
154
|
+
path: route(c),
|
|
155
|
+
})
|
|
156
|
+
: undefined,
|
|
157
|
+
})
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Returns the entry as the console receives it. The entry is an object, which Workers Logs indexes
|
|
162
|
+
* by field. On the Vite dev server, it is one condensed line, since that terminal prints objects
|
|
163
|
+
* across many lines.
|
|
164
|
+
*/
|
|
165
|
+
function print(
|
|
166
|
+
value: Record<string, unknown>,
|
|
167
|
+
options: LogLine.format.Options,
|
|
168
|
+
) {
|
|
169
|
+
return dev() ? LogLine.format(value, options) : value
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** Reads an error property when it is a string or number. */
|
|
173
|
+
function read(error: Error, options: { key: string }) {
|
|
174
|
+
const value: unknown = Reflect.get(error, options.key)
|
|
175
|
+
return typeof value === 'string' || typeof value === 'number'
|
|
176
|
+
? value
|
|
177
|
+
: undefined
|
|
178
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prints `Log` entries as condensed lines on the Vite dev server, whose terminal spreads an object
|
|
3
|
+
* across many lines. Deployed Workers and the tests run the production build, which logs objects.
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/** Each level's label and ANSI color in the dev server's lines. */
|
|
8
|
+
const levels = {
|
|
9
|
+
error: { color: 31, label: 'ERROR' },
|
|
10
|
+
info: { color: 32, label: ' INFO' },
|
|
11
|
+
warn: { color: 33, label: ' WARN' },
|
|
12
|
+
} as const
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Flattens nested objects into `[key, value]` pairs with dotted keys, such as `request.id`, in the
|
|
16
|
+
* entry's order.
|
|
17
|
+
*/
|
|
18
|
+
function flatten(
|
|
19
|
+
value: object,
|
|
20
|
+
options: flatten.Options = { prefix: '' },
|
|
21
|
+
): [string, unknown][] {
|
|
22
|
+
return Object.entries(value).flatMap((pair): [string, unknown][] => {
|
|
23
|
+
const key = `${options.prefix}${pair[0]}`
|
|
24
|
+
const item: unknown = pair[1]
|
|
25
|
+
if (typeof item === 'object' && item !== null && !Array.isArray(item))
|
|
26
|
+
return flatten(item, { prefix: `${key}.` })
|
|
27
|
+
return [[key, item]]
|
|
28
|
+
})
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
declare namespace flatten {
|
|
32
|
+
type Options = {
|
|
33
|
+
/** The dotted path of the object being flattened, such as `error.cause.`. */
|
|
34
|
+
prefix: string
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Formats a log entry as one line in the style of Rust's `tracing`: the time, the colored level, the
|
|
40
|
+
* message, then each field as `key=value`. Stack frames follow on indented lines.
|
|
41
|
+
*/
|
|
42
|
+
export function format(
|
|
43
|
+
value: Record<string, unknown>,
|
|
44
|
+
options: format.Options,
|
|
45
|
+
) {
|
|
46
|
+
const { message, ...fields } = value
|
|
47
|
+
const level = levels[options.level]
|
|
48
|
+
const pairs = flatten(fields)
|
|
49
|
+
|
|
50
|
+
const head = [
|
|
51
|
+
`\x1b[2m${new Date().toISOString().slice(11, 23)}\x1b[0m`,
|
|
52
|
+
`\x1b[1;${level.color}m${level.label}\x1b[0m`,
|
|
53
|
+
`\x1b[1m${String(message)}\x1b[0m`,
|
|
54
|
+
...pairs
|
|
55
|
+
.filter((pair) => !pair[0].endsWith('stack'))
|
|
56
|
+
.map(
|
|
57
|
+
(pair) => `\x1b[3m${pair[0]}\x1b[0m\x1b[2m=\x1b[0m${quote(pair[1])}`,
|
|
58
|
+
),
|
|
59
|
+
].join(' ')
|
|
60
|
+
const frames = pairs
|
|
61
|
+
.filter((pair) => pair[0].endsWith('stack'))
|
|
62
|
+
.flatMap((pair) => String(pair[1]).split('\n'))
|
|
63
|
+
// Paths start at `src/` or `node_modules/`, without the checkout or pnpm's store directory.
|
|
64
|
+
.map((frame) =>
|
|
65
|
+
frame
|
|
66
|
+
.replace(
|
|
67
|
+
/\/node_modules\/\.pnpm\/[^/]+\/node_modules\//,
|
|
68
|
+
'/node_modules/',
|
|
69
|
+
)
|
|
70
|
+
.replace(/\((?:\/[^()]*?)?\/((?:node_modules|src)\/[^()]*)\)/, '($1)'),
|
|
71
|
+
)
|
|
72
|
+
.map((frame) => `\x1b[2m ${frame}\x1b[0m`)
|
|
73
|
+
return [head, ...frames].join('\n')
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export declare namespace format {
|
|
77
|
+
type Options = {
|
|
78
|
+
/** The entry's level. */
|
|
79
|
+
level: keyof typeof levels
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Quotes a field's value when it holds whitespace, a quote, or `=`, so each pair stays one token. */
|
|
84
|
+
function quote(value: unknown) {
|
|
85
|
+
const text = String(value)
|
|
86
|
+
return /[\s"=]/.test(text) || text === '' ? JSON.stringify(text) : text
|
|
87
|
+
}
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RP-initiated logout ([OpenID Connect RP-Initiated Logout 1.0](https://openid.net/specs/openid-connect-rpinitiated-1_0.html)):
|
|
3
|
+
* the checks on an app's ID token hint and post-logout redirect URI, and the revocation of the apps'
|
|
4
|
+
* refresh tokens when the session ends. Tempo ID verifies the hint against its own signing keys in
|
|
5
|
+
* process.
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import { symmetricDecrypt, symmetricEncrypt } from 'better-auth/crypto'
|
|
9
|
+
import { and, eq, isNull } from 'drizzle-orm'
|
|
10
|
+
import type { JSONWebKeySet } from 'jose'
|
|
11
|
+
import { compactVerify, createLocalJWKSet } from 'jose'
|
|
12
|
+
import { Hex } from 'ox'
|
|
13
|
+
import * as z from 'zod'
|
|
14
|
+
import * as Schema from '../app/db/schema.js'
|
|
15
|
+
import * as ErrorResponse from './ErrorResponse.js'
|
|
16
|
+
import type * as Realm from './Realm.js'
|
|
17
|
+
|
|
18
|
+
/** How long a sealed logout request stays valid, in seconds. */
|
|
19
|
+
const continuationTtl = 60
|
|
20
|
+
|
|
21
|
+
namespace schema {
|
|
22
|
+
/** The parameters of a logout request that `seal` carries from a form POST to the GET. */
|
|
23
|
+
export const continuation = z.object({
|
|
24
|
+
client_id: z.string().optional(),
|
|
25
|
+
expiresAt: z.number(),
|
|
26
|
+
id_token_hint: z.string(),
|
|
27
|
+
post_logout_redirect_uri: z.string().optional(),
|
|
28
|
+
state: z.string().optional(),
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** The ID token hint is not an ID token that Tempo ID signed for the app. */
|
|
33
|
+
export class HintInvalidError extends ErrorResponse.define(
|
|
34
|
+
'invalid_id_token_hint',
|
|
35
|
+
) {
|
|
36
|
+
override readonly name = 'Logout.HintInvalidError'
|
|
37
|
+
|
|
38
|
+
constructor() {
|
|
39
|
+
super({
|
|
40
|
+
error_description:
|
|
41
|
+
'Invalid id_token_hint: it is not an ID token that this issuer signed for the app. Send the ID token that the app received at sign-in.',
|
|
42
|
+
field: 'id_token_hint',
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** The app that the hint names may not end the session. */
|
|
48
|
+
export class NotPermittedError extends ErrorResponse.define(
|
|
49
|
+
'logout_not_permitted',
|
|
50
|
+
) {
|
|
51
|
+
override readonly name = 'Logout.NotPermittedError'
|
|
52
|
+
|
|
53
|
+
constructor(options: NotPermittedError.Options) {
|
|
54
|
+
super({
|
|
55
|
+
error_description: `Logout not permitted: the app ${options.clientId} may not end the session. Register the app for logout, then retry.`,
|
|
56
|
+
meta: { client_id: options.clientId },
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export declare namespace NotPermittedError {
|
|
62
|
+
type Options = {
|
|
63
|
+
/** The client ID of the app that the hint names. */
|
|
64
|
+
clientId: string
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** The post-logout redirect URI is not one that the app registered. */
|
|
69
|
+
export class RedirectNotPermittedError extends ErrorResponse.define(
|
|
70
|
+
'post_logout_redirect_not_permitted',
|
|
71
|
+
) {
|
|
72
|
+
override readonly name = 'Logout.RedirectNotPermittedError'
|
|
73
|
+
|
|
74
|
+
constructor(options: RedirectNotPermittedError.Options) {
|
|
75
|
+
super({
|
|
76
|
+
error_description: `Invalid post_logout_redirect_uri: ${options.uri} is not registered for the app. Use one of its post-logout redirect URIs, or leave it out.`,
|
|
77
|
+
field: 'post_logout_redirect_uri',
|
|
78
|
+
meta: { post_logout_redirect_uri: options.uri },
|
|
79
|
+
})
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export declare namespace RedirectNotPermittedError {
|
|
84
|
+
type Options = {
|
|
85
|
+
/** The refused post-logout redirect URI. */
|
|
86
|
+
uri: string
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Checks a logout request: the hint's signature, issuer, and app, then the app's registration and the
|
|
92
|
+
* post-logout redirect URI. Returns the session to end and the URI to redirect to, or the refusal.
|
|
93
|
+
*/
|
|
94
|
+
export async function check(
|
|
95
|
+
db: Realm.Database,
|
|
96
|
+
options: check.Options,
|
|
97
|
+
): Promise<check.ReturnType | ErrorResponse.Instance<typeof check.errors>> {
|
|
98
|
+
const hint = await verify(options)
|
|
99
|
+
if (hint instanceof HintInvalidError) return hint
|
|
100
|
+
|
|
101
|
+
const [client] = await db
|
|
102
|
+
.select({
|
|
103
|
+
disabled: Schema.oauthClient.disabled,
|
|
104
|
+
enableEndSession: Schema.oauthClient.enableEndSession,
|
|
105
|
+
postLogoutRedirectUris: Schema.oauthClient.postLogoutRedirectUris,
|
|
106
|
+
})
|
|
107
|
+
.from(Schema.oauthClient)
|
|
108
|
+
.where(eq(Schema.oauthClient.clientId, hint.clientId))
|
|
109
|
+
if (!client || client.disabled || !client.enableEndSession)
|
|
110
|
+
return new NotPermittedError({ clientId: hint.clientId })
|
|
111
|
+
|
|
112
|
+
const redirect = (() => {
|
|
113
|
+
const uri = options.postLogoutRedirectUri
|
|
114
|
+
if (uri === undefined) return undefined
|
|
115
|
+
// RP-Initiated Logout §3 compares the URI exactly, as the authorization endpoint does.
|
|
116
|
+
if (!(client.postLogoutRedirectUris ?? []).includes(uri))
|
|
117
|
+
return new RedirectNotPermittedError({ uri })
|
|
118
|
+
const url = new URL(uri)
|
|
119
|
+
if (options.state !== undefined)
|
|
120
|
+
url.searchParams.set('state', options.state)
|
|
121
|
+
return url.href
|
|
122
|
+
})()
|
|
123
|
+
if (redirect instanceof RedirectNotPermittedError) return redirect
|
|
124
|
+
|
|
125
|
+
return { redirect, sessionId: hint.sessionId }
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export namespace check {
|
|
129
|
+
/** The refusals `check` returns. */
|
|
130
|
+
export const errors = [
|
|
131
|
+
HintInvalidError,
|
|
132
|
+
NotPermittedError,
|
|
133
|
+
RedirectNotPermittedError,
|
|
134
|
+
] as const
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export declare namespace check {
|
|
138
|
+
type Options = verify.Options & {
|
|
139
|
+
/** Where the app asks the browser to go after logout. Absent for no redirect. */
|
|
140
|
+
postLogoutRedirectUri?: string | undefined
|
|
141
|
+
/** The value that the redirect carries back to the app as `state`. */
|
|
142
|
+
state?: string | undefined
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
type ReturnType = {
|
|
146
|
+
/** The post-logout redirect URI with `state`, or absent when the request names none. */
|
|
147
|
+
redirect: string | undefined
|
|
148
|
+
/** The ID of the session that the hint names. */
|
|
149
|
+
sessionId: string
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Throws when the session with `sessionId` still exists. Better Auth's sign-out logs a failed delete
|
|
155
|
+
* and returns as if it succeeded, so logout checks the row before it reports success.
|
|
156
|
+
*/
|
|
157
|
+
export async function assertEnded(
|
|
158
|
+
db: Realm.Database,
|
|
159
|
+
options: assertEnded.Options,
|
|
160
|
+
) {
|
|
161
|
+
const [row] = await db
|
|
162
|
+
.select({ id: Schema.session.id })
|
|
163
|
+
.from(Schema.session)
|
|
164
|
+
.where(eq(Schema.session.id, options.sessionId))
|
|
165
|
+
if (row) throw new Error('The session still exists after sign-out.')
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export declare namespace assertEnded {
|
|
169
|
+
type Options = {
|
|
170
|
+
/** The ID of the session that sign-out ended. */
|
|
171
|
+
sessionId: string
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Encrypts the parameters of a logout request with a key derived from `secret`, for the URL that a
|
|
177
|
+
* form POST continues at. It expires after a minute, and cannot be read or forged without the
|
|
178
|
+
* secret.
|
|
179
|
+
*/
|
|
180
|
+
export async function seal(parameters: seal.Parameters, options: seal.Options) {
|
|
181
|
+
return await symmetricEncrypt({
|
|
182
|
+
data: JSON.stringify(
|
|
183
|
+
schema.continuation.parse({
|
|
184
|
+
...parameters,
|
|
185
|
+
expiresAt: Math.floor(Date.now() / 1000) + continuationTtl,
|
|
186
|
+
}),
|
|
187
|
+
),
|
|
188
|
+
key: await key(options.secret),
|
|
189
|
+
})
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export declare namespace seal {
|
|
193
|
+
type Parameters = Omit<z.input<typeof schema.continuation>, 'expiresAt'>
|
|
194
|
+
|
|
195
|
+
type Options = {
|
|
196
|
+
/** The `SECRET` variable. */
|
|
197
|
+
secret: string
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Decrypts a sealed logout request, and returns its parameters, or `undefined` when it does not
|
|
203
|
+
* decrypt with `secret`, has another shape, or expired.
|
|
204
|
+
*/
|
|
205
|
+
export async function unseal(sealed: string, options: unseal.Options) {
|
|
206
|
+
const value = await symmetricDecrypt({
|
|
207
|
+
data: sealed,
|
|
208
|
+
key: await key(options.secret),
|
|
209
|
+
})
|
|
210
|
+
.then((data) => schema.continuation.safeParse(JSON.parse(data)))
|
|
211
|
+
.catch(() => undefined)
|
|
212
|
+
if (!value?.success) return undefined
|
|
213
|
+
if (value.data.expiresAt <= Date.now() / 1000) return undefined
|
|
214
|
+
return value.data
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export declare namespace unseal {
|
|
218
|
+
type Options = {
|
|
219
|
+
/** The `SECRET` variable. */
|
|
220
|
+
secret: string
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Revokes the refresh tokens that apps received through the session with `sessionId`. Better Auth
|
|
226
|
+
* revokes a session's tokens when it deletes the session, except `offline_access` refresh tokens,
|
|
227
|
+
* which every app requests, so logout ends the apps' access with this first.
|
|
228
|
+
*/
|
|
229
|
+
export async function revoke(db: Realm.Database, options: revoke.Options) {
|
|
230
|
+
await db
|
|
231
|
+
.update(Schema.oauthRefreshToken)
|
|
232
|
+
.set({ revoked: new Date() })
|
|
233
|
+
.where(
|
|
234
|
+
and(
|
|
235
|
+
eq(Schema.oauthRefreshToken.sessionId, options.sessionId),
|
|
236
|
+
isNull(Schema.oauthRefreshToken.revoked),
|
|
237
|
+
),
|
|
238
|
+
)
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export declare namespace revoke {
|
|
242
|
+
type Options = {
|
|
243
|
+
/** The ID of the session that ends. */
|
|
244
|
+
sessionId: string
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Returns the app, session, and user that an ID token hint names, or `HintInvalidError`. The hint
|
|
250
|
+
* may be expired, as RP-Initiated Logout §2 allows, but Tempo ID must have signed it for the app.
|
|
251
|
+
*/
|
|
252
|
+
async function verify(
|
|
253
|
+
options: verify.Options,
|
|
254
|
+
): Promise<verify.ReturnType | HintInvalidError> {
|
|
255
|
+
const { clientId, issuer, jwks } = options
|
|
256
|
+
const payload = await (async () => {
|
|
257
|
+
try {
|
|
258
|
+
const result = await compactVerify(
|
|
259
|
+
options.hint,
|
|
260
|
+
createLocalJWKSet(jwks),
|
|
261
|
+
{ algorithms: ['RS256'] },
|
|
262
|
+
)
|
|
263
|
+
return JSON.parse(new TextDecoder().decode(result.payload)) as unknown
|
|
264
|
+
} catch {
|
|
265
|
+
// A hint that does not verify is the app's mistake, not a failure to log.
|
|
266
|
+
return undefined
|
|
267
|
+
}
|
|
268
|
+
})()
|
|
269
|
+
if (!payload || typeof payload !== 'object') return new HintInvalidError()
|
|
270
|
+
|
|
271
|
+
const claims = payload as Record<string, unknown>
|
|
272
|
+
const audiences = (() => {
|
|
273
|
+
if (typeof claims.aud === 'string') return [claims.aud]
|
|
274
|
+
if (Array.isArray(claims.aud))
|
|
275
|
+
return claims.aud.filter((entry) => typeof entry === 'string')
|
|
276
|
+
return []
|
|
277
|
+
})()
|
|
278
|
+
const app = clientId ?? (audiences.length === 1 ? audiences[0] : undefined)
|
|
279
|
+
if (
|
|
280
|
+
claims.iss !== issuer ||
|
|
281
|
+
!app ||
|
|
282
|
+
!audiences.includes(app) ||
|
|
283
|
+
typeof claims.sid !== 'string' ||
|
|
284
|
+
!claims.sid ||
|
|
285
|
+
typeof claims.sub !== 'string' ||
|
|
286
|
+
!claims.sub
|
|
287
|
+
)
|
|
288
|
+
return new HintInvalidError()
|
|
289
|
+
|
|
290
|
+
return { clientId: app, sessionId: claims.sid, userId: claims.sub }
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
declare namespace verify {
|
|
294
|
+
type Options = {
|
|
295
|
+
/** The client ID that the request names. Absent to read the app from the hint's `aud`. */
|
|
296
|
+
clientId?: string | undefined
|
|
297
|
+
/** The ID token that the app received at sign-in. */
|
|
298
|
+
hint: string
|
|
299
|
+
/** Tempo ID's issuer, every ID token's `iss`. */
|
|
300
|
+
issuer: string
|
|
301
|
+
/** Tempo ID's public signing keys. */
|
|
302
|
+
jwks: JSONWebKeySet
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
type ReturnType = {
|
|
306
|
+
/** The client ID of the app that the hint names. */
|
|
307
|
+
clientId: string
|
|
308
|
+
/** The ID of the session that the hint names. */
|
|
309
|
+
sessionId: string
|
|
310
|
+
/** The ID of the user that the hint names. */
|
|
311
|
+
userId: string
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/** Returns the key that seals logout requests, derived from `secret` for this purpose alone. */
|
|
316
|
+
async function key(secret: string) {
|
|
317
|
+
const encoder = new TextEncoder()
|
|
318
|
+
const material = await crypto.subtle.importKey(
|
|
319
|
+
'raw',
|
|
320
|
+
encoder.encode(secret),
|
|
321
|
+
'HKDF',
|
|
322
|
+
false,
|
|
323
|
+
['deriveBits'],
|
|
324
|
+
)
|
|
325
|
+
const bits = await crypto.subtle.deriveBits(
|
|
326
|
+
{
|
|
327
|
+
hash: 'SHA-256',
|
|
328
|
+
info: encoder.encode('tempo-id:logout-continuation:v1'),
|
|
329
|
+
name: 'HKDF',
|
|
330
|
+
salt: new Uint8Array(),
|
|
331
|
+
},
|
|
332
|
+
material,
|
|
333
|
+
256,
|
|
334
|
+
)
|
|
335
|
+
return Hex.fromBytes(new Uint8Array(bits))
|
|
336
|
+
}
|