@agentcash/discovery 1.1.2 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +7 -15
- package/dist/cli.js +7 -15
- package/dist/index.cjs +14 -16
- package/dist/index.d.cts +12 -2
- package/dist/index.d.ts +12 -2
- package/dist/index.js +14 -16
- package/dist/schemas.cjs +0 -1
- package/dist/schemas.js +0 -1
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -13864,7 +13864,6 @@ var WellKnownDocSchema = external_exports.object({
|
|
|
13864
13864
|
version: external_exports.number().optional(),
|
|
13865
13865
|
resources: external_exports.array(external_exports.string()).default([]),
|
|
13866
13866
|
mppResources: external_exports.array(external_exports.string()).optional(),
|
|
13867
|
-
// isMmmEnabled
|
|
13868
13867
|
description: external_exports.string().optional(),
|
|
13869
13868
|
ownershipProofs: external_exports.array(external_exports.string()).optional(),
|
|
13870
13869
|
instructions: external_exports.string().optional()
|
|
@@ -13974,9 +13973,6 @@ function fetchSafe(url2, init) {
|
|
|
13974
13973
|
return import_neverthrow.ResultAsync.fromPromise(fetch(url2, init), toFetchError);
|
|
13975
13974
|
}
|
|
13976
13975
|
|
|
13977
|
-
// src/mmm-enabled.ts
|
|
13978
|
-
var isMmmEnabled = () => "1.1.2".includes("-mmm");
|
|
13979
|
-
|
|
13980
13976
|
// src/core/source/openapi/index.ts
|
|
13981
13977
|
var OpenApiParsedSchema = OpenApiDocSchema.transform((doc) => {
|
|
13982
13978
|
const routes = [];
|
|
@@ -13986,9 +13982,7 @@ var OpenApiParsedSchema = OpenApiDocSchema.transform((doc) => {
|
|
|
13986
13982
|
if (!operation) continue;
|
|
13987
13983
|
const authMode = inferAuthMode(operation, doc.security, doc.components?.securitySchemes) ?? void 0;
|
|
13988
13984
|
const p = operation["x-payment-info"];
|
|
13989
|
-
const protocols = (p?.protocols ?? []).filter(
|
|
13990
|
-
(proto) => proto !== "mpp" || isMmmEnabled()
|
|
13991
|
-
);
|
|
13985
|
+
const protocols = (p?.protocols ?? []).filter((proto) => proto.length > 0);
|
|
13992
13986
|
const pricing = (authMode === "paid" || authMode === "apiKey+paid") && p ? {
|
|
13993
13987
|
pricingMode: p.pricingMode,
|
|
13994
13988
|
...p.price ? { price: p.price } : {},
|
|
@@ -14102,6 +14096,7 @@ function checkL2ForOpenAPI(openApi) {
|
|
|
14102
14096
|
return {
|
|
14103
14097
|
...openApi.info.title ? { title: openApi.info.title } : {},
|
|
14104
14098
|
...openApi.info.description ? { description: openApi.info.description } : {},
|
|
14099
|
+
...openApi.info.version ? { version: openApi.info.version } : {},
|
|
14105
14100
|
routes,
|
|
14106
14101
|
source: "openapi"
|
|
14107
14102
|
};
|
|
@@ -14974,7 +14969,7 @@ function detectProtocols(response) {
|
|
|
14974
14969
|
}
|
|
14975
14970
|
const authHeader = response.headers.get("www-authenticate")?.toLowerCase() ?? "";
|
|
14976
14971
|
if (authHeader.includes("x402")) protocols.add("x402");
|
|
14977
|
-
if (
|
|
14972
|
+
if (authHeader.includes("mpp")) protocols.add("mpp");
|
|
14978
14973
|
return [...protocols];
|
|
14979
14974
|
}
|
|
14980
14975
|
function buildProbeUrl(url2, method, inputBody) {
|
|
@@ -15054,7 +15049,7 @@ function parseAuthParams(segment) {
|
|
|
15054
15049
|
return params;
|
|
15055
15050
|
}
|
|
15056
15051
|
function extractPaymentOptions4(wwwAuthenticate) {
|
|
15057
|
-
if (!
|
|
15052
|
+
if (!wwwAuthenticate) return [];
|
|
15058
15053
|
const options = [];
|
|
15059
15054
|
for (const segment of wwwAuthenticate.split(/,\s*(?=Payment\s)/i)) {
|
|
15060
15055
|
const stripped = segment.replace(/^Payment\s+/i, "").trim();
|
|
@@ -15083,12 +15078,10 @@ function extractPaymentOptions4(wwwAuthenticate) {
|
|
|
15083
15078
|
if (!asset || !amount) continue;
|
|
15084
15079
|
options.push({
|
|
15085
15080
|
protocol: "mpp",
|
|
15086
|
-
// isMmmEnabled
|
|
15087
15081
|
paymentMethod,
|
|
15088
15082
|
intent,
|
|
15089
15083
|
realm,
|
|
15090
15084
|
network: `tempo:${String(chainId)}`,
|
|
15091
|
-
// isMmmEnabled
|
|
15092
15085
|
asset,
|
|
15093
15086
|
amount,
|
|
15094
15087
|
...decimals != null ? { decimals } : {},
|
|
@@ -15216,7 +15209,7 @@ function parseOperationProtocols(operation) {
|
|
|
15216
15209
|
const paymentInfo = operation["x-payment-info"];
|
|
15217
15210
|
if (!isRecord(paymentInfo) || !Array.isArray(paymentInfo.protocols)) return void 0;
|
|
15218
15211
|
const protocols = paymentInfo.protocols.filter(
|
|
15219
|
-
(protocol) => typeof protocol === "string" && protocol.length > 0
|
|
15212
|
+
(protocol) => typeof protocol === "string" && protocol.length > 0
|
|
15220
15213
|
);
|
|
15221
15214
|
return protocols.length > 0 ? protocols : void 0;
|
|
15222
15215
|
}
|
|
@@ -15247,8 +15240,7 @@ function getL3ForProbe(probe, path, method) {
|
|
|
15247
15240
|
const outputSchema = probeResult.paymentRequiredBody ? parseOutputSchema(probeResult.paymentRequiredBody) : void 0;
|
|
15248
15241
|
const paymentOptions = [
|
|
15249
15242
|
...probeResult.paymentRequiredBody ? extractPaymentOptions3(probeResult.paymentRequiredBody) : [],
|
|
15250
|
-
...
|
|
15251
|
-
// isMmmEnabled
|
|
15243
|
+
...extractPaymentOptions4(probeResult.wwwAuthenticate)
|
|
15252
15244
|
];
|
|
15253
15245
|
return {
|
|
15254
15246
|
source: "probe",
|
|
@@ -15288,7 +15280,7 @@ async function checkEndpointSchema(options) {
|
|
|
15288
15280
|
const endpoint = new URL(ensureProtocol(options.url));
|
|
15289
15281
|
const origin = normalizeOrigin(endpoint.origin);
|
|
15290
15282
|
const path = normalizePath(endpoint.pathname || "/");
|
|
15291
|
-
if (options.sampleInputBody !== void 0) {
|
|
15283
|
+
if (options.probe || options.sampleInputBody !== void 0) {
|
|
15292
15284
|
const probeResult2 = await getProbe(
|
|
15293
15285
|
endpoint.href,
|
|
15294
15286
|
options.headers,
|
package/dist/cli.js
CHANGED
|
@@ -13834,7 +13834,6 @@ var WellKnownDocSchema = external_exports.object({
|
|
|
13834
13834
|
version: external_exports.number().optional(),
|
|
13835
13835
|
resources: external_exports.array(external_exports.string()).default([]),
|
|
13836
13836
|
mppResources: external_exports.array(external_exports.string()).optional(),
|
|
13837
|
-
// isMmmEnabled
|
|
13838
13837
|
description: external_exports.string().optional(),
|
|
13839
13838
|
ownershipProofs: external_exports.array(external_exports.string()).optional(),
|
|
13840
13839
|
instructions: external_exports.string().optional()
|
|
@@ -13944,9 +13943,6 @@ function fetchSafe(url2, init) {
|
|
|
13944
13943
|
return ResultAsync.fromPromise(fetch(url2, init), toFetchError);
|
|
13945
13944
|
}
|
|
13946
13945
|
|
|
13947
|
-
// src/mmm-enabled.ts
|
|
13948
|
-
var isMmmEnabled = () => "1.1.2".includes("-mmm");
|
|
13949
|
-
|
|
13950
13946
|
// src/core/source/openapi/index.ts
|
|
13951
13947
|
var OpenApiParsedSchema = OpenApiDocSchema.transform((doc) => {
|
|
13952
13948
|
const routes = [];
|
|
@@ -13956,9 +13952,7 @@ var OpenApiParsedSchema = OpenApiDocSchema.transform((doc) => {
|
|
|
13956
13952
|
if (!operation) continue;
|
|
13957
13953
|
const authMode = inferAuthMode(operation, doc.security, doc.components?.securitySchemes) ?? void 0;
|
|
13958
13954
|
const p = operation["x-payment-info"];
|
|
13959
|
-
const protocols = (p?.protocols ?? []).filter(
|
|
13960
|
-
(proto) => proto !== "mpp" || isMmmEnabled()
|
|
13961
|
-
);
|
|
13955
|
+
const protocols = (p?.protocols ?? []).filter((proto) => proto.length > 0);
|
|
13962
13956
|
const pricing = (authMode === "paid" || authMode === "apiKey+paid") && p ? {
|
|
13963
13957
|
pricingMode: p.pricingMode,
|
|
13964
13958
|
...p.price ? { price: p.price } : {},
|
|
@@ -14072,6 +14066,7 @@ function checkL2ForOpenAPI(openApi) {
|
|
|
14072
14066
|
return {
|
|
14073
14067
|
...openApi.info.title ? { title: openApi.info.title } : {},
|
|
14074
14068
|
...openApi.info.description ? { description: openApi.info.description } : {},
|
|
14069
|
+
...openApi.info.version ? { version: openApi.info.version } : {},
|
|
14075
14070
|
routes,
|
|
14076
14071
|
source: "openapi"
|
|
14077
14072
|
};
|
|
@@ -14944,7 +14939,7 @@ function detectProtocols(response) {
|
|
|
14944
14939
|
}
|
|
14945
14940
|
const authHeader = response.headers.get("www-authenticate")?.toLowerCase() ?? "";
|
|
14946
14941
|
if (authHeader.includes("x402")) protocols.add("x402");
|
|
14947
|
-
if (
|
|
14942
|
+
if (authHeader.includes("mpp")) protocols.add("mpp");
|
|
14948
14943
|
return [...protocols];
|
|
14949
14944
|
}
|
|
14950
14945
|
function buildProbeUrl(url2, method, inputBody) {
|
|
@@ -15024,7 +15019,7 @@ function parseAuthParams(segment) {
|
|
|
15024
15019
|
return params;
|
|
15025
15020
|
}
|
|
15026
15021
|
function extractPaymentOptions4(wwwAuthenticate) {
|
|
15027
|
-
if (!
|
|
15022
|
+
if (!wwwAuthenticate) return [];
|
|
15028
15023
|
const options = [];
|
|
15029
15024
|
for (const segment of wwwAuthenticate.split(/,\s*(?=Payment\s)/i)) {
|
|
15030
15025
|
const stripped = segment.replace(/^Payment\s+/i, "").trim();
|
|
@@ -15053,12 +15048,10 @@ function extractPaymentOptions4(wwwAuthenticate) {
|
|
|
15053
15048
|
if (!asset || !amount) continue;
|
|
15054
15049
|
options.push({
|
|
15055
15050
|
protocol: "mpp",
|
|
15056
|
-
// isMmmEnabled
|
|
15057
15051
|
paymentMethod,
|
|
15058
15052
|
intent,
|
|
15059
15053
|
realm,
|
|
15060
15054
|
network: `tempo:${String(chainId)}`,
|
|
15061
|
-
// isMmmEnabled
|
|
15062
15055
|
asset,
|
|
15063
15056
|
amount,
|
|
15064
15057
|
...decimals != null ? { decimals } : {},
|
|
@@ -15186,7 +15179,7 @@ function parseOperationProtocols(operation) {
|
|
|
15186
15179
|
const paymentInfo = operation["x-payment-info"];
|
|
15187
15180
|
if (!isRecord(paymentInfo) || !Array.isArray(paymentInfo.protocols)) return void 0;
|
|
15188
15181
|
const protocols = paymentInfo.protocols.filter(
|
|
15189
|
-
(protocol) => typeof protocol === "string" && protocol.length > 0
|
|
15182
|
+
(protocol) => typeof protocol === "string" && protocol.length > 0
|
|
15190
15183
|
);
|
|
15191
15184
|
return protocols.length > 0 ? protocols : void 0;
|
|
15192
15185
|
}
|
|
@@ -15217,8 +15210,7 @@ function getL3ForProbe(probe, path, method) {
|
|
|
15217
15210
|
const outputSchema = probeResult.paymentRequiredBody ? parseOutputSchema(probeResult.paymentRequiredBody) : void 0;
|
|
15218
15211
|
const paymentOptions = [
|
|
15219
15212
|
...probeResult.paymentRequiredBody ? extractPaymentOptions3(probeResult.paymentRequiredBody) : [],
|
|
15220
|
-
...
|
|
15221
|
-
// isMmmEnabled
|
|
15213
|
+
...extractPaymentOptions4(probeResult.wwwAuthenticate)
|
|
15222
15214
|
];
|
|
15223
15215
|
return {
|
|
15224
15216
|
source: "probe",
|
|
@@ -15258,7 +15250,7 @@ async function checkEndpointSchema(options) {
|
|
|
15258
15250
|
const endpoint = new URL(ensureProtocol(options.url));
|
|
15259
15251
|
const origin = normalizeOrigin(endpoint.origin);
|
|
15260
15252
|
const path = normalizePath(endpoint.pathname || "/");
|
|
15261
|
-
if (options.sampleInputBody !== void 0) {
|
|
15253
|
+
if (options.probe || options.sampleInputBody !== void 0) {
|
|
15262
15254
|
const probeResult2 = await getProbe(
|
|
15263
15255
|
endpoint.href,
|
|
15264
15256
|
options.headers,
|
package/dist/index.cjs
CHANGED
|
@@ -13887,7 +13887,6 @@ var WellKnownDocSchema = external_exports.object({
|
|
|
13887
13887
|
version: external_exports.number().optional(),
|
|
13888
13888
|
resources: external_exports.array(external_exports.string()).default([]),
|
|
13889
13889
|
mppResources: external_exports.array(external_exports.string()).optional(),
|
|
13890
|
-
// isMmmEnabled
|
|
13891
13890
|
description: external_exports.string().optional(),
|
|
13892
13891
|
ownershipProofs: external_exports.array(external_exports.string()).optional(),
|
|
13893
13892
|
instructions: external_exports.string().optional()
|
|
@@ -13997,9 +13996,6 @@ function fetchSafe(url2, init) {
|
|
|
13997
13996
|
return import_neverthrow.ResultAsync.fromPromise(fetch(url2, init), toFetchError);
|
|
13998
13997
|
}
|
|
13999
13998
|
|
|
14000
|
-
// src/mmm-enabled.ts
|
|
14001
|
-
var isMmmEnabled = () => "1.1.2".includes("-mmm");
|
|
14002
|
-
|
|
14003
13999
|
// src/core/source/openapi/index.ts
|
|
14004
14000
|
var OpenApiParsedSchema = OpenApiDocSchema.transform((doc) => {
|
|
14005
14001
|
const routes = [];
|
|
@@ -14009,9 +14005,7 @@ var OpenApiParsedSchema = OpenApiDocSchema.transform((doc) => {
|
|
|
14009
14005
|
if (!operation) continue;
|
|
14010
14006
|
const authMode = inferAuthMode(operation, doc.security, doc.components?.securitySchemes) ?? void 0;
|
|
14011
14007
|
const p = operation["x-payment-info"];
|
|
14012
|
-
const protocols = (p?.protocols ?? []).filter(
|
|
14013
|
-
(proto) => proto !== "mpp" || isMmmEnabled()
|
|
14014
|
-
);
|
|
14008
|
+
const protocols = (p?.protocols ?? []).filter((proto) => proto.length > 0);
|
|
14015
14009
|
const pricing = (authMode === "paid" || authMode === "apiKey+paid") && p ? {
|
|
14016
14010
|
pricingMode: p.pricingMode,
|
|
14017
14011
|
...p.price ? { price: p.price } : {},
|
|
@@ -14125,6 +14119,7 @@ function checkL2ForOpenAPI(openApi) {
|
|
|
14125
14119
|
return {
|
|
14126
14120
|
...openApi.info.title ? { title: openApi.info.title } : {},
|
|
14127
14121
|
...openApi.info.description ? { description: openApi.info.description } : {},
|
|
14122
|
+
...openApi.info.version ? { version: openApi.info.version } : {},
|
|
14128
14123
|
routes,
|
|
14129
14124
|
source: "openapi"
|
|
14130
14125
|
};
|
|
@@ -14195,7 +14190,13 @@ async function discoverOriginSchema(options) {
|
|
|
14195
14190
|
found: true,
|
|
14196
14191
|
origin,
|
|
14197
14192
|
source: "openapi",
|
|
14198
|
-
...l22.title ? {
|
|
14193
|
+
...l22.title ? {
|
|
14194
|
+
info: {
|
|
14195
|
+
title: l22.title,
|
|
14196
|
+
...l22.description ? { description: l22.description } : {},
|
|
14197
|
+
...l22.version ? { version: l22.version } : {}
|
|
14198
|
+
}
|
|
14199
|
+
} : {},
|
|
14199
14200
|
endpoints: l22.routes
|
|
14200
14201
|
};
|
|
14201
14202
|
return withGuidance(base2, l42, guidanceMode);
|
|
@@ -14649,7 +14650,7 @@ function detectProtocols(response) {
|
|
|
14649
14650
|
}
|
|
14650
14651
|
const authHeader = response.headers.get("www-authenticate")?.toLowerCase() ?? "";
|
|
14651
14652
|
if (authHeader.includes("x402")) protocols.add("x402");
|
|
14652
|
-
if (
|
|
14653
|
+
if (authHeader.includes("mpp")) protocols.add("mpp");
|
|
14653
14654
|
return [...protocols];
|
|
14654
14655
|
}
|
|
14655
14656
|
function buildProbeUrl(url2, method, inputBody) {
|
|
@@ -14729,7 +14730,7 @@ function parseAuthParams(segment) {
|
|
|
14729
14730
|
return params;
|
|
14730
14731
|
}
|
|
14731
14732
|
function extractPaymentOptions4(wwwAuthenticate) {
|
|
14732
|
-
if (!
|
|
14733
|
+
if (!wwwAuthenticate) return [];
|
|
14733
14734
|
const options = [];
|
|
14734
14735
|
for (const segment of wwwAuthenticate.split(/,\s*(?=Payment\s)/i)) {
|
|
14735
14736
|
const stripped = segment.replace(/^Payment\s+/i, "").trim();
|
|
@@ -14758,12 +14759,10 @@ function extractPaymentOptions4(wwwAuthenticate) {
|
|
|
14758
14759
|
if (!asset || !amount) continue;
|
|
14759
14760
|
options.push({
|
|
14760
14761
|
protocol: "mpp",
|
|
14761
|
-
// isMmmEnabled
|
|
14762
14762
|
paymentMethod,
|
|
14763
14763
|
intent,
|
|
14764
14764
|
realm,
|
|
14765
14765
|
network: `tempo:${String(chainId)}`,
|
|
14766
|
-
// isMmmEnabled
|
|
14767
14766
|
asset,
|
|
14768
14767
|
amount,
|
|
14769
14768
|
...decimals != null ? { decimals } : {},
|
|
@@ -14891,7 +14890,7 @@ function parseOperationProtocols(operation) {
|
|
|
14891
14890
|
const paymentInfo = operation["x-payment-info"];
|
|
14892
14891
|
if (!isRecord(paymentInfo) || !Array.isArray(paymentInfo.protocols)) return void 0;
|
|
14893
14892
|
const protocols = paymentInfo.protocols.filter(
|
|
14894
|
-
(protocol) => typeof protocol === "string" && protocol.length > 0
|
|
14893
|
+
(protocol) => typeof protocol === "string" && protocol.length > 0
|
|
14895
14894
|
);
|
|
14896
14895
|
return protocols.length > 0 ? protocols : void 0;
|
|
14897
14896
|
}
|
|
@@ -14922,8 +14921,7 @@ function getL3ForProbe(probe, path, method) {
|
|
|
14922
14921
|
const outputSchema = probeResult.paymentRequiredBody ? parseOutputSchema(probeResult.paymentRequiredBody) : void 0;
|
|
14923
14922
|
const paymentOptions = [
|
|
14924
14923
|
...probeResult.paymentRequiredBody ? extractPaymentOptions3(probeResult.paymentRequiredBody) : [],
|
|
14925
|
-
...
|
|
14926
|
-
// isMmmEnabled
|
|
14924
|
+
...extractPaymentOptions4(probeResult.wwwAuthenticate)
|
|
14927
14925
|
];
|
|
14928
14926
|
return {
|
|
14929
14927
|
source: "probe",
|
|
@@ -14967,7 +14965,7 @@ async function checkEndpointSchema(options) {
|
|
|
14967
14965
|
const endpoint = new URL(ensureProtocol(options.url));
|
|
14968
14966
|
const origin = normalizeOrigin(endpoint.origin);
|
|
14969
14967
|
const path = normalizePath(endpoint.pathname || "/");
|
|
14970
|
-
if (options.sampleInputBody !== void 0) {
|
|
14968
|
+
if (options.probe || options.sampleInputBody !== void 0) {
|
|
14971
14969
|
const probeResult2 = await getProbe(
|
|
14972
14970
|
endpoint.href,
|
|
14973
14971
|
options.headers,
|
package/dist/index.d.cts
CHANGED
|
@@ -8,12 +8,14 @@ type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTION
|
|
|
8
8
|
|
|
9
9
|
interface MppPaymentOption {
|
|
10
10
|
protocol: 'mpp';
|
|
11
|
-
/** Payment method identifier, e.g. "tempo" (Tempo protocol). */
|
|
11
|
+
/** Payment method identifier, e.g. "tempo" (Tempo protocol). */
|
|
12
|
+
paymentMethod: string;
|
|
12
13
|
/** Payment intent type, e.g. "charge". */
|
|
13
14
|
intent: string;
|
|
14
15
|
/** Server protection realm. */
|
|
15
16
|
realm: string;
|
|
16
|
-
/** CAIP-2 style network identifier, e.g. "tempo:4217". */
|
|
17
|
+
/** CAIP-2 style network identifier, e.g. "tempo:4217". */
|
|
18
|
+
network: string;
|
|
17
19
|
/** Currency / token contract. */
|
|
18
20
|
asset: string;
|
|
19
21
|
/** Raw token-unit amount string. */
|
|
@@ -107,6 +109,7 @@ interface ProbeResult {
|
|
|
107
109
|
interface L2Result {
|
|
108
110
|
title?: string;
|
|
109
111
|
description?: string;
|
|
112
|
+
version?: string;
|
|
110
113
|
routes: L2Route[];
|
|
111
114
|
source: 'openapi' | 'well-known/x402' | null;
|
|
112
115
|
}
|
|
@@ -164,6 +167,7 @@ interface DiscoverOriginSchemaSuccess {
|
|
|
164
167
|
info?: {
|
|
165
168
|
title: string;
|
|
166
169
|
description?: string;
|
|
170
|
+
version?: string;
|
|
167
171
|
};
|
|
168
172
|
/** Discovered endpoints with advisory pricing and auth metadata. */
|
|
169
173
|
endpoints: L2Route[];
|
|
@@ -196,6 +200,12 @@ interface CheckEndpointOptions {
|
|
|
196
200
|
*
|
|
197
201
|
*/
|
|
198
202
|
sampleInputBody?: Record<string, unknown>;
|
|
203
|
+
/**
|
|
204
|
+
* When true, skips OpenAPI lookup and probes the live endpoint directly.
|
|
205
|
+
* Use this to retrieve actual PaymentOptions (realm, payTo, network, asset, amount)
|
|
206
|
+
* from the 402 response rather than static OpenAPI metadata.
|
|
207
|
+
*/
|
|
208
|
+
probe?: boolean;
|
|
199
209
|
}
|
|
200
210
|
interface EndpointMethodAdvisory extends L3Result {
|
|
201
211
|
method: HttpMethod;
|
package/dist/index.d.ts
CHANGED
|
@@ -8,12 +8,14 @@ type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTION
|
|
|
8
8
|
|
|
9
9
|
interface MppPaymentOption {
|
|
10
10
|
protocol: 'mpp';
|
|
11
|
-
/** Payment method identifier, e.g. "tempo" (Tempo protocol). */
|
|
11
|
+
/** Payment method identifier, e.g. "tempo" (Tempo protocol). */
|
|
12
|
+
paymentMethod: string;
|
|
12
13
|
/** Payment intent type, e.g. "charge". */
|
|
13
14
|
intent: string;
|
|
14
15
|
/** Server protection realm. */
|
|
15
16
|
realm: string;
|
|
16
|
-
/** CAIP-2 style network identifier, e.g. "tempo:4217". */
|
|
17
|
+
/** CAIP-2 style network identifier, e.g. "tempo:4217". */
|
|
18
|
+
network: string;
|
|
17
19
|
/** Currency / token contract. */
|
|
18
20
|
asset: string;
|
|
19
21
|
/** Raw token-unit amount string. */
|
|
@@ -107,6 +109,7 @@ interface ProbeResult {
|
|
|
107
109
|
interface L2Result {
|
|
108
110
|
title?: string;
|
|
109
111
|
description?: string;
|
|
112
|
+
version?: string;
|
|
110
113
|
routes: L2Route[];
|
|
111
114
|
source: 'openapi' | 'well-known/x402' | null;
|
|
112
115
|
}
|
|
@@ -164,6 +167,7 @@ interface DiscoverOriginSchemaSuccess {
|
|
|
164
167
|
info?: {
|
|
165
168
|
title: string;
|
|
166
169
|
description?: string;
|
|
170
|
+
version?: string;
|
|
167
171
|
};
|
|
168
172
|
/** Discovered endpoints with advisory pricing and auth metadata. */
|
|
169
173
|
endpoints: L2Route[];
|
|
@@ -196,6 +200,12 @@ interface CheckEndpointOptions {
|
|
|
196
200
|
*
|
|
197
201
|
*/
|
|
198
202
|
sampleInputBody?: Record<string, unknown>;
|
|
203
|
+
/**
|
|
204
|
+
* When true, skips OpenAPI lookup and probes the live endpoint directly.
|
|
205
|
+
* Use this to retrieve actual PaymentOptions (realm, payTo, network, asset, amount)
|
|
206
|
+
* from the 402 response rather than static OpenAPI metadata.
|
|
207
|
+
*/
|
|
208
|
+
probe?: boolean;
|
|
199
209
|
}
|
|
200
210
|
interface EndpointMethodAdvisory extends L3Result {
|
|
201
211
|
method: HttpMethod;
|
package/dist/index.js
CHANGED
|
@@ -13834,7 +13834,6 @@ var WellKnownDocSchema = external_exports.object({
|
|
|
13834
13834
|
version: external_exports.number().optional(),
|
|
13835
13835
|
resources: external_exports.array(external_exports.string()).default([]),
|
|
13836
13836
|
mppResources: external_exports.array(external_exports.string()).optional(),
|
|
13837
|
-
// isMmmEnabled
|
|
13838
13837
|
description: external_exports.string().optional(),
|
|
13839
13838
|
ownershipProofs: external_exports.array(external_exports.string()).optional(),
|
|
13840
13839
|
instructions: external_exports.string().optional()
|
|
@@ -13944,9 +13943,6 @@ function fetchSafe(url2, init) {
|
|
|
13944
13943
|
return ResultAsync.fromPromise(fetch(url2, init), toFetchError);
|
|
13945
13944
|
}
|
|
13946
13945
|
|
|
13947
|
-
// src/mmm-enabled.ts
|
|
13948
|
-
var isMmmEnabled = () => "1.1.2".includes("-mmm");
|
|
13949
|
-
|
|
13950
13946
|
// src/core/source/openapi/index.ts
|
|
13951
13947
|
var OpenApiParsedSchema = OpenApiDocSchema.transform((doc) => {
|
|
13952
13948
|
const routes = [];
|
|
@@ -13956,9 +13952,7 @@ var OpenApiParsedSchema = OpenApiDocSchema.transform((doc) => {
|
|
|
13956
13952
|
if (!operation) continue;
|
|
13957
13953
|
const authMode = inferAuthMode(operation, doc.security, doc.components?.securitySchemes) ?? void 0;
|
|
13958
13954
|
const p = operation["x-payment-info"];
|
|
13959
|
-
const protocols = (p?.protocols ?? []).filter(
|
|
13960
|
-
(proto) => proto !== "mpp" || isMmmEnabled()
|
|
13961
|
-
);
|
|
13955
|
+
const protocols = (p?.protocols ?? []).filter((proto) => proto.length > 0);
|
|
13962
13956
|
const pricing = (authMode === "paid" || authMode === "apiKey+paid") && p ? {
|
|
13963
13957
|
pricingMode: p.pricingMode,
|
|
13964
13958
|
...p.price ? { price: p.price } : {},
|
|
@@ -14072,6 +14066,7 @@ function checkL2ForOpenAPI(openApi) {
|
|
|
14072
14066
|
return {
|
|
14073
14067
|
...openApi.info.title ? { title: openApi.info.title } : {},
|
|
14074
14068
|
...openApi.info.description ? { description: openApi.info.description } : {},
|
|
14069
|
+
...openApi.info.version ? { version: openApi.info.version } : {},
|
|
14075
14070
|
routes,
|
|
14076
14071
|
source: "openapi"
|
|
14077
14072
|
};
|
|
@@ -14142,7 +14137,13 @@ async function discoverOriginSchema(options) {
|
|
|
14142
14137
|
found: true,
|
|
14143
14138
|
origin,
|
|
14144
14139
|
source: "openapi",
|
|
14145
|
-
...l22.title ? {
|
|
14140
|
+
...l22.title ? {
|
|
14141
|
+
info: {
|
|
14142
|
+
title: l22.title,
|
|
14143
|
+
...l22.description ? { description: l22.description } : {},
|
|
14144
|
+
...l22.version ? { version: l22.version } : {}
|
|
14145
|
+
}
|
|
14146
|
+
} : {},
|
|
14146
14147
|
endpoints: l22.routes
|
|
14147
14148
|
};
|
|
14148
14149
|
return withGuidance(base2, l42, guidanceMode);
|
|
@@ -14596,7 +14597,7 @@ function detectProtocols(response) {
|
|
|
14596
14597
|
}
|
|
14597
14598
|
const authHeader = response.headers.get("www-authenticate")?.toLowerCase() ?? "";
|
|
14598
14599
|
if (authHeader.includes("x402")) protocols.add("x402");
|
|
14599
|
-
if (
|
|
14600
|
+
if (authHeader.includes("mpp")) protocols.add("mpp");
|
|
14600
14601
|
return [...protocols];
|
|
14601
14602
|
}
|
|
14602
14603
|
function buildProbeUrl(url2, method, inputBody) {
|
|
@@ -14676,7 +14677,7 @@ function parseAuthParams(segment) {
|
|
|
14676
14677
|
return params;
|
|
14677
14678
|
}
|
|
14678
14679
|
function extractPaymentOptions4(wwwAuthenticate) {
|
|
14679
|
-
if (!
|
|
14680
|
+
if (!wwwAuthenticate) return [];
|
|
14680
14681
|
const options = [];
|
|
14681
14682
|
for (const segment of wwwAuthenticate.split(/,\s*(?=Payment\s)/i)) {
|
|
14682
14683
|
const stripped = segment.replace(/^Payment\s+/i, "").trim();
|
|
@@ -14705,12 +14706,10 @@ function extractPaymentOptions4(wwwAuthenticate) {
|
|
|
14705
14706
|
if (!asset || !amount) continue;
|
|
14706
14707
|
options.push({
|
|
14707
14708
|
protocol: "mpp",
|
|
14708
|
-
// isMmmEnabled
|
|
14709
14709
|
paymentMethod,
|
|
14710
14710
|
intent,
|
|
14711
14711
|
realm,
|
|
14712
14712
|
network: `tempo:${String(chainId)}`,
|
|
14713
|
-
// isMmmEnabled
|
|
14714
14713
|
asset,
|
|
14715
14714
|
amount,
|
|
14716
14715
|
...decimals != null ? { decimals } : {},
|
|
@@ -14838,7 +14837,7 @@ function parseOperationProtocols(operation) {
|
|
|
14838
14837
|
const paymentInfo = operation["x-payment-info"];
|
|
14839
14838
|
if (!isRecord(paymentInfo) || !Array.isArray(paymentInfo.protocols)) return void 0;
|
|
14840
14839
|
const protocols = paymentInfo.protocols.filter(
|
|
14841
|
-
(protocol) => typeof protocol === "string" && protocol.length > 0
|
|
14840
|
+
(protocol) => typeof protocol === "string" && protocol.length > 0
|
|
14842
14841
|
);
|
|
14843
14842
|
return protocols.length > 0 ? protocols : void 0;
|
|
14844
14843
|
}
|
|
@@ -14869,8 +14868,7 @@ function getL3ForProbe(probe, path, method) {
|
|
|
14869
14868
|
const outputSchema = probeResult.paymentRequiredBody ? parseOutputSchema(probeResult.paymentRequiredBody) : void 0;
|
|
14870
14869
|
const paymentOptions = [
|
|
14871
14870
|
...probeResult.paymentRequiredBody ? extractPaymentOptions3(probeResult.paymentRequiredBody) : [],
|
|
14872
|
-
...
|
|
14873
|
-
// isMmmEnabled
|
|
14871
|
+
...extractPaymentOptions4(probeResult.wwwAuthenticate)
|
|
14874
14872
|
];
|
|
14875
14873
|
return {
|
|
14876
14874
|
source: "probe",
|
|
@@ -14914,7 +14912,7 @@ async function checkEndpointSchema(options) {
|
|
|
14914
14912
|
const endpoint = new URL(ensureProtocol(options.url));
|
|
14915
14913
|
const origin = normalizeOrigin(endpoint.origin);
|
|
14916
14914
|
const path = normalizePath(endpoint.pathname || "/");
|
|
14917
|
-
if (options.sampleInputBody !== void 0) {
|
|
14915
|
+
if (options.probe || options.sampleInputBody !== void 0) {
|
|
14918
14916
|
const probeResult2 = await getProbe(
|
|
14919
14917
|
endpoint.href,
|
|
14920
14918
|
options.headers,
|
package/dist/schemas.cjs
CHANGED
|
@@ -13856,7 +13856,6 @@ var WellKnownDocSchema = external_exports.object({
|
|
|
13856
13856
|
version: external_exports.number().optional(),
|
|
13857
13857
|
resources: external_exports.array(external_exports.string()).default([]),
|
|
13858
13858
|
mppResources: external_exports.array(external_exports.string()).optional(),
|
|
13859
|
-
// isMmmEnabled
|
|
13860
13859
|
description: external_exports.string().optional(),
|
|
13861
13860
|
ownershipProofs: external_exports.array(external_exports.string()).optional(),
|
|
13862
13861
|
instructions: external_exports.string().optional()
|
package/dist/schemas.js
CHANGED
|
@@ -13831,7 +13831,6 @@ var WellKnownDocSchema = external_exports.object({
|
|
|
13831
13831
|
version: external_exports.number().optional(),
|
|
13832
13832
|
resources: external_exports.array(external_exports.string()).default([]),
|
|
13833
13833
|
mppResources: external_exports.array(external_exports.string()).optional(),
|
|
13834
|
-
// isMmmEnabled
|
|
13835
13834
|
description: external_exports.string().optional(),
|
|
13836
13835
|
ownershipProofs: external_exports.array(external_exports.string()).optional(),
|
|
13837
13836
|
instructions: external_exports.string().optional()
|