@certcrypt/sdk 0.0.0-stage → 1.0.1

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.

Potentially problematic release.


This version of @certcrypt/sdk might be problematic. Click here for more details.

Files changed (71) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/LICENSE +178 -0
  3. package/README.md +557 -2
  4. package/SECURITY.md +55 -0
  5. package/dist/src/artifacts/base-certificate.d.ts +336 -0
  6. package/dist/src/artifacts/base-certificate.js +373 -0
  7. package/dist/src/artifacts/base-certificate.js.map +1 -0
  8. package/dist/src/artifacts/capacity-evidence.d.ts +195 -0
  9. package/dist/src/artifacts/capacity-evidence.js +202 -0
  10. package/dist/src/artifacts/capacity-evidence.js.map +1 -0
  11. package/dist/src/artifacts/commitment-inclusion.d.ts +23 -0
  12. package/dist/src/artifacts/commitment-inclusion.js +91 -0
  13. package/dist/src/artifacts/commitment-inclusion.js.map +1 -0
  14. package/dist/src/artifacts/holder-keyset.d.ts +67 -0
  15. package/dist/src/artifacts/holder-keyset.js +149 -0
  16. package/dist/src/artifacts/holder-keyset.js.map +1 -0
  17. package/dist/src/artifacts/rfc3339.d.ts +9 -0
  18. package/dist/src/artifacts/rfc3339.js +39 -0
  19. package/dist/src/artifacts/rfc3339.js.map +1 -0
  20. package/dist/src/client.d.ts +552 -0
  21. package/dist/src/client.js +1347 -0
  22. package/dist/src/client.js.map +1 -0
  23. package/dist/src/crypto/ai-decision.d.ts +73 -0
  24. package/dist/src/crypto/ai-decision.js +94 -0
  25. package/dist/src/crypto/ai-decision.js.map +1 -0
  26. package/dist/src/crypto/canonical-subject.d.ts +33 -0
  27. package/dist/src/crypto/canonical-subject.js +240 -0
  28. package/dist/src/crypto/canonical-subject.js.map +1 -0
  29. package/dist/src/crypto/collection-merkle.d.ts +58 -0
  30. package/dist/src/crypto/collection-merkle.js +164 -0
  31. package/dist/src/crypto/collection-merkle.js.map +1 -0
  32. package/dist/src/crypto/composite.d.ts +53 -0
  33. package/dist/src/crypto/composite.js +69 -0
  34. package/dist/src/crypto/composite.js.map +1 -0
  35. package/dist/src/crypto/digest.d.ts +3 -0
  36. package/dist/src/crypto/digest.js +31 -0
  37. package/dist/src/crypto/digest.js.map +1 -0
  38. package/dist/src/crypto/ecdsa-p256.d.ts +79 -0
  39. package/dist/src/crypto/ecdsa-p256.js +277 -0
  40. package/dist/src/crypto/ecdsa-p256.js.map +1 -0
  41. package/dist/src/crypto/jcs.d.ts +13 -0
  42. package/dist/src/crypto/jcs.js +65 -0
  43. package/dist/src/crypto/jcs.js.map +1 -0
  44. package/dist/src/crypto/merkle.d.ts +18 -0
  45. package/dist/src/crypto/merkle.js +150 -0
  46. package/dist/src/crypto/merkle.js.map +1 -0
  47. package/dist/src/crypto/ml-dsa.d.ts +28 -0
  48. package/dist/src/crypto/ml-dsa.js +60 -0
  49. package/dist/src/crypto/ml-dsa.js.map +1 -0
  50. package/dist/src/crypto/pseudonym.d.ts +8 -0
  51. package/dist/src/crypto/pseudonym.js +50 -0
  52. package/dist/src/crypto/pseudonym.js.map +1 -0
  53. package/dist/src/crypto/strict-json.d.ts +25 -0
  54. package/dist/src/crypto/strict-json.js +180 -0
  55. package/dist/src/crypto/strict-json.js.map +1 -0
  56. package/dist/src/crypto/subject-json-preconditions.d.ts +46 -0
  57. package/dist/src/crypto/subject-json-preconditions.js +381 -0
  58. package/dist/src/crypto/subject-json-preconditions.js.map +1 -0
  59. package/dist/src/index.d.ts +18 -0
  60. package/dist/src/index.js +80 -0
  61. package/dist/src/index.js.map +1 -0
  62. package/dist/src/issuer.d.ts +668 -0
  63. package/dist/src/issuer.js +1066 -0
  64. package/dist/src/issuer.js.map +1 -0
  65. package/dist/src/retry.d.ts +67 -0
  66. package/dist/src/retry.js +78 -0
  67. package/dist/src/retry.js.map +1 -0
  68. package/dist/src/types.d.ts +297 -0
  69. package/dist/src/types.js +15 -0
  70. package/dist/src/types.js.map +1 -0
  71. package/package.json +62 -4
