@peac/cli 0.14.0 → 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.
Files changed (38) hide show
  1. package/dist/commands/bridge/start.d.ts.map +1 -1
  2. package/dist/commands/bridge/status.d.ts.map +1 -1
  3. package/dist/commands/bridge/stop.d.ts.map +1 -1
  4. package/dist/commands/bundle.d.ts.map +1 -1
  5. package/dist/commands/emit-lifecycle.d.ts +140 -0
  6. package/dist/commands/emit-lifecycle.d.ts.map +1 -0
  7. package/dist/commands/observe-command.d.ts +135 -0
  8. package/dist/commands/observe-command.d.ts.map +1 -0
  9. package/dist/commands/policy.d.ts.map +1 -1
  10. package/dist/commands/reconcile.d.ts.map +1 -1
  11. package/dist/commands/record-command.d.ts +102 -0
  12. package/dist/commands/record-command.d.ts.map +1 -0
  13. package/dist/commands/verify.d.ts.map +1 -1
  14. package/dist/index.cjs +2018 -24
  15. package/dist/index.cjs.map +1 -1
  16. package/dist/index.mjs +2025 -31
  17. package/dist/index.mjs.map +1 -1
  18. package/dist/lib/bridge-url.d.ts +25 -0
  19. package/dist/lib/bridge-url.d.ts.map +1 -0
  20. package/dist/lib/capture.d.ts +118 -0
  21. package/dist/lib/capture.d.ts.map +1 -0
  22. package/dist/lib/cli-limits.d.ts +49 -0
  23. package/dist/lib/cli-limits.d.ts.map +1 -0
  24. package/dist/lib/command-option-validation.d.ts +94 -0
  25. package/dist/lib/command-option-validation.d.ts.map +1 -0
  26. package/dist/lib/issuer-key-loader.d.ts +56 -0
  27. package/dist/lib/issuer-key-loader.d.ts.map +1 -0
  28. package/dist/lib/observation-builder.d.ts +79 -0
  29. package/dist/lib/observation-builder.d.ts.map +1 -0
  30. package/dist/lib/observation-pipeline.d.ts +96 -0
  31. package/dist/lib/observation-pipeline.d.ts.map +1 -0
  32. package/dist/lib/output-preflight.d.ts +28 -0
  33. package/dist/lib/output-preflight.d.ts.map +1 -0
  34. package/dist/lib/safe-file.d.ts +88 -0
  35. package/dist/lib/safe-file.d.ts.map +1 -0
  36. package/dist/lib/secret-scan.d.ts +35 -0
  37. package/dist/lib/secret-scan.d.ts.map +1 -0
  38. package/package.json +8 -8
@@ -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"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Secret-scan regex set for bounded-capture samples.
3
+ *
4
+ * Secret-scan is ON by default. When raw sample emission is possible
5
+ * (`--capture-mode raw && --unsafe-allow-raw-capture`), the wrapper
6
+ * runs this regex set against each candidate sample BEFORE emission.
7
+ * If a token-like pattern matches, the sample is suppressed and
8
+ * replaced with `{ sample_suppressed_reason: "secret_pattern_detected",
9
+ * matched_pattern_category: <category> }`. The literal match is NEVER
10
+ * recorded.
11
+ *
12
+ * The regex set is intentionally small (5 named patterns). False
13
+ * positives are tolerated; the suppression itself is observable so a
14
+ * verifier can detect over-suppression.
15
+ *
16
+ * Disabling secret-scan under raw capture requires the third unsafe
17
+ * flag (`--unsafe-disable-secret-scan`); enforcement lives in the
18
+ * subcommand flag-parse layer, not here.
19
+ */
20
+ export type SecretCategory = 'bearer-token' | 'api-key' | 'jwt' | 'aws-access-key' | 'generic-high-entropy';
21
+ export interface SecretMatch {
22
+ category: SecretCategory;
23
+ }
24
+ /**
25
+ * Scan a buffer or string for token-like patterns. Returns the first
26
+ * match (by pattern declaration order); the literal match is NEVER
27
+ * returned to callers.
28
+ */
29
+ export declare function scanForSecrets(input: string | Uint8Array): SecretMatch | null;
30
+ /**
31
+ * Scan an argv element. Same shape as `scanForSecrets` but documents
32
+ * intent: argv elements are scanned independently of stream samples.
33
+ */
34
+ export declare function scanArgvElement(token: string): SecretMatch | null;
35
+ //# sourceMappingURL=secret-scan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secret-scan.d.ts","sourceRoot":"","sources":["../../src/lib/secret-scan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,MAAM,MAAM,cAAc,GACtB,cAAc,GACd,SAAS,GACT,KAAK,GACL,gBAAgB,GAChB,sBAAsB,CAAC;AA0C3B,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,cAAc,CAAC;CAC1B;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,IAAI,CAQ7E;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAEjE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peac/cli",
3
- "version": "0.14.0",
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/crypto": "0.14.0",
42
- "@peac/kernel": "0.14.0",
43
- "@peac/net-node": "0.14.0",
44
- "@peac/audit": "0.14.0",
45
- "@peac/protocol": "0.14.0",
46
- "@peac/policy-kit": "0.14.0",
47
- "@peac/schema": "0.14.0"
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",