New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@libp2p/webrtc

Package Overview
Dependencies
Maintainers
6
Versions
689
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@libp2p/webrtc - npm Package Compare versions

Comparing version 3.1.10 to 3.1.11

2

dist/src/private-to-private/handler.js

@@ -135,4 +135,4 @@ import { CodeError } from '@libp2p/interface/errors';

}
return `/dnsaddr/${candidateParts[4]}/${candidateParts[2].toLowerCase()}/${candidateParts[3]}/webrtc`;
return `/dnsaddr/${candidateParts[4]}/${candidateParts[2].toLowerCase()}/${candidateParts[5]}/webrtc`;
}
//# sourceMappingURL=handler.js.map

@@ -20,2 +20,7 @@ import { AbstractStream, type AbstractStreamInit } from '@libp2p/interface/stream-muxer/stream';

}
export declare const MAX_MESSAGE_SIZE: number;
export declare const MAX_BUFFERED_AMOUNT: number;
export declare const BUFFERED_AMOUNT_LOW_TIMEOUT: number;
export declare const PROTOBUF_OVERHEAD = 5;
export declare const VARINT_LENGTH = 2;
export declare class WebRTCStream extends AbstractStream {

@@ -36,2 +41,5 @@ /**

private messageQueue?;
/**
* The maximum size of a message in bytes
*/
private readonly maxDataSize;

@@ -38,0 +46,0 @@ constructor(init: WebRTCStreamInit);

@@ -9,11 +9,12 @@ import { CodeError } from '@libp2p/interface/errors';

import { Message } from './pb/message.js';
const log = logger('libp2p:webrtc:stream');
// Max message size that can be sent to the DataChannel
const MAX_MESSAGE_SIZE = 16 * 1024;
export const MAX_MESSAGE_SIZE = 16 * 1024;
// How much can be buffered to the DataChannel at once
const MAX_BUFFERED_AMOUNT = 16 * 1024 * 1024;
export const MAX_BUFFERED_AMOUNT = 16 * 1024 * 1024;
// How long time we wait for the 'bufferedamountlow' event to be emitted
const BUFFERED_AMOUNT_LOW_TIMEOUT = 30 * 1000;
export const BUFFERED_AMOUNT_LOW_TIMEOUT = 30 * 1000;
// protobuf field definition overhead
const PROTOBUF_OVERHEAD = 3;
export const PROTOBUF_OVERHEAD = 5;
// Length of varint, in bytes.
export const VARINT_LENGTH = 2;
export class WebRTCStream extends AbstractStream {

@@ -34,2 +35,5 @@ /**

messageQueue;
/**
* The maximum size of a message in bytes
*/
maxDataSize;

@@ -45,3 +49,3 @@ constructor(init) {

maxBufferedAmount: init.dataChannelOptions?.maxBufferedAmount ?? MAX_BUFFERED_AMOUNT,
maxMessageSize: init.dataChannelOptions?.maxMessageSize ?? MAX_MESSAGE_SIZE
maxMessageSize: init.dataChannelOptions?.maxMessageSize ?? init.maxDataSize
};

@@ -63,3 +67,3 @@ this.maxDataSize = init.maxDataSize;

default:
log.error('unknown datachannel state %s', this.channel.readyState);
this.log.error('unknown datachannel state %s', this.channel.readyState);
throw new CodeError('Unknown datachannel state', 'ERR_INVALID_STATE');

@@ -81,3 +85,3 @@ }

void this.close().catch(err => {
log.error('error closing stream after channel closed', err);
this.log.error('error closing stream after channel closed', err);
});

@@ -108,3 +112,3 @@ };

.catch(err => {
log.error('error processing incoming data channel messages', err);
this.log.error('error processing incoming data channel messages', err);
});

@@ -144,3 +148,3 @@ }

else {
log.error('unknown datachannel state %s', this.channel.readyState);
this.log.error('unknown datachannel state %s', this.channel.readyState);
throw new CodeError('Unknown datachannel state', 'ERR_INVALID_STATE');

@@ -192,3 +196,3 @@ }

