New:Socket for Asana Is Now Available.Learn more
Get Started

builder-util-runtime

Package Overview
Dependencies
Maintainers
2
Versions
123
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
9.7.0
to
10.0.0-alpha.0
+13
dist/blockMapApi.d.ts
export interface FileChunks {
checksums: Array<string>;
sizes: Array<number>;
}
export interface BlockMap {
version: "1" | "2";
files: Array<BlockMapFile>;
}
export interface BlockMapFile extends FileChunks {
name: string;
offset: number;
}
//# sourceMappingURL=blockMapApi.d.ts.map
{"version":3,"file":"blockMapApi.d.ts","sourceRoot":"","sources":["../src/blockMapApi.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IACxB,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;CACrB;AAED,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,GAAG,GAAG,GAAG,CAAA;IAClB,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC,CAAA;CAC3B;AAED,MAAM,WAAW,YAAa,SAAQ,UAAU;IAC9C,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;CACf"}
export {};
//# sourceMappingURL=blockMapApi.js.map
{"version":3,"file":"blockMapApi.js","sourceRoot":"","sources":["../src/blockMapApi.ts"],"names":[],"mappings":"","sourcesContent":["export interface FileChunks {\n checksums: Array<string>\n sizes: Array<number>\n}\n\nexport interface BlockMap {\n version: \"1\" | \"2\"\n files: Array<BlockMapFile>\n}\n\nexport interface BlockMapFile extends FileChunks {\n name: string\n offset: number\n}\n"]}
import { EventEmitter } from "events";
export declare class CancellationToken extends EventEmitter {
private parentCancelHandler;
private _cancelled;
get cancelled(): boolean;
private _parent;
set parent(value: CancellationToken);
constructor(parent?: CancellationToken);
cancel(): void;
private onCancel;
createPromise<R>(callback: (resolve: (thenableOrResult: R | PromiseLike<R>) => void, reject: (error: Error) => void, onCancel: (callback: () => void) => void) => void): Promise<R>;
private removeParentCancelHandler;
dispose(): void;
}
export declare class CancellationError extends Error {
constructor();
}
//# sourceMappingURL=CancellationToken.d.ts.map
{"version":3,"file":"CancellationToken.d.ts","sourceRoot":"","sources":["../src/CancellationToken.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAErC,qBAAa,iBAAkB,SAAQ,YAAY;IACjD,OAAO,CAAC,mBAAmB,CAA2B;IAEtD,OAAO,CAAC,UAAU,CAAS;IAC3B,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,OAAO,CAAC,OAAO,CAAiC;IAChD,IAAI,MAAM,CAAC,KAAK,EAAE,iBAAiB,EAMlC;gBAGW,MAAM,CAAC,EAAE,iBAAiB;IAStC,MAAM;IAKN,OAAO,CAAC,QAAQ;IAQhB,aAAa,CAAC,CAAC,EACb,QAAQ,EAAE,CAAC,OAAO,EAAE,CAAC,gBAAgB,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,MAAM,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,EAAE,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,IAAI,KAAK,IAAI,GACpJ,OAAO,CAAC,CAAC,CAAC;IAoDb,OAAO,CAAC,yBAAyB;IAQjC,OAAO;CAQR;AAED,qBAAa,iBAAkB,SAAQ,KAAK;;CAI3C"}
import { EventEmitter } from "events";
export class CancellationToken extends EventEmitter {
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);
}
// 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;
}
}
cancel() {
this._cancelled = true;
this.emit("cancel");
}
onCancel(handler) {
if (this.cancelled) {
handler();
}
else {
this.once("cancel", handler);
}
}
createPromise(callback) {
if (this.cancelled) {
return Promise.reject(new CancellationError());
}
const finallyHandler = () => {
if (cancelHandler != null) {
try {
this.removeListener("cancel", cancelHandler);
cancelHandler = null;
}
catch (_ignore) {
// ignore
}
}
};
let cancelHandler = null;
return new Promise((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;
});
})
.then(it => {
finallyHandler();
return it;
})
.catch((e) => {
finallyHandler();
throw e;
});
}
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;
}
}
}
export class CancellationError extends Error {
constructor() {
super("cancelled");
}
}
//# sourceMappingURL=CancellationToken.js.map
{"version":3,"file":"CancellationToken.js","sourceRoot":"","sources":["../src/CancellationToken.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAErC,MAAM,OAAO,iBAAkB,SAAQ,YAAY;IAIjD,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,UAAU,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;IAC5E,CAAC;IAGD,IAAI,MAAM,CAAC,KAAwB;QACjC,IAAI,CAAC,yBAAyB,EAAE,CAAA;QAEhC,IAAI,CAAC,OAAO,GAAG,KAAK,CAAA;QACpB,IAAI,CAAC,mBAAmB,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAA;QAC9C,IAA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,OAAO,GAAG,IAAI,CAAA;QACrB,CAAC;IACH,CAAC;CACF;AAED,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAC1C;QACE,KAAK,CAAC,WAAW,CAAC,CAAA;IACpB,CAAC;CACF","sourcesContent":["import { EventEmitter } from \"events\"\n\nexport class CancellationToken extends EventEmitter {\n private parentCancelHandler: (() => any) | null = null\n\n private _cancelled: boolean\n get cancelled(): boolean {\n return this._cancelled || (this._parent != null && this._parent.cancelled)\n }\n\n private _parent: CancellationToken | null = null\n set parent(value: CancellationToken) {\n this.removeParentCancelHandler()\n\n this._parent = value\n this.parentCancelHandler = () => this.cancel()\n this._parent.onCancel(this.parentCancelHandler)\n }\n\n // babel cannot compile ... correctly for super calls\n constructor(parent?: CancellationToken) {\n super()\n\n this._cancelled = false\n if (parent != null) {\n this.parent = parent\n }\n }\n\n cancel() {\n this._cancelled = true\n this.emit(\"cancel\")\n }\n\n private onCancel(handler: () => any) {\n if (this.cancelled) {\n handler()\n } else {\n this.once(\"cancel\", handler)\n }\n }\n\n createPromise<R>(\n callback: (resolve: (thenableOrResult: R | PromiseLike<R>) => void, reject: (error: Error) => void, onCancel: (callback: () => void) => void) => void\n ): Promise<R> {\n if (this.cancelled) {\n return Promise.reject<R>(new CancellationError())\n }\n\n const finallyHandler = () => {\n if (cancelHandler != null) {\n try {\n this.removeListener(\"cancel\", cancelHandler)\n cancelHandler = null\n } catch (_ignore) {\n // ignore\n }\n }\n }\n\n let cancelHandler: (() => void) | null = null\n return new Promise<R>((resolve, reject) => {\n let addedCancelHandler: (() => void) | null = null\n\n cancelHandler = () => {\n try {\n if (addedCancelHandler != null) {\n addedCancelHandler()\n addedCancelHandler = null\n }\n } finally {\n reject(new CancellationError())\n }\n }\n\n if (this.cancelled) {\n cancelHandler()\n return\n }\n\n this.onCancel(cancelHandler)\n\n callback(resolve, reject, (callback: () => void) => {\n addedCancelHandler = callback\n })\n })\n .then(it => {\n finallyHandler()\n return it\n })\n .catch((e: any) => {\n finallyHandler()\n throw e\n })\n }\n\n private removeParentCancelHandler() {\n const parent = this._parent\n if (parent != null && this.parentCancelHandler != null) {\n parent.removeListener(\"cancel\", this.parentCancelHandler)\n this.parentCancelHandler = null\n }\n }\n\n dispose() {\n try {\n this.removeParentCancelHandler()\n } finally {\n this.removeAllListeners()\n this._parent = null\n }\n }\n}\n\nexport class CancellationError extends Error {\n constructor() {\n super(\"cancelled\")\n }\n}\n"]}
export declare function newError(message: string, code: string): Error;
//# sourceMappingURL=error.d.ts.map
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,SAIrD"}
export function newError(message, code) {
const error = new Error(message);
error.code = code;
return error;
}
//# sourceMappingURL=error.js.map
{"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,QAAQ,CAAC,OAAe,EAAE,IAAY;IACpD,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,CAC/B;IAAC,KAA+B,CAAC,IAAI,GAAG,IAAI,CAAA;IAC7C,OAAO,KAAK,CAAA;AACd,CAAC","sourcesContent":["export function newError(message: string, code: string) {\n const error = new Error(message)\n ;(error as NodeJS.ErrnoException).code = code\n return error\n}\n"]}
import { BinaryToTextEncoding } from "crypto";
import { IncomingMessage, OutgoingHttpHeader, OutgoingHttpHeaders, RequestOptions } from "http";
import { Transform } from "stream";
import { URL } from "url";
import { CancellationToken } from "./CancellationToken.js";
import { ProgressInfo } from "./ProgressCallbackTransform.js";
/**
* Register an additional HTTP header to strip on cross-origin redirects.
* Intended for custom publishers (e.g. GenericPublisher with a non-standard auth header).
*/
export declare function addSensitiveRedirectHeader(header: string): void;
/**
* Register an additional substring pattern used by {@link safeStringifyJson} to
* identify sensitive field names. Input is normalized (lowercased, separators stripped).
* Intended for custom publishers that store credentials under non-standard field names.
*/
export declare function addSensitiveFieldPattern(pattern: string): void;
export interface RequestHeaders extends OutgoingHttpHeaders {
[key: string]: OutgoingHttpHeader | undefined;
}
export interface DownloadOptions {
readonly headers?: OutgoingHttpHeaders | null;
readonly sha2?: string | null;
readonly sha512?: string | null;
readonly cancellationToken: CancellationToken;
onProgress?: (progress: ProgressInfo) => void;
}
export declare function createHttpError(response: IncomingMessage, description?: any | null): HttpError;
export declare class HttpError extends Error {
readonly statusCode: number;
readonly description: any | null;
constructor(statusCode: number, message?: string, description?: any | null);
isServerError(): boolean;
}
export declare function parseJson(result: Promise<string | null>): Promise<any>;
interface Request {
abort: () => void;
end: (data?: Buffer) => void;
}
export declare abstract class HttpExecutor<T extends Request> {
protected readonly maxRedirects = 10;
request(options: RequestOptions, cancellationToken?: CancellationToken, data?: {
[name: string]: any;
} | null): Promise<string | null>;
doApiRequest(options: RequestOptions, cancellationToken: CancellationToken, requestProcessor: (request: T, reject: (error: Error) => void) => void, redirectCount?: number): Promise<string>;
protected addRedirectHandlers(request: any, options: RequestOptions, reject: (error: Error) => void, redirectCount: number, handler: (options: RequestOptions) => void): void;
addErrorAndTimeoutHandlers(request: any, reject: (error: Error) => void, timeout?: number): void;
private handleResponse;
abstract createRequest(options: RequestOptions, callback: (response: any) => void): T;
downloadToBuffer(url: URL, options: DownloadOptions): Promise<Buffer>;
protected doDownload(requestOptions: RequestOptions, options: DownloadCallOptions, redirectCount: number): void;
protected createMaxRedirectError(): Error;
private addTimeOutHandler;
static prepareRedirectUrlOptions(redirectUrl: string, options: RequestOptions): RequestOptions;
private static reconstructOriginalUrl;
private static isCrossOriginRedirect;
static retryOnServerError(task: () => Promise<any>, maxRetries?: number): Promise<any>;
}
export interface DownloadCallOptions {
responseHandler: ((response: IncomingMessage, callback: (error: Error | null) => void) => void) | null;
onCancel: (callback: () => void) => void;
callback: (error: Error | null) => void;
options: DownloadOptions;
destination: string | null;
}
export declare function configureRequestOptionsFromUrl(url: string, options: RequestOptions): RequestOptions;
export declare function configureRequestUrl(url: URL, options: RequestOptions): void;
export declare class DigestTransform extends Transform {
readonly expected: string;
private readonly algorithm;
private readonly encoding;
private readonly digester;
private _actual;
get actual(): string | null;
isValidateOnEnd: boolean;
constructor(expected: string, algorithm?: string, encoding?: BinaryToTextEncoding);
_transform(chunk: Buffer, encoding: string, callback: any): void;
_flush(callback: any): void;
validate(): null;
}
export declare function safeGetHeader(response: any, headerKey: string): any;
export declare function configureRequestOptions(options: RequestOptions, token?: string | null, method?: "GET" | "DELETE" | "PUT" | "POST"): RequestOptions;
export declare function isSensitiveFieldName(name: string): boolean;
export declare function hashSensitiveValue(value: string): string;
export declare function safeStringifyJson(data: any, skippedNames?: Set<string>): string;
export {};
//# sourceMappingURL=httpExecutor.d.ts.map
{"version":3,"file":"httpExecutor.d.ts","sourceRoot":"","sources":["../src/httpExecutor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAoB,MAAM,QAAQ,CAAA;AAI/D,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,MAAM,CAAA;AAE/F,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAClC,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAEzB,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAE1D,OAAO,EAA6B,YAAY,EAAE,MAAM,gCAAgC,CAAA;AAsBxF;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAE/D;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE9D;AAED,MAAM,WAAW,cAAe,SAAQ,mBAAmB;IACzD,CAAC,GAAG,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS,CAAA;CAC9C;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,IA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AED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAExD;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,GAAG,EAAE,YAAY,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,MAAM,CAW/E"}
import { createHash } from "crypto";
import { sleep } from "./retry.js";
import _debug from "debug";
import { createWriteStream } from "fs";
import { Transform } from "stream";
import { URL } from "url";
import { CancellationToken } from "./CancellationToken.js";
import { newError } from "./error.js";
import { ProgressCallbackTransform } from "./ProgressCallbackTransform.js";
const debug = _debug("electron-builder");
// ── Sensitive-data registries ────────────────────────────────────────────────
// Normalise a header or field name: lowercase + strip all separators (- and _).
// Shared by both registries so lookup is always separator-agnostic.
const normalizeName = (name) => name.toLowerCase().replace(/[-_]/g, "");
// HTTP header names (normalised) stripped on cross-origin redirects.
// Stored normalised; lookup normalises the incoming key with normalizeName().
const SENSITIVE_REDIRECT_HEADERS = new Set(["authorization", "proxyauthorization", "privatetoken", "xapikey", "xauthtoken", "xaccesstoken", "xgitlabtoken", "cookie", "xcsrftoken"]);
// Substrings: a field name containing any of these (after normalization) is redacted.
const SENSITIVE_FIELD_PATTERNS = ["token", "password", "secret", "authorization", "credential", "apikey", "passphrase", "auth"];
// Suffixes: a field name ending with any of these (after normalization) is redacted.
// Intentionally greedy — "publicKey" is also stripped; over-stripping debug logs is
// acceptable, under-stripping a credential is not.
const SENSITIVE_FIELD_SUFFIXES = ["key"];
/**
* Register an additional HTTP header to strip on cross-origin redirects.
* Intended for custom publishers (e.g. GenericPublisher with a non-standard auth header).
*/
export function addSensitiveRedirectHeader(header) {
SENSITIVE_REDIRECT_HEADERS.add(normalizeName(header));
}
/**
* Register an additional substring pattern used by {@link safeStringifyJson} to
* identify sensitive field names. Input is normalized (lowercased, separators stripped).
* Intended for custom publishers that store credentials under non-standard field names.
*/
export function addSensitiveFieldPattern(pattern) {
SENSITIVE_FIELD_PATTERNS.push(pattern.toLowerCase().replace(/[-_]/g, ""));
}
export 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);
}
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"],
]);
export 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";
this.code = `HTTP_ERROR_${statusCode}`;
}
isServerError() {
return this.statusCode >= 500 && this.statusCode <= 599;
}
}
export function parseJson(result) {
return result.then(it => (it == null || it.length === 0 ? null : JSON.parse(it)));
}
export class HttpExecutor {
constructor() {
this.maxRedirects = 10;
}
request(options, cancellationToken = new CancellationToken(), data) {
configureRequestOptions(options);
const json = data == null ? undefined : JSON.stringify(data);
const encodedData = json ? Buffer.from(json) : undefined;
if (encodedData != null) {
if (debug.enabled) {
debug(safeStringifyJson(data));
}
const { headers, ...opts } = options;
options = {
method: "post",
headers: {
"Content-Type": "application/json",
"Content-Length": encodedData.length,
...headers,
},
...opts,
};
}
return this.doApiRequest(options, cancellationToken, it => it.end(encodedData));
}
doApiRequest(options, cancellationToken, requestProcessor, redirectCount = 0) {
if (debug.enabled) {
const { headers: _headers, auth: _auth, ...safeOptions } = options;
debug(`Request: ${safeStringifyJson(safeOptions)}`);
}
return cancellationToken.createPromise((resolve, reject, onCancel) => {
const request = this.createRequest(options, (response) => {
try {
this.handleResponse(response, options, cancellationToken, resolve, reject, redirectCount, requestProcessor);
}
catch (e) {
reject(e);
}
});
this.addErrorAndTimeoutHandlers(request, reject, options.timeout);
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
// eslint-disable-next-line
addRedirectHandlers(request, options, reject, redirectCount, handler) {
// not required for NodeJS
}
addErrorAndTimeoutHandlers(request, reject, timeout = 60 * 1000) {
this.addTimeOutHandler(request, reject, timeout);
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) {
const { headers: _headers, auth: _auth, ...safeOptions } = options;
debug(`Response: ${response.statusCode} ${response.statusMessage}, request options: ${safeStringifyJson(safeOptions)}`);
}
// 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 || "GET"} url: ${options.protocol || "https:"}//${options.hostname}${options.port ? `:${options.port}` : ""}${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 code = response.statusCode ?? 0;
const shouldRedirect = code >= 300 && code < 400;
const redirectUrl = safeGetHeader(response, "location");
if (shouldRedirect && redirectUrl != null) {
if (redirectCount > this.maxRedirects) {
reject(this.createMaxRedirectError());
return;
}
this.doApiRequest(HttpExecutor.prepareRedirectUrlOptions(redirectUrl, options), cancellationToken, requestProcessor, redirectCount).then(resolve).catch(reject);
return;
}
response.setEncoding("utf8");
let data = "";
response.on("error", reject);
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, `method: ${options.method || "GET"} url: ${options.protocol || "https:"}//${options.hostname}${options.port ? `:${options.port}` : ""}${options.path}
Data:
${isJson ? safeStringifyJson(JSON.parse(data)) : data}
`));
}
else {
resolve(data.length === 0 ? null : data);
}
}
catch (e) {
reject(e);
}
});
}
async downloadToBuffer(url, options) {
return await options.cancellationToken.createPromise((resolve, reject, onCancel) => {
const responseChunks = [];
const requestOptions = {
headers: options.headers || undefined,
// because PrivateGitHubProvider requires HttpExecutor.prepareRedirectUrlOptions logic, so, we need to redirect manually
redirect: "manual",
};
configureRequestUrl(url, requestOptions);
configureRequestOptions(requestOptions);
this.doDownload(requestOptions, {
destination: null,
options,
onCancel,
callback: error => {
if (error == null) {
resolve(Buffer.concat(responseChunks));
}
else {
reject(error);
}
},
responseHandler: (response, callback) => {
let receivedLength = 0;
response.on("data", (chunk) => {
receivedLength += chunk.length;
if (receivedLength > 524288000) {
callback(new Error("Maximum allowed size is 500 MB"));
return;
}
responseChunks.push(chunk);
});
response.on("end", () => {
callback(null);
});
},
}, 0);
});
}
doDownload(requestOptions, options, redirectCount) {
const request = this.createRequest(requestOptions, (response) => {
if (response.statusCode >= 400) {
options.callback(new Error(`Cannot download "${requestOptions.protocol || "https:"}//${requestOptions.hostname}${requestOptions.path}", status ${response.statusCode}: ${response.statusMessage}`));
return;
}
// It is possible for the response stream to fail, e.g. when a network is lost while
// response stream is in progress. Stop waiting and reject so consumer can catch the error.
response.on("error", options.callback);
// this code not relevant for Electron (redirect event instead handled)
const redirectUrl = safeGetHeader(response, "location");
if (redirectUrl != null) {
if (redirectCount < this.maxRedirects) {
this.doDownload(HttpExecutor.prepareRedirectUrlOptions(redirectUrl, requestOptions), options, redirectCount++);
}
else {
options.callback(this.createMaxRedirectError());
}
return;
}
if (options.responseHandler == null) {
configurePipes(options, response);
}
else {
options.responseHandler(response, options.callback);
}
});
this.addErrorAndTimeoutHandlers(request, options.callback, requestOptions.timeout);
this.addRedirectHandlers(request, requestOptions, options.callback, redirectCount, requestOptions => {
this.doDownload(requestOptions, options, redirectCount++);
});
request.end();
}
createMaxRedirectError() {
return new Error(`Too many redirects (> ${this.maxRedirects})`);
}
addTimeOutHandler(request, callback, timeout) {
request.on("socket", (socket) => {
socket.setTimeout(timeout, () => {
request.abort();
callback(new Error("Request timed out"));
});
});
}
static prepareRedirectUrlOptions(redirectUrl, options) {
const newOptions = configureRequestOptionsFromUrl(redirectUrl, { ...options });
const headers = newOptions.headers;
if (headers == null) {
return newOptions;
}
const originalUrl = HttpExecutor.reconstructOriginalUrl(options);
const parsedRedirectUrl = parseUrl(redirectUrl, options);
if (HttpExecutor.isCrossOriginRedirect(originalUrl, parsedRedirectUrl)) {
if (debug.enabled) {
debug(`Cross-origin redirect (${originalUrl.host} → ${parsedRedirectUrl.host}): stripping sensitive headers`);
}
for (const key of Object.keys(headers)) {
if (SENSITIVE_REDIRECT_HEADERS.has(normalizeName(key))) {
delete headers[key];
}
}
}
return newOptions;
}
static reconstructOriginalUrl(options) {
const protocol = options.protocol || "https:";
if (!options.hostname) {
throw new Error("Missing hostname in request options");
}
const hostname = options.hostname;
const port = options.port ? `:${options.port}` : "";
const path = options.path || "/";
return new URL(`${protocol}//${hostname}${port}${path}`);
}
static isCrossOriginRedirect(originalUrl, redirectUrl) {
// Case-insensitive hostname comparison
if (originalUrl.hostname.toLowerCase() !== redirectUrl.hostname.toLowerCase()) {
return true;
}
// Special case: allow http -> https redirect on same host with standard ports
// This matches the behavior of Python requests library for backward compatibility
// url.port returns an empty string if the port is omitted
// or explicitly set to the default port for a given protocol.
if (originalUrl.protocol === "http:" &&
// This can be replaced with `!originalUrl.port`, but for the sake of clarity.
["80", ""].includes(originalUrl.port) &&
redirectUrl.protocol === "https:" &&
// This can be replaced with `!redirectUrl.port`, but for the sake of clarity.
["443", ""].includes(redirectUrl.port)) {
return false;
}
// According to RFC 7235, a change in protocol or port constitutes a cross-origin request.
// Forwarding authentication headers to a different origin can be a security risk.
// For example, https://example.com:443 and http://example.com:80 are different origins.
// We only make an exception for HTTP -> HTTPS upgrades on standard ports for backward compatibility.
// Strip auth on any other protocol change
if (originalUrl.protocol !== redirectUrl.protocol) {
return true;
}
// Strip auth on port change (accounting for default ports)
const originalPort = originalUrl.port;
const redirectPort = redirectUrl.port;
return originalPort !== redirectPort;
}
static async retryOnServerError(task, maxRetries = 3) {
for (let attemptNumber = 0;; attemptNumber++) {
try {
return await task();
}
catch (e) {
if (attemptNumber < maxRetries && ((e instanceof HttpError && e.isServerError()) || e.code === "EPIPE")) {
await sleep(1000 * (attemptNumber + 1));
continue;
}
throw e;
}
}
}
}
function parseUrl(url, options) {
try {
// Would throw exception if url is not absolute
return new URL(url);
}
catch {
// Relative URL - construct base URL from original options
const hostname = options.hostname;
const protocol = options.protocol || "https:";
const port = options.port ? `:${options.port}` : "";
const baseUrl = `${protocol}//${hostname}${port}`;
return new URL(url, baseUrl);
}
}
export function configureRequestOptionsFromUrl(url, options) {
const result = configureRequestOptions(options);
const parsedUrl = parseUrl(url, options);
configureRequestUrl(parsedUrl, result);
return result;
}
export function configureRequestUrl(url, options) {
options.protocol = url.protocol;
options.hostname = url.hostname;
if (url.port) {
options.port = url.port;
}
else if (options.port) {
delete options.port;
}
options.path = url.pathname + url.search;
}
export class DigestTransform extends Transform {
// noinspection JSUnusedGlobalSymbols
get actual() {
return this._actual;
}
constructor(expected, algorithm = "sha512", encoding = "base64") {
super();
this.expected = expected;
this.algorithm = algorithm;
this.encoding = encoding;
this._actual = null;
this.isValidateOnEnd = true;
this.digester = createHash(algorithm);
}
// 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;
}
}
callback(null);
}
validate() {
if (this._actual == null) {
throw newError("Not finished yet", "ERR_STREAM_NOT_FINISHED");
}
if (this._actual !== this.expected) {
throw newError(`${this.algorithm} checksum mismatch, expected ${this.expected}, got ${this._actual}`, "ERR_CHECKSUM_MISMATCH");
}
return null;
}
}
function checkSha2(sha2Header, sha2, callback) {
if (sha2Header != null && sha2 != null && sha2Header !== sha2) {
callback(new Error(`checksum mismatch: expected ${sha2} but got ${sha2Header} (X-Checksum-Sha2 header)`));
return false;
}
return true;
}
export 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;
}
}
function configurePipes(options, response) {
if (!checkSha2(safeGetHeader(response, "X-Checksum-Sha2"), options.options.sha2, options.callback)) {
return;
}
const streams = [];
if (options.options.onProgress != null) {
const contentLength = safeGetHeader(response, "content-length");
if (contentLength != null) {
streams.push(new ProgressCallbackTransform(parseInt(contentLength, 10), options.options.cancellationToken, options.options.onProgress));
}
}
const sha512 = options.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.options.sha2 != null) {
streams.push(new DigestTransform(options.options.sha2, "sha256", "hex"));
}
const fileOut = createWriteStream(options.destination);
streams.push(fileOut);
let lastStream = response;
for (const stream of streams) {
stream.on("error", (error) => {
fileOut.close();
if (!options.options.cancellationToken.cancelled) {
options.callback(error);
}
});
lastStream = lastStream.pipe(stream);
}
fileOut.on("finish", () => {
;
fileOut.close(options.callback);
});
}
export function configureRequestOptions(options, token, method) {
if (method != null) {
options.method = method;
}
options.headers = { ...options.headers };
const headers = options.headers;
if (token != null) {
;
headers.authorization = token.startsWith("Basic") || token.startsWith("Bearer") ? 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;
}
export function isSensitiveFieldName(name) {
const normalized = normalizeName(name);
return SENSITIVE_FIELD_PATTERNS.some(p => normalized.includes(p)) || SENSITIVE_FIELD_SUFFIXES.some(s => normalized.endsWith(s));
}
export function hashSensitiveValue(value) {
return `${createHash("sha256").update(value).digest("hex")} (sha256 hash)`;
}
export function safeStringifyJson(data, skippedNames) {
return JSON.stringify(data, (name, value) => {
if (isSensitiveFieldName(name) || (skippedNames != null && skippedNames.has(name))) {
return typeof value === "string" ? hashSensitiveValue(value) : "<stripped sensitive data>";
}
return value;
}, 2);
}
//# sourceMappingURL=httpExecutor.js.map
{"version":3,"file":"httpExecutor.js","sourceRoot":"","sources":["../src/httpExecutor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,UAAU,EAAQ,MAAM,QAAQ,CAAA;AAC/D,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,MAAM,MAAM,OAAO,CAAA;AAC1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,IAAI,CAAA;AAGtC,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAClC,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAEzB,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,yBAAyB,EAAgB,MAAM,gCAAgC,CAAA;AAExF,MAAM,KAAK,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAA;AAExC,gFAAgF;AAEhF,gFAAgF;AAChF,oEAAoE;AACpE,MAAM,aAAa,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;AAEvF,qEAAqE;AACrE,8EAA8E;AAC9E,MAAM,0BAA0B,GAAG,IAAI,GAAG,CAAC,CAAC,eAAe,EAAE,oBAAoB,EAAE,cAAc,EAAE,SAAS,EAAE,YAAY,EAA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,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,wBAAwB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAA;AACjI,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,KAAa;IAC9C,OAAO,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAA;AAC5E,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,IAAS,EAAE,YAA0B;IACrE,OAAO,IAAI,CAAC,SAAS,CACnB,IAAI,EACJ,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QACd,IAAI,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,IAAI,IAAI,IAAI,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;YACnF,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,2BAA2B,CAAA;QAC5F,CAAC;QACD,OAAO,KAAK,CAAA;IACd,CAAC,EACD,CAAC,CACF,CAAA;AACH,CAAC","sourcesContent":["import { BinaryToTextEncoding, createHash, Hash } from \"crypto\"\nimport { sleep } from \"./retry.js\"\nimport _debug from \"debug\"\nimport { createWriteStream } from \"fs\"\nimport { IncomingMessage, OutgoingHttpHeader, OutgoingHttpHeaders, RequestOptions } from \"http\"\nimport { Socket } from \"net\"\nimport { Transform } from \"stream\"\nimport { URL } from \"url\"\nimport { Nullish } from \"./index.js\"\nimport { CancellationToken } from \"./CancellationToken.js\"\nimport { newError } from \"./error.js\"\nimport { ProgressCallbackTransform, ProgressInfo } from \"./ProgressCallbackTransform.js\"\n\nconst debug = _debug(\"electron-builder\")\n\n// ── Sensitive-data registries ────────────────────────────────────────────────\n\n// Normalise a header or field name: lowercase + strip all separators (- and _).\n// Shared by both registries so lookup is always separator-agnostic.\nconst normalizeName = (name: string): string => name.toLowerCase().replace(/[-_]/g, \"\")\n\n// HTTP header names (normalised) stripped on cross-origin redirects.\n// Stored normalised; lookup normalises the incoming key with normalizeName().\nconst SENSITIVE_REDIRECT_HEADERS = new Set([\"authorization\", \"proxyauthorization\", \"privatetoken\", \"xapikey\", \"xauthtoken\", \"xaccesstoken\", \"xgitlabtoken\", \"cookie\", \"xcsrftoken\"])\n\n// Substrings: a field name containing any of these (after normalization) is redacted.\nconst SENSITIVE_FIELD_PATTERNS: string[] = [\"token\", \"password\", \"secret\", \"authorization\", \"credential\", \"apikey\", \"passphrase\", \"auth\"] as const\n\n// Suffixes: a field name ending with any of these (after normalization) is redacted.\n// Intentionally greedy — \"publicKey\" is also stripped; over-stripping debug logs is\n// acceptable, under-stripping a credential is not.\nconst SENSITIVE_FIELD_SUFFIXES: string[] = [\"key\"] as const\n\n/**\n * Register an additional HTTP header to strip on cross-origin redirects.\n * Intended for custom publishers (e.g. GenericPublisher with a non-standard auth header).\n */\nexport function addSensitiveRedirectHeader(header: string): void {\n SENSITIVE_REDIRECT_HEADERS.add(normalizeName(header))\n}\n\n/**\n * Register an additional substring pattern used by {@link safeStringifyJson} to\n * identify sensitive field names. Input is normalized (lowercased, separators stripped).\n * Intended for custom publishers that store credentials under non-standard field names.\n */\nexport function addSensitiveFieldPattern(pattern: string): void {\n SENSITIVE_FIELD_PATTERNS.push(pattern.toLowerCase().replace(/[-_]/g, \"\"))\n}\n\nexport interface RequestHeaders extends OutgoingHttpHeaders {\n [key: string]: OutgoingHttpHeader | undefined\n}\n\nexport interface DownloadOptions {\n readonly headers?: OutgoingHttpHeaders | null\n readonly sha2?: string | null\n readonly sha512?: string | null\n\n readonly cancellationToken: CancellationToken\n\n // noinspection JSUnusedLocalSymbols\n onProgress?: (progress: ProgressInfo) => void\n}\n\nexport function createHttpError(response: IncomingMessage, description: any | null = null) {\n return new HttpError(\n response.statusCode || -1,\n `${response.statusCode} ${response.statusMessage}` +\n (description == null ? \"\" : \"\\n\" + JSON.stringify(description, null, \" \")) +\n \"\\nHeaders: \" +\n safeStringifyJson(response.headers),\n description\n )\n}\n\nconst HTTP_STATUS_CODES = new Map<number, string>([\n [429, \"Too many requests\"],\n [400, \"Bad request\"],\n [403, \"Forbidden\"],\n [404, \"Not found\"],\n [405, \"Method not allowed\"],\n [406, \"Not acceptable\"],\n [408, \"Request timeout\"],\n [413, \"Request entity too large\"],\n [500, \"Internal server error\"],\n [502, \"Bad gateway\"],\n [503, \"Service unavailable\"],\n [504, \"Gateway timeout\"],\n [505, \"HTTP version not supported\"],\n])\n\nexport class HttpError extends Error {\n constructor(\n readonly statusCode: number,\n message = `HTTP error: ${HTTP_STATUS_CODES.get(statusCode) || statusCode}`,\n readonly description: any | null = null\n ) {\n super(message)\n\n this.name = \"HttpError\"\n ;(this as NodeJS.ErrnoException).code = `HTTP_ERROR_${statusCode}`\n }\n\n isServerError() {\n return this.statusCode >= 500 && this.statusCode <= 599\n }\n}\n\nexport function parseJson(result: Promise<string | null>) {\n return result.then(it => (it == null || it.length === 0 ? null : JSON.parse(it)))\n}\n\ninterface Request {\n abort: () => void\n end: (data?: Buffer) => void\n}\nexport abstract class HttpExecutor<T extends Request> {\n protected readonly maxRedirects = 10\n\n request(options: RequestOptions, cancellationToken: CancellationToken = new CancellationToken(), data?: { [name: string]: any } | null): Promise<string | null> {\n configureRequestOptions(options)\n const json = data == null ? undefined : JSON.stringify(data)\n const encodedData = json ? Buffer.from(json) : undefined\n if (encodedData != null) {\n if (debug.enabled) {\n debug(safeStringifyJson(data))\n }\n const { headers, ...opts } = options\n options = {\n method: \"post\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"Content-Length\": encodedData.length,\n ...headers,\n },\n ...opts,\n }\n }\n return this.doApiRequest(options, cancellationToken, it => it.end(encodedData))\n }\n\n doApiRequest(\n options: RequestOptions,\n cancellationToken: CancellationToken,\n requestProcessor: (request: T, reject: (error: Error) => void) => void,\n redirectCount = 0\n ): Promise<string> {\n if (debug.enabled) {\n const { headers: _headers, auth: _auth, ...safeOptions } = options as any\n debug(`Request: ${safeStringifyJson(safeOptions)}`)\n }\n\n return cancellationToken.createPromise<string>((resolve, reject, onCancel) => {\n const request = this.createRequest(options, (response: any) => {\n try {\n this.handleResponse(response, options, cancellationToken, resolve, reject, redirectCount, requestProcessor)\n } catch (e: any) {\n reject(e)\n }\n })\n this.addErrorAndTimeoutHandlers(request, reject, options.timeout)\n this.addRedirectHandlers(request, options, reject, redirectCount, options => {\n this.doApiRequest(options, cancellationToken, requestProcessor, redirectCount).then(resolve).catch(reject)\n })\n requestProcessor(request, reject)\n onCancel(() => request.abort())\n })\n }\n\n // noinspection JSUnusedLocalSymbols\n // eslint-disable-next-line\n protected addRedirectHandlers(request: any, options: RequestOptions, reject: (error: Error) => void, redirectCount: number, handler: (options: RequestOptions) => void) {\n // not required for NodeJS\n }\n\n addErrorAndTimeoutHandlers(request: any, reject: (error: Error) => void, timeout = 60 * 1000) {\n this.addTimeOutHandler(request, reject, timeout)\n request.on(\"error\", reject)\n request.on(\"aborted\", () => {\n reject(new Error(\"Request has been aborted by the server\"))\n })\n }\n\n private handleResponse(\n response: IncomingMessage,\n options: RequestOptions,\n cancellationToken: CancellationToken,\n resolve: (data?: any) => void,\n reject: (error: Error) => void,\n redirectCount: number,\n requestProcessor: (request: T, reject: (error: Error) => void) => void\n ) {\n if (debug.enabled) {\n const { headers: _headers, auth: _auth, ...safeOptions } = options as any\n debug(`Response: ${response.statusCode} ${response.statusMessage}, request options: ${safeStringifyJson(safeOptions)}`)\n }\n\n // we handle any other >= 400 error on request end (read detailed message in the response body)\n if (response.statusCode === 404) {\n // error is clear, we don't need to read detailed error description\n reject(\n createHttpError(\n response,\n `method: ${options.method || \"GET\"} url: ${options.protocol || \"https:\"}//${options.hostname}${options.port ? `:${options.port}` : \"\"}${options.path}\n\nPlease double check that your authentication token is correct. Due to security reasons, actual status maybe not reported, but 404.\n`\n )\n )\n return\n } else if (response.statusCode === 204) {\n // on DELETE request\n resolve()\n return\n }\n\n const code = response.statusCode ?? 0\n const shouldRedirect = code >= 300 && code < 400\n const redirectUrl = safeGetHeader(response, \"location\")\n if (shouldRedirect && redirectUrl != null) {\n if (redirectCount > this.maxRedirects) {\n reject(this.createMaxRedirectError())\n return\n }\n\n this.doApiRequest(HttpExecutor.prepareRedirectUrlOptions(redirectUrl, options), cancellationToken, requestProcessor, redirectCount).then(resolve).catch(reject)\n return\n }\n\n response.setEncoding(\"utf8\")\n\n let data = \"\"\n response.on(\"error\", reject)\n response.on(\"data\", (chunk: string) => (data += chunk))\n response.on(\"end\", () => {\n try {\n if (response.statusCode != null && response.statusCode >= 400) {\n const contentType = safeGetHeader(response, \"content-type\")\n const isJson = contentType != null && (Array.isArray(contentType) ? contentType.find(it => it.includes(\"json\")) != null : contentType.includes(\"json\"))\n reject(\n createHttpError(\n response,\n `method: ${options.method || \"GET\"} url: ${options.protocol || \"https:\"}//${options.hostname}${options.port ? `:${options.port}` : \"\"}${options.path}\n\n Data:\n ${isJson ? safeStringifyJson(JSON.parse(data)) : data}\n `\n )\n )\n } else {\n resolve(data.length === 0 ? null : data)\n }\n } catch (e: any) {\n reject(e)\n }\n })\n }\n\n // noinspection JSUnusedLocalSymbols\n abstract createRequest(options: RequestOptions, callback: (response: any) => void): T\n\n async downloadToBuffer(url: URL, options: DownloadOptions): Promise<Buffer> {\n return await options.cancellationToken.createPromise<Buffer>((resolve, reject, onCancel) => {\n const responseChunks: Buffer[] = []\n const requestOptions = {\n headers: options.headers || undefined,\n // because PrivateGitHubProvider requires HttpExecutor.prepareRedirectUrlOptions logic, so, we need to redirect manually\n redirect: \"manual\",\n }\n configureRequestUrl(url, requestOptions)\n configureRequestOptions(requestOptions)\n this.doDownload(\n requestOptions,\n {\n destination: null,\n options,\n onCancel,\n callback: error => {\n if (error == null) {\n resolve(Buffer.concat(responseChunks))\n } else {\n reject(error)\n }\n },\n responseHandler: (response, callback) => {\n let receivedLength = 0\n response.on(\"data\", (chunk: Buffer) => {\n receivedLength += chunk.length\n if (receivedLength > 524288000) {\n callback(new Error(\"Maximum allowed size is 500 MB\"))\n return\n }\n responseChunks.push(chunk)\n })\n response.on(\"end\", () => {\n callback(null)\n })\n },\n },\n 0\n )\n })\n }\n\n protected doDownload(requestOptions: RequestOptions, options: DownloadCallOptions, redirectCount: number) {\n const request = this.createRequest(requestOptions, (response: IncomingMessage) => {\n if (response.statusCode! >= 400) {\n options.callback(\n new Error(\n `Cannot download \"${requestOptions.protocol || \"https:\"}//${requestOptions.hostname}${requestOptions.path}\", status ${response.statusCode}: ${response.statusMessage}`\n )\n )\n return\n }\n\n // It is possible for the response stream to fail, e.g. when a network is lost while\n // response stream is in progress. Stop waiting and reject so consumer can catch the error.\n response.on(\"error\", options.callback)\n\n // this code not relevant for Electron (redirect event instead handled)\n const redirectUrl = safeGetHeader(response, \"location\")\n if (redirectUrl != null) {\n if (redirectCount < this.maxRedirects) {\n this.doDownload(HttpExecutor.prepareRedirectUrlOptions(redirectUrl, requestOptions), options, redirectCount++)\n } else {\n options.callback(this.createMaxRedirectError())\n }\n return\n }\n\n if (options.responseHandler == null) {\n configurePipes(options, response)\n } else {\n options.responseHandler(response, options.callback)\n }\n })\n this.addErrorAndTimeoutHandlers(request, options.callback, requestOptions.timeout)\n this.addRedirectHandlers(request, requestOptions, options.callback, redirectCount, requestOptions => {\n this.doDownload(requestOptions, options, redirectCount++)\n })\n request.end()\n }\n\n protected createMaxRedirectError() {\n return new Error(`Too many redirects (> ${this.maxRedirects})`)\n }\n\n private addTimeOutHandler(request: any, callback: (error: Error) => void, timeout: number) {\n request.on(\"socket\", (socket: Socket) => {\n socket.setTimeout(timeout, () => {\n request.abort()\n callback(new Error(\"Request timed out\"))\n })\n })\n }\n\n static prepareRedirectUrlOptions(redirectUrl: string, options: RequestOptions): RequestOptions {\n const newOptions = configureRequestOptionsFromUrl(redirectUrl, { ...options })\n const headers = newOptions.headers\n if (headers == null) {\n return newOptions\n }\n\n const originalUrl = HttpExecutor.reconstructOriginalUrl(options)\n const parsedRedirectUrl = parseUrl(redirectUrl, options)\n\n if (HttpExecutor.isCrossOriginRedirect(originalUrl, parsedRedirectUrl)) {\n if (debug.enabled) {\n debug(`Cross-origin redirect (${originalUrl.host} → ${parsedRedirectUrl.host}): stripping sensitive headers`)\n }\n for (const key of Object.keys(headers)) {\n if (SENSITIVE_REDIRECT_HEADERS.has(normalizeName(key))) {\n delete (headers as Record<string, unknown>)[key]\n }\n }\n }\n return newOptions\n }\n\n private static reconstructOriginalUrl(options: RequestOptions): URL {\n const protocol = options.protocol || \"https:\"\n if (!options.hostname) {\n throw new Error(\"Missing hostname in request options\")\n }\n const hostname = options.hostname\n const port = options.port ? `:${options.port}` : \"\"\n const path = options.path || \"/\"\n return new URL(`${protocol}//${hostname}${port}${path}`)\n }\n\n private static isCrossOriginRedirect(originalUrl: URL, redirectUrl: URL): boolean {\n // Case-insensitive hostname comparison\n if (originalUrl.hostname.toLowerCase() !== redirectUrl.hostname.toLowerCase()) {\n return true\n }\n\n // Special case: allow http -> https redirect on same host with standard ports\n // This matches the behavior of Python requests library for backward compatibility\n // url.port returns an empty string if the port is omitted\n // or explicitly set to the default port for a given protocol.\n if (\n originalUrl.protocol === \"http:\" &&\n // This can be replaced with `!originalUrl.port`, but for the sake of clarity.\n [\"80\", \"\"].includes(originalUrl.port) &&\n redirectUrl.protocol === \"https:\" &&\n // This can be replaced with `!redirectUrl.port`, but for the sake of clarity.\n [\"443\", \"\"].includes(redirectUrl.port)\n ) {\n return false\n }\n\n // According to RFC 7235, a change in protocol or port constitutes a cross-origin request.\n // Forwarding authentication headers to a different origin can be a security risk.\n // For example, https://example.com:443 and http://example.com:80 are different origins.\n // We only make an exception for HTTP -> HTTPS upgrades on standard ports for backward compatibility.\n\n // Strip auth on any other protocol change\n if (originalUrl.protocol !== redirectUrl.protocol) {\n return true\n }\n\n // Strip auth on port change (accounting for default ports)\n const originalPort = originalUrl.port\n const redirectPort = redirectUrl.port\n return originalPort !== redirectPort\n }\n\n static async retryOnServerError(task: () => Promise<any>, maxRetries = 3): Promise<any> {\n for (let attemptNumber = 0; ; attemptNumber++) {\n try {\n return await task()\n } catch (e: any) {\n if (attemptNumber < maxRetries && ((e instanceof HttpError && e.isServerError()) || e.code === \"EPIPE\")) {\n await sleep(1000 * (attemptNumber + 1))\n continue\n }\n throw e\n }\n }\n }\n}\n\nexport interface DownloadCallOptions {\n responseHandler: ((response: IncomingMessage, callback: (error: Error | null) => void) => void) | null\n onCancel: (callback: () => void) => void\n callback: (error: Error | null) => void\n\n options: DownloadOptions\n\n destination: string | null\n}\n\nfunction parseUrl(url: string, options: RequestOptions): URL {\n try {\n // Would throw exception if url is not absolute\n return new URL(url)\n } catch {\n // Relative URL - construct base URL from original options\n const hostname = options.hostname\n const protocol = options.protocol || \"https:\"\n const port = options.port ? `:${options.port}` : \"\"\n const baseUrl = `${protocol}//${hostname}${port}`\n return new URL(url, baseUrl)\n }\n}\n\nexport function configureRequestOptionsFromUrl(url: string, options: RequestOptions) {\n const result = configureRequestOptions(options)\n const parsedUrl = parseUrl(url, options)\n configureRequestUrl(parsedUrl, result)\n return result\n}\n\nexport function configureRequestUrl(url: URL, options: RequestOptions): void {\n options.protocol = url.protocol\n options.hostname = url.hostname\n if (url.port) {\n options.port = url.port\n } else if (options.port) {\n delete options.port\n }\n options.path = url.pathname + url.search\n}\n\nexport class DigestTransform extends Transform {\n private readonly digester: Hash\n\n private _actual: string | null = null\n\n // noinspection JSUnusedGlobalSymbols\n get actual() {\n return this._actual\n }\n\n isValidateOnEnd = true\n\n constructor(\n readonly expected: string,\n private readonly algorithm: string = \"sha512\",\n private readonly encoding: BinaryToTextEncoding = \"base64\"\n ) {\n super()\n\n this.digester = createHash(algorithm)\n }\n\n // noinspection JSUnusedGlobalSymbols\n _transform(chunk: Buffer, encoding: string, callback: any) {\n this.digester.update(chunk)\n callback(null, chunk)\n }\n\n // noinspection JSUnusedGlobalSymbols\n _flush(callback: any): void {\n this._actual = this.digester.digest(this.encoding)\n\n if (this.isValidateOnEnd) {\n try {\n this.validate()\n } catch (e: any) {\n callback(e)\n return\n }\n }\n\n callback(null)\n }\n\n validate() {\n if (this._actual == null) {\n throw newError(\"Not finished yet\", \"ERR_STREAM_NOT_FINISHED\")\n }\n\n if (this._actual !== this.expected) {\n throw newError(`${this.algorithm} checksum mismatch, expected ${this.expected}, got ${this._actual}`, \"ERR_CHECKSUM_MISMATCH\")\n }\n\n return null\n }\n}\n\nfunction checkSha2(sha2Header: string | Nullish, sha2: string | Nullish, callback: (error: Error | null) => void): boolean {\n if (sha2Header != null && sha2 != null && sha2Header !== sha2) {\n callback(new Error(`checksum mismatch: expected ${sha2} but got ${sha2Header} (X-Checksum-Sha2 header)`))\n return false\n }\n return true\n}\n\nexport function safeGetHeader(response: any, headerKey: string) {\n const value = response.headers[headerKey]\n if (value == null) {\n return null\n } else if (Array.isArray(value)) {\n // electron API\n return value.length === 0 ? null : value[value.length - 1]\n } else {\n return value\n }\n}\n\nfunction configurePipes(options: DownloadCallOptions, response: IncomingMessage) {\n if (!checkSha2(safeGetHeader(response, \"X-Checksum-Sha2\"), options.options.sha2, options.callback)) {\n return\n }\n\n const streams: Array<any> = []\n if (options.options.onProgress != null) {\n const contentLength = safeGetHeader(response, \"content-length\")\n if (contentLength != null) {\n streams.push(new ProgressCallbackTransform(parseInt(contentLength, 10), options.options.cancellationToken, options.options.onProgress))\n }\n }\n\n const sha512 = options.options.sha512\n if (sha512 != null) {\n streams.push(new DigestTransform(sha512, \"sha512\", sha512.length === 128 && !sha512.includes(\"+\") && !sha512.includes(\"Z\") && !sha512.includes(\"=\") ? \"hex\" : \"base64\"))\n } else if (options.options.sha2 != null) {\n streams.push(new DigestTransform(options.options.sha2, \"sha256\", \"hex\"))\n }\n\n const fileOut = createWriteStream(options.destination!)\n streams.push(fileOut)\n\n let lastStream = response\n for (const stream of streams) {\n stream.on(\"error\", (error: Error) => {\n fileOut.close()\n if (!options.options.cancellationToken.cancelled) {\n options.callback(error)\n }\n })\n lastStream = lastStream.pipe(stream)\n }\n\n fileOut.on(\"finish\", () => {\n ;(fileOut.close as any)(options.callback)\n })\n}\n\nexport function configureRequestOptions(options: RequestOptions, token?: string | null, method?: \"GET\" | \"DELETE\" | \"PUT\" | \"POST\"): RequestOptions {\n if (method != null) {\n options.method = method\n }\n\n options.headers = { ...options.headers }\n const headers = options.headers\n\n if (token != null) {\n ;(headers as any).authorization = token.startsWith(\"Basic\") || token.startsWith(\"Bearer\") ? token : `token ${token}`\n }\n if (headers[\"User-Agent\"] == null) {\n headers[\"User-Agent\"] = \"electron-builder\"\n }\n\n if (method == null || method === \"GET\" || headers[\"Cache-Control\"] == null) {\n headers[\"Cache-Control\"] = \"no-cache\"\n }\n\n // do not specify for node (in any case we use https module)\n if (options.protocol == null && (process.versions as any).electron != null) {\n options.protocol = \"https:\"\n }\n return options\n}\n\nexport function isSensitiveFieldName(name: string): boolean {\n const normalized = normalizeName(name)\n return SENSITIVE_FIELD_PATTERNS.some(p => normalized.includes(p)) || SENSITIVE_FIELD_SUFFIXES.some(s => normalized.endsWith(s))\n}\n\nexport function hashSensitiveValue(value: string): string {\n return `${createHash(\"sha256\").update(value).digest(\"hex\")} (sha256 hash)`\n}\n\nexport function safeStringifyJson(data: any, skippedNames?: Set<string>): string {\n return JSON.stringify(\n data,\n (name, value) => {\n if (isSensitiveFieldName(name) || (skippedNames != null && skippedNames.has(name))) {\n return typeof value === \"string\" ? hashSensitiveValue(value) : \"<stripped sensitive data>\"\n }\n return value\n },\n 2\n )\n}\n"]}
export { BlockMap } from "./blockMapApi.js";
export { CancellationError, CancellationToken } from "./CancellationToken.js";
export { newError } from "./error.js";
export { configureRequestOptions, configureRequestOptionsFromUrl, configureRequestUrl, createHttpError, DigestTransform, DownloadOptions, HttpError, hashSensitiveValue, HttpExecutor, isSensitiveFieldName, parseJson, RequestHeaders, safeGetHeader, safeStringifyJson, } from "./httpExecutor.js";
export { MemoLazy } from "./MemoLazy.js";
export { ProgressCallbackTransform, ProgressInfo } from "./ProgressCallbackTransform.js";
export { AllPublishOptions, BaseS3Options, BitbucketOptions, CustomPublishOptions, GenericServerOptions, getS3LikeProviderBaseUrl, GithubOptions, githubUrl, githubTagPrefix, GitlabOptions, KeygenOptions, PublishConfiguration, PublishProvider, S3Options, SnapStoreOptions, SpacesOptions, GitlabReleaseInfo, GitlabReleaseAsset, } from "./publishOptions.js";
export { retry, sleep } from "./retry.js";
export { parseDn } from "./rfc2253Parser.js";
export { BlockMapDataHolder, PackageFileInfo, ReleaseNoteInfo, UpdateFileInfo, UpdateInfo, WindowsUpdateInfo } from "./updateInfo.js";
export { UUID } from "./uuid.js";
export { parseXml, XElement } from "./xml.js";
export { isValidKey, mapToObject, asArray, Nullish, deepAssign, objectToArgs } from "./objects.js";
export declare const CURRENT_APP_INSTALLER_FILE_NAME = "installer.exe";
export declare const CURRENT_APP_PACKAGE_FILE_NAME = "package.7z";
//# sourceMappingURL=index.d.ts.map
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC7E,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EACL,uBAAuB,EACvB,8BAA8B,EAC9B,mBAAmB,EACnB,eAAe,EACf,eAAe,EACf,eAAe,EACf,SAAS,EACT,kBAAkB,EAClB,YAAY,EACZ,oBAAoB,EACpB,SAAS,EACT,cAAc,EACd,aAAa,EACb,iBAAiB,GAClB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,yBAAyB,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAA;AACxF,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,wBAAwB,EACxB,aAAa,EACb,SAAS,EACT,eAAe,EACf,aAAa,EACb,aAAa,EACb,oBAAoB,EACpB,eAAe,EACf,SAAS,EACT,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAC5C,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,eAAe,EAAE,cAAc,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AACrI,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAC7C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAGlG,eAAO,MAAM,+BAA+B,kBAAkB,CAAA;AAE9D,eAAO,MAAM,6BAA6B,eAAe,CAAA"}
export { CancellationError, CancellationToken } from "./CancellationToken.js";
export { newError } from "./error.js";
export { configureRequestOptions, configureRequestOptionsFromUrl, configureRequestUrl, createHttpError, DigestTransform, HttpError, hashSensitiveValue, HttpExecutor, isSensitiveFieldName, parseJson, safeGetHeader, safeStringifyJson, } from "./httpExecutor.js";
export { MemoLazy } from "./MemoLazy.js";
export { ProgressCallbackTransform } from "./ProgressCallbackTransform.js";
export { getS3LikeProviderBaseUrl, githubUrl, githubTagPrefix, } from "./publishOptions.js";
export { retry, sleep } from "./retry.js";
export { parseDn } from "./rfc2253Parser.js";
export { UUID } from "./uuid.js";
export { parseXml, XElement } from "./xml.js";
export { isValidKey, mapToObject, asArray, deepAssign, objectToArgs } from "./objects.js";
// nsis
export const CURRENT_APP_INSTALLER_FILE_NAME = "installer.exe";
// nsis-web
export const CURRENT_APP_PACKAGE_FILE_NAME = "package.7z";
//# sourceMappingURL=index.js.map
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC7E,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EACL,uBAAuB,EACvB,8BAA8B,EAC9B,mBAAmB,EACnB,eAAe,EACf,eAAe,EAEf,SAAS,EACT,kBAAkB,EAClB,YAAY,EACZ,oBAAoB,EACpB,SAAS,EAET,aAAa,EACb,iBAAiB,GAClB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,yBAAyB,EAAgB,MAAM,gCAAgC,CAAA;AACxF,OAAO,EAML,wBAAwB,EAExB,SAAS,EACT,eAAe,GAUhB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAE5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAC7C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAW,UAAU,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAElG,OAAO;AACP,MAAM,CAAC,MAAM,+BAA+B,GAAG,eAAe,CAAA;AAC9D,WAAW;AACX,MAAM,CAAC,MAAM,6BAA6B,GAAG,YAAY,CAAA","sourcesContent":["export { BlockMap } from \"./blockMapApi.js\"\nexport { CancellationError, CancellationToken } from \"./CancellationToken.js\"\nexport { newError } from \"./error.js\"\nexport {\n configureRequestOptions,\n configureRequestOptionsFromUrl,\n configureRequestUrl,\n createHttpError,\n DigestTransform,\n DownloadOptions,\n HttpError,\n hashSensitiveValue,\n HttpExecutor,\n isSensitiveFieldName,\n parseJson,\n RequestHeaders,\n safeGetHeader,\n safeStringifyJson,\n} from \"./httpExecutor.js\"\nexport { MemoLazy } from \"./MemoLazy.js\"\nexport { ProgressCallbackTransform, ProgressInfo } from \"./ProgressCallbackTransform.js\"\nexport {\n AllPublishOptions,\n BaseS3Options,\n BitbucketOptions,\n CustomPublishOptions,\n GenericServerOptions,\n getS3LikeProviderBaseUrl,\n GithubOptions,\n githubUrl,\n githubTagPrefix,\n GitlabOptions,\n KeygenOptions,\n PublishConfiguration,\n PublishProvider,\n S3Options,\n SnapStoreOptions,\n SpacesOptions,\n GitlabReleaseInfo,\n GitlabReleaseAsset,\n} from \"./publishOptions.js\"\nexport { retry, sleep } from \"./retry.js\"\nexport { parseDn } from \"./rfc2253Parser.js\"\nexport { BlockMapDataHolder, PackageFileInfo, ReleaseNoteInfo, UpdateFileInfo, UpdateInfo, WindowsUpdateInfo } from \"./updateInfo.js\"\nexport { UUID } from \"./uuid.js\"\nexport { parseXml, XElement } from \"./xml.js\"\nexport { isValidKey, mapToObject, asArray, Nullish, deepAssign, objectToArgs } from \"./objects.js\"\n\n// nsis\nexport const CURRENT_APP_INSTALLER_FILE_NAME = \"installer.exe\"\n// nsis-web\nexport const CURRENT_APP_PACKAGE_FILE_NAME = \"package.7z\"\n"]}
export { BlockMap, BlockMapFile } from "./blockMapApi.js";
export { hashSensitiveValue, safeStringifyJson } from "./httpExecutor.js";
export type { SnapStoreOptions } from "./publishOptions.js";
//# sourceMappingURL=indexInternal.d.ts.map
{"version":3,"file":"indexInternal.d.ts","sourceRoot":"","sources":["../src/indexInternal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AACzD,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AACzE,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA"}
export { hashSensitiveValue, safeStringifyJson } from "./httpExecutor.js";
//# sourceMappingURL=indexInternal.js.map
{"version":3,"file":"indexInternal.js","sourceRoot":"","sources":["../src/indexInternal.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA","sourcesContent":["export { BlockMap, BlockMapFile } from \"./blockMapApi.js\"\nexport { hashSensitiveValue, safeStringifyJson } from \"./httpExecutor.js\"\nexport type { SnapStoreOptions } from \"./publishOptions.js\"\n"]}
export declare class MemoLazy<S, V> {
private selector;
private creator;
private selected;
private _value;
constructor(selector: () => S, creator: (selected: S) => Promise<V>);
get hasValue(): boolean;
get value(): Promise<V>;
set value(value: Promise<V>);
}
//# sourceMappingURL=MemoLazy.d.ts.map
{"version":3,"file":"MemoLazy.d.ts","sourceRoot":"","sources":["../src/MemoLazy.ts"],"names":[],"mappings":"AAAA,qBAAa,QAAQ,CAAC,CAAC,EAAE,CAAC;IAKtB,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,OAAO;IALjB,OAAO,CAAC,QAAQ,CAA2B;IAC3C,OAAO,CAAC,MAAM,CAAoC;gBAGxC,QAAQ,EAAE,MAAM,CAAC,EACjB,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC;IAG9C,IAAI,QAAQ,YAEX;IAED,IAAI,KAAK,IAAI,OAAO,CAAC,CAAC,CAAC,CAYtB;IAED,IAAI,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,EAE1B;CACF"}
export class MemoLazy {
constructor(selector, creator) {
this.selector = selector;
this.creator = creator;
this.selected = undefined;
this._value = undefined;
}
get hasValue() {
return this._value !== undefined;
}
get value() {
const selected = this.selector();
if (this._value !== undefined && equals(this.selected, selected)) {
// value exists and selected hasn't changed, so return the cached value
return this._value;
}
this.selected = selected;
const result = this.creator(selected);
this.value = result;
return result;
}
set value(value) {
this._value = value;
}
}
function equals(firstValue, secondValue) {
const isFirstObject = typeof firstValue === "object" && firstValue !== null;
const isSecondObject = typeof secondValue === "object" && secondValue !== null;
// do a shallow comparison of objects, arrays etc.
if (isFirstObject && isSecondObject) {
const keys1 = Object.keys(firstValue);
const keys2 = Object.keys(secondValue);
return keys1.length === keys2.length && keys1.every((key) => equals(firstValue[key], secondValue[key]));
}
// otherwise just compare the values directly
return firstValue === secondValue;
}
//# sourceMappingURL=MemoLazy.js.map
{"version":3,"file":"MemoLazy.js","sourceRoot":"","sources":["../src/MemoLazy.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,QAAQ;IAInB,YACU,QAAiB,EACjB,OAAoC;QADpC,aAAQ,GAAR,QAAQ,CAAS;QACjB,YAAO,GAAP,OAAO,CAA6B;QALtC,aAAQ,GAAkB,SAAS,CAAA;QACnC,WAAM,GAA2B,SAAS,CAAA;IAK/C,CAAC;IAEJ,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,MAAM,KAAK,SAAS,CAAA;IAClC,CAAC;IAED,IAAI,KAAK;QACP,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAA;QAChC,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,CAAC;YACjE,uEAAuE;YACvE,OAAO,IAAI,CAAC,MAAM,CAAA;QACpB,CAAC;QAED,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;QACrC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAA;QAEnB,OAAO,MAAM,CAAA;IACf,CAAC;IAED,IAAI,KAAK,CAAC,KAAiB;QACzB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;IACrB,CAAC;CACF;AAED,SAAS,MAAM,CAAC,UAAe,EAAE,WAAgB;IAC/C,MAAM,aAAa,GAAG,OAAO,UAAU,KAAK,QAAQ,IAAI,UAAU,KAAK,IAAI,CAAA;IAC3E,MAAM,cAAc,GAAG,OAAO,WAAW,KAAK,QAAQ,IAAI,WAAW,KAAK,IAAI,CAAA;IAE9E,kDAAkD;IAClD,IAAI,aAAa,IAAI,cAAc,EAAE,CAAC;QACpC,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;QACrC,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;QAEtC,OAAO,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,GAAQ,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;IAC9G,CAAC;IAED,6CAA6C;IAC7C,OAAO,UAAU,KAAK,WAAW,CAAA;AACnC,CAAC","sourcesContent":["export class MemoLazy<S, V> {\n private selected: S | undefined = undefined\n private _value: Promise<V> | undefined = undefined\n\n constructor(\n private selector: () => S,\n private creator: (selected: S) => Promise<V>\n ) {}\n\n get hasValue() {\n return this._value !== undefined\n }\n\n get value(): Promise<V> {\n const selected = this.selector()\n if (this._value !== undefined && equals(this.selected, selected)) {\n // value exists and selected hasn't changed, so return the cached value\n return this._value\n }\n\n this.selected = selected\n const result = this.creator(selected)\n this.value = result\n\n return result\n }\n\n set value(value: Promise<V>) {\n this._value = value\n }\n}\n\nfunction equals(firstValue: any, secondValue: any): boolean {\n const isFirstObject = typeof firstValue === \"object\" && firstValue !== null\n const isSecondObject = typeof secondValue === \"object\" && secondValue !== null\n\n // do a shallow comparison of objects, arrays etc.\n if (isFirstObject && isSecondObject) {\n const keys1 = Object.keys(firstValue)\n const keys2 = Object.keys(secondValue)\n\n return keys1.length === keys2.length && keys1.every((key: any) => equals(firstValue[key], secondValue[key]))\n }\n\n // otherwise just compare the values directly\n return firstValue === secondValue\n}\n"]}
export type Nullish = null | undefined;
type RecursiveMap = Map<any, RecursiveMap | any>;
export declare function mapToObject(map: RecursiveMap): any;
export declare function isValidKey(key: any): boolean;
export declare function asArray<T>(v: Nullish | T | Array<T>): Array<T>;
export declare function deepAssign<T>(target: T, ...objects: Array<any>): T;
export declare function objectToArgs(obj: Record<string, string | null>): readonly string[];
export {};
//# sourceMappingURL=objects.d.ts.map
{"version":3,"file":"objects.d.ts","sourceRoot":"","sources":["../src/objects.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,GAAG,IAAI,GAAG,SAAS,CAAA;AAEtC,KAAK,YAAY,GAAG,GAAG,CAAC,GAAG,EAAE,YAAY,GAAG,GAAG,CAAC,CAAA;AAEhD,wBAAgB,WAAW,CAAC,GAAG,EAAE,YAAY,OAa5C;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,GAAG,WAMlC;AAED,wBAAgB,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAQ9D;AA0CD,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAOlE;AASD,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,GAAG,SAAS,MAAM,EAAE,CAclF"}
export function mapToObject(map) {
const obj = {};
for (const [key, value] of map) {
if (!isValidKey(key)) {
continue;
}
if (value instanceof Map) {
obj[key] = mapToObject(value);
}
else {
obj[key] = value;
}
}
return obj;
}
export function isValidKey(key) {
const protectedProperties = ["__proto__", "prototype", "constructor"];
if (protectedProperties.includes(key)) {
return false;
}
return ["string", "number", "symbol", "boolean"].includes(typeof key) || key === null;
}
export function asArray(v) {
if (v == null) {
return [];
}
else if (Array.isArray(v)) {
return v;
}
else {
return [v];
}
}
function isObject(x) {
if (Array.isArray(x)) {
return false;
}
const type = typeof x;
return type === "object" || type === "function";
}
function assignKey(target, from, key) {
const value = from[key];
// https://github.com/electron-userland/electron-builder/pull/562
if (value === undefined) {
return;
}
const prevValue = target[key];
if (prevValue == null || value == null || !isObject(prevValue) || !isObject(value)) {
// Merge arrays.
if (Array.isArray(prevValue) && Array.isArray(value)) {
target[key] = Array.from(new Set(prevValue.concat(value)));
}
else {
target[key] = value;
}
}
else {
target[key] = assign(prevValue, value);
}
}
function assign(to, from) {
if (to !== from) {
for (const key of Object.getOwnPropertyNames(from)) {
if (isValidKey(key)) {
assignKey(to, from, key);
}
}
}
return to;
}
export function deepAssign(target, ...objects) {
for (const o of objects) {
if (o != null) {
assign(target, o);
}
}
return target;
}
// Flag names must be letters/digits/hyphens only (e.g. "maintainer", "deb-priority").
// Anything else could inject extra flags into the argument array.
const SAFE_FLAG_NAME_RE = /^[a-zA-Z][a-zA-Z0-9-]*$/;
// Null bytes truncate arguments at the C layer; newlines can split arguments in some parsers.
const UNSAFE_VALUE_RE = /[\0\r\n]/;
export function objectToArgs(obj) {
const args = Object.entries(obj).reduce((args, [name, value]) => {
if (!isValidKey(name) || value == null) {
return args;
}
if (!SAFE_FLAG_NAME_RE.test(name)) {
throw new Error(`objectToArgs: unsafe flag name rejected: ${JSON.stringify(name)}`);
}
if (UNSAFE_VALUE_RE.test(value)) {
throw new Error(`objectToArgs: value for --${name} contains a null byte or newline`);
}
return args.concat([`--${name}`, value]);
}, []);
return Object.freeze(args);
}
//# sourceMappingURL=objects.js.map
{"version":3,"file":"objects.js","sourceRoot":"","sources":["../src/objects.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,WAAW,CAAC,GAAiB;IAC3C,MAAM,GAAG,GAAQ,EAAE,CAAA;IACnB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAA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CAAC,IAAI,OAAO,EAAE,CAAC;QACxB,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC;YACd,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;QACnB,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC;AAED,sFAAsF;AACtF,kEAAkE;AAClE,MAAM,iBAAiB,GAAG,yBAAyB,CAAA;AAEnD,8FAA8F;AAC9F,MAAM,eAAe,GAAG,UAAU,CAAA;AAElC,MAAM,UAAU,YAAY,CAAC,GAAkC;IAC7D,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAW,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE;QACxE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;YACvC,OAAO,IAAI,CAAA;QACb,CAAC;QACD,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAClC,MAAM,IAAI,KAAK,CAAC,4CAA4C,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QACrF,CAAC;QACD,IAAI,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,6BAA6B,IAAI,kCAAkC,CAAC,CAAA;QACtF,CAAC;QACD,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,IAAI,EAAE,EAAE,KAAK,CAAC,CAAC,CAAA;IAC1C,CAAC,EAAE,EAAE,CAAC,CAAA;IACN,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;AAC5B,CAAC","sourcesContent":["export type Nullish = null | undefined\n\ntype RecursiveMap = Map<any, RecursiveMap | any>\n\nexport function mapToObject(map: RecursiveMap) {\n const obj: any = {}\n for (const [key, value] of map) {\n if (!isValidKey(key)) {\n continue\n }\n if (value instanceof Map) {\n obj[key] = mapToObject(value)\n } else {\n obj[key] = value\n }\n }\n return obj\n}\n\nexport function isValidKey(key: any) {\n const protectedProperties = [\"__proto__\", \"prototype\", \"constructor\"]\n if (protectedProperties.includes(key)) {\n return false\n }\n return [\"string\", \"number\", \"symbol\", \"boolean\"].includes(typeof key) || key === null\n}\n\nexport function asArray<T>(v: Nullish | T | Array<T>): Array<T> {\n if (v == null) {\n return []\n } else if (Array.isArray(v)) {\n return v\n } else {\n return [v]\n }\n}\n\nfunction isObject(x: any) {\n if (Array.isArray(x)) {\n return false\n }\n\n const type = typeof x\n return type === \"object\" || type === \"function\"\n}\n\nfunction assignKey(target: any, from: any, key: string) {\n const value = from[key]\n // https://github.com/electron-userland/electron-builder/pull/562\n if (value === undefined) {\n return\n }\n\n const prevValue = target[key]\n if (prevValue == null || value == null || !isObject(prevValue) || !isObject(value)) {\n // Merge arrays.\n if (Array.isArray(prevValue) && Array.isArray(value)) {\n target[key] = Array.from(new Set(prevValue.concat(value)))\n } else {\n target[key] = value\n }\n } else {\n target[key] = assign(prevValue, value)\n }\n}\n\nfunction assign(to: any, from: any) {\n if (to !== from) {\n for (const key of Object.getOwnPropertyNames(from)) {\n if (isValidKey(key)) {\n assignKey(to, from, key)\n }\n }\n }\n return to\n}\n\nexport function deepAssign<T>(target: T, ...objects: Array<any>): T {\n for (const o of objects) {\n if (o != null) {\n assign(target, o)\n }\n }\n return target\n}\n\n// Flag names must be letters/digits/hyphens only (e.g. \"maintainer\", \"deb-priority\").\n// Anything else could inject extra flags into the argument array.\nconst SAFE_FLAG_NAME_RE = /^[a-zA-Z][a-zA-Z0-9-]*$/\n\n// Null bytes truncate arguments at the C layer; newlines can split arguments in some parsers.\nconst UNSAFE_VALUE_RE = /[\\0\\r\\n]/\n\nexport function objectToArgs(obj: Record<string, string | null>): readonly string[] {\n const args = Object.entries(obj).reduce<string[]>((args, [name, value]) => {\n if (!isValidKey(name) || value == null) {\n return args\n }\n if (!SAFE_FLAG_NAME_RE.test(name)) {\n throw new Error(`objectToArgs: unsafe flag name rejected: ${JSON.stringify(name)}`)\n }\n if (UNSAFE_VALUE_RE.test(value)) {\n throw new Error(`objectToArgs: value for --${name} contains a null byte or newline`)\n }\n return args.concat([`--${name}`, value])\n }, [])\n return Object.freeze(args)\n}\n"]}
import { Transform } from "stream";
import { CancellationToken } from "./CancellationToken.js";
export interface ProgressInfo {
total: number;
delta: number;
transferred: number;
percent: number;
bytesPerSecond: number;
}
export declare class ProgressCallbackTransform extends Transform {
private readonly total;
private readonly cancellationToken;
private readonly onProgress;
private start;
private transferred;
private delta;
private nextUpdate;
constructor(total: number, cancellationToken: CancellationToken, onProgress: (info: ProgressInfo) => any);
_transform(chunk: any, encoding: string, callback: any): void;
_flush(callback: any): void;
}
//# sourceMappingURL=ProgressCallbackTransform.d.ts.map
{"version":3,"file":"ProgressCallbackTransform.d.ts","sourceRoot":"","sources":["../src/ProgressCallbackTransform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAClC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAE1D,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,MAAM,CAAA;IACf,cAAc,EAAE,MAAM,CAAA;CACvB;AAED,qBAAa,yBAA0B,SAAQ,SAAS;IAQpD,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAClC,OAAO,CAAC,QAAQ,CAAC,UAAU;IAT7B,OAAO,CAAC,KAAK,CAAa;IAC1B,OAAO,CAAC,WAAW,CAAI;IACvB,OAAO,CAAC,KAAK,CAAI;IAEjB,OAAO,CAAC,UAAU,CAAoB;gBAGnB,KAAK,EAAE,MAAM,EACb,iBAAiB,EAAE,iBAAiB,EACpC,UAAU,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,GAAG;IAK1D,UAAU,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG;IA0BtD,MAAM,CAAC,QAAQ,EAAE,GAAG,GAAG,IAAI;CAiB5B"}
import { Transform } from "stream";
export class ProgressCallbackTransform extends 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;
}
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.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);
}
}
//# sourceMappingURL=ProgressCallbackTransform.js.map
{"version":3,"file":"ProgressCallbackTransform.js","sourceRoot":"","sources":["../src/ProgressCallbackTransform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAWlC,MAAM,OAAO,yBAA0B,SAAQ,SAAS;IAOtD,YACmB,KAAa,EACb,iBAAoC,EACpC,UAAuC;QAExD,KAAK,EAAE,CAAA;QAJU,UAAK,GAAL,KAAK,CAAQ;QACb,sBAAiB,GAAjB,iBAAiB,CAAmB;QACpC,eAAU,GAAV,UAAU,CAA6B;QATlD,UAAK,GA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IAAI,CAAC,iBAAiB,CAAC,SAAS,EAAE,CAAC;YACrC,QAAQ,CAAC,IAAI,KAAK,CAAC,WAAW,CAAC,CAAC,CAAA;YAChC,OAAM;QACR,CAAC;QAED,IAAI,CAAC,UAAU,CAAC;YACd,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,WAAW,EAAE,IAAI,CAAC,KAAK;YACvB,OAAO,EAAE,GAAG;YACZ,cAAc,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;SAClF,CAAC,CAAA;QACF,IAAI,CAAC,KAAK,GAAG,CAAC,CAAA;QAEd,QAAQ,CAAC,IAAI,CAAC,CAAA;IAChB,CAAC;CACF","sourcesContent":["import { Transform } from \"stream\"\nimport { CancellationToken } from \"./CancellationToken.js\"\n\nexport interface ProgressInfo {\n total: number\n delta: number\n transferred: number\n percent: number\n bytesPerSecond: number\n}\n\nexport class ProgressCallbackTransform extends Transform {\n private start = Date.now()\n private transferred = 0\n private delta = 0\n\n private nextUpdate = this.start + 1000\n\n constructor(\n private readonly total: number,\n private readonly cancellationToken: CancellationToken,\n private readonly onProgress: (info: ProgressInfo) => any\n ) {\n super()\n }\n\n _transform(chunk: any, encoding: string, callback: any) {\n if (this.cancellationToken.cancelled) {\n callback(new Error(\"cancelled\"), null)\n return\n }\n\n this.transferred += chunk.length\n this.delta += chunk.length\n\n const now = Date.now()\n if (now >= this.nextUpdate && this.transferred !== this.total /* will be emitted on _flush */) {\n this.nextUpdate = now + 1000\n\n this.onProgress({\n total: this.total,\n delta: this.delta,\n transferred: this.transferred,\n percent: (this.transferred / this.total) * 100,\n bytesPerSecond: Math.round(this.transferred / ((now - this.start) / 1000)),\n })\n this.delta = 0\n }\n\n callback(null, chunk)\n }\n\n _flush(callback: any): void {\n if (this.cancellationToken.cancelled) {\n callback(new Error(\"cancelled\"))\n return\n }\n\n this.onProgress({\n total: this.total,\n delta: this.delta,\n transferred: this.total,\n percent: 100,\n bytesPerSecond: Math.round(this.transferred / ((Date.now() - this.start) / 1000)),\n })\n this.delta = 0\n\n callback(null)\n }\n}\n"]}
import { OutgoingHttpHeaders } from "http";
export type PublishProvider = "github" | "gitlab" | "s3" | "spaces" | "generic" | "custom" | "snapStore" | "keygen" | "bitbucket";
export type AllPublishOptions = string | GithubOptions | GitlabOptions | S3Options | SpacesOptions | GenericServerOptions | CustomPublishOptions | KeygenOptions | SnapStoreOptions | BitbucketOptions;
export interface PublishConfiguration {
/**
* The provider.
*/
readonly provider: PublishProvider;
/**
* @private
* win-only
*/
publisherName?: Array<string> | null;
/**
* @private
* win-only
*/
readonly updaterCacheDirName?: 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;
/**
* Any custom request headers
*/
readonly requestHeaders?: OutgoingHttpHeaders;
/**
* Request timeout in milliseconds. (Default is 2 minutes; O is ignored)
*
* @default 120000
*/
readonly timeout?: number | null;
}
export interface CustomPublishOptions extends PublishConfiguration {
/**
* The provider. Must be `custom`.
*/
readonly provider: "custom";
/**
* The Provider to provide UpdateInfo regarding available updates. Required
* to use custom providers with electron-updater.
*/
updateProvider?: new (options: CustomPublishOptions, updater: any, runtimeOptions: any) => any;
[index: string]: any;
}
/**
* [GitHub](https://help.github.com/articles/about-releases/) options.
*
* GitHub [personal access token](https://help.github.com/articles/creating-an-access-token-for-command-line-use/) is required. You can generate by going to [https://github.com/settings/tokens/new](https://github.com/settings/tokens/new). The access token should have the repo scope/permission.
* Define `GH_TOKEN` environment variable.
*/
export interface GithubOptions extends PublishConfiguration {
/**
* The provider. Must be `github`.
*/
readonly provider: "github";
/**
* The repository name. [Detected automatically](#github-repository-and-bintray-package).
*/
readonly repo?: string | null;
/**
* The owner.
*/
readonly owner?: string | null;
/**
* If defined, sets the prefix of the tag name that comes before the semver number.
* e.g. "v" in "v1.2.3" or "test" of "test1.2.3".
* @default "v"
*/
readonly tagNamePrefix?: string;
/**
* The host (including the port if need).
* @default github.com
*/
readonly host?: string | null;
/**
* The protocol. GitHub Publisher supports only `https`.
* @default https
*/
readonly protocol?: "https" | "http" | null;
/**
* The access token to support auto-update from private github repositories. Never specify it in the configuration files. Only for [setFeedURL](https://www.electron.build/auto-update#appupdatersetfeedurloptions).
*/
readonly token?: string | null;
/**
* Whether to use private github auto-update provider if `GH_TOKEN` environment variable is defined. See [Private GitHub Update Repo](https://www.electron.build/auto-update#private-github-update-repo).
*/
readonly private?: boolean | null;
/**
* The channel.
* @default latest
*/
readonly channel?: string | null;
/**
* The type of release. By default `draft` release will be created.
*
* Also you can set release type using environment variable. If `EP_DRAFT`is set to `true` — `draft`, if `EP_PRE_RELEASE`is set to `true` — `prerelease`.
* @default draft
*/
releaseType?: "draft" | "prerelease" | "release" | null;
}
/** @private */
export declare function githubUrl(options: GithubOptions, defaultHost?: string): string;
export declare function githubTagPrefix(options: GithubOptions): string;
/**
* [GitLab](https://docs.gitlab.com/ee/user/project/releases/) options.
*
* GitLab [personal access token](https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html) is required for private repositories. You can generate one by going to your GitLab profile settings.
* Define `GITLAB_TOKEN` environment variable.
*/
export interface GitlabOptions extends PublishConfiguration {
/**
* The provider. Must be `gitlab`.
*/
readonly provider: "gitlab";
/**
* The GitLab project ID or path (e.g., "12345678" or "namespace/project").
*/
readonly projectId?: string | number | null;
/**
* The GitLab host (including the port if need).
* @default gitlab.com
*/
readonly host?: string | null;
/**
* The access token to support auto-update from private GitLab repositories. Never specify it in the configuration files.
*/
readonly token?: string | null;
/**
* Whether to use `v`-prefixed tag name.
* @default true
*/
readonly vPrefixedTagName?: boolean;
/**
* The channel.
* @default latest
*/
readonly channel?: string | null;
/**
* Upload target method. Can be "project_upload" for GitLab project uploads or "generic_package" for GitLab generic packages.
* @default "project_upload"
*/
readonly uploadTarget?: "project_upload" | "generic_package" | null;
}
/**
* Generic (any HTTP(S) server) options.
* In all publish options [File Macros](https://www.electron.build/file-patterns#file-macros) are supported.
*/
export interface GenericServerOptions extends PublishConfiguration {
/**
* The provider. Must be `generic`.
*/
readonly provider: "generic";
/**
* The base url. e.g. `https://bucket_name.s3.amazonaws.com`.
*/
readonly url: string;
/**
* The channel.
* @default latest
*/
readonly channel?: string | null;
/**
* Whether to use multiple range requests for differential update. Defaults to `true` if `url` doesn't contain `s3.amazonaws.com`.
*/
readonly useMultipleRangeRequest?: boolean;
}
/**
* Keygen options.
* https://keygen.sh/
* Define `KEYGEN_TOKEN` environment variable.
*/
export interface KeygenOptions extends PublishConfiguration {
/**
* The provider. Must be `keygen`.
*/
readonly provider: "keygen";
/**
* Keygen host for self-hosted instances
* @default "api.keygen.sh"
*/
readonly host?: string;
/**
* Keygen account's UUID
*/
readonly account: string;
/**
* Keygen product's UUID
*/
readonly product: string;
/**
* The channel.
* @default stable
*/
readonly channel?: "stable" | "rc" | "beta" | "alpha" | "dev" | null;
/**
* The target Platform. Is set programmatically explicitly during publishing.
*/
readonly platform?: string | null;
}
/**
* Bitbucket options.
* https://bitbucket.org/
* Define `BITBUCKET_TOKEN` environment variable.
*
* For converting an app password to a usable token, you can utilize this
```typescript
convertAppPassword(owner: string, appPassword: string) {
const base64encodedData = Buffer.from(`${owner}:${appPassword.trim()}`).toString("base64")
return `Basic ${base64encodedData}`
}
```
*/
export interface BitbucketOptions extends PublishConfiguration {
/**
* The provider. Must be `bitbucket`.
*/
readonly provider: "bitbucket";
/**
* Repository owner
*/
readonly owner: string;
/**
* The [app password](https://bitbucket.org/account/settings/app-passwords) to support auto-update from private bitbucket repositories.
*/
readonly token?: string | null;
/**
* The user name to support auto-update from private bitbucket repositories.
*/
readonly username?: string | null;
/**
* Repository slug/name
*/
readonly slug: string;
/**
* The channel.
* @default latest
*/
readonly channel?: string | null;
}
/**
* [Snap Store](https://snapcraft.io/) options. To publish directly to Snapcraft, see <a href="https://snapcraft.io/docs/snapcraft-authentication">Snapcraft authentication options</a> for local or CI/CD authentication options.
*/
export interface SnapStoreOptions extends PublishConfiguration {
/**
* The provider. Must be `snapStore`.
*/
readonly provider: "snapStore";
/**
* snapcraft repo name
*/
readonly repo?: string;
/**
* The list of channels the snap would be released.
* @default ["edge"]
*/
readonly channels?: string | Array<string> | null;
}
export interface BaseS3Options extends PublishConfiguration {
/**
* The update channel.
* @default latest
*/
channel?: string | null;
/**
* The directory path.
* @default /
*/
readonly path?: string | null;
/**
* The ACL. Set to `null` to not [add](https://github.com/electron-userland/electron-builder/issues/1822).
*
* @default public-read
*/
readonly acl?: "private" | "public-read" | null;
}
/**
* [Amazon S3](https://aws.amazon.com/s3/) options.
* AWS credentials are required, please see [getting your credentials](http://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/getting-your-credentials.html).
* To set credentials define `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` [environment variables](http://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/loading-node-credentials-environment.html) directly,
* or use [~/.aws/credentials](http://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/loading-node-credentials-shared.html) file,
* or use [~/.aws/config](https://docs.aws.amazon.com/sdkref/latest/guide/file-format.html) file. For the last method to work you will also need to define `AWS_SDK_LOAD_CONFIG=1` environment variable.
*
* Example configuration:
*
```json
{
"build":
"publish": {
"provider": "s3",
"bucket": "bucket-name"
}
}
}
```
*/
export interface S3Options extends BaseS3Options {
/**
* The provider. Must be `s3`.
*/
readonly provider: "s3";
/**
* The bucket name.
*/
readonly bucket: string;
/**
* The region. Is determined and set automatically when publishing.
*/
region?: string | null;
/**
* The ACL. Set to `null` to not [add](https://github.com/electron-userland/electron-builder/issues/1822).
*
* Please see [required permissions for the S3 provider](https://github.com/electron-userland/electron-builder/issues/1618#issuecomment-314679128).
*
* @default public-read
*/
readonly acl?: "private" | "public-read" | null;
/**
* The type of storage to use for the object.
* @default STANDARD
*/
readonly storageClass?: "STANDARD" | "REDUCED_REDUNDANCY" | "STANDARD_IA" | null;
/**
* Server-side encryption algorithm to use for the object.
*/
readonly encryption?: "AES256" | "aws:kms" | null;
/**
* The endpoint URI to send requests to. The default endpoint is built from the configured region.
* The endpoint should be a string like `https://{service}.{region}.amazonaws.com`.
*/
readonly endpoint?: string | null;
/**
* If set to true, this will enable the s3 accelerated endpoint
* These endpoints have a particular format of:
* ${bucketname}.s3-accelerate.amazonaws.com
*/
readonly accelerate?: boolean;
/**
* When true, force a path-style endpoint to be used where the bucket name is part of the path.
* [Path-style Access](https://docs.aws.amazon.com/AmazonS3/latest/userguide/VirtualHosting.html#path-style-access)
*/
readonly forcePathStyle?: boolean;
}
/**
* [DigitalOcean Spaces](https://www.digitalocean.com/community/tutorials/an-introduction-to-digitalocean-spaces) options.
* Access key is required, define `DO_KEY_ID` and `DO_SECRET_KEY` environment variables.
*/
export interface SpacesOptions extends BaseS3Options {
/**
* The provider. Must be `spaces`.
*/
readonly provider: "spaces";
/**
* The space name.
*/
readonly name: string;
/**
* The region (e.g. `nyc3`).
*/
readonly region: string;
}
export interface GitlabReleaseInfo {
name: string;
tag_name: string;
description: string;
created_at: string;
released_at: string;
upcoming_release: boolean;
assets: GitlabReleaseAsset;
}
export interface GitlabReleaseAsset {
count: number;
sources: Array<{
format: string;
url: string;
}>;
links: Array<{
id: number;
name: string;
url: string;
direct_asset_url: string;
link_type: string;
}>;
}
export declare function getS3LikeProviderBaseUrl(configuration: PublishConfiguration): string;
//# sourceMappingURL=publishOptions.d.ts.map
{"version":3,"file":"publishOptions.d.ts","sourceRoot":"","sources":["../src/publishOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAA;AAG1C,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,QAAQ,GAAG,IAAI,GAAG,Q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G,IAAI,CAAA;IAEjC;;;;OAIG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAA;IAE7B;;;OAGG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAA;CAClC;AAED;;;GAGG;AACH,MAAM,WAAW,aAAc,SAAQ,aAAa;IAClD;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAA;IAE3B;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IAErB;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CACxB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;IACnB,gBAAgB,EAAE,OAAO,CAAA;IACzB,MAAM,EAAE,kBAAkB,CAAA;CAC3B;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,KAAK,CAAC;QACb,MAAM,EAAE,MAAM,CAAA;QACd,GAAG,EAAE,MAAM,CAAA;KACZ,CAAC,CAAA;IACF,KAAK,EAAE,KAAK,CAAC;QACX,EAAE,EAAE,MAAM,CAAA;QACV,IAAI,EAAE,MAAM,CAAA;QACZ,GAAG,EAAE,MAAM,CAAA;QACX,gBAAgB,EAAE,MAAM,CAAA;QACxB,SAAS,EAAE,MAAM,CAAA;KAClB,CAAC,CAAA;CACH;AAED,wBAAgB,wBAAwB,CAAC,aAAa,EAAE,oBAAoB,UAS3E"}
/** @private */
export function githubUrl(options, defaultHost = "github.com") {
return `${options.protocol || "https"}://${options.host || defaultHost}`;
}
export function githubTagPrefix(options) {
return options.tagNamePrefix ?? "v";
}
export 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}`);
}
function s3Url(options) {
let url;
if (options.accelerate == true) {
url = `https://${options.bucket}.s3-accelerate.amazonaws.com`;
}
else if (options.endpoint != null) {
url = `${options.endpoint}/${options.bucket}`;
}
else if (options.bucket.includes(".")) {
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
if (options.region === "us-east-1") {
url = `https://s3.amazonaws.com/${options.bucket}`;
}
else {
url = `https://s3-${options.region}.amazonaws.com/${options.bucket}`;
}
}
else if (options.region === "cn-north-1") {
url = `https://${options.bucket}.s3.${options.region}.amazonaws.com.cn`;
}
else {
url = `https://${options.bucket}.s3.amazonaws.com`;
}
return appendPath(url, options.path);
}
function appendPath(url, p) {
if (p != null && p.length > 0) {
if (!p.startsWith("/")) {
url += "/";
}
url += p;
}
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`);
}
return appendPath(`https://${options.name}.${options.region}.digitaloceanspaces.com`, options.path);
}
//# sourceMappingURL=publishOptions.js.map
{"version":3,"file":"publishOptions.js","sourceRoot":"","sources":["../src/publishOptions.ts"],"names":[],"mappings":"AA6IA,eAAe;AACf,MAAM,UAAU,SAAS,CAAC,OAAsB,EAAE,WAAW,GAAG,YAAY;IAC1E,OAAO,GAAG,OAAO,CAAC,QAAQ,IAAI,OAAO,MAAM,OAAO,CAAC,IAAI,IAAI,WAAW,EAAE,CAAA;AAC1E,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,OAAsB;IACpD,OAAO,OAAO,CAAC,aAAa,IAAI,GAAG,CAAA;AACrC,CAAC;AAqUD,MAAM,UAAU,wBAAwB,CAAC,aAAmC;IAC1E,MAAM,QAAQ,GAAG,aAAa,CAAC,QAAQ,CAAA;IACvC,IAAI,QAAQ,KAAK,IAAI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AC,MAAM,mBAAmB,CAAA;IACpD,CAAC;IACD,OAAO,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,CAAC,CAAA;AACtC,CAAC;AAED,SAAS,UAAU,CAAC,GAAW,EAAE,CAAmB;IAClD,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC9B,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACvB,GAAG,IAAI,GAAG,CAAA;QACZ,CAAC;QACD,GAAG,IAAI,CAAC,CAAA;IACV,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AAED,SAAS,SAAS,CAAC,OAAsB;IACvC,IAAI,OAAO,CAAC,IAAI,IAAI,IAAI,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAA;IACpC,CAAC;IACD,IAAI,OAAO,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAA;IACtC,CAAC;IACD,OAAO,UAAU,CAAC,WAAW,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,MAAM,yBAAyB,EAAE,OAAO,CAAC,IAAI,CAAC,CAAA;AACrG,CAAC","sourcesContent":["import { OutgoingHttpHeaders } from \"http\"\nimport { Nullish } from \"./index.js\"\n\nexport type PublishProvider = \"github\" | \"gitlab\" | \"s3\" | \"spaces\" | \"generic\" | \"custom\" | \"snapStore\" | \"keygen\" | \"bitbucket\"\n\n// typescript-json-schema generates only PublishConfiguration if it is specified in the list, so, it is not added here\nexport type AllPublishOptions =\n | string\n | GithubOptions\n | GitlabOptions\n | S3Options\n | SpacesOptions\n | GenericServerOptions\n | CustomPublishOptions\n | KeygenOptions\n | SnapStoreOptions\n | BitbucketOptions\n\nexport interface PublishConfiguration {\n /**\n * The provider.\n */\n readonly provider: PublishProvider\n\n /**\n * @private\n * win-only\n */\n publisherName?: Array<string> | null\n\n /**\n * @private\n * win-only\n */\n readonly updaterCacheDirName?: string | null\n\n /**\n * Whether to publish auto update info files.\n *\n * Auto update relies only on the first provider in the list (you can specify several publishers).\n * Thus, probably, there`s no need to upload the metadata files for the other configured providers. But by default will be uploaded.\n *\n * @default true\n */\n readonly publishAutoUpdate?: boolean\n\n /**\n * Any custom request headers\n */\n readonly requestHeaders?: OutgoingHttpHeaders\n\n /**\n * Request timeout in milliseconds. (Default is 2 minutes; O is ignored)\n *\n * @default 120000\n */\n readonly timeout?: number | null\n}\n\n// https://github.com/electron-userland/electron-builder/issues/3261\nexport interface CustomPublishOptions extends PublishConfiguration {\n /**\n * The provider. Must be `custom`.\n */\n readonly provider: \"custom\"\n\n /**\n * The Provider to provide UpdateInfo regarding available updates. Required\n * to use custom providers with electron-updater.\n */\n updateProvider?: new (options: CustomPublishOptions, updater: any, runtimeOptions: any) => any\n\n [index: string]: any\n}\n\n/**\n * [GitHub](https://help.github.com/articles/about-releases/) options.\n *\n * GitHub [personal access token](https://help.github.com/articles/creating-an-access-token-for-command-line-use/) is required. You can generate by going to [https://github.com/settings/tokens/new](https://github.com/settings/tokens/new). The access token should have the repo scope/permission.\n * Define `GH_TOKEN` environment variable.\n */\nexport interface GithubOptions extends PublishConfiguration {\n /**\n * The provider. Must be `github`.\n */\n readonly provider: \"github\"\n\n /**\n * The repository name. [Detected automatically](#github-repository-and-bintray-package).\n */\n readonly repo?: string | null\n\n /**\n * The owner.\n */\n readonly owner?: string | null\n\n /**\n * If defined, sets the prefix of the tag name that comes before the semver number.\n * e.g. \"v\" in \"v1.2.3\" or \"test\" of \"test1.2.3\".\n * @default \"v\"\n */\n readonly tagNamePrefix?: string\n\n /**\n * The host (including the port if need).\n * @default github.com\n */\n readonly host?: string | null\n\n /**\n * The protocol. GitHub Publisher supports only `https`.\n * @default https\n */\n readonly protocol?: \"https\" | \"http\" | null\n\n /**\n * The access token to support auto-update from private github repositories. Never specify it in the configuration files. Only for [setFeedURL](https://www.electron.build/auto-update#appupdatersetfeedurloptions).\n */\n readonly token?: string | null\n\n /**\n * Whether to use private github auto-update provider if `GH_TOKEN` environment variable is defined. See [Private GitHub Update Repo](https://www.electron.build/auto-update#private-github-update-repo).\n */\n readonly private?: boolean | null\n\n /**\n * The channel.\n * @default latest\n */\n readonly channel?: string | null\n\n /**\n * The type of release. By default `draft` release will be created.\n *\n * Also you can set release type using environment variable. If `EP_DRAFT`is set to `true` — `draft`, if `EP_PRE_RELEASE`is set to `true` — `prerelease`.\n * @default draft\n */\n releaseType?: \"draft\" | \"prerelease\" | \"release\" | null\n}\n\n/** @private */\nexport function githubUrl(options: GithubOptions, defaultHost = \"github.com\") {\n return `${options.protocol || \"https\"}://${options.host || defaultHost}`\n}\n\nexport function githubTagPrefix(options: GithubOptions) {\n return options.tagNamePrefix ?? \"v\"\n}\n\n/**\n * [GitLab](https://docs.gitlab.com/ee/user/project/releases/) options.\n *\n * GitLab [personal access token](https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html) is required for private repositories. You can generate one by going to your GitLab profile settings.\n * Define `GITLAB_TOKEN` environment variable.\n */\nexport interface GitlabOptions extends PublishConfiguration {\n /**\n * The provider. Must be `gitlab`.\n */\n readonly provider: \"gitlab\"\n\n /**\n * The GitLab project ID or path (e.g., \"12345678\" or \"namespace/project\").\n */\n readonly projectId?: string | number | null\n\n /**\n * The GitLab host (including the port if need).\n * @default gitlab.com\n */\n readonly host?: string | null\n\n /**\n * The access token to support auto-update from private GitLab repositories. Never specify it in the configuration files.\n */\n readonly token?: string | null\n\n /**\n * Whether to use `v`-prefixed tag name.\n * @default true\n */\n readonly vPrefixedTagName?: boolean\n\n /**\n * The channel.\n * @default latest\n */\n readonly channel?: string | null\n\n /**\n * Upload target method. Can be \"project_upload\" for GitLab project uploads or \"generic_package\" for GitLab generic packages.\n * @default \"project_upload\"\n */\n readonly uploadTarget?: \"project_upload\" | \"generic_package\" | null\n}\n\n/**\n * Generic (any HTTP(S) server) options.\n * In all publish options [File Macros](https://www.electron.build/file-patterns#file-macros) are supported.\n */\nexport interface GenericServerOptions extends PublishConfiguration {\n /**\n * The provider. Must be `generic`.\n */\n readonly provider: \"generic\"\n\n /**\n * The base url. e.g. `https://bucket_name.s3.amazonaws.com`.\n */\n readonly url: string\n\n /**\n * The channel.\n * @default latest\n */\n readonly channel?: string | null\n\n /**\n * Whether to use multiple range requests for differential update. Defaults to `true` if `url` doesn't contain `s3.amazonaws.com`.\n */\n readonly useMultipleRangeRequest?: boolean\n}\n\n/**\n * Keygen options.\n * https://keygen.sh/\n * Define `KEYGEN_TOKEN` environment variable.\n */\nexport interface KeygenOptions extends PublishConfiguration {\n /**\n * The provider. Must be `keygen`.\n */\n readonly provider: \"keygen\"\n\n /**\n * Keygen host for self-hosted instances\n * @default \"api.keygen.sh\"\n */\n readonly host?: string\n\n /**\n * Keygen account's UUID\n */\n readonly account: string\n\n /**\n * Keygen product's UUID\n */\n readonly product: string\n\n /**\n * The channel.\n * @default stable\n */\n readonly channel?: \"stable\" | \"rc\" | \"beta\" | \"alpha\" | \"dev\" | null\n\n /**\n * The target Platform. Is set programmatically explicitly during publishing.\n */\n readonly platform?: string | null\n}\n\n/**\n * Bitbucket options.\n * https://bitbucket.org/\n * Define `BITBUCKET_TOKEN` environment variable.\n *\n * For converting an app password to a usable token, you can utilize this\n```typescript\nconvertAppPassword(owner: string, appPassword: string) {\n const base64encodedData = Buffer.from(`${owner}:${appPassword.trim()}`).toString(\"base64\")\n return `Basic ${base64encodedData}`\n}\n```\n */\nexport interface BitbucketOptions extends PublishConfiguration {\n /**\n * The provider. Must be `bitbucket`.\n */\n readonly provider: \"bitbucket\"\n\n /**\n * Repository owner\n */\n readonly owner: string\n\n /**\n * The [app password](https://bitbucket.org/account/settings/app-passwords) to support auto-update from private bitbucket repositories.\n */\n readonly token?: string | null\n\n /**\n * The user name to support auto-update from private bitbucket repositories.\n */\n readonly username?: string | null\n\n /**\n * Repository slug/name\n */\n readonly slug: string\n\n /**\n * The channel.\n * @default latest\n */\n readonly channel?: string | null\n}\n\n/**\n * [Snap Store](https://snapcraft.io/) options. To publish directly to Snapcraft, see <a href=\"https://snapcraft.io/docs/snapcraft-authentication\">Snapcraft authentication options</a> for local or CI/CD authentication options.\n */\nexport interface SnapStoreOptions extends PublishConfiguration {\n /**\n * The provider. Must be `snapStore`.\n */\n readonly provider: \"snapStore\"\n\n /**\n * snapcraft repo name\n */\n readonly repo?: string\n\n /**\n * The list of channels the snap would be released.\n * @default [\"edge\"]\n */\n readonly channels?: string | Array<string> | null\n}\n\nexport interface BaseS3Options extends PublishConfiguration {\n /**\n * The update channel.\n * @default latest\n */\n channel?: string | null\n\n /**\n * The directory path.\n * @default /\n */\n readonly path?: string | null\n\n /**\n * The ACL. Set to `null` to not [add](https://github.com/electron-userland/electron-builder/issues/1822).\n *\n * @default public-read\n */\n readonly acl?: \"private\" | \"public-read\" | null\n}\n\n/**\n * [Amazon S3](https://aws.amazon.com/s3/) options.\n * AWS credentials are required, please see [getting your credentials](http://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/getting-your-credentials.html).\n * To set credentials define `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` [environment variables](http://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/loading-node-credentials-environment.html) directly,\n * or use [~/.aws/credentials](http://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/loading-node-credentials-shared.html) file,\n * or use [~/.aws/config](https://docs.aws.amazon.com/sdkref/latest/guide/file-format.html) file. For the last method to work you will also need to define `AWS_SDK_LOAD_CONFIG=1` environment variable.\n *\n * Example configuration:\n *\n```json\n{\n \"build\":\n \"publish\": {\n \"provider\": \"s3\",\n \"bucket\": \"bucket-name\"\n }\n }\n}\n```\n */\nexport interface S3Options extends BaseS3Options {\n /**\n * The provider. Must be `s3`.\n */\n readonly provider: \"s3\"\n\n /**\n * The bucket name.\n */\n readonly bucket: string\n\n /**\n * The region. Is determined and set automatically when publishing.\n */\n region?: string | null\n\n /**\n * The ACL. Set to `null` to not [add](https://github.com/electron-userland/electron-builder/issues/1822).\n *\n * Please see [required permissions for the S3 provider](https://github.com/electron-userland/electron-builder/issues/1618#issuecomment-314679128).\n *\n * @default public-read\n */\n readonly acl?: \"private\" | \"public-read\" | null\n\n /**\n * The type of storage to use for the object.\n * @default STANDARD\n */\n readonly storageClass?: \"STANDARD\" | \"REDUCED_REDUNDANCY\" | \"STANDARD_IA\" | null\n\n /**\n * Server-side encryption algorithm to use for the object.\n */\n readonly encryption?: \"AES256\" | \"aws:kms\" | null\n\n /**\n * The endpoint URI to send requests to. The default endpoint is built from the configured region.\n * The endpoint should be a string like `https://{service}.{region}.amazonaws.com`.\n */\n readonly endpoint?: string | null\n\n /**\n * If set to true, this will enable the s3 accelerated endpoint\n * These endpoints have a particular format of:\n * ${bucketname}.s3-accelerate.amazonaws.com\n */\n readonly accelerate?: boolean\n\n /**\n * When true, force a path-style endpoint to be used where the bucket name is part of the path.\n * [Path-style Access](https://docs.aws.amazon.com/AmazonS3/latest/userguide/VirtualHosting.html#path-style-access)\n */\n readonly forcePathStyle?: boolean\n}\n\n/**\n * [DigitalOcean Spaces](https://www.digitalocean.com/community/tutorials/an-introduction-to-digitalocean-spaces) options.\n * Access key is required, define `DO_KEY_ID` and `DO_SECRET_KEY` environment variables.\n */\nexport interface SpacesOptions extends BaseS3Options {\n /**\n * The provider. Must be `spaces`.\n */\n readonly provider: \"spaces\"\n\n /**\n * The space name.\n */\n readonly name: string\n\n /**\n * The region (e.g. `nyc3`).\n */\n readonly region: string\n}\n\nexport interface GitlabReleaseInfo {\n name: string\n tag_name: string\n description: string\n created_at: string\n released_at: string\n upcoming_release: boolean\n assets: GitlabReleaseAsset\n}\n\nexport interface GitlabReleaseAsset {\n count: number\n sources: Array<{\n format: string\n url: string\n }>\n links: Array<{\n id: number\n name: string\n url: string\n direct_asset_url: string\n link_type: string\n }>\n}\n\nexport function getS3LikeProviderBaseUrl(configuration: PublishConfiguration) {\n const provider = configuration.provider\n if (provider === \"s3\") {\n return s3Url(configuration as S3Options)\n }\n if (provider === \"spaces\") {\n return spacesUrl(configuration as SpacesOptions)\n }\n throw new Error(`Not supported provider: ${provider}`)\n}\n\nfunction s3Url(options: S3Options) {\n let url: string\n if (options.accelerate == true) {\n url = `https://${options.bucket}.s3-accelerate.amazonaws.com`\n } else if (options.endpoint != null) {\n url = `${options.endpoint}/${options.bucket}`\n } else if (options.bucket.includes(\".\")) {\n if (options.region == null) {\n throw new Error(`Bucket name \"${options.bucket}\" includes a dot, but S3 region is missing`)\n }\n\n // special case, see http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingBucket.html#access-bucket-intro\n if (options.region === \"us-east-1\") {\n url = `https://s3.amazonaws.com/${options.bucket}`\n } else {\n url = `https://s3-${options.region}.amazonaws.com/${options.bucket}`\n }\n } else if (options.region === \"cn-north-1\") {\n url = `https://${options.bucket}.s3.${options.region}.amazonaws.com.cn`\n } else {\n url = `https://${options.bucket}.s3.amazonaws.com`\n }\n return appendPath(url, options.path)\n}\n\nfunction appendPath(url: string, p: string | Nullish): string {\n if (p != null && p.length > 0) {\n if (!p.startsWith(\"/\")) {\n url += \"/\"\n }\n url += p\n }\n return url\n}\n\nfunction spacesUrl(options: SpacesOptions) {\n if (options.name == null) {\n throw new Error(`name is missing`)\n }\n if (options.region == null) {\n throw new Error(`region is missing`)\n }\n return appendPath(`https://${options.name}.${options.region}.digitaloceanspaces.com`, options.path)\n}\n"]}
import { setTimeout as sleep } from "timers/promises";
export { sleep };
import { CancellationToken } from "./CancellationToken.js";
export declare function retry<T>(task: () => Promise<T>, options: {
retries: number;
interval: number;
backoff?: number;
attempt?: number;
cancellationToken?: CancellationToken;
shouldRetry?: (e: any) => boolean | Promise<boolean>;
}): Promise<T>;
//# sourceMappingURL=retry.d.ts.map
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,IAAI,KAAK,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,EAAE,KAAK,EAAE,CAAA;AAEhB,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAE1D,wBAAsB,KAAK,CAAC,CAAC,EAC3B,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACtB,OAAO,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IAAC,WAAW,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;CAAE,GAC9K,OAAO,CAAC,CAAC,CAAC,CAYZ"}
import { setTimeout as sleep } from "timers/promises";
export { sleep };
import { CancellationToken } from "./CancellationToken.js";
export async function retry(task, options) {
const { retries: retryCount, interval, backoff = 0, attempt = 0, shouldRetry, cancellationToken = new CancellationToken() } = options;
try {
return await task();
}
catch (error) {
if ((await Promise.resolve(shouldRetry?.(error) ?? true)) && retryCount > 0 && !cancellationToken.cancelled) {
await sleep(interval + backoff * attempt);
return await retry(task, { ...options, retries: retryCount - 1, attempt: attempt + 1 });
}
else {
throw error;
}
}
}
//# sourceMappingURL=retry.js.map
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,IAAI,KAAK,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,EAAE,KAAK,EAAE,CAAA;AAEhB,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAE1D,MAAM,CAAC,KAAK,UAAU,KAAK,CACzB,IAAsB,EACtB,OAA+K;IAE/K,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,GAAG,CAAC,EAAE,OAAO,GAAG,CAAC,EAAE,WAAW,EAAE,iBAAiB,GAAG,IAAI,iBAAiB,EAAE,EAAE,GAAG,OAAO,CAAA;IACrI,IAAI,CAAC;QACH,OAAO,MAAM,IAAI,EAAE,CAAA;IACrB,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,IAAI,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,UAAU,GAAG,CAAC,IAAI,CAAC,iBAAiB,CAAC,SAAS,EAAE,CAAC;YAC5G,MAAM,KAAK,CAAC,QAAQ,GAAG,OAAO,GAAG,OAAO,CAAC,CAAA;YACzC,OAAO,MAAM,KAAK,CAAC,IAAI,EAAE,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,UAAU,GAAG,CAAC,EAAE,OAAO,EAAE,OAAO,GAAG,CAAC,EAAE,CAAC,CAAA;QACzF,CAAC;aAAM,CAAC;YACN,MAAM,KAAK,CAAA;QACb,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import { setTimeout as sleep } from \"timers/promises\"\nexport { sleep }\n\nimport { CancellationToken } from \"./CancellationToken.js\"\n\nexport async function retry<T>(\n task: () => Promise<T>,\n options: { retries: number; interval: number; backoff?: number; attempt?: number; cancellationToken?: CancellationToken; shouldRetry?: (e: any) => boolean | Promise<boolean> }\n): Promise<T> {\n const { retries: retryCount, interval, backoff = 0, attempt = 0, shouldRetry, cancellationToken = new CancellationToken() } = options\n try {\n return await task()\n } catch (error: any) {\n if ((await Promise.resolve(shouldRetry?.(error) ?? true)) && retryCount > 0 && !cancellationToken.cancelled) {\n await sleep(interval + backoff * attempt)\n return await retry(task, { ...options, retries: retryCount - 1, attempt: attempt + 1 })\n } else {\n throw error\n }\n }\n}\n"]}
export declare function parseDn(seq: string): Map<string, string>;
//# sourceMappingURL=rfc2253Parser.d.ts.map
{"version":3,"file":"rfc2253Parser.d.ts","sourceRoot":"","sources":["../src/rfc2253Parser.ts"],"names":[],"mappings":"AAAA,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAqFxD"}
export 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;
}
}
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;
}
}
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
{"version":3,"file":"rfc2253Parser.js","sourceRoot":"","sources":["../src/rfc2253Parser.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,OAAO,CAAC,GAAW;IACjC,IAAI,MAAM,GAAG,KAAK,CAAA;IAClB,IAAI,GAAG,GAAkB,IAAI,CAAA;IAC7B,IAAI,KAAK,GAAG,EAAE,CAAA;IACd,IAAI,YAAY,GAAG,CAAC,CAAA;IAEpB,GAAG,GAAG,GAAG,CAAC,IAAI,EAAE,CAAA;IAChB,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAA;IACxC,KAAK,IAAI,CAA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KAAK,GAAG,EAAE,CAAC;gBAC3C,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;oBACjB,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;gBACxB,CAAC;gBACD,GAAG,GAAG,IAAI,CAAA;gBACV,KAAK,GAAG,EAAE,CAAA;gBACV,SAAQ;YACV,CAAC;QACH,CAAC;QAED,IAAI,EAAE,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;YAC1B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACvB,SAAQ;YACV,CAAC;YAED,IAAI,CAAC,GAAG,YAAY,EAAE,CAAC;gBACrB,IAAI,CAAC,GAAG,CAAC,CAAA;gBACT,OAAO,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;oBACtB,CAAC,EAAE,CAAA;gBACL,CAAC;gBACD,YAAY,GAAG,CAAC,CAAA;YAClB,CAAC;YAED,IACE,YAAY,IAAI,GAAG,CAAC,MAAM;gBAC1B,GAAG,CAAC,YAAY,CAAC,KAAK,GAAG;gBACzB,GAAG,CAAC,YAAY,CAAC,KAAK,GAAG;gBACzB,CAAC,GAAG,KAAK,IAAI,IAAI,GAAG,CAAC,YAAY,CAAC,KAAK,GAAG,CAAC;gBAC3C,CAAC,GAAG,KAAK,IAAI,IAAI,GAAG,CAAC,YAAY,CAAC,KAAK,GAAG,CAAC,EAC3C,CAAC;gBACD,CAAC,GAAG,YAAY,GAAG,CAAC,CAAA;gBACpB,SAAQ;YACV,CAAC;QACH,CAAC;QAED,KAAK,IAAI,EAAE,CAAA;IACb,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["export function parseDn(seq: string): Map<string, string> {\n let quoted = false\n let key: string | null = null\n let token = \"\"\n let nextNonSpace = 0\n\n seq = seq.trim()\n const result = new Map<string, string>()\n for (let i = 0; i <= seq.length; i++) {\n if (i === seq.length) {\n if (key !== null) {\n result.set(key, token)\n }\n break\n }\n\n const ch = seq[i]\n if (quoted) {\n if (ch === '\"') {\n quoted = false\n continue\n }\n } else {\n if (ch === '\"') {\n quoted = true\n continue\n }\n\n if (ch === \"\\\\\") {\n i++\n const ord = parseInt(seq.slice(i, i + 2), 16)\n if (Number.isNaN(ord)) {\n token += seq[i]\n } else {\n i++\n token += String.fromCharCode(ord)\n }\n continue\n }\n\n if (key === null && ch === \"=\") {\n key = token\n token = \"\"\n continue\n }\n\n if (ch === \",\" || ch === \";\" || ch === \"+\") {\n if (key !== null) {\n result.set(key, token)\n }\n key = null\n token = \"\"\n continue\n }\n }\n\n if (ch === \" \" && !quoted) {\n if (token.length === 0) {\n continue\n }\n\n if (i > nextNonSpace) {\n let j = i\n while (seq[j] === \" \") {\n j++\n }\n nextNonSpace = j\n }\n\n if (\n nextNonSpace >= seq.length ||\n seq[nextNonSpace] === \",\" ||\n seq[nextNonSpace] === \";\" ||\n (key === null && seq[nextNonSpace] === \"=\") ||\n (key !== null && seq[nextNonSpace] === \"+\")\n ) {\n i = nextNonSpace - 1\n continue\n }\n }\n\n token += ch\n }\n\n return result\n}\n"]}
export interface ReleaseNoteInfo {
/**
* The version.
*/
readonly version: string;
/**
* The note.
*/
readonly note: string | null;
}
export interface BlockMapDataHolder {
/**
* The file size. Used to verify downloaded size (save one HTTP request to get length).
* Also used when block map data is embedded into the file (appimage, windows web installer package).
*/
size?: number;
/**
* The block map file size. Used when block map data is embedded into the file (appimage, windows web installer package).
* This information can be obtained from the file itself, but it requires additional HTTP request,
* so, to reduce request count, block map size is specified in the update metadata too.
*/
blockMapSize?: number;
/**
* The file checksum.
*/
readonly sha512: string;
readonly isAdminRightsRequired?: boolean;
}
export interface PackageFileInfo extends BlockMapDataHolder {
readonly path: string;
}
export interface UpdateFileInfo extends BlockMapDataHolder {
url: string;
}
export interface UpdateInfo {
/**
* The version.
*/
readonly version: string;
readonly files: Array<UpdateFileInfo>;
/** @deprecated */
readonly path: string;
/** @deprecated */
readonly sha512: string;
/**
* The release name.
*/
releaseName?: string | null;
/**
* The release notes. List if `updater.fullChangelog` is set to `true`, `string` otherwise.
*/
releaseNotes?: string | Array<ReleaseNoteInfo> | null;
/**
* The release date.
*/
releaseDate: string;
/**
* The [staged rollout](https://www.electron.build/auto-update#staged-rollouts) percentage, 0-100.
*/
readonly stagingPercentage?: number;
/**
* The minimum version of system required for the app to run. Sample value: macOS `23.1.0`, Windows `10.0.22631`.
* Same with os.release() value, this is a kernel version.
*/
readonly minimumSystemVersion?: string;
}
export interface WindowsUpdateInfo extends UpdateInfo {
packages?: {
[arch: string]: PackageFileInfo;
} | null;
/**
* @deprecated
* @private
*/
sha2?: string;
}
//# sourceMappingURL=updateInfo.d.ts.map
{"version":3,"file":"updateInfo.d.ts","sourceRoot":"","sources":["../src/updateInfo.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IAExB;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;CAC7B;AAED,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IAEb;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IAErB;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IAEvB,QAAQ,CAAC,qBAAqB,CAAC,EAAE,OAAO,CAAA;CACzC;AAED,MAAM,WAAW,eAAgB,SAAQ,kBAAkB;IACzD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACtB;AAED,MAAM,WAAW,cAAe,SAAQ,kBAAkB;IACxD,GAAG,EAAE,MAAM,CAAA;CACZ;AAED,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IAExB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,CAAA;IAErC,kBAAkB;IAClB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IAErB,kBAAkB;IAClB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IAEvB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAE3B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,eAAe,CAAC,GAAG,IAAI,CAAA;IAErD;;OAEG;IACH,WAAW,EAAE,MAAM,CAAA;IAEnB;;OAEG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAEnC;;;OAGG;IACH,QAAQ,CAAC,oBAAoB,CAAC,EAAE,MAAM,CAAA;CACvC;AAED,MAAM,WAAW,iBAAkB,SAAQ,UAAU;IACnD,QAAQ,CAAC,EAAE;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAAA;KAAE,GAAG,IAAI,CAAA;IAErD;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;CACd"}
export {};
//# sourceMappingURL=updateInfo.js.map
{"version":3,"file":"updateInfo.js","sourceRoot":"","sources":["../src/updateInfo.ts"],"names":[],"mappings":"","sourcesContent":["export interface ReleaseNoteInfo {\n /**\n * The version.\n */\n readonly version: string\n\n /**\n * The note.\n */\n readonly note: string | null\n}\n\nexport interface BlockMapDataHolder {\n /**\n * The file size. Used to verify downloaded size (save one HTTP request to get length).\n * Also used when block map data is embedded into the file (appimage, windows web installer package).\n */\n size?: number\n\n /**\n * The block map file size. Used when block map data is embedded into the file (appimage, windows web installer package).\n * This information can be obtained from the file itself, but it requires additional HTTP request,\n * so, to reduce request count, block map size is specified in the update metadata too.\n */\n blockMapSize?: number\n\n /**\n * The file checksum.\n */\n readonly sha512: string\n\n readonly isAdminRightsRequired?: boolean\n}\n\nexport interface PackageFileInfo extends BlockMapDataHolder {\n readonly path: string\n}\n\nexport interface UpdateFileInfo extends BlockMapDataHolder {\n url: string\n}\n\nexport interface UpdateInfo {\n /**\n * The version.\n */\n readonly version: string\n\n readonly files: Array<UpdateFileInfo>\n\n /** @deprecated */\n readonly path: string\n\n /** @deprecated */\n readonly sha512: string\n\n /**\n * The release name.\n */\n releaseName?: string | null\n\n /**\n * The release notes. List if `updater.fullChangelog` is set to `true`, `string` otherwise.\n */\n releaseNotes?: string | Array<ReleaseNoteInfo> | null\n\n /**\n * The release date.\n */\n releaseDate: string\n\n /**\n * The [staged rollout](https://www.electron.build/auto-update#staged-rollouts) percentage, 0-100.\n */\n readonly stagingPercentage?: number\n\n /**\n * The minimum version of system required for the app to run. Sample value: macOS `23.1.0`, Windows `10.0.22631`.\n * Same with os.release() value, this is a kernel version.\n */\n readonly minimumSystemVersion?: string\n}\n\nexport interface WindowsUpdateInfo extends UpdateInfo {\n packages?: { [arch: string]: PackageFileInfo } | null\n\n /**\n * @deprecated\n * @private\n */\n sha2?: string\n}\n"]}
export declare class UUID {
private ascii;
private readonly binary;
private readonly version;
static readonly OID: Buffer;
constructor(uuid: Buffer | string);
static v5(name: string | Buffer, namespace: Buffer): any;
toString(): string;
inspect(): string;
static check(uuid: Buffer | string, offset?: number): false | {
version: undefined;
variant: string;
format: string;
} | {
version: number;
variant: string;
format: string;
};
static parse(input: string): Buffer;
}
export declare const nil: UUID;
//# sourceMappingURL=uuid.d.ts.map
{"version":3,"file":"uuid.d.ts","sourceRoot":"","sources":["../src/uuid.ts"],"names":[],"mappings":"AAsBA,qBAAa,IAAI;IACf,OAAO,CAAC,KAAK,CAAsB;IACnC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsB;IAC7C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAQ;IAGhC,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAqD;gBAEpE,IAAI,EAAE,MAAM,GAAG,MAAM;IAejC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,SAAS,EAAE,MAAM;IAIlD,QAAQ;IAOR,OAAO;IAIP,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,MAAM,SAAI;;;;;;;;;IA6C9C,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;CAWpC;AAuGD,eAAO,MAAM,GAAG,MAAmD,CAAA"}
import { createHash, randomBytes } from "crypto";
import { newError } from "./error.js";
const invalidName = "options.name must be either a string or a Buffer";
// Node ID according to rfc4122#section-4.5
const randomHost = randomBytes(16);
randomHost[0] = randomHost[0] | 0x01;
// 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
export class UUID {
// from rfc4122#appendix-C
static { this.OID = UUID.parse("6ba7b812-9dad-11d1-80b4-00c04fd430c8"); }
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;
}
}
static v5(name, namespace) {
return uuidNamed(name, "sha1", 0x50, namespace);
}
toString() {
if (this.ascii == null) {
this.ascii = stringify(this.binary);
}
return this.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 (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 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;
}
}
return buffer;
}
}
// 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";
}
}
var UuidEncoding;
(function (UuidEncoding) {
UuidEncoding[UuidEncoding["ASCII"] = 0] = "ASCII";
UuidEncoding[UuidEncoding["BINARY"] = 1] = "BINARY";
UuidEncoding[UuidEncoding["OBJECT"] = 2] = "OBJECT";
})(UuidEncoding || (UuidEncoding = {}));
// v3 + v5
function uuidNamed(name, hashMethod, version, namespace, encoding = UuidEncoding.ASCII) {
const hash = createHash(hashMethod);
const nameIsNotAString = typeof name !== "string";
if (nameIsNotAString && !Buffer.isBuffer(name)) {
throw newError(invalidName, "ERR_INVALID_UUID_NAME");
}
hash.update(namespace);
hash.update(name);
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
export const nil = new UUID("00000000-0000-0000-0000-000000000000");
// UUID.v4 = uuidRandom
// UUID.v4fast = uuidRandomFast
// UUID.v3 = function(options, callback) {
// return uuidNamed("md5", 0x30, options, callback)
// }
//# sourceMappingURL=uuid.js.map
{"version":3,"file":"uuid.js","sourceRoot":"","sources":["../src/uuid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAErC,MAAM,WAAW,GAAG,kDAAkD,CAAA;AAEtE,2CAA2C;AAC3C,MAAM,UAAU,GAAG,WAAW,CAAC,EAAE,CAAC,CAAA;AAClC,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,IAAI,CAAA;AAEpC,2BAA2B;AAC3B,MAAM,QAAQ,GAAQ,EAAE,CAAA;AAExB,2BAA2B;AAC3B,MAAM,QAAQ,GAAkB,EAAE,CAAA;AAClC,yBAAyB;AACzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAA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QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACnB,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACnB,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACnB,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACnB,GAAG;QACH,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACnB,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACnB,GAAG;QACH,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACnB,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACnB,GAAG;QACH,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACnB,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACnB,GAAG;QACH,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACpB,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACpB,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACpB,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACpB,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACpB,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CACrB,CAAA;AACH,CAAC;AAED,qCAAqC;AACrC,MAAM,CAAC,MAAM,GAAG,GAAG,IAAI,IAAI,CAAC,sCAAsC,CAAC,CAAA;AAEnE,uBAAuB;AAEvB,+BAA+B;AAE/B,0CAA0C;AAC1C,uDAAuD;AACvD,IAAI","sourcesContent":["import { createHash, randomBytes } from \"crypto\"\nimport { newError } from \"./error.js\"\n\nconst invalidName = \"options.name must be either a string or a Buffer\"\n\n// Node ID according to rfc4122#section-4.5\nconst randomHost = randomBytes(16)\nrandomHost[0] = randomHost[0] | 0x01\n\n// lookup table hex to byte\nconst hex2byte: any = {}\n\n// lookup table byte to hex\nconst byte2hex: Array<string> = []\n// populate lookup tables\nfor (let i = 0; i < 256; i++) {\n const hex = (i + 0x100).toString(16).substr(1)\n hex2byte[hex] = i\n byte2hex[i] = hex\n}\n\n// UUID class\nexport class UUID {\n private ascii: string | null = null\n private readonly binary: Buffer | null = null\n private readonly version: number\n\n // from rfc4122#appendix-C\n static readonly OID: Buffer = UUID.parse(\"6ba7b812-9dad-11d1-80b4-00c04fd430c8\")\n\n constructor(uuid: Buffer | string) {\n const check = UUID.check(uuid)\n if (!check) {\n throw new Error(\"not a UUID\")\n }\n\n this.version = check.version!\n\n if (check.format === \"ascii\") {\n this.ascii = uuid as string\n } else {\n this.binary = uuid as Buffer\n }\n }\n\n static v5(name: string | Buffer, namespace: Buffer) {\n return uuidNamed(name, \"sha1\", 0x50, namespace)\n }\n\n toString() {\n if (this.ascii == null) {\n this.ascii = stringify(this.binary!)\n }\n return this.ascii\n }\n\n inspect() {\n return `UUID v${this.version} ${this.toString()}`\n }\n\n static check(uuid: Buffer | string, offset = 0) {\n if (typeof uuid === \"string\") {\n uuid = uuid.toLowerCase()\n\n if (!/^[a-f0-9]{8}(-[a-f0-9]{4}){3}-([a-f0-9]{12})$/.test(uuid)) {\n return false\n }\n\n if (uuid === \"00000000-0000-0000-0000-000000000000\") {\n return { version: undefined, variant: \"nil\", format: \"ascii\" }\n }\n\n return {\n version: (hex2byte[uuid[14] + uuid[15]] & 0xf0) >> 4,\n variant: getVariant((hex2byte[uuid[19] + uuid[20]] & 0xe0) >> 5),\n format: \"ascii\",\n }\n }\n\n if (Buffer.isBuffer(uuid)) {\n if (uuid.length < offset + 16) {\n return false\n }\n\n let i = 0\n for (; i < 16; i++) {\n if (uuid[offset + i] !== 0) {\n break\n }\n }\n if (i === 16) {\n return { version: undefined, variant: \"nil\", format: \"binary\" }\n }\n\n return {\n version: (uuid[offset + 6] & 0xf0) >> 4,\n variant: getVariant((uuid[offset + 8] & 0xe0) >> 5),\n format: \"binary\",\n }\n }\n\n throw newError(\"Unknown type of uuid\", \"ERR_UNKNOWN_UUID_TYPE\")\n }\n\n // read stringified uuid into a Buffer\n static parse(input: string): Buffer {\n const buffer = Buffer.allocUnsafe(16)\n let j = 0\n for (let i = 0; i < 16; i++) {\n buffer[i] = hex2byte[input[j++] + input[j++]]\n if (i === 3 || i === 5 || i === 7 || i === 9) {\n j += 1\n }\n }\n return buffer\n }\n}\n\n// according to rfc4122#section-4.1.1\nfunction getVariant(bits: number) {\n switch (bits) {\n case 0:\n case 1:\n case 3:\n return \"ncs\"\n case 4:\n case 5:\n return \"rfc4122\"\n case 6:\n return \"microsoft\"\n default:\n return \"future\"\n }\n}\n\nenum UuidEncoding {\n ASCII,\n BINARY,\n OBJECT,\n}\n\n// v3 + v5\nfunction uuidNamed(name: string | Buffer, hashMethod: string, version: number, namespace: Buffer, encoding: UuidEncoding = UuidEncoding.ASCII) {\n const hash = createHash(hashMethod)\n\n const nameIsNotAString = typeof name !== \"string\"\n if (nameIsNotAString && !Buffer.isBuffer(name)) {\n throw newError(invalidName, \"ERR_INVALID_UUID_NAME\")\n }\n\n hash.update(namespace)\n hash.update(name)\n\n const buffer = hash.digest()\n let result: any\n switch (encoding) {\n case UuidEncoding.BINARY:\n buffer[6] = (buffer[6] & 0x0f) | version\n buffer[8] = (buffer[8] & 0x3f) | 0x80\n result = buffer\n break\n case UuidEncoding.OBJECT:\n buffer[6] = (buffer[6] & 0x0f) | version\n buffer[8] = (buffer[8] & 0x3f) | 0x80\n result = new UUID(buffer)\n break\n default:\n result =\n byte2hex[buffer[0]] +\n byte2hex[buffer[1]] +\n byte2hex[buffer[2]] +\n byte2hex[buffer[3]] +\n \"-\" +\n byte2hex[buffer[4]] +\n byte2hex[buffer[5]] +\n \"-\" +\n byte2hex[(buffer[6] & 0x0f) | version] +\n byte2hex[buffer[7]] +\n \"-\" +\n byte2hex[(buffer[8] & 0x3f) | 0x80] +\n byte2hex[buffer[9]] +\n \"-\" +\n byte2hex[buffer[10]] +\n byte2hex[buffer[11]] +\n byte2hex[buffer[12]] +\n byte2hex[buffer[13]] +\n byte2hex[buffer[14]] +\n byte2hex[buffer[15]]\n break\n }\n return result\n}\n\nfunction stringify(buffer: Buffer) {\n return (\n byte2hex[buffer[0]] +\n byte2hex[buffer[1]] +\n byte2hex[buffer[2]] +\n byte2hex[buffer[3]] +\n \"-\" +\n byte2hex[buffer[4]] +\n byte2hex[buffer[5]] +\n \"-\" +\n byte2hex[buffer[6]] +\n byte2hex[buffer[7]] +\n \"-\" +\n byte2hex[buffer[8]] +\n byte2hex[buffer[9]] +\n \"-\" +\n byte2hex[buffer[10]] +\n byte2hex[buffer[11]] +\n byte2hex[buffer[12]] +\n byte2hex[buffer[13]] +\n byte2hex[buffer[14]] +\n byte2hex[buffer[15]]\n )\n}\n\n// according to rfc4122#section-4.1.7\nexport const nil = new UUID(\"00000000-0000-0000-0000-000000000000\")\n\n// UUID.v4 = uuidRandom\n\n// UUID.v4fast = uuidRandomFast\n\n// UUID.v3 = function(options, callback) {\n// return uuidNamed(\"md5\", 0x30, options, callback)\n// }\n"]}
export declare class XElement {
readonly name: string;
value: string;
attributes: Record<string, string> | null;
isCData: boolean;
elements: Array<XElement> | null;
constructor(name: string);
attribute(name: string): string;
removeAttribute(name: string): void;
element(name: string, ignoreCase?: boolean, errorIfMissed?: string | null): XElement;
elementOrNull(name: string, ignoreCase?: boolean): XElement | null;
getElements(name: string, ignoreCase?: boolean): XElement[];
elementValueOrEmpty(name: string, ignoreCase?: boolean): string;
}
export declare function parseXml(data: string): XElement;
//# sourceMappingURL=xml.d.ts.map
{"version":3,"file":"xml.d.ts","sourceRoot":"","sources":["../src/xml.ts"],"names":[],"mappings":"AAGA,qBAAa,QAAQ;IAMP,QAAQ,CAAC,IAAI,EAAE,MAAM;IALjC,KAAK,SAAK;IACV,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAO;IAChD,OAAO,UAAQ;IACf,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAO;gBAElB,IAAI,EAAE,MAAM;IASjC,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAQ/B,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAMnC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,UAAQ,EAAE,aAAa,GAAE,MAAM,GAAG,IAAW,GAAG,QAAQ;IAQxF,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,UAAQ,GAAG,QAAQ,GAAG,IAAI;IAchE,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,UAAQ;IAO5C,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,UAAQ,GAAG,MAAM;CAI9D;AAaD,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CA2C/C"}
import * as sax from "sax";
import { newError } from "./error.js";
export class XElement {
constructor(name) {
this.name = name;
this.value = "";
this.attributes = null;
this.isCData = false;
this.elements = null;
if (!name) {
throw newError("Element name cannot be empty", "ERR_XML_ELEMENT_NAME_EMPTY");
}
if (!isValidName(name)) {
throw newError(`Invalid element name: ${name}`, "ERR_XML_ELEMENT_INVALID_NAME");
}
}
attribute(name) {
const result = this.attributes === null ? null : this.attributes[name];
if (result == null) {
throw newError(`No attribute "${name}"`, "ERR_XML_MISSED_ATTRIBUTE");
}
return result;
}
removeAttribute(name) {
if (this.attributes !== null) {
delete this.attributes[name];
}
}
element(name, ignoreCase = false, errorIfMissed = null) {
const result = this.elementOrNull(name, ignoreCase);
if (result === null) {
throw newError(errorIfMissed || `No element "${name}"`, "ERR_XML_MISSED_ELEMENT");
}
return result;
}
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;
}
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;
}
}
const NAME_REG_EXP = new RegExp(/^[A-Za-z_][:A-Za-z0-9_-]*$/i);
function isValidName(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());
}
export function parseXml(data) {
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
{"version":3,"file":"xml.js","sourceRoot":"","sources":["../src/xml.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAA;AAC1B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAErC,MAAM,OAAO,QAAQ;IAMnB,YAAqB,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;QALjC,UAAK,GAAG,EAAE,CAAA;QACV,eAAU,GAAkC,IAAI,CAAA;QAChD,YAAO,GAAG,KAAK,CAAA;QACf,aAAQ,GAA2B,IAAI,CAAA;QAGrC,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,QAAQ,CAAC,8BAA8B,EAAE,4BAA4B,CAAC,CAAA;QAC9E,CAAC;QACD,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;YACvB,MAAM,QAAQ,CAAC,yBAAyB,IAAI,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ACrB,CAAC","sourcesContent":["import * as sax from \"sax\"\nimport { newError } from \"./error.js\"\n\nexport class XElement {\n value = \"\"\n attributes: Record<string, string> | null = null\n isCData = false\n elements: Array<XElement> | null = null\n\n constructor(readonly name: string) {\n if (!name) {\n throw newError(\"Element name cannot be empty\", \"ERR_XML_ELEMENT_NAME_EMPTY\")\n }\n if (!isValidName(name)) {\n throw newError(`Invalid element name: ${name}`, \"ERR_XML_ELEMENT_INVALID_NAME\")\n }\n }\n\n attribute(name: string): string {\n const result = this.attributes === null ? null : this.attributes[name]\n if (result == null) {\n throw newError(`No attribute \"${name}\"`, \"ERR_XML_MISSED_ATTRIBUTE\")\n }\n return result\n }\n\n removeAttribute(name: string): void {\n if (this.attributes !== null) {\n delete this.attributes[name]\n }\n }\n\n element(name: string, ignoreCase = false, errorIfMissed: string | null = null): XElement {\n const result = this.elementOrNull(name, ignoreCase)\n if (result === null) {\n throw newError(errorIfMissed || `No element \"${name}\"`, \"ERR_XML_MISSED_ELEMENT\")\n }\n return result\n }\n\n elementOrNull(name: string, ignoreCase = false): XElement | null {\n if (this.elements === null) {\n return null\n }\n\n for (const element of this.elements) {\n if (isNameEquals(element, name, ignoreCase)) {\n return element\n }\n }\n\n return null\n }\n\n getElements(name: string, ignoreCase = false) {\n if (this.elements === null) {\n return []\n }\n return this.elements.filter(it => isNameEquals(it, name, ignoreCase))\n }\n\n elementValueOrEmpty(name: string, ignoreCase = false): string {\n const element = this.elementOrNull(name, ignoreCase)\n return element === null ? \"\" : element.value\n }\n}\n\nconst NAME_REG_EXP = new RegExp(/^[A-Za-z_][:A-Za-z0-9_-]*$/i)\n\nfunction isValidName(name: string) {\n return NAME_REG_EXP.test(name)\n}\n\nfunction isNameEquals(element: XElement, name: string, ignoreCase: boolean) {\n const elementName = element.name\n return elementName === name || (ignoreCase === true && elementName.length === name.length && elementName.toLowerCase() === name.toLowerCase())\n}\n\nexport function parseXml(data: string): XElement {\n let rootElement: XElement | null = null\n const parser = sax.parser(true, {})\n const elements: Array<XElement> = []\n\n parser.onopentag = saxElement => {\n const element = new XElement(saxElement.name)\n element.attributes = saxElement.attributes as Record<string, string>\n\n if (rootElement === null) {\n rootElement = element\n } else {\n const parent = elements[elements.length - 1]\n if (parent.elements == null) {\n parent.elements = []\n }\n parent.elements.push(element)\n }\n elements.push(element)\n }\n\n parser.onclosetag = () => {\n elements.pop()\n }\n\n parser.ontext = text => {\n if (elements.length > 0) {\n elements[elements.length - 1].value = text\n }\n }\n\n parser.oncdata = cdata => {\n const element = elements[elements.length - 1]\n element.value = cdata\n element.isCData = true\n }\n\n parser.onerror = err => {\n throw err\n }\n\n parser.write(data)\n return rootElement!\n}\n"]}
+22
-5
{
"name": "builder-util-runtime",
"version": "9.7.0",
"main": "out/index.js",
"version": "10.0.0-alpha.0",
"type": "module",
"main": "./dist/index.js",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.js"
},
"./internal": {
"types": "./dist/indexInternal.d.ts",
"import": "./dist/indexInternal.js",
"require": "./dist/indexInternal.js"
}
},
"author": "Vladimir Krivosheev",

@@ -15,6 +28,6 @@ "license": "MIT",

"files": [
"out"
"dist"
],
"engines": {
"node": ">=12.0.0"
"node": ">=22.12.0"
},

@@ -29,3 +42,7 @@ "dependencies": {

},
"types": "./out/index.d.ts"
"types": "./dist/index.d.ts",
"scripts": {
"build": "tsc --build tsconfig.build.json --force",
"watch": "tsc --build tsconfig.build.json --watch"
}
}
-12
export interface FileChunks {
checksums: Array<string>;
sizes: Array<number>;
}
export interface BlockMap {
version: "1" | "2";
files: Array<BlockMapFile>;
}
export interface BlockMapFile extends FileChunks {
name: string;
offset: number;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=blockMapApi.js.map
{"version":3,"file":"blockMapApi.js","sourceRoot":"","sources":["../src/blockMapApi.ts"],"names":[],"mappings":"","sourcesContent":["export interface FileChunks {\n checksums: Array<string>\n sizes: Array<number>\n}\n\nexport interface BlockMap {\n version: \"1\" | \"2\"\n files: Array<BlockMapFile>\n}\n\nexport interface BlockMapFile extends FileChunks {\n name: string\n offset: number\n}\n"]}
import { EventEmitter } from "events";
export declare class CancellationToken extends EventEmitter {
private parentCancelHandler;
private _cancelled;
get cancelled(): boolean;
private _parent;
set parent(value: CancellationToken);
constructor(parent?: CancellationToken);
cancel(): void;
private onCancel;
createPromise<R>(callback: (resolve: (thenableOrResult: R | PromiseLike<R>) => void, reject: (error: Error) => void, onCancel: (callback: () => void) => void) => void): Promise<R>;
private removeParentCancelHandler;
dispose(): void;
}
export declare class CancellationError extends Error {
constructor();
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CancellationError = exports.CancellationToken = void 0;
const events_1 = require("events");
class CancellationToken extends events_1.EventEmitter {
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);
}
// 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;
}
}
cancel() {
this._cancelled = true;
this.emit("cancel");
}
onCancel(handler) {
if (this.cancelled) {
handler();
}
else {
this.once("cancel", handler);
}
}
createPromise(callback) {
if (this.cancelled) {
return Promise.reject(new CancellationError());
}
const finallyHandler = () => {
if (cancelHandler != null) {
try {
this.removeListener("cancel", cancelHandler);
cancelHandler = null;
}
catch (_ignore) {
// ignore
}
}
};
let cancelHandler = null;
return new Promise((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;
});
})
.then(it => {
finallyHandler();
return it;
})
.catch((e) => {
finallyHandler();
throw e;
});
}
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
{"version":3,"file":"CancellationToken.js","sourceRoot":"","sources":["../src/CancellationToken.ts"],"names":[],"mappings":";;;AAAA,mCAAqC;AAErC,MAAa,iBAAkB,SAAQ,qBAAY;IAIjD,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,UAAU,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;IAC5E,CAAC;IAGD,IAAI,MAAM,CAAC,KAAwB;QACjC,IAAI,CAAC,yBAAyB,EAAE,CAAA;QAEhC,IAAI,CAAC,OAAO,GAAG,KAAK,CAAA;QACpB,IAAI,CAAC,mBAAmB,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAA;QAC9C,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAA;IACjD,CAAC;IAED,qDAAqD;IACrD,YAAY,MAA0B;QACpC,KAAK,EAAE,CAAA;QAlBD,wBAAmB,GAAuB,IAAI,CAAA;QAO9C,YAAO,GAA6B,IAAI,CAAA;QAa9C,IAAI,CAAC,UAAU,GAAG,KAAK,CAAA;QACvB,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;YACnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACtB,CAAC;IACH,CAAC;IAED,MAAM;QACJ,IAAI,CAAC,UAAU,GAAG,IAAI,CAAA;QACtB,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IACrB,CAAC;IAEO,QAAQ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,QAAoB,EAAE,EAAE;gBACjD,kBAAkB,GAAG,QAAQ,CAAA;YAC/B,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC;aACC,IAAI,CAAC,EAAE,CAAC,EAAE;YACT,cAAc,EAAE,CAAA;YAChB,OAAO,EAAE,CAAA;QACX,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,CAAM,EAAE,EAAE;YAChB,cAAc,EAAE,CAAA;YAChB,MAAM,CAAC,CAAA;QACT,CAAC,CAAC,CAAA;IACN,CAAC;IAEO,yBAAyB;QAC/B,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAA;QAC3B,IAAI,MAAM,IAAI,IAAI,IAAI,IAAI,CAAC,mBAAmB,IAAI,IAAI,EAAE,CAAC;YACvD,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAA;YACzD,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAA;QACjC,CAAC;IACH,CAAC;IAED,OAAO;QACL,IAAI,CAAC;YACH,IAAI,CAAC,yBAAyB,EAAE,CAAA;QAClC,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,kBAAkB,EAAE,CAAA;YACzB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;QACrB,CAAC;IACH,CAAC;CACF;AA9GD,8CA8GC;AAED,MAAa,iBAAkB,SAAQ,KAAK;IAC1C;QACE,KAAK,CAAC,WAAW,CAAC,CAAA;IACpB,CAAC;CACF;AAJD,8CAIC","sourcesContent":["import { EventEmitter } from \"events\"\n\nexport class CancellationToken extends EventEmitter {\n private parentCancelHandler: (() => any) | null = null\n\n private _cancelled: boolean\n get cancelled(): boolean {\n return this._cancelled || (this._parent != null && this._parent.cancelled)\n }\n\n private _parent: CancellationToken | null = null\n set parent(value: CancellationToken) {\n this.removeParentCancelHandler()\n\n this._parent = value\n this.parentCancelHandler = () => this.cancel()\n this._parent.onCancel(this.parentCancelHandler)\n }\n\n // babel cannot compile ... correctly for super calls\n constructor(parent?: CancellationToken) {\n super()\n\n this._cancelled = false\n if (parent != null) {\n this.parent = parent\n }\n }\n\n cancel() {\n this._cancelled = true\n this.emit(\"cancel\")\n }\n\n private onCancel(handler: () => any) {\n if (this.cancelled) {\n handler()\n } else {\n this.once(\"cancel\", handler)\n }\n }\n\n createPromise<R>(\n callback: (resolve: (thenableOrResult: R | PromiseLike<R>) => void, reject: (error: Error) => void, onCancel: (callback: () => void) => void) => void\n ): Promise<R> {\n if (this.cancelled) {\n return Promise.reject<R>(new CancellationError())\n }\n\n const finallyHandler = () => {\n if (cancelHandler != null) {\n try {\n this.removeListener(\"cancel\", cancelHandler)\n cancelHandler = null\n } catch (_ignore) {\n // ignore\n }\n }\n }\n\n let cancelHandler: (() => void) | null = null\n return new Promise<R>((resolve, reject) => {\n let addedCancelHandler: (() => void) | null = null\n\n cancelHandler = () => {\n try {\n if (addedCancelHandler != null) {\n addedCancelHandler()\n addedCancelHandler = null\n }\n } finally {\n reject(new CancellationError())\n }\n }\n\n if (this.cancelled) {\n cancelHandler()\n return\n }\n\n this.onCancel(cancelHandler)\n\n callback(resolve, reject, (callback: () => void) => {\n addedCancelHandler = callback\n })\n })\n .then(it => {\n finallyHandler()\n return it\n })\n .catch((e: any) => {\n finallyHandler()\n throw e\n })\n }\n\n private removeParentCancelHandler() {\n const parent = this._parent\n if (parent != null && this.parentCancelHandler != null) {\n parent.removeListener(\"cancel\", this.parentCancelHandler)\n this.parentCancelHandler = null\n }\n }\n\n dispose() {\n try {\n this.removeParentCancelHandler()\n } finally {\n this.removeAllListeners()\n this._parent = null\n }\n }\n}\n\nexport class CancellationError extends Error {\n constructor() {\n super(\"cancelled\")\n }\n}\n"]}
export declare function newError(message: string, code: string): Error;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.newError = newError;
function newError(message, code) {
const error = new Error(message);
error.code = code;
return error;
}
//# sourceMappingURL=error.js.map
{"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":";;AAAA,4BAIC;AAJD,SAAgB,QAAQ,CAAC,OAAe,EAAE,IAAY;IACpD,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,CAC/B;IAAC,KAA+B,CAAC,IAAI,GAAG,IAAI,CAAA;IAC7C,OAAO,KAAK,CAAA;AACd,CAAC","sourcesContent":["export function newError(message: string, code: string) {\n const error = new Error(message)\n ;(error as NodeJS.ErrnoException).code = code\n return error\n}\n"]}
import { BinaryToTextEncoding } from "crypto";
import { IncomingMessage, OutgoingHttpHeader, OutgoingHttpHeaders, RequestOptions } from "http";
import { Transform } from "stream";
import { URL } from "url";
import { CancellationToken } from "./CancellationToken";
import { ProgressInfo } from "./ProgressCallbackTransform";
/**
* Register an additional HTTP header to strip on cross-origin redirects.
* Intended for custom publishers (e.g. GenericPublisher with a non-standard auth header).
*/
export declare function addSensitiveRedirectHeader(header: string): void;
/**
* Register an additional substring pattern used by {@link safeStringifyJson} to
* identify sensitive field names. Input is normalized (lowercased, separators stripped).
* Intended for custom publishers that store credentials under non-standard field names.
*/
export declare function addSensitiveFieldPattern(pattern: string): void;
export interface RequestHeaders extends OutgoingHttpHeaders {
[key: string]: OutgoingHttpHeader | undefined;
}
export interface DownloadOptions {
readonly headers?: OutgoingHttpHeaders | null;
readonly sha2?: string | null;
readonly sha512?: string | null;
readonly cancellationToken: CancellationToken;
onProgress?: (progress: ProgressInfo) => void;
}
export declare function createHttpError(response: IncomingMessage, description?: any | null): HttpError;
export declare class HttpError extends Error {
readonly statusCode: number;
readonly description: any | null;
constructor(statusCode: number, message?: string, description?: any | null);
isServerError(): boolean;
}
export declare function parseJson(result: Promise<string | null>): Promise<any>;
interface Request {
abort: () => void;
end: (data?: Buffer) => void;
}
export declare abstract class HttpExecutor<T extends Request> {
protected readonly maxRedirects = 10;
request(options: RequestOptions, cancellationToken?: CancellationToken, data?: {
[name: string]: any;
} | null): Promise<string | null>;
doApiRequest(options: RequestOptions, cancellationToken: CancellationToken, requestProcessor: (request: T, reject: (error: Error) => void) => void, redirectCount?: number): Promise<string>;
protected addRedirectHandlers(request: any, options: RequestOptions, reject: (error: Error) => void, redirectCount: number, handler: (options: RequestOptions) => void): void;
addErrorAndTimeoutHandlers(request: any, reject: (error: Error) => void, timeout?: number): void;
private handleResponse;
abstract createRequest(options: RequestOptions, callback: (response: any) => void): T;
downloadToBuffer(url: URL, options: DownloadOptions): Promise<Buffer>;
protected doDownload(requestOptions: RequestOptions, options: DownloadCallOptions, redirectCount: number): void;
protected createMaxRedirectError(): Error;
private addTimeOutHandler;
static prepareRedirectUrlOptions(redirectUrl: string, options: RequestOptions): RequestOptions;
private static reconstructOriginalUrl;
private static isCrossOriginRedirect;
static retryOnServerError(task: () => Promise<any>, maxRetries?: number): Promise<any>;
}
export interface DownloadCallOptions {
responseHandler: ((response: IncomingMessage, callback: (error: Error | null) => void) => void) | null;
onCancel: (callback: () => void) => void;
callback: (error: Error | null) => void;
options: DownloadOptions;
destination: string | null;
}
export declare function configureRequestOptionsFromUrl(url: string, options: RequestOptions): RequestOptions;
export declare function configureRequestUrl(url: URL, options: RequestOptions): void;
export declare class DigestTransform extends Transform {
readonly expected: string;
private readonly algorithm;
private readonly encoding;
private readonly digester;
private _actual;
get actual(): string | null;
isValidateOnEnd: boolean;
constructor(expected: string, algorithm?: string, encoding?: BinaryToTextEncoding);
_transform(chunk: Buffer, encoding: string, callback: any): void;
_flush(callback: any): void;
validate(): null;
}
export declare function safeGetHeader(response: any, headerKey: string): any;
export declare function configureRequestOptions(options: RequestOptions, token?: string | null, method?: "GET" | "DELETE" | "PUT" | "POST"): RequestOptions;
export declare function isSensitiveFieldName(name: string): boolean;
export declare function hashSensitiveValue(value: string): string;
export declare function safeStringifyJson(data: any, skippedNames?: Set<string>): string;
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DigestTransform = exports.HttpExecutor = exports.HttpError = void 0;
exports.addSensitiveRedirectHeader = addSensitiveRedirectHeader;
exports.addSensitiveFieldPattern = addSensitiveFieldPattern;
exports.createHttpError = createHttpError;
exports.parseJson = parseJson;
exports.configureRequestOptionsFromUrl = configureRequestOptionsFromUrl;
exports.configureRequestUrl = configureRequestUrl;
exports.safeGetHeader = safeGetHeader;
exports.configureRequestOptions = configureRequestOptions;
exports.isSensitiveFieldName = isSensitiveFieldName;
exports.hashSensitiveValue = hashSensitiveValue;
exports.safeStringifyJson = safeStringifyJson;
const crypto_1 = require("crypto");
const debug_1 = require("debug");
const fs_1 = require("fs");
const stream_1 = require("stream");
const url_1 = require("url");
const CancellationToken_1 = require("./CancellationToken");
const error_1 = require("./error");
const ProgressCallbackTransform_1 = require("./ProgressCallbackTransform");
const debug = (0, debug_1.default)("electron-builder");
// ── Sensitive-data registries ────────────────────────────────────────────────
// Normalise a header or field name: lowercase + strip all separators (- and _).
// Shared by both registries so lookup is always separator-agnostic.
const normalizeName = (name) => name.toLowerCase().replace(/[-_]/g, "");
// HTTP header names (normalised) stripped on cross-origin redirects.
// Stored normalised; lookup normalises the incoming key with normalizeName().
const SENSITIVE_REDIRECT_HEADERS = new Set(["authorization", "proxyauthorization", "privatetoken", "xapikey", "xauthtoken", "xaccesstoken", "xgitlabtoken", "cookie", "xcsrftoken"]);
// Substrings: a field name containing any of these (after normalization) is redacted.
const SENSITIVE_FIELD_PATTERNS = ["token", "password", "secret", "authorization", "credential", "apikey", "passphrase", "auth"];
// Suffixes: a field name ending with any of these (after normalization) is redacted.
// Intentionally greedy — "publicKey" is also stripped; over-stripping debug logs is
// acceptable, under-stripping a credential is not.
const SENSITIVE_FIELD_SUFFIXES = ["key"];
/**
* Register an additional HTTP header to strip on cross-origin redirects.
* Intended for custom publishers (e.g. GenericPublisher with a non-standard auth header).
*/
function addSensitiveRedirectHeader(header) {
SENSITIVE_REDIRECT_HEADERS.add(normalizeName(header));
}
/**
* Register an additional substring pattern used by {@link safeStringifyJson} to
* identify sensitive field names. Input is normalized (lowercased, separators stripped).
* Intended for custom publishers that store credentials under non-standard field names.
*/
function addSensitiveFieldPattern(pattern) {
SENSITIVE_FIELD_PATTERNS.push(pattern.toLowerCase().replace(/[-_]/g, ""));
}
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);
}
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";
this.code = `HTTP_ERROR_${statusCode}`;
}
isServerError() {
return this.statusCode >= 500 && this.statusCode <= 599;
}
}
exports.HttpError = HttpError;
function parseJson(result) {
return result.then(it => (it == null || it.length === 0 ? null : JSON.parse(it)));
}
class HttpExecutor {
constructor() {
this.maxRedirects = 10;
}
request(options, cancellationToken = new CancellationToken_1.CancellationToken(), data) {
configureRequestOptions(options);
const json = data == null ? undefined : JSON.stringify(data);
const encodedData = json ? Buffer.from(json) : undefined;
if (encodedData != null) {
if (debug.enabled) {
debug(safeStringifyJson(data));
}
const { headers, ...opts } = options;
options = {
method: "post",
headers: {
"Content-Type": "application/json",
"Content-Length": encodedData.length,
...headers,
},
...opts,
};
}
return this.doApiRequest(options, cancellationToken, it => it.end(encodedData));
}
doApiRequest(options, cancellationToken, requestProcessor, redirectCount = 0) {
if (debug.enabled) {
const { headers: _headers, auth: _auth, ...safeOptions } = options;
debug(`Request: ${safeStringifyJson(safeOptions)}`);
}
return cancellationToken.createPromise((resolve, reject, onCancel) => {
const request = this.createRequest(options, (response) => {
try {
this.handleResponse(response, options, cancellationToken, resolve, reject, redirectCount, requestProcessor);
}
catch (e) {
reject(e);
}
});
this.addErrorAndTimeoutHandlers(request, reject, options.timeout);
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
// eslint-disable-next-line
addRedirectHandlers(request, options, reject, redirectCount, handler) {
// not required for NodeJS
}
addErrorAndTimeoutHandlers(request, reject, timeout = 60 * 1000) {
this.addTimeOutHandler(request, reject, timeout);
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) {
var _a;
if (debug.enabled) {
const { headers: _headers, auth: _auth, ...safeOptions } = options;
debug(`Response: ${response.statusCode} ${response.statusMessage}, request options: ${safeStringifyJson(safeOptions)}`);
}
// 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 || "GET"} url: ${options.protocol || "https:"}//${options.hostname}${options.port ? `:${options.port}` : ""}${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 code = (_a = response.statusCode) !== null && _a !== void 0 ? _a : 0;
const shouldRedirect = code >= 300 && code < 400;
const redirectUrl = safeGetHeader(response, "location");
if (shouldRedirect && redirectUrl != null) {
if (redirectCount > this.maxRedirects) {
reject(this.createMaxRedirectError());
return;
}
this.doApiRequest(HttpExecutor.prepareRedirectUrlOptions(redirectUrl, options), cancellationToken, requestProcessor, redirectCount).then(resolve).catch(reject);
return;
}
response.setEncoding("utf8");
let data = "";
response.on("error", reject);
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, `method: ${options.method || "GET"} url: ${options.protocol || "https:"}//${options.hostname}${options.port ? `:${options.port}` : ""}${options.path}
Data:
${isJson ? safeStringifyJson(JSON.parse(data)) : data}
`));
}
else {
resolve(data.length === 0 ? null : data);
}
}
catch (e) {
reject(e);
}
});
}
async downloadToBuffer(url, options) {
return await options.cancellationToken.createPromise((resolve, reject, onCancel) => {
const responseChunks = [];
const requestOptions = {
headers: options.headers || undefined,
// because PrivateGitHubProvider requires HttpExecutor.prepareRedirectUrlOptions logic, so, we need to redirect manually
redirect: "manual",
};
configureRequestUrl(url, requestOptions);
configureRequestOptions(requestOptions);
this.doDownload(requestOptions, {
destination: null,
options,
onCancel,
callback: error => {
if (error == null) {
resolve(Buffer.concat(responseChunks));
}
else {
reject(error);
}
},
responseHandler: (response, callback) => {
let receivedLength = 0;
response.on("data", (chunk) => {
receivedLength += chunk.length;
if (receivedLength > 524288000) {
callback(new Error("Maximum allowed size is 500 MB"));
return;
}
responseChunks.push(chunk);
});
response.on("end", () => {
callback(null);
});
},
}, 0);
});
}
doDownload(requestOptions, options, redirectCount) {
const request = this.createRequest(requestOptions, (response) => {
if (response.statusCode >= 400) {
options.callback(new Error(`Cannot download "${requestOptions.protocol || "https:"}//${requestOptions.hostname}${requestOptions.path}", status ${response.statusCode}: ${response.statusMessage}`));
return;
}
// It is possible for the response stream to fail, e.g. when a network is lost while
// response stream is in progress. Stop waiting and reject so consumer can catch the error.
response.on("error", options.callback);
// this code not relevant for Electron (redirect event instead handled)
const redirectUrl = safeGetHeader(response, "location");
if (redirectUrl != null) {
if (redirectCount < this.maxRedirects) {
this.doDownload(HttpExecutor.prepareRedirectUrlOptions(redirectUrl, requestOptions), options, redirectCount++);
}
else {
options.callback(this.createMaxRedirectError());
}
return;
}
if (options.responseHandler == null) {
configurePipes(options, response);
}
else {
options.responseHandler(response, options.callback);
}
});
this.addErrorAndTimeoutHandlers(request, options.callback, requestOptions.timeout);
this.addRedirectHandlers(request, requestOptions, options.callback, redirectCount, requestOptions => {
this.doDownload(requestOptions, options, redirectCount++);
});
request.end();
}
createMaxRedirectError() {
return new Error(`Too many redirects (> ${this.maxRedirects})`);
}
addTimeOutHandler(request, callback, timeout) {
request.on("socket", (socket) => {
socket.setTimeout(timeout, () => {
request.abort();
callback(new Error("Request timed out"));
});
});
}
static prepareRedirectUrlOptions(redirectUrl, options) {
const newOptions = configureRequestOptionsFromUrl(redirectUrl, { ...options });
const headers = newOptions.headers;
if (headers == null) {
return newOptions;
}
const originalUrl = HttpExecutor.reconstructOriginalUrl(options);
const parsedRedirectUrl = parseUrl(redirectUrl, options);
if (HttpExecutor.isCrossOriginRedirect(originalUrl, parsedRedirectUrl)) {
if (debug.enabled) {
debug(`Cross-origin redirect (${originalUrl.host} → ${parsedRedirectUrl.host}): stripping sensitive headers`);
}
for (const key of Object.keys(headers)) {
if (SENSITIVE_REDIRECT_HEADERS.has(normalizeName(key))) {
delete headers[key];
}
}
}
return newOptions;
}
static reconstructOriginalUrl(options) {
const protocol = options.protocol || "https:";
if (!options.hostname) {
throw new Error("Missing hostname in request options");
}
const hostname = options.hostname;
const port = options.port ? `:${options.port}` : "";
const path = options.path || "/";
return new url_1.URL(`${protocol}//${hostname}${port}${path}`);
}
static isCrossOriginRedirect(originalUrl, redirectUrl) {
// Case-insensitive hostname comparison
if (originalUrl.hostname.toLowerCase() !== redirectUrl.hostname.toLowerCase()) {
return true;
}
// Special case: allow http -> https redirect on same host with standard ports
// This matches the behavior of Python requests library for backward compatibility
// url.port returns an empty string if the port is omitted
// or explicitly set to the default port for a given protocol.
if (originalUrl.protocol === "http:" &&
// This can be replaced with `!originalUrl.port`, but for the sake of clarity.
["80", ""].includes(originalUrl.port) &&
redirectUrl.protocol === "https:" &&
// This can be replaced with `!redirectUrl.port`, but for the sake of clarity.
["443", ""].includes(redirectUrl.port)) {
return false;
}
// According to RFC 7235, a change in protocol or port constitutes a cross-origin request.
// Forwarding authentication headers to a different origin can be a security risk.
// For example, https://example.com:443 and http://example.com:80 are different origins.
// We only make an exception for HTTP -> HTTPS upgrades on standard ports for backward compatibility.
// Strip auth on any other protocol change
if (originalUrl.protocol !== redirectUrl.protocol) {
return true;
}
// Strip auth on port change (accounting for default ports)
const originalPort = originalUrl.port;
const redirectPort = redirectUrl.port;
return originalPort !== redirectPort;
}
static async retryOnServerError(task, maxRetries = 3) {
for (let attemptNumber = 0;; attemptNumber++) {
try {
return await task();
}
catch (e) {
if (attemptNumber < maxRetries && ((e instanceof HttpError && e.isServerError()) || e.code === "EPIPE")) {
await new Promise(r => setTimeout(r, 1000 * (attemptNumber + 1)));
continue;
}
throw e;
}
}
}
}
exports.HttpExecutor = HttpExecutor;
function parseUrl(url, options) {
try {
// Would throw exception if url is not absolute
return new url_1.URL(url);
}
catch {
// Relative URL - construct base URL from original options
const hostname = options.hostname;
const protocol = options.protocol || "https:";
const port = options.port ? `:${options.port}` : "";
const baseUrl = `${protocol}//${hostname}${port}`;
return new url_1.URL(url, baseUrl);
}
}
function configureRequestOptionsFromUrl(url, options) {
const result = configureRequestOptions(options);
const parsedUrl = parseUrl(url, options);
configureRequestUrl(parsedUrl, result);
return result;
}
function configureRequestUrl(url, options) {
options.protocol = url.protocol;
options.hostname = url.hostname;
if (url.port) {
options.port = url.port;
}
else if (options.port) {
delete options.port;
}
options.path = url.pathname + url.search;
}
class DigestTransform extends stream_1.Transform {
// noinspection JSUnusedGlobalSymbols
get actual() {
return this._actual;
}
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_1.createHash)(algorithm);
}
// 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;
}
}
callback(null);
}
validate() {
if (this._actual == null) {
throw (0, error_1.newError)("Not finished yet", "ERR_STREAM_NOT_FINISHED");
}
if (this._actual !== this.expected) {
throw (0, error_1.newError)(`${this.algorithm} checksum mismatch, expected ${this.expected}, got ${this._actual}`, "ERR_CHECKSUM_MISMATCH");
}
return null;
}
}
exports.DigestTransform = DigestTransform;
function checkSha2(sha2Header, sha2, callback) {
if (sha2Header != null && sha2 != null && sha2Header !== sha2) {
callback(new Error(`checksum mismatch: expected ${sha2} but got ${sha2Header} (X-Checksum-Sha2 header)`));
return false;
}
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;
}
}
function configurePipes(options, response) {
if (!checkSha2(safeGetHeader(response, "X-Checksum-Sha2"), options.options.sha2, options.callback)) {
return;
}
const streams = [];
if (options.options.onProgress != null) {
const contentLength = safeGetHeader(response, "content-length");
if (contentLength != null) {
streams.push(new ProgressCallbackTransform_1.ProgressCallbackTransform(parseInt(contentLength, 10), options.options.cancellationToken, options.options.onProgress));
}
}
const sha512 = options.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.options.sha2 != null) {
streams.push(new DigestTransform(options.options.sha2, "sha256", "hex"));
}
const fileOut = (0, fs_1.createWriteStream)(options.destination);
streams.push(fileOut);
let lastStream = response;
for (const stream of streams) {
stream.on("error", (error) => {
fileOut.close();
if (!options.options.cancellationToken.cancelled) {
options.callback(error);
}
});
lastStream = lastStream.pipe(stream);
}
fileOut.on("finish", () => {
;
fileOut.close(options.callback);
});
}
function configureRequestOptions(options, token, method) {
if (method != null) {
options.method = method;
}
options.headers = { ...options.headers };
const headers = options.headers;
if (token != null) {
;
headers.authorization = token.startsWith("Basic") || token.startsWith("Bearer") ? 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 isSensitiveFieldName(name) {
const normalized = normalizeName(name);
return SENSITIVE_FIELD_PATTERNS.some(p => normalized.includes(p)) || SENSITIVE_FIELD_SUFFIXES.some(s => normalized.endsWith(s));
}
function hashSensitiveValue(value) {
return `${(0, crypto_1.createHash)("sha256").update(value).digest("hex")} (sha256 hash)`;
}
function safeStringifyJson(data, skippedNames) {
return JSON.stringify(data, (name, value) => {
if (isSensitiveFieldName(name) || (skippedNames != null && skippedNames.has(name))) {
return typeof value === "string" ? hashSensitiveValue(value) : "<stripped sensitive data>";
}
return value;
}, 2);
}
//# sourceMappingURL=httpExecutor.js.map
{"version":3,"file":"httpExecutor.js","sourceRoot":"","sources":["../src/httpExecutor.ts"],"names":[],"mappings":";;;AAoCA,gEAEC;AAOD,4DAEC;AAiBD,0CASC;AAmCD,8BAEC;AAoWD,wEAKC;AAED,kDASC;AAmED,sCAUC;AAyCD,0DAwBC;AAED,oDAGC;AAED,gDAEC;AAED,8CAWC;AAtoBD,mCAA+D;AAC/D,iCAA0B;AAC1B,2BAAsC;AAGtC,mCAAkC;AAClC,6BAAyB;AAEzB,2DAAuD;AACvD,mCAAkC;AAClC,2EAAqF;AAErF,MAAM,KAAK,GAAG,IAAA,eAAM,EAAC,kBAAkB,CAAC,CAAA;AAExC,gFAAgF;AAEhF,gFAAgF;AAChF,oEAAoE;AACpE,MAAM,aAAa,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;AAEvF,qEAAqE;AACrE,8EAA8E;AAC9E,MAAM,0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G,QAAQ,CAAA;IAC7B,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,SAAgB,oBAAoB,CAAC,IAAY;IAC/C,MAAM,UAAU,GAAG,aAAa,CAAC,IAAI,CAAC,CAAA;IACtC,OAAO,wBAAwB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,wBAAwB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAA;AACjI,CAAC;AAED,SAAgB,kBAAkB,CAAC,KAAa;IAC9C,OAAO,GAAG,IAAA,mBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAA;AAC5E,CAAC;AAED,SAAgB,iBAAiB,CAAC,IAAS,EAAE,YAA0B;IACrE,OAAO,IAAI,CAAC,SAAS,CACnB,IAAI,EACJ,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QACd,IAAI,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,IAAI,IAAI,IAAI,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;YACnF,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,2BAA2B,CAAA;QAC5F,CAAC;QACD,OAAO,KAAK,CAAA;IACd,CAAC,EACD,CAAC,CACF,CAAA;AACH,CAAC","sourcesContent":["import { BinaryToTextEncoding, createHash, Hash } from \"crypto\"\nimport _debug from \"debug\"\nimport { createWriteStream } from \"fs\"\nimport { IncomingMessage, OutgoingHttpHeader, OutgoingHttpHeaders, RequestOptions } from \"http\"\nimport { Socket } from \"net\"\nimport { Transform } from \"stream\"\nimport { URL } from \"url\"\nimport { Nullish } from \".\"\nimport { CancellationToken } from \"./CancellationToken\"\nimport { newError } from \"./error\"\nimport { ProgressCallbackTransform, ProgressInfo } from \"./ProgressCallbackTransform\"\n\nconst debug = _debug(\"electron-builder\")\n\n// ── Sensitive-data registries ────────────────────────────────────────────────\n\n// Normalise a header or field name: lowercase + strip all separators (- and _).\n// Shared by both registries so lookup is always separator-agnostic.\nconst normalizeName = (name: string): string => name.toLowerCase().replace(/[-_]/g, \"\")\n\n// HTTP header names (normalised) stripped on cross-origin redirects.\n// Stored normalised; lookup normalises the incoming key with normalizeName().\nconst SENSITIVE_REDIRECT_HEADERS = new Set([\"authorization\", \"proxyauthorization\", \"privatetoken\", \"xapikey\", \"xauthtoken\", \"xaccesstoken\", \"xgitlabtoken\", \"cookie\", \"xcsrftoken\"])\n\n// Substrings: a field name containing any of these (after normalization) is redacted.\nconst SENSITIVE_FIELD_PATTERNS: string[] = [\"token\", \"password\", \"secret\", \"authorization\", \"credential\", \"apikey\", \"passphrase\", \"auth\"] as const\n\n// Suffixes: a field name ending with any of these (after normalization) is redacted.\n// Intentionally greedy — \"publicKey\" is also stripped; over-stripping debug logs is\n// acceptable, under-stripping a credential is not.\nconst SENSITIVE_FIELD_SUFFIXES: string[] = [\"key\"] as const\n\n/**\n * Register an additional HTTP header to strip on cross-origin redirects.\n * Intended for custom publishers (e.g. GenericPublisher with a non-standard auth header).\n */\nexport function addSensitiveRedirectHeader(header: string): void {\n SENSITIVE_REDIRECT_HEADERS.add(normalizeName(header))\n}\n\n/**\n * Register an additional substring pattern used by {@link safeStringifyJson} to\n * identify sensitive field names. Input is normalized (lowercased, separators stripped).\n * Intended for custom publishers that store credentials under non-standard field names.\n */\nexport function addSensitiveFieldPattern(pattern: string): void {\n SENSITIVE_FIELD_PATTERNS.push(pattern.toLowerCase().replace(/[-_]/g, \"\"))\n}\n\nexport interface RequestHeaders extends OutgoingHttpHeaders {\n [key: string]: OutgoingHttpHeader | undefined\n}\n\nexport interface DownloadOptions {\n readonly headers?: OutgoingHttpHeaders | null\n readonly sha2?: string | null\n readonly sha512?: string | null\n\n readonly cancellationToken: CancellationToken\n\n // noinspection JSUnusedLocalSymbols\n onProgress?: (progress: ProgressInfo) => void\n}\n\nexport function createHttpError(response: IncomingMessage, description: any | null = null) {\n return new HttpError(\n response.statusCode || -1,\n `${response.statusCode} ${response.statusMessage}` +\n (description == null ? \"\" : \"\\n\" + JSON.stringify(description, null, \" \")) +\n \"\\nHeaders: \" +\n safeStringifyJson(response.headers),\n description\n )\n}\n\nconst HTTP_STATUS_CODES = new Map<number, string>([\n [429, \"Too many requests\"],\n [400, \"Bad request\"],\n [403, \"Forbidden\"],\n [404, \"Not found\"],\n [405, \"Method not allowed\"],\n [406, \"Not acceptable\"],\n [408, \"Request timeout\"],\n [413, \"Request entity too large\"],\n [500, \"Internal server error\"],\n [502, \"Bad gateway\"],\n [503, \"Service unavailable\"],\n [504, \"Gateway timeout\"],\n [505, \"HTTP version not supported\"],\n])\n\nexport class HttpError extends Error {\n constructor(\n readonly statusCode: number,\n message = `HTTP error: ${HTTP_STATUS_CODES.get(statusCode) || statusCode}`,\n readonly description: any | null = null\n ) {\n super(message)\n\n this.name = \"HttpError\"\n ;(this as NodeJS.ErrnoException).code = `HTTP_ERROR_${statusCode}`\n }\n\n isServerError() {\n return this.statusCode >= 500 && this.statusCode <= 599\n }\n}\n\nexport function parseJson(result: Promise<string | null>) {\n return result.then(it => (it == null || it.length === 0 ? null : JSON.parse(it)))\n}\n\ninterface Request {\n abort: () => void\n end: (data?: Buffer) => void\n}\nexport abstract class HttpExecutor<T extends Request> {\n protected readonly maxRedirects = 10\n\n request(options: RequestOptions, cancellationToken: CancellationToken = new CancellationToken(), data?: { [name: string]: any } | null): Promise<string | null> {\n configureRequestOptions(options)\n const json = data == null ? undefined : JSON.stringify(data)\n const encodedData = json ? Buffer.from(json) : undefined\n if (encodedData != null) {\n if (debug.enabled) {\n debug(safeStringifyJson(data))\n }\n const { headers, ...opts } = options\n options = {\n method: \"post\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"Content-Length\": encodedData.length,\n ...headers,\n },\n ...opts,\n }\n }\n return this.doApiRequest(options, cancellationToken, it => it.end(encodedData))\n }\n\n doApiRequest(\n options: RequestOptions,\n cancellationToken: CancellationToken,\n requestProcessor: (request: T, reject: (error: Error) => void) => void,\n redirectCount = 0\n ): Promise<string> {\n if (debug.enabled) {\n const { headers: _headers, auth: _auth, ...safeOptions } = options as any\n debug(`Request: ${safeStringifyJson(safeOptions)}`)\n }\n\n return cancellationToken.createPromise<string>((resolve, reject, onCancel) => {\n const request = this.createRequest(options, (response: any) => {\n try {\n this.handleResponse(response, options, cancellationToken, resolve, reject, redirectCount, requestProcessor)\n } catch (e: any) {\n reject(e)\n }\n })\n this.addErrorAndTimeoutHandlers(request, reject, options.timeout)\n this.addRedirectHandlers(request, options, reject, redirectCount, options => {\n this.doApiRequest(options, cancellationToken, requestProcessor, redirectCount).then(resolve).catch(reject)\n })\n requestProcessor(request, reject)\n onCancel(() => request.abort())\n })\n }\n\n // noinspection JSUnusedLocalSymbols\n // eslint-disable-next-line\n protected addRedirectHandlers(request: any, options: RequestOptions, reject: (error: Error) => void, redirectCount: number, handler: (options: RequestOptions) => void) {\n // not required for NodeJS\n }\n\n addErrorAndTimeoutHandlers(request: any, reject: (error: Error) => void, timeout = 60 * 1000) {\n this.addTimeOutHandler(request, reject, timeout)\n request.on(\"error\", reject)\n request.on(\"aborted\", () => {\n reject(new Error(\"Request has been aborted by the server\"))\n })\n }\n\n private handleResponse(\n response: IncomingMessage,\n options: RequestOptions,\n cancellationToken: CancellationToken,\n resolve: (data?: any) => void,\n reject: (error: Error) => void,\n redirectCount: number,\n requestProcessor: (request: T, reject: (error: Error) => void) => void\n ) {\n if (debug.enabled) {\n const { headers: _headers, auth: _auth, ...safeOptions } = options as any\n debug(`Response: ${response.statusCode} ${response.statusMessage}, request options: ${safeStringifyJson(safeOptions)}`)\n }\n\n // we handle any other >= 400 error on request end (read detailed message in the response body)\n if (response.statusCode === 404) {\n // error is clear, we don't need to read detailed error description\n reject(\n createHttpError(\n response,\n `method: ${options.method || \"GET\"} url: ${options.protocol || \"https:\"}//${options.hostname}${options.port ? `:${options.port}` : \"\"}${options.path}\n\nPlease double check that your authentication token is correct. Due to security reasons, actual status maybe not reported, but 404.\n`\n )\n )\n return\n } else if (response.statusCode === 204) {\n // on DELETE request\n resolve()\n return\n }\n\n const code = response.statusCode ?? 0\n const shouldRedirect = code >= 300 && code < 400\n const redirectUrl = safeGetHeader(response, \"location\")\n if (shouldRedirect && redirectUrl != null) {\n if (redirectCount > this.maxRedirects) {\n reject(this.createMaxRedirectError())\n return\n }\n\n this.doApiRequest(HttpExecutor.prepareRedirectUrlOptions(redirectUrl, options), cancellationToken, requestProcessor, redirectCount).then(resolve).catch(reject)\n return\n }\n\n response.setEncoding(\"utf8\")\n\n let data = \"\"\n response.on(\"error\", reject)\n response.on(\"data\", (chunk: string) => (data += chunk))\n response.on(\"end\", () => {\n try {\n if (response.statusCode != null && response.statusCode >= 400) {\n const contentType = safeGetHeader(response, \"content-type\")\n const isJson = contentType != null && (Array.isArray(contentType) ? contentType.find(it => it.includes(\"json\")) != null : contentType.includes(\"json\"))\n reject(\n createHttpError(\n response,\n `method: ${options.method || \"GET\"} url: ${options.protocol || \"https:\"}//${options.hostname}${options.port ? `:${options.port}` : \"\"}${options.path}\n\n Data:\n ${isJson ? safeStringifyJson(JSON.parse(data)) : data}\n `\n )\n )\n } else {\n resolve(data.length === 0 ? null : data)\n }\n } catch (e: any) {\n reject(e)\n }\n })\n }\n\n // noinspection JSUnusedLocalSymbols\n abstract createRequest(options: RequestOptions, callback: (response: any) => void): T\n\n async downloadToBuffer(url: URL, options: DownloadOptions): Promise<Buffer> {\n return await options.cancellationToken.createPromise<Buffer>((resolve, reject, onCancel) => {\n const responseChunks: Buffer[] = []\n const requestOptions = {\n headers: options.headers || undefined,\n // because PrivateGitHubProvider requires HttpExecutor.prepareRedirectUrlOptions logic, so, we need to redirect manually\n redirect: \"manual\",\n }\n configureRequestUrl(url, requestOptions)\n configureRequestOptions(requestOptions)\n this.doDownload(\n requestOptions,\n {\n destination: null,\n options,\n onCancel,\n callback: error => {\n if (error == null) {\n resolve(Buffer.concat(responseChunks))\n } else {\n reject(error)\n }\n },\n responseHandler: (response, callback) => {\n let receivedLength = 0\n response.on(\"data\", (chunk: Buffer) => {\n receivedLength += chunk.length\n if (receivedLength > 524288000) {\n callback(new Error(\"Maximum allowed size is 500 MB\"))\n return\n }\n responseChunks.push(chunk)\n })\n response.on(\"end\", () => {\n callback(null)\n })\n },\n },\n 0\n )\n })\n }\n\n protected doDownload(requestOptions: RequestOptions, options: DownloadCallOptions, redirectCount: number) {\n const request = this.createRequest(requestOptions, (response: IncomingMessage) => {\n if (response.statusCode! >= 400) {\n options.callback(\n new Error(\n `Cannot download \"${requestOptions.protocol || \"https:\"}//${requestOptions.hostname}${requestOptions.path}\", status ${response.statusCode}: ${response.statusMessage}`\n )\n )\n return\n }\n\n // It is possible for the response stream to fail, e.g. when a network is lost while\n // response stream is in progress. Stop waiting and reject so consumer can catch the error.\n response.on(\"error\", options.callback)\n\n // this code not relevant for Electron (redirect event instead handled)\n const redirectUrl = safeGetHeader(response, \"location\")\n if (redirectUrl != null) {\n if (redirectCount < this.maxRedirects) {\n this.doDownload(HttpExecutor.prepareRedirectUrlOptions(redirectUrl, requestOptions), options, redirectCount++)\n } else {\n options.callback(this.createMaxRedirectError())\n }\n return\n }\n\n if (options.responseHandler == null) {\n configurePipes(options, response)\n } else {\n options.responseHandler(response, options.callback)\n }\n })\n this.addErrorAndTimeoutHandlers(request, options.callback, requestOptions.timeout)\n this.addRedirectHandlers(request, requestOptions, options.callback, redirectCount, requestOptions => {\n this.doDownload(requestOptions, options, redirectCount++)\n })\n request.end()\n }\n\n protected createMaxRedirectError() {\n return new Error(`Too many redirects (> ${this.maxRedirects})`)\n }\n\n private addTimeOutHandler(request: any, callback: (error: Error) => void, timeout: number) {\n request.on(\"socket\", (socket: Socket) => {\n socket.setTimeout(timeout, () => {\n request.abort()\n callback(new Error(\"Request timed out\"))\n })\n })\n }\n\n static prepareRedirectUrlOptions(redirectUrl: string, options: RequestOptions): RequestOptions {\n const newOptions = configureRequestOptionsFromUrl(redirectUrl, { ...options })\n const headers = newOptions.headers\n if (headers == null) {\n return newOptions\n }\n\n const originalUrl = HttpExecutor.reconstructOriginalUrl(options)\n const parsedRedirectUrl = parseUrl(redirectUrl, options)\n\n if (HttpExecutor.isCrossOriginRedirect(originalUrl, parsedRedirectUrl)) {\n if (debug.enabled) {\n debug(`Cross-origin redirect (${originalUrl.host} → ${parsedRedirectUrl.host}): stripping sensitive headers`)\n }\n for (const key of Object.keys(headers)) {\n if (SENSITIVE_REDIRECT_HEADERS.has(normalizeName(key))) {\n delete (headers as Record<string, unknown>)[key]\n }\n }\n }\n return newOptions\n }\n\n private static reconstructOriginalUrl(options: RequestOptions): URL {\n const protocol = options.protocol || \"https:\"\n if (!options.hostname) {\n throw new Error(\"Missing hostname in request options\")\n }\n const hostname = options.hostname\n const port = options.port ? `:${options.port}` : \"\"\n const path = options.path || \"/\"\n return new URL(`${protocol}//${hostname}${port}${path}`)\n }\n\n private static isCrossOriginRedirect(originalUrl: URL, redirectUrl: URL): boolean {\n // Case-insensitive hostname comparison\n if (originalUrl.hostname.toLowerCase() !== redirectUrl.hostname.toLowerCase()) {\n return true\n }\n\n // Special case: allow http -> https redirect on same host with standard ports\n // This matches the behavior of Python requests library for backward compatibility\n // url.port returns an empty string if the port is omitted\n // or explicitly set to the default port for a given protocol.\n if (\n originalUrl.protocol === \"http:\" &&\n // This can be replaced with `!originalUrl.port`, but for the sake of clarity.\n [\"80\", \"\"].includes(originalUrl.port) &&\n redirectUrl.protocol === \"https:\" &&\n // This can be replaced with `!redirectUrl.port`, but for the sake of clarity.\n [\"443\", \"\"].includes(redirectUrl.port)\n ) {\n return false\n }\n\n // According to RFC 7235, a change in protocol or port constitutes a cross-origin request.\n // Forwarding authentication headers to a different origin can be a security risk.\n // For example, https://example.com:443 and http://example.com:80 are different origins.\n // We only make an exception for HTTP -> HTTPS upgrades on standard ports for backward compatibility.\n\n // Strip auth on any other protocol change\n if (originalUrl.protocol !== redirectUrl.protocol) {\n return true\n }\n\n // Strip auth on port change (accounting for default ports)\n const originalPort = originalUrl.port\n const redirectPort = redirectUrl.port\n return originalPort !== redirectPort\n }\n\n static async retryOnServerError(task: () => Promise<any>, maxRetries = 3): Promise<any> {\n for (let attemptNumber = 0; ; attemptNumber++) {\n try {\n return await task()\n } catch (e: any) {\n if (attemptNumber < maxRetries && ((e instanceof HttpError && e.isServerError()) || e.code === \"EPIPE\")) {\n await new Promise(r => setTimeout(r, 1000 * (attemptNumber + 1)))\n continue\n }\n throw e\n }\n }\n }\n}\n\nexport interface DownloadCallOptions {\n responseHandler: ((response: IncomingMessage, callback: (error: Error | null) => void) => void) | null\n onCancel: (callback: () => void) => void\n callback: (error: Error | null) => void\n\n options: DownloadOptions\n\n destination: string | null\n}\n\nfunction parseUrl(url: string, options: RequestOptions): URL {\n try {\n // Would throw exception if url is not absolute\n return new URL(url)\n } catch {\n // Relative URL - construct base URL from original options\n const hostname = options.hostname\n const protocol = options.protocol || \"https:\"\n const port = options.port ? `:${options.port}` : \"\"\n const baseUrl = `${protocol}//${hostname}${port}`\n return new URL(url, baseUrl)\n }\n}\n\nexport function configureRequestOptionsFromUrl(url: string, options: RequestOptions) {\n const result = configureRequestOptions(options)\n const parsedUrl = parseUrl(url, options)\n configureRequestUrl(parsedUrl, result)\n return result\n}\n\nexport function configureRequestUrl(url: URL, options: RequestOptions): void {\n options.protocol = url.protocol\n options.hostname = url.hostname\n if (url.port) {\n options.port = url.port\n } else if (options.port) {\n delete options.port\n }\n options.path = url.pathname + url.search\n}\n\nexport class DigestTransform extends Transform {\n private readonly digester: Hash\n\n private _actual: string | null = null\n\n // noinspection JSUnusedGlobalSymbols\n get actual() {\n return this._actual\n }\n\n isValidateOnEnd = true\n\n constructor(\n readonly expected: string,\n private readonly algorithm: string = \"sha512\",\n private readonly encoding: BinaryToTextEncoding = \"base64\"\n ) {\n super()\n\n this.digester = createHash(algorithm)\n }\n\n // noinspection JSUnusedGlobalSymbols\n _transform(chunk: Buffer, encoding: string, callback: any) {\n this.digester.update(chunk)\n callback(null, chunk)\n }\n\n // noinspection JSUnusedGlobalSymbols\n _flush(callback: any): void {\n this._actual = this.digester.digest(this.encoding)\n\n if (this.isValidateOnEnd) {\n try {\n this.validate()\n } catch (e: any) {\n callback(e)\n return\n }\n }\n\n callback(null)\n }\n\n validate() {\n if (this._actual == null) {\n throw newError(\"Not finished yet\", \"ERR_STREAM_NOT_FINISHED\")\n }\n\n if (this._actual !== this.expected) {\n throw newError(`${this.algorithm} checksum mismatch, expected ${this.expected}, got ${this._actual}`, \"ERR_CHECKSUM_MISMATCH\")\n }\n\n return null\n }\n}\n\nfunction checkSha2(sha2Header: string | Nullish, sha2: string | Nullish, callback: (error: Error | null) => void): boolean {\n if (sha2Header != null && sha2 != null && sha2Header !== sha2) {\n callback(new Error(`checksum mismatch: expected ${sha2} but got ${sha2Header} (X-Checksum-Sha2 header)`))\n return false\n }\n return true\n}\n\nexport function safeGetHeader(response: any, headerKey: string) {\n const value = response.headers[headerKey]\n if (value == null) {\n return null\n } else if (Array.isArray(value)) {\n // electron API\n return value.length === 0 ? null : value[value.length - 1]\n } else {\n return value\n }\n}\n\nfunction configurePipes(options: DownloadCallOptions, response: IncomingMessage) {\n if (!checkSha2(safeGetHeader(response, \"X-Checksum-Sha2\"), options.options.sha2, options.callback)) {\n return\n }\n\n const streams: Array<any> = []\n if (options.options.onProgress != null) {\n const contentLength = safeGetHeader(response, \"content-length\")\n if (contentLength != null) {\n streams.push(new ProgressCallbackTransform(parseInt(contentLength, 10), options.options.cancellationToken, options.options.onProgress))\n }\n }\n\n const sha512 = options.options.sha512\n if (sha512 != null) {\n streams.push(new DigestTransform(sha512, \"sha512\", sha512.length === 128 && !sha512.includes(\"+\") && !sha512.includes(\"Z\") && !sha512.includes(\"=\") ? \"hex\" : \"base64\"))\n } else if (options.options.sha2 != null) {\n streams.push(new DigestTransform(options.options.sha2, \"sha256\", \"hex\"))\n }\n\n const fileOut = createWriteStream(options.destination!)\n streams.push(fileOut)\n\n let lastStream = response\n for (const stream of streams) {\n stream.on(\"error\", (error: Error) => {\n fileOut.close()\n if (!options.options.cancellationToken.cancelled) {\n options.callback(error)\n }\n })\n lastStream = lastStream.pipe(stream)\n }\n\n fileOut.on(\"finish\", () => {\n ;(fileOut.close as any)(options.callback)\n })\n}\n\nexport function configureRequestOptions(options: RequestOptions, token?: string | null, method?: \"GET\" | \"DELETE\" | \"PUT\" | \"POST\"): RequestOptions {\n if (method != null) {\n options.method = method\n }\n\n options.headers = { ...options.headers }\n const headers = options.headers\n\n if (token != null) {\n ;(headers as any).authorization = token.startsWith(\"Basic\") || token.startsWith(\"Bearer\") ? token : `token ${token}`\n }\n if (headers[\"User-Agent\"] == null) {\n headers[\"User-Agent\"] = \"electron-builder\"\n }\n\n if (method == null || method === \"GET\" || headers[\"Cache-Control\"] == null) {\n headers[\"Cache-Control\"] = \"no-cache\"\n }\n\n // do not specify for node (in any case we use https module)\n if (options.protocol == null && (process.versions as any).electron != null) {\n options.protocol = \"https:\"\n }\n return options\n}\n\nexport function isSensitiveFieldName(name: string): boolean {\n const normalized = normalizeName(name)\n return SENSITIVE_FIELD_PATTERNS.some(p => normalized.includes(p)) || SENSITIVE_FIELD_SUFFIXES.some(s => normalized.endsWith(s))\n}\n\nexport function hashSensitiveValue(value: string): string {\n return `${createHash(\"sha256\").update(value).digest(\"hex\")} (sha256 hash)`\n}\n\nexport function safeStringifyJson(data: any, skippedNames?: Set<string>): string {\n return JSON.stringify(\n data,\n (name, value) => {\n if (isSensitiveFieldName(name) || (skippedNames != null && skippedNames.has(name))) {\n return typeof value === \"string\" ? hashSensitiveValue(value) : \"<stripped sensitive data>\"\n }\n return value\n },\n 2\n )\n}\n"]}
export { BlockMap } from "./blockMapApi";
export { CancellationError, CancellationToken } from "./CancellationToken";
export { newError } from "./error";
export { configureRequestOptions, configureRequestOptionsFromUrl, configureRequestUrl, createHttpError, DigestTransform, DownloadOptions, HttpError, hashSensitiveValue, HttpExecutor, isSensitiveFieldName, parseJson, RequestHeaders, safeGetHeader, safeStringifyJson, } from "./httpExecutor";
export { MemoLazy } from "./MemoLazy";
export { ProgressCallbackTransform, ProgressInfo } from "./ProgressCallbackTransform";
export { AllPublishOptions, BaseS3Options, BitbucketOptions, CustomPublishOptions, GenericServerOptions, getS3LikeProviderBaseUrl, GithubOptions, githubUrl, githubTagPrefix, GitlabOptions, KeygenOptions, PublishConfiguration, PublishProvider, S3Options, SnapStoreOptions, SpacesOptions, GitlabReleaseInfo, GitlabReleaseAsset, } from "./publishOptions";
export { retry } from "./retry";
export { parseDn } from "./rfc2253Parser";
export { BlockMapDataHolder, PackageFileInfo, ReleaseNoteInfo, UpdateFileInfo, UpdateInfo, WindowsUpdateInfo } from "./updateInfo";
export { UUID } from "./uuid";
export { parseXml, XElement } from "./xml";
export { isValidKey, mapToObject, asArray, Nullish, deepAssign, objectToArgs } from "./objects";
export declare const CURRENT_APP_INSTALLER_FILE_NAME = "installer.exe";
export declare const CURRENT_APP_PACKAGE_FILE_NAME = "package.7z";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CURRENT_APP_PACKAGE_FILE_NAME = exports.CURRENT_APP_INSTALLER_FILE_NAME = exports.objectToArgs = exports.deepAssign = exports.asArray = exports.mapToObject = exports.isValidKey = exports.XElement = exports.parseXml = exports.UUID = exports.parseDn = exports.retry = exports.githubTagPrefix = exports.githubUrl = exports.getS3LikeProviderBaseUrl = exports.ProgressCallbackTransform = exports.MemoLazy = exports.safeStringifyJson = exports.safeGetHeader = exports.parseJson = exports.isSensitiveFieldName = exports.HttpExecutor = exports.hashSensitiveValue = exports.HttpError = exports.DigestTransform = exports.createHttpError = exports.configureRequestUrl = exports.configureRequestOptionsFromUrl = exports.configureRequestOptions = exports.newError = exports.CancellationToken = exports.CancellationError = void 0;
var CancellationToken_1 = require("./CancellationToken");
Object.defineProperty(exports, "CancellationError", { enumerable: true, get: function () { return CancellationToken_1.CancellationError; } });
Object.defineProperty(exports, "CancellationToken", { enumerable: true, get: function () { return CancellationToken_1.CancellationToken; } });
var error_1 = require("./error");
Object.defineProperty(exports, "newError", { enumerable: true, get: function () { return error_1.newError; } });
var httpExecutor_1 = require("./httpExecutor");
Object.defineProperty(exports, "configureRequestOptions", { enumerable: true, get: function () { return httpExecutor_1.configureRequestOptions; } });
Object.defineProperty(exports, "configureRequestOptionsFromUrl", { enumerable: true, get: function () { return httpExecutor_1.configureRequestOptionsFromUrl; } });
Object.defineProperty(exports, "configureRequestUrl", { enumerable: true, get: function () { return httpExecutor_1.configureRequestUrl; } });
Object.defineProperty(exports, "createHttpError", { enumerable: true, get: function () { return httpExecutor_1.createHttpError; } });
Object.defineProperty(exports, "DigestTransform", { enumerable: true, get: function () { return httpExecutor_1.DigestTransform; } });
Object.defineProperty(exports, "HttpError", { enumerable: true, get: function () { return httpExecutor_1.HttpError; } });
Object.defineProperty(exports, "hashSensitiveValue", { enumerable: true, get: function () { return httpExecutor_1.hashSensitiveValue; } });
Object.defineProperty(exports, "HttpExecutor", { enumerable: true, get: function () { return httpExecutor_1.HttpExecutor; } });
Object.defineProperty(exports, "isSensitiveFieldName", { enumerable: true, get: function () { return httpExecutor_1.isSensitiveFieldName; } });
Object.defineProperty(exports, "parseJson", { enumerable: true, get: function () { return httpExecutor_1.parseJson; } });
Object.defineProperty(exports, "safeGetHeader", { enumerable: true, get: function () { return httpExecutor_1.safeGetHeader; } });
Object.defineProperty(exports, "safeStringifyJson", { enumerable: true, get: function () { return httpExecutor_1.safeStringifyJson; } });
var MemoLazy_1 = require("./MemoLazy");
Object.defineProperty(exports, "MemoLazy", { enumerable: true, get: function () { return MemoLazy_1.MemoLazy; } });
var ProgressCallbackTransform_1 = require("./ProgressCallbackTransform");
Object.defineProperty(exports, "ProgressCallbackTransform", { enumerable: true, get: function () { return ProgressCallbackTransform_1.ProgressCallbackTransform; } });
var publishOptions_1 = require("./publishOptions");
Object.defineProperty(exports, "getS3LikeProviderBaseUrl", { enumerable: true, get: function () { return publishOptions_1.getS3LikeProviderBaseUrl; } });
Object.defineProperty(exports, "githubUrl", { enumerable: true, get: function () { return publishOptions_1.githubUrl; } });
Object.defineProperty(exports, "githubTagPrefix", { enumerable: true, get: function () { return publishOptions_1.githubTagPrefix; } });
var retry_1 = require("./retry");
Object.defineProperty(exports, "retry", { enumerable: true, get: function () { return retry_1.retry; } });
var rfc2253Parser_1 = require("./rfc2253Parser");
Object.defineProperty(exports, "parseDn", { enumerable: true, get: function () { return rfc2253Parser_1.parseDn; } });
var uuid_1 = require("./uuid");
Object.defineProperty(exports, "UUID", { enumerable: true, get: function () { return uuid_1.UUID; } });
var xml_1 = require("./xml");
Object.defineProperty(exports, "parseXml", { enumerable: true, get: function () { return xml_1.parseXml; } });
Object.defineProperty(exports, "XElement", { enumerable: true, get: function () { return xml_1.XElement; } });
var objects_1 = require("./objects");
Object.defineProperty(exports, "isValidKey", { enumerable: true, get: function () { return objects_1.isValidKey; } });
Object.defineProperty(exports, "mapToObject", { enumerable: true, get: function () { return objects_1.mapToObject; } });
Object.defineProperty(exports, "asArray", { enumerable: true, get: function () { return objects_1.asArray; } });
Object.defineProperty(exports, "deepAssign", { enumerable: true, get: function () { return objects_1.deepAssign; } });
Object.defineProperty(exports, "objectToArgs", { enumerable: true, get: function () { return objects_1.objectToArgs; } });
// nsis
exports.CURRENT_APP_INSTALLER_FILE_NAME = "installer.exe";
// nsis-web
exports.CURRENT_APP_PACKAGE_FILE_NAME = "package.7z";
//# sourceMappingURL=index.js.map
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AACA,yDAA0E;AAAjE,sHAAA,iBAAiB,OAAA;AAAE,sHAAA,iBAAiB,OAAA;AAC7C,iCAAkC;AAAzB,iGAAA,QAAQ,OAAA;AACjB,+CAeuB;AAdrB,uHAAA,uBAAuB,OAAA;AACvB,8HAAA,8BAA8B,OAAA;AAC9B,mHAAA,mBAAmB,OAAA;AACnB,+GAAA,eAAe,OAAA;AACf,+GAAA,eAAe,OAAA;AAEf,yGAAA,SAAS,OAAA;AACT,kHAAA,kBAAkB,OAAA;AAClB,4GAAA,YAAY,OAAA;AACZ,oHAAA,oBAAoB,OAAA;AACpB,yGAAA,SAAS,OAAA;AAET,6GAAA,aAAa,OAAA;AACb,iHAAA,iBAAiB,OAAA;AAEnB,uCAAqC;AAA5B,oGAAA,QAAQ,OAAA;AACjB,yEAAqF;AAA5E,sIAAA,yBAAyB,OAAA;AAClC,mDAmByB;AAbvB,0HAAA,wBAAwB,OAAA;AAExB,2GAAA,SAAS,OAAA;AACT,iHAAA,eAAe,OAAA;AAWjB,iCAA+B;AAAtB,8FAAA,KAAK,OAAA;AACd,iDAAyC;AAAhC,wGAAA,OAAO,OAAA;AAEhB,+BAA6B;AAApB,4FAAA,IAAI,OAAA;AACb,6BAA0C;AAAjC,+FAAA,QAAQ,OAAA;AAAE,+FAAA,QAAQ,OAAA;AAC3B,qCAA+F;AAAtF,qGAAA,UAAU,OAAA;AAAE,sGAAA,WAAW,OAAA;AAAE,kGAAA,OAAO,OAAA;AAAW,qGAAA,UAAU,OAAA;AAAE,uGAAA,YAAY,OAAA;AAE5E,OAAO;AACM,QAAA,+BAA+B,GAAG,eAAe,CAAA;AAC9D,WAAW;AACE,QAAA,6BAA6B,GAAG,YAAY,CAAA","sourcesContent":["export { BlockMap } from \"./blockMapApi\"\nexport { CancellationError, CancellationToken } from \"./CancellationToken\"\nexport { newError } from \"./error\"\nexport {\n configureRequestOptions,\n configureRequestOptionsFromUrl,\n configureRequestUrl,\n createHttpError,\n DigestTransform,\n DownloadOptions,\n HttpError,\n hashSensitiveValue,\n HttpExecutor,\n isSensitiveFieldName,\n parseJson,\n RequestHeaders,\n safeGetHeader,\n safeStringifyJson,\n} from \"./httpExecutor\"\nexport { MemoLazy } from \"./MemoLazy\"\nexport { ProgressCallbackTransform, ProgressInfo } from \"./ProgressCallbackTransform\"\nexport {\n AllPublishOptions,\n BaseS3Options,\n BitbucketOptions,\n CustomPublishOptions,\n GenericServerOptions,\n getS3LikeProviderBaseUrl,\n GithubOptions,\n githubUrl,\n githubTagPrefix,\n GitlabOptions,\n KeygenOptions,\n PublishConfiguration,\n PublishProvider,\n S3Options,\n SnapStoreOptions,\n SpacesOptions,\n GitlabReleaseInfo,\n GitlabReleaseAsset,\n} from \"./publishOptions\"\nexport { retry } from \"./retry\"\nexport { parseDn } from \"./rfc2253Parser\"\nexport { BlockMapDataHolder, PackageFileInfo, ReleaseNoteInfo, UpdateFileInfo, UpdateInfo, WindowsUpdateInfo } from \"./updateInfo\"\nexport { UUID } from \"./uuid\"\nexport { parseXml, XElement } from \"./xml\"\nexport { isValidKey, mapToObject, asArray, Nullish, deepAssign, objectToArgs } from \"./objects\"\n\n// nsis\nexport const CURRENT_APP_INSTALLER_FILE_NAME = \"installer.exe\"\n// nsis-web\nexport const CURRENT_APP_PACKAGE_FILE_NAME = \"package.7z\"\n"]}
export declare class MemoLazy<S, V> {
private selector;
private creator;
private selected;
private _value;
constructor(selector: () => S, creator: (selected: S) => Promise<V>);
get hasValue(): boolean;
get value(): Promise<V>;
set value(value: Promise<V>);
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MemoLazy = void 0;
class MemoLazy {
constructor(selector, creator) {
this.selector = selector;
this.creator = creator;
this.selected = undefined;
this._value = undefined;
}
get hasValue() {
return this._value !== undefined;
}
get value() {
const selected = this.selector();
if (this._value !== undefined && equals(this.selected, selected)) {
// value exists and selected hasn't changed, so return the cached value
return this._value;
}
this.selected = selected;
const result = this.creator(selected);
this.value = result;
return result;
}
set value(value) {
this._value = value;
}
}
exports.MemoLazy = MemoLazy;
function equals(firstValue, secondValue) {
const isFirstObject = typeof firstValue === "object" && firstValue !== null;
const isSecondObject = typeof secondValue === "object" && secondValue !== null;
// do a shallow comparison of objects, arrays etc.
if (isFirstObject && isSecondObject) {
const keys1 = Object.keys(firstValue);
const keys2 = Object.keys(secondValue);
return keys1.length === keys2.length && keys1.every((key) => equals(firstValue[key], secondValue[key]));
}
// otherwise just compare the values directly
return firstValue === secondValue;
}
//# sourceMappingURL=MemoLazy.js.map
{"version":3,"file":"MemoLazy.js","sourceRoot":"","sources":["../src/MemoLazy.ts"],"names":[],"mappings":";;;AAAA,MAAa,QAAQ;IAInB,YACU,QAAiB,EACjB,OAAoC;QADpC,aAAQ,GAAR,QAAQ,CAAS;QACjB,YAAO,GAAP,OAAO,CAA6B;QALtC,aAAQ,GAAkB,SAAS,CAAA;QACnC,WAAM,GAA2B,SAAS,CAAA;IAK/C,CAAC;IAEJ,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,MAAM,KAAK,SAAS,CAAA;IAClC,CAAC;IAED,IAAI,KAAK;QACP,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAA;QAChC,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,CAAC;YACjE,uEAAuE;YACvE,OAAO,IAAI,CAAC,MAAM,CAAA;QACpB,CAAC;QAED,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;QACrC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAA;QAEnB,OAAO,MAAM,CAAA;IACf,CAAC;IAED,IAAI,KAAK,CAAC,KAAiB;QACzB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;IACrB,CAAC;CACF;AA9BD,4BA8BC;AAED,SAAS,MAAM,CAAC,UAAe,EAAE,WAAgB;IAC/C,MAAM,aAAa,GAAG,OAAO,UAAU,KAAK,QAAQ,IAAI,UAAU,KAAK,IAAI,CAAA;IAC3E,MAAM,cAAc,GAAG,OAAO,WAAW,KAAK,QAAQ,IAAI,WAAW,KAAK,IAAI,CAAA;IAE9E,kDAAkD;IAClD,IAAI,aAAa,IAAI,cAAc,EAAE,CAAC;QACpC,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;QACrC,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;QAEtC,OAAO,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,GAAQ,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;IAC9G,CAAC;IAED,6CAA6C;IAC7C,OAAO,UAAU,KAAK,WAAW,CAAA;AACnC,CAAC","sourcesContent":["export class MemoLazy<S, V> {\n private selected: S | undefined = undefined\n private _value: Promise<V> | undefined = undefined\n\n constructor(\n private selector: () => S,\n private creator: (selected: S) => Promise<V>\n ) {}\n\n get hasValue() {\n return this._value !== undefined\n }\n\n get value(): Promise<V> {\n const selected = this.selector()\n if (this._value !== undefined && equals(this.selected, selected)) {\n // value exists and selected hasn't changed, so return the cached value\n return this._value\n }\n\n this.selected = selected\n const result = this.creator(selected)\n this.value = result\n\n return result\n }\n\n set value(value: Promise<V>) {\n this._value = value\n }\n}\n\nfunction equals(firstValue: any, secondValue: any): boolean {\n const isFirstObject = typeof firstValue === \"object\" && firstValue !== null\n const isSecondObject = typeof secondValue === \"object\" && secondValue !== null\n\n // do a shallow comparison of objects, arrays etc.\n if (isFirstObject && isSecondObject) {\n const keys1 = Object.keys(firstValue)\n const keys2 = Object.keys(secondValue)\n\n return keys1.length === keys2.length && keys1.every((key: any) => equals(firstValue[key], secondValue[key]))\n }\n\n // otherwise just compare the values directly\n return firstValue === secondValue\n}\n"]}
export type Nullish = null | undefined;
type RecursiveMap = Map<any, RecursiveMap | any>;
export declare function mapToObject(map: RecursiveMap): any;
export declare function isValidKey(key: any): boolean;
export declare function asArray<T>(v: Nullish | T | Array<T>): Array<T>;
export declare function deepAssign<T>(target: T, ...objects: Array<any>): T;
export declare function objectToArgs(obj: Record<string, string | null>): readonly string[];
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.mapToObject = mapToObject;
exports.isValidKey = isValidKey;
exports.asArray = asArray;
exports.deepAssign = deepAssign;
exports.objectToArgs = objectToArgs;
function mapToObject(map) {
const obj = {};
for (const [key, value] of map) {
if (!isValidKey(key)) {
continue;
}
if (value instanceof Map) {
obj[key] = mapToObject(value);
}
else {
obj[key] = value;
}
}
return obj;
}
function isValidKey(key) {
const protectedProperties = ["__proto__", "prototype", "constructor"];
if (protectedProperties.includes(key)) {
return false;
}
return ["string", "number", "symbol", "boolean"].includes(typeof key) || key === null;
}
function asArray(v) {
if (v == null) {
return [];
}
else if (Array.isArray(v)) {
return v;
}
else {
return [v];
}
}
function isObject(x) {
if (Array.isArray(x)) {
return false;
}
const type = typeof x;
return type === "object" || type === "function";
}
function assignKey(target, from, key) {
const value = from[key];
// https://github.com/electron-userland/electron-builder/pull/562
if (value === undefined) {
return;
}
const prevValue = target[key];
if (prevValue == null || value == null || !isObject(prevValue) || !isObject(value)) {
// Merge arrays.
if (Array.isArray(prevValue) && Array.isArray(value)) {
target[key] = Array.from(new Set(prevValue.concat(value)));
}
else {
target[key] = value;
}
}
else {
target[key] = assign(prevValue, value);
}
}
function assign(to, from) {
if (to !== from) {
for (const key of Object.getOwnPropertyNames(from)) {
if (isValidKey(key)) {
assignKey(to, from, key);
}
}
}
return to;
}
function deepAssign(target, ...objects) {
for (const o of objects) {
if (o != null) {
assign(target, o);
}
}
return target;
}
// Flag names must be letters/digits/hyphens only (e.g. "maintainer", "deb-priority").
// Anything else could inject extra flags into the argument array.
const SAFE_FLAG_NAME_RE = /^[a-zA-Z][a-zA-Z0-9-]*$/;
// Null bytes truncate arguments at the C layer; newlines can split arguments in some parsers.
const UNSAFE_VALUE_RE = /[\0\r\n]/;
function objectToArgs(obj) {
const args = Object.entries(obj).reduce((args, [name, value]) => {
if (!isValidKey(name) || value == null) {
return args;
}
if (!SAFE_FLAG_NAME_RE.test(name)) {
throw new Error(`objectToArgs: unsafe flag name rejected: ${JSON.stringify(name)}`);
}
if (UNSAFE_VALUE_RE.test(value)) {
throw new Error(`objectToArgs: value for --${name} contains a null byte or newline`);
}
return args.concat([`--${name}`, value]);
}, []);
return Object.freeze(args);
}
//# sourceMappingURL=objects.js.map
{"version":3,"file":"objects.js","sourceRoot":"","sources":["../src/objects.ts"],"names":[],"mappings":";;AAIA,kCAaC;AAED,gCAMC;AAED,0BAQC;AA0CD,gCAOC;AASD,oCAcC;AAvGD,SAAgB,WAAW,CAAC,GAAiB;IAC3C,MAAM,GAAG,GAAQ,EAAE,CAAA;IACnB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,GAAG,EAAE,CAAC;QAC/B,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACrB,SAAQ;QACV,CAAC;QACD,IAAI,KAAK,YAAY,GAAG,EAAE,CAAC;YACzB,GAAG,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,CAAA;QAC/B,CAAC;aAAM,CAAC;YACN,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;QAClB,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AAED,SAAgB,UAAU,CAAC,GAAQ;IACjC,MAAM,mBAAmB,GAAG,CAAC,WAAW,EAAE,WAAW,EAAE,aAAa,CAAC,CAAA;IACrE,IAAI,mBAAmB,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACtC,OAAO,KAAK,CAAA;IACd,CAAC;IACD,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC,QAAQ,CAAC,OAAO,GAAG,CAAC,IAAI,GAAG,KAAK,IAAI,CAAA;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I,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QACrF,CAAC;QACD,IAAI,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,6BAA6B,IAAI,kCAAkC,CAAC,CAAA;QACtF,CAAC;QACD,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,IAAI,EAAE,EAAE,KAAK,CAAC,CAAC,CAAA;IAC1C,CAAC,EAAE,EAAE,CAAC,CAAA;IACN,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;AAC5B,CAAC","sourcesContent":["export type Nullish = null | undefined\n\ntype RecursiveMap = Map<any, RecursiveMap | any>\n\nexport function mapToObject(map: RecursiveMap) {\n const obj: any = {}\n for (const [key, value] of map) {\n if (!isValidKey(key)) {\n continue\n }\n if (value instanceof Map) {\n obj[key] = mapToObject(value)\n } else {\n obj[key] = value\n }\n }\n return obj\n}\n\nexport function isValidKey(key: any) {\n const protectedProperties = [\"__proto__\", \"prototype\", \"constructor\"]\n if (protectedProperties.includes(key)) {\n return false\n }\n return [\"string\", \"number\", \"symbol\", \"boolean\"].includes(typeof key) || key === null\n}\n\nexport function asArray<T>(v: Nullish | T | Array<T>): Array<T> {\n if (v == null) {\n return []\n } else if (Array.isArray(v)) {\n return v\n } else {\n return [v]\n }\n}\n\nfunction isObject(x: any) {\n if (Array.isArray(x)) {\n return false\n }\n\n const type = typeof x\n return type === \"object\" || type === \"function\"\n}\n\nfunction assignKey(target: any, from: any, key: string) {\n const value = from[key]\n // https://github.com/electron-userland/electron-builder/pull/562\n if (value === undefined) {\n return\n }\n\n const prevValue = target[key]\n if (prevValue == null || value == null || !isObject(prevValue) || !isObject(value)) {\n // Merge arrays.\n if (Array.isArray(prevValue) && Array.isArray(value)) {\n target[key] = Array.from(new Set(prevValue.concat(value)))\n } else {\n target[key] = value\n }\n } else {\n target[key] = assign(prevValue, value)\n }\n}\n\nfunction assign(to: any, from: any) {\n if (to !== from) {\n for (const key of Object.getOwnPropertyNames(from)) {\n if (isValidKey(key)) {\n assignKey(to, from, key)\n }\n }\n }\n return to\n}\n\nexport function deepAssign<T>(target: T, ...objects: Array<any>): T {\n for (const o of objects) {\n if (o != null) {\n assign(target, o)\n }\n }\n return target\n}\n\n// Flag names must be letters/digits/hyphens only (e.g. \"maintainer\", \"deb-priority\").\n// Anything else could inject extra flags into the argument array.\nconst SAFE_FLAG_NAME_RE = /^[a-zA-Z][a-zA-Z0-9-]*$/\n\n// Null bytes truncate arguments at the C layer; newlines can split arguments in some parsers.\nconst UNSAFE_VALUE_RE = /[\\0\\r\\n]/\n\nexport function objectToArgs(obj: Record<string, string | null>): readonly string[] {\n const args = Object.entries(obj).reduce<string[]>((args, [name, value]) => {\n if (!isValidKey(name) || value == null) {\n return args\n }\n if (!SAFE_FLAG_NAME_RE.test(name)) {\n throw new Error(`objectToArgs: unsafe flag name rejected: ${JSON.stringify(name)}`)\n }\n if (UNSAFE_VALUE_RE.test(value)) {\n throw new Error(`objectToArgs: value for --${name} contains a null byte or newline`)\n }\n return args.concat([`--${name}`, value])\n }, [])\n return Object.freeze(args)\n}\n"]}
import { Transform } from "stream";
import { CancellationToken } from "./CancellationToken";
export interface ProgressInfo {
total: number;
delta: number;
transferred: number;
percent: number;
bytesPerSecond: number;
}
export declare class ProgressCallbackTransform extends Transform {
private readonly total;
private readonly cancellationToken;
private readonly onProgress;
private start;
private transferred;
private delta;
private nextUpdate;
constructor(total: number, cancellationToken: CancellationToken, onProgress: (info: ProgressInfo) => any);
_transform(chunk: any, encoding: string, callback: any): void;
_flush(callback: any): void;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ProgressCallbackTransform = void 0;
const stream_1 = require("stream");
class ProgressCallbackTransform extends stream_1.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;
}
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.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
{"version":3,"file":"ProgressCallbackTransform.js","sourceRoot":"","sources":["../src/ProgressCallbackTransform.ts"],"names":[],"mappings":";;;AAAA,mCAAkC;AAWlC,MAAa,yBAA0B,SAAQ,kBAAS;IAOtD,YACmB,KAAa,EACb,iBAAoC,EACpC,UAAuC;QAExD,KAAK,EAAE,CAAA;QAJU,UAAK,GAAL,KAAK,CAAQ;QACb,sBAAiB,GAAjB,iBAAiB,CAAmB;QACpC,eAAU,GAAV,UAAU,CAA6B;QATlD,UAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;QAClB,gBAAW,GAAG,CAAC,CAAA;QACf,UAAK,GAAG,CAAC,CAAA;QAET,eAAU,GAAG,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;IAQtC,CAAC;IAED,UAAU,CAAC,KAAU,EAAE,QAAgB,EAAE,QAAa;QACpD,IAAI,IAAI,CAAC,iBAAiB,CAAC,SAAS,EAAE,CAAC;YACrC,QAAQ,CAAC,IAAI,KAAK,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC,CAAA;Y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AC,WAAW,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;SAClF,CAAC,CAAA;QACF,IAAI,CAAC,KAAK,GAAG,CAAC,CAAA;QAEd,QAAQ,CAAC,IAAI,CAAC,CAAA;IAChB,CAAC;CACF;AA1DD,8DA0DC","sourcesContent":["import { Transform } from \"stream\"\nimport { CancellationToken } from \"./CancellationToken\"\n\nexport interface ProgressInfo {\n total: number\n delta: number\n transferred: number\n percent: number\n bytesPerSecond: number\n}\n\nexport class ProgressCallbackTransform extends Transform {\n private start = Date.now()\n private transferred = 0\n private delta = 0\n\n private nextUpdate = this.start + 1000\n\n constructor(\n private readonly total: number,\n private readonly cancellationToken: CancellationToken,\n private readonly onProgress: (info: ProgressInfo) => any\n ) {\n super()\n }\n\n _transform(chunk: any, encoding: string, callback: any) {\n if (this.cancellationToken.cancelled) {\n callback(new Error(\"cancelled\"), null)\n return\n }\n\n this.transferred += chunk.length\n this.delta += chunk.length\n\n const now = Date.now()\n if (now >= this.nextUpdate && this.transferred !== this.total /* will be emitted on _flush */) {\n this.nextUpdate = now + 1000\n\n this.onProgress({\n total: this.total,\n delta: this.delta,\n transferred: this.transferred,\n percent: (this.transferred / this.total) * 100,\n bytesPerSecond: Math.round(this.transferred / ((now - this.start) / 1000)),\n })\n this.delta = 0\n }\n\n callback(null, chunk)\n }\n\n _flush(callback: any): void {\n if (this.cancellationToken.cancelled) {\n callback(new Error(\"cancelled\"))\n return\n }\n\n this.onProgress({\n total: this.total,\n delta: this.delta,\n transferred: this.total,\n percent: 100,\n bytesPerSecond: Math.round(this.transferred / ((Date.now() - this.start) / 1000)),\n })\n this.delta = 0\n\n callback(null)\n }\n}\n"]}
import { OutgoingHttpHeaders } from "http";
export type PublishProvider = "github" | "gitlab" | "s3" | "spaces" | "generic" | "custom" | "snapStore" | "keygen" | "bitbucket";
export type AllPublishOptions = string | GithubOptions | GitlabOptions | S3Options | SpacesOptions | GenericServerOptions | CustomPublishOptions | KeygenOptions | SnapStoreOptions | BitbucketOptions;
export interface PublishConfiguration {
/**
* The provider.
*/
readonly provider: PublishProvider;
/**
* @private
* win-only
*/
publisherName?: Array<string> | null;
/**
* @private
* win-only
*/
readonly updaterCacheDirName?: 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;
/**
* Any custom request headers
*/
readonly requestHeaders?: OutgoingHttpHeaders;
/**
* Request timeout in milliseconds. (Default is 2 minutes; O is ignored)
*
* @default 120000
*/
readonly timeout?: number | null;
}
export interface CustomPublishOptions extends PublishConfiguration {
/**
* The provider. Must be `custom`.
*/
readonly provider: "custom";
/**
* The Provider to provide UpdateInfo regarding available updates. Required
* to use custom providers with electron-updater.
*/
updateProvider?: new (options: CustomPublishOptions, updater: any, runtimeOptions: any) => any;
[index: string]: any;
}
/**
* [GitHub](https://help.github.com/articles/about-releases/) options.
*
* GitHub [personal access token](https://help.github.com/articles/creating-an-access-token-for-command-line-use/) is required. You can generate by going to [https://github.com/settings/tokens/new](https://github.com/settings/tokens/new). The access token should have the repo scope/permission.
* Define `GH_TOKEN` environment variable.
*/
export interface GithubOptions extends PublishConfiguration {
/**
* The provider. Must be `github`.
*/
readonly provider: "github";
/**
* The repository name. [Detected automatically](#github-repository-and-bintray-package).
*/
readonly repo?: string | null;
/**
* The owner.
*/
readonly owner?: string | null;
/**
* Whether to use `v`-prefixed tag name.
* @default true
* @deprecated please use #tagNamePrefix instead.
*/
readonly vPrefixedTagName?: boolean;
/**
* If defined, sets the prefix of the tag name that comes before the semver number.
* e.g. "v" in "v1.2.3" or "test" of "test1.2.3".
* Overrides `vPrefixedTagName`
*/
readonly tagNamePrefix?: string;
/**
* The host (including the port if need).
* @default github.com
*/
readonly host?: string | null;
/**
* The protocol. GitHub Publisher supports only `https`.
* @default https
*/
readonly protocol?: "https" | "http" | null;
/**
* The access token to support auto-update from private github repositories. Never specify it in the configuration files. Only for [setFeedURL](https://www.electron.build/auto-update#appupdatersetfeedurloptions).
*/
readonly token?: string | null;
/**
* Whether to use private github auto-update provider if `GH_TOKEN` environment variable is defined. See [Private GitHub Update Repo](https://www.electron.build/auto-update#private-github-update-repo).
*/
readonly private?: boolean | null;
/**
* The channel.
* @default latest
*/
readonly channel?: string | null;
/**
* The type of release. By default `draft` release will be created.
*
* Also you can set release type using environment variable. If `EP_DRAFT`is set to `true` — `draft`, if `EP_PRE_RELEASE`is set to `true` — `prerelease`.
* @default draft
*/
releaseType?: "draft" | "prerelease" | "release" | null;
}
/** @private */
export declare function githubUrl(options: GithubOptions, defaultHost?: string): string;
export declare function githubTagPrefix(options: GithubOptions): string;
/**
* [GitLab](https://docs.gitlab.com/ee/user/project/releases/) options.
*
* GitLab [personal access token](https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html) is required for private repositories. You can generate one by going to your GitLab profile settings.
* Define `GITLAB_TOKEN` environment variable.
*/
export interface GitlabOptions extends PublishConfiguration {
/**
* The provider. Must be `gitlab`.
*/
readonly provider: "gitlab";
/**
* The GitLab project ID or path (e.g., "12345678" or "namespace/project").
*/
readonly projectId?: string | number | null;
/**
* The GitLab host (including the port if need).
* @default gitlab.com
*/
readonly host?: string | null;
/**
* The access token to support auto-update from private GitLab repositories. Never specify it in the configuration files.
*/
readonly token?: string | null;
/**
* Whether to use `v`-prefixed tag name.
* @default true
*/
readonly vPrefixedTagName?: boolean;
/**
* The channel.
* @default latest
*/
readonly channel?: string | null;
/**
* Upload target method. Can be "project_upload" for GitLab project uploads or "generic_package" for GitLab generic packages.
* @default "project_upload"
*/
readonly uploadTarget?: "project_upload" | "generic_package" | null;
}
/**
* Generic (any HTTP(S) server) options.
* In all publish options [File Macros](https://www.electron.build/file-patterns#file-macros) are supported.
*/
export interface GenericServerOptions extends PublishConfiguration {
/**
* The provider. Must be `generic`.
*/
readonly provider: "generic";
/**
* The base url. e.g. `https://bucket_name.s3.amazonaws.com`.
*/
readonly url: string;
/**
* The channel.
* @default latest
*/
readonly channel?: string | null;
/**
* Whether to use multiple range requests for differential update. Defaults to `true` if `url` doesn't contain `s3.amazonaws.com`.
*/
readonly useMultipleRangeRequest?: boolean;
}
/**
* Keygen options.
* https://keygen.sh/
* Define `KEYGEN_TOKEN` environment variable.
*/
export interface KeygenOptions extends PublishConfiguration {
/**
* The provider. Must be `keygen`.
*/
readonly provider: "keygen";
/**
* Keygen host for self-hosted instances
* @default "api.keygen.sh"
*/
readonly host?: string;
/**
* Keygen account's UUID
*/
readonly account: string;
/**
* Keygen product's UUID
*/
readonly product: string;
/**
* The channel.
* @default stable
*/
readonly channel?: "stable" | "rc" | "beta" | "alpha" | "dev" | null;
/**
* The target Platform. Is set programmatically explicitly during publishing.
*/
readonly platform?: string | null;
}
/**
* Bitbucket options.
* https://bitbucket.org/
* Define `BITBUCKET_TOKEN` environment variable.
*
* For converting an app password to a usable token, you can utilize this
```typescript
convertAppPassword(owner: string, appPassword: string) {
const base64encodedData = Buffer.from(`${owner}:${appPassword.trim()}`).toString("base64")
return `Basic ${base64encodedData}`
}
```
*/
export interface BitbucketOptions extends PublishConfiguration {
/**
* The provider. Must be `bitbucket`.
*/
readonly provider: "bitbucket";
/**
* Repository owner
*/
readonly owner: string;
/**
* The [app password](https://bitbucket.org/account/settings/app-passwords) to support auto-update from private bitbucket repositories.
*/
readonly token?: string | null;
/**
* The user name to support auto-update from private bitbucket repositories.
*/
readonly username?: string | null;
/**
* Repository slug/name
*/
readonly slug: string;
/**
* The channel.
* @default latest
*/
readonly channel?: string | null;
}
/**
* [Snap Store](https://snapcraft.io/) options. To publish directly to Snapcraft, see <a href="https://snapcraft.io/docs/snapcraft-authentication">Snapcraft authentication options</a> for local or CI/CD authentication options.
*/
export interface SnapStoreOptions extends PublishConfiguration {
/**
* The provider. Must be `snapStore`.
*/
readonly provider: "snapStore";
/**
* snapcraft repo name
*/
readonly repo?: string;
/**
* The list of channels the snap would be released.
* @default ["edge"]
*/
readonly channels?: string | Array<string> | null;
}
export interface BaseS3Options extends PublishConfiguration {
/**
* The update channel.
* @default latest
*/
channel?: string | null;
/**
* The directory path.
* @default /
*/
readonly path?: string | null;
/**
* The ACL. Set to `null` to not [add](https://github.com/electron-userland/electron-builder/issues/1822).
*
* @default public-read
*/
readonly acl?: "private" | "public-read" | null;
}
/**
* [Amazon S3](https://aws.amazon.com/s3/) options.
* AWS credentials are required, please see [getting your credentials](http://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/getting-your-credentials.html).
* To set credentials define `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` [environment variables](http://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/loading-node-credentials-environment.html) directly,
* or use [~/.aws/credentials](http://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/loading-node-credentials-shared.html) file,
* or use [~/.aws/config](https://docs.aws.amazon.com/sdkref/latest/guide/file-format.html) file. For the last method to work you will also need to define `AWS_SDK_LOAD_CONFIG=1` environment variable.
*
* Example configuration:
*
```json
{
"build":
"publish": {
"provider": "s3",
"bucket": "bucket-name"
}
}
}
```
*/
export interface S3Options extends BaseS3Options {
/**
* The provider. Must be `s3`.
*/
readonly provider: "s3";
/**
* The bucket name.
*/
readonly bucket: string;
/**
* The region. Is determined and set automatically when publishing.
*/
region?: string | null;
/**
* The ACL. Set to `null` to not [add](https://github.com/electron-userland/electron-builder/issues/1822).
*
* Please see [required permissions for the S3 provider](https://github.com/electron-userland/electron-builder/issues/1618#issuecomment-314679128).
*
* @default public-read
*/
readonly acl?: "private" | "public-read" | null;
/**
* The type of storage to use for the object.
* @default STANDARD
*/
readonly storageClass?: "STANDARD" | "REDUCED_REDUNDANCY" | "STANDARD_IA" | null;
/**
* Server-side encryption algorithm to use for the object.
*/
readonly encryption?: "AES256" | "aws:kms" | null;
/**
* The endpoint URI to send requests to. The default endpoint is built from the configured region.
* The endpoint should be a string like `https://{service}.{region}.amazonaws.com`.
*/
readonly endpoint?: string | null;
/**
* If set to true, this will enable the s3 accelerated endpoint
* These endpoints have a particular format of:
* ${bucketname}.s3-accelerate.amazonaws.com
*/
readonly accelerate?: boolean;
/**
* When true, force a path-style endpoint to be used where the bucket name is part of the path.
* [Path-style Access](https://docs.aws.amazon.com/AmazonS3/latest/userguide/VirtualHosting.html#path-style-access)
*/
readonly forcePathStyle?: boolean;
}
/**
* [DigitalOcean Spaces](https://www.digitalocean.com/community/tutorials/an-introduction-to-digitalocean-spaces) options.
* Access key is required, define `DO_KEY_ID` and `DO_SECRET_KEY` environment variables.
*/
export interface SpacesOptions extends BaseS3Options {
/**
* The provider. Must be `spaces`.
*/
readonly provider: "spaces";
/**
* The space name.
*/
readonly name: string;
/**
* The region (e.g. `nyc3`).
*/
readonly region: string;
}
export interface GitlabReleaseInfo {
name: string;
tag_name: string;
description: string;
created_at: string;
released_at: string;
upcoming_release: boolean;
assets: GitlabReleaseAsset;
}
export interface GitlabReleaseAsset {
count: number;
sources: Array<{
format: string;
url: string;
}>;
links: Array<{
id: number;
name: string;
url: string;
direct_asset_url: string;
link_type: string;
}>;
}
export declare function getS3LikeProviderBaseUrl(configuration: PublishConfiguration): string;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.githubUrl = githubUrl;
exports.githubTagPrefix = githubTagPrefix;
exports.getS3LikeProviderBaseUrl = getS3LikeProviderBaseUrl;
/** @private */
function githubUrl(options, defaultHost = "github.com") {
return `${options.protocol || "https"}://${options.host || defaultHost}`;
}
function githubTagPrefix(options) {
var _a;
if (options.tagNamePrefix) {
return options.tagNamePrefix;
}
if ((_a = options.vPrefixedTagName) !== null && _a !== void 0 ? _a : true) {
return "v";
}
return "";
}
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}`);
}
function s3Url(options) {
let url;
if (options.accelerate == true) {
url = `https://${options.bucket}.s3-accelerate.amazonaws.com`;
}
else if (options.endpoint != null) {
url = `${options.endpoint}/${options.bucket}`;
}
else if (options.bucket.includes(".")) {
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
if (options.region === "us-east-1") {
url = `https://s3.amazonaws.com/${options.bucket}`;
}
else {
url = `https://s3-${options.region}.amazonaws.com/${options.bucket}`;
}
}
else if (options.region === "cn-north-1") {
url = `https://${options.bucket}.s3.${options.region}.amazonaws.com.cn`;
}
else {
url = `https://${options.bucket}.s3.amazonaws.com`;
}
return appendPath(url, options.path);
}
function appendPath(url, p) {
if (p != null && p.length > 0) {
if (!p.startsWith("/")) {
url += "/";
}
url += p;
}
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`);
}
return appendPath(`https://${options.name}.${options.region}.digitaloceanspaces.com`, options.path);
}
//# sourceMappingURL=publishOptions.js.map
{"version":3,"file":"publishOptions.js","sourceRoot":"","sources":["../src/publishOptions.ts"],"names":[],"mappings":";;AAqJA,8BAEC;AAED,0CAQC;AAqUD,4DASC;AA3VD,eAAe;AACf,SAAgB,SAAS,CAAC,OAAsB,EAAE,WAAW,GAAG,YAAY;IAC1E,OAAO,GAAG,OAAO,CAAC,QAAQ,IAAI,OAAO,MAAM,OAAO,CAAC,IAAI,IAAI,WAAW,EAAE,CAAA;AAC1E,CAAC;AAED,SAAgB,eAAe,CAAC,OAAsB;;IACpD,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;QAC1B,OAAO,OAAO,CAAC,aAAa,CAAA;IAC9B,CAAC;IACD,IAAI,MAAA,OAAO,CAAC,gBAAgB,mCAAI,IAAI,EAAE,CAAC;QACrC,OAAO,GAAG,CAAA;IACZ,CAAC;IACD,OAAO,EAAE,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C3C,GAAG,GAAG,WAAW,OAAO,CAAC,MAAM,OAAO,OAAO,CAAC,MAAM,mBAAmB,CAAA;IACzE,CAAC;SAAM,CAAC;QACN,GAAG,GAAG,WAAW,OAAO,CAAC,MAAM,mBAAmB,CAAA;IACpD,CAAC;IACD,OAAO,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,CAAC,CAAA;AACtC,CAAC;AAED,SAAS,UAAU,CAAC,GAAW,EAAE,CAAmB;IAClD,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC9B,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACvB,GAAG,IAAI,GAAG,CAAA;QACZ,CAAC;QACD,GAAG,IAAI,CAAC,CAAA;IACV,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AAED,SAAS,SAAS,CAAC,OAAsB;IACvC,IAAI,OAAO,CAAC,IAAI,IAAI,IAAI,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAA;IACpC,CAAC;IACD,IAAI,OAAO,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAA;IACtC,CAAC;IACD,OAAO,UAAU,CAAC,WAAW,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,MAAM,yBAAyB,EAAE,OAAO,CAAC,IAAI,CAAC,CAAA;AACrG,CAAC","sourcesContent":["import { OutgoingHttpHeaders } from \"http\"\nimport { Nullish } from \".\"\n\nexport type PublishProvider = \"github\" | \"gitlab\" | \"s3\" | \"spaces\" | \"generic\" | \"custom\" | \"snapStore\" | \"keygen\" | \"bitbucket\"\n\n// typescript-json-schema generates only PublishConfiguration if it is specified in the list, so, it is not added here\nexport type AllPublishOptions =\n | string\n | GithubOptions\n | GitlabOptions\n | S3Options\n | SpacesOptions\n | GenericServerOptions\n | CustomPublishOptions\n | KeygenOptions\n | SnapStoreOptions\n | BitbucketOptions\n\nexport interface PublishConfiguration {\n /**\n * The provider.\n */\n readonly provider: PublishProvider\n\n /**\n * @private\n * win-only\n */\n publisherName?: Array<string> | null\n\n /**\n * @private\n * win-only\n */\n readonly updaterCacheDirName?: string | null\n\n /**\n * Whether to publish auto update info files.\n *\n * Auto update relies only on the first provider in the list (you can specify several publishers).\n * Thus, probably, there`s no need to upload the metadata files for the other configured providers. But by default will be uploaded.\n *\n * @default true\n */\n readonly publishAutoUpdate?: boolean\n\n /**\n * Any custom request headers\n */\n readonly requestHeaders?: OutgoingHttpHeaders\n\n /**\n * Request timeout in milliseconds. (Default is 2 minutes; O is ignored)\n *\n * @default 120000\n */\n readonly timeout?: number | null\n}\n\n// https://github.com/electron-userland/electron-builder/issues/3261\nexport interface CustomPublishOptions extends PublishConfiguration {\n /**\n * The provider. Must be `custom`.\n */\n readonly provider: \"custom\"\n\n /**\n * The Provider to provide UpdateInfo regarding available updates. Required\n * to use custom providers with electron-updater.\n */\n updateProvider?: new (options: CustomPublishOptions, updater: any, runtimeOptions: any) => any\n\n [index: string]: any\n}\n\n/**\n * [GitHub](https://help.github.com/articles/about-releases/) options.\n *\n * GitHub [personal access token](https://help.github.com/articles/creating-an-access-token-for-command-line-use/) is required. You can generate by going to [https://github.com/settings/tokens/new](https://github.com/settings/tokens/new). The access token should have the repo scope/permission.\n * Define `GH_TOKEN` environment variable.\n */\nexport interface GithubOptions extends PublishConfiguration {\n /**\n * The provider. Must be `github`.\n */\n readonly provider: \"github\"\n\n /**\n * The repository name. [Detected automatically](#github-repository-and-bintray-package).\n */\n readonly repo?: string | null\n\n /**\n * The owner.\n */\n readonly owner?: string | null\n\n /**\n * Whether to use `v`-prefixed tag name.\n * @default true\n * @deprecated please use #tagNamePrefix instead.\n */\n readonly vPrefixedTagName?: boolean\n\n /**\n * If defined, sets the prefix of the tag name that comes before the semver number.\n * e.g. \"v\" in \"v1.2.3\" or \"test\" of \"test1.2.3\".\n * Overrides `vPrefixedTagName`\n */\n readonly tagNamePrefix?: string\n\n /**\n * The host (including the port if need).\n * @default github.com\n */\n readonly host?: string | null\n\n /**\n * The protocol. GitHub Publisher supports only `https`.\n * @default https\n */\n readonly protocol?: \"https\" | \"http\" | null\n\n /**\n * The access token to support auto-update from private github repositories. Never specify it in the configuration files. Only for [setFeedURL](https://www.electron.build/auto-update#appupdatersetfeedurloptions).\n */\n readonly token?: string | null\n\n /**\n * Whether to use private github auto-update provider if `GH_TOKEN` environment variable is defined. See [Private GitHub Update Repo](https://www.electron.build/auto-update#private-github-update-repo).\n */\n readonly private?: boolean | null\n\n /**\n * The channel.\n * @default latest\n */\n readonly channel?: string | null\n\n /**\n * The type of release. By default `draft` release will be created.\n *\n * Also you can set release type using environment variable. If `EP_DRAFT`is set to `true` — `draft`, if `EP_PRE_RELEASE`is set to `true` — `prerelease`.\n * @default draft\n */\n releaseType?: \"draft\" | \"prerelease\" | \"release\" | null\n}\n\n/** @private */\nexport function githubUrl(options: GithubOptions, defaultHost = \"github.com\") {\n return `${options.protocol || \"https\"}://${options.host || defaultHost}`\n}\n\nexport function githubTagPrefix(options: GithubOptions) {\n if (options.tagNamePrefix) {\n return options.tagNamePrefix\n }\n if (options.vPrefixedTagName ?? true) {\n return \"v\"\n }\n return \"\"\n}\n\n/**\n * [GitLab](https://docs.gitlab.com/ee/user/project/releases/) options.\n *\n * GitLab [personal access token](https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html) is required for private repositories. You can generate one by going to your GitLab profile settings.\n * Define `GITLAB_TOKEN` environment variable.\n */\nexport interface GitlabOptions extends PublishConfiguration {\n /**\n * The provider. Must be `gitlab`.\n */\n readonly provider: \"gitlab\"\n\n /**\n * The GitLab project ID or path (e.g., \"12345678\" or \"namespace/project\").\n */\n readonly projectId?: string | number | null\n\n /**\n * The GitLab host (including the port if need).\n * @default gitlab.com\n */\n readonly host?: string | null\n\n /**\n * The access token to support auto-update from private GitLab repositories. Never specify it in the configuration files.\n */\n readonly token?: string | null\n\n /**\n * Whether to use `v`-prefixed tag name.\n * @default true\n */\n readonly vPrefixedTagName?: boolean\n\n /**\n * The channel.\n * @default latest\n */\n readonly channel?: string | null\n\n /**\n * Upload target method. Can be \"project_upload\" for GitLab project uploads or \"generic_package\" for GitLab generic packages.\n * @default \"project_upload\"\n */\n readonly uploadTarget?: \"project_upload\" | \"generic_package\" | null\n}\n\n/**\n * Generic (any HTTP(S) server) options.\n * In all publish options [File Macros](https://www.electron.build/file-patterns#file-macros) are supported.\n */\nexport interface GenericServerOptions extends PublishConfiguration {\n /**\n * The provider. Must be `generic`.\n */\n readonly provider: \"generic\"\n\n /**\n * The base url. e.g. `https://bucket_name.s3.amazonaws.com`.\n */\n readonly url: string\n\n /**\n * The channel.\n * @default latest\n */\n readonly channel?: string | null\n\n /**\n * Whether to use multiple range requests for differential update. Defaults to `true` if `url` doesn't contain `s3.amazonaws.com`.\n */\n readonly useMultipleRangeRequest?: boolean\n}\n\n/**\n * Keygen options.\n * https://keygen.sh/\n * Define `KEYGEN_TOKEN` environment variable.\n */\nexport interface KeygenOptions extends PublishConfiguration {\n /**\n * The provider. Must be `keygen`.\n */\n readonly provider: \"keygen\"\n\n /**\n * Keygen host for self-hosted instances\n * @default \"api.keygen.sh\"\n */\n readonly host?: string\n\n /**\n * Keygen account's UUID\n */\n readonly account: string\n\n /**\n * Keygen product's UUID\n */\n readonly product: string\n\n /**\n * The channel.\n * @default stable\n */\n readonly channel?: \"stable\" | \"rc\" | \"beta\" | \"alpha\" | \"dev\" | null\n\n /**\n * The target Platform. Is set programmatically explicitly during publishing.\n */\n readonly platform?: string | null\n}\n\n/**\n * Bitbucket options.\n * https://bitbucket.org/\n * Define `BITBUCKET_TOKEN` environment variable.\n *\n * For converting an app password to a usable token, you can utilize this\n```typescript\nconvertAppPassword(owner: string, appPassword: string) {\n const base64encodedData = Buffer.from(`${owner}:${appPassword.trim()}`).toString(\"base64\")\n return `Basic ${base64encodedData}`\n}\n```\n */\nexport interface BitbucketOptions extends PublishConfiguration {\n /**\n * The provider. Must be `bitbucket`.\n */\n readonly provider: \"bitbucket\"\n\n /**\n * Repository owner\n */\n readonly owner: string\n\n /**\n * The [app password](https://bitbucket.org/account/settings/app-passwords) to support auto-update from private bitbucket repositories.\n */\n readonly token?: string | null\n\n /**\n * The user name to support auto-update from private bitbucket repositories.\n */\n readonly username?: string | null\n\n /**\n * Repository slug/name\n */\n readonly slug: string\n\n /**\n * The channel.\n * @default latest\n */\n readonly channel?: string | null\n}\n\n/**\n * [Snap Store](https://snapcraft.io/) options. To publish directly to Snapcraft, see <a href=\"https://snapcraft.io/docs/snapcraft-authentication\">Snapcraft authentication options</a> for local or CI/CD authentication options.\n */\nexport interface SnapStoreOptions extends PublishConfiguration {\n /**\n * The provider. Must be `snapStore`.\n */\n readonly provider: \"snapStore\"\n\n /**\n * snapcraft repo name\n */\n readonly repo?: string\n\n /**\n * The list of channels the snap would be released.\n * @default [\"edge\"]\n */\n readonly channels?: string | Array<string> | null\n}\n\nexport interface BaseS3Options extends PublishConfiguration {\n /**\n * The update channel.\n * @default latest\n */\n channel?: string | null\n\n /**\n * The directory path.\n * @default /\n */\n readonly path?: string | null\n\n /**\n * The ACL. Set to `null` to not [add](https://github.com/electron-userland/electron-builder/issues/1822).\n *\n * @default public-read\n */\n readonly acl?: \"private\" | \"public-read\" | null\n}\n\n/**\n * [Amazon S3](https://aws.amazon.com/s3/) options.\n * AWS credentials are required, please see [getting your credentials](http://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/getting-your-credentials.html).\n * To set credentials define `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` [environment variables](http://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/loading-node-credentials-environment.html) directly,\n * or use [~/.aws/credentials](http://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/loading-node-credentials-shared.html) file,\n * or use [~/.aws/config](https://docs.aws.amazon.com/sdkref/latest/guide/file-format.html) file. For the last method to work you will also need to define `AWS_SDK_LOAD_CONFIG=1` environment variable.\n *\n * Example configuration:\n *\n```json\n{\n \"build\":\n \"publish\": {\n \"provider\": \"s3\",\n \"bucket\": \"bucket-name\"\n }\n }\n}\n```\n */\nexport interface S3Options extends BaseS3Options {\n /**\n * The provider. Must be `s3`.\n */\n readonly provider: \"s3\"\n\n /**\n * The bucket name.\n */\n readonly bucket: string\n\n /**\n * The region. Is determined and set automatically when publishing.\n */\n region?: string | null\n\n /**\n * The ACL. Set to `null` to not [add](https://github.com/electron-userland/electron-builder/issues/1822).\n *\n * Please see [required permissions for the S3 provider](https://github.com/electron-userland/electron-builder/issues/1618#issuecomment-314679128).\n *\n * @default public-read\n */\n readonly acl?: \"private\" | \"public-read\" | null\n\n /**\n * The type of storage to use for the object.\n * @default STANDARD\n */\n readonly storageClass?: \"STANDARD\" | \"REDUCED_REDUNDANCY\" | \"STANDARD_IA\" | null\n\n /**\n * Server-side encryption algorithm to use for the object.\n */\n readonly encryption?: \"AES256\" | \"aws:kms\" | null\n\n /**\n * The endpoint URI to send requests to. The default endpoint is built from the configured region.\n * The endpoint should be a string like `https://{service}.{region}.amazonaws.com`.\n */\n readonly endpoint?: string | null\n\n /**\n * If set to true, this will enable the s3 accelerated endpoint\n * These endpoints have a particular format of:\n * ${bucketname}.s3-accelerate.amazonaws.com\n */\n readonly accelerate?: boolean\n\n /**\n * When true, force a path-style endpoint to be used where the bucket name is part of the path.\n * [Path-style Access](https://docs.aws.amazon.com/AmazonS3/latest/userguide/VirtualHosting.html#path-style-access)\n */\n readonly forcePathStyle?: boolean\n}\n\n/**\n * [DigitalOcean Spaces](https://www.digitalocean.com/community/tutorials/an-introduction-to-digitalocean-spaces) options.\n * Access key is required, define `DO_KEY_ID` and `DO_SECRET_KEY` environment variables.\n */\nexport interface SpacesOptions extends BaseS3Options {\n /**\n * The provider. Must be `spaces`.\n */\n readonly provider: \"spaces\"\n\n /**\n * The space name.\n */\n readonly name: string\n\n /**\n * The region (e.g. `nyc3`).\n */\n readonly region: string\n}\n\nexport interface GitlabReleaseInfo {\n name: string\n tag_name: string\n description: string\n created_at: string\n released_at: string\n upcoming_release: boolean\n assets: GitlabReleaseAsset\n}\n\nexport interface GitlabReleaseAsset {\n count: number\n sources: Array<{\n format: string\n url: string\n }>\n links: Array<{\n id: number\n name: string\n url: string\n direct_asset_url: string\n link_type: string\n }>\n}\n\nexport function getS3LikeProviderBaseUrl(configuration: PublishConfiguration) {\n const provider = configuration.provider\n if (provider === \"s3\") {\n return s3Url(configuration as S3Options)\n }\n if (provider === \"spaces\") {\n return spacesUrl(configuration as SpacesOptions)\n }\n throw new Error(`Not supported provider: ${provider}`)\n}\n\nfunction s3Url(options: S3Options) {\n let url: string\n if (options.accelerate == true) {\n url = `https://${options.bucket}.s3-accelerate.amazonaws.com`\n } else if (options.endpoint != null) {\n url = `${options.endpoint}/${options.bucket}`\n } else if (options.bucket.includes(\".\")) {\n if (options.region == null) {\n throw new Error(`Bucket name \"${options.bucket}\" includes a dot, but S3 region is missing`)\n }\n\n // special case, see http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingBucket.html#access-bucket-intro\n if (options.region === \"us-east-1\") {\n url = `https://s3.amazonaws.com/${options.bucket}`\n } else {\n url = `https://s3-${options.region}.amazonaws.com/${options.bucket}`\n }\n } else if (options.region === \"cn-north-1\") {\n url = `https://${options.bucket}.s3.${options.region}.amazonaws.com.cn`\n } else {\n url = `https://${options.bucket}.s3.amazonaws.com`\n }\n return appendPath(url, options.path)\n}\n\nfunction appendPath(url: string, p: string | Nullish): string {\n if (p != null && p.length > 0) {\n if (!p.startsWith(\"/\")) {\n url += \"/\"\n }\n url += p\n }\n return url\n}\n\nfunction spacesUrl(options: SpacesOptions) {\n if (options.name == null) {\n throw new Error(`name is missing`)\n }\n if (options.region == null) {\n throw new Error(`region is missing`)\n }\n return appendPath(`https://${options.name}.${options.region}.digitaloceanspaces.com`, options.path)\n}\n"]}
import { CancellationToken } from "./CancellationToken";
export declare function retry<T>(task: () => Promise<T>, options: {
retries: number;
interval: number;
backoff?: number;
attempt?: number;
cancellationToken?: CancellationToken;
shouldRetry?: (e: any) => boolean | Promise<boolean>;
}): Promise<T>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.retry = retry;
const CancellationToken_1 = require("./CancellationToken");
async function retry(task, options) {
var _a;
const { retries: retryCount, interval, backoff = 0, attempt = 0, shouldRetry, cancellationToken = new CancellationToken_1.CancellationToken() } = options;
try {
return await task();
}
catch (error) {
if ((await Promise.resolve((_a = shouldRetry === null || shouldRetry === void 0 ? void 0 : shouldRetry(error)) !== null && _a !== void 0 ? _a : true)) && retryCount > 0 && !cancellationToken.cancelled) {
await new Promise(resolve => setTimeout(resolve, interval + backoff * attempt));
return await retry(task, { ...options, retries: retryCount - 1, attempt: attempt + 1 });
}
else {
throw error;
}
}
}
//# sourceMappingURL=retry.js.map
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":";;AAEA,sBAeC;AAjBD,2DAAuD;AAEhD,KAAK,UAAU,KAAK,CACzB,IAAsB,EACtB,OAA+K;;IAE/K,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,GAAG,CAAC,EAAE,OAAO,GAAG,CAAC,EAAE,WAAW,EAAE,iBAAiB,GAAG,IAAI,qCAAiB,EAAE,EAAE,GAAG,OAAO,CAAA;IACrI,IAAI,CAAC;QACH,OAAO,MAAM,IAAI,EAAE,CAAA;IACrB,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,IAAI,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,MAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAG,KAAK,CAAC,mCAAI,IAAI,CAAC,CAAC,IAAI,UAAU,GAAG,CAAC,IAAI,CAAC,iBAAiB,CAAC,SAAS,EAAE,CAAC;YAC5G,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,GAAG,OAAO,CAAC,CAAC,CAAA;YAC/E,OAAO,MAAM,KAAK,CAAC,IAAI,EAAE,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,UAAU,GAAG,CAAC,EAAE,OAAO,EAAE,OAAO,GAAG,CAAC,EAAE,CAAC,CAAA;QACzF,CAAC;aAAM,CAAC;YACN,MAAM,KAAK,CAAA;QACb,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import { CancellationToken } from \"./CancellationToken\"\n\nexport async function retry<T>(\n task: () => Promise<T>,\n options: { retries: number; interval: number; backoff?: number; attempt?: number; cancellationToken?: CancellationToken; shouldRetry?: (e: any) => boolean | Promise<boolean> }\n): Promise<T> {\n const { retries: retryCount, interval, backoff = 0, attempt = 0, shouldRetry, cancellationToken = new CancellationToken() } = options\n try {\n return await task()\n } catch (error: any) {\n if ((await Promise.resolve(shouldRetry?.(error) ?? true)) && retryCount > 0 && !cancellationToken.cancelled) {\n await new Promise(resolve => setTimeout(resolve, interval + backoff * attempt))\n return await retry(task, { ...options, retries: retryCount - 1, attempt: attempt + 1 })\n } else {\n throw error\n }\n }\n}\n"]}
export declare function parseDn(seq: string): Map<string, string>;
"use strict";
Object.defineProperty(exports, "__esModule", { 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;
}
}
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;
}
}
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
{"version":3,"file":"rfc2253Parser.js","sourceRoot":"","sources":["../src/rfc2253Parser.ts"],"names":[],"mappings":";;AAAA,0BAqFC;AArFD,SAAgB,OAAO,CAAC,GAAW;IACjC,IAAI,MAAM,GAAG,KAAK,CAAA;IAClB,IAAI,GAAG,GAAkB,IAAI,CAAA;IAC7B,IAAI,KAAK,GAAG,EAAE,CAAA;IACd,IAAI,YAAY,GAAG,CAAC,CAAA;IAEpB,GAAG,GAAG,GAAG,CAAC,IAAI,EAAE,CAAA;IAChB,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAA;IACxC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,IAAI,CAAC,KAAK,GAAG,CAAC,MAAM,EAAE,CAAC;YACrB,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;gBACjB,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;YACxB,CAAC;YACD,MAAK;QACP,CAAC;QAED,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAA;QACjB,IAAI,MAAM,EAAE,CAAC;YACX,IAAI,EAAE,KAAK,GAAG,EAAE,CAAC;gBACf,MAAM,GAAG,KAAK,CAAA;gBACd,SAAQ;YACV,CAAC;QACH,CAAC;aAAM,CAAC;YACN,IAAI,EAAE,KAAK,GAAG,EAAE,CAAC;gBACf,MA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,CAAC,EAAE,CAAA;gBACL,CAAC;gBACD,YAAY,GAAG,CAAC,CAAA;YAClB,CAAC;YAED,IACE,YAAY,IAAI,GAAG,CAAC,MAAM;gBAC1B,GAAG,CAAC,YAAY,CAAC,KAAK,GAAG;gBACzB,GAAG,CAAC,YAAY,CAAC,KAAK,GAAG;gBACzB,CAAC,GAAG,KAAK,IAAI,IAAI,GAAG,CAAC,YAAY,CAAC,KAAK,GAAG,CAAC;gBAC3C,CAAC,GAAG,KAAK,IAAI,IAAI,GAAG,CAAC,YAAY,CAAC,KAAK,GAAG,CAAC,EAC3C,CAAC;gBACD,CAAC,GAAG,YAAY,GAAG,CAAC,CAAA;gBACpB,SAAQ;YACV,CAAC;QACH,CAAC;QAED,KAAK,IAAI,EAAE,CAAA;IACb,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["export function parseDn(seq: string): Map<string, string> {\n let quoted = false\n let key: string | null = null\n let token = \"\"\n let nextNonSpace = 0\n\n seq = seq.trim()\n const result = new Map<string, string>()\n for (let i = 0; i <= seq.length; i++) {\n if (i === seq.length) {\n if (key !== null) {\n result.set(key, token)\n }\n break\n }\n\n const ch = seq[i]\n if (quoted) {\n if (ch === '\"') {\n quoted = false\n continue\n }\n } else {\n if (ch === '\"') {\n quoted = true\n continue\n }\n\n if (ch === \"\\\\\") {\n i++\n const ord = parseInt(seq.slice(i, i + 2), 16)\n if (Number.isNaN(ord)) {\n token += seq[i]\n } else {\n i++\n token += String.fromCharCode(ord)\n }\n continue\n }\n\n if (key === null && ch === \"=\") {\n key = token\n token = \"\"\n continue\n }\n\n if (ch === \",\" || ch === \";\" || ch === \"+\") {\n if (key !== null) {\n result.set(key, token)\n }\n key = null\n token = \"\"\n continue\n }\n }\n\n if (ch === \" \" && !quoted) {\n if (token.length === 0) {\n continue\n }\n\n if (i > nextNonSpace) {\n let j = i\n while (seq[j] === \" \") {\n j++\n }\n nextNonSpace = j\n }\n\n if (\n nextNonSpace >= seq.length ||\n seq[nextNonSpace] === \",\" ||\n seq[nextNonSpace] === \";\" ||\n (key === null && seq[nextNonSpace] === \"=\") ||\n (key !== null && seq[nextNonSpace] === \"+\")\n ) {\n i = nextNonSpace - 1\n continue\n }\n }\n\n token += ch\n }\n\n return result\n}\n"]}
export interface ReleaseNoteInfo {
/**
* The version.
*/
readonly version: string;
/**
* The note.
*/
readonly note: string | null;
}
export interface BlockMapDataHolder {
/**
* The file size. Used to verify downloaded size (save one HTTP request to get length).
* Also used when block map data is embedded into the file (appimage, windows web installer package).
*/
size?: number;
/**
* The block map file size. Used when block map data is embedded into the file (appimage, windows web installer package).
* This information can be obtained from the file itself, but it requires additional HTTP request,
* so, to reduce request count, block map size is specified in the update metadata too.
*/
blockMapSize?: number;
/**
* The file checksum.
*/
readonly sha512: string;
readonly isAdminRightsRequired?: boolean;
}
export interface PackageFileInfo extends BlockMapDataHolder {
readonly path: string;
}
export interface UpdateFileInfo extends BlockMapDataHolder {
url: string;
}
export interface UpdateInfo {
/**
* The version.
*/
readonly version: string;
readonly files: Array<UpdateFileInfo>;
/** @deprecated */
readonly path: string;
/** @deprecated */
readonly sha512: string;
/**
* The release name.
*/
releaseName?: string | null;
/**
* The release notes. List if `updater.fullChangelog` is set to `true`, `string` otherwise.
*/
releaseNotes?: string | Array<ReleaseNoteInfo> | null;
/**
* The release date.
*/
releaseDate: string;
/**
* The [staged rollout](https://www.electron.build/auto-update#staged-rollouts) percentage, 0-100.
*/
readonly stagingPercentage?: number;
/**
* The minimum version of system required for the app to run. Sample value: macOS `23.1.0`, Windows `10.0.22631`.
* Same with os.release() value, this is a kernel version.
*/
readonly minimumSystemVersion?: string;
}
export interface WindowsUpdateInfo extends UpdateInfo {
packages?: {
[arch: string]: PackageFileInfo;
} | null;
/**
* @deprecated
* @private
*/
sha2?: string;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=updateInfo.js.map
{"version":3,"file":"updateInfo.js","sourceRoot":"","sources":["../src/updateInfo.ts"],"names":[],"mappings":"","sourcesContent":["export interface ReleaseNoteInfo {\n /**\n * The version.\n */\n readonly version: string\n\n /**\n * The note.\n */\n readonly note: string | null\n}\n\nexport interface BlockMapDataHolder {\n /**\n * The file size. Used to verify downloaded size (save one HTTP request to get length).\n * Also used when block map data is embedded into the file (appimage, windows web installer package).\n */\n size?: number\n\n /**\n * The block map file size. Used when block map data is embedded into the file (appimage, windows web installer package).\n * This information can be obtained from the file itself, but it requires additional HTTP request,\n * so, to reduce request count, block map size is specified in the update metadata too.\n */\n blockMapSize?: number\n\n /**\n * The file checksum.\n */\n readonly sha512: string\n\n readonly isAdminRightsRequired?: boolean\n}\n\nexport interface PackageFileInfo extends BlockMapDataHolder {\n readonly path: string\n}\n\nexport interface UpdateFileInfo extends BlockMapDataHolder {\n url: string\n}\n\nexport interface UpdateInfo {\n /**\n * The version.\n */\n readonly version: string\n\n readonly files: Array<UpdateFileInfo>\n\n /** @deprecated */\n readonly path: string\n\n /** @deprecated */\n readonly sha512: string\n\n /**\n * The release name.\n */\n releaseName?: string | null\n\n /**\n * The release notes. List if `updater.fullChangelog` is set to `true`, `string` otherwise.\n */\n releaseNotes?: string | Array<ReleaseNoteInfo> | null\n\n /**\n * The release date.\n */\n releaseDate: string\n\n /**\n * The [staged rollout](https://www.electron.build/auto-update#staged-rollouts) percentage, 0-100.\n */\n readonly stagingPercentage?: number\n\n /**\n * The minimum version of system required for the app to run. Sample value: macOS `23.1.0`, Windows `10.0.22631`.\n * Same with os.release() value, this is a kernel version.\n */\n readonly minimumSystemVersion?: string\n}\n\nexport interface WindowsUpdateInfo extends UpdateInfo {\n packages?: { [arch: string]: PackageFileInfo } | null\n\n /**\n * @deprecated\n * @private\n */\n sha2?: string\n}\n"]}
export declare class UUID {
private ascii;
private readonly binary;
private readonly version;
static readonly OID: Buffer;
constructor(uuid: Buffer | string);
static v5(name: string | Buffer, namespace: Buffer): any;
toString(): string;
inspect(): string;
static check(uuid: Buffer | string, offset?: number): false | {
version: undefined;
variant: string;
format: string;
} | {
version: number;
variant: string;
format: string;
};
static parse(input: string): Buffer;
}
export declare const nil: UUID;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.nil = exports.UUID = void 0;
const crypto_1 = require("crypto");
const error_1 = require("./error");
const invalidName = "options.name must be either a string or a Buffer";
// Node ID according to rfc4122#section-4.5
const randomHost = (0, crypto_1.randomBytes)(16);
randomHost[0] = randomHost[0] | 0x01;
// 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
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;
}
}
static v5(name, namespace) {
return uuidNamed(name, "sha1", 0x50, namespace);
}
toString() {
if (this.ascii == null) {
this.ascii = stringify(this.binary);
}
return this.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 (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, error_1.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;
}
}
return buffer;
}
}
exports.UUID = UUID;
// from rfc4122#appendix-C
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";
}
}
var UuidEncoding;
(function (UuidEncoding) {
UuidEncoding[UuidEncoding["ASCII"] = 0] = "ASCII";
UuidEncoding[UuidEncoding["BINARY"] = 1] = "BINARY";
UuidEncoding[UuidEncoding["OBJECT"] = 2] = "OBJECT";
})(UuidEncoding || (UuidEncoding = {}));
// v3 + v5
function uuidNamed(name, hashMethod, version, namespace, encoding = UuidEncoding.ASCII) {
const hash = (0, crypto_1.createHash)(hashMethod);
const nameIsNotAString = typeof name !== "string";
if (nameIsNotAString && !Buffer.isBuffer(name)) {
throw (0, error_1.newError)(invalidName, "ERR_INVALID_UUID_NAME");
}
hash.update(namespace);
hash.update(name);
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
exports.nil = new UUID("00000000-0000-0000-0000-000000000000");
// UUID.v4 = uuidRandom
// UUID.v4fast = uuidRandomFast
// UUID.v3 = function(options, callback) {
// return uuidNamed("md5", 0x30, options, callback)
// }
//# sourceMappingURL=uuid.js.map
{"version":3,"file":"uuid.js","sourceRoot":"","sources":["../src/uuid.ts"],"names":[],"mappings":";;;AAAA,mCAAgD;AAChD,mCAAkC;AAElC,MAAM,WAAW,GAAG,kDAAkD,CAAA;AAEtE,2CAA2C;AAC3C,MAAM,UAAU,GAAG,IAAA,oBAAW,EAAC,EAAE,CAAC,CAAA;AAClC,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,IAAI,CAAA;AAEpC,2BAA2B;AAC3B,MAAM,QAAQ,GAAQ,EAAE,CAAA;AAExB,2BAA2B;AAC3B,MAAM,QAAQ,GAAkB,EAAE,CAAA;AAClC,yBAAyB;AACzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;IAC7B,MAAM,GAAG,GAAG,CAAC,CA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AAC,CAAC;QACnB,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACnB,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACnB,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACnB,GAAG;QACH,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACnB,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACnB,GAAG;QACH,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACnB,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACnB,GAAG;QACH,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACnB,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACnB,GAAG;QACH,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACpB,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACpB,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACpB,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACpB,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACpB,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CACrB,CAAA;AACH,CAAC;AAED,qCAAqC;AACxB,QAAA,GAAG,GAAG,IAAI,IAAI,CAAC,sCAAsC,CAAC,CAAA;AAEnE,uBAAuB;AAEvB,+BAA+B;AAE/B,0CAA0C;AAC1C,uDAAuD;AACvD,IAAI","sourcesContent":["import { createHash, randomBytes } from \"crypto\"\nimport { newError } from \"./error\"\n\nconst invalidName = \"options.name must be either a string or a Buffer\"\n\n// Node ID according to rfc4122#section-4.5\nconst randomHost = randomBytes(16)\nrandomHost[0] = randomHost[0] | 0x01\n\n// lookup table hex to byte\nconst hex2byte: any = {}\n\n// lookup table byte to hex\nconst byte2hex: Array<string> = []\n// populate lookup tables\nfor (let i = 0; i < 256; i++) {\n const hex = (i + 0x100).toString(16).substr(1)\n hex2byte[hex] = i\n byte2hex[i] = hex\n}\n\n// UUID class\nexport class UUID {\n private ascii: string | null = null\n private readonly binary: Buffer | null = null\n private readonly version: number\n\n // from rfc4122#appendix-C\n static readonly OID: Buffer = UUID.parse(\"6ba7b812-9dad-11d1-80b4-00c04fd430c8\")\n\n constructor(uuid: Buffer | string) {\n const check = UUID.check(uuid)\n if (!check) {\n throw new Error(\"not a UUID\")\n }\n\n this.version = check.version!\n\n if (check.format === \"ascii\") {\n this.ascii = uuid as string\n } else {\n this.binary = uuid as Buffer\n }\n }\n\n static v5(name: string | Buffer, namespace: Buffer) {\n return uuidNamed(name, \"sha1\", 0x50, namespace)\n }\n\n toString() {\n if (this.ascii == null) {\n this.ascii = stringify(this.binary!)\n }\n return this.ascii\n }\n\n inspect() {\n return `UUID v${this.version} ${this.toString()}`\n }\n\n static check(uuid: Buffer | string, offset = 0) {\n if (typeof uuid === \"string\") {\n uuid = uuid.toLowerCase()\n\n if (!/^[a-f0-9]{8}(-[a-f0-9]{4}){3}-([a-f0-9]{12})$/.test(uuid)) {\n return false\n }\n\n if (uuid === \"00000000-0000-0000-0000-000000000000\") {\n return { version: undefined, variant: \"nil\", format: \"ascii\" }\n }\n\n return {\n version: (hex2byte[uuid[14] + uuid[15]] & 0xf0) >> 4,\n variant: getVariant((hex2byte[uuid[19] + uuid[20]] & 0xe0) >> 5),\n format: \"ascii\",\n }\n }\n\n if (Buffer.isBuffer(uuid)) {\n if (uuid.length < offset + 16) {\n return false\n }\n\n let i = 0\n for (; i < 16; i++) {\n if (uuid[offset + i] !== 0) {\n break\n }\n }\n if (i === 16) {\n return { version: undefined, variant: \"nil\", format: \"binary\" }\n }\n\n return {\n version: (uuid[offset + 6] & 0xf0) >> 4,\n variant: getVariant((uuid[offset + 8] & 0xe0) >> 5),\n format: \"binary\",\n }\n }\n\n throw newError(\"Unknown type of uuid\", \"ERR_UNKNOWN_UUID_TYPE\")\n }\n\n // read stringified uuid into a Buffer\n static parse(input: string): Buffer {\n const buffer = Buffer.allocUnsafe(16)\n let j = 0\n for (let i = 0; i < 16; i++) {\n buffer[i] = hex2byte[input[j++] + input[j++]]\n if (i === 3 || i === 5 || i === 7 || i === 9) {\n j += 1\n }\n }\n return buffer\n }\n}\n\n// according to rfc4122#section-4.1.1\nfunction getVariant(bits: number) {\n switch (bits) {\n case 0:\n case 1:\n case 3:\n return \"ncs\"\n case 4:\n case 5:\n return \"rfc4122\"\n case 6:\n return \"microsoft\"\n default:\n return \"future\"\n }\n}\n\nenum UuidEncoding {\n ASCII,\n BINARY,\n OBJECT,\n}\n\n// v3 + v5\nfunction uuidNamed(name: string | Buffer, hashMethod: string, version: number, namespace: Buffer, encoding: UuidEncoding = UuidEncoding.ASCII) {\n const hash = createHash(hashMethod)\n\n const nameIsNotAString = typeof name !== \"string\"\n if (nameIsNotAString && !Buffer.isBuffer(name)) {\n throw newError(invalidName, \"ERR_INVALID_UUID_NAME\")\n }\n\n hash.update(namespace)\n hash.update(name)\n\n const buffer = hash.digest()\n let result: any\n switch (encoding) {\n case UuidEncoding.BINARY:\n buffer[6] = (buffer[6] & 0x0f) | version\n buffer[8] = (buffer[8] & 0x3f) | 0x80\n result = buffer\n break\n case UuidEncoding.OBJECT:\n buffer[6] = (buffer[6] & 0x0f) | version\n buffer[8] = (buffer[8] & 0x3f) | 0x80\n result = new UUID(buffer)\n break\n default:\n result =\n byte2hex[buffer[0]] +\n byte2hex[buffer[1]] +\n byte2hex[buffer[2]] +\n byte2hex[buffer[3]] +\n \"-\" +\n byte2hex[buffer[4]] +\n byte2hex[buffer[5]] +\n \"-\" +\n byte2hex[(buffer[6] & 0x0f) | version] +\n byte2hex[buffer[7]] +\n \"-\" +\n byte2hex[(buffer[8] & 0x3f) | 0x80] +\n byte2hex[buffer[9]] +\n \"-\" +\n byte2hex[buffer[10]] +\n byte2hex[buffer[11]] +\n byte2hex[buffer[12]] +\n byte2hex[buffer[13]] +\n byte2hex[buffer[14]] +\n byte2hex[buffer[15]]\n break\n }\n return result\n}\n\nfunction stringify(buffer: Buffer) {\n return (\n byte2hex[buffer[0]] +\n byte2hex[buffer[1]] +\n byte2hex[buffer[2]] +\n byte2hex[buffer[3]] +\n \"-\" +\n byte2hex[buffer[4]] +\n byte2hex[buffer[5]] +\n \"-\" +\n byte2hex[buffer[6]] +\n byte2hex[buffer[7]] +\n \"-\" +\n byte2hex[buffer[8]] +\n byte2hex[buffer[9]] +\n \"-\" +\n byte2hex[buffer[10]] +\n byte2hex[buffer[11]] +\n byte2hex[buffer[12]] +\n byte2hex[buffer[13]] +\n byte2hex[buffer[14]] +\n byte2hex[buffer[15]]\n )\n}\n\n// according to rfc4122#section-4.1.7\nexport const nil = new UUID(\"00000000-0000-0000-0000-000000000000\")\n\n// UUID.v4 = uuidRandom\n\n// UUID.v4fast = uuidRandomFast\n\n// UUID.v3 = function(options, callback) {\n// return uuidNamed(\"md5\", 0x30, options, callback)\n// }\n"]}
export declare class XElement {
readonly name: string;
value: string;
attributes: Record<string, string> | null;
isCData: boolean;
elements: Array<XElement> | null;
constructor(name: string);
attribute(name: string): string;
removeAttribute(name: string): void;
element(name: string, ignoreCase?: boolean, errorIfMissed?: string | null): XElement;
elementOrNull(name: string, ignoreCase?: boolean): XElement | null;
getElements(name: string, ignoreCase?: boolean): XElement[];
elementValueOrEmpty(name: string, ignoreCase?: boolean): string;
}
export declare function parseXml(data: string): XElement;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.XElement = void 0;
exports.parseXml = parseXml;
const sax = require("sax");
const error_1 = require("./error");
class XElement {
constructor(name) {
this.name = name;
this.value = "";
this.attributes = null;
this.isCData = false;
this.elements = null;
if (!name) {
throw (0, error_1.newError)("Element name cannot be empty", "ERR_XML_ELEMENT_NAME_EMPTY");
}
if (!isValidName(name)) {
throw (0, error_1.newError)(`Invalid element name: ${name}`, "ERR_XML_ELEMENT_INVALID_NAME");
}
}
attribute(name) {
const result = this.attributes === null ? null : this.attributes[name];
if (result == null) {
throw (0, error_1.newError)(`No attribute "${name}"`, "ERR_XML_MISSED_ATTRIBUTE");
}
return result;
}
removeAttribute(name) {
if (this.attributes !== null) {
delete this.attributes[name];
}
}
element(name, ignoreCase = false, errorIfMissed = null) {
const result = this.elementOrNull(name, ignoreCase);
if (result === null) {
throw (0, error_1.newError)(errorIfMissed || `No element "${name}"`, "ERR_XML_MISSED_ELEMENT");
}
return result;
}
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;
}
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);
}
function isNameEquals(element, name, ignoreCase) {
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.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
{"version":3,"file":"xml.js","sourceRoot":"","sources":["../src/xml.ts"],"names":[],"mappings":";;;AA8EA,4BA2CC;AAzHD,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AC,CAAC,CAAC,KAAK,GAAG,IAAI,CAAA;QAC5C,CAAC;IACH,CAAC,CAAA;IAED,MAAM,CAAC,OAAO,GAAG,KAAK,CAAC,EAAE;QACvB,MAAM,OAAO,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;QAC7C,OAAO,CAAC,KAAK,GAAG,KAAK,CAAA;QACrB,OAAO,CAAC,OAAO,GAAG,IAAI,CAAA;IACxB,CAAC,CAAA;IAED,MAAM,CAAC,OAAO,GAAG,GAAG,CAAC,EAAE;QACrB,MAAM,GAAG,CAAA;IACX,CAAC,CAAA;IAED,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAClB,OAAO,WAAY,CAAA;AACrB,CAAC","sourcesContent":["import * as sax from \"sax\"\nimport { newError } from \"./error\"\n\nexport class XElement {\n value = \"\"\n attributes: Record<string, string> | null = null\n isCData = false\n elements: Array<XElement> | null = null\n\n constructor(readonly name: string) {\n if (!name) {\n throw newError(\"Element name cannot be empty\", \"ERR_XML_ELEMENT_NAME_EMPTY\")\n }\n if (!isValidName(name)) {\n throw newError(`Invalid element name: ${name}`, \"ERR_XML_ELEMENT_INVALID_NAME\")\n }\n }\n\n attribute(name: string): string {\n const result = this.attributes === null ? null : this.attributes[name]\n if (result == null) {\n throw newError(`No attribute \"${name}\"`, \"ERR_XML_MISSED_ATTRIBUTE\")\n }\n return result\n }\n\n removeAttribute(name: string): void {\n if (this.attributes !== null) {\n delete this.attributes[name]\n }\n }\n\n element(name: string, ignoreCase = false, errorIfMissed: string | null = null): XElement {\n const result = this.elementOrNull(name, ignoreCase)\n if (result === null) {\n throw newError(errorIfMissed || `No element \"${name}\"`, \"ERR_XML_MISSED_ELEMENT\")\n }\n return result\n }\n\n elementOrNull(name: string, ignoreCase = false): XElement | null {\n if (this.elements === null) {\n return null\n }\n\n for (const element of this.elements) {\n if (isNameEquals(element, name, ignoreCase)) {\n return element\n }\n }\n\n return null\n }\n\n getElements(name: string, ignoreCase = false) {\n if (this.elements === null) {\n return []\n }\n return this.elements.filter(it => isNameEquals(it, name, ignoreCase))\n }\n\n elementValueOrEmpty(name: string, ignoreCase = false): string {\n const element = this.elementOrNull(name, ignoreCase)\n return element === null ? \"\" : element.value\n }\n}\n\nconst NAME_REG_EXP = new RegExp(/^[A-Za-z_][:A-Za-z0-9_-]*$/i)\n\nfunction isValidName(name: string) {\n return NAME_REG_EXP.test(name)\n}\n\nfunction isNameEquals(element: XElement, name: string, ignoreCase: boolean) {\n const elementName = element.name\n return elementName === name || (ignoreCase === true && elementName.length === name.length && elementName.toLowerCase() === name.toLowerCase())\n}\n\nexport function parseXml(data: string): XElement {\n let rootElement: XElement | null = null\n const parser = sax.parser(true, {})\n const elements: Array<XElement> = []\n\n parser.onopentag = saxElement => {\n const element = new XElement(saxElement.name)\n element.attributes = saxElement.attributes as Record<string, string>\n\n if (rootElement === null) {\n rootElement = element\n } else {\n const parent = elements[elements.length - 1]\n if (parent.elements == null) {\n parent.elements = []\n }\n parent.elements.push(element)\n }\n elements.push(element)\n }\n\n parser.onclosetag = () => {\n elements.pop()\n }\n\n parser.ontext = text => {\n if (elements.length > 0) {\n elements[elements.length - 1].value = text\n }\n }\n\n parser.oncdata = cdata => {\n const element = elements[elements.length - 1]\n element.value = cdata\n element.isCData = true\n }\n\n parser.onerror = err => {\n throw err\n }\n\n parser.write(data)\n return rootElement!\n}\n"]}