@libp2p/multistream-select
Advanced tools
Comparing version
export declare const PROTOCOL_ID = "/multistream/1.0.0"; | ||
export declare const MAX_PROTOCOL_LENGTH = 1024; | ||
//# sourceMappingURL=constants.d.ts.map |
export const PROTOCOL_ID = '/multistream/1.0.0'; | ||
// Conforming to go-libp2p | ||
// See https://github.com/multiformats/go-multistream/blob/master/multistream.go#L297 | ||
export const MAX_PROTOCOL_LENGTH = 1024; | ||
//# sourceMappingURL=constants.js.map |
@@ -9,2 +9,3 @@ import { Uint8ArrayList } from 'uint8arraylist'; | ||
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'; | ||
import { MAX_PROTOCOL_LENGTH } from './constants.js'; | ||
const NewLine = uint8ArrayFromString('\n'); | ||
@@ -58,4 +59,4 @@ export function encode(buffer) { | ||
}; | ||
const buf = await pipe(input, lp.decode({ onLength }), async (source) => await first(source)); | ||
if (buf == null) { | ||
const buf = await pipe(input, lp.decode({ onLength, maxDataLength: MAX_PROTOCOL_LENGTH }), async (source) => await first(source)); | ||
if (buf == null || buf.length === 0) { | ||
throw errCode(new Error('no buffer returned'), 'ERR_INVALID_MULTISTREAM_SELECT_MESSAGE'); | ||
@@ -62,0 +63,0 @@ } |
{ | ||
"name": "@libp2p/multistream-select", | ||
"version": "3.1.0", | ||
"version": "3.1.1", | ||
"description": "JavaScript implementation of multistream-select", | ||
@@ -150,3 +150,3 @@ "license": "Apache-2.0 OR MIT", | ||
"it-first": "^1.0.6", | ||
"it-handshake": "^4.0.1", | ||
"it-handshake": "^4.1.2", | ||
"it-length-prefixed": "^8.0.2", | ||
@@ -153,0 +153,0 @@ "it-merge": "^1.0.4", |
export const PROTOCOL_ID = '/multistream/1.0.0' | ||
// Conforming to go-libp2p | ||
// See https://github.com/multiformats/go-multistream/blob/master/multistream.go#L297 | ||
export const MAX_PROTOCOL_LENGTH = 1024 |
@@ -15,2 +15,3 @@ | ||
import type { MultistreamSelectInit } from '.' | ||
import { MAX_PROTOCOL_LENGTH } from './constants.js' | ||
@@ -77,7 +78,7 @@ const NewLine = uint8ArrayFromString('\n') | ||
input, | ||
lp.decode({ onLength }), | ||
lp.decode({ onLength, maxDataLength: MAX_PROTOCOL_LENGTH }), | ||
async (source) => await first(source) | ||
) | ||
if (buf == null) { | ||
if (buf == null || buf.length === 0) { | ||
throw errCode(new Error('no buffer returned'), 'ERR_INVALID_MULTISTREAM_SELECT_MESSAGE') | ||
@@ -84,0 +85,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
46466
1.7%506
1.81%Updated