mppx 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +195 -0
- package/dist/BodyDigest.d.ts +42 -0
- package/dist/BodyDigest.d.ts.map +1 -0
- package/dist/BodyDigest.js +40 -0
- package/dist/BodyDigest.js.map +1 -0
- package/dist/Challenge.d.ts +271 -0
- package/dist/Challenge.d.ts.map +1 -0
- package/dist/Challenge.js +291 -0
- package/dist/Challenge.js.map +1 -0
- package/dist/Credential.d.ts +91 -0
- package/dist/Credential.d.ts.map +1 -0
- package/dist/Credential.js +122 -0
- package/dist/Credential.js.map +1 -0
- package/dist/Errors.d.ts +243 -0
- package/dist/Errors.d.ts.map +1 -0
- package/dist/Errors.js +201 -0
- package/dist/Errors.js.map +1 -0
- package/dist/Expires.d.ts +15 -0
- package/dist/Expires.d.ts.map +1 -0
- package/dist/Expires.js +29 -0
- package/dist/Expires.js.map +1 -0
- package/dist/Intent.d.ts +101 -0
- package/dist/Intent.d.ts.map +1 -0
- package/dist/Intent.js +83 -0
- package/dist/Intent.js.map +1 -0
- package/dist/Mcp.d.ts +74 -0
- package/dist/Mcp.d.ts.map +1 -0
- package/dist/Mcp.js +9 -0
- package/dist/Mcp.js.map +1 -0
- package/dist/MethodIntent.d.ts +225 -0
- package/dist/MethodIntent.d.ts.map +1 -0
- package/dist/MethodIntent.js +156 -0
- package/dist/MethodIntent.js.map +1 -0
- package/dist/PaymentRequest.d.ts +88 -0
- package/dist/PaymentRequest.d.ts.map +1 -0
- package/dist/PaymentRequest.js +81 -0
- package/dist/PaymentRequest.js.map +1 -0
- package/dist/Receipt.d.ts +110 -0
- package/dist/Receipt.d.ts.map +1 -0
- package/dist/Receipt.js +105 -0
- package/dist/Receipt.js.map +1 -0
- package/dist/Store.d.ts +28 -0
- package/dist/Store.d.ts.map +1 -0
- package/dist/Store.js +61 -0
- package/dist/Store.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +1219 -0
- package/dist/cli.js.map +1 -0
- package/dist/client/Methods.d.ts +4 -0
- package/dist/client/Methods.d.ts.map +1 -0
- package/dist/client/Methods.js +4 -0
- package/dist/client/Methods.js.map +1 -0
- package/dist/client/Mppx.d.ts +84 -0
- package/dist/client/Mppx.d.ts.map +1 -0
- package/dist/client/Mppx.js +64 -0
- package/dist/client/Mppx.js.map +1 -0
- package/dist/client/Transport.d.ts +56 -0
- package/dist/client/Transport.d.ts.map +1 -0
- package/dist/client/Transport.js +81 -0
- package/dist/client/Transport.js.map +1 -0
- package/dist/client/index.d.ts +5 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +5 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/internal/Fetch.d.ts +85 -0
- package/dist/client/internal/Fetch.d.ts.map +1 -0
- package/dist/client/internal/Fetch.js +95 -0
- package/dist/client/internal/Fetch.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/types.d.ts +302 -0
- package/dist/internal/types.d.ts.map +1 -0
- package/dist/internal/types.js +2 -0
- package/dist/internal/types.js.map +1 -0
- package/dist/mcp-sdk/client/McpClient.d.ts +78 -0
- package/dist/mcp-sdk/client/McpClient.d.ts.map +1 -0
- package/dist/mcp-sdk/client/McpClient.js +98 -0
- package/dist/mcp-sdk/client/McpClient.js.map +1 -0
- package/dist/mcp-sdk/client/index.d.ts +3 -0
- package/dist/mcp-sdk/client/index.d.ts.map +1 -0
- package/dist/mcp-sdk/client/index.js +3 -0
- package/dist/mcp-sdk/client/index.js.map +1 -0
- package/dist/mcp-sdk/server/Transport.d.ts +43 -0
- package/dist/mcp-sdk/server/Transport.d.ts.map +1 -0
- package/dist/mcp-sdk/server/Transport.js +71 -0
- package/dist/mcp-sdk/server/Transport.js.map +1 -0
- package/dist/mcp-sdk/server/index.d.ts +2 -0
- package/dist/mcp-sdk/server/index.d.ts.map +1 -0
- package/dist/mcp-sdk/server/index.js +2 -0
- package/dist/mcp-sdk/server/index.js.map +1 -0
- package/dist/middlewares/elysia.d.ts +51 -0
- package/dist/middlewares/elysia.d.ts.map +1 -0
- package/dist/middlewares/elysia.js +59 -0
- package/dist/middlewares/elysia.js.map +1 -0
- package/dist/middlewares/express.d.ts +46 -0
- package/dist/middlewares/express.d.ts.map +1 -0
- package/dist/middlewares/express.js +69 -0
- package/dist/middlewares/express.js.map +1 -0
- package/dist/middlewares/hono.d.ts +46 -0
- package/dist/middlewares/hono.d.ts.map +1 -0
- package/dist/middlewares/hono.js +57 -0
- package/dist/middlewares/hono.js.map +1 -0
- package/dist/middlewares/internal/mppx.d.ts +16 -0
- package/dist/middlewares/internal/mppx.d.ts.map +1 -0
- package/dist/middlewares/internal/mppx.js +16 -0
- package/dist/middlewares/internal/mppx.js.map +1 -0
- package/dist/middlewares/nextjs.d.ts +45 -0
- package/dist/middlewares/nextjs.d.ts.map +1 -0
- package/dist/middlewares/nextjs.js +57 -0
- package/dist/middlewares/nextjs.js.map +1 -0
- package/dist/proxy/Proxy.d.ts +47 -0
- package/dist/proxy/Proxy.d.ts.map +1 -0
- package/dist/proxy/Proxy.js +126 -0
- package/dist/proxy/Proxy.js.map +1 -0
- package/dist/proxy/Service.d.ts +100 -0
- package/dist/proxy/Service.d.ts.map +1 -0
- package/dist/proxy/Service.js +147 -0
- package/dist/proxy/Service.js.map +1 -0
- package/dist/proxy/index.d.ts +7 -0
- package/dist/proxy/index.d.ts.map +1 -0
- package/dist/proxy/index.js +7 -0
- package/dist/proxy/index.js.map +1 -0
- package/dist/proxy/internal/Headers.d.ts +3 -0
- package/dist/proxy/internal/Headers.d.ts.map +1 -0
- package/dist/proxy/internal/Headers.js +41 -0
- package/dist/proxy/internal/Headers.js.map +1 -0
- package/dist/proxy/internal/Route.d.ts +14 -0
- package/dist/proxy/internal/Route.d.ts.map +1 -0
- package/dist/proxy/internal/Route.js +47 -0
- package/dist/proxy/internal/Route.js.map +1 -0
- package/dist/proxy/services/anthropic.d.ts +29 -0
- package/dist/proxy/services/anthropic.d.ts.map +1 -0
- package/dist/proxy/services/anthropic.js +30 -0
- package/dist/proxy/services/anthropic.js.map +1 -0
- package/dist/proxy/services/openai.d.ts +29 -0
- package/dist/proxy/services/openai.d.ts.map +1 -0
- package/dist/proxy/services/openai.js +30 -0
- package/dist/proxy/services/openai.js.map +1 -0
- package/dist/proxy/services/stripe.d.ts +29 -0
- package/dist/proxy/services/stripe.d.ts.map +1 -0
- package/dist/proxy/services/stripe.js +30 -0
- package/dist/proxy/services/stripe.js.map +1 -0
- package/dist/server/Methods.d.ts +3 -0
- package/dist/server/Methods.d.ts.map +1 -0
- package/dist/server/Methods.js +3 -0
- package/dist/server/Methods.js.map +1 -0
- package/dist/server/Mppx.d.ts +116 -0
- package/dist/server/Mppx.d.ts.map +1 -0
- package/dist/server/Mppx.js +207 -0
- package/dist/server/Mppx.js.map +1 -0
- package/dist/server/NodeListener.d.ts +3 -0
- package/dist/server/NodeListener.d.ts.map +1 -0
- package/dist/server/NodeListener.js +3 -0
- package/dist/server/NodeListener.js.map +1 -0
- package/dist/server/Request.d.ts +24 -0
- package/dist/server/Request.d.ts.map +1 -0
- package/dist/server/Request.js +26 -0
- package/dist/server/Request.js.map +1 -0
- package/dist/server/Response.d.ts +10 -0
- package/dist/server/Response.d.ts.map +1 -0
- package/dist/server/Response.js +15 -0
- package/dist/server/Response.js.map +1 -0
- package/dist/server/Transport.d.ts +93 -0
- package/dist/server/Transport.d.ts.map +1 -0
- package/dist/server/Transport.js +132 -0
- package/dist/server/Transport.js.map +1 -0
- package/dist/server/index.d.ts +9 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +9 -0
- package/dist/server/index.js.map +1 -0
- package/dist/stripe/Intents.d.ts +54 -0
- package/dist/stripe/Intents.d.ts.map +1 -0
- package/dist/stripe/Intents.js +27 -0
- package/dist/stripe/Intents.js.map +1 -0
- package/dist/stripe/client/Charge.d.ts +114 -0
- package/dist/stripe/client/Charge.d.ts.map +1 -0
- package/dist/stripe/client/Charge.js +77 -0
- package/dist/stripe/client/Charge.js.map +1 -0
- package/dist/stripe/client/MethodIntents.d.ts +80 -0
- package/dist/stripe/client/MethodIntents.d.ts.map +1 -0
- package/dist/stripe/client/MethodIntents.js +34 -0
- package/dist/stripe/client/MethodIntents.js.map +1 -0
- package/dist/stripe/client/index.d.ts +3 -0
- package/dist/stripe/client/index.d.ts.map +1 -0
- package/dist/stripe/client/index.js +3 -0
- package/dist/stripe/client/index.js.map +1 -0
- package/dist/stripe/index.d.ts +2 -0
- package/dist/stripe/index.d.ts.map +1 -0
- package/dist/stripe/index.js +2 -0
- package/dist/stripe/index.js.map +1 -0
- package/dist/stripe/server/Charge.d.ts +74 -0
- package/dist/stripe/server/Charge.d.ts.map +1 -0
- package/dist/stripe/server/Charge.js +79 -0
- package/dist/stripe/server/Charge.js.map +1 -0
- package/dist/stripe/server/MethodIntents.d.ts +65 -0
- package/dist/stripe/server/MethodIntents.d.ts.map +1 -0
- package/dist/stripe/server/MethodIntents.js +21 -0
- package/dist/stripe/server/MethodIntents.js.map +1 -0
- package/dist/stripe/server/index.d.ts +3 -0
- package/dist/stripe/server/index.d.ts.map +1 -0
- package/dist/stripe/server/index.js +3 -0
- package/dist/stripe/server/index.js.map +1 -0
- package/dist/tempo/Attribution.d.ts +101 -0
- package/dist/tempo/Attribution.d.ts.map +1 -0
- package/dist/tempo/Attribution.js +124 -0
- package/dist/tempo/Attribution.js.map +1 -0
- package/dist/tempo/Intents.d.ts +132 -0
- package/dist/tempo/Intents.d.ts.map +1 -0
- package/dist/tempo/Intents.js +81 -0
- package/dist/tempo/Intents.js.map +1 -0
- package/dist/tempo/client/ChannelOps.d.ts +54 -0
- package/dist/tempo/client/ChannelOps.d.ts.map +1 -0
- package/dist/tempo/client/ChannelOps.js +138 -0
- package/dist/tempo/client/ChannelOps.js.map +1 -0
- package/dist/tempo/client/Charge.d.ts +76 -0
- package/dist/tempo/client/Charge.d.ts.map +1 -0
- package/dist/tempo/client/Charge.js +69 -0
- package/dist/tempo/client/Charge.js.map +1 -0
- package/dist/tempo/client/MethodIntents.d.ts +157 -0
- package/dist/tempo/client/MethodIntents.d.ts.map +1 -0
- package/dist/tempo/client/MethodIntents.js +25 -0
- package/dist/tempo/client/MethodIntents.js.map +1 -0
- package/dist/tempo/client/Session.d.ts +159 -0
- package/dist/tempo/client/Session.d.ts.map +1 -0
- package/dist/tempo/client/Session.js +263 -0
- package/dist/tempo/client/Session.js.map +1 -0
- package/dist/tempo/client/SessionManager.d.ts +62 -0
- package/dist/tempo/client/SessionManager.d.ts.map +1 -0
- package/dist/tempo/client/SessionManager.js +196 -0
- package/dist/tempo/client/SessionManager.js.map +1 -0
- package/dist/tempo/client/index.d.ts +6 -0
- package/dist/tempo/client/index.d.ts.map +1 -0
- package/dist/tempo/client/index.js +5 -0
- package/dist/tempo/client/index.js.map +1 -0
- package/dist/tempo/index.d.ts +3 -0
- package/dist/tempo/index.d.ts.map +1 -0
- package/dist/tempo/index.js +3 -0
- package/dist/tempo/index.js.map +1 -0
- package/dist/tempo/internal/account.d.ts +32 -0
- package/dist/tempo/internal/account.d.ts.map +1 -0
- package/dist/tempo/internal/account.js +33 -0
- package/dist/tempo/internal/account.js.map +1 -0
- package/dist/tempo/internal/defaults.d.ts +18 -0
- package/dist/tempo/internal/defaults.d.ts.map +1 -0
- package/dist/tempo/internal/defaults.js +18 -0
- package/dist/tempo/internal/defaults.js.map +1 -0
- package/dist/tempo/internal/types.d.ts +11 -0
- package/dist/tempo/internal/types.d.ts.map +1 -0
- package/dist/tempo/internal/types.js +2 -0
- package/dist/tempo/internal/types.js.map +1 -0
- package/dist/tempo/server/Charge.d.ts +77 -0
- package/dist/tempo/server/Charge.d.ts.map +1 -0
- package/dist/tempo/server/Charge.js +228 -0
- package/dist/tempo/server/Charge.js.map +1 -0
- package/dist/tempo/server/MethodIntents.d.ts +140 -0
- package/dist/tempo/server/MethodIntents.d.ts.map +1 -0
- package/dist/tempo/server/MethodIntents.js +26 -0
- package/dist/tempo/server/MethodIntents.js.map +1 -0
- package/dist/tempo/server/Session.d.ts +148 -0
- package/dist/tempo/server/Session.d.ts.map +1 -0
- package/dist/tempo/server/Session.js +529 -0
- package/dist/tempo/server/Session.js.map +1 -0
- package/dist/tempo/server/internal/transport.d.ts +47 -0
- package/dist/tempo/server/internal/transport.d.ts.map +1 -0
- package/dist/tempo/server/internal/transport.js +118 -0
- package/dist/tempo/server/internal/transport.js.map +1 -0
- package/dist/tempo/stream/Chain.d.ts +52 -0
- package/dist/tempo/stream/Chain.d.ts.map +1 -0
- package/dist/tempo/stream/Chain.js +215 -0
- package/dist/tempo/stream/Chain.js.map +1 -0
- package/dist/tempo/stream/Channel.d.ts +26 -0
- package/dist/tempo/stream/Channel.d.ts.map +1 -0
- package/dist/tempo/stream/Channel.js +27 -0
- package/dist/tempo/stream/Channel.js.map +1 -0
- package/dist/tempo/stream/ChannelStore.d.ts +103 -0
- package/dist/tempo/stream/ChannelStore.d.ts.map +1 -0
- package/dist/tempo/stream/ChannelStore.js +100 -0
- package/dist/tempo/stream/ChannelStore.js.map +1 -0
- package/dist/tempo/stream/Receipt.d.ts +22 -0
- package/dist/tempo/stream/Receipt.d.ts.map +1 -0
- package/dist/tempo/stream/Receipt.js +34 -0
- package/dist/tempo/stream/Receipt.js.map +1 -0
- package/dist/tempo/stream/Sse.d.ts +134 -0
- package/dist/tempo/stream/Sse.d.ts.map +1 -0
- package/dist/tempo/stream/Sse.js +288 -0
- package/dist/tempo/stream/Sse.js.map +1 -0
- package/dist/tempo/stream/Types.d.ts +78 -0
- package/dist/tempo/stream/Types.d.ts.map +1 -0
- package/dist/tempo/stream/Types.js +2 -0
- package/dist/tempo/stream/Types.js.map +1 -0
- package/dist/tempo/stream/Voucher.d.ts +20 -0
- package/dist/tempo/stream/Voucher.d.ts.map +1 -0
- package/dist/tempo/stream/Voucher.js +98 -0
- package/dist/tempo/stream/Voucher.js.map +1 -0
- package/dist/tempo/stream/escrow.abi.d.ts +598 -0
- package/dist/tempo/stream/escrow.abi.d.ts.map +1 -0
- package/dist/tempo/stream/escrow.abi.js +760 -0
- package/dist/tempo/stream/escrow.abi.js.map +1 -0
- package/dist/tempo/stream/index.d.ts +8 -0
- package/dist/tempo/stream/index.d.ts.map +1 -0
- package/dist/tempo/stream/index.js +8 -0
- package/dist/tempo/stream/index.js.map +1 -0
- package/dist/viem/Account.d.ts +12 -0
- package/dist/viem/Account.d.ts.map +1 -0
- package/dist/viem/Account.js +14 -0
- package/dist/viem/Account.js.map +1 -0
- package/dist/viem/Client.d.ts +21 -0
- package/dist/viem/Client.d.ts.map +1 -0
- package/dist/viem/Client.js +19 -0
- package/dist/viem/Client.js.map +1 -0
- package/dist/zod.d.ts +17 -0
- package/dist/zod.d.ts.map +1 -0
- package/dist/zod.js +35 -0
- package/dist/zod.js.map +1 -0
- package/package.json +117 -4
- package/src/BodyDigest.test.ts +43 -0
- package/src/BodyDigest.ts +53 -0
- package/src/Challenge.test-d.ts +81 -0
- package/src/Challenge.test.ts +414 -0
- package/src/Challenge.ts +429 -0
- package/src/Credential.test.ts +227 -0
- package/src/Credential.ts +154 -0
- package/src/Errors.test.ts +402 -0
- package/src/Errors.ts +348 -0
- package/src/Expires.ts +34 -0
- package/src/Intent.test.ts +180 -0
- package/src/Intent.ts +109 -0
- package/src/Mcp.ts +81 -0
- package/src/MethodIntent.test.ts +303 -0
- package/src/MethodIntent.ts +388 -0
- package/src/PaymentRequest.test.ts +152 -0
- package/src/PaymentRequest.ts +107 -0
- package/src/Receipt.test.ts +98 -0
- package/src/Receipt.ts +129 -0
- package/src/Store.ts +84 -0
- package/src/cli.test.ts +542 -0
- package/src/cli.ts +1319 -0
- package/src/client/Methods.ts +3 -0
- package/src/client/Mppx.test-d.ts +90 -0
- package/src/client/Mppx.test.ts +468 -0
- package/src/client/Mppx.ts +149 -0
- package/src/client/Transport.test.ts +283 -0
- package/src/client/Transport.ts +115 -0
- package/src/client/index.ts +4 -0
- package/src/client/internal/Fetch.test-d.ts +57 -0
- package/src/client/internal/Fetch.test.ts +281 -0
- package/src/client/internal/Fetch.ts +157 -0
- package/src/env.d.ts +11 -0
- package/src/index.ts +12 -0
- package/src/internal/types.ts +403 -0
- package/src/mcp-sdk/client/McpClient.test-d.ts +109 -0
- package/src/mcp-sdk/client/McpClient.test.ts +219 -0
- package/src/mcp-sdk/client/McpClient.ts +187 -0
- package/src/mcp-sdk/client/index.ts +2 -0
- package/src/mcp-sdk/server/Transport.ts +94 -0
- package/src/mcp-sdk/server/index.ts +1 -0
- package/src/middlewares/elysia.ts +66 -0
- package/src/middlewares/express.test.ts +155 -0
- package/src/middlewares/express.ts +82 -0
- package/src/middlewares/hono.test.ts +148 -0
- package/src/middlewares/hono.ts +62 -0
- package/src/middlewares/internal/mppx.ts +30 -0
- package/src/middlewares/nextjs.test.ts +164 -0
- package/src/middlewares/nextjs.ts +66 -0
- package/src/proxy/Proxy.test.ts +472 -0
- package/src/proxy/Proxy.ts +175 -0
- package/src/proxy/Service.test.ts +125 -0
- package/src/proxy/Service.ts +227 -0
- package/src/proxy/index.ts +6 -0
- package/src/proxy/internal/Headers.test.ts +100 -0
- package/src/proxy/internal/Headers.ts +40 -0
- package/src/proxy/internal/Route.test.ts +143 -0
- package/src/proxy/internal/Route.ts +54 -0
- package/src/proxy/services/anthropic.ts +45 -0
- package/src/proxy/services/openai.test.ts +97 -0
- package/src/proxy/services/openai.ts +48 -0
- package/src/proxy/services/stripe.ts +49 -0
- package/src/server/Methods.ts +2 -0
- package/src/server/Mppx.test-d.ts +343 -0
- package/src/server/Mppx.test.ts +342 -0
- package/src/server/Mppx.ts +378 -0
- package/src/server/NodeListener.test.ts +188 -0
- package/src/server/NodeListener.ts +3 -0
- package/src/server/Request.test.ts +102 -0
- package/src/server/Request.ts +33 -0
- package/src/server/Response.test.ts +31 -0
- package/src/server/Response.ts +27 -0
- package/src/server/Transport.test.ts +294 -0
- package/src/server/Transport.ts +222 -0
- package/src/server/index.ts +8 -0
- package/src/stripe/Charge.integration.test.ts +326 -0
- package/src/stripe/Intents.test.ts +52 -0
- package/src/stripe/Intents.ts +27 -0
- package/src/stripe/client/Charge.ts +119 -0
- package/src/stripe/client/MethodIntents.ts +37 -0
- package/src/stripe/client/index.ts +2 -0
- package/src/stripe/index.ts +1 -0
- package/src/stripe/server/Charge.ts +121 -0
- package/src/stripe/server/MethodIntents.ts +24 -0
- package/src/stripe/server/index.ts +2 -0
- package/src/tempo/Attribution.test.ts +187 -0
- package/src/tempo/Attribution.ts +156 -0
- package/src/tempo/Intents.test.ts +84 -0
- package/src/tempo/Intents.ts +93 -0
- package/src/tempo/client/ChannelOps.ts +233 -0
- package/src/tempo/client/Charge.ts +84 -0
- package/src/tempo/client/MethodIntents.ts +28 -0
- package/src/tempo/client/Session.ts +369 -0
- package/src/tempo/client/SessionManager.test.ts +223 -0
- package/src/tempo/client/SessionManager.ts +270 -0
- package/src/tempo/client/index.ts +5 -0
- package/src/tempo/index.ts +2 -0
- package/src/tempo/internal/account.ts +47 -0
- package/src/tempo/internal/defaults.ts +20 -0
- package/src/tempo/internal/types.ts +8 -0
- package/src/tempo/server/Charge.test.ts +847 -0
- package/src/tempo/server/Charge.ts +309 -0
- package/src/tempo/server/MethodIntents.ts +29 -0
- package/src/tempo/server/Session.test.ts +1349 -0
- package/src/tempo/server/Session.ts +773 -0
- package/src/tempo/server/Sse.test.ts +289 -0
- package/src/tempo/server/index.ts +5 -0
- package/src/tempo/server/internal/transport.ts +153 -0
- package/src/tempo/stream/Chain.ts +333 -0
- package/src/tempo/stream/Channel.ts +50 -0
- package/src/tempo/stream/ChannelStore.test.ts +473 -0
- package/src/tempo/stream/ChannelStore.ts +202 -0
- package/src/tempo/stream/Receipt.test.ts +84 -0
- package/src/tempo/stream/Receipt.ts +45 -0
- package/src/tempo/stream/Sse.test.ts +401 -0
- package/src/tempo/stream/Sse.ts +375 -0
- package/src/tempo/stream/Types.ts +86 -0
- package/src/tempo/stream/Voucher.test.ts +134 -0
- package/src/tempo/stream/Voucher.ts +123 -0
- package/src/tempo/stream/escrow.abi.ts +759 -0
- package/src/tempo/stream/index.ts +7 -0
- package/src/tsconfig.json +10 -0
- package/src/viem/Account.test.ts +71 -0
- package/src/viem/Account.ts +30 -0
- package/src/viem/Client.test.ts +58 -0
- package/src/viem/Client.ts +33 -0
- package/src/zod.ts +47 -0
package/src/cli.test.ts
ADDED
|
@@ -0,0 +1,542 @@
|
|
|
1
|
+
import { spawn, spawnSync } from 'node:child_process'
|
|
2
|
+
import * as path from 'node:path'
|
|
3
|
+
import { parseUnits } from 'viem'
|
|
4
|
+
import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts'
|
|
5
|
+
import { Addresses } from 'viem/tempo'
|
|
6
|
+
import { afterAll, describe, expect, test } from 'vitest'
|
|
7
|
+
import * as Http from '~test/Http.js'
|
|
8
|
+
import { rpcUrl } from '~test/tempo/prool.js'
|
|
9
|
+
import { deployEscrow } from '~test/tempo/stream.js'
|
|
10
|
+
import { accounts, asset, client, fundAccount } from '~test/tempo/viem.js'
|
|
11
|
+
import * as Store from './Store.js'
|
|
12
|
+
import * as Mppx_server from './server/Mppx.js'
|
|
13
|
+
import { toNodeListener } from './server/Mppx.js'
|
|
14
|
+
import { tempo } from './tempo/server/MethodIntents.js'
|
|
15
|
+
|
|
16
|
+
const cliPath = path.resolve(import.meta.dirname, 'cli.ts')
|
|
17
|
+
const cwd = path.resolve(import.meta.dirname, '..')
|
|
18
|
+
const testPrivateKey = generatePrivateKey()
|
|
19
|
+
const testAccount = privateKeyToAccount(testPrivateKey)
|
|
20
|
+
const env = { ...process.env, NODE_NO_WARNINGS: '1', MPPX_PRIVATE_KEY: testPrivateKey }
|
|
21
|
+
|
|
22
|
+
function run(args: string[], options?: { input?: string }): string {
|
|
23
|
+
const result = runRaw(args, options)
|
|
24
|
+
if (result.status !== 0) {
|
|
25
|
+
const msg = result.stderr?.trim() || result.stdout?.trim() || `exit code ${result.status}`
|
|
26
|
+
throw new Error(msg)
|
|
27
|
+
}
|
|
28
|
+
return result.stdout
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function runRaw(
|
|
32
|
+
args: string[],
|
|
33
|
+
options?: { input?: string; env?: NodeJS.ProcessEnv },
|
|
34
|
+
): { stdout: string; stderr: string; status: number | null } {
|
|
35
|
+
const result = spawnSync('node', ['--import', 'tsx', cliPath, ...args], {
|
|
36
|
+
encoding: 'utf8',
|
|
37
|
+
cwd,
|
|
38
|
+
timeout: 60_000,
|
|
39
|
+
...(options?.input !== undefined && { input: options.input }),
|
|
40
|
+
env: options?.env ?? env,
|
|
41
|
+
})
|
|
42
|
+
return { stdout: result.stdout ?? '', stderr: result.stderr ?? '', status: result.status }
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function runAsync(
|
|
46
|
+
args: string[],
|
|
47
|
+
options?: { input?: string },
|
|
48
|
+
): Promise<{ stdout: string; stderr: string }> {
|
|
49
|
+
return new Promise((resolve, reject) => {
|
|
50
|
+
const child = spawn('node', ['--import', 'tsx', cliPath, ...args], {
|
|
51
|
+
cwd,
|
|
52
|
+
env,
|
|
53
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
let stdout = ''
|
|
57
|
+
let stderr = ''
|
|
58
|
+
child.stdout.on('data', (data: Buffer) => {
|
|
59
|
+
stdout += data.toString()
|
|
60
|
+
})
|
|
61
|
+
child.stderr.on('data', (data: Buffer) => {
|
|
62
|
+
stderr += data.toString()
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
if (options?.input !== undefined) {
|
|
66
|
+
child.stdin.write(options.input)
|
|
67
|
+
child.stdin.end()
|
|
68
|
+
} else {
|
|
69
|
+
child.stdin.end()
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const timer = setTimeout(() => {
|
|
73
|
+
child.kill()
|
|
74
|
+
reject(new Error(`Timed out.\nstdout: ${stdout}\nstderr: ${stderr}`))
|
|
75
|
+
}, 60_000)
|
|
76
|
+
|
|
77
|
+
child.on('close', (code) => {
|
|
78
|
+
clearTimeout(timer)
|
|
79
|
+
if (code !== 0) reject(new Error(stderr.trim() || `exit code ${code}`))
|
|
80
|
+
else resolve({ stdout, stderr })
|
|
81
|
+
})
|
|
82
|
+
child.on('error', (err) => {
|
|
83
|
+
clearTimeout(timer)
|
|
84
|
+
reject(err)
|
|
85
|
+
})
|
|
86
|
+
})
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
describe('basic charge (examples/basic)', () => {
|
|
90
|
+
test('happy path: makes payment and receives response', { timeout: 120_000 }, async () => {
|
|
91
|
+
const { Actions } = await import('viem/tempo')
|
|
92
|
+
await Actions.token.transferSync(client, {
|
|
93
|
+
account: accounts[0],
|
|
94
|
+
chain: client.chain,
|
|
95
|
+
token: asset,
|
|
96
|
+
to: testAccount.address,
|
|
97
|
+
amount: parseUnits('100', 6),
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
const server = Mppx_server.create({
|
|
101
|
+
methods: [tempo.charge({ getClient: () => client })],
|
|
102
|
+
realm: 'cli-test-basic',
|
|
103
|
+
secretKey: 'cli-test-secret',
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
const httpServer = await Http.createServer(async (req, res) => {
|
|
107
|
+
const result = await toNodeListener(
|
|
108
|
+
server.charge({
|
|
109
|
+
amount: '1',
|
|
110
|
+
currency: asset,
|
|
111
|
+
expires: new Date(Date.now() + 60_000).toISOString(),
|
|
112
|
+
recipient: accounts[0].address,
|
|
113
|
+
}),
|
|
114
|
+
)(req, res)
|
|
115
|
+
if (result.status === 402) return
|
|
116
|
+
res.end('paid')
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
try {
|
|
120
|
+
const { stdout } = await runAsync([httpServer.url, '--rpc-url', rpcUrl, '--yes', '-s'], {
|
|
121
|
+
input: '',
|
|
122
|
+
})
|
|
123
|
+
expect(stdout).toContain('paid')
|
|
124
|
+
} finally {
|
|
125
|
+
httpServer.close()
|
|
126
|
+
}
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
test('error: no account found', { timeout: 60_000 }, () => {
|
|
130
|
+
const result = spawnSync(
|
|
131
|
+
'node',
|
|
132
|
+
['--import', 'tsx', cliPath, 'http://localhost:1', '--account', 'nonexistent-account'],
|
|
133
|
+
{
|
|
134
|
+
encoding: 'utf8',
|
|
135
|
+
cwd,
|
|
136
|
+
timeout: 60_000,
|
|
137
|
+
env: { ...process.env, NODE_NO_WARNINGS: '1' },
|
|
138
|
+
},
|
|
139
|
+
)
|
|
140
|
+
expect(result.status).not.toBe(0)
|
|
141
|
+
expect(result.stdout).toContain('Account "nonexistent-account" not found')
|
|
142
|
+
})
|
|
143
|
+
})
|
|
144
|
+
|
|
145
|
+
describe('session multi-fetch (examples/session/multi-fetch)', () => {
|
|
146
|
+
test('happy path: stream payment and receives response', { timeout: 120_000 }, async () => {
|
|
147
|
+
await fundAccount({ address: testAccount.address, token: Addresses.pathUsd })
|
|
148
|
+
await fundAccount({ address: testAccount.address, token: asset })
|
|
149
|
+
|
|
150
|
+
const escrow = await deployEscrow()
|
|
151
|
+
const store = Store.memory()
|
|
152
|
+
const server = Mppx_server.create({
|
|
153
|
+
methods: [
|
|
154
|
+
tempo.session({
|
|
155
|
+
account: accounts[0],
|
|
156
|
+
store,
|
|
157
|
+
getClient: () => client,
|
|
158
|
+
currency: asset,
|
|
159
|
+
escrowContract: escrow,
|
|
160
|
+
chainId: client.chain.id,
|
|
161
|
+
feePayer: true,
|
|
162
|
+
}),
|
|
163
|
+
],
|
|
164
|
+
realm: 'cli-test-multifetch',
|
|
165
|
+
secretKey: 'cli-test-secret',
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
const httpServer = await Http.createServer(async (req, res) => {
|
|
169
|
+
const result = await toNodeListener(
|
|
170
|
+
server.session({
|
|
171
|
+
amount: '0.001',
|
|
172
|
+
recipient: accounts[0].address,
|
|
173
|
+
unitType: 'page',
|
|
174
|
+
}),
|
|
175
|
+
)(req, res)
|
|
176
|
+
if (result.status === 402) return
|
|
177
|
+
res.end('scraped-content')
|
|
178
|
+
})
|
|
179
|
+
|
|
180
|
+
try {
|
|
181
|
+
const { stdout } = await runAsync(
|
|
182
|
+
[httpServer.url, '--rpc-url', rpcUrl, '--yes', '-s', '--deposit', '10'],
|
|
183
|
+
{ input: '' },
|
|
184
|
+
)
|
|
185
|
+
expect(stdout).toContain('scraped-content')
|
|
186
|
+
} finally {
|
|
187
|
+
httpServer.close()
|
|
188
|
+
}
|
|
189
|
+
})
|
|
190
|
+
|
|
191
|
+
test(
|
|
192
|
+
'--channel reuse: second request reuses existing channel',
|
|
193
|
+
{ timeout: 120_000 },
|
|
194
|
+
async () => {
|
|
195
|
+
await fundAccount({ address: testAccount.address, token: Addresses.pathUsd })
|
|
196
|
+
await fundAccount({ address: testAccount.address, token: asset })
|
|
197
|
+
|
|
198
|
+
const escrow = await deployEscrow()
|
|
199
|
+
const store = Store.memory()
|
|
200
|
+
const server = Mppx_server.create({
|
|
201
|
+
methods: [
|
|
202
|
+
tempo.session({
|
|
203
|
+
account: accounts[0],
|
|
204
|
+
store,
|
|
205
|
+
getClient: () => client,
|
|
206
|
+
currency: asset,
|
|
207
|
+
escrowContract: escrow,
|
|
208
|
+
chainId: client.chain.id,
|
|
209
|
+
feePayer: true,
|
|
210
|
+
}),
|
|
211
|
+
],
|
|
212
|
+
realm: 'cli-test-channel-reuse',
|
|
213
|
+
secretKey: 'cli-test-secret',
|
|
214
|
+
})
|
|
215
|
+
|
|
216
|
+
const httpServer = await Http.createServer(async (req, res) => {
|
|
217
|
+
const result = await toNodeListener(
|
|
218
|
+
server.session({
|
|
219
|
+
amount: '0.001',
|
|
220
|
+
recipient: accounts[0].address,
|
|
221
|
+
unitType: 'page',
|
|
222
|
+
}),
|
|
223
|
+
)(req, res)
|
|
224
|
+
if (result.status === 402) return
|
|
225
|
+
res.end('scraped-content')
|
|
226
|
+
})
|
|
227
|
+
|
|
228
|
+
try {
|
|
229
|
+
// First request: open a channel, answer "y" to proceed, "n" to close channel
|
|
230
|
+
const first = await runAsync([httpServer.url, '--rpc-url', rpcUrl, '--deposit', '10'], {
|
|
231
|
+
input: 'y\nn\n',
|
|
232
|
+
})
|
|
233
|
+
expect(first.stdout).toContain('scraped-content')
|
|
234
|
+
|
|
235
|
+
// Extract channel ID from stderr (logged as "Channel opened 0x...")
|
|
236
|
+
const match = first.stderr.match(/Channel opened (0x[0-9a-fA-F]+)/)
|
|
237
|
+
expect(match).toBeTruthy()
|
|
238
|
+
const channelId = match![1]!
|
|
239
|
+
|
|
240
|
+
// Second request: reuse the channel via --channel
|
|
241
|
+
const second = await runAsync(
|
|
242
|
+
[
|
|
243
|
+
httpServer.url,
|
|
244
|
+
'--rpc-url',
|
|
245
|
+
rpcUrl,
|
|
246
|
+
'--yes',
|
|
247
|
+
'-s',
|
|
248
|
+
'--channel',
|
|
249
|
+
channelId,
|
|
250
|
+
'--deposit',
|
|
251
|
+
'10',
|
|
252
|
+
],
|
|
253
|
+
{ input: '' },
|
|
254
|
+
)
|
|
255
|
+
expect(second.stdout).toContain('scraped-content')
|
|
256
|
+
} finally {
|
|
257
|
+
httpServer.close()
|
|
258
|
+
}
|
|
259
|
+
},
|
|
260
|
+
)
|
|
261
|
+
|
|
262
|
+
test('error: --fail exits on server error', { timeout: 60_000 }, async () => {
|
|
263
|
+
const httpServer = await Http.createServer(async (_req, res) => {
|
|
264
|
+
res.writeHead(500)
|
|
265
|
+
res.end('Internal Server Error')
|
|
266
|
+
})
|
|
267
|
+
|
|
268
|
+
try {
|
|
269
|
+
await expect(
|
|
270
|
+
runAsync([httpServer.url, '--rpc-url', rpcUrl, '--fail'], { input: '' }),
|
|
271
|
+
).rejects.toThrow()
|
|
272
|
+
} finally {
|
|
273
|
+
httpServer.close()
|
|
274
|
+
}
|
|
275
|
+
})
|
|
276
|
+
})
|
|
277
|
+
|
|
278
|
+
describe('session sse (examples/session/sse)', () => {
|
|
279
|
+
test('streams SSE tokens to stdout', { timeout: 120_000 }, async () => {
|
|
280
|
+
await fundAccount({ address: testAccount.address, token: Addresses.pathUsd })
|
|
281
|
+
await fundAccount({ address: testAccount.address, token: asset })
|
|
282
|
+
|
|
283
|
+
const escrow = await deployEscrow()
|
|
284
|
+
const store = Store.memory()
|
|
285
|
+
const server = Mppx_server.create({
|
|
286
|
+
methods: [
|
|
287
|
+
tempo.session({
|
|
288
|
+
account: accounts[0],
|
|
289
|
+
store,
|
|
290
|
+
getClient: () => client,
|
|
291
|
+
currency: asset,
|
|
292
|
+
escrowContract: escrow,
|
|
293
|
+
chainId: client.chain.id,
|
|
294
|
+
feePayer: true,
|
|
295
|
+
}),
|
|
296
|
+
],
|
|
297
|
+
realm: 'cli-test-sse',
|
|
298
|
+
secretKey: 'cli-test-secret',
|
|
299
|
+
})
|
|
300
|
+
|
|
301
|
+
const httpServer = await Http.createServer(async (req, res) => {
|
|
302
|
+
const result = await toNodeListener(
|
|
303
|
+
server.session({
|
|
304
|
+
amount: '0.001',
|
|
305
|
+
recipient: accounts[0].address,
|
|
306
|
+
unitType: 'token',
|
|
307
|
+
}),
|
|
308
|
+
)(req, res)
|
|
309
|
+
if (result.status === 402) return
|
|
310
|
+
|
|
311
|
+
res.writeHead(200, {
|
|
312
|
+
'Content-Type': 'text/event-stream',
|
|
313
|
+
'Cache-Control': 'no-cache',
|
|
314
|
+
Connection: 'keep-alive',
|
|
315
|
+
})
|
|
316
|
+
const tokens = ['Hello', ' world', '!']
|
|
317
|
+
for (const token of tokens) {
|
|
318
|
+
res.write(`data: ${JSON.stringify({ token })}\n\n`)
|
|
319
|
+
}
|
|
320
|
+
res.write('data: [DONE]\n\n')
|
|
321
|
+
res.end()
|
|
322
|
+
})
|
|
323
|
+
|
|
324
|
+
try {
|
|
325
|
+
const { stdout } = await runAsync(
|
|
326
|
+
[httpServer.url, '--rpc-url', rpcUrl, '--yes', '--deposit', '10'],
|
|
327
|
+
{ input: '' },
|
|
328
|
+
)
|
|
329
|
+
expect(stdout.trim()).toBe('Hello world!')
|
|
330
|
+
} finally {
|
|
331
|
+
httpServer.close()
|
|
332
|
+
}
|
|
333
|
+
})
|
|
334
|
+
|
|
335
|
+
test('error: server 500 with --fail exits non-zero', { timeout: 60_000 }, async () => {
|
|
336
|
+
const httpServer = await Http.createServer(async (_req, res) => {
|
|
337
|
+
res.writeHead(500)
|
|
338
|
+
res.end('Internal Server Error')
|
|
339
|
+
})
|
|
340
|
+
try {
|
|
341
|
+
await expect(
|
|
342
|
+
runAsync([httpServer.url, '--rpc-url', rpcUrl, '--fail'], { input: '' }),
|
|
343
|
+
).rejects.toThrow()
|
|
344
|
+
} finally {
|
|
345
|
+
httpServer.close()
|
|
346
|
+
}
|
|
347
|
+
})
|
|
348
|
+
})
|
|
349
|
+
|
|
350
|
+
// ---------------------------------------------------------------------------
|
|
351
|
+
// account [action]
|
|
352
|
+
// TODO: investigate account tests timing out in CI (secret-tool/gnome-keyring hangs)
|
|
353
|
+
// ---------------------------------------------------------------------------
|
|
354
|
+
describe.skipIf(!!process.env.CI)('account', () => {
|
|
355
|
+
// Env without MPPX_PRIVATE_KEY so account commands use the keychain
|
|
356
|
+
const accountEnv = { ...process.env, NODE_NO_WARNINGS: '1' }
|
|
357
|
+
const prefix = `__mppx_test_${Date.now()}`
|
|
358
|
+
const createdAccounts: string[] = []
|
|
359
|
+
|
|
360
|
+
function accountRun(args: string[], options?: { input?: string }) {
|
|
361
|
+
return runRaw(args, { ...options, env: accountEnv })
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
function createAccount(name: string) {
|
|
365
|
+
const result = accountRun(['account', 'create', '--account', name], { input: '' })
|
|
366
|
+
if (result.status === 0) createdAccounts.push(name)
|
|
367
|
+
return result
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
function deleteAccount(name: string) {
|
|
371
|
+
return accountRun(['account', 'delete', '--account', name, '--yes'], { input: '' })
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
afterAll(() => {
|
|
375
|
+
for (const name of createdAccounts) {
|
|
376
|
+
deleteAccount(name)
|
|
377
|
+
}
|
|
378
|
+
})
|
|
379
|
+
|
|
380
|
+
// --- account create ---
|
|
381
|
+
|
|
382
|
+
test('create: creates a new account and prints address', () => {
|
|
383
|
+
const name = `${prefix}_create`
|
|
384
|
+
const result = createAccount(name)
|
|
385
|
+
expect(result.status).toBe(0)
|
|
386
|
+
expect(result.stdout).toContain(`Account "${name}" saved to keychain.`)
|
|
387
|
+
expect(result.stdout).toContain('Address 0x')
|
|
388
|
+
})
|
|
389
|
+
|
|
390
|
+
test('create: duplicate name exits with message', () => {
|
|
391
|
+
const name = `${prefix}_dup`
|
|
392
|
+
createAccount(name)
|
|
393
|
+
// Second create with same name (non-interactive, stdin closed) should not succeed
|
|
394
|
+
const result = accountRun(['account', 'create', '--account', name], { input: '' })
|
|
395
|
+
// The CLI prompts for a different name; with empty stdin it exits
|
|
396
|
+
expect(result.stdout).not.toContain('saved to keychain')
|
|
397
|
+
})
|
|
398
|
+
|
|
399
|
+
// --- account view ---
|
|
400
|
+
|
|
401
|
+
test('view: shows address for existing account', () => {
|
|
402
|
+
const name = `${prefix}_view`
|
|
403
|
+
createAccount(name)
|
|
404
|
+
const result = accountRun(['account', 'view', '--account', name])
|
|
405
|
+
expect(result.status).toBe(0)
|
|
406
|
+
expect(result.stdout).toContain('Address')
|
|
407
|
+
expect(result.stdout).toMatch(/0x[0-9a-fA-F]{40}/)
|
|
408
|
+
})
|
|
409
|
+
|
|
410
|
+
test('view: missing account exits non-zero', () => {
|
|
411
|
+
const result = accountRun(['account', 'view', '--account', `${prefix}_nonexistent`])
|
|
412
|
+
expect(result.status).not.toBe(0)
|
|
413
|
+
expect(result.stdout).toContain('not found')
|
|
414
|
+
})
|
|
415
|
+
|
|
416
|
+
// --- account list ---
|
|
417
|
+
|
|
418
|
+
test('list: includes created accounts', () => {
|
|
419
|
+
const name = `${prefix}_list`
|
|
420
|
+
createAccount(name)
|
|
421
|
+
const result = accountRun(['account', 'list'])
|
|
422
|
+
expect(result.status).toBe(0)
|
|
423
|
+
expect(result.stdout).toContain(name)
|
|
424
|
+
})
|
|
425
|
+
|
|
426
|
+
// --- account default ---
|
|
427
|
+
|
|
428
|
+
test('default: sets default account', () => {
|
|
429
|
+
const name = `${prefix}_default`
|
|
430
|
+
createAccount(name)
|
|
431
|
+
const result = accountRun(['account', 'default', '--account', name])
|
|
432
|
+
expect(result.status).toBe(0)
|
|
433
|
+
expect(result.stdout).toContain(`Default account set to "${name}"`)
|
|
434
|
+
})
|
|
435
|
+
|
|
436
|
+
test('default: missing --account flag exits non-zero', () => {
|
|
437
|
+
const result = accountRun(['account', 'default'])
|
|
438
|
+
expect(result.status).not.toBe(0)
|
|
439
|
+
})
|
|
440
|
+
|
|
441
|
+
test('default: nonexistent account exits non-zero', () => {
|
|
442
|
+
const result = accountRun(['account', 'default', '--account', `${prefix}_nope`])
|
|
443
|
+
expect(result.status).not.toBe(0)
|
|
444
|
+
expect(result.stdout).toContain('not found')
|
|
445
|
+
})
|
|
446
|
+
|
|
447
|
+
// --- account delete ---
|
|
448
|
+
|
|
449
|
+
test('delete: removes an existing account', () => {
|
|
450
|
+
const name = `${prefix}_del`
|
|
451
|
+
createAccount(name)
|
|
452
|
+
const result = deleteAccount(name)
|
|
453
|
+
expect(result.status).toBe(0)
|
|
454
|
+
expect(result.stdout).toContain(`Account "${name}" deleted`)
|
|
455
|
+
// Remove from cleanup list since already deleted
|
|
456
|
+
const idx = createdAccounts.indexOf(name)
|
|
457
|
+
if (idx !== -1) createdAccounts.splice(idx, 1)
|
|
458
|
+
|
|
459
|
+
// Verify it's gone
|
|
460
|
+
const view = accountRun(['account', 'view', '--account', name])
|
|
461
|
+
expect(view.status).not.toBe(0)
|
|
462
|
+
})
|
|
463
|
+
|
|
464
|
+
test('delete: missing --account flag exits non-zero', () => {
|
|
465
|
+
const result = accountRun(['account', 'delete', '--yes'])
|
|
466
|
+
expect(result.status).not.toBe(0)
|
|
467
|
+
})
|
|
468
|
+
|
|
469
|
+
test('delete: nonexistent account exits non-zero', () => {
|
|
470
|
+
const result = accountRun(['account', 'delete', '--account', `${prefix}_ghost`, '--yes'])
|
|
471
|
+
expect(result.status).not.toBe(0)
|
|
472
|
+
expect(result.stdout).toContain('not found')
|
|
473
|
+
})
|
|
474
|
+
|
|
475
|
+
// --- unknown action ---
|
|
476
|
+
|
|
477
|
+
test('unknown action exits non-zero', () => {
|
|
478
|
+
const result = accountRun(['account', 'bogus'])
|
|
479
|
+
expect(result.status).not.toBe(0)
|
|
480
|
+
expect(result.stderr).toContain('Unknown action: bogus')
|
|
481
|
+
})
|
|
482
|
+
|
|
483
|
+
// --- no action ---
|
|
484
|
+
|
|
485
|
+
test('no action prints help', () => {
|
|
486
|
+
const result = accountRun(['account'])
|
|
487
|
+
expect(result.status).toBe(0)
|
|
488
|
+
expect(result.stdout).toContain('account [action]')
|
|
489
|
+
})
|
|
490
|
+
})
|
|
491
|
+
|
|
492
|
+
test('mppx --help', () => {
|
|
493
|
+
const { version } = require('../package.json') as { version: string }
|
|
494
|
+
const stdout = run(['--help']).replace(`mppx/${version}`, 'mppx/x.y.z')
|
|
495
|
+
expect(stdout).toMatchInlineSnapshot(`
|
|
496
|
+
"mppx/x.y.z
|
|
497
|
+
|
|
498
|
+
Usage:
|
|
499
|
+
$ mppx [url]
|
|
500
|
+
|
|
501
|
+
Commands:
|
|
502
|
+
[url] Make HTTP request with automatic payment
|
|
503
|
+
account [action] Manage accounts (create, default, delete, fund, list, view)
|
|
504
|
+
|
|
505
|
+
For more info, run any command with the \`--help\` flag:
|
|
506
|
+
$ mppx --help
|
|
507
|
+
$ mppx account --help
|
|
508
|
+
|
|
509
|
+
Actions:
|
|
510
|
+
create Create new account
|
|
511
|
+
default Set default account
|
|
512
|
+
delete Delete account
|
|
513
|
+
fund Fund account with testnet tokens
|
|
514
|
+
list List all accounts
|
|
515
|
+
view View account address
|
|
516
|
+
|
|
517
|
+
Options:
|
|
518
|
+
-a, --account <name> Account name (env: MPPX_ACCOUNT)
|
|
519
|
+
-d, --data <data> Send request body (implies POST unless -X is set)
|
|
520
|
+
-f, --fail Fail silently on HTTP errors (exit 22)
|
|
521
|
+
-i, --include Include response headers in output
|
|
522
|
+
-k, --insecure Skip TLS certificate verification (true for localhost/.local)
|
|
523
|
+
-r, --rpc-url <url> RPC endpoint, defaults to public RPC for chain (env: MPPX_RPC_URL)
|
|
524
|
+
-s, --silent Silent mode (suppress progress and info)
|
|
525
|
+
-v, --verbose Show request/response headers
|
|
526
|
+
-A, --user-agent <ua> Set User-Agent header
|
|
527
|
+
-H, --header <header> Add header (repeatable)
|
|
528
|
+
-L, --location Follow redirects
|
|
529
|
+
-X, --method <method> HTTP method
|
|
530
|
+
--channel <id> Reuse existing stream channel ID
|
|
531
|
+
--deposit <amount> Deposit amount for stream payments (human-readable units)
|
|
532
|
+
--json <json> Send JSON body (sets Content-Type and Accept, implies POST)
|
|
533
|
+
--yes Skip confirmation prompts
|
|
534
|
+
-V, --version Display version number
|
|
535
|
+
-h, --help Display this message
|
|
536
|
+
|
|
537
|
+
Examples:
|
|
538
|
+
mppx example.com/content
|
|
539
|
+
mppx example.com/api --json '{"key":"value"}'
|
|
540
|
+
"
|
|
541
|
+
`)
|
|
542
|
+
})
|