Socket
Socket
Sign inDemoInstall

builder-util-runtime

Package Overview
Dependencies
Maintainers
1
Versions
103
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

builder-util-runtime - npm Package Compare versions

Comparing version 4.0.5 to 4.1.0

106

out/bintray.js
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
value: true
});
exports.BintrayClient = undefined;
exports.BintrayClient = void 0;
var _httpExecutor;
function _httpExecutor() {
const data = require("./httpExecutor");
function _load_httpExecutor() {
return _httpExecutor = require("./httpExecutor");
_httpExecutor = function () {
return data;
};
return data;
}
class BintrayClient {
constructor(options, httpExecutor, cancellationToken, apiKey) {
this.httpExecutor = httpExecutor;
this.cancellationToken = cancellationToken;
this.requestHeaders = null;
if (options.owner == null) {
throw new Error("owner is not specified");
}
if (options.package == null) {
throw new Error("package is not specified");
}
this.repo = options.repo || "generic";
this.packageName = options.package;
this.owner = options.owner;
this.user = options.user || options.owner;
this.component = options.component || null;
this.distribution = options.distribution || "stable";
this.auth = apiKey == null ? null : `Basic ${Buffer.from(`${this.user}:${apiKey}`).toString("base64")}`;
this.basePath = `/packages/${this.owner}/${this.repo}/${this.packageName}`;
constructor(options, httpExecutor, cancellationToken, apiKey) {
this.httpExecutor = httpExecutor;
this.cancellationToken = cancellationToken;
this.requestHeaders = null;
if (options.owner == null) {
throw new Error("owner is not specified");
}
setRequestHeaders(value) {
this.requestHeaders = value;
if (options.package == null) {
throw new Error("package is not specified");
}
bintrayRequest(path, auth, data = null, cancellationToken, method) {
return (0, (_httpExecutor || _load_httpExecutor()).parseJson)(this.httpExecutor.request((0, (_httpExecutor || _load_httpExecutor()).configureRequestOptions)({ hostname: "api.bintray.com", path, headers: this.requestHeaders || undefined }, auth, method), cancellationToken, data));
}
getVersion(version) {
return this.bintrayRequest(`${this.basePath}/versions/${version}`, this.auth, null, this.cancellationToken);
}
getVersionFiles(version) {
return this.bintrayRequest(`${this.basePath}/versions/${version}/files`, this.auth, null, this.cancellationToken);
}
createVersion(version) {
return this.bintrayRequest(`${this.basePath}/versions`, this.auth, {
name: version
}, this.cancellationToken);
}
deleteVersion(version) {
return this.bintrayRequest(`${this.basePath}/versions/${version}`, this.auth, null, this.cancellationToken, "DELETE");
}
}
exports.BintrayClient = BintrayClient; //# sourceMappingURL=bintray.js.map
this.repo = options.repo || "generic";
this.packageName = options.package;
this.owner = options.owner;
this.user = options.user || options.owner;
this.component = options.component || null;
this.distribution = options.distribution || "stable";
this.auth = apiKey == null ? null : `Basic ${Buffer.from(`${this.user}:${apiKey}`).toString("base64")}`;
this.basePath = `/packages/${this.owner}/${this.repo}/${this.packageName}`;
}
setRequestHeaders(value) {
this.requestHeaders = value;
}
bintrayRequest(path, auth, data = null, cancellationToken, method) {
return (0, _httpExecutor().parseJson)(this.httpExecutor.request((0, _httpExecutor().configureRequestOptions)({
hostname: "api.bintray.com",
path,
headers: this.requestHeaders || undefined
}, auth, method), cancellationToken, data));
}
getVersion(version) {
return this.bintrayRequest(`${this.basePath}/versions/${version}`, this.auth, null, this.cancellationToken);
}
getVersionFiles(version) {
return this.bintrayRequest(`${this.basePath}/versions/${version}/files`, this.auth, null, this.cancellationToken);
}
createVersion(version) {
return this.bintrayRequest(`${this.basePath}/versions`, this.auth, {
name: version
}, this.cancellationToken);
}
deleteVersion(version) {
return this.bintrayRequest(`${this.basePath}/versions/${version}`, this.auth, null, this.cancellationToken, "DELETE");
}
} exports.BintrayClient = BintrayClient;
//# sourceMappingURL=bintray.js.map
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
value: true
});
exports.readEmbeddedBlockMapData = exports.BLOCK_MAP_FILE_NAME = undefined;
exports.readEmbeddedBlockMapData = readEmbeddedBlockMapData;
exports.BLOCK_MAP_FILE_NAME = void 0;
var _bluebirdLst;
function _bluebirdLst() {
const data = _interopRequireDefault(require("bluebird-lst"));
function _load_bluebirdLst() {
return _bluebirdLst = require("bluebird-lst");
_bluebirdLst = function () {
return data;
};
return data;
}
var _bluebirdLst2;
function _fsExtraP() {
const data = require("fs-extra-p");
function _load_bluebirdLst2() {
return _bluebirdLst2 = _interopRequireDefault(require("bluebird-lst"));
_fsExtraP = function () {
return data;
};
return data;
}
let readEmbeddedBlockMapData = exports.readEmbeddedBlockMapData = (() => {
var _ref = (0, (_bluebirdLst || _load_bluebirdLst()).coroutine)(function* (file) {
const fd = yield (0, (_fsExtraP || _load_fsExtraP()).open)(file, "r");
try {
const fileSize = (yield (0, (_fsExtraP || _load_fsExtraP()).fstat)(fd)).size;
const sizeBuffer = Buffer.allocUnsafe(4);
yield (0, (_fsExtraP || _load_fsExtraP()).read)(fd, sizeBuffer, 0, sizeBuffer.length, fileSize - sizeBuffer.length);
const dataBuffer = Buffer.allocUnsafe(sizeBuffer.readUInt32BE(0));
yield (0, (_fsExtraP || _load_fsExtraP()).read)(fd, dataBuffer, 0, dataBuffer.length, fileSize - sizeBuffer.length - dataBuffer.length);
yield (0, (_fsExtraP || _load_fsExtraP()).close)(fd);
const inflateRaw = (_bluebirdLst2 || _load_bluebirdLst2()).default.promisify(require("zlib").inflateRaw);
return (yield inflateRaw(dataBuffer)).toString();
} catch (e) {
yield (0, (_fsExtraP || _load_fsExtraP()).close)(fd);
throw e;
}
});
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
return function readEmbeddedBlockMapData(_x) {
return _ref.apply(this, arguments);
};
})();
//# sourceMappingURL=blockMapApi.js.map
const BLOCK_MAP_FILE_NAME = "_blockMap.blockmap";
exports.BLOCK_MAP_FILE_NAME = BLOCK_MAP_FILE_NAME;
async function readEmbeddedBlockMapData(file) {
const fd = await (0, _fsExtraP().open)(file, "r");
var _fsExtraP;
try {
const fileSize = (await (0, _fsExtraP().fstat)(fd)).size;
const sizeBuffer = Buffer.allocUnsafe(4);
await (0, _fsExtraP().read)(fd, sizeBuffer, 0, sizeBuffer.length, fileSize - sizeBuffer.length);
const dataBuffer = Buffer.allocUnsafe(sizeBuffer.readUInt32BE(0));
await (0, _fsExtraP().read)(fd, dataBuffer, 0, dataBuffer.length, fileSize - sizeBuffer.length - dataBuffer.length);
await (0, _fsExtraP().close)(fd);
function _load_fsExtraP() {
return _fsExtraP = require("fs-extra-p");
}
const inflateRaw = _bluebirdLst().default.promisify(require("zlib").inflateRaw);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const BLOCK_MAP_FILE_NAME = exports.BLOCK_MAP_FILE_NAME = "_blockMap.blockmap";
return (await inflateRaw(dataBuffer)).toString();
} catch (e) {
await (0, _fsExtraP().close)(fd);
throw e;
}
}
//# sourceMappingURL=blockMapApi.js.map
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
value: true
});
exports.CancellationError = exports.CancellationToken = undefined;
exports.CancellationError = exports.CancellationToken = void 0;
var _bluebirdLst;
function _bluebirdLst() {
const data = _interopRequireDefault(require("bluebird-lst"));
function _load_bluebirdLst() {
return _bluebirdLst = _interopRequireDefault(require("bluebird-lst"));
_bluebirdLst = function () {
return data;
};
return data;
}
var _events;
function _events() {
const data = require("events");
function _load_events() {
return _events = require("events");
_events = function () {
return data;
};
return data;
}

@@ -22,87 +30,106 @@

class CancellationToken extends (_events || _load_events()).EventEmitter {
// babel cannot compile ... correctly for super calls
constructor(parent) {
super();
this.parentCancelHandler = null;
this._parent = null;
this._cancelled = false;
if (parent != null) {
this.parent = parent;
}
class CancellationToken extends _events().EventEmitter {
// babel cannot compile ... correctly for super calls
constructor(parent) {
super();
this.parentCancelHandler = null;
this._parent = null;
this._cancelled = false;
if (parent != null) {
this.parent = parent;
}
get cancelled() {
return this._cancelled || this._parent != null && this._parent.cancelled;
}
get cancelled() {
return this._cancelled || this._parent != null && this._parent.cancelled;
}
set parent(value) {
this.removeParentCancelHandler();
this._parent = value;
this.parentCancelHandler = () => this.cancel();
this._parent.onCancel(this.parentCancelHandler);
}
cancel() {
this._cancelled = true;
this.emit("cancel");
}
onCancel(handler) {
if (this.cancelled) {
handler();
} else {
this.once("cancel", handler);
}
set parent(value) {
this.removeParentCancelHandler();
this._parent = value;
this.parentCancelHandler = () => this.cancel();
this._parent.onCancel(this.parentCancelHandler);
}
createPromise(callback) {
if (this.cancelled) {
return _bluebirdLst().default.reject(new CancellationError());
}
cancel() {
this._cancelled = true;
this.emit("cancel");
}
onCancel(handler) {
if (this.cancelled) {
handler();
} else {
this.once("cancel", handler);
}
}
createPromise(callback) {
if (this.cancelled) {
return (_bluebirdLst || _load_bluebirdLst()).default.reject(new CancellationError());
}
let cancelHandler = null;
return new (_bluebirdLst || _load_bluebirdLst()).default((resolve, reject) => {
let addedCancelHandler = null;
cancelHandler = () => {
try {
if (addedCancelHandler != null) {
addedCancelHandler();
addedCancelHandler = null;
}
} finally {
reject(new CancellationError());
}
};
if (this.cancelled) {
cancelHandler();
return;
}
this.onCancel(cancelHandler);
callback(resolve, reject, callback => {
addedCancelHandler = callback;
});
}).finally(() => {
if (cancelHandler != null) {
this.removeListener("cancel", cancelHandler);
cancelHandler = null;
}
});
}
removeParentCancelHandler() {
const parent = this._parent;
if (parent != null && this.parentCancelHandler != null) {
parent.removeListener("cancel", this.parentCancelHandler);
this.parentCancelHandler = null;
}
}
dispose() {
let cancelHandler = null;
return new (_bluebirdLst().default)((resolve, reject) => {
let addedCancelHandler = null;
cancelHandler = () => {
try {
this.removeParentCancelHandler();
if (addedCancelHandler != null) {
addedCancelHandler();
addedCancelHandler = null;
}
} finally {
this.removeAllListeners();
this._parent = null;
reject(new CancellationError());
}
};
if (this.cancelled) {
cancelHandler();
return;
}
this.onCancel(cancelHandler);
callback(resolve, reject, callback => {
addedCancelHandler = callback;
});
}).finally(() => {
if (cancelHandler != null) {
this.removeListener("cancel", cancelHandler);
cancelHandler = null;
}
});
}
removeParentCancelHandler() {
const parent = this._parent;
if (parent != null && this.parentCancelHandler != null) {
parent.removeListener("cancel", this.parentCancelHandler);
this.parentCancelHandler = null;
}
}
dispose() {
try {
this.removeParentCancelHandler();
} finally {
this.removeAllListeners();
this._parent = null;
}
}
}
exports.CancellationToken = CancellationToken;
class CancellationError extends Error {
constructor() {
super("Cancelled");
}
}
exports.CancellationError = CancellationError; //# sourceMappingURL=CancellationToken.js.map
constructor() {
super("Cancelled");
}
} exports.CancellationError = CancellationError;
//# sourceMappingURL=CancellationToken.js.map
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
value: true
});
exports.DigestTransform = exports.HttpExecutor = exports.HttpError = undefined;
exports.createHttpError = createHttpError;

@@ -13,7 +12,12 @@ exports.parseJson = parseJson;

exports.safeStringifyJson = safeStringifyJson;
exports.DigestTransform = exports.HttpExecutor = exports.HttpError = void 0;
var _crypto;
function _crypto() {
const data = require("crypto");
function _load_crypto() {
return _crypto = require("crypto");
_crypto = function () {
return data;
};
return data;
}

@@ -23,36 +27,60 @@

var _fsExtraP;
function _fsExtraP() {
const data = require("fs-extra-p");
function _load_fsExtraP() {
return _fsExtraP = require("fs-extra-p");
_fsExtraP = function () {
return data;
};
return data;
}
var _stream;
function _stream() {
const data = require("stream");
function _load_stream() {
return _stream = require("stream");
_stream = function () {
return data;
};
return data;
}
var _url;
function _url() {
const data = require("url");
function _load_url() {
return _url = require("url");
_url = function () {
return data;
};
return data;
}
var _CancellationToken;
function _CancellationToken() {
const data = require("./CancellationToken");
function _load_CancellationToken() {
return _CancellationToken = require("./CancellationToken");
_CancellationToken = function () {
return data;
};
return data;
}
var _index;
function _index() {
const data = require("./index");
function _load_index() {
return _index = require("./index");
_index = function () {
return data;
};
return data;
}
var _ProgressCallbackTransform;
function _ProgressCallbackTransform() {
const data = require("./ProgressCallbackTransform");
function _load_ProgressCallbackTransform() {
return _ProgressCallbackTransform = require("./ProgressCallbackTransform");
_ProgressCallbackTransform = function () {
return data;
};
return data;
}

@@ -63,295 +91,363 @@

const debug = (0, _debug2.default)("electron-builder");
function createHttpError(response, description = null) {
return new HttpError(response.statusCode || -1, `${response.statusCode} ${response.statusMessage}` + (description == null ? "" : "\n" + JSON.stringify(description, null, " ")) + "\nHeaders: " + safeStringifyJson(response.headers), description);
return new HttpError(response.statusCode || -1, `${response.statusCode} ${response.statusMessage}` + (description == null ? "" : "\n" + JSON.stringify(description, null, " ")) + "\nHeaders: " + safeStringifyJson(response.headers), description);
}
const HTTP_STATUS_CODES = new Map([[429, "Too many requests"], [400, "Bad request"], [403, "Forbidden"], [404, "Not found"], [405, "Method not allowed"], [406, "Not acceptable"], [408, "Request timeout"], [413, "Request entity too large"], [500, "Internal server error"], [502, "Bad gateway"], [503, "Service unavailable"], [504, "Gateway timeout"], [505, "HTTP version not supported"]]);
class HttpError extends Error {
constructor(statusCode, message = `HTTP error: ${HTTP_STATUS_CODES.get(statusCode) || statusCode}`, description = null) {
super(message);
this.statusCode = statusCode;
this.description = description;
this.name = "HttpError";
}
constructor(statusCode, message = `HTTP error: ${HTTP_STATUS_CODES.get(statusCode) || statusCode}`, description = null) {
super(message);
this.statusCode = statusCode;
this.description = description;
this.name = "HttpError";
}
}
exports.HttpError = HttpError;
function parseJson(result) {
return result.then(it => it == null || it.length === 0 ? null : JSON.parse(it));
return result.then(it => it == null || it.length === 0 ? null : JSON.parse(it));
}
class HttpExecutor {
constructor() {
this.maxRedirects = 10;
constructor() {
this.maxRedirects = 10;
}
request(options, cancellationToken = new (_CancellationToken().CancellationToken)(), data) {
configureRequestOptions(options);
const encodedData = data == null ? undefined : Buffer.from(JSON.stringify(data));
if (encodedData != null) {
options.method = "post";
options.headers["Content-Type"] = "application/json";
options.headers["Content-Length"] = encodedData.length;
}
request(options, cancellationToken = new (_CancellationToken || _load_CancellationToken()).CancellationToken(), data) {
configureRequestOptions(options);
const encodedData = data == null ? undefined : Buffer.from(JSON.stringify(data));
if (encodedData != null) {
options.method = "post";
options.headers["Content-Type"] = "application/json";
options.headers["Content-Length"] = encodedData.length;
}
return this.doApiRequest(options, cancellationToken, it => it.end(encodedData));
return this.doApiRequest(options, cancellationToken, it => it.end(encodedData));
}
doApiRequest(options, cancellationToken, requestProcessor, redirectCount = 0) {
if (debug.enabled) {
debug(`Request: ${safeStringifyJson(options)}`);
}
doApiRequest(options, cancellationToken, requestProcessor, redirectCount = 0) {
if (debug.enabled) {
debug(`Request: ${safeStringifyJson(options)}`);
return cancellationToken.createPromise((resolve, reject, onCancel) => {
const request = this.doRequest(options, response => {
try {
this.handleResponse(response, options, cancellationToken, resolve, reject, redirectCount, requestProcessor);
} catch (e) {
reject(e);
}
return cancellationToken.createPromise((resolve, reject, onCancel) => {
const request = this.doRequest(options, response => {
try {
this.handleResponse(response, options, cancellationToken, resolve, reject, redirectCount, requestProcessor);
} catch (e) {
reject(e);
}
});
this.addErrorAndTimeoutHandlers(request, reject);
this.addRedirectHandlers(request, options, reject, redirectCount, options => {
this.doApiRequest(options, cancellationToken, requestProcessor, redirectCount).then(resolve).catch(reject);
});
requestProcessor(request, reject);
onCancel(() => request.abort());
});
}
// noinspection JSUnusedLocalSymbols
addRedirectHandlers(request, options, reject, redirectCount, handler) {
// not required for NodeJS
}
addErrorAndTimeoutHandlers(request, reject) {
this.addTimeOutHandler(request, reject);
request.on("error", reject);
request.on("aborted", () => {
reject(new Error("Request has been aborted by the server"));
});
}
handleResponse(response, options, cancellationToken, resolve, reject, redirectCount, requestProcessor) {
if (debug.enabled) {
debug(`Response: ${response.statusCode} ${response.statusMessage}, request options: ${safeStringifyJson(options)}`);
}
// we handle any other >= 400 error on request end (read detailed message in the response body)
if (response.statusCode === 404) {
// error is clear, we don't need to read detailed error description
reject(createHttpError(response, `method: ${options.method} url: ${options.protocol || "https:"}//${options.hostname}${options.path}
});
this.addErrorAndTimeoutHandlers(request, reject);
this.addRedirectHandlers(request, options, reject, redirectCount, options => {
this.doApiRequest(options, cancellationToken, requestProcessor, redirectCount).then(resolve).catch(reject);
});
requestProcessor(request, reject);
onCancel(() => request.abort());
});
} // noinspection JSUnusedLocalSymbols
addRedirectHandlers(request, options, reject, redirectCount, handler) {// not required for NodeJS
}
addErrorAndTimeoutHandlers(request, reject) {
this.addTimeOutHandler(request, reject);
request.on("error", reject);
request.on("aborted", () => {
reject(new Error("Request has been aborted by the server"));
});
}
handleResponse(response, options, cancellationToken, resolve, reject, redirectCount, requestProcessor) {
if (debug.enabled) {
debug(`Response: ${response.statusCode} ${response.statusMessage}, request options: ${safeStringifyJson(options)}`);
} // we handle any other >= 400 error on request end (read detailed message in the response body)
if (response.statusCode === 404) {
// error is clear, we don't need to read detailed error description
reject(createHttpError(response, `method: ${options.method} url: ${options.protocol || "https:"}//${options.hostname}${options.path}
Please double check that your authentication token is correct. Due to security reasons actual status maybe not reported, but 404.
`));
return;
} else if (response.statusCode === 204) {
// on DELETE request
resolve();
return;
}
const redirectUrl = safeGetHeader(response, "location");
if (redirectUrl != null) {
if (redirectCount > 10) {
reject(new Error("Too many redirects (> 10)"));
return;
}
this.doApiRequest(HttpExecutor.prepareRedirectUrlOptions(redirectUrl, options), cancellationToken, requestProcessor, redirectCount).then(resolve).catch(reject);
return;
}
let data = "";
response.setEncoding("utf8");
response.on("data", chunk => data += chunk);
response.on("end", () => {
try {
if (response.statusCode != null && response.statusCode >= 400) {
const contentType = safeGetHeader(response, "content-type");
const isJson = contentType != null && (Array.isArray(contentType) ? contentType.find(it => it.includes("json")) != null : contentType.includes("json"));
reject(createHttpError(response, isJson ? JSON.parse(data) : data));
} else {
resolve(data.length === 0 ? null : data);
}
} catch (e) {
reject(e);
}
});
return;
} else if (response.statusCode === 204) {
// on DELETE request
resolve();
return;
}
doDownload(requestOptions, destination, redirectCount, options, callback, onCancel) {
const request = this.doRequest(requestOptions, response => {
if (response.statusCode >= 400) {
callback(new Error(`Cannot download "${requestOptions.protocol || "https:"}//${requestOptions.hostname}${requestOptions.path}", status ${response.statusCode}: ${response.statusMessage}`));
return;
}
const redirectUrl = safeGetHeader(response, "location");
if (redirectUrl != null) {
if (redirectCount < this.maxRedirects) {
this.doDownload(HttpExecutor.prepareRedirectUrlOptions(redirectUrl, requestOptions), destination, redirectCount++, options, callback, onCancel);
} else {
callback(new Error(`Too many redirects (> ${this.maxRedirects})`));
}
return;
}
configurePipes(options, response, destination, callback, options.cancellationToken);
});
this.addErrorAndTimeoutHandlers(request, callback);
this.addRedirectHandlers(request, requestOptions, callback, redirectCount, requestOptions => {
this.doDownload(requestOptions, destination, redirectCount++, options, callback, onCancel);
});
onCancel(() => request.abort());
request.end();
const redirectUrl = safeGetHeader(response, "location");
if (redirectUrl != null) {
if (redirectCount > 10) {
reject(new Error("Too many redirects (> 10)"));
return;
}
this.doApiRequest(HttpExecutor.prepareRedirectUrlOptions(redirectUrl, options), cancellationToken, requestProcessor, redirectCount).then(resolve).catch(reject);
return;
}
addTimeOutHandler(request, callback) {
request.on("socket", socket => {
socket.setTimeout(60 * 1000, () => {
callback(new Error("Request timed out"));
request.abort();
});
});
}
static prepareRedirectUrlOptions(redirectUrl, options) {
const newOptions = configureRequestOptionsFromUrl(redirectUrl, Object.assign({}, options));
if (newOptions.headers != null && newOptions.headers.Authorization != null && newOptions.headers.Authorization.startsWith("token")) {
const parsedNewUrl = new (_url || _load_url()).URL(redirectUrl);
if (parsedNewUrl.hostname.endsWith(".amazonaws.com")) {
delete newOptions.headers.Authorization;
}
let data = "";
response.setEncoding("utf8");
response.on("data", chunk => data += chunk);
response.on("end", () => {
try {
if (response.statusCode != null && response.statusCode >= 400) {
const contentType = safeGetHeader(response, "content-type");
const isJson = contentType != null && (Array.isArray(contentType) ? contentType.find(it => it.includes("json")) != null : contentType.includes("json"));
reject(createHttpError(response, isJson ? JSON.parse(data) : data));
} else {
resolve(data.length === 0 ? null : data);
}
return newOptions;
} catch (e) {
reject(e);
}
});
}
doDownload(requestOptions, destination, redirectCount, options, callback, onCancel) {
const request = this.doRequest(requestOptions, response => {
if (response.statusCode >= 400) {
callback(new Error(`Cannot download "${requestOptions.protocol || "https:"}//${requestOptions.hostname}${requestOptions.path}", status ${response.statusCode}: ${response.statusMessage}`));
return;
}
const redirectUrl = safeGetHeader(response, "location");
if (redirectUrl != null) {
if (redirectCount < this.maxRedirects) {
this.doDownload(HttpExecutor.prepareRedirectUrlOptions(redirectUrl, requestOptions), destination, redirectCount++, options, callback, onCancel);
} else {
callback(new Error(`Too many redirects (> ${this.maxRedirects})`));
}
return;
}
configurePipes(options, response, destination, callback, options.cancellationToken);
});
this.addErrorAndTimeoutHandlers(request, callback);
this.addRedirectHandlers(request, requestOptions, callback, redirectCount, requestOptions => {
this.doDownload(requestOptions, destination, redirectCount++, options, callback, onCancel);
});
onCancel(() => request.abort());
request.end();
}
addTimeOutHandler(request, callback) {
request.on("socket", socket => {
socket.setTimeout(60 * 1000, () => {
callback(new Error("Request timed out"));
request.abort();
});
});
}
static prepareRedirectUrlOptions(redirectUrl, options) {
const newOptions = configureRequestOptionsFromUrl(redirectUrl, Object.assign({}, options));
if (newOptions.headers != null && newOptions.headers.Authorization != null && newOptions.headers.Authorization.startsWith("token")) {
const parsedNewUrl = new (_url().URL)(redirectUrl);
if (parsedNewUrl.hostname.endsWith(".amazonaws.com")) {
delete newOptions.headers.Authorization;
}
}
return newOptions;
}
}
exports.HttpExecutor = HttpExecutor;
function configureRequestOptionsFromUrl(url, options) {
const parsedUrl = (0, (_url || _load_url()).parse)(url);
options.protocol = parsedUrl.protocol;
options.hostname = parsedUrl.hostname;
if (parsedUrl.port == null) {
if (options.port != null) {
delete options.port;
}
} else {
options.port = parsedUrl.port;
const parsedUrl = (0, _url().parse)(url);
options.protocol = parsedUrl.protocol;
options.hostname = parsedUrl.hostname;
if (parsedUrl.port == null) {
if (options.port != null) {
delete options.port;
}
options.path = parsedUrl.path;
return configureRequestOptions(options);
} else {
options.port = parsedUrl.port;
}
options.path = parsedUrl.path;
return configureRequestOptions(options);
}
class DigestTransform extends (_stream || _load_stream()).Transform {
constructor(expected, algorithm = "sha512", encoding = "base64") {
super();
this.expected = expected;
this.algorithm = algorithm;
this.encoding = encoding;
this._actual = null;
this.isValidateOnEnd = true;
this.digester = (0, (_crypto || _load_crypto()).createHash)(algorithm);
class DigestTransform extends _stream().Transform {
constructor(expected, algorithm = "sha512", encoding = "base64") {
super();
this.expected = expected;
this.algorithm = algorithm;
this.encoding = encoding;
this._actual = null;
this.isValidateOnEnd = true;
this.digester = (0, _crypto().createHash)(algorithm);
} // noinspection JSUnusedGlobalSymbols
get actual() {
return this._actual;
} // noinspection JSUnusedGlobalSymbols
_transform(chunk, encoding, callback) {
this.digester.update(chunk);
callback(null, chunk);
} // noinspection JSUnusedGlobalSymbols
_flush(callback) {
this._actual = this.digester.digest(this.encoding);
if (this.isValidateOnEnd) {
try {
this.validate();
} catch (e) {
callback(e);
return;
}
}
// noinspection JSUnusedGlobalSymbols
get actual() {
return this._actual;
callback(null);
}
validate() {
if (this._actual == null) {
throw (0, _index().newError)("Not finished yet", "ERR_STREAM_NOT_FINISHED");
}
// noinspection JSUnusedGlobalSymbols
_transform(chunk, encoding, callback) {
this.digester.update(chunk);
callback(null, chunk);
if (this._actual !== this.expected) {
throw (0, _index().newError)(`${this.algorithm} checksum mismatch, expected ${this.expected}, got ${this._actual}`, "ERR_CHECKSUM_MISMATCH");
}
// noinspection JSUnusedGlobalSymbols
_flush(callback) {
this._actual = this.digester.digest(this.encoding);
if (this.isValidateOnEnd) {
try {
this.validate();
} catch (e) {
callback(e);
return;
}
}
callback(null);
}
validate() {
if (this._actual == null) {
throw (0, (_index || _load_index()).newError)("Not finished yet", "ERR_STREAM_NOT_FINISHED");
}
if (this._actual !== this.expected) {
throw (0, (_index || _load_index()).newError)(`${this.algorithm} checksum mismatch, expected ${this.expected}, got ${this._actual}`, "ERR_CHECKSUM_MISMATCH");
}
return null;
}
return null;
}
}
exports.DigestTransform = DigestTransform;
function checkSha2(sha2Header, sha2, callback) {
if (sha2Header != null && sha2 != null) {
// todo why bintray doesn't send this header always
if (sha2Header == null) {
callback(new Error("checksum is required, but server response doesn't contain X-Checksum-Sha2 header"));
return false;
} else if (sha2Header !== sha2) {
callback(new Error(`checksum mismatch: expected ${sha2} but got ${sha2Header} (X-Checksum-Sha2 header)`));
return false;
}
if (sha2Header != null && sha2 != null) {
// todo why bintray doesn't send this header always
if (sha2Header == null) {
callback(new Error("checksum is required, but server response doesn't contain X-Checksum-Sha2 header"));
return false;
} else if (sha2Header !== sha2) {
callback(new Error(`checksum mismatch: expected ${sha2} but got ${sha2Header} (X-Checksum-Sha2 header)`));
return false;
}
return true;
}
return true;
}
function safeGetHeader(response, headerKey) {
const value = response.headers[headerKey];
if (value == null) {
return null;
} else if (Array.isArray(value)) {
// electron API
return value.length === 0 ? null : value[value.length - 1];
} else {
return value;
}
const value = response.headers[headerKey];
if (value == null) {
return null;
} else if (Array.isArray(value)) {
// electron API
return value.length === 0 ? null : value[value.length - 1];
} else {
return value;
}
}
function configurePipes(options, response, destination, callback, cancellationToken) {
if (!checkSha2(safeGetHeader(response, "X-Checksum-Sha2"), options.sha2, callback)) {
return;
if (!checkSha2(safeGetHeader(response, "X-Checksum-Sha2"), options.sha2, callback)) {
return;
}
const streams = [];
if (options.onProgress != null) {
const contentLength = safeGetHeader(response, "content-length");
if (contentLength != null) {
streams.push(new (_ProgressCallbackTransform().ProgressCallbackTransform)(parseInt(contentLength, 10), options.cancellationToken, options.onProgress));
}
const streams = [];
if (options.onProgress != null) {
const contentLength = safeGetHeader(response, "content-length");
if (contentLength != null) {
streams.push(new (_ProgressCallbackTransform || _load_ProgressCallbackTransform()).ProgressCallbackTransform(parseInt(contentLength, 10), options.cancellationToken, options.onProgress));
}
}
const sha512 = options.sha512;
if (sha512 != null) {
streams.push(new DigestTransform(sha512, "sha512", sha512.length === 128 && !sha512.includes("+") && !sha512.includes("Z") && !sha512.includes("=") ? "hex" : "base64"));
} else if (options.sha2 != null) {
streams.push(new DigestTransform(options.sha2, "sha256", "hex"));
}
const fileOut = (0, (_fsExtraP || _load_fsExtraP()).createWriteStream)(destination);
streams.push(fileOut);
let lastStream = response;
for (const stream of streams) {
stream.on("error", error => {
if (!cancellationToken.cancelled) {
callback(error);
}
});
lastStream = lastStream.pipe(stream);
}
fileOut.on("finish", () => {
fileOut.close(callback);
}
const sha512 = options.sha512;
if (sha512 != null) {
streams.push(new DigestTransform(sha512, "sha512", sha512.length === 128 && !sha512.includes("+") && !sha512.includes("Z") && !sha512.includes("=") ? "hex" : "base64"));
} else if (options.sha2 != null) {
streams.push(new DigestTransform(options.sha2, "sha256", "hex"));
}
const fileOut = (0, _fsExtraP().createWriteStream)(destination);
streams.push(fileOut);
let lastStream = response;
for (const stream of streams) {
stream.on("error", error => {
if (!cancellationToken.cancelled) {
callback(error);
}
});
lastStream = lastStream.pipe(stream);
}
fileOut.on("finish", () => {
fileOut.close(callback);
});
}
function configureRequestOptions(options, token, method) {
if (method != null) {
options.method = method;
}
let headers = options.headers;
if (headers == null) {
headers = {};
options.headers = headers;
}
if (token != null) {
headers.authorization = token.startsWith("Basic") ? token : `token ${token}`;
}
if (headers["User-Agent"] == null) {
headers["User-Agent"] = "electron-builder";
}
if (method == null || method === "GET" || headers["Cache-Control"] == null) {
headers["Cache-Control"] = "no-cache";
}
// do not specify for node (in any case we use https module)
if (options.protocol == null && process.versions.electron != null) {
options.protocol = "https:";
}
return options;
if (method != null) {
options.method = method;
}
let headers = options.headers;
if (headers == null) {
headers = {};
options.headers = headers;
}
if (token != null) {
headers.authorization = token.startsWith("Basic") ? token : `token ${token}`;
}
if (headers["User-Agent"] == null) {
headers["User-Agent"] = "electron-builder";
}
if (method == null || method === "GET" || headers["Cache-Control"] == null) {
headers["Cache-Control"] = "no-cache";
} // do not specify for node (in any case we use https module)
if (options.protocol == null && process.versions.electron != null) {
options.protocol = "https:";
}
return options;
}
function safeStringifyJson(data, skippedNames) {
return JSON.stringify(data, (name, value) => {
if (name.endsWith("authorization") || name.endsWith("Password") || name.endsWith("PASSWORD") || name.endsWith("Token") || name.includes("password") || name.includes("token") || skippedNames != null && skippedNames.has(name)) {
return "<stripped sensitive data>";
}
return value;
}, 2);
}
return JSON.stringify(data, (name, value) => {
if (name.endsWith("authorization") || name.endsWith("Password") || name.endsWith("PASSWORD") || name.endsWith("Token") || name.includes("password") || name.includes("token") || skippedNames != null && skippedNames.has(name)) {
return "<stripped sensitive data>";
}
return value;
}, 2);
}
//# sourceMappingURL=httpExecutor.js.map
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
value: true
});
var _CancellationToken;
function _load_CancellationToken() {
return _CancellationToken = require("./CancellationToken");
}
exports.asArray = asArray;
exports.newError = newError;
Object.defineProperty(exports, "CancellationToken", {
enumerable: true,
get: function () {
return (_CancellationToken || _load_CancellationToken()).CancellationToken;
}
enumerable: true,
get: function () {
return _CancellationToken().CancellationToken;
}
});
Object.defineProperty(exports, "CancellationError", {
enumerable: true,
get: function () {
return (_CancellationToken || _load_CancellationToken()).CancellationError;
}
enumerable: true,
get: function () {
return _CancellationToken().CancellationError;
}
});
var _httpExecutor;
function _load_httpExecutor() {
return _httpExecutor = require("./httpExecutor");
}
Object.defineProperty(exports, "HttpError", {
enumerable: true,
get: function () {
return (_httpExecutor || _load_httpExecutor()).HttpError;
}
enumerable: true,
get: function () {
return _httpExecutor().HttpError;
}
});
Object.defineProperty(exports, "createHttpError", {
enumerable: true,
get: function () {
return (_httpExecutor || _load_httpExecutor()).createHttpError;
}
enumerable: true,
get: function () {
return _httpExecutor().createHttpError;
}
});
Object.defineProperty(exports, "HttpExecutor", {
enumerable: true,
get: function () {
return (_httpExecutor || _load_httpExecutor()).HttpExecutor;
}
enumerable: true,
get: function () {
return _httpExecutor().HttpExecutor;
}
});
Object.defineProperty(exports, "DigestTransform", {
enumerable: true,
get: function () {
return (_httpExecutor || _load_httpExecutor()).DigestTransform;
}
enumerable: true,
get: function () {
return _httpExecutor().DigestTransform;
}
});
Object.defineProperty(exports, "safeGetHeader", {
enumerable: true,
get: function () {
return (_httpExecutor || _load_httpExecutor()).safeGetHeader;
}
enumerable: true,
get: function () {
return _httpExecutor().safeGetHeader;
}
});
Object.defineProperty(exports, "configureRequestOptions", {
enumerable: true,
get: function () {
return (_httpExecutor || _load_httpExecutor()).configureRequestOptions;
}
enumerable: true,
get: function () {
return _httpExecutor().configureRequestOptions;
}
});
Object.defineProperty(exports, "configureRequestOptionsFromUrl", {
enumerable: true,
get: function () {
return (_httpExecutor || _load_httpExecutor()).configureRequestOptionsFromUrl;
}
enumerable: true,
get: function () {
return _httpExecutor().configureRequestOptionsFromUrl;
}
});
Object.defineProperty(exports, "safeStringifyJson", {
enumerable: true,
get: function () {
return (_httpExecutor || _load_httpExecutor()).safeStringifyJson;
}
enumerable: true,
get: function () {
return _httpExecutor().safeStringifyJson;
}
});
Object.defineProperty(exports, "parseJson", {
enumerable: true,
get: function () {
return (_httpExecutor || _load_httpExecutor()).parseJson;
}
enumerable: true,
get: function () {
return _httpExecutor().parseJson;
}
});
var _publishOptions;
function _load_publishOptions() {
return _publishOptions = require("./publishOptions");
}
Object.defineProperty(exports, "getS3LikeProviderBaseUrl", {
enumerable: true,
get: function () {
return (_publishOptions || _load_publishOptions()).getS3LikeProviderBaseUrl;
}
enumerable: true,
get: function () {
return _publishOptions().getS3LikeProviderBaseUrl;
}
});
Object.defineProperty(exports, "githubUrl", {
enumerable: true,
get: function () {
return (_publishOptions || _load_publishOptions()).githubUrl;
}
enumerable: true,
get: function () {
return _publishOptions().githubUrl;
}
});
Object.defineProperty(exports, "parseDn", {
enumerable: true,
get: function () {
return _rfc2253Parser().parseDn;
}
});
Object.defineProperty(exports, "UUID", {
enumerable: true,
get: function () {
return _uuid().UUID;
}
});
Object.defineProperty(exports, "ProgressCallbackTransform", {
enumerable: true,
get: function () {
return _ProgressCallbackTransform().ProgressCallbackTransform;
}
});
Object.defineProperty(exports, "parseXml", {
enumerable: true,
get: function () {
return _xml().parseXml;
}
});
Object.defineProperty(exports, "XElement", {
enumerable: true,
get: function () {
return _xml().XElement;
}
});
var _rfc2253Parser;
function _CancellationToken() {
const data = require("./CancellationToken");
function _load_rfc2253Parser() {
return _rfc2253Parser = require("./rfc2253Parser");
_CancellationToken = function () {
return data;
};
return data;
}
Object.defineProperty(exports, "parseDn", {
enumerable: true,
get: function () {
return (_rfc2253Parser || _load_rfc2253Parser()).parseDn;
}
});
function _httpExecutor() {
const data = require("./httpExecutor");
var _uuid;
_httpExecutor = function () {
return data;
};
function _load_uuid() {
return _uuid = require("./uuid");
return data;
}
Object.defineProperty(exports, "UUID", {
enumerable: true,
get: function () {
return (_uuid || _load_uuid()).UUID;
}
});
function _publishOptions() {
const data = require("./publishOptions");
var _ProgressCallbackTransform;
_publishOptions = function () {
return data;
};
function _load_ProgressCallbackTransform() {
return _ProgressCallbackTransform = require("./ProgressCallbackTransform");
return data;
}
Object.defineProperty(exports, "ProgressCallbackTransform", {
enumerable: true,
get: function () {
return (_ProgressCallbackTransform || _load_ProgressCallbackTransform()).ProgressCallbackTransform;
}
});
function _rfc2253Parser() {
const data = require("./rfc2253Parser");
var _xml;
_rfc2253Parser = function () {
return data;
};
function _load_xml() {
return _xml = require("./xml");
return data;
}
Object.defineProperty(exports, "parseXml", {
enumerable: true,
get: function () {
return (_xml || _load_xml()).parseXml;
}
});
Object.defineProperty(exports, "XElement", {
enumerable: true,
get: function () {
return (_xml || _load_xml()).XElement;
}
});
exports.asArray = asArray;
exports.newError = newError;
function _uuid() {
const data = require("./uuid");
_uuid = function () {
return data;
};
return data;
}
function _ProgressCallbackTransform() {
const data = require("./ProgressCallbackTransform");
_ProgressCallbackTransform = function () {
return data;
};
return data;
}
function _xml() {
const data = require("./xml");
_xml = function () {
return data;
};
return data;
}
function asArray(v) {
if (v == null) {
return [];
} else if (Array.isArray(v)) {
return v;
} else {
return [v];
}
if (v == null) {
return [];
} else if (Array.isArray(v)) {
return v;
} else {
return [v];
}
}
function newError(message, code) {
const error = new Error(message);
error.code = code;
return error;
}
const error = new Error(message);
error.code = code;
return error;
}
//# sourceMappingURL=index.js.map
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
value: true
});
exports.ProgressCallbackTransform = undefined;
exports.ProgressCallbackTransform = void 0;
var _stream;
function _stream() {
const data = require("stream");
function _load_stream() {
return _stream = require("stream");
_stream = function () {
return data;
};
return data;
}
class ProgressCallbackTransform extends (_stream || _load_stream()).Transform {
constructor(total, cancellationToken, onProgress) {
super();
this.total = total;
this.cancellationToken = cancellationToken;
this.onProgress = onProgress;
this.start = Date.now();
this.transferred = 0;
this.delta = 0;
this.nextUpdate = this.start + 1000;
class ProgressCallbackTransform extends _stream().Transform {
constructor(total, cancellationToken, onProgress) {
super();
this.total = total;
this.cancellationToken = cancellationToken;
this.onProgress = onProgress;
this.start = Date.now();
this.transferred = 0;
this.delta = 0;
this.nextUpdate = this.start + 1000;
}
_transform(chunk, encoding, callback) {
if (this.cancellationToken.cancelled) {
callback(new Error("Cancelled"), null);
return;
}
_transform(chunk, encoding, callback) {
if (this.cancellationToken.cancelled) {
callback(new Error("Cancelled"), null);
return;
}
this.transferred += chunk.length;
this.delta += chunk.length;
const now = Date.now();
if (now >= this.nextUpdate && this.transferred !== this.total /* will be emitted on _flush */) {
this.nextUpdate = now + 1000;
this.onProgress({
total: this.total,
delta: this.delta,
transferred: this.transferred,
percent: this.transferred / this.total * 100,
bytesPerSecond: Math.round(this.transferred / ((now - this.start) / 1000))
});
this.delta = 0;
}
callback(null, chunk);
}
_flush(callback) {
if (this.cancellationToken.cancelled) {
callback(new Error("Cancelled"));
return;
}
this.transferred += chunk.length;
this.delta += chunk.length;
const now = Date.now();
if (now >= this.nextUpdate && this.transferred !== this.total
/* will be emitted on _flush */
) {
this.nextUpdate = now + 1000;
this.onProgress({
total: this.total,
delta: this.delta,
transferred: this.total,
percent: 100,
bytesPerSecond: Math.round(this.transferred / ((Date.now() - this.start) / 1000))
total: this.total,
delta: this.delta,
transferred: this.transferred,
percent: this.transferred / this.total * 100,
bytesPerSecond: Math.round(this.transferred / ((now - this.start) / 1000))
});
this.delta = 0;
callback(null);
}
callback(null, chunk);
}
_flush(callback) {
if (this.cancellationToken.cancelled) {
callback(new Error("Cancelled"));
return;
}
}
exports.ProgressCallbackTransform = ProgressCallbackTransform; //# sourceMappingURL=ProgressCallbackTransform.js.map
this.onProgress({
total: this.total,
delta: this.delta,
transferred: this.total,
percent: 100,
bytesPerSecond: Math.round(this.transferred / ((Date.now() - this.start) / 1000))
});
this.delta = 0;
callback(null);
}
} exports.ProgressCallbackTransform = ProgressCallbackTransform;
//# sourceMappingURL=ProgressCallbackTransform.js.map

@@ -13,2 +13,11 @@ export declare type PublishProvider = "github" | "bintray" | "s3" | "spaces" | "generic";

readonly publisherName?: Array<string> | null;
/**
* Whether to publish auto update info files.
*
* Auto update relies only on the first provider in the list (you can specify several publishers).
* Thus, probably, there`s no need to upload the metadata files for the other configured providers. But by default will be uploaded.
*
* @default true
*/
readonly publishAutoUpdate?: boolean;
}

@@ -15,0 +24,0 @@ /**

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
value: true
});
exports.githubUrl = githubUrl;
exports.getS3LikeProviderBaseUrl = getS3LikeProviderBaseUrl;
/** @private */
function githubUrl(options, defaultHost = "github.com") {
return `${options.protocol || "https"}://${options.host || defaultHost}`;
return `${options.protocol || "https"}://${options.host || defaultHost}`;
}
function getS3LikeProviderBaseUrl(configuration) {
const provider = configuration.provider;
if (provider === "s3") {
return s3Url(configuration);
}
if (provider === "spaces") {
return spacesUrl(configuration);
}
throw new Error(`Not supported provider: ${provider}`);
const provider = configuration.provider;
if (provider === "s3") {
return s3Url(configuration);
}
if (provider === "spaces") {
return spacesUrl(configuration);
}
throw new Error(`Not supported provider: ${provider}`);
}
function s3Url(options) {
let url;
if (options.endpoint != null) {
url = `${options.endpoint}/${options.bucket}`;
let url;
if (options.endpoint != null) {
url = `${options.endpoint}/${options.bucket}`;
} else {
if (!options.bucket.includes(".")) {
if (options.region === "cn-north-1") {
url = `https://${options.bucket}.s3.${options.region}.amazonaws.com.cn`;
} else {
url = `https://${options.bucket}.s3.amazonaws.com`;
}
} else {
if (!options.bucket.includes(".")) {
if (options.region === "cn-north-1") {
url = `https://${options.bucket}.s3.${options.region}.amazonaws.com.cn`;
} else {
url = `https://${options.bucket}.s3.amazonaws.com`;
}
} else {
if (options.region == null) {
throw new Error(`Bucket name "${options.bucket}" includes a dot, but S3 region is missing`);
}
// special case, see http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingBucket.html#access-bucket-intro
url = options.region === "us-east-1" ? `https://s3.amazonaws.com/${options.bucket}` : `https://s3-${options.region}.amazonaws.com/${options.bucket}`;
}
if (options.region == null) {
throw new Error(`Bucket name "${options.bucket}" includes a dot, but S3 region is missing`);
} // special case, see http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingBucket.html#access-bucket-intro
url = options.region === "us-east-1" ? `https://s3.amazonaws.com/${options.bucket}` : `https://s3-${options.region}.amazonaws.com/${options.bucket}`;
}
if (options.path != null) {
url += `/${options.path}`;
}
return url;
}
if (options.path != null) {
url += `/${options.path}`;
}
return url;
}
function spacesUrl(options) {
if (options.name == null) {
throw new Error(`name is missing`);
}
if (options.region == null) {
throw new Error(`region is missing`);
}
let url = `https://${options.name}.${options.region}.digitaloceanspaces.com`;
if (options.path != null) {
url += `/${options.path}`;
}
return url;
}
if (options.name == null) {
throw new Error(`name is missing`);
}
if (options.region == null) {
throw new Error(`region is missing`);
}
let url = `https://${options.name}.${options.region}.digitaloceanspaces.com`;
if (options.path != null) {
url += `/${options.path}`;
}
return url;
}
//# sourceMappingURL=publishOptions.js.map

@@ -1,77 +0,95 @@

'use strict';
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
value: true
});
exports.parseDn = parseDn;
function parseDn(seq) {
let quoted = false;
let key = null;
let token = "";
let nextNonSpace = 0;
seq = seq.trim();
const result = new Map();
for (let i = 0; i <= seq.length; i++) {
if (i === seq.length) {
if (key !== null) {
result.set(key, token);
}
break;
}
const ch = seq[i];
if (quoted) {
if (ch === '"') {
quoted = false;
continue;
}
let quoted = false;
let key = null;
let token = "";
let nextNonSpace = 0;
seq = seq.trim();
const result = new Map();
for (let i = 0; i <= seq.length; i++) {
if (i === seq.length) {
if (key !== null) {
result.set(key, token);
}
break;
}
const ch = seq[i];
if (quoted) {
if (ch === '"') {
quoted = false;
continue;
}
} else {
if (ch === '"') {
quoted = true;
continue;
}
if (ch === "\\") {
i++;
const ord = parseInt(seq.slice(i, i + 2), 16);
if (Number.isNaN(ord)) {
token += seq[i];
} else {
if (ch === '"') {
quoted = true;
continue;
}
if (ch === "\\") {
i++;
const ord = parseInt(seq.slice(i, i + 2), 16);
if (Number.isNaN(ord)) {
token += seq[i];
} else {
i++;
token += String.fromCharCode(ord);
}
continue;
}
if (key === null && ch === "=") {
key = token;
token = "";
continue;
}
if (ch === "," || ch === ";" || ch === "+") {
if (key !== null) {
result.set(key, token);
}
key = null;
token = "";
continue;
}
i++;
token += String.fromCharCode(ord);
}
if (ch === " " && !quoted) {
if (token.length === 0) {
continue;
}
if (i > nextNonSpace) {
let j = i;
while (seq[j] === " ") {
j++;
}
nextNonSpace = j;
}
if (nextNonSpace >= seq.length || seq[nextNonSpace] === "," || seq[nextNonSpace] === ";" || key === null && seq[nextNonSpace] === "=" || key !== null && seq[nextNonSpace] === "+") {
i = nextNonSpace - 1;
continue;
}
continue;
}
if (key === null && ch === "=") {
key = token;
token = "";
continue;
}
if (ch === "," || ch === ";" || ch === "+") {
if (key !== null) {
result.set(key, token);
}
token += ch;
key = null;
token = "";
continue;
}
}
return result;
}
if (ch === " " && !quoted) {
if (token.length === 0) {
continue;
}
if (i > nextNonSpace) {
let j = i;
while (seq[j] === " ") {
j++;
}
nextNonSpace = j;
}
if (nextNonSpace >= seq.length || seq[nextNonSpace] === "," || seq[nextNonSpace] === ";" || key === null && seq[nextNonSpace] === "=" || key !== null && seq[nextNonSpace] === "+") {
i = nextNonSpace - 1;
continue;
}
}
token += ch;
}
return result;
}
//# sourceMappingURL=rfc2253Parser.js.map

@@ -1,2 +0,2 @@

//# sourceMappingURL=updateInfo.js.map
"use strict";
"use strict";
//# sourceMappingURL=updateInfo.js.map
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
value: true
});
exports.nil = exports.UUID = undefined;
exports.nil = exports.UUID = void 0;
var _crypto;
function _crypto() {
const data = require("crypto");
function _load_crypto() {
return _crypto = require("crypto");
_crypto = function () {
return data;
};
return data;
}
var _index;
function _index() {
const data = require("./index");
function _load_index() {
return _index = require("./index");
_index = function () {
return data;
};
return data;
}
const invalidName = "options.name must be either a string or a Buffer";
const moreThan10000 = "can not generate more than 10000 UUIDs per second";
// Node ID according to rfc4122#section-4.5
const randomHost = (0, (_crypto || _load_crypto()).randomBytes)(16);
randomHost[0] = randomHost[0] | 0x01;
// randomize clockSeq initially, as per rfc4122#section-4.1.5
const seed = (0, (_crypto || _load_crypto()).randomBytes)(2);
let clockSeq = (seed[0] | seed[1] << 8) & 0x3fff;
// clock values
const moreThan10000 = "can not generate more than 10000 UUIDs per second"; // Node ID according to rfc4122#section-4.5
const randomHost = (0, _crypto().randomBytes)(16);
randomHost[0] = randomHost[0] | 0x01; // randomize clockSeq initially, as per rfc4122#section-4.1.5
const seed = (0, _crypto().randomBytes)(2);
let clockSeq = (seed[0] | seed[1] << 8) & 0x3fff; // clock values
let lastMTime = 0;
let lastNTime = 0;
// lookup table hex to byte
const hex2byte = {};
// lookup table byte to hex
const byte2hex = [];
// populate lookup tables
let lastNTime = 0; // lookup table hex to byte
const hex2byte = {}; // lookup table byte to hex
const byte2hex = []; // populate lookup tables
for (let i = 0; i < 256; i++) {
const hex = (i + 0x100).toString(16).substr(1);
hex2byte[hex] = i;
byte2hex[i] = hex;
}
// UUID class
const hex = (i + 0x100).toString(16).substr(1);
hex2byte[hex] = i;
byte2hex[i] = hex;
} // UUID class
class UUID {
constructor(uuid) {
this.ascii = null;
this.binary = null;
const check = UUID.check(uuid);
if (!check) {
throw new Error("not a UUID");
}
this.version = check.version;
if (check.format === "ascii") {
this.ascii = uuid;
} else {
this.binary = uuid;
}
constructor(uuid) {
this.ascii = null;
this.binary = null;
const check = UUID.check(uuid);
if (!check) {
throw new Error("not a UUID");
}
static v1() {
return uuidTimeBased(randomHost);
this.version = check.version;
if (check.format === "ascii") {
this.ascii = uuid;
} else {
this.binary = uuid;
}
static v5(name, namespace) {
return uuidNamed(name, "sha1", 0x50, namespace);
}
static v1() {
return uuidTimeBased(randomHost);
}
static v5(name, namespace) {
return uuidNamed(name, "sha1", 0x50, namespace);
}
toString() {
if (this.ascii == null) {
this.ascii = stringify(this.binary);
}
toString() {
if (this.ascii == null) {
this.ascii = stringify(this.binary);
}
return this.ascii;
return this.ascii;
}
toBuffer() {
if (this.binary == null) {
this.binary = UUID.parse(this.ascii);
}
toBuffer() {
if (this.binary == null) {
this.binary = UUID.parse(this.ascii);
}
return Buffer.from(this.binary);
return Buffer.from(this.binary);
}
inspect() {
return `UUID v${this.version} ${this.toString()}`;
}
static check(uuid, offset = 0) {
if (typeof uuid === "string") {
uuid = uuid.toLowerCase();
if (!/^[a-f0-9]{8}(\-[a-f0-9]{4}){3}\-([a-f0-9]{12})$/.test(uuid)) {
return false;
}
if (uuid === "00000000-0000-0000-0000-000000000000") {
return {
version: undefined,
variant: "nil",
format: "ascii"
};
}
return {
version: (hex2byte[uuid[14] + uuid[15]] & 0xf0) >> 4,
variant: getVariant((hex2byte[uuid[19] + uuid[20]] & 0xe0) >> 5),
format: "ascii"
};
}
inspect() {
return `UUID v${this.version} ${this.toString()}`;
}
static check(uuid, offset = 0) {
if (typeof uuid === "string") {
uuid = uuid.toLowerCase();
if (!/^[a-f0-9]{8}(\-[a-f0-9]{4}){3}\-([a-f0-9]{12})$/.test(uuid)) {
return false;
}
if (uuid === "00000000-0000-0000-0000-000000000000") {
return { version: undefined, variant: "nil", format: "ascii" };
}
return {
version: (hex2byte[uuid[14] + uuid[15]] & 0xf0) >> 4,
variant: getVariant((hex2byte[uuid[19] + uuid[20]] & 0xe0) >> 5),
format: "ascii"
};
if (Buffer.isBuffer(uuid)) {
if (uuid.length < offset + 16) {
return false;
}
let i = 0;
for (; i < 16; i++) {
if (uuid[offset + i] !== 0) {
break;
}
if (Buffer.isBuffer(uuid)) {
if (uuid.length < offset + 16) {
return false;
}
let i = 0;
for (; i < 16; i++) {
if (uuid[offset + i] !== 0) {
break;
}
}
if (i === 16) {
return { version: undefined, variant: "nil", format: "binary" };
}
return {
version: (uuid[offset + 6] & 0xf0) >> 4,
variant: getVariant((uuid[offset + 8] & 0xe0) >> 5),
format: "binary"
};
}
throw (0, (_index || _load_index()).newError)("Unknown type of uuid", "ERR_UNKNOWN_UUID_TYPE");
}
if (i === 16) {
return {
version: undefined,
variant: "nil",
format: "binary"
};
}
return {
version: (uuid[offset + 6] & 0xf0) >> 4,
variant: getVariant((uuid[offset + 8] & 0xe0) >> 5),
format: "binary"
};
}
// read stringified uuid into a Buffer
static parse(input) {
const buffer = Buffer.allocUnsafe(16);
let j = 0;
for (let i = 0; i < 16; i++) {
buffer[i] = hex2byte[input[j++] + input[j++]];
if (i === 3 || i === 5 || i === 7 || i === 9) {
j += 1;
}
}
return buffer;
throw (0, _index().newError)("Unknown type of uuid", "ERR_UNKNOWN_UUID_TYPE");
} // read stringified uuid into a Buffer
static parse(input) {
const buffer = Buffer.allocUnsafe(16);
let j = 0;
for (let i = 0; i < 16; i++) {
buffer[i] = hex2byte[input[j++] + input[j++]];
if (i === 3 || i === 5 || i === 7 || i === 9) {
j += 1;
}
}
}
exports.UUID = UUID; // from rfc4122#appendix-C
return buffer;
}
} // from rfc4122#appendix-C
exports.UUID = UUID;
UUID.URL = new UUID("6ba7b811-9dad-11d1-80b4-00c04fd430c8");
UUID.OID = UUID.parse("6ba7b812-9dad-11d1-80b4-00c04fd430c8");
// according to rfc4122#section-4.1.1
UUID.OID = UUID.parse("6ba7b812-9dad-11d1-80b4-00c04fd430c8"); // according to rfc4122#section-4.1.1
function getVariant(bits) {
switch (bits) {
case 0:
case 1:
case 3:
return "ncs";
case 4:
case 5:
return "rfc4122";
case 6:
return "microsoft";
default:
return "future";
}
switch (bits) {
case 0:
case 1:
case 3:
return "ncs";
case 4:
case 5:
return "rfc4122";
case 6:
return "microsoft";
default:
return "future";
}
}
var UuidEncoding;
(function (UuidEncoding) {
UuidEncoding[UuidEncoding["ASCII"] = 0] = "ASCII";
UuidEncoding[UuidEncoding["BINARY"] = 1] = "BINARY";
UuidEncoding[UuidEncoding["OBJECT"] = 2] = "OBJECT";
})(UuidEncoding || (UuidEncoding = {}));
// v1
UuidEncoding[UuidEncoding["ASCII"] = 0] = "ASCII";
UuidEncoding[UuidEncoding["BINARY"] = 1] = "BINARY";
UuidEncoding[UuidEncoding["OBJECT"] = 2] = "OBJECT";
})(UuidEncoding || (UuidEncoding = {})); // v1
function uuidTimeBased(nodeId, encoding = UuidEncoding.ASCII) {
let mTime = Date.now();
let nTime = lastNTime + 1;
const delta = mTime - lastMTime + (nTime - lastNTime) / 10000;
if (delta < 0) {
clockSeq = clockSeq + 1 & 0x3fff;
nTime = 0;
} else if (mTime > lastMTime) {
nTime = 0;
} else if (nTime >= 10000) {
return moreThan10000;
}
lastMTime = mTime;
lastNTime = nTime;
// unix timestamp to gregorian epoch as per rfc4122#section-4.5
mTime += 12219292800000;
const buffer = Buffer.allocUnsafe(16);
const myClockSeq = clockSeq;
const timeLow = ((mTime & 0xfffffff) * 10000 + nTime) % 0x100000000;
const timeHigh = mTime / 0x100000000 * 10000 & 0xfffffff;
buffer[0] = timeLow >>> 24 & 0xff;
buffer[1] = timeLow >>> 16 & 0xff;
buffer[2] = timeLow >>> 8 & 0xff;
buffer[3] = timeLow & 0xff;
buffer[4] = timeHigh >>> 8 & 0xff;
buffer[5] = timeHigh & 0xff;
buffer[6] = timeHigh >>> 24 & 0x0f | 0x10;
buffer[7] = timeHigh >>> 16 & 0x3f | 0x80;
buffer[8] = myClockSeq >>> 8;
buffer[9] = myClockSeq & 0xff;
let result;
switch (encoding) {
case UuidEncoding.BINARY:
buffer[10] = nodeId[0];
buffer[11] = nodeId[1];
buffer[12] = nodeId[2];
buffer[13] = nodeId[3];
buffer[14] = nodeId[4];
buffer[15] = nodeId[5];
result = buffer;
break;
case UuidEncoding.OBJECT:
buffer[10] = nodeId[0];
buffer[11] = nodeId[1];
buffer[12] = nodeId[2];
buffer[13] = nodeId[3];
buffer[14] = nodeId[4];
buffer[15] = nodeId[5];
result = new UUID(buffer);
break;
default:
result = byte2hex[buffer[0]] + byte2hex[buffer[1]] + byte2hex[buffer[2]] + byte2hex[buffer[3]] + "-" + byte2hex[buffer[4]] + byte2hex[buffer[5]] + "-" + byte2hex[buffer[6]] + byte2hex[buffer[7]] + "-" + byte2hex[buffer[8]] + byte2hex[buffer[9]] + "-" + byte2hex[nodeId[0]] + byte2hex[nodeId[1]] + byte2hex[nodeId[2]] + byte2hex[nodeId[3]] + byte2hex[nodeId[4]] + byte2hex[nodeId[5]];
break;
}
return result;
}
// v3 + v5
let mTime = Date.now();
let nTime = lastNTime + 1;
const delta = mTime - lastMTime + (nTime - lastNTime) / 10000;
if (delta < 0) {
clockSeq = clockSeq + 1 & 0x3fff;
nTime = 0;
} else if (mTime > lastMTime) {
nTime = 0;
} else if (nTime >= 10000) {
return moreThan10000;
}
lastMTime = mTime;
lastNTime = nTime; // unix timestamp to gregorian epoch as per rfc4122#section-4.5
mTime += 12219292800000;
const buffer = Buffer.allocUnsafe(16);
const myClockSeq = clockSeq;
const timeLow = ((mTime & 0xfffffff) * 10000 + nTime) % 0x100000000;
const timeHigh = mTime / 0x100000000 * 10000 & 0xfffffff;
buffer[0] = timeLow >>> 24 & 0xff;
buffer[1] = timeLow >>> 16 & 0xff;
buffer[2] = timeLow >>> 8 & 0xff;
buffer[3] = timeLow & 0xff;
buffer[4] = timeHigh >>> 8 & 0xff;
buffer[5] = timeHigh & 0xff;
buffer[6] = timeHigh >>> 24 & 0x0f | 0x10;
buffer[7] = timeHigh >>> 16 & 0x3f | 0x80;
buffer[8] = myClockSeq >>> 8;
buffer[9] = myClockSeq & 0xff;
let result;
switch (encoding) {
case UuidEncoding.BINARY:
buffer[10] = nodeId[0];
buffer[11] = nodeId[1];
buffer[12] = nodeId[2];
buffer[13] = nodeId[3];
buffer[14] = nodeId[4];
buffer[15] = nodeId[5];
result = buffer;
break;
case UuidEncoding.OBJECT:
buffer[10] = nodeId[0];
buffer[11] = nodeId[1];
buffer[12] = nodeId[2];
buffer[13] = nodeId[3];
buffer[14] = nodeId[4];
buffer[15] = nodeId[5];
result = new UUID(buffer);
break;
default:
result = byte2hex[buffer[0]] + byte2hex[buffer[1]] + byte2hex[buffer[2]] + byte2hex[buffer[3]] + "-" + byte2hex[buffer[4]] + byte2hex[buffer[5]] + "-" + byte2hex[buffer[6]] + byte2hex[buffer[7]] + "-" + byte2hex[buffer[8]] + byte2hex[buffer[9]] + "-" + byte2hex[nodeId[0]] + byte2hex[nodeId[1]] + byte2hex[nodeId[2]] + byte2hex[nodeId[3]] + byte2hex[nodeId[4]] + byte2hex[nodeId[5]];
break;
}
return result;
} // v3 + v5
function uuidNamed(name, hashMethod, version, namespace, encoding = UuidEncoding.ASCII) {
const hash = (0, (_crypto || _load_crypto()).createHash)(hashMethod);
const nameIsNotAString = typeof name !== "string";
if (nameIsNotAString && !Buffer.isBuffer(name)) {
throw (0, (_index || _load_index()).newError)(invalidName, "ERR_INVALID_UUID_NAME");
}
hash.update(namespace);
hash.update(name, nameIsNotAString ? "latin1" : "utf8");
const buffer = hash.digest();
let result;
switch (encoding) {
case UuidEncoding.BINARY:
buffer[6] = buffer[6] & 0x0f | version;
buffer[8] = buffer[8] & 0x3f | 0x80;
result = buffer;
break;
case UuidEncoding.OBJECT:
buffer[6] = buffer[6] & 0x0f | version;
buffer[8] = buffer[8] & 0x3f | 0x80;
result = new UUID(buffer);
break;
default:
result = byte2hex[buffer[0]] + byte2hex[buffer[1]] + byte2hex[buffer[2]] + byte2hex[buffer[3]] + "-" + byte2hex[buffer[4]] + byte2hex[buffer[5]] + "-" + byte2hex[buffer[6] & 0x0f | version] + byte2hex[buffer[7]] + "-" + byte2hex[buffer[8] & 0x3f | 0x80] + byte2hex[buffer[9]] + "-" + byte2hex[buffer[10]] + byte2hex[buffer[11]] + byte2hex[buffer[12]] + byte2hex[buffer[13]] + byte2hex[buffer[14]] + byte2hex[buffer[15]];
break;
}
return result;
const hash = (0, _crypto().createHash)(hashMethod);
const nameIsNotAString = typeof name !== "string";
if (nameIsNotAString && !Buffer.isBuffer(name)) {
throw (0, _index().newError)(invalidName, "ERR_INVALID_UUID_NAME");
}
hash.update(namespace);
hash.update(name, nameIsNotAString ? "latin1" : "utf8");
const buffer = hash.digest();
let result;
switch (encoding) {
case UuidEncoding.BINARY:
buffer[6] = buffer[6] & 0x0f | version;
buffer[8] = buffer[8] & 0x3f | 0x80;
result = buffer;
break;
case UuidEncoding.OBJECT:
buffer[6] = buffer[6] & 0x0f | version;
buffer[8] = buffer[8] & 0x3f | 0x80;
result = new UUID(buffer);
break;
default:
result = byte2hex[buffer[0]] + byte2hex[buffer[1]] + byte2hex[buffer[2]] + byte2hex[buffer[3]] + "-" + byte2hex[buffer[4]] + byte2hex[buffer[5]] + "-" + byte2hex[buffer[6] & 0x0f | version] + byte2hex[buffer[7]] + "-" + byte2hex[buffer[8] & 0x3f | 0x80] + byte2hex[buffer[9]] + "-" + byte2hex[buffer[10]] + byte2hex[buffer[11]] + byte2hex[buffer[12]] + byte2hex[buffer[13]] + byte2hex[buffer[14]] + byte2hex[buffer[15]];
break;
}
return result;
}
function stringify(buffer) {
return byte2hex[buffer[0]] + byte2hex[buffer[1]] + byte2hex[buffer[2]] + byte2hex[buffer[3]] + "-" + byte2hex[buffer[4]] + byte2hex[buffer[5]] + "-" + byte2hex[buffer[6]] + byte2hex[buffer[7]] + "-" + byte2hex[buffer[8]] + byte2hex[buffer[9]] + "-" + byte2hex[buffer[10]] + byte2hex[buffer[11]] + byte2hex[buffer[12]] + byte2hex[buffer[13]] + byte2hex[buffer[14]] + byte2hex[buffer[15]];
}
// according to rfc4122#section-4.1.7
const nil = exports.nil = new UUID("00000000-0000-0000-0000-000000000000");
// UUID.v4 = uuidRandom
return byte2hex[buffer[0]] + byte2hex[buffer[1]] + byte2hex[buffer[2]] + byte2hex[buffer[3]] + "-" + byte2hex[buffer[4]] + byte2hex[buffer[5]] + "-" + byte2hex[buffer[6]] + byte2hex[buffer[7]] + "-" + byte2hex[buffer[8]] + byte2hex[buffer[9]] + "-" + byte2hex[buffer[10]] + byte2hex[buffer[11]] + byte2hex[buffer[12]] + byte2hex[buffer[13]] + byte2hex[buffer[14]] + byte2hex[buffer[15]];
} // according to rfc4122#section-4.1.7
const nil = new UUID("00000000-0000-0000-0000-000000000000"); // UUID.v4 = uuidRandom
// UUID.v4fast = uuidRandomFast

@@ -248,2 +311,3 @@ // UUID.v3 = function(options, callback) {

// }
exports.nil = nil;
//# sourceMappingURL=uuid.js.map
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
value: true
});
exports.XElement = undefined;
exports.parseXml = parseXml;
exports.XElement = void 0;
var _sax;
function sax() {
const data = _interopRequireWildcard(require("sax"));
function _load_sax() {
return _sax = _interopRequireWildcard(require("sax"));
sax = function () {
return data;
};
return data;
}
var _index;
function _index() {
const data = require("./index");
function _load_index() {
return _index = require("./index");
_index = function () {
return data;
};
return data;
}
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
class XElement {
constructor(name) {
this.name = name;
this.value = "";
this.attributes = null;
this.isCData = false;
this.elements = null;
if (!name) {
throw (0, (_index || _load_index()).newError)("Element name cannot be empty", "ERR_XML_ELEMENT_NAME_EMPTY");
}
if (!isValidName(name)) {
throw (0, (_index || _load_index()).newError)(`Invalid element name: ${name}`, "ERR_XML_ELEMENT_INVALID_NAME");
}
constructor(name) {
this.name = name;
this.value = "";
this.attributes = null;
this.isCData = false;
this.elements = null;
if (!name) {
throw (0, _index().newError)("Element name cannot be empty", "ERR_XML_ELEMENT_NAME_EMPTY");
}
attribute(name) {
const result = this.attributes === null ? null : this.attributes[name];
if (result == null) {
throw (0, (_index || _load_index()).newError)(`No attribute "${name}"`, "ERR_XML_MISSED_ATTRIBUTE");
}
return result;
if (!isValidName(name)) {
throw (0, _index().newError)(`Invalid element name: ${name}`, "ERR_XML_ELEMENT_INVALID_NAME");
}
removeAttribute(name) {
if (this.attributes !== null) {
delete this.attributes[name];
}
}
attribute(name) {
const result = this.attributes === null ? null : this.attributes[name];
if (result == null) {
throw (0, _index().newError)(`No attribute "${name}"`, "ERR_XML_MISSED_ATTRIBUTE");
}
element(name, ignoreCase = false, errorIfMissed = null) {
const result = this.elementOrNull(name, ignoreCase);
if (result === null) {
throw (0, (_index || _load_index()).newError)(errorIfMissed || `No element "${name}"`, "ERR_XML_MISSED_ELEMENT");
}
return result;
return result;
}
removeAttribute(name) {
if (this.attributes !== null) {
delete this.attributes[name];
}
elementOrNull(name, ignoreCase = false) {
if (this.elements === null) {
return null;
}
for (const element of this.elements) {
if (isNameEquals(element, name, ignoreCase)) {
return element;
}
}
return null;
}
element(name, ignoreCase = false, errorIfMissed = null) {
const result = this.elementOrNull(name, ignoreCase);
if (result === null) {
throw (0, _index().newError)(errorIfMissed || `No element "${name}"`, "ERR_XML_MISSED_ELEMENT");
}
getElements(name, ignoreCase = false) {
if (this.elements === null) {
return [];
}
return this.elements.filter(it => isNameEquals(it, name, ignoreCase));
return result;
}
elementOrNull(name, ignoreCase = false) {
if (this.elements === null) {
return null;
}
elementValueOrEmpty(name, ignoreCase = false) {
const element = this.elementOrNull(name, ignoreCase);
return element === null ? "" : element.value;
for (const element of this.elements) {
if (isNameEquals(element, name, ignoreCase)) {
return element;
}
}
return null;
}
getElements(name, ignoreCase = false) {
if (this.elements === null) {
return [];
}
return this.elements.filter(it => isNameEquals(it, name, ignoreCase));
}
elementValueOrEmpty(name, ignoreCase = false) {
const element = this.elementOrNull(name, ignoreCase);
return element === null ? "" : element.value;
}
}
exports.XElement = XElement;
const NAME_REG_EXP = new RegExp(/^[A-Za-z_][:A-Za-z0-9_-]*$/i);
function isValidName(name) {
return NAME_REG_EXP.test(name);
return NAME_REG_EXP.test(name);
}
function isNameEquals(element, name, ignoreCase) {
const elementName = element.name;
return elementName === name || ignoreCase === true && elementName.length === name.length && elementName.toLowerCase() === name.toLowerCase();
const elementName = element.name;
return elementName === name || ignoreCase === true && elementName.length === name.length && elementName.toLowerCase() === name.toLowerCase();
}
function parseXml(data) {
let rootElement = null;
const parser = (_sax || _load_sax()).parser(true, {});
const elements = [];
parser.onopentag = saxElement => {
const element = new XElement(saxElement.name);
element.attributes = saxElement.attributes;
if (rootElement === null) {
rootElement = element;
} else {
const parent = elements[elements.length - 1];
if (parent.elements == null) {
parent.elements = [];
}
parent.elements.push(element);
}
elements.push(element);
};
parser.onclosetag = () => {
elements.pop();
};
parser.ontext = text => {
if (elements.length > 0) {
elements[elements.length - 1].value = text;
}
};
parser.oncdata = cdata => {
const element = elements[elements.length - 1];
element.value = cdata;
element.isCData = true;
};
parser.onerror = err => {
throw err;
};
parser.write(data);
return rootElement;
}
let rootElement = null;
const parser = sax().parser(true, {});
const elements = [];
parser.onopentag = saxElement => {
const element = new XElement(saxElement.name);
element.attributes = saxElement.attributes;
if (rootElement === null) {
rootElement = element;
} else {
const parent = elements[elements.length - 1];
if (parent.elements == null) {
parent.elements = [];
}
parent.elements.push(element);
}
elements.push(element);
};
parser.onclosetag = () => {
elements.pop();
};
parser.ontext = text => {
if (elements.length > 0) {
elements[elements.length - 1].value = text;
}
};
parser.oncdata = cdata => {
const element = elements[elements.length - 1];
element.value = cdata;
element.isCData = true;
};
parser.onerror = err => {
throw err;
};
parser.write(data);
return rootElement;
}
//# sourceMappingURL=xml.js.map
{
"name": "builder-util-runtime",
"version": "4.0.5",
"version": "4.1.0",
"main": "out/index.js",

@@ -18,3 +18,3 @@ "author": "Vladimir Krivosheev",

"debug": "^3.1.0",
"fs-extra-p": "^4.5.0",
"fs-extra-p": "^4.5.2",
"bluebird-lst": "^1.0.5",

@@ -21,0 +21,0 @@ "sax": "^1.2.4"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc