@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.
- package/CHANGELOG.md +38 -0
- package/dist/ai/profiles.d.mts +48 -25
- package/dist/ai/profiles.js +40 -33
- package/dist/ai/spawn.d.mts +2 -2
- package/dist/ai/types.d.mts +3 -3
- package/dist/ai/worktree.d.mts +2 -2
- package/dist/constants/socket.js +1 -1
- package/dist/debug/_internal.d.ts +1 -1
- package/dist/dlx/detect.js +4 -12
- package/dist/dlx/firewall.js +2 -2
- package/dist/fs/access.d.ts +32 -0
- package/dist/fs/access.js +63 -0
- package/dist/fs/find-up.js +9 -31
- package/dist/fs/resolve-module.d.ts +57 -0
- package/dist/fs/resolve-module.js +63 -0
- package/dist/fs/validate.js +3 -6
- package/dist/http-request/download-types.d.ts +2 -2
- package/dist/http-request/http-request.d.ts +12 -0
- package/dist/http-request/http-request.js +36 -0
- package/dist/http-request/node.d.ts +29 -0
- package/dist/http-request/{convenience.js → node.js} +9 -3
- package/dist/logger/_internal.d.ts +1 -1
- package/dist/logger/browser.d.ts +14 -12
- package/dist/logger/browser.js +3 -10
- package/dist/logger/console.js +3 -3
- package/dist/logger/default.d.ts +8 -402
- package/dist/logger/default.js +5 -822
- package/dist/logger/logger.d.ts +10 -0
- package/dist/logger/logger.js +30 -0
- package/dist/logger/node.d.ts +400 -0
- package/dist/logger/node.js +856 -0
- package/dist/logger/symbols-builder.d.ts +1 -1
- package/dist/logger/types.d.ts +1 -1
- package/dist/packages/provenance.d.ts +42 -0
- package/dist/packages/provenance.js +71 -0
- package/dist/paths/walk.d.ts +40 -0
- package/dist/paths/walk.js +63 -0
- package/dist/primordials/map-set.d.ts +35 -0
- package/dist/primordials/map-set.js +43 -0
- package/dist/promises/_internal.d.ts +8 -2
- package/dist/promises/_internal.js +1 -5
- package/dist/releases/github-asset-url.js +2 -11
- package/dist/releases/github-listing.js +2 -11
- package/dist/releases/github-retry-config.d.ts +31 -0
- package/dist/releases/github-retry-config.js +52 -0
- package/dist/smol/path.d.ts +51 -0
- package/dist/smol/path.js +42 -0
- package/package.json +113 -40
- package/dist/http-request/convenience.d.ts +0 -104
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Lazy-loader for socket-btm's `node:smol-path` — native fast paths for
|
|
3
|
+
* the hot path-string primitives (`dirname`, `normalize`, …) and, per the
|
|
4
|
+
* socket-btm `node-smol-path` Phase 4 plan, batched filesystem ops (`access`,
|
|
5
|
+
* an in-C++ `findUp`). Returns `undefined` on stock Node, non-Node runtimes,
|
|
6
|
+
* and on socket-btm binaries that haven't shipped the binding yet; callers
|
|
7
|
+
* fall back to the JS implementation. Result is cached. The binding does not
|
|
8
|
+
* exist yet (the plan is unbuilt) — this accessor is the seam so that when it
|
|
9
|
+
* lands, only this file changes and `paths/walk`, `fs/access`, `fs/find-up`
|
|
10
|
+
* light up natively. Today `getSmolPath()` is always `undefined` and the JS
|
|
11
|
+
* paths run.
|
|
12
|
+
*/
|
|
13
|
+
import type { PathLike } from 'node:fs';
|
|
14
|
+
/**
|
|
15
|
+
* Native path / filesystem fast-path surface. Only the operations socket-lib's
|
|
16
|
+
* helpers shim are typed; the binding may expose more. Every method is optional
|
|
17
|
+
* so a partial rollout (e.g. `dirname` ships before `access`) still type-checks
|
|
18
|
+
* at the shim sites.
|
|
19
|
+
*/
|
|
20
|
+
export interface SmolPathBinding {
|
|
21
|
+
/**
|
|
22
|
+
* `path.dirname` over the one-byte Fast API. ASCII fast path; two-byte inputs
|
|
23
|
+
* route to the equivalent of `path.dirname`.
|
|
24
|
+
*/
|
|
25
|
+
dirname?: ((p: string) => string) | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* `path.normalize` over the one-byte Fast API.
|
|
28
|
+
*/
|
|
29
|
+
normalize?: ((p: string) => string) | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* `fs.accessSync`-equivalent returning a boolean instead of throwing — skips
|
|
32
|
+
* the V8 error-object materialization the JS wrapper pays on every negative
|
|
33
|
+
* check. `mode` is an `fs.constants` bit.
|
|
34
|
+
*/
|
|
35
|
+
access?: ((path: PathLike, mode?: number | undefined) => boolean) | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* In-C++ find-up: walk `startDir`'s ancestors, return the first dir
|
|
38
|
+
* containing any of `names` (as a file unless `onlyDirectories`), or
|
|
39
|
+
* `undefined`. Collapses the N JS↔native crossings of the JS walk into one.
|
|
40
|
+
*/
|
|
41
|
+
findUp?: ((startDir: string, names: readonly string[], options?: {
|
|
42
|
+
onlyDirectories?: boolean | undefined;
|
|
43
|
+
} | undefined) => string | undefined) | undefined;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Returns the `node:smol-path` binding when running on a smol Node binary that
|
|
47
|
+
* ships it; otherwise `undefined`. Cached across calls.
|
|
48
|
+
*
|
|
49
|
+
* @returns The native binding, or `undefined` to signal "use the JS fallback".
|
|
50
|
+
*/
|
|
51
|
+
export declare function getSmolPath(): SmolPathBinding | undefined;
|
|
@@ -0,0 +1,42 @@
|
|
|
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 path_exports = {};
|
|
22
|
+
__export(path_exports, {
|
|
23
|
+
getSmolPath: () => getSmolPath
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(path_exports);
|
|
26
|
+
var import_module = require("../node/module");
|
|
27
|
+
let _smolPath;
|
|
28
|
+
let _smolPathProbed = false;
|
|
29
|
+
// @__NO_SIDE_EFFECTS__
|
|
30
|
+
function getSmolPath() {
|
|
31
|
+
if (!_smolPathProbed) {
|
|
32
|
+
_smolPathProbed = true;
|
|
33
|
+
if ((0, import_module.isNodeBuiltin)("node:smol-path")) {
|
|
34
|
+
_smolPath = require("node:smol-path");
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return _smolPath;
|
|
38
|
+
}
|
|
39
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
+
0 && (module.exports = {
|
|
41
|
+
getSmolPath
|
|
42
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@socketsecurity/lib",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.3",
|
|
4
4
|
"description": "Core utilities and infrastructure for Socket.dev security tools",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Socket.dev",
|
|
@@ -1319,6 +1319,11 @@
|
|
|
1319
1319
|
"types": "./dist/external-tools/uv/types.d.ts",
|
|
1320
1320
|
"default": "./dist/external-tools/uv/types.js"
|
|
1321
1321
|
},
|
|
1322
|
+
"./fs/access": {
|
|
1323
|
+
"source": "./src/fs/access.ts",
|
|
1324
|
+
"types": "./dist/fs/access.d.ts",
|
|
1325
|
+
"default": "./dist/fs/access.js"
|
|
1326
|
+
},
|
|
1322
1327
|
"./fs/encoding": {
|
|
1323
1328
|
"source": "./src/fs/encoding.ts",
|
|
1324
1329
|
"types": "./dist/fs/encoding.d.ts",
|
|
@@ -1359,6 +1364,11 @@
|
|
|
1359
1364
|
"types": "./dist/fs/read-json-cache.d.ts",
|
|
1360
1365
|
"default": "./dist/fs/read-json-cache.js"
|
|
1361
1366
|
},
|
|
1367
|
+
"./fs/resolve-module": {
|
|
1368
|
+
"source": "./src/fs/resolve-module.ts",
|
|
1369
|
+
"types": "./dist/fs/resolve-module.d.ts",
|
|
1370
|
+
"default": "./dist/fs/resolve-module.js"
|
|
1371
|
+
},
|
|
1362
1372
|
"./fs/safe": {
|
|
1363
1373
|
"source": "./src/fs/safe.ts",
|
|
1364
1374
|
"types": "./dist/fs/safe.d.ts",
|
|
@@ -1484,12 +1494,31 @@
|
|
|
1484
1494
|
"types": "./dist/globs/types.d.ts",
|
|
1485
1495
|
"default": "./dist/globs/types.js"
|
|
1486
1496
|
},
|
|
1497
|
+
"./http-request": {
|
|
1498
|
+
"source": "./src/http-request/node.ts",
|
|
1499
|
+
"browser": {
|
|
1500
|
+
"types": "./dist/http-request/browser.d.ts",
|
|
1501
|
+
"default": "./dist/http-request/browser.js"
|
|
1502
|
+
},
|
|
1503
|
+
"types": "./dist/http-request/node.d.ts",
|
|
1504
|
+
"default": "./dist/http-request/node.js"
|
|
1505
|
+
},
|
|
1487
1506
|
"./http-request/browser": {
|
|
1507
|
+
"browser": {
|
|
1508
|
+
"source": "./src/http-request/browser.ts",
|
|
1509
|
+
"types": "./dist/http-request/browser.d.ts",
|
|
1510
|
+
"default": "./dist/http-request/browser.js"
|
|
1511
|
+
},
|
|
1488
1512
|
"source": "./src/http-request/browser.ts",
|
|
1489
1513
|
"types": "./dist/http-request/browser.d.ts",
|
|
1490
1514
|
"default": "./dist/http-request/browser.js"
|
|
1491
1515
|
},
|
|
1492
1516
|
"./http-request/browser-fetch": {
|
|
1517
|
+
"browser": {
|
|
1518
|
+
"source": "./src/http-request/browser-fetch.ts",
|
|
1519
|
+
"types": "./dist/http-request/browser-fetch.d.ts",
|
|
1520
|
+
"default": "./dist/http-request/browser-fetch.js"
|
|
1521
|
+
},
|
|
1493
1522
|
"source": "./src/http-request/browser-fetch.ts",
|
|
1494
1523
|
"types": "./dist/http-request/browser-fetch.d.ts",
|
|
1495
1524
|
"default": "./dist/http-request/browser-fetch.js"
|
|
@@ -1499,11 +1528,6 @@
|
|
|
1499
1528
|
"types": "./dist/http-request/checksums.d.ts",
|
|
1500
1529
|
"default": "./dist/http-request/checksums.js"
|
|
1501
1530
|
},
|
|
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
1531
|
"./http-request/download": {
|
|
1508
1532
|
"source": "./src/http-request/download.ts",
|
|
1509
1533
|
"types": "./dist/http-request/download.d.ts",
|
|
@@ -1524,6 +1548,20 @@
|
|
|
1524
1548
|
"types": "./dist/http-request/headers.d.ts",
|
|
1525
1549
|
"default": "./dist/http-request/headers.js"
|
|
1526
1550
|
},
|
|
1551
|
+
"./http-request/http-request": {
|
|
1552
|
+
"source": "./src/http-request/node.ts",
|
|
1553
|
+
"browser": {
|
|
1554
|
+
"types": "./dist/http-request/browser.d.ts",
|
|
1555
|
+
"default": "./dist/http-request/browser.js"
|
|
1556
|
+
},
|
|
1557
|
+
"types": "./dist/http-request/node.d.ts",
|
|
1558
|
+
"default": "./dist/http-request/node.js"
|
|
1559
|
+
},
|
|
1560
|
+
"./http-request/node": {
|
|
1561
|
+
"source": "./src/http-request/node.ts",
|
|
1562
|
+
"types": "./dist/http-request/node.d.ts",
|
|
1563
|
+
"default": "./dist/http-request/node.js"
|
|
1564
|
+
},
|
|
1527
1565
|
"./http-request/request": {
|
|
1528
1566
|
"source": "./src/http-request/request.ts",
|
|
1529
1567
|
"types": "./dist/http-request/request.d.ts",
|
|
@@ -1620,11 +1658,20 @@
|
|
|
1620
1658
|
"default": "./dist/links/types.js"
|
|
1621
1659
|
},
|
|
1622
1660
|
"./logger": {
|
|
1623
|
-
"source": "./src/logger/
|
|
1624
|
-
"
|
|
1625
|
-
|
|
1661
|
+
"source": "./src/logger/node.ts",
|
|
1662
|
+
"browser": {
|
|
1663
|
+
"types": "./dist/logger/browser.d.ts",
|
|
1664
|
+
"default": "./dist/logger/browser.js"
|
|
1665
|
+
},
|
|
1666
|
+
"types": "./dist/logger/node.d.ts",
|
|
1667
|
+
"default": "./dist/logger/node.js"
|
|
1626
1668
|
},
|
|
1627
1669
|
"./logger/browser": {
|
|
1670
|
+
"browser": {
|
|
1671
|
+
"source": "./src/logger/browser.ts",
|
|
1672
|
+
"types": "./dist/logger/browser.d.ts",
|
|
1673
|
+
"default": "./dist/logger/browser.js"
|
|
1674
|
+
},
|
|
1628
1675
|
"source": "./src/logger/browser.ts",
|
|
1629
1676
|
"types": "./dist/logger/browser.d.ts",
|
|
1630
1677
|
"default": "./dist/logger/browser.js"
|
|
@@ -1644,6 +1691,20 @@
|
|
|
1644
1691
|
"types": "./dist/logger/default.d.ts",
|
|
1645
1692
|
"default": "./dist/logger/default.js"
|
|
1646
1693
|
},
|
|
1694
|
+
"./logger/logger": {
|
|
1695
|
+
"source": "./src/logger/node.ts",
|
|
1696
|
+
"browser": {
|
|
1697
|
+
"types": "./dist/logger/browser.d.ts",
|
|
1698
|
+
"default": "./dist/logger/browser.js"
|
|
1699
|
+
},
|
|
1700
|
+
"types": "./dist/logger/node.d.ts",
|
|
1701
|
+
"default": "./dist/logger/node.js"
|
|
1702
|
+
},
|
|
1703
|
+
"./logger/node": {
|
|
1704
|
+
"source": "./src/logger/node.ts",
|
|
1705
|
+
"types": "./dist/logger/node.d.ts",
|
|
1706
|
+
"default": "./dist/logger/node.js"
|
|
1707
|
+
},
|
|
1647
1708
|
"./logger/symbols": {
|
|
1648
1709
|
"source": "./src/logger/symbols.ts",
|
|
1649
1710
|
"types": "./dist/logger/symbols.d.ts",
|
|
@@ -1939,6 +2000,11 @@
|
|
|
1939
2000
|
"types": "./dist/paths/socket.d.ts",
|
|
1940
2001
|
"default": "./dist/paths/socket.js"
|
|
1941
2002
|
},
|
|
2003
|
+
"./paths/walk": {
|
|
2004
|
+
"source": "./src/paths/walk.ts",
|
|
2005
|
+
"types": "./dist/paths/walk.d.ts",
|
|
2006
|
+
"default": "./dist/paths/walk.js"
|
|
2007
|
+
},
|
|
1942
2008
|
"./perf/enabled": {
|
|
1943
2009
|
"source": "./src/perf/enabled.ts",
|
|
1944
2010
|
"types": "./dist/perf/enabled.d.ts",
|
|
@@ -2199,6 +2265,11 @@
|
|
|
2199
2265
|
"types": "./dist/releases/github-listing.d.ts",
|
|
2200
2266
|
"default": "./dist/releases/github-listing.js"
|
|
2201
2267
|
},
|
|
2268
|
+
"./releases/github-retry-config": {
|
|
2269
|
+
"source": "./src/releases/github-retry-config.ts",
|
|
2270
|
+
"types": "./dist/releases/github-retry-config.d.ts",
|
|
2271
|
+
"default": "./dist/releases/github-retry-config.js"
|
|
2272
|
+
},
|
|
2202
2273
|
"./releases/github-types": {
|
|
2203
2274
|
"source": "./src/releases/github-types.ts",
|
|
2204
2275
|
"types": "./dist/releases/github-types.d.ts",
|
|
@@ -2299,6 +2370,11 @@
|
|
|
2299
2370
|
"types": "./dist/smol/manifest.d.ts",
|
|
2300
2371
|
"default": "./dist/smol/manifest.js"
|
|
2301
2372
|
},
|
|
2373
|
+
"./smol/path": {
|
|
2374
|
+
"source": "./src/smol/path.ts",
|
|
2375
|
+
"types": "./dist/smol/path.d.ts",
|
|
2376
|
+
"default": "./dist/smol/path.js"
|
|
2377
|
+
},
|
|
2302
2378
|
"./smol/primordial": {
|
|
2303
2379
|
"source": "./src/smol/primordial.ts",
|
|
2304
2380
|
"types": "./dist/smol/primordial.d.ts",
|
|
@@ -2698,27 +2774,6 @@
|
|
|
2698
2774
|
"access": "public",
|
|
2699
2775
|
"provenance": true
|
|
2700
2776
|
},
|
|
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
2777
|
"devDependencies": {
|
|
2723
2778
|
"@anthropic-ai/claude-code": "2.1.92",
|
|
2724
2779
|
"@babel/core": "7.28.4",
|
|
@@ -2736,13 +2791,13 @@
|
|
|
2736
2791
|
"@npmcli/promise-spawn": "8.0.3",
|
|
2737
2792
|
"@sinclair/typebox": "0.34.49",
|
|
2738
2793
|
"@socketregistry/is-unicode-supported": "1.0.5",
|
|
2739
|
-
"@socketregistry/packageurl-js": "
|
|
2740
|
-
"@socketregistry/packageurl-js-stable": "
|
|
2794
|
+
"@socketregistry/packageurl-js": "npm:@socketregistry/packageurl-js@1.4.2",
|
|
2795
|
+
"@socketregistry/packageurl-js-stable": "npm:@socketregistry/packageurl-js@1.4.2",
|
|
2741
2796
|
"@socketregistry/yocto-spinner": "1.0.25",
|
|
2742
|
-
"@socketsecurity/lib": "
|
|
2743
|
-
"@socketsecurity/lib-stable": "
|
|
2744
|
-
"@socketsecurity/sdk": "
|
|
2745
|
-
"@socketsecurity/sdk-stable": "
|
|
2797
|
+
"@socketsecurity/lib": "npm:@socketsecurity/lib@6.0.1",
|
|
2798
|
+
"@socketsecurity/lib-stable": "npm:@socketsecurity/lib@6.0.1",
|
|
2799
|
+
"@socketsecurity/sdk": "npm:@socketsecurity/sdk@4.0.1",
|
|
2800
|
+
"@socketsecurity/sdk-stable": "npm:@socketsecurity/sdk@4.0.1",
|
|
2746
2801
|
"@types/node": "24.9.2",
|
|
2747
2802
|
"@typescript/native-preview": "7.0.0-dev.20260511.1",
|
|
2748
2803
|
"@vitest/coverage-v8": "4.0.3",
|
|
@@ -2773,7 +2828,6 @@
|
|
|
2773
2828
|
"pacote": "21.5.0",
|
|
2774
2829
|
"picomatch": "4.0.4",
|
|
2775
2830
|
"pony-cause": "2.1.11",
|
|
2776
|
-
"prim": "workspace:*",
|
|
2777
2831
|
"semver": "7.7.2",
|
|
2778
2832
|
"signal-exit": "4.1.0",
|
|
2779
2833
|
"spdx-correct": "3.2.0",
|
|
@@ -2790,7 +2844,8 @@
|
|
|
2790
2844
|
"which": "5.0.0",
|
|
2791
2845
|
"yargs-parser": "22.0.0",
|
|
2792
2846
|
"yoctocolors-cjs": "2.1.3",
|
|
2793
|
-
"zod": "4.1.12"
|
|
2847
|
+
"zod": "4.1.12",
|
|
2848
|
+
"prim": "0.1.0"
|
|
2794
2849
|
},
|
|
2795
2850
|
"peerDependencies": {
|
|
2796
2851
|
"typescript": ">=5.0.0"
|
|
@@ -2804,5 +2859,23 @@
|
|
|
2804
2859
|
"node": ">=22",
|
|
2805
2860
|
"pnpm": ">=11.3.0"
|
|
2806
2861
|
},
|
|
2807
|
-
"
|
|
2808
|
-
|
|
2862
|
+
"scripts": {
|
|
2863
|
+
"build": "node scripts/build/cli.mts",
|
|
2864
|
+
"check": "node scripts/check.mts",
|
|
2865
|
+
"check:paths": "node scripts/check-paths.mts",
|
|
2866
|
+
"clean": "node scripts/build/clean.mts",
|
|
2867
|
+
"cover": "node scripts/test/cover.mts",
|
|
2868
|
+
"dev": "node scripts/build/cli.mts --watch",
|
|
2869
|
+
"fix": "node scripts/fix.mts",
|
|
2870
|
+
"format": "oxfmt -c .config/oxfmtrc.json --write .",
|
|
2871
|
+
"format:check": "oxfmt -c .config/oxfmtrc.json --check .",
|
|
2872
|
+
"lint": "node scripts/lint.mts",
|
|
2873
|
+
"prim": "node tools/prim/bin/prim.mts",
|
|
2874
|
+
"security": "node scripts/security.mts",
|
|
2875
|
+
"test": "node scripts/test/cli.mts",
|
|
2876
|
+
"update": "node scripts/update.mts",
|
|
2877
|
+
"lockstep": "node scripts/lockstep.mts",
|
|
2878
|
+
"lockstep:emit-schema": "node scripts/lockstep-emit-schema.mts",
|
|
2879
|
+
"setup-security-tools": "node .claude/hooks/setup-security-tools/install.mts"
|
|
2880
|
+
}
|
|
2881
|
+
}
|
|
@@ -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>;
|