@socketsecurity/lib 6.0.1 → 6.0.3

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.
Files changed (49) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/dist/ai/profiles.d.mts +48 -25
  3. package/dist/ai/profiles.js +40 -33
  4. package/dist/ai/spawn.d.mts +2 -2
  5. package/dist/ai/types.d.mts +3 -3
  6. package/dist/ai/worktree.d.mts +2 -2
  7. package/dist/constants/socket.js +1 -1
  8. package/dist/debug/_internal.d.ts +1 -1
  9. package/dist/dlx/detect.js +4 -12
  10. package/dist/dlx/firewall.js +2 -2
  11. package/dist/fs/access.d.ts +32 -0
  12. package/dist/fs/access.js +63 -0
  13. package/dist/fs/find-up.js +9 -31
  14. package/dist/fs/resolve-module.d.ts +57 -0
  15. package/dist/fs/resolve-module.js +63 -0
  16. package/dist/fs/validate.js +3 -6
  17. package/dist/http-request/download-types.d.ts +2 -2
  18. package/dist/http-request/http-request.d.ts +12 -0
  19. package/dist/http-request/http-request.js +36 -0
  20. package/dist/http-request/node.d.ts +29 -0
  21. package/dist/http-request/{convenience.js → node.js} +9 -3
  22. package/dist/logger/_internal.d.ts +1 -1
  23. package/dist/logger/browser.d.ts +14 -12
  24. package/dist/logger/browser.js +3 -10
  25. package/dist/logger/console.js +3 -3
  26. package/dist/logger/default.d.ts +8 -402
  27. package/dist/logger/default.js +5 -822
  28. package/dist/logger/logger.d.ts +10 -0
  29. package/dist/logger/logger.js +30 -0
  30. package/dist/logger/node.d.ts +400 -0
  31. package/dist/logger/node.js +856 -0
  32. package/dist/logger/symbols-builder.d.ts +1 -1
  33. package/dist/logger/types.d.ts +1 -1
  34. package/dist/packages/provenance.d.ts +42 -0
  35. package/dist/packages/provenance.js +71 -0
  36. package/dist/paths/walk.d.ts +40 -0
  37. package/dist/paths/walk.js +63 -0
  38. package/dist/primordials/map-set.d.ts +35 -0
  39. package/dist/primordials/map-set.js +43 -0
  40. package/dist/promises/_internal.d.ts +8 -2
  41. package/dist/promises/_internal.js +1 -5
  42. package/dist/releases/github-asset-url.js +2 -11
  43. package/dist/releases/github-listing.js +2 -11
  44. package/dist/releases/github-retry-config.d.ts +31 -0
  45. package/dist/releases/github-retry-config.js +52 -0
  46. package/dist/smol/path.d.ts +51 -0
  47. package/dist/smol/path.js +42 -0
  48. package/package.json +113 -40
  49. package/dist/http-request/convenience.d.ts +0 -104
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @file Free-function helpers for per-instance log-symbol construction + symbol
3
- * stripping. Extracted from `logger/default.ts` (the `Logger` class) so the
3
+ * stripping. Extracted from `logger/node.ts` (the `Logger` class) so the
4
4
  * class stays under the 1000-line hard cap and so other callers (alt loggers,
5
5
  * format helpers) can reuse the same logic without instantiating a `Logger`.
6
6
  *
@@ -4,7 +4,7 @@
4
4
  * interface returned by `Logger.createTask`. Pure types; no runtime side
5
5
  * effects so this module stays cheap to import everywhere.
6
6
  */
7
- import type { Logger } from './default';
7
+ import type { Logger } from './node';
8
8
  /**
9
9
  * Log symbols for terminal output with colored indicators.
10
10
  *
@@ -2,6 +2,18 @@
2
2
  * @file Package provenance and attestation verification utilities.
3
3
  */
4
4
  import type { ProvenanceOptions } from './types';
5
+ /**
6
+ * Comparator ordering two trust statuses by ascending trust level. Sorts an
7
+ * array of statuses lowest-trust-first; negate for highest-first.
8
+ */
9
+ export declare function compareTrust(a: TrustStatus, b: TrustStatus): -1 | 0 | 1;
10
+ /**
11
+ * Whether `next` sits at a lower trust level than `prev` — i.e. a release
12
+ * regressed its supply-chain posture. Drives the post-publish provenance
13
+ * reminder: a version that drops from trustedPublisher back to bare provenance
14
+ * is a red flag worth surfacing.
15
+ */
16
+ export declare function didTrustDecrease(prev: TrustStatus, next: TrustStatus): boolean;
5
17
  /**
6
18
  * Fetch package provenance information from npm registry.
7
19
  *
@@ -30,7 +42,37 @@ export declare function getFetcher(): import("../external/make-fetch-happen").Ma
30
42
  * ```
31
43
  */
