mppx 0.0.1 → 0.1.1
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 +89 -0
- package/dist/client/Mppx.d.ts.map +1 -0
- package/dist/client/Mppx.js +69 -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 +87 -0
- package/dist/client/internal/Fetch.d.ts.map +1 -0
- package/dist/client/internal/Fetch.js +99 -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 +105 -0
- package/dist/stripe/client/Charge.d.ts.map +1 -0
- package/dist/stripe/client/Charge.js +74 -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 +201 -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 +119 -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 +165 -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 +315 -0
- package/src/client/internal/Fetch.ts +169 -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 +329 -0
- package/src/stripe/Intents.test.ts +52 -0
- package/src/stripe/Intents.ts +27 -0
- package/src/stripe/client/Charge.ts +115 -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 +276 -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 +154 -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
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { prepareTransactionRequest, signTransaction } from 'viem/actions';
|
|
2
|
+
import { tempo as tempo_chain } from 'viem/chains';
|
|
3
|
+
import { Actions } from 'viem/tempo';
|
|
4
|
+
import * as Credential from '../../Credential.js';
|
|
5
|
+
import * as MethodIntent from '../../MethodIntent.js';
|
|
6
|
+
import * as Account from '../../viem/Account.js';
|
|
7
|
+
import * as Client from '../../viem/Client.js';
|
|
8
|
+
import * as z from '../../zod.js';
|
|
9
|
+
import * as Attribution from '../Attribution.js';
|
|
10
|
+
import * as Intents from '../Intents.js';
|
|
11
|
+
import * as defaults from '../internal/defaults.js';
|
|
12
|
+
/**
|
|
13
|
+
* Creates a Tempo charge method intent for usage on the client.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { tempo } from 'mppx/client'
|
|
18
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
19
|
+
*
|
|
20
|
+
* const charge = tempo.charge({
|
|
21
|
+
* account: privateKeyToAccount('0x...'),
|
|
22
|
+
* })
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export function charge(parameters = {}) {
|
|
26
|
+
const { clientId } = parameters;
|
|
27
|
+
const getClient = Client.getResolver({
|
|
28
|
+
chain: tempo_chain,
|
|
29
|
+
getClient: parameters.getClient,
|
|
30
|
+
rpcUrl: defaults.rpcUrl,
|
|
31
|
+
});
|
|
32
|
+
const getAccount = Account.getResolver({ account: parameters.account });
|
|
33
|
+
return MethodIntent.toClient(Intents.charge, {
|
|
34
|
+
context: z.object({
|
|
35
|
+
account: z.optional(z.custom()),
|
|
36
|
+
}),
|
|
37
|
+
async createCredential({ challenge, context }) {
|
|
38
|
+
const chainId = challenge.request.methodDetails?.chainId;
|
|
39
|
+
const client = await getClient({ chainId });
|
|
40
|
+
const account = getAccount(client, context);
|
|
41
|
+
const { request } = challenge;
|
|
42
|
+
const { amount, currency, recipient, methodDetails } = request;
|
|
43
|
+
const memo = methodDetails?.memo
|
|
44
|
+
? methodDetails.memo
|
|
45
|
+
: Attribution.encode({ serverId: challenge.realm, clientId });
|
|
46
|
+
const prepared = await prepareTransactionRequest(client, {
|
|
47
|
+
account,
|
|
48
|
+
calls: [
|
|
49
|
+
Actions.token.transfer.call({
|
|
50
|
+
amount: BigInt(amount),
|
|
51
|
+
memo,
|
|
52
|
+
to: recipient,
|
|
53
|
+
token: currency,
|
|
54
|
+
}),
|
|
55
|
+
],
|
|
56
|
+
...(methodDetails?.feePayer && { feePayer: true }),
|
|
57
|
+
});
|
|
58
|
+
// FIXME: figure out gas estimation issue for fee payer tx
|
|
59
|
+
prepared.gas = prepared.gas + 5000n;
|
|
60
|
+
const signature = await signTransaction(client, prepared);
|
|
61
|
+
return Credential.serialize({
|
|
62
|
+
challenge,
|
|
63
|
+
payload: { signature, type: 'transaction' },
|
|
64
|
+
source: `did:pkh:eip155:${chainId}:${account.address}`,
|
|
65
|
+
});
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=Charge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Charge.js","sourceRoot":"","sources":["../../../src/tempo/client/Charge.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { charge as charge_ } from './Charge.js';
|
|
2
|
+
import { session as sessionIntent_ } from './Session.js';
|
|
3
|
+
import { sessionManager as session_ } from './SessionManager.js';
|
|
4
|
+
/**
|
|
5
|
+
* Creates both Tempo `charge` and `session` client method intents from shared parameters.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { Mppx, tempo } from 'mppx/client'
|
|
10
|
+
*
|
|
11
|
+
* const mppx = Mppx.create({
|
|
12
|
+
* methods: [tempo({ account })],
|
|
13
|
+
* })
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare function tempo(parameters?: tempo.Parameters): readonly [import("../../MethodIntent.js").Client<import("../../MethodIntent.js").MethodIntent<{
|
|
17
|
+
readonly name: "charge";
|
|
18
|
+
readonly schema: {
|
|
19
|
+
readonly request: import("zod/mini").ZodMiniPipe<import("zod/mini").ZodMiniObject<{
|
|
20
|
+
amount: import("zod/mini").ZodMiniString<string>;
|
|
21
|
+
currency: import("zod/mini").ZodMiniString<string>;
|
|
22
|
+
decimals: import("zod/mini").ZodMiniNumber<number>;
|
|
23
|
+
description: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniString<string>>;
|
|
24
|
+
expires: import("zod/mini").ZodMiniDefault<import("zod/mini").ZodMiniString<string>>;
|
|
25
|
+
externalId: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniString<string>>;
|
|
26
|
+
recipient: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniString<string>>;
|
|
27
|
+
}, import("zod/v4/core").$strip>, import("zod/mini").ZodMiniTransform<{
|
|
28
|
+
amount: string;
|
|
29
|
+
currency: string;
|
|
30
|
+
expires: string;
|
|
31
|
+
description?: string | undefined;
|
|
32
|
+
externalId?: string | undefined;
|
|
33
|
+
recipient?: string | undefined;
|
|
34
|
+
}, {
|
|
35
|
+
amount: string;
|
|
36
|
+
currency: string;
|
|
37
|
+
decimals: number;
|
|
38
|
+
expires: string;
|
|
39
|
+
description?: string | undefined;
|
|
40
|
+
externalId?: string | undefined;
|
|
41
|
+
recipient?: string | undefined;
|
|
42
|
+
}>>;
|
|
43
|
+
};
|
|
44
|
+
}, {
|
|
45
|
+
readonly method: "tempo";
|
|
46
|
+
readonly schema: {
|
|
47
|
+
readonly credential: {
|
|
48
|
+
readonly payload: import("zod/mini").ZodMiniDiscriminatedUnion<[import("zod/mini").ZodMiniObject<{
|
|
49
|
+
hash: import("zod/mini").ZodMiniString<string>;
|
|
50
|
+
type: import("zod/mini").ZodMiniLiteral<"hash">;
|
|
51
|
+
}, import("zod/v4/core").$strip>, import("zod/mini").ZodMiniObject<{
|
|
52
|
+
signature: import("zod/mini").ZodMiniString<string>;
|
|
53
|
+
type: import("zod/mini").ZodMiniLiteral<"transaction">;
|
|
54
|
+
}, import("zod/v4/core").$strip>], "type">;
|
|
55
|
+
};
|
|
56
|
+
readonly request: {
|
|
57
|
+
readonly methodDetails: import("zod/mini").ZodMiniObject<{
|
|
58
|
+
chainId: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniNumber<number>>;
|
|
59
|
+
feePayer: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniPipe<import("zod/mini").ZodMiniUnion<readonly [import("zod/mini").ZodMiniBoolean<boolean>, import("zod/mini").ZodMiniCustom<import("viem").Account, import("viem").Account>]>, import("zod/mini").ZodMiniTransform<boolean, boolean | import("viem").Account>>>;
|
|
60
|
+
memo: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniString<string>>;
|
|
61
|
+
}, import("zod/v4/core").$strip>;
|
|
62
|
+
readonly requires: readonly ["decimals", "recipient"];
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
}>, import("zod/mini").ZodMiniObject<{
|
|
66
|
+
account: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniCustom<`0x${string}` | import("../../viem/Account.js").Account | undefined, `0x${string}` | import("../../viem/Account.js").Account | undefined>>;
|
|
67
|
+
}, import("zod/v4/core").$strip>>, import("../../MethodIntent.js").Client<import("../../MethodIntent.js").MethodIntent<{
|
|
68
|
+
readonly name: "session";
|
|
69
|
+
readonly schema: {
|
|
70
|
+
readonly request: import("zod/mini").ZodMiniPipe<import("zod/mini").ZodMiniObject<{
|
|
71
|
+
amount: import("zod/mini").ZodMiniString<string>;
|
|
72
|
+
unitType: import("zod/mini").ZodMiniString<string>;
|
|
73
|
+
currency: import("zod/mini").ZodMiniString<string>;
|
|
74
|
+
decimals: import("zod/mini").ZodMiniNumber<number>;
|
|
75
|
+
recipient: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniString<string>>;
|
|
76
|
+
suggestedDeposit: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniString<string>>;
|
|
77
|
+
}, import("zod/v4/core").$strip>, import("zod/mini").ZodMiniTransform<{
|
|
78
|
+
suggestedDeposit?: string | undefined;
|
|
79
|
+
amount: string;
|
|
80
|
+
unitType: string;
|
|
81
|
+
currency: string;
|
|
82
|
+
recipient?: string | undefined;
|
|
83
|
+
}, {
|
|
84
|
+
amount: string;
|
|
85
|
+
unitType: string;
|
|
86
|
+
currency: string;
|
|
87
|
+
decimals: number;
|
|
88
|
+
recipient?: string | undefined;
|
|
89
|
+
suggestedDeposit?: string | undefined;
|
|
90
|
+
}>>;
|
|
91
|
+
};
|
|
92
|
+
}, {
|
|
93
|
+
readonly method: "tempo";
|
|
94
|
+
readonly schema: {
|
|
95
|
+
readonly credential: {
|
|
96
|
+
readonly payload: import("zod/mini").ZodMiniDiscriminatedUnion<[import("zod/mini").ZodMiniObject<{
|
|
97
|
+
action: import("zod/mini").ZodMiniLiteral<"open">;
|
|
98
|
+
type: import("zod/mini").ZodMiniLiteral<"transaction">;
|
|
99
|
+
channelId: import("zod/mini").ZodMiniString<string>;
|
|
100
|
+
transaction: import("zod/mini").ZodMiniString<string>;
|
|
101
|
+
authorizedSigner: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniString<string>>;
|
|
102
|
+
cumulativeAmount: import("zod/mini").ZodMiniString<string>;
|
|
103
|
+
signature: import("zod/mini").ZodMiniString<string>;
|
|
104
|
+
}, import("zod/v4/core").$strip>, import("zod/mini").ZodMiniObject<{
|
|
105
|
+
action: import("zod/mini").ZodMiniLiteral<"topUp">;
|
|
106
|
+
type: import("zod/mini").ZodMiniLiteral<"transaction">;
|
|
107
|
+
channelId: import("zod/mini").ZodMiniString<string>;
|
|
108
|
+
transaction: import("zod/mini").ZodMiniString<string>;
|
|
109
|
+
additionalDeposit: import("zod/mini").ZodMiniString<string>;
|
|
110
|
+
}, import("zod/v4/core").$strip>, import("zod/mini").ZodMiniObject<{
|
|
111
|
+
action: import("zod/mini").ZodMiniLiteral<"voucher">;
|
|
112
|
+
channelId: import("zod/mini").ZodMiniString<string>;
|
|
113
|
+
cumulativeAmount: import("zod/mini").ZodMiniString<string>;
|
|
114
|
+
signature: import("zod/mini").ZodMiniString<string>;
|
|
115
|
+
}, import("zod/v4/core").$strip>, import("zod/mini").ZodMiniObject<{
|
|
116
|
+
action: import("zod/mini").ZodMiniLiteral<"close">;
|
|
117
|
+
channelId: import("zod/mini").ZodMiniString<string>;
|
|
118
|
+
cumulativeAmount: import("zod/mini").ZodMiniString<string>;
|
|
119
|
+
signature: import("zod/mini").ZodMiniString<string>;
|
|
120
|
+
}, import("zod/v4/core").$strip>], "action">;
|
|
121
|
+
};
|
|
122
|
+
readonly request: {
|
|
123
|
+
readonly methodDetails: import("zod/mini").ZodMiniObject<{
|
|
124
|
+
escrowContract: import("zod/mini").ZodMiniString<string>;
|
|
125
|
+
channelId: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniString<string>>;
|
|
126
|
+
minVoucherDelta: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniString<string>>;
|
|
127
|
+
chainId: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniNumber<number>>;
|
|
128
|
+
feePayer: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniPipe<import("zod/mini").ZodMiniUnion<readonly [import("zod/mini").ZodMiniBoolean<boolean>, import("zod/mini").ZodMiniCustom<import("viem").Account, import("viem").Account>]>, import("zod/mini").ZodMiniTransform<boolean, boolean | import("viem").Account>>>;
|
|
129
|
+
}, import("zod/v4/core").$strip>;
|
|
130
|
+
readonly requires: readonly ["decimals", "recipient", "currency"];
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
}>, import("zod/mini").ZodMiniObject<{
|
|
134
|
+
account: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniCustom<`0x${string}` | import("../../viem/Account.js").Account | undefined, `0x${string}` | import("../../viem/Account.js").Account | undefined>>;
|
|
135
|
+
action: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniEnum<{
|
|
136
|
+
open: "open";
|
|
137
|
+
topUp: "topUp";
|
|
138
|
+
voucher: "voucher";
|
|
139
|
+
close: "close";
|
|
140
|
+
}>>;
|
|
141
|
+
channelId: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniString<string>>;
|
|
142
|
+
cumulativeAmount: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniString<string>>;
|
|
143
|
+
cumulativeAmountRaw: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniString<string>>;
|
|
144
|
+
transaction: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniString<string>>;
|
|
145
|
+
authorizedSigner: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniString<string>>;
|
|
146
|
+
additionalDeposit: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniString<string>>;
|
|
147
|
+
additionalDepositRaw: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniString<string>>;
|
|
148
|
+
depositRaw: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniString<string>>;
|
|
149
|
+
}, import("zod/v4/core").$strip>>];
|
|
150
|
+
export declare namespace tempo {
|
|
151
|
+
type Parameters = charge_.Parameters & sessionIntent_.Parameters;
|
|
152
|
+
/** Creates a Tempo `charge` client method intent for one-time TIP-20 token transfers. */
|
|
153
|
+
const charge: typeof charge_;
|
|
154
|
+
/** Creates a client-side streaming session for managing payment channels. */
|
|
155
|
+
const session: typeof session_;
|
|
156
|
+
}
|
|
157
|
+
//# sourceMappingURL=MethodIntents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MethodIntents.d.ts","sourceRoot":"","sources":["../../../src/tempo/client/MethodIntents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,OAAO,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,EAAE,cAAc,IAAI,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAEhE;;;;;;;;;;;GAWG;AACH,wBAAgB,KAAK,CAAC,UAAU,GAAE,KAAK,CAAC,UAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mCAEtD;AAED,yBAAiB,KAAK,CAAC;IACrB,KAAY,UAAU,GAAG,OAAO,CAAC,UAAU,GAAG,cAAc,CAAC,UAAU,CAAA;IAEvE,yFAAyF;IAClF,MAAM,MAAM,gBAAU,CAAA;IAC7B,6EAA6E;IACtE,MAAM,OAAO,iBAAW,CAAA;CAChC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { charge as charge_ } from './Charge.js';
|
|
2
|
+
import { session as sessionIntent_ } from './Session.js';
|
|
3
|
+
import { sessionManager as session_ } from './SessionManager.js';
|
|
4
|
+
/**
|
|
5
|
+
* Creates both Tempo `charge` and `session` client method intents from shared parameters.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { Mppx, tempo } from 'mppx/client'
|
|
10
|
+
*
|
|
11
|
+
* const mppx = Mppx.create({
|
|
12
|
+
* methods: [tempo({ account })],
|
|
13
|
+
* })
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export function tempo(parameters = {}) {
|
|
17
|
+
return [charge_(parameters), sessionIntent_(parameters)];
|
|
18
|
+
}
|
|
19
|
+
(function (tempo) {
|
|
20
|
+
/** Creates a Tempo `charge` client method intent for one-time TIP-20 token transfers. */
|
|
21
|
+
tempo.charge = charge_;
|
|
22
|
+
/** Creates a client-side streaming session for managing payment channels. */
|
|
23
|
+
tempo.session = session_;
|
|
24
|
+
})(tempo || (tempo = {}));
|
|
25
|
+
//# sourceMappingURL=MethodIntents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MethodIntents.js","sourceRoot":"","sources":["../../../src/tempo/client/MethodIntents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,OAAO,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,EAAE,cAAc,IAAI,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAEhE;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,KAAK,CAAC,aAA+B,EAAE;IACrD,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,cAAc,CAAC,UAAU,CAAC,CAAU,CAAA;AACnE,CAAC;AAED,WAAiB,KAAK;IAGpB,yFAAyF;IAC5E,YAAM,GAAG,OAAO,CAAA;IAC7B,6EAA6E;IAChE,aAAO,GAAG,QAAQ,CAAA;AACjC,CAAC,EAPgB,KAAK,KAAL,KAAK,QAOrB"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { type Address, type Account as viem_Account } from 'viem';
|
|
2
|
+
import * as MethodIntent from '../../MethodIntent.js';
|
|
3
|
+
import * as Account from '../../viem/Account.js';
|
|
4
|
+
import * as Client from '../../viem/Client.js';
|
|
5
|
+
import * as z from '../../zod.js';
|
|
6
|
+
import { type ChannelEntry } from './ChannelOps.js';
|
|
7
|
+
export declare const streamContextSchema: z.ZodMiniObject<{
|
|
8
|
+
account: z.ZodMiniOptional<z.ZodMiniCustom<`0x${string}` | Account.Account | undefined, `0x${string}` | Account.Account | undefined>>;
|
|
9
|
+
action: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
10
|
+
open: "open";
|
|
11
|
+
topUp: "topUp";
|
|
12
|
+
voucher: "voucher";
|
|
13
|
+
close: "close";
|
|
14
|
+
}>>;
|
|
15
|
+
channelId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
16
|
+
cumulativeAmount: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
17
|
+
cumulativeAmountRaw: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
18
|
+
transaction: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
19
|
+
authorizedSigner: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
20
|
+
additionalDeposit: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
21
|
+
additionalDepositRaw: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
22
|
+
depositRaw: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
23
|
+
}, z.core.$strip>;
|
|
24
|
+
export type StreamContext = z.infer<typeof streamContextSchema>;
|
|
25
|
+
/**
|
|
26
|
+
* Creates a session payment MethodIntent plugin for use with `Mppx.create()`.
|
|
27
|
+
*
|
|
28
|
+
* Supports both auto mode (set `deposit` to manage channels automatically)
|
|
29
|
+
* and manual mode (pass `context.action` to control each step).
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* // Auto mode
|
|
34
|
+
* import { Mppx, tempo } from 'mppx/client'
|
|
35
|
+
*
|
|
36
|
+
* const mppx = Mppx.create({
|
|
37
|
+
* methods: [tempo({
|
|
38
|
+
* account: privateKeyToAccount('0x...'),
|
|
39
|
+
* deposit: '10',
|
|
40
|
+
* })],
|
|
41
|
+
* })
|
|
42
|
+
*
|
|
43
|
+
* const res = await mppx.fetch('/api/chat?prompt=hello')
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* // Manual mode
|
|
49
|
+
* const mppx = Mppx.create({
|
|
50
|
+
* methods: [tempo({ account })],
|
|
51
|
+
* })
|
|
52
|
+
*
|
|
53
|
+
* const credential = await mppx.createCredential(response, {
|
|
54
|
+
* action: 'voucher',
|
|
55
|
+
* channelId: '0x...',
|
|
56
|
+
* cumulativeAmount: '1',
|
|
57
|
+
* })
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export declare function session(parameters?: session.Parameters): MethodIntent.Client<MethodIntent.MethodIntent<{
|
|
61
|
+
readonly name: "session";
|
|
62
|
+
readonly schema: {
|
|
63
|
+
readonly request: z.ZodMiniPipe<z.ZodMiniObject<{
|
|
64
|
+
amount: z.ZodMiniString<string>;
|
|
65
|
+
unitType: z.ZodMiniString<string>;
|
|
66
|
+
currency: z.ZodMiniString<string>;
|
|
67
|
+
decimals: z.ZodMiniNumber<number>;
|
|
68
|
+
recipient: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
69
|
+
suggestedDeposit: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
70
|
+
}, z.core.$strip>, z.ZodMiniTransform<{
|
|
71
|
+
suggestedDeposit?: string | undefined;
|
|
72
|
+
amount: string;
|
|
73
|
+
unitType: string;
|
|
74
|
+
currency: string;
|
|
75
|
+
recipient?: string | undefined;
|
|
76
|
+
}, {
|
|
77
|
+
amount: string;
|
|
78
|
+
unitType: string;
|
|
79
|
+
currency: string;
|
|
80
|
+
decimals: number;
|
|
81
|
+
recipient?: string | undefined;
|
|
82
|
+
suggestedDeposit?: string | undefined;
|
|
83
|
+
}>>;
|
|
84
|
+
};
|
|
85
|
+
}, {
|
|
86
|
+
readonly method: "tempo";
|
|
87
|
+
readonly schema: {
|
|
88
|
+
readonly credential: {
|
|
89
|
+
readonly payload: z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
|
|
90
|
+
action: z.ZodMiniLiteral<"open">;
|
|
91
|
+
type: z.ZodMiniLiteral<"transaction">;
|
|
92
|
+
channelId: z.ZodMiniString<string>;
|
|
93
|
+
transaction: z.ZodMiniString<string>;
|
|
94
|
+
authorizedSigner: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
95
|
+
cumulativeAmount: z.ZodMiniString<string>;
|
|
96
|
+
signature: z.ZodMiniString<string>;
|
|
97
|
+
}, z.core.$strip>, z.ZodMiniObject<{
|
|
98
|
+
action: z.ZodMiniLiteral<"topUp">;
|
|
99
|
+
type: z.ZodMiniLiteral<"transaction">;
|
|
100
|
+
channelId: z.ZodMiniString<string>;
|
|
101
|
+
transaction: z.ZodMiniString<string>;
|
|
102
|
+
additionalDeposit: z.ZodMiniString<string>;
|
|
103
|
+
}, z.core.$strip>, z.ZodMiniObject<{
|
|
104
|
+
action: z.ZodMiniLiteral<"voucher">;
|
|
105
|
+
channelId: z.ZodMiniString<string>;
|
|
106
|
+
cumulativeAmount: z.ZodMiniString<string>;
|
|
107
|
+
signature: z.ZodMiniString<string>;
|
|
108
|
+
}, z.core.$strip>, z.ZodMiniObject<{
|
|
109
|
+
action: z.ZodMiniLiteral<"close">;
|
|
110
|
+
channelId: z.ZodMiniString<string>;
|
|
111
|
+
cumulativeAmount: z.ZodMiniString<string>;
|
|
112
|
+
signature: z.ZodMiniString<string>;
|
|
113
|
+
}, z.core.$strip>], "action">;
|
|
114
|
+
};
|
|
115
|
+
readonly request: {
|
|
116
|
+
readonly methodDetails: z.ZodMiniObject<{
|
|
117
|
+
escrowContract: z.ZodMiniString<string>;
|
|
118
|
+
channelId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
119
|
+
minVoucherDelta: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
120
|
+
chainId: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
121
|
+
feePayer: z.ZodMiniOptional<z.ZodMiniPipe<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniCustom<viem_Account, viem_Account>]>, z.ZodMiniTransform<boolean, boolean | viem_Account>>>;
|
|
122
|
+
}, z.core.$strip>;
|
|
123
|
+
readonly requires: readonly ["decimals", "recipient", "currency"];
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
}>, z.ZodMiniObject<{
|
|
127
|
+
account: z.ZodMiniOptional<z.ZodMiniCustom<`0x${string}` | Account.Account | undefined, `0x${string}` | Account.Account | undefined>>;
|
|
128
|
+
action: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
129
|
+
open: "open";
|
|
130
|
+
topUp: "topUp";
|
|
131
|
+
voucher: "voucher";
|
|
132
|
+
close: "close";
|
|
133
|
+
}>>;
|
|
134
|
+
channelId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
135
|
+
cumulativeAmount: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
136
|
+
cumulativeAmountRaw: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
137
|
+
transaction: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
138
|
+
authorizedSigner: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
139
|
+
additionalDeposit: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
140
|
+
additionalDepositRaw: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
141
|
+
depositRaw: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
142
|
+
}, z.core.$strip>>;
|
|
143
|
+
export declare namespace session {
|
|
144
|
+
type Parameters = Account.getResolver.Parameters & Client.getResolver.Parameters & {
|
|
145
|
+
/** Address authorized to sign vouchers. Defaults to the account address. Use when a separate access key (e.g. secp256k1) signs vouchers while the root account funds the channel. */
|
|
146
|
+
authorizedSigner?: Address | undefined;
|
|
147
|
+
/** Token decimals for parsing human-readable amounts (default: 6). */
|
|
148
|
+
decimals?: number | undefined;
|
|
149
|
+
/** Initial deposit amount in human-readable units (e.g. "10" for 10 tokens). When set, the method handles the full channel lifecycle (open, voucher, cumulative tracking) automatically. */
|
|
150
|
+
deposit?: string | undefined;
|
|
151
|
+
/** Escrow contract address override. Derived from challenge or defaults if not provided. */
|
|
152
|
+
escrowContract?: Address | undefined;
|
|
153
|
+
/** Maximum deposit in human-readable units (e.g. "10"). Caps the server's `suggestedDeposit`. Enables auto-management like `deposit`. */
|
|
154
|
+
maxDeposit?: string | undefined;
|
|
155
|
+
/** Called whenever channel state changes (open, voucher, close, recovery). */
|
|
156
|
+
onChannelUpdate?: ((entry: ChannelEntry) => void) | undefined;
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
//# sourceMappingURL=Session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Session.d.ts","sourceRoot":"","sources":["../../../src/tempo/client/Session.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,OAAO,EAAc,KAAK,OAAO,IAAI,YAAY,EAAE,MAAM,MAAM,CAAA;AAG7E,OAAO,KAAK,YAAY,MAAM,uBAAuB,CAAA;AACrD,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAA;AAChD,OAAO,KAAK,MAAM,MAAM,sBAAsB,CAAA;AAC9C,OAAO,KAAK,CAAC,MAAM,cAAc,CAAA;AAKjC,OAAO,EACL,KAAK,YAAY,EAMlB,MAAM,iBAAiB,CAAA;AAExB,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;iBAW9B,CAAA;AAEF,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,OAAO,CAAC,UAAU,GAAE,OAAO,CAAC,UAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAuR1D;AAED,MAAM,CAAC,OAAO,WAAW,OAAO,CAAC;IAC/B,KAAK,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC,UAAU,GAC9C,MAAM,CAAC,WAAW,CAAC,UAAU,GAAG;QAC9B,qLAAqL;QACrL,gBAAgB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;QACtC,sEAAsE;QACtE,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;QAC7B,4LAA4L;QAC5L,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;QAC5B,4FAA4F;QAC5F,cAAc,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;QACpC,yIAAyI;QACzI,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;QAC/B,8EAA8E;QAC9E,eAAe,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC,GAAG,SAAS,CAAA;KAC9D,CAAA;CACJ"}
|