@xyo-network/event-kit-node 1.0.0 → 2.1.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.
@@ -1 +1 @@
1
- {"version":3,"file":"filesystemCursorStore.d.ts","sourceRoot":"","sources":["../../src/filesystemCursorStore.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAA;AAExE,MAAM,WAAW,4BAA4B;IAC3C,yDAAyD;IACzD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACtB;AAMD;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,4BAA4B,GACpC,oBAAoB,CAsBtB"}
1
+ {"version":3,"file":"filesystemCursorStore.d.ts","sourceRoot":"","sources":["../../src/filesystemCursorStore.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAA;AAExE,MAAM,WAAW,4BAA4B;IAC3C,yDAAyD;IACzD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACtB;AAMD;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,4BAA4B,GACpC,oBAAoB,CAmBtB"}
@@ -1 +1 @@
1
- {"version":3,"file":"filesystemPublisherEndpointChallengeStore.d.ts","sourceRoot":"","sources":["../../src/filesystemPublisherEndpointChallengeStore.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAIV,+BAA+B,EAChC,MAAM,iCAAiC,CAAA;AAYxC,MAAM,WAAW,gDAAgD;IAC/D,8EAA8E;IAC9E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACtB;AAID;;;;GAIG;AACH,wBAAgB,+CAA+C,CAC7D,OAAO,EAAE,gDAAgD,GACxD,+BAA+B,CA2GjC"}
1
+ {"version":3,"file":"filesystemPublisherEndpointChallengeStore.d.ts","sourceRoot":"","sources":["../../src/filesystemPublisherEndpointChallengeStore.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAIV,+BAA+B,EAChC,MAAM,iCAAiC,CAAA;AAYxC,MAAM,WAAW,gDAAgD;IAC/D,8EAA8E;IAC9E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACtB;AAID;;;;GAIG;AACH,wBAAgB,+CAA+C,CAC7D,OAAO,EAAE,gDAAgD,GACxD,+BAA+B,CAqGjC"}
@@ -111,10 +111,7 @@ function replaceJsonValue(_key, candidate) {
111
111
  return typeof candidate === "bigint" ? { $eventKitBigInt: candidate.toString() } : candidate;
112
112
  }
113
113
  function reviveJson(_key, candidate) {
114
- if (typeof candidate === "object" && candidate !== null && Object.keys(candidate).length === 1 && "$eventKitBigInt" in candidate && typeof candidate.$eventKitBigInt === "string" && /^(?:0|[1-9][0-9]*)$/u.test(candidate.$eventKitBigInt)) {
115
- return BigInt(candidate.$eventKitBigInt);
116
- }
117
- return candidate;
114
+ return typeof candidate === "object" && candidate !== null && Object.keys(candidate).length === 1 && "$eventKitBigInt" in candidate && typeof candidate.$eventKitBigInt === "string" && /^(?:0|[1-9][0-9]*)$/u.test(candidate.$eventKitBigInt) ? BigInt(candidate.$eventKitBigInt) : candidate;
118
115
  }
119
116
  async function unlinkIfMissing(path) {
120
117
  try {
@@ -706,7 +703,7 @@ function createFilesystemPublisherEndpointChallengeStore(options) {
706
703
  if (await publish(attempted)) return { kind: "started", record: attempted };
707
704
  const winner = await current(challengeHash);
708
705
  if (winner === void 0) throw new Error("challenge attempt winner vanished");
709
- return winner.state === "verified" ? { kind: "verified", record: winner } : { kind: "already-attempted", record: winner };
706
+ return { kind: winner.state === "verified" ? "verified" : "already-attempted", record: winner };
710
707
  },
711
708
  async completeVerified(input) {
712
709
  const challengeHash = HashZod3.parse(input.challengeHash);
@@ -715,7 +712,7 @@ function createFilesystemPublisherEndpointChallengeStore(options) {
715
712
  const observed = await current(challengeHash);
716
713
  if (observed === void 0) return { kind: "missing" };
717
714
  if (observed.state === "verified") {
718
- return observed.responseHash === responseHash ? { kind: "duplicate", record: observed } : { kind: "collision", record: observed };
715
+ return { kind: observed.responseHash === responseHash ? "duplicate" : "collision", record: observed };
719
716
  }
720
717
  if (observed.state !== "attempted") return { kind: "not-attempted", record: observed };
721
718
  if (!isLive(observed, input.nowSeconds)) return { kind: "expired", record: observed };
@@ -727,7 +724,7 @@ function createFilesystemPublisherEndpointChallengeStore(options) {
727
724
  if (await publish(verified)) return { kind: "verified", record: verified };
728
725
  const winner = await readState(challengeHash, "verified");
729
726
  if (winner === void 0) throw new Error("verified challenge winner vanished");
730
- return winner.responseHash === responseHash ? { kind: "duplicate", record: winner } : { kind: "collision", record: winner };
727
+ return { kind: winner.responseHash === responseHash ? "duplicate" : "collision", record: winner };
731
728
  },
732
729
  get: async (rawHash) => await current(HashZod3.parse(rawHash)),
733
730
  async issue(input) {
@@ -985,6 +982,8 @@ async function persistMutationIntent(store, intent) {
985
982
  }
986
983
  async function publisherServiceRequestFingerprint(input) {
987
984
  return await handshakeMutationRequestFingerprint({
985
+ deliveryMode: input.deliveryMode,
986
+ bestEffort: input.bestEffort ?? null,
988
987
  expiresAtBlock: input.expiresAtBlock ?? null,
989
988
  maxPositionsPerWake: input.maxPositionsPerWake,
990
989
  sources: input.sources,
@@ -1004,6 +1003,8 @@ async function publisherRotationRequestFingerprint(input) {
1004
1003
  }
1005
1004
  async function subscriberSubscriptionRequestFingerprint(input) {
1006
1005
  return await handshakeMutationRequestFingerprint({
1006
+ deliveryMode: input.deliveryMode,
1007
+ bestEffort: input.bestEffort ?? null,
1007
1008
  audience: input.audience,
1008
1009
  challengeSecret: input.challengeSecret,
1009
1010
  deploymentId: input.deploymentId,
@@ -1390,6 +1391,8 @@ function createPublisherHandshakeClient(options) {
1390
1391
  validFromBlock
1391
1392
  };
1392
1393
  const service = createPublisherService({
1394
+ deliveryMode: input.deliveryMode,
1395
+ ...input.bestEffort === void 0 ? {} : { bestEffort: input.bestEffort },
1393
1396
  ...serviceInput,
1394
1397
  authorizationChainId: options.reader.chainId,
1395
1398
  sources: input.sources,
@@ -1509,6 +1512,8 @@ function createPublisherHandshakeClient(options) {
1509
1512
  validFromBlock
1510
1513
  };
1511
1514
  const service = createPublisherService({
1515
+ deliveryMode: selected.service.body.deliveryMode,
1516
+ ...selected.service.body.bestEffort === void 0 ? {} : { bestEffort: selected.service.body.bestEffort },
1512
1517
  ...serviceInput,
1513
1518
  authorizationChainId: options.reader.chainId,
1514
1519
  sources: selected.service.body.events.map((event) => event.source),
@@ -1802,6 +1807,8 @@ function createSubscriberHandshakeClient(options) {
1802
1807
  return Object.freeze(client);
1803
1808
  }
1804
1809
  function subscriberPlaintext(service, input, maxPositionsPerWake) {
1810
+ if (input.deliveryMode !== service.deliveryMode || canonicalJson(input.bestEffort ?? null) !== canonicalJson(service.bestEffort ?? null))
1811
+ throw new Error("Requested delivery terms do not match exact selected service");
1805
1812
  const plaintextInput = {
1806
1813
  audience: input.audience,
1807
1814
  challengeSecret: input.challengeSecret,
@@ -1814,6 +1821,8 @@ function subscriberPlaintext(service, input, maxPositionsPerWake) {
1814
1821
  throw new Error("Requested source is not advertised by the selected service");
1815
1822
  }
1816
1823
  return createWakeSubscriptionPlaintext({
1824
+ deliveryMode: input.deliveryMode,
1825
+ ...input.bestEffort === void 0 ? {} : { bestEffort: input.bestEffort },
1817
1826
  ...plaintextInput,
1818
1827
  source,
1819
1828
  fromPosition: input.fromPosition,