@libp2p/interface 1.2.0 → 1.3.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 +2 -2
- package/dist/src/keys/index.d.ts +5 -5
- package/dist/src/keys/index.d.ts.map +1 -1
- package/dist/src/peer-id/index.d.ts +15 -16
- package/dist/src/peer-id/index.d.ts.map +1 -1
- package/dist/src/peer-id/index.js.map +1 -1
- package/dist/typedoc-urls.json +2 -1
- package/package.json +1 -1
- package/src/keys/index.ts +5 -5
- package/src/peer-id/index.ts +16 -17
package/README.md
CHANGED
|
@@ -50,8 +50,8 @@ $ npm i @libp2p/interface
|
|
|
50
50
|
|
|
51
51
|
Licensed under either of
|
|
52
52
|
|
|
53
|
-
- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
|
|
54
|
-
- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
|
|
53
|
+
- Apache 2.0, ([LICENSE-APACHE](https://github.com/libp2p/js-libp2p/blob/main/packages/interface/LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
|
|
54
|
+
- MIT ([LICENSE-MIT](https://github.com/libp2p/js-libp2p/blob/main/packages/interface/LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
|
|
55
55
|
|
|
56
56
|
# Contribution
|
|
57
57
|
|
package/dist/src/keys/index.d.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import type { Uint8ArrayList } from 'uint8arraylist';
|
|
2
|
-
export interface PublicKey {
|
|
2
|
+
export interface PublicKey<Type extends KeyType = 'Ed25519'> {
|
|
3
3
|
readonly bytes: Uint8Array;
|
|
4
4
|
verify(data: Uint8Array | Uint8ArrayList, sig: Uint8Array): boolean | Promise<boolean>;
|
|
5
5
|
marshal(): Uint8Array;
|
|
6
|
-
equals(key: PublicKey): boolean;
|
|
6
|
+
equals(key: PublicKey<Type>): boolean;
|
|
7
7
|
hash(): Uint8Array | Promise<Uint8Array>;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* Generic private key interface
|
|
11
11
|
*/
|
|
12
|
-
export interface PrivateKey {
|
|
13
|
-
readonly public: PublicKey
|
|
12
|
+
export interface PrivateKey<Type extends KeyType = 'Ed25519'> {
|
|
13
|
+
readonly public: PublicKey<Type>;
|
|
14
14
|
readonly bytes: Uint8Array;
|
|
15
15
|
sign(data: Uint8Array | Uint8ArrayList): Uint8Array | Promise<Uint8Array>;
|
|
16
16
|
marshal(): Uint8Array;
|
|
17
|
-
equals(key: PrivateKey): boolean;
|
|
17
|
+
equals(key: PrivateKey<Type>): boolean;
|
|
18
18
|
hash(): Uint8Array | Promise<Uint8Array>;
|
|
19
19
|
/**
|
|
20
20
|
* Gets the ID of the key.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/keys/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,MAAM,WAAW,SAAS;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/keys/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,MAAM,WAAW,SAAS,CAAC,IAAI,SAAS,OAAO,GAAG,SAAS;IACzD,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAA;IAC1B,MAAM,CAAC,IAAI,EAAE,UAAU,GAAG,cAAc,EAAE,GAAG,EAAE,UAAU,GAAG,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IACtF,OAAO,IAAI,UAAU,CAAA;IACrB,MAAM,CAAC,GAAG,EAAE,SAAS,CAAC,IAAI,CAAC,GAAG,OAAO,CAAA;IACrC,IAAI,IAAI,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;CACzC;AAED;;GAEG;AACH,MAAM,WAAW,UAAU,CAAC,IAAI,SAAS,OAAO,GAAG,SAAS;IAC1D,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC,IAAI,CAAC,CAAA;IAChC,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAA;IAC1B,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,cAAc,GAAG,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;IACzE,OAAO,IAAI,UAAU,CAAA;IACrB,MAAM,CAAC,GAAG,EAAE,UAAU,CAAC,IAAI,CAAC,GAAG,OAAO,CAAA;IACtC,IAAI,IAAI,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;IACxC;;;;;;OAMG;IACH,EAAE,IAAI,OAAO,CAAC,MAAM,CAAC,CAAA;IACrB;;OAEG;IACH,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;CACtE;AAED,eAAO,MAAM,OAAO,YAAY,CAAA;AAChC,eAAO,MAAM,GAAG,QAAQ,CAAA;AACxB,eAAO,MAAM,SAAS,cAAc,CAAA;AAEpC,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,GAAG,OAAO,GAAG,GAAG,OAAO,SAAS,CAAA"}
|
|
@@ -1,30 +1,29 @@
|
|
|
1
|
+
import type { KeyType } from '../keys/index.js';
|
|
1
2
|
import type { CID } from 'multiformats/cid';
|
|
2
3
|
import type { MultihashDigest } from 'multiformats/hashes/interface';
|
|
3
|
-
export type PeerIdType =
|
|
4
|
-
interface
|
|
5
|
-
readonly type: PeerIdType;
|
|
6
|
-
readonly multihash: MultihashDigest;
|
|
7
|
-
readonly privateKey?: Uint8Array;
|
|
8
|
-
readonly publicKey?: Uint8Array;
|
|
9
|
-
toString(): string;
|
|
10
|
-
toCID(): CID;
|
|
11
|
-
toBytes(): Uint8Array;
|
|
12
|
-
equals(other?: PeerId | Uint8Array | string): boolean;
|
|
13
|
-
}
|
|
14
|
-
export interface RSAPeerId extends BasePeerId {
|
|
4
|
+
export type PeerIdType = KeyType | string;
|
|
5
|
+
export interface RSAPeerId extends PeerId {
|
|
15
6
|
readonly type: 'RSA';
|
|
16
7
|
readonly publicKey?: Uint8Array;
|
|
17
8
|
}
|
|
18
|
-
export interface Ed25519PeerId extends
|
|
9
|
+
export interface Ed25519PeerId extends PeerId {
|
|
19
10
|
readonly type: 'Ed25519';
|
|
20
11
|
readonly publicKey: Uint8Array;
|
|
21
12
|
}
|
|
22
|
-
export interface Secp256k1PeerId extends
|
|
13
|
+
export interface Secp256k1PeerId extends PeerId {
|
|
23
14
|
readonly type: 'secp256k1';
|
|
24
15
|
readonly publicKey: Uint8Array;
|
|
25
16
|
}
|
|
26
|
-
export
|
|
17
|
+
export interface PeerId {
|
|
18
|
+
type: PeerIdType;
|
|
19
|
+
multihash: MultihashDigest;
|
|
20
|
+
privateKey?: Uint8Array;
|
|
21
|
+
publicKey?: Uint8Array;
|
|
22
|
+
toString(): string;
|
|
23
|
+
toCID(): CID;
|
|
24
|
+
toBytes(): Uint8Array;
|
|
25
|
+
equals(other?: PeerId | Uint8Array | string): boolean;
|
|
26
|
+
}
|
|
27
27
|
export declare const peerIdSymbol: unique symbol;
|
|
28
28
|
export declare function isPeerId(other: any): other is PeerId;
|
|
29
|
-
export {};
|
|
30
29
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/peer-id/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAEpE,MAAM,MAAM,UAAU,GAAG,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/peer-id/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAEpE,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,MAAM,CAAA;AAEzC,MAAM,WAAW,SAAU,SAAQ,MAAM;IACvC,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAA;IACpB,QAAQ,CAAC,SAAS,CAAC,EAAE,UAAU,CAAA;CAChC;AAED,MAAM,WAAW,aAAc,SAAQ,MAAM;IAC3C,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;IACxB,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAA;CAC/B;AAED,MAAM,WAAW,eAAgB,SAAQ,MAAM;IAC7C,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAA;IAC1B,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAA;CAC/B;AAED,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,UAAU,CAAA;IAChB,SAAS,EAAE,eAAe,CAAA;IAC1B,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,SAAS,CAAC,EAAE,UAAU,CAAA;IAEtB,QAAQ,IAAI,MAAM,CAAA;IAClB,KAAK,IAAI,GAAG,CAAA;IACZ,OAAO,IAAI,UAAU,CAAA;IACrB,MAAM,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,GAAG,OAAO,CAAA;CACtD;AAED,eAAO,MAAM,YAAY,eAAgC,CAAA;AAEzD,wBAAgB,QAAQ,CAAE,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,MAAM,CAErD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/peer-id/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/peer-id/index.ts"],"names":[],"mappings":"AAiCA,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAA;AAEzD,MAAM,UAAU,QAAQ,CAAE,KAAU;IAClC,OAAO,KAAK,IAAI,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAA;AACtD,CAAC"}
|
package/dist/typedoc-urls.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
+
"KeyTypes": "https://libp2p.github.io/js-libp2p/types/_libp2p_crypto.keys.KeyTypes.html",
|
|
2
3
|
"FaultTolerance": "https://libp2p.github.io/js-libp2p/enums/_libp2p_interface.FaultTolerance.html",
|
|
3
4
|
"TopicValidatorResult": "https://libp2p.github.io/js-libp2p/enums/_libp2p_interface.TopicValidatorResult.html",
|
|
4
5
|
"AbortError": "https://libp2p.github.io/js-libp2p/classes/_libp2p_interface.AbortError.html",
|
|
@@ -62,6 +63,7 @@
|
|
|
62
63
|
"PeerDiscovery": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.PeerDiscovery.html",
|
|
63
64
|
"PeerDiscoveryEvents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.PeerDiscoveryEvents.html",
|
|
64
65
|
"PeerDiscoveryProvider": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.PeerDiscoveryProvider.html",
|
|
66
|
+
"PeerId": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.PeerId.html",
|
|
65
67
|
"PeerInfo": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.PeerInfo.html",
|
|
66
68
|
"PeerQuery": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.PeerQuery.html",
|
|
67
69
|
"PeerQueryFilter": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.PeerQueryFilter.html",
|
|
@@ -121,7 +123,6 @@
|
|
|
121
123
|
"Libp2pStatus": "https://libp2p.github.io/js-libp2p/types/_libp2p_interface.Libp2pStatus.html",
|
|
122
124
|
".:Libp2pStatus": "https://libp2p.github.io/js-libp2p/types/_libp2p_interface.Libp2pStatus.html",
|
|
123
125
|
"Message": "https://libp2p.github.io/js-libp2p/types/_libp2p_interface.Message.html",
|
|
124
|
-
"PeerId": "https://libp2p.github.io/js-libp2p/types/_libp2p_interface.PeerId.html",
|
|
125
126
|
"PeerIdType": "https://libp2p.github.io/js-libp2p/types/_libp2p_interface.PeerIdType.html",
|
|
126
127
|
"PendingDialStatus": "https://libp2p.github.io/js-libp2p/types/_libp2p_interface.PendingDialStatus.html",
|
|
127
128
|
".:PendingDialStatus": "https://libp2p.github.io/js-libp2p/types/_libp2p_interface.PendingDialStatus.html",
|
package/package.json
CHANGED
package/src/keys/index.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import type { Uint8ArrayList } from 'uint8arraylist'
|
|
2
2
|
|
|
3
|
-
export interface PublicKey {
|
|
3
|
+
export interface PublicKey<Type extends KeyType = 'Ed25519'> {
|
|
4
4
|
readonly bytes: Uint8Array
|
|
5
5
|
verify(data: Uint8Array | Uint8ArrayList, sig: Uint8Array): boolean | Promise<boolean>
|
|
6
6
|
marshal(): Uint8Array
|
|
7
|
-
equals(key: PublicKey): boolean
|
|
7
|
+
equals(key: PublicKey<Type>): boolean
|
|
8
8
|
hash(): Uint8Array | Promise<Uint8Array>
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Generic private key interface
|
|
13
13
|
*/
|
|
14
|
-
export interface PrivateKey {
|
|
15
|
-
readonly public: PublicKey
|
|
14
|
+
export interface PrivateKey<Type extends KeyType = 'Ed25519'> {
|
|
15
|
+
readonly public: PublicKey<Type>
|
|
16
16
|
readonly bytes: Uint8Array
|
|
17
17
|
sign(data: Uint8Array | Uint8ArrayList): Uint8Array | Promise<Uint8Array>
|
|
18
18
|
marshal(): Uint8Array
|
|
19
|
-
equals(key: PrivateKey): boolean
|
|
19
|
+
equals(key: PrivateKey<Type>): boolean
|
|
20
20
|
hash(): Uint8Array | Promise<Uint8Array>
|
|
21
21
|
/**
|
|
22
22
|
* Gets the ID of the key.
|
package/src/peer-id/index.ts
CHANGED
|
@@ -1,36 +1,35 @@
|
|
|
1
|
+
import type { KeyType } from '../keys/index.js'
|
|
1
2
|
import type { CID } from 'multiformats/cid'
|
|
2
3
|
import type { MultihashDigest } from 'multiformats/hashes/interface'
|
|
3
4
|
|
|
4
|
-
export type PeerIdType =
|
|
5
|
+
export type PeerIdType = KeyType | string
|
|
5
6
|
|
|
6
|
-
interface
|
|
7
|
-
readonly type: PeerIdType
|
|
8
|
-
readonly multihash: MultihashDigest
|
|
9
|
-
readonly privateKey?: Uint8Array
|
|
10
|
-
readonly publicKey?: Uint8Array
|
|
11
|
-
|
|
12
|
-
toString(): string
|
|
13
|
-
toCID(): CID
|
|
14
|
-
toBytes(): Uint8Array
|
|
15
|
-
equals(other?: PeerId | Uint8Array | string): boolean
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface RSAPeerId extends BasePeerId {
|
|
7
|
+
export interface RSAPeerId extends PeerId {
|
|
19
8
|
readonly type: 'RSA'
|
|
20
9
|
readonly publicKey?: Uint8Array
|
|
21
10
|
}
|
|
22
11
|
|
|
23
|
-
export interface Ed25519PeerId extends
|
|
12
|
+
export interface Ed25519PeerId extends PeerId {
|
|
24
13
|
readonly type: 'Ed25519'
|
|
25
14
|
readonly publicKey: Uint8Array
|
|
26
15
|
}
|
|
27
16
|
|
|
28
|
-
export interface Secp256k1PeerId extends
|
|
17
|
+
export interface Secp256k1PeerId extends PeerId {
|
|
29
18
|
readonly type: 'secp256k1'
|
|
30
19
|
readonly publicKey: Uint8Array
|
|
31
20
|
}
|
|
32
21
|
|
|
33
|
-
export
|
|
22
|
+
export interface PeerId {
|
|
23
|
+
type: PeerIdType
|
|
24
|
+
multihash: MultihashDigest
|
|
25
|
+
privateKey?: Uint8Array
|
|
26
|
+
publicKey?: Uint8Array
|
|
27
|
+
|
|
28
|
+
toString(): string
|
|
29
|
+
toCID(): CID
|
|
30
|
+
toBytes(): Uint8Array
|
|
31
|
+
equals(other?: PeerId | Uint8Array | string): boolean
|
|
32
|
+
}
|
|
34
33
|
|
|
35
34
|
export const peerIdSymbol = Symbol.for('@libp2p/peer-id')
|
|
36
35
|
|