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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Response.js","sourceRoot":"","sources":["../../src/server/Response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,iBAAiB,CAAA;AAG5C,MAAM,UAAU,cAAc,CAAC,UAAqC;IAClE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,UAAU,CAAA;IAEvC,MAAM,OAAO,GAA2B;QACtC,kBAAkB,EAAE,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC;QAClD,eAAe,EAAE,UAAU;KAC5B,CAAA;IAED,IAAI,IAAI,GAAkB,IAAI,CAAA;IAE9B,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,CAAC,cAAc,CAAC,GAAG,0BAA0B,CAAA;QACpD,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,gBAAgB,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAA;IAC7D,CAAC;IAED,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAA;AACrD,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import * as Challenge from '../Challenge.js';
|
|
2
|
+
import * as Credential from '../Credential.js';
|
|
3
|
+
import * as Errors from '../Errors.js';
|
|
4
|
+
import type { Distribute, UnionToIntersection } from '../internal/types.js';
|
|
5
|
+
import * as core_Mcp from '../Mcp.js';
|
|
6
|
+
import * as Receipt from '../Receipt.js';
|
|
7
|
+
export { type McpSdk, mcpSdk } from '../mcp-sdk/server/Transport.js';
|
|
8
|
+
/**
|
|
9
|
+
* Server-side transport adapter.
|
|
10
|
+
*
|
|
11
|
+
* Abstracts how challenges are issued and credentials are received
|
|
12
|
+
* across different transport protocols (HTTP, MCP, etc.).
|
|
13
|
+
*/
|
|
14
|
+
export type Transport<in out input = unknown, in out challengeOutput = unknown, in receiptResponse = challengeOutput, out receiptOutput = receiptResponse> = {
|
|
15
|
+
/** Transport name for identification. */
|
|
16
|
+
name: string;
|
|
17
|
+
/**
|
|
18
|
+
* Extracts credential from the transport input.
|
|
19
|
+
* Returns `null` if no credential was provided, or throws if malformed.
|
|
20
|
+
*/
|
|
21
|
+
getCredential: (input: input) => Credential.Credential | null;
|
|
22
|
+
/** Creates a transport response for a payment challenge. */
|
|
23
|
+
respondChallenge: (options: {
|
|
24
|
+
challenge: Challenge.Challenge;
|
|
25
|
+
error?: Errors.PaymentError | undefined;
|
|
26
|
+
input: input;
|
|
27
|
+
}) => challengeOutput | Promise<challengeOutput>;
|
|
28
|
+
/** Attaches a receipt to a successful response. */
|
|
29
|
+
respondReceipt: (options: {
|
|
30
|
+
challengeId: string;
|
|
31
|
+
receipt: Receipt.Receipt;
|
|
32
|
+
response: receiptResponse;
|
|
33
|
+
}) => receiptOutput;
|
|
34
|
+
};
|
|
35
|
+
export type AnyTransport = Transport<any, any, any, any>;
|
|
36
|
+
export type Http = Transport<Request, Response>;
|
|
37
|
+
export type Mcp = Transport<core_Mcp.JsonRpcRequest, core_Mcp.Response>;
|
|
38
|
+
export type Sse<stream = any> = Transport<Request, Response, Response | AsyncIterable<string> | ((stream: stream) => AsyncIterable<string>), Response>;
|
|
39
|
+
/** Extracts the input type from a transport. */
|
|
40
|
+
export type InputOf<transport extends AnyTransport = AnyTransport> = transport extends Transport<infer input, any, any> ? input : never;
|
|
41
|
+
/** Extracts the challenge output type from a transport. */
|
|
42
|
+
export type ChallengeOutputOf<transport extends AnyTransport = AnyTransport> = transport extends Transport<any, infer challengeOutput, any> ? challengeOutput : never;
|
|
43
|
+
/** Extracts the receipt output type from a transport. */
|
|
44
|
+
export type ReceiptResponseOf<transport extends AnyTransport = AnyTransport> = transport extends Transport<any, any, infer response, any> ? response : never;
|
|
45
|
+
/** Extracts the resolved receipt type (return type of respondReceipt). */
|
|
46
|
+
export type ReceiptOutputOf<transport extends AnyTransport = AnyTransport> = transport extends Transport<any, any, any, infer output> ? output : never;
|
|
47
|
+
/**
|
|
48
|
+
* The `withReceipt` overload set for a given transport.
|
|
49
|
+
*
|
|
50
|
+
* Produces one overload per union member of `ReceiptOutputOf<transport>`,
|
|
51
|
+
* so TypeScript can contextually type generator function parameters.
|
|
52
|
+
*/
|
|
53
|
+
export type WithReceipt<transport extends AnyTransport = Http> = WithReceiptOverloads<transport>;
|
|
54
|
+
/**
|
|
55
|
+
* Creates a custom server-side transport.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* import { Transport } from 'mppx/server'
|
|
60
|
+
*
|
|
61
|
+
* const custom = Transport.from({
|
|
62
|
+
* name: 'custom',
|
|
63
|
+
* getCredential(input) { ... },
|
|
64
|
+
* respondChallenge({ challenge, input }) { ... },
|
|
65
|
+
* respondReceipt({ receipt, response, challengeId }) { ... },
|
|
66
|
+
* })
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export declare function from<input = unknown, challengeOutput = unknown, receiptOutput = challengeOutput, receiptResolved = receiptOutput>(transport: Transport<input, challengeOutput, receiptOutput, receiptResolved>): Transport<input, challengeOutput, receiptOutput, receiptResolved>;
|
|
70
|
+
/**
|
|
71
|
+
* HTTP transport for server-side payment handling.
|
|
72
|
+
*
|
|
73
|
+
* - Reads credentials from the `Authorization` header
|
|
74
|
+
* - Issues challenges via `WWW-Authenticate` header with 402 status
|
|
75
|
+
* - Attaches receipts via `Payment-Receipt` header
|
|
76
|
+
*/
|
|
77
|
+
export declare function http(): Http;
|
|
78
|
+
/**
|
|
79
|
+
* MCP transport for server-side payment handling with raw JSON-RPC.
|
|
80
|
+
*
|
|
81
|
+
* - Reads credentials from `_meta["org.paymentauth/credential"]`
|
|
82
|
+
* - Issues challenges via JSON-RPC error with code -32042/-32043
|
|
83
|
+
* - Attaches receipts via `_meta["org.paymentauth/receipt"]`
|
|
84
|
+
*
|
|
85
|
+
* Use this transport when handling raw JSON-RPC messages directly.
|
|
86
|
+
* For use with `@modelcontextprotocol/sdk`, use `mcpSdk()` instead.
|
|
87
|
+
*/
|
|
88
|
+
export declare function mcp(): Transport<core_Mcp.JsonRpcRequest, core_Mcp.Response, core_Mcp.Response, core_Mcp.Response>;
|
|
89
|
+
/** @internal Distributes over the receipt response union to create overloads. */
|
|
90
|
+
type WithReceiptOverloads<transport extends AnyTransport = Http> = {
|
|
91
|
+
(): ReceiptOutputOf<transport>;
|
|
92
|
+
} & UnionToIntersection<Distribute<ReceiptResponseOf<transport>, ReceiptOutputOf<transport>>>;
|
|
93
|
+
//# sourceMappingURL=Transport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Transport.d.ts","sourceRoot":"","sources":["../../src/server/Transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,iBAAiB,CAAA;AAC5C,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAA;AAC9C,OAAO,KAAK,MAAM,MAAM,cAAc,CAAA;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAC3E,OAAO,KAAK,QAAQ,MAAM,WAAW,CAAA;AACrC,OAAO,KAAK,OAAO,MAAM,eAAe,CAAA;AAExC,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAA;AAEpE;;;;;GAKG;AACH,MAAM,MAAM,SAAS,CACnB,EAAE,CAAC,GAAG,CAAC,KAAK,GAAG,OAAO,EACtB,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F;AACjF,KAAK,oBAAoB,CAAC,SAAS,SAAS,YAAY,GAAG,IAAI,IAAI;IAEjE,IAAI,eAAe,CAAC,SAAS,CAAC,CAAA;CAC/B,GAAG,mBAAmB,CAAC,UAAU,CAAC,iBAAiB,CAAC,SAAS,CAAC,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import * as Challenge from '../Challenge.js';
|
|
2
|
+
import * as Credential from '../Credential.js';
|
|
3
|
+
import * as Errors from '../Errors.js';
|
|
4
|
+
import * as core_Mcp from '../Mcp.js';
|
|
5
|
+
import * as Receipt from '../Receipt.js';
|
|
6
|
+
export { mcpSdk } from '../mcp-sdk/server/Transport.js';
|
|
7
|
+
/**
|
|
8
|
+
* Creates a custom server-side transport.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { Transport } from 'mppx/server'
|
|
13
|
+
*
|
|
14
|
+
* const custom = Transport.from({
|
|
15
|
+
* name: 'custom',
|
|
16
|
+
* getCredential(input) { ... },
|
|
17
|
+
* respondChallenge({ challenge, input }) { ... },
|
|
18
|
+
* respondReceipt({ receipt, response, challengeId }) { ... },
|
|
19
|
+
* })
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export function from(transport) {
|
|
23
|
+
return transport;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* HTTP transport for server-side payment handling.
|
|
27
|
+
*
|
|
28
|
+
* - Reads credentials from the `Authorization` header
|
|
29
|
+
* - Issues challenges via `WWW-Authenticate` header with 402 status
|
|
30
|
+
* - Attaches receipts via `Payment-Receipt` header
|
|
31
|
+
*/
|
|
32
|
+
export function http() {
|
|
33
|
+
return from({
|
|
34
|
+
name: 'http',
|
|
35
|
+
getCredential(request) {
|
|
36
|
+
const header = request.headers.get('Authorization');
|
|
37
|
+
if (!header)
|
|
38
|
+
return null;
|
|
39
|
+
const payment = Credential.extractPaymentScheme(header);
|
|
40
|
+
if (!payment)
|
|
41
|
+
return null;
|
|
42
|
+
return Credential.deserialize(payment);
|
|
43
|
+
},
|
|
44
|
+
respondChallenge({ challenge, error }) {
|
|
45
|
+
const headers = {
|
|
46
|
+
'WWW-Authenticate': Challenge.serialize(challenge),
|
|
47
|
+
'Cache-Control': 'no-store',
|
|
48
|
+
};
|
|
49
|
+
let body = null;
|
|
50
|
+
if (error) {
|
|
51
|
+
headers['Content-Type'] = 'application/problem+json';
|
|
52
|
+
body = JSON.stringify(error.toProblemDetails(challenge.id));
|
|
53
|
+
}
|
|
54
|
+
return new Response(body, { status: error?.status ?? 402, headers });
|
|
55
|
+
},
|
|
56
|
+
respondReceipt({ receipt, response }) {
|
|
57
|
+
const headers = new Headers(response.headers);
|
|
58
|
+
headers.set('Payment-Receipt', Receipt.serialize(receipt));
|
|
59
|
+
return new Response(response.body, {
|
|
60
|
+
status: response.status,
|
|
61
|
+
statusText: response.statusText,
|
|
62
|
+
headers,
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* MCP transport for server-side payment handling with raw JSON-RPC.
|
|
69
|
+
*
|
|
70
|
+
* - Reads credentials from `_meta["org.paymentauth/credential"]`
|
|
71
|
+
* - Issues challenges via JSON-RPC error with code -32042/-32043
|
|
72
|
+
* - Attaches receipts via `_meta["org.paymentauth/receipt"]`
|
|
73
|
+
*
|
|
74
|
+
* Use this transport when handling raw JSON-RPC messages directly.
|
|
75
|
+
* For use with `@modelcontextprotocol/sdk`, use `mcpSdk()` instead.
|
|
76
|
+
*/
|
|
77
|
+
export function mcp() {
|
|
78
|
+
return from({
|
|
79
|
+
name: 'mcp',
|
|
80
|
+
getCredential(request) {
|
|
81
|
+
const meta = request.params?._meta;
|
|
82
|
+
const credential = meta?.[core_Mcp.credentialMetaKey];
|
|
83
|
+
if (!credential)
|
|
84
|
+
return null;
|
|
85
|
+
return credential;
|
|
86
|
+
},
|
|
87
|
+
respondChallenge({ challenge, input, error }) {
|
|
88
|
+
return {
|
|
89
|
+
jsonrpc: '2.0',
|
|
90
|
+
id: input.id,
|
|
91
|
+
error: {
|
|
92
|
+
code: mcpErrorCode(error),
|
|
93
|
+
message: error?.message ?? 'Payment Required',
|
|
94
|
+
data: {
|
|
95
|
+
httpStatus: error?.status ?? 402,
|
|
96
|
+
challenges: [challenge],
|
|
97
|
+
...(error && { problem: error.toProblemDetails(challenge.id) }),
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
},
|
|
102
|
+
respondReceipt({ receipt, response, challengeId }) {
|
|
103
|
+
if ('error' in response)
|
|
104
|
+
return response;
|
|
105
|
+
const mcpReceipt = {
|
|
106
|
+
...receipt,
|
|
107
|
+
challengeId,
|
|
108
|
+
};
|
|
109
|
+
return {
|
|
110
|
+
...response,
|
|
111
|
+
result: {
|
|
112
|
+
...response.result,
|
|
113
|
+
_meta: {
|
|
114
|
+
...response.result._meta,
|
|
115
|
+
[core_Mcp.receiptMetaKey]: mcpReceipt,
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
/** @internal */
|
|
123
|
+
function mcpErrorCode(error) {
|
|
124
|
+
if (!error)
|
|
125
|
+
return core_Mcp.paymentRequiredCode;
|
|
126
|
+
if (error instanceof Errors.MalformedCredentialError)
|
|
127
|
+
return -32602;
|
|
128
|
+
if (error instanceof Errors.PaymentRequiredError)
|
|
129
|
+
return core_Mcp.paymentRequiredCode;
|
|
130
|
+
return core_Mcp.paymentVerificationFailedCode;
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=Transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Transport.js","sourceRoot":"","sources":["../../src/server/Transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,iBAAiB,CAAA;AAC5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CAAC,gBAAgB,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC;qBAChE;iBACF;aACF,CAAA;QACH,CAAC;QAED,cAAc,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE;YAC/C,IAAI,OAAO,IAAI,QAAQ;gBAAE,OAAO,QAAQ,CAAA;YAExC,MAAM,UAAU,GAAqB;gBACnC,GAAG,OAAO;gBACV,WAAW;aACZ,CAAA;YAED,OAAO;gBACL,GAAG,QAAQ;gBACX,MAAM,EAAE;oBACN,GAAG,QAAQ,CAAC,MAAM;oBAClB,KAAK,EAAE;wBACL,GAAG,QAAQ,CAAC,MAAM,CAAC,KAAK;wBACxB,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,UAAU;qBACtC;iBACF;aACF,CAAA;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC;AAED,gBAAgB;AAChB,SAAS,YAAY,CAAC,KAA2B;IAC/C,IAAI,CAAC,KAAK;QAAE,OAAO,QAAQ,CAAC,mBAAmB,CAAA;IAC/C,IAAI,KAAK,YAAY,MAAM,CAAC,wBAAwB;QAAE,OAAO,CAAC,KAAK,CAAA;IACnE,IAAI,KAAK,YAAY,MAAM,CAAC,oBAAoB;QAAE,OAAO,QAAQ,CAAC,mBAAmB,CAAA;IACrF,OAAO,QAAQ,CAAC,6BAA6B,CAAA;AAC/C,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * as Expires from '../Expires.js';
|
|
2
|
+
export * as Store from '../Store.js';
|
|
3
|
+
export { stripe, tempo } from './Methods.js';
|
|
4
|
+
export * as Mppx from './Mppx.js';
|
|
5
|
+
export * as NodeListener from './NodeListener.js';
|
|
6
|
+
export * as Request from './Request.js';
|
|
7
|
+
export * as Response from './Response.js';
|
|
8
|
+
export * as Transport from './Transport.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,eAAe,CAAA;AACxC,OAAO,KAAK,KAAK,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAA;AACjD,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * as Expires from '../Expires.js';
|
|
2
|
+
export * as Store from '../Store.js';
|
|
3
|
+
export { stripe, tempo } from './Methods.js';
|
|
4
|
+
export * as Mppx from './Mppx.js';
|
|
5
|
+
export * as NodeListener from './NodeListener.js';
|
|
6
|
+
export * as Request from './Request.js';
|
|
7
|
+
export * as Response from './Response.js';
|
|
8
|
+
export * as Transport from './Transport.js';
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,eAAe,CAAA;AACxC,OAAO,KAAK,KAAK,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAA;AACjD,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import * as MethodIntent from '../MethodIntent.js';
|
|
2
|
+
import * as z from '../zod.js';
|
|
3
|
+
/**
|
|
4
|
+
* Stripe charge intent for one-time payments via Shared Payment Tokens (SPTs).
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/tempoxyz/payment-auth-spec/blob/main/specs/methods/stripe/draft-stripe-charge-00.md
|
|
7
|
+
*/
|
|
8
|
+
export declare const charge: MethodIntent.MethodIntent<{
|
|
9
|
+
readonly name: "charge";
|
|
10
|
+
readonly schema: {
|
|
11
|
+
readonly request: z.ZodMiniPipe<z.ZodMiniObject<{
|
|
12
|
+
amount: z.ZodMiniString<string>;
|
|
13
|
+
currency: z.ZodMiniString<string>;
|
|
14
|
+
decimals: z.ZodMiniNumber<number>;
|
|
15
|
+
description: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
16
|
+
expires: z.ZodMiniDefault<z.ZodMiniString<string>>;
|
|
17
|
+
externalId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
18
|
+
recipient: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
19
|
+
}, z.core.$strip>, z.ZodMiniTransform<{
|
|
20
|
+
amount: string;
|
|
21
|
+
currency: string;
|
|
22
|
+
expires: string;
|
|
23
|
+
description?: string | undefined;
|
|
24
|
+
externalId?: string | undefined;
|
|
25
|
+
recipient?: string | undefined;
|
|
26
|
+
}, {
|
|
27
|
+
amount: string;
|
|
28
|
+
currency: string;
|
|
29
|
+
decimals: number;
|
|
30
|
+
expires: string;
|
|
31
|
+
description?: string | undefined;
|
|
32
|
+
externalId?: string | undefined;
|
|
33
|
+
recipient?: string | undefined;
|
|
34
|
+
}>>;
|
|
35
|
+
};
|
|
36
|
+
}, {
|
|
37
|
+
readonly method: "stripe";
|
|
38
|
+
readonly schema: {
|
|
39
|
+
readonly credential: {
|
|
40
|
+
readonly payload: z.ZodMiniObject<{
|
|
41
|
+
spt: z.ZodMiniString<string>;
|
|
42
|
+
externalId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
43
|
+
}, z.core.$strip>;
|
|
44
|
+
};
|
|
45
|
+
readonly request: {
|
|
46
|
+
readonly methodDetails: z.ZodMiniObject<{
|
|
47
|
+
networkId: z.ZodMiniString<string>;
|
|
48
|
+
paymentMethodTypes: z.ZodMiniArray<z.ZodMiniString<string>>;
|
|
49
|
+
metadata: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniString<string>>>;
|
|
50
|
+
}, z.core.$strip>;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
}>;
|
|
54
|
+
//# sourceMappingURL=Intents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Intents.d.ts","sourceRoot":"","sources":["../../src/stripe/Intents.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,YAAY,MAAM,oBAAoB,CAAA;AAClD,OAAO,KAAK,CAAC,MAAM,WAAW,CAAA;AAE9B;;;;GAIG;AACH,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiBjB,CAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as Intent from '../Intent.js';
|
|
2
|
+
import * as MethodIntent from '../MethodIntent.js';
|
|
3
|
+
import * as z from '../zod.js';
|
|
4
|
+
/**
|
|
5
|
+
* Stripe charge intent for one-time payments via Shared Payment Tokens (SPTs).
|
|
6
|
+
*
|
|
7
|
+
* @see https://github.com/tempoxyz/payment-auth-spec/blob/main/specs/methods/stripe/draft-stripe-charge-00.md
|
|
8
|
+
*/
|
|
9
|
+
export const charge = MethodIntent.fromIntent(Intent.charge, {
|
|
10
|
+
method: 'stripe',
|
|
11
|
+
schema: {
|
|
12
|
+
credential: {
|
|
13
|
+
payload: z.object({
|
|
14
|
+
spt: z.string(),
|
|
15
|
+
externalId: z.optional(z.string()),
|
|
16
|
+
}),
|
|
17
|
+
},
|
|
18
|
+
request: {
|
|
19
|
+
methodDetails: z.object({
|
|
20
|
+
networkId: z.string(),
|
|
21
|
+
paymentMethodTypes: z.array(z.string()).check(z.minLength(1)),
|
|
22
|
+
metadata: z.optional(z.record(z.string(), z.string())),
|
|
23
|
+
}),
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
//# sourceMappingURL=Intents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Intents.js","sourceRoot":"","sources":["../../src/stripe/Intents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,cAAc,CAAA;AACtC,OAAO,KAAK,YAAY,MAAM,oBAAoB,CAAA;AAClD,OAAO,KAAK,CAAC,MAAM,WAAW,CAAA;AAE9B;;;;GAIG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,YAAY,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE;IAC3D,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE;QACN,UAAU,EAAE;YACV,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC;gBAChB,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;gBACf,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;aACnC,CAAC;SACH;QACD,OAAO,EAAE;YACP,aAAa,EAAE,CAAC,CAAC,MAAM,CAAC;gBACtB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;gBACrB,kBAAkB,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;gBAC7D,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;aACvD,CAAC;SACH;KACF;CACF,CAAC,CAAA"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import * as MethodIntent from '../../MethodIntent.js';
|
|
2
|
+
import * as z from '../../zod.js';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a Stripe charge method intent for usage on the client.
|
|
5
|
+
*
|
|
6
|
+
* Accepts a `createSpt` callback that handles SPT creation (requires
|
|
7
|
+
* a secret key, so typically proxied through a server endpoint).
|
|
8
|
+
*
|
|
9
|
+
* The `paymentMethod` (e.g. from Stripe Elements) can be provided at
|
|
10
|
+
* initialization or at credential-creation time via `context`.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { stripe } from 'mppx/client'
|
|
15
|
+
*
|
|
16
|
+
* const charge = stripe.charge({
|
|
17
|
+
* createSpt: async ({ paymentMethod, amount, currency, networkId, expiresAt, metadata }) => {
|
|
18
|
+
* const res = await fetch('/api/create-spt', {
|
|
19
|
+
* method: 'POST',
|
|
20
|
+
* headers: { 'Content-Type': 'application/json' },
|
|
21
|
+
* body: JSON.stringify({ paymentMethod, amount, currency, networkId, expiresAt, metadata }),
|
|
22
|
+
* })
|
|
23
|
+
* const { spt } = await res.json()
|
|
24
|
+
* return spt
|
|
25
|
+
* },
|
|
26
|
+
* })
|
|
27
|
+
*
|
|
28
|
+
* // paymentMethod comes from Stripe Elements at credential-creation time
|
|
29
|
+
* const credential = await charge.createCredential({
|
|
30
|
+
* challenge,
|
|
31
|
+
* context: { paymentMethod: 'pm_xxx' },
|
|
32
|
+
* })
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare function charge(parameters: charge.Parameters): MethodIntent.Client<MethodIntent.MethodIntent<{
|
|
36
|
+
readonly name: "charge";
|
|
37
|
+
readonly schema: {
|
|
38
|
+
readonly request: z.ZodMiniPipe<z.ZodMiniObject<{
|
|
39
|
+
amount: z.ZodMiniString<string>;
|
|
40
|
+
currency: z.ZodMiniString<string>;
|
|
41
|
+
decimals: z.ZodMiniNumber<number>;
|
|
42
|
+
description: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
43
|
+
expires: z.ZodMiniDefault<z.ZodMiniString<string>>;
|
|
44
|
+
externalId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
45
|
+
recipient: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
46
|
+
}, z.core.$strip>, z.ZodMiniTransform<{
|
|
47
|
+
amount: string;
|
|
48
|
+
currency: string;
|
|
49
|
+
expires: string;
|
|
50
|
+
description?: string | undefined;
|
|
51
|
+
externalId?: string | undefined;
|
|
52
|
+
recipient?: string | undefined;
|
|
53
|
+
}, {
|
|
54
|
+
amount: string;
|
|
55
|
+
currency: string;
|
|
56
|
+
decimals: number;
|
|
57
|
+
expires: string;
|
|
58
|
+
description?: string | undefined;
|
|
59
|
+
externalId?: string | undefined;
|
|
60
|
+
recipient?: string | undefined;
|
|
61
|
+
}>>;
|
|
62
|
+
};
|
|
63
|
+
}, {
|
|
64
|
+
readonly method: "stripe";
|
|
65
|
+
readonly schema: {
|
|
66
|
+
readonly credential: {
|
|
67
|
+
readonly payload: z.ZodMiniObject<{
|
|
68
|
+
spt: z.ZodMiniString<string>;
|
|
69
|
+
externalId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
70
|
+
}, z.core.$strip>;
|
|
71
|
+
};
|
|
72
|
+
readonly request: {
|
|
73
|
+
readonly methodDetails: z.ZodMiniObject<{
|
|
74
|
+
networkId: z.ZodMiniString<string>;
|
|
75
|
+
paymentMethodTypes: z.ZodMiniArray<z.ZodMiniString<string>>;
|
|
76
|
+
metadata: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniString<string>>>;
|
|
77
|
+
}, z.core.$strip>;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
}>, z.ZodMiniObject<{
|
|
81
|
+
paymentMethod: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
82
|
+
}, z.core.$strip>>;
|
|
83
|
+
export declare namespace charge {
|
|
84
|
+
type Parameters = {
|
|
85
|
+
/**
|
|
86
|
+
* Creates a Shared Payment Token (SPT) for the given parameters.
|
|
87
|
+
*
|
|
88
|
+
* SPT creation requires a Stripe secret key, so this typically
|
|
89
|
+
* proxies through a server endpoint (e.g. `POST /api/create-spt`).
|
|
90
|
+
* If you are running a client in an enviroment with a secret key, you can just create the
|
|
91
|
+
* SPT directly in this callback.
|
|
92
|
+
*/
|
|
93
|
+
createSpt: (parameters: CreateSptParameters) => Promise<string>;
|
|
94
|
+
/** Optional client-side external reference ID for the credential payload. */
|
|
95
|
+
externalId?: string | undefined;
|
|
96
|
+
/** Default payment method ID. Overridden by `context.paymentMethod`. */
|
|
97
|
+
paymentMethod?: string | undefined;
|
|
98
|
+
};
|
|
99
|
+
type CreateSptParameters = {
|
|
100
|
+
/** Stripe payment method ID (e.g. from Stripe Elements). */
|
|
101
|
+
paymentMethod: string;
|
|
102
|
+
/** Payment amount (in smallest currency unit). */
|
|
103
|
+
amount: string;
|
|
104
|
+
/** Three-letter ISO currency code. */
|
|
105
|
+
currency: string;
|
|
106
|
+
/** Stripe Business Network profile ID. */
|
|
107
|
+
networkId: string | undefined;
|
|
108
|
+
/** SPT expiration as a Unix timestamp (seconds). */
|
|
109
|
+
expiresAt: number;
|
|
110
|
+
/** Optional metadata to associate with the SPT. */
|
|
111
|
+
metadata?: Record<string, string> | undefined;
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=Charge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Charge.d.ts","sourceRoot":"","sources":["../../../src/stripe/client/Charge.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,YAAY,MAAM,uBAAuB,CAAA;AACrD,OAAO,KAAK,CAAC,MAAM,cAAc,CAAA;AAGjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAgDnD;AAED,MAAM,CAAC,OAAO,WAAW,MAAM,CAAC;IAC9B,KAAK,UAAU,GAAG;QAChB;;;;;;;WAOG;QACH,SAAS,EAAE,CAAC,UAAU,EAAE,mBAAmB,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;QAC/D,6EAA6E;QAC7E,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;QAC/B,wEAAwE;QACxE,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KACnC,CAAA;IAED,KAAK,mBAAmB,GAAG;QACzB,4DAA4D;QAC5D,aAAa,EAAE,MAAM,CAAA;QACrB,kDAAkD;QAClD,MAAM,EAAE,MAAM,CAAA;QACd,sCAAsC;QACtC,QAAQ,EAAE,MAAM,CAAA;QAChB,0CAA0C;QAC1C,SAAS,EAAE,MAAM,GAAG,SAAS,CAAA;QAC7B,oDAAoD;QACpD,SAAS,EAAE,MAAM,CAAA;QACjB,mDAAmD;QACnD,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAA;KAC9C,CAAA;CACF"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import * as Credential from '../../Credential.js';
|
|
2
|
+
import * as MethodIntent from '../../MethodIntent.js';
|
|
3
|
+
import * as z from '../../zod.js';
|
|
4
|
+
import * as Intents from '../Intents.js';
|
|
5
|
+
/**
|
|
6
|
+
* Creates a Stripe charge method intent for usage on the client.
|
|
7
|
+
*
|
|
8
|
+
* Accepts a `createSpt` callback that handles SPT creation (requires
|
|
9
|
+
* a secret key, so typically proxied through a server endpoint).
|
|
10
|
+
*
|
|
11
|
+
* The `paymentMethod` (e.g. from Stripe Elements) can be provided at
|
|
12
|
+
* initialization or at credential-creation time via `context`.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* import { stripe } from 'mppx/client'
|
|
17
|
+
*
|
|
18
|
+
* const charge = stripe.charge({
|
|
19
|
+
* createSpt: async ({ paymentMethod, amount, currency, networkId, expiresAt, metadata }) => {
|
|
20
|
+
* const res = await fetch('/api/create-spt', {
|
|
21
|
+
* method: 'POST',
|
|
22
|
+
* headers: { 'Content-Type': 'application/json' },
|
|
23
|
+
* body: JSON.stringify({ paymentMethod, amount, currency, networkId, expiresAt, metadata }),
|
|
24
|
+
* })
|
|
25
|
+
* const { spt } = await res.json()
|
|
26
|
+
* return spt
|
|
27
|
+
* },
|
|
28
|
+
* })
|
|
29
|
+
*
|
|
30
|
+
* // paymentMethod comes from Stripe Elements at credential-creation time
|
|
31
|
+
* const credential = await charge.createCredential({
|
|
32
|
+
* challenge,
|
|
33
|
+
* context: { paymentMethod: 'pm_xxx' },
|
|
34
|
+
* })
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export function charge(parameters) {
|
|
38
|
+
const { createSpt, externalId, paymentMethod: defaultPaymentMethod } = parameters;
|
|
39
|
+
return MethodIntent.toClient(Intents.charge, {
|
|
40
|
+
context: z.object({
|
|
41
|
+
paymentMethod: z.optional(z.string()),
|
|
42
|
+
}),
|
|
43
|
+
async createCredential({ challenge, context }) {
|
|
44
|
+
const paymentMethod = context?.paymentMethod ?? defaultPaymentMethod;
|
|
45
|
+
if (!paymentMethod)
|
|
46
|
+
throw new Error('paymentMethod is required (pass via context or parameters)');
|
|
47
|
+
const amount = challenge.request.amount;
|
|
48
|
+
const currency = challenge.request.currency;
|
|
49
|
+
const networkId = challenge.request.methodDetails?.networkId;
|
|
50
|
+
if (!networkId)
|
|
51
|
+
throw new Error('networkId is required in challenge.methodDetails');
|
|
52
|
+
const metadata = challenge.request.methodDetails?.metadata;
|
|
53
|
+
if (metadata?.externalId) {
|
|
54
|
+
throw new Error('methodDetails.metadata.externalId is reserved; use credential externalId instead');
|
|
55
|
+
}
|
|
56
|
+
const expiresAt = challenge.request.expires
|
|
57
|
+
? Math.floor(new Date(challenge.request.expires).getTime() / 1000)
|
|
58
|
+
: Math.floor(Date.now() / 1000) + 3600;
|
|
59
|
+
const spt = await createSpt({
|
|
60
|
+
paymentMethod,
|
|
61
|
+
amount,
|
|
62
|
+
currency,
|
|
63
|
+
networkId,
|
|
64
|
+
expiresAt,
|
|
65
|
+
metadata,
|
|
66
|
+
});
|
|
67
|
+
return Credential.serialize({
|
|
68
|
+
challenge,
|
|
69
|
+
payload: {
|
|
70
|
+
spt,
|
|
71
|
+
...(externalId ? { externalId } : {}),
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=Charge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Charge.js","sourceRoot":"","sources":["../../../src/stripe/client/Charge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAA;AACjD,OAAO,KAAK,YAAY,MAAM,uBAAuB,CAAA;AACrD,OAAO,KAAK,CAAC,MAAM,cAAc,CAAA;AACjC,OAAO,KAAK,OAAO,MAAM,eAAe,CAAA;AAExC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,UAAU,MAAM,CAAC,UAA6B;IAClD,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,oBAAoB,EAAE,GAAG,UAAU,CAAA;IAEjF,OAAO,YAAY,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE;QAC3C,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC;YAChB,aAAa,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;SACtC,CAAC;QAEF,KAAK,CAAC,gBAAgB,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE;YAC3C,MAAM,aAAa,GAAG,OAAO,EAAE,aAAa,IAAI,oBAAoB,CAAA;YACpE,IAAI,CAAC,aAAa;gBAChB,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAA;YAE/E,MA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*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* import { Mppx, stripe } from 'mppx/client'
|
|
8
|
+
*
|
|
9
|
+
* const mppx = Mppx.create({
|
|
10
|
+
* methods: [
|
|
11
|
+
* stripe({
|
|
12
|
+
* createSpt: async (params) => {
|
|
13
|
+
* const res = await fetch('/api/create-spt', {
|
|
14
|
+
* method: 'POST',
|
|
15
|
+
* headers: { 'Content-Type': 'application/json' },
|
|
16
|
+
* body: JSON.stringify(params),
|
|
17
|
+
* })
|
|
18
|
+
* const { spt } = await res.json()
|
|
19
|
+
* return spt
|
|
20
|
+
* },
|
|
21
|
+
* paymentMethod: 'pm_card_visa',
|
|
22
|
+
* }),
|
|
23
|
+
* ],
|
|
24
|
+
* })
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function stripe(parameters: stripe.Parameters): readonly [import("../../MethodIntent.js").Client<import("../../MethodIntent.js").MethodIntent<{
|
|
28
|
+
readonly name: "charge";
|
|
29
|
+
readonly schema: {
|
|
30
|
+
readonly request: import("zod/mini").ZodMiniPipe<import("zod/mini").ZodMiniObject<{
|
|
31
|
+
amount: import("zod/mini").ZodMiniString<string>;
|
|
32
|
+
currency: import("zod/mini").ZodMiniString<string>;
|
|
33
|
+
decimals: import("zod/mini").ZodMiniNumber<number>;
|
|
34
|
+
description: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniString<string>>;
|
|
35
|
+
expires: import("zod/mini").ZodMiniDefault<import("zod/mini").ZodMiniString<string>>;
|
|
36
|
+
externalId: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniString<string>>;
|
|
37
|
+
recipient: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniString<string>>;
|
|
38
|
+
}, import("zod/v4/core").$strip>, import("zod/mini").ZodMiniTransform<{
|
|
39
|
+
amount: string;
|
|
40
|
+
currency: string;
|
|
41
|
+
expires: string;
|
|
42
|
+
description?: string | undefined;
|
|
43
|
+
externalId?: string | undefined;
|
|
44
|
+
recipient?: string | undefined;
|
|
45
|
+
}, {
|
|
46
|
+
amount: string;
|
|
47
|
+
currency: string;
|
|
48
|
+
decimals: number;
|
|
49
|
+
expires: string;
|
|
50
|
+
description?: string | undefined;
|
|
51
|
+
externalId?: string | undefined;
|
|
52
|
+
recipient?: string | undefined;
|
|
53
|
+
}>>;
|
|
54
|
+
};
|
|
55
|
+
}, {
|
|
56
|
+
readonly method: "stripe";
|
|
57
|
+
readonly schema: {
|
|
58
|
+
readonly credential: {
|
|
59
|
+
readonly payload: import("zod/mini").ZodMiniObject<{
|
|
60
|
+
spt: import("zod/mini").ZodMiniString<string>;
|
|
61
|
+
externalId: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniString<string>>;
|
|
62
|
+
}, import("zod/v4/core").$strip>;
|
|
63
|
+
};
|
|
64
|
+
readonly request: {
|
|
65
|
+
readonly methodDetails: import("zod/mini").ZodMiniObject<{
|
|
66
|
+
networkId: import("zod/mini").ZodMiniString<string>;
|
|
67
|
+
paymentMethodTypes: import("zod/mini").ZodMiniArray<import("zod/mini").ZodMiniString<string>>;
|
|
68
|
+
metadata: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniRecord<import("zod/mini").ZodMiniString<string>, import("zod/mini").ZodMiniString<string>>>;
|
|
69
|
+
}, import("zod/v4/core").$strip>;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
}>, import("zod/mini").ZodMiniObject<{
|
|
73
|
+
paymentMethod: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniString<string>>;
|
|
74
|
+
}, import("zod/v4/core").$strip>>];
|
|
75
|
+
export declare namespace stripe {
|
|
76
|
+
type Parameters = charge_.Parameters;
|
|
77
|
+
/** Creates a Stripe `charge` client method intent for SPT-based payments. */
|
|
78
|
+
const charge: typeof charge_;
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=MethodIntents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MethodIntents.d.ts","sourceRoot":"","sources":["../../../src/stripe/client/MethodIntents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,OAAO,EAAE,MAAM,aAAa,CAAA;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mCAEnD;AAED,yBAAiB,MAAM,CAAC;IACtB,KAAY,UAAU,GAAG,OAAO,CAAC,UAAU,CAAA;IAE3C,6EAA6E;IACtE,MAAM,MAAM,gBAAU,CAAA;CAC9B"}
|