32
44
  export declare function getProvenanceDetails(attestationData: unknown): unknown;
45
+ /**
46
+ * Map a trust status to its 0..3 ladder level.
47
+ */
48
+ export declare function getTrustLevel(status: TrustStatus): TrustLevel;
49
+ /**
50
+ * Map a trust status to its human-readable level name.
51
+ */
52
+ export declare function getTrustLevelName(status: TrustStatus): TrustLevelName;
53
+ /**
54
+ * Extract provenance / trusted-publisher / staged-publish flags from a registry
55
+ * version document.
56
+ */
57
+ export declare function getTrustStatus(meta: unknown): TrustStatus;
33
58
  /**
34
59
  * Check if a value indicates a trusted publisher (GitHub or GitLab).
35
60
  */
36
61
  export declare function isTrustedPublisher(value: unknown): boolean;
62
+ /**
63
+ * Trust signals derived from a registry version document.
64
+ */
65
+ export interface TrustStatus {
66
+ provenance: boolean;
67
+ trustedPublisher: boolean;
68
+ stagedPublish: boolean;
69
+ }
70
+ /**
71
+ * Trust ladder, low → high. The index IS the level (0..3), so a single array
72
+ * maps both directions: `TRUST_LEVELS[level]` → name, and
73
+ * `TRUST_LEVELS.indexOf(name)` → level. One source of truth, no parallel Record
74
+ * to keep in sync.
75
+ */
76
+ export declare const TRUST_LEVELS: readonly ['none', 'provenance', 'trustedPublisher', 'stagedPublish'];
77
+ export type TrustLevel = 0 | 1 | 2 | 3;
78
+ export type TrustLevelName = (typeof TRUST_LEVELS)[number];
@@ -30,11 +30,17 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
30
30
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
31
31
  var provenance_exports = {};
32
32
  __export(provenance_exports, {
33
+ TRUST_LEVELS: () => TRUST_LEVELS,
34
+ compareTrust: () => compareTrust,
35
+ didTrustDecrease: () => didTrustDecrease,
33
36
  fetchPackageProvenance: () => fetchPackageProvenance,
34
37
  findProvenance: () => findProvenance,
35
38
  getAttestations: () => getAttestations,
36
39
  getFetcher: () => getFetcher,
37
40
  getProvenanceDetails: () => getProvenanceDetails,
41
+ getTrustLevel: () => getTrustLevel,
42
+ getTrustLevelName: () => getTrustLevelName,
43
+ getTrustStatus: () => getTrustStatus,
38
44
  isTrustedPublisher: () => isTrustedPublisher
39
45
  });
40
46
  module.exports = __toCommonJS(provenance_exports);
@@ -43,13 +49,29 @@ var import_packages = require("../constants/packages");
43
49
  var import_make_fetch_happen = __toESM(require("../external/make-fetch-happen"));
44
50
  var import_signal = require("../abort/signal");
45
51
  var import_parse = require("../url/parse");
52
+ var import_predicates = require("../objects/predicates");
46
53
  var import_array = require("../primordials/array");
47
54
  var import_buffer = require("../primordials/buffer");
48
55
  var import_json = require("../primordials/json");
56
+ var import_object = require("../primordials/object");
49
57
  var import_string = require("../primordials/string");
50
58
  const SLSA_PROVENANCE_V0_2 = "https://slsa.dev/provenance/v0.2";
51
59
  const SLSA_PROVENANCE_V1_0 = "https://slsa.dev/provenance/v1";
52
60
  let _fetcher;
61
+ function compareTrust(a, b) {
62
+ const levelA = getTrustLevel(a);
63
+ const levelB = getTrustLevel(b);
64
+ if (levelA < levelB) {
65
+ return -1;
66
+ }
67
+ if (levelA > levelB) {
68
+ return 1;
69
+ }
70
+ return 0;
71
+ }
72
+ function didTrustDecrease(prev, next) {
73
+ return getTrustLevel(next) < getTrustLevel(prev);
74
+ }
53
75
  // @__NO_SIDE_EFFECTS__
