You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@libp2p/interface

Package Overview
Dependencies
Maintainers
6
Versions
694
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

to
2.10.5-4420fad68

12

dist/src/connection-encrypter.d.ts
import type { MultiaddrConnection } from './connection.js';
import type { AbortOptions, StreamMuxerFactory } from './index.js';
import type { AbortOptions, Logger, StreamMuxerFactory } from './index.js';
import type { PeerId } from './peer-id.js';

@@ -22,2 +22,8 @@ import type { Duplex } from 'it-stream-types';

/**
* A stream with an optional logger
*/
export interface SecurableStream extends Duplex<AsyncGenerator<Uint8Array | Uint8ArrayList>> {
log?: Logger;
}
/**
* A libp2p connection encrypter module must be compliant to this interface

@@ -33,3 +39,3 @@ * to ensure all exchanged data between two peers is encrypted.

*/
secureOutbound<Stream extends Duplex<AsyncGenerator<Uint8Array | Uint8ArrayList>> = MultiaddrConnection>(connection: Stream, options?: SecureConnectionOptions): Promise<SecuredConnection<Stream, Extension>>;
secureOutbound<Stream extends SecurableStream = MultiaddrConnection>(connection: Stream, options?: SecureConnectionOptions): Promise<SecuredConnection<Stream, Extension>>;
/**

@@ -40,3 +46,3 @@ * Decrypt incoming data. If the remote PeerId is known,

*/
secureInbound<Stream extends Duplex<AsyncGenerator<Uint8Array | Uint8ArrayList>> = MultiaddrConnection>(connection: Stream, options?: SecureConnectionOptions): Promise<SecuredConnection<Stream, Extension>>;
secureInbound<Stream extends SecurableStream = MultiaddrConnection>(connection: Stream, options?: SecureConnectionOptions): Promise<SecuredConnection<Stream, Extension>>;
}

@@ -43,0 +49,0 @@ export interface SecuredConnection<Stream = any, Extension = unknown> {

@@ -28,2 +28,3 @@ /**

import type { Listener, OutboundConnectionUpgradeEvents } from './transport.js';
import type { DNS } from '@multiformats/dns';
import type { Multiaddr } from '@multiformats/multiaddr';

@@ -114,6 +115,38 @@ import type { TypedEventTarget } from 'main-event';

export interface Logger {
/**
* Log a message
*/
(formatter: any, ...args: any[]): void;
/**
* Log an error message
*/
error(formatter: any, ...args: any[]): void;
/**
* Log a trace message
*/
trace(formatter: any, ...args: any[]): void;
/**
* `true` if this logger is enabled
*/
enabled: boolean;
/**
* Create a logger scoped below this one
*
* @example
*
* ```ts
* import { defaultLogger } from '@libp2p/logger'
*
* const log = defaultLogger().forComponent('foo')
*
* log('hello')
* // foo hello
*
* const subLog = log.newScope('bar')
*
* subLog('hello')
* // foo:bar hello
* ```
*/
newScope(name: string): Logger;
}