@@ -0,0 +1,50 @@
1
+ // Copyright © 2025-2026 CERTCRYPT, Inc., its affiliates or licensors. All rights reserved.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ /**
15
+ * Operation-scoped pseudonyms — issuer-side mirror of the reference verifier,
16
+ * ported byte-for-byte (CCCP/1):
17
+ *
18
+ * pseudonym(field) = SHA3-256( frame(operation_salt) || frame(domain_tag) || frame(stable_id) )
19
+ *
20
+ * Each field is absorbed with an 8-byte big-endian length prefix (framing) so
21
+ * field boundaries are unambiguous — without this, ("ab","c") and ("a","bc")
22
+ * would collide. 32-byte output, lowercase hex.
23
+ *
24
+ * Hash: SHA3-256 (FIPS 202 fixed-output), not SHAKE-256 — the output is a fixed
25
+ * 32 bytes, so the XOF buys nothing.
26
+ *
27
+ * Parity is pinned by the published conformance vectors
28
+ * (`fixtures/primitives/pseudonym`).
29
+ */
30
+ import { createHash } from "node:crypto";
31
+ /** Absorb a field with an 8-byte big-endian length prefix. */
32
+ function frame(field) {
33
+ const len = Buffer.alloc(8);
34
+ len.writeBigUInt64BE(BigInt(field.length));
35
+ return Buffer.concat([len, Buffer.from(field)]);
36
+ }
37
+ /**
38
+ * Derive an operation-scoped pseudonym. `operationSalt` is the public
39
+ * per-operation salt carried in the evidence; `domain` separates namespaces;
40
+ * `stableId` is the identifier being projected; the capacity evidence carries
41
+ * only its pseudonym.
42
+ */
43
+ export function derivePseudonym(operationSalt, domain, stableId) {
44
+ const h = createHash("sha3-256");
45
+ h.update(frame(operationSalt));
46
+ h.update(frame(new TextEncoder().encode(domain)));
47
+ h.update(frame(new TextEncoder().encode(stableId)));
48
+ return h.digest("hex");
49
+ }
50
+ //# sourceMappingURL=pseudonym.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pseudonym.js","sourceRoot":"","sources":["../../../src/crypto/pseudonym.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAIzC,8DAA8D;AAC9D,SAAS,KAAK,CAAC,KAAiB;IAC9B,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC5B,GAAG,CAAC,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IAC3C,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAClD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAC7B,aAAyB,EACzB,MAAuB,EACvB,QAAgB;IAEhB,MAAM,CAAC,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC;IACjC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;IAC/B,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAClD,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IACpD,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACzB,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Strict JSON parsing: RFC 8259 grammar, and no object may carry the same member
3
+ * name twice, at any depth.
4
+ *
5
+ * `JSON.parse` accepts duplicate member names and keeps the last value. Another
6
+ * parser may keep the first, or reject, so two verifiers reading the same bytes
7
+ * could evaluate different data. A duplicate therefore makes the input
8
+ * non-conformant (CCSP/1 §8.1, and the JSON subject profiles), and this parser
9
+ * fails closed on it.
10
+ *
11
+ * Member names are compared after decoding their escapes, so `"anchor"` and
12
+ * `"anchor"` are the same name. Only object members are compared: repeated
13
+ * elements of an array are ordinary data, and the same name in two different
14
+ * objects is not a duplicate.
15
+ *
16
+ * The scan validates the whole document before `JSON.parse` builds the value, so
17
+ * the value returned is exactly the one `JSON.parse` would produce for a
18
+ * document without duplicates.
19
+ */
20
+ /** Thrown for a document that is not valid JSON or that repeats a member name. */
21
+ export declare class StrictJsonError extends Error {
22
+ constructor(message: string);
23
+ }
24
+ /** Parse `text` as strict JSON (see the module comment). Throws `StrictJsonError`. */
25
+ export declare function strictJsonParse(text: string): unknown;
@@ -0,0 +1,180 @@
1
+ // Copyright © 2025-2026 CERTCRYPT, Inc., its affiliates or licensors. All rights reserved.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ /**
15
+ * Strict JSON parsing: RFC 8259 grammar, and no object may carry the same member
16
+ * name twice, at any depth.
17
+ *
18
+ * `JSON.parse` accepts duplicate member names and keeps the last value. Another
19
+ * parser may keep the first, or reject, so two verifiers reading the same bytes
20
+ * could evaluate different data. A duplicate therefore makes the input
21
+ * non-conformant (CCSP/1 §8.1, and the JSON subject profiles), and this parser
22
+ * fails closed on it.
23
+ *
24
+ * Member names are compared after decoding their escapes, so `"anchor"` and
25
+ * `"anchor"` are the same name. Only object members are compared: repeated
26
+ * elements of an array are ordinary data, and the same name in two different
27
+ * objects is not a duplicate.
28
+ *
29
+ * The scan validates the whole document before `JSON.parse` builds the value, so
30
+ * the value returned is exactly the one `JSON.parse` would produce for a
31
+ * document without duplicates.
32
+ */
33
+ /** Thrown for a document that is not valid JSON or that repeats a member name. */
34
+ export class StrictJsonError extends Error {
35
+ constructor(message) {
36
+ super(message);
37
+ this.name = "StrictJsonError";
38
+ }
39
+ }
40
+ /** Parse `text` as strict JSON (see the module comment). Throws `StrictJsonError`. */
41
+ export function strictJsonParse(text) {
42
+ scanStrict(text);
43
+ return JSON.parse(text);
44
+ }
45
+ /** Maximum nesting depth accepted; deeper input is refused, not truncated. */
46
+ const MAX_DEPTH = 512;
47
+ function scanStrict(text) {
48
+ let i = 0;
49
+ const n = text.length;
50
+ const stack = [];
51
+ const fail = (what) => {
52
+ throw new StrictJsonError(`invalid JSON at offset ${i}: ${what}`);
53
+ };
54
+ const skipWs = () => {
55
+ while (i < n) {
56
+ const c = text.charCodeAt(i);
57
+ if (c === 0x20 || c === 0x09 || c === 0x0a || c === 0x0d)
58
+ i++;
59
+ else
60
+ break;
61
+ }
62
+ };
63
+ // Returns the raw token of a string starting at text[i] === '"'.
64
+ const readString = () => {
65
+ const start = i;
66
+ i++; // opening quote
67
+ while (i < n) {
68
+ const c = text.charCodeAt(i);
69
+ if (c === 0x22) {
70
+ i++;
71
+ return text.slice(start, i);
72
+ }
73
+ if (c === 0x5c) {
74
+ const e = text[i + 1];
75
+ if (e === "u") {
76
+ if (!/^[0-9a-fA-F]{4}$/.test(text.slice(i + 2, i + 6)))
77
+ fail("bad \\u escape");
78
+ i += 6;
79
+ }
80
+ else if (e !== undefined && '"\\/bfnrt'.includes(e)) {
81
+ i += 2;
82
+ }
83
+ else {
84
+ fail("bad escape");
85
+ }
86
+ continue;
87
+ }
88
+ if (c < 0x20)
89
+ fail("control character in string");
90
+ i++;
91
+ }
92
+ return fail("unterminated string");
93
+ };
94
+ const readNumber = () => {
95
+ const m = /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?/.exec(text.slice(i, i + 4096));
96
+ if (!m || m[0].length === 0)
97
+ fail("bad number");
98
+ i += m[0].length;
99
+ };
100
+ const readLiteral = () => {
101
+ for (const lit of ["true", "false", "null"]) {
102
+ if (text.startsWith(lit, i)) {
103
+ i += lit.length;
104
+ return;
105
+ }
106
+ }
107
+ fail("unexpected token");
108
+ };
109
+ // Reads one value. Scalars are consumed; a container pushes a frame and
110
+ // returns, and its members are consumed by the main loop.
111
+ const readValue = () => {
112
+ skipWs();
113
+ if (i >= n)
114
+ fail("unexpected end of input");
115
+ const ch = text[i];
116
+ if (ch === "{" || ch === "[") {
117
+ if (stack.length >= MAX_DEPTH)
118
+ fail(`nesting deeper than ${MAX_DEPTH}`);
119
+ i++;
120
+ stack.push(ch === "{" ? { kind: "object", names: new Set() } : { kind: "array" });
121
+ skipWs();
122
+ if (text[i] === (ch === "{" ? "}" : "]")) {
123
+ i++;
124
+ stack.pop();
125
+ return;
126
+ }
127
+ if (ch === "{")
128
+ readMemberName(stack[stack.length - 1]);
129
+ else
130
+ readValue();
131
+ return;
132
+ }
133
+ if (ch === '"')
134
+ readString();
135
+ else if (ch === "-" || (ch >= "0" && ch <= "9"))
136
+ readNumber();
137
+ else
138
+ readLiteral();
139
+ };
140
+ // Reads `"name" :` and the value that follows.
141
+ const readMemberName = (frame) => {
142
+ skipWs();
143
+ if (text[i] !== '"')
144
+ fail("expected member name");
145
+ const raw = readString();
146
+ const name = JSON.parse(raw);
147
+ if (frame.names.has(name)) {
148
+ throw new StrictJsonError(`duplicate member name ${JSON.stringify(name)}`);
149
+ }
150
+ frame.names.add(name);
151
+ skipWs();
152
+ if (text[i] !== ":")
153
+ fail("expected ':'");
154
+ i++;
155
+ readValue();
156
+ };
157
+ readValue();
158
+ // After each completed value, close or continue the enclosing containers.
159
+ while (stack.length > 0) {
160
+ skipWs();
161
+ const frame = stack[stack.length - 1];
162
+ const close = frame.kind === "object" ? "}" : "]";
163
+ if (text[i] === close) {
164
+ i++;
165
+ stack.pop();
166
+ continue;
167
+ }
168
+ if (text[i] !== ",")
169
+ fail(`expected ',' or '${close}'`);
170
+ i++;
171
+ if (frame.kind === "object")
172
+ readMemberName(frame);
173
+ else
174
+ readValue();
175
+ }
176
+ skipWs();
177
+ if (i !== n)
178
+ fail("trailing content");
179
+ }
180
+ //# sourceMappingURL=strict-json.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strict-json.js","sourceRoot":"","sources":["../../../src/crypto/strict-json.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;;;;;;;;;;;;;;;;;;GAkBG;AAEH,kFAAkF;AAClF,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACxC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AAED,sFAAsF;AACtF,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,UAAU,CAAC,IAAI,CAAC,CAAC;IACjB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,8EAA8E;AAC9E,MAAM,SAAS,GAAG,GAAG,CAAC;AAWtB,SAAS,UAAU,CAAC,IAAY;IAC9B,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;IACtB,MAAM,KAAK,GAAY,EAAE,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,CAAC,CAAC;AACxC,CAAC"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Field-set / value-discipline preconditions for the JSON-object subject
3
+ * profiles, enforced BEFORE canonicalization.
4
+ *
5
+ * Copied byte-for-byte in behavior from
6
+ * `certcrypt-verifier-toolkit-js/core/crypto/subject-json-preconditions.ts` so
7
+ * the issuer-side `canonical_bytes(subject)` for JSON-object profiles matches the
8
+ * verifier's. The toolkit does not export this module, so it is
9
+ * vendored here (same rationale as `jcs.ts`).
10
+ *
11
+ * Each profile spec states that structural conformance is a *precondition of
12
+ * canonicalization*, not a separable later check: `canonical_bytes(subject)` is
13
+ * defined ONLY for an object satisfying the profile in full, and for any
14
+ * other object the profile does not apply and the implementation MUST fail
15
+ * closed (subject.collection/1, subject.ai-decision/1, and the no-number
16
+ * discipline of subject.context-snapshot/1).
17
+ */
18
+ /** Thrown when a JSON-object subject violates its profile precondition. */
19
+ export declare class SubjectPreconditionError extends Error {
20
+ readonly profile: string;
21
+ constructor(profile: string, detail: string);
22
+ }
23
+ /**
24
+ * subject.collection/1: exactly four members — `commitment_scheme`, `root`,
25
+ * `declared_cardinality` and the `leaves[]` array, whose entries each declare their
26
+ * own `profile` and `commitment_digest_hex`. Also checks the commitment-scheme-specific
27
+ * `root` shape, the `declared_cardinality` grammar, and that the cardinality agrees
28
+ * with the number of leaves.
29
+ */
30
+ export declare function assertCollectionPrecondition(value: unknown): void;
31
+ /** subject.ai-decision/1 §7.4: the profiles an input or output may be declared under. */
32
+ export declare const AI_DECISION_IO_PROFILES: readonly string[];
33
+ /**
34
+ * subject.ai-decision/1: exact member set with the required/optional split, flat
35
+ * string-valued nested objects, the all-strings value discipline, and the syntax
36
+ * preconditions of §7.3 (salted part commitments, the input/output `profile`,
37
+ * and `decided_at`).
38
+ */
39
+ export declare function assertAiDecisionPrecondition(value: unknown): void;
40
+ /**
41
+ * subject.context-snapshot/1: the only precondition this profile fixes at
42
+ * the canonicalization boundary is that the value is a JSON object with no JSON
43
+ * number at any depth (booleans and nulls are permitted). It does not fix a member set — the snapshot
44
+ * shape is governed by the higher-layer protocol (CCVP/1), not this profile.
45
+ */
46
+ export declare function assertContextSnapshotPrecondition(value: unknown): void;