@socketsecurity/lib 6.0.9 → 6.0.10
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 +6 -0
- package/README.md +8 -9
- package/dist/abort/signal.d.ts +1 -1
- package/dist/abort/signal.js +1 -1
- package/dist/ai/agent-context.d.mts +1 -1
- package/dist/ai/agent-context.js +3 -2
- package/dist/ai/backends.d.mts +3 -3
- package/dist/ai/backends.js +2 -2
- package/dist/ai/billing-context.d.mts +74 -0
- package/dist/ai/billing-context.js +129 -0
- package/dist/ai/credentials.d.mts +39 -5
- package/dist/ai/credentials.js +61 -6
- package/dist/ai/discover.d.mts +4 -0
- package/dist/ai/discover.js +4 -0
- package/dist/ai/exec.d.mts +1 -1
- package/dist/ai/exec.js +1 -1
- package/dist/ai/http.d.mts +8 -8
- package/dist/ai/http.js +6 -6
- package/dist/ai/profiles.d.mts +9 -10
- package/dist/ai/profiles.js +0 -5
- package/dist/ai/role.d.mts +58 -0
- package/dist/ai/role.js +96 -0
- package/dist/ai/route-heuristic.d.mts +177 -0
- package/dist/ai/route-heuristic.js +194 -0
- package/dist/ai/route.d.mts +10 -9
- package/dist/ai/route.js +14 -13
- package/dist/ai/spawn.d.mts +2 -1
- package/dist/ai/spawn.js +25 -2
- package/dist/ai/subagent-status.d.mts +2 -0
- package/dist/ai/subagent-status.js +2 -0
- package/dist/ai/tier.d.mts +1 -1
- package/dist/ai/types.d.mts +9 -2
- package/dist/ai/worktree.d.mts +1 -1
- package/dist/ai/worktree.js +3 -2
- package/dist/argv/parse.d.ts +2 -0
- package/dist/argv/parse.js +2 -0
- package/dist/bin/_internal.d.ts +1 -1
- package/dist/bin/_internal.js +1 -1
- package/dist/bin/prim.cjs +446 -300
- package/dist/bin/shadow.js +2 -1
- package/dist/bin/which.d.ts +28 -3
- package/dist/bin/which.js +45 -3
- package/dist/cacache/_internal.d.ts +10 -2
- package/dist/cacache/_internal.js +6 -10
- package/dist/cache/ttl/_internal.d.ts +33 -0
- package/dist/cache/ttl/_internal.js +68 -0
- package/dist/cache/ttl/browser.d.ts +56 -0
- package/dist/cache/ttl/browser.js +257 -0
- package/dist/cache/ttl/store.js +10 -33
- package/dist/cache/ttl/types.d.ts +46 -3
- package/dist/checks/primordials-defaults.d.ts +5 -5
- package/dist/checks/primordials-defaults.js +5 -5
- package/dist/checks/primordials.d.ts +1 -1
- package/dist/checks/primordials.js +25 -17
- package/dist/cli/check-primordials.d.ts +6 -1
- package/dist/cli/check-primordials.js +14 -5
- package/dist/cli/check.js +1 -1
- package/dist/cli/socket-lib.d.ts +1 -1
- package/dist/cli/socket-lib.js +3 -3
- package/dist/colors/socket-palette.d.ts +1 -1
- package/dist/compression/brotli.d.ts +6 -2
- package/dist/compression/brotli.js +4 -0
- package/dist/compression/gzip.d.ts +6 -2
- package/dist/compression/gzip.js +6 -1
- package/dist/config/layers.d.ts +4 -4
- package/dist/config/layers.js +4 -4
- package/dist/constants/agents.d.ts +3 -0
- package/dist/constants/agents.js +3 -0
- package/dist/constants/node.d.ts +14 -0
- package/dist/constants/node.js +14 -0
- package/dist/constants/package-default-node-range.js +1 -5
- package/dist/constants/packages.d.ts +5 -0
- package/dist/constants/packages.js +5 -0
- package/dist/constants/platform.d.ts +1 -1
- package/dist/constants/platform.js +1 -1
- package/dist/constants/socket.js +1 -1
- package/dist/constants/typescript.d.ts +5 -0
- package/dist/constants/typescript.js +5 -0
- package/dist/debug/_internal.d.ts +22 -7
- package/dist/debug/_internal.js +33 -15
- package/dist/debug/namespace.js +11 -8
- package/dist/debug/output.d.ts +12 -1
- package/dist/debug/output.js +33 -16
- package/dist/dlx/binary-resolution.js +7 -4
- package/dist/eco/npm/npm/parse-lockfile.js +2 -1
- package/dist/eco/npm/vlt/exec.d.ts +1 -1
- package/dist/eco/npm/vlt/exec.js +1 -1
- package/dist/env/agents.d.ts +6 -0
- package/dist/env/agents.js +29 -0
- package/dist/env/flags.d.ts +12 -0
- package/dist/env/flags.js +23 -0
- package/dist/env/github-status.js +2 -2
- package/dist/env/providers.d.ts +6 -0
- package/dist/env/providers.js +23 -0
- package/dist/env/proxy.js +1 -1
- package/dist/env/rewire.d.ts +32 -0
- package/dist/env/rewire.js +55 -23
- package/dist/env/runtimes.d.ts +9 -0
- package/dist/env/runtimes.js +53 -0
- package/dist/env/socket-cli.d.ts +5 -2
- package/dist/env/socket-cli.js +6 -3
- package/dist/errors/predicates.d.ts +3 -2
- package/dist/errors/predicates.js +5 -3
- package/dist/errors/stack.js +2 -1
- package/dist/events/exit/_internal.d.ts +1 -23
- package/dist/external/@npmcli/package-json.js +179 -88
- package/dist/external/@npmcli/promise-spawn.js +2 -2
- package/dist/external/@sinclair/typebox/value.js +5 -4
- package/dist/external/@socketregistry/yocto-spinner.js +3 -3
- package/dist/external/adm-zip.d.ts +82 -0
- package/dist/external/adm-zip.js +2 -2
- package/dist/external/cacache.d.ts +87 -0
- package/dist/external/debug.d.ts +22 -0
- package/dist/external/debug.js +11 -4
- package/dist/external/del.d.ts +1 -0
- package/dist/external/external-pack.d.ts +12 -0
- package/dist/external/external-pack.js +41 -34
- package/dist/external/fast-glob.d.ts +8 -0
- package/dist/external/fast-sort.d.ts +1 -0
- package/dist/external/get-east-asian-width.d.ts +5 -0
- package/dist/external/get-east-asian-width.js +8 -1
- package/dist/external/has-flag.d.ts +1 -0
- package/dist/external/inquirer-pack.d.ts +18 -0
- package/dist/external/libnpmexec.d.ts +35 -0
- package/dist/external/libnpmpack.d.ts +1 -0
- package/dist/external/make-fetch-happen.d.ts +13 -0
- package/dist/external/normalize-package-data.d.ts +4 -0
- package/dist/external/npm-core.d.ts +14 -0
- package/dist/external/npm-pack.d.ts +24 -0
- package/dist/external/npm-pack.js +1551 -1867
- package/dist/external/npm-package-arg.d.ts +4 -0
- package/dist/external/p-map.js +8 -1
- package/dist/external/pacote.d.ts +15 -0
- package/dist/external/pico-pack.d.ts +16 -0
- package/dist/external/pico-pack.js +38 -23
- package/dist/external/picomatch.d.ts +96 -0
- package/dist/external/pony-cause.d.ts +14 -0
- package/dist/external/semver.d.ts +60 -0
- package/dist/external/semver.js +1459 -4
- package/dist/external/shell-quote.d.ts +51 -0
- package/dist/external/shell-quote.js +55 -15
- package/dist/external/signal-exit.d.ts +1 -0
- package/dist/external/spdx-correct.d.ts +4 -0
- package/dist/external/spdx-expression-parse.d.ts +4 -0
- package/dist/external/spdx-pack.d.ts +10 -0
- package/dist/external/std-env.d.ts +284 -0
- package/dist/external/std-env.js +323 -0
- package/dist/external/streaming-iterables.d.ts +11 -0
- package/dist/external/supports-color.d.ts +1 -0
- package/dist/external/tar-fs.d.ts +31 -0
- package/dist/external/validate-npm-package-name.d.ts +4 -0
- package/dist/external/which.d.ts +25 -0
- package/dist/external/which.js +2 -2
- package/dist/external/yargs-parser.d.ts +2 -0
- package/dist/external/yargs-parser.js +11 -3
- package/dist/external/yoctocolors-cjs.d.ts +51 -0
- package/dist/external-tools/bazel/asset-names.d.ts +1 -1
- package/dist/external-tools/bazel/from-download.d.ts +1 -1
- package/dist/external-tools/bazel/resolve.d.ts +3 -0
- package/dist/external-tools/bazel/resolve.js +3 -0
- package/dist/external-tools/cdxgen/asset-names.d.ts +5 -5
- package/dist/external-tools/cdxgen/asset-names.js +3 -3
- package/dist/external-tools/cdxgen/from-download.d.ts +2 -2
- package/dist/external-tools/cdxgen/from-download.js +1 -1
- package/dist/external-tools/cdxgen/resolve.d.ts +4 -1
- package/dist/external-tools/cdxgen/resolve.js +4 -1
- package/dist/external-tools/cdxgen/types.d.ts +1 -1
- package/dist/external-tools/from-download.d.ts +2 -2
- package/dist/external-tools/from-download.js +1 -1
- package/dist/external-tools/janus/asset-names.d.ts +4 -1
- package/dist/external-tools/janus/asset-names.js +3 -0
- package/dist/external-tools/janus/from-download.d.ts +3 -3
- package/dist/external-tools/janus/from-download.js +2 -2
- package/dist/external-tools/janus/resolve.d.ts +3 -0
- package/dist/external-tools/janus/resolve.js +3 -0
- package/dist/external-tools/jre/asset-names.d.ts +3 -1
- package/dist/external-tools/jre/asset-names.js +2 -0
- package/dist/external-tools/jre/from-download.d.ts +1 -1
- package/dist/external-tools/manifest.d.ts +5 -3
- package/dist/external-tools/manifest.js +4 -2
- package/dist/external-tools/opengrep/asset-names.d.ts +1 -1
- package/dist/external-tools/opengrep/resolve.d.ts +3 -0
- package/dist/external-tools/opengrep/resolve.js +3 -0
- package/dist/external-tools/python/asset-names.d.ts +3 -1
- package/dist/external-tools/python/asset-names.js +7 -3
- package/dist/external-tools/python/pin.js +3 -1
- package/dist/external-tools/python/resolve.d.ts +3 -0
- package/dist/external-tools/python/resolve.js +3 -0
- package/dist/external-tools/sbt/resolve.d.ts +3 -0
- package/dist/external-tools/sbt/resolve.js +3 -0
- package/dist/external-tools/skillspector/from-uv.d.ts +1 -1
- package/dist/external-tools/synp/resolve.d.ts +3 -0
- package/dist/external-tools/synp/resolve.js +3 -0
- package/dist/external-tools/trivy/asset-names.d.ts +1 -1
- package/dist/external-tools/trivy/resolve.d.ts +3 -0
- package/dist/external-tools/trivy/resolve.js +3 -0
- package/dist/external-tools/trufflehog/asset-names.d.ts +4 -1
- package/dist/external-tools/trufflehog/asset-names.js +3 -0
- package/dist/external-tools/trufflehog/from-download.d.ts +1 -1
- package/dist/external-tools/trufflehog/resolve.d.ts +3 -0
- package/dist/external-tools/trufflehog/resolve.js +3 -0
- package/dist/external-tools/uv/asset-names.d.ts +1 -1
- package/dist/external-tools/uv/resolve.d.ts +3 -0
- package/dist/external-tools/uv/resolve.js +3 -0
- package/dist/fleet/repo-config.d.ts +8 -6
- package/dist/fleet/repo-config.js +8 -6
- package/dist/fs/_internal.d.ts +1 -1
- package/dist/fs/_internal.js +1 -1
- package/dist/fs/access.d.ts +2 -0
- package/dist/fs/access.js +2 -0
- package/dist/fs/allowed-dirs-cache.js +5 -3
- package/dist/fs/find.js +1 -2
- package/dist/fs/inspect.d.ts +2 -2
- package/dist/fs/read-file.js +3 -4
- package/dist/fs/safe.js +1 -1
- package/dist/git/_internal.js +5 -1
- package/dist/github/commit.d.ts +92 -0
- package/dist/github/commit.js +113 -0
- package/dist/github/ghsa.js +1 -1
- package/dist/github/refs-graphql.js +1 -1
- package/dist/github/request.js +1 -1
- package/dist/github/token.d.ts +5 -2
- package/dist/github/token.js +6 -4
- package/dist/github/workflow-runs.d.ts +107 -0
- package/dist/github/workflow-runs.js +98 -0
- package/dist/http-request/_internal.d.ts +1 -1
- package/dist/http-request/browser.d.ts +6 -0
- package/dist/http-request/browser.js +3 -2
- package/dist/http-request/download.js +2 -0
- package/dist/http-request/headers.d.ts +1 -1
- package/dist/http-request/headers.js +1 -1
- package/dist/http-request/request-attempt.js +6 -3
- package/dist/http-request/request-types.d.ts +10 -1
- package/dist/http-request/request.js +2 -2
- package/dist/http-request/user-agent.d.ts +23 -2
- package/dist/http-request/user-agent.js +48 -6
- package/dist/integrity.d.ts +3 -1
- package/dist/integrity.js +3 -1
- package/dist/json/format.js +4 -1
- package/dist/logger/_internal.d.ts +13 -15
- package/dist/logger/_internal.js +21 -21
- package/dist/logger/colors.d.ts +9 -3
- package/dist/logger/colors.js +6 -13
- package/dist/logger/console-methods.js +2 -2
- package/dist/logger/console.d.ts +1 -0
- package/dist/logger/console.js +9 -9
- package/dist/logger/node.js +2 -1
- package/dist/native-messaging/install.js +1 -1
- package/dist/native-messaging/rate-limit.d.ts +4 -1
- package/dist/native-messaging/rate-limit.js +4 -1
- package/dist/node/events.d.ts +3 -0
- package/dist/node/events.js +3 -0
- package/dist/node/fs.d.ts +1 -1
- package/dist/node/timers-promises.d.ts +3 -0
- package/dist/node/timers-promises.js +3 -0
- package/dist/node/url.d.ts +3 -0
- package/dist/node/url.js +3 -0
- package/dist/npm/meta-cache.d.ts +183 -0
- package/dist/npm/meta-cache.js +318 -0
- package/dist/npm/meta-slice.d.ts +27 -0
- package/dist/npm/meta-slice.js +68 -0
- package/dist/npm/meta-types.d.ts +282 -0
- package/dist/npm/meta-types.js +2 -0
- package/dist/npm/meta.d.ts +125 -0
- package/dist/npm/meta.js +347 -0
- package/dist/npm/registry.d.ts +212 -0
- package/dist/npm/registry.js +284 -0
- package/dist/objects/getters.d.ts +1 -1
- package/dist/objects/getters.js +1 -1
- package/dist/packages/manifest.js +6 -7
- package/dist/packages/metadata-extensions.js +2 -4
- package/dist/packages/provenance.d.ts +8 -0
- package/dist/packages/provenance.js +8 -0
- package/dist/packages/tarball.js +1 -2
- package/dist/packages/validation.d.ts +0 -10
- package/dist/packages/validation.js +0 -14
- package/dist/paths/exts.d.ts +30 -0
- package/dist/paths/exts.js +30 -0
- package/dist/paths/filenames.d.ts +6 -0
- package/dist/paths/filenames.js +6 -0
- package/dist/paths/globs.d.ts +6 -0
- package/dist/paths/globs.js +6 -0
- package/dist/paths/resolve.js +19 -14
- package/dist/paths/socket.d.ts +8 -8
- package/dist/paths/socket.js +8 -8
- package/dist/perf/report.js +4 -2
- package/dist/pkg-ext/data.js +0 -2
- package/dist/primordials/globals.d.ts +1 -1
- package/dist/primordials/globals.js +1 -1
- package/dist/primordials/headers.d.ts +13 -1
- package/dist/primordials/headers.js +13 -1
- package/dist/primordials/process.d.ts +1 -1
- package/dist/primordials/process.js +1 -1
- package/dist/primordials/url.d.ts +18 -0
- package/dist/primordials/url.js +18 -0
- package/dist/process/spawn/child.js +3 -5
- package/dist/promises/_internal.d.ts +1 -1
- package/dist/promises/_internal.js +1 -2
- package/dist/promises/options.js +3 -3
- package/dist/releases/socket-btm-binary-naming.js +12 -1
- package/dist/secrets/_internal.d.ts +1 -1
- package/dist/secrets/_internal.js +1 -1
- package/dist/secrets/find.d.ts +2 -2
- package/dist/secrets/find.js +2 -2
- package/dist/secrets/keychain.d.ts +10 -1
- package/dist/secrets/keychain.js +10 -1
- package/dist/secrets/socket-api-token.d.ts +1 -1
- package/dist/secrets/socket-api-token.js +1 -1
- package/dist/secrets/types.d.ts +1 -1
- package/dist/smol/http.d.ts +2 -0
- package/dist/smol/http.js +2 -0
- package/dist/smol/https.d.ts +2 -0
- package/dist/smol/https.js +2 -0
- package/dist/sorts/_internal.d.ts +2 -3
- package/dist/sorts/_internal.js +1 -3
- package/dist/spinner/format.js +2 -4
- package/dist/stdio/footer.js +8 -7
- package/dist/stdio/prompts.d.ts +8 -15
- package/dist/stdio/prompts.js +18 -29
- package/dist/strings/predicates.d.ts +2 -2
- package/dist/strings/search.js +1 -1
- package/dist/strings/types.d.ts +4 -0
- package/dist/strings/width.d.ts +1 -0
- package/dist/strings/width.js +17 -8
- package/dist/themes/context.d.ts +13 -0
- package/dist/themes/context.js +23 -8
- package/dist/versions/_internal.d.ts +43 -13
- package/dist/versions/_internal.js +27 -15
- package/dist/versions/compare.d.ts +16 -10
- package/dist/versions/compare.js +36 -16
- package/dist/versions/parse.js +1 -1
- package/dist/versions/range.js +3 -2
- package/dist/words/pluralize.js +4 -1
- package/llms.txt +63 -750
- package/package.json +200 -35
package/dist/cache/ttl/store.js
CHANGED
|
@@ -5,12 +5,12 @@ const require_primordials_error = require('../../primordials/error.js');
|
|
|
5
5
|
const require_primordials_string = require('../../primordials/string.js');
|
|
6
6
|
const require_primordials_math = require('../../primordials/math.js');
|
|
7
7
|
const require_primordials_map_set = require('../../primordials/map-set.js');
|
|
8
|
-
const require_primordials_regexp = require('../../primordials/regexp.js');
|
|
9
8
|
const require_primordials_date = require('../../primordials/date.js');
|
|
10
9
|
const require_primordials_json = require('../../primordials/json.js');
|
|
11
10
|
const require_cacache_clear = require('../../cacache/clear.js');
|
|
12
11
|
const require_cacache_read = require('../../cacache/read.js');
|
|
13
12
|
const require_cacache_write = require('../../cacache/write.js');
|
|
13
|
+
const require_cache_ttl__internal = require('./_internal.js');
|
|
14
14
|
|
|
15
15
|
//#region src/cache/ttl/store.ts
|
|
16
16
|
/**
|
|
@@ -30,9 +30,6 @@ const require_cacache_write = require('../../cacache/write.js');
|
|
|
30
30
|
* - Clock-skew detection: entries with suspiciously-far-future `expiresAt` are
|
|
31
31
|
* treated as expired.
|
|
32
32
|
*/
|
|
33
|
-
const DEFAULT_TTL_MS = 300 * 1e3;
|
|
34
|
-
const DEFAULT_PREFIX = "ttl-cache";
|
|
35
|
-
const DEFAULT_MEMO_MAX_SIZE = 1e3;
|
|
36
33
|
/**
|
|
37
34
|
* Create a TTL-based cache instance.
|
|
38
35
|
*
|
|
@@ -47,50 +44,30 @@ function createTtlCache(options) {
|
|
|
47
44
|
const opts = {
|
|
48
45
|
__proto__: null,
|
|
49
46
|
memoize: true,
|
|
50
|
-
memoMaxSize: DEFAULT_MEMO_MAX_SIZE,
|
|
51
|
-
prefix: DEFAULT_PREFIX,
|
|
52
|
-
ttl: DEFAULT_TTL_MS,
|
|
47
|
+
memoMaxSize: require_cache_ttl__internal.DEFAULT_MEMO_MAX_SIZE,
|
|
48
|
+
prefix: require_cache_ttl__internal.DEFAULT_PREFIX,
|
|
49
|
+
ttl: require_cache_ttl__internal.DEFAULT_TTL_MS,
|
|
53
50
|
...options
|
|
54
51
|
};
|
|
55
52
|
if (opts.prefix?.includes("*")) throw new require_primordials_error.TypeErrorCtor("Cache prefix cannot contain wildcards (*). Use clear({ prefix: \"pattern*\" }) for wildcard matching.");
|
|
56
53
|
const memoCache = new require_primordials_map_set.MapCtor();
|
|
57
|
-
const memoMaxSize = require_primordials_math.MathMax(1, opts.memoMaxSize ??
|
|
54
|
+
const memoMaxSize = require_primordials_math.MathMax(1, opts.memoMaxSize ?? 1e3);
|
|
58
55
|
function memoSet(fullKey, entry) {
|
|
59
|
-
|
|
60
|
-
if (memoCache.has(fullKey)) memoCache.delete(fullKey);
|
|
61
|
-
else if (memoCache.size >= memoMaxSize) {
|
|
62
|
-
const oldest = memoCache.keys().next().value;
|
|
63
|
-
if (oldest !== void 0) memoCache.delete(oldest);
|
|
64
|
-
}
|
|
65
|
-
/* c8 ignore stop */
|
|
66
|
-
memoCache.set(fullKey, entry);
|
|
56
|
+
require_cache_ttl__internal.lruSet(memoCache, memoMaxSize, fullKey, entry);
|
|
67
57
|
}
|
|
68
|
-
/* c8 ignore next */
|
|
69
|
-
const ttl = opts.ttl ??
|
|
58
|
+
/* c8 ignore next - default-ttl fallback arm */
|
|
59
|
+
const ttl = opts.ttl ?? 3e5;
|
|
70
60
|
/**
|
|
71
61
|
* Build full cache key with prefix.
|
|
72
62
|
*/
|
|
73
63
|
function buildKey(key) {
|
|
74
64
|
return `${opts.prefix}:${key}`;
|
|
75
65
|
}
|
|
76
|
-
/**
|
|
77
|
-
* Check if entry is expired. Also detects clock skew by treating suspiciously
|
|
78
|
-
* far-future expiresAt as expired.
|
|
79
|
-
*/
|
|
80
66
|
function isExpired(entry) {
|
|
81
|
-
|
|
82
|
-
if (entry.expiresAt > now + ttl + 1e4) return true;
|
|
83
|
-
return now > entry.expiresAt;
|
|
67
|
+
return require_cache_ttl__internal.isExpiredEntry(entry, ttl);
|
|
84
68
|
}
|
|
85
|
-
/**
|
|
86
|
-
* Create a matcher function for a pattern (with wildcard support). Returns a
|
|
87
|
-
* function that tests if a key matches the pattern.
|
|
88
|
-
*/
|
|
89
69
|
function createMatcher(pattern) {
|
|
90
|
-
|
|
91
|
-
if (!pattern.includes("*")) return (key) => require_primordials_string.StringPrototypeStartsWith(key, fullPattern);
|
|
92
|
-
const regex = new require_primordials_regexp.RegExpCtor(`^${require_primordials_string.StringPrototypeReplaceAll(require_primordials_string.StringPrototypeReplaceAll(fullPattern, /[.+?^${}()|[\]\\]/g, "\\$&"), "*", ".*")}$`);
|
|
93
|
-
return (key) => require_primordials_regexp.RegExpPrototypeTest(regex, key);
|
|
70
|
+
return require_cache_ttl__internal.createKeyMatcher(opts.prefix ?? "ttl-cache", pattern);
|
|
94
71
|
}
|
|
95
72
|
async function get(key) {
|
|
96
73
|
if (require_primordials_string.StringPrototypeIncludes(key, "*")) throw new require_primordials_error.TypeErrorCtor("Cache key cannot contain wildcards (*). Use getAll(pattern) to retrieve multiple entries.");
|
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file Public type surface for `cache/ttl/*` modules — the `TtlCache`
|
|
3
|
-
* interface (the seven-method API returned by `createTtlCache`
|
|
4
|
-
* `TtlCacheEntry` storage shape,
|
|
5
|
-
*
|
|
3
|
+
* interface (the seven-method API returned by `createTtlCache` and
|
|
4
|
+
* `createBrowserTtlCache`), the `TtlCacheEntry` storage shape, the
|
|
5
|
+
* `TtlCacheStorage` adapter contract for the browser store's persistent
|
|
6
|
+
* tier, and the `TtlCacheOptions` / `BrowserTtlCacheOptions` /
|
|
7
|
+
* `ClearOptions` configuration records. Pure types, no runtime side
|
|
8
|
+
* effects.
|
|
6
9
|
*/
|
|
10
|
+
export interface BrowserTtlCacheOptions extends TtlCacheOptions {
|
|
11
|
+
/**
|
|
12
|
+
* Storage adapter backing the persistent tier — wrap `chrome.storage.local`,
|
|
13
|
+
* `sessionStorage` / `localStorage`, IndexedDB, or anything else with a
|
|
14
|
+
* key-value string surface. Omit for a memo-only (in-memory) cache.
|
|
15
|
+
*/
|
|
16
|
+
storage?: TtlCacheStorage | undefined;
|
|
17
|
+
}
|
|
7
18
|
export interface ClearOptions {
|
|
8
19
|
/**
|
|
9
20
|
* Only clear in-memory memoization cache, not persistent cache. Useful for
|
|
@@ -107,3 +118,35 @@ export interface TtlCacheOptions {
|
|
|
107
118
|
*/
|
|
108
119
|
prefix?: string | undefined;
|
|
109
120
|
}
|
|
121
|
+
/**
|
|
122
|
+
* Key-value string storage adapter for `createBrowserTtlCache`'s persistent
|
|
123
|
+
* tier. Every method may be sync or async; keys are FULL (prefixed) cache
|
|
124
|
+
* keys, values are JSON-serialized `TtlCacheEntry` payloads. The shape is
|
|
125
|
+
* structurally compatible with `window.sessionStorage` / `localStorage`, and
|
|
126
|
+
* `chrome.storage.local` wraps in a few lines. Adapter failures are always
|
|
127
|
+
* swallowed by the cache — the memo tier is the source of truth.
|
|
128
|
+
*/
|
|
129
|
+
export interface TtlCacheStorage {
|
|
130
|
+
/**
|
|
131
|
+
* Read the raw serialized entry for a key. Return `null` or `undefined`
|
|
132
|
+
* for a miss (`null` is accepted so Web Storage objects satisfy the shape
|
|
133
|
+
* directly); a rejection or throw is treated as a miss.
|
|
134
|
+
*/
|
|
135
|
+
getItem(key: string): Promise<string | null | undefined> | string | null | undefined;
|
|
136
|
+
/**
|
|
137
|
+
* Optional enumeration of every key currently in the backing store. When
|
|
138
|
+
* present, wildcard operations (`getAll` / `deleteAll` / `clear`) cover
|
|
139
|
+
* entries written by previous sessions; without it they cover only the
|
|
140
|
+
* keys currently in the memo tier.
|
|
141
|
+
*/
|
|
142
|
+
keys?(): Promise<string[]> | string[];
|
|
143
|
+
/**
|
|
144
|
+
* Remove one key. Failures are swallowed (best-effort removal).
|
|
145
|
+
*/
|
|
146
|
+
removeItem(key: string): Promise<void> | void;
|
|
147
|
+
/**
|
|
148
|
+
* Persist the raw serialized entry. Failures are swallowed — the memo tier
|
|
149
|
+
* remains the source of truth.
|
|
150
|
+
*/
|
|
151
|
+
setItem(key: string, value: string): Promise<void> | void;
|
|
152
|
+
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file GENERATED — do not edit by hand. Run `node
|
|
3
|
-
* scripts/post-build/make-primordials-defaults.mts` (also runs as part
|
|
4
|
-
* `pnpm run build`) to regenerate from the `globals` npm package's
|
|
3
|
+
* scripts/repo/post-build/make-primordials-defaults.mts` (also runs as part
|
|
4
|
+
* of `pnpm run build`) to regenerate from the `globals` npm package's
|
|
5
5
|
* globals.json crossed against src/primordials/*.ts `Ctor` exports. Source:
|
|
6
6
|
* globals@<bumped via taze>, env = builtin ∪ node. Filter: identifiers
|
|
7
7
|
* socket-lib exports as `<name>Ctor`.
|
|
8
8
|
*/
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
* a `Ctor` suffix. Downstream repos that destructure raw `primordials` use
|
|
12
|
-
* map to resolve the source-side name to socket-lib's export.
|
|
10
|
+
* Socket-canonical alias map: socket-lib mirrors standard JS + Node globals
|
|
11
|
+
* with a `Ctor` suffix. Downstream repos that destructure raw `primordials` use
|
|
12
|
+
* this map to resolve the source-side name to socket-lib's export.
|
|
13
13
|
*/
|
|
14
14
|
export declare const DEFAULT_ALIAS_MAP: Readonly<Record<string, string>>;
|
|
15
15
|
/**
|
|
@@ -6,16 +6,16 @@ const require_primordials_object = require('../primordials/object.js');
|
|
|
6
6
|
//#region src/checks/primordials-defaults.ts
|
|
7
7
|
/**
|
|
8
8
|
* @file GENERATED — do not edit by hand. Run `node
|
|
9
|
-
* scripts/post-build/make-primordials-defaults.mts` (also runs as part
|
|
10
|
-
* `pnpm run build`) to regenerate from the `globals` npm package's
|
|
9
|
+
* scripts/repo/post-build/make-primordials-defaults.mts` (also runs as part
|
|
10
|
+
* of `pnpm run build`) to regenerate from the `globals` npm package's
|
|
11
11
|
* globals.json crossed against src/primordials/*.ts `Ctor` exports. Source:
|
|
12
12
|
* globals@<bumped via taze>, env = builtin ∪ node. Filter: identifiers
|
|
13
13
|
* socket-lib exports as `<name>Ctor`.
|
|
14
14
|
*/
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
17
|
-
* a `Ctor` suffix. Downstream repos that destructure raw `primordials` use
|
|
18
|
-
* map to resolve the source-side name to socket-lib's export.
|
|
16
|
+
* Socket-canonical alias map: socket-lib mirrors standard JS + Node globals
|
|
17
|
+
* with a `Ctor` suffix. Downstream repos that destructure raw `primordials` use
|
|
18
|
+
* this map to resolve the source-side name to socket-lib's export.
|
|
19
19
|
*/
|
|
20
20
|
const DEFAULT_ALIAS_MAP = require_primordials_object.ObjectFreeze({
|
|
21
21
|
__proto__: null,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @file Primordials drift check — generic core. Each
|
|
2
|
+
* @file Primordials drift check — generic core. Each Socket repo that
|
|
3
3
|
* destructures from Node's internal `primordials` global needs to keep its
|
|
4
4
|
* usage shape-aligned with socket-lib's userland mirror
|
|
5
5
|
* (`@socketsecurity/lib/primordials`). This module is the parser + diff
|
|
@@ -10,7 +10,7 @@ node_path = require_runtime.__toESM(node_path);
|
|
|
10
10
|
|
|
11
11
|
//#region src/checks/primordials.ts
|
|
12
12
|
/**
|
|
13
|
-
* @file Primordials drift check — generic core. Each
|
|
13
|
+
* @file Primordials drift check — generic core. Each Socket repo that
|
|
14
14
|
* destructures from Node's internal `primordials` global needs to keep its
|
|
15
15
|
* usage shape-aligned with socket-lib's userland mirror
|
|
16
16
|
* (`@socketsecurity/lib/primordials`). This module is the parser + diff
|
|
@@ -65,11 +65,13 @@ function checkPrimordials(config) {
|
|
|
65
65
|
}
|
|
66
66
|
const socketLibNames = readSocketLibPrimordialNames(resolveSocketLibPrimordials(config));
|
|
67
67
|
const findings = [];
|
|
68
|
-
|
|
68
|
+
const usedNames = [...used].toSorted();
|
|
69
|
+
for (let i = 0, { length } = usedNames; i < length; i += 1) {
|
|
70
|
+
const name = usedNames[i];
|
|
69
71
|
if (config.nodeInternalOnly.has(name)) continue;
|
|
70
72
|
if (socketLibNames.has(name)) continue;
|
|
71
73
|
const aliased = config.aliasMap.get(name);
|
|
72
|
-
/* c8 ignore start */
|
|
74
|
+
/* c8 ignore start - usedToFiles fallback is unreachable by construction */
|
|
73
75
|
if (aliased) {
|
|
74
76
|
if (socketLibNames.has(aliased)) continue;
|
|
75
77
|
findings.push({
|
|
@@ -140,12 +142,15 @@ function extractPrimordialsNames(src) {
|
|
|
140
142
|
const re = /const\s*\{\s*([^}]*?)\}\s*=\s*primordials\b/g;
|
|
141
143
|
const out = [];
|
|
142
144
|
let m;
|
|
143
|
-
while ((m = re.exec(cleaned)) !== null)
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
145
|
+
while ((m = re.exec(cleaned)) !== null) {
|
|
146
|
+
const rawNames = m[1].split(",");
|
|
147
|
+
for (let i = 0, { length } = rawNames; i < length; i += 1) {
|
|
148
|
+
const trimmed = rawNames[i].trim();
|
|
149
|
+
if (!trimmed) continue;
|
|
150
|
+
const nameMatch = NAME_HEAD_RE.exec(trimmed);
|
|
151
|
+
/* c8 ignore start - malformed export-list segments aren't tested */
|
|
152
|
+
if (nameMatch) out.push(nameMatch[1]);
|
|
153
|
+
}
|
|
149
154
|
}
|
|
150
155
|
return out;
|
|
151
156
|
}
|
|
@@ -159,12 +164,15 @@ function extractTsExports(src) {
|
|
|
159
164
|
const out = /* @__PURE__ */ new Set();
|
|
160
165
|
for (const m of src.matchAll(/^export\s+(?:declare\s+)?const\s+([A-Za-z_$][A-Za-z0-9_$]*)/gm)) out.add(m[1]);
|
|
161
166
|
for (const m of src.matchAll(/^export\s+(?:declare\s+)?function\s+([A-Za-z_$][A-Za-z0-9_$]*)/gm)) out.add(m[1]);
|
|
162
|
-
for (const m of src.matchAll(/^export\s*\{\s*([^}]+)\}/gm))
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
167
|
+
for (const m of src.matchAll(/^export\s*\{\s*([^}]+)\}/gm)) {
|
|
168
|
+
const rawNames = m[1].split(",");
|
|
169
|
+
for (let i = 0, { length } = rawNames; i < length; i += 1) {
|
|
170
|
+
const trimmed = rawNames[i].trim();
|
|
171
|
+
if (!trimmed) continue;
|
|
172
|
+
const nameMatch = NAME_HEAD_RE.exec(trimmed);
|
|
173
|
+
/* c8 ignore start - malformed export-list segments aren't tested */
|
|
174
|
+
if (nameMatch) out.add(nameMatch[1]);
|
|
175
|
+
}
|
|
168
176
|
}
|
|
169
177
|
return [...out];
|
|
170
178
|
}
|
|
@@ -176,7 +184,7 @@ function extractTsExports(src) {
|
|
|
176
184
|
function readSocketLibPrimordialNames(resolved) {
|
|
177
185
|
if ((0, node_fs.statSync)(resolved).isFile()) return new Set(extractTsExports((0, node_fs.readFileSync)(resolved, "utf8")));
|
|
178
186
|
const out = /* @__PURE__ */ new Set();
|
|
179
|
-
/* c8 ignore start */
|
|
187
|
+
/* c8 ignore start - leaf-classification branches aren't tested separately */
|
|
180
188
|
for (const name of (0, node_fs.readdirSync)(resolved)) {
|
|
181
189
|
if (!name.endsWith(".ts") && !name.endsWith(".d.ts")) continue;
|
|
182
190
|
const full = node_path.default.join(resolved, name);
|
|
@@ -203,7 +211,7 @@ function readSocketLibPrimordialNames(resolved) {
|
|
|
203
211
|
* Throws when none of the candidates exist.
|
|
204
212
|
*/
|
|
205
213
|
function resolveSocketLibPrimordials(config) {
|
|
206
|
-
/* c8 ignore start */
|
|
214
|
+
/* c8 ignore start - resolver branch needs dedicated test setup per candidate */
|
|
207
215
|
if (config.socketLibPrimordialsPath) {
|
|
208
216
|
if (!(0, node_fs.existsSync)(config.socketLibPrimordialsPath)) throw new require_primordials_error.ErrorCtor(`socketLibPrimordialsPath does not exist: ${config.socketLibPrimordialsPath}`);
|
|
209
217
|
return config.socketLibPrimordialsPath;
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* error)
|
|
11
11
|
*/
|
|
12
12
|
import type { PrimordialsCheckConfig, PrimordialsCheckResult, PrimordialsFinding } from '../checks/primordials';
|
|
13
|
+
export declare const FALLBACK_CONFIG_PATHS: readonly string[];
|
|
13
14
|
export interface ParsedArgs {
|
|
14
15
|
readonly config: string | undefined;
|
|
15
16
|
readonly json: boolean;
|
|
@@ -39,8 +40,12 @@ export declare function renderHuman(result: PrimordialsCheckResult, args: Parsed
|
|
|
39
40
|
* they typed). Otherwise probes the fallback list in order and returns the
|
|
40
41
|
* first hit. Returns the head of the list when none exist, so the caller's
|
|
41
42
|
* "config file not found" error message names the canonical default.
|
|
43
|
+
*
|
|
44
|
+
* `baseDir` is the directory the relative candidates resolve against; it
|
|
45
|
+
* defaults to `process.cwd()` (the repo root the user runs from) and is a
|
|
46
|
+
* parameter so callers/tests can probe a fixture tree without `process.chdir`.
|
|
42
47
|
*/
|
|
43
|
-
export declare function resolveConfigPath(explicit: string | undefined): string;
|
|
48
|
+
export declare function resolveConfigPath(explicit: string | undefined, baseDir?: string): string;
|
|
44
49
|
export declare function runCheckPrimordials(argv: readonly string[]): Promise<number>;
|
|
45
50
|
export declare function serialize(result: PrimordialsCheckResult): {
|
|
46
51
|
ok: boolean;
|
|
@@ -32,7 +32,11 @@ node_path = require_runtime.__toESM(node_path);
|
|
|
32
32
|
*/
|
|
33
33
|
const logger = require_logger_default.getDefaultLogger();
|
|
34
34
|
const DEFAULT_CONFIG_PATH = ".socket-lib.json";
|
|
35
|
-
const FALLBACK_CONFIG_PATHS = [
|
|
35
|
+
const FALLBACK_CONFIG_PATHS = [
|
|
36
|
+
".socket-lib.json",
|
|
37
|
+
".config/socket-lib.json",
|
|
38
|
+
".config/repo/socket-lib.json"
|
|
39
|
+
];
|
|
36
40
|
const CONFIG_SECTION = "primordials";
|
|
37
41
|
function loadConfig(configPath) {
|
|
38
42
|
if (!(0, node_fs.existsSync)(configPath)) throw new require_primordials_error.ErrorCtor(`config file not found: ${configPath}`);
|
|
@@ -96,7 +100,7 @@ function printHelp() {
|
|
|
96
100
|
logger.log("");
|
|
97
101
|
logger.log("Options:");
|
|
98
102
|
logger.log(` --config, -c <path> Config file. Default: ${DEFAULT_CONFIG_PATH}`);
|
|
99
|
-
logger.log(` (falls back to .config/socket-lib.json)`);
|
|
103
|
+
logger.log(` (falls back to .config/socket-lib.json, then .config/repo/socket-lib.json)`);
|
|
100
104
|
logger.log(" --explain Print one detailed line per finding.");
|
|
101
105
|
logger.log(" --json Machine-readable JSON output.");
|
|
102
106
|
logger.log(" --silent Silent on success.");
|
|
@@ -110,7 +114,7 @@ function printHelp() {
|
|
|
110
114
|
logger.log(" }");
|
|
111
115
|
logger.log("");
|
|
112
116
|
logger.log("Only `scanDirs` is required. `aliasMap` and `nodeInternalOnly`");
|
|
113
|
-
logger.log("default to the
|
|
117
|
+
logger.log("default to the Socket-canonical sets and only need entries when");
|
|
114
118
|
logger.log("your repo extends or overrides them.");
|
|
115
119
|
logger.log("");
|
|
116
120
|
logger.log("A bare object (no `primordials` section) is also accepted for");
|
|
@@ -140,12 +144,16 @@ function renderHuman(result, args) {
|
|
|
140
144
|
* they typed). Otherwise probes the fallback list in order and returns the
|
|
141
145
|
* first hit. Returns the head of the list when none exist, so the caller's
|
|
142
146
|
* "config file not found" error message names the canonical default.
|
|
147
|
+
*
|
|
148
|
+
* `baseDir` is the directory the relative candidates resolve against; it
|
|
149
|
+
* defaults to `process.cwd()` (the repo root the user runs from) and is a
|
|
150
|
+
* parameter so callers/tests can probe a fixture tree without `process.chdir`.
|
|
143
151
|
*/
|
|
144
|
-
function resolveConfigPath(explicit) {
|
|
152
|
+
function resolveConfigPath(explicit, baseDir = node_process.default.cwd()) {
|
|
145
153
|
if (explicit !== void 0) return explicit;
|
|
146
154
|
for (let i = 0, { length } = FALLBACK_CONFIG_PATHS; i < length; i += 1) {
|
|
147
155
|
const candidate = FALLBACK_CONFIG_PATHS[i];
|
|
148
|
-
if ((0, node_fs.existsSync)(node_path.default.resolve(candidate))) return candidate;
|
|
156
|
+
if ((0, node_fs.existsSync)(node_path.default.resolve(baseDir, candidate))) return candidate;
|
|
149
157
|
}
|
|
150
158
|
return FALLBACK_CONFIG_PATHS[0];
|
|
151
159
|
}
|
|
@@ -187,6 +195,7 @@ function serialize(result) {
|
|
|
187
195
|
}
|
|
188
196
|
|
|
189
197
|
//#endregion
|
|
198
|
+
exports.FALLBACK_CONFIG_PATHS = FALLBACK_CONFIG_PATHS;
|
|
190
199
|
exports.loadConfig = loadConfig;
|
|
191
200
|
exports.parseArgs = parseArgs;
|
|
192
201
|
exports.printHelp = printHelp;
|
package/dist/cli/check.js
CHANGED
|
@@ -18,7 +18,7 @@ const logger = require_logger_default.getDefaultLogger();
|
|
|
18
18
|
const CHECKS = new require_primordials_map_set.MapCtor([["primordials", "primordials"], ["prim", "primordials"]]);
|
|
19
19
|
const ALIASES = new require_primordials_map_set.MapCtor([["primordials", ["prim"]]]);
|
|
20
20
|
function printHelp() {
|
|
21
|
-
logger.log("socket-lib check —
|
|
21
|
+
logger.log("socket-lib check — Socket-wide static-analysis checks");
|
|
22
22
|
logger.log("");
|
|
23
23
|
logger.log("Usage:");
|
|
24
24
|
logger.log(" socket-lib check <name> [...opts]");
|
package/dist/cli/socket-lib.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
3
|
* @file `socket-lib` CLI entry point — top-level dispatcher. socket-lib — print
|
|
4
|
-
* help, list commands socket-lib check <name> [opts...] — run a
|
|
4
|
+
* help, list commands socket-lib check <name> [opts...] — run a Socket-wide
|
|
5
5
|
* check Subcommands live as siblings under `src/cli/`; each is its own file
|
|
6
6
|
* so a misbehaving check can't crash other commands at parse time. The
|
|
7
7
|
* dispatcher just routes; subcommands own their own arg parsing. The CLI is
|
package/dist/cli/socket-lib.js
CHANGED
|
@@ -11,7 +11,7 @@ node_process = require_runtime.__toESM(node_process);
|
|
|
11
11
|
//#region src/cli/socket-lib.ts
|
|
12
12
|
/**
|
|
13
13
|
* @file `socket-lib` CLI entry point — top-level dispatcher. socket-lib — print
|
|
14
|
-
* help, list commands socket-lib check <name> [opts...] — run a
|
|
14
|
+
* help, list commands socket-lib check <name> [opts...] — run a Socket-wide
|
|
15
15
|
* check Subcommands live as siblings under `src/cli/`; each is its own file
|
|
16
16
|
* so a misbehaving check can't crash other commands at parse time. The
|
|
17
17
|
* dispatcher just routes; subcommands own their own arg parsing. The CLI is
|
|
@@ -21,13 +21,13 @@ node_process = require_runtime.__toESM(node_process);
|
|
|
21
21
|
*/
|
|
22
22
|
const logger = require_logger_default.getDefaultLogger();
|
|
23
23
|
function printHelp() {
|
|
24
|
-
logger.log("socket-lib —
|
|
24
|
+
logger.log("socket-lib — Socket-wide static-analysis CLI");
|
|
25
25
|
logger.log("");
|
|
26
26
|
logger.log("Usage:");
|
|
27
27
|
logger.log(" socket-lib <command> [...args]");
|
|
28
28
|
logger.log("");
|
|
29
29
|
logger.log("Commands:");
|
|
30
|
-
logger.log(" check <name> Run a
|
|
30
|
+
logger.log(" check <name> Run a Socket-wide check (primordials, ...).");
|
|
31
31
|
logger.log("");
|
|
32
32
|
logger.log("Run `socket-lib check --help` for the list of checks.");
|
|
33
33
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file Socket terminal-color palette — mirrors the CSS design tokens defined
|
|
3
|
-
* in
|
|
3
|
+
* in Socket's `template/styles/tokens.css` (light / dark / synthwave
|
|
4
4
|
* themes). Each helper returns the input string wrapped in a 24-bit ANSI
|
|
5
5
|
* escape sequence so the rendered hex matches the brand exactly; no rounding
|
|
6
6
|
* to the legacy 8-color palette. Picocolors / yoctocolors only ship a fixed
|
|
@@ -37,11 +37,13 @@ export declare function compressBrotliFile(srcPath: string, options: CompressFil
|
|
|
37
37
|
* The `pipeline` from `node:stream/promises` is the safe way to wire it up — it
|
|
38
38
|
* handles error propagation across all stages.
|
|
39
39
|
*/
|
|
40
|
-
export declare function createBrotliCompressor(options?: CompressOptions | undefined): import("zlib").BrotliCompress;
|
|
40
|
+
export declare function createBrotliCompressor(options?: CompressOptions | undefined): import("node:zlib").BrotliCompress;
|
|
41
41
|
/**
|
|
42
42
|
* Create a brotli decompress transform stream.
|
|
43
|
+
*
|
|
44
|
+
* @unused No internal or Socket consumers (exercised only by its unit tests).
|
|
43
45
|
*/
|
|
44
|
-
export declare function createBrotliDecompressor(): import("zlib").BrotliDecompress;
|
|
46
|
+
export declare function createBrotliDecompressor(): import("node:zlib").BrotliDecompress;
|
|
45
47
|
/**
|
|
46
48
|
* Decompress a brotli-compressed Buffer.
|
|
47
49
|
*/
|
|
@@ -70,6 +72,8 @@ export declare function hasBrotliExt(filePath: string): boolean;
|
|
|
70
72
|
* false for inputs too short to be valid. Brotli has no fixed magic bytes, so
|
|
71
73
|
* this is intentionally permissive — the authoritative test is
|
|
72
74
|
* `decompressBrotli(buf)` succeeding. Use for UI hints, not correctness.
|
|
75
|
+
*
|
|
76
|
+
* @unused No internal or Socket consumers (exercised only by its unit tests).
|
|
73
77
|
*/
|
|
74
78
|
export declare function isBrotliCompressed(input: Buffer): boolean;
|
|
75
79
|
/**
|
|
@@ -46,6 +46,8 @@ function createBrotliCompressor(options) {
|
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
48
|
* Create a brotli decompress transform stream.
|
|
49
|
+
*
|
|
50
|
+
* @unused No internal or Socket consumers (exercised only by its unit tests).
|
|
49
51
|
*/
|
|
50
52
|
function createBrotliDecompressor() {
|
|
51
53
|
return (0, node_zlib.createBrotliDecompress)();
|
|
@@ -77,6 +79,8 @@ function hasBrotliExt(filePath) {
|
|
|
77
79
|
* false for inputs too short to be valid. Brotli has no fixed magic bytes, so
|
|
78
80
|
* this is intentionally permissive — the authoritative test is
|
|
79
81
|
* `decompressBrotli(buf)` succeeding. Use for UI hints, not correctness.
|
|
82
|
+
*
|
|
83
|
+
* @unused No internal or Socket consumers (exercised only by its unit tests).
|
|
80
84
|
*/
|
|
81
85
|
function isBrotliCompressed(input) {
|
|
82
86
|
return require_primordials_buffer.BufferIsBuffer(input) && input.byteLength >= BROTLI_MIN_LEN;
|
|
@@ -30,11 +30,13 @@ export declare function compressGzipFile(srcPath: string, options: CompressFileO
|
|
|
30
30
|
/**
|
|
31
31
|
* Create a gzip compress transform stream.
|
|
32
32
|
*/
|
|
33
|
-
export declare function createGzipCompressor(options?: CompressOptions | undefined): import("zlib").Gzip;
|
|
33
|
+
export declare function createGzipCompressor(options?: CompressOptions | undefined): import("node:zlib").Gzip;
|
|
34
34
|
/**
|
|
35
35
|
* Create a gzip decompress transform stream.
|
|
36
|
+
*
|
|
37
|
+
* @unused No internal or Socket consumers (exercised only by its unit tests).
|
|
36
38
|
*/
|
|
37
|
-
export declare function createGzipDecompressor(): import("zlib").Gunzip;
|
|
39
|
+
export declare function createGzipDecompressor(): import("node:zlib").Gunzip;
|
|
38
40
|
/**
|
|
39
41
|
* Decompress a gzip-compressed Buffer.
|
|
40
42
|
*/
|
|
@@ -59,6 +61,8 @@ export declare function hasGzipExt(filePath: string): boolean;
|
|
|
59
61
|
/**
|
|
60
62
|
* Magic-byte check for gzip. Reads the first two bytes and matches the gzip
|
|
61
63
|
* spec's 0x1f 0x8b signature. Authoritative.
|
|
64
|
+
*
|
|
65
|
+
* @unused No internal or Socket consumers (exercised only by its unit tests).
|
|
62
66
|
*/
|
|
63
67
|
export declare function isGzipCompressed(input: Buffer): boolean;
|
|
64
68
|
/**
|
package/dist/compression/gzip.js
CHANGED
|
@@ -30,7 +30,8 @@ const GZIP_EXTS = new require_primordials_map_set.SetCtor([
|
|
|
30
30
|
* compression. Default level is 6 (zlib default).
|
|
31
31
|
*/
|
|
32
32
|
async function compressGzip(input, options) {
|
|
33
|
-
|
|
33
|
+
const buf = typeof input === "string" ? require_primordials_buffer.BufferFrom(input, "utf8") : input;
|
|
34
|
+
return await gzipAsync(buf, resolveGzipOptions(options));
|
|
34
35
|
}
|
|
35
36
|
async function compressGzipFile(srcPath, destOrOptions, maybeOptions) {
|
|
36
37
|
const { destPath, options, inPlace } = require_compression__internal.resolveFileArgs("compressGzipFile", srcPath, destOrOptions, maybeOptions, (p) => `${p}.gz`);
|
|
@@ -46,6 +47,8 @@ function createGzipCompressor(options) {
|
|
|
46
47
|
}
|
|
47
48
|
/**
|
|
48
49
|
* Create a gzip decompress transform stream.
|
|
50
|
+
*
|
|
51
|
+
* @unused No internal or Socket consumers (exercised only by its unit tests).
|
|
49
52
|
*/
|
|
50
53
|
function createGzipDecompressor() {
|
|
51
54
|
return (0, node_zlib.createGunzip)();
|
|
@@ -76,6 +79,8 @@ function hasGzipExt(filePath) {
|
|
|
76
79
|
/**
|
|
77
80
|
* Magic-byte check for gzip. Reads the first two bytes and matches the gzip
|
|
78
81
|
* spec's 0x1f 0x8b signature. Authoritative.
|
|
82
|
+
*
|
|
83
|
+
* @unused No internal or Socket consumers (exercised only by its unit tests).
|
|
79
84
|
*/
|
|
80
85
|
function isGzipCompressed(input) {
|
|
81
86
|
return require_primordials_buffer.BufferIsBuffer(input) && input.byteLength >= 2 && input[0] === GZIP_MAGIC_0 && input[1] === GZIP_MAGIC_1;
|
package/dist/config/layers.d.ts
CHANGED
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
* returns the layers that exist. Callers apply their own merge, because merge
|
|
7
7
|
* policy varies (a denylist unions all layers; an allowlist takes the highest
|
|
8
8
|
* layer that declares one; an array key concatenates). `mergeConfigArray`
|
|
9
|
-
* covers the concat case across any number of layers. No
|
|
10
|
-
* lives here — the
|
|
11
|
-
* is `fleet/repo-config`'s `resolveRepoConfig`, a thin
|
|
12
|
-
* reader.
|
|
9
|
+
* covers the concat case across any number of layers. No Socket-specific
|
|
10
|
+
* knowledge lives here — the Socket-convention `.config/fleet` +
|
|
11
|
+
* `.config/repo` wrapper is `fleet/repo-config`'s `resolveRepoConfig`, a thin
|
|
12
|
+
* layer over this reader.
|
|
13
13
|
*/
|
|
14
14
|
export interface ReadConfigLayersOptions {
|
|
15
15
|
dirs: readonly string[];
|
package/dist/config/layers.js
CHANGED
|
@@ -15,10 +15,10 @@ const require_git_repo = require('../git/repo.js');
|
|
|
15
15
|
* returns the layers that exist. Callers apply their own merge, because merge
|
|
16
16
|
* policy varies (a denylist unions all layers; an allowlist takes the highest
|
|
17
17
|
* layer that declares one; an array key concatenates). `mergeConfigArray`
|
|
18
|
-
* covers the concat case across any number of layers. No
|
|
19
|
-
* lives here — the
|
|
20
|
-
* is `fleet/repo-config`'s `resolveRepoConfig`, a thin
|
|
21
|
-
* reader.
|
|
18
|
+
* covers the concat case across any number of layers. No Socket-specific
|
|
19
|
+
* knowledge lives here — the Socket-convention `.config/fleet` +
|
|
20
|
+
* `.config/repo` wrapper is `fleet/repo-config`'s `resolveRepoConfig`, a thin
|
|
21
|
+
* layer over this reader.
|
|
22
22
|
*/
|
|
23
23
|
/**
|
|
24
24
|
* Concatenate one array-valued key across all layers — the common merge for a
|
|
@@ -17,6 +17,9 @@ export declare const NPM_REGISTRY_URL = "https://registry.npmjs.org";
|
|
|
17
17
|
export declare const YARN_BERRY = "yarn/berry";
|
|
18
18
|
export declare const YARN_CLASSIC = "yarn/classic";
|
|
19
19
|
export declare const ZPM = "zpm";
|
|
20
|
+
/**
|
|
21
|
+
* @unused No internal or Socket consumers (exercised only by its unit tests).
|
|
22
|
+
*/
|
|
20
23
|
export declare const PACKAGE_LOCK = "package-lock";
|
|
21
24
|
export declare const PACKAGE_LOCK_JSON = "package-lock.json";
|
|
22
25
|
export declare const NPM_SHRINKWRAP_JSON = "npm-shrinkwrap.json";
|
package/dist/constants/agents.js
CHANGED
|
@@ -51,6 +51,9 @@ const NPM_REGISTRY_URL = "https://registry.npmjs.org";
|
|
|
51
51
|
const YARN_BERRY = "yarn/berry";
|
|
52
52
|
const YARN_CLASSIC = "yarn/classic";
|
|
53
53
|
const ZPM = "zpm";
|
|
54
|
+
/**
|
|
55
|
+
* @unused No internal or Socket consumers (exercised only by its unit tests).
|
|
56
|
+
*/
|
|
54
57
|
const PACKAGE_LOCK = "package-lock";
|
|
55
58
|
const PACKAGE_LOCK_JSON = "package-lock.json";
|
|
56
59
|
const NPM_SHRINKWRAP_JSON = "npm-shrinkwrap.json";
|
package/dist/constants/node.d.ts
CHANGED
|
@@ -61,6 +61,8 @@ export declare function getNodeNoWarningsFlags(): string[];
|
|
|
61
61
|
* Get the patch component of the current Node.js version.
|
|
62
62
|
*
|
|
63
63
|
* @returns The patch version number, or `0` if it cannot be parsed.
|
|
64
|
+
*
|
|
65
|
+
* @unused No internal or Socket consumers (exercised only by its unit tests).
|
|
64
66
|
*/
|
|
65
67
|
export declare function getNodePatchVersion(): number;
|
|
66
68
|
/**
|
|
@@ -83,6 +85,8 @@ export declare function getNodeVersion(): string;
|
|
|
83
85
|
* API. The API is available on Node.js 24+.
|
|
84
86
|
*
|
|
85
87
|
* @returns `true` when the current runtime is Node.js 24 or newer.
|
|
88
|
+
*
|
|
89
|
+
* @unused No internal or Socket consumers (exercised only by its unit tests).
|
|
86
90
|
*/
|
|
87
91
|
export declare function supportsNodeCompileCacheApi(): boolean;
|
|
88
92
|
/**
|
|
@@ -90,6 +94,8 @@ export declare function supportsNodeCompileCacheApi(): boolean;
|
|
|
90
94
|
* Env-var-based compile caching is available on Node.js 22+.
|
|
91
95
|
*
|
|
92
96
|
* @returns `true` when the current runtime is Node.js 22 or newer.
|
|
97
|
+
*
|
|
98
|
+
* @unused No internal or Socket consumers (exercised only by its unit tests).
|
|
93
99
|
*/
|
|
94
100
|
export declare function supportsNodeCompileCacheEnvVar(): boolean;
|
|
95
101
|
/**
|
|
@@ -105,6 +111,8 @@ export declare function supportsNodeDisableSigusr1Flag(): boolean;
|
|
|
105
111
|
* The flag is available on Node.js 21+.
|
|
106
112
|
*
|
|
107
113
|
* @returns `true` when the current runtime is Node.js 21 or newer.
|
|
114
|
+
*
|
|
115
|
+
* @unused No internal or Socket consumers (exercised only by its unit tests).
|
|
108
116
|
*/
|
|
109
117
|
export declare function supportsNodeDisableWarningFlag(): boolean;
|
|
110
118
|
/**
|
|
@@ -112,6 +120,8 @@ export declare function supportsNodeDisableWarningFlag(): boolean;
|
|
|
112
120
|
* (`--experimental-permission` on Node 20-23, `--permission` on Node 24+).
|
|
113
121
|
*
|
|
114
122
|
* @returns `true` when the current runtime is Node.js 20 or newer.
|
|
123
|
+
*
|
|
124
|
+
* @unused No internal or Socket consumers (exercised only by its unit tests).
|
|
115
125
|
*/
|
|
116
126
|
export declare function supportsNodePermissionFlag(): boolean;
|
|
117
127
|
/**
|
|
@@ -119,6 +129,8 @@ export declare function supportsNodePermissionFlag(): boolean;
|
|
|
119
129
|
* Node.js 22.12+ or Node.js 23+.
|
|
120
130
|
*
|
|
121
131
|
* @returns `true` when the runtime supports `require()`-ing ES modules.
|
|
132
|
+
*
|
|
133
|
+
* @unused No internal or Socket consumers (exercised only by its unit tests).
|
|
122
134
|
*/
|
|
123
135
|
export declare function supportsNodeRequireModule(): boolean;
|
|
124
136
|
/**
|
|
@@ -157,6 +169,8 @@ export declare function supportsNodeStripTypesDefault(): boolean;
|
|
|
157
169
|
* `process.send()` is callable to message the parent process.
|
|
158
170
|
*
|
|
159
171
|
* @returns `true` when the current process has an IPC channel to its parent.
|
|
172
|
+
*
|
|
173
|
+
* @unused No internal or Socket consumers (exercised only by its unit tests).
|
|
160
174
|
*/
|
|
161
175
|
export declare function supportsProcessSend(): boolean;
|
|
162
176
|
export declare const ESNEXT = "esnext";
|