@xyo-network/event-kit-node 0.1.8 → 1.0.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.
- package/dist/node/filesystemEventKitReplayCheckpointStore.d.ts.map +1 -1
- package/dist/node/filesystemHandshakeMutationIntentStore.d.ts.map +1 -1
- package/dist/node/filesystemPublisherEndpointChallengeStore.d.ts.map +1 -1
- package/dist/node/filesystemPublisherOutbox.d.ts.map +1 -1
- package/dist/node/filesystemWakeInbox.d.ts.map +1 -1
- package/dist/node/handshake.mjs +32 -38
- package/dist/node/handshake.mjs.map +2 -2
- package/dist/node/handshakeClients.d.ts.map +1 -1
- package/dist/node/index.mjs +180 -161
- package/dist/node/index.mjs.map +3 -3
- package/dist/node/runtime/handshakeDiscovery.d.ts.map +1 -1
- package/dist/node/runtime/httpsTransport.d.ts.map +1 -1
- package/dist/node/runtime/publisherRuntime.d.ts.map +1 -1
- package/dist/node/runtime/sources.d.ts.map +1 -1
- package/dist/node/runtime.mjs +84 -64
- package/dist/node/runtime.mjs.map +2 -2
- package/dist/node/sqliteWakeQueue.d.ts.map +1 -1
- package/package.json +27 -27
|
@@ -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,
|
|
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,
|
|
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,
|
|
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 +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,
|
|
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,
|
|
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"}
|
package/dist/node/handshake.mjs
CHANGED
|
@@ -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
|
|
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
|
|
101
|
+
await unlinkIfMissing(tempPath);
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
function suffix() {
|
|
@@ -116,8 +116,12 @@ function reviveJson(_key, candidate) {
|
|
|
116
116
|
}
|
|
117
117
|
return candidate;
|
|
118
118
|
}
|
|
119
|
-
function
|
|
120
|
-
|
|
119
|
+
async function unlinkIfMissing(path) {
|
|
120
|
+
try {
|
|
121
|
+
await unlink(path);
|
|
122
|
+
} catch (error) {
|
|
123
|
+
if (errorCode2(error) !== "ENOENT") throw error;
|
|
124
|
+
}
|
|
121
125
|
}
|
|
122
126
|
function errorCode2(error) {
|
|
123
127
|
return typeof error === "object" && error !== null && "code" in error ? error.code : void 0;
|
|
@@ -133,8 +137,18 @@ function createFilesystemEventKitReplayCheckpointStore(options) {
|
|
|
133
137
|
return await readJsonFileStrict(path);
|
|
134
138
|
},
|
|
135
139
|
async save(checkpoint) {
|
|
136
|
-
const
|
|
137
|
-
|
|
140
|
+
const previous = tail;
|
|
141
|
+
const save = (async () => {
|
|
142
|
+
await previous;
|
|
143
|
+
await replaceJsonFile(path, checkpoint);
|
|
144
|
+
})();
|
|
145
|
+
tail = (async () => {
|
|
146
|
+
try {
|
|
147
|
+
await save;
|
|
148
|
+
} catch {
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
})();
|
|
138
152
|
await save;
|
|
139
153
|
}
|
|
140
154
|
};
|
|
@@ -166,7 +180,7 @@ function assertIntentShape(intent) {
|
|
|
166
180
|
if (!/^[0-9a-f]{40}$/u.test(intent.chainId)) {
|
|
167
181
|
throw new TypeError("publication chainId must be a canonical 20-byte lowercase hexadecimal chain id");
|
|
168
182
|
}
|
|
169
|
-
if (
|
|
183
|
+
if ([...intent.eventHashes, ...intent.attachmentHashes].some((hash) => !/^[0-9a-f]{64}$/u.test(hash))) {
|
|
170
184
|
throw new TypeError("publication intent hashes must be 32-byte lowercase hexadecimal");
|
|
171
185
|
}
|
|
172
186
|
}
|
|
@@ -527,9 +541,7 @@ function createFilesystemHandshakeMutationIntentStore(options) {
|
|
|
527
541
|
return intent;
|
|
528
542
|
}
|
|
529
543
|
return {
|
|
530
|
-
async
|
|
531
|
-
return await readIntent(parseHandshakeMutationIntentLookup(lookup));
|
|
532
|
-
},
|
|
544
|
+
get: async (lookup) => await readIntent(parseHandshakeMutationIntentLookup(lookup)),
|
|
533
545
|
async getOrCreate(rawIntent) {
|
|
534
546
|
const proposed = await parseHandshakeMutationIntent(rawIntent);
|
|
535
547
|
const path = pathFor(proposed);
|
|
@@ -717,9 +729,7 @@ function createFilesystemPublisherEndpointChallengeStore(options) {
|
|
|
717
729
|
if (winner === void 0) throw new Error("verified challenge winner vanished");
|
|
718
730
|
return winner.responseHash === responseHash ? { kind: "duplicate", record: winner } : { kind: "collision", record: winner };
|
|
719
731
|
},
|
|
720
|
-
async
|
|
721
|
-
return await current(HashZod3.parse(rawHash));
|
|
722
|
-
},
|
|
732
|
+
get: async (rawHash) => await current(HashZod3.parse(rawHash)),
|
|
723
733
|
async issue(input) {
|
|
724
734
|
const challenge = EndpointChallengeZod2.parse(input.challenge);
|
|
725
735
|
const challengeHash = HashZod3.parse(input.challengeHash);
|
|
@@ -870,27 +880,13 @@ function createEventKitHandshakePublicationPort(transport) {
|
|
|
870
880
|
const chainId = ChainIdZod2.parse(transport.session.chainId);
|
|
871
881
|
const port = {
|
|
872
882
|
chainId,
|
|
873
|
-
async
|
|
874
|
-
|
|
875
|
-
},
|
|
876
|
-
async
|
|
877
|
-
|
|
878
|
-
},
|
|
879
|
-
async
|
|
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
|
-
},
|
|
883
|
+
publishPublisherEncryptionKeyRevocation: async (input) => await publishPublisherEncryptionKeyRevocation({ ...transport, ...input }),
|
|
884
|
+
publishPublisherService: async (input) => await publishPublisherService({ ...transport, ...input }),
|
|
885
|
+
publishPublisherServiceRevocation: async (input) => await publishPublisherServiceRevocation({ ...transport, ...input }),
|
|
886
|
+
publishWakeGrantRevocation: async (input) => await publishWakeGrantRevocation({ ...transport, ...input }),
|
|
887
|
+
publishWakeSubscription: async (input) => await publishWakeSubscription({ ...transport, ...input }),
|
|
888
|
+
publishWakeSubscriptionAcceptance: async (input) => await publishWakeSubscriptionAcceptance({ ...transport, ...input }),
|
|
889
|
+
publishWakeSubscriptionRevocation: async (input) => await publishWakeSubscriptionRevocation({ ...transport, ...input }),
|
|
894
890
|
async source() {
|
|
895
891
|
const raw = String(await transport.signer.address());
|
|
896
892
|
const normalized = NormalizedAddressZod3.parse(normalizeAddress(raw));
|
|
@@ -1801,9 +1797,7 @@ function createSubscriberHandshakeClient(options) {
|
|
|
1801
1797
|
});
|
|
1802
1798
|
return await publishSubscriberSubscriptionIntent(resolvedIntent.intent, resolvedIntent.disposition);
|
|
1803
1799
|
},
|
|
1804
|
-
async
|
|
1805
|
-
return await lookup(subscriptionId);
|
|
1806
|
-
}
|
|
1800
|
+
subscriptions: async (subscriptionId) => await lookup(subscriptionId)
|
|
1807
1801
|
};
|
|
1808
1802
|
return Object.freeze(client);
|
|
1809
1803
|
}
|
|
@@ -1816,7 +1810,7 @@ function subscriberPlaintext(service, input, maxPositionsPerWake) {
|
|
|
1816
1810
|
queueId: input.queueId
|
|
1817
1811
|
};
|
|
1818
1812
|
const source = input.source;
|
|
1819
|
-
if (
|
|
1813
|
+
if (service.events.every((event) => canonicalJson(event.source) !== canonicalJson(source))) {
|
|
1820
1814
|
throw new Error("Requested source is not advertised by the selected service");
|
|
1821
1815
|
}
|
|
1822
1816
|
return createWakeSubscriptionPlaintext({
|