@welshman/net 0.0.49 → 0.1.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.
- package/build/src/adapter.d.ts +46 -0
- package/build/src/adapter.js +91 -0
- package/build/src/adapter.js.map +1 -0
- package/build/src/auth.d.ts +57 -0
- package/build/src/auth.js +137 -0
- package/build/src/auth.js.map +1 -0
- package/build/src/context.d.ts +10 -0
- package/build/src/context.js +10 -0
- package/build/src/context.js.map +1 -0
- package/build/src/diff.d.ts +55 -0
- package/build/src/diff.js +148 -0
- package/build/src/diff.js.map +1 -0
- package/build/src/index.d.ts +12 -25
- package/build/src/index.js +12 -19
- package/build/src/index.js.map +1 -1
- package/build/src/message.d.ts +59 -0
- package/build/src/message.js +35 -0
- package/build/src/message.js.map +1 -0
- package/build/src/{Negentropy.js → negentropy.js} +1 -1
- package/build/src/{Negentropy.js.map → negentropy.js.map} +1 -1
- package/build/src/policy.d.ts +32 -0
- package/build/src/policy.js +202 -0
- package/build/src/policy.js.map +1 -0
- package/build/src/pool.d.ts +20 -0
- package/build/src/pool.js +67 -0
- package/build/src/pool.js.map +1 -0
- package/build/src/publish.d.ts +60 -0
- package/build/src/publish.js +120 -0
- package/build/src/publish.js.map +1 -0
- package/build/src/request.d.ts +79 -0
- package/build/src/request.js +191 -0
- package/build/src/request.js.map +1 -0
- package/build/src/socket.d.ts +41 -0
- package/build/src/socket.js +108 -0
- package/build/src/socket.js.map +1 -0
- package/build/src/{Tracker.js → tracker.js} +1 -1
- package/build/src/{Tracker.js.map → tracker.js.map} +1 -1
- package/build/src/util.d.ts +3 -0
- package/build/src/util.js +2 -0
- package/build/src/util.js.map +1 -0
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -9
- package/build/src/Connection.d.ts +0 -27
- package/build/src/Connection.js +0 -58
- package/build/src/Connection.js.map +0 -1
- package/build/src/ConnectionAuth.d.ts +0 -28
- package/build/src/ConnectionAuth.js +0 -99
- package/build/src/ConnectionAuth.js.map +0 -1
- package/build/src/ConnectionEvent.d.ts +0 -11
- package/build/src/ConnectionEvent.js +0 -13
- package/build/src/ConnectionEvent.js.map +0 -1
- package/build/src/ConnectionSender.d.ts +0 -9
- package/build/src/ConnectionSender.js +0 -51
- package/build/src/ConnectionSender.js.map +0 -1
- package/build/src/ConnectionState.d.ts +0 -17
- package/build/src/ConnectionState.js +0 -80
- package/build/src/ConnectionState.js.map +0 -1
- package/build/src/ConnectionStats.d.ts +0 -26
- package/build/src/ConnectionStats.js +0 -83
- package/build/src/ConnectionStats.js.map +0 -1
- package/build/src/Context.d.ts +0 -33
- package/build/src/Context.js +0 -40
- package/build/src/Context.js.map +0 -1
- package/build/src/Executor.d.ts +0 -51
- package/build/src/Executor.js +0 -106
- package/build/src/Executor.js.map +0 -1
- package/build/src/Pool.d.ts +0 -10
- package/build/src/Pool.js +0 -35
- package/build/src/Pool.js.map +0 -1
- package/build/src/Publish.d.ts +0 -42
- package/build/src/Publish.js +0 -68
- package/build/src/Publish.js.map +0 -1
- package/build/src/Socket.d.ts +0 -26
- package/build/src/Socket.js +0 -113
- package/build/src/Socket.js.map +0 -1
- package/build/src/Subscribe.d.ts +0 -60
- package/build/src/Subscribe.js +0 -293
- package/build/src/Subscribe.js.map +0 -1
- package/build/src/Sync.d.ts +0 -42
- package/build/src/Sync.js +0 -125
- package/build/src/Sync.js.map +0 -1
- package/build/src/target/Echo.d.ts +0 -7
- package/build/src/target/Echo.js +0 -13
- package/build/src/target/Echo.js.map +0 -1
- package/build/src/target/Local.d.ts +0 -11
- package/build/src/target/Local.js +0 -25
- package/build/src/target/Local.js.map +0 -1
- package/build/src/target/Multi.d.ts +0 -10
- package/build/src/target/Multi.js +0 -22
- package/build/src/target/Multi.js.map +0 -1
- package/build/src/target/Relay.d.ts +0 -11
- package/build/src/target/Relay.js +0 -24
- package/build/src/target/Relay.js.map +0 -1
- package/build/src/target/Relays.d.ts +0 -10
- package/build/src/target/Relays.js +0 -25
- package/build/src/target/Relays.js.map +0 -1
- /package/build/src/{Negentropy.d.ts → negentropy.d.ts} +0 -0
- /package/build/src/{Tracker.d.ts → tracker.d.ts} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ConnectionEvent.js","sourceRoot":"","sources":["../../src/ConnectionEvent.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,eAUX;AAVD,WAAY,eAAe;IACzB,6CAA0B,CAAA;IAC1B,6DAA0C,CAAA;IAC1C,uCAAoB,CAAA;IACpB,yCAAsB,CAAA;IACtB,yCAAsB,CAAA;IACtB,yCAAsB,CAAA;IACtB,8CAA2B,CAAA;IAC3B,4CAAyB,CAAA;IACzB,wCAAqB,CAAA;AACvB,CAAC,EAVW,eAAe,KAAf,eAAe,QAU1B"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Worker } from "@welshman/lib";
|
|
2
|
-
import type { Message } from "./Socket.js";
|
|
3
|
-
import type { Connection } from "./Connection.js";
|
|
4
|
-
export declare class ConnectionSender {
|
|
5
|
-
readonly cxn: Connection;
|
|
6
|
-
worker: Worker<Message>;
|
|
7
|
-
constructor(cxn: Connection);
|
|
8
|
-
push: (message: Message) => void;
|
|
9
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { Worker, complement, spec } from "@welshman/lib";
|
|
2
|
-
import { AUTH_JOIN } from "@welshman/util";
|
|
3
|
-
import { SocketStatus } from "./Socket.js";
|
|
4
|
-
import { AuthStatus } from "./ConnectionAuth.js";
|
|
5
|
-
export class ConnectionSender {
|
|
6
|
-
cxn;
|
|
7
|
-
worker;
|
|
8
|
-
constructor(cxn) {
|
|
9
|
-
this.cxn = cxn;
|
|
10
|
-
this.worker = new Worker({
|
|
11
|
-
shouldDefer: (message) => {
|
|
12
|
-
const verb = message[0];
|
|
13
|
-
// Always send CLOSE to clean up pending requests
|
|
14
|
-
if (verb === "CLOSE")
|
|
15
|
-
return false;
|
|
16
|
-
// If we're not connected, nothing we can do
|
|
17
|
-
if (cxn.socket.status !== SocketStatus.Open)
|
|
18
|
-
return true;
|
|
19
|
-
// Always allow sending AUTH
|
|
20
|
-
if (verb === "AUTH")
|
|
21
|
-
return false;
|
|
22
|
-
// Always allow sending join requests
|
|
23
|
-
if (verb === "EVENT" && message[1].kind === AUTH_JOIN)
|
|
24
|
-
return false;
|
|
25
|
-
// Wait for auth
|
|
26
|
-
if (![AuthStatus.None, AuthStatus.Ok].includes(cxn.auth.status))
|
|
27
|
-
return true;
|
|
28
|
-
// Limit concurrent requests
|
|
29
|
-
if (verb === "REQ")
|
|
30
|
-
return cxn.state.pendingRequests.size >= 50;
|
|
31
|
-
return false;
|
|
32
|
-
},
|
|
33
|
-
});
|
|
34
|
-
this.worker.addGlobalHandler((message) => {
|
|
35
|
-
const verb = message[0];
|
|
36
|
-
// If we're closing something that never got sent, skip it
|
|
37
|
-
if (verb === "CLOSE" && !cxn.state.pendingRequests.has(message[1])) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
cxn.socket.send(message);
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
push = (message) => {
|
|
44
|
-
// If we ended up handling a CLOSE before we sent the REQ, don't send the REQ
|
|
45
|
-
if (message[0] === "CLOSE") {
|
|
46
|
-
this.worker.buffer = this.worker.buffer.filter(complement(spec(["REQ", message[1]])));
|
|
47
|
-
}
|
|
48
|
-
this.worker.push(message);
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
//# sourceMappingURL=ConnectionSender.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ConnectionSender.js","sourceRoot":"","sources":["../../src/ConnectionSender.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAC,MAAM,eAAe,CAAA;AACtD,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAA;AACxC,OAAO,EAAC,YAAY,EAAC,MAAM,aAAa,CAAA;AAGx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AAC,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBACnE,OAAM;YACR,CAAC;YACD,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC1B,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,IAAI,GAAG,CAAC,OAAgB,EAAE,EAAE;QAC1B,6EAA6E;QAC7E,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE,CAAC;YAC3B,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QACvF,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IAC3B,CAAC,CAAA;CACF"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { SignedEvent, Filter } from "@welshman/util";
|
|
2
|
-
import type { Connection } from "./Connection.js";
|
|
3
|
-
export type PublishState = {
|
|
4
|
-
sent: number;
|
|
5
|
-
event: SignedEvent;
|
|
6
|
-
};
|
|
7
|
-
export type RequestState = {
|
|
8
|
-
sent: number;
|
|
9
|
-
filters: Filter[];
|
|
10
|
-
eose?: boolean;
|
|
11
|
-
};
|
|
12
|
-
export declare class ConnectionState {
|
|
13
|
-
readonly cxn: Connection;
|
|
14
|
-
pendingPublishes: Map<string, PublishState>;
|
|
15
|
-
pendingRequests: Map<string, RequestState>;
|
|
16
|
-
constructor(cxn: Connection);
|
|
17
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { sleep } from "@welshman/lib";
|
|
2
|
-
import { AUTH_JOIN } from "@welshman/util";
|
|
3
|
-
import { ConnectionEvent } from "./ConnectionEvent.js";
|
|
4
|
-
export class ConnectionState {
|
|
5
|
-
cxn;
|
|
6
|
-
pendingPublishes = new Map();
|
|
7
|
-
pendingRequests = new Map();
|
|
8
|
-
constructor(cxn) {
|
|
9
|
-
this.cxn = cxn;
|
|
10
|
-
cxn.sender.worker.addGlobalHandler(([verb, ...extra]) => {
|
|
11
|
-
if (verb === "REQ") {
|
|
12
|
-
const [reqId, ...filters] = extra;
|
|
13
|
-
this.pendingRequests.set(reqId, { filters, sent: Date.now() });
|
|
14
|
-
}
|
|
15
|
-
if (verb === "CLOSE") {
|
|
16
|
-
const [reqId] = extra;
|
|
17
|
-
this.pendingRequests.delete(reqId);
|
|
18
|
-
}
|
|
19
|
-
if (verb === "EVENT") {
|
|
20
|
-
const [event] = extra;
|
|
21
|
-
this.pendingPublishes.set(event.id, { sent: Date.now(), event });
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
cxn.socket.worker.addGlobalHandler(([verb, ...extra]) => {
|
|
25
|
-
if (verb === "OK") {
|
|
26
|
-
const [eventId, _ok, notice] = extra;
|
|
27
|
-
const pub = this.pendingPublishes.get(eventId);
|
|
28
|
-
if (!pub)
|
|
29
|
-
return;
|
|
30
|
-
// Re-enqueue pending events when auth challenge is received
|
|
31
|
-
if (notice?.startsWith("auth-required:") && pub.event.kind !== AUTH_JOIN) {
|
|
32
|
-
this.cxn.send(["EVENT", pub.event]);
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
this.pendingPublishes.delete(eventId);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
if (verb === "EOSE") {
|
|
39
|
-
const [reqId] = extra;
|
|
40
|
-
const req = this.pendingRequests.get(reqId);
|
|
41
|
-
if (req) {
|
|
42
|
-
req.eose = true;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
if (verb === "CLOSED") {
|
|
46
|
-
const [reqId] = extra;
|
|
47
|
-
// Re-enqueue pending reqs when auth challenge is received
|
|
48
|
-
if (extra[1]?.startsWith("auth-required:")) {
|
|
49
|
-
const req = this.pendingRequests.get(reqId);
|
|
50
|
-
if (req) {
|
|
51
|
-
this.cxn.send(["REQ", reqId, ...req.filters]);
|
|
52
|
-
}
|
|
53
|
-
if (extra[1]) {
|
|
54
|
-
this.cxn.emit(ConnectionEvent.Notice, extra[1]);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
this.pendingRequests.delete(reqId);
|
|
58
|
-
}
|
|
59
|
-
if (verb === "NOTICE") {
|
|
60
|
-
const [notice] = extra;
|
|
61
|
-
this.cxn.emit(ConnectionEvent.Notice, notice);
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
// Whenever we reconnect, re-enqueue pending stuff. Delay this so that if a connection
|
|
65
|
-
// is flapping we're not sending too much noise.
|
|
66
|
-
cxn.on(ConnectionEvent.Close, async (cxn) => {
|
|
67
|
-
await sleep(10_000);
|
|
68
|
-
if (this.pendingRequests.size > 0 || this.pendingPublishes.size > 0) {
|
|
69
|
-
this.cxn.open();
|
|
70
|
-
}
|
|
71
|
-
for (const [reqId, req] of this.pendingRequests.entries()) {
|
|
72
|
-
this.cxn.send(["REQ", reqId, ...req.filters]);
|
|
73
|
-
}
|
|
74
|
-
for (const [_, pub] of this.pendingPublishes.entries()) {
|
|
75
|
-
this.cxn.send(["EVENT", pub.event]);
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
//# sourceMappingURL=ConnectionState.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ConnectionState.js","sourceRoot":"","sources":["../../src/ConnectionState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,eAAe,CAAA;AACnC,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAA;AAIxC,OAAO,EAAC,eAAe,EAAC,MAAM,sBAAsB,CAAA;AAapD,MAAM,OAAO,eAAe;IAIL;IAHrB,gBAAgB,GAAG,IAAI,GAAG,EAAwB,CAAA;IAClD,eAAe,GAAG,IAAI,GAAG,EA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AAK,CAAC,CAAA;YACpC,CAAC;YAED,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACtB,MAAM,CAAC,MAAM,CAAC,GAAG,KAAK,CAAA;gBAEtB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;YAC/C,CAAC;QACH,CAAC,CAAC,CAAA;QAEF,sFAAsF;QACtF,gDAAgD;QAChD,GAAG,CAAC,EAAE,CAAC,eAAe,CAAC,KAAK,EAAE,KAAK,EAAE,GAAe,EAAE,EAAE;YACtD,MAAM,KAAK,CAAC,MAAM,CAAC,CAAA;YAEnB,IAAI,IAAI,CAAC,eAAe,CAAC,IAAI,GAAG,CAAC,IAAI,IAAI,CAAC,gBAAgB,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;gBACpE,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAA;YACjB,CAAC;YAED,KAAK,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,IAAI,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,EAAE,CAAC;gBAC1D,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC,CAAA;YAC/C,CAAC;YAED,KAAK,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,IAAI,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,EAAE,CAAC;gBACvD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAA;YACrC,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;CACF"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { Connection } from "./Connection.js";
|
|
2
|
-
export declare class ConnectionStats {
|
|
3
|
-
readonly cxn: Connection;
|
|
4
|
-
openCount: number;
|
|
5
|
-
closeCount: number;
|
|
6
|
-
errorCount: number;
|
|
7
|
-
publishCount: number;
|
|
8
|
-
requestCount: number;
|
|
9
|
-
eventCount: number;
|
|
10
|
-
lastOpen: number;
|
|
11
|
-
lastClose: number;
|
|
12
|
-
lastError: number;
|
|
13
|
-
lastPublish: number;
|
|
14
|
-
lastRequest: number;
|
|
15
|
-
lastEvent: number;
|
|
16
|
-
lastAuth: number;
|
|
17
|
-
publishTimer: number;
|
|
18
|
-
publishSuccessCount: number;
|
|
19
|
-
publishFailureCount: number;
|
|
20
|
-
eoseCount: number;
|
|
21
|
-
eoseTimer: number;
|
|
22
|
-
noticeCount: number;
|
|
23
|
-
constructor(cxn: Connection);
|
|
24
|
-
getRequestSpeed: () => number;
|
|
25
|
-
getPublishSpeed: () => number;
|
|
26
|
-
}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { ConnectionEvent } from "./ConnectionEvent.js";
|
|
2
|
-
export class ConnectionStats {
|
|
3
|
-
cxn;
|
|
4
|
-
openCount = 0;
|
|
5
|
-
closeCount = 0;
|
|
6
|
-
errorCount = 0;
|
|
7
|
-
publishCount = 0;
|
|
8
|
-
requestCount = 0;
|
|
9
|
-
eventCount = 0;
|
|
10
|
-
lastOpen = 0;
|
|
11
|
-
lastClose = 0;
|
|
12
|
-
lastError = 0;
|
|
13
|
-
lastPublish = 0;
|
|
14
|
-
lastRequest = 0;
|
|
15
|
-
lastEvent = 0;
|
|
16
|
-
lastAuth = 0;
|
|
17
|
-
publishTimer = 0;
|
|
18
|
-
publishSuccessCount = 0;
|
|
19
|
-
publishFailureCount = 0;
|
|
20
|
-
eoseCount = 0;
|
|
21
|
-
eoseTimer = 0;
|
|
22
|
-
noticeCount = 0;
|
|
23
|
-
constructor(cxn) {
|
|
24
|
-
this.cxn = cxn;
|
|
25
|
-
cxn.on(ConnectionEvent.Open, (cxn) => {
|
|
26
|
-
this.openCount++;
|
|
27
|
-
this.lastOpen = Date.now();
|
|
28
|
-
});
|
|
29
|
-
cxn.on(ConnectionEvent.Close, (cxn) => {
|
|
30
|
-
this.closeCount++;
|
|
31
|
-
this.lastClose = Date.now();
|
|
32
|
-
});
|
|
33
|
-
cxn.on(ConnectionEvent.Error, (cxn) => {
|
|
34
|
-
this.errorCount++;
|
|
35
|
-
this.lastError = Date.now();
|
|
36
|
-
});
|
|
37
|
-
cxn.on(ConnectionEvent.Send, (cxn, [verb]) => {
|
|
38
|
-
if (verb === "REQ") {
|
|
39
|
-
this.requestCount++;
|
|
40
|
-
this.lastRequest = Date.now();
|
|
41
|
-
}
|
|
42
|
-
if (verb === "EVENT") {
|
|
43
|
-
this.publishCount++;
|
|
44
|
-
this.lastPublish = Date.now();
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
cxn.on(ConnectionEvent.Receive, (cxn, [verb, ...extra]) => {
|
|
48
|
-
if (verb === "OK") {
|
|
49
|
-
const pub = this.cxn.state.pendingPublishes.get(extra[0]);
|
|
50
|
-
if (pub) {
|
|
51
|
-
this.publishTimer += Date.now() - pub.sent;
|
|
52
|
-
}
|
|
53
|
-
if (extra[1]) {
|
|
54
|
-
this.publishSuccessCount++;
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
this.publishFailureCount++;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
if (verb === "AUTH") {
|
|
61
|
-
this.lastAuth = Date.now();
|
|
62
|
-
}
|
|
63
|
-
if (verb === "EVENT") {
|
|
64
|
-
this.eventCount++;
|
|
65
|
-
this.lastEvent = Date.now();
|
|
66
|
-
}
|
|
67
|
-
if (verb === "EOSE") {
|
|
68
|
-
const request = this.cxn.state.pendingRequests.get(extra[0]);
|
|
69
|
-
// Only count the first eose
|
|
70
|
-
if (request && !request.eose) {
|
|
71
|
-
this.eoseCount++;
|
|
72
|
-
this.eoseTimer += Date.now() - request.sent;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
if (verb === "NOTICE") {
|
|
76
|
-
this.noticeCount++;
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
getRequestSpeed = () => (this.eoseCount ? this.eoseTimer / this.eoseCount : 0);
|
|
81
|
-
getPublishSpeed = () => this.publishSuccessCount ? this.publishTimer / this.publishSuccessCount : 0;
|
|
82
|
-
}
|
|
83
|
-
//# sourceMappingURL=ConnectionStats.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ConnectionStats.js","sourceRoot":"","sources":["../../src/ConnectionStats.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,eAAe,EAAC,MAAM,sBAAsB,CAAA;AAEpD,MAAM,OAAO,eAAe;IAqBL;IApBrB,SAAS,GAAG,CAAC,CAAA;IACb,UAAU,GAAG,CAAC,CAAA;IACd,UAAU,GAAG,CAAC,CAAA;IACd,YAAY,GAAG,CAAC,CAAA;IAChB,YAAY,GAAG,CAAC,CAAA;IAChB,UAAU,GAAG,CAAC,CAAA;IACd,QAAQ,GAAG,CAAC,CAAA;IACZ,SAAS,GAAG,CAAC,CAAA;IACb,SAAS,GAAG,CAAC,CAAA;IACb,WAAW,GAAG,CAAC,CAAA;IACf,WAAW,GAAG,CAAC,CAAA;IACf,SAAS,GAAG,CAAC,CAAA;IACb,QAAQ,GAAG,CAAC,CAAA;IACZ,YAAY,GAAG,CAAC,CAAA;IAChB,mBAAmB,GAAG,CAAC,CAAA;IACvB,mBAAmB,GAAG,CAAC,CAAA;IACvB,SAAS,GAAG,CAAC,CAAA;IACb,SAAS,GAAG,CAAC,CAAA;IACb,WAAW,GAAG,CAAC,CAAA;IAEf,YAAqB,GAAe;QAAf,QAAG,GAAH,GAAG,CAAY;QAClC,GAAG,CAAC,EAAE,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC,GAAe,EAAE,EAAE;YAC/C,IAAI,CAAC,SAAS,EAAE,CAAA;YAChB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;QAC5B,CAAC,CAAC,CAAA;QAEF,GAAG,CAAC,EAAE,CAAC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AC,CAAC,CAAC,CAAC,CAAA;CAC9E"}
|
package/build/src/Context.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { StampedEvent, SignedEvent, Filter, TrustedEvent } from "@welshman/util";
|
|
2
|
-
import { Pool } from "./Pool.js";
|
|
3
|
-
import { Executor } from "./Executor.js";
|
|
4
|
-
import { AuthMode } from "./ConnectionAuth.js";
|
|
5
|
-
import type { Subscription, RelaysAndFilters } from "./Subscribe.js";
|
|
6
|
-
export type NetContext = {
|
|
7
|
-
pool: Pool;
|
|
8
|
-
authMode: AuthMode;
|
|
9
|
-
onEvent: (url: string, event: TrustedEvent) => void;
|
|
10
|
-
signEvent: (event: StampedEvent) => Promise<SignedEvent | undefined>;
|
|
11
|
-
getExecutor: (relays: string[]) => Executor;
|
|
12
|
-
isDeleted: (url: string, event: TrustedEvent) => boolean;
|
|
13
|
-
isValid: (url: string, event: TrustedEvent) => boolean;
|
|
14
|
-
matchFilters: (url: string, filters: Filter[], event: TrustedEvent) => boolean;
|
|
15
|
-
optimizeSubscriptions: (subs: Subscription[]) => RelaysAndFilters[];
|
|
16
|
-
};
|
|
17
|
-
export declare const defaultOptimizeSubscriptions: (subs: Subscription[]) => {
|
|
18
|
-
relays: string[];
|
|
19
|
-
filters: Filter[];
|
|
20
|
-
}[];
|
|
21
|
-
export declare const eventValidationScores: Map<string, number>;
|
|
22
|
-
export declare const isEventValid: (url: string, event: TrustedEvent) => boolean;
|
|
23
|
-
export declare const getDefaultNetContext: (overrides?: Partial<NetContext>) => {
|
|
24
|
-
pool: Pool;
|
|
25
|
-
authMode: AuthMode;
|
|
26
|
-
onEvent: ((...args: unknown[]) => undefined) | ((url: string, event: TrustedEvent) => void);
|
|
27
|
-
signEvent: ((...args: unknown[]) => undefined) | ((event: StampedEvent) => Promise<SignedEvent | undefined>);
|
|
28
|
-
getExecutor: (relays: string[]) => Executor;
|
|
29
|
-
isDeleted: (url: string, event: TrustedEvent) => boolean;
|
|
30
|
-
isValid: (url: string, event: TrustedEvent) => boolean;
|
|
31
|
-
matchFilters: (url: string, filters: Filter[], event: TrustedEvent) => boolean;
|
|
32
|
-
optimizeSubscriptions: (subs: Subscription[]) => RelaysAndFilters[];
|
|
33
|
-
};
|
package/build/src/Context.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { ctx, randomInt, uniq, noop, always } from "@welshman/lib";
|
|
2
|
-
import { LOCAL_RELAY_URL, matchFilters, unionFilters, isSignedEvent, hasValidSignature, } from "@welshman/util";
|
|
3
|
-
import { Pool } from "./Pool.js";
|
|
4
|
-
import { Executor } from "./Executor.js";
|
|
5
|
-
import { AuthMode } from "./ConnectionAuth.js";
|
|
6
|
-
import { Relays } from "./target/Relays.js";
|
|
7
|
-
export const defaultOptimizeSubscriptions = (subs) => uniq(subs.flatMap(sub => sub.request.relays || [])).map(relay => {
|
|
8
|
-
const relaySubs = subs.filter(sub => sub.request.relays.includes(relay));
|
|
9
|
-
const filters = unionFilters(relaySubs.flatMap(sub => sub.request.filters));
|
|
10
|
-
return { relays: [relay], filters };
|
|
11
|
-
});
|
|
12
|
-
export const eventValidationScores = new Map();
|
|
13
|
-
export const isEventValid = (url, event) => {
|
|
14
|
-
if (url === LOCAL_RELAY_URL)
|
|
15
|
-
return true;
|
|
16
|
-
const validCount = eventValidationScores.get(url) || 0;
|
|
17
|
-
// The more events we've actually validated from this relay, the more we can trust it.
|
|
18
|
-
if (validCount > randomInt(100, 1000))
|
|
19
|
-
return true;
|
|
20
|
-
const isValid = isSignedEvent(event) && hasValidSignature(event);
|
|
21
|
-
// If the event was valid, increase the relay's score. If not, reset it
|
|
22
|
-
// Never validate less than 10% to make sure we're never totally checking out
|
|
23
|
-
if (!isValid || validCount < 900) {
|
|
24
|
-
eventValidationScores.set(url, isValid ? validCount + 1 : 0);
|
|
25
|
-
}
|
|
26
|
-
return isValid;
|
|
27
|
-
};
|
|
28
|
-
export const getDefaultNetContext = (overrides = {}) => ({
|
|
29
|
-
pool: new Pool(),
|
|
30
|
-
authMode: AuthMode.Implicit,
|
|
31
|
-
onEvent: noop,
|
|
32
|
-
signEvent: noop,
|
|
33
|
-
isDeleted: always(false),
|
|
34
|
-
isValid: isEventValid,
|
|
35
|
-
getExecutor: (relays) => new Executor(new Relays(relays.map((relay) => ctx.net.pool.get(relay)))),
|
|
36
|
-
matchFilters: (url, filters, event) => matchFilters(filters, event),
|
|
37
|
-
optimizeSubscriptions: defaultOptimizeSubscriptions,
|
|
38
|
-
...overrides,
|
|
39
|
-
});
|
|
40
|
-
//# sourceMappingURL=Context.js.map
|
package/build/src/Context.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Context.js","sourceRoot":"","sources":["../../src/Context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAC,MAAM,eAAe,CAAA;AAChE,OAAO,EACL,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,iBAAiB,GAClB,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAC9B,OAAO,EAAC,QAAQ,EAAC,MAAM,eAAe,CAAA;AACtC,OAAO,EAAC,QAAQ,EAAC,MAAM,qBAAqB,CAAA;AAC5C,OAAO,EAAC,MAAM,EAAC,MAAM,oBAAoB,CAAA;AAezC,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,IAAoB,EAAE,EAAE,CACnE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;IAC9D,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CA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E,YAAY;IACrB,WAAW,EAAE,CAAC,MAAgB,EAAE,EAAE,CAChC,IAAI,QAAQ,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAa,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAClF,YAAY,EAAE,CAAC,GAAW,EAAE,OAAiB,EAAE,KAAmB,EAAE,EAAE,CACpE,YAAY,CAAC,OAAO,EAAE,KAAK,CAAC;IAC9B,qBAAqB,EAAE,4BAA4B;IACnD,GAAG,SAAS;CACb,CAAC,CAAA"}
|
package/build/src/Executor.d.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import type { Emitter } from "@welshman/lib";
|
|
2
|
-
import type { SignedEvent, TrustedEvent, Filter } from "@welshman/util";
|
|
3
|
-
import type { Message } from "./Socket.js";
|
|
4
|
-
import type { Connection } from "./Connection.js";
|
|
5
|
-
export type Target = Emitter & {
|
|
6
|
-
connections: Connection[];
|
|
7
|
-
send: (...args: Message) => Promise<void>;
|
|
8
|
-
cleanup: () => void;
|
|
9
|
-
};
|
|
10
|
-
export type NegentropyMessage = {
|
|
11
|
-
have: string[];
|
|
12
|
-
need: string[];
|
|
13
|
-
};
|
|
14
|
-
type EventCallback = (url: string, event: TrustedEvent) => void;
|
|
15
|
-
type EoseCallback = (url: string) => void;
|
|
16
|
-
type CloseCallback = () => void;
|
|
17
|
-
type OkCallback = (url: string, id: string, ...extra: any[]) => void;
|
|
18
|
-
type ErrorCallback = (url: string, id: string, ...extra: any[]) => void;
|
|
19
|
-
type DiffMessage = {
|
|
20
|
-
have: string[];
|
|
21
|
-
need: string[];
|
|
22
|
-
};
|
|
23
|
-
type DiffMessageCallback = (url: string, { have, need }: DiffMessage) => void;
|
|
24
|
-
type SubscribeOpts = {
|
|
25
|
-
onEvent?: EventCallback;
|
|
26
|
-
onEose?: EoseCallback;
|
|
27
|
-
};
|
|
28
|
-
type PublishOpts = {
|
|
29
|
-
verb?: string;
|
|
30
|
-
onOk?: OkCallback;
|
|
31
|
-
onError?: ErrorCallback;
|
|
32
|
-
};
|
|
33
|
-
type DiffOpts = {
|
|
34
|
-
onError?: ErrorCallback;
|
|
35
|
-
onMessage?: DiffMessageCallback;
|
|
36
|
-
onClose?: CloseCallback;
|
|
37
|
-
};
|
|
38
|
-
export declare class Executor {
|
|
39
|
-
readonly target: Target;
|
|
40
|
-
constructor(target: Target);
|
|
41
|
-
subscribe(filters: Filter[], { onEvent, onEose }?: SubscribeOpts): {
|
|
42
|
-
unsubscribe: () => void;
|
|
43
|
-
};
|
|
44
|
-
publish(event: SignedEvent, { verb, onOk, onError }?: PublishOpts): {
|
|
45
|
-
unsubscribe: () => void;
|
|
46
|
-
};
|
|
47
|
-
diff(filter: Filter, events: TrustedEvent[], { onMessage, onError, onClose }?: DiffOpts): {
|
|
48
|
-
unsubscribe: () => void;
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
export {};
|
package/build/src/Executor.js
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { ctx, noop } from "@welshman/lib";
|
|
2
|
-
import { Negentropy, NegentropyStorageVector } from "./Negentropy.js";
|
|
3
|
-
const createSubId = (prefix) => `${prefix}-${Math.random().toString().slice(2, 10)}`;
|
|
4
|
-
export class Executor {
|
|
5
|
-
target;
|
|
6
|
-
constructor(target) {
|
|
7
|
-
this.target = target;
|
|
8
|
-
}
|
|
9
|
-
subscribe(filters, { onEvent, onEose } = {}) {
|
|
10
|
-
let closed = false;
|
|
11
|
-
const id = createSubId("REQ");
|
|
12
|
-
const eventListener = (url, subid, e) => {
|
|
13
|
-
if (subid === id) {
|
|
14
|
-
ctx.net.onEvent(url, e);
|
|
15
|
-
onEvent?.(url, e);
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
const eoseListener = (url, subid) => {
|
|
19
|
-
if (subid === id) {
|
|
20
|
-
onEose?.(url);
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
this.target.on("EVENT", eventListener);
|
|
24
|
-
this.target.on("EOSE", eoseListener);
|
|
25
|
-
this.target.send("REQ", id, ...filters);
|
|
26
|
-
return {
|
|
27
|
-
unsubscribe: () => {
|
|
28
|
-
if (closed)
|
|
29
|
-
return;
|
|
30
|
-
this.target.send("CLOSE", id).catch(noop);
|
|
31
|
-
this.target.off("EVENT", eventListener);
|
|
32
|
-
this.target.off("EOSE", eoseListener);
|
|
33
|
-
closed = true;
|
|
34
|
-
},
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
publish(event, { verb = "EVENT", onOk, onError } = {}) {
|
|
38
|
-
const okListener = (url, id, ok, message) => {
|
|
39
|
-
if (id === event.id) {
|
|
40
|
-
if (ok) {
|
|
41
|
-
ctx.net.onEvent(url, event);
|
|
42
|
-
}
|
|
43
|
-
onOk?.(url, id, ok, message);
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
const errorListener = (url, id, ...payload) => {
|
|
47
|
-
if (id === event.id) {
|
|
48
|
-
onError?.(url, id, ...payload);
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
this.target.on("OK", okListener);
|
|
52
|
-
this.target.on("ERROR", errorListener);
|
|
53
|
-
this.target.send(verb, event);
|
|
54
|
-
return {
|
|
55
|
-
unsubscribe: () => {
|
|
56
|
-
this.target.off("OK", okListener);
|
|
57
|
-
this.target.off("ERROR", errorListener);
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
diff(filter, events, { onMessage, onError, onClose } = {}) {
|
|
62
|
-
let closed = false;
|
|
63
|
-
const id = createSubId("NEG");
|
|
64
|
-
const storage = new NegentropyStorageVector();
|
|
65
|
-
const neg = new Negentropy(storage, 50_000);
|
|
66
|
-
for (const event of events) {
|
|
67
|
-
storage.insert(event.created_at, event.id);
|
|
68
|
-
}
|
|
69
|
-
storage.seal();
|
|
70
|
-
const msgListener = async (url, negid, msg) => {
|
|
71
|
-
if (negid === id) {
|
|
72
|
-
const [newMsg, have, need] = await neg.reconcile(msg);
|
|
73
|
-
onMessage?.(url, { have, need });
|
|
74
|
-
if (newMsg) {
|
|
75
|
-
this.target.send("NEG-MSG", id, newMsg);
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
close();
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
const errListener = (url, negid, msg) => {
|
|
83
|
-
if (negid === id) {
|
|
84
|
-
onError?.(url, msg);
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
const close = () => {
|
|
88
|
-
if (closed)
|
|
89
|
-
return;
|
|
90
|
-
this.target.send("NEG-CLOSE", id).catch(noop);
|
|
91
|
-
this.target.off("NEG-MSG", msgListener);
|
|
92
|
-
this.target.off("NEG-ERR", errListener);
|
|
93
|
-
closed = true;
|
|
94
|
-
onClose?.();
|
|
95
|
-
};
|
|
96
|
-
this.target.on("NEG-MSG", msgListener);
|
|
97
|
-
this.target.on("NEG-ERR", errListener);
|
|
98
|
-
neg.initiate().then((msg) => {
|
|
99
|
-
this.target.send("NEG-OPEN", id, filter, msg);
|
|
100
|
-
});
|
|
101
|
-
return {
|
|
102
|
-
unsubscribe: close,
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
//# sourceMappingURL=Executor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Executor.js","sourceRoot":"","sources":["../../src/Executor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,IAAI,EAAC,MAAM,eAAe,CAAA;AAKvC,OAAO,EAAC,UAAU,EAAE,uBAAuB,EAAC,MAAM,iBAAiB,CAAA;AAwBnE,MAAM,WAAW,GAAG,CAAC,MAAc,EAAE,EAAE,CAAC,GAAG,MAAM,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EA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G,GAAG,EAAE;YACjB,IAAI,MAAM;gBAAE,OAAM;YAElB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;YAC7C,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA;YACvC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA;YAEvC,MAAM,GAAG,IAAI,CAAA;YACb,OAAO,EAAE,EAAE,CAAA;QACb,CAAC,CAAA;QAED,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA;QACtC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA;QAEtC,GAAG,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAC,GAAW,EAAE,EAAE;YAClC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,CAAC,CAAA;QAC/C,CAAC,CAAC,CAAA;QAEF,OAAO;YACL,WAAW,EAAE,KAAK;SACnB,CAAA;IACH,CAAC;CACF"}
|
package/build/src/Pool.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Emitter } from "@welshman/lib";
|
|
2
|
-
import { Connection } from "./Connection.js";
|
|
3
|
-
export declare class Pool extends Emitter {
|
|
4
|
-
data: Map<string, Connection>;
|
|
5
|
-
constructor();
|
|
6
|
-
has(url: string): boolean;
|
|
7
|
-
get(url: string): Connection;
|
|
8
|
-
remove(url: string): void;
|
|
9
|
-
clear(): void;
|
|
10
|
-
}
|
package/build/src/Pool.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { Emitter } from "@welshman/lib";
|
|
2
|
-
import { Connection } from "./Connection.js";
|
|
3
|
-
export class Pool extends Emitter {
|
|
4
|
-
data;
|
|
5
|
-
constructor() {
|
|
6
|
-
super();
|
|
7
|
-
this.data = new Map();
|
|
8
|
-
}
|
|
9
|
-
has(url) {
|
|
10
|
-
return this.data.has(url);
|
|
11
|
-
}
|
|
12
|
-
get(url) {
|
|
13
|
-
const oldConnection = this.data.get(url);
|
|
14
|
-
if (oldConnection) {
|
|
15
|
-
return oldConnection;
|
|
16
|
-
}
|
|
17
|
-
const newConnection = new Connection(url);
|
|
18
|
-
this.data.set(url, newConnection);
|
|
19
|
-
this.emit("init", newConnection);
|
|
20
|
-
return newConnection;
|
|
21
|
-
}
|
|
22
|
-
remove(url) {
|
|
23
|
-
const connection = this.data.get(url);
|
|
24
|
-
if (connection) {
|
|
25
|
-
connection.cleanup();
|
|
26
|
-
this.data.delete(url);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
clear() {
|
|
30
|
-
for (const url of this.data.keys()) {
|
|
31
|
-
this.remove(url);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
//# sourceMappingURL=Pool.js.map
|
package/build/src/Pool.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Pool.js","sourceRoot":"","sources":["../../src/Pool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAA;AACrC,OAAO,EAAC,UAAU,EAAC,MAAM,iBAAiB,CAAA;AAE1C,MAAM,OAAO,IAAK,SAAQ,OAAO;IAC/B,IAAI,CAAyB;IAE7B;QACE,KAAK,EAAE,CAAA;QAEP,IAAI,CAAC,IAAI,GAAG,IAAI,GAAG,EAAE,CAAA;IACvB,CAAC;IAED,GAAG,CAAC,GAAW;QACb,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IAC3B,CAAC;IAED,GAAG,CAAC,GAAW;QACb,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAExC,IAAI,aAAa,EAAE,CAAC;YAClB,OAAO,aAAa,CAAA;QACtB,CAAC;QAED,MAAM,aAAa,GAAG,IAAI,UAAU,CAAC,GAAG,CAAC,CAAA;QAEzC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,aAAa,CAAC,CAAA;QACjC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;QAEhC,OAAO,aAAa,CAAA;IACtB,CAAC;IAED,MAAM,CAAC,GAAW;QAChB,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAErC,IAAI,UAAU,EAAE,CAAC;YACf,UAAU,CAAC,OAAO,EAAE,CAAA;YAEpB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QACvB,CAAC;IACH,CAAC;IAED,KAAK;QACH,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;YACnC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QAClB,CAAC;IACH,CAAC;CACF"}
|
package/build/src/Publish.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { Emitter } from "@welshman/lib";
|
|
2
|
-
import type { Deferred } from "@welshman/lib";
|
|
3
|
-
import type { SignedEvent } from "@welshman/util";
|
|
4
|
-
export declare enum PublishStatus {
|
|
5
|
-
Pending = "pending",
|
|
6
|
-
Success = "success",
|
|
7
|
-
Failure = "failure",
|
|
8
|
-
Timeout = "timeout",
|
|
9
|
-
Aborted = "aborted"
|
|
10
|
-
}
|
|
11
|
-
export type PublishStatusMap = Map<string, PublishStatus>;
|
|
12
|
-
export type PublishRequest = {
|
|
13
|
-
event: SignedEvent;
|
|
14
|
-
relays: string[];
|
|
15
|
-
signal?: AbortSignal;
|
|
16
|
-
timeout?: number;
|
|
17
|
-
verb?: "EVENT" | "AUTH";
|
|
18
|
-
};
|
|
19
|
-
export type Publish = {
|
|
20
|
-
id: string;
|
|
21
|
-
created_at: number;
|
|
22
|
-
emitter: Emitter;
|
|
23
|
-
request: PublishRequest;
|
|
24
|
-
status: PublishStatusMap;
|
|
25
|
-
result: Deferred<PublishStatusMap>;
|
|
26
|
-
};
|
|
27
|
-
export declare const makePublish: (request: PublishRequest) => {
|
|
28
|
-
id: string;
|
|
29
|
-
created_at: number;
|
|
30
|
-
request: PublishRequest;
|
|
31
|
-
emitter: Emitter;
|
|
32
|
-
result: Deferred<PublishStatusMap>;
|
|
33
|
-
status: PublishStatusMap;
|
|
34
|
-
};
|
|
35
|
-
export declare const publish: (request: PublishRequest) => {
|
|
36
|
-
id: string;
|
|
37
|
-
created_at: number;
|
|
38
|
-
request: PublishRequest;
|
|
39
|
-
emitter: Emitter;
|
|
40
|
-
result: Deferred<PublishStatusMap>;
|
|
41
|
-
status: PublishStatusMap;
|
|
42
|
-
};
|