Comparing version 1.15.22 to 1.16.0
@@ -80,3 +80,6 @@ cmake_minimum_required(VERSION 3.1) | ||
include(AwsSanitizers) | ||
include(AwsCRuntime) | ||
aws_determine_local_c_runtime(AWS_C_RUNTIME) | ||
file(GLOB AWS_CRT_SRC | ||
@@ -107,5 +110,4 @@ "source/*.c" | ||
set(destination bin/${CMAKE_JS_PLATFORM}-${NODE_ARCH}) | ||
set(destination bin/${CMAKE_JS_PLATFORM}-${NODE_ARCH}-${AWS_C_RUNTIME}) | ||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/aws-crt-nodejs.node" | ||
DESTINATION ${destination}) |
@@ -512,1 +512,8 @@ /* | ||
) : void; | ||
export const cRuntime: string; | ||
export const CRuntimeType: { | ||
NON_LINUX: string, | ||
MUSL: string, | ||
GLIBC: string | ||
}; |
@@ -29,3 +29,7 @@ "use strict"; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.cRuntime = exports.CRuntimeType = void 0; | ||
const path = __importStar(require("path")); | ||
@@ -35,2 +39,29 @@ const os_1 = require("os"); | ||
const process_1 = require("process"); | ||
const child_process_1 = __importDefault(require("child_process")); | ||
const CRuntimeType = Object.freeze({ | ||
NON_LINUX: "cruntime", | ||
MUSL: "musl", | ||
GLIBC: "glibc" | ||
}); | ||
exports.CRuntimeType = CRuntimeType; | ||
function getCRuntime() { | ||
if ((0, os_1.platform)() !== "linux") { | ||
return CRuntimeType.NON_LINUX; | ||
} | ||
try { | ||
// sometimes, ldd's output goes to stderr, so capture that too | ||
// Using spawnSync because execSync treats any output to stderr as an exception. | ||
const spawnedProcess = child_process_1.default.spawnSync('ldd', ['--version'], { encoding: 'utf8' }); | ||
const output = spawnedProcess.stdout + spawnedProcess.stderr; | ||
if (output.includes(CRuntimeType.MUSL)) { | ||
return CRuntimeType.MUSL; | ||
} | ||
else { | ||
return CRuntimeType.GLIBC; | ||
} | ||
} | ||
catch (error) { | ||
return CRuntimeType.GLIBC; | ||
} | ||
} | ||
const upgrade_string = "Please upgrade to node >=10.16.0, or use the provided browser implementation."; | ||
@@ -47,4 +78,6 @@ if ('napi' in process_1.versions) { | ||
} | ||
const cRuntime = getCRuntime(); | ||
exports.cRuntime = cRuntime; | ||
const binary_name = 'aws-crt-nodejs'; | ||
const platformDir = `${os_1.platform}-${os_1.arch}`; | ||
const platformDir = `${os_1.platform}-${os_1.arch}-${cRuntime}`; | ||
let source_root = path.resolve(__dirname, '..', '..'); | ||
@@ -51,0 +84,0 @@ const dist = path.join(source_root, 'dist'); |
@@ -13,2 +13,3 @@ /* | ||
import * as io from "./io"; | ||
import {CRuntimeType, cRuntime} from "./binding" | ||
@@ -223,3 +224,8 @@ jest.setTimeout(10000); | ||
test_env.conditional_test(test_env.AWS_IOT_ENV.mqtt5_is_valid_pkcs11())('Aws Iot Core PKCS11 - Connection Success', async () => { | ||
/** | ||
* Skip test if cruntime is Musl. Softhsm library crashes on Alpine if we don't use AWS_PKCS11_LIB_STRICT_INITIALIZE_FINALIZE. | ||
* Supporting AWS_PKCS11_LIB_STRICT_INITIALIZE_FINALIZE on Node-js is not trivial due to non-deterministic cleanup. | ||
* TODO: Support AWS_PKCS11_LIB_STRICT_INITIALIZE_FINALIZE | ||
*/ | ||
test_env.conditional_test(cRuntime !== CRuntimeType.MUSL && test_env.AWS_IOT_ENV.mqtt5_is_valid_pkcs11())('Aws Iot Core PKCS11 - Connection Success', async () => { | ||
const pkcs11_lib = new io.Pkcs11Lib(test_env.AWS_IOT_ENV.MQTT5_PKCS11_LIB_PATH); | ||
@@ -226,0 +232,0 @@ let builder = iot.AwsIotMqtt5ClientConfigBuilder.newDirectMqttBuilderWithMtlsFromPkcs11( |
@@ -13,2 +13,3 @@ /* | ||
import {once} from "events"; | ||
import {cRuntime, CRuntimeType} from "./binding" | ||
@@ -53,3 +54,9 @@ test_env.conditional_test(test_env.AWS_IOT_ENV.mqtt311_is_valid_custom_auth_unsigned())('Aws Iot Core Mqtt over websockets with Non-Signing Custom Auth - Connection Success', async () => { | ||
test_env.conditional_test(test_env.AWS_IOT_ENV.mqtt311_is_valid_pkcs11())('Aws Iot Core PKCS11 connection', async () => { | ||
/** | ||
* Skip test if cruntime is Musl. Softhsm library crashes on Alpine if we don't use AWS_PKCS11_LIB_STRICT_INITIALIZE_FINALIZE. | ||
* Supporting AWS_PKCS11_LIB_STRICT_INITIALIZE_FINALIZE on Node-js is not trivial due to non-deterministic cleanup. | ||
* TODO: Support AWS_PKCS11_LIB_STRICT_INITIALIZE_FINALIZE | ||
*/ | ||
test_env.conditional_test(cRuntime !== CRuntimeType.MUSL && test_env.AWS_IOT_ENV.mqtt311_is_valid_pkcs11())('Aws Iot Core PKCS11 connection', async () => { | ||
const pkcs11_lib = new io.Pkcs11Lib(test_env.AWS_IOT_ENV.MQTT311_PKCS11_LIB_PATH); | ||
@@ -56,0 +63,0 @@ const builder = aws_iot_mqtt311.AwsIotMqttConnectionConfigBuilder.new_mtls_pkcs11_builder({ |
@@ -512,1 +512,8 @@ /* | ||
) : void; | ||
export const cRuntime: string; | ||
export const CRuntimeType: { | ||
NON_LINUX: string, | ||
MUSL: string, | ||
GLIBC: string | ||
}; |
@@ -10,3 +10,31 @@ /* | ||
import { versions } from 'process'; | ||
import child_process from "child_process"; | ||
const CRuntimeType = Object.freeze({ | ||
NON_LINUX: "cruntime", | ||
MUSL: "musl", | ||
GLIBC: "glibc" | ||
}); | ||
function getCRuntime() { | ||
if(platform() !== "linux") { | ||
return CRuntimeType.NON_LINUX; | ||
} | ||
try { | ||
// sometimes, ldd's output goes to stderr, so capture that too | ||
// Using spawnSync because execSync treats any output to stderr as an exception. | ||
const spawnedProcess = child_process.spawnSync('ldd', ['--version'], { encoding: 'utf8' }); | ||
const output = spawnedProcess.stdout + spawnedProcess.stderr; | ||
if (output.includes(CRuntimeType.MUSL)) { | ||
return CRuntimeType.MUSL; | ||
} else { | ||
return CRuntimeType.GLIBC; | ||
} | ||
} catch (error) { | ||
return CRuntimeType.GLIBC; | ||
} | ||
} | ||
const upgrade_string = "Please upgrade to node >=10.16.0, or use the provided browser implementation."; | ||
@@ -22,5 +50,5 @@ if ('napi' in versions) { | ||
} | ||
const cRuntime = getCRuntime() | ||
const binary_name = 'aws-crt-nodejs'; | ||
const platformDir = `${platform}-${arch}`; | ||
const platformDir = `${platform}-${arch}-${cRuntime}`; | ||
@@ -52,1 +80,2 @@ let source_root = path.resolve(__dirname, '..', '..'); | ||
export default binding; | ||
export { CRuntimeType , cRuntime }; |
@@ -9,3 +9,3 @@ /* | ||
import {once} from "events"; | ||
import crt_native from "./binding"; | ||
import crt_native, {cRuntime, CRuntimeType} from "./binding"; | ||
import * as os from "os"; | ||
@@ -318,5 +318,8 @@ | ||
conditional_test(hasEchoServerEnvironment())('Eventstream protocol connection failure Echo Server - bad version', async () => { | ||
/* | ||
* Skip this test on Musl as it is very flaky | ||
* TODO: Figure out why it is flaky on Musl and fix it. | ||
*/ | ||
conditional_test(cRuntime !== CRuntimeType.MUSL && hasEchoServerEnvironment())('Eventstream protocol connection failure Echo Server - bad version', async () => { | ||
let connection : eventstream.ClientConnection = new eventstream.ClientConnection(makeGoodConfig()); | ||
await connection.connect({}); | ||
@@ -365,3 +368,2 @@ | ||
await disconnected; | ||
connection.close(); | ||
@@ -368,0 +370,0 @@ }); |
@@ -9,2 +9,3 @@ /* | ||
import { CrtError } from './error'; | ||
import {cRuntime, CRuntimeType} from "./binding"; | ||
@@ -25,3 +26,8 @@ const conditional_test = (condition: any) => condition ? it : it.skip; | ||
const PKCS11_LIB_PATH = process.env.AWS_TEST_PKCS11_LIB ?? ""; | ||
const pkcs11_test = conditional_test(PKCS11_LIB_PATH) | ||
/** | ||
* Skip test if cruntime is Musl. Softhsm library crashes on Alpine if we don't use AWS_PKCS11_LIB_STRICT_INITIALIZE_FINALIZE. | ||
* Supporting AWS_PKCS11_LIB_STRICT_INITIALIZE_FINALIZE on Node-js is not trivial due to non-deterministic cleanup. | ||
* TODO: Support AWS_PKCS11_LIB_STRICT_INITIALIZE_FINALIZE in tests | ||
*/ | ||
const pkcs11_test = conditional_test(cRuntime !== CRuntimeType.MUSL && PKCS11_LIB_PATH) | ||
@@ -28,0 +34,0 @@ pkcs11_test('Pkcs11Lib sanity check', () => { |
{ | ||
"name": "aws-crt", | ||
"version": "1.15.22", | ||
"version": "1.16.0", | ||
"description": "NodeJS/browser bindings to the aws-c-* libraries", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/awslabs/aws-crt-nodejs", |
@@ -14,2 +14,3 @@ /** | ||
const tar = require("tar"); | ||
const getCRuntime = require("./cruntime") | ||
@@ -120,3 +121,3 @@ const nativeSourceDir = "crt/"; | ||
arch: arch, | ||
out: path.join('build', `${platform}-${arch}`), | ||
out: path.join('build', `${platform}-${arch}-${getCRuntime()}`), | ||
cMakeOptions: { | ||
@@ -123,0 +124,0 @@ CMAKE_EXPORT_COMPILE_COMMANDS: true, |
@@ -9,5 +9,6 @@ /** | ||
const fs = require("fs"); | ||
const getCRuntime = require("./cruntime") | ||
if (!process.argv.includes('--rebuild')) { | ||
const binaryDir = path.join('dist', 'bin', `${os.platform()}-${os.arch()}`, 'aws-crt-nodejs.node'); | ||
const binaryDir = path.join('dist', 'bin', `${os.platform()}-${os.arch()}-${getCRuntime()}`, 'aws-crt-nodejs.node'); | ||
if (fs.existsSync(binaryDir)) { | ||
@@ -14,0 +15,0 @@ // Don't continue if the binding already exists (unless --rebuild is specified) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23434678
312
38158
4