54
76
  async function fetchPackageProvenance(pkgName, pkgVersion, options) {
55
77
  const { signal, timeout = 1e4 } = {
@@ -165,6 +187,43 @@ function getProvenanceDetails(attestationData) {
165
187
  workflowRunId
166
188
  };
167
189
  }
190
+ function getTrustLevel(status) {
191
+ if (status.stagedPublish) {
192
+ return 3;
193
+ }
194
+ if (status.trustedPublisher && status.provenance) {
195
+ return 2;
196
+ }
197
+ if (status.provenance) {
198
+ return 1;
199
+ }
200
+ return 0;
201
+ }
202
+ function getTrustLevelName(status) {
203
+ return TRUST_LEVELS[getTrustLevel(status)];
204
+ }
205
+ function getTrustStatus(meta) {
206
+ const status = {
207
+ provenance: false,
208
+ trustedPublisher: false,
209
+ // Reserved: the npm registry does not yet expose a staged-publish flag, so
210
+ // this stays false until a registry signal exists to set it.
211
+ stagedPublish: false
212
+ };
213
+ if (!(0, import_predicates.isObject)(meta)) {
214
+ return status;
215
+ }
216
+ const npmUser = (0, import_object.ObjectHasOwn)(meta, "_npmUser") ? meta["_npmUser"] : void 0;
217
+ if ((0, import_predicates.isObject)(npmUser) && (0, import_object.ObjectHasOwn)(npmUser, "trustedPublisher") && npmUser["trustedPublisher"]) {
218
+ status.trustedPublisher = true;
219
+ }
220
+ const dist = (0, import_object.ObjectHasOwn)(meta, "dist") ? meta["dist"] : void 0;
221
+ const attestations = (0, import_predicates.isObject)(dist) && (0, import_object.ObjectHasOwn)(dist, "attestations") ? dist["attestations"] : void 0;
222
+ if ((0, import_predicates.isObject)(attestations) && (0, import_object.ObjectHasOwn)(attestations, "provenance") && attestations["provenance"]) {
223
+ status.provenance = true;
224
+ }
225
+ return status;
226
+ }
168
227
  function isTrustedPublisher(value) {
169
228
  if (typeof value !== "string" || !value) {
170
229
  return false;
@@ -191,12 +250,24 @@ function isTrustedPublisher(value) {
191
250
  }
192
251
  return (0, import_string.StringPrototypeIncludes)(value, "github") || (0, import_string.StringPrototypeIncludes)(value, "gitlab");
193
252
  }
253
+ const TRUST_LEVELS = [
254
+ "none",
255
+ "provenance",
256
+ "trustedPublisher",
257
+ "stagedPublish"
258
+ ];
194
259
  // Annotate the CommonJS export names for ESM import in node:
195
260
  0 && (module.exports = {
261
+ TRUST_LEVELS,
262
+ compareTrust,
263
+ didTrustDecrease,
196
264
  fetchPackageProvenance,
197
265
  findProvenance,
198
266
  getAttestations,
199
267
  getFetcher,
200
268
  getProvenanceDetails,
269
+ getTrustLevel,
270
+ getTrustLevelName,
271
+ getTrustStatus,
201
272
  isTrustedPublisher
202
273
  });
@@ -0,0 +1,40 @@
1
+ /**
2
+ * @file Walk parent directories. `walkUp` is the lazy ancestor generator that
3
+ * `fs/find-up` and package-root lookups build on: given a starting path it
4
+ * yields that path, then each parent, up to and INCLUDING the filesystem root
5
+ * (or a caller-supplied `stopAt` boundary). Lazy so a caller can stop early
6
+ * without computing the whole chain.
7
+ */
8
+ export interface WalkUpOptions {
9
+ /**
10
+ * Starting directory. Relative `from` values are resolved against this.
11
+ * Defaults to `process.cwd()`.
12
+ */
13
+ cwd?: string | undefined;
14
+ /**
15
+ * Last directory to yield (INCLUSIVE). Traversal stops after this path is
16
+ * emitted. Defaults to the filesystem root.
17
+ */
18
+ stopAt?: string | undefined;
19
+ }
20
+ /**
21
+ * Lazily yield `from` and each of its ancestor directories, up to and including
22
+ * the filesystem root (or `stopAt`). Each yielded path is normalized to forward
23
+ * slashes.
24
+ *
25
+ * @example
26
+ * ;```ts
27
+ * for (const dir of walkUp('/a/b/c')) {
28
+ * // '/a/b/c', '/a/b', '/a', '/'
29
+ * }
30
+ *
31
+ * // Stop at a boundary (inclusive):
32
+ * [...walkUp('/a/b/c', { stopAt: '/a' })] // ['/a/b/c', '/a/b', '/a']
33
+ * ```
34
+ *
35
+ * @param from - Path to start from. Relative values resolve against `cwd`.
36
+ * @param options - `cwd` and `stopAt` boundary.
37
+ *
38
+ * @returns Generator of normalized absolute directory paths.
39
+ */
40
+ export declare function walkUp(from: string, options?: WalkUpOptions | undefined): Generator<string>;
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ /* Socket Lib - Built with esbuild */
3
+ "use strict";
4
+ var __create = Object.create;
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __export = (target, all) => {
11
+ for (var name in all)
12
+ __defProp(target, name, { get: all[name], enumerable: true });
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from))
17
+ if (!__hasOwnProp.call(to, key) && key !== except)
18
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28
+ mod
29
+ ));
30
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
31
+ var walk_exports = {};
32
+ __export(walk_exports, {
33
+ walkUp: () => walkUp
34
+ });
35
+ module.exports = __toCommonJS(walk_exports);
36
+ var import_node_process = __toESM(require("node:process"));
37
+ var import_path = require("../node/path");
38
+ var import_path2 = require("../smol/path");
39
+ var import_normalize = require("./normalize");
40
+ function* walkUp(from, options) {
41
+ const { cwd = import_node_process.default.cwd(), stopAt } = {
42
+ __proto__: null,
43
+ ...options
44
+ };
45
+ const path = (0, import_path.getNodePath)();
46
+ const smol = (0, import_path2.getSmolPath)();
47
+ const dirname = smol?.dirname ?? path.dirname;
48
+ let dir = path.resolve(cwd, from);
49
+ const stopDir = stopAt ? path.resolve(cwd, stopAt) : void 0;
50
+ let prev;
51
+ while (dir !== prev) {
52
+ yield (0, import_normalize.normalizePath)(dir);
53
+ if (stopDir !== void 0 && dir === stopDir) {
54
+ return;
55
+ }
56
+ prev = dir;
57
+ dir = dirname(dir);
58
+ }
59
+ }
60
+ // Annotate the CommonJS export names for ESM import in node:
61
+ 0 && (module.exports = {
62
+ walkUp
63
+ });
@@ -4,6 +4,30 @@
4
4
  * constructor — there's a separate `weakRefSafe` wrapper in `./uncurry` for
