node-datachannel 0.2.1 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/.github/workflows/build-linux.yml +2 -0
  2. package/.github/workflows/build-win.yml +1 -7
  3. package/CMakeLists.txt +2 -2
  4. package/README.md +18 -3
  5. package/lib/datachannel-stream.js +86 -0
  6. package/lib/index.d.ts +16 -2
  7. package/lib/index.js +3 -1
  8. package/node_modules/decompress-response/index.d.ts +14 -21
  9. package/node_modules/decompress-response/index.js +34 -16
  10. package/node_modules/decompress-response/license +1 -1
  11. package/node_modules/decompress-response/package.json +23 -17
  12. package/node_modules/decompress-response/readme.md +2 -6
  13. package/node_modules/detect-libc/README.md +124 -42
  14. package/node_modules/detect-libc/index.d.ts +11 -0
  15. package/node_modules/detect-libc/lib/detect-libc.js +166 -80
  16. package/node_modules/detect-libc/lib/process.js +16 -0
  17. package/node_modules/detect-libc/package.json +20 -20
  18. package/node_modules/{semver → lru-cache}/LICENSE +0 -0
  19. package/node_modules/lru-cache/README.md +166 -0
  20. package/node_modules/lru-cache/index.js +334 -0
  21. package/node_modules/lru-cache/node_modules/yallist/LICENSE +15 -0
  22. package/node_modules/lru-cache/node_modules/yallist/README.md +204 -0
  23. package/node_modules/lru-cache/node_modules/yallist/iterator.js +8 -0
  24. package/node_modules/lru-cache/node_modules/yallist/package.json +65 -0
  25. package/node_modules/lru-cache/node_modules/yallist/yallist.js +426 -0
  26. package/node_modules/lru-cache/package.json +74 -0
  27. package/node_modules/mimic-response/index.d.ts +2 -2
  28. package/node_modules/mimic-response/index.js +41 -2
  29. package/node_modules/mimic-response/package.json +17 -17
  30. package/node_modules/mimic-response/readme.md +22 -1
  31. package/node_modules/node-abi/.circleci/config.yml +63 -0
  32. package/node_modules/node-abi/.releaserc.json +9 -0
  33. package/node_modules/node-abi/abi_registry.json +45 -3
  34. package/node_modules/node-abi/index.js +5 -2
  35. package/node_modules/node-abi/node_modules/semver/CHANGELOG.md +111 -0
  36. package/node_modules/node-abi/node_modules/semver/LICENSE +15 -0
  37. package/node_modules/{semver → node-abi/node_modules/semver}/README.md +180 -26
  38. package/node_modules/node-abi/node_modules/semver/bin/semver.js +173 -0
  39. package/node_modules/node-abi/node_modules/semver/classes/comparator.js +135 -0
  40. package/node_modules/node-abi/node_modules/semver/classes/index.js +5 -0
  41. package/node_modules/node-abi/node_modules/semver/classes/range.js +510 -0
  42. package/node_modules/node-abi/node_modules/semver/classes/semver.js +287 -0
  43. package/node_modules/node-abi/node_modules/semver/functions/clean.js +6 -0
  44. package/node_modules/node-abi/node_modules/semver/functions/cmp.js +48 -0
  45. package/node_modules/node-abi/node_modules/semver/functions/coerce.js +51 -0
  46. package/node_modules/node-abi/node_modules/semver/functions/compare-build.js +7 -0
  47. package/node_modules/node-abi/node_modules/semver/functions/compare-loose.js +3 -0
  48. package/node_modules/node-abi/node_modules/semver/functions/compare.js +5 -0
  49. package/node_modules/node-abi/node_modules/semver/functions/diff.js +23 -0
  50. package/node_modules/node-abi/node_modules/semver/functions/eq.js +3 -0
  51. package/node_modules/node-abi/node_modules/semver/functions/gt.js +3 -0
  52. package/node_modules/node-abi/node_modules/semver/functions/gte.js +3 -0
  53. package/node_modules/node-abi/node_modules/semver/functions/inc.js +15 -0
  54. package/node_modules/node-abi/node_modules/semver/functions/lt.js +3 -0
  55. package/node_modules/node-abi/node_modules/semver/functions/lte.js +3 -0
  56. package/node_modules/node-abi/node_modules/semver/functions/major.js +3 -0
  57. package/node_modules/node-abi/node_modules/semver/functions/minor.js +3 -0
  58. package/node_modules/node-abi/node_modules/semver/functions/neq.js +3 -0
  59. package/node_modules/node-abi/node_modules/semver/functions/parse.js +33 -0
  60. package/node_modules/node-abi/node_modules/semver/functions/patch.js +3 -0
  61. package/node_modules/node-abi/node_modules/semver/functions/prerelease.js +6 -0
  62. package/node_modules/node-abi/node_modules/semver/functions/rcompare.js +3 -0
  63. package/node_modules/node-abi/node_modules/semver/functions/rsort.js +3 -0
  64. package/node_modules/node-abi/node_modules/semver/functions/satisfies.js +10 -0
  65. package/node_modules/node-abi/node_modules/semver/functions/sort.js +3 -0
  66. package/node_modules/node-abi/node_modules/semver/functions/valid.js +6 -0
  67. package/node_modules/node-abi/node_modules/semver/index.js +48 -0
  68. package/node_modules/node-abi/node_modules/semver/internal/constants.js +17 -0
  69. package/node_modules/node-abi/node_modules/semver/internal/debug.js +9 -0
  70. package/node_modules/node-abi/node_modules/semver/internal/identifiers.js +23 -0
  71. package/node_modules/node-abi/node_modules/semver/internal/parse-options.js +11 -0
  72. package/node_modules/node-abi/node_modules/semver/internal/re.js +182 -0
  73. package/node_modules/{semver → node-abi/node_modules/semver}/package.json +32 -23
  74. package/node_modules/node-abi/node_modules/semver/preload.js +2 -0
  75. package/node_modules/{semver → node-abi/node_modules/semver}/range.bnf +0 -0
  76. package/node_modules/node-abi/node_modules/semver/ranges/gtr.js +4 -0
  77. package/node_modules/node-abi/node_modules/semver/ranges/intersects.js +7 -0
  78. package/node_modules/node-abi/node_modules/semver/ranges/ltr.js +4 -0
  79. package/node_modules/node-abi/node_modules/semver/ranges/max-satisfying.js +25 -0
  80. package/node_modules/node-abi/node_modules/semver/ranges/min-satisfying.js +24 -0
  81. package/node_modules/node-abi/node_modules/semver/ranges/min-version.js +60 -0
  82. package/node_modules/node-abi/node_modules/semver/ranges/outside.js +80 -0
  83. package/node_modules/node-abi/node_modules/semver/ranges/simplify.js +44 -0
  84. package/node_modules/node-abi/node_modules/semver/ranges/subset.js +222 -0
  85. package/node_modules/node-abi/node_modules/semver/ranges/to-comparators.js +8 -0
  86. package/node_modules/node-abi/node_modules/semver/ranges/valid.js +11 -0
  87. package/node_modules/node-abi/package.json +20 -17
  88. package/node_modules/node-abi/test/index.js +7 -15
  89. package/node_modules/prebuild-install/CHANGELOG.md +24 -7
  90. package/node_modules/prebuild-install/README.md +24 -4
  91. package/node_modules/prebuild-install/asset.js +10 -10
  92. package/node_modules/prebuild-install/bin.js +13 -13
  93. package/node_modules/prebuild-install/download.js +22 -22
  94. package/node_modules/prebuild-install/log.js +4 -4
  95. package/node_modules/prebuild-install/package.json +18 -19
  96. package/node_modules/prebuild-install/proxy.js +10 -10
  97. package/node_modules/prebuild-install/rc.js +12 -12
  98. package/node_modules/prebuild-install/util.js +14 -14
  99. package/node_modules/simple-get/.github/dependabot.yml +15 -0
  100. package/node_modules/simple-get/.github/workflows/ci.yml +23 -0
  101. package/node_modules/simple-get/README.md +17 -3
  102. package/node_modules/simple-get/index.js +9 -0
  103. package/node_modules/simple-get/package.json +27 -13
  104. package/package.json +6 -5
  105. package/src/media-audio-wrapper.cpp +2 -2
  106. package/src/peer-connection-wrapper.cpp +63 -10
  107. package/src/peer-connection-wrapper.h +7 -2
  108. package/test/test.js +45 -0
  109. package/node_modules/detect-libc/.npmignore +0 -7
  110. package/node_modules/detect-libc/bin/detect-libc.js +0 -18
  111. package/node_modules/node-abi/.travis.yml +0 -17
  112. package/node_modules/semver/CHANGELOG.md +0 -39
  113. package/node_modules/semver/bin/semver +0 -160
  114. package/node_modules/semver/semver.js +0 -1483
