@libp2p/multistream-select 6.0.29 → 7.0.0-049bfa0fa

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- import type { MultistreamSelectInit, ProtocolStream } from './index.js';
2
- import type { Duplex } from 'it-stream-types';
1
+ import type { MultistreamSelectInit } from './index.js';
2
+ import type { MultiaddrConnection, MessageStream } from '@libp2p/interface';
3
3
  /**
4
4
  * Handle multistream protocol selections for the given list of protocols.
5
5
  *
@@ -46,5 +46,5 @@ import type { Duplex } from 'it-stream-types';
46
46
  * })
47
47
  * ```
48
48
  */
49
- export declare function handle<Stream extends Duplex<any, any, any>>(stream: Stream, protocols: string | string[], options: MultistreamSelectInit): Promise<ProtocolStream<Stream>>;
49
+ export declare function handle<Stream extends MessageStream = MultiaddrConnection>(stream: Stream, protocols: string | string[], options?: MultistreamSelectInit): Promise<string>;
50
50
  //# sourceMappingURL=handle.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"handle.d.ts","sourceRoot":"","sources":["../../src/handle.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AACvE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAE7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,wBAAsB,MAAM,CAAE,MAAM,SAAS,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAG,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CA+ClL"}
1
+ {"version":3,"file":"handle.d.ts","sourceRoot":"","sources":["../../src/handle.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AACvD,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAE3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,wBAAsB,MAAM,CAAE,MAAM,SAAS,aAAa,GAAG,mBAAmB,EAAG,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,OAAO,GAAE,qBAA0B,GAAG,OAAO,CAAC,MAAM,CAAC,CAkDrL"}
@@ -1,9 +1,9 @@
1
+ import { lpStream } from '@libp2p/utils';
1
2
  import { encode } from 'it-length-prefixed';
2
- import { lpStream } from 'it-length-prefixed-stream';
3
3
  import { Uint8ArrayList } from 'uint8arraylist';
4
4
  import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string';
5
5
  import { MAX_PROTOCOL_LENGTH, PROTOCOL_ID } from './constants.js';
6
- import * as multistream from './multistream.js';
6
+ import { readString } from './multistream.js';
7
7
  /**
8
8
  * Handle multistream protocol selections for the given list of protocols.
9
9
  *
@@ -50,41 +50,42 @@ import * as multistream from './multistream.js';
50
50
  * })
51
51
  * ```
52
52
  */
53
- export async function handle(stream, protocols, options) {
53
+ export async function handle(stream, protocols, options = {}) {
54
54
  protocols = Array.isArray(protocols) ? protocols : [protocols];
55
- options.log.trace('handle: available protocols %s', protocols);
55
+ const log = stream.log.newScope('mss:handle');
56
56
  const lp = lpStream(stream, {
57
57
  ...options,
58
58
  maxDataLength: MAX_PROTOCOL_LENGTH,
59
59
  maxLengthLength: 2 // 2 bytes is enough to length-prefix MAX_PROTOCOL_LENGTH
60
60
  });
61
61
  while (true) {
62
- options.log.trace('handle: reading incoming string');
63
- const protocol = await multistream.readString(lp, options);
64
- options.log.trace('handle: read "%s"', protocol);
62
+ log.trace('reading incoming string');
63
+ const protocol = await readString(lp, options);
64
+ log.trace('read "%s"', protocol);
65
65
  if (protocol === PROTOCOL_ID) {
66
- options.log.trace('handle: respond with "%s" for "%s"', PROTOCOL_ID, protocol);
67
- await multistream.write(lp, uint8ArrayFromString(`${PROTOCOL_ID}\n`), options);
68
- options.log.trace('handle: responded with "%s" for "%s"', PROTOCOL_ID, protocol);
66
+ log.trace('respond with "%s" for "%s"', PROTOCOL_ID, protocol);
67
+ await lp.write(uint8ArrayFromString(`${PROTOCOL_ID}\n`), options);
68
+ log.trace('responded with "%s" for "%s"', PROTOCOL_ID, protocol);
69
69
  continue;
70
70
  }
71
71
  if (protocols.includes(protocol)) {
72
- options.log.trace('handle: respond with "%s" for "%s"', protocol, protocol);
73
- await multistream.write(lp, uint8ArrayFromString(`${protocol}\n`), options);
74
- options.log.trace('handle: responded with "%s" for "%s"', protocol, protocol);
75
- return { stream: lp.unwrap(), protocol };
72
+ log.trace('respond with "%s" for "%s"', protocol, protocol);
73
+ await lp.write(uint8ArrayFromString(`${protocol}\n`), options);
74
+ log.trace('responded with "%s" for "%s"', protocol, protocol);
75
+ lp.unwrap();
76
+ return protocol;
76
77
  }
77
78
  if (protocol === 'ls') {
78
79
  // <varint-msg-len><varint-proto-name-len><proto-name>\n<varint-proto-name-len><proto-name>\n\n
79
80
  const protos = new Uint8ArrayList(...protocols.map(p => encode.single(uint8ArrayFromString(`${p}\n`))), uint8ArrayFromString('\n'));
80
- options.log.trace('handle: respond with "%s" for %s', protocols, protocol);
81
- await multistream.write(lp, protos, options);
82
- options.log.trace('handle: responded with "%s" for %s', protocols, protocol);
81
+ log.trace('respond with "%s" for %s', protocols, protocol);
82
+ await lp.write(protos, options);
83
+ log.trace('responded with "%s" for %s', protocols, protocol);
83
84
  continue;
84
85
  }
85
- options.log.trace('handle: respond with "na" for "%s"', protocol);
86
- await multistream.write(lp, uint8ArrayFromString('na\n'), options);
87
- options.log('handle: responded with "na" for "%s"', protocol);
86
+ log.trace('respond with "na" for "%s"', protocol);
87
+ await lp.write(uint8ArrayFromString('na\n'), options);
88
+ log('responded with "na" for "%s"', protocol);
88
89
  }
89
90
  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,CAAC,KAAK,CAAC,0BAA0B,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAA;YAC1D,MAAM,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;YAC/B,GAAG,CAAC,KAAK,CAAC,4BAA4B,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAA;YAC5D,SAAQ;QACV,CAAC;QAED,GAAG,CAAC,KAAK,CAAC,4BAA4B,EAAE,QAAQ,CAAC,CAAA;QACjD,MAAM,EAAE,CAAC,KAAK,CAAC,oBAAoB,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,CAAA;QACrD,GAAG,CAAC,8BAA8B,EAAE,QAAQ,CAAC,CAAA;IAC/C,CAAC;AACH,CAAC"}
@@ -20,14 +20,10 @@
20
20
  * ```
21
21
  */
22
22
  import { PROTOCOL_ID } from './constants.js';
23
- import type { AbortOptions, LoggerOptions } from '@libp2p/interface';
24
- import type { LengthPrefixedStreamOpts } from 'it-length-prefixed-stream';
23
+ import type { AbortOptions } from '@libp2p/interface';
24
+ import type { LengthPrefixedStreamOpts } from '@libp2p/utils';
25
25
  export { PROTOCOL_ID };
26
- export interface ProtocolStream<Stream> {
27
- stream: Stream;
28
- protocol: string;
29
- }
30
- export interface MultistreamSelectInit extends AbortOptions, LoggerOptions, Partial<LengthPrefixedStreamOpts> {
26
+ export interface MultistreamSelectInit extends AbortOptions, Partial<LengthPrefixedStreamOpts> {
31
27
  /**
32
28
  * When false, and only a single protocol is being negotiated, use optimistic
33
29
  * select to send both the protocol name and the first data buffer in the
@@ -38,6 +34,5 @@ export interface MultistreamSelectInit extends AbortOptions, LoggerOptions, Part
38
34
  negotiateFully?: boolean;
39
35
  }
40
36
  export { select } from './select.js';
41
- export type { SelectStream } from './select.js';
42
37
  export { handle } from './handle.js';
43
38
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACpE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAA;AAEzE,OAAO,EAAE,WAAW,EAAE,CAAA;AAEtB,MAAM,WAAW,cAAc,CAAC,MAAM;IACpC,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,qBAAsB,SAAQ,YAAY,EAAE,aAAa,EAAE,OAAO,CAAC,wBAAwB,CAAC;IAC3G;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;CACzB;AAED,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAA;AAE7D,OAAO,EAAE,WAAW,EAAE,CAAA;AAEtB,MAAM,WAAW,qBAAsB,SAAQ,YAAY,EAAE,OAAO,CAAC,wBAAwB,CAAC;IAC5F;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;CACzB;AAED,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAI5C,OAAO,EAAE,WAAW,EAAE,CAAA;AAkBtB,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAI5C,OAAO,EAAE,WAAW,EAAE,CAAA;AAatB,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA"}
@@ -1,21 +1,7 @@
1
- import type { AbortOptions, LoggerOptions } from '@libp2p/interface';
2
- import type { LengthPrefixedStream } from 'it-length-prefixed-stream';
3
- import type { Duplex, Source } from 'it-stream-types';
4
- import type { Uint8ArrayList } from 'uint8arraylist';
5
- /**
6
- * `write` encodes and writes a single buffer
7
- */
8
- export declare function write(writer: LengthPrefixedStream<Duplex<AsyncGenerator<Uint8Array | Uint8ArrayList>, Source<Uint8Array>>>, buffer: Uint8Array | Uint8ArrayList, options?: AbortOptions): Promise<void>;
9
- /**
10
- * `writeAll` behaves like `write`, except it encodes an array of items as a single write
11
- */
12
- export declare function writeAll(writer: LengthPrefixedStream<Duplex<AsyncGenerator<Uint8Array | Uint8ArrayList>, Source<Uint8Array>>>, buffers: Uint8Array[], options?: AbortOptions): Promise<void>;
13
- /**
14
- * Read a length-prefixed buffer from the passed stream, stripping the final newline character
15
- */
16
- export declare function read(reader: LengthPrefixedStream<Duplex<AsyncGenerator<Uint8Array | Uint8ArrayList>, Source<Uint8Array>>>, options: AbortOptions & LoggerOptions): Promise<Uint8ArrayList>;
1
+ import type { AbortOptions } from '@libp2p/interface';
2
+ import type { LengthPrefixedStream } from '@libp2p/utils';
17
3
  /**
18
4
  * Read a length-prefixed string from the passed stream, stripping the final newline character
19
5
  */
20
- export declare function readString(reader: LengthPrefixedStream<Duplex<AsyncGenerator<Uint8Array | Uint8ArrayList>, Source<Uint8Array>>>, options: AbortOptions & LoggerOptions): Promise<string>;
6
+ export declare function readString(reader: LengthPrefixedStream<any>, options?: AbortOptions): Promise<string>;
21
7
  //# sourceMappingURL=multistream.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"multistream.d.ts","sourceRoot":"","sources":["../../src/multistream.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACpE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AACrE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAIpD;;GAEG;AACH,wBAAsB,KAAK,CAAE,MAAM,EAAE,oBAAoB,CAAC,MAAM,CAAC,cAAc,CAAC,UAAU,GAAG,cAAc,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,GAAG,cAAc,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAE9M;AAED;;GAEG;AACH,wBAAsB,QAAQ,CAAE,MAAM,EAAE,oBAAoB,CAAC,MAAM,CAAC,cAAc,CAAC,UAAU,GAAG,cAAc,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAEnM;AAED;;GAEG;AACH,wBAAsB,IAAI,CAAE,MAAM,EAAE,oBAAoB,CAAC,MAAM,CAAC,cAAc,CAAC,UAAU,GAAG,cAAc,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,YAAY,GAAG,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC,CASjM;AAED;;GAEG;AACH,wBAAsB,UAAU,CAAE,MAAM,EAAE,oBAAoB,CAAC,MAAM,CAAC,cAAc,CAAC,UAAU,GAAG,cAAc,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,YAAY,GAAG,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAI/L"}
1
+ {"version":3,"file":"multistream.d.ts","sourceRoot":"","sources":["../../src/multistream.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAA;AAIzD;;GAEG;AACH,wBAAsB,UAAU,CAAE,MAAM,EAAE,oBAAoB,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAS5G"}
@@ -3,33 +3,14 @@ import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string';
3
3
  import { toString as uint8ArrayToString } from 'uint8arrays/to-string';
4
4
  const NewLine = uint8ArrayFromString('\n');
5
5
  /**
6
- * `write` encodes and writes a single buffer
7
- */
8
- export async function write(writer, buffer, options) {
9
- await writer.write(buffer, options);
10
- }
11
- /**
12
- * `writeAll` behaves like `write`, except it encodes an array of items as a single write
13
- */
14
- export async function writeAll(writer, buffers, options) {
15
- await writer.writeV(buffers, options);
16
- }
17
- /**
18
- * Read a length-prefixed buffer from the passed stream, stripping the final newline character
6
+ * Read a length-prefixed string from the passed stream, stripping the final newline character
19
7
  */
20
- export async function read(reader, options) {
8
+ export async function readString(reader, options) {
21
9
  const buf = await reader.read(options);
22
- if (buf.byteLength === 0 || buf.get(buf.byteLength - 1) !== NewLine[0]) {
23
- options.log.error('Invalid mss message - missing newline', buf);
10
+ const arr = buf.subarray();
11
+ if (arr.byteLength === 0 || arr[arr.length - 1] !== NewLine[0]) {
24
12
  throw new InvalidMessageError('Missing newline');
25
13
  }
26
- return buf.sublist(0, -1); // Remove newline
27
- }
28
- /**
29
- * Read a length-prefixed string from the passed stream, stripping the final newline character
30
- */
31
- export async function readString(reader, options) {
32
- const buf = await read(reader, options);
33
- return uint8ArrayToString(buf.subarray());
14
+ return uint8ArrayToString(arr).trimEnd();
34
15
  }
35
16
  //# sourceMappingURL=multistream.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"multistream.js","sourceRoot":"","sources":["../../src/multistream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,EAAE,UAAU,IAAI,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAC5E,OAAO,EAAE,QAAQ,IAAI,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAMtE,MAAM,OAAO,GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAA;AAE1C;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CAAE,MAAqG,EAAE,MAAmC,EAAE,OAAsB;IAC7L,MAAM,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AACrC,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAE,MAAqG,EAAE,OAAqB,EAAE,OAAsB;IAClL,MAAM,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AACvC,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,IAAI,CAAE,MAAqG,EAAE,OAAqC;IACtK,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IAEtC,IAAI,GAAG,CAAC,UAAU,KAAK,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,GAA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iB,CAAC,CAAA;IAClD,CAAC;IAED,OAAO,kBAAkB,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,CAAA;AAC1C,CAAC"}
@@ -1,12 +1,5 @@
1
- import type { MultistreamSelectInit, ProtocolStream } from './index.js';
2
- import type { AbortOptions } from '@libp2p/interface';
3
- import type { Duplex } from 'it-stream-types';
4
- export interface SelectStream extends Duplex<any, any, any> {
5
- readStatus?: string;
6
- closeWrite?(options?: AbortOptions): Promise<void>;
7
- closeRead?(options?: AbortOptions): Promise<void>;
8
- close?(options?: AbortOptions): Promise<void>;
9
- }
1
+ import type { MultistreamSelectInit } from './index.js';
2
+ import type { MessageStream } from '@libp2p/interface';
10
3
  /**
11
4
  * Negotiate a protocol to use from a list of protocols.
12
5
  *
@@ -50,5 +43,5 @@ export interface SelectStream extends Duplex<any, any, any> {
50
43
  * // }
51
44
  * ```
52
45
  */
53
- export declare function select<Stream extends SelectStream>(stream: Stream, protocols: string | string[], options: MultistreamSelectInit): Promise<ProtocolStream<Stream>>;
46
+ export declare function select<Stream extends MessageStream>(stream: Stream, protocols: string | string[], options?: MultistreamSelectInit): Promise<string>;
54
47
  //# sourceMappingURL=select.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../src/select.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AACvE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAE7C,MAAM,WAAW,YAAa,SAAQ,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;IACzD,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,CAAC,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAClD,SAAS,CAAC,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACjD,KAAK,CAAC,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAC9C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAsB,MAAM,CAAE,MAAM,SAAS,YAAY,EAAG,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAoDzK"}
1
+ {"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../src/select.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AACvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAEtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAsB,MAAM,CAAE,MAAM,SAAS,aAAa,EAAG,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,OAAO,GAAE,qBAA0B,GAAG,OAAO,CAAC,MAAM,CAAC,CAoD/J"}
@@ -1,12 +1,8 @@
1
1
  import { UnsupportedProtocolError } from '@libp2p/interface';
2
- import { lpStream } from 'it-length-prefixed-stream';
3
- import pDefer from 'p-defer';
4
- import { raceSignal } from 'race-signal';
5
- import * as varint from 'uint8-varint';
6
- import { Uint8ArrayList } from 'uint8arraylist';
2
+ import { lpStream } from '@libp2p/utils';
7
3
  import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string';
8
4
  import { MAX_PROTOCOL_LENGTH } from './constants.js';
9
- import * as multistream from './multistream.js';
5
+ import { readString } from './multistream.js';
10
6
  import { PROTOCOL_ID } from './index.js';
11
7
  /**
12
8
  * Negotiate a protocol to use from a list of protocols.
@@ -51,247 +47,48 @@ import { PROTOCOL_ID } from './index.js';
51
47
  * // }
52
48
  * ```
53
49
  */
54
- export async function select(stream, protocols, options) {
50
+ export async function select(stream, protocols, options = {}) {
55
51
  protocols = Array.isArray(protocols) ? [...protocols] : [protocols];
56
- if (protocols.length === 1 && options.negotiateFully === false) {
57
- return optimisticSelect(stream, protocols[0], options);
58
- }
59
- const lp = lpStream(stream, {
60
- ...options,
61
- maxDataLength: MAX_PROTOCOL_LENGTH
62
- });
63
- const protocol = protocols.shift();
64
- if (protocol == null) {
52
+ if (protocols.length === 0) {
65
53
  throw new Error('At least one protocol must be specified');
66
54
  }
67
- options.log.trace('select: write ["%s", "%s"]', PROTOCOL_ID, protocol);
68
- const p1 = uint8ArrayFromString(`${PROTOCOL_ID}\n`);
69
- const p2 = uint8ArrayFromString(`${protocol}\n`);
70
- await multistream.writeAll(lp, [p1, p2], options);
71
- options.log.trace('select: reading multistream-select header');
72
- let response = await multistream.readString(lp, options);
73
- options.log.trace('select: read "%s"', response);
74
- // Read the protocol response if we got the protocolId in return
75
- if (response === PROTOCOL_ID) {
76
- options.log.trace('select: reading protocol response');
77
- response = await multistream.readString(lp, options);
78
- options.log.trace('select: read "%s"', response);
79
- }
80
- // We're done
81
- if (response === protocol) {
82
- return { stream: lp.unwrap(), protocol };
83
- }
84
- // We haven't gotten a valid ack, try the other protocols
85
- for (const protocol of protocols) {
86
- options.log.trace('select: write "%s"', protocol);
87
- await multistream.write(lp, uint8ArrayFromString(`${protocol}\n`), options);
88
- options.log.trace('select: reading protocol response');
89
- const response = await multistream.readString(lp, options);
90
- options.log.trace('select: read "%s" for "%s"', response, protocol);
91
- if (response === protocol) {
92
- return { stream: lp.unwrap(), protocol };
93
- }
94
- }
95
- throw new UnsupportedProtocolError('protocol selection failed');
96
- }
97
- /**
98
- * Optimistically negotiates a protocol.
99
- *
100
- * It *does not* block writes waiting for the other end to respond. Instead, it
101
- * simply assumes the negotiation went successfully and starts writing data.
102
- *
103
- * Use when it is known that the receiver supports the desired protocol.
104
- */
105
- function optimisticSelect(stream, protocol, options) {
106
- const originalSink = stream.sink.bind(stream);
107
- const originalSource = stream.source;
108
- let negotiated = false;
109
- let negotiating = false;
110
- const doneNegotiating = pDefer();
111
- let sentProtocol = false;
112
- let sendingProtocol = false;
113
- const doneSendingProtocol = pDefer();
114
- let readProtocol = false;
115
- let readingProtocol = false;
116
- const doneReadingProtocol = pDefer();
117
- const lp = lpStream({
118
- sink: originalSink,
119
- source: originalSource
120
- }, {
55
+ const log = stream.log.newScope('mss:select');
56
+ const lp = lpStream(stream, {
121
57
  ...options,
122
58
  maxDataLength: MAX_PROTOCOL_LENGTH
123
59
  });
124
- stream.sink = async (source) => {
125
- const { sink } = lp.unwrap();
126
- await sink(async function* () {
127
- let sentData = false;
128
- for await (const buf of source) {
129
- // started reading before the source yielded, wait for protocol send
130
- if (sendingProtocol) {
131
- await doneSendingProtocol.promise;
132
- }
133
- // writing before reading, send the protocol and the first chunk of data
134
- if (!sentProtocol) {
135
- sendingProtocol = true;
136
- options.log.trace('optimistic: write ["%s", "%s", data(%d)] in sink', PROTOCOL_ID, protocol, buf.byteLength);
137
- const protocolString = `${protocol}\n`;
138
- // send protocols in first chunk of data written to transport
139
- yield new Uint8ArrayList(Uint8Array.from([19]), // length of PROTOCOL_ID plus newline
140
- uint8ArrayFromString(`${PROTOCOL_ID}\n`), varint.encode(protocolString.length), uint8ArrayFromString(protocolString), buf).subarray();
141
- options.log.trace('optimistic: wrote ["%s", "%s", data(%d)] in sink', PROTOCOL_ID, protocol, buf.byteLength);
142
- sentProtocol = true;
143
- sendingProtocol = false;
144
- doneSendingProtocol.resolve();
145
- // read the negotiation response but don't block more sending
146
- negotiate()
147
- .catch(err => {
148
- options.log.error('could not finish optimistic protocol negotiation of %s', protocol, err);
149
- });
150
- }
151
- else {
152
- yield buf;
153
- }
154
- sentData = true;
155
- }
156
- // special case - the source passed to the sink has ended but we didn't
157
- // negotiated the protocol yet so do it now
158
- if (!sentData) {
159
- await negotiate();
160
- }
161
- }());
162
- };
163
- async function negotiate() {
164
- if (negotiating) {
165
- options.log.trace('optimistic: already negotiating %s stream', protocol);
166
- await doneNegotiating.promise;
167
- return;
168
- }
169
- negotiating = true;
170
- try {
171
- // we haven't sent the protocol yet, send it now
172
- if (!sentProtocol) {
173
- options.log.trace('optimistic: doing send protocol for %s stream', protocol);
174
- await doSendProtocol();
175
- }
176
- // if we haven't read the protocol response yet, do it now
177
- if (!readProtocol) {
178
- options.log.trace('optimistic: doing read protocol for %s stream', protocol);
179
- await doReadProtocol();
60
+ for (let i = 0; i < protocols.length; i++) {
61
+ const protocol = protocols[i];
62
+ let response;
63
+ if (i === 0) {
64
+ // Write the multistream-select header along with the first protocol
65
+ log.trace('write ["%s", "%s"]', PROTOCOL_ID, protocol);
66
+ const p1 = uint8ArrayFromString(`${PROTOCOL_ID}\n`);
67
+ const p2 = uint8ArrayFromString(`${protocol}\n`);
68
+ await lp.writeV([p1, p2], options);
69
+ log.trace('reading multistream-select header');
70
+ response = await readString(lp, options);
71
+ log.trace('read "%s"', response);
72
+ // Read the protocol response if we got the protocolId in return
73
+ if (response !== PROTOCOL_ID) {
74
+ log.error('did not read multistream-select header from response');
75
+ break;
180
76
  }
181
77
  }
182
- finally {
183
- negotiating = false;
184
- negotiated = true;
185
- doneNegotiating.resolve();
78
+ else {
79
+ // We haven't gotten a valid ack, try the other protocols
80
+ log.trace('write "%s"', protocol);
81
+ await lp.write(uint8ArrayFromString(`${protocol}\n`), options);
186
82
  }
187
- }
188
- async function doSendProtocol() {
189
- if (sendingProtocol) {
190
- await doneSendingProtocol.promise;
191
- return;
192
- }
193
- sendingProtocol = true;
194
- try {
195
- options.log.trace('optimistic: write ["%s", "%s", data] in source', PROTOCOL_ID, protocol);
196
- await lp.writeV([
197
- uint8ArrayFromString(`${PROTOCOL_ID}\n`),
198
- uint8ArrayFromString(`${protocol}\n`)
199
- ]);
200
- options.log.trace('optimistic: wrote ["%s", "%s", data] in source', PROTOCOL_ID, protocol);
201
- }
202
- finally {
203
- sentProtocol = true;
204
- sendingProtocol = false;
205
- doneSendingProtocol.resolve();
206
- }
207
- }
208
- async function doReadProtocol() {
209
- if (readingProtocol) {
210
- await doneReadingProtocol.promise;
211
- return;
212
- }
213
- readingProtocol = true;
214
- try {
215
- options.log.trace('optimistic: reading multistream select header');
216
- let response = await multistream.readString(lp, options);
217
- options.log.trace('optimistic: read multistream select header "%s"', response);
218
- if (response === PROTOCOL_ID) {
219
- response = await multistream.readString(lp, options);
220
- }
221
- options.log.trace('optimistic: read protocol "%s", expecting "%s"', response, protocol);
222
- if (response !== protocol) {
223
- throw new UnsupportedProtocolError('protocol selection failed');
224
- }
225
- }
226
- finally {
227
- readProtocol = true;
228
- readingProtocol = false;
229
- doneReadingProtocol.resolve();
83
+ log.trace('reading protocol response');
84
+ response = await readString(lp, options);
85
+ log.trace('read "%s"', response);
86
+ if (response === protocol) {
87
+ log.trace('selected "%s" after negotiation', response);
88
+ lp.unwrap();
89
+ return protocol;
230
90
  }
231
91
  }
232
- stream.source = (async function* () {
233
- // make sure we've done protocol negotiation before we read stream data
234
- await negotiate();
235
- options.log.trace('optimistic: reading data from "%s" stream', protocol);
236
- yield* lp.unwrap().source;
237
- })();
238
- if (stream.closeRead != null) {
239
- const originalCloseRead = stream.closeRead.bind(stream);
240
- stream.closeRead = async (opts) => {
241
- // we need to read & write to negotiate the protocol so ensure we've done
242
- // this before closing the readable end of the stream
243
- if (!negotiated) {
244
- await negotiate().catch(err => {
245
- options.log.error('could not negotiate protocol before close read', err);
246
- });
247
- }
248
- // protocol has been negotiated, ok to close the readable end
249
- await originalCloseRead(opts);
250
- };
251
- }
252
- if (stream.closeWrite != null) {
253
- const originalCloseWrite = stream.closeWrite.bind(stream);
254
- stream.closeWrite = async (opts) => {
255
- // we need to read & write to negotiate the protocol so ensure we've done
256
- // this before closing the writable end of the stream
257
- if (!negotiated) {
258
- await negotiate().catch(err => {
259
- options.log.error('could not negotiate protocol before close write', err);
260
- });
261
- }
262
- // protocol has been negotiated, ok to close the writable end
263
- await originalCloseWrite(opts);
264
- };
265
- }
266
- if (stream.close != null) {
267
- const originalClose = stream.close.bind(stream);
268
- stream.close = async (opts) => {
269
- // if we are in the process of negotiation, let it finish before closing
270
- // because we may have unsent early data
271
- const tasks = [];
272
- if (sendingProtocol) {
273
- tasks.push(doneSendingProtocol.promise);
274
- }
275
- if (readingProtocol) {
276
- tasks.push(doneReadingProtocol.promise);
277
- }
278
- if (tasks.length > 0) {
279
- // let the in-flight protocol negotiation finish gracefully
280
- await raceSignal(Promise.all(tasks), opts?.signal);
281
- }
282
- else {
283
- // no protocol negotiation attempt has occurred so don't start one
284
- negotiated = true;
285
- negotiating = false;
286
- doneNegotiating.resolve();
287
- }
288
- // protocol has been negotiated, ok to close the writable end
289
- await originalClose(opts);
290
- };
291
- }
292
- return {
293
- stream,
294
- protocol
295
- };
92
+ throw new UnsupportedProtocolError(`Protocol selection failed - could not negotiate ${protocols}`);
296
93
  }
297
94
  //# sourceMappingURL=select.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"select.js","sourceRoot":"","sources":["../../src/select.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAA;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAA;AACpD,OAAO,MAAM,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,KAAK,MAAM,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,UAAU,IAAI,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAC5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAYxC;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,GAAG,CAAC,KAAK,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAA;YACjC,MAAM,EAAE,CAAC,KAAK,CAAC,oBAAoB,CAAC,GAAG,QAAQ,IAAI,CAAC,EAAE,OAAO,CAAC,CAAA;QAChE,CAAC;QAED,GAAG,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAA;QACtC,QAAQ,GAAG,MAAM,UAAU,CAAC,EAAE,EAAE,OAAO,CAAC,CAAA;QACxC,GAAG,CAAC,KAAK,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAA;QAEhC,IAAI,QAAQ,KAAK,QAAQ,EAAE,CAAC;YAC1B,GAAG,CAAC,KAAK,CAAC,iCAAiC,EAAE,QAAQ,CAAC,CAAA;YACtD,EAAE,CAAC,MAAM,EAAE,CAAA;YAEX,OAAO,QAAQ,CAAA;QACjB,CAAC;IACH,CAAC;IAED,MAAM,IAAI,wBAAwB,CAAC,mDAAmD,SAAS,EAAE,CAAC,CAAA;AACpG,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libp2p/multistream-select",
3
- "version": "6.0.29",
3
+ "version": "7.0.0-049bfa0fa",
4
4
  "description": "JavaScript implementation of multistream-select",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/multistream-select#readme",
@@ -51,24 +51,19 @@
51
51
  "test:electron-main": "aegir test -t electron-main"
52
52
  },
53
53
  "dependencies": {
54
- "@libp2p/interface": "^2.11.0",
54
+ "@libp2p/interface": "3.0.0-049bfa0fa",
55
+ "@libp2p/utils": "7.0.0-049bfa0fa",
55
56
  "it-length-prefixed": "^10.0.1",
56
- "it-length-prefixed-stream": "^2.0.2",
57
- "it-stream-types": "^2.0.2",
58
- "p-defer": "^4.0.1",
59
- "race-signal": "^1.1.3",
60
- "uint8-varint": "^2.0.4",
61
57
  "uint8arraylist": "^2.4.8",
62
58
  "uint8arrays": "^5.1.0"
63
59
  },
64
60
  "devDependencies": {
65
- "@libp2p/logger": "^5.2.0",
66
- "aegir": "^47.0.14",
61
+ "aegir": "^47.0.22",
67
62
  "iso-random-stream": "^2.0.2",
68
- "it-all": "^3.0.8",
69
- "it-drain": "^3.0.9",
70
- "it-pair": "^2.0.6",
63
+ "it-all": "^3.0.9",
64
+ "it-drain": "^3.0.10",
71
65
  "it-pipe": "^3.0.1",
66
+ "p-event": "^6.0.1",
72
67
  "p-timeout": "^6.1.4"
73
68
  },
74
69
  "sideEffects": false