@primust/verifier 1.0.0

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 (46) hide show
  1. package/LICENSE +93 -0
  2. package/dist/bounded-trace.d.ts +46 -0
  3. package/dist/bounded-trace.d.ts.map +1 -0
  4. package/dist/bounded-trace.js +558 -0
  5. package/dist/bounded-trace.js.map +1 -0
  6. package/dist/cli.d.ts +18 -0
  7. package/dist/cli.d.ts.map +1 -0
  8. package/dist/cli.js +391 -0
  9. package/dist/cli.js.map +1 -0
  10. package/dist/index.d.ts +13 -0
  11. package/dist/index.d.ts.map +1 -0
  12. package/dist/index.js +13 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/key-cache.d.ts +20 -0
  15. package/dist/key-cache.d.ts.map +1 -0
  16. package/dist/key-cache.js +68 -0
  17. package/dist/key-cache.js.map +1 -0
  18. package/dist/scoped.d.ts +35 -0
  19. package/dist/scoped.d.ts.map +1 -0
  20. package/dist/scoped.js +582 -0
  21. package/dist/scoped.js.map +1 -0
  22. package/dist/types.d.ts +60 -0
  23. package/dist/types.d.ts.map +1 -0
  24. package/dist/types.js +5 -0
  25. package/dist/types.js.map +1 -0
  26. package/dist/upstream_resolver.d.ts +60 -0
  27. package/dist/upstream_resolver.d.ts.map +1 -0
  28. package/dist/upstream_resolver.js +126 -0
  29. package/dist/upstream_resolver.js.map +1 -0
  30. package/dist/v29-envelope.d.ts +55 -0
  31. package/dist/v29-envelope.d.ts.map +1 -0
  32. package/dist/v29-envelope.js +450 -0
  33. package/dist/v29-envelope.js.map +1 -0
  34. package/dist/verifier.d.ts +36 -0
  35. package/dist/verifier.d.ts.map +1 -0
  36. package/dist/verifier.js +1235 -0
  37. package/dist/verifier.js.map +1 -0
  38. package/dist/verifier.test.d.ts +2 -0
  39. package/dist/verifier.test.d.ts.map +1 -0
  40. package/dist/verifier.test.js +395 -0
  41. package/dist/verifier.test.js.map +1 -0
  42. package/dist/verify-html-template.d.ts +45 -0
  43. package/dist/verify-html-template.d.ts.map +1 -0
  44. package/dist/verify-html-template.js +182 -0
  45. package/dist/verify-html-template.js.map +1 -0
  46. package/package.json +52 -0