5
5
  * the throws-on-non-Object case.
6
6
  */
7
+ declare global {
8
+ interface Map<K, V> {
9
+ getOrInsert(key: K, value: V): V;
10
+ getOrInsertComputed(key: K, callbackfn: (key: K) => V): V;
11
+ }
12
+ interface WeakMap<K extends WeakKey, V> {
13
+ getOrInsert(key: K, value: V): V;
14
+ getOrInsertComputed(key: K, callbackfn: (key: K) => V): V;
15
+ }
16
+ interface ReadonlySetLike<T> {
17
+ has(value: T): boolean;
18
+ keys(): IterableIterator<T>;
19
+ readonly size: number;
20
+ }
21
+ interface Set<T> {
22
+ difference<U>(other: ReadonlySetLike<U>): Set<T>;
23
+ intersection<U>(other: ReadonlySetLike<U>): Set<T & U>;
24
+ isDisjointFrom(other: ReadonlySetLike<unknown>): boolean;
25
+ isSubsetOf(other: ReadonlySetLike<unknown>): boolean;
26
+ isSupersetOf(other: ReadonlySetLike<unknown>): boolean;
27
+ symmetricDifference<U>(other: ReadonlySetLike<U>): Set<T | U>;
28
+ union<U>(other: ReadonlySetLike<U>): Set<T | U>;
29
+ }
30
+ }
7
31
  export declare const MapCtor: MapConstructor;
8
32
  export declare const SetCtor: SetConstructor;
9
33
  export declare const WeakMapCtor: WeakMapConstructor;
@@ -14,6 +38,8 @@ export declare const MapPrototypeDelete: (self: unknown, key: any) => boolean;
14
38
  export declare const MapPrototypeEntries: (self: unknown) => MapIterator<[any, any]>;
15
39
  export declare const MapPrototypeForEach: (self: unknown, callbackfn: (value: any, key: any, map: Map<any, any>) => void, thisArg?: any) => void;
16
40
  export declare const MapPrototypeGet: (self: unknown, key: any) => any;
41
+ export declare const MapPrototypeGetOrInsert: (self: unknown, key: any, value: any) => any;
42
+ export declare const MapPrototypeGetOrInsertComputed: (self: unknown, key: any, callbackfn: (key: any) => any) => any;
17
43
  export declare const MapPrototypeHas: (self: unknown, key: any) => boolean;
18
44
  export declare const MapPrototypeKeys: (self: unknown) => MapIterator<any>;
19
45
  export declare const MapPrototypeSet: (self: unknown, key: any, value: any) => Map<any, any>;
@@ -21,13 +47,22 @@ export declare const MapPrototypeValues: (self: unknown) => MapIterator<any>;
21
47
  export declare const SetPrototypeAdd: (self: unknown, value: any) => Set<any>;
22
48
  export declare const SetPrototypeClear: (self: unknown) => void;
23
49
  export declare const SetPrototypeDelete: (self: unknown, value: any) => boolean;
50
+ export declare const SetPrototypeDifference: <U>(self: unknown, other: ReadonlySetLike<U>) => Set<any>;
24
51
  export declare const SetPrototypeEntries: (self: unknown) => SetIterator<[any, any]>;
