diff --git a/package.json b/package.json index 83cbc199bb..195489aee0 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "release": "npm run docs:no-publish && aegir run release && npm run docs" }, "dependencies": { - "aegir": "^37.9.0" + "aegir": "^38.1.0" }, "workspaces": [ "packages/*" diff --git a/packages/libp2p-peer-id-factory/package.json b/packages/libp2p-peer-id-factory/package.json index e98af7306c..e5add4f193 100644 --- a/packages/libp2p-peer-id-factory/package.json +++ b/packages/libp2p-peer-id-factory/package.json @@ -152,7 +152,7 @@ "uint8arrays": "^4.0.2" }, "devDependencies": { - "aegir": "^37.9.0", + "aegir": "^38.1.0", "protons": "^6.0.0", "util": "^0.12.4" }, diff --git a/packages/libp2p-peer-id-factory/src/index.ts b/packages/libp2p-peer-id-factory/src/index.ts index 50e841e1f5..c0e4240f0d 100644 --- a/packages/libp2p-peer-id-factory/src/index.ts +++ b/packages/libp2p-peer-id-factory/src/index.ts @@ -54,7 +54,7 @@ export function exportToProtobuf (peerId: RSAPeerId | Ed25519PeerId | Secp256k1P }) } -export async function createFromProtobuf (buf: Uint8Array) { +export async function createFromProtobuf (buf: Uint8Array): Promise { const { id, privKey, @@ -68,7 +68,7 @@ export async function createFromProtobuf (buf: Uint8Array) { ) } -export async function createFromJSON (obj: { id: string, privKey?: string, pubKey?: string }) { +export async function createFromJSON (obj: { id: string, privKey?: string, pubKey?: string }): Promise { return await createFromParts( uint8ArrayFromString(obj.id, 'base58btc'), obj.privKey != null ? uint8ArrayFromString(obj.privKey, 'base64pad') : undefined, @@ -76,13 +76,13 @@ export async function createFromJSON (obj: { id: string, privKey?: string, pubKe ) } -async function createFromParts (multihash: Uint8Array, privKey?: Uint8Array, pubKey?: Uint8Array) { +async function createFromParts (multihash: Uint8Array, privKey?: Uint8Array, pubKey?: Uint8Array): Promise { if (privKey != null) { const key = await unmarshalPrivateKey(privKey) return await createFromPrivKey(key) } else if (pubKey != null) { - const key = await unmarshalPublicKey(pubKey) + const key = unmarshalPublicKey(pubKey) return await createFromPubKey(key) } diff --git a/packages/libp2p-peer-id-factory/test/index.spec.ts b/packages/libp2p-peer-id-factory/test/index.spec.ts index 632b906c40..8a126369a1 100644 --- a/packages/libp2p-peer-id-factory/test/index.spec.ts +++ b/packages/libp2p-peer-id-factory/test/index.spec.ts @@ -40,7 +40,7 @@ describe('PeerId', () => { it('can be created for a secp256k1 key', async () => { const id = await PeerIdFactory.createSecp256k1PeerId() - const expB58 = base58btc.encode((await identity.digest(id.publicKey)).bytes).slice(1) + const expB58 = base58btc.encode((identity.digest(id.publicKey)).bytes).slice(1) expect(id.toString()).to.equal(expB58) }) @@ -154,33 +154,33 @@ describe('PeerId', () => { it('recreate from embedded ed25519 key', async () => { const key = '12D3KooWRm8J3iL796zPFi2EtGGtUJn58AG67gcqzMFHZnnsTzqD' - const id = await peerIdFromString(key) + const id = peerIdFromString(key) expect(id.toString()).to.equal(key) if (id.publicKey == null) { throw new Error('No pubic key found on Ed25519 key') } - const expB58 = base58btc.encode((await identity.digest(id.publicKey)).bytes).slice(1) + const expB58 = base58btc.encode((identity.digest(id.publicKey)).bytes).slice(1) expect(id.toString()).to.equal(expB58) }) it('recreate from embedded secp256k1 key', async () => { const key = '16Uiu2HAm5qw8UyXP2RLxQUx5KvtSN8DsTKz8quRGqGNC3SYiaB8E' - const id = await peerIdFromString(key) + const id = peerIdFromString(key) expect(id.toString()).to.equal(key) if (id.publicKey == null) { throw new Error('No pubic key found on secp256k1 key') } - const expB58 = base58btc.encode((await identity.digest(id.publicKey)).bytes).slice(1) + const expB58 = base58btc.encode((identity.digest(id.publicKey)).bytes).slice(1) expect(id.toString()).to.equal(expB58) }) it('recreate from string key', async () => { const key = 'QmRsooYQasV5f5r834NSpdUtmejdQcpxXkK6qsozZWEihC' - const id = await peerIdFromString(key) + const id = peerIdFromString(key) expect(id.toString()).to.equal(key) }) @@ -192,7 +192,7 @@ describe('PeerId', () => { throw new Error('No public key found on peer id created from secp256k1 public key') } - const expB58 = base58btc.encode((await identity.digest(id.publicKey)).bytes).slice(1) + const expB58 = base58btc.encode((identity.digest(id.publicKey)).bytes).slice(1) expect(id.toString()).to.equal(expB58) }) @@ -204,7 +204,7 @@ describe('PeerId', () => { throw new Error('No public key found on peer id created from secp256k1 private key') } - const expB58 = base58btc.encode((await identity.digest(id.publicKey)).bytes).slice(1) + const expB58 = base58btc.encode((identity.digest(id.publicKey)).bytes).slice(1) expect(id.toString()).to.equal(expB58) }) diff --git a/packages/libp2p-peer-id/package.json b/packages/libp2p-peer-id/package.json index a3edaafb41..c3330824a3 100644 --- a/packages/libp2p-peer-id/package.json +++ b/packages/libp2p-peer-id/package.json @@ -144,7 +144,7 @@ "uint8arrays": "^4.0.2" }, "devDependencies": { - "aegir": "^37.9.0" + "aegir": "^38.1.0" }, "typedoc": { "entryPoint": "./src/index.ts" diff --git a/packages/libp2p-peer-id/src/index.ts b/packages/libp2p-peer-id/src/index.ts index 2baed2249b..6d017fbd3c 100644 --- a/packages/libp2p-peer-id/src/index.ts +++ b/packages/libp2p-peer-id/src/index.ts @@ -66,15 +66,15 @@ class PeerIdImpl { }) } - get [Symbol.toStringTag] () { + get [Symbol.toStringTag] (): string { return `PeerId(${this.toString()})` } - get [symbol] () { + get [symbol] (): boolean { return true } - toString () { + toString (): string { if (this.string == null) { this.string = base58btc.encode(this.multihash.bytes).slice(1) } @@ -84,18 +84,18 @@ class PeerIdImpl { // return self-describing String representation // in default format from RFC 0001: https://github.com/libp2p/specs/pull/209 - toCID () { + toCID (): CID { return CID.createV1(LIBP2P_KEY_CODE, this.multihash) } - toBytes () { + toBytes (): Uint8Array { return this.multihash.bytes } /** - * Returns Multiaddr as a JSON encoded object + * Returns Multiaddr as a JSON string */ - toJSON () { + toJSON (): string { return this.toString() } @@ -216,7 +216,7 @@ export function peerIdFromString (str: string, decoder?: MultibaseDecoder): return peerIdFromBytes(baseDecoder.decode(str)) } -export function peerIdFromBytes (buf: Uint8Array) { +export function peerIdFromBytes (buf: Uint8Array): PeerId { try { const multihash = Digest.decode(buf)