tapimo 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (520) hide show
  1. package/README.md +57 -16
  2. package/dist/ApiKey.d.ts +4 -1
  3. package/dist/ApiKey.d.ts.map +1 -1
  4. package/dist/ApiKey.js +6 -2
  5. package/dist/ApiKey.js.map +1 -1
  6. package/dist/ApiKeys.d.ts +98 -3
  7. package/dist/ApiKeys.d.ts.map +1 -1
  8. package/dist/ApiKeys.js +150 -1
  9. package/dist/ApiKeys.js.map +1 -1
  10. package/dist/App.d.ts +7917 -2315
  11. package/dist/App.d.ts.map +1 -1
  12. package/dist/App.js +141 -329
  13. package/dist/App.js.map +1 -1
  14. package/dist/Scope.d.ts +20 -4
  15. package/dist/Scope.d.ts.map +1 -1
  16. package/dist/Scope.js +23 -4
  17. package/dist/Scope.js.map +1 -1
  18. package/dist/Webhooks.d.ts +2 -2
  19. package/dist/Webhooks.d.ts.map +1 -1
  20. package/dist/Webhooks.js +2 -2
  21. package/dist/Webhooks.js.map +1 -1
  22. package/dist/admin/App.d.ts +203 -120
  23. package/dist/admin/App.d.ts.map +1 -1
  24. package/dist/admin/apps/api-keys.d.ts +111 -6
  25. package/dist/admin/apps/api-keys.d.ts.map +1 -1
  26. package/dist/admin/apps/api-keys.js +67 -0
  27. package/dist/admin/apps/api-keys.js.map +1 -1
  28. package/dist/admin/apps/scopes.d.ts +12 -1
  29. package/dist/admin/apps/scopes.d.ts.map +1 -1
  30. package/dist/admin/apps/scopes.js +3 -0
  31. package/dist/admin/apps/scopes.js.map +1 -1
  32. package/dist/admin/apps/verified-tokens.d.ts +116 -116
  33. package/dist/admin/apps/verified-tokens.js +1 -1
  34. package/dist/admin/apps/verified-tokens.js.map +1 -1
  35. package/dist/admin/ui.generated.d.ts +1 -1
  36. package/dist/admin/ui.generated.js +13 -13
  37. package/dist/admin/ui.generated.js.map +1 -1
  38. package/dist/analytics/Analytics.d.ts +151 -0
  39. package/dist/analytics/Analytics.d.ts.map +1 -0
  40. package/dist/analytics/Analytics.js +212 -0
  41. package/dist/analytics/Analytics.js.map +1 -0
  42. package/dist/analytics/tables/requestEvents.d.ts +215 -0
  43. package/dist/analytics/tables/requestEvents.d.ts.map +1 -0
  44. package/dist/analytics/tables/requestEvents.js +264 -0
  45. package/dist/analytics/tables/requestEvents.js.map +1 -0
  46. package/dist/apps/data/App.d.ts +19576 -0
  47. package/dist/apps/data/App.d.ts.map +1 -0
  48. package/dist/apps/data/App.js +272 -0
  49. package/dist/apps/data/App.js.map +1 -0
  50. package/dist/apps/data/index.d.ts +3 -0
  51. package/dist/apps/data/index.d.ts.map +1 -0
  52. package/dist/apps/data/index.js +3 -0
  53. package/dist/apps/data/index.js.map +1 -0
  54. package/dist/apps/{activities.d.ts → data/routes/activities.d.ts} +32 -32
  55. package/dist/apps/{activities.d.ts.map → data/routes/activities.d.ts.map} +1 -1
  56. package/dist/apps/{activities.js → data/routes/activities.js} +13 -13
  57. package/dist/apps/data/routes/activities.js.map +1 -0
  58. package/dist/apps/{addresses.d.ts → data/routes/addresses.d.ts} +22 -22
  59. package/dist/apps/{addresses.d.ts.map → data/routes/addresses.d.ts.map} +1 -1
  60. package/dist/apps/{addresses.js → data/routes/addresses.js} +5 -5
  61. package/dist/apps/data/routes/addresses.js.map +1 -0
  62. package/dist/apps/{balances.d.ts → data/routes/balances.d.ts} +4 -4
  63. package/dist/apps/data/routes/balances.d.ts.map +1 -0
  64. package/dist/apps/{balances.js → data/routes/balances.js} +42 -11
  65. package/dist/apps/data/routes/balances.js.map +1 -0
  66. package/dist/apps/{blocks.d.ts → data/routes/blocks.d.ts} +47 -47
  67. package/dist/apps/data/routes/blocks.d.ts.map +1 -0
  68. package/dist/apps/{blocks.js → data/routes/blocks.js} +13 -13
  69. package/dist/apps/data/routes/blocks.js.map +1 -0
  70. package/dist/apps/{coingecko.d.ts → data/routes/coingecko.d.ts} +8 -8
  71. package/dist/apps/data/routes/coingecko.d.ts.map +1 -0
  72. package/dist/apps/{coingecko.js → data/routes/coingecko.js} +13 -13
  73. package/dist/apps/data/routes/coingecko.js.map +1 -0
  74. package/dist/apps/{exchanges.d.ts → data/routes/exchanges.d.ts} +108 -108
  75. package/dist/apps/data/routes/exchanges.d.ts.map +1 -0
  76. package/dist/apps/{exchanges.js → data/routes/exchanges.js} +19 -19
  77. package/dist/apps/data/routes/exchanges.js.map +1 -0
  78. package/dist/apps/{fee-amm.d.ts → data/routes/fee-amm.d.ts} +39 -39
  79. package/dist/apps/data/routes/fee-amm.d.ts.map +1 -0
  80. package/dist/apps/{fee-amm.js → data/routes/fee-amm.js} +17 -17
  81. package/dist/apps/data/routes/fee-amm.js.map +1 -0
  82. package/dist/apps/data/routes/funding.d.ts +765 -0
  83. package/dist/apps/data/routes/funding.d.ts.map +1 -0
  84. package/dist/apps/data/routes/funding.js +383 -0
  85. package/dist/apps/data/routes/funding.js.map +1 -0
  86. package/dist/apps/{indexer.d.ts → data/routes/indexer.d.ts} +4 -4
  87. package/dist/apps/data/routes/indexer.d.ts.map +1 -0
  88. package/dist/apps/{indexer.js → data/routes/indexer.js} +13 -9
  89. package/dist/apps/data/routes/indexer.js.map +1 -0
  90. package/dist/apps/{receipts.d.ts → data/routes/receipts.d.ts} +49 -49
  91. package/dist/apps/data/routes/receipts.d.ts.map +1 -0
  92. package/dist/apps/{receipts.js → data/routes/receipts.js} +14 -20
  93. package/dist/apps/data/routes/receipts.js.map +1 -0
  94. package/dist/apps/{rpc.d.ts → data/routes/rpc.d.ts} +33 -40
  95. package/dist/apps/data/routes/rpc.d.ts.map +1 -0
  96. package/dist/apps/{rpc.js → data/routes/rpc.js} +35 -7
  97. package/dist/apps/data/routes/rpc.js.map +1 -0
  98. package/dist/apps/{tokenlist.d.ts → data/routes/tokenlist.d.ts} +40 -40
  99. package/dist/apps/data/routes/tokenlist.d.ts.map +1 -0
  100. package/dist/apps/{tokenlist.js → data/routes/tokenlist.js} +8 -8
  101. package/dist/apps/data/routes/tokenlist.js.map +1 -0
  102. package/dist/apps/{tokens.d.ts → data/routes/tokens.d.ts} +468 -468
  103. package/dist/apps/data/routes/tokens.d.ts.map +1 -0
  104. package/dist/apps/{tokens.js → data/routes/tokens.js} +19 -19
  105. package/dist/apps/data/routes/tokens.js.map +1 -0
  106. package/dist/apps/{transactions.d.ts → data/routes/transactions.d.ts} +304 -304
  107. package/dist/apps/data/routes/transactions.d.ts.map +1 -0
  108. package/dist/apps/{transactions.js → data/routes/transactions.js} +13 -13
  109. package/dist/apps/data/routes/transactions.js.map +1 -0
  110. package/dist/apps/{transfers.d.ts → data/routes/transfers.d.ts} +62 -62
  111. package/dist/apps/data/routes/transfers.d.ts.map +1 -0
  112. package/dist/apps/{transfers.js → data/routes/transfers.js} +13 -13
  113. package/dist/apps/data/routes/transfers.js.map +1 -0
  114. package/dist/apps/{verified-tokens.d.ts → data/routes/verified-tokens.d.ts} +6 -6
  115. package/dist/apps/data/routes/verified-tokens.d.ts.map +1 -0
  116. package/dist/apps/{verified-tokens.js → data/routes/verified-tokens.js} +9 -9
  117. package/dist/apps/data/routes/verified-tokens.js.map +1 -0
  118. package/dist/apps/{webhooks.d.ts → data/routes/webhooks.d.ts} +17 -17
  119. package/dist/apps/{webhooks.d.ts.map → data/routes/webhooks.d.ts.map} +1 -1
  120. package/dist/apps/{webhooks.js → data/routes/webhooks.js} +38 -34
  121. package/dist/apps/data/routes/webhooks.js.map +1 -0
  122. package/dist/apps/docs/App.d.ts +29 -0
  123. package/dist/apps/docs/App.d.ts.map +1 -0
  124. package/dist/apps/docs/App.js +54 -0
  125. package/dist/apps/docs/App.js.map +1 -0
  126. package/dist/{internal/OpenApi.fonts.d.ts → apps/docs/fonts.d.ts} +1 -1
  127. package/dist/apps/docs/fonts.d.ts.map +1 -0
  128. package/dist/{internal/OpenApi.fonts.js → apps/docs/fonts.js} +1 -1
  129. package/dist/apps/docs/fonts.js.map +1 -0
  130. package/dist/apps/docs/index.d.ts +2 -0
  131. package/dist/apps/docs/index.d.ts.map +1 -0
  132. package/dist/apps/docs/index.js +2 -0
  133. package/dist/apps/docs/index.js.map +1 -0
  134. package/dist/{internal/OpenApi.logo.d.ts → apps/docs/logo.d.ts} +1 -1
  135. package/dist/apps/docs/logo.d.ts.map +1 -0
  136. package/dist/{internal/OpenApi.logo.js → apps/docs/logo.js} +1 -1
  137. package/dist/apps/docs/logo.js.map +1 -0
  138. package/dist/apps/docs/reference.d.ts +21 -0
  139. package/dist/apps/docs/reference.d.ts.map +1 -0
  140. package/dist/apps/docs/reference.js +112 -0
  141. package/dist/apps/docs/reference.js.map +1 -0
  142. package/dist/apps/index.d.ts +5 -0
  143. package/dist/apps/index.d.ts.map +1 -0
  144. package/dist/apps/index.js +5 -0
  145. package/dist/apps/index.js.map +1 -0
  146. package/dist/apps/mcp.d.ts +76 -0
  147. package/dist/apps/mcp.d.ts.map +1 -0
  148. package/dist/apps/mcp.js +188 -0
  149. package/dist/apps/mcp.js.map +1 -0
  150. package/dist/apps/metadata.d.ts +7 -0
  151. package/dist/apps/metadata.d.ts.map +1 -0
  152. package/dist/apps/metadata.js +15 -0
  153. package/dist/apps/metadata.js.map +1 -0
  154. package/dist/apps/platform/App.d.ts +5262 -0
  155. package/dist/apps/platform/App.d.ts.map +1 -0
  156. package/dist/apps/platform/App.js +84 -0
  157. package/dist/apps/platform/App.js.map +1 -0
  158. package/dist/apps/platform/Billing.d.ts +279 -0
  159. package/dist/apps/platform/Billing.d.ts.map +1 -0
  160. package/dist/apps/platform/Billing.js +477 -0
  161. package/dist/apps/platform/Billing.js.map +1 -0
  162. package/dist/apps/platform/index.d.ts +3 -0
  163. package/dist/apps/platform/index.d.ts.map +1 -0
  164. package/dist/apps/platform/index.js +3 -0
  165. package/dist/apps/platform/index.js.map +1 -0
  166. package/dist/apps/platform/routes/api-keys.d.ts +973 -0
  167. package/dist/apps/platform/routes/api-keys.d.ts.map +1 -0
  168. package/dist/apps/platform/routes/api-keys.js +430 -0
  169. package/dist/apps/platform/routes/api-keys.js.map +1 -0
  170. package/dist/apps/platform/routes/billing.d.ts +1520 -0
  171. package/dist/apps/platform/routes/billing.d.ts.map +1 -0
  172. package/dist/apps/platform/routes/billing.js +795 -0
  173. package/dist/apps/platform/routes/billing.js.map +1 -0
  174. package/dist/apps/platform/routes/invitations.d.ts +851 -0
  175. package/dist/apps/platform/routes/invitations.d.ts.map +1 -0
  176. package/dist/apps/platform/routes/invitations.js +471 -0
  177. package/dist/apps/platform/routes/invitations.js.map +1 -0
  178. package/dist/apps/platform/routes/me.d.ts +95 -0
  179. package/dist/apps/platform/routes/me.d.ts.map +1 -0
  180. package/dist/apps/platform/routes/me.js +81 -0
  181. package/dist/apps/platform/routes/me.js.map +1 -0
  182. package/dist/apps/platform/routes/members.d.ts +554 -0
  183. package/dist/apps/platform/routes/members.d.ts.map +1 -0
  184. package/dist/apps/platform/routes/members.js +251 -0
  185. package/dist/apps/platform/routes/members.js.map +1 -0
  186. package/dist/apps/platform/routes/orgs.d.ts +596 -0
  187. package/dist/apps/platform/routes/orgs.d.ts.map +1 -0
  188. package/dist/apps/platform/routes/orgs.js +276 -0
  189. package/dist/apps/platform/routes/orgs.js.map +1 -0
  190. package/dist/apps/platform/routes/projects.d.ts +740 -0
  191. package/dist/apps/platform/routes/projects.d.ts.map +1 -0
  192. package/dist/apps/platform/routes/projects.js +286 -0
  193. package/dist/apps/platform/routes/projects.js.map +1 -0
  194. package/dist/apps/platform/routes/scopes.d.ts +107 -0
  195. package/dist/apps/platform/routes/scopes.d.ts.map +1 -0
  196. package/dist/apps/platform/routes/scopes.js +66 -0
  197. package/dist/apps/platform/routes/scopes.js.map +1 -0
  198. package/dist/apps/platform/routes/usage.d.ts +588 -0
  199. package/dist/apps/platform/routes/usage.d.ts.map +1 -0
  200. package/dist/apps/platform/routes/usage.js +391 -0
  201. package/dist/apps/platform/routes/usage.js.map +1 -0
  202. package/dist/apps/relay/App.d.ts +44 -0
  203. package/dist/apps/relay/App.d.ts.map +1 -0
  204. package/dist/apps/relay/App.js +211 -0
  205. package/dist/apps/relay/App.js.map +1 -0
  206. package/dist/apps/relay/Sponsorships.d.ts +107 -0
  207. package/dist/apps/relay/Sponsorships.d.ts.map +1 -0
  208. package/dist/apps/relay/Sponsorships.js +194 -0
  209. package/dist/apps/relay/Sponsorships.js.map +1 -0
  210. package/dist/apps/relay/index.d.ts +3 -0
  211. package/dist/apps/relay/index.d.ts.map +1 -0
  212. package/dist/apps/relay/index.js +3 -0
  213. package/dist/apps/relay/index.js.map +1 -0
  214. package/dist/cli/Cli.d.ts +9 -2
  215. package/dist/cli/Cli.d.ts.map +1 -1
  216. package/dist/cli/Cli.js +12 -4
  217. package/dist/cli/Cli.js.map +1 -1
  218. package/dist/cli/commands/admin.d.ts +5 -1
  219. package/dist/cli/commands/admin.d.ts.map +1 -1
  220. package/dist/cli/commands/admin.js +82 -3
  221. package/dist/cli/commands/admin.js.map +1 -1
  222. package/dist/db/Db.d.ts +17 -0
  223. package/dist/db/Db.d.ts.map +1 -1
  224. package/dist/db/Db.js +254 -0
  225. package/dist/db/Db.js.map +1 -1
  226. package/dist/db/Schema.d.ts +159 -0
  227. package/dist/db/Schema.d.ts.map +1 -1
  228. package/dist/db/Schema.js +187 -2
  229. package/dist/db/Schema.js.map +1 -1
  230. package/dist/db/tables/billingSettings.d.ts +55 -0
  231. package/dist/db/tables/billingSettings.d.ts.map +1 -0
  232. package/dist/db/tables/billingSettings.js +70 -0
  233. package/dist/db/tables/billingSettings.js.map +1 -0
  234. package/dist/db/tables/invitations.d.ts +84 -0
  235. package/dist/db/tables/invitations.d.ts.map +1 -0
  236. package/dist/db/tables/invitations.js +165 -0
  237. package/dist/db/tables/invitations.js.map +1 -0
  238. package/dist/db/tables/memberships.d.ts +108 -0
  239. package/dist/db/tables/memberships.d.ts.map +1 -0
  240. package/dist/db/tables/memberships.js +153 -0
  241. package/dist/db/tables/memberships.js.map +1 -0
  242. package/dist/db/tables/organizations.d.ts +48 -0
  243. package/dist/db/tables/organizations.d.ts.map +1 -1
  244. package/dist/db/tables/organizations.js +97 -2
  245. package/dist/db/tables/organizations.js.map +1 -1
  246. package/dist/db/tables/projects.d.ts +65 -0
  247. package/dist/db/tables/projects.d.ts.map +1 -0
  248. package/dist/db/tables/projects.js +75 -0
  249. package/dist/db/tables/projects.js.map +1 -0
  250. package/dist/db/tables/requestUsage.d.ts +121 -0
  251. package/dist/db/tables/requestUsage.d.ts.map +1 -0
  252. package/dist/db/tables/requestUsage.js +150 -0
  253. package/dist/db/tables/requestUsage.js.map +1 -0
  254. package/dist/db/tables/sponsoredTransactions.d.ts +239 -0
  255. package/dist/db/tables/sponsoredTransactions.d.ts.map +1 -0
  256. package/dist/db/tables/sponsoredTransactions.js +314 -0
  257. package/dist/db/tables/sponsoredTransactions.js.map +1 -0
  258. package/dist/db/tables/stripeCustomers.d.ts +81 -0
  259. package/dist/db/tables/stripeCustomers.d.ts.map +1 -0
  260. package/dist/db/tables/stripeCustomers.js +120 -0
  261. package/dist/db/tables/stripeCustomers.js.map +1 -0
  262. package/dist/db/tables/users.d.ts +48 -0
  263. package/dist/db/tables/users.d.ts.map +1 -0
  264. package/dist/db/tables/users.js +65 -0
  265. package/dist/db/tables/users.js.map +1 -0
  266. package/dist/handlers/internal/executionError.d.ts.map +1 -1
  267. package/dist/handlers/internal/executionError.js +2 -0
  268. package/dist/handlers/internal/executionError.js.map +1 -1
  269. package/dist/handlers/internal/multisig.d.ts +2 -6
  270. package/dist/handlers/internal/multisig.d.ts.map +1 -1
  271. package/dist/handlers/internal/multisig.js +11 -36
  272. package/dist/handlers/internal/multisig.js.map +1 -1
  273. package/dist/handlers/internal/sponsorship.d.ts +35 -2
  274. package/dist/handlers/internal/sponsorship.d.ts.map +1 -1
  275. package/dist/handlers/internal/sponsorship.js +53 -14
  276. package/dist/handlers/internal/sponsorship.js.map +1 -1
  277. package/dist/handlers/internal/utils.d.ts +10 -3
  278. package/dist/handlers/internal/utils.d.ts.map +1 -1
  279. package/dist/handlers/internal/utils.js +14 -6
  280. package/dist/handlers/internal/utils.js.map +1 -1
  281. package/dist/handlers/relay.d.ts +6 -2
  282. package/dist/handlers/relay.d.ts.map +1 -1
  283. package/dist/handlers/relay.js +16 -2
  284. package/dist/handlers/relay.js.map +1 -1
  285. package/dist/index.d.ts +1 -0
  286. package/dist/index.d.ts.map +1 -1
  287. package/dist/index.js +1 -0
  288. package/dist/index.js.map +1 -1
  289. package/dist/internal/Auth.d.ts +222 -6
  290. package/dist/internal/Auth.d.ts.map +1 -1
  291. package/dist/internal/Auth.js +625 -74
  292. package/dist/internal/Auth.js.map +1 -1
  293. package/dist/internal/Cache.d.ts.map +1 -1
  294. package/dist/internal/Cache.js +4 -1
  295. package/dist/internal/Cache.js.map +1 -1
  296. package/dist/internal/EdgeCache.d.ts +10 -0
  297. package/dist/internal/EdgeCache.d.ts.map +1 -1
  298. package/dist/internal/EdgeCache.js +39 -8
  299. package/dist/internal/EdgeCache.js.map +1 -1
  300. package/dist/internal/Fees.d.ts +27 -0
  301. package/dist/internal/Fees.d.ts.map +1 -0
  302. package/dist/internal/Fees.js +48 -0
  303. package/dist/internal/Fees.js.map +1 -0
  304. package/dist/internal/FundingRoutes.d.ts +183 -0
  305. package/dist/internal/FundingRoutes.d.ts.map +1 -0
  306. package/dist/internal/FundingRoutes.js +490 -0
  307. package/dist/internal/FundingRoutes.js.map +1 -0
  308. package/dist/internal/Id.d.ts +15 -0
  309. package/dist/internal/Id.d.ts.map +1 -0
  310. package/dist/internal/Id.js +22 -0
  311. package/dist/internal/Id.js.map +1 -0
  312. package/dist/internal/Log.d.ts +9 -3
  313. package/dist/internal/Log.d.ts.map +1 -1
  314. package/dist/internal/Log.js +7 -0
  315. package/dist/internal/Log.js.map +1 -1
  316. package/dist/internal/OpenApi.d.ts +10 -20
  317. package/dist/internal/OpenApi.d.ts.map +1 -1
  318. package/dist/internal/OpenApi.js +8 -58
  319. package/dist/internal/OpenApi.js.map +1 -1
  320. package/dist/internal/RateLimit.d.ts +25 -0
  321. package/dist/internal/RateLimit.d.ts.map +1 -1
  322. package/dist/internal/RateLimit.js +51 -0
  323. package/dist/internal/RateLimit.js.map +1 -1
  324. package/dist/internal/Response.d.ts +1 -1
  325. package/dist/internal/Response.d.ts.map +1 -1
  326. package/dist/internal/Schema.d.ts +8 -0
  327. package/dist/internal/Schema.d.ts.map +1 -1
  328. package/dist/internal/Schema.js +7 -0
  329. package/dist/internal/Schema.js.map +1 -1
  330. package/dist/internal/Store.d.ts +7 -1
  331. package/dist/internal/Store.d.ts.map +1 -1
  332. package/dist/internal/Store.js +16 -2
  333. package/dist/internal/Store.js.map +1 -1
  334. package/dist/internal/Viem.d.ts +84 -0
  335. package/dist/internal/Viem.d.ts.map +1 -1
  336. package/dist/internal/Webhooks.d.ts +1 -1
  337. package/dist/internal/Webhooks.d.ts.map +1 -1
  338. package/dist/internal/Webhooks.js +3 -3
  339. package/dist/internal/Webhooks.js.map +1 -1
  340. package/package.json +33 -6
  341. package/src/ApiKey.ts +10 -2
  342. package/src/ApiKeys.test.ts +155 -1
  343. package/src/ApiKeys.ts +203 -1
  344. package/src/App.test.ts +64 -75741
  345. package/src/App.ts +218 -420
  346. package/src/Client.test-d.ts +657 -15
  347. package/src/Scope.ts +26 -4
  348. package/src/Webhooks.ts +2 -2
  349. package/src/admin/apps/api-keys.test.ts +51 -0
  350. package/src/admin/apps/api-keys.ts +84 -0
  351. package/src/admin/apps/scopes.test.ts +11 -1
  352. package/src/admin/apps/scopes.ts +3 -0
  353. package/src/admin/apps/verified-tokens.ts +1 -1
  354. package/src/admin/ui/src/components/Page.tsx +2 -3
  355. package/src/admin/ui/src/routes/__root.tsx +2 -2
  356. package/src/admin/ui/src/routes/api-keys.tsx +2 -2
  357. package/src/admin/ui.generated.ts +13 -13
  358. package/src/analytics/Analytics.test.ts +527 -0
  359. package/src/analytics/Analytics.ts +318 -0
  360. package/src/analytics/tables/requestEvents.ts +523 -0
  361. package/src/apps/composition.test.ts +66 -0
  362. package/src/apps/data/App.test.ts +72 -0
  363. package/src/apps/data/App.ts +330 -0
  364. package/src/apps/data/index.ts +2 -0
  365. package/src/apps/{activities.test.ts → data/routes/activities.test.ts} +3 -3
  366. package/src/apps/{activities.ts → data/routes/activities.ts} +15 -15
  367. package/src/apps/{addresses.ts → data/routes/addresses.ts} +6 -6
  368. package/src/apps/{balances.test.ts → data/routes/balances.test.ts} +2 -2
  369. package/src/apps/{balances.ts → data/routes/balances.ts} +46 -12
  370. package/src/apps/{blocks.test.ts → data/routes/blocks.test.ts} +3 -3
  371. package/src/apps/{blocks.ts → data/routes/blocks.ts} +14 -14
  372. package/src/apps/{coingecko.test.ts → data/routes/coingecko.test.ts} +2 -2
  373. package/src/apps/{coingecko.ts → data/routes/coingecko.ts} +14 -14
  374. package/src/apps/{exchanges.test.ts → data/routes/exchanges.test.ts} +1 -1
  375. package/src/apps/{exchanges.ts → data/routes/exchanges.ts} +20 -20
  376. package/src/apps/{fee-amm.test.ts → data/routes/fee-amm.test.ts} +3 -3
  377. package/src/apps/{fee-amm.ts → data/routes/fee-amm.ts} +18 -18
  378. package/src/apps/data/routes/funding.test.ts +214 -0
  379. package/src/apps/data/routes/funding.ts +584 -0
  380. package/src/apps/{indexer.test.ts → data/routes/indexer.test.ts} +26 -5
  381. package/src/apps/{indexer.ts → data/routes/indexer.ts} +13 -10
  382. package/src/apps/{receipts.test.ts → data/routes/receipts.test.ts} +3 -3
  383. package/src/apps/{receipts.ts → data/routes/receipts.ts} +15 -22
  384. package/src/apps/{rpc.test.ts → data/routes/rpc.test.ts} +122 -7
  385. package/src/apps/{rpc.ts → data/routes/rpc.ts} +38 -8
  386. package/src/apps/{tokenlist.test.ts → data/routes/tokenlist.test.ts} +3 -3
  387. package/src/apps/{tokenlist.ts → data/routes/tokenlist.ts} +9 -9
  388. package/src/apps/{tokens.test.ts → data/routes/tokens.test.ts} +2 -2
  389. package/src/apps/{tokens.ts → data/routes/tokens.ts} +20 -20
  390. package/src/apps/{transactions.test.ts → data/routes/transactions.test.ts} +3 -3
  391. package/src/apps/{transactions.ts → data/routes/transactions.ts} +15 -15
  392. package/src/apps/{transfers.test.ts → data/routes/transfers.test.ts} +2 -2
  393. package/src/apps/{transfers.ts → data/routes/transfers.ts} +15 -15
  394. package/src/apps/{verified-tokens.test.ts → data/routes/verified-tokens.test.ts} +3 -3
  395. package/src/apps/{verified-tokens.ts → data/routes/verified-tokens.ts} +10 -10
  396. package/src/apps/{webhooks.test.ts → data/routes/webhooks.test.ts} +7 -7
  397. package/src/apps/{webhooks.ts → data/routes/webhooks.ts} +50 -43
  398. package/src/apps/docs/App.ts +65 -0
  399. package/src/apps/docs/index.ts +1 -0
  400. package/src/apps/docs/reference.ts +132 -0
  401. package/src/apps/index.ts +4 -0
  402. package/src/apps/mcp.test.ts +206 -0
  403. package/src/apps/mcp.ts +250 -0
  404. package/src/apps/metadata.ts +23 -0
  405. package/src/apps/platform/App.ts +169 -0
  406. package/src/apps/platform/Billing.test.ts +530 -0
  407. package/src/apps/platform/Billing.ts +682 -0
  408. package/src/apps/platform/index.ts +2 -0
  409. package/src/apps/platform/routes/api-keys.test.ts +493 -0
  410. package/src/apps/platform/routes/api-keys.ts +543 -0
  411. package/src/apps/platform/routes/billing.test.ts +1100 -0
  412. package/src/apps/platform/routes/billing.ts +966 -0
  413. package/src/apps/platform/routes/invitations.test.ts +409 -0
  414. package/src/apps/platform/routes/invitations.ts +587 -0
  415. package/src/apps/platform/routes/me.test.ts +351 -0
  416. package/src/apps/platform/routes/me.ts +106 -0
  417. package/src/apps/platform/routes/members.test.ts +195 -0
  418. package/src/apps/platform/routes/members.ts +313 -0
  419. package/src/apps/platform/routes/orgs.test.ts +313 -0
  420. package/src/apps/platform/routes/orgs.ts +365 -0
  421. package/src/apps/platform/routes/projects.test.ts +181 -0
  422. package/src/apps/platform/routes/projects.ts +367 -0
  423. package/src/apps/platform/routes/scopes.test.ts +29 -0
  424. package/src/apps/platform/routes/scopes.ts +85 -0
  425. package/src/apps/platform/routes/usage.test.ts +422 -0
  426. package/src/apps/platform/routes/usage.ts +527 -0
  427. package/src/apps/relay/App.test.ts +933 -0
  428. package/src/apps/relay/App.ts +236 -0
  429. package/src/apps/relay/Sponsorships.test.ts +375 -0
  430. package/src/apps/relay/Sponsorships.ts +306 -0
  431. package/src/apps/relay/index.ts +2 -0
  432. package/src/cli/Cli.test.ts +25 -2
  433. package/src/cli/Cli.ts +18 -3
  434. package/src/cli/commands/admin.test.ts +83 -0
  435. package/src/cli/commands/admin.ts +91 -3
  436. package/src/db/Db.ts +296 -0
  437. package/src/db/Schema.ts +241 -2
  438. package/src/db/tables/billingSettings.test.ts +87 -0
  439. package/src/db/tables/billingSettings.ts +108 -0
  440. package/src/db/tables/invitations.ts +198 -0
  441. package/src/db/tables/memberships.ts +208 -0
  442. package/src/db/tables/organizations.test.ts +38 -2
  443. package/src/db/tables/organizations.ts +117 -2
  444. package/src/db/tables/projects.ts +107 -0
  445. package/src/db/tables/requestUsage.ts +231 -0
  446. package/src/db/tables/sponsoredTransactions.test.ts +325 -0
  447. package/src/db/tables/sponsoredTransactions.ts +464 -0
  448. package/src/db/tables/stripeCustomers.test.ts +109 -0
  449. package/src/db/tables/stripeCustomers.ts +162 -0
  450. package/src/db/tables/users.ts +85 -0
  451. package/src/handlers/internal/executionError.ts +2 -0
  452. package/src/handlers/internal/multisig.test.ts +84 -10
  453. package/src/handlers/internal/multisig.ts +15 -50
  454. package/src/handlers/internal/sponsorship.ts +106 -20
  455. package/src/handlers/internal/utils.ts +19 -7
  456. package/src/handlers/{internal/relay.localnet.test.ts → relay.test.ts} +2 -2
  457. package/src/handlers/relay.ts +23 -5
  458. package/src/index.ts +1 -0
  459. package/src/internal/Auth.test.ts +491 -25
  460. package/src/internal/Auth.ts +839 -84
  461. package/src/internal/Cache.ts +5 -1
  462. package/src/internal/Cursor.test.ts +3 -2
  463. package/src/internal/EdgeCache.test.ts +27 -4
  464. package/src/internal/EdgeCache.ts +47 -9
  465. package/src/internal/Fees.test.ts +32 -0
  466. package/src/internal/Fees.ts +51 -0
  467. package/src/internal/FundingRoutes.ts +583 -0
  468. package/src/internal/Id.test.ts +17 -0
  469. package/src/internal/Id.ts +24 -0
  470. package/src/internal/Log.test.ts +2 -1
  471. package/src/internal/Log.ts +16 -3
  472. package/src/internal/MetricSink.ts +1 -1
  473. package/src/internal/OpenApi.ts +12 -60
  474. package/src/internal/RateLimit.test.ts +84 -0
  475. package/src/internal/RateLimit.ts +70 -0
  476. package/src/internal/Response.ts +1 -1
  477. package/src/internal/Schema.ts +8 -0
  478. package/src/internal/Store.test.ts +52 -0
  479. package/src/internal/Store.ts +24 -5
  480. package/src/internal/Tidx.local.test.ts +1 -1
  481. package/src/internal/VerifiedTokens.test.ts +1 -1
  482. package/src/internal/WebhookDestination.test.ts +1 -1
  483. package/src/internal/Webhooks.test.ts +7 -7
  484. package/src/internal/Webhooks.ts +4 -4
  485. package/dist/apps/activities.js.map +0 -1
  486. package/dist/apps/addresses.js.map +0 -1
  487. package/dist/apps/balances.d.ts.map +0 -1
  488. package/dist/apps/balances.js.map +0 -1
  489. package/dist/apps/blocks.d.ts.map +0 -1
  490. package/dist/apps/blocks.js.map +0 -1
  491. package/dist/apps/coingecko.d.ts.map +0 -1
  492. package/dist/apps/coingecko.js.map +0 -1
  493. package/dist/apps/exchanges.d.ts.map +0 -1
  494. package/dist/apps/exchanges.js.map +0 -1
  495. package/dist/apps/fee-amm.d.ts.map +0 -1
  496. package/dist/apps/fee-amm.js.map +0 -1
  497. package/dist/apps/indexer.d.ts.map +0 -1
  498. package/dist/apps/indexer.js.map +0 -1
  499. package/dist/apps/receipts.d.ts.map +0 -1
  500. package/dist/apps/receipts.js.map +0 -1
  501. package/dist/apps/rpc.d.ts.map +0 -1
  502. package/dist/apps/rpc.js.map +0 -1
  503. package/dist/apps/tokenlist.d.ts.map +0 -1
  504. package/dist/apps/tokenlist.js.map +0 -1
  505. package/dist/apps/tokens.d.ts.map +0 -1
  506. package/dist/apps/tokens.js.map +0 -1
  507. package/dist/apps/transactions.d.ts.map +0 -1
  508. package/dist/apps/transactions.js.map +0 -1
  509. package/dist/apps/transfers.d.ts.map +0 -1
  510. package/dist/apps/transfers.js.map +0 -1
  511. package/dist/apps/verified-tokens.d.ts.map +0 -1
  512. package/dist/apps/verified-tokens.js.map +0 -1
  513. package/dist/apps/webhooks.js.map +0 -1
  514. package/dist/internal/OpenApi.fonts.d.ts.map +0 -1
  515. package/dist/internal/OpenApi.fonts.js.map +0 -1
  516. package/dist/internal/OpenApi.logo.d.ts.map +0 -1
  517. package/dist/internal/OpenApi.logo.js.map +0 -1
  518. package/src/handlers/internal/multisig.localnet.test.ts +0 -146
  519. /package/src/{internal/OpenApi.fonts.ts → apps/docs/fonts.ts} +0 -0
  520. /package/src/{internal/OpenApi.logo.ts → apps/docs/logo.ts} +0 -0
