@libp2p/peer-id
Advanced tools
Comparing version 1.1.6 to 1.1.7
@@ -6,3 +6,3 @@ import { CID } from 'multiformats/cid'; | ||
import type { PeerId } from '@libp2p/interfaces/peer-id'; | ||
interface PeerIdOptions { | ||
interface PeerIdInit { | ||
type: 'RSA' | 'Ed25519' | 'secp256k1'; | ||
@@ -18,3 +18,3 @@ multihash: MultihashDigest; | ||
private readonly strings; | ||
constructor(opts: PeerIdOptions); | ||
constructor(init: PeerIdInit); | ||
get [Symbol.toStringTag](): string; | ||
@@ -30,3 +30,3 @@ get [symbol](): boolean; | ||
} | ||
export declare function createPeerId(opts: PeerIdOptions): PeerIdImpl; | ||
export declare function createPeerId(init: PeerIdInit): PeerIdImpl; | ||
export declare function peerIdFromPeerId(other: any): PeerId; | ||
@@ -33,0 +33,0 @@ export declare function peerIdFromString(str: string, decoder?: MultibaseDecoder<any>): PeerId; |
@@ -20,6 +20,6 @@ import { CID } from 'multiformats/cid'; | ||
class PeerIdImpl { | ||
constructor(opts) { | ||
this.type = opts.type; | ||
this.multihash = opts.multihash; | ||
this.privateKey = opts.privateKey; | ||
constructor(init) { | ||
this.type = init.type; | ||
this.multihash = init.multihash; | ||
this.privateKey = init.privateKey; | ||
// mark toString cache as non-enumerable | ||
@@ -73,24 +73,24 @@ this.strings = new Map(); | ||
class RSAPeerIdImpl extends PeerIdImpl { | ||
constructor(opts) { | ||
super({ ...opts, type: 'RSA' }); | ||
constructor(init) { | ||
super({ ...init, type: 'RSA' }); | ||
this.type = 'RSA'; | ||
this.publicKey = opts.publicKey; | ||
this.publicKey = init.publicKey; | ||
} | ||
} | ||
class Ed25519PeerIdImpl extends PeerIdImpl { | ||
constructor(opts) { | ||
super({ ...opts, type: 'Ed25519' }); | ||
constructor(init) { | ||
super({ ...init, type: 'Ed25519' }); | ||
this.type = 'Ed25519'; | ||
this.publicKey = opts.multihash.digest; | ||
this.publicKey = init.multihash.digest; | ||
} | ||
} | ||
class Secp256k1PeerIdImpl extends PeerIdImpl { | ||
constructor(opts) { | ||
super({ ...opts, type: 'secp256k1' }); | ||
constructor(init) { | ||
super({ ...init, type: 'secp256k1' }); | ||
this.type = 'secp256k1'; | ||
this.publicKey = opts.multihash.digest; | ||
this.publicKey = init.multihash.digest; | ||
} | ||
} | ||
export function createPeerId(opts) { | ||
return new PeerIdImpl(opts); | ||
export function createPeerId(init) { | ||
return new PeerIdImpl(init); | ||
} | ||
@@ -97,0 +97,0 @@ export function peerIdFromPeerId(other) { |
{ | ||
"name": "@libp2p/peer-id", | ||
"version": "1.1.6", | ||
"version": "1.1.7", | ||
"description": "IPFS Peer Id implementation in Node.js", | ||
@@ -135,3 +135,3 @@ "license": "Apache-2.0 OR MIT", | ||
"dependencies": { | ||
"@libp2p/interfaces": "^1.3.6", | ||
"@libp2p/interfaces": "^1.3.12", | ||
"err-code": "^3.0.1", | ||
@@ -138,0 +138,0 @@ "multiformats": "^9.6.3", |
@@ -26,3 +26,3 @@ import { CID } from 'multiformats/cid' | ||
interface PeerIdOptions { | ||
interface PeerIdInit { | ||
type: 'RSA' | 'Ed25519' | 'secp256k1' | ||
@@ -33,3 +33,3 @@ multihash: MultihashDigest | ||
interface RSAPeerIdOptions { | ||
interface RSAPeerIdInit { | ||
multihash: MultihashDigest | ||
@@ -40,3 +40,3 @@ privateKey?: Uint8Array | ||
interface Ed25519PeerIdOptions { | ||
interface Ed25519PeerIdInit { | ||
multihash: MultihashDigest | ||
@@ -46,3 +46,3 @@ privateKey?: Uint8Array | ||
interface Secp256k1PeerIdOptions { | ||
interface Secp256k1PeerIdInit { | ||
multihash: MultihashDigest | ||
@@ -59,6 +59,6 @@ privateKey?: Uint8Array | ||
constructor (opts: PeerIdOptions) { | ||
this.type = opts.type | ||
this.multihash = opts.multihash | ||
this.privateKey = opts.privateKey | ||
constructor (init: PeerIdInit) { | ||
this.type = init.type | ||
this.multihash = init.multihash | ||
this.privateKey = init.privateKey | ||
@@ -126,6 +126,6 @@ // mark toString cache as non-enumerable | ||
constructor (opts: RSAPeerIdOptions) { | ||
super({ ...opts, type: 'RSA' }) | ||
constructor (init: RSAPeerIdInit) { | ||
super({ ...init, type: 'RSA' }) | ||
this.publicKey = opts.publicKey | ||
this.publicKey = init.publicKey | ||
} | ||
@@ -138,6 +138,6 @@ } | ||
constructor (opts: Ed25519PeerIdOptions) { | ||
super({ ...opts, type: 'Ed25519' }) | ||
constructor (init: Ed25519PeerIdInit) { | ||
super({ ...init, type: 'Ed25519' }) | ||
this.publicKey = opts.multihash.digest | ||
this.publicKey = init.multihash.digest | ||
} | ||
@@ -150,11 +150,11 @@ } | ||
constructor (opts: Secp256k1PeerIdOptions) { | ||
super({ ...opts, type: 'secp256k1' }) | ||
constructor (init: Secp256k1PeerIdInit) { | ||
super({ ...init, type: 'secp256k1' }) | ||
this.publicKey = opts.multihash.digest | ||
this.publicKey = init.multihash.digest | ||
} | ||
} | ||
export function createPeerId (opts: PeerIdOptions) { | ||
return new PeerIdImpl(opts) | ||
export function createPeerId (init: PeerIdInit) { | ||
return new PeerIdImpl(init) | ||
} | ||
@@ -161,0 +161,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
26987
Updated@libp2p/interfaces@^1.3.12