25
52
  export declare const SetPrototypeForEach: (self: unknown, callbackfn: (value: any, value2: any, set: Set<any>) => void, thisArg?: any) => void;
26
53
  export declare const SetPrototypeHas: (self: unknown, value: any) => boolean;
54
+ export declare const SetPrototypeIntersection: <U>(self: unknown, other: ReadonlySetLike<U>) => Set<any>;
55
+ export declare const SetPrototypeIsDisjointFrom: (self: unknown, other: ReadonlySetLike<unknown>) => boolean;
56
+ export declare const SetPrototypeIsSubsetOf: (self: unknown, other: ReadonlySetLike<unknown>) => boolean;
57
+ export declare const SetPrototypeIsSupersetOf: (self: unknown, other: ReadonlySetLike<unknown>) => boolean;
27
58
  export declare const SetPrototypeKeys: (self: unknown) => SetIterator<any>;
59
+ export declare const SetPrototypeSymmetricDifference: <U>(self: unknown, other: ReadonlySetLike<U>) => Set<any>;
60
+ export declare const SetPrototypeUnion: <U>(self: unknown, other: ReadonlySetLike<U>) => Set<any>;
28
61
  export declare const SetPrototypeValues: (self: unknown) => SetIterator<any>;
29
62
  export declare const WeakMapPrototypeDelete: (self: unknown, key: WeakKey) => boolean;
30
63
  export declare const WeakMapPrototypeGet: (self: unknown, key: WeakKey) => any;
64
+ export declare const WeakMapPrototypeGetOrInsert: (self: unknown, key: WeakKey, value: any) => any;
65
+ export declare const WeakMapPrototypeGetOrInsertComputed: (self: unknown, key: WeakKey, callbackfn: (key: WeakKey) => any) => any;
31
66
  export declare const WeakMapPrototypeHas: (self: unknown, key: WeakKey) => boolean;
32
67
  export declare const WeakMapPrototypeSet: (self: unknown, key: WeakKey, value: any) => WeakMap<WeakKey, any>;
33
68
  export declare const WeakSetPrototypeAdd: (self: unknown, value: WeakKey) => WeakSet<WeakKey>;
