tapimo 0.5.3 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/App.d.ts +15830 -7220
- package/dist/App.d.ts.map +1 -1
- package/dist/App.js +9 -1
- package/dist/App.js.map +1 -1
- package/dist/Scope.d.ts +4 -0
- package/dist/Scope.d.ts.map +1 -1
- package/dist/Scope.js +5 -0
- package/dist/Scope.js.map +1 -1
- package/dist/admin/App.d.ts +1011 -412
- package/dist/admin/App.d.ts.map +1 -1
- package/dist/admin/App.js +4 -0
- package/dist/admin/App.js.map +1 -1
- package/dist/admin/apps/api-keys.d.ts +2 -1
- package/dist/admin/apps/api-keys.d.ts.map +1 -1
- package/dist/admin/apps/early-access.d.ts +148 -0
- package/dist/admin/apps/early-access.d.ts.map +1 -0
- package/dist/admin/apps/early-access.js +133 -0
- package/dist/admin/apps/early-access.js.map +1 -0
- package/dist/admin/apps/organizations.d.ts +124 -1
- package/dist/admin/apps/organizations.d.ts.map +1 -1
- package/dist/admin/apps/organizations.js +97 -6
- package/dist/admin/apps/organizations.js.map +1 -1
- package/dist/admin/apps/verified-tokens.d.ts +526 -1
- package/dist/admin/apps/verified-tokens.d.ts.map +1 -1
- package/dist/admin/apps/verified-tokens.js +214 -1
- package/dist/admin/apps/verified-tokens.js.map +1 -1
- package/dist/admin/ui.generated.d.ts +1 -1
- package/dist/admin/ui.generated.d.ts.map +1 -1
- package/dist/admin/ui.generated.js +95 -75
- package/dist/admin/ui.generated.js.map +1 -1
- package/dist/analytics/Analytics.d.ts.map +1 -1
- package/dist/analytics/Analytics.js +20 -0
- package/dist/analytics/Analytics.js.map +1 -1
- package/dist/analytics/tables/requestEvents.d.ts +18 -0
- package/dist/analytics/tables/requestEvents.d.ts.map +1 -1
- package/dist/analytics/tables/requestEvents.js +36 -7
- package/dist/analytics/tables/requestEvents.js.map +1 -1
- package/dist/apps/data/App.d.ts +6260 -4924
- package/dist/apps/data/App.d.ts.map +1 -1
- package/dist/apps/data/App.js +11 -6
- package/dist/apps/data/App.js.map +1 -1
- package/dist/apps/data/FundingQuoteProviders.d.ts +34 -1
- package/dist/apps/data/FundingQuoteProviders.d.ts.map +1 -1
- package/dist/apps/data/FundingQuoteProviders.js +194 -16
- package/dist/apps/data/FundingQuoteProviders.js.map +1 -1
- package/dist/apps/data/FxOracle.d.ts +71 -0
- package/dist/apps/data/FxOracle.d.ts.map +1 -0
- package/dist/apps/data/FxOracle.js +97 -0
- package/dist/apps/data/FxOracle.js.map +1 -0
- package/dist/apps/data/index.d.ts +1 -0
- package/dist/apps/data/index.d.ts.map +1 -1
- package/dist/apps/data/index.js +1 -0
- package/dist/apps/data/index.js.map +1 -1
- package/dist/apps/data/routes/activities.d.ts +3599 -1382
- package/dist/apps/data/routes/activities.d.ts.map +1 -1
- package/dist/apps/data/routes/activities.js +250 -88
- package/dist/apps/data/routes/activities.js.map +1 -1
- package/dist/apps/data/routes/addresses.d.ts +872 -251
- package/dist/apps/data/routes/addresses.d.ts.map +1 -1
- package/dist/apps/data/routes/addresses.js +11 -9
- package/dist/apps/data/routes/addresses.js.map +1 -1
- package/dist/apps/data/routes/balances.d.ts +77 -26
- package/dist/apps/data/routes/balances.d.ts.map +1 -1
- package/dist/apps/data/routes/balances.js +88 -45
- package/dist/apps/data/routes/balances.js.map +1 -1
- package/dist/apps/data/routes/blocks.d.ts +39 -39
- package/dist/apps/data/routes/coingecko.d.ts +54 -54
- package/dist/apps/data/routes/exchanges.d.ts +856 -105
- package/dist/apps/data/routes/exchanges.d.ts.map +1 -1
- package/dist/apps/data/routes/exchanges.js +518 -76
- package/dist/apps/data/routes/exchanges.js.map +1 -1
- package/dist/apps/data/routes/fee-amm.d.ts +81 -67
- package/dist/apps/data/routes/fee-amm.d.ts.map +1 -1
- package/dist/apps/data/routes/fee-amm.js +76 -91
- package/dist/apps/data/routes/fee-amm.js.map +1 -1
- package/dist/apps/data/routes/funding.d.ts +80 -36
- package/dist/apps/data/routes/funding.d.ts.map +1 -1
- package/dist/apps/data/routes/funding.js +65 -31
- package/dist/apps/data/routes/funding.js.map +1 -1
- package/dist/apps/data/routes/receipts.d.ts +392 -315
- package/dist/apps/data/routes/receipts.d.ts.map +1 -1
- package/dist/apps/data/routes/receipts.js +152 -77
- package/dist/apps/data/routes/receipts.js.map +1 -1
- package/dist/apps/data/routes/tokens.d.ts +167 -174
- package/dist/apps/data/routes/tokens.d.ts.map +1 -1
- package/dist/apps/data/routes/tokens.js +15 -13
- package/dist/apps/data/routes/tokens.js.map +1 -1
- package/dist/apps/data/routes/transactions.d.ts +277 -536
- package/dist/apps/data/routes/transactions.d.ts.map +1 -1
- package/dist/apps/data/routes/transactions.js +96 -77
- package/dist/apps/data/routes/transactions.js.map +1 -1
- package/dist/apps/data/routes/transfers.d.ts +157 -81
- package/dist/apps/data/routes/transfers.d.ts.map +1 -1
- package/dist/apps/data/routes/transfers.js +272 -130
- package/dist/apps/data/routes/transfers.js.map +1 -1
- package/dist/apps/data/routes/valuation.d.ts +307 -0
- package/dist/apps/data/routes/valuation.d.ts.map +1 -0
- package/dist/apps/data/routes/valuation.js +292 -0
- package/dist/apps/data/routes/valuation.js.map +1 -0
- package/dist/apps/data/routes/verified-tokens.d.ts +36 -36
- package/dist/apps/data/routes/verified-tokens.d.ts.map +1 -1
- package/dist/apps/data/routes/verified-tokens.js +7 -5
- package/dist/apps/data/routes/verified-tokens.js.map +1 -1
- package/dist/apps/data/routes/webhooks.d.ts +103 -123
- package/dist/apps/data/routes/webhooks.d.ts.map +1 -1
- package/dist/apps/data/routes/webhooks.js +124 -25
- package/dist/apps/data/routes/webhooks.js.map +1 -1
- package/dist/apps/index.d.ts +2 -1
- package/dist/apps/index.d.ts.map +1 -1
- package/dist/apps/index.js +2 -1
- package/dist/apps/index.js.map +1 -1
- package/dist/apps/management/App.d.ts +8554 -1692
- package/dist/apps/management/App.d.ts.map +1 -1
- package/dist/apps/management/App.js +12 -1
- package/dist/apps/management/App.js.map +1 -1
- package/dist/apps/management/routes/api-keys.d.ts +7 -0
- package/dist/apps/management/routes/api-keys.d.ts.map +1 -1
- package/dist/apps/management/routes/api-keys.js +17 -3
- package/dist/apps/management/routes/api-keys.js.map +1 -1
- package/dist/apps/management/routes/billing.d.ts +157 -162
- package/dist/apps/management/routes/billing.d.ts.map +1 -1
- package/dist/apps/management/routes/billing.js +31 -23
- package/dist/apps/management/routes/billing.js.map +1 -1
- package/dist/apps/management/routes/faucet.d.ts +232 -0
- package/dist/apps/management/routes/faucet.d.ts.map +1 -0
- package/dist/apps/management/routes/faucet.js +154 -0
- package/dist/apps/management/routes/faucet.js.map +1 -0
- package/dist/apps/management/routes/invitations.d.ts +60 -60
- package/dist/apps/management/routes/invite-links.d.ts +49 -20
- package/dist/apps/management/routes/invite-links.d.ts.map +1 -1
- package/dist/apps/management/routes/invite-links.js +26 -1
- package/dist/apps/management/routes/invite-links.js.map +1 -1
- package/dist/apps/management/routes/me.d.ts +6 -6
- package/dist/apps/management/routes/members.d.ts +6 -6
- package/dist/apps/management/routes/orgs.d.ts +42 -42
- package/dist/apps/management/routes/orgs.d.ts.map +1 -1
- package/dist/apps/management/routes/orgs.js +5 -0
- package/dist/apps/management/routes/orgs.js.map +1 -1
- package/dist/apps/management/routes/projects.d.ts +44 -44
- package/dist/apps/management/routes/usage.d.ts +3 -0
- package/dist/apps/management/routes/usage.d.ts.map +1 -1
- package/dist/apps/management/routes/usage.js +4 -0
- package/dist/apps/management/routes/usage.js.map +1 -1
- package/dist/apps/management/routes/verified-token-requests.d.ts +697 -0
- package/dist/apps/management/routes/verified-token-requests.d.ts.map +1 -0
- package/dist/apps/management/routes/verified-token-requests.js +271 -0
- package/dist/apps/management/routes/verified-token-requests.js.map +1 -0
- package/dist/apps/management/routes/webhooks.d.ts +6977 -0
- package/dist/apps/management/routes/webhooks.d.ts.map +1 -0
- package/dist/apps/management/routes/webhooks.js +573 -0
- package/dist/apps/management/routes/webhooks.js.map +1 -0
- package/dist/apps/mpp/App.d.ts +363 -0
- package/dist/apps/mpp/App.d.ts.map +1 -0
- package/dist/apps/mpp/App.js +72 -0
- package/dist/apps/mpp/App.js.map +1 -0
- package/dist/apps/mpp/Mpp.d.ts +178 -0
- package/dist/apps/mpp/Mpp.d.ts.map +1 -0
- package/dist/apps/mpp/Mpp.js +183 -0
- package/dist/apps/mpp/Mpp.js.map +1 -0
- package/dist/apps/mpp/index.d.ts +3 -0
- package/dist/apps/mpp/index.d.ts.map +1 -0
- package/dist/apps/mpp/index.js +3 -0
- package/dist/apps/mpp/index.js.map +1 -0
- package/dist/apps/relay/App.d.ts.map +1 -1
- package/dist/apps/relay/App.js +56 -9
- package/dist/apps/relay/App.js.map +1 -1
- package/dist/db/Db.d.ts +6 -0
- package/dist/db/Db.d.ts.map +1 -1
- package/dist/db/Db.js +110 -0
- package/dist/db/Db.js.map +1 -1
- package/dist/db/Schema.d.ts +53 -0
- package/dist/db/Schema.d.ts.map +1 -1
- package/dist/db/Schema.js +56 -0
- package/dist/db/Schema.js.map +1 -1
- package/dist/db/tables/earlyAccess.d.ts +50 -0
- package/dist/db/tables/earlyAccess.d.ts.map +1 -0
- package/dist/db/tables/earlyAccess.js +63 -0
- package/dist/db/tables/earlyAccess.js.map +1 -0
- package/dist/db/tables/enabledBillingSources.d.ts +73 -0
- package/dist/db/tables/enabledBillingSources.d.ts.map +1 -0
- package/dist/db/tables/enabledBillingSources.js +69 -0
- package/dist/db/tables/enabledBillingSources.js.map +1 -0
- package/dist/db/tables/invitations.d.ts.map +1 -1
- package/dist/db/tables/invitations.js +3 -0
- package/dist/db/tables/invitations.js.map +1 -1
- package/dist/db/tables/inviteLinks.d.ts +10 -2
- package/dist/db/tables/inviteLinks.d.ts.map +1 -1
- package/dist/db/tables/inviteLinks.js +10 -1
- package/dist/db/tables/inviteLinks.js.map +1 -1
- package/dist/db/tables/organizations.d.ts +5 -2
- package/dist/db/tables/organizations.d.ts.map +1 -1
- package/dist/db/tables/organizations.js +13 -2
- package/dist/db/tables/organizations.js.map +1 -1
- package/dist/db/tables/sponsoredTransactions.d.ts +2 -0
- package/dist/db/tables/sponsoredTransactions.d.ts.map +1 -1
- package/dist/db/tables/sponsoredTransactions.js +2 -0
- package/dist/db/tables/sponsoredTransactions.js.map +1 -1
- package/dist/db/tables/verifiedTokenRequests.d.ts +94 -0
- package/dist/db/tables/verifiedTokenRequests.d.ts.map +1 -0
- package/dist/db/tables/verifiedTokenRequests.js +120 -0
- package/dist/db/tables/verifiedTokenRequests.js.map +1 -0
- package/dist/db/tables/webhookSubscriptions.d.ts +14 -0
- package/dist/db/tables/webhookSubscriptions.d.ts.map +1 -1
- package/dist/db/tables/webhookSubscriptions.js +16 -0
- package/dist/db/tables/webhookSubscriptions.js.map +1 -1
- package/dist/handlers/internal/utils.d.ts +1 -16
- package/dist/handlers/internal/utils.d.ts.map +1 -1
- package/dist/handlers/internal/utils.js +17 -6
- package/dist/handlers/internal/utils.js.map +1 -1
- package/dist/handlers/relay.d.ts.map +1 -1
- package/dist/handlers/relay.js +37 -5
- package/dist/handlers/relay.js.map +1 -1
- package/dist/internal/Auth.d.ts +11 -2
- package/dist/internal/Auth.d.ts.map +1 -1
- package/dist/internal/Auth.js +14 -47
- package/dist/internal/Auth.js.map +1 -1
- package/dist/internal/FundingQuotes.d.ts +147 -47
- package/dist/internal/FundingQuotes.d.ts.map +1 -1
- package/dist/internal/FundingQuotes.js +119 -33
- package/dist/internal/FundingQuotes.js.map +1 -1
- package/dist/internal/Log.d.ts +37 -5
- package/dist/internal/Log.d.ts.map +1 -1
- package/dist/internal/Log.js +52 -3
- package/dist/internal/Log.js.map +1 -1
- package/dist/internal/MetricSink.d.ts.map +1 -1
- package/dist/internal/MetricSink.js +24 -0
- package/dist/internal/MetricSink.js.map +1 -1
- package/dist/internal/OpenApi.d.ts +2 -2
- package/dist/internal/OpenApi.d.ts.map +1 -1
- package/dist/internal/OpenApi.js +3 -0
- package/dist/internal/OpenApi.js.map +1 -1
- package/dist/internal/Response.d.ts +2 -2
- package/dist/internal/Response.d.ts.map +1 -1
- package/dist/internal/Response.js +12 -4
- package/dist/internal/Response.js.map +1 -1
- package/dist/internal/Schema.d.ts +14 -5
- package/dist/internal/Schema.d.ts.map +1 -1
- package/dist/internal/Schema.js +23 -5
- package/dist/internal/Schema.js.map +1 -1
- package/dist/internal/Value.d.ts +18 -0
- package/dist/internal/Value.d.ts.map +1 -1
- package/dist/internal/Value.js +11 -1
- package/dist/internal/Value.js.map +1 -1
- package/dist/internal/VerifiedTokens.d.ts.map +1 -1
- package/dist/internal/VerifiedTokens.js +10 -1
- package/dist/internal/VerifiedTokens.js.map +1 -1
- package/dist/internal/Webhooks.d.ts +24 -3
- package/dist/internal/Webhooks.d.ts.map +1 -1
- package/dist/internal/Webhooks.js +34 -8
- package/dist/internal/Webhooks.js.map +1 -1
- package/package.json +7 -2
- package/src/App.test.ts +9 -4
- package/src/App.ts +23 -3
- package/src/Client.test-d.ts +733 -20
- package/src/Scope.ts +5 -0
- package/src/admin/App.test.ts +4 -0
- package/src/admin/App.ts +4 -0
- package/src/admin/apps/early-access.test.ts +125 -0
- package/src/admin/apps/early-access.ts +176 -0
- package/src/admin/apps/organizations.test.ts +86 -2
- package/src/admin/apps/organizations.ts +155 -31
- package/src/admin/apps/scopes.test.ts +5 -0
- package/src/admin/apps/verified-tokens.test.ts +201 -0
- package/src/admin/apps/verified-tokens.ts +532 -286
- package/src/admin/ui/plugin.ts +2 -1
- package/src/admin/ui/src/lib/early-access.ts +63 -0
- package/src/admin/ui/src/lib/organizations.test.ts +81 -1
- package/src/admin/ui/src/lib/organizations.ts +92 -0
- package/src/admin/ui/src/lib/verified-tokens.ts +79 -0
- package/src/admin/ui/src/routeTree.gen.ts +33 -2
- package/src/admin/ui/src/routes/__root.tsx +2 -1
- package/src/admin/ui/src/routes/api-keys.tsx +1 -1
- package/src/admin/ui/src/routes/early-access.tsx +162 -0
- package/src/admin/ui/src/routes/organizations_.$orgId.tsx +103 -0
- package/src/admin/ui/src/routes/verified-tokens.tsx +230 -19
- package/src/admin/ui.generated.ts +95 -94
- package/src/analytics/Analytics.test.ts +83 -0
- package/src/analytics/Analytics.ts +20 -0
- package/src/analytics/tables/requestEvents.ts +60 -7
- package/src/apps/composition.test.ts +11 -2
- package/src/apps/data/App.test.ts +1 -1
- package/src/apps/data/App.ts +22 -14
- package/src/apps/data/FundingQuoteProviders.test.ts +297 -4
- package/src/apps/data/FundingQuoteProviders.ts +255 -29
- package/src/apps/data/FxOracle.test.ts +118 -0
- package/src/apps/data/FxOracle.ts +153 -0
- package/src/apps/data/index.ts +1 -0
- package/src/apps/data/routes/activities.test.ts +177 -3
- package/src/apps/data/routes/activities.ts +441 -132
- package/src/apps/data/routes/addresses.ts +19 -9
- package/src/apps/data/routes/balances.test.ts +148 -11
- package/src/apps/data/routes/balances.ts +140 -51
- package/src/apps/data/routes/exchanges.test.ts +544 -9
- package/src/apps/data/routes/exchanges.ts +690 -103
- package/src/apps/data/routes/fee-amm.test.ts +47 -23
- package/src/apps/data/routes/fee-amm.ts +98 -119
- package/src/apps/data/routes/funding.test.ts +113 -8
- package/src/apps/data/routes/funding.ts +77 -51
- package/src/apps/data/routes/receipts.test.ts +129 -23
- package/src/apps/data/routes/receipts.ts +205 -100
- package/src/apps/data/routes/tokens.test.ts +43 -0
- package/src/apps/data/routes/tokens.ts +28 -13
- package/src/apps/data/routes/transactions.test.ts +72 -19
- package/src/apps/data/routes/transactions.ts +162 -92
- package/src/apps/data/routes/transfers.test.ts +341 -31
- package/src/apps/data/routes/transfers.ts +358 -158
- package/src/apps/data/routes/valuation.test.ts +437 -0
- package/src/apps/data/routes/valuation.ts +423 -0
- package/src/apps/data/routes/verified-tokens.ts +14 -2
- package/src/apps/data/routes/webhooks.test.ts +56 -8
- package/src/apps/data/routes/webhooks.ts +144 -27
- package/src/apps/index.ts +2 -1
- package/src/apps/management/App.ts +13 -0
- package/src/apps/management/routes/api-keys.test.ts +14 -0
- package/src/apps/management/routes/api-keys.ts +27 -3
- package/src/apps/management/routes/billing.test.ts +152 -20
- package/src/apps/management/routes/billing.ts +34 -18
- package/src/apps/management/routes/faucet.test.ts +87 -0
- package/src/apps/management/routes/faucet.ts +201 -0
- package/src/apps/management/routes/invite-links.test.ts +117 -0
- package/src/apps/management/routes/invite-links.ts +43 -1
- package/src/apps/management/routes/me.test.ts +9 -99
- package/src/apps/management/routes/orgs.test.ts +45 -2
- package/src/apps/management/routes/orgs.ts +6 -0
- package/src/apps/management/routes/scopes.test.ts +1 -0
- package/src/apps/management/routes/usage.test.ts +6 -0
- package/src/apps/management/routes/usage.ts +7 -0
- package/src/apps/management/routes/verified-token-requests.test.ts +377 -0
- package/src/apps/management/routes/verified-token-requests.ts +397 -0
- package/src/apps/management/routes/webhooks.test.ts +426 -0
- package/src/apps/management/routes/webhooks.ts +672 -0
- package/src/apps/mpp/App.ts +86 -0
- package/src/apps/mpp/Mpp.test.ts +193 -0
- package/src/apps/mpp/Mpp.ts +353 -0
- package/src/apps/mpp/index.ts +2 -0
- package/src/apps/mpp/internal/Adapter.ts +11 -0
- package/src/apps/mpp/internal/Error.ts +9 -0
- package/src/apps/mpp/internal/Idempotency.ts +7 -0
- package/src/apps/mpp/internal/Screening.ts +10 -0
- package/src/apps/relay/App.test.ts +88 -6
- package/src/apps/relay/App.ts +61 -9
- package/src/db/Db.test.ts +19 -0
- package/src/db/Db.ts +125 -0
- package/src/db/Schema.ts +68 -0
- package/src/db/tables/earlyAccess.ts +86 -0
- package/src/db/tables/enabledBillingSources.test.ts +303 -0
- package/src/db/tables/enabledBillingSources.ts +118 -0
- package/src/db/tables/invitations.ts +3 -0
- package/src/db/tables/inviteLinks.ts +22 -3
- package/src/db/tables/organizations.test.ts +103 -0
- package/src/db/tables/organizations.ts +18 -2
- package/src/db/tables/sponsoredTransactions.ts +4 -0
- package/src/db/tables/verifiedTokenRequests.test.ts +200 -0
- package/src/db/tables/verifiedTokenRequests.ts +182 -0
- package/src/db/tables/webhookSubscriptions.ts +31 -0
- package/src/handlers/internal/utils.ts +22 -6
- package/src/handlers/relay.errors.test.ts +153 -0
- package/src/handlers/relay.ts +42 -7
- package/src/internal/Auth.test.ts +3 -3
- package/src/internal/Auth.ts +15 -47
- package/src/internal/FundingQuotes.test.ts +161 -6
- package/src/internal/FundingQuotes.ts +141 -39
- package/src/internal/Log.test-d.ts +21 -0
- package/src/internal/Log.test.ts +141 -0
- package/src/internal/Log.ts +93 -6
- package/src/internal/MetricSink.test.ts +215 -0
- package/src/internal/MetricSink.ts +24 -0
- package/src/internal/OpenApi.ts +3 -0
- package/src/internal/Response.test.ts +28 -0
- package/src/internal/Response.ts +12 -4
- package/src/internal/Schema.ts +50 -5
- package/src/internal/Value.test.ts +20 -0
- package/src/internal/Value.ts +24 -1
- package/src/internal/VerifiedTokens.ts +9 -1
- package/src/internal/Webhooks.test.ts +140 -0
- package/src/internal/Webhooks.ts +53 -9
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { Hono } from 'hono'
|
|
2
|
+
import type * as z from 'zod/mini'
|
|
3
|
+
|
|
4
|
+
import type * as App from '../../App.js'
|
|
5
|
+
import * as Auth from '../../internal/Auth.js'
|
|
6
|
+
import * as OpenApi from '../../internal/OpenApi.js'
|
|
7
|
+
import * as Metadata from '../metadata.js'
|
|
8
|
+
import * as Mpp from './Mpp.js'
|
|
9
|
+
|
|
10
|
+
/** Mounts MPP credential verification and broadcast routes. */
|
|
11
|
+
export function mpp() {
|
|
12
|
+
const app = new Hono<App.Environment>()
|
|
13
|
+
.post(
|
|
14
|
+
'/v1/mpp/verify',
|
|
15
|
+
Auth.policy({ apiKey: { scopes: ['mpp:write'] }, mpp: false, public: false }),
|
|
16
|
+
OpenApi.validate('json', Mpp.schema.RelayInput, bodyValidation),
|
|
17
|
+
OpenApi.describeRoute({
|
|
18
|
+
operationId: 'verifyMppCredential',
|
|
19
|
+
responses: responses({
|
|
20
|
+
description: 'The MPP credential validation result.',
|
|
21
|
+
schema: Mpp.schema.VerifyResponse,
|
|
22
|
+
}),
|
|
23
|
+
summary: 'Verify MPP credential',
|
|
24
|
+
tags: ['MPP Relay'],
|
|
25
|
+
}),
|
|
26
|
+
(c) => {
|
|
27
|
+
if (Auth.narrowAccess) return Auth.accessError(c)
|
|
28
|
+
if (OpenApi.narrowValidation) return OpenApi.validationError(c, bodyValidation)
|
|
29
|
+
return Mpp.unavailable<Mpp.VerifyResponse>(c)
|
|
30
|
+
},
|
|
31
|
+
)
|
|
32
|
+
.post(
|
|
33
|
+
'/v1/mpp/broadcast',
|
|
34
|
+
Auth.policy({ apiKey: { scopes: ['mpp:write'] }, mpp: false, public: false }),
|
|
35
|
+
OpenApi.validate('json', Mpp.schema.RelayInput, bodyValidation),
|
|
36
|
+
OpenApi.describeRoute({
|
|
37
|
+
operationId: 'broadcastMppCredential',
|
|
38
|
+
responses: responses({
|
|
39
|
+
description: 'The MPP credential broadcast result.',
|
|
40
|
+
schema: Mpp.schema.BroadcastResponse,
|
|
41
|
+
}),
|
|
42
|
+
summary: 'Broadcast MPP credential',
|
|
43
|
+
tags: ['MPP Relay'],
|
|
44
|
+
}),
|
|
45
|
+
(c) => {
|
|
46
|
+
if (Auth.narrowAccess) return Auth.accessError(c)
|
|
47
|
+
if (OpenApi.narrowValidation) return OpenApi.validationError(c, bodyValidation)
|
|
48
|
+
return Mpp.unavailable<Mpp.BroadcastResponse>(c)
|
|
49
|
+
},
|
|
50
|
+
)
|
|
51
|
+
return Metadata.attach(app, openapi)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const bodyValidation = {
|
|
55
|
+
code: 'body_invalid',
|
|
56
|
+
message: 'Check the MPP credential and challenge, then try again.',
|
|
57
|
+
} as const
|
|
58
|
+
|
|
59
|
+
function responses<schema extends z.ZodMiniType>(options: { description: string; schema: schema }) {
|
|
60
|
+
return {
|
|
61
|
+
...OpenApi.responses({
|
|
62
|
+
errors: { 403: 'The API key does not grant MPP relay access.' },
|
|
63
|
+
success: options,
|
|
64
|
+
}),
|
|
65
|
+
503: {
|
|
66
|
+
content: { 'application/json': { schema: OpenApi.resolver(Mpp.schema.Unavailable) } },
|
|
67
|
+
description: 'MPP relay settlement is temporarily unavailable.',
|
|
68
|
+
headers: {
|
|
69
|
+
'Retry-After': {
|
|
70
|
+
description: 'How many seconds to wait before retrying the relay.',
|
|
71
|
+
schema: { type: 'integer' as const },
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const openapi = {
|
|
79
|
+
tags: [
|
|
80
|
+
{
|
|
81
|
+
name: 'MPP Relay',
|
|
82
|
+
description: 'Validate and broadcast MPP payment credentials through Tempo.',
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
'x-tagGroups': [{ name: 'Payments', tags: ['MPP Relay'] }],
|
|
86
|
+
} satisfies App.create.Metadata
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import * as TestApp from '../../../test/App.js'
|
|
2
|
+
import * as Mpp from './Mpp.js'
|
|
3
|
+
|
|
4
|
+
const key = {
|
|
5
|
+
id: 'key_mpp',
|
|
6
|
+
orgId: 'org_test',
|
|
7
|
+
scopes: ['mpp:write'],
|
|
8
|
+
token: 'secret_mpp',
|
|
9
|
+
} satisfies TestApp.kvStore.Key
|
|
10
|
+
|
|
11
|
+
const input = {
|
|
12
|
+
challenge: {
|
|
13
|
+
description: 'Tempo API payment',
|
|
14
|
+
id: 'ch_01j3j1k2l3m4n5p6q7r8s9t0u',
|
|
15
|
+
intent: 'charge',
|
|
16
|
+
method: 'tempo',
|
|
17
|
+
opaque: 'eyJhbGciOiJIUzI1NiJ9',
|
|
18
|
+
realm: 'merchant.example',
|
|
19
|
+
request: { amount: '1', currency: 'USD' },
|
|
20
|
+
},
|
|
21
|
+
payload: { signature: `0x${'aa'.repeat(65)}`, type: 'transaction' },
|
|
22
|
+
} satisfies Mpp.RelayInput
|
|
23
|
+
|
|
24
|
+
const errorCodes = [
|
|
25
|
+
'unsupported',
|
|
26
|
+
'policy_denied',
|
|
27
|
+
'invalid_payment',
|
|
28
|
+
'insufficient_funds',
|
|
29
|
+
'expired',
|
|
30
|
+
'already_used',
|
|
31
|
+
'screen_rejected',
|
|
32
|
+
'simulation_failed',
|
|
33
|
+
'broadcast_failed',
|
|
34
|
+
'temporarily_unavailable',
|
|
35
|
+
'unknown',
|
|
36
|
+
] as const
|
|
37
|
+
|
|
38
|
+
const errorDescriptions = [
|
|
39
|
+
'Method, intent, network, or asset is unsupported.',
|
|
40
|
+
'Payment violates relay or account policy.',
|
|
41
|
+
'Payload, signature, parties, or payment requirements are invalid.',
|
|
42
|
+
'Sender lacks funds.',
|
|
43
|
+
'Challenge or payment authorization expired.',
|
|
44
|
+
'Credential or transaction already used.',
|
|
45
|
+
'Originator or recipient failed screening.',
|
|
46
|
+
'Transaction simulation failed before broadcast.',
|
|
47
|
+
'Transaction broadcast or confirmation failed.',
|
|
48
|
+
'Retry may succeed.',
|
|
49
|
+
'Unexpected relay failure.',
|
|
50
|
+
] as const
|
|
51
|
+
|
|
52
|
+
describe('MPP relay', () => {
|
|
53
|
+
test.each(['/v1/mpp/verify', '/v1/mpp/broadcast'])('%s requires the MPP scope', async (path) => {
|
|
54
|
+
const app = TestApp.create({ auth: { keys: [key] } })
|
|
55
|
+
const response = await app.fetch(
|
|
56
|
+
new Request(`http://tempo-api.test${path}`, {
|
|
57
|
+
body: JSON.stringify(input),
|
|
58
|
+
headers: { 'content-type': 'application/json', authorization: 'Bearer secret_mpp' },
|
|
59
|
+
method: 'POST',
|
|
60
|
+
}),
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
expect(response.status).toBe(503)
|
|
64
|
+
expect(response.headers.get('retry-after')).toBe('60')
|
|
65
|
+
expect(await response.json()).toMatchInlineSnapshot(`
|
|
66
|
+
{
|
|
67
|
+
"error": {
|
|
68
|
+
"code": "temporarily_unavailable",
|
|
69
|
+
"message": "MPP relay is not enabled yet.",
|
|
70
|
+
},
|
|
71
|
+
"success": false,
|
|
72
|
+
}
|
|
73
|
+
`)
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
test('rejects unscoped API keys', async () => {
|
|
77
|
+
const app = TestApp.create({ auth: { keys: [key, TestApp.key] } })
|
|
78
|
+
const response = await app.fetch(
|
|
79
|
+
new Request('http://tempo-api.test/v1/mpp/verify', {
|
|
80
|
+
body: JSON.stringify(input),
|
|
81
|
+
headers: {
|
|
82
|
+
'content-type': 'application/json',
|
|
83
|
+
authorization: `Bearer ${TestApp.key.token}`,
|
|
84
|
+
},
|
|
85
|
+
method: 'POST',
|
|
86
|
+
}),
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
expect(response.status).toBe(403)
|
|
90
|
+
expect(await response.json()).toMatchObject({ error: { code: 'api_key_forbidden' } })
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
test('requires API-key authentication', async () => {
|
|
94
|
+
const app = TestApp.create()
|
|
95
|
+
const response = await app.fetch(
|
|
96
|
+
new Request('http://tempo-api.test/v1/mpp/verify', {
|
|
97
|
+
body: JSON.stringify(input),
|
|
98
|
+
headers: { 'content-type': 'application/json' },
|
|
99
|
+
method: 'POST',
|
|
100
|
+
}),
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
expect(response.status).toBe(401)
|
|
104
|
+
expect(await response.json()).toMatchObject({ error: { code: 'api_key_missing' } })
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
test.each(['/v1/mpp/verify', '/v1/mpp/broadcast'])(
|
|
108
|
+
'%s rejects malformed credential input before the disabled handler',
|
|
109
|
+
async (path) => {
|
|
110
|
+
const app = TestApp.create({ auth: { keys: [key] } })
|
|
111
|
+
const response = await app.fetch(
|
|
112
|
+
new Request(`http://tempo-api.test${path}`, {
|
|
113
|
+
body: JSON.stringify({}),
|
|
114
|
+
headers: { 'content-type': 'application/json', authorization: 'Bearer secret_mpp' },
|
|
115
|
+
method: 'POST',
|
|
116
|
+
}),
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
expect(response.status).toBe(400)
|
|
120
|
+
expect(await response.json()).toMatchObject({ error: { code: 'body_invalid' } })
|
|
121
|
+
},
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
test.each(['/v1/mpp/verify', '/v1/mpp/broadcast'])(
|
|
125
|
+
'%s requires a credential payload',
|
|
126
|
+
async (path) => {
|
|
127
|
+
const app = TestApp.create({ auth: { keys: [key] } })
|
|
128
|
+
const response = await app.fetch(
|
|
129
|
+
new Request(`http://tempo-api.test${path}`, {
|
|
130
|
+
body: JSON.stringify({ challenge: input.challenge }),
|
|
131
|
+
headers: { 'content-type': 'application/json', authorization: 'Bearer secret_mpp' },
|
|
132
|
+
method: 'POST',
|
|
133
|
+
}),
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
expect(response.status).toBe(400)
|
|
137
|
+
expect(await response.json()).toMatchObject({ error: { code: 'body_invalid' } })
|
|
138
|
+
},
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
test('publishes the MPP endpoints', async () => {
|
|
142
|
+
const app = TestApp.create()
|
|
143
|
+
const spec = (await (await app.request('/openapi.json')).json()) as {
|
|
144
|
+
paths: Record<string, { post?: { responses?: Record<string, unknown> } }>
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
for (const path of ['/v1/mpp/verify', '/v1/mpp/broadcast']) {
|
|
148
|
+
expect(spec.paths[path]?.post?.responses?.['200']).toBeDefined()
|
|
149
|
+
expect(spec.paths[path]?.post?.responses?.['503']).toBeDefined()
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const response = JSON.stringify(spec.paths['/v1/mpp/verify']?.post?.responses?.['200'])
|
|
153
|
+
for (const description of errorDescriptions) expect(response).toContain(description)
|
|
154
|
+
})
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
describe('MPP relay schemas', () => {
|
|
158
|
+
test('parses public relay contracts', () => {
|
|
159
|
+
expect(Mpp.schema.RelayInput.parse(input)).toEqual(input)
|
|
160
|
+
expect(Mpp.schema.VerifyResponse.parse({ success: true })).toEqual({ success: true })
|
|
161
|
+
expect(
|
|
162
|
+
Mpp.schema.BroadcastResponse.parse({
|
|
163
|
+
receipt: {
|
|
164
|
+
method: 'tempo',
|
|
165
|
+
reference: `0x${'22'.repeat(32)}`,
|
|
166
|
+
timestamp: '2026-07-20T18:30:00.000Z',
|
|
167
|
+
},
|
|
168
|
+
success: true,
|
|
169
|
+
}),
|
|
170
|
+
).toMatchInlineSnapshot(`
|
|
171
|
+
{
|
|
172
|
+
"receipt": {
|
|
173
|
+
"method": "tempo",
|
|
174
|
+
"reference": "0x2222222222222222222222222222222222222222222222222222222222222222",
|
|
175
|
+
"timestamp": "2026-07-20T18:30:00.000Z",
|
|
176
|
+
},
|
|
177
|
+
"success": true,
|
|
178
|
+
}
|
|
179
|
+
`)
|
|
180
|
+
})
|
|
181
|
+
|
|
182
|
+
test.each(errorCodes)('accepts the %s error code', (code) => {
|
|
183
|
+
expect(Mpp.schema.RelayError.parse({ code })).toEqual({ code })
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
test('publishes the relay error code type', () => {
|
|
187
|
+
expectTypeOf<Mpp.RelayErrorCode>().toEqualTypeOf<(typeof errorCodes)[number]>()
|
|
188
|
+
})
|
|
189
|
+
|
|
190
|
+
test('rejects an unknown error code', () => {
|
|
191
|
+
expect(Mpp.schema.RelayError.safeParse({ code: 'unexpected' }).success).toBe(false)
|
|
192
|
+
})
|
|
193
|
+
})
|
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
import type { Context, TypedResponse } from 'hono'
|
|
2
|
+
import * as z from 'zod/mini'
|
|
3
|
+
|
|
4
|
+
import type * as App from '../../App.js'
|
|
5
|
+
import * as Response from '../../internal/Response.js'
|
|
6
|
+
import * as Schema from '../../internal/Schema.js'
|
|
7
|
+
|
|
8
|
+
/** Stable MPP relay failure codes. */
|
|
9
|
+
export const relayErrorCode = {
|
|
10
|
+
/** Credential or transaction already used. */
|
|
11
|
+
alreadyUsed: 'already_used',
|
|
12
|
+
/** Transaction broadcast or confirmation failed. */
|
|
13
|
+
broadcastFailed: 'broadcast_failed',
|
|
14
|
+
/** Challenge or payment authorization expired. */
|
|
15
|
+
expired: 'expired',
|
|
16
|
+
/** Payload, signature, parties, or payment requirements are invalid. */
|
|
17
|
+
invalidPayment: 'invalid_payment',
|
|
18
|
+
/** Sender lacks funds. */
|
|
19
|
+
insufficientFunds: 'insufficient_funds',
|
|
20
|
+
/** Payment violates relay or account policy. */
|
|
21
|
+
policyDenied: 'policy_denied',
|
|
22
|
+
/** Originator or recipient failed screening. */
|
|
23
|
+
screenRejected: 'screen_rejected',
|
|
24
|
+
/** Transaction simulation failed before broadcast. */
|
|
25
|
+
simulationFailed: 'simulation_failed',
|
|
26
|
+
/** Retry may succeed. */
|
|
27
|
+
temporarilyUnavailable: 'temporarily_unavailable',
|
|
28
|
+
/** Method, intent, network, or asset is unsupported. */
|
|
29
|
+
unsupported: 'unsupported',
|
|
30
|
+
/** Unexpected relay failure. */
|
|
31
|
+
unknown: 'unknown',
|
|
32
|
+
} as const
|
|
33
|
+
|
|
34
|
+
/** Stable MPP relay failure code. */
|
|
35
|
+
export type RelayErrorCode = (typeof relayErrorCode)[keyof typeof relayErrorCode]
|
|
36
|
+
|
|
37
|
+
/** MPP relay error response. */
|
|
38
|
+
export type RelayError = {
|
|
39
|
+
/** Stable machine-readable reason the relay rejected the credential. */
|
|
40
|
+
code: RelayErrorCode
|
|
41
|
+
/** Human-readable explanation of the relay result. */
|
|
42
|
+
message?: string | undefined
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** MPP challenge accepted with a relay credential payload. */
|
|
46
|
+
export type Challenge = {
|
|
47
|
+
/** Additional MPP challenge metadata, preserved verbatim for validation. */
|
|
48
|
+
[key: string]: unknown
|
|
49
|
+
/** Human-readable payment description. */
|
|
50
|
+
description?: string | undefined
|
|
51
|
+
/** When the payment challenge expires, as an ISO-8601 timestamp. */
|
|
52
|
+
expires?: string | undefined
|
|
53
|
+
/** Payment challenge identifier. */
|
|
54
|
+
id: string
|
|
55
|
+
/** MPP payment intent. */
|
|
56
|
+
intent: string
|
|
57
|
+
/** MPP payment method. */
|
|
58
|
+
method: string
|
|
59
|
+
/** Opaque data bound to the challenge by its issuer. */
|
|
60
|
+
opaque?: string | undefined
|
|
61
|
+
/** MPP realm that issued the challenge. */
|
|
62
|
+
realm: string
|
|
63
|
+
/** Payment request bound to the challenge. */
|
|
64
|
+
request: Record<string, unknown>
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** MPP challenge and credential payload accepted by the relay. */
|
|
68
|
+
export type RelayInput = {
|
|
69
|
+
/** Payment challenge supplied with the credential. */
|
|
70
|
+
challenge: Challenge
|
|
71
|
+
/** Method-specific MPP credential payload. */
|
|
72
|
+
payload: unknown
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Broadcast MPP payment receipt. */
|
|
76
|
+
export type Receipt = {
|
|
77
|
+
/** Optional caller-provided payment reference. */
|
|
78
|
+
externalId?: string | undefined
|
|
79
|
+
/** Payment method that settled the credential. */
|
|
80
|
+
method: string
|
|
81
|
+
/** On-chain or payment-system settlement reference. */
|
|
82
|
+
reference: string
|
|
83
|
+
/** When the payment settled, as an ISO-8601 timestamp. */
|
|
84
|
+
timestamp: string
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** MPP credential validation response. */
|
|
88
|
+
export type VerifyResponse = { success: true } | { error: RelayError; success: false }
|
|
89
|
+
|
|
90
|
+
/** MPP credential broadcast response. */
|
|
91
|
+
export type BroadcastResponse =
|
|
92
|
+
| { receipt: Receipt; success: true }
|
|
93
|
+
| { error: RelayError; success: false }
|
|
94
|
+
|
|
95
|
+
/** Retryable response returned while relay settlement is disabled. */
|
|
96
|
+
export type Unavailable = {
|
|
97
|
+
error: { code: 'temporarily_unavailable'; message: 'MPP relay is not enabled yet.' }
|
|
98
|
+
success: false
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function errorCode<const code extends RelayErrorCode>(value: code, description: string) {
|
|
102
|
+
return z.literal(value).check(z.describe(description), z.meta({ examples: [value] }))
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** MPP relay schemas. */
|
|
106
|
+
export namespace schema {
|
|
107
|
+
/** Stable MPP relay failure codes. */
|
|
108
|
+
export const ErrorCode = Schema.describe(
|
|
109
|
+
z.union([
|
|
110
|
+
errorCode(relayErrorCode.unsupported, 'Method, intent, network, or asset is unsupported.'),
|
|
111
|
+
errorCode(relayErrorCode.policyDenied, 'Payment violates relay or account policy.'),
|
|
112
|
+
errorCode(
|
|
113
|
+
relayErrorCode.invalidPayment,
|
|
114
|
+
'Payload, signature, parties, or payment requirements are invalid.',
|
|
115
|
+
),
|
|
116
|
+
errorCode(relayErrorCode.insufficientFunds, 'Sender lacks funds.'),
|
|
117
|
+
errorCode(relayErrorCode.expired, 'Challenge or payment authorization expired.'),
|
|
118
|
+
errorCode(relayErrorCode.alreadyUsed, 'Credential or transaction already used.'),
|
|
119
|
+
errorCode(relayErrorCode.screenRejected, 'Originator or recipient failed screening.'),
|
|
120
|
+
errorCode(relayErrorCode.simulationFailed, 'Transaction simulation failed before broadcast.'),
|
|
121
|
+
errorCode(relayErrorCode.broadcastFailed, 'Transaction broadcast or confirmation failed.'),
|
|
122
|
+
errorCode(relayErrorCode.temporarilyUnavailable, 'Retry may succeed.'),
|
|
123
|
+
errorCode(relayErrorCode.unknown, 'Unexpected relay failure.'),
|
|
124
|
+
]),
|
|
125
|
+
'A stable machine-readable reason the MPP relay rejected or could not process a payment.',
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
/** Error returned by the MPP relay. */
|
|
129
|
+
export const RelayError = Schema.describe(
|
|
130
|
+
z
|
|
131
|
+
.object({
|
|
132
|
+
code: ErrorCode,
|
|
133
|
+
message: z
|
|
134
|
+
.optional(z.string())
|
|
135
|
+
.check(
|
|
136
|
+
z.describe('A human-readable explanation of the relay result.'),
|
|
137
|
+
z.meta({ examples: ['MPP relay is not enabled yet.'] }),
|
|
138
|
+
),
|
|
139
|
+
})
|
|
140
|
+
.check(
|
|
141
|
+
z.meta({
|
|
142
|
+
examples: [
|
|
143
|
+
{
|
|
144
|
+
code: relayErrorCode.temporarilyUnavailable,
|
|
145
|
+
message: 'MPP relay is not enabled yet.',
|
|
146
|
+
},
|
|
147
|
+
],
|
|
148
|
+
}),
|
|
149
|
+
),
|
|
150
|
+
'An error returned by the MPP relay.',
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
/** MPP challenge accepted with a relay credential payload. */
|
|
154
|
+
export const Challenge = Schema.describe(
|
|
155
|
+
z.looseObject({
|
|
156
|
+
description: z
|
|
157
|
+
.optional(z.string())
|
|
158
|
+
.check(
|
|
159
|
+
z.describe('A human-readable description of the payment.'),
|
|
160
|
+
z.meta({ examples: ['Tempo API payment'] }),
|
|
161
|
+
),
|
|
162
|
+
expires: z
|
|
163
|
+
.optional(z.string())
|
|
164
|
+
.check(
|
|
165
|
+
z.describe('When the payment challenge expires, as an ISO-8601 timestamp.'),
|
|
166
|
+
z.meta({ examples: ['2026-07-21T21:30:00.000Z'] }),
|
|
167
|
+
),
|
|
168
|
+
id: z
|
|
169
|
+
.string()
|
|
170
|
+
.check(
|
|
171
|
+
z.describe('The payment challenge identifier.'),
|
|
172
|
+
z.meta({ examples: ['ch_01j3j1k2l3m4n5p6q7r8s9t0u'] }),
|
|
173
|
+
),
|
|
174
|
+
intent: z
|
|
175
|
+
.string()
|
|
176
|
+
.check(z.describe('The MPP payment intent.'), z.meta({ examples: ['charge'] })),
|
|
177
|
+
method: z
|
|
178
|
+
.string()
|
|
179
|
+
.check(z.describe('The MPP payment method.'), z.meta({ examples: ['tempo'] })),
|
|
180
|
+
opaque: z
|
|
181
|
+
.optional(z.string())
|
|
182
|
+
.check(
|
|
183
|
+
z.describe('Opaque data bound to the challenge by its issuer.'),
|
|
184
|
+
z.meta({ examples: ['eyJhbGciOiJIUzI1NiJ9'] }),
|
|
185
|
+
),
|
|
186
|
+
realm: z
|
|
187
|
+
.string()
|
|
188
|
+
.check(
|
|
189
|
+
z.describe('The MPP realm that issued the challenge.'),
|
|
190
|
+
z.meta({ examples: ['merchant.example'] }),
|
|
191
|
+
),
|
|
192
|
+
request: z
|
|
193
|
+
.record(z.string(), z.unknown())
|
|
194
|
+
.check(
|
|
195
|
+
z.describe('The payment request bound to the challenge.'),
|
|
196
|
+
z.meta({ examples: [{ amount: '1', currency: 'USD' }] }),
|
|
197
|
+
),
|
|
198
|
+
}),
|
|
199
|
+
'An MPP payment challenge.',
|
|
200
|
+
)
|
|
201
|
+
|
|
202
|
+
/** Request accepted by MPP relay verification and broadcast routes. */
|
|
203
|
+
export const RelayInput = Schema.describe(
|
|
204
|
+
z.object({
|
|
205
|
+
challenge: Challenge,
|
|
206
|
+
payload: z
|
|
207
|
+
.custom<unknown>((value) => value !== undefined)
|
|
208
|
+
.check(
|
|
209
|
+
z.describe('The method-specific MPP credential payload.'),
|
|
210
|
+
z.meta({ examples: [{ signature: `0x${'aa'.repeat(65)}`, type: 'transaction' }] }),
|
|
211
|
+
),
|
|
212
|
+
}),
|
|
213
|
+
'An MPP payment credential and its challenge.',
|
|
214
|
+
)
|
|
215
|
+
|
|
216
|
+
/** Receipt returned after the relay broadcasts a payment. */
|
|
217
|
+
export const Receipt = Schema.describe(
|
|
218
|
+
z.object({
|
|
219
|
+
externalId: z
|
|
220
|
+
.optional(z.string())
|
|
221
|
+
.check(
|
|
222
|
+
z.describe('An optional caller-provided payment reference.'),
|
|
223
|
+
z.meta({ examples: ['pi_01j3j1k2l3m4n5p6q7r8s9t0u'] }),
|
|
224
|
+
),
|
|
225
|
+
method: z
|
|
226
|
+
.string()
|
|
227
|
+
.check(
|
|
228
|
+
z.describe('The payment method that settled the credential.'),
|
|
229
|
+
z.meta({ examples: ['tempo'] }),
|
|
230
|
+
),
|
|
231
|
+
reference: z
|
|
232
|
+
.string()
|
|
233
|
+
.check(
|
|
234
|
+
z.describe('The on-chain or payment-system reference for the settlement.'),
|
|
235
|
+
z.meta({ examples: [`0x${'22'.repeat(32)}`] }),
|
|
236
|
+
),
|
|
237
|
+
timestamp: z
|
|
238
|
+
.string()
|
|
239
|
+
.check(
|
|
240
|
+
z.describe('When the payment settled, as an ISO-8601 timestamp.'),
|
|
241
|
+
z.meta({ examples: ['2026-07-20T18:30:00.000Z'] }),
|
|
242
|
+
),
|
|
243
|
+
}),
|
|
244
|
+
'A receipt for a broadcast MPP payment.',
|
|
245
|
+
)
|
|
246
|
+
|
|
247
|
+
/** Read-only MPP credential validation result. */
|
|
248
|
+
export const VerifyResponse = Schema.describe(
|
|
249
|
+
z.union([
|
|
250
|
+
z.object({
|
|
251
|
+
success: z
|
|
252
|
+
.literal(true)
|
|
253
|
+
.check(
|
|
254
|
+
z.describe('Whether the credential passed relay checks.'),
|
|
255
|
+
z.meta({ examples: [true] }),
|
|
256
|
+
),
|
|
257
|
+
}),
|
|
258
|
+
z.object({
|
|
259
|
+
error: RelayError.check(
|
|
260
|
+
z.describe('The reason the credential did not pass relay checks.'),
|
|
261
|
+
z.meta({
|
|
262
|
+
examples: [
|
|
263
|
+
{ code: relayErrorCode.invalidPayment, message: 'Credential signature is invalid.' },
|
|
264
|
+
],
|
|
265
|
+
}),
|
|
266
|
+
),
|
|
267
|
+
success: z
|
|
268
|
+
.literal(false)
|
|
269
|
+
.check(
|
|
270
|
+
z.describe('Whether the credential passed relay checks.'),
|
|
271
|
+
z.meta({ examples: [false] }),
|
|
272
|
+
),
|
|
273
|
+
}),
|
|
274
|
+
]),
|
|
275
|
+
'The result of read-only MPP credential validation.',
|
|
276
|
+
)
|
|
277
|
+
|
|
278
|
+
/** MPP credential broadcast result. */
|
|
279
|
+
export const BroadcastResponse = Schema.describe(
|
|
280
|
+
z.union([
|
|
281
|
+
z.object({
|
|
282
|
+
receipt: Receipt.check(
|
|
283
|
+
z.describe('The payment settlement receipt.'),
|
|
284
|
+
z.meta({
|
|
285
|
+
examples: [
|
|
286
|
+
{
|
|
287
|
+
method: 'tempo',
|
|
288
|
+
reference: `0x${'22'.repeat(32)}`,
|
|
289
|
+
timestamp: '2026-07-20T18:30:00.000Z',
|
|
290
|
+
},
|
|
291
|
+
],
|
|
292
|
+
}),
|
|
293
|
+
),
|
|
294
|
+
success: z
|
|
295
|
+
.literal(true)
|
|
296
|
+
.check(
|
|
297
|
+
z.describe('Whether the relay broadcast the credential.'),
|
|
298
|
+
z.meta({ examples: [true] }),
|
|
299
|
+
),
|
|
300
|
+
}),
|
|
301
|
+
z.object({
|
|
302
|
+
error: RelayError.check(
|
|
303
|
+
z.describe('The reason the relay did not broadcast the credential.'),
|
|
304
|
+
z.meta({
|
|
305
|
+
examples: [
|
|
306
|
+
{ code: relayErrorCode.broadcastFailed, message: 'Transaction broadcast failed.' },
|
|
307
|
+
],
|
|
308
|
+
}),
|
|
309
|
+
),
|
|
310
|
+
success: z
|
|
311
|
+
.literal(false)
|
|
312
|
+
.check(
|
|
313
|
+
z.describe('Whether the relay broadcast the credential.'),
|
|
314
|
+
z.meta({ examples: [false] }),
|
|
315
|
+
),
|
|
316
|
+
}),
|
|
317
|
+
]),
|
|
318
|
+
'The result of broadcasting an MPP credential.',
|
|
319
|
+
)
|
|
320
|
+
|
|
321
|
+
/** Temporary response returned while MPP relay settlement is disabled. */
|
|
322
|
+
export const Unavailable = Schema.describe(
|
|
323
|
+
z.object({
|
|
324
|
+
error: z.object({
|
|
325
|
+
code: z
|
|
326
|
+
.literal(relayErrorCode.temporarilyUnavailable)
|
|
327
|
+
.check(z.describe('The retryable relay failure code.')),
|
|
328
|
+
message: z
|
|
329
|
+
.literal('MPP relay is not enabled yet.')
|
|
330
|
+
.check(z.describe('The retryable relay failure message.')),
|
|
331
|
+
}),
|
|
332
|
+
success: z.literal(false).check(z.describe('Whether the relay processed the credential.')),
|
|
333
|
+
}),
|
|
334
|
+
'A retryable response returned while MPP relay settlement is disabled.',
|
|
335
|
+
)
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/** Returns the relay-disabled response while retaining its published success contract. */
|
|
339
|
+
export function unavailable<success>(
|
|
340
|
+
c: Context<App.Environment>,
|
|
341
|
+
): TypedResponse<success, 200> | TypedResponse<Unavailable, 503> {
|
|
342
|
+
c.header('Retry-After', '60')
|
|
343
|
+
return c.json(
|
|
344
|
+
Response.validated(schema.Unavailable, {
|
|
345
|
+
error: {
|
|
346
|
+
code: relayErrorCode.temporarilyUnavailable,
|
|
347
|
+
message: 'MPP relay is not enabled yet.',
|
|
348
|
+
},
|
|
349
|
+
success: false,
|
|
350
|
+
}),
|
|
351
|
+
503,
|
|
352
|
+
)
|
|
353
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type * as Mpp from '../Mpp.js'
|
|
2
|
+
|
|
3
|
+
/** Future MPPX lifecycle adapter. */
|
|
4
|
+
export type Adapter = {
|
|
5
|
+
/** Broadcasts a validated MPP credential. */
|
|
6
|
+
broadcast(input: Mpp.RelayInput): Promise<Mpp.BroadcastResponse>
|
|
7
|
+
/** Validates an MPP credential without broadcasting it. */
|
|
8
|
+
verify(input: Mpp.RelayInput): Promise<Mpp.VerifyResponse>
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// TODO(mppx#597): implement with validateCredential and broadcastCredential.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type * as Mpp from '../Mpp.js'
|
|
2
|
+
|
|
3
|
+
/** Future MPPX failure mapper. */
|
|
4
|
+
export type Mapper = {
|
|
5
|
+
/** Maps an MPPX failure to the stable public relay error contract. */
|
|
6
|
+
map(cause: unknown): Mpp.RelayError
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// TODO(mppx#597): map validation, replay, simulation, and broadcast failures.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Future address-screening result. */
|
|
2
|
+
export type Result = { allowed: boolean }
|
|
3
|
+
|
|
4
|
+
/** Future address-screening provider. */
|
|
5
|
+
export type Provider = {
|
|
6
|
+
/** Screens one normalized account address on a Tempo chain. */
|
|
7
|
+
screen(options: { address: string; chainId: number }): Promise<Result>
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// TODO(mppx#597): add concurrent cached Chainalysis screening behind this provider.
|