Merge branch 'master' of git.wmi.amu.edu.pl:s452108/atcheck

This commit is contained in:
s416422 2019-12-16 18:49:15 +01:00
commit 895c6da9fd
26109 changed files with 2136427 additions and 0 deletions

View File

@ -0,0 +1,41 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class UserCache extends Controller
{
public function delete($classes_code) {
DB::table("usercache")->where("classcode", $classes_code)->delete();
}
public function get($classes_code) {
$object = DB::table("usercache")->where("classcode", $classes_code)->first();
return $object;
}
public function add(Request $request) {
$classes_code = $request->classes_code;
$classes = DB::table("classes")->where("classes_code", $classes_code)->first();
if(is_null($classes)) {
return response()->json(['message' => 'Nie ma takich zajęć'], 400);
} else {
$cache = DB::table("usercache")->where("classcode", $classes_code)->first();
if(!is_null($cache)) {
return response()->json(['message' => 'Użytkownik w cache'], 500);
}
}
DB::table("usercache")->insert([
"name" => $request->student_name,
"surname" => $request->student_surname,
"classcode" => $request->classes_code,
"index" => $request->student_index
]);
return response()->json(['message' => 'ADDED'], 200);
}
}

View File

@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class Usercache extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('usercache', function (Blueprint $table) {
$table->bigIncrements('id')->unique();
$table->string('name');
$table->string('surname');
$table->string('classcode');
$table->string('index');
$table->timestamp('inserted_at')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('usercache');
}
}

View File

@ -0,0 +1,42 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-beta/css/materialize.min.css">
<meta charset="UTF-8">
<title>Add student</title>
</head>
<body>
<div class="container">
<form>
<div>
<h5 class="center">Enter student data</h3> <br />
Name: <input type="text" id="name" required autofocus/> <br />
Surname: <input type="text" id="surname" required autofocus/> <br />
Index: <input type="text" id="index" required autofocus/> <br />
</div>
<br />
<button class="btn waves-effect waves-light" type="submit">Add</button>
</form>
</div>
<script>
const electron = require('electron');
const {ipcRenderer} = electron;
const form = document.querySelector("form");
form.addEventListener("submit",submitForm);
function submitForm(e){
e.preventDefault();
var name = document.querySelector("#name").value;
var surname = document.querySelector("#surname").value;
var index = document.querySelector("#index").value;
const item = [name,surname,index];
ipcRenderer.send("item:add",item);
}
</script>
</body>
</html>

View File

@ -0,0 +1,47 @@
<!DOCTYPE html>
<html>
<head>
<!-- Compiled and minified CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-beta/css/materialize.min.css">
<meta charset="UTF-8">
<title>Add classes</title>
</head>
<body>
<div class="container">
<form>
<div>
<h5 class="center">Enter class data</h3>
<br /> Kod zajęć:
<input type="text" id="classcode" required autofocus/>
</div>
<br />
<button class="btn waves-effect waves-light" type="submit">Akceptuj</button>
</form>
</div>
<script>
const electron = require('electron');
const {
ipcRenderer
} = electron;
const form = document.querySelector("form");
form.addEventListener("submit", submitForm);
function submitForm(e) {
e.preventDefault();
var classcode = document.querySelector("#classcode").value;
ipcRenderer.send("set:classcode", classcode);
}
</script>
</body>
</html>

57
lsscanner/new_ubuntu/index.html Executable file
View File

@ -0,0 +1,57 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-beta/css/materialize.min.css">
<meta charset="UTF-8">
<title>Student counter</title>
</head>
<body>
<nav>
<div class="nav-wrapper">
<a class="brand-logo center">Student counter</a>
</div>
</nav>
<ul>
</ul>
<script>
const electron = require('electron');
const {ipcRenderer} = electron;
const ul = document.querySelector("ul");
ipcRenderer.on("item:add",function(e,item) {
console.log(item);
ul.className = "collection";
const li = document.createElement('li');
li.className = "collection-item";
var date = item[3] ? item[3] : Date.now();
const itemText = document.createTextNode(item[0] + " " + item[1] + " " + item[2] + " " + date);
li.appendChild(itemText);
li.id = item[2];
ul.appendChild(li);
});
ul.addEventListener('dblclick',removeItem);
function removeItem(item) {
ipcRenderer.send("item:delete",item.target.id);
item.target.remove();
if (ul.children.length == 0) {
ul.className = "";
}
}
</script>
</html>

BIN
lsscanner/new_ubuntu/info.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

394
lsscanner/new_ubuntu/main.js Executable file
View File

@ -0,0 +1,394 @@
//Get required packages
const electron = require('electron');
const path = require('path');
const url = require('url');
const fs = require('fs');
const asn1js = require('asn1js');
const util = require('util');
const notifier = require('node-notifier');
const smartcard = require('smartcard');
const axios = require('axios')
let class_code = "";
let counter = 0;
const {
app,
BrowserWindow,
Menu,
ipcMain
} = electron;
let mainWindow;
let AddWindow;
//Listen for the app to be ready
app.on('ready', function () {
//Create new window
mainWindow = new BrowserWindow({
width: 500,
height: 600,
webPreferences: {
nodeIntegration: true
}});
//Load html into window
mainWindow.loadURL(url.format({
pathname: path.join(__dirname, "classcode.html"),
protocol: "file:",
slashes: true
}));
//Quit app when closed
mainWindow.on("closed", function () {
app.quit();
})
//Menu from template
const mainMenu = Menu.buildFromTemplate(mainMenuTemplate);
Menu.setApplicationMenu(mainMenu);
});
function readNewCard(application) {
application.issueCommand([0x00, 0xA4, 0x04, 0x04, 0x07, 0xD6, 0x16, 0x00, 0x00, 0x30, 0x01, 0x01, 0x00])
.then(response => {
console.info(`Response: '${response}' '${response.meaning()}'`);
application.issueCommand([0x00, 0xA4, 0x02, 0x04, 0x02, 0x00, 0x02, 0x00])
.then(response => {
console.info(`Response: '${response}' '${response.meaning()}'`);
var response2 = `${response}`;
if(response2.indexOf("6a82") == 0) {
console.log("ALERTTTTTT");
readNewCard(application);
return;
}
application.issueCommand([0x00, 0xB0, 0x00, 0x00, 0xE6])
.then(response => {
console.info(`Response: '${response}' '${response.meaning()}'`);
var response2 = `${response}`;
if(response2.indexOf("000000") == 0) {
console.log("ALERTTTTTT");
readNewCard(application);
return;
}
var start = response2.indexOf("2a8468016504010101");
start = start + 18;
response2 = response2.substring(start);
while (1) {
var type = response2.substring(0, 2);
if (type == "30") break;
if (parseInt(response2.substring(2, 4), 16) > 127) {
var count = parseInt(response2.substring(2, 4), 16) - 128;
var length = "";
var k = 1;
for (k = 1; k <= count; k++) {
length += response2.substring(2 + (k * 2), 4 + (k * 2));
}
var total_length = parseInt(length, 16) * 2;
response2 = response2.substr(4 + (k - 1) * 2, total_length);
} else {
var total_length = parseInt(response2.substring(2, 4), 16) * 2 + 4;
response2 = response2.substr(4, total_length);
}
}
//region How to work with ASN.1 strings
let bmp_string_encoded = new ArrayBuffer(response2.length / 2);
let bmp_string_view = new Uint8Array(bmp_string_encoded);
var kk = 0;
for (var i = 0; i < (response2.length / 2); i++) {
bmp_string_view[i] = "0x" + response2.substring(kk, kk + 2);
kk += 2;
}
let bmp_string_decoded = asn1js.fromBER(bmp_string_encoded);
if (bmp_string_decoded.offset === (-1)) return; // Error during decoding
let obj = bmp_string_decoded.result.valueBlock.value;
var names = obj[4].valueBlock.value[0].valueBlock.value;
var surnames = obj[3].valueBlock.value[0].valueBlock.value;
var index = obj[5].valueBlock.value;
var output = [names, surnames, index];
printStudent(output);
}).catch(error => {
console.error('Error:', error, error.stack + '\n');
});
}).catch(error => {
console.error('Error:', error, error.stack + '\n');
});
}).catch(error => {
console.error('Error:', error, error.stack + '\n');
});
}
function readOldCard(application) {
application.selectFile([0xD6, 0x16, 0x00, 0x00, 0x30, 0x01, 0x01])
.then(response => {
console.info(`Response: '${response}' '${response.meaning()}'`);
application.issueCommand([0x00, 0xA4, 0x02, 0x00, 0x02, 0x00, 0x02, 0x12])
.then(response => {
console.info(`Response: '${response}' '${response.meaning()}'`);
application.issueCommand([0x00, 0xB0, 0x00, 0x00, 0xF8])
.then(response => {
console.info(`Response: '${response}' '${response.meaning()}'`);
var response2 = `${response}`;
var start = response2.indexOf("2a8468016504010101");
start = start + 18;
response2 = response2.substring(start);
while (1) {
var type = response2.substring(0, 2);
if (type == "30") break;
if (parseInt(response2.substring(2, 4), 16) > 127) {
var count = parseInt(response2.substring(2, 4), 16) - 128;
var length = "";
var k = 1;
for (k = 1; k <= count; k++) {
length += response2.substring(2 + (k * 2), 4 + (k * 2));
}
var total_length = parseInt(length, 16) * 2;
response2 = response2.substr(4 + (k - 1) * 2, total_length);
} else {
var total_length = parseInt(response2.substring(2, 4), 16) * 2 + 4;
response2 = response2.substr(4, total_length);
}
}
//region How to work with ASN.1 strings
let bmp_string_encoded = new ArrayBuffer(response2.length / 2);
let bmp_string_view = new Uint8Array(bmp_string_encoded);
var kk = 0;
for (var i = 0; i < (response2.length / 2); i++) {
bmp_string_view[i] = "0x" + response2.substring(kk, kk + 2);
kk += 2;
}
let bmp_string_decoded = asn1js.fromBER(bmp_string_encoded);
if (bmp_string_decoded.offset === (-1)) return; // Error during decoding
let obj = bmp_string_decoded.result.valueBlock.value;
var names = obj[4].valueBlock.value[0].valueBlock.value;
var surnames = obj[3].valueBlock.value[0].valueBlock.value;
var index = obj[5].valueBlock.value;
var output = [names, surnames, index];
printStudent(output);
}).catch(error => {
console.error('Error:', error, error.stack + '\n');
});
}).catch(error => {
console.error('Error:', error, error.stack + '\n');
}); }).catch(error => {
console.error('Error:', error, error.stack + '\n');
});
}
var Devices = smartcard.Devices;
var devices = new Devices();
devices.on('device-activated', event => {
console.log('Smart card reader active');
var device = event.device;
device.on('card-inserted', event => {
var card = event.card;
//console.log(`Card '${card.getAtr()}' inserted into '${event.device}'` + '\n');
var Iso7816Application = smartcard.Iso7816Application;
var application = new Iso7816Application(card);
console.log(card.getAtr());
if(card.getAtr() == "3bdd18008131fe4580f9a000000077010800079000fe") {
readNewCard(application);
} else {
readOldCard(application);
}
});
});
//Add student manually
function createAddWindow() {
//Create new window
AddWindow = new BrowserWindow({
width: 300,
height: 400,
title: "Add student manually"
});
//Load html into window
AddWindow.loadURL(url.format({
pathname: path.join(__dirname, "addstudent.html"),
protocol: "file:",
slashes: true
}));
//Garbage
AddWindow.on("close", function () {
AddWindow = null;
});
}
function printStudent(item) {
var dateTime = require('node-datetime');
var dt = dateTime.create();
var formatted = dt.format('d-m-Y H:M:S');
item.push(formatted);
mainWindow.webContents.send("item:add", item);
notifier.notify({
title: "Student registered",
message: item[0] + " " + item[1],
icon: path.join(__dirname, 'ok.png')
});
axios.post('http://127.0.0.1:8000/add/cache', {
classes_code: 'LLcUHw3b0a',
student_index: item[2],
student_name: item[0],
student_surname: item[1]
})
.then((res) => {
console.log(`statusCode: ${res.statusCode}`)
console.log(res)
})
.catch((error) => {
console.error(error)
})
}
//Catch
ipcMain.on("item:add", function (e, item) {
printStudent(item);
AddWindow.close();
})
ipcMain.on("card:read", function (e) {
card_read();
})
ipcMain.on("set:classcode", function (e,classcode) {
class_code = classcode;
mainWindow.loadURL(url.format({
pathname: path.join(__dirname, "index.html"),
protocol: "file:",
slashes: true
}));
})
//Menu template
const mainMenuTemplate = [{
label: "Student",
submenu: [{
label: "Add student",
accelerator: process.platfrom == "darwin" ? "Command+E" : "Ctrl+E",
click() {
createAddWindow();
}
},
{
label: "Quit program",
accelerator: process.platfrom == "darwin" ? "Command+Q" : "Ctrl+Q",
click() {
app.quit();
}
}
]
}, {
label: "Classes",
submenu: [{
label: "Add classes",
click() {
createAddClassesWindow();
}
},
{
label: "Pick classes",
click() {
createSelectClassesWindow();
}
}
]
}];
//If mac psuh empty obj to Menu
if (process.platfrom == "darwin") {
mainMenuTemplate.unshift({});
}
//Add dev tools on DEV
if (process.env.NODE_ENV !== 'production') {
mainMenuTemplate.push({
label: "DEV",
submenu: [{
label: "Toggle dev tools",
accelerator: process.platfrom == "darwin" ? "Command+I" : "Ctrl+I",
click(item, focusedWindow) {
focusedWindow.toggleDevTools();
}
},
{
role: "reload"
}
]
});
}

1
lsscanner/new_ubuntu/node_modules/.bin/detect-libc generated vendored Symbolic link
View File

@ -0,0 +1 @@
../detect-libc/bin/detect-libc.js

1
lsscanner/new_ubuntu/node_modules/.bin/electron generated vendored Symbolic link
View File

@ -0,0 +1 @@
../electron/cli.js

1
lsscanner/new_ubuntu/node_modules/.bin/electron-rebuild generated vendored Symbolic link
View File

@ -0,0 +1 @@
../electron-rebuild/lib/src/cli.js

1
lsscanner/new_ubuntu/node_modules/.bin/extract-zip generated vendored Symbolic link
View File

@ -0,0 +1 @@
../extract-zip/cli.js

1
lsscanner/new_ubuntu/node_modules/.bin/mkdirp generated vendored Symbolic link
View File

@ -0,0 +1 @@
../mkdirp/bin/cmd.js

1
lsscanner/new_ubuntu/node_modules/.bin/node-gyp generated vendored Symbolic link
View File

@ -0,0 +1 @@
../node-gyp/bin/node-gyp.js

1
lsscanner/new_ubuntu/node_modules/.bin/nopt generated vendored Symbolic link
View File

@ -0,0 +1 @@
../nopt/bin/nopt.js

1
lsscanner/new_ubuntu/node_modules/.bin/npm generated vendored Symbolic link
View File

@ -0,0 +1 @@
../npm/bin/npm-cli.js

1
lsscanner/new_ubuntu/node_modules/.bin/npx generated vendored Symbolic link
View File

@ -0,0 +1 @@
../npm/bin/npx-cli.js

1
lsscanner/new_ubuntu/node_modules/.bin/rimraf generated vendored Symbolic link
View File

@ -0,0 +1 @@
../rimraf/bin.js

1
lsscanner/new_ubuntu/node_modules/.bin/semver generated vendored Symbolic link
View File

@ -0,0 +1 @@
../semver/bin/semver.js

1
lsscanner/new_ubuntu/node_modules/.bin/sshpk-conv generated vendored Symbolic link
View File

@ -0,0 +1 @@
../sshpk/bin/sshpk-conv

1
lsscanner/new_ubuntu/node_modules/.bin/sshpk-sign generated vendored Symbolic link
View File

@ -0,0 +1 @@
../sshpk/bin/sshpk-sign

1
lsscanner/new_ubuntu/node_modules/.bin/sshpk-verify generated vendored Symbolic link
View File

@ -0,0 +1 @@
../sshpk/bin/sshpk-verify

1
lsscanner/new_ubuntu/node_modules/.bin/uuid generated vendored Symbolic link
View File

@ -0,0 +1 @@
../uuid/bin/uuid

1
lsscanner/new_ubuntu/node_modules/.bin/which generated vendored Symbolic link
View File

@ -0,0 +1 @@
../which/bin/which

View File

@ -0,0 +1,96 @@
# @electron/get
> Download Electron release artifacts
[![CircleCI](https://circleci.com/gh/electron/get.svg?style=svg)](https://circleci.com/gh/electron/get)
## Usage
### Simple: Downloading an Electron Binary ZIP
```typescript
import { download } from '@electron/get';
// NB: Use this syntax within an async function, Node does not have support for
// top-level await as of Node 12.
const zipFilePath = await download('4.0.4');
```
### Advanced: Downloading a macOS Electron Symbol File
```typescript
import { downloadArtifact } from '@electron/get';
// NB: Use this syntax within an async function, Node does not have support for
// top-level await as of Node 12.
const zipFilePath = await downloadArtifact({
version: '4.0.4',
platform: 'darwin',
artifactName: 'electron',
artifactSuffix: 'symbols',
arch: 'x64',
});
```
### Specifying a mirror
Anatomy of a download URL, in terms of `mirrorOptions`:
```
https://github.com/electron/electron/releases/download/v4.0.4/electron-v4.0.4-linux-x64.zip
| | | |
------------------------------------------------------- -----------------------------
| |
mirror / nightly_mirror | | customFilename
------
||
customDir
```
Example:
```typescript
import { download } from '@electron/get';
const zipFilePath = await download('4.0.4', {
mirrorOptions: {
mirror: 'https://mirror.example.com/electron/',
customDir: 'custom',
customFilename: 'unofficial-electron-linux.zip'
}
});
// Will download from https://mirror.example.com/electron/custom/unofficial-electron-linux.zip
const nightlyZipFilePath = await download('8.0.0-nightly.20190901', {
mirrorOptions: {
nightly_mirror: 'https://nightly.example.com/',
customDir: 'nightlies',
customFilename: 'nightly-linux.zip'
}
});
// Will download from https://nightly.example.com/nightlies/nightly-linux.zip
```
## How It Works
This module downloads Electron to a known place on your system and caches it
so that future requests for that asset can be returned instantly. The cache
locations are:
* Linux: `$XDG_CACHE_HOME` or `~/.cache/electron/`
* MacOS: `~/Library/Caches/electron/`
* Windows: `%LOCALAPPDATA%/electron/Cache` or `~/AppData/Local/electron/Cache/`
By default, the module uses [`got`](https://github.com/sindresorhus/got) as the
downloader. As a result, you can use the same [options](https://github.com/sindresorhus/got#options)
via `downloadOptions`.
### Proxies
Downstream packages should utilize the `initializeProxy` function to add HTTP(S) proxy support. A
different proxy module is used, depending on the version of Node in use, and as such, there are
slightly different ways to set the proxy environment variables. For Node 10 and above,
[`global-agent`](https://github.com/gajus/global-agent#environment-variables) is used. Otherwise,
[`global-tunnel-ng`](https://github.com/np-maintain/global-tunnel#auto-config) is used. Refer to the
appropriate linked module to determine how to configure proxy support.

View File

@ -0,0 +1,7 @@
export declare class Cache {
private cacheRoot;
constructor(cacheRoot?: string);
private getCachePath;
getPathForFileInCache(url: string, fileName: string): Promise<string | null>;
putFileInCache(url: string, currentPath: string, fileName: string): Promise<string>;
}

View File

@ -0,0 +1,100 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
var debug_1 = require("debug");
var env_paths_1 = require("env-paths");
var fs = require("fs-extra");
var path = require("path");
var sanitize = require("sanitize-filename");
var d = debug_1.default('@electron/get:cache');
var defaultCacheRoot = env_paths_1.default('electron', {
suffix: '',
}).cache;
var Cache = /** @class */ (function () {
function Cache(cacheRoot) {
if (cacheRoot === void 0) { cacheRoot = defaultCacheRoot; }
this.cacheRoot = cacheRoot;
}
Cache.prototype.getCachePath = function (url, fileName) {
var sanitizedUrl = sanitize(url);
return path.resolve(this.cacheRoot, sanitizedUrl, fileName);
};
Cache.prototype.getPathForFileInCache = function (url, fileName) {
return __awaiter(this, void 0, void 0, function () {
var cachePath;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
cachePath = this.getCachePath(url, fileName);
return [4 /*yield*/, fs.pathExists(cachePath)];
case 1:
if (_a.sent()) {
return [2 /*return*/, cachePath];
}
return [2 /*return*/, null];
}
});
});
};
Cache.prototype.putFileInCache = function (url, currentPath, fileName) {
return __awaiter(this, void 0, void 0, function () {
var cachePath;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
cachePath = this.getCachePath(url, fileName);
d("Moving " + currentPath + " to " + cachePath);
return [4 /*yield*/, fs.pathExists(cachePath)];
case 1:
if (!_a.sent()) return [3 /*break*/, 3];
d('* Replacing existing file');
return [4 /*yield*/, fs.remove(cachePath)];
case 2:
_a.sent();
_a.label = 3;
case 3: return [4 /*yield*/, fs.move(currentPath, cachePath)];
case 4:
_a.sent();
return [2 /*return*/, cachePath];
}
});
});
};
return Cache;
}());
exports.Cache = Cache;
//# sourceMappingURL=Cache.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"Cache.js","sourceRoot":"","sources":["../../src/Cache.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAA0B;AAC1B,uCAAiC;AACjC,6BAA+B;AAC/B,2BAA6B;AAC7B,4CAA8C;AAE9C,IAAM,CAAC,GAAG,eAAK,CAAC,qBAAqB,CAAC,CAAC;AAEvC,IAAM,gBAAgB,GAAG,mBAAQ,CAAC,UAAU,EAAE;IAC5C,MAAM,EAAE,EAAE;CACX,CAAC,CAAC,KAAK,CAAC;AAET;IACE,eAAoB,SAA4B;QAA5B,0BAAA,EAAA,4BAA4B;QAA5B,cAAS,GAAT,SAAS,CAAmB;IAAG,CAAC;IAE5C,4BAAY,GAApB,UAAqB,GAAW,EAAE,QAAgB;QAChD,IAAM,YAAY,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;QACnC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAC;IAC9D,CAAC;IAEY,qCAAqB,GAAlC,UAAmC,GAAW,EAAE,QAAgB;;;;;;wBACxD,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;wBAC/C,qBAAM,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAA;;wBAAlC,IAAI,SAA8B,EAAE;4BAClC,sBAAO,SAAS,EAAC;yBAClB;wBAED,sBAAO,IAAI,EAAC;;;;KACb;IAEY,8BAAc,GAA3B,UAA4B,GAAW,EAAE,WAAmB,EAAE,QAAgB;;;;;;wBACtE,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;wBACnD,CAAC,CAAC,YAAU,WAAW,YAAO,SAAW,CAAC,CAAC;wBACvC,qBAAM,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAA;;6BAA9B,SAA8B,EAA9B,wBAA8B;wBAChC,CAAC,CAAC,2BAA2B,CAAC,CAAC;wBAC/B,qBAAM,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,EAAA;;wBAA1B,SAA0B,CAAC;;4BAG7B,qBAAM,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,EAAA;;wBAArC,SAAqC,CAAC;wBAEtC,sBAAO,SAAS,EAAC;;;;KAClB;IACH,YAAC;AAAD,CAAC,AA7BD,IA6BC;AA7BY,sBAAK"}

View File

@ -0,0 +1,3 @@
export interface Downloader<T> {
download(url: string, targetFilePath: string, options: T): Promise<void>;
}

View File

@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=Downloader.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"Downloader.js","sourceRoot":"","sources":["../../src/Downloader.ts"],"names":[],"mappings":""}

View File

@ -0,0 +1,7 @@
import { Downloader } from './Downloader';
export declare class GotDownloader implements Downloader<any> {
/**
* @param options - see [`got#options`](https://github.com/sindresorhus/got#options) for possible keys/values.
*/
download(url: string, targetFilePath: string, options?: any): Promise<void>;
}

View File

@ -0,0 +1,73 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
var fs = require("fs-extra");
var got = require("got");
var path = require("path");
var GotDownloader = /** @class */ (function () {
function GotDownloader() {
}
/**
* @param options - see [`got#options`](https://github.com/sindresorhus/got#options) for possible keys/values.
*/
GotDownloader.prototype.download = function (url, targetFilePath, options) {
return __awaiter(this, void 0, void 0, function () {
var writeStream;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, fs.mkdirp(path.dirname(targetFilePath))];
case 1:
_a.sent();
writeStream = fs.createWriteStream(targetFilePath);
return [4 /*yield*/, new Promise(function (resolve, reject) {
var downloadStream = got.stream(url, options);
downloadStream.pipe(writeStream);
downloadStream.on('error', function (error) { return reject(error); });
writeStream.on('error', function (error) { return reject(error); });
writeStream.on('close', function () { return resolve(); });
})];
case 2:
_a.sent();
return [2 /*return*/];
}
});
});
};
return GotDownloader;
}());
exports.GotDownloader = GotDownloader;
//# sourceMappingURL=GotDownloader.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"GotDownloader.js","sourceRoot":"","sources":["../../src/GotDownloader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAA+B;AAC/B,yBAA2B;AAC3B,2BAA6B;AAI7B;IAAA;IAgBA,CAAC;IAfC;;OAEG;IACG,gCAAQ,GAAd,UAAe,GAAW,EAAE,cAAsB,EAAE,OAAa;;;;;4BAC/D,qBAAM,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,EAAA;;wBAA7C,SAA6C,CAAC;wBACxC,WAAW,GAAG,EAAE,CAAC,iBAAiB,CAAC,cAAc,CAAC,CAAC;wBACzD,qBAAM,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;gCAChC,IAAM,cAAc,GAAG,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;gCAChD,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;gCAEjC,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,UAAA,KAAK,IAAI,OAAA,MAAM,CAAC,KAAK,CAAC,EAAb,CAAa,CAAC,CAAC;gCACnD,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,UAAA,KAAK,IAAI,OAAA,MAAM,CAAC,KAAK,CAAC,EAAb,CAAa,CAAC,CAAC;gCAChD,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,cAAM,OAAA,OAAO,EAAE,EAAT,CAAS,CAAC,CAAC;4BAC3C,CAAC,CAAC,EAAA;;wBAPF,SAOE,CAAC;;;;;KACJ;IACH,oBAAC;AAAD,CAAC,AAhBD,IAgBC;AAhBY,sCAAa"}

View File

@ -0,0 +1,3 @@
import { ElectronArtifactDetails } from './types';
export declare function getArtifactFileName(details: ElectronArtifactDetails): string;
export declare function getArtifactRemoteURL(details: ElectronArtifactDetails): string;

