node-datachannel 0.2.4 → 0.3.2
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.
- package/.editorconfig +12 -0
- package/.eslintignore +2 -0
- package/.eslintrc.js +8 -0
- package/.github/FUNDING.yml +2 -0
- package/.github/workflows/build-linux.yml +3 -3
- package/.github/workflows/build-mac.yml +1 -1
- package/.github/workflows/build-win.yml +4 -4
- package/.github/workflows/lint.yml +22 -0
- package/.prettierrc.js +7 -0
- package/CMakeLists.txt +8 -2
- package/README.md +4 -4
- package/examples/client-server/client-benchmark.js +43 -32
- package/examples/client-server/client-periodic.js +30 -14
- package/examples/client-server/client.js +6 -5
- package/examples/client-server/package-lock.json +183 -44
- package/examples/client-server/signaling-server.js +3 -5
- package/examples/media/media.js +9 -9
- package/lib/datachannel-stream.js +23 -12
- package/lib/index.d.ts +113 -116
- package/lib/index.js +3 -2
- package/node_modules/detect-libc/package.json +1 -0
- package/node_modules/lru-cache/package.json +1 -2
- package/node_modules/minimist/index.js +6 -2
- package/node_modules/minimist/package.json +10 -11
- package/node_modules/minimist/readme.markdown +4 -1
- package/node_modules/minimist/test/proto.js +16 -0
- package/node_modules/node-abi/node_modules/semver/README.md +3 -1
- package/node_modules/node-abi/node_modules/semver/bin/semver.js +19 -9
- package/node_modules/node-abi/node_modules/semver/classes/comparator.js +3 -2
- package/node_modules/node-abi/node_modules/semver/classes/index.js +1 -1
- package/node_modules/node-abi/node_modules/semver/classes/range.js +31 -22
- package/node_modules/node-abi/node_modules/semver/classes/semver.js +1 -1
- package/node_modules/node-abi/node_modules/semver/functions/cmp.js +8 -4
- package/node_modules/node-abi/node_modules/semver/functions/coerce.js +3 -2
- package/node_modules/node-abi/node_modules/semver/functions/inc.js +4 -1
- package/node_modules/node-abi/node_modules/semver/functions/parse.js +1 -1
- package/node_modules/node-abi/node_modules/semver/internal/constants.js +2 -2
- package/node_modules/node-abi/node_modules/semver/internal/identifiers.js +1 -1
- package/node_modules/node-abi/node_modules/semver/internal/parse-options.js +3 -3
- package/node_modules/node-abi/node_modules/semver/internal/re.js +3 -3
- package/node_modules/node-abi/node_modules/semver/package.json +51 -18
- package/node_modules/node-abi/node_modules/semver/ranges/min-version.js +2 -1
- package/node_modules/node-abi/node_modules/semver/ranges/outside.js +1 -1
- package/node_modules/node-abi/node_modules/semver/ranges/simplify.js +15 -12
- package/node_modules/node-abi/node_modules/semver/ranges/subset.js +53 -31
- package/node_modules/node-abi/package.json +1 -0
- package/node_modules/npmlog/node_modules/are-we-there-yet/package.json +10 -10
- package/node_modules/npmlog/package.json +1 -1
- package/node_modules/tar-stream/node_modules/bl/.travis.yml +4 -3
- package/node_modules/tar-stream/node_modules/bl/BufferList.js +1 -1
- package/node_modules/tar-stream/node_modules/bl/package.json +10 -10
- package/node_modules/tar-stream/node_modules/bl/test/test.js +20 -2
- package/node_modules/wide-align/LICENSE +0 -0
- package/node_modules/wide-align/README.md +0 -0
- package/node_modules/wide-align/align.js +0 -0
- package/node_modules/wide-align/package.json +14 -14
- package/package.json +12 -4
- package/src/data-channel-wrapper.cpp +90 -40
- package/src/data-channel-wrapper.h +2 -0
- package/src/media-audio-wrapper.cpp +5 -5
- package/src/media-track-wrapper.cpp +96 -38
- package/src/media-track-wrapper.h +1 -0
- package/src/media-video-wrapper.cpp +5 -5
- package/src/peer-connection-wrapper.cpp +111 -54
- package/test/connectivity.js +22 -21
- package/test/test.js +25 -33
- package/node_modules/node-abi/node_modules/semver/CHANGELOG.md +0 -111
package/lib/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import * as stream from 'stream';
|
|
|
3
3
|
export as namespace NodeDataChannel;
|
|
4
4
|
|
|
5
5
|
// Enum in d.ts is tricky
|
|
6
|
-
export type LogLevel =
|
|
6
|
+
export type LogLevel = 'Verbose' | 'Debug' | 'Info' | 'Warning' | 'Error' | 'Fatal';
|
|
7
7
|
|
|
8
8
|
// SCTP Settings
|
|
9
9
|
export interface SctpSettings {
|
|
@@ -22,11 +22,11 @@ export function cleanup(): void;
|
|
|
22
22
|
export function setSctpSettings(settings: SctpSettings): void;
|
|
23
23
|
|
|
24
24
|
// Proxy Server
|
|
25
|
-
export type ProxyServerType = '
|
|
25
|
+
export type ProxyServerType = 'Socks5' | 'Http';
|
|
26
26
|
export interface ProxyServer {
|
|
27
27
|
type: ProxyServerType;
|
|
28
28
|
ip: string;
|
|
29
|
-
port:
|
|
29
|
+
port: number;
|
|
30
30
|
username?: string;
|
|
31
31
|
password?: string;
|
|
32
32
|
}
|
|
@@ -34,12 +34,12 @@ export interface ProxyServer {
|
|
|
34
34
|
export const enum RelayType {
|
|
35
35
|
TurnUdp = 'TurnUdp',
|
|
36
36
|
TurnTcp = 'TurnTcp',
|
|
37
|
-
TurnTls = 'TurnTls'
|
|
37
|
+
TurnTls = 'TurnTls',
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
export interface IceServer {
|
|
41
41
|
hostname: string;
|
|
42
|
-
port:
|
|
42
|
+
port: number;
|
|
43
43
|
username?: string;
|
|
44
44
|
password?: string;
|
|
45
45
|
relayType?: RelayType;
|
|
@@ -61,11 +61,13 @@ export const enum DescriptionType {
|
|
|
61
61
|
Offer = 'Offer',
|
|
62
62
|
Answer = 'Answer',
|
|
63
63
|
Pranswer = 'Pranswer',
|
|
64
|
-
Rollback = 'Rollback'
|
|
64
|
+
Rollback = 'Rollback',
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
export const enum ReliabilityType {
|
|
68
|
-
Reliable = 0,
|
|
68
|
+
Reliable = 0,
|
|
69
|
+
Rexmit = 1,
|
|
70
|
+
Timed = 2,
|
|
69
71
|
}
|
|
70
72
|
|
|
71
73
|
export interface DataChannelInitConfig {
|
|
@@ -81,7 +83,7 @@ export interface DataChannelInitConfig {
|
|
|
81
83
|
type?: ReliabilityType;
|
|
82
84
|
unordered?: boolean;
|
|
83
85
|
rexmit?: number;
|
|
84
|
-
}
|
|
86
|
+
};
|
|
85
87
|
}
|
|
86
88
|
|
|
87
89
|
export interface SelectedCandidateInfo {
|
|
@@ -97,136 +99,131 @@ export const enum Direction {
|
|
|
97
99
|
RecvOnly = 'RecvOnly',
|
|
98
100
|
SendRecv = 'SendRecv',
|
|
99
101
|
Inactive = 'Inactive',
|
|
100
|
-
Unknown = 'Unknown'
|
|
102
|
+
Unknown = 'Unknown',
|
|
101
103
|
}
|
|
102
104
|
|
|
103
105
|
export class RtcpReceivingSession {
|
|
104
|
-
requestBitrate
|
|
105
|
-
requestKeyframe
|
|
106
|
+
requestBitrate(bitRate: number): void;
|
|
107
|
+
requestKeyframe(): boolean;
|
|
106
108
|
}
|
|
107
109
|
|
|
108
110
|
export class Audio {
|
|
109
111
|
constructor(mid: string, dir: Direction);
|
|
110
|
-
addAudioCodec
|
|
111
|
-
addOpusCodec
|
|
112
|
-
|
|
113
|
-
direction
|
|
114
|
-
generateSdp
|
|
115
|
-
mid
|
|
116
|
-
setDirection
|
|
117
|
-
description
|
|
118
|
-
removeFormat
|
|
119
|
-
addSSRC
|
|
120
|
-
removeSSRC
|
|
121
|
-
replaceSSRC
|
|
122
|
-
hasSSRC
|
|
123
|
-
getSSRCs
|
|
124
|
-
getCNameForSsrc
|
|
125
|
-
setBitrate
|
|
126
|
-
getBitrate
|
|
127
|
-
hasPayloadType
|
|
128
|
-
addRTXCodec
|
|
129
|
-
addRTPMap
|
|
130
|
-
parseSdpLine
|
|
112
|
+
addAudioCodec(payloadType: number, codec: string, profile?: string): void;
|
|
113
|
+
addOpusCodec(payloadType: number, profile?: string): string;
|
|
114
|
+
|
|
115
|
+
direction(): Direction;
|
|
116
|
+
generateSdp(eol: string, addr: string, port: number): string;
|
|
117
|
+
mid(): string;
|
|
118
|
+
setDirection(dir: Direction): void;
|
|
119
|
+
description(): string;
|
|
120
|
+
removeFormat(fmt: string): void;
|
|
121
|
+
addSSRC(ssrc: number, name?: string, msid?: string, trackID?: string): void;
|
|
122
|
+
removeSSRC(ssrc: number): void;
|
|
123
|
+
replaceSSRC(oldSsrc: number, ssrc: number, name?: string, msid?: string, trackID?: string): void;
|
|
124
|
+
hasSSRC(ssrc: number): boolean;
|
|
125
|
+
getSSRCs(): number[];
|
|
126
|
+
getCNameForSsrc(ssrc: number): string;
|
|
127
|
+
setBitrate(bitRate: number): void;
|
|
128
|
+
getBitrate(): number;
|
|
129
|
+
hasPayloadType(payloadType: number): boolean;
|
|
130
|
+
addRTXCodec(payloadType: number, originalPayloadType: number, clockRate: number): void;
|
|
131
|
+
addRTPMap(): void;
|
|
132
|
+
parseSdpLine(line: string): void;
|
|
131
133
|
}
|
|
132
134
|
|
|
133
135
|
export class Video {
|
|
134
136
|
constructor(mid: string, dir: Direction);
|
|
135
|
-
addVideoCodec
|
|
136
|
-
addH264Codec
|
|
137
|
-
addVP8Codec
|
|
138
|
-
addVP9Codec
|
|
139
|
-
|
|
140
|
-
direction
|
|
141
|
-
generateSdp
|
|
142
|
-
mid
|
|
143
|
-
setDirection
|
|
144
|
-
description
|
|
145
|
-
removeFormat
|
|
146
|
-
addSSRC
|
|
147
|
-
removeSSRC
|
|
148
|
-
replaceSSRC
|
|
149
|
-
hasSSRC
|
|
150
|
-
getSSRCs
|
|
151
|
-
getCNameForSsrc
|
|
152
|
-
setBitrate
|
|
153
|
-
getBitrate
|
|
154
|
-
hasPayloadType
|
|
155
|
-
addRTXCodec
|
|
156
|
-
addRTPMap
|
|
157
|
-
parseSdpLine
|
|
137
|
+
addVideoCodec(payloadType: number, codec: string, profile?: string): void;
|
|
138
|
+
addH264Codec(payloadType: number, profile?: string): void;
|
|
139
|
+
addVP8Codec(payloadType: number): void;
|
|
140
|
+
addVP9Codec(payloadType: number): void;
|
|
141
|
+
|
|
142
|
+
direction(): Direction;
|
|
143
|
+
generateSdp(eol: string, addr: string, port: number): string;
|
|
144
|
+
mid(): string;
|
|
145
|
+
setDirection(dir: Direction): void;
|
|
146
|
+
description(): string;
|
|
147
|
+
removeFormat(fmt: string): void;
|
|
148
|
+
addSSRC(ssrc: number, name?: string, msid?: string, trackID?: string): void;
|
|
149
|
+
removeSSRC(ssrc: number): void;
|
|
150
|
+
replaceSSRC(oldSsrc: number, ssrc: number, name?: string, msid?: string, trackID?: string): void;
|
|
151
|
+
hasSSRC(ssrc: number): boolean;
|
|
152
|
+
getSSRCs(): number[];
|
|
153
|
+
getCNameForSsrc(ssrc: number): string;
|
|
154
|
+
setBitrate(bitRate: number): void;
|
|
155
|
+
getBitrate(): number;
|
|
156
|
+
hasPayloadType(payloadType: number): boolean;
|
|
157
|
+
addRTXCodec(payloadType: number, originalPayloadType: number, clockRate: number): void;
|
|
158
|
+
addRTPMap(): void;
|
|
159
|
+
parseSdpLine(line: string): void;
|
|
158
160
|
}
|
|
159
161
|
|
|
160
162
|
export class Track {
|
|
161
|
-
direction
|
|
162
|
-
mid
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
bufferedAmount
|
|
170
|
-
maxMessageSize
|
|
171
|
-
setBufferedAmountLowThreshold
|
|
172
|
-
requestKeyframe
|
|
173
|
-
setMediaHandler
|
|
174
|
-
onOpen
|
|
175
|
-
onClosed
|
|
176
|
-
onError
|
|
177
|
-
|
|
178
|
-
onBufferedAmountLow: (cb: () => void) => void;
|
|
179
|
-
onMessage: (cb: (msg: string | Buffer) => void) => void;
|
|
163
|
+
direction(): Direction;
|
|
164
|
+
mid(): string;
|
|
165
|
+
type(): string;
|
|
166
|
+
close(): void;
|
|
167
|
+
sendMessage(msg: string): boolean;
|
|
168
|
+
sendMessageBinary(buffer: Buffer): boolean;
|
|
169
|
+
isOpen(): boolean;
|
|
170
|
+
isClosed(): boolean;
|
|
171
|
+
bufferedAmount(): number;
|
|
172
|
+
maxMessageSize(): number;
|
|
173
|
+
setBufferedAmountLowThreshold(newSize: number): void;
|
|
174
|
+
requestKeyframe(): boolean;
|
|
175
|
+
setMediaHandler(handler: RtcpReceivingSession): void;
|
|
176
|
+
onOpen(cb: () => void): void;
|
|
177
|
+
onClosed(cb: () => void): void;
|
|
178
|
+
onError(cb: (err: string) => void): void;
|
|
179
|
+
onMessage(cb: (msg: Buffer) => void): void;
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
export class DataChannel {
|
|
183
|
-
close
|
|
184
|
-
getLabel
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
onBufferedAmountLow
|
|
197
|
-
onMessage
|
|
183
|
+
close(): void;
|
|
184
|
+
getLabel(): string;
|
|
185
|
+
getId(): number;
|
|
186
|
+
getProtocol(): string;
|
|
187
|
+
sendMessage(msg: string): boolean;
|
|
188
|
+
sendMessageBinary(buffer: Buffer): boolean;
|
|
189
|
+
isOpen(): boolean;
|
|
190
|
+
bufferedAmount(): number;
|
|
191
|
+
maxMessageSize(): number;
|
|
192
|
+
setBufferedAmountLowThreshold(newSize: number): void;
|
|
193
|
+
onOpen(cb: () => void): void;
|
|
194
|
+
onClosed(cb: () => void): void;
|
|
195
|
+
onError(cb: (err: string) => void): void;
|
|
196
|
+
onBufferedAmountLow(cb: () => void): void;
|
|
197
|
+
onMessage(cb: (msg: string | Buffer) => void): void;
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
export class PeerConnection {
|
|
201
201
|
constructor(peerName: string, config: RtcConfig);
|
|
202
|
-
close
|
|
203
|
-
setLocalDescription
|
|
204
|
-
setRemoteDescription
|
|
205
|
-
localDescription
|
|
206
|
-
addRemoteCandidate
|
|
207
|
-
createDataChannel
|
|
208
|
-
addTrack
|
|
209
|
-
hasMedia
|
|
210
|
-
state
|
|
211
|
-
signalingState
|
|
212
|
-
gatheringState
|
|
213
|
-
onLocalDescription
|
|
214
|
-
onLocalCandidate
|
|
215
|
-
onStateChange
|
|
216
|
-
onSignalingStateChange: (state:
|
|
217
|
-
onGatheringStateChange: (state:
|
|
218
|
-
onDataChannel
|
|
219
|
-
onTrack: () =>
|
|
220
|
-
bytesSent
|
|
221
|
-
bytesReceived
|
|
222
|
-
rtt
|
|
223
|
-
getSelectedCandidatePair
|
|
202
|
+
close(): void;
|
|
203
|
+
setLocalDescription(type?: DescriptionType): void;
|
|
204
|
+
setRemoteDescription(sdp: string, type: DescriptionType): void;
|
|
205
|
+
localDescription(): { type: string; sdp: string } | null;
|
|
206
|
+
addRemoteCandidate(candidate: string, mid: string): void;
|
|
207
|
+
createDataChannel(label: string, config?: DataChannelInitConfig): DataChannel;
|
|
208
|
+
addTrack(media: Video | Audio): Track;
|
|
209
|
+
hasMedia(): boolean;
|
|
210
|
+
state(): string;
|
|
211
|
+
signalingState(): string;
|
|
212
|
+
gatheringState(): string;
|
|
213
|
+
onLocalDescription(cb: (sdp: string, type: DescriptionType) => void): void;
|
|
214
|
+
onLocalCandidate(cb: (candidate: string, mid: string) => void): void;
|
|
215
|
+
onStateChange(cb: (state: string) => void): void;
|
|
216
|
+
onSignalingStateChange(cb: (state: string) => void): void;
|
|
217
|
+
onGatheringStateChange(cb: (state: string) => void): void;
|
|
218
|
+
onDataChannel(cb: (dc: DataChannel) => void): void;
|
|
219
|
+
onTrack(cb: (track: Track) => void): void;
|
|
220
|
+
bytesSent(): number;
|
|
221
|
+
bytesReceived(): number;
|
|
222
|
+
rtt(): number;
|
|
223
|
+
getSelectedCandidatePair(): { local: SelectedCandidateInfo; remote: SelectedCandidateInfo } | null;
|
|
224
224
|
}
|
|
225
225
|
|
|
226
226
|
export class DataChannelStream extends stream.Duplex {
|
|
227
|
-
constructor(
|
|
228
|
-
rawChannel: DataChannel,
|
|
229
|
-
options?: Omit<stream.DuplexOptions, 'objectMode'>
|
|
230
|
-
);
|
|
227
|
+
constructor(rawChannel: DataChannel, options?: Omit<stream.DuplexOptions, 'objectMode'>);
|
|
231
228
|
get label(): string;
|
|
232
|
-
}
|
|
229
|
+
}
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
2
|
+
const nodeDataChannel = require('../build/Release/node_datachannel.node');
|
|
2
3
|
module.exports = nodeDataChannel;
|
|
3
4
|
|
|
4
|
-
module.exports.DataChannelStream = require('./datachannel-stream');
|
|
5
|
+
module.exports.DataChannelStream = require('./datachannel-stream');
|
|
@@ -70,7 +70,7 @@ module.exports = function (args, opts) {
|
|
|
70
70
|
var o = obj;
|
|
71
71
|
for (var i = 0; i < keys.length-1; i++) {
|
|
72
72
|
var key = keys[i];
|
|
73
|
-
if (key
|
|
73
|
+
if (isConstructorOrProto(o, key)) return;
|
|
74
74
|
if (o[key] === undefined) o[key] = {};
|
|
75
75
|
if (o[key] === Object.prototype || o[key] === Number.prototype
|
|
76
76
|
|| o[key] === String.prototype) o[key] = {};
|
|
@@ -79,7 +79,7 @@ module.exports = function (args, opts) {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
var key = keys[keys.length - 1];
|
|
82
|
-
if (key
|
|
82
|
+
if (isConstructorOrProto(o, key)) return;
|
|
83
83
|
if (o === Object.prototype || o === Number.prototype
|
|
84
84
|
|| o === String.prototype) o = {};
|
|
85
85
|
if (o === Array.prototype) o = [];
|
|
@@ -243,3 +243,7 @@ function isNumber (x) {
|
|
|
243
243
|
return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
|
|
244
244
|
}
|
|
245
245
|
|
|
246
|
+
|
|
247
|
+
function isConstructorOrProto (obj, key) {
|
|
248
|
+
return key === 'constructor' && typeof obj[key] === 'function' || key === '__proto__';
|
|
249
|
+
}
|
|
@@ -1,35 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"_args": [
|
|
3
3
|
[
|
|
4
|
-
"minimist@1.2.
|
|
4
|
+
"minimist@1.2.6",
|
|
5
5
|
"/home/runner/work/node-datachannel/node-datachannel"
|
|
6
6
|
]
|
|
7
7
|
],
|
|
8
|
-
"_from": "minimist@1.2.
|
|
9
|
-
"_id": "minimist@1.2.
|
|
8
|
+
"_from": "minimist@1.2.6",
|
|
9
|
+
"_id": "minimist@1.2.6",
|
|
10
10
|
"_inBundle": false,
|
|
11
|
-
"_integrity": "sha512-
|
|
11
|
+
"_integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==",
|
|
12
12
|
"_location": "/minimist",
|
|
13
13
|
"_phantomChildren": {},
|
|
14
14
|
"_requested": {
|
|
15
15
|
"type": "version",
|
|
16
16
|
"registry": true,
|
|
17
|
-
"raw": "minimist@1.2.
|
|
17
|
+
"raw": "minimist@1.2.6",
|
|
18
18
|
"name": "minimist",
|
|
19
19
|
"escapedName": "minimist",
|
|
20
|
-
"rawSpec": "1.2.
|
|
20
|
+
"rawSpec": "1.2.6",
|
|
21
21
|
"saveSpec": null,
|
|
22
|
-
"fetchSpec": "1.2.
|
|
22
|
+
"fetchSpec": "1.2.6"
|
|
23
23
|
},
|
|
24
24
|
"_requiredBy": [
|
|
25
|
-
"/json5",
|
|
26
25
|
"/mkdirp",
|
|
27
26
|
"/prebuild",
|
|
28
27
|
"/prebuild-install",
|
|
29
28
|
"/rc"
|
|
30
29
|
],
|
|
31
|
-
"_resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.
|
|
32
|
-
"_spec": "1.2.
|
|
30
|
+
"_resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz",
|
|
31
|
+
"_spec": "1.2.6",
|
|
33
32
|
"_where": "/home/runner/work/node-datachannel/node-datachannel",
|
|
34
33
|
"author": {
|
|
35
34
|
"name": "James Halliday",
|
|
@@ -76,5 +75,5 @@
|
|
|
76
75
|
"opera/12"
|
|
77
76
|
]
|
|
78
77
|
},
|
|
79
|
-
"version": "1.2.
|
|
78
|
+
"version": "1.2.6"
|
|
80
79
|
}
|
|
@@ -34,7 +34,10 @@ $ node example/parse.js -x 3 -y 4 -n5 -abc --beep=boop foo bar baz
|
|
|
34
34
|
Previous versions had a prototype pollution bug that could cause privilege
|
|
35
35
|
escalation in some circumstances when handling untrusted user input.
|
|
36
36
|
|
|
37
|
-
Please use version 1.2.
|
|
37
|
+
Please use version 1.2.6 or later:
|
|
38
|
+
|
|
39
|
+
* https://security.snyk.io/vuln/SNYK-JS-MINIMIST-2429795 (version <=1.2.5)
|
|
40
|
+
* https://snyk.io/vuln/SNYK-JS-MINIMIST-559764 (version <=1.2.3)
|
|
38
41
|
|
|
39
42
|
# methods
|
|
40
43
|
|
|
@@ -42,3 +42,19 @@ test('proto pollution (constructor)', function (t) {
|
|
|
42
42
|
t.equal(argv.y, undefined);
|
|
43
43
|
t.end();
|
|
44
44
|
});
|
|
45
|
+
|
|
46
|
+
test('proto pollution (constructor function)', function (t) {
|
|
47
|
+
var argv = parse(['--_.concat.constructor.prototype.y', '123']);
|
|
48
|
+
function fnToBeTested() {}
|
|
49
|
+
t.equal(fnToBeTested.y, undefined);
|
|
50
|
+
t.equal(argv.y, undefined);
|
|
51
|
+
t.end();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// powered by snyk - https://github.com/backstage/backstage/issues/10343
|
|
55
|
+
test('proto pollution (constructor function) snyk', function (t) {
|
|
56
|
+
var argv = parse('--_.constructor.constructor.prototype.foo bar'.split(' '));
|
|
57
|
+
t.equal((function(){}).foo, undefined);
|
|
58
|
+
t.equal(argv.y, undefined);
|
|
59
|
+
t.end();
|
|
60
|
+
})
|
|
@@ -264,7 +264,9 @@ provided tuple parts.
|
|
|
264
264
|
Any of `X`, `x`, or `*` may be used to "stand in" for one of the
|
|
265
265
|
numeric values in the `[major, minor, patch]` tuple.
|
|
266
266
|
|
|
267
|
-
* `*` := `>=0.0.0` (Any version satisfies
|
|
267
|
+
* `*` := `>=0.0.0` (Any non-prerelease version satisfies, unless
|
|
268
|
+
`includePrerelease` is specified, in which case any version at all
|
|
269
|
+
satisfies)
|
|
268
270
|
* `1.x` := `>=1.0.0 <2.0.0-0` (Matching major version)
|
|
269
271
|
* `1.2.x` := `>=1.2.0 <1.3.0-0` (Matching major and minor versions)
|
|
270
272
|
|
|
@@ -27,16 +27,19 @@ const semver = require('../')
|
|
|
27
27
|
|
|
28
28
|
let reverse = false
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
let options = {}
|
|
31
31
|
|
|
32
32
|
const main = () => {
|
|
33
|
-
if (!argv.length)
|
|
33
|
+
if (!argv.length) {
|
|
34
|
+
return help()
|
|
35
|
+
}
|
|
34
36
|
while (argv.length) {
|
|
35
37
|
let a = argv.shift()
|
|
36
38
|
const indexOfEqualSign = a.indexOf('=')
|
|
37
39
|
if (indexOfEqualSign !== -1) {
|
|
40
|
+
const value = a.slice(indexOfEqualSign + 1)
|
|
38
41
|
a = a.slice(0, indexOfEqualSign)
|
|
39
|
-
argv.unshift(
|
|
42
|
+
argv.unshift(value)
|
|
40
43
|
}
|
|
41
44
|
switch (a) {
|
|
42
45
|
case '-rv': case '-rev': case '--rev': case '--reverse':
|
|
@@ -85,26 +88,31 @@ const main = () => {
|
|
|
85
88
|
}
|
|
86
89
|
}
|
|
87
90
|
|
|
88
|
-
|
|
91
|
+
options = { loose: loose, includePrerelease: includePrerelease, rtl: rtl }
|
|
89
92
|
|
|
90
93
|
versions = versions.map((v) => {
|
|
91
94
|
return coerce ? (semver.coerce(v, options) || { version: v }).version : v
|
|
92
95
|
}).filter((v) => {
|
|
93
96
|
return semver.valid(v)
|
|
94
97
|
})
|
|
95
|
-
if (!versions.length)
|
|
96
|
-
|
|
98
|
+
if (!versions.length) {
|
|
99
|
+
return fail()
|
|
100
|
+
}
|
|
101
|
+
if (inc && (versions.length !== 1 || range.length)) {
|
|
102
|
+
return failInc()
|
|
103
|
+
}
|
|
97
104
|
|
|
98
105
|
for (let i = 0, l = range.length; i < l; i++) {
|
|
99
106
|
versions = versions.filter((v) => {
|
|
100
107
|
return semver.satisfies(v, range[i], options)
|
|
101
108
|
})
|
|
102
|
-
if (!versions.length)
|
|
109
|
+
if (!versions.length) {
|
|
110
|
+
return fail()
|
|
111
|
+
}
|
|
103
112
|
}
|
|
104
113
|
return success(versions)
|
|
105
114
|
}
|
|
106
115
|
|
|
107
|
-
|
|
108
116
|
const failInc = () => {
|
|
109
117
|
console.error('--inc can only be used on a single version with no range')
|
|
110
118
|
fail()
|
|
@@ -120,7 +128,9 @@ const success = () => {
|
|
|
120
128
|
return semver.clean(v, options)
|
|
121
129
|
}).map((v) => {
|
|
122
130
|
return inc ? semver.inc(v, inc, options, identifier) : v
|
|
123
|
-
}).forEach((v, i, _) => {
|
|
131
|
+
}).forEach((v, i, _) => {
|
|
132
|
+
console.log(v)
|
|
133
|
+
})
|
|
124
134
|
}
|
|
125
135
|
|
|
126
136
|
const help = () => console.log(
|
|
@@ -4,6 +4,7 @@ class Comparator {
|
|
|
4
4
|
static get ANY () {
|
|
5
5
|
return ANY
|
|
6
6
|
}
|
|
7
|
+
|
|
7
8
|
constructor (comp, options) {
|
|
8
9
|
options = parseOptions(options)
|
|
9
10
|
|
|
@@ -80,7 +81,7 @@ class Comparator {
|
|
|
80
81
|
if (!options || typeof options !== 'object') {
|
|
81
82
|
options = {
|
|
82
83
|
loose: !!options,
|
|
83
|
-
includePrerelease: false
|
|
84
|
+
includePrerelease: false,
|
|
84
85
|
}
|
|
85
86
|
}
|
|
86
87
|
|
|
@@ -128,7 +129,7 @@ class Comparator {
|
|
|
128
129
|
module.exports = Comparator
|
|
129
130
|
|
|
130
131
|
const parseOptions = require('../internal/parse-options')
|
|
131
|
-
const {re, t} = require('../internal/re')
|
|
132
|
+
const { re, t } = require('../internal/re')
|
|
132
133
|
const cmp = require('../functions/cmp')
|
|
133
134
|
const debug = require('../internal/debug')
|
|
134
135
|
const SemVer = require('./semver')
|