Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@checkly/chrome-aws-lambda

Package Overview
Dependencies
Maintainers
10
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@checkly/chrome-aws-lambda - npm Package Compare versions

Comparing version 92.0.4512-10.0.3 to 92.0.4512-10.0.3-2

build/util.d.ts

15

build/index.d.ts

@@ -5,7 +5,2 @@ /// <reference path="../typings/chrome-aws-lambda.d.ts" />

/**
* Downloads or symlinks a custom font and returns its basename, patching the environment so that Chromium can find it.
* If not running on AWS Lambda nor Google Cloud Functions, `null` is returned instead.
*/
static font(input: string): Promise<string>;
/**
* Returns a list of additional Chromium flags recommended for serverless environments.

@@ -19,8 +14,8 @@ * The canonical list of flags can be found on https://peter.sh/experiments/chromium-command-line-switches/.

static get defaultViewport(): Required<Viewport>;
static prepare(folder: string): Promise<{
fontConfigPath: string;
ldLibraryPath: string;
chromiumPath: string;
}>;
/**
* Inflates the current version of Chromium and returns the path to the binary.
* If not running on AWS Lambda nor Google Cloud Functions, `null` is returned instead.
*/
static get executablePath(): Promise<string>;
/**
* Returns a boolean indicating if we are running on AWS Lambda or Google Cloud Functions.

@@ -27,0 +22,0 @@ * False is returned if Serverless environment variables `IS_LOCAL` or `IS_OFFLINE` are set.

"use strict";
/// <reference path="../typings/chrome-aws-lambda.d.ts" />
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
const fs_1 = require("fs");
const lambdafs_1 = __importDefault(require("lambdafs"));
const path_1 = require("path");
const url_1 = require("url");
if (/^AWS_Lambda_nodejs(?:10|12|14)[.]x$/.test(process.env.AWS_EXECUTION_ENV) === true) {
if (process.env.FONTCONFIG_PATH === undefined) {
process.env.FONTCONFIG_PATH = '/tmp/aws';
}
if (process.env.LD_LIBRARY_PATH === undefined) {
process.env.LD_LIBRARY_PATH = '/tmp/aws/lib';
}
else if (process.env.LD_LIBRARY_PATH.startsWith('/tmp/aws/lib') !== true) {
process.env.LD_LIBRARY_PATH = [...new Set(['/tmp/aws/lib', ...process.env.LD_LIBRARY_PATH.split(':')])].join(':');
}
}
const util_1 = require("./util");
class Chromium {
/**
* Downloads or symlinks a custom font and returns its basename, patching the environment so that Chromium can find it.
* If not running on AWS Lambda nor Google Cloud Functions, `null` is returned instead.
*/
static font(input) {
if (Chromium.headless !== true) {
return null;
}
if (process.env.HOME === undefined) {
process.env.HOME = '/tmp';
}
if (fs_1.existsSync(`${process.env.HOME}/.fonts`) !== true) {
fs_1.mkdirSync(`${process.env.HOME}/.fonts`);
}
return new Promise((resolve, reject) => {
if (/^https?:[/][/]/i.test(input) !== true) {
input = `file://${input}`;
}
const url = new url_1.URL(input);
const output = `${process.env.HOME}/.fonts/${url.pathname.split('/').pop()}`;
if (fs_1.existsSync(output) === true) {
return resolve(output.split('/').pop());
}
if (url.protocol === 'file:') {
fs_1.access(url.pathname, (error) => {
if (error != null) {
return reject(error);
}
fs_1.symlink(url.pathname, output, (error) => {
return error != null ? reject(error) : resolve(url.pathname.split('/').pop());
});
});
}
else {
let handler = url.protocol === 'http:' ? require('http').get : require('https').get;
handler(input, (response) => {
if (response.statusCode !== 200) {
return reject(`Unexpected status code: ${response.statusCode}.`);
}
const stream = fs_1.createWriteStream(output);
stream.once('error', (error) => {
return reject(error);
});
response.on('data', (chunk) => {
stream.write(chunk);
});
response.once('end', () => {
stream.end(() => {
return resolve(url.pathname.split('/').pop());
});
});
});
}
});
}
/**
* Returns a list of additional Chromium flags recommended for serverless environments.

@@ -127,27 +57,29 @@ * The canonical list of flags can be found on https://peter.sh/experiments/chromium-command-line-switches/.

}
/**
* Inflates the current version of Chromium and returns the path to the binary.
* If not running on AWS Lambda nor Google Cloud Functions, `null` is returned instead.
*/
static get executablePath() {
if (Chromium.headless !== true) {
return Promise.resolve(null);
}
if (fs_1.existsSync('/tmp/chromium') === true) {
for (const file of fs_1.readdirSync('/tmp')) {
static async prepare(folder) {
await fs_1.promises.mkdir(folder, { recursive: true, mode: 0o777 });
const chromiumExpectedPath = path_1.join(folder, 'chromium');
if (await util_1.fileExists(chromiumExpectedPath)) {
const files = await fs_1.promises.readdir(folder);
for (const file of files) {
if (file.startsWith('core.chromium') === true) {
fs_1.unlinkSync(`/tmp/${file}`);
await fs_1.promises.unlink(path_1.join(folder, file));
}
}
return Promise.resolve('/tmp/chromium');
}
const input = path_1.join(__dirname, '..', 'bin');
const promises = [
lambdafs_1.default.inflate(`${input}/chromium.br`),
lambdafs_1.default.inflate(`${input}/swiftshader.tar.br`),
];
if (/^AWS_Lambda_nodejs(?:10|12|14)[.]x$/.test(process.env.AWS_EXECUTION_ENV) === true) {
promises.push(lambdafs_1.default.inflate(`${input}/aws.tar.br`));
else {
const input = path_1.join(__dirname, '..', 'bin');
const promises = [
util_1.inflate(folder, `${input}/chromium.br`),
util_1.inflate(folder, `${input}/swiftshader.tar.br`),
util_1.inflate(folder, `${input}/aws.tar.br`),
];
const awsFolder = path_1.join(folder, 'aws');
await Promise.all(promises);
await fs_1.promises.writeFile(path_1.join(awsFolder, 'fonts.conf'), util_1.fontConfig(awsFolder), { encoding: 'utf8', mode: 0o700 });
}
return Promise.all(promises).then((result) => result.shift());
return {
fontConfigPath: path_1.join(folder, 'aws'),
ldLibraryPath: path_1.join(folder, 'aws', 'lib'),
chromiumPath: chromiumExpectedPath,
};
}

@@ -154,0 +86,0 @@ /**

{
"name": "@checkly/chrome-aws-lambda",
"private": false,
"version": "92.0.4512-10.0.3",
"version": "92.0.4512-10.0.3-2",
"author": {

@@ -28,3 +28,3 @@ "name": "Alix Axel"

"dependencies": {
"lambdafs": "^2.0.3"
"tar-fs": "^2.1.1"
},

@@ -34,2 +34,4 @@ "devDependencies": {

"puppeteer-core": "^10.0.0",
"@types/tar-fs": "^2.0.1",
"playwright-core": "^1.16.2",
"rimraf": "^3.0.2",

@@ -36,0 +38,0 @@ "typescript": "4.3.2"

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