View File

@ -0,0 +1,43 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
var BASE_URL = 'https://github.com/electron/electron/releases/download/';
var NIGHTLY_BASE_URL = 'https://github.com/electron/nightlies/releases/download/';
function getArtifactFileName(details) {
utils_1.ensureIsTruthyString(details, 'artifactName');
if (details.isGeneric) {
return details.artifactName;
}
utils_1.ensureIsTruthyString(details, 'arch');
utils_1.ensureIsTruthyString(details, 'platform');
utils_1.ensureIsTruthyString(details, 'version');
return [
details.artifactName,
details.version,
details.platform,
details.arch
].concat((details.artifactSuffix ? [details.artifactSuffix] : [])).join('-') + ".zip";
}
exports.getArtifactFileName = getArtifactFileName;
function mirrorVar(name, options, defaultValue) {
// Convert camelCase to camel_case for env var reading
var lowerName = name.replace(/([a-z])([A-Z])/g, function (_, a, b) { return a + "_" + b; }).toLowerCase();
return (process.env["NPM_CONFIG_ELECTRON_" + lowerName.toUpperCase()] ||
process.env["npm_config_electron_" + lowerName] ||
process.env["npm_package_config_electron_" + lowerName] ||
process.env["ELECTRON_" + lowerName.toUpperCase()] ||
options[name] ||
defaultValue);
}
function getArtifactRemoteURL(details) {
var opts = details.mirrorOptions || {};
var base = mirrorVar('mirror', opts, BASE_URL);
if (details.version.includes('nightly')) {
base = mirrorVar('nightly_mirror', opts, NIGHTLY_BASE_URL);
}
var path = mirrorVar('customDir', opts, details.version);
var file = mirrorVar('customFilename', opts, getArtifactFileName(details));
return "" + base + path + "/" + file;
}
exports.getArtifactRemoteURL = getArtifactRemoteURL;
//# sourceMappingURL=artifact-utils.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"artifact-utils.js","sourceRoot":"","sources":["../../src/artifact-utils.ts"],"names":[],"mappings":";;AACA,iCAA+C;AAE/C,IAAM,QAAQ,GAAG,yDAAyD,CAAC;AAC3E,IAAM,gBAAgB,GAAG,0DAA0D,CAAC;AAEpF,SAAgB,mBAAmB,CAAC,OAAgC;IAClE,4BAAoB,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IAE9C,IAAI,OAAO,CAAC,SAAS,EAAE;QACrB,OAAO,OAAO,CAAC,YAAY,CAAC;KAC7B;IAED,4BAAoB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACtC,4BAAoB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IAC1C,4BAAoB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IAEzC,OAAU;QACR,OAAO,CAAC,YAAY;QACpB,OAAO,CAAC,OAAO;QACf,OAAO,CAAC,QAAQ;QAChB,OAAO,CAAC,IAAI;aACT,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAC3D,IAAI,CAAC,GAAG,CAAC,SAAM,CAAC;AACpB,CAAC;AAlBD,kDAkBC;AAED,SAAS,SAAS,CAAC,IAAyB,EAAE,OAAsB,EAAE,YAAoB;IACxF,sDAAsD;IACtD,IAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE,UAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAK,OAAG,CAAC,SAAI,CAAG,EAAX,CAAW,CAAC,CAAC,WAAW,EAAE,CAAC;IAE1F,OAAO,CACL,OAAO,CAAC,GAAG,CAAC,yBAAuB,SAAS,CAAC,WAAW,EAAI,CAAC;QAC7D,OAAO,CAAC,GAAG,CAAC,yBAAuB,SAAW,CAAC;QAC/C,OAAO,CAAC,GAAG,CAAC,iCAA+B,SAAW,CAAC;QACvD,OAAO,CAAC,GAAG,CAAC,cAAY,SAAS,CAAC,WAAW,EAAI,CAAC;QAClD,OAAO,CAAC,IAAI,CAAC;QACb,YAAY,CACb,CAAC;AACJ,CAAC;AAED,SAAgB,oBAAoB,CAAC,OAAgC;IACnE,IAAM,IAAI,GAAkB,OAAO,CAAC,aAAa,IAAI,EAAE,CAAC;IACxD,IAAI,IAAI,GAAG,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC/C,IAAI,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;QACvC,IAAI,GAAG,SAAS,CAAC,gBAAgB,EAAE,IAAI,EAAE,gBAAgB,CAAC,CAAC;KAC5D;IACD,IAAM,IAAI,GAAG,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAC3D,IAAM,IAAI,GAAG,SAAS,CAAC,gBAAgB,EAAE,IAAI,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC;IAE7E,OAAO,KAAG,IAAI,GAAG,IAAI,SAAI,IAAM,CAAC;AAClC,CAAC;AAVD,oDAUC"}

View File

@ -0,0 +1,2 @@
import { Downloader } from './Downloader';
export declare function getDownloaderForSystem(): Promise<Downloader<any>>;

View File

@ -0,0 +1,52 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
function getDownloaderForSystem() {
return __awaiter(this, void 0, void 0, function () {
var GotDownloader;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, Promise.resolve().then(function () { return require('./GotDownloader'); })];
case 1:
GotDownloader = (_a.sent()).GotDownloader;
return [2 /*return*/, new GotDownloader()];
}
});
});
}
exports.getDownloaderForSystem = getDownloaderForSystem;
//# sourceMappingURL=downloader-resolver.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"downloader-resolver.js","sourceRoot":"","sources":["../../src/downloader-resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,SAAsB,sBAAsB;;;;;wBAKhB,yEAAa,iBAAiB,OAAC;;oBAAjD,aAAa,GAAK,CAAA,SAA+B,CAAA,cAApC;oBACrB,sBAAO,IAAI,aAAa,EAAE,EAAC;;;;CAC5B;AAPD,wDAOC"}

View File

@ -0,0 +1,18 @@
import { ElectronDownloadRequestOptions, ElectronPlatformArtifactDetailsWithDefaults } from './types';
export { getHostArch } from './utils';
export { initializeProxy } from './proxy';
export * from './types';
/**
* Downloads a specific version of Electron and returns an absolute path to a
* ZIP file.
*
* @param version - The version of Electron you want to download
*/
export declare function download(version: string, options?: ElectronDownloadRequestOptions): Promise<string>;
/**
* Downloads an artifact from an Electron release and returns an absolute path
* to the downloaded file.
*
* @param artifactDetails - The information required to download the artifact
*/
export declare function downloadArtifact(_artifactDetails: ElectronPlatformArtifactDetailsWithDefaults): Promise<string>;

View File

@ -0,0 +1,162 @@
"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
var debug_1 = require("debug");
var path = require("path");
var artifact_utils_1 = require("./artifact-utils");
var Cache_1 = require("./Cache");
var downloader_resolver_1 = require("./downloader-resolver");
var proxy_1 = require("./proxy");
var utils_1 = require("./utils");
var utils_2 = require("./utils");
exports.getHostArch = utils_2.getHostArch;
var proxy_2 = require("./proxy");
exports.initializeProxy = proxy_2.initializeProxy;
var d = debug_1.default('@electron/get:index');
var sumchecker = require('sumchecker');
if (process.env.ELECTRON_GET_USE_PROXY) {
proxy_1.initializeProxy();
}
/**
* Downloads a specific version of Electron and returns an absolute path to a
* ZIP file.
*
* @param version - The version of Electron you want to download
*/
function download(version, options) {
return downloadArtifact(__assign({}, options, { version: version, platform: process.platform, arch: utils_1.getHostArch(), artifactName: 'electron' }));
}
exports.download = download;
/**
* Downloads an artifact from an Electron release and returns an absolute path
* to the downloaded file.
*
* @param artifactDetails - The information required to download the artifact
*/
function downloadArtifact(_artifactDetails) {
return __awaiter(this, void 0, void 0, function () {
var artifactDetails, fileName, url, cache, cachedPath;
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
artifactDetails = _artifactDetails.isGeneric
? __assign({}, _artifactDetails) : __assign({ platform: process.platform, arch: utils_1.getHostArch() }, _artifactDetails);
utils_1.ensureIsTruthyString(artifactDetails, 'version');
artifactDetails.version = utils_1.normalizeVersion(artifactDetails.version);
fileName = artifact_utils_1.getArtifactFileName(artifactDetails);
url = artifact_utils_1.getArtifactRemoteURL(artifactDetails);
cache = new Cache_1.Cache(artifactDetails.cacheRoot);
if (!!artifactDetails.force) return [3 /*break*/, 2];
d("Checking the cache for " + fileName + " (" + url + ")");
return [4 /*yield*/, cache.getPathForFileInCache(url, fileName)];
case 1:
cachedPath = _a.sent();
if (cachedPath === null) {
d('Cache miss');
}
else {
d('Cache hit');
return [2 /*return*/, cachedPath];
}
_a.label = 2;
case 2:
if (!artifactDetails.isGeneric &&
utils_1.isOfficialLinuxIA32Download(artifactDetails.platform, artifactDetails.arch, artifactDetails.version, artifactDetails.mirrorOptions)) {
console.warn('Official Linux/ia32 support is deprecated.');
console.warn('For more info: https://electronjs.org/blog/linux-32bit-support');
}
return [4 /*yield*/, utils_1.withTempDirectoryIn(artifactDetails.tempDirectory, function (tempFolder) { return __awaiter(_this, void 0, void 0, function () {
var tempDownloadPath, downloader, _a, shasumPath;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
tempDownloadPath = path.resolve(tempFolder, artifact_utils_1.getArtifactFileName(artifactDetails));
_a = artifactDetails.downloader;
if (_a) return [3 /*break*/, 2];
return [4 /*yield*/, downloader_resolver_1.getDownloaderForSystem()];
case 1:
_a = (_b.sent());
_b.label = 2;
case 2:
downloader = _a;
d("Downloading " + url + " to " + tempDownloadPath + " with options: " + JSON.stringify(artifactDetails.downloadOptions));
return [4 /*yield*/, downloader.download(url, tempDownloadPath, artifactDetails.downloadOptions)];
case 3:
_b.sent();
if (!(!artifactDetails.artifactName.startsWith('SHASUMS256') &&
!artifactDetails.unsafelyDisableChecksums)) return [3 /*break*/, 6];
return [4 /*yield*/, downloadArtifact({
isGeneric: true,
version: artifactDetails.version,
artifactName: 'SHASUMS256.txt',
force: artifactDetails.force,
downloadOptions: artifactDetails.downloadOptions,
downloader: artifactDetails.downloader,
mirrorOptions: artifactDetails.mirrorOptions,
})];
case 4:
shasumPath = _b.sent();
return [4 /*yield*/, sumchecker('sha256', shasumPath, path.dirname(tempDownloadPath), [
path.basename(tempDownloadPath),
])];
case 5:
_b.sent();
_b.label = 6;
case 6: return [4 /*yield*/, cache.putFileInCache(url, tempDownloadPath, fileName)];
case 7: return [2 /*return*/, _b.sent()];
}
});
}); })];
case 3: return [2 /*return*/, _a.sent()];
}
});
});
}
exports.downloadArtifact = downloadArtifact;
//# sourceMappingURL=index.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAA0B;AAC1B,2BAA6B;AAE7B,mDAA6E;AAM7E,iCAAgC;AAChC,6DAA+D;AAC/D,iCAA0C;AAC1C,iCAMiB;AAEjB,iCAAsC;AAA7B,8BAAA,WAAW,CAAA;AACpB,iCAA0C;AAAjC,kCAAA,eAAe,CAAA;AAGxB,IAAM,CAAC,GAAG,eAAK,CAAC,qBAAqB,CAAC,CAAC;AACvC,IAAM,UAAU,GAAwC,OAAO,CAAC,YAAY,CAAC,CAAC;AAE9E,IAAI,OAAO,CAAC,GAAG,CAAC,sBAAsB,EAAE;IACtC,uBAAe,EAAE,CAAC;CACnB;AAED;;;;;GAKG;AACH,SAAgB,QAAQ,CACtB,OAAe,EACf,OAAwC;IAExC,OAAO,gBAAgB,cAClB,OAAO,IACV,OAAO,SAAA,EACP,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAC1B,IAAI,EAAE,mBAAW,EAAE,EACnB,YAAY,EAAE,UAAU,IACxB,CAAC;AACL,CAAC;AAXD,4BAWC;AAED;;;;;GAKG;AACH,SAAsB,gBAAgB,CACpC,gBAA6D;;;;;;;oBAEvD,eAAe,GAA4B,gBAAgB,CAAC,SAAS;wBACzE,CAAC,cACM,gBAAgB,EAEvB,CAAC,YACG,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAC1B,IAAI,EAAE,mBAAW,EAAE,IAChB,gBAAgB,CACpB,CAAC;oBACN,4BAAoB,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC;oBACjD,eAAe,CAAC,OAAO,GAAG,wBAAgB,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;oBAE9D,QAAQ,GAAG,oCAAmB,CAAC,eAAe,CAAC,CAAC;oBAChD,GAAG,GAAG,qCAAoB,CAAC,eAAe,CAAC,CAAC;oBAC5C,KAAK,GAAG,IAAI,aAAK,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;yBAG/C,CAAC,eAAe,CAAC,KAAK,EAAtB,wBAAsB;oBACxB,CAAC,CAAC,4BAA0B,QAAQ,UAAK,GAAG,MAAG,CAAC,CAAC;oBAC9B,qBAAM,KAAK,CAAC,qBAAqB,CAAC,GAAG,EAAE,QAAQ,CAAC,EAAA;;oBAA7D,UAAU,GAAG,SAAgD;oBAEnE,IAAI,UAAU,KAAK,IAAI,EAAE;wBACvB,CAAC,CAAC,YAAY,CAAC,CAAC;qBACjB;yBAAM;wBACL,CAAC,CAAC,WAAW,CAAC,CAAC;wBACf,sBAAO,UAAU,EAAC;qBACnB;;;oBAGH,IACE,CAAC,eAAe,CAAC,SAAS;wBAC1B,mCAA2B,CACzB,eAAe,CAAC,QAAQ,EACxB,eAAe,CAAC,IAAI,EACpB,eAAe,CAAC,OAAO,EACvB,eAAe,CAAC,aAAa,CAC9B,EACD;wBACA,OAAO,CAAC,IAAI,CAAC,4CAA4C,CAAC,CAAC;wBAC3D,OAAO,CAAC,IAAI,CAAC,gEAAgE,CAAC,CAAC;qBAChF;oBAEM,qBAAM,2BAAmB,CAAC,eAAe,CAAC,aAAa,EAAE,UAAM,UAAU;;;;;wCACxE,gBAAgB,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,oCAAmB,CAAC,eAAe,CAAC,CAAC,CAAC;wCAErE,KAAA,eAAe,CAAC,UAAU,CAAA;gDAA1B,wBAA0B;wCAAK,qBAAM,4CAAsB,EAAE,EAAA;;wCAA/B,KAAA,CAAC,SAA8B,CAAC,CAAA;;;wCAA3E,UAAU,KAAiE;wCACjF,CAAC,CACC,iBAAe,GAAG,YAAO,gBAAgB,uBAAkB,IAAI,CAAC,SAAS,CACvE,eAAe,CAAC,eAAe,CAC9B,CACJ,CAAC;wCACF,qBAAM,UAAU,CAAC,QAAQ,CAAC,GAAG,EAAE,gBAAgB,EAAE,eAAe,CAAC,eAAe,CAAC,EAAA;;wCAAjF,SAAiF,CAAC;6CAIhF,CAAA,CAAC,eAAe,CAAC,YAAY,CAAC,UAAU,CAAC,YAAY,CAAC;4CACtD,CAAC,eAAe,CAAC,wBAAwB,CAAA,EADzC,wBACyC;wCAEtB,qBAAM,gBAAgB,CAAC;gDACxC,SAAS,EAAE,IAAI;gDACf,OAAO,EAAE,eAAe,CAAC,OAAO;gDAChC,YAAY,EAAE,gBAAgB;gDAC9B,KAAK,EAAE,eAAe,CAAC,KAAK;gDAC5B,eAAe,EAAE,eAAe,CAAC,eAAe;gDAChD,UAAU,EAAE,eAAe,CAAC,UAAU;gDACtC,aAAa,EAAE,eAAe,CAAC,aAAa;6CAC7C,CAAC,EAAA;;wCARI,UAAU,GAAG,SAQjB;wCAEF,qBAAM,UAAU,CAAC,QAAQ,EAAE,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE;gDACrE,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC;6CAChC,CAAC,EAAA;;wCAFF,SAEE,CAAC;;4CAGE,qBAAM,KAAK,CAAC,cAAc,CAAC,GAAG,EAAE,gBAAgB,EAAE,QAAQ,CAAC,EAAA;4CAAlE,sBAAO,SAA2D,EAAC;;;6BACpE,CAAC,EAAA;wBAhCF,sBAAO,SAgCL,EAAC;;;;CACJ;AA9ED,4CA8EC"}

View File

@ -0,0 +1,4 @@
/**
* Initializes a third-party proxy module for HTTP(S) requests.
*/
export declare function initializeProxy(): void;

View File

@ -0,0 +1,26 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var debug = require("debug");
var d = debug('@electron/get:proxy');
/**
* Initializes a third-party proxy module for HTTP(S) requests.
*/
function initializeProxy() {
try {
// Code originally from https://github.com/yeoman/yo/blob/b2eea87e/lib/cli.js#L19-L28
var MAJOR_NODEJS_VERSION = parseInt(process.version.slice(1).split('.')[0], 10);
if (MAJOR_NODEJS_VERSION >= 10) {
// `global-agent` works with Node.js v10 and above.
require('global-agent').bootstrap();
}
else {
// `global-tunnel-ng` works with Node.js v10 and below.
require('global-tunnel-ng').initialize();
}
}
catch (e) {
d('Could not load either proxy modules, built-in proxy support not available:', e);
}
}
exports.initializeProxy = initializeProxy;
//# sourceMappingURL=proxy.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"proxy.js","sourceRoot":"","sources":["../../src/proxy.ts"],"names":[],"mappings":";;AAAA,6BAA+B;AAE/B,IAAM,CAAC,GAAG,KAAK,CAAC,qBAAqB,CAAC,CAAC;AAEvC;;GAEG;AACH,SAAgB,eAAe;IAC7B,IAAI;QACF,qFAAqF;QACrF,IAAM,oBAAoB,GAAG,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAElF,IAAI,oBAAoB,IAAI,EAAE,EAAE;YAC9B,mDAAmD;YACnD,OAAO,CAAC,cAAc,CAAC,CAAC,SAAS,EAAE,CAAC;SACrC;aAAM;YACL,uDAAuD;YACvD,OAAO,CAAC,kBAAkB,CAAC,CAAC,UAAU,EAAE,CAAC;SAC1C;KACF;IAAC,OAAO,CAAC,EAAE;QACV,CAAC,CAAC,4EAA4E,EAAE,CAAC,CAAC,CAAC;KACpF;AACH,CAAC;AAfD,0CAeC"}

View File

@ -0,0 +1,93 @@
import { Downloader } from './Downloader';
export interface MirrorOptions {
/**
* The Electron nightly-specific mirror URL.
*/
nightly_mirror?: string;
mirror?: string;
customDir?: string;
customFilename?: string;
}
export interface ElectronDownloadRequest {
/**
* The version of Electron associated with the artifact.
*/
version: string;
/**
* The type of artifact. For example:
* * `electron`
* * `ffmpeg`
*/
artifactName: string;
}
export interface ElectronDownloadRequestOptions {
/**
* Whether to download an artifact regardless of whether it's in the cache directory.
*
* Defaults to `false`.
*/
force?: boolean;
/**
* When set to `true`, disables checking that the artifact download completed successfully
* with the correct payload.
*
* Defaults to `false`.
*/
unsafelyDisableChecksums?: boolean;
/**
* The directory that caches Electron artifact downloads.
*
* The default value is dependent upon the host platform:
*
* * Linux: `$XDG_CACHE_HOME` or `~/.cache/electron/`
* * MacOS: `~/Library/Caches/electron/`
* * Windows: `%LOCALAPPDATA%/electron/Cache` or `~/AppData/Local/electron/Cache/`
*/
cacheRoot?: string;
/**
* Options passed to the downloader module.
*/
downloadOptions?: DownloadOptions;
/**
* Options related to specifying an artifact mirror.
*/
mirrorOptions?: MirrorOptions;
/**
* The custom [[Downloader]] class used to download artifacts. Defaults to the
* built-in [[GotDownloader]].
*/
downloader?: Downloader<any>;
/**
* A temporary directory for downloads.
* It is used before artifacts are put into cache.
*/
tempDirectory?: string;
}
export declare type ElectronPlatformArtifactDetails = {
/**
* The target artifact platform. These are Node-style platform names, for example:
* * `win32`
* * `darwin`
* * `linux`
*/
platform: string;
/**
* The target artifact architecture. These are Node-style architecture names, for example:
* * `ia32`
* * `x64`
* * `armv7l`
*/
arch: string;
artifactSuffix?: string;
isGeneric?: false;
} & ElectronDownloadRequest & ElectronDownloadRequestOptions;
export declare type ElectronGenericArtifactDetails = {
isGeneric: true;
} & ElectronDownloadRequest & ElectronDownloadRequestOptions;
export declare type ElectronArtifactDetails = ElectronPlatformArtifactDetails | ElectronGenericArtifactDetails;
export declare type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
export declare type ElectronPlatformArtifactDetailsWithDefaults = (Omit<ElectronPlatformArtifactDetails, 'platform' | 'arch'> & {
platform?: string;
arch?: string;
}) | ElectronGenericArtifactDetails;
export declare type DownloadOptions = any;

View File

@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=types.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}

View File

@ -0,0 +1,19 @@
export declare function withTempDirectoryIn<T>(parentDirectory: string | undefined, fn: (directory: string) => Promise<T>): Promise<T>;
export declare function withTempDirectory<T>(fn: (directory: string) => Promise<T>): Promise<T>;
export declare function normalizeVersion(version: string): string;
/**
* Runs the `uname` command and returns the trimmed output.
*/
export declare function uname(): string;
/**
* Generates an architecture name that would be used in an Electron or Node.js
* download file name, from the `process` module information.
*/
export declare function getHostArch(): string;
/**
* Generates an architecture name that would be used in an Electron or Node.js
* download file name.
*/
export declare function getNodeArch(arch: string): string;
export declare function ensureIsTruthyString<T, K extends keyof T>(obj: T, key: K): void;
export declare function isOfficialLinuxIA32Download(platform: string, arch: string, version: string, mirrorOptions?: object): boolean;

View File

@ -0,0 +1,143 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
var childProcess = require("child_process");
var fs = require("fs-extra");
var os = require("os");
var path = require("path");
function useAndRemoveDirectory(directory, fn) {
return __awaiter(this, void 0, void 0, function () {
var result;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, , 2, 4]);
return [4 /*yield*/, fn(directory)];
case 1:
result = _a.sent();
return [3 /*break*/, 4];
case 2: return [4 /*yield*/, fs.remove(directory)];
case 3:
_a.sent();
return [7 /*endfinally*/];
case 4: return [2 /*return*/, result];
}
});
});
}
function withTempDirectoryIn(parentDirectory, fn) {
if (parentDirectory === void 0) { parentDirectory = os.tmpdir(); }
return __awaiter(this, void 0, void 0, function () {
var tempDirectoryPrefix, tempDirectory;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
tempDirectoryPrefix = 'electron-download-';
return [4 /*yield*/, fs.mkdtemp(path.resolve(parentDirectory, tempDirectoryPrefix))];
case 1:
tempDirectory = _a.sent();
return [2 /*return*/, useAndRemoveDirectory(tempDirectory, fn)];
}
});
});
}
exports.withTempDirectoryIn = withTempDirectoryIn;
function withTempDirectory(fn) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, withTempDirectoryIn(undefined, fn)];
});
});
}
exports.withTempDirectory = withTempDirectory;
function normalizeVersion(version) {
if (!version.startsWith('v')) {
return "v" + version;
}
return version;
}
exports.normalizeVersion = normalizeVersion;
/**
* Runs the `uname` command and returns the trimmed output.
*/
function uname() {
return childProcess
.execSync('uname -m')
.toString()
.trim();
}
exports.uname = uname;
/**
* Generates an architecture name that would be used in an Electron or Node.js
* download file name, from the `process` module information.
*/
function getHostArch() {
return getNodeArch(process.arch);
}
exports.getHostArch = getHostArch;
/**
* Generates an architecture name that would be used in an Electron or Node.js
* download file name.
*/
function getNodeArch(arch) {
if (arch === 'arm') {
switch (process.config.variables.arm_version) {
case '6':
return uname();
case '7':
return 'armv7l';
default:
break;
}
}
return arch;
}
exports.getNodeArch = getNodeArch;
function ensureIsTruthyString(obj, key) {
if (!obj[key] || typeof obj[key] !== 'string') {
throw new Error("Expected property \"" + key + "\" to be provided as a string but it was not");
}
}
exports.ensureIsTruthyString = ensureIsTruthyString;
function isOfficialLinuxIA32Download(platform, arch, version, mirrorOptions) {
return (platform === 'linux' &&
arch === 'ia32' &&
Number(version.slice(1).split('.')[0]) >= 4 &&
typeof mirrorOptions === 'undefined');
}
exports.isOfficialLinuxIA32Download = isOfficialLinuxIA32Download;
//# sourceMappingURL=utils.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAA8C;AAC9C,6BAA+B;AAC/B,uBAAyB;AACzB,2BAA6B;AAE7B,SAAe,qBAAqB,CAClC,SAAiB,EACjB,EAAqC;;;;;;;oBAI1B,qBAAM,EAAE,CAAC,SAAS,CAAC,EAAA;;oBAA5B,MAAM,GAAG,SAAmB,CAAC;;wBAE7B,qBAAM,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,EAAA;;oBAA1B,SAA0B,CAAC;;wBAE7B,sBAAO,MAAM,EAAC;;;;CACf;AAED,SAAsB,mBAAmB,CACvC,eAAqC,EACrC,EAAqC;IADrC,gCAAA,EAAA,kBAA0B,EAAE,CAAC,MAAM,EAAE;;;;;;oBAG/B,mBAAmB,GAAG,oBAAoB,CAAC;oBAC3B,qBAAM,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,mBAAmB,CAAC,CAAC,EAAA;;oBAApF,aAAa,GAAG,SAAoE;oBAC1F,sBAAO,qBAAqB,CAAC,aAAa,EAAE,EAAE,CAAC,EAAC;;;;CACjD;AAPD,kDAOC;AAED,SAAsB,iBAAiB,CAAI,EAAqC;;;YAC9E,sBAAO,mBAAmB,CAAC,SAAS,EAAE,EAAE,CAAC,EAAC;;;CAC3C;AAFD,8CAEC;AAED,SAAgB,gBAAgB,CAAC,OAAe;IAC9C,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;QAC5B,OAAO,MAAI,OAAS,CAAC;KACtB;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AALD,4CAKC;AAED;;GAEG;AACH,SAAgB,KAAK;IACnB,OAAO,YAAY;SAChB,QAAQ,CAAC,UAAU,CAAC;SACpB,QAAQ,EAAE;SACV,IAAI,EAAE,CAAC;AACZ,CAAC;AALD,sBAKC;AAED;;;GAGG;AACH,SAAgB,WAAW;IACzB,OAAO,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AACnC,CAAC;AAFD,kCAEC;AAED;;;GAGG;AACH,SAAgB,WAAW,CAAC,IAAY;IACtC,IAAI,IAAI,KAAK,KAAK,EAAE;QAClB,QAAS,OAAO,CAAC,MAAM,CAAC,SAAiB,CAAC,WAAW,EAAE;YACrD,KAAK,GAAG;gBACN,OAAO,KAAK,EAAE,CAAC;YACjB,KAAK,GAAG;gBACN,OAAO,QAAQ,CAAC;YAClB;gBACE,MAAM;SACT;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAbD,kCAaC;AAED,SAAgB,oBAAoB,CAAuB,GAAM,EAAE,GAAM;IACvE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,OAAO,GAAG,CAAC,GAAG,CAAC,KAAK,QAAQ,EAAE;QAC7C,MAAM,IAAI,KAAK,CAAC,yBAAsB,GAAG,iDAA6C,CAAC,CAAC;KACzF;AACH,CAAC;AAJD,oDAIC;AAED,SAAgB,2BAA2B,CACzC,QAAgB,EAChB,IAAY,EACZ,OAAe,EACf,aAAsB;IAEtB,OAAO,CACL,QAAQ,KAAK,OAAO;QACpB,IAAI,KAAK,MAAM;QACf,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAC3C,OAAO,aAAa,KAAK,WAAW,CACrC,CAAC;AACJ,CAAC;AAZD,kEAYC"}

