Marcos commited on
Commit
9307755
·
1 Parent(s): 753cdab

Automated push by deployment script

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. Dockerfile +4 -4
  2. node_modules/.bin/uuid +1 -0
  3. node_modules/.package-lock.json +153 -0
  4. node_modules/@types/webrtc/LICENSE +21 -0
  5. node_modules/@types/webrtc/MediaStream.d.ts +194 -0
  6. node_modules/@types/webrtc/README.md +16 -0
  7. node_modules/@types/webrtc/RTCPeerConnection.d.ts +455 -0
  8. node_modules/@types/webrtc/index.d.ts +8 -0
  9. node_modules/@types/webrtc/package.json +32 -0
  10. node_modules/@types/webrtc/ts5.0/MediaStream.d.ts +194 -0
  11. node_modules/@types/webrtc/ts5.0/RTCPeerConnection.d.ts +459 -0
  12. node_modules/@types/webrtc/ts5.0/index.d.ts +2 -0
  13. node_modules/agent-base/README.md +145 -0
  14. node_modules/agent-base/dist/src/index.d.ts +78 -0
  15. node_modules/agent-base/dist/src/index.js +203 -0
  16. node_modules/agent-base/dist/src/index.js.map +1 -0
  17. node_modules/agent-base/dist/src/promisify.d.ts +4 -0
  18. node_modules/agent-base/dist/src/promisify.js +18 -0
  19. node_modules/agent-base/dist/src/promisify.js.map +1 -0
  20. node_modules/agent-base/package.json +64 -0
  21. node_modules/agent-base/src/index.ts +345 -0
  22. node_modules/agent-base/src/promisify.ts +33 -0
  23. node_modules/bent/.github/workflows/mikeals-workflow.yml +50 -0
  24. node_modules/bent/README.md +104 -0
  25. node_modules/bent/package.json +33 -0
  26. node_modules/bent/src/browser.js +76 -0
  27. node_modules/bent/src/core.js +51 -0
  28. node_modules/bent/src/nodejs.js +178 -0
  29. node_modules/bent/test/test-basics.js +255 -0
  30. node_modules/bent/test/test-compression.js +59 -0
  31. node_modules/bent/test/test-errors.js +124 -0
  32. node_modules/bytesish/.github/workflows/mikeals-workflow.yml +50 -0
  33. node_modules/bytesish/README.md +106 -0
  34. node_modules/bytesish/browser.js +50 -0
  35. node_modules/bytesish/core.js +88 -0
  36. node_modules/bytesish/junit-report-browser.xml +23 -0
  37. node_modules/bytesish/node.js +30 -0
  38. node_modules/bytesish/package.json +27 -0
  39. node_modules/bytesish/test/basics.spec.js +120 -0
  40. node_modules/caseless/LICENSE +28 -0
  41. node_modules/caseless/README.md +45 -0
  42. node_modules/caseless/index.js +67 -0
  43. node_modules/caseless/package.json +27 -0
  44. node_modules/caseless/test.js +67 -0
  45. node_modules/debug/LICENSE +20 -0
  46. node_modules/debug/README.md +481 -0
  47. node_modules/debug/package.json +65 -0
  48. node_modules/debug/src/browser.js +272 -0
  49. node_modules/debug/src/common.js +292 -0
  50. node_modules/debug/src/index.js +10 -0
Dockerfile CHANGED
@@ -52,15 +52,15 @@ WORKDIR /home/node/app
52
 
53
  # Copy package.json and package-lock.json (or yarn.lock) first
54
  # This allows Docker to cache the npm install step if these files don't change
55
- # COPY --chown=node:node backend/package.json backend/package-lock.json* ./
56
  # If you use yarn, uncomment the next line and comment out the npm ci line
57
- COPY --chown=node:node backend/package.json backend/yarn.lock ./
58
 
59
  # Install dependencies
60
  # Using npm ci for cleaner installs if package-lock.json is present
61
- # RUN npm ci --only=production
62
  # If you use yarn, uncomment the next line and comment out the npm ci line
63
- RUN yarn install --production --frozen-lockfile
64
 
65
  # Copy the rest of the application files from the backend directory
66
  COPY --chown=node:node backend/ ./
 
52
 
53
  # Copy package.json and package-lock.json (or yarn.lock) first
54
  # This allows Docker to cache the npm install step if these files don't change
55
+ COPY --chown=node:node backend/package.json backend/package-lock.json* ./
56
  # If you use yarn, uncomment the next line and comment out the npm ci line
57
+ # COPY --chown=node:node backend/package.json backend/yarn.lock ./
58
 
59
  # Install dependencies
60
  # Using npm ci for cleaner installs if package-lock.json is present
61
+ RUN npm ci --only=production
62
  # If you use yarn, uncomment the next line and comment out the npm ci line
63
+ # RUN yarn install --production --frozen-lockfile
64
 
65
  # Copy the rest of the application files from the backend directory
66
  COPY --chown=node:node backend/ ./
