@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.
- package/dist/commercetools-mock.cjs.development.js +32 -3
- package/dist/commercetools-mock.cjs.development.js.map +1 -1
- package/dist/commercetools-mock.cjs.production.min.js +1 -1
- package/dist/commercetools-mock.cjs.production.min.js.map +1 -1
- package/dist/commercetools-mock.esm.js +32 -3
- package/dist/commercetools-mock.esm.js.map +1 -1
- package/dist/lib/masking.d.ts +1 -0
- package/package.json +1 -1
- package/src/lib/masking.ts +22 -0
- package/src/repositories/project.ts +7 -1
- package/src/services/product-projection.test.ts +11 -0
- package/src/storage.ts +8 -2
|
@@ -646,8 +646,12 @@ class InMemoryStorage extends AbstractStorage {
|
|
|
646
646
|
|
|
647
647
|
const resources = Array.from(store.values());
|
|
648
648
|
const resource = resources.find(e => e.key === key);
|
|
649
|
-
|
|
650
|
-
|
|
649
|
+
|
|
650
|
+
if (resource) {
|
|
651
|
+
return this.expand(projectKey, resource, params.expand);
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
return null;
|
|
651
655
|
}
|
|
652
656
|
|
|
653
657
|
delete(projectKey, typeId, id, params = {}) {
|
|
@@ -2968,6 +2972,28 @@ class ProductTypeService extends AbstractService {
|
|
|
2968
2972
|
|
|
2969
2973
|
}
|
|
2970
2974
|
|
|
2975
|
+
const maskSecretValue = (resource, path) => {
|
|
2976
|
+
const parts = path.split('.');
|
|
2977
|
+
const clone = JSON.parse(JSON.stringify(resource));
|
|
2978
|
+
let val = clone;
|
|
2979
|
+
const target = parts.pop();
|
|
2980
|
+
|
|
2981
|
+
for (let i = 0; i < parts.length; i++) {
|
|
2982
|
+
const part = parts[i];
|
|
2983
|
+
val = val[part];
|
|
2984
|
+
|
|
2985
|
+
if (val == undefined) {
|
|
2986
|
+
return resource;
|
|
2987
|
+
}
|
|
2988
|
+
}
|
|
2989
|
+
|
|
2990
|
+
if (val && target && val[target]) {
|
|
2991
|
+
val[target] = '****';
|
|
2992
|
+
}
|
|
2993
|
+
|
|
2994
|
+
return clone;
|
|
2995
|
+
};
|
|
2996
|
+
|
|
2971
2997
|
class ProjectRepository extends AbstractRepository {
|
|
2972
2998
|
constructor() {
|
|
2973
2999
|
super(...arguments);
|
|
@@ -3051,7 +3077,10 @@ class ProjectRepository extends AbstractRepository {
|
|
|
3051
3077
|
get(projectKey) {
|
|
3052
3078
|
const data = this._storage.getProject(projectKey);
|
|
3053
3079
|
|
|
3054
|
-
|
|
3080
|
+
const resource = this._storage.getProject(projectKey);
|
|
3081
|
+
|
|
3082
|
+
const masked = maskSecretValue(resource, 'externalOAuth.authorizationHeader');
|
|
3083
|
+
return masked;
|
|
3055
3084
|
}
|
|
3056
3085
|
|
|
3057
3086
|
save(projectKey, resource) {
|