@@ -1,31 +1,31 @@
1
1
  {
2
2
  "_args": [
3
3
  [
4
- "prebuild-install@6.1.4",
4
+ "prebuild-install@7.0.1",
5
5
  "/home/runner/work/node-datachannel/node-datachannel"
6
6
  ]
7
7
  ],
8
- "_from": "prebuild-install@6.1.4",
9
- "_id": "prebuild-install@6.1.4",
8
+ "_from": "prebuild-install@7.0.1",
9
+ "_id": "prebuild-install@7.0.1",
10
10
  "_inBundle": false,
11
- "_integrity": "sha512-Z4vpywnK1lBg+zdPCVCsKq0xO66eEV9rWo2zrROGGiRS4JtueBOdlB1FnY8lcy7JsUud/Q3ijUxyWN26Ika0vQ==",
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@6.1.4",
17
+ "raw": "prebuild-install@7.0.1",
18
18
  "name": "prebuild-install",
19
19
  "escapedName": "prebuild-install",
20
- "rawSpec": "6.1.4",
20
+ "rawSpec": "7.0.1",
21
21
  "saveSpec": null,
22
- "fetchSpec": "6.1.4"
22
+ "fetchSpec": "7.0.1"
23
23
  },
24
24
  "_requiredBy": [
25
25
  "/"
26
26
  ],
