@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.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,26 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [6.0.2](https://github.com/SocketDev/socket-lib/releases/tag/v6.0.2) - 2026-05-26
9
+
10
+ ### Added
11
+
12
+ - **`./logger/logger` and `./http-request/http-request`** as the canonical class / function-surface entries, paired with the existing `./logger/{node,browser}` and `./http-request/{node,browser}` implementations. Bundlers that honor the `'browser'` export condition pick the right impl automatically: `import { Logger } from '@socketsecurity/lib/logger/logger'` and `import { httpJson } from '@socketsecurity/lib/http-request/http-request'` work on both platforms.
13
+ - **`./logger/default`** holds the shared-singleton accessor: `getDefaultLogger()` returns one process-wide `Logger` instance (lazily constructed). Same on both platforms.
14
+ - **`./http-request` top-level export.** New canonical entry mirroring `./http-request/http-request`.
15
+ - **Package trust-status helpers in `./packages/provenance`.** `getTrustStatus(meta)` extracts `{ provenance, trustedPublisher, stagedPublish }` from an npm registry version document; `getTrustLevel(status)` maps to a 0..3 ladder and `getTrustLevelName(status)` to its name; `TRUST_LEVELS` is the single source-of-truth array (index = level); `compareTrust(a, b)` is an ascending-level comparator; `didTrustDecrease(prev, next)` flags a release that regressed its supply-chain posture.
16
+ - **`primordials/map-set` Stage 4 surface.** `getOrInsert` / `getOrInsertComputed` on `Map` / `WeakMap` plus the Set-composition methods (`union`, `intersection`, `difference`, `symmetricDifference`, `isSubsetOf`, `isSupersetOf`, `isDisjointFrom`) are ambient-declared, so consumers get types for methods Node 22+ ships but TypeScript's lib doesn't yet surface.
17
+
18
+ ### Changed (breaking)
19
+
20
+ - **`getDefaultLogger` moved from `./logger` to `./logger/default`.** The bare `./logger` entry now exposes the `Logger` class only (matching `./logger/logger`). Migration: `import { getDefaultLogger } from '@socketsecurity/lib/logger'` → `from '@socketsecurity/lib/logger/default'`.
21
+ - **`./logger/default` semantics shifted.** Previously `./logger/default` resolved to the Node logger source; that file is now `./logger/node`. The `./logger/default` path is the singleton accessor module.
22
+ - **`./http-request/convenience` removed.** `httpJson` and `httpText` live on `./http-request/node` and `./http-request/browser` alongside `httpRequest` and `HttpResponseError`. Most consumers should import from `./http-request` (auto-routing) rather than the explicit leaf.
23
+
24
+ ### Fixed
25
+
26
+ - **`./logger` auto-resolves to `./logger/browser` on browser platforms.** 6.0.1 announced this but shipped without the `'browser'` condition on the `./logger` entry, so bundlers fell through to the Node default and pulled in `node:*` builtins.
27
+
8
28
  ## [6.0.1](https://github.com/SocketDev/socket-lib/releases/tag/v6.0.1) - 2026-05-25
9
29
 
10
30
  Five additive features plus public-surface polish on top of 6.0.0. The path renames drop doubled-name leaves (`spawn/spawn`, `ttl-cache/cache`, `globs/glob`, `links/link`, `promise-queue/queue`) and regroup three top-level directories whose contents were the same concept (process events) under a new `events/` umbrella. Renames are path-only; no symbol renames or behavior changes.
@@ -77,7 +77,7 @@ const SOCKET_REGISTRY_APP_NAME = "registry";
77
77
  const SOCKET_WHEELHOUSE_APP_NAME = "wheelhouse";
78
78
  const SOCKET_APP_PREFIX = "_";
79
79
  const SOCKET_LIB_NAME = "@socketsecurity/lib";
80
- const SOCKET_LIB_VERSION = "6.0.1";
80
+ const SOCKET_LIB_VERSION = "6.0.2";
81
81
  const SOCKET_IPC_HANDSHAKE = "SOCKET_IPC_HANDSHAKE";
82
82
  const CACHE_SOCKET_API_DIR = "socket-api";
83
83
  const REGISTRY = "registry";
@@ -6,7 +6,7 @@
6
6
  * override). Co-located so the namespace / output / caller-info leaves don't
