diginext-utils 3.0.2 → 3.0.4

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.
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.detectPrivateKey = void 0;
7
- const fs_1 = __importDefault(require("fs"));
8
7
  const getAllFiles_1 = __importDefault(require("./getAllFiles"));
8
+ const detectPrivateKeyByFilePath_1 = __importDefault(require("./detectPrivateKeyByFilePath"));
9
9
  function detectPrivateKey(dirPath) {
10
10
  //
11
11
  const list = (0, getAllFiles_1.default)(dirPath);
@@ -13,18 +13,11 @@ function detectPrivateKey(dirPath) {
13
13
  const _list = [];
14
14
  for (let i = 0; i < list.length; i++) {
15
15
  const _path = list[i];
16
- // Read the contents of the file
17
- const fileContents = fs_1.default.readFileSync(_path);
18
- switch (true) {
19
- case fileContents.includes("-----BEGIN "):
20
- case fileContents.includes("SECRET=") && !fileContents.includes("SECRET=\n") && !fileContents.includes("SECRET=*"):
21
- {
22
- _list.push(_path);
23
- result = false;
24
- }
25
- break;
26
- default:
27
- break;
16
+ if ((0, detectPrivateKeyByFilePath_1.default)(_path)) {
17
+ }
18
+ else {
19
+ _list.push(_path);
20
+ result = false;
28
21
  }
29
22
  }
30
23
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"detectPrivateKey.js","sourceRoot":"","sources":["../../src/file/detectPrivateKey.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gEAAwC;AAExC,SAAwB,gBAAgB,CAAC,OAAe;IACvD,EAAE;IACF,MAAM,IAAI,GAAG,IAAA,qBAAW,EAAC,OAAO,CAAC,CAAC;IAElC,IAAI,MAAM,GAAG,IAAI,CAAC;IAElB,MAAM,KAAK,GAAG,EAAE,CAAC;IAEjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE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AO;QACN,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,KAAK;KACX,CAAC;AACH,CAAC;AAtBD,mCAsBC;AAEQ,4CAAgB"}
@@ -0,0 +1,2 @@
1
+ export default function detectPrivateKeyByFilePath(_path: string): boolean;
2
+ export { detectPrivateKeyByFilePath };
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.detectPrivateKeyByFilePath = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ function detectPrivateKeyByFilePath(_path) {
9
+ //
10
+ if (!fs_1.default.existsSync(_path))
11
+ return true;
12
+ const fileContents = fs_1.default.readFileSync(_path);
13
+ switch (true) {
14
+ case fileContents.includes("-----BEGIN "):
15
+ case fileContents.includes("SECRET=") && !fileContents.includes("SECRET=\n") && !fileContents.includes("SECRET=*"):
16
+ return false;
17
+ default:
18
+ break;
19
+ }
20
+ return true;
21
+ }
22
+ exports.default = detectPrivateKeyByFilePath;
23
+ exports.detectPrivateKeyByFilePath = detectPrivateKeyByFilePath;
24
+ //# sourceMappingURL=detectPrivateKeyByFilePath.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detectPrivateKeyByFilePath.js","sourceRoot":"","sources":["../../src/file/detectPrivateKeyByFilePath.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AAEpB,SAAwB,0BAA0B,CAAC,KAAa;IAC/D,EAAE;IACF,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAEvC,MAAM,YAAY,GAAG,YAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IAE5C,QAAQ,IAAI,EAAE;QACb,KAAK,YAAY,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;QAC1C,KAAK,YAAY,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,UAAU,CAAC;YACjH,OAAO,KAAK,CAAC;QACd;YACC,MAAM;KACP;IAED,OAAO,IAAI,CAAC;AACb,CAAC;AAfD,6CAeC;AAEQ,gEAA0B"}
@@ -1,5 +1,5 @@
1
- import fs from "fs";
2
1
  import getAllFiles from "./getAllFiles";
2
+ import detectPrivateKeyByFilePath from "./detectPrivateKeyByFilePath";
3
3
  export default function detectPrivateKey(dirPath) {
4
4
  //
5
5
  const list = getAllFiles(dirPath);
@@ -7,18 +7,11 @@ export default function detectPrivateKey(dirPath) {
7
7
  const _list = [];
8
8
  for (let i = 0; i < list.length; i++) {
9
9
  const _path = list[i];
10
- // Read the contents of the file
11
- const fileContents = fs.readFileSync(_path);
12
- switch (true) {
13
- case fileContents.includes("-----BEGIN "):
14
- case fileContents.includes("SECRET=") && !fileContents.includes("SECRET=\n") && !fileContents.includes("SECRET=*"):
15
- {
16
- _list.push(_path);
17
- result = false;
18
- }
19
- break;
20
- default:
21
- break;
10
+ if (detectPrivateKeyByFilePath(_path)) {
11
+ }
12
+ else {
13
+ _list.push(_path);
14
+ result = false;
22
15
  }
23
16
  }
24
17
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"detectPrivateKey.js","sourceRoot":"","sources":["../../src/file/detectPrivateKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,WAAW,MAAM,eAAe,CAAC;AAExC,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,OAAe;IACvD,EAAE;IACF,MAAM,IAAI,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;IAElC,IAAI,MAAM,GAAG,IAAI,CAAC;IAElB,MAAM,KAAK,GAAG,EAAE,CAAC;IAEjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAA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MAAM,GAAG,KAAK,CAAC;SACf;KACD;IAED,OAAO;QACN,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,KAAK;KACX,CAAC;AACH,CAAC;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export default function detectPrivateKeyByFilePath(_path: string): boolean;
2
+ export { detectPrivateKeyByFilePath };
@@ -0,0 +1,17 @@
1
+ import fs from "fs";
2
+ export default function detectPrivateKeyByFilePath(_path) {
3
+ //
4
+ if (!fs.existsSync(_path))
5
+ return true;
6
+ const fileContents = fs.readFileSync(_path);
7
+ switch (true) {
8
+ case fileContents.includes("-----BEGIN "):
9
+ case fileContents.includes("SECRET=") && !fileContents.includes("SECRET=\n") && !fileContents.includes("SECRET=*"):
10
+ return false;
11
+ default:
12
+ break;
13
+ }
14
+ return true;
15
+ }
16
+ export { detectPrivateKeyByFilePath };
17
+ //# sourceMappingURL=detectPrivateKeyByFilePath.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detectPrivateKeyByFilePath.js","sourceRoot":"","sources":["../../src/file/detectPrivateKeyByFilePath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,MAAM,CAAC,OAAO,UAAU,0BAA0B,CAAC,KAAa;IAC/D,EAAE;IACF,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAEvC,MAAM,YAAY,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IAE5C,QAAQ,IAAI,EAAE;QACb,KAAK,YAAY,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;QAC1C,KAAK,YAAY,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,UAAU,CAAC;YACjH,OAAO,KAAK,CAAC;QACd;YACC,MAAM;KACP;IAED,OAAO,IAAI,CAAC;AACb,CAAC;AAED,OAAO,EAAE,0BAA0B,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diginext-utils",
3
- "version": "3.0.2",
3
+ "version": "3.0.4",
4
4
  "sideEffects": false,
5
5
  "readme": "README.md",
6
6
  "homepage": "https://wearetopgroup.com",