@libp2p/peer-id-factory
Advanced tools
Comparing version 1.0.9 to 1.0.10
@@ -1,2 +0,2 @@ | ||
import { keys } from '@libp2p/crypto'; | ||
import { generateKeyPair, marshalPrivateKey, unmarshalPrivateKey, marshalPublicKey, unmarshalPublicKey } from '@libp2p/crypto/keys'; | ||
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'; | ||
@@ -6,3 +6,3 @@ import { peerIdFromKeys, peerIdFromBytes } from '@libp2p/peer-id'; | ||
export const createEd25519PeerId = async () => { | ||
const key = await keys.generateKeyPair('Ed25519'); | ||
const key = await generateKeyPair('Ed25519'); | ||
const id = await createFromPrivKey(key); | ||
@@ -15,3 +15,3 @@ if (id.type === 'Ed25519') { | ||
export const createSecp256k1PeerId = async () => { | ||
const key = await keys.generateKeyPair('secp256k1'); | ||
const key = await generateKeyPair('secp256k1'); | ||
const id = await createFromPrivKey(key); | ||
@@ -24,3 +24,3 @@ if (id.type === 'secp256k1') { | ||
export const createRSAPeerId = async (opts) => { | ||
const key = await keys.generateKeyPair('RSA', opts?.bits ?? 2048); | ||
const key = await generateKeyPair('RSA', opts?.bits ?? 2048); | ||
const id = await createFromPrivKey(key); | ||
@@ -33,6 +33,6 @@ if (id.type === 'RSA') { | ||
export async function createFromPubKey(publicKey) { | ||
return await peerIdFromKeys(keys.marshalPublicKey(publicKey)); | ||
return await peerIdFromKeys(marshalPublicKey(publicKey)); | ||
} | ||
export async function createFromPrivKey(privateKey) { | ||
return await peerIdFromKeys(keys.marshalPublicKey(privateKey.public), keys.marshalPrivateKey(privateKey)); | ||
return await peerIdFromKeys(marshalPublicKey(privateKey.public), marshalPrivateKey(privateKey)); | ||
} | ||
@@ -55,7 +55,7 @@ export function exportToProtobuf(peerId, excludePrivateKey) { | ||
if (privKey != null) { | ||
const key = await keys.unmarshalPrivateKey(privKey); | ||
const key = await unmarshalPrivateKey(privKey); | ||
return await createFromPrivKey(key); | ||
} | ||
else if (pubKey != null) { | ||
const key = await keys.unmarshalPublicKey(pubKey); | ||
const key = await unmarshalPublicKey(pubKey); | ||
return await createFromPubKey(key); | ||
@@ -62,0 +62,0 @@ } |
@@ -0,1 +1,2 @@ | ||
import type { Codec } from 'protons-runtime'; | ||
export interface PeerIdProto { | ||
@@ -7,3 +8,3 @@ id: Uint8Array; | ||
export declare namespace PeerIdProto { | ||
const codec: () => import("protons-runtime/dist/src/codecs/codec").Codec<PeerIdProto>; | ||
const codec: () => Codec<PeerIdProto>; | ||
const encode: (obj: PeerIdProto) => Uint8Array; | ||
@@ -10,0 +11,0 @@ const decode: (buf: Uint8Array) => PeerIdProto; |
{ | ||
"name": "@libp2p/peer-id-factory", | ||
"version": "1.0.9", | ||
"version": "1.0.10", | ||
"description": "IPFS Peer Id implementation in Node.js", | ||
@@ -129,2 +129,3 @@ "license": "Apache-2.0 OR MIT", | ||
"dep-check": "aegir dep-check", | ||
"generate": "protons src/proto.proto", | ||
"build": "aegir build", | ||
@@ -145,3 +146,3 @@ "test": "aegir test", | ||
"multiformats": "^9.6.3", | ||
"protons-runtime": "^1.0.2", | ||
"protons-runtime": "^1.0.4", | ||
"uint8arrays": "^3.0.0" | ||
@@ -151,5 +152,5 @@ }, | ||
"aegir": "^37.0.7", | ||
"protons": "^3.0.2", | ||
"protons": "^3.0.4", | ||
"util": "^0.12.4" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
import { keys } from '@libp2p/crypto' | ||
import { generateKeyPair, marshalPrivateKey, unmarshalPrivateKey, marshalPublicKey, unmarshalPublicKey } from '@libp2p/crypto/keys' | ||
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' | ||
@@ -9,3 +9,3 @@ import { peerIdFromKeys, peerIdFromBytes } from '@libp2p/peer-id' | ||
export const createEd25519PeerId = async (): Promise<Ed25519PeerId> => { | ||
const key = await keys.generateKeyPair('Ed25519') | ||
const key = await generateKeyPair('Ed25519') | ||
const id = await createFromPrivKey(key) | ||
@@ -21,3 +21,3 @@ | ||
export const createSecp256k1PeerId = async (): Promise<Secp256k1PeerId> => { | ||
const key = await keys.generateKeyPair('secp256k1') | ||
const key = await generateKeyPair('secp256k1') | ||
const id = await createFromPrivKey(key) | ||
@@ -33,3 +33,3 @@ | ||
export const createRSAPeerId = async (opts?: { bits: number }): Promise<RSAPeerId> => { | ||
const key = await keys.generateKeyPair('RSA', opts?.bits ?? 2048) | ||
const key = await generateKeyPair('RSA', opts?.bits ?? 2048) | ||
const id = await createFromPrivKey(key) | ||
@@ -45,7 +45,7 @@ | ||
export async function createFromPubKey (publicKey: PublicKey) { | ||
return await peerIdFromKeys(keys.marshalPublicKey(publicKey)) | ||
return await peerIdFromKeys(marshalPublicKey(publicKey)) | ||
} | ||
export async function createFromPrivKey (privateKey: PrivateKey) { | ||
return await peerIdFromKeys(keys.marshalPublicKey(privateKey.public), keys.marshalPrivateKey(privateKey)) | ||
return await peerIdFromKeys(marshalPublicKey(privateKey.public), marshalPrivateKey(privateKey)) | ||
} | ||
@@ -85,7 +85,7 @@ | ||
if (privKey != null) { | ||
const key = await keys.unmarshalPrivateKey(privKey) | ||
const key = await unmarshalPrivateKey(privKey) | ||
return await createFromPrivKey(key) | ||
} else if (pubKey != null) { | ||
const key = await keys.unmarshalPublicKey(pubKey) | ||
const key = await unmarshalPublicKey(pubKey) | ||
@@ -92,0 +92,0 @@ return await createFromPubKey(key) |
@@ -5,2 +5,3 @@ /* eslint-disable import/export */ | ||
import { encodeMessage, decodeMessage, message, bytes } from 'protons-runtime' | ||
import type { Codec } from 'protons-runtime' | ||
@@ -14,3 +15,3 @@ export interface PeerIdProto { | ||
export namespace PeerIdProto { | ||
export const codec = () => { | ||
export const codec = (): Codec<PeerIdProto> => { | ||
return message<PeerIdProto>({ | ||
@@ -17,0 +18,0 @@ 1: { name: 'id', codec: bytes }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
18673
201
0
Updatedprotons-runtime@^1.0.4