tapimo 0.0.0 → 0.0.1

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.
Files changed (422) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +118 -0
  3. package/dist/ApiKey.d.ts +65 -0
  4. package/dist/ApiKey.d.ts.map +1 -0
  5. package/dist/ApiKey.js +105 -0
  6. package/dist/ApiKey.js.map +1 -0
  7. package/dist/ApiKeySource.d.ts +166 -0
  8. package/dist/ApiKeySource.d.ts.map +1 -0
  9. package/dist/ApiKeySource.js +234 -0
  10. package/dist/ApiKeySource.js.map +1 -0
  11. package/dist/App.d.ts +19317 -0
  12. package/dist/App.d.ts.map +1 -0
  13. package/dist/App.js +612 -0
  14. package/dist/App.js.map +1 -0
  15. package/dist/Assets.d.ts +44 -0
  16. package/dist/Assets.d.ts.map +1 -0
  17. package/dist/Assets.js +23 -0
  18. package/dist/Assets.js.map +1 -0
  19. package/dist/Auth.d.ts +2 -0
  20. package/dist/Auth.d.ts.map +1 -0
  21. package/dist/Auth.js +2 -0
  22. package/dist/Auth.js.map +1 -0
  23. package/dist/Cli.d.ts +21 -0
  24. package/dist/Cli.d.ts.map +1 -0
  25. package/dist/Cli.js +13 -0
  26. package/dist/Cli.js.map +1 -0
  27. package/dist/Client.d.ts +20 -0
  28. package/dist/Client.d.ts.map +1 -0
  29. package/dist/Client.js +24 -0
  30. package/dist/Client.js.map +1 -0
  31. package/dist/Metrics.d.ts +70 -0
  32. package/dist/Metrics.d.ts.map +1 -0
  33. package/dist/Metrics.js +91 -0
  34. package/dist/Metrics.js.map +1 -0
  35. package/dist/Scope.d.ts +35 -0
  36. package/dist/Scope.d.ts.map +1 -0
  37. package/dist/Scope.js +38 -0
  38. package/dist/Scope.js.map +1 -0
  39. package/dist/Webhooks.d.ts +79 -0
  40. package/dist/Webhooks.d.ts.map +1 -0
  41. package/dist/Webhooks.js +107 -0
  42. package/dist/Webhooks.js.map +1 -0
  43. package/dist/admin/Access.d.ts +41 -0
  44. package/dist/admin/Access.d.ts.map +1 -0
  45. package/dist/admin/Access.js +75 -0
  46. package/dist/admin/Access.js.map +1 -0
  47. package/dist/admin/App.d.ts +1221 -0
  48. package/dist/admin/App.d.ts.map +1 -0
  49. package/dist/admin/App.js +113 -0
  50. package/dist/admin/App.js.map +1 -0
  51. package/dist/admin/apps/api-keys.d.ts +209 -0
  52. package/dist/admin/apps/api-keys.d.ts.map +1 -0
  53. package/dist/admin/apps/api-keys.js +129 -0
  54. package/dist/admin/apps/api-keys.js.map +1 -0
  55. package/dist/admin/apps/scopes.d.ts +46 -0
  56. package/dist/admin/apps/scopes.d.ts.map +1 -0
  57. package/dist/admin/apps/scopes.js +41 -0
  58. package/dist/admin/apps/scopes.js.map +1 -0
  59. package/dist/admin/apps/verified-tokens.d.ts +1206 -0
  60. package/dist/admin/apps/verified-tokens.d.ts.map +1 -0
  61. package/dist/admin/apps/verified-tokens.js +485 -0
  62. package/dist/admin/apps/verified-tokens.js.map +1 -0
  63. package/dist/admin/index.d.ts +3 -0
  64. package/dist/admin/index.d.ts.map +1 -0
  65. package/dist/admin/index.js +3 -0
  66. package/dist/admin/index.js.map +1 -0
  67. package/dist/admin/ui.generated.d.ts +11 -0
  68. package/dist/admin/ui.generated.d.ts.map +1 -0
  69. package/dist/admin/ui.generated.js +43 -0
  70. package/dist/admin/ui.generated.js.map +1 -0
  71. package/dist/apps/activities.d.ts +18725 -0
  72. package/dist/apps/activities.d.ts.map +1 -0
  73. package/dist/apps/activities.js +3138 -0
  74. package/dist/apps/activities.js.map +1 -0
  75. package/dist/apps/addresses.d.ts +3662 -0
  76. package/dist/apps/addresses.d.ts.map +1 -0
  77. package/dist/apps/addresses.js +22 -0
  78. package/dist/apps/addresses.js.map +1 -0
  79. package/dist/apps/balances.d.ts +342 -0
  80. package/dist/apps/balances.d.ts.map +1 -0
  81. package/dist/apps/balances.js +393 -0
  82. package/dist/apps/balances.js.map +1 -0
  83. package/dist/apps/blocks.d.ts +931 -0
  84. package/dist/apps/blocks.d.ts.map +1 -0
  85. package/dist/apps/blocks.js +689 -0
  86. package/dist/apps/blocks.js.map +1 -0
  87. package/dist/apps/coingecko.d.ts +1053 -0
  88. package/dist/apps/coingecko.d.ts.map +1 -0
  89. package/dist/apps/coingecko.js +1015 -0
  90. package/dist/apps/coingecko.js.map +1 -0
  91. package/dist/apps/exchanges.d.ts +3000 -0
  92. package/dist/apps/exchanges.d.ts.map +1 -0
  93. package/dist/apps/exchanges.js +3570 -0
  94. package/dist/apps/exchanges.js.map +1 -0
  95. package/dist/apps/fee-amm.d.ts +640 -0
  96. package/dist/apps/fee-amm.d.ts.map +1 -0
  97. package/dist/apps/fee-amm.js +815 -0
  98. package/dist/apps/fee-amm.js.map +1 -0
  99. package/dist/apps/indexer.d.ts +116 -0
  100. package/dist/apps/indexer.d.ts.map +1 -0
  101. package/dist/apps/indexer.js +270 -0
  102. package/dist/apps/indexer.js.map +1 -0
  103. package/dist/apps/receipts.d.ts +1438 -0
  104. package/dist/apps/receipts.d.ts.map +1 -0
  105. package/dist/apps/receipts.js +874 -0
  106. package/dist/apps/receipts.js.map +1 -0
  107. package/dist/apps/rpc.d.ts +173 -0
  108. package/dist/apps/rpc.d.ts.map +1 -0
  109. package/dist/apps/rpc.js +191 -0
  110. package/dist/apps/rpc.js.map +1 -0
  111. package/dist/apps/tokenlist.d.ts +192 -0
  112. package/dist/apps/tokenlist.d.ts.map +1 -0
  113. package/dist/apps/tokenlist.js +153 -0
  114. package/dist/apps/tokenlist.js.map +1 -0
  115. package/dist/apps/tokens.d.ts +2246 -0
  116. package/dist/apps/tokens.d.ts.map +1 -0
  117. package/dist/apps/tokens.js +1789 -0
  118. package/dist/apps/tokens.js.map +1 -0
  119. package/dist/apps/transactions.d.ts +2327 -0
  120. package/dist/apps/transactions.d.ts.map +1 -0
  121. package/dist/apps/transactions.js +975 -0
  122. package/dist/apps/transactions.js.map +1 -0
  123. package/dist/apps/transfers.d.ts +589 -0
  124. package/dist/apps/transfers.d.ts.map +1 -0
  125. package/dist/apps/transfers.js +769 -0
  126. package/dist/apps/transfers.js.map +1 -0
  127. package/dist/apps/verified-tokens.d.ts +544 -0
  128. package/dist/apps/verified-tokens.d.ts.map +1 -0
  129. package/dist/apps/verified-tokens.js +234 -0
  130. package/dist/apps/verified-tokens.js.map +1 -0
  131. package/dist/apps/webhooks.d.ts +7684 -0
  132. package/dist/apps/webhooks.d.ts.map +1 -0
  133. package/dist/apps/webhooks.js +2112 -0
  134. package/dist/apps/webhooks.js.map +1 -0
  135. package/dist/cloudflare.d.ts +32 -0
  136. package/dist/cloudflare.d.ts.map +1 -0
  137. package/dist/cloudflare.js +45 -0
  138. package/dist/cloudflare.js.map +1 -0
  139. package/dist/index.d.ts +16 -0
  140. package/dist/index.d.ts.map +1 -0
  141. package/dist/index.js +16 -0
  142. package/dist/index.js.map +1 -0
  143. package/dist/internal/Auth.d.ts +298 -0
  144. package/dist/internal/Auth.d.ts.map +1 -0
  145. package/dist/internal/Auth.js +613 -0
  146. package/dist/internal/Auth.js.map +1 -0
  147. package/dist/internal/Cache.d.ts +74 -0
  148. package/dist/internal/Cache.d.ts.map +1 -0
  149. package/dist/internal/Cache.js +215 -0
  150. package/dist/internal/Cache.js.map +1 -0
  151. package/dist/internal/Cursor.d.ts +79 -0
  152. package/dist/internal/Cursor.d.ts.map +1 -0
  153. package/dist/internal/Cursor.js +116 -0
  154. package/dist/internal/Cursor.js.map +1 -0
  155. package/dist/internal/EdgeCache.d.ts +59 -0
  156. package/dist/internal/EdgeCache.d.ts.map +1 -0
  157. package/dist/internal/EdgeCache.js +174 -0
  158. package/dist/internal/EdgeCache.js.map +1 -0
  159. package/dist/internal/Log.d.ts +104 -0
  160. package/dist/internal/Log.d.ts.map +1 -0
  161. package/dist/internal/Log.js +118 -0
  162. package/dist/internal/Log.js.map +1 -0
  163. package/dist/internal/MetricSink.d.ts +65 -0
  164. package/dist/internal/MetricSink.d.ts.map +1 -0
  165. package/dist/internal/MetricSink.js +146 -0
  166. package/dist/internal/MetricSink.js.map +1 -0
  167. package/dist/internal/Mpp.d.ts +71 -0
  168. package/dist/internal/Mpp.d.ts.map +1 -0
  169. package/dist/internal/Mpp.js +105 -0
  170. package/dist/internal/Mpp.js.map +1 -0
  171. package/dist/internal/OpenApi.d.ts +313 -0
  172. package/dist/internal/OpenApi.d.ts.map +1 -0
  173. package/dist/internal/OpenApi.fonts.d.ts +2 -0
  174. package/dist/internal/OpenApi.fonts.d.ts.map +1 -0
  175. package/dist/internal/OpenApi.fonts.js +39 -0
  176. package/dist/internal/OpenApi.fonts.js.map +1 -0
  177. package/dist/internal/OpenApi.js +335 -0
  178. package/dist/internal/OpenApi.js.map +1 -0
  179. package/dist/internal/OpenApi.logo.d.ts +6 -0
  180. package/dist/internal/OpenApi.logo.d.ts.map +1 -0
  181. package/dist/internal/OpenApi.logo.js +19 -0
  182. package/dist/internal/OpenApi.logo.js.map +1 -0
  183. package/dist/internal/Path.d.ts +5 -0
  184. package/dist/internal/Path.d.ts.map +1 -0
  185. package/dist/internal/Path.js +16 -0
  186. package/dist/internal/Path.js.map +1 -0
  187. package/dist/internal/RateLimit.d.ts +60 -0
  188. package/dist/internal/RateLimit.d.ts.map +1 -0
  189. package/dist/internal/RateLimit.js +48 -0
  190. package/dist/internal/RateLimit.js.map +1 -0
  191. package/dist/internal/Response.d.ts +132 -0
  192. package/dist/internal/Response.d.ts.map +1 -0
  193. package/dist/internal/Response.js +72 -0
  194. package/dist/internal/Response.js.map +1 -0
  195. package/dist/internal/Schema.d.ts +257 -0
  196. package/dist/internal/Schema.d.ts.map +1 -0
  197. package/dist/internal/Schema.js +360 -0
  198. package/dist/internal/Schema.js.map +1 -0
  199. package/dist/internal/Store.d.ts +204 -0
  200. package/dist/internal/Store.d.ts.map +1 -0
  201. package/dist/internal/Store.js +274 -0
  202. package/dist/internal/Store.js.map +1 -0
  203. package/dist/internal/Tidx.d.ts +120 -0
  204. package/dist/internal/Tidx.d.ts.map +1 -0
  205. package/dist/internal/Tidx.js +156 -0
  206. package/dist/internal/Tidx.js.map +1 -0
  207. package/dist/internal/Timing.d.ts +22 -0
  208. package/dist/internal/Timing.d.ts.map +1 -0
  209. package/dist/internal/Timing.js +32 -0
  210. package/dist/internal/Timing.js.map +1 -0
  211. package/dist/internal/Ttl.d.ts +25 -0
  212. package/dist/internal/Ttl.d.ts.map +1 -0
  213. package/dist/internal/Ttl.js +49 -0
  214. package/dist/internal/Ttl.js.map +1 -0
  215. package/dist/internal/Value.d.ts +47 -0
  216. package/dist/internal/Value.d.ts.map +1 -0
  217. package/dist/internal/Value.js +122 -0
  218. package/dist/internal/Value.js.map +1 -0
  219. package/dist/internal/VerifiedTokens.d.ts +228 -0
  220. package/dist/internal/VerifiedTokens.d.ts.map +1 -0
  221. package/dist/internal/VerifiedTokens.js +450 -0
  222. package/dist/internal/VerifiedTokens.js.map +1 -0
  223. package/dist/internal/Viem.d.ts +2008 -0
  224. package/dist/internal/Viem.d.ts.map +1 -0
  225. package/dist/internal/Viem.js +63 -0
  226. package/dist/internal/Viem.js.map +1 -0
  227. package/dist/internal/WebhookDestination.d.ts +198 -0
  228. package/dist/internal/WebhookDestination.d.ts.map +1 -0
  229. package/dist/internal/WebhookDestination.js +170 -0
  230. package/dist/internal/WebhookDestination.js.map +1 -0
  231. package/dist/internal/Webhooks.d.ts +433 -0
  232. package/dist/internal/Webhooks.d.ts.map +1 -0
  233. package/dist/internal/Webhooks.js +489 -0
  234. package/dist/internal/Webhooks.js.map +1 -0
  235. package/dist/internal/webhookDestinations/betterStack.d.ts +26 -0
  236. package/dist/internal/webhookDestinations/betterStack.d.ts.map +1 -0
  237. package/dist/internal/webhookDestinations/betterStack.js +76 -0
  238. package/dist/internal/webhookDestinations/betterStack.js.map +1 -0
  239. package/dist/internal/webhookDestinations/slack.d.ts +59 -0
  240. package/dist/internal/webhookDestinations/slack.d.ts.map +1 -0
  241. package/dist/internal/webhookDestinations/slack.js +422 -0
  242. package/dist/internal/webhookDestinations/slack.js.map +1 -0
  243. package/dist/internal/webhookDestinations/url.d.ts +17 -0
  244. package/dist/internal/webhookDestinations/url.d.ts.map +1 -0
  245. package/dist/internal/webhookDestinations/url.js +130 -0
  246. package/dist/internal/webhookDestinations/url.js.map +1 -0
  247. package/dist/openrpc.json +5302 -0
  248. package/package.json +46 -4
  249. package/seeds/31318/icons/0x20c0000000000000000000000000000000000000.svg +1 -0
  250. package/seeds/31318/icons/0x20c0000000000000000000000000000000000001.svg +1 -0
  251. package/seeds/31318/icons/0x20c0000000000000000000000000000000000002.svg +1 -0
  252. package/seeds/31318/icons/0x20c0000000000000000000000000000000000003.svg +1 -0
  253. package/seeds/31318/verified-tokens.json +30 -0
  254. package/seeds/4217/icons/0x20c0000000000000000000000000000000000000.svg +25 -0
  255. package/seeds/4217/icons/0x20c000000000000000000000048c8f36df1c9a4a.svg +1 -0
  256. package/seeds/4217/icons/0x20c0000000000000000000000520792dcccccccc.svg +1 -0
  257. package/seeds/4217/icons/0x20c0000000000000000000000a6da882d075a4c3.svg +4 -0
  258. package/seeds/4217/icons/0x20c000000000000000000000111111111e910f0f.svg +30 -0
  259. package/seeds/4217/icons/0x20c00000000000000000000014f22ca97301eb73.svg +1 -0
  260. package/seeds/4217/icons/0x20c0000000000000000000001621e21f71cf12fb.svg +1 -0
  261. package/seeds/4217/icons/0x20c0000000000000000000002f52d5cc21a3207b.svg +1 -0
  262. package/seeds/4217/icons/0x20c0000000000000000000003158081efd85bfc2.svg +11 -0
  263. package/seeds/4217/icons/0x20c0000000000000000000003554d28269e0f3c2.svg +1 -0
  264. package/seeds/4217/icons/0x20c000000000000000000000383a23bacb546ab9.svg +1 -0
  265. package/seeds/4217/icons/0x20c00000000000000000000042109aef2f8b28e1.png +0 -0
  266. package/seeds/4217/icons/0x20c0000000000000000000005c0bac7cef389a11.svg +1 -0
  267. package/seeds/4217/icons/0x20c0000000000000000000006fd9a167923ba194.png +0 -0
  268. package/seeds/4217/icons/0x20c0000000000000000000007f7ba549dd0251b9.svg +1 -0
  269. package/seeds/4217/icons/0x20c0000000000000000000008191667423f70e67.svg +5 -0
  270. package/seeds/4217/icons/0x20c0000000000000000000008ee4fcff88888888.svg +1 -0
  271. package/seeds/4217/icons/0x20c0000000000000000000009a4a4b17e0dc6651.svg +1 -0
  272. package/seeds/4217/icons/0x20c000000000000000000000ab02d39df30bd17e.svg +1 -0
  273. package/seeds/4217/icons/0x20c000000000000000000000ae247a1130450f09.svg +1 -0
  274. package/seeds/4217/icons/0x20c000000000000000000000aeed2ec36a54d0e5.svg +1 -0
  275. package/seeds/4217/icons/0x20c000000000000000000000b9537d11c60e8b50.svg +1 -0
  276. package/seeds/4217/icons/0x20c000000000000000000000bd95bfb69fbe6ce3.svg +1 -0
  277. package/seeds/4217/icons/0x20c000000000000000000000c412ec89d0c08be5.svg +1 -0
  278. package/seeds/4217/icons/0x20c000000000000000000000f047dd7018e50367.png +0 -0
  279. package/seeds/4217/verified-tokens.json +177 -0
  280. package/seeds/42431/icons/0x20c0000000000000000000000000000000000000.svg +25 -0
  281. package/seeds/42431/icons/0x20c0000000000000000000000000000000000001.svg +1 -0
  282. package/seeds/42431/icons/0x20c0000000000000000000000000000000000002.svg +1 -0
  283. package/seeds/42431/icons/0x20c0000000000000000000000000000000000003.svg +1 -0
  284. package/seeds/42431/icons/0x20c0000000000000000000009e8d7eb59b783726.svg +1 -0
  285. package/seeds/42431/icons/0x20c000000000000000000000d72572838bbee59c.svg +1 -0
  286. package/seeds/42431/verified-tokens.json +44 -0
  287. package/seeds/openrpc/README.md +27 -0
  288. package/seeds/openrpc/execution-apis.json +8989 -0
  289. package/src/ApiKey.test.ts +91 -0
  290. package/src/ApiKey.ts +122 -0
  291. package/src/ApiKeySource.test-d.ts +11 -0
  292. package/src/ApiKeySource.test.ts +295 -0
  293. package/src/ApiKeySource.ts +303 -0
  294. package/src/App.test-d.ts +38 -0
  295. package/src/App.test.ts +65927 -0
  296. package/src/App.ts +855 -0
  297. package/src/Assets.ts +58 -0
  298. package/src/Auth.ts +1 -0
  299. package/src/Cli.test.ts +81 -0
  300. package/src/Cli.ts +38 -0
  301. package/src/Client.test-d.ts +1438 -0
  302. package/src/Client.test.ts +134 -0
  303. package/src/Client.ts +45 -0
  304. package/src/Metrics.ts +154 -0
  305. package/src/Scope.ts +50 -0
  306. package/src/Webhooks.test.ts +49 -0
  307. package/src/Webhooks.ts +172 -0
  308. package/src/admin/Access.test.ts +130 -0
  309. package/src/admin/Access.ts +87 -0
  310. package/src/admin/App.test.ts +225 -0
  311. package/src/admin/App.ts +216 -0
  312. package/src/admin/apps/api-keys.test.ts +156 -0
  313. package/src/admin/apps/api-keys.ts +157 -0
  314. package/src/admin/apps/scopes.test.ts +52 -0
  315. package/src/admin/apps/scopes.ts +47 -0
  316. package/src/admin/apps/verified-tokens.test.ts +415 -0
  317. package/src/admin/apps/verified-tokens.ts +566 -0
  318. package/src/admin/index.ts +2 -0
  319. package/src/admin/ui/plugin.ts +135 -0
  320. package/src/admin/ui/src/components/Checkbox.tsx +22 -0
  321. package/src/admin/ui/src/components/Dialog.tsx +32 -0
  322. package/src/admin/ui/src/components/MobileProfile.tsx +31 -0
  323. package/src/admin/ui/src/components/Page.tsx +53 -0
  324. package/src/admin/ui/src/components/TempoLogo.tsx +37 -0
  325. package/src/admin/ui/src/fonts/Pilat-Demi.woff2 +0 -0
  326. package/src/admin/ui/src/fonts/Pilat-Regular.woff2 +0 -0
  327. package/src/admin/ui/src/lib/api-keys.ts +63 -0
  328. package/src/admin/ui/src/lib/client.ts +15 -0
  329. package/src/admin/ui/src/lib/config.ts +57 -0
  330. package/src/admin/ui/src/lib/query-client.ts +26 -0
  331. package/src/admin/ui/src/lib/scopes.ts +25 -0
  332. package/src/admin/ui/src/lib/verified-tokens.ts +89 -0
  333. package/src/admin/ui/src/lib/wagmi.ts +18 -0
  334. package/src/admin/ui/src/routeTree.gen.ts +104 -0
  335. package/src/admin/ui/src/router.tsx +25 -0
  336. package/src/admin/ui/src/routes/__root.tsx +219 -0
  337. package/src/admin/ui/src/routes/api-keys.tsx +329 -0
  338. package/src/admin/ui/src/routes/index.tsx +7 -0
  339. package/src/admin/ui/src/routes/verified-tokens.tsx +331 -0
  340. package/src/admin/ui/src/styles.css +20 -0
  341. package/src/admin/ui/tsconfig.json +16 -0
  342. package/src/admin/ui/vite.config.ts +29 -0
  343. package/src/admin/ui.generated.ts +60 -0
  344. package/src/apps/activities.test.ts +1020 -0
  345. package/src/apps/activities.ts +3934 -0
  346. package/src/apps/addresses.ts +24 -0
  347. package/src/apps/balances.test.ts +274 -0
  348. package/src/apps/balances.ts +533 -0
  349. package/src/apps/blocks.test.ts +385 -0
  350. package/src/apps/blocks.ts +896 -0
  351. package/src/apps/coingecko.test.ts +218 -0
  352. package/src/apps/coingecko.ts +1383 -0
  353. package/src/apps/exchanges.test.ts +958 -0
  354. package/src/apps/exchanges.ts +4773 -0
  355. package/src/apps/fee-amm.test.ts +321 -0
  356. package/src/apps/fee-amm.ts +1121 -0
  357. package/src/apps/indexer.test.ts +153 -0
  358. package/src/apps/indexer.ts +330 -0
  359. package/src/apps/receipts.test.ts +285 -0
  360. package/src/apps/receipts.ts +1193 -0
  361. package/src/apps/rpc.test.ts +302 -0
  362. package/src/apps/rpc.ts +222 -0
  363. package/src/apps/tokenlist.test.ts +80 -0
  364. package/src/apps/tokenlist.ts +207 -0
  365. package/src/apps/tokens.test.ts +1062 -0
  366. package/src/apps/tokens.ts +2292 -0
  367. package/src/apps/transactions.test.ts +408 -0
  368. package/src/apps/transactions.ts +1363 -0
  369. package/src/apps/transfers.test.ts +371 -0
  370. package/src/apps/transfers.ts +1116 -0
  371. package/src/apps/verified-tokens.test.ts +114 -0
  372. package/src/apps/verified-tokens.ts +295 -0
  373. package/src/apps/webhooks.test.ts +1937 -0
  374. package/src/apps/webhooks.ts +2926 -0
  375. package/src/cloudflare.ts +55 -0
  376. package/src/index.ts +15 -0
  377. package/src/internal/Auth.test.ts +922 -0
  378. package/src/internal/Auth.ts +1007 -0
  379. package/src/internal/Cache.test.ts +240 -0
  380. package/src/internal/Cache.ts +262 -0
  381. package/src/internal/Cursor.test.ts +100 -0
  382. package/src/internal/Cursor.ts +149 -0
  383. package/src/internal/EdgeCache.test.ts +234 -0
  384. package/src/internal/EdgeCache.ts +224 -0
  385. package/src/internal/Errors.ts +14 -0
  386. package/src/internal/Log.test.ts +244 -0
  387. package/src/internal/Log.ts +216 -0
  388. package/src/internal/MetricSink.ts +220 -0
  389. package/src/internal/Mpp.test.ts +64 -0
  390. package/src/internal/Mpp.ts +141 -0
  391. package/src/internal/OpenApi.fonts.ts +38 -0
  392. package/src/internal/OpenApi.logo.ts +18 -0
  393. package/src/internal/OpenApi.ts +488 -0
  394. package/src/internal/Path.test.ts +14 -0
  395. package/src/internal/Path.ts +15 -0
  396. package/src/internal/RateLimit.test.ts +93 -0
  397. package/src/internal/RateLimit.ts +93 -0
  398. package/src/internal/Response.ts +131 -0
  399. package/src/internal/Schema.test.ts +34 -0
  400. package/src/internal/Schema.ts +523 -0
  401. package/src/internal/Store.test.ts +461 -0
  402. package/src/internal/Store.ts +507 -0
  403. package/src/internal/Tidx.local.test.ts +33 -0
  404. package/src/internal/Tidx.test.ts +294 -0
  405. package/src/internal/Tidx.ts +238 -0
  406. package/src/internal/Timing.test.ts +22 -0
  407. package/src/internal/Timing.ts +62 -0
  408. package/src/internal/Ttl.test.ts +18 -0
  409. package/src/internal/Ttl.ts +59 -0
  410. package/src/internal/Value.ts +114 -0
  411. package/src/internal/VerifiedTokens.test.ts +333 -0
  412. package/src/internal/VerifiedTokens.ts +645 -0
  413. package/src/internal/Viem.test.ts +115 -0
  414. package/src/internal/Viem.ts +164 -0
  415. package/src/internal/WebhookDestination.test.ts +648 -0
  416. package/src/internal/WebhookDestination.ts +331 -0
  417. package/src/internal/Webhooks.test.ts +668 -0
  418. package/src/internal/Webhooks.ts +940 -0
  419. package/src/internal/webhookDestinations/betterStack.ts +91 -0
  420. package/src/internal/webhookDestinations/slack.ts +496 -0
  421. package/src/internal/webhookDestinations/url.ts +128 -0
  422. package/src/openrpc.json +5302 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025-present
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,118 @@
1
+ # Tempo API
2
+
3
+ ## Overview
4
+
5
+ The Tempo API is Tempo's next-generation data API. It is designed for
6
+ clients that need a high-level surface for exploring the Tempo chain.
7
+
8
+ ## Usage
9
+
10
+ The Tempo API is a composable [Hono](https://hono.dev) app. You can run your own
11
+ instance (**Self-hosted**) or call the hosted API directly (**Hosted**).
12
+
13
+ ### Hosted
14
+
15
+ Call the hosted Tempo API directly at `https://api.tempo.xyz`:
16
+
17
+ ```sh
18
+ curl https://api.tempo.xyz/v1/tokens
19
+ ```
20
+
21
+ ```ts
22
+ const response = await fetch('https://api.tempo.xyz/v1/tokens/0x…')
23
+ const token = await response.json()
24
+ ```
25
+
26
+ Explore the API interactively at the root [`/`](https://api.tempo.xyz).
27
+
28
+ ### Self-hosted
29
+
30
+ Install the package:
31
+
32
+ ```sh
33
+ pnpm i tapimo
34
+ ```
35
+
36
+ Compose an app with `App.create`. It returns a handler with a Web `fetch`
37
+ method and a Node.js `listener`, so you can serve it from any runtime or
38
+ framework:
39
+
40
+ <!-- prettier-ignore -->
41
+ ```ts
42
+ import { App } from 'tapimo'
43
+
44
+ const handler = App.create()
45
+
46
+ createServer(handler.listener) // Node.js
47
+ Bun.serve({ fetch: handler.fetch }) // Bun
48
+ Deno.serve({ fetch: handler.fetch }) // Deno
49
+ app.all('*', (c) => handler.fetch(c.request)) // Elysia
50
+ app.use(handler.listener) // Express
51
+ app.use((c) => handler.fetch(c.req.raw)) // Hono
52
+ export const GET = handler.fetch // Next.js
53
+ export const POST = handler.fetch // Next.js
54
+ ```
55
+
56
+ ## Typed Client
57
+
58
+ Use the typed client for endpoint autocomplete and API-key/header configuration:
59
+
60
+ ```ts twoslash
61
+ import { Client } from 'tapimo'
62
+
63
+ const client = Client.create({
64
+ // API key sugar for the canonical `tempo-api-key` header.
65
+ apiKey: 'tempo_api_key',
66
+ // Override the API URL. Defaults to `Client.defaultUrl`.
67
+ url: 'https://api.tempo.xyz',
68
+ // Or pass custom headers directly.
69
+ headers: { authorization: 'Bearer tempo_api_key' },
70
+ })
71
+ ```
72
+
73
+ Requests are end-to-end type-safe across params, statuses, response bodies, and errors. For example, `GET /v1/tokens/:token`:
74
+
75
+ ```ts twoslash
76
+ const response = await client.v1.tokens[':token'].$get({
77
+ param: { token: '0x20c0000000000000000000000000000000000000' },
78
+ })
79
+
80
+ // Narrow responses by status
81
+ if (response.status !== 200) {
82
+ response.status
83
+ // ^? (property) status: 400 | 401 | 402 | 403 | 404 | 429 | 502
84
+
85
+ if (response.status === 404) {
86
+ const json = await response.json()
87
+ // ^? const json: { error: { code: "token_not_found"; message: string; ... }; requestId: string }
88
+ json.error.code
89
+ // ^? (property) code: "token_not_found"
90
+ } else if (response.status === 402) {
91
+ const challenge = await response.text()
92
+ // ^? const challenge: string
93
+ // Handle the payment challenge from `WWW-Authenticate`.
94
+ } else {
95
+ const json = await response.json()
96
+ // ^? const json: { error: { code: "query_invalid" | "api_key_invalid" | "upstream_error" | ...; ... }; requestId: string }
97
+ // Handle validation, auth, rate-limit, or upstream errors.
98
+ }
99
+
100
+ throw new Error('Request failed')
101
+ }
102
+
103
+ response.status
104
+ // ^? (property) status: 200
105
+ const token = await response.json()
106
+ // ^? const token: { address: Hex.Hex; currency: string; decimals: number; name: string; ... }
107
+ token.symbol
108
+ // ^? (property) symbol: string
109
+ ```
110
+
111
+ ## Development
112
+
113
+ ```sh
114
+ pnpm install # Install dependencies
115
+ pnpm test # Run tests
116
+ pnpm app:dev # Seed local KV (verified tokens) + run API app
117
+ pnpm app:seed # Seed local KV with curated verified tokens from seeds/
118
+ ```
@@ -0,0 +1,65 @@
1
+ /**
2
+ * The resolved API-key resource and the reusable credential primitives every
3
+ * source backend shares.
4
+ *
5
+ * Holds the resolved {@link ApiKey} type and its {@link schema}, the token
6
+ * format/generation ({@link generateToken}/{@link generateId}), the storage-key
7
+ * derivation ({@link keyFor}/{@link recordPrefix}), and log {@link redact}ion.
8
+ * These live here — not in a single source — so every `ApiKeySource` backend
9
+ * (the built-in store, a future D1/Postgres source) issues and parses
10
+ * byte-identical credentials and cannot drift. The persisted record/mint-input
11
+ * shapes and provisioning (mint/list/revoke) belong to the
12
+ * `ApiKeySource.Source` contract, which composes these primitives with its own
13
+ * persistence.
14
+ */
15
+ import * as z from 'zod/mini';
16
+ /** Zod schemas owned by the API-key module. */
17
+ export declare namespace schema {
18
+ /**
19
+ * Canonical schema for resolved API-key metadata, and the single source of
20
+ * truth for the {@link ApiKey} type. `ApiKeySource` derives its persisted
21
+ * `Record` and `MintInput` schemas from this one, so the resolved and
22
+ * persisted shapes cannot drift.
23
+ */
24
+ const ApiKey: z.ZodMiniObject<{
25
+ environment: z.ZodMiniDefault<z.ZodMiniEnum<{
26
+ production: "production";
27
+ sandbox: "sandbox";
28
+ }>>;
29
+ id: z.ZodMiniString<string>;
30
+ name: z.ZodMiniOptional<z.ZodMiniString<string>>;
31
+ orgId: z.ZodMiniString<string>;
32
+ rateLimits: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniObject<{
33
+ perMinute: z.ZodMiniNumber<number>;
34
+ }, z.core.$strip>>>;
35
+ scopes: z.ZodMiniReadonly<z.ZodMiniArray<z.ZodMiniEnum<{
36
+ "*": "*";
37
+ "data:read": "data:read";
38
+ "indexer:query": "indexer:query";
39
+ "webhooks:read": "webhooks:read";
40
+ "webhooks:write": "webhooks:write";
41
+ }>>>;
42
+ }, z.core.$strip>;
43
+ }
44
+ /** API-key metadata resolved by an auth source. */
45
+ export type ApiKey = z.output<typeof schema.ApiKey>;
46
+ /**
47
+ * Replaces every issued token in a string with a masked placeholder so secrets
48
+ * never reach logs. Apply to anything that may embed a credential — error
49
+ * stacks, request dumps, and the values of the `tempo-api-key` and
50
+ * `Authorization` headers (whose tokens match the issued-token pattern).
51
+ */
52
+ export declare function redact(text: string): string;
53
+ /**
54
+ * Generates a new plaintext token (environment prefix + 48 lowercase hex chars
55
+ * / 192 bits). Shared by every source backend so issued tokens are
56
+ * format-identical.
57
+ */
58
+ export declare function generateToken(environment?: ApiKey['environment']): string;
59
+ /** Generates a stable, opaque key id (`key_…`). */
60
+ export declare function generateId(): string;
61
+ /** Storage-key prefix under which key records are persisted, keyed by token hash. */
62
+ export declare const recordPrefix = "apikey:";
63
+ /** Storage key under which the record for a plaintext token is persisted. */
64
+ export declare function keyFor(token: string): string;
65
+ //# sourceMappingURL=ApiKey.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApiKey.d.ts","sourceRoot":"","sources":["../src/ApiKey.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,KAAK,CAAC,MAAM,UAAU,CAAA;AAK7B,+CAA+C;AAC/C,yBAAiB,MAAM,CAAC;IACtB;;;;;OAKG;IACI,MAAM,MAAM;;;;;;;;;;;;;;;;;;qBAiBjB,CAAA;CACH;AAED,mDAAmD;AACnD,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,MAAM,CAAC,MAAM,CAAC,CAAA;AAEnD;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAI3C;AAiCD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,WAAW,GAAE,MAAM,CAAC,aAAa,CAAgB,GAAG,MAAM,CAEvF;AAED,mDAAmD;AACnD,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAED,qFAAqF;AACrF,eAAO,MAAM,YAAY,YAAY,CAAA;AAOrC,6EAA6E;AAC7E,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE5C"}
package/dist/ApiKey.js ADDED
@@ -0,0 +1,105 @@
1
+ /**
2
+ * The resolved API-key resource and the reusable credential primitives every
3
+ * source backend shares.
4
+ *
5
+ * Holds the resolved {@link ApiKey} type and its {@link schema}, the token
6
+ * format/generation ({@link generateToken}/{@link generateId}), the storage-key
7
+ * derivation ({@link keyFor}/{@link recordPrefix}), and log {@link redact}ion.
8
+ * These live here — not in a single source — so every `ApiKeySource` backend
9
+ * (the built-in store, a future D1/Postgres source) issues and parses
10
+ * byte-identical credentials and cannot drift. The persisted record/mint-input
11
+ * shapes and provisioning (mint/list/revoke) belong to the
12
+ * `ApiKeySource.Source` contract, which composes these primitives with its own
13
+ * persistence.
14
+ */
15
+ import { nanoid } from 'nanoid';
16
+ import { Hash, Hex } from 'ox';
17
+ import * as z from 'zod/mini';
18
+ import * as RateLimit from './internal/RateLimit.js';
19
+ import * as Scope from './Scope.js';
20
+ /** Zod schemas owned by the API-key module. */
21
+ export var schema;
22
+ (function (schema) {
23
+ /**
24
+ * Canonical schema for resolved API-key metadata, and the single source of
25
+ * truth for the {@link ApiKey} type. `ApiKeySource` derives its persisted
26
+ * `Record` and `MintInput` schemas from this one, so the resolved and
27
+ * persisted shapes cannot drift.
28
+ */
29
+ schema.ApiKey = z.object({
30
+ environment: z
31
+ ._default(z.enum(['production', 'sandbox']), 'production')
32
+ .check(z.describe('Key environment.')),
33
+ id: z.string().check(z.describe('Stable key id.')),
34
+ name: z.optional(z.string()).check(z.describe('Human-readable key name.')),
35
+ orgId: z.string().check(z.describe('Owning organization id.')),
36
+ rateLimits: z
37
+ .optional(z.record(z.string(), RateLimit.schema.Limit))
38
+ .check(z.describe("Per-key quota overrides keyed by quota scope. The reserved '*' entry is the per-key default; any other key overrides that scope. Omit to inherit server config. The most specific match wins.")),
39
+ scopes: z
40
+ .readonly(z.array(z.enum([...Scope.catalog.map((entry) => entry.scope), Scope.wildcard])))
41
+ .check(z.describe("Granted scopes. '*' grants all scopes.")),
42
+ });
43
+ })(schema || (schema = {}));
44
+ /**
45
+ * Replaces every issued token in a string with a masked placeholder so secrets
46
+ * never reach logs. Apply to anything that may embed a credential — error
47
+ * stacks, request dumps, and the values of the `tempo-api-key` and
48
+ * `Authorization` headers (whose tokens match the issued-token pattern).
49
+ */
50
+ export function redact(text) {
51
+ return text
52
+ .replace(tokenPattern(), (match) => `${match.split('sk:')[0]}sk:…`)
53
+ .replace(legacyTokenPattern(), 'tempo_…');
54
+ }
55
+ /**
56
+ * Token prefix per environment. The prefix encodes the environment so a leaked
57
+ * sandbox token is visibly distinct from a production one; otherwise there is a
58
+ * single token kind. Prefixes exist purely for recognizability and leak
59
+ * detection (CI secret scanning, log redaction — see {@link redact}).
60
+ */
61
+ const tokenPrefix = {
62
+ production: 'tempo:sk:',
63
+ sandbox: 'tempo_sandbox:sk:',
64
+ };
65
+ /**
66
+ * Greppable pattern matching an issued token (`tempo:sk:`/`tempo_sandbox:sk:` +
67
+ * 48–64 lowercase hex chars), suitable for CI secret scanning and log
68
+ * redaction. A fresh instance is returned on each call so callers never share
69
+ * `lastIndex` state.
70
+ */
71
+ function tokenPattern() {
72
+ return /tempo(_sandbox)?:sk:[a-f0-9]{48,64}/g;
73
+ }
74
+ /**
75
+ * Greppable pattern matching a deprecated v1 token (`tempo_` + 40 lowercase hex
76
+ * chars), kept so legacy credentials are redacted from logs with the same
77
+ * guarantees as current tokens. A fresh instance is returned on each call so
78
+ * callers never share `lastIndex` state.
79
+ */
80
+ function legacyTokenPattern() {
81
+ return /tempo_[a-f0-9]{40}/g;
82
+ }
83
+ /**
84
+ * Generates a new plaintext token (environment prefix + 48 lowercase hex chars
85
+ * / 192 bits). Shared by every source backend so issued tokens are
86
+ * format-identical.
87
+ */
88
+ export function generateToken(environment = 'production') {
89
+ return `${tokenPrefix[environment]}${Hex.random(24).slice(2)}`;
90
+ }
91
+ /** Generates a stable, opaque key id (`key_…`). */
92
+ export function generateId() {
93
+ return `key_${nanoid()}`;
94
+ }
95
+ /** Storage-key prefix under which key records are persisted, keyed by token hash. */
96
+ export const recordPrefix = 'apikey:';
97
+ /** Hashes a plaintext token to its at-rest lookup hash (lowercase hex, no `0x`). */
98
+ function hash(token) {
99
+ return Hash.sha256(Hex.fromString(token)).slice(2);
100
+ }
101
+ /** Storage key under which the record for a plaintext token is persisted. */
102
+ export function keyFor(token) {
103
+ return `${recordPrefix}${hash(token)}`;
104
+ }
105
+ //# sourceMappingURL=ApiKey.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApiKey.js","sourceRoot":"","sources":["../src/ApiKey.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,IAAI,CAAA;AAC9B,OAAO,KAAK,CAAC,MAAM,UAAU,CAAA;AAE7B,OAAO,KAAK,SAAS,MAAM,yBAAyB,CAAA;AACpD,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AAEnC,+CAA+C;A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4
+ * Every backend implements one shared contract ({@link Source}) covering both
5
+ * the read path ({@link Source.resolve}, wired into `Auth.middleware`'s
6
+ * `apiKey.source`) and the provisioning path ({@link Source.mint}/{@link
7
+ * Source.list}/{@link Source.revoke}), so backends are interchangeable wherever a
8
+ * source is accepted. {@link store} is the built-in store-backed source (e.g. a
9
+ * Cloudflare KV namespace); {@link from} type-checks a bring-your-own backend
10
+ * (D1, Postgres, …) against the contract. The persisted {@link Record}/{@link
11
+ * MintInput} shapes live here (derived from `ApiKey.schema` so they cannot drift
12
+ * from the resolved shape), while the shared credential primitives (token
13
+ * format/generation, storage-key derivation, redaction) live in `./ApiKey.js`.
14
+ */
15
+ import * as z from 'zod/mini';
16
+ import * as ApiKey from './ApiKey.js';
17
+ import type * as Store from './internal/Store.js';
18
+ /** Zod schemas owned by the API-key source module. */
19
+ export declare namespace schema {
20
+ /**
21
+ * Fields accepted when minting a key, and the single source of truth for the
22
+ * {@link MintInput} type and `mint` validation. Derived from the resolved
23
+ * `ApiKey.schema` (minus the generated `id`) so the scope vocabulary stays in
24
+ * lockstep with the resolved shape.
25
+ */
26
+ const MintInput: z.ZodMiniObject<{
27
+ environment: z.ZodMiniDefault<z.ZodMiniEnum<{
28
+ production: "production";
29
+ sandbox: "sandbox";
30
+ }>>;
31
+ name: z.ZodMiniOptional<z.ZodMiniString<string>>;
32
+ rateLimits: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniObject<{
33
+ perMinute: z.ZodMiniNumber<number>;
34
+ }, z.core.$strip>>>;
35
+ scopes: z.ZodMiniReadonly<z.ZodMiniArray<z.ZodMiniEnum<{
36
+ "*": "*";
37
+ "data:read": "data:read";
38
+ "indexer:query": "indexer:query";
39
+ "webhooks:read": "webhooks:read";
40
+ "webhooks:write": "webhooks:write";
41
+ }>>>;
42
+ createdBy: z.ZodMiniOptional<z.ZodMiniString<string>>;
43
+ expiresAt: z.ZodMiniOptional<z.ZodMiniString<string>>;
44
+ orgId: z.ZodMiniOptional<z.ZodMiniString<string>>;
45
+ }, z.core.$strip>;
46
+ /**
47
+ * A persisted API-key record: the resolved `ApiKey.schema` plus
48
+ * persistence/display fields. Extending the resolved schema keeps the resolved
49
+ * and persisted shapes in lockstep.
50
+ */
51
+ const Record: z.ZodMiniObject<{
52
+ environment: z.ZodMiniDefault<z.ZodMiniEnum<{
53
+ production: "production";
54
+ sandbox: "sandbox";
55
+ }>>;
56
+ id: z.ZodMiniString<string>;
57
+ name: z.ZodMiniOptional<z.ZodMiniString<string>>;
58
+ orgId: z.ZodMiniString<string>;
59
+ rateLimits: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniObject<{
60
+ perMinute: z.ZodMiniNumber<number>;
61
+ }, z.core.$strip>>>;
62
+ scopes: z.ZodMiniReadonly<z.ZodMiniArray<z.ZodMiniEnum<{
63
+ "*": "*";
64
+ "data:read": "data:read";
65
+ "indexer:query": "indexer:query";
66
+ "webhooks:read": "webhooks:read";
67
+ "webhooks:write": "webhooks:write";
68
+ }>>>;
69
+ createdAt: z.ZodMiniString<string>;
70
+ createdBy: z.ZodMiniOptional<z.ZodMiniString<string>>;
71
+ expiresAt: z.ZodMiniOptional<z.ZodMiniString<string>>;
72
+ tokenLast4: z.ZodMiniString<string>;
73
+ }, z.core.$strip>;
74
+ }
75
+ /**
76
+ * A durable API-key record as persisted by a source. A superset of the resolved
77
+ * `ApiKey.ApiKey` with provisioning/display metadata. The plaintext token is
78
+ * never stored — records are keyed by its hash (`ApiKey.keyFor`) and carry only
79
+ * `tokenLast4` for display.
80
+ */
81
+ export type Record = z.output<typeof schema.Record>;
82
+ /**
83
+ * Fields accepted when minting a key via {@link Source.mint}. Uses the schema's
84
+ * *input* type so defaulted fields (e.g. `environment`) are optional for callers
85
+ * — the default is applied during `mint`'s validation.
86
+ */
87
+ export type MintInput = z.input<typeof schema.MintInput>;
88
+ /** Result of {@link Source.mint}: the persisted record and its one-time token. */
89
+ export type MintResult = {
90
+ /** The persisted key record (metadata only — never the token). */
91
+ record: Record;
92
+ /** The plaintext token, shown once and unrecoverable afterward. */
93
+ token: string;
94
+ };
95
+ /** Options for {@link Source.list}. */
96
+ export type ListOptions = {
97
+ /** Restrict results to keys owned by this organization. */
98
+ orgId?: string | undefined;
99
+ };
100
+ /**
101
+ * The contract every pluggable API-key source implements — both the read path
102
+ * ({@link Source.resolve}, used by `Auth.middleware`'s `apiKey.source`) and the
103
+ * provisioning path ({@link Source.mint}/{@link Source.list}/{@link
104
+ * Source.revoke}). {@link store} is the built-in store-backed source; future
105
+ * database-backed sources (D1, Postgres, …) implement this same contract, so any
106
+ * backend stays interchangeable wherever a source is accepted.
107
+ */
108
+ export type Source = {
109
+ /** Lists key records (metadata only — never tokens), newest first. */
110
+ list(options?: ListOptions): Promise<readonly Record[]>;
111
+ /**
112
+ * Mints a key: persists its hashed record and returns the record plus the
113
+ * one-time plaintext token (shown once, unrecoverable afterward).
114
+ */
115
+ mint(input: MintInput): Promise<MintResult>;
116
+ /** Resolves a plaintext API key token to its metadata, or `null`. */
117
+ resolve(token: string): Promise<ApiKey.ApiKey | null>;
118
+ /** Revokes a key by id. Returns whether a matching record was deleted. */
119
+ revoke(id: string): Promise<boolean>;
120
+ };
121
+ /**
122
+ * Creates a {@link Source} from a value, type-checking it against the contract.
123
+ * The escape hatch for bringing your own backend (D1, Postgres, …): author the
124
+ * implementation inline and have it validated against {@link Source}.
125
+ */
126
+ export declare function from<const source extends Source>(source: source): source;
127
+ /**
128
+ * The default {@link Source} when none is configured: it resolves every token to
129
+ * `null` and lists nothing, so API-key access stays closed until a real source
130
+ * (e.g. {@link store}) is wired in. Its provisioning methods are inert —
131
+ * {@link Source.list} returns `[]`, {@link Source.revoke} returns `false`, and
132
+ * {@link Source.mint} throws, since there is nowhere to persist a key.
133
+ */
134
+ export declare const noop: Source;
135
+ /**
136
+ * Creates a store-backed {@link Source} over a {@link Store.State}. Records are
137
+ * persisted keyed by token hash (`ApiKey.keyFor`) and validated against the
138
+ * scope catalog on read; unknown, corrupt, expired, or invalid records resolve
139
+ * to `null`. An `id → recordKey` index makes revoke-by-id O(1).
140
+ */
141
+ export declare function store(state: Store.State): Source;
142
+ /**
143
+ * Wraps a source with a short-TTL in-memory cache on the resolve path, so hot
144
+ * keys skip the backend read (e.g. a KV `get`) on every request. Positive
145
+ * results cache for `ttl` (default 60s), negative for `negativeTtl` (default
146
+ * 10s) so a freshly minted key is usable quickly; concurrent misses for one
147
+ * token are single-flighted. Entries are keyed by the token's storage-key
148
+ * derivation (`ApiKey.keyFor`, a sha256) — never the plaintext token.
149
+ *
150
+ * The cache is per-isolate, so a revoked key may stay resolvable elsewhere
151
+ * for up to `ttl` — the accepted trade-off for removing a backend read from
152
+ * the auth path of every request. Provisioning methods pass through uncached.
153
+ */
154
+ export declare function cached(source: Source, options?: cached.Options): Source;
155
+ export declare namespace cached {
156
+ /** Options for wrapping a source with a short-TTL resolve cache. */
157
+ type Options = {
158
+ /** Time-to-live for negative (`null`) results in milliseconds. */
159
+ negativeTtl?: number | undefined;
160
+ /** Clock used for expiry. */
161
+ now?: (() => number) | undefined;
162
+ /** Time-to-live for positive results in milliseconds. */
163
+ ttl?: number | undefined;
164
+ };
165
+ }
166
+ //# sourceMappingURL=ApiKeySource.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApiKeySource.d.ts","sourceRoot":"","sources":["../src/ApiKeySource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,CAAC,MAAM,UAAU,CAAA;AAE7B,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,KAAK,KAAK,MAAM,qBAAqB,CAAA;AAEjD,sDAAsD;AACtD,yBAAiB,MAAM,CAAC;IACtB;;;;;OAKG;IACI,MAAM,SAAS;;;;;;;;;;;;;;;;;;;qBASpB,CAAA;IAEF;;;;OAIG;IACI,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;qBAKjB,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