package/dist/App.js CHANGED
@@ -4,46 +4,36 @@ import { cors as hono_cors } from 'hono/cors';
4
4
  import { HTTPException } from 'hono/http-exception';
5
5
  import { requestId } from 'hono/request-id';
6
6
  import { generateSpecs } from 'hono-openapi';
7
- import { Handler as vocs_Handler } from 'vocs/server';
8
- import * as z from 'zod/mini';
9
7
  import * as ApiKey from './ApiKey.js';
10
8
  import * as Assets from './Assets.js';
11
9
  import * as Auth from './internal/Auth.js';
12
10
  import * as Db from './db/Db.js';
13
11
  import * as EdgeCache from './internal/EdgeCache.js';
14
- import * as Handler from './Handler.js';
15
12
  import * as Log from './internal/Log.js';
16
13
  import * as MetricSink from './internal/MetricSink.js';
17
14
  import * as OpenApi from './internal/OpenApi.js';
18
15
  import * as Store from './internal/Store.js';
19
16
  import * as Path from './internal/Path.js';
20
17
  import * as Response from './internal/Response.js';
21
- import * as Schema from './internal/Schema.js';
22
- import * as Tidx from './internal/Tidx.js';
23
18
  import * as Timing from './internal/Timing.js';
24
- import * as VerifiedTokens from './internal/VerifiedTokens.js';
25
19
  import * as Viem from './internal/Viem.js';
