Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@libp2p/interface

Package Overview
Dependencies
Maintainers
6
Versions
518
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@libp2p/interface - npm Package Compare versions

Comparing version 2.1.0 to 2.1.1-c258b35af

4

dist/src/connection/index.d.ts

@@ -112,3 +112,3 @@ import type { AbortOptions, Logger } from '../index.js';

*
* The sink will return and the source will throw if an error is passed or return normally if not.
* The sink will return and the source will throw.
*/

@@ -305,3 +305,3 @@ abort(err: Error): void;

*/
protect(connection: MultiaddrConnection): Promise<MultiaddrConnection>;
protect(connection: MultiaddrConnection, options?: AbortOptions): Promise<MultiaddrConnection>;
}

@@ -308,0 +308,0 @@ export interface MultiaddrConnectionTimeline {

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

/** Noop for browser compatibility */
/**
* Noop for browser compatibility
*/
export declare function setMaxListeners(): void;
//# sourceMappingURL=events.browser.d.ts.map

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

/** Noop for browser compatibility */
/**
* Noop for browser compatibility
*/
export function setMaxListeners() { }
//# sourceMappingURL=events.browser.js.map
/// <reference types="node" />
import { setMaxListeners as nodeSetMaxListeners } from 'events';
/**
* Create a setMaxListeners that doesn't break browser usage
*/
export declare const setMaxListeners: typeof nodeSetMaxListeners;
//# sourceMappingURL=events.d.ts.map
import { setMaxListeners as nodeSetMaxListeners } from 'events';
// create a setMaxListeners that doesn't break browser usage
/**
* Create a setMaxListeners that doesn't break browser usage
*/
export const setMaxListeners = (n, ...eventTargets) => {

@@ -4,0 +6,0 @@ try {

@@ -5,10 +5,9 @@ import type { CID } from 'multiformats/cid';

export type KeyType = 'RSA' | 'Ed25519' | 'secp256k1';
interface PublicKeyBase<KeyType extends string, DigestCode extends number = number> {
export interface RSAPublicKey {
/**
* The type of this key
*/
readonly type: KeyType;
readonly type: 'RSA';
/**
* The raw public key bytes (for Ed25519 and secp256k1 keys) or PKIX in ASN1
* DER format (for RSA keys)
* PKIX in ASN1 DER format
*/

@@ -23,15 +22,12 @@ readonly raw: Uint8Array;

*
* It contains either an identity hash containing the protobuf version of the
* public key (for Ed25519 and secp256k1 keys) or a sha256 hash of the
* protobuf version of the public key (RSA keys).
* It contains a sha256 hash of the protobuf version of the public key.
*/
toMultihash(): MultihashDigest<DigestCode>;
toMultihash(): MultihashDigest<0x12>;
/**
* Return this public key as a CID encoded with the `libp2p-key` codec
*
* The digest contains either an identity hash containing the protobuf version
* of the public key (for Ed25519 and secp256k1 keys) or a sha256 hash of the
* protobuf version of the public key (RSA keys).
* The digest contains a sha256 hash of the protobuf version of the public
* key.
*/
toCID(): CID<unknown, 0x72, DigestCode, 1>;
toCID(): CID<unknown, 0x72, 0x12, 1>;
/**

@@ -47,8 +43,72 @@ * Verify the passed data was signed by the private key corresponding to this

}
export interface RSAPublicKey extends PublicKeyBase<'RSA', 0x12> {
export interface Ed25519PublicKey {
/**
* The type of this key
*/
readonly type: 'Ed25519';
/**
* The raw public key bytes
*/
readonly raw: Uint8Array;
/**
* Returns `true` if the passed object matches this key
*/
equals(key?: any): boolean;
/**
* Returns this public key as an identity hash containing the protobuf wrapped
* public key
*/
toMultihash(): MultihashDigest<0x0>;
/**
* Return this public key as a CID encoded with the `libp2p-key` codec
*
* The digest contains an identity hash containing the protobuf wrapped
* version of the public key.
*/
toCID(): CID<unknown, 0x72, 0x0, 1>;
/**
* Verify the passed data was signed by the private key corresponding to this
* public key
*/
verify(data: Uint8Array | Uint8ArrayList, sig: Uint8Array): boolean | Promise<boolean>;
/**
* Returns this key as a multihash with base58btc encoding
*/
toString(): string;
}
export interface Ed25519PublicKey extends PublicKeyBase<'Ed25519', 0x0> {
export interface Secp256k1PublicKey {
/**
* The type of this key
*/
readonly type: 'secp256k1';
/**
* The raw public key bytes
*/
readonly raw: Uint8Array;
/**
* Returns `true` if the passed object matches this key
*/
equals(key?: any): boolean;
/**
* Returns this public key as an identity hash containing the protobuf wrapped
* public key
*/
toMultihash(): MultihashDigest<0x0>;
/**
* Return this public key as a CID encoded with the `libp2p-key` codec
*
* The digest contains an identity hash containing the protobuf wrapped
* version of the public key.
*/
toCID(): CID<unknown, 0x72, 0x0, 1>;
/**
* Verify the passed data was signed by the private key corresponding to this
* public key
*/
verify(data: Uint8Array | Uint8ArrayList, sig: Uint8Array): boolean | Promise<boolean>;
/**
* Returns this key as a multihash with base58btc encoding
*/
toString(): string;
}
export interface Secp256k1PublicKey extends PublicKeyBase<'secp256k1', 0x0> {
}
export type PublicKey = RSAPublicKey | Ed25519PublicKey | Secp256k1PublicKey;

@@ -63,14 +123,13 @@ /**

*/
interface PrivateKeyBase<KeyType extends string, PublicKeyType extends PublicKeyBase<KeyType>> {
export interface RSAPrivateKey {
/**
* The type of this key
*/
readonly type: KeyType;
readonly type: 'RSA';
/**
* The public key that corresponds to this private key
*/
readonly publicKey: PublicKeyType;
readonly publicKey: RSAPublicKey;
/**
* The raw public key bytes (for Ed25519 and secp256k1 keys) or PKIX in ASN1
* DER format (for RSA keys)
* PKIX in ASN1 DER format
*/

@@ -88,8 +147,48 @@ readonly raw: Uint8Array;

}
export interface RSAPrivateKey extends PrivateKeyBase<'RSA', RSAPublicKey> {
export interface Ed25519PrivateKey {
/**
* The type of this key
*/
readonly type: 'Ed25519';
/**
* The public key that corresponds to this private key
*/
readonly publicKey: Ed25519PublicKey;
/**
* The raw public key bytes
*/
readonly raw: Uint8Array;
/**
* Returns `true` if the passed object matches this key
*/
equals(key?: any): boolean;
/**
* Sign the passed data with this private key and return the signature for
* later verification
*/
sign(data: Uint8Array | Uint8ArrayList): Uint8Array | Promise<Uint8Array>;
}
export interface Ed25519PrivateKey extends PrivateKeyBase<'Ed25519', Ed25519PublicKey> {
export interface Secp256k1PrivateKey {
/**
* The type of this key
*/
readonly type: 'secp256k1';
/**
* The public key that corresponds to this private key
*/
readonly publicKey: Secp256k1PublicKey;
/**
* The raw public key bytes
*/
readonly raw: Uint8Array;
/**
* Returns `true` if the passed object matches this key
*/
equals(key?: any): boolean;
/**
* Sign the passed data with this private key and return the signature for
* later verification
*/
sign(data: Uint8Array | Uint8ArrayList): Uint8Array | Promise<Uint8Array>;
}
export interface Secp256k1PrivateKey extends PrivateKeyBase<'secp256k1', Secp256k1PublicKey> {
}
export type PrivateKey = RSAPrivateKey | Ed25519PrivateKey | Secp256k1PrivateKey;

@@ -101,3 +200,2 @@ /**

export declare function isPrivateKey(key?: any): key is PrivateKey;
export {};
//# sourceMappingURL=index.d.ts.map

@@ -98,3 +98,3 @@ import type { Stream } from '../connection/index.js';

}
interface Subscription {
export interface Subscription {
topic: string;

@@ -246,3 +246,2 @@ subscribe: boolean;

export declare function isPubSub(obj?: any): obj is PubSub;
export {};
//# sourceMappingURL=index.d.ts.map

@@ -11,7 +11,11 @@ import type { Connection, Stream } from '../connection/index.js';

/**
* How many incoming streams can be open for this protocol at the same time on each connection (default: 32)
* How many incoming streams can be open for this protocol at the same time on each connection
*
* @default 32
*/
maxInboundStreams?: number;
/**
* How many outgoing streams can be open for this protocol at the same time on each connection (default: 64)
* How many outgoing streams can be open for this protocol at the same time on each connection
*
* @default 64
*/

@@ -18,0 +22,0 @@ maxOutboundStreams?: number;

{
"name": "@libp2p/interface",
"version": "2.1.0",
"version": "2.1.1-c258b35af",
"description": "The interface implemented by a libp2p node",

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

@@ -129,3 +129,3 @@ import type { AbortOptions, Logger } from '../index.js'

*
* The sink will return and the source will throw if an error is passed or return normally if not.
* The sink will return and the source will throw.
*/

@@ -358,3 +358,3 @@ abort(err: Error): void

*/
protect(connection: MultiaddrConnection): Promise<MultiaddrConnection>
protect(connection: MultiaddrConnection, options?: AbortOptions): Promise<MultiaddrConnection>
}

@@ -361,0 +361,0 @@

@@ -1,2 +0,4 @@

/** Noop for browser compatibility */
/**
* Noop for browser compatibility
*/
export function setMaxListeners (): void {}
import { setMaxListeners as nodeSetMaxListeners } from 'events'
// create a setMaxListeners that doesn't break browser usage
/**
* Create a setMaxListeners that doesn't break browser usage
*/
export const setMaxListeners: typeof nodeSetMaxListeners = (n, ...eventTargets) => {

@@ -5,0 +7,0 @@ try {

@@ -7,11 +7,10 @@ import type { CID } from 'multiformats/cid'

interface PublicKeyBase<KeyType extends string, DigestCode extends number = number> {
export interface RSAPublicKey {
/**
* The type of this key
*/
readonly type: KeyType
readonly type: 'RSA'
/**
* The raw public key bytes (for Ed25519 and secp256k1 keys) or PKIX in ASN1
* DER format (for RSA keys)
* PKIX in ASN1 DER format
*/

@@ -28,7 +27,5 @@ readonly raw: Uint8Array

*
* It contains either an identity hash containing the protobuf version of the
* public key (for Ed25519 and secp256k1 keys) or a sha256 hash of the
* protobuf version of the public key (RSA keys).
* It contains a sha256 hash of the protobuf version of the public key.
*/
toMultihash(): MultihashDigest<DigestCode>
toMultihash(): MultihashDigest<0x12>

@@ -38,7 +35,6 @@ /**

*
* The digest contains either an identity hash containing the protobuf version
* of the public key (for Ed25519 and secp256k1 keys) or a sha256 hash of the
* protobuf version of the public key (RSA keys).
* The digest contains a sha256 hash of the protobuf version of the public
* key.
*/
toCID(): CID<unknown, 0x72, DigestCode, 1>
toCID(): CID<unknown, 0x72, 0x12, 1>

@@ -57,5 +53,86 @@ /**

export interface RSAPublicKey extends PublicKeyBase<'RSA', 0x12> {}
export interface Ed25519PublicKey extends PublicKeyBase<'Ed25519', 0x0> {}
export interface Secp256k1PublicKey extends PublicKeyBase<'secp256k1', 0x0> {}
export interface Ed25519PublicKey {
/**
* The type of this key
*/
readonly type: 'Ed25519'
/**
* The raw public key bytes
*/
readonly raw: Uint8Array
/**
* Returns `true` if the passed object matches this key
*/
equals(key?: any): boolean
/**
* Returns this public key as an identity hash containing the protobuf wrapped
* public key
*/
toMultihash(): MultihashDigest<0x0>
/**
* Return this public key as a CID encoded with the `libp2p-key` codec
*
* The digest contains an identity hash containing the protobuf wrapped
* version of the public key.
*/
toCID(): CID<unknown, 0x72, 0x0, 1>
/**
* Verify the passed data was signed by the private key corresponding to this
* public key
*/
verify(data: Uint8Array | Uint8ArrayList, sig: Uint8Array): boolean | Promise<boolean>
/**
* Returns this key as a multihash with base58btc encoding
*/
toString(): string
}
export interface Secp256k1PublicKey {
/**
* The type of this key
*/
readonly type: 'secp256k1'
/**
* The raw public key bytes
*/
readonly raw: Uint8Array
/**
* Returns `true` if the passed object matches this key
*/
equals(key?: any): boolean
/**
* Returns this public key as an identity hash containing the protobuf wrapped
* public key
*/
toMultihash(): MultihashDigest<0x0>
/**
* Return this public key as a CID encoded with the `libp2p-key` codec
*
* The digest contains an identity hash containing the protobuf wrapped
* version of the public key.
*/
toCID(): CID<unknown, 0x72, 0x0, 1>
/**
* Verify the passed data was signed by the private key corresponding to this
* public key
*/
verify(data: Uint8Array | Uint8ArrayList, sig: Uint8Array): boolean | Promise<boolean>
/**
* Returns this key as a multihash with base58btc encoding
*/
toString(): string
}
export type PublicKey = RSAPublicKey | Ed25519PublicKey | Secp256k1PublicKey

@@ -83,7 +160,7 @@

*/
interface PrivateKeyBase<KeyType extends string, PublicKeyType extends PublicKeyBase<KeyType>> {
export interface RSAPrivateKey {
/**
* The type of this key
*/
readonly type: KeyType
readonly type: 'RSA'

@@ -93,7 +170,6 @@ /**

*/
readonly publicKey: PublicKeyType
readonly publicKey: RSAPublicKey
/**
* The raw public key bytes (for Ed25519 and secp256k1 keys) or PKIX in ASN1
* DER format (for RSA keys)
* PKIX in ASN1 DER format
*/

@@ -114,5 +190,58 @@ readonly raw: Uint8Array

export interface RSAPrivateKey extends PrivateKeyBase<'RSA', RSAPublicKey> {}
export interface Ed25519PrivateKey extends PrivateKeyBase<'Ed25519', Ed25519PublicKey> {}
export interface Secp256k1PrivateKey extends PrivateKeyBase<'secp256k1', Secp256k1PublicKey> {}
export interface Ed25519PrivateKey {
/**
* The type of this key
*/
readonly type: 'Ed25519'
/**
* The public key that corresponds to this private key
*/
readonly publicKey: Ed25519PublicKey
/**
* The raw public key bytes
*/
readonly raw: Uint8Array
/**
* Returns `true` if the passed object matches this key
*/
equals(key?: any): boolean
/**
* Sign the passed data with this private key and return the signature for
* later verification
*/
sign(data: Uint8Array | Uint8ArrayList): Uint8Array | Promise<Uint8Array>
}
export interface Secp256k1PrivateKey {
/**
* The type of this key
*/
readonly type: 'secp256k1'
/**
* The public key that corresponds to this private key
*/
readonly publicKey: Secp256k1PublicKey
/**
* The raw public key bytes
*/
readonly raw: Uint8Array
/**
* Returns `true` if the passed object matches this key
*/
equals(key?: any): boolean
/**
* Sign the passed data with this private key and return the signature for
* later verification
*/
sign(data: Uint8Array | Uint8ArrayList): Uint8Array | Promise<Uint8Array>
}
export type PrivateKey = RSAPrivateKey | Ed25519PrivateKey | Secp256k1PrivateKey

@@ -119,0 +248,0 @@

@@ -118,3 +118,3 @@ import type { Stream } from '../connection/index.js'

interface Subscription {
export interface Subscription {
topic: string

@@ -121,0 +121,0 @@ subscribe: boolean

@@ -14,3 +14,5 @@ import type { Connection, Stream } from '../connection/index.js'

/**
* How many incoming streams can be open for this protocol at the same time on each connection (default: 32)
* How many incoming streams can be open for this protocol at the same time on each connection
*
* @default 32
*/

@@ -20,3 +22,5 @@ maxInboundStreams?: number

/**
* How many outgoing streams can be open for this protocol at the same time on each connection (default: 64)
* How many outgoing streams can be open for this protocol at the same time on each connection
*
* @default 64
*/

@@ -23,0 +27,0 @@ maxOutboundStreams?: number

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

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

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