@socketsecurity/lib 6.0.1 → 6.0.2

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.
@@ -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
  });
@@ -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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@socketsecurity/lib",
3
- "version": "6.0.1",
3
+ "version": "6.0.2",
4
4
  "description": "Core utilities and infrastructure for Socket.dev security tools",
5
5
  "keywords": [
6
6
  "Socket.dev",
@@ -1484,12 +1484,31 @@
1484
1484
  "types": "./dist/globs/types.d.ts",
1485
1485
  "default": "./dist/globs/types.js"
1486
1486
  },
1487
+ "./http-request": {
1488
+ "source": "./src/http-request/node.ts",
1489
+ "browser": {
1490
+ "types": "./dist/http-request/browser.d.ts",
1491
+ "default": "./dist/http-request/browser.js"
1492
+ },
1493
+ "types": "./dist/http-request/node.d.ts",
1494
+ "default": "./dist/http-request/node.js"
1495
+ },
1487
1496
  "./http-request/browser": {
1497
+ "browser": {
1498
+ "source": "./src/http-request/browser.ts",
1499
+ "types": "./dist/http-request/browser.d.ts",
1500
+ "default": "./dist/http-request/browser.js"
1501
+ },
1488
1502
  "source": "./src/http-request/browser.ts",
1489
1503
  "types": "./dist/http-request/browser.d.ts",
1490
1504
  "default": "./dist/http-request/browser.js"
1491
1505
  },
1492
1506
  "./http-request/browser-fetch": {
1507
+ "browser": {
1508
+ "source": "./src/http-request/browser-fetch.ts",
1509
+ "types": "./dist/http-request/browser-fetch.d.ts",
1510
+ "default": "./dist/http-request/browser-fetch.js"
1511
+ },
1493
1512
  "source": "./src/http-request/browser-fetch.ts",
1494
1513
  "types": "./dist/http-request/browser-fetch.d.ts",
1495
1514
  "default": "./dist/http-request/browser-fetch.js"
@@ -1499,11 +1518,6 @@
1499
1518
  "types": "./dist/http-request/checksums.d.ts",
1500
1519
  "default": "./dist/http-request/checksums.js"
1501
1520
  },
1502
- "./http-request/convenience": {
1503
- "source": "./src/http-request/convenience.ts",
1504
- "types": "./dist/http-request/convenience.d.ts",
1505
- "default": "./dist/http-request/convenience.js"
1506
- },
1507
1521
  "./http-request/download": {
1508
1522
  "source": "./src/http-request/download.ts",
1509
1523
  "types": "./dist/http-request/download.d.ts",
@@ -1524,6 +1538,20 @@
1524
1538
  "types": "./dist/http-request/headers.d.ts",
1525
1539
  "default": "./dist/http-request/headers.js"
1526
1540
  },
1541
+ "./http-request/http-request": {
1542
+ "source": "./src/http-request/node.ts",
1543
+ "browser": {
1544
+ "types": "./dist/http-request/browser.d.ts",
1545
+ "default": "./dist/http-request/browser.js"
1546
+ },
1547
+ "types": "./dist/http-request/node.d.ts",
1548
+ "default": "./dist/http-request/node.js"
1549
+ },
1550
+ "./http-request/node": {
1551
+ "source": "./src/http-request/node.ts",
1552
+ "types": "./dist/http-request/node.d.ts",
1553
+ "default": "./dist/http-request/node.js"
1554
+ },
1527
1555
  "./http-request/request": {
1528
1556
  "source": "./src/http-request/request.ts",
1529
1557
  "types": "./dist/http-request/request.d.ts",
@@ -1620,11 +1648,20 @@
1620
1648
  "default": "./dist/links/types.js"
1621
1649
  },