node_modules/.bin/uuid ADDED
@@ -0,0 +1 @@
 
 
1
+ ../uuid/dist/bin/uuid
node_modules/.package-lock.json ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "mineru_space",
3
+ "lockfileVersion": 3,
4
+ "requires": true,
5
+ "packages": {
6
+ "node_modules/@types/webrtc": {
7
+ "version": "0.0.37",
8
+ "resolved": "https://registry.npmjs.org/@types/webrtc/-/webrtc-0.0.37.tgz",
9
+ "integrity": "sha512-JGAJC/ZZDhcrrmepU4sPLQLIOIAgs5oIK+Ieq90K8fdaNMhfdfqmYatJdgif1NDQtvrSlTOGJDUYHIDunuufOg==",
10
+ "license": "MIT"
11
+ },
12
+ "node_modules/agent-base": {
13
+ "version": "6.0.2",
14
+ "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz",
15
+ "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==",
16
+ "license": "MIT",
17
+ "dependencies": {
18
+ "debug": "4"
19
+ },
20
+ "engines": {
21
+ "node": ">= 6.0.0"
22
+ }
23
+ },
24
+ "node_modules/bent": {
25
+ "version": "7.3.12",
26
+ "resolved": "https://registry.npmjs.org/bent/-/bent-7.3.12.tgz",
27
+ "integrity": "sha512-T3yrKnVGB63zRuoco/7Ybl7BwwGZR0lceoVG5XmQyMIH9s19SV5m+a8qam4if0zQuAmOQTyPTPmsQBdAorGK3w==",
28
+ "license": "Apache-2.0",
29
+ "dependencies": {
30
+ "bytesish": "^0.4.1",
31
+ "caseless": "~0.12.0",
32
+ "is-stream": "^2.0.0"
33
+ }
34
+ },
35
+ "node_modules/bytesish": {
36
+ "version": "0.4.4",
37
+ "resolved": "https://registry.npmjs.org/bytesish/-/bytesish-0.4.4.tgz",
38
+ "integrity": "sha512-i4uu6M4zuMUiyfZN4RU2+i9+peJh//pXhd9x1oSe1LBkZ3LEbCoygu8W0bXTukU1Jme2txKuotpCZRaC3FLxcQ==",
39
+ "license": "(Apache-2.0 AND MIT)"
40
+ },
41
+ "node_modules/caseless": {
42
+ "version": "0.12.0",
43
+ "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz",
44
+ "integrity": "sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw==",
45
+ "license": "Apache-2.0"
46
+ },
47
+ "node_modules/debug": {
48
+ "version": "4.4.0",
49
+ "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz",
50
+ "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==",
51
+ "license": "MIT",
52
+ "dependencies": {
53
+ "ms": "^2.1.3"
54
+ },
55
+ "engines": {
56
+ "node": ">=6.0"
57
+ },
58
+ "peerDependenciesMeta": {
59
+ "supports-color": {
60
+ "optional": true
61
+ }
62
+ }
63
+ },
64
+ "node_modules/https-proxy-agent": {
65
+ "version": "4.0.0",
66
+ "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-4.0.0.tgz",
67
+ "integrity": "sha512-zoDhWrkR3of1l9QAL8/scJZyLu8j/gBkcwcaQOZh7Gyh/+uJQzGVETdgT30akuwkpL8HTRfssqI3BZuV18teDg==",
68
+ "license": "MIT",
69
+ "dependencies": {
70
+ "agent-base": "5",
71
+ "debug": "4"
72
+ },
73
+ "engines": {
74
+ "node": ">= 6.0.0"
75
+ }
76
+ },
77
+ "node_modules/https-proxy-agent/node_modules/agent-base": {
78
+ "version": "5.1.1",
79
+ "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-5.1.1.tgz",
80
+ "integrity": "sha512-TMeqbNl2fMW0nMjTEPOwe3J/PRFP4vqeoNuQMG0HlMrtm5QxKqdvAkZ1pRBQ/ulIyDD5Yq0nJ7YbdD8ey0TO3g==",
81
+ "license": "MIT",
82
+ "engines": {
83
+ "node": ">= 6.0.0"
84
+ }
85
+ },
86
+ "node_modules/is-stream": {
87
+ "version": "2.0.1",
88
+ "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz",
89
+ "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==",
90
+ "license": "MIT",
91
+ "engines": {
92
+ "node": ">=8"
93
+ },
94
+ "funding": {
95
+ "url": "https://github.com/sponsors/sindresorhus"
96
+ }
97
+ },
98
+ "node_modules/microsoft-cognitiveservices-speech-sdk": {
99
+ "version": "1.43.1",
100
+ "resolved": "https://registry.npmjs.org/microsoft-cognitiveservices-speech-sdk/-/microsoft-cognitiveservices-speech-sdk-1.43.1.tgz",
101
+ "integrity": "sha512-xO/rlhNSodzCNBtlA3edXDO0+8Q2tMG96nNsjE0JiyAR4Ul/qsZtM4iggTSi+Zax3JtYzrH7W+7349vdpJNaTA==",
102
+ "license": "MIT",
103
+ "dependencies": {
104
+ "@types/webrtc": "^0.0.37",
105
+ "agent-base": "^6.0.1",
106
+ "bent": "^7.3.12",
107
+ "https-proxy-agent": "^4.0.0",
108
+ "uuid": "^9.0.0",
109
+ "ws": "^7.5.6"
110
+ }
111
+ },
112
+ "node_modules/ms": {
113
+ "version": "2.1.3",
114
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
115
+ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
116
+ "license": "MIT"
117
+ },
118
+ "node_modules/uuid": {
119
+ "version": "9.0.1",
120
+ "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz",
121
+ "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==",
122
+ "funding": [
123
+ "https://github.com/sponsors/broofa",
124
+ "https://github.com/sponsors/ctavan"
125
+ ],
126
+ "license": "MIT",
127
+ "bin": {
128
+ "uuid": "dist/bin/uuid"
129
+ }
130
+ },
131
+ "node_modules/ws": {
132
+ "version": "7.5.10",
133
+ "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.10.tgz",
134
+ "integrity": "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==",
135
+ "license": "MIT",
136
+ "engines": {
137
+ "node": ">=8.3.0"
138
+ },
139
+ "peerDependencies": {
140
+ "bufferutil": "^4.0.1",
141
+ "utf-8-validate": "^5.0.2"
142
+ },
143
+ "peerDependenciesMeta": {
144
+ "bufferutil": {
145
+ "optional": true
146
+ },
147
+ "utf-8-validate": {
148
+ "optional": true
149
+ }
150
+ }
151
+ }
152
+ }
153
+ }
node_modules/@types/webrtc/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) Microsoft Corporation.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE
node_modules/@types/webrtc/MediaStream.d.ts ADDED
@@ -0,0 +1,194 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Taken from http://dev.w3.org/2011/webrtc/editor/getusermedia.html
2
+ // version: W3C Editor's Draft 29 June 2015
3
+
4
+ interface ConstrainBooleanParameters {
5
+ exact?: boolean | undefined;
6
+ ideal?: boolean | undefined;
7
+ }
8
+
9
+ interface NumberRange {
10
+ max?: number | undefined;
11
+ min?: number | undefined;
12
+ }
13
+
14
+ interface ConstrainNumberRange extends NumberRange {
15
+ exact?: number | undefined;
16
+ ideal?: number | undefined;
17
+ }
18
+
19
+ interface ConstrainStringParameters {
20
+ exact?: string | string[] | undefined;
21
+ ideal?: string | string[] | undefined;
22
+ }
23
+
24
+ interface MediaStreamConstraints {
25
+ video?: boolean | MediaTrackConstraints | undefined;
26
+ audio?: boolean | MediaTrackConstraints | undefined;
27
+ }
28
+
29
+ declare namespace W3C {
30
+ type LongRange = NumberRange;
31
+ type DoubleRange = NumberRange;
32
+ type ConstrainBoolean = boolean | ConstrainBooleanParameters;
33
+ type ConstrainNumber = number | ConstrainNumberRange;
34
+ type ConstrainLong = ConstrainNumber;
35
+ type ConstrainDouble = ConstrainNumber;
36
+ type ConstrainString = string | string[] | ConstrainStringParameters;
37
+ }
38
+
39
+ interface MediaTrackConstraints extends MediaTrackConstraintSet {
40
+ advanced?: MediaTrackConstraintSet[] | undefined;
41
+ }
42
+
43
+ interface MediaTrackConstraintSet {
44
+ width?: W3C.ConstrainLong | undefined;
45
+ height?: W3C.ConstrainLong | undefined;
46
+ aspectRatio?: W3C.ConstrainDouble | undefined;
47
+ frameRate?: W3C.ConstrainDouble | undefined;
48
+ facingMode?: W3C.ConstrainString | undefined;
49
+ volume?: W3C.ConstrainDouble | undefined;
50
+ sampleRate?: W3C.ConstrainLong | undefined;
51
+ sampleSize?: W3C.ConstrainLong | undefined;
52
+ echoCancellation?: W3C.ConstrainBoolean | undefined;
53
+ latency?: W3C.ConstrainDouble | undefined;
54
+ deviceId?: W3C.ConstrainString | undefined;
55
+ groupId?: W3C.ConstrainString | undefined;
56
+ }
57
+
58
+ interface MediaTrackSupportedConstraints {
59
+ width?: boolean | undefined;
60
+ height?: boolean | undefined;
61
+ aspectRatio?: boolean | undefined;
62
+ frameRate?: boolean | undefined;
63
+ facingMode?: boolean | undefined;
64
+ volume?: boolean | undefined;
65
+ sampleRate?: boolean | undefined;
66
+ sampleSize?: boolean | undefined;
67
+ echoCancellation?: boolean | undefined;
68
+ latency?: boolean | undefined;
69
+ deviceId?: boolean | undefined;
70
+ groupId?: boolean | undefined;
71
+ }
72
+
73
+ interface MediaStream extends EventTarget {
74
+ // id: string;
75
+ // active: boolean;
76
+
77
+ // onactive: EventListener;
78
+ // oninactive: EventListener;
79
+ // onaddtrack: (event: MediaStreamTrackEvent) => any;
80
+ // onremovetrack: (event: MediaStreamTrackEvent) => any;
81
+
82
+ clone(): MediaStream;
83
+ stop(): void;
84
+
85
+ getAudioTracks(): MediaStreamTrack[];
86
+ getVideoTracks(): MediaStreamTrack[];
87
+ getTracks(): MediaStreamTrack[];
88
+
89
+ getTrackById(trackId: string): MediaStreamTrack;
90
+
91
+ addTrack(track: MediaStreamTrack): void;
92
+ removeTrack(track: MediaStreamTrack): void;
93
+ }
94
+
95
+ interface MediaStreamTrackEvent extends Event {
96
+ // track: MediaStreamTrack;
97
+ }
98
+
99
+ interface MediaStreamTrack extends EventTarget {
100
+ // id: string;
101
+ // kind: string;
102
+ // label: string;
103
+ enabled: boolean;
104
+ // muted: boolean;
105
+ // remote: boolean;
106
+ // readyState: MediaStreamTrackState;
107
+
108
+ // onmute: EventListener;
109
+ // onunmute: EventListener;
110
+ // onended: EventListener;
111
+ // onoverconstrained: EventListener;
112
+
113
+ clone(): MediaStreamTrack;
114
+
115
+ stop(): void;
116
+
117
+ getCapabilities(): MediaTrackCapabilities;
118
+ getConstraints(): MediaTrackConstraints;
119
+ getSettings(): MediaTrackSettings;
120
+ applyConstraints(constraints: MediaTrackConstraints): Promise<void>;
121
+ }
122
+
123
+ interface MediaTrackCapabilities {
124
+ // width: number | W3C.LongRange;
125
+ // height: number | W3C.LongRange;
126
+ // aspectRatio: number | W3C.DoubleRange;
127
+ // frameRate: number | W3C.DoubleRange;
128
+ // facingMode: string;
129
+ // volume: number | W3C.DoubleRange;
130
+ // sampleRate: number | W3C.LongRange;
131
+ // sampleSize: number | W3C.LongRange;
132
+ // echoCancellation: boolean[];
133
+ latency?: W3C.DoubleRange | undefined;
134
+ // deviceId: string;
135
+ // groupId: string;
136
+ }
137
+
138
+ interface MediaTrackSettings {
139
+ // width: number;
140
+ // height: number;
141
+ // aspectRatio: number;
142
+ // frameRate: number;
143
+ // facingMode: string;
144
+ // volume: number;
145
+ // sampleRate: number;
146
+ // sampleSize: number;
147
+ // echoCancellation: boolean;
148
+ latency?: number | undefined;
149
+ // deviceId: string;
150
+ // groupId: string;
151
+ }
152
+
153
+ interface MediaStreamError {
154
+ readonly name: string;
155
+ readonly message: string | null;
156
+ readonly constraintName: string | null;
157
+ }
158
+
159
+ interface NavigatorGetUserMedia {
160
+ (
161
+ constraints: MediaStreamConstraints,
162
+ successCallback: (stream: MediaStream) => void,
163
+ errorCallback: (error: MediaStreamError) => void,
164
+ ): void;
165
+ }
166
+
167
+ // to use with adapter.js, see: https://github.com/webrtc/adapter
168
+ declare var getUserMedia: NavigatorGetUserMedia;
169
+
170
+ interface Navigator {
171
+ getUserMedia: NavigatorGetUserMedia;
172
+
173
+ webkitGetUserMedia: NavigatorGetUserMedia;
174
+
175
+ mozGetUserMedia: NavigatorGetUserMedia;
176
+
177
+ msGetUserMedia: NavigatorGetUserMedia;
178
+
179
+ readonly mediaDevices: MediaDevices;
180
+ }
181
+
182
+ interface MediaDevices {
183
+ getSupportedConstraints(): MediaTrackSupportedConstraints;
184
+
185
+ getUserMedia(constraints: MediaStreamConstraints): Promise<MediaStream>;
186
+ enumerateDevices(): Promise<MediaDeviceInfo[]>;
187
+ }
188
+
189
+ interface MediaDeviceInfo {
190
+ // label: string;
191
+ // deviceId: string;
192
+ // kind: string;
193
+ // groupId: string;
194
+ }
node_modules/@types/webrtc/README.md ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Installation
2
+ > `npm install --save @types/webrtc`
3
+
4
+ # Summary
5
+ This package contains type definitions for webrtc (https://webrtc.org/).
6
+
7
+ # Details
8
+ Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/webrtc.
9
+
10
+ ### Additional Details
11
+ * Last updated: Mon, 25 Sep 2023 13:39:07 GMT
12
+ * Dependencies: none
13
+ * Global values: `RTCError`, `RTCErrorEvent`, `getUserMedia`
14
+
15
+ # Credits
16
+ These definitions were written by [Toshiya Nakakura](https://github.com/nakakura).
node_modules/@types/webrtc/RTCPeerConnection.d.ts ADDED
@@ -0,0 +1,455 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // W3 Spec: https://www.w3.org/TR/webrtc/
2
+ //
3
+ // Note: Commented out definitions clash with definitions in lib.es6.d.ts. I
4
+ // still kept them in here though, as sometimes they're more specific than the
5
+ // ES6 library ones.
6
+
7
+ /// <reference path='MediaStream.d.ts' />
8
+
9
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcerror
10
+ interface RTCError extends DOMException {
11
+ readonly errorDetail: RTCErrorDetailType;
12
+ readonly httpRequestStatusCode: number | null;
13
+ readonly receivedAlert: number | null;
14
+ readonly sctpCauseCode: number | null;
15
+ readonly sdpLineNumber: number | null;
16
+ readonly sentAlert: number | null;
17
+ }
18
+
19
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcerrorinit
20
+ interface RTCErrorInit {
21
+ errorDetail: RTCErrorDetailType;
22
+ httpRequestStatusCode?: number | undefined;
23
+ receivedAlert?: number | undefined;
24
+ sctpCauseCode?: number | undefined;
25
+ sdpLineNumber?: number | undefined;
26
+ sentAlert?: number | undefined;
27
+ }
28
+
29
+ declare var RTCError: {
30
+ prototype: RTCError;
31
+ new(init: RTCErrorInit, message?: string): RTCError;
32
+ };
33
+
34
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcerrorevent
35
+ interface RTCErrorEvent extends Event {
36
+ readonly error: RTCError;
37
+ }
38
+
39
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcerroreventinit
40
+ interface RTCErrorEventInit extends EventInit {
41
+ error: RTCError;
42
+ }
43
+
44
+ declare var RTCErrorEvent: {
45
+ prototype: RTCErrorEvent;
46
+ new(type: string, eventInitDict: RTCErrorEventInit): RTCErrorEvent;
47
+ };
48
+
49
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcicecandidatepair
50
+ interface RTCIceCandidatePair {
51
+ local?: RTCIceCandidate | undefined;
52
+ remote?: RTCIceCandidate | undefined;
53
+ }
54
+
55
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcofferansweroptions
56
+ interface RTCOfferAnswerOptions {
57
+ voiceActivityDetection?: boolean | undefined; // default = true
58
+ }
59
+
60
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcofferoptions
61
+ interface RTCOfferOptions extends RTCOfferAnswerOptions {
62
+ iceRestart?: boolean | undefined; // default = false
63
+ }
64
+
65
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcansweroptions
66
+ interface RTCAnswerOptions extends RTCOfferAnswerOptions {
67
+ }
68
+
69
+ // https://www.w3.org/TR/webrtc/#idl-def-rtciceserver
70
+ interface RTCIceServer {
71
+ credential?: string | undefined;
72
+ urls: string | string[];
73
+ username?: string | undefined;
74
+ }
75
+
76
+ // https://www.w3.org/TR/webrtc/#idl-def-rtciceparameters
77
+ interface RTCIceParameters {
78
+ iceLite?: boolean | undefined;
79
+ password?: string | undefined;
80
+ usernameFragment?: string | undefined;
81
+ }
82
+
83
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcicerole
84
+ type RTCIceRole = "controlled" | "controlling" | "unknown";
85
+
86
+ interface RTCIceTransportEventMap {
87
+ "gatheringstatechange": Event;
88
+ "selectedcandidatepairchange": Event;
89
+ "statechange": Event;
90
+ }
91
+
92
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcicetransport
93
+ type IceTransportEventHandler = ((this: RTCIceTransport, ev: Event) => any) | null;
94
+ interface RTCIceTransport extends EventTarget {
95
+ readonly role: RTCIceRole;
96
+ // readonly component: RTCIceComponent;
97
+ // readonly state: RTCIceTransportState;
98
+ readonly gatheringState: RTCIceGatheringState;
99
+ getLocalCandidates(): RTCIceCandidate[];
100
+ getRemoteCandidates(): RTCIceCandidate[];
101
+ getLocalParameters(): RTCIceParameters | null;
102
+ getRemoteParameters(): RTCIceParameters | null;
103
+ getSelectedCandidatePair(): RTCIceCandidatePair | null;
104
+ onstatechange: IceTransportEventHandler;
105
+ ongatheringstatechange: IceTransportEventHandler;
106
+ onselectedcandidatepairchange: IceTransportEventHandler;
107
+ addEventListener<K extends keyof RTCIceTransportEventMap>(
108
+ type: K,
109
+ listener: (this: RTCIceTransport, ev: RTCIceTransportEventMap[K]) => any,
110
+ options?: boolean | AddEventListenerOptions,
111
+ ): void;
112
+ addEventListener(
113
+ type: string,
114
+ listener: EventListenerOrEventListenerObject,
115
+ options?: boolean | AddEventListenerOptions,
116
+ ): void;
117
+ removeEventListener<K extends keyof RTCIceTransportEventMap>(
118
+ type: K,
119
+ listener: (this: RTCIceTransport, ev: RTCIceTransportEventMap[K]) => any,
120
+ options: boolean | EventListenerOptions,
121
+ ): void;
122
+ removeEventListener(
123
+ type: string,
124
+ listener: EventListenerOrEventListenerObject,
125
+ options?: boolean | EventListenerOptions,
126
+ ): void;
127
+ }
128
+
129
+ interface RTCDtlsTransportEventMap {
130
+ "error": Event;
131
+ "statechange": Event;
132
+ }
133
+
134
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcdtlstransport
135
+ type DtlsTransportEventHandler<E extends Event> = ((this: RTCDtlsTransport, ev: E) => any) | null;
136
+ interface RTCDtlsTransport extends EventTarget {
137
+ readonly iceTransport: RTCIceTransport;
138
+ readonly state: RTCDtlsTransportState;
139
+ getRemoteCertificates(): ArrayBuffer[];
140
+ onerror: DtlsTransportEventHandler<Event>;
141
+ onstatechange: DtlsTransportEventHandler<Event>;
142
+ addEventListener<K extends keyof RTCDtlsTransportEventMap>(
143
+ type: K,
144
+ listener: (this: RTCDtlsTransport, ev: RTCDtlsTransportEventMap[K]) => any,
145
+ options?: boolean | AddEventListenerOptions,
146
+ ): void;
147
+ addEventListener(
148
+ type: string,
149
+ listener: EventListenerOrEventListenerObject,
150
+ options?: boolean | AddEventListenerOptions,
151
+ ): void;
152
+ removeEventListener<K extends keyof RTCDtlsTransportEventMap>(
153
+ type: K,
154
+ listener: (this: RTCDtlsTransport, ev: RTCDtlsTransportEventMap[K]) => any,
155
+ options?: boolean | EventListenerOptions,
156
+ ): void;
157
+ removeEventListener(
158
+ type: string,
159
+ listener: EventListenerOrEventListenerObject,
160
+ options?: boolean | EventListenerOptions,
161
+ ): void;
162
+ }
163
+
164
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcrtpcodeccapability
165
+ interface RTCRtpCodecCapability {
166
+ mimeType: string;
167
+ }
168
+
169
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcrtpheaderextensioncapability
170
+ interface RTCRtpHeaderExtensionCapability {
171
+ uri: string;
172
+ }
173
+
174
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcrtpcapabilities
175
+ interface RTCRtpCapabilities {
176
+ // codecs: RTCRtpCodecCapability[];
177
+ // headerExtensions: RTCRtpHeaderExtensionCapability[];
178
+ }
179
+
180
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcrtprtxparameters
181
+ interface RTCRtpRtxParameters {
182
+ // ssrc: number;
183
+ }
184
+
185
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcrtpfecparameters
186
+ interface RTCRtpFecParameters {
187
+ // ssrc: number;
188
+ }
189
+
190
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcrtpencodingparameters
191
+ interface RTCRtpEncodingParameters {
192
+ // ssrc: number;
193
+ // rtx: RTCRtpRtxParameters;
194
+ // fec: RTCRtpFecParameters;
195
+ // dtx?: RTCDtxStatus;
196
+ // active: boolean;
197
+ // priority: RTCPriorityType;
198
+ // maxBitrate: number;
199
+ rid: string;
200
+ scaleResolutionDownBy?: number | undefined; // default = 1
201
+ }
202
+
203
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcrtpheaderextensionparameters
204
+ interface RTCRtpHeaderExtensionParameters {
205
+ // uri: string;
206
+ // id: number;
207
+ encrypted?: boolean | undefined;
208
+ }
209
+
210
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcrtcpparameters
211
+ interface RTCRtcpParameters {
212
+ // cname: string;
213
+ // reducedSize: boolean;
214
+ }
215
+
216
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcrtpcodecparameters
217
+ interface RTCRtpCodecParameters {
218
+ // payloadType: number;
219
+ mimeType: string;
220
+ // clockRate: number;
221
+ channels?: number | undefined; // default = 1
222
+ sdpFmtpLine?: string | undefined;
223
+ }
224
+
225
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcrtpparameters
226
+ interface RTCRtpParameters {
227
+ transactionId: string;
228
+ // encodings: RTCRtpEncodingParameters[];
229
+ // headerExtensions: RTCRtpHeaderExtensionParameters[];
230
+ // rtcp: RTCRtcpParameters;
231
+ // codecs: RTCRtpCodecParameters[];
232
+ // degradationPreference?: RTCDegradationPreference; // default = 'balanced'
233
+ }
234
+
235
+ // https://www.w3.org/TR/webrtc/#dom-rtcrtpcontributingsource
236
+ interface RTCRtpContributingSource {
237
+ // readonly timestamp: number;
238
+ source: number;
239
+ // readonly audioLevel: number | null;
240
+ readonly voiceActivityFlag?: boolean | undefined;
241
+ }
242
+
243
+ // https://www.w3.org/TR/webrtc/#dom-rtcrtpsender
244
+ interface RTCRtpSender {
245
+ // readonly track?: MediaStreamTrack;
246
+ // readonly transport?: RTCDtlsTransport;
247
+ // readonly rtcpTransport?: RTCDtlsTransport;
248
+ setParameters(parameters?: RTCRtpParameters): Promise<void>;
249
+ getParameters(): RTCRtpParameters;
250
+ replaceTrack(withTrack: MediaStreamTrack): Promise<void>;
251
+ }
252
+
253
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcrtpreceiver
254
+ interface RTCRtpReceiver {
255
+ // readonly track?: MediaStreamTrack;
256
+ // readonly transport?: RTCDtlsTransport;
257
+ // readonly rtcpTransport?: RTCDtlsTransport;
258
+ getParameters(): RTCRtpParameters;
259
+ getContributingSources(): RTCRtpContributingSource[];
260
+ }
261
+
262
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcrtptransceiver
263
+ interface RTCRtpTransceiver {
264
+ readonly mid: string | null;
265
+ readonly sender: RTCRtpSender;
266
+ readonly receiver: RTCRtpReceiver;
267
+ readonly stopped: boolean;
268
+ direction: RTCRtpTransceiverDirection;
269
+ setDirection(direction: RTCRtpTransceiverDirection): void;
270
+ stop(): void;
271
+ setCodecPreferences(codecs: RTCRtpCodecCapability[]): void;
272
+ }
273
+
274
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcrtptransceiverinit
275
+ interface RTCRtpTransceiverInit {
276
+ direction?: RTCRtpTransceiverDirection | undefined; // default = 'sendrecv'
277
+ streams?: MediaStream[] | undefined;
278
+ sendEncodings?: RTCRtpEncodingParameters[] | undefined;
279
+ }
280
+
281
+ // https://www.w3.org/TR/webrtc/#dom-rtccertificate
282
+ interface RTCCertificate {
283
+ readonly expires: number;
284
+ getAlgorithm(): string;
285
+ }
286
+
287
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcconfiguration
288
+ interface RTCConfiguration {
289
+ iceServers?: RTCIceServer[] | undefined;
290
+ iceTransportPolicy?: RTCIceTransportPolicy | undefined; // default = 'all'
291
+ bundlePolicy?: RTCBundlePolicy | undefined; // default = 'balanced'
292
+ rtcpMuxPolicy?: RTCRtcpMuxPolicy | undefined; // default = 'require'
293
+ peerIdentity?: string | undefined; // default = null
294
+ certificates?: RTCCertificate[] | undefined;
295
+ iceCandidatePoolSize?: number | undefined; // default = 0
296
+ }
297
+
298
+ // Compatibility for older definitions on DefinitelyTyped.
299
+ type RTCPeerConnectionConfig = RTCConfiguration;
300
+
301
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcsctptransport
302
+ interface RTCSctpTransport {
303
+ readonly transport: RTCDtlsTransport;
304
+ readonly maxMessageSize: number;
305
+ }
306
+
307
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcdatachannelinit
308
+ interface RTCDataChannelInit {
309
+ ordered?: boolean | undefined; // default = true
310
+ maxPacketLifeTime?: number | undefined;
311
+ maxRetransmits?: number | undefined;
312
+ protocol?: string | undefined; // default = ''
313
+ negotiated?: boolean | undefined; // default = false
314
+ id?: number | undefined;
315
+ }
316
+
317
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcdatachannel
318
+ type DataChannelEventHandler<E extends Event> = ((this: RTCDataChannel, ev: E) => any) | null;
319
+ interface RTCDataChannel extends EventTarget {
320
+ readonly label: string;
321
+ readonly ordered: boolean;
322
+ readonly maxPacketLifeTime: number | null;
323
+ readonly maxRetransmits: number | null;
324
+ readonly protocol: string;
325
+ readonly negotiated: boolean;
326
+ readonly id: number | null;
327
+ readonly readyState: RTCDataChannelState;
328
+ readonly bufferedAmount: number;
329
+ bufferedAmountLowThreshold: number;
330
+ // binaryType: string;
331
+
332
+ close(): void;
333
+ send(data: string | Blob | ArrayBuffer | ArrayBufferView): void;
334
+
335
+ onopen: DataChannelEventHandler<Event>;
336
+ onmessage: DataChannelEventHandler<MessageEvent>;
337
+ onbufferedamountlow: DataChannelEventHandler<Event>;
338
+ // onerror: DataChannelEventHandler<RTCErrorEvent>;
339
+ onclose: DataChannelEventHandler<Event>;
340
+ }
341
+
342
+ // https://www.w3.org/TR/webrtc/#h-rtctrackevent
343
+ interface RTCTrackEvent extends Event {
344
+ readonly receiver: RTCRtpReceiver;
345
+ readonly track: MediaStreamTrack;
346
+ readonly streams: ReadonlyArray<MediaStream>;
347
+ readonly transceiver: RTCRtpTransceiver;
348
+ }
349
+
350
+ // https://www.w3.org/TR/webrtc/#h-rtcpeerconnectioniceevent
351
+ interface RTCPeerConnectionIceEvent extends Event {
352
+ readonly url: string | null;
353
+ }
354
+
355
+ // https://www.w3.org/TR/webrtc/#h-rtcpeerconnectioniceerrorevent
356
+ interface RTCPeerConnectionIceErrorEvent extends Event {
357
+ readonly hostCandidate: string;
358
+ readonly url: string;
359
+ readonly errorCode: number;
360
+ readonly errorText: string;
361
+ }
362
+
363
+ // https://www.w3.org/TR/webrtc/#h-rtcdatachannelevent
364
+ interface RTCDataChannelEvent {
365
+ readonly channel: RTCDataChannel;
366
+ }
367
+
368
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcpeerconnection
369
+ type PeerConnectionEventHandler<E extends Event> = ((this: RTCPeerConnection, ev: E) => any) | null;
370
+ interface RTCPeerConnection extends EventTarget {
371
+ createOffer(options?: RTCOfferOptions): Promise<RTCSessionDescriptionInit>;
372
+ createAnswer(options?: RTCAnswerOptions): Promise<RTCSessionDescriptionInit>;
373
+
374
+ setLocalDescription(description: RTCSessionDescriptionInit): Promise<void>;
375
+ readonly localDescription: RTCSessionDescription | null;
376
+ readonly currentLocalDescription: RTCSessionDescription | null;
377
+ readonly pendingLocalDescription: RTCSessionDescription | null;
378
+
379
+ setRemoteDescription(description: RTCSessionDescriptionInit): Promise<void>;
380
+ readonly remoteDescription: RTCSessionDescription | null;
381
+ readonly currentRemoteDescription: RTCSessionDescription | null;
382
+ readonly pendingRemoteDescription: RTCSessionDescription | null;
383
+
384
+ addIceCandidate(candidate?: RTCIceCandidateInit | RTCIceCandidate): Promise<void>;
385
+
386
+ readonly signalingState: RTCSignalingState;
387
+ readonly connectionState: RTCPeerConnectionState;
388
+
389
+ getConfiguration(): RTCConfiguration;
390
+ setConfiguration(configuration: RTCConfiguration): void;
391
+ close(): void;
392
+
393
+ onicecandidateerror: PeerConnectionEventHandler<Event>;
394
+ onconnectionstatechange: PeerConnectionEventHandler<Event>;
395
+
396
+ // Extension: https://www.w3.org/TR/webrtc/#h-rtcpeerconnection-interface-extensions
397
+ getSenders(): RTCRtpSender[];
398
+ getReceivers(): RTCRtpReceiver[];
399
+ getTransceivers(): RTCRtpTransceiver[];
400
+ addTrack(track: MediaStreamTrack, ...streams: MediaStream[]): RTCRtpSender;
401
+ removeTrack(sender: RTCRtpSender): void;
402
+ addTransceiver(trackOrKind: MediaStreamTrack | string, init?: RTCRtpTransceiverInit): RTCRtpTransceiver;
403
+ ontrack: PeerConnectionEventHandler<RTCTrackEvent>;
404
+
405
+ // Extension: https://www.w3.org/TR/webrtc/#h-rtcpeerconnection-interface-extensions-1
406
+ readonly sctp: RTCSctpTransport | null;
407
+ createDataChannel(label: string | null, dataChannelDict?: RTCDataChannelInit): RTCDataChannel;
408
+ ondatachannel: PeerConnectionEventHandler<RTCDataChannelEvent>;
409
+
410
+ // Extension: https://www.w3.org/TR/webrtc/#h-rtcpeerconnection-interface-extensions-2
411
+ getStats(selector?: MediaStreamTrack | null): Promise<RTCStatsReport>;
412
+
413
+ // Extension: https://www.w3.org/TR/webrtc/#legacy-interface-extensions
414
+ // Deprecated!
415
+ createOffer(
416
+ successCallback: RTCSessionDescriptionCallback,
417
+ failureCallback: RTCPeerConnectionErrorCallback,
418
+ options?: RTCOfferOptions,
419
+ ): Promise<void>;
420
+ setLocalDescription(
421
+ description: RTCSessionDescriptionInit,
422
+ successCallback: () => void,
423
+ failureCallback: RTCPeerConnectionErrorCallback,
424
+ ): Promise<void>;
425
+ createAnswer(
426
+ successCallback: RTCSessionDescriptionCallback,
427
+ failureCallback: RTCPeerConnectionErrorCallback,
428
+ ): Promise<void>;
429
+ setRemoteDescription(
430
+ description: RTCSessionDescriptionInit,
431
+ successCallback: () => void,
432
+ failureCallback: RTCPeerConnectionErrorCallback,
433
+ ): Promise<void>;
434
+ addIceCandidate(
435
+ candidate: RTCIceCandidateInit | RTCIceCandidate,
436
+ successCallback: () => void,
437
+ failureCallback: RTCPeerConnectionErrorCallback,
438
+ ): Promise<void>;
439
+ getStats(
440
+ selector: MediaStreamTrack | null,
441
+ successCallback: (report: RTCStatsReport) => void,
442
+ failureCallback: RTCPeerConnectionErrorCallback,
443
+ ): Promise<void>;
444
+ }
445
+ interface RTCPeerConnectionStatic {
446
+ new(configuration?: RTCConfiguration, options?: any): RTCPeerConnection;
447
+ readonly defaultIceServers: RTCIceServer[];
448
+
449
+ // Extension: https://www.w3.org/TR/webrtc/#sec.cert-mgmt
450
+ generateCertificate(keygenAlgorithm: string): Promise<RTCCertificate>;
451
+ }
452
+
453
+ interface Window {
454
+ RTCPeerConnection: RTCPeerConnectionStatic;
455
+ }
node_modules/@types/webrtc/index.d.ts ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ // Type definitions for webrtc
2
+ // Project: https://webrtc.org/
3
+ // Definitions by: Toshiya Nakakura <https://github.com/nakakura>
4
+ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5
+ // TypeScript Version: 4.9
6
+
7
+ /// <reference path="RTCPeerConnection.d.ts" />
8
+ /// <reference path="MediaStream.d.ts" />
node_modules/@types/webrtc/package.json ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@types/webrtc",
3
+ "version": "0.0.37",
4
+ "description": "TypeScript definitions for webrtc",
5
+ "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/webrtc",
6
+ "license": "MIT",
7
+ "contributors": [
8
+ {
9
+ "name": "Toshiya Nakakura",
10
+ "url": "https://github.com/nakakura",
11
+ "githubUsername": "nakakura"
12
+ }
13
+ ],
14
+ "main": "",
15
+ "types": "index.d.ts",
16
+ "typesVersions": {
17
+ "<=5.0": {
18
+ "*": [
19
+ "ts5.0/*"
20
+ ]
21
+ }
22
+ },
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
26
+ "directory": "types/webrtc"
27
+ },
28
+ "scripts": {},
29
+ "dependencies": {},
30
+ "typesPublisherContentHash": "e1ae6c59b3e4613f2d86e44aafad1fbc6d952ad3e6c58b6cca72cfb4d54aa0a4",
31
+ "typeScriptVersion": "4.9"
32
+ }
node_modules/@types/webrtc/ts5.0/MediaStream.d.ts ADDED
@@ -0,0 +1,194 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Taken from http://dev.w3.org/2011/webrtc/editor/getusermedia.html
2
+ // version: W3C Editor's Draft 29 June 2015
3
+
4
+ interface ConstrainBooleanParameters {
5
+ exact?: boolean | undefined;
6
+ ideal?: boolean | undefined;
7
+ }
8
+
9
+ interface NumberRange {
10
+ max?: number | undefined;
11
+ min?: number | undefined;
12
+ }
13
+
14
+ interface ConstrainNumberRange extends NumberRange {
15
+ exact?: number | undefined;
16
+ ideal?: number | undefined;
17
+ }
18
+
19
+ interface ConstrainStringParameters {
20
+ exact?: string | string[] | undefined;
21
+ ideal?: string | string[] | undefined;
22
+ }
23
+
24
+ interface MediaStreamConstraints {
25
+ video?: boolean | MediaTrackConstraints | undefined;
26
+ audio?: boolean | MediaTrackConstraints | undefined;
27
+ }
28
+
29
+ declare namespace W3C {
30
+ type LongRange = NumberRange;
31
+ type DoubleRange = NumberRange;
32
+ type ConstrainBoolean = boolean | ConstrainBooleanParameters;
33
+ type ConstrainNumber = number | ConstrainNumberRange;
34
+ type ConstrainLong = ConstrainNumber;
35
+ type ConstrainDouble = ConstrainNumber;
36
+ type ConstrainString = string | string[] | ConstrainStringParameters;
37
+ }
38
+
39
+ interface MediaTrackConstraints extends MediaTrackConstraintSet {
40
+ advanced?: MediaTrackConstraintSet[] | undefined;
41
+ }
42
+
43
+ interface MediaTrackConstraintSet {
44
+ width?: W3C.ConstrainLong | undefined;
45
+ height?: W3C.ConstrainLong | undefined;
46
+ aspectRatio?: W3C.ConstrainDouble | undefined;
47
+ frameRate?: W3C.ConstrainDouble | undefined;
48
+ facingMode?: W3C.ConstrainString | undefined;
49
+ volume?: W3C.ConstrainDouble | undefined;
50
+ sampleRate?: W3C.ConstrainLong | undefined;
51
+ sampleSize?: W3C.ConstrainLong | undefined;
52
+ echoCancellation?: W3C.ConstrainBoolean | undefined;
53
+ latency?: W3C.ConstrainDouble | undefined;
54
+ deviceId?: W3C.ConstrainString | undefined;
55
+ groupId?: W3C.ConstrainString | undefined;
56
+ }
57
+
58
+ interface MediaTrackSupportedConstraints {
59
+ width?: boolean | undefined;
60
+ height?: boolean | undefined;
61
+ aspectRatio?: boolean | undefined;
62
+ frameRate?: boolean | undefined;
63
+ facingMode?: boolean | undefined;
64
+ volume?: boolean | undefined;
65
+ sampleRate?: boolean | undefined;
66
+ sampleSize?: boolean | undefined;
67
+ echoCancellation?: boolean | undefined;
68
+ latency?: boolean | undefined;
69
+ deviceId?: boolean | undefined;
70
+ groupId?: boolean | undefined;
71
+ }
72
+
73
+ interface MediaStream extends EventTarget {
74
+ // id: string;
75
+ // active: boolean;
76
+
77
+ // onactive: EventListener;
78
+ // oninactive: EventListener;
79
+ // onaddtrack: (event: MediaStreamTrackEvent) => any;
80
+ // onremovetrack: (event: MediaStreamTrackEvent) => any;
81
+
82
+ clone(): MediaStream;
83
+ stop(): void;
84
+
85
+ getAudioTracks(): MediaStreamTrack[];
86
+ getVideoTracks(): MediaStreamTrack[];
87
+ getTracks(): MediaStreamTrack[];
88
+
89
+ getTrackById(trackId: string): MediaStreamTrack;
90
+
91
+ addTrack(track: MediaStreamTrack): void;
92
+ removeTrack(track: MediaStreamTrack): void;
93
+ }
94
+
95
+ interface MediaStreamTrackEvent extends Event {
96
+ // track: MediaStreamTrack;
97
+ }
98
+
99
+ interface MediaStreamTrack extends EventTarget {
100
+ // id: string;
101
+ // kind: string;
102
+ // label: string;
103
+ enabled: boolean;
104
+ // muted: boolean;
105
+ // remote: boolean;
106
+ // readyState: MediaStreamTrackState;
107
+
108
+ // onmute: EventListener;
109
+ // onunmute: EventListener;
110
+ // onended: EventListener;
111
+ // onoverconstrained: EventListener;
112
+
113
+ clone(): MediaStreamTrack;
114
+
115
+ stop(): void;
116
+
117
+ getCapabilities(): MediaTrackCapabilities;
118
+ getConstraints(): MediaTrackConstraints;
119
+ getSettings(): MediaTrackSettings;
120
+ applyConstraints(constraints: MediaTrackConstraints): Promise<void>;
121
+ }
122
+
123
+ interface MediaTrackCapabilities {
124
+ // width: number | W3C.LongRange;
125
+ // height: number | W3C.LongRange;
126
+ // aspectRatio: number | W3C.DoubleRange;
127
+ // frameRate: number | W3C.DoubleRange;
128
+ // facingMode: string;
129
+ // volume: number | W3C.DoubleRange;
130
+ // sampleRate: number | W3C.LongRange;
131
+ // sampleSize: number | W3C.LongRange;
132
+ // echoCancellation: boolean[];
133
+ latency?: W3C.DoubleRange | undefined;
134
+ // deviceId: string;
135
+ // groupId: string;
136
+ }
137
+
138
+ interface MediaTrackSettings {
139
+ // width: number;
140
+ // height: number;
141
+ // aspectRatio: number;
142
+ // frameRate: number;
143
+ // facingMode: string;
144
+ // volume: number;
145
+ // sampleRate: number;
146
+ // sampleSize: number;
147
+ // echoCancellation: boolean;
148
+ latency?: number | undefined;
149
+ // deviceId: string;
150
+ // groupId: string;
151
+ }
152
+
153
+ interface MediaStreamError {
154
+ readonly name: string;
155
+ readonly message: string | null;
156
+ readonly constraintName: string | null;
157
+ }
158
+
159
+ interface NavigatorGetUserMedia {
160
+ (
161
+ constraints: MediaStreamConstraints,
162
+ successCallback: (stream: MediaStream) => void,
163
+ errorCallback: (error: MediaStreamError) => void,
164
+ ): void;
165
+ }
166
+
167
+ // to use with adapter.js, see: https://github.com/webrtc/adapter
168
+ declare var getUserMedia: NavigatorGetUserMedia;
169
+
170
+ interface Navigator {
171
+ getUserMedia: NavigatorGetUserMedia;
172
+
173
+ webkitGetUserMedia: NavigatorGetUserMedia;
174
+
175
+ mozGetUserMedia: NavigatorGetUserMedia;
176
+
177
+ msGetUserMedia: NavigatorGetUserMedia;
178
+
179
+ readonly mediaDevices: MediaDevices;
180
+ }
181
+
182
+ interface MediaDevices {
183
+ getSupportedConstraints(): MediaTrackSupportedConstraints;
184
+
185
+ getUserMedia(constraints: MediaStreamConstraints): Promise<MediaStream>;
186
+ enumerateDevices(): Promise<MediaDeviceInfo[]>;
187
+ }
188
+
189
+ interface MediaDeviceInfo {
190
+ // label: string;
191
+ // deviceId: string;
192
+ // kind: string;
193
+ // groupId: string;
194
+ }
node_modules/@types/webrtc/ts5.0/RTCPeerConnection.d.ts ADDED
@@ -0,0 +1,459 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Note: Commented out definitions clash with definitions in lib.es6.d.ts. I
2
+ // still kept them in here though, as sometimes they're more specific than the
3
+ // ES6 library ones.
4
+
5
+ /// <reference path='MediaStream.d.ts' />
6
+
7
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcerror
8
+ interface RTCError extends DOMException {
9
+ readonly errorDetail: RTCErrorDetailType;
10
+ readonly httpRequestStatusCode: number | null;
11
+ readonly receivedAlert: number | null;
12
+ readonly sctpCauseCode: number | null;
13
+ readonly sdpLineNumber: number | null;
14
+ readonly sentAlert: number | null;
15
+ }
16
+
17
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcerrorinit
18
+ interface RTCErrorInit {
19
+ errorDetail: RTCErrorDetailType;
20
+ httpRequestStatusCode?: number | undefined;
21
+ receivedAlert?: number | undefined;
22
+ sctpCauseCode?: number | undefined;
23
+ sdpLineNumber?: number | undefined;
24
+ sentAlert?: number | undefined;
25
+ }
26
+
27
+ declare var RTCError: {
28
+ prototype: RTCError;
29
+ new(init: RTCErrorInit, message?: string): RTCError;
30
+ };
31
+
32
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcerrorevent
33
+ interface RTCErrorEvent extends Event {
34
+ readonly error: RTCError;
35
+ }
36
+
37
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcerroreventinit
38
+ interface RTCErrorEventInit extends EventInit {
39
+ error: RTCError;
40
+ }
41
+
42
+ declare var RTCErrorEvent: {
43
+ prototype: RTCErrorEvent;
44
+ new(type: string, eventInitDict: RTCErrorEventInit): RTCErrorEvent;
45
+ };
46
+
47
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcicecandidatepair
48
+ interface RTCIceCandidatePair {
49
+ local?: RTCIceCandidate | undefined;
50
+ remote?: RTCIceCandidate | undefined;
51
+ }
52
+
53
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcofferansweroptions
54
+ interface RTCOfferAnswerOptions {
55
+ voiceActivityDetection?: boolean | undefined; // default = true
56
+ }
57
+
58
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcofferoptions
59
+ interface RTCOfferOptions extends RTCOfferAnswerOptions {
60
+ iceRestart?: boolean | undefined; // default = false
61
+ }
62
+
63
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcansweroptions
64
+ interface RTCAnswerOptions extends RTCOfferAnswerOptions {
65
+ }
66
+
67
+ // https://www.w3.org/TR/webrtc/#idl-def-rtciceserver
68
+ interface RTCIceServer {
69
+ credential?: string | undefined;
70
+ urls: string | string[];
71
+ username?: string | undefined;
72
+ }
73
+
74
+ // https://www.w3.org/TR/webrtc/#idl-def-rtciceparameters
75
+ interface RTCIceParameters {
76
+ iceLite?: boolean | undefined;
77
+ password?: string | undefined;
78
+ usernameFragment?: string | undefined;
79
+ }
80
+
81
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcicerole
82
+ type RTCIceRole = "controlled" | "controlling" | "unknown";
83
+
84
+ interface RTCIceTransportEventMap {
85
+ "gatheringstatechange": Event;
86
+ "selectedcandidatepairchange": Event;
87
+ "statechange": Event;
88
+ }
89
+
90
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcicetransport
91
+ type IceTransportEventHandler = ((this: RTCIceTransport, ev: Event) => any) | null;
92
+ interface RTCIceTransport extends EventTarget {
93
+ readonly role: RTCIceRole;
94
+ // readonly component: RTCIceComponent;
95
+ // readonly state: RTCIceTransportState;
96
+ readonly gatheringState: RTCIceGatheringState;
97
+ getLocalCandidates(): RTCIceCandidate[];
98
+ getRemoteCandidates(): RTCIceCandidate[];
99
+ getLocalParameters(): RTCIceParameters | null;
100
+ getRemoteParameters(): RTCIceParameters | null;
101
+ getSelectedCandidatePair(): RTCIceCandidatePair | null;
102
+ onstatechange: IceTransportEventHandler;
103
+ ongatheringstatechange: IceTransportEventHandler;
104
+ onselectedcandidatepairchange: IceTransportEventHandler;
105
+ addEventListener<K extends keyof RTCIceTransportEventMap>(
106
+ type: K,
107
+ listener: (this: RTCIceTransport, ev: RTCIceTransportEventMap[K]) => any,
108
+ options?: boolean | AddEventListenerOptions,
109
+ ): void;
110
+ addEventListener(
111
+ type: string,
112
+ listener: EventListenerOrEventListenerObject,
113
+ options?: boolean | AddEventListenerOptions,
114
+ ): void;
115
+ removeEventListener<K extends keyof RTCIceTransportEventMap>(
116
+ type: K,
117
+ listener: (this: RTCIceTransport, ev: RTCIceTransportEventMap[K]) => any,
118
+ options: boolean | EventListenerOptions,
119
+ ): void;
120
+ removeEventListener(
121
+ type: string,
122
+ listener: EventListenerOrEventListenerObject,
123
+ options?: boolean | EventListenerOptions,
124
+ ): void;
125
+ }
126
+
127
+ interface RTCDtlsTransportEventMap {
128
+ "error": Event;
129
+ "statechange": Event;
130
+ }
131
+
132
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcdtlstransport
133
+ type DtlsTransportEventHandler<E extends Event> = ((this: RTCDtlsTransport, ev: E) => any) | null;
134
+ interface RTCDtlsTransport extends EventTarget {
135
+ readonly iceTransport: RTCIceTransport;
136
+ readonly state: RTCDtlsTransportState;
137
+ getRemoteCertificates(): ArrayBuffer[];
138
+ onerror: DtlsTransportEventHandler<Event>;
139
+ onstatechange: DtlsTransportEventHandler<Event>;
140
+ addEventListener<K extends keyof RTCDtlsTransportEventMap>(
141
+ type: K,
142
+ listener: (this: RTCDtlsTransport, ev: RTCDtlsTransportEventMap[K]) => any,
143
+ options?: boolean | AddEventListenerOptions,
144
+ ): void;
145
+ addEventListener(
146
+ type: string,
147
+ listener: EventListenerOrEventListenerObject,
148
+ options?: boolean | AddEventListenerOptions,
149
+ ): void;
150
+ removeEventListener<K extends keyof RTCDtlsTransportEventMap>(
151
+ type: K,
152
+ listener: (this: RTCDtlsTransport, ev: RTCDtlsTransportEventMap[K]) => any,
153
+ options?: boolean | EventListenerOptions,
154
+ ): void;
155
+ removeEventListener(
156
+ type: string,
157
+ listener: EventListenerOrEventListenerObject,
158
+ options?: boolean | EventListenerOptions,
159
+ ): void;
160
+ }
161
+
162
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcrtpcodeccapability
163
+ interface RTCRtpCodecCapability {
164
+ mimeType: string;
165
+ }
166
+
167
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcrtpheaderextensioncapability
168
+ interface RTCRtpHeaderExtensionCapability {
169
+ uri?: string | undefined;
170
+ }
171
+
172
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcrtpcapabilities
173
+ interface RTCRtpCapabilities {
174
+ // codecs: RTCRtpCodecCapability[];
175
+ // headerExtensions: RTCRtpHeaderExtensionCapability[];
176
+ }
177
+
178
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcrtprtxparameters
179
+ interface RTCRtpRtxParameters {
180
+ // ssrc: number;
181
+ }
182
+
183
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcrtpfecparameters
184
+ interface RTCRtpFecParameters {
185
+ // ssrc: number;
186
+ }
187
+
188
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcrtpencodingparameters
189
+ interface RTCRtpEncodingParameters {
190
+ // ssrc: number;
191
+ // rtx: RTCRtpRtxParameters;
192
+ // fec: RTCRtpFecParameters;
193
+ // dtx?: RTCDtxStatus;
194
+ // active: boolean;
195
+ // priority: RTCPriorityType;
196
+ // maxBitrate: number;
197
+ rid: string;
198
+ scaleResolutionDownBy?: number | undefined; // default = 1
199
+ }
200
+
201
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcrtpheaderextensionparameters
202
+ interface RTCRtpHeaderExtensionParameters {
203
+ // uri: string;
204
+ // id: number;
205
+ encrypted?: boolean | undefined;
206
+ }
207
+
208
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcrtcpparameters
209
+ interface RTCRtcpParameters {
210
+ // cname: string;
211
+ // reducedSize: boolean;
212
+ }
213
+
214
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcrtpcodecparameters
215
+ interface RTCRtpCodecParameters {
216
+ // payloadType: number;
217
+ mimeType: string;
218
+ // clockRate: number;
219
+ channels?: number | undefined; // default = 1
220
+ sdpFmtpLine?: string | undefined;
221
+ }
222
+
223
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcrtpparameters
224
+ interface RTCRtpParameters {
225
+ transactionId: string;
226
+ // encodings: RTCRtpEncodingParameters[];
227
+ // headerExtensions: RTCRtpHeaderExtensionParameters[];
228
+ // rtcp: RTCRtcpParameters;
229
+ // codecs: RTCRtpCodecParameters[];
230
+ // degradationPreference?: RTCDegradationPreference; // default = 'balanced'
231
+ }
232
+
233
+ // https://www.w3.org/TR/webrtc/#dom-rtcrtpcontributingsource
234
+ interface RTCRtpContributingSource {
235
+ // readonly timestamp: number;
236
+ source: number;
237
+ // readonly audioLevel: number | null;
238
+ readonly voiceActivityFlag?: boolean | undefined;
239
+ }
240
+
241
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcrtpcapabilities
242
+ interface RTCRtcCapabilities {
243
+ codecs: RTCRtpCodecCapability[];
244
+ headerExtensions: RTCRtpHeaderExtensionCapability[];
245
+ }
246
+
247
+ // https://www.w3.org/TR/webrtc/#dom-rtcrtpsender
248
+ interface RTCRtpSender {
249
+ // readonly track?: MediaStreamTrack;
250
+ // readonly transport?: RTCDtlsTransport;
251
+ // readonly rtcpTransport?: RTCDtlsTransport;
252
+ setParameters(parameters?: RTCRtpParameters): Promise<void>;
253
+ getParameters(): RTCRtpParameters;
254
+ replaceTrack(withTrack: MediaStreamTrack): Promise<void>;
255
+ }
256
+
257
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcrtpreceiver
258
+ interface RTCRtpReceiver {
259
+ // readonly track?: MediaStreamTrack;
260
+ // readonly transport?: RTCDtlsTransport;
261
+ // readonly rtcpTransport?: RTCDtlsTransport;
262
+ getParameters(): RTCRtpParameters;
263
+ getContributingSources(): RTCRtpContributingSource[];
264
+ }
265
+
266
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcrtptransceiver
267
+ interface RTCRtpTransceiver {
268
+ readonly mid: string | null;
269
+ readonly sender: RTCRtpSender;
270
+ readonly receiver: RTCRtpReceiver;
271
+ readonly stopped: boolean;
272
+ direction: RTCRtpTransceiverDirection;
273
+ setDirection(direction: RTCRtpTransceiverDirection): void;
274
+ stop(): void;
275
+ setCodecPreferences(codecs: RTCRtpCodecCapability[]): void;
276
+ }
277
+
278
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcrtptransceiverinit
279
+ interface RTCRtpTransceiverInit {
280
+ direction?: RTCRtpTransceiverDirection | undefined; // default = 'sendrecv'
281
+ streams?: MediaStream[] | undefined;
282
+ sendEncodings?: RTCRtpEncodingParameters[] | undefined;
283
+ }
284
+
285
+ // https://www.w3.org/TR/webrtc/#dom-rtccertificate
286
+ interface RTCCertificate {
287
+ readonly expires: number;
288
+ getAlgorithm(): string;
289
+ }
290
+
291
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcconfiguration
292
+ interface RTCConfiguration {
293
+ iceServers?: RTCIceServer[] | undefined;
294
+ iceTransportPolicy?: RTCIceTransportPolicy | undefined; // default = 'all'
295
+ bundlePolicy?: RTCBundlePolicy | undefined; // default = 'balanced'
296
+ rtcpMuxPolicy?: RTCRtcpMuxPolicy | undefined; // default = 'require'
297
+ peerIdentity?: string | undefined; // default = null
298
+ certificates?: RTCCertificate[] | undefined;
299
+ iceCandidatePoolSize?: number | undefined; // default = 0
300
+ }
301
+
302
+ // Compatibility for older definitions on DefinitelyTyped.
303
+ type RTCPeerConnectionConfig = RTCConfiguration;
304
+
305
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcsctptransport
306
+ interface RTCSctpTransport {
307
+ readonly transport: RTCDtlsTransport;
308
+ readonly maxMessageSize: number;
309
+ }
310
+
311
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcdatachannelinit
312
+ interface RTCDataChannelInit {
313
+ ordered?: boolean | undefined; // default = true
314
+ maxPacketLifeTime?: number | undefined;
315
+ maxRetransmits?: number | undefined;
316
+ protocol?: string | undefined; // default = ''
317
+ negotiated?: boolean | undefined; // default = false
318
+ id?: number | undefined;
319
+ }
320
+
321
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcdatachannel
322
+ type DataChannelEventHandler<E extends Event> = ((this: RTCDataChannel, ev: E) => any) | null;
323
+ interface RTCDataChannel extends EventTarget {
324
+ readonly label: string;
325
+ readonly ordered: boolean;
326
+ readonly maxPacketLifeTime: number | null;
327
+ readonly maxRetransmits: number | null;
328
+ readonly protocol: string;
329
+ readonly negotiated: boolean;
330
+ readonly id: number | null;
331
+ readonly readyState: RTCDataChannelState;
332
+ readonly bufferedAmount: number;
333
+ bufferedAmountLowThreshold: number;
334
+ // binaryType: string;
335
+
336
+ close(): void;
337
+ send(data: string | Blob | ArrayBuffer | ArrayBufferView): void;
338
+
339
+ onopen: DataChannelEventHandler<Event>;
340
+ onmessage: DataChannelEventHandler<MessageEvent>;
341
+ onbufferedamountlow: DataChannelEventHandler<Event>;
342
+ // onerror: DataChannelEventHandler<RTCErrorEvent>;
343
+ onclose: DataChannelEventHandler<Event>;
344
+ }
345
+
346
+ // https://www.w3.org/TR/webrtc/#h-rtctrackevent
347
+ interface RTCTrackEvent extends Event {
348
+ readonly receiver: RTCRtpReceiver;
349
+ readonly track: MediaStreamTrack;
350
+ readonly streams: ReadonlyArray<MediaStream>;
351
+ readonly transceiver: RTCRtpTransceiver;
352
+ }
353
+
354
+ // https://www.w3.org/TR/webrtc/#h-rtcpeerconnectioniceevent
355
+ interface RTCPeerConnectionIceEvent extends Event {
356
+ readonly url: string | null;
357
+ }
358
+
359
+ // https://www.w3.org/TR/webrtc/#h-rtcpeerconnectioniceerrorevent
360
+ interface RTCPeerConnectionIceErrorEvent extends Event {
361
+ readonly hostCandidate: string;
362
+ readonly url: string;
363
+ readonly errorCode: number;
364
+ readonly errorText: string;
365
+ }
366
+
367
+ // https://www.w3.org/TR/webrtc/#h-rtcdatachannelevent
368
+ interface RTCDataChannelEvent {
369
+ readonly channel: RTCDataChannel;
370
+ }
371
+
372
+ // https://www.w3.org/TR/webrtc/#idl-def-rtcpeerconnection
373
+ type PeerConnectionEventHandler<E extends Event> = ((this: RTCPeerConnection, ev: E) => any) | null;
374
+ interface RTCPeerConnection extends EventTarget {
375
+ createOffer(options?: RTCOfferOptions): Promise<RTCSessionDescriptionInit>;
376
+ createAnswer(options?: RTCAnswerOptions): Promise<RTCSessionDescriptionInit>;
377
+
378
+ setLocalDescription(description: RTCSessionDescriptionInit): Promise<void>;
379
+ readonly localDescription: RTCSessionDescription | null;
380
+ readonly currentLocalDescription: RTCSessionDescription | null;
381
+ readonly pendingLocalDescription: RTCSessionDescription | null;
382
+
383
+ setRemoteDescription(description: RTCSessionDescriptionInit): Promise<void>;
384
+ readonly remoteDescription: RTCSessionDescription | null;
385
+ readonly currentRemoteDescription: RTCSessionDescription | null;
386
+ readonly pendingRemoteDescription: RTCSessionDescription | null;
387
+
388
+ addIceCandidate(candidate?: RTCIceCandidateInit | RTCIceCandidate): Promise<void>;
389
+
390
+ readonly signalingState: RTCSignalingState;
391
+ readonly connectionState: RTCPeerConnectionState;
392
+
393
+ getConfiguration(): RTCConfiguration;
394
+ setConfiguration(configuration: RTCConfiguration): void;
395
+ close(): void;
396
+
397
+ onicecandidateerror: PeerConnectionEventHandler<Event>;
398
+ onconnectionstatechange: PeerConnectionEventHandler<Event>;
399
+
400
+ // Extension: https://www.w3.org/TR/webrtc/#h-rtcpeerconnection-interface-extensions
401
+ getSenders(): RTCRtpSender[];
402
+ getReceivers(): RTCRtpReceiver[];
403
+ getTransceivers(): RTCRtpTransceiver[];
404
+ addTrack(track: MediaStreamTrack, ...streams: MediaStream[]): RTCRtpSender;
405
+ removeTrack(sender: RTCRtpSender): void;
406
+ addTransceiver(trackOrKind: MediaStreamTrack | string, init?: RTCRtpTransceiverInit): RTCRtpTransceiver;
407
+ ontrack: PeerConnectionEventHandler<RTCTrackEvent>;
408
+
409
+ // Extension: https://www.w3.org/TR/webrtc/#h-rtcpeerconnection-interface-extensions-1
410
+ readonly sctp: RTCSctpTransport | null;
411
+ createDataChannel(label: string | null, dataChannelDict?: RTCDataChannelInit): RTCDataChannel;
412
+ ondatachannel: PeerConnectionEventHandler<RTCDataChannelEvent>;
413
+
414
+ // Extension: https://www.w3.org/TR/webrtc/#h-rtcpeerconnection-interface-extensions-2
415
+ getStats(selector?: MediaStreamTrack | null): Promise<RTCStatsReport>;
416
+
417
+ // Extension: https://www.w3.org/TR/webrtc/#legacy-interface-extensions
418
+ // Deprecated!
419
+ createOffer(
420
+ successCallback: RTCSessionDescriptionCallback,
421
+ failureCallback: RTCPeerConnectionErrorCallback,
422
+ options?: RTCOfferOptions,
423
+ ): Promise<void>;
424
+ setLocalDescription(
425
+ description: RTCSessionDescriptionInit,
426
+ successCallback: () => void,
427
+ failureCallback: RTCPeerConnectionErrorCallback,
428
+ ): Promise<void>;
429
+ createAnswer(
430
+ successCallback: RTCSessionDescriptionCallback,
431
+ failureCallback: RTCPeerConnectionErrorCallback,
432
+ ): Promise<void>;
433
+ setRemoteDescription(
434
+ description: RTCSessionDescriptionInit,
435
+ successCallback: () => void,
436
+ failureCallback: RTCPeerConnectionErrorCallback,
437
+ ): Promise<void>;
438
+ addIceCandidate(
439
+ candidate: RTCIceCandidateInit | RTCIceCandidate,
440
+ successCallback: () => void,
441
+ failureCallback: RTCPeerConnectionErrorCallback,
442
+ ): Promise<void>;
443
+ getStats(
444
+ selector: MediaStreamTrack | null,
445
+ successCallback: (report: RTCStatsReport) => void,
446
+ failureCallback: RTCPeerConnectionErrorCallback,
447
+ ): Promise<void>;
448
+ }
449
+ interface RTCPeerConnectionStatic {
450
+ new(configuration?: RTCConfiguration, options?: any): RTCPeerConnection;
451
+ readonly defaultIceServers: RTCIceServer[];
452
+
453
+ // Extension: https://www.w3.org/TR/webrtc/#sec.cert-mgmt
454
+ generateCertificate(keygenAlgorithm: string): Promise<RTCCertificate>;
455
+ }
456
+
457
+ interface Window {
458
+ RTCPeerConnection: RTCPeerConnectionStatic;
459
+ }
node_modules/@types/webrtc/ts5.0/index.d.ts ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ /// <reference path="RTCPeerConnection.d.ts" />
2
+ /// <reference path="MediaStream.d.ts" />
node_modules/agent-base/README.md ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ agent-base
2
+ ==========
3
+ ### Turn a function into an [`http.Agent`][http.Agent] instance
4
+ [![Build Status](https://github.com/TooTallNate/node-agent-base/workflows/Node%20CI/badge.svg)](https://github.com/TooTallNate/node-agent-base/actions?workflow=Node+CI)
5
+
6
+ This module provides an `http.Agent` generator. That is, you pass it an async
7
+ callback function, and it returns a new `http.Agent` instance that will invoke the
8
+ given callback function when sending outbound HTTP requests.
9
+
10
+ #### Some subclasses:
11
+
12
+ Here's some more interesting uses of `agent-base`.
13
+ Send a pull request to list yours!
14
+
15
+ * [`http-proxy-agent`][http-proxy-agent]: An HTTP(s) proxy `http.Agent` implementation for HTTP endpoints
16
+ * [`https-proxy-agent`][https-proxy-agent]: An HTTP(s) proxy `http.Agent` implementation for HTTPS endpoints
17
+ * [`pac-proxy-agent`][pac-proxy-agent]: A PAC file proxy `http.Agent` implementation for HTTP and HTTPS
18
+ * [`socks-proxy-agent`][socks-proxy-agent]: A SOCKS proxy `http.Agent` implementation for HTTP and HTTPS
19
+
20
+
21
+ Installation
22
+ ------------
23
+
24
+ Install with `npm`:
25
+
26
+ ``` bash
27
+ $ npm install agent-base
28
+ ```
29
+
30
+
31
+ Example
32
+ -------
33
+
34
+ Here's a minimal example that creates a new `net.Socket` connection to the server
35
+ for every HTTP request (i.e. the equivalent of `agent: false` option):
36
+
37
+ ```js
38
+ var net = require('net');
39
+ var tls = require('tls');
40
+ var url = require('url');
41
+ var http = require('http');
42
+ var agent = require('agent-base');
43
+
44
+ var endpoint = 'http://nodejs.org/api/';
45
+ var parsed = url.parse(endpoint);
46
+
47
+ // This is the important part!
48
+ parsed.agent = agent(function (req, opts) {
49
+ var socket;
50
+ // `secureEndpoint` is true when using the https module
51
+ if (opts.secureEndpoint) {
52
+ socket = tls.connect(opts);
53
+ } else {
54
+ socket = net.connect(opts);
55
+ }
56
+ return socket;
57
+ });
58
+
59
+ // Everything else works just like normal...
60
+ http.get(parsed, function (res) {
61
+ console.log('"response" event!', res.headers);
62
+ res.pipe(process.stdout);
63
+ });
64
+ ```
65
+
66
+ Returning a Promise or using an `async` function is also supported:
67
+
68
+ ```js
69
+ agent(async function (req, opts) {
70
+ await sleep(1000);
71
+ // etc…
72
+ });
73
+ ```
74
+
75
+ Return another `http.Agent` instance to "pass through" the responsibility
76
+ for that HTTP request to that agent:
77
+
78
+ ```js
79
+ agent(function (req, opts) {
80
+ return opts.secureEndpoint ? https.globalAgent : http.globalAgent;
81
+ });
82
+ ```
83
+
84
+
85
+ API
86
+ ---
87
+
88
+ ## Agent(Function callback[, Object options]) → [http.Agent][]
89
+
90
+ Creates a base `http.Agent` that will execute the callback function `callback`
91
+ for every HTTP request that it is used as the `agent` for. The callback function
92
+ is responsible for creating a `stream.Duplex` instance of some kind that will be
93
+ used as the underlying socket in the HTTP request.
94
+
95
+ The `options` object accepts the following properties:
96
+
97
+ * `timeout` - Number - Timeout for the `callback()` function in milliseconds. Defaults to Infinity (optional).
98
+
99
+ The callback function should have the following signature:
100
+
101
+ ### callback(http.ClientRequest req, Object options, Function cb) → undefined
102
+
103
+ The ClientRequest `req` can be accessed to read request headers and
104
+ and the path, etc. The `options` object contains the options passed
105
+ to the `http.request()`/`https.request()` function call, and is formatted
106
+ to be directly passed to `net.connect()`/`tls.connect()`, or however
107
+ else you want a Socket to be created. Pass the created socket to
108
+ the callback function `cb` once created, and the HTTP request will
109
+ continue to proceed.
110
+
111
+ If the `https` module is used to invoke the HTTP request, then the
112
+ `secureEndpoint` property on `options` _will be set to `true`_.
113
+
114
+
115
+ License
116
+ -------
117
+
118
+ (The MIT License)
119
+
120
+ Copyright (c) 2013 Nathan Rajlich &lt;[email protected]&gt;
121
+
122
+ Permission is hereby granted, free of charge, to any person obtaining
123
+ a copy of this software and associated documentation files (the
124
+ 'Software'), to deal in the Software without restriction, including
125
+ without limitation the rights to use, copy, modify, merge, publish,
126
+ distribute, sublicense, and/or sell copies of the Software, and to
127
+ permit persons to whom the Software is furnished to do so, subject to
128
+ the following conditions:
129
+
130
+ The above copyright notice and this permission notice shall be
131
+ included in all copies or substantial portions of the Software.
132
+
133
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
134
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
135
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
136
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
137
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
138
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
139
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
140
+
141
+ [http-proxy-agent]: https://github.com/TooTallNate/node-http-proxy-agent
142
+ [https-proxy-agent]: https://github.com/TooTallNate/node-https-proxy-agent
143
+ [pac-proxy-agent]: https://github.com/TooTallNate/node-pac-proxy-agent
144
+ [socks-proxy-agent]: https://github.com/TooTallNate/node-socks-proxy-agent
145
+ [http.Agent]: https://nodejs.org/api/http.html#http_class_http_agent
node_modules/agent-base/dist/src/index.d.ts ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /// <reference types="node" />
2
+ import net from 'net';
3
+ import http from 'http';
4
+ import https from 'https';
5
+ import { Duplex } from 'stream';
6
+ import { EventEmitter } from 'events';
7
+ declare function createAgent(opts?: createAgent.AgentOptions): createAgent.Agent;
8
+ declare function createAgent(callback: createAgent.AgentCallback, opts?: createAgent.AgentOptions): createAgent.Agent;
9
+ declare namespace createAgent {
10
+ interface ClientRequest extends http.ClientRequest {
11
+ _last?: boolean;
12
+ _hadError?: boolean;
13
+ method: string;
14
+ }
15
+ interface AgentRequestOptions {
16
+ host?: string;
17
+ path?: string;
18
+ port: number;
19
+ }
20
+ interface HttpRequestOptions extends AgentRequestOptions, Omit<http.RequestOptions, keyof AgentRequestOptions> {
21
+ secureEndpoint: false;
22
+ }
23
+ interface HttpsRequestOptions extends AgentRequestOptions, Omit<https.RequestOptions, keyof AgentRequestOptions> {
24
+ secureEndpoint: true;
25
+ }
26
+ type RequestOptions = HttpRequestOptions | HttpsRequestOptions;
27
+ type AgentLike = Pick<createAgent.Agent, 'addRequest'> | http.Agent;
28
+ type AgentCallbackReturn = Duplex | AgentLike;
29
+ type AgentCallbackCallback = (err?: Error | null, socket?: createAgent.AgentCallbackReturn) => void;
30
+ type AgentCallbackPromise = (req: createAgent.ClientRequest, opts: createAgent.RequestOptions) => createAgent.AgentCallbackReturn | Promise<createAgent.AgentCallbackReturn>;
31
+ type AgentCallback = typeof Agent.prototype.callback;
32
+ type AgentOptions = {
33
+ timeout?: number;
34
+ };
35
+ /**
36
+ * Base `http.Agent` implementation.
37
+ * No pooling/keep-alive is implemented by default.
38
+ *
39
+ * @param {Function} callback
40
+ * @api public
41
+ */
42
+ class Agent extends EventEmitter {
43
+ timeout: number | null;
44
+ maxFreeSockets: number;
45
+ maxTotalSockets: number;
46
+ maxSockets: number;
47
+ sockets: {
48
+ [key: string]: net.Socket[];
49
+ };
50
+ freeSockets: {
51
+ [key: string]: net.Socket[];
52
+ };
53
+ requests: {
54
+ [key: string]: http.IncomingMessage[];
55
+ };
56
+ options: https.AgentOptions;
57
+ private promisifiedCallback?;
58
+ private explicitDefaultPort?;
59
+ private explicitProtocol?;
60
+ constructor(callback?: createAgent.AgentCallback | createAgent.AgentOptions, _opts?: createAgent.AgentOptions);
61
+ get defaultPort(): number;
62
+ set defaultPort(v: number);
63
+ get protocol(): string;
64
+ set protocol(v: string);
65
+ callback(req: createAgent.ClientRequest, opts: createAgent.RequestOptions, fn: createAgent.AgentCallbackCallback): void;
66
+ callback(req: createAgent.ClientRequest, opts: createAgent.RequestOptions): createAgent.AgentCallbackReturn | Promise<createAgent.AgentCallbackReturn>;
67
+ /**
68
+ * Called by node-core's "_http_client.js" module when creating
69
+ * a new HTTP request with this Agent instance.
70
+ *
71
+ * @api public
72
+ */
73
+ addRequest(req: ClientRequest, _opts: RequestOptions): void;
74
+ freeSocket(socket: net.Socket, opts: AgentOptions): void;
75
+ destroy(): void;
76
+ }
77
+ }
78
+ export = createAgent;
node_modules/agent-base/dist/src/index.js ADDED
@@ -0,0 +1,203 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ const events_1 = require("events");
6
+ const debug_1 = __importDefault(require("debug"));
7
+ const promisify_1 = __importDefault(require("./promisify"));
8
+ const debug = debug_1.default('agent-base');
9
+ function isAgent(v) {
10
+ return Boolean(v) && typeof v.addRequest === 'function';
11
+ }
12
+ function isSecureEndpoint() {
13
+ const { stack } = new Error();
14
+ if (typeof stack !== 'string')
15
+ return false;
16
+ return stack.split('\n').some(l => l.indexOf('(https.js:') !== -1 || l.indexOf('node:https:') !== -1);
17
+ }
18
+ function createAgent(callback, opts) {
19
+ return new createAgent.Agent(callback, opts);
20
+ }
21
+ (function (createAgent) {
22
+ /**
23
+ * Base `http.Agent` implementation.
24
+ * No pooling/keep-alive is implemented by default.
25
+ *
26
+ * @param {Function} callback
27
+ * @api public
28
+ */
29
+ class Agent extends events_1.EventEmitter {
30
+ constructor(callback, _opts) {
31
+ super();
32
+ let opts = _opts;
33
+ if (typeof callback === 'function') {
34
+ this.callback = callback;
35
+ }
36
+ else if (callback) {
37
+ opts = callback;
38
+ }
39
+ // Timeout for the socket to be returned from the callback
40
+ this.timeout = null;
41
+ if (opts && typeof opts.timeout === 'number') {
42
+ this.timeout = opts.timeout;
43
+ }
44
+ // These aren't actually used by `agent-base`, but are required
45
+ // for the TypeScript definition files in `@types/node` :/
46
+ this.maxFreeSockets = 1;
47
+ this.maxSockets = 1;
48
+ this.maxTotalSockets = Infinity;
49
+ this.sockets = {};
50
+ this.freeSockets = {};
51
+ this.requests = {};
52
+ this.options = {};
53
+ }
54
+ get defaultPort() {
55
+ if (typeof this.explicitDefaultPort === 'number') {
56
+ return this.explicitDefaultPort;
57
+ }
58
+ return isSecureEndpoint() ? 443 : 80;
59
+ }
60
+ set defaultPort(v) {
61
+ this.explicitDefaultPort = v;
62
+ }
63
+ get protocol() {
64
+ if (typeof this.explicitProtocol === 'string') {
65
+ return this.explicitProtocol;
66
+ }
67
+ return isSecureEndpoint() ? 'https:' : 'http:';
68
+ }
69
+ set protocol(v) {
70
+ this.explicitProtocol = v;
71
+ }
72
+ callback(req, opts, fn) {
73
+ throw new Error('"agent-base" has no default implementation, you must subclass and override `callback()`');
74
+ }
75
+ /**
76
+ * Called by node-core's "_http_client.js" module when creating
77
+ * a new HTTP request with this Agent instance.
78
+ *
79
+ * @api public
80
+ */
81
+ addRequest(req, _opts) {
82
+ const opts = Object.assign({}, _opts);
83
+ if (typeof opts.secureEndpoint !== 'boolean') {
84
+ opts.secureEndpoint = isSecureEndpoint();
85
+ }
86
+ if (opts.host == null) {
87
+ opts.host = 'localhost';
88
+ }
89
+ if (opts.port == null) {
90
+ opts.port = opts.secureEndpoint ? 443 : 80;
91
+ }
92
+ if (opts.protocol == null) {
93
+ opts.protocol = opts.secureEndpoint ? 'https:' : 'http:';
94
+ }
95
+ if (opts.host && opts.path) {
96
+ // If both a `host` and `path` are specified then it's most
97
+ // likely the result of a `url.parse()` call... we need to
98
+ // remove the `path` portion so that `net.connect()` doesn't
99
+ // attempt to open that as a unix socket file.
100
+ delete opts.path;
101
+ }
102
+ delete opts.agent;
103
+ delete opts.hostname;
104
+ delete opts._defaultAgent;
105
+ delete opts.defaultPort;
106
+ delete opts.createConnection;
107
+ // Hint to use "Connection: close"
108
+ // XXX: non-documented `http` module API :(
109
+ req._last = true;
110
+ req.shouldKeepAlive = false;
111
+ let timedOut = false;
112
+ let timeoutId = null;
113
+ const timeoutMs = opts.timeout || this.timeout;
114
+ const onerror = (err) => {
115
+ if (req._hadError)
116
+ return;
117
+ req.emit('error', err);
118
+ // For Safety. Some additional errors might fire later on
119
+ // and we need to make sure we don't double-fire the error event.
120
+ req._hadError = true;
121
+ };
122
+ const ontimeout = () => {
123
+ timeoutId = null;
124
+ timedOut = true;
125
+ const err = new Error(`A "socket" was not created for HTTP request before ${timeoutMs}ms`);
126
+ err.code = 'ETIMEOUT';
127
+ onerror(err);
128
+ };
129
+ const callbackError = (err) => {
130
+ if (timedOut)
131
+ return;
132
+ if (timeoutId !== null) {
133
+ clearTimeout(timeoutId);
134
+ timeoutId = null;
135
+ }
136
+ onerror(err);
137
+ };
138
+ const onsocket = (socket) => {
139
+ if (timedOut)
140
+ return;
141
+ if (timeoutId != null) {
142
+ clearTimeout(timeoutId);
143
+ timeoutId = null;
144
+ }
145
+ if (isAgent(socket)) {
146
+ // `socket` is actually an `http.Agent` instance, so
147
+ // relinquish responsibility for this `req` to the Agent
148
+ // from here on
149
+ debug('Callback returned another Agent instance %o', socket.constructor.name);
150
+ socket.addRequest(req, opts);
151
+ return;
152
+ }
153
+ if (socket) {
154
+ socket.once('free', () => {
155
+ this.freeSocket(socket, opts);
156
+ });
157
+ req.onSocket(socket);
158
+ return;
159
+ }
160
+ const err = new Error(`no Duplex stream was returned to agent-base for \`${req.method} ${req.path}\``);
161
+ onerror(err);
162
+ };
163
+ if (typeof this.callback !== 'function') {
164
+ onerror(new Error('`callback` is not defined'));
165
+ return;
166
+ }
167
+ if (!this.promisifiedCallback) {
168
+ if (this.callback.length >= 3) {
169
+ debug('Converting legacy callback function to promise');
170
+ this.promisifiedCallback = promisify_1.default(this.callback);
171
+ }
172
+ else {
173
+ this.promisifiedCallback = this.callback;
174
+ }
175
+ }
176
+ if (typeof timeoutMs === 'number' && timeoutMs > 0) {
177
+ timeoutId = setTimeout(ontimeout, timeoutMs);
178
+ }
179
+ if ('port' in opts && typeof opts.port !== 'number') {
180
+ opts.port = Number(opts.port);
181
+ }
182
+ try {
183
+ debug('Resolving socket for %o request: %o', opts.protocol, `${req.method} ${req.path}`);
184
+ Promise.resolve(this.promisifiedCallback(req, opts)).then(onsocket, callbackError);
185
+ }
186
+ catch (err) {
187
+ Promise.reject(err).catch(callbackError);
188
+ }
189
+ }
190
+ freeSocket(socket, opts) {
191
+ debug('Freeing socket %o %o', socket.constructor.name, opts);
192
+ socket.destroy();
193
+ }
194
+ destroy() {
195
+ debug('Destroying agent %o', this.constructor.name);
196
+ }
197
+ }
198
+ createAgent.Agent = Agent;
199
+ // So that `instanceof` works correctly
200
+ createAgent.prototype = createAgent.Agent.prototype;
201
+ })(createAgent || (createAgent = {}));
202
+ module.exports = createAgent;
203
+ //# sourceMappingURL=index.js.map
node_modules/agent-base/dist/src/index.js.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAIA,mCAAsC;AACtC,kDAAgC;AAChC,4DAAoC;AAEpC,MAAM,KAAK,GAAG,eAAW,CAAC,YAAY,CAAC,CAAC;AAExC,SAAS,OAAO,CAAC,CAAM;IACtB,OAAO,OAAO,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,UAAU,KAAK,UAAU,CAAC;AACzD,CAAC;AAED,SAAS,gBAAgB;IACxB,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,KAAK,EAAE,CAAC;IAC9B,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5C,OAAO,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,IAAK,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACxG,CAAC;AAOD,SAAS,WAAW,CACnB,QAA+D,EAC/D,IAA+B;IAE/B,OAAO,IAAI,WAAW,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;AAC9C,CAAC;AAED,WAAU,WAAW;IAmDpB;;;;;;OAMG;IACH,MAAa,KAAM,SAAQ,qBAAY;QAmBtC,YACC,QAA+D,EAC/D,KAAgC;YAEhC,KAAK,EAAE,CAAC;YAER,IAAI,IAAI,GAAG,KAAK,CAAC;YACjB,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE;gBACnC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;aACzB;iBAAM,IAAI,QAAQ,EAAE;gBACpB,IAAI,GAAG,QAAQ,CAAC;aAChB;YAED,0DAA0D;YAC1D,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;YACpB,IAAI,IAAI,IAAI,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ,EAAE;gBAC7C,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;aAC5B;YAED,+DAA+D;YAC/D,0DAA0D;YAC1D,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC;YACxB,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC;YACpB,IAAI,CAAC,eAAe,GAAG,QAAQ,CAAC;YAChC,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;YAClB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;YACtB,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;YACnB,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QACnB,CAAC;QAED,IAAI,WAAW;YACd,IAAI,OAAO,IAAI,CAAC,mBAAmB,KAAK,QAAQ,EAAE;gBACjD,OAAO,IAAI,CAAC,mBAAmB,CAAC;aAChC;YACD,OAAO,gBAAgB,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QACtC,CAAC;QAED,IAAI,WAAW,CAAC,CAAS;YACxB,IAAI,CAAC,mBAAmB,GAAG,CAAC,CAAC;QAC9B,CAAC;QAED,IAAI,QAAQ;YACX,IAAI,OAAO,IAAI,CAAC,gBAAgB,KAAK,QAAQ,EAAE;gBAC9C,OAAO,IAAI,CAAC,gBAAgB,CAAC;aAC7B;YACD,OAAO,gBAAgB,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC;QAChD,CAAC;QAED,IAAI,QAAQ,CAAC,CAAS;YACrB,IAAI,CAAC,gBAAgB,GAAG,CAAC,CAAC;QAC3B,CAAC;QAaD,QAAQ,CACP,GAA8B,EAC9B,IAA8B,EAC9B,EAAsC;YAKtC,MAAM,IAAI,KAAK,CACd,yFAAyF,CACzF,CAAC;QACH,CAAC;QAED;;;;;WAKG;QACH,UAAU,CAAC,GAAkB,EAAE,KAAqB;YACnD,MAAM,IAAI,qBAAwB,KAAK,CAAE,CAAC;YAE1C,IAAI,OAAO,IAAI,CAAC,cAAc,KAAK,SAAS,EAAE;gBAC7C,IAAI,CAAC,cAAc,GAAG,gBAAgB,EAAE,CAAC;aACzC;YAED,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,EAAE;gBACtB,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;aACxB;YAED,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,EAAE;gBACtB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;aAC3C;YAED,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,EAAE;gBAC1B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC;aACzD;YAED,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE;gBAC3B,2DAA2D;gBAC3D,0DAA0D;gBAC1D,4DAA4D;gBAC5D,8CAA8C;gBAC9C,OAAO,IAAI,CAAC,IAAI,CAAC;aACjB;YAED,OAAO,IAAI,CAAC,KAAK,CAAC;YAClB,OAAO,IAAI,CAAC,QAAQ,CAAC;YACrB,OAAO,IAAI,CAAC,aAAa,CAAC;YAC1B,OAAO,IAAI,CAAC,WAAW,CAAC;YACxB,OAAO,IAAI,CAAC,gBAAgB,CAAC;YAE7B,kCAAkC;YAClC,2CAA2C;YAC3C,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC;YACjB,GAAG,CAAC,eAAe,GAAG,KAAK,CAAC;YAE5B,IAAI,QAAQ,GAAG,KAAK,CAAC;YACrB,IAAI,SAAS,GAAyC,IAAI,CAAC;YAC3D,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC;YAE/C,MAAM,OAAO,GAAG,CAAC,GAA0B,EAAE,EAAE;gBAC9C,IAAI,GAAG,CAAC,SAAS;oBAAE,OAAO;gBAC1B,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;gBACvB,yDAAyD;gBACzD,iEAAiE;gBACjE,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC;YACtB,CAAC,CAAC;YAEF,MAAM,SAAS,GAAG,GAAG,EAAE;gBACtB,SAAS,GAAG,IAAI,CAAC;gBACjB,QAAQ,GAAG,IAAI,CAAC;gBAChB,MAAM,GAAG,GAA0B,IAAI,KAAK,CAC3C,sDAAsD,SAAS,IAAI,CACnE,CAAC;gBACF,GAAG,CAAC,IAAI,GAAG,UAAU,CAAC;gBACtB,OAAO,CAAC,GAAG,CAAC,CAAC;YACd,CAAC,CAAC;YAEF,MAAM,aAAa,GAAG,CAAC,GAA0B,EAAE,EAAE;gBACpD,IAAI,QAAQ;oBAAE,OAAO;gBACrB,IAAI,SAAS,KAAK,IAAI,EAAE;oBACvB,YAAY,CAAC,SAAS,CAAC,CAAC;oBACxB,SAAS,GAAG,IAAI,CAAC;iBACjB;gBACD,OAAO,CAAC,GAAG,CAAC,CAAC;YACd,CAAC,CAAC;YAEF,MAAM,QAAQ,GAAG,CAAC,MAA2B,EAAE,EAAE;gBAChD,IAAI,QAAQ;oBAAE,OAAO;gBACrB,IAAI,SAAS,IAAI,IAAI,EAAE;oBACtB,YAAY,CAAC,SAAS,CAAC,CAAC;oBACxB,SAAS,GAAG,IAAI,CAAC;iBACjB;gBAED,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE;oBACpB,oDAAoD;oBACpD,wDAAwD;oBACxD,eAAe;oBACf,KAAK,CACJ,6CAA6C,EAC7C,MAAM,CAAC,WAAW,CAAC,IAAI,CACvB,CAAC;oBACD,MAA4B,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;oBACpD,OAAO;iBACP;gBAED,IAAI,MAAM,EAAE;oBACX,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE;wBACxB,IAAI,CAAC,UAAU,CAAC,MAAoB,EAAE,IAAI,CAAC,CAAC;oBAC7C,CAAC,CAAC,CAAC;oBACH,GAAG,CAAC,QAAQ,CAAC,MAAoB,CAAC,CAAC;oBACnC,OAAO;iBACP;gBAED,MAAM,GAAG,GAAG,IAAI,KAAK,CACpB,qDAAqD,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,IAAI,IAAI,CAC/E,CAAC;gBACF,OAAO,CAAC,GAAG,CAAC,CAAC;YACd,CAAC,CAAC;YAEF,IAAI,OAAO,IAAI,CAAC,QAAQ,KAAK,UAAU,EAAE;gBACxC,OAAO,CAAC,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC,CAAC;gBAChD,OAAO;aACP;YAED,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE;gBAC9B,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC,EAAE;oBAC9B,KAAK,CAAC,gDAAgD,CAAC,CAAC;oBACxD,IAAI,CAAC,mBAAmB,GAAG,mBAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;iBACpD;qBAAM;oBACN,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,QAAQ,CAAC;iBACzC;aACD;YAED,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,SAAS,GAAG,CAAC,EAAE;gBACnD,SAAS,GAAG,UAAU,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;aAC7C;YAED,IAAI,MAAM,IAAI,IAAI,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE;gBACpD,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aAC9B;YAED,IAAI;gBACH,KAAK,CACJ,qCAAqC,EACrC,IAAI,CAAC,QAAQ,EACb,GAAG,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,IAAI,EAAE,CAC3B,CAAC;gBACF,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,mBAAmB,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CACxD,QAAQ,EACR,aAAa,CACb,CAAC;aACF;YAAC,OAAO,GAAG,EAAE;gBACb,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;aACzC;QACF,CAAC;QAED,UAAU,CAAC,MAAkB,EAAE,IAAkB;YAChD,KAAK,CAAC,sBAAsB,EAAE,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAC7D,MAAM,CAAC,OAAO,EAAE,CAAC;QAClB,CAAC;QAED,OAAO;YACN,KAAK,CAAC,qBAAqB,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACrD,CAAC;KACD;IAxPY,iBAAK,QAwPjB,CAAA;IAED,uCAAuC;IACvC,WAAW,CAAC,SAAS,GAAG,WAAW,CAAC,KAAK,CAAC,SAAS,CAAC;AACrD,CAAC,EAtTS,WAAW,KAAX,WAAW,QAsTpB;AAED,iBAAS,WAAW,CAAC"}
node_modules/agent-base/dist/src/promisify.d.ts ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ import { ClientRequest, RequestOptions, AgentCallbackCallback, AgentCallbackPromise } from './index';
2
+ declare type LegacyCallback = (req: ClientRequest, opts: RequestOptions, fn: AgentCallbackCallback) => void;
3
+ export default function promisify(fn: LegacyCallback): AgentCallbackPromise;
4
+ export {};
node_modules/agent-base/dist/src/promisify.js ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ function promisify(fn) {
4
+ return function (req, opts) {
5
+ return new Promise((resolve, reject) => {
6
+ fn.call(this, req, opts, (err, rtn) => {
7
+ if (err) {
8
+ reject(err);
9
+ }
10
+ else {
11
+ resolve(rtn);
12
+ }
13
+ });
14
+ });
15
+ };
16
+ }
17
+ exports.default = promisify;
18
+ //# sourceMappingURL=promisify.js.map
node_modules/agent-base/dist/src/promisify.js.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"promisify.js","sourceRoot":"","sources":["../../src/promisify.ts"],"names":[],"mappings":";;AAeA,SAAwB,SAAS,CAAC,EAAkB;IACnD,OAAO,UAAsB,GAAkB,EAAE,IAAoB;QACpE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACtC,EAAE,CAAC,IAAI,CACN,IAAI,EACJ,GAAG,EACH,IAAI,EACJ,CAAC,GAA6B,EAAE,GAAyB,EAAE,EAAE;gBAC5D,IAAI,GAAG,EAAE;oBACR,MAAM,CAAC,GAAG,CAAC,CAAC;iBACZ;qBAAM;oBACN,OAAO,CAAC,GAAG,CAAC,CAAC;iBACb;YACF,CAAC,CACD,CAAC;QACH,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC;AACH,CAAC;AAjBD,4BAiBC"}
node_modules/agent-base/package.json ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "agent-base",
3
+ "version": "6.0.2",
4
+ "description": "Turn a function into an `http.Agent` instance",
5
+ "main": "dist/src/index",
6
+ "typings": "dist/src/index",
7
+ "files": [
8
+ "dist/src",
9
+ "src"
10
+ ],
11
+ "scripts": {
12
+ "prebuild": "rimraf dist",
13
+ "build": "tsc",
14
+ "postbuild": "cpy --parents src test '!**/*.ts' dist",
15
+ "test": "mocha --reporter spec dist/test/*.js",
16
+ "test-lint": "eslint src --ext .js,.ts",
17
+ "prepublishOnly": "npm run build"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git://github.com/TooTallNate/node-agent-base.git"
22
+ },
23
+ "keywords": [
24
+ "http",
25
+ "agent",
26
+ "base",
27
+ "barebones",
28
+ "https"
29
+ ],
30
+ "author": "Nathan Rajlich <[email protected]> (http://n8.io/)",
31
+ "license": "MIT",
32
+ "bugs": {
33
+ "url": "https://github.com/TooTallNate/node-agent-base/issues"
34
+ },
35
+ "dependencies": {
36
+ "debug": "4"
37
+ },
38
+ "devDependencies": {
39
+ "@types/debug": "4",
40
+ "@types/mocha": "^5.2.7",
41
+ "@types/node": "^14.0.20",
42
+ "@types/semver": "^7.1.0",
43
+ "@types/ws": "^6.0.3",
44
+ "@typescript-eslint/eslint-plugin": "1.6.0",
45
+ "@typescript-eslint/parser": "1.1.0",
46
+ "async-listen": "^1.2.0",
47
+ "cpy-cli": "^2.0.0",
48
+ "eslint": "5.16.0",
49
+ "eslint-config-airbnb": "17.1.0",
50
+ "eslint-config-prettier": "4.1.0",
51
+ "eslint-import-resolver-typescript": "1.1.1",
52
+ "eslint-plugin-import": "2.16.0",
53
+ "eslint-plugin-jsx-a11y": "6.2.1",
54
+ "eslint-plugin-react": "7.12.4",
55
+ "mocha": "^6.2.0",
56
+ "rimraf": "^3.0.0",
57
+ "semver": "^7.1.2",
58
+ "typescript": "^3.5.3",
59
+ "ws": "^3.0.0"
60
+ },
61
+ "engines": {
62
+ "node": ">= 6.0.0"
63
+ }
64
+ }
node_modules/agent-base/src/index.ts ADDED
@@ -0,0 +1,345 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import net from 'net';
2
+ import http from 'http';
3
+ import https from 'https';
4
+ import { Duplex } from 'stream';
5
+ import { EventEmitter } from 'events';
6
+ import createDebug from 'debug';
7
+ import promisify from './promisify';
8
+
9
+ const debug = createDebug('agent-base');
10
+
11
+ function isAgent(v: any): v is createAgent.AgentLike {
12
+ return Boolean(v) && typeof v.addRequest === 'function';
13
+ }
14
+
15
+ function isSecureEndpoint(): boolean {
16
+ const { stack } = new Error();
17
+ if (typeof stack !== 'string') return false;
18
+ return stack.split('\n').some(l => l.indexOf('(https.js:') !== -1 || l.indexOf('node:https:') !== -1);
19
+ }
20
+
21
+ function createAgent(opts?: createAgent.AgentOptions): createAgent.Agent;
22
+ function createAgent(
23
+ callback: createAgent.AgentCallback,
24
+ opts?: createAgent.AgentOptions
25
+ ): createAgent.Agent;
26
+ function createAgent(
27
+ callback?: createAgent.AgentCallback | createAgent.AgentOptions,
28
+ opts?: createAgent.AgentOptions
29
+ ) {
30
+ return new createAgent.Agent(callback, opts);
31
+ }
32
+
33
+ namespace createAgent {
34
+ export interface ClientRequest extends http.ClientRequest {
35
+ _last?: boolean;
36
+ _hadError?: boolean;
37
+ method: string;
38
+ }
39
+
40
+ export interface AgentRequestOptions {
41
+ host?: string;
42
+ path?: string;
43
+ // `port` on `http.RequestOptions` can be a string or undefined,
44
+ // but `net.TcpNetConnectOpts` expects only a number
45
+ port: number;
46
+ }
47
+
48
+ export interface HttpRequestOptions
49
+ extends AgentRequestOptions,
50
+ Omit<http.RequestOptions, keyof AgentRequestOptions> {
51
+ secureEndpoint: false;
52
+ }
53
+
54
+ export interface HttpsRequestOptions
55
+ extends AgentRequestOptions,
56
+ Omit<https.RequestOptions, keyof AgentRequestOptions> {
57
+ secureEndpoint: true;
58
+ }
59
+
60
+ export type RequestOptions = HttpRequestOptions | HttpsRequestOptions;
61
+
62
+ export type AgentLike = Pick<createAgent.Agent, 'addRequest'> | http.Agent;
63
+
64
+ export type AgentCallbackReturn = Duplex | AgentLike;
65
+
66
+ export type AgentCallbackCallback = (
67
+ err?: Error | null,
68
+ socket?: createAgent.AgentCallbackReturn
69
+ ) => void;
70
+
71
+ export type AgentCallbackPromise = (
72
+ req: createAgent.ClientRequest,
73
+ opts: createAgent.RequestOptions
74
+ ) =>
75
+ | createAgent.AgentCallbackReturn
76
+ | Promise<createAgent.AgentCallbackReturn>;
77
+
78
+ export type AgentCallback = typeof Agent.prototype.callback;
79
+
80
+ export type AgentOptions = {
81
+ timeout?: number;
82
+ };
83
+
84
+ /**
85
+ * Base `http.Agent` implementation.
86
+ * No pooling/keep-alive is implemented by default.
87
+ *
88
+ * @param {Function} callback
89
+ * @api public
90
+ */
91
+ export class Agent extends EventEmitter {
92
+ public timeout: number | null;
93
+ public maxFreeSockets: number;
94
+ public maxTotalSockets: number;
95
+ public maxSockets: number;
96
+ public sockets: {
97
+ [key: string]: net.Socket[];
98
+ };
99
+ public freeSockets: {
100
+ [key: string]: net.Socket[];
101
+ };
102
+ public requests: {
103
+ [key: string]: http.IncomingMessage[];
104
+ };
105
+ public options: https.AgentOptions;
106
+ private promisifiedCallback?: createAgent.AgentCallbackPromise;
107
+ private explicitDefaultPort?: number;
108
+ private explicitProtocol?: string;
109
+
110
+ constructor(
111
+ callback?: createAgent.AgentCallback | createAgent.AgentOptions,
112
+ _opts?: createAgent.AgentOptions
113
+ ) {
114
+ super();
115
+
116
+ let opts = _opts;
117
+ if (typeof callback === 'function') {
118
+ this.callback = callback;
119
+ } else if (callback) {
120
+ opts = callback;
121
+ }
122
+
123
+ // Timeout for the socket to be returned from the callback
124
+ this.timeout = null;
125
+ if (opts && typeof opts.timeout === 'number') {
126
+ this.timeout = opts.timeout;
127
+ }
128
+
129
+ // These aren't actually used by `agent-base`, but are required
130
+ // for the TypeScript definition files in `@types/node` :/
131
+ this.maxFreeSockets = 1;
132
+ this.maxSockets = 1;
133
+ this.maxTotalSockets = Infinity;
134
+ this.sockets = {};
135
+ this.freeSockets = {};
136
+ this.requests = {};
137
+ this.options = {};
138
+ }
139
+
140
+ get defaultPort(): number {
141
+ if (typeof this.explicitDefaultPort === 'number') {
142
+ return this.explicitDefaultPort;
143
+ }
144
+ return isSecureEndpoint() ? 443 : 80;
145
+ }
146
+
147
+ set defaultPort(v: number) {
148
+ this.explicitDefaultPort = v;
149
+ }
150
+
151
+ get protocol(): string {
152
+ if (typeof this.explicitProtocol === 'string') {
153
+ return this.explicitProtocol;
154
+ }
155
+ return isSecureEndpoint() ? 'https:' : 'http:';
156
+ }
157
+
158
+ set protocol(v: string) {
159
+ this.explicitProtocol = v;
160
+ }
161
+
162
+ callback(
163
+ req: createAgent.ClientRequest,
164
+ opts: createAgent.RequestOptions,
165
+ fn: createAgent.AgentCallbackCallback
166
+ ): void;
167
+ callback(
168
+ req: createAgent.ClientRequest,
169
+ opts: createAgent.RequestOptions
170
+ ):
171
+ | createAgent.AgentCallbackReturn
172
+ | Promise<createAgent.AgentCallbackReturn>;
173
+ callback(
174
+ req: createAgent.ClientRequest,
175
+ opts: createAgent.AgentOptions,
176
+ fn?: createAgent.AgentCallbackCallback
177
+ ):
178
+ | createAgent.AgentCallbackReturn
179
+ | Promise<createAgent.AgentCallbackReturn>
180
+ | void {
181
+ throw new Error(
182
+ '"agent-base" has no default implementation, you must subclass and override `callback()`'
183
+ );
184
+ }
185
+
186
+ /**
187
+ * Called by node-core's "_http_client.js" module when creating
188
+ * a new HTTP request with this Agent instance.
189
+ *
190
+ * @api public
191
+ */
192
+ addRequest(req: ClientRequest, _opts: RequestOptions): void {
193
+ const opts: RequestOptions = { ..._opts };
194
+
195
+ if (typeof opts.secureEndpoint !== 'boolean') {
196
+ opts.secureEndpoint = isSecureEndpoint();
197
+ }
198
+
199
+ if (opts.host == null) {
200
+ opts.host = 'localhost';
201
+ }
202
+
203
+ if (opts.port == null) {
204
+ opts.port = opts.secureEndpoint ? 443 : 80;
205
+ }
206
+
207
+ if (opts.protocol == null) {
208
+ opts.protocol = opts.secureEndpoint ? 'https:' : 'http:';
209
+ }
210
+
211
+ if (opts.host && opts.path) {
212
+ // If both a `host` and `path` are specified then it's most
213
+ // likely the result of a `url.parse()` call... we need to
214
+ // remove the `path` portion so that `net.connect()` doesn't
215
+ // attempt to open that as a unix socket file.
216
+ delete opts.path;
217
+ }
218
+
219
+ delete opts.agent;
220
+ delete opts.hostname;
221
+ delete opts._defaultAgent;
222
+ delete opts.defaultPort;
223
+ delete opts.createConnection;
224
+
225
+ // Hint to use "Connection: close"
226
+ // XXX: non-documented `http` module API :(
227
+ req._last = true;
228
+ req.shouldKeepAlive = false;
229
+
230
+ let timedOut = false;
231
+ let timeoutId: ReturnType<typeof setTimeout> | null = null;
232
+ const timeoutMs = opts.timeout || this.timeout;
233
+
234
+ const onerror = (err: NodeJS.ErrnoException) => {
235
+ if (req._hadError) return;
236
+ req.emit('error', err);
237
+ // For Safety. Some additional errors might fire later on
238
+ // and we need to make sure we don't double-fire the error event.
239
+ req._hadError = true;
240
+ };
241
+
242
+ const ontimeout = () => {
243
+ timeoutId = null;
244
+ timedOut = true;
245
+ const err: NodeJS.ErrnoException = new Error(
246
+ `A "socket" was not created for HTTP request before ${timeoutMs}ms`
247
+ );
248
+ err.code = 'ETIMEOUT';
249
+ onerror(err);
250
+ };
251
+
252
+ const callbackError = (err: NodeJS.ErrnoException) => {
253
+ if (timedOut) return;
254
+ if (timeoutId !== null) {
255
+ clearTimeout(timeoutId);
256
+ timeoutId = null;
257
+ }
258
+ onerror(err);
259
+ };
260
+
261
+ const onsocket = (socket: AgentCallbackReturn) => {
262
+ if (timedOut) return;
263
+ if (timeoutId != null) {
264
+ clearTimeout(timeoutId);
265
+ timeoutId = null;
266
+ }
267
+
268
+ if (isAgent(socket)) {
269
+ // `socket` is actually an `http.Agent` instance, so
270
+ // relinquish responsibility for this `req` to the Agent
271
+ // from here on
272
+ debug(
273
+ 'Callback returned another Agent instance %o',
274
+ socket.constructor.name
275
+ );
276
+ (socket as createAgent.Agent).addRequest(req, opts);
277
+ return;
278
+ }
279
+
280
+ if (socket) {
281
+ socket.once('free', () => {
282
+ this.freeSocket(socket as net.Socket, opts);
283
+ });
284
+ req.onSocket(socket as net.Socket);
285
+ return;
286
+ }
287
+
288
+ const err = new Error(
289
+ `no Duplex stream was returned to agent-base for \`${req.method} ${req.path}\``
290
+ );
291
+ onerror(err);
292
+ };
293
+
294
+ if (typeof this.callback !== 'function') {
295
+ onerror(new Error('`callback` is not defined'));
296
+ return;
297
+ }
298
+
299
+ if (!this.promisifiedCallback) {
300
+ if (this.callback.length >= 3) {
301
+ debug('Converting legacy callback function to promise');
302
+ this.promisifiedCallback = promisify(this.callback);
303
+ } else {
304
+ this.promisifiedCallback = this.callback;
305
+ }
306
+ }
307
+
308
+ if (typeof timeoutMs === 'number' && timeoutMs > 0) {
309
+ timeoutId = setTimeout(ontimeout, timeoutMs);
310
+ }
311
+
312
+ if ('port' in opts && typeof opts.port !== 'number') {
313
+ opts.port = Number(opts.port);
314
+ }
315
+
316
+ try {
317
+ debug(
318
+ 'Resolving socket for %o request: %o',
319
+ opts.protocol,
320
+ `${req.method} ${req.path}`
321
+ );
322
+ Promise.resolve(this.promisifiedCallback(req, opts)).then(
323
+ onsocket,
324
+ callbackError
325
+ );
326
+ } catch (err) {
327
+ Promise.reject(err).catch(callbackError);
328
+ }
329
+ }
330
+
331
+ freeSocket(socket: net.Socket, opts: AgentOptions) {
332
+ debug('Freeing socket %o %o', socket.constructor.name, opts);
333
+ socket.destroy();
334
+ }
335
+
336
+ destroy() {
337
+ debug('Destroying agent %o', this.constructor.name);
338
+ }
339
+ }
340
+
341
+ // So that `instanceof` works correctly
342
+ createAgent.prototype = createAgent.Agent.prototype;
343
+ }
344
+
345
+ export = createAgent;
node_modules/agent-base/src/promisify.ts ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import {
2
+ Agent,
3
+ ClientRequest,
4
+ RequestOptions,
5
+ AgentCallbackCallback,
6
+ AgentCallbackPromise,
7
+ AgentCallbackReturn
8
+ } from './index';
9
+
10
+ type LegacyCallback = (
11
+ req: ClientRequest,
12
+ opts: RequestOptions,
13
+ fn: AgentCallbackCallback
14
+ ) => void;
15
+
16
+ export default function promisify(fn: LegacyCallback): AgentCallbackPromise {
17
+ return function(this: Agent, req: ClientRequest, opts: RequestOptions) {
18
+ return new Promise((resolve, reject) => {
19
+ fn.call(
20
+ this,
21
+ req,
22
+ opts,
23
+ (err: Error | null | undefined, rtn?: AgentCallbackReturn) => {
24
+ if (err) {
25
+ reject(err);
26
+ } else {
27
+ resolve(rtn);
28
+ }
29
+ }
30
+ );
31
+ });
32
+ };
33
+ }
node_modules/bent/.github/workflows/mikeals-workflow.yml ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ on: [push, pull_request]
2
+ name: Build, Test and maybe Publish
3
+ jobs:
4
+ test:
5
+ name: Build & Test
6
+ runs-on: ubuntu-latest
7
+ strategy:
8
+ matrix:
9
+ node-version: [12.x, 14.x]
10
+ steps:
11
+ - uses: actions/checkout@v2
12
+ - name: Use Node.js ${{ matrix.node-version }}
13
+ uses: actions/setup-node@v1
14
+ with:
15
+ node-version: ${{ matrix.node-version }}
16
+ - name: Cache node_modules
17
+ id: cache-modules
18
+ uses: actions/cache@v1
19
+ with:
20
+ path: node_modules
21
+ key: ${{ matrix.node-version }}-${{ runner.OS }}-build-${{ hashFiles('package.json') }}
22
+ - name: Build
23
+ if: steps.cache-modules.outputs.cache-hit != 'true'
24
+ run: npm install
25
+ - name: Test
26
+ run: npm_config_yes=true npx best-test@latest
27
+ publish:
28
+ name: Publish
29
+ needs: test
30
+ runs-on: ubuntu-latest
31
+ if: github.event_name == 'push' && ( github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' )
32
+ steps:
33
+ - uses: actions/checkout@v2
34
+ - name: Cache node_modules
35
+ id: cache-modules
36
+ uses: actions/cache@v1
37
+ with:
38
+ path: node_modules
39
+ key: 12.x-${{ runner.OS }}-build-${{ hashFiles('package.json') }}
40
+ - name: Build
41
+ if: steps.cache-modules.outputs.cache-hit != 'true'
42
+ run: npm install
43
+ - name: Test
44
+ run: npm_config_yes=true npx best-test@latest
45
+
46
+ - name: Publish
47
+ uses: mikeal/merge-release@master
48
+ env:
49
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50
+ NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
node_modules/bent/README.md ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # bent
2
+
3
+ ![2377](https://img.shields.io/badge/compiled%20bundle-2k-brightgreen) ![1106](https://img.shields.io/badge/gzipped%20bundle-1k-brightgreen)
4
+
5
+ Functional HTTP client for Node.js and Browsers with async/await.
6
+
7
+ *Incredibly small browser version built on fetch with no external dependencies or polyfills.*
8
+
9
+ ## Usage
10
+
11
+ ```javascript
12
+ const bent = require('bent')
13
+
14
+ const getJSON = bent('json')
15
+ const getBuffer = bent('buffer')
16
+
17
+ let obj = await getJSON('http://site.com/json.api')
18
+ let buffer = await getBuffer('http://site.com/image.png')
19
+ ```
20
+
21
+ As you can see, bent is a function that returns an async function.
22
+
23
+ Bent takes options which constrain what is accepted by the client.
24
+ Any response that falls outside the constraints will generate an error.
25
+
26
+ You can provide these options in any order, and Bent will figure out which option is which by inspecting the option's type and content.
27
+ ```javascript
28
+ const post = bent('http://localhost:3000/', 'POST', 'json', 200);
29
+ const response = await post('cars/new', {name: 'bmw', wheels: 4});
30
+ ```
31
+
32
+ If you don't set a response encoding (`'json'`, `'string'` or `'buffer'`)
33
+ then the *native* response object will be returned after the statusCode check.
34
+
35
+ In Node.js, we also add decoding methods that match the Fetch API (`.json()`,
36
+ `.text()` and `.arrayBuffer()`).
37
+
38
+ ```javascript
39
+ const bent = require('bent')
40
+
41
+ const getStream = bent('http://site.com')
42
+
43
+ let stream = await getStream('/json.api')
44
+ // status code
45
+ stream.status // 200
46
+ stream.statusCode // 200
47
+ // optionally decode
48
+ const obj = await stream.json()
49
+ // or
50
+ const str = await stream.text()
51
+ ```
52
+
53
+ The following options are available.
54
+
55
+ * **HTTP Method**: `'GET'`, `'PUT'`, or any other ALLCAPS string will be
56
+ used to set the HTTP method. Defaults to `'GET'`.
57
+ * **Response Format**: Available formats are `'string'`, `'buffer'`, and
58
+ `'json'`. By default, the response object/stream will be returned instead
59
+ of a decoded response. *Browser returns `ArrayBuffer` instead of `Buffer`.*
60
+ * **Status Codes**: Any number will be considered an acceptable status code.
61
+ By default, `200` is the only acceptable status code. When any status codes
62
+ are provided, `200` must be included explicitly in order to be acceptable.
63
+ * **Headers**: An object can be passed to set request headers.
64
+ * **Base URL**: Any string that begins with 'https:' or 'http:' is
65
+ considered the Base URL. Subsequent queries need only pass the remaining
66
+ URL string.
67
+
68
+ The returned async function is used for subsequent requests.
69
+
70
+ When working with Binary this library uses different types in the browser and Node.js. In Node.js all binary must be done
71
+ using the `Buffer` type. In the browser you can use ArrayBuffer or any ArrayBuffer view type (UInt8Array, etc).
72
+
73
+ ### `async request(url[, body=null, headers={}])`
74
+
75
+ * **url**: Fully qualified URL to the remote resource, or in the case that a
76
+ base URL is passed the remaining URL string.
77
+ * **body**: Request body. Can be a string, a stream (node.js), a buffer (node.js) (see note below),
78
+ an ArrayBuffer (browser), or a JSON object.
79
+ * **headers**: An object of any headers you need to set for just this request.
80
+
81
+ ```javascript
82
+ const bent = require('bent')
83
+
84
+ const put = bent('PUT', 201)
85
+ await put('http://site.com/upload', Buffer.from('test'))
86
+ ```
87
+
88
+ Or
89
+
90
+
91
+ ```javascript
92
+ const bent = require('bent')
93
+
94
+ const put = bent('PUT', 201, 'http://site.com')
95
+ await put('/upload', Buffer.from('test'))
96
+ ```
97
+
98
+ **NOTE:** If the `body` is passed as an `object`, it will be treated
99
+ as JSON, stringified and the `Content-Type` will be set to `application/json`
100
+ unless already set. A common requirement is to POST using `form-urlencoded`.
101
+ This will require you to set the `Content-Type` header to
102
+ `application/x-www-form-urlencoded` and to encode the body yourself,
103
+ perhaps using
104
+ [form-urlencoded](https://www.npmjs.com/package/form-urlencoded).
node_modules/bent/package.json ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "bent",
3
+ "version": "7.3.12",
4
+ "description": "Functional HTTP client for Node.js w/ async/await.",
5
+ "main": "src/nodejs.js",
6
+ "browser": "src/browser.js",
7
+ "scripts": {
8
+ "lint": "standard",
9
+ "test:node": "hundreds mocha --timeout=5000 test/test-*.js",
10
+ "test:browser": "polendina --cleanup --service-worker --worker test/test-*.js",
11
+ "test": "npm run lint && npm run test:node && npm run test:browser",
12
+ "coverage": "nyc --reporter=html mocha test/test-*.js && npx http-server coverage"
13
+ },
14
+ "keywords": [],
15
+ "author": "Mikeal Rogers <[email protected]> (http://www.mikealrogers.com)",
16
+ "license": "Apache-2.0",
17
+ "dependencies": {
18
+ "bytesish": "^0.4.1",
19
+ "caseless": "~0.12.0",
20
+ "is-stream": "^2.0.0"
21
+ },
22
+ "devDependencies": {
23
+ "hundreds": "0.0.2",
24
+ "mocha": "^7.0.1",
25
+ "polendina": "1.0.0",
26
+ "standard": "^14.3.1",
27
+ "tsame": "^2.0.1"
28
+ },
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "https://github.com/mikeal/bent.git"
32
+ }
33
+ }
node_modules/bent/src/browser.js ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+ /* global fetch, btoa, Headers */
3
+ const core = require('./core')
4
+
5
+ class StatusError extends Error {
6
+ constructor (res, ...params) {
7
+ super(...params)
8
+
9
+ if (Error.captureStackTrace) {
10
+ Error.captureStackTrace(this, StatusError)
11
+ }
12
+
13
+ this.name = 'StatusError'
14
+ this.message = res.statusMessage
15
+ this.statusCode = res.status
16
+ this.res = res
17
+ this.json = res.json.bind(res)
18
+ this.text = res.text.bind(res)
19
+ this.arrayBuffer = res.arrayBuffer.bind(res)
20
+ let buffer
21
+ const get = () => {
22
+ if (!buffer) buffer = this.arrayBuffer()
23
+ return buffer
24
+ }
25
+ Object.defineProperty(this, 'responseBody', { get })
26
+ // match Node.js headers object
27
+ this.headers = {}
28
+ for (const [key, value] of res.headers.entries()) {
29
+ this.headers[key.toLowerCase()] = value
30
+ }
31
+ }
32
+ }
33
+
34
+ const mkrequest = (statusCodes, method, encoding, headers, baseurl) => async (_url, body, _headers = {}) => {
35
+ _url = baseurl + (_url || '')
36
+ let parsed = new URL(_url)
37
+
38
+ if (!headers) headers = {}
39
+ if (parsed.username) {
40
+ headers.Authorization = 'Basic ' + btoa(parsed.username + ':' + parsed.password)
41
+ parsed = new URL(parsed.protocol + '//' + parsed.host + parsed.pathname + parsed.search)
42
+ }
43
+ if (parsed.protocol !== 'https:' && parsed.protocol !== 'http:') {
44
+ throw new Error(`Unknown protocol, ${parsed.protocol}`)
45
+ }
46
+
47
+ if (body) {
48
+ if (body instanceof ArrayBuffer ||
49
+ ArrayBuffer.isView(body) ||
50
+ typeof body === 'string'
51
+ ) {
52
+ // noop
53
+ } else if (typeof body === 'object') {
54
+ body = JSON.stringify(body)
55
+ headers['Content-Type'] = 'application/json'
56
+ } else {
57
+ throw new Error('Unknown body type.')
58
+ }
59
+ }
60
+
61
+ _headers = new Headers({ ...(headers || {}), ..._headers })
62
+
63
+ const resp = await fetch(parsed, { method, headers: _headers, body })
64
+ resp.statusCode = resp.status
65
+
66
+ if (!statusCodes.has(resp.status)) {
67
+ throw new StatusError(resp)
68
+ }
69
+
70
+ if (encoding === 'json') return resp.json()
71
+ else if (encoding === 'buffer') return resp.arrayBuffer()
72
+ else if (encoding === 'string') return resp.text()
73
+ else return resp
74
+ }
75
+
76
+ module.exports = core(mkrequest)
node_modules/bent/src/core.js ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+ const encodings = new Set(['json', 'buffer', 'string'])
3
+
4
+ module.exports = mkrequest => (...args) => {
5
+ const statusCodes = new Set()
6
+ let method
7
+ let encoding
8
+ let headers
9
+ let baseurl = ''
10
+
11
+ args.forEach(arg => {
12
+ if (typeof arg === 'string') {
13
+ if (arg.toUpperCase() === arg) {
14
+ if (method) {
15
+ const msg = `Can't set method to ${arg}, already set to ${method}.`
16
+ throw new Error(msg)
17
+ } else {
18
+ method = arg
19
+ }
20
+ } else if (arg.startsWith('http:') || arg.startsWith('https:')) {
21
+ baseurl = arg
22
+ } else {
23
+ if (encodings.has(arg)) {
24
+ encoding = arg
25
+ } else {
26
+ throw new Error(`Unknown encoding, ${arg}`)
27
+ }
28
+ }
29
+ } else if (typeof arg === 'number') {
30
+ statusCodes.add(arg)
31
+ } else if (typeof arg === 'object') {
32
+ if (Array.isArray(arg) || arg instanceof Set) {
33
+ arg.forEach(code => statusCodes.add(code))
34
+ } else {
35
+ if (headers) {
36
+ throw new Error('Cannot set headers twice.')
37
+ }
38
+ headers = arg
39
+ }
40
+ } else {
41
+ throw new Error(`Unknown type: ${typeof arg}`)
42
+ }
43
+ })
44
+
45
+ if (!method) method = 'GET'
46
+ if (statusCodes.size === 0) {
47
+ statusCodes.add(200)
48
+ }
49
+
50
+ return mkrequest(statusCodes, method, encoding, headers, baseurl)
51
+ }
node_modules/bent/src/nodejs.js ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+ const http = require('http')
3
+ const https = require('https')
4
+ const { URL } = require('url')
5
+ const isStream = require('is-stream')
6
+ const caseless = require('caseless')
7
+ const bytes = require('bytesish')
8
+ const bent = require('./core')
9
+ const zlib = require('zlib')
10
+ const { PassThrough } = require('stream')
11
+
12
+ const compression = {}
13
+
14
+ /* istanbul ignore else */
15
+ if (zlib.createBrotliDecompress) compression.br = () => zlib.createBrotliDecompress()
16
+ /* istanbul ignore else */
17
+ if (zlib.createGunzip) compression.gzip = () => zlib.createGunzip()
18
+ /* istanbul ignore else */
19
+ if (zlib.createInflate) compression.deflate = () => zlib.createInflate()
20
+
21
+ const acceptEncoding = Object.keys(compression).join(', ')
22
+
23
+ const getResponse = resp => {
24
+ const ret = new PassThrough()
25
+ ret.statusCode = resp.statusCode
26
+ ret.status = resp.statusCode
27
+ ret.statusMessage = resp.statusMessage
28
+ ret.headers = resp.headers
29
+ ret._response = resp
30
+ if (ret.headers['content-encoding']) {
31
+ const encodings = ret.headers['content-encoding'].split(', ').reverse()
32
+ while (encodings.length) {
33
+ const enc = encodings.shift()
34
+ if (compression[enc]) {
35
+ const decompress = compression[enc]()
36
+ decompress.on('error', (e) => ret.emit('error', new Error('ZBufError', e)))
37
+ resp = resp.pipe(decompress)
38
+ } else {
39
+ break
40
+ }
41
+ }
42
+ }
43
+ return resp.pipe(ret)
44
+ }
45
+
46
+ class StatusError extends Error {
47
+ constructor (res, ...params) {
48
+ super(...params)
49
+
50
+ Error.captureStackTrace(this, StatusError)
51
+ this.name = 'StatusError'
52
+ this.message = res.statusMessage
53
+ this.statusCode = res.statusCode
54
+ this.json = res.json
55
+ this.text = res.text
56
+ this.arrayBuffer = res.arrayBuffer
57
+ this.headers = res.headers
58
+ let buffer
59
+ const get = () => {
60
+ if (!buffer) buffer = this.arrayBuffer()
61
+ return buffer
62
+ }
63
+ Object.defineProperty(this, 'responseBody', { get })
64
+ }
65
+ }
66
+
67
+ const getBuffer = stream => new Promise((resolve, reject) => {
68
+ const parts = []
69
+ stream.on('error', reject)
70
+ stream.on('end', () => resolve(Buffer.concat(parts)))
71
+ stream.on('data', d => parts.push(d))
72
+ })
73
+
74
+ const decodings = res => {
75
+ let _buffer
76
+ res.arrayBuffer = () => {
77
+ if (!_buffer) {
78
+ _buffer = getBuffer(res)
79
+ return _buffer
80
+ } else {
81
+ throw new Error('body stream is locked')
82
+ }
83
+ }
84
+ res.text = () => res.arrayBuffer().then(buff => buff.toString())
85
+ res.json = async () => {
86
+ const str = await res.text()
87
+ try {
88
+ return JSON.parse(str)
89
+ } catch (e) {
90
+ e.message += `str"${str}"`
91
+ throw e
92
+ }
93
+ }
94
+ }
95
+
96
+ const mkrequest = (statusCodes, method, encoding, headers, baseurl) => (_url, body = null, _headers = {}) => {
97
+ _url = baseurl + (_url || '')
98
+ const parsed = new URL(_url)
99
+ let h
100
+ if (parsed.protocol === 'https:') {
101
+ h = https
102
+ } else if (parsed.protocol === 'http:') {
103
+ h = http
104
+ } else {
105
+ throw new Error(`Unknown protocol, ${parsed.protocol}`)
106
+ }
107
+ const request = {
108
+ path: parsed.pathname + parsed.search,
109
+ port: parsed.port,
110
+ method: method,
111
+ headers: { ...(headers || {}), ..._headers },
112
+ hostname: parsed.hostname
113
+ }
114
+ if (parsed.username || parsed.password) {
115
+ request.auth = [parsed.username, parsed.password].join(':')
116
+ }
117
+ const c = caseless(request.headers)
118
+ if (encoding === 'json') {
119
+ if (!c.get('accept')) {
120
+ c.set('accept', 'application/json')
121
+ }
122
+ }
123
+ if (!c.has('accept-encoding')) {
124
+ c.set('accept-encoding', acceptEncoding)
125
+ }
126
+ return new Promise((resolve, reject) => {
127
+ const req = h.request(request, async res => {
128
+ res = getResponse(res)
129
+ res.on('error', reject)
130
+ decodings(res)
131
+ res.status = res.statusCode
132
+ if (!statusCodes.has(res.statusCode)) {
133
+ return reject(new StatusError(res))
134
+ }
135
+
136
+ if (!encoding) return resolve(res)
137
+ else {
138
+ /* istanbul ignore else */
139
+ if (encoding === 'buffer') {
140
+ resolve(res.arrayBuffer())
141
+ } else if (encoding === 'json') {
142
+ resolve(res.json())
143
+ } else if (encoding === 'string') {
144
+ resolve(res.text())
145
+ }
146
+ }
147
+ })
148
+ req.on('error', reject)
149
+ if (body) {
150
+ if (body instanceof ArrayBuffer || ArrayBuffer.isView(body)) {
151
+ body = bytes.native(body)
152
+ }
153
+ if (Buffer.isBuffer(body)) {
154
+ // noop
155
+ } else if (typeof body === 'string') {
156
+ body = Buffer.from(body)
157
+ } else if (isStream(body)) {
158
+ body.pipe(req)
159
+ body = null
160
+ } else if (typeof body === 'object') {
161
+ if (!c.has('content-type')) {
162
+ req.setHeader('content-type', 'application/json')
163
+ }
164
+ body = Buffer.from(JSON.stringify(body))
165
+ } else {
166
+ reject(new Error('Unknown body type.'))
167
+ }
168
+ if (body) {
169
+ req.setHeader('content-length', body.length)
170
+ req.end(body)
171
+ }
172
+ } else {
173
+ req.end()
174
+ }
175
+ })
176
+ }
177
+
178
+ module.exports = bent(mkrequest)
node_modules/bent/test/test-basics.js ADDED
@@ -0,0 +1,255 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* globals atob, it */
2
+ 'use strict'
3
+ const bent = require('../')
4
+ const assert = require('assert')
5
+ const tsame = require('tsame')
6
+ const { PassThrough } = require('stream')
7
+
8
+ const http = require('http')
9
+
10
+ const test = it
11
+
12
+ const same = (x, y) => assert.ok(tsame(x, y))
13
+
14
+ const baseurl = 'https://echo-server.mikeal.now.sh/src'
15
+ const u = path => baseurl + path
16
+
17
+ const enc = str => (new TextEncoder()).encode(str).buffer
18
+ const dec = str => Uint8Array.from(atob(str), c => c.charCodeAt(0)).buffer
19
+ const decode = arr => (new TextDecoder('utf-8')).decode(arr)
20
+
21
+ test('basic 200 ok', async () => {
22
+ const request = bent('string')
23
+ const str = await request(u('/echo.js?body=ok'))
24
+ same(str, 'ok')
25
+ })
26
+
27
+ test('basic 200 ok baseurl', async () => {
28
+ const request = bent('string', baseurl)
29
+ const str = await request('/echo.js?body=ok')
30
+ same(str, 'ok')
31
+ })
32
+
33
+ test('basic 200', async () => {
34
+ const request = bent()
35
+ const res = await request(u('/echo.js?body=ok'))
36
+ same(res.statusCode, 200)
37
+ })
38
+
39
+ test('basic buffer', async () => {
40
+ const request = bent('buffer')
41
+ const buff = await request(u('/echo.js?body=ok'))
42
+ if (buff instanceof ArrayBuffer) {
43
+ same(buff, enc('ok'))
44
+ } else {
45
+ same(buff, Buffer.from('ok'))
46
+ }
47
+ })
48
+
49
+ test('double buffer decode', async () => {
50
+ const request = bent()
51
+ const resp = await request(u('/echo.js?body=ok'))
52
+ const validate = buff => {
53
+ if (buff instanceof ArrayBuffer) {
54
+ same(buff, enc('ok'))
55
+ } else {
56
+ same(buff, Buffer.from('ok'))
57
+ }
58
+ }
59
+ validate(await resp.arrayBuffer())
60
+ let threw = true
61
+ try {
62
+ await resp.arrayBuffer()
63
+ threw = false
64
+ } catch (e) {
65
+ if (!e.message.includes('body stream is locked')) throw e
66
+ }
67
+ assert.ok(threw)
68
+ })
69
+
70
+ test('basic json', async () => {
71
+ const request = bent('json')
72
+ const json = await request(u('/info.js'))
73
+ same(json.method, 'GET')
74
+ })
75
+
76
+ test('json based media type', async () => {
77
+ const request = bent('json', { accept: 'application/vnd.something.com' })
78
+ const json = await request(u('/info.js'))
79
+ same(json.headers.accept, 'application/vnd.something.com')
80
+ })
81
+
82
+ test('basic PUT', async () => {
83
+ const request = bent('PUT', 'json')
84
+ let body
85
+ if (process.browser) {
86
+ body = enc(Math.random().toString())
87
+ } else {
88
+ body = Buffer.from(Math.random().toString())
89
+ }
90
+ const json = await request(u('/info.js'), body)
91
+ if (process.browser) {
92
+ same(dec(json.base64), body)
93
+ } else {
94
+ same(Buffer.from(json.base64, 'base64'), body)
95
+ }
96
+ })
97
+
98
+ test('base PUT string', async () => {
99
+ const request = bent('PUT', 'json')
100
+ const json = await request(u('/info.js'), 'teststring')
101
+ if (process.browser) {
102
+ same(atob(json.base64), 'teststring')
103
+ } else {
104
+ same(Buffer.from(json.base64, 'base64').toString(), 'teststring')
105
+ }
106
+ })
107
+
108
+ test('status 201', async () => {
109
+ const request = bent('string', 201)
110
+ const str = await request(u('/echo.js?statusCode=201&body=ok'))
111
+ same(str, 'ok')
112
+
113
+ try {
114
+ await request(u('/echo.js?body=ok'))
115
+ throw new Error('Call should have thrown.')
116
+ } catch (e) {
117
+ same(e.message, process.browser ? null : 'OK')
118
+ // basic header test
119
+ same(e.headers['content-length'], '2')
120
+ }
121
+ })
122
+
123
+ test('multiple status', async () => {
124
+ const request = bent('string', [200, 201])
125
+ const str200 = await request(u('/echo.js?body=ok'))
126
+ same(str200, 'ok')
127
+
128
+ const str201 = await request(u('/echo.js?statusCode=201&body=ok'))
129
+ same(str201, 'ok')
130
+
131
+ try {
132
+ await request(u('/echo.js?statusCode=202&body=ok'))
133
+ throw new Error('Call should have thrown.')
134
+ } catch (e) {
135
+ same(e.message, process.browser ? null : 'Accepted')
136
+ // basic header test
137
+ same(e.headers['content-length'], '2')
138
+ }
139
+ })
140
+
141
+ test('PUT stream', async () => {
142
+ const body = Buffer.from(Math.random().toString())
143
+ const request = bent('PUT', 'json')
144
+ const b = new PassThrough()
145
+ const res = request(u('/info.js'), b)
146
+ b.end(body)
147
+ const info = await res
148
+ same(info.method, 'PUT')
149
+ // Unfortunately, we can't test this against lamda cause it doesn't support
150
+ // transfer-encoding: chunked.
151
+ // t.same(Buffer.from(info.base64, 'base64'), body)
152
+ })
153
+
154
+ test('PUT JSON', async () => {
155
+ const request = bent('PUT', 'json')
156
+ const info = await request(u('/info.js'), { ok: 200 })
157
+ let res
158
+ if (process.browser) {
159
+ res = JSON.parse(atob(info.base64))
160
+ } else {
161
+ res = JSON.parse(Buffer.from(info.base64, 'base64').toString())
162
+ }
163
+ same(res, { ok: 200 })
164
+ same(info.headers['content-type'], 'application/json')
165
+ })
166
+
167
+ if (process.browser) {
168
+ test('500 Response body and message', async () => {
169
+ const request = bent()
170
+ let body
171
+ let _e
172
+ try {
173
+ await request(u('/echo.js?statusCode=500&body=ok'))
174
+ } catch (e) {
175
+ _e = e
176
+ body = e.responseBody
177
+ }
178
+ const validate = buffer => {
179
+ if (process.browser) {
180
+ same(decode(buffer), 'ok')
181
+ } else {
182
+ same(buffer.toString(), 'ok')
183
+ }
184
+ }
185
+ validate(await body)
186
+ // should be able to access again
187
+ validate(await _e.responseBody)
188
+
189
+ same(_e.message, null)
190
+ })
191
+ } else {
192
+ test('500 Response body and message', async () => {
193
+ const request = bent()
194
+ let body
195
+ let _e
196
+ try {
197
+ await request(u('/echo.js?statusCode=500&body=ok'))
198
+ } catch (e) {
199
+ _e = e
200
+ body = e.responseBody
201
+ }
202
+ const validate = buffer => {
203
+ if (process.browser) {
204
+ same(decode(buffer), 'ok')
205
+ } else {
206
+ same(buffer.toString(), 'ok')
207
+ }
208
+ }
209
+ validate(await body)
210
+ // should be able to access again
211
+ validate(await _e.responseBody)
212
+
213
+ same(_e.message, 'Internal Server Error')
214
+ })
215
+ }
216
+
217
+ test('auth', async () => {
218
+ const request = bent('https://test:[email protected]/basic-auth/test/pass', 'json')
219
+ const obj = await request()
220
+ same(obj, { authenticated: true, user: 'test' })
221
+ })
222
+
223
+ if (process.browser) {
224
+ test('override headers', async () => {
225
+ const request = bent('string', { Accept: 'application/json' })
226
+ let info = await request(u('/info.js'), null, { Accept: 'application/xml' })
227
+ info = JSON.parse(info)
228
+ same(info.headers.accept, 'application/xml')
229
+ })
230
+ } else {
231
+ test('override headers', async () => {
232
+ const request = bent('json', { 'X-Default': 'ok', 'X-Override-Me': 'not overriden' })
233
+ const info = await request(u('/info.js'), null, { 'X-Override-Me': 'overriden', 'X-New': 'ok' })
234
+ same(info.headers['x-default'], 'ok')
235
+ same(info.headers['x-override-me'], 'overriden')
236
+ same(info.headers['x-new'], 'ok')
237
+ })
238
+
239
+ test('manually-set content-type header when body is present', async () => {
240
+ const server = http.createServer((request, response) => {
241
+ response.statusCode = request.headers['content-type'] === 'application/jose+json' ? 200 : 400
242
+ response.end()
243
+ })
244
+ await new Promise((resolve, reject) => {
245
+ server.listen(9999, () => {
246
+ resolve()
247
+ })
248
+ })
249
+ const request = bent('POST')
250
+ const response = request('http://localhost:9999', { ok: true }, { 'content-type': 'application/jose+json' })
251
+ const info = await response
252
+ same(info.statusCode, 200)
253
+ server.close()
254
+ })
255
+ }
node_modules/bent/test/test-compression.js ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+ /* globals it */
3
+ const bent = require('../')
4
+ const assert = require('assert')
5
+ const tsame = require('tsame')
6
+ const qs = require('querystring')
7
+ const zlib = require('zlib')
8
+
9
+ const test = it
10
+
11
+ const same = (x, y) => assert.ok(tsame(x, y))
12
+
13
+ const baseurl = 'https://echo-server.mikeal.now.sh/src'
14
+ const u = path => baseurl + path
15
+
16
+ if (!process.browser) {
17
+ test('accept header', async () => {
18
+ let request = bent('json')
19
+ let json = await request(u('/info.js'))
20
+ same(json.headers['accept-encoding'], 'br, gzip, deflate')
21
+
22
+ request = bent('json', { 'Accept-Encoding': 'test' })
23
+ json = await request(u('/info.js'))
24
+ same(json.headers['accept-encoding'], 'test')
25
+ })
26
+
27
+ test('brotli', async () => {
28
+ const request = bent('string', baseurl)
29
+ const base64 = zlib.brotliCompressSync('ok').toString('base64')
30
+ const headers = 'content-encoding:br'
31
+ const str = await request(`/echo.js?${qs.stringify({ base64, headers })}`)
32
+ same(str, 'ok')
33
+ })
34
+
35
+ test('gzip', async () => {
36
+ const request = bent('string', baseurl)
37
+ const base64 = zlib.gzipSync('ok').toString('base64')
38
+ const headers = 'content-encoding:gzip'
39
+ const str = await request(`/echo.js?${qs.stringify({ base64, headers })}`)
40
+ same(str, 'ok')
41
+ })
42
+
43
+ test('deflate', async () => {
44
+ const request = bent('string', baseurl)
45
+ const base64 = zlib.deflateSync('ok').toString('base64')
46
+ const headers = 'content-encoding:deflate'
47
+ const str = await request(`/echo.js?${qs.stringify({ base64, headers })}`)
48
+ same(str, 'ok')
49
+ })
50
+
51
+ test('unknown', async () => {
52
+ const request = bent('buffer', baseurl)
53
+ const base64 = zlib.gzipSync('untouched').toString('base64')
54
+ const headers = 'content-encoding:myown'
55
+ const buffer = await request(`/echo.js?${qs.stringify({ base64, headers })}`)
56
+ const str = zlib.gunzipSync(buffer).toString('utf8')
57
+ same(str, 'untouched')
58
+ })
59
+ }
node_modules/bent/test/test-errors.js ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+ /* globals it */
3
+ const bent = require('../')
4
+ const tsame = require('tsame')
5
+ const assert = require('assert')
6
+ const zlib = require('zlib')
7
+ const ttype = (e, str) => same(e.constructor.name, str)
8
+ const qs = require('querystring')
9
+
10
+ const test = it
11
+ const same = (x, y) => assert.ok(tsame(x, y))
12
+
13
+ test('Invalid encoding', done => {
14
+ try {
15
+ bent('blah')
16
+ } catch (e) {
17
+ ttype(e, 'Error')
18
+ same(e.message, 'Unknown encoding, blah')
19
+ done()
20
+ }
21
+ })
22
+
23
+ test('double method', done => {
24
+ try {
25
+ bent('GET', 'PUT')
26
+ } catch (e) {
27
+ ttype(e, 'Error')
28
+ same(e.message, 'Can\'t set method to PUT, already set to GET.')
29
+ done()
30
+ }
31
+ })
32
+
33
+ test('double headers', done => {
34
+ try {
35
+ bent({}, {})
36
+ } catch (e) {
37
+ ttype(e, 'Error')
38
+ same(e.message, 'Cannot set headers twice.')
39
+ done()
40
+ }
41
+ })
42
+
43
+ test('unknown protocol', async () => {
44
+ try {
45
+ const request = bent()
46
+ await request('ftp://host.com')
47
+ throw new Error('Should have already failed')
48
+ } catch (e) {
49
+ ttype(e, 'Error')
50
+ same(e.message, 'Unknown protocol, ftp:')
51
+ }
52
+ })
53
+
54
+ test('Invalid type', done => {
55
+ try {
56
+ bent(true)
57
+ } catch (e) {
58
+ ttype(e, 'Error')
59
+ same(e.message, 'Unknown type: boolean')
60
+ done()
61
+ }
62
+ })
63
+
64
+ test('Invalid body', async () => {
65
+ const r = bent('PUT')
66
+ try {
67
+ await r('http://localhost:3000', true)
68
+ throw new Error('Should have failed')
69
+ } catch (e) {
70
+ ttype(e, 'Error')
71
+ same(e.message, 'Unknown body type.')
72
+ }
73
+ })
74
+
75
+ test('Invalid json', async () => {
76
+ const r = bent('GET', 'json')
77
+ try {
78
+ await r('https://echo-server.mikeal.now.sh/src/echo.js?body=[asdf]')
79
+ throw new Error('Should have failed')
80
+ } catch (e) {
81
+ assert.ok(e.message.startsWith('Unexpected token a in JSON'))
82
+ }
83
+ })
84
+
85
+ const getError = async () => {
86
+ const r = bent(201)
87
+ try {
88
+ await r('https://echo-server.mikeal.now.sh/src/echo.js?body="asdf"')
89
+ throw new Error('Should have failed')
90
+ } catch (e) {
91
+ ttype(e, 'StatusError')
92
+ return e
93
+ }
94
+ }
95
+
96
+ test('error decodings', async () => {
97
+ let e = await getError()
98
+ same(await e.text(), '"asdf"')
99
+ e = await getError()
100
+ same(await e.json(), 'asdf')
101
+ })
102
+
103
+ if (!process.browser) {
104
+ test('Z_BUF_ERROR error', async () => {
105
+ const request = bent('json')
106
+ try {
107
+ await request('https://echo-server.mikeal.now.sh/src/echo.js?headers=content-encoding%3Agzip%2Ccontent-type%3Aapplication%2Fjson')
108
+ } catch (e) {
109
+ ttype(e, 'Error')
110
+ return e
111
+ }
112
+ })
113
+ test('gzip json compresssion SyntaxError', async () => {
114
+ const request = bent('json')
115
+ const base64 = zlib.gzipSync('ok').toString('base64')
116
+ const headers = 'content-encoding:gzip,content-type:application/json'
117
+ try {
118
+ await request(`https://echo-server.mikeal.now.sh/src/echo.js?${qs.stringify({ base64, headers })}`)
119
+ } catch (e) {
120
+ ttype(e, 'SyntaxError')
121
+ return e
122
+ }
123
+ })
124
+ }
node_modules/bytesish/.github/workflows/mikeals-workflow.yml ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ on: [push, pull_request]
2
+ name: Build, Test and maybe Publish
3
+ jobs:
4
+ test:
5
+ name: Build & Test
6
+ runs-on: ubuntu-latest
7
+ strategy:
8
+ matrix:
9
+ node-version: [12.x, 14.x]
10
+ steps:
11
+ - uses: actions/checkout@v2
12
+ - name: Use Node.js ${{ matrix.node-version }}
13
+ uses: actions/setup-node@v1
14
+ with:
15
+ node-version: ${{ matrix.node-version }}
16
+ - name: Cache node_modules
17
+ id: cache-modules
18
+ uses: actions/cache@v1
19
+ with:
20
+ path: node_modules
21
+ key: ${{ matrix.node-version }}-${{ runner.OS }}-build-${{ hashFiles('package.json') }}
22
+ - name: Build
23
+ if: steps.cache-modules.outputs.cache-hit != 'true'
24
+ run: npm install
25
+ - name: Test
26
+ run: npm_config_yes=true npx best-test@latest
27
+ publish:
28
+ name: Publish
29
+ needs: test
30
+ runs-on: ubuntu-latest
31
+ if: github.event_name == 'push' && ( github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' )
32
+ steps:
33
+ - uses: actions/checkout@v2
34
+ - name: Cache node_modules
35
+ id: cache-modules
36
+ uses: actions/cache@v1
37
+ with:
38
+ path: node_modules
39
+ key: 12.x-${{ runner.OS }}-build-${{ hashFiles('package.json') }}
40
+ - name: Build
41
+ if: steps.cache-modules.outputs.cache-hit != 'true'
42
+ run: npm install
43
+ - name: Test
44
+ run: npm_config_yes=true npx best-test@latest
45
+
46
+ - name: Publish
47
+ uses: mikeal/merge-release@master
48
+ env:
49
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50
+ NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
node_modules/bytesish/README.md ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # `bytesish`
2
+
3
+ ![5002](https://img.shields.io/badge/compiled%20bundle-5k-green) ![1903](https://img.shields.io/badge/gzipped%20bundle-2k-brightgreen)
4
+
5
+ If you're writing a library that needs to work in Node.js and in Browsers,
6
+ it's quite difficult to figure out what "the right thing" to do with binary
7
+ is.
8
+
9
+ If you want to be compatible with Node.js libraries you'll need to accept
10
+ and return `Buffer` instances. If you want to be compatible with Browser API's
11
+ you'll need to accept and return a number of types, the browser is sort of a mess
12
+ when it comes to binary with many different "views" of binary data.
13
+
14
+ The moment you use the Node.js `Buffer` API in a library that is bundled for
15
+ use in Browsers the bundler will inject a rather large polyfill for the entire
16
+ `Buffer` API. It's quite difficult to accept and return `Buffer` instances while
17
+ avoiding this penalty.
18
+
19
+ However, there is some good news. No matter what the binary type there's an underlying
20
+ `ArrayBuffer` associated with the instance. There's also one generic binary view object
21
+ available in both Node.js and Browsers called `DataView`. This means that you can take
22
+ any binary type and do a **zero memcopy** conversion to a `DataView`.
23
+
24
+ But there are some problems with `DataView`. Not all APIs take it in browsers and almost
25
+ none accept it in Node.js. It's a great API for reading and writing to an `ArrayBuffer`
26
+ but it lacks a lot of other functionality that can be difficult to accomplish cross-platform.
27
+
28
+ `bytesish` is here to help. This library helps you accept and convert different binary types
29
+ into a consistent type, `DataView`, without loading any polyfills or other dependencies, then
30
+ convert back into an ideal type for the platform your library is running in.
31
+
32
+ What `bytesish` does:
33
+
34
+ * Returns a `DataView` from any known binary type (zero copy).
35
+ * Creates a `DataView` from a string with any encoding.
36
+ * Converts any type to a string of any encoding.
37
+ * Converts any to an ideal native object (`Buffer` or `Uint8Array`).
38
+ * Provides utility functions for comparison, sorting, copying and slices
39
+ any binary type or string.
40
+
41
+ `bytesish` does not create a new Binary Type for accessing and manipulating
42
+ binary data, because you can just use `DataView` for that. `bytesish` tries to be a
43
+ small piece of code that does not contribute any more than necessary to your bundle size.
44
+ It does this by containing only the binary operations you need that are difficult to
45
+ do cross-platform (Node.js and Browsers).
46
+
47
+ ```javascript
48
+ let bytes = require('bytesish')
49
+ let view = bytes('hello world')
50
+
51
+ /* zero copy conversions */
52
+ view = bytes(Buffer.from('hello world')) // Buffer instance
53
+ view = bytes((new TextEncoder()).encode('hello world')) // Uint8Array
54
+
55
+ /* base64 conversions */
56
+ let base64String = bytes.toString(view, 'base64')
57
+ base64String = bytes.toString(Buffer.from('hello world'), 'base64')
58
+ base64String = bytes.toString('hello world', 'base64')
59
+
60
+ /* since this is a string conversion it will create a new binary instance */
61
+ let viewCopy = bytes(base64String, 'base64')
62
+ ```
63
+
64
+ # API
65
+
66
+ ## Zero Copy
67
+
68
+ ### `bytes(from)`
69
+
70
+ ### `bytes.sort(a, b)`
71
+
72
+ ### `bytes.compare(a, b)`
73
+
74
+ ### `bytes.native(from[, encoding])`
75
+
76
+ ### `bytes.slice(from[, start=0[, end=from.byteLength]])`
77
+
78
+ ### `bytes.typedArray(from[, Class=Uint8Array])`
79
+
80
+ ## Optimized (memcopy only when necessary)
81
+
82
+ ### `bytes.arrayBuffer(from[, encoding])`
83
+
84
+ ## Memory Copy
85
+
86
+ All memcopy APIs return an `ArrayBuffer`
87
+
88
+ ### `bytes.memcopy(from[, encoding])`
89
+
90
+ Returns an `ArrayBuffer` copy of the given binary or string.
91
+
92
+ ### `bytes.memcopySlice(from[, start=0[, end=from.byteLength]])`
93
+
94
+ Returns an `ArrayBuffer` copy from a slize of the given binary or string.
95
+
96
+ ### `bytes.concat(values)`
97
+
98
+ `values` is an iterable of binary or string types.
99
+
100
+ Returns a newly allocated `ArrayBuffer` contained the concatenated binary data.
101
+
102
+ ## String Conversions
103
+
104
+ ### `bytes(from[, encoding])`
105
+
106
+ ### `bytes.toString(from[, outputEncoding])`
node_modules/bytesish/browser.js ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* globals atob, btoa, crypto */
2
+ /* istanbul ignore file */
3
+ 'use strict'
4
+ const bytes = require('./core')
5
+
6
+ bytes.from = (_from, _encoding) => {
7
+ if (_from instanceof DataView) return _from
8
+ if (_from instanceof ArrayBuffer) return new DataView(_from)
9
+ let buffer
10
+ if (typeof _from === 'string') {
11
+ if (!_encoding) {
12
+ _encoding = 'utf-8'
13
+ } else if (_encoding === 'base64') {
14
+ buffer = Uint8Array.from(atob(_from), c => c.charCodeAt(0)).buffer
15
+ return new DataView(buffer)
16
+ }
17
+ if (_encoding !== 'utf-8') throw new Error('Browser support for encodings other than utf-8 not implemented')
18
+ return new DataView((new TextEncoder()).encode(_from).buffer)
19
+ } else if (typeof _from === 'object') {
20
+ if (ArrayBuffer.isView(_from)) {
21
+ if (_from.byteLength === _from.buffer.byteLength) return new DataView(_from.buffer)
22
+ else return new DataView(_from.buffer, _from.byteOffset, _from.byteLength)
23
+ }
24
+ }
25
+ throw new Error('Unkown type. Cannot convert to ArrayBuffer')
26
+ }
27
+
28
+ bytes.toString = (_from, encoding) => {
29
+ _from = bytes(_from, encoding)
30
+ const uint = new Uint8Array(_from.buffer, _from.byteOffset, _from.byteLength)
31
+ const str = String.fromCharCode(...uint)
32
+ if (encoding === 'base64') {
33
+ /* would be nice to find a way to do this directly from a buffer
34
+ * instead of doing two string conversions
35
+ */
36
+ return btoa(str)
37
+ } else {
38
+ return str
39
+ }
40
+ }
41
+
42
+ bytes.native = (_from, encoding) => {
43
+ if (_from instanceof Uint8Array) return _from
44
+ _from = bytes.from(_from, encoding)
45
+ return new Uint8Array(_from.buffer, _from.byteOffset, _from.byteLength)
46
+ }
47
+
48
+ if (process.browser) bytes._randomFill = (...args) => crypto.getRandomValues(...args)
49
+
50
+ module.exports = bytes
node_modules/bytesish/core.js ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ const length = (a, b) => {
4
+ if (a.byteLength === b.byteLength) return a.byteLength
5
+ else if (a.byteLength > b.byteLength) return a.byteLength
6
+ return b.byteLength
7
+ }
8
+
9
+ const bytes = (_from, encoding) => bytes.from(_from, encoding)
10
+
11
+ bytes.sorter = (a, b) => {
12
+ a = bytes(a)
13
+ b = bytes(b)
14
+ const len = length(a, b)
15
+ let i = 0
16
+ while (i < (len - 1)) {
17
+ if (i >= a.byteLength) return 1
18
+ else if (i >= b.byteLength) return -1
19
+
20
+ if (a.getUint8(i) < b.getUint8(i)) return -1
21
+ else if (a.getUint8(i) > b.getUint8(i)) return 1
22
+ i++
23
+ }
24
+ return 0
25
+ }
26
+
27
+ bytes.compare = (a, b) => !bytes.sorter(a, b)
28
+ bytes.memcopy = (_from, encoding) => {
29
+ const b = bytes(_from, encoding)
30
+ return b.buffer.slice(b.byteOffset, b.byteOffset + b.byteLength)
31
+ }
32
+ bytes.arrayBuffer = (_from, encoding) => {
33
+ _from = bytes(_from, encoding)
34
+ if (_from.buffer.byteLength === _from.byteLength) return _from.buffer
35
+ return _from.buffer.slice(_from.byteOffset, _from.byteOffset + _from.byteLength)
36
+ }
37
+ const sliceOptions = (_from, start = 0, end = null) => {
38
+ _from = bytes(_from)
39
+ end = (end === null ? _from.byteLength : end) - start
40
+ return [_from.buffer, _from.byteOffset + start, end]
41
+ }
42
+ bytes.slice = (_from, start, end) => new DataView(...sliceOptions(_from, start, end))
43
+
44
+ bytes.memcopySlice = (_from, start, end) => {
45
+ const [buffer, offset, length] = sliceOptions(_from, start, end)
46
+ return buffer.slice(offset, length + offset)
47
+ }
48
+ bytes.typedArray = (_from, _Class = Uint8Array) => {
49
+ _from = bytes(_from)
50
+ return new _Class(_from.buffer, _from.byteOffset, _from.byteLength / _Class.BYTES_PER_ELEMENT)
51
+ }
52
+
53
+ bytes.concat = (_from) => {
54
+ _from = Array.from(_from)
55
+ _from = _from.map(b => bytes(b))
56
+ const length = _from.reduce((x, y) => x + y.byteLength, 0)
57
+ const ret = new Uint8Array(length)
58
+ let i = 0
59
+ for (const part of _from) {
60
+ const view = bytes.typedArray(part)
61
+ ret.set(view, i)
62
+ i += view.byteLength
63
+ }
64
+ return ret.buffer
65
+ }
66
+
67
+ const maxEntropy = 65536
68
+
69
+ bytes.random = length => {
70
+ const ab = new ArrayBuffer(length)
71
+ if (length > maxEntropy) {
72
+ let i = 0
73
+ while (i < ab.byteLength) {
74
+ let len
75
+ if (i + maxEntropy > ab.byteLength) len = ab.byteLength - i
76
+ else len = maxEntropy
77
+ const view = new Uint8Array(ab, i, len)
78
+ i += maxEntropy
79
+ bytes._randomFill(view)
80
+ }
81
+ } else {
82
+ const view = new Uint8Array(ab)
83
+ bytes._randomFill(view)
84
+ }
85
+ return ab
86
+ }
87
+
88
+ module.exports = bytes
node_modules/bytesish/junit-report-browser.xml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <testsuite name="HeadlessChrome 85.0.4183 (Linux 0.0.0)" package="" timestamp="2020-10-10T04:49:55" id="0" hostname="fv-az195" tests="12" errors="0" failures="0" time="0.002">
3
+ <properties>
4
+ <property name="browser.fullName" value="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/85.0.4183.121 Safari/537.36"/>
5
+ </properties>
6
+ <testcase name=" string conversion" time="0" classname=""/>
7
+ <testcase name=" compare" time="0" classname=""/>
8
+ <testcase name=" double view" time="0" classname=""/>
9
+ <testcase name=" typed array" time="0" classname=""/>
10
+ <testcase name=" from array buffer" time="0" classname=""/>
11
+ <testcase name=" to array buffer" time="0" classname=""/>
12
+ <testcase name=" Uint8Array" time="0" classname=""/>
13
+ <testcase name=" native" time="0" classname=""/>
14
+ <testcase name=" slice" time="0" classname=""/>
15
+ <testcase name=" slice memcopy" time="0" classname=""/>
16
+ <testcase name=" concat" time="0" classname=""/>
17
+ <testcase name=" random above max entropy" time="0.002" classname=""/>
18
+ <system-out>
19
+ <![CDATA[
20
+ ]]>
21
+ </system-out>
22
+ <system-err/>
23
+ </testsuite>
node_modules/bytesish/node.js ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+ const crypto = require('crypto')
3
+ const fallback = require('./browser').from
4
+ const bytes = require('./core')
5
+
6
+ bytes.from = (_from, encoding) => {
7
+ if (_from instanceof DataView) return _from
8
+ if (_from instanceof ArrayBuffer) return new DataView(_from)
9
+ if (typeof _from === 'string') {
10
+ _from = Buffer.from(_from, encoding)
11
+ }
12
+ if (Buffer.isBuffer(_from)) {
13
+ return new DataView(_from.buffer, _from.byteOffset, _from.byteLength)
14
+ }
15
+ return fallback(_from, encoding)
16
+ }
17
+ bytes.toString = (_from, encoding) => {
18
+ _from = bytes(_from)
19
+ return Buffer.from(_from.buffer, _from.byteOffset, _from.byteLength).toString(encoding)
20
+ }
21
+
22
+ bytes.native = (_from, encoding) => {
23
+ if (Buffer.isBuffer(_from)) return _from
24
+ _from = bytes(_from, encoding)
25
+ return Buffer.from(_from.buffer, _from.byteOffset, _from.byteLength)
26
+ }
27
+
28
+ bytes._randomFill = crypto.randomFillSync
29
+
30
+ module.exports = bytes
node_modules/bytesish/package.json ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "bytesish",
3
+ "version": "0.4.4",
4
+ "main": "node.js",
5
+ "browser": "browser.js",
6
+ "scripts": {
7
+ "test": "hundreds aegir test -t node browser",
8
+ "pretest": "aegir lint"
9
+ },
10
+ "keywords": [],
11
+ "author": "Mikeal Rogers <[email protected]> (https://www.mikealrogers.com/)",
12
+ "license": "(Apache-2.0 AND MIT)",
13
+ "devDependencies": {
14
+ "aegir": "^20.4.1",
15
+ "hundreds": "0.0.2",
16
+ "tsame": "^2.0.1"
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/mikeal/bytesish.git"
21
+ },
22
+ "bugs": {
23
+ "url": "https://github.com/mikeal/bytesish/issues"
24
+ },
25
+ "homepage": "https://github.com/mikeal/bytesish#readme",
26
+ "description": "Cross-Platform Binary API"
27
+ }
node_modules/bytesish/test/basics.spec.js ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+ const assert = require('assert')
3
+ const tsame = require('tsame')
4
+ const { it } = require('mocha')
5
+ const bytes = require('../')
6
+
7
+ const test = it
8
+
9
+ const same = (x, y) => assert.ok(tsame(x, y))
10
+
11
+ test('string conversion', done => {
12
+ const ab = bytes('hello world')
13
+ assert(ab instanceof DataView)
14
+ const str = bytes.toString(ab)
15
+ same(str, 'hello world')
16
+ done()
17
+ })
18
+
19
+ test('compare', done => {
20
+ const a = bytes('hello world')
21
+ const b = bytes('hello world 2')
22
+ assert(bytes.compare(a, a))
23
+ assert(bytes.compare(a, 'hello world'))
24
+ assert(!bytes.compare(a, b))
25
+ assert(!bytes.compare(b, a))
26
+ assert(!bytes.compare(a, '123'))
27
+ assert(!bytes.compare('123', a))
28
+ done()
29
+ })
30
+
31
+ test('double view', done => {
32
+ const a = bytes('hello world')
33
+ const b = bytes(a)
34
+ same(a, b)
35
+ done()
36
+ })
37
+
38
+ test('typed array', done => {
39
+ const ab = bytes.random(4)
40
+ const view = bytes(ab)
41
+ const uint = bytes.typedArray(ab, Uint32Array)
42
+ assert(uint instanceof Uint32Array)
43
+ assert(bytes.compare(uint, view))
44
+ done()
45
+ })
46
+
47
+ test('from array buffer', done => {
48
+ const a = bytes('hello world')
49
+ const b = bytes(bytes.memcopy(a))
50
+ same(bytes.toString(a), bytes.toString(b))
51
+ done()
52
+ })
53
+
54
+ test('to array buffer', done => {
55
+ const a = bytes.arrayBuffer('hello world')
56
+ const b = bytes('hello world')
57
+ assert(a instanceof ArrayBuffer)
58
+ assert(bytes.compare(a, b))
59
+ assert(a, bytes.arrayBuffer(a))
60
+ done()
61
+ })
62
+
63
+ test('Uint8Array', done => {
64
+ const a = bytes('hello world')
65
+ const b = bytes(new Uint8Array(bytes.memcopy(a)))
66
+ same(bytes.toString(a), bytes.toString(b))
67
+ done()
68
+ })
69
+
70
+ test('native', done => {
71
+ let n = bytes.native('hello world')
72
+ if (process.browser) {
73
+ assert(n instanceof Uint8Array)
74
+ n = bytes.native(n)
75
+ assert(n instanceof Uint8Array)
76
+ } else {
77
+ assert(n instanceof Buffer)
78
+ n = bytes.native(n)
79
+ assert(n instanceof Buffer)
80
+ }
81
+ done()
82
+ })
83
+
84
+ test('slice', done => {
85
+ const a = bytes.slice('hello world', 2, 7)
86
+ assert(a instanceof DataView)
87
+ const b = bytes.arrayBuffer('hello world').slice(2, 7)
88
+ same(b, bytes.arrayBuffer(a))
89
+ done()
90
+ })
91
+
92
+ test('slice memcopy', done => {
93
+ const a = bytes.memcopySlice('hello world', 2, 7)
94
+ assert(a instanceof ArrayBuffer)
95
+ const b = bytes.arrayBuffer('hello world').slice(2, 7)
96
+ same(b, a)
97
+ const c = bytes.memcopySlice(a)
98
+ assert(a !== c)
99
+ same(a, c)
100
+ done()
101
+ })
102
+
103
+ test('concat', done => {
104
+ let values = [bytes('1'), bytes.native('2'), bytes.arrayBuffer('3')]
105
+ let ab = bytes.concat(values)
106
+ assert(ab instanceof ArrayBuffer)
107
+ assert(bytes.compare(ab, '123'))
108
+ values = [bytes('one')]
109
+ ab = bytes.concat(values)
110
+ assert(bytes.compare(ab, 'one'))
111
+ done()
112
+ })
113
+
114
+ test('random above max entropy', done => {
115
+ const maxEntropy = 65536
116
+ const size = (maxEntropy * 3) + 8
117
+ const rand = bytes.random(size)
118
+ same(rand.byteLength, size)
119
+ done()
120
+ })
node_modules/caseless/LICENSE ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
5
+ 1. Definitions.
6
+ "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
7
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
8
+ "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
9
+ "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
10
+ "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
11
+ "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
12
+ "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
13
+ "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
14
+ "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
15
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
16
+ 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
17
+ 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
18
+ 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
19
+ You must give any other recipients of the Work or Derivative Works a copy of this License; and
20
+ You must cause any modified files to carry prominent notices stating that You changed the files; and
21
+ You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
22
+ If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
23
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
24
+ 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
25
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
26
+ 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
27
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
28
+ END OF TERMS AND CONDITIONS
node_modules/caseless/README.md ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Caseless -- wrap an object to set and get property with caseless semantics but also preserve caseing.
2
+
3
+ This library is incredibly useful when working with HTTP headers. It allows you to get/set/check for headers in a caseless manner while also preserving the caseing of headers the first time they are set.
4
+
5
+ ## Usage
6
+
7
+ ```javascript
8
+ var headers = {}
9
+ , c = caseless(headers)
10
+ ;
11
+ c.set('a-Header', 'asdf')
12
+ c.get('a-header') === 'asdf'
13
+ ```
14
+
15
+ ## has(key)
16
+
17
+ Has takes a name and if it finds a matching header will return that header name with the preserved caseing it was set with.
18
+
19
+ ```javascript
20
+ c.has('a-header') === 'a-Header'
21
+ ```
22
+
23
+ ## set(key, value[, clobber=true])
24
+
25
+ Set is fairly straight forward except that if the header exists and clobber is disabled it will add `','+value` to the existing header.
26
+
27
+ ```javascript
28
+ c.set('a-Header', 'fdas')
29
+ c.set('a-HEADER', 'more', false)
30
+ c.get('a-header') === 'fdsa,more'
31
+ ```
32
+
33
+ ## swap(key)
34
+
35
+ Swaps the casing of a header with the new one that is passed in.
36
+
37
+ ```javascript
38
+ var headers = {}
39
+ , c = caseless(headers)
40
+ ;
41
+ c.set('a-Header', 'fdas')
42
+ c.swap('a-HEADER')
43
+ c.has('a-header') === 'a-HEADER'
44
+ headers === {'a-HEADER': 'fdas'}
45
+ ```
node_modules/caseless/index.js ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function Caseless (dict) {
2
+ this.dict = dict || {}
3
+ }
4
+ Caseless.prototype.set = function (name, value, clobber) {
5
+ if (typeof name === 'object') {
6
+ for (var i in name) {
7
+ this.set(i, name[i], value)
8
+ }
9
+ } else {
10
+ if (typeof clobber === 'undefined') clobber = true
11
+ var has = this.has(name)
12
+
13
+ if (!clobber && has) this.dict[has] = this.dict[has] + ',' + value
14
+ else this.dict[has || name] = value
15
+ return has
16
+ }
17
+ }
18
+ Caseless.prototype.has = function (name) {
19
+ var keys = Object.keys(this.dict)
20
+ , name = name.toLowerCase()
21
+ ;
22
+ for (var i=0;i<keys.length;i++) {
23
+ if (keys[i].toLowerCase() === name) return keys[i]
24
+ }
25
+ return false
26
+ }
27
+ Caseless.prototype.get = function (name) {
28
+ name = name.toLowerCase()
29
+ var result, _key
30
+ var headers = this.dict
31
+ Object.keys(headers).forEach(function (key) {
32
+ _key = key.toLowerCase()
33
+ if (name === _key) result = headers[key]
34
+ })
35
+ return result
36
+ }
37
+ Caseless.prototype.swap = function (name) {
38
+ var has = this.has(name)
39
+ if (has === name) return
40
+ if (!has) throw new Error('There is no header than matches "'+name+'"')
41
+ this.dict[name] = this.dict[has]
42
+ delete this.dict[has]
43
+ }
44
+ Caseless.prototype.del = function (name) {
45
+ var has = this.has(name)
46
+ return delete this.dict[has || name]
47
+ }
48
+
49
+ module.exports = function (dict) {return new Caseless(dict)}
50
+ module.exports.httpify = function (resp, headers) {
51
+ var c = new Caseless(headers)
52
+ resp.setHeader = function (key, value, clobber) {
53
+ if (typeof value === 'undefined') return
54
+ return c.set(key, value, clobber)
55
+ }
56
+ resp.hasHeader = function (key) {
57
+ return c.has(key)
58
+ }
59
+ resp.getHeader = function (key) {
60
+ return c.get(key)
61
+ }
62
+ resp.removeHeader = function (key) {
63
+ return c.del(key)
64
+ }
65
+ resp.headers = c.dict
66
+ return c
67
+ }
node_modules/caseless/package.json ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "caseless",
3
+ "version": "0.12.0",
4
+ "description": "Caseless object set/get/has, very useful when working with HTTP headers.",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "node test.js"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/mikeal/caseless"
12
+ },
13
+ "keywords": [
14
+ "headers",
15
+ "http",
16
+ "caseless"
17
+ ],
18
+ "test": "node test.js",
19
+ "author": "Mikeal Rogers <[email protected]>",
20
+ "license": "Apache-2.0",
21
+ "bugs": {
22
+ "url": "https://github.com/mikeal/caseless/issues"
23
+ },
24
+ "devDependencies": {
25
+ "tape": "^2.10.2"
26
+ }
27
+ }
node_modules/caseless/test.js ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var tape = require('tape')
2
+ , caseless = require('./')
3
+ ;
4
+
5
+ tape('set get has', function (t) {
6
+ var headers = {}
7
+ , c = caseless(headers)
8
+ ;
9
+ t.plan(17)
10
+ c.set('a-Header', 'asdf')
11
+ t.equal(c.get('a-header'), 'asdf')
12
+ t.equal(c.has('a-header'), 'a-Header')
13
+ t.ok(!c.has('nothing'))
14
+ // old bug where we used the wrong regex
15
+ t.ok(!c.has('a-hea'))
16
+ c.set('a-header', 'fdsa')
17
+ t.equal(c.get('a-header'), 'fdsa')
18
+ t.equal(c.get('a-Header'), 'fdsa')
19
+ c.set('a-HEADER', 'more', false)
20
+ t.equal(c.get('a-header'), 'fdsa,more')
21
+
22
+ t.deepEqual(headers, {'a-Header': 'fdsa,more'})
23
+ c.swap('a-HEADER')
24
+ t.deepEqual(headers, {'a-HEADER': 'fdsa,more'})
25
+
26
+ c.set('deleteme', 'foobar')
27
+ t.ok(c.has('deleteme'))
28
+ t.ok(c.del('deleteme'))
29
+ t.notOk(c.has('deleteme'))
30
+ t.notOk(c.has('idonotexist'))
31
+ t.ok(c.del('idonotexist'))
32
+
33
+ c.set('tva', 'test1')
34
+ c.set('tva-header', 'test2')
35
+ t.equal(c.has('tva'), 'tva')
36
+ t.notOk(c.has('header'))
37
+
38
+ t.equal(c.get('tva'), 'test1')
39
+
40
+ })
41
+
42
+ tape('swap', function (t) {
43
+ var headers = {}
44
+ , c = caseless(headers)
45
+ ;
46
+ t.plan(4)
47
+ // No Header to Swap.
48
+ t.throws(function () {
49
+ c.swap('content-type')
50
+ })
51
+ // Set Header.
52
+ c.set('content-type', 'application/json')
53
+ // Swap Header With Itself.
54
+ c.swap('content-type')
55
+ // Does Not Delete Itself.
56
+ t.ok(c.has('content-type'))
57
+ // Swap Header With a Different Header.
58
+ c.swap('Content-Type')
59
+ // Still Has Header.
60
+ t.ok(c.has('Content-Type'))
61
+ // Delete Header.
62
+ c.del('Content-Type')
63
+ // No Header to Swap.
64
+ t.throws(function () {
65
+ c.swap('content-type')
66
+ })
67
+ })
node_modules/debug/LICENSE ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2014-2017 TJ Holowaychuk <[email protected]>
4
+ Copyright (c) 2018-2021 Josh Junon
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software
7
+ and associated documentation files (the 'Software'), to deal in the Software without restriction,
8
+ including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
9
+ and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all copies or substantial
13
+ portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
16
+ LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
19
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
+
node_modules/debug/README.md ADDED
@@ -0,0 +1,481 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # debug
2
+ [![OpenCollective](https://opencollective.com/debug/backers/badge.svg)](#backers)
3
+ [![OpenCollective](https://opencollective.com/debug/sponsors/badge.svg)](#sponsors)
4
+
5
+ <img width="647" src="https://user-images.githubusercontent.com/71256/29091486-fa38524c-7c37-11e7-895f-e7ec8e1039b6.png">
6
+
7
+ A tiny JavaScript debugging utility modelled after Node.js core's debugging
8
+ technique. Works in Node.js and web browsers.
9
+
10
+ ## Installation
11
+
12
+ ```bash
13
+ $ npm install debug
14
+ ```
15
+
16
+ ## Usage
17
+
18
+ `debug` exposes a function; simply pass this function the name of your module, and it will return a decorated version of `console.error` for you to pass debug statements to. This will allow you to toggle the debug output for different parts of your module as well as the module as a whole.
19
+
20
+ Example [_app.js_](./examples/node/app.js):
21
+
22
+ ```js
23
+ var debug = require('debug')('http')
24
+ , http = require('http')
25
+ , name = 'My App';
26
+
27
+ // fake app
28
+
29
+ debug('booting %o', name);
30
+
31
+ http.createServer(function(req, res){
32
+ debug(req.method + ' ' + req.url);
33
+ res.end('hello\n');
34
+ }).listen(3000, function(){
35
+ debug('listening');
36
+ });
37
+
38
+ // fake worker of some kind
39
+
40
+ require('./worker');
41
+ ```
42
+
43
+ Example [_worker.js_](./examples/node/worker.js):
44
+
45
+ ```js
46
+ var a = require('debug')('worker:a')
47
+ , b = require('debug')('worker:b');
48
+
49
+ function work() {
50
+ a('doing lots of uninteresting work');
51
+ setTimeout(work, Math.random() * 1000);
52
+ }
53
+
54
+ work();
55
+
56
+ function workb() {
57
+ b('doing some work');
58
+ setTimeout(workb, Math.random() * 2000);
59
+ }
60
+
61
+ workb();
62
+ ```
63
+
64
+ The `DEBUG` environment variable is then used to enable these based on space or
65
+ comma-delimited names.
66
+
67
+ Here are some examples:
68
+
69
+ <img width="647" alt="screen shot 2017-08-08 at 12 53 04 pm" src="https://user-images.githubusercontent.com/71256/29091703-a6302cdc-7c38-11e7-8304-7c0b3bc600cd.png">
70
+ <img width="647" alt="screen shot 2017-08-08 at 12 53 38 pm" src="https://user-images.githubusercontent.com/71256/29091700-a62a6888-7c38-11e7-800b-db911291ca2b.png">
71
+ <img width="647" alt="screen shot 2017-08-08 at 12 53 25 pm" src="https://user-images.githubusercontent.com/71256/29091701-a62ea114-7c38-11e7-826a-2692bedca740.png">
72
+
73
+ #### Windows command prompt notes
74
+
75
+ ##### CMD
76
+
77
+ On Windows the environment variable is set using the `set` command.
78
+
79
+ ```cmd
80
+ set DEBUG=*,-not_this
81
+ ```
82
+
83
+ Example:
84
+
85
+ ```cmd
86
+ set DEBUG=* & node app.js
87
+ ```
88
+
89
+ ##### PowerShell (VS Code default)
90
+
91
+ PowerShell uses different syntax to set environment variables.
92
+
93
+ ```cmd
94
+ $env:DEBUG = "*,-not_this"
95
+ ```
96
+
97
+ Example:
98
+
99
+ ```cmd
100
+ $env:DEBUG='app';node app.js
101
+ ```
102
+
103
+ Then, run the program to be debugged as usual.
104
+
105
+ npm script example:
106
+ ```js
107
+ "windowsDebug": "@powershell -Command $env:DEBUG='*';node app.js",
108
+ ```
109
+
110
+ ## Namespace Colors
111
+
112
+ Every debug instance has a color generated for it based on its namespace name.
113
+ This helps when visually parsing the debug output to identify which debug instance
114
+ a debug line belongs to.
115
+
116
+ #### Node.js
117
+
118
+ In Node.js, colors are enabled when stderr is a TTY. You also _should_ install
119
+ the [`supports-color`](https://npmjs.org/supports-color) module alongside debug,
120
+ otherwise debug will only use a small handful of basic colors.
121
+
122
+ <img width="521" src="https://user-images.githubusercontent.com/71256/29092181-47f6a9e6-7c3a-11e7-9a14-1928d8a711cd.png">
123
+
124
+ #### Web Browser
125
+
126
+ Colors are also enabled on "Web Inspectors" that understand the `%c` formatting
127
+ option. These are WebKit web inspectors, Firefox ([since version
128
+ 31](https://hacks.mozilla.org/2014/05/editable-box-model-multiple-selection-sublime-text-keys-much-more-firefox-developer-tools-episode-31/))
129
+ and the Firebug plugin for Firefox (any version).
130
+
131
+ <img width="524" src="https://user-images.githubusercontent.com/71256/29092033-b65f9f2e-7c39-11e7-8e32-f6f0d8e865c1.png">
132
+
133
+
134
+ ## Millisecond diff
135
+
136
+ When actively developing an application it can be useful to see when the time spent between one `debug()` call and the next. Suppose for example you invoke `debug()` before requesting a resource, and after as well, the "+NNNms" will show you how much time was spent between calls.
137
+
138
+ <img width="647" src="https://user-images.githubusercontent.com/71256/29091486-fa38524c-7c37-11e7-895f-e7ec8e1039b6.png">
139
+
140
+ When stdout is not a TTY, `Date#toISOString()` is used, making it more useful for logging the debug information as shown below:
141
+
142
+ <img width="647" src="https://user-images.githubusercontent.com/71256/29091956-6bd78372-7c39-11e7-8c55-c948396d6edd.png">
143
+
144
+
145
+ ## Conventions
146
+
147
+ If you're using this in one or more of your libraries, you _should_ use the name of your library so that developers may toggle debugging as desired without guessing names. If you have more than one debuggers you _should_ prefix them with your library name and use ":" to separate features. For example "bodyParser" from Connect would then be "connect:bodyParser". If you append a "*" to the end of your name, it will always be enabled regardless of the setting of the DEBUG environment variable. You can then use it for normal output as well as debug output.
148
+
149
+ ## Wildcards
150
+
151
+ The `*` character may be used as a wildcard. Suppose for example your library has
152
+ debuggers named "connect:bodyParser", "connect:compress", "connect:session",
153
+ instead of listing all three with
154
+ `DEBUG=connect:bodyParser,connect:compress,connect:session`, you may simply do
155
+ `DEBUG=connect:*`, or to run everything using this module simply use `DEBUG=*`.
156
+
157
+ You can also exclude specific debuggers by prefixing them with a "-" character.
158
+ For example, `DEBUG=*,-connect:*` would include all debuggers except those
159
+ starting with "connect:".
160
+
161
+ ## Environment Variables
162
+
163
+ When running through Node.js, you can set a few environment variables that will
164
+ change the behavior of the debug logging:
165
+
166
+ | Name | Purpose |
167
+ |-----------|-------------------------------------------------|
168
+ | `DEBUG` | Enables/disables specific debugging namespaces. |
169
+ | `DEBUG_HIDE_DATE` | Hide date from debug output (non-TTY). |
170
+ | `DEBUG_COLORS`| Whether or not to use colors in the debug output. |
171
+ | `DEBUG_DEPTH` | Object inspection depth. |
172
+ | `DEBUG_SHOW_HIDDEN` | Shows hidden properties on inspected objects. |
173
+
174
+
175
+ __Note:__ The environment variables beginning with `DEBUG_` end up being
176
+ converted into an Options object that gets used with `%o`/`%O` formatters.
177
+ See the Node.js documentation for
178
+ [`util.inspect()`](https://nodejs.org/api/util.html#util_util_inspect_object_options)
179
+ for the complete list.
180
+
181
+ ## Formatters
182
+
183
+ Debug uses [printf-style](https://wikipedia.org/wiki/Printf_format_string) formatting.
184
+ Below are the officially supported formatters:
185
+
186
+ | Formatter | Representation |
187
+ |-----------|----------------|
188
+ | `%O` | Pretty-print an Object on multiple lines. |
189
+ | `%o` | Pretty-print an Object all on a single line. |
190
+ | `%s` | String. |
191
+ | `%d` | Number (both integer and float). |
192
+ | `%j` | JSON. Replaced with the string '[Circular]' if the argument contains circular references. |
193
+ | `%%` | Single percent sign ('%'). This does not consume an argument. |
194
+
195
+
196
+ ### Custom formatters
197
+
198
+ You can add custom formatters by extending the `debug.formatters` object.
199
+ For example, if you wanted to add support for rendering a Buffer as hex with
200
+ `%h`, you could do something like:
201
+
202
+ ```js
203
+ const createDebug = require('debug')
204
+ createDebug.formatters.h = (v) => {
205
+ return v.toString('hex')
206
+ }
207
+
208
+ // …elsewhere
209
+ const debug = createDebug('foo')
210
+ debug('this is hex: %h', new Buffer('hello world'))
211
+ // foo this is hex: 68656c6c6f20776f726c6421 +0ms
212
+ ```
213
+
214
+
215
+ ## Browser Support
216
+
217
+ You can build a browser-ready script using [browserify](https://github.com/substack/node-browserify),
218
+ or just use the [browserify-as-a-service](https://wzrd.in/) [build](https://wzrd.in/standalone/debug@latest),
219
+ if you don't want to build it yourself.
220
+
221
+ Debug's enable state is currently persisted by `localStorage`.
222
+ Consider the situation shown below where you have `worker:a` and `worker:b`,
223
+ and wish to debug both. You can enable this using `localStorage.debug`:
224
+
225
+ ```js
226
+ localStorage.debug = 'worker:*'
227
+ ```
228
+
229
+ And then refresh the page.
230
+
231
+ ```js
232
+ a = debug('worker:a');
233
+ b = debug('worker:b');
234
+
235
+ setInterval(function(){
236
+ a('doing some work');
237
+ }, 1000);
238
+
239
+ setInterval(function(){
240
+ b('doing some work');
241
+ }, 1200);
242
+ ```
243
+
244
+ In Chromium-based web browsers (e.g. Brave, Chrome, and Electron), the JavaScript console will—by default—only show messages logged by `debug` if the "Verbose" log level is _enabled_.
245
+
246
+ <img width="647" src="https://user-images.githubusercontent.com/7143133/152083257-29034707-c42c-4959-8add-3cee850e6fcf.png">
247
+
248
+ ## Output streams
249
+
250
+ By default `debug` will log to stderr, however this can be configured per-namespace by overriding the `log` method:
251
+
252
+ Example [_stdout.js_](./examples/node/stdout.js):
253
+
254
+ ```js
255
+ var debug = require('debug');
256
+ var error = debug('app:error');
257
+
258
+ // by default stderr is used
259
+ error('goes to stderr!');
260
+
261
+ var log = debug('app:log');
262
+ // set this namespace to log via console.log
263
+ log.log = console.log.bind(console); // don't forget to bind to console!
264
+ log('goes to stdout');
265
+ error('still goes to stderr!');
266
+
267
+ // set all output to go via console.info
268
+ // overrides all per-namespace log settings
269
+ debug.log = console.info.bind(console);
270
+ error('now goes to stdout via console.info');
271
+ log('still goes to stdout, but via console.info now');
272
+ ```
273
+
274
+ ## Extend
275
+ You can simply extend debugger
276
+ ```js
277
+ const log = require('debug')('auth');
278
+
279
+ //creates new debug instance with extended namespace
280
+ const logSign = log.extend('sign');
281
+ const logLogin = log.extend('login');
282
+
283
+ log('hello'); // auth hello
284
+ logSign('hello'); //auth:sign hello
285
+ logLogin('hello'); //auth:login hello
286
+ ```
287
+
288
+ ## Set dynamically
289
+
290
+ You can also enable debug dynamically by calling the `enable()` method :
291
+
292
+ ```js
293
+ let debug = require('debug');
294
+
295
+ console.log(1, debug.enabled('test'));
296
+
297
+ debug.enable('test');
298
+ console.log(2, debug.enabled('test'));
299
+
300
+ debug.disable();
301
+ console.log(3, debug.enabled('test'));
302
+
303
+ ```
304
+
305
+ print :
306
+ ```
307
+ 1 false
308
+ 2 true
309
+ 3 false
310
+ ```
311
+
312
+ Usage :
313
+ `enable(namespaces)`
314
+ `namespaces` can include modes separated by a colon and wildcards.
315
+
316
+ Note that calling `enable()` completely overrides previously set DEBUG variable :
317
+
318
+ ```
319
+ $ DEBUG=foo node -e 'var dbg = require("debug"); dbg.enable("bar"); console.log(dbg.enabled("foo"))'
320
+ => false
321
+ ```
322
+
323
+ `disable()`
324
+
325
+ Will disable all namespaces. The functions returns the namespaces currently
326
+ enabled (and skipped). This can be useful if you want to disable debugging
327
+ temporarily without knowing what was enabled to begin with.
328
+
329
+ For example:
330
+
331
+ ```js
332
+ let debug = require('debug');
333
+ debug.enable('foo:*,-foo:bar');
334
+ let namespaces = debug.disable();
335
+ debug.enable(namespaces);
336
+ ```
337
+
338
+ Note: There is no guarantee that the string will be identical to the initial
339
+ enable string, but semantically they will be identical.
340
+
341
+ ## Checking whether a debug target is enabled
342
+
343
+ After you've created a debug instance, you can determine whether or not it is
344
+ enabled by checking the `enabled` property:
345
+
346
+ ```javascript
347
+ const debug = require('debug')('http');
348
+
349
+ if (debug.enabled) {
350
+ // do stuff...
351
+ }
352
+ ```
353
+
354
+ You can also manually toggle this property to force the debug instance to be
355
+ enabled or disabled.
356
+
357
+ ## Usage in child processes
358
+
359
+ Due to the way `debug` detects if the output is a TTY or not, colors are not shown in child processes when `stderr` is piped. A solution is to pass the `DEBUG_COLORS=1` environment variable to the child process.
360
+ For example:
361
+
362
+ ```javascript
363
+ worker = fork(WORKER_WRAP_PATH, [workerPath], {
364
+ stdio: [
365
+ /* stdin: */ 0,
366
+ /* stdout: */ 'pipe',
367
+ /* stderr: */ 'pipe',
368
+ 'ipc',
369
+ ],
370
+ env: Object.assign({}, process.env, {
371
+ DEBUG_COLORS: 1 // without this settings, colors won't be shown
372
+ }),
373
+ });
374
+
375
+ worker.stderr.pipe(process.stderr, { end: false });
376
+ ```
377
+
378
+
379
+ ## Authors
380
+
381
+ - TJ Holowaychuk
382
+ - Nathan Rajlich
383
+ - Andrew Rhyne
384
+ - Josh Junon
385
+
386
+ ## Backers
387
+
388
+ Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/debug#backer)]
389
+
390
+ <a href="https://opencollective.com/debug/backer/0/website" target="_blank"><img src="https://opencollective.com/debug/backer/0/avatar.svg"></a>
391
+ <a href="https://opencollective.com/debug/backer/1/website" target="_blank"><img src="https://opencollective.com/debug/backer/1/avatar.svg"></a>
392
+ <a href="https://opencollective.com/debug/backer/2/website" target="_blank"><img src="https://opencollective.com/debug/backer/2/avatar.svg"></a>
393
+ <a href="https://opencollective.com/debug/backer/3/website" target="_blank"><img src="https://opencollective.com/debug/backer/3/avatar.svg"></a>
394
+ <a href="https://opencollective.com/debug/backer/4/website" target="_blank"><img src="https://opencollective.com/debug/backer/4/avatar.svg"></a>
395
+ <a href="https://opencollective.com/debug/backer/5/website" target="_blank"><img src="https://opencollective.com/debug/backer/5/avatar.svg"></a>
396
+ <a href="https://opencollective.com/debug/backer/6/website" target="_blank"><img src="https://opencollective.com/debug/backer/6/avatar.svg"></a>
397
+ <a href="https://opencollective.com/debug/backer/7/website" target="_blank"><img src="https://opencollective.com/debug/backer/7/avatar.svg"></a>
398
+ <a href="https://opencollective.com/debug/backer/8/website" target="_blank"><img src="https://opencollective.com/debug/backer/8/avatar.svg"></a>
399
+ <a href="https://opencollective.com/debug/backer/9/website" target="_blank"><img src="https://opencollective.com/debug/backer/9/avatar.svg"></a>
400
+ <a href="https://opencollective.com/debug/backer/10/website" target="_blank"><img src="https://opencollective.com/debug/backer/10/avatar.svg"></a>
401
+ <a href="https://opencollective.com/debug/backer/11/website" target="_blank"><img src="https://opencollective.com/debug/backer/11/avatar.svg"></a>
402
+ <a href="https://opencollective.com/debug/backer/12/website" target="_blank"><img src="https://opencollective.com/debug/backer/12/avatar.svg"></a>
403
+ <a href="https://opencollective.com/debug/backer/13/website" target="_blank"><img src="https://opencollective.com/debug/backer/13/avatar.svg"></a>
404
+ <a href="https://opencollective.com/debug/backer/14/website" target="_blank"><img src="https://opencollective.com/debug/backer/14/avatar.svg"></a>
405
+ <a href="https://opencollective.com/debug/backer/15/website" target="_blank"><img src="https://opencollective.com/debug/backer/15/avatar.svg"></a>
406
+ <a href="https://opencollective.com/debug/backer/16/website" target="_blank"><img src="https://opencollective.com/debug/backer/16/avatar.svg"></a>
407
+ <a href="https://opencollective.com/debug/backer/17/website" target="_blank"><img src="https://opencollective.com/debug/backer/17/avatar.svg"></a>
408
+ <a href="https://opencollective.com/debug/backer/18/website" target="_blank"><img src="https://opencollective.com/debug/backer/18/avatar.svg"></a>
409
+ <a href="https://opencollective.com/debug/backer/19/website" target="_blank"><img src="https://opencollective.com/debug/backer/19/avatar.svg"></a>
410
+ <a href="https://opencollective.com/debug/backer/20/website" target="_blank"><img src="https://opencollective.com/debug/backer/20/avatar.svg"></a>
411
+ <a href="https://opencollective.com/debug/backer/21/website" target="_blank"><img src="https://opencollective.com/debug/backer/21/avatar.svg"></a>
412
+ <a href="https://opencollective.com/debug/backer/22/website" target="_blank"><img src="https://opencollective.com/debug/backer/22/avatar.svg"></a>
413
+ <a href="https://opencollective.com/debug/backer/23/website" target="_blank"><img src="https://opencollective.com/debug/backer/23/avatar.svg"></a>
414
+ <a href="https://opencollective.com/debug/backer/24/website" target="_blank"><img src="https://opencollective.com/debug/backer/24/avatar.svg"></a>
415
+ <a href="https://opencollective.com/debug/backer/25/website" target="_blank"><img src="https://opencollective.com/debug/backer/25/avatar.svg"></a>
416
+ <a href="https://opencollective.com/debug/backer/26/website" target="_blank"><img src="https://opencollective.com/debug/backer/26/avatar.svg"></a>
417
+ <a href="https://opencollective.com/debug/backer/27/website" target="_blank"><img src="https://opencollective.com/debug/backer/27/avatar.svg"></a>
418
+ <a href="https://opencollective.com/debug/backer/28/website" target="_blank"><img src="https://opencollective.com/debug/backer/28/avatar.svg"></a>
419
+ <a href="https://opencollective.com/debug/backer/29/website" target="_blank"><img src="https://opencollective.com/debug/backer/29/avatar.svg"></a>
420
+
421
+
422
+ ## Sponsors
423
+
424
+ Become a sponsor and get your logo on our README on Github with a link to your site. [[Become a sponsor](https://opencollective.com/debug#sponsor)]
425
+
426
+ <a href="https://opencollective.com/debug/sponsor/0/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/0/avatar.svg"></a>
427
+ <a href="https://opencollective.com/debug/sponsor/1/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/1/avatar.svg"></a>
428
+ <a href="https://opencollective.com/debug/sponsor/2/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/2/avatar.svg"></a>
429
+ <a href="https://opencollective.com/debug/sponsor/3/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/3/avatar.svg"></a>
430
+ <a href="https://opencollective.com/debug/sponsor/4/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/4/avatar.svg"></a>
431
+ <a href="https://opencollective.com/debug/sponsor/5/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/5/avatar.svg"></a>
432
+ <a href="https://opencollective.com/debug/sponsor/6/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/6/avatar.svg"></a>
433
+ <a href="https://opencollective.com/debug/sponsor/7/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/7/avatar.svg"></a>
434
+ <a href="https://opencollective.com/debug/sponsor/8/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/8/avatar.svg"></a>
435
+ <a href="https://opencollective.com/debug/sponsor/9/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/9/avatar.svg"></a>
436
+ <a href="https://opencollective.com/debug/sponsor/10/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/10/avatar.svg"></a>
437
+ <a href="https://opencollective.com/debug/sponsor/11/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/11/avatar.svg"></a>
438
+ <a href="https://opencollective.com/debug/sponsor/12/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/12/avatar.svg"></a>
439
+ <a href="https://opencollective.com/debug/sponsor/13/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/13/avatar.svg"></a>
440
+ <a href="https://opencollective.com/debug/sponsor/14/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/14/avatar.svg"></a>
441
+ <a href="https://opencollective.com/debug/sponsor/15/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/15/avatar.svg"></a>
442
+ <a href="https://opencollective.com/debug/sponsor/16/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/16/avatar.svg"></a>
443
+ <a href="https://opencollective.com/debug/sponsor/17/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/17/avatar.svg"></a>
444
+ <a href="https://opencollective.com/debug/sponsor/18/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/18/avatar.svg"></a>
445
+ <a href="https://opencollective.com/debug/sponsor/19/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/19/avatar.svg"></a>
446
+ <a href="https://opencollective.com/debug/sponsor/20/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/20/avatar.svg"></a>
447
+ <a href="https://opencollective.com/debug/sponsor/21/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/21/avatar.svg"></a>
448
+ <a href="https://opencollective.com/debug/sponsor/22/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/22/avatar.svg"></a>
449
+ <a href="https://opencollective.com/debug/sponsor/23/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/23/avatar.svg"></a>
450
+ <a href="https://opencollective.com/debug/sponsor/24/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/24/avatar.svg"></a>
451
+ <a href="https://opencollective.com/debug/sponsor/25/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/25/avatar.svg"></a>
452
+ <a href="https://opencollective.com/debug/sponsor/26/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/26/avatar.svg"></a>
453
+ <a href="https://opencollective.com/debug/sponsor/27/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/27/avatar.svg"></a>
454
+ <a href="https://opencollective.com/debug/sponsor/28/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/28/avatar.svg"></a>
455
+ <a href="https://opencollective.com/debug/sponsor/29/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/29/avatar.svg"></a>
456
+
457
+ ## License
458
+
459
+ (The MIT License)
460
+
461
+ Copyright (c) 2014-2017 TJ Holowaychuk &lt;[email protected]&gt;
462
+ Copyright (c) 2018-2021 Josh Junon
463
+
464
+ Permission is hereby granted, free of charge, to any person obtaining
465
+ a copy of this software and associated documentation files (the
466
+ 'Software'), to deal in the Software without restriction, including
467
+ without limitation the rights to use, copy, modify, merge, publish,
468
+ distribute, sublicense, and/or sell copies of the Software, and to
469
+ permit persons to whom the Software is furnished to do so, subject to
470
+ the following conditions:
471
+
472
+ The above copyright notice and this permission notice shall be
473
+ included in all copies or substantial portions of the Software.
474
+
475
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
476
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
477
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
478
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
479
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
480
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
481
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
node_modules/debug/package.json ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "debug",
3
+ "version": "4.4.0",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "git://github.com/debug-js/debug.git"
7
+ },
8
+ "description": "Lightweight debugging utility for Node.js and the browser",
9
+ "keywords": [
10
+ "debug",
11
+ "log",
12
+ "debugger"
13
+ ],
14
+ "files": [
15
+ "src",
16
+ "LICENSE",
17
+ "README.md"
18
+ ],
19
+ "author": "Josh Junon (https://github.com/qix-)",
20
+ "contributors": [
21
+ "TJ Holowaychuk <[email protected]>",
22
+ "Nathan Rajlich <[email protected]> (http://n8.io)",
23
+ "Andrew Rhyne <[email protected]>"
24
+ ],
25
+ "license": "MIT",
26
+ "scripts": {
27
+ "lint": "xo",
28
+ "test": "npm run test:node && npm run test:browser && npm run lint",
29
+ "test:node": "istanbul cover _mocha -- test.js test.node.js",
30
+ "test:browser": "karma start --single-run",
31
+ "test:coverage": "cat ./coverage/lcov.info | coveralls"
32
+ },
33
+ "dependencies": {
34
+ "ms": "^2.1.3"
35
+ },
36
+ "devDependencies": {
37
+ "brfs": "^2.0.1",
38
+ "browserify": "^16.2.3",
39
+ "coveralls": "^3.0.2",
40
+ "istanbul": "^0.4.5",
41
+ "karma": "^3.1.4",
42
+ "karma-browserify": "^6.0.0",
43
+ "karma-chrome-launcher": "^2.2.0",
44
+ "karma-mocha": "^1.3.0",
45
+ "mocha": "^5.2.0",
46
+ "mocha-lcov-reporter": "^1.2.0",
47
+ "sinon": "^14.0.0",
48
+ "xo": "^0.23.0"
49
+ },
50
+ "peerDependenciesMeta": {
51
+ "supports-color": {
52
+ "optional": true
53
+ }
54
+ },
55
+ "main": "./src/index.js",
56
+ "browser": "./src/browser.js",
57
+ "engines": {
58
+ "node": ">=6.0"
59
+ },
60
+ "xo": {
61
+ "rules": {
62
+ "import/extensions": "off"
63
+ }
64
+ }
65
+ }
node_modules/debug/src/browser.js ADDED
@@ -0,0 +1,272 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* eslint-env browser */
2
+
3
+ /**
4
+ * This is the web browser implementation of `debug()`.
5
+ */
6
+
7
+ exports.formatArgs = formatArgs;
8
+ exports.save = save;
9
+ exports.load = load;
10
+ exports.useColors = useColors;
11
+ exports.storage = localstorage();
12
+ exports.destroy = (() => {
13
+ let warned = false;
14
+
15
+ return () => {
16
+ if (!warned) {
17
+ warned = true;
18
+ console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
19
+ }
20
+ };
21
+ })();
22
+
23
+ /**
24
+ * Colors.
25
+ */
26
+
27
+ exports.colors = [
28
+ '#0000CC',
29
+ '#0000FF',
30
+ '#0033CC',
31
+ '#0033FF',
32
+ '#0066CC',
33
+ '#0066FF',
34
+ '#0099CC',
35
+ '#0099FF',
36
+ '#00CC00',
37
+ '#00CC33',
38
+ '#00CC66',
39
+ '#00CC99',
40
+ '#00CCCC',
41
+ '#00CCFF',
42
+ '#3300CC',
43
+ '#3300FF',
44
+ '#3333CC',
45
+ '#3333FF',
46
+ '#3366CC',
47
+ '#3366FF',
48
+ '#3399CC',
49
+ '#3399FF',
50
+ '#33CC00',
51
+ '#33CC33',
52
+ '#33CC66',
53
+ '#33CC99',
54
+ '#33CCCC',
55
+ '#33CCFF',
56
+ '#6600CC',
57
+ '#6600FF',
58
+ '#6633CC',
59
+ '#6633FF',
60
+ '#66CC00',
61
+ '#66CC33',
62
+ '#9900CC',
63
+ '#9900FF',
64
+ '#9933CC',
65
+ '#9933FF',
66
+ '#99CC00',
67
+ '#99CC33',
68
+ '#CC0000',
69
+ '#CC0033',
70
+ '#CC0066',
71
+ '#CC0099',
72
+ '#CC00CC',
73
+ '#CC00FF',
74
+ '#CC3300',
75
+ '#CC3333',
76
+ '#CC3366',
77
+ '#CC3399',
78
+ '#CC33CC',
79
+ '#CC33FF',
80
+ '#CC6600',
81
+ '#CC6633',
82
+ '#CC9900',
83
+ '#CC9933',
84
+ '#CCCC00',
85
+ '#CCCC33',
86
+ '#FF0000',
87
+ '#FF0033',
88
+ '#FF0066',
89
+ '#FF0099',
90
+ '#FF00CC',
91
+ '#FF00FF',
92
+ '#FF3300',
93
+ '#FF3333',
94
+ '#FF3366',
95
+ '#FF3399',
96
+ '#FF33CC',
97
+ '#FF33FF',
98
+ '#FF6600',
99
+ '#FF6633',
100
+ '#FF9900',
101
+ '#FF9933',
102
+ '#FFCC00',
103
+ '#FFCC33'
104
+ ];
105
+
106
+ /**
107
+ * Currently only WebKit-based Web Inspectors, Firefox >= v31,
108
+ * and the Firebug extension (any Firefox version) are known
109
+ * to support "%c" CSS customizations.
110
+ *
111
+ * TODO: add a `localStorage` variable to explicitly enable/disable colors
112
+ */
113
+
114
+ // eslint-disable-next-line complexity
115
+ function useColors() {
116
+ // NB: In an Electron preload script, document will be defined but not fully
117
+ // initialized. Since we know we're in Chrome, we'll just detect this case
118
+ // explicitly
119
+ if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
120
+ return true;
121
+ }
122
+
123
+ // Internet Explorer and Edge do not support colors.
124
+ if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
125
+ return false;
126
+ }
127
+
128
+ let m;
129
+
130
+ // Is webkit? http://stackoverflow.com/a/16459606/376773
131
+ // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
132
+ // eslint-disable-next-line no-return-assign
133
+ return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
134
+ // Is firebug? http://stackoverflow.com/a/398120/376773
135
+ (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
136
+ // Is firefox >= v31?
137
+ // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
138
+ (typeof navigator !== 'undefined' && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31) ||
139
+ // Double check webkit in userAgent just in case we are in a worker
140
+ (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
141
+ }
142
+
143
+ /**
144
+ * Colorize log arguments if enabled.
145
+ *
146
+ * @api public
147
+ */
148
+
149
+ function formatArgs(args) {
150
+ args[0] = (this.useColors ? '%c' : '') +
151
+ this.namespace +
152
+ (this.useColors ? ' %c' : ' ') +
153
+ args[0] +
154
+ (this.useColors ? '%c ' : ' ') +
155
+ '+' + module.exports.humanize(this.diff);
156
+
157
+ if (!this.useColors) {
158
+ return;
159
+ }
160
+
161
+ const c = 'color: ' + this.color;
162
+ args.splice(1, 0, c, 'color: inherit');
163
+
164
+ // The final "%c" is somewhat tricky, because there could be other
165
+ // arguments passed either before or after the %c, so we need to
166
+ // figure out the correct index to insert the CSS into
167
+ let index = 0;
168
+ let lastC = 0;
169
+ args[0].replace(/%[a-zA-Z%]/g, match => {
170
+ if (match === '%%') {
171
+ return;
172
+ }
173
+ index++;
174
+ if (match === '%c') {
175
+ // We only are interested in the *last* %c
176
+ // (the user may have provided their own)
177
+ lastC = index;
178
+ }
179
+ });
180
+
181
+ args.splice(lastC, 0, c);
182
+ }
183
+
184
+ /**
185
+ * Invokes `console.debug()` when available.
186
+ * No-op when `console.debug` is not a "function".
187
+ * If `console.debug` is not available, falls back
188
+ * to `console.log`.
189
+ *
190
+ * @api public
191
+ */
192
+ exports.log = console.debug || console.log || (() => {});
193
+
194
+ /**
195
+ * Save `namespaces`.
196
+ *
197
+ * @param {String} namespaces
198
+ * @api private
199
+ */
200
+ function save(namespaces) {
201
+ try {
202
+ if (namespaces) {
203
+ exports.storage.setItem('debug', namespaces);
204
+ } else {
205
+ exports.storage.removeItem('debug');
206
+ }
207
+ } catch (error) {
208
+ // Swallow
209
+ // XXX (@Qix-) should we be logging these?
210
+ }
211
+ }
212
+
213
+ /**
214
+ * Load `namespaces`.
215
+ *
216
+ * @return {String} returns the previously persisted debug modes
217
+ * @api private
218
+ */
219
+ function load() {
220
+ let r;
221
+ try {
222
+ r = exports.storage.getItem('debug');
223
+ } catch (error) {
224
+ // Swallow
225
+ // XXX (@Qix-) should we be logging these?
226
+ }
227
+
228
+ // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
229
+ if (!r && typeof process !== 'undefined' && 'env' in process) {
230
+ r = process.env.DEBUG;
231
+ }
232
+
233
+ return r;
234
+ }
235
+
236
+ /**
237
+ * Localstorage attempts to return the localstorage.
238
+ *
239
+ * This is necessary because safari throws
240
+ * when a user disables cookies/localstorage
241
+ * and you attempt to access it.
242
+ *
243
+ * @return {LocalStorage}
244
+ * @api private
245
+ */
246
+
247
+ function localstorage() {
248
+ try {
249
+ // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
250
+ // The Browser also has localStorage in the global context.
251
+ return localStorage;
252
+ } catch (error) {
253
+ // Swallow
254
+ // XXX (@Qix-) should we be logging these?
255
+ }
256
+ }
257
+
258
+ module.exports = require('./common')(exports);
259
+
260
+ const {formatters} = module.exports;
261
+
262
+ /**
263
+ * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
264
+ */
265
+
266
+ formatters.j = function (v) {
267
+ try {
268
+ return JSON.stringify(v);
269
+ } catch (error) {
270
+ return '[UnexpectedJSONParseError]: ' + error.message;
271
+ }
272
+ };
node_modules/debug/src/common.js ADDED
@@ -0,0 +1,292 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /**
3
+ * This is the common logic for both the Node.js and web browser
4
+ * implementations of `debug()`.
5
+ */
6
+
7
+ function setup(env) {
8
+ createDebug.debug = createDebug;
9
+ createDebug.default = createDebug;
10
+ createDebug.coerce = coerce;
11
+ createDebug.disable = disable;
12
+ createDebug.enable = enable;
13
+ createDebug.enabled = enabled;
14
+ createDebug.humanize = require('ms');
15
+ createDebug.destroy = destroy;
16
+
17
+ Object.keys(env).forEach(key => {
18
+ createDebug[key] = env[key];
19
+ });
20
+
21
+ /**
22
+ * The currently active debug mode names, and names to skip.
23
+ */
24
+
25
+ createDebug.names = [];
26
+ createDebug.skips = [];
27
+
28
+ /**
29
+ * Map of special "%n" handling functions, for the debug "format" argument.
30
+ *
31
+ * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
32
+ */
33
+ createDebug.formatters = {};
34
+
35
+ /**
36
+ * Selects a color for a debug namespace
37
+ * @param {String} namespace The namespace string for the debug instance to be colored
38
+ * @return {Number|String} An ANSI color code for the given namespace
39
+ * @api private
40
+ */
41
+ function selectColor(namespace) {
42
+ let hash = 0;
43
+
44
+ for (let i = 0; i < namespace.length; i++) {
45
+ hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
46
+ hash |= 0; // Convert to 32bit integer
47
+ }
48
+
49
+ return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
50
+ }
51
+ createDebug.selectColor = selectColor;
52
+
53
+ /**
54
+ * Create a debugger with the given `namespace`.
55
+ *
56
+ * @param {String} namespace
57
+ * @return {Function}
58
+ * @api public
59
+ */
60
+ function createDebug(namespace) {
61
+ let prevTime;
62
+ let enableOverride = null;
63
+ let namespacesCache;
64
+ let enabledCache;
65
+
66
+ function debug(...args) {
67
+ // Disabled?
68
+ if (!debug.enabled) {
69
+ return;
70
+ }
71
+
72
+ const self = debug;
73
+
74
+ // Set `diff` timestamp
75
+ const curr = Number(new Date());
76
+ const ms = curr - (prevTime || curr);
77
+ self.diff = ms;
78
+ self.prev = prevTime;
79
+ self.curr = curr;
80
+ prevTime = curr;
81
+
82
+ args[0] = createDebug.coerce(args[0]);
83
+
84
+ if (typeof args[0] !== 'string') {
85
+ // Anything else let's inspect with %O
86
+ args.unshift('%O');
87
+ }
88
+
89
+ // Apply any `formatters` transformations
90
+ let index = 0;
91
+ args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
92
+ // If we encounter an escaped % then don't increase the array index
93
+ if (match === '%%') {
94
+ return '%';
95
+ }
96
+ index++;
97
+ const formatter = createDebug.formatters[format];
98
+ if (typeof formatter === 'function') {
99
+ const val = args[index];
100
+ match = formatter.call(self, val);
101
+
102
+ // Now we need to remove `args[index]` since it's inlined in the `format`
103
+ args.splice(index, 1);
104
+ index--;
105
+ }
106
+ return match;
107
+ });
108
+
109
+ // Apply env-specific formatting (colors, etc.)
110
+ createDebug.formatArgs.call(self, args);
111
+
112
+ const logFn = self.log || createDebug.log;
113
+ logFn.apply(self, args);
114
+ }
115
+
116
+ debug.namespace = namespace;
117
+ debug.useColors = createDebug.useColors();
118
+ debug.color = createDebug.selectColor(namespace);
119
+ debug.extend = extend;
120
+ debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.
121
+
122
+ Object.defineProperty(debug, 'enabled', {
123
+ enumerable: true,
124
+ configurable: false,
125
+ get: () => {
126
+ if (enableOverride !== null) {
127
+ return enableOverride;
128
+ }
129
+ if (namespacesCache !== createDebug.namespaces) {
130
+ namespacesCache = createDebug.namespaces;
131
+ enabledCache = createDebug.enabled(namespace);
132
+ }
133
+
134
+ return enabledCache;
135
+ },
136
+ set: v => {
137
+ enableOverride = v;
138
+ }
139
+ });
140
+
141
+ // Env-specific initialization logic for debug instances
142
+ if (typeof createDebug.init === 'function') {
143
+ createDebug.init(debug);
144
+ }
145
+
146
+ return debug;
147
+ }
148
+
149
+ function extend(namespace, delimiter) {
150
+ const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
151
+ newDebug.log = this.log;
152
+ return newDebug;
153
+ }
154
+
155
+ /**
156
+ * Enables a debug mode by namespaces. This can include modes
157
+ * separated by a colon and wildcards.
158
+ *
159
+ * @param {String} namespaces
160
+ * @api public
161
+ */
162
+ function enable(namespaces) {
163
+ createDebug.save(namespaces);
164
+ createDebug.namespaces = namespaces;
165
+
166
+ createDebug.names = [];
167
+ createDebug.skips = [];
168
+
169
+ const split = (typeof namespaces === 'string' ? namespaces : '')
170
+ .trim()
171
+ .replace(' ', ',')
172
+ .split(',')
173
+ .filter(Boolean);
174
+
175
+ for (const ns of split) {
176
+ if (ns[0] === '-') {
177
+ createDebug.skips.push(ns.slice(1));
178
+ } else {
179
+ createDebug.names.push(ns);
180
+ }
181
+ }
182
+ }
183
+
184
+ /**
185
+ * Checks if the given string matches a namespace template, honoring
186
+ * asterisks as wildcards.
187
+ *
188
+ * @param {String} search
189
+ * @param {String} template
190
+ * @return {Boolean}
191
+ */
192
+ function matchesTemplate(search, template) {
193
+ let searchIndex = 0;
194
+ let templateIndex = 0;
195
+ let starIndex = -1;
196
+ let matchIndex = 0;
197
+
198
+ while (searchIndex < search.length) {
199
+ if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === '*')) {
200
+ // Match character or proceed with wildcard
201
+ if (template[templateIndex] === '*') {
202
+ starIndex = templateIndex;
203
+ matchIndex = searchIndex;
204
+ templateIndex++; // Skip the '*'
205
+ } else {
206
+ searchIndex++;
207
+ templateIndex++;
208
+ }
209
+ } else if (starIndex !== -1) { // eslint-disable-line no-negated-condition
210
+ // Backtrack to the last '*' and try to match more characters
211
+ templateIndex = starIndex + 1;
212
+ matchIndex++;
213
+ searchIndex = matchIndex;
214
+ } else {
215
+ return false; // No match
216
+ }
217
+ }
218
+
219
+ // Handle trailing '*' in template
220
+ while (templateIndex < template.length && template[templateIndex] === '*') {
221
+ templateIndex++;
222
+ }
223
+
224
+ return templateIndex === template.length;
225
+ }
226
+
227
+ /**
228
+ * Disable debug output.
229
+ *
230
+ * @return {String} namespaces
231
+ * @api public
232
+ */
233
+ function disable() {
234
+ const namespaces = [
235
+ ...createDebug.names,
236
+ ...createDebug.skips.map(namespace => '-' + namespace)
237
+ ].join(',');
238
+ createDebug.enable('');
239
+ return namespaces;
240
+ }
241
+
242
+ /**
243
+ * Returns true if the given mode name is enabled, false otherwise.
244
+ *
245
+ * @param {String} name
246
+ * @return {Boolean}
247
+ * @api public
248
+ */
249
+ function enabled(name) {
250
+ for (const skip of createDebug.skips) {
251
+ if (matchesTemplate(name, skip)) {
252
+ return false;
253
+ }
254
+ }
255
+
256
+ for (const ns of createDebug.names) {
257
+ if (matchesTemplate(name, ns)) {
258
+ return true;
259
+ }
260
+ }
261
+
262
+ return false;
263
+ }
264
+
265
+ /**
266
+ * Coerce `val`.
267
+ *
268
+ * @param {Mixed} val
269
+ * @return {Mixed}
270
+ * @api private
271
+ */
272
+ function coerce(val) {
273
+ if (val instanceof Error) {
274
+ return val.stack || val.message;
275
+ }
276
+ return val;
277
+ }
278
+
279
+ /**
280
+ * XXX DO NOT USE. This is a temporary stub function.
281
+ * XXX It WILL be removed in the next major release.
282
+ */
283
+ function destroy() {
284
+ console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
285
+ }
286
+
287
+ createDebug.enable(createDebug.load());
288
+
289
+ return createDebug;
290
+ }
291
+
292
+ module.exports = setup;
node_modules/debug/src/index.js ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Detect Electron renderer / nwjs process, which is node, but we should
3
+ * treat as a browser.
4
+ */
5
+
6
+ if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) {
7
+ module.exports = require('./browser.js');
8
+ } else {
9
+ module.exports = require('./node.js');
10
+ }