26
20
  import openrpcSpec from './openrpc.json' with { type: 'json' };
27
- import { transactions as transactionActivities } from './apps/activities.js';
28
- import { addresses } from './apps/addresses.js';
29
- import { blocks, blocksByTimestampCompat } from './apps/blocks.js';
30
- import { coingecko } from './apps/coingecko.js';
31
- import { exchanges } from './apps/exchanges.js';
32
- import { feeAmm } from './apps/fee-amm.js';
33
- import { indexer } from './apps/indexer.js';
34
- import { receipts } from './apps/receipts.js';
35
- import { rpc as rpcApp } from './apps/rpc.js';
36
- import { tokens } from './apps/tokens.js';
37
- import { transactions } from './apps/transactions.js';
38
- import { transfers } from './apps/transfers.js';
39
- import { verifiedTokens } from './apps/verified-tokens.js';
40
- import { tokenlist } from './apps/tokenlist.js';
41
- import { schema as webhookSchema, webhooks } from './apps/webhooks.js';
21
+ import * as Metadata from './apps/metadata.js';
22
+ import * as Data from './apps/data/App.js';
23
+ import * as Platform from './apps/platform/App.js';
24
+ export var data = Data.data;
25
+ export var platform = Platform.platform;
26
+ // Type anchor only never invoked. Expresses the canonical composition so
27
+ // `App` (and thus `Client`) reflect the full route surface; real consumers
28
+ // compose explicitly.
29
+ function compose(options) {
30
+ return create(options).route('/', data()).route('/', platform());
31
+ }
42
32
  /** Top-level OpenAPI `info.description`, rendered above the reference. */