1622
1650
  "./logger": {
1623
- "source": "./src/logger/default.ts",
1624
- "types": "./dist/logger/default.d.ts",
1625
- "default": "./dist/logger/default.js"
1651
+ "source": "./src/logger/node.ts",
1652
+ "browser": {
1653
+ "types": "./dist/logger/browser.d.ts",
1654
+ "default": "./dist/logger/browser.js"
1655
+ },
1656
+ "types": "./dist/logger/node.d.ts",
1657
+ "default": "./dist/logger/node.js"
1626
1658
  },
1627
1659
  "./logger/browser": {
1660
+ "browser": {
1661
+ "source": "./src/logger/browser.ts",
1662
+ "types": "./dist/logger/browser.d.ts",
1663
+ "default": "./dist/logger/browser.js"
1664
+ },
1628
1665
  "source": "./src/logger/browser.ts",
1629
1666
  "types": "./dist/logger/browser.d.ts",
1630
1667
  "default": "./dist/logger/browser.js"
@@ -1644,6 +1681,20 @@
1644
1681
  "types": "./dist/logger/default.d.ts",
1645
1682
  "default": "./dist/logger/default.js"
1646
1683
  },
1684
+ "./logger/logger": {
1685
+ "source": "./src/logger/node.ts",
1686
+ "browser": {
1687
+ "types": "./dist/logger/browser.d.ts",
1688
+ "default": "./dist/logger/browser.js"
1689
+ },
1690
+ "types": "./dist/logger/node.d.ts",
1691
+ "default": "./dist/logger/node.js"
1692
+ },
1693
+ "./logger/node": {
1694
+ "source": "./src/logger/node.ts",
1695
+ "types": "./dist/logger/node.d.ts",
1696
+ "default": "./dist/logger/node.js"
1697
+ },
1647
1698
  "./logger/symbols": {
1648
1699
  "source": "./src/logger/symbols.ts",
1649
1700
  "types": "./dist/logger/symbols.d.ts",
@@ -2698,27 +2749,6 @@
2698
2749
  "access": "public",
2699
2750
  "provenance": true
2700
2751
  },
2701
- "scripts": {
2702
- "build": "node scripts/build/cli.mts",
2703
- "check": "node scripts/check.mts",
2704
- "check:paths": "node scripts/check-paths.mts",
2705
- "clean": "node scripts/build/clean.mts",
2706
- "cover": "node scripts/test/cover.mts",
2707
- "dev": "node scripts/build/cli.mts --watch",
2708
- "fix": "node scripts/fix.mts",
2709
- "format": "oxfmt -c .config/oxfmtrc.json --write .",
2710
- "format:check": "oxfmt -c .config/oxfmtrc.json --check .",
2711
- "lint": "node scripts/lint.mts",
2712
- "prim": "node tools/prim/bin/prim.mts",
2713
- "security": "node scripts/security.mts",
2714
- "prepare": "node scripts/install-git-hooks.mts && node scripts/build/cli.mts --quiet",
2715
- "prepublishOnly": "pnpm run build",
2716
- "test": "node scripts/test/cli.mts",
2717
- "update": "node scripts/update.mts",
2718
- "lockstep": "node scripts/lockstep.mts",
2719
- "lockstep:emit-schema": "node scripts/lockstep-emit-schema.mts",
2720
- "setup-security-tools": "node .claude/hooks/setup-security-tools/install.mts"
2721
- },
2722
2752
  "devDependencies": {
2723
2753
  "@anthropic-ai/claude-code": "2.1.92",
2724
2754
  "@babel/core": "7.28.4",
@@ -2736,13 +2766,13 @@
2736
2766
  "@npmcli/promise-spawn": "8.0.3",
2737
2767
  "@sinclair/typebox": "0.34.49",
2738
2768
  "@socketregistry/is-unicode-supported": "1.0.5",
2739
- "@socketregistry/packageurl-js": "catalog:",
2740
- "@socketregistry/packageurl-js-stable": "catalog:",
2769
+ "@socketregistry/packageurl-js": "npm:@socketregistry/packageurl-js@1.4.2",
2770
+ "@socketregistry/packageurl-js-stable": "npm:@socketregistry/packageurl-js@1.4.2",
2741
2771
  "@socketregistry/yocto-spinner": "1.0.25",
2742
- "@socketsecurity/lib": "catalog:",
2743
- "@socketsecurity/lib-stable": "catalog:",
2744
- "@socketsecurity/sdk": "catalog:",
2745
- "@socketsecurity/sdk-stable": "catalog:",
2772
+ "@socketsecurity/lib": "npm:@socketsecurity/lib@6.0.1",
2773
+ "@socketsecurity/lib-stable": "npm:@socketsecurity/lib@6.0.1",
2774
+ "@socketsecurity/sdk": "npm:@socketsecurity/sdk@4.0.1",
2775
+ "@socketsecurity/sdk-stable": "npm:@socketsecurity/sdk@4.0.1",
2746
2776
  "@types/node": "24.9.2",
2747
2777
  "@typescript/native-preview": "7.0.0-dev.20260511.1",
2748
2778
  "@vitest/coverage-v8": "4.0.3",
@@ -2773,7 +2803,6 @@
2773
2803
  "pacote": "21.5.0",
2774
2804
  "picomatch": "4.0.4",
2775
2805
  "pony-cause": "2.1.11",
2776
- "prim": "workspace:*",
2777
2806
  "semver": "7.7.2",
2778
2807
  "signal-exit": "4.1.0",
2779
2808
  "spdx-correct": "3.2.0",
@@ -2790,7 +2819,8 @@
2790
2819
  "which": "5.0.0",
2791
2820
  "yargs-parser": "22.0.0",
2792
2821
  "yoctocolors-cjs": "2.1.3",
2793
- "zod": "4.1.12"
2822
+ "zod": "4.1.12",
2823
+ "prim": "0.1.0"
2794
2824
  },
