node-datachannel 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +12 -0
- package/.eslintignore +2 -0
- package/.eslintrc.js +8 -0
- package/.github/FUNDING.yml +2 -0
- package/.github/workflows/build-linux.yml +5 -3
- package/.github/workflows/build-mac.yml +1 -1
- package/.github/workflows/build-win.yml +4 -10
- package/.prettierrc.js +7 -0
- package/CMakeLists.txt +8 -2
- package/README.md +4 -4
- package/lib/datachannel-stream.js +97 -0
- package/lib/index.d.ts +60 -53
- package/lib/index.js +5 -2
- package/node_modules/decompress-response/index.d.ts +14 -21
- package/node_modules/decompress-response/index.js +34 -16
- package/node_modules/decompress-response/license +1 -1
- package/node_modules/decompress-response/package.json +23 -17
- package/node_modules/decompress-response/readme.md +2 -6
- package/node_modules/detect-libc/README.md +124 -42
- package/node_modules/detect-libc/index.d.ts +11 -0
- package/node_modules/detect-libc/lib/detect-libc.js +166 -80
- package/node_modules/detect-libc/lib/process.js +16 -0
- package/node_modules/detect-libc/package.json +20 -19
- package/node_modules/{semver → lru-cache}/LICENSE +0 -0
- package/node_modules/lru-cache/README.md +166 -0
- package/node_modules/lru-cache/index.js +334 -0
- package/node_modules/lru-cache/node_modules/yallist/LICENSE +15 -0
- package/node_modules/lru-cache/node_modules/yallist/README.md +204 -0
- package/node_modules/lru-cache/node_modules/yallist/iterator.js +8 -0
- package/node_modules/lru-cache/node_modules/yallist/package.json +65 -0
- package/node_modules/lru-cache/node_modules/yallist/yallist.js +426 -0
- package/node_modules/lru-cache/package.json +75 -0
- package/node_modules/mimic-response/index.d.ts +2 -2
- package/node_modules/mimic-response/index.js +41 -2
- package/node_modules/mimic-response/package.json +17 -17
- package/node_modules/mimic-response/readme.md +22 -1
- package/node_modules/minimist/index.js +6 -2
- package/node_modules/minimist/package.json +10 -10
- package/node_modules/minimist/readme.markdown +4 -1
- package/node_modules/minimist/test/proto.js +16 -0
- package/node_modules/node-abi/.circleci/config.yml +63 -0
- package/node_modules/node-abi/.releaserc.json +9 -0
- package/node_modules/node-abi/abi_registry.json +45 -3
- package/node_modules/node-abi/index.js +5 -2
- package/node_modules/node-abi/node_modules/semver/CHANGELOG.md +111 -0
- package/node_modules/node-abi/node_modules/semver/LICENSE +15 -0
- package/node_modules/{semver → node-abi/node_modules/semver}/README.md +180 -26
- package/node_modules/node-abi/node_modules/semver/bin/semver.js +173 -0
- package/node_modules/node-abi/node_modules/semver/classes/comparator.js +135 -0
- package/node_modules/node-abi/node_modules/semver/classes/index.js +5 -0
- package/node_modules/node-abi/node_modules/semver/classes/range.js +510 -0
- package/node_modules/node-abi/node_modules/semver/classes/semver.js +287 -0
- package/node_modules/node-abi/node_modules/semver/functions/clean.js +6 -0
- package/node_modules/node-abi/node_modules/semver/functions/cmp.js +48 -0
- package/node_modules/node-abi/node_modules/semver/functions/coerce.js +51 -0
- package/node_modules/node-abi/node_modules/semver/functions/compare-build.js +7 -0
- package/node_modules/node-abi/node_modules/semver/functions/compare-loose.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/compare.js +5 -0
- package/node_modules/node-abi/node_modules/semver/functions/diff.js +23 -0
- package/node_modules/node-abi/node_modules/semver/functions/eq.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/gt.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/gte.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/inc.js +15 -0
- package/node_modules/node-abi/node_modules/semver/functions/lt.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/lte.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/major.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/minor.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/neq.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/parse.js +33 -0
- package/node_modules/node-abi/node_modules/semver/functions/patch.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/prerelease.js +6 -0
- package/node_modules/node-abi/node_modules/semver/functions/rcompare.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/rsort.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/satisfies.js +10 -0
- package/node_modules/node-abi/node_modules/semver/functions/sort.js +3 -0
- package/node_modules/node-abi/node_modules/semver/functions/valid.js +6 -0
- package/node_modules/node-abi/node_modules/semver/index.js +48 -0
- package/node_modules/node-abi/node_modules/semver/internal/constants.js +17 -0
- package/node_modules/node-abi/node_modules/semver/internal/debug.js +9 -0
- package/node_modules/node-abi/node_modules/semver/internal/identifiers.js +23 -0
- package/node_modules/node-abi/node_modules/semver/internal/parse-options.js +11 -0
- package/node_modules/node-abi/node_modules/semver/internal/re.js +182 -0
- package/node_modules/{semver → node-abi/node_modules/semver}/package.json +32 -23
- package/node_modules/node-abi/node_modules/semver/preload.js +2 -0
- package/node_modules/{semver → node-abi/node_modules/semver}/range.bnf +0 -0
- package/node_modules/node-abi/node_modules/semver/ranges/gtr.js +4 -0
- package/node_modules/node-abi/node_modules/semver/ranges/intersects.js +7 -0
- package/node_modules/node-abi/node_modules/semver/ranges/ltr.js +4 -0
- package/node_modules/node-abi/node_modules/semver/ranges/max-satisfying.js +25 -0
- package/node_modules/node-abi/node_modules/semver/ranges/min-satisfying.js +24 -0
- package/node_modules/node-abi/node_modules/semver/ranges/min-version.js +60 -0
- package/node_modules/node-abi/node_modules/semver/ranges/outside.js +80 -0
- package/node_modules/node-abi/node_modules/semver/ranges/simplify.js +44 -0
- package/node_modules/node-abi/node_modules/semver/ranges/subset.js +222 -0
- package/node_modules/node-abi/node_modules/semver/ranges/to-comparators.js +8 -0
- package/node_modules/node-abi/node_modules/semver/ranges/valid.js +11 -0
- package/node_modules/node-abi/package.json +21 -17
- package/node_modules/node-abi/test/index.js +7 -15
- package/node_modules/prebuild-install/CHANGELOG.md +24 -7
- package/node_modules/prebuild-install/README.md +24 -4
- package/node_modules/prebuild-install/asset.js +10 -10
- package/node_modules/prebuild-install/bin.js +13 -13
- package/node_modules/prebuild-install/download.js +22 -22
- package/node_modules/prebuild-install/log.js +4 -4
- package/node_modules/prebuild-install/package.json +18 -19
- package/node_modules/prebuild-install/proxy.js +10 -10
- package/node_modules/prebuild-install/rc.js +12 -12
- package/node_modules/prebuild-install/util.js +14 -14
- package/node_modules/simple-get/.github/dependabot.yml +15 -0
- package/node_modules/simple-get/.github/workflows/ci.yml +23 -0
- package/node_modules/simple-get/README.md +17 -3
- package/node_modules/simple-get/index.js +9 -0
- package/node_modules/simple-get/package.json +27 -13
- package/package.json +15 -6
- package/src/data-channel-wrapper.cpp +56 -22
- package/src/data-channel-wrapper.h +3 -0
- package/src/media-audio-wrapper.cpp +7 -7
- package/src/media-track-wrapper.cpp +40 -21
- package/src/media-track-wrapper.h +2 -0
- package/src/media-video-wrapper.cpp +5 -5
- package/src/peer-connection-wrapper.cpp +48 -27
- package/src/peer-connection-wrapper.h +2 -0
- package/test/connectivity.js +6 -6
- package/test/test.js +46 -1
- package/node_modules/detect-libc/.npmignore +0 -7
- package/node_modules/detect-libc/bin/detect-libc.js +0 -18
- package/node_modules/node-abi/.travis.yml +0 -17
- package/node_modules/semver/CHANGELOG.md +0 -39
- package/node_modules/semver/bin/semver +0 -160
- package/node_modules/semver/semver.js +0 -1483
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"_args": [
|
|
3
3
|
[
|
|
4
|
-
"prebuild-install@
|
|
4
|
+
"prebuild-install@7.0.1",
|
|
5
5
|
"/home/runner/work/node-datachannel/node-datachannel"
|
|
6
6
|
]
|
|
7
7
|
],
|
|
8
|
-
"_from": "prebuild-install@
|
|
9
|
-
"_id": "prebuild-install@
|
|
8
|
+
"_from": "prebuild-install@7.0.1",
|
|
9
|
+
"_id": "prebuild-install@7.0.1",
|
|
10
10
|
"_inBundle": false,
|
|
11
|
-
"_integrity": "sha512-
|
|
11
|
+
"_integrity": "sha512-QBSab31WqkyxpnMWQxubYAHR5S9B2+r81ucocew34Fkl98FhvKIF50jIJnNOBmAZfyNV7vE5T6gd3hTVWgY6tg==",
|
|
12
12
|
"_location": "/prebuild-install",
|
|
13
13
|
"_phantomChildren": {},
|
|
14
14
|
"_requested": {
|
|
15
15
|
"type": "version",
|
|
16
16
|
"registry": true,
|
|
17
|
-
"raw": "prebuild-install@
|
|
17
|
+
"raw": "prebuild-install@7.0.1",
|
|
18
18
|
"name": "prebuild-install",
|
|
19
19
|
"escapedName": "prebuild-install",
|
|
20
|
-
"rawSpec": "
|
|
20
|
+
"rawSpec": "7.0.1",
|
|
21
21
|
"saveSpec": null,
|
|
22
|
-
"fetchSpec": "
|
|
22
|
+
"fetchSpec": "7.0.1"
|
|
23
23
|
},
|
|
24
24
|
"_requiredBy": [
|
|
25
25
|
"/"
|
|
26
26
|
],
|
|
27
|
-
"_resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-
|
|
28
|
-
"_spec": "
|
|
27
|
+
"_resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-7.0.1.tgz",
|
|
28
|
+
"_spec": "7.0.1",
|
|
29
29
|
"_where": "/home/runner/work/node-datachannel/node-datachannel",
|
|
30
30
|
"author": {
|
|
31
31
|
"name": "Mathias Buus",
|
|
@@ -75,32 +75,32 @@
|
|
|
75
75
|
}
|
|
76
76
|
],
|
|
77
77
|
"dependencies": {
|
|
78
|
-
"detect-libc": "^
|
|
78
|
+
"detect-libc": "^2.0.0",
|
|
79
79
|
"expand-template": "^2.0.3",
|
|
80
80
|
"github-from-package": "0.0.0",
|
|
81
81
|
"minimist": "^1.2.3",
|
|
82
82
|
"mkdirp-classic": "^0.5.3",
|
|
83
83
|
"napi-build-utils": "^1.0.1",
|
|
84
|
-
"node-abi": "^
|
|
84
|
+
"node-abi": "^3.3.0",
|
|
85
85
|
"npmlog": "^4.0.1",
|
|
86
86
|
"pump": "^3.0.0",
|
|
87
87
|
"rc": "^1.2.7",
|
|
88
|
-
"simple-get": "^
|
|
88
|
+
"simple-get": "^4.0.0",
|
|
89
89
|
"tar-fs": "^2.0.0",
|
|
90
90
|
"tunnel-agent": "^0.6.0"
|
|
91
91
|
},
|
|
92
92
|
"description": "A command line tool to easily install prebuilt binaries for multiple version of node/iojs on a specific platform",
|
|
93
93
|
"devDependencies": {
|
|
94
94
|
"a-native-module": "^1.0.0",
|
|
95
|
-
"hallmark": "^
|
|
95
|
+
"hallmark": "^4.0.0",
|
|
96
96
|
"nock": "^10.0.6",
|
|
97
97
|
"rimraf": "^2.5.2",
|
|
98
|
-
"standard": "^
|
|
99
|
-
"tape": "^
|
|
98
|
+
"standard": "^16.0.4",
|
|
99
|
+
"tape": "^5.3.1",
|
|
100
100
|
"tempy": "0.2.1"
|
|
101
101
|
},
|
|
102
102
|
"engines": {
|
|
103
|
-
"node": ">=
|
|
103
|
+
"node": ">=10"
|
|
104
104
|
},
|
|
105
105
|
"homepage": "https://github.com/prebuild/prebuild-install",
|
|
106
106
|
"keywords": [
|
|
@@ -123,8 +123,7 @@
|
|
|
123
123
|
},
|
|
124
124
|
"scripts": {
|
|
125
125
|
"hallmark": "hallmark --fix",
|
|
126
|
-
"
|
|
127
|
-
"test": "tape test/*-test.js && npm run lint"
|
|
126
|
+
"test": "standard && hallmark && tape test/*-test.js"
|
|
128
127
|
},
|
|
129
|
-
"version": "
|
|
128
|
+
"version": "7.0.1"
|
|
130
129
|
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
const url = require('url')
|
|
2
|
+
const tunnel = require('tunnel-agent')
|
|
3
|
+
const util = require('./util')
|
|
4
4
|
|
|
5
5
|
function applyProxy (reqOpts, opts) {
|
|
6
|
-
|
|
6
|
+
const log = opts.log || util.noopLogger
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
const proxy = opts['https-proxy'] || opts.proxy
|
|
9
9
|
|
|
10
10
|
if (proxy) {
|
|
11
11
|
// eslint-disable-next-line node/no-deprecated-api
|
|
12
|
-
|
|
12
|
+
const parsedDownloadUrl = url.parse(reqOpts.url)
|
|
13
13
|
// eslint-disable-next-line node/no-deprecated-api
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
const parsedProxy = url.parse(proxy)
|
|
15
|
+
const uriProtocol = (parsedDownloadUrl.protocol === 'https:' ? 'https' : 'http')
|
|
16
|
+
const proxyProtocol = (parsedProxy.protocol === 'https:' ? 'Https' : 'Http')
|
|
17
|
+
const tunnelFnName = [uriProtocol, proxyProtocol].join('Over')
|
|
18
18
|
reqOpts.agent = tunnel[tunnelFnName]({
|
|
19
19
|
proxy: {
|
|
20
20
|
host: parsedProxy.hostname,
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
const path = require('path')
|
|
2
|
+
const minimist = require('minimist')
|
|
3
|
+
const getAbi = require('node-abi').getAbi
|
|
4
|
+
const detectLibc = require('detect-libc')
|
|
5
|
+
const napi = require('napi-build-utils')
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const env = process.env
|
|
8
|
+
const libc = env.LIBC || (detectLibc.isNonGlibcLinuxSync() && detectLibc.familySync()) || ''
|
|
9
9
|
|
|
10
10
|
// Get the configuration
|
|
11
11
|
module.exports = function (pkg) {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
const pkgConf = pkg.config || {}
|
|
13
|
+
const buildFromSource = env.npm_config_build_from_source
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
const rc = require('rc')('prebuild-install', {
|
|
16
16
|
target: pkgConf.target || env.npm_config_target || process.versions.node,
|
|
17
17
|
runtime: pkgConf.runtime || env.npm_config_runtime || 'node',
|
|
18
18
|
arch: pkgConf.arch || env.npm_config_arch || process.arch,
|
|
@@ -23,8 +23,8 @@ module.exports = function (pkg) {
|
|
|
23
23
|
verbose: env.npm_config_verbose === 'true',
|
|
24
24
|
buildFromSource: buildFromSource === pkg.name || buildFromSource === 'true',
|
|
25
25
|
path: '.',
|
|
26
|
-
proxy: env.npm_config_proxy || env
|
|
27
|
-
'https-proxy': env.npm_config_https_proxy || env
|
|
26
|
+
proxy: env.npm_config_proxy || env.http_proxy || env.HTTP_PROXY,
|
|
27
|
+
'https-proxy': env.npm_config_https_proxy || env.https_proxy || env.HTTPS_PROXY,
|
|
28
28
|
'local-address': env.npm_config_local_address,
|
|
29
29
|
'local-prebuilds': 'prebuilds',
|
|
30
30
|
'tag-prefix': 'v',
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
const path = require('path')
|
|
2
|
+
const github = require('github-from-package')
|
|
3
|
+
const home = require('os').homedir
|
|
4
|
+
const crypto = require('crypto')
|
|
5
|
+
const expandTemplate = require('expand-template')()
|
|
6
6
|
|
|
7
7
|
function getDownloadUrl (opts) {
|
|
8
|
-
|
|
8
|
+
const pkgName = opts.pkg.name.replace(/^@[a-zA-Z0-9_\-.~]+\//, '')
|
|
9
9
|
return expandTemplate(urlTemplate(opts), {
|
|
10
10
|
name: pkgName,
|
|
11
11
|
package_name: pkgName,
|
|
@@ -40,8 +40,8 @@ function urlTemplate (opts) {
|
|
|
40
40
|
return opts.download
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
const packageName = '{name}-v{version}-{runtime}-v{abi}-{platform}{libc}-{arch}.tar.gz'
|
|
44
|
+
const hostMirrorUrl = getHostMirrorUrl(opts)
|
|
45
45
|
|
|
46
46
|
if (hostMirrorUrl) {
|
|
47
47
|
return hostMirrorUrl + '/{tag_prefix}{version}/' + packageName
|
|
@@ -65,7 +65,7 @@ function getEnvPrefix (pkgName) {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
function getHostMirrorUrl (opts) {
|
|
68
|
-
|
|
68
|
+
const propName = getEnvPrefix(opts.pkg.name) + '_binary_host'
|
|
69
69
|
return process.env[propName] || process.env[propName + '_mirror']
|
|
70
70
|
}
|
|
71
71
|
|
|
@@ -74,12 +74,12 @@ function trimSlashes (str) {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
function cachedPrebuild (url) {
|
|
77
|
-
|
|
77
|
+
const digest = crypto.createHash('md5').update(url).digest('hex').slice(0, 6)
|
|
78
78
|
return path.join(prebuildCache(), digest + '-' + path.basename(url).replace(/[^a-zA-Z0-9.]+/g, '-'))
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
function npmCache () {
|
|
82
|
-
|
|
82
|
+
const env = process.env
|
|
83
83
|
return env.npm_config_cache || (env.APPDATA ? path.join(env.APPDATA, 'npm-cache') : path.join(home(), '.npm'))
|
|
84
84
|
}
|
|
85
85
|
|
|
@@ -110,12 +110,12 @@ function packageOrigin (env, pkg) {
|
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
function localPrebuild (url, opts) {
|
|
113
|
-
|
|
114
|
-
|
|
113
|
+
const propName = getEnvPrefix(opts.pkg.name) + '_local_prebuilds'
|
|
114
|
+
const prefix = process.env[propName] || opts['local-prebuilds'] || 'prebuilds'
|
|
115
115
|
return path.join(prefix, path.basename(url))
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
|
|
118
|
+
const noopLogger = {
|
|
119
119
|
http: function () {},
|
|
120
120
|
silly: function () {},
|
|
121
121
|
debug: function () {},
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
updates:
|
|
3
|
+
- package-ecosystem: npm
|
|
4
|
+
directory: /
|
|
5
|
+
schedule:
|
|
6
|
+
interval: daily
|
|
7
|
+
labels:
|
|
8
|
+
- dependency
|
|
9
|
+
versioning-strategy: increase-if-necessary
|
|
10
|
+
- package-ecosystem: github-actions
|
|
11
|
+
directory: /
|
|
12
|
+
schedule:
|
|
13
|
+
interval: daily
|
|
14
|
+
labels:
|
|
15
|
+
- dependency
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
name: ci
|
|
2
|
+
'on':
|
|
3
|
+
- push
|
|
4
|
+
- pull_request
|
|
5
|
+
jobs:
|
|
6
|
+
test:
|
|
7
|
+
name: Node ${{ matrix.node }} / ${{ matrix.os }}
|
|
8
|
+
runs-on: ${{ matrix.os }}
|
|
9
|
+
strategy:
|
|
10
|
+
fail-fast: false
|
|
11
|
+
matrix:
|
|
12
|
+
os:
|
|
13
|
+
- ubuntu-latest
|
|
14
|
+
node:
|
|
15
|
+
- '14'
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v2
|
|
18
|
+
- uses: actions/setup-node@v2
|
|
19
|
+
with:
|
|
20
|
+
node-version: ${{ matrix.node }}
|
|
21
|
+
- run: npm install
|
|
22
|
+
- run: npm run build --if-present
|
|
23
|
+
- run: npm test
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
# simple-get [![
|
|
1
|
+
# simple-get [![ci][ci-image]][ci-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url]
|
|
2
2
|
|
|
3
|
-
[
|
|
4
|
-
[
|
|
3
|
+
[ci-image]: https://img.shields.io/github/workflow/status/feross/simple-get/ci/master
|
|
4
|
+
[ci-url]: https://github.com/feross/simple-get/actions
|
|
5
5
|
[npm-image]: https://img.shields.io/npm/v/simple-get.svg
|
|
6
6
|
[npm-url]: https://npmjs.org/package/simple-get
|
|
7
7
|
[downloads-image]: https://img.shields.io/npm/dm/simple-get.svg
|
|
@@ -254,6 +254,20 @@ const opts = {
|
|
|
254
254
|
get(opts, function (err, res) {})
|
|
255
255
|
```
|
|
256
256
|
|
|
257
|
+
### Basic Auth
|
|
258
|
+
|
|
259
|
+
```js
|
|
260
|
+
const user = 'someuser'
|
|
261
|
+
const pass = 'pa$$word'
|
|
262
|
+
const encodedAuth = Buffer.from(`${user}:${pass}`).toString('base64')
|
|
263
|
+
|
|
264
|
+
get('http://example.com', {
|
|
265
|
+
headers: {
|
|
266
|
+
authorization: `Basic ${encodedAuth}`
|
|
267
|
+
}
|
|
268
|
+
})
|
|
269
|
+
```
|
|
270
|
+
|
|
257
271
|
### OAuth
|
|
258
272
|
|
|
259
273
|
You can use the [`oauth-1.0a`](https://github.com/ddo/oauth-1.0a) module to create
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/*! simple-get. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
1
2
|
module.exports = simpleGet
|
|
2
3
|
|
|
3
4
|
const concat = require('simple-concat')
|
|
@@ -43,6 +44,7 @@ function simpleGet (opts, cb) {
|
|
|
43
44
|
if (opts.json) opts.headers.accept = 'application/json'
|
|
44
45
|
if (opts.method) opts.method = opts.method.toUpperCase()
|
|
45
46
|
|
|
47
|
+
const originalHost = opts.hostname // hostname before potential redirect
|
|
46
48
|
const protocol = opts.protocol === 'https:' ? https : http // Support http/https urls
|
|
47
49
|
const req = protocol.request(opts, res => {
|
|
48
50
|
if (opts.followRedirects !== false && res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
|
@@ -50,6 +52,13 @@ function simpleGet (opts, cb) {
|
|
|
50
52
|
delete opts.headers.host // Discard `host` header on redirect (see #32)
|
|
51
53
|
res.resume() // Discard response
|
|
52
54
|
|
|
55
|
+
const redirectHost = url.parse(opts.url).hostname // eslint-disable-line node/no-deprecated-api
|
|
56
|
+
// If redirected host is different than original host, drop headers to prevent cookie leak (#73)
|
|
57
|
+
if (redirectHost !== null && redirectHost !== originalHost) {
|
|
58
|
+
delete opts.headers.cookie
|
|
59
|
+
delete opts.headers.authorization
|
|
60
|
+
}
|
|
61
|
+
|
|
53
62
|
if (opts.method === 'POST' && [301, 302].includes(res.statusCode)) {
|
|
54
63
|
opts.method = 'GET' // On 301/302 redirect, change POST to GET (see #35)
|
|
55
64
|
delete opts.headers['content-length']; delete opts.headers['content-type']
|
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"_args": [
|
|
3
3
|
[
|
|
4
|
-
"simple-get@
|
|
4
|
+
"simple-get@4.0.1",
|
|
5
5
|
"/home/runner/work/node-datachannel/node-datachannel"
|
|
6
6
|
]
|
|
7
7
|
],
|
|
8
|
-
"_from": "simple-get@
|
|
9
|
-
"_id": "simple-get@
|
|
8
|
+
"_from": "simple-get@4.0.1",
|
|
9
|
+
"_id": "simple-get@4.0.1",
|
|
10
10
|
"_inBundle": false,
|
|
11
|
-
"_integrity": "sha512-
|
|
11
|
+
"_integrity": "sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==",
|
|
12
12
|
"_location": "/simple-get",
|
|
13
13
|
"_phantomChildren": {},
|
|
14
14
|
"_requested": {
|
|
15
15
|
"type": "version",
|
|
16
16
|
"registry": true,
|
|
17
|
-
"raw": "simple-get@
|
|
17
|
+
"raw": "simple-get@4.0.1",
|
|
18
18
|
"name": "simple-get",
|
|
19
19
|
"escapedName": "simple-get",
|
|
20
|
-
"rawSpec": "
|
|
20
|
+
"rawSpec": "4.0.1",
|
|
21
21
|
"saveSpec": null,
|
|
22
|
-
"fetchSpec": "
|
|
22
|
+
"fetchSpec": "4.0.1"
|
|
23
23
|
},
|
|
24
24
|
"_requiredBy": [
|
|
25
25
|
"/prebuild-install"
|
|
26
26
|
],
|
|
27
|
-
"_resolved": "https://registry.npmjs.org/simple-get/-/simple-get-
|
|
28
|
-
"_spec": "
|
|
27
|
+
"_resolved": "https://registry.npmjs.org/simple-get/-/simple-get-4.0.1.tgz",
|
|
28
|
+
"_spec": "4.0.1",
|
|
29
29
|
"_where": "/home/runner/work/node-datachannel/node-datachannel",
|
|
30
30
|
"author": {
|
|
31
31
|
"name": "Feross Aboukhadijeh",
|
|
32
32
|
"email": "feross@feross.org",
|
|
33
|
-
"url": "
|
|
33
|
+
"url": "https://feross.org"
|
|
34
34
|
},
|
|
35
35
|
"browser": {
|
|
36
36
|
"decompress-response": false
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"url": "https://github.com/feross/simple-get/issues"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"decompress-response": "^
|
|
42
|
+
"decompress-response": "^6.0.0",
|
|
43
43
|
"once": "^1.3.1",
|
|
44
44
|
"simple-concat": "^1.0.0"
|
|
45
45
|
},
|
|
@@ -48,8 +48,22 @@
|
|
|
48
48
|
"self-signed-https": "^1.0.5",
|
|
49
49
|
"standard": "*",
|
|
50
50
|
"string-to-stream": "^3.0.0",
|
|
51
|
-
"tape": "^
|
|
51
|
+
"tape": "^5.0.0"
|
|
52
52
|
},
|
|
53
|
+
"funding": [
|
|
54
|
+
{
|
|
55
|
+
"type": "github",
|
|
56
|
+
"url": "https://github.com/sponsors/feross"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"type": "patreon",
|
|
60
|
+
"url": "https://www.patreon.com/feross"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"type": "consulting",
|
|
64
|
+
"url": "https://feross.org/support"
|
|
65
|
+
}
|
|
66
|
+
],
|
|
53
67
|
"homepage": "https://github.com/feross/simple-get",
|
|
54
68
|
"keywords": [
|
|
55
69
|
"request",
|
|
@@ -77,5 +91,5 @@
|
|
|
77
91
|
"scripts": {
|
|
78
92
|
"test": "standard && tape test/*.js"
|
|
79
93
|
},
|
|
80
|
-
"version": "
|
|
94
|
+
"version": "4.0.1"
|
|
81
95
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-datachannel",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "libdatachannel node bindings",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"build": "cmake-js build",
|
|
16
16
|
"_prebuild": "prebuild --backend cmake-js",
|
|
17
17
|
"clean": "cmake-js clean",
|
|
18
|
+
"lint": "eslint lib/**/*",
|
|
18
19
|
"test": "jest"
|
|
19
20
|
},
|
|
20
21
|
"repository": {
|
|
@@ -46,17 +47,25 @@
|
|
|
46
47
|
},
|
|
47
48
|
"homepage": "https://github.com/murat-dogan/node-datachannel#readme",
|
|
48
49
|
"devDependencies": {
|
|
49
|
-
"
|
|
50
|
-
"
|
|
50
|
+
"@types/node": "^17.0.23",
|
|
51
|
+
"@typescript-eslint/eslint-plugin": "^5.18.0",
|
|
52
|
+
"@typescript-eslint/parser": "^5.18.0",
|
|
53
|
+
"cmake-js": "^6.3.0",
|
|
54
|
+
"eslint": "^8.12.0",
|
|
55
|
+
"eslint-config-prettier": "^8.5.0",
|
|
56
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
57
|
+
"jest": "^27.5.1",
|
|
51
58
|
"nan": "^2.15.0",
|
|
52
59
|
"napi-thread-safe-callback-cancellable": "^0.0.7",
|
|
53
|
-
"node-addon-api": "^4.
|
|
54
|
-
"prebuild": "^11.0.
|
|
60
|
+
"node-addon-api": "^4.3.0",
|
|
61
|
+
"prebuild": "^11.0.3",
|
|
62
|
+
"prettier": "^2.6.2",
|
|
63
|
+
"typescript": "^4.6.3"
|
|
55
64
|
},
|
|
56
65
|
"bundledDependencies": [
|
|
57
66
|
"prebuild-install"
|
|
58
67
|
],
|
|
59
68
|
"dependencies": {
|
|
60
|
-
"prebuild-install": "^
|
|
69
|
+
"prebuild-install": "^7.0.1"
|
|
61
70
|
}
|
|
62
71
|
}
|
|
@@ -20,6 +20,8 @@ Napi::Object DataChannelWrapper::Init(Napi::Env env, Napi::Object exports)
|
|
|
20
20
|
{
|
|
21
21
|
InstanceMethod("close", &DataChannelWrapper::close),
|
|
22
22
|
InstanceMethod("getLabel", &DataChannelWrapper::getLabel),
|
|
23
|
+
InstanceMethod("getId", &DataChannelWrapper::getId),
|
|
24
|
+
InstanceMethod("getProtocol", &DataChannelWrapper::getProtocol),
|
|
23
25
|
InstanceMethod("sendMessage", &DataChannelWrapper::sendMessage),
|
|
24
26
|
InstanceMethod("sendMessageBinary", &DataChannelWrapper::sendMessageBinary),
|
|
25
27
|
InstanceMethod("isOpen", &DataChannelWrapper::isOpen),
|
|
@@ -42,8 +44,26 @@ Napi::Object DataChannelWrapper::Init(Napi::Env env, Napi::Object exports)
|
|
|
42
44
|
|
|
43
45
|
DataChannelWrapper::DataChannelWrapper(const Napi::CallbackInfo &info) : Napi::ObjectWrap<DataChannelWrapper>(info)
|
|
44
46
|
{
|
|
45
|
-
mDataChannelPtr = *(info[0].As<Napi::External<std::shared_ptr<rtc::DataChannel>>>().Data());
|
|
47
|
+
mDataChannelPtr = *(info[0].As<Napi::External<std::shared_ptr<rtc::DataChannel>>>().Data());
|
|
46
48
|
|
|
49
|
+
mDataChannelPtr->onClosed([&]()
|
|
50
|
+
{
|
|
51
|
+
if (mOnClosedCallback)
|
|
52
|
+
mOnClosedCallback->call([this](Napi::Env env, std::vector<napi_value> &args) {
|
|
53
|
+
// Check the peer connection is not closed
|
|
54
|
+
if(instances.find(this) == instances.end())
|
|
55
|
+
throw ThreadSafeCallback::CancelException();
|
|
56
|
+
|
|
57
|
+
cleanCbsAndEraseInstance();
|
|
58
|
+
|
|
59
|
+
// This will run in main thread and needs to construct the
|
|
60
|
+
// arguments for the call
|
|
61
|
+
args = {};
|
|
62
|
+
});
|
|
63
|
+
else {
|
|
64
|
+
cleanCbsAndEraseInstance();
|
|
65
|
+
} });
|
|
66
|
+
|
|
47
67
|
instances.insert(this);
|
|
48
68
|
}
|
|
49
69
|
|
|
@@ -54,20 +74,11 @@ DataChannelWrapper::~DataChannelWrapper()
|
|
|
54
74
|
|
|
55
75
|
void DataChannelWrapper::doClose()
|
|
56
76
|
{
|
|
57
|
-
instances.erase(this);
|
|
58
|
-
|
|
59
77
|
if (mDataChannelPtr)
|
|
60
78
|
{
|
|
61
79
|
try
|
|
62
80
|
{
|
|
63
|
-
mOnOpenCallback.reset();
|
|
64
|
-
mOnClosedCallback.reset();
|
|
65
|
-
mOnErrorCallback.reset();
|
|
66
|
-
mOnBufferedAmountLowCallback.reset();
|
|
67
|
-
mOnMessageCallback.reset();
|
|
68
|
-
|
|
69
81
|
mDataChannelPtr->close();
|
|
70
|
-
mDataChannelPtr.reset();
|
|
71
82
|
}
|
|
72
83
|
catch (std::exception &ex)
|
|
73
84
|
{
|
|
@@ -77,6 +88,18 @@ void DataChannelWrapper::doClose()
|
|
|
77
88
|
}
|
|
78
89
|
}
|
|
79
90
|
|
|
91
|
+
void DataChannelWrapper::cleanCbsAndEraseInstance()
|
|
92
|
+
{
|
|
93
|
+
mOnOpenCallback.reset();
|
|
94
|
+
mOnClosedCallback.reset();
|
|
95
|
+
mOnErrorCallback.reset();
|
|
96
|
+
mOnBufferedAmountLowCallback.reset();
|
|
97
|
+
mOnMessageCallback.reset();
|
|
98
|
+
|
|
99
|
+
instances.erase(this);
|
|
100
|
+
mDataChannelPtr.reset();
|
|
101
|
+
}
|
|
102
|
+
|
|
80
103
|
void DataChannelWrapper::close(const Napi::CallbackInfo &info)
|
|
81
104
|
{
|
|
82
105
|
doClose();
|
|
@@ -93,6 +116,28 @@ Napi::Value DataChannelWrapper::getLabel(const Napi::CallbackInfo &info)
|
|
|
93
116
|
return Napi::String::New(info.Env(), mDataChannelPtr->label());
|
|
94
117
|
}
|
|
95
118
|
|
|
119
|
+
Napi::Value DataChannelWrapper::getId(const Napi::CallbackInfo &info)
|
|
120
|
+
{
|
|
121
|
+
if (!mDataChannelPtr)
|
|
122
|
+
{
|
|
123
|
+
Napi::Error::New(info.Env(), "It seems data-channel is destroyed!").ThrowAsJavaScriptException();
|
|
124
|
+
return info.Env().Null();
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return Napi::Number::New(info.Env(), mDataChannelPtr->id());
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
Napi::Value DataChannelWrapper::getProtocol(const Napi::CallbackInfo &info)
|
|
131
|
+
{
|
|
132
|
+
if (!mDataChannelPtr)
|
|
133
|
+
{
|
|
134
|
+
Napi::Error::New(info.Env(), "It seems data-channel is destroyed!").ThrowAsJavaScriptException();
|
|
135
|
+
return info.Env().Null();
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return Napi::String::New(info.Env(), mDataChannelPtr->protocol());
|
|
139
|
+
}
|
|
140
|
+
|
|
96
141
|
Napi::Value DataChannelWrapper::sendMessage(const Napi::CallbackInfo &info)
|
|
97
142
|
{
|
|
98
143
|
if (!mDataChannelPtr)
|
|
@@ -278,18 +323,7 @@ void DataChannelWrapper::onClosed(const Napi::CallbackInfo &info)
|
|
|
278
323
|
// Callback
|
|
279
324
|
mOnClosedCallback = std::make_unique<ThreadSafeCallback>(info[0].As<Napi::Function>());
|
|
280
325
|
|
|
281
|
-
|
|
282
|
-
{
|
|
283
|
-
if (mOnClosedCallback)
|
|
284
|
-
mOnClosedCallback->call([this](Napi::Env env, std::vector<napi_value> &args) {
|
|
285
|
-
// Check the peer connection is not closed
|
|
286
|
-
if(instances.find(this) == instances.end())
|
|
287
|
-
throw ThreadSafeCallback::CancelException();
|
|
288
|
-
|
|
289
|
-
// This will run in main thread and needs to construct the
|
|
290
|
-
// arguments for the call
|
|
291
|
-
args = {};
|
|
292
|
-
}); });
|
|
326
|
+
// Object cb call moved to the constructor
|
|
293
327
|
}
|
|
294
328
|
|
|
295
329
|
void DataChannelWrapper::onError(const Napi::CallbackInfo &info)
|
|
@@ -23,6 +23,8 @@ public:
|
|
|
23
23
|
// Functions
|
|
24
24
|
void close(const Napi::CallbackInfo &info);
|
|
25
25
|
Napi::Value getLabel(const Napi::CallbackInfo &info);
|
|
26
|
+
Napi::Value getId(const Napi::CallbackInfo &info);
|
|
27
|
+
Napi::Value getProtocol(const Napi::CallbackInfo &info);
|
|
26
28
|
Napi::Value sendMessage(const Napi::CallbackInfo &info);
|
|
27
29
|
Napi::Value sendMessageBinary(const Napi::CallbackInfo &info);
|
|
28
30
|
Napi::Value isOpen(const Napi::CallbackInfo &info);
|
|
@@ -44,6 +46,7 @@ private:
|
|
|
44
46
|
static std::unordered_set<DataChannelWrapper*> instances;
|
|
45
47
|
|
|
46
48
|
void doClose();
|
|
49
|
+
void cleanCbsAndEraseInstance();
|
|
47
50
|
|
|
48
51
|
std::string mLabel;
|
|
49
52
|
std::shared_ptr<rtc::DataChannel> mDataChannelPtr = nullptr;
|
|
@@ -51,7 +51,7 @@ AudioWrapper::AudioWrapper(const Napi::CallbackInfo &info) : Napi::ObjectWrap<Au
|
|
|
51
51
|
rtc::Description::Direction dir = rtc::Description::Direction::SendOnly;
|
|
52
52
|
|
|
53
53
|
// optional
|
|
54
|
-
if (length >
|
|
54
|
+
if (length > 0)
|
|
55
55
|
{
|
|
56
56
|
if (!info[0].IsString())
|
|
57
57
|
{
|
|
@@ -62,7 +62,7 @@ AudioWrapper::AudioWrapper(const Napi::CallbackInfo &info) : Napi::ObjectWrap<Au
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
// ootional
|
|
65
|
-
if (length >
|
|
65
|
+
if (length > 1)
|
|
66
66
|
{
|
|
67
67
|
if (!info[1].IsString())
|
|
68
68
|
{
|
|
@@ -157,15 +157,15 @@ Napi::Value AudioWrapper::generateSdp(const Napi::CallbackInfo &info)
|
|
|
157
157
|
Napi::Env env = info.Env();
|
|
158
158
|
int length = info.Length();
|
|
159
159
|
|
|
160
|
-
if (length < 3 || !info[0].IsString() || !info[1].IsString() || !info[2].
|
|
160
|
+
if (length < 3 || !info[0].IsString() || !info[1].IsString() || !info[2].IsNumber())
|
|
161
161
|
{
|
|
162
|
-
Napi::TypeError::New(env, "We expect (String, String,
|
|
162
|
+
Napi::TypeError::New(env, "We expect (String, String, Number) as param").ThrowAsJavaScriptException();
|
|
163
163
|
return Napi::String::New(env, "");
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
std::string eol = info[0].As<Napi::String>().ToString();
|
|
167
167
|
std::string addr = info[1].As<Napi::String>().ToString();
|
|
168
|
-
|
|
168
|
+
uint16_t port = info[2].As<Napi::Number>().Uint32Value();
|
|
169
169
|
|
|
170
170
|
return Napi::String::New(env, mAudioPtr->generateSdp(eol, addr, port));
|
|
171
171
|
}
|
|
@@ -398,7 +398,7 @@ void AudioWrapper::setBitrate(const Napi::CallbackInfo &info)
|
|
|
398
398
|
Napi::Value AudioWrapper::getBitrate(const Napi::CallbackInfo &info)
|
|
399
399
|
{
|
|
400
400
|
|
|
401
|
-
return Napi::Number::New(info.Env(), mAudioPtr->
|
|
401
|
+
return Napi::Number::New(info.Env(), mAudioPtr->bitrate());
|
|
402
402
|
}
|
|
403
403
|
|
|
404
404
|
Napi::Value AudioWrapper::hasPayloadType(const Napi::CallbackInfo &info)
|
|
@@ -432,7 +432,7 @@ void AudioWrapper::addRTXCodec(const Napi::CallbackInfo &info)
|
|
|
432
432
|
unsigned int originalPayloadType = static_cast<unsigned int>(info[1].As<Napi::Number>().ToNumber());
|
|
433
433
|
unsigned int clockRate = static_cast<unsigned int>(info[2].As<Napi::Number>().ToNumber());
|
|
434
434
|
|
|
435
|
-
mAudioPtr->
|
|
435
|
+
mAudioPtr->addRtxCodec(payloadType, originalPayloadType, clockRate);
|
|
436
436
|
}
|
|
437
437
|
|
|
438
438
|
void AudioWrapper::addRTPMap(const Napi::CallbackInfo &info)
|