@peac/protocol 0.13.2 → 0.13.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.
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Internal rollback-path flag.
3
+ *
4
+ * INTERNAL ONLY. Both flag values currently use the same protocol path.
5
+ * The flag reader is exercised so rollback-path plumbing can be validated
6
+ * without changing public behavior.
7
+ *
8
+ * Public option types MUST NOT declare `_internal.legacyPath`; callers
9
+ * inside this package access the programmatic option only through
10
+ * internal casts. Flag identifiers are forbidden on the public TypeScript
11
+ * surface by `scripts/verify-dist-private-leaks.mjs` (Tier 1 + scoped
12
+ * runtime allowlist for `@peac/protocol` runtime files only) and by
13
+ * `scripts/verify-no-semantic-widening.mjs`.
14
+ */
15
+ /**
16
+ * Programmatic-flag shape. Internal-only; never appears on any
17
+ * exported public option type. Mirrors the existing shadow-flag
18
+ * pattern at `_internal/shadow.ts` so the dist-leak gates and the
19
+ * semantic-widening gates apply uniformly.
20
+ *
21
+ * @internal
22
+ */
23
+ export interface LegacyPathOptions {
24
+ readonly _internal?: {
25
+ readonly legacyPath?: boolean;
26
+ };
27
+ }
28
+ /**
29
+ * Read the rollback-path flag from environment or programmatic
30
+ * options. Read once per call, NOT cached at module scope, so tests
31
+ * can toggle the env var dynamically. Strict semantics: only the
32
+ * literal string `'1'` activates the flag, mirroring
33
+ * `PEAC_INTERNAL_SHADOW_CORE`.
34
+ *
35
+ * Environment access is guarded for browser / edge runtimes that do
36
+ * not expose `process`; the function never throws.
37
+ *
38
+ * Caller pattern at protocol hot paths:
39
+ *
40
+ * void readLegacyPathFlag(options as unknown as LegacyPathOptions);
41
+ *
42
+ * The `void` discards the returned boolean intentionally: both flag
43
+ * values currently use the same protocol path, and the call exists
44
+ * so the read path is exercised.
45
+ *
46
+ * @internal
47
+ */
48
+ export declare function readLegacyPathFlag(options?: LegacyPathOptions): boolean;
49
+ //# sourceMappingURL=legacy-path.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legacy-path.d.ts","sourceRoot":"","sources":["../../src/_internal/legacy-path.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH;;;;;;;GAOG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,SAAS,CAAC,EAAE;QACnB,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;KAC/B,CAAC;CACH;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAKvE"}
@@ -28,4 +28,39 @@ export declare function verdictKey(v: ParityVerdict): string;
28
28
  * encode digests). Example caller: corpus-canonical-truth sanity test.
29
29
  */
30
30
  export declare function verdictKeyShape(v: ParityVerdict): string;
31
+ /**
32
+ * Stringify a ParityVerdict using error-class-equivalent semantics.
33
+ *
34
+ * Encodes ONLY:
35
+ * - `accepted` boolean
36
+ * - sorted error-code MULTISET preserving counts
37
+ *
38
+ * Ignores:
39
+ * - error path
40
+ * - warnings (codes and paths)
41
+ * - canonicalClaimsDigest
42
+ * - any other field
43
+ *
44
+ * Does NOT dedupe duplicate codes. Two errors emitted with the same
45
+ * `code` are encoded as two entries; this preserves multiset semantics
46
+ * because duplicate counts may carry meaningful diagnostic signal that
47
+ * dedup would erase.
48
+ *
49
+ * Use for diagnostic overlap comparisons where the goal is to assert
50
+ * agreement on what error CLASS was raised, independent of where it
51
+ * was emitted, what message it carried, or what warnings accompanied
52
+ * it. Path comparison is intentionally too strict for this gate;
53
+ * callers needing path-aware comparison should use `verdictKey` or
54
+ * `verdictKeyShape`.
55
+ *
56
+ * NOTE on input construction: `makeVerdict()` deduplicates errors by
57
+ * `(code, path)` before normalization. To preserve a true multiset of
58
+ * same-code entries through `verdictKeyErrorClass`, callers MUST
59
+ * construct the `ParityVerdict` literally (without `makeVerdict`) or
60
+ * supply errors with distinct `path` values that survive dedup. The
61
+ * function operates on the verdict's `.errors` array as given; it is
62
+ * the caller's responsibility to ensure that array carries the
63
+ * intended multiset shape.
64
+ */
65
+ export declare function verdictKeyErrorClass(v: ParityVerdict): string;
31
66
  //# sourceMappingURL=parity-verdict.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"parity-verdict.d.ts","sourceRoot":"","sources":["../../../src/_internal/test-helpers/parity-verdict.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAEpG,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,CAAC;AAwB1D;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,QAAQ,EAAE,OAAO,EACjB,MAAM,GAAE,WAAW,EAAO,EAC1B,QAAQ,GAAE,aAAa,EAAO,EAC9B,qBAAqB,CAAC,EAAE,MAAM,GAC7B,aAAa,CAUf;AAgBD;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,aAAa,GAAG,MAAM,CAMnD;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,aAAa,GAAG,MAAM,CAExD"}
