Huge News!Announcing our $40M Series B led by Abstract Ventures.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 1.0.17 to 1.0.18

3

dist/src/index.d.ts
import type { PublicKey, PrivateKey } from '@libp2p/interface-keys';
import type { RSAPeerId, Ed25519PeerId, Secp256k1PeerId, PeerId } from '@libp2p/interface-peer-id';
import type { Uint8ArrayList } from 'uint8arraylist';
export declare const createEd25519PeerId: () => Promise<Ed25519PeerId>;

@@ -11,3 +10,3 @@ export declare const createSecp256k1PeerId: () => Promise<Secp256k1PeerId>;

export declare function createFromPrivKey(privateKey: PrivateKey): Promise<PeerId>;
export declare function exportToProtobuf(peerId: RSAPeerId | Ed25519PeerId | Secp256k1PeerId, excludePrivateKey?: boolean): Uint8ArrayList;
export declare function exportToProtobuf(peerId: RSAPeerId | Ed25519PeerId | Secp256k1PeerId, excludePrivateKey?: boolean): Uint8Array;
export declare function createFromProtobuf(buf: Uint8Array): Promise<PeerId>;

@@ -14,0 +13,0 @@ export declare function createFromJSON(obj: {

@@ -0,3 +1,3 @@

import type { Uint8ArrayList } from 'uint8arraylist';
import type { Codec } from 'protons-runtime';
import type { Uint8ArrayList } from 'uint8arraylist';
export interface PeerIdProto {

@@ -10,5 +10,5 @@ id: Uint8Array;

const codec: () => Codec<PeerIdProto>;
const encode: (obj: PeerIdProto) => Uint8ArrayList;
const encode: (obj: PeerIdProto) => Uint8Array;
const decode: (buf: Uint8Array | Uint8ArrayList) => PeerIdProto;
}
//# sourceMappingURL=proto.d.ts.map
/* eslint-disable import/export */
/* eslint-disable @typescript-eslint/no-namespace */
import { encodeMessage, decodeMessage, message, bytes } from 'protons-runtime';
import { encodeMessage, decodeMessage, message } from 'protons-runtime';
export var PeerIdProto;
(function (PeerIdProto) {
let _codec;
PeerIdProto.codec = () => {
return message({
1: { name: 'id', codec: bytes },
2: { name: 'pubKey', codec: bytes, optional: true },
3: { name: 'privKey', codec: bytes, optional: true }
});
if (_codec == null) {
_codec = message((obj, writer, opts = {}) => {
if (opts.lengthDelimited !== false) {
writer.fork();
}
if (obj.id != null) {
writer.uint32(10);
writer.bytes(obj.id);
}
else {
throw new Error('Protocol error: required field "id" was not found in object');
}
if (obj.pubKey != null) {
writer.uint32(18);
writer.bytes(obj.pubKey);
}
if (obj.privKey != null) {
writer.uint32(26);
writer.bytes(obj.privKey);
}
if (opts.lengthDelimited !== false) {
writer.ldelim();
}
}, (reader, length) => {
const obj = {
id: new Uint8Array(0)
};
const end = length == null ? reader.len : reader.pos + length;
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
obj.id = reader.bytes();
break;
case 2:
obj.pubKey = reader.bytes();
break;
case 3:
obj.privKey = reader.bytes();
break;
default:
reader.skipType(tag & 7);
break;
}
}
if (obj.id == null) {
throw new Error('Protocol error: value for required field "id" was not found in protobuf');
}
return obj;
});
}
return _codec;
};

@@ -13,0 +61,0 @@ PeerIdProto.encode = (obj) => {

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

@@ -150,3 +150,3 @@ "license": "Apache-2.0 OR MIT",

"multiformats": "^9.6.3",
"protons-runtime": "^2.0.2",
"protons-runtime": "^3.1.0",
"uint8arraylist": "^2.0.0",

@@ -157,5 +157,5 @@ "uint8arrays": "^3.0.0"

"aegir": "^37.0.7",
"protons": "^4.0.1",
"protons": "^5.1.0",
"util": "^0.12.4"
}
}

@@ -7,3 +7,2 @@ import { generateKeyPair, marshalPrivateKey, unmarshalPrivateKey, marshalPublicKey, unmarshalPublicKey } from '@libp2p/crypto/keys'

import type { RSAPeerId, Ed25519PeerId, Secp256k1PeerId, PeerId } from '@libp2p/interface-peer-id'
import type { Uint8ArrayList } from 'uint8arraylist'

@@ -51,3 +50,3 @@ export const createEd25519PeerId = async (): Promise<Ed25519PeerId> => {

export function exportToProtobuf (peerId: RSAPeerId | Ed25519PeerId | Secp256k1PeerId, excludePrivateKey?: boolean): Uint8ArrayList {
export function exportToProtobuf (peerId: RSAPeerId | Ed25519PeerId | Secp256k1PeerId, excludePrivateKey?: boolean): Uint8Array {
return PeerIdProto.encode({

@@ -54,0 +53,0 @@ id: peerId.multihash.bytes,

/* eslint-disable import/export */
/* eslint-disable @typescript-eslint/no-namespace */
import { encodeMessage, decodeMessage, message, bytes } from 'protons-runtime'
import { encodeMessage, decodeMessage, message } from 'protons-runtime'
import type { Uint8ArrayList } from 'uint8arraylist'
import type { Codec } from 'protons-runtime'
import type { Uint8ArrayList } from 'uint8arraylist'

@@ -15,11 +15,69 @@ export interface PeerIdProto {

export namespace PeerIdProto {
let _codec: Codec<PeerIdProto>
export const codec = (): Codec<PeerIdProto> => {
return message<PeerIdProto>({
1: { name: 'id', codec: bytes },
2: { name: 'pubKey', codec: bytes, optional: true },
3: { name: 'privKey', codec: bytes, optional: true }
})
if (_codec == null) {
_codec = message<PeerIdProto>((obj, writer, opts = {}) => {
if (opts.lengthDelimited !== false) {
writer.fork()
}
if (obj.id != null) {
writer.uint32(10)
writer.bytes(obj.id)
} else {
throw new Error('Protocol error: required field "id" was not found in object')
}
if (obj.pubKey != null) {
writer.uint32(18)
writer.bytes(obj.pubKey)
}
if (obj.privKey != null) {
writer.uint32(26)
writer.bytes(obj.privKey)
}
if (opts.lengthDelimited !== false) {
writer.ldelim()
}
}, (reader, length) => {
const obj: any = {
id: new Uint8Array(0)
}
const end = length == null ? reader.len : reader.pos + length
while (reader.pos < end) {
const tag = reader.uint32()
switch (tag >>> 3) {
case 1:
obj.id = reader.bytes()
break
case 2:
obj.pubKey = reader.bytes()
break
case 3:
obj.privKey = reader.bytes()
break
default:
reader.skipType(tag & 7)
break
}
}
if (obj.id == null) {
throw new Error('Protocol error: value for required field "id" was not found in protobuf')
}
return obj
})
}
return _codec
}
export const encode = (obj: PeerIdProto): Uint8ArrayList => {
export const encode = (obj: PeerIdProto): Uint8Array => {
return encodeMessage(obj, PeerIdProto.codec())

@@ -26,0 +84,0 @@ }

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

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