View File

@ -0,0 +1,7 @@
export declare class Cache {
private cacheRoot;
constructor(cacheRoot?: string);
private getCachePath;
getPathForFileInCache(url: string, fileName: string): Promise<string | null>;
putFileInCache(url: string, currentPath: string, fileName: string): Promise<string>;
}

View File

@ -0,0 +1,98 @@
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
import debug from 'debug';
import envPaths from 'env-paths';
import * as fs from 'fs-extra';
import * as path from 'path';
import * as sanitize from 'sanitize-filename';
var d = debug('@electron/get:cache');
var defaultCacheRoot = envPaths('electron', {
suffix: '',
}).cache;
var Cache = /** @class */ (function () {
function Cache(cacheRoot) {
if (cacheRoot === void 0) { cacheRoot = defaultCacheRoot; }
this.cacheRoot = cacheRoot;
}
Cache.prototype.getCachePath = function (url, fileName) {
var sanitizedUrl = sanitize(url);
return path.resolve(this.cacheRoot, sanitizedUrl, fileName);
};
Cache.prototype.getPathForFileInCache = function (url, fileName) {
return __awaiter(this, void 0, void 0, function () {
var cachePath;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
cachePath = this.getCachePath(url, fileName);
return [4 /*yield*/, fs.pathExists(cachePath)];
case 1:
if (_a.sent()) {
return [2 /*return*/, cachePath];
}
return [2 /*return*/, null];
}
});
});
};
Cache.prototype.putFileInCache = function (url, currentPath, fileName) {
return __awaiter(this, void 0, void 0, function () {
var cachePath;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
cachePath = this.getCachePath(url, fileName);
d("Moving " + currentPath + " to " + cachePath);
return [4 /*yield*/, fs.pathExists(cachePath)];
case 1:
if (!_a.sent()) return [3 /*break*/, 3];
d('* Replacing existing file');
return [4 /*yield*/, fs.remove(cachePath)];
case 2:
_a.sent();
_a.label = 3;
case 3: return [4 /*yield*/, fs.move(currentPath, cachePath)];
case 4:
_a.sent();
return [2 /*return*/, cachePath];
}
});
});
};
return Cache;
}());
export { Cache };
//# sourceMappingURL=Cache.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"Cache.js","sourceRoot":"","sources":["../../src/Cache.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,QAAQ,MAAM,WAAW,CAAC;AACjC,OAAO,KAAK,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,QAAQ,MAAM,mBAAmB,CAAC;AAE9C,IAAM,CAAC,GAAG,KAAK,CAAC,qBAAqB,CAAC,CAAC;AAEvC,IAAM,gBAAgB,GAAG,QAAQ,CAAC,UAAU,EAAE;IAC5C,MAAM,EAAE,EAAE;CACX,CAAC,CAAC,KAAK,CAAC;AAET;IACE,eAAoB,SAA4B;QAA5B,0BAAA,EAAA,4BAA4B;QAA5B,cAAS,GAAT,SAAS,CAAmB;IAAG,CAAC;IAE5C,4BAAY,GAApB,UAAqB,GAAW,EAAE,QAAgB;QAChD,IAAM,YAAY,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;QACnC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAC;IAC9D,CAAC;IAEY,qCAAqB,GAAlC,UAAmC,GAAW,EAAE,QAAgB;;;;;;wBACxD,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;wBAC/C,qBAAM,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAA;;wBAAlC,IAAI,SAA8B,EAAE;4BAClC,sBAAO,SAAS,EAAC;yBAClB;wBAED,sBAAO,IAAI,EAAC;;;;KACb;IAEY,8BAAc,GAA3B,UAA4B,GAAW,EAAE,WAAmB,EAAE,QAAgB;;;;;;wBACtE,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;wBACnD,CAAC,CAAC,YAAU,WAAW,YAAO,SAAW,CAAC,CAAC;wBACvC,qBAAM,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAA;;6BAA9B,SAA8B,EAA9B,wBAA8B;wBAChC,CAAC,CAAC,2BAA2B,CAAC,CAAC;wBAC/B,qBAAM,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,EAAA;;wBAA1B,SAA0B,CAAC;;4BAG7B,qBAAM,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,EAAA;;wBAArC,SAAqC,CAAC;wBAEtC,sBAAO,SAAS,EAAC;;;;KAClB;IACH,YAAC;AAAD,CAAC,AA7BD,IA6BC"}

View File

@ -0,0 +1,3 @@
export interface Downloader<T> {
download(url: string, targetFilePath: string, options: T): Promise<void>;
}

View File

@ -0,0 +1 @@
//# sourceMappingURL=Downloader.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"Downloader.js","sourceRoot":"","sources":["../../src/Downloader.ts"],"names":[],"mappings":""}

View File

@ -0,0 +1,7 @@
import { Downloader } from './Downloader';
export declare class GotDownloader implements Downloader<any> {
/**
* @param options - see [`got#options`](https://github.com/sindresorhus/got#options) for possible keys/values.
*/
download(url: string, targetFilePath: string, options?: any): Promise<void>;
}

View File

@ -0,0 +1,71 @@
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
import * as fs from 'fs-extra';
import * as got from 'got';
import * as path from 'path';
var GotDownloader = /** @class */ (function () {
function GotDownloader() {
}
/**
* @param options - see [`got#options`](https://github.com/sindresorhus/got#options) for possible keys/values.
*/
GotDownloader.prototype.download = function (url, targetFilePath, options) {
return __awaiter(this, void 0, void 0, function () {
var writeStream;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, fs.mkdirp(path.dirname(targetFilePath))];
case 1:
_a.sent();
writeStream = fs.createWriteStream(targetFilePath);
return [4 /*yield*/, new Promise(function (resolve, reject) {
var downloadStream = got.stream(url, options);
downloadStream.pipe(writeStream);
downloadStream.on('error', function (error) { return reject(error); });
writeStream.on('error', function (error) { return reject(error); });
writeStream.on('close', function () { return resolve(); });
})];
case 2:
_a.sent();
return [2 /*return*/];
}
});
});
};
return GotDownloader;
}());
export { GotDownloader };
//# sourceMappingURL=GotDownloader.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"GotDownloader.js","sourceRoot":"","sources":["../../src/GotDownloader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAC3B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAI7B;IAAA;IAgBA,CAAC;IAfC;;OAEG;IACG,gCAAQ,GAAd,UAAe,GAAW,EAAE,cAAsB,EAAE,OAAa;;;;;4BAC/D,qBAAM,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,EAAA;;wBAA7C,SAA6C,CAAC;wBACxC,WAAW,GAAG,EAAE,CAAC,iBAAiB,CAAC,cAAc,CAAC,CAAC;wBACzD,qBAAM,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;gCAChC,IAAM,cAAc,GAAG,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;gCAChD,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;gCAEjC,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,UAAA,KAAK,IAAI,OAAA,MAAM,CAAC,KAAK,CAAC,EAAb,CAAa,CAAC,CAAC;gCACnD,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,UAAA,KAAK,IAAI,OAAA,MAAM,CAAC,KAAK,CAAC,EAAb,CAAa,CAAC,CAAC;gCAChD,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,cAAM,OAAA,OAAO,EAAE,EAAT,CAAS,CAAC,CAAC;4BAC3C,CAAC,CAAC,EAAA;;wBAPF,SAOE,CAAC;;;;;KACJ;IACH,oBAAC;AAAD,CAAC,AAhBD,IAgBC"}

View File

@ -0,0 +1,3 @@
import { ElectronArtifactDetails } from './types';
export declare function getArtifactFileName(details: ElectronArtifactDetails): string;
export declare function getArtifactRemoteURL(details: ElectronArtifactDetails): string;

View File

@ -0,0 +1,39 @@
import { ensureIsTruthyString } from './utils';
var BASE_URL = 'https://github.com/electron/electron/releases/download/';
var NIGHTLY_BASE_URL = 'https://github.com/electron/nightlies/releases/download/';
export function getArtifactFileName(details) {
ensureIsTruthyString(details, 'artifactName');
if (details.isGeneric) {
return details.artifactName;
}
ensureIsTruthyString(details, 'arch');
ensureIsTruthyString(details, 'platform');
ensureIsTruthyString(details, 'version');
return [
details.artifactName,
details.version,
details.platform,
details.arch
].concat((details.artifactSuffix ? [details.artifactSuffix] : [])).join('-') + ".zip";
}
function mirrorVar(name, options, defaultValue) {
// Convert camelCase to camel_case for env var reading
var lowerName = name.replace(/([a-z])([A-Z])/g, function (_, a, b) { return a + "_" + b; }).toLowerCase();
return (process.env["NPM_CONFIG_ELECTRON_" + lowerName.toUpperCase()] ||
process.env["npm_config_electron_" + lowerName] ||
process.env["npm_package_config_electron_" + lowerName] ||
process.env["ELECTRON_" + lowerName.toUpperCase()] ||
options[name] ||
defaultValue);
}
export function getArtifactRemoteURL(details) {
var opts = details.mirrorOptions || {};
var base = mirrorVar('mirror', opts, BASE_URL);
if (details.version.includes('nightly')) {
base = mirrorVar('nightly_mirror', opts, NIGHTLY_BASE_URL);
}
var path = mirrorVar('customDir', opts, details.version);
var file = mirrorVar('customFilename', opts, getArtifactFileName(details));
return "" + base + path + "/" + file;
}
//# sourceMappingURL=artifact-utils.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"artifact-utils.js","sourceRoot":"","sources":["../../src/artifact-utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAE/C,IAAM,QAAQ,GAAG,yDAAyD,CAAC;AAC3E,IAAM,gBAAgB,GAAG,0DAA0D,CAAC;AAEpF,MAAM,UAAU,mBAAmB,CAAC,OAAgC;IAClE,oBAAoB,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IAE9C,IAAI,OAAO,CAAC,SAAS,EAAE;QACrB,OAAO,OAAO,CAAC,YAAY,CAAC;KAC7B;IAED,oBAAoB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACtC,oBAAoB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IAC1C,oBAAoB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IAEzC,OAAU;QACR,OAAO,CAAC,YAAY;QACpB,OAAO,CAAC,OAAO;QACf,OAAO,CAAC,QAAQ;QAChB,OAAO,CAAC,IAAI;aACT,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAC3D,IAAI,CAAC,GAAG,CAAC,SAAM,CAAC;AACpB,CAAC;AAED,SAAS,SAAS,CAAC,IAAyB,EAAE,OAAsB,EAAE,YAAoB;IACxF,sDAAsD;IACtD,IAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE,UAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAK,OAAG,CAAC,SAAI,CAAG,EAAX,CAAW,CAAC,CAAC,WAAW,EAAE,CAAC;IAE1F,OAAO,CACL,OAAO,CAAC,GAAG,CAAC,yBAAuB,SAAS,CAAC,WAAW,EAAI,CAAC;QAC7D,OAAO,CAAC,GAAG,CAAC,yBAAuB,SAAW,CAAC;QAC/C,OAAO,CAAC,GAAG,CAAC,iCAA+B,SAAW,CAAC;QACvD,OAAO,CAAC,GAAG,CAAC,cAAY,SAAS,CAAC,WAAW,EAAI,CAAC;QAClD,OAAO,CAAC,IAAI,CAAC;QACb,YAAY,CACb,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,OAAgC;IACnE,IAAM,IAAI,GAAkB,OAAO,CAAC,aAAa,IAAI,EAAE,CAAC;IACxD,IAAI,IAAI,GAAG,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC/C,IAAI,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;QACvC,IAAI,GAAG,SAAS,CAAC,gBAAgB,EAAE,IAAI,EAAE,gBAAgB,CAAC,CAAC;KAC5D;IACD,IAAM,IAAI,GAAG,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAC3D,IAAM,IAAI,GAAG,SAAS,CAAC,gBAAgB,EAAE,IAAI,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC;IAE7E,OAAO,KAAG,IAAI,GAAG,IAAI,SAAI,IAAM,CAAC;AAClC,CAAC"}

View File

@ -0,0 +1,2 @@
import { Downloader } from './Downloader';
export declare function getDownloaderForSystem(): Promise<Downloader<any>>;

View File

@ -0,0 +1,49 @@
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
export function getDownloaderForSystem() {
return __awaiter(this, void 0, void 0, function () {
var GotDownloader;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, import('./GotDownloader')];
case 1:
GotDownloader = (_a.sent()).GotDownloader;
return [2 /*return*/, new GotDownloader()];
}
});
});
}
//# sourceMappingURL=downloader-resolver.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"downloader-resolver.js","sourceRoot":"","sources":["../../src/downloader-resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,MAAM,UAAgB,sBAAsB;;;;;wBAKhB,qBAAM,MAAM,CAAC,iBAAiB,CAAC,EAAA;;oBAAjD,aAAa,GAAK,CAAA,SAA+B,CAAA,cAApC;oBACrB,sBAAO,IAAI,aAAa,EAAE,EAAC;;;;CAC5B"}

View File

@ -0,0 +1,18 @@
import { ElectronDownloadRequestOptions, ElectronPlatformArtifactDetailsWithDefaults } from './types';
export { getHostArch } from './utils';
export { initializeProxy } from './proxy';
export * from './types';
/**
* Downloads a specific version of Electron and returns an absolute path to a
* ZIP file.
*
* @param version - The version of Electron you want to download
*/
export declare function download(version: string, options?: ElectronDownloadRequestOptions): Promise<string>;
/**
* Downloads an artifact from an Electron release and returns an absolute path
* to the downloaded file.
*
* @param artifactDetails - The information required to download the artifact
*/
export declare function downloadArtifact(_artifactDetails: ElectronPlatformArtifactDetailsWithDefaults): Promise<string>;

View File

@ -0,0 +1,156 @@
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
import debug from 'debug';
import * as path from 'path';
import { getArtifactFileName, getArtifactRemoteURL } from './artifact-utils';
import { Cache } from './Cache';
import { getDownloaderForSystem } from './downloader-resolver';
import { initializeProxy } from './proxy';
import { withTempDirectoryIn, normalizeVersion, getHostArch, ensureIsTruthyString, isOfficialLinuxIA32Download, } from './utils';
export { getHostArch } from './utils';
export { initializeProxy } from './proxy';
var d = debug('@electron/get:index');
var sumchecker = require('sumchecker');
if (process.env.ELECTRON_GET_USE_PROXY) {
initializeProxy();
}
/**
* Downloads a specific version of Electron and returns an absolute path to a
* ZIP file.
*
* @param version - The version of Electron you want to download
*/
export function download(version, options) {
return downloadArtifact(__assign({}, options, { version: version, platform: process.platform, arch: getHostArch(), artifactName: 'electron' }));
}
/**
* Downloads an artifact from an Electron release and returns an absolute path
* to the downloaded file.
*
* @param artifactDetails - The information required to download the artifact
*/
export function downloadArtifact(_artifactDetails) {
return __awaiter(this, void 0, void 0, function () {
var artifactDetails, fileName, url, cache, cachedPath;
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
artifactDetails = _artifactDetails.isGeneric
? __assign({}, _artifactDetails) : __assign({ platform: process.platform, arch: getHostArch() }, _artifactDetails);
ensureIsTruthyString(artifactDetails, 'version');
artifactDetails.version = normalizeVersion(artifactDetails.version);
fileName = getArtifactFileName(artifactDetails);
url = getArtifactRemoteURL(artifactDetails);
cache = new Cache(artifactDetails.cacheRoot);
if (!!artifactDetails.force) return [3 /*break*/, 2];
d("Checking the cache for " + fileName + " (" + url + ")");
return [4 /*yield*/, cache.getPathForFileInCache(url, fileName)];
case 1:
cachedPath = _a.sent();
if (cachedPath === null) {
d('Cache miss');
}
else {
d('Cache hit');
return [2 /*return*/, cachedPath];
}
_a.label = 2;
case 2:
if (!artifactDetails.isGeneric &&
isOfficialLinuxIA32Download(artifactDetails.platform, artifactDetails.arch, artifactDetails.version, artifactDetails.mirrorOptions)) {
console.warn('Official Linux/ia32 support is deprecated.');
console.warn('For more info: https://electronjs.org/blog/linux-32bit-support');
}
return [4 /*yield*/, withTempDirectoryIn(artifactDetails.tempDirectory, function (tempFolder) { return __awaiter(_this, void 0, void 0, function () {
var tempDownloadPath, downloader, _a, shasumPath;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
tempDownloadPath = path.resolve(tempFolder, getArtifactFileName(artifactDetails));
_a = artifactDetails.downloader;
if (_a) return [3 /*break*/, 2];
return [4 /*yield*/, getDownloaderForSystem()];
case 1:
_a = (_b.sent());
_b.label = 2;
case 2:
downloader = _a;
d("Downloading " + url + " to " + tempDownloadPath + " with options: " + JSON.stringify(artifactDetails.downloadOptions));
return [4 /*yield*/, downloader.download(url, tempDownloadPath, artifactDetails.downloadOptions)];
case 3:
_b.sent();
if (!(!artifactDetails.artifactName.startsWith('SHASUMS256') &&
!artifactDetails.unsafelyDisableChecksums)) return [3 /*break*/, 6];
return [4 /*yield*/, downloadArtifact({
isGeneric: true,
version: artifactDetails.version,
artifactName: 'SHASUMS256.txt',
force: artifactDetails.force,
downloadOptions: artifactDetails.downloadOptions,
downloader: artifactDetails.downloader,
mirrorOptions: artifactDetails.mirrorOptions,
})];
case 4:
shasumPath = _b.sent();
return [4 /*yield*/, sumchecker('sha256', shasumPath, path.dirname(tempDownloadPath), [
path.basename(tempDownloadPath),
])];
case 5:
_b.sent();
_b.label = 6;
case 6: return [4 /*yield*/, cache.putFileInCache(url, tempDownloadPath, fileName)];
case 7: return [2 /*return*/, _b.sent()];
}
});
}); })];
case 3: return [2 /*return*/, _a.sent()];
}
});
});
}
//# sourceMappingURL=index.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAM7E,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,EACX,oBAAoB,EACpB,2BAA2B,GAC5B,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAG1C,IAAM,CAAC,GAAG,KAAK,CAAC,qBAAqB,CAAC,CAAC;AACvC,IAAM,UAAU,GAAwC,OAAO,CAAC,YAAY,CAAC,CAAC;AAE9E,IAAI,OAAO,CAAC,GAAG,CAAC,sBAAsB,EAAE;IACtC,eAAe,EAAE,CAAC;CACnB;AAED;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CACtB,OAAe,EACf,OAAwC;IAExC,OAAO,gBAAgB,cAClB,OAAO,IACV,OAAO,SAAA,EACP,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAC1B,IAAI,EAAE,WAAW,EAAE,EACnB,YAAY,EAAE,UAAU,IACxB,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAgB,gBAAgB,CACpC,gBAA6D;;;;;;;oBAEvD,eAAe,GAA4B,gBAAgB,CAAC,SAAS;wBACzE,CAAC,cACM,gBAAgB,EAEvB,CAAC,YACG,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAC1B,IAAI,EAAE,WAAW,EAAE,IAChB,gBAAgB,CACpB,CAAC;oBACN,oBAAoB,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC;oBACjD,eAAe,CAAC,OAAO,GAAG,gBAAgB,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;oBAE9D,QAAQ,GAAG,mBAAmB,CAAC,eAAe,CAAC,CAAC;oBAChD,GAAG,GAAG,oBAAoB,CAAC,eAAe,CAAC,CAAC;oBAC5C,KAAK,GAAG,IAAI,KAAK,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;yBAG/C,CAAC,eAAe,CAAC,KAAK,EAAtB,wBAAsB;oBACxB,CAAC,CAAC,4BAA0B,QAAQ,UAAK,GAAG,MAAG,CAAC,CAAC;oBAC9B,qBAAM,KAAK,CAAC,qBAAqB,CAAC,GAAG,EAAE,QAAQ,CAAC,EAAA;;oBAA7D,UAAU,GAAG,SAAgD;oBAEnE,IAAI,UAAU,KAAK,IAAI,EAAE;wBACvB,CAAC,CAAC,YAAY,CAAC,CAAC;qBACjB;yBAAM;wBACL,CAAC,CAAC,WAAW,CAAC,CAAC;wBACf,sBAAO,UAAU,EAAC;qBACnB;;;oBAGH,IACE,CAAC,eAAe,CAAC,SAAS;wBAC1B,2BAA2B,CACzB,eAAe,CAAC,QAAQ,EACxB,eAAe,CAAC,IAAI,EACpB,eAAe,CAAC,OAAO,EACvB,eAAe,CAAC,aAAa,CAC9B,EACD;wBACA,OAAO,CAAC,IAAI,CAAC,4CAA4C,CAAC,CAAC;wBAC3D,OAAO,CAAC,IAAI,CAAC,gEAAgE,CAAC,CAAC;qBAChF;oBAEM,qBAAM,mBAAmB,CAAC,eAAe,CAAC,aAAa,EAAE,UAAM,UAAU;;;;;wCACxE,gBAAgB,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,mBAAmB,CAAC,eAAe,CAAC,CAAC,CAAC;wCAErE,KAAA,eAAe,CAAC,UAAU,CAAA;gDAA1B,wBAA0B;wCAAK,qBAAM,sBAAsB,EAAE,EAAA;;wCAA/B,KAAA,CAAC,SAA8B,CAAC,CAAA;;;wCAA3E,UAAU,KAAiE;wCACjF,CAAC,CACC,iBAAe,GAAG,YAAO,gBAAgB,uBAAkB,IAAI,CAAC,SAAS,CACvE,eAAe,CAAC,eAAe,CAC9B,CACJ,CAAC;wCACF,qBAAM,UAAU,CAAC,QAAQ,CAAC,GAAG,EAAE,gBAAgB,EAAE,eAAe,CAAC,eAAe,CAAC,EAAA;;wCAAjF,SAAiF,CAAC;6CAIhF,CAAA,CAAC,eAAe,CAAC,YAAY,CAAC,UAAU,CAAC,YAAY,CAAC;4CACtD,CAAC,eAAe,CAAC,wBAAwB,CAAA,EADzC,wBACyC;wCAEtB,qBAAM,gBAAgB,CAAC;gDACxC,SAAS,EAAE,IAAI;gDACf,OAAO,EAAE,eAAe,CAAC,OAAO;gDAChC,YAAY,EAAE,gBAAgB;gDAC9B,KAAK,EAAE,eAAe,CAAC,KAAK;gDAC5B,eAAe,EAAE,eAAe,CAAC,eAAe;gDAChD,UAAU,EAAE,eAAe,CAAC,UAAU;gDACtC,aAAa,EAAE,eAAe,CAAC,aAAa;6CAC7C,CAAC,EAAA;;wCARI,UAAU,GAAG,SAQjB;wCAEF,qBAAM,UAAU,CAAC,QAAQ,EAAE,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE;gDACrE,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC;6CAChC,CAAC,EAAA;;wCAFF,SAEE,CAAC;;4CAGE,qBAAM,KAAK,CAAC,cAAc,CAAC,GAAG,EAAE,gBAAgB,EAAE,QAAQ,CAAC,EAAA;4CAAlE,sBAAO,SAA2D,EAAC;;;6BACpE,CAAC,EAAA;wBAhCF,sBAAO,SAgCL,EAAC;;;;CACJ"}

View File

@ -0,0 +1,4 @@
/**
* Initializes a third-party proxy module for HTTP(S) requests.
*/
export declare function initializeProxy(): void;

View File

@ -0,0 +1,23 @@
import * as debug from 'debug';
var d = debug('@electron/get:proxy');
/**
* Initializes a third-party proxy module for HTTP(S) requests.
*/
export function initializeProxy() {
try {
// Code originally from https://github.com/yeoman/yo/blob/b2eea87e/lib/cli.js#L19-L28
var MAJOR_NODEJS_VERSION = parseInt(process.version.slice(1).split('.')[0], 10);
if (MAJOR_NODEJS_VERSION >= 10) {
// `global-agent` works with Node.js v10 and above.
require('global-agent').bootstrap();
}
else {
// `global-tunnel-ng` works with Node.js v10 and below.
require('global-tunnel-ng').initialize();
}
}
catch (e) {
d('Could not load either proxy modules, built-in proxy support not available:', e);
}
}
//# sourceMappingURL=proxy.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"proxy.js","sourceRoot":"","sources":["../../src/proxy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,IAAM,CAAC,GAAG,KAAK,CAAC,qBAAqB,CAAC,CAAC;AAEvC;;GAEG;AACH,MAAM,UAAU,eAAe;IAC7B,IAAI;QACF,qFAAqF;QACrF,IAAM,oBAAoB,GAAG,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAElF,IAAI,oBAAoB,IAAI,EAAE,EAAE;YAC9B,mDAAmD;YACnD,OAAO,CAAC,cAAc,CAAC,CAAC,SAAS,EAAE,CAAC;SACrC;aAAM;YACL,uDAAuD;YACvD,OAAO,CAAC,kBAAkB,CAAC,CAAC,UAAU,EAAE,CAAC;SAC1C;KACF;IAAC,OAAO,CAAC,EAAE;QACV,CAAC,CAAC,4EAA4E,EAAE,CAAC,CAAC,CAAC;KACpF;AACH,CAAC"}

