mppx 0.8.15 → 0.8.18
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/CHANGELOG.md +91 -0
- package/README.md +15 -0
- package/dist/Challenge.js +61 -39
- package/dist/Constants.d.ts +17 -17
- package/dist/Errors.d.ts +3 -3
- package/dist/Method.d.ts +35 -5
- package/dist/Method.js +7 -22
- package/dist/Store.d.ts +19 -0
- package/dist/Store.js +43 -0
- package/dist/attestation/Client.d.ts +17 -0
- package/dist/attestation/Client.js +28 -0
- package/dist/attestation/Constants.d.ts +15 -0
- package/dist/attestation/Constants.js +15 -0
- package/dist/attestation/Server.d.ts +4 -0
- package/dist/attestation/Server.js +8 -0
- package/dist/attestation/Types.d.ts +76 -0
- package/dist/attestation/Types.js +2 -0
- package/dist/attestation/index.d.ts +6 -0
- package/dist/attestation/index.js +6 -0
- package/dist/attestation/internal/HttpMessageSignature.d.ts +73 -0
- package/dist/attestation/internal/HttpMessageSignature.js +320 -0
- package/dist/attestation/internal/SigningContext.d.ts +4 -0
- package/dist/attestation/internal/SigningContext.js +11 -0
- package/dist/bin.js +3 -3
- package/dist/cli/THIRD-PARTY-LICENSES.txt +328 -0
- package/dist/cli/account.d.ts +14 -14
- package/dist/cli/cli.d.ts +6 -6
- package/dist/cli/cli.js +253 -1504
- package/dist/cli/plugins/index.js +19 -5
- package/dist/cli/plugins/tempo.js +7 -3
- package/dist/cli/sessions/Manager.js +7 -4
- package/dist/cli/sessions/commands.d.ts +4 -4
- package/dist/cli/sessions/request.d.ts +2 -0
- package/dist/cli/sessions/request.js +18 -0
- package/dist/cli/sessions/store.js +28 -14
- package/dist/cli/utils.d.ts +1 -1
- package/dist/cli/validate/index.d.ts +3 -3
- package/dist/client/Mppx.d.ts +3 -0
- package/dist/client/Mppx.js +13 -5
- package/dist/client/Transport.d.ts +3 -5
- package/dist/client/Transport.js +1 -17
- package/dist/client/internal/Fetch.js +2 -6
- package/dist/discovery/Discovery.js +2 -1
- package/dist/discovery/OpenApi.d.ts +3 -5
- package/dist/discovery/OpenApi.js +13 -34
- package/dist/discovery/internal/Metadata.d.ts +20 -0
- package/dist/discovery/internal/Metadata.js +36 -0
- package/dist/evm/Methods.d.ts +11 -11
- package/dist/evm/Types.d.ts +17 -17
- package/dist/evm/client/Charge.d.ts +11 -11
- package/dist/evm/client/Charge.js +8 -0
- package/dist/evm/client/Methods.d.ts +11 -11
- package/dist/evm/server/Charge.d.ts +1 -1
- package/dist/evm/server/Charge.js +2 -0
- package/dist/evm/server/Methods.d.ts +11 -11
- package/dist/internal/HeaderCodec.d.ts +2 -2
- package/dist/internal/types.d.ts +6 -0
- package/dist/proxy/Proxy.d.ts +2 -0
- package/dist/proxy/Proxy.js +117 -9
- package/dist/proxy/Service.d.ts +36 -1
- package/dist/proxy/Service.js +9 -8
- package/dist/proxy/services/anthropic.js +1 -0
- package/dist/proxy/services/openai.js +1 -0
- package/dist/proxy/services/stripe.js +1 -0
- package/dist/server/Mppx.d.ts +75 -13
- package/dist/server/Mppx.js +201 -23
- package/dist/server/core.d.ts +9 -0
- package/dist/server/core.js +9 -0
- package/dist/server/internal/html/config.d.ts +9 -9
- package/dist/server/internal/html/constants.d.ts +17 -17
- package/dist/stripe/Methods.d.ts +10 -10
- package/dist/stripe/client/Charge.d.ts +10 -10
- package/dist/stripe/client/Methods.d.ts +10 -10
- package/dist/stripe/internal/constants.d.ts +1 -1
- package/dist/stripe/internal/constants.js +1 -1
- package/dist/stripe/internal/types.d.ts +1 -0
- package/dist/stripe/server/Charge.d.ts +11 -11
- package/dist/stripe/server/Charge.js +51 -5
- package/dist/stripe/server/Methods.d.ts +137 -48
- package/dist/stripe/server/Methods.js +265 -4
- package/dist/stripe/server/internal/deposit-address.d.ts +13 -0
- package/dist/stripe/server/internal/deposit-address.js +28 -0
- package/dist/stripe/server/internal/html.gen.d.ts +1 -1
- package/dist/stripe/server/internal/html.gen.js +1 -1
- package/dist/stripe/server/internal/record-payment.d.ts +15 -0
- package/dist/stripe/server/internal/record-payment.js +42 -0
- package/dist/stripe/server/internal/request.d.ts +25 -0
- package/dist/stripe/server/internal/request.js +29 -0
- package/dist/stripe/server/spt.d.ts +8 -0
- package/dist/stripe/server/spt.js +8 -0
- package/dist/tap/Constants.d.ts +28 -0
- package/dist/tap/Constants.js +32 -0
- package/dist/tap/Types.d.ts +11 -0
- package/dist/tap/Types.js +2 -0
- package/dist/tap/client/index.d.ts +26 -0
- package/dist/tap/client/index.js +33 -0
- package/dist/tap/index.d.ts +5 -0
- package/dist/tap/index.js +5 -0
- package/dist/tap/server/index.d.ts +20 -0
- package/dist/tap/server/index.js +36 -0
- package/dist/tempo/Attribution.d.ts +1 -1
- package/dist/tempo/Methods.d.ts +73 -60
- package/dist/tempo/Methods.js +14 -3
- package/dist/tempo/Proof.d.ts +16 -16
- package/dist/tempo/client/Charge.d.ts +22 -19
- package/dist/tempo/client/Charge.js +32 -16
- package/dist/tempo/client/Methods.d.ts +51 -38
- package/dist/tempo/client/Subscription.d.ts +23 -23
- package/dist/tempo/internal/address.d.ts +2 -1
- package/dist/tempo/internal/address.js +3 -1
- package/dist/tempo/internal/auto-swap.js +4 -19
- package/dist/tempo/internal/defaults.d.ts +17 -6
- package/dist/tempo/internal/defaults.js +11 -0
- package/dist/tempo/internal/fee-payer.d.ts +12 -12
- package/dist/tempo/internal/machine-token-charge.d.ts +51 -0
- package/dist/tempo/internal/machine-token-charge.js +113 -0
- package/dist/tempo/internal/machine-token-session.d.ts +88 -0
- package/dist/tempo/internal/machine-token-session.js +173 -0
- package/dist/tempo/internal/proof.d.ts +17 -17
- package/dist/tempo/internal/signature-envelope.d.ts +14 -0
- package/dist/tempo/internal/signature-envelope.js +28 -0
- package/dist/tempo/legacy/client/ChannelOps.d.ts +2 -2
- package/dist/tempo/legacy/client/ChannelOps.js +11 -5
- package/dist/tempo/legacy/client/Session.d.ts +33 -21
- package/dist/tempo/legacy/client/Session.js +3 -3
- package/dist/tempo/legacy/client/SessionManager.d.ts +3 -1
- package/dist/tempo/legacy/client/SessionManager.js +2 -0
- package/dist/tempo/legacy/index.d.ts +1 -3
- package/dist/tempo/legacy/index.js +1 -3
- package/dist/tempo/legacy/session/escrow.abi.d.ts +374 -374
- package/dist/tempo/server/Charge.d.ts +28 -11
- package/dist/tempo/server/Charge.js +101 -55
- package/dist/tempo/server/Methods.d.ts +58 -56
- package/dist/tempo/server/Methods.js +8 -18
- package/dist/tempo/server/Relay.d.ts +1 -1
- package/dist/tempo/server/Relay.js +2 -2
- package/dist/tempo/server/Subscription.d.ts +25 -25
- package/dist/tempo/server/Subscription.js +2 -0
- package/dist/tempo/server/index.d.ts +1 -1
- package/dist/tempo/server/index.js +1 -1
- package/dist/tempo/server/internal/html.gen.d.ts +1 -1
- package/dist/tempo/server/internal/html.gen.js +1 -1
- package/dist/tempo/server/internal/transport.d.ts +2 -0
- package/dist/tempo/server/internal/transport.js +9 -2
- package/dist/tempo/session/client/ChannelOps.d.ts +18 -3
- package/dist/tempo/session/client/ChannelOps.js +35 -6
- package/dist/tempo/session/client/ChannelStore.d.ts +0 -5
- package/dist/tempo/session/client/ChannelStore.js +2 -2
- package/dist/tempo/session/client/CredentialState.d.ts +18 -3
- package/dist/tempo/session/client/CredentialState.js +77 -76
- package/dist/tempo/session/client/Runtime.d.ts +4 -2
- package/dist/tempo/session/client/Runtime.js +21 -5
- package/dist/tempo/session/client/Session.d.ts +34 -22
- package/dist/tempo/session/client/Session.js +186 -63
- package/dist/tempo/session/client/SessionManager.d.ts +3 -1
- package/dist/tempo/session/client/SessionManager.js +35 -11
- package/dist/tempo/session/client/Transports.d.ts +2 -0
- package/dist/tempo/session/client/Transports.js +12 -2
- package/dist/tempo/session/precompile/Chain.d.ts +37 -2
- package/dist/tempo/session/precompile/Chain.js +116 -15
- package/dist/tempo/session/precompile/Protocol.d.ts +15 -0
- package/dist/tempo/session/precompile/Protocol.js +7 -0
- package/dist/tempo/session/precompile/Voucher.d.ts +7 -5
- package/dist/tempo/session/precompile/Voucher.js +6 -12
- package/dist/tempo/session/precompile/escrow.abi.d.ts +306 -306
- package/dist/tempo/session/server/ChannelStore.d.ts +15 -0
- package/dist/tempo/session/server/ChannelStore.js +27 -12
- package/dist/tempo/session/server/CredentialVerification.d.ts +39 -20
- package/dist/tempo/session/server/CredentialVerification.js +359 -89
- package/dist/tempo/session/server/MeteredStream.d.ts +4 -1
- package/dist/tempo/session/server/MeteredStream.js +8 -5
- package/dist/tempo/session/server/RequestState.d.ts +19 -0
- package/dist/tempo/session/server/RequestState.js +61 -15
- package/dist/tempo/session/server/Session.d.ts +46 -23
- package/dist/tempo/session/server/Session.js +150 -56
- package/dist/tempo/session/server/Settlement.d.ts +11 -4
- package/dist/tempo/session/server/Settlement.js +53 -21
- package/dist/tempo/session/server/Sse.d.ts +3 -1
- package/dist/tempo/session/server/Sse.js +2 -1
- package/dist/tempo/session/server/Transports.d.ts +1 -1
- package/dist/tempo/session/server/Transports.js +1 -0
- package/dist/tempo/session/server/Ws.d.ts +6 -1
- package/dist/tempo/session/server/Ws.js +1 -0
- package/dist/tempo/subscription/KeyAuthorization.d.ts +39 -39
- package/dist/web-bot-auth/Constants.d.ts +20 -0
- package/dist/web-bot-auth/Constants.js +24 -0
- package/dist/web-bot-auth/Types.d.ts +10 -0
- package/dist/web-bot-auth/Types.js +2 -0
- package/dist/web-bot-auth/client/index.d.ts +29 -0
- package/dist/web-bot-auth/client/index.js +64 -0
- package/dist/web-bot-auth/index.d.ts +7 -0
- package/dist/web-bot-auth/index.js +7 -0
- package/dist/web-bot-auth/internal/JwkThumbprint.d.ts +5 -0
- package/dist/web-bot-auth/internal/JwkThumbprint.js +20 -0
- package/dist/web-bot-auth/internal/SignatureAgent.d.ts +3 -0
- package/dist/web-bot-auth/internal/SignatureAgent.js +18 -0
- package/dist/web-bot-auth/server/index.d.ts +35 -0
- package/dist/web-bot-auth/server/index.js +88 -0
- package/dist/x402/Types.d.ts +6 -6
- package/dist/x402/client/Exact.d.ts +8 -0
- package/dist/x402/client/Exact.js +40 -10
- package/dist/x402/server/EvmCharge.d.ts +22 -0
- package/dist/x402/server/EvmCharge.js +54 -20
- package/package.json +28 -34
- package/dist/BodyDigest.d.ts.map +0 -1
- package/dist/BodyDigest.js.map +0 -1
- package/dist/Challenge.d.ts.map +0 -1
- package/dist/Challenge.js.map +0 -1
- package/dist/Constants.d.ts.map +0 -1
- package/dist/Constants.js.map +0 -1
- package/dist/Credential.d.ts.map +0 -1
- package/dist/Credential.js.map +0 -1
- package/dist/Errors.d.ts.map +0 -1
- package/dist/Errors.js.map +0 -1
- package/dist/Expires.d.ts.map +0 -1
- package/dist/Expires.js.map +0 -1
- package/dist/Html.d.ts.map +0 -1
- package/dist/Html.js.map +0 -1
- package/dist/Mcp.d.ts.map +0 -1
- package/dist/Mcp.js.map +0 -1
- package/dist/Method.d.ts.map +0 -1
- package/dist/Method.js.map +0 -1
- package/dist/PaymentRequest.d.ts.map +0 -1
- package/dist/PaymentRequest.js.map +0 -1
- package/dist/Receipt.d.ts.map +0 -1
- package/dist/Receipt.js.map +0 -1
- package/dist/Store.d.ts.map +0 -1
- package/dist/Store.js.map +0 -1
- package/dist/bin.d.ts.map +0 -1
- package/dist/bin.js.map +0 -1
- package/dist/cli/account.d.ts.map +0 -1
- package/dist/cli/account.js.map +0 -1
- package/dist/cli/cli.d.ts.map +0 -1
- package/dist/cli/cli.js.map +0 -1
- package/dist/cli/config.d.ts.map +0 -1
- package/dist/cli/config.js.map +0 -1
- package/dist/cli/internal.d.ts.map +0 -1
- package/dist/cli/internal.js.map +0 -1
- package/dist/cli/plugins/evm.d.ts.map +0 -1
- package/dist/cli/plugins/evm.js.map +0 -1
- package/dist/cli/plugins/index.d.ts.map +0 -1
- package/dist/cli/plugins/index.js.map +0 -1
- package/dist/cli/plugins/plugin.d.ts.map +0 -1
- package/dist/cli/plugins/plugin.js.map +0 -1
- package/dist/cli/plugins/stripe.d.ts.map +0 -1
- package/dist/cli/plugins/stripe.js.map +0 -1
- package/dist/cli/plugins/tempo.d.ts.map +0 -1
- package/dist/cli/plugins/tempo.js.map +0 -1
- package/dist/cli/sessions/Manager.d.ts.map +0 -1
- package/dist/cli/sessions/Manager.js.map +0 -1
- package/dist/cli/sessions/commands.d.ts.map +0 -1
- package/dist/cli/sessions/commands.js.map +0 -1
- package/dist/cli/sessions/request.d.ts.map +0 -1
- package/dist/cli/sessions/request.js.map +0 -1
- package/dist/cli/sessions/store.d.ts.map +0 -1
- package/dist/cli/sessions/store.js.map +0 -1
- package/dist/cli/utils.d.ts.map +0 -1
- package/dist/cli/utils.js.map +0 -1
- package/dist/cli/validate/challenge.d.ts.map +0 -1
- package/dist/cli/validate/challenge.js.map +0 -1
- package/dist/cli/validate/discovery.d.ts.map +0 -1
- package/dist/cli/validate/discovery.js.map +0 -1
- package/dist/cli/validate/helpers.d.ts.map +0 -1
- package/dist/cli/validate/helpers.js.map +0 -1
- package/dist/cli/validate/index.d.ts.map +0 -1
- package/dist/cli/validate/index.js.map +0 -1
- package/dist/cli/validate/messages.d.ts.map +0 -1
- package/dist/cli/validate/messages.js.map +0 -1
- package/dist/cli/validate/payment.d.ts.map +0 -1
- package/dist/cli/validate/payment.js.map +0 -1
- package/dist/client/Methods.d.ts.map +0 -1
- package/dist/client/Methods.js.map +0 -1
- package/dist/client/Mppx.d.ts.map +0 -1
- package/dist/client/Mppx.js.map +0 -1
- package/dist/client/Transport.d.ts.map +0 -1
- package/dist/client/Transport.js.map +0 -1
- package/dist/client/index.d.ts.map +0 -1
- package/dist/client/index.js.map +0 -1
- package/dist/client/internal/Fetch.d.ts.map +0 -1
- package/dist/client/internal/Fetch.js.map +0 -1
- package/dist/client/internal/MethodChallenge.d.ts.map +0 -1
- package/dist/client/internal/MethodChallenge.js.map +0 -1
- package/dist/client/internal/MethodResponse.d.ts.map +0 -1
- package/dist/client/internal/MethodResponse.js.map +0 -1
- package/dist/client/internal/protocols/Mcp.d.ts.map +0 -1
- package/dist/client/internal/protocols/Mcp.js.map +0 -1
- package/dist/client/internal/protocols/Mpp.d.ts.map +0 -1
- package/dist/client/internal/protocols/Mpp.js.map +0 -1
- package/dist/client/internal/protocols/Protocol.d.ts.map +0 -1
- package/dist/client/internal/protocols/Protocol.js.map +0 -1
- package/dist/client/internal/protocols/Shared.d.ts.map +0 -1
- package/dist/client/internal/protocols/Shared.js.map +0 -1
- package/dist/client/internal/protocols/X402.d.ts.map +0 -1
- package/dist/client/internal/protocols/X402.js.map +0 -1
- package/dist/client/node.d.ts.map +0 -1
- package/dist/client/node.js.map +0 -1
- package/dist/discovery/Discovery.d.ts.map +0 -1
- package/dist/discovery/Discovery.js.map +0 -1
- package/dist/discovery/OpenApi.d.ts.map +0 -1
- package/dist/discovery/OpenApi.js.map +0 -1
- package/dist/discovery/Validate.d.ts.map +0 -1
- package/dist/discovery/Validate.js.map +0 -1
- package/dist/discovery/index.d.ts.map +0 -1
- package/dist/discovery/index.js.map +0 -1
- package/dist/evm/Assets.d.ts.map +0 -1
- package/dist/evm/Assets.js.map +0 -1
- package/dist/evm/Chains.d.ts.map +0 -1
- package/dist/evm/Chains.js.map +0 -1
- package/dist/evm/Methods.d.ts.map +0 -1
- package/dist/evm/Methods.js.map +0 -1
- package/dist/evm/Types.d.ts.map +0 -1
- package/dist/evm/Types.js.map +0 -1
- package/dist/evm/client/Charge.d.ts.map +0 -1
- package/dist/evm/client/Charge.js.map +0 -1
- package/dist/evm/client/Methods.d.ts.map +0 -1
- package/dist/evm/client/Methods.js.map +0 -1
- package/dist/evm/client/index.d.ts.map +0 -1
- package/dist/evm/client/index.js.map +0 -1
- package/dist/evm/index.d.ts.map +0 -1
- package/dist/evm/index.js.map +0 -1
- package/dist/evm/server/Charge.d.ts.map +0 -1
- package/dist/evm/server/Charge.js.map +0 -1
- package/dist/evm/server/Methods.d.ts.map +0 -1
- package/dist/evm/server/Methods.js.map +0 -1
- package/dist/evm/server/index.d.ts.map +0 -1
- package/dist/evm/server/index.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/internal/AcceptPayment.d.ts.map +0 -1
- package/dist/internal/AcceptPayment.js.map +0 -1
- package/dist/internal/HeaderCodec.d.ts.map +0 -1
- package/dist/internal/HeaderCodec.js.map +0 -1
- package/dist/internal/constantTimeEqual.d.ts.map +0 -1
- package/dist/internal/constantTimeEqual.js.map +0 -1
- package/dist/internal/env.d.ts.map +0 -1
- package/dist/internal/env.js.map +0 -1
- package/dist/internal/types.d.ts.map +0 -1
- package/dist/internal/types.js.map +0 -1
- package/dist/mcp/client/McpClient.d.ts.map +0 -1
- package/dist/mcp/client/McpClient.js.map +0 -1
- package/dist/mcp/client/index.d.ts.map +0 -1
- package/dist/mcp/client/index.js.map +0 -1
- package/dist/mcp/server/Transport.d.ts.map +0 -1
- package/dist/mcp/server/Transport.js.map +0 -1
- package/dist/mcp/server/index.d.ts.map +0 -1
- package/dist/mcp/server/index.js.map +0 -1
- package/dist/middlewares/elysia.d.ts.map +0 -1
- package/dist/middlewares/elysia.js.map +0 -1
- package/dist/middlewares/express.d.ts.map +0 -1
- package/dist/middlewares/express.js.map +0 -1
- package/dist/middlewares/hono.d.ts.map +0 -1
- package/dist/middlewares/hono.js.map +0 -1
- package/dist/middlewares/internal/mppx.d.ts.map +0 -1
- package/dist/middlewares/internal/mppx.js.map +0 -1
- package/dist/middlewares/nextjs.d.ts.map +0 -1
- package/dist/middlewares/nextjs.js.map +0 -1
- package/dist/proxy/Proxy.d.ts.map +0 -1
- package/dist/proxy/Proxy.js.map +0 -1
- package/dist/proxy/Service.d.ts.map +0 -1
- package/dist/proxy/Service.js.map +0 -1
- package/dist/proxy/index.d.ts.map +0 -1
- package/dist/proxy/index.js.map +0 -1
- package/dist/proxy/internal/Headers.d.ts.map +0 -1
- package/dist/proxy/internal/Headers.js.map +0 -1
- package/dist/proxy/internal/Route.d.ts.map +0 -1
- package/dist/proxy/internal/Route.js.map +0 -1
- package/dist/proxy/services/anthropic.d.ts.map +0 -1
- package/dist/proxy/services/anthropic.js.map +0 -1
- package/dist/proxy/services/openai.d.ts.map +0 -1
- package/dist/proxy/services/openai.js.map +0 -1
- package/dist/proxy/services/stripe.d.ts.map +0 -1
- package/dist/proxy/services/stripe.js.map +0 -1
- package/dist/server/Methods.d.ts.map +0 -1
- package/dist/server/Methods.js.map +0 -1
- package/dist/server/Mppx.d.ts.map +0 -1
- package/dist/server/Mppx.js.map +0 -1
- package/dist/server/NodeListener.d.ts.map +0 -1
- package/dist/server/NodeListener.js.map +0 -1
- package/dist/server/Request.d.ts.map +0 -1
- package/dist/server/Request.js.map +0 -1
- package/dist/server/Response.d.ts.map +0 -1
- package/dist/server/Response.js.map +0 -1
- package/dist/server/Transport.d.ts.map +0 -1
- package/dist/server/Transport.js.map +0 -1
- package/dist/server/index.d.ts.map +0 -1
- package/dist/server/index.js.map +0 -1
- package/dist/server/internal/html/compose.main.gen.d.ts.map +0 -1
- package/dist/server/internal/html/compose.main.gen.js.map +0 -1
- package/dist/server/internal/html/config.d.ts.map +0 -1
- package/dist/server/internal/html/config.js.map +0 -1
- package/dist/server/internal/html/constants.d.ts.map +0 -1
- package/dist/server/internal/html/constants.js.map +0 -1
- package/dist/server/internal/html/serviceWorker.client.d.ts.map +0 -1
- package/dist/server/internal/html/serviceWorker.client.js.map +0 -1
- package/dist/server/internal/html/serviceWorker.gen.d.ts.map +0 -1
- package/dist/server/internal/html/serviceWorker.gen.js.map +0 -1
- package/dist/server/internal/scope.d.ts.map +0 -1
- package/dist/server/internal/scope.js.map +0 -1
- package/dist/stripe/Methods.d.ts.map +0 -1
- package/dist/stripe/Methods.js.map +0 -1
- package/dist/stripe/client/Charge.d.ts.map +0 -1
- package/dist/stripe/client/Charge.js.map +0 -1
- package/dist/stripe/client/Methods.d.ts.map +0 -1
- package/dist/stripe/client/Methods.js.map +0 -1
- package/dist/stripe/client/index.d.ts.map +0 -1
- package/dist/stripe/client/index.js.map +0 -1
- package/dist/stripe/index.d.ts.map +0 -1
- package/dist/stripe/index.js.map +0 -1
- package/dist/stripe/internal/constants.d.ts.map +0 -1
- package/dist/stripe/internal/constants.js.map +0 -1
- package/dist/stripe/internal/types.d.ts.map +0 -1
- package/dist/stripe/internal/types.js.map +0 -1
- package/dist/stripe/server/Charge.d.ts.map +0 -1
- package/dist/stripe/server/Charge.js.map +0 -1
- package/dist/stripe/server/Methods.d.ts.map +0 -1
- package/dist/stripe/server/Methods.js.map +0 -1
- package/dist/stripe/server/index.d.ts.map +0 -1
- package/dist/stripe/server/index.js.map +0 -1
- package/dist/stripe/server/internal/html/types.d.ts.map +0 -1
- package/dist/stripe/server/internal/html/types.js.map +0 -1
- package/dist/stripe/server/internal/html.gen.d.ts.map +0 -1
- package/dist/stripe/server/internal/html.gen.js.map +0 -1
- package/dist/tempo/Attribution.d.ts.map +0 -1
- package/dist/tempo/Attribution.js.map +0 -1
- package/dist/tempo/Methods.d.ts.map +0 -1
- package/dist/tempo/Methods.js.map +0 -1
- package/dist/tempo/Proof.d.ts.map +0 -1
- package/dist/tempo/Proof.js.map +0 -1
- package/dist/tempo/client/Charge.d.ts.map +0 -1
- package/dist/tempo/client/Charge.js.map +0 -1
- package/dist/tempo/client/Methods.d.ts.map +0 -1
- package/dist/tempo/client/Methods.js.map +0 -1
- package/dist/tempo/client/ResolveAccount.d.ts.map +0 -1
- package/dist/tempo/client/ResolveAccount.js.map +0 -1
- package/dist/tempo/client/Subscription.d.ts.map +0 -1
- package/dist/tempo/client/Subscription.js.map +0 -1
- package/dist/tempo/client/index.d.ts.map +0 -1
- package/dist/tempo/client/index.js.map +0 -1
- package/dist/tempo/index.d.ts.map +0 -1
- package/dist/tempo/index.js.map +0 -1
- package/dist/tempo/internal/account.d.ts.map +0 -1
- package/dist/tempo/internal/account.js.map +0 -1
- package/dist/tempo/internal/address.d.ts.map +0 -1
- package/dist/tempo/internal/address.js.map +0 -1
- package/dist/tempo/internal/auto-swap.d.ts.map +0 -1
- package/dist/tempo/internal/auto-swap.js.map +0 -1
- package/dist/tempo/internal/charge.d.ts.map +0 -1
- package/dist/tempo/internal/charge.js.map +0 -1
- package/dist/tempo/internal/defaults.d.ts.map +0 -1
- package/dist/tempo/internal/defaults.js.map +0 -1
- package/dist/tempo/internal/fee-payer.d.ts.map +0 -1
- package/dist/tempo/internal/fee-payer.js.map +0 -1
- package/dist/tempo/internal/fee-token.d.ts.map +0 -1
- package/dist/tempo/internal/fee-token.js.map +0 -1
- package/dist/tempo/internal/proof.d.ts.map +0 -1
- package/dist/tempo/internal/proof.js.map +0 -1
- package/dist/tempo/internal/selectors.d.ts.map +0 -1
- package/dist/tempo/internal/selectors.js.map +0 -1
- package/dist/tempo/internal/types.d.ts.map +0 -1
- package/dist/tempo/internal/types.js.map +0 -1
- package/dist/tempo/legacy/client/ChannelOps.d.ts.map +0 -1
- package/dist/tempo/legacy/client/ChannelOps.js.map +0 -1
- package/dist/tempo/legacy/client/Session.d.ts.map +0 -1
- package/dist/tempo/legacy/client/Session.js.map +0 -1
- package/dist/tempo/legacy/client/SessionManager.d.ts.map +0 -1
- package/dist/tempo/legacy/client/SessionManager.js.map +0 -1
- package/dist/tempo/legacy/client/index.d.ts.map +0 -1
- package/dist/tempo/legacy/client/index.js.map +0 -1
- package/dist/tempo/legacy/index.d.ts.map +0 -1
- package/dist/tempo/legacy/index.js.map +0 -1
- package/dist/tempo/legacy/server/Session.d.ts +0 -208
- package/dist/tempo/legacy/server/Session.d.ts.map +0 -1
- package/dist/tempo/legacy/server/Session.js +0 -698
- package/dist/tempo/legacy/server/Session.js.map +0 -1
- package/dist/tempo/legacy/server/index.d.ts +0 -5
- package/dist/tempo/legacy/server/index.d.ts.map +0 -1
- package/dist/tempo/legacy/server/index.js +0 -5
- package/dist/tempo/legacy/server/index.js.map +0 -1
- package/dist/tempo/legacy/session/Chain.d.ts.map +0 -1
- package/dist/tempo/legacy/session/Chain.js.map +0 -1
- package/dist/tempo/legacy/session/Channel.d.ts.map +0 -1
- package/dist/tempo/legacy/session/Channel.js.map +0 -1
- package/dist/tempo/legacy/session/ChannelStore.d.ts +0 -22
- package/dist/tempo/legacy/session/ChannelStore.d.ts.map +0 -1
- package/dist/tempo/legacy/session/ChannelStore.js +0 -6
- package/dist/tempo/legacy/session/ChannelStore.js.map +0 -1
- package/dist/tempo/legacy/session/Types.d.ts.map +0 -1
- package/dist/tempo/legacy/session/Types.js.map +0 -1
- package/dist/tempo/legacy/session/Voucher.d.ts.map +0 -1
- package/dist/tempo/legacy/session/Voucher.js.map +0 -1
- package/dist/tempo/legacy/session/escrow.abi.d.ts.map +0 -1
- package/dist/tempo/legacy/session/escrow.abi.js.map +0 -1
- package/dist/tempo/legacy/session/index.d.ts.map +0 -1
- package/dist/tempo/legacy/session/index.js.map +0 -1
- package/dist/tempo/server/Charge.d.ts.map +0 -1
- package/dist/tempo/server/Charge.js.map +0 -1
- package/dist/tempo/server/Methods.d.ts.map +0 -1
- package/dist/tempo/server/Methods.js.map +0 -1
- package/dist/tempo/server/Relay.d.ts.map +0 -1
- package/dist/tempo/server/Relay.js.map +0 -1
- package/dist/tempo/server/SponsorBudget.d.ts.map +0 -1
- package/dist/tempo/server/SponsorBudget.js.map +0 -1
- package/dist/tempo/server/Subscription.d.ts.map +0 -1
- package/dist/tempo/server/Subscription.js.map +0 -1
- package/dist/tempo/server/index.d.ts.map +0 -1
- package/dist/tempo/server/index.js.map +0 -1
- package/dist/tempo/server/internal/html.gen.d.ts.map +0 -1
- package/dist/tempo/server/internal/html.gen.js.map +0 -1
- package/dist/tempo/server/internal/request-body.d.ts.map +0 -1
- package/dist/tempo/server/internal/request-body.js.map +0 -1
- package/dist/tempo/server/internal/transport.d.ts.map +0 -1
- package/dist/tempo/server/internal/transport.js.map +0 -1
- package/dist/tempo/session/Snapshot.d.ts.map +0 -1
- package/dist/tempo/session/Snapshot.js.map +0 -1
- package/dist/tempo/session/client/ChannelOps.d.ts.map +0 -1
- package/dist/tempo/session/client/ChannelOps.js.map +0 -1
- package/dist/tempo/session/client/ChannelStore.d.ts.map +0 -1
- package/dist/tempo/session/client/ChannelStore.js.map +0 -1
- package/dist/tempo/session/client/CredentialState.d.ts.map +0 -1
- package/dist/tempo/session/client/CredentialState.js.map +0 -1
- package/dist/tempo/session/client/ReceiptCoordinator.d.ts.map +0 -1
- package/dist/tempo/session/client/ReceiptCoordinator.js.map +0 -1
- package/dist/tempo/session/client/Runtime.d.ts.map +0 -1
- package/dist/tempo/session/client/Runtime.js.map +0 -1
- package/dist/tempo/session/client/Session.d.ts.map +0 -1
- package/dist/tempo/session/client/Session.js.map +0 -1
- package/dist/tempo/session/client/SessionManager.d.ts.map +0 -1
- package/dist/tempo/session/client/SessionManager.js.map +0 -1
- package/dist/tempo/session/client/Transports.d.ts.map +0 -1
- package/dist/tempo/session/client/Transports.js.map +0 -1
- package/dist/tempo/session/client/index.d.ts.map +0 -1
- package/dist/tempo/session/client/index.js.map +0 -1
- package/dist/tempo/session/client/internal/SessionManager.d.ts.map +0 -1
- package/dist/tempo/session/client/internal/SessionManager.js.map +0 -1
- package/dist/tempo/session/index.d.ts.map +0 -1
- package/dist/tempo/session/index.js.map +0 -1
- package/dist/tempo/session/precompile/Chain.d.ts.map +0 -1
- package/dist/tempo/session/precompile/Chain.js.map +0 -1
- package/dist/tempo/session/precompile/Channel.d.ts.map +0 -1
- package/dist/tempo/session/precompile/Channel.js.map +0 -1
- package/dist/tempo/session/precompile/Protocol.d.ts.map +0 -1
- package/dist/tempo/session/precompile/Protocol.js.map +0 -1
- package/dist/tempo/session/precompile/Voucher.d.ts.map +0 -1
- package/dist/tempo/session/precompile/Voucher.js.map +0 -1
- package/dist/tempo/session/precompile/escrow.abi.d.ts.map +0 -1
- package/dist/tempo/session/precompile/escrow.abi.js.map +0 -1
- package/dist/tempo/session/precompile/index.d.ts.map +0 -1
- package/dist/tempo/session/precompile/index.js.map +0 -1
- package/dist/tempo/session/server/ChannelOps.d.ts.map +0 -1
- package/dist/tempo/session/server/ChannelOps.js.map +0 -1
- package/dist/tempo/session/server/ChannelStore.d.ts.map +0 -1
- package/dist/tempo/session/server/ChannelStore.js.map +0 -1
- package/dist/tempo/session/server/CredentialVerification.d.ts.map +0 -1
- package/dist/tempo/session/server/CredentialVerification.js.map +0 -1
- package/dist/tempo/session/server/MeteredStream.d.ts.map +0 -1
- package/dist/tempo/session/server/MeteredStream.js.map +0 -1
- package/dist/tempo/session/server/RequestState.d.ts.map +0 -1
- package/dist/tempo/session/server/RequestState.js.map +0 -1
- package/dist/tempo/session/server/Session.d.ts.map +0 -1
- package/dist/tempo/session/server/Session.js.map +0 -1
- package/dist/tempo/session/server/Settlement.d.ts.map +0 -1
- package/dist/tempo/session/server/Settlement.js.map +0 -1
- package/dist/tempo/session/server/Sse.d.ts.map +0 -1
- package/dist/tempo/session/server/Sse.js.map +0 -1
- package/dist/tempo/session/server/Transports.d.ts.map +0 -1
- package/dist/tempo/session/server/Transports.js.map +0 -1
- package/dist/tempo/session/server/Ws.d.ts.map +0 -1
- package/dist/tempo/session/server/Ws.js.map +0 -1
- package/dist/tempo/session/server/index.d.ts.map +0 -1
- package/dist/tempo/session/server/index.js.map +0 -1
- package/dist/tempo/subscription/KeyAuthorization.d.ts.map +0 -1
- package/dist/tempo/subscription/KeyAuthorization.js.map +0 -1
- package/dist/tempo/subscription/Receipt.d.ts.map +0 -1
- package/dist/tempo/subscription/Receipt.js.map +0 -1
- package/dist/tempo/subscription/Store.d.ts.map +0 -1
- package/dist/tempo/subscription/Store.js.map +0 -1
- package/dist/tempo/subscription/Types.d.ts.map +0 -1
- package/dist/tempo/subscription/Types.js.map +0 -1
- package/dist/tempo/subscription/index.d.ts.map +0 -1
- package/dist/tempo/subscription/index.js.map +0 -1
- package/dist/validation/core.d.ts.map +0 -1
- package/dist/validation/core.js.map +0 -1
- package/dist/validation/index.d.ts.map +0 -1
- package/dist/validation/index.js.map +0 -1
- package/dist/viem/Account.d.ts.map +0 -1
- package/dist/viem/Account.js.map +0 -1
- package/dist/viem/Client.d.ts.map +0 -1
- package/dist/viem/Client.js.map +0 -1
- package/dist/x402/Assets.d.ts.map +0 -1
- package/dist/x402/Assets.js.map +0 -1
- package/dist/x402/Header.d.ts.map +0 -1
- package/dist/x402/Header.js.map +0 -1
- package/dist/x402/Types.d.ts.map +0 -1
- package/dist/x402/Types.js.map +0 -1
- package/dist/x402/client/Exact.d.ts.map +0 -1
- package/dist/x402/client/Exact.js.map +0 -1
- package/dist/x402/index.d.ts.map +0 -1
- package/dist/x402/index.js.map +0 -1
- package/dist/x402/internal/ChallengeBrand.d.ts.map +0 -1
- package/dist/x402/internal/ChallengeBrand.js.map +0 -1
- package/dist/x402/internal/RouteBinding.d.ts.map +0 -1
- package/dist/x402/internal/RouteBinding.js.map +0 -1
- package/dist/x402/server/EvmCharge.d.ts.map +0 -1
- package/dist/x402/server/EvmCharge.js.map +0 -1
- package/dist/x402/server/Facilitator.d.ts.map +0 -1
- package/dist/x402/server/Facilitator.js.map +0 -1
- package/dist/zod.d.ts.map +0 -1
- package/dist/zod.js.map +0 -1
- package/src/BodyDigest.test.ts +0 -43
- package/src/BodyDigest.ts +0 -55
- package/src/Challenge.fuzz.test.ts +0 -121
- package/src/Challenge.test-d.ts +0 -82
- package/src/Challenge.test.ts +0 -995
- package/src/Challenge.ts +0 -683
- package/src/Constants.ts +0 -58
- package/src/Credential.fuzz.test.ts +0 -62
- package/src/Credential.test.ts +0 -378
- package/src/Credential.ts +0 -217
- package/src/Errors.test.ts +0 -520
- package/src/Errors.ts +0 -448
- package/src/Expires.test.ts +0 -112
- package/src/Expires.ts +0 -59
- package/src/Html.ts +0 -67
- package/src/Mcp.ts +0 -85
- package/src/Method.test.ts +0 -177
- package/src/Method.ts +0 -617
- package/src/PaymentRequest.test.ts +0 -147
- package/src/PaymentRequest.ts +0 -108
- package/src/Receipt.test.ts +0 -151
- package/src/Receipt.ts +0 -146
- package/src/Store.test-d.ts +0 -195
- package/src/Store.test.ts +0 -357
- package/src/Store.ts +0 -329
- package/src/bin.ts +0 -4
- package/src/cli/account.ts +0 -269
- package/src/cli/cli.test.ts +0 -2221
- package/src/cli/cli.ts +0 -1649
- package/src/cli/config.test.ts +0 -89
- package/src/cli/config.ts +0 -50
- package/src/cli/internal.ts +0 -114
- package/src/cli/mcp.test.ts +0 -262
- package/src/cli/plugins/evm.ts +0 -55
- package/src/cli/plugins/index.ts +0 -4
- package/src/cli/plugins/plugin.ts +0 -84
- package/src/cli/plugins/stripe.ts +0 -174
- package/src/cli/plugins/tempo.ts +0 -1102
- package/src/cli/sessions/Manager.test.ts +0 -249
- package/src/cli/sessions/Manager.ts +0 -93
- package/src/cli/sessions/commands.ts +0 -444
- package/src/cli/sessions/request.test.ts +0 -51
- package/src/cli/sessions/request.ts +0 -353
- package/src/cli/sessions/store.test.ts +0 -581
- package/src/cli/sessions/store.ts +0 -940
- package/src/cli/utils.test.ts +0 -156
- package/src/cli/utils.ts +0 -394
- package/src/cli/validate/challenge.ts +0 -565
- package/src/cli/validate/discovery.test.ts +0 -435
- package/src/cli/validate/discovery.ts +0 -221
- package/src/cli/validate/helpers.ts +0 -166
- package/src/cli/validate/index.ts +0 -229
- package/src/cli/validate/messages.ts +0 -7
- package/src/cli/validate/payment.ts +0 -774
- package/src/cli/validate.test.ts +0 -843
- package/src/client/Methods.ts +0 -8
- package/src/client/Mppx.test-d.ts +0 -270
- package/src/client/Mppx.test.ts +0 -1065
- package/src/client/Mppx.ts +0 -466
- package/src/client/Transport.test.ts +0 -619
- package/src/client/Transport.ts +0 -191
- package/src/client/index.ts +0 -29
- package/src/client/internal/Fetch.browser.test.ts +0 -197
- package/src/client/internal/Fetch.test-d.ts +0 -109
- package/src/client/internal/Fetch.test.ts +0 -2336
- package/src/client/internal/Fetch.ts +0 -1079
- package/src/client/internal/MethodChallenge.ts +0 -35
- package/src/client/internal/MethodResponse.ts +0 -67
- package/src/client/internal/protocols/Mcp.test.ts +0 -220
- package/src/client/internal/protocols/Mcp.ts +0 -186
- package/src/client/internal/protocols/Mpp.ts +0 -21
- package/src/client/internal/protocols/Protocol.ts +0 -10
- package/src/client/internal/protocols/Shared.ts +0 -25
- package/src/client/internal/protocols/X402.ts +0 -46
- package/src/client/node.test.ts +0 -115
- package/src/client/node.ts +0 -247
- package/src/discovery/Discovery.test.ts +0 -214
- package/src/discovery/Discovery.ts +0 -105
- package/src/discovery/OpenApi.test.ts +0 -453
- package/src/discovery/OpenApi.ts +0 -224
- package/src/discovery/Validate.test.ts +0 -305
- package/src/discovery/Validate.ts +0 -77
- package/src/discovery/index.ts +0 -3
- package/src/env.d.ts +0 -12
- package/src/evm/Assets.ts +0 -1
- package/src/evm/Chains.ts +0 -11
- package/src/evm/Methods.ts +0 -44
- package/src/evm/PublicInterface.test-d.ts +0 -134
- package/src/evm/Types.ts +0 -140
- package/src/evm/client/Charge.test.ts +0 -347
- package/src/evm/client/Charge.ts +0 -187
- package/src/evm/client/Methods.ts +0 -19
- package/src/evm/client/index.ts +0 -6
- package/src/evm/index.ts +0 -16
- package/src/evm/server/Charge.test.ts +0 -339
- package/src/evm/server/Charge.ts +0 -290
- package/src/evm/server/Methods.ts +0 -22
- package/src/evm/server/index.ts +0 -6
- package/src/index.ts +0 -14
- package/src/internal/AcceptPayment.test.ts +0 -343
- package/src/internal/AcceptPayment.ts +0 -366
- package/src/internal/HeaderCodec.ts +0 -36
- package/src/internal/changeset.test.ts +0 -106
- package/src/internal/constantTimeEqual.test.ts +0 -47
- package/src/internal/constantTimeEqual.ts +0 -10
- package/src/internal/env.test.ts +0 -42
- package/src/internal/env.ts +0 -49
- package/src/internal/types.test-d.ts +0 -21
- package/src/internal/types.ts +0 -470
- package/src/mcp/client/McpClient.integration.test.ts +0 -652
- package/src/mcp/client/McpClient.test-d.ts +0 -144
- package/src/mcp/client/McpClient.test.ts +0 -463
- package/src/mcp/client/McpClient.ts +0 -307
- package/src/mcp/client/McpClient.unit.test.ts +0 -135
- package/src/mcp/client/index.ts +0 -2
- package/src/mcp/server/Transport.test.ts +0 -191
- package/src/mcp/server/Transport.ts +0 -111
- package/src/mcp/server/index.ts +0 -1
- package/src/middlewares/elysia.test.ts +0 -295
- package/src/middlewares/elysia.ts +0 -116
- package/src/middlewares/express.test.ts +0 -371
- package/src/middlewares/express.ts +0 -140
- package/src/middlewares/hono.test.ts +0 -476
- package/src/middlewares/hono.ts +0 -153
- package/src/middlewares/internal/mppx.test.ts +0 -177
- package/src/middlewares/internal/mppx.ts +0 -67
- package/src/middlewares/nextjs.test.ts +0 -369
- package/src/middlewares/nextjs.ts +0 -107
- package/src/proxy/Proxy.test.ts +0 -1031
- package/src/proxy/Proxy.ts +0 -345
- package/src/proxy/Service.test.ts +0 -182
- package/src/proxy/Service.ts +0 -253
- package/src/proxy/index.ts +0 -6
- package/src/proxy/internal/Headers.test.ts +0 -139
- package/src/proxy/internal/Headers.ts +0 -66
- package/src/proxy/internal/Route.test.ts +0 -217
- package/src/proxy/internal/Route.ts +0 -64
- package/src/proxy/services/anthropic.test.ts +0 -132
- package/src/proxy/services/anthropic.ts +0 -52
- package/src/proxy/services/openai.test.ts +0 -157
- package/src/proxy/services/openai.ts +0 -59
- package/src/proxy/services/stripe.test.ts +0 -175
- package/src/proxy/services/stripe.ts +0 -58
- package/src/server/Methods.ts +0 -3
- package/src/server/Mppx.authorize.test.ts +0 -210
- package/src/server/Mppx.test-d.ts +0 -360
- package/src/server/Mppx.test.ts +0 -5813
- package/src/server/Mppx.ts +0 -2623
- package/src/server/NodeListener.test.ts +0 -293
- package/src/server/NodeListener.ts +0 -45
- package/src/server/Request.test.ts +0 -255
- package/src/server/Request.ts +0 -155
- package/src/server/Response.test.ts +0 -32
- package/src/server/Response.ts +0 -45
- package/src/server/Transport.test.ts +0 -598
- package/src/server/Transport.ts +0 -320
- package/src/server/index.ts +0 -9
- package/src/server/internal/html/compose.main.gen.ts +0 -2
- package/src/server/internal/html/compose.main.ts +0 -88
- package/src/server/internal/html/config.ts +0 -672
- package/src/server/internal/html/constants.ts +0 -28
- package/src/server/internal/html/serviceWorker.client.ts +0 -28
- package/src/server/internal/html/serviceWorker.gen.ts +0 -2
- package/src/server/internal/html/serviceWorker.ts +0 -27
- package/src/server/internal/html/tsconfig.compose.json +0 -8
- package/src/server/internal/html/tsconfig.worker.client.json +0 -8
- package/src/server/internal/html/tsconfig.worker.json +0 -8
- package/src/server/internal/scope.ts +0 -43
- package/src/stripe/Charge.integration.test.ts +0 -329
- package/src/stripe/Methods.test.ts +0 -62
- package/src/stripe/Methods.ts +0 -44
- package/src/stripe/client/Charge.test.ts +0 -205
- package/src/stripe/client/Charge.ts +0 -132
- package/src/stripe/client/Methods.ts +0 -37
- package/src/stripe/client/index.ts +0 -2
- package/src/stripe/index.ts +0 -1
- package/src/stripe/internal/constants.ts +0 -7
- package/src/stripe/internal/types.ts +0 -46
- package/src/stripe/server/Charge.test-d.ts +0 -66
- package/src/stripe/server/Charge.test.ts +0 -621
- package/src/stripe/server/Charge.ts +0 -434
- package/src/stripe/server/Methods.ts +0 -24
- package/src/stripe/server/index.ts +0 -2
- package/src/stripe/server/internal/html/main.ts +0 -165
- package/src/stripe/server/internal/html/node_modules/.bin/mppx +0 -22
- package/src/stripe/server/internal/html/node_modules/.bin/mppx.src +0 -22
- package/src/stripe/server/internal/html/package.json +0 -9
- package/src/stripe/server/internal/html/stripe-js-pure.d.ts +0 -7
- package/src/stripe/server/internal/html/tsconfig.json +0 -8
- package/src/stripe/server/internal/html/types.ts +0 -5
- package/src/stripe/server/internal/html.gen.ts +0 -2
- package/src/tempo/AccessKeyAuthorization.test.ts +0 -141
- package/src/tempo/Attribution.test.ts +0 -294
- package/src/tempo/Attribution.ts +0 -185
- package/src/tempo/Methods.test.ts +0 -425
- package/src/tempo/Methods.ts +0 -367
- package/src/tempo/Proof.conformance.test.ts +0 -146
- package/src/tempo/Proof.test-d.ts +0 -32
- package/src/tempo/Proof.test.ts +0 -40
- package/src/tempo/Proof.ts +0 -69
- package/src/tempo/PublicExports.test-d.ts +0 -130
- package/src/tempo/Subscription.integration.test.ts +0 -591
- package/src/tempo/client/Charge.test.ts +0 -501
- package/src/tempo/client/Charge.ts +0 -289
- package/src/tempo/client/Methods.ts +0 -45
- package/src/tempo/client/ResolveAccount.ts +0 -46
- package/src/tempo/client/Subscription.test.ts +0 -180
- package/src/tempo/client/Subscription.ts +0 -156
- package/src/tempo/client/index.ts +0 -17
- package/src/tempo/index.ts +0 -5
- package/src/tempo/internal/account.ts +0 -56
- package/src/tempo/internal/address.ts +0 -6
- package/src/tempo/internal/auto-swap.test.ts +0 -198
- package/src/tempo/internal/auto-swap.ts +0 -188
- package/src/tempo/internal/charge.test.ts +0 -66
- package/src/tempo/internal/charge.ts +0 -43
- package/src/tempo/internal/defaults.test.ts +0 -95
- package/src/tempo/internal/defaults.ts +0 -53
- package/src/tempo/internal/fee-payer.test.ts +0 -1177
- package/src/tempo/internal/fee-payer.ts +0 -808
- package/src/tempo/internal/fee-token.test.ts +0 -165
- package/src/tempo/internal/fee-token.ts +0 -72
- package/src/tempo/internal/proof.test.ts +0 -97
- package/src/tempo/internal/proof.ts +0 -87
- package/src/tempo/internal/selectors.ts +0 -10
- package/src/tempo/internal/types.ts +0 -19
- package/src/tempo/legacy/AccessKeyAuthorization.test.ts +0 -162
- package/src/tempo/legacy/README.md +0 -9
- package/src/tempo/legacy/client/ChannelOps.test.ts +0 -379
- package/src/tempo/legacy/client/ChannelOps.ts +0 -271
- package/src/tempo/legacy/client/Session.test.ts +0 -800
- package/src/tempo/legacy/client/Session.ts +0 -397
- package/src/tempo/legacy/client/SessionManager.test.ts +0 -468
- package/src/tempo/legacy/client/SessionManager.ts +0 -909
- package/src/tempo/legacy/client/index.ts +0 -6
- package/src/tempo/legacy/index.ts +0 -6
- package/src/tempo/legacy/server/Defaults.test-d.ts +0 -9
- package/src/tempo/legacy/server/Session.test.ts +0 -6370
- package/src/tempo/legacy/server/Session.ts +0 -1024
- package/src/tempo/legacy/server/index.ts +0 -4
- package/src/tempo/legacy/session/Chain.test.ts +0 -1349
- package/src/tempo/legacy/session/Chain.ts +0 -830
- package/src/tempo/legacy/session/Channel.test.ts +0 -109
- package/src/tempo/legacy/session/Channel.ts +0 -51
- package/src/tempo/legacy/session/ChannelStore.test.ts +0 -58
- package/src/tempo/legacy/session/ChannelStore.ts +0 -39
- package/src/tempo/legacy/session/Types.ts +0 -91
- package/src/tempo/legacy/session/Voucher.test.ts +0 -410
- package/src/tempo/legacy/session/Voucher.ts +0 -183
- package/src/tempo/legacy/session/escrow.abi.ts +0 -760
- package/src/tempo/legacy/session/index.ts +0 -8
- package/src/tempo/server/AtomicStore.test-d.ts +0 -50
- package/src/tempo/server/Charge.test.ts +0 -6121
- package/src/tempo/server/Charge.ts +0 -1351
- package/src/tempo/server/Methods.ts +0 -106
- package/src/tempo/server/Relay.test.ts +0 -677
- package/src/tempo/server/Relay.ts +0 -297
- package/src/tempo/server/SponsorBudget.test.ts +0 -154
- package/src/tempo/server/SponsorBudget.ts +0 -219
- package/src/tempo/server/Sse.test.ts +0 -321
- package/src/tempo/server/Subscription.test.ts +0 -1944
- package/src/tempo/server/Subscription.ts +0 -1333
- package/src/tempo/server/index.ts +0 -12
- package/src/tempo/server/internal/html/main.ts +0 -115
- package/src/tempo/server/internal/html/node_modules/.bin/mppx +0 -22
- package/src/tempo/server/internal/html/node_modules/.bin/mppx.src +0 -22
- package/src/tempo/server/internal/html/package.json +0 -10
- package/src/tempo/server/internal/html/tsconfig.json +0 -8
- package/src/tempo/server/internal/html.gen.ts +0 -2
- package/src/tempo/server/internal/request-body.test.ts +0 -210
- package/src/tempo/server/internal/request-body.ts +0 -61
- package/src/tempo/server/internal/transport.test.ts +0 -903
- package/src/tempo/server/internal/transport.ts +0 -310
- package/src/tempo/session/README.md +0 -208
- package/src/tempo/session/Snapshot.test.ts +0 -41
- package/src/tempo/session/Snapshot.ts +0 -95
- package/src/tempo/session/client/ChannelOps.test.ts +0 -218
- package/src/tempo/session/client/ChannelOps.ts +0 -348
- package/src/tempo/session/client/ChannelStore.ts +0 -111
- package/src/tempo/session/client/CredentialState.test.ts +0 -789
- package/src/tempo/session/client/CredentialState.ts +0 -942
- package/src/tempo/session/client/ReceiptCoordinator.ts +0 -95
- package/src/tempo/session/client/Runtime.test.ts +0 -1104
- package/src/tempo/session/client/Runtime.ts +0 -1008
- package/src/tempo/session/client/Session.test.ts +0 -1355
- package/src/tempo/session/client/Session.ts +0 -420
- package/src/tempo/session/client/SessionManager.test.ts +0 -1899
- package/src/tempo/session/client/SessionManager.ts +0 -996
- package/src/tempo/session/client/Transports.test.ts +0 -1141
- package/src/tempo/session/client/Transports.ts +0 -1534
- package/src/tempo/session/client/index.ts +0 -40
- package/src/tempo/session/client/internal/SessionManager.ts +0 -36
- package/src/tempo/session/index.ts +0 -7
- package/src/tempo/session/precompile/Chain.integration.test.ts +0 -339
- package/src/tempo/session/precompile/Chain.test.ts +0 -1641
- package/src/tempo/session/precompile/Chain.ts +0 -1149
- package/src/tempo/session/precompile/Channel.test.ts +0 -147
- package/src/tempo/session/precompile/Channel.ts +0 -108
- package/src/tempo/session/precompile/Protocol.test.ts +0 -358
- package/src/tempo/session/precompile/Protocol.ts +0 -520
- package/src/tempo/session/precompile/Voucher.test.ts +0 -354
- package/src/tempo/session/precompile/Voucher.ts +0 -162
- package/src/tempo/session/precompile/escrow.abi.ts +0 -226
- package/src/tempo/session/precompile/index.ts +0 -33
- package/src/tempo/session/server/ChannelOps.test.ts +0 -129
- package/src/tempo/session/server/ChannelOps.ts +0 -157
- package/src/tempo/session/server/ChannelStore.test.ts +0 -1093
- package/src/tempo/session/server/ChannelStore.ts +0 -835
- package/src/tempo/session/server/CredentialVerification.test.ts +0 -299
- package/src/tempo/session/server/CredentialVerification.ts +0 -775
- package/src/tempo/session/server/MeteredStream.ts +0 -95
- package/src/tempo/session/server/RequestState.test.ts +0 -574
- package/src/tempo/session/server/RequestState.ts +0 -507
- package/src/tempo/session/server/Session.integration.test.ts +0 -449
- package/src/tempo/session/server/Session.test.ts +0 -3862
- package/src/tempo/session/server/Session.ts +0 -570
- package/src/tempo/session/server/Settlement.test.ts +0 -345
- package/src/tempo/session/server/Settlement.ts +0 -527
- package/src/tempo/session/server/Sse.fuzz.test.ts +0 -138
- package/src/tempo/session/server/Sse.test.ts +0 -557
- package/src/tempo/session/server/Sse.ts +0 -254
- package/src/tempo/session/server/Transports.test.ts +0 -346
- package/src/tempo/session/server/Transports.ts +0 -255
- package/src/tempo/session/server/Ws.test.ts +0 -594
- package/src/tempo/session/server/Ws.ts +0 -385
- package/src/tempo/session/server/index.ts +0 -12
- package/src/tempo/subscription/KeyAuthorization.test.ts +0 -282
- package/src/tempo/subscription/KeyAuthorization.ts +0 -396
- package/src/tempo/subscription/Receipt.ts +0 -28
- package/src/tempo/subscription/Store.test.ts +0 -609
- package/src/tempo/subscription/Store.ts +0 -449
- package/src/tempo/subscription/Types.ts +0 -68
- package/src/tempo/subscription/index.ts +0 -23
- package/src/tsconfig.json +0 -10
- package/src/validation/core.ts +0 -386
- package/src/validation/index.ts +0 -11
- package/src/viem/Account.test.ts +0 -72
- package/src/viem/Account.ts +0 -30
- package/src/viem/Client.test.ts +0 -366
- package/src/viem/Client.ts +0 -93
- package/src/x402/Assets.test.ts +0 -253
- package/src/x402/Assets.ts +0 -221
- package/src/x402/Exact.e2e.test.ts +0 -448
- package/src/x402/Exact.localnet.test.ts +0 -475
- package/src/x402/Header.test.ts +0 -73
- package/src/x402/Header.ts +0 -79
- package/src/x402/PublicInterface.test-d.ts +0 -39
- package/src/x402/Types.ts +0 -248
- package/src/x402/client/Exact.test.ts +0 -309
- package/src/x402/client/Exact.ts +0 -186
- package/src/x402/index.ts +0 -6
- package/src/x402/internal/ChallengeBrand.ts +0 -14
- package/src/x402/internal/RouteBinding.ts +0 -18
- package/src/x402/server/EvmCharge.ts +0 -394
- package/src/x402/server/Facilitator.test.ts +0 -111
- package/src/x402/server/Facilitator.ts +0 -56
- package/src/zod.test.ts +0 -169
- package/src/zod.ts +0 -71
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isAddress, isAddressEqual, zeroAddress, } from 'viem';
|
|
2
2
|
import { AmountExceedsDepositError, ChannelClosedError, ChannelNotFoundError, InsufficientBalanceError, InvalidSignatureError, VerificationFailedError, } from '../../../Errors.js';
|
|
3
|
+
import * as MachineTokenSession from '../../internal/machine-token-session.js';
|
|
3
4
|
import * as Chain from '../precompile/Chain.js';
|
|
4
5
|
import { readChannelClosedReceiptFields } from '../precompile/Chain.js';
|
|
5
6
|
import * as Channel from '../precompile/Channel.js';
|
|
@@ -7,20 +8,13 @@ import { createSessionReceipt, uint96, } from '../precompile/Protocol.js';
|
|
|
7
8
|
import * as Voucher from '../precompile/Voucher.js';
|
|
8
9
|
import * as ChannelStore from './ChannelStore.js';
|
|
9
10
|
import { getChallengePaymentFields } from './RequestState.js';
|
|
10
|
-
import { assertSettlementSender, getClientAccount } from './Settlement.js';
|
|
11
|
+
import { assertSettlementSender, getClientAccount, resolveChannelTransactionOptions, } from './Settlement.js';
|
|
11
12
|
/** Returns the effective voucher signer for a TIP-1034 descriptor. */
|
|
12
13
|
export function authorizedSigner(descriptor) {
|
|
13
14
|
return isAddressEqual(descriptor.authorizedSigner, zeroAddress)
|
|
14
15
|
? descriptor.payer
|
|
15
16
|
: descriptor.authorizedSigner;
|
|
16
17
|
}
|
|
17
|
-
/** Asserts that a credential payload includes a TIP-1034 descriptor. */
|
|
18
|
-
export function assertDescriptor(payload) {
|
|
19
|
-
if (!payload.descriptor)
|
|
20
|
-
throw new VerificationFailedError({
|
|
21
|
-
reason: 'descriptor required for TIP-1034 session action',
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
18
|
/** Asserts that two TIP-1034 descriptors identify the same channel. */
|
|
25
19
|
export function assertSameDescriptor(a, b) {
|
|
26
20
|
if (!isAddressEqual(a.payer, b.payer) ||
|
|
@@ -58,6 +52,53 @@ export function validateChannelDescriptor(descriptor, channelId, chainId, escrow
|
|
|
58
52
|
});
|
|
59
53
|
}
|
|
60
54
|
}
|
|
55
|
+
async function resolveCredentialRoute(parameters) {
|
|
56
|
+
const { challenge, chainId, client, escrow, payload } = parameters;
|
|
57
|
+
const { descriptor } = payload;
|
|
58
|
+
const channelId = ChannelStore.normalizeChannelId(payload.channelId);
|
|
59
|
+
if (Channel.computeId({ ...descriptor, chainId, escrow }).toLowerCase() !== channelId.toLowerCase())
|
|
60
|
+
throw new VerificationFailedError({ reason: 'channel descriptor does not match channelId' });
|
|
61
|
+
const request = getChallengePaymentFields(challenge);
|
|
62
|
+
const expectedOperator = parameters.expectedOperator ?? zeroAddress;
|
|
63
|
+
const direct = isAddressEqual(descriptor.payee, request.recipient) &&
|
|
64
|
+
isAddressEqual(descriptor.token, request.currency) &&
|
|
65
|
+
isAddressEqual(descriptor.operator, expectedOperator);
|
|
66
|
+
if (direct)
|
|
67
|
+
return {
|
|
68
|
+
allowedFeeTokens: MachineTokenSession.allowedSponsoredFeeTokens({
|
|
69
|
+
chainId,
|
|
70
|
+
override: parameters.feeToken,
|
|
71
|
+
paymentToken: request.currency,
|
|
72
|
+
}),
|
|
73
|
+
expectedOperator,
|
|
74
|
+
payment: request,
|
|
75
|
+
};
|
|
76
|
+
if (payload.action !== 'close' && !MachineTokenSession.isEnabledChallenge(challenge))
|
|
77
|
+
throw new VerificationFailedError({ reason: 'credential descriptor does not match challenge' });
|
|
78
|
+
const route = await MachineTokenSession.matchRoute(client, {
|
|
79
|
+
active: payload.action !== 'close',
|
|
80
|
+
chainId,
|
|
81
|
+
descriptor,
|
|
82
|
+
merchant: request.recipient,
|
|
83
|
+
targetToken: request.currency,
|
|
84
|
+
});
|
|
85
|
+
if (!route)
|
|
86
|
+
throw new VerificationFailedError({
|
|
87
|
+
reason: 'machine-token channel is not bound to the challenged merchant and currency',
|
|
88
|
+
});
|
|
89
|
+
return {
|
|
90
|
+
allowedFeeTokens: [
|
|
91
|
+
MachineTokenSession.resolveFeeToken({
|
|
92
|
+
chainId,
|
|
93
|
+
override: parameters.feeToken,
|
|
94
|
+
paymentToken: route.token,
|
|
95
|
+
}),
|
|
96
|
+
],
|
|
97
|
+
expectedOperator: route.operator,
|
|
98
|
+
machineRouter: route.operator,
|
|
99
|
+
payment: { ...request, currency: route.token, recipient: route.payee },
|
|
100
|
+
};
|
|
101
|
+
}
|
|
61
102
|
/** Validates on-chain channel state before accepting or charging a credential. */
|
|
62
103
|
export function validateChannelState(state, amount) {
|
|
63
104
|
if (state.deposit === 0n) {
|
|
@@ -133,6 +174,9 @@ function readHex(value, field) {
|
|
|
133
174
|
return value;
|
|
134
175
|
throw new VerificationFailedError({ reason: `invalid session credential ${field}` });
|
|
135
176
|
}
|
|
177
|
+
function readOptionalHex(value, field) {
|
|
178
|
+
return value === undefined ? undefined : readHex(value, field);
|
|
179
|
+
}
|
|
136
180
|
function readRawAmount(value, field) {
|
|
137
181
|
if (typeof value === 'string' && /^[0-9]+$/.test(value))
|
|
138
182
|
return value;
|
|
@@ -195,6 +239,7 @@ export function requireSessionCredentialPayload(payload) {
|
|
|
195
239
|
channelId: header.channelId,
|
|
196
240
|
transaction: readHex(candidate.transaction, 'transaction'),
|
|
197
241
|
signature: readHex(candidate.signature, 'signature'),
|
|
242
|
+
authorizationSignature: readOptionalHex(candidate.authorizationSignature, 'authorizationSignature'),
|
|
198
243
|
descriptor: readDescriptor(candidate.descriptor),
|
|
199
244
|
cumulativeAmount: readRawAmount(candidate.cumulativeAmount, 'cumulativeAmount'),
|
|
200
245
|
...(candidate.authorizedSigner === undefined
|
|
@@ -219,6 +264,7 @@ export function requireSessionCredentialPayload(payload) {
|
|
|
219
264
|
descriptor: readDescriptor(candidate.descriptor),
|
|
220
265
|
cumulativeAmount: readRawAmount(candidate.cumulativeAmount, 'cumulativeAmount'),
|
|
221
266
|
signature: readHex(candidate.signature, 'signature'),
|
|
267
|
+
authorizationSignature: readOptionalHex(candidate.authorizationSignature, 'authorizationSignature'),
|
|
222
268
|
};
|
|
223
269
|
case 'close':
|
|
224
270
|
return {
|
|
@@ -227,6 +273,8 @@ export function requireSessionCredentialPayload(payload) {
|
|
|
227
273
|
descriptor: readDescriptor(candidate.descriptor),
|
|
228
274
|
cumulativeAmount: readRawAmount(candidate.cumulativeAmount, 'cumulativeAmount'),
|
|
229
275
|
signature: readHex(candidate.signature, 'signature'),
|
|
276
|
+
authorizationSignature: readOptionalHex(candidate.authorizationSignature, 'authorizationSignature'),
|
|
277
|
+
refundSignature: readOptionalHex(candidate.refundSignature, 'refundSignature'),
|
|
230
278
|
};
|
|
231
279
|
}
|
|
232
280
|
}
|
|
@@ -241,14 +289,269 @@ const refreshOnChainVerificationCache = {
|
|
|
241
289
|
topUp: true,
|
|
242
290
|
voucher: false,
|
|
243
291
|
};
|
|
244
|
-
/**
|
|
245
|
-
export async function
|
|
246
|
-
const
|
|
292
|
+
/** Validates all action-specific session credential invariants without changing payment state. */
|
|
293
|
+
export async function validateCredentialPayload(parameters) {
|
|
294
|
+
const { payload } = parameters;
|
|
295
|
+
const context = await resolveCredentialContext(parameters);
|
|
296
|
+
switch (payload.action) {
|
|
297
|
+
case 'open':
|
|
298
|
+
await validateOpenCredential(context, payload);
|
|
299
|
+
break;
|
|
300
|
+
case 'topUp':
|
|
301
|
+
await validateTopUpCredential(context, payload);
|
|
302
|
+
break;
|
|
303
|
+
case 'voucher':
|
|
304
|
+
await validateVoucherCredential(context, payload);
|
|
305
|
+
break;
|
|
306
|
+
case 'close':
|
|
307
|
+
await validateCloseCredential(context, payload);
|
|
308
|
+
break;
|
|
309
|
+
}
|
|
310
|
+
return { action: payload.action, channelId: ChannelStore.normalizeChannelId(payload.channelId) };
|
|
311
|
+
}
|
|
312
|
+
async function validateOpenCredential(parameters, payload) {
|
|
313
|
+
const { challenge, chainId, client, escrow, expectedOperator, payment: request } = parameters;
|
|
314
|
+
const cumulativeAmount = uint96(BigInt(payload.cumulativeAmount));
|
|
315
|
+
if (payload.authorizedSigner !== undefined &&
|
|
316
|
+
!isAddressEqual(payload.authorizedSigner, payload.descriptor.authorizedSigner))
|
|
317
|
+
throw new VerificationFailedError({
|
|
318
|
+
reason: 'credential authorizedSigner does not match descriptor',
|
|
319
|
+
});
|
|
320
|
+
const channelId = ChannelStore.normalizeChannelId(payload.channelId);
|
|
321
|
+
validateChannelDescriptor(payload.descriptor, channelId, chainId, escrow, request.recipient, request.currency, expectedOperator);
|
|
322
|
+
const transaction = Chain.validateOpenCredentialTransaction({
|
|
323
|
+
allowedFeeTokens: parameters.allowedFeeTokens,
|
|
324
|
+
challengeExpires: challenge.expires,
|
|
325
|
+
chainId,
|
|
326
|
+
escrowContract: escrow,
|
|
327
|
+
expectedAuthorizedSigner: payload.descriptor.authorizedSigner,
|
|
328
|
+
expectedChannelId: channelId,
|
|
329
|
+
expectedCurrency: request.currency,
|
|
330
|
+
expectedOperator,
|
|
331
|
+
expectedPayee: request.recipient,
|
|
332
|
+
expectedExpiringNonceHash: payload.descriptor.expiringNonceHash,
|
|
333
|
+
expectedPayer: payload.descriptor.payer,
|
|
334
|
+
feePayer: parameters.feePayer,
|
|
335
|
+
feePayerPolicy: parameters.feePayerPolicy,
|
|
336
|
+
serializedTransaction: payload.transaction,
|
|
337
|
+
});
|
|
338
|
+
assertOpenCredentialCoversRequest({
|
|
339
|
+
cumulativeAmount,
|
|
340
|
+
openDeposit: transaction.openDeposit,
|
|
341
|
+
requestAmount: request.amount,
|
|
342
|
+
});
|
|
343
|
+
assertSameDescriptor(transaction.descriptor, payload.descriptor);
|
|
344
|
+
if (cumulativeAmount > transaction.openDeposit)
|
|
345
|
+
throw new AmountExceedsDepositError({ reason: 'voucher amount exceeds open deposit' });
|
|
346
|
+
const valid = await Voucher.verifyVoucher(escrow, chainId, { channelId, cumulativeAmount, signature: payload.signature }, authorizedSigner(transaction.descriptor));
|
|
347
|
+
if (!valid)
|
|
348
|
+
throw new InvalidSignatureError({ reason: 'invalid voucher signature' });
|
|
349
|
+
await Chain.simulateCredentialTransaction({
|
|
350
|
+
client,
|
|
351
|
+
feePayer: parameters.feePayer,
|
|
352
|
+
transaction: transaction.transaction,
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
async function validateTopUpCredential(parameters, payload) {
|
|
356
|
+
const { challenge, chainId, client, escrow, expectedOperator, payment: request, store, } = parameters;
|
|
357
|
+
const additionalDeposit = uint96(BigInt(payload.additionalDeposit));
|
|
358
|
+
const channelId = ChannelStore.normalizeChannelId(payload.channelId);
|
|
359
|
+
validateChannelDescriptor(payload.descriptor, channelId, chainId, escrow, request.recipient, request.currency, expectedOperator);
|
|
360
|
+
const channel = await ChannelStore.loadPrecompileChannel({
|
|
361
|
+
descriptor: payload.descriptor,
|
|
362
|
+
channelId,
|
|
363
|
+
chainId,
|
|
364
|
+
escrow,
|
|
365
|
+
store,
|
|
366
|
+
validateDescriptor: true,
|
|
367
|
+
});
|
|
368
|
+
const transaction = Chain.validateTopUpCredentialTransaction({
|
|
369
|
+
additionalDeposit,
|
|
370
|
+
allowedFeeTokens: parameters.allowedFeeTokens,
|
|
371
|
+
challengeExpires: challenge.expires,
|
|
372
|
+
chainId,
|
|
373
|
+
descriptor: channel.descriptor,
|
|
374
|
+
escrowContract: escrow,
|
|
375
|
+
expectedChannelId: channelId,
|
|
376
|
+
expectedCurrency: request.currency,
|
|
377
|
+
feePayer: parameters.feePayer,
|
|
378
|
+
feePayerPolicy: parameters.feePayerPolicy,
|
|
379
|
+
serializedTransaction: payload.transaction,
|
|
380
|
+
});
|
|
381
|
+
validateChannelState(await Chain.getChannelState(client, channelId, escrow));
|
|
382
|
+
await Chain.simulateCredentialTransaction({
|
|
383
|
+
client,
|
|
384
|
+
feePayer: parameters.feePayer,
|
|
385
|
+
transaction: transaction.transaction,
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
async function validateVoucherCredential(parameters, payload) {
|
|
389
|
+
const { chainId, client, credentialSource, escrow, minVoucherDelta, store, channelStateTtl, lastOnChainVerified, payment: request, } = parameters;
|
|
390
|
+
const { expectedOperator } = parameters;
|
|
391
|
+
const channelId = ChannelStore.normalizeChannelId(payload.channelId);
|
|
392
|
+
const voucher = Voucher.parseVoucherFromPayload(channelId, payload.cumulativeAmount, payload.signature, payload.authorizationSignature);
|
|
393
|
+
validateChannelDescriptor(payload.descriptor, channelId, chainId, escrow, request.recipient, request.currency, expectedOperator);
|
|
394
|
+
const channel = await ChannelStore.loadPrecompileChannel({
|
|
395
|
+
descriptor: payload.descriptor,
|
|
396
|
+
channelId,
|
|
397
|
+
chainId,
|
|
398
|
+
escrow,
|
|
399
|
+
store,
|
|
400
|
+
validateDescriptor: true,
|
|
401
|
+
});
|
|
402
|
+
assertCredentialSourceCanSpend({ chainId, channel, source: credentialSource });
|
|
403
|
+
if (channel.finalized)
|
|
404
|
+
throw new ChannelClosedError({ reason: 'channel is finalized' });
|
|
405
|
+
const channelState = await resolveVoucherChannelState({
|
|
406
|
+
channel,
|
|
407
|
+
channelId,
|
|
408
|
+
channelStateTtl,
|
|
409
|
+
client,
|
|
410
|
+
escrow,
|
|
411
|
+
lastOnChainVerified,
|
|
412
|
+
});
|
|
413
|
+
await ChannelStore.validateVoucher({
|
|
414
|
+
channel,
|
|
415
|
+
channelState,
|
|
416
|
+
methodDetails: { chainId, escrowContract: escrow },
|
|
417
|
+
minVoucherDelta,
|
|
418
|
+
voucher,
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
async function resolveVoucherChannelState(parameters) {
|
|
422
|
+
const { channel, channelId, channelStateTtl, client, escrow, lastOnChainVerified } = parameters;
|
|
423
|
+
const isStale = Date.now() - (lastOnChainVerified.get(channelId) ?? 0) > channelStateTtl;
|
|
424
|
+
const state = isStale ? await Chain.getChannelState(client, channelId, escrow) : undefined;
|
|
425
|
+
if (state)
|
|
426
|
+
lastOnChainVerified.set(channelId, Date.now());
|
|
427
|
+
return {
|
|
428
|
+
deposit: state?.deposit ?? uint96(channel.deposit),
|
|
429
|
+
settled: state?.settled ?? uint96(channel.settledOnChain),
|
|
430
|
+
closeRequestedAt: state?.closeRequestedAt ?? Number(channel.closeRequestedAt),
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
function verifyMachineSessionAuthorization(parameters) {
|
|
434
|
+
const { chainId, payload, router } = parameters;
|
|
435
|
+
if (payload.action === 'topUp')
|
|
436
|
+
return undefined;
|
|
437
|
+
if (!router)
|
|
438
|
+
return undefined;
|
|
439
|
+
// The escrow resolves a zero authorizedSigner to the payer, but the router
|
|
440
|
+
// domain is bound to an explicit signer; reject the delegation up front
|
|
441
|
+
// instead of failing signature verification against the zero address.
|
|
442
|
+
if (isAddressEqual(payload.descriptor.authorizedSigner, zeroAddress))
|
|
443
|
+
throw new VerificationFailedError({
|
|
444
|
+
reason: 'machine-token sessions require an explicit authorizedSigner',
|
|
445
|
+
});
|
|
446
|
+
if (!payload.authorizationSignature)
|
|
447
|
+
throw new VerificationFailedError({
|
|
448
|
+
reason: 'machine-token voucher requires a router authorization',
|
|
449
|
+
});
|
|
450
|
+
const valid = MachineTokenSession.verifyAuthorization({
|
|
451
|
+
authorization: {
|
|
452
|
+
channelId: ChannelStore.normalizeChannelId(payload.channelId),
|
|
453
|
+
cumulativeAmount: uint96(BigInt(payload.cumulativeAmount)),
|
|
454
|
+
},
|
|
455
|
+
chainId,
|
|
456
|
+
expectedSigner: payload.descriptor.authorizedSigner,
|
|
457
|
+
router,
|
|
458
|
+
signature: payload.authorizationSignature,
|
|
459
|
+
});
|
|
460
|
+
if (!valid)
|
|
461
|
+
throw new InvalidSignatureError({ reason: 'invalid machine-token router authorization' });
|
|
462
|
+
}
|
|
463
|
+
async function resolveCredentialContext(parameters) {
|
|
464
|
+
const route = await resolveCredentialRoute(parameters);
|
|
465
|
+
verifyMachineSessionAuthorization({
|
|
466
|
+
chainId: parameters.chainId,
|
|
467
|
+
payload: parameters.payload,
|
|
468
|
+
router: route.machineRouter,
|
|
469
|
+
});
|
|
470
|
+
return { ...parameters, ...route };
|
|
471
|
+
}
|
|
472
|
+
function assertMachineCloseAmount(machineRouter, cumulativeAmount, captureAmount) {
|
|
473
|
+
if (machineRouter && cumulativeAmount !== captureAmount)
|
|
474
|
+
throw new VerificationFailedError({
|
|
475
|
+
reason: `machine-token close voucher amount must equal ${captureAmount} (capture amount)`,
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
async function inspectCloseCredential(parameters, payload) {
|
|
479
|
+
const { account: accountOverride, chainId, client, escrow, expectedOperator, machineRouter, payment, store, } = parameters;
|
|
480
|
+
const cumulativeAmount = uint96(BigInt(payload.cumulativeAmount));
|
|
481
|
+
const channelId = ChannelStore.normalizeChannelId(payload.channelId);
|
|
482
|
+
validateChannelDescriptor(payload.descriptor, channelId, chainId, escrow, payment.recipient, payment.currency, expectedOperator);
|
|
483
|
+
const channel = await ChannelStore.loadPrecompileChannel({
|
|
484
|
+
descriptor: payload.descriptor,
|
|
485
|
+
channelId,
|
|
486
|
+
chainId,
|
|
487
|
+
escrow,
|
|
488
|
+
store,
|
|
489
|
+
});
|
|
490
|
+
if (channel.finalized)
|
|
491
|
+
throw new ChannelClosedError({ reason: 'channel is already finalized' });
|
|
492
|
+
const state = await Chain.getChannelState(client, channelId, escrow);
|
|
493
|
+
if (state.closeRequestedAt !== 0)
|
|
494
|
+
throw new ChannelClosedError({ reason: 'channel has a pending close request' });
|
|
495
|
+
if (state.deposit === 0n && (cumulativeAmount !== 0n || channel.spent !== 0n))
|
|
496
|
+
throw new ChannelClosedError({ reason: 'channel deposit is zero (settled)' });
|
|
497
|
+
if (cumulativeAmount < channel.spent)
|
|
498
|
+
throw new VerificationFailedError({
|
|
499
|
+
reason: `close voucher amount must be >= ${channel.spent} (spent)`,
|
|
500
|
+
});
|
|
501
|
+
if (cumulativeAmount < state.settled)
|
|
502
|
+
throw new VerificationFailedError({
|
|
503
|
+
reason: `close voucher amount must be >= ${state.settled} (on-chain settled)`,
|
|
504
|
+
});
|
|
505
|
+
if (!(await Voucher.verifyVoucher(escrow, chainId, { channelId, cumulativeAmount, signature: payload.signature }, channel.authorizedSigner)))
|
|
506
|
+
throw new InvalidSignatureError({ reason: 'invalid voucher signature' });
|
|
507
|
+
const refundSignature = machineRouter ? payload.refundSignature : undefined;
|
|
508
|
+
if (machineRouter) {
|
|
509
|
+
if (!refundSignature)
|
|
510
|
+
throw new VerificationFailedError({
|
|
511
|
+
reason: 'machine-token close requires a refund authorization',
|
|
512
|
+
});
|
|
513
|
+
if (!(await Voucher.verifyVoucher(escrow, chainId, { channelId, cumulativeAmount: uint96(state.deposit), signature: refundSignature }, payload.descriptor.authorizedSigner)))
|
|
514
|
+
throw new InvalidSignatureError({ reason: 'invalid machine-token refund authorization' });
|
|
515
|
+
}
|
|
516
|
+
const captureAmount = uint96(channel.spent > state.settled ? channel.spent : state.settled);
|
|
517
|
+
if (captureAmount > state.deposit)
|
|
518
|
+
throw new AmountExceedsDepositError({ reason: 'close capture amount exceeds on-chain deposit' });
|
|
519
|
+
assertMachineCloseAmount(machineRouter, cumulativeAmount, captureAmount);
|
|
520
|
+
const account = accountOverride ?? getClientAccount(client);
|
|
521
|
+
if (!machineRouter || !account)
|
|
522
|
+
assertSettlementSender({
|
|
523
|
+
operation: 'close',
|
|
524
|
+
channelId,
|
|
525
|
+
operator: channel.operator,
|
|
526
|
+
payee: channel.payee,
|
|
527
|
+
sender: account?.address,
|
|
528
|
+
});
|
|
529
|
+
return {
|
|
530
|
+
account,
|
|
531
|
+
authorizationSignature: machineRouter ? payload.authorizationSignature : undefined,
|
|
532
|
+
captureAmount,
|
|
533
|
+
channel,
|
|
534
|
+
channelId,
|
|
535
|
+
cumulativeAmount,
|
|
536
|
+
refundSignature,
|
|
537
|
+
state,
|
|
538
|
+
};
|
|
539
|
+
}
|
|
540
|
+
async function validateCloseCredential(parameters, payload) {
|
|
541
|
+
await inspectCloseCredential(parameters, payload);
|
|
542
|
+
}
|
|
543
|
+
/** Broadcasts a validated session credential payload and applies its state transition. */
|
|
544
|
+
export async function broadcastCredentialPayload(context) {
|
|
545
|
+
const receipt = await broadcastCredentialAction(await resolveCredentialContext(context));
|
|
247
546
|
if (refreshOnChainVerificationCache[context.payload.action])
|
|
248
547
|
context.lastOnChainVerified.set(receipt.channelId, Date.now());
|
|
249
548
|
return receipt;
|
|
250
549
|
}
|
|
251
|
-
|
|
550
|
+
/** @deprecated Use {@link broadcastCredentialPayload}. */
|
|
551
|
+
export async function verifyCredentialPayload(context) {
|
|
552
|
+
return broadcastCredentialPayload(context);
|
|
553
|
+
}
|
|
554
|
+
function broadcastCredentialAction(context) {
|
|
252
555
|
const { payload } = context;
|
|
253
556
|
switch (payload.action) {
|
|
254
557
|
case 'open':
|
|
@@ -265,11 +568,8 @@ function actionContext(context, payload) {
|
|
|
265
568
|
return { ...context, payload };
|
|
266
569
|
}
|
|
267
570
|
async function handleOpenCredential(parameters) {
|
|
268
|
-
const { store, client, challenge, payload, chainId, escrow } = parameters;
|
|
269
|
-
const request = getChallengePaymentFields(challenge);
|
|
270
|
-
const expectedOperator = parameters.expectedOperator ?? zeroAddress;
|
|
571
|
+
const { store, client, challenge, payload, chainId, escrow, expectedOperator, payment: request, } = parameters;
|
|
271
572
|
const cumulativeAmount = uint96(BigInt(payload.cumulativeAmount));
|
|
272
|
-
assertDescriptor(payload);
|
|
273
573
|
if (payload.authorizedSigner !== undefined &&
|
|
274
574
|
!isAddressEqual(payload.authorizedSigner, payload.descriptor.authorizedSigner))
|
|
275
575
|
throw new VerificationFailedError({
|
|
@@ -278,6 +578,7 @@ async function handleOpenCredential(parameters) {
|
|
|
278
578
|
const channelId = ChannelStore.normalizeChannelId(payload.channelId);
|
|
279
579
|
validateChannelDescriptor(payload.descriptor, channelId, chainId, escrow, request.recipient, request.currency, expectedOperator);
|
|
280
580
|
const result = await Chain.broadcastOpenTransaction({
|
|
581
|
+
allowedFeeTokens: parameters.allowedFeeTokens,
|
|
281
582
|
challengeExpires: challenge.expires,
|
|
282
583
|
chainId,
|
|
283
584
|
client,
|
|
@@ -319,6 +620,7 @@ async function handleOpenCredential(parameters) {
|
|
|
319
620
|
expiringNonceHash: result.expiringNonceHash,
|
|
320
621
|
cumulativeAmount,
|
|
321
622
|
signature: payload.signature,
|
|
623
|
+
authorizationSignature: payload.authorizationSignature,
|
|
322
624
|
state,
|
|
323
625
|
}));
|
|
324
626
|
if (!updated)
|
|
@@ -333,11 +635,8 @@ async function handleOpenCredential(parameters) {
|
|
|
333
635
|
});
|
|
334
636
|
}
|
|
335
637
|
async function handleTopUpCredential(parameters) {
|
|
336
|
-
const { store, client, challenge, payload, chainId, escrow } = parameters;
|
|
337
|
-
const request = getChallengePaymentFields(challenge);
|
|
338
|
-
const expectedOperator = parameters.expectedOperator ?? zeroAddress;
|
|
638
|
+
const { store, client, challenge, payload, chainId, escrow, expectedOperator, payment: request, } = parameters;
|
|
339
639
|
const additionalDeposit = uint96(BigInt(payload.additionalDeposit));
|
|
340
|
-
assertDescriptor(payload);
|
|
341
640
|
const channelId = ChannelStore.normalizeChannelId(payload.channelId);
|
|
342
641
|
validateChannelDescriptor(payload.descriptor, channelId, chainId, escrow, request.recipient, request.currency, expectedOperator);
|
|
343
642
|
const channel = await ChannelStore.loadPrecompileChannel({
|
|
@@ -350,6 +649,7 @@ async function handleTopUpCredential(parameters) {
|
|
|
350
649
|
});
|
|
351
650
|
const result = await Chain.broadcastTopUpTransaction({
|
|
352
651
|
additionalDeposit,
|
|
652
|
+
allowedFeeTokens: parameters.allowedFeeTokens,
|
|
353
653
|
challengeExpires: challenge.expires,
|
|
354
654
|
chainId,
|
|
355
655
|
client,
|
|
@@ -374,12 +674,10 @@ async function handleTopUpCredential(parameters) {
|
|
|
374
674
|
});
|
|
375
675
|
}
|
|
376
676
|
async function handleVoucherCredential(parameters) {
|
|
377
|
-
const { store, client, challenge, credentialSource, payload, chainId, escrow, minVoucherDelta, channelStateTtl, lastOnChainVerified, } = parameters;
|
|
378
|
-
const
|
|
379
|
-
const expectedOperator = parameters.expectedOperator ?? zeroAddress;
|
|
677
|
+
const { store, client, challenge, credentialSource, payload, chainId, escrow, minVoucherDelta, channelStateTtl, lastOnChainVerified, payment: request, } = parameters;
|
|
678
|
+
const { expectedOperator } = parameters;
|
|
380
679
|
const channelId = ChannelStore.normalizeChannelId(payload.channelId);
|
|
381
|
-
const voucher = Voucher.parseVoucherFromPayload(channelId, payload.cumulativeAmount, payload.signature);
|
|
382
|
-
assertDescriptor(payload);
|
|
680
|
+
const voucher = Voucher.parseVoucherFromPayload(channelId, payload.cumulativeAmount, payload.signature, payload.authorizationSignature);
|
|
383
681
|
validateChannelDescriptor(payload.descriptor, channelId, chainId, escrow, request.recipient, request.currency, expectedOperator);
|
|
384
682
|
const channel = await ChannelStore.loadPrecompileChannel({
|
|
385
683
|
descriptor: payload.descriptor,
|
|
@@ -392,15 +690,14 @@ async function handleVoucherCredential(parameters) {
|
|
|
392
690
|
assertCredentialSourceCanSpend({ chainId, channel, source: credentialSource });
|
|
393
691
|
if (channel.finalized)
|
|
394
692
|
throw new ChannelClosedError({ reason: 'channel is finalized' });
|
|
395
|
-
const
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
};
|
|
693
|
+
const channelState = await resolveVoucherChannelState({
|
|
694
|
+
channel,
|
|
695
|
+
channelId,
|
|
696
|
+
channelStateTtl,
|
|
697
|
+
client,
|
|
698
|
+
escrow,
|
|
699
|
+
lastOnChainVerified,
|
|
700
|
+
});
|
|
404
701
|
if (channelState.closeRequestedAt !== 0) {
|
|
405
702
|
await store.updateChannel(channelId, (current) => current
|
|
406
703
|
? {
|
|
@@ -422,41 +719,10 @@ async function handleVoucherCredential(parameters) {
|
|
|
422
719
|
});
|
|
423
720
|
}
|
|
424
721
|
async function handleCloseCredential(parameters) {
|
|
425
|
-
const { store, client, challenge, payload,
|
|
426
|
-
const
|
|
427
|
-
const
|
|
428
|
-
|
|
429
|
-
const channelId = ChannelStore.normalizeChannelId(payload.channelId);
|
|
430
|
-
assertDescriptor(payload);
|
|
431
|
-
validateChannelDescriptor(payload.descriptor, channelId, chainId, escrow, request.recipient, request.currency, expectedOperator);
|
|
432
|
-
const channel = await ChannelStore.loadPrecompileChannel({
|
|
433
|
-
descriptor: payload.descriptor,
|
|
434
|
-
channelId,
|
|
435
|
-
chainId,
|
|
436
|
-
escrow,
|
|
437
|
-
store,
|
|
438
|
-
});
|
|
439
|
-
if (channel.finalized)
|
|
440
|
-
throw new ChannelClosedError({ reason: 'channel is already finalized' });
|
|
441
|
-
const state = await Chain.getChannelState(client, channelId, escrow);
|
|
442
|
-
if (state.closeRequestedAt !== 0)
|
|
443
|
-
throw new ChannelClosedError({ reason: 'channel has a pending close request' });
|
|
444
|
-
if (state.deposit === 0n && (cumulativeAmount !== 0n || channel.spent !== 0n))
|
|
445
|
-
throw new ChannelClosedError({ reason: 'channel deposit is zero (settled)' });
|
|
446
|
-
if (cumulativeAmount < channel.spent)
|
|
447
|
-
throw new VerificationFailedError({
|
|
448
|
-
reason: `close voucher amount must be >= ${channel.spent} (spent)`,
|
|
449
|
-
});
|
|
450
|
-
if (cumulativeAmount < state.settled)
|
|
451
|
-
throw new VerificationFailedError({
|
|
452
|
-
reason: `close voucher amount must be >= ${state.settled} (on-chain settled)`,
|
|
453
|
-
});
|
|
454
|
-
const valid = await Voucher.verifyVoucher(escrow, chainId, { channelId, cumulativeAmount: cumulativeAmount, signature: payload.signature }, channel.authorizedSigner);
|
|
455
|
-
if (!valid)
|
|
456
|
-
throw new InvalidSignatureError({ reason: 'invalid voucher signature' });
|
|
457
|
-
let captureAmount = uint96(channel.spent > state.settled ? channel.spent : state.settled);
|
|
458
|
-
if (captureAmount > state.deposit)
|
|
459
|
-
throw new AmountExceedsDepositError({ reason: 'close capture amount exceeds on-chain deposit' });
|
|
722
|
+
const { store, client, challenge, payload, escrow, machineRouter } = parameters;
|
|
723
|
+
const inspected = await inspectCloseCredential(parameters, payload);
|
|
724
|
+
const { account, authorizationSignature, channel, channelId, cumulativeAmount, refundSignature, state, } = inspected;
|
|
725
|
+
let { captureAmount } = inspected;
|
|
460
726
|
const pendingCloseStartedAt = BigInt(Math.floor(Date.now() / 1000) || 1);
|
|
461
727
|
const previousCloseRequestedAt = channel.closeRequestedAt;
|
|
462
728
|
let pendingCloseMarked = false;
|
|
@@ -469,31 +735,26 @@ async function handleCloseCredential(parameters) {
|
|
|
469
735
|
onChainSettled: state.settled,
|
|
470
736
|
});
|
|
471
737
|
if (next.state) {
|
|
738
|
+
assertMachineCloseAmount(machineRouter, cumulativeAmount, next.captureAmount);
|
|
472
739
|
captureAmount = next.captureAmount;
|
|
473
740
|
pendingCloseMarked = true;
|
|
474
741
|
}
|
|
475
742
|
return next.state;
|
|
476
743
|
});
|
|
477
|
-
const account = parameters.account ?? getClientAccount(client);
|
|
478
744
|
let txHash;
|
|
479
745
|
let receipt;
|
|
480
746
|
try {
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
...(parameters.feePayerPolicy ? { feePayerPolicy: parameters.feePayerPolicy } : {}),
|
|
493
|
-
...(parameters.feeToken ? { feeToken: parameters.feeToken } : {}),
|
|
494
|
-
candidateFeeTokens: [channel.token],
|
|
495
|
-
}
|
|
496
|
-
: undefined);
|
|
747
|
+
const transactionOptions = resolveChannelTransactionOptions(channel, parameters, account, machineRouter);
|
|
748
|
+
if (machineRouter) {
|
|
749
|
+
if (!authorizationSignature || !refundSignature)
|
|
750
|
+
throw new VerificationFailedError({
|
|
751
|
+
reason: 'machine-token close requires router and refund authorizations',
|
|
752
|
+
});
|
|
753
|
+
txHash = await Chain.closeMachineSessionOnChain(client, channel.descriptor, cumulativeAmount, payload.signature, authorizationSignature, refundSignature, machineRouter, transactionOptions);
|
|
754
|
+
}
|
|
755
|
+
else {
|
|
756
|
+
txHash = await Chain.closeOnChain(client, channel.descriptor, cumulativeAmount, captureAmount, payload.signature, escrow, transactionOptions);
|
|
757
|
+
}
|
|
497
758
|
receipt = await Chain.waitForSuccessfulReceipt(client, txHash);
|
|
498
759
|
}
|
|
499
760
|
catch (error) {
|
|
@@ -506,9 +767,18 @@ async function handleCloseCredential(parameters) {
|
|
|
506
767
|
}
|
|
507
768
|
const closed = readChannelClosedReceiptFields(Chain.getChannelEvent(receipt, 'ChannelClosed', channelId));
|
|
508
769
|
const { refundedToPayer, settledToPayee } = closed;
|
|
509
|
-
if (
|
|
770
|
+
if (machineRouter) {
|
|
771
|
+
if (settledToPayee !== state.deposit || refundedToPayer !== 0n)
|
|
772
|
+
throw new VerificationFailedError({
|
|
773
|
+
reason: 'machine-token ChannelClosed amounts are invalid',
|
|
774
|
+
});
|
|
775
|
+
}
|
|
776
|
+
else if (settledToPayee > captureAmount || settledToPayee + refundedToPayer > state.deposit) {
|
|
510
777
|
throw new VerificationFailedError({ reason: 'ChannelClosed amounts do not match state' });
|
|
778
|
+
}
|
|
779
|
+
const logicalSettled = machineRouter ? captureAmount : settledToPayee;
|
|
511
780
|
const updated = await store.updateChannel(channelId, (current) => ChannelStore.finalizeClosedChannelState({
|
|
781
|
+
authorizationSignature,
|
|
512
782
|
captureAmount,
|
|
513
783
|
channelId,
|
|
514
784
|
cumulativeAmount,
|
|
@@ -521,8 +791,8 @@ async function handleCloseCredential(parameters) {
|
|
|
521
791
|
txHash,
|
|
522
792
|
channelId,
|
|
523
793
|
trigger: 'close',
|
|
524
|
-
amount:
|
|
525
|
-
delta:
|
|
794
|
+
amount: logicalSettled,
|
|
795
|
+
delta: logicalSettled - state.settled,
|
|
526
796
|
}));
|
|
527
797
|
}
|
|
528
798
|
catch {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Hex } from 'viem';
|
|
2
|
+
import type { MaybePromise } from '../../../internal/types.js';
|
|
2
3
|
import type { NeedVoucherEvent } from '../precompile/Protocol.js';
|
|
3
4
|
import * as ChannelStore from './ChannelStore.js';
|
|
4
5
|
/** Controller passed to manual-charge streaming generators. */
|
|
@@ -30,9 +31,11 @@ export type MeteredStreamOptions = {
|
|
|
30
31
|
formatNeedVoucher(parameters: NeedVoucherEvent): string;
|
|
31
32
|
/** Async source or manual-charge source. */
|
|
32
33
|
generate: SessionStreamGenerator;
|
|
34
|
+
/** Runs after a nonzero reserved charge has been committed. */
|
|
35
|
+
onChargeCommitted?: ((channel: ChannelStore.State) => MaybePromise<unknown>) | undefined;
|
|
33
36
|
/** Store polling interval when `waitForUpdate` is unavailable. */
|
|
34
37
|
pollIntervalMs: number;
|
|
35
|
-
/** Pre-authorized units that may be emitted without
|
|
38
|
+
/** Pre-authorized implicit tick-cost units that may be emitted without a new reservation. */
|
|
36
39
|
prepaidUnits?: number | undefined;
|
|
37
40
|
/** Optional abort signal for stream cancellation. */
|
|
38
41
|
signal?: AbortSignal | undefined;
|
|
@@ -4,22 +4,23 @@ export async function* meterIterable(options) {
|
|
|
4
4
|
let prepaidUnits = options.prepaidUnits ?? 0;
|
|
5
5
|
let reservedAmount = 0n;
|
|
6
6
|
let reservedUnits = 0;
|
|
7
|
-
const charge = async (amount
|
|
8
|
-
if (prepaidUnits > 0) {
|
|
7
|
+
const charge = async (amount) => {
|
|
8
|
+
if (amount === undefined && prepaidUnits > 0) {
|
|
9
9
|
prepaidUnits -= 1;
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
12
|
+
const resolvedAmount = amount ?? options.tickCost;
|
|
12
13
|
await reserveChargeOrWait({
|
|
13
14
|
store: options.store,
|
|
14
15
|
channelId: options.channelId,
|
|
15
|
-
amount,
|
|
16
|
+
amount: resolvedAmount,
|
|
16
17
|
reservedAmount,
|
|
17
18
|
emit: options.emitNeedVoucher,
|
|
18
19
|
formatNeedVoucher: options.formatNeedVoucher,
|
|
19
20
|
pollIntervalMs: options.pollIntervalMs,
|
|
20
21
|
signal: options.signal,
|
|
21
22
|
});
|
|
22
|
-
reservedAmount +=
|
|
23
|
+
reservedAmount += resolvedAmount;
|
|
23
24
|
reservedUnits += 1;
|
|
24
25
|
};
|
|
25
26
|
const signal = options.signal ?? new AbortController().signal;
|
|
@@ -29,7 +30,7 @@ export async function* meterIterable(options) {
|
|
|
29
30
|
break;
|
|
30
31
|
if (typeof options.generate !== 'function')
|
|
31
32
|
await charge();
|
|
32
|
-
await commitReservedCharges({
|
|
33
|
+
const channel = await commitReservedCharges({
|
|
33
34
|
store: options.store,
|
|
34
35
|
channelId: options.channelId,
|
|
35
36
|
amount: reservedAmount,
|
|
@@ -37,6 +38,8 @@ export async function* meterIterable(options) {
|
|
|
37
38
|
});
|
|
38
39
|
reservedAmount = 0n;
|
|
39
40
|
reservedUnits = 0;
|
|
41
|
+
if (channel)
|
|
42
|
+
await options.onChargeCommitted?.(channel);
|
|
40
43
|
yield value;
|
|
41
44
|
}
|
|
42
45
|
}
|