tapimo 0.5.1 → 0.5.3

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 (120) hide show
  1. package/dist/App.d.ts +34 -18
  2. package/dist/App.d.ts.map +1 -1
  3. package/dist/apps/data/App.d.ts +3217 -3217
  4. package/dist/apps/data/FundingQuoteProviders.d.ts +32 -0
  5. package/dist/apps/data/FundingQuoteProviders.d.ts.map +1 -1
  6. package/dist/apps/data/FundingQuoteProviders.js +134 -1
  7. package/dist/apps/data/FundingQuoteProviders.js.map +1 -1
  8. package/dist/apps/data/routes/balances.d.ts +46 -46
  9. package/dist/apps/data/routes/coingecko.d.ts +169 -169
  10. package/dist/apps/data/routes/funding.d.ts +8 -2
  11. package/dist/apps/data/routes/funding.d.ts.map +1 -1
  12. package/dist/apps/data/routes/funding.js +4 -4
  13. package/dist/apps/data/routes/funding.js.map +1 -1
  14. package/dist/apps/data/routes/indexer.d.ts +34 -34
  15. package/dist/apps/data/routes/receipts.d.ts +228 -228
  16. package/dist/apps/data/routes/transfers.d.ts +8 -15
  17. package/dist/apps/data/routes/transfers.d.ts.map +1 -1
  18. package/dist/apps/data/routes/transfers.js +21 -27
  19. package/dist/apps/data/routes/transfers.js.map +1 -1
  20. package/dist/apps/data/routes/webhooks.d.ts +35 -35
  21. package/dist/apps/data/routes/webhooks.d.ts.map +1 -1
  22. package/dist/apps/data/routes/webhooks.js +176 -42
  23. package/dist/apps/data/routes/webhooks.js.map +1 -1
  24. package/dist/apps/management/App.d.ts +982 -966
  25. package/dist/apps/management/App.d.ts.map +1 -1
  26. package/dist/apps/management/Billing.d.ts.map +1 -1
  27. package/dist/apps/management/Billing.js +5 -4
  28. package/dist/apps/management/Billing.js.map +1 -1
  29. package/dist/apps/management/routes/billing.d.ts.map +1 -1
  30. package/dist/apps/management/routes/billing.js +1 -1
  31. package/dist/apps/management/routes/billing.js.map +1 -1
  32. package/dist/apps/management/routes/invitations.d.ts +121 -121
  33. package/dist/apps/management/routes/orgs.d.ts +102 -86
  34. package/dist/apps/management/routes/orgs.d.ts.map +1 -1
  35. package/dist/apps/management/routes/orgs.js +18 -1
  36. package/dist/apps/management/routes/orgs.js.map +1 -1
  37. package/dist/apps/mcp.d.ts +9 -2
  38. package/dist/apps/mcp.d.ts.map +1 -1
  39. package/dist/apps/mcp.js +9 -4
  40. package/dist/apps/mcp.js.map +1 -1
  41. package/dist/apps/relay/Sponsorships.d.ts +3 -0
  42. package/dist/apps/relay/Sponsorships.d.ts.map +1 -1
  43. package/dist/apps/relay/Sponsorships.js +15 -1
  44. package/dist/apps/relay/Sponsorships.js.map +1 -1
  45. package/dist/cli/Cli.d.ts.map +1 -1
  46. package/dist/cli/Cli.js +7 -2
  47. package/dist/cli/Cli.js.map +1 -1
  48. package/dist/db/Db.d.ts.map +1 -1
  49. package/dist/db/Db.js +4 -0
  50. package/dist/db/Db.js.map +1 -1
  51. package/dist/db/Schema.js +1 -1
  52. package/dist/db/Schema.js.map +1 -1
  53. package/dist/db/tables/organizations.d.ts +6 -0
  54. package/dist/db/tables/organizations.d.ts.map +1 -1
  55. package/dist/db/tables/organizations.js +26 -0
  56. package/dist/db/tables/organizations.js.map +1 -1
  57. package/dist/db/tables/requestUsage.d.ts +2 -11
  58. package/dist/db/tables/requestUsage.d.ts.map +1 -1
  59. package/dist/db/tables/requestUsage.js +1 -20
  60. package/dist/db/tables/requestUsage.js.map +1 -1
  61. package/dist/db/tables/sponsoredTransactions.d.ts +2 -1
  62. package/dist/db/tables/sponsoredTransactions.d.ts.map +1 -1
  63. package/dist/db/tables/sponsoredTransactions.js +46 -8
  64. package/dist/db/tables/sponsoredTransactions.js.map +1 -1
  65. package/dist/internal/Auth.d.ts +4 -0
  66. package/dist/internal/Auth.d.ts.map +1 -1
  67. package/dist/internal/Auth.js +7 -8
  68. package/dist/internal/Auth.js.map +1 -1
  69. package/dist/internal/Cache.d.ts.map +1 -1
  70. package/dist/internal/Cache.js +9 -1
  71. package/dist/internal/Cache.js.map +1 -1
  72. package/dist/internal/EdgeCache.d.ts.map +1 -1
  73. package/dist/internal/EdgeCache.js +12 -3
  74. package/dist/internal/EdgeCache.js.map +1 -1
  75. package/dist/internal/FundingQuotes.d.ts +16 -10
  76. package/dist/internal/FundingQuotes.d.ts.map +1 -1
  77. package/dist/internal/FundingQuotes.js +9 -0
  78. package/dist/internal/FundingQuotes.js.map +1 -1
  79. package/dist/internal/RateLimit.d.ts +2 -0
  80. package/dist/internal/RateLimit.d.ts.map +1 -1
  81. package/dist/internal/RateLimit.js +4 -4
  82. package/dist/internal/RateLimit.js.map +1 -1
  83. package/package.json +7 -2
  84. package/src/App.test.ts +2 -2
  85. package/src/Client.test-d.ts +28 -2
  86. package/src/apps/data/FundingQuoteProviders.test.ts +184 -0
  87. package/src/apps/data/FundingQuoteProviders.ts +185 -1
  88. package/src/apps/data/routes/funding.test.ts +7 -0
  89. package/src/apps/data/routes/funding.ts +4 -4
  90. package/src/apps/data/routes/tokens.test.ts +54 -0
  91. package/src/apps/data/routes/transfers.test.ts +73 -1
  92. package/src/apps/data/routes/transfers.ts +24 -30
  93. package/src/apps/data/routes/webhooks.test.ts +203 -0
  94. package/src/apps/data/routes/webhooks.ts +191 -54
  95. package/src/apps/management/Billing.test.ts +50 -1
  96. package/src/apps/management/Billing.ts +5 -4
  97. package/src/apps/management/routes/billing.ts +6 -1
  98. package/src/apps/management/routes/orgs.ts +19 -1
  99. package/src/apps/mcp.test.ts +13 -0
  100. package/src/apps/mcp.ts +18 -5
  101. package/src/apps/relay/Sponsorships.ts +24 -1
  102. package/src/cli/Cli.test.ts +36 -0
  103. package/src/cli/Cli.ts +7 -2
  104. package/src/db/Db.ts +4 -0
  105. package/src/db/Schema.ts +1 -1
  106. package/src/db/tables/organizations.test.ts +30 -0
  107. package/src/db/tables/organizations.ts +28 -0
  108. package/src/db/tables/requestUsage.ts +3 -23
  109. package/src/db/tables/sponsoredTransactions.test.ts +41 -0
  110. package/src/db/tables/sponsoredTransactions.ts +46 -7
  111. package/src/internal/Auth.test.ts +63 -10
  112. package/src/internal/Auth.ts +11 -9
  113. package/src/internal/Cache.test.ts +19 -0
  114. package/src/internal/Cache.ts +13 -1
  115. package/src/internal/EdgeCache.test.ts +40 -0
  116. package/src/internal/EdgeCache.ts +11 -3
  117. package/src/internal/FundingQuotes.test.ts +33 -0
  118. package/src/internal/FundingQuotes.ts +9 -0
  119. package/src/internal/RateLimit.test.ts +12 -0
  120. package/src/internal/RateLimit.ts +4 -4
