@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
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file CI/host provider detection, re-exported from std-env — not
|
|
3
|
+
* reimplemented. std-env is a devDependency, inlined by the bundler.
|
|
4
|
+
*/
|
|
5
|
+
export { detectProvider, provider, providerInfo } from '../external/std-env';
|
|
6
|
+
export type { ProviderInfo, ProviderName } from '../external/std-env';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* Socket Lib - Built with rolldown */
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
let src_external_std_env = require("../external/std-env");
|
|
5
|
+
|
|
6
|
+
Object.defineProperty(exports, 'detectProvider', {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return src_external_std_env.detectProvider;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, 'provider', {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return src_external_std_env.provider;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, 'providerInfo', {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return src_external_std_env.providerInfo;
|
|
22
|
+
}
|
|
23
|
+
});
|
package/dist/env/proxy.js
CHANGED
|
@@ -86,7 +86,7 @@ function createEnvProxy(base, overrides) {
|
|
|
86
86
|
return lookupEnvValue(prop);
|
|
87
87
|
},
|
|
88
88
|
ownKeys(_target) {
|
|
89
|
-
return [
|
|
89
|
+
return [.../* @__PURE__ */ new Set([...require_primordials_object.ObjectKeys(base), ...overrides ? require_primordials_object.ObjectKeys(overrides) : []])];
|
|
90
90
|
},
|
|
91
91
|
getOwnPropertyDescriptor(_target, prop) {
|
|
92
92
|
if (typeof prop !== "string") return;
|
package/dist/env/rewire.d.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* - Compatible with vi.stubEnv() - reads from process.env as final fallback
|
|
9
9
|
* - Thread-safe for concurrent test execution
|
|
10
10
|
*/
|
|
11
|
+
import type { AsyncLocalStorage } from 'node:async_hooks';
|
|
11
12
|
import { getNodeAsyncHooks } from '../node/async-hooks';
|
|
12
13
|
export type EnvOverrides = Map<string, string | undefined>;
|
|
13
14
|
/**
|
|
@@ -50,6 +51,27 @@ export declare const getAsyncHooks: typeof getNodeAsyncHooks;
|
|
|
50
51
|
* @internal Used by env getters to support test rewiring
|
|
51
52
|
*/
|
|
52
53
|
export declare function getEnvValue(key: string): string | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* Get the current isolated-override map, or undefined when none is active.
|
|
56
|
+
* Off Node (browser bundles) there is no AsyncLocalStorage and no isolated
|
|
57
|
+
* context — env getters fall straight through to the other tiers.
|
|
58
|
+
*
|
|
59
|
+
* @private
|
|
60
|
+
*/
|
|
61
|
+
export declare function getIsolatedOverrides(): EnvOverrides | undefined;
|
|
62
|
+
/**
|
|
63
|
+
* Get the process-scoped AsyncLocalStorage used for nested env overrides
|
|
64
|
+
* (withEnv/withEnvSync).
|
|
65
|
+
*
|
|
66
|
+
* Constructed LAZILY (memoized) rather than at module-eval: an
|
|
67
|
+
* AsyncLocalStorage holds a live native handle, and constructing it at import
|
|
68
|
+
* time pins that handle into every module transitively importing this leaf —
|
|
69
|
+
* aborting V8 --build-snapshot serialization. Deferring to first use keeps the
|
|
70
|
+
* single-store semantics while leaving module import snapshot-safe.
|
|
71
|
+
*
|
|
72
|
+
* @private
|
|
73
|
+
*/
|
|
74
|
+
export declare function getIsolatedOverridesStorage(): AsyncLocalStorage<EnvOverrides>;
|
|
53
75
|
/**
|
|
54
76
|
* Check if an environment variable has been overridden.
|
|
55
77
|
*
|
|
@@ -100,6 +122,16 @@ export declare function isInEnv(key: string): boolean;
|
|
|
100
122
|
* ```
|
|
101
123
|
*/
|
|
102
124
|
export declare function resetEnv(): void;
|
|
125
|
+
/**
|
|
126
|
+
* Read `process.env` without assuming a real Node `process`. Probes the
|
|
127
|
+
* GLOBAL `process` via `typeof` (no `node:process` import — webpack throws
|
|
128
|
+
* UnhandledSchemeError on `node:` specifiers before the `browser`-field stubs
|
|
129
|
+
* apply), so browser bundles load this leaf cleanly and env getters read as
|
|
130
|
+
* unset instead of throwing.
|
|
131
|
+
*
|
|
132
|
+
* @private
|
|
133
|
+
*/
|
|
134
|
+
export declare function safeProcessEnv(): Record<string, string | undefined> | undefined;
|
|
103
135
|
/**
|
|
104
136
|
* Set an environment variable override for testing. This does not modify
|
|
105
137
|
* process.env, only affects env getters.
|
package/dist/env/rewire.js
CHANGED
|
@@ -1,31 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/* Socket Lib - Built with rolldown */
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
const
|
|
4
|
+
const require_constants_runtime = require('../constants/runtime.js');
|
|
5
5
|
const require_primordials_object = require('../primordials/object.js');
|
|
6
6
|
const require_objects_predicates = require('../objects/predicates.js');
|
|
7
7
|
const require_env_boolean = require('./boolean.js');
|
|
8
8
|
const require_node_async_hooks = require('../node/async-hooks.js');
|
|
9
9
|
const require_primordials_map_set = require('../primordials/map-set.js');
|
|
10
|
-
let node_process = require("node:process");
|
|
11
|
-
node_process = require_runtime.__toESM(node_process);
|
|
12
10
|
|
|
13
11
|
//#region src/env/rewire.ts
|
|
14
|
-
|
|
15
|
-
* @file Environment variable rewiring utilities for testing. Uses
|
|
16
|
-
* AsyncLocalStorage for context-isolated overrides that work with concurrent
|
|
17
|
-
* tests. Features:
|
|
18
|
-
*
|
|
19
|
-
* - Context-isolated overrides via withEnv() for advanced use cases
|
|
20
|
-
* - Test-friendly setEnv/clearEnv/resetEnv that work in beforeEach/afterEach
|
|
21
|
-
* - Compatible with vi.stubEnv() - reads from process.env as final fallback
|
|
22
|
-
* - Thread-safe for concurrent test execution
|
|
23
|
-
*/
|
|
24
|
-
const { AsyncLocalStorage } = require_node_async_hooks.getNodeAsyncHooks();
|
|
25
|
-
const isolatedOverridesStorage = new AsyncLocalStorage();
|
|
12
|
+
let isolatedOverridesStorage;
|
|
26
13
|
const sharedOverridesSymbol = Symbol.for("@socketsecurity/lib/env/rewire/test-overrides");
|
|
27
14
|
const globalThisRef = globalThis;
|
|
28
|
-
if (require_env_boolean.envAsBoolean(
|
|
15
|
+
if (require_env_boolean.envAsBoolean(safeProcessEnv()?.["VITEST"]) && !globalThisRef[sharedOverridesSymbol]) globalThisRef[sharedOverridesSymbol] = new require_primordials_map_set.MapCtor();
|
|
29
16
|
const sharedOverrides = globalThisRef[sharedOverridesSymbol];
|
|
30
17
|
/**
|
|
31
18
|
* Clear a specific environment variable override.
|
|
@@ -69,10 +56,39 @@ const getAsyncHooks = require_node_async_hooks.getNodeAsyncHooks;
|
|
|
69
56
|
* @internal Used by env getters to support test rewiring
|
|
70
57
|
*/
|
|
71
58
|
function getEnvValue(key) {
|
|
72
|
-
const isolatedOverrides =
|
|
59
|
+
const isolatedOverrides = getIsolatedOverrides();
|
|
73
60
|
if (isolatedOverrides?.has(key)) return isolatedOverrides.get(key);
|
|
74
61
|
if (sharedOverrides?.has(key)) return sharedOverrides.get(key);
|
|
75
|
-
return
|
|
62
|
+
return safeProcessEnv()?.[key];
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Get the current isolated-override map, or undefined when none is active.
|
|
66
|
+
* Off Node (browser bundles) there is no AsyncLocalStorage and no isolated
|
|
67
|
+
* context — env getters fall straight through to the other tiers.
|
|
68
|
+
*
|
|
69
|
+
* @private
|
|
70
|
+
*/
|
|
71
|
+
function getIsolatedOverrides() {
|
|
72
|
+
return require_constants_runtime.IS_NODE ? getIsolatedOverridesStorage().getStore() : void 0;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Get the process-scoped AsyncLocalStorage used for nested env overrides
|
|
76
|
+
* (withEnv/withEnvSync).
|
|
77
|
+
*
|
|
78
|
+
* Constructed LAZILY (memoized) rather than at module-eval: an
|
|
79
|
+
* AsyncLocalStorage holds a live native handle, and constructing it at import
|
|
80
|
+
* time pins that handle into every module transitively importing this leaf —
|
|
81
|
+
* aborting V8 --build-snapshot serialization. Deferring to first use keeps the
|
|
82
|
+
* single-store semantics while leaving module import snapshot-safe.
|
|
83
|
+
*
|
|
84
|
+
* @private
|
|
85
|
+
*/
|
|
86
|
+
function getIsolatedOverridesStorage() {
|
|
87
|
+
if (isolatedOverridesStorage === void 0) {
|
|
88
|
+
const { AsyncLocalStorage } = require_node_async_hooks.getNodeAsyncHooks();
|
|
89
|
+
isolatedOverridesStorage = new AsyncLocalStorage();
|
|
90
|
+
}
|
|
91
|
+
return isolatedOverridesStorage;
|
|
76
92
|
}
|
|
77
93
|
/**
|
|
78
94
|
* Check if an environment variable has been overridden.
|
|
@@ -91,7 +107,7 @@ function getEnvValue(key) {
|
|
|
91
107
|
* @returns `true` if the variable has been overridden, `false` otherwise
|
|
92
108
|
*/
|
|
93
109
|
function hasOverride(key) {
|
|
94
|
-
return !!(
|
|
110
|
+
return !!(getIsolatedOverrides()?.has(key) || sharedOverrides?.has(key));
|
|
95
111
|
}
|
|
96
112
|
/**
|
|
97
113
|
* Check if an environment variable exists (has a key), checking overrides
|
|
@@ -112,9 +128,10 @@ function hasOverride(key) {
|
|
|
112
128
|
* @internal Used by env getters to check for key presence (not value truthiness)
|
|
113
129
|
*/
|
|
114
130
|
function isInEnv(key) {
|
|
115
|
-
if (
|
|
131
|
+
if (getIsolatedOverrides()?.has(key)) return true;
|
|
116
132
|
if (sharedOverrides?.has(key)) return true;
|
|
117
|
-
|
|
133
|
+
const env = safeProcessEnv();
|
|
134
|
+
return env ? require_objects_predicates.hasOwn(env, key) : false;
|
|
118
135
|
}
|
|
119
136
|
/**
|
|
120
137
|
* Clear all environment variable overrides. Useful in afterEach hooks to ensure
|
|
@@ -133,6 +150,18 @@ function resetEnv() {
|
|
|
133
150
|
sharedOverrides?.clear();
|
|
134
151
|
}
|
|
135
152
|
/**
|
|
153
|
+
* Read `process.env` without assuming a real Node `process`. Probes the
|
|
154
|
+
* GLOBAL `process` via `typeof` (no `node:process` import — webpack throws
|
|
155
|
+
* UnhandledSchemeError on `node:` specifiers before the `browser`-field stubs
|
|
156
|
+
* apply), so browser bundles load this leaf cleanly and env getters read as
|
|
157
|
+
* unset instead of throwing.
|
|
158
|
+
*
|
|
159
|
+
* @private
|
|
160
|
+
*/
|
|
161
|
+
function safeProcessEnv() {
|
|
162
|
+
return typeof process !== "undefined" && process ? process.env : void 0;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
136
165
|
* Set an environment variable override for testing. This does not modify
|
|
137
166
|
* process.env, only affects env getters.
|
|
138
167
|
*
|
|
@@ -193,7 +222,7 @@ function setEnv(key, value) {
|
|
|
193
222
|
*/
|
|
194
223
|
async function withEnv(overrides, fn) {
|
|
195
224
|
const map = new require_primordials_map_set.MapCtor(require_primordials_object.ObjectEntries(overrides));
|
|
196
|
-
return await
|
|
225
|
+
return await getIsolatedOverridesStorage().run(map, fn);
|
|
197
226
|
}
|
|
198
227
|
/**
|
|
199
228
|
* Synchronous version of withEnv for non-async code.
|
|
@@ -211,16 +240,19 @@ async function withEnv(overrides, fn) {
|
|
|
211
240
|
*/
|
|
212
241
|
function withEnvSync(overrides, fn) {
|
|
213
242
|
const map = new require_primordials_map_set.MapCtor(require_primordials_object.ObjectEntries(overrides));
|
|
214
|
-
return
|
|
243
|
+
return getIsolatedOverridesStorage().run(map, fn);
|
|
215
244
|
}
|
|
216
245
|
|
|
217
246
|
//#endregion
|
|
218
247
|
exports.clearEnv = clearEnv;
|
|
219
248
|
exports.getAsyncHooks = getAsyncHooks;
|
|
220
249
|
exports.getEnvValue = getEnvValue;
|
|
250
|
+
exports.getIsolatedOverrides = getIsolatedOverrides;
|
|
251
|
+
exports.getIsolatedOverridesStorage = getIsolatedOverridesStorage;
|
|
221
252
|
exports.hasOverride = hasOverride;
|
|
222
253
|
exports.isInEnv = isInEnv;
|
|
223
254
|
exports.resetEnv = resetEnv;
|
|
255
|
+
exports.safeProcessEnv = safeProcessEnv;
|
|
224
256
|
exports.setEnv = setEnv;
|
|
225
257
|
exports.withEnv = withEnv;
|
|
226
258
|
exports.withEnvSync = withEnvSync;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file JS runtime detection, re-exported from std-env — not reimplemented.
|
|
3
|
+
* std-env is a devDependency, inlined by the bundler.
|
|
4
|
+
* `isNode` is omitted: socket-lib's `constants/runtime` `IS_NODE` (a
|
|
5
|
+
* typeof-safe global probe) already owns Node detection. The edge/alt-runtime
|
|
6
|
+
* flags below have no socket-lib equivalent.
|
|
7
|
+
*/
|
|
8
|
+
export { isBun, isDeno, isEdgeLight, isFastly, isNetlify, isWorkerd, runtime, runtimeInfo, } from '../external/std-env';
|
|
9
|
+
export type { RuntimeInfo, RuntimeName } from '../external/std-env';
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* Socket Lib - Built with rolldown */
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
let src_external_std_env = require("../external/std-env");
|
|
5
|
+
|
|
6
|
+
Object.defineProperty(exports, 'isBun', {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return src_external_std_env.isBun;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, 'isDeno', {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return src_external_std_env.isDeno;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, 'isEdgeLight', {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return src_external_std_env.isEdgeLight;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, 'isFastly', {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return src_external_std_env.isFastly;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, 'isNetlify', {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return src_external_std_env.isNetlify;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, 'isWorkerd', {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return src_external_std_env.isWorkerd;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports, 'runtime', {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function () {
|
|
45
|
+
return src_external_std_env.runtime;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(exports, 'runtimeInfo', {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function () {
|
|
51
|
+
return src_external_std_env.runtimeInfo;
|
|
52
|
+
}
|
|
53
|
+
});
|
package/dist/env/socket-cli.d.ts
CHANGED
|
@@ -122,8 +122,11 @@ export declare function getSocketCliConfig(): string | undefined;
|
|
|
122
122
|
*/
|
|
123
123
|
export declare function getSocketCliFix(): string | undefined;
|
|
124
124
|
/**
|
|
125
|
-
* Socket CLI GitHub authentication token. Checks SOCKET_CLI_GITHUB_TOKEN,
|
|
126
|
-
* SOCKET_SECURITY_GITHUB_PAT
|
|
125
|
+
* Socket CLI GitHub authentication token. Checks SOCKET_CLI_GITHUB_TOKEN, then
|
|
126
|
+
* SOCKET_SECURITY_GITHUB_PAT. It does NOT fall back to the generic GITHUB_TOKEN
|
|
127
|
+
* — callers wanting the standard token compose `getGitHubToken()` on top (as
|
|
128
|
+
* the CLI's own token wrapper does), keeping the CLI-specific and generic token
|
|
129
|
+
* concerns separate.
|
|
127
130
|
*
|
|
128
131
|
* @example
|
|
129
132
|
* ;```typescript
|
package/dist/env/socket-cli.js
CHANGED
|
@@ -146,8 +146,11 @@ function getSocketCliFix() {
|
|
|
146
146
|
return require_env_rewire.getEnvValue("SOCKET_CLI_FIX");
|
|
147
147
|
}
|
|
148
148
|
/**
|
|
149
|
-
* Socket CLI GitHub authentication token. Checks SOCKET_CLI_GITHUB_TOKEN,
|
|
150
|
-
* SOCKET_SECURITY_GITHUB_PAT
|
|
149
|
+
* Socket CLI GitHub authentication token. Checks SOCKET_CLI_GITHUB_TOKEN, then
|
|
150
|
+
* SOCKET_SECURITY_GITHUB_PAT. It does NOT fall back to the generic GITHUB_TOKEN
|
|
151
|
+
* — callers wanting the standard token compose `getGitHubToken()` on top (as
|
|
152
|
+
* the CLI's own token wrapper does), keeping the CLI-specific and generic token
|
|
153
|
+
* concerns separate.
|
|
151
154
|
*
|
|
152
155
|
* @example
|
|
153
156
|
* ;```typescript
|
|
@@ -160,7 +163,7 @@ function getSocketCliFix() {
|
|
|
160
163
|
* @returns GitHub token or undefined
|
|
161
164
|
*/
|
|
162
165
|
function getSocketCliGithubToken() {
|
|
163
|
-
return require_env_rewire.getEnvValue("SOCKET_CLI_GITHUB_TOKEN") || require_env_rewire.getEnvValue("SOCKET_SECURITY_GITHUB_PAT") ||
|
|
166
|
+
return require_env_rewire.getEnvValue("SOCKET_CLI_GITHUB_TOKEN") || require_env_rewire.getEnvValue("SOCKET_SECURITY_GITHUB_PAT") || void 0;
|
|
164
167
|
}
|
|
165
168
|
/**
|
|
166
169
|
* Whether to skip Socket CLI API token requirement (alternative name).
|
|
@@ -6,8 +6,9 @@
|
|
|
6
6
|
*/
|
|
7
7
|
/**
|
|
8
8
|
* Reference to the native ES2025 `Error.isError` when the running engine ships
|
|
9
|
-
* it, otherwise `undefined`.
|
|
10
|
-
*
|
|
9
|
+
* it, otherwise `undefined`. Consumes the single primordial snapshot
|
|
10
|
+
* ({@link ErrorIsError}) rather than re-probing the global — one capture point.
|
|
11
|
+
* Exposed separately so tests and callers can detect the fast-path.
|
|
11
12
|
*/
|
|
12
13
|
export declare const isErrorBuiltin: ((value: unknown) => value is Error) | undefined;
|
|
13
14
|
/**
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/* Socket Lib - Built with rolldown */
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
const require_primordials_error = require('../primordials/error.js');
|
|
4
5
|
const require_primordials_object = require('../primordials/object.js');
|
|
5
6
|
const require_primordials_string = require('../primordials/string.js');
|
|
6
7
|
|
|
@@ -13,10 +14,11 @@ const require_primordials_string = require('../primordials/string.js');
|
|
|
13
14
|
*/
|
|
14
15
|
/**
|
|
15
16
|
* Reference to the native ES2025 `Error.isError` when the running engine ships
|
|
16
|
-
* it, otherwise `undefined`.
|
|
17
|
-
*
|
|
17
|
+
* it, otherwise `undefined`. Consumes the single primordial snapshot
|
|
18
|
+
* ({@link ErrorIsError}) rather than re-probing the global — one capture point.
|
|
19
|
+
* Exposed separately so tests and callers can detect the fast-path.
|
|
18
20
|
*/
|
|
19
|
-
const isErrorBuiltin =
|
|
21
|
+
const isErrorBuiltin = require_primordials_error.ErrorIsError;
|
|
20
22
|
/**
|
|
21
23
|
* Narrow a caught value to a Node.js `ErrnoException` — an Error with a `.code`
|
|
22
24
|
* string set by libuv/syscall failures (e.g. `'ENOENT'`, `'EACCES'`, `'EBUSY'`,
|
package/dist/errors/stack.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/* Socket Lib - Built with rolldown */
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
const require_errors_predicates = require('./predicates.js');
|
|
4
5
|
let src_external_pony_cause = require("../external/pony-cause");
|
|
5
6
|
|
|
6
7
|
//#region src/errors/stack.ts
|
|
@@ -18,7 +19,7 @@ let src_external_pony_cause = require("../external/pony-cause");
|
|
|
18
19
|
* errorStack(e) })` safely.
|
|
19
20
|
*/
|
|
20
21
|
function errorStack(value) {
|
|
21
|
-
if (isError(value)) return (0, src_external_pony_cause.stackWithCauses)(value);
|
|
22
|
+
if (require_errors_predicates.isError(value)) return (0, src_external_pony_cause.stackWithCauses)(value);
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
//#endregion
|
|
@@ -15,29 +15,7 @@ export declare const globalProcess: (NodeJS.Process & {
|
|
|
15
15
|
__signal_exit_emitter__?: EventEmitter | undefined;
|
|
16
16
|
reallyExit?: ((code?: number | undefined) => never) | undefined;
|
|
17
17
|
}) | undefined;
|
|
18
|
-
export declare const originalProcessEmit:
|
|
19
|
-
(event: "beforeExit", code: number): boolean;
|
|
20
|
-
(event: "disconnect"): boolean;
|
|
21
|
-
(event: "exit", code: number): boolean;
|
|
22
|
-
(event: "rejectionHandled", promise: Promise<unknown>): boolean;
|
|
23
|
-
(event: "uncaughtException", error: Error): boolean;
|
|
24
|
-
(event: "uncaughtExceptionMonitor", error: Error): boolean;
|
|
25
|
-
(event: "unhandledRejection", reason: unknown, promise: Promise<unknown>): boolean;
|
|
26
|
-
(event: "warning", warning: Error): boolean;
|
|
27
|
-
(event: "message", message: unknown, sendHandle: import("child_process").SendHandle): NodeJS.Process & {
|
|
28
|
-
__signal_exit_emitter__?: EventEmitter | undefined;
|
|
29
|
-
reallyExit?: ((code?: number | undefined) => never) | undefined;
|
|
30
|
-
};
|
|
31
|
-
(event: NodeJS.Signals, signal?: NodeJS.Signals): boolean;
|
|
32
|
-
(event: "multipleResolves", type: NodeJS.MultipleResolveType, promise: Promise<unknown>, value: unknown): NodeJS.Process & {
|
|
33
|
-
__signal_exit_emitter__?: EventEmitter | undefined;
|
|
34
|
-
reallyExit?: ((code?: number | undefined) => never) | undefined;
|
|
35
|
-
};
|
|
36
|
-
(event: "worker", listener: NodeJS.WorkerListener): NodeJS.Process & {
|
|
37
|
-
__signal_exit_emitter__?: EventEmitter | undefined;
|
|
38
|
-
reallyExit?: ((code?: number | undefined) => never) | undefined;
|
|
39
|
-
};
|
|
40
|
-
} | undefined;
|
|
18
|
+
export declare const originalProcessEmit: NodeJS.Process['emit'] | undefined;
|
|
41
19
|
export declare const platform: string;
|
|
42
20
|
export declare const originalProcessReallyExit: ((code?: number | undefined) => never) | undefined;
|
|
43
21
|
export declare const WIN32: boolean;
|