@xyo-network/event-kit-node 0.1.9 → 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.
@@ -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":"filesystemEventKitReplayCheckpointStore.d.ts","sourceRoot":"","sources":["../../src/filesystemEventKitReplayCheckpointStore.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,6BAA6B,EAC9B,MAAM,wCAAwC,CAAA;AAI/C,MAAM,WAAW,8CAA8C;IAC7D,wEAAwE;IACxE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACtB;AAED,oFAAoF;AACpF,wBAAgB,6CAA6C,CAC3D,OAAO,EAAE,8CAA8C,GACtD,6BAA6B,CAgB/B"}
1
+ {"version":3,"file":"filesystemEventKitReplayCheckpointStore.d.ts","sourceRoot":"","sources":["../../src/filesystemEventKitReplayCheckpointStore.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,6BAA6B,EAC9B,MAAM,wCAAwC,CAAA;AAI/C,MAAM,WAAW,8CAA8C;IAC7D,wEAAwE;IACxE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACtB;AAED,oFAAoF;AACpF,wBAAgB,6CAA6C,CAC3D,OAAO,EAAE,8CAA8C,GACtD,6BAA6B,CA0B/B"}
@@ -1 +1 @@
1
- {"version":3,"file":"filesystemHandshakeMutationIntentStore.d.ts","sourceRoot":"","sources":["../../src/filesystemHandshakeMutationIntentStore.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAGV,4BAA4B,EAC7B,MAAM,8BAA8B,CAAA;AAOrC,MAAM,WAAW,6CAA6C;IAC5D,2EAA2E;IAC3E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACtB;AAED;;;;GAIG;AACH,wBAAgB,4CAA4C,CAC1D,OAAO,EAAE,6CAA6C,GACrD,4BAA4B,CAqD9B"}
1
+ {"version":3,"file":"filesystemHandshakeMutationIntentStore.d.ts","sourceRoot":"","sources":["../../src/filesystemHandshakeMutationIntentStore.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAGV,4BAA4B,EAC7B,MAAM,8BAA8B,CAAA;AAOrC,MAAM,WAAW,6CAA6C;IAC5D,2EAA2E;IAC3E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACtB;AAED;;;;GAIG;AACH,wBAAgB,4CAA4C,CAC1D,OAAO,EAAE,6CAA6C,GACrD,4BAA4B,CAmD9B"}
@@ -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,CA6GjC"}
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"}
@@ -1 +1 @@
1
- {"version":3,"file":"filesystemPublisherOutbox.d.ts","sourceRoot":"","sources":["../../src/filesystemPublisherOutbox.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAe,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAIhF,MAAM,WAAW,gCAAgC;IAC/C,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACtB;AAED;;;;;;;;GAQG;AACH,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,gCAAgC,GACxC,eAAe,CAkCjB"}
1
+ {"version":3,"file":"filesystemPublisherOutbox.d.ts","sourceRoot":"","sources":["../../src/filesystemPublisherOutbox.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAe,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAIhF,MAAM,WAAW,gCAAgC;IAC/C,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACtB;AAED;;;;;;;;GAQG;AACH,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,gCAAgC,GACxC,eAAe,CAgCjB"}
@@ -1 +1 @@
1
- {"version":3,"file":"filesystemWakeInbox.d.ts","sourceRoot":"","sources":["../../src/filesystemWakeInbox.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAEV,eAAe,EAKhB,MAAM,iCAAiC,CAAA;AAExC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAGnE,MAAM,WAAW,0BAA0B;IACzC,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,yEAAyE;IACzE,QAAQ,CAAC,KAAK,EAAE,mBAAmB,CAAA;CACpC;AAED,MAAM,WAAW,mBAAoB,SAAQ,eAAe;IAC1D,kFAAkF;IAClF,kBAAkB,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;CAC5D;AAkBD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,0BAA0B,GAClC,mBAAmB,CAwHrB"}
1
+ {"version":3,"file":"filesystemWakeInbox.d.ts","sourceRoot":"","sources":["../../src/filesystemWakeInbox.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAEV,eAAe,EAKhB,MAAM,iCAAiC,CAAA;AAExC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAGnE,MAAM,WAAW,0BAA0B;IACzC,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,yEAAyE;IACzE,QAAQ,CAAC,KAAK,EAAE,mBAAmB,CAAA;CACpC;AAED,MAAM,WAAW,mBAAoB,SAAQ,eAAe;IAC1D,kFAAkF;IAClF,kBAAkB,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;CAC5D;AAkBD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,0BAA0B,GAClC,mBAAmB,CA4HrB"}
@@ -80,7 +80,7 @@ async function replaceJsonFile(path, value, options = {}) {
80
80
  await rename(tempPath, path);
81
81
  await syncDirectory(directory);
82
82
  } catch (error) {
83
- await unlink(tempPath).catch(ignoreNotFound);
83
+ await unlinkIfMissing(tempPath);
84
84
  throw error;
85
85
  }
86
86
  }
@@ -98,7 +98,7 @@ async function publishJsonFile(path, value, options = {}) {
98
98
  if (errorCode2(error) === "EEXIST") return false;
99
99
  throw error;
100
100
  } finally {
101
- await unlink(tempPath).catch(ignoreNotFound);
101
+ await unlinkIfMissing(tempPath);
102
102
  }
103
103
  }
104
104
  function suffix() {
@@ -111,13 +111,14 @@ 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
- function ignoreNotFound(error) {
120
- if (errorCode2(error) !== "ENOENT") throw error;
116
+ async function unlinkIfMissing(path) {
117
+ try {
118
+ await unlink(path);
119
+ } catch (error) {
120
+ if (errorCode2(error) !== "ENOENT") throw error;
121
+ }
121
122
  }
122
123
  function errorCode2(error) {
123
124
  return typeof error === "object" && error !== null && "code" in error ? error.code : void 0;
@@ -133,8 +134,18 @@ function createFilesystemEventKitReplayCheckpointStore(options) {
133
134
  return await readJsonFileStrict(path);
134
135
  },
135
136
  async save(checkpoint) {
136
- const save = tail.then(async () => await replaceJsonFile(path, checkpoint));
137
- tail = save.catch(() => false);
137
+ const previous = tail;
138
+ const save = (async () => {
139
+ await previous;
140
+ await replaceJsonFile(path, checkpoint);
141
+ })();
142
+ tail = (async () => {
143
+ try {
144
+ await save;
145
+ } catch {
146
+ return false;
147
+ }
148
+ })();
138
149
  await save;
139
150
  }
140
151
  };
@@ -166,7 +177,7 @@ function assertIntentShape(intent) {
166
177
  if (!/^[0-9a-f]{40}$/u.test(intent.chainId)) {
167
178
  throw new TypeError("publication chainId must be a canonical 20-byte lowercase hexadecimal chain id");
168
179
  }
169
- if (![...intent.eventHashes, ...intent.attachmentHashes].every((hash) => /^[0-9a-f]{64}$/u.test(hash))) {
180
+ if ([...intent.eventHashes, ...intent.attachmentHashes].some((hash) => !/^[0-9a-f]{64}$/u.test(hash))) {
170
181
  throw new TypeError("publication intent hashes must be 32-byte lowercase hexadecimal");
171
182
  }
172
183
  }
@@ -527,9 +538,7 @@ function createFilesystemHandshakeMutationIntentStore(options) {
527
538
  return intent;
528
539
  }
529
540
  return {
530
- async get(lookup) {
531
- return await readIntent(parseHandshakeMutationIntentLookup(lookup));
532
- },
541
+ get: async (lookup) => await readIntent(parseHandshakeMutationIntentLookup(lookup)),
533
542
  async getOrCreate(rawIntent) {
534
543
  const proposed = await parseHandshakeMutationIntent(rawIntent);
535
544
  const path = pathFor(proposed);
@@ -694,7 +703,7 @@ function createFilesystemPublisherEndpointChallengeStore(options) {
694
703
  if (await publish(attempted)) return { kind: "started", record: attempted };
695
704
  const winner = await current(challengeHash);
696
705
  if (winner === void 0) throw new Error("challenge attempt winner vanished");
697
- return winner.state === "verified" ? { kind: "verified", record: winner } : { kind: "already-attempted", record: winner };
706
+ return { kind: winner.state === "verified" ? "verified" : "already-attempted", record: winner };
698
707
  },
699
708
  async completeVerified(input) {
700
709
  const challengeHash = HashZod3.parse(input.challengeHash);
@@ -703,7 +712,7 @@ function createFilesystemPublisherEndpointChallengeStore(options) {
703
712
  const observed = await current(challengeHash);
704
713
  if (observed === void 0) return { kind: "missing" };
705
714
  if (observed.state === "verified") {
706
- return observed.responseHash === responseHash ? { kind: "duplicate", record: observed } : { kind: "collision", record: observed };
715
+ return { kind: observed.responseHash === responseHash ? "duplicate" : "collision", record: observed };
707
716
  }
708
717
  if (observed.state !== "attempted") return { kind: "not-attempted", record: observed };
709
718
  if (!isLive(observed, input.nowSeconds)) return { kind: "expired", record: observed };
@@ -715,11 +724,9 @@ function createFilesystemPublisherEndpointChallengeStore(options) {
715
724
  if (await publish(verified)) return { kind: "verified", record: verified };
716
725
  const winner = await readState(challengeHash, "verified");
717
726
  if (winner === void 0) throw new Error("verified challenge winner vanished");
718
- return winner.responseHash === responseHash ? { kind: "duplicate", record: winner } : { kind: "collision", record: winner };
719
- },
720
- async get(rawHash) {
721
- return await current(HashZod3.parse(rawHash));
727
+ return { kind: winner.responseHash === responseHash ? "duplicate" : "collision", record: winner };
722
728
  },
729
+ get: async (rawHash) => await current(HashZod3.parse(rawHash)),
723
730
  async issue(input) {
724
731
  const challenge = EndpointChallengeZod2.parse(input.challenge);
725
732
  const challengeHash = HashZod3.parse(input.challengeHash);
@@ -870,27 +877,13 @@ function createEventKitHandshakePublicationPort(transport) {
870
877
  const chainId = ChainIdZod2.parse(transport.session.chainId);
871
878
  const port = {
872
879
  chainId,
873
- async publishPublisherEncryptionKeyRevocation(input) {
874
- return await publishPublisherEncryptionKeyRevocation({ ...transport, ...input });
875
- },
876
- async publishPublisherService(input) {
877
- return await publishPublisherService({ ...transport, ...input });
878
- },
879
- async publishPublisherServiceRevocation(input) {
880
- return await publishPublisherServiceRevocation({ ...transport, ...input });
881
- },
882
- async publishWakeGrantRevocation(input) {
883
- return await publishWakeGrantRevocation({ ...transport, ...input });
884
- },
885
- async publishWakeSubscription(input) {
886
- return await publishWakeSubscription({ ...transport, ...input });
887
- },
888
- async publishWakeSubscriptionAcceptance(input) {
889
- return await publishWakeSubscriptionAcceptance({ ...transport, ...input });
890
- },
891
- async publishWakeSubscriptionRevocation(input) {
892
- return await publishWakeSubscriptionRevocation({ ...transport, ...input });
893
- },
880
+ publishPublisherEncryptionKeyRevocation: async (input) => await publishPublisherEncryptionKeyRevocation({ ...transport, ...input }),
881
+ publishPublisherService: async (input) => await publishPublisherService({ ...transport, ...input }),
882
+ publishPublisherServiceRevocation: async (input) => await publishPublisherServiceRevocation({ ...transport, ...input }),
883
+ publishWakeGrantRevocation: async (input) => await publishWakeGrantRevocation({ ...transport, ...input }),
884
+ publishWakeSubscription: async (input) => await publishWakeSubscription({ ...transport, ...input }),
885
+ publishWakeSubscriptionAcceptance: async (input) => await publishWakeSubscriptionAcceptance({ ...transport, ...input }),
886
+ publishWakeSubscriptionRevocation: async (input) => await publishWakeSubscriptionRevocation({ ...transport, ...input }),
894
887
  async source() {
895
888
  const raw = String(await transport.signer.address());
896
889
  const normalized = NormalizedAddressZod3.parse(normalizeAddress(raw));
@@ -1801,9 +1794,7 @@ function createSubscriberHandshakeClient(options) {
1801
1794
  });
1802
1795
  return await publishSubscriberSubscriptionIntent(resolvedIntent.intent, resolvedIntent.disposition);
1803
1796
  },
1804
- async subscriptions(subscriptionId) {
1805
- return await lookup(subscriptionId);
1806
- }
1797
+ subscriptions: async (subscriptionId) => await lookup(subscriptionId)
1807
1798
  };
1808
1799
  return Object.freeze(client);
1809
1800
  }
@@ -1816,7 +1807,7 @@ function subscriberPlaintext(service, input, maxPositionsPerWake) {
1816
1807
  queueId: input.queueId
1817
1808
  };
1818
1809
  const source = input.source;
1819
- if (!service.events.some((event) => canonicalJson(event.source) === canonicalJson(source))) {
1810
+ if (service.events.every((event) => canonicalJson(event.source) !== canonicalJson(source))) {
1820
1811
  throw new Error("Requested source is not advertised by the selected service");
1821
1812
  }
1822
1813
  return createWakeSubscriptionPlaintext({