@socketsecurity/cli 0.14.43 → 0.14.45
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/README.md +16 -38
- package/bin/cli.js +17 -7
- package/bin/npm-cli.js +1 -1
- package/bin/npx-cli.js +1 -1
- package/dist/constants.d.ts +121 -11
- package/dist/constants.js +91 -10
- package/dist/constants.js.map +1 -0
- package/dist/init.gradle +250 -0
- package/dist/module-sync/cli.js +6115 -3842
- package/dist/module-sync/cli.js.map +1 -0
- package/dist/module-sync/edge.d.ts +66 -0
- package/dist/module-sync/errors.d.ts +6 -1
- package/dist/module-sync/index.d.ts +192 -0
- package/dist/module-sync/index.js +1879 -0
- package/dist/module-sync/index.js.map +1 -0
- package/dist/module-sync/logging.d.ts +3 -3
- package/dist/module-sync/node.d.ts +84 -0
- package/dist/module-sync/npm-injection.js +7 -1486
- package/dist/module-sync/npm-injection.js.map +1 -0
- package/dist/module-sync/npm-paths.d.ts +3 -2
- package/dist/module-sync/npm-paths.js +91 -42
- package/dist/module-sync/npm-paths.js.map +1 -0
- package/dist/module-sync/npm.d.ts +24 -0
- package/dist/module-sync/npm.js +99 -0
- package/dist/module-sync/npm.js.map +1 -0
- package/dist/module-sync/path-resolve.d.ts +1 -1
- package/dist/module-sync/proc-log.d.ts +3 -0
- package/dist/module-sync/reify.d.ts +1018 -0
- package/dist/module-sync/sdk.d.ts +5 -0
- package/dist/module-sync/settings.d.ts +5 -4
- package/dist/module-sync/shadow-bin.d.ts +1 -1
- package/dist/module-sync/shadow-bin.js +33 -16
- package/dist/module-sync/shadow-bin.js.map +1 -0
- package/dist/module-sync/types.d.ts +45 -0
- package/dist/require/cli.js +6114 -3842
- package/dist/require/constants.js +1 -1
- package/dist/require/index.js +3 -0
- package/dist/require/npm.js +3 -0
- package/dist/require/vendor.js +2336 -6
- package/package.json +69 -42
- package/dist/constants.d.ts.map +0 -1
- package/dist/module-sync/socket-url.d.ts +0 -40
- package/dist/module-sync/socket-url.js +0 -301
- package/dist/require/socket-url.js +0 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@socketsecurity/cli",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.45",
|
|
4
4
|
"description": "CLI tool for Socket.dev",
|
|
5
5
|
"homepage": "http://github.com/SocketDev/socket-cli",
|
|
6
6
|
"license": "MIT",
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
"url": "https://socket.dev"
|
|
15
15
|
},
|
|
16
16
|
"bin": {
|
|
17
|
-
"cli": "
|
|
18
|
-
"socket": "
|
|
19
|
-
"socket-npm": "
|
|
20
|
-
"socket-npx": "
|
|
17
|
+
"cli": "bin/cli.js",
|
|
18
|
+
"socket": "bin/cli.js",
|
|
19
|
+
"socket-npm": "bin/npm-cli.js",
|
|
20
|
+
"socket-npx": "bin/npx-cli.js"
|
|
21
21
|
},
|
|
22
22
|
"exports": {
|
|
23
23
|
"./bin/cli.js": {
|
|
@@ -37,20 +37,25 @@
|
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"build": "run-s build:*",
|
|
40
|
-
"build:dist": "rollup -c .config/rollup.dist.config.mjs",
|
|
41
|
-
"build:test": "rollup -c .config/rollup.test.config.mjs",
|
|
40
|
+
"build:dist": "del-cli 'dist' && rollup -c .config/rollup.dist.config.mjs",
|
|
41
|
+
"build:test": "del-cli 'test/dist' && rollup -c .config/rollup.test.config.mjs",
|
|
42
42
|
"check": "run-p -c --aggregate-output check:*",
|
|
43
43
|
"check:lint": "eslint --report-unused-disable-directives .",
|
|
44
|
+
"check:lint:fix": "npm run check:lint -- --fix",
|
|
44
45
|
"check:tsc": "tsc",
|
|
45
|
-
"check:type-coverage": "type-coverage
|
|
46
|
+
"check:type-coverage": "type-coverage",
|
|
47
|
+
"check:type-coverage:detail": "npm run check:type-coverage -- --detail",
|
|
46
48
|
"clean": "run-p --aggregate-output clean:*",
|
|
47
49
|
"clean:dist": "del-cli 'dist' 'test/dist'",
|
|
48
50
|
"clean:node_modules": "del-cli '**/node_modules'",
|
|
51
|
+
"fix": "run-s lint:fix check:lint:fix",
|
|
49
52
|
"knip:dependencies": "knip --dependencies",
|
|
50
53
|
"knip:exports": "knip --include exports,duplicates",
|
|
51
|
-
"lint": "oxlint -c=./.oxlintrc.json --ignore-path=./.
|
|
54
|
+
"lint": "oxlint -c=./.oxlintrc.json --ignore-path=./.oxlintignore --tsconfig=./tsconfig.json .",
|
|
52
55
|
"lint:fix": "npm run lint -- --fix && npm run lint:fix:fast",
|
|
53
|
-
"lint:fix:fast": "
|
|
56
|
+
"lint:fix:fast": "biome format --write",
|
|
57
|
+
"lint-staged": "lint-staged",
|
|
58
|
+
"precommit": "lint-staged",
|
|
54
59
|
"prepare": "husky && custompatch",
|
|
55
60
|
"test": "run-s check build:* test:* test:coverage:*",
|
|
56
61
|
"test-ci": "run-s build:* test:*",
|
|
@@ -58,65 +63,72 @@
|
|
|
58
63
|
"test:coverage:c8": "c8 --reporter=none node --test 'test/socket-npm.test.cjs'",
|
|
59
64
|
"test:coverage:merge": "cp -r .tap/coverage/*.json coverage/tmp && c8 --reporter=lcov --reporter=text --include 'dist/{module-sync,require}/*.js' --exclude 'dist/require/vendor.js' report",
|
|
60
65
|
"update": "run-p --aggregate-output update:**",
|
|
61
|
-
"update:deps": "npx npm-check-updates"
|
|
66
|
+
"update:deps": "npx --yes npm-check-updates"
|
|
62
67
|
},
|
|
63
68
|
"dependencies": {
|
|
64
69
|
"@apideck/better-ajv-errors": "^0.3.6",
|
|
65
|
-
"@cyclonedx/cdxgen": "^11.1.
|
|
70
|
+
"@cyclonedx/cdxgen": "^11.1.10",
|
|
66
71
|
"@npmcli/promise-spawn": "^8.0.2",
|
|
67
|
-
"@
|
|
68
|
-
"@socketregistry/
|
|
72
|
+
"@octokit/rest": "^21.1.1",
|
|
73
|
+
"@socketregistry/hyrious__bun.lockb": "^1.0.13",
|
|
74
|
+
"@socketregistry/indent-string": "^1.0.10",
|
|
69
75
|
"@socketregistry/is-interactive": "^1.0.1",
|
|
70
76
|
"@socketregistry/is-unicode-supported": "^1.0.0",
|
|
77
|
+
"@socketregistry/packageurl-js": "^1.0.2",
|
|
71
78
|
"@socketsecurity/config": "^2.1.3",
|
|
72
|
-
"@socketsecurity/registry": "^1.0.
|
|
79
|
+
"@socketsecurity/registry": "^1.0.93",
|
|
73
80
|
"@socketsecurity/sdk": "^1.4.5",
|
|
74
81
|
"blessed": "^0.1.81",
|
|
75
82
|
"blessed-contrib": "^4.11.0",
|
|
76
83
|
"browserslist": "4.24.4",
|
|
77
84
|
"chalk-table": "^1.0.2",
|
|
78
85
|
"cmd-shim": "^7.0.0",
|
|
86
|
+
"fast-content-type-parse": "^2.0.1",
|
|
79
87
|
"has-flag": "4.0.0",
|
|
80
88
|
"hpagent": "^1.2.0",
|
|
81
89
|
"ignore": "^7.0.3",
|
|
82
90
|
"meow": "^13.2.0",
|
|
83
91
|
"micromatch": "^4.0.8",
|
|
84
|
-
"
|
|
92
|
+
"ndjson": "^2.0.0",
|
|
93
|
+
"npm-package-arg": "^12.0.2",
|
|
85
94
|
"open": "^10.1.0",
|
|
86
95
|
"pony-cause": "^2.1.11",
|
|
87
|
-
"semver": "^7.7.
|
|
96
|
+
"semver": "^7.7.1",
|
|
97
|
+
"simple-git": "^3.27.0",
|
|
88
98
|
"synp": "^1.9.14",
|
|
89
99
|
"terminal-link": "2.1.1",
|
|
90
100
|
"tiny-updater": "^3.5.3",
|
|
91
|
-
"tinyglobby": "^0.2.
|
|
101
|
+
"tinyglobby": "^0.2.12",
|
|
92
102
|
"which": "^5.0.0",
|
|
93
103
|
"yaml": "^2.7.0",
|
|
94
104
|
"yargs-parser": "^21.1.1",
|
|
95
105
|
"yoctocolors-cjs": "^2.1.2"
|
|
96
106
|
},
|
|
97
107
|
"devDependencies": {
|
|
98
|
-
"@babel/core": "^7.26.
|
|
108
|
+
"@babel/core": "^7.26.9",
|
|
99
109
|
"@babel/plugin-proposal-export-default-from": "^7.25.9",
|
|
100
110
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
101
111
|
"@babel/plugin-transform-export-namespace-from": "^7.25.9",
|
|
102
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
103
|
-
"@babel/preset-env": "^7.26.
|
|
112
|
+
"@babel/plugin-transform-runtime": "^7.26.9",
|
|
113
|
+
"@babel/preset-env": "^7.26.9",
|
|
104
114
|
"@babel/preset-typescript": "^7.26.0",
|
|
105
|
-
"@babel/runtime": "^7.26.
|
|
106
|
-
"@
|
|
107
|
-
"@eslint/
|
|
115
|
+
"@babel/runtime": "^7.26.9",
|
|
116
|
+
"@biomejs/biome": "^1.9.4",
|
|
117
|
+
"@eslint/compat": "^1.2.7",
|
|
118
|
+
"@eslint/js": "^9.21.0",
|
|
108
119
|
"@rollup/plugin-commonjs": "^28.0.2",
|
|
109
120
|
"@rollup/plugin-json": "^6.1.0",
|
|
110
121
|
"@rollup/plugin-node-resolve": "^16.0.0",
|
|
111
122
|
"@rollup/plugin-replace": "^6.0.2",
|
|
112
123
|
"@rollup/pluginutils": "^5.1.4",
|
|
113
|
-
"@tapjs/run": "^4.0.
|
|
124
|
+
"@tapjs/run": "^4.0.2",
|
|
114
125
|
"@types/blessed": "^0.1.25",
|
|
115
126
|
"@types/cmd-shim": "^5.0.2",
|
|
116
127
|
"@types/micromatch": "^4.0.9",
|
|
117
128
|
"@types/mocha": "^10.0.10",
|
|
118
129
|
"@types/mock-fs": "^4.13.4",
|
|
119
|
-
"@types/
|
|
130
|
+
"@types/ndjson": "^2.0.4",
|
|
131
|
+
"@types/node": "^22.13.5",
|
|
120
132
|
"@types/npmcli__arborist": "^6.3.0",
|
|
121
133
|
"@types/npmcli__promise-spawn": "^6.0.3",
|
|
122
134
|
"@types/proc-log": "^3.0.4",
|
|
@@ -124,36 +136,35 @@
|
|
|
124
136
|
"@types/update-notifier": "^6.0.8",
|
|
125
137
|
"@types/which": "^3.0.4",
|
|
126
138
|
"@types/yargs-parser": "^21.0.3",
|
|
127
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
128
|
-
"@typescript-eslint/parser": "^8.
|
|
139
|
+
"@typescript-eslint/eslint-plugin": "^8.25.0",
|
|
140
|
+
"@typescript-eslint/parser": "^8.25.0",
|
|
129
141
|
"c8": "^10.1.3",
|
|
130
142
|
"custompatch": "^1.1.4",
|
|
131
143
|
"del-cli": "^6.0.0",
|
|
132
|
-
"eslint": "^9.
|
|
133
|
-
"eslint-import-resolver-oxc": "^0.
|
|
144
|
+
"eslint": "^9.21.0",
|
|
145
|
+
"eslint-import-resolver-oxc": "^0.12.0",
|
|
134
146
|
"eslint-plugin-depend": "^0.12.0",
|
|
135
147
|
"eslint-plugin-import-x": "^4.6.1",
|
|
136
148
|
"eslint-plugin-n": "^17.15.1",
|
|
137
149
|
"eslint-plugin-sort-destructure-keys": "^2.0.0",
|
|
138
150
|
"eslint-plugin-unicorn": "^56.0.1",
|
|
139
151
|
"husky": "^9.1.7",
|
|
140
|
-
"knip": "^5.
|
|
152
|
+
"knip": "^5.45.0",
|
|
153
|
+
"lint-staged": "^15.4.3",
|
|
141
154
|
"magic-string": "^0.30.17",
|
|
142
|
-
"mock-fs": "^5.
|
|
143
|
-
"nock": "^14.0.
|
|
155
|
+
"mock-fs": "^5.5.0",
|
|
156
|
+
"nock": "^14.0.1",
|
|
144
157
|
"npm-run-all2": "^7.0.2",
|
|
145
|
-
"oxlint": "0.15.
|
|
146
|
-
"prettier": "3.4.2",
|
|
158
|
+
"oxlint": "0.15.12",
|
|
147
159
|
"read-package-up": "^11.0.0",
|
|
148
|
-
"rollup": "4.34.
|
|
160
|
+
"rollup": "4.34.8",
|
|
149
161
|
"rollup-plugin-ts": "^3.4.5",
|
|
150
162
|
"type-coverage": "^2.29.7",
|
|
151
163
|
"typescript": "5.4.5",
|
|
152
|
-
"typescript-eslint": "^8.
|
|
164
|
+
"typescript-eslint": "^8.25.0",
|
|
153
165
|
"unplugin-purge-polyfills": "^0.0.7"
|
|
154
166
|
},
|
|
155
167
|
"overrides": {
|
|
156
|
-
"@socketregistry/packageurl-js": "npm:@socketregistry/packageurl-js@^1",
|
|
157
168
|
"aggregate-error": "npm:@socketregistry/aggregate-error@^1",
|
|
158
169
|
"es-define-property": "npm:@socketregistry/es-define-property@^1",
|
|
159
170
|
"function-bind": "npm:@socketregistry/function-bind@^1",
|
|
@@ -163,11 +174,11 @@
|
|
|
163
174
|
"has-proto": "npm:@socketregistry/has-proto@^1",
|
|
164
175
|
"has-symbols": "npm:@socketregistry/has-symbols@^1",
|
|
165
176
|
"hasown": "npm:@socketregistry/hasown@^1",
|
|
166
|
-
"indent-string": "
|
|
177
|
+
"indent-string": "$@socketregistry/indent-string",
|
|
167
178
|
"is-core-module": "npm:@socketregistry/is-core-module@^1",
|
|
168
179
|
"isarray": "npm:@socketregistry/isarray@^1",
|
|
169
180
|
"npm-package-arg": "$npm-package-arg",
|
|
170
|
-
"packageurl-js": "
|
|
181
|
+
"packageurl-js": "$@socketregistry/packageurl-js",
|
|
171
182
|
"path-parse": "npm:@socketregistry/path-parse@^1",
|
|
172
183
|
"safe-buffer": "npm:@socketregistry/safe-buffer@^1",
|
|
173
184
|
"safer-buffer": "npm:@socketregistry/safer-buffer@^1",
|
|
@@ -180,7 +191,6 @@
|
|
|
180
191
|
"yaml": "$yaml"
|
|
181
192
|
},
|
|
182
193
|
"resolutions": {
|
|
183
|
-
"@socketregistry/packageurl-js": "npm:@socketregistry/packageurl-js@^1",
|
|
184
194
|
"aggregate-error": "npm:@socketregistry/aggregate-error@^1",
|
|
185
195
|
"es-define-property": "npm:@socketregistry/es-define-property@^1",
|
|
186
196
|
"function-bind": "npm:@socketregistry/function-bind@^1",
|
|
@@ -214,5 +224,22 @@
|
|
|
214
224
|
"dist/**",
|
|
215
225
|
"shadow-bin/**",
|
|
216
226
|
"translations.json"
|
|
217
|
-
]
|
|
227
|
+
],
|
|
228
|
+
"lint-staged": {
|
|
229
|
+
"*.{cjs,js,json,md,mjs,ts}": [
|
|
230
|
+
"npm run lint -- --fix",
|
|
231
|
+
"npm run lint:fix:fast -- --no-errors-on-unmatched --files-ignore-unknown=true --colors=off"
|
|
232
|
+
]
|
|
233
|
+
},
|
|
234
|
+
"typeCoverage": {
|
|
235
|
+
"cache": true,
|
|
236
|
+
"atLeast": 95,
|
|
237
|
+
"ignoreAsAssertion": true,
|
|
238
|
+
"ignoreCatch": true,
|
|
239
|
+
"ignoreEmptyType": true,
|
|
240
|
+
"ignore-non-null-assertion": true,
|
|
241
|
+
"ignore-type-assertion": true,
|
|
242
|
+
"ignore-files": "test/*",
|
|
243
|
+
"strict": true
|
|
244
|
+
}
|
|
218
245
|
}
|
package/dist/constants.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAIA,OAAO,iBAAiB,MAAM,wCAAwC,CAAA;AAWtE,KAAK,WAAW,GAAG,OAAO,iBAAiB,CAAC,GAAG,CAAA;AAE/C,KAAK,iBAAiB,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,0BAA0B,CAAC,CAAA;AAE/E,KAAK,SAAS,GAAG,IAAI,CAAC,iBAAiB,EAAE,QAAQ,CAAC,GAChD,QAAQ,CAAC;IACP,MAAM,EAAE;QACN,IAAI,OAAO,CAAC,GAAG,CAAC,CAAA;QAChB,CAAC,CAAC,SAAS,MAAM,GAAG,GAAG,SAAS,EAC9B,GAAG,CAAC,EAAE,CAAC,GACN,OAAO,CAAC,CAAC,SAAS,MAAM,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAA;KAC/C,CAAA;CACF,CAAC,CAAA;AAEJ,KAAK,GAAG,GAAG,WAAW,GACpB,QAAQ,CAAC;IACP,gBAAgB,EAAE,OAAO,CAAA;CAC1B,CAAC,CAAA;AAEJ,KAAK,GAAG,GAAG,QAAQ,CAAC;IAClB,gCAAgC,EAAE,OAAO,CAAA;IACzC,gDAAgD,EAAE,OAAO,CAAA;CAC1D,CAAC,CAAA;AAEF,KAAK,SAAS,GAAG,IAAI,CACnB,OAAO,iBAAiB,EACxB,0BAA0B,GAAG,KAAK,GAAG,KAAK,CAC3C,GAAG;IACF,QAAQ,CAAC,0BAA0B,EAAE,SAAS,CAAA;IAC9C,QAAQ,CAAC,UAAU,EAAE,2BAA2B,CAAA;IAChD,QAAQ,CAAC,aAAa,EAAE,gBAAgB,CAAA;IACxC,QAAQ,CAAC,eAAe,EAAE,QAAQ,CAAA;IAClC,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAA;IACnB,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAA;IACjB,QAAQ,CAAC,SAAS,EAAE,aAAa,GAAG,SAAS,CAAA;IAC7C,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAA;IACjB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;IAC1B,QAAQ,CAAC,WAAW,EAAE,aAAa,CAAA;IACnC,QAAQ,CAAC,gBAAgB,EAAE,4BAA4B,CAAA;IACvD,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAA;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAA;IAC3B,QAAQ,CAAC,gBAAgB,EAAE,kBAAkB,CAAA;IAC7C,QAAQ,CAAC,gCAAgC,EAAE,kCAAkC,CAAA;IAC7E,QAAQ,CAAC,qBAAqB,EAAE,gDAAgD,CAAA;IAChF,QAAQ,CAAC,gDAAgD,EAAE,kDAAkD,CAAA;IAC7G,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAA;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,UAAU,EAAE,YAAY,CAAA;IACjC,QAAQ,CAAC,YAAY,EAAE,cAAc,CAAA;IACrC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAA;IAChC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAC7B,CAAA;AAyED,QAAA,MAAM,SAAS,WAiDd,CAAA"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { SocketSdk } from "@socketsecurity/sdk";
|
|
3
|
-
import { ObjectEncodingOptions, OpenMode, PathLike } from "node:fs";
|
|
4
|
-
import { promises as fs } from "node:fs";
|
|
5
|
-
import { readFileSync as fsReadFileSync } from "node:fs";
|
|
6
|
-
import { Abortable } from "node:events";
|
|
7
|
-
import { FileHandle } from "node:fs/promises";
|
|
8
|
-
import indentString from "@socketregistry/indent-string/index.cjs";
|
|
9
|
-
import { logSymbols } from "./logging.js";
|
|
10
|
-
declare function getDefaultToken(): string | undefined;
|
|
11
|
-
declare function getPublicToken(): string;
|
|
12
|
-
declare function setupSdk(apiToken?: string | undefined, apiBaseUrl?: string | undefined, proxy?: string | undefined): Promise<SocketSdk>;
|
|
13
|
-
declare function findUp(name: string | string[], { cwd }: {
|
|
14
|
-
cwd: string | undefined;
|
|
15
|
-
}): Promise<string | undefined>;
|
|
16
|
-
type ReadFileOptions = ObjectEncodingOptions & Abortable & {
|
|
17
|
-
flag?: OpenMode | undefined;
|
|
18
|
-
};
|
|
19
|
-
declare function readFileBinary(filepath: PathLike | FileHandle, options?: ReadFileOptions): Promise<Buffer>;
|
|
20
|
-
declare function readFileUtf8(filepath: PathLike | FileHandle, options?: ReadFileOptions): Promise<string>;
|
|
21
|
-
declare function safeReadFile(...args: Parameters<typeof fs.readFile>): ReturnType<typeof fs.readFile> | undefined;
|
|
22
|
-
declare function safeReadFileSync(...args: Parameters<typeof fsReadFileSync>): ReturnType<typeof fsReadFileSync> | undefined;
|
|
23
|
-
declare class ColorOrMarkdown {
|
|
24
|
-
useMarkdown: boolean;
|
|
25
|
-
constructor(useMarkdown: boolean);
|
|
26
|
-
bold(text: string): string;
|
|
27
|
-
header(text: string, level?: number): string;
|
|
28
|
-
hyperlink(text: string, url: string | undefined, { fallback, fallbackToUrl }?: {
|
|
29
|
-
fallback?: boolean;
|
|
30
|
-
fallbackToUrl?: boolean;
|
|
31
|
-
}): string;
|
|
32
|
-
indent(...args: Parameters<typeof indentString>): ReturnType<typeof indentString>;
|
|
33
|
-
italic(text: string): string;
|
|
34
|
-
json(value: any): string;
|
|
35
|
-
list(items: string[]): string;
|
|
36
|
-
get logSymbols(): typeof logSymbols;
|
|
37
|
-
}
|
|
38
|
-
declare function getSocketDevAlertUrl(alertType: string): string;
|
|
39
|
-
declare function getSocketDevPackageOverviewUrl(eco: string, name: string, version?: string): string;
|
|
40
|
-
export { getDefaultToken, getPublicToken, setupSdk, findUp, ReadFileOptions, readFileBinary, readFileUtf8, safeReadFile, safeReadFileSync, ColorOrMarkdown, getSocketDevAlertUrl, getSocketDevPackageOverviewUrl };
|
|
@@ -1,301 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
function _socketInterop(e) {
|
|
4
|
-
let c = 0
|
|
5
|
-
for (const k in e ?? {}) {
|
|
6
|
-
c = c === 0 && k === 'default' ? 1 : 0
|
|
7
|
-
if (!c && k !== '__esModule') break
|
|
8
|
-
}
|
|
9
|
-
return c ? e.default : e
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
var terminalLink = _socketInterop(require('terminal-link'));
|
|
13
|
-
var colors = _socketInterop(require('yoctocolors-cjs'));
|
|
14
|
-
var indentString = require('@socketregistry/indent-string/index.cjs');
|
|
15
|
-
var npmPaths = require('./npm-paths.js');
|
|
16
|
-
var process = require('node:process');
|
|
17
|
-
var hpagent = _socketInterop(require('hpagent'));
|
|
18
|
-
var isInteractive = require('@socketregistry/is-interactive/index.cjs');
|
|
19
|
-
var registryConstants = require('@socketsecurity/registry/lib/constants');
|
|
20
|
-
var prompts = require('@socketsecurity/registry/lib/prompts');
|
|
21
|
-
var strings = require('@socketsecurity/registry/lib/strings');
|
|
22
|
-
var sdk = require('@socketsecurity/sdk');
|
|
23
|
-
var fs = require('node:fs');
|
|
24
|
-
var os = require('node:os');
|
|
25
|
-
var path = require('node:path');
|
|
26
|
-
var config = require('@socketsecurity/config');
|
|
27
|
-
var constants = require('./constants.js');
|
|
28
|
-
|
|
29
|
-
class AuthError extends Error {}
|
|
30
|
-
class InputError extends Error {
|
|
31
|
-
constructor(message, body) {
|
|
32
|
-
super(message);
|
|
33
|
-
this.body = body;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
function isErrnoException(value) {
|
|
37
|
-
if (!(value instanceof Error)) {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
return value.code !== undefined;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const markdownLogSymbols = {
|
|
44
|
-
__proto__: null,
|
|
45
|
-
info: ':information_source:',
|
|
46
|
-
error: ':stop_sign:',
|
|
47
|
-
success: ':white_check_mark:',
|
|
48
|
-
warning: ':warning:'
|
|
49
|
-
};
|
|
50
|
-
class ColorOrMarkdown {
|
|
51
|
-
constructor(useMarkdown) {
|
|
52
|
-
this.useMarkdown = !!useMarkdown;
|
|
53
|
-
}
|
|
54
|
-
bold(text) {
|
|
55
|
-
return this.useMarkdown ? `**${text}**` : colors.bold(`${text}`);
|
|
56
|
-
}
|
|
57
|
-
header(text, level = 1) {
|
|
58
|
-
return this.useMarkdown ? `\n${''.padStart(level, '#')} ${text}\n` : colors.underline(`\n${level === 1 ? colors.bold(text) : text}\n`);
|
|
59
|
-
}
|
|
60
|
-
hyperlink(text, url, {
|
|
61
|
-
fallback = true,
|
|
62
|
-
fallbackToUrl
|
|
63
|
-
} = {}) {
|
|
64
|
-
if (url) {
|
|
65
|
-
return this.useMarkdown ? `[${text}](${url})` : terminalLink(text, url, {
|
|
66
|
-
fallback: fallbackToUrl ? (_text, url) => url : fallback
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
return text;
|
|
70
|
-
}
|
|
71
|
-
indent(...args) {
|
|
72
|
-
return indentString(...args);
|
|
73
|
-
}
|
|
74
|
-
italic(text) {
|
|
75
|
-
return this.useMarkdown ? `_${text}_` : colors.italic(`${text}`);
|
|
76
|
-
}
|
|
77
|
-
json(value) {
|
|
78
|
-
return this.useMarkdown ? '```json\n' + JSON.stringify(value) + '\n```' : JSON.stringify(value);
|
|
79
|
-
}
|
|
80
|
-
list(items) {
|
|
81
|
-
const indentedContent = items.map(item => this.indent(item).trimStart());
|
|
82
|
-
return this.useMarkdown ? `* ${indentedContent.join('\n* ')}\n` : `${indentedContent.join('\n')}\n`;
|
|
83
|
-
}
|
|
84
|
-
get logSymbols() {
|
|
85
|
-
return this.useMarkdown ? markdownLogSymbols : npmPaths.logSymbols;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
async function findUp(name, {
|
|
90
|
-
cwd = process.cwd()
|
|
91
|
-
}) {
|
|
92
|
-
let dir = path.resolve(cwd);
|
|
93
|
-
const {
|
|
94
|
-
root
|
|
95
|
-
} = path.parse(dir);
|
|
96
|
-
const names = [name].flat();
|
|
97
|
-
while (dir && dir !== root) {
|
|
98
|
-
for (const name of names) {
|
|
99
|
-
const filePath = path.join(dir, name);
|
|
100
|
-
try {
|
|
101
|
-
// eslint-disable-next-line no-await-in-loop
|
|
102
|
-
const stats = await fs.promises.stat(filePath);
|
|
103
|
-
if (stats.isFile()) {
|
|
104
|
-
return filePath;
|
|
105
|
-
}
|
|
106
|
-
} catch {}
|
|
107
|
-
}
|
|
108
|
-
dir = path.dirname(dir);
|
|
109
|
-
}
|
|
110
|
-
return undefined;
|
|
111
|
-
}
|
|
112
|
-
async function readFileBinary(filepath, options) {
|
|
113
|
-
return await fs.promises.readFile(filepath, {
|
|
114
|
-
...options,
|
|
115
|
-
encoding: 'binary'
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
async function readFileUtf8(filepath, options) {
|
|
119
|
-
return await fs.promises.readFile(filepath, {
|
|
120
|
-
...options,
|
|
121
|
-
encoding: 'utf8'
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
function safeReadFile(...args) {
|
|
125
|
-
try {
|
|
126
|
-
return fs.promises.readFile(...args);
|
|
127
|
-
} catch {}
|
|
128
|
-
return undefined;
|
|
129
|
-
}
|
|
130
|
-
function safeReadFileSync(...args) {
|
|
131
|
-
try {
|
|
132
|
-
return fs.readFileSync(...args);
|
|
133
|
-
} catch {}
|
|
134
|
-
return undefined;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
const LOCALAPPDATA = 'LOCALAPPDATA';
|
|
138
|
-
let _settings;
|
|
139
|
-
function getSettings() {
|
|
140
|
-
if (_settings === undefined) {
|
|
141
|
-
_settings = {};
|
|
142
|
-
const settingsPath = getSettingsPath();
|
|
143
|
-
if (settingsPath) {
|
|
144
|
-
const raw = safeReadFileSync(settingsPath, 'utf8');
|
|
145
|
-
if (raw) {
|
|
146
|
-
try {
|
|
147
|
-
Object.assign(_settings, JSON.parse(Buffer.from(raw, 'base64').toString()));
|
|
148
|
-
} catch {
|
|
149
|
-
npmPaths.logger.warn(`Failed to parse settings at ${settingsPath}`);
|
|
150
|
-
}
|
|
151
|
-
} else {
|
|
152
|
-
fs.mkdirSync(path.dirname(settingsPath), {
|
|
153
|
-
recursive: true
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
return _settings;
|
|
159
|
-
}
|
|
160
|
-
let _settingsPath;
|
|
161
|
-
let _warnedSettingPathWin32Missing = false;
|
|
162
|
-
function getSettingsPath() {
|
|
163
|
-
if (_settingsPath === undefined) {
|
|
164
|
-
// Lazily access constants.WIN32.
|
|
165
|
-
const {
|
|
166
|
-
WIN32
|
|
167
|
-
} = constants;
|
|
168
|
-
let dataHome = WIN32 ? process.env[LOCALAPPDATA] : process.env['XDG_DATA_HOME'];
|
|
169
|
-
if (!dataHome) {
|
|
170
|
-
if (WIN32) {
|
|
171
|
-
if (!_warnedSettingPathWin32Missing) {
|
|
172
|
-
_warnedSettingPathWin32Missing = true;
|
|
173
|
-
npmPaths.logger.warn(`Missing %${LOCALAPPDATA}%`);
|
|
174
|
-
}
|
|
175
|
-
} else {
|
|
176
|
-
dataHome = path.join(os.homedir(), ...(process.platform === 'darwin' ? ['Library', 'Application Support'] : ['.local', 'share']));
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
_settingsPath = dataHome ? path.join(dataHome, 'socket', 'settings') : undefined;
|
|
180
|
-
}
|
|
181
|
-
return _settingsPath;
|
|
182
|
-
}
|
|
183
|
-
function findSocketYmlSync() {
|
|
184
|
-
let prevDir = null;
|
|
185
|
-
let dir = process.cwd();
|
|
186
|
-
while (dir !== prevDir) {
|
|
187
|
-
let ymlPath = path.join(dir, 'socket.yml');
|
|
188
|
-
let yml = safeReadFileSync(ymlPath, 'utf8');
|
|
189
|
-
if (yml === undefined) {
|
|
190
|
-
ymlPath = path.join(dir, 'socket.yaml');
|
|
191
|
-
yml = safeReadFileSync(ymlPath, 'utf8');
|
|
192
|
-
}
|
|
193
|
-
if (typeof yml === 'string') {
|
|
194
|
-
try {
|
|
195
|
-
return {
|
|
196
|
-
path: ymlPath,
|
|
197
|
-
parsed: config.parseSocketConfig(yml)
|
|
198
|
-
};
|
|
199
|
-
} catch {
|
|
200
|
-
throw new Error(`Found file but was unable to parse ${ymlPath}`);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
prevDir = dir;
|
|
204
|
-
dir = path.join(dir, '..');
|
|
205
|
-
}
|
|
206
|
-
return null;
|
|
207
|
-
}
|
|
208
|
-
function getSetting(key) {
|
|
209
|
-
return getSettings()[key];
|
|
210
|
-
}
|
|
211
|
-
let pendingSave = false;
|
|
212
|
-
function updateSetting(key, value) {
|
|
213
|
-
const settings = getSettings();
|
|
214
|
-
settings[key] = value;
|
|
215
|
-
if (!pendingSave) {
|
|
216
|
-
pendingSave = true;
|
|
217
|
-
process.nextTick(() => {
|
|
218
|
-
pendingSave = false;
|
|
219
|
-
const settingsPath = getSettingsPath();
|
|
220
|
-
if (settingsPath) {
|
|
221
|
-
fs.writeFileSync(settingsPath, Buffer.from(JSON.stringify(settings)).toString('base64'));
|
|
222
|
-
}
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
// The API server that should be used for operations.
|
|
228
|
-
function getDefaultApiBaseUrl() {
|
|
229
|
-
const baseUrl = process.env['SOCKET_SECURITY_API_BASE_URL'] || getSetting('apiBaseUrl');
|
|
230
|
-
return strings.isNonEmptyString(baseUrl) ? baseUrl : undefined;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
// The API server that should be used for operations.
|
|
234
|
-
function getDefaultHttpProxy() {
|
|
235
|
-
const apiProxy = process.env['SOCKET_SECURITY_API_PROXY'] || getSetting('apiProxy');
|
|
236
|
-
return strings.isNonEmptyString(apiProxy) ? apiProxy : undefined;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
// This API key should be stored globally for the duration of the CLI execution.
|
|
240
|
-
let _defaultToken;
|
|
241
|
-
function getDefaultToken() {
|
|
242
|
-
const key = process.env['SOCKET_SECURITY_API_TOKEN'] ||
|
|
243
|
-
// Keep 'SOCKET_SECURITY_API_KEY' as an alias of 'SOCKET_SECURITY_API_TOKEN'.
|
|
244
|
-
// TODO: Remove 'SOCKET_SECURITY_API_KEY' alias.
|
|
245
|
-
process.env['SOCKET_SECURITY_API_KEY'] ||
|
|
246
|
-
// TODO: Rename the 'apiKey' setting to 'apiToken'.
|
|
247
|
-
getSetting('apiKey') || _defaultToken;
|
|
248
|
-
_defaultToken = strings.isNonEmptyString(key) ? key : undefined;
|
|
249
|
-
return _defaultToken;
|
|
250
|
-
}
|
|
251
|
-
function getPublicToken() {
|
|
252
|
-
return getDefaultToken() ?? registryConstants.SOCKET_PUBLIC_API_TOKEN;
|
|
253
|
-
}
|
|
254
|
-
async function setupSdk(apiToken = getDefaultToken(), apiBaseUrl = getDefaultApiBaseUrl(), proxy = getDefaultHttpProxy()) {
|
|
255
|
-
if (typeof apiToken !== 'string' && isInteractive()) {
|
|
256
|
-
apiToken = await prompts.password({
|
|
257
|
-
message: 'Enter your Socket.dev API key (not saved, use socket login to persist)'
|
|
258
|
-
});
|
|
259
|
-
_defaultToken = apiToken;
|
|
260
|
-
}
|
|
261
|
-
if (!apiToken) {
|
|
262
|
-
throw new AuthError('You need to provide an API key');
|
|
263
|
-
}
|
|
264
|
-
return new sdk.SocketSdk(apiToken, {
|
|
265
|
-
agent: proxy ? {
|
|
266
|
-
http: new hpagent.HttpProxyAgent({
|
|
267
|
-
proxy
|
|
268
|
-
}),
|
|
269
|
-
https: new hpagent.HttpsProxyAgent({
|
|
270
|
-
proxy
|
|
271
|
-
})
|
|
272
|
-
} : undefined,
|
|
273
|
-
baseUrl: apiBaseUrl,
|
|
274
|
-
// Lazily access constants.rootPkgJsonPath.
|
|
275
|
-
userAgent: sdk.createUserAgentFromPkgJson(require(constants.rootPkgJsonPath))
|
|
276
|
-
});
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
function getSocketDevAlertUrl(alertType) {
|
|
280
|
-
return `https://socket.dev/alerts/${alertType}`;
|
|
281
|
-
}
|
|
282
|
-
function getSocketDevPackageOverviewUrl(eco, name, version) {
|
|
283
|
-
return `https://socket.dev/${eco}/package/${name}${version ? `/overview/${version}` : ''}`;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
exports.AuthError = AuthError;
|
|
287
|
-
exports.ColorOrMarkdown = ColorOrMarkdown;
|
|
288
|
-
exports.InputError = InputError;
|
|
289
|
-
exports.findSocketYmlSync = findSocketYmlSync;
|
|
290
|
-
exports.findUp = findUp;
|
|
291
|
-
exports.getDefaultToken = getDefaultToken;
|
|
292
|
-
exports.getPublicToken = getPublicToken;
|
|
293
|
-
exports.getSetting = getSetting;
|
|
294
|
-
exports.getSocketDevAlertUrl = getSocketDevAlertUrl;
|
|
295
|
-
exports.getSocketDevPackageOverviewUrl = getSocketDevPackageOverviewUrl;
|
|
296
|
-
exports.isErrnoException = isErrnoException;
|
|
297
|
-
exports.readFileBinary = readFileBinary;
|
|
298
|
-
exports.readFileUtf8 = readFileUtf8;
|
|
299
|
-
exports.safeReadFile = safeReadFile;
|
|
300
|
-
exports.setupSdk = setupSdk;
|
|
301
|
-
exports.updateSetting = updateSetting;
|