27
- "_resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-6.1.4.tgz",
28
- "_spec": "6.1.4",
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": "^1.0.3",
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": "^2.21.0",
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": "^3.0.3",
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": "^3.0.0",
95
+ "hallmark": "^4.0.0",
96
96
  "nock": "^10.0.6",
97
97
  "rimraf": "^2.5.2",
98
- "standard": "^13.0.2",
99
- "tape": "^4.5.1",
98
+ "standard": "^16.0.4",
99
+ "tape": "^5.3.1",
100
100
  "tempy": "0.2.1"
101
101
  },
102
102
  "engines": {
103
- "node": ">=6"
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
- "lint": "standard && hallmark",
127
- "test": "tape test/*-test.js && npm run lint"
126
+ "test": "standard && hallmark && tape test/*-test.js"
128
127
  },
129
- "version": "6.1.4"
128
+ "version": "7.0.1"
130
129
  }
@@ -1,20 +1,20 @@
1
- var url = require('url')
2
- var tunnel = require('tunnel-agent')
3
- var util = require('./util')
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
- var log = opts.log || util.noopLogger
6
+ const log = opts.log || util.noopLogger
7
7
 
8
- var proxy = opts['https-proxy'] || opts.proxy
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
- var parsedDownloadUrl = url.parse(reqOpts.url)
12
+ const parsedDownloadUrl = url.parse(reqOpts.url)
13
13
  // eslint-disable-next-line node/no-deprecated-api
14
- var parsedProxy = url.parse(proxy)
15
- var uriProtocol = (parsedDownloadUrl.protocol === 'https:' ? 'https' : 'http')
16
- var proxyProtocol = (parsedProxy.protocol === 'https:' ? 'Https' : 'Http')
17
- var tunnelFnName = [uriProtocol, proxyProtocol].join('Over')
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
- var path = require('path')
2
- var minimist = require('minimist')
3
- var getAbi = require('node-abi').getAbi
4
- var detectLibc = require('detect-libc')
5
- var napi = require('napi-build-utils')
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
- var env = process.env
8
- var libc = env.LIBC || (detectLibc.isNonGlibcLinux && detectLibc.family) || ''
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
- var pkgConf = pkg.config || {}
13
- var buildFromSource = env.npm_config_build_from_source
12
+ const pkgConf = pkg.config || {}
13
+ const buildFromSource = env.npm_config_build_from_source
14
14
 
