@cero-base/core 1.18.2 → 2.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/README.md +5 -6
- package/package.json +14 -11
- package/src/blobs/index.js +17 -17
- package/src/blobs/server.js +0 -2
- package/src/database/changes.js +34 -60
- package/src/database/dispatch.js +156 -245
- package/src/database/encryption.js +22 -52
- package/src/database/envelope.js +1 -3
- package/src/database/index.js +514 -513
- package/src/database/rotation.js +191 -193
- package/src/identity/index.js +8 -12
- package/src/index.js +5 -9
- package/src/lib/constants.js +3 -12
- package/src/lib/errors.js +6 -10
- package/src/lib/schema.js +2 -5
- package/src/lib/utils.js +55 -38
- package/src/network/index.js +138 -166
- package/src/pairing/candidate.js +123 -0
- package/src/pairing/index.js +36 -267
- package/src/pairing/invite.js +3 -4
- package/src/pairing/request.js +96 -0
- package/src/rpc/index.js +4 -14
- package/src/rpc/peer.js +3 -7
- package/src/storage/index.js +36 -49
- package/types/blobs/codec.d.ts +8 -8
- package/types/blobs/index.d.ts +38 -37
- package/types/blobs/server.d.ts +8 -10
- package/types/database/changes.d.ts +3 -8
- package/types/database/dispatch.d.ts +28 -25
- package/types/database/encryption.d.ts +22 -30
- package/types/database/envelope.d.ts +2 -2
- package/types/database/index.d.ts +196 -221
- package/types/database/rotation.d.ts +47 -30
- package/types/identity/index.d.ts +83 -87
- package/types/index.d.ts +42 -55
- package/types/lib/constants.d.ts +34 -38
- package/types/lib/errors.d.ts +16 -20
- package/types/lib/schema.d.ts +49 -42
- package/types/lib/spec/index.d.ts +29 -55
- package/types/lib/utils.d.ts +26 -20
- package/types/network/discovery.d.ts +7 -7
- package/types/network/index.d.ts +64 -72
- package/types/pairing/candidate.d.ts +36 -0
- package/types/pairing/index.d.ts +91 -151
- package/types/pairing/invite.d.ts +91 -91
- package/types/pairing/request.d.ts +133 -0
- package/types/rpc/client.d.ts +2 -2
- package/types/rpc/index.d.ts +30 -33
- package/types/rpc/peer.d.ts +11 -11
- package/types/rpc/server.d.ts +2 -2
- package/types/storage/index.d.ts +70 -71
- package/src/database/bootstrap.js +0 -133
- package/src/database/hooks.js +0 -112
- package/src/database/membership.js +0 -67
- package/types/database/bootstrap.d.ts +0 -20
- package/types/database/hooks.d.ts +0 -8
- package/types/database/membership.d.ts +0 -7
|
@@ -1,23 +1,37 @@
|
|
|
1
|
-
|
|
1
|
+
declare let version: number;
|
|
2
|
+
declare function setVersion(v: any): void;
|
|
3
|
+
declare function encode(name: any, value: any, v?: number): any;
|
|
4
|
+
declare function decode(name: any, buffer: any, v?: number): any;
|
|
5
|
+
declare function getEnum(name: any): void;
|
|
6
|
+
declare function getEncoding(name: any): {
|
|
2
7
|
preencode(state: any, m: any): void;
|
|
3
8
|
encode(state: any, m: any): void;
|
|
4
9
|
decode(state: any): {
|
|
5
|
-
prev: any;
|
|
6
|
-
next: any;
|
|
7
|
-
} | {
|
|
8
10
|
status: any;
|
|
9
11
|
reason: any;
|
|
10
12
|
key: any;
|
|
11
13
|
encryptionKey: any;
|
|
12
14
|
extra: any;
|
|
13
|
-
}
|
|
15
|
+
};
|
|
16
|
+
} | {
|
|
17
|
+
preencode(state: any, m: any): void;
|
|
18
|
+
encode(state: any, m: any): void;
|
|
19
|
+
decode(state: any): {
|
|
14
20
|
data: any;
|
|
15
|
-
}
|
|
21
|
+
};
|
|
22
|
+
} | {
|
|
23
|
+
preencode(state: any, m: any): void;
|
|
24
|
+
encode(state: any, m: any): void;
|
|
25
|
+
decode(state: any): {
|
|
16
26
|
id: any;
|
|
17
27
|
name: any;
|
|
18
28
|
role: any;
|
|
19
29
|
noAccept: boolean;
|
|
20
|
-
}
|
|
30
|
+
};
|
|
31
|
+
} | {
|
|
32
|
+
preencode(state: any, m: any): void;
|
|
33
|
+
encode(state: any, m: any): void;
|
|
34
|
+
decode(state: any): {
|
|
21
35
|
coreKey: any;
|
|
22
36
|
blockOffset: any;
|
|
23
37
|
blockLength: any;
|
|
@@ -25,37 +39,15 @@ export function resolveStruct(name: any, v?: number): {
|
|
|
25
39
|
byteLength: any;
|
|
26
40
|
type: any;
|
|
27
41
|
};
|
|
28
|
-
}
|
|
29
|
-
export function getStruct(name: any, v?: number): {
|
|
42
|
+
} | {
|
|
30
43
|
preencode(state: any, m: any): void;
|
|
31
44
|
encode(state: any, m: any): void;
|
|
32
45
|
decode(state: any): {
|
|
33
46
|
prev: any;
|
|
34
47
|
next: any;
|
|
35
|
-
} | {
|
|
36
|
-
status: any;
|
|
37
|
-
reason: any;
|
|
38
|
-
key: any;
|
|
39
|
-
encryptionKey: any;
|
|
40
|
-
extra: any;
|
|
41
|
-
} | {
|
|
42
|
-
data: any;
|
|
43
|
-
} | {
|
|
44
|
-
id: any;
|
|
45
|
-
name: any;
|
|
46
|
-
role: any;
|
|
47
|
-
noAccept: boolean;
|
|
48
|
-
} | {
|
|
49
|
-
coreKey: any;
|
|
50
|
-
blockOffset: any;
|
|
51
|
-
blockLength: any;
|
|
52
|
-
byteOffset: any;
|
|
53
|
-
byteLength: any;
|
|
54
|
-
type: any;
|
|
55
48
|
};
|
|
56
49
|
};
|
|
57
|
-
|
|
58
|
-
export function getEncoding(name: any): {
|
|
50
|
+
declare function getStruct(name: any, v?: number): {
|
|
59
51
|
preencode(state: any, m: any): void;
|
|
60
52
|
encode(state: any, m: any): void;
|
|
61
53
|
decode(state: any): {
|
|
@@ -64,42 +56,24 @@ export function getEncoding(name: any): {
|
|
|
64
56
|
key: any;
|
|
65
57
|
encryptionKey: any;
|
|
66
58
|
extra: any;
|
|
67
|
-
}
|
|
68
|
-
} | {
|
|
69
|
-
preencode(state: any, m: any): void;
|
|
70
|
-
encode(state: any, m: any): void;
|
|
71
|
-
decode(state: any): {
|
|
59
|
+
} | {
|
|
72
60
|
data: any;
|
|
73
|
-
}
|
|
74
|
-
} | {
|
|
75
|
-
preencode(state: any, m: any): void;
|
|
76
|
-
encode(state: any, m: any): void;
|
|
77
|
-
decode(state: any): {
|
|
61
|
+
} | {
|
|
78
62
|
id: any;
|
|
79
63
|
name: any;
|
|
80
64
|
role: any;
|
|
81
65
|
noAccept: boolean;
|
|
82
|
-
}
|
|
83
|
-
} | {
|
|
84
|
-
preencode(state: any, m: any): void;
|
|
85
|
-
encode(state: any, m: any): void;
|
|
86
|
-
decode(state: any): {
|
|
66
|
+
} | {
|
|
87
67
|
coreKey: any;
|
|
88
68
|
blockOffset: any;
|
|
89
69
|
blockLength: any;
|
|
90
70
|
byteOffset: any;
|
|
91
71
|
byteLength: any;
|
|
92
72
|
type: any;
|
|
93
|
-
}
|
|
94
|
-
} | {
|
|
95
|
-
preencode(state: any, m: any): void;
|
|
96
|
-
encode(state: any, m: any): void;
|
|
97
|
-
decode(state: any): {
|
|
73
|
+
} | {
|
|
98
74
|
prev: any;
|
|
99
75
|
next: any;
|
|
100
76
|
};
|
|
101
77
|
};
|
|
102
|
-
|
|
103
|
-
export
|
|
104
|
-
export function setVersion(v: any): void;
|
|
105
|
-
export let version: number;
|
|
78
|
+
declare const resolveStruct: typeof getStruct;
|
|
79
|
+
export { resolveStruct, getStruct, getEnum, getEncoding, encode, decode, setVersion, version };
|
package/types/lib/utils.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
export { WRITE, INVITE, ASSIGN, REMOVE } from './constants.js';
|
|
1
2
|
/**
|
|
2
3
|
* Generate a short opaque id (z32-encoded 16 random bytes).
|
|
3
4
|
*
|
|
4
5
|
* @returns {string}
|
|
5
6
|
*/
|
|
6
|
-
export function genId(): string;
|
|
7
|
-
|
|
8
|
-
export function
|
|
7
|
+
export declare function genId(): string;
|
|
8
|
+
/** @type {(dbKey: Uint8Array, writer: Uint8Array, appender: Uint8Array) => Uint8Array} */
|
|
9
|
+
export declare function admission(dbKey: Uint8Array<ArrayBufferLike>, writer: Uint8Array<ArrayBufferLike>, appender: Uint8Array<ArrayBufferLike>): Uint8Array<ArrayBufferLike>;
|
|
10
|
+
/** @type {(dbKey: Uint8Array, writer: Uint8Array) => Uint8Array} */
|
|
11
|
+
export declare function ownership(dbKey: Uint8Array<ArrayBufferLike>, writer: Uint8Array<ArrayBufferLike>): Uint8Array<ArrayBufferLike>;
|
|
9
12
|
/**
|
|
10
13
|
* Whether `role` is granted `perm` under the default policy.
|
|
11
14
|
*
|
|
@@ -13,14 +16,13 @@ export function claimWriterPayload(dbKey: Uint8Array, writer: Uint8Array): Uint8
|
|
|
13
16
|
* @param {string} perm
|
|
14
17
|
* @returns {boolean}
|
|
15
18
|
*/
|
|
16
|
-
export function can(role: string, perm: string): boolean;
|
|
17
|
-
export function isRank(role: any): boolean;
|
|
18
|
-
export function grants(a: any, b: any): boolean;
|
|
19
|
-
export function outranks(a: any, b: any): boolean;
|
|
19
|
+
export declare function can(role: string, perm: string): boolean;
|
|
20
|
+
export declare function isRank(role: any): boolean;
|
|
21
|
+
export declare function grants(a: any, b: any): boolean;
|
|
22
|
+
export declare function outranks(a: any, b: any): boolean;
|
|
20
23
|
/**
|
|
21
|
-
* Stream-of-snapshots primitive. Couples a `get` (returns the latest value)
|
|
22
|
-
*
|
|
23
|
-
* time `watch` ticks.
|
|
24
|
+
* Stream-of-snapshots primitive. Couples a `get` (returns the latest value) with a `watch`
|
|
25
|
+
* (re-fires on change) and emits the newest snapshot every time `watch` ticks.
|
|
24
26
|
*
|
|
25
27
|
* @template T
|
|
26
28
|
* @param {object} args
|
|
@@ -28,21 +30,25 @@ export function outranks(a: any, b: any): boolean;
|
|
|
28
30
|
* @param {(fn: () => void) => (() => void) | void} args.watch
|
|
29
31
|
* @returns {import('streamx').Readable<T>}
|
|
30
32
|
*/
|
|
31
|
-
export function subscribe<T>({ get, watch }: {
|
|
33
|
+
export declare function subscribe<T>({ get, watch }: {
|
|
32
34
|
get: () => Promise<T> | T;
|
|
33
35
|
watch: (fn: () => void) => (() => void) | void;
|
|
34
|
-
}): import(
|
|
35
|
-
export function searchHit(row: any, term: any, fields: any): boolean;
|
|
36
|
+
}): import('streamx').Readable<T>;
|
|
37
|
+
export declare function searchHit(row: any, term: any, fields: any): boolean;
|
|
36
38
|
/**
|
|
37
|
-
*
|
|
39
|
+
* The in-memory query grammar over rows: equality on any non-reserved field,
|
|
40
|
+
* id ranges, `search`, then `reverse` and `limit`.
|
|
38
41
|
*
|
|
39
|
-
* @
|
|
42
|
+
* @param {any[]} rows
|
|
43
|
+
* @param {Record<string, any>} [query]
|
|
44
|
+
* @returns {any[]}
|
|
40
45
|
*/
|
|
41
|
-
export
|
|
46
|
+
export declare function filter(rows: any[], query?: Record<string, any>): any[];
|
|
42
47
|
/**
|
|
43
|
-
*
|
|
48
|
+
* Run `cb` when `signal` aborts — or immediately if it already has.
|
|
44
49
|
*
|
|
45
|
-
* @
|
|
50
|
+
* @param {AbortSignal | undefined} signal
|
|
51
|
+
* @param {() => void} cb
|
|
52
|
+
* @returns {(() => void) | undefined}
|
|
46
53
|
*/
|
|
47
|
-
export
|
|
48
|
-
export { WRITE, INVITE, ASSIGN, REMOVE } from "./constants.js";
|
|
54
|
+
export declare function onAbort(signal: AbortSignal | undefined, cb: () => void): (() => void) | undefined;
|
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
* Handle for a single topic membership on a {@link Network}. Wraps a hyperswarm
|
|
3
3
|
* PeerDiscovery session and lets it switch between active/passive announce/lookup.
|
|
4
4
|
*/
|
|
5
|
-
export class Discovery {
|
|
5
|
+
export declare class Discovery {
|
|
6
|
+
network: import("./index.js").Network;
|
|
7
|
+
session: any;
|
|
8
|
+
_mode: "active" | "passive";
|
|
9
|
+
_destroyed: boolean;
|
|
6
10
|
/**
|
|
7
11
|
* @param {import('./index.js').Network} network Owning network.
|
|
8
12
|
* @param {any} session Hyperswarm PeerDiscovery session from `swarm.join()`.
|
|
9
13
|
* @param {'active' | 'passive'} mode
|
|
10
14
|
*/
|
|
11
|
-
constructor(network: import(
|
|
12
|
-
network: import("./index.js").Network;
|
|
13
|
-
session: any;
|
|
14
|
-
_mode: "active" | "passive";
|
|
15
|
-
_destroyed: boolean;
|
|
15
|
+
constructor(network: import('./index.js').Network, session: any, mode: 'active' | 'passive');
|
|
16
16
|
/** @returns {'active' | 'passive'} */
|
|
17
|
-
get mode():
|
|
17
|
+
get mode(): 'active' | 'passive';
|
|
18
18
|
/** @returns {boolean} */
|
|
19
19
|
get destroyed(): boolean;
|
|
20
20
|
/**
|
package/types/network/index.d.ts
CHANGED
|
@@ -1,4 +1,46 @@
|
|
|
1
|
-
|
|
1
|
+
import ReadyResource from 'ready-resource';
|
|
2
|
+
import { Discovery } from './discovery.js';
|
|
3
|
+
export declare function channelTopic(topic: any, channel: any): any;
|
|
4
|
+
export type NetworkOpts = {
|
|
5
|
+
/**
|
|
6
|
+
* Long-lived keypair used as the swarm identity.
|
|
7
|
+
*/
|
|
8
|
+
identity?: import('../identity/index.js').Identity;
|
|
9
|
+
/**
|
|
10
|
+
* Custom DHT bootstrap nodes.
|
|
11
|
+
*/
|
|
12
|
+
bootstrap?: Array<{
|
|
13
|
+
host: string;
|
|
14
|
+
port: number;
|
|
15
|
+
}>;
|
|
16
|
+
/**
|
|
17
|
+
* Incoming-connection filter.
|
|
18
|
+
*/
|
|
19
|
+
firewall?: (remotePublicKey: Uint8Array, payload: any) => boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Relay public keys to tunnel through.
|
|
22
|
+
*/
|
|
23
|
+
relayThrough?: Uint8Array[];
|
|
24
|
+
/**
|
|
25
|
+
* Reconnect backoff tiers in ms; the default escalates to ~10min, far too slow for local nets.
|
|
26
|
+
*/
|
|
27
|
+
backoffs?: number[];
|
|
28
|
+
/**
|
|
29
|
+
* Optional network-isolation label; only same-channel peers meet.
|
|
30
|
+
*/
|
|
31
|
+
channel?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Corestore; required for mirrors (blind peers replicate its cores).
|
|
34
|
+
*/
|
|
35
|
+
store?: any;
|
|
36
|
+
/**
|
|
37
|
+
* Blind-peer public keys; each attached room/blob core is mirrored through them for offline sync.
|
|
38
|
+
*/
|
|
39
|
+
mirrors?: Array<string | Uint8Array>;
|
|
40
|
+
};
|
|
41
|
+
export type Replicable = {
|
|
42
|
+
replicate: (stream: any) => any;
|
|
43
|
+
};
|
|
2
44
|
/**
|
|
3
45
|
* @typedef {object} NetworkOpts
|
|
4
46
|
* @property {import('../identity/index.js').Identity} [identity] Long-lived keypair used as the swarm identity.
|
|
@@ -16,9 +58,7 @@ export function channelTopic(topic: any, channel: any): any;
|
|
|
16
58
|
* Hyperswarm peer-discovery + replication multiplexer. Wraps a swarm and a
|
|
17
59
|
* shared wakeup channel, replicating any attached resource onto every peer.
|
|
18
60
|
*/
|
|
19
|
-
export class Network extends ReadyResource {
|
|
20
|
-
/** @param {NetworkOpts} [opts] */
|
|
21
|
-
constructor({ identity, bootstrap, firewall, relayThrough, backoffs, channel, store, mirrors }?: NetworkOpts);
|
|
61
|
+
export declare class Network extends ReadyResource {
|
|
22
62
|
identity: import("../index.js").Identity;
|
|
23
63
|
bootstrap: {
|
|
24
64
|
host: string;
|
|
@@ -32,7 +72,7 @@ export class Network extends ReadyResource {
|
|
|
32
72
|
mirrors: any[];
|
|
33
73
|
_swarm: any;
|
|
34
74
|
wakeup: any;
|
|
35
|
-
info:
|
|
75
|
+
info: object;
|
|
36
76
|
_peerInfo: Map<any, any>;
|
|
37
77
|
_infoSenders: Set<any>;
|
|
38
78
|
_replicateables: Set<any>;
|
|
@@ -40,15 +80,21 @@ export class Network extends ReadyResource {
|
|
|
40
80
|
_injected: Set<any>;
|
|
41
81
|
_blind: any;
|
|
42
82
|
_blindPeering: any;
|
|
83
|
+
/** @param {NetworkOpts} [opts] */
|
|
84
|
+
constructor({ identity, bootstrap, firewall, relayThrough, backoffs, channel, store, mirrors }?: NetworkOpts);
|
|
43
85
|
/** @returns {any} The underlying hyperswarm, or null before ready / after close. */
|
|
44
86
|
get swarm(): any;
|
|
87
|
+
/** @returns {Map<string, any>} Known peers keyed by public-key string. */
|
|
88
|
+
get peers(): Map<string, any>;
|
|
89
|
+
/** @returns {Set<any>} Live connection streams — swarm and injected. */
|
|
90
|
+
get connections(): Set<any>;
|
|
91
|
+
/** @returns {boolean} */
|
|
92
|
+
get suspended(): boolean;
|
|
93
|
+
_open(): Promise<void>;
|
|
94
|
+
_close(): Promise<void>;
|
|
45
95
|
/**
|
|
46
|
-
* Feed an externally-established connection — a Bluetooth L2CAP channel, a
|
|
47
|
-
*
|
|
48
|
-
* duplex is wrapped in NoiseSecretStream (pass `isInitiator`); a stream
|
|
49
|
-
* that already IS one is used as-is. From here it gets the exact same
|
|
50
|
-
* treatment as a swarm connection: wakeup, replication of every attached
|
|
51
|
-
* core, pairing, and the 'connection' event.
|
|
96
|
+
* Feed an externally-established connection — a Bluetooth L2CAP channel, a serial link, an
|
|
97
|
+
* in-process pair, any duplex — into the network.
|
|
52
98
|
*
|
|
53
99
|
* @param {any} stream Duplex transport, or a ready NoiseSecretStream.
|
|
54
100
|
* @param {{ isInitiator?: boolean }} [opts] Which side initiates the noise handshake (raw duplexes only).
|
|
@@ -58,27 +104,21 @@ export class Network extends ReadyResource {
|
|
|
58
104
|
isInitiator?: boolean;
|
|
59
105
|
}): any;
|
|
60
106
|
/**
|
|
61
|
-
* Lazily create the network-shared BlindPairing.
|
|
62
|
-
* handle's pairing member — per-handle instances each added their own swarm
|
|
63
|
-
* and DHT listeners plus a protomux channel per connection.
|
|
107
|
+
* Lazily create the network-shared BlindPairing.
|
|
64
108
|
*
|
|
65
109
|
* @returns {Promise<any>}
|
|
66
110
|
*/
|
|
67
111
|
blind(): Promise<any>;
|
|
68
112
|
/**
|
|
69
|
-
* Re-attach pairing channels on injected connections. blind-pairing only
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* a member/candidate added later must re-run the attach. Idempotent:
|
|
73
|
-
* protomux refuses duplicate channels.
|
|
113
|
+
* Re-attach pairing channels on injected connections. blind-pairing only auto-attaches
|
|
114
|
+
* refs that existed when a connection arrived — swarm peers meet again over topic joins,
|
|
115
|
+
* injected links (Bluetooth,.
|
|
74
116
|
*
|
|
75
117
|
* @returns {Promise<void>}
|
|
76
118
|
*/
|
|
77
119
|
refreshInjected(): Promise<void>;
|
|
78
120
|
/**
|
|
79
|
-
* Declare this peer's self-reported info ({ name, ... }).
|
|
80
|
-
* encrypted channel on every live and future connection — never on the
|
|
81
|
-
* radio advertisement or the DHT.
|
|
121
|
+
* Declare this peer's self-reported info ({ name, ... }).
|
|
82
122
|
*
|
|
83
123
|
* @param {object | null} info
|
|
84
124
|
*/
|
|
@@ -90,13 +130,6 @@ export class Network extends ReadyResource {
|
|
|
90
130
|
* @returns {object | null}
|
|
91
131
|
*/
|
|
92
132
|
getInfo(key: Uint8Array | string): object | null;
|
|
93
|
-
_attachInfo(conn: any): void;
|
|
94
|
-
/** @returns {Map<string, any>} Known peers keyed by public-key string. */
|
|
95
|
-
get peers(): Map<string, any>;
|
|
96
|
-
/** @returns {Set<any>} Live connection streams — swarm and injected. */
|
|
97
|
-
get connections(): Set<any>;
|
|
98
|
-
/** @returns {boolean} */
|
|
99
|
-
get suspended(): boolean;
|
|
100
133
|
/**
|
|
101
134
|
* Wait for pending DHT announces and lookups to settle, bounded by timeout.
|
|
102
135
|
*
|
|
@@ -126,7 +159,7 @@ export class Network extends ReadyResource {
|
|
|
126
159
|
* @returns {Discovery}
|
|
127
160
|
*/
|
|
128
161
|
join(topic: Uint8Array, { mode }?: {
|
|
129
|
-
mode?:
|
|
162
|
+
mode?: 'active' | 'passive';
|
|
130
163
|
}): Discovery;
|
|
131
164
|
/**
|
|
132
165
|
* Register a replicable resource (hypercore, autobee, hyperdb).
|
|
@@ -152,46 +185,5 @@ export class Network extends ReadyResource {
|
|
|
152
185
|
* @returns {void}
|
|
153
186
|
*/
|
|
154
187
|
replicate(target: Replicable): void;
|
|
188
|
+
_attachInfo(conn: any): void;
|
|
155
189
|
}
|
|
156
|
-
export type NetworkOpts = {
|
|
157
|
-
/**
|
|
158
|
-
* Long-lived keypair used as the swarm identity.
|
|
159
|
-
*/
|
|
160
|
-
identity?: import("../identity/index.js").Identity;
|
|
161
|
-
/**
|
|
162
|
-
* Custom DHT bootstrap nodes.
|
|
163
|
-
*/
|
|
164
|
-
bootstrap?: Array<{
|
|
165
|
-
host: string;
|
|
166
|
-
port: number;
|
|
167
|
-
}>;
|
|
168
|
-
/**
|
|
169
|
-
* Incoming-connection filter.
|
|
170
|
-
*/
|
|
171
|
-
firewall?: (remotePublicKey: Uint8Array, payload: any) => boolean;
|
|
172
|
-
/**
|
|
173
|
-
* Relay public keys to tunnel through.
|
|
174
|
-
*/
|
|
175
|
-
relayThrough?: Uint8Array[];
|
|
176
|
-
/**
|
|
177
|
-
* Reconnect backoff tiers in ms; the default escalates to ~10min, far too slow for local nets.
|
|
178
|
-
*/
|
|
179
|
-
backoffs?: number[];
|
|
180
|
-
/**
|
|
181
|
-
* Optional network-isolation label; only same-channel peers meet.
|
|
182
|
-
*/
|
|
183
|
-
channel?: string;
|
|
184
|
-
/**
|
|
185
|
-
* Corestore; required for mirrors (blind peers replicate its cores).
|
|
186
|
-
*/
|
|
187
|
-
store?: any;
|
|
188
|
-
/**
|
|
189
|
-
* Blind-peer public keys; each attached room/blob core is mirrored through them for offline sync.
|
|
190
|
-
*/
|
|
191
|
-
mirrors?: Array<string | Uint8Array>;
|
|
192
|
-
};
|
|
193
|
-
export type Replicable = {
|
|
194
|
-
replicate: (stream: any) => any;
|
|
195
|
-
};
|
|
196
|
-
import ReadyResource from 'ready-resource';
|
|
197
|
-
import { Discovery } from './discovery.js';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal — the joiner side: a candidate's handshake state machine (this *is* the
|
|
3
|
+
* blind-pairing `addCandidate`).
|
|
4
|
+
*
|
|
5
|
+
* @property {any} _candidate blind-pairing addCandidate handle (null until started).
|
|
6
|
+
* @property {ReturnType<typeof setTimeout> | null} _timer Pending timeout, if any.
|
|
7
|
+
* @property {((result: any) => void) | null} _resolve Promise resolver, set in `start`.
|
|
8
|
+
* @property {((err: Error) => void) | null} _reject Promise rejecter, set in `start`.
|
|
9
|
+
* @property {boolean} _settled Whether the handshake has already settled.
|
|
10
|
+
*/
|
|
11
|
+
export declare class Candidate {
|
|
12
|
+
pairing: import("./index.js").Pairing;
|
|
13
|
+
invite: import("./invite.js").Invite;
|
|
14
|
+
userData: Uint8Array<ArrayBufferLike>;
|
|
15
|
+
timeout: number;
|
|
16
|
+
_candidate: any;
|
|
17
|
+
_timer: number;
|
|
18
|
+
_resolve: (value: import("./index.js").JoinResult | PromiseLike<import("./index.js").JoinResult>) => void;
|
|
19
|
+
_reject: (reason?: any) => void;
|
|
20
|
+
_settled: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* @param {import('./index.js').Pairing} pairing
|
|
23
|
+
* @param {import('./invite.js').Invite} invite
|
|
24
|
+
* @param {Uint8Array | null} userData
|
|
25
|
+
* @param {number} timeout
|
|
26
|
+
*/
|
|
27
|
+
constructor(pairing: import('./index.js').Pairing, invite: import('./invite.js').Invite, userData: Uint8Array | null, timeout: number);
|
|
28
|
+
/**
|
|
29
|
+
* Kick off the handshake; returns a promise that settles with the host response.
|
|
30
|
+
*
|
|
31
|
+
* @returns {Promise<import('./index.js').JoinResult>}
|
|
32
|
+
*/
|
|
33
|
+
start(): Promise<import('./index.js').JoinResult>;
|
|
34
|
+
_done(result: any): void;
|
|
35
|
+
_fail(err: any): void;
|
|
36
|
+
}
|