@labdigital/commercetools-mock 0.5.14 → 0.5.15

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.
@@ -653,8 +653,12 @@ class InMemoryStorage extends AbstractStorage {
653
653
 
654
654
  const resources = Array.from(store.values());
655
655
  const resource = resources.find(e => e.key === key);
656
- if (params.expand) return this.expand(projectKey, resource, params.expand);
657
- return resource;
656
+
657
+ if (resource) {
658
+ return this.expand(projectKey, resource, params.expand);
659
+ }
660
+
661
+ return null;
658
662
  }
659
663
 
660
664
  delete(projectKey, typeId, id, params = {}) {
@@ -2975,6 +2979,28 @@ class ProductTypeService extends AbstractService {
2975
2979
 
2976
2980
  }
2977
2981
 
2982
+ const maskSecretValue = (resource, path) => {
2983
+ const parts = path.split('.');
2984
+ const clone = JSON.parse(JSON.stringify(resource));
2985
+ let val = clone;
2986
+ const target = parts.pop();
2987
+
2988
+ for (let i = 0; i < parts.length; i++) {
2989
+ const part = parts[i];
2990
+ val = val[part];
2991
+
2992
+ if (val == undefined) {
2993
+ return resource;
2994
+ }
2995
+ }
2996
+
2997
+ if (val && target && val[target]) {
2998
+ val[target] = '****';
2999
+ }
3000
+
3001
+ return clone;
3002
+ };
3003
+
2978
3004
  class ProjectRepository extends AbstractRepository {
2979
3005
  constructor() {
2980
3006
  super(...arguments);
@@ -3058,7 +3084,10 @@ class ProjectRepository extends AbstractRepository {
3058
3084
  get(projectKey) {
3059
3085
  const data = this._storage.getProject(projectKey);
3060
3086
 
3061
- return this._storage.getProject(projectKey);
3087
+ const resource = this._storage.getProject(projectKey);
3088
+
3089
+ const masked = maskSecretValue(resource, 'externalOAuth.authorizationHeader');
3090
+ return masked;
3062
3091
  }
3063
3092
 
3064
3093
  save(projectKey, resource) {