7
7
  * fragment ownership of this shared module state.
8
8
  */
9
- export declare const logger: import("../logger/default").Logger;
9
+ export declare const logger: import("../logger/node").Logger;
10
10
  export declare const debugByNamespace: Map<any, any>;
11
11
  export { getNodeUtil as getUtil } from '../node/util';
12
12
  /**
@@ -24,7 +24,7 @@ __export(firewall_exports, {
24
24
  npmPurl: () => npmPurl
25
25
  });
26
26
  module.exports = __toCommonJS(firewall_exports);
27
- var import_convenience = require("../http-request/convenience");
27
+ var import_node = require("../http-request/node");
28
28
  var import_user_agent = require("../http-request/user-agent");
29
29
  var import_error = require("../primordials/error");
30
30
  var import_map_set = require("../primordials/map-set");
@@ -59,7 +59,7 @@ async function checkFirewallPurls(arb, requestedPackage) {
59
59
  await (0, import_promise.PromiseAllSettled)(
60
60
  purls.map(async ({ name, purl, version }) => {
61
61
  try {
62
- const data = await (0, import_convenience.httpJson)(
62
+ const data = await (0, import_node.httpJson)(
63
63
  `${FIREWALL_API_URL}/${encodeURIComponent(purl)}`,
64
64
  {
65
65
  headers: { "User-Agent": (0, import_user_agent.getSocketCallerUserAgent)() },
@@ -6,7 +6,7 @@
6
6
  * - `Checksums` / `FetchChecksumsOptions` — checksum-file helpers
7
7
  */
8
8
  import type { IncomingHttpHeaders } from 'node:http';
9
- import type { Logger } from '../logger/default';
9
+ import type { Logger } from '../logger/node';
10
10
  /**
11
11
  * Configuration options for file downloads.
12
12
  */