async _sendFlag(flag) {
log.trace('Sending flag: %s', flag.toString());
this.log.trace('Sending flag: %s', flag.toString());
const msgbuf = Message.encode({ flag });

@@ -204,3 +208,3 @@ const prefixedBuf = lengthPrefixed.encode.single(msgbuf);

direction,
maxDataSize: (dataChannelOptions?.maxMessageSize ?? MAX_MESSAGE_SIZE) - PROTOBUF_OVERHEAD,
maxDataSize: (dataChannelOptions?.maxMessageSize ?? MAX_MESSAGE_SIZE) - PROTOBUF_OVERHEAD - VARINT_LENGTH,
dataChannelOptions,

@@ -207,0 +211,0 @@ onEnd,

{
"name": "@libp2p/webrtc",
"version": "3.1.10",
"version": "3.1.11",
"description": "A libp2p transport using WebRTC connections",

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

"@libp2p/interface": "^0.1.2",
"@libp2p/interface-internal": "^0.1.4",
"@libp2p/interface-internal": "^0.1.5",
"@libp2p/logger": "^3.0.2",

@@ -74,5 +74,5 @@ "@libp2p/peer-id": "^3.0.2",

"@chainsafe/libp2p-yamux": "^5.0.0",
"@libp2p/interface-compliance-tests": "^4.0.5",
"@libp2p/peer-id-factory": "^3.0.3",
"@libp2p/websockets": "^7.0.6",
"@libp2p/interface-compliance-tests": "^4.0.6",
"@libp2p/peer-id-factory": "^3.0.4",
"@libp2p/websockets": "^7.0.7",
"@types/sinon": "^10.0.15",

@@ -84,5 +84,5 @@ "aegir": "^40.0.8",

"it-pair": "^2.0.6",
"libp2p": "^0.46.10",
"libp2p": "^0.46.11",
"protons": "^7.0.2",
"sinon": "^15.1.2",
"sinon": "^16.0.0",
"sinon-ts": "^1.0.0"

@@ -89,0 +89,0 @@ },

@@ -176,3 +176,3 @@ import { CodeError } from '@libp2p/interface/errors'

return `/dnsaddr/${candidateParts[4]}/${candidateParts[2].toLowerCase()}/${candidateParts[3]}/webrtc`
return `/dnsaddr/${candidateParts[4]}/${candidateParts[2].toLowerCase()}/${candidateParts[5]}/webrtc`
}

@@ -11,4 +11,2 @@ import { CodeError } from '@libp2p/interface/errors'

const log = logger('libp2p:webrtc:stream')
export interface DataChannelOpts {

@@ -35,13 +33,16 @@ maxMessageSize: number

// Max message size that can be sent to the DataChannel
const MAX_MESSAGE_SIZE = 16 * 1024
export const MAX_MESSAGE_SIZE = 16 * 1024
// How much can be buffered to the DataChannel at once
const MAX_BUFFERED_AMOUNT = 16 * 1024 * 1024
export const MAX_BUFFERED_AMOUNT = 16 * 1024 * 1024
// How long time we wait for the 'bufferedamountlow' event to be emitted
const BUFFERED_AMOUNT_LOW_TIMEOUT = 30 * 1000
export const BUFFERED_AMOUNT_LOW_TIMEOUT = 30 * 1000
// protobuf field definition overhead
const PROTOBUF_OVERHEAD = 3
export const PROTOBUF_OVERHEAD = 5
// Length of varint, in bytes.
export const VARINT_LENGTH = 2
export class WebRTCStream extends AbstractStream {

@@ -65,2 +66,6 @@ /**

private messageQueue?: Uint8ArrayList
/**
* The maximum size of a message in bytes
*/
private readonly maxDataSize: number

@@ -78,3 +83,3 @@

maxBufferedAmount: init.dataChannelOptions?.maxBufferedAmount ?? MAX_BUFFERED_AMOUNT,
maxMessageSize: init.dataChannelOptions?.maxMessageSize ?? MAX_MESSAGE_SIZE
maxMessageSize: init.dataChannelOptions?.maxMessageSize ?? init.maxDataSize
}

@@ -99,3 +104,3 @@ this.maxDataSize = init.maxDataSize

default:
log.error('unknown datachannel state %s', this.channel.readyState)
this.log.error('unknown datachannel state %s', this.channel.readyState)
throw new CodeError('Unknown datachannel state', 'ERR_INVALID_STATE')

@@ -120,3 +125,3 @@ }

void this.close().catch(err => {
log.error('error closing stream after channel closed', err)
this.log.error('error closing stream after channel closed', err)
})

@@ -154,3 +159,3 @@ }

.catch(err => {
log.error('error processing incoming data channel messages', err)
this.log.error('error processing incoming data channel messages', err)
})

@@ -193,3 +198,3 @@ }

} else {
log.error('unknown datachannel state %s', this.channel.readyState)
this.log.error('unknown datachannel state %s', this.channel.readyState)
throw new CodeError('Unknown datachannel state', 'ERR_INVALID_STATE')

@@ -253,3 +258,3 @@ }

private async _sendFlag (flag: Message.Flag): Promise<void> {
log.trace('Sending flag: %s', flag.toString())
this.log.trace('Sending flag: %s', flag.toString())
const msgbuf = Message.encode({ flag })

@@ -289,3 +294,3 @@ const prefixedBuf = lengthPrefixed.encode.single(msgbuf)

direction,
maxDataSize: (dataChannelOptions?.maxMessageSize ?? MAX_MESSAGE_SIZE) - PROTOBUF_OVERHEAD,
maxDataSize: (dataChannelOptions?.maxMessageSize ?? MAX_MESSAGE_SIZE) - PROTOBUF_OVERHEAD - VARINT_LENGTH,
dataChannelOptions,

@@ -292,0 +297,0 @@ onEnd,

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc