node-datachannel
Advanced tools
Comparing version 0.2.4 to 0.3.0
@@ -5,2 +5,8 @@ cmake_minimum_required(VERSION 3.15) | ||
# Workaround for https://github.com/murat-dogan/node-datachannel/issues/65 | ||
if( NODE_RUNTIMEVERSION VERSION_GREATER_EQUAL "17.0.0") | ||
add_compile_definitions(OPENSSL_API_COMPAT=0x10100001L) | ||
add_compile_definitions(OPENSSL_CONFIGURED_API=0x30000000L) | ||
endif() | ||
include_directories(${CMAKE_JS_INC}) | ||
@@ -31,3 +37,3 @@ | ||
GIT_REPOSITORY https://github.com/paullouisageneau/libdatachannel.git | ||
GIT_TAG "v0.16.6" | ||
GIT_TAG "v0.17.0" | ||
) | ||
@@ -34,0 +40,0 @@ |
@@ -0,1 +1,2 @@ | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const stream = require('stream'); | ||
@@ -12,3 +13,2 @@ | ||
module.exports = class DataChannelStream extends stream.Duplex { | ||
constructor(rawChannel, streamOptions) { | ||
@@ -18,3 +18,3 @@ super({ | ||
...streamOptions, | ||
objectMode: true // Preserve the string/buffer distinction (WebRTC treats them differently) | ||
objectMode: true, // Preserve the string/buffer distinction (WebRTC treats them differently) | ||
}); | ||
@@ -56,10 +56,14 @@ | ||
let sentOk; | ||
if (Buffer.isBuffer(chunk)) { | ||
sentOk = this._rawChannel.sendMessageBinary(chunk); | ||
} else if (typeof chunk === 'string') { | ||
sentOk = this._rawChannel.sendMessage(chunk); | ||
} else { | ||
const typeName = chunk.constructor.name || typeof chunk; | ||
callback(new Error(`Cannot write ${typeName} to DataChannel stream`)); | ||
return; | ||
try { | ||
if (Buffer.isBuffer(chunk)) { | ||
sentOk = this._rawChannel.sendMessageBinary(chunk); | ||
} else if (typeof chunk === 'string') { | ||
sentOk = this._rawChannel.sendMessage(chunk); | ||
} else { | ||
const typeName = chunk.constructor.name || typeof chunk; | ||
throw new Error(`Cannot write ${typeName} to DataChannel stream`); | ||
} | ||
} catch (err) { | ||
return callback(err); | ||
} | ||
@@ -70,3 +74,3 @@ | ||
} else { | ||
callback(new Error("Failed to write to DataChannel")); | ||
callback(new Error('Failed to write to DataChannel')); | ||
} | ||
@@ -90,2 +94,9 @@ } | ||
} | ||
get id() { | ||
return this._rawChannel.getId(); | ||
} | ||
get protocol() { | ||
return this._rawChannel.getProtocol(); | ||
} | ||
}; |
@@ -6,3 +6,3 @@ import * as stream from 'stream'; | ||
// Enum in d.ts is tricky | ||
export type LogLevel = "Verbose" | "Debug" | "Info" | "Warning" | "Error" | "Fatal"; | ||
export type LogLevel = 'Verbose' | 'Debug' | 'Info' | 'Warning' | 'Error' | 'Fatal'; | ||
@@ -30,3 +30,3 @@ // SCTP Settings | ||
ip: string; | ||
port: Number; | ||
port: number; | ||
username?: string; | ||
@@ -39,3 +39,3 @@ password?: string; | ||
TurnTcp = 'TurnTcp', | ||
TurnTls = 'TurnTls' | ||
TurnTls = 'TurnTls', | ||
} | ||
@@ -45,3 +45,3 @@ | ||
hostname: string; | ||
port: Number; | ||
port: number; | ||
username?: string; | ||
@@ -68,7 +68,9 @@ password?: string; | ||
Pranswer = 'Pranswer', | ||
Rollback = 'Rollback' | ||
Rollback = 'Rollback', | ||
} | ||
export const enum ReliabilityType { | ||
Reliable = 0, Rexmit = 1, Timed = 2 | ||
Reliable = 0, | ||
Rexmit = 1, | ||
Timed = 2, | ||
} | ||
@@ -89,3 +91,3 @@ | ||
rexmit?: number; | ||
} | ||
}; | ||
} | ||
@@ -106,7 +108,7 @@ | ||
Inactive = 'Inactive', | ||
Unknown = 'Unknown' | ||
Unknown = 'Unknown', | ||
} | ||
export class RtcpReceivingSession { | ||
requestBitrate: (bitRate: Number) => void; | ||
requestBitrate: (bitRate: number) => void; | ||
requestKeyframe: () => boolean; | ||
@@ -117,4 +119,4 @@ } | ||
constructor(mid: string, dir: Direction); | ||
addAudioCodec: (payloadType: Number, codec: string, profile?: string) => void; | ||
addOpusCodec: (payloadType: Number, profile?: string) => string; | ||
addAudioCodec: (payloadType: number, codec: string, profile?: string) => void; | ||
addOpusCodec: (payloadType: number, profile?: string) => string; | ||
@@ -127,12 +129,12 @@ direction: () => Direction; | ||
removeFormat: (fmt: string) => void; | ||
addSSRC: (ssrc: Number, name?: string, msid?: string, trackID?: string) => void; | ||
removeSSRC: (ssrc: Number) => void; | ||
replaceSSRC: (oldSsrc: Number, ssrc: Number, name?: string, msid?: string, trackID?: string) => void; | ||
hasSSRC: (ssrc: Number) => boolean; | ||
getSSRCs: () => Number[]; | ||
getCNameForSsrc: (ssrc: Number) => string; | ||
setBitrate: (bitRate: Number) => void; | ||
getBitrate: () => Number; | ||
hasPayloadType: (payloadType: Number) => boolean; | ||
addRTXCodec: (payloadType: Number, originalPayloadType: Number, clockRate: Number) => void; | ||
addSSRC: (ssrc: number, name?: string, msid?: string, trackID?: string) => void; | ||
removeSSRC: (ssrc: number) => void; | ||
replaceSSRC: (oldSsrc: number, ssrc: number, name?: string, msid?: string, trackID?: string) => void; | ||
hasSSRC: (ssrc: number) => boolean; | ||
getSSRCs: () => number[]; | ||
getCNameForSsrc: (ssrc: number) => string; | ||
setBitrate: (bitRate: number) => void; | ||
getBitrate: () => number; | ||
hasPayloadType: (payloadType: number) => boolean; | ||
addRTXCodec: (payloadType: number, originalPayloadType: number, clockRate: number) => void; | ||
addRTPMap: () => void; | ||
@@ -144,6 +146,6 @@ parseSdpLine: (line: string) => void; | ||
constructor(mid: string, dir: Direction); | ||
addVideoCodec: (payloadType: Number, codec: string, profile?: string) => void; | ||
addH264Codec: (payloadType: Number, profile?: string) => void; | ||
addVP8Codec: (payloadType: Number) => void; | ||
addVP9Codec: (payloadType: Number) => void; | ||
addVideoCodec: (payloadType: number, codec: string, profile?: string) => void; | ||
addH264Codec: (payloadType: number, profile?: string) => void; | ||
addVP8Codec: (payloadType: number) => void; | ||
addVP9Codec: (payloadType: number) => void; | ||
@@ -156,12 +158,12 @@ direction: () => Direction; | ||
removeFormat: (fmt: string) => void; | ||
addSSRC: (ssrc: Number, name?: string, msid?: string, trackID?: string) => void; | ||
removeSSRC: (ssrc: Number) => void; | ||
replaceSSRC: (oldSsrc: Number, ssrc: Number, name?: string, msid?: string, trackID?: string) => void; | ||
hasSSRC: (ssrc: Number) => boolean; | ||
getSSRCs: () => Number[]; | ||
getCNameForSsrc: (ssrc: Number) => string; | ||
setBitrate: (bitRate: Number) => void; | ||
getBitrate: () => Number; | ||
hasPayloadType: (payloadType: Number) => boolean; | ||
addRTXCodec: (payloadType: Number, originalPayloadType: Number, clockRate: Number) => void; | ||
addSSRC: (ssrc: number, name?: string, msid?: string, trackID?: string) => void; | ||
removeSSRC: (ssrc: number) => void; | ||
replaceSSRC: (oldSsrc: number, ssrc: number, name?: string, msid?: string, trackID?: string) => void; | ||
hasSSRC: (ssrc: number) => boolean; | ||
getSSRCs: () => number[]; | ||
getCNameForSsrc: (ssrc: number) => string; | ||
setBitrate: (bitRate: number) => void; | ||
getBitrate: () => number; | ||
hasPayloadType: (payloadType: number) => boolean; | ||
addRTXCodec: (payloadType: number, originalPayloadType: number, clockRate: number) => void; | ||
addRTPMap: () => void; | ||
@@ -174,2 +176,3 @@ parseSdpLine: (line: string) => void; | ||
mid: () => string; | ||
type: () => string; | ||
close: () => void; | ||
@@ -180,14 +183,11 @@ sendMessage: (msg: string) => boolean; | ||
isClosed: () => boolean; | ||
availableAmount: () => Number; | ||
bufferedAmount: () => Number; | ||
maxMessageSize: () => Number; | ||
setBufferedAmountLowThreshold: (newSize: Number) => void; | ||
bufferedAmount: () => number; | ||
maxMessageSize: () => number; | ||
setBufferedAmountLowThreshold: (newSize: number) => void; | ||
requestKeyframe: () => boolean; | ||
setMediaHandler: (handler: RtcpReceivingSession) => void | ||
setMediaHandler: (handler: RtcpReceivingSession) => void; | ||
onOpen: (cb: () => void) => void; | ||
onClosed: (cb: () => void) => void; | ||
onError: (cb: (err: string) => void) => void; | ||
onAvailable: (cb: () => void) => void; | ||
onBufferedAmountLow: (cb: () => void) => void; | ||
onMessage: (cb: (msg: string | Buffer) => void) => void; | ||
onMessage: (cb: (msg: Buffer) => void) => void; | ||
} | ||
@@ -198,13 +198,13 @@ | ||
getLabel: () => string; | ||
getId: () => number; | ||
getProtocol: () => string; | ||
sendMessage: (msg: string) => boolean; | ||
sendMessageBinary: (buffer: Buffer) => boolean; | ||
isOpen: () => boolean; | ||
availableAmount: () => Number; | ||
bufferedAmount: () => Number; | ||
maxMessageSize: () => Number; | ||
setBufferedAmountLowThreshold: (newSize: Number) => void; | ||
bufferedAmount: () => number; | ||
maxMessageSize: () => number; | ||
setBufferedAmountLowThreshold: (newSize: number) => void; | ||
onOpen: (cb: () => void) => void; | ||
onClosed: (cb: () => void) => void; | ||
onError: (cb: (err: string) => void) => void; | ||
onAvailable: (cb: () => void) => void; | ||
onBufferedAmountLow: (cb: () => void) => void; | ||
@@ -217,5 +217,5 @@ onMessage: (cb: (msg: string | Buffer) => void) => void; | ||
close: () => void; | ||
setLocalDescription: (type: DescriptionType) => void; | ||
setLocalDescription: (type?: DescriptionType) => void; | ||
setRemoteDescription: (sdp: string, type: DescriptionType) => void; | ||
localDescription: () => { type: string, sdp: string }; | ||
localDescription: () => { type: string; sdp: string }; | ||
addRemoteCandidate: (candidate: string, mid: string) => void; | ||
@@ -234,15 +234,12 @@ createDataChannel: (label: string, config?: DataChannelInitConfig) => DataChannel; | ||
onDataChannel: (cb: (dc: DataChannel) => void) => void; | ||
onTrack: () => Track; | ||
onTrack: (cb: (track: Track) => void) => void; | ||
bytesSent: () => number; | ||
bytesReceived: () => number; | ||
rtt: () => number; | ||
getSelectedCandidatePair: () => { local: SelectedCandidateInfo, remote: SelectedCandidateInfo } | null; | ||
getSelectedCandidatePair: () => { local: SelectedCandidateInfo; remote: SelectedCandidateInfo } | null; | ||
} | ||
export class DataChannelStream extends stream.Duplex { | ||
constructor( | ||
rawChannel: DataChannel, | ||
options?: Omit<stream.DuplexOptions, 'objectMode'> | ||
); | ||
constructor(rawChannel: DataChannel, options?: Omit<stream.DuplexOptions, 'objectMode'>); | ||
get label(): string; | ||
} | ||
} |
@@ -1,4 +0,5 @@ | ||
const nodeDataChannel = require("../build/Release/node_datachannel.node"); | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const nodeDataChannel = require('../build/Release/node_datachannel.node'); | ||
module.exports = nodeDataChannel; | ||
module.exports.DataChannelStream = require('./datachannel-stream'); | ||
module.exports.DataChannelStream = require('./datachannel-stream'); |
@@ -25,2 +25,3 @@ { | ||
"_requiredBy": [ | ||
"/prebuild", | ||
"/prebuild-install" | ||
@@ -27,0 +28,0 @@ ], |
@@ -25,5 +25,6 @@ { | ||
"_requiredBy": [ | ||
"/@typescript-eslint/eslint-plugin/semver", | ||
"/@typescript-eslint/typescript-estree/semver", | ||
"/jest-snapshot/semver", | ||
"/node-abi/semver", | ||
"/prebuild/node-abi/semver" | ||
"/node-abi/semver" | ||
], | ||
@@ -30,0 +31,0 @@ "_resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", |
@@ -73,3 +73,3 @@ module.exports = function (args, opts) { | ||
var key = keys[i]; | ||
if (key === '__proto__') return; | ||
if (isConstructorOrProto(o, key)) return; | ||
if (o[key] === undefined) o[key] = {}; | ||
@@ -83,3 +83,3 @@ if (o[key] === Object.prototype || o[key] === Number.prototype | ||
var key = keys[keys.length - 1]; | ||
if (key === '__proto__') return; | ||
if (isConstructorOrProto(o, key)) return; | ||
if (o === Object.prototype || o === Number.prototype | ||
@@ -248,1 +248,5 @@ || o === String.prototype) o = {}; | ||
function isConstructorOrProto (obj, key) { | ||
return key === 'constructor' && typeof obj[key] === 'function' || key === '__proto__'; | ||
} |
{ | ||
"_args": [ | ||
[ | ||
"minimist@1.2.5", | ||
"minimist@1.2.6", | ||
"/home/runner/work/node-datachannel/node-datachannel" | ||
] | ||
], | ||
"_from": "minimist@1.2.5", | ||
"_id": "minimist@1.2.5", | ||
"_from": "minimist@1.2.6", | ||
"_id": "minimist@1.2.6", | ||
"_inBundle": false, | ||
"_integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", | ||
"_integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==", | ||
"_location": "/minimist", | ||
@@ -17,8 +17,8 @@ "_phantomChildren": {}, | ||
"registry": true, | ||
"raw": "minimist@1.2.5", | ||
"raw": "minimist@1.2.6", | ||
"name": "minimist", | ||
"escapedName": "minimist", | ||
"rawSpec": "1.2.5", | ||
"rawSpec": "1.2.6", | ||
"saveSpec": null, | ||
"fetchSpec": "1.2.5" | ||
"fetchSpec": "1.2.6" | ||
}, | ||
@@ -32,4 +32,4 @@ "_requiredBy": [ | ||
], | ||
"_resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", | ||
"_spec": "1.2.5", | ||
"_resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz", | ||
"_spec": "1.2.6", | ||
"_where": "/home/runner/work/node-datachannel/node-datachannel", | ||
@@ -81,3 +81,3 @@ "author": { | ||
}, | ||
"version": "1.2.5" | ||
"version": "1.2.6" | ||
} |
@@ -45,1 +45,17 @@ var parse = require('../'); | ||
}); | ||
test('proto pollution (constructor function)', function (t) { | ||
var argv = parse(['--_.concat.constructor.prototype.y', '123']); | ||
function fnToBeTested() {} | ||
t.equal(fnToBeTested.y, undefined); | ||
t.equal(argv.y, undefined); | ||
t.end(); | ||
}); | ||
// powered by snyk - https://github.com/backstage/backstage/issues/10343 | ||
test('proto pollution (constructor function) snyk', function (t) { | ||
var argv = parse('--_.constructor.constructor.prototype.foo bar'.split(' ')); | ||
t.equal((function(){}).foo, undefined); | ||
t.equal(argv.y, undefined); | ||
t.end(); | ||
}) |
@@ -27,2 +27,3 @@ { | ||
"_requiredBy": [ | ||
"/prebuild", | ||
"/prebuild-install" | ||
@@ -29,0 +30,0 @@ ], |
{ | ||
"name": "node-datachannel", | ||
"version": "0.2.4", | ||
"version": "0.3.0", | ||
"description": "libdatachannel node bindings", | ||
@@ -18,2 +18,3 @@ "main": "lib/index.js", | ||
"clean": "cmake-js clean", | ||
"lint": "eslint lib/**/*", | ||
"test": "jest" | ||
@@ -50,8 +51,16 @@ }, | ||
"devDependencies": { | ||
"@types/node": "^17.0.23", | ||
"@typescript-eslint/eslint-plugin": "^5.18.0", | ||
"@typescript-eslint/parser": "^5.18.0", | ||
"cmake-js": "^6.3.0", | ||
"eslint": "^8.12.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"jest": "^27.5.1", | ||
"nan": "^2.15.0", | ||
"napi-thread-safe-callback-cancellable": "^0.0.7", | ||
"node-addon-api": "^4.2.0", | ||
"prebuild": "^11.0.3" | ||
"node-addon-api": "^4.3.0", | ||
"prebuild": "^11.0.3", | ||
"prettier": "^2.6.2", | ||
"typescript": "^4.6.3" | ||
}, | ||
@@ -62,5 +71,4 @@ "bundledDependencies": [ | ||
"dependencies": { | ||
"@types/node": "^17.0.21", | ||
"prebuild-install": "^7.0.1" | ||
} | ||
} |
@@ -121,3 +121,3 @@ # Easy to use WebRTC data channels and media transport | ||
hostname: string; | ||
port: Number; | ||
port: number; | ||
username?: string; | ||
@@ -275,11 +275,11 @@ password?: string; | ||
**bufferedAmount: () => Number** | ||
**bufferedAmount: () => number** | ||
Get current buffered amount level | ||
**maxMessageSize: () => Number** | ||
**maxMessageSize: () => number** | ||
Get max message size of the data-channel, that could be sent | ||
**setBufferedAmountLowThreshold: (newSize: Number) => void** | ||
**setBufferedAmountLowThreshold: (newSize: number) => void** | ||
@@ -286,0 +286,0 @@ Set buffer level of the `onBufferedAmountLow` callback |
@@ -69,2 +69,5 @@ const nodeDataChannel = require('../lib/index'); | ||
dc2.sendMessage("Hello From Peer2"); | ||
dc2.onClosed(() => { | ||
console.log('dc2 closed'); | ||
}); | ||
}); | ||
@@ -89,2 +92,5 @@ | ||
}); | ||
dc1.onClosed(() => { | ||
console.log('dc1 closed'); | ||
}); | ||
@@ -96,9 +102,3 @@ setTimeout(() => { | ||
peer2.close(); | ||
dc1 = null; | ||
dc2 = null; | ||
peer1 = null; | ||
peer2 = null; | ||
nodeDataChannel.cleanup(); | ||
// No need for this (>= V0.1.14) | ||
// process.exit(); | ||
}, 5 * 1000); |
@@ -27,4 +27,7 @@ const nodeDataChannel = require('../lib/index'); | ||
let peer = new nodeDataChannel.PeerConnection("Peer", { iceServers: ["stun:stun.l.google.com:19302"] }); | ||
let dc = peer.createDataChannel('test'); | ||
let dc = peer.createDataChannel('test', { protocol: 'test-protocol' }); | ||
expect(dc).toBeDefined(); | ||
expect(dc.getId()).toBeDefined(); | ||
expect(dc.getProtocol()).toBe('test-protocol'); | ||
expect(dc.getLabel()).toBe('test'); | ||
expect(dc.onOpen).toBeDefined(); | ||
@@ -188,5 +191,2 @@ expect(dc.onMessage).toBeDefined(); | ||
clientChannel.close(); | ||
await new Promise((resolve) => echoStream.on('end', resolve)); | ||
clientPeer.close(); | ||
@@ -193,0 +193,0 @@ echoPeer.close(); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1316980
1
508
19961
14
- Removed@types/node@^17.0.21
- Removed@types/node@17.0.45(transitive)