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.2 to 2.0.3-3dfc236e

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.2",
"version": "2.0.3-3dfc236e",
"description": "Create PeerId instances",
"license": "Apache-2.0 OR MIT",
"homepage": "https://github.com/libp2p/js-libp2p-peer-id/tree/master/packages/libp2p-peer-id-factory#readme",
"homepage": "https://github.com/libp2p/js-libp2p/tree/master/packages/peer-id-factory#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/libp2p/js-libp2p-peer-id.git"
"url": "git+https://github.com/libp2p/js-libp2p.git"
},
"bugs": {
"url": "https://github.com/libp2p/js-libp2p-peer-id/issues"
"url": "https://github.com/libp2p/js-libp2p/issues"
},

@@ -17,6 +17,2 @@ "keywords": [

],
"engines": {
"node": ">=16.0.0",
"npm": ">=7.0.0"
},
"type": "module",

@@ -45,87 +41,2 @@ "types": "./dist/src/index.d.ts",

},
"release": {
"branches": [
"master"
],
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "conventionalcommits",
"releaseRules": [
{
"breaking": true,
"release": "major"
},
{
"revert": true,
"release": "patch"
},
{
"type": "feat",
"release": "minor"
},
{
"type": "fix",
"release": "patch"
},
{
"type": "docs",
"release": "patch"
},
{
"type": "test",
"release": "patch"
},
{
"type": "deps",
"release": "patch"
},
{
"scope": "no-release",
"release": false
}
]
}
],
[
"@semantic-release/release-notes-generator",
{
"preset": "conventionalcommits",
"presetConfig": {
"types": [
{
"type": "feat",
"section": "Features"
},
{
"type": "fix",
"section": "Bug Fixes"
},
{
"type": "chore",
"section": "Trivial Changes"
},
{
"type": "docs",
"section": "Documentation"
},
{
"type": "deps",
"section": "Dependencies"
},
{
"type": "test",
"section": "Tests"
}
]
}
}
],
"@semantic-release/changelog",
"@semantic-release/npm",
"@semantic-release/github",
"@semantic-release/git"
]
},
"scripts": {

@@ -143,19 +54,17 @@ "clean": "aegir clean",

"test:node": "aegir test -t node --cov",
"test:electron-main": "aegir test -t electron-main",
"release": "aegir release"
"test:electron-main": "aegir test -t electron-main"
},
"dependencies": {
"@libp2p/crypto": "^1.0.0",
"@libp2p/interface-keys": "^1.0.2",
"@libp2p/interface-peer-id": "^2.0.0",
"@libp2p/peer-id": "^2.0.0",
"multiformats": "^11.0.0",
"@libp2p/crypto": "1.0.17-3dfc236e",
"@libp2p/interface-keys": "1.0.8-3dfc236e",
"@libp2p/interface-peer-id": "2.0.2-3dfc236e",
"@libp2p/peer-id": "2.0.3-3dfc236e",
"multiformats": "^11.0.2",
"protons-runtime": "^5.0.0",
"uint8arraylist": "^2.0.0",
"uint8arrays": "^4.0.2"
"uint8arraylist": "^2.4.3",
"uint8arrays": "^4.0.3"
},
"devDependencies": {
"aegir": "^38.1.0",
"protons": "^7.0.2",
"util": "^0.12.4"
"aegir": "^39.0.10",
"protons": "^7.0.2"
},

@@ -162,0 +71,0 @@ "typedoc": {

@@ -5,4 +5,4 @@ # @libp2p/peer-id-factory <!-- omit in toc -->

[![Discuss](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg?style=flat-square)](https://discuss.libp2p.io)
[![codecov](https://img.shields.io/codecov/c/github/libp2p/js-libp2p-peer-id.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-peer-id)
[![CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p-peer-id/js-test-and-release.yml?branch=master\&style=flat-square)](https://github.com/libp2p/js-libp2p-peer-id/actions/workflows/js-test-and-release.yml?query=branch%3Amaster)
[![codecov](https://img.shields.io/codecov/c/github/libp2p/js-libp2p.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p)
[![CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/main.yml?branch=master\&style=flat-square)](https://github.com/libp2p/js-libp2p/actions/workflows/main.yml?query=branch%3Amaster)

@@ -19,3 +19,3 @@ > Create PeerId instances

- [License](#license)
- [Contribute](#contribute)
- [Contribution](#contribution)

@@ -59,3 +59,3 @@ ## Install

- <https://libp2p.github.io/js-libp2p-peer-id/modules/_libp2p_peer_id_factory.html>
- <https://libp2p.github.io/js-libp2p/modules/_libp2p_peer_id_factory.html>

@@ -69,4 +69,4 @@ ## License

## Contribute
## Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
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