@peac/protocol 0.13.0 → 0.13.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/_internal/record-core/bounded-validator.d.ts +83 -0
- package/dist/_internal/record-core/bounded-validator.d.ts.map +1 -0
- package/dist/_internal/record-core/codec/index.d.ts +27 -0
- package/dist/_internal/record-core/codec/index.d.ts.map +1 -0
- package/dist/_internal/record-core/codec/jws-jwt.d.ts +25 -0
- package/dist/_internal/record-core/codec/jws-jwt.d.ts.map +1 -0
- package/dist/_internal/record-core/codec/types.d.ts +80 -0
- package/dist/_internal/record-core/codec/types.d.ts.map +1 -0
- package/dist/_internal/record-core/index.d.ts +14 -0
- package/dist/_internal/record-core/index.d.ts.map +1 -0
- package/dist/_internal/record-core/normalize.d.ts +24 -0
- package/dist/_internal/record-core/normalize.d.ts.map +1 -0
- package/dist/_internal/record-core/shadow-hook.d.ts +46 -0
- package/dist/_internal/record-core/shadow-hook.d.ts.map +1 -0
- package/dist/_internal/record-core/types.d.ts +15 -0
- package/dist/_internal/record-core/types.d.ts.map +1 -0
- package/dist/_internal/record-core/validators/extension-budget.d.ts +47 -0
- package/dist/_internal/record-core/validators/extension-budget.d.ts.map +1 -0
- package/dist/_internal/record-core/validators/index.d.ts +13 -0
- package/dist/_internal/record-core/validators/index.d.ts.map +1 -0
- package/dist/_internal/record-core/validators/issuer-form.d.ts +58 -0
- package/dist/_internal/record-core/validators/issuer-form.d.ts.map +1 -0
- package/dist/_internal/record-core/validators/jose-hardening.d.ts +58 -0
- package/dist/_internal/record-core/validators/jose-hardening.d.ts.map +1 -0
- package/dist/_internal/record-core/validators/kernel-constraints.d.ts +48 -0
- package/dist/_internal/record-core/validators/kernel-constraints.d.ts.map +1 -0
- package/dist/_internal/record-core/validators/temporal.d.ts +50 -0
- package/dist/_internal/record-core/validators/temporal.d.ts.map +1 -0
- package/dist/_internal/record-core/validators/type-extension-mapping.d.ts +51 -0
- package/dist/_internal/record-core/validators/type-extension-mapping.d.ts.map +1 -0
- package/dist/_internal/record-core/validators/types.d.ts +42 -0
- package/dist/_internal/record-core/validators/types.d.ts.map +1 -0
- package/dist/_internal/shadow-observe.d.ts +93 -0
- package/dist/_internal/shadow-observe.d.ts.map +1 -0
- package/dist/_internal/shadow-redact.d.ts +74 -0
- package/dist/_internal/shadow-redact.d.ts.map +1 -0
- package/dist/_internal/shadow-types.d.ts +62 -0
- package/dist/_internal/shadow-types.d.ts.map +1 -0
- package/dist/_internal/shadow.d.ts +134 -0
- package/dist/_internal/shadow.d.ts.map +1 -0
- package/dist/_internal/test-helpers/canonical-runner.d.ts +43 -0
- package/dist/_internal/test-helpers/canonical-runner.d.ts.map +1 -0
- package/dist/_internal/test-helpers/corpus-loader.d.ts +61 -0
- package/dist/_internal/test-helpers/corpus-loader.d.ts.map +1 -0
- package/dist/_internal/test-helpers/fixture-manifest.d.ts +46 -0
- package/dist/_internal/test-helpers/fixture-manifest.d.ts.map +1 -0
- package/dist/_internal/test-helpers/parity-verdict.d.ts +31 -0
- package/dist/_internal/test-helpers/parity-verdict.d.ts.map +1 -0
- package/dist/index.cjs +684 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +685 -12
- package/dist/index.mjs.map +1 -1
- package/dist/issue.d.ts +12 -12
- package/dist/issue.d.ts.map +1 -1
- package/dist/policy-binding.d.ts +1 -1
- package/dist/verify-local.cjs +645 -3
- package/dist/verify-local.cjs.map +1 -1
- package/dist/verify-local.d.ts.map +1 -1
- package/dist/verify-local.mjs +647 -5
- package/dist/verify-local.mjs.map +1 -1
- package/package.json +6 -4
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bounded internal temporal validator (occurred_at skew only).
|
|
3
|
+
*
|
|
4
|
+
* INTERNAL ONLY. This is the parity-observed counterpart of
|
|
5
|
+
* @peac/schema.checkOccurredAtSkew (referenced by verify-local.ts when
|
|
6
|
+
* claims.kind === 'evidence'). Both implementations consume the same
|
|
7
|
+
* OCCURRED_AT_TOLERANCE_SECONDS constant from @peac/kernel and apply
|
|
8
|
+
* the same skew classification rules in the same order; behavioral
|
|
9
|
+
* parity is proven byte-equal by the parity tests, not by code copy.
|
|
10
|
+
*
|
|
11
|
+
* Existing canonical checkOccurredAtSkew in @peac/schema remains
|
|
12
|
+
* canonical. This module is observational only; it is NOT re-exported
|
|
13
|
+
* from packages/protocol/src/index.ts and is NOT wired into runtime
|
|
14
|
+
* paths (issue.ts, verify-local.ts) in v0.13.1.
|
|
15
|
+
*
|
|
16
|
+
* SCOPE (deliberately narrow):
|
|
17
|
+
* - occurred_at canonical skew classification ONLY
|
|
18
|
+
* - the iat-not-yet-valid check (`iat > now + maxClockSkew`) lives
|
|
19
|
+
* inline at verify-local.ts:454 with no helper to import; wrapping
|
|
20
|
+
* it would make LEFT and RIGHT identical 1-line predicates that
|
|
21
|
+
* prove nothing, so it is explicitly deferred to a later step
|
|
22
|
+
* (extraction first, parity second)
|
|
23
|
+
*
|
|
24
|
+
* Rules (must mirror checkOccurredAtSkew exactly; evidence-kind-only
|
|
25
|
+
* is the caller's responsibility):
|
|
26
|
+
* 1. occurredAt undefined -> accepted, no warning
|
|
27
|
+
* 2. parse occurredAt as ISO/RFC 3339; if NaN -> accepted, no warning
|
|
28
|
+
* (the parse failure surfaces from schema validation elsewhere)
|
|
29
|
+
* 3. ts > now + tolerance -> rejected with E_OCCURRED_AT_FUTURE
|
|
30
|
+
* 4. ts > iat (within tolerance) -> accepted with occurred_at_skew
|
|
31
|
+
* warning at pointer /occurred_at
|
|
32
|
+
* 5. ts <= iat -> accepted, no warning
|
|
33
|
+
*
|
|
34
|
+
* The injected `now` parameter is required; this module never reads
|
|
35
|
+
* Date.now() so tests are deterministic.
|
|
36
|
+
*/
|
|
37
|
+
export interface TemporalWarning {
|
|
38
|
+
readonly code: string;
|
|
39
|
+
readonly pointer?: string;
|
|
40
|
+
}
|
|
41
|
+
export type TemporalResult = {
|
|
42
|
+
readonly accepted: true;
|
|
43
|
+
readonly warnings?: readonly TemporalWarning[];
|
|
44
|
+
} | {
|
|
45
|
+
readonly accepted: false;
|
|
46
|
+
readonly errorCode: string;
|
|
47
|
+
readonly pointer?: string;
|
|
48
|
+
};
|
|
49
|
+
export declare function validateTemporalInternal(occurredAt: string | undefined, iat: number, now: number, tolerance?: number): TemporalResult;
|
|
50
|
+
//# sourceMappingURL=temporal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"temporal.d.ts","sourceRoot":"","sources":["../../../../src/_internal/record-core/validators/temporal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAIH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,MAAM,cAAc,GACtB;IAAE,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,eAAe,EAAE,CAAA;CAAE,GAC3E;IAAE,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAIxF,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,SAAS,GAAE,MAAsC,GAChD,cAAc,CAsBhB"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bounded internal type-extension mapping validator.
|
|
3
|
+
*
|
|
4
|
+
* INTERNAL ONLY. This is the parity-observed counterpart of the
|
|
5
|
+
* type/extension warning-emission block at verify-local.ts:477-540
|
|
6
|
+
* (interop strictness branch). Both implementations consume the same
|
|
7
|
+
* registries (REGISTERED_RECEIPT_TYPES, REGISTERED_EXTENSION_GROUP_KEYS,
|
|
8
|
+
* TYPE_TO_EXTENSION_MAP) and the same warning-code constants from
|
|
9
|
+
* @peac/schema; behavioral parity is proven byte-equal by the parity
|
|
10
|
+
* tests, not by code copy.
|
|
11
|
+
*
|
|
12
|
+
* Existing canonical emission in @peac/protocol/verifyLocal remains
|
|
13
|
+
* canonical. This module is observational only; it is NOT re-exported
|
|
14
|
+
* from packages/protocol/src/index.ts and is NOT wired into runtime
|
|
15
|
+
* paths (issue.ts, verify-local.ts) in v0.13.1.
|
|
16
|
+
*
|
|
17
|
+
* Output shape: a deterministically-ordered list of warning records,
|
|
18
|
+
* each carrying only `code` and `pointer`. The canonical emission also
|
|
19
|
+
* carries a `message` field; messages are intentionally omitted from
|
|
20
|
+
* the parity comparison because the missing/mismatch messages embed
|
|
21
|
+
* claim values (claims.type and the expected extension group), and
|
|
22
|
+
* comparison on (code, pointer) is what the verifier output API
|
|
23
|
+
* actually exposes to consumers via the warning code/pointer pair.
|
|
24
|
+
*
|
|
25
|
+
* Emission order (must mirror verify-local.ts exactly; tests assert):
|
|
26
|
+
* 1. type_unregistered (when claims.type is not in REGISTERED_RECEIPT_TYPES)
|
|
27
|
+
* 2. unknown_extension_preserved (one per unknown-but-well-formed
|
|
28
|
+
* extension key, in Object.keys iteration order)
|
|
29
|
+
* 3. extension_group_missing OR extension_group_mismatch (when
|
|
30
|
+
* checkTypeExtensionMapping returns missing/mismatch; not emitted
|
|
31
|
+
* for kind === 'challenge' or for unmapped/custom types)
|
|
32
|
+
*/
|
|
33
|
+
/** Minimal claims shape required by the type-extension warning surface. */
|
|
34
|
+
export interface TypeExtensionMappingInput {
|
|
35
|
+
readonly kind: string;
|
|
36
|
+
readonly type: string;
|
|
37
|
+
readonly extensions?: Record<string, unknown>;
|
|
38
|
+
}
|
|
39
|
+
/** Normalized warning entry. Comparison shape; canonical messages omitted. */
|
|
40
|
+
export interface TypeExtensionMappingWarning {
|
|
41
|
+
readonly code: string;
|
|
42
|
+
readonly pointer: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Evaluate the type-extension mapping warning surface for parsed Wire 0.2
|
|
46
|
+
* claims. Returns warnings in canonical emission order; emits no warnings
|
|
47
|
+
* when the claims are fully registered and the expected extension group
|
|
48
|
+
* is present (or when no expected group exists for the given type).
|
|
49
|
+
*/
|
|
50
|
+
export declare function validateTypeExtensionMappingInternal(input: TypeExtensionMappingInput): TypeExtensionMappingWarning[];
|
|
51
|
+
//# sourceMappingURL=type-extension-mapping.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-extension-mapping.d.ts","sourceRoot":"","sources":["../../../../src/_internal/record-core/validators/type-extension-mapping.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAaH,2EAA2E;AAC3E,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/C;AAED,8EAA8E;AAC9E,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAiCD;;;;;GAKG;AACH,wBAAgB,oCAAoC,CAClD,KAAK,EAAE,yBAAyB,GAC/B,2BAA2B,EAAE,CA6B/B"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal validator types for the bounded shadow-mode validator foundation.
|
|
3
|
+
*
|
|
4
|
+
* INTERNAL ONLY. These names MUST NOT appear in any emitted .d.ts file from
|
|
5
|
+
* the published @peac/protocol package. Enforced by Tier 2 + Tier 2b
|
|
6
|
+
* dist-leak gates in scripts/verify-dist-private-leaks.mjs.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Stable, normalized verdict shape for parity comparison between two
|
|
10
|
+
* validators. The differential harness compares JCS-canonicalized JSON
|
|
11
|
+
* forms of two verdicts; raw exception messages, raw Zod issues, raw
|
|
12
|
+
* stack traces, and object key order are NEVER compared.
|
|
13
|
+
*/
|
|
14
|
+
export interface ParityVerdict {
|
|
15
|
+
/** Did the validator accept the input? */
|
|
16
|
+
readonly accepted: boolean;
|
|
17
|
+
/** Normalized error codes; sorted by code then path; deduplicated. */
|
|
18
|
+
readonly errors: readonly ParityError[];
|
|
19
|
+
/** Normalized warning codes; sorted by code then path; deduplicated. */
|
|
20
|
+
readonly warnings: readonly ParityWarning[];
|
|
21
|
+
/**
|
|
22
|
+
* SHA-256 hex of the JCS-canonicalized accepted claims object. Present
|
|
23
|
+
* only when accepted is true. Asserts canonical-claims agreement, not
|
|
24
|
+
* just accept/reject agreement.
|
|
25
|
+
*/
|
|
26
|
+
readonly canonicalClaimsDigest?: string;
|
|
27
|
+
}
|
|
28
|
+
/** Normalized error entry. `code` is a canonical identifier. */
|
|
29
|
+
export interface ParityError {
|
|
30
|
+
/** Canonical error code (e.g., from @peac/kernel/errors). */
|
|
31
|
+
readonly code: string;
|
|
32
|
+
/** Stable JSON-pointer-like path. Omitted when not applicable. */
|
|
33
|
+
readonly path?: string;
|
|
34
|
+
}
|
|
35
|
+
/** Normalized warning entry. `code` is a canonical identifier. */
|
|
36
|
+
export interface ParityWarning {
|
|
37
|
+
/** Canonical warning code (e.g., from @peac/schema/wire-02-warnings). */
|
|
38
|
+
readonly code: string;
|
|
39
|
+
/** Stable JSON-pointer-like path. Omitted when not applicable. */
|
|
40
|
+
readonly path?: string;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/_internal/record-core/validators/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B,0CAA0C;IAC1C,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,sEAAsE;IACtE,QAAQ,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,CAAC;IACxC,wEAAwE;IACxE,QAAQ,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,CAAC;IAC5C;;;;OAIG;IACH,QAAQ,CAAC,qBAAqB,CAAC,EAAE,MAAM,CAAC;CACzC;AAED,gEAAgE;AAChE,MAAM,WAAW,WAAW;IAC1B,6DAA6D;IAC7D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,kEAAkE;IAClE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,kEAAkE;AAClE,MAAM,WAAW,aAAa;IAC5B,yEAAyE;IACzE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,kEAAkE;IAClE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalized internal observation shape for shadow-vs-real comparison.
|
|
3
|
+
*
|
|
4
|
+
* @internal
|
|
5
|
+
*
|
|
6
|
+
* INTERNAL ONLY. Not re-exported from packages/protocol/src/index.ts.
|
|
7
|
+
*
|
|
8
|
+
* The shadow scheduler compares real-path and shadow-path results via
|
|
9
|
+
* canonical hashes. To make that comparison meaningful (not just an
|
|
10
|
+
* accept/reject boolean) and free of false positives, both sides
|
|
11
|
+
* project onto the SAME stable normalized `ShadowObservation` shape
|
|
12
|
+
* before the hash:
|
|
13
|
+
*
|
|
14
|
+
* - `accepted`: did the validator accept the input?
|
|
15
|
+
* - `violationCodes`: sorted, deduplicated registered error codes.
|
|
16
|
+
* - `warningCodes`: sorted, deduplicated registered warning codes.
|
|
17
|
+
*
|
|
18
|
+
* Layer-tag metadata is intentionally NOT part of the comparable
|
|
19
|
+
* shape. The bounded validator emits per-layer tags; the canonical
|
|
20
|
+
* Zod path does not. Including them would cause a hash divergence
|
|
21
|
+
* even on full functional agreement, masking true divergence as
|
|
22
|
+
* noise.
|
|
23
|
+
*
|
|
24
|
+
* Issue path projection:
|
|
25
|
+
*
|
|
26
|
+
* `IssueResult` does not expose warning codes; canonical issuance
|
|
27
|
+
* either succeeds (and surfaces no warnings to the caller) or
|
|
28
|
+
* throws. To prevent the bounded validator's warnings from
|
|
29
|
+
* producing false `output-byte-diff` records on a successful
|
|
30
|
+
* issuance, the issue-side comparison runs in ACCEPTED-ONLY mode:
|
|
31
|
+
* `warningCodes` is projected to `[]` on BOTH sides.
|
|
32
|
+
*
|
|
33
|
+
* VerifyLocal success path projection:
|
|
34
|
+
*
|
|
35
|
+
* `VerifyLocalSuccess` exposes a `warnings` array of registered
|
|
36
|
+
* warning codes. The verifyLocal-side comparison includes
|
|
37
|
+
* `warningCodes` from both sides (canonical surfaces them
|
|
38
|
+
* directly; the bounded validator's warningCodes are mapped from
|
|
39
|
+
* `BoundedWarning.code`).
|
|
40
|
+
*/
|
|
41
|
+
import type { BoundedValidationResult } from './record-core/bounded-validator.js';
|
|
42
|
+
/**
|
|
43
|
+
* Canonical observation projected from either the real path or the
|
|
44
|
+
* shadow path.
|
|
45
|
+
*
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
export interface ShadowObservation {
|
|
49
|
+
readonly accepted: boolean;
|
|
50
|
+
/** Registered error codes, sorted, deduplicated. */
|
|
51
|
+
readonly violationCodes: readonly string[];
|
|
52
|
+
/** Registered warning codes, sorted, deduplicated. */
|
|
53
|
+
readonly warningCodes: readonly string[];
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Real-path observation for a successful `issue()` call. Always
|
|
57
|
+
* projects to the empty accepted-only shape; canonical issuance
|
|
58
|
+
* surfaces no warning codes through `IssueResult`.
|
|
59
|
+
*
|
|
60
|
+
* @internal
|
|
61
|
+
*/
|
|
62
|
+
export declare function realObservationForIssue(): ShadowObservation;
|
|
63
|
+
/**
|
|
64
|
+
* Real-path observation for a successful `verifyLocal()` call. Maps
|
|
65
|
+
* the canonical `warnings: VerificationWarning[]` array onto the
|
|
66
|
+
* normalized warningCodes set.
|
|
67
|
+
*
|
|
68
|
+
* @internal
|
|
69
|
+
*/
|
|
70
|
+
export declare function realObservationForVerifyLocalSuccess(warnings: readonly {
|
|
71
|
+
code: string;
|
|
72
|
+
}[] | undefined): ShadowObservation;
|
|
73
|
+
/**
|
|
74
|
+
* Project a `BoundedValidationResult` into the shared observation
|
|
75
|
+
* shape with full warning-code parity. Use on the verifyLocal path
|
|
76
|
+
* where canonical exposes warning codes through
|
|
77
|
+
* `VerifyLocalSuccess.warnings`.
|
|
78
|
+
*
|
|
79
|
+
* @internal
|
|
80
|
+
*/
|
|
81
|
+
export declare function shadowObservationFromBounded(bounded: BoundedValidationResult): ShadowObservation;
|
|
82
|
+
/**
|
|
83
|
+
* Project a `BoundedValidationResult` into the shared observation
|
|
84
|
+
* shape with `warningCodes` flattened to `[]`. Use on the issue path
|
|
85
|
+
* where canonical issuance does not surface warning codes through
|
|
86
|
+
* `IssueResult`. Without this projection the bounded validator's
|
|
87
|
+
* type-extension or temporal warnings would create false
|
|
88
|
+
* `output-byte-diff` records on every otherwise-successful issuance.
|
|
89
|
+
*
|
|
90
|
+
* @internal
|
|
91
|
+
*/
|
|
92
|
+
export declare function shadowObservationFromBoundedAcceptedOnly(bounded: BoundedValidationResult): ShadowObservation;
|
|
93
|
+
//# sourceMappingURL=shadow-observe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shadow-observe.d.ts","sourceRoot":"","sources":["../../src/_internal/shadow-observe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAElF;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,oDAAoD;IACpD,QAAQ,CAAC,cAAc,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3C,sDAAsD;IACtD,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;CAC1C;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,IAAI,iBAAiB,CAE3D;AAED;;;;;;GAMG;AACH,wBAAgB,oCAAoC,CAClD,QAAQ,EAAE,SAAS;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,GAAG,SAAS,GAChD,iBAAiB,CAOnB;AAED;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,uBAAuB,GAAG,iBAAiB,CAMhG;AAED;;;;;;;;;GASG;AACH,wBAAgB,wCAAwC,CACtD,OAAO,EAAE,uBAAuB,GAC/B,iBAAiB,CAMnB"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shadow-mode telemetry redaction and canonical hashing.
|
|
3
|
+
*
|
|
4
|
+
* @internal
|
|
5
|
+
*
|
|
6
|
+
* INTERNAL ONLY. Not re-exported from packages/protocol/src/index.ts.
|
|
7
|
+
*
|
|
8
|
+
* Two responsibilities:
|
|
9
|
+
*
|
|
10
|
+
* 1. `redactNote(input, maxBytes)`: scrub known secret classes from
|
|
11
|
+
* a free-form string and bound it to a UTF-8 byte ceiling. Used
|
|
12
|
+
* for the `notes` field on every shadow divergence record so
|
|
13
|
+
* that an accidental string concatenation cannot leak credential
|
|
14
|
+
* material into the in-memory shadow log.
|
|
15
|
+
*
|
|
16
|
+
* 2. `canonicalHashOf(value)` / `hashJws(jws)`: produce a SHA-256
|
|
17
|
+
* hex digest of a canonicalized representation. Used as the
|
|
18
|
+
* comparison primitive between real-path and shadow-path results
|
|
19
|
+
* so the divergence log never needs to store raw output.
|
|
20
|
+
*
|
|
21
|
+
* SECRET_PATTERNS is the ground-truth contract for what counts as a
|
|
22
|
+
* leakable secret class. Adding a regex here REQUIRES a paired
|
|
23
|
+
* adversarial test vector in shadow-redact-adversarial.test.ts (one
|
|
24
|
+
* matching vector + one adjacent benign-not-matched vector). Removing
|
|
25
|
+
* a regex here REQUIRES the same justification.
|
|
26
|
+
*
|
|
27
|
+
* Platform neutrality: this module avoids Node-only globals (`Buffer`,
|
|
28
|
+
* `node:crypto`) so it can ship inside the platform-neutral
|
|
29
|
+
* @peac/protocol bundle. UTF-8 byte work uses TextEncoder/TextDecoder;
|
|
30
|
+
* SHA-256 hashing delegates to @peac/crypto.sha256Hex which uses the
|
|
31
|
+
* Web Crypto API with a dynamic Node fallback.
|
|
32
|
+
*/
|
|
33
|
+
/**
|
|
34
|
+
* UTF-8 byte length of a string. Platform-neutral replacement for
|
|
35
|
+
* `Buffer.byteLength(s, 'utf8')`.
|
|
36
|
+
*
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
39
|
+
export declare function utf8ByteLength(value: string): number;
|
|
40
|
+
/**
|
|
41
|
+
* Redact known secret classes from `input` and bound the result to
|
|
42
|
+
* `maxBytes` UTF-8 bytes. The output always either matches the input
|
|
43
|
+
* (when no secret was found and the byte budget permits) or contains
|
|
44
|
+
* the `[REDACTED]` marker.
|
|
45
|
+
*
|
|
46
|
+
* Truncation is byte-aware so multibyte UTF-8 sequences are not split
|
|
47
|
+
* mid-character. When the redacted string exceeds `maxBytes`, the
|
|
48
|
+
* tail is replaced with the marker.
|
|
49
|
+
*
|
|
50
|
+
* @internal
|
|
51
|
+
*/
|
|
52
|
+
export declare function redactNote(input: string, maxBytes: number): string;
|
|
53
|
+
/**
|
|
54
|
+
* SHA-256 hex digest of a canonical-stringified value. Used by the
|
|
55
|
+
* shadow comparator to detect output-byte-diff WITHOUT logging raw
|
|
56
|
+
* content. Object keys are sorted recursively so equivalent objects
|
|
57
|
+
* with different key orders produce identical digests.
|
|
58
|
+
*
|
|
59
|
+
* Async because SHA-256 hashing in this codebase is platform-neutral
|
|
60
|
+
* via @peac/crypto.sha256Hex (Web Crypto API with dynamic Node
|
|
61
|
+
* fallback). Callers run inside the shadow scheduler's microtask /
|
|
62
|
+
* macrotask boundary, so an additional await is free.
|
|
63
|
+
*
|
|
64
|
+
* @internal
|
|
65
|
+
*/
|
|
66
|
+
export declare function canonicalHashOf(value: unknown): Promise<string>;
|
|
67
|
+
/**
|
|
68
|
+
* SHA-256 hex digest of a JWS string. Used as the primary
|
|
69
|
+
* `recordRefHash` input for divergence records.
|
|
70
|
+
*
|
|
71
|
+
* @internal
|
|
72
|
+
*/
|
|
73
|
+
export declare function hashJws(jws: string): Promise<string>;
|
|
74
|
+
//# sourceMappingURL=shadow-redact.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shadow-redact.d.ts","sourceRoot":"","sources":["../../src/_internal/shadow-redact.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAuEH;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAiBlE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAErE;AAED;;;;;GAKG;AACH,wBAAsB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAE1D"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shadow-mode divergence types.
|
|
3
|
+
*
|
|
4
|
+
* @internal
|
|
5
|
+
*
|
|
6
|
+
* INTERNAL ONLY. Not re-exported from packages/protocol/src/index.ts.
|
|
7
|
+
* The dist-leak Tier 2 (.d.ts) and Tier 2b (runtime-export) gates
|
|
8
|
+
* assert these names never appear in any public emitted file.
|
|
9
|
+
*
|
|
10
|
+
* Divergence records describe the difference between the canonical
|
|
11
|
+
* (real-path) result of a public call and a shadow-path result. They
|
|
12
|
+
* NEVER carry raw secret material, raw error messages, raw payloads,
|
|
13
|
+
* or stringified results. All comparison is done via canonical hashes
|
|
14
|
+
* (SHA-256 over a canonical-stringified value); all error reporting is
|
|
15
|
+
* done via registered error codes (not message text); all free-form
|
|
16
|
+
* notes are bounded and redacted before storage.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* The class of divergence between real-path and shadow-path results.
|
|
20
|
+
*
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
export type ShadowDivergenceKind = 'output-byte-diff' | 'error-code-diff' | 'timing-diff' | 'resource-limit-diff' | 'shadow-error';
|
|
24
|
+
/**
|
|
25
|
+
* Which public call produced this divergence record.
|
|
26
|
+
*
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
export type ShadowCall = 'issue' | 'verifyLocal' | 'verify';
|
|
30
|
+
/**
|
|
31
|
+
* A single divergence record. Fields are intentionally narrow:
|
|
32
|
+
*
|
|
33
|
+
* - hashes (SHA-256 hex of canonicalized values), never raw values;
|
|
34
|
+
* - error codes (registered identifiers), never message text;
|
|
35
|
+
* - byte lengths (counts), never payload contents;
|
|
36
|
+
* - notes (short category labels, ≤128 bytes, redaction-marked).
|
|
37
|
+
*
|
|
38
|
+
* @internal
|
|
39
|
+
*/
|
|
40
|
+
export interface ShadowDivergence {
|
|
41
|
+
readonly kind: ShadowDivergenceKind;
|
|
42
|
+
readonly call: ShadowCall;
|
|
43
|
+
/** SHA-256 hex of the recordRef (e.g., the produced JWS). Never the raw ref. */
|
|
44
|
+
readonly recordRefHash: string;
|
|
45
|
+
/** SHA-256 hex of the canonical real-path result, when defined. */
|
|
46
|
+
readonly realResultHash?: string;
|
|
47
|
+
/** SHA-256 hex of the canonical shadow-path result, when defined. */
|
|
48
|
+
readonly shadowResultHash?: string;
|
|
49
|
+
/** Registered error code from the real-path failure, when present. */
|
|
50
|
+
readonly realErrorCode?: string;
|
|
51
|
+
/** Registered error code from the shadow-path failure, when present. */
|
|
52
|
+
readonly shadowErrorCode?: string;
|
|
53
|
+
/** Byte length of the real-path result. */
|
|
54
|
+
readonly realByteLen?: number;
|
|
55
|
+
/** Byte length of the shadow-path result. */
|
|
56
|
+
readonly shadowByteLen?: number;
|
|
57
|
+
/** Short category label, ≤128 bytes, redaction-marked. */
|
|
58
|
+
readonly notes: string;
|
|
59
|
+
/** ISO 8601 UTC timestamp. */
|
|
60
|
+
readonly timestamp: string;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=shadow-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shadow-types.d.ts","sourceRoot":"","sources":["../../src/_internal/shadow-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAC5B,kBAAkB,GAClB,iBAAiB,GACjB,aAAa,GACb,qBAAqB,GACrB,cAAc,CAAC;AAEnB;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,aAAa,GAAG,QAAQ,CAAC;AAE5D;;;;;;;;;GASG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAC;IACpC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,gFAAgF;IAChF,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,mEAAmE;IACnE,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,qEAAqE;IACrE,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IACnC,sEAAsE;IACtE,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,wEAAwE;IACxE,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,2CAA2C;IAC3C,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,6CAA6C;IAC7C,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,0DAA0D;IAC1D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,8BAA8B;IAC9B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shadow-mode scheduler.
|
|
3
|
+
*
|
|
4
|
+
* @internal
|
|
5
|
+
*
|
|
6
|
+
* INTERNAL ONLY. Not re-exported from packages/protocol/src/index.ts.
|
|
7
|
+
*
|
|
8
|
+
* Schedules a shadow function to run AFTER the public-call boundary
|
|
9
|
+
* has returned its real-path result to the caller. The shadow run:
|
|
10
|
+
*
|
|
11
|
+
* - is gated by `isShadowEnabled(options)` (env or programmatic);
|
|
12
|
+
* - starts on a MACROTASK boundary (`setTimeout(..., 0)`), NOT on a
|
|
13
|
+
* microtask, because microtasks can run before promise
|
|
14
|
+
* continuations attached to the public async call and would still
|
|
15
|
+
* add observable latency for CPU-heavy shadow work;
|
|
16
|
+
* - has a bounded wall-clock REPORTING timeout (250ms by default;
|
|
17
|
+
* see "Timeout guarantee class" below);
|
|
18
|
+
* - reports comparison results into a bounded in-memory log;
|
|
19
|
+
* - SWALLOWS every error, never propagating to the real-path return
|
|
20
|
+
* value or surfacing as an unhandled-rejection event.
|
|
21
|
+
*
|
|
22
|
+
* The public function:
|
|
23
|
+
*
|
|
24
|
+
* - returns the real-path value FIRST (the macrotask boundary is
|
|
25
|
+
* past every async continuation already attached to the call
|
|
26
|
+
* site);
|
|
27
|
+
* - never awaits shadow work;
|
|
28
|
+
* - is byte-identical in its return value with shadow ON vs OFF.
|
|
29
|
+
*
|
|
30
|
+
* Timeout guarantee class. The 250ms timeout is a REPORTING bound,
|
|
31
|
+
* not a hard preemption guarantee. Where the shadow function consults
|
|
32
|
+
* the supplied `AbortSignal`, the runner aborts and bounds CPU; where
|
|
33
|
+
* the shadow function is pure-CPU and ignores the signal (the v0.13.1
|
|
34
|
+
* record-core validators are this shape), JavaScript cannot preempt
|
|
35
|
+
* it. The runner stops awaiting and records `timing-diff`; the work
|
|
36
|
+
* may continue to completion off the runner's await chain. Either
|
|
37
|
+
* way, the public-call boundary returns its real-path value
|
|
38
|
+
* immediately.
|
|
39
|
+
*
|
|
40
|
+
* Test-only helpers (`_peekShadowLog`, `_resetShadowLog`,
|
|
41
|
+
* `_drainShadowQueueForTests`) are exposed for deterministic
|
|
42
|
+
* assertions in vitest. Production code MUST NOT call them.
|
|
43
|
+
*
|
|
44
|
+
* Platform neutrality: this module avoids Node-only globals
|
|
45
|
+
* (`Buffer`, `node:crypto`, unguarded `process`). Hashing delegates
|
|
46
|
+
* to @peac/crypto; environment reads guard for the absence of
|
|
47
|
+
* `process` so the module loads cleanly under browser / edge
|
|
48
|
+
* runtimes.
|
|
49
|
+
*/
|
|
50
|
+
import type { ShadowCall, ShadowDivergence } from './shadow-types.js';
|
|
51
|
+
/**
|
|
52
|
+
* Programmatic-flag shape. Internal-only; never appears in any
|
|
53
|
+
* exported public option type.
|
|
54
|
+
*
|
|
55
|
+
* @internal
|
|
56
|
+
*/
|
|
57
|
+
export interface ShadowEnableOptions {
|
|
58
|
+
readonly _internal?: {
|
|
59
|
+
readonly shadowCore?: boolean;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Read the shadow-enable flag from environment or programmatic
|
|
64
|
+
* options. Read once per call, NOT cached at module scope, so tests
|
|
65
|
+
* can toggle the env var dynamically. Environment access is guarded
|
|
66
|
+
* for browser / edge runtimes that do not expose `process`.
|
|
67
|
+
*
|
|
68
|
+
* @internal
|
|
69
|
+
*/
|
|
70
|
+
export declare function isShadowEnabled(options?: ShadowEnableOptions): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Inputs to `scheduleShadow`. The `shadowFn` factory receives an
|
|
73
|
+
* `AbortSignal` so cancellable implementations can opt in. v0.13.1
|
|
74
|
+
* shadow paths are pure-CPU and ignore the signal; the runner still
|
|
75
|
+
* passes one for forward-compat.
|
|
76
|
+
*
|
|
77
|
+
* @internal
|
|
78
|
+
*/
|
|
79
|
+
export interface ScheduleShadowArgs<T> {
|
|
80
|
+
readonly call: ShadowCall;
|
|
81
|
+
readonly realResult: T | undefined;
|
|
82
|
+
readonly realError: {
|
|
83
|
+
code?: string;
|
|
84
|
+
} | undefined;
|
|
85
|
+
readonly shadowFn: (signal?: AbortSignal) => Promise<T>;
|
|
86
|
+
readonly recordRef: string;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Schedule shadow work AFTER the real-path return.
|
|
90
|
+
*
|
|
91
|
+
* The shadow run starts on the next MACROTASK boundary (via
|
|
92
|
+
* `setTimeout(..., 0)`). The public function returns its real-path
|
|
93
|
+
* value before the macrotask fires, including for async callers
|
|
94
|
+
* whose `.then` / `await` continuations execute on microtasks.
|
|
95
|
+
* `queueMicrotask` would interleave with those continuations and is
|
|
96
|
+
* intentionally avoided.
|
|
97
|
+
*
|
|
98
|
+
* Tasks are tracked internally so test helpers can drain them for
|
|
99
|
+
* deterministic assertions; production callers ignore the (void)
|
|
100
|
+
* return.
|
|
101
|
+
*
|
|
102
|
+
* Failures inside the shadow path are converted to divergence records
|
|
103
|
+
* inside the task body. The outer `task.catch(() => {})` is defense
|
|
104
|
+
* in depth: if anything inside `runShadowTask` throws after the inner
|
|
105
|
+
* try/catch (e.g., a hash failure during canonical comparison), the
|
|
106
|
+
* outer catch swallows the rejection so no unhandled-rejection event
|
|
107
|
+
* fires.
|
|
108
|
+
*
|
|
109
|
+
* @internal
|
|
110
|
+
*/
|
|
111
|
+
export declare function scheduleShadow<T>(args: ScheduleShadowArgs<T>): void;
|
|
112
|
+
/**
|
|
113
|
+
* Read the in-memory shadow log without mutating it. TEST USE ONLY.
|
|
114
|
+
*
|
|
115
|
+
* @internal
|
|
116
|
+
*/
|
|
117
|
+
export declare function _peekShadowLog(): readonly ShadowDivergence[];
|
|
118
|
+
/**
|
|
119
|
+
* Clear the in-memory shadow log. TEST USE ONLY.
|
|
120
|
+
*
|
|
121
|
+
* @internal
|
|
122
|
+
*/
|
|
123
|
+
export declare function _resetShadowLog(): void;
|
|
124
|
+
/**
|
|
125
|
+
* Drain the pending-shadow-tasks set so deterministic assertions can
|
|
126
|
+
* run after a sequence of shadow-enabled calls. Yields to the event
|
|
127
|
+
* loop until every scheduled `setTimeout` has fired AND every
|
|
128
|
+
* resulting task has settled. TEST USE ONLY. Production code MUST
|
|
129
|
+
* NOT call this.
|
|
130
|
+
*
|
|
131
|
+
* @internal
|
|
132
|
+
*/
|
|
133
|
+
export declare function _drainShadowQueueForTests(): Promise<void>;
|
|
134
|
+
//# sourceMappingURL=shadow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shadow.d.ts","sourceRoot":"","sources":["../../src/_internal/shadow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAYtE;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,SAAS,CAAC,EAAE;QACnB,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;KAC/B,CAAC;CACH;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAGtE;AAQD;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB,CAAC,CAAC;IACnC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,CAAC,GAAG,SAAS,CAAC;IACnC,QAAQ,CAAC,SAAS,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC;IAClD,QAAQ,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;IACxD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAAG,IAAI,CAiBnE;AAyHD;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,SAAS,gBAAgB,EAAE,CAE5D;AAED;;;;GAIG;AACH,wBAAgB,eAAe,IAAI,IAAI,CAEtC;AAED;;;;;;;;GAQG;AACH,wBAAsB,yBAAyB,IAAI,OAAO,CAAC,IAAI,CAAC,CAU/D"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical-path runner for parity tests.
|
|
3
|
+
*
|
|
4
|
+
* INTERNAL TEST HELPER. Wraps the existing canonical validator path
|
|
5
|
+
* (validateKernelConstraints + parseReceiptClaims for envelope; or
|
|
6
|
+
* validateWire02Header for JOSE) and returns a normalized ParityVerdict.
|
|
7
|
+
*
|
|
8
|
+
* Used by both the canonical-truth sanity test and the differential
|
|
9
|
+
* harness. Pure: same input always yields the same verdict bytes.
|
|
10
|
+
*/
|
|
11
|
+
import { type ParityVerdict } from './parity-verdict.js';
|
|
12
|
+
/** Kind of canonical runner to dispatch to. */
|
|
13
|
+
export type CanonicalRunnerKind = 'envelope' | 'jose';
|
|
14
|
+
/**
|
|
15
|
+
* Run JOSE-hardening canonical path on a JOSE protected header. Returns
|
|
16
|
+
* accepted=true if the header passes validateWire02Header, accepted=false
|
|
17
|
+
* with the CryptoError code on rejection.
|
|
18
|
+
*/
|
|
19
|
+
export declare function runJoseCanonical(header: Record<string, unknown> | undefined): ParityVerdict;
|
|
20
|
+
/**
|
|
21
|
+
* Run Wire 0.2 envelope canonical path on parsed claims. Layer 1 only:
|
|
22
|
+
* kernel constraints (depth / total nodes / key counts) followed by Zod
|
|
23
|
+
* schema parse. Type-extension warnings live at Layer 3 (verifyLocal)
|
|
24
|
+
* and are intentionally out of scope for the parity foundation.
|
|
25
|
+
*
|
|
26
|
+
* Accepted records carry canonicalClaimsDigest computed from the parsed
|
|
27
|
+
* claims via JCS + SHA-256 + "sha256:" prefix. This anchors the verdict
|
|
28
|
+
* to the canonical normalized claims, not just the accept/reject bit:
|
|
29
|
+
* two validators that both accept but disagree on parsed/normalized
|
|
30
|
+
* claims will produce different digests and the harness will catch it.
|
|
31
|
+
*/
|
|
32
|
+
export declare function runEnvelopeCanonical(payload: Record<string, unknown>): Promise<ParityVerdict>;
|
|
33
|
+
/**
|
|
34
|
+
* Dispatch to the appropriate canonical runner by kind.
|
|
35
|
+
*
|
|
36
|
+
* kind === 'jose' → runJoseCanonical(input as header) (sync)
|
|
37
|
+
* kind === 'envelope' → runEnvelopeCanonical(input as payload) (async)
|
|
38
|
+
*
|
|
39
|
+
* The dispatcher always returns a Promise so callers can uniformly
|
|
40
|
+
* await regardless of kind.
|
|
41
|
+
*/
|
|
42
|
+
export declare function runCanonicalForKind(kind: CanonicalRunnerKind, input: Record<string, unknown>): Promise<ParityVerdict>;
|
|
43
|
+
//# sourceMappingURL=canonical-runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canonical-runner.d.ts","sourceRoot":"","sources":["../../../src/_internal/test-helpers/canonical-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EAAiC,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAmBxF,+CAA+C;AAC/C,MAAM,MAAM,mBAAmB,GAAG,UAAU,GAAG,MAAM,CAAC;AAEtD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GAAG,aAAa,CAY3F;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,OAAO,CAAC,aAAa,CAAC,CAmBxB;AAED;;;;;;;;GAQG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,mBAAmB,EACzB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,OAAO,CAAC,aAAa,CAAC,CAGxB"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parity corpus loader.
|
|
3
|
+
*
|
|
4
|
+
* INTERNAL TEST HELPER. Loads parity-corpus families under
|
|
5
|
+
* specs/conformance/parity-corpus/ and validates each family's vectors.json
|
|
6
|
+
* against its vectors.schema.json (JSON Schema 2020-12) using ajv strict +
|
|
7
|
+
* ajv-formats.
|
|
8
|
+
*
|
|
9
|
+
* Used by the differential harness in __tests__/_internal/. Not exported
|
|
10
|
+
* from packages/protocol/src/index.ts. Not part of the published surface.
|
|
11
|
+
*/
|
|
12
|
+
/** Canonical family identifiers shipped at the v0.13.1 floor. */
|
|
13
|
+
export declare const PARITY_FAMILIES: readonly ["default-flows", "jose-hardening", "runtime-governance", "commerce-bridges"];
|
|
14
|
+
export type ParityFamily = (typeof PARITY_FAMILIES)[number];
|
|
15
|
+
/** Floor vector counts per family (per plan amendment §0S.5). */
|
|
16
|
+
export declare const PARITY_FLOOR_COUNTS: Readonly<Record<ParityFamily, number>>;
|
|
17
|
+
export interface ParityVectorInput {
|
|
18
|
+
readonly payload: Record<string, unknown>;
|
|
19
|
+
readonly header?: Record<string, unknown>;
|
|
20
|
+
}
|
|
21
|
+
export interface ParityVectorExpected {
|
|
22
|
+
readonly accepted: boolean;
|
|
23
|
+
readonly errors?: ReadonlyArray<{
|
|
24
|
+
readonly code: string;
|
|
25
|
+
readonly path?: string;
|
|
26
|
+
}>;
|
|
27
|
+
readonly warnings?: ReadonlyArray<{
|
|
28
|
+
readonly code: string;
|
|
29
|
+
readonly path?: string;
|
|
30
|
+
}>;
|
|
31
|
+
}
|
|
32
|
+
export interface ParityVector {
|
|
33
|
+
readonly id: string;
|
|
34
|
+
readonly description: string;
|
|
35
|
+
readonly input: ParityVectorInput;
|
|
36
|
+
readonly expected: ParityVectorExpected;
|
|
37
|
+
}
|
|
38
|
+
export interface ParityCorpusFamily {
|
|
39
|
+
readonly family: ParityFamily;
|
|
40
|
+
readonly description: string;
|
|
41
|
+
readonly version: string;
|
|
42
|
+
readonly generator?: string;
|
|
43
|
+
readonly vectors: ReadonlyArray<ParityVector>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Resolve the parity-corpus root directory.
|
|
47
|
+
*
|
|
48
|
+
* Walks up from `process.cwd()` looking for `specs/conformance/parity-corpus/`.
|
|
49
|
+
* Works whether tests run from the repo root or from any package directory.
|
|
50
|
+
* Override allowed via the optional argument.
|
|
51
|
+
*/
|
|
52
|
+
export declare function resolveCorpusRoot(override?: string): string;
|
|
53
|
+
/**
|
|
54
|
+
* Load and schema-validate one parity family. Throws an Error with a
|
|
55
|
+
* structured message if the family's vectors.json does not match its
|
|
56
|
+
* vectors.schema.json or if the floor count is not met.
|
|
57
|
+
*/
|
|
58
|
+
export declare function loadFamily(family: ParityFamily, corpusRoot?: string): ParityCorpusFamily;
|
|
59
|
+
/** Load all four families. Returns them in declared family order. */
|
|
60
|
+
export declare function loadAllFamilies(corpusRoot?: string): ReadonlyArray<ParityCorpusFamily>;
|
|
61
|
+
//# sourceMappingURL=corpus-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"corpus-loader.d.ts","sourceRoot":"","sources":["../../../src/_internal/test-helpers/corpus-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAOH,iEAAiE;AACjE,eAAO,MAAM,eAAe,wFAKlB,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAE5D,iEAAiE;AACjE,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAKtE,CAAC;AAEF,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC1C,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC3C;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,aAAa,CAAC;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACnF,QAAQ,CAAC,QAAQ,CAAC,EAAE,aAAa,CAAC;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACtF;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,iBAAiB,CAAC;IAClC,QAAQ,CAAC,QAAQ,EAAE,oBAAoB,CAAC;CACzC;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;CAC/C;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAc3D;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,YAAY,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,kBAAkB,CAuCxF;AAED,qEAAqE;AACrE,wBAAgB,eAAe,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,aAAa,CAAC,kBAAkB,CAAC,CAEtF"}
|