@action-state-group/capsule-viewer 0.19.0 → 0.19.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.
@@ -2542,7 +2542,7 @@ var EvidenceGraph = (() => {
2542
2542
  }
2543
2543
  });
2544
2544
 
2545
- // node_modules/@action-state-group/cll/dist/chunk-FSX46CVZ.js
2545
+ // node_modules/@action-state-group/cll/dist/chunk-X2Y6VH3Q.js
2546
2546
  function validateIdentifier(value) {
2547
2547
  const length = new TextEncoder().encode(value).length;
2548
2548
  if (length < 1 || length > limits.identifier || !/^[A-Za-z0-9._:/-]+$/u.test(value))
@@ -2552,8 +2552,8 @@ var EvidenceGraph = (() => {
2552
2552
  );
2553
2553
  }
2554
2554
  var limits, CllError;
2555
- var init_chunk_FSX46CVZ = __esm({
2556
- "node_modules/@action-state-group/cll/dist/chunk-FSX46CVZ.js"() {
2555
+ var init_chunk_X2Y6VH3Q = __esm({
2556
+ "node_modules/@action-state-group/cll/dist/chunk-X2Y6VH3Q.js"() {
2557
2557
  limits = Object.freeze({
2558
2558
  entryBytes: 32,
2559
2559
  witnesses: 32,
@@ -4645,56 +4645,85 @@ var EvidenceGraph = (() => {
4645
4645
  }
4646
4646
  });
4647
4647
 
4648
- // node_modules/@action-state-group/cll/dist/chunk-YQXOEEBD.js
4648
+ // node_modules/@action-state-group/cll/dist/chunk-L6ZLKNEI.js
4649
+ function decodeCheckpointStatement(cose) {
4650
+ if (cose.length < 2 || cose.length > limits.checkpointPayload || cose[0] !== 210)
4651
+ return void 0;
4652
+ const items = decode(cose.subarray(1), {
4653
+ allowIndefinite: false,
4654
+ coerceUndefinedToNull: false,
4655
+ useMaps: true
4656
+ });
4657
+ if (!Array.isArray(items) || items.length !== 4 || !(items[0] instanceof Uint8Array) || !(items[1] instanceof Map) || items[1].size !== 0 || !(items[2] instanceof Uint8Array) || !(items[3] instanceof Uint8Array))
4658
+ return void 0;
4659
+ const headers = decode(items[0], {
4660
+ allowIndefinite: false,
4661
+ useMaps: true
4662
+ });
4663
+ if (!(headers instanceof Map)) return void 0;
4664
+ const kid = headers.get(4);
4665
+ const cwt = headers.get(15);
4666
+ if (headers.size !== 4 || headers.get(1) !== -8 || headers.get(3) !== CHECKPOINT_CONTENT_TYPE || !(kid instanceof Uint8Array) || kid.length !== 32 || !(cwt instanceof Map) || cwt.size !== 2)
4667
+ return void 0;
4668
+ const logId = cwt.get(1);
4669
+ const subject = cwt.get(2);
4670
+ if (typeof logId !== "string" || typeof subject !== "string")
4671
+ return void 0;
4672
+ validateIdentifier(logId);
4673
+ const claims = decode(items[2], {
4674
+ allowIndefinite: false,
4675
+ coerceUndefinedToNull: false,
4676
+ useMaps: true
4677
+ });
4678
+ if (!(claims instanceof Map) || !bytesEqual(encodeCanonical(claims), items[2]))
4679
+ return void 0;
4680
+ const allowedClaims = /* @__PURE__ */ new Set([
4681
+ "kind",
4682
+ "log_size",
4683
+ "commitment",
4684
+ "prev_size",
4685
+ "prev_commitment",
4686
+ "issued_at",
4687
+ "cadence",
4688
+ "consistency_proof"
4689
+ ]);
4690
+ if (claims.size < 6 || claims.size > 8 || [...claims.keys()].some(
4691
+ (key) => typeof key !== "string" || !allowedClaims.has(key)
4692
+ ) || claims.get("kind") !== "cll-checkpoint")
4693
+ return void 0;
4694
+ return {
4695
+ items,
4696
+ kid,
4697
+ logId,
4698
+ subject,
4699
+ claims
4700
+ };
4701
+ }
4702
+ async function checkpointRejectionFieldWith(crypto, cose) {
4703
+ try {
4704
+ const statement = decodeCheckpointStatement(cose);
4705
+ if (statement === void 0) return void 0;
4706
+ const issuedAt = statement.claims.get("issued_at");
4707
+ if (typeof issuedAt === "string" && isRfc3339(issuedAt)) return void 0;
4708
+ const { items, kid } = statement;
4709
+ return await crypto.verifyEd25519(
4710
+ kid,
4711
+ signatureMessage(items),
4712
+ items[3]
4713
+ ) === true ? "issued_at" : void 0;
4714
+ } catch {
4715
+ return void 0;
4716
+ }
4717
+ }
4649
4718
  async function verifyCheckpointWith(crypto, cose) {
4650
4719
  try {
4651
- if (cose.length < 2 || cose.length > limits.checkpointPayload || cose[0] !== 210)
4652
- return false;
4653
- const items = decode(cose.subarray(1), {
4654
- allowIndefinite: false,
4655
- coerceUndefinedToNull: false,
4656
- useMaps: true
4657
- });
4658
- if (!Array.isArray(items) || items.length !== 4 || !(items[0] instanceof Uint8Array) || !(items[1] instanceof Map) || items[1].size !== 0 || !(items[2] instanceof Uint8Array) || !(items[3] instanceof Uint8Array))
4659
- return false;
4660
- const headers = decode(items[0], {
4661
- allowIndefinite: false,
4662
- useMaps: true
4663
- });
4664
- if (!(headers instanceof Map)) return false;
4665
- const kid = headers.get(4);
4666
- const cwt = headers.get(15);
4667
- if (headers.size !== 4 || headers.get(1) !== -8 || headers.get(3) !== CHECKPOINT_CONTENT_TYPE || !(kid instanceof Uint8Array) || kid.length !== 32 || !(cwt instanceof Map) || cwt.size !== 2)
4668
- return false;
4669
- const logId = cwt.get(1);
4670
- const subject = cwt.get(2);
4671
- if (typeof logId !== "string" || typeof subject !== "string") return false;
4672
- validateIdentifier(logId);
4673
- const claims = decode(items[2], {
4674
- allowIndefinite: false,
4675
- coerceUndefinedToNull: false,
4676
- useMaps: true
4677
- });
4678
- if (!(claims instanceof Map) || !bytesEqual(encodeCanonical(claims), items[2]))
4679
- return false;
4680
- const allowedClaims = /* @__PURE__ */ new Set([
4681
- "kind",
4682
- "log_size",
4683
- "commitment",
4684
- "prev_size",
4685
- "prev_commitment",
4686
- "issued_at",
4687
- "cadence",
4688
- "consistency_proof"
4689
- ]);
4690
- if (claims.size < 6 || claims.size > 8 || [...claims.keys()].some(
4691
- (key) => typeof key !== "string" || !allowedClaims.has(key)
4692
- ) || claims.get("kind") !== "cll-checkpoint")
4693
- return false;
4720
+ const statement = decodeCheckpointStatement(cose);
4721
+ if (statement === void 0) return false;
4722
+ const { items, kid, logId, subject, claims } = statement;
4694
4723
  const logSize = claims.get("log_size");
4695
4724
  const previousSize = claims.get("prev_size");
4696
4725
  const issuedAt = claims.get("issued_at");
4697
- if (!Number.isSafeInteger(logSize) || logSize < 1 || !Number.isSafeInteger(previousSize) || previousSize < 0 || previousSize >= logSize || typeof issuedAt !== "string" || formatTime(issuedAt) !== issuedAt || subject !== `${logId}#${logSize}`)
4726
+ if (!Number.isSafeInteger(logSize) || logSize < 1 || !Number.isSafeInteger(previousSize) || previousSize < 0 || previousSize >= logSize || typeof issuedAt !== "string" || !isRfc3339(issuedAt) || subject !== logId && subject !== `${logId}#${logSize}`)
4698
4727
  return false;
4699
4728
  const decodePeaks = (value) => {
4700
4729
  if (!(value instanceof Uint8Array)) return void 0;
@@ -4760,11 +4789,7 @@ var EvidenceGraph = (() => {
4760
4789
  if (!Number.isSafeInteger(cadence) || cadence < 1)
4761
4790
  return false;
4762
4791
  }
4763
- return await crypto.verifyEd25519(
4764
- kid,
4765
- encodeCanonical(["Signature1", items[0], new Uint8Array(), items[2]]),
4766
- items[3]
4767
- ) === true;
4792
+ return await crypto.verifyEd25519(kid, signatureMessage(items), items[3]) === true;
4768
4793
  } catch {
4769
4794
  return false;
4770
4795
  }
@@ -4828,11 +4853,11 @@ var EvidenceGraph = (() => {
4828
4853
  const k = littleEndian(sha512(digest2)) % Point.Fn.ORDER;
4829
4854
  return Point.BASE.multiplyUnsafe(s).equals(rPoint.add(a.multiplyUnsafe(k)));
4830
4855
  }
4831
- var CHECKPOINT_CONTENT_TYPE, encodeCanonical, toHex2, bytesEqual, formatTime, Point, littleEndian;
4832
- var init_chunk_YQXOEEBD = __esm({
4833
- "node_modules/@action-state-group/cll/dist/chunk-YQXOEEBD.js"() {
4856
+ var CHECKPOINT_CONTENT_TYPE, encodeCanonical, toHex2, bytesEqual, formatTime, isRfc3339, signatureMessage, Point, littleEndian;
4857
+ var init_chunk_L6ZLKNEI = __esm({
4858
+ "node_modules/@action-state-group/cll/dist/chunk-L6ZLKNEI.js"() {
4834
4859
  init_chunk_JR35ZH2C();
4835
- init_chunk_FSX46CVZ();
4860
+ init_chunk_X2Y6VH3Q();
4836
4861
  init_cborg();
4837
4862
  init_ed25519();
4838
4863
  init_sha2();
@@ -4858,6 +4883,26 @@ var EvidenceGraph = (() => {
4858
4883
  const trimmed = fraction.replace(/0+$/u, "");
4859
4884
  return `${parsed.toISOString().slice(0, 19)}${trimmed === "" ? "" : `.${trimmed}`}Z`;
4860
4885
  };
4886
+ isRfc3339 = (value) => {
4887
+ const match = /^(\d{4})-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d)(?:\.(\d+))?(Z|[+-]\d\d:\d\d)$/u.exec(
4888
+ value
4889
+ );
4890
+ if (match === null) return false;
4891
+ const [year, month, day, hour, minute, second] = match.slice(1, 7).map(Number);
4892
+ const date = /* @__PURE__ */ new Date(0);
4893
+ date.setUTCFullYear(year, month - 1, day);
4894
+ if (date.getUTCFullYear() !== year || date.getUTCMonth() !== month - 1 || date.getUTCDate() !== day || hour > 23 || minute > 59 || second > 59)
4895
+ return false;
4896
+ try {
4897
+ formatTime(
4898
+ `${value.slice(0, 19)}${match[7] === void 0 ? "" : `.${match[7].slice(0, 9)}`}${match[8]}`
4899
+ );
4900
+ return true;
4901
+ } catch {
4902
+ return false;
4903
+ }
4904
+ };
4905
+ signatureMessage = (items) => encodeCanonical(["Signature1", items[0], new Uint8Array(), items[2]]);
4861
4906
  ({ Point } = ed25519);
4862
4907
  littleEndian = (bytes) => {
4863
4908
  let value = 0n;
@@ -4874,6 +4919,7 @@ var EvidenceGraph = (() => {
4874
4919
  CHECKPOINT_CONTENT_TYPE: () => CHECKPOINT_CONTENT_TYPE,
4875
4920
  MmrTree: () => MmrTree2,
4876
4921
  checkpointMetadata: () => checkpointMetadata,
4922
+ checkpointRejectionField: () => checkpointRejectionField,
4877
4923
  commitmentObject: () => commitmentObject,
4878
4924
  consistencyProof: () => consistencyProof,
4879
4925
  inclusionProof: () => inclusionProof,
@@ -4937,12 +4983,12 @@ var EvidenceGraph = (() => {
4937
4983
  h.forEach((word, i) => outView.setUint32(i * 4, word));
4938
4984
  return out;
4939
4985
  }
4940
- var K2, H02, rotr3, join, hash, MmrTree2, rootFromPeaks2, verifyInclusionValue2, verifyHexInclusion2, verifyConsistency2, verifyRange2, checkpointCrypto, verifyCheckpoint, checkpointMetadata;
4986
+ var K2, H02, rotr3, join, hash, MmrTree2, rootFromPeaks2, verifyInclusionValue2, verifyHexInclusion2, verifyConsistency2, verifyRange2, checkpointCrypto, checkpointRejectionField, verifyCheckpoint, checkpointMetadata;
4941
4987
  var init_browser = __esm({
4942
4988
  "node_modules/@action-state-group/cll/dist/browser.js"() {
4943
- init_chunk_YQXOEEBD();
4989
+ init_chunk_L6ZLKNEI();
4944
4990
  init_chunk_JR35ZH2C();
4945
- init_chunk_FSX46CVZ();
4991
+ init_chunk_X2Y6VH3Q();
4946
4992
  K2 = new Uint32Array([
4947
4993
  1116352408,
4948
4994
  1899447441,
@@ -5049,6 +5095,7 @@ var EvidenceGraph = (() => {
5049
5095
  hash,
5050
5096
  verifyEd25519: async (publicKey, message, signature2) => verifyEd25519(publicKey, message, signature2)
5051
5097
  };
5098
+ checkpointRejectionField = (cose) => checkpointRejectionFieldWith(checkpointCrypto, cose);
5052
5099
  verifyCheckpoint = (cose) => verifyCheckpointWith(checkpointCrypto, cose);
5053
5100
  checkpointMetadata = (cose) => checkpointMetadataWith(checkpointCrypto, cose);
5054
5101
  }
@@ -17689,16 +17736,16 @@ ${s} .check .steps{margin:12px 0 0;padding-left:20px;font-size:14px;line-height:
17689
17736
  }
17690
17737
  function builtCommit() {
17691
17738
  if (false) return void 0;
17692
- return commitPrefix("d2469c3f76ce0f01190ccde5328be1580f0005c3");
17739
+ return commitPrefix("25886484a7054bf7ec926c60917c5f995c90361e");
17693
17740
  }
17694
17741
  var commit = builtCommit();
17695
17742
  var unreleased = false;
17696
17743
  var VIEWER_BUILD = {
17697
17744
  viewer: "@action-state-group/capsule-viewer",
17698
- viewerVersion: "0.19.0",
17745
+ viewerVersion: "0.19.1",
17699
17746
  verifier: "@action-state-group/agent-action-capsule",
17700
17747
  verifierVersion: "0.14.0",
17701
- cllVersion: "0.3.0",
17748
+ cllVersion: "0.4.0",
17702
17749
  ...commit === void 0 ? {} : { commit },
17703
17750
  ...unreleased ? { unreleased: true } : {}
17704
17751
  };
@@ -19,10 +19,10 @@ const unreleased = typeof __CAPSULE_VIEWER_UNRELEASED__ === "boolean" &&
19
19
  __CAPSULE_VIEWER_UNRELEASED__;
20
20
  export const VIEWER_BUILD = {
21
21
  viewer: "@action-state-group/capsule-viewer",
22
- viewerVersion: "0.19.0",
22
+ viewerVersion: "0.19.1",
23
23
  verifier: "@action-state-group/agent-action-capsule",
24
24
  verifierVersion: "0.14.0",
25
- cllVersion: "0.3.0",
25
+ cllVersion: "0.4.0",
26
26
  ...(commit === undefined ? {} : { commit }),
27
27
  ...(unreleased ? { unreleased: true } : {}),
28
28
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@action-state-group/capsule-viewer",
3
- "version": "0.19.0",
3
+ "version": "0.19.1",
4
4
  "description": "capsule-viewer page emitter and presentation builder, under the Agent Action Capsule presentation contract",
5
5
  "license": "Apache-2.0 AND BSD-3-Clause",
6
6
  "type": "module",
@@ -35,9 +35,14 @@
35
35
  "check:package": "node scripts/check-package.mjs",
36
36
  "emitter:iife": "node scripts/build-iife.mjs"
37
37
  },
38
+ "overrides": {
39
+ "@action-state-group/agent-action-capsule": {
40
+ "@action-state-group/cll": "$@action-state-group/cll"
41
+ }
42
+ },
38
43
  "dependencies": {
39
44
  "@action-state-group/agent-action-capsule": "0.14.0",
40
- "@action-state-group/cll": "0.3.0"
45
+ "@action-state-group/cll": "0.4.0"
41
46
  },
42
47
  "devDependencies": {
43
48
  "@types/jsdom": "30.0.0",