mppx 0.1.1 → 0.2.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/dist/Challenge.d.ts +18 -18
- package/dist/Challenge.d.ts.map +1 -1
- package/dist/Challenge.js +8 -8
- package/dist/Challenge.js.map +1 -1
- package/dist/Errors.d.ts +58 -8
- package/dist/Errors.d.ts.map +1 -1
- package/dist/Errors.js +51 -9
- package/dist/Errors.js.map +1 -1
- package/dist/Method.d.ts +154 -0
- package/dist/Method.d.ts.map +1 -0
- package/dist/Method.js +81 -0
- package/dist/Method.js.map +1 -0
- package/dist/PaymentRequest.d.ts +5 -5
- package/dist/PaymentRequest.d.ts.map +1 -1
- package/dist/PaymentRequest.js +11 -6
- package/dist/PaymentRequest.js.map +1 -1
- package/dist/cli.js +67 -18
- package/dist/cli.js.map +1 -1
- package/dist/client/Methods.d.ts +2 -2
- package/dist/client/Methods.d.ts.map +1 -1
- package/dist/client/Methods.js +2 -2
- package/dist/client/Methods.js.map +1 -1
- package/dist/client/Mppx.d.ts +7 -7
- package/dist/client/Mppx.d.ts.map +1 -1
- package/dist/client/Mppx.js +3 -3
- package/dist/client/Mppx.js.map +1 -1
- package/dist/client/internal/Fetch.d.ts +10 -10
- package/dist/client/internal/Fetch.d.ts.map +1 -1
- package/dist/client/internal/Fetch.js +2 -2
- package/dist/client/internal/Fetch.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/mcp-sdk/client/McpClient.d.ts +6 -6
- package/dist/mcp-sdk/client/McpClient.d.ts.map +1 -1
- package/dist/mcp-sdk/client/McpClient.js +4 -4
- package/dist/mcp-sdk/client/McpClient.js.map +1 -1
- package/dist/middlewares/elysia.d.ts +1 -1
- package/dist/middlewares/express.d.ts +1 -1
- package/dist/middlewares/hono.d.ts +1 -1
- package/dist/middlewares/internal/mppx.d.ts +7 -7
- package/dist/middlewares/internal/mppx.d.ts.map +1 -1
- package/dist/middlewares/internal/mppx.js +5 -5
- package/dist/middlewares/internal/mppx.js.map +1 -1
- package/dist/middlewares/nextjs.d.ts +1 -1
- package/dist/proxy/Service.js +2 -2
- package/dist/proxy/Service.js.map +1 -1
- package/dist/server/Methods.d.ts +2 -2
- package/dist/server/Methods.d.ts.map +1 -1
- package/dist/server/Methods.js +2 -2
- package/dist/server/Methods.js.map +1 -1
- package/dist/server/Mppx.d.ts +17 -17
- package/dist/server/Mppx.d.ts.map +1 -1
- package/dist/server/Mppx.js +9 -9
- package/dist/server/Mppx.js.map +1 -1
- package/dist/stripe/{Intents.d.ts → Methods.d.ts} +22 -22
- package/dist/stripe/Methods.d.ts.map +1 -0
- package/dist/stripe/Methods.js +42 -0
- package/dist/stripe/Methods.js.map +1 -0
- package/dist/stripe/client/Charge.d.ts +40 -27
- package/dist/stripe/client/Charge.d.ts.map +1 -1
- package/dist/stripe/client/Charge.js +15 -7
- package/dist/stripe/client/Charge.js.map +1 -1
- package/dist/stripe/client/{MethodIntents.d.ts → Methods.d.ts} +24 -23
- package/dist/stripe/client/Methods.d.ts.map +1 -0
- package/dist/stripe/client/{MethodIntents.js → Methods.js} +3 -3
- package/dist/stripe/client/Methods.js.map +1 -0
- package/dist/stripe/client/index.d.ts +1 -1
- package/dist/stripe/client/index.d.ts.map +1 -1
- package/dist/stripe/client/index.js +1 -1
- package/dist/stripe/client/index.js.map +1 -1
- package/dist/stripe/index.d.ts +1 -1
- package/dist/stripe/index.d.ts.map +1 -1
- package/dist/stripe/index.js +1 -1
- package/dist/stripe/index.js.map +1 -1
- package/dist/stripe/internal/types.d.ts +25 -0
- package/dist/stripe/internal/types.d.ts.map +1 -0
- package/dist/stripe/internal/types.js +2 -0
- package/dist/stripe/internal/types.js.map +1 -0
- package/dist/stripe/server/Charge.d.ts +47 -28
- package/dist/stripe/server/Charge.d.ts.map +1 -1
- package/dist/stripe/server/Charge.js +90 -32
- package/dist/stripe/server/Charge.js.map +1 -1
- package/dist/stripe/server/{MethodIntents.d.ts → Methods.d.ts} +24 -23
- package/dist/stripe/server/Methods.d.ts.map +1 -0
- package/dist/stripe/server/{MethodIntents.js → Methods.js} +3 -3
- package/dist/stripe/server/Methods.js.map +1 -0
- package/dist/stripe/server/index.d.ts +1 -1
- package/dist/stripe/server/index.d.ts.map +1 -1
- package/dist/stripe/server/index.js +1 -1
- package/dist/stripe/server/index.js.map +1 -1
- package/dist/tempo/{Intents.d.ts → Methods.d.ts} +72 -69
- package/dist/tempo/Methods.d.ts.map +1 -0
- package/dist/tempo/Methods.js +118 -0
- package/dist/tempo/Methods.js.map +1 -0
- package/dist/tempo/client/ChannelOps.d.ts +1 -1
- package/dist/tempo/client/ChannelOps.js +1 -1
- package/dist/tempo/client/Charge.d.ts +25 -25
- package/dist/tempo/client/Charge.d.ts.map +1 -1
- package/dist/tempo/client/Charge.js +3 -3
- package/dist/tempo/client/Charge.js.map +1 -1
- package/dist/tempo/client/{MethodIntents.d.ts → Methods.d.ts} +74 -70
- package/dist/tempo/client/Methods.d.ts.map +1 -0
- package/dist/tempo/client/{MethodIntents.js → Methods.js} +3 -3
- package/dist/tempo/client/Methods.js.map +1 -0
- package/dist/tempo/client/Session.d.ts +49 -45
- package/dist/tempo/client/Session.d.ts.map +1 -1
- package/dist/tempo/client/Session.js +4 -4
- package/dist/tempo/client/Session.js.map +1 -1
- package/dist/tempo/client/SessionManager.d.ts +1 -1
- package/dist/tempo/client/SessionManager.js +1 -1
- package/dist/tempo/client/index.d.ts +1 -1
- package/dist/tempo/client/index.d.ts.map +1 -1
- package/dist/tempo/client/index.js +1 -1
- package/dist/tempo/client/index.js.map +1 -1
- package/dist/tempo/index.d.ts +1 -1
- package/dist/tempo/index.d.ts.map +1 -1
- package/dist/tempo/index.js +1 -1
- package/dist/tempo/index.js.map +1 -1
- package/dist/tempo/server/Charge.d.ts +27 -27
- package/dist/tempo/server/Charge.d.ts.map +1 -1
- package/dist/tempo/server/Charge.js +3 -3
- package/dist/tempo/server/Charge.js.map +1 -1
- package/dist/tempo/server/{MethodIntents.d.ts → Methods.d.ts} +73 -69
- package/dist/tempo/server/Methods.d.ts.map +1 -0
- package/dist/tempo/server/{MethodIntents.js → Methods.js} +4 -4
- package/dist/tempo/server/Methods.js.map +1 -0
- package/dist/tempo/server/Session.d.ts +51 -47
- package/dist/tempo/server/Session.d.ts.map +1 -1
- package/dist/tempo/server/Session.js +4 -4
- package/dist/tempo/server/Session.js.map +1 -1
- package/dist/tempo/server/index.d.ts +6 -0
- package/dist/tempo/server/index.d.ts.map +1 -0
- package/dist/tempo/server/index.js +6 -0
- package/dist/tempo/server/index.js.map +1 -0
- package/package.json +2 -1
- package/src/Challenge.test-d.ts +3 -3
- package/src/Challenge.test.ts +7 -7
- package/src/Challenge.ts +34 -34
- package/src/Errors.test.ts +75 -21
- package/src/Errors.ts +74 -9
- package/src/Method.test.ts +76 -0
- package/src/Method.ts +228 -0
- package/src/PaymentRequest.test.ts +5 -5
- package/src/PaymentRequest.ts +15 -10
- package/src/cli.test.ts +12 -22
- package/src/cli.ts +74 -21
- package/src/client/Methods.ts +2 -2
- package/src/client/Mppx.test-d.ts +6 -6
- package/src/client/Mppx.test.ts +26 -22
- package/src/client/Mppx.ts +10 -10
- package/src/client/Transport.test.ts +6 -6
- package/src/client/internal/Fetch.ts +21 -24
- package/src/index.ts +1 -2
- package/src/mcp-sdk/client/McpClient.test.ts +1 -1
- package/src/mcp-sdk/client/McpClient.ts +11 -13
- package/src/middlewares/elysia.ts +1 -1
- package/src/middlewares/express.ts +1 -1
- package/src/middlewares/hono.ts +1 -1
- package/src/middlewares/internal/mppx.ts +10 -10
- package/src/middlewares/nextjs.ts +1 -1
- package/src/proxy/Service.ts +2 -2
- package/src/server/Methods.ts +2 -2
- package/src/server/Mppx.test-d.ts +27 -29
- package/src/server/Mppx.test.ts +23 -19
- package/src/server/Mppx.ts +43 -43
- package/src/server/Transport.test.ts +8 -8
- package/src/stripe/{Intents.test.ts → Methods.test.ts} +12 -12
- package/src/stripe/Methods.ts +45 -0
- package/src/stripe/client/Charge.test.ts +189 -0
- package/src/stripe/client/Charge.ts +29 -16
- package/src/stripe/client/{MethodIntents.ts → Methods.ts} +2 -2
- package/src/stripe/client/index.ts +1 -1
- package/src/stripe/index.ts +1 -1
- package/src/stripe/internal/types.ts +22 -0
- package/src/stripe/server/Charge.test.ts +241 -0
- package/src/stripe/server/Charge.ts +124 -38
- package/src/stripe/server/{MethodIntents.ts → Methods.ts} +2 -2
- package/src/stripe/server/index.ts +1 -1
- package/src/tempo/{Intents.test.ts → Methods.test.ts} +15 -15
- package/src/tempo/{Intents.ts → Methods.ts} +77 -22
- package/src/tempo/client/ChannelOps.ts +1 -1
- package/src/tempo/client/Charge.ts +3 -3
- package/src/tempo/client/{MethodIntents.ts → Methods.ts} +2 -2
- package/src/tempo/client/Session.ts +4 -4
- package/src/tempo/client/SessionManager.ts +1 -1
- package/src/tempo/client/index.ts +1 -1
- package/src/tempo/index.ts +1 -1
- package/src/tempo/server/Charge.ts +4 -7
- package/src/tempo/server/{MethodIntents.ts → Methods.ts} +3 -3
- package/src/tempo/server/Session.test.ts +4 -7
- package/src/tempo/server/Session.ts +6 -6
- package/src/tempo/server/index.ts +1 -1
- package/dist/Intent.d.ts +0 -101
- package/dist/Intent.d.ts.map +0 -1
- package/dist/Intent.js +0 -83
- package/dist/Intent.js.map +0 -1
- package/dist/MethodIntent.d.ts +0 -225
- package/dist/MethodIntent.d.ts.map +0 -1
- package/dist/MethodIntent.js +0 -156
- package/dist/MethodIntent.js.map +0 -1
- package/dist/stripe/Intents.d.ts.map +0 -1
- package/dist/stripe/Intents.js +0 -27
- package/dist/stripe/Intents.js.map +0 -1
- package/dist/stripe/client/MethodIntents.d.ts.map +0 -1
- package/dist/stripe/client/MethodIntents.js.map +0 -1
- package/dist/stripe/server/MethodIntents.d.ts.map +0 -1
- package/dist/stripe/server/MethodIntents.js.map +0 -1
- package/dist/tempo/Intents.d.ts.map +0 -1
- package/dist/tempo/Intents.js +0 -81
- package/dist/tempo/Intents.js.map +0 -1
- package/dist/tempo/client/MethodIntents.d.ts.map +0 -1
- package/dist/tempo/client/MethodIntents.js.map +0 -1
- package/dist/tempo/server/MethodIntents.d.ts.map +0 -1
- package/dist/tempo/server/MethodIntents.js.map +0 -1
- package/src/Intent.test.ts +0 -180
- package/src/Intent.ts +0 -109
- package/src/MethodIntent.test.ts +0 -303
- package/src/MethodIntent.ts +0 -388
- package/src/stripe/Intents.ts +0 -27
|
@@ -1,21 +1,36 @@
|
|
|
1
1
|
import { PaymentActionRequiredError, PaymentExpiredError, VerificationFailedError, } from '../../Errors.js';
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
2
|
+
import * as Method from '../../Method.js';
|
|
3
|
+
import * as Methods from '../Methods.js';
|
|
4
4
|
/**
|
|
5
5
|
* Creates a Stripe charge method intent for usage on the server.
|
|
6
6
|
*
|
|
7
7
|
* Verifies payment by creating a Stripe PaymentIntent with the provided SPT.
|
|
8
8
|
*
|
|
9
|
+
* Accepts either a `client` (a pre-configured Stripe SDK instance) or a raw
|
|
10
|
+
* `secretKey`. Using `client` is recommended—it lets you configure retries,
|
|
11
|
+
* API version, and other options on the Stripe instance you control.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import Stripe from 'stripe'
|
|
16
|
+
* import { stripe } from 'mppx/server'
|
|
17
|
+
*
|
|
18
|
+
* const stripeClient = new Stripe(process.env.STRIPE_SECRET_KEY!)
|
|
19
|
+
* const charge = stripe.charge({ client: stripeClient, networkId: 'internal', paymentMethodTypes: ['card'] })
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
9
22
|
* @example
|
|
10
23
|
* ```ts
|
|
11
24
|
* import { stripe } from 'mppx/server'
|
|
12
25
|
*
|
|
13
|
-
* const charge = stripe.charge({ secretKey: 'sk_...' })
|
|
26
|
+
* const charge = stripe.charge({ secretKey: 'sk_...', networkId: 'internal', paymentMethodTypes: ['card'] })
|
|
14
27
|
* ```
|
|
15
28
|
*/
|
|
16
29
|
export function charge(parameters) {
|
|
17
|
-
const { amount, currency, decimals, description, externalId, metadata, networkId, paymentMethodTypes,
|
|
18
|
-
|
|
30
|
+
const { amount, currency, decimals, description, externalId, metadata, networkId, paymentMethodTypes, } = parameters;
|
|
31
|
+
const client = 'client' in parameters ? parameters.client : undefined;
|
|
32
|
+
const secretKey = 'secretKey' in parameters ? parameters.secretKey : undefined;
|
|
33
|
+
return Method.toServer(Methods.charge, {
|
|
19
34
|
defaults: {
|
|
20
35
|
amount,
|
|
21
36
|
currency,
|
|
@@ -31,36 +46,21 @@ export function charge(parameters) {
|
|
|
31
46
|
const { request } = challenge;
|
|
32
47
|
if (request.expires && new Date(request.expires) < new Date())
|
|
33
48
|
throw new PaymentExpiredError({ expires: request.expires });
|
|
34
|
-
const parsed =
|
|
49
|
+
const parsed = Methods.charge.schema.credential.payload.safeParse(credential.payload);
|
|
35
50
|
if (!parsed.success)
|
|
36
51
|
throw new Error('Invalid credential payload: missing or malformed spt');
|
|
37
52
|
const { spt, externalId: credentialExternalId } = parsed.data;
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
body.set(`metadata[${key}]`, value);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
const response = await fetch('https://api.stripe.com/v1/payment_intents', {
|
|
53
|
-
method: 'POST',
|
|
54
|
-
headers: {
|
|
55
|
-
Authorization: `Basic ${btoa(`${secretKey}:`)}`,
|
|
56
|
-
'Content-Type': 'application/x-www-form-urlencoded',
|
|
57
|
-
'Idempotency-Key': `mppx_${challenge.id}_${spt}`,
|
|
58
|
-
},
|
|
59
|
-
body,
|
|
60
|
-
});
|
|
61
|
-
if (!response.ok)
|
|
62
|
-
throw new VerificationFailedError({ reason: 'Stripe PaymentIntent failed' });
|
|
63
|
-
const pi = (await response.json());
|
|
53
|
+
const userMetadata = request.methodDetails?.metadata;
|
|
54
|
+
const resolvedMetadata = { ...buildAnalytics({ credential }), ...userMetadata };
|
|
55
|
+
const pi = client
|
|
56
|
+
? await createWithClient({ client, challenge, request, spt, metadata: resolvedMetadata })
|
|
57
|
+
: await createWithSecretKey({
|
|
58
|
+
secretKey: secretKey,
|
|
59
|
+
challenge,
|
|
60
|
+
request,
|
|
61
|
+
spt,
|
|
62
|
+
metadata: resolvedMetadata,
|
|
63
|
+
});
|
|
64
64
|
if (pi.status === 'requires_action') {
|
|
65
65
|
throw new PaymentActionRequiredError({ reason: 'Stripe PaymentIntent requires action' });
|
|
66
66
|
}
|
|
@@ -76,4 +76,62 @@ export function charge(parameters) {
|
|
|
76
76
|
},
|
|
77
77
|
});
|
|
78
78
|
}
|
|
79
|
+
/** Creates a PaymentIntent using the Stripe SDK client. */
|
|
80
|
+
async function createWithClient(parameters) {
|
|
81
|
+
const { client, challenge, metadata, request, spt } = parameters;
|
|
82
|
+
try {
|
|
83
|
+
const result = await client.paymentIntents.create({
|
|
84
|
+
amount: Number(request.amount),
|
|
85
|
+
automatic_payment_methods: { allow_redirects: 'never', enabled: true },
|
|
86
|
+
confirm: true,
|
|
87
|
+
currency: request.currency,
|
|
88
|
+
metadata,
|
|
89
|
+
payment_method: spt,
|
|
90
|
+
}, { idempotencyKey: `mppx_${challenge.id}_${spt}` });
|
|
91
|
+
return { id: result.id, status: result.status };
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
throw new VerificationFailedError({ reason: 'Stripe PaymentIntent failed' });
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/** Creates a PaymentIntent using a raw secret key and fetch. */
|
|
98
|
+
async function createWithSecretKey(parameters) {
|
|
99
|
+
const { secretKey, challenge, metadata, request, spt } = parameters;
|
|
100
|
+
const body = new URLSearchParams({
|
|
101
|
+
amount: request.amount,
|
|
102
|
+
'automatic_payment_methods[allow_redirects]': 'never',
|
|
103
|
+
'automatic_payment_methods[enabled]': 'true',
|
|
104
|
+
confirm: 'true',
|
|
105
|
+
currency: request.currency,
|
|
106
|
+
shared_payment_granted_token: spt,
|
|
107
|
+
});
|
|
108
|
+
for (const [key, value] of Object.entries(metadata)) {
|
|
109
|
+
body.set(`metadata[${key}]`, value);
|
|
110
|
+
}
|
|
111
|
+
const response = await fetch('https://api.stripe.com/v1/payment_intents', {
|
|
112
|
+
method: 'POST',
|
|
113
|
+
headers: {
|
|
114
|
+
Authorization: `Basic ${btoa(`${secretKey}:`)}`,
|
|
115
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
116
|
+
'Idempotency-Key': `mppx_${challenge.id}_${spt}`,
|
|
117
|
+
},
|
|
118
|
+
body,
|
|
119
|
+
});
|
|
120
|
+
if (!response.ok)
|
|
121
|
+
throw new VerificationFailedError({ reason: 'Stripe PaymentIntent failed' });
|
|
122
|
+
return (await response.json());
|
|
123
|
+
}
|
|
124
|
+
/** @internal */
|
|
125
|
+
function buildAnalytics(parameters) {
|
|
126
|
+
const { credential } = parameters;
|
|
127
|
+
const { challenge } = credential;
|
|
128
|
+
return {
|
|
129
|
+
mpp_version: '1',
|
|
130
|
+
mpp_is_mpp: 'true',
|
|
131
|
+
mpp_intent: challenge.intent,
|
|
132
|
+
mpp_challenge_id: challenge.id,
|
|
133
|
+
mpp_server_id: challenge.realm,
|
|
134
|
+
...(credential.source ? { mpp_client_id: credential.source } : {}),
|
|
135
|
+
};
|
|
136
|
+
}
|
|
79
137
|
//# sourceMappingURL=Charge.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Charge.js","sourceRoot":"","sources":["../../../src/stripe/server/Charge.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Charge.js","sourceRoot":"","sources":["../../../src/stripe/server/Charge.ts"],"names":[],"mappings":"AACA,OAAO,EACL,0BAA0B,EAC1B,mBAAmB,EACnB,uBAA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ACpD,IAAI,CAAC,GAAG,CAAC,YAAY,GAAG,GAAG,EAAE,KAAK,CAAC,CAAA;IACrC,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,2CAA2C,EAAE;QACxE,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACP,aAAa,EAAE,SAAS,IAAI,CAAC,GAAG,SAAS,GAAG,CAAC,EAAE;YAC/C,cAAc,EAAE,mCAAmC;YACnD,iBAAiB,EAAE,QAAQ,SAAS,CAAC,EAAE,IAAI,GAAG,EAAE;SACjD;QACD,IAAI;KACL,CAAC,CAAA;IAEF,IAAI,CAAC,QAAQ,CAAC,EAAE;QAAE,MAAM,IAAI,uBAAuB,CAAC,EAAE,MAAM,EAAE,6BAA6B,EAAE,CAAC,CAAA;IAC9F,OAAO,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAmC,CAAA;AAClE,CAAC;AAED,gBAAgB;AAChB,SAAS,cAAc,CAAC,UAAiD;IACvE,MAAM,EAAE,UAAU,EAAE,GAAG,UAAU,CAAA;IACjC,MAAM,EAAE,SAAS,EAAE,GAAG,UAAU,CAAA;IAChC,OAAO;QACL,WAAW,EAAE,GAAG;QAChB,UAAU,EAAE,MAAM;QAClB,UAAU,EAAE,SAAS,CAAC,MAAM;QAC5B,gBAAgB,EAAE,SAAS,CAAC,EAAE;QAC9B,aAAa,EAAE,SAAS,CAAC,KAAK;QAC9B,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACnE,CAAA;AACH,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { charge as charge_ } from './Charge.js';
|
|
2
2
|
/**
|
|
3
|
-
* Creates a Stripe `charge` method
|
|
3
|
+
* Creates a Stripe `charge` method for usage on the server.
|
|
4
4
|
*
|
|
5
5
|
* @example
|
|
6
6
|
* ```ts
|
|
@@ -11,9 +11,16 @@ import { charge as charge_ } from './Charge.js';
|
|
|
11
11
|
* })
|
|
12
12
|
* ```
|
|
13
13
|
*/
|
|
14
|
-
export declare function stripe<const parameters extends stripe.Parameters>(parameters: parameters): readonly [import("../../
|
|
15
|
-
readonly name: "
|
|
14
|
+
export declare function stripe<const parameters extends stripe.Parameters>(parameters: parameters): readonly [import("../../Method.js").Server<{
|
|
15
|
+
readonly name: "stripe";
|
|
16
|
+
readonly intent: "charge";
|
|
16
17
|
readonly schema: {
|
|
18
|
+
readonly credential: {
|
|
19
|
+
readonly payload: import("zod/mini").ZodMiniObject<{
|
|
20
|
+
externalId: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniString<string>>;
|
|
21
|
+
spt: import("zod/mini").ZodMiniString<string>;
|
|
22
|
+
}, import("zod/v4/core").$strip>;
|
|
23
|
+
};
|
|
17
24
|
readonly request: import("zod/mini").ZodMiniPipe<import("zod/mini").ZodMiniObject<{
|
|
18
25
|
amount: import("zod/mini").ZodMiniString<string>;
|
|
19
26
|
currency: import("zod/mini").ZodMiniString<string>;
|
|
@@ -21,9 +28,17 @@ export declare function stripe<const parameters extends stripe.Parameters>(param
|
|
|
21
28
|
description: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniString<string>>;
|
|
22
29
|
expires: import("zod/mini").ZodMiniDefault<import("zod/mini").ZodMiniString<string>>;
|
|
23
30
|
externalId: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniString<string>>;
|
|
31
|
+
metadata: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniRecord<import("zod/mini").ZodMiniString<string>, import("zod/mini").ZodMiniString<string>>>;
|
|
32
|
+
networkId: import("zod/mini").ZodMiniString<string>;
|
|
33
|
+
paymentMethodTypes: import("zod/mini").ZodMiniArray<import("zod/mini").ZodMiniString<string>>;
|
|
24
34
|
recipient: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniString<string>>;
|
|
25
35
|
}, import("zod/v4/core").$strip>, import("zod/mini").ZodMiniTransform<{
|
|
26
36
|
amount: string;
|
|
37
|
+
methodDetails: {
|
|
38
|
+
metadata?: Record<string, string> | undefined;
|
|
39
|
+
networkId: string;
|
|
40
|
+
paymentMethodTypes: string[];
|
|
41
|
+
};
|
|
27
42
|
currency: string;
|
|
28
43
|
expires: string;
|
|
29
44
|
description?: string | undefined;
|
|
@@ -34,32 +49,18 @@ export declare function stripe<const parameters extends stripe.Parameters>(param
|
|
|
34
49
|
currency: string;
|
|
35
50
|
decimals: number;
|
|
36
51
|
expires: string;
|
|
52
|
+
networkId: string;
|
|
53
|
+
paymentMethodTypes: string[];
|
|
37
54
|
description?: string | undefined;
|
|
38
55
|
externalId?: string | undefined;
|
|
56
|
+
metadata?: Record<string, string> | undefined;
|
|
39
57
|
recipient?: string | undefined;
|
|
40
58
|
}>>;
|
|
41
59
|
};
|
|
42
|
-
},
|
|
43
|
-
readonly method: "stripe";
|
|
44
|
-
readonly schema: {
|
|
45
|
-
readonly credential: {
|
|
46
|
-
readonly payload: import("zod/mini").ZodMiniObject<{
|
|
47
|
-
spt: import("zod/mini").ZodMiniString<string>;
|
|
48
|
-
externalId: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniString<string>>;
|
|
49
|
-
}, import("zod/v4/core").$strip>;
|
|
50
|
-
};
|
|
51
|
-
readonly request: {
|
|
52
|
-
readonly methodDetails: import("zod/mini").ZodMiniObject<{
|
|
53
|
-
networkId: import("zod/mini").ZodMiniString<string>;
|
|
54
|
-
paymentMethodTypes: import("zod/mini").ZodMiniArray<import("zod/mini").ZodMiniString<string>>;
|
|
55
|
-
metadata: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniRecord<import("zod/mini").ZodMiniString<string>, import("zod/mini").ZodMiniString<string>>>;
|
|
56
|
-
}, import("zod/v4/core").$strip>;
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
}>, charge_.DeriveDefaults<parameters>, undefined>];
|
|
60
|
+
}, charge_.DeriveDefaults<parameters>, undefined>];
|
|
60
61
|
export declare namespace stripe {
|
|
61
62
|
type Parameters = charge_.Parameters;
|
|
62
|
-
/** Creates a Stripe `charge` method
|
|
63
|
+
/** Creates a Stripe `charge` method for SPT-based payments. */
|
|
63
64
|
const charge: typeof charge_;
|
|
64
65
|
}
|
|
65
|
-
//# sourceMappingURL=
|
|
66
|
+
//# sourceMappingURL=Methods.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Methods.d.ts","sourceRoot":"","sources":["../../../src/stripe/server/Methods.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,OAAO,EAAE,MAAM,aAAa,CAAA;AAE/C;;;;;;;;;;;GAWG;AACH,wBAAgB,MAAM,CAAC,KAAK,CAAC,UAAU,SAAS,MAAM,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mDAExF;AAED,yBAAiB,MAAM,CAAC;IACtB,KAAY,UAAU,GAAG,OAAO,CAAC,UAAU,CAAA;IAE3C,+DAA+D;IACxD,MAAM,MAAM,gBAAU,CAAA;CAC9B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { charge as charge_ } from './Charge.js';
|
|
2
2
|
/**
|
|
3
|
-
* Creates a Stripe `charge` method
|
|
3
|
+
* Creates a Stripe `charge` method for usage on the server.
|
|
4
4
|
*
|
|
5
5
|
* @example
|
|
6
6
|
* ```ts
|
|
@@ -15,7 +15,7 @@ export function stripe(parameters) {
|
|
|
15
15
|
return [stripe.charge(parameters)];
|
|
16
16
|
}
|
|
17
17
|
(function (stripe) {
|
|
18
|
-
/** Creates a Stripe `charge` method
|
|
18
|
+
/** Creates a Stripe `charge` method for SPT-based payments. */
|
|
19
19
|
stripe.charge = charge_;
|
|
20
20
|
})(stripe || (stripe = {}));
|
|
21
|
-
//# sourceMappingURL=
|
|
21
|
+
//# sourceMappingURL=Methods.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Methods.js","sourceRoot":"","sources":["../../../src/stripe/server/Methods.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,OAAO,EAAE,MAAM,aAAa,CAAA;AAE/C;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,MAAM,CAA6C,UAAsB;IACvF,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAU,CAAA;AAC7C,CAAC;AAED,WAAiB,MAAM;IAGrB,+DAA+D;IAClD,aAAM,GAAG,OAAO,CAAA;AAC/B,CAAC,EALgB,MAAM,KAAN,MAAM,QAKtB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/stripe/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/stripe/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/stripe/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/stripe/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA"}
|
|
@@ -1,23 +1,40 @@
|
|
|
1
1
|
import type { Account } from 'viem';
|
|
2
|
-
import * as MethodIntent from '../MethodIntent.js';
|
|
3
2
|
import * as z from '../zod.js';
|
|
4
3
|
/**
|
|
5
4
|
* Tempo charge intent for one-time TIP-20 token transfers.
|
|
6
5
|
*
|
|
7
6
|
* @see https://github.com/tempoxyz/payment-auth-spec/blob/main/specs/methods/tempo/draft-tempo-charge-00.md
|
|
8
7
|
*/
|
|
9
|
-
export declare const charge:
|
|
10
|
-
readonly name: "
|
|
8
|
+
export declare const charge: {
|
|
9
|
+
readonly name: "tempo";
|
|
10
|
+
readonly intent: "charge";
|
|
11
11
|
readonly schema: {
|
|
12
|
+
readonly credential: {
|
|
13
|
+
readonly payload: z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
|
|
14
|
+
hash: z.ZodMiniString<string>;
|
|
15
|
+
type: z.ZodMiniLiteral<"hash">;
|
|
16
|
+
}, z.core.$strip>, z.ZodMiniObject<{
|
|
17
|
+
signature: z.ZodMiniString<string>;
|
|
18
|
+
type: z.ZodMiniLiteral<"transaction">;
|
|
19
|
+
}, z.core.$strip>], "type">;
|
|
20
|
+
};
|
|
12
21
|
readonly request: z.ZodMiniPipe<z.ZodMiniObject<{
|
|
13
22
|
amount: z.ZodMiniString<string>;
|
|
23
|
+
chainId: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
14
24
|
currency: z.ZodMiniString<string>;
|
|
15
25
|
decimals: z.ZodMiniNumber<number>;
|
|
16
26
|
description: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
17
27
|
expires: z.ZodMiniDefault<z.ZodMiniString<string>>;
|
|
18
28
|
externalId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
29
|
+
feePayer: z.ZodMiniOptional<z.ZodMiniPipe<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniCustom<Account, Account>]>, z.ZodMiniTransform<boolean, boolean | Account>>>;
|
|
30
|
+
memo: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
19
31
|
recipient: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
20
32
|
}, z.core.$strip>, z.ZodMiniTransform<{
|
|
33
|
+
methodDetails?: {
|
|
34
|
+
memo?: string | undefined;
|
|
35
|
+
feePayer?: boolean | undefined;
|
|
36
|
+
chainId?: number | undefined;
|
|
37
|
+
} | undefined;
|
|
21
38
|
amount: string;
|
|
22
39
|
currency: string;
|
|
23
40
|
expires: string;
|
|
@@ -29,82 +46,40 @@ export declare const charge: MethodIntent.MethodIntent<{
|
|
|
29
46
|
currency: string;
|
|
30
47
|
decimals: number;
|
|
31
48
|
expires: string;
|
|
49
|
+
chainId?: number | undefined;
|
|
32
50
|
description?: string | undefined;
|
|
33
51
|
externalId?: string | undefined;
|
|
52
|
+
feePayer?: boolean | undefined;
|
|
53
|
+
memo?: string | undefined;
|
|
34
54
|
recipient?: string | undefined;
|
|
35
55
|
}>>;
|
|
36
56
|
};
|
|
37
|
-
}
|
|
38
|
-
readonly method: "tempo";
|
|
39
|
-
readonly schema: {
|
|
40
|
-
readonly credential: {
|
|
41
|
-
readonly payload: z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
|
|
42
|
-
hash: z.ZodMiniString<string>;
|
|
43
|
-
type: z.ZodMiniLiteral<"hash">;
|
|
44
|
-
}, z.core.$strip>, z.ZodMiniObject<{
|
|
45
|
-
signature: z.ZodMiniString<string>;
|
|
46
|
-
type: z.ZodMiniLiteral<"transaction">;
|
|
47
|
-
}, z.core.$strip>], "type">;
|
|
48
|
-
};
|
|
49
|
-
readonly request: {
|
|
50
|
-
readonly methodDetails: z.ZodMiniObject<{
|
|
51
|
-
chainId: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
52
|
-
feePayer: z.ZodMiniOptional<z.ZodMiniPipe<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniCustom<Account, Account>]>, z.ZodMiniTransform<boolean, boolean | Account>>>;
|
|
53
|
-
memo: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
54
|
-
}, z.core.$strip>;
|
|
55
|
-
readonly requires: readonly ["decimals", "recipient"];
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
}>;
|
|
57
|
+
};
|
|
59
58
|
/**
|
|
60
59
|
* Tempo session intent for pay-as-you-go streaming payments.
|
|
61
60
|
*
|
|
62
61
|
* Uses cumulative vouchers over a payment channel. Credential payloads
|
|
63
62
|
* are a discriminated union on `action`: open, topUp, voucher, close.
|
|
64
63
|
*/
|
|
65
|
-
export declare const session:
|
|
66
|
-
readonly name: "
|
|
67
|
-
readonly
|
|
68
|
-
readonly request: z.ZodMiniPipe<z.ZodMiniObject<{
|
|
69
|
-
amount: z.ZodMiniString<string>;
|
|
70
|
-
unitType: z.ZodMiniString<string>;
|
|
71
|
-
currency: z.ZodMiniString<string>;
|
|
72
|
-
decimals: z.ZodMiniNumber<number>;
|
|
73
|
-
recipient: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
74
|
-
suggestedDeposit: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
75
|
-
}, z.core.$strip>, z.ZodMiniTransform<{
|
|
76
|
-
suggestedDeposit?: string | undefined;
|
|
77
|
-
amount: string;
|
|
78
|
-
unitType: string;
|
|
79
|
-
currency: string;
|
|
80
|
-
recipient?: string | undefined;
|
|
81
|
-
}, {
|
|
82
|
-
amount: string;
|
|
83
|
-
unitType: string;
|
|
84
|
-
currency: string;
|
|
85
|
-
decimals: number;
|
|
86
|
-
recipient?: string | undefined;
|
|
87
|
-
suggestedDeposit?: string | undefined;
|
|
88
|
-
}>>;
|
|
89
|
-
};
|
|
90
|
-
}, {
|
|
91
|
-
readonly method: "tempo";
|
|
64
|
+
export declare const session: {
|
|
65
|
+
readonly name: "tempo";
|
|
66
|
+
readonly intent: "session";
|
|
92
67
|
readonly schema: {
|
|
93
68
|
readonly credential: {
|
|
94
69
|
readonly payload: z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
|
|
95
70
|
action: z.ZodMiniLiteral<"open">;
|
|
96
|
-
type: z.ZodMiniLiteral<"transaction">;
|
|
97
|
-
channelId: z.ZodMiniString<string>;
|
|
98
|
-
transaction: z.ZodMiniString<string>;
|
|
99
71
|
authorizedSigner: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
72
|
+
channelId: z.ZodMiniString<string>;
|
|
100
73
|
cumulativeAmount: z.ZodMiniString<string>;
|
|
101
74
|
signature: z.ZodMiniString<string>;
|
|
75
|
+
transaction: z.ZodMiniString<string>;
|
|
76
|
+
type: z.ZodMiniLiteral<"transaction">;
|
|
102
77
|
}, z.core.$strip>, z.ZodMiniObject<{
|
|
103
78
|
action: z.ZodMiniLiteral<"topUp">;
|
|
104
|
-
|
|
79
|
+
additionalDeposit: z.ZodMiniString<string>;
|
|
105
80
|
channelId: z.ZodMiniString<string>;
|
|
106
81
|
transaction: z.ZodMiniString<string>;
|
|
107
|
-
|
|
82
|
+
type: z.ZodMiniLiteral<"transaction">;
|
|
108
83
|
}, z.core.$strip>, z.ZodMiniObject<{
|
|
109
84
|
action: z.ZodMiniLiteral<"voucher">;
|
|
110
85
|
channelId: z.ZodMiniString<string>;
|
|
@@ -117,16 +92,44 @@ export declare const session: MethodIntent.MethodIntent<{
|
|
|
117
92
|
signature: z.ZodMiniString<string>;
|
|
118
93
|
}, z.core.$strip>], "action">;
|
|
119
94
|
};
|
|
120
|
-
readonly request: {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
95
|
+
readonly request: z.ZodMiniPipe<z.ZodMiniObject<{
|
|
96
|
+
amount: z.ZodMiniString<string>;
|
|
97
|
+
chainId: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
98
|
+
channelId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
99
|
+
currency: z.ZodMiniString<string>;
|
|
100
|
+
decimals: z.ZodMiniNumber<number>;
|
|
101
|
+
escrowContract: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
102
|
+
feePayer: z.ZodMiniOptional<z.ZodMiniPipe<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniCustom<Account, Account>]>, z.ZodMiniTransform<boolean, boolean | Account>>>;
|
|
103
|
+
minVoucherDelta: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
104
|
+
recipient: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
105
|
+
suggestedDeposit: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
106
|
+
unitType: z.ZodMiniString<string>;
|
|
107
|
+
}, z.core.$strip>, z.ZodMiniTransform<{
|
|
108
|
+
methodDetails: {
|
|
109
|
+
feePayer?: boolean | undefined;
|
|
110
|
+
chainId?: number | undefined;
|
|
111
|
+
minVoucherDelta?: string | undefined;
|
|
112
|
+
channelId?: string | undefined;
|
|
113
|
+
escrowContract: string | undefined;
|
|
114
|
+
};
|
|
115
|
+
suggestedDeposit?: string | undefined;
|
|
116
|
+
amount: string;
|
|
117
|
+
currency: string;
|
|
118
|
+
unitType: string;
|
|
119
|
+
recipient?: string | undefined;
|
|
120
|
+
}, {
|
|
121
|
+
amount: string;
|
|
122
|
+
currency: string;
|
|
123
|
+
decimals: number;
|
|
124
|
+
unitType: string;
|
|
125
|
+
chainId?: number | undefined;
|
|
126
|
+
channelId?: string | undefined;
|
|
127
|
+
escrowContract?: string | undefined;
|
|
128
|
+
feePayer?: boolean | undefined;
|
|
129
|
+
minVoucherDelta?: string | undefined;
|
|
130
|
+
recipient?: string | undefined;
|
|
131
|
+
suggestedDeposit?: string | undefined;
|
|
132
|
+
}>>;
|
|
130
133
|
};
|
|
131
|
-
}
|
|
132
|
-
//# sourceMappingURL=
|
|
134
|
+
};
|
|
135
|
+
//# sourceMappingURL=Methods.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Methods.d.ts","sourceRoot":"","sources":["../../src/tempo/Methods.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAInC,OAAO,KAAK,CAAC,MAAM,WAAW,CAAA;AAE9B;;;;GAIG;AACH,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2CjB,CAAA;AAEF;;;;;GAKG;AACH,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqFlB,CAAA"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { parseUnits } from 'viem';
|
|
2
|
+
import * as Expires from '../Expires.js';
|
|
3
|
+
import * as Method from '../Method.js';
|
|
4
|
+
import * as z from '../zod.js';
|
|
5
|
+
/**
|
|
6
|
+
* Tempo charge intent for one-time TIP-20 token transfers.
|
|
7
|
+
*
|
|
8
|
+
* @see https://github.com/tempoxyz/payment-auth-spec/blob/main/specs/methods/tempo/draft-tempo-charge-00.md
|
|
9
|
+
*/
|
|
10
|
+
export const charge = Method.from({
|
|
11
|
+
name: 'tempo',
|
|
12
|
+
intent: 'charge',
|
|
13
|
+
schema: {
|
|
14
|
+
credential: {
|
|
15
|
+
payload: z.discriminatedUnion('type', [
|
|
16
|
+
z.object({ hash: z.hash(), type: z.literal('hash') }),
|
|
17
|
+
z.object({ signature: z.signature(), type: z.literal('transaction') }),
|
|
18
|
+
]),
|
|
19
|
+
},
|
|
20
|
+
request: z.pipe(z.object({
|
|
21
|
+
amount: z.amount(),
|
|
22
|
+
chainId: z.optional(z.number()),
|
|
23
|
+
currency: z.string(),
|
|
24
|
+
decimals: z.number(),
|
|
25
|
+
description: z.optional(z.string()),
|
|
26
|
+
expires: z._default(z.datetime(), () => Expires.minutes(5)),
|
|
27
|
+
externalId: z.optional(z.string()),
|
|
28
|
+
feePayer: z.optional(z.pipe(z.union([z.boolean(), z.custom()]), z.transform((v) => (typeof v === 'object' ? true : v)))),
|
|
29
|
+
memo: z.optional(z.hash()),
|
|
30
|
+
recipient: z.optional(z.string()),
|
|
31
|
+
}), z.transform(({ amount, chainId, decimals, feePayer, memo, ...rest }) => ({
|
|
32
|
+
...rest,
|
|
33
|
+
amount: parseUnits(amount, decimals).toString(),
|
|
34
|
+
...(chainId !== undefined || feePayer !== undefined || memo !== undefined
|
|
35
|
+
? {
|
|
36
|
+
methodDetails: {
|
|
37
|
+
...(chainId !== undefined && { chainId }),
|
|
38
|
+
...(feePayer !== undefined && { feePayer }),
|
|
39
|
+
...(memo !== undefined && { memo }),
|
|
40
|
+
},
|
|
41
|
+
}
|
|
42
|
+
: {}),
|
|
43
|
+
}))),
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
/**
|
|
47
|
+
* Tempo session intent for pay-as-you-go streaming payments.
|
|
48
|
+
*
|
|
49
|
+
* Uses cumulative vouchers over a payment channel. Credential payloads
|
|
50
|
+
* are a discriminated union on `action`: open, topUp, voucher, close.
|
|
51
|
+
*/
|
|
52
|
+
export const session = Method.from({
|
|
53
|
+
name: 'tempo',
|
|
54
|
+
intent: 'session',
|
|
55
|
+
schema: {
|
|
56
|
+
credential: {
|
|
57
|
+
payload: z.discriminatedUnion('action', [
|
|
58
|
+
z.object({
|
|
59
|
+
action: z.literal('open'),
|
|
60
|
+
authorizedSigner: z.optional(z.string()),
|
|
61
|
+
channelId: z.hash(),
|
|
62
|
+
cumulativeAmount: z.amount(),
|
|
63
|
+
signature: z.signature(),
|
|
64
|
+
transaction: z.signature(),
|
|
65
|
+
type: z.literal('transaction'),
|
|
66
|
+
}),
|
|
67
|
+
z.object({
|
|
68
|
+
action: z.literal('topUp'),
|
|
69
|
+
additionalDeposit: z.amount(),
|
|
70
|
+
channelId: z.hash(),
|
|
71
|
+
transaction: z.signature(),
|
|
72
|
+
type: z.literal('transaction'),
|
|
73
|
+
}),
|
|
74
|
+
z.object({
|
|
75
|
+
action: z.literal('voucher'),
|
|
76
|
+
channelId: z.hash(),
|
|
77
|
+
cumulativeAmount: z.amount(),
|
|
78
|
+
signature: z.signature(),
|
|
79
|
+
}),
|
|
80
|
+
z.object({
|
|
81
|
+
action: z.literal('close'),
|
|
82
|
+
channelId: z.hash(),
|
|
83
|
+
cumulativeAmount: z.amount(),
|
|
84
|
+
signature: z.signature(),
|
|
85
|
+
}),
|
|
86
|
+
]),
|
|
87
|
+
},
|
|
88
|
+
request: z.pipe(z.object({
|
|
89
|
+
amount: z.amount(),
|
|
90
|
+
chainId: z.optional(z.number()),
|
|
91
|
+
channelId: z.optional(z.hash()),
|
|
92
|
+
currency: z.string(),
|
|
93
|
+
decimals: z.number(),
|
|
94
|
+
escrowContract: z.optional(z.string()),
|
|
95
|
+
feePayer: z.optional(z.pipe(z.union([z.boolean(), z.custom()]), z.transform((v) => (typeof v === 'object' ? true : v)))),
|
|
96
|
+
minVoucherDelta: z.optional(z.amount()),
|
|
97
|
+
recipient: z.optional(z.string()),
|
|
98
|
+
suggestedDeposit: z.optional(z.amount()),
|
|
99
|
+
unitType: z.string(),
|
|
100
|
+
}), z.transform(({ amount, chainId, channelId, decimals, escrowContract, feePayer, minVoucherDelta, suggestedDeposit, ...rest }) => ({
|
|
101
|
+
...rest,
|
|
102
|
+
amount: parseUnits(amount, decimals).toString(),
|
|
103
|
+
...(suggestedDeposit
|
|
104
|
+
? {
|
|
105
|
+
suggestedDeposit: parseUnits(suggestedDeposit, decimals).toString(),
|
|
106
|
+
}
|
|
107
|
+
: {}),
|
|
108
|
+
methodDetails: {
|
|
109
|
+
escrowContract,
|
|
110
|
+
...(channelId !== undefined && { channelId }),
|
|
111
|
+
...(minVoucherDelta !== undefined && { minVoucherDelta }),
|
|
112
|
+
...(chainId !== undefined && { chainId }),
|
|
113
|
+
...(feePayer !== undefined && { feePayer }),
|
|
114
|
+
},
|
|
115
|
+
}))),
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
//# sourceMappingURL=Methods.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
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AAQ,EACR,cAAc,EACd,QAAQ,EACR,eAAe,EACf,gBAAgB,EAChB,GAAG,IAAI,EACR,EAAE,EAAE,CAAC,CAAC;YACL,GAAG,IAAI;YACP,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,QAAQ,EAAE;YAC/C,GAAG,CAAC,gBAAgB;gBAClB,CAAC,CAAC;oBACE,gBAAgB,EAAE,UAAU,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAAC,QAAQ,EAAE;iBACpE;gBACH,CAAC,CAAC,EAAE,CAAC;YACP,aAAa,EAAE;gBACb,cAAc;gBACd,GAAG,CAAC,SAAS,KAAK,SAAS,IAAI,EAAE,SAAS,EAAE,CAAC;gBAC7C,GAAG,CAAC,eAAe,KAAK,SAAS,IAAI,EAAE,eAAe,EAAE,CAAC;gBACzD,GAAG,CAAC,OAAO,KAAK,SAAS,IAAI,EAAE,OAAO,EAAE,CAAC;gBACzC,GAAG,CAAC,QAAQ,KAAK,SAAS,IAAI,EAAE,QAAQ,EAAE,CAAC;aAC5C;SACF,CAAC,CACH,CACF;KACF;CACF,CAAC,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Shared client-side channel operations.
|
|
3
3
|
*
|
|
4
|
-
* Provides the low-level helpers that both `session()`
|
|
4
|
+
* Provides the low-level helpers that both `session()`
|
|
5
5
|
* and `sessionManager()` (orchestrator) rely on: escrow resolution, channel
|
|
6
6
|
* ID computation, on-chain open/voucher/close payload construction, channel
|
|
7
7
|
* recovery from on-chain state, and credential serialization.
|