@@ -55,7 +55,7 @@ export interface HttpDownloadOptions {
55
55
  *
56
56
  * @example
57
57
  * ;```ts
58
- * import { getDefaultLogger } from '@socketsecurity/lib/logger/default'
58
+ * import { getDefaultLogger } from '@socketsecurity/lib/logger/node'
59
59
  *
60
60
  * const logger = getDefaultLogger()
61
61
  * await httpDownload('https://example.com/file.zip', '/tmp/file.zip', {
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @file Public HTTP-request entry — re-exports the platform-correct
3
+ * implementation. Bundlers that honor the package.json `'browser'` condition
4
+ * (rolldown, vite, esbuild on browser platform) swap this entry to
5
+ * `./browser`; Node consumers get `./node`. Same named exports (`httpJson`,
6
+ * `httpText`, `httpRequest`, `HttpResponseError`) on both platforms so
7
+ * callers can write `import { httpJson } from
8
+ * '@socketsecurity/lib/http-request/http-request'` without caring about
9
+ * platform.
10
+ */
11
+ export { httpJson, httpRequest, httpText, HttpResponseError } from './node';
12
+ export type { HttpResponse, HttpRequestOptions } from './node';
@@ -0,0 +1,36 @@
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 http_request_exports = {};
22
+ __export(http_request_exports, {
23
+ HttpResponseError: () => import_node.HttpResponseError,
24
+ httpJson: () => import_node.httpJson,
25
+ httpRequest: () => import_node.httpRequest,
26
+ httpText: () => import_node.httpText
27
+ });
28
+ module.exports = __toCommonJS(http_request_exports);
29
+ var import_node = require("./node");
30
+ // Annotate the CommonJS export names for ESM import in node:
31
+ 0 && (module.exports = {
32
+ HttpResponseError,
33
+ httpJson,
34
+ httpRequest,
35
+ httpText
36
+ });
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @file Node-side HTTP request layer — the public surface (`httpJson`,
3
+ * `httpText`, `httpRequest`, `HttpResponseError`) for consumers on Node.
4
+ * Pairs with `./browser` (browser-safe variant via `fetch`); both files
5
+ * expose the same named exports so the package.json `'browser'` condition can
6
+ * swap them by platform without consumers changing their imports. `httpJson`
7
+ * and `httpText` live here directly; `httpRequest` and the shared types are
8
+ * re-exported from their dedicated leaves so the sub-imports
9
+ * (`./http-request/request`, `./http-request/response-types`) stay loadable
10
+ * individually for callers that don't want the convenience wrappers in their
11
+ * bundle.
12
+ */
13
+ import type { HttpRequestOptions } from './request-types';
14
+ export { httpRequest } from './request';
15
+ export { HttpResponseError } from './response-types';
16
+ export type { HttpResponse } from './response-types';
17
+ export type { HttpRequestOptions } from './request-types';
18
+ /**
19
+ * GET / POST a JSON endpoint. Automatically sets `Accept: application/json` and
20
+ * `Content-Type: application/json` (when a body is present); user-supplied
21
+ * headers always win. Throws `HttpResponseError` on non-2xx.
22
+ */
23
+ export declare function httpJson<T = unknown>(url: string, options?: HttpRequestOptions | undefined): Promise<T>;
24
+ /**
25
+ * GET / POST a text endpoint. Sets `Accept: text/plain` (and `Content-Type:
26
+ * text/plain` on bodies); user headers override. Throws `HttpResponseError` on
27
+ * non-2xx.
28
+ */
29
+ export declare function httpText(url: string, options?: HttpRequestOptions | undefined): Promise<string>;
@@ -18,15 +18,19 @@ var __copyProps = (to, from, except, desc) => {
18
18
  return to;
19
19
  };
20
20
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
- var convenience_exports = {};
22
- __export(convenience_exports, {
21
+ var node_exports = {};
22
+ __export(node_exports, {
23
+ HttpResponseError: () => import_response_types2.HttpResponseError,
23
24
  httpJson: () => httpJson,
25
+ httpRequest: () => import_request2.httpRequest,
24
26
  httpText: () => httpText
25
27
  });
26
- module.exports = __toCommonJS(convenience_exports);
28
+ module.exports = __toCommonJS(node_exports);
27
29
  var import_error = require("../primordials/error");
28
30
  var import_request = require("./request");
29
31
  var import_response_types = require("./response-types");
32
+ var import_request2 = require("./request");
33
+ var import_response_types2 = require("./response-types");
30
34
  async function httpJson(url, options) {
31
35
  const {
32
36
  body,
@@ -91,6 +95,8 @@ async function httpText(url, options) {
91
95
  }
92
96
  // Annotate the CommonJS export names for ESM import in node:
93
97
  0 && (module.exports = {
98
+ HttpResponseError,
94
99
  httpJson,
100
+ httpRequest,
95
101
  httpText
96
102
  });
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @file Private state shared between the `logger/default` class (which owns the
2
+ * @file Private state shared between the `logger/node` class (which owns the
3
3
  * public `Logger` surface) and `logger/console-init` (which mutates
4
4
  * `Logger.prototype` to mirror `globalConsole`). The `_` prefix keeps this
5
5
  * module out of the generated package.json `exports` map (the `dist/**\/_*`
@@ -1,16 +1,18 @@
1
1
  /**
2
- * @file Browser-safe Logger surfaceminimal shim mirroring the public
3
- * `success`/`fail`/`warn`/`error`/`info`/`log` methods of the full Node
4
- * Logger, but backed by the global `console` so it works in Chrome MV3
2
+ * @file Browser-safe `Logger` implementationmirrors the public `success` /
3
+ * `fail` / `warn` / `error` / `info` / `log` surface of the Node `Logger`
4
+ * (see `./node`) but backed by the global `console` so it works in Chrome MV3
5
5
  * service workers, content scripts, popups, and any other browser context
6
- * that doesn't have `node:process` / `node:console` / fs.
6
+ * without `node:process` / `node:console` / fs. Consumers should import
7
+ * `Logger` from `./logger` (auto-routed by the package.json `browser`
8
+ * condition) or `./default` for the singleton. `./browser` is the
9
+ * explicit-platform name; useful for tests pinning to one implementation.
7
10
  */
8
- export interface BrowserLogger {
9
- log(message: unknown, ...args: unknown[]): BrowserLogger;
10
- info(message: unknown, ...args: unknown[]): BrowserLogger;
11
- warn(message: unknown, ...args: unknown[]): BrowserLogger;
12
- error(message: unknown, ...args: unknown[]): BrowserLogger;
13
- success(message: unknown, ...args: unknown[]): BrowserLogger;
14
- fail(message: unknown, ...args: unknown[]): BrowserLogger;
11
+ export declare class Logger {
12
+ log(message: unknown, ...args: unknown[]): this;
13
+ info(message: unknown, ...args: unknown[]): this;
14
+ warn(message: unknown, ...args: unknown[]): this;
15
+ error(message: unknown, ...args: unknown[]): this;
16
+ success(message: unknown, ...args: unknown[]): this;
17
+ fail(message: unknown, ...args: unknown[]): this;
15
18
  }
16
- export declare function getDefaultLogger(): BrowserLogger;
@@ -20,14 +20,14 @@ var __copyProps = (to, from, except, desc) => {
20
20
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
21
  var browser_exports = {};
22
22
  __export(browser_exports, {
23
- getDefaultLogger: () => getDefaultLogger
23
+ Logger: () => Logger
24
24
  });
25
25
  module.exports = __toCommonJS(browser_exports);
26
26
  const SYM_SUCCESS = "\u2713";
27
27
  const SYM_FAIL = "\u2715";
28
28
  const SYM_WARN = "\u26A0";
29
29
  const SYM_INFO = "\u2139";
30
- class ConsoleBrowserLogger {
30
+ class Logger {
31
31
  log(message, ...args) {
32
32
  console.log(message, ...args);
33
33
  return this;
@@ -52,14 +52,7 @@ class ConsoleBrowserLogger {
52
52
  return this.error(message, ...args);
53
53
  }
54
54
  }
55
- let sharedLogger;
56
- function getDefaultLogger() {
57
- if (!sharedLogger) {
58
- sharedLogger = new ConsoleBrowserLogger();
59
- }
60
- return sharedLogger;
61
- }
62
55
  // Annotate the CommonJS export names for ESM import in node:
63
56
  0 && (module.exports = {
64
- getDefaultLogger
57
+ Logger
65
58
  });
@@ -38,7 +38,7 @@ var import_node_process = __toESM(require("node:process"));
38
38
  var import_object = require("../primordials/object");
39
39
  var import_reflect = require("../primordials/reflect");
40
40
  var import_internal = require("./_internal");
41
- var import_default = require("./default");
41
+ var import_node = require("./node");
42
42
  var import_symbols = require("./symbols");
43
43
  let _Console;
44
44
  let _prototypeInitialized = false;
@@ -77,7 +77,7 @@ function ensurePrototypeInitialized() {
77
77
  ]
78
78
  ];
79
79
  for (const { 0: key, 1: value } of (0, import_object.ObjectEntries)(import_internal.globalConsole)) {
80
- if (!import_default.Logger.prototype[key] && typeof value === "function") {
80
+ if (!import_node.Logger.prototype[key] && typeof value === "function") {
81
81
  const { [key]: func } = {
82
82
  [key](...args) {
83
83
  let con = import_internal.privateConsole.get(this);
@@ -110,7 +110,7 @@ function ensurePrototypeInitialized() {
110
110
  ]);
111
111
  }
112
112
  }
113
- (0, import_object.ObjectDefineProperties)(import_default.Logger.prototype, (0, import_object.ObjectFromEntries)(entries));
113
+ (0, import_object.ObjectDefineProperties)(import_node.Logger.prototype, (0, import_object.ObjectFromEntries)(entries));
114
114
  }
115
115
  // Annotate the CommonJS export names for ESM import in node:
116
116
  0 && (module.exports = {