43
33
  const infoDescription = 'REST API for reading and interacting with Tempo';
44
34
  /** Creates the Tempo API Hono app. */
45
35
  export function create(options) {
46
- const { assets, defaultChainId = Viem.defaultChainId, path = '/', rpc } = options;
36
+ const { path = '/' } = options;
47
37
  // Capture as the literal generic so `Hono.basePath(...)` preserves the
48
38
  // typed prefix. testClient's `Client<T, ...>` inference collapses to a
49
39
  // `Record<string, ...>` index signature when the BasePath generic is the
@@ -58,30 +48,6 @@ export function create(options) {
58
48
  // Authoritative state lives elsewhere: webhooks + verified tokens in
59
49
  // `options.db`, API-key records in `options.kv`.
60
50
  const store = options.cache?.store ?? Store.memory();
61
- // Memoize one viem client per resolved upstream. Clients are stateless HTTP
62
- // transports, so reusing them avoids per-request construction cost. The cache
63
- // key is the resolved output (`url` + `basicAuth` + `chainId`), not the
64
- // principal, so a resolver `rpc` may branch on any principal field while
65
- // client cardinality stays bounded by the number of distinct upstreams —
66
- // callers that resolve to the same upstream share a client.
67
- const clients = new Map();
68
- const getClient = (chainId = defaultChainId, principal = null) => {
69
- // Resolve to derive the cache key; `Viem.getClient` re-resolves to build the
70
- // client on a miss. `resolve` is pure and cheap, so the extra call is free.
71
- const { url, basicAuth } = Viem.resolve(rpc, { chainId, principal });
72
- const cacheKey = `${url}|${basicAuth ?? ''}|${chainId}`;
73
- const existing = clients.get(cacheKey);
74
- if (existing)
75
- return existing;
76
- const client = Viem.getClient({ chainId, principal, rpc });
77
- clients.set(cacheKey, client);
78
- return client;
79
- };
80
- // Memoize TIDX clients per `chainId` so the base URL resolver runs once per
81
- // chain instead of on every request. The same factory backs the scheduled
82
- // webhook poller (`Webhooks.createPoller`), keeping client construction in
83
- // one place.
84
- const getTidx = Tidx.createGetClient({ defaultChainId, tidx: options.tidx });
85
51
  // Build the app in two phases: register middleware imperatively, then chain
86
52
  // route mounts so the merged Hono schema flows through the return type. The
87
53
  // chained type is what makes `testClient(create())` produce typed path
@@ -134,68 +100,29 @@ export function create(options) {
134
100
  return recordAnalytics?.(entry);
135
101
  },
136
102
  }));
