@lidofinance/satanizer 0.48.0 → 0.50.0

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/index.cjs CHANGED
@@ -17,34 +17,34 @@ function $parcel$exportWildcard(dest, source) {
17
17
  function $parcel$export(e, n, v, s) {
18
18
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
19
19
  }
20
- var $6181fcac47f6fbd9$exports = {};
20
+ var $2576456b7ecaaf27$exports = {};
21
21
 
22
- $parcel$export($6181fcac47f6fbd9$exports, "satanizer", () => $6181fcac47f6fbd9$export$4aabe16cd431674e);
22
+ $parcel$export($2576456b7ecaaf27$exports, "satanizer", () => $2576456b7ecaaf27$export$4aabe16cd431674e);
23
23
  // Escape string to be safely used in RegExp constructor
24
24
  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping
25
- const $6181fcac47f6fbd9$var$escapeRegExp = (string)=>string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&") // $& means the whole matched string
25
+ const $2576456b7ecaaf27$var$escapeRegExp = (string)=>string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&") // $& means the whole matched string
26
26
  ;
27
- const $6181fcac47f6fbd9$var$patternToRegex = (pattern)=>{
27
+ const $2576456b7ecaaf27$var$patternToRegex = (pattern)=>{
28
28
  // Need to make regex global to work with matchAll
29
29
  if (pattern == null) // regex which never matches anything
30
30
  return /$a/g;
31
31
  if (pattern instanceof RegExp) return new RegExp(pattern.source, "g");
32
- return new RegExp($6181fcac47f6fbd9$var$escapeRegExp(pattern), "g");
32
+ return new RegExp($2576456b7ecaaf27$var$escapeRegExp(pattern), "g");
33
33
  };
34
- const $6181fcac47f6fbd9$var$matchIndexes = (regex, input)=>Array.from(input.matchAll(regex)).filter((item)=>item != null)// Need to force types, because TS doesn't know it is the match
34
+ const $2576456b7ecaaf27$var$matchIndexes = (regex, input)=>Array.from(input.matchAll(regex)).filter((item)=>item != null)// Need to force types, because TS doesn't know it is the match
35
35
  .map((match)=>[
36
36
  match.index,
37
37
  match.index + match[0].length
38
38
  ]);
39
- const $6181fcac47f6fbd9$var$getMask = (length)=>Array.from({
39
+ const $2576456b7ecaaf27$var$getMask = (length)=>Array.from({
40
40
  length: length
41
41
  }).fill("*").join("");
42
- const $6181fcac47f6fbd9$var$satanizerFactory = (patterns)=>(input)=>{
42
+ const $2576456b7ecaaf27$var$satanizerFactory = (patterns)=>(input)=>{
43
43
  const visited = new Set();
44
44
  // eslint-disable-next-line unicorn/consistent-function-scoping
45
- const satanizeString = (target)=>patterns.map($6181fcac47f6fbd9$var$patternToRegex)// Need to find all indexes first, otherwise we may miss overlaps
46
- .flatMap((regex)=>$6181fcac47f6fbd9$var$matchIndexes(regex, target))// Now it's safe to replace every match with the mask
47
- .reduce((acc, [start, end])=>acc.slice(0, start) + $6181fcac47f6fbd9$var$getMask(end - start) + acc.slice(end), target);
45
+ const satanizeString = (target)=>patterns.map($2576456b7ecaaf27$var$patternToRegex)// Need to find all indexes first, otherwise we may miss overlaps
46
+ .flatMap((regex)=>$2576456b7ecaaf27$var$matchIndexes(regex, target))// Now it's safe to replace every match with the mask
47
+ .reduce((acc, [start, end])=>acc.slice(0, start) + $2576456b7ecaaf27$var$getMask(end - start) + acc.slice(end), target);
48
48
  const satanizeArray = (target)=>{
49
49
  if (visited.has(target)) return "[Cycle]";
50
50
  visited.add(target);
@@ -67,34 +67,34 @@ const $6181fcac47f6fbd9$var$satanizerFactory = (patterns)=>(input)=>{
67
67
  };
68
68
  return satanize(input);
69
69
  };
70
- function $6181fcac47f6fbd9$export$4aabe16cd431674e(patterns, ...args) {
71
- if (args.length === 1) return $6181fcac47f6fbd9$var$satanizerFactory(patterns)(args[0]);
72
- return $6181fcac47f6fbd9$var$satanizerFactory(patterns);
70
+ function $2576456b7ecaaf27$export$4aabe16cd431674e(patterns, ...args) {
71
+ if (args.length === 1) return $2576456b7ecaaf27$var$satanizerFactory(patterns)(args[0]);
72
+ return $2576456b7ecaaf27$var$satanizerFactory(patterns);
73
73
  }
74
74
 
75
75
 
76
- var $2f2af15db2572749$exports = {};
76
+ var $7674c9b13e7faff9$exports = {};
77
77
 
78
- $parcel$export($2f2af15db2572749$exports, "blockchainAddress", () => $2f2af15db2572749$export$1e20809441cc69a);
79
- $parcel$export($2f2af15db2572749$exports, "ensAddress", () => $2f2af15db2572749$export$6a3b35e38f46684a);
80
- $parcel$export($2f2af15db2572749$exports, "ipAddress", () => $2f2af15db2572749$export$450e57019586b28f);
81
- $parcel$export($2f2af15db2572749$exports, "macAddress", () => $2f2af15db2572749$export$4aae620858fd13ea);
82
- $parcel$export($2f2af15db2572749$exports, "commonPatterns", () => $2f2af15db2572749$export$a83d9d00fb7126e2);
78
+ $parcel$export($7674c9b13e7faff9$exports, "blockchainAddress", () => $7674c9b13e7faff9$export$1e20809441cc69a);
79
+ $parcel$export($7674c9b13e7faff9$exports, "ensAddress", () => $7674c9b13e7faff9$export$6a3b35e38f46684a);
80
+ $parcel$export($7674c9b13e7faff9$exports, "ipAddress", () => $7674c9b13e7faff9$export$450e57019586b28f);
81
+ $parcel$export($7674c9b13e7faff9$exports, "macAddress", () => $7674c9b13e7faff9$export$4aae620858fd13ea);
82
+ $parcel$export($7674c9b13e7faff9$exports, "commonPatterns", () => $7674c9b13e7faff9$export$a83d9d00fb7126e2);
83
83
  // May caught ids, maybe needs to test this a bit more
84
- const $2f2af15db2572749$export$1e20809441cc69a = /(0x)?[a-zA-Z0-9]{40,}/;
85
- const $2f2af15db2572749$export$6a3b35e38f46684a = /[a-zA-Z0-9.]+\.eth/;
86
- const $2f2af15db2572749$export$450e57019586b28f = /\d+\.\d+\.\d+\.\d+/;
87
- const $2f2af15db2572749$export$4aae620858fd13ea = /([0-9a-fA-F]{2}[:-]){5}([0-9a-fA-F]{2})/;
88
- const $2f2af15db2572749$export$a83d9d00fb7126e2 = [
89
- $2f2af15db2572749$export$1e20809441cc69a,
90
- $2f2af15db2572749$export$6a3b35e38f46684a,
91
- $2f2af15db2572749$export$450e57019586b28f,
92
- $2f2af15db2572749$export$4aae620858fd13ea
84
+ const $7674c9b13e7faff9$export$1e20809441cc69a = /(0x)?[a-zA-Z0-9]{40,}/;
85
+ const $7674c9b13e7faff9$export$6a3b35e38f46684a = /[a-zA-Z0-9.]+\.eth/;
86
+ const $7674c9b13e7faff9$export$450e57019586b28f = /\d+\.\d+\.\d+\.\d+/;
87
+ const $7674c9b13e7faff9$export$4aae620858fd13ea = /([0-9a-fA-F]{2}[:-]){5}([0-9a-fA-F]{2})/;
88
+ const $7674c9b13e7faff9$export$a83d9d00fb7126e2 = [
89
+ $7674c9b13e7faff9$export$1e20809441cc69a,
90
+ $7674c9b13e7faff9$export$6a3b35e38f46684a,
91
+ $7674c9b13e7faff9$export$450e57019586b28f,
92
+ $7674c9b13e7faff9$export$4aae620858fd13ea
93
93
  ];
94
94
 
95
95
 
96
- $parcel$exportWildcard(module.exports, $6181fcac47f6fbd9$exports);
97
- $parcel$exportWildcard(module.exports, $2f2af15db2572749$exports);
96
+ $parcel$exportWildcard(module.exports, $2576456b7ecaaf27$exports);
97
+ $parcel$exportWildcard(module.exports, $7674c9b13e7faff9$exports);
98
98
 
99
99
 
100
100
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;ACAA,wDAAwD;AACxD,6FAA6F;AAC7F,MAAM,qCAAe,CAAC,SAA2B,OAAO,QAAQ,uBAAuB,QAAQ,oCAAoC;;AAInI,MAAM,uCAAiB,CAAC;IACtB,kDAAkD;IAClD,IAAI,WAAW,MACb,qCAAqC;IACrC,OAAO;IAET,IAAI,mBAAmB,QACrB,OAAO,IAAI,OAAO,QAAQ,QAAQ;IAEpC,OAAO,IAAI,OAAO,mCAAa,UAAU;AAC3C;AAEA,MAAM,qCAAe,CAAC,OAAe,QACnC,MAAM,KAAK,MAAM,SAAS,QACvB,OAAO,CAAC,OAAS,QAAQ,KAC1B,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uCAAiB;AAC1B;;;;;;;;;;ACpFA,sDAAsD;AAC/C,MAAM,2CAAoB;AAC1B,MAAM,4CAAa;AAEnB,MAAM,4CAAY;AAClB,MAAM,4CAAa;AAEnB,MAAM,4CAAiB;IAAC;IAAmB;IAAY;IAAW;CAAW;;","sources":["packages/core/satanazier/src/index.ts","packages/core/satanazier/src/satanizer.ts","packages/core/satanazier/src/common-patterns.ts"],"sourcesContent":["export * from './satanizer'\nexport * from './common-patterns'\n","// Escape string to be safely used in RegExp constructor\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping\nconst escapeRegExp = (string: string): string => string.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&') // $& means the whole matched string\n\nexport type Pattern = RegExp | string | null | undefined\n\nconst patternToRegex = (pattern: Pattern): RegExp => {\n // Need to make regex global to work with matchAll\n if (pattern == null) {\n // regex which never matches anything\n return /$a/g\n }\n if (pattern instanceof RegExp) {\n return new RegExp(pattern.source, 'g')\n }\n return new RegExp(escapeRegExp(pattern), 'g')\n}\n\nconst matchIndexes = (regex: RegExp, input: string) =>\n Array.from(input.matchAll(regex))\n .filter((item) => item != null)\n // Need to force types, because TS doesn't know it is the match\n .map((match) => [match.index as number, (match.index as number) + match[0].length])\n\nconst getMask = (length: number) => Array.from({ length }).fill('*').join('')\n\nconst satanizerFactory = (patterns: Pattern[]) => (input: unknown) => {\n const visited = new Set<unknown>()\n\n // eslint-disable-next-line unicorn/consistent-function-scoping\n const satanizeString = (target: string) =>\n patterns\n .map(patternToRegex)\n // Need to find all indexes first, otherwise we may miss overlaps\n .flatMap((regex) => matchIndexes(regex, target))\n // Now it's safe to replace every match with the mask\n .reduce((acc, [start, end]) => acc.slice(0, start) + getMask(end - start) + acc.slice(end), target)\n\n const satanizeArray = <T>(target: T[]): T[] | string => {\n if (visited.has(target)) {\n return '[Cycle]'\n }\n visited.add(target)\n return target.map(satanize)\n }\n\n const satanizeObject = <T extends object>(target: T): T | string => {\n if (visited.has(target)) {\n return '[Cycle]'\n }\n visited.add(target)\n return Object.getOwnPropertyNames(target).reduce(\n (acc, key) => ({ ...acc, [satanize(key)]: satanize(target[key as keyof T]) }),\n {} as T,\n )\n }\n\n const satanize = <T>(target: T): T => {\n if (typeof target === 'string') {\n return satanizeString(target) as T\n }\n if (typeof target === 'number' || typeof target === 'boolean' || target == null) {\n return target\n }\n if (Array.isArray(target)) {\n return satanizeArray(target) as T\n }\n if (typeof target === 'object') {\n return satanizeObject(target) as T\n }\n return target\n }\n\n return satanize(input)\n}\n\n// Overload type definition to accept both types of call.\nexport function satanizer(pattern: Pattern[]): <T>(input: T) => T // this is a bit incorrect since we don't perserve methods\nexport function satanizer<T>(pattern: Pattern[], input: T): T\nexport function satanizer<T>(patterns: Pattern[], ...args: [] | [T]) {\n if (args.length === 1) {\n return satanizerFactory(patterns)(args[0])\n }\n return satanizerFactory(patterns)\n}\n","// May caught ids, maybe needs to test this a bit more\nexport const blockchainAddress = /(0x)?[a-zA-Z0-9]{40,}/\nexport const ensAddress = /[a-zA-Z0-9.]+\\.eth/\n// It's not really valid, but it's still ok for secrets\nexport const ipAddress = /\\d+\\.\\d+\\.\\d+\\.\\d+/\nexport const macAddress = /([0-9a-fA-F]{2}[:-]){5}([0-9a-fA-F]{2})/\n\nexport const commonPatterns = [blockchainAddress, ensAddress, ipAddress, macAddress]\n"],"names":[],"version":3,"file":"index.cjs.map","sourceRoot":"../../../../"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;ACAA,wDAAwD;AACxD,6FAA6F;AAC7F,MAAM,qCAAe,CAAC,SAA2B,OAAO,QAAQ,uBAAuB,QAAQ,oCAAoC;;AAInI,MAAM,uCAAiB,CAAC;IACtB,kDAAkD;IAClD,IAAI,WAAW,MACb,qCAAqC;IACrC,OAAO;IAET,IAAI,mBAAmB,QACrB,OAAO,IAAI,OAAO,QAAQ,QAAQ;IAEpC,OAAO,IAAI,OAAO,mCAAa,UAAU;AAC3C;AAEA,MAA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G,IAAc;IACjE,IAAI,KAAK,WAAW,GAClB,OAAO,uCAAiB,UAAU,IAAI,CAAC,EAAE;IAE3C,OAAO,uCAAiB;AAC1B;;;;;;;;;;ACpFA,sDAAsD;AAC/C,MAAM,2CAAoB;AAC1B,MAAM,4CAAa;AAEnB,MAAM,4CAAY;AAClB,MAAM,4CAAa;AAEnB,MAAM,4CAAiB;IAAC;IAAmB;IAAY;IAAW;CAAW;;","sources":["packages/core/satanizer/src/index.ts","packages/core/satanizer/src/satanizer.ts","packages/core/satanizer/src/common-patterns.ts"],"sourcesContent":["export * from './satanizer'\nexport * from './common-patterns'\n","// Escape string to be safely used in RegExp constructor\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping\nconst escapeRegExp = (string: string): string => string.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&') // $& means the whole matched string\n\nexport type Pattern = RegExp | string | null | undefined\n\nconst patternToRegex = (pattern: Pattern): RegExp => {\n // Need to make regex global to work with matchAll\n if (pattern == null) {\n // regex which never matches anything\n return /$a/g\n }\n if (pattern instanceof RegExp) {\n return new RegExp(pattern.source, 'g')\n }\n return new RegExp(escapeRegExp(pattern), 'g')\n}\n\nconst matchIndexes = (regex: RegExp, input: string) =>\n Array.from(input.matchAll(regex))\n .filter((item) => item != null)\n // Need to force types, because TS doesn't know it is the match\n .map((match) => [match.index as number, (match.index as number) + match[0].length])\n\nconst getMask = (length: number) => Array.from({ length }).fill('*').join('')\n\nconst satanizerFactory = (patterns: Pattern[]) => (input: unknown) => {\n const visited = new Set<unknown>()\n\n // eslint-disable-next-line unicorn/consistent-function-scoping\n const satanizeString = (target: string) =>\n patterns\n .map(patternToRegex)\n // Need to find all indexes first, otherwise we may miss overlaps\n .flatMap((regex) => matchIndexes(regex, target))\n // Now it's safe to replace every match with the mask\n .reduce((acc, [start, end]) => acc.slice(0, start) + getMask(end - start) + acc.slice(end), target)\n\n const satanizeArray = <T>(target: T[]): T[] | string => {\n if (visited.has(target)) {\n return '[Cycle]'\n }\n visited.add(target)\n return target.map(satanize)\n }\n\n const satanizeObject = <T extends object>(target: T): T | string => {\n if (visited.has(target)) {\n return '[Cycle]'\n }\n visited.add(target)\n return Object.getOwnPropertyNames(target).reduce(\n (acc, key) => ({ ...acc, [satanize(key)]: satanize(target[key as keyof T]) }),\n {} as T,\n )\n }\n\n const satanize = <T>(target: T): T => {\n if (typeof target === 'string') {\n return satanizeString(target) as T\n }\n if (typeof target === 'number' || typeof target === 'boolean' || target == null) {\n return target\n }\n if (Array.isArray(target)) {\n return satanizeArray(target) as T\n }\n if (typeof target === 'object') {\n return satanizeObject(target) as T\n }\n return target\n }\n\n return satanize(input)\n}\n\n// Overload type definition to accept both types of call.\nexport function satanizer(pattern: Pattern[]): <T>(input: T) => T // this is a bit incorrect since we don't perserve methods\nexport function satanizer<T>(pattern: Pattern[], input: T): T\nexport function satanizer<T>(patterns: Pattern[], ...args: [] | [T]) {\n if (args.length === 1) {\n return satanizerFactory(patterns)(args[0])\n }\n return satanizerFactory(patterns)\n}\n","// May caught ids, maybe needs to test this a bit more\nexport const blockchainAddress = /(0x)?[a-zA-Z0-9]{40,}/\nexport const ensAddress = /[a-zA-Z0-9.]+\\.eth/\n// It's not really valid, but it's still ok for secrets\nexport const ipAddress = /\\d+\\.\\d+\\.\\d+\\.\\d+/\nexport const macAddress = /([0-9a-fA-F]{2}[:-]){5}([0-9a-fA-F]{2})/\n\nexport const commonPatterns = [blockchainAddress, ensAddress, ipAddress, macAddress]\n"],"names":[],"version":3,"file":"index.cjs.map","sourceRoot":"../../../../"}
@@ -1 +1 @@
1
- {"mappings":"AAIA,sBAAsB,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;AAyExD,0BAA0B,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,CAAC,CAAA;AACjE,0BAA0B,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAAA;AC7E7D,OAAO,MAAM,yBAA2C,CAAA;AACxD,OAAO,MAAM,kBAAiC,CAAA;AAE9C,OAAO,MAAM,iBAAgC,CAAA;AAC7C,OAAO,MAAM,kBAAsD,CAAA;AAEnE,OAAO,MAAM,wBAAuE,CAAA","sources":["packages/core/satanazier/src/src/satanizer.ts","packages/core/satanazier/src/src/common-patterns.ts","packages/core/satanazier/src/src/index.ts","packages/core/satanazier/src/index.ts"],"sourcesContent":[null,null,null,"export * from './satanizer'\nexport * from './common-patterns'\n"],"names":[],"version":3,"file":"index.d.ts.map","sourceRoot":"../../../../"}
1
+ {"mappings":"AAIA,sBAAsB,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;AAyExD,0BAA0B,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,CAAC,CAAA;AACjE,0BAA0B,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAAA;AC7E7D,OAAO,MAAM,yBAA2C,CAAA;AACxD,OAAO,MAAM,kBAAiC,CAAA;AAE9C,OAAO,MAAM,iBAAgC,CAAA;AAC7C,OAAO,MAAM,kBAAsD,CAAA;AAEnE,OAAO,MAAM,wBAAuE,CAAA","sources":["packages/core/satanizer/src/src/satanizer.ts","packages/core/satanizer/src/src/common-patterns.ts","packages/core/satanizer/src/src/index.ts","packages/core/satanizer/src/index.ts"],"sourcesContent":[null,null,null,"export * from './satanizer'\nexport * from './common-patterns'\n"],"names":[],"version":3,"file":"index.d.ts.map","sourceRoot":"../../../../"}
package/dist/index.mjs CHANGED
@@ -1,34 +1,34 @@
1
1
  function $parcel$export(e, n, v, s) {
2
2
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
3
3
  }
4
- var $634bfa66b85378ba$exports = {};
4
+ var $ddf4fa459eb9e789$exports = {};
5
5
 
6
- $parcel$export($634bfa66b85378ba$exports, "satanizer", () => $634bfa66b85378ba$export$4aabe16cd431674e);
6
+ $parcel$export($ddf4fa459eb9e789$exports, "satanizer", () => $ddf4fa459eb9e789$export$4aabe16cd431674e);
7
7
  // Escape string to be safely used in RegExp constructor
8
8
  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping
9
- const $634bfa66b85378ba$var$escapeRegExp = (string)=>string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&") // $& means the whole matched string
9
+ const $ddf4fa459eb9e789$var$escapeRegExp = (string)=>string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&") // $& means the whole matched string
10
10
  ;
11
- const $634bfa66b85378ba$var$patternToRegex = (pattern)=>{
11
+ const $ddf4fa459eb9e789$var$patternToRegex = (pattern)=>{
12
12
  // Need to make regex global to work with matchAll
13
13
  if (pattern == null) // regex which never matches anything
14
14
  return /$a/g;
15
15
  if (pattern instanceof RegExp) return new RegExp(pattern.source, "g");
16
- return new RegExp($634bfa66b85378ba$var$escapeRegExp(pattern), "g");
16
+ return new RegExp($ddf4fa459eb9e789$var$escapeRegExp(pattern), "g");
17
17
  };
18
- const $634bfa66b85378ba$var$matchIndexes = (regex, input)=>Array.from(input.matchAll(regex)).filter((item)=>item != null)// Need to force types, because TS doesn't know it is the match
18
+ const $ddf4fa459eb9e789$var$matchIndexes = (regex, input)=>Array.from(input.matchAll(regex)).filter((item)=>item != null)// Need to force types, because TS doesn't know it is the match
19
19
  .map((match)=>[
20
20
  match.index,
21
21
  match.index + match[0].length
22
22
  ]);
23
- const $634bfa66b85378ba$var$getMask = (length)=>Array.from({
23
+ const $ddf4fa459eb9e789$var$getMask = (length)=>Array.from({
24
24
  length: length
25
25
  }).fill("*").join("");
26
- const $634bfa66b85378ba$var$satanizerFactory = (patterns)=>(input)=>{
26
+ const $ddf4fa459eb9e789$var$satanizerFactory = (patterns)=>(input)=>{
27
27
  const visited = new Set();
28
28
  // eslint-disable-next-line unicorn/consistent-function-scoping
29
- const satanizeString = (target)=>patterns.map($634bfa66b85378ba$var$patternToRegex)// Need to find all indexes first, otherwise we may miss overlaps
30
- .flatMap((regex)=>$634bfa66b85378ba$var$matchIndexes(regex, target))// Now it's safe to replace every match with the mask
31
- .reduce((acc, [start, end])=>acc.slice(0, start) + $634bfa66b85378ba$var$getMask(end - start) + acc.slice(end), target);
29
+ const satanizeString = (target)=>patterns.map($ddf4fa459eb9e789$var$patternToRegex)// Need to find all indexes first, otherwise we may miss overlaps
30
+ .flatMap((regex)=>$ddf4fa459eb9e789$var$matchIndexes(regex, target))// Now it's safe to replace every match with the mask
31
+ .reduce((acc, [start, end])=>acc.slice(0, start) + $ddf4fa459eb9e789$var$getMask(end - start) + acc.slice(end), target);
32
32
  const satanizeArray = (target)=>{
33
33
  if (visited.has(target)) return "[Cycle]";
34
34
  visited.add(target);
@@ -51,33 +51,33 @@ const $634bfa66b85378ba$var$satanizerFactory = (patterns)=>(input)=>{
51
51
  };
52
52
  return satanize(input);
53
53
  };
54
- function $634bfa66b85378ba$export$4aabe16cd431674e(patterns, ...args) {
55
- if (args.length === 1) return $634bfa66b85378ba$var$satanizerFactory(patterns)(args[0]);
56
- return $634bfa66b85378ba$var$satanizerFactory(patterns);
54
+ function $ddf4fa459eb9e789$export$4aabe16cd431674e(patterns, ...args) {
55
+ if (args.length === 1) return $ddf4fa459eb9e789$var$satanizerFactory(patterns)(args[0]);
56
+ return $ddf4fa459eb9e789$var$satanizerFactory(patterns);
57
57
  }
58
58
 
59
59
 
60
- var $a4f22c43dff7d58a$exports = {};
60
+ var $b5b2cbf03a530a05$exports = {};
61
61
 
62
- $parcel$export($a4f22c43dff7d58a$exports, "blockchainAddress", () => $a4f22c43dff7d58a$export$1e20809441cc69a);
63
- $parcel$export($a4f22c43dff7d58a$exports, "ensAddress", () => $a4f22c43dff7d58a$export$6a3b35e38f46684a);
64
- $parcel$export($a4f22c43dff7d58a$exports, "ipAddress", () => $a4f22c43dff7d58a$export$450e57019586b28f);
65
- $parcel$export($a4f22c43dff7d58a$exports, "macAddress", () => $a4f22c43dff7d58a$export$4aae620858fd13ea);
66
- $parcel$export($a4f22c43dff7d58a$exports, "commonPatterns", () => $a4f22c43dff7d58a$export$a83d9d00fb7126e2);
62
+ $parcel$export($b5b2cbf03a530a05$exports, "blockchainAddress", () => $b5b2cbf03a530a05$export$1e20809441cc69a);
63
+ $parcel$export($b5b2cbf03a530a05$exports, "ensAddress", () => $b5b2cbf03a530a05$export$6a3b35e38f46684a);
64
+ $parcel$export($b5b2cbf03a530a05$exports, "ipAddress", () => $b5b2cbf03a530a05$export$450e57019586b28f);
65
+ $parcel$export($b5b2cbf03a530a05$exports, "macAddress", () => $b5b2cbf03a530a05$export$4aae620858fd13ea);
66
+ $parcel$export($b5b2cbf03a530a05$exports, "commonPatterns", () => $b5b2cbf03a530a05$export$a83d9d00fb7126e2);
67
67
  // May caught ids, maybe needs to test this a bit more
68
- const $a4f22c43dff7d58a$export$1e20809441cc69a = /(0x)?[a-zA-Z0-9]{40,}/;
69
- const $a4f22c43dff7d58a$export$6a3b35e38f46684a = /[a-zA-Z0-9.]+\.eth/;
70
- const $a4f22c43dff7d58a$export$450e57019586b28f = /\d+\.\d+\.\d+\.\d+/;
71
- const $a4f22c43dff7d58a$export$4aae620858fd13ea = /([0-9a-fA-F]{2}[:-]){5}([0-9a-fA-F]{2})/;
72
- const $a4f22c43dff7d58a$export$a83d9d00fb7126e2 = [
73
- $a4f22c43dff7d58a$export$1e20809441cc69a,
74
- $a4f22c43dff7d58a$export$6a3b35e38f46684a,
75
- $a4f22c43dff7d58a$export$450e57019586b28f,
76
- $a4f22c43dff7d58a$export$4aae620858fd13ea
68
+ const $b5b2cbf03a530a05$export$1e20809441cc69a = /(0x)?[a-zA-Z0-9]{40,}/;
69
+ const $b5b2cbf03a530a05$export$6a3b35e38f46684a = /[a-zA-Z0-9.]+\.eth/;
70
+ const $b5b2cbf03a530a05$export$450e57019586b28f = /\d+\.\d+\.\d+\.\d+/;
71
+ const $b5b2cbf03a530a05$export$4aae620858fd13ea = /([0-9a-fA-F]{2}[:-]){5}([0-9a-fA-F]{2})/;
72
+ const $b5b2cbf03a530a05$export$a83d9d00fb7126e2 = [
73
+ $b5b2cbf03a530a05$export$1e20809441cc69a,
74
+ $b5b2cbf03a530a05$export$6a3b35e38f46684a,
75
+ $b5b2cbf03a530a05$export$450e57019586b28f,
76
+ $b5b2cbf03a530a05$export$4aae620858fd13ea
77
77
  ];
78
78
 
79
79
 
80
80
 
81
81
 
82
- export {$634bfa66b85378ba$export$4aabe16cd431674e as satanizer, $a4f22c43dff7d58a$export$1e20809441cc69a as blockchainAddress, $a4f22c43dff7d58a$export$6a3b35e38f46684a as ensAddress, $a4f22c43dff7d58a$export$450e57019586b28f as ipAddress, $a4f22c43dff7d58a$export$4aae620858fd13ea as macAddress, $a4f22c43dff7d58a$export$a83d9d00fb7126e2 as commonPatterns};
82
+ export {$ddf4fa459eb9e789$export$4aabe16cd431674e as satanizer, $b5b2cbf03a530a05$export$1e20809441cc69a as blockchainAddress, $b5b2cbf03a530a05$export$6a3b35e38f46684a as ensAddress, $b5b2cbf03a530a05$export$450e57019586b28f as ipAddress, $b5b2cbf03a530a05$export$4aae620858fd13ea as macAddress, $b5b2cbf03a530a05$export$a83d9d00fb7126e2 as commonPatterns};
83
83
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"mappings":";;;;;;ACAA,wDAAwD;AACxD,6FAA6F;AAC7F,MAAM,qCAAe,CAAC,SAA2B,OAAO,QAAQ,uBAAuB,QAAQ,oCAAoC;;AAInI,MAAM,uCAAiB,CAAC;IACtB,kDAAkD;IAClD,IAAI,WAAW,MACb,qCAAqC;IACrC,OAAO;IAET,IAAI,mBAAmB,QACrB,OAAO,IAAI,OAAO,QAAQ,QAAQ;IAEpC,OAAO,IAAI,OAAO,mCAAa,UAAU;AAC3C;AAEA,MAAM,qCAAe,CAAC,OAAe,QACnC,MAAM,KAAK,MAAM,SAA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iB,UAAU,IAAI,CAAC,EAAE;IAE3C,OAAO,uCAAiB;AAC1B;;;;;;;;;;ACpFA,sDAAsD;AAC/C,MAAM,2CAAoB;AAC1B,MAAM,4CAAa;AAEnB,MAAM,4CAAY;AAClB,MAAM,4CAAa;AAEnB,MAAM,4CAAiB;IAAC;IAAmB;IAAY;IAAW;CAAW;;","sources":["packages/core/satanazier/src/index.ts","packages/core/satanazier/src/satanizer.ts","packages/core/satanazier/src/common-patterns.ts"],"sourcesContent":["export * from './satanizer'\nexport * from './common-patterns'\n","// Escape string to be safely used in RegExp constructor\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping\nconst escapeRegExp = (string: string): string => string.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&') // $& means the whole matched string\n\nexport type Pattern = RegExp | string | null | undefined\n\nconst patternToRegex = (pattern: Pattern): RegExp => {\n // Need to make regex global to work with matchAll\n if (pattern == null) {\n // regex which never matches anything\n return /$a/g\n }\n if (pattern instanceof RegExp) {\n return new RegExp(pattern.source, 'g')\n }\n return new RegExp(escapeRegExp(pattern), 'g')\n}\n\nconst matchIndexes = (regex: RegExp, input: string) =>\n Array.from(input.matchAll(regex))\n .filter((item) => item != null)\n // Need to force types, because TS doesn't know it is the match\n .map((match) => [match.index as number, (match.index as number) + match[0].length])\n\nconst getMask = (length: number) => Array.from({ length }).fill('*').join('')\n\nconst satanizerFactory = (patterns: Pattern[]) => (input: unknown) => {\n const visited = new Set<unknown>()\n\n // eslint-disable-next-line unicorn/consistent-function-scoping\n const satanizeString = (target: string) =>\n patterns\n .map(patternToRegex)\n // Need to find all indexes first, otherwise we may miss overlaps\n .flatMap((regex) => matchIndexes(regex, target))\n // Now it's safe to replace every match with the mask\n .reduce((acc, [start, end]) => acc.slice(0, start) + getMask(end - start) + acc.slice(end), target)\n\n const satanizeArray = <T>(target: T[]): T[] | string => {\n if (visited.has(target)) {\n return '[Cycle]'\n }\n visited.add(target)\n return target.map(satanize)\n }\n\n const satanizeObject = <T extends object>(target: T): T | string => {\n if (visited.has(target)) {\n return '[Cycle]'\n }\n visited.add(target)\n return Object.getOwnPropertyNames(target).reduce(\n (acc, key) => ({ ...acc, [satanize(key)]: satanize(target[key as keyof T]) }),\n {} as T,\n )\n }\n\n const satanize = <T>(target: T): T => {\n if (typeof target === 'string') {\n return satanizeString(target) as T\n }\n if (typeof target === 'number' || typeof target === 'boolean' || target == null) {\n return target\n }\n if (Array.isArray(target)) {\n return satanizeArray(target) as T\n }\n if (typeof target === 'object') {\n return satanizeObject(target) as T\n }\n return target\n }\n\n return satanize(input)\n}\n\n// Overload type definition to accept both types of call.\nexport function satanizer(pattern: Pattern[]): <T>(input: T) => T // this is a bit incorrect since we don't perserve methods\nexport function satanizer<T>(pattern: Pattern[], input: T): T\nexport function satanizer<T>(patterns: Pattern[], ...args: [] | [T]) {\n if (args.length === 1) {\n return satanizerFactory(patterns)(args[0])\n }\n return satanizerFactory(patterns)\n}\n","// May caught ids, maybe needs to test this a bit more\nexport const blockchainAddress = /(0x)?[a-zA-Z0-9]{40,}/\nexport const ensAddress = /[a-zA-Z0-9.]+\\.eth/\n// It's not really valid, but it's still ok for secrets\nexport const ipAddress = /\\d+\\.\\d+\\.\\d+\\.\\d+/\nexport const macAddress = /([0-9a-fA-F]{2}[:-]){5}([0-9a-fA-F]{2})/\n\nexport const commonPatterns = [blockchainAddress, ensAddress, ipAddress, macAddress]\n"],"names":[],"version":3,"file":"index.mjs.map","sourceRoot":"../../../../"}
1
+ {"mappings":";;;;;;ACAA,wDAAwD;AACxD,6FAA6F;AAC7F,MAAM,qCAAe,CAAC,SAA2B,OAAO,QAAQ,uBAAuB,QAAQ,oCAAoC;;AAInI,MAAM,uCAAiB,CAAC;IACtB,kDAAkD;IAClD,IAAI,WAAW,MACb,qCAAqC;IACrC,OAAO;IAET,IAAI,mBAAmB,QACrB,OAAO,IAAI,OAAO,QAAQ,QAAQ;IAEpC,OAAO,IAAI,OAAO,mCAAa,U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AAa,QAAmB,EAAE,GAAG,IAAc;IACjE,IAAI,KAAK,WAAW,GAClB,OAAO,uCAAiB,UAAU,IAAI,CAAC,EAAE;IAE3C,OAAO,uCAAiB;AAC1B;;;;;;;;;;ACpFA,sDAAsD;AAC/C,MAAM,2CAAoB;AAC1B,MAAM,4CAAa;AAEnB,MAAM,4CAAY;AAClB,MAAM,4CAAa;AAEnB,MAAM,4CAAiB;IAAC;IAAmB;IAAY;IAAW;CAAW;;","sources":["packages/core/satanizer/src/index.ts","packages/core/satanizer/src/satanizer.ts","packages/core/satanizer/src/common-patterns.ts"],"sourcesContent":["export * from './satanizer'\nexport * from './common-patterns'\n","// Escape string to be safely used in RegExp constructor\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping\nconst escapeRegExp = (string: string): string => string.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&') // $& means the whole matched string\n\nexport type Pattern = RegExp | string | null | undefined\n\nconst patternToRegex = (pattern: Pattern): RegExp => {\n // Need to make regex global to work with matchAll\n if (pattern == null) {\n // regex which never matches anything\n return /$a/g\n }\n if (pattern instanceof RegExp) {\n return new RegExp(pattern.source, 'g')\n }\n return new RegExp(escapeRegExp(pattern), 'g')\n}\n\nconst matchIndexes = (regex: RegExp, input: string) =>\n Array.from(input.matchAll(regex))\n .filter((item) => item != null)\n // Need to force types, because TS doesn't know it is the match\n .map((match) => [match.index as number, (match.index as number) + match[0].length])\n\nconst getMask = (length: number) => Array.from({ length }).fill('*').join('')\n\nconst satanizerFactory = (patterns: Pattern[]) => (input: unknown) => {\n const visited = new Set<unknown>()\n\n // eslint-disable-next-line unicorn/consistent-function-scoping\n const satanizeString = (target: string) =>\n patterns\n .map(patternToRegex)\n // Need to find all indexes first, otherwise we may miss overlaps\n .flatMap((regex) => matchIndexes(regex, target))\n // Now it's safe to replace every match with the mask\n .reduce((acc, [start, end]) => acc.slice(0, start) + getMask(end - start) + acc.slice(end), target)\n\n const satanizeArray = <T>(target: T[]): T[] | string => {\n if (visited.has(target)) {\n return '[Cycle]'\n }\n visited.add(target)\n return target.map(satanize)\n }\n\n const satanizeObject = <T extends object>(target: T): T | string => {\n if (visited.has(target)) {\n return '[Cycle]'\n }\n visited.add(target)\n return Object.getOwnPropertyNames(target).reduce(\n (acc, key) => ({ ...acc, [satanize(key)]: satanize(target[key as keyof T]) }),\n {} as T,\n )\n }\n\n const satanize = <T>(target: T): T => {\n if (typeof target === 'string') {\n return satanizeString(target) as T\n }\n if (typeof target === 'number' || typeof target === 'boolean' || target == null) {\n return target\n }\n if (Array.isArray(target)) {\n return satanizeArray(target) as T\n }\n if (typeof target === 'object') {\n return satanizeObject(target) as T\n }\n return target\n }\n\n return satanize(input)\n}\n\n// Overload type definition to accept both types of call.\nexport function satanizer(pattern: Pattern[]): <T>(input: T) => T // this is a bit incorrect since we don't perserve methods\nexport function satanizer<T>(pattern: Pattern[], input: T): T\nexport function satanizer<T>(patterns: Pattern[], ...args: [] | [T]) {\n if (args.length === 1) {\n return satanizerFactory(patterns)(args[0])\n }\n return satanizerFactory(patterns)\n}\n","// May caught ids, maybe needs to test this a bit more\nexport const blockchainAddress = /(0x)?[a-zA-Z0-9]{40,}/\nexport const ensAddress = /[a-zA-Z0-9.]+\\.eth/\n// It's not really valid, but it's still ok for secrets\nexport const ipAddress = /\\d+\\.\\d+\\.\\d+\\.\\d+/\nexport const macAddress = /([0-9a-fA-F]{2}[:-]){5}([0-9a-fA-F]{2})/\n\nexport const commonPatterns = [blockchainAddress, ensAddress, ipAddress, macAddress]\n"],"names":[],"version":3,"file":"index.mjs.map","sourceRoot":"../../../../"}
package/package.json CHANGED
@@ -2,12 +2,12 @@
2
2
  "name": "@lidofinance/satanizer",
3
3
  "description": "Tool, which mask secrets",
4
4
  "repository": "https://github.com/lidofinance/warehouse.git",
5
- "homepage": "https://github.com/lidofinance/warehouse/tree/main/packages/core/satanazier",
5
+ "homepage": "https://github.com/lidofinance/warehouse/tree/main/packages/core/satanizer",
6
6
  "bugs": {
7
7
  "url": "https://github.com/lidofinance/warehouse/issues"
8
8
  },
9
9
  "license": "MIT",
10
- "version": "0.48.0",
10
+ "version": "0.50.0",
11
11
  "files": [
12
12
  "dist"
13
13
  ],
@@ -32,7 +32,7 @@
32
32
  "test": "jest"
33
33
  },
34
34
  "devDependencies": {
35
- "@lidofinance/config-prettier": "~0.48.0",
35
+ "@lidofinance/config-prettier": "~0.50.0",
36
36
  "@types/jest": "^29.2.4",
37
37
  "@types/node": "^20.0.0",
38
38
  "jest": "^29.3.1",