@socketsecurity/lib 5.23.0 → 5.25.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/CHANGELOG.md +18 -0
- package/dist/archives.js +4 -4
- package/dist/constants/socket.js +1 -1
- package/dist/debug.js +5 -5
- package/dist/dlx/manifest.js +18 -20
- package/dist/errors.js +2 -3
- package/dist/external/@npmcli/package-json/lib/read-package.js +3 -2
- package/dist/external/@npmcli/package-json.js +4125 -165
- package/dist/external/@npmcli/promise-spawn.js +3 -2
- package/dist/external/adm-zip.js +3 -2
- package/dist/external/debug.js +2 -1
- package/dist/external/external-pack.js +4 -3
- package/dist/external/fast-sort.js +2 -1
- package/dist/external/get-east-asian-width.js +3 -2
- package/dist/external/npm-pack.js +6965 -4075
- package/dist/external/p-map.js +6 -5
- package/dist/external/pico-pack.js +24 -23
- package/dist/external/supports-color.js +3 -1
- package/dist/external/tar-fs.js +9 -8
- package/dist/external/which.js +3 -2
- package/dist/external/yargs-parser.js +3 -2
- package/dist/fs.js +5 -4
- package/dist/git.js +3 -3
- package/dist/github.d.ts +3 -3
- package/dist/github.js +3 -3
- package/dist/http-request.d.ts +2 -2
- package/dist/json/edit.js +9 -9
- package/dist/json/parse.d.ts +2 -2
- package/dist/json/parse.js +2 -2
- package/dist/logger.js +5 -6
- package/dist/objects.js +28 -39
- package/dist/packages/edit.js +3 -3
- package/dist/packages/isolation.js +3 -3
- package/dist/primordials.d.ts +337 -0
- package/dist/primordials.js +828 -0
- package/dist/process-lock.js +11 -11
- package/dist/releases/github.js +4 -4
- package/dist/signal-exit.js +4 -4
- package/dist/spawn.d.ts +13 -13
- package/dist/stdio/stderr.d.ts +2 -2
- package/dist/suppress-warnings.js +2 -2
- package/package.json +12 -8
- package/dist/env/socket-cli-shadow.d.ts +0 -77
- package/dist/env/socket-cli-shadow.js +0 -59
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,24 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [5.25.0](https://github.com/SocketDev/socket-lib/releases/tag/v5.25.0) - 2026-04-26
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- `@socketsecurity/lib/primordials` — new public module exposing safe references to ~100 built-in constructors, static methods, and prototype methods captured at module-load time. Mirrors the Node.js-internal primordials convention: static methods retain their name (`ObjectKeys`, `ArrayIsArray`, `JSONParse`, `ReflectApply`); prototype methods are uncurried via `uncurryThis` (`StringPrototypeSlice(str, 0, 3)` instead of `str.slice(0, 3)`); constructors get a `Ctor` suffix (`MapCtor`, `SetCtor`, `ErrorCtor`, …) to avoid shadowing the capital-case global. Library internals migrated to use these helpers so prototype-pollution attacks on the caller realm can't redirect them. Surface includes `Function`, `Math`, and the full Error subclass set (`TypeErrorCtor`, `RangeErrorCtor`, `SyntaxErrorCtor`, `ReferenceErrorCtor`, `URIErrorCtor`, `EvalErrorCtor`, `AggregateErrorCtor`) after audit-driven coverage passes
|
|
13
|
+
|
|
14
|
+
## [5.24.0](https://github.com/SocketDev/socket-lib/releases/tag/v5.24.0) - 2026-04-22
|
|
15
|
+
|
|
16
|
+
### Removed
|
|
17
|
+
|
|
18
|
+
- `@socketsecurity/lib/env/socket-cli-shadow` — deleted. Unused after Socket CLI's shadow infrastructure was removed
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
|
|
22
|
+
- `packPackage()` / `extractPackage()` now work for non-registry specs (local dir/tarball, remote tarball URL, git). The bundled pacote fetchers (`dir.js`, `file.js`, `remote.js`, `git.js`) were over-stubbed and broke every non-registry path
|
|
23
|
+
- `EditablePackageJson.prepare()` no longer throws `git.find is not a function`. `@npmcli/git` is reached from `normalize.gitHead`, not just `arb.audit()`, so it can't be stubbed
|
|
24
|
+
- `packPackage(<dir>)` now runs `prepack` / `postpack` scripts instead of throwing `runScript is not a function`. `@npmcli/run-script` is reachable whenever `ignoreScripts` isn't set
|
|
25
|
+
|
|
8
26
|
## [5.23.0](https://github.com/SocketDev/socket-lib/releases/tag/v5.23.0) - 2026-04-22
|
|
9
27
|
|
|
10
28
|
### Added
|
package/dist/archives.js
CHANGED
|
@@ -212,9 +212,9 @@ async function extractTar(archivePath, outputDir, options = {}) {
|
|
|
212
212
|
const readStream = (0, import_node_fs.createReadStream)(archivePath);
|
|
213
213
|
try {
|
|
214
214
|
await (0, import_promises.pipeline)(readStream, extractStream);
|
|
215
|
-
} catch (
|
|
215
|
+
} catch (e) {
|
|
216
216
|
readStream.destroy();
|
|
217
|
-
throw
|
|
217
|
+
throw e;
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
220
|
async function extractTarGz(archivePath, outputDir, options = {}) {
|
|
@@ -304,9 +304,9 @@ async function extractTarGz(archivePath, outputDir, options = {}) {
|
|
|
304
304
|
const readStream = (0, import_node_fs.createReadStream)(archivePath);
|
|
305
305
|
try {
|
|
306
306
|
await (0, import_promises.pipeline)(readStream, (0, import_node_zlib.createGunzip)(), extractStream);
|
|
307
|
-
} catch (
|
|
307
|
+
} catch (e) {
|
|
308
308
|
readStream.destroy();
|
|
309
|
-
throw
|
|
309
|
+
throw e;
|
|
310
310
|
}
|
|
311
311
|
}
|
|
312
312
|
async function extractZip(archivePath, outputDir, options = {}) {
|
package/dist/constants/socket.js
CHANGED
|
@@ -77,7 +77,7 @@ const SOCKET_FIREWALL_APP_NAME = "sfw";
|
|
|
77
77
|
const SOCKET_REGISTRY_APP_NAME = "registry";
|
|
78
78
|
const SOCKET_APP_PREFIX = "_";
|
|
79
79
|
const SOCKET_LIB_NAME = "@socketsecurity/lib";
|
|
80
|
-
const SOCKET_LIB_VERSION = "5.
|
|
80
|
+
const SOCKET_LIB_VERSION = "5.25.0";
|
|
81
81
|
const SOCKET_LIB_URL = "https://github.com/SocketDev/socket-lib";
|
|
82
82
|
const SOCKET_LIB_USER_AGENT = `socketsecurity-lib/${SOCKET_LIB_VERSION} (${SOCKET_LIB_URL})`;
|
|
83
83
|
const SOCKET_IPC_HANDSHAKE = "SOCKET_IPC_HANDSHAKE";
|
package/dist/debug.js
CHANGED
|
@@ -50,9 +50,9 @@ var import_is_unicode_supported = __toESM(require("./external/@socketregistry/is
|
|
|
50
50
|
var import_debug2 = __toESM(require("./external/debug"));
|
|
51
51
|
var import_logger = require("./logger");
|
|
52
52
|
var import_objects = require("./objects");
|
|
53
|
+
var import_primordials = require("./primordials");
|
|
53
54
|
var import_spinner = require("./spinner");
|
|
54
55
|
var import_strings = require("./strings");
|
|
55
|
-
const ReflectApply = Reflect.apply;
|
|
56
56
|
const logger = (0, import_logger.getDefaultLogger)();
|
|
57
57
|
const debugByNamespace = /* @__PURE__ */ new Map();
|
|
58
58
|
let _util;
|
|
@@ -65,7 +65,7 @@ function customLog(...args) {
|
|
|
65
65
|
showHidden: import_debug2.default.inspectOpts.showHidden === null ? void 0 : import_debug2.default.inspectOpts.showHidden,
|
|
66
66
|
depth: import_debug2.default.inspectOpts.depth === null || typeof import_debug2.default.inspectOpts.depth === "boolean" ? void 0 : import_debug2.default.inspectOpts.depth
|
|
67
67
|
} : {};
|
|
68
|
-
ReflectApply(logger.info, logger, [
|
|
68
|
+
(0, import_primordials.ReflectApply)(logger.info, logger, [
|
|
69
69
|
util.formatWithOptions(inspectOpts, ...args)
|
|
70
70
|
]);
|
|
71
71
|
}
|
|
@@ -189,7 +189,7 @@ function debugCacheNs(namespacesOrOpts, operation, key, meta) {
|
|
|
189
189
|
const spinnerInstance = options.spinner || (0, import_spinner.getDefaultSpinner)();
|
|
190
190
|
const wasSpinning = spinnerInstance?.isSpinning;
|
|
191
191
|
spinnerInstance?.stop();
|
|
192
|
-
ReflectApply(logger.info, logger, logArgs);
|
|
192
|
+
(0, import_primordials.ReflectApply)(logger.info, logger, logArgs);
|
|
193
193
|
if (wasSpinning) {
|
|
194
194
|
spinnerInstance?.start();
|
|
195
195
|
}
|
|
@@ -253,7 +253,7 @@ function debugLogNs(namespacesOrOpts, ...args) {
|
|
|
253
253
|
const spinnerInstance = options.spinner || (0, import_spinner.getDefaultSpinner)();
|
|
254
254
|
const wasSpinning = spinnerInstance?.isSpinning;
|
|
255
255
|
spinnerInstance?.stop();
|
|
256
|
-
ReflectApply(logger.info, logger, logArgs);
|
|
256
|
+
(0, import_primordials.ReflectApply)(logger.info, logger, logArgs);
|
|
257
257
|
if (wasSpinning) {
|
|
258
258
|
spinnerInstance?.start();
|
|
259
259
|
}
|
|
@@ -285,7 +285,7 @@ function debugNs(namespacesOrOpts, ...args) {
|
|
|
285
285
|
const spinnerInstance = options.spinner || (0, import_spinner.getDefaultSpinner)();
|
|
286
286
|
const wasSpinning = spinnerInstance?.isSpinning;
|
|
287
287
|
spinnerInstance?.stop();
|
|
288
|
-
ReflectApply(logger.info, logger, logArgs);
|
|
288
|
+
(0, import_primordials.ReflectApply)(logger.info, logger, logArgs);
|
|
289
289
|
if (wasSpinning) {
|
|
290
290
|
spinnerInstance?.start();
|
|
291
291
|
}
|
package/dist/dlx/manifest.js
CHANGED
|
@@ -79,8 +79,8 @@ class DlxManifest {
|
|
|
79
79
|
return { __proto__: null };
|
|
80
80
|
}
|
|
81
81
|
return JSON.parse(content);
|
|
82
|
-
} catch (
|
|
83
|
-
logger.warn(`Failed to read manifest: ${(0, import_errors.errorMessage)(
|
|
82
|
+
} catch (e) {
|
|
83
|
+
logger.warn(`Failed to read manifest: ${(0, import_errors.errorMessage)(e)}`);
|
|
84
84
|
return { __proto__: null };
|
|
85
85
|
}
|
|
86
86
|
}
|
|
@@ -92,22 +92,22 @@ class DlxManifest {
|
|
|
92
92
|
const manifestDir = path.dirname(this.manifestPath);
|
|
93
93
|
try {
|
|
94
94
|
(0, import_fs.safeMkdirSync)(manifestDir, { recursive: true });
|
|
95
|
-
} catch (
|
|
96
|
-
logger.warn(`Failed to create manifest directory: ${(0, import_errors.errorMessage)(
|
|
95
|
+
} catch (e) {
|
|
96
|
+
logger.warn(`Failed to create manifest directory: ${(0, import_errors.errorMessage)(e)}`);
|
|
97
97
|
}
|
|
98
98
|
const content = JSON.stringify(data, null, 2);
|
|
99
99
|
const tempPath = `${this.manifestPath}.tmp`;
|
|
100
100
|
try {
|
|
101
101
|
fs.writeFileSync(tempPath, content, "utf8");
|
|
102
102
|
fs.renameSync(tempPath, this.manifestPath);
|
|
103
|
-
} catch (
|
|
103
|
+
} catch (e) {
|
|
104
104
|
try {
|
|
105
105
|
if (fs.existsSync(tempPath)) {
|
|
106
106
|
fs.unlinkSync(tempPath);
|
|
107
107
|
}
|
|
108
108
|
} catch {
|
|
109
109
|
}
|
|
110
|
-
throw
|
|
110
|
+
throw e;
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
/**
|
|
@@ -126,8 +126,8 @@ class DlxManifest {
|
|
|
126
126
|
const data = JSON.parse(content);
|
|
127
127
|
delete data[name];
|
|
128
128
|
await this.writeManifest(data);
|
|
129
|
-
} catch (
|
|
130
|
-
logger.warn(`Failed to clear cache for ${name}: ${(0, import_errors.errorMessage)(
|
|
129
|
+
} catch (e) {
|
|
130
|
+
logger.warn(`Failed to clear cache for ${name}: ${(0, import_errors.errorMessage)(e)}`);
|
|
131
131
|
}
|
|
132
132
|
});
|
|
133
133
|
}
|
|
@@ -140,8 +140,8 @@ class DlxManifest {
|
|
|
140
140
|
if (fs.existsSync(this.manifestPath)) {
|
|
141
141
|
fs.unlinkSync(this.manifestPath);
|
|
142
142
|
}
|
|
143
|
-
} catch (
|
|
144
|
-
logger.warn(`Failed to clear all cache: ${(0, import_errors.errorMessage)(
|
|
143
|
+
} catch (e) {
|
|
144
|
+
logger.warn(`Failed to clear all cache: ${(0, import_errors.errorMessage)(e)}`);
|
|
145
145
|
}
|
|
146
146
|
});
|
|
147
147
|
}
|
|
@@ -172,8 +172,8 @@ class DlxManifest {
|
|
|
172
172
|
}
|
|
173
173
|
const data = JSON.parse(content);
|
|
174
174
|
return Object.keys(data);
|
|
175
|
-
} catch (
|
|
176
|
-
logger.warn(`Failed to get package list: ${(0, import_errors.errorMessage)(
|
|
175
|
+
} catch (e) {
|
|
176
|
+
logger.warn(`Failed to get package list: ${(0, import_errors.errorMessage)(e)}`);
|
|
177
177
|
return [];
|
|
178
178
|
}
|
|
179
179
|
}
|
|
@@ -214,31 +214,29 @@ class DlxManifest {
|
|
|
214
214
|
data = JSON.parse(content2);
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
|
-
} catch (
|
|
218
|
-
logger.warn(`Failed to read existing manifest: ${(0, import_errors.errorMessage)(
|
|
217
|
+
} catch (e) {
|
|
218
|
+
logger.warn(`Failed to read existing manifest: ${(0, import_errors.errorMessage)(e)}`);
|
|
219
219
|
}
|
|
220
220
|
data[name] = record;
|
|
221
221
|
const manifestDir = path.dirname(this.manifestPath);
|
|
222
222
|
try {
|
|
223
223
|
(0, import_fs.safeMkdirSync)(manifestDir, { recursive: true });
|
|
224
|
-
} catch (
|
|
225
|
-
logger.warn(
|
|
226
|
-
`Failed to create manifest directory: ${(0, import_errors.errorMessage)(error)}`
|
|
227
|
-
);
|
|
224
|
+
} catch (e) {
|
|
225
|
+
logger.warn(`Failed to create manifest directory: ${(0, import_errors.errorMessage)(e)}`);
|
|
228
226
|
}
|
|
229
227
|
const content = JSON.stringify(data, null, 2);
|
|
230
228
|
const tempPath = `${this.manifestPath}.tmp`;
|
|
231
229
|
try {
|
|
232
230
|
fs.writeFileSync(tempPath, content, "utf8");
|
|
233
231
|
fs.renameSync(tempPath, this.manifestPath);
|
|
234
|
-
} catch (
|
|
232
|
+
} catch (e) {
|
|
235
233
|
try {
|
|
236
234
|
if (fs.existsSync(tempPath)) {
|
|
237
235
|
fs.unlinkSync(tempPath);
|
|
238
236
|
}
|
|
239
237
|
} catch {
|
|
240
238
|
}
|
|
241
|
-
throw
|
|
239
|
+
throw e;
|
|
242
240
|
}
|
|
243
241
|
});
|
|
244
242
|
}
|
package/dist/errors.js
CHANGED
|
@@ -33,13 +33,12 @@ __export(errors_exports, {
|
|
|
33
33
|
module.exports = __toCommonJS(errors_exports);
|
|
34
34
|
var import_core = require("./constants/core");
|
|
35
35
|
var import_pony_cause = require("./external/pony-cause");
|
|
36
|
-
|
|
37
|
-
const ReflectApply = Reflect.apply;
|
|
36
|
+
var import_primordials = require("./primordials");
|
|
38
37
|
function isErrorShim(value) {
|
|
39
38
|
if (value === null || typeof value !== "object") {
|
|
40
39
|
return false;
|
|
41
40
|
}
|
|
42
|
-
return
|
|
41
|
+
return (0, import_primordials.ObjectPrototypeToString)(value) === "[object Error]";
|
|
43
42
|
}
|
|
44
43
|
const isErrorBuiltin = Error.isError;
|
|
45
44
|
const isError = isErrorBuiltin ?? isErrorShim;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const { SymbolFor: _p_SymbolFor } = require('../../../../primordials.js')
|
|
1
2
|
"use strict";
|
|
2
3
|
/**
|
|
3
4
|
* Bundled from @npmcli/package-json/lib/read-package.js
|
|
@@ -15,8 +16,8 @@ var __commonJS = (cb, mod) => function __require() {
|
|
|
15
16
|
var require_lib = __commonJS({
|
|
16
17
|
"node_modules/.pnpm/json-parse-even-better-errors@5.0.0/node_modules/json-parse-even-better-errors/lib/index.js"(exports2, module2) {
|
|
17
18
|
"use strict";
|
|
18
|
-
var INDENT =
|
|
19
|
-
var NEWLINE =
|
|
19
|
+
var INDENT = _p_SymbolFor("indent");
|
|
20
|
+
var NEWLINE = _p_SymbolFor("newline");
|
|
20
21
|
var DEFAULT_NEWLINE = "\n";
|
|
21
22
|
var DEFAULT_INDENT = " ";
|
|
22
23
|
var BOM = /^\uFEFF/;
|