@peac/cli 0.14.1 → 0.14.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/dist/commands/bridge/start.d.ts.map +1 -1
- package/dist/commands/bridge/status.d.ts.map +1 -1
- package/dist/commands/bridge/stop.d.ts.map +1 -1
- package/dist/commands/bundle.d.ts.map +1 -1
- package/dist/commands/policy.d.ts.map +1 -1
- package/dist/commands/reconcile.d.ts.map +1 -1
- package/dist/commands/verify.d.ts.map +1 -1
- package/dist/index.cjs +96 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +97 -23
- package/dist/index.mjs.map +1 -1
- package/dist/lib/bridge-url.d.ts +25 -0
- package/dist/lib/bridge-url.d.ts.map +1 -0
- package/dist/lib/safe-file.d.ts +88 -0
- package/dist/lib/safe-file.d.ts.map +1 -0
- package/package.json +8 -8
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validate-and-normalize a bridge base URL. The bridge URL flows in from
|
|
3
|
+
* either a config file (`~/.peac/bridge.json`) or `process.env.PEAC_BRIDGE_URL`.
|
|
4
|
+
* Both are local-trust sources, but a value that originated as a filesystem
|
|
5
|
+
* path could otherwise reach an HTTP fetch sink without an explicit
|
|
6
|
+
* protocol-shape check.
|
|
7
|
+
*
|
|
8
|
+
* `parseBridgeBaseUrl()` parses the input via the WHATWG `URL` constructor
|
|
9
|
+
* (which throws on malformed input) and restricts the protocol to `http:` or
|
|
10
|
+
* `https:`. Returning the parsed URL gives downstream callers a clean base
|
|
11
|
+
* for `joinBridgePath()` joins.
|
|
12
|
+
*/
|
|
13
|
+
export declare function parseBridgeBaseUrl(raw: unknown): URL;
|
|
14
|
+
/**
|
|
15
|
+
* Join an endpoint path onto a parsed bridge base URL while preserving any
|
|
16
|
+
* configured base pathname prefix. A bridge mounted behind a reverse proxy
|
|
17
|
+
* at `https://example.com/bridge` MUST resolve `/health` to
|
|
18
|
+
* `https://example.com/bridge/health`, not `https://example.com/health`.
|
|
19
|
+
*
|
|
20
|
+
* The endpoint path is treated as a relative segment list: leading slashes
|
|
21
|
+
* are stripped, doubled slashes inside the joined pathname are collapsed,
|
|
22
|
+
* and any query/fragment from the base is dropped (callers add their own).
|
|
23
|
+
*/
|
|
24
|
+
export declare function joinBridgePath(base: URL, endpointPath: string): URL;
|
|
25
|
+
//# sourceMappingURL=bridge-url.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge-url.d.ts","sourceRoot":"","sources":["../../src/lib/bridge-url.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,CASpD;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,GAAG,GAAG,CAUnE"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal file-IO helpers for @peac/cli command handlers.
|
|
3
|
+
*
|
|
4
|
+
* Package-private; not exported from any package barrel and not part of
|
|
5
|
+
* the public CLI API. Mirrors the syscall-style conventions already in
|
|
6
|
+
* use in `output-preflight.ts`: named imports from `node:fs`,
|
|
7
|
+
* fd-bound reads, errno discrimination via `NodeJS.ErrnoException`, and
|
|
8
|
+
* `closeSync` always wrapped in `try`/`finally` with secondary errors
|
|
9
|
+
* swallowed so they do not mask the primary error.
|
|
10
|
+
*
|
|
11
|
+
* The helpers exist to remove TOCTOU patterns where an existence probe
|
|
12
|
+
* (`existsSync` / `accessSync` / `statSync`) is followed by a file
|
|
13
|
+
* operation (`readFileSync` / `writeFileSync` / `openSync` / `unlinkSync`)
|
|
14
|
+
* on the same path. The atomic alternative is a single syscall that
|
|
15
|
+
* discriminates outcome via errno: success means the operation worked;
|
|
16
|
+
* `ENOENT` means the file is missing; `EACCES` means the file is
|
|
17
|
+
* unreadable / unwritable; `EISDIR` / `ENOTDIR` means the path is the
|
|
18
|
+
* wrong type.
|
|
19
|
+
*
|
|
20
|
+
* Each helper takes a path string. Internal use of file descriptors is
|
|
21
|
+
* hidden from the caller. Callers receive plain return values on success
|
|
22
|
+
* and `NodeJS.ErrnoException`-shaped errors on failure that they can
|
|
23
|
+
* inspect via `e.code === 'ENOENT' | 'EACCES' | 'EEXIST' | 'EISDIR' |
|
|
24
|
+
* 'ENOTDIR'` and translate into user-facing wording.
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* Read the entire file at `path` as a UTF-8 string via a single
|
|
28
|
+
* fd-bound `open`/`fstat`/`read`/`close` sequence.
|
|
29
|
+
*
|
|
30
|
+
* Throws an `ErrnoException`-shaped error on failure. Callers
|
|
31
|
+
* discriminate via `e.code`:
|
|
32
|
+
* - `ENOENT`: file does not exist
|
|
33
|
+
* - `EISDIR`: path resolves to a directory
|
|
34
|
+
* - `EACCES`: not readable
|
|
35
|
+
*/
|
|
36
|
+
export declare function readFileUtf8Snapshot(path: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* Read the entire file at `path` as a `Buffer` via a single fd-bound
|
|
39
|
+
* `open`/`fstat`/`read`/`close` sequence. Optionally enforces a maximum
|
|
40
|
+
* byte size. The size limit is checked twice: once against the `fstat`
|
|
41
|
+
* size before reading (cheap fast-fail) and once against the actual
|
|
42
|
+
* read length (defends against the file growing between `fstat` and the
|
|
43
|
+
* subsequent `readFileSync`).
|
|
44
|
+
*
|
|
45
|
+
* Throws on failure:
|
|
46
|
+
* - `ENOENT`: file does not exist
|
|
47
|
+
* - `EISDIR`: path resolves to a directory
|
|
48
|
+
* - `EACCES`: not readable
|
|
49
|
+
* - `E_PEAC_FILE_TOO_LARGE`: file exceeds `options.maxBytes`
|
|
50
|
+
*/
|
|
51
|
+
export declare function readFileBufferSnapshot(path: string, options?: {
|
|
52
|
+
maxBytes?: number;
|
|
53
|
+
}): Buffer;
|
|
54
|
+
/**
|
|
55
|
+
* Write `data` to `path` atomically without overwriting an existing
|
|
56
|
+
* file. Uses POSIX `O_CREAT | O_EXCL | O_WRONLY` semantics via Node's
|
|
57
|
+
* `'wx'` flag. The path either gets created with the supplied content
|
|
58
|
+
* or the call throws `EEXIST`.
|
|
59
|
+
*
|
|
60
|
+
* Callers translate `EEXIST` into user-facing wording (e.g. "use --force
|
|
61
|
+
* to overwrite").
|
|
62
|
+
*/
|
|
63
|
+
export declare function writeFileNoOverwrite(path: string, data: string | Buffer, options?: {
|
|
64
|
+
encoding?: BufferEncoding;
|
|
65
|
+
mode?: number;
|
|
66
|
+
}): void;
|
|
67
|
+
/**
|
|
68
|
+
* Rewrite a JSON config file atomically. If the file does not exist
|
|
69
|
+
* (ENOENT), returns silently: there is no config to rewrite. Otherwise
|
|
70
|
+
* the existing content is parsed, `mutate(config)` is invoked, and the
|
|
71
|
+
* mutated config is written via a sibling temp file plus
|
|
72
|
+
* `renameSync`. The final target path is never partially written.
|
|
73
|
+
*
|
|
74
|
+
* Existing file permissions on the target are preserved across the
|
|
75
|
+
* rename. If the existing mode cannot be observed, the temp file is
|
|
76
|
+
* created with a restrictive `0o600` fallback so a config rewrite never
|
|
77
|
+
* accidentally widens the permission set.
|
|
78
|
+
*
|
|
79
|
+
* Cleans up the temp file if rename fails. Read failures other than
|
|
80
|
+
* `ENOENT` propagate to the caller.
|
|
81
|
+
*/
|
|
82
|
+
export declare function rewriteJsonFileAtomic(path: string, mutate: (config: Record<string, unknown>) => void): void;
|
|
83
|
+
/**
|
|
84
|
+
* Remove the file at `path` if it exists. Swallows `ENOENT`. All
|
|
85
|
+
* other errors propagate to the caller.
|
|
86
|
+
*/
|
|
87
|
+
export declare function unlinkIfExists(path: string): void;
|
|
88
|
+
//# sourceMappingURL=safe-file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safe-file.d.ts","sourceRoot":"","sources":["../../src/lib/safe-file.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAeH;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAkBzD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAyB5F;AAgBD;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GAAG,MAAM,EACrB,OAAO,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,cAAc,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GACrD,IAAI,CAQN;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,GAChD,IAAI,CAiDN;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAMjD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peac/cli",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.2",
|
|
4
4
|
"description": "PEAC protocol command-line tools",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -38,13 +38,13 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"chalk": "^4.1.2",
|
|
40
40
|
"commander": "^11.0.0",
|
|
41
|
-
"@peac/audit": "0.14.
|
|
42
|
-
"@peac/
|
|
43
|
-
"@peac/
|
|
44
|
-
"@peac/
|
|
45
|
-
"@peac/
|
|
46
|
-
"@peac/
|
|
47
|
-
"@peac/schema": "0.14.
|
|
41
|
+
"@peac/audit": "0.14.2",
|
|
42
|
+
"@peac/crypto": "0.14.2",
|
|
43
|
+
"@peac/policy-kit": "0.14.2",
|
|
44
|
+
"@peac/protocol": "0.14.2",
|
|
45
|
+
"@peac/kernel": "0.14.2",
|
|
46
|
+
"@peac/net-node": "0.14.2",
|
|
47
|
+
"@peac/schema": "0.14.2"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@types/node": "^22.19.11",
|