@@ -160,3 +193,23 @@ /**

}
export interface MultiaddrResolveOptions extends AbortOptions, LoggerOptions {
/**
* An optional DNS resolver
*/
dns?: DNS;
}
/**
* `MultiaddrResolver`s perform resolution of multiaddr components that require
* translation by external systems (for example DNSADDR to TXT records).
*/
export interface MultiaddrResolver {
/**
* Returns true if this resolver can resolve components of this multiaddr
*/
canResolve(address: Multiaddr): boolean;
/**
* Returns one or more multiaddrs with components resolved to other values
*/
resolve(address: Multiaddr, options: MultiaddrResolveOptions): Promise<Multiaddr[]>;
}
/**
* Once you have a libp2p instance, you can listen to several events it emits,

@@ -163,0 +216,0 @@ * so that you can be notified of relevant network events.

import type { Direction, Stream } from './connection.js';
import type { AbortOptions } from './index.js';
import type { AbortOptions, Logger } from './index.js';
import type { Duplex } from 'it-stream-types';

@@ -54,3 +54,7 @@ import type { Uint8ArrayList } from 'uint8arraylist';

direction?: Direction;
/**
* The logger used by the connection
*/
log?: Logger;
}
//# sourceMappingURL=stream-muxer.d.ts.map
{
"name": "@libp2p/interface",
"version": "2.10.4",
"version": "2.10.5-4420fad68",
"description": "The interface implemented by a libp2p node",

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

"dependencies": {
"@multiformats/dns": "^1.0.6",
"@multiformats/multiaddr": "^12.4.4",

@@ -46,0 +47,0 @@ "it-pushable": "^3.2.3",

import type { MultiaddrConnection } from './connection.js'
import type { AbortOptions, StreamMuxerFactory } from './index.js'
import type { AbortOptions, Logger, StreamMuxerFactory } from './index.js'
import type { PeerId } from './peer-id.js'

@@ -25,2 +25,9 @@ import type { Duplex } from 'it-stream-types'

/**
* A stream with an optional logger
*/
export interface SecurableStream extends Duplex<AsyncGenerator<Uint8Array | Uint8ArrayList>> {
log?: Logger
}
/**
* A libp2p connection encrypter module must be compliant to this interface

@@ -37,3 +44,3 @@ * to ensure all exchanged data between two peers is encrypted.

*/
secureOutbound <Stream extends Duplex<AsyncGenerator<Uint8Array | Uint8ArrayList>> = MultiaddrConnection> (connection: Stream, options?: SecureConnectionOptions): Promise<SecuredConnection<Stream, Extension>>
secureOutbound <Stream extends SecurableStream = MultiaddrConnection> (connection: Stream, options?: SecureConnectionOptions): Promise<SecuredConnection<Stream, Extension>>

@@ -45,3 +52,3 @@ /**

*/
secureInbound <Stream extends Duplex<AsyncGenerator<Uint8Array | Uint8ArrayList>> = MultiaddrConnection> (connection: Stream, options?: SecureConnectionOptions): Promise<SecuredConnection<Stream, Extension>>
secureInbound <Stream extends SecurableStream = MultiaddrConnection> (connection: Stream, options?: SecureConnectionOptions): Promise<SecuredConnection<Stream, Extension>>
}

@@ -48,0 +55,0 @@

@@ -29,2 +29,3 @@ /**

import type { Listener, OutboundConnectionUpgradeEvents } from './transport.js'
import type { DNS } from '@multiformats/dns'
import type { Multiaddr } from '@multiformats/multiaddr'

@@ -130,6 +131,42 @@ import type { TypedEventTarget } from 'main-event'

export interface Logger {
/**
* Log a message
*/
(formatter: any, ...args: any[]): void
/**
* Log an error message
*/
error(formatter: any, ...args: any[]): void
/**
* Log a trace message
*/
trace(formatter: any, ...args: any[]): void
/**
* `true` if this logger is enabled
*/
enabled: boolean
/**
* Create a logger scoped below this one
*
* @example
*
* ```ts
* import { defaultLogger } from '@libp2p/logger'
*
* const log = defaultLogger().forComponent('foo')
*
* log('hello')
* // foo hello
*
* const subLog = log.newScope('bar')
*
* subLog('hello')
* // foo:bar hello
* ```
*/
newScope(name: string): Logger
}

@@ -178,3 +215,26 @@

export interface MultiaddrResolveOptions extends AbortOptions, LoggerOptions {
/**
* An optional DNS resolver
*/
dns?: DNS
}
/**
* `MultiaddrResolver`s perform resolution of multiaddr components that require
* translation by external systems (for example DNSADDR to TXT records).
*/
export interface MultiaddrResolver {
/**
* Returns true if this resolver can resolve components of this multiaddr
*/
canResolve (address: Multiaddr): boolean
/**
* Returns one or more multiaddrs with components resolved to other values
*/
resolve (address: Multiaddr, options: MultiaddrResolveOptions): Promise<Multiaddr[]>
}
/**
* Once you have a libp2p instance, you can listen to several events it emits,

@@ -181,0 +241,0 @@ * so that you can be notified of relevant network events.

import type { Direction, Stream } from './connection.js'
import type { AbortOptions } from './index.js'
import type { AbortOptions, Logger } from './index.js'
import type { Duplex } from 'it-stream-types'

@@ -63,2 +63,7 @@ import type { Uint8ArrayList } from 'uint8arraylist'

direction?: Direction
/**
* The logger used by the connection
*/
log?: Logger
}

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