@weftlabs/sdk 0.25.0 → 0.26.1
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/facilitator/middleware/index.js +29 -17
- package/dist/facilitator/middleware/index.js.map +1 -1
- package/dist/facilitator/middleware/index.mjs +15 -5
- package/dist/facilitator/middleware/index.mjs.map +1 -1
- package/dist/index.d.mts +98 -96
- package/dist/index.d.ts +98 -96
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -2
- package/dist/index.mjs.map +1 -1
- package/dist/server.js +29 -17
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +15 -5
- package/dist/server.mjs.map +1 -1
- package/docs/FetchApi.md +3 -3
- package/package.json +1 -1
package/dist/server.mjs
CHANGED
|
@@ -175,12 +175,11 @@ async function getFeeInfo(config, cacheConfig) {
|
|
|
175
175
|
import {
|
|
176
176
|
SETTLEMENT_OVERRIDES_HEADER,
|
|
177
177
|
withPrivateCacheControl,
|
|
178
|
-
x402HTTPResourceServer,
|
|
179
178
|
x402ResourceServer
|
|
180
179
|
} from "@x402/core/server";
|
|
181
180
|
|
|
182
181
|
// package.json
|
|
183
|
-
var version = "0.
|
|
182
|
+
var version = "0.26.1";
|
|
184
183
|
|
|
185
184
|
// src/facilitator/middleware/product.ts
|
|
186
185
|
var PRODUCT_TYPES = ["api", "agent", "mcp"];
|
|
@@ -768,6 +767,7 @@ function resumePaymentResult(resourceServer, resumed, context) {
|
|
|
768
767
|
}
|
|
769
768
|
|
|
770
769
|
// src/facilitator/middleware/settlement.ts
|
|
770
|
+
import { x402HTTPResourceServer } from "@x402/core/server";
|
|
771
771
|
import { decodePaymentResponseHeader } from "@x402/core/http";
|
|
772
772
|
var CORE_FACILITATOR_UNAVAILABLE = /^Facilitator settle failed \(503\):(?: |$)/;
|
|
773
773
|
function isFacilitatorUnavailable(errorReason) {
|
|
@@ -810,6 +810,17 @@ function serializeResponseBody(response) {
|
|
|
810
810
|
}
|
|
811
811
|
return typeof response.body === "string" ? response.body : String(response.body ?? "");
|
|
812
812
|
}
|
|
813
|
+
var WeftHTTPResourceServer = class extends x402HTTPResourceServer {
|
|
814
|
+
processSettlement(...args) {
|
|
815
|
+
const request = args[3]?.request;
|
|
816
|
+
const method = request?.method ?? request?.adapter.getMethod();
|
|
817
|
+
if (method) {
|
|
818
|
+
const payload = { ...args[0], httpMethod: method.toUpperCase() };
|
|
819
|
+
args[0] = payload;
|
|
820
|
+
}
|
|
821
|
+
return super.processSettlement(...args);
|
|
822
|
+
}
|
|
823
|
+
};
|
|
813
824
|
|
|
814
825
|
// src/facilitator/middleware/express.ts
|
|
815
826
|
var UNSAFE_FAILURE_HEADERS = /* @__PURE__ */ new Set([
|
|
@@ -934,7 +945,7 @@ function weftPaymentMiddleware(routes, config) {
|
|
|
934
945
|
resourceServer.register(network, schemeServer);
|
|
935
946
|
});
|
|
936
947
|
}
|
|
937
|
-
const httpServer = new
|
|
948
|
+
const httpServer = new WeftHTTPResourceServer(
|
|
938
949
|
resourceServer,
|
|
939
950
|
applyProductIdentity(routes, config ?? {})
|
|
940
951
|
);
|
|
@@ -1238,7 +1249,6 @@ function weftPaymentMiddleware(routes, config) {
|
|
|
1238
1249
|
import {
|
|
1239
1250
|
SETTLEMENT_OVERRIDES_HEADER as SETTLEMENT_OVERRIDES_HEADER2,
|
|
1240
1251
|
withPrivateCacheControl as withPrivateCacheControl2,
|
|
1241
|
-
x402HTTPResourceServer as x402HTTPResourceServer2,
|
|
1242
1252
|
x402ResourceServer as x402ResourceServer2
|
|
1243
1253
|
} from "@x402/core/server";
|
|
1244
1254
|
var FACILITATOR_SYNC_RETRY_FLOOR_MS2 = 3e4;
|
|
@@ -1357,7 +1367,7 @@ function weftPaymentMiddlewareHono(routes, config) {
|
|
|
1357
1367
|
resourceServer.register(network, schemeServer);
|
|
1358
1368
|
});
|
|
1359
1369
|
}
|
|
1360
|
-
const httpServer = new
|
|
1370
|
+
const httpServer = new WeftHTTPResourceServer(
|
|
1361
1371
|
resourceServer,
|
|
1362
1372
|
applyProductIdentity(routes, config ?? {})
|
|
1363
1373
|
);
|