mppx 0.8.14 → 0.8.17
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 +57 -0
- package/dist/Challenge.d.ts.map +1 -1
- package/dist/Challenge.js +40 -35
- package/dist/Challenge.js.map +1 -1
- package/dist/Constants.d.ts +17 -17
- package/dist/Constants.d.ts.map +1 -1
- package/dist/Credential.d.ts.map +1 -1
- package/dist/Errors.d.ts +3 -3
- package/dist/Errors.d.ts.map +1 -1
- package/dist/Errors.js.map +1 -1
- package/dist/Method.d.ts +35 -5
- package/dist/Method.d.ts.map +1 -1
- package/dist/Method.js +7 -22
- package/dist/Method.js.map +1 -1
- package/dist/Store.d.ts +19 -0
- package/dist/Store.d.ts.map +1 -1
- package/dist/Store.js +43 -0
- package/dist/Store.js.map +1 -1
- package/dist/attestation/Client.d.ts +17 -0
- package/dist/attestation/Client.d.ts.map +1 -0
- package/dist/attestation/Client.js +28 -0
- package/dist/attestation/Client.js.map +1 -0
- package/dist/attestation/Constants.d.ts +15 -0
- package/dist/attestation/Constants.d.ts.map +1 -0
- package/dist/attestation/Constants.js +15 -0
- package/dist/attestation/Constants.js.map +1 -0
- package/dist/attestation/Server.d.ts +4 -0
- package/dist/attestation/Server.d.ts.map +1 -0
- package/dist/attestation/Server.js +8 -0
- package/dist/attestation/Server.js.map +1 -0
- package/dist/attestation/Types.d.ts +76 -0
- package/dist/attestation/Types.d.ts.map +1 -0
- package/dist/attestation/Types.js +2 -0
- package/dist/attestation/Types.js.map +1 -0
- package/dist/attestation/index.d.ts +6 -0
- package/dist/attestation/index.d.ts.map +1 -0
- package/dist/attestation/index.js +6 -0
- package/dist/attestation/index.js.map +1 -0
- package/dist/attestation/internal/HttpMessageSignature.d.ts +73 -0
- package/dist/attestation/internal/HttpMessageSignature.d.ts.map +1 -0
- package/dist/attestation/internal/HttpMessageSignature.js +320 -0
- package/dist/attestation/internal/HttpMessageSignature.js.map +1 -0
- package/dist/attestation/internal/SigningContext.d.ts +4 -0
- package/dist/attestation/internal/SigningContext.d.ts.map +1 -0
- package/dist/attestation/internal/SigningContext.js +11 -0
- package/dist/attestation/internal/SigningContext.js.map +1 -0
- package/dist/cli/account.d.ts +14 -14
- package/dist/cli/account.d.ts.map +1 -1
- package/dist/cli/cli.d.ts +6 -6
- package/dist/cli/cli.d.ts.map +1 -1
- package/dist/cli/cli.js +1 -0
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/plugins/tempo.js.map +1 -1
- package/dist/cli/sessions/commands.d.ts +4 -4
- package/dist/cli/sessions/commands.d.ts.map +1 -1
- package/dist/cli/sessions/commands.js.map +1 -1
- package/dist/cli/sessions/store.d.ts.map +1 -1
- package/dist/cli/sessions/store.js.map +1 -1
- package/dist/cli/utils.d.ts +1 -1
- package/dist/cli/utils.d.ts.map +1 -1
- package/dist/cli/utils.js.map +1 -1
- package/dist/cli/validate/discovery.js.map +1 -1
- package/dist/cli/validate/index.d.ts +3 -3
- package/dist/cli/validate/index.d.ts.map +1 -1
- package/dist/cli/validate/payment.d.ts.map +1 -1
- package/dist/cli/validate/payment.js +18 -4
- package/dist/cli/validate/payment.js.map +1 -1
- package/dist/client/Mppx.d.ts +3 -0
- package/dist/client/Mppx.d.ts.map +1 -1
- package/dist/client/Mppx.js +13 -5
- package/dist/client/Mppx.js.map +1 -1
- package/dist/client/Transport.d.ts +3 -5
- package/dist/client/Transport.d.ts.map +1 -1
- package/dist/client/Transport.js +1 -17
- package/dist/client/Transport.js.map +1 -1
- package/dist/client/internal/Fetch.d.ts.map +1 -1
- package/dist/client/internal/Fetch.js +92 -13
- package/dist/client/internal/Fetch.js.map +1 -1
- package/dist/client/internal/MethodChallenge.d.ts +2 -0
- package/dist/client/internal/MethodChallenge.d.ts.map +1 -1
- package/dist/client/internal/MethodChallenge.js +4 -0
- package/dist/client/internal/MethodChallenge.js.map +1 -1
- package/dist/client/internal/MethodResponse.d.ts +15 -0
- package/dist/client/internal/MethodResponse.d.ts.map +1 -1
- package/dist/client/internal/MethodResponse.js +10 -0
- package/dist/client/internal/MethodResponse.js.map +1 -1
- package/dist/client/node.js.map +1 -1
- package/dist/discovery/OpenApi.d.ts +3 -5
- package/dist/discovery/OpenApi.d.ts.map +1 -1
- package/dist/discovery/OpenApi.js +13 -34
- package/dist/discovery/OpenApi.js.map +1 -1
- package/dist/discovery/internal/Metadata.d.ts +20 -0
- package/dist/discovery/internal/Metadata.d.ts.map +1 -0
- package/dist/discovery/internal/Metadata.js +36 -0
- package/dist/discovery/internal/Metadata.js.map +1 -0
- package/dist/evm/Methods.d.ts +11 -11
- package/dist/evm/Methods.d.ts.map +1 -1
- package/dist/evm/Types.d.ts +17 -17
- package/dist/evm/Types.d.ts.map +1 -1
- package/dist/evm/client/Charge.d.ts +11 -11
- package/dist/evm/client/Methods.d.ts +11 -11
- package/dist/evm/server/Charge.d.ts +1 -1
- package/dist/evm/server/Charge.d.ts.map +1 -1
- package/dist/evm/server/Charge.js +2 -0
- package/dist/evm/server/Charge.js.map +1 -1
- package/dist/evm/server/Methods.d.ts +11 -11
- package/dist/internal/HeaderCodec.d.ts +2 -2
- package/dist/internal/HeaderCodec.d.ts.map +1 -1
- package/dist/internal/types.d.ts +6 -0
- package/dist/internal/types.d.ts.map +1 -1
- package/dist/middlewares/elysia.js.map +1 -1
- package/dist/middlewares/express.js.map +1 -1
- package/dist/middlewares/hono.js.map +1 -1
- package/dist/middlewares/nextjs.js.map +1 -1
- package/dist/proxy/Proxy.d.ts +2 -0
- package/dist/proxy/Proxy.d.ts.map +1 -1
- package/dist/proxy/Proxy.js +117 -9
- package/dist/proxy/Proxy.js.map +1 -1
- package/dist/proxy/Service.d.ts +36 -1
- package/dist/proxy/Service.d.ts.map +1 -1
- package/dist/proxy/Service.js +9 -8
- package/dist/proxy/Service.js.map +1 -1
- package/dist/proxy/services/anthropic.d.ts.map +1 -1
- package/dist/proxy/services/anthropic.js +1 -0
- package/dist/proxy/services/anthropic.js.map +1 -1
- package/dist/proxy/services/openai.d.ts.map +1 -1
- package/dist/proxy/services/openai.js +1 -0
- package/dist/proxy/services/openai.js.map +1 -1
- package/dist/proxy/services/stripe.d.ts.map +1 -1
- package/dist/proxy/services/stripe.js +1 -0
- package/dist/proxy/services/stripe.js.map +1 -1
- package/dist/server/Mppx.d.ts +75 -13
- package/dist/server/Mppx.d.ts.map +1 -1
- package/dist/server/Mppx.js +201 -23
- package/dist/server/Mppx.js.map +1 -1
- package/dist/server/internal/html/config.d.ts +9 -9
- package/dist/server/internal/html/config.d.ts.map +1 -1
- package/dist/server/internal/html/constants.d.ts +17 -17
- package/dist/server/internal/html/constants.d.ts.map +1 -1
- package/dist/stripe/Methods.d.ts +10 -10
- package/dist/stripe/Methods.d.ts.map +1 -1
- 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/internal/types.d.ts.map +1 -1
- package/dist/stripe/server/Charge.d.ts +11 -11
- package/dist/stripe/server/Charge.d.ts.map +1 -1
- package/dist/stripe/server/Charge.js +49 -1
- package/dist/stripe/server/Charge.js.map +1 -1
- package/dist/stripe/server/Methods.d.ts +137 -48
- package/dist/stripe/server/Methods.d.ts.map +1 -1
- package/dist/stripe/server/Methods.js +259 -4
- package/dist/stripe/server/Methods.js.map +1 -1
- package/dist/stripe/server/internal/deposit-address.d.ts +13 -0
- package/dist/stripe/server/internal/deposit-address.d.ts.map +1 -0
- package/dist/stripe/server/internal/deposit-address.js +28 -0
- package/dist/stripe/server/internal/deposit-address.js.map +1 -0
- package/dist/stripe/server/internal/html.gen.d.ts +1 -1
- package/dist/stripe/server/internal/html.gen.d.ts.map +1 -1
- package/dist/stripe/server/internal/html.gen.js +1 -1
- package/dist/stripe/server/internal/html.gen.js.map +1 -1
- package/dist/stripe/server/internal/record-payment.d.ts +15 -0
- package/dist/stripe/server/internal/record-payment.d.ts.map +1 -0
- package/dist/stripe/server/internal/record-payment.js +42 -0
- package/dist/stripe/server/internal/record-payment.js.map +1 -0
- package/dist/stripe/server/internal/request.d.ts +25 -0
- package/dist/stripe/server/internal/request.d.ts.map +1 -0
- package/dist/stripe/server/internal/request.js +29 -0
- package/dist/stripe/server/internal/request.js.map +1 -0
- package/dist/tap/Constants.d.ts +28 -0
- package/dist/tap/Constants.d.ts.map +1 -0
- package/dist/tap/Constants.js +32 -0
- package/dist/tap/Constants.js.map +1 -0
- package/dist/tap/Types.d.ts +11 -0
- package/dist/tap/Types.d.ts.map +1 -0
- package/dist/tap/Types.js +2 -0
- package/dist/tap/Types.js.map +1 -0
- package/dist/tap/client/index.d.ts +26 -0
- package/dist/tap/client/index.d.ts.map +1 -0
- package/dist/tap/client/index.js +33 -0
- package/dist/tap/client/index.js.map +1 -0
- package/dist/tap/index.d.ts +5 -0
- package/dist/tap/index.d.ts.map +1 -0
- package/dist/tap/index.js +5 -0
- package/dist/tap/index.js.map +1 -0
- package/dist/tap/server/index.d.ts +20 -0
- package/dist/tap/server/index.d.ts.map +1 -0
- package/dist/tap/server/index.js +36 -0
- package/dist/tap/server/index.js.map +1 -0
- package/dist/tempo/Attribution.d.ts +1 -1
- package/dist/tempo/Methods.d.ts +60 -60
- package/dist/tempo/Methods.d.ts.map +1 -1
- package/dist/tempo/Proof.d.ts +16 -16
- package/dist/tempo/client/Charge.d.ts +19 -19
- package/dist/tempo/client/Charge.d.ts.map +1 -1
- package/dist/tempo/client/Charge.js +1 -7
- package/dist/tempo/client/Charge.js.map +1 -1
- package/dist/tempo/client/Methods.d.ts +38 -38
- package/dist/tempo/client/Methods.js.map +1 -1
- package/dist/tempo/client/Subscription.d.ts +23 -23
- package/dist/tempo/client/Subscription.js.map +1 -1
- package/dist/tempo/internal/address.d.ts +2 -1
- package/dist/tempo/internal/address.d.ts.map +1 -1
- package/dist/tempo/internal/address.js +3 -1
- package/dist/tempo/internal/address.js.map +1 -1
- package/dist/tempo/internal/auto-swap.d.ts.map +1 -1
- package/dist/tempo/internal/auto-swap.js +4 -19
- package/dist/tempo/internal/auto-swap.js.map +1 -1
- package/dist/tempo/internal/defaults.d.ts +6 -6
- package/dist/tempo/internal/defaults.d.ts.map +1 -1
- package/dist/tempo/internal/fee-payer.d.ts +12 -12
- package/dist/tempo/internal/fee-payer.d.ts.map +1 -1
- package/dist/tempo/internal/fee-payer.js.map +1 -1
- package/dist/tempo/internal/proof.d.ts +17 -17
- package/dist/tempo/internal/proof.d.ts.map +1 -1
- package/dist/tempo/legacy/client/Session.d.ts +20 -20
- package/dist/tempo/legacy/client/Session.js.map +1 -1
- package/dist/tempo/legacy/client/SessionManager.js.map +1 -1
- package/dist/tempo/legacy/index.d.ts +1 -3
- package/dist/tempo/legacy/index.d.ts.map +1 -1
- package/dist/tempo/legacy/index.js +1 -3
- package/dist/tempo/legacy/index.js.map +1 -1
- package/dist/tempo/legacy/session/escrow.abi.d.ts +374 -374
- package/dist/tempo/legacy/session/escrow.abi.d.ts.map +1 -1
- package/dist/tempo/server/Charge.d.ts +34 -12
- package/dist/tempo/server/Charge.d.ts.map +1 -1
- package/dist/tempo/server/Charge.js +44 -39
- package/dist/tempo/server/Charge.js.map +1 -1
- package/dist/tempo/server/Methods.d.ts +37 -52
- package/dist/tempo/server/Methods.d.ts.map +1 -1
- package/dist/tempo/server/Methods.js +0 -14
- package/dist/tempo/server/Methods.js.map +1 -1
- package/dist/tempo/server/Relay.d.ts +14 -5
- package/dist/tempo/server/Relay.d.ts.map +1 -1
- package/dist/tempo/server/Relay.js +6 -4
- package/dist/tempo/server/Relay.js.map +1 -1
- package/dist/tempo/server/SponsorBudget.d.ts.map +1 -1
- package/dist/tempo/server/SponsorBudget.js +7 -1
- package/dist/tempo/server/SponsorBudget.js.map +1 -1
- package/dist/tempo/server/Subscription.d.ts +25 -25
- package/dist/tempo/server/Subscription.d.ts.map +1 -1
- package/dist/tempo/server/Subscription.js +2 -0
- package/dist/tempo/server/Subscription.js.map +1 -1
- package/dist/tempo/server/index.d.ts +1 -1
- package/dist/tempo/server/index.d.ts.map +1 -1
- package/dist/tempo/server/index.js +1 -1
- package/dist/tempo/server/index.js.map +1 -1
- package/dist/tempo/server/internal/html.gen.d.ts +1 -1
- package/dist/tempo/server/internal/html.gen.d.ts.map +1 -1
- package/dist/tempo/server/internal/html.gen.js +1 -1
- package/dist/tempo/server/internal/html.gen.js.map +1 -1
- package/dist/tempo/server/internal/transport.d.ts +2 -0
- package/dist/tempo/server/internal/transport.d.ts.map +1 -1
- package/dist/tempo/server/internal/transport.js +9 -2
- package/dist/tempo/server/internal/transport.js.map +1 -1
- package/dist/tempo/session/client/ChannelOps.js.map +1 -1
- package/dist/tempo/session/client/CredentialState.d.ts +1 -1
- package/dist/tempo/session/client/CredentialState.js.map +1 -1
- package/dist/tempo/session/client/ReceiptCoordinator.js.map +1 -1
- package/dist/tempo/session/client/Runtime.js.map +1 -1
- package/dist/tempo/session/client/Session.d.ts +19 -19
- package/dist/tempo/session/client/Session.d.ts.map +1 -1
- package/dist/tempo/session/client/Session.js +128 -14
- package/dist/tempo/session/client/Session.js.map +1 -1
- package/dist/tempo/session/client/SessionManager.d.ts.map +1 -1
- package/dist/tempo/session/client/SessionManager.js +62 -20
- package/dist/tempo/session/client/SessionManager.js.map +1 -1
- package/dist/tempo/session/client/Transports.d.ts +9 -1
- package/dist/tempo/session/client/Transports.d.ts.map +1 -1
- package/dist/tempo/session/client/Transports.js +36 -13
- package/dist/tempo/session/client/Transports.js.map +1 -1
- package/dist/tempo/session/precompile/Chain.d.ts +27 -0
- package/dist/tempo/session/precompile/Chain.d.ts.map +1 -1
- package/dist/tempo/session/precompile/Chain.js +68 -7
- package/dist/tempo/session/precompile/Chain.js.map +1 -1
- package/dist/tempo/session/precompile/Protocol.js.map +1 -1
- package/dist/tempo/session/precompile/Voucher.d.ts +4 -4
- package/dist/tempo/session/precompile/Voucher.d.ts.map +1 -1
- package/dist/tempo/session/precompile/escrow.abi.d.ts +306 -306
- package/dist/tempo/session/precompile/escrow.abi.d.ts.map +1 -1
- package/dist/tempo/session/server/ChannelStore.d.ts +9 -0
- package/dist/tempo/session/server/ChannelStore.d.ts.map +1 -1
- package/dist/tempo/session/server/ChannelStore.js +16 -8
- package/dist/tempo/session/server/ChannelStore.js.map +1 -1
- package/dist/tempo/session/server/CredentialVerification.d.ts +30 -13
- package/dist/tempo/session/server/CredentialVerification.d.ts.map +1 -1
- package/dist/tempo/session/server/CredentialVerification.js +207 -13
- package/dist/tempo/session/server/CredentialVerification.js.map +1 -1
- package/dist/tempo/session/server/MeteredStream.d.ts +3 -0
- package/dist/tempo/session/server/MeteredStream.d.ts.map +1 -1
- package/dist/tempo/session/server/MeteredStream.js +3 -1
- package/dist/tempo/session/server/MeteredStream.js.map +1 -1
- package/dist/tempo/session/server/Session.d.ts +32 -21
- package/dist/tempo/session/server/Session.d.ts.map +1 -1
- package/dist/tempo/session/server/Session.js +116 -53
- package/dist/tempo/session/server/Session.js.map +1 -1
- package/dist/tempo/session/server/Sse.d.ts +3 -1
- package/dist/tempo/session/server/Sse.d.ts.map +1 -1
- package/dist/tempo/session/server/Sse.js +2 -1
- package/dist/tempo/session/server/Sse.js.map +1 -1
- package/dist/tempo/session/server/Transports.d.ts +1 -1
- package/dist/tempo/session/server/Transports.d.ts.map +1 -1
- package/dist/tempo/session/server/Transports.js +1 -0
- package/dist/tempo/session/server/Transports.js.map +1 -1
- package/dist/tempo/session/server/Ws.d.ts +6 -1
- package/dist/tempo/session/server/Ws.d.ts.map +1 -1
- package/dist/tempo/session/server/Ws.js +4 -0
- package/dist/tempo/session/server/Ws.js.map +1 -1
- package/dist/tempo/subscription/KeyAuthorization.d.ts +38 -866
- package/dist/tempo/subscription/KeyAuthorization.d.ts.map +1 -1
- package/dist/tempo/subscription/KeyAuthorization.js +14 -3
- package/dist/tempo/subscription/KeyAuthorization.js.map +1 -1
- package/dist/viem/Account.d.ts.map +1 -1
- package/dist/viem/Account.js.map +1 -1
- package/dist/viem/Client.d.ts.map +1 -1
- package/dist/viem/Client.js +6 -1
- package/dist/viem/Client.js.map +1 -1
- package/dist/web-bot-auth/Constants.d.ts +20 -0
- package/dist/web-bot-auth/Constants.d.ts.map +1 -0
- package/dist/web-bot-auth/Constants.js +24 -0
- package/dist/web-bot-auth/Constants.js.map +1 -0
- package/dist/web-bot-auth/Types.d.ts +10 -0
- package/dist/web-bot-auth/Types.d.ts.map +1 -0
- package/dist/web-bot-auth/Types.js +2 -0
- package/dist/web-bot-auth/Types.js.map +1 -0
- package/dist/web-bot-auth/client/index.d.ts +29 -0
- package/dist/web-bot-auth/client/index.d.ts.map +1 -0
- package/dist/web-bot-auth/client/index.js +64 -0
- package/dist/web-bot-auth/client/index.js.map +1 -0
- package/dist/web-bot-auth/index.d.ts +7 -0
- package/dist/web-bot-auth/index.d.ts.map +1 -0
- package/dist/web-bot-auth/index.js +7 -0
- package/dist/web-bot-auth/index.js.map +1 -0
- package/dist/web-bot-auth/internal/JwkThumbprint.d.ts +5 -0
- package/dist/web-bot-auth/internal/JwkThumbprint.d.ts.map +1 -0
- package/dist/web-bot-auth/internal/JwkThumbprint.js +20 -0
- package/dist/web-bot-auth/internal/JwkThumbprint.js.map +1 -0
- package/dist/web-bot-auth/internal/SignatureAgent.d.ts +3 -0
- package/dist/web-bot-auth/internal/SignatureAgent.d.ts.map +1 -0
- package/dist/web-bot-auth/internal/SignatureAgent.js +18 -0
- package/dist/web-bot-auth/internal/SignatureAgent.js.map +1 -0
- package/dist/web-bot-auth/server/index.d.ts +35 -0
- package/dist/web-bot-auth/server/index.d.ts.map +1 -0
- package/dist/web-bot-auth/server/index.js +88 -0
- package/dist/web-bot-auth/server/index.js.map +1 -0
- package/dist/x402/Assets.d.ts.map +1 -1
- package/dist/x402/Types.d.ts +6 -6
- package/dist/x402/Types.d.ts.map +1 -1
- package/dist/x402/server/EvmCharge.d.ts.map +1 -1
- package/dist/x402/server/EvmCharge.js +32 -20
- package/dist/x402/server/EvmCharge.js.map +1 -1
- package/package.json +20 -4
- package/src/Challenge.fuzz.test.ts +80 -47
- package/src/Challenge.test.ts +65 -0
- package/src/Challenge.ts +39 -35
- package/src/Method.ts +82 -68
- package/src/Store.test-d.ts +16 -0
- package/src/Store.test.ts +50 -0
- package/src/Store.ts +68 -0
- package/src/attestation/Attestation.integration.test.ts +208 -0
- package/src/attestation/Client.test.ts +83 -0
- package/src/attestation/Client.ts +34 -0
- package/src/attestation/Constants.ts +15 -0
- package/src/attestation/Server.test.ts +60 -0
- package/src/attestation/Server.ts +12 -0
- package/src/attestation/Types.test-d.ts +54 -0
- package/src/attestation/Types.ts +77 -0
- package/src/attestation/index.ts +5 -0
- package/src/attestation/internal/HttpMessageSignature.test.ts +101 -0
- package/src/attestation/internal/HttpMessageSignature.ts +429 -0
- package/src/attestation/internal/SigningContext.ts +13 -0
- package/src/bin.js +2 -0
- package/src/cli/cli.ts +1 -0
- package/src/cli/validate/payment.ts +18 -4
- package/src/cli/validate.test.ts +16 -0
- package/src/client/Mppx.test-d.ts +17 -0
- package/src/client/Mppx.test.ts +14 -14
- package/src/client/Mppx.ts +25 -4
- package/src/client/Transport.test.ts +12 -45
- package/src/client/Transport.ts +3 -24
- package/src/client/internal/Fetch.test.ts +77 -0
- package/src/client/internal/Fetch.ts +112 -14
- package/src/client/internal/MethodChallenge.ts +5 -0
- package/src/client/internal/MethodResponse.ts +28 -0
- package/src/discovery/OpenApi.test.ts +170 -0
- package/src/discovery/OpenApi.ts +16 -48
- package/src/discovery/internal/Metadata.ts +51 -0
- package/src/evm/server/Charge.ts +6 -1
- package/src/internal/AcceptPayment.test.ts +12 -8
- package/src/internal/types.ts +9 -0
- package/src/mcp/client/McpClient.integration.test.ts +19 -32
- package/src/middlewares/elysia.test.ts +2 -12
- package/src/middlewares/express.test.ts +2 -12
- package/src/middlewares/hono.test.ts +6 -9
- package/src/middlewares/nextjs.test.ts +2 -12
- package/src/proxy/Proxy.test.ts +26 -19
- package/src/proxy/Proxy.ts +147 -9
- package/src/proxy/Proxy.upstreamError.test.ts +364 -0
- package/src/proxy/Service.test.ts +73 -3
- package/src/proxy/Service.ts +50 -23
- package/src/proxy/services/anthropic.ts +1 -0
- package/src/proxy/services/hooks.test-d.ts +14 -0
- package/src/proxy/services/hooks.test.ts +44 -0
- package/src/proxy/services/openai.ts +1 -0
- package/src/proxy/services/stripe.ts +1 -0
- package/src/server/Methods.test-d.ts +88 -0
- package/src/server/Methods.test.ts +69 -0
- package/src/server/Mppx.test-d.ts +141 -7
- package/src/server/Mppx.test.ts +1017 -119
- package/src/server/Mppx.ts +350 -54
- package/src/stripe/internal/constants.ts +1 -1
- package/src/stripe/internal/types.ts +1 -0
- package/src/stripe/server/Charge.test-d.ts +16 -1
- package/src/stripe/server/Charge.test.ts +79 -0
- package/src/stripe/server/Charge.ts +54 -1
- package/src/stripe/server/Methods.test-d.ts +157 -0
- package/src/stripe/server/Methods.test.ts +403 -0
- package/src/stripe/server/Methods.ts +423 -6
- package/src/stripe/server/internal/deposit-address.ts +57 -0
- package/src/stripe/server/internal/html/node_modules/.bin/mppx +3 -3
- package/src/stripe/server/internal/html/package.json +1 -1
- package/src/stripe/server/internal/html.gen.ts +1 -1
- package/src/stripe/server/internal/record-payment.ts +66 -0
- package/src/stripe/server/internal/request.ts +49 -0
- package/src/tap/Constants.ts +32 -0
- package/src/tap/Tap.test.ts +125 -0
- package/src/tap/Types.ts +11 -0
- package/src/tap/client/index.ts +54 -0
- package/src/tap/index.ts +4 -0
- package/src/tap/server/index.ts +48 -0
- package/src/tempo/PublicExports.test-d.ts +3 -3
- package/src/tempo/client/Charge.ts +1 -19
- package/src/tempo/internal/address.test.ts +42 -0
- package/src/tempo/internal/address.ts +3 -3
- package/src/tempo/internal/auto-swap.test.ts +4 -4
- package/src/tempo/internal/auto-swap.ts +7 -50
- package/src/tempo/legacy/README.md +5 -5
- package/src/tempo/legacy/index.ts +1 -3
- package/src/tempo/server/AtomicStore.test-d.ts +13 -0
- package/src/tempo/server/Charge.test.ts +19 -84
- package/src/tempo/server/Charge.ts +92 -56
- package/src/tempo/server/Methods.ts +0 -20
- package/src/tempo/server/Relay.test.ts +161 -7
- package/src/tempo/server/Relay.ts +15 -6
- package/src/tempo/server/SponsorBudget.test.ts +29 -0
- package/src/tempo/server/SponsorBudget.ts +7 -1
- package/src/tempo/server/Subscription.ts +4 -1
- package/src/tempo/server/index.ts +1 -1
- package/src/tempo/server/internal/html/node_modules/.bin/mppx +3 -3
- package/src/tempo/server/internal/html/package.json +1 -1
- package/src/tempo/server/internal/html.gen.ts +1 -1
- package/src/tempo/server/internal/transport.test.ts +22 -3
- package/src/tempo/server/internal/transport.ts +15 -3
- package/src/tempo/session/README.md +119 -0
- package/src/tempo/session/client/Session.test.ts +299 -33
- package/src/tempo/session/client/Session.ts +152 -16
- package/src/tempo/session/client/SessionManager.test.ts +216 -9
- package/src/tempo/session/client/SessionManager.ts +63 -17
- package/src/tempo/session/client/Transports.test.ts +22 -0
- package/src/tempo/session/client/Transports.ts +58 -22
- package/src/tempo/session/precompile/Chain.ts +131 -11
- package/src/tempo/session/server/ChannelStore.ts +33 -12
- package/src/tempo/session/server/CredentialVerification.test.ts +4 -4
- package/src/tempo/session/server/CredentialVerification.ts +340 -28
- package/src/tempo/session/server/MeteredStream.ts +5 -1
- package/src/tempo/session/server/Session.test.ts +483 -36
- package/src/tempo/session/server/Session.ts +159 -60
- package/src/tempo/session/server/Sse.test.ts +77 -0
- package/src/tempo/session/server/Sse.ts +8 -1
- package/src/tempo/session/server/Transports.ts +2 -1
- package/src/tempo/session/server/Ws.test.ts +171 -0
- package/src/tempo/session/server/Ws.ts +10 -1
- package/src/tempo/subscription/KeyAuthorization.test.ts +70 -1
- package/src/tempo/subscription/KeyAuthorization.ts +14 -3
- package/src/viem/Client.test.ts +18 -1
- package/src/viem/Client.ts +7 -1
- package/src/web-bot-auth/Constants.ts +24 -0
- package/src/web-bot-auth/Types.ts +9 -0
- package/src/web-bot-auth/WebBotAuth.test.ts +182 -0
- package/src/web-bot-auth/client/index.ts +84 -0
- package/src/web-bot-auth/index.ts +6 -0
- package/src/web-bot-auth/internal/JwkThumbprint.ts +21 -0
- package/src/web-bot-auth/internal/SignatureAgent.ts +18 -0
- package/src/web-bot-auth/server/index.ts +113 -0
- package/src/x402/Exact.e2e.test.ts +121 -81
- package/src/x402/Exact.localnet.test.ts +1 -1
- package/src/x402/server/EvmCharge.ts +35 -19
- 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/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/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/ChannelStore.test.ts +0 -58
- package/src/tempo/legacy/session/ChannelStore.ts +0 -39
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { NoExtraKeys } from '../../internal/types.js'
|
|
2
|
-
import { session as sessionLegacy_, settle as settleLegacy_ } from '../legacy/server/index.js'
|
|
3
2
|
import {
|
|
4
3
|
charge as sessionCharge_,
|
|
5
4
|
session as session_,
|
|
@@ -18,23 +17,6 @@ const sessionServer = Object.assign(session_, {
|
|
|
18
17
|
settleBatch: settleBatch_,
|
|
19
18
|
})
|
|
20
19
|
|
|
21
|
-
function createSessionLegacyMethod<
|
|
22
|
-
const parameters extends NonNullable<Parameters<typeof sessionLegacy_>[0]>,
|
|
23
|
-
>(parameters?: parameters) {
|
|
24
|
-
return Object.assign(sessionLegacy_(parameters as never), { alias: 'sessionLegacy' as const })
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const sessionLegacyServer = Object.assign(createSessionLegacyMethod, {
|
|
28
|
-
settle: settleLegacy_,
|
|
29
|
-
Ws: Ws_,
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
/** Creates a legacy contract-backed Tempo `session` server method. */
|
|
33
|
-
export const sessionLegacy = sessionLegacyServer
|
|
34
|
-
|
|
35
|
-
/** Settles a legacy contract-backed Tempo session channel. */
|
|
36
|
-
export const settleLegacy = settleLegacy_
|
|
37
|
-
|
|
38
20
|
function createChargeMethod<const parameters extends tempo.Parameters>(
|
|
39
21
|
parameters: parameters | undefined,
|
|
40
22
|
) {
|
|
@@ -86,8 +68,6 @@ export namespace tempo {
|
|
|
86
68
|
export const common = tempo
|
|
87
69
|
/** Creates a TIP-1034 Tempo `session` method for session-based TIP-20 token payments. */
|
|
88
70
|
export const session = sessionServer
|
|
89
|
-
/** @deprecated Use `tempo.session()` for the TIP-1034 session server method. */
|
|
90
|
-
export const sessionLegacy = sessionLegacyServer
|
|
91
71
|
/** Creates a Tempo `subscription` method for recurring TIP-20 token payments. */
|
|
92
72
|
export const subscription = subscription_
|
|
93
73
|
/** Renews an overdue Tempo subscription outside of the HTTP request path. */
|
|
@@ -4,6 +4,8 @@ import * as Http from '~test/Http.js'
|
|
|
4
4
|
|
|
5
5
|
import * as Challenge from '../../Challenge.js'
|
|
6
6
|
import * as Credential from '../../Credential.js'
|
|
7
|
+
import * as Method from '../../Method.js'
|
|
8
|
+
import * as Receipt from '../../Receipt.js'
|
|
7
9
|
import * as Mppx from '../../server/Mppx.js'
|
|
8
10
|
import { tempo } from './Methods.js'
|
|
9
11
|
|
|
@@ -23,6 +25,11 @@ const credential = {
|
|
|
23
25
|
source: 'did:pkh:eip155:42431:0x123',
|
|
24
26
|
} as const
|
|
25
27
|
|
|
28
|
+
const pushedPayload = {
|
|
29
|
+
hash: '0x1a2b3c4d5e6f7890abcdef1234567890abcdef1234567890abcdef1234567890',
|
|
30
|
+
type: 'hash',
|
|
31
|
+
} as const
|
|
32
|
+
|
|
26
33
|
type RelayHandler = (url: URL, init: RequestInit) => Response | Promise<Response>
|
|
27
34
|
|
|
28
35
|
function mockRelay(handler: RelayHandler): typeof globalThis.fetch {
|
|
@@ -52,7 +59,10 @@ function successReceipt() {
|
|
|
52
59
|
})
|
|
53
60
|
}
|
|
54
61
|
|
|
55
|
-
async function createPaymentServer(
|
|
62
|
+
async function createPaymentServer(
|
|
63
|
+
fetch: typeof globalThis.fetch,
|
|
64
|
+
payload: typeof credential.payload | typeof pushedPayload = credential.payload,
|
|
65
|
+
) {
|
|
56
66
|
const [method] = methods(fetch, apiBaseUrl)
|
|
57
67
|
const mppx = Mppx.create({ methods: [method], realm, secretKey })
|
|
58
68
|
const handle = mppx.tempo.charge({ amount: '1', decimals: 6 })
|
|
@@ -65,7 +75,7 @@ async function createPaymentServer(fetch: typeof globalThis.fetch) {
|
|
|
65
75
|
const challenge = Challenge.fromResponse(challengeResponse)
|
|
66
76
|
const paymentCredential = Credential.from({
|
|
67
77
|
challenge,
|
|
68
|
-
payload
|
|
78
|
+
payload,
|
|
69
79
|
source: credential.source,
|
|
70
80
|
})
|
|
71
81
|
|
|
@@ -186,7 +196,7 @@ describe('relay boundary', () => {
|
|
|
186
196
|
headers: expect.objectContaining({
|
|
187
197
|
Accept: 'application/json',
|
|
188
198
|
'content-type': 'application/json',
|
|
189
|
-
'idempotency-key': expect.stringMatching(/^
|
|
199
|
+
'idempotency-key': expect.stringMatching(/^mpp_0x/),
|
|
190
200
|
'tempo-api-key': 'tempo_api_key',
|
|
191
201
|
}),
|
|
192
202
|
method: 'POST',
|
|
@@ -196,6 +206,65 @@ describe('relay boundary', () => {
|
|
|
196
206
|
])
|
|
197
207
|
})
|
|
198
208
|
|
|
209
|
+
test('delegates pushed transaction finalization to the relay', async () => {
|
|
210
|
+
const calls: Array<{ init: RequestInit; url: URL }> = []
|
|
211
|
+
const fetch = mockRelay((url, init) => {
|
|
212
|
+
calls.push({ init, url })
|
|
213
|
+
return url.pathname === '/v1/mpp/validate'
|
|
214
|
+
? Response.json({ success: true })
|
|
215
|
+
: successReceipt()
|
|
216
|
+
})
|
|
217
|
+
const [method] = methods(fetch)
|
|
218
|
+
const pushedCredential = { ...credential, payload: pushedPayload }
|
|
219
|
+
|
|
220
|
+
await expect(
|
|
221
|
+
method.verify({
|
|
222
|
+
credential: pushedCredential,
|
|
223
|
+
request: credential.challenge.request,
|
|
224
|
+
} as never),
|
|
225
|
+
).resolves.toMatchObject({
|
|
226
|
+
method: 'tempo',
|
|
227
|
+
reference: '0xabc',
|
|
228
|
+
status: 'success',
|
|
229
|
+
})
|
|
230
|
+
expect(calls).toEqual([
|
|
231
|
+
expect.objectContaining({ url: new URL(`${apiBaseUrl}/v1/mpp/validate`) }),
|
|
232
|
+
expect.objectContaining({
|
|
233
|
+
init: expect.objectContaining({ body: JSON.stringify(pushedCredential) }),
|
|
234
|
+
url: new URL(`${apiBaseUrl}/v1/mpp/broadcast`),
|
|
235
|
+
}),
|
|
236
|
+
])
|
|
237
|
+
})
|
|
238
|
+
|
|
239
|
+
test('validates a pushed transaction before returning its receipt', async () => {
|
|
240
|
+
const calls: string[] = []
|
|
241
|
+
const fetch = mockRelay((url) => {
|
|
242
|
+
calls.push(url.pathname)
|
|
243
|
+
return url.pathname === '/v1/mpp/validate'
|
|
244
|
+
? Response.json({ success: true })
|
|
245
|
+
: successReceipt()
|
|
246
|
+
})
|
|
247
|
+
const [method] = methods(fetch)
|
|
248
|
+
const pushedCredential = {
|
|
249
|
+
...credential,
|
|
250
|
+
challenge: {
|
|
251
|
+
...credential.challenge,
|
|
252
|
+
expires: new Date(Date.now() + 60_000).toISOString(),
|
|
253
|
+
},
|
|
254
|
+
payload: pushedPayload,
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
await expect(
|
|
258
|
+
Method.broadcastCredential([method], pushedCredential as never),
|
|
259
|
+
).resolves.toMatchObject({
|
|
260
|
+
method: 'tempo',
|
|
261
|
+
reference: '0xabc',
|
|
262
|
+
status: 'success',
|
|
263
|
+
})
|
|
264
|
+
|
|
265
|
+
expect(calls).toEqual(['/v1/mpp/validate', '/v1/mpp/broadcast'])
|
|
266
|
+
})
|
|
267
|
+
|
|
199
268
|
test('uses the transaction hash as the transaction broadcast idempotency key', async () => {
|
|
200
269
|
const calls: RequestInit[] = []
|
|
201
270
|
const fetch = mockRelay((_url, init) => {
|
|
@@ -213,9 +282,9 @@ describe('relay boundary', () => {
|
|
|
213
282
|
|
|
214
283
|
const keys = calls.map((init) => (init.headers as Record<string, string>)['idempotency-key'])
|
|
215
284
|
expect(keys).toEqual([
|
|
216
|
-
`
|
|
217
|
-
`
|
|
218
|
-
`
|
|
285
|
+
`mpp_${Hash.keccak256(Hex.toBytes(credential.payload.signature), { as: 'Hex' })}`,
|
|
286
|
+
`mpp_${Hash.keccak256(Hex.toBytes(credential.payload.signature), { as: 'Hex' })}`,
|
|
287
|
+
`mpp_${Hash.keccak256(Hex.toBytes('0x5678'), { as: 'Hex' })}`,
|
|
219
288
|
])
|
|
220
289
|
})
|
|
221
290
|
|
|
@@ -247,7 +316,7 @@ describe('relay boundary', () => {
|
|
|
247
316
|
),
|
|
248
317
|
{ as: 'Hex' },
|
|
249
318
|
)
|
|
250
|
-
expect(headers['idempotency-key']).toBe(`
|
|
319
|
+
expect(headers['idempotency-key']).toBe(`mpp_${expected}`)
|
|
251
320
|
})
|
|
252
321
|
|
|
253
322
|
test('preserves the legacy combined verify hook', async () => {
|
|
@@ -433,6 +502,91 @@ describe('relay HTTP flow', () => {
|
|
|
433
502
|
}
|
|
434
503
|
})
|
|
435
504
|
|
|
505
|
+
test('delegates pushed transaction finalization to the relay', async () => {
|
|
506
|
+
const calls: string[] = []
|
|
507
|
+
const fetch = mockRelay((url) => {
|
|
508
|
+
calls.push(url.pathname)
|
|
509
|
+
return url.pathname === '/v1/mpp/validate'
|
|
510
|
+
? Response.json({ success: true })
|
|
511
|
+
: successReceipt()
|
|
512
|
+
})
|
|
513
|
+
const { pay, server } = await createPaymentServer(fetch, pushedPayload)
|
|
514
|
+
|
|
515
|
+
try {
|
|
516
|
+
const response = await pay()
|
|
517
|
+
|
|
518
|
+
expect(response.status).toBe(200)
|
|
519
|
+
expect(Receipt.fromResponse(response)).toMatchObject({
|
|
520
|
+
method: 'tempo',
|
|
521
|
+
reference: '0xabc',
|
|
522
|
+
status: 'success',
|
|
523
|
+
})
|
|
524
|
+
expect(calls).toEqual(['/v1/mpp/validate', '/v1/mpp/broadcast'])
|
|
525
|
+
} finally {
|
|
526
|
+
server.close()
|
|
527
|
+
}
|
|
528
|
+
})
|
|
529
|
+
|
|
530
|
+
test('does not issue a receipt when relay validation rejects a pushed transaction', async () => {
|
|
531
|
+
const calls: string[] = []
|
|
532
|
+
const fetch = mockRelay((url) => {
|
|
533
|
+
calls.push(url.pathname)
|
|
534
|
+
return Response.json({
|
|
535
|
+
error: { code: 'policy_denied', message: 'private detail' },
|
|
536
|
+
success: false,
|
|
537
|
+
})
|
|
538
|
+
})
|
|
539
|
+
const { pay, server } = await createPaymentServer(fetch, pushedPayload)
|
|
540
|
+
|
|
541
|
+
try {
|
|
542
|
+
const response = await pay()
|
|
543
|
+
const body = (await response.json()) as Record<string, unknown>
|
|
544
|
+
|
|
545
|
+
expect(response.status).toBe(402)
|
|
546
|
+
expect(response.headers.get('Payment-Receipt')).toBeNull()
|
|
547
|
+
expect(body).toMatchObject({
|
|
548
|
+
detail: 'Payment verification failed.',
|
|
549
|
+
type: 'https://paymentauth.org/problems/verification-failed',
|
|
550
|
+
})
|
|
551
|
+
expect(JSON.stringify(body)).not.toContain('policy_denied')
|
|
552
|
+
expect(JSON.stringify(body)).not.toContain('private detail')
|
|
553
|
+
expect(calls).toEqual(['/v1/mpp/validate'])
|
|
554
|
+
} finally {
|
|
555
|
+
server.close()
|
|
556
|
+
}
|
|
557
|
+
})
|
|
558
|
+
|
|
559
|
+
test('does not issue a receipt when relay finalization rejects a pushed transaction', async () => {
|
|
560
|
+
const calls: string[] = []
|
|
561
|
+
const fetch = mockRelay((url) => {
|
|
562
|
+
calls.push(url.pathname)
|
|
563
|
+
return url.pathname === '/v1/mpp/validate'
|
|
564
|
+
? Response.json({ success: true })
|
|
565
|
+
: Response.json({
|
|
566
|
+
error: { code: 'already_used', message: 'private detail' },
|
|
567
|
+
success: false,
|
|
568
|
+
})
|
|
569
|
+
})
|
|
570
|
+
const { pay, server } = await createPaymentServer(fetch, pushedPayload)
|
|
571
|
+
|
|
572
|
+
try {
|
|
573
|
+
const response = await pay()
|
|
574
|
+
const body = (await response.json()) as Record<string, unknown>
|
|
575
|
+
|
|
576
|
+
expect(response.status).toBe(402)
|
|
577
|
+
expect(response.headers.get('Payment-Receipt')).toBeNull()
|
|
578
|
+
expect(body).toMatchObject({
|
|
579
|
+
detail: 'Payment verification failed.',
|
|
580
|
+
details: { code: 'already_used' },
|
|
581
|
+
type: 'https://paymentauth.org/problems/verification-failed',
|
|
582
|
+
})
|
|
583
|
+
expect(JSON.stringify(body)).not.toContain('private detail')
|
|
584
|
+
expect(calls).toEqual(['/v1/mpp/validate', '/v1/mpp/broadcast'])
|
|
585
|
+
} finally {
|
|
586
|
+
server.close()
|
|
587
|
+
}
|
|
588
|
+
})
|
|
589
|
+
|
|
436
590
|
test.each([
|
|
437
591
|
['validation network failure', () => Promise.reject(new TypeError('tempo api unavailable')), 1],
|
|
438
592
|
[
|
|
@@ -64,8 +64,10 @@ type BroadcastResponse =
|
|
|
64
64
|
* Configures a Tempo payment method to use Tempo API's MPP relay.
|
|
65
65
|
*
|
|
66
66
|
* The adapter preserves the supplied method's challenge configuration while
|
|
67
|
-
* delegating
|
|
68
|
-
* `/v1/mpp/
|
|
67
|
+
* delegating validation and finalization to `/v1/mpp/validate` and
|
|
68
|
+
* `/v1/mpp/broadcast`. The relay receives every submitted credential: it
|
|
69
|
+
* broadcasts pull transactions and finalizes push transaction hashes without
|
|
70
|
+
* sending them again.
|
|
69
71
|
*
|
|
70
72
|
* @internal
|
|
71
73
|
*/
|
|
@@ -127,13 +129,20 @@ export declare namespace configure {
|
|
|
127
129
|
Method.Server<intent>,
|
|
128
130
|
'broadcast' | 'validate'
|
|
129
131
|
> & {
|
|
130
|
-
/**
|
|
132
|
+
/** Delegates payment finalization to Tempo API's relay. */
|
|
131
133
|
broadcast: Method.BroadcastFn<intent>
|
|
132
134
|
/** Validates the credential through Tempo API. */
|
|
133
135
|
validate: Method.ValidateFn<intent>
|
|
134
136
|
}
|
|
135
137
|
|
|
136
|
-
/**
|
|
138
|
+
/**
|
|
139
|
+
* Tempo API relay configuration for server-side Tempo charges.
|
|
140
|
+
*
|
|
141
|
+
* The adapter sends every credential to the relay for finalization. The
|
|
142
|
+
* relay broadcasts pull credentials, while it recognizes a push credential
|
|
143
|
+
* as an already-broadcast transaction and returns its receipt without
|
|
144
|
+
* sending it again.
|
|
145
|
+
*/
|
|
137
146
|
type Options = {
|
|
138
147
|
/** Tempo API key with the `mpp:write` scope. */
|
|
139
148
|
apiKey: string
|
|
@@ -223,11 +232,11 @@ function idempotencyKey(input: RelayInput): string {
|
|
|
223
232
|
Hex.validate(payload.signature)
|
|
224
233
|
) {
|
|
225
234
|
const transactionHash = Hash.keccak256(Hex.toBytes(payload.signature), { as: 'Hex' })
|
|
226
|
-
return `
|
|
235
|
+
return `mpp_${transactionHash}`
|
|
227
236
|
}
|
|
228
237
|
|
|
229
238
|
const hash = Hash.sha256(Bytes.fromString(Json.canonicalize(input)), { as: 'Hex' })
|
|
230
|
-
return `
|
|
239
|
+
return `mpp_${hash}`
|
|
231
240
|
}
|
|
232
241
|
|
|
233
242
|
function failure(value?: unknown) {
|
|
@@ -74,6 +74,35 @@ describe('SponsorBudget', () => {
|
|
|
74
74
|
expect(Object.keys(state!.reservations)).toEqual([hash2])
|
|
75
75
|
})
|
|
76
76
|
|
|
77
|
+
test('does not reconcile a broadcasting reservation before its owner publishes pending', async () => {
|
|
78
|
+
const store = memoryStore()
|
|
79
|
+
const getReceipt = async (hash: Hex) => {
|
|
80
|
+
if (hash === hash1) return {}
|
|
81
|
+
throw new Error('not found')
|
|
82
|
+
}
|
|
83
|
+
const first = await SponsorBudget.reserve(store, parameters({ getReceipt }))
|
|
84
|
+
expect(await SponsorBudget.transition(store, first, 'broadcasting')).toBe(true)
|
|
85
|
+
|
|
86
|
+
const second = SponsorBudget.reserve(
|
|
87
|
+
store,
|
|
88
|
+
parameters({
|
|
89
|
+
getReceipt,
|
|
90
|
+
id: hash2,
|
|
91
|
+
owner: 'worker-2',
|
|
92
|
+
transactionHash: hash2,
|
|
93
|
+
}),
|
|
94
|
+
)
|
|
95
|
+
expect(
|
|
96
|
+
await Promise.race([
|
|
97
|
+
second.then(() => 'reserved' as const),
|
|
98
|
+
new Promise<'waiting'>((resolve) => setTimeout(() => resolve('waiting'), 40)),
|
|
99
|
+
]),
|
|
100
|
+
).toBe('waiting')
|
|
101
|
+
|
|
102
|
+
expect(await SponsorBudget.transition(store, first, 'pending')).toBe(true)
|
|
103
|
+
await expect(second).resolves.toMatchObject({ id: hash2, owner: 'worker-2' })
|
|
104
|
+
})
|
|
105
|
+
|
|
77
106
|
test('fences release and transition by reservation owner', async () => {
|
|
78
107
|
const store = memoryStore()
|
|
79
108
|
const handle = await SponsorBudget.reserve(store, parameters())
|
|
@@ -99,7 +99,13 @@ async function reconcile(
|
|
|
99
99
|
await release(store, handle)
|
|
100
100
|
return
|
|
101
101
|
}
|
|
102
|
-
|
|
102
|
+
// The broadcasting owner has submitted (or is about to submit) the
|
|
103
|
+
// transaction but has not yet published that outcome to this store.
|
|
104
|
+
// Releasing its reservation here races the owner's transition to
|
|
105
|
+
// `pending`: the transaction can settle while the owner observes a lost
|
|
106
|
+
// reservation and reports a retryable payment failure. Only reconcile
|
|
107
|
+
// receipts after the owner has completed that hand-off.
|
|
108
|
+
if (reservation.phase !== 'pending') return
|
|
103
109
|
|
|
104
110
|
try {
|
|
105
111
|
await parameters.getReceipt(reservation.transactionHash)
|
|
@@ -94,6 +94,8 @@ export function subscription<const parameters extends subscription.Parameters>(
|
|
|
94
94
|
undefined,
|
|
95
95
|
subscription.Extensions
|
|
96
96
|
>(Methods.subscription, {
|
|
97
|
+
canOffer: parameters.canOffer,
|
|
98
|
+
onPaymentSuccess: parameters.onPaymentSuccess,
|
|
97
99
|
defaults: {
|
|
98
100
|
amount,
|
|
99
101
|
currency,
|
|
@@ -1281,7 +1283,8 @@ export declare namespace subscription {
|
|
|
1281
1283
|
storeKeyPrefix?: string | undefined
|
|
1282
1284
|
testnet?: boolean | undefined
|
|
1283
1285
|
waitForConfirmation?: boolean | undefined
|
|
1284
|
-
} & Defaults
|
|
1286
|
+
} & Defaults &
|
|
1287
|
+
Method.ComposableHooks<typeof Methods.subscription>
|
|
1285
1288
|
|
|
1286
1289
|
/** Derived defaults after account and chain configuration are applied. */
|
|
1287
1290
|
type DeriveDefaults<parameters extends Parameters> = types.DeriveDefaults<
|
|
@@ -2,7 +2,7 @@ export * as ChannelStore from '../session/server/ChannelStore.js'
|
|
|
2
2
|
export * as Sse from '../session/server/Sse.js'
|
|
3
3
|
export * as Ws from '../session/server/Ws.js'
|
|
4
4
|
export { charge } from './Charge.js'
|
|
5
|
-
export {
|
|
5
|
+
export { tempo } from './Methods.js'
|
|
6
6
|
export { session, settle, settleBatch } from '../session/server/Session.js'
|
|
7
7
|
export type {
|
|
8
8
|
OnSessionSettlement,
|
|
@@ -15,8 +15,8 @@ else
|
|
|
15
15
|
export NODE_PATH="/home/runner/work/mppx/mppx/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
16
|
fi
|
|
17
17
|
if [ -x "$basedir/node" ]; then
|
|
18
|
-
exec "$basedir/node" "$basedir/../mppx/
|
|
18
|
+
exec "$basedir/node" "$basedir/../mppx/src/bin.js" "$@"
|
|
19
19
|
else
|
|
20
|
-
exec node "$basedir/../mppx/
|
|
20
|
+
exec node "$basedir/../mppx/src/bin.js" "$@"
|
|
21
21
|
fi
|
|
22
|
-
# cmd-shim-target=/home/runner/work/mppx/mppx/src/tempo/server/internal/html/node_modules/mppx/
|
|
22
|
+
# cmd-shim-target=/home/runner/work/mppx/mppx/src/tempo/server/internal/html/node_modules/mppx/src/bin.js
|