@libp2p/interface
Advanced tools
| import type { Stream } from '../connection/index.js'; | ||
| import type { EventEmitter } from '../events.js'; | ||
| import type { PeerId } from '../peer-id/index.js'; | ||
| import type { Pushable } from 'it-pushable'; | ||
| import type { Uint8ArrayList } from 'uint8arraylist'; | ||
| /** | ||
| * On the producing side: | ||
| * * Build messages with the signature, key (from may be enough for certain inlineable public key types), from and seqno fields. | ||
| * | ||
| * On the consuming side: | ||
| * * Enforce the fields to be present, reject otherwise. | ||
| * * Propagate only if the fields are valid and signature can be verified, reject otherwise. | ||
| */ | ||
| export declare const StrictSign = "StrictSign"; | ||
| /** | ||
| * On the producing side: | ||
| * * Build messages without the signature, key, from and seqno fields. | ||
| * * The corresponding protobuf key-value pairs are absent from the marshalled message, not just empty. | ||
| * | ||
| * On the consuming side: | ||
| * * Enforce the fields to be absent, reject otherwise. | ||
| * * Propagate only if the fields are absent, reject otherwise. | ||
| * * A message_id function will not be able to use the above fields, and should instead rely on the data field. A commonplace strategy is to calculate a hash. | ||
| */ | ||
| export declare const StrictNoSign = "StrictNoSign"; | ||
| export type SignaturePolicy = typeof StrictSign | typeof StrictNoSign; | ||
| export interface SignedMessage { | ||
| type: 'signed'; | ||
| from: PeerId; | ||
| topic: string; | ||
| data: Uint8Array; | ||
| sequenceNumber: bigint; | ||
| signature: Uint8Array; | ||
| key: Uint8Array; | ||
| } | ||
| export interface UnsignedMessage { | ||
| type: 'unsigned'; | ||
| topic: string; | ||
| data: Uint8Array; | ||
| } | ||
| export type Message = SignedMessage | UnsignedMessage; | ||
| export interface PubSubRPCMessage { | ||
| from?: Uint8Array; | ||
| topic?: string; | ||
| data?: Uint8Array; | ||
| sequenceNumber?: Uint8Array; | ||
| signature?: Uint8Array; | ||
| key?: Uint8Array; | ||
| } | ||
| export interface PubSubRPCSubscription { | ||
| subscribe?: boolean; | ||
| topic?: string; | ||
| } | ||
| export interface PubSubRPC { | ||
| subscriptions: PubSubRPCSubscription[]; | ||
| messages: PubSubRPCMessage[]; | ||
| } | ||
| export interface PeerStreams extends EventEmitter<PeerStreamEvents> { | ||
| id: PeerId; | ||
| protocol: string; | ||
| outboundStream?: Pushable<Uint8ArrayList>; | ||
| inboundStream?: AsyncIterable<Uint8ArrayList>; | ||
| isWritable: boolean; | ||
| close: () => void; | ||
| write: (buf: Uint8Array | Uint8ArrayList) => void; | ||
| attachInboundStream: (stream: Stream) => AsyncIterable<Uint8ArrayList>; | ||
| attachOutboundStream: (stream: Stream) => Promise<Pushable<Uint8ArrayList>>; | ||
| } | ||
| export interface PubSubInit { | ||
| enabled?: boolean; | ||
| multicodecs?: string[]; | ||
| /** | ||
| * defines how signatures should be handled | ||
| */ | ||
| globalSignaturePolicy?: SignaturePolicy; | ||
| /** | ||
| * if can relay messages not subscribed | ||
| */ | ||
| canRelayMessage?: boolean; | ||
| /** | ||
| * if publish should emit to self, if subscribed | ||
| */ | ||
| emitSelf?: boolean; | ||
| /** | ||
| * handle this many incoming pubsub messages concurrently | ||
| */ | ||
| messageProcessingConcurrency?: number; | ||
| /** | ||
| * How many parallel incoming streams to allow on the pubsub protocol per-connection | ||
| */ | ||
| maxInboundStreams?: number; | ||
| /** | ||
| * How many parallel outgoing streams to allow on the pubsub protocol per-connection | ||
| */ | ||
| maxOutboundStreams?: number; | ||
| } | ||
| interface Subscription { | ||
| topic: string; | ||
| subscribe: boolean; | ||
| } | ||
| export interface SubscriptionChangeData { | ||
| peerId: PeerId; | ||
| subscriptions: Subscription[]; | ||
| } | ||
| export interface PubSubEvents { | ||
| 'subscription-change': CustomEvent<SubscriptionChangeData>; | ||
| 'message': CustomEvent<Message>; | ||
| } | ||
| export interface PublishResult { | ||
| recipients: PeerId[]; | ||
| } | ||
| export declare enum TopicValidatorResult { | ||
| /** | ||
| * The message is considered valid, and it should be delivered and forwarded to the network | ||
| */ | ||
| Accept = "accept", | ||
| /** | ||
| * The message is neither delivered nor forwarded to the network | ||
| */ | ||
| Ignore = "ignore", | ||
| /** | ||
| * The message is considered invalid, and it should be rejected | ||
| */ | ||
| Reject = "reject" | ||
| } | ||
| export interface TopicValidatorFn { | ||
| (peer: PeerId, message: Message): TopicValidatorResult | Promise<TopicValidatorResult>; | ||
| } | ||
| export interface PubSub<Events extends Record<string, any> = PubSubEvents> extends EventEmitter<Events> { | ||
| /** | ||
| * The global signature policy controls whether or not we sill send and receive | ||
| * signed or unsigned messages. | ||
| * | ||
| * Signed messages prevent spoofing message senders and should be preferred to | ||
| * using unsigned messages. | ||
| */ | ||
| globalSignaturePolicy: typeof StrictSign | typeof StrictNoSign; | ||
| /** | ||
| * A list of multicodecs that contain the pubsub protocol name. | ||
| */ | ||
| multicodecs: string[]; | ||
| /** | ||
| * Pubsub routers support message validators per topic, which will validate the message | ||
| * before its propagations. They are stored in a map where keys are the topic name and | ||
| * values are the validators. | ||
| * | ||
| * @example | ||
| * | ||
| * ```js | ||
| * const topic = 'topic' | ||
| * const validateMessage = (msgTopic, msg) => { | ||
| * const input = uint8ArrayToString(msg.data) | ||
| * const validInputs = ['a', 'b', 'c'] | ||
| * | ||
| * if (!validInputs.includes(input)) { | ||
| * throw new Error('no valid input received') | ||
| * } | ||
| * } | ||
| * libp2p.pubsub.topicValidators.set(topic, validateMessage) | ||
| * ``` | ||
| */ | ||
| topicValidators: Map<string, TopicValidatorFn>; | ||
| getPeers: () => PeerId[]; | ||
| /** | ||
| * Gets a list of topics the node is subscribed to. | ||
| * | ||
| * ```js | ||
| * const topics = libp2p.pubsub.getTopics() | ||
| * ``` | ||
| */ | ||
| getTopics: () => string[]; | ||
| /** | ||
| * Subscribes to a pubsub topic. | ||
| * | ||
| * @example | ||
| * | ||
| * ```js | ||
| * const topic = 'topic' | ||
| * const handler = (msg) => { | ||
| * if (msg.topic === topic) { | ||
| * // msg.data - pubsub data received | ||
| * } | ||
| * } | ||
| * | ||
| * libp2p.pubsub.addEventListener('message', handler) | ||
| * libp2p.pubsub.subscribe(topic) | ||
| * ``` | ||
| */ | ||
| subscribe: (topic: string) => void; | ||
| /** | ||
| * Unsubscribes from a pubsub topic. | ||
| * | ||
| * @example | ||
| * | ||
| * ```js | ||
| * const topic = 'topic' | ||
| * const handler = (msg) => { | ||
| * // msg.data - pubsub data received | ||
| * } | ||
| * | ||
| * libp2p.pubsub.removeEventListener(topic handler) | ||
| * libp2p.pubsub.unsubscribe(topic) | ||
| * ``` | ||
| */ | ||
| unsubscribe: (topic: string) => void; | ||
| /** | ||
| * Gets a list of the PeerIds that are subscribed to one topic. | ||
| * | ||
| * @example | ||
| * | ||
| * ```js | ||
| * const peerIds = libp2p.pubsub.getSubscribers(topic) | ||
| * ``` | ||
| */ | ||
| getSubscribers: (topic: string) => PeerId[]; | ||
| /** | ||
| * Publishes messages to the given topic. | ||
| * | ||
| * @example | ||
| * | ||
| * ```js | ||
| * const topic = 'topic' | ||
| * const data = uint8ArrayFromString('data') | ||
| * | ||
| * await libp2p.pubsub.publish(topic, data) | ||
| * ``` | ||
| */ | ||
| publish: (topic: string, data: Uint8Array) => Promise<PublishResult>; | ||
| } | ||
| export interface PeerStreamEvents { | ||
| 'stream:inbound': CustomEvent<never>; | ||
| 'stream:outbound': CustomEvent<never>; | ||
| 'close': CustomEvent<never>; | ||
| } | ||
| export {}; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pubsub/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,eAAe,CAAA;AAEtC;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,iBAAiB,CAAA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AAE,OAAO,EAAE,OAAO,GAAG,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAA;CACvF;AAED,MAAM,WAAW,MAAM,CAAC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,YAAY,CAAE,SAAQ,YAAY,CAAC,MAAM,CAAC;IACrG;;;;;;OAMG;IACH,qBAAqB,EAAE,OAAO,UAAU,GAAG,OAAO,YAAY,CAAA;IAE9D;;OAEG;IACH,WAAW,EAAE,MAAM,EAAE,CAAA;IAErB;;;;;;;;;;;;;;;;;;;OAmBG;IACH,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;IAE9C,QAAQ,EAAE,MAAM,MAAM,EAAE,CAAA;IAExB;;;;;;OAMG;IACH,SAAS,EAAE,MAAM,MAAM,EAAE,CAAA;IAEzB;;;;;;;;;;;;;;;;OAgBG;IACH,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAElC;;;;;;;;;;;;;;OAcG;IACH,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAEpC;;;;;;;;OAQG;IACH,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,EAAE,CAAA;IAE3C;;;;;;;;;;;OAWG;IACH,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,KAAK,OAAO,CAAC,aAAa,CAAC,CAAA;CACrE;AAED,MAAM,WAAW,gBAAgB;IAC/B,gBAAgB,EAAE,WAAW,CAAC,KAAK,CAAC,CAAA;IACpC,iBAAiB,EAAE,WAAW,CAAC,KAAK,CAAC,CAAA;IACrC,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,CAAA;CAC5B"} |
| /** | ||
| * On the producing side: | ||
| * * Build messages with the signature, key (from may be enough for certain inlineable public key types), from and seqno fields. | ||
| * | ||
| * On the consuming side: | ||
| * * Enforce the fields to be present, reject otherwise. | ||
| * * Propagate only if the fields are valid and signature can be verified, reject otherwise. | ||
| */ | ||
| export const StrictSign = 'StrictSign'; | ||
| /** | ||
| * On the producing side: | ||
| * * Build messages without the signature, key, from and seqno fields. | ||
| * * The corresponding protobuf key-value pairs are absent from the marshalled message, not just empty. | ||
| * | ||
| * On the consuming side: | ||
| * * Enforce the fields to be absent, reject otherwise. | ||
| * * Propagate only if the fields are absent, reject otherwise. | ||
| * * A message_id function will not be able to use the above fields, and should instead rely on the data field. A commonplace strategy is to calculate a hash. | ||
| */ | ||
| export const StrictNoSign = 'StrictNoSign'; | ||
| export var TopicValidatorResult; | ||
| (function (TopicValidatorResult) { | ||
| /** | ||
| * The message is considered valid, and it should be delivered and forwarded to the network | ||
| */ | ||
| TopicValidatorResult["Accept"] = "accept"; | ||
| /** | ||
| * The message is neither delivered nor forwarded to the network | ||
| */ | ||
| TopicValidatorResult["Ignore"] = "ignore"; | ||
| /** | ||
| * The message is considered invalid, and it should be rejected | ||
| */ | ||
| TopicValidatorResult["Reject"] = "reject"; | ||
| })(TopicValidatorResult || (TopicValidatorResult = {})); | ||
| //# sourceMappingURL=index.js.map |
| {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/pubsub/index.ts"],"names":[],"mappings":"AAMA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,YAAY,CAAA;AAEtC;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,cAAc,CAAA;AA6G1C,MAAM,CAAN,IAAY,oBAaX;AAbD,WAAY,oBAAoB;IAC9B;;OAEG;IACH,yCAAiB,CAAA;IACjB;;OAEG;IACH,yCAAiB,CAAA;IACjB;;OAEG;IACH,yCAAiB,CAAA;AACnB,CAAC,EAbW,oBAAoB,KAApB,oBAAoB,QAa/B"} |
| import type { Stream } from '../connection/index.js' | ||
| import type { EventEmitter } from '../events.js' | ||
| import type { PeerId } from '../peer-id/index.js' | ||
| import type { Pushable } from 'it-pushable' | ||
| import type { Uint8ArrayList } from 'uint8arraylist' | ||
| /** | ||
| * On the producing side: | ||
| * * Build messages with the signature, key (from may be enough for certain inlineable public key types), from and seqno fields. | ||
| * | ||
| * On the consuming side: | ||
| * * Enforce the fields to be present, reject otherwise. | ||
| * * Propagate only if the fields are valid and signature can be verified, reject otherwise. | ||
| */ | ||
| export const StrictSign = 'StrictSign' | ||
| /** | ||
| * On the producing side: | ||
| * * Build messages without the signature, key, from and seqno fields. | ||
| * * The corresponding protobuf key-value pairs are absent from the marshalled message, not just empty. | ||
| * | ||
| * On the consuming side: | ||
| * * Enforce the fields to be absent, reject otherwise. | ||
| * * Propagate only if the fields are absent, reject otherwise. | ||
| * * A message_id function will not be able to use the above fields, and should instead rely on the data field. A commonplace strategy is to calculate a hash. | ||
| */ | ||
| export const StrictNoSign = 'StrictNoSign' | ||
| export type SignaturePolicy = typeof StrictSign | typeof StrictNoSign | ||
| export interface SignedMessage { | ||
| type: 'signed' | ||
| from: PeerId | ||
| topic: string | ||
| data: Uint8Array | ||
| sequenceNumber: bigint | ||
| signature: Uint8Array | ||
| key: Uint8Array | ||
| } | ||
| export interface UnsignedMessage { | ||
| type: 'unsigned' | ||
| topic: string | ||
| data: Uint8Array | ||
| } | ||
| export type Message = SignedMessage | UnsignedMessage | ||
| export interface PubSubRPCMessage { | ||
| from?: Uint8Array | ||
| topic?: string | ||
| data?: Uint8Array | ||
| sequenceNumber?: Uint8Array | ||
| signature?: Uint8Array | ||
| key?: Uint8Array | ||
| } | ||
| export interface PubSubRPCSubscription { | ||
| subscribe?: boolean | ||
| topic?: string | ||
| } | ||
| export interface PubSubRPC { | ||
| subscriptions: PubSubRPCSubscription[] | ||
| messages: PubSubRPCMessage[] | ||
| } | ||
| export interface PeerStreams extends EventEmitter<PeerStreamEvents> { | ||
| id: PeerId | ||
| protocol: string | ||
| outboundStream?: Pushable<Uint8ArrayList> | ||
| inboundStream?: AsyncIterable<Uint8ArrayList> | ||
| isWritable: boolean | ||
| close: () => void | ||
| write: (buf: Uint8Array | Uint8ArrayList) => void | ||
| attachInboundStream: (stream: Stream) => AsyncIterable<Uint8ArrayList> | ||
| attachOutboundStream: (stream: Stream) => Promise<Pushable<Uint8ArrayList>> | ||
| } | ||
| export interface PubSubInit { | ||
| enabled?: boolean | ||
| multicodecs?: string[] | ||
| /** | ||
| * defines how signatures should be handled | ||
| */ | ||
| globalSignaturePolicy?: SignaturePolicy | ||
| /** | ||
| * if can relay messages not subscribed | ||
| */ | ||
| canRelayMessage?: boolean | ||
| /** | ||
| * if publish should emit to self, if subscribed | ||
| */ | ||
| emitSelf?: boolean | ||
| /** | ||
| * handle this many incoming pubsub messages concurrently | ||
| */ | ||
| messageProcessingConcurrency?: number | ||
| /** | ||
| * How many parallel incoming streams to allow on the pubsub protocol per-connection | ||
| */ | ||
| maxInboundStreams?: number | ||
| /** | ||
| * How many parallel outgoing streams to allow on the pubsub protocol per-connection | ||
| */ | ||
| maxOutboundStreams?: number | ||
| } | ||
| interface Subscription { | ||
| topic: string | ||
| subscribe: boolean | ||
| } | ||
| export interface SubscriptionChangeData { | ||
| peerId: PeerId | ||
| subscriptions: Subscription[] | ||
| } | ||
| export interface PubSubEvents { | ||
| 'subscription-change': CustomEvent<SubscriptionChangeData> | ||
| 'message': CustomEvent<Message> | ||
| } | ||
| export interface PublishResult { | ||
| recipients: PeerId[] | ||
| } | ||
| export enum TopicValidatorResult { | ||
| /** | ||
| * The message is considered valid, and it should be delivered and forwarded to the network | ||
| */ | ||
| Accept = 'accept', | ||
| /** | ||
| * The message is neither delivered nor forwarded to the network | ||
| */ | ||
| Ignore = 'ignore', | ||
| /** | ||
| * The message is considered invalid, and it should be rejected | ||
| */ | ||
| Reject = 'reject' | ||
| } | ||
| export interface TopicValidatorFn { | ||
| (peer: PeerId, message: Message): TopicValidatorResult | Promise<TopicValidatorResult> | ||
| } | ||
| export interface PubSub<Events extends Record<string, any> = PubSubEvents> extends EventEmitter<Events> { | ||
| /** | ||
| * The global signature policy controls whether or not we sill send and receive | ||
| * signed or unsigned messages. | ||
| * | ||
| * Signed messages prevent spoofing message senders and should be preferred to | ||
| * using unsigned messages. | ||
| */ | ||
| globalSignaturePolicy: typeof StrictSign | typeof StrictNoSign | ||
| /** | ||
| * A list of multicodecs that contain the pubsub protocol name. | ||
| */ | ||
| multicodecs: string[] | ||
| /** | ||
| * Pubsub routers support message validators per topic, which will validate the message | ||
| * before its propagations. They are stored in a map where keys are the topic name and | ||
| * values are the validators. | ||
| * | ||
| * @example | ||
| * | ||
| * ```js | ||
| * const topic = 'topic' | ||
| * const validateMessage = (msgTopic, msg) => { | ||
| * const input = uint8ArrayToString(msg.data) | ||
| * const validInputs = ['a', 'b', 'c'] | ||
| * | ||
| * if (!validInputs.includes(input)) { | ||
| * throw new Error('no valid input received') | ||
| * } | ||
| * } | ||
| * libp2p.pubsub.topicValidators.set(topic, validateMessage) | ||
| * ``` | ||
| */ | ||
| topicValidators: Map<string, TopicValidatorFn> | ||
| getPeers: () => PeerId[] | ||
| /** | ||
| * Gets a list of topics the node is subscribed to. | ||
| * | ||
| * ```js | ||
| * const topics = libp2p.pubsub.getTopics() | ||
| * ``` | ||
| */ | ||
| getTopics: () => string[] | ||
| /** | ||
| * Subscribes to a pubsub topic. | ||
| * | ||
| * @example | ||
| * | ||
| * ```js | ||
| * const topic = 'topic' | ||
| * const handler = (msg) => { | ||
| * if (msg.topic === topic) { | ||
| * // msg.data - pubsub data received | ||
| * } | ||
| * } | ||
| * | ||
| * libp2p.pubsub.addEventListener('message', handler) | ||
| * libp2p.pubsub.subscribe(topic) | ||
| * ``` | ||
| */ | ||
| subscribe: (topic: string) => void | ||
| /** | ||
| * Unsubscribes from a pubsub topic. | ||
| * | ||
| * @example | ||
| * | ||
| * ```js | ||
| * const topic = 'topic' | ||
| * const handler = (msg) => { | ||
| * // msg.data - pubsub data received | ||
| * } | ||
| * | ||
| * libp2p.pubsub.removeEventListener(topic handler) | ||
| * libp2p.pubsub.unsubscribe(topic) | ||
| * ``` | ||
| */ | ||
| unsubscribe: (topic: string) => void | ||
| /** | ||
| * Gets a list of the PeerIds that are subscribed to one topic. | ||
| * | ||
| * @example | ||
| * | ||
| * ```js | ||
| * const peerIds = libp2p.pubsub.getSubscribers(topic) | ||
| * ``` | ||
| */ | ||
| getSubscribers: (topic: string) => PeerId[] | ||
| /** | ||
| * Publishes messages to the given topic. | ||
| * | ||
| * @example | ||
| * | ||
| * ```js | ||
| * const topic = 'topic' | ||
| * const data = uint8ArrayFromString('data') | ||
| * | ||
| * await libp2p.pubsub.publish(topic, data) | ||
| * ``` | ||
| */ | ||
| publish: (topic: string, data: Uint8Array) => Promise<PublishResult> | ||
| } | ||
| export interface PeerStreamEvents { | ||
| 'stream:inbound': CustomEvent<never> | ||
| 'stream:outbound': CustomEvent<never> | ||
| 'close': CustomEvent<never> | ||
| } |
@@ -1,2 +0,1 @@ | ||
| import type * as Status from './status.js'; | ||
| import type { AbortOptions } from '../index.js'; | ||
@@ -8,32 +7,20 @@ import type { PeerId } from '../peer-id/index.js'; | ||
| export interface ConnectionTimeline { | ||
| /** | ||
| * When the connection was opened | ||
| */ | ||
| open: number; | ||
| /** | ||
| * When the MultiaddrConnection was upgraded to a Connection - e.g. the type | ||
| * of connection encryption and multiplexing was negotiated. | ||
| */ | ||
| upgraded?: number; | ||
| /** | ||
| * When the connection was closed. | ||
| */ | ||
| close?: number; | ||
| } | ||
| /** | ||
| * Outbound conections are opened by the local node, inbound streams are opened by the remote | ||
| * Outbound connections are opened by the local node, inbound streams are opened by the remote | ||
| */ | ||
| export type Direction = 'inbound' | 'outbound'; | ||
| export interface ConnectionStat { | ||
| /** | ||
| * Outbound conections are opened by the local node, inbound streams are opened by the remote | ||
| */ | ||
| direction: Direction; | ||
| /** | ||
| * Lifecycle times for the connection | ||
| */ | ||
| timeline: ConnectionTimeline; | ||
| /** | ||
| * Once a multiplexer has been negotiated for this stream, it will be set on the stat object | ||
| */ | ||
| multiplexer?: string; | ||
| /** | ||
| * Once a connection encrypter has been negotiated for this stream, it will be set on the stat object | ||
| */ | ||
| encryption?: string; | ||
| /** | ||
| * The current status of the connection | ||
| */ | ||
| status: keyof typeof Status; | ||
| } | ||
| export interface StreamTimeline { | ||
@@ -60,18 +47,30 @@ /** | ||
| reset?: number; | ||
| } | ||
| export interface StreamStat { | ||
| /** | ||
| * Outbound streams are opened by the local node, inbound streams are opened by the remote | ||
| * A timestamp of when the stream was aborted | ||
| */ | ||
| direction: Direction; | ||
| /** | ||
| * Lifecycle times for the stream | ||
| */ | ||
| timeline: StreamTimeline; | ||
| /** | ||
| * Once a protocol has been negotiated for this stream, it will be set on the stat object | ||
| */ | ||
| protocol?: string; | ||
| abort?: number; | ||
| } | ||
| /** | ||
| * The states a stream can be in | ||
| */ | ||
| export type StreamStatus = 'open' | 'closing' | 'closed' | 'aborted' | 'reset'; | ||
| /** | ||
| * The states the readable end of a stream can be in | ||
| * | ||
| * ready - the readable end is ready for reading | ||
| * closing - the readable end is closing | ||
| * closed - the readable end has closed | ||
| */ | ||
| export type ReadStatus = 'ready' | 'closing' | 'closed'; | ||
| /** | ||
| * The states the writable end of a stream can be in | ||
| * | ||
| * ready - the writable end is ready for writing | ||
| * writing - the writable end is in the process of being written to | ||
| * done - the source passed to the `.sink` function yielded all values without error | ||
| * closing - the writable end is closing | ||
| * closed - the writable end has closed | ||
| */ | ||
| export type WriteStatus = 'ready' | 'writing' | 'done' | 'closing' | 'closed'; | ||
| /** | ||
| * A Stream is a data channel between two peers that | ||
@@ -93,3 +92,3 @@ * can be written to and read from at both ends. | ||
| */ | ||
| close: () => void; | ||
| close: (options?: AbortOptions) => Promise<void>; | ||
| /** | ||
@@ -102,3 +101,3 @@ * Closes the stream for **reading**. If iterating over the source of this stream in a `for await of` loop, it will return (exit the loop) after any buffered data has been consumed. | ||
| */ | ||
| closeRead: () => void; | ||
| closeRead: (options?: AbortOptions) => Promise<void>; | ||
| /** | ||
@@ -109,3 +108,3 @@ * Closes the stream for **writing**. If iterating over the source of this stream in a `for await of` loop, it will return (exit the loop) after any buffered data has been consumed. | ||
| */ | ||
| closeWrite: () => void; | ||
| closeWrite: (options?: AbortOptions) => Promise<void>; | ||
| /** | ||
@@ -122,10 +121,2 @@ * Closes the stream for **reading** *and* **writing**. This should be called when a *local error* has occurred. | ||
| /** | ||
| * Closes the stream *immediately* for **reading** *and* **writing**. This should be called when a *remote error* has occurred. | ||
| * | ||
| * This function is called automatically by the muxer when it receives a `RESET` message from the remote. | ||
| * | ||
| * The sink will return and the source will throw. | ||
| */ | ||
| reset: () => void; | ||
| /** | ||
| * Unique identifier for a stream. Identifiers are not unique across muxers. | ||
@@ -135,9 +126,29 @@ */ | ||
| /** | ||
| * Stats about this stream | ||
| * Outbound streams are opened by the local node, inbound streams are opened by the remote | ||
| */ | ||
| stat: StreamStat; | ||
| direction: Direction; | ||
| /** | ||
| * Lifecycle times for the stream | ||
| */ | ||
| timeline: StreamTimeline; | ||
| /** | ||
| * Once a protocol has been negotiated for this stream, it will be set on the stat object | ||
| */ | ||
| protocol?: string; | ||
| /** | ||
| * User defined stream metadata | ||
| */ | ||
| metadata: Record<string, any>; | ||
| /** | ||
| * The current status of the stream | ||
| */ | ||
| status: StreamStatus; | ||
| /** | ||
| * The current status of the readable end of the stream | ||
| */ | ||
| readStatus: ReadStatus; | ||
| /** | ||
| * The current status of the writable end of the stream | ||
| */ | ||
| writeStatus: WriteStatus; | ||
| } | ||
@@ -151,3 +162,9 @@ export interface NewStreamOptions extends AbortOptions { | ||
| maxOutboundStreams?: number; | ||
| /** | ||
| * Opt-in to running over a transient connection - one that has time/data limits | ||
| * placed on it. | ||
| */ | ||
| runOnTransientConnection?: boolean; | ||
| } | ||
| export type ConnectionStatus = 'open' | 'closing' | 'closed'; | ||
| /** | ||
@@ -160,12 +177,70 @@ * A Connection is a high-level representation of a connection | ||
| export interface Connection { | ||
| /** | ||
| * The unique identifier for this connection | ||
| */ | ||
| id: string; | ||
| stat: ConnectionStat; | ||
| /** | ||
| * The address of the remote end of the connection | ||
| */ | ||
| remoteAddr: Multiaddr; | ||
| /** | ||
| * The id of the peer at the remote end of the connection | ||
| */ | ||
| remotePeer: PeerId; | ||
| /** | ||
| * A list of tags applied to this connection | ||
| */ | ||
| tags: string[]; | ||
| /** | ||
| * A list of open streams on this connection | ||
| */ | ||
| streams: Stream[]; | ||
| newStream: (multicodecs: string | string[], options?: NewStreamOptions) => Promise<Stream>; | ||
| /** | ||
| * Outbound conections are opened by the local node, inbound streams are opened by the remote | ||
| */ | ||
| direction: Direction; | ||
| /** | ||
| * Lifecycle times for the connection | ||
| */ | ||
| timeline: ConnectionTimeline; | ||
| /** | ||
| * Once a multiplexer has been negotiated for this stream, it will be set on the stat object | ||
| */ | ||
| multiplexer?: string; | ||
| /** | ||
| * Once a connection encrypter has been negotiated for this stream, it will be set on the stat object | ||
| */ | ||
| encryption?: string; | ||
| /** | ||
| * The current status of the connection | ||
| */ | ||
| status: ConnectionStatus; | ||
| /** | ||
| * A transient connection is one that is not expected to be open for very long | ||
| * or one that cannot transfer very much data, such as one being used as a | ||
| * circuit relay connection. Protocols need to explicitly opt-in to being run | ||
| * over transient connections. | ||
| */ | ||
| transient: boolean; | ||
| /** | ||
| * Create a new stream on this connection and negotiate one of the passed protocols | ||
| */ | ||
| newStream: (protocols: string | string[], options?: NewStreamOptions) => Promise<Stream>; | ||
| /** | ||
| * Add a stream to this connection | ||
| */ | ||
| addStream: (stream: Stream) => void; | ||
| /** | ||
| * Remove a stream from this connection | ||
| */ | ||
| removeStream: (id: string) => void; | ||
| close: () => Promise<void>; | ||
| /** | ||
| * Gracefully close the connection. All queued data will be written to the | ||
| * underlying transport. | ||
| */ | ||
| close: (options?: AbortOptions) => Promise<void>; | ||
| /** | ||
| * Immediately close the connection, any queued data will be discarded | ||
| */ | ||
| abort: (err: Error) => void; | ||
| } | ||
@@ -183,4 +258,14 @@ export declare const symbol: unique symbol; | ||
| export interface MultiaddrConnectionTimeline { | ||
| /** | ||
| * When the connection was opened | ||
| */ | ||
| open: number; | ||
| /** | ||
| * When the MultiaddrConnection was upgraded to a Connection - the type of | ||
| * connection encryption and multiplexing was negotiated. | ||
| */ | ||
| upgraded?: number; | ||
| /** | ||
| * When the connection was closed. | ||
| */ | ||
| close?: number; | ||
@@ -194,6 +279,20 @@ } | ||
| export interface MultiaddrConnection extends Duplex<AsyncGenerator<Uint8Array>, Source<Uint8Array>, Promise<void>> { | ||
| close: (err?: Error) => Promise<void>; | ||
| /** | ||
| * Gracefully close the connection. All queued data will be written to the | ||
| * underlying transport. | ||
| */ | ||
| close: (options?: AbortOptions) => Promise<void>; | ||
| /** | ||
| * Immediately close the connection, any queued data will be discarded | ||
| */ | ||
| abort: (err: Error) => void; | ||
| /** | ||
| * The address of the remote end of the connection | ||
| */ | ||
| remoteAddr: Multiaddr; | ||
| /** | ||
| * When connection lifecycle events occurred | ||
| */ | ||
| timeline: MultiaddrConnectionTimeline; | ||
| } | ||
| //# sourceMappingURL=index.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/connection/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,MAAM,aAAa,CAAA;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,UAAU,CAAA;AAE9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WAAW,mBAAmB;IAClC;;;;OAIG;IACH,OAAO,EAAE,CAAC,UAAU,EAAE,mBAAmB,KAAK,OAAO,CAAC,mBAAmB,CAAC,CAAA;CAC3E;AAED,MAAM,WAAW,2BAA2B;IAC1C;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IAEZ;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IAEjB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAoB,SAAQ,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAChH;;;OAGG;IACH,KAAK,EAAE,CAAC,OAAO,CAAC,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAEhD;;OAEG;IACH,KAAK,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,IAAI,CAAA;IAE3B;;OAEG;IACH,UAAU,EAAE,SAAS,CAAA;IAErB;;OAEG;IACH,QAAQ,EAAE,2BAA2B,CAAA;CACtC"} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/connection/index.ts"],"names":[],"mappings":"AA6LA,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAA;AAEtD,MAAM,UAAU,YAAY,CAAE,KAAU;IACtC,OAAO,KAAK,IAAI,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;AAChD,CAAC"} | ||
| {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/connection/index.ts"],"names":[],"mappings":"AA0RA,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAA;AAEtD,MAAM,UAAU,YAAY,CAAE,KAAU;IACtC,OAAO,KAAK,IAAI,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;AAChD,CAAC"} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AACA;;;;GAIG;AACH,qBAAa,UAAW,SAAQ,KAAK;IACnC,SAAgB,IAAI,EAAE,MAAM,CAAA;IAC5B,SAAgB,IAAI,EAAE,MAAM,CAAA;gBAEf,OAAO,GAAE,MAAoC;IAM1D,MAAM,CAAC,QAAQ,CAAC,IAAI,eAAc;IAElC,MAAM,CAAC,QAAQ,CAAC,IAAI,aAAY;CACjC;AAED,qBAAa,SAAS,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAE,SAAQ,KAAK;aAKvE,IAAI,EAAE,MAAM;IAJ9B,SAAgB,KAAK,EAAE,CAAC,CAAA;gBAGtB,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,MAAM,EAC5B,KAAK,CAAC,EAAE,CAAC;CAOZ;AAED,qBAAa,mBAAoB,SAAQ,KAAK;IACrC,IAAI,EAAE,MAAM,CAAA;gBAEN,OAAO,SAAoB;IAKxC,MAAM,CAAC,QAAQ,CAAC,IAAI,yBAAwB;CAC7C;AAED,qBAAa,0BAA2B,SAAQ,KAAK;IAC5C,IAAI,EAAE,MAAM,CAAA;gBAEN,OAAO,SAA4B;IAKhD,MAAM,CAAC,QAAQ,CAAC,IAAI,iCAAgC;CACrD;AAED,qBAAa,8BAA+B,SAAQ,KAAK;IAChD,IAAI,EAAE,MAAM,CAAA;gBAEN,OAAO,SAAgC;IAKpD,MAAM,CAAC,QAAQ,CAAC,IAAI,qCAAoC;CACzD"} | ||
| {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,UAAW,SAAQ,KAAK;IACnC,SAAg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a,OAAO,GAAG,6BAA6B;QAClD,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,8BAA8B,CAAC,IAAI,CAAA;IACjD,CAAC;IAED,MAAM,CAAU,IAAI,GAAG,iCAAiC,CAAA"} |
@@ -16,3 +16,3 @@ /** | ||
| */ | ||
| import type { Connection, Stream } from './connection/index.js'; | ||
| import type { Connection, NewStreamOptions, Stream } from './connection/index.js'; | ||
| import type { ContentRouting } from './content-routing/index.js'; | ||
@@ -463,6 +463,10 @@ import type { EventEmitter } from './events.js'; | ||
| */ | ||
| dialProtocol: (peer: PeerId | Multiaddr | Multiaddr[], protocols: string | string[], options?: AbortOptions) => Promise<Stream>; | ||
| dialProtocol: (peer: PeerId | Multiaddr | Multiaddr[], protocols: string | string[], options?: NewStreamOptions) => Promise<Stream>; | ||
| /** | ||
| * Attempts to gracefully close an open connection to the given peer. If the connection is not closed in the grace period, it will be forcefully closed. | ||
| * Attempts to gracefully close an open connection to the given peer. If the | ||
| * connection is not closed in the grace period, it will be forcefully closed. | ||
| * | ||
| * An AbortSignal can optionally be passed to control when the connection is | ||
| * forcefully closed. | ||
| * | ||
| * @example | ||
@@ -474,3 +478,3 @@ * | ||
| */ | ||
| hangUp: (peer: PeerId | Multiaddr) => Promise<void>; | ||
| hangUp: (peer: PeerId | Multiaddr, options?: AbortOptions) => Promise<void>; | ||
| /** | ||
@@ -477,0 +481,0 @@ * Sets up [multistream-select routing](https://github.com/multiformats/multistream-select) of protocols to their application handlers. Whenever a stream is opened on one of the provided protocols, the handler will be called. `handle` must be called in order to register a handler and support for a given protocol. This also informs other peers of the protocols you support. |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAC/D,OAAO,KAAK,EAAE,cAA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CAAA;AAEpC,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,GAAG,OAAO,GAAG,GAAG,OAAO,SAAS,CAAA"} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/keys/index.ts"],"names":[],"mappings":"AAiCA,MAAM,CAAC,MAAM,OAAO,GAAG,SAAS,CAAA;AAChC,MAAM,CAAC,MAAM,GAAG,GAAG,KAAK,CAAA;AACxB,MAAM,CAAC,MAAM,SAAS,GAAG,WAAW,CAAA"} | ||
| {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/keys/index.ts"],"names":[],"mappings":"AAgCA,MAAM,CAAC,MAAM,OAAO,GAAG,SAAS,CAAA;AAChC,MAAM,CAAC,MAAM,GAAG,GAAG,KAAK,CAAA;AACxB,MAAM,CAAC,MAAM,SAAS,GAAG,WAAW,CAAA"} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"tags.d.ts","sourceRoot":"","sources":["../../../src/peer-store/tags.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,UAAU,eAAe,CAAA"} | ||
| {"version":3,"file":"tags.d.ts","sourceRoot":"","sources":["../../../src/peer-store/tags.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,eAAe,CAAA"} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"tags.js","sourceRoot":"","sources":["../../../src/peer-store/tags.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,UAAU,GAAG,YAAY,CAAA"} | ||
| {"version":3,"file":"tags.js","sourceRoot":"","sources":["../../../src/peer-store/tags.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG,YAAY,CAAA"} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"startable.d.ts","sourceRoot":"","sources":["../../src/startable.ts"],"names":[],"mappings":"AACA;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,MAAM,OAAO,CAAA;IAExB;;;;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,GAAG,CACf,UAAU,CAAC,GAAG,CAAC,KAAK,EAAC,CAAC,EAAC,EAAE;QACvB,IAAI,CAAC,CAAC,UAAU,IAAI,IAAI,EAAE;YACxB,MAAM,CAAC,CAAC,UAAU,EAAE,CAAA;SACrB;IACH,CAAC,CAAC,CACH,CAAA;IAED,MAAM,OAAO,CAAC,GAAG,CACf,UAAU,CAAC,GAAG,CAAC,KAAK,EAAC,CAAC,EAAC,EAAE;QACvB,MAAM,CAAC,CAAC,IAAI,EAAE,CAAA;IAChB,CAAC,CAAC,CACH,CAAA;IAED,MAAM,OAAO,CAAC,GAAG,CACf,UAAU,CAAC,GAAG,CAAC,KAAK,EAAC,CAAC,EAAC,EAAE;QACvB,IAAI,CAAC,CAAC,SAAS,IAAI,IAAI,EAAE;YACvB,MAAM,CAAC,CAAC,SAAS,EAAE,CAAA;SACpB;IACH,CAAC,CAAC,CACH,CAAA;AACH,CAAC"} |
@@ -18,2 +18,7 @@ import type { Connection, Stream } from '../connection/index.js'; | ||
| maxOutboundStreams?: number; | ||
| /** | ||
| * Opt-in to running over a transient connection - one that has time/data limits | ||
| * placed on it. | ||
| */ | ||
| runOnTransientConnection?: boolean; | ||
| } | ||
@@ -20,0 +25,0 @@ export interface StreamHandlerRecord { |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/stream-handler/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAEhE,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,UAAU,CAAA;CACvB;AAED,MAAM,WAAW,aAAa;IAC5B,CAAC,IAAI,EAAE,kBAAkB,GAAG,IAAI,CAAA;CACjC;AAED,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAE1B;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAC5B;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,aAAa,CAAA;IACtB,OAAO,EAAE,oBAAoB,CAAA;CAC9B"} | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/stream-handler/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAEhE,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,UAAU,CAAA;CACvB;AAED,MAAM,WAAW,aAAa;IAC5B,CAAC,IAAI,EAAE,kBAAkB,GAAG,IAAI,CAAA;CACjC;AAED,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAE1B;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAE3B;;;OAGG;IACH,wBAAwB,CAAC,EAAE,OAAO,CAAA;CACnC;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,aAAa,CAAA;IACtB,OAAO,EAAE,oBAAoB,CAAA;CAC9B"} |
@@ -35,5 +35,9 @@ import type { Direction, Stream } from '../connection/index.js'; | ||
| */ | ||
| close: (err?: Error) => void; | ||
| close: (options?: AbortOptions) => Promise<void>; | ||
| /** | ||
| * Close or abort all tracked streams and stop the muxer | ||
| */ | ||
| abort: (err: Error) => void; | ||
| } | ||
| export interface StreamMuxerInit extends AbortOptions { | ||
| export interface StreamMuxerInit { | ||
| /** | ||
@@ -40,0 +44,0 @@ * A callback function invoked every time an incoming stream is opened |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/stream-muxer/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AA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AE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;IAEhB;;OAEG;IACH,iBAAiB,EAAE,CAAC,IAAI,CAAC,EAAE,eAAe,KAAK,WAAW,CAAA;CAC3D;AAED;;GAEG;AACH,MAAM,WAAW,WAAY,SAAQ,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,cAAc,GAAG,UAAU,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACzH;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;IAEhB;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,CAAA;IAC1B;;;OAGG;IACH,SAAS,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IAEtD;;OAEG;IACH,KAAK,EAAE,CAAC,OAAO,CAAC,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAEhD;;OAEG;IACH,KAAK,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,IAAI,CAAA;CAC5B;AAED,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;IAE3C;;OAEG;IACH,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;IAEtC;;OAEG;IACH,SAAS,CAAC,EAAE,SAAS,CAAA;CACtB"} |
| import { Uint8ArrayList } from 'uint8arraylist'; | ||
| import type { Direction, Stream, StreamStat } from '../connection/index.js'; | ||
| import type { Direction, ReadStatus, Stream, StreamStatus, StreamTimeline, WriteStatus } from '../connection/index.js'; | ||
| import type { AbortOptions } from '../index.js'; | ||
| import type { Source } from 'it-stream-types'; | ||
| interface Logger { | ||
| (formatter: any, ...args: any[]): void; | ||
| error: (formatter: any, ...args: any[]) => void; | ||
| trace: (formatter: any, ...args: any[]) => void; | ||
| enabled: boolean; | ||
| } | ||
| export interface AbstractStreamInit { | ||
@@ -14,6 +21,5 @@ /** | ||
| /** | ||
| * The maximum allowable data size, any data larger than this will be | ||
| * chunked and sent in multiple data messages | ||
| * A Logger implementation used to log stream-specific information | ||
| */ | ||
| maxDataSize: number; | ||
| log: Logger; | ||
| /** | ||
@@ -27,28 +33,80 @@ * User specific stream metadata | ||
| onEnd?: (err?: Error | undefined) => void; | ||
| /** | ||
| * Invoked when the readable end of the stream is closed | ||
| */ | ||
| onCloseRead?: () => void; | ||
| /** | ||
| * Invoked when the writable end of the stream is closed | ||
| */ | ||
| onCloseWrite?: () => void; | ||
| /** | ||
| * Invoked when the the stream has been reset by the remote | ||
| */ | ||
| onReset?: () => void; | ||
| /** | ||
| * Invoked when the the stream has errored | ||
| */ | ||
| onAbort?: (err: Error) => void; | ||
| /** | ||
| * How long to wait in ms for stream data to be written to the underlying | ||
| * connection when closing the writable end of the stream. (default: 500) | ||
| */ | ||
| closeTimeout?: number; | ||
| } | ||
| export declare abstract class AbstractStream implements Stream { | ||
| id: string; | ||
| stat: StreamStat; | ||
| direction: Direction; | ||
| timeline: StreamTimeline; | ||
| protocol?: string; | ||
| metadata: Record<string, unknown>; | ||
| source: AsyncGenerator<Uint8ArrayList, void, unknown>; | ||
| private readonly abortController; | ||
| private readonly resetController; | ||
| private readonly closeController; | ||
| private sourceEnded; | ||
| private sinkEnded; | ||
| private sinkSunk; | ||
| status: StreamStatus; | ||
| readStatus: ReadStatus; | ||
| writeStatus: WriteStatus; | ||
| private readonly sinkController; | ||
| private readonly sinkEnd; | ||
| private endErr; | ||
| private readonly streamSource; | ||
| private readonly onEnd?; | ||
| private readonly maxDataSize; | ||
| private readonly onCloseRead?; | ||
| private readonly onCloseWrite?; | ||
| private readonly onReset?; | ||
| private readonly onAbort?; | ||
| protected readonly log: Logger; | ||
| constructor(init: AbstractStreamInit); | ||
| sink(source: Source<Uint8ArrayList | Uint8Array>): Promise<void>; | ||
| protected onSourceEnd(err?: Error): void; | ||
| protected onSinkEnd(err?: Error): void; | ||
| close(): void; | ||
| closeRead(): void; | ||
| closeWrite(): void; | ||
| close(options?: AbortOptions): Promise<void>; | ||
| closeRead(options?: AbortOptions): Promise<void>; | ||
| closeWrite(options?: AbortOptions): Promise<void>; | ||
| /** | ||
| * Close immediately for reading and writing and send a reset message (local | ||
| * error) | ||
| */ | ||
| abort(err: Error): void; | ||
| /** | ||
| * Receive a reset message - close immediately for reading and writing (remote | ||
| * error) | ||
| */ | ||
| reset(): void; | ||
| sink(source: Source<Uint8ArrayList | Uint8Array>): Promise<void>; | ||
| _closeSinkAndSource(err?: Error): void; | ||
| _closeSink(err?: Error): void; | ||
| _closeSource(err?: Error): void; | ||
| /** | ||
| * The remote closed for writing so we should expect to receive no more | ||
| * messages | ||
| */ | ||
| remoteCloseWrite(): void; | ||
| /** | ||
| * The remote closed for reading so we should not send any more | ||
| * messages | ||
| */ | ||
| remoteCloseRead(): void; | ||
| /** | ||
| * The underlying muxer has closed, no more messages can be sent or will | ||
| * be received, close immediately to free up resources | ||
| */ | ||
| destroy(): void; | ||
| /** | ||
| * When an extending class reads data from it's implementation-specific source, | ||
@@ -67,11 +125,11 @@ * call this method to allow the stream consumer to read the data. | ||
| */ | ||
| abstract sendNewStream(): void | Promise<void>; | ||
| abstract sendNewStream(options?: AbortOptions): void | Promise<void>; | ||
| /** | ||
| * Send a data message to the remote muxer | ||
| */ | ||
| abstract sendData(buf: Uint8ArrayList): void | Promise<void>; | ||
| abstract sendData(buf: Uint8ArrayList, options?: AbortOptions): void | Promise<void>; | ||
| /** | ||
| * Send a reset message to the remote muxer | ||
| */ | ||
| abstract sendReset(): void | Promise<void>; | ||
| abstract sendReset(options?: AbortOptions): void | Promise<void>; | ||
| /** | ||
@@ -81,3 +139,3 @@ * Send a message to the remote muxer, informing them no more data messages | ||
| */ | ||
| abstract sendCloseWrite(): void | Promise<void>; | ||
| abstract sendCloseWrite(options?: AbortOptions): void | Promise<void>; | ||
| /** | ||
@@ -87,4 +145,5 @@ * Send a message to the remote muxer, informing them no more data messages | ||
| */ | ||
| abstract sendCloseRead(): void | Promise<void>; | ||
| abstract sendCloseRead(options?: AbortOptions): void | Promise<void>; | ||
| } | ||
| export {}; | ||
| //# sourceMappingURL=stream.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../../src/stream-muxer/stream.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAE/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAC3E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAa7C,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,EAAE,EAAE,MAAM,CAAA;IAEV;;OAEG;IACH,SAAS,EAAE,SAAS,CAAA;IAEpB;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAA;IAEnB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAElC;;OAEG;IACH,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,GAAG,SAAS,KAAK,IAAI,CAAA;CAC1C;AAMD,8BAAsB,cAAe,YAAW,MAAM;IAC7C,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,UAAU,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACjC,MAAM,EAAE,cAAc,CAAC,cAAc,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;IAE5D,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAiB;IACjD,OAAO,CAAC,QAAQ,CAAC,eAAe,CA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Aa,CAAE,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;CACtE"} |
+223
-167
@@ -1,15 +0,8 @@ | ||
| // import { logger } from '@libp2p/logger' | ||
| import { abortableSource } from 'abortable-iterator'; | ||
| import { anySignal } from 'any-signal'; | ||
| import { pushable } from 'it-pushable'; | ||
| import defer, {} from 'p-defer'; | ||
| import { Uint8ArrayList } from 'uint8arraylist'; | ||
| import { CodeError } from '../errors.js'; | ||
| // const log = logger('libp2p:stream') | ||
| const log = () => { }; | ||
| log.trace = () => { }; | ||
| log.error = () => { }; | ||
| const ERR_STREAM_RESET = 'ERR_STREAM_RESET'; | ||
| const ERR_STREAM_ABORT = 'ERR_STREAM_ABORT'; | ||
| const ERR_SINK_ENDED = 'ERR_SINK_ENDED'; | ||
| const ERR_DOUBLE_SINK = 'ERR_DOUBLE_SINK'; | ||
| const ERR_SINK_INVALID_STATE = 'ERR_SINK_INVALID_STATE'; | ||
| function isPromise(res) { | ||
@@ -20,44 +13,49 @@ return res != null && typeof res.then === 'function'; | ||
| id; | ||
| stat; | ||
| direction; | ||
| timeline; | ||
| protocol; | ||
| metadata; | ||
| source; | ||
| abortController; | ||
| resetController; | ||
| closeController; | ||
| sourceEnded; | ||
| sinkEnded; | ||
| sinkSunk; | ||
| status; | ||
| readStatus; | ||
| writeStatus; | ||
| sinkController; | ||
| sinkEnd; | ||
| endErr; | ||
| streamSource; | ||
| onEnd; | ||
| maxDataSize; | ||
| onCloseRead; | ||
| onCloseWrite; | ||
| onReset; | ||
| onAbort; | ||
| log; | ||
| constructor(init) { | ||
| this.abortController = new AbortController(); | ||
| this.resetController = new AbortController(); | ||
| this.closeController = new AbortController(); | ||
| this.sourceEnded = false; | ||
| this.sinkEnded = false; | ||
| this.sinkSunk = false; | ||
| this.sinkController = new AbortController(); | ||
| this.sinkEnd = defer(); | ||
| this.log = init.log; | ||
| // stream status | ||
| this.status = 'open'; | ||
| this.readStatus = 'ready'; | ||
| this.writeStatus = 'ready'; | ||
| this.id = init.id; | ||
| this.metadata = init.metadata ?? {}; | ||
| this.stat = { | ||
| direction: init.direction, | ||
| timeline: { | ||
| open: Date.now() | ||
| } | ||
| this.direction = init.direction; | ||
| this.timeline = { | ||
| open: Date.now() | ||
| }; | ||
| this.maxDataSize = init.maxDataSize; | ||
| this.onEnd = init.onEnd; | ||
| this.onCloseRead = init?.onCloseRead; | ||
| this.onCloseWrite = init?.onCloseWrite; | ||
| this.onReset = init?.onReset; | ||
| this.onAbort = init?.onAbort; | ||
| this.source = this.streamSource = pushable({ | ||
| onEnd: () => { | ||
| // already sent a reset message | ||
| if (this.stat.timeline.reset !== null) { | ||
| const res = this.sendCloseRead(); | ||
| if (isPromise(res)) { | ||
| res.catch(err => { | ||
| log.error('error while sending close read', err); | ||
| }); | ||
| } | ||
| onEnd: (err) => { | ||
| if (err != null) { | ||
| this.log.trace('source ended with error', err); | ||
| } | ||
| this.onSourceEnd(); | ||
| else { | ||
| this.log.trace('source ended'); | ||
| } | ||
| this.readStatus = 'closed'; | ||
| this.onSourceEnd(err); | ||
| } | ||
@@ -68,14 +66,56 @@ }); | ||
| } | ||
| async sink(source) { | ||
| if (this.writeStatus !== 'ready') { | ||
| throw new CodeError(`writable end state is "${this.writeStatus}" not "ready"`, ERR_SINK_INVALID_STATE); | ||
| } | ||
| try { | ||
| this.writeStatus = 'writing'; | ||
| const options = { | ||
| signal: this.sinkController.signal | ||
| }; | ||
| if (this.direction === 'outbound') { // If initiator, open a new stream | ||
| const res = this.sendNewStream(options); | ||
| if (isPromise(res)) { | ||
| await res; | ||
| } | ||
| } | ||
| source = abortableSource(source, this.sinkController.signal, { | ||
| returnOnAbort: true | ||
| }); | ||
| this.log.trace('sink reading from source'); | ||
| for await (let data of source) { | ||
| data = data instanceof Uint8Array ? new Uint8ArrayList(data) : data; | ||
| const res = this.sendData(data, options); | ||
| if (isPromise(res)) { // eslint-disable-line max-depth | ||
| await res; | ||
| } | ||
| } | ||
| this.log.trace('sink finished reading from source'); | ||
| this.writeStatus = 'done'; | ||
| this.log.trace('sink calling closeWrite'); | ||
| await this.closeWrite(options); | ||
| this.onSinkEnd(); | ||
| } | ||
| catch (err) { | ||
| this.log.trace('sink ended with error, calling abort with error', err); | ||
| this.abort(err); | ||
| throw err; | ||
| } | ||
| finally { | ||
| this.log.trace('resolve sink end'); | ||
| this.sinkEnd.resolve(); | ||
| } | ||
| } | ||
| onSourceEnd(err) { | ||
| if (this.sourceEnded) { | ||
| if (this.timeline.closeRead != null) { | ||
| return; | ||
| } | ||
| this.stat.timeline.closeRead = Date.now(); | ||
| this.sourceEnded = true; | ||
| log.trace('%s stream %s source end - err: %o', this.stat.direction, this.id, err); | ||
| this.timeline.closeRead = Date.now(); | ||
| if (err != null && this.endErr == null) { | ||
| this.endErr = err; | ||
| } | ||
| if (this.sinkEnded) { | ||
| this.stat.timeline.close = Date.now(); | ||
| this.onCloseRead?.(); | ||
| if (this.timeline.closeWrite != null) { | ||
| this.log.trace('source and sink ended'); | ||
| this.timeline.close = Date.now(); | ||
| if (this.onEnd != null) { | ||
@@ -85,15 +125,18 @@ this.onEnd(this.endErr); | ||
| } | ||
| else { | ||
| this.log.trace('source ended, waiting for sink to end'); | ||
| } | ||
| } | ||
| onSinkEnd(err) { | ||
| if (this.sinkEnded) { | ||
| if (this.timeline.closeWrite != null) { | ||
| return; | ||
| } | ||
| this.stat.timeline.closeWrite = Date.now(); | ||
| this.sinkEnded = true; | ||
| log.trace('%s stream %s sink end - err: %o', this.stat.direction, this.id, err); | ||
| this.timeline.closeWrite = Date.now(); | ||
| if (err != null && this.endErr == null) { | ||
| this.endErr = err; | ||
| } | ||
| if (this.sourceEnded) { | ||
| this.stat.timeline.close = Date.now(); | ||
| this.onCloseWrite?.(); | ||
| if (this.timeline.closeRead != null) { | ||
| this.log.trace('sink and source ended'); | ||
| this.timeline.close = Date.now(); | ||
| if (this.onEnd != null) { | ||
@@ -103,141 +146,154 @@ this.onEnd(this.endErr); | ||
| } | ||
| else { | ||
| this.log.trace('sink ended, waiting for source to end'); | ||
| } | ||
| } | ||
| // Close for both Reading and Writing | ||
| close() { | ||
| log.trace('%s stream %s close', this.stat.direction, this.id); | ||
| this.closeRead(); | ||
| this.closeWrite(); | ||
| async close(options) { | ||
| this.log.trace('closing gracefully'); | ||
| this.status = 'closing'; | ||
| await Promise.all([ | ||
| this.closeRead(options), | ||
| this.closeWrite(options) | ||
| ]); | ||
| this.status = 'closed'; | ||
| this.log.trace('closed gracefully'); | ||
| } | ||
| // Close for reading | ||
| closeRead() { | ||
| log.trace('%s stream %s closeRead', this.stat.direction, this.id); | ||
| if (this.sourceEnded) { | ||
| async closeRead(options = {}) { | ||
| if (this.readStatus === 'closing' || this.readStatus === 'closed') { | ||
| return; | ||
| } | ||
| this.streamSource.end(); | ||
| this.log.trace('closing readable end of stream with starting read status "%s"', this.readStatus); | ||
| const readStatus = this.readStatus; | ||
| this.readStatus = 'closing'; | ||
| if (readStatus === 'ready') { | ||
| this.log.trace('ending internal source queue'); | ||
| this.streamSource.end(); | ||
| } | ||
| if (this.status !== 'reset' && this.status !== 'aborted') { | ||
| this.log.trace('send close read to remote'); | ||
| await this.sendCloseRead(options); | ||
| } | ||
| this.log.trace('closed readable end of stream'); | ||
| } | ||
| // Close for writing | ||
| closeWrite() { | ||
| log.trace('%s stream %s closeWrite', this.stat.direction, this.id); | ||
| if (this.sinkEnded) { | ||
| async closeWrite(options = {}) { | ||
| if (this.writeStatus === 'closing' || this.writeStatus === 'closed') { | ||
| return; | ||
| } | ||
| this.closeController.abort(); | ||
| try { | ||
| // need to call this here as the sink method returns in the catch block | ||
| // when the close controller is aborted | ||
| const res = this.sendCloseWrite(); | ||
| if (isPromise(res)) { | ||
| res.catch(err => { | ||
| log.error('error while sending close write', err); | ||
| this.log.trace('closing writable end of stream with starting write status "%s"', this.writeStatus); | ||
| const writeStatus = this.writeStatus; | ||
| if (this.writeStatus === 'ready') { | ||
| this.log.trace('sink was never sunk, sink an empty array'); | ||
| await this.sink([]); | ||
| } | ||
| this.writeStatus = 'closing'; | ||
| if (writeStatus === 'writing') { | ||
| // stop reading from the source passed to `.sink` in the microtask queue | ||
| // - this lets any data queued by the user in the current tick get read | ||
| // before we exit | ||
| await new Promise((resolve, reject) => { | ||
| queueMicrotask(() => { | ||
| this.log.trace('aborting source passed to .sink'); | ||
| this.sinkController.abort(); | ||
| this.sinkEnd.promise.then(resolve, reject); | ||
| }); | ||
| } | ||
| }); | ||
| } | ||
| catch (err) { | ||
| log.trace('%s stream %s error sending close', this.stat.direction, this.id, err); | ||
| if (this.status !== 'reset' && this.status !== 'aborted') { | ||
| this.log.trace('send close write to remote'); | ||
| await this.sendCloseWrite(options); | ||
| } | ||
| this.onSinkEnd(); | ||
| this.writeStatus = 'closed'; | ||
| this.log.trace('closed writable end of stream'); | ||
| } | ||
| // Close for reading and writing (local error) | ||
| /** | ||
| * Close immediately for reading and writing and send a reset message (local | ||
| * error) | ||
| */ | ||
| abort(err) { | ||
| log.trace('%s stream %s abort', this.stat.direction, this.id, err); | ||
| // End the source with the passed error | ||
| this.streamSource.end(err); | ||
| this.abortController.abort(); | ||
| this.onSinkEnd(err); | ||
| if (this.status === 'closed' || this.status === 'aborted' || this.status === 'reset') { | ||
| return; | ||
| } | ||
| this.log('abort with error', err); | ||
| // try to send a reset message | ||
| this.log('try to send reset to remote'); | ||
| const res = this.sendReset(); | ||
| if (isPromise(res)) { | ||
| res.catch((err) => { | ||
| this.log.error('error sending reset message', err); | ||
| }); | ||
| } | ||
| this.status = 'aborted'; | ||
| this.timeline.abort = Date.now(); | ||
| this._closeSinkAndSource(err); | ||
| this.onAbort?.(err); | ||
| } | ||
| // Close immediately for reading and writing (remote error) | ||
| /** | ||
| * Receive a reset message - close immediately for reading and writing (remote | ||
| * error) | ||
| */ | ||
| reset() { | ||
| if (this.status === 'closed' || this.status === 'aborted' || this.status === 'reset') { | ||
| return; | ||
| } | ||
| const err = new CodeError('stream reset', ERR_STREAM_RESET); | ||
| this.resetController.abort(); | ||
| this.streamSource.end(err); | ||
| this.status = 'reset'; | ||
| this._closeSinkAndSource(err); | ||
| this.onReset?.(); | ||
| } | ||
| _closeSinkAndSource(err) { | ||
| this._closeSink(err); | ||
| this._closeSource(err); | ||
| } | ||
| _closeSink(err) { | ||
| // if the sink function is running, cause it to end | ||
| if (this.writeStatus === 'writing') { | ||
| this.log.trace('end sink source'); | ||
| this.sinkController.abort(); | ||
| } | ||
| this.onSinkEnd(err); | ||
| } | ||
| async sink(source) { | ||
| if (this.sinkSunk) { | ||
| throw new CodeError('sink already called on stream', ERR_DOUBLE_SINK); | ||
| } | ||
| this.sinkSunk = true; | ||
| if (this.sinkEnded) { | ||
| throw new CodeError('stream closed for writing', ERR_SINK_ENDED); | ||
| } | ||
| const signal = anySignal([ | ||
| this.abortController.signal, | ||
| this.resetController.signal, | ||
| this.closeController.signal | ||
| ]); | ||
| try { | ||
| source = abortableSource(source, signal); | ||
| if (this.stat.direction === 'outbound') { // If initiator, open a new stream | ||
| const res = this.sendNewStream(); | ||
| if (isPromise(res)) { | ||
| await res; | ||
| } | ||
| } | ||
| for await (let data of source) { | ||
| while (data.length > 0) { | ||
| if (data.length <= this.maxDataSize) { | ||
| const res = this.sendData(data instanceof Uint8Array ? new Uint8ArrayList(data) : data); | ||
| if (isPromise(res)) { // eslint-disable-line max-depth | ||
| await res; | ||
| } | ||
| break; | ||
| } | ||
| data = data instanceof Uint8Array ? new Uint8ArrayList(data) : data; | ||
| const res = this.sendData(data.sublist(0, this.maxDataSize)); | ||
| if (isPromise(res)) { | ||
| await res; | ||
| } | ||
| data.consume(this.maxDataSize); | ||
| } | ||
| } | ||
| } | ||
| catch (err) { | ||
| if (err.type === 'aborted' && err.message === 'The operation was aborted') { | ||
| if (this.closeController.signal.aborted) { | ||
| return; | ||
| } | ||
| if (this.resetController.signal.aborted) { | ||
| err.message = 'stream reset'; | ||
| err.code = ERR_STREAM_RESET; | ||
| } | ||
| if (this.abortController.signal.aborted) { | ||
| err.message = 'stream aborted'; | ||
| err.code = ERR_STREAM_ABORT; | ||
| } | ||
| } | ||
| // Send no more data if this stream was remotely reset | ||
| if (err.code === ERR_STREAM_RESET) { | ||
| log.trace('%s stream %s reset', this.stat.direction, this.id); | ||
| } | ||
| else { | ||
| log.trace('%s stream %s error', this.stat.direction, this.id, err); | ||
| try { | ||
| const res = this.sendReset(); | ||
| if (isPromise(res)) { | ||
| await res; | ||
| } | ||
| this.stat.timeline.reset = Date.now(); | ||
| } | ||
| catch (err) { | ||
| log.trace('%s stream %s error sending reset', this.stat.direction, this.id, err); | ||
| } | ||
| } | ||
| _closeSource(err) { | ||
| // if the source is not ending, end it | ||
| if (this.readStatus !== 'closing' && this.readStatus !== 'closed') { | ||
| this.log.trace('ending source with %d bytes to be read by consumer', this.streamSource.readableLength); | ||
| this.readStatus = 'closing'; | ||
| this.streamSource.end(err); | ||
| this.onSinkEnd(err); | ||
| throw err; | ||
| } | ||
| finally { | ||
| signal.clear(); | ||
| } | ||
| /** | ||
| * The remote closed for writing so we should expect to receive no more | ||
| * messages | ||
| */ | ||
| remoteCloseWrite() { | ||
| if (this.readStatus === 'closing' || this.readStatus === 'closed') { | ||
| this.log('received remote close write but local source is already closed'); | ||
| return; | ||
| } | ||
| try { | ||
| const res = this.sendCloseWrite(); | ||
| if (isPromise(res)) { | ||
| await res; | ||
| } | ||
| this.log.trace('remote close write'); | ||
| this._closeSource(); | ||
| } | ||
| /** | ||
| * The remote closed for reading so we should not send any more | ||
| * messages | ||
| */ | ||
| remoteCloseRead() { | ||
| if (this.writeStatus === 'closing' || this.writeStatus === 'closed') { | ||
| this.log('received remote close read but local sink is already closed'); | ||
| return; | ||
| } | ||
| catch (err) { | ||
| log.trace('%s stream %s error sending close', this.stat.direction, this.id, err); | ||
| this.log.trace('remote close read'); | ||
| this._closeSink(); | ||
| } | ||
| /** | ||
| * The underlying muxer has closed, no more messages can be sent or will | ||
| * be received, close immediately to free up resources | ||
| */ | ||
| destroy() { | ||
| if (this.status === 'closed' || this.status === 'aborted' || this.status === 'reset') { | ||
| this.log('received destroy but we are already closed'); | ||
| return; | ||
| } | ||
| this.onSinkEnd(); | ||
| this.log.trace('muxer destroyed'); | ||
| this._closeSinkAndSource(); | ||
| } | ||
@@ -244,0 +300,0 @@ /** |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"stream.js","sourceRoot":"","sources":["../../../src/stream-muxer/stream.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,EAAiB,QAAQ,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAIxC,sCAAsC;AAEtC,MAAM,GAAG,GAAQ,GAAG,EAAE,GAAE,CAAC,CAAA;AACzB,GAAG,CAAC,KAAK,GAAG,GAAG,EAAE,GAAE,CAAC,CAAA;AACpB,GAAG,CAAC,KAAK,GAAG,GAAG,EAAE,GAAE,CAAC,CAAA;AAEpB,MAAM,gBAAgB,GAAG,kBAAkB,CAAA;AAC3C,MAAM,gBAAgB,GAAG,kBAAkB,CAAA;AAC3C,MAAM,cAAc,GAAG,gBAAgB,CAAA;AACvC,MAAM,eAAe,GAAG,iBAAiB,CAAA;AA8BzC,SAAS,SAAS,CAAE,GAAS;IAC3B,OAAO,GAAG,IAAI,IAAI,IAAI,OAAO,GAAG,CAAC,IAAI,KAAK,UAAU,CAAA;AACtD,CAAC;AAED,MAAM,OAAgB,cAAc;IAC3B,EAAE,CAAQ;IACV,IAAI,CAAY;IAChB,QAAQ,CAAyB;IACjC,MAAM,CAA+C;IAE3C,eAAe,CAAiB;IAChC,eAAe,CAAiB;IAChC,eAAe,CAAiB;IACzC,WAAW,CAAS;IACpB,SAAS,CAAS;IAClB,QAAQ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AI,IAAI,CAAC,MAAM,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,IAAI,IAAI,CAAC,MAAM,KAAK,OAAO,EAAE;YACpF,IAAI,CAAC,GAAG,CAAC,4CAA4C,CAAC,CAAA;YACtD,OAAM;SACP;QAED,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAA;QAEjC,IAAI,CAAC,mBAAmB,EAAE,CAAA;IAC5B,CAAC;IAED;;;OAGG;IACH,UAAU,CAAE,IAAoB;QAC9B,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC9B,CAAC;IAED;;;OAGG;IACH,oBAAoB;QAClB,OAAO,IAAI,CAAC,YAAY,CAAC,cAAc,CAAA;IACzC,CAAC;CA6BF"} |
@@ -85,2 +85,7 @@ import type { Connection, MultiaddrConnection } from '../connection/index.js'; | ||
| muxerFactory?: StreamMuxerFactory; | ||
| /** | ||
| * The passed MultiaddrConnection has limits place on duration and/or data | ||
| * transfer amounts so is not expected to be open for very long. | ||
| */ | ||
| transient?: boolean; | ||
| } | ||
@@ -87,0 +92,0 @@ export interface Upgrader { |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transport/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAC7E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAExD,MAAM,WAAW,cAAc;IAC7B,YAAY,EAAE,WAAW,CAAC,UAAU,CAAC,CAAA;IACrC,WAAW,EAAE,WAAW,CAAA;IACxB,OAAO,E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O,CAAA;CACpB;AAED,MAAM,WAAW,QAAQ;IACvB;;OAEG;IACH,eAAe,EAAE,CAAC,MAAM,EAAE,mBAAmB,EAAE,IAAI,CAAC,EAAE,eAAe,KAAK,OAAO,CAAC,UAAU,CAAC,CAAA;IAE7F;;OAEG;IACH,cAAc,EAAE,CAAC,MAAM,EAAE,mBAAmB,EAAE,IAAI,CAAC,EAAE,eAAe,KAAK,OAAO,CAAC,UAAU,CAAC,CAAA;CAC7F"} |
+8
-11
| { | ||
| "name": "@libp2p/interface", | ||
| "version": "0.0.1", | ||
| "version": "0.1.0", | ||
| "description": "The interface implemented by a libp2p node", | ||
@@ -59,6 +59,2 @@ "license": "Apache-2.0 OR MIT", | ||
| }, | ||
| "./connection/status": { | ||
| "types": "./dist/src/connection/status.d.ts", | ||
| "import": "./dist/src/connection/status.js" | ||
| }, | ||
| "./content-routing": { | ||
@@ -116,2 +112,6 @@ "types": "./dist/src/content-routing/index.d.ts", | ||
| }, | ||
| "./pubsub": { | ||
| "types": "./dist/src/pubsub/index.d.ts", | ||
| "import": "./dist/src/pubsub/index.js" | ||
| }, | ||
| "./record": { | ||
@@ -164,6 +164,6 @@ "types": "./dist/src/record/index.d.ts", | ||
| "abortable-iterator": "^5.0.1", | ||
| "any-signal": "^4.1.1", | ||
| "it-pushable": "^3.1.3", | ||
| "it-pushable": "^3.2.0", | ||
| "it-stream-types": "^2.0.1", | ||
| "multiformats": "^12.0.1", | ||
| "p-defer": "^4.0.0", | ||
| "uint8arraylist": "^2.4.3" | ||
@@ -173,9 +173,6 @@ }, | ||
| "@types/sinon": "^10.0.15", | ||
| "aegir": "^39.0.10", | ||
| "aegir": "^40.0.1", | ||
| "sinon": "^15.1.2", | ||
| "sinon-ts": "^1.0.0" | ||
| }, | ||
| "typedoc": { | ||
| "entryPoint": "./src/index.ts" | ||
| } | ||
| } |
+180
-59
@@ -1,2 +0,1 @@ | ||
| import type * as Status from './status.js' | ||
| import type { AbortOptions } from '../index.js' | ||
@@ -9,39 +8,24 @@ import type { PeerId } from '../peer-id/index.js' | ||
| export interface ConnectionTimeline { | ||
| open: number | ||
| upgraded?: number | ||
| close?: number | ||
| } | ||
| /** | ||
| * Outbound conections are opened by the local node, inbound streams are opened by the remote | ||
| */ | ||
| export type Direction = 'inbound' | 'outbound' | ||
| export interface ConnectionStat { | ||
| /** | ||
| * Outbound conections are opened by the local node, inbound streams are opened by the remote | ||
| * When the connection was opened | ||
| */ | ||
| direction: Direction | ||
| open: number | ||
| /** | ||
| * Lifecycle times for the connection | ||
| * When the MultiaddrConnection was upgraded to a Connection - e.g. the type | ||
| * of connection encryption and multiplexing was negotiated. | ||
| */ | ||
| timeline: ConnectionTimeline | ||
| upgraded?: number | ||
| /** | ||
| * Once a multiplexer has been negotiated for this stream, it will be set on the stat object | ||
| * When the connection was closed. | ||
| */ | ||
| multiplexer?: string | ||
| close?: number | ||
| } | ||
| /** | ||
| * Once a connection encrypter has been negotiated for this stream, it will be set on the stat object | ||
| */ | ||
| encryption?: string | ||
| /** | ||
| * Outbound connections are opened by the local node, inbound streams are opened by the remote | ||
| */ | ||
| export type Direction = 'inbound' | 'outbound' | ||
| /** | ||
| * The current status of the connection | ||
| */ | ||
| status: keyof typeof Status | ||
| } | ||
| export interface StreamTimeline { | ||
@@ -72,22 +56,35 @@ /** | ||
| reset?: number | ||
| } | ||
| export interface StreamStat { | ||
| /** | ||
| * Outbound streams are opened by the local node, inbound streams are opened by the remote | ||
| * A timestamp of when the stream was aborted | ||
| */ | ||
| direction: Direction | ||
| abort?: number | ||
| } | ||
| /** | ||
| * Lifecycle times for the stream | ||
| */ | ||
| timeline: StreamTimeline | ||
| /** | ||
| * The states a stream can be in | ||
| */ | ||
| export type StreamStatus = 'open' | 'closing' | 'closed' | 'aborted' | 'reset' | ||
| /** | ||
| * Once a protocol has been negotiated for this stream, it will be set on the stat object | ||
| */ | ||
| protocol?: string | ||
| } | ||
| /** | ||
| * The states the readable end of a stream can be in | ||
| * | ||
| * ready - the readable end is ready for reading | ||
| * closing - the readable end is closing | ||
| * closed - the readable end has closed | ||
| */ | ||
| export type ReadStatus = 'ready' | 'closing' | 'closed' | ||
| /** | ||
| * The states the writable end of a stream can be in | ||
| * | ||
| * ready - the writable end is ready for writing | ||
| * writing - the writable end is in the process of being written to | ||
| * done - the source passed to the `.sink` function yielded all values without error | ||
| * closing - the writable end is closing | ||
| * closed - the writable end has closed | ||
| */ | ||
| export type WriteStatus = 'ready' | 'writing' | 'done' | 'closing' | 'closed' | ||
| /** | ||
| * A Stream is a data channel between two peers that | ||
@@ -109,3 +106,3 @@ * can be written to and read from at both ends. | ||
| */ | ||
| close: () => void | ||
| close: (options?: AbortOptions) => Promise<void> | ||
@@ -119,3 +116,3 @@ /** | ||
| */ | ||
| closeRead: () => void | ||
| closeRead: (options?: AbortOptions) => Promise<void> | ||
@@ -127,3 +124,3 @@ /** | ||
| */ | ||
| closeWrite: () => void | ||
| closeWrite: (options?: AbortOptions) => Promise<void> | ||
@@ -142,24 +139,40 @@ /** | ||
| /** | ||
| * Closes the stream *immediately* for **reading** *and* **writing**. This should be called when a *remote error* has occurred. | ||
| * | ||
| * This function is called automatically by the muxer when it receives a `RESET` message from the remote. | ||
| * | ||
| * The sink will return and the source will throw. | ||
| * Unique identifier for a stream. Identifiers are not unique across muxers. | ||
| */ | ||
| reset: () => void | ||
| id: string | ||
| /** | ||
| * Unique identifier for a stream. Identifiers are not unique across muxers. | ||
| * Outbound streams are opened by the local node, inbound streams are opened by the remote | ||
| */ | ||
| id: string | ||
| direction: Direction | ||
| /** | ||
| * Stats about this stream | ||
| * Lifecycle times for the stream | ||
| */ | ||
| stat: StreamStat | ||
| timeline: StreamTimeline | ||
| /** | ||
| * Once a protocol has been negotiated for this stream, it will be set on the stat object | ||
| */ | ||
| protocol?: string | ||
| /** | ||
| * User defined stream metadata | ||
| */ | ||
| metadata: Record<string, any> | ||
| /** | ||
| * The current status of the stream | ||
| */ | ||
| status: StreamStatus | ||
| /** | ||
| * The current status of the readable end of the stream | ||
| */ | ||
| readStatus: ReadStatus | ||
| /** | ||
| * The current status of the writable end of the stream | ||
| */ | ||
| writeStatus: WriteStatus | ||
| } | ||
@@ -174,4 +187,12 @@ | ||
| maxOutboundStreams?: number | ||
| /** | ||
| * Opt-in to running over a transient connection - one that has time/data limits | ||
| * placed on it. | ||
| */ | ||
| runOnTransientConnection?: boolean | ||
| } | ||
| export type ConnectionStatus = 'open' | 'closing' | 'closed' | ||
| /** | ||
@@ -184,13 +205,85 @@ * A Connection is a high-level representation of a connection | ||
| export interface Connection { | ||
| /** | ||
| * The unique identifier for this connection | ||
| */ | ||
| id: string | ||
| stat: ConnectionStat | ||
| /** | ||
| * The address of the remote end of the connection | ||
| */ | ||
| remoteAddr: Multiaddr | ||
| /** | ||
| * The id of the peer at the remote end of the connection | ||
| */ | ||
| remotePeer: PeerId | ||
| /** | ||
| * A list of tags applied to this connection | ||
| */ | ||
| tags: string[] | ||
| /** | ||
| * A list of open streams on this connection | ||
| */ | ||
| streams: Stream[] | ||
| newStream: (multicodecs: string | string[], options?: NewStreamOptions) => Promise<Stream> | ||
| /** | ||
| * Outbound conections are opened by the local node, inbound streams are opened by the remote | ||
| */ | ||
| direction: Direction | ||
| /** | ||
| * Lifecycle times for the connection | ||
| */ | ||
| timeline: ConnectionTimeline | ||
| /** | ||
| * Once a multiplexer has been negotiated for this stream, it will be set on the stat object | ||
| */ | ||
| multiplexer?: string | ||
| /** | ||
| * Once a connection encrypter has been negotiated for this stream, it will be set on the stat object | ||
| */ | ||
| encryption?: string | ||
| /** | ||
| * The current status of the connection | ||
| */ | ||
| status: ConnectionStatus | ||
| /** | ||
| * A transient connection is one that is not expected to be open for very long | ||
| * or one that cannot transfer very much data, such as one being used as a | ||
| * circuit relay connection. Protocols need to explicitly opt-in to being run | ||
| * over transient connections. | ||
| */ | ||
| transient: boolean | ||
| /** | ||
| * Create a new stream on this connection and negotiate one of the passed protocols | ||
| */ | ||
| newStream: (protocols: string | string[], options?: NewStreamOptions) => Promise<Stream> | ||
| /** | ||
| * Add a stream to this connection | ||
| */ | ||
| addStream: (stream: Stream) => void | ||
| /** | ||
| * Remove a stream from this connection | ||
| */ | ||
| removeStream: (id: string) => void | ||
| close: () => Promise<void> | ||
| /** | ||
| * Gracefully close the connection. All queued data will be written to the | ||
| * underlying transport. | ||
| */ | ||
| close: (options?: AbortOptions) => Promise<void> | ||
| /** | ||
| * Immediately close the connection, any queued data will be discarded | ||
| */ | ||
| abort: (err: Error) => void | ||
| } | ||
@@ -205,3 +298,2 @@ | ||
| export interface ConnectionProtector { | ||
| /** | ||
@@ -216,4 +308,16 @@ * Takes a given Connection and creates a private encryption stream | ||
| export interface MultiaddrConnectionTimeline { | ||
| /** | ||
| * When the connection was opened | ||
| */ | ||
| open: number | ||
| /** | ||
| * When the MultiaddrConnection was upgraded to a Connection - the type of | ||
| * connection encryption and multiplexing was negotiated. | ||
| */ | ||
| upgraded?: number | ||
| /** | ||
| * When the connection was closed. | ||
| */ | ||
| close?: number | ||
@@ -228,5 +332,22 @@ } | ||
| export interface MultiaddrConnection extends Duplex<AsyncGenerator<Uint8Array>, Source<Uint8Array>, Promise<void>> { | ||
| close: (err?: Error) => Promise<void> | ||
| /** | ||
| * Gracefully close the connection. All queued data will be written to the | ||
| * underlying transport. | ||
| */ | ||
| close: (options?: AbortOptions) => Promise<void> | ||
| /** | ||
| * Immediately close the connection, any queued data will be discarded | ||
| */ | ||
| abort: (err: Error) => void | ||
| /** | ||
| * The address of the remote end of the connection | ||
| */ | ||
| remoteAddr: Multiaddr | ||
| /** | ||
| * When connection lifecycle events occurred | ||
| */ | ||
| timeline: MultiaddrConnectionTimeline | ||
| } |
+0
-1
@@ -1,2 +0,1 @@ | ||
| /** | ||
@@ -3,0 +2,0 @@ * When this error is thrown it means an operation was aborted, |
+8
-4
@@ -17,3 +17,3 @@ /** | ||
| import type { Connection, Stream } from './connection/index.js' | ||
| import type { Connection, NewStreamOptions, Stream } from './connection/index.js' | ||
| import type { ContentRouting } from './content-routing/index.js' | ||
@@ -507,7 +507,11 @@ import type { EventEmitter } from './events.js' | ||
| */ | ||
| dialProtocol: (peer: PeerId | Multiaddr | Multiaddr[], protocols: string | string[], options?: AbortOptions) => Promise<Stream> | ||
| dialProtocol: (peer: PeerId | Multiaddr | Multiaddr[], protocols: string | string[], options?: NewStreamOptions) => Promise<Stream> | ||
| /** | ||
| * Attempts to gracefully close an open connection to the given peer. If the connection is not closed in the grace period, it will be forcefully closed. | ||
| * Attempts to gracefully close an open connection to the given peer. If the | ||
| * connection is not closed in the grace period, it will be forcefully closed. | ||
| * | ||
| * An AbortSignal can optionally be passed to control when the connection is | ||
| * forcefully closed. | ||
| * | ||
| * @example | ||
@@ -519,3 +523,3 @@ * | ||
| */ | ||
| hangUp: (peer: PeerId | Multiaddr) => Promise<void> | ||
| hangUp: (peer: PeerId | Multiaddr, options?: AbortOptions) => Promise<void> | ||
@@ -522,0 +526,0 @@ /** |
@@ -1,2 +0,1 @@ | ||
| export interface PublicKey { | ||
@@ -3,0 +2,0 @@ readonly bytes: Uint8Array |
@@ -1,2 +0,1 @@ | ||
| export const KEEP_ALIVE = 'keep-alive' |
+0
-1
@@ -1,2 +0,1 @@ | ||
| /** | ||
@@ -3,0 +2,0 @@ * Implemented by components that have a lifecycle |
@@ -22,2 +22,8 @@ import type { Connection, Stream } from '../connection/index.js' | ||
| maxOutboundStreams?: number | ||
| /** | ||
| * Opt-in to running over a transient connection - one that has time/data limits | ||
| * placed on it. | ||
| */ | ||
| runOnTransientConnection?: boolean | ||
| } | ||
@@ -24,0 +30,0 @@ |
@@ -40,6 +40,11 @@ import type { Direction, Stream } from '../connection/index.js' | ||
| */ | ||
| close: (err?: Error) => void | ||
| close: (options?: AbortOptions) => Promise<void> | ||
| /** | ||
| * Close or abort all tracked streams and stop the muxer | ||
| */ | ||
| abort: (err: Error) => void | ||
| } | ||
| export interface StreamMuxerInit extends AbortOptions { | ||
| export interface StreamMuxerInit { | ||
| /** | ||
@@ -46,0 +51,0 @@ * A callback function invoked every time an incoming stream is opened |
+293
-184
@@ -1,20 +0,19 @@ | ||
| // import { logger } from '@libp2p/logger' | ||
| import { abortableSource } from 'abortable-iterator' | ||
| import { anySignal } from 'any-signal' | ||
| import { type Pushable, pushable } from 'it-pushable' | ||
| import defer, { type DeferredPromise } from 'p-defer' | ||
| import { Uint8ArrayList } from 'uint8arraylist' | ||
| import { CodeError } from '../errors.js' | ||
| import type { Direction, Stream, StreamStat } from '../connection/index.js' | ||
| import type { Direction, ReadStatus, Stream, StreamStatus, StreamTimeline, WriteStatus } from '../connection/index.js' | ||
| import type { AbortOptions } from '../index.js' | ||
| import type { Source } from 'it-stream-types' | ||
| // const log = logger('libp2p:stream') | ||
| interface Logger { | ||
| (formatter: any, ...args: any[]): void | ||
| error: (formatter: any, ...args: any[]) => void | ||
| trace: (formatter: any, ...args: any[]) => void | ||
| enabled: boolean | ||
| } | ||
| const log: any = () => {} | ||
| log.trace = () => {} | ||
| log.error = () => {} | ||
| const ERR_STREAM_RESET = 'ERR_STREAM_RESET' | ||
| const ERR_STREAM_ABORT = 'ERR_STREAM_ABORT' | ||
| const ERR_SINK_ENDED = 'ERR_SINK_ENDED' | ||
| const ERR_DOUBLE_SINK = 'ERR_DOUBLE_SINK' | ||
| const ERR_SINK_INVALID_STATE = 'ERR_SINK_INVALID_STATE' | ||
@@ -33,6 +32,5 @@ export interface AbstractStreamInit { | ||
| /** | ||
| * The maximum allowable data size, any data larger than this will be | ||
| * chunked and sent in multiple data messages | ||
| * A Logger implementation used to log stream-specific information | ||
| */ | ||
| maxDataSize: number | ||
| log: Logger | ||
@@ -48,2 +46,28 @@ /** | ||
| onEnd?: (err?: Error | undefined) => void | ||
| /** | ||
| * Invoked when the readable end of the stream is closed | ||
| */ | ||
| onCloseRead?: () => void | ||
| /** | ||
| * Invoked when the writable end of the stream is closed | ||
| */ | ||
| onCloseWrite?: () => void | ||
| /** | ||
| * Invoked when the the stream has been reset by the remote | ||
| */ | ||
| onReset?: () => void | ||
| /** | ||
| * Invoked when the the stream has errored | ||
| */ | ||
| onAbort?: (err: Error) => void | ||
| /** | ||
| * How long to wait in ms for stream data to be written to the underlying | ||
| * connection when closing the writable end of the stream. (default: 500) | ||
| */ | ||
| closeTimeout?: number | ||
| } | ||
@@ -57,50 +81,56 @@ | ||
| public id: string | ||
| public stat: StreamStat | ||
| public direction: Direction | ||
| public timeline: StreamTimeline | ||
| public protocol?: string | ||
| public metadata: Record<string, unknown> | ||
| public source: AsyncGenerator<Uint8ArrayList, void, unknown> | ||
| public status: StreamStatus | ||
| public readStatus: ReadStatus | ||
| public writeStatus: WriteStatus | ||
| private readonly abortController: AbortController | ||
| private readonly resetController: AbortController | ||
| private readonly closeController: AbortController | ||
| private sourceEnded: boolean | ||
| private sinkEnded: boolean | ||
| private sinkSunk: boolean | ||
| private readonly sinkController: AbortController | ||
| private readonly sinkEnd: DeferredPromise<void> | ||
| private endErr: Error | undefined | ||
| private readonly streamSource: Pushable<Uint8ArrayList> | ||
| private readonly onEnd?: (err?: Error | undefined) => void | ||
| private readonly maxDataSize: number | ||
| private readonly onCloseRead?: () => void | ||
| private readonly onCloseWrite?: () => void | ||
| private readonly onReset?: () => void | ||
| private readonly onAbort?: (err: Error) => void | ||
| protected readonly log: Logger | ||
| constructor (init: AbstractStreamInit) { | ||
| this.abortController = new AbortController() | ||
| this.resetController = new AbortController() | ||
| this.closeController = new AbortController() | ||
| this.sourceEnded = false | ||
| this.sinkEnded = false | ||
| this.sinkSunk = false | ||
| this.sinkController = new AbortController() | ||
| this.sinkEnd = defer() | ||
| this.log = init.log | ||
| // stream status | ||
| this.status = 'open' | ||
| this.readStatus = 'ready' | ||
| this.writeStatus = 'ready' | ||
| this.id = init.id | ||
| this.metadata = init.metadata ?? {} | ||
| this.stat = { | ||
| direction: init.direction, | ||
| timeline: { | ||
| open: Date.now() | ||
| } | ||
| this.direction = init.direction | ||
| this.timeline = { | ||
| open: Date.now() | ||
| } | ||
| this.maxDataSize = init.maxDataSize | ||
| this.onEnd = init.onEnd | ||
| this.onCloseRead = init?.onCloseRead | ||
| this.onCloseWrite = init?.onCloseWrite | ||
| this.onReset = init?.onReset | ||
| this.onAbort = init?.onAbort | ||
| this.source = this.streamSource = pushable<Uint8ArrayList>({ | ||
| onEnd: () => { | ||
| // already sent a reset message | ||
| if (this.stat.timeline.reset !== null) { | ||
| const res = this.sendCloseRead() | ||
| if (isPromise(res)) { | ||
| res.catch(err => { | ||
| log.error('error while sending close read', err) | ||
| }) | ||
| } | ||
| onEnd: (err) => { | ||
| if (err != null) { | ||
| this.log.trace('source ended with error', err) | ||
| } else { | ||
| this.log.trace('source ended') | ||
| } | ||
| this.onSourceEnd() | ||
| this.readStatus = 'closed' | ||
| this.onSourceEnd(err) | ||
| } | ||
@@ -113,10 +143,61 @@ }) | ||
| async sink (source: Source<Uint8ArrayList | Uint8Array>): Promise<void> { | ||
| if (this.writeStatus !== 'ready') { | ||
| throw new CodeError(`writable end state is "${this.writeStatus}" not "ready"`, ERR_SINK_INVALID_STATE) | ||
| } | ||
| try { | ||
| this.writeStatus = 'writing' | ||
| const options: AbortOptions = { | ||
| signal: this.sinkController.signal | ||
| } | ||
| if (this.direction === 'outbound') { // If initiator, open a new stream | ||
| const res = this.sendNewStream(options) | ||
| if (isPromise(res)) { | ||
| await res | ||
| } | ||
| } | ||
| source = abortableSource(source, this.sinkController.signal, { | ||
| returnOnAbort: true | ||
| }) | ||
| this.log.trace('sink reading from source') | ||
| for await (let data of source) { | ||
| data = data instanceof Uint8Array ? new Uint8ArrayList(data) : data | ||
| const res = this.sendData(data, options) | ||
| if (isPromise(res)) { // eslint-disable-line max-depth | ||
| await res | ||
| } | ||
| } | ||
| this.log.trace('sink finished reading from source') | ||
| this.writeStatus = 'done' | ||
| this.log.trace('sink calling closeWrite') | ||
| await this.closeWrite(options) | ||
| this.onSinkEnd() | ||
| } catch (err: any) { | ||
| this.log.trace('sink ended with error, calling abort with error', err) | ||
| this.abort(err) | ||
| throw err | ||
| } finally { | ||
| this.log.trace('resolve sink end') | ||
| this.sinkEnd.resolve() | ||
| } | ||
| } | ||
| protected onSourceEnd (err?: Error): void { | ||
| if (this.sourceEnded) { | ||
| if (this.timeline.closeRead != null) { | ||
| return | ||
| } | ||
| this.stat.timeline.closeRead = Date.now() | ||
| this.sourceEnded = true | ||
| log.trace('%s stream %s source end - err: %o', this.stat.direction, this.id, err) | ||
| this.timeline.closeRead = Date.now() | ||
@@ -127,8 +208,13 @@ if (err != null && this.endErr == null) { | ||
| if (this.sinkEnded) { | ||
| this.stat.timeline.close = Date.now() | ||
| this.onCloseRead?.() | ||
| if (this.timeline.closeWrite != null) { | ||
| this.log.trace('source and sink ended') | ||
| this.timeline.close = Date.now() | ||
| if (this.onEnd != null) { | ||
| this.onEnd(this.endErr) | ||
| } | ||
| } else { | ||
| this.log.trace('source ended, waiting for sink to end') | ||
| } | ||
@@ -138,9 +224,7 @@ } | ||
| protected onSinkEnd (err?: Error): void { | ||
| if (this.sinkEnded) { | ||
| if (this.timeline.closeWrite != null) { | ||
| return | ||
| } | ||
| this.stat.timeline.closeWrite = Date.now() | ||
| this.sinkEnded = true | ||
| log.trace('%s stream %s sink end - err: %o', this.stat.direction, this.id, err) | ||
| this.timeline.closeWrite = Date.now() | ||
@@ -151,8 +235,13 @@ if (err != null && this.endErr == null) { | ||
| if (this.sourceEnded) { | ||
| this.stat.timeline.close = Date.now() | ||
| this.onCloseWrite?.() | ||
| if (this.timeline.closeRead != null) { | ||
| this.log.trace('sink and source ended') | ||
| this.timeline.close = Date.now() | ||
| if (this.onEnd != null) { | ||
| this.onEnd(this.endErr) | ||
| } | ||
| } else { | ||
| this.log.trace('sink ended, waiting for source to end') | ||
| } | ||
@@ -162,170 +251,190 @@ } | ||
| // Close for both Reading and Writing | ||
| close (): void { | ||
| log.trace('%s stream %s close', this.stat.direction, this.id) | ||
| async close (options?: AbortOptions): Promise<void> { | ||
| this.log.trace('closing gracefully') | ||
| this.closeRead() | ||
| this.closeWrite() | ||
| } | ||
| this.status = 'closing' | ||
| // Close for reading | ||
| closeRead (): void { | ||
| log.trace('%s stream %s closeRead', this.stat.direction, this.id) | ||
| await Promise.all([ | ||
| this.closeRead(options), | ||
| this.closeWrite(options) | ||
| ]) | ||
| if (this.sourceEnded) { | ||
| return | ||
| } | ||
| this.status = 'closed' | ||
| this.streamSource.end() | ||
| this.log.trace('closed gracefully') | ||
| } | ||
| // Close for writing | ||
| closeWrite (): void { | ||
| log.trace('%s stream %s closeWrite', this.stat.direction, this.id) | ||
| if (this.sinkEnded) { | ||
| async closeRead (options: AbortOptions = {}): Promise<void> { | ||
| if (this.readStatus === 'closing' || this.readStatus === 'closed') { | ||
| return | ||
| } | ||
| this.closeController.abort() | ||
| this.log.trace('closing readable end of stream with starting read status "%s"', this.readStatus) | ||
| try { | ||
| // need to call this here as the sink method returns in the catch block | ||
| // when the close controller is aborted | ||
| const res = this.sendCloseWrite() | ||
| const readStatus = this.readStatus | ||
| this.readStatus = 'closing' | ||
| if (isPromise(res)) { | ||
| res.catch(err => { | ||
| log.error('error while sending close write', err) | ||
| }) | ||
| } | ||
| } catch (err) { | ||
| log.trace('%s stream %s error sending close', this.stat.direction, this.id, err) | ||
| if (readStatus === 'ready') { | ||
| this.log.trace('ending internal source queue') | ||
| this.streamSource.end() | ||
| } | ||
| this.onSinkEnd() | ||
| } | ||
| if (this.status !== 'reset' && this.status !== 'aborted') { | ||
| this.log.trace('send close read to remote') | ||
| await this.sendCloseRead(options) | ||
| } | ||
| // Close for reading and writing (local error) | ||
| abort (err: Error): void { | ||
| log.trace('%s stream %s abort', this.stat.direction, this.id, err) | ||
| // End the source with the passed error | ||
| this.streamSource.end(err) | ||
| this.abortController.abort() | ||
| this.onSinkEnd(err) | ||
| this.log.trace('closed readable end of stream') | ||
| } | ||
| // Close immediately for reading and writing (remote error) | ||
| reset (): void { | ||
| const err = new CodeError('stream reset', ERR_STREAM_RESET) | ||
| this.resetController.abort() | ||
| this.streamSource.end(err) | ||
| this.onSinkEnd(err) | ||
| } | ||
| async closeWrite (options: AbortOptions = {}): Promise<void> { | ||
| if (this.writeStatus === 'closing' || this.writeStatus === 'closed') { | ||
| return | ||
| } | ||
| async sink (source: Source<Uint8ArrayList | Uint8Array>): Promise<void> { | ||
| if (this.sinkSunk) { | ||
| throw new CodeError('sink already called on stream', ERR_DOUBLE_SINK) | ||
| this.log.trace('closing writable end of stream with starting write status "%s"', this.writeStatus) | ||
| const writeStatus = this.writeStatus | ||
| if (this.writeStatus === 'ready') { | ||
| this.log.trace('sink was never sunk, sink an empty array') | ||
| await this.sink([]) | ||
| } | ||
| this.sinkSunk = true | ||
| this.writeStatus = 'closing' | ||
| if (this.sinkEnded) { | ||
| throw new CodeError('stream closed for writing', ERR_SINK_ENDED) | ||
| if (writeStatus === 'writing') { | ||
| // stop reading from the source passed to `.sink` in the microtask queue | ||
| // - this lets any data queued by the user in the current tick get read | ||
| // before we exit | ||
| await new Promise((resolve, reject) => { | ||
| queueMicrotask(() => { | ||
| this.log.trace('aborting source passed to .sink') | ||
| this.sinkController.abort() | ||
| this.sinkEnd.promise.then(resolve, reject) | ||
| }) | ||
| }) | ||
| } | ||
| const signal = anySignal([ | ||
| this.abortController.signal, | ||
| this.resetController.signal, | ||
| this.closeController.signal | ||
| ]) | ||
| if (this.status !== 'reset' && this.status !== 'aborted') { | ||
| this.log.trace('send close write to remote') | ||
| await this.sendCloseWrite(options) | ||
| } | ||
| try { | ||
| source = abortableSource(source, signal) | ||
| this.writeStatus = 'closed' | ||
| if (this.stat.direction === 'outbound') { // If initiator, open a new stream | ||
| const res = this.sendNewStream() | ||
| this.log.trace('closed writable end of stream') | ||
| } | ||
| if (isPromise(res)) { | ||
| await res | ||
| } | ||
| } | ||
| /** | ||
| * Close immediately for reading and writing and send a reset message (local | ||
| * error) | ||
| */ | ||
| abort (err: Error): void { | ||
| if (this.status === 'closed' || this.status === 'aborted' || this.status === 'reset') { | ||
| return | ||
| } | ||
| for await (let data of source) { | ||
| while (data.length > 0) { | ||
| if (data.length <= this.maxDataSize) { | ||
| const res = this.sendData(data instanceof Uint8Array ? new Uint8ArrayList(data) : data) | ||
| this.log('abort with error', err) | ||
| if (isPromise(res)) { // eslint-disable-line max-depth | ||
| await res | ||
| } | ||
| // try to send a reset message | ||
| this.log('try to send reset to remote') | ||
| const res = this.sendReset() | ||
| break | ||
| } | ||
| data = data instanceof Uint8Array ? new Uint8ArrayList(data) : data | ||
| const res = this.sendData(data.sublist(0, this.maxDataSize)) | ||
| if (isPromise(res)) { | ||
| res.catch((err) => { | ||
| this.log.error('error sending reset message', err) | ||
| }) | ||
| } | ||
| if (isPromise(res)) { | ||
| await res | ||
| } | ||
| this.status = 'aborted' | ||
| this.timeline.abort = Date.now() | ||
| this._closeSinkAndSource(err) | ||
| this.onAbort?.(err) | ||
| } | ||
| data.consume(this.maxDataSize) | ||
| } | ||
| } | ||
| } catch (err: any) { | ||
| if (err.type === 'aborted' && err.message === 'The operation was aborted') { | ||
| if (this.closeController.signal.aborted) { | ||
| return | ||
| } | ||
| /** | ||
| * Receive a reset message - close immediately for reading and writing (remote | ||
| * error) | ||
| */ | ||
| reset (): void { | ||
| if (this.status === 'closed' || this.status === 'aborted' || this.status === 'reset') { | ||
| return | ||
| } | ||
| if (this.resetController.signal.aborted) { | ||
| err.message = 'stream reset' | ||
| err.code = ERR_STREAM_RESET | ||
| } | ||
| const err = new CodeError('stream reset', ERR_STREAM_RESET) | ||
| if (this.abortController.signal.aborted) { | ||
| err.message = 'stream aborted' | ||
| err.code = ERR_STREAM_ABORT | ||
| } | ||
| } | ||
| this.status = 'reset' | ||
| this._closeSinkAndSource(err) | ||
| this.onReset?.() | ||
| } | ||
| // Send no more data if this stream was remotely reset | ||
| if (err.code === ERR_STREAM_RESET) { | ||
| log.trace('%s stream %s reset', this.stat.direction, this.id) | ||
| } else { | ||
| log.trace('%s stream %s error', this.stat.direction, this.id, err) | ||
| try { | ||
| const res = this.sendReset() | ||
| _closeSinkAndSource (err?: Error): void { | ||
| this._closeSink(err) | ||
| this._closeSource(err) | ||
| } | ||
| if (isPromise(res)) { | ||
| await res | ||
| } | ||
| _closeSink (err?: Error): void { | ||
| // if the sink function is running, cause it to end | ||
| if (this.writeStatus === 'writing') { | ||
| this.log.trace('end sink source') | ||
| this.sinkController.abort() | ||
| } | ||
| this.stat.timeline.reset = Date.now() | ||
| } catch (err) { | ||
| log.trace('%s stream %s error sending reset', this.stat.direction, this.id, err) | ||
| } | ||
| } | ||
| this.onSinkEnd(err) | ||
| } | ||
| _closeSource (err?: Error): void { | ||
| // if the source is not ending, end it | ||
| if (this.readStatus !== 'closing' && this.readStatus !== 'closed') { | ||
| this.log.trace('ending source with %d bytes to be read by consumer', this.streamSource.readableLength) | ||
| this.readStatus = 'closing' | ||
| this.streamSource.end(err) | ||
| this.onSinkEnd(err) | ||
| } | ||
| } | ||
| throw err | ||
| } finally { | ||
| signal.clear() | ||
| /** | ||
| * The remote closed for writing so we should expect to receive no more | ||
| * messages | ||
| */ | ||
| remoteCloseWrite (): void { | ||
| if (this.readStatus === 'closing' || this.readStatus === 'closed') { | ||
| this.log('received remote close write but local source is already closed') | ||
| return | ||
| } | ||
| try { | ||
| const res = this.sendCloseWrite() | ||
| this.log.trace('remote close write') | ||
| this._closeSource() | ||
| } | ||
| if (isPromise(res)) { | ||
| await res | ||
| } | ||
| } catch (err) { | ||
| log.trace('%s stream %s error sending close', this.stat.direction, this.id, err) | ||
| /** | ||
| * The remote closed for reading so we should not send any more | ||
| * messages | ||
| */ | ||
| remoteCloseRead (): void { | ||
| if (this.writeStatus === 'closing' || this.writeStatus === 'closed') { | ||
| this.log('received remote close read but local sink is already closed') | ||
| return | ||
| } | ||
| this.onSinkEnd() | ||
| this.log.trace('remote close read') | ||
| this._closeSink() | ||
| } | ||
| /** | ||
| * The underlying muxer has closed, no more messages can be sent or will | ||
| * be received, close immediately to free up resources | ||
| */ | ||
| destroy (): void { | ||
| if (this.status === 'closed' || this.status === 'aborted' || this.status === 'reset') { | ||
| this.log('received destroy but we are already closed') | ||
| return | ||
| } | ||
| this.log.trace('muxer destroyed') | ||
| this._closeSinkAndSource() | ||
| } | ||
| /** | ||
| * When an extending class reads data from it's implementation-specific source, | ||
@@ -350,3 +459,3 @@ * call this method to allow the stream consumer to read the data. | ||
| */ | ||
| abstract sendNewStream (): void | Promise<void> | ||
| abstract sendNewStream (options?: AbortOptions): void | Promise<void> | ||
@@ -356,3 +465,3 @@ /** | ||
| */ | ||
| abstract sendData (buf: Uint8ArrayList): void | Promise<void> | ||
| abstract sendData (buf: Uint8ArrayList, options?: AbortOptions): void | Promise<void> | ||
@@ -362,3 +471,3 @@ /** | ||
| */ | ||
| abstract sendReset (): void | Promise<void> | ||
| abstract sendReset (options?: AbortOptions): void | Promise<void> | ||
@@ -369,3 +478,3 @@ /** | ||
| */ | ||
| abstract sendCloseWrite (): void | Promise<void> | ||
| abstract sendCloseWrite (options?: AbortOptions): void | Promise<void> | ||
@@ -376,3 +485,3 @@ /** | ||
| */ | ||
| abstract sendCloseRead (): void | Promise<void> | ||
| abstract sendCloseRead (options?: AbortOptions): void | Promise<void> | ||
| } |
@@ -99,2 +99,8 @@ import type { Connection, MultiaddrConnection } from '../connection/index.js' | ||
| muxerFactory?: StreamMuxerFactory | ||
| /** | ||
| * The passed MultiaddrConnection has limits place on duration and/or data | ||
| * transfer amounts so is not expected to be open for very long. | ||
| */ | ||
| transient?: boolean | ||
| } | ||
@@ -101,0 +107,0 @@ |
| export declare const OPEN = "OPEN"; | ||
| export declare const CLOSING = "CLOSING"; | ||
| export declare const CLOSED = "CLOSED"; | ||
| //# sourceMappingURL=status.d.ts.map |
| {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../src/connection/status.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,IAAI,SAAS,CAAA;AAC1B,eAAO,MAAM,OAAO,YAAY,CAAA;AAChC,eAAO,MAAM,MAAM,WAAW,CAAA"} |
| export const OPEN = 'OPEN'; | ||
| export const CLOSING = 'CLOSING'; | ||
| export const CLOSED = 'CLOSED'; | ||
| //# sourceMappingURL=status.js.map |
| {"version":3,"file":"status.js","sourceRoot":"","sources":["../../../src/connection/status.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,IAAI,GAAG,MAAM,CAAA;AAC1B,MAAM,CAAC,MAAM,OAAO,GAAG,SAAS,CAAA;AAChC,MAAM,CAAC,MAAM,MAAM,GAAG,QAAQ,CAAA"} |
| export const OPEN = 'OPEN' | ||
| export const CLOSING = 'CLOSING' | ||
| export const CLOSED = 'CLOSED' |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
253972
16.75%6107
17.92%+ Added
- Removed
- Removed
Updated