mppx 0.8.19 → 0.9.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/CHANGELOG.md +16 -0
- package/README.md +0 -6
- package/dist/Challenge.d.ts +7 -0
- package/dist/Challenge.js +32 -6
- package/dist/Constants.d.ts +1 -0
- package/dist/Constants.js +1 -0
- package/dist/Credential.d.ts +11 -5
- package/dist/Credential.js +8 -8
- package/dist/Html.js +1 -1
- package/dist/cli/THIRD-PARTY-LICENSES.txt +1 -1
- package/dist/cli/cli.d.ts +2 -2
- package/dist/cli/cli.js +134 -134
- package/dist/cli/plugins/index.js +13 -13
- package/dist/cli/sessions/Manager.js +4 -6
- package/dist/cli/sessions/commands.d.ts +1 -1
- package/dist/cli/sessions/store.js +13 -19
- package/dist/cli/validate/index.d.ts +2 -2
- package/dist/client/Mppx.d.ts +39 -2
- package/dist/client/Mppx.js +102 -46
- package/dist/client/Transport.js +1 -1
- package/dist/client/internal/protocols/Mpp.d.ts +1 -1
- package/dist/client/internal/protocols/Mpp.js +5 -3
- package/dist/client/internal/protocols/Protocol.d.ts +3 -1
- package/dist/client/internal/protocols/Shared.js +5 -1
- package/dist/integrations/x402/Evm.d.ts +29 -0
- package/dist/integrations/x402/Evm.js +150 -0
- package/dist/integrations/x402/Negotiator.d.ts +36 -0
- package/dist/integrations/x402/Negotiator.js +165 -0
- package/dist/mcp/internal/Credential.d.ts +9 -0
- package/dist/mcp/internal/Credential.js +16 -0
- package/dist/mcp/server/Transport.js +2 -4
- package/dist/middlewares/express.js +5 -12
- package/dist/middlewares/internal/express.d.ts +8 -0
- package/dist/middlewares/internal/express.js +24 -0
- package/dist/middlewares/internal/node.d.ts +10 -0
- package/dist/middlewares/internal/node.js +34 -0
- package/dist/proxy/Proxy.js +15 -9
- package/dist/server/Mppx.d.ts +2 -0
- package/dist/server/Mppx.js +17 -14
- package/dist/server/Transport.d.ts +8 -2
- package/dist/server/Transport.js +6 -3
- package/dist/server/internal/SecretKey.d.ts +3 -0
- package/dist/server/internal/SecretKey.js +9 -0
- package/dist/server/internal/html/serviceWorker.client.d.ts +1 -1
- package/dist/server/internal/html/serviceWorker.client.js +2 -2
- package/dist/server/internal/html/serviceWorker.gen.d.ts +1 -1
- package/dist/server/internal/html/serviceWorker.gen.js +1 -1
- package/dist/stripe/server/internal/html.gen.d.ts +1 -1
- package/dist/stripe/server/internal/html.gen.js +1 -1
- package/dist/tempo/Methods.d.ts +0 -10
- package/dist/tempo/Methods.js +3 -12
- package/dist/tempo/client/Charge.d.ts +0 -3
- package/dist/tempo/client/Charge.js +3 -13
- package/dist/tempo/client/Methods.d.ts +0 -10
- package/dist/tempo/internal/account.d.ts +15 -6
- package/dist/tempo/internal/account.js +17 -26
- package/dist/tempo/internal/defaults.d.ts +0 -11
- package/dist/tempo/internal/defaults.js +0 -11
- package/dist/tempo/internal/fee-payer.d.ts +21 -3
- package/dist/tempo/internal/fee-payer.js +10 -19
- package/dist/tempo/internal/remote-fee-payer.d.ts +12 -0
- package/dist/tempo/internal/remote-fee-payer.js +17 -0
- package/dist/tempo/legacy/client/Session.d.ts +0 -7
- package/dist/tempo/server/Charge.d.ts +0 -3
- package/dist/tempo/server/Charge.js +26 -68
- package/dist/tempo/server/Methods.d.ts +4 -18
- package/dist/tempo/server/Methods.js +4 -8
- package/dist/tempo/server/internal/html.gen.d.ts +1 -1
- package/dist/tempo/server/internal/html.gen.js +1 -1
- package/dist/tempo/session/client/ChannelOps.d.ts +0 -14
- package/dist/tempo/session/client/ChannelOps.js +0 -22
- package/dist/tempo/session/client/ChannelStore.d.ts +5 -0
- package/dist/tempo/session/client/ChannelStore.js +2 -2
- package/dist/tempo/session/client/CredentialState.d.ts +2 -12
- package/dist/tempo/session/client/CredentialState.js +75 -73
- package/dist/tempo/session/client/Session.d.ts +2 -9
- package/dist/tempo/session/client/Session.js +71 -176
- package/dist/tempo/session/client/SessionManager.js +9 -28
- package/dist/tempo/session/precompile/Chain.d.ts +0 -4
- package/dist/tempo/session/precompile/Chain.js +1 -29
- package/dist/tempo/session/precompile/Protocol.d.ts +0 -13
- package/dist/tempo/session/precompile/Voucher.d.ts +1 -3
- package/dist/tempo/session/precompile/Voucher.js +12 -6
- package/dist/tempo/session/server/ChannelStore.d.ts +0 -6
- package/dist/tempo/session/server/ChannelStore.js +4 -11
- package/dist/tempo/session/server/CredentialVerification.d.ts +7 -9
- package/dist/tempo/session/server/CredentialVerification.js +118 -184
- package/dist/tempo/session/server/RequestState.d.ts +0 -17
- package/dist/tempo/session/server/RequestState.js +15 -59
- package/dist/tempo/session/server/Session.d.ts +0 -9
- package/dist/tempo/session/server/Session.js +8 -37
- package/dist/tempo/session/server/Settlement.d.ts +0 -7
- package/dist/tempo/session/server/Settlement.js +16 -50
- package/dist/viem/Client.d.ts +7 -2
- package/dist/viem/Client.js +17 -5
- package/dist/x402/Types.d.ts +2 -0
- package/dist/x402/Types.js +2 -0
- package/dist/x402/mcp.d.ts +20 -0
- package/dist/x402/mcp.js +153 -0
- package/dist/x402/middlewares/express.d.ts +23 -0
- package/dist/x402/middlewares/express.js +49 -0
- package/dist/x402/middlewares/hono.d.ts +13 -0
- package/dist/x402/middlewares/hono.js +36 -0
- package/dist/x402/middlewares/next.d.ts +17 -0
- package/dist/x402/middlewares/next.js +58 -0
- package/package.json +41 -1
- package/dist/tempo/internal/machine-token-charge.d.ts +0 -51
- package/dist/tempo/internal/machine-token-charge.js +0 -113
- package/dist/tempo/internal/machine-token-session.d.ts +0 -88
- package/dist/tempo/internal/machine-token-session.js +0 -173
- package/dist/tempo/internal/signature-envelope.d.ts +0 -14
- package/dist/tempo/internal/signature-envelope.js +0 -28
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# mppx
|
|
2
2
|
|
|
3
|
+
## 0.9.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- c23eaf0: Removed machineUSD charge and session flows, requiring servers that advertise machineUSD to remove that configuration before upgrading.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 9582c40: Routed hosted Tempo fee-payer fills through the configured `withFeePayer` transport and broadcast completed transactions through the default RPC transport.
|
|
12
|
+
- d343aae: Added `preparePayment` for inspecting a selected client payment before creating and attaching its credential.
|
|
13
|
+
- 7ce3160: Added the V8 coverage provider required by the configured test coverage command.
|
|
14
|
+
- 5e10359: Fixed concurrent HTML builds sharing a temporary directory.
|
|
15
|
+
- 4e4810a: Added a `requiresAuth` server option that used `Payment-Authorization` for Payment credentials.
|
|
16
|
+
- 1a36a5e: Added HTTP headers to remote Tempo fee-payer configuration.
|
|
17
|
+
- 07c59cf: Added dual MPP/x402 wrappers for Express, Hono, Next.js, and MCP, backed by official x402 adapters and native MPP protocol handling. Exposed Tempo and source-chain MPP payments for compatible EVM requirements; x402 Fastify and Axios compatibility adapters were deferred.
|
|
18
|
+
|
|
3
19
|
## 0.8.19
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -52,7 +52,6 @@ const mppx = Mppx.create({
|
|
|
52
52
|
methods: [
|
|
53
53
|
tempo({
|
|
54
54
|
currency: '0x20c0000000000000000000000000000000000000',
|
|
55
|
-
machineTokenEnabled: true,
|
|
56
55
|
recipient: '0x742d35Cc6634c0532925a3b844bC9e7595F8fE00',
|
|
57
56
|
}),
|
|
58
57
|
],
|
|
@@ -84,11 +83,6 @@ Mppx.create({
|
|
|
84
83
|
const res = await fetch('https://mpp.dev/api/ping/paid')
|
|
85
84
|
```
|
|
86
85
|
|
|
87
|
-
The client API is the same for PathUSD, USDC.e, and machineUSD. A server advertises
|
|
88
|
-
`machineTokenEnabled`; the client uses machineUSD when a verified route and sufficient balance
|
|
89
|
-
are available, and otherwise pays the token requested by the challenge. Sessions keep the selected
|
|
90
|
-
rail until the channel closes.
|
|
91
|
-
|
|
92
86
|
## Examples
|
|
93
87
|
|
|
94
88
|
| Example | Description |
|
package/dist/Challenge.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export declare const Schema: z.ZodMiniObject<{
|
|
|
16
16
|
description: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
17
17
|
digest: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
18
18
|
expires: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
19
|
+
header: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
19
20
|
id: z.ZodMiniString<string>;
|
|
20
21
|
intent: z.ZodMiniString<string>;
|
|
21
22
|
method: z.ZodMiniString<string>;
|
|
@@ -106,6 +107,8 @@ export declare namespace from {
|
|
|
106
107
|
digest?: string | undefined;
|
|
107
108
|
/** Optional expiration timestamp (ISO 8601). */
|
|
108
109
|
expires?: z.DatetimeInput | undefined;
|
|
110
|
+
/** Optional HTTP field name to carry the payment credential. When omitted, uses Authorization. */
|
|
111
|
+
header?: string | undefined;
|
|
109
112
|
/** Intent type (e.g., "charge", "session"). */
|
|
110
113
|
intent: string;
|
|
111
114
|
/** Optional server-defined correlation data (serialized as `opaque` on the challenge). Flat string-to-string map; clients MUST NOT modify. */
|
|
@@ -168,6 +171,8 @@ export declare namespace fromMethod {
|
|
|
168
171
|
digest?: string | undefined;
|
|
169
172
|
/** Optional expiration timestamp (ISO 8601). */
|
|
170
173
|
expires?: z.DatetimeInput | undefined;
|
|
174
|
+
/** Optional HTTP field name to carry the payment credential. When omitted, uses Authorization. */
|
|
175
|
+
header?: string | undefined;
|
|
171
176
|
/** Optional server-defined correlation data (serialized as `opaque` on the challenge). Flat string-to-string map; clients MUST NOT modify. */
|
|
172
177
|
meta?: Record<string, string> | undefined;
|
|
173
178
|
/** Server realm (e.g., hostname). */
|
|
@@ -309,4 +314,6 @@ export declare namespace verify {
|
|
|
309
314
|
}
|
|
310
315
|
/** Extracts parsed server-defined correlation data from a challenge when available. */
|
|
311
316
|
export declare function meta(challenge: Challenge): Record<string, string> | undefined;
|
|
317
|
+
/** Returns the HTTP field name a client must use for a payment credential. */
|
|
318
|
+
export declare function credentialHeader(challenge: Challenge): string;
|
|
312
319
|
//# sourceMappingURL=Challenge.d.ts.map
|
package/dist/Challenge.js
CHANGED
|
@@ -21,6 +21,8 @@ export const Schema = z.object({
|
|
|
21
21
|
digest: z.optional(z.string().check(z.regex(/^sha-256=/, 'Invalid digest format'))),
|
|
22
22
|
/** Optional expiration timestamp (ISO 8601). */
|
|
23
23
|
expires: z.optional(z.datetime()),
|
|
24
|
+
/** Optional HTTP field name to carry the payment credential. When omitted, uses Authorization. */
|
|
25
|
+
header: z.optional(z.string().check(z.regex(/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/, 'Invalid HTTP header name'))),
|
|
24
26
|
/** Unique challenge identifier (HMAC-bound). */
|
|
25
27
|
id: z.string().check(z.minLength(1)),
|
|
26
28
|
/** Intent type (e.g., "charge", "session"). */
|
|
@@ -75,7 +77,11 @@ export const Schema = z.object({
|
|
|
75
77
|
*/
|
|
76
78
|
export function from(parameters, options) {
|
|
77
79
|
void options;
|
|
78
|
-
const { description, digest, meta, method: methodName, intent, realm, request, secretKey, } = parameters;
|
|
80
|
+
const { description, digest, meta, method: methodName, header: suppliedHeader, intent, realm, request, secretKey, } = parameters;
|
|
81
|
+
// `Authorization` is the implicit protocol default and is intentionally not
|
|
82
|
+
// advertised on the wire. This preserves the legacy challenge binding and
|
|
83
|
+
// lets servers opt into an alternate credential field explicitly.
|
|
84
|
+
const header = isDefaultCredentialHeader(suppliedHeader) ? undefined : suppliedHeader;
|
|
79
85
|
const expires = parameters.expires ? z.toDatetimeString(parameters.expires) : undefined;
|
|
80
86
|
const opaque = parameters.opaque ?? (meta !== undefined ? PaymentRequest.serialize(meta) : undefined);
|
|
81
87
|
const id = secretKey
|
|
@@ -90,6 +96,7 @@ export function from(parameters, options) {
|
|
|
90
96
|
...(description && { description }),
|
|
91
97
|
...(digest && { digest }),
|
|
92
98
|
...(expires && { expires }),
|
|
99
|
+
...(header !== undefined && { header }),
|
|
93
100
|
...(meta !== undefined && { meta }),
|
|
94
101
|
...(opaque !== undefined && { opaque }),
|
|
95
102
|
});
|
|
@@ -128,7 +135,7 @@ export function from(parameters, options) {
|
|
|
128
135
|
*/
|
|
129
136
|
export function fromMethod(method, parameters) {
|
|
130
137
|
const { name: methodName, intent } = method;
|
|
131
|
-
const { description, digest, expires, id, meta, realm, secretKey } = parameters;
|
|
138
|
+
const { description, digest, expires, header, id, meta, realm, secretKey } = parameters;
|
|
132
139
|
const request = PaymentRequest.fromMethod(method, parameters.request);
|
|
133
140
|
return from({
|
|
134
141
|
...(id !== undefined ? { id } : { secretKey }),
|
|
@@ -139,6 +146,7 @@ export function fromMethod(method, parameters) {
|
|
|
139
146
|
description,
|
|
140
147
|
digest,
|
|
141
148
|
expires,
|
|
149
|
+
header,
|
|
142
150
|
meta,
|
|
143
151
|
});
|
|
144
152
|
}
|
|
@@ -170,6 +178,9 @@ export function serialize(challenge) {
|
|
|
170
178
|
parts.push(authParam('digest', challenge.digest));
|
|
171
179
|
if (challenge.expires !== undefined)
|
|
172
180
|
parts.push(authParam('expires', challenge.expires));
|
|
181
|
+
const credentialHeader = challenge.header;
|
|
182
|
+
if (credentialHeader !== undefined && !isDefaultCredentialHeader(credentialHeader))
|
|
183
|
+
parts.push(authParam('header', credentialHeader));
|
|
173
184
|
if (challenge.opaque !== undefined)
|
|
174
185
|
parts.push(authParam('opaque', challenge.opaque));
|
|
175
186
|
else if (challenge.meta !== undefined)
|
|
@@ -490,22 +501,37 @@ export function meta(challenge) {
|
|
|
490
501
|
* of truth for what the challenge ID binds to — used by both `computeId()`
|
|
491
502
|
* (challenge creation) and `verify()` (credential verification).
|
|
492
503
|
*
|
|
493
|
-
*
|
|
504
|
+
* Legacy slots: realm | method | intent | request | expires | digest | opaque.
|
|
505
|
+
* Challenges advertising a credential header insert it immediately before the
|
|
506
|
+
* final opaque slot.
|
|
494
507
|
*
|
|
495
508
|
* Because the HMAC covers ALL fields, the server does not need to separately
|
|
496
509
|
* pin opaque, digest, or expires during verification — any change to those
|
|
497
510
|
* fields produces a different HMAC and fails the ID comparison.
|
|
498
511
|
*/
|
|
499
512
|
function idBindingInput(challenge) {
|
|
500
|
-
|
|
513
|
+
const values = [
|
|
501
514
|
challenge.realm,
|
|
502
515
|
challenge.method,
|
|
503
516
|
challenge.intent,
|
|
504
517
|
PaymentRequest.serialize(challenge.request),
|
|
505
518
|
challenge.expires ?? '',
|
|
506
519
|
challenge.digest ?? '',
|
|
507
|
-
|
|
508
|
-
|
|
520
|
+
];
|
|
521
|
+
// Keep opaque in the final optional slot required by the Payment auth scheme.
|
|
522
|
+
const credentialHeader = challenge.header;
|
|
523
|
+
if (credentialHeader !== undefined && !isDefaultCredentialHeader(credentialHeader))
|
|
524
|
+
values.push(credentialHeader);
|
|
525
|
+
values.push(challenge.opaque ?? (challenge.meta ? PaymentRequest.serialize(challenge.meta) : ''));
|
|
526
|
+
return values.join('|');
|
|
527
|
+
}
|
|
528
|
+
/** Returns the HTTP field name a client must use for a payment credential. */
|
|
529
|
+
export function credentialHeader(challenge) {
|
|
530
|
+
return challenge.header ?? Constants.Headers.authorization;
|
|
531
|
+
}
|
|
532
|
+
/** Returns whether a credential header is the implicit HTTP authentication default. */
|
|
533
|
+
function isDefaultCredentialHeader(header) {
|
|
534
|
+
return header?.toLowerCase() === Constants.Headers.authorization.toLowerCase();
|
|
509
535
|
}
|
|
510
536
|
/** @internal Computes HMAC-SHA256 challenge ID from parameters. */
|
|
511
537
|
function computeId(challenge, options) {
|
package/dist/Constants.d.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
export declare const Headers: {
|
|
3
3
|
readonly acceptPayment: 'Accept-Payment';
|
|
4
4
|
readonly authorization: 'Authorization';
|
|
5
|
+
readonly paymentAuthorization: 'Payment-Authorization';
|
|
5
6
|
readonly paymentReceipt: 'Payment-Receipt';
|
|
6
7
|
readonly paymentSession: 'Payment-Session';
|
|
7
8
|
readonly paymentSessionSnapshot: 'Payment-Session-Snapshot';
|
package/dist/Constants.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
export const Headers = {
|
|
3
3
|
acceptPayment: 'Accept-Payment',
|
|
4
4
|
authorization: 'Authorization',
|
|
5
|
+
paymentAuthorization: 'Payment-Authorization',
|
|
5
6
|
paymentReceipt: 'Payment-Receipt',
|
|
6
7
|
paymentSession: 'Payment-Session',
|
|
7
8
|
paymentSessionSnapshot: 'Payment-Session-Snapshot',
|
package/dist/Credential.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export type Credential<payload = unknown, challenge extends Challenge.Challenge
|
|
|
12
12
|
};
|
|
13
13
|
export declare class MissingAuthorizationHeaderError extends Error {
|
|
14
14
|
readonly name = "MissingAuthorizationHeaderError";
|
|
15
|
-
constructor();
|
|
15
|
+
constructor(header?: string);
|
|
16
16
|
}
|
|
17
17
|
export declare class MissingPaymentSchemeError extends Error {
|
|
18
18
|
readonly name = "MissingPaymentSchemeError";
|
|
@@ -23,7 +23,7 @@ export declare class InvalidCredentialEncodingError extends Error {
|
|
|
23
23
|
constructor();
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
|
-
* Deserializes
|
|
26
|
+
* Deserializes a Payment credential header value to a credential.
|
|
27
27
|
* Accepts the spec-compliant base64url `opaque` string shape and the legacy
|
|
28
28
|
* object-shaped `opaque` form emitted by older mppx versions.
|
|
29
29
|
*
|
|
@@ -66,7 +66,7 @@ export declare namespace from {
|
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
68
|
/**
|
|
69
|
-
* Extracts the credential from a Request's
|
|
69
|
+
* Extracts the credential from a Request's configured credential header.
|
|
70
70
|
*
|
|
71
71
|
* @param request - The HTTP request.
|
|
72
72
|
* @returns The deserialized credential.
|
|
@@ -78,9 +78,15 @@ export declare namespace from {
|
|
|
78
78
|
* const credential = Credential.fromRequest(request)
|
|
79
79
|
* ```
|
|
80
80
|
*/
|
|
81
|
-
export declare function fromRequest<payload = unknown>(request: Request): Credential<payload>;
|
|
81
|
+
export declare function fromRequest<payload = unknown>(request: Request, options?: fromRequest.Options): Credential<payload>;
|
|
82
|
+
export declare namespace fromRequest {
|
|
83
|
+
type Options = {
|
|
84
|
+
/** HTTP field containing the Payment credential. @default 'Authorization' */
|
|
85
|
+
header?: string | undefined;
|
|
86
|
+
};
|
|
87
|
+
}
|
|
82
88
|
/**
|
|
83
|
-
* Serializes a credential to the
|
|
89
|
+
* Serializes a credential to the Payment credential header format.
|
|
84
90
|
* When present, `challenge.opaque` is emitted unchanged as the base64url string
|
|
85
91
|
* required by the Payment auth credential format.
|
|
86
92
|
*
|
package/dist/Credential.js
CHANGED
|
@@ -4,8 +4,8 @@ import * as Constants from './Constants.js';
|
|
|
4
4
|
import * as PaymentRequest from './PaymentRequest.js';
|
|
5
5
|
export class MissingAuthorizationHeaderError extends Error {
|
|
6
6
|
name = 'MissingAuthorizationHeaderError';
|
|
7
|
-
constructor() {
|
|
8
|
-
super(
|
|
7
|
+
constructor(header = Constants.Headers.authorization) {
|
|
8
|
+
super(`Missing ${header} header.`);
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
export class MissingPaymentSchemeError extends Error {
|
|
@@ -21,7 +21,7 @@ export class InvalidCredentialEncodingError extends Error {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
|
-
* Deserializes
|
|
24
|
+
* Deserializes a Payment credential header value to a credential.
|
|
25
25
|
* Accepts the spec-compliant base64url `opaque` string shape and the legacy
|
|
26
26
|
* object-shaped `opaque` form emitted by older mppx versions.
|
|
27
27
|
*
|
|
@@ -105,7 +105,7 @@ export function from(parameters) {
|
|
|
105
105
|
};
|
|
106
106
|
}
|
|
107
107
|
/**
|
|
108
|
-
* Extracts the credential from a Request's
|
|
108
|
+
* Extracts the credential from a Request's configured credential header.
|
|
109
109
|
*
|
|
110
110
|
* @param request - The HTTP request.
|
|
111
111
|
* @returns The deserialized credential.
|
|
@@ -117,17 +117,17 @@ export function from(parameters) {
|
|
|
117
117
|
* const credential = Credential.fromRequest(request)
|
|
118
118
|
* ```
|
|
119
119
|
*/
|
|
120
|
-
export function fromRequest(request) {
|
|
121
|
-
const header = request.headers.get(Constants.Headers.authorization);
|
|
120
|
+
export function fromRequest(request, options = {}) {
|
|
121
|
+
const header = request.headers.get(options.header ?? Constants.Headers.authorization);
|
|
122
122
|
if (!header)
|
|
123
|
-
throw new MissingAuthorizationHeaderError();
|
|
123
|
+
throw new MissingAuthorizationHeaderError(options.header);
|
|
124
124
|
const payment = extractPaymentScheme(header);
|
|
125
125
|
if (!payment)
|
|
126
126
|
throw new MissingPaymentSchemeError();
|
|
127
127
|
return deserialize(payment);
|
|
128
128
|
}
|
|
129
129
|
/**
|
|
130
|
-
* Serializes a credential to the
|
|
130
|
+
* Serializes a credential to the Payment credential header format.
|
|
131
131
|
* When present, `challenge.opaque` is emitted unchanged as the base64url string
|
|
132
132
|
* required by the Payment auth credential format.
|
|
133
133
|
*
|
package/dist/Html.js
CHANGED
|
@@ -34,7 +34,7 @@ export function init(methodName) {
|
|
|
34
34
|
document.getElementById(data.rootId)?.after(el);
|
|
35
35
|
},
|
|
36
36
|
root: document.getElementById(data.rootId),
|
|
37
|
-
submit: submitCredential,
|
|
37
|
+
submit: (credential) => submitCredential(credential, data.challenge.header),
|
|
38
38
|
vars,
|
|
39
39
|
};
|
|
40
40
|
}
|
package/dist/cli/cli.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Cli } from 'incur';
|
|
2
2
|
declare const cli: Cli.Cli<{
|
|
3
|
-
|
|
3
|
+
mppx: {
|
|
4
4
|
args: {
|
|
5
5
|
url: string;
|
|
6
6
|
};
|
|
@@ -29,6 +29,6 @@ declare const cli: Cli.Cli<{
|
|
|
29
29
|
verbose: number;
|
|
30
30
|
};
|
|
31
31
|
};
|
|
32
|
-
}, undefined, undefined, undefined>;
|
|
32
|
+
}, undefined, undefined, undefined, "mppx">;
|
|
33
33
|
export default cli;
|
|
34
34
|
//# sourceMappingURL=cli.d.ts.map
|