137
- // The chain ids this deployment serves: the built-in public chains plus the
138
- // configured `defaultChainId` and any explicit `supportedChainIds`. Exposed on
139
- // context so mounted apps with a path `chainId` (e.g. GeckoTerminal) can guard
140
- // it too.
141
- const supportedChainIds = new Set([
142
- ...Object.keys(Viem.url).map(Number),
143
- ...Object.keys(Tidx.url).map(Number),
144
- defaultChainId,
145
- ...(options.supportedChainIds ?? []),
146
- ]);
147
103
  // Normalize the `db` option: the plain form is `{ source }` with no cached
148
104
  // side; `cached` falls back to `source` so consumers never branch.
149
105
  const db = 'source' in options.db ? options.db : { source: options.db };
106
+ // Normalize the `analytics` option: accept the bare source or `{ source }`,
107
+ // mirroring `db`. Undefined leaves usage analytics unconfigured (501).
108
+ const analytics = options.analytics === undefined
109
+ ? undefined
110
+ : 'source' in options.analytics
111
+ ? options.analytics.source
112
+ : options.analytics;
113
+ // Built-in auth: the session surface (mounted last) plus the enforcement
114
+ // middleware (installed below), wired together in `Auth.install`.
115
+ const auth = Auth.install({ auth: options.auth, db: db.source, kv: options.kv });
150
116
  base.use('*', Timing.middleware());