View File

@ -0,0 +1,93 @@
import { Downloader } from './Downloader';
export interface MirrorOptions {
/**
* The Electron nightly-specific mirror URL.
*/
nightly_mirror?: string;
mirror?: string;
customDir?: string;
customFilename?: string;
}
export interface ElectronDownloadRequest {
/**
* The version of Electron associated with the artifact.
*/
version: string;
/**
* The type of artifact. For example:
* * `electron`
* * `ffmpeg`
*/
artifactName: string;
}
export interface ElectronDownloadRequestOptions {
/**
* Whether to download an artifact regardless of whether it's in the cache directory.
*
* Defaults to `false`.
*/
force?: boolean;
/**
* When set to `true`, disables checking that the artifact download completed successfully
* with the correct payload.
*
* Defaults to `false`.
*/
unsafelyDisableChecksums?: boolean;
/**
* The directory that caches Electron artifact downloads.
*
* The default value is dependent upon the host platform:
*
* * Linux: `$XDG_CACHE_HOME` or `~/.cache/electron/`
* * MacOS: `~/Library/Caches/electron/`
* * Windows: `%LOCALAPPDATA%/electron/Cache` or `~/AppData/Local/electron/Cache/`
*/
cacheRoot?: string;
/**
* Options passed to the downloader module.
*/
downloadOptions?: DownloadOptions;
/**
* Options related to specifying an artifact mirror.
*/
mirrorOptions?: MirrorOptions;
/**
* The custom [[Downloader]] class used to download artifacts. Defaults to the
* built-in [[GotDownloader]].
*/
downloader?: Downloader<any>;
/**
* A temporary directory for downloads.
* It is used before artifacts are put into cache.
*/
tempDirectory?: string;
}
export declare type ElectronPlatformArtifactDetails = {
/**
* The target artifact platform. These are Node-style platform names, for example:
* * `win32`
* * `darwin`
* * `linux`
*/
platform: string;
/**
* The target artifact architecture. These are Node-style architecture names, for example:
* * `ia32`
* * `x64`
* * `armv7l`
*/
arch: string;
artifactSuffix?: string;
isGeneric?: false;
} & ElectronDownloadRequest & ElectronDownloadRequestOptions;
export declare type ElectronGenericArtifactDetails = {
isGeneric: true;
} & ElectronDownloadRequest & ElectronDownloadRequestOptions;
export declare type ElectronArtifactDetails = ElectronPlatformArtifactDetails | ElectronGenericArtifactDetails;
export declare type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
export declare type ElectronPlatformArtifactDetailsWithDefaults = (Omit<ElectronPlatformArtifactDetails, 'platform' | 'arch'> & {
platform?: string;
arch?: string;
}) | ElectronGenericArtifactDetails;
export declare type DownloadOptions = any;

View File

@ -0,0 +1 @@
//# sourceMappingURL=types.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}

View File

@ -0,0 +1,19 @@
export declare function withTempDirectoryIn<T>(parentDirectory: string | undefined, fn: (directory: string) => Promise<T>): Promise<T>;
export declare function withTempDirectory<T>(fn: (directory: string) => Promise<T>): Promise<T>;
export declare function normalizeVersion(version: string): string;
/**
* Runs the `uname` command and returns the trimmed output.
*/
export declare function uname(): string;
/**
* Generates an architecture name that would be used in an Electron or Node.js
* download file name, from the `process` module information.
*/
export declare function getHostArch(): string;
/**
* Generates an architecture name that would be used in an Electron or Node.js
* download file name.
*/
export declare function getNodeArch(arch: string): string;
export declare function ensureIsTruthyString<T, K extends keyof T>(obj: T, key: K): void;
export declare function isOfficialLinuxIA32Download(platform: string, arch: string, version: string, mirrorOptions?: object): boolean;

View File

@ -0,0 +1,133 @@
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
import * as childProcess from 'child_process';
import * as fs from 'fs-extra';
import * as os from 'os';
import * as path from 'path';
function useAndRemoveDirectory(directory, fn) {
return __awaiter(this, void 0, void 0, function () {
var result;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, , 2, 4]);
return [4 /*yield*/, fn(directory)];
case 1:
result = _a.sent();
return [3 /*break*/, 4];
case 2: return [4 /*yield*/, fs.remove(directory)];
case 3:
_a.sent();
return [7 /*endfinally*/];
case 4: return [2 /*return*/, result];
}
});
});
}
export function withTempDirectoryIn(parentDirectory, fn) {
if (parentDirectory === void 0) { parentDirectory = os.tmpdir(); }
return __awaiter(this, void 0, void 0, function () {
var tempDirectoryPrefix, tempDirectory;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
tempDirectoryPrefix = 'electron-download-';
return [4 /*yield*/, fs.mkdtemp(path.resolve(parentDirectory, tempDirectoryPrefix))];
case 1:
tempDirectory = _a.sent();
return [2 /*return*/, useAndRemoveDirectory(tempDirectory, fn)];
}
});
});
}
export function withTempDirectory(fn) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, withTempDirectoryIn(undefined, fn)];
});
});
}
export function normalizeVersion(version) {
if (!version.startsWith('v')) {
return "v" + version;
}
return version;
}
/**
* Runs the `uname` command and returns the trimmed output.
*/
export function uname() {
return childProcess
.execSync('uname -m')
.toString()
.trim();
}
/**
* Generates an architecture name that would be used in an Electron or Node.js
* download file name, from the `process` module information.
*/
export function getHostArch() {
return getNodeArch(process.arch);
}
/**
* Generates an architecture name that would be used in an Electron or Node.js
* download file name.
*/
export function getNodeArch(arch) {
if (arch === 'arm') {
switch (process.config.variables.arm_version) {
case '6':
return uname();
case '7':
return 'armv7l';
default:
break;
}
}
return arch;
}
export function ensureIsTruthyString(obj, key) {
if (!obj[key] || typeof obj[key] !== 'string') {
throw new Error("Expected property \"" + key + "\" to be provided as a string but it was not");
}
}
export function isOfficialLinuxIA32Download(platform, arch, version, mirrorOptions) {
return (platform === 'linux' &&
arch === 'ia32' &&
Number(version.slice(1).split('.')[0]) >= 4 &&
typeof mirrorOptions === 'undefined');
}
//# sourceMappingURL=utils.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,YAAY,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,SAAe,qBAAqB,CAClC,SAAiB,EACjB,EAAqC;;;;;;;oBAI1B,qBAAM,EAAE,CAAC,SAAS,CAAC,EAAA;;oBAA5B,MAAM,GAAG,SAAmB,CAAC;;wBAE7B,qBAAM,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,EAAA;;oBAA1B,SAA0B,CAAC;;wBAE7B,sBAAO,MAAM,EAAC;;;;CACf;AAED,MAAM,UAAgB,mBAAmB,CACvC,eAAqC,EACrC,EAAqC;IADrC,gCAAA,EAAA,kBAA0B,EAAE,CAAC,MAAM,EAAE;;;;;;oBAG/B,mBAAmB,GAAG,oBAAoB,CAAC;oBAC3B,qBAAM,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,mBAAmB,CAAC,CAAC,EAAA;;oBAApF,aAAa,GAAG,SAAoE;oBAC1F,sBAAO,qBAAqB,CAAC,aAAa,EAAE,EAAE,CAAC,EAAC;;;;CACjD;AAED,MAAM,UAAgB,iBAAiB,CAAI,EAAqC;;;YAC9E,sBAAO,mBAAmB,CAAC,SAAS,EAAE,EAAE,CAAC,EAAC;;;CAC3C;AAED,MAAM,UAAU,gBAAgB,CAAC,OAAe;IAC9C,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;QAC5B,OAAO,MAAI,OAAS,CAAC;KACtB;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,KAAK;IACnB,OAAO,YAAY;SAChB,QAAQ,CAAC,UAAU,CAAC;SACpB,QAAQ,EAAE;SACV,IAAI,EAAE,CAAC;AACZ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW;IACzB,OAAO,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AACnC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,IAAI,IAAI,KAAK,KAAK,EAAE;QAClB,QAAS,OAAO,CAAC,MAAM,CAAC,SAAiB,CAAC,WAAW,EAAE;YACrD,KAAK,GAAG;gBACN,OAAO,KAAK,EAAE,CAAC;YACjB,KAAK,GAAG;gBACN,OAAO,QAAQ,CAAC;YAClB;gBACE,MAAM;SACT;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAuB,GAAM,EAAE,GAAM;IACvE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,OAAO,GAAG,CAAC,GAAG,CAAC,KAAK,QAAQ,EAAE;QAC7C,MAAM,IAAI,KAAK,CAAC,yBAAsB,GAAG,iDAA6C,CAAC,CAAC;KACzF;AACH,CAAC;AAED,MAAM,UAAU,2BAA2B,CACzC,QAAgB,EAChB,IAAY,EACZ,OAAe,EACf,aAAsB;IAEtB,OAAO,CACL,QAAQ,KAAK,OAAO;QACpB,IAAI,KAAK,MAAM;QACf,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAC3C,OAAO,aAAa,KAAK,WAAW,CACrC,CAAC;AACJ,CAAC"}

View File

@ -0,0 +1,115 @@
{
"_args": [
[
"@electron/get@1.7.0",
"/home/massta/Documents/new"
]
],
"_development": true,
"_from": "@electron/get@1.7.0",
"_id": "@electron/get@1.7.0",
"_inBundle": false,
"_integrity": "sha512-Xzo+xLQ+gwmGywFnFuG7HNIALPVJOCkvKagGxSXU1LC3s/j3h2Nku9OdwJ4KDkITeUuXfvAO5KS8rLGcmAunNQ==",
"_location": "/@electron/get",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@electron/get@1.7.0",
"name": "@electron/get",
"escapedName": "@electron%2fget",
"scope": "@electron",
"rawSpec": "1.7.0",
"saveSpec": null,
"fetchSpec": "1.7.0"
},
"_requiredBy": [
"/electron"
],
"_resolved": "https://registry.npmjs.org/@electron/get/-/get-1.7.0.tgz",
"_spec": "1.7.0",
"_where": "/home/massta/Documents/new",
"author": {
"name": "Samuel Attard"
},
"bugs": {
"url": "https://github.com/electron/get/issues"
},
"dependencies": {
"debug": "^4.1.1",
"env-paths": "^2.2.0",
"fs-extra": "^8.1.0",
"global-agent": "^2.0.2",
"global-tunnel-ng": "^2.7.1",
"got": "^9.6.0",
"sanitize-filename": "^1.6.2",
"sumchecker": "^3.0.0"
},
"description": "Utility for downloading artifacts from different versions of Electron",
"devDependencies": {
"@continuous-auth/semantic-release-npm": "^1.0.3",
"@types/debug": "^4.1.4",
"@types/fs-extra": "^8.0.0",
"@types/got": "^9.4.4",
"@types/jest": "^24.0.13",
"@types/node": "^12.0.2",
"@types/sanitize-filename": "^1.1.28",
"gh-pages": "^2.0.1",
"husky": "^2.3.0",
"jest": "^24.8.0",
"lint-staged": "^8.1.7",
"prettier": "^1.17.1",
"semantic-release": "^15.13.12",
"ts-jest": "^24.0.0",
"typedoc": "^0.14.2",
"typedoc-plugin-nojekyll": "^1.0.1",
"typescript": "^3.4.5"
},
"engines": {
"node": ">=8.6"
},
"files": [
"dist/*",
"README.md"
],
"homepage": "https://github.com/electron/get#readme",
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"keywords": [
"electron",
"download",
"prebuild",
"get",
"artifact",
"release"
],
"license": "MIT",
"lint-staged": {
"*.ts": [
"prettier --write",
"git add"
]
},
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"name": "@electron/get",
"optionalDependencies": {
"global-agent": "^2.0.2",
"global-tunnel-ng": "^2.7.1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/electron/get.git"
},
"scripts": {
"build": "tsc && tsc -p tsconfig.esm.json",
"build:docs": "typedoc --plugin typedoc-plugin-nojekyll --out docs",
"prepublishOnly": "npm run build",
"publish:docs": "gh-pages-clean && node script/publish-docs.js",
"test": "prettier --check \"src/**/*.ts\" && jest --coverage"
},
"version": "1.7.0"
}

View File

@ -0,0 +1,132 @@
/// <reference types="node" />
/// <reference lib="es2016" />
/// <reference lib="es2017.sharedmemory" />
/// <reference lib="esnext.asynciterable" />
/// <reference lib="dom" />
declare type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
declare type Primitive = null | undefined | string | number | boolean | Symbol;
export interface ArrayLike {
length: number;
}
export interface Class<T = unknown> {
new (...args: any[]): T;
}
declare type DomElement = object & {
nodeType: 1;
nodeName: string;
};
declare type NodeStream = object & {
pipe: Function;
};
export declare const enum TypeName {
null = "null",
boolean = "boolean",
undefined = "undefined",
string = "string",
number = "number",
symbol = "symbol",
Function = "Function",
GeneratorFunction = "GeneratorFunction",
AsyncFunction = "AsyncFunction",
Observable = "Observable",
Array = "Array",
Buffer = "Buffer",
Object = "Object",
RegExp = "RegExp",
Date = "Date",
Error = "Error",
Map = "Map",
Set = "Set",
WeakMap = "WeakMap",
WeakSet = "WeakSet",
Int8Array = "Int8Array",
Uint8Array = "Uint8Array",
Uint8ClampedArray = "Uint8ClampedArray",
Int16Array = "Int16Array",
Uint16Array = "Uint16Array",
Int32Array = "Int32Array",
Uint32Array = "Uint32Array",
Float32Array = "Float32Array",
Float64Array = "Float64Array",
ArrayBuffer = "ArrayBuffer",
SharedArrayBuffer = "SharedArrayBuffer",
DataView = "DataView",
Promise = "Promise",
URL = "URL"
}
declare function is(value: unknown): TypeName;
declare namespace is {
const undefined: (value: unknown) => value is undefined;
const string: (value: unknown) => value is string;
const number: (value: unknown) => value is number;
const function_: (value: unknown) => value is Function;
const null_: (value: unknown) => value is null;
const class_: (value: unknown) => value is Class<unknown>;
const boolean: (value: unknown) => value is boolean;
const symbol: (value: unknown) => value is Symbol;
const numericString: (value: unknown) => boolean;
const array: (arg: any) => arg is any[];
const buffer: (input: unknown) => input is Buffer;
const nullOrUndefined: (value: unknown) => value is null | undefined;
const object: (value: unknown) => value is object;
const iterable: (value: unknown) => value is IterableIterator<unknown>;
const asyncIterable: (value: unknown) => value is AsyncIterableIterator<unknown>;
const generator: (value: unknown) => value is Generator;
const nativePromise: (value: unknown) => value is Promise<unknown>;
const promise: (value: unknown) => value is Promise<unknown>;
const generatorFunction: (value: unknown) => value is GeneratorFunction;
const asyncFunction: (value: unknown) => value is Function;
const boundFunction: (value: unknown) => value is Function;
const regExp: (value: unknown) => value is RegExp;
const date: (value: unknown) => value is Date;
const error: (value: unknown) => value is Error;
const map: (value: unknown) => value is Map<unknown, unknown>;
const set: (value: unknown) => value is Set<unknown>;
const weakMap: (value: unknown) => value is WeakMap<object, unknown>;
const weakSet: (value: unknown) => value is WeakSet<object>;
const int8Array: (value: unknown) => value is Int8Array;
const uint8Array: (value: unknown) => value is Uint8Array;
const uint8ClampedArray: (value: unknown) => value is Uint8ClampedArray;
const int16Array: (value: unknown) => value is Int16Array;
const uint16Array: (value: unknown) => value is Uint16Array;
const int32Array: (value: unknown) => value is Int32Array;
const uint32Array: (value: unknown) => value is Uint32Array;
const float32Array: (value: unknown) => value is Float32Array;
const float64Array: (value: unknown) => value is Float64Array;
const arrayBuffer: (value: unknown) => value is ArrayBuffer;
const sharedArrayBuffer: (value: unknown) => value is SharedArrayBuffer;
const dataView: (value: unknown) => value is DataView;
const directInstanceOf: <T>(instance: unknown, klass: Class<T>) => instance is T;
const urlInstance: (value: unknown) => value is URL;
const urlString: (value: unknown) => boolean;
const truthy: (value: unknown) => boolean;
const falsy: (value: unknown) => boolean;
const nan: (value: unknown) => boolean;
const primitive: (value: unknown) => value is Primitive;
const integer: (value: unknown) => value is number;
const safeInteger: (value: unknown) => value is number;
const plainObject: (value: unknown) => boolean;
const typedArray: (value: unknown) => value is TypedArray;
const arrayLike: (value: unknown) => value is ArrayLike;
const inRange: (value: number, range: number | number[]) => boolean;
const domElement: (value: unknown) => value is DomElement;
const observable: (value: unknown) => boolean;
const nodeStream: (value: unknown) => value is NodeStream;
const infinite: (value: unknown) => boolean;
const even: (value: number) => boolean;
const odd: (value: number) => boolean;
const emptyArray: (value: unknown) => boolean;
const nonEmptyArray: (value: unknown) => boolean;
const emptyString: (value: unknown) => boolean;
const nonEmptyString: (value: unknown) => boolean;
const emptyStringOrWhitespace: (value: unknown) => boolean;
const emptyObject: (value: unknown) => boolean;
const nonEmptyObject: (value: unknown) => boolean;
const emptySet: (value: unknown) => boolean;
const nonEmptySet: (value: unknown) => boolean;
const emptyMap: (value: unknown) => boolean;
const nonEmptyMap: (value: unknown) => boolean;
const any: (predicate: unknown, ...values: unknown[]) => boolean;
const all: (predicate: unknown, ...values: unknown[]) => boolean;
}
export default is;

View File

@ -0,0 +1,245 @@
"use strict";
/// <reference lib="es2016"/>
/// <reference lib="es2017.sharedmemory"/>
/// <reference lib="esnext.asynciterable"/>
/// <reference lib="dom"/>
Object.defineProperty(exports, "__esModule", { value: true });
// TODO: Use the `URL` global when targeting Node.js 10
// tslint:disable-next-line
const URLGlobal = typeof URL === 'undefined' ? require('url').URL : URL;
const toString = Object.prototype.toString;
const isOfType = (type) => (value) => typeof value === type;
const isBuffer = (input) => !is.nullOrUndefined(input) && !is.nullOrUndefined(input.constructor) && is.function_(input.constructor.isBuffer) && input.constructor.isBuffer(input);
const getObjectType = (value) => {
const objectName = toString.call(value).slice(8, -1);
if (objectName) {
return objectName;
}
return null;
};
const isObjectOfType = (type) => (value) => getObjectType(value) === type;
function is(value) {
switch (value) {
case null:
return "null" /* null */;
case true:
case false:
return "boolean" /* boolean */;
default:
}
switch (typeof value) {
case 'undefined':
return "undefined" /* undefined */;
case 'string':
return "string" /* string */;
case 'number':
return "number" /* number */;
case 'symbol':
return "symbol" /* symbol */;
default:
}
if (is.function_(value)) {
return "Function" /* Function */;
}
if (is.observable(value)) {
return "Observable" /* Observable */;
}
if (Array.isArray(value)) {
return "Array" /* Array */;
}
if (isBuffer(value)) {
return "Buffer" /* Buffer */;
}
const tagType = getObjectType(value);
if (tagType) {
return tagType;
}
if (value instanceof String || value instanceof Boolean || value instanceof Number) {
throw new TypeError('Please don\'t use object wrappers for primitive types');
}
return "Object" /* Object */;
}
(function (is) {
// tslint:disable-next-line:strict-type-predicates
const isObject = (value) => typeof value === 'object';
// tslint:disable:variable-name
is.undefined = isOfType('undefined');
is.string = isOfType('string');
is.number = isOfType('number');
is.function_ = isOfType('function');
// tslint:disable-next-line:strict-type-predicates
is.null_ = (value) => value === null;
is.class_ = (value) => is.function_(value) && value.toString().startsWith('class ');
is.boolean = (value) => value === true || value === false;
is.symbol = isOfType('symbol');
// tslint:enable:variable-name
is.numericString = (value) => is.string(value) && value.length > 0 && !Number.isNaN(Number(value));
is.array = Array.isArray;
is.buffer = isBuffer;
is.nullOrUndefined = (value) => is.null_(value) || is.undefined(value);
is.object = (value) => !is.nullOrUndefined(value) && (is.function_(value) || isObject(value));
is.iterable = (value) => !is.nullOrUndefined(value) && is.function_(value[Symbol.iterator]);
is.asyncIterable = (value) => !is.nullOrUndefined(value) && is.function_(value[Symbol.asyncIterator]);
is.generator = (value) => is.iterable(value) && is.function_(value.next) && is.function_(value.throw);
is.nativePromise = (value) => isObjectOfType("Promise" /* Promise */)(value);
const hasPromiseAPI = (value) => !is.null_(value) &&
isObject(value) &&
is.function_(value.then) &&
is.function_(value.catch);
is.promise = (value) => is.nativePromise(value) || hasPromiseAPI(value);
is.generatorFunction = isObjectOfType("GeneratorFunction" /* GeneratorFunction */);
is.asyncFunction = isObjectOfType("AsyncFunction" /* AsyncFunction */);
is.boundFunction = (value) => is.function_(value) && !value.hasOwnProperty('prototype');
is.regExp = isObjectOfType("RegExp" /* RegExp */);
is.date = isObjectOfType("Date" /* Date */);
is.error = isObjectOfType("Error" /* Error */);
is.map = (value) => isObjectOfType("Map" /* Map */)(value);
is.set = (value) => isObjectOfType("Set" /* Set */)(value);
is.weakMap = (value) => isObjectOfType("WeakMap" /* WeakMap */)(value);
is.weakSet = (value) => isObjectOfType("WeakSet" /* WeakSet */)(value);
is.int8Array = isObjectOfType("Int8Array" /* Int8Array */);
is.uint8Array = isObjectOfType("Uint8Array" /* Uint8Array */);
is.uint8ClampedArray = isObjectOfType("Uint8ClampedArray" /* Uint8ClampedArray */);
is.int16Array = isObjectOfType("Int16Array" /* Int16Array */);
is.uint16Array = isObjectOfType("Uint16Array" /* Uint16Array */);
is.int32Array = isObjectOfType("Int32Array" /* Int32Array */);
is.uint32Array = isObjectOfType("Uint32Array" /* Uint32Array */);
is.float32Array = isObjectOfType("Float32Array" /* Float32Array */);
is.float64Array = isObjectOfType("Float64Array" /* Float64Array */);
is.arrayBuffer = isObjectOfType("ArrayBuffer" /* ArrayBuffer */);
is.sharedArrayBuffer = isObjectOfType("SharedArrayBuffer" /* SharedArrayBuffer */);
is.dataView = isObjectOfType("DataView" /* DataView */);
is.directInstanceOf = (instance, klass) => Object.getPrototypeOf(instance) === klass.prototype;
is.urlInstance = (value) => isObjectOfType("URL" /* URL */)(value);
is.urlString = (value) => {
if (!is.string(value)) {
return false;
}
try {
new URLGlobal(value); // tslint:disable-line no-unused-expression
return true;
}
catch (_a) {
return false;
}
};
is.truthy = (value) => Boolean(value);
is.falsy = (value) => !value;
is.nan = (value) => Number.isNaN(value);
const primitiveTypes = new Set([
'undefined',
'string',
'number',
'boolean',
'symbol'
]);
is.primitive = (value) => is.null_(value) || primitiveTypes.has(typeof value);
is.integer = (value) => Number.isInteger(value);
is.safeInteger = (value) => Number.isSafeInteger(value);
is.plainObject = (value) => {
// From: https://github.com/sindresorhus/is-plain-obj/blob/master/index.js
let prototype;
return getObjectType(value) === "Object" /* Object */ &&
(prototype = Object.getPrototypeOf(value), prototype === null || // tslint:disable-line:ban-comma-operator
prototype === Object.getPrototypeOf({}));
};
const typedArrayTypes = new Set([
"Int8Array" /* Int8Array */,
"Uint8Array" /* Uint8Array */,
"Uint8ClampedArray" /* Uint8ClampedArray */,
"Int16Array" /* Int16Array */,
"Uint16Array" /* Uint16Array */,
"Int32Array" /* Int32Array */,
"Uint32Array" /* Uint32Array */,
"Float32Array" /* Float32Array */,
"Float64Array" /* Float64Array */
]);
is.typedArray = (value) => {
const objectType = getObjectType(value);
if (objectType === null) {
return false;
}
return typedArrayTypes.has(objectType);
};
const isValidLength = (value) => is.safeInteger(value) && value > -1;
is.arrayLike = (value) => !is.nullOrUndefined(value) && !is.function_(value) && isValidLength(value.length);
is.inRange = (value, range) => {
if (is.number(range)) {
return value >= Math.min(0, range) && value <= Math.max(range, 0);
}
if (is.array(range) && range.length === 2) {
return value >= Math.min(...range) && value <= Math.max(...range);
}
throw new TypeError(`Invalid range: ${JSON.stringify(range)}`);
};
const NODE_TYPE_ELEMENT = 1;
const DOM_PROPERTIES_TO_CHECK = [
'innerHTML',
'ownerDocument',
'style',
'attributes',
'nodeValue'
];
is.domElement = (value) => is.object(value) && value.nodeType === NODE_TYPE_ELEMENT && is.string(value.nodeName) &&
!is.plainObject(value) && DOM_PROPERTIES_TO_CHECK.every(property => property in value);
is.observable = (value) => {
if (!value) {
return false;
}
if (value[Symbol.observable] && value === value[Symbol.observable]()) {
return true;
}
if (value['@@observable'] && value === value['@@observable']()) {
return true;
}
return false;
};
is.nodeStream = (value) => !is.nullOrUndefined(value) && isObject(value) && is.function_(value.pipe) && !is.observable(value);
is.infinite = (value) => value === Infinity || value === -Infinity;
const isAbsoluteMod2 = (rem) => (value) => is.integer(value) && Math.abs(value % 2) === rem;
is.even = isAbsoluteMod2(0);
is.odd = isAbsoluteMod2(1);
const isWhiteSpaceString = (value) => is.string(value) && /\S/.test(value) === false;
is.emptyArray = (value) => is.array(value) && value.length === 0;
is.nonEmptyArray = (value) => is.array(value) && value.length > 0;
is.emptyString = (value) => is.string(value) && value.length === 0;
is.nonEmptyString = (value) => is.string(value) && value.length > 0;
is.emptyStringOrWhitespace = (value) => is.emptyString(value) || isWhiteSpaceString(value);
is.emptyObject = (value) => is.object(value) && !is.map(value) && !is.set(value) && Object.keys(value).length === 0;
is.nonEmptyObject = (value) => is.object(value) && !is.map(value) && !is.set(value) && Object.keys(value).length > 0;
is.emptySet = (value) => is.set(value) && value.size === 0;
is.nonEmptySet = (value) => is.set(value) && value.size > 0;
is.emptyMap = (value) => is.map(value) && value.size === 0;
is.nonEmptyMap = (value) => is.map(value) && value.size > 0;
const predicateOnArray = (method, predicate, values) => {
if (is.function_(predicate) === false) {
throw new TypeError(`Invalid predicate: ${JSON.stringify(predicate)}`);
}
if (values.length === 0) {
throw new TypeError('Invalid number of values');
}
return method.call(values, predicate);
};
// tslint:disable variable-name
is.any = (predicate, ...values) => predicateOnArray(Array.prototype.some, predicate, values);
is.all = (predicate, ...values) => predicateOnArray(Array.prototype.every, predicate, values);
// tslint:enable variable-name
})(is || (is = {}));
// Some few keywords are reserved, but we'll populate them for Node.js users
// See https://github.com/Microsoft/TypeScript/issues/2536
Object.defineProperties(is, {
class: {
value: is.class_
},
function: {
value: is.function_
},
null: {
value: is.null_
}
});
exports.default = is;
// For CommonJS default export support
module.exports = is;
module.exports.default = is;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,9 @@
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -0,0 +1,100 @@
{
"_args": [
[
"@sindresorhus/is@0.14.0",
"/home/massta/Documents/new"
]
],
"_development": true,
"_from": "@sindresorhus/is@0.14.0",
"_id": "@sindresorhus/is@0.14.0",
"_inBundle": false,
"_integrity": "sha512-9NET910DNaIPngYnLLPeg+Ogzqsi9uM4mSboU5y6p8S5DzMTVEsJZrawi+BoDNUVBa2DhJqQYUFvMDfgU062LQ==",
"_location": "/@sindresorhus/is",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@sindresorhus/is@0.14.0",
"name": "@sindresorhus/is",
"escapedName": "@sindresorhus%2fis",
"scope": "@sindresorhus",
"rawSpec": "0.14.0",
"saveSpec": null,
"fetchSpec": "0.14.0"
},
"_requiredBy": [
"/got"
],
"_resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-0.14.0.tgz",
"_spec": "0.14.0",
"_where": "/home/massta/Documents/new",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"bugs": {
"url": "https://github.com/sindresorhus/is/issues"
},
"description": "Type check values: `is.string('🦄') //=> true`",
"devDependencies": {
"@sindresorhus/tsconfig": "^0.1.0",
"@types/jsdom": "^11.12.0",
"@types/node": "^10.12.10",
"@types/tempy": "^0.2.0",
"@types/zen-observable": "^0.8.0",
"ava": "^0.25.0",
"del-cli": "^1.1.0",
"jsdom": "^11.6.2",
"rxjs": "^6.3.3",
"tempy": "^0.2.1",
"tslint": "^5.9.1",
"tslint-xo": "^0.10.0",
"typescript": "^3.2.1",
"zen-observable": "^0.8.8"
},
"engines": {
"node": ">=6"
},
"files": [
"dist"
],
"homepage": "https://github.com/sindresorhus/is#readme",
"keywords": [
"type",
"types",
"is",
"check",
"checking",
"validate",
"validation",
"utility",
"util",
"typeof",
"instanceof",
"object",
"assert",
"assertion",
"test",
"kind",
"primitive",
"verify",
"compare"
],
"license": "MIT",
"main": "dist/index.js",
"name": "@sindresorhus/is",
"repository": {
"type": "git",
"url": "git+https://github.com/sindresorhus/is.git"
},
"scripts": {
"build": "del dist && tsc",
"lint": "tslint --format stylish --project .",
"prepublish": "npm run build && del dist/tests",
"test": "npm run lint && npm run build && ava dist/tests"
},
"types": "dist/index.d.ts",
"version": "0.14.0"
}

