@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,381 @@
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
+ * Field-set / value-discipline preconditions for the JSON-object subject
16
+ * profiles, enforced BEFORE canonicalization.
17
+ *
18
+ * Copied byte-for-byte in behavior from
19
+ * `certcrypt-verifier-toolkit-js/core/crypto/subject-json-preconditions.ts` so
20
+ * the issuer-side `canonical_bytes(subject)` for JSON-object profiles matches the
21
+ * verifier's. The toolkit does not export this module, so it is
22
+ * vendored here (same rationale as `jcs.ts`).
23
+ *
24
+ * Each profile spec states that structural conformance is a *precondition of
25
+ * canonicalization*, not a separable later check: `canonical_bytes(subject)` is
26
+ * defined ONLY for an object satisfying the profile in full, and for any
27
+ * other object the profile does not apply and the implementation MUST fail
28
+ * closed (subject.collection/1, subject.ai-decision/1, and the no-number
29
+ * discipline of subject.context-snapshot/1).
30
+ */
31
+ /** Thrown when a JSON-object subject violates its profile precondition. */
32
+ export class SubjectPreconditionError extends Error {
33
+ profile;
34
+ constructor(profile, detail) {
35
+ super(`subject precondition failed for ${profile}: ${detail}`);
36
+ this.name = "SubjectPreconditionError";
37
+ this.profile = profile;
38
+ }
39
+ }
40
+ function isPlainObject(v) {
41
+ return typeof v === "object" && v !== null && !Array.isArray(v);
42
+ }
43
+ /**
44
+ * Recursively assert the string-only value discipline of the two JSON-object
45
+ * profiles with closed, string-valued member sets (subject.collection/1 and
46
+ * subject.ai-decision/1): every value at any depth (object members, array
47
+ * elements) MUST be a JSON string, object, or array. A JSON number, boolean, or
48
+ * null token anywhere is non-conformant. This is what keeps RFC 8785 free of
49
+ * number serialization. subject.context-snapshot/1 uses the narrower
50
+ * `assertNoJsonNumber` below.
51
+ */
52
+ function assertStringOnly(profile, value, path) {
53
+ if (typeof value === "string")
54
+ return;
55
+ if (Array.isArray(value)) {
56
+ value.forEach((el, i) => assertStringOnly(profile, el, `${path}[${i}]`));
57
+ return;
58
+ }
59
+ if (isPlainObject(value)) {
60
+ for (const k of Object.keys(value)) {
61
+ assertStringOnly(profile, value[k], path ? `${path}.${k}` : k);
62
+ }
63
+ return;
64
+ }
65
+ // number, boolean, null, or undefined — all forbidden.
66
+ const kind = value === null ? "null" : typeof value;
67
+ throw new SubjectPreconditionError(profile, `value at ${path || "(root)"} is a JSON ${kind}; every value must be a string, object, or array (no numbers/booleans/nulls)`);
68
+ }
69
+ const CARDINALITY_MAX = 18446744073709551615n; // 2^64 − 1
70
+ /**
71
+ * subject.collection/1: exactly four members — `commitment_scheme`, `root`,
72
+ * `declared_cardinality` and the `leaves[]` array, whose entries each declare their
73
+ * own `profile` and `commitment_digest_hex`. Also checks the commitment-scheme-specific
74
+ * `root` shape, the `declared_cardinality` grammar, and that the cardinality agrees
75
+ * with the number of leaves.
76
+ */
77
+ export function assertCollectionPrecondition(value) {
78
+ const P = "subject.collection/1";
79
+ if (!isPlainObject(value)) {
80
+ throw new SubjectPreconditionError(P, "subject is not a JSON object");
81
+ }
82
+ const REQUIRED = ["commitment_scheme", "root", "declared_cardinality", "leaves"];
83
+ const STRING_MEMBERS = ["commitment_scheme", "root", "declared_cardinality"];
84
+ const keys = Object.keys(value);
85
+ for (const k of REQUIRED) {
86
+ if (!(k in value))
87
+ throw new SubjectPreconditionError(P, `missing member "${k}"`);
88
+ }
89
+ for (const k of keys) {
90
+ if (!REQUIRED.includes(k)) {
91
+ throw new SubjectPreconditionError(P, `unexpected member "${k}" (exactly four members allowed)`);
92
+ }
93
+ if (STRING_MEMBERS.includes(k) && typeof value[k] !== "string") {
94
+ throw new SubjectPreconditionError(P, `member "${k}" must be a string`);
95
+ }
96
+ }
97
+ // `leaves` is the one non-string member: an ordered array where each entry declares
98
+ // its own profile and commitment (`subject.collection/1` §7.4). Its position IS the
99
+ // leaf index, so the array is load-bearing.
100
+ const leaves = value.leaves;
101
+ if (!Array.isArray(leaves) || leaves.length === 0) {
102
+ throw new SubjectPreconditionError(P, `"leaves" must be a non-empty array`);
103
+ }
104
+ for (let i = 0; i < leaves.length; i++) {
105
+ const leaf = leaves[i];
106
+ if (typeof leaf !== "object" || leaf === null || Array.isArray(leaf)) {
107
+ throw new SubjectPreconditionError(P, `"leaves[${i}]" must be an object`);
108
+ }
109
+ const lk = Object.keys(leaf);
110
+ if (lk.length !== 2 || !("profile" in leaf) || !("commitment_digest_hex" in leaf)) {
111
+ throw new SubjectPreconditionError(P, `"leaves[${i}]" must contain exactly "profile" and "commitment_digest_hex"`);
112
+ }
113
+ for (const k of lk) {
114
+ if (typeof leaf[k] !== "string") {
115
+ throw new SubjectPreconditionError(P, `"leaves[${i}].${k}" must be a string`);
116
+ }
117
+ }
118
+ if (!/^[0-9a-f]{64}$/.test(leaf.commitment_digest_hex)) {
119
+ throw new SubjectPreconditionError(P, `"leaves[${i}].commitment_digest_hex" must be 64 lowercase hex characters`);
120
+ }
121
+ }
122
+ // declared_cardinality: canonical unsigned base-10, no sign, no leading
123
+ // zeros, > 0, ≤ 2^64 − 1.
124
+ const dc = value.declared_cardinality;
125
+ if (!/^[1-9][0-9]*$/.test(dc)) {
126
+ throw new SubjectPreconditionError(P, `"declared_cardinality" must be a canonical unsigned base-10 integer with no sign and no leading zeros`);
127
+ }
128
+ if (BigInt(dc) > CARDINALITY_MAX) {
129
+ throw new SubjectPreconditionError(P, `"declared_cardinality" exceeds 2^64 − 1`);
130
+ }
131
+ // §7.4.3: the economic layer bills on declared_cardinality, so it MUST agree with
132
+ // the array rather than be derived from it.
133
+ if (String(leaves.length) !== dc) {
134
+ throw new SubjectPreconditionError(P, `"declared_cardinality" (${dc}) does not equal the number of leaves (${leaves.length})`);
135
+ }
136
+ // For the sha3-256 merkle scheme, root is 64 lowercase hex chars.
137
+ if (value.commitment_scheme === "collection.merkle-sha3-256/1") {
138
+ if (!/^[0-9a-f]{64}$/.test(value.root)) {
139
+ throw new SubjectPreconditionError(P, `"root" must be a 64-character lowercase hex string under collection.merkle-sha3-256/1`);
140
+ }
141
+ }
142
+ assertStringOnly(P, value, "");
143
+ }
144
+ /** subject.ai-decision/1 §7.4: the profiles an input or output may be declared under. */
145
+ export const AI_DECISION_IO_PROFILES = [
146
+ "subject.text/1",
147
+ "subject.binary/1",
148
+ "subject.email/1",
149
+ "subject.ai-decision/1",
150
+ ];
151
+ const HEX64 = /^[0-9a-f]{64}$/;
152
+ const AI_PART_ID = /^[a-z][a-z0-9._-]{0,63}$/;
153
+ const MEDIA_TYPE = /^[a-z0-9][a-z0-9!#$&^_.+-]{0,126}\/[a-z0-9][a-z0-9!#$&^_.+-]{0,126}$/;
154
+ const AI_MAX_PARTS = 256;
155
+ const AI_MAX_MAP_MEMBERS = 128;
156
+ /** subject.ai-decision/1 §7.3 canonical UTC millisecond timestamp syntax. */
157
+ const DECISION_TIME = /^([0-9]{4})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])\.([0-9]{3})Z$/;
158
+ function canonicalDecisionTime(profile, value, member) {
159
+ if (typeof value !== "string") {
160
+ throw new SubjectPreconditionError(profile, `member "${member}" must be a string`);
161
+ }
162
+ const m = DECISION_TIME.exec(value);
163
+ if (!m) {
164
+ throw new SubjectPreconditionError(profile, `"${member}" must be UTC with milliseconds (YYYY-MM-DDTHH:MM:SS.sssZ)`);
165
+ }
166
+ const [year, month, day, hour, minute, second, millisecond] = m.slice(1).map(Number);
167
+ if (year === 0) {
168
+ throw new SubjectPreconditionError(profile, `"${member}" is not a real Gregorian date`);
169
+ }
170
+ const leap = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
171
+ const monthDays = [31, leap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
172
+ if (day > monthDays[month - 1]) {
173
+ throw new SubjectPreconditionError(profile, `"${member}" is not a real Gregorian date`);
174
+ }
175
+ void hour;
176
+ void minute;
177
+ void second;
178
+ void millisecond;
179
+ return value;
180
+ }
181
+ /**
182
+ * subject.ai-decision/1: exact member set with the required/optional split, flat
183
+ * string-valued nested objects, the all-strings value discipline, and the syntax
184
+ * preconditions of §7.3 (salted part commitments, the input/output `profile`,
185
+ * and `decided_at`).
186
+ */
187
+ export function assertAiDecisionPrecondition(value) {
188
+ const P = "subject.ai-decision/1";
189
+ if (!isPlainObject(value)) {
190
+ throw new SubjectPreconditionError(P, "record is not a JSON object");
191
+ }
192
+ // String-only first: it is the discipline that keeps JCS number-free and it
193
+ // subsumes "no boolean/null" for every member below.
194
+ assertStringOnly(P, value, "");
195
+ const REQUIRED = [
196
+ "profile",
197
+ "decision_id",
198
+ "decided_at",
199
+ "model",
200
+ "observation_scope",
201
+ "input",
202
+ "output",
203
+ "decision",
204
+ ];
205
+ const OPTIONAL = ["parameters", "context", "started_at", "actor_id", "policy_ref"];
206
+ const allowed = new Set([...REQUIRED, ...OPTIONAL]);
207
+ for (const k of REQUIRED) {
208
+ if (!(k in value))
209
+ throw new SubjectPreconditionError(P, `missing required member "${k}"`);
210
+ }
211
+ for (const k of Object.keys(value)) {
212
+ if (!allowed.has(k)) {
213
+ throw new SubjectPreconditionError(P, `unexpected member "${k}"`);
214
+ }
215
+ }
216
+ if (value.profile !== P) {
217
+ throw new SubjectPreconditionError(P, `"profile" must equal "${P}"`);
218
+ }
219
+ for (const k of ["profile", "decision_id", "decision", "observation_scope"]) {
220
+ if (typeof value[k] !== "string") {
221
+ throw new SubjectPreconditionError(P, `member "${k}" must be a string`);
222
+ }
223
+ }
224
+ if (!AI_PART_ID.test(value.decision_id)) {
225
+ throw new SubjectPreconditionError(P, `"decision_id" is not a canonical identifier`);
226
+ }
227
+ if (value.decision.length === 0) {
228
+ throw new SubjectPreconditionError(P, `"decision" must not be empty`);
229
+ }
230
+ if (value.observation_scope !== "client" && value.observation_scope !== "runtime") {
231
+ throw new SubjectPreconditionError(P, `"observation_scope" must be "client" or "runtime"`);
232
+ }
233
+ const decidedAt = canonicalDecisionTime(P, value.decided_at, "decided_at");
234
+ if ("started_at" in value) {
235
+ const startedAt = canonicalDecisionTime(P, value.started_at, "started_at");
236
+ if (startedAt > decidedAt) {
237
+ throw new SubjectPreconditionError(P, `"started_at" must not be after "decided_at"`);
238
+ }
239
+ }
240
+ // model: object with string id + provider, optional string version, no other members.
241
+ assertNestedStringObject(P, value.model, "model", ["id", "provider"], ["version"]);
242
+ const model = value.model;
243
+ for (const member of ["id", "provider", ...(Object.hasOwn(model, "version") ? ["version"] : [])]) {
244
+ if (model[member].length === 0) {
245
+ throw new SubjectPreconditionError(P, `"model.${member}" must not be empty`);
246
+ }
247
+ }
248
+ const seenIds = new Set();
249
+ const seenNonces = new Set();
250
+ let partCount = 0;
251
+ for (const side of ["input", "output"]) {
252
+ const parts = value[side];
253
+ if (!Array.isArray(parts) || parts.length === 0) {
254
+ throw new SubjectPreconditionError(P, `"${side}" must be a non-empty array`);
255
+ }
256
+ partCount += parts.length;
257
+ for (let i = 0; i < parts.length; i++) {
258
+ const name = `${side}[${i}]`;
259
+ assertNestedStringObject(P, parts[i], name, ["id", "role", "media_type", "profile", "material_nonce_hex", "commitment_digest_hex"], []);
260
+ const part = parts[i];
261
+ if (!AI_PART_ID.test(part.id)) {
262
+ throw new SubjectPreconditionError(P, `"${name}.id" is not a canonical part identifier`);
263
+ }
264
+ if (seenIds.has(part.id)) {
265
+ throw new SubjectPreconditionError(P, `material id ${JSON.stringify(part.id)} is duplicated`);
266
+ }
267
+ seenIds.add(part.id);
268
+ if (part.role.length === 0) {
269
+ throw new SubjectPreconditionError(P, `"${name}.role" must not be empty`);
270
+ }
271
+ if (!MEDIA_TYPE.test(part.media_type)) {
272
+ throw new SubjectPreconditionError(P, `"${name}.media_type" must be a lowercase MIME essence without parameters`);
273
+ }
274
+ if (!AI_DECISION_IO_PROFILES.includes(part.profile)) {
275
+ throw new SubjectPreconditionError(P, `"${name}.profile" is not an admitted material profile`);
276
+ }
277
+ if (!HEX64.test(part.material_nonce_hex)) {
278
+ throw new SubjectPreconditionError(P, `"${name}.material_nonce_hex" must be 64 lowercase hex characters`);
279
+ }
280
+ if (seenNonces.has(part.material_nonce_hex)) {
281
+ throw new SubjectPreconditionError(P, `material nonce ${JSON.stringify(part.material_nonce_hex)} is duplicated`);
282
+ }
283
+ seenNonces.add(part.material_nonce_hex);
284
+ if (!HEX64.test(part.commitment_digest_hex)) {
285
+ throw new SubjectPreconditionError(P, `"${name}.commitment_digest_hex" must be 64 lowercase hex characters`);
286
+ }
287
+ }
288
+ }
289
+ if (partCount > AI_MAX_PARTS) {
290
+ throw new SubjectPreconditionError(P, `input and output together may contain at most ${AI_MAX_PARTS} parts`);
291
+ }
292
+ for (const mapName of ["parameters", "context"]) {
293
+ if (mapName in value)
294
+ assertFlatStringMap(P, value[mapName], mapName);
295
+ }
296
+ for (const k of ["actor_id", "policy_ref"]) {
297
+ if (k in value && typeof value[k] !== "string") {
298
+ throw new SubjectPreconditionError(P, `optional member "${k}" must be a string`);
299
+ }
300
+ }
301
+ }
302
+ function assertFlatStringMap(profile, value, name) {
303
+ if (!isPlainObject(value)) {
304
+ throw new SubjectPreconditionError(profile, `"${name}" must be an object when present`);
305
+ }
306
+ const entries = Object.entries(value);
307
+ if (entries.length > AI_MAX_MAP_MEMBERS) {
308
+ throw new SubjectPreconditionError(profile, `"${name}" may contain at most ${AI_MAX_MAP_MEMBERS} members`);
309
+ }
310
+ for (const [k, v] of entries) {
311
+ if (typeof v !== "string") {
312
+ throw new SubjectPreconditionError(profile, `"${name}.${k}" must be a string`);
313
+ }
314
+ }
315
+ }
316
+ function assertNestedStringObject(profile, obj, name, required, optional) {
317
+ if (!isPlainObject(obj)) {
318
+ throw new SubjectPreconditionError(profile, `member "${name}" must be an object`);
319
+ }
320
+ const allowed = new Set([...required, ...optional]);
321
+ for (const k of required) {
322
+ if (!(k in obj))
323
+ throw new SubjectPreconditionError(profile, `"${name}" missing member "${k}"`);
324
+ }
325
+ for (const k of Object.keys(obj)) {
326
+ if (!allowed.has(k)) {
327
+ throw new SubjectPreconditionError(profile, `"${name}" has unexpected member "${k}"`);
328
+ }
329
+ if (typeof obj[k] !== "string") {
330
+ throw new SubjectPreconditionError(profile, `"${name}.${k}" must be a string`);
331
+ }
332
+ }
333
+ }
334
+ /**
335
+ * subject.context-snapshot/1: the only precondition this profile fixes at
336
+ * the canonicalization boundary is that the value is a JSON object with no JSON
337
+ * number at any depth (booleans and nulls are permitted). It does not fix a member set — the snapshot
338
+ * shape is governed by the higher-layer protocol (CCVP/1), not this profile.
339
+ */
340
+ export function assertContextSnapshotPrecondition(value) {
341
+ const P = "subject.context-snapshot/1";
342
+ if (!isPlainObject(value)) {
343
+ throw new SubjectPreconditionError(P, "snapshot is not a JSON object");
344
+ }
345
+ assertNoJsonNumber(P, value, "");
346
+ }
347
+ /**
348
+ * `subject.context-snapshot/1` §7.1: no JSON NUMBER at any depth. Booleans and
349
+ * nulls are permitted.
350
+ *
351
+ * Narrower than `assertStringOnly` on purpose, and the difference is normative.
352
+ * That function serves `subject.collection/1` and `subject.ai-decision/1`, whose
353
+ * member sets are closed and entirely string-valued. This profile fixes no member
354
+ * set — the snapshot shape belongs to CCVP/1 — and §7 requires preserving "the
355
+ * exact string, boolean, array, object, and null semantics of the input", while
356
+ * §8 forbids coercing "booleans or nulls into strings". CCVP/1 §7.1 relies on
357
+ * this: its normative entry example carries `valid_to: null` for an open-ended
358
+ * eligibility window, and `revoked_at: null` for one never revoked.
359
+ *
360
+ * Rejecting nulls here would make the governing protocol's own example
361
+ * non-conformant, and would force an open window to be spelled as a string —
362
+ * exactly the coercion §8 prohibits. Only numbers are excluded, because number
363
+ * serialization is the one RFC 8785 divergence vector across languages.
364
+ */
365
+ function assertNoJsonNumber(profile, value, path) {
366
+ if (typeof value === "number") {
367
+ throw new SubjectPreconditionError(profile, `value at ${path || "(root)"} is a JSON number; every numeric-looking value ` +
368
+ `must be carried as a JSON string so RFC 8785 canonicalization converges ` +
369
+ `across languages`);
370
+ }
371
+ if (Array.isArray(value)) {
372
+ value.forEach((el, i) => assertNoJsonNumber(profile, el, `${path}[${i}]`));
373
+ return;
374
+ }
375
+ if (isPlainObject(value)) {
376
+ for (const k of Object.keys(value)) {
377
+ assertNoJsonNumber(profile, value[k], path ? `${path}.${k}` : k);
378
+ }
379
+ }
380
+ }
381
+ //# sourceMappingURL=subject-json-preconditions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subject-json-preconditions.js","sourceRoot":"","sources":["../../../src/crypto/subject-json-preconditions.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;;;;;;;;;;;;;;;;GAgBG;AAEH,2EAA2E;AAC3E,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IACxC,OAAO,CAAS;IACzB,YAAY,OAAe,EAAE,MAAc;QACzC,KAAK,CAAC,mCAAmC,OAAO,KAAK,MAAM,EAAE,CAAC,CAAC;QAC/D,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;QACvC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF;AAED,SAAS,aAAa,CAAC,CAAU;IAC/B,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAClE,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,gBAAgB,CAAC,OAAe,EAAE,K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,KAAc;IAC9D,MAAM,CAAC,GAAG,4BAA4B,CAAC;IACvC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,wBAAwB,CAAC,CAAC,EAAE,+BAA+B,CAAC,CAAC;IACzE,CAAC;IACD,kBAAkB,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;AACnC,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAS,kBAAkB,CAAC,OAAe,EAAE,KAAc,EAAE,IAAY;IACvE,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,MAAM,IAAI,wBAAwB,CAChC,OAAO,EACP,YAAY,IAAI,IAAI,QAAQ,iDAAiD;YAC3E,0EAA0E;YAC1E,kBAAkB,CACrB,CAAC;IACJ,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,kBAAkB,CAAC,OAAO,EAAE,EAAE,EAAE,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QAC3E,OAAO;IACT,CAAC;IACD,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACnC,kBAAkB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,18 @@
1
+ export { CertcryptNodeClient, CertcryptNodeError, type NodeClientOptions, type WaitOptions, type WaitProgress, type VerificationPackage, type BuildPackageOptions, type DeadLetter, type RetryOptions, type ActivationResult, } from "./client.js";
2
+ export { decideRetry, parseRetryAfter, RETRY_DEFAULTS, RETRY_AFTER_MIN_MS, RETRY_AFTER_MAX_MS, type RetryPolicy, type RetryDecision, type TransportOutcome, } from "./retry.js";
3
+ export { buildCommitmentInclusionProof, commitmentLeafHash, commitmentSubtreeRoot, COMMITMENT_LEAF_VERSION, type CommitmentInclusionProof, } from "./artifacts/commitment-inclusion.js";
4
+ export type { LooseCommitment, IssueRequest, IssueResponse, OperationRecord, OperationState, MemberResult, SettlementWindowEstimate, SettlementProgress, UnresolvedEmission, UnresolvedEmissions, } from "./types.js";
5
+ export { toRfc3339Seconds } from "./artifacts/rfc3339.js";
6
+ export { buildAiDecisionPart, buildAiDecisionSubject, type AiDecisionMaterialInput, type AiDecisionPartDescriptor, type BuiltAiDecisionPart, type AiDecisionModel, type BuildAiDecisionSubjectInput, type AiDecisionRecord, type AiDecisionMaterialRecord, type BuiltAiDecisionSubject, } from "./crypto/ai-decision.js";
7
+ export { assembleEvidence, evidenceDigestHex, projectedCommitmentSigningBytes, ZERO_DATA_PROFILE, type CapacityEvidence, type EvidenceInputs, type StableIdentifiers, type SignedLevel1Binding, type CompositeSignatureWire, type ComponentSignature, type Level1AuthorizationBinding, type ProjectedCommitment, type ProjectedAuthorization, type OperativeContext, MAX_SUBMISSION_SET_MEMBERS, SubmissionSetTooLargeError, assertSubmissionSetWithinBound, } from "./artifacts/capacity-evidence.js";
8
+ export { assembleBaseCertificate, assembleUnsignedPayload, computeSubjectCommitment, computeAnchorCommitment, subjectLocalDigestHex, payloadCanonDigestHex, generateNonceHex, generateIssuerKey, deriveIssuerKey, computeExpiresAt, resolveCollectionSubjects, assembleContextSnapshotCertificate, issuerKeyFingerprintHex, type ConsistencyContext, type AssembleContextSnapshotInput, type ResolvedCollection, type SubjectInput, type IssuanceTarget, type SubjectCommitment, type CertificateAnchor, type CertificatePayload, type CertificateSignature, type BaseCertificate, type MintedCertificate, type IssuerKey, type AssemblePayloadInput, type AssembleBaseCertificateInput, } from "./artifacts/base-certificate.js";
9
+ export { canonicalBytesForSubject, UnsupportedProfileError, SUBJECT_BINARY, SUBJECT_TEXT, SUBJECT_EMAIL, SUBJECT_COLLECTION, SUBJECT_AI_DECISION, SUBJECT_CONTEXT_SNAPSHOT, SUPPORTED_SUBJECT_PROFILES, } from "./crypto/canonical-subject.js";
10
+ export { SubjectPreconditionError } from "./crypto/subject-json-preconditions.js";
11
+ export { collectionLeafHash, collectionNodeHash, collectionMerkleRoot, collectionInclusionProof, buildCollection, COLLECTION_MERKLE_SCHEME, type CollectionLeafInput, type BuiltCollection, } from "./crypto/collection-merkle.js";
12
+ export { digestBytes, digestHexBytes, digestHexText } from "./crypto/digest.js";
13
+ export { jcsCanonicalizeBytes, jcsCanonicalizeString } from "./crypto/jcs.js";
14
+ export { compositeSignP256, compositeMPrime, PROFILE_P256_MLDSA65, } from "./crypto/composite.js";
15
+ export { HolderKeySet, type OperationKey, type OperationKeyDisclosure, } from "./artifacts/holder-keyset.js";
16
+ export { Certcrypt, InMemoryLeafStore, emissionHandleFromRecovery, } from "./issuer.js";
17
+ export type { CertcryptOptions, IssueInput, IssueResult, PreparedCommitment, SubmitResult, IssuerMode, SettlementPreferences, LeafStore, BindingStore, BindingStoreEntry, EmissionHandle, EmissionResolution, RecoveredHandleFragment, } from "./issuer.js";
18
+ export { SUPPORTED_RULES_VERSIONS, registerRulesDomain } from "./issuer.js";
@@ -0,0 +1,80 @@
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
+ // CERTCRYPT SDK for JavaScript — public surface.
15
+ //
16
+ // What is deliberately NOT exported: single signature components (an ML-DSA-65
17
+ // or a P-256 signer, keygen or verifier on its own). A composite is valid only
18
+ // as the AND of both, so exposing one half would hand out a way to produce
19
+ // something that looks like a signature and carries no post-quantum half.
20
+ export { CertcryptNodeClient, CertcryptNodeError, } from "./client.js";
21
+ // The transport-retry policy in `retry.ts`, exported
22
+ // so an integrator wrapping its own transport can apply the same decisions.
23
+ export { decideRetry, parseRetryAfter, RETRY_DEFAULTS, RETRY_AFTER_MIN_MS, RETRY_AFTER_MAX_MS, } from "./retry.js";
24
+ export { buildCommitmentInclusionProof, commitmentLeafHash, commitmentSubtreeRoot, COMMITMENT_LEAF_VERSION, } from "./artifacts/commitment-inclusion.js";
25
+ // RFC 3339 second-precision timestamp normalization (shared by the zero-data
26
+ // evidence path).
27
+ export { toRfc3339Seconds } from "./artifacts/rfc3339.js";
28
+ export { buildAiDecisionPart, buildAiDecisionSubject, } from "./crypto/ai-decision.js";
29
+ // The SDK exposes the EVIDENCE producer (what only the holder can do — sign a
30
+ // projected commitment). It exposes no submission-set builder: the node is the
31
+ // builder.
32
+ export { assembleEvidence, evidenceDigestHex, projectedCommitmentSigningBytes, ZERO_DATA_PROFILE, MAX_SUBMISSION_SET_MEMBERS, SubmissionSetTooLargeError, assertSubmissionSetWithinBound, } from "./artifacts/capacity-evidence.js";
33
+ // Verifiable-subject issuance (CCSP/1 Issued plane): the issuer builds and SIGNS
34
+ // the base_certificate with its own composite issuer key, client-side — no
35
+ // custody. Its subject anchor (CCCP/1) lets a third party verify the
36
+ // certificate against the original material offline with the verifier toolkit.
37
+ export { assembleBaseCertificate, assembleUnsignedPayload, computeSubjectCommitment, computeAnchorCommitment, subjectLocalDigestHex, payloadCanonDigestHex, generateNonceHex, generateIssuerKey,
38
+ // The issuer's composite signing key from its seed alone; the id is a label
39
+ // (conformance family `issuer-key-derivation`).
40
+ deriveIssuerKey,
41
+ // expires_at = issued_at + the rules domain's commitment TTL.
42
+ computeExpiresAt,
43
+ // Collection subjects declared by leaves, resolved under the anchor nonce.
44
+ resolveCollectionSubjects,
45
+ // CCVP/1: a context snapshot certificate, and the composite key fingerprint
46
+ // its entries and a certificate's declared context name.
47
+ assembleContextSnapshotCertificate, issuerKeyFingerprintHex, } from "./artifacts/base-certificate.js";
48
+ export { canonicalBytesForSubject, UnsupportedProfileError, SUBJECT_BINARY, SUBJECT_TEXT, SUBJECT_EMAIL, SUBJECT_COLLECTION, SUBJECT_AI_DECISION, SUBJECT_CONTEXT_SNAPSHOT, SUPPORTED_SUBJECT_PROFILES, } from "./crypto/canonical-subject.js";
49
+ // The precondition failure the JSON-object profiles raise. Exported alongside the
50
+ // other typed errors so an integrator can distinguish "my subject is malformed"
51
+ // (fix the input) from a transport or node failure (retry) — catching it by
52
+ // message text would be the only alternative.
53
+ export { SubjectPreconditionError } from "./crypto/subject-json-preconditions.js";
54
+ // `subject.collection/1` Merkle primitives. Exported because building an
55
+ // ELEMENT-LEVEL inclusion proof is an ISSUER-side job — only whoever holds the
56
+ // certificate has the collection's leaf digests — and folding the path by hand is
57
+ // the one place an integrator reliably gets it wrong: a lone right-edge node on an
58
+ // odd level is promoted unchanged and contributes NO sibling. `collectionInclusionProof`
59
+ // already implements that (and the conformance vectors cover odd cardinalities), so
60
+ // an issuer never has to reimplement it, nor pull in the verifier toolkit to emit.
61
+ export { collectionLeafHash, collectionNodeHash, collectionMerkleRoot, collectionInclusionProof, buildCollection, COLLECTION_MERKLE_SCHEME, } from "./crypto/collection-merkle.js";
62
+ // SHA3-256 and RFC 8785 (JCS): the two byte primitives every digest in the
63
+ // protocol is built from, exported so an integrator recomputes a digest with the
64
+ // exact bytes this SDK signs rather than an approximation.
65
+ export { digestBytes, digestHexBytes, digestHexText } from "./crypto/digest.js";
66
+ export { jcsCanonicalizeBytes, jcsCanonicalizeString } from "./crypto/jcs.js";
67
+ export { compositeSignP256, compositeMPrime, PROFILE_P256_MLDSA65, } from "./crypto/composite.js";
68
+ // The holder's operation-key tree. A first-party issuer builds one (e.g. from a
69
+ // custodied seed), commits its root in the Level-1 authorization, and signs each
70
+ // zero-data commitment with a distinct, never-reused leaf.
71
+ export { HolderKeySet, } from "./artifacts/holder-keyset.js";
72
+ export { Certcrypt, InMemoryLeafStore,
73
+ // Rebuilds a handle from a recovered fragment + the issuer-held certificate.
74
+ // Refuses a fragment whose emission has not settled rather than inventing a
75
+ // Merkle position.
76
+ emissionHandleFromRecovery, } from "./issuer.js";
77
+ // The rules domains this SDK implements. Emitting under any other is refused
78
+ // at construction — see rules-domain/1 §14.2.
79
+ export { SUPPORTED_RULES_VERSIONS, registerRulesDomain } from "./issuer.js";
80
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.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,iDAAiD;AACjD,EAAE;AACF,+EAA+E;AAC/E,+EAA+E;AAC/E,2EAA2E;AAC3E,0EAA0E;AAE1E,OAAO,EACL,mBAAmB,EACnB,kBAAkB,GAYnB,MAAM,aAAa,CAAC;AACrB,qDAAqD;AACrD,4EAA4E;AAC5E,OAAO,EACL,WAAW,EACX,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,kBAAkB,GAInB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,6BAA6B,EAC7B,kBAAkB,EAClB,qBAAqB,EACrB,uBAAuB,GAExB,MAAM,qCAAqC,CAAC;AAwB7C,6EAA6E;AAC7E,kBAAkB;AAClB,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EACL,mBAAmB,EACnB,sBAAsB,GASvB,MAAM,yBAAyB,C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