151
117
  base.use('*', async (c, next) => {
152
- // Put app-level dependencies on Hono context so mounted handlers only
153
- // receive request-local state from `c`.
118
+ c.set('analytics', analytics);
154
119
  c.set('basePath', basePath);
155
- c.set('chainId', defaultChainId);
156
120
  c.set('db', db.source);
157
121
  c.set('dbCached', db.cached ?? db.source);
158
- c.set('getAsset', createGetAsset({ assets, basePath, origin: new URL(c.req.url).origin }));
159
- c.set('getClient', (chainId) => getClient(chainId, Auth.getPrincipal(c)));
160
- c.set('getTidx', (chainId) => getTidx(chainId, Auth.getPrincipal(c)));
161
122
  c.set('kv', options.kv);
162
- c.set('rpc', rpc);
163
123
  c.set('store', store);
164
- c.set('supportedChainIds', supportedChainIds);
165
- c.set('tidx', options.tidx);
166
- // Feature configs default to enabled empty configs; `false` disables.
167
- c.set('verifiedTokens', options.verifiedTokens === false ? undefined : (options.verifiedTokens ?? {})); // prettier-ignore
168
- c.set('webhook', options.webhook === false ? undefined : (options.webhook ?? {}));
169
124
  await next();
170
125
  });
171
- // Reject a syntactically valid `chainId` this deployment does not serve before
172
- // it reaches an upstream — an unknown chain otherwise hits the configured
173
- // RPC/indexer (a static `tidx.baseUrl` answers for any chain id) and comes
174
- // back as an opaque `upstream_error`.
175
- base.use('*', async (c, next) => {
176
- const raw = c.req.query('chainId') ?? c.req.query('chain_id');
177
- if (raw === undefined)
178
- return next();
179
- // Only reject a well-formed-but-unsupported chain here; malformed values
180
- // (e.g. `abc`, `0`) fall through to the route's own query validation.
181
- const parsed = Schema.ChainId.safeParse(raw);
182
- if (!parsed.success || supportedChainIds.has(parsed.data))
183
- return next();
184
- return Response.unsupportedChainId(c, parsed.data, supportedChainIds);
185
- });
186
- // Skip the static asset route entirely when no store is configured; token
187
- // logo URIs simply go unresolved.
188
- if (assets)
189
- base.use('/assets/*', async (c, next) => {
190
- const key = stripAssetPath(c.req.path, basePath).replace(/^\/+/, '');
191
- const asset = key ? await assets.get(key) : undefined;
192
- if (!asset)
193
- return next();
194
- return c.body(asset.body, 200, {
195
- 'Cache-Control': 'public, max-age=86400',
196
- 'Content-Type': asset.contentType,
197
- });
198
- });
199
126
  // Safety net: any non-2xx response (auth/validation errors, MPP `402`
200
127
  // challenges, rate-limit `429`s, upstream `502`s, etc.) must never be
201
128
  // cached. This wraps endpoint middleware and handlers registered below.