2795
2825
  "peerDependencies": {
2796
2826
  "typescript": ">=5.0.0"
@@ -2804,5 +2834,23 @@
2804
2834
  "node": ">=22",
2805
2835
  "pnpm": ">=11.3.0"
2806
2836
  },
2807
- "packageManager": "pnpm@11.3.0"
2808
- }
2837
+ "scripts": {
2838
+ "build": "node scripts/build/cli.mts",
2839
+ "check": "node scripts/check.mts",
2840
+ "check:paths": "node scripts/check-paths.mts",
2841
+ "clean": "node scripts/build/clean.mts",
2842
+ "cover": "node scripts/test/cover.mts",
2843
+ "dev": "node scripts/build/cli.mts --watch",
2844
+ "fix": "node scripts/fix.mts",
2845
+ "format": "oxfmt -c .config/oxfmtrc.json --write .",
2846
+ "format:check": "oxfmt -c .config/oxfmtrc.json --check .",
2847
+ "lint": "node scripts/lint.mts",
2848
+ "prim": "node tools/prim/bin/prim.mts",
2849
+ "security": "node scripts/security.mts",
2850
+ "test": "node scripts/test/cli.mts",
2851
+ "update": "node scripts/update.mts",
2852
+ "lockstep": "node scripts/lockstep.mts",
2853
+ "lockstep:emit-schema": "node scripts/lockstep-emit-schema.mts",
2854
+ "setup-security-tools": "node .claude/hooks/setup-security-tools/install.mts"
2855
+ }
2856
+ }
@@ -1,104 +0,0 @@
1
- /**
2
- * @file Thin convenience wrappers over `httpRequest` — `httpJson` and
3
- * `httpText`. Both set sensible default `Accept` (and `Content-Type` when a
4
- * body is present) headers, then delegate to `httpRequest`. User-supplied
5
- * headers always win in the merge. Each wrapper throws `HttpResponseError` on
6
- * non-2xx responses (parallel to the `throwOnError` mode of `httpRequest`) so
7
- * callers never have to inspect `.ok` themselves.
8
- */
9
- import type { HttpRequestOptions } from './request-types';
10
- /**
11
- * Perform an HTTP request and parse JSON response. Convenience wrapper around
12
- * `httpRequest` for JSON API calls. Automatically sets appropriate headers for
13
- * JSON requests: - `Accept: application/json` (always) - `Content-Type:
14
- * application/json` (when body is present) User-provided headers override these
15
- * defaults.
16
- *
17
- * @example
18
- * ;```ts
19
- * // Simple JSON GET (automatically sets Accept: application/json)
20
- * const data = await httpJson('https://api.example.com/data')
21
- * console.log(data)
22
- *
23
- * // With type safety
24
- * interface User {
25
- * id: number
26
- * name: string
27
- * email: string
28
- * }
29
- * const user = await httpJson<User>('https://api.example.com/user/123')
30
- * console.log(user.name, user.email)
31
- *
32
- * // POST with JSON body (automatically sets Content-Type: application/json)
33
- * const result = await httpJson('https://api.example.com/users', {
34
- * method: 'POST',
35
- * body: JSON.stringify({ name: 'Alice', email: 'alice@example.com' }),
36
- * })
37
- *
38
- * // With custom headers and retries
39
- * const data = await httpJson('https://api.example.com/data', {
40
- * headers: {
41
- * Authorization: 'Bearer token123',
42
- * },
43
- * retries: 3,
44
- * retryDelay: 1000,
45
- * })
46
- * ```
47
- *
48
- * @template T - Expected JSON response type (defaults to `unknown`)
49
- *
50
- * @param url - The URL to request (must start with http:// or https://)
51
- * @param options - Request configuration options.
52
- *
53
- * @returns Promise resolving to parsed JSON data
54
- *
55
- * @throws {Error} When request fails, response is not ok (status < 200 or >=
56
- * 300), or JSON parsing fails.
57
- */
58
- export declare function httpJson<T = unknown>(url: string, options?: HttpRequestOptions | undefined): Promise<T>;
59
- /**
60
- * Perform an HTTP request and return text response. Convenience wrapper around
61
- * `httpRequest` for fetching text content. Automatically sets appropriate
62
- * headers for text requests: - `Accept: text/plain` (always) - `Content-Type:
63
- * text/plain` (when body is present) User-provided headers override these
64
- * defaults.
65
- *
66
- * @example
67
- * ;```ts
68
- * // Fetch HTML (automatically sets Accept: text/plain)
69
- * const html = await httpText('https://example.com')
70
- * console.log(html.includes('<!DOCTYPE html>'))
71
- *
72
- * // Fetch plain text
73
- * const text = await httpText('https://example.com/file.txt')
74
- * console.log(text)
75
- *
76
- * // POST with text body (automatically sets Content-Type: text/plain)
77
- * const result = await httpText('https://example.com/api', {
78
- * method: 'POST',
79
- * body: 'raw text data',
80
- * })
81
- *
82
- * // With custom headers (override defaults)
83
- * const text = await httpText('https://example.com/data.txt', {
84
- * headers: {
85
- * Authorization: 'Bearer token123',
86
- * Accept: 'text/html', // Override default Accept header
87
- * },
88
- * })
89
- *
90
- * // With timeout
91
- * const text = await httpText('https://example.com/large-file.txt', {
92
- * timeout: 60000, // 1 minute
93
- * })
94
- * ```
95
- *
96
- * @param url - The URL to request (must start with http:// or https://)
97
- * @param options - Request configuration options.
98
- *
99
- * @returns Promise resolving to response body as UTF-8 string
100
- *
101
- * @throws {Error} When request fails or response is not ok (status < 200 or >=
102
- * 300)
103
- */
104
- export declare function httpText(url: string, options?: HttpRequestOptions | undefined): Promise<string>;