@@ -33,12 +33,16 @@ const volatileHeaders = [
33
33
  'cf-cache-status',
34
34
  'content-encoding',
35
35
  'content-length',
36
- 'server-timing',
37
- 'set-cookie',
36
+ 'payment-receipt',
37
+ 'payment-session-snapshot',
38
38
  'ratelimit-limit',
39
39
  'ratelimit-remaining',
40
40
  'ratelimit-reset',
41
+ 'ratelimit-scope',
42
+ 'server-timing',
43
+ 'set-cookie',
41
44
  'tempo-request-id',
45
+ 'www-authenticate',
42
46
  ]
43
47
 
44
48
  /**
@@ -115,6 +119,8 @@ export function middleware<environment extends Env>(
115
119
  if (c.res.status < 200 || c.res.status >= 300) return
116
120
  if (c.res.headers.has('set-cookie')) return
117
121
  if (c.res.headers.get('content-type')?.includes('text/event-stream')) return
122
+ const responseDirectives = (c.res.headers.get('cache-control') ?? '').toLowerCase()
123
+ if (responseDirectives.includes('no-cache') || responseDirectives.includes('no-store')) return
118
124
 
119
125
  // Store a public, sanitized copy; the client still receives the original
120
126
  // (private, metered) response for this miss. Clone synchronously — the
@@ -247,7 +253,9 @@ function isTextual(contentType: string | null): boolean {
247
253
  function cacheKey(requestUrl: string) {
248
254
  const url = new URL(requestUrl)
249
255
  url.searchParams.sort()
250
- return url.toString()
256
+ // Version the key so entries written before a sanitizer change cannot
257
+ // survive the deployment that changes the shared-cache boundary.
258
+ return `edge:v2:${url.toString()}`
251
259
  }
252
260
 
253
261
  function getWaitUntil(c: { executionCtx?: { waitUntil(promise: Promise<unknown>): void } }) {
@@ -235,6 +235,32 @@ describe('listQuoteCandidates', () => {
235
235
 
236
236
  expect(candidate?.id).toBe('tron-usdt-tempo-usdt0-rhino')
237
237
  })
238
+
239
+ test('selects proven Squid stablecoin corridors', () => {
240
+ const candidates = [
241
+ FundingQuotes.listQuoteCandidates({
242
+ destinationToken: 'USDC.e',
243
+ provider: 'squid',
244
+ sourceAmount: '1000000',
245
+ sourceAmountUnits: 'baseUnits',
246
+ sourceChain: 'base',
247
+ sourceToken: 'USDC',
248
+ })[0],
249
+ FundingQuotes.listQuoteCandidates({
250
+ destinationToken: 'USDT0',
251
+ provider: 'squid',
252
+ sourceAmount: '1000000',
253
+ sourceAmountUnits: 'baseUnits',
254
+ sourceChain: 'ethereum',
255
+ sourceToken: 'USDT',
256
+ })[0],
257
+ ]
258
+
259
+ expect(candidates.map((candidate) => candidate?.id)).toEqual([
260
+ 'base-usdc-tempo-usdce-squid',
261
+ 'ethereum-usdt-tempo-usdt0-squid',
262
+ ])
263
+ })
238
264
  })
239
265
 
240
266
  describe('listProviders', () => {
@@ -262,6 +288,13 @@ describe('listProviders', () => {
262
288
  "requiresApiKey": false,
263
289
  "status": "unconfigured",
264
290
  },
291
+ {
292
+ "id": "squid",
293
+ "kind": "solverNetwork",
294
+ "name": "Squid",
295
+ "requiresApiKey": true,
296
+ "status": "unconfigured",
297
+ },
265
298
  ]
266
299
  `)
267
300
  })
@@ -245,6 +245,13 @@ const providers = [
245
245
  requiresApiKey: false,
246
246
  status: 'unconfigured',
247
247
  },
248
+ {
249
+ id: 'squid',
250
+ kind: 'solverNetwork',
251
+ name: 'Squid',
252
+ requiresApiKey: true,
253
+ status: 'unconfigured',
254
+ },
248
255
  ] as const
249
256
 
250
257
  type TokenInput = (typeof sourceChains)[number]['tokens'][number]
@@ -369,7 +376,9 @@ const inventory: readonly InventoryEntry[] = [
369
376
  { destinationToken: 'usdce', provider: 'across', sourceChains: ['ethereum', 'base', 'bnb'], sourceTokens: ['USDC'] }, // prettier-ignore
370
377
  { destinationToken: 'usdce', provider: 'relay', sourceChains: ['ethereum', 'base', 'bnb'], sourceTokens: ['USDC', 'USDT'] }, // prettier-ignore
371
378
  { destinationToken: 'usdce', provider: 'rhino', sourceChains: ['base', 'solana'], sourceTokens: ['USDC'] }, // prettier-ignore
379
+ { destinationToken: 'usdce', provider: 'squid', sourceChains: ['ethereum', 'base', 'bnb'], sourceTokens: ['USDC'] }, // prettier-ignore
372
380
  { destinationToken: 'usdt0', provider: 'rhino', sourceChains: ['tron'], sourceTokens: ['USDT'] }, // prettier-ignore
381
+ { destinationToken: 'usdt0', provider: 'squid', sourceChains: ['ethereum', 'base', 'bnb'], sourceTokens: ['USDT'] }, // prettier-ignore
373
382
  ]
374
383
 
375
384
  type InventoryEntry = {
@@ -130,6 +130,18 @@ describe('edge', () => {
130
130
  expect(ip.limit).toHaveBeenCalledWith({ key: '2001:db8:abcd:12' })
131
131
  })
132
132
 
133
+ test('normalizes equivalent IPv6 addresses to the same /64 prefix', () => {
134
+ expect([
135
+ RateLimit.normalizeIp('2001:0db8:abcd:0012::1'),
136
+ RateLimit.normalizeIp('2001:db8:abcd:12:ffff::2'),
137
+ ]).toMatchInlineSnapshot(`
138
+ [
139
+ "2001:db8:abcd:12",
140
+ "2001:db8:abcd:12",
141
+ ]
142
+ `)
143
+ })
144
+
133
145
  test('returns 429 when any layer denies', async () => {
134
146
  const response = await RateLimit.edge(request({ asn: 64512, ip: '203.0.113.7' }), {
135
147
  asn: binding(false),
@@ -139,12 +139,12 @@ type CfProperties = { asn?: number | undefined }
139
139
  function clientKey(request: Request): string {
140
140
  const ip = request.headers.get('cf-connecting-ip')
141
141
  if (!ip) return 'unknown'
142
- if (ip.includes('.')) return ip
143
- return ipv6Prefix(ip)
142
+ return normalizeIp(ip)
144
143
  }
145
144
 
146
- /** First four hextets of an IPv6 address, with `::` expanded. */
147
- function ipv6Prefix(ip: string): string {
145
+ /** Normalizes an IPv4 address or IPv6 /64 prefix for per-client quotas. */
146
+ export function normalizeIp(ip: string): string {
147
+ if (ip.includes('.')) return ip
148
148
  const [address = ''] = ip.split('%')
149
149
  const [head = '', tail = ''] = address.split('::')
150
150
  const left = head ? head.split(':') : []