Socket
Socket
Sign inDemoInstall

aws-crt

Package Overview
Dependencies
Maintainers
4
Versions
123
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aws-crt - npm Package Compare versions

Comparing version 1.17.0 to 1.17.1

scripts/build_dependencies/build_step_axios.js

12

package.json
{
"name": "aws-crt",
"version": "1.17.0",
"version": "1.17.1",
"description": "NodeJS/browser bindings to the aws-c-* libraries",

@@ -37,3 +37,2 @@ "homepage": "https://github.com/awslabs/aws-crt-nodejs",

"aws-sdk": "^2.848.0",
"cmake-js": "^6.3.2",
"https-proxy-agent": "^5.0.1",

@@ -44,3 +43,2 @@ "jest": "^27.2.1",

"puppeteer": "^3.3.0",
"tar": "^6.1.11",
"ts-jest": "^27.0.5",

@@ -51,3 +49,5 @@ "typedoc": "^0.22.18",

"uuid": "^8.3.2",
"yargs": "^17.2.1"
"yargs": "^17.2.1",
"cmake-js": "^6.3.2",
"tar": "^6.1.11"
},

@@ -59,8 +59,6 @@ "dependencies": {

"buffer": "^6.0.3",
"cmake-js": "^6.3.2",
"crypto-js": "^4.0.0",
"mqtt": "^4.3.7",
"process": "^0.11.10",
"tar": "^6.1.11"
"process": "^0.11.10"
}
}

@@ -5,3 +5,2 @@ /**

*/
const os = require("os")
const fs = require("fs");

@@ -12,8 +11,5 @@ const crypto = require('crypto');

const cmake = require("cmake-js");
const axios = require("axios");
const tar = require("tar");
const getCRuntime = require("./cruntime")
const nativeSourceDir = "crt/";
const build_step_tar = require("./build_dependencies/build_step_tar");
const build_step_cmake = require("./build_dependencies/build_step_cmake");

@@ -45,116 +41,2 @@ function rmRecursive(rmPath) {

function downloadFile(fileUrl, outputLocationPath) {
const writer = fs.createWriteStream(outputLocationPath);
return axios({
method: 'get',
url: fileUrl,
responseType: 'stream',
}).then(response => {
return new Promise((resolve, reject) => {
response.data.pipe(writer);
let error = null;
writer.on('error', err => {
error = err;
writer.close();
reject(err);
});
writer.on('close', () => {
if (!error) {
resolve();
}
});
});
});
}
function checkChecksum(url, local_file) {
return axios({
method: 'get',
url: url,
responseType: 'text',
}).then(response => {
return new Promise((resolve, reject) => {
const filestream = fs.createReadStream(local_file);
const hash = crypto.createHash('sha256');
filestream.on('readable', () => {
// Only one element is going to be produced by the
// hash stream.
const data = filestream.read();
if (data)
hash.update(data);
else {
const checksum = hash.digest("hex")
if (checksum === response.data) {
resolve()
}
else {
reject(new Error("source code checksum mismatch"))
}
}
});
});
})
}
async function fetchNativeCode(url, version, path) {
const sourceURL = `${url}/aws-crt-${version}-source.tgz`
const tarballPath = path + "source.tgz";
await downloadFile(sourceURL, tarballPath);
const sourceChecksumURL = `${url}/aws-crt-${version}-source.sha256`;
await checkChecksum(sourceChecksumURL, tarballPath);
await tar.x({ file: tarballPath, strip: 2, C: nativeSourceDir });
}
async function buildLocally() {
const platform = os.platform();
let arch = os.arch();
// Allow cross-compile (so OSX can do arm64 or x64 builds) via:
// --target-arch ARCH
if (process.argv.includes('--target-arch')) {
arch = process.argv[process.argv.indexOf('--target-arch') + 1];
}
// options for cmake.BuildSystem
let options = {
target: "install",
debug: process.argv.includes('--debug'),
arch: arch,
out: path.join('build', `${platform}-${arch}-${getCRuntime()}`),
cMakeOptions: {
CMAKE_EXPORT_COMPILE_COMMANDS: true,
CMAKE_JS_PLATFORM: platform,
BUILD_TESTING: 'OFF',
CMAKE_INSTALL_PREFIX: 'crt/install',
CMAKE_PREFIX_PATH: 'crt/install',
}
}
// We need to pass some extra flags to pull off cross-compiling
// because cmake-js doesn't set everything we need.
//
// See the docs on `arch`: https://github.com/cmake-js/cmake-js/blob/v6.1.0/README.md?#runtimes
// > Notice: on non-Windows systems the C++ toolset's architecture's gonna be used despite this setting.
if (platform === 'darwin') {
// What Node calls "x64", Apple calls "x86_64". They both agree on the term "arm64" though.
options.cMakeOptions.CMAKE_OSX_ARCHITECTURES = (arch === 'x64') ? 'x86_64' : arch;
options.cMakeOptions.CMAKE_OSX_DEPLOYMENT_TARGET = "10.9";
}
// Convert any -D arguments to this script to cmake -D arguments
for (const arg of process.argv) {
if (arg.startsWith('-D')) {
const option = arg.substring(2).split('=')
options.cMakeOptions[option[0]] = option[1]
}
}
// Enable parallel build (ignored by cmake older than 3.12)
process.env.CMAKE_BUILD_PARALLEL_LEVEL = `${Math.max(os.cpus().length, 1)}`;
// Run the build
var buildSystem = new cmake.BuildSystem(options);
await buildSystem.build();
}
async function buildFromRemoteSource(tmpPath) {

@@ -175,9 +57,22 @@ if (fs.existsSync(nativeSourceDir)) {

const version = JSON.parse(rawData)["version"];
await fetchNativeCode(host, version, tmpPath);
// Get the file using tar, loaded as an install-time dependency (see scripts/build_dependencies)
try {
await build_step_tar.performStep(host, version, tmpPath, nativeSourceDir);
} catch (error) {
console.log("tar perform step failed with" + error);
throw error;
} finally {
rmRecursive(tmpPath);
}
// Clean up temp directory
rmRecursive(tmpPath);
// Kick off local build
await buildLocally();
// Local build finished successfully, we don't need source anymore.
rmRecursive(nativeSourceDir);
// Kick off local build using cmake-js loaded as an install-time dependency (see scripts/build_dependencies)
try {
await build_step_cmake.performStep();
} catch (error) {
console.log("tar perform step failed with" + error);
throw error;
} finally {
// Local build finished successfully, we don't need source anymore.
rmRecursive(nativeSourceDir);
}
}

@@ -206,2 +101,3 @@

rmRecursive(nativeSourceDir);
console.log("build from remote source failed with" + err);
throw err;

@@ -211,3 +107,3 @@ }

// kick off local build
await buildLocally();
await build_step_cmake.performStep();
}

@@ -214,0 +110,0 @@ })().catch((reason) => {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc