@libp2p/peer-id-factory
Advanced tools
Comparing version 1.0.17 to 1.0.18
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
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
24188
298
1
+ Added@protobufjs/aspromise@1.1.2(transitive)
+ Added@protobufjs/base64@1.1.2(transitive)
+ Added@protobufjs/codegen@2.0.4(transitive)
+ Added@protobufjs/eventemitter@1.1.0(transitive)
+ Added@protobufjs/fetch@1.1.0(transitive)
+ Added@protobufjs/float@1.0.2(transitive)
+ Added@protobufjs/inquire@1.1.0(transitive)
+ Added@protobufjs/path@1.1.2(transitive)
+ Added@protobufjs/pool@1.1.0(transitive)
+ Added@protobufjs/utf8@1.1.0(transitive)
+ Added@types/node@22.10.2(transitive)
+ Addedlong@5.2.3(transitive)
+ Addedprotobufjs@7.4.0(transitive)
+ Addedprotons-runtime@3.1.0(transitive)
+ Addedundici-types@6.20.0(transitive)
- Removedbyte-access@1.0.1(transitive)
- Removedlongbits@1.1.0(transitive)
- Removedprotons-runtime@2.0.2(transitive)
- Removeduint8-varint@1.0.8(transitive)
Updatedprotons-runtime@^3.1.0