@peac/mappings-paymentauth 0.12.4

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 ADDED
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2025-2026 PEAC Protocol Contributors
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # @peac/mappings-paymentauth
2
+
3
+ HTTP Payment authentication scheme (paymentauth/MPP) mapping for PEAC.
4
+
5
+ Envelope-first parsing of paymentauth wire artifacts with raw + normalized types. Method-specific payloads are treated as `unknown` because each payment method (card, lightning, stripe, tempo) has its own specification.
6
+
7
+ ## Status
8
+
9
+ Experimental. The paymentauth core spec (`draft-ryan-httpauth-payment-01`) is an active individual draft (not standards-track). Discovery and JSON-RPC/MCP transport drafts are at draft-00.
10
+
11
+ ## Features
12
+
13
+ - Parse `WWW-Authenticate: Payment` challenges (first challenge; separate header lines recommended for multiple challenges)
14
+ - Parse `Authorization: Payment` credentials (base64url-encoded JSON)
15
+ - Parse `Payment-Receipt` headers (base64url-encoded JSON)
16
+ - Normalize to stable PEAC-facing types with `_raw` back-references
17
+ - OpenAPI discovery extraction (`x-service-info`, `x-payment-info`)
18
+ - JSON-RPC error detection (`-32042`, `-32043`)
19
+ - MCP `_meta` key extraction (`org.paymentauth/credential`, `org.paymentauth/receipt`)
20
+ - MCP capability advertisement typing (`experimental.payment`)
21
+
22
+ ## Security
23
+
24
+ - Raw `Authorization: Payment` and `Payment-Receipt` values never appear in thrown errors
25
+ - Parser limits enforced: header size, param count, payload size, JSON depth
26
+ - Decoded bytes preserved alongside strings for non-UTF-8 safety
27
+ - `redactPaymentauthHeader()` helper for safe logging
28
+
29
+ ## No Network I/O
30
+
31
+ This package contains zero network calls. All functions are pure parsers and normalizers.
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Paymentauth carrier adapter for Evidence Carrier Contract.
3
+ *
4
+ * Header-only embed transport via PEAC-Receipt (compact JWS).
5
+ * All size limits enforce the 8 KB header ceiling (HTTP transport).
6
+ *
7
+ * receipt_ref is computed from the raw upstream artifact actually received
8
+ * (the literal Payment-Receipt header value), NOT assumed to be a JWS.
9
+ *
10
+ * Co-existence: PEAC PEAC-Receipt and paymentauth Payment-Receipt can
11
+ * appear on the same HTTP response. They serve different purposes:
12
+ * - PEAC-Receipt: signed PEAC interaction record (compact JWS)
13
+ * - Payment-Receipt: paymentauth payment receipt (base64url JSON)
14
+ * No semantic coupling is implied between them.
15
+ */
16
+ import type { PeacEvidenceCarrier, CarrierMeta, CarrierValidationResult, CarrierAdapter } from '@peac/kernel';
17
+ /** Paymentauth carrier size limits (HTTP header transport ceiling) */
18
+ export declare const PAYMENTAUTH_CARRIER_LIMITS: {
19
+ readonly embed: 65536;
20
+ readonly headers: 8192;
21
+ };
22
+ /** Simple header map */
23
+ export type PaymentauthHeaderMap = Record<string, string>;
24
+ /** Paymentauth HTTP response with headers */
25
+ export interface PaymentauthResponseLike {
26
+ headers?: PaymentauthHeaderMap;
27
+ body?: Record<string, unknown>;
28
+ }
29
+ /** Extraction result */
30
+ export interface PaymentauthExtractResult {
31
+ receipts: PeacEvidenceCarrier[];
32
+ meta: CarrierMeta;
33
+ /**
34
+ * Raw Payment-Receipt header value if present (upstream artifact).
35
+ * This is observational upstream material and is NEVER part of
36
+ * receipt_jws. It is captured separately for audit/traceability only.
37
+ */
38
+ rawPaymentReceipt?: string;
39
+ }
40
+ /** Async extraction result */
41
+ export interface PaymentauthExtractAsyncResult extends PaymentauthExtractResult {
42
+ violations: string[];
43
+ }
44
+ /**
45
+ * Attach PEAC carrier to paymentauth response headers.
46
+ *
47
+ * Sets PEAC-Receipt header with compact JWS. This is the PEAC evidence
48
+ * carrier; it coexists with (but is independent of) the paymentauth
49
+ * Payment-Receipt header.
50
+ */
51
+ export declare function attachCarrierToPaymentauthHeaders(headers: PaymentauthHeaderMap, carrier: PeacEvidenceCarrier): PaymentauthHeaderMap;
52
+ /**
53
+ * Extract PEAC carrier from paymentauth response headers (sync).
54
+ *
55
+ * Reads PEAC-Receipt header for compact JWS. Also captures the raw
56
+ * Payment-Receipt header value if present (upstream artifact, NOT
57
+ * stored in receipt_jws).
58
+ */
59
+ export declare function extractCarrierFromPaymentauthHeaders(headers: PaymentauthHeaderMap): PaymentauthExtractResult | null;
60
+ /**
61
+ * Extract PEAC carrier from paymentauth response headers (async).
62
+ *
63
+ * Computes receipt_ref from the PEAC-Receipt JWS.
64
+ */
65
+ export declare function extractCarrierFromPaymentauthHeadersAsync(headers: PaymentauthHeaderMap): Promise<PaymentauthExtractAsyncResult | null>;
66
+ /**
67
+ * CarrierAdapter implementation for paymentauth HTTP responses.
68
+ *
69
+ * Extracts PEAC-Receipt from response headers. Attaches PEAC-Receipt
70
+ * to response headers. Enforces 8 KB header size limits.
71
+ */
72
+ export declare class PaymentauthCarrierAdapter implements CarrierAdapter<PaymentauthResponseLike, PaymentauthResponseLike> {
73
+ extract(input: PaymentauthResponseLike): {
74
+ receipts: PeacEvidenceCarrier[];
75
+ meta: CarrierMeta;
76
+ } | null;
77
+ attach(output: PaymentauthResponseLike, carriers: PeacEvidenceCarrier[], meta?: CarrierMeta): PaymentauthResponseLike;
78
+ validateConstraints(carrier: PeacEvidenceCarrier, meta: CarrierMeta): CarrierValidationResult;
79
+ }
80
+ //# sourceMappingURL=carrier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"carrier.d.ts","sourceRoot":"","sources":["../src/carrier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EACV,mBAAmB,EACnB,WAAW,EACX,uBAAuB,EACvB,cAAc,EACf,MAAM,cAAc,CAAC;AActB,sEAAsE;AACtE,eAAO,MAAM,0BAA0B;;;CAG7B,CAAC;AAMX,wBAAwB;AACxB,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE1D,6CAA6C;AAC7C,MAAM,WAAW,uBAAuB;IACtC,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED,wBAAwB;AACxB,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,mBAAmB,EAAE,CAAC;IAChC,IAAI,EAAE,WAAW,CAAC;IAClB;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,8BAA8B;AAC9B,MAAM,WAAW,6BAA8B,SAAQ,wBAAwB;IAC7E,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB;AA2BD;;;;;;GAMG;AACH,wBAAgB,iCAAiC,CAC/C,OAAO,EAAE,oBAAoB,EAC7B,OAAO,EAAE,mBAAmB,GAC3B,oBAAoB,CAStB;AAMD;;;;;;GAMG;AACH,wBAAgB,oCAAoC,CAClD,OAAO,EAAE,oBAAoB,GAC5B,wBAAwB,GAAG,IAAI,CA0BjC;AAED;;;;GAIG;AACH,wBAAsB,yCAAyC,CAC7D,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,6BAA6B,GAAG,IAAI,CAAC,CAuB/C;AAMD;;;;;GAKG;AACH,qBAAa,yBAA0B,YAAW,cAAc,CAC9D,uBAAuB,EACvB,uBAAuB,CACxB;IACC,OAAO,CACL,KAAK,EAAE,uBAAuB,GAC7B;QAAE,QAAQ,EAAE,mBAAmB,EAAE,CAAC;QAAC,IAAI,EAAE,WAAW,CAAA;KAAE,GAAG,IAAI;IAKhE,MAAM,CACJ,MAAM,EAAE,uBAAuB,EAC/B,QAAQ,EAAE,mBAAmB,EAAE,EAC/B,IAAI,CAAC,EAAE,WAAW,GACjB,uBAAuB;IAsB1B,mBAAmB,CAAC,OAAO,EAAE,mBAAmB,EAAE,IAAI,EAAE,WAAW,GAAG,uBAAuB;CAG9F"}
@@ -0,0 +1,169 @@
1
+ "use strict";
2
+ /**
3
+ * Paymentauth carrier adapter for Evidence Carrier Contract.
4
+ *
5
+ * Header-only embed transport via PEAC-Receipt (compact JWS).
6
+ * All size limits enforce the 8 KB header ceiling (HTTP transport).
7
+ *
8
+ * receipt_ref is computed from the raw upstream artifact actually received
9
+ * (the literal Payment-Receipt header value), NOT assumed to be a JWS.
10
+ *
11
+ * Co-existence: PEAC PEAC-Receipt and paymentauth Payment-Receipt can
12
+ * appear on the same HTTP response. They serve different purposes:
13
+ * - PEAC-Receipt: signed PEAC interaction record (compact JWS)
14
+ * - Payment-Receipt: paymentauth payment receipt (base64url JSON)
15
+ * No semantic coupling is implied between them.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.PaymentauthCarrierAdapter = exports.PAYMENTAUTH_CARRIER_LIMITS = void 0;
19
+ exports.attachCarrierToPaymentauthHeaders = attachCarrierToPaymentauthHeaders;
20
+ exports.extractCarrierFromPaymentauthHeaders = extractCarrierFromPaymentauthHeaders;
21
+ exports.extractCarrierFromPaymentauthHeadersAsync = extractCarrierFromPaymentauthHeadersAsync;
22
+ const kernel_1 = require("@peac/kernel");
23
+ const schema_1 = require("@peac/schema");
24
+ const constants_js_1 = require("./constants.js");
25
+ // ---------------------------------------------------------------------------
26
+ // Constants
27
+ // ---------------------------------------------------------------------------
28
+ /** Paymentauth carrier size limits (HTTP header transport ceiling) */
29
+ exports.PAYMENTAUTH_CARRIER_LIMITS = {
30
+ embed: schema_1.CARRIER_TRANSPORT_LIMITS.acp_embed,
31
+ headers: schema_1.CARRIER_TRANSPORT_LIMITS.acp_headers,
32
+ };
33
+ // ---------------------------------------------------------------------------
34
+ // Helpers
35
+ // ---------------------------------------------------------------------------
36
+ function defaultMeta() {
37
+ return {
38
+ transport: 'paymentauth',
39
+ format: 'embed',
40
+ max_size: exports.PAYMENTAUTH_CARRIER_LIMITS.headers,
41
+ };
42
+ }
43
+ /** Case-insensitive header lookup (RFC 9110) */
44
+ function findHeader(headers, target) {
45
+ const targetLower = target.toLowerCase();
46
+ const key = Object.keys(headers).find((k) => k.toLowerCase() === targetLower);
47
+ if (!key)
48
+ return null;
49
+ const value = headers[key];
50
+ return value && value.length > 0 ? value : null;
51
+ }
52
+ // ---------------------------------------------------------------------------
53
+ // Attach
54
+ // ---------------------------------------------------------------------------
55
+ /**
56
+ * Attach PEAC carrier to paymentauth response headers.
57
+ *
58
+ * Sets PEAC-Receipt header with compact JWS. This is the PEAC evidence
59
+ * carrier; it coexists with (but is independent of) the paymentauth
60
+ * Payment-Receipt header.
61
+ */
62
+ function attachCarrierToPaymentauthHeaders(headers, carrier) {
63
+ if (!carrier.receipt_jws) {
64
+ throw new Error('Paymentauth carrier requires receipt_jws (embed format)');
65
+ }
66
+ headers[kernel_1.PEAC_RECEIPT_HEADER] = carrier.receipt_jws;
67
+ if (carrier.receipt_url) {
68
+ headers[kernel_1.PEAC_RECEIPT_URL_HEADER] = carrier.receipt_url;
69
+ }
70
+ return headers;
71
+ }
72
+ // ---------------------------------------------------------------------------
73
+ // Extract
74
+ // ---------------------------------------------------------------------------
75
+ /**
76
+ * Extract PEAC carrier from paymentauth response headers (sync).
77
+ *
78
+ * Reads PEAC-Receipt header for compact JWS. Also captures the raw
79
+ * Payment-Receipt header value if present (upstream artifact, NOT
80
+ * stored in receipt_jws).
81
+ */
82
+ function extractCarrierFromPaymentauthHeaders(headers) {
83
+ const jws = findHeader(headers, kernel_1.PEAC_RECEIPT_HEADER);
84
+ if (!jws)
85
+ return null;
86
+ const carrier = {
87
+ receipt_ref: 'sha256:0000000000000000000000000000000000000000000000000000000000000000',
88
+ receipt_jws: jws,
89
+ };
90
+ const receiptUrl = findHeader(headers, kernel_1.PEAC_RECEIPT_URL_HEADER);
91
+ if (receiptUrl) {
92
+ carrier.receipt_url = receiptUrl;
93
+ }
94
+ // Capture raw Payment-Receipt header if present (upstream artifact)
95
+ const rawPaymentReceipt = findHeader(headers, constants_js_1.PAYMENT_RECEIPT_HEADER);
96
+ return {
97
+ receipts: [carrier],
98
+ meta: {
99
+ ...defaultMeta(),
100
+ redaction: ['receipt_ref_pending_async'],
101
+ },
102
+ rawPaymentReceipt: rawPaymentReceipt ?? undefined,
103
+ };
104
+ }
105
+ /**
106
+ * Extract PEAC carrier from paymentauth response headers (async).
107
+ *
108
+ * Computes receipt_ref from the PEAC-Receipt JWS.
109
+ */
110
+ async function extractCarrierFromPaymentauthHeadersAsync(headers) {
111
+ const jws = findHeader(headers, kernel_1.PEAC_RECEIPT_HEADER);
112
+ if (!jws)
113
+ return null;
114
+ const ref = await (0, schema_1.computeReceiptRef)(jws);
115
+ const carrier = {
116
+ receipt_ref: ref,
117
+ receipt_jws: jws,
118
+ };
119
+ const receiptUrl = findHeader(headers, kernel_1.PEAC_RECEIPT_URL_HEADER);
120
+ if (receiptUrl) {
121
+ carrier.receipt_url = receiptUrl;
122
+ }
123
+ const rawPaymentReceipt = findHeader(headers, constants_js_1.PAYMENT_RECEIPT_HEADER);
124
+ return {
125
+ receipts: [carrier],
126
+ meta: defaultMeta(),
127
+ violations: [],
128
+ rawPaymentReceipt: rawPaymentReceipt ?? undefined,
129
+ };
130
+ }
131
+ // ---------------------------------------------------------------------------
132
+ // PaymentauthCarrierAdapter
133
+ // ---------------------------------------------------------------------------
134
+ /**
135
+ * CarrierAdapter implementation for paymentauth HTTP responses.
136
+ *
137
+ * Extracts PEAC-Receipt from response headers. Attaches PEAC-Receipt
138
+ * to response headers. Enforces 8 KB header size limits.
139
+ */
140
+ class PaymentauthCarrierAdapter {
141
+ extract(input) {
142
+ if (!input.headers)
143
+ return null;
144
+ return extractCarrierFromPaymentauthHeaders(input.headers);
145
+ }
146
+ attach(output, carriers, meta) {
147
+ if (carriers.length === 0)
148
+ return output;
149
+ const carrier = carriers[0];
150
+ if (!carrier.receipt_jws) {
151
+ throw new Error('Paymentauth carrier requires receipt_jws (embed format)');
152
+ }
153
+ const effectiveMeta = meta ?? defaultMeta();
154
+ const validation = (0, schema_1.validateCarrierConstraints)(carrier, effectiveMeta);
155
+ if (!validation.valid) {
156
+ throw new Error(`Carrier constraint violation: ${validation.violations.join('; ')}`);
157
+ }
158
+ if (!output.headers) {
159
+ output.headers = {};
160
+ }
161
+ attachCarrierToPaymentauthHeaders(output.headers, carrier);
162
+ return output;
163
+ }
164
+ validateConstraints(carrier, meta) {
165
+ return (0, schema_1.validateCarrierConstraints)(carrier, meta);
166
+ }
167
+ }
168
+ exports.PaymentauthCarrierAdapter = PaymentauthCarr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,KAAK,CAAC,iCAAiC,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACvF,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,MAAM,CAAC,OAAO,GAAG,EAAE,CAAC;QACtB,CAAC;QACD,iCAAiC,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAE3D,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,mBAAmB,CAAC,OAA4B,EAAE,IAAiB;QACjE,OAAO,IAAA,mCAA0B,EAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACnD,CAAC;CACF;AAxCD,8DAwCC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Constants for paymentauth/MPP mapping.
3
+ *
4
+ * The normative HTTP authentication scheme name is "Payment".
5
+ * "paymentauth" is the PEAC registry identifier.
6
+ * "MPP" is ecosystem branding and not used as a protocol identifier.
7
+ */
8
+ /** HTTP authentication scheme name (normative per draft-ryan-httpauth-payment) */
9
+ export declare const PAYMENTAUTH_SCHEME: "Payment";
10
+ /** WWW-Authenticate header name */
11
+ export declare const WWW_AUTHENTICATE: "WWW-Authenticate";
12
+ /** Authorization header name */
13
+ export declare const AUTHORIZATION: "Authorization";
14
+ /** Payment-Receipt response header name */
15
+ export declare const PAYMENT_RECEIPT_HEADER: "Payment-Receipt";
16
+ /** Maximum header byte length (8 KB per paymentauth size considerations, Section 9.4) */
17
+ export declare const MAX_HEADER_BYTES = 8192;
18
+ /** Maximum decoded payload byte length */
19
+ export declare const MAX_DECODED_PAYLOAD_BYTES = 65536;
20
+ /** Maximum JSON nesting depth for decoded payloads */
21
+ export declare const MAX_JSON_NESTING_DEPTH = 10;
22
+ /** Maximum auth-param count per challenge */
23
+ export declare const MAX_AUTH_PARAMS = 32;
24
+ /** PEAC payment rail identifier for paymentauth */
25
+ export declare const PAYMENTAUTH_RAIL: "paymentauth";
26
+ /** JSON-RPC error code: Payment Required */
27
+ export declare const JSONRPC_PAYMENT_REQUIRED = -32042;
28
+ /** JSON-RPC error code: Verification Failed */
29
+ export declare const JSONRPC_VERIFICATION_FAILED = -32043;
30
+ /** MCP _meta key for paymentauth credential */
31
+ export declare const MCP_META_CREDENTIAL: "org.paymentauth/credential";
32
+ /** MCP _meta key for paymentauth receipt */
33
+ export declare const MCP_META_RECEIPT: "org.paymentauth/receipt";
34
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,kFAAkF;AAClF,eAAO,MAAM,kBAAkB,EAAG,SAAkB,CAAC;AAErD,mCAAmC;AACnC,eAAO,MAAM,gBAAgB,EAAG,kBAA2B,CAAC;AAE5D,gCAAgC;AAChC,eAAO,MAAM,aAAa,EAAG,eAAwB,CAAC;AAEtD,2CAA2C;AAC3C,eAAO,MAAM,sBAAsB,EAAG,iBAA0B,CAAC;AAMjE,yFAAyF;AACzF,eAAO,MAAM,gBAAgB,OAAQ,CAAC;AAEtC,0CAA0C;AAC1C,eAAO,MAAM,yBAAyB,QAAS,CAAC;AAEhD,sDAAsD;AACtD,eAAO,MAAM,sBAAsB,KAAK,CAAC;AAEzC,6CAA6C;AAC7C,eAAO,MAAM,eAAe,KAAK,CAAC;AAElC,mDAAmD;AACnD,eAAO,MAAM,gBAAgB,EAAG,aAAsB,CAAC;AAMvD,4CAA4C;AAC5C,eAAO,MAAM,wBAAwB,SAAS,CAAC;AAE/C,+CAA+C;AAC/C,eAAO,MAAM,2BAA2B,SAAS,CAAC;AAMlD,+CAA+C;AAC/C,eAAO,MAAM,mBAAmB,EAAG,4BAAqC,CAAC;AAEzE,4CAA4C;AAC5C,eAAO,MAAM,gBAAgB,EAAG,yBAAkC,CAAC"}
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ /**
3
+ * Constants for paymentauth/MPP mapping.
4
+ *
5
+ * The normative HTTP authentication scheme name is "Payment".
6
+ * "paymentauth" is the PEAC registry identifier.
7
+ * "MPP" is ecosystem branding and not used as a protocol identifier.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.MCP_META_RECEIPT = exports.MCP_META_CREDENTIAL = exports.JSONRPC_VERIFICATION_FAILED = exports.JSONRPC_PAYMENT_REQUIRED = exports.PAYMENTAUTH_RAIL = exports.MAX_AUTH_PARAMS = exports.MAX_JSON_NESTING_DEPTH = exports.MAX_DECODED_PAYLOAD_BYTES = exports.MAX_HEADER_BYTES = exports.PAYMENT_RECEIPT_HEADER = exports.AUTHORIZATION = exports.WWW_AUTHENTICATE = exports.PAYMENTAUTH_SCHEME = void 0;
11
+ /** HTTP authentication scheme name (normative per draft-ryan-httpauth-payment) */
12
+ exports.PAYMENTAUTH_SCHEME = 'Payment';
13
+ /** WWW-Authenticate header name */
14
+ exports.WWW_AUTHENTICATE = 'WWW-Authenticate';
15
+ /** Authorization header name */
16
+ exports.AUTHORIZATION = 'Authorization';
17
+ /** Payment-Receipt response header name */
18
+ exports.PAYMENT_RECEIPT_HEADER = 'Payment-Receipt';
19
+ // ---------------------------------------------------------------------------
20
+ // Parser Limits (security hardening)
21
+ // ---------------------------------------------------------------------------
22
+ /** Maximum header byte length (8 KB per paymentauth size considerations, Section 9.4) */
23
+ exports.MAX_HEADER_BYTES = 8_192;
24
+ /** Maximum decoded payload byte length */
25
+ exports.MAX_DECODED_PAYLOAD_BYTES = 65_536;
26
+ /** Maximum JSON nesting depth for decoded payloads */
27
+ exports.MAX_JSON_NESTING_DEPTH = 10;
28
+ /** Maximum auth-param count per challenge */
29
+ exports.MAX_AUTH_PARAMS = 32;
30
+ /** PEAC payment rail identifier for paymentauth */
31
+ exports.PAYMENTAUTH_RAIL = 'paymentauth';
32
+ // ---------------------------------------------------------------------------
33
+ // JSON-RPC Error Codes (draft-payment-transport-mcp-00)
34
+ // ---------------------------------------------------------------------------
35
+ /** JSON-RPC error code: Payment Required */
36
+ exports.JSONRPC_PAYMENT_REQUIRED = -32042;
37
+ /** JSON-RPC error code: Verification Failed */
38
+ exports.JSONRPC_VERIFICATION_FAILED = -32043;
39
+ // ---------------------------------------------------------------------------
40
+ // MCP _meta Keys (draft-payment-transport-mcp-00)
41
+ // ---------------------------------------------------------------------------
42
+ /** MCP _meta key for paymentauth credential */
43
+ exports.MCP_META_CREDENTIAL = 'org.paymentauth/credential';
44
+ /** MCP _meta key for paymentauth receipt */
45
+ exports.MCP_META_RECEIPT = 'org.paymentauth/receipt';
46
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,kFAAkF;AACrE,QAAA,kBAAkB,GAAG,SAAkB,CAAC;AAErD,mCAAmC;AACtB,QAAA,gBAAgB,GAAG,kBAA2B,CAAC;AAE5D,gCAAgC;AACnB,QAAA,aAAa,GAAG,eAAwB,CAAC;AAEtD,2CAA2C;AAC9B,QAAA,sBAAsB,GAAG,iBAA0B,CAAC;AAEjE,8EAA8E;AAC9E,qCAAqC;AACrC,8EAA8E;AAE9E,yFAAyF;AAC5E,QAAA,gBAAgB,GAAG,KAAK,CAAC;AAEtC,0CAA0C;AAC7B,QAAA,yBAAyB,GAAG,MAAM,CAAC;AAEhD,sDAAsD;AACzC,QAAA,sBAAsB,GAAG,EAAE,CAAC;AAEzC,6CAA6C;AAChC,QAAA,eAAe,GAAG,EAAE,CAAC;AAElC,mDAAmD;AACtC,QAAA,gBAAgB,GAAG,aAAsB,CAAC;AAEvD,8EAA8E;AAC9E,wDAAwD;AACxD,8EAA8E;AAE9E,4CAA4C;AAC/B,QAAA,wBAAwB,GAAG,CAAC,KAAK,CAAC;AAE/C,+CAA+C;AAClC,QAAA,2BAA2B,GAAG,CAAC,KAAK,CAAC;AAElD,8EAA8E;AAC9E,kDAAkD;AAClD,8EAA8E;AAE9E,+CAA+C;AAClC,QAAA,mBAAmB,GAAG,4BAAqC,CAAC;AAEzE,4CAA4C;AAC/B,QAAA,gBAAgB,GAAG,yBAAkC,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Paymentauth discovery extraction from OpenAPI documents.
3
+ *
4
+ * Parses x-service-info and x-payment-info extensions per
5
+ * draft-payment-discovery-00. Pure extraction; no network I/O.
6
+ *
7
+ * The OpenAPI document is useful for discovery, but the live 402
8
+ * challenge is always authoritative (per discovery spec).
9
+ */
10
+ import type { PaymentauthServiceInfo, PaymentauthPaymentInfo } from './types.js';
11
+ /**
12
+ * Extract x-service-info from an OpenAPI document root.
13
+ *
14
+ * Returns null if the extension is absent or malformed.
15
+ */
16
+ export declare function extractServiceInfo(openapiDoc: unknown): PaymentauthServiceInfo | null;
17
+ /**
18
+ * Extract x-payment-info from an OpenAPI operation.
19
+ *
20
+ * Returns null if the extension is absent or malformed.
21
+ */
22
+ export declare function extractPaymentInfo(operation: unknown): PaymentauthPaymentInfo | null;
23
+ //# sourceMappingURL=discovery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEjF;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,OAAO,GAAG,sBAAsB,GAAG,IAAI,CA2BrF;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,OAAO,GAAG,sBAAsB,GAAG,IAAI,CAuBpF"}