@@ -26,6 +26,8 @@ __export(map_set_exports, {
26
26
  MapPrototypeEntries: () => MapPrototypeEntries,
27
27
  MapPrototypeForEach: () => MapPrototypeForEach,
28
28
  MapPrototypeGet: () => MapPrototypeGet,
29
+ MapPrototypeGetOrInsert: () => MapPrototypeGetOrInsert,
30
+ MapPrototypeGetOrInsertComputed: () => MapPrototypeGetOrInsertComputed,
29
31
  MapPrototypeHas: () => MapPrototypeHas,
30
32
  MapPrototypeKeys: () => MapPrototypeKeys,
31
33
  MapPrototypeSet: () => MapPrototypeSet,
@@ -34,14 +36,23 @@ __export(map_set_exports, {
34
36
  SetPrototypeAdd: () => SetPrototypeAdd,
35
37
  SetPrototypeClear: () => SetPrototypeClear,
36
38
  SetPrototypeDelete: () => SetPrototypeDelete,
39
+ SetPrototypeDifference: () => SetPrototypeDifference,
37
40
  SetPrototypeEntries: () => SetPrototypeEntries,
38
41
  SetPrototypeForEach: () => SetPrototypeForEach,
39
42
  SetPrototypeHas: () => SetPrototypeHas,
43
+ SetPrototypeIntersection: () => SetPrototypeIntersection,
44
+ SetPrototypeIsDisjointFrom: () => SetPrototypeIsDisjointFrom,
45
+ SetPrototypeIsSubsetOf: () => SetPrototypeIsSubsetOf,
46
+ SetPrototypeIsSupersetOf: () => SetPrototypeIsSupersetOf,
40
47
  SetPrototypeKeys: () => SetPrototypeKeys,
48
+ SetPrototypeSymmetricDifference: () => SetPrototypeSymmetricDifference,
49
+ SetPrototypeUnion: () => SetPrototypeUnion,
41
50
  SetPrototypeValues: () => SetPrototypeValues,
42
51
  WeakMapCtor: () => WeakMapCtor,
43
52
  WeakMapPrototypeDelete: () => WeakMapPrototypeDelete,
44
53
  WeakMapPrototypeGet: () => WeakMapPrototypeGet,
54
+ WeakMapPrototypeGetOrInsert: () => WeakMapPrototypeGetOrInsert,
55
+ WeakMapPrototypeGetOrInsertComputed: () => WeakMapPrototypeGetOrInsertComputed,
45
56
  WeakMapPrototypeHas: () => WeakMapPrototypeHas,
46
57
  WeakMapPrototypeSet: () => WeakMapPrototypeSet,
47
58
  WeakRefCtor: () => WeakRefCtor,
@@ -62,6 +73,10 @@ const MapPrototypeDelete = (0, import_uncurry.uncurryThis)(Map.prototype.delete)
62
73
  const MapPrototypeEntries = (0, import_uncurry.uncurryThis)(Map.prototype.entries);
63
74
  const MapPrototypeForEach = (0, import_uncurry.uncurryThis)(Map.prototype.forEach);
64
75
  const MapPrototypeGet = (0, import_uncurry.uncurryThis)(Map.prototype.get);
76
+ const MapPrototypeGetOrInsert = (0, import_uncurry.uncurryThis)(Map.prototype.getOrInsert);
77
+ const MapPrototypeGetOrInsertComputed = (0, import_uncurry.uncurryThis)(
78
+ Map.prototype.getOrInsertComputed
79
+ );
65
80
  const MapPrototypeHas = (0, import_uncurry.uncurryThis)(Map.prototype.has);
66
81
  const MapPrototypeKeys = (0, import_uncurry.uncurryThis)(Map.prototype.keys);
67
82
  const MapPrototypeSet = (0, import_uncurry.uncurryThis)(Map.prototype.set);
@@ -69,13 +84,30 @@ const MapPrototypeValues = (0, import_uncurry.uncurryThis)(Map.prototype.values)
69
84
  const SetPrototypeAdd = (0, import_uncurry.uncurryThis)(Set.prototype.add);
70
85
  const SetPrototypeClear = (0, import_uncurry.uncurryThis)(Set.prototype.clear);
71
86
  const SetPrototypeDelete = (0, import_uncurry.uncurryThis)(Set.prototype.delete);
87
+ const SetPrototypeDifference = (0, import_uncurry.uncurryThis)(Set.prototype.difference);
72
88
  const SetPrototypeEntries = (0, import_uncurry.uncurryThis)(Set.prototype.entries);
73
89
  const SetPrototypeForEach = (0, import_uncurry.uncurryThis)(Set.prototype.forEach);
74
90
  const SetPrototypeHas = (0, import_uncurry.uncurryThis)(Set.prototype.has);
91
+ const SetPrototypeIntersection = (0, import_uncurry.uncurryThis)(Set.prototype.intersection);
92
+ const SetPrototypeIsDisjointFrom = (0, import_uncurry.uncurryThis)(
93
+ Set.prototype.isDisjointFrom
94
+ );
95
+ const SetPrototypeIsSubsetOf = (0, import_uncurry.uncurryThis)(Set.prototype.isSubsetOf);
96
+ const SetPrototypeIsSupersetOf = (0, import_uncurry.uncurryThis)(Set.prototype.isSupersetOf);
75
97
  const SetPrototypeKeys = (0, import_uncurry.uncurryThis)(Set.prototype.keys);
98
+ const SetPrototypeSymmetricDifference = (0, import_uncurry.uncurryThis)(
99
+ Set.prototype.symmetricDifference
100
+ );
101
+ const SetPrototypeUnion = (0, import_uncurry.uncurryThis)(Set.prototype.union);
76
102
  const SetPrototypeValues = (0, import_uncurry.uncurryThis)(Set.prototype.values);
77
103
  const WeakMapPrototypeDelete = (0, import_uncurry.uncurryThis)(WeakMap.prototype.delete);
78
104
  const WeakMapPrototypeGet = (0, import_uncurry.uncurryThis)(WeakMap.prototype.get);
105
+ const WeakMapPrototypeGetOrInsert = (0, import_uncurry.uncurryThis)(
106
+ WeakMap.prototype.getOrInsert
107
+ );
108
+ const WeakMapPrototypeGetOrInsertComputed = (0, import_uncurry.uncurryThis)(
109
+ WeakMap.prototype.getOrInsertComputed
110
+ );
79
111
  const WeakMapPrototypeHas = (0, import_uncurry.uncurryThis)(WeakMap.prototype.has);
80
112
  const WeakMapPrototypeSet = (0, import_uncurry.uncurryThis)(WeakMap.prototype.set);
81
113
  const WeakSetPrototypeAdd = (0, import_uncurry.uncurryThis)(WeakSet.prototype.add);
@@ -89,6 +121,8 @@ const WeakSetPrototypeHas = (0, import_uncurry.uncurryThis)(WeakSet.prototype.ha
89
121
  MapPrototypeEntries,
90
122
  MapPrototypeForEach,
91
123
  MapPrototypeGet,
124
+ MapPrototypeGetOrInsert,
125
+ MapPrototypeGetOrInsertComputed,
92
126
  MapPrototypeHas,
93
127
  MapPrototypeKeys,
94
128
  MapPrototypeSet,
@@ -97,14 +131,23 @@ const WeakSetPrototypeHas = (0, import_uncurry.uncurryThis)(WeakSet.prototype.ha
97
131
  SetPrototypeAdd,
98
132
  SetPrototypeClear,
99
133
  SetPrototypeDelete,
134
+ SetPrototypeDifference,
100
135
  SetPrototypeEntries,
101
136
  SetPrototypeForEach,
102
137
  SetPrototypeHas,
138
+ SetPrototypeIntersection,
139
+ SetPrototypeIsDisjointFrom,
140
+ SetPrototypeIsSubsetOf,
141
+ SetPrototypeIsSupersetOf,
103
142
  SetPrototypeKeys,
143
+ SetPrototypeSymmetricDifference,
144
+ SetPrototypeUnion,
104
145
  SetPrototypeValues,
105
146
  WeakMapCtor,
106
147
  WeakMapPrototypeDelete,
107
148
  WeakMapPrototypeGet,
149
+ WeakMapPrototypeGetOrInsert,
150
+ WeakMapPrototypeGetOrInsertComputed,
108
151
  WeakMapPrototypeHas,
109
152
  WeakMapPrototypeSet,
110
153
  WeakRefCtor,
@@ -5,8 +5,14 @@
5
5
  */
6
6
  export declare const abortSignal: AbortSignal;
7
7
  /**
8
- * Get the timers/promises module. Uses lazy loading to avoid Webpack bundling
9
- * issues.
8
+ * Get the timers/promises module. Lazy `require` (not a top-level import) to
9
+ * avoid Webpack bundling issues.
10
+ *
11
+ * Intentionally NOT memoized: Node's module cache already makes the repeat
12
+ * `require` effectively free, and caching the reference breaks fake timers
13
+ * (`vi.useFakeTimers()` swaps the clock after this module loads; a cached
14
+ * reference would hold the pre-fake real `setTimeout`, burning real wallclock
15
+ * on retry backoff and starving the test worker pool).
10
16
  *
11
17
  * @private
12
18
  *
@@ -26,13 +26,9 @@ __export(internal_exports, {
26
26
  module.exports = __toCommonJS(internal_exports);
27
27
  var import_abort = require("../process/abort");
28
28
  const abortSignal = (0, import_abort.getAbortSignal)();
29
- let _timers;
30
29
  // @__NO_SIDE_EFFECTS__
31
30
  function getTimers() {
32
- if (_timers === void 0) {
33
- _timers = require("node:timers/promises");
34
- }
35
- return _timers;
31
+ return require("node:timers/promises");
36
32
  }
37
33
  // Annotate the CommonJS export names for ESM import in node:
38
34
  0 && (module.exports = {
@@ -29,18 +29,9 @@ var import_retry = require("../promises/retry");
29
29
  var import_array = require("../primordials/array");
30
30
  var import_error = require("../primordials/error");
31
31
  var import_json = require("../primordials/json");
32
- var import_object = require("../primordials/object");
33
32
  var import_github_assets = require("./github-assets");
34
33
  var import_github_auth = require("./github-auth");
35
- const RETRY_CONFIG = (0, import_object.ObjectFreeze)({
36
- __proto__: null,
37
- // Exponential backoff: delay doubles with each retry (5s, 10s, 20s).
38
- backoffFactor: 2,
39
- // Initial delay before first retry.
40
- baseDelayMs: 5e3,
41
- // Maximum number of retry attempts (excluding initial request).
42
- retries: 2
43
- });
34
+ var import_github_retry_config = require("./github-retry-config");
44
35
  async function fetchReleaseAssetsViaGraphQL(owner, repo, tag) {
45
36
  const response = await (0, import_request.httpRequest)("https://api.github.com/graphql", {
46
37
  body: (0, import_json.JSONStringify)({
@@ -143,7 +134,7 @@ async function getReleaseAssetUrl(tag, assetPattern, repoConfig, options = {}) {
143
134
  assets2 = release.assets;
144
135
  }
145
136
  return assets2;
146
- }, RETRY_CONFIG);
137
+ }, import_github_retry_config.GITHUB_RETRY_CONFIG);
147
138
  if (!assets) {
148
139
  if (nothrow) {
149
140
  return void 0;
@@ -31,19 +31,10 @@ var import_array = require("../primordials/array");
31
31
  var import_date = require("../primordials/date");
32
32
  var import_error = require("../primordials/error");
33
33
  var import_json = require("../primordials/json");
34
- var import_object = require("../primordials/object");
35
34
  var import_string = require("../primordials/string");
36
35
  var import_github_assets = require("./github-assets");
37
36
  var import_github_auth = require("./github-auth");
38
- const RETRY_CONFIG = (0, import_object.ObjectFreeze)({
39
- __proto__: null,
40
- // Exponential backoff: delay doubles with each retry (5s, 10s, 20s).
41
- backoffFactor: 2,
42
- // Initial delay before first retry.
43
- baseDelayMs: 5e3,
44
- // Maximum number of retry attempts (excluding initial request).
45
- retries: 2
46
- });
37
+ var import_github_retry_config = require("./github-retry-config");
47
38
  async function fetchReleasesViaGraphQL(owner, repo) {
48
39
  const response = await (0, import_request.httpRequest)("https://api.github.com/graphql", {
49
40
  body: (0, import_json.JSONStringify)({
@@ -161,7 +152,7 @@ async function getLatestRelease(toolPrefix, repoConfig, options = {}) {
161
152
  );
162
153
  const latestRelease = matchingReleases[0];
163
154
  return latestRelease.tag_name;
164
- }, RETRY_CONFIG) ?? void 0;
155
+ }, import_github_retry_config.GITHUB_RETRY_CONFIG) ?? void 0;
165
156
  }
166
157
  // Annotate the CommonJS export names for ESM import in node:
167
158
  0 && (module.exports = {
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @file Shared retry configuration for the GitHub release helpers
3
+ * (`github-listing`, `github-asset-url`). Exponential backoff over the
4
+ * transient-failure / rate-limit surface. `baseDelayMs` is overridable via
5
+ * `SOCKET_GITHUB_RETRY_BASE_DELAY_MS` — set it to `0` for near-instant
6
+ * retries. Tests set it so the backoff sleep (5s + 10s of real wallclock)
7
+ * doesn't run: pRetry's delay goes through `node:timers/promises`, which
8
+ * `vi.useFakeTimers()` doesn't reliably intercept, so a zero base delay is
9
+ * the robust, fake-timer-independent way to keep these tests fast. CI can
10
+ * also dial it down. Default stays 5000ms for production resilience.
11
+ */
12
+ /**
13
+ * Default base delay (ms) before the first retry when the env override is unset
14
+ * or non-numeric.
15
+ */
16
+ export declare const DEFAULT_BASE_DELAY_MS = 5000;
17
+ /**
18
+ * Resolve the retry base delay from `SOCKET_GITHUB_RETRY_BASE_DELAY_MS`,
19
+ * falling back to {@link DEFAULT_BASE_DELAY_MS}. Read live (not memoized) so
20
+ * it's unit-testable by mutating the env — and so a long-lived process that has
21
+ * the env changed under it picks up the new value on next read.
22
+ *
23
+ * @returns The configured base delay in milliseconds.
24
+ */
25
+ export declare function resolveBaseDelayMs(): number;
26
+ export declare const GITHUB_RETRY_CONFIG: Readonly<{
27
+ __proto__: null;
28
+ backoffFactor: 2;
29
+ baseDelayMs: number;
30
+ retries: 2;
31
+ }>;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ /* Socket Lib - Built with esbuild */
3
+ "use strict";
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
+ var github_retry_config_exports = {};
22
+ __export(github_retry_config_exports, {
23
+ DEFAULT_BASE_DELAY_MS: () => DEFAULT_BASE_DELAY_MS,
24
+ GITHUB_RETRY_CONFIG: () => GITHUB_RETRY_CONFIG,
25
+ resolveBaseDelayMs: () => resolveBaseDelayMs
26
+ });
27
+ module.exports = __toCommonJS(github_retry_config_exports);
28
+ var import_number = require("../env/number");
29
+ var import_rewire = require("../env/rewire");
30
+ var import_object = require("../primordials/object");
31
+ const DEFAULT_BASE_DELAY_MS = 5e3;
32
+ function resolveBaseDelayMs() {
33
+ return (0, import_number.envAsNumber)(
34
+ (0, import_rewire.getEnvValue)("SOCKET_GITHUB_RETRY_BASE_DELAY_MS"),
35
+ DEFAULT_BASE_DELAY_MS
36
+ );
37
+ }
38
+ const GITHUB_RETRY_CONFIG = (0, import_object.ObjectFreeze)({
39
+ __proto__: null,
40
+ // Exponential backoff: delay doubles with each retry (5s, 10s, 20s).
41
+ backoffFactor: 2,
42
+ // Initial delay before first retry. Overridable for tests / CI.
43
+ baseDelayMs: resolveBaseDelayMs(),
44
+ // Maximum number of retry attempts (excluding initial request).
45
+ retries: 2
46
+ });
47
+ // Annotate the CommonJS export names for ESM import in node:
48
+ 0 && (module.exports = {
49
+ DEFAULT_BASE_DELAY_MS,
50
+ GITHUB_RETRY_CONFIG,
51
+ resolveBaseDelayMs
52
+ });