@minip2p/core 0.8.3 → 0.10.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/README.md +10 -4
- package/dist/backend.d.ts +72 -13
- package/dist/backend.d.ts.map +1 -1
- package/dist/backend.js +69 -6
- package/dist/backend.js.map +1 -1
- package/dist/errors.d.ts +13 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +17 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/sdk.d.ts +30 -7
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +273 -46
- package/dist/sdk.js.map +1 -1
- package/dist/settle-handles.d.ts +30 -0
- package/dist/settle-handles.d.ts.map +1 -0
- package/dist/settle-handles.js +69 -0
- package/dist/settle-handles.js.map +1 -0
- package/dist/types.d.ts +154 -16
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +55 -2
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
- package/src/backend.ts +136 -15
- package/src/errors.ts +20 -0
- package/src/index.ts +7 -1
- package/src/sdk.ts +307 -50
- package/src/settle-handles.ts +78 -0
- package/src/types.ts +158 -18
package/README.md
CHANGED
|
@@ -17,7 +17,9 @@ await stream.write(new Uint8Array([1, 2, 3]));
|
|
|
17
17
|
stream.closeWrite();
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
Reading applies backpressure: a chunk counts as consumed when `read()` returns it or every `data` handler has returned from it, and each stream delivers at most one receive window that has not been consumed, so a reader that stops reading stalls its sender instead of losing data. An `async` `data` handler is consumed when it returns its Promise, not when the Promise settles; use `read()` to hold the sender back while asynchronous work runs.
|
|
20
|
+
Reading applies backpressure: a chunk counts as consumed when `read()` returns it or every `data` handler has returned from it, and each stream delivers at most one receive window that has not been consumed, so a reader that stops reading stalls its sender instead of losing data. An `async` `data` handler is consumed when it returns its Promise, not when the Promise settles; use `read()` to hold the sender back while asynchronous work runs. Unconsumed bytes keep holding native resources after their connection ends (ADR 0012): native keeps the ended connection's slot until they are consumed or the stream is abandoned, so the SDK still acknowledges bytes it discards or reads after a close. An endpoint whose application never consumes what it received can have native refuse new connections.
|
|
21
|
+
|
|
22
|
+
The endpoint's event queue keeps stream and connection-end events. A peer-opened stream, or a connection, that ends without carrying data before any of its events was dispatched leaves the queue whole, so peer churn cannot grow it; an unseen connection that is replaced folds into its successor.
|
|
21
23
|
|
|
22
24
|
Streams are async iterables. Iteration preserves chunk order, drains bytes buffered before a remote write half-close, and then ends quietly. Local shutdown, reset, peer disconnect, connection replacement, or driver failure rejects the iterator with its terminal error:
|
|
23
25
|
|
|
@@ -37,10 +39,14 @@ for await (const event of endpoint.events({ signal })) {
|
|
|
37
39
|
}
|
|
38
40
|
```
|
|
39
41
|
|
|
40
|
-
A peer holds one connection at a time. `connectionEstablished` and `connectionClosed` mark the peer connecting and disconnecting; when a newer connection takes the peer's slot, a single `connectionReplaced` (`{ peerId, oldConnId, newConnId }`) stands in for both, the peer stays connected, and streams and pending opens on `oldConnId` end with `StreamClosedError`. `peerReady` carries the `connId` that completed Identify and fires once per connection. `waitPeerReady` follows the peer's current connection, so a stale `peerReady` for a replaced connection never resolves it; it resolves at once when `connectionInfo(peerId).readyProtocols` shows the current connection is already ready, and rejects with `PeerDisconnectedError` when that connection closes.
|
|
42
|
+
A peer holds one connection at a time. `connectionEstablished` and `connectionClosed` mark the peer connecting and disconnecting, and `connectionClosed` carries a `reason` (`ConnectionCloseReason`: `local`, `remote` with the peer's `code`, `timedOut`, `stalled`, or `error` with a `message`); when a newer connection takes the peer's slot, a single `connectionReplaced` (`{ peerId, oldConnId, newConnId }`) stands in for both, the peer stays connected, and streams and pending opens on `oldConnId` end with `StreamClosedError`. `peerReady` carries the `connId` that completed Identify and fires once per connection. `waitPeerReady` follows the peer's current connection, so a stale `peerReady` for a replaced connection never resolves it; it resolves at once when `connectionInfo(peerId).readyProtocols` shows the current connection is already ready, and rejects with `PeerDisconnectedError` when that connection closes.
|
|
41
43
|
|
|
42
44
|
`connect` accepts a Connection target: a peer ID, one complete peer multiaddress, or a list of complete addresses naming one peer. For a Connection attempt, a timeout ends only the local wait (`cancelOnTimeout: true` opts into cancelling), an aborted `signal` cancels the attempt (the wait settles from its terminal), and a terminal lost to event overflow rejects with `ConnectResultLostError`. Waits never stop unrelated events from reaching other subscribers.
|
|
43
45
|
|
|
44
|
-
Use `endpoint.on("stream", handler)` to claim inbound streams. Operations accept `{ timeoutMs, signal }`; the default timeout is 65 seconds and `timeoutMs: 0` disables it.
|
|
46
|
+
Use `endpoint.on("stream", handler)` to claim inbound streams. Operations accept `{ timeoutMs, signal }`; the default timeout is 65 seconds and `timeoutMs: 0` disables it. Streams implement `Symbol.dispose`. `endpoint.close(timeoutMs = 500)` rejects outstanding operations at once, then resolves with an `EndpointCloseReport` (`{ reason, outcome?, unfinished }`) once native has disconnected peers and drained for up to `timeoutMs` (`0` tears down at once); `onClose` observers receive the same report then. The deadline bounds teardown time, not delivery of accepted writes. Endpoints implement `Symbol.asyncDispose` (awaits `close()`) and `Symbol.dispose` (starts it).
|
|
47
|
+
|
|
48
|
+
`create` throws `InvalidConfigError` when native rejects the configuration. Its `capability` (`Gossipsub`, `Mdns`, `Discovery`, `Transport`, or `Options`, from `ConfigCapability`) names the part to change, and `detail` carries the native diagnostic. A malformed listen address and a socket the platform refused are not config errors; they keep their native error codes.
|
|
49
|
+
|
|
50
|
+
With mDNS enabled, `mdnsFailed` (`{ kind, detail }`, `kind` from `MdnsFailureKind`) reports a hard mDNS failure once per change in failure state. mDNS keeps running and retries, and `mdnsRecovered` follows once a retry succeeds; a goodbye that failed during shutdown is final.
|
|
45
51
|
|
|
46
|
-
Raw native unions, the `Minip2pBackend` adapter contract, `resolveEndpointConfig` (shared config defaults and validation), and `typedFfiError` (native `FfiError` variant
|
|
52
|
+
Raw native unions, the `Minip2pBackend` adapter contract, `resolveEndpointConfig` (shared config defaults and validation), and `typedFfiError` (native `FfiError` variant to typed SDK error) are available from `@minip2p/core/backend`.
|
package/dist/backend.d.ts
CHANGED
|
@@ -1,4 +1,40 @@
|
|
|
1
|
+
import { CloseOutcome } from "./types.js";
|
|
1
2
|
import type { Bytes, ConnectionInfo, IdentifyInfo, KnownPeerInfo, Minip2pConfig, PathKind, P2pEvent, Reachability, RelayReservationInfo } from "./types.js";
|
|
3
|
+
/** How the native endpoint's close drain ended (`EndpointClosed`). */
|
|
4
|
+
export interface BackendClosed {
|
|
5
|
+
readonly outcome: CloseOutcome;
|
|
6
|
+
/** Peers whose connections were still tracked, each once. */
|
|
7
|
+
readonly unfinished: readonly string[];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The peers `EndpointClosed`'s unfinished connections name, each once. An
|
|
11
|
+
* inbound handshake that had not identified its peer names none.
|
|
12
|
+
*/
|
|
13
|
+
export declare const unfinishedPeers: (unfinished: readonly {
|
|
14
|
+
readonly peerId?: string | undefined;
|
|
15
|
+
}[]) => string[];
|
|
16
|
+
/**
|
|
17
|
+
* A native adapter's side of {@link Minip2pBackend.close}: stops native once,
|
|
18
|
+
* then resolves with the native `EndpointClosed` the adapter hands to
|
|
19
|
+
* {@link settle}, or at once when no driver started.
|
|
20
|
+
*/
|
|
21
|
+
export declare class NativeCloseLatch {
|
|
22
|
+
#private;
|
|
23
|
+
constructor();
|
|
24
|
+
/** Whether `close` was called; later native events can be ignored. */
|
|
25
|
+
get requested(): boolean;
|
|
26
|
+
/** Records the native `EndpointClosed`, which may precede `close`. */
|
|
27
|
+
settle(closed: BackendClosed): void;
|
|
28
|
+
/**
|
|
29
|
+
* Runs `stop` on the first call, then resolves once native closed and
|
|
30
|
+
* `release`, if any, ran. Later calls return the same promise.
|
|
31
|
+
*/
|
|
32
|
+
close(started: boolean, stop: () => void, release?: () => void): Promise<BackendClosed>;
|
|
33
|
+
}
|
|
34
|
+
/** A native connection snapshot: {@link ConnectionInfo} with the raw path. */
|
|
35
|
+
export interface BackendConnectionInfo extends Omit<ConnectionInfo, "path"> {
|
|
36
|
+
readonly path: PathKind;
|
|
37
|
+
}
|
|
2
38
|
/** Full native identity allocated for an outbound stream. */
|
|
3
39
|
export interface BackendOpenStream {
|
|
4
40
|
/** Endpoint-local connection carrying the stream. */
|
|
@@ -26,10 +62,19 @@ export type BackendConnectTarget = {
|
|
|
26
62
|
export interface Minip2pBackend {
|
|
27
63
|
/** Starts native event delivery exactly once. */
|
|
28
64
|
start: (listener: (event: P2pEvent) => void) => void;
|
|
29
|
-
/**
|
|
65
|
+
/**
|
|
66
|
+
* Releases adapter state retained until an event has been dispatched,
|
|
67
|
+
* elided, dropped, or coalesced into an earlier one.
|
|
68
|
+
*/
|
|
30
69
|
eventHandled?: (event: P2pEvent) => void;
|
|
31
|
-
/**
|
|
32
|
-
|
|
70
|
+
/**
|
|
71
|
+
* Requests native shutdown, draining for up to `timeoutMs` (`0` tears down
|
|
72
|
+
* at once), and resolves with the native `EndpointClosed`, the driver's
|
|
73
|
+
* last event, once the native endpoint is released. Idempotent: later
|
|
74
|
+
* calls return the same promise and their timeout is ignored. Resolves at
|
|
75
|
+
* once for a backend whose `start` failed. Never rejects.
|
|
76
|
+
*/
|
|
77
|
+
close: (timeoutMs: number) => Promise<BackendClosed>;
|
|
33
78
|
/** Returns the local peer ID. */
|
|
34
79
|
peerId: () => string;
|
|
35
80
|
/** Returns bound peer multiaddresses. */
|
|
@@ -46,10 +91,10 @@ export interface Minip2pBackend {
|
|
|
46
91
|
discoveryNowMs: () => number | undefined;
|
|
47
92
|
/** Returns the active relay reservation. */
|
|
48
93
|
activeReservation: () => RelayReservationInfo | undefined;
|
|
49
|
-
/** Returns the
|
|
94
|
+
/** Returns the path of a peer's established connection. */
|
|
50
95
|
path: (peerId: string) => PathKind | undefined;
|
|
51
|
-
/** Returns
|
|
52
|
-
connectionInfo: (peerId: string) =>
|
|
96
|
+
/** Returns a snapshot of a peer's established connection. */
|
|
97
|
+
connectionInfo: (peerId: string) => BackendConnectionInfo | undefined;
|
|
53
98
|
/** Builds a circuit address through a relay. */
|
|
54
99
|
circuitAddress: (relayAddress: string, peerId: string) => string;
|
|
55
100
|
/** Returns the native reachability state. */
|
|
@@ -87,8 +132,10 @@ export interface Minip2pBackend {
|
|
|
87
132
|
*
|
|
88
133
|
* Called once, when the stream becomes ready; the returned function keeps
|
|
89
134
|
* naming that stream after its terminal event retires the public IDs. It
|
|
90
|
-
* throws on an over-acknowledgement and is a no-op once the stream
|
|
91
|
-
* connection
|
|
135
|
+
* throws on an over-acknowledgement and is a no-op once the stream is
|
|
136
|
+
* settled. Unacknowledged bytes hold their ended connection's native slot,
|
|
137
|
+
* so this, and `abandonStream`, must still reach native for a stream whose
|
|
138
|
+
* connection ended while its events were in flight (see `SettleHandles`).
|
|
92
139
|
*/
|
|
93
140
|
streamConsumer: (connId: number, streamId: number) => (bytes: number) => void;
|
|
94
141
|
/** Half-closes the local stream write side, after any pending write. */
|
|
@@ -107,13 +154,25 @@ export interface Minip2pBackend {
|
|
|
107
154
|
export { resolveEndpointConfig, type BackendEndpointConfig } from "./config.js";
|
|
108
155
|
export { EventDrain } from "./event-drain.js";
|
|
109
156
|
export { ConnectionIdMap, u64ToNumber } from "./native-ids.js";
|
|
110
|
-
export {
|
|
157
|
+
export { SettleHandles, eventStream } from "./settle-handles.js";
|
|
158
|
+
export { ConnectionCloseReason_Tags, P2pEvent_Tags, PathKind_Tags, type P2pEvent, type P2pEventByTag, type PathKind, type RawConnectionCloseReason, } from "./types.js";
|
|
159
|
+
/**
|
|
160
|
+
* The parts of a native `FfiError` an adapter reads off its toolchain's error
|
|
161
|
+
* value: the variant name, its detail field, and an `InvalidConfig`'s
|
|
162
|
+
* capability as its Rust variant name.
|
|
163
|
+
*/
|
|
164
|
+
export interface NativeErrorFields {
|
|
165
|
+
readonly tag?: string | undefined;
|
|
166
|
+
readonly detail?: string | undefined;
|
|
167
|
+
readonly capability?: string | undefined;
|
|
168
|
+
}
|
|
111
169
|
/**
|
|
112
|
-
* Returns the typed SDK error for a native `FfiError
|
|
113
|
-
*
|
|
114
|
-
*
|
|
170
|
+
* Returns the typed SDK error for a native `FfiError`, or `undefined` for
|
|
171
|
+
* variants that adapters rethrow unchanged. An `InvalidConfig` whose
|
|
172
|
+
* capability is missing or unknown (native and SDK versions out of step)
|
|
173
|
+
* is rethrown unchanged too, rather than given a capability it did not name.
|
|
115
174
|
*/
|
|
116
|
-
export declare const typedFfiError: (
|
|
175
|
+
export declare const typedFfiError: ({ capability, detail, tag, }: NativeErrorFields) => Error | undefined;
|
|
117
176
|
/** Platform implementation used to construct endpoints and identity helpers. */
|
|
118
177
|
export interface Minip2pBackendFactory {
|
|
119
178
|
create: (config: Minip2pConfig) => Minip2pBackend;
|
package/dist/backend.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backend.d.ts","sourceRoot":"","sources":["../src/backend.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"backend.d.ts","sourceRoot":"","sources":["../src/backend.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,YAAY,EAAoB,MAAM,YAAY,CAAC;AAC5D,OAAO,KAAK,EACV,KAAK,EACL,cAAc,EACd,YAAY,EACZ,aAAa,EACb,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,oBAAoB,EACrB,MAAM,YAAY,CAAC;AAEpB,sEAAsE;AACtE,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAC/B,6DAA6D;IAC7D,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;CACxC;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,eACd,SAAS;IAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,EAAE,KAC9D,MAAM,EAIR,CAAC;AAEF;;;;GAIG;AACH,qBAAa,gBAAgB;;IAK3B,cA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ACjE,OAAO,EACL,0BAA0B,EAC1B,aAAa,EACb,aAAa,EACb,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,KAAK,QAAQ,EACb,KAAK,wBAAwB,GAC9B,MAAM,YAAY,CAAC;AAEpB;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1C;AAMD;;;;;GAKG;AACH,eAAO,MAAM,aAAa,iCAIvB,iBAAiB,KAAG,KAAK,GAAG,SAoB9B,CAAC;AAEF,gFAAgF;AAChF,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,cAAc,CAAC;IAClD,iBAAiB,EAAE,MAAM,UAAU,CAAC;IACpC,mBAAmB,EAAE,CAAC,SAAS,EAAE,KAAK,KAAK,MAAM,CAAC;IAClD,cAAc,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;CAClE"}
|
package/dist/backend.js
CHANGED
|
@@ -1,14 +1,72 @@
|
|
|
1
|
-
import { BackpressureError, MessageTooLargeError, NotPermittedError, } from "./errors.js";
|
|
1
|
+
import { BackpressureError, InvalidConfigError, MessageTooLargeError, NotPermittedError, } from "./errors.js";
|
|
2
|
+
import { CloseOutcome, ConfigCapability } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* The peers `EndpointClosed`'s unfinished connections name, each once. An
|
|
5
|
+
* inbound handshake that had not identified its peer names none.
|
|
6
|
+
*/
|
|
7
|
+
export const unfinishedPeers = (unfinished) => [
|
|
8
|
+
...new Set(unfinished.flatMap(({ peerId }) => (peerId === undefined ? [] : [peerId]))),
|
|
9
|
+
];
|
|
10
|
+
/**
|
|
11
|
+
* A native adapter's side of {@link Minip2pBackend.close}: stops native once,
|
|
12
|
+
* then resolves with the native `EndpointClosed` the adapter hands to
|
|
13
|
+
* {@link settle}, or at once when no driver started.
|
|
14
|
+
*/
|
|
15
|
+
export class NativeCloseLatch {
|
|
16
|
+
#closed;
|
|
17
|
+
#resolve;
|
|
18
|
+
#closing;
|
|
19
|
+
constructor() {
|
|
20
|
+
// oxlint-disable-next-line promise/avoid-new -- Settled by a native event, not a callback API.
|
|
21
|
+
this.#closed = new Promise((resolve) => {
|
|
22
|
+
this.#resolve = resolve;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
/** Whether `close` was called; later native events can be ignored. */
|
|
26
|
+
get requested() {
|
|
27
|
+
return this.#closing !== undefined;
|
|
28
|
+
}
|
|
29
|
+
/** Records the native `EndpointClosed`, which may precede `close`. */
|
|
30
|
+
settle(closed) {
|
|
31
|
+
this.#resolve?.(closed);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Runs `stop` on the first call, then resolves once native closed and
|
|
35
|
+
* `release`, if any, ran. Later calls return the same promise.
|
|
36
|
+
*/
|
|
37
|
+
close(started, stop, release) {
|
|
38
|
+
this.#closing ??= this.#finish(started, stop, release);
|
|
39
|
+
return this.#closing;
|
|
40
|
+
}
|
|
41
|
+
async #finish(started, stop, release) {
|
|
42
|
+
stop();
|
|
43
|
+
// Without a driver, native released the endpoint at once.
|
|
44
|
+
const closed = started
|
|
45
|
+
? await this.#closed
|
|
46
|
+
: { outcome: CloseOutcome.Drained, unfinished: [] };
|
|
47
|
+
try {
|
|
48
|
+
release?.();
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
// The endpoint is closed either way; the report still stands.
|
|
52
|
+
}
|
|
53
|
+
return closed;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
2
56
|
export { resolveEndpointConfig } from "./config.js";
|
|
3
57
|
export { EventDrain } from "./event-drain.js";
|
|
4
58
|
export { ConnectionIdMap, u64ToNumber } from "./native-ids.js";
|
|
5
|
-
export {
|
|
59
|
+
export { SettleHandles, eventStream } from "./settle-handles.js";
|
|
60
|
+
export { ConnectionCloseReason_Tags, P2pEvent_Tags, PathKind_Tags, } from "./types.js";
|
|
61
|
+
// Each capability's name is its value, so an own key is a capability.
|
|
62
|
+
const isConfigCapability = (name) => Object.hasOwn(ConfigCapability, name);
|
|
6
63
|
/**
|
|
7
|
-
* Returns the typed SDK error for a native `FfiError
|
|
8
|
-
*
|
|
9
|
-
*
|
|
64
|
+
* Returns the typed SDK error for a native `FfiError`, or `undefined` for
|
|
65
|
+
* variants that adapters rethrow unchanged. An `InvalidConfig` whose
|
|
66
|
+
* capability is missing or unknown (native and SDK versions out of step)
|
|
67
|
+
* is rethrown unchanged too, rather than given a capability it did not name.
|
|
10
68
|
*/
|
|
11
|
-
export const typedFfiError = (tag,
|
|
69
|
+
export const typedFfiError = ({ capability, detail, tag, }) => {
|
|
12
70
|
switch (tag) {
|
|
13
71
|
case "Backpressure": {
|
|
14
72
|
return new BackpressureError();
|
|
@@ -19,6 +77,11 @@ export const typedFfiError = (tag, detail) => {
|
|
|
19
77
|
case "NotPermitted": {
|
|
20
78
|
return new NotPermittedError(detail);
|
|
21
79
|
}
|
|
80
|
+
case "InvalidConfig": {
|
|
81
|
+
return capability !== undefined && isConfigCapability(capability)
|
|
82
|
+
? new InvalidConfigError(capability, detail ?? "")
|
|
83
|
+
: undefined;
|
|
84
|
+
}
|
|
22
85
|
default: {
|
|
23
86
|
return undefined;
|
|
24
87
|
}
|
package/dist/backend.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backend.js","sourceRoot":"","sources":["../src/backend.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"backend.js","sourceRoot":"","sources":["../src/backend.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,E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,CAAC,UAAU,EAAE,MAAM,IAAI,EAAE,CAAC;gBAClD,CAAC,CAAC,SAAS,CAAC;QAChB,CAAC;QACD,SAAS,CAAC;YACR,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;AACH,CAAC,CAAC"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DriverFailureKind, EndpointErrorKind, NatErrorKind } from "./types.js";
|
|
1
|
+
import type { ConfigCapability, DriverFailureKind, EndpointErrorKind, NatErrorKind } from "./types.js";
|
|
2
2
|
/** Pubsub rejected a publish because its bounded native queue is full. */
|
|
3
3
|
export declare class BackpressureError extends Error {
|
|
4
4
|
constructor();
|
|
@@ -11,6 +11,18 @@ export declare class MessageTooLargeError extends Error {
|
|
|
11
11
|
export declare class NotPermittedError extends Error {
|
|
12
12
|
constructor(message?: string);
|
|
13
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* The endpoint configuration was invalid. `capability` names the part of the
|
|
16
|
+
* configuration to change; a socket the platform refused is a transport
|
|
17
|
+
* failure instead, and a malformed listen address an invalid-address one.
|
|
18
|
+
*/
|
|
19
|
+
export declare class InvalidConfigError extends Error {
|
|
20
|
+
/** The part of the configuration that was invalid. */
|
|
21
|
+
readonly capability: ConfigCapability;
|
|
22
|
+
/** Human-readable native diagnostic. */
|
|
23
|
+
readonly detail: string;
|
|
24
|
+
constructor(capability: ConfigCapability, detail: string);
|
|
25
|
+
}
|
|
14
26
|
/** Platform-neutral operation cancellation error. */
|
|
15
27
|
export declare class AbortError extends Error {
|
|
16
28
|
constructor(message?: string);
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,YAAY,EACb,MAAM,YAAY,CAAC;AAEpB,0EAA0E;AAC1E,qBAAa,iBAAk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E;IAC9E,QAAQ,CAAC,IAAI,EAAE,iBAAiB,GAAG,aAAa,CAAC;IACjD,sBAAsB;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,gEAAgE;IAChE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,gDAAgD;IAChD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,mDAAmD;IACnD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB,YAAY,OAAO,EAAE;QACnB,IAAI,EAAE,iBAAiB,GAAG,aAAa,CAAC;QACxC,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,MAAM,EAAE,MAAM,CAAC;KAChB,EAQA;CACF;AAED,6DAA6D;AAC7D,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,YAAY,OAAO,SAA6C,EAG/D;CACF;AAED;;;;GAIG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,yEAAyE;IACzE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,yCAAyC;IACzC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAE/B,YAAY,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAOlD;CACF;AAED,yEAAyE;AACzE,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,cAGC;CACF"}
|
package/dist/errors.js
CHANGED
|
@@ -20,6 +20,23 @@ export class NotPermittedError extends Error {
|
|
|
20
20
|
this.name = "NotPermittedError";
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* The endpoint configuration was invalid. `capability` names the part of the
|
|
25
|
+
* configuration to change; a socket the platform refused is a transport
|
|
26
|
+
* failure instead, and a malformed listen address an invalid-address one.
|
|
27
|
+
*/
|
|
28
|
+
export class InvalidConfigError extends Error {
|
|
29
|
+
/** The part of the configuration that was invalid. */
|
|
30
|
+
capability;
|
|
31
|
+
/** Human-readable native diagnostic. */
|
|
32
|
+
detail;
|
|
33
|
+
constructor(capability, detail) {
|
|
34
|
+
super(detail.length > 0 ? detail : `Invalid ${capability} configuration`);
|
|
35
|
+
this.name = "InvalidConfigError";
|
|
36
|
+
this.capability = capability;
|
|
37
|
+
this.detail = detail;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
23
40
|
/** Platform-neutral operation cancellation error. */
|
|
24
41
|
export class AbortError extends Error {
|
|
25
42
|
constructor(message = "The operation was aborted") {
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,4FAA4F;
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAS5F,0EAA0E;AAC1E,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAC1C;QACE,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACzC,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF;AAED,wDAAwD;AACxD,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAC7C;QACE,KAAK,CAAC,kDAAkD,CAAC,CAAC;QAC1D,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;AAED,2DAA2D;AAC3D,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAC1C,YAAY,OAAO,GAAG,gCAAgC;QACpD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC3C,sDAAsD;IAC7C,UAAU,CAAmB;IACtC,wCAAwC;IAC/B,MAAM,CAAS;IAExB,YAAY,UAA4B,EAAE,MAAc;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B,CAAC;CACF;AAED,6DAA6D;AAC7D,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAC1C,YAAY,OAAO,GAAG,0CAA0C;QAC9D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAC7C,yEAAyE;IAChE,QAAQ,CAAS;IAC1B,yCAAyC;IAChC,aAAa,CAAS;IAE/B,YAAY,QAAgB,EAAE,aAAqB;QACjD,KAAK,CACH,qCAAqC,QAAQ,6CAA6C,aAAa,GAAG,CAC3G,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;QACnC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;CACF;AAED,yEAAyE;AACzE,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAChD;QACE,KAAK,CAAC,kEAAkE,CAAC,CAAC;QAC1E,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;IACxC,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { AbortError, BackpressureError, ClosedError, ConnectCancelledError, ConnectFailedError, ConnectResultLostError, ConnectResultUnavailableError, DriverFailedError, EventQueueOverflowError, MessageTooLargeError, NotPermittedError, OpenStreamError, PeerDisconnectedError, StreamClosedError, TimeoutError, WriteBufferFullError, } from "./errors.js";
|
|
1
|
+
export { AbortError, BackpressureError, ClosedError, ConnectCancelledError, ConnectFailedError, ConnectResultLostError, ConnectResultUnavailableError, DriverFailedError, EventQueueOverflowError, InvalidConfigError, MessageTooLargeError, NotPermittedError, OpenStreamError, PeerDisconnectedError, StreamClosedError, TimeoutError, WriteBufferFullError, } from "./errors.js";
|
|
2
2
|
export { Minip2pBase, Stream, type StreamEventMap } from "./sdk.js";
|
|
3
|
-
export { DiscoverySource, DriverFailureKind, EndpointErrorKind, NatErrorKind, Reachability, type Bytes, type
|
|
3
|
+
export { CloseOutcome, ConfigCapability, DiscoverySource, DriverFailureKind, EndpointErrorKind, MdnsFailureKind, NatErrorKind, Reachability, type Bytes, type ConnectionCloseReason, type ConnectionInfo, type ConnectOptions, type ConnectResult, type ConnectTarget, type EndpointCloseReason, type EndpointCloseReport, type EventsOptions, type IdentifyInfo, type InboundStreamMeta, type KnownPeerInfo, type Minip2pCatchAllEventMap, type Minip2pConfig, type Minip2pDiscoveryOptions, type Minip2pEvent, type Minip2pMdnsOptions, type Minip2pNamedEventMap, type OnceOptions, type OpOptions, type Path, type RelayReservationInfo, type Unsubscribe, type WaitForOptions, } from "./types.js";
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,WAAW,EACX,qBAAqB,EACrB,kBAAkB,EAClB,sBAAsB,EACtB,6BAA6B,EAC7B,iBAAiB,EACjB,uBAAuB,EACvB,oBAAoB,EACpB,iBAAiB,EACjB,eAAe,EACf,qBAAqB,EACrB,iBAAiB,EACjB,YAAY,EACZ,oBAAoB,GACrB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,cAAc,EAAE,MAAM,UAAU,CAAC;AACpE,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,KAAK,KAAK,EACV,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,WAAW,EACX,qBAAqB,EACrB,kBAAkB,EAClB,sBAAsB,EACtB,6BAA6B,EAC7B,iBAAiB,EACjB,uBAAuB,EACvB,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,eAAe,EACf,qBAAqB,EACrB,iBAAiB,EACjB,YAAY,EACZ,oBAAoB,GACrB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,cAAc,EAAE,MAAM,UAAU,CAAC;AACpE,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,KAAK,KAAK,EACV,KAAK,qBAAqB,EAC1B,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,uBAAuB,EAC5B,KAAK,aAAa,EAClB,KAAK,uBAAuB,EAC5B,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,IAAI,EACT,KAAK,oBAAoB,EACzB,KAAK,WAAW,EAChB,KAAK,cAAc,GACpB,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { AbortError, BackpressureError, ClosedError, ConnectCancelledError, ConnectFailedError, ConnectResultLostError, ConnectResultUnavailableError, DriverFailedError, EventQueueOverflowError, MessageTooLargeError, NotPermittedError, OpenStreamError, PeerDisconnectedError, StreamClosedError, TimeoutError, WriteBufferFullError, } from "./errors.js";
|
|
1
|
+
export { AbortError, BackpressureError, ClosedError, ConnectCancelledError, ConnectFailedError, ConnectResultLostError, ConnectResultUnavailableError, DriverFailedError, EventQueueOverflowError, InvalidConfigError, MessageTooLargeError, NotPermittedError, OpenStreamError, PeerDisconnectedError, StreamClosedError, TimeoutError, WriteBufferFullError, } from "./errors.js";
|
|
2
2
|
export { Minip2pBase, Stream } from "./sdk.js";
|
|
3
|
-
export { DiscoverySource, DriverFailureKind, EndpointErrorKind, NatErrorKind, Reachability, } from "./types.js";
|
|
3
|
+
export { CloseOutcome, ConfigCapability, DiscoverySource, DriverFailureKind, EndpointErrorKind, MdnsFailureKind, NatErrorKind, Reachability, } from "./types.js";
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,WAAW,EACX,qBAAqB,EACrB,kBAAkB,EAClB,sBAAsB,EACtB,6BAA6B,EAC7B,iBAAiB,EACjB,uBAAuB,EACvB,oBAAoB,EACpB,iBAAiB,EACjB,eAAe,EACf,qBAAqB,EACrB,iBAAiB,EACjB,YAAY,EACZ,oBAAoB,GACrB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,WAAW,EAAE,MAAM,EAAuB,MAAM,UAAU,CAAC;AACpE,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,YAAY,EACZ,YAAY,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,WAAW,EACX,qBAAqB,EACrB,kBAAkB,EAClB,sBAAsB,EACtB,6BAA6B,EAC7B,iBAAiB,EACjB,uBAAuB,EACvB,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,eAAe,EACf,qBAAqB,EACrB,iBAAiB,EACjB,YAAY,EACZ,oBAAoB,GACrB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,WAAW,EAAE,MAAM,EAAuB,MAAM,UAAU,CAAC;AACpE,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,YAAY,GAyBb,MAAM,YAAY,CAAC"}
|
package/dist/sdk.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Minip2pBackend } from "./backend.js";
|
|
2
|
-
import type { Bytes,
|
|
2
|
+
import type { Bytes, ConnectionInfo, ConnectOptions, ConnectResult, ConnectTarget, EndpointCloseReport, EventsOptions, IdentifyInfo, InboundStreamMeta, KnownPeerInfo, Minip2pEvent, Minip2pNamedEventMap, OnceOptions, OpOptions, Path, Reachability, RelayReservationInfo, Unsubscribe, WaitForOptions } from "./types.js";
|
|
3
3
|
type EventKind = keyof Minip2pNamedEventMap;
|
|
4
4
|
type NamedHandler<Kind extends EventKind> = (payload: Minip2pNamedEventMap[Kind]) => void;
|
|
5
5
|
type CatchAllHandler = (event: Minip2pEvent) => void;
|
|
@@ -145,11 +145,27 @@ export declare class Minip2pBase {
|
|
|
145
145
|
} & Minip2pNamedEventMap[Kind]>): Promise<{
|
|
146
146
|
readonly type: Kind;
|
|
147
147
|
} & Minip2pNamedEventMap[Kind]>;
|
|
148
|
-
/**
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
148
|
+
/**
|
|
149
|
+
* Registers a one-shot endpoint shutdown observer. It stays registered
|
|
150
|
+
* through the native close drain and fires once that finishes, with the
|
|
151
|
+
* same report {@link close} resolves with. A no-op once it has fired.
|
|
152
|
+
*/
|
|
153
|
+
onClose(handler: (report: EndpointCloseReport) => void): Unsubscribe;
|
|
154
|
+
/**
|
|
155
|
+
* Stops the endpoint: rejects outstanding operations and drops listeners
|
|
156
|
+
* at once, then has native disconnect peers and drain for up to
|
|
157
|
+
* `timeoutMs` (default 500; `0` tears down at once, best effort). Resolves
|
|
158
|
+
* with the close report once the drain finished, after `onClose`
|
|
159
|
+
* observers ran; it never rejects. The deadline bounds teardown time only,
|
|
160
|
+
* not delivery of accepted writes: QUIC discards queued writes and TCP may
|
|
161
|
+
* abort. Idempotent: a later call returns the same promise, including
|
|
162
|
+
* after a driver failure closed the endpoint.
|
|
163
|
+
*/
|
|
164
|
+
close(timeoutMs?: number): Promise<EndpointCloseReport>;
|
|
165
|
+
/** Starts {@link close} with the default drain, without waiting for it. */
|
|
152
166
|
[Symbol.dispose](): void;
|
|
167
|
+
/** {@link close} with the default drain, for `await using`. */
|
|
168
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
153
169
|
/** Returns this endpoint's base58 peer ID. */
|
|
154
170
|
peerId(): string;
|
|
155
171
|
/** Returns the currently bound peer multiaddresses. */
|
|
@@ -170,9 +186,16 @@ export declare class Minip2pBase {
|
|
|
170
186
|
get circuitAddress(): string | undefined;
|
|
171
187
|
/** Returns the latest AutoNAT reachability verdict. */
|
|
172
188
|
reachability(): Reachability;
|
|
173
|
-
/**
|
|
189
|
+
/**
|
|
190
|
+
* Returns the path of `peerId`'s established connection; `undefined` only
|
|
191
|
+
* while the peer is not connected.
|
|
192
|
+
*/
|
|
174
193
|
path(peerId: string): Path | undefined;
|
|
175
|
-
/**
|
|
194
|
+
/**
|
|
195
|
+
* Returns a snapshot of `peerId`'s established connection: its connection
|
|
196
|
+
* ID, remote address, path, and Identify protocols once ready;
|
|
197
|
+
* `undefined` while the peer is not connected.
|
|
198
|
+
*/
|
|
176
199
|
connectionInfo(peerId: string): ConnectionInfo | undefined;
|
|
177
200
|
/** Returns whether the native driver is accepting work. */
|
|
178
201
|
isRunning(): boolean;
|
package/dist/sdk.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAGV,cAAc,EACf,MAAM,cAAc,CAAC;AAsBtB,OAAO,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