@kumiai/hub-tunnel 0.12.2 → 0.13.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/lib/encrypted-transport.js +16 -6
- package/lib/index.d.ts +1 -0
- package/lib/transport.d.ts +14 -3
- package/lib/transport.js +10 -3
- package/package.json +9 -9
|
@@ -35,14 +35,24 @@ function wrapHub({ hub, encryptor, groupID, onEvent, onEncryptError, onExpired,
|
|
|
35
35
|
remember(result.sequenceID);
|
|
36
36
|
return result;
|
|
37
37
|
},
|
|
38
|
-
subscribe (subscriberDID, topicID, options) {
|
|
39
|
-
return hub.subscribe(
|
|
38
|
+
subscribe ({ subscriberDID, topicID, ...options }) {
|
|
39
|
+
return hub.subscribe({
|
|
40
|
+
subscriberDID,
|
|
41
|
+
topicID,
|
|
42
|
+
...options
|
|
43
|
+
});
|
|
40
44
|
},
|
|
41
|
-
unsubscribe (subscriberDID, topicID) {
|
|
42
|
-
return hub.unsubscribe?.(
|
|
45
|
+
unsubscribe ({ subscriberDID, topicID }) {
|
|
46
|
+
return hub.unsubscribe?.({
|
|
47
|
+
subscriberDID,
|
|
48
|
+
topicID
|
|
49
|
+
});
|
|
43
50
|
},
|
|
44
|
-
receive (subscriberDID, options) {
|
|
45
|
-
const inner = hub.receive(
|
|
51
|
+
receive ({ subscriberDID, ...options }) {
|
|
52
|
+
const inner = hub.receive({
|
|
53
|
+
subscriberDID,
|
|
54
|
+
...options
|
|
55
|
+
});
|
|
46
56
|
const innerIterator = inner[Symbol.asyncIterator]();
|
|
47
57
|
const ackedOnDecrypt = new Set();
|
|
48
58
|
const inFlightDecrypts = new Set();
|
package/lib/index.d.ts
CHANGED
|
@@ -5,4 +5,5 @@ export { BackpressureError, DecryptError, DuplicateFrameError, EncryptError, Env
|
|
|
5
5
|
export type { FrameDroppedReason, ObservabilityEvent, ObservabilityEventListener, } from './events.js';
|
|
6
6
|
export { decodeFrame, encodeFrame, HUB_FRAME_VERSION, type HubFrame, type HubFrameMessageBody, hubFrameSchema, } from './frame.js';
|
|
7
7
|
export { precedesSequenceID } from './sequence.js';
|
|
8
|
+
export type { HubBaseReceiveParams, HubBaseSubscribeParams, HubBaseUnsubscribeParams, } from './transport.js';
|
|
8
9
|
export { createHubTunnelTransport, type HubBase, type HubFetchTopicParams, type HubFetchTopicResult, type HubPublishParams, type HubReceiveOptions, type HubReceiveSubscription, type HubSubscribeOptions, type HubTunnelSessionID, type HubTunnelTransportParams, type LogHub, type MailboxHub, type MailboxHubEvent, type MailboxHubEvents, type MailboxPublishParams, } from './transport.js';
|
package/lib/transport.d.ts
CHANGED
|
@@ -91,6 +91,17 @@ export type HubFetchTopicResult = {
|
|
|
91
91
|
/** Removed log frames after the exclusive cursor, from the same snapshot as messages and head. */
|
|
92
92
|
gap: boolean;
|
|
93
93
|
};
|
|
94
|
+
export type HubBaseSubscribeParams = {
|
|
95
|
+
subscriberDID: string;
|
|
96
|
+
topicID: string;
|
|
97
|
+
} & HubSubscribeOptions;
|
|
98
|
+
export type HubBaseUnsubscribeParams = {
|
|
99
|
+
subscriberDID: string;
|
|
100
|
+
topicID: string;
|
|
101
|
+
};
|
|
102
|
+
export type HubBaseReceiveParams = {
|
|
103
|
+
subscriberDID: string;
|
|
104
|
+
} & HubReceiveOptions;
|
|
94
105
|
/**
|
|
95
106
|
* The APIs both hub kinds share — everything except how you publish. `events` are
|
|
96
107
|
* connection-lifecycle (reconnect/connect/disconnect), emitted by a mailbox and a log hub alike, so
|
|
@@ -98,9 +109,9 @@ export type HubFetchTopicResult = {
|
|
|
98
109
|
* own `publish` on top; neither is derived from the other.
|
|
99
110
|
*/
|
|
100
111
|
export type HubBase = {
|
|
101
|
-
subscribe: (
|
|
102
|
-
unsubscribe?: (
|
|
103
|
-
receive: (
|
|
112
|
+
subscribe: (params: HubBaseSubscribeParams) => Promise<void> | void;
|
|
113
|
+
unsubscribe?: (params: HubBaseUnsubscribeParams) => Promise<void> | void;
|
|
114
|
+
receive: (params: HubBaseReceiveParams) => HubReceiveSubscription;
|
|
104
115
|
readonly events?: MailboxHubEvents;
|
|
105
116
|
};
|
|
106
117
|
/**
|
package/lib/transport.js
CHANGED
|
@@ -32,12 +32,16 @@ const DEFAULT_INBOX_CAPACITY = 1024;
|
|
|
32
32
|
// frames but still lets sends proceed.
|
|
33
33
|
const subscribed = (async ()=>{
|
|
34
34
|
try {
|
|
35
|
-
await hub.subscribe(
|
|
35
|
+
await hub.subscribe({
|
|
36
|
+
subscriberDID: localDID,
|
|
37
|
+
topicID: receiveTopicID
|
|
38
|
+
});
|
|
36
39
|
} catch {
|
|
37
40
|
// A failed subscribe yields no inbound frames; the send gate still proceeds.
|
|
38
41
|
}
|
|
39
42
|
})();
|
|
40
|
-
const subscription = hub.receive(
|
|
43
|
+
const subscription = hub.receive({
|
|
44
|
+
subscriberDID: localDID,
|
|
41
45
|
topicID: receiveTopicID
|
|
42
46
|
});
|
|
43
47
|
const iterator = subscription[Symbol.asyncIterator]();
|
|
@@ -100,7 +104,10 @@ const DEFAULT_INBOX_CAPACITY = 1024;
|
|
|
100
104
|
// Ordered after `subscribed`: unsubscribing before an in-flight subscribe lands would have
|
|
101
105
|
// the subscribe's later mutation resurrect a subscription this transport no longer wants.
|
|
102
106
|
// `releaseResources` itself stays synchronous — only the unsubscribe is deferred.
|
|
103
|
-
void subscribed.then(()=>hub.unsubscribe?.(
|
|
107
|
+
void subscribed.then(()=>hub.unsubscribe?.({
|
|
108
|
+
subscriberDID: localDID,
|
|
109
|
+
topicID: receiveTopicID
|
|
110
|
+
})).catch(()=>{});
|
|
104
111
|
try {
|
|
105
112
|
// Fire-and-forget: awaiting `return()` deadlocks on the real wire hub, where it waits behind
|
|
106
113
|
// the drain loop's in-flight `next()` that never settles during teardown. No-op catch keeps a
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kumiai/hub-tunnel",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "Peer-to-peer Enkaku transport tunneled through a hub relay",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"enkaku",
|
|
@@ -26,19 +26,19 @@
|
|
|
26
26
|
"lib/*"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@enkaku/transport": "^0.
|
|
30
|
-
"@kumiai/hub-protocol": "^0.
|
|
29
|
+
"@enkaku/transport": "^0.23.0",
|
|
30
|
+
"@kumiai/hub-protocol": "^0.13.0",
|
|
31
31
|
"@sozai/async": "^0.4.3",
|
|
32
|
-
"@sozai/codec": "^0.4.
|
|
32
|
+
"@sozai/codec": "^0.4.4",
|
|
33
33
|
"@sozai/event": "^0.1.6",
|
|
34
34
|
"@sozai/schema": "^0.1.6"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@enkaku/client": "^0.
|
|
38
|
-
"@enkaku/protocol": "^0.
|
|
39
|
-
"@enkaku/server": "^0.
|
|
40
|
-
"@kokuin/token": "^0.
|
|
41
|
-
"@kumiai/hub-conformance": "^0.
|
|
37
|
+
"@enkaku/client": "^0.23.0",
|
|
38
|
+
"@enkaku/protocol": "^0.23.0",
|
|
39
|
+
"@enkaku/server": "^0.23.0",
|
|
40
|
+
"@kokuin/token": "^0.7.0",
|
|
41
|
+
"@kumiai/hub-conformance": "^0.13.0"
|
|
42
42
|
},
|
|
43
43
|
"publishConfig": {
|
|
44
44
|
"access": "public"
|