@kontent-ai/delivery-sdk 16.4.4 → 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.
Files changed (48) hide show
  1. package/dist/bundles/kontent-delivery.umd.js +115 -29
  2. package/dist/bundles/kontent-delivery.umd.js.map +1 -1
  3. package/dist/bundles/kontent-delivery.umd.min.js +1 -1
  4. package/dist/bundles/kontent-delivery.umd.min.js.map +1 -1
  5. package/dist/bundles/report.json +1 -1
  6. package/dist/bundles/report.min.json +1 -1
  7. package/dist/bundles/stats.json +467 -425
  8. package/dist/bundles/stats.min.json +189 -119
  9. package/dist/cjs/query/element/element-query.class.js +1 -1
  10. package/dist/cjs/query/element/element-query.class.js.map +1 -1
  11. package/dist/cjs/query/item/single-item-query.class.js +1 -1
  12. package/dist/cjs/query/item/single-item-query.class.js.map +1 -1
  13. package/dist/cjs/query/taxonomy/taxonomy-query.class.js +1 -1
  14. package/dist/cjs/query/taxonomy/taxonomy-query.class.js.map +1 -1
  15. package/dist/cjs/query/type/single-type-query.class.js +1 -1
  16. package/dist/cjs/query/type/single-type-query.class.js.map +1 -1
  17. package/dist/cjs/query/used-in/used-in-query.class.js +1 -1
  18. package/dist/cjs/query/used-in/used-in-query.class.js.map +1 -1
  19. package/dist/cjs/sdk-info.generated.js +1 -1
  20. package/dist/es6/query/element/element-query.class.js +1 -1
  21. package/dist/es6/query/element/element-query.class.js.map +1 -1
  22. package/dist/es6/query/item/single-item-query.class.js +1 -1
  23. package/dist/es6/query/item/single-item-query.class.js.map +1 -1
  24. package/dist/es6/query/taxonomy/taxonomy-query.class.js +1 -1
  25. package/dist/es6/query/taxonomy/taxonomy-query.class.js.map +1 -1
  26. package/dist/es6/query/type/single-type-query.class.js +1 -1
  27. package/dist/es6/query/type/single-type-query.class.js.map +1 -1
  28. package/dist/es6/query/used-in/used-in-query.class.js +1 -1
  29. package/dist/es6/query/used-in/used-in-query.class.js.map +1 -1
  30. package/dist/es6/sdk-info.generated.js +1 -1
  31. package/dist/esnext/query/element/element-query.class.js +1 -1
  32. package/dist/esnext/query/element/element-query.class.js.map +1 -1
  33. package/dist/esnext/query/item/single-item-query.class.js +1 -1
  34. package/dist/esnext/query/item/single-item-query.class.js.map +1 -1
  35. package/dist/esnext/query/taxonomy/taxonomy-query.class.js +1 -1
  36. package/dist/esnext/query/taxonomy/taxonomy-query.class.js.map +1 -1
  37. package/dist/esnext/query/type/single-type-query.class.js +1 -1
  38. package/dist/esnext/query/type/single-type-query.class.js.map +1 -1
  39. package/dist/esnext/query/used-in/used-in-query.class.js +1 -1
  40. package/dist/esnext/query/used-in/used-in-query.class.js.map +1 -1
  41. package/dist/esnext/sdk-info.generated.js +1 -1
  42. package/lib/query/element/element-query.class.ts +3 -1
  43. package/lib/query/item/single-item-query.class.ts +1 -1
  44. package/lib/query/taxonomy/taxonomy-query.class.ts +1 -1
  45. package/lib/query/type/single-type-query.class.ts +1 -1
  46. package/lib/query/used-in/used-in-query.class.ts +3 -1
  47. package/lib/sdk-info.generated.ts +1 -1
  48. 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 _b, _c;
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((_b = options === null || options === void 0 ? void 0 : options.headers) !== null && _b !== void 0 ? _b : [], false),
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: (_c = options === null || options === void 0 ? void 0 : options.cancelToken) === null || _c === void 0 ? void 0 : _c.token
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 _b, _c;
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((_b = options === null || options === void 0 ? void 0 : options.headers) !== null && _b !== void 0 ? _b : [], false),
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: (_c = options === null || options === void 0 ? void 0 : options.cancelToken) === null || _c === void 0 ? void 0 : _c.token
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 _b, _c;
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((_b = options === null || options === void 0 ? void 0 : options.headers) !== null && _b !== void 0 ? _b : [], false),
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: (_c = options === null || options === void 0 ? void 0 : options.cancelToken) === null || _c === void 0 ? void 0 : _c.token
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 _b, _c;
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((_b = options === null || options === void 0 ? void 0 : options.headers) !== null && _b !== void 0 ? _b : [], false),
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: (_c = options === null || options === void 0 ? void 0 : options.cancelToken) === null || _c === void 0 ? void 0 : _c.token
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 _b, _c;
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((_b = options === null || options === void 0 ? void 0 : options.headers) !== null && _b !== void 0 ? _b : [], false),
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: (_c = options === null || options === void 0 ? void 0 : options.cancelToken) === null || _c === void 0 ? void 0 : _c.token
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. `, error);
590
+ console.error(`Executing '${data.url}' failed. Request was retried '${data.retryAttempt}' times.`, sanitizedError);
583
591
  }
584
- throw error;
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) => {
@@ -3473,7 +3559,7 @@ class ElementQuery extends base_query_class_1.BaseQuery {
3473
3559
  return this.queryService.getElementAsync(this.getUrl(), (_a = this._queryConfig) !== null && _a !== void 0 ? _a : {});
3474
3560
  }
3475
3561
  getUrl() {
3476
- return super.resolveUrlInternal(`/types/${this.typeCodename}/elements/${this.elementCodename}`);
3562
+ return super.resolveUrlInternal(`/types/${encodeURIComponent(this.typeCodename)}/elements/${encodeURIComponent(this.elementCodename)}`);
3477
3563
  }
3478
3564
  map(json) {
3479
3565
  return this.queryService.mappingService.viewContentTypeElementResponse(json);
@@ -3729,7 +3815,7 @@ class SingleItemQuery extends base_query_class_1.BaseQuery {
3729
3815
  return this.queryService.getSingleItemAsync(this.getUrl(), (_a = this._queryConfig) !== null && _a !== void 0 ? _a : {});
3730
3816
  }
3731
3817
  getUrl() {
3732
- const action = '/items/' + this.codename;
3818
+ const action = '/items/' + encodeURIComponent(this.codename);
3733
3819
  // add default language is necessry
3734
3820
  this.processDefaultLanguageParameter();
3735
3821
  //process client level archived item exclusion
@@ -4164,7 +4250,7 @@ class TaxonomyQuery extends base_query_class_1.BaseQuery {
4164
4250
  return this.queryService.getTaxonomy(this.getUrl(), (_a = this._queryConfig) !== null && _a !== void 0 ? _a : {});
4165
4251
  }
4166
4252
  getUrl() {
4167
- const action = '/' + this.taxonomiesEndpoint + '/' + this.taxonomyCodename;
4253
+ const action = '/' + this.taxonomiesEndpoint + '/' + encodeURIComponent(this.taxonomyCodename);
4168
4254
  return super.resolveUrlInternal(action);
4169
4255
  }
4170
4256
  map(json) {
@@ -4275,7 +4361,7 @@ class SingleTypeQuery extends base_query_class_1.BaseQuery {
4275
4361
  return this.queryService.getSingleType(this.getUrl(), (_a = this._queryConfig) !== null && _a !== void 0 ? _a : {});
4276
4362
  }
4277
4363
  getUrl() {
4278
- const action = '/types/' + this.typeCodename;
4364
+ const action = '/types/' + encodeURIComponent(this.typeCodename);
4279
4365
  return super.resolveUrlInternal(action);
4280
4366
  }
4281
4367
  map(json) {
@@ -4353,7 +4439,7 @@ class UsedInQuery extends base_listing_query_class_1.BaseListingQuery {
4353
4439
  return this.queryService.getUsedIn(this.getUrl(), (_a = this._queryConfig) !== null && _a !== void 0 ? _a : {});
4354
4440
  }
4355
4441
  getUrl() {
4356
- const action = `/${this.setup.entity === 'asset' ? 'assets' : 'items'}/${this.setup.codename}/used-in`;
4442
+ const action = `/${this.setup.entity === 'asset' ? 'assets' : 'items'}/${encodeURIComponent(this.setup.codename)}/used-in`;
4357
4443
  // add default language is necessary
4358
4444
  this.processDefaultLanguageParameter();
4359
4445
  //process client level archived item exclusion
@@ -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.4',
4483
+ version: '16.4.6',
4398
4484
  name: '@kontent-ai/delivery-sdk'
4399
4485
  };
4400
4486