tapimo 0.13.0 → 0.15.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/README.md +7 -4
- package/dist/ApiKey.js +1 -1
- package/dist/ApiKey.js.map +1 -1
- package/dist/ApiKeys.d.ts +95 -14
- package/dist/ApiKeys.d.ts.map +1 -1
- package/dist/ApiKeys.js +360 -49
- package/dist/ApiKeys.js.map +1 -1
- package/dist/App.d.ts +21383 -18056
- package/dist/App.d.ts.map +1 -1
- package/dist/App.js +301 -22
- package/dist/App.js.map +1 -1
- package/dist/Assets.d.ts.map +1 -1
- package/dist/Assets.js +2 -1
- package/dist/Assets.js.map +1 -1
- package/dist/Handler.d.ts +0 -1
- package/dist/Handler.d.ts.map +1 -1
- package/dist/Handler.js +0 -1
- package/dist/Handler.js.map +1 -1
- package/dist/Scope.d.ts +13 -5
- package/dist/Scope.d.ts.map +1 -1
- package/dist/Scope.js +16 -5
- package/dist/Scope.js.map +1 -1
- package/dist/Webhooks.js +2 -2
- package/dist/Webhooks.js.map +1 -1
- package/dist/admin/App.d.ts +3936 -1337
- package/dist/admin/App.d.ts.map +1 -1
- package/dist/admin/App.js +26 -5
- package/dist/admin/App.js.map +1 -1
- package/dist/admin/apps/api-keys.d.ts +159 -7
- package/dist/admin/apps/api-keys.d.ts.map +1 -1
- package/dist/admin/apps/api-keys.js +95 -43
- package/dist/admin/apps/api-keys.js.map +1 -1
- package/dist/admin/apps/earn-vaults.d.ts +1446 -0
- package/dist/admin/apps/earn-vaults.d.ts.map +1 -1
- package/dist/admin/apps/earn-vaults.js +465 -8
- package/dist/admin/apps/earn-vaults.js.map +1 -1
- package/dist/admin/apps/organizations.d.ts +344 -3
- package/dist/admin/apps/organizations.d.ts.map +1 -1
- package/dist/admin/apps/organizations.js +288 -10
- package/dist/admin/apps/organizations.js.map +1 -1
- package/dist/admin/apps/routes-support.d.ts +95 -0
- package/dist/admin/apps/routes-support.d.ts.map +1 -0
- package/dist/admin/apps/routes-support.js +151 -0
- package/dist/admin/apps/routes-support.js.map +1 -0
- package/dist/admin/apps/routes.d.ts +2764 -0
- package/dist/admin/apps/routes.d.ts.map +1 -0
- package/dist/admin/apps/routes.js +728 -0
- package/dist/admin/apps/routes.js.map +1 -0
- package/dist/admin/apps/subsidies.d.ts +501 -0
- package/dist/admin/apps/subsidies.d.ts.map +1 -0
- package/dist/admin/apps/subsidies.js +384 -0
- package/dist/admin/apps/subsidies.js.map +1 -0
- package/dist/admin/apps/verified-tokens.d.ts +16 -16
- package/dist/admin/apps/verified-tokens.d.ts.map +1 -1
- package/dist/admin/apps/verified-tokens.js +3 -3
- 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 +129 -69
- package/dist/admin/ui.generated.js.map +1 -1
- package/dist/analytics/Analytics.d.ts +5 -2
- package/dist/analytics/Analytics.d.ts.map +1 -1
- package/dist/analytics/Analytics.js +31 -1
- package/dist/analytics/Analytics.js.map +1 -1
- package/dist/analytics/tables/requestEvents.d.ts +2 -1
- package/dist/analytics/tables/requestEvents.d.ts.map +1 -1
- package/dist/analytics/tables/requestEvents.js +10 -1
- package/dist/analytics/tables/requestEvents.js.map +1 -1
- package/dist/analytics/tables/routesLifecycleIntervals.d.ts +72 -0
- package/dist/analytics/tables/routesLifecycleIntervals.d.ts.map +1 -0
- package/dist/analytics/tables/routesLifecycleIntervals.js +56 -0
- package/dist/analytics/tables/routesLifecycleIntervals.js.map +1 -0
- package/dist/apps/Zones.d.ts +21 -12526
- package/dist/apps/Zones.d.ts.map +1 -1
- package/dist/apps/Zones.js +40 -8
- package/dist/apps/Zones.js.map +1 -1
- package/dist/apps/data/App.d.ts +4310 -2548
- package/dist/apps/data/App.d.ts.map +1 -1
- package/dist/apps/data/App.js +86 -26
- package/dist/apps/data/App.js.map +1 -1
- package/dist/apps/data/routes/activities.d.ts +364 -34
- package/dist/apps/data/routes/activities.d.ts.map +1 -1
- package/dist/apps/data/routes/activities.js +495 -190
- package/dist/apps/data/routes/activities.js.map +1 -1
- package/dist/apps/data/routes/addresses.d.ts +94 -22
- package/dist/apps/data/routes/addresses.d.ts.map +1 -1
- package/dist/apps/data/routes/blocks.d.ts +37 -37
- package/dist/apps/data/routes/coingecko.d.ts.map +1 -1
- package/dist/apps/data/routes/coingecko.js +47 -21
- package/dist/apps/data/routes/coingecko.js.map +1 -1
- package/dist/apps/data/routes/earn.d.ts +1641 -352
- package/dist/apps/data/routes/earn.d.ts.map +1 -1
- package/dist/apps/data/routes/earn.js +1561 -120
- package/dist/apps/data/routes/earn.js.map +1 -1
- package/dist/apps/data/routes/exchanges.d.ts +15 -0
- package/dist/apps/data/routes/exchanges.d.ts.map +1 -1
- package/dist/apps/data/routes/exchanges.js +180 -114
- package/dist/apps/data/routes/exchanges.js.map +1 -1
- package/dist/apps/data/routes/fee-amm.d.ts +5 -0
- package/dist/apps/data/routes/fee-amm.d.ts.map +1 -1
- package/dist/apps/data/routes/fee-amm.js +49 -38
- package/dist/apps/data/routes/fee-amm.js.map +1 -1
- package/dist/apps/data/routes/indexer.d.ts +125 -0
- package/dist/apps/data/routes/indexer.d.ts.map +1 -1
- package/dist/apps/data/routes/indexer.js +83 -27
- package/dist/apps/data/routes/indexer.js.map +1 -1
- package/dist/apps/data/routes/rpc.d.ts +507 -33
- package/dist/apps/data/routes/rpc.d.ts.map +1 -1
- package/dist/apps/data/routes/rpc.js +266 -156
- package/dist/apps/data/routes/rpc.js.map +1 -1
- package/dist/apps/data/routes/tokenlist.d.ts +47 -15
- package/dist/apps/data/routes/tokenlist.d.ts.map +1 -1
- package/dist/apps/data/routes/tokenlist.js +68 -11
- package/dist/apps/data/routes/tokenlist.js.map +1 -1
- package/dist/apps/data/routes/tokens.d.ts +95 -93
- package/dist/apps/data/routes/tokens.d.ts.map +1 -1
- package/dist/apps/data/routes/tokens.js +26 -14
- package/dist/apps/data/routes/tokens.js.map +1 -1
- package/dist/apps/data/routes/transfers.d.ts +16 -0
- package/dist/apps/data/routes/transfers.d.ts.map +1 -1
- package/dist/apps/data/routes/transfers.js +9 -7
- package/dist/apps/data/routes/transfers.js.map +1 -1
- package/dist/apps/data/routes/verified-tokens.d.ts +4 -4
- package/dist/apps/data/routes/verified-tokens.d.ts.map +1 -1
- package/dist/apps/data/routes/verified-tokens.js +64 -20
- package/dist/apps/data/routes/verified-tokens.js.map +1 -1
- package/dist/apps/data/routes/webhooks.d.ts +1210 -70
- package/dist/apps/data/routes/webhooks.d.ts.map +1 -1
- package/dist/apps/data/routes/webhooks.js +301 -163
- package/dist/apps/data/routes/webhooks.js.map +1 -1
- package/dist/apps/data/routes/zones.d.ts.map +1 -1
- package/dist/apps/data/routes/zones.js +20 -12
- package/dist/apps/data/routes/zones.js.map +1 -1
- package/dist/apps/docs/reference.js +2 -2
- package/dist/apps/docs/reference.js.map +1 -1
- package/dist/apps/index.d.ts +1 -1
- package/dist/apps/index.d.ts.map +1 -1
- package/dist/apps/index.js +1 -1
- package/dist/apps/index.js.map +1 -1
- package/dist/apps/management/App.d.ts +4119 -3297
- package/dist/apps/management/App.d.ts.map +1 -1
- package/dist/apps/management/App.js +5 -14
- package/dist/apps/management/App.js.map +1 -1
- package/dist/apps/management/Billing.d.ts +49 -8
- package/dist/apps/management/Billing.d.ts.map +1 -1
- package/dist/apps/management/Billing.js +221 -26
- package/dist/apps/management/Billing.js.map +1 -1
- package/dist/apps/management/routes/api-keys.d.ts +174 -72
- package/dist/apps/management/routes/api-keys.d.ts.map +1 -1
- package/dist/apps/management/routes/api-keys.js +43 -15
- package/dist/apps/management/routes/api-keys.js.map +1 -1
- package/dist/apps/management/routes/billing.d.ts +364 -78
- package/dist/apps/management/routes/billing.d.ts.map +1 -1
- package/dist/apps/management/routes/billing.js +274 -49
- package/dist/apps/management/routes/billing.js.map +1 -1
- package/dist/apps/management/routes/faucet.d.ts +6 -6
- package/dist/apps/management/routes/faucet.js +1 -1
- package/dist/apps/management/routes/faucet.js.map +1 -1
- package/dist/apps/management/routes/invitations.d.ts +99 -24
- package/dist/apps/management/routes/invitations.d.ts.map +1 -1
- package/dist/apps/management/routes/invitations.js +117 -13
- package/dist/apps/management/routes/invitations.js.map +1 -1
- package/dist/apps/management/routes/invite-links.d.ts +42 -42
- package/dist/apps/management/routes/me.d.ts.map +1 -1
- package/dist/apps/management/routes/me.js +6 -2
- package/dist/apps/management/routes/me.js.map +1 -1
- package/dist/apps/management/routes/members.d.ts +16 -16
- package/dist/apps/management/routes/orgs.d.ts +36 -20
- package/dist/apps/management/routes/orgs.d.ts.map +1 -1
- package/dist/apps/management/routes/orgs.js +52 -12
- package/dist/apps/management/routes/orgs.js.map +1 -1
- package/dist/apps/management/routes/projects.d.ts +40 -40
- package/dist/apps/management/routes/projects.d.ts.map +1 -1
- package/dist/apps/management/routes/projects.js +6 -1
- package/dist/apps/management/routes/projects.js.map +1 -1
- package/dist/apps/management/routes/scopes.d.ts.map +1 -1
- package/dist/apps/management/routes/scopes.js +4 -1
- package/dist/apps/management/routes/scopes.js.map +1 -1
- package/dist/apps/management/routes/usage.d.ts +8 -8
- package/dist/apps/management/routes/usage.js +21 -4
- package/dist/apps/management/routes/usage.js.map +1 -1
- package/dist/apps/management/routes/verified-token-requests.d.ts +16 -16
- package/dist/apps/management/routes/webhooks.d.ts +931 -215
- package/dist/apps/management/routes/webhooks.d.ts.map +1 -1
- package/dist/apps/management/routes/webhooks.js +71 -25
- package/dist/apps/management/routes/webhooks.js.map +1 -1
- package/dist/apps/mcp.d.ts +1 -1
- package/dist/apps/mcp.js +7 -7
- package/dist/apps/mcp.js.map +1 -1
- package/dist/apps/mpp/App.d.ts.map +1 -1
- package/dist/apps/mpp/App.js +35 -7
- package/dist/apps/mpp/App.js.map +1 -1
- package/dist/apps/mpp/internal/Adapter.d.ts +2 -0
- package/dist/apps/mpp/internal/Adapter.d.ts.map +1 -1
- package/dist/apps/mpp/internal/Adapter.js +30 -1
- package/dist/apps/mpp/internal/Adapter.js.map +1 -1
- package/dist/apps/mpp/internal/Policy.d.ts +22 -4
- package/dist/apps/mpp/internal/Policy.d.ts.map +1 -1
- package/dist/apps/mpp/internal/Policy.js +24 -6
- package/dist/apps/mpp/internal/Policy.js.map +1 -1
- package/dist/apps/mpp/internal/Sponsorship.d.ts +3 -0
- package/dist/apps/mpp/internal/Sponsorship.d.ts.map +1 -1
- package/dist/apps/mpp/internal/Sponsorship.js +6 -3
- package/dist/apps/mpp/internal/Sponsorship.js.map +1 -1
- package/dist/apps/relay/App.d.ts +2 -0
- package/dist/apps/relay/App.d.ts.map +1 -1
- package/dist/apps/relay/App.js +177 -26
- package/dist/apps/relay/App.js.map +1 -1
- package/dist/apps/relay/Sponsorships.d.ts +5 -3
- package/dist/apps/relay/Sponsorships.d.ts.map +1 -1
- package/dist/apps/relay/Sponsorships.js +232 -25
- package/dist/apps/relay/Sponsorships.js.map +1 -1
- package/dist/apps/{funding → routes}/Access.d.ts +4 -4
- package/dist/apps/routes/Access.d.ts.map +1 -0
- package/dist/apps/{funding → routes}/Access.js +4 -4
- package/dist/apps/routes/Access.js.map +1 -0
- package/dist/apps/{funding → routes}/App.d.ts +841 -136
- package/dist/apps/{funding → routes}/App.d.ts.map +1 -1
- package/dist/apps/{funding → routes}/App.js +17 -17
- package/dist/apps/routes/App.js.map +1 -0
- package/dist/apps/routes/Inventory.d.ts.map +1 -0
- package/dist/apps/{funding → routes}/Inventory.js +2 -2
- package/dist/apps/routes/Inventory.js.map +1 -0
- package/dist/apps/routes/index.d.ts +2 -0
- package/dist/apps/routes/index.d.ts.map +1 -0
- package/dist/apps/routes/index.js +2 -0
- package/dist/apps/routes/index.js.map +1 -0
- package/dist/apps/{funding → routes}/routes/chains.d.ts +7 -7
- package/dist/apps/routes/routes/chains.d.ts.map +1 -0
- package/dist/apps/{funding → routes}/routes/chains.js +25 -25
- package/dist/apps/routes/routes/chains.js.map +1 -0
- package/dist/apps/{funding → routes}/routes/deposit-addresses.d.ts +123 -59
- package/dist/apps/routes/routes/deposit-addresses.d.ts.map +1 -0
- package/dist/apps/{funding → routes}/routes/deposit-addresses.js +498 -223
- package/dist/apps/routes/routes/deposit-addresses.js.map +1 -0
- package/dist/apps/{funding → routes}/routes/providers.d.ts +8 -8
- package/dist/apps/routes/routes/providers.d.ts.map +1 -0
- package/dist/apps/routes/routes/providers.js +57 -0
- package/dist/apps/routes/routes/providers.js.map +1 -0
- package/dist/apps/{funding → routes}/routes/quotes.d.ts +19 -16
- package/dist/apps/routes/routes/quotes.d.ts.map +1 -0
- package/dist/apps/{funding → routes}/routes/quotes.js +55 -38
- package/dist/apps/routes/routes/quotes.js.map +1 -0
- package/dist/apps/{funding → routes}/routes/transfers.d.ts +957 -71
- package/dist/apps/routes/routes/transfers.d.ts.map +1 -0
- package/dist/apps/routes/routes/transfers.js +1140 -0
- package/dist/apps/routes/routes/transfers.js.map +1 -0
- package/dist/cli/Cli.d.ts +30 -0
- package/dist/cli/Cli.d.ts.map +1 -1
- package/dist/cli/commands/admin.d.ts +36 -0
- package/dist/cli/commands/admin.d.ts.map +1 -1
- package/dist/cli/commands/admin.js +273 -0
- package/dist/cli/commands/admin.js.map +1 -1
- package/dist/cloudflare.d.ts +16 -14
- package/dist/cloudflare.d.ts.map +1 -1
- package/dist/cloudflare.js +26 -21
- package/dist/cloudflare.js.map +1 -1
- package/dist/db/Db.d.ts +63 -21
- package/dist/db/Db.d.ts.map +1 -1
- package/dist/db/Db.js +1052 -15
- package/dist/db/Db.js.map +1 -1
- package/dist/db/Schema.d.ts +785 -133
- package/dist/db/Schema.d.ts.map +1 -1
- package/dist/db/Schema.js +590 -162
- package/dist/db/Schema.js.map +1 -1
- package/dist/db/tables/apiKeyAdmissionBootstraps.d.ts +4 -0
- package/dist/db/tables/apiKeyAdmissionBootstraps.d.ts.map +1 -0
- package/dist/db/tables/apiKeyAdmissionBootstraps.js +2 -0
- package/dist/db/tables/apiKeyAdmissionBootstraps.js.map +1 -0
- package/dist/db/tables/apiKeyAdmissions.d.ts +73 -0
- package/dist/db/tables/apiKeyAdmissions.d.ts.map +1 -0
- package/dist/db/tables/apiKeyAdmissions.js +142 -0
- package/dist/db/tables/apiKeyAdmissions.js.map +1 -0
- package/dist/db/tables/apiKeyOwnerAdmissions.d.ts +4 -0
- package/dist/db/tables/apiKeyOwnerAdmissions.d.ts.map +1 -0
- package/dist/db/tables/apiKeyOwnerAdmissions.js +2 -0
- package/dist/db/tables/apiKeyOwnerAdmissions.js.map +1 -0
- package/dist/db/tables/apiKeyOwnerTombstones.d.ts +20 -0
- package/dist/db/tables/apiKeyOwnerTombstones.d.ts.map +1 -0
- package/dist/db/tables/apiKeyOwnerTombstones.js +57 -0
- package/dist/db/tables/apiKeyOwnerTombstones.js.map +1 -0
- package/dist/db/tables/apiKeyRevocations.d.ts +21 -0
- package/dist/db/tables/apiKeyRevocations.d.ts.map +1 -0
- package/dist/db/tables/apiKeyRevocations.js +98 -0
- package/dist/db/tables/apiKeyRevocations.js.map +1 -0
- package/dist/db/tables/authAccounts.d.ts +47 -0
- package/dist/db/tables/authAccounts.d.ts.map +1 -0
- package/dist/db/tables/authAccounts.js +72 -0
- package/dist/db/tables/authAccounts.js.map +1 -0
- package/dist/db/tables/authSessions.d.ts +12 -0
- package/dist/db/tables/authSessions.d.ts.map +1 -0
- package/dist/db/tables/authSessions.js +2 -0
- package/dist/db/tables/authSessions.js.map +1 -0
- package/dist/db/tables/authVerifications.d.ts +12 -0
- package/dist/db/tables/authVerifications.d.ts.map +1 -0
- package/dist/db/tables/authVerifications.js +2 -0
- package/dist/db/tables/authVerifications.js.map +1 -0
- package/dist/db/tables/invitations.d.ts +17 -1
- package/dist/db/tables/invitations.d.ts.map +1 -1
- package/dist/db/tables/invitations.js +123 -43
- package/dist/db/tables/invitations.js.map +1 -1
- package/dist/db/tables/memberships.d.ts +8 -0
- package/dist/db/tables/memberships.d.ts.map +1 -1
- package/dist/db/tables/memberships.js +51 -2
- package/dist/db/tables/memberships.js.map +1 -1
- package/dist/db/tables/organizations.d.ts +51 -5
- package/dist/db/tables/organizations.d.ts.map +1 -1
- package/dist/db/tables/organizations.js +135 -47
- package/dist/db/tables/organizations.js.map +1 -1
- package/dist/db/tables/projects.d.ts +27 -1
- package/dist/db/tables/projects.d.ts.map +1 -1
- package/dist/db/tables/projects.js +38 -3
- package/dist/db/tables/projects.js.map +1 -1
- package/dist/db/tables/requestUsage.d.ts.map +1 -1
- package/dist/db/tables/requestUsage.js.map +1 -1
- package/dist/db/tables/rewardAccounts.d.ts +86 -0
- package/dist/db/tables/rewardAccounts.d.ts.map +1 -0
- package/dist/db/tables/rewardAccounts.js +88 -0
- package/dist/db/tables/rewardAccounts.js.map +1 -0
- package/dist/db/tables/rewardCampaignDistributors.d.ts +36 -0
- package/dist/db/tables/rewardCampaignDistributors.d.ts.map +1 -0
- package/dist/db/tables/rewardCampaignDistributors.js +30 -0
- package/dist/db/tables/rewardCampaignDistributors.js.map +1 -0
- package/dist/db/tables/rewardCampaigns.d.ts +171 -0
- package/dist/db/tables/rewardCampaigns.d.ts.map +1 -0
- package/dist/db/tables/rewardCampaigns.js +392 -0
- package/dist/db/tables/rewardCampaigns.js.map +1 -0
- package/dist/db/tables/rewardCredits.d.ts +53 -0
- package/dist/db/tables/rewardCredits.d.ts.map +1 -0
- package/dist/db/tables/rewardCredits.js +63 -0
- package/dist/db/tables/rewardCredits.js.map +1 -0
- package/dist/db/tables/rewardEligibilityAssociations.d.ts +61 -0
- package/dist/db/tables/rewardEligibilityAssociations.d.ts.map +1 -0
- package/dist/db/tables/rewardEligibilityAssociations.js +103 -0
- package/dist/db/tables/rewardEligibilityAssociations.js.map +1 -0
- package/dist/db/tables/rewardRuns.d.ts +188 -0
- package/dist/db/tables/rewardRuns.d.ts.map +1 -0
- package/dist/db/tables/rewardRuns.js +278 -0
- package/dist/db/tables/rewardRuns.js.map +1 -0
- package/dist/db/tables/rewardTransactionAttempts.d.ts +100 -0
- package/dist/db/tables/rewardTransactionAttempts.d.ts.map +1 -0
- package/dist/db/tables/rewardTransactionAttempts.js +163 -0
- package/dist/db/tables/rewardTransactionAttempts.js.map +1 -0
- package/dist/db/tables/routesCatalog.d.ts +58 -0
- package/dist/db/tables/routesCatalog.d.ts.map +1 -0
- package/dist/db/tables/{fundingCatalog.js → routesCatalog.js} +19 -19
- package/dist/db/tables/routesCatalog.js.map +1 -0
- package/dist/db/tables/routesDepositAddresses.d.ts +476 -0
- package/dist/db/tables/routesDepositAddresses.d.ts.map +1 -0
- package/dist/db/tables/routesDepositAddresses.js +587 -0
- package/dist/db/tables/routesDepositAddresses.js.map +1 -0
- package/dist/db/tables/{fundingDepositRequestObservations.d.ts → routesDepositRequestObservations.d.ts} +6 -6
- package/dist/db/tables/routesDepositRequestObservations.d.ts.map +1 -0
- package/dist/db/tables/{fundingDepositRequestObservations.js → routesDepositRequestObservations.js} +6 -6
- package/dist/db/tables/routesDepositRequestObservations.js.map +1 -0
- package/dist/db/tables/{fundingDeposits.d.ts → routesDeposits.d.ts} +210 -22
- package/dist/db/tables/routesDeposits.d.ts.map +1 -0
- package/dist/db/tables/routesDeposits.js +576 -0
- package/dist/db/tables/routesDeposits.js.map +1 -0
- package/dist/db/tables/routesIdempotency.d.ts +166 -0
- package/dist/db/tables/routesIdempotency.d.ts.map +1 -0
- package/dist/db/tables/routesIdempotency.js +330 -0
- package/dist/db/tables/routesIdempotency.js.map +1 -0
- package/dist/db/tables/routesSubsidies.d.ts +27 -0
- package/dist/db/tables/routesSubsidies.d.ts.map +1 -0
- package/dist/db/tables/routesSubsidies.js +45 -0
- package/dist/db/tables/routesSubsidies.js.map +1 -0
- package/dist/db/tables/{fundingTransferEvents.d.ts → routesTransferEvents.d.ts} +3 -3
- package/dist/db/tables/routesTransferEvents.d.ts.map +1 -0
- package/dist/db/tables/{fundingTransferEvents.js → routesTransferEvents.js} +3 -3
- package/dist/db/tables/routesTransferEvents.js.map +1 -0
- package/dist/db/tables/routesTransferSubsidies.d.ts +19 -0
- package/dist/db/tables/routesTransferSubsidies.d.ts.map +1 -0
- package/dist/db/tables/routesTransferSubsidies.js +17 -0
- package/dist/db/tables/routesTransferSubsidies.js.map +1 -0
- package/dist/db/tables/routesTransferSubsidyNonces.d.ts +51 -0
- package/dist/db/tables/routesTransferSubsidyNonces.d.ts.map +1 -0
- package/dist/db/tables/routesTransferSubsidyNonces.js +82 -0
- package/dist/db/tables/routesTransferSubsidyNonces.js.map +1 -0
- package/dist/db/tables/routesTransferTransactions.d.ts +77 -0
- package/dist/db/tables/routesTransferTransactions.d.ts.map +1 -0
- package/dist/db/tables/routesTransferTransactions.js +86 -0
- package/dist/db/tables/routesTransferTransactions.js.map +1 -0
- package/dist/db/tables/routesTransfers.d.ts +319 -0
- package/dist/db/tables/routesTransfers.d.ts.map +1 -0
- package/dist/db/tables/routesTransfers.js +372 -0
- package/dist/db/tables/routesTransfers.js.map +1 -0
- package/dist/db/tables/sponsoredTransactions.d.ts +112 -13
- package/dist/db/tables/sponsoredTransactions.d.ts.map +1 -1
- package/dist/db/tables/sponsoredTransactions.js +241 -38
- package/dist/db/tables/sponsoredTransactions.js.map +1 -1
- package/dist/db/tables/sponsorshipAttributions.d.ts +69 -0
- package/dist/db/tables/sponsorshipAttributions.d.ts.map +1 -0
- package/dist/db/tables/sponsorshipAttributions.js +77 -0
- package/dist/db/tables/sponsorshipAttributions.js.map +1 -0
- package/dist/db/tables/sponsorshipReconciliationCursors.d.ts +22 -0
- package/dist/db/tables/sponsorshipReconciliationCursors.d.ts.map +1 -0
- package/dist/db/tables/sponsorshipReconciliationCursors.js +45 -0
- package/dist/db/tables/sponsorshipReconciliationCursors.js.map +1 -0
- package/dist/db/tables/stripeCustomers.d.ts +11 -0
- package/dist/db/tables/stripeCustomers.d.ts.map +1 -1
- package/dist/db/tables/stripeCustomers.js +13 -0
- package/dist/db/tables/stripeCustomers.js.map +1 -1
- package/dist/db/tables/users.d.ts +17 -1
- package/dist/db/tables/users.d.ts.map +1 -1
- package/dist/db/tables/users.js +47 -2
- package/dist/db/tables/users.js.map +1 -1
- package/dist/db/tables/webhookQueueEvents.d.ts.map +1 -1
- package/dist/db/tables/webhookQueueEvents.js +5 -1
- package/dist/db/tables/webhookQueueEvents.js.map +1 -1
- package/dist/db/tables/webhookSubscriptions.d.ts +22 -10
- package/dist/db/tables/webhookSubscriptions.d.ts.map +1 -1
- package/dist/db/tables/webhookSubscriptions.js +50 -15
- package/dist/db/tables/webhookSubscriptions.js.map +1 -1
- package/dist/handlers/internal/executionError.d.ts +2 -2
- package/dist/handlers/internal/executionError.d.ts.map +1 -1
- package/dist/handlers/internal/executionError.js +1 -2
- package/dist/handlers/internal/executionError.js.map +1 -1
- package/dist/handlers/internal/multisig.d.ts +4 -232
- package/dist/handlers/internal/multisig.d.ts.map +1 -1
- package/dist/handlers/internal/multisig.js +11 -537
- package/dist/handlers/internal/multisig.js.map +1 -1
- package/dist/handlers/internal/sponsorship.d.ts +19 -8
- package/dist/handlers/internal/sponsorship.d.ts.map +1 -1
- package/dist/handlers/internal/sponsorship.js +13 -9
- package/dist/handlers/internal/sponsorship.js.map +1 -1
- package/dist/handlers/relay.d.ts +9 -12
- package/dist/handlers/relay.d.ts.map +1 -1
- package/dist/handlers/relay.js +81 -85
- package/dist/handlers/relay.js.map +1 -1
- package/dist/index.d.ts +0 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -17
- package/dist/index.js.map +1 -1
- package/dist/internal/AssetResponse.d.ts +12 -0
- package/dist/internal/AssetResponse.d.ts.map +1 -0
- package/dist/internal/AssetResponse.js +21 -0
- package/dist/internal/AssetResponse.js.map +1 -0
- package/dist/internal/Auth.d.ts +48 -12
- package/dist/internal/Auth.d.ts.map +1 -1
- package/dist/internal/Auth.js +603 -175
- package/dist/internal/Auth.js.map +1 -1
- package/dist/internal/BetterAuth.d.ts +1488 -0
- package/dist/internal/BetterAuth.d.ts.map +1 -0
- package/dist/internal/BetterAuth.js +253 -0
- package/dist/internal/BetterAuth.js.map +1 -0
- package/dist/internal/Cache.d.ts +2 -0
- package/dist/internal/Cache.d.ts.map +1 -1
- package/dist/internal/Cache.js +2 -0
- package/dist/internal/Cache.js.map +1 -1
- package/dist/internal/EarnRates.d.ts +26 -3
- package/dist/internal/EarnRates.d.ts.map +1 -1
- package/dist/internal/EarnRates.js +84 -19
- package/dist/internal/EarnRates.js.map +1 -1
- package/dist/internal/EarnSharePrices.d.ts +120 -0
- package/dist/internal/EarnSharePrices.d.ts.map +1 -0
- package/dist/internal/EarnSharePrices.js +179 -0
- package/dist/internal/EarnSharePrices.js.map +1 -0
- package/dist/internal/EarnVaults.d.ts +4 -0
- package/dist/internal/EarnVaults.d.ts.map +1 -1
- package/dist/internal/EarnVaults.js +31 -14
- package/dist/internal/EarnVaults.js.map +1 -1
- package/dist/internal/Email.d.ts +37 -0
- package/dist/internal/Email.d.ts.map +1 -0
- package/dist/internal/Email.js +16 -0
- package/dist/internal/Email.js.map +1 -0
- package/dist/internal/Log.d.ts +32 -28
- package/dist/internal/Log.d.ts.map +1 -1
- package/dist/internal/Log.js +18 -11
- package/dist/internal/Log.js.map +1 -1
- package/dist/internal/MetricSink.d.ts +3 -0
- package/dist/internal/MetricSink.d.ts.map +1 -1
- package/dist/internal/MetricSink.js +67 -8
- package/dist/internal/MetricSink.js.map +1 -1
- package/dist/internal/Mpp.d.ts.map +1 -1
- package/dist/internal/Mpp.js +20 -25
- package/dist/internal/Mpp.js.map +1 -1
- package/dist/internal/OpenApi.d.ts +26 -3
- package/dist/internal/OpenApi.d.ts.map +1 -1
- package/dist/internal/OpenApi.js +25 -10
- package/dist/internal/OpenApi.js.map +1 -1
- package/dist/internal/Provider.d.ts +1 -1
- package/dist/internal/Provider.d.ts.map +1 -1
- package/dist/internal/RateLimit.d.ts.map +1 -1
- package/dist/internal/RateLimit.js +13 -1
- package/dist/internal/RateLimit.js.map +1 -1
- package/dist/internal/Store.d.ts +16 -0
- package/dist/internal/Store.d.ts.map +1 -1
- package/dist/internal/Store.js +59 -8
- package/dist/internal/Store.js.map +1 -1
- package/dist/internal/Tidx.d.ts +9 -2
- package/dist/internal/Tidx.d.ts.map +1 -1
- package/dist/internal/Tidx.js +78 -11
- package/dist/internal/Tidx.js.map +1 -1
- package/dist/internal/Timing.d.ts +26 -0
- package/dist/internal/Timing.d.ts.map +1 -1
- package/dist/internal/Timing.js +63 -5
- package/dist/internal/Timing.js.map +1 -1
- package/dist/internal/VercelOidc.d.ts +94 -0
- package/dist/internal/VercelOidc.d.ts.map +1 -0
- package/dist/internal/VercelOidc.js +128 -0
- package/dist/internal/VercelOidc.js.map +1 -0
- package/dist/internal/VerifiedTokens.d.ts +2 -8
- package/dist/internal/VerifiedTokens.d.ts.map +1 -1
- package/dist/internal/VerifiedTokens.js +24 -24
- package/dist/internal/VerifiedTokens.js.map +1 -1
- package/dist/internal/Viem.d.ts +46 -2068
- package/dist/internal/Viem.d.ts.map +1 -1
- package/dist/internal/Viem.js +171 -11
- package/dist/internal/Viem.js.map +1 -1
- package/dist/internal/Webhooks.d.ts +12 -4
- package/dist/internal/Webhooks.d.ts.map +1 -1
- package/dist/internal/Webhooks.js +9 -3
- package/dist/internal/Webhooks.js.map +1 -1
- package/dist/internal/ZoneRpc.d.ts +7 -0
- package/dist/internal/ZoneRpc.d.ts.map +1 -0
- package/dist/internal/ZoneRpc.js +49 -0
- package/dist/internal/ZoneRpc.js.map +1 -0
- package/dist/internal/index.d.ts +3 -1
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +3 -1
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/rewards/Audit.d.ts +88 -0
- package/dist/internal/rewards/Audit.d.ts.map +1 -0
- package/dist/internal/rewards/Audit.js +134 -0
- package/dist/internal/rewards/Audit.js.map +1 -0
- package/dist/internal/rewards/Campaigns.d.ts +572 -0
- package/dist/internal/rewards/Campaigns.d.ts.map +1 -0
- package/dist/internal/rewards/Campaigns.js +531 -0
- package/dist/internal/rewards/Campaigns.js.map +1 -0
- package/dist/internal/rewards/Credits.d.ts +76 -0
- package/dist/internal/rewards/Credits.d.ts.map +1 -0
- package/dist/internal/rewards/Credits.js +95 -0
- package/dist/internal/rewards/Credits.js.map +1 -0
- package/dist/internal/rewards/Events.d.ts +100 -0
- package/dist/internal/rewards/Events.d.ts.map +1 -0
- package/dist/internal/rewards/Events.js +340 -0
- package/dist/internal/rewards/Events.js.map +1 -0
- package/dist/internal/rewards/Projection.d.ts +237 -0
- package/dist/internal/rewards/Projection.d.ts.map +1 -0
- package/dist/internal/rewards/Projection.js +616 -0
- package/dist/internal/rewards/Projection.js.map +1 -0
- package/dist/internal/rewards/Rates.d.ts +44 -0
- package/dist/internal/rewards/Rates.d.ts.map +1 -0
- package/dist/internal/rewards/Rates.js +60 -0
- package/dist/internal/rewards/Rates.js.map +1 -0
- package/dist/internal/rewards/Read.d.ts +158 -0
- package/dist/internal/rewards/Read.d.ts.map +1 -0
- package/dist/internal/rewards/Read.js +292 -0
- package/dist/internal/rewards/Read.js.map +1 -0
- package/dist/internal/rewards/Runner.d.ts +164 -0
- package/dist/internal/rewards/Runner.d.ts.map +1 -0
- package/dist/internal/rewards/Runner.js +1778 -0
- package/dist/internal/rewards/Runner.js.map +1 -0
- package/dist/internal/rewards/Signer.d.ts +224 -0
- package/dist/internal/rewards/Signer.d.ts.map +1 -0
- package/dist/internal/rewards/Signer.js +135 -0
- package/dist/internal/rewards/Signer.js.map +1 -0
- package/dist/internal/rewards/index.d.ts +15 -0
- package/dist/internal/rewards/index.d.ts.map +1 -0
- package/dist/internal/rewards/index.js +15 -0
- package/dist/internal/rewards/index.js.map +1 -0
- package/dist/internal/{funding → routes}/Action.d.ts +12 -1
- package/dist/internal/routes/Action.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/Action.js +17 -9
- package/dist/internal/routes/Action.js.map +1 -0
- package/dist/internal/{funding → routes}/Catalog.d.ts +20 -20
- package/dist/internal/routes/Catalog.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/Catalog.js +29 -29
- package/dist/internal/routes/Catalog.js.map +1 -0
- package/dist/internal/{funding → routes}/Chain.d.ts +10 -10
- package/dist/internal/routes/Chain.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/Chain.js +3 -3
- package/dist/internal/routes/Chain.js.map +1 -0
- package/dist/internal/{funding → routes}/Deposit.d.ts +45 -23
- package/dist/internal/routes/Deposit.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/Deposit.js +60 -27
- package/dist/internal/routes/Deposit.js.map +1 -0
- package/dist/internal/{funding → routes}/DepositAddress.d.ts +56 -27
- package/dist/internal/routes/DepositAddress.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/DepositAddress.js +95 -33
- package/dist/internal/routes/DepositAddress.js.map +1 -0
- package/dist/internal/{funding → routes}/DepositWebhook.d.ts +4 -4
- package/dist/internal/routes/DepositWebhook.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/DepositWebhook.js +4 -3
- package/dist/internal/routes/DepositWebhook.js.map +1 -0
- package/dist/internal/routes/Economics.d.ts +25 -0
- package/dist/internal/routes/Economics.d.ts.map +1 -0
- package/dist/internal/routes/Economics.js +28 -0
- package/dist/internal/routes/Economics.js.map +1 -0
- package/dist/internal/{funding → routes}/Evidence.d.ts +3 -3
- package/dist/internal/routes/Evidence.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/Evidence.js +9 -17
- package/dist/internal/routes/Evidence.js.map +1 -0
- package/dist/internal/routes/Observability.d.ts +154 -0
- package/dist/internal/routes/Observability.d.ts.map +1 -0
- package/dist/internal/routes/Observability.js +389 -0
- package/dist/internal/routes/Observability.js.map +1 -0
- package/dist/internal/{funding → routes}/Provider.d.ts +350 -104
- package/dist/internal/routes/Provider.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/Provider.js +233 -97
- package/dist/internal/routes/Provider.js.map +1 -0
- package/dist/internal/{funding → routes}/Reconciliation.d.ts +11 -6
- package/dist/internal/routes/Reconciliation.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/Reconciliation.js +408 -158
- package/dist/internal/routes/Reconciliation.js.map +1 -0
- package/dist/internal/routes/Route.d.ts +21 -0
- package/dist/internal/routes/Route.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/Route.js +1 -1
- package/dist/internal/routes/Route.js.map +1 -0
- package/dist/internal/{funding → routes}/SourceObservation.d.ts +6 -6
- package/dist/internal/routes/SourceObservation.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/SourceObservation.js +13 -15
- package/dist/internal/routes/SourceObservation.js.map +1 -0
- package/dist/internal/{funding → routes}/Subsidy.d.ts +48 -3
- package/dist/internal/routes/Subsidy.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/Subsidy.js +43 -3
- package/dist/internal/routes/Subsidy.js.map +1 -0
- package/dist/internal/{funding → routes}/Token.d.ts +4 -4
- package/dist/internal/routes/Token.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/Token.js +3 -3
- package/dist/internal/routes/Token.js.map +1 -0
- package/dist/internal/{funding → routes}/Transfer.d.ts +324 -34
- package/dist/internal/routes/Transfer.d.ts.map +1 -0
- package/dist/internal/routes/Transfer.js +728 -0
- package/dist/internal/routes/Transfer.js.map +1 -0
- package/dist/internal/routes/TransferReconciliation.d.ts +55 -0
- package/dist/internal/routes/TransferReconciliation.d.ts.map +1 -0
- package/dist/internal/routes/TransferReconciliation.js +422 -0
- package/dist/internal/routes/TransferReconciliation.js.map +1 -0
- package/dist/internal/routes/TransferSubsidy.d.ts +201 -0
- package/dist/internal/routes/TransferSubsidy.d.ts.map +1 -0
- package/dist/internal/routes/TransferSubsidy.js +256 -0
- package/dist/internal/routes/TransferSubsidy.js.map +1 -0
- package/dist/internal/routes/TransferWebhook.d.ts +21 -0
- package/dist/internal/routes/TransferWebhook.d.ts.map +1 -0
- package/dist/internal/routes/TransferWebhook.js +43 -0
- package/dist/internal/routes/TransferWebhook.js.map +1 -0
- package/dist/internal/{funding → routes}/index.d.ts +3 -0
- package/dist/internal/routes/index.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/index.js +3 -0
- package/dist/internal/routes/index.js.map +1 -0
- package/dist/internal/{funding → routes}/providers/across.d.ts +4 -4
- package/dist/internal/routes/providers/across.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/providers/across.js +13 -13
- package/dist/internal/routes/providers/across.js.map +1 -0
- package/dist/internal/{funding → routes}/providers/relay.d.ts +21 -12
- package/dist/internal/routes/providers/relay.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/providers/relay.js +197 -122
- package/dist/internal/routes/providers/relay.js.map +1 -0
- package/dist/internal/{funding → routes}/providers/rhino.d.ts +4 -4
- package/dist/internal/routes/providers/rhino.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/providers/rhino.js +10 -10
- package/dist/internal/routes/providers/rhino.js.map +1 -0
- package/dist/internal/{funding → routes}/providers/squid.d.ts +4 -4
- package/dist/internal/routes/providers/squid.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/providers/squid.js +14 -14
- package/dist/internal/routes/providers/squid.js.map +1 -0
- package/dist/internal/routes/providers/stargate.d.ts +165 -0
- package/dist/internal/routes/providers/stargate.d.ts.map +1 -0
- package/dist/internal/routes/providers/stargate.js +898 -0
- package/dist/internal/routes/providers/stargate.js.map +1 -0
- package/dist/internal/{funding → routes}/providers/symbiosis.d.ts +4 -4
- package/dist/internal/routes/providers/symbiosis.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/providers/symbiosis.js +30 -20
- package/dist/internal/routes/providers/symbiosis.js.map +1 -0
- package/dist/internal/webhookDestinations/slack.d.ts.map +1 -1
- package/dist/internal/webhookDestinations/slack.js +22 -6
- package/dist/internal/webhookDestinations/slack.js.map +1 -1
- package/dist/providers/index.d.ts +12 -12
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js +12 -12
- package/dist/providers/index.js.map +1 -1
- package/dist/server.d.ts +19 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +19 -0
- package/dist/server.js.map +1 -0
- package/package.json +15 -4
- package/src/ApiKey.ts +1 -1
- package/src/ApiKeys.test.ts +1033 -3
- package/src/ApiKeys.ts +489 -48
- package/src/App.test-d.ts +1 -1
- package/src/App.test.ts +216 -25
- package/src/App.ts +335 -31
- package/src/Assets.test.ts +2 -2
- package/src/Assets.ts +3 -1
- package/src/Auth.test-d.ts +1 -1
- package/src/Client.test-d.ts +611 -101
- package/src/Handler.ts +0 -1
- package/src/OpenApi.contract.test.ts +195 -0
- package/src/Scope.ts +17 -5
- package/src/Webhooks.ts +2 -2
- package/src/admin/App.test.ts +30 -2
- package/src/admin/App.ts +42 -6
- package/src/admin/apps/api-keys.test.ts +267 -5
- package/src/admin/apps/api-keys.ts +100 -50
- package/src/admin/apps/earn-vaults.test.ts +158 -0
- package/src/admin/apps/earn-vaults.ts +681 -7
- package/src/admin/apps/organizations.test.ts +342 -1
- package/src/admin/apps/organizations.ts +368 -8
- package/src/admin/apps/routes-support.test.ts +200 -0
- package/src/admin/apps/routes-support.ts +201 -0
- package/src/admin/apps/routes.test.ts +450 -0
- package/src/admin/apps/routes.ts +896 -0
- package/src/admin/apps/scopes.test.ts +15 -5
- package/src/admin/apps/subsidies.test.ts +306 -0
- package/src/admin/apps/subsidies.ts +457 -0
- package/src/admin/apps/verified-tokens.test.ts +8 -3
- package/src/admin/apps/verified-tokens.ts +3 -3
- package/src/admin/ui/plugin.ts +1 -2
- package/src/admin/ui/src/components/RewardCampaignForm.tsx +1009 -0
- package/src/admin/ui/src/lib/config.ts +11 -2
- package/src/admin/ui/src/lib/earn-vaults.ts +2 -2
- package/src/admin/ui/src/lib/organizations.test.ts +147 -3
- package/src/admin/ui/src/lib/organizations.ts +136 -0
- package/src/admin/ui/src/lib/query-client.ts +1 -1
- package/src/admin/ui/src/lib/reward-campaigns.ts +136 -0
- package/src/admin/ui/src/lib/routes.test.ts +88 -0
- package/src/admin/ui/src/lib/routes.ts +304 -0
- package/src/admin/ui/src/lib/subsidies.ts +75 -0
- package/src/admin/ui/src/routeTree.gen.ts +63 -0
- package/src/admin/ui/src/routes/__root.tsx +12 -1
- package/src/admin/ui/src/routes/api-keys.tsx +196 -84
- package/src/admin/ui/src/routes/earn.vaults_.$vaultId.edit.tsx +105 -70
- package/src/admin/ui/src/routes/organizations_.$orgId.tsx +334 -2
- package/src/admin/ui/src/routes/routes.tsx +1615 -0
- package/src/admin/ui/src/routes/routes_.support.tsx +248 -0
- package/src/admin/ui/src/routes/subsidies.tsx +799 -0
- package/src/admin/ui.generated.ts +144 -69
- package/src/analytics/Analytics.test.ts +108 -18
- package/src/analytics/Analytics.ts +38 -6
- package/src/analytics/tables/requestEvents.test.ts +100 -0
- package/src/analytics/tables/requestEvents.ts +10 -1
- package/src/analytics/tables/routesLifecycleIntervals.ts +140 -0
- package/src/apps/Zones.test.ts +18 -3
- package/src/apps/Zones.ts +55 -8
- package/src/apps/composition.test.ts +68 -59
- package/src/apps/data/App.test.ts +154 -2
- package/src/apps/data/App.ts +102 -33
- package/src/apps/data/routes/activities.test.ts +419 -7
- package/src/apps/data/routes/activities.ts +683 -216
- package/src/apps/data/routes/balances.test.ts +2 -2
- package/src/apps/data/routes/blocks.test.ts +46 -1
- package/src/apps/data/routes/coingecko.test.ts +419 -1
- package/src/apps/data/routes/coingecko.ts +309 -253
- package/src/apps/data/routes/earn.discovery.test.ts +274 -0
- package/src/apps/data/routes/earn.test.ts +1661 -29
- package/src/apps/data/routes/earn.ts +2314 -328
- package/src/apps/data/routes/exchanges.test.ts +752 -30
- package/src/apps/data/routes/exchanges.ts +954 -753
- package/src/apps/data/routes/fee-amm.test.ts +224 -0
- package/src/apps/data/routes/fee-amm.ts +208 -178
- package/src/apps/data/routes/indexer.test.ts +389 -0
- package/src/apps/data/routes/indexer.ts +165 -69
- package/src/apps/data/routes/receipts.test.ts +1 -1
- package/src/apps/data/routes/rpc.test.ts +352 -8
- package/src/apps/data/routes/rpc.ts +407 -219
- package/src/apps/data/routes/rpc.zone.test.ts +340 -0
- package/src/apps/data/routes/tokenlist.test.ts +285 -0
- package/src/apps/data/routes/tokenlist.ts +173 -88
- package/src/apps/data/routes/tokens.test.ts +93 -3
- package/src/apps/data/routes/tokens.ts +39 -23
- package/src/apps/data/routes/transactions.test.ts +1 -1
- package/src/apps/data/routes/transfers.test.ts +56 -24
- package/src/apps/data/routes/transfers.ts +19 -8
- package/src/apps/data/routes/valuation.test.ts +1 -1
- package/src/apps/data/routes/verified-tokens.test.ts +345 -0
- package/src/apps/data/routes/verified-tokens.ts +99 -29
- package/src/apps/data/routes/webhooks.test.ts +659 -81
- package/src/apps/data/routes/webhooks.ts +1104 -817
- package/src/apps/data/routes/zones.test.ts +148 -71
- package/src/apps/data/routes/zones.ts +71 -55
- package/src/apps/docs/reference.ts +2 -2
- package/src/apps/index.ts +1 -1
- package/src/apps/management/App.ts +9 -51
- package/src/apps/management/Billing.test.ts +375 -14
- package/src/apps/management/Billing.ts +283 -34
- package/src/apps/management/routes/api-keys.test.ts +269 -7
- package/src/apps/management/routes/api-keys.ts +61 -20
- package/src/apps/management/routes/billing.test.ts +477 -15
- package/src/apps/management/routes/billing.ts +377 -50
- package/src/apps/management/routes/faucet.test.ts +1 -1
- package/src/apps/management/routes/faucet.ts +1 -1
- package/src/apps/management/routes/invitations.test.ts +270 -3
- package/src/apps/management/routes/invitations.ts +185 -15
- package/src/apps/management/routes/invoicePreview.test.ts +549 -0
- package/src/apps/management/routes/me.test.ts +246 -5
- package/src/apps/management/routes/me.ts +7 -2
- package/src/apps/management/routes/members.test.ts +108 -0
- package/src/apps/management/routes/orgs.test.ts +191 -3
- package/src/apps/management/routes/orgs.ts +58 -11
- package/src/apps/management/routes/projects.test.ts +33 -3
- package/src/apps/management/routes/projects.ts +6 -1
- package/src/apps/management/routes/scopes.test.ts +30 -2
- package/src/apps/management/routes/scopes.ts +4 -1
- package/src/apps/management/routes/usage.test.ts +32 -0
- package/src/apps/management/routes/usage.ts +22 -4
- package/src/apps/management/routes/webhooks.test.ts +49 -26
- package/src/apps/management/routes/webhooks.ts +93 -38
- package/src/apps/mcp.test.ts +6 -6
- package/src/apps/mcp.ts +7 -7
- package/src/apps/mpp/App.ts +37 -7
- package/src/apps/mpp/Mpp.test.ts +49 -8
- package/src/apps/mpp/Mpp.zone.test.ts +219 -0
- package/src/apps/mpp/internal/Adapter.ts +34 -0
- package/src/apps/mpp/internal/Policy.test.ts +86 -31
- package/src/apps/mpp/internal/Policy.ts +49 -7
- package/src/apps/mpp/internal/Sponsorship.test.ts +207 -0
- package/src/apps/mpp/internal/Sponsorship.ts +9 -3
- package/src/apps/relay/App.test.ts +1024 -38
- package/src/apps/relay/App.ts +228 -32
- package/src/apps/relay/App.zone-billing.test.ts +257 -0
- package/src/apps/relay/Sponsorships.test.ts +67 -4
- package/src/apps/relay/Sponsorships.ts +253 -29
- package/src/apps/relay/Sponsorships.zone.test.ts +102 -0
- package/src/apps/{funding → routes}/Access.ts +6 -6
- package/src/apps/routes/App.test.ts +165 -0
- package/src/apps/routes/App.ts +96 -0
- package/src/apps/{funding → routes}/Inventory.ts +2 -2
- package/src/apps/routes/index.ts +1 -0
- package/src/apps/{funding → routes}/routes/chains.test.ts +66 -66
- package/src/apps/{funding → routes}/routes/chains.ts +23 -23
- package/src/apps/{funding → routes}/routes/deposit-addresses.test.ts +1362 -462
- package/src/apps/{funding → routes}/routes/deposit-addresses.ts +568 -248
- package/src/apps/{funding → routes}/routes/providers.test.ts +27 -33
- package/src/apps/{funding → routes}/routes/providers.ts +23 -23
- package/src/apps/{funding → routes}/routes/quotes.test.ts +298 -41
- package/src/apps/{funding → routes}/routes/quotes.ts +57 -40
- package/src/apps/routes/routes/transfers.test.ts +2876 -0
- package/src/apps/routes/routes/transfers.ts +1332 -0
- package/src/cli/Cli.test.ts +1 -1
- package/src/cli/commands/admin.test.ts +748 -1
- package/src/cli/commands/admin.ts +278 -0
- package/src/cloudflare.ts +52 -47
- package/src/db/Db.test.ts +245 -2
- package/src/db/Db.ts +1511 -34
- package/src/db/Schema.ts +744 -228
- package/src/db/tables/apiKeyAdmissionBootstraps.ts +4 -0
- package/src/db/tables/apiKeyAdmissions.ts +218 -0
- package/src/db/tables/apiKeyOwnerAdmissions.ts +4 -0
- package/src/db/tables/apiKeyOwnerTombstones.ts +81 -0
- package/src/db/tables/apiKeyRevocations.test.ts +74 -0
- package/src/db/tables/apiKeyRevocations.ts +121 -0
- package/src/db/tables/authAccounts.ts +105 -0
- package/src/db/tables/authSessions.ts +13 -0
- package/src/db/tables/authVerifications.ts +13 -0
- package/src/db/tables/invitations.ts +142 -45
- package/src/db/tables/memberships.ts +79 -3
- package/src/db/tables/organizations.test.ts +725 -7
- package/src/db/tables/organizations.ts +182 -49
- package/src/db/tables/projects.test.ts +71 -0
- package/src/db/tables/projects.ts +59 -4
- package/src/db/tables/requestUsage.ts +4 -1
- package/src/db/tables/rewardAccounts.ts +178 -0
- package/src/db/tables/rewardCampaignDistributors.ts +68 -0
- package/src/db/tables/rewardCampaigns.test.ts +1388 -0
- package/src/db/tables/rewardCampaigns.ts +647 -0
- package/src/db/tables/rewardCredits.ts +110 -0
- package/src/db/tables/rewardEligibilityAssociations.test.ts +271 -0
- package/src/db/tables/rewardEligibilityAssociations.ts +184 -0
- package/src/db/tables/rewardRuns.ts +514 -0
- package/src/db/tables/rewardTransactionAttempts.ts +272 -0
- package/src/db/tables/routesCatalog.test.ts +185 -0
- package/src/db/tables/routesCatalog.ts +163 -0
- package/src/db/tables/routesDepositAddresses.test.ts +1048 -0
- package/src/db/tables/routesDepositAddresses.ts +1008 -0
- package/src/db/tables/{fundingDepositRequestObservations.test.ts → routesDepositRequestObservations.test.ts} +13 -14
- package/src/db/tables/{fundingDepositRequestObservations.ts → routesDepositRequestObservations.ts} +10 -10
- package/src/db/tables/{fundingDeposits.test.ts → routesDeposits.test.ts} +316 -46
- package/src/db/tables/routesDeposits.ts +1062 -0
- package/src/db/tables/routesIdempotency.test.ts +796 -0
- package/src/db/tables/routesIdempotency.ts +496 -0
- package/src/db/tables/routesSubsidies.test.ts +120 -0
- package/src/db/tables/routesSubsidies.ts +71 -0
- package/src/db/tables/{fundingTransferEvents.ts → routesTransferEvents.ts} +4 -4
- package/src/db/tables/routesTransferSubsidies.ts +38 -0
- package/src/db/tables/routesTransferSubsidyNonces.ts +124 -0
- package/src/db/tables/routesTransferTransactions.test.ts +195 -0
- package/src/db/tables/routesTransferTransactions.ts +158 -0
- package/src/db/tables/routesTransfers.test.ts +338 -0
- package/src/db/tables/routesTransfers.ts +662 -0
- package/src/db/tables/sponsoredTransactions.test.ts +563 -1
- package/src/db/tables/sponsoredTransactions.ts +386 -42
- package/src/db/tables/sponsorshipAttributions.test.ts +160 -0
- package/src/db/tables/sponsorshipAttributions.ts +168 -0
- package/src/db/tables/sponsorshipReconciliationCursors.test.ts +115 -0
- package/src/db/tables/sponsorshipReconciliationCursors.ts +67 -0
- package/src/db/tables/stripeCustomers.test.ts +85 -0
- package/src/db/tables/stripeCustomers.ts +24 -0
- package/src/db/tables/users.test.ts +129 -0
- package/src/db/tables/users.ts +49 -3
- package/src/db/tables/webhookQueueEvents.ts +8 -1
- package/src/db/tables/webhookSubscriptions.ts +103 -21
- package/src/handlers/internal/executionError.ts +3 -4
- package/src/handlers/internal/multisig.ts +13 -816
- package/src/handlers/internal/sponsorship.ts +26 -10
- package/src/handlers/relay.test-d.ts +9 -1
- package/src/handlers/relay.test.ts +823 -3
- package/src/handlers/relay.ts +127 -107
- package/src/index.test-d.ts +7 -0
- package/src/index.ts +0 -17
- package/src/internal/AssetResponse.ts +26 -0
- package/src/internal/Auth.test.ts +1564 -9
- package/src/internal/Auth.ts +833 -239
- package/src/internal/BetterAuth.test.ts +242 -0
- package/src/internal/BetterAuth.ts +349 -0
- package/src/internal/Cache.ts +2 -0
- package/src/internal/EarnRates.test.ts +17 -0
- package/src/internal/EarnRates.ts +124 -31
- package/src/internal/EarnSharePrices.test.ts +182 -0
- package/src/internal/EarnSharePrices.ts +313 -0
- package/src/internal/EarnVaults.test.ts +21 -0
- package/src/internal/EarnVaults.ts +37 -15
- package/src/internal/Email.ts +54 -0
- package/src/internal/Idempotency.test.ts +2 -2
- package/src/internal/Log.test-d.ts +10 -7
- package/src/internal/Log.test.ts +114 -16
- package/src/internal/Log.ts +55 -40
- package/src/internal/MetricSink.test.ts +313 -26
- package/src/internal/MetricSink.ts +73 -8
- package/src/internal/Mpp.test.ts +31 -0
- package/src/internal/Mpp.ts +21 -24
- package/src/internal/OpenApi.ts +45 -12
- package/src/internal/Provider.test.ts +1 -1
- package/src/internal/Provider.ts +1 -1
- package/src/internal/RateLimit.test.ts +21 -3
- package/src/internal/RateLimit.ts +12 -1
- package/src/internal/Store.test-d.ts +1 -1
- package/src/internal/Store.test.ts +151 -8
- package/src/internal/Store.ts +76 -9
- package/src/internal/Tidx.test.ts +59 -8
- package/src/internal/Tidx.ts +86 -14
- package/src/internal/Timing.test.ts +77 -0
- package/src/internal/Timing.ts +83 -6
- package/src/internal/VercelOidc.test.ts +188 -0
- package/src/internal/VercelOidc.ts +193 -0
- package/src/internal/VerifiedTokens.test.ts +60 -6
- package/src/internal/VerifiedTokens.ts +21 -24
- package/src/internal/Viem.batch.test.ts +80 -0
- package/src/internal/Viem.test.ts +201 -2
- package/src/internal/Viem.ts +249 -17
- package/src/internal/Webhooks.test.ts +125 -1
- package/src/internal/Webhooks.ts +22 -4
- package/src/internal/ZoneRpc.ts +50 -0
- package/src/internal/exchange/Provider.test.ts +2 -2
- package/src/internal/index.test.ts +3 -1
- package/src/internal/index.ts +3 -1
- package/src/internal/rewards/Audit.ts +231 -0
- package/src/internal/rewards/Campaigns.test.ts +1234 -0
- package/src/internal/rewards/Campaigns.ts +1205 -0
- package/src/internal/rewards/Credits.ts +165 -0
- package/src/internal/rewards/Events.local.test.ts +113 -0
- package/src/internal/rewards/Events.test.ts +152 -0
- package/src/internal/rewards/Events.ts +468 -0
- package/src/internal/rewards/Projection.test.ts +681 -0
- package/src/internal/rewards/Projection.ts +987 -0
- package/src/internal/rewards/Rates.test.ts +171 -0
- package/src/internal/rewards/Rates.ts +110 -0
- package/src/internal/rewards/Read.test.ts +501 -0
- package/src/internal/rewards/Read.ts +476 -0
- package/src/internal/rewards/Runner.checkpoint.test.ts +80 -0
- package/src/internal/rewards/Runner.states.test.ts +188 -0
- package/src/internal/rewards/Runner.test.ts +90 -0
- package/src/internal/rewards/Runner.ts +2229 -0
- package/src/internal/rewards/Signer.test.ts +79 -0
- package/src/internal/rewards/Signer.ts +180 -0
- package/src/internal/rewards/index.ts +14 -0
- package/src/internal/{funding → routes}/Action.test.ts +63 -14
- package/src/internal/{funding → routes}/Action.ts +35 -8
- package/src/internal/{funding → routes}/Catalog.test.ts +3 -3
- package/src/internal/{funding → routes}/Catalog.ts +39 -39
- package/src/internal/{funding → routes}/Chain.test.ts +1 -1
- package/src/internal/{funding → routes}/Chain.ts +11 -11
- package/src/internal/{funding → routes}/Deposit.test.ts +1 -1
- package/src/internal/{funding → routes}/Deposit.ts +93 -45
- package/src/internal/{funding → routes}/DepositAddress.test.ts +11 -3
- package/src/internal/{funding → routes}/DepositAddress.ts +132 -53
- package/src/internal/{funding → routes}/DepositWebhook.test.ts +61 -18
- package/src/internal/{funding → routes}/DepositWebhook.ts +9 -8
- package/src/internal/routes/Economics.test.ts +42 -0
- package/src/internal/routes/Economics.ts +47 -0
- package/src/internal/{funding → routes}/Evidence.test.ts +6 -6
- package/src/internal/{funding → routes}/Evidence.ts +11 -22
- package/src/internal/routes/Observability.test.ts +636 -0
- package/src/internal/routes/Observability.ts +668 -0
- package/src/internal/{funding → routes}/Provider.test.ts +489 -153
- package/src/internal/{funding → routes}/Provider.ts +531 -185
- package/src/internal/{funding → routes}/Reconciliation.local.test.ts +84 -12
- package/src/internal/{funding → routes}/Reconciliation.test.ts +1213 -279
- package/src/internal/{funding → routes}/Reconciliation.ts +501 -203
- package/src/internal/routes/Reconciliation.unattributed.test.ts +250 -0
- package/src/internal/{funding → routes}/Route.ts +7 -7
- package/src/internal/{funding → routes}/SourceObservation.test.ts +13 -14
- package/src/internal/{funding → routes}/SourceObservation.ts +18 -22
- package/src/internal/{funding → routes}/Subsidy.local.test.ts +7 -7
- package/src/internal/routes/Subsidy.test.ts +169 -0
- package/src/internal/{funding → routes}/Subsidy.ts +86 -6
- package/src/internal/{funding → routes}/Token.test.ts +1 -1
- package/src/internal/{funding → routes}/Token.ts +5 -5
- package/src/internal/routes/Transfer.test.ts +1199 -0
- package/src/internal/routes/Transfer.ts +1206 -0
- package/src/internal/routes/TransferReconciliation.test.ts +731 -0
- package/src/internal/routes/TransferReconciliation.ts +527 -0
- package/src/internal/routes/TransferSubsidy.test.ts +172 -0
- package/src/internal/routes/TransferSubsidy.ts +447 -0
- package/src/internal/routes/TransferWebhook.test.ts +128 -0
- package/src/internal/routes/TransferWebhook.ts +67 -0
- package/src/internal/{funding → routes}/index.test.ts +6 -3
- package/src/internal/{funding → routes}/index.ts +3 -0
- package/src/internal/{funding → routes}/providers/across.ts +16 -16
- package/src/internal/{funding → routes}/providers/index.test.ts +157 -44
- package/src/internal/{funding → routes}/providers/relay.test.ts +165 -32
- package/src/internal/{funding → routes}/providers/relay.ts +231 -136
- package/src/internal/{funding → routes}/providers/rhino.ts +16 -16
- package/src/internal/{funding → routes}/providers/squid.ts +17 -17
- package/src/internal/routes/providers/stargate.test.ts +728 -0
- package/src/internal/routes/providers/stargate.ts +1276 -0
- package/src/internal/{funding → routes}/providers/symbiosis.ts +64 -24
- package/src/internal/webhookDestinations/slack.ts +20 -5
- package/src/providers/index.ts +13 -13
- package/src/server.ts +18 -0
- package/dist/apps/funding/Access.d.ts.map +0 -1
- package/dist/apps/funding/Access.js.map +0 -1
- package/dist/apps/funding/App.js.map +0 -1
- package/dist/apps/funding/Inventory.d.ts.map +0 -1
- package/dist/apps/funding/Inventory.js.map +0 -1
- package/dist/apps/funding/ProviderAttempts.d.ts +0 -5
- package/dist/apps/funding/ProviderAttempts.d.ts.map +0 -1
- package/dist/apps/funding/ProviderAttempts.js +0 -24
- package/dist/apps/funding/ProviderAttempts.js.map +0 -1
- package/dist/apps/funding/index.d.ts +0 -2
- package/dist/apps/funding/index.d.ts.map +0 -1
- package/dist/apps/funding/index.js +0 -2
- package/dist/apps/funding/index.js.map +0 -1
- package/dist/apps/funding/routes/chains.d.ts.map +0 -1
- package/dist/apps/funding/routes/chains.js.map +0 -1
- package/dist/apps/funding/routes/deposit-addresses.d.ts.map +0 -1
- package/dist/apps/funding/routes/deposit-addresses.js.map +0 -1
- package/dist/apps/funding/routes/providers.d.ts.map +0 -1
- package/dist/apps/funding/routes/providers.js +0 -57
- package/dist/apps/funding/routes/providers.js.map +0 -1
- package/dist/apps/funding/routes/quotes.d.ts.map +0 -1
- package/dist/apps/funding/routes/quotes.js.map +0 -1
- package/dist/apps/funding/routes/transfers.d.ts.map +0 -1
- package/dist/apps/funding/routes/transfers.js +0 -622
- package/dist/apps/funding/routes/transfers.js.map +0 -1
- package/dist/db/tables/fundingCatalog.d.ts +0 -58
- package/dist/db/tables/fundingCatalog.d.ts.map +0 -1
- package/dist/db/tables/fundingCatalog.js.map +0 -1
- package/dist/db/tables/fundingDepositAddresses.d.ts +0 -192
- package/dist/db/tables/fundingDepositAddresses.d.ts.map +0 -1
- package/dist/db/tables/fundingDepositAddresses.js +0 -235
- package/dist/db/tables/fundingDepositAddresses.js.map +0 -1
- package/dist/db/tables/fundingDepositRequestObservations.d.ts.map +0 -1
- package/dist/db/tables/fundingDepositRequestObservations.js.map +0 -1
- package/dist/db/tables/fundingDeposits.d.ts.map +0 -1
- package/dist/db/tables/fundingDeposits.js +0 -295
- package/dist/db/tables/fundingDeposits.js.map +0 -1
- package/dist/db/tables/fundingIdempotency.d.ts +0 -91
- package/dist/db/tables/fundingIdempotency.d.ts.map +0 -1
- package/dist/db/tables/fundingIdempotency.js +0 -103
- package/dist/db/tables/fundingIdempotency.js.map +0 -1
- package/dist/db/tables/fundingTransferEvents.d.ts.map +0 -1
- package/dist/db/tables/fundingTransferEvents.js.map +0 -1
- package/dist/db/tables/fundingTransferTransactions.d.ts +0 -15
- package/dist/db/tables/fundingTransferTransactions.d.ts.map +0 -1
- package/dist/db/tables/fundingTransferTransactions.js +0 -27
- package/dist/db/tables/fundingTransferTransactions.js.map +0 -1
- package/dist/db/tables/fundingTransfers.d.ts +0 -82
- package/dist/db/tables/fundingTransfers.d.ts.map +0 -1
- package/dist/db/tables/fundingTransfers.js +0 -89
- package/dist/db/tables/fundingTransfers.js.map +0 -1
- package/dist/internal/funding/Action.d.ts.map +0 -1
- package/dist/internal/funding/Action.js.map +0 -1
- package/dist/internal/funding/Catalog.d.ts.map +0 -1
- package/dist/internal/funding/Catalog.js.map +0 -1
- package/dist/internal/funding/Chain.d.ts.map +0 -1
- package/dist/internal/funding/Chain.js.map +0 -1
- package/dist/internal/funding/Deposit.d.ts.map +0 -1
- package/dist/internal/funding/Deposit.js.map +0 -1
- package/dist/internal/funding/DepositAddress.d.ts.map +0 -1
- package/dist/internal/funding/DepositAddress.js.map +0 -1
- package/dist/internal/funding/DepositWebhook.d.ts.map +0 -1
- package/dist/internal/funding/DepositWebhook.js.map +0 -1
- package/dist/internal/funding/Evidence.d.ts.map +0 -1
- package/dist/internal/funding/Evidence.js.map +0 -1
- package/dist/internal/funding/Provider.d.ts.map +0 -1
- package/dist/internal/funding/Provider.js.map +0 -1
- package/dist/internal/funding/Reconciliation.d.ts.map +0 -1
- package/dist/internal/funding/Reconciliation.js.map +0 -1
- package/dist/internal/funding/Route.d.ts +0 -21
- package/dist/internal/funding/Route.d.ts.map +0 -1
- package/dist/internal/funding/Route.js.map +0 -1
- package/dist/internal/funding/SourceObservation.d.ts.map +0 -1
- package/dist/internal/funding/SourceObservation.js.map +0 -1
- package/dist/internal/funding/Subsidy.d.ts.map +0 -1
- package/dist/internal/funding/Subsidy.js.map +0 -1
- package/dist/internal/funding/Token.d.ts.map +0 -1
- package/dist/internal/funding/Token.js.map +0 -1
- package/dist/internal/funding/Transfer.d.ts.map +0 -1
- package/dist/internal/funding/Transfer.js +0 -334
- package/dist/internal/funding/Transfer.js.map +0 -1
- package/dist/internal/funding/index.d.ts.map +0 -1
- package/dist/internal/funding/index.js.map +0 -1
- package/dist/internal/funding/providers/across.d.ts.map +0 -1
- package/dist/internal/funding/providers/across.js.map +0 -1
- package/dist/internal/funding/providers/relay.d.ts.map +0 -1
- package/dist/internal/funding/providers/relay.js.map +0 -1
- package/dist/internal/funding/providers/rhino.d.ts.map +0 -1
- package/dist/internal/funding/providers/rhino.js.map +0 -1
- package/dist/internal/funding/providers/squid.d.ts.map +0 -1
- package/dist/internal/funding/providers/squid.js.map +0 -1
- package/dist/internal/funding/providers/stargate.d.ts +0 -38
- package/dist/internal/funding/providers/stargate.d.ts.map +0 -1
- package/dist/internal/funding/providers/stargate.js +0 -277
- package/dist/internal/funding/providers/stargate.js.map +0 -1
- package/dist/internal/funding/providers/symbiosis.d.ts.map +0 -1
- package/dist/internal/funding/providers/symbiosis.js.map +0 -1
- package/src/apps/funding/App.test.ts +0 -78
- package/src/apps/funding/App.ts +0 -78
- package/src/apps/funding/ProviderAttempts.ts +0 -26
- package/src/apps/funding/index.ts +0 -1
- package/src/apps/funding/routes/transfers.test.ts +0 -1638
- package/src/apps/funding/routes/transfers.ts +0 -721
- package/src/db/tables/fundingCatalog.test.ts +0 -122
- package/src/db/tables/fundingCatalog.ts +0 -163
- package/src/db/tables/fundingDepositAddresses.test.ts +0 -608
- package/src/db/tables/fundingDepositAddresses.ts +0 -443
- package/src/db/tables/fundingDeposits.ts +0 -572
- package/src/db/tables/fundingIdempotency.test.ts +0 -182
- package/src/db/tables/fundingIdempotency.ts +0 -180
- package/src/db/tables/fundingTransferTransactions.test.ts +0 -69
- package/src/db/tables/fundingTransferTransactions.ts +0 -37
- package/src/db/tables/fundingTransfers.test.ts +0 -89
- package/src/db/tables/fundingTransfers.ts +0 -153
- package/src/handlers/internal/multisig.test.ts +0 -818
- package/src/internal/funding/Subsidy.test.ts +0 -75
- package/src/internal/funding/Transfer.test.ts +0 -369
- package/src/internal/funding/Transfer.ts +0 -545
- package/src/internal/funding/providers/stargate.test.ts +0 -163
- package/src/internal/funding/providers/stargate.ts +0 -409
- /package/dist/apps/{funding → routes}/Inventory.d.ts +0 -0
- /package/src/internal/{funding → routes}/Route.test.ts +0 -0
package/dist/internal/Auth.js
CHANGED
|
@@ -1,31 +1,57 @@
|
|
|
1
1
|
import * as Accounts from 'accounts/server';
|
|
2
|
+
import { splitSetCookieHeader } from 'better-auth/cookies';
|
|
2
3
|
import { Hono } from 'hono';
|
|
4
|
+
import { deleteCookie, getCookie, setCookie } from 'hono/cookie';
|
|
3
5
|
import { createMiddleware } from 'hono/factory';
|
|
4
6
|
import { matchedRoutes } from 'hono/route';
|
|
5
7
|
import { findTargetHandler } from 'hono/utils/handler';
|
|
8
|
+
import * as jose from 'jose';
|
|
9
|
+
import { sql } from 'kysely';
|
|
6
10
|
import { Challenge, Credential } from 'mppx';
|
|
7
11
|
import { Mppx, tempo } from 'mppx/hono';
|
|
12
|
+
import { Address, Hex } from 'ox';
|
|
8
13
|
import { Addresses } from 'viem/tempo';
|
|
9
14
|
import { tempoMainnet } from 'viem/tempo/chains';
|
|
10
15
|
import * as z from 'zod/mini';
|
|
11
16
|
import * as ApiKey from '../ApiKey.js';
|
|
12
17
|
import * as ApiKeys from '../ApiKeys.js';
|
|
18
|
+
import * as ApiKeyAdmissions from '../db/tables/apiKeyAdmissions.js';
|
|
19
|
+
import * as ApiKeyOwnerTombstones from '../db/tables/apiKeyOwnerTombstones.js';
|
|
20
|
+
import * as AuthAccounts from '../db/tables/authAccounts.js';
|
|
21
|
+
import * as BetterAuth from './BetterAuth.js';
|
|
13
22
|
import * as Db from '../db/Db.js';
|
|
14
23
|
import * as Memberships from '../db/tables/memberships.js';
|
|
15
24
|
import * as IpAllowlist from './IpAllowlist.js';
|
|
16
25
|
import * as Metadata from '../apps/metadata.js';
|
|
17
26
|
import * as OpenApi from './OpenApi.js';
|
|
18
27
|
import * as Organizations from '../db/tables/organizations.js';
|
|
28
|
+
import * as Path from './Path.js';
|
|
19
29
|
import * as Projects from '../db/tables/projects.js';
|
|
20
30
|
import * as RateLimit from './RateLimit.js';
|
|
21
31
|
import * as Response from './Response.js';
|
|
22
32
|
import * as Schema from './Schema.js';
|
|
23
33
|
import * as Scope from '../Scope.js';
|
|
34
|
+
import * as Timing from './Timing.js';
|
|
24
35
|
import * as Users from '../db/tables/users.js';
|
|
25
36
|
const policySymbol = Symbol('tempo-api.auth.policy');
|
|
26
37
|
const mppManagementSymbol = Symbol('tempo-api.auth.mpp-management');
|
|
27
38
|
const defaultApiKeyRateLimit = { limit: 10_000, period: 'minute' };
|
|
39
|
+
const defaultIdentitySessionTtl = 24 * 60 * 60;
|
|
28
40
|
const defaultMppRateLimit = { limit: 100, period: 'minute' };
|
|
41
|
+
const defaultPublicRateLimit = { limit: 60, period: 'minute' };
|
|
42
|
+
const identityCookieName = 'tempo_identity';
|
|
43
|
+
const walletIdentityIssuer = 'https://wallet.tempo.xyz/api/oidc';
|
|
44
|
+
function isIdentityTokenError(error) {
|
|
45
|
+
return (error instanceof jose.errors.JOSEAlgNotAllowed ||
|
|
46
|
+
error instanceof jose.errors.JOSENotSupported ||
|
|
47
|
+
error instanceof jose.errors.JWSInvalid ||
|
|
48
|
+
error instanceof jose.errors.JWKSNoMatchingKey ||
|
|
49
|
+
error instanceof jose.errors.JWSSignatureVerificationFailed ||
|
|
50
|
+
error instanceof jose.errors.JWTClaimValidationFailed ||
|
|
51
|
+
error instanceof jose.errors.JWTExpired ||
|
|
52
|
+
error instanceof jose.errors.JWTInvalid ||
|
|
53
|
+
(error instanceof Error && error.message === 'email not verified'));
|
|
54
|
+
}
|
|
29
55
|
/** Reads the authenticated principal from a Hono context. */
|
|
30
56
|
export function getPrincipal(c) {
|
|
31
57
|
return c.get('principal') ?? null;
|
|
@@ -265,6 +291,13 @@ export function paidAccessError(c) {
|
|
|
265
291
|
}
|
|
266
292
|
/** Creates auth middleware for protected OpenAPI routes. */
|
|
267
293
|
export function middleware(options) {
|
|
294
|
+
const resolve = createApiKeyResolver({
|
|
295
|
+
apiKey: options.apiKey,
|
|
296
|
+
scopeCatalog: options.scopeCatalog,
|
|
297
|
+
});
|
|
298
|
+
return createAuthMiddleware(options, resolve);
|
|
299
|
+
}
|
|
300
|
+
function createAuthMiddleware(options, resolve) {
|
|
268
301
|
const { rateLimit: mppRateLimit = defaultMppRateLimit, session: session_ = {}, sessionChainIds, ...mpp } = options.mpp === false ? {} : (options.mpp ?? {});
|
|
269
302
|
const secretKey = resolveMppSecretKey(mpp.secretKey);
|
|
270
303
|
const defaults = laneDefaults(options);
|
|
@@ -278,24 +311,13 @@ export function middleware(options) {
|
|
|
278
311
|
// keyed by token sha256) so hot keys skip the backend read on the auth path
|
|
279
312
|
// of every request. Pass `apiKey.cache: false` when immediate key updates
|
|
280
313
|
// matter more than the per-request read.
|
|
281
|
-
const resolve = (() => {
|
|
282
|
-
const uncached = (c, token) => {
|
|
283
|
-
const kv = contextKv(c);
|
|
284
|
-
return kv
|
|
285
|
-
? ApiKeys.resolve(kv.store, token, { scopeCatalog: options.scopeCatalog })
|
|
286
|
-
: Promise.resolve(null);
|
|
287
|
-
};
|
|
288
|
-
if (options.apiKey === false || options.apiKey?.cache === false)
|
|
289
|
-
return uncached;
|
|
290
|
-
return cachedResolve(uncached, options.apiKey?.cache ?? {});
|
|
291
|
-
})();
|
|
292
314
|
const auth = {
|
|
293
315
|
...(options.apiKey === false
|
|
294
316
|
? {}
|
|
295
317
|
: {
|
|
296
318
|
apiKey: {
|
|
297
319
|
...(options.apiKey?.rateLimits ? { rateLimits: options.apiKey.rateLimits } : {}),
|
|
298
|
-
resolve,
|
|
320
|
+
resolve: resolve.resolve,
|
|
299
321
|
},
|
|
300
322
|
}),
|
|
301
323
|
// The throttle ceiling for sandbox keys without active billing, so
|
|
@@ -336,33 +358,90 @@ export function middleware(options) {
|
|
|
336
358
|
: {}),
|
|
337
359
|
};
|
|
338
360
|
return createMiddleware((c, next) => {
|
|
339
|
-
const
|
|
340
|
-
if (!
|
|
361
|
+
const resolved = resolveRequestPolicy(c, { base, defaults, options });
|
|
362
|
+
if (!resolved)
|
|
341
363
|
return next();
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
const routePolicies = policies(c);
|
|
345
|
-
const configuredOverride = (() => {
|
|
346
|
-
const configured = overrides?.[key];
|
|
347
|
-
if (configured !== undefined)
|
|
348
|
-
return configured;
|
|
349
|
-
const inheritedMethod = routePolicies.find((policy) => policy.inheritOverridesFrom)?.inheritOverridesFrom;
|
|
350
|
-
if (inheritedMethod === undefined)
|
|
351
|
-
return undefined;
|
|
352
|
-
const inheritedKey = `${inheritedMethod.toUpperCase()} ${key.slice(key.indexOf(' ') + 1)}`;
|
|
353
|
-
return overrides?.[inheritedKey];
|
|
354
|
-
})();
|
|
355
|
-
const routeOverride = management && configuredOverride ? { mpp: configuredOverride.mpp } : configuredOverride;
|
|
356
|
-
const endpointPolicy = bindMppScope(resolvePolicy(base, defaults, [...routePolicies, routeOverride], description), scope);
|
|
357
|
-
if (!endpointPolicy)
|
|
364
|
+
c.set('auth', auth);
|
|
365
|
+
if (!resolved.policy)
|
|
358
366
|
return next();
|
|
359
|
-
if (management && (!auth.mpp || !
|
|
367
|
+
if (resolved.management && (!auth.mpp || !resolved.policy.mpp))
|
|
360
368
|
return next();
|
|
361
|
-
|
|
362
|
-
return require(endpointPolicy)(c, next);
|
|
369
|
+
return require(resolved.policy)(c, next);
|
|
363
370
|
});
|
|
364
371
|
}
|
|
365
|
-
|
|
372
|
+
function resolveRequestPolicy(c, options) {
|
|
373
|
+
const route = openApiRoute(c);
|
|
374
|
+
if (!route)
|
|
375
|
+
return undefined;
|
|
376
|
+
const { key, description, management, scope } = route;
|
|
377
|
+
const overrides = options.options.overrides;
|
|
378
|
+
const routePolicies = policies(c);
|
|
379
|
+
const configuredOverride = (() => {
|
|
380
|
+
const configured = overrides?.[key];
|
|
381
|
+
if (configured !== undefined)
|
|
382
|
+
return configured;
|
|
383
|
+
const inheritedMethod = routePolicies.find((routePolicy) => routePolicy !== false && routePolicy.inheritOverridesFrom !== undefined)?.inheritOverridesFrom;
|
|
384
|
+
if (inheritedMethod === undefined)
|
|
385
|
+
return undefined;
|
|
386
|
+
const inheritedKey = `${inheritedMethod.toUpperCase()} ${key.slice(key.indexOf(' ') + 1)}`;
|
|
387
|
+
return overrides?.[inheritedKey];
|
|
388
|
+
})();
|
|
389
|
+
const routeOverride = management && configuredOverride ? { mpp: configuredOverride.mpp } : configuredOverride;
|
|
390
|
+
return {
|
|
391
|
+
management,
|
|
392
|
+
policy: bindMppScope(resolvePolicy(options.base, options.defaults, [...routePolicies, routeOverride], description), scope),
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
function createApiKeyResolver(options) {
|
|
396
|
+
const requests = new WeakMap();
|
|
397
|
+
const uncached = (c, token) => {
|
|
398
|
+
const kv = contextKv(c);
|
|
399
|
+
return kv
|
|
400
|
+
? ApiKeys.resolve(kv.store, token, { scopeCatalog: options.scopeCatalog })
|
|
401
|
+
: Promise.resolve(null);
|
|
402
|
+
};
|
|
403
|
+
const cache = options.apiKey === false || options.apiKey?.cache === false
|
|
404
|
+
? { invalidate: () => { }, peek: () => undefined, resolve: uncached }
|
|
405
|
+
: cachedResolve(uncached, options.apiKey?.cache ?? {});
|
|
406
|
+
return {
|
|
407
|
+
peek: (c, token) => {
|
|
408
|
+
const tokenHash = ApiKey.hash(token);
|
|
409
|
+
const existing = requests.get(c);
|
|
410
|
+
if (existing?.tokenHash === tokenHash)
|
|
411
|
+
return existing.apiKey;
|
|
412
|
+
return cache.peek(token);
|
|
413
|
+
},
|
|
414
|
+
resolve: async (c, token) => {
|
|
415
|
+
const tokenHash = ApiKey.hash(token);
|
|
416
|
+
const existing = requests.get(c);
|
|
417
|
+
if (existing?.tokenHash === tokenHash)
|
|
418
|
+
return existing.apiKey;
|
|
419
|
+
const cached = await cache.resolve(c, token);
|
|
420
|
+
const kv = contextKv(c);
|
|
421
|
+
const apiKey = cached &&
|
|
422
|
+
((kv && (await ApiKeys.isOwnerDeleted(kv.store, cached))) ||
|
|
423
|
+
!(await apiKeyOwnerExists(cached, options.db)))
|
|
424
|
+
? null
|
|
425
|
+
: cached;
|
|
426
|
+
if (cached && !apiKey)
|
|
427
|
+
cache.invalidate(token);
|
|
428
|
+
requests.set(c, { apiKey, tokenHash });
|
|
429
|
+
return apiKey;
|
|
430
|
+
},
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
/** Rejects attributed keys fenced by a committed owner deletion. */
|
|
434
|
+
async function apiKeyOwnerExists(apiKey, source) {
|
|
435
|
+
if (!source)
|
|
436
|
+
return true;
|
|
437
|
+
const db = Db.get(source);
|
|
438
|
+
if (!(await ApiKeyAdmissions.matches(db, apiKey)))
|
|
439
|
+
return false;
|
|
440
|
+
if (await ApiKeyOwnerTombstones.isDeleted(db, apiKey))
|
|
441
|
+
return false;
|
|
442
|
+
return true;
|
|
443
|
+
}
|
|
444
|
+
/** Zod schemas documenting the session sign-in surface. */
|
|
366
445
|
var schema;
|
|
367
446
|
(function (schema) {
|
|
368
447
|
const siweMessage = 'api.tempo.xyz wants you to sign in with your Ethereum account:\n0x0000000000000000000000000000000000000000\n\nURI: https://api.tempo.xyz\nVersion: 1\nChain ID: 0\nNonce: 3D0sZfnHqTBmc9tKR\nIssued At: 2026-01-01T00:00:00.000Z\nExpiration Time: 2026-01-01T00:10:00.000Z';
|
|
@@ -379,19 +458,19 @@ var schema;
|
|
|
379
458
|
let challenge;
|
|
380
459
|
(function (challenge) {
|
|
381
460
|
/** Request body. Accepted fields beyond this document pass through to the SDK handler. */
|
|
382
|
-
challenge.Body = z.object({});
|
|
461
|
+
challenge.Body = OpenApi.component(z.object({}), 'SiweChallengeRequest');
|
|
383
462
|
/** Response body. */
|
|
384
|
-
challenge.Response = z.object({
|
|
463
|
+
challenge.Response = OpenApi.component(z.object({
|
|
385
464
|
message: z
|
|
386
465
|
.string()
|
|
387
466
|
.check(z.describe('Single-use EIP-4361 (SIWE) message to sign and submit for verification.'), z.meta({ examples: [siweMessage] })),
|
|
388
|
-
});
|
|
467
|
+
}), 'SiweChallengeResponse');
|
|
389
468
|
})(challenge = schema.challenge || (schema.challenge = {}));
|
|
390
469
|
/** Schemas for `POST /v1/auth/siwe` (verify). */
|
|
391
470
|
let verify;
|
|
392
471
|
(function (verify) {
|
|
393
472
|
/** Request body. */
|
|
394
|
-
verify.Body = z.object({
|
|
473
|
+
verify.Body = OpenApi.component(z.object({
|
|
395
474
|
address: z
|
|
396
475
|
.string()
|
|
397
476
|
.check(z.describe('Wallet address that signed the message; becomes the session subject.'), z.meta({ examples: ['0x0000000000000000000000000000000000000001'] })),
|
|
@@ -407,14 +486,26 @@ var schema;
|
|
|
407
486
|
signature: z
|
|
408
487
|
.string()
|
|
409
488
|
.check(z.describe('Signature over the challenge message (or the key-authorization digest).'), z.meta({ examples: [`0x${'aa'.repeat(65)}`] })),
|
|
410
|
-
});
|
|
489
|
+
}), 'SiweVerifyRequest');
|
|
411
490
|
/** Response body. */
|
|
412
|
-
verify.Response = z.object({
|
|
491
|
+
verify.Response = OpenApi.component(z.object({
|
|
413
492
|
token: z
|
|
414
493
|
.optional(z.string())
|
|
415
494
|
.check(z.describe('Bearer session token; present only when `returnToken` is true.'), z.meta({ examples: ['aa'.repeat(32)] })),
|
|
416
|
-
});
|
|
495
|
+
}), 'SiweVerifyResponse');
|
|
417
496
|
})(verify = schema.verify || (schema.verify = {}));
|
|
497
|
+
/** Schemas for `POST /v1/auth/identity`. */
|
|
498
|
+
let identity;
|
|
499
|
+
(function (identity) {
|
|
500
|
+
/** Request body. */
|
|
501
|
+
identity.Body = OpenApi.component(z.object({
|
|
502
|
+
idToken: z
|
|
503
|
+
.string()
|
|
504
|
+
.check(z.describe('Wallet-issued OpenID Connect identity token.'), z.meta({ examples: ['eyJhbGciOiJFZERTQSJ9.eyJzdWIiOiIweDAwMDAifQ.c2lnbmF0dXJl'] })),
|
|
505
|
+
}), 'IdentitySignInRequest');
|
|
506
|
+
/** Response body. */
|
|
507
|
+
identity.Response = OpenApi.component(z.object({}), 'IdentitySignInResponse');
|
|
508
|
+
})(identity = schema.identity || (schema.identity = {}));
|
|
418
509
|
})(schema || (schema = {}));
|
|
419
510
|
/** `{ error }` response for a sign-in handler failure status. */
|
|
420
511
|
function handlerError(description) {
|
|
@@ -431,17 +522,34 @@ function handlerError(description) {
|
|
|
431
522
|
*/
|
|
432
523
|
export function install(options) {
|
|
433
524
|
const { db, kv, scopeCatalog } = options;
|
|
434
|
-
const { session: options_session, ...options_middleware } = options.auth === false ? {} : (options.auth ?? {});
|
|
525
|
+
const { edgeRateLimit: options_edgeRateLimit, session: options_session, ...options_middleware } = options.auth === false ? {} : (options.auth ?? {});
|
|
526
|
+
const publicClientIp = typeof options_middleware.public === 'object' ? options_middleware.public.clientIp : undefined;
|
|
435
527
|
if (options_session && !kv)
|
|
436
528
|
throw new Error('`auth.session` requires the `kv` state store: sessions and sign-in challenges persist there.'); // prettier-ignore
|
|
529
|
+
const options_betterAuth = options_session
|
|
530
|
+
? {
|
|
531
|
+
basePath: Path.join(options.basePath, 'v1/auth'),
|
|
532
|
+
clientIp: (request) => resolveTrustedClientIp(request, publicClientIp),
|
|
533
|
+
db,
|
|
534
|
+
get email() {
|
|
535
|
+
return options.email();
|
|
536
|
+
},
|
|
537
|
+
rateLimit: RateLimit.memory(options_middleware.rateLimit),
|
|
538
|
+
secret: options_session.secret,
|
|
539
|
+
...(options_session.google ? { google: options_session.google } : {}),
|
|
540
|
+
...(options_session.trustedOrigins
|
|
541
|
+
? { trustedOrigins: options_session.trustedOrigins }
|
|
542
|
+
: {}),
|
|
543
|
+
}
|
|
544
|
+
: undefined;
|
|
437
545
|
// Session sign-in surface (challenge, verify, logout — SIWE wallet sign-in
|
|
438
546
|
// today) plus the capability the session lane resolves through. Public but
|
|
439
547
|
// policy-gated: the hidden describeRoute engages the middleware for the
|
|
440
548
|
// mounted sub-app, and the public lane rate-limits challenge-store writes.
|
|
441
549
|
const app = (() => {
|
|
442
|
-
if (!options_session || !kv)
|
|
550
|
+
if (!options_betterAuth || !options_session || !kv)
|
|
443
551
|
return undefined;
|
|
444
|
-
const { issuer, origin, requireEmail, ttl } =
|
|
552
|
+
const { issuer, origin, requireEmail, ttl } = options_session.wallet ?? {};
|
|
445
553
|
const handler = Accounts.Handler.auth({
|
|
446
554
|
getClient: options.getClient,
|
|
447
555
|
...(issuer || requireEmail
|
|
@@ -476,30 +584,108 @@ export function install(options) {
|
|
|
476
584
|
},
|
|
477
585
|
...(ttl ? { ttl } : {}),
|
|
478
586
|
});
|
|
587
|
+
const identity = options_session.identity;
|
|
588
|
+
const identitySessionTtl = identity?.ttl ?? defaultIdentitySessionTtl;
|
|
589
|
+
const identitySessionKey = (token) => `identity:session:${token}`;
|
|
590
|
+
async function resolveWallet(payload) {
|
|
591
|
+
const database = Db.get(db);
|
|
592
|
+
const verifiedEmail = payload.email?.trim().toLowerCase();
|
|
593
|
+
return database.kysely.transaction().execute(async (kysely) => {
|
|
594
|
+
const tx = { ...database, kysely };
|
|
595
|
+
// Organization creation locks the same address row before resolving
|
|
596
|
+
// the wallet owner, serializing resource writes with reconciliation.
|
|
597
|
+
const addressUser = await Users.getByAddressForUpdate(tx, payload.address);
|
|
598
|
+
if (!addressUser)
|
|
599
|
+
return null;
|
|
600
|
+
if (verifiedEmail)
|
|
601
|
+
await sql `SELECT pg_advisory_xact_lock(hashtextextended(${verifiedEmail}, 0))`.execute(kysely);
|
|
602
|
+
const linkedUserId = await AuthAccounts.getWalletUserId(tx, payload.address);
|
|
603
|
+
const linkedUser = linkedUserId ? await Users.get(tx, linkedUserId) : undefined;
|
|
604
|
+
const emailUser = verifiedEmail ? await Users.getByEmail(tx, verifiedEmail) : undefined;
|
|
605
|
+
const walletUser = linkedUser ?? addressUser;
|
|
606
|
+
const walletHasResources = emailUser && walletUser.id !== emailUser.id
|
|
607
|
+
? await Memberships.existsForUser(tx, walletUser.id)
|
|
608
|
+
: false;
|
|
609
|
+
// A verified email reconciles a provisional email-less wallet link.
|
|
610
|
+
// Keep a provisional owner when changing it would orphan its access.
|
|
611
|
+
const user = walletHasResources ? walletUser : (emailUser ?? walletUser);
|
|
612
|
+
if (linkedUser?.id !== user.id)
|
|
613
|
+
await AuthAccounts.setWalletUser(tx, { address: payload.address, userId: user.id });
|
|
614
|
+
if (verifiedEmail && (user.email !== verifiedEmail || !user.emailVerified))
|
|
615
|
+
await Users.setEmail(tx, user.id, verifiedEmail);
|
|
616
|
+
return { email: verifiedEmail ?? user.email ?? undefined, user };
|
|
617
|
+
});
|
|
618
|
+
}
|
|
479
619
|
const session = {
|
|
480
620
|
resolve: async (c) => {
|
|
481
|
-
const
|
|
482
|
-
|
|
621
|
+
const [betterAuth, identitySession, wallet] = await Promise.all([
|
|
622
|
+
(async () => {
|
|
623
|
+
const auth = BetterAuth.fromContext(c, options_betterAuth);
|
|
624
|
+
const request = BetterAuth.request(c, options_betterAuth);
|
|
625
|
+
const result = await auth.api.getSession({ headers: request.headers });
|
|
626
|
+
if (!result)
|
|
627
|
+
return null;
|
|
628
|
+
const provider = 'provider' in result.session && typeof result.session.provider === 'string'
|
|
629
|
+
? result.session.provider
|
|
630
|
+
: undefined;
|
|
631
|
+
if (!provider ||
|
|
632
|
+
!result.user.email ||
|
|
633
|
+
(provider === 'email' && !options_betterAuth.email))
|
|
634
|
+
return null;
|
|
635
|
+
return {
|
|
636
|
+
email: result.user.email,
|
|
637
|
+
id: result.user.id,
|
|
638
|
+
identity: { provider, subject: result.user.email },
|
|
639
|
+
type: 'session',
|
|
640
|
+
};
|
|
641
|
+
})(),
|
|
642
|
+
(async () => {
|
|
643
|
+
if (!identity)
|
|
644
|
+
return null;
|
|
645
|
+
const token = getCookie(c, identityCookieName);
|
|
646
|
+
if (!token)
|
|
647
|
+
return null;
|
|
648
|
+
const value = await kv.store.get(identitySessionKey(token));
|
|
649
|
+
if (value === null)
|
|
650
|
+
return null;
|
|
651
|
+
const payload = JSON.parse(value);
|
|
652
|
+
if (payload.expiresAt <= Math.floor(Date.now() / 1_000))
|
|
653
|
+
return null;
|
|
654
|
+
const user = await resolveWallet(payload);
|
|
655
|
+
if (!user)
|
|
656
|
+
return null;
|
|
657
|
+
return {
|
|
658
|
+
...(user.email ? { email: user.email } : {}),
|
|
659
|
+
id: user.user.id,
|
|
660
|
+
identity: { provider: 'wallet', subject: payload.address },
|
|
661
|
+
type: 'session',
|
|
662
|
+
};
|
|
663
|
+
})(),
|
|
664
|
+
(async () => {
|
|
665
|
+
const payload = await handler.getSession(c.req.raw);
|
|
666
|
+
if (!payload)
|
|
667
|
+
return null;
|
|
668
|
+
const user = await resolveWallet(payload);
|
|
669
|
+
if (!user)
|
|
670
|
+
return null;
|
|
671
|
+
return {
|
|
672
|
+
...(user.email ? { email: user.email } : {}),
|
|
673
|
+
id: user.user.id,
|
|
674
|
+
identity: { provider: 'wallet', subject: payload.address },
|
|
675
|
+
type: 'session',
|
|
676
|
+
};
|
|
677
|
+
})(),
|
|
678
|
+
]);
|
|
679
|
+
if (betterAuth && identitySession && betterAuth.id !== identitySession.id)
|
|
483
680
|
return null;
|
|
484
|
-
|
|
485
|
-
const user = await Users.getByAddress(database, payload.address);
|
|
486
|
-
if (!user)
|
|
681
|
+
if (betterAuth && wallet && betterAuth.id !== wallet.id)
|
|
487
682
|
return null;
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
await Users.setEmail(database, user.id, payload.email);
|
|
492
|
-
const email = payload.email ?? user.email ?? undefined;
|
|
493
|
-
return {
|
|
494
|
-
...(email ? { email } : {}),
|
|
495
|
-
id: user.id,
|
|
496
|
-
identity: { provider: 'wallet', subject: payload.address },
|
|
497
|
-
type: 'session',
|
|
498
|
-
};
|
|
683
|
+
if (identitySession && wallet && identitySession.id !== wallet.id)
|
|
684
|
+
return null;
|
|
685
|
+
return betterAuth ?? identitySession ?? wallet;
|
|
499
686
|
},
|
|
500
687
|
};
|
|
501
688
|
const policy_public = policy({ public: true });
|
|
502
|
-
const policy_session = policy({ public: true, session: true });
|
|
503
689
|
const describe = OpenApi.describeRoute({ hide: true });
|
|
504
690
|
const app = new Hono()
|
|
505
691
|
.use('/v1/auth/siwe', policy_public, describe)
|
|
@@ -507,10 +693,7 @@ export function install(options) {
|
|
|
507
693
|
// Documented operations: pre-routes carrying the OpenAPI metadata and the
|
|
508
694
|
// envelope-shaped body validation; the mounted handler owns behavior.
|
|
509
695
|
// Statement form keeps them off the app type (`hc` surface).
|
|
510
|
-
app.post('/v1/auth/siwe/challenge', policy_public, OpenApi.
|
|
511
|
-
code: 'body_invalid',
|
|
512
|
-
message: 'Invalid request body',
|
|
513
|
-
}), OpenApi.describeRoute({
|
|
696
|
+
app.post('/v1/auth/siwe/challenge', policy_public, OpenApi.documentJsonRequest(schema.challenge.Body), validateJsonRequest(schema.challenge.Body), OpenApi.describeRoute({
|
|
514
697
|
description: 'Issues a single-use SIWE challenge message to sign. The challenge expires after a short TTL.',
|
|
515
698
|
// Overrides the surface-wide hidden mount guard for this documented route.
|
|
516
699
|
hide: false,
|
|
@@ -528,10 +711,7 @@ export function install(options) {
|
|
|
528
711
|
summary: 'Create challenge (SIWE)',
|
|
529
712
|
tags: ['Authentication'],
|
|
530
713
|
}));
|
|
531
|
-
app.post('/v1/auth/siwe', policy_public, OpenApi.
|
|
532
|
-
code: 'body_invalid',
|
|
533
|
-
message: 'Invalid request body',
|
|
534
|
-
}), OpenApi.describeRoute({
|
|
714
|
+
app.post('/v1/auth/siwe', policy_public, OpenApi.documentJsonRequest(schema.verify.Body), validateJsonRequest(schema.verify.Body), OpenApi.describeRoute({
|
|
535
715
|
description: 'Verifies the signed challenge and establishes a session. Sets a session cookie by default; pass `returnToken` to receive a bearer token instead.',
|
|
536
716
|
hide: false,
|
|
537
717
|
operationId: 'verifySiwe',
|
|
@@ -557,35 +737,257 @@ export function install(options) {
|
|
|
557
737
|
summary: 'Authenticate (SIWE)',
|
|
558
738
|
tags: ['Authentication'],
|
|
559
739
|
}));
|
|
560
|
-
|
|
561
|
-
|
|
740
|
+
if (identity)
|
|
741
|
+
app.post('/v1/auth/identity', policy_public, OpenApi.documentJsonRequest(schema.identity.Body), validateJsonRequest(schema.identity.Body), OpenApi.describeRoute({
|
|
742
|
+
description: 'Verifies a Wallet-issued OpenID Connect identity token and establishes a session.',
|
|
743
|
+
hide: false,
|
|
744
|
+
operationId: 'verifyIdentity',
|
|
745
|
+
responses: {
|
|
746
|
+
200: {
|
|
747
|
+
content: {
|
|
748
|
+
'application/json': { schema: OpenApi.resolver(schema.identity.Response) },
|
|
749
|
+
},
|
|
750
|
+
description: 'Session established.',
|
|
751
|
+
headers: {
|
|
752
|
+
...OpenApi.successHeaders,
|
|
753
|
+
'Set-Cookie': {
|
|
754
|
+
description: `Session cookie (${identityCookieName}).`,
|
|
755
|
+
schema: { type: 'string' },
|
|
756
|
+
},
|
|
757
|
+
},
|
|
758
|
+
},
|
|
759
|
+
400: OpenApi.standardError(400, 'Malformed request body.', ['body_invalid']),
|
|
760
|
+
401: OpenApi.standardError(401, 'Identity verification failed.', ['identity_invalid']),
|
|
761
|
+
429: OpenApi.standardError(429, 'Rate limited.'),
|
|
762
|
+
500: OpenApi.standardError(500, 'Internal server error.'),
|
|
763
|
+
},
|
|
764
|
+
summary: 'Authenticate identity',
|
|
765
|
+
tags: ['Authentication'],
|
|
766
|
+
}), async (c) => {
|
|
767
|
+
const { idToken } = schema.identity.Body.parse(await c.req.json());
|
|
768
|
+
const claims = await Accounts.Identity.verify(idToken, {
|
|
769
|
+
audience: identity.audience,
|
|
770
|
+
issuer: identity.issuer ?? walletIdentityIssuer,
|
|
771
|
+
}).catch((error) => {
|
|
772
|
+
// Issuer and network failures must reach the request error signal.
|
|
773
|
+
if (isIdentityTokenError(error))
|
|
774
|
+
return undefined;
|
|
775
|
+
throw error;
|
|
776
|
+
});
|
|
777
|
+
if (!claims || !Address.validate(claims.subject, { strict: false }))
|
|
778
|
+
return Response.error(c, {
|
|
779
|
+
code: 'identity_invalid',
|
|
780
|
+
message: 'Invalid identity token',
|
|
781
|
+
status: 401,
|
|
782
|
+
});
|
|
783
|
+
const address = Address.checksum(claims.subject);
|
|
784
|
+
await Users.upsertByAddress(Db.get(db), { address });
|
|
785
|
+
const issuedAt = Math.floor(Date.now() / 1_000);
|
|
786
|
+
const token = Hex.fromBytes(crypto.getRandomValues(new Uint8Array(32))).slice(2);
|
|
787
|
+
await kv.store.put(identitySessionKey(token), JSON.stringify({
|
|
788
|
+
address,
|
|
789
|
+
...(claims.email ? { email: claims.email } : {}),
|
|
790
|
+
expiresAt: issuedAt + identitySessionTtl,
|
|
791
|
+
issuedAt,
|
|
792
|
+
}), { ttl: identitySessionTtl * 1_000 });
|
|
793
|
+
setCookie(c, identityCookieName, token, {
|
|
794
|
+
httpOnly: true,
|
|
795
|
+
maxAge: identitySessionTtl,
|
|
796
|
+
path: '/',
|
|
797
|
+
sameSite: 'Lax',
|
|
798
|
+
secure: new URL(c.req.url).protocol === 'https:',
|
|
799
|
+
});
|
|
800
|
+
return c.json({}, 200);
|
|
801
|
+
});
|
|
802
|
+
app.post('/v1/auth/logout', policy(false), createMiddleware(async (c, next) => {
|
|
803
|
+
const auth = c.get('auth');
|
|
804
|
+
const principal = principalFromPublic(c, auth);
|
|
805
|
+
const result = await consumeRateLimit(auth, {
|
|
806
|
+
key: `public:${principal.id}`,
|
|
807
|
+
limit: auth.publicRateLimit ?? defaultPublicRateLimit,
|
|
808
|
+
});
|
|
809
|
+
if (result) {
|
|
810
|
+
setRateLimitHeaders(c, result);
|
|
811
|
+
if (!result.allowed)
|
|
812
|
+
return rateLimitExceeded(c, result);
|
|
813
|
+
}
|
|
814
|
+
c.set('principal', principal);
|
|
815
|
+
await next();
|
|
816
|
+
return undefined;
|
|
817
|
+
}), OpenApi.describeRoute({
|
|
818
|
+
description: 'Revokes auth sessions and clears their cookies.',
|
|
562
819
|
hide: false,
|
|
563
|
-
operationId: '
|
|
820
|
+
operationId: 'logout',
|
|
564
821
|
responses: {
|
|
565
|
-
204: { description: '
|
|
822
|
+
204: { description: 'Sessions revoked and cookies cleared.' },
|
|
566
823
|
429: OpenApi.standardError(429, 'Rate limited.'),
|
|
567
|
-
500: OpenApi.standardError(500, '
|
|
824
|
+
500: OpenApi.standardError(500, 'Session logout failed.', ['session_logout_failed']),
|
|
568
825
|
},
|
|
569
826
|
summary: 'Sign out',
|
|
570
827
|
tags: ['Authentication'],
|
|
571
|
-
}))
|
|
828
|
+
}), async (c) => {
|
|
829
|
+
const walletHeaders = (() => {
|
|
830
|
+
const authorization = c.req.header('authorization');
|
|
831
|
+
const cookie = c.req.header('cookie');
|
|
832
|
+
if (!authorization?.match(/^Bearer\s+.+$/i) || !cookie?.match(/(?:^|;\s*)accounts_auth=/))
|
|
833
|
+
return [c.req.raw.headers];
|
|
834
|
+
const bearer = new Headers(c.req.raw.headers);
|
|
835
|
+
bearer.delete('cookie');
|
|
836
|
+
const cookie_ = new Headers(c.req.raw.headers);
|
|
837
|
+
cookie_.delete('authorization');
|
|
838
|
+
return [bearer, cookie_];
|
|
839
|
+
})();
|
|
840
|
+
const [betterAuth, identityLogout, ...accounts] = await Promise.allSettled([
|
|
841
|
+
BetterAuth.fromContext(c, options_betterAuth).api.signOut({
|
|
842
|
+
headers: c.req.raw.headers,
|
|
843
|
+
returnHeaders: true,
|
|
844
|
+
}),
|
|
845
|
+
(async () => {
|
|
846
|
+
const token = getCookie(c, identityCookieName);
|
|
847
|
+
deleteCookie(c, identityCookieName, { path: '/' });
|
|
848
|
+
if (token)
|
|
849
|
+
await kv.store.delete(identitySessionKey(token));
|
|
850
|
+
})(),
|
|
851
|
+
...walletHeaders.map((headers) => handler.request(new Request(new URL('/logout', c.req.url), {
|
|
852
|
+
headers,
|
|
853
|
+
method: 'POST',
|
|
854
|
+
}))),
|
|
855
|
+
]);
|
|
856
|
+
if (betterAuth.status === 'fulfilled')
|
|
857
|
+
for (const cookie of splitSetCookieHeader(betterAuth.value.headers.get('Set-Cookie') ?? ''))
|
|
858
|
+
c.header('Set-Cookie', cookie, { append: true });
|
|
859
|
+
for (const result of accounts)
|
|
860
|
+
if (result.status === 'fulfilled')
|
|
861
|
+
for (const cookie of splitSetCookieHeader(result.value.headers.get('Set-Cookie') ?? ''))
|
|
862
|
+
c.header('Set-Cookie', cookie, { append: true });
|
|
863
|
+
const error = (() => {
|
|
864
|
+
const rejected = [betterAuth, identityLogout, ...accounts].find((result) => result.status === 'rejected');
|
|
865
|
+
if (rejected?.status === 'rejected')
|
|
866
|
+
return rejected.reason instanceof Error
|
|
867
|
+
? rejected.reason
|
|
868
|
+
: new Error('Session logout failed', { cause: rejected.reason });
|
|
869
|
+
const failed = accounts.find((result) => result.status === 'fulfilled' && !result.value.ok);
|
|
870
|
+
if (failed?.status === 'fulfilled')
|
|
871
|
+
return new Error(`Accounts session logout failed with status ${failed.value.status}`);
|
|
872
|
+
return undefined;
|
|
873
|
+
})();
|
|
874
|
+
if (error) {
|
|
875
|
+
c.error = error;
|
|
876
|
+
return Response.error(c, {
|
|
877
|
+
code: 'session_logout_failed',
|
|
878
|
+
message: 'Session logout failed',
|
|
879
|
+
status: 500,
|
|
880
|
+
});
|
|
881
|
+
}
|
|
882
|
+
return c.body(null, 204);
|
|
883
|
+
});
|
|
884
|
+
app.route('/v1/auth/siwe', handler);
|
|
885
|
+
app.on(['GET', 'POST'], '/v1/auth/*', policy_public, describe, async (c, next) => {
|
|
886
|
+
if (c.req.method === 'POST' &&
|
|
887
|
+
stripBasePath(c.req.path, basePath(c)) === '/v1/auth/email-otp/send-verification-otp') {
|
|
888
|
+
const body = await c.req.raw
|
|
889
|
+
.clone()
|
|
890
|
+
.json()
|
|
891
|
+
.catch(() => undefined);
|
|
892
|
+
if (body && typeof body === 'object' && 'type' in body && body.type !== 'sign-in')
|
|
893
|
+
return Response.error(c, {
|
|
894
|
+
code: 'body_invalid',
|
|
895
|
+
message: 'Only sign-in OTPs are supported',
|
|
896
|
+
status: 400,
|
|
897
|
+
});
|
|
898
|
+
}
|
|
899
|
+
const response = await BetterAuth.fromContext(c, options_betterAuth).handler(BetterAuth.request(c, options_betterAuth));
|
|
900
|
+
// Leave unmatched paths available to auth providers mounted by the host app.
|
|
901
|
+
return response.status === 404 ? next() : response;
|
|
902
|
+
});
|
|
572
903
|
return Object.assign(
|
|
573
904
|
// The tag joins the `Management API` group at `management()`'s chosen slot;
|
|
574
905
|
// group listings filter to defined tags, so it drops out when unmounted.
|
|
575
|
-
Metadata.attach(app
|
|
906
|
+
Metadata.attach(app, {
|
|
907
|
+
securitySchemes: {
|
|
908
|
+
session: {
|
|
909
|
+
description: 'Session cookie established by email OTP, Wallet identity, or SIWE sign-in. Browsers send `tempo_auth.session_token`, `tempo_identity`, or `accounts_auth`; Accounts sessions may also use `Authorization: Bearer <token>`.', // prettier-ignore
|
|
910
|
+
in: 'header',
|
|
911
|
+
name: 'Cookie',
|
|
912
|
+
type: 'apiKey',
|
|
913
|
+
},
|
|
914
|
+
},
|
|
576
915
|
tags: [{ name: 'Authentication', description: 'Authenticate into the Tempo Platform.' }],
|
|
577
916
|
}), { session });
|
|
578
917
|
})();
|
|
918
|
+
const resolve = createApiKeyResolver({
|
|
919
|
+
apiKey: options_middleware.apiKey,
|
|
920
|
+
db: options.db,
|
|
921
|
+
scopeCatalog,
|
|
922
|
+
});
|
|
923
|
+
const defaults = laneDefaults(options_middleware);
|
|
924
|
+
const base = {};
|
|
925
|
+
const edgeRateLimit = (() => {
|
|
926
|
+
if (options.auth === false || !options_edgeRateLimit)
|
|
927
|
+
return undefined;
|
|
928
|
+
const superAdminTokenHash = options_middleware.superAdmin?.secret
|
|
929
|
+
? ApiKey.hash(options_middleware.superAdmin.secret)
|
|
930
|
+
: undefined;
|
|
931
|
+
return createMiddleware(async (c, next) => {
|
|
932
|
+
const credential = getApiKeyCredential(c);
|
|
933
|
+
const resolved = resolveRequestPolicy(c, { base, defaults, options: options_middleware });
|
|
934
|
+
const isSuperAdmin = credential &&
|
|
935
|
+
superAdminTokenHash !== undefined &&
|
|
936
|
+
ApiKey.hash(credential.token) === superAdminTokenHash;
|
|
937
|
+
const canUseApiKeyQuota = credential &&
|
|
938
|
+
!isSuperAdmin &&
|
|
939
|
+
!hasPaymentCredential(c) &&
|
|
940
|
+
options_middleware.apiKey !== false &&
|
|
941
|
+
resolved?.policy?.apiKey &&
|
|
942
|
+
(!resolved.management || (options_middleware.mpp !== false && resolved.policy.mpp));
|
|
943
|
+
const cached = canUseApiKeyQuota ? resolve.peek(c, credential.token) : undefined;
|
|
944
|
+
if (cached)
|
|
945
|
+
return next();
|
|
946
|
+
const response = await Timing.time(c, 'edge_rate_limit', () => options_edgeRateLimit(c.req.raw));
|
|
947
|
+
if (response)
|
|
948
|
+
return response;
|
|
949
|
+
if (canUseApiKeyQuota && cached === undefined)
|
|
950
|
+
await resolve.resolve(c, credential.token);
|
|
951
|
+
return next();
|
|
952
|
+
});
|
|
953
|
+
})();
|
|
579
954
|
const middleware_ = options.auth === false
|
|
580
955
|
? undefined
|
|
581
|
-
:
|
|
956
|
+
: createAuthMiddleware({
|
|
582
957
|
...options_middleware,
|
|
583
958
|
...(app ? { session: app.session } : {}),
|
|
584
959
|
scopeCatalog,
|
|
585
|
-
});
|
|
586
|
-
return { app, middleware: middleware_ };
|
|
960
|
+
}, resolve);
|
|
961
|
+
return { app, edgeRateLimit, middleware: middleware_ };
|
|
587
962
|
}
|
|
588
|
-
|
|
963
|
+
function validateJsonRequest(schema) {
|
|
964
|
+
return async (c, next) => {
|
|
965
|
+
if (!c.req.header('content-type')?.toLowerCase().startsWith('application/json'))
|
|
966
|
+
return Response.error(c, {
|
|
967
|
+
code: 'body_invalid',
|
|
968
|
+
message: 'Invalid request body',
|
|
969
|
+
status: 400,
|
|
970
|
+
});
|
|
971
|
+
const value = await (async () => {
|
|
972
|
+
try {
|
|
973
|
+
return await c.req.raw.clone().json();
|
|
974
|
+
}
|
|
975
|
+
catch {
|
|
976
|
+
return undefined;
|
|
977
|
+
}
|
|
978
|
+
})();
|
|
979
|
+
const result = schema.safeParse(value);
|
|
980
|
+
if (!result.success)
|
|
981
|
+
return Response.error(c, {
|
|
982
|
+
code: 'body_invalid',
|
|
983
|
+
details: Response.validationDetails(result.error.issues),
|
|
984
|
+
message: 'Invalid request body',
|
|
985
|
+
status: 400,
|
|
986
|
+
});
|
|
987
|
+
return next();
|
|
988
|
+
};
|
|
989
|
+
}
|
|
990
|
+
/** Creates route middleware that contributes an auth policy override, or bypasses auth when passed `false`. */
|
|
589
991
|
export function policy(options) {
|
|
590
992
|
const middleware = createMiddleware((_, next) => next());
|
|
591
993
|
middleware[policySymbol] = options;
|
|
@@ -601,7 +1003,7 @@ export function installMppManagementRoutes(app, options = {}) {
|
|
|
601
1003
|
continue;
|
|
602
1004
|
const target = targets.get(route.path) ?? { path: route.path };
|
|
603
1005
|
const override = policyFromRoute(route);
|
|
604
|
-
if (override
|
|
1006
|
+
if (override && override.mpp !== undefined)
|
|
605
1007
|
target.mpp = resolveMppLane(target.mpp, override.mpp, { session: {} });
|
|
606
1008
|
const spec = openApiSpec(route);
|
|
607
1009
|
if (spec) {
|
|
@@ -646,7 +1048,7 @@ function laneDefaults(options) {
|
|
|
646
1048
|
scopes: apiKey?.scopes ?? [Scope.wildcard],
|
|
647
1049
|
},
|
|
648
1050
|
mpp: { session: {} },
|
|
649
|
-
public: { rateLimit: public_?.rateLimit ??
|
|
1051
|
+
public: { rateLimit: public_?.rateLimit ?? defaultPublicRateLimit },
|
|
650
1052
|
session: true,
|
|
651
1053
|
};
|
|
652
1054
|
}
|
|
@@ -796,7 +1198,7 @@ export function describeAccess(app) {
|
|
|
796
1198
|
if (typeof spec?.operationId === 'string')
|
|
797
1199
|
group.operationId = spec.operationId;
|
|
798
1200
|
const override = policyFromRoute(route);
|
|
799
|
-
if (override)
|
|
1201
|
+
if (override !== undefined)
|
|
800
1202
|
group.overrides.push(override);
|
|
801
1203
|
groups.set(key, group);
|
|
802
1204
|
}
|
|
@@ -809,7 +1211,12 @@ export function describeAccess(app) {
|
|
|
809
1211
|
let public_ = false;
|
|
810
1212
|
let mpp = false;
|
|
811
1213
|
let session = false;
|
|
1214
|
+
let bypass = false;
|
|
812
1215
|
for (const override of overrides) {
|
|
1216
|
+
if (override === false) {
|
|
1217
|
+
bypass = true;
|
|
1218
|
+
break;
|
|
1219
|
+
}
|
|
813
1220
|
if (override.apiKey !== undefined)
|
|
814
1221
|
apiKey = override.apiKey !== false;
|
|
815
1222
|
if (override.apiKey && override.apiKey !== true && override.apiKey.scopes)
|
|
@@ -821,7 +1228,14 @@ export function describeAccess(app) {
|
|
|
821
1228
|
if (override.session !== undefined)
|
|
822
1229
|
session = override.session !== false;
|
|
823
1230
|
}
|
|
824
|
-
access[operationId] = {
|
|
1231
|
+
access[operationId] = {
|
|
1232
|
+
apiKey,
|
|
1233
|
+
...(bypass ? { bypass: true } : {}),
|
|
1234
|
+
mpp,
|
|
1235
|
+
public: public_,
|
|
1236
|
+
scopes: apiKey ? scopes : [],
|
|
1237
|
+
session,
|
|
1238
|
+
};
|
|
825
1239
|
}
|
|
826
1240
|
return access;
|
|
827
1241
|
}
|
|
@@ -862,14 +1276,17 @@ export function require(policy) {
|
|
|
862
1276
|
const hasQueryApiKey = new URL(c.req.url).searchParams.has('key');
|
|
863
1277
|
// Auth owns `key`; strict route schemas must not validate it.
|
|
864
1278
|
stripApiKeyQuery(c);
|
|
865
|
-
// Reject unknown chains before MPP builds a chain-bound challenge. Route
|
|
866
|
-
// groups publish their supported chains into the shared app context.
|
|
867
1279
|
const chainId = explicitChainId(c);
|
|
868
1280
|
const supportedChainIds = c.var['supportedChainIds'];
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
1281
|
+
const unsupportedChain = (() => {
|
|
1282
|
+
if (chainId === undefined ||
|
|
1283
|
+
!(supportedChainIds instanceof Set) ||
|
|
1284
|
+
supportedChainIds.has(chainId))
|
|
1285
|
+
return undefined;
|
|
1286
|
+
return { chainId, supportedChainIds };
|
|
1287
|
+
})();
|
|
1288
|
+
if (unsupportedChain && !credential)
|
|
1289
|
+
return Response.unsupportedChainId(c, unsupportedChain.chainId, unsupportedChain.supportedChainIds);
|
|
873
1290
|
const proceed = async () => {
|
|
874
1291
|
await next();
|
|
875
1292
|
// Query credential responses must not enter shared caches.
|
|
@@ -890,11 +1307,15 @@ export function require(policy) {
|
|
|
890
1307
|
// The super admin secret precedes key lookup: it is not a stored key.
|
|
891
1308
|
// It must never reach KV resolution or scope/quota checks.
|
|
892
1309
|
if (auth.superAdmin && ApiKey.hash(credential.token) === auth.superAdmin.tokenHash) {
|
|
1310
|
+
if (unsupportedChain)
|
|
1311
|
+
return Response.unsupportedChainId(c, unsupportedChain.chainId, unsupportedChain.supportedChainIds);
|
|
893
1312
|
c.set('principal', { actor: 'super_admin', id: 'super_admin', type: 'super_admin' });
|
|
894
1313
|
return proceed();
|
|
895
1314
|
}
|
|
896
1315
|
const apiKey_resolved = await auth.apiKey?.resolve(c, credential.token);
|
|
897
1316
|
if (!apiKey_resolved) {
|
|
1317
|
+
if (unsupportedChain)
|
|
1318
|
+
return Response.unsupportedChainId(c, unsupportedChain.chainId, unsupportedChain.supportedChainIds);
|
|
898
1319
|
// A bearer session token is indistinguishable from an API key at the
|
|
899
1320
|
// header, so a failed key lookup falls through to the session lane
|
|
900
1321
|
// before rejecting.
|
|
@@ -931,6 +1352,28 @@ export function require(policy) {
|
|
|
931
1352
|
message: 'API key not permitted for this route',
|
|
932
1353
|
status: 403,
|
|
933
1354
|
});
|
|
1355
|
+
// Non-paid requests consume API-key quota before rejection. Paid
|
|
1356
|
+
// requests use the MPP quota after access checks.
|
|
1357
|
+
const scope = policy.apiKey.scopes[0] ?? Scope.wildcard;
|
|
1358
|
+
const throttled = apiKey.environment === 'sandbox' && apiKey.billingActive !== true;
|
|
1359
|
+
const limit = throttled
|
|
1360
|
+
? (policy.public?.rateLimit ?? auth.publicRateLimit ?? { limit: 60, period: 'minute' })
|
|
1361
|
+
: resolveApiKeyLimit({ apiKey, auth, policy: policy.apiKey, scope });
|
|
1362
|
+
const paid = hasPayment && !throttled;
|
|
1363
|
+
const result = paid
|
|
1364
|
+
? null
|
|
1365
|
+
: await consumeRateLimit(auth, {
|
|
1366
|
+
key: `api_key:${apiKey.id}:scope:${scope}`,
|
|
1367
|
+
limit,
|
|
1368
|
+
});
|
|
1369
|
+
if (result) {
|
|
1370
|
+
setRateLimitHeaders(c, result);
|
|
1371
|
+
// Surface the bucket so callers can correlate a 429 with the exhausted
|
|
1372
|
+
// quota. MPP challenges own their headers and drop these by design.
|
|
1373
|
+
c.header('RateLimit-Scope', scope);
|
|
1374
|
+
}
|
|
1375
|
+
if (unsupportedChain)
|
|
1376
|
+
return Response.unsupportedChainId(c, unsupportedChain.chainId, unsupportedChain.supportedChainIds);
|
|
934
1377
|
if (apiKey.allowedIps.length &&
|
|
935
1378
|
!(await IpAllowlist.allows(c, {
|
|
936
1379
|
address: trustedClientIp(c, auth),
|
|
@@ -958,53 +1401,25 @@ export function require(policy) {
|
|
|
958
1401
|
message: 'API key missing required scope',
|
|
959
1402
|
status: 403,
|
|
960
1403
|
});
|
|
961
|
-
|
|
962
|
-
// `billingActive` is snapshotted on the key record (stamped at mint,
|
|
963
|
-
// re-synced when billing changes), so this needs no billing read on the
|
|
964
|
-
// request path. Resolved before the paid lane so a payment credential
|
|
965
|
-
// can't buy past the throttle: sandbox is non-billable testnet.
|
|
966
|
-
const throttled = apiKey.environment === 'sandbox' && apiKey.billingActive !== true;
|
|
967
|
-
if (hasPayment && !throttled)
|
|
1404
|
+
if (paid)
|
|
968
1405
|
return requirePayment(c, proceed, {
|
|
969
1406
|
auth,
|
|
970
1407
|
payment: { reason: 'api_key_over_quota', type: 'mpp' },
|
|
971
1408
|
policy,
|
|
972
1409
|
principal,
|
|
973
1410
|
});
|
|
974
|
-
if (
|
|
975
|
-
// A
|
|
976
|
-
//
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
key: `api_key:${apiKey.id}:scope:${scope}`,
|
|
986
|
-
limit,
|
|
1411
|
+
if (result && !result.allowed) {
|
|
1412
|
+
// A throttled sandbox key gets a plain 429, never an MPP challenge. It
|
|
1413
|
+
// must activate billing to lift the ceiling, not pay per request.
|
|
1414
|
+
if (throttled)
|
|
1415
|
+
return rateLimitExceeded(c, result);
|
|
1416
|
+
return requirePaymentOrRateLimit(c, proceed, {
|
|
1417
|
+
auth,
|
|
1418
|
+
payment: { reason: 'api_key_over_quota', type: 'mpp' },
|
|
1419
|
+
policy,
|
|
1420
|
+
principal,
|
|
1421
|
+
rateLimit: result,
|
|
987
1422
|
});
|
|
988
|
-
if (result) {
|
|
989
|
-
setRateLimitHeaders(c, result);
|
|
990
|
-
// Surface the bucket so callers can correlate a 429 with the exhausted
|
|
991
|
-
// quota. Set before the over-quota branch so it rides the 429 (an MPP
|
|
992
|
-
// 402 challenge is owned by mppx and drops these headers — by design).
|
|
993
|
-
c.header('RateLimit-Scope', scope);
|
|
994
|
-
}
|
|
995
|
-
if (result && !result.allowed) {
|
|
996
|
-
// A throttled sandbox key gets a plain 429, never an MPP challenge —
|
|
997
|
-
// it must activate billing to lift the ceiling, not pay per request.
|
|
998
|
-
if (throttled)
|
|
999
|
-
return rateLimitExceeded(c, result);
|
|
1000
|
-
return requirePaymentOrRateLimit(c, proceed, {
|
|
1001
|
-
auth,
|
|
1002
|
-
payment: { reason: 'api_key_over_quota', type: 'mpp' },
|
|
1003
|
-
policy,
|
|
1004
|
-
principal,
|
|
1005
|
-
rateLimit: result,
|
|
1006
|
-
});
|
|
1007
|
-
}
|
|
1008
1423
|
}
|
|
1009
1424
|
return proceed();
|
|
1010
1425
|
}
|
|
@@ -1074,7 +1489,8 @@ export function require(policy) {
|
|
|
1074
1489
|
* server-side — we just stop waiting for it.
|
|
1075
1490
|
*/
|
|
1076
1491
|
const rateLimitConsumeTimeout = 300;
|
|
1077
|
-
|
|
1492
|
+
/** Consumes one quota and returns null when its counter is unavailable, allowing callers to fail open. */
|
|
1493
|
+
export function consumeRateLimit(auth, options) {
|
|
1078
1494
|
if (!auth.rateLimit)
|
|
1079
1495
|
return Promise.resolve(null);
|
|
1080
1496
|
// Fail open: a rate-limit store error (e.g. a lost Durable Object connection)
|
|
@@ -1160,12 +1576,15 @@ function clientIp(c, auth) {
|
|
|
1160
1576
|
return auth.publicClientIp ? auth.publicClientIp(c.req.raw) : c.req.header('cf-connecting-ip');
|
|
1161
1577
|
}
|
|
1162
1578
|
function trustedClientIp(c, auth) {
|
|
1163
|
-
|
|
1164
|
-
|
|
1579
|
+
return resolveTrustedClientIp(c.req.raw, auth.publicClientIp);
|
|
1580
|
+
}
|
|
1581
|
+
function resolveTrustedClientIp(request, resolve) {
|
|
1582
|
+
if (resolve)
|
|
1583
|
+
return resolve(request);
|
|
1165
1584
|
// Cloudflare supplies both the request metadata and this header.
|
|
1166
|
-
if (!('cf' in
|
|
1585
|
+
if (!('cf' in request))
|
|
1167
1586
|
return undefined;
|
|
1168
|
-
return
|
|
1587
|
+
return request.headers.get('cf-connecting-ip') ?? undefined;
|
|
1169
1588
|
}
|
|
1170
1589
|
/** Removes the reserved auth query parameter before route validation. */
|
|
1171
1590
|
function stripApiKeyQuery(c) {
|
|
@@ -1348,19 +1767,13 @@ function setRateLimitHeaders(c, result) {
|
|
|
1348
1767
|
function contextKv(c) {
|
|
1349
1768
|
return c.get('kv');
|
|
1350
1769
|
}
|
|
1351
|
-
// Resolve the session lane from the auth context's capability.
|
|
1352
|
-
//
|
|
1770
|
+
// Resolve the session lane from the auth context's capability. Dependency
|
|
1771
|
+
// failures propagate to the app error boundary instead of becoming a `401`.
|
|
1353
1772
|
async function resolveSession(c, auth) {
|
|
1354
1773
|
const session = auth.session;
|
|
1355
1774
|
if (!session)
|
|
1356
1775
|
return null;
|
|
1357
|
-
|
|
1358
|
-
return await session.resolve(c);
|
|
1359
|
-
}
|
|
1360
|
-
catch (error) {
|
|
1361
|
-
console.error('[auth] session resolve failed; treating as no session', error);
|
|
1362
|
-
return null;
|
|
1363
|
-
}
|
|
1776
|
+
return session.resolve(c);
|
|
1364
1777
|
}
|
|
1365
1778
|
/** Maximum resolve-cache entries held per isolate before eviction. */
|
|
1366
1779
|
const cachedMaxEntries = 10_000;
|
|
@@ -1377,39 +1790,54 @@ function cachedResolve(resolve, options) {
|
|
|
1377
1790
|
const { negativeTtl = 10_000, now = Date.now, ttl = 60_000 } = options;
|
|
1378
1791
|
const cells = new Map();
|
|
1379
1792
|
const flights = new Map();
|
|
1380
|
-
return
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1793
|
+
return {
|
|
1794
|
+
invalidate(token) {
|
|
1795
|
+
cells.delete(`v1:${ApiKey.hash(token)}`);
|
|
1796
|
+
},
|
|
1797
|
+
peek(token) {
|
|
1798
|
+
const key = `v1:${ApiKey.hash(token)}`;
|
|
1799
|
+
const cell = cells.get(key);
|
|
1800
|
+
if (!cell)
|
|
1801
|
+
return undefined;
|
|
1802
|
+
if (cell.expiresAt > now())
|
|
1803
|
+
return cell.value;
|
|
1387
1804
|
cells.delete(key);
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
const
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1805
|
+
return undefined;
|
|
1806
|
+
},
|
|
1807
|
+
async resolve(c, token) {
|
|
1808
|
+
// Versioned so a future record-shape change can't serve stale shapes.
|
|
1809
|
+
const key = `v1:${ApiKey.hash(token)}`;
|
|
1810
|
+
const cell = cells.get(key);
|
|
1811
|
+
if (cell && cell.expiresAt > now())
|
|
1812
|
+
return cell.value;
|
|
1813
|
+
if (cell)
|
|
1814
|
+
cells.delete(key);
|
|
1815
|
+
const existing = flights.get(key);
|
|
1816
|
+
if (existing)
|
|
1817
|
+
return existing;
|
|
1818
|
+
const flight = (async () => {
|
|
1819
|
+
const value = await resolve(c, token);
|
|
1820
|
+
// Bound the cache: random invalid tokens each add a (negative) entry,
|
|
1821
|
+
// so sweep expired cells at the cap and then drop the oldest.
|
|
1822
|
+
if (cells.size >= cachedMaxEntries) {
|
|
1823
|
+
const time = now();
|
|
1824
|
+
for (const [name, entry] of cells)
|
|
1825
|
+
if (entry.expiresAt <= time)
|
|
1826
|
+
cells.delete(name);
|
|
1827
|
+
while (cells.size >= cachedMaxEntries)
|
|
1828
|
+
cells.delete(cells.keys().next().value);
|
|
1829
|
+
}
|
|
1830
|
+
cells.set(key, { expiresAt: now() + (value ? ttl : negativeTtl), value });
|
|
1831
|
+
return value;
|
|
1832
|
+
})();
|
|
1833
|
+
flights.set(key, flight);
|
|
1834
|
+
try {
|
|
1835
|
+
return await flight;
|
|
1402
1836
|
}
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
try {
|
|
1408
|
-
return await flight;
|
|
1409
|
-
}
|
|
1410
|
-
finally {
|
|
1411
|
-
flights.delete(key);
|
|
1412
|
-
}
|
|
1837
|
+
finally {
|
|
1838
|
+
flights.delete(key);
|
|
1839
|
+
}
|
|
1840
|
+
},
|
|
1413
1841
|
};
|
|
1414
1842
|
}
|
|
1415
1843
|
/** Thrown when a rate-limit consume exceeds {@link rateLimitConsumeTimeout}. */
|