@lng2004/node-datachannel 0.32.3-20260813 → 0.32.3-20260815.1
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/CMakeLists.txt +25 -5
- package/package.json +7 -5
- package/prebuilds/linux/prebuilds-linux-arm-/node_datachannel-linux-arm/node-napi-v8.node +0 -0
- package/prebuilds/linux/prebuilds-linux-arm-musl/node_datachannel-linux-arm-musl/node-napi-v8.node +0 -0
- package/prebuilds/linux/prebuilds-linux-arm64-/node_datachannel-linux-arm64/node-napi-v8.node +0 -0
- package/prebuilds/linux/prebuilds-linux-arm64-musl/node_datachannel-linux-arm64-musl/node-napi-v8.node +0 -0
- package/prebuilds/linux/prebuilds-linux-x64-/node_datachannel-linux-x64/node-napi-v8.node +0 -0
- package/prebuilds/linux/prebuilds-linux-x64-musl/node_datachannel-linux-x64-musl/node-napi-v8.node +0 -0
- package/prebuilds/mac-arm64/prebuilds-mac-arm64/node_datachannel-darwin-arm64/node-napi-v8.node +0 -0
- package/prebuilds/mac-x64/prebuilds-mac-x64/node_datachannel-darwin-x64/node-napi-v8.node +0 -0
- package/prebuilds/win/prebuilds-win-arm64/node_datachannel-win32-arm64/node-napi-v8.node +0 -0
- package/prebuilds/win/prebuilds-win-x64/node_datachannel-win32-x64/node-napi-v8.node +0 -0
- package/scripts/build-mbedtls.js +28 -0
- package/scripts/build-mbedtls.ps1 +84 -0
- package/scripts/build-mbedtls.sh +50 -0
package/CMakeLists.txt
CHANGED
|
@@ -14,8 +14,7 @@ add_definitions(-DNAPI_VERSION=8)
|
|
|
14
14
|
include_directories(${CMAKE_JS_INC})
|
|
15
15
|
|
|
16
16
|
if(WIN32)
|
|
17
|
-
set(
|
|
18
|
-
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
|
17
|
+
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
|
|
19
18
|
endif()
|
|
20
19
|
|
|
21
20
|
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Android")
|
|
@@ -27,8 +26,30 @@ if (NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
|
|
27
26
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frtti")
|
|
28
27
|
endif()
|
|
29
28
|
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
option(USE_MBEDTLS "Use Mbed TLS instead of OpenSSL" ON)
|
|
30
|
+
option(USE_GNUTLS "Use GnuTLS instead of OpenSSL" OFF)
|
|
31
|
+
|
|
32
|
+
if(USE_MBEDTLS AND USE_GNUTLS)
|
|
33
|
+
message(FATAL_ERROR "Both USE_MBEDTLS and USE_GNUTLS cannot be enabled at the same time")
|
|
34
|
+
endif()
|
|
35
|
+
|
|
36
|
+
set(NDC_MBEDTLS_INSTALL_DIR "${CMAKE_SOURCE_DIR}/deps/mbedtls/install" CACHE PATH "Path to manually built MbedTLS install prefix")
|
|
37
|
+
|
|
38
|
+
if(DEFINED ENV{NDC_MBEDTLS_INSTALL_DIR} AND NOT "$ENV{NDC_MBEDTLS_INSTALL_DIR}" STREQUAL "")
|
|
39
|
+
set(NDC_MBEDTLS_INSTALL_DIR "$ENV{NDC_MBEDTLS_INSTALL_DIR}" CACHE PATH "Path to manually built MbedTLS install prefix" FORCE)
|
|
40
|
+
endif()
|
|
41
|
+
|
|
42
|
+
if(USE_MBEDTLS)
|
|
43
|
+
if(EXISTS "${NDC_MBEDTLS_INSTALL_DIR}")
|
|
44
|
+
list(PREPEND CMAKE_PREFIX_PATH "${NDC_MBEDTLS_INSTALL_DIR}")
|
|
45
|
+
else()
|
|
46
|
+
message(WARNING "MbedTLS install directory not found at ${NDC_MBEDTLS_INSTALL_DIR}. Run scripts/build-mbedtls.sh or scripts/build-mbedtls.ps1 first.")
|
|
47
|
+
endif()
|
|
48
|
+
endif()
|
|
49
|
+
|
|
50
|
+
# Forward crypto backend selection to libdatachannel.
|
|
51
|
+
set(USE_MBEDTLS ${USE_MBEDTLS} CACHE BOOL "Use Mbed TLS instead of OpenSSL" FORCE)
|
|
52
|
+
set(USE_GNUTLS ${USE_GNUTLS} CACHE BOOL "Use GnuTLS instead of OpenSSL" FORCE)
|
|
32
53
|
|
|
33
54
|
include(FetchContent)
|
|
34
55
|
|
|
@@ -124,7 +145,6 @@ elseif(UNIX)
|
|
|
124
145
|
endif()
|
|
125
146
|
|
|
126
147
|
if(WIN32)
|
|
127
|
-
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MT")
|
|
128
148
|
list(APPEND LINK_LIBRARIES crypt32.lib)
|
|
129
149
|
endif()
|
|
130
150
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lng2004/node-datachannel",
|
|
3
|
-
"version": "0.32.3-
|
|
3
|
+
"version": "0.32.3-20260815.1",
|
|
4
4
|
"description": "WebRTC For Node.js and Electron. libdatachannel node bindings.",
|
|
5
5
|
"main": "./dist/cjs/lib/index.cjs",
|
|
6
6
|
"module": "./dist/esm/lib/index.mjs",
|
|
@@ -34,13 +34,14 @@
|
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"install": "pkg-prebuilds-verify ./binding-options.js || (npm install --ignore-scripts --production=false && npm run compile)",
|
|
37
|
-
"rebuild": "pkg-prebuilds-verify ./binding-options.js || cmake-js rebuild",
|
|
38
|
-
"install:nice": "npm run clean && npm install --ignore-scripts --production=false && cmake-js configure --CDUSE_NICE=1 && cmake-js build",
|
|
37
|
+
"rebuild": "pkg-prebuilds-verify ./binding-options.js || (npm run build:mbedtls && cmake-js rebuild)",
|
|
38
|
+
"install:nice": "npm run clean && npm install --ignore-scripts --production=false && npm run build:mbedtls && cmake-js configure --CDUSE_NICE=1 && cmake-js build",
|
|
39
39
|
"install:gnu": "npm run clean && npm install --ignore-scripts --production=false && cmake-js configure --CDUSE_GNUTLS=1 && cmake-js build",
|
|
40
|
+
"build:mbedtls": "node ./scripts/build-mbedtls.js",
|
|
40
41
|
"build": "npm run compile && npm run build:tsc",
|
|
41
|
-
"compile": "cmake-js build",
|
|
42
|
+
"compile": "npm run build:mbedtls && cmake-js build",
|
|
42
43
|
"build:debug": "npm run compile:debug && npm run build:tsc",
|
|
43
|
-
"compile:debug": "cmake-js configure -D && cmake-js build -D",
|
|
44
|
+
"compile:debug": "npm run build:mbedtls && cmake-js configure -D && cmake-js build -D",
|
|
44
45
|
"build:tsc": "rimraf dist && rollup -c",
|
|
45
46
|
"build:tsc:watch": "rollup -c -w",
|
|
46
47
|
"clean": "rimraf dist build",
|
|
@@ -57,6 +58,7 @@
|
|
|
57
58
|
"files": [
|
|
58
59
|
"dist",
|
|
59
60
|
"prebuilds",
|
|
61
|
+
"scripts",
|
|
60
62
|
"binding-options.js",
|
|
61
63
|
"src/cpp",
|
|
62
64
|
"CMakeLists.txt",
|
|
Binary file
|
package/prebuilds/linux/prebuilds-linux-arm-musl/node_datachannel-linux-arm-musl/node-napi-v8.node
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/prebuilds/linux/prebuilds-linux-x64-musl/node_datachannel-linux-x64-musl/node-napi-v8.node
ADDED
|
Binary file
|
package/prebuilds/mac-arm64/prebuilds-mac-arm64/node_datachannel-darwin-arm64/node-napi-v8.node
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const { spawnSync } = require('node:child_process');
|
|
2
|
+
const path = require('node:path');
|
|
3
|
+
|
|
4
|
+
const rootDir = path.resolve(__dirname, '..');
|
|
5
|
+
const shellScript = path.join(rootDir, 'scripts', 'build-mbedtls.sh');
|
|
6
|
+
const psScript = path.join(rootDir, 'scripts', 'build-mbedtls.ps1');
|
|
7
|
+
|
|
8
|
+
function run(command, args) {
|
|
9
|
+
const result = spawnSync(command, args, {
|
|
10
|
+
cwd: rootDir,
|
|
11
|
+
env: process.env,
|
|
12
|
+
stdio: 'inherit',
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
if (result.error) {
|
|
16
|
+
throw result.error;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (typeof result.status === 'number' && result.status !== 0) {
|
|
20
|
+
process.exit(result.status);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (process.platform === 'win32') {
|
|
25
|
+
run('powershell', ['-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', psScript]);
|
|
26
|
+
} else {
|
|
27
|
+
run('sh', [shellScript]);
|
|
28
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
$ErrorActionPreference = "Stop"
|
|
2
|
+
|
|
3
|
+
$RootDir = Resolve-Path (Join-Path $PSScriptRoot "..")
|
|
4
|
+
$MbedTlsVersion = if ($env:MBEDTLS_VERSION) { $env:MBEDTLS_VERSION } else { "3.6.1" }
|
|
5
|
+
$MbedTlsTag = "v$MbedTlsVersion"
|
|
6
|
+
$MbedTlsRepo = "https://github.com/Mbed-TLS/mbedtls.git"
|
|
7
|
+
|
|
8
|
+
$MbedTlsRoot = Join-Path $RootDir "deps/mbedtls"
|
|
9
|
+
$MbedTlsSrc = Join-Path $MbedTlsRoot "src"
|
|
10
|
+
$MbedTlsBuild = Join-Path $MbedTlsRoot "build"
|
|
11
|
+
$MbedTlsInstall = if ($env:NDC_MBEDTLS_INSTALL_DIR) { $env:NDC_MBEDTLS_INSTALL_DIR } else { Join-Path $MbedTlsRoot "install" }
|
|
12
|
+
$MbedTlsConfig = Join-Path $MbedTlsSrc "include/mbedtls/mbedtls_config.h"
|
|
13
|
+
|
|
14
|
+
if (-not (Get-Command cmake -ErrorAction SilentlyContinue)) {
|
|
15
|
+
throw "cmake is required to build mbedtls"
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (-not (Get-Command git -ErrorAction SilentlyContinue)) {
|
|
19
|
+
throw "git is required to build mbedtls"
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
New-Item -ItemType Directory -Force -Path $MbedTlsRoot | Out-Null
|
|
23
|
+
|
|
24
|
+
if (-not (Test-Path (Join-Path $MbedTlsSrc ".git"))) {
|
|
25
|
+
if (Test-Path $MbedTlsSrc) {
|
|
26
|
+
Remove-Item -Recurse -Force $MbedTlsSrc
|
|
27
|
+
}
|
|
28
|
+
git clone --recursive --depth 1 --branch $MbedTlsTag $MbedTlsRepo $MbedTlsSrc
|
|
29
|
+
} else {
|
|
30
|
+
git -C $MbedTlsSrc fetch --depth 1 origin $MbedTlsTag
|
|
31
|
+
git -C $MbedTlsSrc checkout --force $MbedTlsTag
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (Test-Path $MbedTlsConfig) {
|
|
35
|
+
$configText = Get-Content -Path $MbedTlsConfig -Raw
|
|
36
|
+
$updated = $configText -replace '(?m)^//\s*#define MBEDTLS_SSL_DTLS_SRTP', '#define MBEDTLS_SSL_DTLS_SRTP'
|
|
37
|
+
if ($updated -ne $configText) {
|
|
38
|
+
Set-Content -Path $MbedTlsConfig -Value $updated -NoNewline
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (Test-Path $MbedTlsBuild) {
|
|
43
|
+
Remove-Item -Recurse -Force $MbedTlsBuild
|
|
44
|
+
}
|
|
45
|
+
if (Test-Path $MbedTlsInstall) {
|
|
46
|
+
Remove-Item -Recurse -Force $MbedTlsInstall
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
$cmakeArgs = @(
|
|
50
|
+
"-S", $MbedTlsSrc,
|
|
51
|
+
"-B", $MbedTlsBuild,
|
|
52
|
+
"-DCMAKE_BUILD_TYPE=Release",
|
|
53
|
+
"-DCMAKE_POSITION_INDEPENDENT_CODE=ON",
|
|
54
|
+
"-DENABLE_PROGRAMS=OFF",
|
|
55
|
+
"-DENABLE_TESTING=OFF",
|
|
56
|
+
"-DUSE_STATIC_MBEDTLS_LIBRARY=ON",
|
|
57
|
+
"-DUSE_SHARED_MBEDTLS_LIBRARY=OFF",
|
|
58
|
+
"-DCMAKE_INSTALL_PREFIX=$MbedTlsInstall"
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
$cmakePlatform = $null
|
|
62
|
+
if ($env:VSCMD_ARG_TGT_ARCH) {
|
|
63
|
+
switch ($env:VSCMD_ARG_TGT_ARCH.ToLowerInvariant()) {
|
|
64
|
+
"x86" { $cmakePlatform = "Win32" }
|
|
65
|
+
"x64" { $cmakePlatform = "x64" }
|
|
66
|
+
"arm" { $cmakePlatform = "ARM" }
|
|
67
|
+
"arm64" { $cmakePlatform = "ARM64" }
|
|
68
|
+
default { Write-Warning "Unknown VSCMD_ARG_TGT_ARCH '$($env:VSCMD_ARG_TGT_ARCH)'; not setting CMake platform." }
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if ($cmakePlatform) {
|
|
73
|
+
$cmakeArgs += "-A"
|
|
74
|
+
$cmakeArgs += $cmakePlatform
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if ($env:NDC_MBEDTLS_CMAKE_ARGS) {
|
|
78
|
+
$cmakeArgs += $env:NDC_MBEDTLS_CMAKE_ARGS.Split(' ', [System.StringSplitOptions]::RemoveEmptyEntries)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
& cmake @cmakeArgs
|
|
82
|
+
& cmake --build $MbedTlsBuild --config Release --target install --parallel
|
|
83
|
+
|
|
84
|
+
Write-Host "Built mbedtls $MbedTlsVersion into $MbedTlsInstall"
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#!/usr/bin/env sh
|
|
2
|
+
set -eu
|
|
3
|
+
|
|
4
|
+
ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
|
5
|
+
MBEDTLS_VERSION="${MBEDTLS_VERSION:-3.6.1}"
|
|
6
|
+
MBEDTLS_GIT_TAG="v${MBEDTLS_VERSION}"
|
|
7
|
+
MBEDTLS_REPO_URL="https://github.com/Mbed-TLS/mbedtls.git"
|
|
8
|
+
|
|
9
|
+
MBEDTLS_ROOT_DIR="${ROOT_DIR}/deps/mbedtls"
|
|
10
|
+
MBEDTLS_SRC_DIR="${MBEDTLS_ROOT_DIR}/src"
|
|
11
|
+
MBEDTLS_BUILD_DIR="${MBEDTLS_ROOT_DIR}/build"
|
|
12
|
+
MBEDTLS_INSTALL_DIR="${NDC_MBEDTLS_INSTALL_DIR:-${MBEDTLS_ROOT_DIR}/install}"
|
|
13
|
+
MBEDTLS_CONFIG_FILE="${MBEDTLS_SRC_DIR}/include/mbedtls/mbedtls_config.h"
|
|
14
|
+
|
|
15
|
+
if ! command -v cmake >/dev/null 2>&1; then
|
|
16
|
+
echo "cmake is required to build mbedtls" >&2
|
|
17
|
+
exit 1
|
|
18
|
+
fi
|
|
19
|
+
|
|
20
|
+
if ! command -v git >/dev/null 2>&1; then
|
|
21
|
+
echo "git is required to build mbedtls" >&2
|
|
22
|
+
exit 1
|
|
23
|
+
fi
|
|
24
|
+
|
|
25
|
+
mkdir -p "${MBEDTLS_ROOT_DIR}"
|
|
26
|
+
|
|
27
|
+
if [ ! -d "${MBEDTLS_SRC_DIR}/.git" ]; then
|
|
28
|
+
rm -rf "${MBEDTLS_SRC_DIR}"
|
|
29
|
+
git clone --recursive --depth 1 --branch "${MBEDTLS_GIT_TAG}" "${MBEDTLS_REPO_URL}" "${MBEDTLS_SRC_DIR}"
|
|
30
|
+
else
|
|
31
|
+
git -C "${MBEDTLS_SRC_DIR}" fetch --depth 1 origin "${MBEDTLS_GIT_TAG}"
|
|
32
|
+
git -C "${MBEDTLS_SRC_DIR}" checkout --force "${MBEDTLS_GIT_TAG}"
|
|
33
|
+
fi
|
|
34
|
+
|
|
35
|
+
if [ -f "${MBEDTLS_CONFIG_FILE}" ] && grep -q '^//[[:space:]]*#define MBEDTLS_SSL_DTLS_SRTP' "${MBEDTLS_CONFIG_FILE}"; then
|
|
36
|
+
sed -i.bak 's|^//[[:space:]]*#define MBEDTLS_SSL_DTLS_SRTP|#define MBEDTLS_SSL_DTLS_SRTP|' "${MBEDTLS_CONFIG_FILE}"
|
|
37
|
+
fi
|
|
38
|
+
|
|
39
|
+
rm -rf "${MBEDTLS_BUILD_DIR}" "${MBEDTLS_INSTALL_DIR}"
|
|
40
|
+
|
|
41
|
+
CMAKE_ARGS="-S ${MBEDTLS_SRC_DIR} -B ${MBEDTLS_BUILD_DIR} -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DENABLE_PROGRAMS=OFF -DENABLE_TESTING=OFF -DUSE_STATIC_MBEDTLS_LIBRARY=ON -DUSE_SHARED_MBEDTLS_LIBRARY=OFF -DCMAKE_INSTALL_PREFIX=${MBEDTLS_INSTALL_DIR}"
|
|
42
|
+
|
|
43
|
+
if [ -n "${NDC_MBEDTLS_CMAKE_ARGS:-}" ]; then
|
|
44
|
+
CMAKE_ARGS="${CMAKE_ARGS} ${NDC_MBEDTLS_CMAKE_ARGS}"
|
|
45
|
+
fi
|
|
46
|
+
|
|
47
|
+
cmake ${CMAKE_ARGS}
|
|
48
|
+
cmake --build "${MBEDTLS_BUILD_DIR}" --config Release --target install --parallel
|
|
49
|
+
|
|
50
|
+
echo "Built mbedtls ${MBEDTLS_VERSION} into ${MBEDTLS_INSTALL_DIR}"
|