@northflank/js-client 0.4.1 → 0.5.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/api-client.d.ts +6013 -0
- package/dist/cjs/api-client.js +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/esm/api-client.d.ts +6013 -0
- package/dist/esm/api-client.js +15 -0
- package/dist/esm/package.json +3 -0
- package/package.json +12 -19
- package/dist/api-client.d.ts +0 -481
- package/dist/api-client.js +0 -748
- package/dist/api-endpoint.d.ts +0 -63
- package/dist/api-endpoint.js +0 -216
- package/dist/context/api-client-context-provider.d.ts +0 -47
- package/dist/context/api-client-context-provider.js +0 -332
- package/dist/context/api-client-file-context-provider.d.ts +0 -11
- package/dist/context/api-client-file-context-provider.js +0 -138
- package/dist/context/api-client-in-memory-context-provider.d.ts +0 -6
- package/dist/context/api-client-in-memory-context-provider.js +0 -82
- package/dist/context/index.d.ts +0 -3
- package/dist/context/index.js +0 -15
- package/dist/endpoints/abort/addon/backup.d.ts +0 -21
- package/dist/endpoints/abort/addon/backup.js +0 -36
- package/dist/endpoints/abort/addon/restore.d.ts +0 -26
- package/dist/endpoints/abort/addon/restore.js +0 -36
- package/dist/endpoints/abort/job/build.d.ts +0 -21
- package/dist/endpoints/abort/job/build.js +0 -36
- package/dist/endpoints/abort/job/run.d.ts +0 -21
- package/dist/endpoints/abort/job/run.js +0 -36
- package/dist/endpoints/abort/service/build.d.ts +0 -21
- package/dist/endpoints/abort/service/build.js +0 -36
- package/dist/endpoints/add/domain/subdomain.d.ts +0 -33
- package/dist/endpoints/add/domain/subdomain.js +0 -36
- package/dist/endpoints/add/registryCredentials.d.ts +0 -47
- package/dist/endpoints/add/registryCredentials.js +0 -36
- package/dist/endpoints/assign/subdomain/service.d.ts +0 -28
- package/dist/endpoints/assign/subdomain/service.js +0 -36
- package/dist/endpoints/backup/addon.d.ts +0 -51
- package/dist/endpoints/backup/addon.js +0 -36
- package/dist/endpoints/create/addon.d.ts +0 -90
- package/dist/endpoints/create/addon.js +0 -36
- package/dist/endpoints/create/domain.d.ts +0 -27
- package/dist/endpoints/create/domain.js +0 -36
- package/dist/endpoints/create/job/cron.d.ts +0 -157
- package/dist/endpoints/create/job/cron.js +0 -36
- package/dist/endpoints/create/job/manual.d.ts +0 -147
- package/dist/endpoints/create/job/manual.js +0 -36
- package/dist/endpoints/create/project.d.ts +0 -29
- package/dist/endpoints/create/project.js +0 -36
- package/dist/endpoints/create/secret.d.ts +0 -79
- package/dist/endpoints/create/secret.js +0 -36
- package/dist/endpoints/create/service/build.d.ts +0 -116
- package/dist/endpoints/create/service/build.js +0 -36
- package/dist/endpoints/create/service/combined.d.ts +0 -166
- package/dist/endpoints/create/service/combined.js +0 -36
- package/dist/endpoints/create/service/deployment.d.ts +0 -137
- package/dist/endpoints/create/service/deployment.js +0 -36
- package/dist/endpoints/delete/addon.d.ts +0 -19
- package/dist/endpoints/delete/addon.js +0 -36
- package/dist/endpoints/delete/backup.d.ts +0 -21
- package/dist/endpoints/delete/backup.js +0 -36
- package/dist/endpoints/delete/domain.d.ts +0 -17
- package/dist/endpoints/delete/domain.js +0 -36
- package/dist/endpoints/delete/job.d.ts +0 -19
- package/dist/endpoints/delete/job.js +0 -36
- package/dist/endpoints/delete/project.d.ts +0 -17
- package/dist/endpoints/delete/project.js +0 -36
- package/dist/endpoints/delete/registryCredentials.d.ts +0 -17
- package/dist/endpoints/delete/registryCredentials.js +0 -36
- package/dist/endpoints/delete/secret.d.ts +0 -19
- package/dist/endpoints/delete/secret.js +0 -36
- package/dist/endpoints/delete/secretLink.d.ts +0 -21
- package/dist/endpoints/delete/secretLink.js +0 -36
- package/dist/endpoints/delete/service.d.ts +0 -19
- package/dist/endpoints/delete/service.js +0 -36
- package/dist/endpoints/delete/subdomain.d.ts +0 -19
- package/dist/endpoints/delete/subdomain.js +0 -36
- package/dist/endpoints/get/addon/backup/download.d.ts +0 -24
- package/dist/endpoints/get/addon/backup/download.js +0 -36
- package/dist/endpoints/get/addon/backup.d.ts +0 -46
- package/dist/endpoints/get/addon/backup.js +0 -36
- package/dist/endpoints/get/addon/backups.d.ts +0 -54
- package/dist/endpoints/get/addon/backups.js +0 -40
- package/dist/endpoints/get/addon/containers.d.ts +0 -40
- package/dist/endpoints/get/addon/containers.js +0 -40
- package/dist/endpoints/get/addon/credentials.d.ts +0 -24
- package/dist/endpoints/get/addon/credentials.js +0 -36
- package/dist/endpoints/get/addon/types.d.ts +0 -48
- package/dist/endpoints/get/addon/types.js +0 -36
- package/dist/endpoints/get/addon/version.d.ts +0 -53
- package/dist/endpoints/get/addon/version.js +0 -36
- package/dist/endpoints/get/addon.d.ts +0 -69
- package/dist/endpoints/get/addon.js +0 -36
- package/dist/endpoints/get/dnsId.d.ts +0 -15
- package/dist/endpoints/get/dnsId.js +0 -36
- package/dist/endpoints/get/domain.d.ts +0 -33
- package/dist/endpoints/get/domain.js +0 -36
- package/dist/endpoints/get/job/buildArguments.d.ts +0 -19
- package/dist/endpoints/get/job/buildArguments.js +0 -36
- package/dist/endpoints/get/job/builds.d.ts +0 -50
- package/dist/endpoints/get/job/builds.js +0 -39
- package/dist/endpoints/get/job/containers.d.ts +0 -40
- package/dist/endpoints/get/job/containers.js +0 -40
- package/dist/endpoints/get/job/deployment.d.ts +0 -51
- package/dist/endpoints/get/job/deployment.js +0 -36
- package/dist/endpoints/get/job/environment.d.ts +0 -24
- package/dist/endpoints/get/job/environment.js +0 -40
- package/dist/endpoints/get/job/environmentDetails.d.ts +0 -42
- package/dist/endpoints/get/job/environmentDetails.js +0 -36
- package/dist/endpoints/get/job/healthChecks.d.ts +0 -44
- package/dist/endpoints/get/job/healthChecks.js +0 -36
- package/dist/endpoints/get/job/run.d.ts +0 -42
- package/dist/endpoints/get/job/run.js +0 -36
- package/dist/endpoints/get/job/runs.d.ts +0 -52
- package/dist/endpoints/get/job/runs.js +0 -39
- package/dist/endpoints/get/job.d.ts +0 -86
- package/dist/endpoints/get/job.js +0 -36
- package/dist/endpoints/get/project.d.ts +0 -72
- package/dist/endpoints/get/project.js +0 -36
- package/dist/endpoints/get/registryCredentials.d.ts +0 -34
- package/dist/endpoints/get/registryCredentials.js +0 -36
- package/dist/endpoints/get/secret.d.ts +0 -55
- package/dist/endpoints/get/secret.js +0 -39
- package/dist/endpoints/get/secretDetails.d.ts +0 -63
- package/dist/endpoints/get/secretDetails.js +0 -36
- package/dist/endpoints/get/secretLink.d.ts +0 -44
- package/dist/endpoints/get/secretLink.js +0 -36
- package/dist/endpoints/get/service/buildArguments.d.ts +0 -19
- package/dist/endpoints/get/service/buildArguments.js +0 -36
- package/dist/endpoints/get/service/builds.d.ts +0 -50
- package/dist/endpoints/get/service/builds.js +0 -40
- package/dist/endpoints/get/service/containers.d.ts +0 -40
- package/dist/endpoints/get/service/containers.js +0 -40
- package/dist/endpoints/get/service/deployment.d.ts +0 -51
- package/dist/endpoints/get/service/deployment.js +0 -36
- package/dist/endpoints/get/service/environmentVariableDetails.d.ts +0 -42
- package/dist/endpoints/get/service/environmentVariableDetails.js +0 -36
- package/dist/endpoints/get/service/environmentVariables.d.ts +0 -24
- package/dist/endpoints/get/service/environmentVariables.js +0 -40
- package/dist/endpoints/get/service/healthChecks.d.ts +0 -44
- package/dist/endpoints/get/service/healthChecks.js +0 -36
- package/dist/endpoints/get/service/ports.d.ts +0 -35
- package/dist/endpoints/get/service/ports.js +0 -36
- package/dist/endpoints/get/service.d.ts +0 -103
- package/dist/endpoints/get/service.js +0 -36
- package/dist/endpoints/get/subdomain.d.ts +0 -30
- package/dist/endpoints/get/subdomain.js +0 -36
- package/dist/endpoints/import/addon/backup.d.ts +0 -31
- package/dist/endpoints/import/addon/backup.js +0 -36
- package/dist/endpoints/list/addons.d.ts +0 -45
- package/dist/endpoints/list/addons.js +0 -39
- package/dist/endpoints/list/domains.d.ts +0 -34
- package/dist/endpoints/list/domains.js +0 -39
- package/dist/endpoints/list/jobs.d.ts +0 -44
- package/dist/endpoints/list/jobs.js +0 -39
- package/dist/endpoints/list/plans.d.ts +0 -30
- package/dist/endpoints/list/plans.js +0 -36
- package/dist/endpoints/list/projects.d.ts +0 -32
- package/dist/endpoints/list/projects.js +0 -39
- package/dist/endpoints/list/regions.d.ts +0 -18
- package/dist/endpoints/list/regions.js +0 -36
- package/dist/endpoints/list/registryCredentials.d.ts +0 -41
- package/dist/endpoints/list/registryCredentials.js +0 -39
- package/dist/endpoints/list/secrets.d.ts +0 -52
- package/dist/endpoints/list/secrets.js +0 -39
- package/dist/endpoints/list/services.d.ts +0 -44
- package/dist/endpoints/list/services.js +0 -39
- package/dist/endpoints/list/vcs.d.ts +0 -51
- package/dist/endpoints/list/vcs.js +0 -36
- package/dist/endpoints/pause/addon.d.ts +0 -19
- package/dist/endpoints/pause/addon.js +0 -36
- package/dist/endpoints/pause/service.d.ts +0 -19
- package/dist/endpoints/pause/service.js +0 -36
- package/dist/endpoints/restart/addon.d.ts +0 -19
- package/dist/endpoints/restart/addon.js +0 -36
- package/dist/endpoints/restart/service.d.ts +0 -19
- package/dist/endpoints/restart/service.js +0 -36
- package/dist/endpoints/restore/addon/backup.d.ts +0 -21
- package/dist/endpoints/restore/addon/backup.js +0 -36
- package/dist/endpoints/resume/addon.d.ts +0 -19
- package/dist/endpoints/resume/addon.js +0 -36
- package/dist/endpoints/resume/service.d.ts +0 -24
- package/dist/endpoints/resume/service.js +0 -36
- package/dist/endpoints/scale/addon.d.ts +0 -28
- package/dist/endpoints/scale/addon.js +0 -36
- package/dist/endpoints/scale/service.d.ts +0 -26
- package/dist/endpoints/scale/service.js +0 -36
- package/dist/endpoints/start/job/build.d.ts +0 -37
- package/dist/endpoints/start/job/build.js +0 -36
- package/dist/endpoints/start/job/run.d.ts +0 -37
- package/dist/endpoints/start/job/run.js +0 -36
- package/dist/endpoints/start/service/build.d.ts +0 -41
- package/dist/endpoints/start/service/build.js +0 -36
- package/dist/endpoints/unassign/subdomain.d.ts +0 -19
- package/dist/endpoints/unassign/subdomain.js +0 -36
- package/dist/endpoints/update/addon/networkSettings.d.ts +0 -26
- package/dist/endpoints/update/addon/networkSettings.js +0 -36
- package/dist/endpoints/update/addon/security.d.ts +0 -29
- package/dist/endpoints/update/addon/security.js +0 -36
- package/dist/endpoints/update/addon/version.d.ts +0 -24
- package/dist/endpoints/update/addon/version.js +0 -36
- package/dist/endpoints/update/job/buildArguments.d.ts +0 -24
- package/dist/endpoints/update/job/buildArguments.js +0 -36
- package/dist/endpoints/update/job/cmdOverride.d.ts +0 -24
- package/dist/endpoints/update/job/cmdOverride.js +0 -36
- package/dist/endpoints/update/job/deployment.d.ts +0 -37
- package/dist/endpoints/update/job/deployment.js +0 -36
- package/dist/endpoints/update/job/environment.d.ts +0 -24
- package/dist/endpoints/update/job/environment.js +0 -36
- package/dist/endpoints/update/job/healthChecks.d.ts +0 -45
- package/dist/endpoints/update/job/healthChecks.js +0 -36
- package/dist/endpoints/update/job/settings.d.ts +0 -30
- package/dist/endpoints/update/job/settings.js +0 -36
- package/dist/endpoints/update/registryCredentials.d.ts +0 -31
- package/dist/endpoints/update/registryCredentials.js +0 -36
- package/dist/endpoints/update/secret.d.ts +0 -54
- package/dist/endpoints/update/secret.js +0 -36
- package/dist/endpoints/update/secretLink.d.ts +0 -40
- package/dist/endpoints/update/secretLink.js +0 -36
- package/dist/endpoints/update/service/buildArguments.d.ts +0 -24
- package/dist/endpoints/update/service/buildArguments.js +0 -36
- package/dist/endpoints/update/service/buildOptions.d.ts +0 -52
- package/dist/endpoints/update/service/buildOptions.js +0 -36
- package/dist/endpoints/update/service/cmdOverride.d.ts +0 -24
- package/dist/endpoints/update/service/cmdOverride.js +0 -36
- package/dist/endpoints/update/service/deployment.d.ts +0 -37
- package/dist/endpoints/update/service/deployment.js +0 -36
- package/dist/endpoints/update/service/environmentVariables.d.ts +0 -29
- package/dist/endpoints/update/service/environmentVariables.js +0 -36
- package/dist/endpoints/update/service/healthChecks.d.ts +0 -45
- package/dist/endpoints/update/service/healthChecks.js +0 -36
- package/dist/endpoints/update/service/ports.d.ts +0 -55
- package/dist/endpoints/update/service/ports.js +0 -36
- package/dist/endpoints/verify/domain.d.ts +0 -17
- package/dist/endpoints/verify/domain.js +0 -36
- package/dist/endpoints/verify/subdomain.d.ts +0 -19
- package/dist/endpoints/verify/subdomain.js +0 -36
- package/dist/port-forward/client/api-helper.d.ts +0 -30
- package/dist/port-forward/client/api-helper.js +0 -102
- package/dist/port-forward/client/atomic-write.d.ts +0 -3
- package/dist/port-forward/client/atomic-write.js +0 -95
- package/dist/port-forward/client/host-file-ast.d.ts +0 -52
- package/dist/port-forward/client/host-file-ast.js +0 -279
- package/dist/port-forward/client/host-file.d.ts +0 -26
- package/dist/port-forward/client/host-file.js +0 -226
- package/dist/port-forward/client/loopback.d.ts +0 -4
- package/dist/port-forward/client/loopback.js +0 -219
- package/dist/port-forward/client/port-forwarder.d.ts +0 -86
- package/dist/port-forward/client/port-forwarder.js +0 -593
- package/dist/port-forward/client/port-tunnel-tcp.d.ts +0 -34
- package/dist/port-forward/client/port-tunnel-tcp.js +0 -209
- package/dist/port-forward/client/port-tunnel-udp.d.ts +0 -25
- package/dist/port-forward/client/port-tunnel-udp.js +0 -147
- package/dist/port-forward/client/port-tunnel.d.ts +0 -32
- package/dist/port-forward/client/port-tunnel.js +0 -2
- package/dist/port-forward/client/promise-mutex.d.ts +0 -4
- package/dist/port-forward/client/promise-mutex.js +0 -62
- package/dist/utils.d.ts +0 -8
- package/dist/utils.js +0 -97
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
-
if (k2 === undefined) k2 = k;
|
|
19
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
20
|
-
}) : (function(o, m, k, k2) {
|
|
21
|
-
if (k2 === undefined) k2 = k;
|
|
22
|
-
o[k2] = m[k];
|
|
23
|
-
}));
|
|
24
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
-
}) : function(o, v) {
|
|
27
|
-
o["default"] = v;
|
|
28
|
-
});
|
|
29
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
-
if (mod && mod.__esModule) return mod;
|
|
31
|
-
var result = {};
|
|
32
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
-
__setModuleDefault(result, mod);
|
|
34
|
-
return result;
|
|
35
|
-
};
|
|
36
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
37
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
39
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
40
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
41
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
42
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
46
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
47
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
48
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
49
|
-
function step(op) {
|
|
50
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
51
|
-
while (_) try {
|
|
52
|
-
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;
|
|
53
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
54
|
-
switch (op[0]) {
|
|
55
|
-
case 0: case 1: t = op; break;
|
|
56
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
57
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
58
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
59
|
-
default:
|
|
60
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
61
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
62
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
63
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
64
|
-
if (t[2]) _.ops.pop();
|
|
65
|
-
_.trys.pop(); continue;
|
|
66
|
-
}
|
|
67
|
-
op = body.call(thisArg, _);
|
|
68
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
69
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
73
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
74
|
-
};
|
|
75
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
76
|
-
exports.PortTunnelTcp = void 0;
|
|
77
|
-
// import WebSocket from 'ws';
|
|
78
|
-
var pump_1 = __importDefault(require("pump"));
|
|
79
|
-
var net = __importStar(require("net"));
|
|
80
|
-
var events_1 = require("events");
|
|
81
|
-
var lodash_1 = require("lodash");
|
|
82
|
-
var Transform = require('stream').Transform;
|
|
83
|
-
var WebSocket = require('ws');
|
|
84
|
-
var PortTunnelTcp = /** @class */ (function (_super) {
|
|
85
|
-
__extends(PortTunnelTcp, _super);
|
|
86
|
-
function PortTunnelTcp(endpoint, headers, rewriteHostHeader, bindTo, closeTimeout) {
|
|
87
|
-
if (closeTimeout === void 0) { closeTimeout = 5000; }
|
|
88
|
-
var _this = _super.call(this) || this;
|
|
89
|
-
_this.endpoint = endpoint;
|
|
90
|
-
_this.headers = headers;
|
|
91
|
-
_this.rewriteHostHeader = rewriteHostHeader;
|
|
92
|
-
_this.closeTimeout = closeTimeout;
|
|
93
|
-
_this.protocol = 'TCP';
|
|
94
|
-
_this.openConnections = new Set();
|
|
95
|
-
_this.bindTo = bindTo;
|
|
96
|
-
_this.tcpServer = net.createServer(_this.handleConnection.bind(_this));
|
|
97
|
-
var hostnamesForRegex = rewriteHostHeader === null || rewriteHostHeader === void 0 ? void 0 : rewriteHostHeader.altHostnames.map(function (h) { return lodash_1.escapeRegExp(h); }).join('|');
|
|
98
|
-
_this.hostRegex = new RegExp("Host: (?:" + hostnamesForRegex + ")(:.*$|$)", 'im');
|
|
99
|
-
return _this;
|
|
100
|
-
}
|
|
101
|
-
PortTunnelTcp.prototype.open = function () {
|
|
102
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
103
|
-
var _this = this;
|
|
104
|
-
return __generator(this, function (_a) {
|
|
105
|
-
return [2 /*return*/, new Promise(function (r) {
|
|
106
|
-
if (_this.bindTo) {
|
|
107
|
-
var _a = _this.bindTo, port_1 = _a.port, address_1 = _a.address;
|
|
108
|
-
_this.tcpServer.listen(port_1, address_1, function () {
|
|
109
|
-
_this.emit('tunnel-open', { address: address_1, port: port_1 });
|
|
110
|
-
r({ address: address_1, port: port_1 });
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
_this.tcpServer.listen(0, function () {
|
|
115
|
-
var _a = _this.tcpServer.address(), address = _a.address, port = _a.port;
|
|
116
|
-
_this.emit('tunnel-open', { address: address, port: port });
|
|
117
|
-
r({ address: address, port: port });
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
})];
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
};
|
|
124
|
-
PortTunnelTcp.prototype.close = function () {
|
|
125
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
126
|
-
var closed;
|
|
127
|
-
var _this = this;
|
|
128
|
-
return __generator(this, function (_a) {
|
|
129
|
-
switch (_a.label) {
|
|
130
|
-
case 0:
|
|
131
|
-
closed = false;
|
|
132
|
-
return [4 /*yield*/, Promise.race([
|
|
133
|
-
new Promise(function (r) {
|
|
134
|
-
_this.tcpServer.close(function () {
|
|
135
|
-
closed = true;
|
|
136
|
-
_this.emit('tunnel-close');
|
|
137
|
-
r();
|
|
138
|
-
});
|
|
139
|
-
}),
|
|
140
|
-
new Promise(function (r) {
|
|
141
|
-
// force close connection after timeout
|
|
142
|
-
new Promise(function (res) { return setTimeout(res, _this.closeTimeout); }).then(function () {
|
|
143
|
-
if (!closed) {
|
|
144
|
-
_this.openConnections.forEach(function (con) {
|
|
145
|
-
con.destroy();
|
|
146
|
-
_this.openConnections.delete(con);
|
|
147
|
-
});
|
|
148
|
-
r();
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
}),
|
|
152
|
-
])];
|
|
153
|
-
case 1:
|
|
154
|
-
_a.sent();
|
|
155
|
-
return [2 /*return*/];
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
};
|
|
160
|
-
PortTunnelTcp.prototype.handleConnection = function (local) {
|
|
161
|
-
var _this = this;
|
|
162
|
-
this.openConnections.add(local);
|
|
163
|
-
var remote = new WebSocket(this.endpoint.replace('https:', 'wss:'), {
|
|
164
|
-
headers: this.headers,
|
|
165
|
-
});
|
|
166
|
-
var duplex = WebSocket.createWebSocketStream(remote);
|
|
167
|
-
if (this.rewriteHostHeader) {
|
|
168
|
-
pump_1.default(local, this.getHeaderTransform(), duplex);
|
|
169
|
-
}
|
|
170
|
-
else {
|
|
171
|
-
pump_1.default(local, duplex);
|
|
172
|
-
}
|
|
173
|
-
pump_1.default(duplex, local);
|
|
174
|
-
remote.on('close', function (ws, code, reason) {
|
|
175
|
-
_this.emit('connection-close', ws, code, reason);
|
|
176
|
-
});
|
|
177
|
-
duplex.on('error', function (error) {
|
|
178
|
-
_this.emit('connection-error', error);
|
|
179
|
-
});
|
|
180
|
-
local.on('error', function (error) {
|
|
181
|
-
_this.emit('connection-error', error);
|
|
182
|
-
});
|
|
183
|
-
this.emit('connection-accept');
|
|
184
|
-
};
|
|
185
|
-
/** rewrite host header which can lead to issues when request coming from a different hostname */
|
|
186
|
-
PortTunnelTcp.prototype.getHeaderTransform = function () {
|
|
187
|
-
if (this.rewriteHostHeader) {
|
|
188
|
-
var targetHostname_1 = this.rewriteHostHeader.targetHostname;
|
|
189
|
-
var regexp_1 = this.hostRegex;
|
|
190
|
-
return new Transform({
|
|
191
|
-
transform: function (chunk, _encoding, callback) {
|
|
192
|
-
var stringChunk = chunk.toString();
|
|
193
|
-
var firstLine = stringChunk.split('\n', 1)[0];
|
|
194
|
-
// Check if HTTP request
|
|
195
|
-
if (firstLine.includes('HTTP')) {
|
|
196
|
-
var replaceHeader = stringChunk.replace(regexp_1, "Host: " + targetHostname_1); // rewrite host header to full hostname
|
|
197
|
-
callback(null, Buffer.from(replaceHeader));
|
|
198
|
-
}
|
|
199
|
-
else {
|
|
200
|
-
callback(null, chunk);
|
|
201
|
-
}
|
|
202
|
-
},
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
return undefined;
|
|
206
|
-
};
|
|
207
|
-
return PortTunnelTcp;
|
|
208
|
-
}(events_1.EventEmitter));
|
|
209
|
-
exports.PortTunnelTcp = PortTunnelTcp;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { EventEmitter } from 'events';
|
|
3
|
-
import { PortTunnel } from './port-tunnel';
|
|
4
|
-
export declare class PortTunnelUdp extends EventEmitter implements PortTunnel {
|
|
5
|
-
private readonly endpoint;
|
|
6
|
-
private readonly headers;
|
|
7
|
-
private readonly udpSocket;
|
|
8
|
-
readonly protocol = "UDP";
|
|
9
|
-
readonly bindTo?: {
|
|
10
|
-
address: string;
|
|
11
|
-
port: number;
|
|
12
|
-
};
|
|
13
|
-
constructor(endpoint: string, headers: {
|
|
14
|
-
[_: string]: string;
|
|
15
|
-
}, bindTo?: {
|
|
16
|
-
address: string;
|
|
17
|
-
port: number;
|
|
18
|
-
});
|
|
19
|
-
open(): Promise<{
|
|
20
|
-
address: string;
|
|
21
|
-
port: number;
|
|
22
|
-
}>;
|
|
23
|
-
close(): Promise<void>;
|
|
24
|
-
private handleConnection;
|
|
25
|
-
}
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
-
function step(op) {
|
|
31
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
-
while (_) try {
|
|
33
|
-
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;
|
|
34
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
-
switch (op[0]) {
|
|
36
|
-
case 0: case 1: t = op; break;
|
|
37
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
-
default:
|
|
41
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
-
if (t[2]) _.ops.pop();
|
|
46
|
-
_.trys.pop(); continue;
|
|
47
|
-
}
|
|
48
|
-
op = body.call(thisArg, _);
|
|
49
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
-
exports.PortTunnelUdp = void 0;
|
|
55
|
-
var events_1 = require("events");
|
|
56
|
-
var dgram = require('dgram');
|
|
57
|
-
var WebSocket = require('ws');
|
|
58
|
-
var PortTunnelUdp = /** @class */ (function (_super) {
|
|
59
|
-
__extends(PortTunnelUdp, _super);
|
|
60
|
-
function PortTunnelUdp(endpoint, headers, bindTo) {
|
|
61
|
-
var _this = _super.call(this) || this;
|
|
62
|
-
_this.endpoint = endpoint;
|
|
63
|
-
_this.headers = headers;
|
|
64
|
-
_this.protocol = 'UDP';
|
|
65
|
-
_this.bindTo = bindTo;
|
|
66
|
-
_this.udpSocket = dgram.createSocket('udp4');
|
|
67
|
-
_this.handleConnection();
|
|
68
|
-
return _this;
|
|
69
|
-
}
|
|
70
|
-
PortTunnelUdp.prototype.open = function () {
|
|
71
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
72
|
-
var _this = this;
|
|
73
|
-
return __generator(this, function (_a) {
|
|
74
|
-
return [2 /*return*/, new Promise(function (r) {
|
|
75
|
-
if (_this.bindTo) {
|
|
76
|
-
var _a = _this.bindTo, port_1 = _a.port, address_1 = _a.address;
|
|
77
|
-
_this.udpSocket.bind(port_1, address_1, function () {
|
|
78
|
-
_this.emit('tunnel-open', { address: address_1, port: port_1 });
|
|
79
|
-
r({ address: address_1, port: port_1 });
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
_this.udpSocket.bind(0, function () {
|
|
84
|
-
var _a = _this.udpSocket.address(), address = _a.address, port = _a.port;
|
|
85
|
-
_this.emit('tunnel-open', { address: address, port: port });
|
|
86
|
-
r({ address: address, port: port });
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
})];
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
};
|
|
93
|
-
PortTunnelUdp.prototype.close = function () {
|
|
94
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
95
|
-
var _this = this;
|
|
96
|
-
return __generator(this, function (_a) {
|
|
97
|
-
switch (_a.label) {
|
|
98
|
-
case 0: return [4 /*yield*/, new Promise(function (r) {
|
|
99
|
-
_this.udpSocket.close(function () {
|
|
100
|
-
_this.emit('tunnel-close');
|
|
101
|
-
r();
|
|
102
|
-
});
|
|
103
|
-
})];
|
|
104
|
-
case 1:
|
|
105
|
-
_a.sent();
|
|
106
|
-
return [2 /*return*/];
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
};
|
|
111
|
-
PortTunnelUdp.prototype.handleConnection = function () {
|
|
112
|
-
var _this = this;
|
|
113
|
-
var remote = new WebSocket(this.endpoint.replace('https:', 'wss:'), {
|
|
114
|
-
headers: this.headers,
|
|
115
|
-
});
|
|
116
|
-
var duplex = WebSocket.createWebSocketStream(remote);
|
|
117
|
-
var clientInfo;
|
|
118
|
-
this.udpSocket.on('message', function (msg, rinfo) {
|
|
119
|
-
clientInfo = rinfo;
|
|
120
|
-
duplex.write(msg);
|
|
121
|
-
});
|
|
122
|
-
duplex.on('data', function (chunk) {
|
|
123
|
-
if (clientInfo) {
|
|
124
|
-
_this.udpSocket.send(chunk, clientInfo.port, clientInfo.address, function (error) {
|
|
125
|
-
if (error) {
|
|
126
|
-
_this.emit('connection-error', error);
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
this.udpSocket.on('error', function (error) {
|
|
132
|
-
_this.emit('connection-error', error);
|
|
133
|
-
});
|
|
134
|
-
duplex.on('error', function (error) {
|
|
135
|
-
_this.emit('connection-error', error);
|
|
136
|
-
});
|
|
137
|
-
remote.on('connection-close', function (ws, code, reason) {
|
|
138
|
-
_this.emit('connection-close', ws, code, reason);
|
|
139
|
-
});
|
|
140
|
-
remote.on('connection-error', function (error) {
|
|
141
|
-
_this.emit('connection-error', error);
|
|
142
|
-
});
|
|
143
|
-
this.emit('connection-accept');
|
|
144
|
-
};
|
|
145
|
-
return PortTunnelUdp;
|
|
146
|
-
}(events_1.EventEmitter));
|
|
147
|
-
exports.PortTunnelUdp = PortTunnelUdp;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { EventEmitter } from 'events';
|
|
3
|
-
export declare type PortForwardingInfo = {
|
|
4
|
-
type: 'addon' | 'service';
|
|
5
|
-
projectId: string;
|
|
6
|
-
id: string;
|
|
7
|
-
address: string;
|
|
8
|
-
port: number;
|
|
9
|
-
portName?: string;
|
|
10
|
-
protocol?: 'HTTP' | 'TCP' | 'UDP';
|
|
11
|
-
hostnames: string[];
|
|
12
|
-
};
|
|
13
|
-
export interface PortTunnel extends EventEmitter {
|
|
14
|
-
readonly bindTo?: {
|
|
15
|
-
address: string;
|
|
16
|
-
port: number;
|
|
17
|
-
};
|
|
18
|
-
readonly protocol: 'TCP' | 'UDP';
|
|
19
|
-
on(event: 'tunnel-open', listener: ({ address: string, port: number }: {
|
|
20
|
-
address: any;
|
|
21
|
-
port: any;
|
|
22
|
-
}) => any): any;
|
|
23
|
-
on(event: 'tunnel-close', listener: () => any): any;
|
|
24
|
-
on(event: 'connection-accept', listener: () => any): any;
|
|
25
|
-
on(event: 'connection-close', listener: () => any): any;
|
|
26
|
-
on(event: 'connection-error', listener: (error: any) => any): any;
|
|
27
|
-
open(): Promise<{
|
|
28
|
-
address: string;
|
|
29
|
-
port: number;
|
|
30
|
-
}>;
|
|
31
|
-
close(): Promise<void>;
|
|
32
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
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;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.AsyncMutex = void 0;
|
|
40
|
-
var AsyncMutex = /** @class */ (function () {
|
|
41
|
-
function AsyncMutex() {
|
|
42
|
-
this.previousPromise = Promise.resolve();
|
|
43
|
-
}
|
|
44
|
-
AsyncMutex.prototype.enter = function (f) {
|
|
45
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
46
|
-
var newPromise;
|
|
47
|
-
return __generator(this, function (_a) {
|
|
48
|
-
newPromise = this.previousPromise
|
|
49
|
-
.then(function () {
|
|
50
|
-
return f();
|
|
51
|
-
})
|
|
52
|
-
.catch(function () {
|
|
53
|
-
return f();
|
|
54
|
-
});
|
|
55
|
-
this.previousPromise = newPromise;
|
|
56
|
-
return [2 /*return*/, newPromise];
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
};
|
|
60
|
-
return AsyncMutex;
|
|
61
|
-
}());
|
|
62
|
-
exports.AsyncMutex = AsyncMutex;
|
package/dist/utils.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export declare function isRunningAsAdmin(): {
|
|
2
|
-
error: boolean;
|
|
3
|
-
message?: string;
|
|
4
|
-
type?: 'windows-admin' | 'unix-admin';
|
|
5
|
-
};
|
|
6
|
-
export declare const isNode: boolean;
|
|
7
|
-
export declare const sleep: (t: number) => Promise<void>;
|
|
8
|
-
export declare const asyncSequential: <T, R>(elements: T[], op: (_: T) => Promise<R>) => Promise<R[]>;
|
package/dist/utils.js
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
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;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.asyncSequential = exports.sleep = exports.isNode = exports.isRunningAsAdmin = void 0;
|
|
40
|
-
var child_process_1 = require("child_process");
|
|
41
|
-
function isRunningAsAdmin() {
|
|
42
|
-
// https://stackoverflow.com/questions/4051883
|
|
43
|
-
var isUnixAdmin = function () { return !(process.getuid && process.getuid() !== 0); };
|
|
44
|
-
var isWindowsAdmin = function () {
|
|
45
|
-
try {
|
|
46
|
-
child_process_1.execSync('fsutil dirty query %systemdrive%');
|
|
47
|
-
return true;
|
|
48
|
-
}
|
|
49
|
-
catch (err) {
|
|
50
|
-
if (err.code === 'ENOENT') {
|
|
51
|
-
try {
|
|
52
|
-
child_process_1.execSync('fltmc');
|
|
53
|
-
return true;
|
|
54
|
-
}
|
|
55
|
-
catch (_) {
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return false;
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
if (process.platform !== 'win32') {
|
|
63
|
-
if (isUnixAdmin()) {
|
|
64
|
-
return { error: false, type: 'unix-admin' };
|
|
65
|
-
}
|
|
66
|
-
return {
|
|
67
|
-
error: true,
|
|
68
|
-
message: "You are not running this command with sufficient privileges (uid=" + process.getuid() + "). Try running with 'sudo'.",
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
if (isWindowsAdmin()) {
|
|
72
|
-
return { error: false, type: 'windows-admin' };
|
|
73
|
-
}
|
|
74
|
-
return {
|
|
75
|
-
error: true,
|
|
76
|
-
message: "You are not running this command as administrator. Please start command line with admin rights.",
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
exports.isRunningAsAdmin = isRunningAsAdmin;
|
|
80
|
-
exports.isNode = typeof process !== 'undefined' && process.versions != null && process.versions.node != null;
|
|
81
|
-
var sleep = function (t) { return new Promise(function (r) { return setTimeout(function () { return r(); }, t); }); };
|
|
82
|
-
exports.sleep = sleep;
|
|
83
|
-
var asyncSequential = function (elements, op) { return __awaiter(void 0, void 0, void 0, function () {
|
|
84
|
-
var empty;
|
|
85
|
-
return __generator(this, function (_a) {
|
|
86
|
-
empty = Promise.resolve([]);
|
|
87
|
-
return [2 /*return*/, elements.reduce(function (prevPromise, element) {
|
|
88
|
-
return prevPromise.then(function (result) {
|
|
89
|
-
return op(element).then(function (r) {
|
|
90
|
-
result.push(r);
|
|
91
|
-
return result;
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
}, empty)];
|
|
95
|
-
});
|
|
96
|
-
}); };
|
|
97
|
-
exports.asyncSequential = asyncSequential;
|