Skip to content

Commit

Permalink
deps: bump aegir from 37.12.1 to 38.1.0 (libp2p#46)
Browse files Browse the repository at this point in the history
* deps: bump aegir from 37.12.1 to 38.1.0

Bumps [aegir](https://github.com/ipfs/aegir) from 37.12.1 to 38.1.0.
- [Release notes](https://github.com/ipfs/aegir/releases)
- [Changelog](https://github.com/ipfs/aegir/blob/master/CHANGELOG.md)
- [Commits](ipfs/aegir@v37.12.1...v38.1.0)

---
updated-dependencies:
- dependency-name: aegir
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* fix: add return types to methods and remove pointless awaits

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: achingbrain <alex@achingbrain.net>
  • Loading branch information
dependabot[bot] and achingbrain authored Jan 18, 2023
1 parent 06e39f0 commit ba54f6a
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/*"
Expand Down
2 changes: 1 addition & 1 deletion packages/libp2p-peer-id-factory/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
8 changes: 4 additions & 4 deletions packages/libp2p-peer-id-factory/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function exportToProtobuf (peerId: RSAPeerId | Ed25519PeerId | Secp256k1P
})
}

export async function createFromProtobuf (buf: Uint8Array) {
export async function createFromProtobuf (buf: Uint8Array): Promise<PeerId> {
const {
id,
privKey,
Expand All @@ -68,21 +68,21 @@ 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<PeerId> {
return await createFromParts(
uint8ArrayFromString(obj.id, 'base58btc'),
obj.privKey != null ? uint8ArrayFromString(obj.privKey, 'base64pad') : undefined,
obj.pubKey != null ? uint8ArrayFromString(obj.pubKey, 'base64pad') : undefined
)
}

async function createFromParts (multihash: Uint8Array, privKey?: Uint8Array, pubKey?: Uint8Array) {
async function createFromParts (multihash: Uint8Array, privKey?: Uint8Array, pubKey?: Uint8Array): Promise<PeerId> {
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)
}
Expand Down
16 changes: 8 additions & 8 deletions packages/libp2p-peer-id-factory/test/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})

Expand Down Expand Up @@ -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)
})

Expand All @@ -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)
})

Expand All @@ -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)
})

Expand Down
2 changes: 1 addition & 1 deletion packages/libp2p-peer-id/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
"uint8arrays": "^4.0.2"
},
"devDependencies": {
"aegir": "^37.9.0"
"aegir": "^38.1.0"
},
"typedoc": {
"entryPoint": "./src/index.ts"
Expand Down
16 changes: 8 additions & 8 deletions packages/libp2p-peer-id/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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()
}

Expand Down Expand Up @@ -216,7 +216,7 @@ export function peerIdFromString (str: string, decoder?: MultibaseDecoder<any>):
return peerIdFromBytes(baseDecoder.decode(str))
}

export function peerIdFromBytes (buf: Uint8Array) {
export function peerIdFromBytes (buf: Uint8Array): PeerId {
try {
const multihash = Digest.decode(buf)

Expand Down

0 comments on commit ba54f6a

Please sign in to comment.