@marcohefti/request-network-api-client 0.5.8 → 0.5.10
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/README.md +5 -7
- package/dist/cjs/domains/currencies/index.js +4 -2
- package/dist/cjs/domains/currencies/index.js.map +1 -1
- package/dist/cjs/domains/requests/index.js +2 -2
- package/dist/cjs/domains/requests/index.js.map +1 -1
- package/dist/cjs/index.js +80 -14
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/domains/currencies/index.d.mts +1 -1
- package/dist/esm/domains/currencies/index.js +4 -2
- package/dist/esm/domains/currencies/index.js.map +1 -1
- package/dist/esm/domains/requests/index.js +2 -2
- package/dist/esm/domains/requests/index.js.map +1 -1
- package/dist/esm/{index-ziziGrHN.d.mts → index-Bum0bfZQ.d.mts} +2 -1
- package/dist/esm/index.d.mts +10 -15
- package/dist/esm/index.js +81 -14
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -639,6 +639,65 @@ function asRecord(value) {
|
|
|
639
639
|
}
|
|
640
640
|
return void 0;
|
|
641
641
|
}
|
|
642
|
+
var REDACTED_VALUE = "<redacted>";
|
|
643
|
+
var REDACTED_HEADERS = /* @__PURE__ */ new Set(["x-api-key", "authorization", "cookie"]);
|
|
644
|
+
var RESPONSE_HEADER_ALLOWLIST = /* @__PURE__ */ new Set(["content-type", "content-length", "x-request-id", "x-correlation-id", "retry-after"]);
|
|
645
|
+
var LOG_TRUNCATION = {
|
|
646
|
+
maxDepth: 5,
|
|
647
|
+
maxKeys: 50,
|
|
648
|
+
maxArray: 50,
|
|
649
|
+
maxString: 2e3
|
|
650
|
+
};
|
|
651
|
+
function redactHeaders(headers) {
|
|
652
|
+
const out = {};
|
|
653
|
+
if (!headers) return out;
|
|
654
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
655
|
+
const lower = key.toLowerCase();
|
|
656
|
+
out[lower] = REDACTED_HEADERS.has(lower) ? REDACTED_VALUE : value;
|
|
657
|
+
}
|
|
658
|
+
return out;
|
|
659
|
+
}
|
|
660
|
+
function pickResponseHeaders(headers) {
|
|
661
|
+
const out = {};
|
|
662
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
663
|
+
const lower = key.toLowerCase();
|
|
664
|
+
if (RESPONSE_HEADER_ALLOWLIST.has(lower)) {
|
|
665
|
+
out[lower] = value;
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
return out;
|
|
669
|
+
}
|
|
670
|
+
function truncateStringForLogs(value) {
|
|
671
|
+
return value.length > LOG_TRUNCATION.maxString ? `${value.slice(0, LOG_TRUNCATION.maxString)}\u2026(truncated)` : value;
|
|
672
|
+
}
|
|
673
|
+
function truncateArrayForLogs(value, depth) {
|
|
674
|
+
const trimmed = value.slice(0, LOG_TRUNCATION.maxArray).map((item) => truncateForLogs(item, depth + 1));
|
|
675
|
+
return value.length > LOG_TRUNCATION.maxArray ? [...trimmed, "[truncated:max-array]"] : trimmed;
|
|
676
|
+
}
|
|
677
|
+
function truncateObjectForLogs(value, depth) {
|
|
678
|
+
const entries = Object.entries(value);
|
|
679
|
+
const sliced = entries.slice(0, LOG_TRUNCATION.maxKeys);
|
|
680
|
+
const out = {};
|
|
681
|
+
for (const [key, v] of sliced) {
|
|
682
|
+
out[key] = truncateForLogs(v, depth + 1);
|
|
683
|
+
}
|
|
684
|
+
if (entries.length > LOG_TRUNCATION.maxKeys) {
|
|
685
|
+
out["__truncated__"] = "max-keys";
|
|
686
|
+
}
|
|
687
|
+
return out;
|
|
688
|
+
}
|
|
689
|
+
function truncateForLogs(value, depth = 0) {
|
|
690
|
+
if (value == null) return value;
|
|
691
|
+
if (typeof value === "string") return truncateStringForLogs(value);
|
|
692
|
+
if (typeof value === "number" || typeof value === "boolean") return value;
|
|
693
|
+
if (typeof value === "bigint") return value.toString();
|
|
694
|
+
if (typeof value === "symbol") return value.toString();
|
|
695
|
+
if (typeof value === "function") return "[function]";
|
|
696
|
+
if (depth >= LOG_TRUNCATION.maxDepth) return "[truncated:max-depth]";
|
|
697
|
+
if (Array.isArray(value)) return truncateArrayForLogs(value, depth);
|
|
698
|
+
if (typeof value === "object") return truncateObjectForLogs(value, depth);
|
|
699
|
+
return "[unserializable]";
|
|
700
|
+
}
|
|
642
701
|
function mapToError(res, req, validation) {
|
|
643
702
|
const operationId = req.meta?.operationId;
|
|
644
703
|
const rawPayload = asRecord(res.data);
|
|
@@ -656,11 +715,25 @@ function mapToError(res, req, validation) {
|
|
|
656
715
|
}
|
|
657
716
|
payload = asRecord(parsed.data);
|
|
658
717
|
}
|
|
718
|
+
const captureErrorContext = req.meta?.captureErrorContext === true;
|
|
659
719
|
const error = buildRequestApiError({
|
|
660
720
|
payload,
|
|
661
721
|
status: res.status,
|
|
662
722
|
headers: res.headers,
|
|
663
|
-
fallbackMessage: res.text ?? `HTTP ${String(res.status)}
|
|
723
|
+
fallbackMessage: res.text ?? `HTTP ${String(res.status)}`,
|
|
724
|
+
meta: captureErrorContext ? {
|
|
725
|
+
request: {
|
|
726
|
+
method: req.method,
|
|
727
|
+
url: req.url,
|
|
728
|
+
headers: redactHeaders(req.headers),
|
|
729
|
+
hasBody: req.body != null
|
|
730
|
+
},
|
|
731
|
+
response: {
|
|
732
|
+
status: res.status,
|
|
733
|
+
headers: pickResponseHeaders(res.headers),
|
|
734
|
+
body: truncateForLogs(res.data ?? res.text)
|
|
735
|
+
}
|
|
736
|
+
} : void 0
|
|
664
737
|
});
|
|
665
738
|
throw error;
|
|
666
739
|
}
|
|
@@ -1183,7 +1256,8 @@ function createCurrenciesApi(http) {
|
|
|
1183
1256
|
description: DESCRIPTION_LIST2,
|
|
1184
1257
|
signal: options?.signal,
|
|
1185
1258
|
timeoutMs: options?.timeoutMs,
|
|
1186
|
-
validation: options?.validation
|
|
1259
|
+
validation: options?.validation,
|
|
1260
|
+
meta: options?.meta
|
|
1187
1261
|
});
|
|
1188
1262
|
const parsed = parseWithSchema({
|
|
1189
1263
|
schema: CurrenciesListSchema,
|
|
@@ -1205,7 +1279,8 @@ function createCurrenciesApi(http) {
|
|
|
1205
1279
|
description: DESCRIPTION_CONVERSION_ROUTES2,
|
|
1206
1280
|
signal: options?.signal,
|
|
1207
1281
|
timeoutMs: options?.timeoutMs,
|
|
1208
|
-
validation: options?.validation
|
|
1282
|
+
validation: options?.validation,
|
|
1283
|
+
meta: options?.meta
|
|
1209
1284
|
});
|
|
1210
1285
|
const parsed = parseWithSchema({
|
|
1211
1286
|
schema: ConversionRoutesSchema,
|
|
@@ -2188,7 +2263,7 @@ var RequestControllerV1_stopRecurrenceRequest_v1_404 = ErrorEnvelopeSchema6;
|
|
|
2188
2263
|
schemaRegistry.register({ key: { operationId: "RequestControllerV1_stopRecurrenceRequest_v1", kind: "response", status: 404 }, schema: RequestControllerV1_stopRecurrenceRequest_v1_404 });
|
|
2189
2264
|
var RequestControllerV1_stopRecurrenceRequest_v1_429 = ErrorEnvelopeSchema6;
|
|
2190
2265
|
schemaRegistry.register({ key: { operationId: "RequestControllerV1_stopRecurrenceRequest_v1", kind: "response", status: 429 }, schema: RequestControllerV1_stopRecurrenceRequest_v1_429 });
|
|
2191
|
-
var RequestControllerV1_getPaymentCalldata_v1_200 = z.union([z.object({ "transactions": z.array(z.object({ "data": z.string(), "to": z.string(), "value": z.object({ "type": z.enum(["BigNumber"]).optional(), "hex": z.string().optional() }).passthrough() }).passthrough()), "metadata": z.object({ "stepsRequired": z.number(), "needsApproval": z.boolean(), "approvalTransactionIndex": z.number().nullable().optional(), "hasEnoughBalance": z.boolean(), "hasEnoughGas": z.boolean() }).passthrough() }).passthrough(), z.object({ "paymentIntentId": z.string(), "paymentIntent": z.string(), "approvalPermitPayload": z.string().nullable().optional(), "approvalCalldata": z.object({ "to": z.string().optional(), "data": z.string().optional(), "value": z.string().optional() }).passthrough().nullable().optional(), "metadata": z.object({ "supportsEIP2612": z.boolean() }).passthrough() }).passthrough()]);
|
|
2266
|
+
var RequestControllerV1_getPaymentCalldata_v1_200 = z.union([z.object({ "transactions": z.array(z.object({ "data": z.string(), "to": z.string(), "value": z.object({ "type": z.enum(["BigNumber"]).optional(), "hex": z.string().optional() }).passthrough() }).passthrough()), "metadata": z.object({ "stepsRequired": z.number(), "needsApproval": z.boolean(), "approvalTransactionIndex": z.number().nullable().optional(), "paymentTransactionIndex": z.number().nullable().optional(), "hasEnoughBalance": z.boolean().optional(), "hasEnoughGas": z.boolean().optional() }).passthrough() }).passthrough(), z.object({ "paymentIntentId": z.string(), "paymentIntent": z.string(), "approvalPermitPayload": z.string().nullable().optional(), "approvalCalldata": z.object({ "to": z.string().optional(), "data": z.string().optional(), "value": z.string().optional() }).passthrough().nullable().optional(), "metadata": z.object({ "supportsEIP2612": z.boolean() }).passthrough() }).passthrough()]);
|
|
2192
2267
|
schemaRegistry.register({ key: { operationId: "RequestControllerV1_getPaymentCalldata_v1", kind: "response", status: 200 }, schema: RequestControllerV1_getPaymentCalldata_v1_200 });
|
|
2193
2268
|
var RequestControllerV1_getPaymentCalldata_v1_400 = ErrorEnvelopeSchema6;
|
|
2194
2269
|
schemaRegistry.register({ key: { operationId: "RequestControllerV1_getPaymentCalldata_v1", kind: "response", status: 400 }, schema: RequestControllerV1_getPaymentCalldata_v1_400 });
|
|
@@ -2238,7 +2313,7 @@ var RequestControllerV2_updateRequest_v2_404 = ErrorEnvelopeSchema6;
|
|
|
2238
2313
|
schemaRegistry.register({ key: { operationId: "RequestControllerV2_updateRequest_v2", kind: "response", status: 404 }, schema: RequestControllerV2_updateRequest_v2_404 });
|
|
2239
2314
|
var RequestControllerV2_updateRequest_v2_429 = ErrorEnvelopeSchema6;
|
|
2240
2315
|
schemaRegistry.register({ key: { operationId: "RequestControllerV2_updateRequest_v2", kind: "response", status: 429 }, schema: RequestControllerV2_updateRequest_v2_429 });
|
|
2241
|
-
var RequestControllerV2_getPaymentCalldata_v2_200 = z.union([z.object({ "transactions": z.array(z.object({ "data": z.string(), "to": z.string(), "value": z.object({ "type": z.enum(["BigNumber"]).optional(), "hex": z.string().optional() }).passthrough() }).passthrough()), "metadata": z.object({ "stepsRequired": z.number(), "needsApproval": z.boolean(), "approvalTransactionIndex": z.number().nullable().optional(), "hasEnoughBalance": z.boolean(), "hasEnoughGas": z.boolean() }).passthrough() }).passthrough(), z.object({ "paymentIntentId": z.string(), "paymentIntent": z.string(), "approvalPermitPayload": z.string().nullable().optional(), "approvalCalldata": z.object({ "to": z.string().optional(), "data": z.string().optional(), "value": z.string().optional() }).passthrough().nullable().optional(), "metadata": z.object({ "supportsEIP2612": z.boolean() }).passthrough() }).passthrough()]);
|
|
2316
|
+
var RequestControllerV2_getPaymentCalldata_v2_200 = z.union([z.object({ "transactions": z.array(z.object({ "data": z.string(), "to": z.string(), "value": z.object({ "type": z.enum(["BigNumber"]).optional(), "hex": z.string().optional() }).passthrough() }).passthrough()), "metadata": z.object({ "stepsRequired": z.number(), "needsApproval": z.boolean(), "approvalTransactionIndex": z.number().nullable().optional(), "paymentTransactionIndex": z.number().nullable().optional(), "hasEnoughBalance": z.boolean().optional(), "hasEnoughGas": z.boolean().optional() }).passthrough() }).passthrough(), z.object({ "paymentIntentId": z.string(), "paymentIntent": z.string(), "approvalPermitPayload": z.string().nullable().optional(), "approvalCalldata": z.object({ "to": z.string().optional(), "data": z.string().optional(), "value": z.string().optional() }).passthrough().nullable().optional(), "metadata": z.object({ "supportsEIP2612": z.boolean() }).passthrough() }).passthrough()]);
|
|
2242
2317
|
schemaRegistry.register({ key: { operationId: "RequestControllerV2_getPaymentCalldata_v2", kind: "response", status: 200 }, schema: RequestControllerV2_getPaymentCalldata_v2_200 });
|
|
2243
2318
|
var RequestControllerV2_getPaymentCalldata_v2_400 = ErrorEnvelopeSchema6;
|
|
2244
2319
|
schemaRegistry.register({ key: { operationId: "RequestControllerV2_getPaymentCalldata_v2", kind: "response", status: 400 }, schema: RequestControllerV2_getPaymentCalldata_v2_400 });
|
|
@@ -2309,14 +2384,6 @@ function createRequestClient(options) {
|
|
|
2309
2384
|
};
|
|
2310
2385
|
}
|
|
2311
2386
|
|
|
2312
|
-
// src/core/config/request-environment.config.ts
|
|
2313
|
-
var RequestEnvironment = {
|
|
2314
|
-
production: "https://api.request.network",
|
|
2315
|
-
// Legacy placeholder for partner-managed sandboxes; Request does not operate a public staging host.
|
|
2316
|
-
staging: "https://api.stage.request.network",
|
|
2317
|
-
local: "http://127.0.0.1:8080"
|
|
2318
|
-
};
|
|
2319
|
-
|
|
2320
2387
|
// src/domains/requests/v1/index.ts
|
|
2321
2388
|
var v1_exports4 = {};
|
|
2322
2389
|
__export(v1_exports4, {
|
|
@@ -3423,6 +3490,6 @@ function assertRequestRecurringEvent(event) {
|
|
|
3423
3490
|
}
|
|
3424
3491
|
}
|
|
3425
3492
|
|
|
3426
|
-
export { DEFAULT_RETRY_CONFIG, RequestApiError,
|
|
3493
|
+
export { DEFAULT_RETRY_CONFIG, RequestApiError, SchemaRegistry, ValidationError, browserFetchAdapter, buildRequestApiError, client_ids_exports as clientIds, computeRetryDelay, createHttpClient, createRequestClient, currencies_exports as currencies, v1_exports as currenciesV1, isRequestApiError, nodeFetchAdapter, parseWithRegistry, parseWithSchema, pay_exports as pay, v1_exports2 as payV1, payer_exports as payer, v1_exports3 as payerV1, v2_exports as payerV2, payments_exports as payments, payouts_exports as payouts, requests_exports as requests, v1_exports4 as requestsV1, schemaRegistry, shouldRetryRequest, webhooks_exports as webhooks };
|
|
3427
3494
|
//# sourceMappingURL=index.js.map
|
|
3428
3495
|
//# sourceMappingURL=index.js.map
|