New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@libp2p/peer-id-factory

Package Overview
Dependencies
Maintainers
6
Versions
448
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@libp2p/peer-id-factory - npm Package Compare versions

Comparing version 2.0.3 to 2.0.4

14

dist/src/index.js
import { generateKeyPair, marshalPrivateKey, unmarshalPrivateKey, marshalPublicKey, unmarshalPublicKey } from '@libp2p/crypto/keys';
import { peerIdFromKeys, peerIdFromBytes } from '@libp2p/peer-id';
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string';
import { peerIdFromKeys, peerIdFromBytes } from '@libp2p/peer-id';
import { PeerIdProto } from './proto.js';

@@ -30,6 +30,6 @@ export const createEd25519PeerId = async () => {

export async function createFromPubKey(publicKey) {
return await peerIdFromKeys(marshalPublicKey(publicKey));
return peerIdFromKeys(marshalPublicKey(publicKey));
}
export async function createFromPrivKey(privateKey) {
return await peerIdFromKeys(marshalPublicKey(privateKey.public), marshalPrivateKey(privateKey));
return peerIdFromKeys(marshalPublicKey(privateKey.public), marshalPrivateKey(privateKey));
}

@@ -45,6 +45,6 @@ export function exportToProtobuf(peerId, excludePrivateKey) {

const { id, privKey, pubKey } = PeerIdProto.decode(buf);
return await createFromParts(id ?? new Uint8Array(0), privKey, pubKey);
return createFromParts(id ?? new Uint8Array(0), privKey, pubKey);
}
export async function createFromJSON(obj) {
return await createFromParts(uint8ArrayFromString(obj.id, 'base58btc'), obj.privKey != null ? uint8ArrayFromString(obj.privKey, 'base64pad') : undefined, obj.pubKey != null ? uint8ArrayFromString(obj.pubKey, 'base64pad') : undefined);
return createFromParts(uint8ArrayFromString(obj.id, 'base58btc'), obj.privKey != null ? uint8ArrayFromString(obj.privKey, 'base64pad') : undefined, obj.pubKey != null ? uint8ArrayFromString(obj.pubKey, 'base64pad') : undefined);
}

@@ -54,7 +54,7 @@ async function createFromParts(multihash, privKey, pubKey) {

const key = await unmarshalPrivateKey(privKey);
return await createFromPrivKey(key);
return createFromPrivKey(key);
}
else if (pubKey != null) {
const key = unmarshalPublicKey(pubKey);
return await createFromPubKey(key);
return createFromPubKey(key);
}

@@ -61,0 +61,0 @@ return peerIdFromBytes(multihash);

{
"name": "@libp2p/peer-id-factory",
"version": "2.0.3",
"version": "2.0.4",
"description": "Create PeerId instances",

@@ -155,5 +155,4 @@ "license": "Apache-2.0 OR MIT",

"devDependencies": {
"aegir": "^38.1.0",
"protons": "^7.0.2",
"util": "^0.12.4"
"aegir": "^39.0.10",
"protons": "^7.0.2"
},

@@ -160,0 +159,0 @@ "typedoc": {

import { generateKeyPair, marshalPrivateKey, unmarshalPrivateKey, marshalPublicKey, unmarshalPublicKey } from '@libp2p/crypto/keys'
import { peerIdFromKeys, peerIdFromBytes } from '@libp2p/peer-id'
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
import { peerIdFromKeys, peerIdFromBytes } from '@libp2p/peer-id'
import { PeerIdProto } from './proto.js'

@@ -42,7 +42,7 @@ import type { PublicKey, PrivateKey } from '@libp2p/interface-keys'

export async function createFromPubKey (publicKey: PublicKey): Promise<PeerId> {
return await peerIdFromKeys(marshalPublicKey(publicKey))
return peerIdFromKeys(marshalPublicKey(publicKey))
}
export async function createFromPrivKey (privateKey: PrivateKey): Promise<PeerId> {
return await peerIdFromKeys(marshalPublicKey(privateKey.public), marshalPrivateKey(privateKey))
return peerIdFromKeys(marshalPublicKey(privateKey.public), marshalPrivateKey(privateKey))
}

@@ -65,3 +65,3 @@

return await createFromParts(
return createFromParts(
id ?? new Uint8Array(0),

@@ -74,3 +74,3 @@ privKey,

export async function createFromJSON (obj: { id: string, privKey?: string, pubKey?: string }): Promise<PeerId> {
return await createFromParts(
return createFromParts(
uint8ArrayFromString(obj.id, 'base58btc'),

@@ -86,7 +86,7 @@ obj.privKey != null ? uint8ArrayFromString(obj.privKey, 'base64pad') : undefined,

return await createFromPrivKey(key)
return createFromPrivKey(key)
} else if (pubKey != null) {
const key = unmarshalPublicKey(pubKey)
return await createFromPubKey(key)
return createFromPubKey(key)
}

@@ -93,0 +93,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc