@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 +190 -0
- package/README.md +31 -0
- package/dist/carrier.d.ts +80 -0
- package/dist/carrier.d.ts.map +1 -0
- package/dist/carrier.js +169 -0
- package/dist/carrier.js.map +1 -0
- package/dist/constants.d.ts +34 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +46 -0
- package/dist/constants.js.map +1 -0
- package/dist/discovery.d.ts +23 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +74 -0
- package/dist/discovery.js.map +1 -0
- package/dist/errors.d.ts +13 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +20 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +63 -0
- package/dist/index.js.map +1 -0
- package/dist/jsonrpc.d.ts +37 -0
- package/dist/jsonrpc.d.ts.map +1 -0
- package/dist/jsonrpc.js +83 -0
- package/dist/jsonrpc.js.map +1 -0
- package/dist/map.d.ts +38 -0
- package/dist/map.d.ts.map +1 -0
- package/dist/map.js +96 -0
- package/dist/map.js.map +1 -0
- package/dist/mcp.d.ts +44 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +62 -0
- package/dist/mcp.js.map +1 -0
- package/dist/parse.d.ts +70 -0
- package/dist/parse.d.ts.map +1 -0
- package/dist/parse.js +399 -0
- package/dist/parse.js.map +1 -0
- package/dist/types.d.ts +139 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +16 -0
- package/dist/types.js.map +1 -0
- package/package.json +40 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Paymentauth discovery extraction from OpenAPI documents.
|
|
4
|
+
*
|
|
5
|
+
* Parses x-service-info and x-payment-info extensions per
|
|
6
|
+
* draft-payment-discovery-00. Pure extraction; no network I/O.
|
|
7
|
+
*
|
|
8
|
+
* The OpenAPI document is useful for discovery, but the live 402
|
|
9
|
+
* challenge is always authoritative (per discovery spec).
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.extractServiceInfo = extractServiceInfo;
|
|
13
|
+
exports.extractPaymentInfo = extractPaymentInfo;
|
|
14
|
+
/**
|
|
15
|
+
* Extract x-service-info from an OpenAPI document root.
|
|
16
|
+
*
|
|
17
|
+
* Returns null if the extension is absent or malformed.
|
|
18
|
+
*/
|
|
19
|
+
function extractServiceInfo(openapiDoc) {
|
|
20
|
+
if (!openapiDoc || typeof openapiDoc !== 'object' || Array.isArray(openapiDoc)) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
const doc = openapiDoc;
|
|
24
|
+
const info = doc['x-service-info'];
|
|
25
|
+
if (!info || typeof info !== 'object' || Array.isArray(info)) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
const raw = info;
|
|
29
|
+
const result = {};
|
|
30
|
+
if (Array.isArray(raw.categories)) {
|
|
31
|
+
result.categories = raw.categories.filter((c) => typeof c === 'string');
|
|
32
|
+
}
|
|
33
|
+
if (raw.docs && typeof raw.docs === 'object' && !Array.isArray(raw.docs)) {
|
|
34
|
+
const docs = raw.docs;
|
|
35
|
+
result.docs = {};
|
|
36
|
+
if (typeof docs.apiReference === 'string')
|
|
37
|
+
result.docs.apiReference = docs.apiReference;
|
|
38
|
+
if (typeof docs.homepage === 'string')
|
|
39
|
+
result.docs.homepage = docs.homepage;
|
|
40
|
+
if (typeof docs.llms === 'string')
|
|
41
|
+
result.docs.llms = docs.llms;
|
|
42
|
+
}
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Extract x-payment-info from an OpenAPI operation.
|
|
47
|
+
*
|
|
48
|
+
* Returns null if the extension is absent or malformed.
|
|
49
|
+
*/
|
|
50
|
+
function extractPaymentInfo(operation) {
|
|
51
|
+
if (!operation || typeof operation !== 'object' || Array.isArray(operation)) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
const op = operation;
|
|
55
|
+
const info = op['x-payment-info'];
|
|
56
|
+
if (!info || typeof info !== 'object' || Array.isArray(info)) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
const raw = info;
|
|
60
|
+
const result = {};
|
|
61
|
+
if (typeof raw.intent === 'string')
|
|
62
|
+
result.intent = raw.intent;
|
|
63
|
+
if (typeof raw.method === 'string')
|
|
64
|
+
result.method = raw.method;
|
|
65
|
+
if (typeof raw.amount === 'string' || raw.amount === null) {
|
|
66
|
+
result.amount = raw.amount;
|
|
67
|
+
}
|
|
68
|
+
if (typeof raw.currency === 'string')
|
|
69
|
+
result.currency = raw.currency;
|
|
70
|
+
if (typeof raw.description === 'string')
|
|
71
|
+
result.description = raw.description;
|
|
72
|
+
return result;
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=discovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery.js","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;AASH,gDA2BC;AAOD,gDAuBC;AA9DD;;;;GAIG;AACH,SAAgB,kBAAkB,CAAC,UAAmB;IACpD,IAAI,CAAC,UAAU,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QAC/E,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,GAAG,GAAG,UAAqC,CAAC;IAClD,MAAM,IAAI,GAAG,GAAG,CAAC,gBAAgB,CAAC,CAAC;IACnC,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7D,OAAO,IAAI,CAAC;IACd,CAAC;IAED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I,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7D,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,GAAG,GAAG,IAA+B,CAAC;IAC5C,MAAM,MAAM,GAA2B,EAAE,CAAC;IAE1C,IAAI,OAAO,GAAG,CAAC,MAAM,KAAK,QAAQ;QAAE,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC;IAC/D,IAAI,OAAO,GAAG,CAAC,MAAM,KAAK,QAAQ;QAAE,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC;IAC/D,IAAI,OAAO,GAAG,CAAC,MAAM,KAAK,QAAQ,IAAI,GAAG,CAAC,MAAM,KAAK,IAAI,EAAE,CAAC;QAC1D,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,MAAuB,CAAC;IAC9C,CAAC;IACD,IAAI,OAAO,GAAG,CAAC,QAAQ,KAAK,QAAQ;QAAE,MAAM,CAAC,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;IACrE,IAAI,OAAO,GAAG,CAAC,WAAW,KAAK,QAAQ;QAAE,MAAM,CAAC,WAAW,GAAG,GAAG,CAAC,WAAW,CAAC;IAE9E,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Paymentauth mapping errors.
|
|
3
|
+
*
|
|
4
|
+
* SECURITY: error messages MUST NOT contain raw Authorization: Payment
|
|
5
|
+
* or Payment-Receipt header values. Use redactPaymentauthHeader() for
|
|
6
|
+
* safe logging.
|
|
7
|
+
*/
|
|
8
|
+
export type PaymentauthErrorCode = 'PARSE_HEADER_TOO_LARGE' | 'PARSE_TOO_MANY_PARAMS' | 'PARSE_MISSING_SCHEME' | 'PARSE_MISSING_REQUIRED_PARAM' | 'PARSE_INVALID_BASE64URL' | 'PARSE_PAYLOAD_TOO_LARGE' | 'PARSE_JSON_DEPTH_EXCEEDED' | 'PARSE_INVALID_UTF8' | 'NORMALIZE_MISSING_FIELD';
|
|
9
|
+
export declare class PaymentauthError extends Error {
|
|
10
|
+
readonly code: PaymentauthErrorCode;
|
|
11
|
+
constructor(code: PaymentauthErrorCode, message: string);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,MAAM,oBAAoB,GAC5B,wBAAwB,GACxB,uBAAuB,GACvB,sBAAsB,GACtB,8BAA8B,GAC9B,yBAAyB,GACzB,yBAAyB,GACzB,2BAA2B,GAC3B,oBAAoB,GACpB,yBAAyB,CAAC;AAE9B,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAC;gBAExB,IAAI,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM;CAKxD"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Paymentauth mapping errors.
|
|
4
|
+
*
|
|
5
|
+
* SECURITY: error messages MUST NOT contain raw Authorization: Payment
|
|
6
|
+
* or Payment-Receipt header values. Use redactPaymentauthHeader() for
|
|
7
|
+
* safe logging.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.PaymentauthError = void 0;
|
|
11
|
+
class PaymentauthError extends Error {
|
|
12
|
+
code;
|
|
13
|
+
constructor(code, message) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.name = 'PaymentauthError';
|
|
16
|
+
this.code = code;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.PaymentauthError = PaymentauthError;
|
|
20
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAaH,MAAa,gBAAiB,SAAQ,KAAK;IAChC,IAAI,CAAuB;IAEpC,YAAY,IAA0B,EAAE,OAAe;QACrD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AARD,4CAQC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @peac/mappings-paymentauth
|
|
3
|
+
*
|
|
4
|
+
* HTTP Payment authentication scheme (paymentauth/MPP) mapping for PEAC.
|
|
5
|
+
* Envelope-first parsing with raw + normalized types.
|
|
6
|
+
* Method-specific payloads treated as `unknown`.
|
|
7
|
+
* No network I/O.
|
|
8
|
+
*/
|
|
9
|
+
export { PAYMENTAUTH_SCHEME, WWW_AUTHENTICATE, AUTHORIZATION, PAYMENT_RECEIPT_HEADER, MAX_HEADER_BYTES, MAX_DECODED_PAYLOAD_BYTES, MAX_JSON_NESTING_DEPTH, MAX_AUTH_PARAMS, PAYMENTAUTH_RAIL, JSONRPC_PAYMENT_REQUIRED, JSONRPC_VERIFICATION_FAILED, MCP_META_CREDENTIAL, MCP_META_RECEIPT, } from './constants.js';
|
|
10
|
+
export type { RawPaymentauthChallenge, RawPaymentauthCredential, RawPaymentauthReceipt, NormalizedPaymentauthChallenge, NormalizedPaymentauthCredential, NormalizedPaymentauthReceipt, PaymentauthServiceInfo, PaymentauthPaymentInfo, } from './types.js';
|
|
11
|
+
export { PaymentauthError } from './errors.js';
|
|
12
|
+
export type { PaymentauthErrorCode } from './errors.js';
|
|
13
|
+
export { redactPaymentauthHeader, parsePaymentauthChallenges, parsePaymentauthCredential, parsePaymentauthReceipt, normalizeChallenge, normalizeCredential, normalizeReceipt, } from './parse.js';
|
|
14
|
+
export { extractServiceInfo, extractPaymentInfo } from './discovery.js';
|
|
15
|
+
export { isPaymentRequiredError, isVerificationFailedError, parsePaymentauthFromJsonRpcError, parsePaymentauthFromJsonRpcResult, } from './jsonrpc.js';
|
|
16
|
+
export type { PaymentauthMcpCapability } from './mcp.js';
|
|
17
|
+
export { extractCredentialFromMcpMeta, extractReceiptFromMcpMeta, extractPaymentauthCapability, } from './mcp.js';
|
|
18
|
+
export { fromPaymentauthReceipt, toCommerceExtensionFields } from './map.js';
|
|
19
|
+
export type { PaymentauthHeaderMap, PaymentauthResponseLike, PaymentauthExtractResult, PaymentauthExtractAsyncResult, } from './carrier.js';
|
|
20
|
+
export { PAYMENTAUTH_CARRIER_LIMITS, attachCarrierToPaymentauthHeaders, extractCarrierFromPaymentauthHeaders, extractCarrierFromPaymentauthHeadersAsync, PaymentauthCarrierAdapter, } from './carrier.js';
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACb,sBAAsB,EACtB,gBAAgB,EAChB,yBAAyB,EACzB,sBAAsB,EACtB,eAAe,EACf,gBAAgB,EAChB,wBAAwB,EACxB,2BAA2B,EAC3B,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AAGxB,YAAY,EACV,uBAAuB,EACvB,wBAAwB,EACxB,qBAAqB,EACrB,8BAA8B,EAC9B,+BAA+B,EAC/B,4BAA4B,EAC5B,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAGxD,OAAO,EACL,uBAAuB,EACvB,0BAA0B,EAC1B,0BAA0B,EAC1B,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAGxE,OAAO,EACL,sBAAsB,EACtB,yBAAyB,EACzB,gCAAgC,EAChC,iCAAiC,GAClC,MAAM,cAAc,CAAC;AAGtB,YAAY,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EACL,4BAA4B,EAC5B,yBAAyB,EACzB,4BAA4B,GAC7B,MAAM,UAAU,CAAC;AAGlB,OAAO,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAG7E,YAAY,EACV,oBAAoB,EACpB,uBAAuB,EACvB,wBAAwB,EACxB,6BAA6B,GAC9B,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,0BAA0B,EAC1B,iCAAiC,EACjC,oCAAoC,EACpC,yCAAyC,EACzC,yBAAyB,GAC1B,MAAM,cAAc,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @peac/mappings-paymentauth
|
|
4
|
+
*
|
|
5
|
+
* HTTP Payment authentication scheme (paymentauth/MPP) mapping for PEAC.
|
|
6
|
+
* Envelope-first parsing with raw + normalized types.
|
|
7
|
+
* Method-specific payloads treated as `unknown`.
|
|
8
|
+
* No network I/O.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.PaymentauthCarrierAdapter = exports.extractCarrierFromPaymentauthHeadersAsync = exports.extractCarrierFromPaymentauthHeaders = exports.attachCarrierToPaymentauthHeaders = exports.PAYMENTAUTH_CARRIER_LIMITS = exports.toCommerceExtensionFields = exports.fromPaymentauthReceipt = exports.extractPaymentauthCapability = exports.extractReceiptFromMcpMeta = exports.extractCredentialFromMcpMeta = exports.parsePaymentauthFromJsonRpcResult = exports.parsePaymentauthFromJsonRpcError = exports.isVerificationFailedError = exports.isPaymentRequiredError = exports.extractPaymentInfo = exports.extractServiceInfo = exports.normalizeReceipt = exports.normalizeCredential = exports.normalizeChallenge = exports.parsePaymentauthReceipt = exports.parsePaymentauthCredential = exports.parsePaymentauthChallenges = exports.redactPaymentauthHeader = exports.PaymentauthError = 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;
|
|
12
|
+
// Constants
|
|
13
|
+
var constants_js_1 = require("./constants.js");
|
|
14
|
+
Object.defineProperty(exports, "PAYMENTAUTH_SCHEME", { enumerable: true, get: function () { return constants_js_1.PAYMENTAUTH_SCHEME; } });
|
|
15
|
+
Object.defineProperty(exports, "WWW_AUTHENTICATE", { enumerable: true, get: function () { return constants_js_1.WWW_AUTHENTICATE; } });
|
|
16
|
+
Object.defineProperty(exports, "AUTHORIZATION", { enumerable: true, get: function () { return constants_js_1.AUTHORIZATION; } });
|
|
17
|
+
Object.defineProperty(exports, "PAYMENT_RECEIPT_HEADER", { enumerable: true, get: function () { return constants_js_1.PAYMENT_RECEIPT_HEADER; } });
|
|
18
|
+
Object.defineProperty(exports, "MAX_HEADER_BYTES", { enumerable: true, get: function () { return constants_js_1.MAX_HEADER_BYTES; } });
|
|
19
|
+
Object.defineProperty(exports, "MAX_DECODED_PAYLOAD_BYTES", { enumerable: true, get: function () { return constants_js_1.MAX_DECODED_PAYLOAD_BYTES; } });
|
|
20
|
+
Object.defineProperty(exports, "MAX_JSON_NESTING_DEPTH", { enumerable: true, get: function () { return constants_js_1.MAX_JSON_NESTING_DEPTH; } });
|
|
21
|
+
Object.defineProperty(exports, "MAX_AUTH_PARAMS", { enumerable: true, get: function () { return constants_js_1.MAX_AUTH_PARAMS; } });
|
|
22
|
+
Object.defineProperty(exports, "PAYMENTAUTH_RAIL", { enumerable: true, get: function () { return constants_js_1.PAYMENTAUTH_RAIL; } });
|
|
23
|
+
Object.defineProperty(exports, "JSONRPC_PAYMENT_REQUIRED", { enumerable: true, get: function () { return constants_js_1.JSONRPC_PAYMENT_REQUIRED; } });
|
|
24
|
+
Object.defineProperty(exports, "JSONRPC_VERIFICATION_FAILED", { enumerable: true, get: function () { return constants_js_1.JSONRPC_VERIFICATION_FAILED; } });
|
|
25
|
+
Object.defineProperty(exports, "MCP_META_CREDENTIAL", { enumerable: true, get: function () { return constants_js_1.MCP_META_CREDENTIAL; } });
|
|
26
|
+
Object.defineProperty(exports, "MCP_META_RECEIPT", { enumerable: true, get: function () { return constants_js_1.MCP_META_RECEIPT; } });
|
|
27
|
+
// Errors
|
|
28
|
+
var errors_js_1 = require("./errors.js");
|
|
29
|
+
Object.defineProperty(exports, "PaymentauthError", { enumerable: true, get: function () { return errors_js_1.PaymentauthError; } });
|
|
30
|
+
// Parsing and normalization
|
|
31
|
+
var parse_js_1 = require("./parse.js");
|
|
32
|
+
Object.defineProperty(exports, "redactPaymentauthHeader", { enumerable: true, get: function () { return parse_js_1.redactPaymentauthHeader; } });
|
|
33
|
+
Object.defineProperty(exports, "parsePaymentauthChallenges", { enumerable: true, get: function () { return parse_js_1.parsePaymentauthChallenges; } });
|
|
34
|
+
Object.defineProperty(exports, "parsePaymentauthCredential", { enumerable: true, get: function () { return parse_js_1.parsePaymentauthCredential; } });
|
|
35
|
+
Object.defineProperty(exports, "parsePaymentauthReceipt", { enumerable: true, get: function () { return parse_js_1.parsePaymentauthReceipt; } });
|
|
36
|
+
Object.defineProperty(exports, "normalizeChallenge", { enumerable: true, get: function () { return parse_js_1.normalizeChallenge; } });
|
|
37
|
+
Object.defineProperty(exports, "normalizeCredential", { enumerable: true, get: function () { return parse_js_1.normalizeCredential; } });
|
|
38
|
+
Object.defineProperty(exports, "normalizeReceipt", { enumerable: true, get: function () { return parse_js_1.normalizeReceipt; } });
|
|
39
|
+
// Discovery
|
|
40
|
+
var discovery_js_1 = require("./discovery.js");
|
|
41
|
+
Object.defineProperty(exports, "extractServiceInfo", { enumerable: true, get: function () { return discovery_js_1.extractServiceInfo; } });
|
|
42
|
+
Object.defineProperty(exports, "extractPaymentInfo", { enumerable: true, get: function () { return discovery_js_1.extractPaymentInfo; } });
|
|
43
|
+
// JSON-RPC transport helpers
|
|
44
|
+
var jsonrpc_js_1 = require("./jsonrpc.js");
|
|
45
|
+
Object.defineProperty(exports, "isPaymentRequiredError", { enumerable: true, get: function () { return jsonrpc_js_1.isPaymentRequiredError; } });
|
|
46
|
+
Object.defineProperty(exports, "isVerificationFailedError", { enumerable: true, get: function () { return jsonrpc_js_1.isVerificationFailedError; } });
|
|
47
|
+
Object.defineProperty(exports, "parsePaymentauthFromJsonRpcError", { enumerable: true, get: function () { return jsonrpc_js_1.parsePaymentauthFromJsonRpcError; } });
|
|
48
|
+
Object.defineProperty(exports, "parsePaymentauthFromJsonRpcResult", { enumerable: true, get: function () { return jsonrpc_js_1.parsePaymentauthFromJsonRpcResult; } });
|
|
49
|
+
var mcp_js_1 = require("./mcp.js");
|
|
50
|
+
Object.defineProperty(exports, "extractCredentialFromMcpMeta", { enumerable: true, get: function () { return mcp_js_1.extractCredentialFromMcpMeta; } });
|
|
51
|
+
Object.defineProperty(exports, "extractReceiptFromMcpMeta", { enumerable: true, get: function () { return mcp_js_1.extractReceiptFromMcpMeta; } });
|
|
52
|
+
Object.defineProperty(exports, "extractPaymentauthCapability", { enumerable: true, get: function () { return mcp_js_1.extractPaymentauthCapability; } });
|
|
53
|
+
// Evidence mapping
|
|
54
|
+
var map_js_1 = require("./map.js");
|
|
55
|
+
Object.defineProperty(exports, "fromPaymentauthReceipt", { enumerable: true, get: function () { return map_js_1.fromPaymentauthReceipt; } });
|
|
56
|
+
Object.defineProperty(exports, "toCommerceExtensionFields", { enumerable: true, get: function () { return map_js_1.toCommerceExtensionFields; } });
|
|
57
|
+
var carrier_js_1 = require("./carrier.js");
|
|
58
|
+
Object.defineProperty(exports, "PAYMENTAUTH_CARRIER_LIMITS", { enumerable: true, get: function () { return carrier_js_1.PAYMENTAUTH_CARRIER_LIMITS; } });
|
|
59
|
+
Object.defineProperty(exports, "attachCarrierToPaymentauthHeaders", { enumerable: true, get: function () { return carrier_js_1.attachCarrierToPaymentauthHeaders; } });
|
|
60
|
+
Object.defineProperty(exports, "extractCarrierFromPaymentauthHeaders", { enumerable: true, get: function () { return carrier_js_1.extractCarrierFromPaymentauthHeaders; } });
|
|
61
|
+
Object.defineProperty(exports, "extractCarrierFromPaymentauthHeadersAsync", { enumerable: true, get: function () { return carrier_js_1.extractCarrierFromPaymentauthHeadersAsync; } });
|
|
62
|
+
Object.defineProperty(exports, "PaymentauthCarrierAdapter", { enumerable: true, get: function () { return carrier_js_1.PaymentauthCarrierAdapter; } });
|
|
63
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAEH,YAAY;AACZ,+CAcwB;AAbtB,kHAAA,kBAAkB,OAAA;AAClB,gHAAA,gBAAgB,OAAA;AAChB,6GAAA,aAAa,OAAA;AACb,sHAAA,sBAAsB,OAAA;AACtB,gHAAA,gBAAgB,OAAA;AAChB,yHAAA,yBAAyB,OAAA;AACzB,sHAAA,sBAAsB,OAAA;AACtB,+GAAA,eAAe,OAAA;AACf,gHAAA,gBAAgB,OAAA;AAChB,wHAAA,wBAAwB,OAAA;AACxB,2HAAA,2BAA2B,OAAA;AAC3B,mHAAA,mBAAmB,OAAA;AACnB,gHAAA,gBAAgB,OAAA;AAelB,SAAS;AACT,yCAA+C;AAAtC,6GAAA,gBAAgB,OAAA;AAGzB,4BAA4B;AAC5B,uCAQoB;AAPlB,mHAAA,uBAAuB,OAAA;AACvB,sHAAA,0BAA0B,OAAA;AAC1B,sHAAA,0BAA0B,OAAA;AAC1B,mHAAA,uBAAuB,OAAA;AACvB,8GAAA,kBAAkB,OAAA;AAClB,+GAAA,mBAAmB,OAAA;AACnB,4GAAA,gBAAgB,OAAA;AAGlB,YAAY;AACZ,+CAAwE;AAA/D,kHAAA,kBAAkB,OAAA;AAAE,kHAAA,kBAAkB,OAAA;AAE/C,6BAA6B;AAC7B,2CAKsB;AAJpB,oHAAA,sBAAsB,OAAA;AACtB,uHAAA,yBAAyB,OAAA;AACzB,8HAAA,gCAAgC,OAAA;AAChC,+HAAA,iCAAiC,OAAA;AAKnC,mCAIkB;AAHhB,sHAAA,4BAA4B,OAAA;AAC5B,mHAAA,yBAAyB,OAAA;AACzB,sHAAA,4BAA4B,OAAA;AAG9B,mBAAmB;AACnB,mCAA6E;AAApE,gHAAA,sBAAsB,OAAA;AAAE,mHAAA,yBAAyB,OAAA;AAU1D,2CAMsB;AALpB,wHAAA,0BAA0B,OAAA;AAC1B,+HAAA,iCAAiC,OAAA;AACjC,kIAAA,oCAAoC,OAAA;AACpC,uIAAA,yCAAyC,OAAA;AACzC,uHAAA,yBAAyB,OAAA"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Paymentauth JSON-RPC transport helpers.
|
|
3
|
+
*
|
|
4
|
+
* Generic JSON-RPC error detection and challenge/receipt extraction
|
|
5
|
+
* per draft-payment-transport-mcp-00 (JSON-RPC section).
|
|
6
|
+
* Separated from MCP-specific sugar in mcp.ts.
|
|
7
|
+
*/
|
|
8
|
+
import type { RawPaymentauthChallenge, RawPaymentauthReceipt } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Check if a JSON-RPC error indicates payment is required.
|
|
11
|
+
*/
|
|
12
|
+
export declare function isPaymentRequiredError(error: {
|
|
13
|
+
code: number;
|
|
14
|
+
}): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Check if a JSON-RPC error indicates verification failed.
|
|
17
|
+
*/
|
|
18
|
+
export declare function isVerificationFailedError(error: {
|
|
19
|
+
code: number;
|
|
20
|
+
}): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Extract paymentauth challenge from a JSON-RPC -32042 error.
|
|
23
|
+
*
|
|
24
|
+
* The error data may contain a challenge string (WWW-Authenticate value)
|
|
25
|
+
* or structured challenge parameters.
|
|
26
|
+
*/
|
|
27
|
+
export declare function parsePaymentauthFromJsonRpcError(error: {
|
|
28
|
+
code: number;
|
|
29
|
+
data?: unknown;
|
|
30
|
+
}): RawPaymentauthChallenge | null;
|
|
31
|
+
/**
|
|
32
|
+
* Extract paymentauth receipt from a JSON-RPC result.
|
|
33
|
+
*
|
|
34
|
+
* The result may contain a receipt field (Payment-Receipt value).
|
|
35
|
+
*/
|
|
36
|
+
export declare function parsePaymentauthFromJsonRpcResult(result: unknown): RawPaymentauthReceipt | null;
|
|
37
|
+
//# sourceMappingURL=jsonrpc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonrpc.d.ts","sourceRoot":"","sources":["../src/jsonrpc.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAGjF;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAEvE;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAE1E;AAED;;;;;GAKG;AACH,wBAAgB,gCAAgC,CAAC,KAAK,EAAE;IACtD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,GAAG,uBAAuB,GAAG,IAAI,CA6BjC;AAED;;;;GAIG;AACH,wBAAgB,iCAAiC,CAAC,MAAM,EAAE,OAAO,GAAG,qBAAqB,GAAG,IAAI,CAY/F"}
|
package/dist/jsonrpc.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Paymentauth JSON-RPC transport helpers.
|
|
4
|
+
*
|
|
5
|
+
* Generic JSON-RPC error detection and challenge/receipt extraction
|
|
6
|
+
* per draft-payment-transport-mcp-00 (JSON-RPC section).
|
|
7
|
+
* Separated from MCP-specific sugar in mcp.ts.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.isPaymentRequiredError = isPaymentRequiredError;
|
|
11
|
+
exports.isVerificationFailedError = isVerificationFailedError;
|
|
12
|
+
exports.parsePaymentauthFromJsonRpcError = parsePaymentauthFromJsonRpcError;
|
|
13
|
+
exports.parsePaymentauthFromJsonRpcResult = parsePaymentauthFromJsonRpcResult;
|
|
14
|
+
const constants_js_1 = require("./constants.js");
|
|
15
|
+
const parse_js_1 = require("./parse.js");
|
|
16
|
+
/**
|
|
17
|
+
* Check if a JSON-RPC error indicates payment is required.
|
|
18
|
+
*/
|
|
19
|
+
function isPaymentRequiredError(error) {
|
|
20
|
+
return error.code === constants_js_1.JSONRPC_PAYMENT_REQUIRED;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Check if a JSON-RPC error indicates verification failed.
|
|
24
|
+
*/
|
|
25
|
+
function isVerificationFailedError(error) {
|
|
26
|
+
return error.code === constants_js_1.JSONRPC_VERIFICATION_FAILED;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Extract paymentauth challenge from a JSON-RPC -32042 error.
|
|
30
|
+
*
|
|
31
|
+
* The error data may contain a challenge string (WWW-Authenticate value)
|
|
32
|
+
* or structured challenge parameters.
|
|
33
|
+
*/
|
|
34
|
+
function parsePaymentauthFromJsonRpcError(error) {
|
|
35
|
+
if (error.code !== constants_js_1.JSONRPC_PAYMENT_REQUIRED)
|
|
36
|
+
return null;
|
|
37
|
+
if (!error.data)
|
|
38
|
+
return null;
|
|
39
|
+
// If data is a string, try to parse as WWW-Authenticate value
|
|
40
|
+
if (typeof error.data === 'string') {
|
|
41
|
+
const challenges = (0, parse_js_1.parsePaymentauthChallenges)(error.data);
|
|
42
|
+
return challenges.length > 0 ? challenges[0] : null;
|
|
43
|
+
}
|
|
44
|
+
// If data is an object with a challenge field, extract params
|
|
45
|
+
if (typeof error.data === 'object' && !Array.isArray(error.data)) {
|
|
46
|
+
const data = error.data;
|
|
47
|
+
if (typeof data.challenge === 'string') {
|
|
48
|
+
const challenges = (0, parse_js_1.parsePaymentauthChallenges)(data.challenge);
|
|
49
|
+
return challenges.length > 0 ? challenges[0] : null;
|
|
50
|
+
}
|
|
51
|
+
// Structured challenge params
|
|
52
|
+
if (typeof data.id === 'string' && typeof data.method === 'string') {
|
|
53
|
+
const params = {};
|
|
54
|
+
for (const [key, value] of Object.entries(data)) {
|
|
55
|
+
if (typeof value === 'string')
|
|
56
|
+
params[key] = value;
|
|
57
|
+
}
|
|
58
|
+
const serialized = JSON.stringify(error.data);
|
|
59
|
+
return { rawHeader: serialized, rawSegment: serialized, params };
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Extract paymentauth receipt from a JSON-RPC result.
|
|
66
|
+
*
|
|
67
|
+
* The result may contain a receipt field (Payment-Receipt value).
|
|
68
|
+
*/
|
|
69
|
+
function parsePaymentauthFromJsonRpcResult(result) {
|
|
70
|
+
if (!result || typeof result !== 'object' || Array.isArray(result))
|
|
71
|
+
return null;
|
|
72
|
+
const obj = result;
|
|
73
|
+
const receiptValue = obj.receipt;
|
|
74
|
+
if (typeof receiptValue !== 'string')
|
|
75
|
+
return null;
|
|
76
|
+
try {
|
|
77
|
+
return (0, parse_js_1.parsePaymentauthReceipt)(receiptValue);
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=jsonrpc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonrpc.js","sourceRoot":"","sources":["../src/jsonrpc.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AASH,wDAEC;AAKD,8DAEC;AAQD,4EAgCC;AAOD,8EAYC;AA3ED,iDAAuF;AAEvF,yCAAiF;AAEjF;;GAEG;AACH,SAAgB,sBAAsB,CAAC,KAAuB;IAC5D,OAAO,KAAK,CAAC,IAAI,KAAK,uCAAwB,CAAC;AACjD,CAAC;AAED;;GAEG;AACH,SAAgB,yBAAyB,CAAC,KAAuB;IAC/D,OAAO,KAAK,CAAC,IAAI,KAAK,0CAA2B,CAAC;AACpD,CAAC;AAED;;;;;GAKG;AACH,SAAgB,gCAAgC,CAAC,KAGhD;IACC,IAAI,KAAK,CAAC,IAAI,KAAK,uCAAwB;QAAE,OAAO,IAAI,CAAC;IACzD,IAAI,CAAC,KAAK,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IAE7B,8DAA8D;IAC9D,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QACnC,MAAM,UAAU,GAAG,IAAA,qCAA0B,EAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC1D,OAAO,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACtD,CAAC;IAED,8DAA8D;IAC9D,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACjE,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,IAAA,kCAAuB,EAAC,YAAY,CAAC,CAAC;IAC/C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
package/dist/map.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Paymentauth evidence mapping.
|
|
3
|
+
*
|
|
4
|
+
* Maps normalized paymentauth artifacts to PEAC PaymentEvidence and
|
|
5
|
+
* commerce extension fields. Only populates fields backed by actual
|
|
6
|
+
* upstream data; never synthesizes missing information.
|
|
7
|
+
*
|
|
8
|
+
* receipt_ref is computed from the raw upstream artifact (the literal
|
|
9
|
+
* header value received), NOT assumed to be a JWS envelope.
|
|
10
|
+
*/
|
|
11
|
+
import type { PaymentEvidence } from '@peac/schema';
|
|
12
|
+
import type { NormalizedPaymentauthReceipt, NormalizedPaymentauthChallenge } from './types.js';
|
|
13
|
+
/**
|
|
14
|
+
* Map a paymentauth receipt (with optional challenge context) to PEAC PaymentEvidence.
|
|
15
|
+
*
|
|
16
|
+
* Only populates fields that the source artifacts actually provide.
|
|
17
|
+
* Amount and currency are extracted from the decoded challenge request
|
|
18
|
+
* if available and object-shaped; otherwise omitted.
|
|
19
|
+
*
|
|
20
|
+
* @param receipt - Normalized paymentauth receipt
|
|
21
|
+
* @param challenge - Optional normalized challenge that preceded this receipt
|
|
22
|
+
* @returns PaymentEvidence with fields backed by upstream data
|
|
23
|
+
*/
|
|
24
|
+
export declare function fromPaymentauthReceipt(receipt: NormalizedPaymentauthReceipt, challenge?: NormalizedPaymentauthChallenge): PaymentEvidence;
|
|
25
|
+
/**
|
|
26
|
+
* Extract partial commerce extension fields from paymentauth artifacts.
|
|
27
|
+
*
|
|
28
|
+
* Only returns fields that the source data actually provides.
|
|
29
|
+
* Returns undefined if no commerce-relevant data is available.
|
|
30
|
+
*/
|
|
31
|
+
export declare function toCommerceExtensionFields(receipt: NormalizedPaymentauthReceipt, challenge?: NormalizedPaymentauthChallenge): Partial<{
|
|
32
|
+
payment_rail: string;
|
|
33
|
+
amount_minor: string;
|
|
34
|
+
currency: string;
|
|
35
|
+
reference: string;
|
|
36
|
+
env: 'live' | 'test';
|
|
37
|
+
}> | undefined;
|
|
38
|
+
//# sourceMappingURL=map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../src/map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAGpD,OAAO,KAAK,EAAE,4BAA4B,EAAE,8BAA8B,EAAE,MAAM,YAAY,CAAC;AAE/F;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,4BAA4B,EACrC,SAAS,CAAC,EAAE,8BAA8B,GACzC,eAAe,CA2CjB;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,4BAA4B,EACrC,SAAS,CAAC,EAAE,8BAA8B,GAExC,OAAO,CAAC;IACN,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACtB,CAAC,GACF,SAAS,CAsBZ"}
|
package/dist/map.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Paymentauth evidence mapping.
|
|
4
|
+
*
|
|
5
|
+
* Maps normalized paymentauth artifacts to PEAC PaymentEvidence and
|
|
6
|
+
* commerce extension fields. Only populates fields backed by actual
|
|
7
|
+
* upstream data; never synthesizes missing information.
|
|
8
|
+
*
|
|
9
|
+
* receipt_ref is computed from the raw upstream artifact (the literal
|
|
10
|
+
* header value received), NOT assumed to be a JWS envelope.
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.fromPaymentauthReceipt = fromPaymentauthReceipt;
|
|
14
|
+
exports.toCommerceExtensionFields = toCommerceExtensionFields;
|
|
15
|
+
const constants_js_1 = require("./constants.js");
|
|
16
|
+
/**
|
|
17
|
+
* Map a paymentauth receipt (with optional challenge context) to PEAC PaymentEvidence.
|
|
18
|
+
*
|
|
19
|
+
* Only populates fields that the source artifacts actually provide.
|
|
20
|
+
* Amount and currency are extracted from the decoded challenge request
|
|
21
|
+
* if available and object-shaped; otherwise omitted.
|
|
22
|
+
*
|
|
23
|
+
* @param receipt - Normalized paymentauth receipt
|
|
24
|
+
* @param challenge - Optional normalized challenge that preceded this receipt
|
|
25
|
+
* @returns PaymentEvidence with fields backed by upstream data
|
|
26
|
+
*/
|
|
27
|
+
function fromPaymentauthReceipt(receipt, challenge) {
|
|
28
|
+
// Extract amount/currency from challenge request if available
|
|
29
|
+
let amount;
|
|
30
|
+
let currency;
|
|
31
|
+
let asset;
|
|
32
|
+
if (challenge?.decodedRequest && typeof challenge.decodedRequest === 'object') {
|
|
33
|
+
const req = challenge.decodedRequest;
|
|
34
|
+
if (typeof req.amount === 'string' && /^[0-9]+$/.test(req.amount)) {
|
|
35
|
+
amount = parseInt(req.amount, 10);
|
|
36
|
+
}
|
|
37
|
+
else if (typeof req.amount === 'number' && Number.isFinite(req.amount)) {
|
|
38
|
+
amount = req.amount;
|
|
39
|
+
}
|
|
40
|
+
if (typeof req.currency === 'string' && req.currency.length > 0) {
|
|
41
|
+
currency = req.currency.toUpperCase();
|
|
42
|
+
asset = currency;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
// Build evidence metadata from available upstream data
|
|
46
|
+
const evidenceMeta = {
|
|
47
|
+
paymentauth_method: receipt.method,
|
|
48
|
+
paymentauth_status: receipt.status,
|
|
49
|
+
};
|
|
50
|
+
if (receipt.timestamp)
|
|
51
|
+
evidenceMeta.timestamp = receipt.timestamp;
|
|
52
|
+
if (challenge) {
|
|
53
|
+
evidenceMeta.challenge_id = challenge.id;
|
|
54
|
+
evidenceMeta.challenge_intent = challenge.intent;
|
|
55
|
+
evidenceMeta.challenge_realm = challenge.realm;
|
|
56
|
+
}
|
|
57
|
+
if (Object.keys(receipt.extras).length > 0) {
|
|
58
|
+
evidenceMeta.receipt_extras = receipt.extras;
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
rail: constants_js_1.PAYMENTAUTH_RAIL,
|
|
62
|
+
reference: receipt.reference ?? receipt._raw.rawValue.substring(0, 32),
|
|
63
|
+
amount: amount ?? 0,
|
|
64
|
+
currency: currency ?? 'UNKNOWN',
|
|
65
|
+
asset: asset ?? currency ?? 'UNKNOWN',
|
|
66
|
+
env: 'live',
|
|
67
|
+
evidence: evidenceMeta,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Extract partial commerce extension fields from paymentauth artifacts.
|
|
72
|
+
*
|
|
73
|
+
* Only returns fields that the source data actually provides.
|
|
74
|
+
* Returns undefined if no commerce-relevant data is available.
|
|
75
|
+
*/
|
|
76
|
+
function toCommerceExtensionFields(receipt, challenge) {
|
|
77
|
+
const fields = {};
|
|
78
|
+
fields.payment_rail = constants_js_1.PAYMENTAUTH_RAIL;
|
|
79
|
+
if (challenge?.decodedRequest && typeof challenge.decodedRequest === 'object') {
|
|
80
|
+
const req = challenge.decodedRequest;
|
|
81
|
+
if (typeof req.amount === 'string' && /^-?[0-9]+$/.test(req.amount)) {
|
|
82
|
+
fields.amount_minor = req.amount;
|
|
83
|
+
}
|
|
84
|
+
if (typeof req.currency === 'string' && req.currency.length > 0) {
|
|
85
|
+
fields.currency = req.currency.toUpperCase();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (receipt.reference) {
|
|
89
|
+
fields.reference = receipt.reference;
|
|
90
|
+
}
|
|
91
|
+
// Only return if we have at least rail + one other field
|
|
92
|
+
if (Object.keys(fields).length <= 1)
|
|
93
|
+
return undefined;
|
|
94
|
+
return { ...fields, env: 'live' };
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=map.js.map
|
package/dist/map.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map.js","sourceRoot":"","sources":["../src/map.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;AAmBH,wDA8CC;AAQD,8DAiCC;AArGD,iDAAkD;AAGlD;;;;;;;;;;GAUG;AACH,SAAgB,sBAAsB,CACpC,OAAqC,EACrC,SAA0C;IAE1C,8DAA8D;IAC9D,IAAI,MAA0B,CAAC;IAC/B,IAAI,QAA4B,CAAC;IACjC,IAAI,KAAyB,CAAC;IAE9B,IAAI,SAAS,EAAE,cAAc,IAAI,OAAO,SAAS,CAAC,cAAc,KAAK,QAAQ,EAAE,CAAC;QAC9E,MAAM,GAAG,GAAG,SAAS,CAAC,cAAyC,CAAC;QAChE,IAAI,OAAO,GAAG,CAAC,MAAM,KAAK,QAAQ,IAAI,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;YAClE,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QACpC,CAAC;aAAM,IAAI,OAAO,GAAG,CAAC,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;YACzE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC;QACtB,CAAC;QACD,IAAI,OAAO,GAAG,CAAC,QAAQ,KAAK,QAAQ,IAAI,GAAG,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAChE,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;YACtC,KAAK,GAAG,QAAQ,CAAC;QACnB,CAAC;IACH,CAAC;IAED,uDAAuD;IACvD,MAAM,YAAY,GAAe;QAC/B,kBAAkB,EAAE,OAAO,CAAC,MAAM;QAClC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AC,EAAE,CAAC;YACpE,MAAM,CAAC,YAAY,GAAG,GAAG,CAAC,MAAM,CAAC;QACnC,CAAC;QACD,IAAI,OAAO,GAAG,CAAC,QAAQ,KAAK,QAAQ,IAAI,GAAG,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAChE,MAAM,CAAC,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;QAC/C,CAAC;IACH,CAAC;IAED,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;QACtB,MAAM,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;IACvC,CAAC;IAED,yDAAyD;IACzD,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,IAAI,CAAC;QAAE,OAAO,SAAS,CAAC;IAEtD,OAAO,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE,MAAM,EAAkD,CAAC;AACpF,CAAC"}
|
package/dist/mcp.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Paymentauth MCP-specific helpers.
|
|
3
|
+
*
|
|
4
|
+
* Extraction of paymentauth artifacts from MCP _meta keys
|
|
5
|
+
* and capability advertisement typing per draft-payment-transport-mcp-00.
|
|
6
|
+
*
|
|
7
|
+
* Separated from generic JSON-RPC helpers in jsonrpc.ts.
|
|
8
|
+
*
|
|
9
|
+
* Co-existence: paymentauth uses "org.paymentauth/*" keys in _meta,
|
|
10
|
+
* which do not collide with PEAC's "org.peacprotocol/*" keys.
|
|
11
|
+
* Both can appear on the same MCP response.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Extract paymentauth credential from MCP tool response _meta.
|
|
15
|
+
*
|
|
16
|
+
* Looks for the org.paymentauth/credential key.
|
|
17
|
+
*/
|
|
18
|
+
export declare function extractCredentialFromMcpMeta(meta: Record<string, unknown>): string | null;
|
|
19
|
+
/**
|
|
20
|
+
* Extract paymentauth receipt from MCP tool response _meta.
|
|
21
|
+
*
|
|
22
|
+
* Looks for the org.paymentauth/receipt key.
|
|
23
|
+
*/
|
|
24
|
+
export declare function extractReceiptFromMcpMeta(meta: Record<string, unknown>): string | null;
|
|
25
|
+
/**
|
|
26
|
+
* MCP capability for paymentauth (experimental.payment).
|
|
27
|
+
*
|
|
28
|
+
* Advertised in MCP InitializeResult.capabilities.experimental.
|
|
29
|
+
*/
|
|
30
|
+
export interface PaymentauthMcpCapability {
|
|
31
|
+
/** Whether the server supports paymentauth challenges */
|
|
32
|
+
supported: boolean;
|
|
33
|
+
/** Accepted payment methods */
|
|
34
|
+
methods?: string[];
|
|
35
|
+
/** Accepted payment intents */
|
|
36
|
+
intents?: string[];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Extract paymentauth capability from MCP InitializeResult.
|
|
40
|
+
*
|
|
41
|
+
* Looks for capabilities.experimental.payment.
|
|
42
|
+
*/
|
|
43
|
+
export declare function extractPaymentauthCapability(capabilities: Record<string, unknown>): PaymentauthMcpCapability | null;
|
|
44
|
+
//# sourceMappingURL=mcp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../src/mcp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH;;;;GAIG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,GAAG,IAAI,CAGzF;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,GAAG,IAAI,CAGtF;AAED;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC,yDAAyD;IACzD,SAAS,EAAE,OAAO,CAAC;IACnB,+BAA+B;IAC/B,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,+BAA+B;IAC/B,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,CAC1C,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACpC,wBAAwB,GAAG,IAAI,CAqBjC"}
|
package/dist/mcp.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Paymentauth MCP-specific helpers.
|
|
4
|
+
*
|
|
5
|
+
* Extraction of paymentauth artifacts from MCP _meta keys
|
|
6
|
+
* and capability advertisement typing per draft-payment-transport-mcp-00.
|
|
7
|
+
*
|
|
8
|
+
* Separated from generic JSON-RPC helpers in jsonrpc.ts.
|
|
9
|
+
*
|
|
10
|
+
* Co-existence: paymentauth uses "org.paymentauth/*" keys in _meta,
|
|
11
|
+
* which do not collide with PEAC's "org.peacprotocol/*" keys.
|
|
12
|
+
* Both can appear on the same MCP response.
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.extractCredentialFromMcpMeta = extractCredentialFromMcpMeta;
|
|
16
|
+
exports.extractReceiptFromMcpMeta = extractReceiptFromMcpMeta;
|
|
17
|
+
exports.extractPaymentauthCapability = extractPaymentauthCapability;
|
|
18
|
+
const constants_js_1 = require("./constants.js");
|
|
19
|
+
/**
|
|
20
|
+
* Extract paymentauth credential from MCP tool response _meta.
|
|
21
|
+
*
|
|
22
|
+
* Looks for the org.paymentauth/credential key.
|
|
23
|
+
*/
|
|
24
|
+
function extractCredentialFromMcpMeta(meta) {
|
|
25
|
+
const value = meta[constants_js_1.MCP_META_CREDENTIAL];
|
|
26
|
+
return typeof value === 'string' && value.length > 0 ? value : null;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Extract paymentauth receipt from MCP tool response _meta.
|
|
30
|
+
*
|
|
31
|
+
* Looks for the org.paymentauth/receipt key.
|
|
32
|
+
*/
|
|
33
|
+
function extractReceiptFromMcpMeta(meta) {
|
|
34
|
+
const value = meta[constants_js_1.MCP_META_RECEIPT];
|
|
35
|
+
return typeof value === 'string' && value.length > 0 ? value : null;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Extract paymentauth capability from MCP InitializeResult.
|
|
39
|
+
*
|
|
40
|
+
* Looks for capabilities.experimental.payment.
|
|
41
|
+
*/
|
|
42
|
+
function extractPaymentauthCapability(capabilities) {
|
|
43
|
+
const experimental = capabilities.experimental;
|
|
44
|
+
if (!experimental || typeof experimental !== 'object' || Array.isArray(experimental)) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
const payment = experimental.payment;
|
|
48
|
+
if (!payment || typeof payment !== 'object' || Array.isArray(payment)) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
const cap = payment;
|
|
52
|
+
return {
|
|
53
|
+
supported: cap.supported === true,
|
|
54
|
+
methods: Array.isArray(cap.methods)
|
|
55
|
+
? cap.methods.filter((m) => typeof m === 'string')
|
|
56
|
+
: undefined,
|
|
57
|
+
intents: Array.isArray(cap.intents)
|
|
58
|
+
? cap.intents.filter((i) => typeof i === 'string')
|
|
59
|
+
: undefined,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=mcp.js.map
|
package/dist/mcp.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.js","sourceRoot":"","sources":["../src/mcp.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;AASH,oEAGC;AAOD,8DAGC;AAqBD,oEAuBC;AAhED,iDAAuE;AAEvE;;;;GAIG;AACH,SAAgB,4BAA4B,CAAC,IAA6B;IACxE,MAAM,KAAK,GAAG,IAAI,CAAC,kCAAmB,CAAC,CAAC;IACxC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AAC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