@libp2p/peer-id 4.0.10-fd1f8343d → 4.1.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/dist/src/index.d.ts +7 -7
- package/dist/src/index.d.ts.map +1 -1
- package/dist/typedoc-urls.json +14 -0
- package/package.json +2 -2
- package/src/index.ts +6 -6
package/dist/src/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* console.log(peer.toString()) // "12D3K..."
|
|
14
14
|
* ```
|
|
15
15
|
*/
|
|
16
|
-
import { type PeerIdType, type
|
|
16
|
+
import { type Ed25519PeerId, type PeerIdType, type RSAPeerId, type Secp256k1PeerId } from '@libp2p/interface';
|
|
17
17
|
import { CID } from 'multiformats/cid';
|
|
18
18
|
import type { MultibaseDecoder } from 'multiformats/bases/interface';
|
|
19
19
|
import type { MultihashDigest } from 'multiformats/hashes/interface';
|
|
@@ -22,15 +22,15 @@ interface PeerIdInit {
|
|
|
22
22
|
multihash: MultihashDigest;
|
|
23
23
|
privateKey?: Uint8Array;
|
|
24
24
|
}
|
|
25
|
-
export declare function createPeerId(init: PeerIdInit):
|
|
26
|
-
export declare function peerIdFromPeerId(other: any):
|
|
27
|
-
export declare function peerIdFromString(str: string, decoder?: MultibaseDecoder<any>):
|
|
28
|
-
export declare function peerIdFromBytes(buf: Uint8Array):
|
|
29
|
-
export declare function peerIdFromCID(cid: CID):
|
|
25
|
+
export declare function createPeerId(init: PeerIdInit): Ed25519PeerId | Secp256k1PeerId | RSAPeerId;
|
|
26
|
+
export declare function peerIdFromPeerId(other: any): Ed25519PeerId | Secp256k1PeerId | RSAPeerId;
|
|
27
|
+
export declare function peerIdFromString(str: string, decoder?: MultibaseDecoder<any>): Ed25519PeerId | Secp256k1PeerId | RSAPeerId;
|
|
28
|
+
export declare function peerIdFromBytes(buf: Uint8Array): Ed25519PeerId | Secp256k1PeerId | RSAPeerId;
|
|
29
|
+
export declare function peerIdFromCID(cid: CID): Ed25519PeerId | Secp256k1PeerId | RSAPeerId;
|
|
30
30
|
/**
|
|
31
31
|
* @param publicKey - A marshalled public key
|
|
32
32
|
* @param privateKey - A marshalled private key
|
|
33
33
|
*/
|
|
34
|
-
export declare function peerIdFromKeys(publicKey: Uint8Array, privateKey?: Uint8Array): Promise<
|
|
34
|
+
export declare function peerIdFromKeys(publicKey: Uint8Array, privateKey?: Uint8Array): Promise<Ed25519PeerId | Secp256k1PeerId | RSAPeerId>;
|
|
35
35
|
export {};
|
|
36
36
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,KAAK,eAAe,EAA6B,MAAM,mBAAmB,CAAA;AAGxI,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAKtC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AACpE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAgBpE,UAAU,UAAU;IAClB,IAAI,EAAE,UAAU,CAAA;IAChB,SAAS,EAAE,eAAe,CAAA;IAC1B,UAAU,CAAC,EAAE,UAAU,CAAA;CACxB;AAyID,wBAAgB,YAAY,CAAE,IAAI,EAAE,UAAU,GAAG,aAAa,GAAG,eAAe,GAAG,SAAS,CAc3F;AAED,wBAAgB,gBAAgB,CAAE,KAAK,EAAE,GAAG,GAAG,aAAa,GAAG,eAAe,GAAG,SAAS,CAczF;AAED,wBAAgB,gBAAgB,CAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,CAAC,GAAG,CAAC,GAAG,aAAa,GAAG,eAAe,GAAG,SAAS,CAkB3H;AAED,wBAAgB,eAAe,CAAE,GAAG,EAAE,UAAU,GAAG,aAAa,GAAG,eAAe,GAAG,SAAS,CAoB7F;AAED,wBAAgB,aAAa,CAAE,GAAG,EAAE,GAAG,GAAG,aAAa,GAAG,eAAe,GAAG,SAAS,CAkBpF;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAAE,SAAS,EAAE,UAAU,EAAE,UAAU,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,aAAa,GAAG,eAAe,GAAG,SAAS,CAAC,CAU1I"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"createPeerId": "https://libp2p.github.io/js-libp2p/functions/_libp2p_peer_id.createPeerId.html",
|
|
3
|
+
".:createPeerId": "https://libp2p.github.io/js-libp2p/functions/_libp2p_peer_id.createPeerId.html",
|
|
4
|
+
"peerIdFromBytes": "https://libp2p.github.io/js-libp2p/functions/_libp2p_peer_id.peerIdFromBytes.html",
|
|
5
|
+
".:peerIdFromBytes": "https://libp2p.github.io/js-libp2p/functions/_libp2p_peer_id.peerIdFromBytes.html",
|
|
6
|
+
"peerIdFromCID": "https://libp2p.github.io/js-libp2p/functions/_libp2p_peer_id.peerIdFromCID.html",
|
|
7
|
+
".:peerIdFromCID": "https://libp2p.github.io/js-libp2p/functions/_libp2p_peer_id.peerIdFromCID.html",
|
|
8
|
+
"peerIdFromKeys": "https://libp2p.github.io/js-libp2p/functions/_libp2p_peer_id.peerIdFromKeys.html",
|
|
9
|
+
".:peerIdFromKeys": "https://libp2p.github.io/js-libp2p/functions/_libp2p_peer_id.peerIdFromKeys.html",
|
|
10
|
+
"peerIdFromPeerId": "https://libp2p.github.io/js-libp2p/functions/_libp2p_peer_id.peerIdFromPeerId.html",
|
|
11
|
+
".:peerIdFromPeerId": "https://libp2p.github.io/js-libp2p/functions/_libp2p_peer_id.peerIdFromPeerId.html",
|
|
12
|
+
"peerIdFromString": "https://libp2p.github.io/js-libp2p/functions/_libp2p_peer_id.peerIdFromString.html",
|
|
13
|
+
".:peerIdFromString": "https://libp2p.github.io/js-libp2p/functions/_libp2p_peer_id.peerIdFromString.html"
|
|
14
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/peer-id",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "Implementation of @libp2p/interface-peer-id",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/peer-id#readme",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"test:electron-main": "aegir test -t electron-main"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@libp2p/interface": "1.
|
|
57
|
+
"@libp2p/interface": "^1.3.0",
|
|
58
58
|
"multiformats": "^13.1.0",
|
|
59
59
|
"uint8arrays": "^5.0.3"
|
|
60
60
|
},
|
package/src/index.ts
CHANGED
|
@@ -181,7 +181,7 @@ class Secp256k1PeerIdImpl extends PeerIdImpl implements Secp256k1PeerId {
|
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
-
export function createPeerId (init: PeerIdInit):
|
|
184
|
+
export function createPeerId (init: PeerIdInit): Ed25519PeerId | Secp256k1PeerId | RSAPeerId {
|
|
185
185
|
if (init.type === 'RSA') {
|
|
186
186
|
return new RSAPeerIdImpl(init)
|
|
187
187
|
}
|
|
@@ -197,7 +197,7 @@ export function createPeerId (init: PeerIdInit): PeerId {
|
|
|
197
197
|
throw new CodeError('Type must be "RSA", "Ed25519" or "secp256k1"', 'ERR_INVALID_PARAMETERS')
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
-
export function peerIdFromPeerId (other: any):
|
|
200
|
+
export function peerIdFromPeerId (other: any): Ed25519PeerId | Secp256k1PeerId | RSAPeerId {
|
|
201
201
|
if (other.type === 'RSA') {
|
|
202
202
|
return new RSAPeerIdImpl(other)
|
|
203
203
|
}
|
|
@@ -213,7 +213,7 @@ export function peerIdFromPeerId (other: any): PeerId {
|
|
|
213
213
|
throw new CodeError('Not a PeerId', 'ERR_INVALID_PARAMETERS')
|
|
214
214
|
}
|
|
215
215
|
|
|
216
|
-
export function peerIdFromString (str: string, decoder?: MultibaseDecoder<any>):
|
|
216
|
+
export function peerIdFromString (str: string, decoder?: MultibaseDecoder<any>): Ed25519PeerId | Secp256k1PeerId | RSAPeerId {
|
|
217
217
|
decoder = decoder ?? baseDecoder
|
|
218
218
|
|
|
219
219
|
if (str.charAt(0) === '1' || str.charAt(0) === 'Q') {
|
|
@@ -233,7 +233,7 @@ export function peerIdFromString (str: string, decoder?: MultibaseDecoder<any>):
|
|
|
233
233
|
return peerIdFromBytes(baseDecoder.decode(str))
|
|
234
234
|
}
|
|
235
235
|
|
|
236
|
-
export function peerIdFromBytes (buf: Uint8Array):
|
|
236
|
+
export function peerIdFromBytes (buf: Uint8Array): Ed25519PeerId | Secp256k1PeerId | RSAPeerId {
|
|
237
237
|
try {
|
|
238
238
|
const multihash = Digest.decode(buf)
|
|
239
239
|
|
|
@@ -255,7 +255,7 @@ export function peerIdFromBytes (buf: Uint8Array): PeerId {
|
|
|
255
255
|
throw new Error('Supplied PeerID CID is invalid')
|
|
256
256
|
}
|
|
257
257
|
|
|
258
|
-
export function peerIdFromCID (cid: CID):
|
|
258
|
+
export function peerIdFromCID (cid: CID): Ed25519PeerId | Secp256k1PeerId | RSAPeerId {
|
|
259
259
|
if (cid == null || cid.multihash == null || cid.version == null || (cid.version === 1 && cid.code !== LIBP2P_KEY_CODE)) {
|
|
260
260
|
throw new Error('Supplied PeerID CID is invalid')
|
|
261
261
|
}
|
|
@@ -279,7 +279,7 @@ export function peerIdFromCID (cid: CID): PeerId {
|
|
|
279
279
|
* @param publicKey - A marshalled public key
|
|
280
280
|
* @param privateKey - A marshalled private key
|
|
281
281
|
*/
|
|
282
|
-
export async function peerIdFromKeys (publicKey: Uint8Array, privateKey?: Uint8Array): Promise<
|
|
282
|
+
export async function peerIdFromKeys (publicKey: Uint8Array, privateKey?: Uint8Array): Promise<Ed25519PeerId | Secp256k1PeerId | RSAPeerId> {
|
|
283
283
|
if (publicKey.length === MARSHALLED_ED225519_PUBLIC_KEY_LENGTH) {
|
|
284
284
|
return new Ed25519PeerIdImpl({ multihash: Digest.create(identity.code, publicKey), privateKey })
|
|
285
285
|
}
|