@libp2p/interface 2.9.0-f1de46607 → 2.10.0-aa25d38ab
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +3 -3
- package/dist/src/content-routing.d.ts +2 -2
- package/dist/src/content-routing.d.ts.map +1 -1
- package/dist/src/content-routing.js +1 -1
- package/dist/src/errors.d.ts +8 -1
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/errors.js +11 -1
- package/dist/src/errors.js.map +1 -1
- package/dist/src/event-target.d.ts +2 -2
- package/dist/src/event-target.d.ts.map +1 -1
- package/dist/src/event-target.js +0 -1
- package/dist/src/event-target.js.map +1 -1
- package/dist/src/events.d.ts +0 -1
- package/dist/src/events.d.ts.map +1 -1
- package/dist/src/index.d.ts +40 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/metrics.d.ts +1 -2
- package/dist/src/metrics.d.ts.map +1 -1
- package/dist/src/peer-discovery.d.ts +6 -1
- package/dist/src/peer-discovery.d.ts.map +1 -1
- package/dist/src/peer-routing.d.ts +3 -3
- package/dist/src/peer-routing.d.ts.map +1 -1
- package/dist/src/peer-routing.js +2 -2
- package/dist/src/peer-store.d.ts +26 -0
- package/dist/src/peer-store.d.ts.map +1 -1
- package/dist/src/peer-store.js.map +1 -1
- package/dist/src/pubsub.d.ts +13 -10
- package/dist/src/pubsub.d.ts.map +1 -1
- package/dist/src/pubsub.js +8 -8
- package/dist/src/pubsub.js.map +1 -1
- package/dist/src/record.d.ts +25 -1
- package/dist/src/record.d.ts.map +1 -1
- package/dist/src/startable.d.ts +52 -1
- package/dist/src/startable.d.ts.map +1 -1
- package/dist/src/startable.js +51 -0
- package/dist/src/startable.js.map +1 -1
- package/dist/src/topology.d.ts +2 -1
- package/dist/src/topology.d.ts.map +1 -1
- package/dist/src/transport.d.ts +40 -4
- package/dist/src/transport.d.ts.map +1 -1
- package/dist/src/transport.js +3 -0
- package/dist/src/transport.js.map +1 -1
- package/package.json +4 -11
- package/src/content-routing.ts +2 -2
- package/src/errors.ts +13 -1
- package/src/event-target.ts +2 -2
- package/src/index.ts +40 -3
- package/src/metrics.ts +1 -1
- package/src/peer-discovery.ts +6 -1
- package/src/peer-routing.ts +3 -3
- package/src/peer-store.ts +27 -0
- package/src/pubsub.ts +13 -10
- package/src/record.ts +30 -1
- package/src/startable.ts +52 -1
- package/src/topology.ts +2 -1
- package/src/transport.ts +47 -5
package/dist/src/startable.d.ts
CHANGED
|
@@ -39,7 +39,58 @@ export interface Startable {
|
|
|
39
39
|
*/
|
|
40
40
|
afterStop?(): void | Promise<void>;
|
|
41
41
|
}
|
|
42
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Returns `true` if the object has type overlap with `Startable`
|
|
44
|
+
*/
|
|
45
|
+
export declare function isStartable(obj?: any): obj is Startable;
|
|
46
|
+
/**
|
|
47
|
+
* A function that can be used to start and objects passed to it. This checks
|
|
48
|
+
* that an object is startable before invoking its lifecycle methods so it is
|
|
49
|
+
* safe to pass non-`Startable`s in.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
*
|
|
53
|
+
* ```TypeScript
|
|
54
|
+
* import { start } from '@libp2p/interface'
|
|
55
|
+
* import type { Startable } from '@libp2p/interface'
|
|
56
|
+
*
|
|
57
|
+
* const startable: Startable = {
|
|
58
|
+
* start: () => {},
|
|
59
|
+
* stop: () => {}
|
|
60
|
+
* }
|
|
61
|
+
*
|
|
62
|
+
* const notStartable = 5
|
|
63
|
+
*
|
|
64
|
+
* await start(
|
|
65
|
+
* startable,
|
|
66
|
+
* notStartable
|
|
67
|
+
* )
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
43
70
|
export declare function start(...objs: any[]): Promise<void>;
|
|
71
|
+
/**
|
|
72
|
+
* A function that can be used to stop and objects passed to it. This checks
|
|
73
|
+
* that an object is startable before invoking its lifecycle methods so it is
|
|
74
|
+
* safe to pass non-`Startable`s in.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
*
|
|
78
|
+
* ```TypeScript
|
|
79
|
+
* import { stop } from '@libp2p/interface'
|
|
80
|
+
* import type { Startable } from '@libp2p/interface'
|
|
81
|
+
*
|
|
82
|
+
* const startable: Startable = {
|
|
83
|
+
* start: () => {},
|
|
84
|
+
* stop: () => {}
|
|
85
|
+
* }
|
|
86
|
+
*
|
|
87
|
+
* const notStartable = 5
|
|
88
|
+
*
|
|
89
|
+
* await stop(
|
|
90
|
+
* startable,
|
|
91
|
+
* notStartable
|
|
92
|
+
* )
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
44
95
|
export declare function stop(...objs: any[]): Promise<void>;
|
|
45
96
|
//# sourceMappingURL=startable.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"startable.d.ts","sourceRoot":"","sources":["../../src/startable.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB;;;;OAIG;IACH,WAAW,CAAC,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAEpC;;;;OAIG;IACH,KAAK,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAE7B;;;;OAIG;IACH,UAAU,CAAC,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAEnC;;;;OAIG;IACH,UAAU,CAAC,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAEnC;;;;OAIG;IACH,IAAI,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAE5B;;;;OAIG;IACH,SAAS,CAAC,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACnC;AAED,wBAAgB,WAAW,CAAE,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,SAAS,
|
|
1
|
+
{"version":3,"file":"startable.d.ts","sourceRoot":"","sources":["../../src/startable.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB;;;;OAIG;IACH,WAAW,CAAC,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAEpC;;;;OAIG;IACH,KAAK,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAE7B;;;;OAIG;IACH,UAAU,CAAC,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAEnC;;;;OAIG;IACH,UAAU,CAAC,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAEnC;;;;OAIG;IACH,IAAI,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAE5B;;;;OAIG;IACH,SAAS,CAAC,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACnC;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAE,GAAG,CAAC,EAAE,GAAG,GAAG,GAAG,IAAI,SAAS,CAExD;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,KAAK,CAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA8B1D;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,IAAI,CAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA8BzD"}
|
package/dist/src/startable.js
CHANGED
|
@@ -1,6 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns `true` if the object has type overlap with `Startable`
|
|
3
|
+
*/
|
|
1
4
|
export function isStartable(obj) {
|
|
2
5
|
return obj != null && typeof obj.start === 'function' && typeof obj.stop === 'function';
|
|
3
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* A function that can be used to start and objects passed to it. This checks
|
|
9
|
+
* that an object is startable before invoking its lifecycle methods so it is
|
|
10
|
+
* safe to pass non-`Startable`s in.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
*
|
|
14
|
+
* ```TypeScript
|
|
15
|
+
* import { start } from '@libp2p/interface'
|
|
16
|
+
* import type { Startable } from '@libp2p/interface'
|
|
17
|
+
*
|
|
18
|
+
* const startable: Startable = {
|
|
19
|
+
* start: () => {},
|
|
20
|
+
* stop: () => {}
|
|
21
|
+
* }
|
|
22
|
+
*
|
|
23
|
+
* const notStartable = 5
|
|
24
|
+
*
|
|
25
|
+
* await start(
|
|
26
|
+
* startable,
|
|
27
|
+
* notStartable
|
|
28
|
+
* )
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
4
31
|
export async function start(...objs) {
|
|
5
32
|
const startables = [];
|
|
6
33
|
for (const obj of objs) {
|
|
@@ -22,6 +49,30 @@ export async function start(...objs) {
|
|
|
22
49
|
}
|
|
23
50
|
}));
|
|
24
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* A function that can be used to stop and objects passed to it. This checks
|
|
54
|
+
* that an object is startable before invoking its lifecycle methods so it is
|
|
55
|
+
* safe to pass non-`Startable`s in.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
*
|
|
59
|
+
* ```TypeScript
|
|
60
|
+
* import { stop } from '@libp2p/interface'
|
|
61
|
+
* import type { Startable } from '@libp2p/interface'
|
|
62
|
+
*
|
|
63
|
+
* const startable: Startable = {
|
|
64
|
+
* start: () => {},
|
|
65
|
+
* stop: () => {}
|
|
66
|
+
* }
|
|
67
|
+
*
|
|
68
|
+
* const notStartable = 5
|
|
69
|
+
*
|
|
70
|
+
* await stop(
|
|
71
|
+
* startable,
|
|
72
|
+
* notStartable
|
|
73
|
+
* )
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
25
76
|
export async function stop(...objs) {
|
|
26
77
|
const startables = [];
|
|
27
78
|
for (const obj of objs) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"startable.js","sourceRoot":"","sources":["../../src/startable.ts"],"names":[],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;;;;;;GAuBG;AACH,MAAM,CAAC,KAAK,UAAU,IAAI,CAAE,GAAG,IAAW;IACxC,MAAM,UAAU,GAAgB,EAAE,CAAA;IAElC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAI,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC;YACrB,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QACtB,CAAC;IACH,CAAC;IAED,MAAM,OAAO,CAAC,GAAG,CACf,UAAU,CAAC,GAAG,CAAC,KAAK,EAAC,CAAC,EAAC,EAAE;QACvB,IAAI,CAAC,CAAC,UAAU,IAAI,IAAI,EAAE,CAAC;YACzB,MAAM,CAAC,CAAC,UAAU,EAAE,CAAA;QACtB,CAAC;IACH,CAAC,CAAC,CACH,CAAA;IAED,MAAM,OAAO,CAAC,GAAG,CACf,UAAU,CAAC,GAAG,CAAC,KAAK,EAAC,CAAC,EAAC,EAAE;QACvB,MAAM,CAAC,CAAC,IAAI,EAAE,CAAA;IAChB,CAAC,CAAC,CACH,CAAA;IAED,MAAM,OAAO,CAAC,GAAG,CACf,UAAU,CAAC,GAAG,CAAC,KAAK,EAAC,CAAC,EAAC,EAAE;QACvB,IAAI,CAAC,CAAC,SAAS,IAAI,IAAI,EAAE,CAAC;YACxB,MAAM,CAAC,CAAC,SAAS,EAAE,CAAA;QACrB,CAAC;IACH,CAAC,CAAC,CACH,CAAA;AACH,CAAC"}
|
package/dist/src/topology.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { Connection } from './connection.js';
|
|
2
2
|
import type { PeerId } from './peer-id.js';
|
|
3
3
|
/**
|
|
4
|
-
* A topology filter
|
|
4
|
+
* A topology filter - this can be used by topologies to ensure they do not
|
|
5
|
+
* receive duplicate notifications of individual peers
|
|
5
6
|
*
|
|
6
7
|
* @see https://libp2p.github.io/js-libp2p/functions/_libp2p_peer_collections.peerFilter-1.html
|
|
7
8
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"topology.d.ts","sourceRoot":"","sources":["../../src/topology.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAE1C
|
|
1
|
+
{"version":3,"file":"topology.d.ts","sourceRoot":"","sources":["../../src/topology.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAE1C;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,GAAG,CAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAA;IAC7B,GAAG,CAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,MAAM,CAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;CAC9B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,QAAQ;IACvB;;;OAGG;IACH,MAAM,CAAC,EAAE,cAAc,CAAA;IAEvB;;;;;;OAMG;IACH,yBAAyB,CAAC,EAAE,OAAO,CAAA;IAEnC;;;OAGG;IACH,SAAS,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,IAAI,CAAA;IAElD;;;OAGG;IACH,YAAY,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;CACpC"}
|
package/dist/src/transport.d.ts
CHANGED
|
@@ -9,16 +9,16 @@ export interface ListenerEvents {
|
|
|
9
9
|
* This event signals to the transport manager that the listening addresses
|
|
10
10
|
* have changed and may be emitted at any point and/or multiple times
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
listening: CustomEvent;
|
|
13
13
|
/**
|
|
14
14
|
* Emitted if listening on an address failed
|
|
15
15
|
*/
|
|
16
|
-
|
|
16
|
+
error: CustomEvent<Error>;
|
|
17
17
|
/**
|
|
18
18
|
* Emitted when the listener has been shut down, has no open connections and
|
|
19
19
|
* will no longer accept new connections
|
|
20
20
|
*/
|
|
21
|
-
|
|
21
|
+
close: CustomEvent;
|
|
22
22
|
}
|
|
23
23
|
export interface Listener extends TypedEventTarget<ListenerEvents> {
|
|
24
24
|
/**
|
|
@@ -42,6 +42,9 @@ export interface Listener extends TypedEventTarget<ListenerEvents> {
|
|
|
42
42
|
updateAnnounceAddrs(addrs: Multiaddr[]): void;
|
|
43
43
|
}
|
|
44
44
|
export declare const transportSymbol: unique symbol;
|
|
45
|
+
/**
|
|
46
|
+
* A filter that acts on a list of multiaddrs
|
|
47
|
+
*/
|
|
45
48
|
export interface MultiaddrFilter {
|
|
46
49
|
(multiaddrs: Multiaddr[]): Multiaddr[];
|
|
47
50
|
}
|
|
@@ -90,7 +93,10 @@ export interface Transport<DialEvents extends ProgressEvent = ProgressEvent> {
|
|
|
90
93
|
*/
|
|
91
94
|
dialFilter: MultiaddrFilter;
|
|
92
95
|
}
|
|
93
|
-
|
|
96
|
+
/**
|
|
97
|
+
* Used to disambiguate transport implementations
|
|
98
|
+
*/
|
|
99
|
+
export declare function isTransport(other?: any): other is Transport;
|
|
94
100
|
/**
|
|
95
101
|
* Enum Transport Manager Fault Tolerance values
|
|
96
102
|
*/
|
|
@@ -104,11 +110,41 @@ export declare enum FaultTolerance {
|
|
|
104
110
|
*/
|
|
105
111
|
NO_FATAL = 1
|
|
106
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* Options accepted by the upgrader during connection establishment
|
|
115
|
+
*/
|
|
107
116
|
export interface UpgraderOptions<ConnectionUpgradeEvents extends ProgressEvent = ProgressEvent> extends ProgressOptions<ConnectionUpgradeEvents>, Required<AbortOptions> {
|
|
117
|
+
/**
|
|
118
|
+
* If true the invoking transport is expected to implement it's own encryption
|
|
119
|
+
* and an encryption protocol will not attempted to be negotiated via
|
|
120
|
+
* multi-stream select
|
|
121
|
+
*
|
|
122
|
+
* @default false
|
|
123
|
+
*/
|
|
108
124
|
skipEncryption?: boolean;
|
|
125
|
+
/**
|
|
126
|
+
* If true no connection protection will be performed on the connection.
|
|
127
|
+
*/
|
|
109
128
|
skipProtection?: boolean;
|
|
129
|
+
/**
|
|
130
|
+
* By default a stream muxer protocol will be negotiated via multi-stream
|
|
131
|
+
* select after an encryption protocol has been agreed on.
|
|
132
|
+
*
|
|
133
|
+
* If a transport provides it's own stream muxing facility pass a muxer
|
|
134
|
+
* factory instance here to skip muxer negotiation.
|
|
135
|
+
*/
|
|
110
136
|
muxerFactory?: StreamMuxerFactory;
|
|
137
|
+
/**
|
|
138
|
+
* If the connection is to have limits applied to it, pass them here
|
|
139
|
+
*/
|
|
111
140
|
limits?: ConnectionLimits;
|
|
141
|
+
/**
|
|
142
|
+
* Multi-stream select is a initiator/responder protocol. By default a
|
|
143
|
+
* connection returned from `upgrader.upgradeOutbound` will be the initiator
|
|
144
|
+
* and one returned from `upgrader.upgradeInbound` will be the responder.
|
|
145
|
+
*
|
|
146
|
+
* Pass a value here to override the default.
|
|
147
|
+
*/
|
|
112
148
|
initiator?: boolean;
|
|
113
149
|
}
|
|
114
150
|
export type InboundConnectionUpgradeEvents = ProgressEvent<'upgrader:encrypt-inbound-connection'> | ProgressEvent<'upgrader:multiplex-inbound-connection'>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACxF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AACpF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAA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H,YAAY,CAAC,EAAE,kBAAkB,CAAA;IAEjC;;OAEG;IACH,MAAM,CAAC,EAAE,gBAAgB,CAAA;IAEzB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAED,MAAM,MAAM,8BAA8B,GAC1C,aAAa,CAAC,qCAAqC,CAAC,GACpD,aAAa,CAAC,uCAAuC,CAAC,CAAA;AAEtD,MAAM,MAAM,+BAA+B,GAC3C,aAAa,CAAC,sCAAsC,CAAC,GACrD,aAAa,CAAC,wCAAwC,CAAC,CAAA;AAEvD,MAAM,WAAW,QAAQ;IACvB;;OAEG;IACH,eAAe,CAAC,MAAM,EAAE,mBAAmB,EAAE,IAAI,CAAC,EAAE,eAAe,CAAC,+BAA+B,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;IAE1H;;;OAGG;IACH,cAAc,CAAC,MAAM,EAAE,mBAAmB,EAAE,IAAI,CAAC,EAAE,eAAe,CAAC,8BAA8B,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAElH;;;;;;;OAOG;IACH,wBAAwB,CAAE,MAAM,EAAE,WAAW,GAAG,eAAe,CAAA;IAE/D;;OAEG;IACH,eAAe,IAAK,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAA;IAEnD;;OAEG;IACH,uBAAuB,IAAK,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAA;CAC7D"}
|
package/dist/src/transport.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/transport.ts"],"names":[],"mappings":"AAgDA,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/transport.ts"],"names":[],"mappings":"AAgDA,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAA;AA8D9D;;GAEG;AACH,MAAM,UAAU,WAAW,CAAE,KAAW;IACtC,OAAO,KAAK,IAAI,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAA;AACzD,CAAC;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,cAUX;AAVD,WAAY,cAAc;IACxB;;OAEG;IACH,6DAAa,CAAA;IAEb;;OAEG;IACH,2DAAQ,CAAA;AACV,CAAC,EAVW,cAAc,KAAd,cAAc,QAUzB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/interface",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.10.0-aa25d38ab",
|
|
4
4
|
"description": "The interface implemented by a libp2p node",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/interface#readme",
|
|
@@ -33,13 +33,6 @@
|
|
|
33
33
|
"import": "./dist/src/index.js"
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
|
-
"eslintConfig": {
|
|
37
|
-
"extends": "ipfs",
|
|
38
|
-
"parserOptions": {
|
|
39
|
-
"project": true,
|
|
40
|
-
"sourceType": "module"
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
36
|
"scripts": {
|
|
44
37
|
"clean": "aegir clean",
|
|
45
38
|
"lint": "aegir lint",
|
|
@@ -48,15 +41,15 @@
|
|
|
48
41
|
"build": "aegir build"
|
|
49
42
|
},
|
|
50
43
|
"dependencies": {
|
|
51
|
-
"@multiformats/multiaddr": "^12.
|
|
44
|
+
"@multiformats/multiaddr": "^12.4.0",
|
|
52
45
|
"it-pushable": "^3.2.3",
|
|
53
46
|
"it-stream-types": "^2.0.2",
|
|
54
|
-
"multiformats": "^13.3.
|
|
47
|
+
"multiformats": "^13.3.4",
|
|
55
48
|
"progress-events": "^1.0.1",
|
|
56
49
|
"uint8arraylist": "^2.4.8"
|
|
57
50
|
},
|
|
58
51
|
"devDependencies": {
|
|
59
|
-
"aegir": "^
|
|
52
|
+
"aegir": "^47.0.6"
|
|
60
53
|
},
|
|
61
54
|
"browser": {
|
|
62
55
|
"./dist/src/events.js": "./dist/src/events.browser.js"
|
package/src/content-routing.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { CID } from 'multiformats/cid'
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Any object that implements this Symbol as a property should return a
|
|
7
|
-
* ContentRouting instance as the property value, similar to how
|
|
7
|
+
* Partial<ContentRouting> instance as the property value, similar to how
|
|
8
8
|
* `Symbol.Iterable` can be used to return an `Iterable` from an `Iterator`.
|
|
9
9
|
*
|
|
10
10
|
* @example
|
|
@@ -28,7 +28,7 @@ export const contentRoutingSymbol = Symbol.for('@libp2p/content-routing')
|
|
|
28
28
|
* interested callers.
|
|
29
29
|
*/
|
|
30
30
|
export interface ContentRoutingProvider {
|
|
31
|
-
[contentRoutingSymbol]: ContentRouting
|
|
31
|
+
[contentRoutingSymbol]: Partial<ContentRouting>
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
export interface ContentRouting {
|
package/src/errors.ts
CHANGED
|
@@ -353,7 +353,7 @@ export class TooManyOutboundProtocolStreamsError extends Error {
|
|
|
353
353
|
}
|
|
354
354
|
|
|
355
355
|
/**
|
|
356
|
-
* Thrown when
|
|
356
|
+
* Thrown when an attempt to operate on an unsupported key was made
|
|
357
357
|
*/
|
|
358
358
|
export class UnsupportedKeyTypeError extends Error {
|
|
359
359
|
static name = 'UnsupportedKeyTypeError'
|
|
@@ -363,3 +363,15 @@ export class UnsupportedKeyTypeError extends Error {
|
|
|
363
363
|
this.name = 'UnsupportedKeyTypeError'
|
|
364
364
|
}
|
|
365
365
|
}
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Thrown when an operation has not been implemented
|
|
369
|
+
*/
|
|
370
|
+
export class NotImplementedError extends Error {
|
|
371
|
+
static name = 'NotImplementedError'
|
|
372
|
+
|
|
373
|
+
constructor (message = 'Not implemented') {
|
|
374
|
+
super(message)
|
|
375
|
+
this.name = 'NotImplementedError'
|
|
376
|
+
}
|
|
377
|
+
}
|
package/src/event-target.ts
CHANGED
|
@@ -10,7 +10,8 @@ interface Listener {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* Adds types to the EventTarget class. Hopefully this won't be necessary
|
|
13
|
+
* Adds types to the EventTarget class. Hopefully this won't be necessary
|
|
14
|
+
* forever.
|
|
14
15
|
*
|
|
15
16
|
* https://github.com/microsoft/TypeScript/issues/28357
|
|
16
17
|
* https://github.com/microsoft/TypeScript/issues/43477
|
|
@@ -31,7 +32,6 @@ export interface TypedEventTarget <EventMap extends Record<string, any>> extends
|
|
|
31
32
|
|
|
32
33
|
/**
|
|
33
34
|
* An implementation of a typed event target
|
|
34
|
-
* etc
|
|
35
35
|
*/
|
|
36
36
|
export class TypedEventEmitter<EventMap extends Record<string, any>> extends EventTarget implements TypedEventTarget<EventMap> {
|
|
37
37
|
readonly #listeners = new Map<any, Listener[]>()
|
package/src/index.ts
CHANGED
|
@@ -53,6 +53,9 @@ export interface SignedPeerRecord {
|
|
|
53
53
|
seq: bigint
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
/**
|
|
57
|
+
* A certificate that can be used to secure connections
|
|
58
|
+
*/
|
|
56
59
|
export interface TLSCertificate {
|
|
57
60
|
/**
|
|
58
61
|
* The private key that corresponds to the certificate in PEM format
|
|
@@ -130,9 +133,43 @@ export interface Logger {
|
|
|
130
133
|
}
|
|
131
134
|
|
|
132
135
|
/**
|
|
133
|
-
* Peer logger component for libp2p
|
|
136
|
+
* Peer logger component for libp2p. This can be used to create loggers that are
|
|
137
|
+
* scoped to individual system components or services.
|
|
138
|
+
*
|
|
139
|
+
* To see logs, run your app with `DEBUG` set as an env var or for browsers, in
|
|
140
|
+
* `localStorage`:
|
|
141
|
+
*
|
|
142
|
+
* ```console
|
|
143
|
+
* $ DEBUG=libp2p* node index.js
|
|
144
|
+
* libp2p:my-service hello +0ms
|
|
145
|
+
* ```
|
|
134
146
|
*/
|
|
135
147
|
export interface ComponentLogger {
|
|
148
|
+
/**
|
|
149
|
+
* Returns a logger for the specified component.
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
*
|
|
153
|
+
* ```TypeScript
|
|
154
|
+
* import { ComponentLogger, Logger } from '@libp2p/interface'
|
|
155
|
+
*
|
|
156
|
+
* interface MyServiceComponents {
|
|
157
|
+
* logger: ComponentLogger
|
|
158
|
+
* }
|
|
159
|
+
*
|
|
160
|
+
* class MyService {
|
|
161
|
+
* private readonly log: Logger
|
|
162
|
+
*
|
|
163
|
+
* constructor (components) {
|
|
164
|
+
* this.log = components.logger.forComponent('libp2p:my-service')
|
|
165
|
+
*
|
|
166
|
+
* this.log('hello')
|
|
167
|
+
* // logs:
|
|
168
|
+
* // libp2p:my-service hello +0ms
|
|
169
|
+
* }
|
|
170
|
+
* }
|
|
171
|
+
* ```
|
|
172
|
+
*/
|
|
136
173
|
forComponent(name: string): Logger
|
|
137
174
|
}
|
|
138
175
|
|
|
@@ -299,7 +336,7 @@ export interface Libp2pEvents<T extends ServiceMap = ServiceMap> {
|
|
|
299
336
|
* })
|
|
300
337
|
* ```
|
|
301
338
|
*/
|
|
302
|
-
|
|
339
|
+
start: CustomEvent<Libp2p<T>>
|
|
303
340
|
|
|
304
341
|
/**
|
|
305
342
|
* This event notifies listeners that the node has stopped
|
|
@@ -310,7 +347,7 @@ export interface Libp2pEvents<T extends ServiceMap = ServiceMap> {
|
|
|
310
347
|
* })
|
|
311
348
|
* ```
|
|
312
349
|
*/
|
|
313
|
-
|
|
350
|
+
stop: CustomEvent<Libp2p<T>>
|
|
314
351
|
}
|
|
315
352
|
|
|
316
353
|
/**
|
package/src/metrics.ts
CHANGED
|
@@ -510,7 +510,7 @@ export interface Metrics {
|
|
|
510
510
|
/**
|
|
511
511
|
* Infer the yielded type of an (async)iterable
|
|
512
512
|
*/
|
|
513
|
-
type YieldType<T extends AsyncIterator<any> | Iterator<any>> = T extends AsyncIterator<infer Y> ? Y : T extends Iterator<infer Y, any, any> ? Y : never
|
|
513
|
+
export type YieldType<T extends AsyncIterator<any> | Iterator<any>> = T extends AsyncIterator<infer Y> ? Y : T extends Iterator<infer Y, any, any> ? Y : never
|
|
514
514
|
|
|
515
515
|
export type TraceAttributes = Record<string, number | string | boolean | number[] | string[] | boolean[]>
|
|
516
516
|
|
package/src/peer-discovery.ts
CHANGED
|
@@ -31,7 +31,12 @@ export interface PeerDiscoveryProvider {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
export interface PeerDiscoveryEvents {
|
|
34
|
-
|
|
34
|
+
peer: CustomEvent<PeerInfo>
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
/**
|
|
38
|
+
* A class that implements the `PeerDiscovery` interface uses an
|
|
39
|
+
* implementation-specific method to discover peers. These peers are then added
|
|
40
|
+
* to the peer store for use by other system components and services.
|
|
41
|
+
*/
|
|
37
42
|
export interface PeerDiscovery extends TypedEventTarget<PeerDiscoveryEvents> {}
|
package/src/peer-routing.ts
CHANGED
|
@@ -4,8 +4,8 @@ import type { PeerInfo } from './peer-info.js'
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Any object that implements this Symbol as a property should return a
|
|
7
|
-
* PeerRouting instance as the property value, similar to how
|
|
8
|
-
*
|
|
7
|
+
* PeerRouting instance as the property value, similar to how `Symbol.Iterable`
|
|
8
|
+
* can be used to return an `Iterable` from an `Iterator`.
|
|
9
9
|
*
|
|
10
10
|
* @example
|
|
11
11
|
*
|
|
@@ -28,7 +28,7 @@ export const peerRoutingSymbol = Symbol.for('@libp2p/peer-routing')
|
|
|
28
28
|
* interested callers.
|
|
29
29
|
*/
|
|
30
30
|
export interface PeerRoutingProvider {
|
|
31
|
-
[peerRoutingSymbol]: PeerRouting
|
|
31
|
+
[peerRoutingSymbol]: Partial<PeerRouting>
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
export interface PeerRouting {
|
package/src/peer-store.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { PublicKey } from './keys.js'
|
|
2
2
|
import type { PeerId } from './peer-id.js'
|
|
3
|
+
import type { PeerInfo } from './peer-info.js'
|
|
3
4
|
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -229,6 +230,32 @@ export interface PeerStore {
|
|
|
229
230
|
*/
|
|
230
231
|
get(peerId: PeerId): Promise<Peer>
|
|
231
232
|
|
|
233
|
+
/**
|
|
234
|
+
* Returns a PeerInfo object for the passed peer id. This is similar to `get`
|
|
235
|
+
* except the returned value contains fewer fields and is often used to
|
|
236
|
+
* exchange peer information with other systems.
|
|
237
|
+
*
|
|
238
|
+
* The returned object can be passed to `JSON.stringify` without any
|
|
239
|
+
* additional processing.
|
|
240
|
+
*
|
|
241
|
+
* @see https://docs.libp2p.io/concepts/fundamentals/peers/#peer-info
|
|
242
|
+
*
|
|
243
|
+
* @example
|
|
244
|
+
*
|
|
245
|
+
* ```TypeScript
|
|
246
|
+
* const peerInfo = await peerStore.getInfo(peerId)
|
|
247
|
+
*
|
|
248
|
+
* console.info(JSON.stringify(peerInfo))
|
|
249
|
+
* // {
|
|
250
|
+
* // id: 'peerId'
|
|
251
|
+
* // multiaddrs: [
|
|
252
|
+
* // '...'
|
|
253
|
+
* // ]
|
|
254
|
+
* // }
|
|
255
|
+
* ```
|
|
256
|
+
*/
|
|
257
|
+
getInfo (peerId: PeerId): Promise<PeerInfo>
|
|
258
|
+
|
|
232
259
|
/**
|
|
233
260
|
* Adds a peer to the peer store, overwriting any existing data
|
|
234
261
|
*
|
package/src/pubsub.ts
CHANGED
|
@@ -7,23 +7,23 @@ import type { Uint8ArrayList } from 'uint8arraylist'
|
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* On the producing side:
|
|
10
|
-
*
|
|
10
|
+
* - Build messages with the signature, key (from may be enough for certain inlineable public key types), from and seqno fields.
|
|
11
11
|
*
|
|
12
12
|
* On the consuming side:
|
|
13
|
-
*
|
|
14
|
-
*
|
|
13
|
+
* - Enforce the fields to be present, reject otherwise.
|
|
14
|
+
* - Propagate only if the fields are valid and signature can be verified, reject otherwise.
|
|
15
15
|
*/
|
|
16
16
|
export const StrictSign = 'StrictSign'
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* On the producing side:
|
|
20
|
-
*
|
|
21
|
-
*
|
|
20
|
+
* - Build messages without the signature, key, from and seqno fields.
|
|
21
|
+
* - The corresponding protobuf key-value pairs are absent from the marshaled message, not just empty.
|
|
22
22
|
*
|
|
23
23
|
* On the consuming side:
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
24
|
+
* - Enforce the fields to be absent, reject otherwise.
|
|
25
|
+
* - Propagate only if the fields are absent, reject otherwise.
|
|
26
|
+
* - A message_id function will not be able to use the above fields, and should instead rely on the data field. A commonplace strategy is to calculate a hash.
|
|
27
27
|
*/
|
|
28
28
|
export const StrictNoSign = 'StrictNoSign'
|
|
29
29
|
|
|
@@ -127,7 +127,7 @@ export interface SubscriptionChangeData {
|
|
|
127
127
|
|
|
128
128
|
export interface PubSubEvents {
|
|
129
129
|
'subscription-change': CustomEvent<SubscriptionChangeData>
|
|
130
|
-
|
|
130
|
+
message: CustomEvent<Message>
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
export interface PublishResult {
|
|
@@ -153,6 +153,9 @@ export interface TopicValidatorFn {
|
|
|
153
153
|
(peer: PeerId, message: Message): TopicValidatorResult | Promise<TopicValidatorResult>
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
+
/**
|
|
157
|
+
* @deprecated This will be removed from `@libp2p/interface` in a future release, pubsub implementations should declare their own types
|
|
158
|
+
*/
|
|
156
159
|
export interface PubSub<Events extends Record<string, any> = PubSubEvents> extends TypedEventTarget<Events> {
|
|
157
160
|
/**
|
|
158
161
|
* The global signature policy controls whether or not we sill send and receive
|
|
@@ -266,7 +269,7 @@ export interface PubSub<Events extends Record<string, any> = PubSubEvents> exten
|
|
|
266
269
|
export interface PeerStreamEvents {
|
|
267
270
|
'stream:inbound': CustomEvent<never>
|
|
268
271
|
'stream:outbound': CustomEvent<never>
|
|
269
|
-
|
|
272
|
+
close: CustomEvent<never>
|
|
270
273
|
}
|
|
271
274
|
|
|
272
275
|
/**
|
package/src/record.ts
CHANGED
|
@@ -23,13 +23,42 @@ export interface Record {
|
|
|
23
23
|
equals(other: Record): boolean
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* A message with a signed payload.
|
|
28
|
+
*/
|
|
26
29
|
export interface Envelope {
|
|
30
|
+
/**
|
|
31
|
+
* The public key of the keypair used to sign the payload
|
|
32
|
+
*/
|
|
27
33
|
publicKey: PublicKey
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* How the payload should be interpreted
|
|
37
|
+
*/
|
|
28
38
|
payloadType: Uint8Array | Uint8ArrayList
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The contents of the envelope
|
|
42
|
+
*/
|
|
29
43
|
payload: Uint8Array
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* A signature that can be used to verify the payload is intact
|
|
47
|
+
*/
|
|
30
48
|
signature: Uint8Array | Uint8ArrayList
|
|
31
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Serialize the envelope to a binary format
|
|
52
|
+
*/
|
|
32
53
|
marshal(): Uint8Array
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Use the public key to validate that the payload is intact
|
|
57
|
+
*/
|
|
33
58
|
validate(domain: string): Promise<boolean>
|
|
34
|
-
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Returns true if this envelope has equivalency with the passed object
|
|
62
|
+
*/
|
|
63
|
+
equals(other?: Envelope): boolean
|
|
35
64
|
}
|