@socketsecurity/lib 5.26.0 → 5.26.1

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 (147) hide show
  1. package/CHANGELOG.md +345 -1185
  2. package/README.md +1 -1
  3. package/dist/abort.js +7 -6
  4. package/dist/agent.js +16 -15
  5. package/dist/ansi.js +3 -2
  6. package/dist/archives.js +18 -17
  7. package/dist/argv/flags.js +29 -28
  8. package/dist/argv/parse.js +4 -3
  9. package/dist/arrays.js +3 -2
  10. package/dist/bin.js +12 -11
  11. package/dist/cacache.js +16 -11
  12. package/dist/cache-with-ttl.js +26 -21
  13. package/dist/colors.js +2 -1
  14. package/dist/constants/licenses.js +2 -1
  15. package/dist/constants/lifecycle-script-names.js +2 -1
  16. package/dist/constants/maintained-node-versions.js +2 -1
  17. package/dist/constants/node.js +4 -3
  18. package/dist/constants/package-default-socket-categories.js +2 -1
  19. package/dist/constants/packages.js +4 -3
  20. package/dist/constants/socket.js +1 -1
  21. package/dist/cover/code.js +9 -8
  22. package/dist/cover/formatters.js +12 -11
  23. package/dist/cover/type.js +5 -4
  24. package/dist/crypto.d.ts +36 -0
  25. package/dist/{effects/ultra.js → crypto.js} +33 -37
  26. package/dist/debug.js +12 -15
  27. package/dist/dlx/arborist.js +10 -9
  28. package/dist/dlx/binary.js +27 -24
  29. package/dist/dlx/cache.js +2 -10
  30. package/dist/dlx/detect.js +6 -5
  31. package/dist/dlx/integrity.js +13 -11
  32. package/dist/dlx/lockfile.js +7 -6
  33. package/dist/dlx/manifest.js +6 -5
  34. package/dist/dlx/package.js +17 -16
  35. package/dist/dlx/packages.js +6 -5
  36. package/dist/dlx/paths.d.ts +1 -1
  37. package/dist/dlx/paths.js +2 -1
  38. package/dist/effects/pulse-frames.js +4 -3
  39. package/dist/effects/shimmer-keyframes.d.ts +62 -0
  40. package/dist/effects/shimmer-keyframes.js +55 -0
  41. package/dist/effects/shimmer-terminal.d.ts +66 -0
  42. package/dist/effects/shimmer-terminal.js +57 -0
  43. package/dist/effects/shimmer.d.ts +293 -0
  44. package/dist/effects/shimmer.js +180 -0
  45. package/dist/env/rewire.js +4 -3
  46. package/dist/env.js +5 -4
  47. package/dist/errors.js +1 -1
  48. package/dist/external/@npmcli/package-json/lib/read-package.js +10 -10
  49. package/dist/external/@npmcli/package-json.js +372 -372
  50. package/dist/external/@npmcli/promise-spawn.js +24 -24
  51. package/dist/external/@socketregistry/packageurl-js.js +19 -18
  52. package/dist/external/@socketregistry/yocto-spinner.js +4 -3
  53. package/dist/external/@yarnpkg/extensions.js +2 -1
  54. package/dist/external/adm-zip.js +70 -70
  55. package/dist/external/debug.js +22 -22
  56. package/dist/external/external-pack.js +45 -45
  57. package/dist/external/fast-sort.js +5 -5
  58. package/dist/external/libnpmexec.js +4 -3
  59. package/dist/external/npm-pack.js +369 -369
  60. package/dist/external/p-map.js +9 -9
  61. package/dist/external/pico-pack.js +190 -190
  62. package/dist/external/pony-cause.js +2 -1
  63. package/dist/external/spdx-pack.js +11 -10
  64. package/dist/external/tar-fs.js +58 -58
  65. package/dist/external/which.js +13 -13
  66. package/dist/external/yargs-parser.js +71 -71
  67. package/dist/fs.js +19 -23
  68. package/dist/git.js +14 -13
  69. package/dist/github.d.ts +34 -0
  70. package/dist/github.js +248 -23
  71. package/dist/globs.d.ts +20 -0
  72. package/dist/globs.js +134 -25
  73. package/dist/http-request.d.ts +4 -3
  74. package/dist/http-request.js +39 -32
  75. package/dist/ipc-cli.js +2 -1
  76. package/dist/ipc.js +5 -4
  77. package/dist/json/edit.js +4 -3
  78. package/dist/json/format.js +3 -2
  79. package/dist/json/parse.js +7 -6
  80. package/dist/links.js +2 -1
  81. package/dist/logger.js +21 -14
  82. package/dist/memoization.js +16 -15
  83. package/dist/objects.js +2 -2
  84. package/dist/packages/edit.js +8 -7
  85. package/dist/packages/exports.js +17 -16
  86. package/dist/packages/isolation.js +20 -13
  87. package/dist/packages/licenses.js +6 -3
  88. package/dist/packages/manifest.js +2 -1
  89. package/dist/packages/normalize.js +8 -4
  90. package/dist/packages/operations.js +5 -4
  91. package/dist/packages/provenance.js +7 -6
  92. package/dist/packages/specs.js +2 -1
  93. package/dist/packages/validation.js +2 -1
  94. package/dist/paths/normalize.js +32 -40
  95. package/dist/paths/packages.js +2 -1
  96. package/dist/paths/rewire.js +3 -2
  97. package/dist/performance.js +19 -18
  98. package/dist/primordials.d.ts +9 -0
  99. package/dist/primordials.js +17 -0
  100. package/dist/process-lock.js +14 -13
  101. package/dist/promise-queue.js +17 -9
  102. package/dist/promises.d.ts +29 -6
  103. package/dist/promises.js +19 -15
  104. package/dist/regexps.js +9 -8
  105. package/dist/releases/github-api.d.ts +56 -0
  106. package/dist/releases/github-api.js +275 -0
  107. package/dist/releases/github-archives.d.ts +60 -0
  108. package/dist/releases/github-archives.js +136 -0
  109. package/dist/releases/github-assets.d.ts +21 -0
  110. package/dist/releases/github-assets.js +52 -0
  111. package/dist/releases/github-auth.d.ts +16 -0
  112. package/dist/releases/github-auth.js +51 -0
  113. package/dist/releases/github-downloads.d.ts +42 -0
  114. package/dist/releases/github-downloads.js +155 -0
  115. package/dist/releases/github-types.d.ts +66 -0
  116. package/dist/{effects/types.js → releases/github-types.js} +2 -2
  117. package/dist/releases/socket-btm.d.ts +1 -1
  118. package/dist/releases/socket-btm.js +17 -17
  119. package/dist/schema/parse.js +2 -1
  120. package/dist/schema/validate.js +6 -5
  121. package/dist/shadow.js +2 -1
  122. package/dist/signal-exit.js +2 -2
  123. package/dist/spawn.js +45 -35
  124. package/dist/spinner.d.ts +13 -6
  125. package/dist/spinner.js +75 -57
  126. package/dist/ssri.js +8 -7
  127. package/dist/stdio/footer.js +13 -12
  128. package/dist/stdio/header.js +5 -4
  129. package/dist/stdio/progress.js +13 -12
  130. package/dist/strings.js +19 -18
  131. package/dist/suppress-warnings.js +2 -2
  132. package/dist/tables.js +16 -13
  133. package/dist/temporary-executor.js +2 -1
  134. package/dist/themes/context.js +2 -1
  135. package/dist/themes/types.d.ts +1 -1
  136. package/dist/themes/utils.d.ts +8 -3
  137. package/dist/themes/utils.js +29 -5
  138. package/dist/url.js +4 -3
  139. package/package.json +44 -20
  140. package/dist/effects/text-shimmer.d.ts +0 -58
  141. package/dist/effects/text-shimmer.js +0 -192
  142. package/dist/effects/types.d.ts +0 -47
  143. package/dist/effects/ultra.d.ts +0 -22
  144. package/dist/releases/github.d.ts +0 -234
  145. package/dist/releases/github.js +0 -417
  146. package/dist/themes/index.d.ts +0 -49
  147. package/dist/themes/index.js +0 -60
