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

@libp2p/interfaces

Package Overview
Dependencies
Maintainers
4
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@libp2p/interfaces - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

dist/src/peer-store/index.d.ts

30

dist/src/connection/index.d.ts
import type { Multiaddr } from '@multiformats/multiaddr';
import type { PeerId } from '../peer-id';
import type { MuxedStream } from '../stream-muxer';
import type * as Status from './status.js';
import type { Duplex } from 'it-stream-types';
export interface Timeline {

@@ -17,9 +17,23 @@ open: number;

}
export interface StreamData {
export interface Metadata {
protocol: string;
metadata: Record<string, any>;
}
export interface Stream {
/**
* A Stream is a data channel between two peers that
* can be written to and read from at both ends.
*
* It may be encrypted and multiplexed depending on the
* configuration of the nodes.
*/
export interface Stream extends Duplex<Uint8Array> {
close: () => void;
abort: (err?: Error) => void;
reset: () => void;
timeline: Timeline;
id: string;
}
export interface ProtocolStream {
protocol: string;
stream: MuxedStream;
stream: Stream;
}

@@ -37,7 +51,7 @@ /**

remotePeer: PeerId;
registry: Map<string, StreamData>;
registry: Map<string, Metadata>;
tags: string[];
streams: MuxedStream[];
newStream: (multicodecs: string[]) => Promise<Stream>;
addStream: (muxedStream: MuxedStream, streamData: StreamData) => void;
streams: Stream[];
newStream: (multicodecs: string[]) => Promise<ProtocolStream>;
addStream: (stream: Stream, data: Metadata) => void;
removeStream: (id: string) => void;

@@ -44,0 +58,0 @@ close: () => Promise<void>;

@@ -37,2 +37,3 @@ import type { PeerId } from '../peer-id';

queryFuncTimeout?: number;
minPeers?: number;
}

@@ -122,3 +123,3 @@ /**

/**
* Find providers for a given CI
* Find providers of a given CID
*/

@@ -125,0 +126,0 @@ findProviders: (key: CID, options?: QueryOptions) => AsyncIterable<QueryEvent>;

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

import type { PeerId } from './peer-id/index.js';
import type { Multiaddr } from '@multiformats/multiaddr';
import type { Duplex } from 'it-stream-types';
export interface AbortOptions {

@@ -9,2 +12,12 @@ signal?: AbortSignal;

}
export interface Dialer {
dialProtocol: (peer: PeerId, protocol: string, options?: {
signal?: AbortSignal;
}) => Promise<{
stream: Duplex<Uint8Array>;
}>;
}
export interface Addressable {
multiaddrs: Multiaddr[];
}
//# sourceMappingURL=index.d.ts.map

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

import type { PeerId } from '../peer-id/index.js';
/**

@@ -20,4 +21,13 @@ * Record is the base implementation of a record that can be used as the payload of a libp2p envelope.

*/
equals: (other: unknown) => boolean;
equals: (other: Record) => boolean;
}
export interface Envelope {
peerId: PeerId;
payloadType: Uint8Array;
payload: Uint8Array;
signature: Uint8Array;
marshal: () => Uint8Array;
validate: (domain: string) => Promise<boolean>;
equals: (other: Envelope) => boolean;
}
//# sourceMappingURL=index.d.ts.map

@@ -1,25 +0,12 @@

import type { Connection } from '../connection';
import type { MuxedStream } from '../stream-muxer';
import type { Connection, Stream } from '../connection';
import type { PeerId } from '../peer-id';
import type { PeerData } from '../peer-data';
import type { PeerStore } from '../peer-store';
export interface IncomingStreamEvent {
protocol: string;
stream: MuxedStream;
stream: Stream;
connection: Connection;
}
export interface ChangeProtocolsEvent {
peerId: PeerId;
protocols: string[];
}
export interface ProtoBook {
get: (peerId: PeerId) => string[];
}
export interface PeerStore {
on: (event: 'change:protocols', handler: (event: ChangeProtocolsEvent) => void) => void;
protoBook: ProtoBook;
peers: Map<string, PeerData>;
get: (peerId: PeerId) => PeerData;
}
export interface Registrar {
handle: (multicodecs: string[], handler: (event: IncomingStreamEvent) => void) => void;
handle: (multicodec: string | string[], handler: (event: IncomingStreamEvent) => void) => void;
unhandle: (multicodec: string) => void;
register: (topology: any) => string;

@@ -26,0 +13,0 @@ unregister: (id: string) => void;

import type { Duplex } from 'it-stream-types';
import type { Stream } from '../connection/index.js';
export interface MuxerFactory {

@@ -10,8 +11,8 @@ new (options: MuxerOptions): Muxer;

export interface Muxer extends Duplex<Uint8Array> {
readonly streams: MuxedStream[];
readonly streams: Stream[];
/**
* Initiate a new stream with the given name. If no name is
* provided, the id of th stream will be used.
* provided, the id of the stream will be used.
*/
newStream: (name?: string) => MuxedStream;
newStream: (name?: string) => Stream;
}

@@ -22,20 +23,9 @@ export interface MuxerOptions {

*/
onStream?: (stream: MuxedStream) => void;
onStream?: (stream: Stream) => void;
/**
* A function called when a stream ends.
*/
onStreamEnd?: (stream: MuxedStream) => void;
onStreamEnd?: (stream: Stream) => void;
maxMsgSize?: number;
}
export interface MuxedTimeline {
open: number;
close?: number;
}
export interface MuxedStream extends Duplex<Uint8Array> {
close: () => void;
abort: (err?: Error) => void;
reset: () => void;
timeline: MuxedTimeline;
id: string;
}
//# sourceMappingURL=index.d.ts.map

@@ -79,2 +79,5 @@ /// <reference types="node" />

}
export interface ProtocolHandler {
(stream: Duplex<Uint8Array>, connection: Connection): void;
}
//# sourceMappingURL=index.d.ts.map
{
"name": "@libp2p/interfaces",
"version": "1.2.0",
"version": "1.3.0",
"description": "Interfaces for JS Libp2p",

@@ -99,2 +99,6 @@ "license": "Apache-2.0 OR MIT",

},
"./peer-store": {
"import": "./dist/src/peer-store/index.js",
"types": "./dist/src/peer-store/index.d.ts"
},
"./pubsub": {

@@ -101,0 +105,0 @@ "import": "./dist/src/pubsub/index.js",

import type { Multiaddr } from '@multiformats/multiaddr'
import type { PeerId } from '../peer-id'
import type { MuxedStream } from '../stream-muxer'
import type * as Status from './status.js'
import type { Duplex } from 'it-stream-types'

@@ -20,3 +20,3 @@ export interface Timeline {

export interface StreamData {
export interface Metadata {
protocol: string

@@ -26,5 +26,20 @@ metadata: Record<string, any>

export interface Stream {
/**
* A Stream is a data channel between two peers that
* can be written to and read from at both ends.
*
* It may be encrypted and multiplexed depending on the
* configuration of the nodes.
*/
export interface Stream extends Duplex<Uint8Array> {
close: () => void
abort: (err?: Error) => void
reset: () => void
timeline: Timeline
id: string
}
export interface ProtocolStream {
protocol: string
stream: MuxedStream
stream: Stream
}

@@ -43,10 +58,10 @@

remotePeer: PeerId
registry: Map<string, StreamData>
registry: Map<string, Metadata>
tags: string[]
streams: MuxedStream[]
streams: Stream[]
newStream: (multicodecs: string[]) => Promise<Stream>
addStream: (muxedStream: MuxedStream, streamData: StreamData) => void
newStream: (multicodecs: string[]) => Promise<ProtocolStream>
addStream: (stream: Stream, data: Metadata) => void
removeStream: (id: string) => void
close: () => Promise<void>
}

@@ -42,2 +42,3 @@ import type { PeerId } from '../peer-id'

queryFuncTimeout?: number
minPeers?: number
}

@@ -138,3 +139,3 @@

/**
* Find providers for a given CI
* Find providers of a given CID
*/

@@ -141,0 +142,0 @@ findProviders: (key: CID, options?: QueryOptions) => AsyncIterable<QueryEvent>

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

import type { PeerId } from './peer-id/index.js'
import type { Multiaddr } from '@multiformats/multiaddr'
import type { Duplex } from 'it-stream-types'

@@ -11,1 +14,11 @@ export interface AbortOptions {

}
// Implemented by libp2p, should be moved to libp2p-interfaces eventually
export interface Dialer {
dialProtocol: (peer: PeerId, protocol: string, options?: { signal?: AbortSignal }) => Promise<{ stream: Duplex<Uint8Array> }>
}
// Implemented by libp2p, should be moved to libp2p-interfaces eventually
export interface Addressable {
multiaddrs: Multiaddr[]
}

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

import type { PeerId } from '../peer-id/index.js'
/**

@@ -20,3 +22,14 @@ * Record is the base implementation of a record that can be used as the payload of a libp2p envelope.

*/
equals: (other: unknown) => boolean
equals: (other: Record) => boolean
}
export interface Envelope {
peerId: PeerId
payloadType: Uint8Array
payload: Uint8Array
signature: Uint8Array
marshal: () => Uint8Array
validate: (domain: string) => Promise<boolean>
equals: (other: Envelope) => boolean
}

@@ -1,30 +0,15 @@

import type { Connection } from '../connection'
import type { MuxedStream } from '../stream-muxer'
import type { Connection, Stream } from '../connection'
import type { PeerId } from '../peer-id'
import type { PeerData } from '../peer-data'
import type { PeerStore } from '../peer-store'
export interface IncomingStreamEvent {
protocol: string
stream: MuxedStream
stream: Stream
connection: Connection
}
export interface ChangeProtocolsEvent {
peerId: PeerId
protocols: string[]
}
export interface Registrar {
handle: (multicodec: string | string[], handler: (event: IncomingStreamEvent) => void) => void
unhandle: (multicodec: string) => void
export interface ProtoBook {
get: (peerId: PeerId) => string[]
}
export interface PeerStore {
on: (event: 'change:protocols', handler: (event: ChangeProtocolsEvent) => void) => void
protoBook: ProtoBook
peers: Map<string, PeerData>
get: (peerId: PeerId) => PeerData
}
export interface Registrar {
handle: (multicodecs: string[], handler: (event: IncomingStreamEvent) => void) => void
register: (topology: any) => string

@@ -31,0 +16,0 @@ unregister: (id: string) => void

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

@@ -12,8 +13,8 @@ export interface MuxerFactory {

export interface Muxer extends Duplex<Uint8Array> {
readonly streams: MuxedStream[]
readonly streams: Stream[]
/**
* Initiate a new stream with the given name. If no name is
* provided, the id of th stream will be used.
* provided, the id of the stream will be used.
*/
newStream: (name?: string) => MuxedStream
newStream: (name?: string) => Stream
}

@@ -25,3 +26,3 @@

*/
onStream?: (stream: MuxedStream) => void
onStream?: (stream: Stream) => void

@@ -31,17 +32,4 @@ /**

*/
onStreamEnd?: (stream: MuxedStream) => void
onStreamEnd?: (stream: Stream) => void
maxMsgSize?: number
}
export interface MuxedTimeline {
open: number
close?: number
}
export interface MuxedStream extends Duplex<Uint8Array> {
close: () => void
abort: (err?: Error) => void
reset: () => void
timeline: MuxedTimeline
id: string
}

@@ -82,1 +82,5 @@ import type { EventEmitter } from 'events'

}
export interface ProtocolHandler {
(stream: Duplex<Uint8Array>, connection: Connection): void
}

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