View File

@ -0,0 +1,451 @@
# is [![Build Status](https://travis-ci.org/sindresorhus/is.svg?branch=master)](https://travis-ci.org/sindresorhus/is)
> Type check values: `is.string('🦄') //=> true`
<img src="header.gif" width="182" align="right">
## Install
```
$ npm install @sindresorhus/is
```
## Usage
```js
const is = require('@sindresorhus/is');
is('🦄');
//=> 'string'
is(new Map());
//=> 'Map'
is.number(6);
//=> true
```
When using `is` together with TypeScript, [type guards](http://www.typescriptlang.org/docs/handbook/advanced-types.html#type-guards-and-differentiating-types) are being used to infer the correct type inside if-else statements.
```ts
import is from '@sindresorhus/is';
const padLeft = (value: string, padding: string | number) => {
if (is.number(padding)) {
// `padding` is typed as `number`
return Array(padding + 1).join(' ') + value;
}
if (is.string(padding)) {
// `padding` is typed as `string`
return padding + value;
}
throw new TypeError(`Expected 'padding' to be of type 'string' or 'number', got '${is(padding)}'.`);
}
padLeft('🦄', 3);
//=> ' 🦄'
padLeft('🦄', '🌈');
//=> '🌈🦄'
```
## API
### is(value)
Returns the type of `value`.
Primitives are lowercase and object types are camelcase.
Example:
- `'undefined'`
- `'null'`
- `'string'`
- `'symbol'`
- `'Array'`
- `'Function'`
- `'Object'`
Note: It will throw an error if you try to feed it object-wrapped primitives, as that's a bad practice. For example `new String('foo')`.
### is.{method}
All the below methods accept a value and returns a boolean for whether the value is of the desired type.
#### Primitives
##### .undefined(value)
##### .null(value)
##### .string(value)
##### .number(value)
##### .boolean(value)
##### .symbol(value)
#### Built-in types
##### .array(value)
##### .function(value)
##### .buffer(value)
##### .object(value)
Keep in mind that [functions are objects too](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions).
##### .numericString(value)
Returns `true` for a string that represents a number. For example, `'42'` and `'-8'`.
Note: `'NaN'` returns `false`, but `'Infinity'` and `'-Infinity'` return `true`.
##### .regExp(value)
##### .date(value)
##### .error(value)
##### .nativePromise(value)
##### .promise(value)
Returns `true` for any object with a `.then()` and `.catch()` method. Prefer this one over `.nativePromise()` as you usually want to allow userland promise implementations too.
##### .generator(value)
Returns `true` for any object that implements its own `.next()` and `.throw()` methods and has a function definition for `Symbol.iterator`.
##### .generatorFunction(value)
##### .asyncFunction(value)
Returns `true` for any `async` function that can be called with the `await` operator.
```js
is.asyncFunction(async () => {});
// => true
is.asyncFunction(() => {});
// => false
```
##### .boundFunction(value)
Returns `true` for any `bound` function.
```js
is.boundFunction(() => {});
// => true
is.boundFunction(function () {}.bind(null));
// => true
is.boundFunction(function () {});
// => false
```
##### .map(value)
##### .set(value)
##### .weakMap(value)
##### .weakSet(value)
#### Typed arrays
##### .int8Array(value)
##### .uint8Array(value)
##### .uint8ClampedArray(value)
##### .int16Array(value)
##### .uint16Array(value)
##### .int32Array(value)
##### .uint32Array(value)
##### .float32Array(value)
##### .float64Array(value)
#### Structured data
##### .arrayBuffer(value)
##### .sharedArrayBuffer(value)
##### .dataView(value)
#### Emptiness
##### .emptyString(value)
Returns `true` if the value is a `string` and the `.length` is 0.
##### .nonEmptyString(value)
Returns `true` if the value is a `string` and the `.length` is more than 0.
##### .emptyStringOrWhitespace(value)
Returns `true` if `is.emptyString(value)` or if it's a `string` that is all whitespace.
##### .emptyArray(value)
Returns `true` if the value is an `Array` and the `.length` is 0.
##### .nonEmptyArray(value)
Returns `true` if the value is an `Array` and the `.length` is more than 0.
##### .emptyObject(value)
Returns `true` if the value is an `Object` and `Object.keys(value).length` is 0.
Please note that `Object.keys` returns only own enumerable properties. Hence something like this can happen:
```js
const object1 = {};
Object.defineProperty(object1, 'property1', {
value: 42,
writable: true,
enumerable: false,
configurable: true
});
is.emptyObject(object1);
// => true
```
##### .nonEmptyObject(value)
Returns `true` if the value is an `Object` and `Object.keys(value).length` is more than 0.
##### .emptySet(value)
Returns `true` if the value is a `Set` and the `.size` is 0.
##### .nonEmptySet(Value)
Returns `true` if the value is a `Set` and the `.size` is more than 0.
##### .emptyMap(value)
Returns `true` if the value is a `Map` and the `.size` is 0.
##### .nonEmptyMap(value)
Returns `true` if the value is a `Map` and the `.size` is more than 0.
#### Miscellaneous
##### .directInstanceOf(value, class)
Returns `true` if `value` is a direct instance of `class`.
```js
is.directInstanceOf(new Error(), Error);
//=> true
class UnicornError extends Error {}
is.directInstanceOf(new UnicornError(), Error);
//=> false
```
##### .urlInstance(value)
Returns `true` if `value` is an instance of the [`URL` class](https://developer.mozilla.org/en-US/docs/Web/API/URL).
```js
const url = new URL('https://example.com');
is.urlInstance(url);
//=> true
```
### .url(value)
Returns `true` if `value` is a URL string.
Note: this only does basic checking using the [`URL` class](https://developer.mozilla.org/en-US/docs/Web/API/URL) constructor.
```js
const url = 'https://example.com';
is.url(url);
//=> true
is.url(new URL(url));
//=> false
```
##### .truthy(value)
Returns `true` for all values that evaluate to true in a boolean context:
```js
is.truthy('🦄');
//=> true
is.truthy(undefined);
//=> false
```
##### .falsy(value)
Returns `true` if `value` is one of: `false`, `0`, `''`, `null`, `undefined`, `NaN`.
##### .nan(value)
##### .nullOrUndefined(value)
##### .primitive(value)
JavaScript primitives are as follows: `null`, `undefined`, `string`, `number`, `boolean`, `symbol`.
##### .integer(value)
##### .safeInteger(value)
Returns `true` if `value` is a [safe integer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger).
##### .plainObject(value)
An object is plain if it's created by either `{}`, `new Object()`, or `Object.create(null)`.
##### .iterable(value)
##### .asyncIterable(value)
##### .class(value)
Returns `true` for instances created by a class.
##### .typedArray(value)
##### .arrayLike(value)
A `value` is array-like if it is not a function and has a `value.length` that is a safe integer greater than or equal to 0.
```js
is.arrayLike(document.forms);
//=> true
function foo() {
is.arrayLike(arguments);
//=> true
}
foo();
```
##### .inRange(value, range)
Check if `value` (number) is in the given `range`. The range is an array of two values, lower bound and upper bound, in no specific order.
```js
is.inRange(3, [0, 5]);
is.inRange(3, [5, 0]);
is.inRange(0, [-2, 2]);
```
##### .inRange(value, upperBound)
Check if `value` (number) is in the range of `0` to `upperBound`.
```js
is.inRange(3, 10);
```
##### .domElement(value)
Returns `true` if `value` is a DOM Element.
##### .nodeStream(value)
Returns `true` if `value` is a Node.js [stream](https://nodejs.org/api/stream.html).
```js
const fs = require('fs');
is.nodeStream(fs.createReadStream('unicorn.png'));
//=> true
```
##### .observable(value)
Returns `true` if `value` is an `Observable`.
```js
const {Observable} = require('rxjs');
is.observable(new Observable());
//=> true
```
##### .infinite(value)
Check if `value` is `Infinity` or `-Infinity`.
##### .even(value)
Returns `true` if `value` is an even integer.
##### .odd(value)
Returns `true` if `value` is an odd integer.
##### .any(predicate, ...values)
Returns `true` if **any** of the input `values` returns true in the `predicate`:
```js
is.any(is.string, {}, true, '🦄');
//=> true
is.any(is.boolean, 'unicorns', [], new Map());
//=> false
```
##### .all(predicate, ...values)
Returns `true` if **all** of the input `values` returns true in the `predicate`:
```js
is.all(is.object, {}, new Map(), new Set());
//=> true
is.all(is.string, '🦄', [], 'unicorns');
//=> false
```
## FAQ
### Why yet another type checking module?
There are hundreds of type checking modules on npm, unfortunately, I couldn't find any that fit my needs:
- Includes both type methods and ability to get the type
- Types of primitives returned as lowercase and object types as camelcase
- Covers all built-ins
- Unsurprising behavior
- Well-maintained
- Comprehensive test suite
For the ones I found, pick 3 of these.
The most common mistakes I noticed in these modules was using `instanceof` for type checking, forgetting that functions are objects, and omitting `symbol` as a primitive.
## Related
- [ow](https://github.com/sindresorhus/ow) - Function argument validation for humans
- [is-stream](https://github.com/sindresorhus/is-stream) - Check if something is a Node.js stream
- [is-observable](https://github.com/sindresorhus/is-observable) - Check if a value is an Observable
- [file-type](https://github.com/sindresorhus/file-type) - Detect the file type of a Buffer/Uint8Array
- [is-ip](https://github.com/sindresorhus/is-ip) - Check if a string is an IP address
- [is-array-sorted](https://github.com/sindresorhus/is-array-sorted) - Check if an Array is sorted
- [is-error-constructor](https://github.com/sindresorhus/is-error-constructor) - Check if a value is an error constructor
- [is-empty-iterable](https://github.com/sindresorhus/is-empty-iterable) - Check if an Iterable is empty
- [is-blob](https://github.com/sindresorhus/is-blob) - Check if a value is a Blob - File-like object of immutable, raw data
- [has-emoji](https://github.com/sindresorhus/has-emoji) - Check whether a string has any emoji
## Created by
- [Sindre Sorhus](https://github.com/sindresorhus)
- [Giora Guttsait](https://github.com/gioragutt)
- [Brandon Smith](https://github.com/brandon93s)
## License
MIT

View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018 Szymon Marczak
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -0,0 +1,70 @@
# http-timer
> Timings for HTTP requests
[![Build Status](https://travis-ci.org/szmarczak/http-timer.svg?branch=master)](https://travis-ci.org/szmarczak/http-timer)
[![Coverage Status](https://coveralls.io/repos/github/szmarczak/http-timer/badge.svg?branch=master)](https://coveralls.io/github/szmarczak/http-timer?branch=master)
[![install size](https://packagephobia.now.sh/badge?p=@szmarczak/http-timer)](https://packagephobia.now.sh/result?p=@szmarczak/http-timer)
Inspired by the [`request` package](https://github.com/request/request).
## Usage
```js
'use strict';
const https = require('https');
const timer = require('@szmarczak/http-timer');
const request = https.get('https://httpbin.org/anything');
const timings = timer(request);
request.on('response', response => {
response.on('data', () => {}); // Consume the data somehow
response.on('end', () => {
console.log(timings);
});
});
// { start: 1535708511443,
// socket: 1535708511444,
// lookup: 1535708511444,
// connect: 1535708511582,
// upload: 1535708511887,
// response: 1535708512037,
// end: 1535708512040,
// phases:
// { wait: 1,
// dns: 0,
// tcp: 138,
// request: 305,
// firstByte: 150,
// download: 3,
// total: 597 } }
```
## API
### timer(request)
Returns: `Object`
- `start` - Time when the request started.
- `socket` - Time when a socket was assigned to the request.
- `lookup` - Time when the DNS lookup finished.
- `connect` - Time when the socket successfully connected.
- `upload` - Time when the request finished uploading.
- `response` - Time when the request fired the `response` event.
- `end` - Time when the response fired the `end` event.
- `error` - Time when the request fired the `error` event.
- `phases`
- `wait` - `timings.socket - timings.start`
- `dns` - `timings.lookup - timings.socket`
- `tcp` - `timings.connect - timings.lookup`
- `request` - `timings.upload - timings.connect`
- `firstByte` - `timings.response - timings.upload`
- `download` - `timings.end - timings.response`
- `total` - `timings.end - timings.start` or `timings.error - timings.start`
**Note**: The time is a `number` representing the milliseconds elapsed since the UNIX epoch.
## License
MIT

View File

@ -0,0 +1,79 @@
{
"_args": [
[
"@szmarczak/http-timer@1.1.2",
"/home/massta/Documents/new"
]
],
"_development": true,
"_from": "@szmarczak/http-timer@1.1.2",
"_id": "@szmarczak/http-timer@1.1.2",
"_inBundle": false,
"_integrity": "sha512-XIB2XbzHTN6ieIjfIMV9hlVcfPU26s2vafYWQcZHWXHOxiaRZYEDKEwdl129Zyg50+foYV2jCgtrqSA6qNuNSA==",
"_location": "/@szmarczak/http-timer",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@szmarczak/http-timer@1.1.2",
"name": "@szmarczak/http-timer",
"escapedName": "@szmarczak%2fhttp-timer",
"scope": "@szmarczak",
"rawSpec": "1.1.2",
"saveSpec": null,
"fetchSpec": "1.1.2"
},
"_requiredBy": [
"/got"
],
"_resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-1.1.2.tgz",
"_spec": "1.1.2",
"_where": "/home/massta/Documents/new",
"author": {
"name": "Szymon Marczak"
},
"bugs": {
"url": "https://github.com/szmarczak/http-timer/issues"
},
"dependencies": {
"defer-to-connect": "^1.0.1"
},
"description": "Timings for HTTP requests",
"devDependencies": {
"ava": "^0.25.0",
"coveralls": "^3.0.2",
"nyc": "^12.0.2",
"p-event": "^2.1.0",
"xo": "^0.22.0"
},
"engines": {
"node": ">=6"
},
"files": [
"source"
],
"homepage": "https://github.com/szmarczak/http-timer#readme",
"keywords": [
"http",
"https",
"timer",
"timings"
],
"license": "MIT",
"main": "source",
"name": "@szmarczak/http-timer",
"repository": {
"type": "git",
"url": "git+https://github.com/szmarczak/http-timer.git"
},
"scripts": {
"coveralls": "nyc report --reporter=text-lcov | coveralls",
"test": "xo && nyc ava"
},
"version": "1.1.2",
"xo": {
"rules": {
"unicorn/filename-case": "camelCase"
}
}
}

View File

@ -0,0 +1,99 @@
'use strict';
const deferToConnect = require('defer-to-connect');
module.exports = request => {
const timings = {
start: Date.now(),
socket: null,
lookup: null,
connect: null,
upload: null,
response: null,
end: null,
error: null,
phases: {
wait: null,
dns: null,
tcp: null,
request: null,
firstByte: null,
download: null,
total: null
}
};
const handleError = origin => {
const emit = origin.emit.bind(origin);
origin.emit = (event, ...args) => {
// Catches the `error` event
if (event === 'error') {
timings.error = Date.now();
timings.phases.total = timings.error - timings.start;
origin.emit = emit;
}
// Saves the original behavior
return emit(event, ...args);
};
};
let uploadFinished = false;
const onUpload = () => {
timings.upload = Date.now();
timings.phases.request = timings.upload - timings.connect;
};
handleError(request);
request.once('socket', socket => {
timings.socket = Date.now();
timings.phases.wait = timings.socket - timings.start;
const lookupListener = () => {
timings.lookup = Date.now();
timings.phases.dns = timings.lookup - timings.socket;
};
socket.once('lookup', lookupListener);
deferToConnect(socket, () => {
timings.connect = Date.now();
if (timings.lookup === null) {
socket.removeListener('lookup', lookupListener);
timings.lookup = timings.connect;
timings.phases.dns = timings.lookup - timings.socket;
}
timings.phases.tcp = timings.connect - timings.lookup;
if (uploadFinished && !timings.upload) {
onUpload();
}
});
});
request.once('finish', () => {
uploadFinished = true;
if (timings.connect) {
onUpload();
}
});
request.once('response', response => {
timings.response = Date.now();
timings.phases.firstByte = timings.response - timings.upload;
handleError(response);
response.once('end', () => {
timings.end = Date.now();
timings.phases.download = timings.end - timings.response;
timings.phases.total = timings.end - timings.start;
});
});
return timings;
};

21
lsscanner/new_ubuntu/node_modules/@types/node/LICENSE generated vendored Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) Microsoft Corporation. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE

View File

@ -0,0 +1,16 @@
# Installation
> `npm install --save @types/node`
# Summary
This package contains type definitions for Node.js (http://nodejs.org/).
# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
### Additional Details
* Last updated: Tue, 19 Nov 2019 19:44:54 GMT
* Dependencies: none
* Global values: `Buffer`, `NodeJS`, `Symbol`, `__dirname`, `__filename`, `clearImmediate`, `clearInterval`, `clearTimeout`, `console`, `exports`, `global`, `module`, `process`, `queueMicrotask`, `require`, `setImmediate`, `setInterval`, `setTimeout`
# Credits
These definitions were written by Microsoft TypeScript (https://github.com/Microsoft), DefinitelyTyped (https://github.com/DefinitelyTyped), Alberto Schiabel (https://github.com/jkomyno), Alexander T. (https://github.com/a-tarasyuk), Alvis HT Tang (https://github.com/alvis), Andrew Makarov (https://github.com/r3nya), Benjamin Toueg (https://github.com/btoueg), Bruno Scheufler (https://github.com/brunoscheufler), Chigozirim C. (https://github.com/smac89), Christian Vaagland Tellnes (https://github.com/tellnes), David Junger (https://github.com/touffy), Deividas Bakanas (https://github.com/DeividasBakanas), Eugene Y. Q. Shen (https://github.com/eyqs), Flarna (https://github.com/Flarna), Hannes Magnusson (https://github.com/Hannes-Magnusson-CK), Hoàng Văn Khải (https://github.com/KSXGitHub), Huw (https://github.com/hoo29), Kelvin Jin (https://github.com/kjin), Klaus Meinhardt (https://github.com/ajafff), Lishude (https://github.com/islishude), Mariusz Wiktorczyk (https://github.com/mwiktorczyk), Mohsen Azimi (https://github.com/mohsen1), Nicolas Even (https://github.com/n-e), Nicolas Voigt (https://github.com/octo-sniffle), Nikita Galkin (https://github.com/galkin), Parambir Singh (https://github.com/parambirs), Sebastian Silbermann (https://github.com/eps1lon), Simon Schick (https://github.com/SimonSchick), Thomas den Hollander (https://github.com/ThomasdenH), Wilco Bakker (https://github.com/WilcoBakker), wwwy3y3 (https://github.com/wwwy3y3), Zane Hannan AU (https://github.com/ZaneHannanAU), Samuel Ainsworth (https://github.com/samuela), Kyle Uehlein (https://github.com/kuehlein), Jordi Oliveras Rovira (https://github.com/j-oliveras), Thanik Bhongbhibhat (https://github.com/bhongy), Marcin Kopacz (https://github.com/chyzwar), Trivikram Kamat (https://github.com/trivikr), Minh Son Nguyen (https://github.com/nguymin4), and Junxiao Shi (https://github.com/yoursunny).

View File

@ -0,0 +1,48 @@
declare module "assert" {
function internal(value: any, message?: string | Error): void;
namespace internal {
class AssertionError implements Error {
name: string;
message: string;
actual: any;
expected: any;
operator: string;
generatedMessage: boolean;
code: 'ERR_ASSERTION';
constructor(options?: {
message?: string; actual?: any; expected?: any;
operator?: string; stackStartFn?: Function
});
}
function fail(message?: string | Error): never;
/** @deprecated since v10.0.0 - use fail([message]) or other assert functions instead. */
function fail(actual: any, expected: any, message?: string | Error, operator?: string, stackStartFn?: Function): never;
function ok(value: any, message?: string | Error): void;
function equal(actual: any, expected: any, message?: string | Error): void;
function notEqual(actual: any, expected: any, message?: string | Error): void;
function deepEqual(actual: any, expected: any, message?: string | Error): void;
function notDeepEqual(actual: any, expected: any, message?: string | Error): void;
function strictEqual(actual: any, expected: any, message?: string | Error): void;
function notStrictEqual(actual: any, expected: any, message?: string | Error): void;
function deepStrictEqual(actual: any, expected: any, message?: string | Error): void;
function notDeepStrictEqual(actual: any, expected: any, message?: string | Error): void;
function throws(block: () => any, message?: string | Error): void;
function throws(block: () => any, error: RegExp | Function | Object | Error, message?: string | Error): void;
function doesNotThrow(block: () => any, message?: string | Error): void;
function doesNotThrow(block: () => any, error: RegExp | Function, message?: string | Error): void;
function ifError(value: any): void;
function rejects(block: (() => Promise<any>) | Promise<any>, message?: string | Error): Promise<void>;
function rejects(block: (() => Promise<any>) | Promise<any>, error: RegExp | Function | Object | Error, message?: string | Error): Promise<void>;
function doesNotReject(block: (() => Promise<any>) | Promise<any>, message?: string | Error): Promise<void>;
function doesNotReject(block: (() => Promise<any>) | Promise<any>, error: RegExp | Function, message?: string | Error): Promise<void>;
const strict: typeof internal;
}
export = internal;
}

View File

@ -0,0 +1,132 @@
/**
* Async Hooks module: https://nodejs.org/api/async_hooks.html
*/
declare module "async_hooks" {
/**
* Returns the asyncId of the current execution context.
*/
function executionAsyncId(): number;
/**
* Returns the ID of the resource responsible for calling the callback that is currently being executed.
*/
function triggerAsyncId(): number;
interface HookCallbacks {
/**
* Called when a class is constructed that has the possibility to emit an asynchronous event.
* @param asyncId a unique ID for the async resource
* @param type the type of the async resource
* @param triggerAsyncId the unique ID of the async resource in whose execution context this async resource was created
* @param resource reference to the resource representing the async operation, needs to be released during destroy
*/
init?(asyncId: number, type: string, triggerAsyncId: number, resource: Object): void;
/**
* When an asynchronous operation is initiated or completes a callback is called to notify the user.
* The before callback is called just before said callback is executed.
* @param asyncId the unique identifier assigned to the resource about to execute the callback.
*/
before?(asyncId: number): void;
/**
* Called immediately after the callback specified in before is completed.
* @param asyncId the unique identifier assigned to the resource which has executed the callback.
*/
after?(asyncId: number): void;
/**
* Called when a promise has resolve() called. This may not be in the same execution id
* as the promise itself.
* @param asyncId the unique id for the promise that was resolve()d.
*/
promiseResolve?(asyncId: number): void;
/**
* Called after the resource corresponding to asyncId is destroyed
* @param asyncId a unique ID for the async resource
*/
destroy?(asyncId: number): void;
}
interface AsyncHook {
/**
* Enable the callbacks for a given AsyncHook instance. If no callbacks are provided enabling is a noop.
*/
enable(): this;
/**
* Disable the callbacks for a given AsyncHook instance from the global pool of AsyncHook callbacks to be executed. Once a hook has been disabled it will not be called again until enabled.
*/
disable(): this;
}
/**
* Registers functions to be called for different lifetime events of each async operation.
* @param options the callbacks to register
* @return an AsyncHooks instance used for disabling and enabling hooks
*/
function createHook(options: HookCallbacks): AsyncHook;
interface AsyncResourceOptions {
/**
* The ID of the execution context that created this async event.
* Default: `executionAsyncId()`
*/
triggerAsyncId?: number;
/**
* Disables automatic `emitDestroy` when the object is garbage collected.
* This usually does not need to be set (even if `emitDestroy` is called
* manually), unless the resource's `asyncId` is retrieved and the
* sensitive API's `emitDestroy` is called with it.
* Default: `false`
*/
requireManualDestroy?: boolean;
}
/**
* The class AsyncResource was designed to be extended by the embedder's async resources.
* Using this users can easily trigger the lifetime events of their own resources.
*/
class AsyncResource {
/**
* AsyncResource() is meant to be extended. Instantiating a
* new AsyncResource() also triggers init. If triggerAsyncId is omitted then
* async_hook.executionAsyncId() is used.
* @param type The type of async event.
* @param triggerAsyncId The ID of the execution context that created
* this async event (default: `executionAsyncId()`), or an
* AsyncResourceOptions object (since 9.3)
*/
constructor(type: string, triggerAsyncId?: number|AsyncResourceOptions);
/**
* Call the provided function with the provided arguments in the
* execution context of the async resource. This will establish the
* context, trigger the AsyncHooks before callbacks, call the function,
* trigger the AsyncHooks after callbacks, and then restore the original
* execution context.
* @param fn The function to call in the execution context of this
* async resource.
* @param thisArg The receiver to be used for the function call.
* @param args Optional arguments to pass to the function.
*/
runInAsyncScope<This, Result>(fn: (this: This, ...args: any[]) => Result, thisArg?: This, ...args: any[]): Result;
/**
* Call AsyncHooks destroy callbacks.
*/
emitDestroy(): void;
/**
* @return the unique ID assigned to this AsyncResource instance.
*/
asyncId(): number;
/**
* @return the trigger ID for this AsyncResource instance.
*/
triggerAsyncId(): number;
}
}

View File

@ -0,0 +1,41 @@
// base definnitions for all NodeJS modules that are not specific to any version of TypeScript
/// <reference path="globals.d.ts" />
/// <reference path="assert.d.ts" />
/// <reference path="async_hooks.d.ts" />
/// <reference path="buffer.d.ts" />
/// <reference path="child_process.d.ts" />
/// <reference path="cluster.d.ts" />
/// <reference path="console.d.ts" />
/// <reference path="constants.d.ts" />
/// <reference path="crypto.d.ts" />
/// <reference path="dgram.d.ts" />
/// <reference path="dns.d.ts" />
/// <reference path="domain.d.ts" />
/// <reference path="events.d.ts" />
/// <reference path="fs.d.ts" />
/// <reference path="http.d.ts" />
/// <reference path="http2.d.ts" />
/// <reference path="https.d.ts" />
/// <reference path="inspector.d.ts" />
/// <reference path="module.d.ts" />
/// <reference path="net.d.ts" />
/// <reference path="os.d.ts" />
/// <reference path="path.d.ts" />
/// <reference path="perf_hooks.d.ts" />
/// <reference path="process.d.ts" />
/// <reference path="punycode.d.ts" />
/// <reference path="querystring.d.ts" />
/// <reference path="readline.d.ts" />
/// <reference path="repl.d.ts" />
/// <reference path="stream.d.ts" />
/// <reference path="string_decoder.d.ts" />
/// <reference path="timers.d.ts" />
/// <reference path="tls.d.ts" />
/// <reference path="trace_events.d.ts" />
/// <reference path="tty.d.ts" />
/// <reference path="url.d.ts" />
/// <reference path="util.d.ts" />
/// <reference path="v8.d.ts" />
/// <reference path="vm.d.ts" />
/// <reference path="worker_threads.d.ts" />
/// <reference path="zlib.d.ts" />

View File

@ -0,0 +1,22 @@
declare module "buffer" {
export const INSPECT_MAX_BYTES: number;
export const kMaxLength: number;
export const kStringMaxLength: number;
export const constants: {
MAX_LENGTH: number;
MAX_STRING_LENGTH: number;
};
const BuffType: typeof Buffer;
export type TranscodeEncoding = "ascii" | "utf8" | "utf16le" | "ucs2" | "latin1" | "binary";
export function transcode(source: Uint8Array, fromEnc: TranscodeEncoding, toEnc: TranscodeEncoding): Buffer;
export const SlowBuffer: {
/** @deprecated since v6.0.0, use Buffer.allocUnsafeSlow() */
new(size: number): Buffer;
prototype: Buffer;
};
export { BuffType as Buffer };
}

View File

@ -0,0 +1,478 @@
declare module "child_process" {
import * as events from "events";
import * as net from "net";
import { Writable, Readable, Stream, Pipe } from "stream";
interface ChildProcess extends events.EventEmitter {
stdin: Writable | null;
stdout: Readable | null;
stderr: Readable | null;
readonly channel?: Pipe | null;
readonly stdio: [
Writable | null, // stdin
Readable | null, // stdout
Readable | null, // stderr
Readable | Writable | null | undefined, // extra
Readable | Writable | null | undefined // extra
];
readonly killed: boolean;
readonly pid: number;
readonly connected: boolean;
kill(signal?: string): void;
send(message: any, callback?: (error: Error | null) => void): boolean;
send(message: any, sendHandle?: net.Socket | net.Server, callback?: (error: Error | null) => void): boolean;
send(message: any, sendHandle?: net.Socket | net.Server, options?: MessageOptions, callback?: (error: Error | null) => void): boolean;
disconnect(): void;
unref(): void;
ref(): void;
/**
* events.EventEmitter
* 1. close
* 2. disconnect
* 3. error
* 4. exit
* 5. message
*/
addListener(event: string, listener: (...args: any[]) => void): this;
addListener(event: "close", listener: (code: number, signal: string) => void): this;
addListener(event: "disconnect", listener: () => void): this;
addListener(event: "error", listener: (err: Error) => void): this;
addListener(event: "exit", listener: (code: number | null, signal: string | null) => void): this;
addListener(event: "message", listener: (message: any, sendHandle: net.Socket | net.Server) => void): this;
emit(event: string | symbol, ...args: any[]): boolean;
emit(event: "close", code: number, signal: string): boolean;
emit(event: "disconnect"): boolean;
emit(event: "error", err: Error): boolean;
emit(event: "exit", code: number | null, signal: string | null): boolean;
emit(event: "message", message: any, sendHandle: net.Socket | net.Server): boolean;
on(event: string, listener: (...args: any[]) => void): this;
on(event: "close", listener: (code: number, signal: string) => void): this;
on(event: "disconnect", listener: () => void): this;
on(event: "error", listener: (err: Error) => void): this;
on(event: "exit", listener: (code: number | null, signal: string | null) => void): this;
on(event: "message", listener: (message: any, sendHandle: net.Socket | net.Server) => void): this;
once(event: string, listener: (...args: any[]) => void): this;
once(event: "close", listener: (code: number, signal: string) => void): this;
once(event: "disconnect", listener: () => void): this;
once(event: "error", listener: (err: Error) => void): this;
once(event: "exit", listener: (code: number | null, signal: string | null) => void): this;
once(event: "message", listener: (message: any, sendHandle: net.Socket | net.Server) => void): this;
prependListener(event: string, listener: (...args: any[]) => void): this;
prependListener(event: "close", listener: (code: number, signal: string) => void): this;
prependListener(event: "disconnect", listener: () => void): this;
prependListener(event: "error", listener: (err: Error) => void): this;
prependListener(event: "exit", listener: (code: number | null, signal: string | null) => void): this;
prependListener(event: "message", listener: (message: any, sendHandle: net.Socket | net.Server) => void): this;
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
prependOnceListener(event: "close", listener: (code: number, signal: string) => void): this;
prependOnceListener(event: "disconnect", listener: () => void): this;
prependOnceListener(event: "error", listener: (err: Error) => void): this;
prependOnceListener(event: "exit", listener: (code: number | null, signal: string | null) => void): this;
prependOnceListener(event: "message", listener: (message: any, sendHandle: net.Socket | net.Server) => void): this;
}
// return this object when stdio option is undefined or not specified
interface ChildProcessWithoutNullStreams extends ChildProcess {
stdin: Writable;
stdout: Readable;
stderr: Readable;
readonly stdio: [
Writable, // stdin
Readable, // stdout
Readable, // stderr
Readable | Writable | null | undefined, // extra, no modification
Readable | Writable | null | undefined // extra, no modification
];
}
// return this object when stdio option is a tuple of 3
interface ChildProcessByStdio<
I extends null | Writable,
O extends null | Readable,
E extends null | Readable,
> extends ChildProcess {
stdin: I;
stdout: O;
stderr: E;
readonly stdio: [
I,
O,
E,
Readable | Writable | null | undefined, // extra, no modification
Readable | Writable | null | undefined // extra, no modification
];
}
interface MessageOptions {
keepOpen?: boolean;
}
type StdioOptions = "pipe" | "ignore" | "inherit" | Array<("pipe" | "ipc" | "ignore" | "inherit" | Stream | number | null | undefined)>;
interface ProcessEnvOptions {
uid?: number;
gid?: number;
cwd?: string;
env?: NodeJS.ProcessEnv;
}
interface CommonOptions extends ProcessEnvOptions {
/**
* @default true
*/
windowsHide?: boolean;
/**
* @default 0
*/
timeout?: number;
}
interface SpawnOptions extends CommonOptions {
argv0?: string;
stdio?: StdioOptions;
detached?: boolean;
shell?: boolean | string;
windowsVerbatimArguments?: boolean;
}
interface SpawnOptionsWithoutStdio extends SpawnOptions {
stdio?: 'pipe' | Array<null | undefined | 'pipe'>;
}
type StdioNull = 'inherit' | 'ignore' | Stream;
type StdioPipe = undefined | null | 'pipe';
interface SpawnOptionsWithStdioTuple<
Stdin extends StdioNull | StdioPipe,
Stdout extends StdioNull | StdioPipe,
Stderr extends StdioNull | StdioPipe,
> extends SpawnOptions {
stdio: [Stdin, Stdout, Stderr];
}
// overloads of spawn without 'args'
function spawn(command: string, options?: SpawnOptionsWithoutStdio): ChildProcessWithoutNullStreams;
function spawn(
command: string,
options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>,
): ChildProcessByStdio<Writable, Readable, Readable>;
function spawn(
command: string,
options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>,
): ChildProcessByStdio<Writable, Readable, null>;
function spawn(
command: string,
options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>,
): ChildProcessByStdio<Writable, null, Readable>;
function spawn(
command: string,
options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>,
): ChildProcessByStdio<null, Readable, Readable>;
function spawn(
command: string,
options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>,
): ChildProcessByStdio<Writable, null, null>;
function spawn(
command: string,
options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>,
): ChildProcessByStdio<null, Readable, null>;
function spawn(
command: string,
options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>,
): ChildProcessByStdio<null, null, Readable>;
function spawn(
command: string,
options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>,
): ChildProcessByStdio<null, null, null>;
function spawn(command: string, options: SpawnOptions): ChildProcess;
// overloads of spawn with 'args'
function spawn(command: string, args?: ReadonlyArray<string>, options?: SpawnOptionsWithoutStdio): ChildProcessWithoutNullStreams;
function spawn(
command: string,
args: ReadonlyArray<string>,
options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>,
): ChildProcessByStdio<Writable, Readable, Readable>;
function spawn(
command: string,
args: ReadonlyArray<string>,
options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>,
): ChildProcessByStdio<Writable, Readable, null>;
function spawn(
command: string,
args: ReadonlyArray<string>,
options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>,
): ChildProcessByStdio<Writable, null, Readable>;
function spawn(
command: string,
args: ReadonlyArray<string>,
options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>,
): ChildProcessByStdio<null, Readable, Readable>;
function spawn(
command: string,
args: ReadonlyArray<string>,
options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>,
): ChildProcessByStdio<Writable, null, null>;
function spawn(
command: string,
args: ReadonlyArray<string>,
options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>,
): ChildProcessByStdio<null, Readable, null>;
function spawn(
command: string,
args: ReadonlyArray<string>,
options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>,
): ChildProcessByStdio<null, null, Readable>;
function spawn(
command: string,
args: ReadonlyArray<string>,
options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>,
): ChildProcessByStdio<null, null, null>;
function spawn(command: string, args: ReadonlyArray<string>, options: SpawnOptions): ChildProcess;
interface ExecOptions extends CommonOptions {
shell?: string;
maxBuffer?: number;
killSignal?: string;
}
interface ExecOptionsWithStringEncoding extends ExecOptions {
encoding: BufferEncoding;
}
interface ExecOptionsWithBufferEncoding extends ExecOptions {
encoding: string | null; // specify `null`.
}
interface ExecException extends Error {
cmd?: string;
killed?: boolean;
code?: number;
signal?: string;
}
// no `options` definitely means stdout/stderr are `string`.
function exec(command: string, callback?: (error: ExecException | null, stdout: string, stderr: string) => void): ChildProcess;
// `options` with `"buffer"` or `null` for `encoding` means stdout/stderr are definitely `Buffer`.
function exec(command: string, options: { encoding: "buffer" | null } & ExecOptions, callback?: (error: ExecException | null, stdout: Buffer, stderr: Buffer) => void): ChildProcess;
// `options` with well known `encoding` means stdout/stderr are definitely `string`.
function exec(command: string, options: { encoding: BufferEncoding } & ExecOptions, callback?: (error: ExecException | null, stdout: string, stderr: string) => void): ChildProcess;
// `options` with an `encoding` whose type is `string` means stdout/stderr could either be `Buffer` or `string`.
// There is no guarantee the `encoding` is unknown as `string` is a superset of `BufferEncoding`.
function exec(command: string, options: { encoding: string } & ExecOptions, callback?: (error: ExecException | null, stdout: string | Buffer, stderr: string | Buffer) => void): ChildProcess;
// `options` without an `encoding` means stdout/stderr are definitely `string`.
function exec(command: string, options: ExecOptions, callback?: (error: ExecException | null, stdout: string, stderr: string) => void): ChildProcess;
// fallback if nothing else matches. Worst case is always `string | Buffer`.
function exec(
command: string,
options: ({ encoding?: string | null } & ExecOptions) | undefined | null,
callback?: (error: ExecException | null, stdout: string | Buffer, stderr: string | Buffer) => void,
): ChildProcess;
interface PromiseWithChild<T> extends Promise<T> {
child: ChildProcess;
}
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
namespace exec {
function __promisify__(command: string): PromiseWithChild<{ stdout: string, stderr: string }>;
function __promisify__(command: string, options: { encoding: "buffer" | null } & ExecOptions): PromiseWithChild<{ stdout: Buffer, stderr: Buffer }>;
function __promisify__(command: string, options: { encoding: BufferEncoding } & ExecOptions): PromiseWithChild<{ stdout: string, stderr: string }>;
function __promisify__(command: string, options: ExecOptions): PromiseWithChild<{ stdout: string, stderr: string }>;
function __promisify__(command: string, options?: ({ encoding?: string | null } & ExecOptions) | null): PromiseWithChild<{ stdout: string | Buffer, stderr: string | Buffer }>;
}
interface ExecFileOptions extends CommonOptions {
maxBuffer?: number;
killSignal?: string;
windowsVerbatimArguments?: boolean;
shell?: boolean | string;
}
interface ExecFileOptionsWithStringEncoding extends ExecFileOptions {
encoding: BufferEncoding;
}
interface ExecFileOptionsWithBufferEncoding extends ExecFileOptions {
encoding: 'buffer' | null;
}
interface ExecFileOptionsWithOtherEncoding extends ExecFileOptions {
encoding: string;
}
function execFile(file: string): ChildProcess;
function execFile(file: string, options: ({ encoding?: string | null } & ExecFileOptions) | undefined | null): ChildProcess;
function execFile(file: string, args?: ReadonlyArray<string> | null): ChildProcess;
function execFile(file: string, args: ReadonlyArray<string> | undefined | null, options: ({ encoding?: string | null } & ExecFileOptions) | undefined | null): ChildProcess;
// no `options` definitely means stdout/stderr are `string`.
function execFile(file: string, callback: (error: Error | null, stdout: string, stderr: string) => void): ChildProcess;
function execFile(file: string, args: ReadonlyArray<string> | undefined | null, callback: (error: Error | null, stdout: string, stderr: string) => void): ChildProcess;
// `options` with `"buffer"` or `null` for `encoding` means stdout/stderr are definitely `Buffer`.
function execFile(file: string, options: ExecFileOptionsWithBufferEncoding, callback: (error: Error | null, stdout: Buffer, stderr: Buffer) => void): ChildProcess;
function execFile(
file: string,
args: ReadonlyArray<string> | undefined | null,
options: ExecFileOptionsWithBufferEncoding,
callback: (error: Error | null, stdout: Buffer, stderr: Buffer) => void,
): ChildProcess;
// `options` with well known `encoding` means stdout/stderr are definitely `string`.
function execFile(file: string, options: ExecFileOptionsWithStringEncoding, callback: (error: Error | null, stdout: string, stderr: string) => void): ChildProcess;
function execFile(
file: string,
args: ReadonlyArray<string> | undefined | null,
options: ExecFileOptionsWithStringEncoding,
callback: (error: Error | null, stdout: string, stderr: string) => void,
): ChildProcess;
// `options` with an `encoding` whose type is `string` means stdout/stderr could either be `Buffer` or `string`.
// There is no guarantee the `encoding` is unknown as `string` is a superset of `BufferEncoding`.
function execFile(
file: string,
options: ExecFileOptionsWithOtherEncoding,
callback: (error: Error | null, stdout: string | Buffer, stderr: string | Buffer) => void,
): ChildProcess;
function execFile(
file: string,
args: ReadonlyArray<string> | undefined | null,
options: ExecFileOptionsWithOtherEncoding,
callback: (error: Error | null, stdout: string | Buffer, stderr: string | Buffer) => void,
): ChildProcess;
// `options` without an `encoding` means stdout/stderr are definitely `string`.
function execFile(file: string, options: ExecFileOptions, callback: (error: Error | null, stdout: string, stderr: string) => void): ChildProcess;
function execFile(file: string, args: ReadonlyArray<string> | undefined | null, options: ExecFileOptions, callback: (error: Error | null, stdout: string, stderr: string) => void): ChildProcess;
// fallback if nothing else matches. Worst case is always `string | Buffer`.
function execFile(
file: string,
options: ({ encoding?: string | null } & ExecFileOptions) | undefined | null,
callback: ((error: Error | null, stdout: string | Buffer, stderr: string | Buffer) => void) | undefined | null,
): ChildProcess;
function execFile(
file: string,
args: ReadonlyArray<string> | undefined | null,
options: ({ encoding?: string | null } & ExecFileOptions) | undefined | null,
callback: ((error: Error | null, stdout: string | Buffer, stderr: string | Buffer) => void) | undefined | null,
): ChildProcess;
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
namespace execFile {
function __promisify__(file: string): PromiseWithChild<{ stdout: string, stderr: string }>;
function __promisify__(file: string, args: string[] | undefined | null): PromiseWithChild<{ stdout: string, stderr: string }>;
function __promisify__(file: string, options: ExecFileOptionsWithBufferEncoding): PromiseWithChild<{ stdout: Buffer, stderr: Buffer }>;
function __promisify__(file: string, args: string[] | undefined | null, options: ExecFileOptionsWithBufferEncoding): PromiseWithChild<{ stdout: Buffer, stderr: Buffer }>;
function __promisify__(file: string, options: ExecFileOptionsWithStringEncoding): PromiseWithChild<{ stdout: string, stderr: string }>;
function __promisify__(file: string, args: string[] | undefined | null, options: ExecFileOptionsWithStringEncoding): PromiseWithChild<{ stdout: string, stderr: string }>;
function __promisify__(file: string, options: ExecFileOptionsWithOtherEncoding): PromiseWithChild<{ stdout: string | Buffer, stderr: string | Buffer }>;
function __promisify__(file: string, args: string[] | undefined | null, options: ExecFileOptionsWithOtherEncoding): PromiseWithChild<{ stdout: string | Buffer, stderr: string | Buffer }>;
function __promisify__(file: string, options: ExecFileOptions): PromiseWithChild<{ stdout: string, stderr: string }>;
function __promisify__(file: string, args: string[] | undefined | null, options: ExecFileOptions): PromiseWithChild<{ stdout: string, stderr: string }>;
function __promisify__(file: string, options: ({ encoding?: string | null } & ExecFileOptions) | undefined | null): PromiseWithChild<{ stdout: string | Buffer, stderr: string | Buffer }>;
function __promisify__(
file: string,
args: string[] | undefined | null,
options: ({ encoding?: string | null } & ExecFileOptions) | undefined | null,
): PromiseWithChild<{ stdout: string | Buffer, stderr: string | Buffer }>;
}
interface ForkOptions extends ProcessEnvOptions {
execPath?: string;
execArgv?: string[];
silent?: boolean;
stdio?: StdioOptions;
detached?: boolean;
windowsVerbatimArguments?: boolean;
}
function fork(modulePath: string, args?: ReadonlyArray<string>, options?: ForkOptions): ChildProcess;
interface SpawnSyncOptions extends CommonOptions {
argv0?: string; // Not specified in the docs
input?: string | NodeJS.ArrayBufferView;
stdio?: StdioOptions;
killSignal?: string | number;
maxBuffer?: number;
encoding?: string;
shell?: boolean | string;
windowsVerbatimArguments?: boolean;
}
interface SpawnSyncOptionsWithStringEncoding extends SpawnSyncOptions {
encoding: BufferEncoding;
}
interface SpawnSyncOptionsWithBufferEncoding extends SpawnSyncOptions {
encoding: string; // specify `null`.
}
interface SpawnSyncReturns<T> {
pid: number;
output: string[];
stdout: T;
stderr: T;
status: number | null;
signal: string | null;
error?: Error;
}
function spawnSync(command: string): SpawnSyncReturns<Buffer>;
function spawnSync(command: string, options?: SpawnSyncOptionsWithStringEncoding): SpawnSyncReturns<string>;
function spawnSync(command: string, options?: SpawnSyncOptionsWithBufferEncoding): SpawnSyncReturns<Buffer>;
function spawnSync(command: string, options?: SpawnSyncOptions): SpawnSyncReturns<Buffer>;
function spawnSync(command: string, args?: ReadonlyArray<string>, options?: SpawnSyncOptionsWithStringEncoding): SpawnSyncReturns<string>;
function spawnSync(command: string, args?: ReadonlyArray<string>, options?: SpawnSyncOptionsWithBufferEncoding): SpawnSyncReturns<Buffer>;
function spawnSync(command: string, args?: ReadonlyArray<string>, options?: SpawnSyncOptions): SpawnSyncReturns<Buffer>;
interface ExecSyncOptions extends CommonOptions {
input?: string | Uint8Array;
stdio?: StdioOptions;
shell?: string;
killSignal?: string | number;
maxBuffer?: number;
encoding?: string;
}
interface ExecSyncOptionsWithStringEncoding extends ExecSyncOptions {
encoding: BufferEncoding;
}
interface ExecSyncOptionsWithBufferEncoding extends ExecSyncOptions {
encoding: string; // specify `null`.
}
function execSync(command: string): Buffer;
function execSync(command: string, options?: ExecSyncOptionsWithStringEncoding): string;
function execSync(command: string, options?: ExecSyncOptionsWithBufferEncoding): Buffer;
function execSync(command: string, options?: ExecSyncOptions): Buffer;
interface ExecFileSyncOptions extends CommonOptions {
input?: string | NodeJS.ArrayBufferView;
stdio?: StdioOptions;
killSignal?: string | number;
maxBuffer?: number;
encoding?: string;
shell?: boolean | string;
}
interface ExecFileSyncOptionsWithStringEncoding extends ExecFileSyncOptions {
encoding: BufferEncoding;
}
interface ExecFileSyncOptionsWithBufferEncoding extends ExecFileSyncOptions {
encoding: string; // specify `null`.
}
function execFileSync(command: string): Buffer;
function execFileSync(command: string, options?: ExecFileSyncOptionsWithStringEncoding): string;
function execFileSync(command: string, options?: ExecFileSyncOptionsWithBufferEncoding): Buffer;
function execFileSync(command: string, options?: ExecFileSyncOptions): Buffer;
function execFileSync(command: string, args?: ReadonlyArray<string>, options?: ExecFileSyncOptionsWithStringEncoding): string;
function execFileSync(command: string, args?: ReadonlyArray<string>, options?: ExecFileSyncOptionsWithBufferEncoding): Buffer;
function execFileSync(command: string, args?: ReadonlyArray<string>, options?: ExecFileSyncOptions): Buffer;
}

View File

@ -0,0 +1,260 @@
declare module "cluster" {
import * as child from "child_process";
import * as events from "events";
import * as net from "net";
// interfaces
interface ClusterSettings {
execArgv?: string[]; // default: process.execArgv
exec?: string;
args?: string[];
silent?: boolean;
stdio?: any[];
uid?: number;
gid?: number;
inspectPort?: number | (() => number);
}
interface Address {
address: string;
port: number;
addressType: number | "udp4" | "udp6"; // 4, 6, -1, "udp4", "udp6"
}
class Worker extends events.EventEmitter {
id: number;
process: child.ChildProcess;
send(message: any, sendHandle?: any, callback?: (error: Error | null) => void): boolean;
kill(signal?: string): void;
destroy(signal?: string): void;
disconnect(): void;
isConnected(): boolean;
isDead(): boolean;
exitedAfterDisconnect: boolean;
/**
* events.EventEmitter
* 1. disconnect
* 2. error
* 3. exit
* 4. listening
* 5. message
* 6. online
*/
addListener(event: string, listener: (...args: any[]) => void): this;
addListener(event: "disconnect", listener: () => void): this;
addListener(event: "error", listener: (error: Error) => void): this;
addListener(event: "exit", listener: (code: number, signal: string) => void): this;
addListener(event: "listening", listener: (address: Address) => void): this;
addListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
addListener(event: "online", listener: () => void): this;
emit(event: string | symbol, ...args: any[]): boolean;
emit(event: "disconnect"): boolean;
emit(event: "error", error: Error): boolean;
emit(event: "exit", code: number, signal: string): boolean;
emit(event: "listening", address: Address): boolean;
emit(event: "message", message: any, handle: net.Socket | net.Server): boolean;
emit(event: "online"): boolean;
on(event: string, listener: (...args: any[]) => void): this;
on(event: "disconnect", listener: () => void): this;
on(event: "error", listener: (error: Error) => void): this;
on(event: "exit", listener: (code: number, signal: string) => void): this;
on(event: "listening", listener: (address: Address) => void): this;
on(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
on(event: "online", listener: () => void): this;
once(event: string, listener: (...args: any[]) => void): this;
once(event: "disconnect", listener: () => void): this;
once(event: "error", listener: (error: Error) => void): this;
once(event: "exit", listener: (code: number, signal: string) => void): this;
once(event: "listening", listener: (address: Address) => void): this;
once(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
once(event: "online", listener: () => void): this;
prependListener(event: string, listener: (...args: any[]) => void): this;
prependListener(event: "disconnect", listener: () => void): this;
prependListener(event: "error", listener: (error: Error) => void): this;
prependListener(event: "exit", listener: (code: number, signal: string) => void): this;
prependListener(event: "listening", listener: (address: Address) => void): this;
prependListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
prependListener(event: "online", listener: () => void): this;
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
prependOnceListener(event: "disconnect", listener: () => void): this;
prependOnceListener(event: "error", listener: (error: Error) => void): this;
prependOnceListener(event: "exit", listener: (code: number, signal: string) => void): this;
prependOnceListener(event: "listening", listener: (address: Address) => void): this;
prependOnceListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
prependOnceListener(event: "online", listener: () => void): this;
}
interface Cluster extends events.EventEmitter {
Worker: Worker;
disconnect(callback?: () => void): void;
fork(env?: any): Worker;
isMaster: boolean;
isWorker: boolean;
// TODO: cluster.schedulingPolicy
settings: ClusterSettings;
setupMaster(settings?: ClusterSettings): void;
worker?: Worker;
workers?: {
[index: string]: Worker | undefined
};
/**
* events.EventEmitter
* 1. disconnect
* 2. exit
* 3. fork
* 4. listening
* 5. message
* 6. online
* 7. setup
*/
addListener(event: string, listener: (...args: any[]) => void): this;
addListener(event: "disconnect", listener: (worker: Worker) => void): this;
addListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
addListener(event: "fork", listener: (worker: Worker) => void): this;
addListener(event: "listening", listener: (worker: Worker, address: Address) => void): this;
addListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
addListener(event: "online", listener: (worker: Worker) => void): this;
addListener(event: "setup", listener: (settings: ClusterSettings) => void): this;
emit(event: string | symbol, ...args: any[]): boolean;
emit(event: "disconnect", worker: Worker): boolean;
emit(event: "exit", worker: Worker, code: number, signal: string): boolean;
emit(event: "fork", worker: Worker): boolean;
emit(event: "listening", worker: Worker, address: Address): boolean;
emit(event: "message", worker: Worker, message: any, handle: net.Socket | net.Server): boolean;
emit(event: "online", worker: Worker): boolean;
emit(event: "setup", settings: ClusterSettings): boolean;
on(event: string, listener: (...args: any[]) => void): this;
on(event: "disconnect", listener: (worker: Worker) => void): this;
on(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
on(event: "fork", listener: (worker: Worker) => void): this;
on(event: "listening", listener: (worker: Worker, address: Address) => void): this;
on(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
on(event: "online", listener: (worker: Worker) => void): this;
on(event: "setup", listener: (settings: ClusterSettings) => void): this;
once(event: string, listener: (...args: any[]) => void): this;
once(event: "disconnect", listener: (worker: Worker) => void): this;
once(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
once(event: "fork", listener: (worker: Worker) => void): this;
once(event: "listening", listener: (worker: Worker, address: Address) => void): this;
once(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
once(event: "online", listener: (worker: Worker) => void): this;
once(event: "setup", listener: (settings: ClusterSettings) => void): this;
prependListener(event: string, listener: (...args: any[]) => void): this;
prependListener(event: "disconnect", listener: (worker: Worker) => void): this;
prependListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
prependListener(event: "fork", listener: (worker: Worker) => void): this;
prependListener(event: "listening", listener: (worker: Worker, address: Address) => void): this;
prependListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
prependListener(event: "online", listener: (worker: Worker) => void): this;
prependListener(event: "setup", listener: (settings: ClusterSettings) => void): this;
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
prependOnceListener(event: "disconnect", listener: (worker: Worker) => void): this;
prependOnceListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
prependOnceListener(event: "fork", listener: (worker: Worker) => void): this;
prependOnceListener(event: "listening", listener: (worker: Worker, address: Address) => void): this;
// the handle is a net.Socket or net.Server object, or undefined.
prependOnceListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this;
prependOnceListener(event: "online", listener: (worker: Worker) => void): this;
prependOnceListener(event: "setup", listener: (settings: ClusterSettings) => void): this;
}
function disconnect(callback?: () => void): void;
function fork(env?: any): Worker;
const isMaster: boolean;
const isWorker: boolean;
// TODO: cluster.schedulingPolicy
const settings: ClusterSettings;
function setupMaster(settings?: ClusterSettings): void;
const worker: Worker;
const workers: {
[index: string]: Worker | undefined
};
/**
* events.EventEmitter
* 1. disconnect
* 2. exit
* 3. fork
* 4. listening
* 5. message
* 6. online
* 7. setup
*/
function addListener(event: string, listener: (...args: any[]) => void): Cluster;
function addListener(event: "disconnect", listener: (worker: Worker) => void): Cluster;
function addListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster;
function addListener(event: "fork", listener: (worker: Worker) => void): Cluster;
function addListener(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster;
// the handle is a net.Socket or net.Server object, or undefined.
function addListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): Cluster;
function addListener(event: "online", listener: (worker: Worker) => void): Cluster;
function addListener(event: "setup", listener: (settings: ClusterSettings) => void): Cluster;
function emit(event: string | symbol, ...args: any[]): boolean;
function emit(event: "disconnect", worker: Worker): boolean;
function emit(event: "exit", worker: Worker, code: number, signal: string): boolean;
function emit(event: "fork", worker: Worker): boolean;
function emit(event: "listening", worker: Worker, address: Address): boolean;
function emit(event: "message", worker: Worker, message: any, handle: net.Socket | net.Server): boolean;
function emit(event: "online", worker: Worker): boolean;
function emit(event: "setup", settings: ClusterSettings): boolean;
function on(event: string, listener: (...args: any[]) => void): Cluster;
function on(event: "disconnect", listener: (worker: Worker) => void): Cluster;
function on(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster;
function on(event: "fork", listener: (worker: Worker) => void): Cluster;
function on(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster;
function on(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): Cluster; // the handle is a net.Socket or net.Server object, or undefined.
function on(event: "online", listener: (worker: Worker) => void): Cluster;
function on(event: "setup", listener: (settings: ClusterSettings) => void): Cluster;
function once(event: string, listener: (...args: any[]) => void): Cluster;
function once(event: "disconnect", listener: (worker: Worker) => void): Cluster;
function once(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster;
function once(event: "fork", listener: (worker: Worker) => void): Cluster;
function once(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster;
function once(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): Cluster; // the handle is a net.Socket or net.Server object, or undefined.
function once(event: "online", listener: (worker: Worker) => void): Cluster;
function once(event: "setup", listener: (settings: ClusterSettings) => void): Cluster;
function removeListener(event: string, listener: (...args: any[]) => void): Cluster;
function removeAllListeners(event?: string): Cluster;
function setMaxListeners(n: number): Cluster;
function getMaxListeners(): number;
function listeners(event: string): Function[];
function listenerCount(type: string): number;
function prependListener(event: string, listener: (...args: any[]) => void): Cluster;
function prependListener(event: "disconnect", listener: (worker: Worker) => void): Cluster;
function prependListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster;
function prependListener(event: "fork", listener: (worker: Worker) => void): Cluster;
function prependListener(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster;
// the handle is a net.Socket or net.Server object, or undefined.
function prependListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): Cluster;
function prependListener(event: "online", listener: (worker: Worker) => void): Cluster;
function prependListener(event: "setup", listener: (settings: ClusterSettings) => void): Cluster;
function prependOnceListener(event: string, listener: (...args: any[]) => void): Cluster;
function prependOnceListener(event: "disconnect", listener: (worker: Worker) => void): Cluster;
function prependOnceListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster;
function prependOnceListener(event: "fork", listener: (worker: Worker) => void): Cluster;
function prependOnceListener(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster;
// the handle is a net.Socket or net.Server object, or undefined.
function prependOnceListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): Cluster;
function prependOnceListener(event: "online", listener: (worker: Worker) => void): Cluster;
function prependOnceListener(event: "setup", listener: (settings: ClusterSettings) => void): Cluster;
function eventNames(): string[];
}

View File

@ -0,0 +1,3 @@
declare module "console" {
export = console;
}

View File

@ -0,0 +1,448 @@
/** @deprecated since v6.3.0 - use constants property exposed by the relevant module instead. */
declare module "constants" {
/** @deprecated since v6.3.0 - use `os.constants.errno.E2BIG` instead. */
const E2BIG: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.EACCES` instead. */
const EACCES: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.EADDRINUSE` instead. */
const EADDRINUSE: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.EADDRNOTAVAIL` instead. */
const EADDRNOTAVAIL: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.EAFNOSUPPORT` instead. */
const EAFNOSUPPORT: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.EAGAIN` instead. */
const EAGAIN: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.EALREADY` instead. */
const EALREADY: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.EBADF` instead. */
const EBADF: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.EBADMSG` instead. */
const EBADMSG: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.EBUSY` instead. */
const EBUSY: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.ECANCELED` instead. */
const ECANCELED: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.ECHILD` instead. */
const ECHILD: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.ECONNABORTED` instead. */
const ECONNABORTED: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.ECONNREFUSED` instead. */
const ECONNREFUSED: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.ECONNRESET` instead. */
const ECONNRESET: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.EDEADLK` instead. */
const EDEADLK: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.EDESTADDRREQ` instead. */
const EDESTADDRREQ: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.EDOM` instead. */
const EDOM: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.EEXIST` instead. */
const EEXIST: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.EFAULT` instead. */
const EFAULT: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.EFBIG` instead. */
const EFBIG: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.EHOSTUNREACH` instead. */
const EHOSTUNREACH: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.EIDRM` instead. */
const EIDRM: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.EILSEQ` instead. */
const EILSEQ: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.EINPROGRESS` instead. */
const EINPROGRESS: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.EINTR` instead. */
const EINTR: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.EINVAL` instead. */
const EINVAL: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.EIO` instead. */
const EIO: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.EISCONN` instead. */
const EISCONN: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.EISDIR` instead. */
const EISDIR: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.ELOOP` instead. */
const ELOOP: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.EMFILE` instead. */
const EMFILE: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.EMLINK` instead. */
const EMLINK: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.EMSGSIZE` instead. */
const EMSGSIZE: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.ENAMETOOLONG` instead. */
const ENAMETOOLONG: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.ENETDOWN` instead. */
const ENETDOWN: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.ENETRESET` instead. */
const ENETRESET: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.ENETUNREACH` instead. */
const ENETUNREACH: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.ENFILE` instead. */
const ENFILE: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOBUFS` instead. */
const ENOBUFS: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.ENODATA` instead. */
const ENODATA: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.ENODEV` instead. */
const ENODEV: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOENT` instead. */
const ENOENT: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOEXEC` instead. */
const ENOEXEC: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOLCK` instead. */
const ENOLCK: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOLINK` instead. */
const ENOLINK: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOMEM` instead. */
const ENOMEM: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOMSG` instead. */
const ENOMSG: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOPROTOOPT` instead. */
const ENOPROTOOPT: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOSPC` instead. */
const ENOSPC: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOSR` instead. */
const ENOSR: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOSTR` instead. */
const ENOSTR: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOSYS` instead. */
const ENOSYS: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOTCONN` instead. */
const ENOTCONN: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOTDIR` instead. */
const ENOTDIR: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOTEMPTY` instead. */
const ENOTEMPTY: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOTSOCK` instead. */
const ENOTSOCK: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOTSUP` instead. */
const ENOTSUP: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.ENOTTY` instead. */
const ENOTTY: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.ENXIO` instead. */
const ENXIO: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.EOPNOTSUPP` instead. */
const EOPNOTSUPP: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.EOVERFLOW` instead. */
const EOVERFLOW: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.EPERM` instead. */
const EPERM: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.EPIPE` instead. */
const EPIPE: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.EPROTO` instead. */
const EPROTO: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.EPROTONOSUPPORT` instead. */
const EPROTONOSUPPORT: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.EPROTOTYPE` instead. */
const EPROTOTYPE: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.ERANGE` instead. */
const ERANGE: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.EROFS` instead. */
const EROFS: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.ESPIPE` instead. */
const ESPIPE: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.ESRCH` instead. */
const ESRCH: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.ETIME` instead. */
const ETIME: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.ETIMEDOUT` instead. */
const ETIMEDOUT: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.ETXTBSY` instead. */
const ETXTBSY: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.EWOULDBLOCK` instead. */
const EWOULDBLOCK: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.EXDEV` instead. */
const EXDEV: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEINTR` instead. */
const WSAEINTR: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEBADF` instead. */
const WSAEBADF: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEACCES` instead. */
const WSAEACCES: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEFAULT` instead. */
const WSAEFAULT: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEINVAL` instead. */
const WSAEINVAL: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEMFILE` instead. */
const WSAEMFILE: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEWOULDBLOCK` instead. */
const WSAEWOULDBLOCK: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEINPROGRESS` instead. */
const WSAEINPROGRESS: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEALREADY` instead. */
const WSAEALREADY: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAENOTSOCK` instead. */
const WSAENOTSOCK: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEDESTADDRREQ` instead. */
const WSAEDESTADDRREQ: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEMSGSIZE` instead. */
const WSAEMSGSIZE: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEPROTOTYPE` instead. */
const WSAEPROTOTYPE: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAENOPROTOOPT` instead. */
const WSAENOPROTOOPT: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEPROTONOSUPPORT` instead. */
const WSAEPROTONOSUPPORT: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAESOCKTNOSUPPORT` instead. */
const WSAESOCKTNOSUPPORT: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEOPNOTSUPP` instead. */
const WSAEOPNOTSUPP: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEPFNOSUPPORT` instead. */
const WSAEPFNOSUPPORT: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEAFNOSUPPORT` instead. */
const WSAEAFNOSUPPORT: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEADDRINUSE` instead. */
const WSAEADDRINUSE: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEADDRNOTAVAIL` instead. */
const WSAEADDRNOTAVAIL: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAENETDOWN` instead. */
const WSAENETDOWN: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAENETUNREACH` instead. */
const WSAENETUNREACH: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAENETRESET` instead. */
const WSAENETRESET: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAECONNABORTED` instead. */
const WSAECONNABORTED: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAECONNRESET` instead. */
const WSAECONNRESET: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAENOBUFS` instead. */
const WSAENOBUFS: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEISCONN` instead. */
const WSAEISCONN: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAENOTCONN` instead. */
const WSAENOTCONN: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAESHUTDOWN` instead. */
const WSAESHUTDOWN: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAETOOMANYREFS` instead. */
const WSAETOOMANYREFS: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAETIMEDOUT` instead. */
const WSAETIMEDOUT: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAECONNREFUSED` instead. */
const WSAECONNREFUSED: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAELOOP` instead. */
const WSAELOOP: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAENAMETOOLONG` instead. */
const WSAENAMETOOLONG: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEHOSTDOWN` instead. */
const WSAEHOSTDOWN: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEHOSTUNREACH` instead. */
const WSAEHOSTUNREACH: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAENOTEMPTY` instead. */
const WSAENOTEMPTY: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEPROCLIM` instead. */
const WSAEPROCLIM: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEUSERS` instead. */
const WSAEUSERS: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEDQUOT` instead. */
const WSAEDQUOT: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAESTALE` instead. */
const WSAESTALE: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEREMOTE` instead. */
const WSAEREMOTE: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSASYSNOTREADY` instead. */
const WSASYSNOTREADY: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAVERNOTSUPPORTED` instead. */
const WSAVERNOTSUPPORTED: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSANOTINITIALISED` instead. */
const WSANOTINITIALISED: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEDISCON` instead. */
const WSAEDISCON: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAENOMORE` instead. */
const WSAENOMORE: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAECANCELLED` instead. */
const WSAECANCELLED: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEINVALIDPROCTABLE` instead. */
const WSAEINVALIDPROCTABLE: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEINVALIDPROVIDER` instead. */
const WSAEINVALIDPROVIDER: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEPROVIDERFAILEDINIT` instead. */
const WSAEPROVIDERFAILEDINIT: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSASYSCALLFAILURE` instead. */
const WSASYSCALLFAILURE: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSASERVICE_NOT_FOUND` instead. */
const WSASERVICE_NOT_FOUND: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSATYPE_NOT_FOUND` instead. */
const WSATYPE_NOT_FOUND: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSA_E_NO_MORE` instead. */
const WSA_E_NO_MORE: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSA_E_CANCELLED` instead. */
const WSA_E_CANCELLED: number;
/** @deprecated since v6.3.0 - use `os.constants.errno.WSAEREFUSED` instead. */
const WSAEREFUSED: number;
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGHUP` instead. */
const SIGHUP: number;
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGINT` instead. */
const SIGINT: number;
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGILL` instead. */
const SIGILL: number;
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGABRT` instead. */
const SIGABRT: number;
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGFPE` instead. */
const SIGFPE: number;
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGKILL` instead. */
const SIGKILL: number;
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGSEGV` instead. */
const SIGSEGV: number;
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGTERM` instead. */
const SIGTERM: number;
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGBREAK` instead. */
const SIGBREAK: number;
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGWINCH` instead. */
const SIGWINCH: number;
const SSL_OP_ALL: number;
const SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: number;
const SSL_OP_CIPHER_SERVER_PREFERENCE: number;
const SSL_OP_CISCO_ANYCONNECT: number;
const SSL_OP_COOKIE_EXCHANGE: number;
const SSL_OP_CRYPTOPRO_TLSEXT_BUG: number;
const SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: number;
const SSL_OP_EPHEMERAL_RSA: number;
const SSL_OP_LEGACY_SERVER_CONNECT: number;
const SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER: number;
const SSL_OP_MICROSOFT_SESS_ID_BUG: number;
const SSL_OP_MSIE_SSLV2_RSA_PADDING: number;
const SSL_OP_NETSCAPE_CA_DN_BUG: number;
const SSL_OP_NETSCAPE_CHALLENGE_BUG: number;
const SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG: number;
const SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG: number;
const SSL_OP_NO_COMPRESSION: number;
const SSL_OP_NO_QUERY_MTU: number;
const SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION: number;
const SSL_OP_NO_SSLv2: number;
const SSL_OP_NO_SSLv3: number;
const SSL_OP_NO_TICKET: number;
const SSL_OP_NO_TLSv1: number;
const SSL_OP_NO_TLSv1_1: number;
const SSL_OP_NO_TLSv1_2: number;
const SSL_OP_PKCS1_CHECK_1: number;
const SSL_OP_PKCS1_CHECK_2: number;
const SSL_OP_SINGLE_DH_USE: number;
const SSL_OP_SINGLE_ECDH_USE: number;
const SSL_OP_SSLEAY_080_CLIENT_DH_BUG: number;
const SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG: number;
const SSL_OP_TLS_BLOCK_PADDING_BUG: number;
const SSL_OP_TLS_D5_BUG: number;
const SSL_OP_TLS_ROLLBACK_BUG: number;
const ENGINE_METHOD_DSA: number;
const ENGINE_METHOD_DH: number;
const ENGINE_METHOD_RAND: number;
const ENGINE_METHOD_ECDH: number;
const ENGINE_METHOD_ECDSA: number;
const ENGINE_METHOD_CIPHERS: number;
const ENGINE_METHOD_DIGESTS: number;
const ENGINE_METHOD_STORE: number;
const ENGINE_METHOD_PKEY_METHS: number;
const ENGINE_METHOD_PKEY_ASN1_METHS: number;
const ENGINE_METHOD_ALL: number;
const ENGINE_METHOD_NONE: number;
const DH_CHECK_P_NOT_SAFE_PRIME: number;
const DH_CHECK_P_NOT_PRIME: number;
const DH_UNABLE_TO_CHECK_GENERATOR: number;
const DH_NOT_SUITABLE_GENERATOR: number;
const RSA_PKCS1_PADDING: number;
const RSA_SSLV23_PADDING: number;
const RSA_NO_PADDING: number;
const RSA_PKCS1_OAEP_PADDING: number;
const RSA_X931_PADDING: number;
const RSA_PKCS1_PSS_PADDING: number;
const POINT_CONVERSION_COMPRESSED: number;
const POINT_CONVERSION_UNCOMPRESSED: number;
const POINT_CONVERSION_HYBRID: number;
const O_RDONLY: number;
const O_WRONLY: number;
const O_RDWR: number;
const S_IFMT: number;
const S_IFREG: number;
const S_IFDIR: number;
const S_IFCHR: number;
const S_IFBLK: number;
const S_IFIFO: number;
const S_IFSOCK: number;
const S_IRWXU: number;
const S_IRUSR: number;
const S_IWUSR: number;
const S_IXUSR: number;
const S_IRWXG: number;
const S_IRGRP: number;
const S_IWGRP: number;
const S_IXGRP: number;
const S_IRWXO: number;
const S_IROTH: number;
const S_IWOTH: number;
const S_IXOTH: number;
const S_IFLNK: number;
const O_CREAT: number;
const O_EXCL: number;
const O_NOCTTY: number;
const O_DIRECTORY: number;
const O_NOATIME: number;
const O_NOFOLLOW: number;
const O_SYNC: number;
const O_DSYNC: number;
const O_SYMLINK: number;
const O_DIRECT: number;
const O_NONBLOCK: number;
const O_TRUNC: number;
const O_APPEND: number;
const F_OK: number;
const R_OK: number;
const W_OK: number;
const X_OK: number;
const COPYFILE_EXCL: number;
const COPYFILE_FICLONE: number;
const COPYFILE_FICLONE_FORCE: number;
const UV_UDP_REUSEADDR: number;
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGQUIT` instead. */
const SIGQUIT: number;
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGTRAP` instead. */
const SIGTRAP: number;
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGIOT` instead. */
const SIGIOT: number;
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGBUS` instead. */
const SIGBUS: number;
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGUSR1` instead. */
const SIGUSR1: number;
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGUSR2` instead. */
const SIGUSR2: number;
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGPIPE` instead. */
const SIGPIPE: number;
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGALRM` instead. */
const SIGALRM: number;
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGCHLD` instead. */
const SIGCHLD: number;
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGSTKFLT` instead. */
const SIGSTKFLT: number;
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGCONT` instead. */
const SIGCONT: number;
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGSTOP` instead. */
const SIGSTOP: number;
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGTSTP` instead. */
const SIGTSTP: number;
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGTTIN` instead. */
const SIGTTIN: number;
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGTTOU` instead. */
const SIGTTOU: number;
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGURG` instead. */
const SIGURG: number;
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGXCPU` instead. */
const SIGXCPU: number;
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGXFSZ` instead. */
const SIGXFSZ: number;
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGVTALRM` instead. */
const SIGVTALRM: number;
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGPROF` instead. */
const SIGPROF: number;
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGIO` instead. */
const SIGIO: number;
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGPOLL` instead. */
const SIGPOLL: number;
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGPWR` instead. */
const SIGPWR: number;
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGSYS` instead. */
const SIGSYS: number;
/** @deprecated since v6.3.0 - use `os.constants.signals.SIGUNUSED` instead. */
const SIGUNUSED: number;
const defaultCoreCipherList: string;
const defaultCipherList: string;
const ENGINE_METHOD_RSA: number;
const ALPN_ENABLED: number;
}

View File

@ -0,0 +1,614 @@
declare module "crypto" {
import * as stream from "stream";
interface Certificate {
exportChallenge(spkac: BinaryLike): Buffer;
exportPublicKey(spkac: BinaryLike): Buffer;
verifySpkac(spkac: NodeJS.ArrayBufferView): boolean;
}
const Certificate: {
new(): Certificate;
(): Certificate;
};
namespace constants { // https://nodejs.org/dist/latest-v10.x/docs/api/crypto.html#crypto_crypto_constants
const OPENSSL_VERSION_NUMBER: number;
/** Applies multiple bug workarounds within OpenSSL. See https://www.openssl.org/docs/man1.0.2/ssl/SSL_CTX_set_options.html for detail. */
const SSL_OP_ALL: number;
/** Allows legacy insecure renegotiation between OpenSSL and unpatched clients or servers. See https://www.openssl.org/docs/man1.0.2/ssl/SSL_CTX_set_options.html. */
const SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: number;
/** Attempts to use the server's preferences instead of the client's when selecting a cipher. See https://www.openssl.org/docs/man1.0.2/ssl/SSL_CTX_set_options.html. */
const SSL_OP_CIPHER_SERVER_PREFERENCE: number;
/** Instructs OpenSSL to use Cisco's "speshul" version of DTLS_BAD_VER. */
const SSL_OP_CISCO_ANYCONNECT: number;
/** Instructs OpenSSL to turn on cookie exchange. */
const SSL_OP_COOKIE_EXCHANGE: number;
/** Instructs OpenSSL to add server-hello extension from an early version of the cryptopro draft. */
const SSL_OP_CRYPTOPRO_TLSEXT_BUG: number;
/** Instructs OpenSSL to disable a SSL 3.0/TLS 1.0 vulnerability workaround added in OpenSSL 0.9.6d. */
const SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: number;
/** Instructs OpenSSL to always use the tmp_rsa key when performing RSA operations. */
const SSL_OP_EPHEMERAL_RSA: number;
/** Allows initial connection to servers that do not support RI. */
const SSL_OP_LEGACY_SERVER_CONNECT: number;
const SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER: number;
const SSL_OP_MICROSOFT_SESS_ID_BUG: number;
/** Instructs OpenSSL to disable the workaround for a man-in-the-middle protocol-version vulnerability in the SSL 2.0 server implementation. */
const SSL_OP_MSIE_SSLV2_RSA_PADDING: number;
const SSL_OP_NETSCAPE_CA_DN_BUG: number;
const SSL_OP_NETSCAPE_CHALLENGE_BUG: number;
const SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG: number;
const SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG: number;
/** Instructs OpenSSL to disable support for SSL/TLS compression. */
const SSL_OP_NO_COMPRESSION: number;
const SSL_OP_NO_QUERY_MTU: number;
/** Instructs OpenSSL to always start a new session when performing renegotiation. */
const SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION: number;
const SSL_OP_NO_SSLv2: number;
const SSL_OP_NO_SSLv3: number;
const SSL_OP_NO_TICKET: number;
const SSL_OP_NO_TLSv1: number;
const SSL_OP_NO_TLSv1_1: number;
const SSL_OP_NO_TLSv1_2: number;
const SSL_OP_PKCS1_CHECK_1: number;
const SSL_OP_PKCS1_CHECK_2: number;
/** Instructs OpenSSL to always create a new key when using temporary/ephemeral DH parameters. */
const SSL_OP_SINGLE_DH_USE: number;
/** Instructs OpenSSL to always create a new key when using temporary/ephemeral ECDH parameters. */
const SSL_OP_SINGLE_ECDH_USE: number;
const SSL_OP_SSLEAY_080_CLIENT_DH_BUG: number;
const SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG: number;
const SSL_OP_TLS_BLOCK_PADDING_BUG: number;
const SSL_OP_TLS_D5_BUG: number;
/** Instructs OpenSSL to disable version rollback attack detection. */
const SSL_OP_TLS_ROLLBACK_BUG: number;
const ENGINE_METHOD_RSA: number;
const ENGINE_METHOD_DSA: number;
const ENGINE_METHOD_DH: number;
const ENGINE_METHOD_RAND: number;
const ENGINE_METHOD_EC: number;
const ENGINE_METHOD_CIPHERS: number;
const ENGINE_METHOD_DIGESTS: number;
const ENGINE_METHOD_PKEY_METHS: number;
const ENGINE_METHOD_PKEY_ASN1_METHS: number;
const ENGINE_METHOD_ALL: number;
const ENGINE_METHOD_NONE: number;
const DH_CHECK_P_NOT_SAFE_PRIME: number;
const DH_CHECK_P_NOT_PRIME: number;
const DH_UNABLE_TO_CHECK_GENERATOR: number;
const DH_NOT_SUITABLE_GENERATOR: number;
const ALPN_ENABLED: number;
const RSA_PKCS1_PADDING: number;
const RSA_SSLV23_PADDING: number;
const RSA_NO_PADDING: number;
const RSA_PKCS1_OAEP_PADDING: number;
const RSA_X931_PADDING: number;
const RSA_PKCS1_PSS_PADDING: number;
/** Sets the salt length for RSA_PKCS1_PSS_PADDING to the digest size when signing or verifying. */
const RSA_PSS_SALTLEN_DIGEST: number;
/** Sets the salt length for RSA_PKCS1_PSS_PADDING to the maximum permissible value when signing data. */
const RSA_PSS_SALTLEN_MAX_SIGN: number;
/** Causes the salt length for RSA_PKCS1_PSS_PADDING to be determined automatically when verifying a signature. */
const RSA_PSS_SALTLEN_AUTO: number;
const POINT_CONVERSION_COMPRESSED: number;
const POINT_CONVERSION_UNCOMPRESSED: number;
const POINT_CONVERSION_HYBRID: number;
/** Specifies the built-in default cipher list used by Node.js (colon-separated values). */
const defaultCoreCipherList: string;
/** Specifies the active default cipher list used by the current Node.js process (colon-separated values). */
const defaultCipherList: string;
}
interface HashOptions extends stream.TransformOptions {
/**
* For XOF hash functions such as `shake256`, the
* outputLength option can be used to specify the desired output length in bytes.
*/
outputLength?: number;
}
/** @deprecated since v10.0.0 */
const fips: boolean;
function createHash(algorithm: string, options?: HashOptions): Hash;
function createHmac(algorithm: string, key: BinaryLike, options?: stream.TransformOptions): Hmac;
type Utf8AsciiLatin1Encoding = "utf8" | "ascii" | "latin1";
type HexBase64Latin1Encoding = "latin1" | "hex" | "base64";
type Utf8AsciiBinaryEncoding = "utf8" | "ascii" | "binary";
type HexBase64BinaryEncoding = "binary" | "base64" | "hex";
type ECDHKeyFormat = "compressed" | "uncompressed" | "hybrid";
class Hash extends stream.Transform {
private constructor();
update(data: BinaryLike): Hash;
update(data: string, input_encoding: Utf8AsciiLatin1Encoding): Hash;
digest(): Buffer;
digest(encoding: HexBase64Latin1Encoding): string;
}
class Hmac extends stream.Transform {
private constructor();
update(data: BinaryLike): Hmac;
update(data: string, input_encoding: Utf8AsciiLatin1Encoding): Hmac;
digest(): Buffer;
digest(encoding: HexBase64Latin1Encoding): string;
}
type KeyObjectType = 'secret' | 'public' | 'private';
interface KeyExportOptions<T extends KeyFormat> {
type: 'pkcs1' | 'spki' | 'pkcs8' | 'sec1';
format: T;
cipher?: string;
passphrase?: string | Buffer;
}
class KeyObject {
private constructor();
asymmetricKeyType?: KeyType;
/**
* For asymmetric keys, this property represents the size of the embedded key in
* bytes. This property is `undefined` for symmetric keys.
*/
asymmetricKeySize?: number;
export(options: KeyExportOptions<'pem'>): string | Buffer;
export(options?: KeyExportOptions<'der'>): Buffer;
symmetricSize?: number;
type: KeyObjectType;
}
type CipherCCMTypes = 'aes-128-ccm' | 'aes-192-ccm' | 'aes-256-ccm';
type CipherGCMTypes = 'aes-128-gcm' | 'aes-192-gcm' | 'aes-256-gcm';
type BinaryLike = string | NodeJS.ArrayBufferView;
type CipherKey = BinaryLike | KeyObject;
interface CipherCCMOptions extends stream.TransformOptions {
authTagLength: number;
}
interface CipherGCMOptions extends stream.TransformOptions {
authTagLength?: number;
}
/** @deprecated since v10.0.0 use createCipheriv() */
function createCipher(algorithm: CipherCCMTypes, password: BinaryLike, options: CipherCCMOptions): CipherCCM;
/** @deprecated since v10.0.0 use createCipheriv() */
function createCipher(algorithm: CipherGCMTypes, password: BinaryLike, options?: CipherGCMOptions): CipherGCM;
/** @deprecated since v10.0.0 use createCipheriv() */
function createCipher(algorithm: string, password: BinaryLike, options?: stream.TransformOptions): Cipher;
function createCipheriv(
algorithm: CipherCCMTypes,
key: CipherKey,
iv: BinaryLike | null,
options: CipherCCMOptions
): CipherCCM;
function createCipheriv(
algorithm: CipherGCMTypes,
key: CipherKey,
iv: BinaryLike | null,
options?: CipherGCMOptions
): CipherGCM;
function createCipheriv(
algorithm: string, key: CipherKey, iv: BinaryLike | null, options?: stream.TransformOptions
): Cipher;
class Cipher extends stream.Transform {
private constructor();
update(data: BinaryLike): Buffer;
update(data: string, input_encoding: Utf8AsciiBinaryEncoding): Buffer;
update(data: NodeJS.ArrayBufferView, input_encoding: undefined, output_encoding: HexBase64BinaryEncoding): string;
update(data: string, input_encoding: Utf8AsciiBinaryEncoding | undefined, output_encoding: HexBase64BinaryEncoding): string;
final(): Buffer;
final(output_encoding: string): string;
setAutoPadding(auto_padding?: boolean): this;
// getAuthTag(): Buffer;
// setAAD(buffer: Buffer): this; // docs only say buffer
}
interface CipherCCM extends Cipher {
setAAD(buffer: Buffer, options: { plaintextLength: number }): this;
getAuthTag(): Buffer;
}
interface CipherGCM extends Cipher {
setAAD(buffer: Buffer, options?: { plaintextLength: number }): this;
getAuthTag(): Buffer;
}
/** @deprecated since v10.0.0 use createCipheriv() */
function createDecipher(algorithm: CipherCCMTypes, password: BinaryLike, options: CipherCCMOptions): DecipherCCM;
/** @deprecated since v10.0.0 use createCipheriv() */
function createDecipher(algorithm: CipherGCMTypes, password: BinaryLike, options?: CipherGCMOptions): DecipherGCM;
/** @deprecated since v10.0.0 use createCipheriv() */
function createDecipher(algorithm: string, password: BinaryLike, options?: stream.TransformOptions): Decipher;
function createDecipheriv(
algorithm: CipherCCMTypes,
key: BinaryLike,
iv: BinaryLike | null,
options: CipherCCMOptions,
): DecipherCCM;
function createDecipheriv(
algorithm: CipherGCMTypes,
key: BinaryLike,
iv: BinaryLike | null,
options?: CipherGCMOptions,
): DecipherGCM;
function createDecipheriv(algorithm: string, key: BinaryLike, iv: BinaryLike | null, options?: stream.TransformOptions): Decipher;
class Decipher extends stream.Transform {
private constructor();
update(data: NodeJS.ArrayBufferView): Buffer;
update(data: string, input_encoding: HexBase64BinaryEncoding): Buffer;
update(data: NodeJS.ArrayBufferView, input_encoding: HexBase64BinaryEncoding | undefined, output_encoding: Utf8AsciiBinaryEncoding): string;
update(data: string, input_encoding: HexBase64BinaryEncoding | undefined, output_encoding: Utf8AsciiBinaryEncoding): string;
final(): Buffer;
final(output_encoding: string): string;
setAutoPadding(auto_padding?: boolean): this;
// setAuthTag(tag: NodeJS.ArrayBufferView): this;
// setAAD(buffer: NodeJS.ArrayBufferView): this;
}
interface DecipherCCM extends Decipher {
setAuthTag(buffer: NodeJS.ArrayBufferView): this;
setAAD(buffer: NodeJS.ArrayBufferView, options: { plaintextLength: number }): this;
}
interface DecipherGCM extends Decipher {
setAuthTag(buffer: NodeJS.ArrayBufferView): this;
setAAD(buffer: NodeJS.ArrayBufferView, options?: { plaintextLength: number }): this;
}
interface PrivateKeyInput {
key: string | Buffer;
format?: KeyFormat;
type?: 'pkcs1' | 'pkcs8' | 'sec1';
passphrase?: string | Buffer;
}
interface PublicKeyInput {
key: string | Buffer;
format?: KeyFormat;
type?: 'pkcs1' | 'spki';
}
function createPrivateKey(key: PrivateKeyInput | string | Buffer): KeyObject;
function createPublicKey(key: PublicKeyInput | string | Buffer | KeyObject): KeyObject;
function createSecretKey(key: Buffer): KeyObject;
function createSign(algorithm: string, options?: stream.WritableOptions): Signer;
interface SigningOptions {
/**
* @See crypto.constants.RSA_PKCS1_PADDING
*/
padding?: number;
saltLength?: number;
}
interface SignPrivateKeyInput extends PrivateKeyInput, SigningOptions {
}
type KeyLike = string | Buffer | KeyObject;
class Signer extends stream.Writable {
private constructor();
update(data: BinaryLike): Signer;
update(data: string, input_encoding: Utf8AsciiLatin1Encoding): Signer;
sign(private_key: SignPrivateKeyInput | KeyLike): Buffer;
sign(private_key: SignPrivateKeyInput | KeyLike, output_format: HexBase64Latin1Encoding): string;
}
function createVerify(algorithm: string, options?: stream.WritableOptions): Verify;
class Verify extends stream.Writable {
private constructor();
update(data: BinaryLike): Verify;
update(data: string, input_encoding: Utf8AsciiLatin1Encoding): Verify;
verify(object: Object | KeyLike, signature: NodeJS.ArrayBufferView): boolean;
verify(object: Object | KeyLike, signature: string, signature_format?: HexBase64Latin1Encoding): boolean;
// https://nodejs.org/api/crypto.html#crypto_verifier_verify_object_signature_signature_format
// The signature field accepts a TypedArray type, but it is only available starting ES2017
}
function createDiffieHellman(prime_length: number, generator?: number | NodeJS.ArrayBufferView): DiffieHellman;
function createDiffieHellman(prime: NodeJS.ArrayBufferView): DiffieHellman;
function createDiffieHellman(prime: string, prime_encoding: HexBase64Latin1Encoding): DiffieHellman;
function createDiffieHellman(prime: string, prime_encoding: HexBase64Latin1Encoding, generator: number | NodeJS.ArrayBufferView): DiffieHellman;
function createDiffieHellman(prime: string, prime_encoding: HexBase64Latin1Encoding, generator: string, generator_encoding: HexBase64Latin1Encoding): DiffieHellman;
class DiffieHellman {
private constructor();
generateKeys(): Buffer;
generateKeys(encoding: HexBase64Latin1Encoding): string;
computeSecret(other_public_key: NodeJS.ArrayBufferView): Buffer;
computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding): Buffer;
computeSecret(other_public_key: NodeJS.ArrayBufferView, output_encoding: HexBase64Latin1Encoding): string;
computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding, output_encoding: HexBase64Latin1Encoding): string;
getPrime(): Buffer;
getPrime(encoding: HexBase64Latin1Encoding): string;
getGenerator(): Buffer;
getGenerator(encoding: HexBase64Latin1Encoding): string;
getPublicKey(): Buffer;
getPublicKey(encoding: HexBase64Latin1Encoding): string;
getPrivateKey(): Buffer;
getPrivateKey(encoding: HexBase64Latin1Encoding): string;
setPublicKey(public_key: NodeJS.ArrayBufferView): void;
setPublicKey(public_key: string, encoding: string): void;
setPrivateKey(private_key: NodeJS.ArrayBufferView): void;
setPrivateKey(private_key: string, encoding: string): void;
verifyError: number;
}
function getDiffieHellman(group_name: string): DiffieHellman;
function pbkdf2(
password: BinaryLike,
salt: BinaryLike,
iterations: number,
keylen: number,
digest: string,
callback: (err: Error | null, derivedKey: Buffer) => any,
): void;
function pbkdf2Sync(password: BinaryLike, salt: BinaryLike, iterations: number, keylen: number, digest: string): Buffer;
function randomBytes(size: number): Buffer;
function randomBytes(size: number, callback: (err: Error | null, buf: Buffer) => void): void;
function pseudoRandomBytes(size: number): Buffer;
function pseudoRandomBytes(size: number, callback: (err: Error | null, buf: Buffer) => void): void;
function randomFillSync<T extends NodeJS.ArrayBufferView>(buffer: T, offset?: number, size?: number): T;
function randomFill<T extends NodeJS.ArrayBufferView>(buffer: T, callback: (err: Error | null, buf: T) => void): void;
function randomFill<T extends NodeJS.ArrayBufferView>(buffer: T, offset: number, callback: (err: Error | null, buf: T) => void): void;
function randomFill<T extends NodeJS.ArrayBufferView>(buffer: T, offset: number, size: number, callback: (err: Error | null, buf: T) => void): void;
interface ScryptOptions {
N?: number;
r?: number;
p?: number;
maxmem?: number;
}
function scrypt(
password: BinaryLike,
salt: BinaryLike,
keylen: number, callback: (err: Error | null, derivedKey: Buffer) => void,
): void;
function scrypt(
password: BinaryLike,
salt: BinaryLike,
keylen: number,
options: ScryptOptions,
callback: (err: Error | null, derivedKey: Buffer) => void,
): void;
function scryptSync(password: BinaryLike, salt: BinaryLike, keylen: number, options?: ScryptOptions): Buffer;
interface RsaPublicKey {
key: KeyLike;
padding?: number;
}
interface RsaPrivateKey {
key: KeyLike;
passphrase?: string;
/**
* @default 'sha1'
*/
oaepHash?: string;
oaepLabel?: NodeJS.TypedArray;
padding?: number;
}
function publicEncrypt(key: RsaPublicKey | RsaPrivateKey | KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
function publicDecrypt(key: RsaPublicKey | RsaPrivateKey | KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
function privateDecrypt(private_key: RsaPrivateKey | KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
function privateEncrypt(private_key: RsaPrivateKey | KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
function getCiphers(): string[];
function getCurves(): string[];
function getHashes(): string[];
class ECDH {
private constructor();
static convertKey(
key: BinaryLike,
curve: string,
inputEncoding?: HexBase64Latin1Encoding,
outputEncoding?: "latin1" | "hex" | "base64",
format?: "uncompressed" | "compressed" | "hybrid",
): Buffer | string;
generateKeys(): Buffer;
generateKeys(encoding: HexBase64Latin1Encoding, format?: ECDHKeyFormat): string;
computeSecret(other_public_key: NodeJS.ArrayBufferView): Buffer;
computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding): Buffer;
computeSecret(other_public_key: NodeJS.ArrayBufferView, output_encoding: HexBase64Latin1Encoding): string;
computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding, output_encoding: HexBase64Latin1Encoding): string;
getPrivateKey(): Buffer;
getPrivateKey(encoding: HexBase64Latin1Encoding): string;
getPublicKey(): Buffer;
getPublicKey(encoding: HexBase64Latin1Encoding, format?: ECDHKeyFormat): string;
setPrivateKey(private_key: NodeJS.ArrayBufferView): void;
setPrivateKey(private_key: string, encoding: HexBase64Latin1Encoding): void;
}
function createECDH(curve_name: string): ECDH;
function timingSafeEqual(a: NodeJS.ArrayBufferView, b: NodeJS.ArrayBufferView): boolean;
/** @deprecated since v10.0.0 */
const DEFAULT_ENCODING: string;
type KeyType = 'rsa' | 'dsa' | 'ec';
type KeyFormat = 'pem' | 'der';
interface BasePrivateKeyEncodingOptions<T extends KeyFormat> {
format: T;
cipher?: string;
passphrase?: string;
}
interface KeyPairKeyObjectResult {
publicKey: KeyObject;
privateKey: KeyObject;
}
interface ECKeyPairKeyObjectOptions {
/**
* Name of the curve to use.
*/
namedCurve: string;
}
interface RSAKeyPairKeyObjectOptions {
/**
* Key size in bits
*/
modulusLength: number;
/**
* @default 0x10001
*/
publicExponent?: number;
}
interface DSAKeyPairKeyObjectOptions {
/**
* Key size in bits
*/
modulusLength: number;
/**
* Size of q in bits
*/
divisorLength: number;
}
interface RSAKeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
/**
* Key size in bits
*/
modulusLength: number;
/**
* @default 0x10001
*/
publicExponent?: number;
publicKeyEncoding: {
type: 'pkcs1' | 'spki';
format: PubF;
};
privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
type: 'pkcs1' | 'pkcs8';
};
}
interface DSAKeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
/**
* Key size in bits
*/
modulusLength: number;
/**
* Size of q in bits
*/
divisorLength: number;
publicKeyEncoding: {
type: 'spki';
format: PubF;
};
privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
type: 'pkcs8';
};
}
interface ECKeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
/**
* Name of the curve to use.
*/
namedCurve: string;
publicKeyEncoding: {
type: 'pkcs1' | 'spki';
format: PubF;
};
privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
type: 'sec1' | 'pkcs8';
};
}
interface KeyPairSyncResult<T1 extends string | Buffer, T2 extends string | Buffer> {
publicKey: T1;
privateKey: T2;
}
function generateKeyPairSync(type: 'rsa', options: RSAKeyPairOptions<'pem', 'pem'>): KeyPairSyncResult<string, string>;
function generateKeyPairSync(type: 'rsa', options: RSAKeyPairOptions<'pem', 'der'>): KeyPairSyncResult<string, Buffer>;
function generateKeyPairSync(type: 'rsa', options: RSAKeyPairOptions<'der', 'pem'>): KeyPairSyncResult<Buffer, string>;
function generateKeyPairSync(type: 'rsa', options: RSAKeyPairOptions<'der', 'der'>): KeyPairSyncResult<Buffer, Buffer>;
function generateKeyPairSync(type: 'rsa', options: RSAKeyPairKeyObjectOptions): KeyPairKeyObjectResult;
function generateKeyPairSync(type: 'dsa', options: DSAKeyPairOptions<'pem', 'pem'>): KeyPairSyncResult<string, string>;
function generateKeyPairSync(type: 'dsa', options: DSAKeyPairOptions<'pem', 'der'>): KeyPairSyncResult<string, Buffer>;
function generateKeyPairSync(type: 'dsa', options: DSAKeyPairOptions<'der', 'pem'>): KeyPairSyncResult<Buffer, string>;
function generateKeyPairSync(type: 'dsa', options: DSAKeyPairOptions<'der', 'der'>): KeyPairSyncResult<Buffer, Buffer>;
function generateKeyPairSync(type: 'dsa', options: DSAKeyPairKeyObjectOptions): KeyPairKeyObjectResult;
function generateKeyPairSync(type: 'ec', options: ECKeyPairOptions<'pem', 'pem'>): KeyPairSyncResult<string, string>;
function generateKeyPairSync(type: 'ec', options: ECKeyPairOptions<'pem', 'der'>): KeyPairSyncResult<string, Buffer>;
function generateKeyPairSync(type: 'ec', options: ECKeyPairOptions<'der', 'pem'>): KeyPairSyncResult<Buffer, string>;
function generateKeyPairSync(type: 'ec', options: ECKeyPairOptions<'der', 'der'>): KeyPairSyncResult<Buffer, Buffer>;
function generateKeyPairSync(type: 'ec', options: ECKeyPairKeyObjectOptions): KeyPairKeyObjectResult;
function generateKeyPair(type: 'rsa', options: RSAKeyPairOptions<'pem', 'pem'>, callback: (err: Error | null, publicKey: string, privateKey: string) => void): void;
function generateKeyPair(type: 'rsa', options: RSAKeyPairOptions<'pem', 'der'>, callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void): void;
function generateKeyPair(type: 'rsa', options: RSAKeyPairOptions<'der', 'pem'>, callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void): void;
function generateKeyPair(type: 'rsa', options: RSAKeyPairOptions<'der', 'der'>, callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void): void;
function generateKeyPair(type: 'rsa', options: RSAKeyPairKeyObjectOptions, callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void): void;
function generateKeyPair(type: 'dsa', options: DSAKeyPairOptions<'pem', 'pem'>, callback: (err: Error | null, publicKey: string, privateKey: string) => void): void;
function generateKeyPair(type: 'dsa', options: DSAKeyPairOptions<'pem', 'der'>, callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void): void;
function generateKeyPair(type: 'dsa', options: DSAKeyPairOptions<'der', 'pem'>, callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void): void;
function generateKeyPair(type: 'dsa', options: DSAKeyPairOptions<'der', 'der'>, callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void): void;
function generateKeyPair(type: 'dsa', options: DSAKeyPairKeyObjectOptions, callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void): void;
function generateKeyPair(type: 'ec', options: ECKeyPairOptions<'pem', 'pem'>, callback: (err: Error | null, publicKey: string, privateKey: string) => void): void;
function generateKeyPair(type: 'ec', options: ECKeyPairOptions<'pem', 'der'>, callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void): void;
function generateKeyPair(type: 'ec', options: ECKeyPairOptions<'der', 'pem'>, callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void): void;
function generateKeyPair(type: 'ec', options: ECKeyPairOptions<'der', 'der'>, callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void): void;
function generateKeyPair(type: 'ec', options: ECKeyPairKeyObjectOptions, callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void): void;
namespace generateKeyPair {
function __promisify__(type: "rsa", options: RSAKeyPairOptions<'pem', 'pem'>): Promise<{ publicKey: string, privateKey: string }>;
function __promisify__(type: "rsa", options: RSAKeyPairOptions<'pem', 'der'>): Promise<{ publicKey: string, privateKey: Buffer }>;
function __promisify__(type: "rsa", options: RSAKeyPairOptions<'der', 'pem'>): Promise<{ publicKey: Buffer, privateKey: string }>;
function __promisify__(type: "rsa", options: RSAKeyPairOptions<'der', 'der'>): Promise<{ publicKey: Buffer, privateKey: Buffer }>;
function __promisify__(type: "rsa", options: RSAKeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
function __promisify__(type: "dsa", options: DSAKeyPairOptions<'pem', 'pem'>): Promise<{ publicKey: string, privateKey: string }>;
function __promisify__(type: "dsa", options: DSAKeyPairOptions<'pem', 'der'>): Promise<{ publicKey: string, privateKey: Buffer }>;
function __promisify__(type: "dsa", options: DSAKeyPairOptions<'der', 'pem'>): Promise<{ publicKey: Buffer, privateKey: string }>;
function __promisify__(type: "dsa", options: DSAKeyPairOptions<'der', 'der'>): Promise<{ publicKey: Buffer, privateKey: Buffer }>;
function __promisify__(type: "dsa", options: DSAKeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
function __promisify__(type: "ec", options: ECKeyPairOptions<'pem', 'pem'>): Promise<{ publicKey: string, privateKey: string }>;
function __promisify__(type: "ec", options: ECKeyPairOptions<'pem', 'der'>): Promise<{ publicKey: string, privateKey: Buffer }>;
function __promisify__(type: "ec", options: ECKeyPairOptions<'der', 'pem'>): Promise<{ publicKey: Buffer, privateKey: string }>;
function __promisify__(type: "ec", options: ECKeyPairOptions<'der', 'der'>): Promise<{ publicKey: Buffer, privateKey: Buffer }>;
function __promisify__(type: "ec", options: ECKeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
}
/**
* Calculates and returns the signature for `data` using the given private key and
* algorithm. If `algorithm` is `null` or `undefined`, then the algorithm is
* dependent upon the key type (especially Ed25519 and Ed448).
*
* If `key` is not a [`KeyObject`][], this function behaves as if `key` had been
* passed to [`crypto.createPrivateKey()`][].
*/
function sign(algorithm: string | null | undefined, data: NodeJS.ArrayBufferView, key: KeyLike | SignPrivateKeyInput): Buffer;
interface VerifyKeyWithOptions extends KeyObject, SigningOptions {
}
/**
* Calculates and returns the signature for `data` using the given private key and
* algorithm. If `algorithm` is `null` or `undefined`, then the algorithm is
* dependent upon the key type (especially Ed25519 and Ed448).
*
* If `key` is not a [`KeyObject`][], this function behaves as if `key` had been
* passed to [`crypto.createPublicKey()`][].
*/
function verify(algorithm: string | null | undefined, data: NodeJS.ArrayBufferView, key: KeyLike | VerifyKeyWithOptions, signature: NodeJS.ArrayBufferView): Buffer;
}

Some files were not shown because too many files have changed in this diff Show More