@kontent-ai/delivery-sdk 16.4.5 → 16.4.6
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/bundles/kontent-delivery.umd.js +110 -24
- package/dist/bundles/kontent-delivery.umd.js.map +1 -1
- package/dist/bundles/kontent-delivery.umd.min.js +1 -1
- package/dist/bundles/kontent-delivery.umd.min.js.map +1 -1
- package/dist/bundles/report.json +1 -1
- package/dist/bundles/report.min.json +1 -1
- package/dist/bundles/stats.json +123 -81
- package/dist/bundles/stats.min.json +229 -159
- package/dist/cjs/sdk-info.generated.js +1 -1
- package/dist/es6/sdk-info.generated.js +1 -1
- package/dist/esnext/sdk-info.generated.js +1 -1
- package/lib/sdk-info.generated.ts +1 -1
- package/package.json +2 -2
|
@@ -360,7 +360,7 @@ var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _argume
|
|
|
360
360
|
|
|
361
361
|
|
|
362
362
|
function getWithRetryAsync(instance, call, functionsConfig, options) {
|
|
363
|
-
var _a;
|
|
363
|
+
var _a, _b;
|
|
364
364
|
return __awaiter(this, void 0, void 0, function* () {
|
|
365
365
|
const retryStrategyOptions = (_a = options === null || options === void 0 ? void 0 : options.retryStrategy) !== null && _a !== void 0 ? _a : _helpers_retry_helper__WEBPACK_IMPORTED_MODULE_3__.retryHelper.defaultRetryStrategy;
|
|
366
366
|
return yield runWithRetryAsync({
|
|
@@ -368,13 +368,14 @@ function getWithRetryAsync(instance, call, functionsConfig, options) {
|
|
|
368
368
|
url: call.url,
|
|
369
369
|
retryStrategy: retryStrategyOptions,
|
|
370
370
|
functionsConfig: functionsConfig,
|
|
371
|
+
headers: (_b = options === null || options === void 0 ? void 0 : options.headers) !== null && _b !== void 0 ? _b : [],
|
|
371
372
|
call: (retryAttempt) => __awaiter(this, void 0, void 0, function* () {
|
|
372
|
-
var
|
|
373
|
+
var _c, _d;
|
|
373
374
|
_http_debugger__WEBPACK_IMPORTED_MODULE_2__.httpDebugger.debugStartHttpRequest();
|
|
374
375
|
const axiosResponse = yield instance.get(call.url, {
|
|
375
|
-
headers: getHeadersJson((
|
|
376
|
+
headers: getHeadersJson((_c = options === null || options === void 0 ? void 0 : options.headers) !== null && _c !== void 0 ? _c : [], false),
|
|
376
377
|
responseType: options === null || options === void 0 ? void 0 : options.responseType,
|
|
377
|
-
cancelToken: (
|
|
378
|
+
cancelToken: (_d = options === null || options === void 0 ? void 0 : options.cancelToken) === null || _d === void 0 ? void 0 : _d.token
|
|
378
379
|
});
|
|
379
380
|
const response = {
|
|
380
381
|
data: axiosResponse.data,
|
|
@@ -393,7 +394,7 @@ function getWithRetryAsync(instance, call, functionsConfig, options) {
|
|
|
393
394
|
});
|
|
394
395
|
}
|
|
395
396
|
function postWithRetryAsync(instance, call, functionsConfig, options) {
|
|
396
|
-
var _a;
|
|
397
|
+
var _a, _b;
|
|
397
398
|
return __awaiter(this, void 0, void 0, function* () {
|
|
398
399
|
const retryStrategyOptions = (_a = options === null || options === void 0 ? void 0 : options.retryStrategy) !== null && _a !== void 0 ? _a : _helpers_retry_helper__WEBPACK_IMPORTED_MODULE_3__.retryHelper.defaultRetryStrategy;
|
|
399
400
|
return yield runWithRetryAsync({
|
|
@@ -401,17 +402,18 @@ function postWithRetryAsync(instance, call, functionsConfig, options) {
|
|
|
401
402
|
url: call.url,
|
|
402
403
|
retryStrategy: retryStrategyOptions,
|
|
403
404
|
functionsConfig: functionsConfig,
|
|
405
|
+
headers: (_b = options === null || options === void 0 ? void 0 : options.headers) !== null && _b !== void 0 ? _b : [],
|
|
404
406
|
call: (retryAttempt) => __awaiter(this, void 0, void 0, function* () {
|
|
405
|
-
var
|
|
407
|
+
var _c, _d;
|
|
406
408
|
_http_debugger__WEBPACK_IMPORTED_MODULE_2__.httpDebugger.debugStartHttpRequest();
|
|
407
409
|
const axiosResponse = yield instance.post(call.url, call.body, {
|
|
408
|
-
headers: getHeadersJson((
|
|
410
|
+
headers: getHeadersJson((_c = options === null || options === void 0 ? void 0 : options.headers) !== null && _c !== void 0 ? _c : [], false),
|
|
409
411
|
responseType: options === null || options === void 0 ? void 0 : options.responseType,
|
|
410
412
|
// required for uploading large files
|
|
411
413
|
// https://github.com/axios/axios/issues/1362
|
|
412
414
|
maxContentLength: 'Infinity',
|
|
413
415
|
maxBodyLength: 'Infinity',
|
|
414
|
-
cancelToken: (
|
|
416
|
+
cancelToken: (_d = options === null || options === void 0 ? void 0 : options.cancelToken) === null || _d === void 0 ? void 0 : _d.token
|
|
415
417
|
});
|
|
416
418
|
const response = {
|
|
417
419
|
data: axiosResponse.data,
|
|
@@ -430,7 +432,7 @@ function postWithRetryAsync(instance, call, functionsConfig, options) {
|
|
|
430
432
|
});
|
|
431
433
|
}
|
|
432
434
|
function putWithRetryAsync(instance, call, functionsConfig, options) {
|
|
433
|
-
var _a;
|
|
435
|
+
var _a, _b;
|
|
434
436
|
return __awaiter(this, void 0, void 0, function* () {
|
|
435
437
|
const retryStrategyOptions = (_a = options === null || options === void 0 ? void 0 : options.retryStrategy) !== null && _a !== void 0 ? _a : _helpers_retry_helper__WEBPACK_IMPORTED_MODULE_3__.retryHelper.defaultRetryStrategy;
|
|
436
438
|
return yield runWithRetryAsync({
|
|
@@ -438,17 +440,18 @@ function putWithRetryAsync(instance, call, functionsConfig, options) {
|
|
|
438
440
|
url: call.url,
|
|
439
441
|
retryStrategy: retryStrategyOptions,
|
|
440
442
|
functionsConfig: functionsConfig,
|
|
443
|
+
headers: (_b = options === null || options === void 0 ? void 0 : options.headers) !== null && _b !== void 0 ? _b : [],
|
|
441
444
|
call: (retryAttempt) => __awaiter(this, void 0, void 0, function* () {
|
|
442
|
-
var
|
|
445
|
+
var _c, _d;
|
|
443
446
|
_http_debugger__WEBPACK_IMPORTED_MODULE_2__.httpDebugger.debugStartHttpRequest();
|
|
444
447
|
const axiosResponse = yield instance.put(call.url, call.body, {
|
|
445
|
-
headers: getHeadersJson((
|
|
448
|
+
headers: getHeadersJson((_c = options === null || options === void 0 ? void 0 : options.headers) !== null && _c !== void 0 ? _c : [], false),
|
|
446
449
|
responseType: options === null || options === void 0 ? void 0 : options.responseType,
|
|
447
450
|
// required for uploading large files
|
|
448
451
|
// https://github.com/axios/axios/issues/1362
|
|
449
452
|
maxContentLength: 'Infinity',
|
|
450
453
|
maxBodyLength: 'Infinity',
|
|
451
|
-
cancelToken: (
|
|
454
|
+
cancelToken: (_d = options === null || options === void 0 ? void 0 : options.cancelToken) === null || _d === void 0 ? void 0 : _d.token
|
|
452
455
|
});
|
|
453
456
|
const response = {
|
|
454
457
|
data: axiosResponse.data,
|
|
@@ -467,7 +470,7 @@ function putWithRetryAsync(instance, call, functionsConfig, options) {
|
|
|
467
470
|
});
|
|
468
471
|
}
|
|
469
472
|
function patchWithRetryAsync(instance, call, functionsConfig, options) {
|
|
470
|
-
var _a;
|
|
473
|
+
var _a, _b;
|
|
471
474
|
return __awaiter(this, void 0, void 0, function* () {
|
|
472
475
|
const retryStrategyOptions = (_a = options === null || options === void 0 ? void 0 : options.retryStrategy) !== null && _a !== void 0 ? _a : _helpers_retry_helper__WEBPACK_IMPORTED_MODULE_3__.retryHelper.defaultRetryStrategy;
|
|
473
476
|
return yield runWithRetryAsync({
|
|
@@ -475,17 +478,18 @@ function patchWithRetryAsync(instance, call, functionsConfig, options) {
|
|
|
475
478
|
url: call.url,
|
|
476
479
|
retryStrategy: retryStrategyOptions,
|
|
477
480
|
functionsConfig: functionsConfig,
|
|
481
|
+
headers: (_b = options === null || options === void 0 ? void 0 : options.headers) !== null && _b !== void 0 ? _b : [],
|
|
478
482
|
call: (retryAttempt) => __awaiter(this, void 0, void 0, function* () {
|
|
479
|
-
var
|
|
483
|
+
var _c, _d;
|
|
480
484
|
_http_debugger__WEBPACK_IMPORTED_MODULE_2__.httpDebugger.debugStartHttpRequest();
|
|
481
485
|
const axiosResponse = yield instance.patch(call.url, call.body, {
|
|
482
|
-
headers: getHeadersJson((
|
|
486
|
+
headers: getHeadersJson((_c = options === null || options === void 0 ? void 0 : options.headers) !== null && _c !== void 0 ? _c : [], false),
|
|
483
487
|
responseType: options === null || options === void 0 ? void 0 : options.responseType,
|
|
484
488
|
// required for uploading large files
|
|
485
489
|
// https://github.com/axios/axios/issues/1362
|
|
486
490
|
maxContentLength: 'Infinity',
|
|
487
491
|
maxBodyLength: 'Infinity',
|
|
488
|
-
cancelToken: (
|
|
492
|
+
cancelToken: (_d = options === null || options === void 0 ? void 0 : options.cancelToken) === null || _d === void 0 ? void 0 : _d.token
|
|
489
493
|
});
|
|
490
494
|
const response = {
|
|
491
495
|
data: axiosResponse.data,
|
|
@@ -504,7 +508,7 @@ function patchWithRetryAsync(instance, call, functionsConfig, options) {
|
|
|
504
508
|
});
|
|
505
509
|
}
|
|
506
510
|
function deleteWithRetryAsync(instance, call, functionsConfig, options) {
|
|
507
|
-
var _a;
|
|
511
|
+
var _a, _b;
|
|
508
512
|
return __awaiter(this, void 0, void 0, function* () {
|
|
509
513
|
const retryStrategyOptions = (_a = options === null || options === void 0 ? void 0 : options.retryStrategy) !== null && _a !== void 0 ? _a : _helpers_retry_helper__WEBPACK_IMPORTED_MODULE_3__.retryHelper.defaultRetryStrategy;
|
|
510
514
|
return yield runWithRetryAsync({
|
|
@@ -512,17 +516,18 @@ function deleteWithRetryAsync(instance, call, functionsConfig, options) {
|
|
|
512
516
|
url: call.url,
|
|
513
517
|
retryStrategy: retryStrategyOptions,
|
|
514
518
|
functionsConfig: functionsConfig,
|
|
519
|
+
headers: (_b = options === null || options === void 0 ? void 0 : options.headers) !== null && _b !== void 0 ? _b : [],
|
|
515
520
|
call: (retryAttempt) => __awaiter(this, void 0, void 0, function* () {
|
|
516
|
-
var
|
|
521
|
+
var _c, _d;
|
|
517
522
|
_http_debugger__WEBPACK_IMPORTED_MODULE_2__.httpDebugger.debugStartHttpRequest();
|
|
518
523
|
const axiosResponse = yield instance.delete(call.url, {
|
|
519
|
-
headers: getHeadersJson((
|
|
524
|
+
headers: getHeadersJson((_c = options === null || options === void 0 ? void 0 : options.headers) !== null && _c !== void 0 ? _c : [], false),
|
|
520
525
|
responseType: options === null || options === void 0 ? void 0 : options.responseType,
|
|
521
526
|
// required for uploading large files
|
|
522
527
|
// https://github.com/axios/axios/issues/1362
|
|
523
528
|
maxContentLength: 'Infinity',
|
|
524
529
|
maxBodyLength: 'Infinity',
|
|
525
|
-
cancelToken: (
|
|
530
|
+
cancelToken: (_d = options === null || options === void 0 ? void 0 : options.cancelToken) === null || _d === void 0 ? void 0 : _d.token
|
|
526
531
|
});
|
|
527
532
|
const response = {
|
|
528
533
|
data: axiosResponse.data,
|
|
@@ -575,16 +580,97 @@ function runWithRetryAsync(data) {
|
|
|
575
580
|
retryStrategy: data.retryStrategy,
|
|
576
581
|
retryAttempt: data.retryAttempt + 1,
|
|
577
582
|
url: data.url,
|
|
578
|
-
functionsConfig: data.functionsConfig
|
|
583
|
+
functionsConfig: data.functionsConfig,
|
|
584
|
+
headers: data.headers
|
|
579
585
|
});
|
|
580
586
|
}
|
|
587
|
+
// sanitize the error before logging / re-throwing so the authorization token is not leaked
|
|
588
|
+
const sanitizedError = sanitizeError(error, data.headers);
|
|
581
589
|
if (data.functionsConfig.logErrorsToConsole) {
|
|
582
|
-
console.error(`Executing '${data.url}' failed. Request was retried '${data.retryAttempt}' times
|
|
590
|
+
console.error(`Executing '${data.url}' failed. Request was retried '${data.retryAttempt}' times.`, sanitizedError);
|
|
583
591
|
}
|
|
584
|
-
throw
|
|
592
|
+
throw sanitizedError;
|
|
585
593
|
}
|
|
586
594
|
});
|
|
587
595
|
}
|
|
596
|
+
const redactedValue = 'redacted';
|
|
597
|
+
const maxRedactionDepth = 10;
|
|
598
|
+
/**
|
|
599
|
+
* Returns the caller-supplied 'authorization' header value(s), which are the secret token(s) to
|
|
600
|
+
* scrub from errors. Note: if a consumer sets the authorization token on the axios instance defaults
|
|
601
|
+
* instead of passing it via 'options.headers', it is not known here and cannot be redacted.
|
|
602
|
+
*/
|
|
603
|
+
function getSecretHeaderValues(headers) {
|
|
604
|
+
return headers
|
|
605
|
+
.filter((header) => header.header.toLowerCase() === 'authorization')
|
|
606
|
+
.map((header) => header.value)
|
|
607
|
+
// skip empty values - splitting on an empty string would corrupt every string
|
|
608
|
+
.filter((value) => typeof value === 'string' && value.length > 0);
|
|
609
|
+
}
|
|
610
|
+
function redactStringValue(value, secrets) {
|
|
611
|
+
let result = value;
|
|
612
|
+
for (const secret of secrets) {
|
|
613
|
+
if (result.includes(secret)) {
|
|
614
|
+
result = result.split(secret).join(redactedValue);
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
return result;
|
|
618
|
+
}
|
|
619
|
+
/**
|
|
620
|
+
* Walks the object graph (cycle- and depth-guarded) replacing every occurrence of a secret with the
|
|
621
|
+
* redacted placeholder in place.
|
|
622
|
+
*/
|
|
623
|
+
function redactSecretsInPlace(target, secrets, seen, depth) {
|
|
624
|
+
if (depth > maxRedactionDepth || target === null || typeof target !== 'object') {
|
|
625
|
+
return;
|
|
626
|
+
}
|
|
627
|
+
if (seen.has(target)) {
|
|
628
|
+
// break cycles (config.headers, request.socket, response.request, ...)
|
|
629
|
+
return;
|
|
630
|
+
}
|
|
631
|
+
seen.add(target);
|
|
632
|
+
for (const key of Object.keys(target)) {
|
|
633
|
+
let value;
|
|
634
|
+
try {
|
|
635
|
+
value = target[key];
|
|
636
|
+
}
|
|
637
|
+
catch (_a) {
|
|
638
|
+
// accessing the property threw (e.g. a getter) - skip it
|
|
639
|
+
continue;
|
|
640
|
+
}
|
|
641
|
+
if (typeof value === 'string') {
|
|
642
|
+
const redacted = redactStringValue(value, secrets);
|
|
643
|
+
if (redacted !== value) {
|
|
644
|
+
try {
|
|
645
|
+
target[key] = redacted;
|
|
646
|
+
}
|
|
647
|
+
catch (_b) {
|
|
648
|
+
// property is read-only - skip it
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
else if (value && typeof value === 'object') {
|
|
653
|
+
redactSecretsInPlace(value, secrets, seen, depth + 1);
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
/**
|
|
658
|
+
* If 'error' is an axios error, redacts every occurrence of the caller's authorization token (taken
|
|
659
|
+
* from 'headers') throughout the error, replacing it with a redacted placeholder. Non-axios errors
|
|
660
|
+
* and errors with no known token are returned unchanged. This prevents the authorization token from
|
|
661
|
+
* leaking via console logs or the re-thrown error. All other axios properties are preserved.
|
|
662
|
+
*/
|
|
663
|
+
function sanitizeError(error, headers) {
|
|
664
|
+
if (!axios__WEBPACK_IMPORTED_MODULE_0__["default"].isAxiosError(error)) {
|
|
665
|
+
return error;
|
|
666
|
+
}
|
|
667
|
+
const secrets = getSecretHeaderValues(headers);
|
|
668
|
+
if (secrets.length === 0) {
|
|
669
|
+
return error;
|
|
670
|
+
}
|
|
671
|
+
redactSecretsInPlace(error, secrets, new WeakSet(), 0);
|
|
672
|
+
return error;
|
|
673
|
+
}
|
|
588
674
|
function getHeadersJson(headers, addContentTypeHeader) {
|
|
589
675
|
const headerJson = {};
|
|
590
676
|
headers.forEach((header) => {
|
|
@@ -4394,7 +4480,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
4394
4480
|
exports.sdkInfo = void 0;
|
|
4395
4481
|
exports.sdkInfo = {
|
|
4396
4482
|
host: 'npmjs.com',
|
|
4397
|
-
version: '16.4.
|
|
4483
|
+
version: '16.4.6',
|
|
4398
4484
|
name: '@kontent-ai/delivery-sdk'
|
|
4399
4485
|
};
|
|
4400
4486
|
|