diginext-utils 3.0.4 → 3.0.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.
@@ -5,14 +5,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.detectPrivateKeyByFilePath = void 0;
7
7
  const fs_1 = __importDefault(require("fs"));
8
+ const object_1 = require("../object");
8
9
  function detectPrivateKeyByFilePath(_path) {
9
10
  //
10
11
  if (!fs_1.default.existsSync(_path))
11
12
  return true;
12
- const fileContents = fs_1.default.readFileSync(_path);
13
+ const fileContents = fs_1.default.readFileSync(_path, "utf8");
14
+ const secretPattern = /((SECRET|TOKEN|PRIVATE)[\S+|=]+[\S]+)/g;
15
+ // console.log(fileContents.match(secretPattern));
13
16
  switch (true) {
14
- case fileContents.includes("-----BEGIN "):
15
- case fileContents.includes("SECRET=") && !fileContents.includes("SECRET=\n") && !fileContents.includes("SECRET=*"):
17
+ case fileContents.includes(`${`-----`}BEGIN `):
18
+ case _path.includes(".env") && (0, object_1.toBool)(fileContents.match(secretPattern)):
16
19
  return false;
17
20
  default:
18
21
  break;
@@ -1 +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
+ {"version":3,"file":"detectPrivateKeyByFilePath.js","sourceRoot":"","sources":["../../src/file/detectPrivateKeyByFilePath.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,sCAAmC;AAEnC,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,EAAE,MAAM,CAAW,CAAC;IAC9D,MAAM,aAAa,GAAG,wCAAwC,CAAC;IAE/D,kDAAkD;IAElD,QAAQ,IAAI,EAAE;QACb,KAAK,YAAY,CAAC,QAAQ,CAAC,GAAG,OAAO,QAAQ,CAAC,CAAC;QAC/C,KAAK,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,IAAA,eAAM,EAAC,YAAY,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;YACvE,OAAO,KAAK,CAAC;QACd;YACC,MAAM;KACP;IAED,OAAO,IAAI,CAAC;AACb,CAAC;AAlBD,6CAkBC;AAEQ,gEAA0B"}
@@ -1,12 +1,15 @@
1
1
  import fs from "fs";
2
+ import { toBool } from "../object";
2
3
  export default function detectPrivateKeyByFilePath(_path) {
3
4
  //
4
5
  if (!fs.existsSync(_path))
5
6
  return true;
6
- const fileContents = fs.readFileSync(_path);
7
+ const fileContents = fs.readFileSync(_path, "utf8");
8
+ const secretPattern = /((SECRET|TOKEN|PRIVATE)[\S+|=]+[\S]+)/g;
9
+ // console.log(fileContents.match(secretPattern));
7
10
  switch (true) {
8
- case fileContents.includes("-----BEGIN "):
9
- case fileContents.includes("SECRET=") && !fileContents.includes("SECRET=\n") && !fileContents.includes("SECRET=*"):
11
+ case fileContents.includes(`${`-----`}BEGIN `):
12
+ case _path.includes(".env") && toBool(fileContents.match(secretPattern)):
10
13
  return false;
11
14
  default:
12
15
  break;
@@ -1 +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"}
1
+ {"version":3,"file":"detectPrivateKeyByFilePath.js","sourceRoot":"","sources":["../../src/file/detectPrivateKeyByFilePath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,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,EAAE,MAAM,CAAW,CAAC;IAC9D,MAAM,aAAa,GAAG,wCAAwC,CAAC;IAE/D,kDAAkD;IAElD,QAAQ,IAAI,EAAE;QACb,KAAK,YAAY,CAAC,QAAQ,CAAC,GAAG,OAAO,QAAQ,CAAC,CAAC;QAC/C,KAAK,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;YACvE,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.4",
3
+ "version": "3.0.6",
4
4
  "sideEffects": false,
5
5
  "readme": "README.md",
6
6
  "homepage": "https://wearetopgroup.com",
@@ -23,48 +23,56 @@
23
23
  "esm"
24
24
  ],
25
25
  "scripts": {
26
- "build": "npm run prebuild && tsc --module commonjs --outDir dist && tsc --module esnext --outDir esm && npm run test",
27
- "build_tsup": "tsup src/**/*.ts --format esm,cjs --dts --legacy-output",
28
- "prebuild": "run-script-os || exit 0",
29
- "prebuild:win32": "rd /S /Q dist esm",
30
- "prebuild:darwin:linux": "rm -rf dist && rm -rf esm",
31
- "prebuild:default": "rm -rf dist && rm -rf esm",
26
+ "build": "npm run clean && tsc --module commonjs --outDir dist && tsc --module esnext --outDir esm && npm run test",
27
+ "dev": "nodemon tsc --module commonjs --outDir dist",
28
+ "clean": "rimraf dist esm",
32
29
  "release": "npm run build && npm publish",
33
- "dev": "npm run prebuild && concurrently \"tsup src/**/*.ts --format esm,cjs --dts --watch\"",
34
30
  "test": "mocha test/*.test.js",
35
- "lint": "TIMING=1 eslint src --fix",
36
- "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
31
+ "lint": "TIMING=1 eslint src --fix"
37
32
  },
38
33
  "dependencies": {
39
- "@types/file-saver": "^2.0.5",
40
- "@types/jest": "^26.0.22",
41
- "@types/node": "^18.8.5",
42
- "@types/react": "^17.0.13",
43
- "@types/react-dom": "^17.0.8",
44
34
  "blueimp-load-image": "^5.16.0",
45
- "run-script-os": "^1.1.6",
46
35
  "chalk": "4.1.2",
47
36
  "concurrently": "^7.2.2",
48
- "config": "*",
49
- "core-js": "^3.24.1",
50
37
  "dayjs": "^1.11.5",
51
- "esm": "^3.2.25",
52
38
  "file-saver": "^2.0.5",
53
39
  "gsap": "^3.10.4",
54
- "lodash": "^4.17.21",
55
- "tsconfig": "*",
56
- "tsup": "^6.1.3",
57
- "typescript": "^4.5.3"
40
+ "lodash": "^4.17.21"
58
41
  },
59
42
  "publishConfig": {
60
43
  "access": "public"
61
44
  },
62
45
  "devDependencies": {
46
+ "@types/file-saver": "^2.0.5",
47
+ "@types/jest": "^26.0.22",
48
+ "@types/node": "^18.8.5",
49
+ "@types/react": "^17.0.13",
50
+ "@types/react-dom": "^17.0.8",
63
51
  "@types/blueimp-load-image": "^5.16.0",
64
52
  "@types/lodash": "^4.14.186",
65
53
  "eslint": "^7.16.0",
66
54
  "eslint-plugin-import": "^2.26.0",
67
55
  "esm": "^3.2.25",
56
+ "rimraf": "^5.0.1",
57
+ "typescript": "^4.5.3",
68
58
  "mocha": "^10.0.0"
59
+ },
60
+ "nodemonConfig": {
61
+ "watch": [
62
+ "src"
63
+ ],
64
+ "exec": "pnpm",
65
+ "ext": "js,json,ts,tsx",
66
+ "ignore": [
67
+ "node_modules",
68
+ "dist",
69
+ "build",
70
+ "esm",
71
+ "*.log"
72
+ ],
73
+ "delay": "1",
74
+ "env": {
75
+ "NODE_ENV": "local"
76
+ }
69
77
  }
70
78
  }