mppx 0.3.13 → 0.3.15
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 +1 -1
- package/dist/Challenge.d.ts.map +1 -1
- package/dist/Challenge.js +107 -15
- package/dist/Challenge.js.map +1 -1
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +4 -0
- package/dist/bin.js.map +1 -0
- package/dist/cli.d.ts +26 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +1478 -915
- package/dist/cli.js.map +1 -1
- package/dist/client/Mppx.d.ts +2 -0
- package/dist/client/Mppx.d.ts.map +1 -1
- package/dist/client/Mppx.js +2 -0
- package/dist/client/Mppx.js.map +1 -1
- package/dist/server/Mppx.d.ts.map +1 -1
- package/dist/server/Mppx.js +2 -1
- package/dist/server/Mppx.js.map +1 -1
- package/dist/stripe/Methods.d.ts +0 -3
- package/dist/stripe/Methods.d.ts.map +1 -1
- package/dist/stripe/Methods.js +0 -2
- package/dist/stripe/Methods.js.map +1 -1
- package/dist/stripe/client/Charge.d.ts +0 -3
- package/dist/stripe/client/Charge.d.ts.map +1 -1
- package/dist/stripe/client/Charge.js +2 -2
- package/dist/stripe/client/Charge.js.map +1 -1
- package/dist/stripe/client/Methods.d.ts +0 -3
- package/dist/stripe/client/Methods.d.ts.map +1 -1
- package/dist/stripe/server/Charge.d.ts +0 -3
- package/dist/stripe/server/Charge.d.ts.map +1 -1
- package/dist/stripe/server/Charge.js +2 -2
- package/dist/stripe/server/Charge.js.map +1 -1
- package/dist/stripe/server/Methods.d.ts +0 -3
- package/dist/stripe/server/Methods.d.ts.map +1 -1
- package/dist/tempo/Methods.d.ts +0 -3
- package/dist/tempo/Methods.d.ts.map +1 -1
- package/dist/tempo/Methods.js +3 -3
- package/dist/tempo/Methods.js.map +1 -1
- package/dist/tempo/client/Charge.d.ts +13 -3
- package/dist/tempo/client/Charge.d.ts.map +1 -1
- package/dist/tempo/client/Charge.js +18 -1
- package/dist/tempo/client/Charge.js.map +1 -1
- package/dist/tempo/client/Methods.d.ts +4 -3
- package/dist/tempo/client/Methods.d.ts.map +1 -1
- package/dist/tempo/server/Charge.d.ts +0 -3
- package/dist/tempo/server/Charge.d.ts.map +1 -1
- package/dist/tempo/server/Charge.js +2 -1
- package/dist/tempo/server/Charge.js.map +1 -1
- package/dist/tempo/server/Methods.d.ts +0 -3
- package/dist/tempo/server/Methods.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/Challenge.test.ts +94 -18
- package/src/Challenge.ts +118 -15
- package/src/PaymentRequest.test.ts +0 -5
- package/src/bin.ts +4 -0
- package/src/cli.test.ts +180 -252
- package/src/cli.ts +1085 -485
- package/src/client/Mppx.test-d.ts +9 -0
- package/src/client/Mppx.test.ts +83 -5
- package/src/client/Mppx.ts +5 -0
- package/src/client/Transport.test.ts +5 -8
- package/src/client/internal/Fetch.browser.test.ts +135 -0
- package/src/client/internal/Fetch.test.ts +0 -88
- package/src/mcp-sdk/client/McpClient.test.ts +1 -1
- package/src/server/Mppx.ts +3 -1
- package/src/server/Transport.test.ts +6 -9
- package/src/stripe/Methods.ts +0 -2
- package/src/stripe/client/Charge.ts +2 -2
- package/src/stripe/server/Charge.ts +2 -2
- package/src/tempo/Methods.test.ts +22 -0
- package/src/tempo/Methods.ts +3 -3
- package/src/tempo/client/Charge.ts +29 -1
- package/src/tempo/server/Charge.test.ts +34 -72
- package/src/tempo/server/Charge.ts +2 -1
package/src/Challenge.test.ts
CHANGED
|
@@ -250,12 +250,12 @@ describe('fromMethod', () => {
|
|
|
250
250
|
const challenge = Challenge.fromMethod(Methods.charge, {
|
|
251
251
|
id: 'abc123',
|
|
252
252
|
realm: 'api.example.com',
|
|
253
|
+
expires: '2025-01-06T12:00:00Z',
|
|
253
254
|
request: {
|
|
254
255
|
amount: '1',
|
|
255
256
|
currency: '0x20c0000000000000000000000000000000000001',
|
|
256
257
|
decimals: 6,
|
|
257
258
|
recipient: '0x742d35Cc6634C0532925a3b844Bc9e7595f8fE00',
|
|
258
|
-
expires: '2025-01-06T12:00:00Z',
|
|
259
259
|
},
|
|
260
260
|
})
|
|
261
261
|
|
|
@@ -269,7 +269,6 @@ describe('fromMethod', () => {
|
|
|
269
269
|
"request": {
|
|
270
270
|
"amount": "1000000",
|
|
271
271
|
"currency": "0x20c0000000000000000000000000000000000001",
|
|
272
|
-
"expires": "2025-01-06T12:00:00Z",
|
|
273
272
|
"recipient": "0x742d35Cc6634C0532925a3b844Bc9e7595f8fE00",
|
|
274
273
|
},
|
|
275
274
|
}
|
|
@@ -280,12 +279,12 @@ describe('fromMethod', () => {
|
|
|
280
279
|
const challenge = Challenge.fromMethod(Methods.charge, {
|
|
281
280
|
id: 'abc123',
|
|
282
281
|
realm: 'api.example.com',
|
|
282
|
+
expires: '2025-01-06T12:00:00Z',
|
|
283
283
|
request: {
|
|
284
284
|
amount: '1',
|
|
285
285
|
currency: '0x20c0000000000000000000000000000000000001',
|
|
286
286
|
decimals: 6,
|
|
287
287
|
recipient: '0x742d35Cc6634C0532925a3b844Bc9e7595f8fE00',
|
|
288
|
-
expires: '2025-01-06T12:00:00Z',
|
|
289
288
|
chainId: 42431,
|
|
290
289
|
feePayer: true,
|
|
291
290
|
},
|
|
@@ -301,7 +300,6 @@ describe('fromMethod', () => {
|
|
|
301
300
|
"request": {
|
|
302
301
|
"amount": "1000000",
|
|
303
302
|
"currency": "0x20c0000000000000000000000000000000000001",
|
|
304
|
-
"expires": "2025-01-06T12:00:00Z",
|
|
305
303
|
"methodDetails": {
|
|
306
304
|
"chainId": 42431,
|
|
307
305
|
"feePayer": true,
|
|
@@ -321,7 +319,6 @@ describe('fromMethod', () => {
|
|
|
321
319
|
currency: '0x20c0000000000000000000000000000000000001',
|
|
322
320
|
decimals: 6,
|
|
323
321
|
recipient: '0x742d35Cc6634C0532925a3b844Bc9e7595f8fE00',
|
|
324
|
-
expires: '2025-01-06T12:00:00Z',
|
|
325
322
|
},
|
|
326
323
|
digest: 'sha-256=abc',
|
|
327
324
|
expires: '2025-01-06T12:00:00Z',
|
|
@@ -334,12 +331,12 @@ describe('fromMethod', () => {
|
|
|
334
331
|
test('behavior: creates challenge with HMAC-bound id via secretKey', () => {
|
|
335
332
|
const challenge = Challenge.fromMethod(Methods.charge, {
|
|
336
333
|
realm: 'api.example.com',
|
|
334
|
+
expires: '2025-01-06T12:00:00Z',
|
|
337
335
|
request: {
|
|
338
336
|
amount: '1',
|
|
339
337
|
currency: '0x20c0000000000000000000000000000000000001',
|
|
340
338
|
decimals: 6,
|
|
341
339
|
recipient: '0x742d35Cc6634C0532925a3b844Bc9e7595f8fE00',
|
|
342
|
-
expires: '2025-01-06T12:00:00Z',
|
|
343
340
|
},
|
|
344
341
|
secretKey: 'my-secret',
|
|
345
342
|
})
|
|
@@ -358,7 +355,6 @@ describe('fromMethod', () => {
|
|
|
358
355
|
amount: 123,
|
|
359
356
|
currency: '0x20c0000000000000000000000000000000000001',
|
|
360
357
|
recipient: '0x742d35Cc6634C0532925a3b844Bc9e7595f8fE00',
|
|
361
|
-
expires: '2025-01-06T12:00:00Z',
|
|
362
358
|
} as any,
|
|
363
359
|
}),
|
|
364
360
|
).toThrow()
|
|
@@ -402,17 +398,18 @@ describe('serialize', () => {
|
|
|
402
398
|
})
|
|
403
399
|
|
|
404
400
|
describe('deserialize', () => {
|
|
405
|
-
|
|
406
|
-
|
|
401
|
+
const paymentHeader = Challenge.serialize(
|
|
402
|
+
Challenge.from({
|
|
407
403
|
id: 'abc123',
|
|
408
404
|
realm: 'api.example.com',
|
|
409
405
|
method: 'tempo',
|
|
410
406
|
intent: 'charge',
|
|
411
407
|
request: { amount: '1000000', currency: 'USD' },
|
|
412
|
-
})
|
|
408
|
+
}),
|
|
409
|
+
)
|
|
413
410
|
|
|
414
|
-
|
|
415
|
-
const challenge = Challenge.deserialize(
|
|
411
|
+
test('behavior: deserializes WWW-Authenticate header', () => {
|
|
412
|
+
const challenge = Challenge.deserialize(paymentHeader)
|
|
416
413
|
|
|
417
414
|
expect(challenge).toMatchInlineSnapshot(`
|
|
418
415
|
{
|
|
@@ -446,20 +443,100 @@ describe('deserialize', () => {
|
|
|
446
443
|
expect(challenge?.expires).toBe('2025-01-06T12:00:00Z')
|
|
447
444
|
})
|
|
448
445
|
|
|
449
|
-
test(
|
|
450
|
-
|
|
446
|
+
test.each([
|
|
447
|
+
{ name: 'single Payment scheme', header: paymentHeader },
|
|
448
|
+
{ name: 'Payment after another scheme', header: `Bearer realm="api", ${paymentHeader}` },
|
|
449
|
+
{
|
|
450
|
+
name: 'scheme token is case-insensitive',
|
|
451
|
+
header: paymentHeader.replace(/^Payment /, 'payment '),
|
|
452
|
+
},
|
|
453
|
+
{
|
|
454
|
+
name: 'quoted values in previous schemes do not interfere',
|
|
455
|
+
header: `Bearer error_description="retry with Payment challenge", ${paymentHeader}`,
|
|
456
|
+
},
|
|
457
|
+
{
|
|
458
|
+
name: 'parses Payment params before the next scheme token',
|
|
459
|
+
header: `${paymentHeader}, Bearer realm="fallback"`,
|
|
460
|
+
},
|
|
461
|
+
])('behavior: extracts challenge for $name', ({ header }) => {
|
|
462
|
+
const challenge = Challenge.deserialize(header)
|
|
463
|
+
|
|
464
|
+
expect(challenge.id).toBe('abc123')
|
|
465
|
+
expect(challenge.method).toBe('tempo')
|
|
466
|
+
expect(challenge.intent).toBe('charge')
|
|
467
|
+
})
|
|
468
|
+
|
|
469
|
+
const request = /request="([^"]+)"/.exec(paymentHeader)?.[1]
|
|
470
|
+
if (!request) throw new Error('request missing from serialized challenge')
|
|
471
|
+
|
|
472
|
+
test.each([
|
|
473
|
+
{
|
|
474
|
+
name: 'escaped quotes',
|
|
475
|
+
headerValue: 'premium \\"access\\"',
|
|
476
|
+
expected: 'premium "access"',
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
name: 'escaped comma',
|
|
480
|
+
headerValue: 'tier\\,premium',
|
|
481
|
+
expected: 'tier,premium',
|
|
482
|
+
},
|
|
483
|
+
{
|
|
484
|
+
name: 'escaped backslash',
|
|
485
|
+
headerValue: 'path\\\\alpha',
|
|
486
|
+
expected: 'path\\alpha',
|
|
487
|
+
},
|
|
488
|
+
])('behavior: deserializes $name in quoted-string values', ({ headerValue, expected }) => {
|
|
489
|
+
const header =
|
|
490
|
+
'Payment id="abc123", realm="api.example.com", method="tempo", intent="charge", request="' +
|
|
491
|
+
request +
|
|
492
|
+
`", description="${headerValue}"`
|
|
493
|
+
|
|
494
|
+
const challenge = Challenge.deserialize(header)
|
|
495
|
+
expect(challenge.description).toBe(expected)
|
|
496
|
+
})
|
|
497
|
+
|
|
498
|
+
test.each([
|
|
499
|
+
{
|
|
500
|
+
name: 'missing Payment scheme',
|
|
501
|
+
header: 'Bearer token',
|
|
502
|
+
error: 'Missing Payment scheme.',
|
|
503
|
+
},
|
|
504
|
+
{
|
|
505
|
+
name: 'duplicate parameters',
|
|
506
|
+
header: 'Payment id="a", realm="api", method="tempo", intent="charge", request="e30", id="b"',
|
|
507
|
+
error: 'Duplicate parameter: id',
|
|
508
|
+
},
|
|
509
|
+
{
|
|
510
|
+
name: 'unterminated quoted-string',
|
|
511
|
+
header:
|
|
512
|
+
'Payment id="a", realm="api", method="tempo", intent="charge", request="e30", description="oops',
|
|
513
|
+
error: 'Unterminated quoted-string.',
|
|
514
|
+
},
|
|
515
|
+
{
|
|
516
|
+
name: 'invalid method casing',
|
|
517
|
+
header: 'Payment id="a", realm="api", method="Tempo", intent="charge", request="e30"',
|
|
518
|
+
error: 'Invalid method: "Tempo". Must be lowercase per spec.',
|
|
519
|
+
},
|
|
520
|
+
{
|
|
521
|
+
name: 'malformed auth-param',
|
|
522
|
+
header:
|
|
523
|
+
'Payment id="a", realm="api", method="tempo", intent="charge", request="e30", ="value"',
|
|
524
|
+
error: 'Malformed auth-param.',
|
|
525
|
+
},
|
|
526
|
+
])('error: throws for $name', ({ header, error }) => {
|
|
527
|
+
expect(() => Challenge.deserialize(header)).toThrow(error)
|
|
451
528
|
})
|
|
452
529
|
|
|
453
530
|
test('error: missing required fields', () => {
|
|
454
531
|
expect(() => Challenge.deserialize('Payment realm="test"')).toThrow()
|
|
455
532
|
})
|
|
456
533
|
|
|
457
|
-
test('error:
|
|
534
|
+
test('error: missing request parameter after valid Payment scheme', () => {
|
|
458
535
|
expect(() =>
|
|
459
536
|
Challenge.deserialize(
|
|
460
|
-
'Payment id="a", realm="api", method="tempo", intent="charge"
|
|
537
|
+
'Bearer realm="api", Payment id="a", realm="api", method="tempo", intent="charge"',
|
|
461
538
|
),
|
|
462
|
-
).toThrow('
|
|
539
|
+
).toThrow('Missing request parameter.')
|
|
463
540
|
})
|
|
464
541
|
})
|
|
465
542
|
|
|
@@ -584,7 +661,6 @@ describe('opaque', () => {
|
|
|
584
661
|
currency: '0x20c0000000000000000000000000000000000001',
|
|
585
662
|
decimals: 6,
|
|
586
663
|
recipient: '0x742d35Cc6634C0532925a3b844Bc9e7595f8fE00',
|
|
587
|
-
expires: '2025-01-06T12:00:00Z',
|
|
588
664
|
},
|
|
589
665
|
meta: { payment_intent: 'pi_3abc123XYZ' },
|
|
590
666
|
})
|
package/src/Challenge.ts
CHANGED
|
@@ -125,7 +125,7 @@ export function from<
|
|
|
125
125
|
secretKey,
|
|
126
126
|
} = parameters
|
|
127
127
|
|
|
128
|
-
const expires =
|
|
128
|
+
const expires = parameters.expires as string
|
|
129
129
|
const id = secretKey
|
|
130
130
|
? computeId({ ...parameters, expires, ...(meta && { opaque: meta }) }, { secretKey })
|
|
131
131
|
: (parameters as { id: string }).id
|
|
@@ -205,11 +205,11 @@ export declare namespace from {
|
|
|
205
205
|
* Methods.charge,
|
|
206
206
|
* {
|
|
207
207
|
* realm: 'api.example.com',
|
|
208
|
+
* expires: '2025-01-06T12:00:00Z',
|
|
208
209
|
* request: {
|
|
209
210
|
* amount: '1000000',
|
|
210
211
|
* currency: '0x20c0000000000000000000000000000000000001',
|
|
211
212
|
* recipient: '0x742d35Cc6634C0532925a3b844Bc9e7595f8fE00',
|
|
212
|
-
* expires: '2025-01-06T12:00:00Z',
|
|
213
213
|
* },
|
|
214
214
|
* },
|
|
215
215
|
* { secretKey: 'my-secret' },
|
|
@@ -319,20 +319,10 @@ export function deserialize<const methods extends readonly Method.Method[] | und
|
|
|
319
319
|
value: string,
|
|
320
320
|
options?: from.Options<methods>,
|
|
321
321
|
): from.ReturnType<from.Parameters, methods> {
|
|
322
|
-
const
|
|
323
|
-
if (!
|
|
322
|
+
const params = extractPaymentAuthParams(value)
|
|
323
|
+
if (!params) throw new Error('Missing Payment scheme.')
|
|
324
324
|
|
|
325
|
-
const
|
|
326
|
-
const result: Record<string, string> = {}
|
|
327
|
-
|
|
328
|
-
for (const match of params.matchAll(/(\w+)="([^"]+)"/g)) {
|
|
329
|
-
const key = match[1]
|
|
330
|
-
const value = match[2]
|
|
331
|
-
if (key && value) {
|
|
332
|
-
if (key in result) throw new Error(`Duplicate parameter: ${key}`)
|
|
333
|
-
result[key] = value
|
|
334
|
-
}
|
|
335
|
-
}
|
|
325
|
+
const result = parseAuthParams(params)
|
|
336
326
|
|
|
337
327
|
const { request, opaque, ...rest } = result
|
|
338
328
|
if (!request) throw new Error('Missing request parameter.')
|
|
@@ -349,6 +339,119 @@ export function deserialize<const methods extends readonly Method.Method[] | und
|
|
|
349
339
|
)
|
|
350
340
|
}
|
|
351
341
|
|
|
342
|
+
/** @internal Extracts the `Payment` scheme from a WWW-Authenticate value that may contain multiple schemes. */
|
|
343
|
+
function extractPaymentAuthParams(header: string): string | null {
|
|
344
|
+
const token = 'Payment'
|
|
345
|
+
let inQuotes = false
|
|
346
|
+
let escaped = false
|
|
347
|
+
|
|
348
|
+
for (let i = 0; i < header.length; i++) {
|
|
349
|
+
const char = header[i]
|
|
350
|
+
|
|
351
|
+
if (inQuotes) {
|
|
352
|
+
if (escaped) escaped = false
|
|
353
|
+
else if (char === '\\') escaped = true
|
|
354
|
+
else if (char === '"') inQuotes = false
|
|
355
|
+
continue
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
if (char === '"') {
|
|
359
|
+
inQuotes = true
|
|
360
|
+
continue
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
if (!startsWithSchemeToken(header, i, token)) continue
|
|
364
|
+
|
|
365
|
+
const prefix = header.slice(0, i)
|
|
366
|
+
if (prefix.trim() && !prefix.trimEnd().endsWith(',')) continue
|
|
367
|
+
|
|
368
|
+
let paramsStart = i + token.length
|
|
369
|
+
while (paramsStart < header.length && /\s/.test(header[paramsStart] ?? '')) paramsStart++
|
|
370
|
+
return header.slice(paramsStart)
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
return null
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/** @internal Parses auth-params with support for escaped quoted-string values. */
|
|
377
|
+
function parseAuthParams(input: string): Record<string, string> {
|
|
378
|
+
const result: Record<string, string> = {}
|
|
379
|
+
let i = 0
|
|
380
|
+
|
|
381
|
+
while (i < input.length) {
|
|
382
|
+
while (i < input.length && /[\s,]/.test(input[i] ?? '')) i++
|
|
383
|
+
if (i >= input.length) break
|
|
384
|
+
|
|
385
|
+
const keyStart = i
|
|
386
|
+
while (i < input.length && /[A-Za-z0-9_-]/.test(input[i] ?? '')) i++
|
|
387
|
+
const key = input.slice(keyStart, i)
|
|
388
|
+
if (!key) throw new Error('Malformed auth-param.')
|
|
389
|
+
|
|
390
|
+
while (i < input.length && /\s/.test(input[i] ?? '')) i++
|
|
391
|
+
|
|
392
|
+
// If there is no '=' after a token, this is likely another auth scheme.
|
|
393
|
+
if (input[i] !== '=') break
|
|
394
|
+
i++
|
|
395
|
+
|
|
396
|
+
while (i < input.length && /\s/.test(input[i] ?? '')) i++
|
|
397
|
+
|
|
398
|
+
const [value, nextIndex] = readAuthParamValue(input, i)
|
|
399
|
+
i = nextIndex
|
|
400
|
+
|
|
401
|
+
if (key in result) throw new Error(`Duplicate parameter: ${key}`)
|
|
402
|
+
result[key] = value
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
return result
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/** @internal */
|
|
409
|
+
function readAuthParamValue(input: string, start: number): [value: string, nextIndex: number] {
|
|
410
|
+
if (input[start] === '"') return readQuotedAuthParamValue(input, start + 1)
|
|
411
|
+
|
|
412
|
+
let i = start
|
|
413
|
+
while (i < input.length && input[i] !== ',') i++
|
|
414
|
+
return [input.slice(start, i).trim(), i]
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/** @internal */
|
|
418
|
+
function readQuotedAuthParamValue(
|
|
419
|
+
input: string,
|
|
420
|
+
start: number,
|
|
421
|
+
): [value: string, nextIndex: number] {
|
|
422
|
+
let i = start
|
|
423
|
+
let value = ''
|
|
424
|
+
let escaped = false
|
|
425
|
+
|
|
426
|
+
while (i < input.length) {
|
|
427
|
+
const char = input[i]!
|
|
428
|
+
i++
|
|
429
|
+
|
|
430
|
+
if (escaped) {
|
|
431
|
+
value += char
|
|
432
|
+
escaped = false
|
|
433
|
+
continue
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
if (char === '\\') {
|
|
437
|
+
escaped = true
|
|
438
|
+
continue
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
if (char === '"') return [value, i]
|
|
442
|
+
value += char
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
throw new Error('Unterminated quoted-string.')
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/** @internal */
|
|
449
|
+
function startsWithSchemeToken(value: string, index: number, token: string): boolean {
|
|
450
|
+
if (!value.slice(index).toLowerCase().startsWith(token.toLowerCase())) return false
|
|
451
|
+
const next = value[index + token.length]
|
|
452
|
+
return Boolean(next && /\s/.test(next))
|
|
453
|
+
}
|
|
454
|
+
|
|
352
455
|
/**
|
|
353
456
|
* Extracts the challenge from a Headers object.
|
|
354
457
|
*
|
|
@@ -26,13 +26,11 @@ describe('fromMethod', () => {
|
|
|
26
26
|
currency: '0x20c0000000000000000000000000000000000001',
|
|
27
27
|
decimals: 6,
|
|
28
28
|
recipient: '0x742d35Cc6634C0532925a3b844Bc9e7595f8fE00',
|
|
29
|
-
expires: '2025-01-06T12:00:00Z',
|
|
30
29
|
})
|
|
31
30
|
expect(request).toMatchInlineSnapshot(`
|
|
32
31
|
{
|
|
33
32
|
"amount": "1000000",
|
|
34
33
|
"currency": "0x20c0000000000000000000000000000000000001",
|
|
35
|
-
"expires": "2025-01-06T12:00:00Z",
|
|
36
34
|
"recipient": "0x742d35Cc6634C0532925a3b844Bc9e7595f8fE00",
|
|
37
35
|
}
|
|
38
36
|
`)
|
|
@@ -44,14 +42,12 @@ describe('fromMethod', () => {
|
|
|
44
42
|
currency: '0x20c0000000000000000000000000000000000001',
|
|
45
43
|
decimals: 6,
|
|
46
44
|
recipient: '0x742d35Cc6634C0532925a3b844Bc9e7595f8fE00',
|
|
47
|
-
expires: '2025-01-06T12:00:00Z',
|
|
48
45
|
chainId: 42431,
|
|
49
46
|
})
|
|
50
47
|
expect(request).toMatchInlineSnapshot(`
|
|
51
48
|
{
|
|
52
49
|
"amount": "1000000",
|
|
53
50
|
"currency": "0x20c0000000000000000000000000000000000001",
|
|
54
|
-
"expires": "2025-01-06T12:00:00Z",
|
|
55
51
|
"methodDetails": {
|
|
56
52
|
"chainId": 42431,
|
|
57
53
|
},
|
|
@@ -66,7 +62,6 @@ describe('fromMethod', () => {
|
|
|
66
62
|
amount: 123,
|
|
67
63
|
currency: '0x20c0000000000000000000000000000000000001',
|
|
68
64
|
recipient: '0x742d35Cc6634C0532925a3b844Bc9e7595f8fE00',
|
|
69
|
-
expires: '2025-01-06T12:00:00Z',
|
|
70
65
|
} as any),
|
|
71
66
|
).toThrowErrorMatchingInlineSnapshot(`
|
|
72
67
|
[$ZodError: [
|
package/src/bin.ts
ADDED