@libp2p/interface 2.0.1-c628c44c5 → 2.1.0-7f7ec82ae
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/src/connection/index.d.ts +1 -1
- package/dist/src/events.browser.d.ts +3 -1
- package/dist/src/events.browser.d.ts.map +1 -1
- package/dist/src/events.browser.js +3 -1
- package/dist/src/events.browser.js.map +1 -1
- package/dist/src/events.d.ts +3 -0
- package/dist/src/events.d.ts.map +1 -1
- package/dist/src/events.js +3 -1
- package/dist/src/events.js.map +1 -1
- package/dist/src/keys/index.d.ts +124 -26
- package/dist/src/keys/index.d.ts.map +1 -1
- package/dist/src/keys/index.js.map +1 -1
- package/dist/src/metrics/index.d.ts +142 -0
- package/dist/src/metrics/index.d.ts.map +1 -1
- package/dist/src/pubsub/index.d.ts +1 -2
- package/dist/src/pubsub/index.d.ts.map +1 -1
- package/dist/src/stream-handler/index.d.ts +6 -2
- package/dist/src/stream-handler/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/connection/index.ts +1 -1
- package/src/events.browser.ts +3 -1
- package/src/events.ts +3 -1
- package/src/keys/index.ts +152 -23
- package/src/metrics/index.ts +166 -0
- package/src/pubsub/index.ts +1 -1
- package/src/stream-handler/index.ts +6 -2
|
@@ -109,7 +109,7 @@ export interface Stream extends Duplex<AsyncGenerator<Uint8ArrayList>, Source<Ui
|
|
|
109
109
|
*
|
|
110
110
|
* This will cause a `RESET` message to be sent to the remote, *unless* the sink has already ended.
|
|
111
111
|
*
|
|
112
|
-
* The sink will return and the source will throw
|
|
112
|
+
* The sink will return and the source will throw.
|
|
113
113
|
*/
|
|
114
114
|
abort(err: Error): void;
|
|
115
115
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.browser.d.ts","sourceRoot":"","sources":["../../src/events.browser.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"events.browser.d.ts","sourceRoot":"","sources":["../../src/events.browser.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,eAAe,IAAK,IAAI,CAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.browser.js","sourceRoot":"","sources":["../../src/events.browser.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"events.browser.js","sourceRoot":"","sources":["../../src/events.browser.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,eAAe,KAAW,CAAC"}
|
package/dist/src/events.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { setMaxListeners as nodeSetMaxListeners } from 'events';
|
|
3
|
+
/**
|
|
4
|
+
* Create a setMaxListeners that doesn't break browser usage
|
|
5
|
+
*/
|
|
3
6
|
export declare const setMaxListeners: typeof nodeSetMaxListeners;
|
|
4
7
|
//# sourceMappingURL=events.d.ts.map
|
package/dist/src/events.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/events.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,IAAI,mBAAmB,EAAE,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/events.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,IAAI,mBAAmB,EAAE,MAAM,QAAQ,CAAA;AAE/D;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,OAAO,mBAMpC,CAAA"}
|
package/dist/src/events.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { setMaxListeners as nodeSetMaxListeners } from 'events';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Create a setMaxListeners that doesn't break browser usage
|
|
4
|
+
*/
|
|
3
5
|
export const setMaxListeners = (n, ...eventTargets) => {
|
|
4
6
|
try {
|
|
5
7
|
nodeSetMaxListeners(n, ...eventTargets);
|
package/dist/src/events.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,IAAI,mBAAmB,EAAE,MAAM,QAAQ,CAAA;AAE/D
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,IAAI,mBAAmB,EAAE,MAAM,QAAQ,CAAA;AAE/D;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAA+B,CAAC,CAAC,EAAE,GAAG,YAAY,EAAE,EAAE;IAChF,IAAI,CAAC;QACH,mBAAmB,CAAC,CAAC,EAAE,GAAG,YAAY,CAAC,CAAA;IACzC,CAAC;IAAC,MAAM,CAAC;QACP,sBAAsB;IACxB,CAAC;AACH,CAAC,CAAA"}
|
package/dist/src/keys/index.d.ts
CHANGED
|
@@ -2,14 +2,13 @@ import type { CID } from 'multiformats/cid';
|
|
|
2
2
|
import type { MultihashDigest } from 'multiformats/hashes/interface';
|
|
3
3
|
import type { Uint8ArrayList } from 'uint8arraylist';
|
|
4
4
|
export type KeyType = 'RSA' | 'Ed25519' | 'secp256k1';
|
|
5
|
-
interface
|
|
5
|
+
export interface RSAPublicKey {
|
|
6
6
|
/**
|
|
7
7
|
* The type of this key
|
|
8
8
|
*/
|
|
9
|
-
readonly type:
|
|
9
|
+
readonly type: 'RSA';
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
* DER format (for RSA keys)
|
|
11
|
+
* PKIX in ASN1 DER format
|
|
13
12
|
*/
|
|
14
13
|
readonly raw: Uint8Array;
|
|
15
14
|
/**
|
|
@@ -19,19 +18,16 @@ interface PublicKeyBase<KeyType extends string, DigestCode extends number = numb
|
|
|
19
18
|
/**
|
|
20
19
|
* Returns this public key as a Multihash digest.
|
|
21
20
|
*
|
|
22
|
-
* It contains
|
|
23
|
-
* public key (for Ed25519 and secp256k1 keys) or a sha256 hash of the
|
|
24
|
-
* protobuf version of the public key (RSA keys).
|
|
21
|
+
* It contains a sha256 hash of the protobuf version of the public key.
|
|
25
22
|
*/
|
|
26
|
-
toMultihash(): MultihashDigest<
|
|
23
|
+
toMultihash(): MultihashDigest<0x12>;
|
|
27
24
|
/**
|
|
28
25
|
* Return this public key as a CID encoded with the `libp2p-key` codec
|
|
29
26
|
*
|
|
30
|
-
* The digest contains
|
|
31
|
-
*
|
|
32
|
-
* protobuf version of the public key (RSA keys).
|
|
27
|
+
* The digest contains a sha256 hash of the protobuf version of the public
|
|
28
|
+
* key.
|
|
33
29
|
*/
|
|
34
|
-
toCID(): CID<unknown, 0x72,
|
|
30
|
+
toCID(): CID<unknown, 0x72, 0x12, 1>;
|
|
35
31
|
/**
|
|
36
32
|
* Verify the passed data was signed by the private key corresponding to this
|
|
37
33
|
* public key
|
|
@@ -42,11 +38,75 @@ interface PublicKeyBase<KeyType extends string, DigestCode extends number = numb
|
|
|
42
38
|
*/
|
|
43
39
|
toString(): string;
|
|
44
40
|
}
|
|
45
|
-
export interface
|
|
46
|
-
|
|
47
|
-
|
|
41
|
+
export interface Ed25519PublicKey {
|
|
42
|
+
/**
|
|
43
|
+
* The type of this key
|
|
44
|
+
*/
|
|
45
|
+
readonly type: 'Ed25519';
|
|
46
|
+
/**
|
|
47
|
+
* The raw public key bytes
|
|
48
|
+
*/
|
|
49
|
+
readonly raw: Uint8Array;
|
|
50
|
+
/**
|
|
51
|
+
* Returns `true` if the passed object matches this key
|
|
52
|
+
*/
|
|
53
|
+
equals(key?: any): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Returns this public key as an identity hash containing the protobuf wrapped
|
|
56
|
+
* public key
|
|
57
|
+
*/
|
|
58
|
+
toMultihash(): MultihashDigest<0x0>;
|
|
59
|
+
/**
|
|
60
|
+
* Return this public key as a CID encoded with the `libp2p-key` codec
|
|
61
|
+
*
|
|
62
|
+
* The digest contains an identity hash containing the protobuf wrapped
|
|
63
|
+
* version of the public key.
|
|
64
|
+
*/
|
|
65
|
+
toCID(): CID<unknown, 0x72, 0x0, 1>;
|
|
66
|
+
/**
|
|
67
|
+
* Verify the passed data was signed by the private key corresponding to this
|
|
68
|
+
* public key
|
|
69
|
+
*/
|
|
70
|
+
verify(data: Uint8Array | Uint8ArrayList, sig: Uint8Array): boolean | Promise<boolean>;
|
|
71
|
+
/**
|
|
72
|
+
* Returns this key as a multihash with base58btc encoding
|
|
73
|
+
*/
|
|
74
|
+
toString(): string;
|
|
48
75
|
}
|
|
49
|
-
export interface Secp256k1PublicKey
|
|
76
|
+
export interface Secp256k1PublicKey {
|
|
77
|
+
/**
|
|
78
|
+
* The type of this key
|
|
79
|
+
*/
|
|
80
|
+
readonly type: 'secp256k1';
|
|
81
|
+
/**
|
|
82
|
+
* The raw public key bytes
|
|
83
|
+
*/
|
|
84
|
+
readonly raw: Uint8Array;
|
|
85
|
+
/**
|
|
86
|
+
* Returns `true` if the passed object matches this key
|
|
87
|
+
*/
|
|
88
|
+
equals(key?: any): boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Returns this public key as an identity hash containing the protobuf wrapped
|
|
91
|
+
* public key
|
|
92
|
+
*/
|
|
93
|
+
toMultihash(): MultihashDigest<0x0>;
|
|
94
|
+
/**
|
|
95
|
+
* Return this public key as a CID encoded with the `libp2p-key` codec
|
|
96
|
+
*
|
|
97
|
+
* The digest contains an identity hash containing the protobuf wrapped
|
|
98
|
+
* version of the public key.
|
|
99
|
+
*/
|
|
100
|
+
toCID(): CID<unknown, 0x72, 0x0, 1>;
|
|
101
|
+
/**
|
|
102
|
+
* Verify the passed data was signed by the private key corresponding to this
|
|
103
|
+
* public key
|
|
104
|
+
*/
|
|
105
|
+
verify(data: Uint8Array | Uint8ArrayList, sig: Uint8Array): boolean | Promise<boolean>;
|
|
106
|
+
/**
|
|
107
|
+
* Returns this key as a multihash with base58btc encoding
|
|
108
|
+
*/
|
|
109
|
+
toString(): string;
|
|
50
110
|
}
|
|
51
111
|
export type PublicKey = RSAPublicKey | Ed25519PublicKey | Secp256k1PublicKey;
|
|
52
112
|
/**
|
|
@@ -57,18 +117,17 @@ export declare function isPublicKey(key?: any): key is PublicKey;
|
|
|
57
117
|
/**
|
|
58
118
|
* Generic private key interface
|
|
59
119
|
*/
|
|
60
|
-
interface
|
|
120
|
+
export interface RSAPrivateKey {
|
|
61
121
|
/**
|
|
62
122
|
* The type of this key
|
|
63
123
|
*/
|
|
64
|
-
readonly type:
|
|
124
|
+
readonly type: 'RSA';
|
|
65
125
|
/**
|
|
66
126
|
* The public key that corresponds to this private key
|
|
67
127
|
*/
|
|
68
|
-
readonly publicKey:
|
|
128
|
+
readonly publicKey: RSAPublicKey;
|
|
69
129
|
/**
|
|
70
|
-
*
|
|
71
|
-
* DER format (for RSA keys)
|
|
130
|
+
* PKIX in ASN1 DER format
|
|
72
131
|
*/
|
|
73
132
|
readonly raw: Uint8Array;
|
|
74
133
|
/**
|
|
@@ -81,11 +140,51 @@ interface PrivateKeyBase<KeyType extends string, PublicKeyType extends PublicKey
|
|
|
81
140
|
*/
|
|
82
141
|
sign(data: Uint8Array | Uint8ArrayList): Uint8Array | Promise<Uint8Array>;
|
|
83
142
|
}
|
|
84
|
-
export interface
|
|
85
|
-
|
|
86
|
-
|
|
143
|
+
export interface Ed25519PrivateKey {
|
|
144
|
+
/**
|
|
145
|
+
* The type of this key
|
|
146
|
+
*/
|
|
147
|
+
readonly type: 'Ed25519';
|
|
148
|
+
/**
|
|
149
|
+
* The public key that corresponds to this private key
|
|
150
|
+
*/
|
|
151
|
+
readonly publicKey: Ed25519PublicKey;
|
|
152
|
+
/**
|
|
153
|
+
* The raw public key bytes
|
|
154
|
+
*/
|
|
155
|
+
readonly raw: Uint8Array;
|
|
156
|
+
/**
|
|
157
|
+
* Returns `true` if the passed object matches this key
|
|
158
|
+
*/
|
|
159
|
+
equals(key?: any): boolean;
|
|
160
|
+
/**
|
|
161
|
+
* Sign the passed data with this private key and return the signature for
|
|
162
|
+
* later verification
|
|
163
|
+
*/
|
|
164
|
+
sign(data: Uint8Array | Uint8ArrayList): Uint8Array | Promise<Uint8Array>;
|
|
87
165
|
}
|
|
88
|
-
export interface Secp256k1PrivateKey
|
|
166
|
+
export interface Secp256k1PrivateKey {
|
|
167
|
+
/**
|
|
168
|
+
* The type of this key
|
|
169
|
+
*/
|
|
170
|
+
readonly type: 'secp256k1';
|
|
171
|
+
/**
|
|
172
|
+
* The public key that corresponds to this private key
|
|
173
|
+
*/
|
|
174
|
+
readonly publicKey: Secp256k1PublicKey;
|
|
175
|
+
/**
|
|
176
|
+
* The raw public key bytes
|
|
177
|
+
*/
|
|
178
|
+
readonly raw: Uint8Array;
|
|
179
|
+
/**
|
|
180
|
+
* Returns `true` if the passed object matches this key
|
|
181
|
+
*/
|
|
182
|
+
equals(key?: any): boolean;
|
|
183
|
+
/**
|
|
184
|
+
* Sign the passed data with this private key and return the signature for
|
|
185
|
+
* later verification
|
|
186
|
+
*/
|
|
187
|
+
sign(data: Uint8Array | Uint8ArrayList): Uint8Array | Promise<Uint8Array>;
|
|
89
188
|
}
|
|
90
189
|
export type PrivateKey = RSAPrivateKey | Ed25519PrivateKey | Secp256k1PrivateKey;
|
|
91
190
|
/**
|
|
@@ -93,5 +192,4 @@ export type PrivateKey = RSAPrivateKey | Ed25519PrivateKey | Secp256k1PrivateKey
|
|
|
93
192
|
* interface. Can be used to disambiguate object types.
|
|
94
193
|
*/
|
|
95
194
|
export declare function isPrivateKey(key?: any): key is PrivateKey;
|
|
96
|
-
export {};
|
|
97
195
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/keys/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AACpE,OAA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index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/keys/index.ts"],"names":[],"mappings":"AAuIA;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAE,GAAS;IACpC,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;QAChB,OAAO,KAAK,CAAA;IACd,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,IAAI,KAAK,KAAK,IAAI,GAAG,CAAC,IAAI,KAAK,SAAS,IAAI,GAAG,CAAC,IAAI,KAAK,WAAW,CAAC;QAC/E,GAAG,CAAC,GAAG,YAAY,UAAU;QAC7B,OAAO,GAAG,CAAC,MAAM,KAAK,UAAU;QAChC,OAAO,GAAG,CAAC,WAAW,KAAK,UAAU;QACrC,OAAO,GAAG,CAAC,KAAK,KAAK,UAAU;QAC/B,OAAO,GAAG,CAAC,MAAM,KAAK,UAAU,CAAA;AACpC,CAAC;AA2FD;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAE,GAAS;IACrC,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;QAChB,OAAO,KAAK,CAAA;IACd,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,IAAI,KAAK,KAAK,IAAI,GAAG,CAAC,IAAI,KAAK,SAAS,IAAI,GAAG,CAAC,IAAI,KAAK,WAAW,CAAC;QAC/E,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC;QAC1B,GAAG,CAAC,GAAG,YAAY,UAAU;QAC7B,OAAO,GAAG,CAAC,MAAM,KAAK,UAAU;QAChC,OAAO,GAAG,CAAC,IAAI,KAAK,UAAU,CAAA;AAClC,CAAC"}
|
|
@@ -124,6 +124,126 @@ export interface CounterGroup<T extends string = any> {
|
|
|
124
124
|
*/
|
|
125
125
|
reset(): void;
|
|
126
126
|
}
|
|
127
|
+
export interface HistogramOptions extends MetricOptions {
|
|
128
|
+
/**
|
|
129
|
+
* Buckets for the histogram
|
|
130
|
+
*/
|
|
131
|
+
buckets?: number[];
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Create tracked metrics that are expensive to calculate by passing
|
|
135
|
+
* a function that is only invoked when metrics are being scraped
|
|
136
|
+
*/
|
|
137
|
+
export interface CalculatedHistogramOptions<T = number> extends HistogramOptions {
|
|
138
|
+
/**
|
|
139
|
+
* An optional function invoked to calculate the component metric instead of
|
|
140
|
+
* using `.observe`
|
|
141
|
+
*/
|
|
142
|
+
calculate: CalculateMetric<T>;
|
|
143
|
+
}
|
|
144
|
+
export interface Histogram {
|
|
145
|
+
/**
|
|
146
|
+
* Observe the passed value
|
|
147
|
+
*/
|
|
148
|
+
observe(value: number): void;
|
|
149
|
+
/**
|
|
150
|
+
* Reset this histogram to its default value
|
|
151
|
+
*/
|
|
152
|
+
reset(): void;
|
|
153
|
+
/**
|
|
154
|
+
* Start a timed metric, call the returned function to
|
|
155
|
+
* stop the timer
|
|
156
|
+
*/
|
|
157
|
+
timer(): StopTimer;
|
|
158
|
+
}
|
|
159
|
+
export interface HistogramGroup<T extends string = any> {
|
|
160
|
+
/**
|
|
161
|
+
* Observe the passed value for the named key in the group
|
|
162
|
+
*/
|
|
163
|
+
observe(values: Partial<Record<T, number>>): void;
|
|
164
|
+
/**
|
|
165
|
+
* Reset the passed key in this histogram group to its default value
|
|
166
|
+
* or all keys if no key is passed
|
|
167
|
+
*/
|
|
168
|
+
reset(): void;
|
|
169
|
+
/**
|
|
170
|
+
* Start a timed metric for the named key in the group, call
|
|
171
|
+
* the returned function to stop the timer
|
|
172
|
+
*/
|
|
173
|
+
timer(key: string): StopTimer;
|
|
174
|
+
}
|
|
175
|
+
export interface SummaryOptions extends MetricOptions {
|
|
176
|
+
/**
|
|
177
|
+
* Percentiles for the summary
|
|
178
|
+
*/
|
|
179
|
+
percentiles?: number[];
|
|
180
|
+
/**
|
|
181
|
+
* Configure how old a bucket can be before it is reset for sliding window
|
|
182
|
+
*/
|
|
183
|
+
maxAgeSeconds?: number;
|
|
184
|
+
/**
|
|
185
|
+
* Configure how many buckets in the sliding window
|
|
186
|
+
*/
|
|
187
|
+
ageBuckets?: number;
|
|
188
|
+
/**
|
|
189
|
+
* Remove entries without any new values in the last `maxAgeSeconds`
|
|
190
|
+
*/
|
|
191
|
+
pruneAgedBuckets?: boolean;
|
|
192
|
+
/**
|
|
193
|
+
* Control compression of data in t-digest
|
|
194
|
+
*/
|
|
195
|
+
compressCount?: number;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Create tracked metrics that are expensive to calculate by passing
|
|
199
|
+
* a function that is only invoked when metrics are being scraped
|
|
200
|
+
*/
|
|
201
|
+
export interface CalculatedSummaryOptions<T = number> extends SummaryOptions {
|
|
202
|
+
/**
|
|
203
|
+
* An optional function invoked to calculate the component metric instead of
|
|
204
|
+
* using `.observe`
|
|
205
|
+
*/
|
|
206
|
+
calculate: CalculateMetric<T>;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* A tracked summary loosely based on the Summary interface exposed
|
|
210
|
+
* by the prom-client module
|
|
211
|
+
*/
|
|
212
|
+
export interface Summary {
|
|
213
|
+
/**
|
|
214
|
+
* Observe the passed value
|
|
215
|
+
*/
|
|
216
|
+
observe(value: number): void;
|
|
217
|
+
/**
|
|
218
|
+
* Reset this summary to its default value
|
|
219
|
+
*/
|
|
220
|
+
reset(): void;
|
|
221
|
+
/**
|
|
222
|
+
* Start a timed metric, call the returned function to
|
|
223
|
+
* stop the timer
|
|
224
|
+
*/
|
|
225
|
+
timer(): StopTimer;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* A group of tracked summaries loosely based on the Summary interface
|
|
229
|
+
* exposed by the prom-client module
|
|
230
|
+
*/
|
|
231
|
+
export interface SummaryGroup<T extends string = any> {
|
|
232
|
+
/**
|
|
233
|
+
* Observe the passed value for the named key in the group
|
|
234
|
+
*/
|
|
235
|
+
observe(values: Partial<Record<T, number>>): void;
|
|
236
|
+
/**
|
|
237
|
+
* Reset the passed key in this summary group to its default value
|
|
238
|
+
* or all keys if no key is passed
|
|
239
|
+
*/
|
|
240
|
+
reset(): void;
|
|
241
|
+
/**
|
|
242
|
+
* Start a timed metric for the named key in the group, call
|
|
243
|
+
* the returned function to stop the timer
|
|
244
|
+
*/
|
|
245
|
+
timer(key: string): StopTimer;
|
|
246
|
+
}
|
|
127
247
|
/**
|
|
128
248
|
* The libp2p metrics tracking object. This interface is only concerned
|
|
129
249
|
* with the collection of metrics, please see the individual implementations
|
|
@@ -299,5 +419,27 @@ export interface Metrics {
|
|
|
299
419
|
* method on the returned counter group object
|
|
300
420
|
*/
|
|
301
421
|
registerCounterGroup: ((name: string, options?: MetricOptions) => CounterGroup) & ((name: string, options: CalculatedMetricOptions<Record<string, number>>) => void);
|
|
422
|
+
/**
|
|
423
|
+
* Register an arbitrary histogram. Call this to set help/labels for histograms
|
|
424
|
+
* and observe them by calling methods on the returned histogram object
|
|
425
|
+
*/
|
|
426
|
+
registerHistogram: ((name: string, options?: HistogramOptions) => Histogram) & ((name: string, options: CalculatedHistogramOptions) => void);
|
|
427
|
+
/**
|
|
428
|
+
* Register a a group of related histograms. Call this to set help/labels for
|
|
429
|
+
* groups of related histograms that will be updated with by calling the `.observe`
|
|
430
|
+
* method on the returned histogram group object
|
|
431
|
+
*/
|
|
432
|
+
registerHistogramGroup: ((name: string, options?: HistogramOptions) => HistogramGroup) & ((name: string, options: CalculatedHistogramOptions<Record<string, number>>) => void);
|
|
433
|
+
/**
|
|
434
|
+
* Register an arbitrary summary. Call this to set help/labels for summaries
|
|
435
|
+
* and observe them by calling methods on the returned summary object
|
|
436
|
+
*/
|
|
437
|
+
registerSummary: ((name: string, options?: SummaryOptions) => Summary) & ((name: string, options: CalculatedSummaryOptions) => void);
|
|
438
|
+
/**
|
|
439
|
+
* Register a a group of related summaries. Call this to set help/labels for
|
|
440
|
+
* groups of related summaries that will be updated with by calling the `.observe`
|
|
441
|
+
* method on the returned summary group object
|
|
442
|
+
*/
|
|
443
|
+
registerSummaryGroup: ((name: string, options?: SummaryOptions) => SummaryGroup) & ((name: string, options: CalculatedSummaryOptions<Record<string, number>>) => void);
|
|
302
444
|
}
|
|
303
445
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/metrics/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAErF;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED;;;GAGG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC,CAAA;AAExE;;;GAGG;AACH,MAAM,WAAW,uBAAuB,CAAC,CAAC,GAAG,MAAM,CAAE,SAAQ,aAAa;IACxE;;;OAGG;IACH,SAAS,EAAE,eAAe,CAAC,CAAC,CAAC,CAAA;CAC9B;AAED;;;GAGG;AACH,MAAM,WAAW,SAAS;IAAG,IAAI,IAAI,CAAA;CAAE;AAEvC;;;GAGG;AACH,MAAM,WAAW,MAAM;IACrB;;OAEG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IAE3B;;OAEG;IACH,SAAS,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAE/B;;OAEG;IACH,SAAS,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAE/B;;OAEG;IACH,KAAK,IAAI,IAAI,CAAA;IAEb;;;OAGG;IACH,KAAK,IAAI,SAAS,CAAA;CACnB;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW,CAAC,CAAC,SAAS,MAAM,GAAG,GAAG;IACjD;;OAEG;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AAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,0BAA0B,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,KAAK,IAAI,CAAC,CAAA;IAE9K;;;OAGG;IACH,eAAe,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,wBAAwB,KAAK,IAAI,CAAC,CAAA;IAEpI;;;;OAIG;IACH,oBAAoB,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,KAAK,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,wBAAwB,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,KAAK,IAAI,CAAC,CAAA;CACvK"}
|
|
@@ -95,7 +95,7 @@ export interface PubSubInit {
|
|
|
95
95
|
*/
|
|
96
96
|
maxOutboundStreams?: number;
|
|
97
97
|
}
|
|
98
|
-
interface Subscription {
|
|
98
|
+
export interface Subscription {
|
|
99
99
|
topic: string;
|
|
100
100
|
subscribe: boolean;
|
|
101
101
|
}
|
|
@@ -242,5 +242,4 @@ export declare const pubSubSymbol: unique symbol;
|
|
|
242
242
|
* Returns true if the passed argument is a PubSub implementation
|
|
243
243
|
*/
|
|
244
244
|
export declare function isPubSub(obj?: any): obj is PubSub;
|
|
245
|
-
export {};
|
|
246
245
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pubsub/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,M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AiB,EAAE,WAAW,CAAC,KAAK,CAAC,CAAA;IACrC,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,CAAA;CAC5B;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY,eAA+B,CAAA;AAExD;;GAEG;AACH,wBAAgB,QAAQ,CAAE,GAAG,CAAC,EAAE,GAAG,GAAG,GAAG,IAAI,MAAM,CAElD"}
|
|
@@ -8,11 +8,15 @@ export interface StreamHandler {
|
|
|
8
8
|
}
|
|
9
9
|
export interface StreamHandlerOptions {
|
|
10
10
|
/**
|
|
11
|
-
* How many incoming streams can be open for this protocol at the same time on each connection
|
|
11
|
+
* How many incoming streams can be open for this protocol at the same time on each connection
|
|
12
|
+
*
|
|
13
|
+
* @default 32
|
|
12
14
|
*/
|
|
13
15
|
maxInboundStreams?: number;
|
|
14
16
|
/**
|
|
15
|
-
* How many outgoing streams can be open for this protocol at the same time on each connection
|
|
17
|
+
* How many outgoing streams can be open for this protocol at the same time on each connection
|
|
18
|
+
*
|
|
19
|
+
* @default 64
|
|
16
20
|
*/
|
|
17
21
|
maxOutboundStreams?: number;
|
|
18
22
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/stream-handler/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAEhE,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,UAAU,CAAA;CACvB;AAED,MAAM,WAAW,aAAa;IAC5B,CAAC,IAAI,EAAE,kBAAkB,GAAG,IAAI,CAAA;CACjC;AAED,MAAM,WAAW,oBAAoB;IACnC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/stream-handler/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAEhE,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,UAAU,CAAA;CACvB;AAED,MAAM,WAAW,aAAa;IAC5B,CAAC,IAAI,EAAE,kBAAkB,GAAG,IAAI,CAAA;CACjC;AAED,MAAM,WAAW,oBAAoB;IACnC;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAE1B;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAE3B;;;OAGG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAA;CACjC;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,aAAa,CAAA;IACtB,OAAO,EAAE,oBAAoB,CAAA;CAC9B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/interface",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0-7f7ec82ae",
|
|
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",
|
package/src/connection/index.ts
CHANGED
|
@@ -126,7 +126,7 @@ export interface Stream extends Duplex<AsyncGenerator<Uint8ArrayList>, Source<Ui
|
|
|
126
126
|
*
|
|
127
127
|
* This will cause a `RESET` message to be sent to the remote, *unless* the sink has already ended.
|
|
128
128
|
*
|
|
129
|
-
* The sink will return and the source will throw
|
|
129
|
+
* The sink will return and the source will throw.
|
|
130
130
|
*/
|
|
131
131
|
abort(err: Error): void
|
|
132
132
|
|
package/src/events.browser.ts
CHANGED
package/src/events.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { setMaxListeners as nodeSetMaxListeners } from 'events'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Create a setMaxListeners that doesn't break browser usage
|
|
5
|
+
*/
|
|
4
6
|
export const setMaxListeners: typeof nodeSetMaxListeners = (n, ...eventTargets) => {
|
|
5
7
|
try {
|
|
6
8
|
nodeSetMaxListeners(n, ...eventTargets)
|
package/src/keys/index.ts
CHANGED
|
@@ -4,15 +4,14 @@ import type { Uint8ArrayList } from 'uint8arraylist'
|
|
|
4
4
|
|
|
5
5
|
export type KeyType = 'RSA' | 'Ed25519' | 'secp256k1'
|
|
6
6
|
|
|
7
|
-
interface
|
|
7
|
+
export interface RSAPublicKey {
|
|
8
8
|
/**
|
|
9
9
|
* The type of this key
|
|
10
10
|
*/
|
|
11
|
-
readonly type:
|
|
11
|
+
readonly type: 'RSA'
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
15
|
-
* DER format (for RSA keys)
|
|
14
|
+
* PKIX in ASN1 DER format
|
|
16
15
|
*/
|
|
17
16
|
readonly raw: Uint8Array
|
|
18
17
|
|
|
@@ -24,20 +23,101 @@ interface PublicKeyBase<KeyType extends string, DigestCode extends number = numb
|
|
|
24
23
|
/**
|
|
25
24
|
* Returns this public key as a Multihash digest.
|
|
26
25
|
*
|
|
27
|
-
* It contains
|
|
28
|
-
* public key (for Ed25519 and secp256k1 keys) or a sha256 hash of the
|
|
29
|
-
* protobuf version of the public key (RSA keys).
|
|
26
|
+
* It contains a sha256 hash of the protobuf version of the public key.
|
|
30
27
|
*/
|
|
31
|
-
toMultihash(): MultihashDigest<
|
|
28
|
+
toMultihash(): MultihashDigest<0x12>
|
|
32
29
|
|
|
33
30
|
/**
|
|
34
31
|
* Return this public key as a CID encoded with the `libp2p-key` codec
|
|
35
32
|
*
|
|
36
|
-
* The digest contains
|
|
37
|
-
*
|
|
38
|
-
* protobuf version of the public key (RSA keys).
|
|
33
|
+
* The digest contains a sha256 hash of the protobuf version of the public
|
|
34
|
+
* key.
|
|
39
35
|
*/
|
|
40
|
-
toCID(): CID<unknown, 0x72,
|
|
36
|
+
toCID(): CID<unknown, 0x72, 0x12, 1>
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Verify the passed data was signed by the private key corresponding to this
|
|
40
|
+
* public key
|
|
41
|
+
*/
|
|
42
|
+
verify(data: Uint8Array | Uint8ArrayList, sig: Uint8Array): boolean | Promise<boolean>
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Returns this key as a multihash with base58btc encoding
|
|
46
|
+
*/
|
|
47
|
+
toString(): string
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface Ed25519PublicKey {
|
|
51
|
+
/**
|
|
52
|
+
* The type of this key
|
|
53
|
+
*/
|
|
54
|
+
readonly type: 'Ed25519'
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The raw public key bytes
|
|
58
|
+
*/
|
|
59
|
+
readonly raw: Uint8Array
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Returns `true` if the passed object matches this key
|
|
63
|
+
*/
|
|
64
|
+
equals(key?: any): boolean
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Returns this public key as an identity hash containing the protobuf wrapped
|
|
68
|
+
* public key
|
|
69
|
+
*/
|
|
70
|
+
toMultihash(): MultihashDigest<0x0>
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Return this public key as a CID encoded with the `libp2p-key` codec
|
|
74
|
+
*
|
|
75
|
+
* The digest contains an identity hash containing the protobuf wrapped
|
|
76
|
+
* version of the public key.
|
|
77
|
+
*/
|
|
78
|
+
toCID(): CID<unknown, 0x72, 0x0, 1>
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Verify the passed data was signed by the private key corresponding to this
|
|
82
|
+
* public key
|
|
83
|
+
*/
|
|
84
|
+
verify(data: Uint8Array | Uint8ArrayList, sig: Uint8Array): boolean | Promise<boolean>
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Returns this key as a multihash with base58btc encoding
|
|
88
|
+
*/
|
|
89
|
+
toString(): string
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface Secp256k1PublicKey {
|
|
93
|
+
/**
|
|
94
|
+
* The type of this key
|
|
95
|
+
*/
|
|
96
|
+
readonly type: 'secp256k1'
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* The raw public key bytes
|
|
100
|
+
*/
|
|
101
|
+
readonly raw: Uint8Array
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Returns `true` if the passed object matches this key
|
|
105
|
+
*/
|
|
106
|
+
equals(key?: any): boolean
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Returns this public key as an identity hash containing the protobuf wrapped
|
|
110
|
+
* public key
|
|
111
|
+
*/
|
|
112
|
+
toMultihash(): MultihashDigest<0x0>
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Return this public key as a CID encoded with the `libp2p-key` codec
|
|
116
|
+
*
|
|
117
|
+
* The digest contains an identity hash containing the protobuf wrapped
|
|
118
|
+
* version of the public key.
|
|
119
|
+
*/
|
|
120
|
+
toCID(): CID<unknown, 0x72, 0x0, 1>
|
|
41
121
|
|
|
42
122
|
/**
|
|
43
123
|
* Verify the passed data was signed by the private key corresponding to this
|
|
@@ -51,9 +131,6 @@ interface PublicKeyBase<KeyType extends string, DigestCode extends number = numb
|
|
|
51
131
|
toString(): string
|
|
52
132
|
}
|
|
53
133
|
|
|
54
|
-
export interface RSAPublicKey extends PublicKeyBase<'RSA', 0x12> {}
|
|
55
|
-
export interface Ed25519PublicKey extends PublicKeyBase<'Ed25519', 0x0> {}
|
|
56
|
-
export interface Secp256k1PublicKey extends PublicKeyBase<'secp256k1', 0x0> {}
|
|
57
134
|
export type PublicKey = RSAPublicKey | Ed25519PublicKey | Secp256k1PublicKey
|
|
58
135
|
|
|
59
136
|
/**
|
|
@@ -76,20 +153,75 @@ export function isPublicKey (key?: any): key is PublicKey {
|
|
|
76
153
|
/**
|
|
77
154
|
* Generic private key interface
|
|
78
155
|
*/
|
|
79
|
-
interface
|
|
156
|
+
export interface RSAPrivateKey {
|
|
157
|
+
/**
|
|
158
|
+
* The type of this key
|
|
159
|
+
*/
|
|
160
|
+
readonly type: 'RSA'
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* The public key that corresponds to this private key
|
|
164
|
+
*/
|
|
165
|
+
readonly publicKey: RSAPublicKey
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* PKIX in ASN1 DER format
|
|
169
|
+
*/
|
|
170
|
+
readonly raw: Uint8Array
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Returns `true` if the passed object matches this key
|
|
174
|
+
*/
|
|
175
|
+
equals(key?: any): boolean
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Sign the passed data with this private key and return the signature for
|
|
179
|
+
* later verification
|
|
180
|
+
*/
|
|
181
|
+
sign(data: Uint8Array | Uint8ArrayList): Uint8Array | Promise<Uint8Array>
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export interface Ed25519PrivateKey {
|
|
185
|
+
/**
|
|
186
|
+
* The type of this key
|
|
187
|
+
*/
|
|
188
|
+
readonly type: 'Ed25519'
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* The public key that corresponds to this private key
|
|
192
|
+
*/
|
|
193
|
+
readonly publicKey: Ed25519PublicKey
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* The raw public key bytes
|
|
197
|
+
*/
|
|
198
|
+
readonly raw: Uint8Array
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Returns `true` if the passed object matches this key
|
|
202
|
+
*/
|
|
203
|
+
equals(key?: any): boolean
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Sign the passed data with this private key and return the signature for
|
|
207
|
+
* later verification
|
|
208
|
+
*/
|
|
209
|
+
sign(data: Uint8Array | Uint8ArrayList): Uint8Array | Promise<Uint8Array>
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export interface Secp256k1PrivateKey {
|
|
80
213
|
/**
|
|
81
214
|
* The type of this key
|
|
82
215
|
*/
|
|
83
|
-
readonly type:
|
|
216
|
+
readonly type: 'secp256k1'
|
|
84
217
|
|
|
85
218
|
/**
|
|
86
219
|
* The public key that corresponds to this private key
|
|
87
220
|
*/
|
|
88
|
-
readonly publicKey:
|
|
221
|
+
readonly publicKey: Secp256k1PublicKey
|
|
89
222
|
|
|
90
223
|
/**
|
|
91
|
-
* The raw public key bytes
|
|
92
|
-
* DER format (for RSA keys)
|
|
224
|
+
* The raw public key bytes
|
|
93
225
|
*/
|
|
94
226
|
readonly raw: Uint8Array
|
|
95
227
|
|
|
@@ -105,9 +237,6 @@ interface PrivateKeyBase<KeyType extends string, PublicKeyType extends PublicKey
|
|
|
105
237
|
sign(data: Uint8Array | Uint8ArrayList): Uint8Array | Promise<Uint8Array>
|
|
106
238
|
}
|
|
107
239
|
|
|
108
|
-
export interface RSAPrivateKey extends PrivateKeyBase<'RSA', RSAPublicKey> {}
|
|
109
|
-
export interface Ed25519PrivateKey extends PrivateKeyBase<'Ed25519', Ed25519PublicKey> {}
|
|
110
|
-
export interface Secp256k1PrivateKey extends PrivateKeyBase<'secp256k1', Secp256k1PublicKey> {}
|
|
111
240
|
export type PrivateKey = RSAPrivateKey | Ed25519PrivateKey | Secp256k1PrivateKey
|
|
112
241
|
|
|
113
242
|
/**
|
package/src/metrics/index.ts
CHANGED
|
@@ -142,6 +142,146 @@ export interface CounterGroup<T extends string = any> {
|
|
|
142
142
|
reset(): void
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
+
export interface HistogramOptions extends MetricOptions {
|
|
146
|
+
/**
|
|
147
|
+
* Buckets for the histogram
|
|
148
|
+
*/
|
|
149
|
+
buckets?: number[]
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Create tracked metrics that are expensive to calculate by passing
|
|
154
|
+
* a function that is only invoked when metrics are being scraped
|
|
155
|
+
*/
|
|
156
|
+
export interface CalculatedHistogramOptions<T = number> extends HistogramOptions {
|
|
157
|
+
/**
|
|
158
|
+
* An optional function invoked to calculate the component metric instead of
|
|
159
|
+
* using `.observe`
|
|
160
|
+
*/
|
|
161
|
+
calculate: CalculateMetric<T>
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export interface Histogram {
|
|
165
|
+
/**
|
|
166
|
+
* Observe the passed value
|
|
167
|
+
*/
|
|
168
|
+
observe(value: number): void
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Reset this histogram to its default value
|
|
172
|
+
*/
|
|
173
|
+
reset(): void
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Start a timed metric, call the returned function to
|
|
177
|
+
* stop the timer
|
|
178
|
+
*/
|
|
179
|
+
timer(): StopTimer
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export interface HistogramGroup<T extends string = any> {
|
|
183
|
+
/**
|
|
184
|
+
* Observe the passed value for the named key in the group
|
|
185
|
+
*/
|
|
186
|
+
observe(values: Partial<Record<T, number>>): void
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Reset the passed key in this histogram group to its default value
|
|
190
|
+
* or all keys if no key is passed
|
|
191
|
+
*/
|
|
192
|
+
reset(): void
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Start a timed metric for the named key in the group, call
|
|
196
|
+
* the returned function to stop the timer
|
|
197
|
+
*/
|
|
198
|
+
timer(key: string): StopTimer
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export interface SummaryOptions extends MetricOptions {
|
|
202
|
+
/**
|
|
203
|
+
* Percentiles for the summary
|
|
204
|
+
*/
|
|
205
|
+
percentiles?: number[]
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Configure how old a bucket can be before it is reset for sliding window
|
|
209
|
+
*/
|
|
210
|
+
maxAgeSeconds?: number
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Configure how many buckets in the sliding window
|
|
214
|
+
*/
|
|
215
|
+
ageBuckets?: number
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Remove entries without any new values in the last `maxAgeSeconds`
|
|
219
|
+
*/
|
|
220
|
+
pruneAgedBuckets?: boolean
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Control compression of data in t-digest
|
|
224
|
+
*/
|
|
225
|
+
compressCount?: number
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Create tracked metrics that are expensive to calculate by passing
|
|
230
|
+
* a function that is only invoked when metrics are being scraped
|
|
231
|
+
*/
|
|
232
|
+
export interface CalculatedSummaryOptions<T = number> extends SummaryOptions {
|
|
233
|
+
/**
|
|
234
|
+
* An optional function invoked to calculate the component metric instead of
|
|
235
|
+
* using `.observe`
|
|
236
|
+
*/
|
|
237
|
+
calculate: CalculateMetric<T>
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* A tracked summary loosely based on the Summary interface exposed
|
|
242
|
+
* by the prom-client module
|
|
243
|
+
*/
|
|
244
|
+
export interface Summary {
|
|
245
|
+
/**
|
|
246
|
+
* Observe the passed value
|
|
247
|
+
*/
|
|
248
|
+
observe(value: number): void
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Reset this summary to its default value
|
|
252
|
+
*/
|
|
253
|
+
reset(): void
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Start a timed metric, call the returned function to
|
|
257
|
+
* stop the timer
|
|
258
|
+
*/
|
|
259
|
+
timer(): StopTimer
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* A group of tracked summaries loosely based on the Summary interface
|
|
264
|
+
* exposed by the prom-client module
|
|
265
|
+
*/
|
|
266
|
+
export interface SummaryGroup<T extends string = any> {
|
|
267
|
+
/**
|
|
268
|
+
* Observe the passed value for the named key in the group
|
|
269
|
+
*/
|
|
270
|
+
observe(values: Partial<Record<T, number>>): void
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Reset the passed key in this summary group to its default value
|
|
274
|
+
* or all keys if no key is passed
|
|
275
|
+
*/
|
|
276
|
+
reset(): void
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Start a timed metric for the named key in the group, call
|
|
280
|
+
* the returned function to stop the timer
|
|
281
|
+
*/
|
|
282
|
+
timer(key: string): StopTimer
|
|
283
|
+
}
|
|
284
|
+
|
|
145
285
|
/**
|
|
146
286
|
* The libp2p metrics tracking object. This interface is only concerned
|
|
147
287
|
* with the collection of metrics, please see the individual implementations
|
|
@@ -322,4 +462,30 @@ export interface Metrics {
|
|
|
322
462
|
* method on the returned counter group object
|
|
323
463
|
*/
|
|
324
464
|
registerCounterGroup: ((name: string, options?: MetricOptions) => CounterGroup) & ((name: string, options: CalculatedMetricOptions<Record<string, number>>) => void)
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* Register an arbitrary histogram. Call this to set help/labels for histograms
|
|
468
|
+
* and observe them by calling methods on the returned histogram object
|
|
469
|
+
*/
|
|
470
|
+
registerHistogram: ((name: string, options?: HistogramOptions) => Histogram) & ((name: string, options: CalculatedHistogramOptions) => void)
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* Register a a group of related histograms. Call this to set help/labels for
|
|
474
|
+
* groups of related histograms that will be updated with by calling the `.observe`
|
|
475
|
+
* method on the returned histogram group object
|
|
476
|
+
*/
|
|
477
|
+
registerHistogramGroup: ((name: string, options?: HistogramOptions) => HistogramGroup) & ((name: string, options: CalculatedHistogramOptions<Record<string, number>>) => void)
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* Register an arbitrary summary. Call this to set help/labels for summaries
|
|
481
|
+
* and observe them by calling methods on the returned summary object
|
|
482
|
+
*/
|
|
483
|
+
registerSummary: ((name: string, options?: SummaryOptions) => Summary) & ((name: string, options: CalculatedSummaryOptions) => void)
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* Register a a group of related summaries. Call this to set help/labels for
|
|
487
|
+
* groups of related summaries that will be updated with by calling the `.observe`
|
|
488
|
+
* method on the returned summary group object
|
|
489
|
+
*/
|
|
490
|
+
registerSummaryGroup: ((name: string, options?: SummaryOptions) => SummaryGroup) & ((name: string, options: CalculatedSummaryOptions<Record<string, number>>) => void)
|
|
325
491
|
}
|
package/src/pubsub/index.ts
CHANGED
|
@@ -11,12 +11,16 @@ export interface StreamHandler {
|
|
|
11
11
|
|
|
12
12
|
export interface StreamHandlerOptions {
|
|
13
13
|
/**
|
|
14
|
-
* How many incoming streams can be open for this protocol at the same time on each connection
|
|
14
|
+
* How many incoming streams can be open for this protocol at the same time on each connection
|
|
15
|
+
*
|
|
16
|
+
* @default 32
|
|
15
17
|
*/
|
|
16
18
|
maxInboundStreams?: number
|
|
17
19
|
|
|
18
20
|
/**
|
|
19
|
-
* How many outgoing streams can be open for this protocol at the same time on each connection
|
|
21
|
+
* How many outgoing streams can be open for this protocol at the same time on each connection
|
|
22
|
+
*
|
|
23
|
+
* @default 64
|
|
20
24
|
*/
|
|
21
25
|
maxOutboundStreams?: number
|
|
22
26
|
|