node-datachannel 0.2.1 → 0.2.4
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/.github/workflows/build-linux.yml +2 -0
- package/.github/workflows/build-win.yml +1 -7
- package/CMakeLists.txt +2 -2
- package/README.md +18 -3
- package/lib/datachannel-stream.js +86 -0
- package/lib/index.d.ts +16 -2
- package/lib/index.js +3 -1
- package/node_modules/decompress-response/index.d.ts +14 -21
- package/node_modules/decompress-response/index.js +34 -16
- package/node_modules/decompress-response/license +1 -1
- package/node_modules/decompress-response/package.json +23 -17
- package/node_modules/decompress-response/readme.md +2 -6
- package/node_modules/detect-libc/README.md +124 -42
- package/node_modules/detect-libc/index.d.ts +11 -0
- package/node_modules/detect-libc/lib/detect-libc.js +166 -80
- package/node_modules/detect-libc/lib/process.js +16 -0
- package/node_modules/detect-libc/package.json +20 -20
- package/node_modules/{semver → lru-cache}/LICENSE +0 -0
- package/node_modules/lru-cache/README.md +166 -0
- package/node_modules/lru-cache/index.js +334 -0
- package/node_modules/lru-cache/node_modules/yallist/LICENSE +15 -0
- package/node_modules/lru-cache/node_modules/yallist/README.md +204 -0
- package/node_modules/lru-cache/node_modules/yallist/iterator.js +8 -0
- package/node_modules/lru-cache/node_modules/yallist/package.json +65 -0
- package/node_modules/lru-cache/node_modules/yallist/yallist.js +426 -0
- package/node_modules/lru-cache/package.json +74 -0
- package/node_modules/mimic-response/index.d.ts +2 -2
- package/node_modules/mimic-response/index.js +41 -2
- package/node_modules/mimic-response/package.json +17 -17
- package/node_modules/mimic-response/readme.md +22 -1
- package/node_modules/node-abi/.circleci/config.yml +63 -0
- package/node_modules/node-abi/.releaserc.json +9 -0
- package/node_modules/node-abi/abi_registry.json +45 -3
- package/node_modules/node-abi/index.js +5 -2
- package/node_modules/node-abi/node_modules/semver/CHANGELOG.md +111 -0
- package/node_modules/node-abi/node_modules/semver/LICENSE +15 -0
- package/node_modules/{semver → node-abi/node_modules/semver}/README.md +180 -26
- package/node_modules/node-abi/node_modules/semver/bin/semver.js +173 -0
- package/node_modules/node-abi/node_modules/semver/classes/comparator.js +135 -0
- package/node_modules/node-abi/node_modules/semver/classes/index.js +5 -0
- package/node_modules/node-abi/node_modules/semver/classes/range.js +510 -0
- package/node_modules/node-abi/node_modules/semver/classes/semver.js +287 -0
- package/node_modules/node-abi/node_modules/semver/functions/clean.js +6 -0
- package/node_modules/node-abi/node_modules/semver/functions/cmp.js +48 -0
- package/node_modules/node-abi/node_modules/semver/functions/coerce.js +51 -0
- package/node_modules/node-abi/node_modules/semver/functions/compare-build.js +7 -0
- package/node_modules/node-abi/node_modules/semver/functions/compare-loose.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/compare.js +5 -0
- package/node_modules/node-abi/node_modules/semver/functions/diff.js +23 -0
- package/node_modules/node-abi/node_modules/semver/functions/eq.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/gt.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/gte.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/inc.js +15 -0
- package/node_modules/node-abi/node_modules/semver/functions/lt.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/lte.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/major.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/minor.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/neq.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/parse.js +33 -0
- package/node_modules/node-abi/node_modules/semver/functions/patch.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/prerelease.js +6 -0
- package/node_modules/node-abi/node_modules/semver/functions/rcompare.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/rsort.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/satisfies.js +10 -0
- package/node_modules/node-abi/node_modules/semver/functions/sort.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/valid.js +6 -0
- package/node_modules/node-abi/node_modules/semver/index.js +48 -0
- package/node_modules/node-abi/node_modules/semver/internal/constants.js +17 -0
- package/node_modules/node-abi/node_modules/semver/internal/debug.js +9 -0
- package/node_modules/node-abi/node_modules/semver/internal/identifiers.js +23 -0
- package/node_modules/node-abi/node_modules/semver/internal/parse-options.js +11 -0
- package/node_modules/node-abi/node_modules/semver/internal/re.js +182 -0
- package/node_modules/{semver → node-abi/node_modules/semver}/package.json +32 -23
- package/node_modules/node-abi/node_modules/semver/preload.js +2 -0
- package/node_modules/{semver → node-abi/node_modules/semver}/range.bnf +0 -0
- package/node_modules/node-abi/node_modules/semver/ranges/gtr.js +4 -0
- package/node_modules/node-abi/node_modules/semver/ranges/intersects.js +7 -0
- package/node_modules/node-abi/node_modules/semver/ranges/ltr.js +4 -0
- package/node_modules/node-abi/node_modules/semver/ranges/max-satisfying.js +25 -0
- package/node_modules/node-abi/node_modules/semver/ranges/min-satisfying.js +24 -0
- package/node_modules/node-abi/node_modules/semver/ranges/min-version.js +60 -0
- package/node_modules/node-abi/node_modules/semver/ranges/outside.js +80 -0
- package/node_modules/node-abi/node_modules/semver/ranges/simplify.js +44 -0
- package/node_modules/node-abi/node_modules/semver/ranges/subset.js +222 -0
- package/node_modules/node-abi/node_modules/semver/ranges/to-comparators.js +8 -0
- package/node_modules/node-abi/node_modules/semver/ranges/valid.js +11 -0
- package/node_modules/node-abi/package.json +20 -17
- package/node_modules/node-abi/test/index.js +7 -15
- package/node_modules/prebuild-install/CHANGELOG.md +24 -7
- package/node_modules/prebuild-install/README.md +24 -4
- package/node_modules/prebuild-install/asset.js +10 -10
- package/node_modules/prebuild-install/bin.js +13 -13
- package/node_modules/prebuild-install/download.js +22 -22
- package/node_modules/prebuild-install/log.js +4 -4
- package/node_modules/prebuild-install/package.json +18 -19
- package/node_modules/prebuild-install/proxy.js +10 -10
- package/node_modules/prebuild-install/rc.js +12 -12
- package/node_modules/prebuild-install/util.js +14 -14
- package/node_modules/simple-get/.github/dependabot.yml +15 -0
- package/node_modules/simple-get/.github/workflows/ci.yml +23 -0
- package/node_modules/simple-get/README.md +17 -3
- package/node_modules/simple-get/index.js +9 -0
- package/node_modules/simple-get/package.json +27 -13
- package/package.json +6 -5
- package/src/media-audio-wrapper.cpp +2 -2
- package/src/peer-connection-wrapper.cpp +63 -10
- package/src/peer-connection-wrapper.h +7 -2
- package/test/test.js +45 -0
- package/node_modules/detect-libc/.npmignore +0 -7
- package/node_modules/detect-libc/bin/detect-libc.js +0 -18
- package/node_modules/node-abi/.travis.yml +0 -17
- package/node_modules/semver/CHANGELOG.md +0 -39
- package/node_modules/semver/bin/semver +0 -160
- package/node_modules/semver/semver.js +0 -1483
|
@@ -45,6 +45,7 @@ jobs:
|
|
|
45
45
|
- uses: actions/checkout@v2
|
|
46
46
|
- name: Prepare Cross Compile
|
|
47
47
|
run: |
|
|
48
|
+
sudo apt update
|
|
48
49
|
sudo apt install -y g++-arm-linux-gnueabihf gcc-arm-linux-gnueabihf
|
|
49
50
|
mkdir sysroot && cd sysroot
|
|
50
51
|
wget https://commondatastorage.googleapis.com/chrome-linux-sysroot/toolchain/ef5c4f84bcafb7a3796d36bb1db7826317dde51c/debian_sid_arm_sysroot.tar.xz
|
|
@@ -72,6 +73,7 @@ jobs:
|
|
|
72
73
|
- uses: actions/checkout@v2
|
|
73
74
|
- name: Prepare Cross Compile
|
|
74
75
|
run: |
|
|
76
|
+
sudo apt update
|
|
75
77
|
sudo apt install -y g++-aarch64-linux-gnu gcc-aarch64-linux-gnu
|
|
76
78
|
mkdir sysroot && cd sysroot
|
|
77
79
|
wget https://commondatastorage.googleapis.com/chrome-linux-sysroot/toolchain/953c2471bc7e71a788309f6c2d2003e8b703305d/debian_sid_arm64_sysroot.tar.xz
|
package/CMakeLists.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
cmake_minimum_required(VERSION 3.15)
|
|
2
2
|
cmake_policy(SET CMP0091 NEW)
|
|
3
|
-
project(node_datachannel VERSION 0.2.
|
|
3
|
+
project(node_datachannel VERSION 0.2.4)
|
|
4
4
|
|
|
5
5
|
include_directories(${CMAKE_JS_INC})
|
|
6
6
|
|
|
@@ -27,7 +27,7 @@ include(FetchContent)
|
|
|
27
27
|
FetchContent_Declare(
|
|
28
28
|
libdatachannel
|
|
29
29
|
GIT_REPOSITORY https://github.com/paullouisageneau/libdatachannel.git
|
|
30
|
-
GIT_TAG "v0.16.
|
|
30
|
+
GIT_TAG "v0.16.6"
|
|
31
31
|
)
|
|
32
32
|
|
|
33
33
|
option(NO_MEDIA "Disable media transport support in libdatachannel" OFF)
|
package/README.md
CHANGED
|
@@ -133,7 +133,7 @@ TURN Server Example : turn:USERNAME:PASSWORD@TURN_IP_OR_ADDRESS:PORT
|
|
|
133
133
|
TURN Server Example (TCP) : turn:USERNAME:PASSWORD@TURN_IP_OR_ADDRESS:PORT?transport=tcp
|
|
134
134
|
TURN Server Example (TLS) : turns:USERNAME:PASSWORD@TURN_IP_OR_ADDRESS:PORT
|
|
135
135
|
|
|
136
|
-
```
|
|
136
|
+
```
|
|
137
137
|
|
|
138
138
|
**close: () => void**
|
|
139
139
|
|
|
@@ -179,7 +179,18 @@ export interface DataChannelInitConfig {
|
|
|
179
179
|
export const enum ReliabilityType {
|
|
180
180
|
Reliable = 0, Rexmit = 1, Timed = 2
|
|
181
181
|
}
|
|
182
|
-
```
|
|
182
|
+
```
|
|
183
|
+
**state: () => string**
|
|
184
|
+
|
|
185
|
+
Get current state
|
|
186
|
+
|
|
187
|
+
**signalingState: () => string**
|
|
188
|
+
|
|
189
|
+
Get current signaling state
|
|
190
|
+
|
|
191
|
+
**gatheringState: () => string**
|
|
192
|
+
|
|
193
|
+
Get current gathering state
|
|
183
194
|
|
|
184
195
|
**onLocalDescription: (cb: (sdp: string, type: DescriptionType) => void) => void**
|
|
185
196
|
|
|
@@ -200,6 +211,10 @@ Local Candidate Callback
|
|
|
200
211
|
|
|
201
212
|
State Change Callback
|
|
202
213
|
|
|
214
|
+
**onSignalingStateChange: (state: (sdp: string) => void) => void**
|
|
215
|
+
|
|
216
|
+
Signaling State Change Callback
|
|
217
|
+
|
|
203
218
|
**onGatheringStateChange: (state: (sdp: string) => void) => void**
|
|
204
219
|
|
|
205
220
|
Gathering State Change Callback
|
|
@@ -238,7 +253,7 @@ export interface SelectedCandidateInfo {
|
|
|
238
253
|
|
|
239
254
|
**close: () => void**
|
|
240
255
|
|
|
241
|
-
Close data channel
|
|
256
|
+
Close data channel
|
|
242
257
|
|
|
243
258
|
**getLabel: () => string**
|
|
244
259
|
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
const stream = require('stream');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Turns a node-datachannel DataChannel into a real Node.js stream, complete with buffering,
|
|
5
|
+
* backpressure (up to a point - if the buffer fills up, messages are dropped), and
|
|
6
|
+
* support for piping data elsewhere.
|
|
7
|
+
*
|
|
8
|
+
* Read & written data may be either UTF-8 strings or Buffers - this difference exists at
|
|
9
|
+
* the protocol level, and is preserved here throughout.
|
|
10
|
+
*/
|
|
11
|
+
module.exports = class DataChannelStream extends stream.Duplex {
|
|
12
|
+
|
|
13
|
+
constructor(rawChannel, streamOptions) {
|
|
14
|
+
super({
|
|
15
|
+
allowHalfOpen: false, // Default to autoclose on end().
|
|
16
|
+
...streamOptions,
|
|
17
|
+
objectMode: true // Preserve the string/buffer distinction (WebRTC treats them differently)
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
this._rawChannel = rawChannel;
|
|
21
|
+
this._readActive = true;
|
|
22
|
+
|
|
23
|
+
rawChannel.onMessage((msg) => {
|
|
24
|
+
if (!this._readActive) return; // If the buffer is full, drop messages.
|
|
25
|
+
|
|
26
|
+
// If the push is rejected, we pause reading until the next call to _read().
|
|
27
|
+
this._readActive = this.push(msg);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// When the DataChannel closes, the readable & writable ends close
|
|
31
|
+
rawChannel.onClosed(() => {
|
|
32
|
+
this.push(null);
|
|
33
|
+
this.destroy();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
rawChannel.onError((errMsg) => {
|
|
37
|
+
this.destroy(new Error(`DataChannel error: ${errMsg}`));
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// Buffer all writes until the DataChannel opens
|
|
41
|
+
if (!rawChannel.isOpen()) {
|
|
42
|
+
this.cork();
|
|
43
|
+
rawChannel.onOpen(() => this.uncork());
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
_read() {
|
|
48
|
+
// Stop dropping messages, if the buffer filling up meant we were doing so before.
|
|
49
|
+
this._readActive = true;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
_write(chunk, encoding, callback) {
|
|
53
|
+
let sentOk;
|
|
54
|
+
if (Buffer.isBuffer(chunk)) {
|
|
55
|
+
sentOk = this._rawChannel.sendMessageBinary(chunk);
|
|
56
|
+
} else if (typeof chunk === 'string') {
|
|
57
|
+
sentOk = this._rawChannel.sendMessage(chunk);
|
|
58
|
+
} else {
|
|
59
|
+
const typeName = chunk.constructor.name || typeof chunk;
|
|
60
|
+
callback(new Error(`Cannot write ${typeName} to DataChannel stream`));
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (sentOk) {
|
|
65
|
+
callback(null);
|
|
66
|
+
} else {
|
|
67
|
+
callback(new Error("Failed to write to DataChannel"));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
_final(callback) {
|
|
72
|
+
if (!this.allowHalfOpen) this.destroy();
|
|
73
|
+
callback(null);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
_destroy(maybeErr, callback) {
|
|
77
|
+
// When the stream is destroyed, we close the DataChannel.
|
|
78
|
+
this._rawChannel.close();
|
|
79
|
+
callback(maybeErr);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
get label() {
|
|
83
|
+
return this._rawChannel.getLabel();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as stream from 'stream';
|
|
2
|
+
|
|
1
3
|
export as namespace NodeDataChannel;
|
|
2
4
|
|
|
3
5
|
// Enum in d.ts is tricky
|
|
@@ -90,7 +92,7 @@ export interface SelectedCandidateInfo {
|
|
|
90
92
|
}
|
|
91
93
|
|
|
92
94
|
// Must be same as rtc enum class Direction
|
|
93
|
-
export enum Direction {
|
|
95
|
+
export const enum Direction {
|
|
94
96
|
SendOnly = 'SendOnly',
|
|
95
97
|
RecvOnly = 'RecvOnly',
|
|
96
98
|
SendRecv = 'SendRecv',
|
|
@@ -134,7 +136,7 @@ export class Video {
|
|
|
134
136
|
addH264Codec: (payloadType: Number, profile?: string) => void;
|
|
135
137
|
addVP8Codec: (payloadType: Number) => void;
|
|
136
138
|
addVP9Codec: (payloadType: Number) => void;
|
|
137
|
-
|
|
139
|
+
|
|
138
140
|
direction: () => Direction;
|
|
139
141
|
generateSdp: (eol: string, addr: string, port: string) => string;
|
|
140
142
|
mid: () => string;
|
|
@@ -205,9 +207,13 @@ export class PeerConnection {
|
|
|
205
207
|
createDataChannel: (label: string, config?: DataChannelInitConfig) => DataChannel;
|
|
206
208
|
addTrack: (media: Video | Audio) => Track;
|
|
207
209
|
hasMedia: () => boolean;
|
|
210
|
+
state: () => string;
|
|
211
|
+
signalingState: () => string;
|
|
212
|
+
gatheringState: () => string;
|
|
208
213
|
onLocalDescription: (cb: (sdp: string, type: DescriptionType) => void) => void;
|
|
209
214
|
onLocalCandidate: (cb: (candidate: string, mid: string) => void) => void;
|
|
210
215
|
onStateChange: (cb: (state: string) => void) => void;
|
|
216
|
+
onSignalingStateChange: (state: (sdp: string) => void) => void;
|
|
211
217
|
onGatheringStateChange: (state: (sdp: string) => void) => void;
|
|
212
218
|
onDataChannel: (cb: (dc: DataChannel) => void) => void;
|
|
213
219
|
onTrack: () => Track;
|
|
@@ -216,3 +222,11 @@ export class PeerConnection {
|
|
|
216
222
|
rtt: () => number;
|
|
217
223
|
getSelectedCandidatePair: () => { local: SelectedCandidateInfo, remote: SelectedCandidateInfo } | null;
|
|
218
224
|
}
|
|
225
|
+
|
|
226
|
+
export class DataChannelStream extends stream.Duplex {
|
|
227
|
+
constructor(
|
|
228
|
+
rawChannel: DataChannel,
|
|
229
|
+
options?: Omit<stream.DuplexOptions, 'objectMode'>
|
|
230
|
+
);
|
|
231
|
+
get label(): string;
|
|
232
|
+
}
|
package/lib/index.js
CHANGED
|
@@ -1,29 +1,22 @@
|
|
|
1
1
|
/// <reference types="node"/>
|
|
2
2
|
import {IncomingMessage} from 'http';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
Decompress a HTTP response if needed.
|
|
4
|
+
/**
|
|
5
|
+
Decompress a HTTP response if needed.
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
@param response - The HTTP incoming stream with compressed data.
|
|
8
|
+
@returns The decompressed HTTP response stream.
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
@example
|
|
11
|
+
```
|
|
12
|
+
import {http} from 'http';
|
|
13
|
+
import decompressResponse = require('decompress-response');
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
// TODO: remove this in the next major version, refactor the whole definition to:
|
|
24
|
-
// declare function decompressResponse(response: IncomingMessage): IncomingMessage;
|
|
25
|
-
// export = decompressResponse;
|
|
26
|
-
default: typeof decompressResponse;
|
|
27
|
-
};
|
|
15
|
+
http.get('https://sindresorhus.com', response => {
|
|
16
|
+
response = decompressResponse(response);
|
|
17
|
+
});
|
|
18
|
+
```
|
|
19
|
+
*/
|
|
20
|
+
declare function decompressResponse(response: IncomingMessage): IncomingMessage;
|
|
28
21
|
|
|
29
22
|
export = decompressResponse;
|
|
@@ -1,40 +1,58 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
const {PassThrough
|
|
2
|
+
const {Transform, PassThrough} = require('stream');
|
|
3
3
|
const zlib = require('zlib');
|
|
4
4
|
const mimicResponse = require('mimic-response');
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
module.exports = response => {
|
|
7
7
|
const contentEncoding = (response.headers['content-encoding'] || '').toLowerCase();
|
|
8
8
|
|
|
9
9
|
if (!['gzip', 'deflate', 'br'].includes(contentEncoding)) {
|
|
10
10
|
return response;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
// TODO: Remove this when targeting Node.js 12.
|
|
13
14
|
const isBrotli = contentEncoding === 'br';
|
|
14
15
|
if (isBrotli && typeof zlib.createBrotliDecompress !== 'function') {
|
|
16
|
+
response.destroy(new Error('Brotli is not supported on Node.js < 12'));
|
|
15
17
|
return response;
|
|
16
18
|
}
|
|
17
19
|
|
|
18
|
-
|
|
19
|
-
const stream = new PassThroughStream();
|
|
20
|
+
let isEmpty = true;
|
|
20
21
|
|
|
21
|
-
|
|
22
|
+
const checker = new Transform({
|
|
23
|
+
transform(data, _encoding, callback) {
|
|
24
|
+
isEmpty = false;
|
|
22
25
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
callback(null, data);
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
flush(callback) {
|
|
30
|
+
callback();
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const finalStream = new PassThrough({
|
|
35
|
+
autoDestroy: false,
|
|
36
|
+
destroy(error, callback) {
|
|
37
|
+
response.destroy();
|
|
38
|
+
|
|
39
|
+
callback(error);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const decompressStream = isBrotli ? zlib.createBrotliDecompress() : zlib.createUnzip();
|
|
44
|
+
|
|
45
|
+
decompressStream.once('error', error => {
|
|
46
|
+
if (isEmpty && !response.readable) {
|
|
47
|
+
finalStream.end();
|
|
27
48
|
return;
|
|
28
49
|
}
|
|
29
50
|
|
|
30
|
-
|
|
51
|
+
finalStream.destroy(error);
|
|
31
52
|
});
|
|
32
53
|
|
|
33
|
-
response
|
|
54
|
+
mimicResponse(response, finalStream);
|
|
55
|
+
response.pipe(checker).pipe(decompressStream).pipe(finalStream);
|
|
34
56
|
|
|
35
|
-
return
|
|
57
|
+
return finalStream;
|
|
36
58
|
};
|
|
37
|
-
|
|
38
|
-
module.exports = decompressResponse;
|
|
39
|
-
// TODO: remove this in the next major version
|
|
40
|
-
module.exports.default = decompressResponse;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
|
3
|
+
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
6
|
|
|
@@ -1,59 +1,60 @@
|
|
|
1
1
|
{
|
|
2
2
|
"_args": [
|
|
3
3
|
[
|
|
4
|
-
"decompress-response@
|
|
4
|
+
"decompress-response@6.0.0",
|
|
5
5
|
"/home/runner/work/node-datachannel/node-datachannel"
|
|
6
6
|
]
|
|
7
7
|
],
|
|
8
|
-
"_from": "decompress-response@
|
|
9
|
-
"_id": "decompress-response@
|
|
8
|
+
"_from": "decompress-response@6.0.0",
|
|
9
|
+
"_id": "decompress-response@6.0.0",
|
|
10
10
|
"_inBundle": false,
|
|
11
|
-
"_integrity": "sha512-
|
|
11
|
+
"_integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==",
|
|
12
12
|
"_location": "/decompress-response",
|
|
13
13
|
"_phantomChildren": {},
|
|
14
14
|
"_requested": {
|
|
15
15
|
"type": "version",
|
|
16
16
|
"registry": true,
|
|
17
|
-
"raw": "decompress-response@
|
|
17
|
+
"raw": "decompress-response@6.0.0",
|
|
18
18
|
"name": "decompress-response",
|
|
19
19
|
"escapedName": "decompress-response",
|
|
20
|
-
"rawSpec": "
|
|
20
|
+
"rawSpec": "6.0.0",
|
|
21
21
|
"saveSpec": null,
|
|
22
|
-
"fetchSpec": "
|
|
22
|
+
"fetchSpec": "6.0.0"
|
|
23
23
|
},
|
|
24
24
|
"_requiredBy": [
|
|
25
25
|
"/simple-get"
|
|
26
26
|
],
|
|
27
|
-
"_resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-
|
|
28
|
-
"_spec": "
|
|
27
|
+
"_resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz",
|
|
28
|
+
"_spec": "6.0.0",
|
|
29
29
|
"_where": "/home/runner/work/node-datachannel/node-datachannel",
|
|
30
30
|
"author": {
|
|
31
31
|
"name": "Sindre Sorhus",
|
|
32
32
|
"email": "sindresorhus@gmail.com",
|
|
33
|
-
"url": "sindresorhus.com"
|
|
33
|
+
"url": "https://sindresorhus.com"
|
|
34
34
|
},
|
|
35
35
|
"bugs": {
|
|
36
36
|
"url": "https://github.com/sindresorhus/decompress-response/issues"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"mimic-response": "^
|
|
39
|
+
"mimic-response": "^3.1.0"
|
|
40
40
|
},
|
|
41
41
|
"description": "Decompress a HTTP response if needed",
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@types/node": "^
|
|
43
|
+
"@types/node": "^14.0.1",
|
|
44
44
|
"ava": "^2.2.0",
|
|
45
45
|
"get-stream": "^5.0.0",
|
|
46
|
-
"pify": "^
|
|
47
|
-
"tsd": "^0.
|
|
48
|
-
"xo": "^0.
|
|
46
|
+
"pify": "^5.0.0",
|
|
47
|
+
"tsd": "^0.11.0",
|
|
48
|
+
"xo": "^0.30.0"
|
|
49
49
|
},
|
|
50
50
|
"engines": {
|
|
51
|
-
"node": ">=
|
|
51
|
+
"node": ">=10"
|
|
52
52
|
},
|
|
53
53
|
"files": [
|
|
54
54
|
"index.js",
|
|
55
55
|
"index.d.ts"
|
|
56
56
|
],
|
|
57
|
+
"funding": "https://github.com/sponsors/sindresorhus",
|
|
57
58
|
"homepage": "https://github.com/sindresorhus/decompress-response#readme",
|
|
58
59
|
"keywords": [
|
|
59
60
|
"decompress",
|
|
@@ -81,5 +82,10 @@
|
|
|
81
82
|
"scripts": {
|
|
82
83
|
"test": "xo && ava && tsd"
|
|
83
84
|
},
|
|
84
|
-
"version": "
|
|
85
|
+
"version": "6.0.0",
|
|
86
|
+
"xo": {
|
|
87
|
+
"rules": {
|
|
88
|
+
"@typescript-eslint/prefer-readonly-parameter-types": "off"
|
|
89
|
+
}
|
|
90
|
+
}
|
|
85
91
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# decompress-response [](https://travis-ci.com/sindresorhus/decompress-response)
|
|
2
2
|
|
|
3
3
|
> Decompress a HTTP response if needed
|
|
4
4
|
|
|
@@ -6,14 +6,12 @@ Decompresses the [response](https://nodejs.org/api/http.html#http_class_http_inc
|
|
|
6
6
|
|
|
7
7
|
Used by [`got`](https://github.com/sindresorhus/got).
|
|
8
8
|
|
|
9
|
-
|
|
10
9
|
## Install
|
|
11
10
|
|
|
12
11
|
```
|
|
13
12
|
$ npm install decompress-response
|
|
14
13
|
```
|
|
15
14
|
|
|
16
|
-
|
|
17
15
|
## Usage
|
|
18
16
|
|
|
19
17
|
```js
|
|
@@ -25,7 +23,6 @@ http.get('https://sindresorhus.com', response => {
|
|
|
25
23
|
});
|
|
26
24
|
```
|
|
27
25
|
|
|
28
|
-
|
|
29
26
|
## API
|
|
30
27
|
|
|
31
28
|
### decompressResponse(response)
|
|
@@ -38,12 +35,11 @@ Type: [`http.IncomingMessage`](https://nodejs.org/api/http.html#http_class_http_
|
|
|
38
35
|
|
|
39
36
|
The HTTP incoming stream with compressed data.
|
|
40
37
|
|
|
41
|
-
|
|
42
38
|
---
|
|
43
39
|
|
|
44
40
|
<div align="center">
|
|
45
41
|
<b>
|
|
46
|
-
<a href="https://tidelift.com/subscription/pkg/npm-
|
|
42
|
+
<a href="https://tidelift.com/subscription/pkg/npm-decompress-response?utm_source=npm-decompress-response&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
|
|
47
43
|
</b>
|
|
48
44
|
<br>
|
|
49
45
|
<sub>
|