15
- var rc = require('rc')('prebuild-install', {
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['http_proxy'] || env['HTTP_PROXY'],
27
- 'https-proxy': env.npm_config_https_proxy || env['https_proxy'] || env['HTTPS_PROXY'],
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
- var path = require('path')
2
- var github = require('github-from-package')
3
- var home = require('os').homedir
4
- var crypto = require('crypto')
5
- var expandTemplate = require('expand-template')()
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
- var pkgName = opts.pkg.name.replace(/^@[a-zA-Z0-9_\-.~]+\//, '')
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
- var packageName = '{name}-v{version}-{runtime}-v{abi}-{platform}{libc}-{arch}.tar.gz'
44
- var hostMirrorUrl = getHostMirrorUrl(opts)
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
- var propName = getEnvPrefix(opts.pkg.name) + '_binary_host'
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
- var digest = crypto.createHash('md5').update(url).digest('hex').slice(0, 6)
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
- var env = process.env
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
- var propName = getEnvPrefix(opts.pkg.name) + '_local_prebuilds'
114
- var prefix = process.env[propName] || opts['local-prebuilds'] || 'prebuilds'
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
- var noopLogger = {
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 [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url]
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
- [travis-image]: https://img.shields.io/travis/feross/simple-get/master.svg
4
- [travis-url]: https://travis-ci.org/feross/simple-get
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@3.1.0",
4
+ "simple-get@4.0.1",
5
5
  "/home/runner/work/node-datachannel/node-datachannel"
6
6
  ]
7
7
  ],
8
- "_from": "simple-get@3.1.0",
9
- "_id": "simple-get@3.1.0",
8
+ "_from": "simple-get@4.0.1",
9
+ "_id": "simple-get@4.0.1",
10
10
  "_inBundle": false,
11
- "_integrity": "sha512-bCR6cP+aTdScaQCnQKbPKtJOKDp/hj9EDLJo3Nw4y1QksqaovlW/bnptB6/c1e+qmNIDHRK+oXFDdEqBT8WzUA==",
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@3.1.0",
17
+ "raw": "simple-get@4.0.1",
18
18
  "name": "simple-get",
19
19
  "escapedName": "simple-get",
20
- "rawSpec": "3.1.0",
20
+ "rawSpec": "4.0.1",
21
21
  "saveSpec": null,
22
- "fetchSpec": "3.1.0"
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-3.1.0.tgz",
28
- "_spec": "3.1.0",
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": "http://feross.org/"
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": "^4.2.0",
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": "^4.0.0"
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": "3.1.0"
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.2.1",
3
+ "version": "0.2.4",
4
4
  "description": "libdatachannel node bindings",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -46,17 +46,18 @@
46
46
  },
47
47
  "homepage": "https://github.com/murat-dogan/node-datachannel#readme",
48
48
  "devDependencies": {
49
- "cmake-js": "^6.2.1",
50
- "jest": "^27.2.5",
49
+ "cmake-js": "^6.3.0",
50
+ "jest": "^27.5.1",
51
51
  "nan": "^2.15.0",
52
52
  "napi-thread-safe-callback-cancellable": "^0.0.7",
53
53
  "node-addon-api": "^4.2.0",
54
- "prebuild": "^11.0.0"
54
+ "prebuild": "^11.0.3"
55
55
  },
56
56
  "bundledDependencies": [
57
57
  "prebuild-install"
58
58
  ],
59
59
  "dependencies": {
60
- "prebuild-install": "^6.1.4"
60
+ "@types/node": "^17.0.21",
61
+ "prebuild-install": "^7.0.1"
61
62
  }
62
63
  }