package/LICENSE ADDED
@@ -0,0 +1,93 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity.
18
+
19
+ "You" (or "Your") shall mean an individual or Legal Entity
20
+ exercising permissions granted by this License.
21
+
22
+ "Source" form shall mean the preferred form for making modifications.
23
+
24
+ "Object" form shall mean any form resulting from mechanical
25
+ transformation or translation of a Source form.
26
+
27
+ "Work" shall mean the work of authorship made available under
28
+ the License.
29
+
30
+ "Contribution" shall mean any work of authorship submitted to the
31
+ Licensor for inclusion in the Work.
32
+
33
+ "Contributor" shall mean Licensor and any Legal Entity on behalf of
34
+ whom a Contribution has been received by the Licensor.
35
+
36
+ 2. Grant of Copyright License. Subject to the terms and conditions of
37
+ this License, each Contributor hereby grants to You a perpetual,
38
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
39
+ copyright license to reproduce, prepare Derivative Works of,
40
+ publicly display, publicly perform, sublicense, and distribute the
41
+ Work and such Derivative Works in Source or Object form.
42
+
43
+ 3. Grant of Patent License. Subject to the terms and conditions of
44
+ this License, each Contributor hereby grants to You a perpetual,
45
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
46
+ patent license to make, have made, use, offer to sell, sell,
47
+ import, and otherwise transfer the Work.
48
+
49
+ 4. Redistribution. You may reproduce and distribute copies of the
50
+ Work or Derivative Works thereof in any medium, with or without
51
+ modifications, and in Source or Object form, provided that You
52
+ meet the following conditions:
53
+
54
+ (a) You must give any other recipients of the Work or
55
+ Derivative Works a copy of this License; and
56
+
57
+ (b) You must cause any modified files to carry prominent notices
58
+ stating that You changed the files; and
59
+
60
+ (c) You must retain, in the Source form of any Derivative Works
61
+ that You distribute, all copyright, patent, trademark, and
62
+ attribution notices from the Source form of the Work; and
63
+
64
+ (d) If the Work includes a "NOTICE" text file, You must include
65
+ a readable copy of the attribution notices contained within
66
+ such NOTICE file.
67
+
68
+ 5. Submission of Contributions.
69
+
70
+ 6. Trademarks. This License does not grant permission to use the trade
71
+ names, trademarks, service marks, or product names of the Licensor.
72
+
73
+ 7. Disclaimer of Warranty. The Work is provided on an "AS IS" BASIS,
74
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND.
75
+
76
+ 8. Limitation of Liability. In no event shall any Contributor be
77
+ liable to You for damages.
78
+
79
+ 9. Accepting Warranty or Additional Liability.
80
+
81
+ Copyright 2026 Primust Inc.
82
+
83
+ Licensed under the Apache License, Version 2.0 (the "License");
84
+ you may not use this file except in compliance with the License.
85
+ You may obtain a copy of the License at
86
+
87
+ http://www.apache.org/licenses/LICENSE-2.0
88
+
89
+ Unless required by applicable law or agreed to in writing, software
90
+ distributed under the License is distributed on an "AS IS" BASIS,
91
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
92
+ See the License for the specific language governing permissions and
93
+ limitations under the License.
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Reference TypeScript interpreter for bounded_trace_v1 verification.
3
+ *
4
+ * This is the canonical second-opinion verifier described in PRIMUST_V27 §20.2,
5
+ * ported from verifier-py/src/primust_verify/bounded_trace.py. It is
6
+ * intentionally small and obviously-correct: consumes a BoundedTraceV1 payload
7
+ * plus a ProfileRecord and produces one of the §16.3 canonical downgrade
8
+ * reason codes (or "ok" on success).
9
+ *
10
+ * Crypto used: SHA-256 with RFC 6962-style domain-separated leaves (0x00)
11
+ * and nodes (0x01). Canonical JSON follows RFC 8785 + ECMAScript 7.1.12.1
12
+ * number serialization for cross-language parity.
13
+ *
14
+ * SI-3 (VPEC verifiability): this module's output MUST match the Python
15
+ * reference byte-for-byte across the shared conformance fixture corpus at
16
+ * packages/verifier-py/tests/fixtures/bounded_trace_v1/. The conformance
17
+ * runner in scripts/lane_a_conformance.* enforces this.
18
+ *
19
+ * Zero runtime dependencies besides node:crypto.
20
+ */
21
+ export declare function canonicalNumber(x: number): string;
22
+ /**
23
+ * Canonical JSON serialization:
24
+ * - object keys sorted lexicographically
25
+ * - UTF-8
26
+ * - separators ",":":", no whitespace
27
+ * - numbers via canonicalNumber
28
+ * - strings via JSON.stringify (same escape rules as Python json with ensure_ascii=False)
29
+ */
30
+ export declare function canonicalJson(obj: unknown): Uint8Array;
31
+ export declare function canonicalJsonString(obj: unknown): string;
32
+ export declare function buildMerkleRoot(leaves: Uint8Array[]): string;
33
+ export interface BoundedTraceResult {
34
+ valid: boolean;
35
+ proof_level: "operator_bound" | "execution";
36
+ reason: string;
37
+ disclosed_operator_count: number;
38
+ verified_merkle_paths: number;
39
+ details: Record<string, unknown>;
40
+ }
41
+ export declare const REASONS: readonly ["profile_not_found", "profile_signature_invalid", "profile_not_empirical", "profile_expired", "profile_revoked", "profile_no_freshness_window", "profile_trace_mismatch", "runtime_not_supported", "trace_schema_unknown", "missing_merkle_root", "merkle_inclusion_failed", "threshold_violation", "runtime_section_missing", "retrieval_section_missing", "closed_api_pre_cohort", "closed_api_pre_promote", "closed_api_v2_promoted", "profile_deprecated", "unknown_lifecycle_state"];
42
+ export type ReasonCode = (typeof REASONS)[number] | "thresholds_verified";
43
+ export declare function verifyBoundedTrace(trace: Record<string, unknown>, profile: Record<string, unknown>, options?: {
44
+ now?: Date;
45
+ }): BoundedTraceResult;
46
+ //# sourceMappingURL=bounded-trace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bounded-trace.d.ts","sourceRoot":"","sources":["../src/bounded-trace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAMH,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CA6BjD;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,UAAU,CAGtD;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAiBxD;AAiCD,wBAAgB,eAAe,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,CAgB5D;AAID,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,OAAO,CAAC;IACf,WAAW,EAAE,gBAAgB,GAAG,WAAW,CAAC;IAC5C,MAAM,EAAE,MAAM,CAAC;IACf,wBAAwB,EAAE,MAAM,CAAC;IACjC,qBAAqB,EAAE,MAAM,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAID,eAAO,MAAM,OAAO,qeA0BV,CAAC;AAEX,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,CAAC,GAAG,qBAAqB,CAAC;AAsS1E,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,OAAO,GAAE;IAAE,GAAG,CAAC,EAAE,IAAI,CAAA;CAAO,GAC3B,kBAAkB,CA2JpB"}