@@ -212,85 +139,71 @@ export function create(options) {
212
139
  // latency.
213
140
  if (options.cache?.edge !== false)
214
141
  base.use('*', EdgeCache.middleware({ store }));
215
- const base_routed = base.get('/health', OpenApi.describeRoute({ hide: true }), (c) => c.json({ status: 'ok' }, 200));
216
- for (const middleware of options.middleware ?? [])
217
- base_routed.use('*', middleware);
218
- const app = base_routed
219
- .route('/v1/addresses', addresses())
220
- .route('/v1/blocks', blocks())
221
- .route('/v1/exchange', exchanges())
222
- .route('/v1/fee-amm', feeAmm())
223
- .route('/v1/indexer', indexer())
224
- .route('/v1/tokenlist', tokenlist())
225
- .route('/v1/tokens', tokens())
226
- .route('/v1/transactions', receipts())
227
- .route('/v1/transactions', transactions())
228
- .route('/v1/transactions', transactionActivities())
229
- .route('/v1/transfers', transfers())
230
- .route('/v1/verified-tokens', verifiedTokens())
231
- .route('/v1/webhooks', webhooks({ enabled: options.webhook !== false }))
232
- .route('/rpc', rpcApp())
233
- .use('/rpc/relay', Auth.policy({ apiKey: { scopes: ['rpc-relay'] }, mpp: false, public: false }), OpenApi.describeRoute({ hide: true, summary: 'Relay RPC' }))
234
- .use('/rpc/relay/*', Auth.policy({ apiKey: { scopes: ['rpc-relay'] }, mpp: false, public: false }), OpenApi.describeRoute({ hide: true, summary: 'Relay RPC' }))
235
- .route('/rpc/relay', Handler.relay({
236
- cache: store,
237
- getClient: (chainId) => getClient(chainId),
238
- ...(options.verifiedTokens === false
239
- ? {}
240
- : {
241
- resolveTokens: async (chainId) => {
242
- const snapshot = await VerifiedTokens.read(Db.get(db.cached ?? db.source), chainId);
243
- return snapshot?.list.map((token) => token.address) ?? [];
244
- },
245
- }),
246
- }))
247
- .route('/gecko', coingecko())
248
- // Hidden compatibility route for the prior Tempo API's
249
- // `GET /chains/:chainId/blocks/by-timestamp` (chain id in the path).
250
- .route('/chains', blocksByTimestampCompat());
251
- const spec = (async () => {
252
- // OAS 3.1 `webhooks`: document the signed envelope Tempo API POSTs to subscriber
253
- // URLs (an outbound payload, not an endpoint of this API). Only when enabled.
254
- const webhooksDoc = (() => {
255
- if (options.webhook === false)
256
- return {};
257
- // `io: 'output'` documents the delivered (serialized) shape; `unrepresentable: 'any'`
258
- // tolerates the transaction payload's transforms (e.g. lazy fee-token metadata),
259
- // which have no JSON-Schema form, by emitting `{}` for those nodes rather than throwing.
260
- const envelope = z.toJSONSchema(webhookSchema.Envelope, {
261
- io: 'output',
262
- target: 'draft-2020-12',
263
- unrepresentable: 'any',
264
- });
265
- delete envelope.$schema;
266
- const header = (name, description) => ({
267
- description,
268
- in: 'header',
269
- name,
270
- required: true,
271
- schema: { type: 'string' },
272
- });
273
- return {
274
- webhooks: {
275
- event: {
276
- post: {
277
- description: 'When an event you subscribed to happens, Tempo sends this signed message to your webhook URL as an HTTP POST (the same shape is used by `POST /webhooks/:id/ping` so you can test your endpoint). Always verify the `tempo-signature` header before trusting the body, then reply with any 2xx status to confirm you received it. If your endpoint returns a non-2xx status, times out, or redirects, Tempo retries with increasing delays; an endpoint that keeps failing is eventually disabled.',
278
- parameters: [
279
- header('tempo-signature', 'Signature proving the message really came from Tempo. An HMAC-SHA256 of the body using your webhook secret, formatted `t=<unix>,v1=<hex>`. Verify this before trusting the payload.'),
280
- header('tempo-event-id', 'A unique, stable id for this event (`evt_…`). The same event may be delivered more than once, so use this id to skip duplicates.'),
281
- header('tempo-event-type', 'What happened: `token:transfer`, `transaction:included`, `log:emitted`, `block:created`, or `ping`.'), // prettier-ignore
282
- ],
283
- requestBody: {
284
- content: { 'application/json': { schema: envelope } },
285
- required: true,
286
- },
287
- responses: { '2xx': { description: 'Delivery acknowledged.' } },
288
- summary: 'Webhook event delivery',
289
- tags: ['Webhooks'],
290
- },
291
- },
292
- },
293
- };
142
+ const app = base.get('/health', OpenApi.describeRoute({ hide: true }), (c) => c.json({ status: 'ok' }, 200));
143
+ // Built-in enforcement: default-closed policies over OpenAPI-registered
144
+ // routes. `auth: false` leaves policies unenforced (tests only).
145
+ if (auth.middleware)
146
+ app.use('*', auth.middleware);
147
+ // Collect each mounted group's OpenAPI metadata: Hono's `.route()` drops
148
+ // sub-app metadata, so a group attaches it to its instance (a WeakMap) and we
149
+ // read it back here. Patching the runtime method, not the type, keeps `hc`.
150
+ const metadata = [];
151
+ const route = app.route.bind(app);
152
+ app.route = ((path, sub) => {
153
+ const entry = Metadata.read(sub);
154
+ if (entry)
155
+ metadata.push(entry);
156
+ return route(path, sub);
157
+ });
158
+ // Register the JSON error envelopes eagerly (they don't depend on mounted
159
+ // routes) so error handling is live before the first request and a consumer's
160
+ // `withSentry(app)` sees them already in place.
161
+ app.notFound((c) => Response.error(c, { code: 'not_found', message: 'Route not found', status: 404 }));
162
+ app.onError((cause, c) => {
163
+ if (cause instanceof HTTPException)
164
+ return errorFromException(c, cause);
165
+ // Redact any leaked API-key token from the logged error/stack.
166
+ console.error(ApiKey.redact(cause instanceof Error ? (cause.stack ?? cause.message) : String(cause)));
167
+ return Response.error(c, {
168
+ code: 'internal_error',
169
+ message: 'Internal server error',
170
+ status: 500,
171
+ });
172
+ });
173
+ // Mount the OpenAPI/OpenRPC documents and docs reference lazily on the first
174
+ // request, so the document sees the full route surface without a `seal()`
175
+ // step. The patched `fetch` runs this before Hono builds its matcher.
176
+ //
177
+ // Spec generation stays lazy: ordinary API traffic only installs the routes,
178
+ // while `/openapi.json` and the Vocs handler start the memoized build.
179
+ let spec;
180
+ const getSpec = () => (spec ??= buildSpec());
181
+ const buildSpec = async () => {
182
+ // Merge each mounted group's contributed OpenAPI metadata (tags, security
183
+ // schemes, webhooks block). Unused tags/schemes don't render, so a subset
184
+ // app's document carries only what its groups contributed.
185
+ // The built-in session surface's metadata appends after every mounted
186
+ // group's, so consumer-mounted groups lead the document order.
187
+ const metadata_all = (() => {
188
+ const entry = auth.app ? Metadata.read(auth.app) : undefined;
189
+ return entry ? [...metadata, entry] : metadata;
190
+ })();
191
+ const contributedSchemes = Object.assign({}, ...metadata_all.map((m) => m.securitySchemes ?? {})); // prettier-ignore
192
+ const tags = metadata_all.flatMap((m) => m.tags ?? []);
193
+ // Tag groups contributed under the same name merge into one sidebar group,
194
+ // deduped and filtered to defined tags (a group may list a tag another
195
+ // surface defines, e.g. `Auth` from the built-in session surface).
196
+ const tagGroups = (() => {
197
+ const defined = new Set(tags.map((tag) => tag.name));
198
+ const groups = new Map();
199
+ for (const { name, tags: members } of metadata_all.flatMap((m) => m['x-tagGroups'] ?? []))
200
+ groups.set(name, { name, tags: [...(groups.get(name)?.tags ?? []), ...members] });
201
+ return [...groups.values()]
202
+ .map((group) => ({
203
+ ...group,
204
+ tags: [...new Set(group.tags)].filter((tag) => defined.has(tag)),
205
+ })) // prettier-ignore
206
+ .filter((group) => group.tags.length > 0);
294
207
  })();
295
208
  const generated = await generateSpecs(app, {
296
209
  documentation: {
@@ -309,6 +222,7 @@ export function create(options) {
309
222
  scheme: 'bearer',
310
223
  type: 'http',
311
224
  },
225
+ ...contributedSchemes,
312
226
  },
313
227
  },
314
228
  info: {
@@ -322,70 +236,22 @@ export function create(options) {
322
236
  { url: basePath || '/', description: 'Relative to the host serving this document.' },
323
237
  ]),
324
238
  ],
325
- tags: [
326
- {
327
- name: 'Activities',
328
- description: 'A readable feed of what an account did onchain.',
329
- },
330
- {
331
- name: 'Balances',
332
- description: 'How much of each token an account holds.',
333
- },
334
- {
335
- name: 'Blocks',
336
- description: 'The ordered batches of transactions making up the chain.',
337
- },
338
- {
339
- name: 'Exchange',
340
- description: "Tempo's built-in stablecoin exchange: pairs, swaps, orders, prices.",
341
- },
342
- {
343
- name: 'Fee AMM',
344
- description: 'Pools that convert stablecoins to pay fees.',
345
- },
346
- {
347
- name: 'Tokens',
348
- description: 'TIP-20 token details, supply, and holders.',
349
- },
350
- {
351
- name: 'Transactions',
352
- description: 'Transactions submitted to Tempo, and their receipts.',
353
- },
354
- {
355
- name: 'Transfers',
356
- description: 'Token movements from executing transactions.',
357
- },
358
- {
359
- name: 'Verified Tokens',
360
- description: 'A curated, trusted list of TIP-20 tokens.',
361
- },
362
- ...(options.webhook !== false
363
- ? [
364
- {
365
- name: 'Webhooks',
366
- description: 'Get signed callbacks when onchain events happen.',
367
- },
368
- ]
369
- : []),
370
- {
371
- name: 'Indexer',
372
- description: "Run read-only SQL queries against Tempo's indexed data.",
373
- },
374
- {
375
- name: 'RPC',
376
- description: 'Direct access to the chain over Ethereum JSON-RPC. Not part of the stable API contract; best-effort support only. No compatibility, latency, availability, or data-freshness guarantees. Breaking changes may happen with limited notice.',
377
- },
378
- {
379
- name: 'CoinGecko',
380
- description: "Exchange data in CoinGecko's GeckoTerminal format.",
381
- },
382
- ],
239
+ tags,
240
+ ...(tagGroups.length ? { 'x-tagGroups': tagGroups } : {}),
383
241
  },
384
242
  });
385
- // Set per-operation `security` and the `402` payment-challenge response from
386
- // each route's resolved auth policy (the single source of truth), so the
387
- // anonymous option and `402` appear only where the public/MPP lanes are
388
- // enabled not on every operation via the document default.
243
+ // Document the outbound `webhooks` block only when the webhook routes are
244
+ // actually mounted; a disabled feature hides its routes, so it must not
245
+ // advertise deliveries.
246
+ const hasWebhookRoutes = Object.keys(generated.paths).some((path) => /\/webhooks(\/|$)/.test(path));
247
+ const webhookBlocks = hasWebhookRoutes ? metadata_all.flatMap((m) => (m.webhooks ? [m.webhooks()] : [])) : []; // prettier-ignore
248
+ const webhooksDoc = webhookBlocks.length
249
+ ? { webhooks: Object.assign({}, ...webhookBlocks) }
250
+ : {};
251
+ // Set per-operation `security` and the `402` payment-challenge response
252
+ // from each route's resolved auth policy (the single source of truth), so
253
+ // the anonymous option and `402` appear only where the public/MPP lanes
254
+ // are enabled, not on every operation via the document default.
389
255
  applyAccess(generated.paths, Auth.describeAccess(app));
390
256
  // Point the `/rpc` operation at the OpenRPC document via `x-openrpc`.
391
257
  applyOpenrpcLink(generated.paths, basePath);
@@ -395,37 +261,32 @@ export function create(options) {
395
261
  // tag and preserves document path order within a tag, so reordering here
396
262
  // drives the sidebar sub-item order.
397
263
  return { ...generated, ...webhooksDoc, paths: sortPaths(generated.paths) };
398
- })();
399
- app.get('/openapi.json', async (c) => c.json(await spec));
400
- // The OpenRPC document is a committed build artifact (no runtime generator);
401
- // see scripts/openrpc/build.ts and `pnpm openrpc:build`.
402
- app.get('/openrpc.json', (c) => c.json(openrpcSpec));
403
- if (options.docs !== false)
404
- app.route('/', vocs_Handler.openApi({
405
- // Inline the OpenRPC doc so vocs expands it without a self-subrequest
406
- // (see `inlineOpenrpc`); the public `/openapi.json` keeps the URL ref.
407
- spec: spec.then(inlineOpenrpc),
408
- sidebar: { collapsed: true },
409
- vocs: { logoUrl: OpenApi.logoUrl, title: 'Tempo API Reference', ...options.docs },
410
- }, { fallback: 'next', css: OpenApi.css }));
411
- app.notFound((c) => Response.error(c, { code: 'not_found', message: 'Route not found', status: 404 }));
412
- app.onError((cause, c) => {
413
- if (cause instanceof HTTPException)
414
- return errorFromException(c, cause);
415
- // Redact any leaked API-key token from the logged error/stack.
416
- console.error(ApiKey.redact(cause instanceof Error ? (cause.stack ?? cause.message) : String(cause)));
417
- return Response.error(c, {
418
- code: 'internal_error',
419
- message: 'Internal server error',
420
- status: 500,
421
- });
264
+ };
265
+ let finalized = false;
266
+ const finalize = () => {
267
+ if (finalized)
268
+ return;
269
+ finalized = true;
270
+ app.get('/openapi.json', async (c) => c.json(await getSpec()));
271
+ // The OpenRPC document is a committed build artifact (no runtime generator);
272
+ // see scripts/openrpc/build.ts and `pnpm openrpc:build`.
273
+ app.get('/openrpc.json', (c) => c.json(openrpcSpec));
274
+ // Mount each docs group's reference factory (see `docs()` in `tapimo/docs`)
275
+ // last, so its catch-all sits behind every API route and the documents
276
+ // above regardless of where the group sat in the composition chain.
277
+ for (const entry of metadata)
278
+ if (entry.docs)
279
+ app.route('/', entry.docs({ spec: getSpec }));
280
+ };
281
+ // Patch `fetch` to finalize once before dispatch. `request()` reads
282
+ // `this.fetch` dynamically so it picks up the patch, and the captured
283
+ // `originalFetch` still dispatches as a bare value (used by `App.listener`).
284
+ const originalFetch = app.fetch;
285
+ app.fetch = ((request, ...rest) => {
286
+ finalize();
287
+ return originalFetch(request, ...rest);
422
288
  });
423
- // Return the typed chained Hono directly. Spreading `store`/`listener` onto
424
- // the app would intersect the inferred Hono type and breaks `testClient`'s
425
- // schema inference for downstream consumers. The cache `store` is owned by
426
- // the caller (pass `options.cache.store`), and a Node listener is produced on
427
- // demand via `App.listener(app)`.
428
- return app;
289
+ return route('/', auth.app ?? new Hono());
429
290
  }
430
291
  /**
431
292
  * Wraps a Tempo API app with a `node:http`-compatible request listener.
@@ -508,10 +369,11 @@ function sortPaths(paths) {
508
369
  }
509
370
  /**
510
371
  * Sets per-operation `security` and the `402` payment-challenge response from
511
- * each route's resolved access lanes (see {@link Auth.describeAccess}). The
512
- * anonymous (`{}`) security option and the `402` response are emitted only where
513
- * the route's policy enables the public and MPP lanes respectively; required
514
- * API-key scopes are surfaced as the `x-required-scopes` extension.
372
+ * each route's resolved access lanes (see {@link Auth.describeAccess}).
373
+ * Security options compose from the enabled lanes API keys (header +
374
+ * bearer), sessions (cookie + bearer token), anonymous (`{}`) and the `402`
375
+ * response is emitted only where the MPP lane is enabled; required API-key
376
+ * scopes are surfaced as the `x-required-scopes` extension.
515
377
  */
516
378
  function applyAccess(paths, access) {
517
379
  for (const item of Object.values(paths)) {
@@ -521,7 +383,13 @@ function applyAccess(paths, access) {
521
383
  const lanes = access[op.operationId];
522
384
  if (!lanes)
523
385
  continue;
524
- op.security = [{ apiKey: [] }, { bearerAuth: [] }, ...(lanes.public ? [{}] : [])];
386
+ const security = [
387
+ ...(lanes.apiKey ? [{ apiKey: [] }, { bearerAuth: [] }] : []),
388
+ ...(lanes.session ? [{ session: [] }, ...(lanes.apiKey ? [] : [{ bearerAuth: [] }])] : []),
389
+ ...(lanes.public ? [{}] : []),
390
+ ];
391
+ if (security.length > 0)
392
+ op.security = security;
525
393
  if (lanes.scopes.length > 0)
526
394
  op['x-required-scopes'] = [...lanes.scopes];
527
395
  if (lanes.mpp)
@@ -538,7 +406,7 @@ function applyAccess(paths, access) {
538
406
  * method/param/return schemas it accepts.
539
407
  *
540
408
  * The public `/openapi.json` keeps a URL reference (small, conventional). The
541
- * docs handler instead receives the document inlined — see `inlineOpenrpc`.
409
+ * docs handler instead inlines the document — see `inlineOpenrpc` in `tapimo/docs`.
542
410
  */
543
411
  function applyOpenrpcLink(paths, basePath) {
544
412
  // `basePath` is `/` at the root mount and `/api` etc. otherwise; strip any
@@ -549,30 +417,6 @@ function applyOpenrpcLink(paths, basePath) {
549
417
  if (isMutableOperation(op) && isRpcOperation(op))
550
418
  op['x-openrpc'] = url;
551
419
  }
552
- /**
553
- * Returns a shallow copy of `spec` with the JSON-RPC passthrough operation's
554
- * `x-openrpc` replaced by the inline OpenRPC document, for the docs handler.
555
- *
556
- * Vocs expands `x-openrpc` at request time. A URL reference (as kept in the
557
- * public `/openapi.json`) would make the docs worker fetch its own
558
- * `/openrpc.json` — a self-subrequest that is unreliable on Cloudflare Workers
559
- * and silently falls back to a single, unexpanded operation. Inlining the
560
- * committed artifact keeps expansion deterministic across local and deployed
561
- * environments, without bloating the public spec. Only the affected path/op are
562
- * cloned; the rest of the (large) document is shared by reference.
563
- */
564
- function inlineOpenrpc(spec) {
565
- const paths = {};
566
- for (const [pathname, item] of Object.entries(spec.paths)) {
567
- let next = item;
568
- if (isRecord(item))
569
- for (const [method, op] of Object.entries(item))
570
- if (isMutableOperation(op) && isRpcOperation(op))
571
- next = { ...item, [method]: { ...op, 'x-openrpc': openrpcSpec } };
572
- paths[pathname] = next;
573
- }
574
- return { ...spec, paths };
575
- }
576
420
  function isRpcOperation(op) {
577
421
  return op.operationId === 'rpcRequest';
578
422
  }
@@ -588,38 +432,6 @@ function isJson(response) {
588
432
  function isRecord(value) {
589
433
  return !!value && typeof value === 'object' && !Array.isArray(value);
590
434
  }
591
- function createGetAsset(options) {
592
- const { assets, basePath, origin } = options;
593
- // Without an asset store, every lookup misses so callers fall back to their
594
- // "no static data" behavior (undefined logo URIs).
595
- if (!assets)
596
- return () => undefined;
597
- return async (chainId, path) => {
598
- // Public URLs include `/assets/:chainId`, but the store is keyed by
599
- // `:chainId/:path` (e.g. an R2 object key), decoupled from the URL shape.
600
- // `path` may be absolute (`Path.join` returns a leading slash); strip it so
601
- // the key is `:chainId/:path`, not `:chainId//:path`.
602
- const pathname = Path.join(basePath, 'assets', String(chainId), path);
603
- const key = `${chainId}/${path.replace(/^\/+/, '')}`;
604
- const asset = await assets.get(key);
605
- if (!asset)
606
- return undefined;
607
- // Return an absolute public URL (scheme + host) against the request origin
608
- // so logo URLs work for any consumer regardless of the API's domain.
609
- return {
610
- response: new globalThis.Response(asset.body, {
611
- headers: { 'Content-Type': asset.contentType },
612
- }),
613
- uri: new URL(pathname, origin).toString(),
614
- };
615
- };
616
- }
617
- function stripAssetPath(path, basePath) {
618
- for (const prefix of [`${Path.join(basePath, 'assets')}/`, '/assets/'])
619
- if (path.startsWith(prefix))
620
- return `/${path.slice(prefix.length)}`;
621
- return path;
622
- }
623
435
  function getRequestListener(fetch) {
624
436
  let listener;
625
437
  return async (incoming_, outgoing_) => {