1
+ {"version":3,"file":"parity-verdict.d.ts","sourceRoot":"","sources":["../../../src/_internal/test-helpers/parity-verdict.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAEpG,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,CAAC;AAwB1D;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,QAAQ,EAAE,OAAO,EACjB,MAAM,GAAE,WAAW,EAAO,EAC1B,QAAQ,GAAE,aAAa,EAAO,EAC9B,qBAAqB,CAAC,EAAE,MAAM,GAC7B,aAAa,CAUf;AAgBD;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,aAAa,GAAG,MAAM,CAMnD;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,aAAa,GAAG,MAAM,CAExD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,aAAa,GAAG,MAAM,CAO7D"}
package/dist/index.cjs CHANGED
@@ -595,6 +595,14 @@ function pruneStale() {
595
595
  while (SHADOW_LOG.length > 0 && SHADOW_LOG[0].timestamp < cutoffIso) SHADOW_LOG.shift();
596
596
  }
597
597
 
598
+ // src/_internal/legacy-path.ts
599
+ function readLegacyPathFlag(options) {
600
+ if (options?._internal?.legacyPath === true) return true;
601
+ if (typeof process === "undefined" || process === null) return false;
602
+ const env = process.env;
603
+ return env?.PEAC_INTERNAL_LEGACY_PATH === "1";
604
+ }
605
+
598
606
  // src/_internal/shadow-observe.ts
599
607
  function realObservationForIssue() {
600
608
  return EMPTY_ACCEPTED;
@@ -805,6 +813,7 @@ async function issue(options) {
805
813
  return issueWire02(options);
806
814
  }
807
815
  async function issueWire02(options) {
816
+ void readLegacyPathFlag(options);
808
817
  if (!schema.isCanonicalIss(options.iss)) {
809
818
  throw new IssueError({
810
819
  code: "E_ISS_NOT_CANONICAL",
@@ -1919,6 +1928,8 @@ function jwkToPublicKey(jwk) {
1919
1928
  return new Uint8Array(xBytes);
1920
1929
  }
1921
1930
  async function verifyReceipt(optionsOrJws) {
1931
+ const legacyPathOptions = typeof optionsOrJws === "string" ? void 0 : optionsOrJws;
1932
+ void readLegacyPathFlag(legacyPathOptions);
1922
1933
  const receiptJws = typeof optionsOrJws === "string" ? optionsOrJws : optionsOrJws.receiptJws;
1923
1934
  const inputSnapshot = typeof optionsOrJws === "string" ? void 0 : optionsOrJws.subject_snapshot;
1924
1935
  const telemetry = typeof optionsOrJws === "string" ? void 0 : optionsOrJws.telemetry;
@@ -2110,6 +2121,7 @@ function sanitizeParseIssues(issues) {
2110
2121
  }));
2111
2122
  }
2112
2123
  async function verifyLocal(jws, publicKey, options = {}) {
2124
+ void readLegacyPathFlag(options);
2113
2125
  const {
2114
2126
  issuer,
2115
2127
  subjectUri,