@@ -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 > 1)
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 > 2)
65
+ if (length > 1)
66
66
  {
67
67
  if (!info[1].IsString())
68
68
  {
@@ -32,9 +32,13 @@ Napi::Object PeerConnectionWrapper::Init(Napi::Env env, Napi::Object exports)
32
32
  InstanceMethod("createDataChannel", &PeerConnectionWrapper::createDataChannel),
33
33
  InstanceMethod("addTrack", &PeerConnectionWrapper::addTrack),
34
34
  InstanceMethod("hasMedia", &PeerConnectionWrapper::hasMedia),
35
+ InstanceMethod("state", &PeerConnectionWrapper::state),
36
+ InstanceMethod("signalingState", &PeerConnectionWrapper::signalingState),
37
+ InstanceMethod("gatheringState", &PeerConnectionWrapper::gatheringState),
35
38
  InstanceMethod("onLocalDescription", &PeerConnectionWrapper::onLocalDescription),
36
39
  InstanceMethod("onLocalCandidate", &PeerConnectionWrapper::onLocalCandidate),
37
40
  InstanceMethod("onStateChange", &PeerConnectionWrapper::onStateChange),
41
+ InstanceMethod("onSignalingStateChange", &PeerConnectionWrapper::onSignalingStateChange),
38
42
  InstanceMethod("onGatheringStateChange", &PeerConnectionWrapper::onGatheringStateChange),
39
43
  InstanceMethod("onDataChannel", &PeerConnectionWrapper::onDataChannel),
40
44
  InstanceMethod("onTrack", &PeerConnectionWrapper::onTrack),
@@ -536,8 +540,7 @@ void PeerConnectionWrapper::onLocalDescription(const Napi::CallbackInfo &info)
536
540
  // Callback
537
541
  mOnLocalDescriptionCallback = std::make_unique<ThreadSafeCallback>(info[0].As<Napi::Function>());
538
542
 
539
- mRtcPeerConnPtr->onLocalDescription([&](const rtc::Description &sdp)
540
- {
543
+ mRtcPeerConnPtr->onLocalDescription([&](const rtc::Description &sdp) {
541
544
  if (mOnLocalDescriptionCallback)
542
545
  mOnLocalDescriptionCallback->call([this, sdp](Napi::Env env, std::vector<napi_value> &args) {
543
546
  // Check the peer connection is not closed
@@ -566,8 +569,7 @@ void PeerConnectionWrapper::onLocalCandidate(const Napi::CallbackInfo &info)
566
569
  // Callback
567
570
  mOnLocalCandidateCallback = std::make_unique<ThreadSafeCallback>(info[0].As<Napi::Function>());
568
571
 
569
- mRtcPeerConnPtr->onLocalCandidate([&](const rtc::Candidate &candidate)
570
- {
572
+ mRtcPeerConnPtr->onLocalCandidate([&](const rtc::Candidate &candidate) {
571
573
  if (mOnLocalCandidateCallback)
572
574
  mOnLocalCandidateCallback->call([this, candidate](Napi::Env env, std::vector<napi_value> &args) {
573
575
  // Check the peer connection is not closed
@@ -596,8 +598,7 @@ void PeerConnectionWrapper::onStateChange(const Napi::CallbackInfo &info)
596
598
  // Callback
597
599
  mOnStateChangeCallback = std::make_unique<ThreadSafeCallback>(info[0].As<Napi::Function>());
598
600
 
599
- mRtcPeerConnPtr->onStateChange([&](rtc::PeerConnection::State state)
600
- {
601
+ mRtcPeerConnPtr->onStateChange([&](rtc::PeerConnection::State state) {
601
602
  if (mOnStateChangeCallback)
602
603
  mOnStateChangeCallback->call([this, state](Napi::Env env, std::vector<napi_value> &args) {
603
604
  // Check the peer connection is not closed
@@ -612,6 +613,35 @@ void PeerConnectionWrapper::onStateChange(const Napi::CallbackInfo &info)
612
613
  }); });
613
614
  }
614
615
 
616
+ void PeerConnectionWrapper::onSignalingStateChange(const Napi::CallbackInfo &info)
617
+ {
618
+ Napi::Env env = info.Env();
619
+ int length = info.Length();
620
+
621
+ if (length < 1 || !info[0].IsFunction())
622
+ {
623
+ Napi::TypeError::New(env, "Function expected").ThrowAsJavaScriptException();
624
+ return;
625
+ }
626
+
627
+ // Callback
628
+ mOnSignalingStateChangeCallback = std::make_unique<ThreadSafeCallback>(info[0].As<Napi::Function>());
629
+
630
+ mRtcPeerConnPtr->onSignalingStateChange([&](rtc::PeerConnection::SignalingState state) {
631
+ if (mOnSignalingStateChangeCallback)
632
+ mOnSignalingStateChangeCallback->call([this, state](Napi::Env env, std::vector<napi_value> &args) {
633
+ // Check the peer connection is not closed
634
+ if(instances.find(this) == instances.end())
635
+ throw ThreadSafeCallback::CancelException();
636
+
637
+ // This will run in main thread and needs to construct the
638
+ // arguments for the call
639
+ std::ostringstream stream;
640
+ stream << state;
641
+ args = {Napi::String::New(env, stream.str())};
642
+ }); });
643
+ }
644
+
615
645
  void PeerConnectionWrapper::onGatheringStateChange(const Napi::CallbackInfo &info)
616
646
  {
617
647
  Napi::Env env = info.Env();
@@ -626,8 +656,7 @@ void PeerConnectionWrapper::onGatheringStateChange(const Napi::CallbackInfo &inf
626
656
  // Callback
627
657
  mOnGatheringStateChangeCallback = std::make_unique<ThreadSafeCallback>(info[0].As<Napi::Function>());
628
658
 
629
- mRtcPeerConnPtr->onGatheringStateChange([&](rtc::PeerConnection::GatheringState state)
630
- {
659
+ mRtcPeerConnPtr->onGatheringStateChange([&](rtc::PeerConnection::GatheringState state) {
631
660
  if (mOnGatheringStateChangeCallback)
632
661
  mOnGatheringStateChangeCallback->call([this, state](Napi::Env env, std::vector<napi_value> &args) {
633
662
  // Check the peer connection is not closed
@@ -841,7 +870,7 @@ Napi::Value PeerConnectionWrapper::addTrack(const Napi::CallbackInfo &info)
841
870
  return instance;
842
871
  }
843
872
 
844
- Napi::Error::New(env, std::string("Unknown media type")).ThrowAsJavaScriptException();
873
+ Napi::Error::New(env, std::string("Unknown media type")).ThrowAsJavaScriptException();
845
874
  return env.Null();
846
875
  }
847
876
  catch (std::exception &ex)
@@ -885,4 +914,28 @@ Napi::Value PeerConnectionWrapper::hasMedia(const Napi::CallbackInfo &info)
885
914
  {
886
915
  Napi::Env env = info.Env();
887
916
  return Napi::Boolean::New(env, mRtcPeerConnPtr->hasMedia());
888
- }
917
+ }
918
+
919
+ Napi::Value PeerConnectionWrapper::state(const Napi::CallbackInfo &info)
920
+ {
921
+ Napi::Env env = info.Env();
922
+ std::ostringstream stream;
923
+ stream << mRtcPeerConnPtr->state();
924
+ return Napi::String::New(env, stream.str());
925
+ }
926
+
927
+ Napi::Value PeerConnectionWrapper::signalingState(const Napi::CallbackInfo &info)
928
+ {
929
+ Napi::Env env = info.Env();
930
+ std::ostringstream stream;
931
+ stream << mRtcPeerConnPtr->signalingState();
932
+ return Napi::String::New(env, stream.str());
933
+ }
934
+
935
+ Napi::Value PeerConnectionWrapper::gatheringState(const Napi::CallbackInfo &info)
936
+ {
937
+ Napi::Env env = info.Env();
938
+ std::ostringstream stream;
939
+ stream << mRtcPeerConnPtr->gatheringState();
940
+ return Napi::String::New(env, stream.str());
941
+ }
@@ -26,13 +26,17 @@ public:
26
26
  Napi::Value localDescription(const Napi::CallbackInfo &info);
27
27
  void addRemoteCandidate(const Napi::CallbackInfo &info);
28
28
  Napi::Value createDataChannel(const Napi::CallbackInfo &info);
29
- Napi::Value addTrack(const Napi::CallbackInfo &info);
30
- Napi::Value hasMedia(const Napi::CallbackInfo &info);
29
+ Napi::Value addTrack(const Napi::CallbackInfo &info);
30
+ Napi::Value hasMedia(const Napi::CallbackInfo &info);
31
+ Napi::Value state(const Napi::CallbackInfo &info);
32
+ Napi::Value signalingState(const Napi::CallbackInfo &info);
33
+ Napi::Value gatheringState(const Napi::CallbackInfo &info);
31
34
 
32
35
  // Callbacks
33
36
  void onLocalDescription(const Napi::CallbackInfo &info);
34
37
  void onLocalCandidate(const Napi::CallbackInfo &info);
35
38
  void onStateChange(const Napi::CallbackInfo &info);
39
+ void onSignalingStateChange(const Napi::CallbackInfo &info);
36
40
  void onGatheringStateChange(const Napi::CallbackInfo &info);
37
41
  void onDataChannel(const Napi::CallbackInfo &info);
38
42
  void onTrack(const Napi::CallbackInfo &info);
@@ -59,6 +63,7 @@ private:
59
63
  std::unique_ptr<ThreadSafeCallback> mOnLocalDescriptionCallback = nullptr;
60
64
  std::unique_ptr<ThreadSafeCallback> mOnLocalCandidateCallback = nullptr;
61
65
  std::unique_ptr<ThreadSafeCallback> mOnStateChangeCallback = nullptr;
66
+ std::unique_ptr<ThreadSafeCallback> mOnSignalingStateChangeCallback = nullptr;
62
67
  std::unique_ptr<ThreadSafeCallback> mOnGatheringStateChangeCallback = nullptr;
63
68
  std::unique_ptr<ThreadSafeCallback> mOnDataChannelCallback = nullptr;
64
69
  std::unique_ptr<ThreadSafeCallback> mOnTrackCallback = nullptr;