@@ -28,6 +28,7 @@ var import_fs = require("./fs");
28
28
  var import_logger = require("./logger");
29
29
  var import_promises = require("./promises");
30
30
  var import_signal_exit = require("./signal-exit");
31
+ var import_primordials = require("./primordials");
31
32
  let _fs;
32
33
  // @__NO_SIDE_EFFECTS__
33
34
  function getFs() {
@@ -46,8 +47,8 @@ function getPath() {
46
47
  }
47
48
  const logger = (0, import_logger.getDefaultLogger)();
48
49
  class ProcessLockManager {
49
- activeLocks = /* @__PURE__ */ new Set();
50
- touchTimers = /* @__PURE__ */ new Map();
50
+ activeLocks = new import_primordials.SetCtor();
51
+ touchTimers = new import_primordials.MapCtor();
51
52
  exitHandlerRegistered = false;
52
53
  /**
53
54
  * Ensure process exit handler is registered for cleanup.
@@ -84,7 +85,7 @@ class ProcessLockManager {
84
85
  try {
85
86
  const fs = /* @__PURE__ */ getFs();
86
87
  if (fs.existsSync(lockPath)) {
87
- const now = Date.now() / 1e3;
88
+ const now = (0, import_primordials.DateNow)() / 1e3;
88
89
  fs.utimesSync(lockPath, now, now);
89
90
  }
90
91
  } catch (e) {
@@ -135,7 +136,7 @@ class ProcessLockManager {
135
136
  if (!stats) {
136
137
  return false;
137
138
  }
138
- return Date.now() - stats.mtime.getTime() > staleMs;
139
+ return (0, import_primordials.DateNow)() - stats.mtime.getTime() > staleMs;
139
140
  } catch {
140
141
  return false;
141
142
  }
@@ -195,29 +196,29 @@ class ProcessLockManager {
195
196
  const code = e.code;
196
197
  if (code === "EEXIST") {
197
198
  if (this.isStale(lockPath, staleMs)) {
198
- throw new Error(`Stale lock detected: ${lockPath}`);
199
+ throw new import_primordials.ErrorCtor(`Stale lock detected: ${lockPath}`);
199
200
  }
200
- throw new Error(`Lock already exists: ${lockPath}`);
201
+ throw new import_primordials.ErrorCtor(`Lock already exists: ${lockPath}`);
201
202
  }
202
203
  if (code === "EACCES" || code === "EPERM") {
203
- throw new Error(
204
+ throw new import_primordials.ErrorCtor(
204
205
  `Permission denied creating lock: ${lockPath}. Check directory permissions or run with appropriate access.`,
205
206
  { cause: e }
206
207
  );
207
208
  }
208
209
  if (code === "EROFS") {
209
- throw new Error(
210
+ throw new import_primordials.ErrorCtor(
210
211
  `Cannot create lock on read-only filesystem: ${lockPath}`,
211
212
  { cause: e }
212
213
  );
213
214
  }
214
215
  if (code === "ENOTDIR") {
215
- const lastSlashIndex = Math.max(
216
+ const lastSlashIndex = (0, import_primordials.MathMax)(
216
217
  lockPath.lastIndexOf("/"),
217
218
  lockPath.lastIndexOf("\\")
218
219
  );
219
220
  const parentDir = lastSlashIndex === -1 ? "." : lockPath.slice(0, lastSlashIndex);
220
- throw new Error(
221
+ throw new import_primordials.ErrorCtor(
221
222
  `Cannot create lock directory: ${lockPath}
222
223
  A path component is a file when it should be a directory.
223
224
  Parent path: ${parentDir}
@@ -229,12 +230,12 @@ To resolve:
229
230
  );
230
231
  }
231
232
  if (code === "ENOENT") {
232
- const lastSlashIndex = Math.max(
233
+ const lastSlashIndex = (0, import_primordials.MathMax)(
233
234
  lockPath.lastIndexOf("/"),
234
235
  lockPath.lastIndexOf("\\")
235
236
  );
236
237
  const parentDir = lastSlashIndex === -1 ? "." : lockPath.slice(0, lastSlashIndex);
237
- throw new Error(
238
+ throw new import_primordials.ErrorCtor(
238
239
  `Cannot create lock directory: ${lockPath}
239
240
  Parent directory does not exist: ${parentDir}
240
241
  To resolve:
@@ -244,7 +245,7 @@ To resolve:
244
245
  { cause: e }
245
246
  );
246
247
  }
247
- throw new Error(`Failed to acquire lock: ${lockPath}`, {
248
+ throw new import_primordials.ErrorCtor(`Failed to acquire lock: ${lockPath}`, {
248
249
  cause: e
249
250
  });
250
251
  }
@@ -23,6 +23,7 @@ __export(promise_queue_exports, {
23
23
  PromiseQueue: () => PromiseQueue
24
24
  });
25
25
  module.exports = __toCommonJS(promise_queue_exports);
26
+ var import_primordials = require("./primordials");
26
27
  class PromiseQueue {
27
28
  queue = [];
28
29
  running = 0;
@@ -41,7 +42,7 @@ class PromiseQueue {
41
42
  this.maxConcurrency = maxConcurrency;
42
43
  this.maxQueueLength = maxQueueLength;
43
44
  if (maxConcurrency < 1) {
44
- throw new Error("maxConcurrency must be at least 1");
45
+ throw new import_primordials.ErrorCtor("maxConcurrency must be at least 1");
45
46
  }
46
47
  }
47
48
  /**
@@ -51,9 +52,9 @@ class PromiseQueue {
51
52
  * with "Task dropped: queue length exceeded" if the queue is full.
52
53
  */
53
54
  async add(fn) {
54
- return await new Promise((resolve, reject) => {
55
+ return await new import_primordials.PromiseCtor((resolve, reject) => {
55
56
  if (this.maxQueueLength !== void 0 && this.queue.length >= this.maxQueueLength) {
56
- reject(new Error("Task dropped: queue length exceeded"));
57
+ reject(new import_primordials.ErrorCtor("Task dropped: queue length exceeded"));
57
58
  return;
58
59
  }
59
60
  const task = { fn, resolve, reject };
@@ -71,10 +72,17 @@ class PromiseQueue {
71
72
  return;
72
73
  }
73
74
  this.running++;
74
- Promise.resolve().then(() => task.fn()).then(task.resolve).catch(task.reject).finally(() => {
75
- this.running--;
76
- this.runNext();
77
- });
75
+ (async () => {
76
+ try {
77
+ const result = await task.fn();
78
+ task.resolve(result);
79
+ } catch (err) {
80
+ task.reject(err);
81
+ } finally {
82
+ this.running--;
83
+ this.runNext();
84
+ }
85
+ })();
78
86
  }
79
87
  notifyIdleIfNeeded() {
80
88
  if (this.running === 0 && this.queue.length === 0) {
@@ -91,7 +99,7 @@ class PromiseQueue {
91
99
  if (this.running === 0 && this.queue.length === 0) {
92
100
  return;
93
101
  }
94
- return await new Promise((resolve) => {
102
+ return await new import_primordials.PromiseCtor((resolve) => {
95
103
  this.idleResolvers.push(resolve);
96
104
  });
97
105
  }
@@ -114,7 +122,7 @@ class PromiseQueue {
114
122
  const pending = this.queue;
115
123
  this.queue = [];
116
124
  for (const task of pending) {
117
- task.reject(new Error("Task cancelled: queue cleared"));
125
+ task.reject(new import_primordials.ErrorCtor("Task cancelled: queue cleared"));
118
126
  }
119
127
  this.notifyIdleIfNeeded();
120
128
  }
@@ -460,12 +460,13 @@ export interface PromiseWithResolvers<T> {
460
460
  * handles as first-class values, per
461
461
  * [ECMA-262 §27.2.4.9](https://tc39.es/ecma262/#sec-promise.withResolvers).
462
462
  *
463
- * Bound to native `Promise.withResolvers` when available (Node 20.12+ /
464
- * 21+ / 22+; V8 ≥ 12.0); otherwise falls back to a spec-equivalent
465
- * `new Promise(executor)` implementation that captures the handles via
466
- * closure. The returned object always has own data properties `promise`,
467
- * `resolve`, `reject` on `Object.prototype` — writable, enumerable, and
468
- * configurable — matching the spec's `CreateDataPropertyOrThrow` steps.
463
+ * Uses the `PromiseWithResolvers` primordial (already bound) when
464
+ * available (Node 20.12+ / 21+ / 22+; V8 ≥ 12.0); otherwise falls back
465
+ * to a spec-equivalent `new Promise(executor)` that captures the
466
+ * handles via closure. The returned object always has own data
467
+ * properties `promise`, `resolve`, `reject` on `Object.prototype` —
468
+ * writable, enumerable, and configurable — matching the spec's
469
+ * `CreateDataPropertyOrThrow` steps.
469
470
  *
470
471
  * Use this instead of the manual
471
472
  * `let resolve; const p = new Promise(r => { resolve = r })` dance for
@@ -481,3 +482,25 @@ export interface PromiseWithResolvers<T> {
481
482
  * ```
482
483
  */
483
484
  export declare const withResolvers: <T>() => PromiseWithResolvers<T>;
485
+ /**
486
+ * Drain an async iterable into an array, per
487
+ * [TC39 Array.fromAsync](https://tc39.es/proposal-array-from-async/).
488
+ *
489
+ * Uses the `ArrayFromAsync` primordial (already bound) when available
490
+ * (Node 22+; V8 ≥ 12.0); otherwise falls back to a `for await…of` +
491
+ * push loop.
492
+ *
493
+ * Use this instead of the manual
494
+ * `const out = []; for await (const x of iter) out.push(x); return out`
495
+ * dance when collecting an async iterator's values.
496
+ *
497
+ * Like the native, this only handles the unary form (no `mapFn` /
498
+ * `thisArg` overload).
499
+ *
500
+ * @example
501
+ * ```typescript
502
+ * import { glob } from 'node:fs/promises'
503
+ * const files = await fromAsync(glob('**\/*.ts', { cwd: '/tmp/proj' }))
504
+ * ```
505
+ */
506
+ export declare const fromAsync: <T>(source: AsyncIterable<T> | Iterable<T | PromiseLike<T>>) => Promise<T[]>;
package/dist/promises.js CHANGED
@@ -20,6 +20,7 @@ var __copyProps = (to, from, except, desc) => {
20
20
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
21
  var promises_exports = {};
22
22
  __export(promises_exports, {
23
+ fromAsync: () => fromAsync,
23
24
  normalizeIterationOptions: () => normalizeIterationOptions,
24
25
  normalizeRetryOptions: () => normalizeRetryOptions,
25
26
  pEach: () => pEach,
@@ -34,6 +35,7 @@ module.exports = __toCommonJS(promises_exports);
34
35
  var import_arrays = require("./arrays");
35
36
  var import_core = require("./constants/core");
36
37
  var import_process = require("./constants/process");
38
+ var import_primordials = require("./primordials");
37
39
  const abortSignal = (0, import_process.getAbortSignal)();
38
40
  let _timers;
39
41
  // @__NO_SIDE_EFFECTS__
@@ -54,7 +56,7 @@ function normalizeIterationOptions(options) {
54
56
  // AbortSignal used to support cancellation.
55
57
  signal = abortSignal
56
58
  } = { __proto__: null, ...opts };
57
- const normalizedConcurrency = Math.max(1, concurrency);
59
+ const normalizedConcurrency = (0, import_primordials.MathMax)(1, concurrency);
58
60
  const retryOpts = /* @__PURE__ */ resolveRetryOptions(retries);
59
61
  return {
60
62
  __proto__: null,
@@ -111,7 +113,7 @@ async function pEach(array, callbackFn, options) {
111
113
  if (signal?.aborted) {
112
114
  return;
113
115
  }
114
- await Promise.allSettled(
116
+ await (0, import_primordials.PromiseAllSettled)(
115
117
  chunk.map(
116
118
  (item) => /* @__PURE__ */ pRetry((...args) => callbackFn(args[0]), {
117
119
  ...retries,
@@ -158,7 +160,7 @@ async function pFilterChunk(chunks, callbackFn, options) {
158
160
  filteredChunks[i] = [];
159
161
  } else {
160
162
  const chunk = chunks[i];
161
- const settled = await Promise.allSettled(
163
+ const settled = await (0, import_primordials.PromiseAllSettled)(
162
164
  chunk.map(
163
165
  (value) => /* @__PURE__ */ pRetry((...args) => callbackFn(args[0]), {
164
166
  ...retryOpts,
@@ -211,9 +213,9 @@ async function pRetry(callbackFn, options) {
211
213
  }
212
214
  let waitTime = delay;
213
215
  if (jitter) {
214
- waitTime += Math.floor(Math.random() * delay);
216
+ waitTime += (0, import_primordials.MathFloor)((0, import_primordials.MathRandom)() * delay);
215
217
  }
216
- waitTime = Math.min(waitTime, maxDelayMs);
218
+ waitTime = (0, import_primordials.MathMin)(waitTime, maxDelayMs);
217
219
  if (typeof onRetry === "function") {
218
220
  try {
219
221
  const result = onRetry(retries - attempts, e, waitTime);
@@ -221,7 +223,7 @@ async function pRetry(callbackFn, options) {
221
223
  break;
222
224
  }
223
225
  if (typeof result === "number" && result >= 0) {
224
- waitTime = Math.min(result, maxDelayMs);
226
+ waitTime = (0, import_primordials.MathMin)(result, maxDelayMs);
225
227
  }
226
228
  } catch (e2) {
227
229
  if (onRetryRethrow) {
@@ -237,7 +239,7 @@ async function pRetry(callbackFn, options) {
237
239
  if (signal?.aborted) {
238
240
  return void 0;
239
241
  }
240
- delay = Math.min(delay * backoffFactor, maxDelayMs);
242
+ delay = (0, import_primordials.MathMin)(delay * backoffFactor, maxDelayMs);
241
243
  }
242
244
  }
243
245
  if (error !== import_core.UNDEFINED_TOKEN) {
@@ -259,23 +261,25 @@ function resolveRetryOptions(options) {
259
261
  }
260
262
  return options ? { ...defaults, ...options } : defaults;
261
263
  }
262
- const maybeNativeWithResolvers = Promise.withResolvers;
263
- const withResolvers = typeof maybeNativeWithResolvers === "function" ? (
264
- // Bind so callers who destructure the export don't lose `this`.
265
- maybeNativeWithResolvers.bind(
266
- Promise
267
- )
268
- ) : () => {
264
+ const withResolvers = import_primordials.PromiseWithResolvers !== void 0 ? import_primordials.PromiseWithResolvers : () => {
269
265
  let resolve;
270
266
  let reject;
271
- const promise = new Promise((res, rej) => {
267
+ const promise = new import_primordials.PromiseCtor((res, rej) => {
272
268
  resolve = res;
273
269
  reject = rej;
274
270
  });
275
271
  return { promise, resolve, reject };
276
272
  };
273
+ const fromAsync = import_primordials.ArrayFromAsync !== void 0 ? import_primordials.ArrayFromAsync : async (source) => {
274
+ const out = [];
275
+ for await (const item of source) {
276
+ out.push(item);
277
+ }
278
+ return out;
279
+ };
277
280
  // Annotate the CommonJS export names for ESM import in node:
278
281
  0 && (module.exports = {
282
+ fromAsync,
279
283
  normalizeIterationOptions,
280
284
  normalizeRetryOptions,
281
285
  pEach,
package/dist/regexps.js CHANGED
@@ -23,17 +23,18 @@ __export(regexps_exports, {
23
23
  escapeRegExp: () => escapeRegExp
24
24
  });
25
25
  module.exports = __toCommonJS(regexps_exports);
26
- const SYNTAX_CHARACTERS = new Set("^$\\.*+?()[]{}|/");
27
- const CONTROL_ESCAPES = /* @__PURE__ */ new Map([
26
+ var import_primordials = require("./primordials");
27
+ const SYNTAX_CHARACTERS = new import_primordials.SetCtor("^$\\.*+?()[]{}|/");
28
+ const CONTROL_ESCAPES = new import_primordials.MapCtor([
28
29
  [9, "\\t"],
29
30
  [10, "\\n"],
30
31
  [11, "\\v"],
31
32
  [12, "\\f"],
32
33
  [13, "\\r"]
33
34
  ]);
34
- const OTHER_PUNCTUATORS = new Set(",-=<>#&!%:;@~'`\"");
35
+ const OTHER_PUNCTUATORS = new import_primordials.SetCtor(",-=<>#&!%:;@~'`\"");
35
36
  function isSpecHexEscapeCp(cp) {
36
- if (OTHER_PUNCTUATORS.has(String.fromCodePoint(cp))) {
37
+ if (OTHER_PUNCTUATORS.has((0, import_primordials.StringFromCodePoint)(cp))) {
37
38
  return true;
38
39
  }
39
40
  if (cp === 10 || cp === 13 || cp === 8232 || cp === 8233) {
@@ -48,16 +49,16 @@ function isSpecHexEscapeCp(cp) {
48
49
  return false;
49
50
  }
50
51
  function hex2(n) {
51
- return n.toString(16).padStart(2, "0");
52
+ return (0, import_primordials.NumberPrototypeToString)(n, 16).padStart(2, "0");
52
53
  }
53
54
  function hex4(n) {
54
- return n.toString(16).padStart(4, "0");
55
+ return (0, import_primordials.NumberPrototypeToString)(n, 16).padStart(4, "0");
55
56
  }
56
57
  function escapeRegExpFallback(str) {
57
58
  let out = "";
58
59
  let isFirst = true;
59
60
  for (const char of str) {
60
- const cp = char.codePointAt(0);
61
+ const cp = (0, import_primordials.StringPrototypeCodePointAt)(char, 0);
61
62
  if (isFirst && (cp >= 48 && cp <= 57 || cp >= 65 && cp <= 90 || cp >= 97 && cp <= 122)) {
62
63
  out += "\\x" + hex2(cp);
63
64
  } else if (SYNTAX_CHARACTERS.has(char)) {
@@ -71,7 +72,7 @@ function escapeRegExpFallback(str) {
71
72
  out += "\\x" + hex2(cp);
72
73
  } else {
73
74
  for (let i = 0; i < char.length; i++) {
74
- out += "\\u" + hex4(char.charCodeAt(i));
75
+ out += "\\u" + hex4((0, import_primordials.StringPrototypeCharCodeAt)(char, i));
75
76
  }
76
77
  }
77
78
  } else {
@@ -0,0 +1,56 @@
1
+ /**
2
+ * @fileoverview GitHub release listing + asset-URL discovery.
3
+ *
4
+ * REST is the canonical path; we fall back to GraphQL when GitHub's
5
+ * Elasticsearch listing index is degraded (200 OK + empty body). Both
6
+ * transports normalize to the same internal `ReleaseRow` shape so the
7
+ * filtering pipeline doesn't care which transport produced the data.
8
+ */
9
+ import type { AssetPattern, RepoConfig } from './github-types';
10
+ /**
11
+ * Get latest release tag matching a tool prefix.
12
+ * Optionally filter by releases containing a matching asset.
13
+ *
14
+ * @param toolPrefix - Tool name prefix to search for (e.g., 'node-smol-')
15
+ * @param repoConfig - Repository configuration (owner/repo)
16
+ * @param options - Additional options
17
+ * @param options.assetPattern - Optional pattern to filter releases by matching asset
18
+ * @param options.nothrow - If true, return undefined instead of throwing when both REST and GraphQL backends are degraded. Default: false.
19
+ * @returns Latest release tag or undefined if not found
20
+ * @throws {Error} If both REST and GraphQL backends are degraded and nothrow is false.
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * const tag = await getLatestRelease('lief-', {
25
+ * owner: 'SocketDev', repo: 'socket-btm',
26
+ * })
27
+ * console.log(tag) // 'lief-2025-01-15-abc1234'
28
+ * ```
29
+ */
30
+ export declare function getLatestRelease(toolPrefix: string, repoConfig: RepoConfig, options?: {
31
+ assetPattern?: AssetPattern;
32
+ nothrow?: boolean;
33
+ }): Promise<string | undefined>;
34
+ /**
35
+ * Get download URL for a specific release asset.
36
+ * Supports pattern matching for dynamic asset discovery.
37
+ *
38
+ * @param tag - Release tag name
39
+ * @param assetPattern - Asset name or pattern (glob string, prefix/suffix object, or RegExp)
40
+ * @param repoConfig - Repository configuration (owner/repo)
41
+ * @param options - Additional options
42
+ * @param options.nothrow - If true, return undefined instead of throwing when both REST and GraphQL backends are degraded. Default: false.
43
+ * @returns Browser download URL for the asset, or undefined when not found.
44
+ * @throws {Error} If both REST and GraphQL backends are degraded and nothrow is false.
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * const url = await getReleaseAssetUrl(
49
+ * 'v1.0.0', 'tool-linux-x64',
50
+ * { owner: 'SocketDev', repo: 'socket-btm' },
51
+ * )
52
+ * ```
53
+ */
54
+ export declare function getReleaseAssetUrl(tag: string, assetPattern: string | AssetPattern, repoConfig: RepoConfig, options?: {
55
+ nothrow?: boolean;
56
+ }): Promise<string | undefined>;