diff --git a/github-actions/create-pr-for-changes/action.yml b/github-actions/create-pr-for-changes/action.yml index e3dffb85e..57713157b 100644 --- a/github-actions/create-pr-for-changes/action.yml +++ b/github-actions/create-pr-for-changes/action.yml @@ -65,9 +65,9 @@ inputs: To skip the automatic clean up of obsolete branches, set this option to `false`. Example: `clean-up-branches: false` - angular-robot-key: + angular-robot-token: required: true - description: The private key for the Angular Robot Github app. Used to authenticate with GitHub. + description: A GitHub access token for Angular Robot. Used to authenticate with GitHub. outputs: result: diff --git a/github-actions/create-pr-for-changes/lib/BUILD.bazel b/github-actions/create-pr-for-changes/lib/BUILD.bazel index 233b73549..de308e09f 100644 --- a/github-actions/create-pr-for-changes/lib/BUILD.bazel +++ b/github-actions/create-pr-for-changes/lib/BUILD.bazel @@ -13,7 +13,6 @@ ts_library( exclude = ["*.spec.ts"], ), deps = [ - "//github-actions:utils", "//ng-dev/utils", "@npm//@actions/core", "@npm//@actions/github", diff --git a/github-actions/create-pr-for-changes/lib/main.ts b/github-actions/create-pr-for-changes/lib/main.ts index ef1008e81..1d5f56cbc 100644 --- a/github-actions/create-pr-for-changes/lib/main.ts +++ b/github-actions/create-pr-for-changes/lib/main.ts @@ -6,7 +6,6 @@ import {GithubConfig, setConfig} from '../../../ng-dev/utils/config.js'; import {AuthenticatedGitClient} from '../../../ng-dev/utils/git/authenticated-git-client.js'; import {GithubRepo} from '../../../ng-dev/utils/git/github.js'; import {getRepositoryGitUrl} from '../../../ng-dev/utils/git/github-urls.js'; -import {ANGULAR_ROBOT, getAuthTokenFor, revokeActiveInstallationToken} from '../../utils.js'; const enum ActionResult { created = 'created', @@ -18,8 +17,6 @@ main(); // Helpers async function main(): Promise { - let authToken: string | null = null; - try { // Initialize outputs. core.setOutput('result', ActionResult.nothing); @@ -35,10 +32,10 @@ async function main(): Promise { }; setConfig(config); - // Configure the `AuthenticatedGitClient` to be authenticated with the token for the Angular - // Robot. - authToken = await getAuthTokenFor(ANGULAR_ROBOT); - AuthenticatedGitClient.configure(authToken); + // Configure the `AuthenticatedGitClient` to be authenticated with the provided GitHub access + // token for Angular Robot. + const accessToken = core.getInput('angular-robot-token', {required: true}); + AuthenticatedGitClient.configure(accessToken); /** The authenticated GitClient. */ const git = await AuthenticatedGitClient.get(); git.run(['config', 'user.email', 'angular-robot@google.com']); @@ -206,10 +203,6 @@ async function main(): Promise { core.setOutput('result', ActionResult.failed); core.error(err); core.setFailed(err.message); - } finally { - if (authToken !== null) { - await revokeActiveInstallationToken(authToken); - } } } diff --git a/github-actions/create-pr-for-changes/main.js b/github-actions/create-pr-for-changes/main.js index cc6393c08..53a9403ce 100644 --- a/github-actions/create-pr-for-changes/main.js +++ b/github-actions/create-pr-for-changes/main.js @@ -1262,12 +1262,12 @@ var require_lib = __commonJS({ throw new Error("Client has already been disposed."); } const parsedUrl = new URL(requestUrl); - let info3 = this._prepareRequest(verb, parsedUrl, headers); + let info2 = this._prepareRequest(verb, parsedUrl, headers); const maxTries = this._allowRetries && RetryableHttpVerbs.includes(verb) ? this._maxRetries + 1 : 1; let numTries = 0; let response; do { - response = yield this.requestRaw(info3, data); + response = yield this.requestRaw(info2, data); if (response && response.message && response.message.statusCode === HttpCodes.Unauthorized) { let authenticationHandler; for (const handler of this.handlers) { @@ -1277,7 +1277,7 @@ var require_lib = __commonJS({ } } if (authenticationHandler) { - return authenticationHandler.handleAuthentication(this, info3, data); + return authenticationHandler.handleAuthentication(this, info2, data); } else { return response; } @@ -1300,8 +1300,8 @@ var require_lib = __commonJS({ } } } - info3 = this._prepareRequest(verb, parsedRedirectUrl, headers); - response = yield this.requestRaw(info3, data); + info2 = this._prepareRequest(verb, parsedRedirectUrl, headers); + response = yield this.requestRaw(info2, data); redirectsRemaining--; } if (!response.message.statusCode || !HttpResponseRetryCodes.includes(response.message.statusCode)) { @@ -1322,7 +1322,7 @@ var require_lib = __commonJS({ } this._disposed = true; } - requestRaw(info3, data) { + requestRaw(info2, data) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => { function callbackForResult(err, res) { @@ -1334,16 +1334,16 @@ var require_lib = __commonJS({ resolve(res); } } - this.requestRawWithCallback(info3, data, callbackForResult); + this.requestRawWithCallback(info2, data, callbackForResult); }); }); } - requestRawWithCallback(info3, data, onResult) { + requestRawWithCallback(info2, data, onResult) { if (typeof data === "string") { - if (!info3.options.headers) { - info3.options.headers = {}; + if (!info2.options.headers) { + info2.options.headers = {}; } - info3.options.headers["Content-Length"] = Buffer.byteLength(data, "utf8"); + info2.options.headers["Content-Length"] = Buffer.byteLength(data, "utf8"); } let callbackCalled = false; function handleResult(err, res) { @@ -1352,7 +1352,7 @@ var require_lib = __commonJS({ onResult(err, res); } } - const req = info3.httpModule.request(info3.options, (msg) => { + const req = info2.httpModule.request(info2.options, (msg) => { const res = new HttpClientResponse(msg); handleResult(void 0, res); }); @@ -1364,7 +1364,7 @@ var require_lib = __commonJS({ if (socket) { socket.end(); } - handleResult(new Error(`Request timeout: ${info3.options.path}`)); + handleResult(new Error(`Request timeout: ${info2.options.path}`)); }); req.on("error", function(err) { handleResult(err); @@ -1386,27 +1386,27 @@ var require_lib = __commonJS({ return this._getAgent(parsedUrl); } _prepareRequest(method, requestUrl, headers) { - const info3 = {}; - info3.parsedUrl = requestUrl; - const usingSsl = info3.parsedUrl.protocol === "https:"; - info3.httpModule = usingSsl ? https : http; + const info2 = {}; + info2.parsedUrl = requestUrl; + const usingSsl = info2.parsedUrl.protocol === "https:"; + info2.httpModule = usingSsl ? https : http; const defaultPort = usingSsl ? 443 : 80; - info3.options = {}; - info3.options.host = info3.parsedUrl.hostname; - info3.options.port = info3.parsedUrl.port ? parseInt(info3.parsedUrl.port) : defaultPort; - info3.options.path = (info3.parsedUrl.pathname || "") + (info3.parsedUrl.search || ""); - info3.options.method = method; - info3.options.headers = this._mergeHeaders(headers); + info2.options = {}; + info2.options.host = info2.parsedUrl.hostname; + info2.options.port = info2.parsedUrl.port ? parseInt(info2.parsedUrl.port) : defaultPort; + info2.options.path = (info2.parsedUrl.pathname || "") + (info2.parsedUrl.search || ""); + info2.options.method = method; + info2.options.headers = this._mergeHeaders(headers); if (this.userAgent != null) { - info3.options.headers["user-agent"] = this.userAgent; + info2.options.headers["user-agent"] = this.userAgent; } - info3.options.agent = this._getAgent(info3.parsedUrl); + info2.options.agent = this._getAgent(info2.parsedUrl); if (this.handlers) { for (const handler of this.handlers) { - handler.prepareRequest(info3.options); + handler.prepareRequest(info2.options); } } - return info3; + return info2; } _mergeHeaders(headers) { if (this.requestOptions && this.requestOptions.headers) { @@ -2055,7 +2055,7 @@ var require_core = __commonJS({ process.env["PATH"] = `${inputPath}${path.delimiter}${process.env["PATH"]}`; } exports.addPath = addPath; - function getInput3(name, options) { + function getInput2(name, options) { const val = process.env[`INPUT_${name.replace(/ /g, "_").toUpperCase()}`] || ""; if (options && options.required && !val) { throw new Error(`Input required and not supplied: ${name}`); @@ -2065,16 +2065,16 @@ var require_core = __commonJS({ } return val.trim(); } - exports.getInput = getInput3; + exports.getInput = getInput2; function getMultilineInput(name, options) { - const inputs = getInput3(name, options).split("\n").filter((x) => x !== ""); + const inputs = getInput2(name, options).split("\n").filter((x) => x !== ""); return inputs; } exports.getMultilineInput = getMultilineInput; function getBooleanInput(name, options) { const trueValue = ["true", "True", "TRUE"]; const falseValue = ["false", "False", "FALSE"]; - const val = getInput3(name, options); + const val = getInput2(name, options); if (trueValue.includes(val)) return true; if (falseValue.includes(val)) @@ -2117,10 +2117,10 @@ Support boolean input list: \`true | True | TRUE | false | False | FALSE\``); command_1.issueCommand("notice", utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message); } exports.notice = notice; - function info3(message) { + function info2(message) { process.stdout.write(message + os3.EOL); } - exports.info = info3; + exports.info = info2; function startGroup(name) { command_1.issue("group", name); } @@ -2592,8 +2592,8 @@ var require_dist_node2 = __commonJS({ function isKeyOperator(operator) { return operator === ";" || operator === "&" || operator === "?"; } - function getValues(context3, operator, key, modifier) { - var value = context3[key], result = []; + function getValues(context2, operator, key, modifier) { + var value = context2[key], result = []; if (isDefined(value) && value !== "") { if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") { value = value.toString(); @@ -2653,7 +2653,7 @@ var require_dist_node2 = __commonJS({ expand: expand.bind(null, template) }; } - function expand(template, context3) { + function expand(template, context2) { var operators = ["+", "#", ".", "/", ";", "?", "&"]; return template.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g, function(_, expression, literal) { if (expression) { @@ -2665,7 +2665,7 @@ var require_dist_node2 = __commonJS({ } expression.split(/,/g).forEach(function(variable) { var tmp = /([^:\*]*)(?::(\d+)|(\*))?/.exec(variable); - values.push(getValues(context3, operator, tmp[1], tmp[2] || tmp[3])); + values.push(getValues(context2, operator, tmp[1], tmp[2] || tmp[3])); }); if (operator && operator !== "+") { var separator = ","; @@ -9738,7 +9738,7 @@ var require_dist_node8 = __commonJS({ } var VERSION = "3.6.0"; var _excluded = ["authStrategy"]; - var Octokit3 = class { + var Octokit2 = class { constructor(options = {}) { const hook = new beforeAfterHook.Collection(); const requestDefaults = { @@ -9824,9 +9824,9 @@ var require_dist_node8 = __commonJS({ return NewOctokit; } }; - Octokit3.VERSION = VERSION; - Octokit3.plugins = []; - exports.Octokit = Octokit3; + Octokit2.VERSION = VERSION; + Octokit2.plugins = []; + exports.Octokit = Octokit2; } }); @@ -11223,21 +11223,21 @@ var require_dist2 = __commonJS({ function renderScalar(name, params3) { return renderName(name) + renderParams(params3); } - function renderInlineFragment(fragment2, context3) { - return "...on ".concat(fragment2.typeName).concat(renderObject(void 0, fragment2.internal, context3)); + function renderInlineFragment(fragment2, context2) { + return "...on ".concat(fragment2.typeName).concat(renderObject(void 0, fragment2.internal, context2)); } - function renderFragment(fragment2, context3) { - return "fragment ".concat(fragment2.name, " on ").concat(fragment2.typeName).concat(renderObject(void 0, fragment2.internal, context3)); + function renderFragment(fragment2, context2) { + return "fragment ".concat(fragment2.name, " on ").concat(fragment2.typeName).concat(renderObject(void 0, fragment2.internal, context2)); } - function renderArray(name, arr, context3) { + function renderArray(name, arr, context2) { var first = arr[0]; if (first === void 0 || first === null) { throw new Error("Cannot render array with no first value"); } first[paramsSymbol] = arr[paramsSymbol]; - return renderType(name, first, context3); + return renderType(name, first, context2); } - function renderType(name, value, context3) { + function renderType(name, value, context2) { switch (typeof value) { case "bigint": case "boolean": @@ -11251,9 +11251,9 @@ var require_dist2 = __commonJS({ if (isScalarObject(value)) { return "".concat(renderScalar(name, value[paramsSymbol]), " "); } else if (Array.isArray(value)) { - return renderArray(name, value, context3); + return renderArray(name, value, context2); } else { - return renderObject(name, value, context3); + return renderObject(name, value, context2); } case "undefined": return ""; @@ -11261,19 +11261,19 @@ var require_dist2 = __commonJS({ throw new Error("Cannot render type ".concat(typeof value)); } } - function renderObject(name, obj, context3) { + function renderObject(name, obj, context2) { var fields = []; for (var _i = 0, _a = Object.entries(obj); _i < _a.length; _i++) { var _b = _a[_i], key = _b[0], value = _b[1]; - fields.push(renderType(key, value, context3)); + fields.push(renderType(key, value, context2)); } for (var _c = 0, _d = Object.getOwnPropertySymbols(obj); _c < _d.length; _c++) { var sym = _d[_c]; var value = obj[sym]; if (isInlineFragmentObject(value)) { - fields.push(renderInlineFragment(value, context3)); + fields.push(renderInlineFragment(value, context2)); } else if (isFragmentObject(value)) { - context3.fragments.set(sym, value); + context2.fragments.set(sym, value); fields.push("...".concat(value.name)); } } @@ -11283,12 +11283,12 @@ var require_dist2 = __commonJS({ return "".concat(renderName(name)).concat(renderParams(obj[paramsSymbol]), "{").concat(fields.join("").trim(), "}"); } function render(value) { - var context3 = { + var context2 = { fragments: /* @__PURE__ */ new Map() }; - var rend = renderObject(void 0, value, context3); + var rend = renderObject(void 0, value, context2); var rendered = /* @__PURE__ */ new Map(); - var executingContext = context3; + var executingContext = context2; var currentContext = { fragments: /* @__PURE__ */ new Map() }; @@ -11307,15 +11307,15 @@ var require_dist2 = __commonJS({ return rend + Array.from(rendered.values()).join(""); } function fragmentToString(value) { - var context3 = { + var context2 = { fragments: /* @__PURE__ */ new Map() }; - renderObject(void 0, value, context3); + renderObject(void 0, value, context2); var currentContext = { fragments: /* @__PURE__ */ new Map() }; var output = ""; - for (var _i = 0, _a = Array.from(context3.fragments.entries()); _i < _a.length; _i++) { + for (var _i = 0, _a = Array.from(context2.fragments.entries()); _i < _a.length; _i++) { var _b = _a[_i], fragment2 = _b[1]; output = output + renderFragment(fragment2, currentContext); } @@ -11573,8 +11573,8 @@ var require_dist_node11 = __commonJS({ function isKeyOperator(operator) { return operator === ";" || operator === "&" || operator === "?"; } - function getValues(context3, operator, key, modifier) { - var value = context3[key], result = []; + function getValues(context2, operator, key, modifier) { + var value = context2[key], result = []; if (isDefined(value) && value !== "") { if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") { value = value.toString(); @@ -11634,7 +11634,7 @@ var require_dist_node11 = __commonJS({ expand: expand.bind(null, template) }; } - function expand(template, context3) { + function expand(template, context2) { var operators = ["+", "#", ".", "/", ";", "?", "&"]; return template.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g, function(_, expression, literal) { if (expression) { @@ -11646,7 +11646,7 @@ var require_dist_node11 = __commonJS({ } expression.split(/,/g).forEach(function(variable) { var tmp = /([^:\*]*)(?::(\d+)|(\*))?/.exec(variable); - values.push(getValues(context3, operator, tmp[1], tmp[2] || tmp[3])); + values.push(getValues(context2, operator, tmp[1], tmp[2] || tmp[3])); }); if (operator && operator !== "+") { var separator = ","; @@ -14794,7 +14794,7 @@ var require_dist_node16 = __commonJS({ var graphql2 = require_dist_node14(); var authToken = require_dist_node15(); var VERSION = "4.0.5"; - var Octokit3 = class { + var Octokit2 = class { constructor(options = {}) { const hook = new beforeAfterHook.Collection(); const requestDefaults = { @@ -14881,9 +14881,9 @@ var require_dist_node16 = __commonJS({ return NewOctokit; } }; - Octokit3.VERSION = VERSION; - Octokit3.plugins = []; - exports.Octokit = Octokit3; + Octokit2.VERSION = VERSION; + Octokit2.plugins = []; + exports.Octokit = Octokit2; } }); @@ -16089,7523 +16089,16 @@ var require_dist_node20 = __commonJS({ var pluginPaginateRest = require_dist_node18(); var pluginRestEndpointMethods = require_dist_node19(); var VERSION = "19.0.4"; - var Octokit3 = core2.Octokit.plugin(pluginRequestLog.requestLog, pluginRestEndpointMethods.legacyRestEndpointMethods, pluginPaginateRest.paginateRest).defaults({ + var Octokit2 = core2.Octokit.plugin(pluginRequestLog.requestLog, pluginRestEndpointMethods.legacyRestEndpointMethods, pluginPaginateRest.paginateRest).defaults({ userAgent: `octokit-rest.js/${VERSION}` }); - exports.Octokit = Octokit3; - } -}); - -// -var require_lib7 = __commonJS({ - ""(exports, module) { - "use strict"; - var conversions = {}; - module.exports = conversions; - function sign(x) { - return x < 0 ? -1 : 1; - } - function evenRound(x) { - if (x % 1 === 0.5 && (x & 1) === 0) { - return Math.floor(x); - } else { - return Math.round(x); - } - } - function createNumberConversion(bitLength, typeOpts) { - if (!typeOpts.unsigned) { - --bitLength; - } - const lowerBound = typeOpts.unsigned ? 0 : -Math.pow(2, bitLength); - const upperBound = Math.pow(2, bitLength) - 1; - const moduloVal = typeOpts.moduloBitLength ? Math.pow(2, typeOpts.moduloBitLength) : Math.pow(2, bitLength); - const moduloBound = typeOpts.moduloBitLength ? Math.pow(2, typeOpts.moduloBitLength - 1) : Math.pow(2, bitLength - 1); - return function(V, opts) { - if (!opts) - opts = {}; - let x = +V; - if (opts.enforceRange) { - if (!Number.isFinite(x)) { - throw new TypeError("Argument is not a finite number"); - } - x = sign(x) * Math.floor(Math.abs(x)); - if (x < lowerBound || x > upperBound) { - throw new TypeError("Argument is not in byte range"); - } - return x; - } - if (!isNaN(x) && opts.clamp) { - x = evenRound(x); - if (x < lowerBound) - x = lowerBound; - if (x > upperBound) - x = upperBound; - return x; - } - if (!Number.isFinite(x) || x === 0) { - return 0; - } - x = sign(x) * Math.floor(Math.abs(x)); - x = x % moduloVal; - if (!typeOpts.unsigned && x >= moduloBound) { - return x - moduloVal; - } else if (typeOpts.unsigned) { - if (x < 0) { - x += moduloVal; - } else if (x === -0) { - return 0; - } - } - return x; - }; - } - conversions["void"] = function() { - return void 0; - }; - conversions["boolean"] = function(val) { - return !!val; - }; - conversions["byte"] = createNumberConversion(8, { unsigned: false }); - conversions["octet"] = createNumberConversion(8, { unsigned: true }); - conversions["short"] = createNumberConversion(16, { unsigned: false }); - conversions["unsigned short"] = createNumberConversion(16, { unsigned: true }); - conversions["long"] = createNumberConversion(32, { unsigned: false }); - conversions["unsigned long"] = createNumberConversion(32, { unsigned: true }); - conversions["long long"] = createNumberConversion(32, { unsigned: false, moduloBitLength: 64 }); - conversions["unsigned long long"] = createNumberConversion(32, { unsigned: true, moduloBitLength: 64 }); - conversions["double"] = function(V) { - const x = +V; - if (!Number.isFinite(x)) { - throw new TypeError("Argument is not a finite floating-point value"); - } - return x; - }; - conversions["unrestricted double"] = function(V) { - const x = +V; - if (isNaN(x)) { - throw new TypeError("Argument is NaN"); - } - return x; - }; - conversions["float"] = conversions["double"]; - conversions["unrestricted float"] = conversions["unrestricted double"]; - conversions["DOMString"] = function(V, opts) { - if (!opts) - opts = {}; - if (opts.treatNullAsEmptyString && V === null) { - return ""; - } - return String(V); - }; - conversions["ByteString"] = function(V, opts) { - const x = String(V); - let c = void 0; - for (let i = 0; (c = x.codePointAt(i)) !== void 0; ++i) { - if (c > 255) { - throw new TypeError("Argument is not a valid bytestring"); - } - } - return x; - }; - conversions["USVString"] = function(V) { - const S = String(V); - const n = S.length; - const U = []; - for (let i = 0; i < n; ++i) { - const c = S.charCodeAt(i); - if (c < 55296 || c > 57343) { - U.push(String.fromCodePoint(c)); - } else if (56320 <= c && c <= 57343) { - U.push(String.fromCodePoint(65533)); - } else { - if (i === n - 1) { - U.push(String.fromCodePoint(65533)); - } else { - const d = S.charCodeAt(i + 1); - if (56320 <= d && d <= 57343) { - const a = c & 1023; - const b = d & 1023; - U.push(String.fromCodePoint((2 << 15) + (2 << 9) * a + b)); - ++i; - } else { - U.push(String.fromCodePoint(65533)); - } - } - } - } - return U.join(""); - }; - conversions["Date"] = function(V, opts) { - if (!(V instanceof Date)) { - throw new TypeError("Argument is not a Date object"); - } - if (isNaN(V)) { - return void 0; - } - return V; - }; - conversions["RegExp"] = function(V, opts) { - if (!(V instanceof RegExp)) { - V = new RegExp(V); - } - return V; - }; - } -}); - -// -var require_utils6 = __commonJS({ - ""(exports, module) { - "use strict"; - module.exports.mixin = function mixin(target, source) { - const keys = Object.getOwnPropertyNames(source); - for (let i = 0; i < keys.length; ++i) { - Object.defineProperty(target, keys[i], Object.getOwnPropertyDescriptor(source, keys[i])); - } - }; - module.exports.wrapperSymbol = Symbol("wrapper"); - module.exports.implSymbol = Symbol("impl"); - module.exports.wrapperForImpl = function(impl) { - return impl[module.exports.wrapperSymbol]; - }; - module.exports.implForWrapper = function(wrapper) { - return wrapper[module.exports.implSymbol]; - }; - } -}); - -// -var require_url_state_machine3 = __commonJS({ - ""(exports, module) { - "use strict"; - var punycode = __require("punycode"); - var tr46 = require_tr46(); - var specialSchemes = { - ftp: 21, - file: null, - gopher: 70, - http: 80, - https: 443, - ws: 80, - wss: 443 - }; - var failure = Symbol("failure"); - function countSymbols(str) { - return punycode.ucs2.decode(str).length; - } - function at(input, idx) { - const c = input[idx]; - return isNaN(c) ? void 0 : String.fromCodePoint(c); - } - function isASCIIDigit(c) { - return c >= 48 && c <= 57; - } - function isASCIIAlpha(c) { - return c >= 65 && c <= 90 || c >= 97 && c <= 122; - } - function isASCIIAlphanumeric(c) { - return isASCIIAlpha(c) || isASCIIDigit(c); - } - function isASCIIHex(c) { - return isASCIIDigit(c) || c >= 65 && c <= 70 || c >= 97 && c <= 102; - } - function isSingleDot(buffer) { - return buffer === "." || buffer.toLowerCase() === "%2e"; - } - function isDoubleDot(buffer) { - buffer = buffer.toLowerCase(); - return buffer === ".." || buffer === "%2e." || buffer === ".%2e" || buffer === "%2e%2e"; - } - function isWindowsDriveLetterCodePoints(cp1, cp2) { - return isASCIIAlpha(cp1) && (cp2 === 58 || cp2 === 124); - } - function isWindowsDriveLetterString(string) { - return string.length === 2 && isASCIIAlpha(string.codePointAt(0)) && (string[1] === ":" || string[1] === "|"); - } - function isNormalizedWindowsDriveLetterString(string) { - return string.length === 2 && isASCIIAlpha(string.codePointAt(0)) && string[1] === ":"; - } - function containsForbiddenHostCodePoint(string) { - return string.search(/\u0000|\u0009|\u000A|\u000D|\u0020|#|%|\/|:|\?|@|\[|\\|\]/) !== -1; - } - function containsForbiddenHostCodePointExcludingPercent(string) { - return string.search(/\u0000|\u0009|\u000A|\u000D|\u0020|#|\/|:|\?|@|\[|\\|\]/) !== -1; - } - function isSpecialScheme(scheme) { - return specialSchemes[scheme] !== void 0; - } - function isSpecial(url) { - return isSpecialScheme(url.scheme); - } - function defaultPort(scheme) { - return specialSchemes[scheme]; - } - function percentEncode(c) { - let hex = c.toString(16).toUpperCase(); - if (hex.length === 1) { - hex = "0" + hex; - } - return "%" + hex; - } - function utf8PercentEncode(c) { - const buf = new Buffer(c); - let str = ""; - for (let i = 0; i < buf.length; ++i) { - str += percentEncode(buf[i]); - } - return str; - } - function utf8PercentDecode(str) { - const input = new Buffer(str); - const output = []; - for (let i = 0; i < input.length; ++i) { - if (input[i] !== 37) { - output.push(input[i]); - } else if (input[i] === 37 && isASCIIHex(input[i + 1]) && isASCIIHex(input[i + 2])) { - output.push(parseInt(input.slice(i + 1, i + 3).toString(), 16)); - i += 2; - } else { - output.push(input[i]); - } - } - return new Buffer(output).toString(); - } - function isC0ControlPercentEncode(c) { - return c <= 31 || c > 126; - } - var extraPathPercentEncodeSet = /* @__PURE__ */ new Set([32, 34, 35, 60, 62, 63, 96, 123, 125]); - function isPathPercentEncode(c) { - return isC0ControlPercentEncode(c) || extraPathPercentEncodeSet.has(c); - } - var extraUserinfoPercentEncodeSet = /* @__PURE__ */ new Set([47, 58, 59, 61, 64, 91, 92, 93, 94, 124]); - function isUserinfoPercentEncode(c) { - return isPathPercentEncode(c) || extraUserinfoPercentEncodeSet.has(c); - } - function percentEncodeChar(c, encodeSetPredicate) { - const cStr = String.fromCodePoint(c); - if (encodeSetPredicate(c)) { - return utf8PercentEncode(cStr); - } - return cStr; - } - function parseIPv4Number(input) { - let R = 10; - if (input.length >= 2 && input.charAt(0) === "0" && input.charAt(1).toLowerCase() === "x") { - input = input.substring(2); - R = 16; - } else if (input.length >= 2 && input.charAt(0) === "0") { - input = input.substring(1); - R = 8; - } - if (input === "") { - return 0; - } - const regex = R === 10 ? /[^0-9]/ : R === 16 ? /[^0-9A-Fa-f]/ : /[^0-7]/; - if (regex.test(input)) { - return failure; - } - return parseInt(input, R); - } - function parseIPv4(input) { - const parts = input.split("."); - if (parts[parts.length - 1] === "") { - if (parts.length > 1) { - parts.pop(); - } - } - if (parts.length > 4) { - return input; - } - const numbers = []; - for (const part of parts) { - if (part === "") { - return input; - } - const n = parseIPv4Number(part); - if (n === failure) { - return input; - } - numbers.push(n); - } - for (let i = 0; i < numbers.length - 1; ++i) { - if (numbers[i] > 255) { - return failure; - } - } - if (numbers[numbers.length - 1] >= Math.pow(256, 5 - numbers.length)) { - return failure; - } - let ipv4 = numbers.pop(); - let counter = 0; - for (const n of numbers) { - ipv4 += n * Math.pow(256, 3 - counter); - ++counter; - } - return ipv4; - } - function serializeIPv4(address) { - let output = ""; - let n = address; - for (let i = 1; i <= 4; ++i) { - output = String(n % 256) + output; - if (i !== 4) { - output = "." + output; - } - n = Math.floor(n / 256); - } - return output; - } - function parseIPv6(input) { - const address = [0, 0, 0, 0, 0, 0, 0, 0]; - let pieceIndex = 0; - let compress = null; - let pointer = 0; - input = punycode.ucs2.decode(input); - if (input[pointer] === 58) { - if (input[pointer + 1] !== 58) { - return failure; - } - pointer += 2; - ++pieceIndex; - compress = pieceIndex; - } - while (pointer < input.length) { - if (pieceIndex === 8) { - return failure; - } - if (input[pointer] === 58) { - if (compress !== null) { - return failure; - } - ++pointer; - ++pieceIndex; - compress = pieceIndex; - continue; - } - let value = 0; - let length = 0; - while (length < 4 && isASCIIHex(input[pointer])) { - value = value * 16 + parseInt(at(input, pointer), 16); - ++pointer; - ++length; - } - if (input[pointer] === 46) { - if (length === 0) { - return failure; - } - pointer -= length; - if (pieceIndex > 6) { - return failure; - } - let numbersSeen = 0; - while (input[pointer] !== void 0) { - let ipv4Piece = null; - if (numbersSeen > 0) { - if (input[pointer] === 46 && numbersSeen < 4) { - ++pointer; - } else { - return failure; - } - } - if (!isASCIIDigit(input[pointer])) { - return failure; - } - while (isASCIIDigit(input[pointer])) { - const number = parseInt(at(input, pointer)); - if (ipv4Piece === null) { - ipv4Piece = number; - } else if (ipv4Piece === 0) { - return failure; - } else { - ipv4Piece = ipv4Piece * 10 + number; - } - if (ipv4Piece > 255) { - return failure; - } - ++pointer; - } - address[pieceIndex] = address[pieceIndex] * 256 + ipv4Piece; - ++numbersSeen; - if (numbersSeen === 2 || numbersSeen === 4) { - ++pieceIndex; - } - } - if (numbersSeen !== 4) { - return failure; - } - break; - } else if (input[pointer] === 58) { - ++pointer; - if (input[pointer] === void 0) { - return failure; - } - } else if (input[pointer] !== void 0) { - return failure; - } - address[pieceIndex] = value; - ++pieceIndex; - } - if (compress !== null) { - let swaps = pieceIndex - compress; - pieceIndex = 7; - while (pieceIndex !== 0 && swaps > 0) { - const temp = address[compress + swaps - 1]; - address[compress + swaps - 1] = address[pieceIndex]; - address[pieceIndex] = temp; - --pieceIndex; - --swaps; - } - } else if (compress === null && pieceIndex !== 8) { - return failure; - } - return address; - } - function serializeIPv6(address) { - let output = ""; - const seqResult = findLongestZeroSequence(address); - const compress = seqResult.idx; - let ignore0 = false; - for (let pieceIndex = 0; pieceIndex <= 7; ++pieceIndex) { - if (ignore0 && address[pieceIndex] === 0) { - continue; - } else if (ignore0) { - ignore0 = false; - } - if (compress === pieceIndex) { - const separator = pieceIndex === 0 ? "::" : ":"; - output += separator; - ignore0 = true; - continue; - } - output += address[pieceIndex].toString(16); - if (pieceIndex !== 7) { - output += ":"; - } - } - return output; - } - function parseHost(input, isSpecialArg) { - if (input[0] === "[") { - if (input[input.length - 1] !== "]") { - return failure; - } - return parseIPv6(input.substring(1, input.length - 1)); - } - if (!isSpecialArg) { - return parseOpaqueHost(input); - } - const domain = utf8PercentDecode(input); - const asciiDomain = tr46.toASCII(domain, false, tr46.PROCESSING_OPTIONS.NONTRANSITIONAL, false); - if (asciiDomain === null) { - return failure; - } - if (containsForbiddenHostCodePoint(asciiDomain)) { - return failure; - } - const ipv4Host = parseIPv4(asciiDomain); - if (typeof ipv4Host === "number" || ipv4Host === failure) { - return ipv4Host; - } - return asciiDomain; - } - function parseOpaqueHost(input) { - if (containsForbiddenHostCodePointExcludingPercent(input)) { - return failure; - } - let output = ""; - const decoded = punycode.ucs2.decode(input); - for (let i = 0; i < decoded.length; ++i) { - output += percentEncodeChar(decoded[i], isC0ControlPercentEncode); - } - return output; - } - function findLongestZeroSequence(arr) { - let maxIdx = null; - let maxLen = 1; - let currStart = null; - let currLen = 0; - for (let i = 0; i < arr.length; ++i) { - if (arr[i] !== 0) { - if (currLen > maxLen) { - maxIdx = currStart; - maxLen = currLen; - } - currStart = null; - currLen = 0; - } else { - if (currStart === null) { - currStart = i; - } - ++currLen; - } - } - if (currLen > maxLen) { - maxIdx = currStart; - maxLen = currLen; - } - return { - idx: maxIdx, - len: maxLen - }; - } - function serializeHost(host) { - if (typeof host === "number") { - return serializeIPv4(host); - } - if (host instanceof Array) { - return "[" + serializeIPv6(host) + "]"; - } - return host; - } - function trimControlChars(url) { - return url.replace(/^[\u0000-\u001F\u0020]+|[\u0000-\u001F\u0020]+$/g, ""); - } - function trimTabAndNewline(url) { - return url.replace(/\u0009|\u000A|\u000D/g, ""); - } - function shortenPath(url) { - const path = url.path; - if (path.length === 0) { - return; - } - if (url.scheme === "file" && path.length === 1 && isNormalizedWindowsDriveLetter(path[0])) { - return; - } - path.pop(); - } - function includesCredentials(url) { - return url.username !== "" || url.password !== ""; - } - function cannotHaveAUsernamePasswordPort(url) { - return url.host === null || url.host === "" || url.cannotBeABaseURL || url.scheme === "file"; - } - function isNormalizedWindowsDriveLetter(string) { - return /^[A-Za-z]:$/.test(string); - } - function URLStateMachine(input, base, encodingOverride, url, stateOverride) { - this.pointer = 0; - this.input = input; - this.base = base || null; - this.encodingOverride = encodingOverride || "utf-8"; - this.stateOverride = stateOverride; - this.url = url; - this.failure = false; - this.parseError = false; - if (!this.url) { - this.url = { - scheme: "", - username: "", - password: "", - host: null, - port: null, - path: [], - query: null, - fragment: null, - cannotBeABaseURL: false - }; - const res2 = trimControlChars(this.input); - if (res2 !== this.input) { - this.parseError = true; - } - this.input = res2; - } - const res = trimTabAndNewline(this.input); - if (res !== this.input) { - this.parseError = true; - } - this.input = res; - this.state = stateOverride || "scheme start"; - this.buffer = ""; - this.atFlag = false; - this.arrFlag = false; - this.passwordTokenSeenFlag = false; - this.input = punycode.ucs2.decode(this.input); - for (; this.pointer <= this.input.length; ++this.pointer) { - const c = this.input[this.pointer]; - const cStr = isNaN(c) ? void 0 : String.fromCodePoint(c); - const ret = this["parse " + this.state](c, cStr); - if (!ret) { - break; - } else if (ret === failure) { - this.failure = true; - break; - } - } - } - URLStateMachine.prototype["parse scheme start"] = function parseSchemeStart(c, cStr) { - if (isASCIIAlpha(c)) { - this.buffer += cStr.toLowerCase(); - this.state = "scheme"; - } else if (!this.stateOverride) { - this.state = "no scheme"; - --this.pointer; - } else { - this.parseError = true; - return failure; - } - return true; - }; - URLStateMachine.prototype["parse scheme"] = function parseScheme(c, cStr) { - if (isASCIIAlphanumeric(c) || c === 43 || c === 45 || c === 46) { - this.buffer += cStr.toLowerCase(); - } else if (c === 58) { - if (this.stateOverride) { - if (isSpecial(this.url) && !isSpecialScheme(this.buffer)) { - return false; - } - if (!isSpecial(this.url) && isSpecialScheme(this.buffer)) { - return false; - } - if ((includesCredentials(this.url) || this.url.port !== null) && this.buffer === "file") { - return false; - } - if (this.url.scheme === "file" && (this.url.host === "" || this.url.host === null)) { - return false; - } - } - this.url.scheme = this.buffer; - this.buffer = ""; - if (this.stateOverride) { - return false; - } - if (this.url.scheme === "file") { - if (this.input[this.pointer + 1] !== 47 || this.input[this.pointer + 2] !== 47) { - this.parseError = true; - } - this.state = "file"; - } else if (isSpecial(this.url) && this.base !== null && this.base.scheme === this.url.scheme) { - this.state = "special relative or authority"; - } else if (isSpecial(this.url)) { - this.state = "special authority slashes"; - } else if (this.input[this.pointer + 1] === 47) { - this.state = "path or authority"; - ++this.pointer; - } else { - this.url.cannotBeABaseURL = true; - this.url.path.push(""); - this.state = "cannot-be-a-base-URL path"; - } - } else if (!this.stateOverride) { - this.buffer = ""; - this.state = "no scheme"; - this.pointer = -1; - } else { - this.parseError = true; - return failure; - } - return true; - }; - URLStateMachine.prototype["parse no scheme"] = function parseNoScheme(c) { - if (this.base === null || this.base.cannotBeABaseURL && c !== 35) { - return failure; - } else if (this.base.cannotBeABaseURL && c === 35) { - this.url.scheme = this.base.scheme; - this.url.path = this.base.path.slice(); - this.url.query = this.base.query; - this.url.fragment = ""; - this.url.cannotBeABaseURL = true; - this.state = "fragment"; - } else if (this.base.scheme === "file") { - this.state = "file"; - --this.pointer; - } else { - this.state = "relative"; - --this.pointer; - } - return true; - }; - URLStateMachine.prototype["parse special relative or authority"] = function parseSpecialRelativeOrAuthority(c) { - if (c === 47 && this.input[this.pointer + 1] === 47) { - this.state = "special authority ignore slashes"; - ++this.pointer; - } else { - this.parseError = true; - this.state = "relative"; - --this.pointer; - } - return true; - }; - URLStateMachine.prototype["parse path or authority"] = function parsePathOrAuthority(c) { - if (c === 47) { - this.state = "authority"; - } else { - this.state = "path"; - --this.pointer; - } - return true; - }; - URLStateMachine.prototype["parse relative"] = function parseRelative(c) { - this.url.scheme = this.base.scheme; - if (isNaN(c)) { - this.url.username = this.base.username; - this.url.password = this.base.password; - this.url.host = this.base.host; - this.url.port = this.base.port; - this.url.path = this.base.path.slice(); - this.url.query = this.base.query; - } else if (c === 47) { - this.state = "relative slash"; - } else if (c === 63) { - this.url.username = this.base.username; - this.url.password = this.base.password; - this.url.host = this.base.host; - this.url.port = this.base.port; - this.url.path = this.base.path.slice(); - this.url.query = ""; - this.state = "query"; - } else if (c === 35) { - this.url.username = this.base.username; - this.url.password = this.base.password; - this.url.host = this.base.host; - this.url.port = this.base.port; - this.url.path = this.base.path.slice(); - this.url.query = this.base.query; - this.url.fragment = ""; - this.state = "fragment"; - } else if (isSpecial(this.url) && c === 92) { - this.parseError = true; - this.state = "relative slash"; - } else { - this.url.username = this.base.username; - this.url.password = this.base.password; - this.url.host = this.base.host; - this.url.port = this.base.port; - this.url.path = this.base.path.slice(0, this.base.path.length - 1); - this.state = "path"; - --this.pointer; - } - return true; - }; - URLStateMachine.prototype["parse relative slash"] = function parseRelativeSlash(c) { - if (isSpecial(this.url) && (c === 47 || c === 92)) { - if (c === 92) { - this.parseError = true; - } - this.state = "special authority ignore slashes"; - } else if (c === 47) { - this.state = "authority"; - } else { - this.url.username = this.base.username; - this.url.password = this.base.password; - this.url.host = this.base.host; - this.url.port = this.base.port; - this.state = "path"; - --this.pointer; - } - return true; - }; - URLStateMachine.prototype["parse special authority slashes"] = function parseSpecialAuthoritySlashes(c) { - if (c === 47 && this.input[this.pointer + 1] === 47) { - this.state = "special authority ignore slashes"; - ++this.pointer; - } else { - this.parseError = true; - this.state = "special authority ignore slashes"; - --this.pointer; - } - return true; - }; - URLStateMachine.prototype["parse special authority ignore slashes"] = function parseSpecialAuthorityIgnoreSlashes(c) { - if (c !== 47 && c !== 92) { - this.state = "authority"; - --this.pointer; - } else { - this.parseError = true; - } - return true; - }; - URLStateMachine.prototype["parse authority"] = function parseAuthority(c, cStr) { - if (c === 64) { - this.parseError = true; - if (this.atFlag) { - this.buffer = "%40" + this.buffer; - } - this.atFlag = true; - const len = countSymbols(this.buffer); - for (let pointer = 0; pointer < len; ++pointer) { - const codePoint = this.buffer.codePointAt(pointer); - if (codePoint === 58 && !this.passwordTokenSeenFlag) { - this.passwordTokenSeenFlag = true; - continue; - } - const encodedCodePoints = percentEncodeChar(codePoint, isUserinfoPercentEncode); - if (this.passwordTokenSeenFlag) { - this.url.password += encodedCodePoints; - } else { - this.url.username += encodedCodePoints; - } - } - this.buffer = ""; - } else if (isNaN(c) || c === 47 || c === 63 || c === 35 || isSpecial(this.url) && c === 92) { - if (this.atFlag && this.buffer === "") { - this.parseError = true; - return failure; - } - this.pointer -= countSymbols(this.buffer) + 1; - this.buffer = ""; - this.state = "host"; - } else { - this.buffer += cStr; - } - return true; - }; - URLStateMachine.prototype["parse hostname"] = URLStateMachine.prototype["parse host"] = function parseHostName(c, cStr) { - if (this.stateOverride && this.url.scheme === "file") { - --this.pointer; - this.state = "file host"; - } else if (c === 58 && !this.arrFlag) { - if (this.buffer === "") { - this.parseError = true; - return failure; - } - const host = parseHost(this.buffer, isSpecial(this.url)); - if (host === failure) { - return failure; - } - this.url.host = host; - this.buffer = ""; - this.state = "port"; - if (this.stateOverride === "hostname") { - return false; - } - } else if (isNaN(c) || c === 47 || c === 63 || c === 35 || isSpecial(this.url) && c === 92) { - --this.pointer; - if (isSpecial(this.url) && this.buffer === "") { - this.parseError = true; - return failure; - } else if (this.stateOverride && this.buffer === "" && (includesCredentials(this.url) || this.url.port !== null)) { - this.parseError = true; - return false; - } - const host = parseHost(this.buffer, isSpecial(this.url)); - if (host === failure) { - return failure; - } - this.url.host = host; - this.buffer = ""; - this.state = "path start"; - if (this.stateOverride) { - return false; - } - } else { - if (c === 91) { - this.arrFlag = true; - } else if (c === 93) { - this.arrFlag = false; - } - this.buffer += cStr; - } - return true; - }; - URLStateMachine.prototype["parse port"] = function parsePort(c, cStr) { - if (isASCIIDigit(c)) { - this.buffer += cStr; - } else if (isNaN(c) || c === 47 || c === 63 || c === 35 || isSpecial(this.url) && c === 92 || this.stateOverride) { - if (this.buffer !== "") { - const port = parseInt(this.buffer); - if (port > Math.pow(2, 16) - 1) { - this.parseError = true; - return failure; - } - this.url.port = port === defaultPort(this.url.scheme) ? null : port; - this.buffer = ""; - } - if (this.stateOverride) { - return false; - } - this.state = "path start"; - --this.pointer; - } else { - this.parseError = true; - return failure; - } - return true; - }; - var fileOtherwiseCodePoints = /* @__PURE__ */ new Set([47, 92, 63, 35]); - URLStateMachine.prototype["parse file"] = function parseFile(c) { - this.url.scheme = "file"; - if (c === 47 || c === 92) { - if (c === 92) { - this.parseError = true; - } - this.state = "file slash"; - } else if (this.base !== null && this.base.scheme === "file") { - if (isNaN(c)) { - this.url.host = this.base.host; - this.url.path = this.base.path.slice(); - this.url.query = this.base.query; - } else if (c === 63) { - this.url.host = this.base.host; - this.url.path = this.base.path.slice(); - this.url.query = ""; - this.state = "query"; - } else if (c === 35) { - this.url.host = this.base.host; - this.url.path = this.base.path.slice(); - this.url.query = this.base.query; - this.url.fragment = ""; - this.state = "fragment"; - } else { - if (this.input.length - this.pointer - 1 === 0 || !isWindowsDriveLetterCodePoints(c, this.input[this.pointer + 1]) || this.input.length - this.pointer - 1 >= 2 && !fileOtherwiseCodePoints.has(this.input[this.pointer + 2])) { - this.url.host = this.base.host; - this.url.path = this.base.path.slice(); - shortenPath(this.url); - } else { - this.parseError = true; - } - this.state = "path"; - --this.pointer; - } - } else { - this.state = "path"; - --this.pointer; - } - return true; - }; - URLStateMachine.prototype["parse file slash"] = function parseFileSlash(c) { - if (c === 47 || c === 92) { - if (c === 92) { - this.parseError = true; - } - this.state = "file host"; - } else { - if (this.base !== null && this.base.scheme === "file") { - if (isNormalizedWindowsDriveLetterString(this.base.path[0])) { - this.url.path.push(this.base.path[0]); - } else { - this.url.host = this.base.host; - } - } - this.state = "path"; - --this.pointer; - } - return true; - }; - URLStateMachine.prototype["parse file host"] = function parseFileHost(c, cStr) { - if (isNaN(c) || c === 47 || c === 92 || c === 63 || c === 35) { - --this.pointer; - if (!this.stateOverride && isWindowsDriveLetterString(this.buffer)) { - this.parseError = true; - this.state = "path"; - } else if (this.buffer === "") { - this.url.host = ""; - if (this.stateOverride) { - return false; - } - this.state = "path start"; - } else { - let host = parseHost(this.buffer, isSpecial(this.url)); - if (host === failure) { - return failure; - } - if (host === "localhost") { - host = ""; - } - this.url.host = host; - if (this.stateOverride) { - return false; - } - this.buffer = ""; - this.state = "path start"; - } - } else { - this.buffer += cStr; - } - return true; - }; - URLStateMachine.prototype["parse path start"] = function parsePathStart(c) { - if (isSpecial(this.url)) { - if (c === 92) { - this.parseError = true; - } - this.state = "path"; - if (c !== 47 && c !== 92) { - --this.pointer; - } - } else if (!this.stateOverride && c === 63) { - this.url.query = ""; - this.state = "query"; - } else if (!this.stateOverride && c === 35) { - this.url.fragment = ""; - this.state = "fragment"; - } else if (c !== void 0) { - this.state = "path"; - if (c !== 47) { - --this.pointer; - } - } - return true; - }; - URLStateMachine.prototype["parse path"] = function parsePath(c) { - if (isNaN(c) || c === 47 || isSpecial(this.url) && c === 92 || !this.stateOverride && (c === 63 || c === 35)) { - if (isSpecial(this.url) && c === 92) { - this.parseError = true; - } - if (isDoubleDot(this.buffer)) { - shortenPath(this.url); - if (c !== 47 && !(isSpecial(this.url) && c === 92)) { - this.url.path.push(""); - } - } else if (isSingleDot(this.buffer) && c !== 47 && !(isSpecial(this.url) && c === 92)) { - this.url.path.push(""); - } else if (!isSingleDot(this.buffer)) { - if (this.url.scheme === "file" && this.url.path.length === 0 && isWindowsDriveLetterString(this.buffer)) { - if (this.url.host !== "" && this.url.host !== null) { - this.parseError = true; - this.url.host = ""; - } - this.buffer = this.buffer[0] + ":"; - } - this.url.path.push(this.buffer); - } - this.buffer = ""; - if (this.url.scheme === "file" && (c === void 0 || c === 63 || c === 35)) { - while (this.url.path.length > 1 && this.url.path[0] === "") { - this.parseError = true; - this.url.path.shift(); - } - } - if (c === 63) { - this.url.query = ""; - this.state = "query"; - } - if (c === 35) { - this.url.fragment = ""; - this.state = "fragment"; - } - } else { - if (c === 37 && (!isASCIIHex(this.input[this.pointer + 1]) || !isASCIIHex(this.input[this.pointer + 2]))) { - this.parseError = true; - } - this.buffer += percentEncodeChar(c, isPathPercentEncode); - } - return true; - }; - URLStateMachine.prototype["parse cannot-be-a-base-URL path"] = function parseCannotBeABaseURLPath(c) { - if (c === 63) { - this.url.query = ""; - this.state = "query"; - } else if (c === 35) { - this.url.fragment = ""; - this.state = "fragment"; - } else { - if (!isNaN(c) && c !== 37) { - this.parseError = true; - } - if (c === 37 && (!isASCIIHex(this.input[this.pointer + 1]) || !isASCIIHex(this.input[this.pointer + 2]))) { - this.parseError = true; - } - if (!isNaN(c)) { - this.url.path[0] = this.url.path[0] + percentEncodeChar(c, isC0ControlPercentEncode); - } - } - return true; - }; - URLStateMachine.prototype["parse query"] = function parseQuery(c, cStr) { - if (isNaN(c) || !this.stateOverride && c === 35) { - if (!isSpecial(this.url) || this.url.scheme === "ws" || this.url.scheme === "wss") { - this.encodingOverride = "utf-8"; - } - const buffer = new Buffer(this.buffer); - for (let i = 0; i < buffer.length; ++i) { - if (buffer[i] < 33 || buffer[i] > 126 || buffer[i] === 34 || buffer[i] === 35 || buffer[i] === 60 || buffer[i] === 62) { - this.url.query += percentEncode(buffer[i]); - } else { - this.url.query += String.fromCodePoint(buffer[i]); - } - } - this.buffer = ""; - if (c === 35) { - this.url.fragment = ""; - this.state = "fragment"; - } - } else { - if (c === 37 && (!isASCIIHex(this.input[this.pointer + 1]) || !isASCIIHex(this.input[this.pointer + 2]))) { - this.parseError = true; - } - this.buffer += cStr; - } - return true; - }; - URLStateMachine.prototype["parse fragment"] = function parseFragment(c) { - if (isNaN(c)) { - } else if (c === 0) { - this.parseError = true; - } else { - if (c === 37 && (!isASCIIHex(this.input[this.pointer + 1]) || !isASCIIHex(this.input[this.pointer + 2]))) { - this.parseError = true; - } - this.url.fragment += percentEncodeChar(c, isC0ControlPercentEncode); - } - return true; - }; - function serializeURL(url, excludeFragment) { - let output = url.scheme + ":"; - if (url.host !== null) { - output += "//"; - if (url.username !== "" || url.password !== "") { - output += url.username; - if (url.password !== "") { - output += ":" + url.password; - } - output += "@"; - } - output += serializeHost(url.host); - if (url.port !== null) { - output += ":" + url.port; - } - } else if (url.host === null && url.scheme === "file") { - output += "//"; - } - if (url.cannotBeABaseURL) { - output += url.path[0]; - } else { - for (const string of url.path) { - output += "/" + string; - } - } - if (url.query !== null) { - output += "?" + url.query; - } - if (!excludeFragment && url.fragment !== null) { - output += "#" + url.fragment; - } - return output; - } - function serializeOrigin(tuple) { - let result = tuple.scheme + "://"; - result += serializeHost(tuple.host); - if (tuple.port !== null) { - result += ":" + tuple.port; - } - return result; - } - module.exports.serializeURL = serializeURL; - module.exports.serializeURLOrigin = function(url) { - switch (url.scheme) { - case "blob": - try { - return module.exports.serializeURLOrigin(module.exports.parseURL(url.path[0])); - } catch (e) { - return "null"; - } - case "ftp": - case "gopher": - case "http": - case "https": - case "ws": - case "wss": - return serializeOrigin({ - scheme: url.scheme, - host: url.host, - port: url.port - }); - case "file": - return "file://"; - default: - return "null"; - } - }; - module.exports.basicURLParse = function(input, options) { - if (options === void 0) { - options = {}; - } - const usm = new URLStateMachine(input, options.baseURL, options.encodingOverride, options.url, options.stateOverride); - if (usm.failure) { - return "failure"; - } - return usm.url; - }; - module.exports.setTheUsername = function(url, username) { - url.username = ""; - const decoded = punycode.ucs2.decode(username); - for (let i = 0; i < decoded.length; ++i) { - url.username += percentEncodeChar(decoded[i], isUserinfoPercentEncode); - } - }; - module.exports.setThePassword = function(url, password) { - url.password = ""; - const decoded = punycode.ucs2.decode(password); - for (let i = 0; i < decoded.length; ++i) { - url.password += percentEncodeChar(decoded[i], isUserinfoPercentEncode); - } - }; - module.exports.serializeHost = serializeHost; - module.exports.cannotHaveAUsernamePasswordPort = cannotHaveAUsernamePasswordPort; - module.exports.serializeInteger = function(integer) { - return String(integer); - }; - module.exports.parseURL = function(input, options) { - if (options === void 0) { - options = {}; - } - return module.exports.basicURLParse(input, { baseURL: options.baseURL, encodingOverride: options.encodingOverride }); - }; - } -}); - -// -var require_URL_impl3 = __commonJS({ - ""(exports) { - "use strict"; - var usm = require_url_state_machine3(); - exports.implementation = class URLImpl { - constructor(constructorArgs) { - const url = constructorArgs[0]; - const base = constructorArgs[1]; - let parsedBase = null; - if (base !== void 0) { - parsedBase = usm.basicURLParse(base); - if (parsedBase === "failure") { - throw new TypeError("Invalid base URL"); - } - } - const parsedURL = usm.basicURLParse(url, { baseURL: parsedBase }); - if (parsedURL === "failure") { - throw new TypeError("Invalid URL"); - } - this._url = parsedURL; - } - get href() { - return usm.serializeURL(this._url); - } - set href(v) { - const parsedURL = usm.basicURLParse(v); - if (parsedURL === "failure") { - throw new TypeError("Invalid URL"); - } - this._url = parsedURL; - } - get origin() { - return usm.serializeURLOrigin(this._url); - } - get protocol() { - return this._url.scheme + ":"; - } - set protocol(v) { - usm.basicURLParse(v + ":", { url: this._url, stateOverride: "scheme start" }); - } - get username() { - return this._url.username; - } - set username(v) { - if (usm.cannotHaveAUsernamePasswordPort(this._url)) { - return; - } - usm.setTheUsername(this._url, v); - } - get password() { - return this._url.password; - } - set password(v) { - if (usm.cannotHaveAUsernamePasswordPort(this._url)) { - return; - } - usm.setThePassword(this._url, v); - } - get host() { - const url = this._url; - if (url.host === null) { - return ""; - } - if (url.port === null) { - return usm.serializeHost(url.host); - } - return usm.serializeHost(url.host) + ":" + usm.serializeInteger(url.port); - } - set host(v) { - if (this._url.cannotBeABaseURL) { - return; - } - usm.basicURLParse(v, { url: this._url, stateOverride: "host" }); - } - get hostname() { - if (this._url.host === null) { - return ""; - } - return usm.serializeHost(this._url.host); - } - set hostname(v) { - if (this._url.cannotBeABaseURL) { - return; - } - usm.basicURLParse(v, { url: this._url, stateOverride: "hostname" }); - } - get port() { - if (this._url.port === null) { - return ""; - } - return usm.serializeInteger(this._url.port); - } - set port(v) { - if (usm.cannotHaveAUsernamePasswordPort(this._url)) { - return; - } - if (v === "") { - this._url.port = null; - } else { - usm.basicURLParse(v, { url: this._url, stateOverride: "port" }); - } - } - get pathname() { - if (this._url.cannotBeABaseURL) { - return this._url.path[0]; - } - if (this._url.path.length === 0) { - return ""; - } - return "/" + this._url.path.join("/"); - } - set pathname(v) { - if (this._url.cannotBeABaseURL) { - return; - } - this._url.path = []; - usm.basicURLParse(v, { url: this._url, stateOverride: "path start" }); - } - get search() { - if (this._url.query === null || this._url.query === "") { - return ""; - } - return "?" + this._url.query; - } - set search(v) { - const url = this._url; - if (v === "") { - url.query = null; - return; - } - const input = v[0] === "?" ? v.substring(1) : v; - url.query = ""; - usm.basicURLParse(input, { url, stateOverride: "query" }); - } - get hash() { - if (this._url.fragment === null || this._url.fragment === "") { - return ""; - } - return "#" + this._url.fragment; - } - set hash(v) { - if (v === "") { - this._url.fragment = null; - return; - } - const input = v[0] === "#" ? v.substring(1) : v; - this._url.fragment = ""; - usm.basicURLParse(input, { url: this._url, stateOverride: "fragment" }); - } - toJSON() { - return this.href; - } - }; - } -}); - -// -var require_URL3 = __commonJS({ - ""(exports, module) { - "use strict"; - var conversions = require_lib7(); - var utils = require_utils6(); - var Impl = require_URL_impl3(); - var impl = utils.implSymbol; - function URL3(url) { - if (!this || this[impl] || !(this instanceof URL3)) { - throw new TypeError("Failed to construct 'URL': Please use the 'new' operator, this DOM object constructor cannot be called as a function."); - } - if (arguments.length < 1) { - throw new TypeError("Failed to construct 'URL': 1 argument required, but only " + arguments.length + " present."); - } - const args = []; - for (let i = 0; i < arguments.length && i < 2; ++i) { - args[i] = arguments[i]; - } - args[0] = conversions["USVString"](args[0]); - if (args[1] !== void 0) { - args[1] = conversions["USVString"](args[1]); - } - module.exports.setup(this, args); - } - URL3.prototype.toJSON = function toJSON() { - if (!this || !module.exports.is(this)) { - throw new TypeError("Illegal invocation"); - } - const args = []; - for (let i = 0; i < arguments.length && i < 0; ++i) { - args[i] = arguments[i]; - } - return this[impl].toJSON.apply(this[impl], args); - }; - Object.defineProperty(URL3.prototype, "href", { - get() { - return this[impl].href; - }, - set(V) { - V = conversions["USVString"](V); - this[impl].href = V; - }, - enumerable: true, - configurable: true - }); - URL3.prototype.toString = function() { - if (!this || !module.exports.is(this)) { - throw new TypeError("Illegal invocation"); - } - return this.href; - }; - Object.defineProperty(URL3.prototype, "origin", { - get() { - return this[impl].origin; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(URL3.prototype, "protocol", { - get() { - return this[impl].protocol; - }, - set(V) { - V = conversions["USVString"](V); - this[impl].protocol = V; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(URL3.prototype, "username", { - get() { - return this[impl].username; - }, - set(V) { - V = conversions["USVString"](V); - this[impl].username = V; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(URL3.prototype, "password", { - get() { - return this[impl].password; - }, - set(V) { - V = conversions["USVString"](V); - this[impl].password = V; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(URL3.prototype, "host", { - get() { - return this[impl].host; - }, - set(V) { - V = conversions["USVString"](V); - this[impl].host = V; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(URL3.prototype, "hostname", { - get() { - return this[impl].hostname; - }, - set(V) { - V = conversions["USVString"](V); - this[impl].hostname = V; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(URL3.prototype, "port", { - get() { - return this[impl].port; - }, - set(V) { - V = conversions["USVString"](V); - this[impl].port = V; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(URL3.prototype, "pathname", { - get() { - return this[impl].pathname; - }, - set(V) { - V = conversions["USVString"](V); - this[impl].pathname = V; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(URL3.prototype, "search", { - get() { - return this[impl].search; - }, - set(V) { - V = conversions["USVString"](V); - this[impl].search = V; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(URL3.prototype, "hash", { - get() { - return this[impl].hash; - }, - set(V) { - V = conversions["USVString"](V); - this[impl].hash = V; - }, - enumerable: true, - configurable: true - }); - module.exports = { - is(obj) { - return !!obj && obj[impl] instanceof Impl.implementation; - }, - create(constructorArgs, privateData) { - let obj = Object.create(URL3.prototype); - this.setup(obj, constructorArgs, privateData); - return obj; - }, - setup(obj, constructorArgs, privateData) { - if (!privateData) - privateData = {}; - privateData.wrapper = obj; - obj[impl] = new Impl.implementation(constructorArgs, privateData); - obj[impl][utils.wrapperSymbol] = obj; - }, - interface: URL3, - expose: { - Window: { URL: URL3 }, - Worker: { URL: URL3 } - } - }; - } -}); - -// -var require_public_api3 = __commonJS({ - ""(exports) { - "use strict"; - exports.URL = require_URL3().interface; - exports.serializeURL = require_url_state_machine3().serializeURL; - exports.serializeURLOrigin = require_url_state_machine3().serializeURLOrigin; - exports.basicURLParse = require_url_state_machine3().basicURLParse; - exports.setTheUsername = require_url_state_machine3().setTheUsername; - exports.setThePassword = require_url_state_machine3().setThePassword; - exports.serializeHost = require_url_state_machine3().serializeHost; - exports.serializeInteger = require_url_state_machine3().serializeInteger; - exports.parseURL = require_url_state_machine3().parseURL; - } -}); - -// -var require_lib8 = __commonJS({ - ""(exports, module) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - function _interopDefault(ex) { - return ex && typeof ex === "object" && "default" in ex ? ex["default"] : ex; - } - var Stream = _interopDefault(__require("stream")); - var http = _interopDefault(__require("http")); - var Url = _interopDefault(__require("url")); - var whatwgUrl = _interopDefault(require_public_api3()); - var https = _interopDefault(__require("https")); - var zlib = _interopDefault(__require("zlib")); - var Readable = Stream.Readable; - var BUFFER = Symbol("buffer"); - var TYPE = Symbol("type"); - var Blob = class { - constructor() { - this[TYPE] = ""; - const blobParts = arguments[0]; - const options = arguments[1]; - const buffers = []; - let size = 0; - if (blobParts) { - const a = blobParts; - const length = Number(a.length); - for (let i = 0; i < length; i++) { - const element = a[i]; - let buffer; - if (element instanceof Buffer) { - buffer = element; - } else if (ArrayBuffer.isView(element)) { - buffer = Buffer.from(element.buffer, element.byteOffset, element.byteLength); - } else if (element instanceof ArrayBuffer) { - buffer = Buffer.from(element); - } else if (element instanceof Blob) { - buffer = element[BUFFER]; - } else { - buffer = Buffer.from(typeof element === "string" ? element : String(element)); - } - size += buffer.length; - buffers.push(buffer); - } - } - this[BUFFER] = Buffer.concat(buffers); - let type = options && options.type !== void 0 && String(options.type).toLowerCase(); - if (type && !/[^\u0020-\u007E]/.test(type)) { - this[TYPE] = type; - } - } - get size() { - return this[BUFFER].length; - } - get type() { - return this[TYPE]; - } - text() { - return Promise.resolve(this[BUFFER].toString()); - } - arrayBuffer() { - const buf = this[BUFFER]; - const ab = buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength); - return Promise.resolve(ab); - } - stream() { - const readable = new Readable(); - readable._read = function() { - }; - readable.push(this[BUFFER]); - readable.push(null); - return readable; - } - toString() { - return "[object Blob]"; - } - slice() { - const size = this.size; - const start = arguments[0]; - const end = arguments[1]; - let relativeStart, relativeEnd; - if (start === void 0) { - relativeStart = 0; - } else if (start < 0) { - relativeStart = Math.max(size + start, 0); - } else { - relativeStart = Math.min(start, size); - } - if (end === void 0) { - relativeEnd = size; - } else if (end < 0) { - relativeEnd = Math.max(size + end, 0); - } else { - relativeEnd = Math.min(end, size); - } - const span = Math.max(relativeEnd - relativeStart, 0); - const buffer = this[BUFFER]; - const slicedBuffer = buffer.slice(relativeStart, relativeStart + span); - const blob = new Blob([], { type: arguments[2] }); - blob[BUFFER] = slicedBuffer; - return blob; - } - }; - Object.defineProperties(Blob.prototype, { - size: { enumerable: true }, - type: { enumerable: true }, - slice: { enumerable: true } - }); - Object.defineProperty(Blob.prototype, Symbol.toStringTag, { - value: "Blob", - writable: false, - enumerable: false, - configurable: true - }); - function FetchError(message, type, systemError) { - Error.call(this, message); - this.message = message; - this.type = type; - if (systemError) { - this.code = this.errno = systemError.code; - } - Error.captureStackTrace(this, this.constructor); - } - FetchError.prototype = Object.create(Error.prototype); - FetchError.prototype.constructor = FetchError; - FetchError.prototype.name = "FetchError"; - var convert; - try { - convert = require_encoding().convert; - } catch (e) { - } - var INTERNALS = Symbol("Body internals"); - var PassThrough = Stream.PassThrough; - function Body(body) { - var _this = this; - var _ref = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, _ref$size = _ref.size; - let size = _ref$size === void 0 ? 0 : _ref$size; - var _ref$timeout = _ref.timeout; - let timeout = _ref$timeout === void 0 ? 0 : _ref$timeout; - if (body == null) { - body = null; - } else if (isURLSearchParams(body)) { - body = Buffer.from(body.toString()); - } else if (isBlob(body)) - ; - else if (Buffer.isBuffer(body)) - ; - else if (Object.prototype.toString.call(body) === "[object ArrayBuffer]") { - body = Buffer.from(body); - } else if (ArrayBuffer.isView(body)) { - body = Buffer.from(body.buffer, body.byteOffset, body.byteLength); - } else if (body instanceof Stream) - ; - else { - body = Buffer.from(String(body)); - } - this[INTERNALS] = { - body, - disturbed: false, - error: null - }; - this.size = size; - this.timeout = timeout; - if (body instanceof Stream) { - body.on("error", function(err) { - const error2 = err.name === "AbortError" ? err : new FetchError(`Invalid response body while trying to fetch ${_this.url}: ${err.message}`, "system", err); - _this[INTERNALS].error = error2; - }); - } - } - Body.prototype = { - get body() { - return this[INTERNALS].body; - }, - get bodyUsed() { - return this[INTERNALS].disturbed; - }, - arrayBuffer() { - return consumeBody.call(this).then(function(buf) { - return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength); - }); - }, - blob() { - let ct = this.headers && this.headers.get("content-type") || ""; - return consumeBody.call(this).then(function(buf) { - return Object.assign( - new Blob([], { - type: ct.toLowerCase() - }), - { - [BUFFER]: buf - } - ); - }); - }, - json() { - var _this2 = this; - return consumeBody.call(this).then(function(buffer) { - try { - return JSON.parse(buffer.toString()); - } catch (err) { - return Body.Promise.reject(new FetchError(`invalid json response body at ${_this2.url} reason: ${err.message}`, "invalid-json")); - } - }); - }, - text() { - return consumeBody.call(this).then(function(buffer) { - return buffer.toString(); - }); - }, - buffer() { - return consumeBody.call(this); - }, - textConverted() { - var _this3 = this; - return consumeBody.call(this).then(function(buffer) { - return convertBody(buffer, _this3.headers); - }); - } - }; - Object.defineProperties(Body.prototype, { - body: { enumerable: true }, - bodyUsed: { enumerable: true }, - arrayBuffer: { enumerable: true }, - blob: { enumerable: true }, - json: { enumerable: true }, - text: { enumerable: true } - }); - Body.mixIn = function(proto2) { - for (const name of Object.getOwnPropertyNames(Body.prototype)) { - if (!(name in proto2)) { - const desc = Object.getOwnPropertyDescriptor(Body.prototype, name); - Object.defineProperty(proto2, name, desc); - } - } - }; - function consumeBody() { - var _this4 = this; - if (this[INTERNALS].disturbed) { - return Body.Promise.reject(new TypeError(`body used already for: ${this.url}`)); - } - this[INTERNALS].disturbed = true; - if (this[INTERNALS].error) { - return Body.Promise.reject(this[INTERNALS].error); - } - let body = this.body; - if (body === null) { - return Body.Promise.resolve(Buffer.alloc(0)); - } - if (isBlob(body)) { - body = body.stream(); - } - if (Buffer.isBuffer(body)) { - return Body.Promise.resolve(body); - } - if (!(body instanceof Stream)) { - return Body.Promise.resolve(Buffer.alloc(0)); - } - let accum = []; - let accumBytes = 0; - let abort = false; - return new Body.Promise(function(resolve, reject) { - let resTimeout; - if (_this4.timeout) { - resTimeout = setTimeout(function() { - abort = true; - reject(new FetchError(`Response timeout while trying to fetch ${_this4.url} (over ${_this4.timeout}ms)`, "body-timeout")); - }, _this4.timeout); - } - body.on("error", function(err) { - if (err.name === "AbortError") { - abort = true; - reject(err); - } else { - reject(new FetchError(`Invalid response body while trying to fetch ${_this4.url}: ${err.message}`, "system", err)); - } - }); - body.on("data", function(chunk) { - if (abort || chunk === null) { - return; - } - if (_this4.size && accumBytes + chunk.length > _this4.size) { - abort = true; - reject(new FetchError(`content size at ${_this4.url} over limit: ${_this4.size}`, "max-size")); - return; - } - accumBytes += chunk.length; - accum.push(chunk); - }); - body.on("end", function() { - if (abort) { - return; - } - clearTimeout(resTimeout); - try { - resolve(Buffer.concat(accum, accumBytes)); - } catch (err) { - reject(new FetchError(`Could not create Buffer from response body for ${_this4.url}: ${err.message}`, "system", err)); - } - }); - }); - } - function convertBody(buffer, headers) { - if (typeof convert !== "function") { - throw new Error("The package `encoding` must be installed to use the textConverted() function"); - } - const ct = headers.get("content-type"); - let charset = "utf-8"; - let res, str; - if (ct) { - res = /charset=([^;]*)/i.exec(ct); - } - str = buffer.slice(0, 1024).toString(); - if (!res && str) { - res = / 0 && arguments[0] !== void 0 ? arguments[0] : void 0; - this[MAP] = /* @__PURE__ */ Object.create(null); - if (init instanceof Headers) { - const rawHeaders = init.raw(); - const headerNames = Object.keys(rawHeaders); - for (const headerName of headerNames) { - for (const value of rawHeaders[headerName]) { - this.append(headerName, value); - } - } - return; - } - if (init == null) - ; - else if (typeof init === "object") { - const method = init[Symbol.iterator]; - if (method != null) { - if (typeof method !== "function") { - throw new TypeError("Header pairs must be iterable"); - } - const pairs = []; - for (const pair of init) { - if (typeof pair !== "object" || typeof pair[Symbol.iterator] !== "function") { - throw new TypeError("Each header pair must be iterable"); - } - pairs.push(Array.from(pair)); - } - for (const pair of pairs) { - if (pair.length !== 2) { - throw new TypeError("Each header pair must be a name/value tuple"); - } - this.append(pair[0], pair[1]); - } - } else { - for (const key of Object.keys(init)) { - const value = init[key]; - this.append(key, value); - } - } - } else { - throw new TypeError("Provided initializer must be an object"); - } - } - get(name) { - name = `${name}`; - validateName(name); - const key = find(this[MAP], name); - if (key === void 0) { - return null; - } - return this[MAP][key].join(", "); - } - forEach(callback) { - let thisArg = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : void 0; - let pairs = getHeaders(this); - let i = 0; - while (i < pairs.length) { - var _pairs$i = pairs[i]; - const name = _pairs$i[0], value = _pairs$i[1]; - callback.call(thisArg, value, name, this); - pairs = getHeaders(this); - i++; - } - } - set(name, value) { - name = `${name}`; - value = `${value}`; - validateName(name); - validateValue(value); - const key = find(this[MAP], name); - this[MAP][key !== void 0 ? key : name] = [value]; - } - append(name, value) { - name = `${name}`; - value = `${value}`; - validateName(name); - validateValue(value); - const key = find(this[MAP], name); - if (key !== void 0) { - this[MAP][key].push(value); - } else { - this[MAP][name] = [value]; - } - } - has(name) { - name = `${name}`; - validateName(name); - return find(this[MAP], name) !== void 0; - } - delete(name) { - name = `${name}`; - validateName(name); - const key = find(this[MAP], name); - if (key !== void 0) { - delete this[MAP][key]; - } - } - raw() { - return this[MAP]; - } - keys() { - return createHeadersIterator(this, "key"); - } - values() { - return createHeadersIterator(this, "value"); - } - [Symbol.iterator]() { - return createHeadersIterator(this, "key+value"); - } - }; - Headers.prototype.entries = Headers.prototype[Symbol.iterator]; - Object.defineProperty(Headers.prototype, Symbol.toStringTag, { - value: "Headers", - writable: false, - enumerable: false, - configurable: true - }); - Object.defineProperties(Headers.prototype, { - get: { enumerable: true }, - forEach: { enumerable: true }, - set: { enumerable: true }, - append: { enumerable: true }, - has: { enumerable: true }, - delete: { enumerable: true }, - keys: { enumerable: true }, - values: { enumerable: true }, - entries: { enumerable: true } - }); - function getHeaders(headers) { - let kind = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "key+value"; - const keys = Object.keys(headers[MAP]).sort(); - return keys.map(kind === "key" ? function(k) { - return k.toLowerCase(); - } : kind === "value" ? function(k) { - return headers[MAP][k].join(", "); - } : function(k) { - return [k.toLowerCase(), headers[MAP][k].join(", ")]; - }); - } - var INTERNAL = Symbol("internal"); - function createHeadersIterator(target, kind) { - const iterator = Object.create(HeadersIteratorPrototype); - iterator[INTERNAL] = { - target, - kind, - index: 0 - }; - return iterator; - } - var HeadersIteratorPrototype = Object.setPrototypeOf({ - next() { - if (!this || Object.getPrototypeOf(this) !== HeadersIteratorPrototype) { - throw new TypeError("Value of `this` is not a HeadersIterator"); - } - var _INTERNAL = this[INTERNAL]; - const target = _INTERNAL.target, kind = _INTERNAL.kind, index = _INTERNAL.index; - const values = getHeaders(target, kind); - const len = values.length; - if (index >= len) { - return { - value: void 0, - done: true - }; - } - this[INTERNAL].index = index + 1; - return { - value: values[index], - done: false - }; - } - }, Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]()))); - Object.defineProperty(HeadersIteratorPrototype, Symbol.toStringTag, { - value: "HeadersIterator", - writable: false, - enumerable: false, - configurable: true - }); - function exportNodeCompatibleHeaders(headers) { - const obj = Object.assign({ __proto__: null }, headers[MAP]); - const hostHeaderKey = find(headers[MAP], "Host"); - if (hostHeaderKey !== void 0) { - obj[hostHeaderKey] = obj[hostHeaderKey][0]; - } - return obj; - } - function createHeadersLenient(obj) { - const headers = new Headers(); - for (const name of Object.keys(obj)) { - if (invalidTokenRegex.test(name)) { - continue; - } - if (Array.isArray(obj[name])) { - for (const val of obj[name]) { - if (invalidHeaderCharRegex.test(val)) { - continue; - } - if (headers[MAP][name] === void 0) { - headers[MAP][name] = [val]; - } else { - headers[MAP][name].push(val); - } - } - } else if (!invalidHeaderCharRegex.test(obj[name])) { - headers[MAP][name] = [obj[name]]; - } - } - return headers; - } - var INTERNALS$1 = Symbol("Response internals"); - var STATUS_CODES = http.STATUS_CODES; - var Response = class { - constructor() { - let body = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : null; - let opts = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; - Body.call(this, body, opts); - const status = opts.status || 200; - const headers = new Headers(opts.headers); - if (body != null && !headers.has("Content-Type")) { - const contentType = extractContentType(body); - if (contentType) { - headers.append("Content-Type", contentType); - } - } - this[INTERNALS$1] = { - url: opts.url, - status, - statusText: opts.statusText || STATUS_CODES[status], - headers, - counter: opts.counter - }; - } - get url() { - return this[INTERNALS$1].url || ""; - } - get status() { - return this[INTERNALS$1].status; - } - get ok() { - return this[INTERNALS$1].status >= 200 && this[INTERNALS$1].status < 300; - } - get redirected() { - return this[INTERNALS$1].counter > 0; - } - get statusText() { - return this[INTERNALS$1].statusText; - } - get headers() { - return this[INTERNALS$1].headers; - } - clone() { - return new Response(clone(this), { - url: this.url, - status: this.status, - statusText: this.statusText, - headers: this.headers, - ok: this.ok, - redirected: this.redirected - }); - } - }; - Body.mixIn(Response.prototype); - Object.defineProperties(Response.prototype, { - url: { enumerable: true }, - status: { enumerable: true }, - ok: { enumerable: true }, - redirected: { enumerable: true }, - statusText: { enumerable: true }, - headers: { enumerable: true }, - clone: { enumerable: true } - }); - Object.defineProperty(Response.prototype, Symbol.toStringTag, { - value: "Response", - writable: false, - enumerable: false, - configurable: true - }); - var INTERNALS$2 = Symbol("Request internals"); - var URL3 = Url.URL || whatwgUrl.URL; - var parse_url = Url.parse; - var format_url = Url.format; - function parseURL(urlStr) { - if (/^[a-zA-Z][a-zA-Z\d+\-.]*:/.exec(urlStr)) { - urlStr = new URL3(urlStr).toString(); - } - return parse_url(urlStr); - } - var streamDestructionSupported = "destroy" in Stream.Readable.prototype; - function isRequest(input) { - return typeof input === "object" && typeof input[INTERNALS$2] === "object"; - } - function isAbortSignal(signal) { - const proto2 = signal && typeof signal === "object" && Object.getPrototypeOf(signal); - return !!(proto2 && proto2.constructor.name === "AbortSignal"); - } - var Request = class { - constructor(input) { - let init = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; - let parsedURL; - if (!isRequest(input)) { - if (input && input.href) { - parsedURL = parseURL(input.href); - } else { - parsedURL = parseURL(`${input}`); - } - input = {}; - } else { - parsedURL = parseURL(input.url); - } - let method = init.method || input.method || "GET"; - method = method.toUpperCase(); - if ((init.body != null || isRequest(input) && input.body !== null) && (method === "GET" || method === "HEAD")) { - throw new TypeError("Request with GET/HEAD method cannot have body"); - } - let inputBody = init.body != null ? init.body : isRequest(input) && input.body !== null ? clone(input) : null; - Body.call(this, inputBody, { - timeout: init.timeout || input.timeout || 0, - size: init.size || input.size || 0 - }); - const headers = new Headers(init.headers || input.headers || {}); - if (inputBody != null && !headers.has("Content-Type")) { - const contentType = extractContentType(inputBody); - if (contentType) { - headers.append("Content-Type", contentType); - } - } - let signal = isRequest(input) ? input.signal : null; - if ("signal" in init) - signal = init.signal; - if (signal != null && !isAbortSignal(signal)) { - throw new TypeError("Expected signal to be an instanceof AbortSignal"); - } - this[INTERNALS$2] = { - method, - redirect: init.redirect || input.redirect || "follow", - headers, - parsedURL, - signal - }; - this.follow = init.follow !== void 0 ? init.follow : input.follow !== void 0 ? input.follow : 20; - this.compress = init.compress !== void 0 ? init.compress : input.compress !== void 0 ? input.compress : true; - this.counter = init.counter || input.counter || 0; - this.agent = init.agent || input.agent; - } - get method() { - return this[INTERNALS$2].method; - } - get url() { - return format_url(this[INTERNALS$2].parsedURL); - } - get headers() { - return this[INTERNALS$2].headers; - } - get redirect() { - return this[INTERNALS$2].redirect; - } - get signal() { - return this[INTERNALS$2].signal; - } - clone() { - return new Request(this); - } - }; - Body.mixIn(Request.prototype); - Object.defineProperty(Request.prototype, Symbol.toStringTag, { - value: "Request", - writable: false, - enumerable: false, - configurable: true - }); - Object.defineProperties(Request.prototype, { - method: { enumerable: true }, - url: { enumerable: true }, - headers: { enumerable: true }, - redirect: { enumerable: true }, - clone: { enumerable: true }, - signal: { enumerable: true } - }); - function getNodeRequestOptions(request) { - const parsedURL = request[INTERNALS$2].parsedURL; - const headers = new Headers(request[INTERNALS$2].headers); - if (!headers.has("Accept")) { - headers.set("Accept", "*/*"); - } - if (!parsedURL.protocol || !parsedURL.hostname) { - throw new TypeError("Only absolute URLs are supported"); - } - if (!/^https?:$/.test(parsedURL.protocol)) { - throw new TypeError("Only HTTP(S) protocols are supported"); - } - if (request.signal && request.body instanceof Stream.Readable && !streamDestructionSupported) { - throw new Error("Cancellation of streamed requests with AbortSignal is not supported in node < 8"); - } - let contentLengthValue = null; - if (request.body == null && /^(POST|PUT)$/i.test(request.method)) { - contentLengthValue = "0"; - } - if (request.body != null) { - const totalBytes = getTotalBytes(request); - if (typeof totalBytes === "number") { - contentLengthValue = String(totalBytes); - } - } - if (contentLengthValue) { - headers.set("Content-Length", contentLengthValue); - } - if (!headers.has("User-Agent")) { - headers.set("User-Agent", "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)"); - } - if (request.compress && !headers.has("Accept-Encoding")) { - headers.set("Accept-Encoding", "gzip,deflate"); - } - let agent = request.agent; - if (typeof agent === "function") { - agent = agent(parsedURL); - } - if (!headers.has("Connection") && !agent) { - headers.set("Connection", "close"); - } - return Object.assign({}, parsedURL, { - method: request.method, - headers: exportNodeCompatibleHeaders(headers), - agent - }); - } - function AbortError(message) { - Error.call(this, message); - this.type = "aborted"; - this.message = message; - Error.captureStackTrace(this, this.constructor); - } - AbortError.prototype = Object.create(Error.prototype); - AbortError.prototype.constructor = AbortError; - AbortError.prototype.name = "AbortError"; - var URL$1 = Url.URL || whatwgUrl.URL; - var PassThrough$1 = Stream.PassThrough; - var isDomainOrSubdomain = function isDomainOrSubdomain2(destination, original) { - const orig = new URL$1(original).hostname; - const dest = new URL$1(destination).hostname; - return orig === dest || orig[orig.length - dest.length - 1] === "." && orig.endsWith(dest); - }; - function fetch(url, opts) { - if (!fetch.Promise) { - throw new Error("native promise missing, set fetch.Promise to your favorite alternative"); - } - Body.Promise = fetch.Promise; - return new fetch.Promise(function(resolve, reject) { - const request = new Request(url, opts); - const options = getNodeRequestOptions(request); - const send = (options.protocol === "https:" ? https : http).request; - const signal = request.signal; - let response = null; - const abort = function abort2() { - let error2 = new AbortError("The user aborted a request."); - reject(error2); - if (request.body && request.body instanceof Stream.Readable) { - request.body.destroy(error2); - } - if (!response || !response.body) - return; - response.body.emit("error", error2); - }; - if (signal && signal.aborted) { - abort(); - return; - } - const abortAndFinalize = function abortAndFinalize2() { - abort(); - finalize(); - }; - const req = send(options); - let reqTimeout; - if (signal) { - signal.addEventListener("abort", abortAndFinalize); - } - function finalize() { - req.abort(); - if (signal) - signal.removeEventListener("abort", abortAndFinalize); - clearTimeout(reqTimeout); - } - if (request.timeout) { - req.once("socket", function(socket) { - reqTimeout = setTimeout(function() { - reject(new FetchError(`network timeout at: ${request.url}`, "request-timeout")); - finalize(); - }, request.timeout); - }); - } - req.on("error", function(err) { - reject(new FetchError(`request to ${request.url} failed, reason: ${err.message}`, "system", err)); - finalize(); - }); - req.on("response", function(res) { - clearTimeout(reqTimeout); - const headers = createHeadersLenient(res.headers); - if (fetch.isRedirect(res.statusCode)) { - const location = headers.get("Location"); - let locationURL = null; - try { - locationURL = location === null ? null : new URL$1(location, request.url).toString(); - } catch (err) { - if (request.redirect !== "manual") { - reject(new FetchError(`uri requested responds with an invalid redirect URL: ${location}`, "invalid-redirect")); - finalize(); - return; - } - } - switch (request.redirect) { - case "error": - reject(new FetchError(`uri requested responds with a redirect, redirect mode is set to error: ${request.url}`, "no-redirect")); - finalize(); - return; - case "manual": - if (locationURL !== null) { - try { - headers.set("Location", locationURL); - } catch (err) { - reject(err); - } - } - break; - case "follow": - if (locationURL === null) { - break; - } - if (request.counter >= request.follow) { - reject(new FetchError(`maximum redirect reached at: ${request.url}`, "max-redirect")); - finalize(); - return; - } - const requestOpts = { - headers: new Headers(request.headers), - follow: request.follow, - counter: request.counter + 1, - agent: request.agent, - compress: request.compress, - method: request.method, - body: request.body, - signal: request.signal, - timeout: request.timeout, - size: request.size - }; - if (!isDomainOrSubdomain(request.url, locationURL)) { - for (const name of ["authorization", "www-authenticate", "cookie", "cookie2"]) { - requestOpts.headers.delete(name); - } - } - if (res.statusCode !== 303 && request.body && getTotalBytes(request) === null) { - reject(new FetchError("Cannot follow redirect with body being a readable stream", "unsupported-redirect")); - finalize(); - return; - } - if (res.statusCode === 303 || (res.statusCode === 301 || res.statusCode === 302) && request.method === "POST") { - requestOpts.method = "GET"; - requestOpts.body = void 0; - requestOpts.headers.delete("content-length"); - } - resolve(fetch(new Request(locationURL, requestOpts))); - finalize(); - return; - } - } - res.once("end", function() { - if (signal) - signal.removeEventListener("abort", abortAndFinalize); - }); - let body = res.pipe(new PassThrough$1()); - const response_options = { - url: request.url, - status: res.statusCode, - statusText: res.statusMessage, - headers, - size: request.size, - timeout: request.timeout, - counter: request.counter - }; - const codings = headers.get("Content-Encoding"); - if (!request.compress || request.method === "HEAD" || codings === null || res.statusCode === 204 || res.statusCode === 304) { - response = new Response(body, response_options); - resolve(response); - return; - } - const zlibOptions = { - flush: zlib.Z_SYNC_FLUSH, - finishFlush: zlib.Z_SYNC_FLUSH - }; - if (codings == "gzip" || codings == "x-gzip") { - body = body.pipe(zlib.createGunzip(zlibOptions)); - response = new Response(body, response_options); - resolve(response); - return; - } - if (codings == "deflate" || codings == "x-deflate") { - const raw = res.pipe(new PassThrough$1()); - raw.once("data", function(chunk) { - if ((chunk[0] & 15) === 8) { - body = body.pipe(zlib.createInflate()); - } else { - body = body.pipe(zlib.createInflateRaw()); - } - response = new Response(body, response_options); - resolve(response); - }); - return; - } - if (codings == "br" && typeof zlib.createBrotliDecompress === "function") { - body = body.pipe(zlib.createBrotliDecompress()); - response = new Response(body, response_options); - resolve(response); - return; - } - response = new Response(body, response_options); - resolve(response); - }); - writeToStream(req, request); - }); - } - fetch.isRedirect = function(code) { - return code === 301 || code === 302 || code === 303 || code === 307 || code === 308; - }; - fetch.Promise = global.Promise; - module.exports = exports = fetch; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.default = exports; - exports.Headers = Headers; - exports.Request = Request; - exports.Response = Response; - exports.FetchError = FetchError; - } -}); - -// -var require_dist_node21 = __commonJS({ - ""(exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - function _interopDefault(ex) { - return ex && typeof ex === "object" && "default" in ex ? ex["default"] : ex; - } - var deprecation = require_dist_node3(); - var once = _interopDefault(require_once()); - var logOnceCode = once((deprecation2) => console.warn(deprecation2)); - var logOnceHeaders = once((deprecation2) => console.warn(deprecation2)); - var RequestError = class extends Error { - constructor(message, statusCode, options) { - super(message); - if (Error.captureStackTrace) { - Error.captureStackTrace(this, this.constructor); - } - this.name = "HttpError"; - this.status = statusCode; - let headers; - if ("headers" in options && typeof options.headers !== "undefined") { - headers = options.headers; - } - if ("response" in options) { - this.response = options.response; - headers = options.response.headers; - } - const requestCopy = Object.assign({}, options.request); - if (options.request.headers.authorization) { - requestCopy.headers = Object.assign({}, options.request.headers, { - authorization: options.request.headers.authorization.replace(/ .*$/, " [REDACTED]") - }); - } - requestCopy.url = requestCopy.url.replace(/\bclient_secret=\w+/g, "client_secret=[REDACTED]").replace(/\baccess_token=\w+/g, "access_token=[REDACTED]"); - this.request = requestCopy; - Object.defineProperty(this, "code", { - get() { - logOnceCode(new deprecation.Deprecation("[@octokit/request-error] `error.code` is deprecated, use `error.status`.")); - return statusCode; - } - }); - Object.defineProperty(this, "headers", { - get() { - logOnceHeaders(new deprecation.Deprecation("[@octokit/request-error] `error.headers` is deprecated, use `error.response.headers`.")); - return headers || {}; - } - }); - } - }; - exports.RequestError = RequestError; - } -}); - -// -var require_dist_node22 = __commonJS({ - ""(exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - function _interopDefault(ex) { - return ex && typeof ex === "object" && "default" in ex ? ex["default"] : ex; - } - var endpoint = require_dist_node2(); - var universalUserAgent = require_dist_node(); - var isPlainObject = require_is_plain_object(); - var nodeFetch = _interopDefault(require_lib8()); - var requestError = require_dist_node21(); - var VERSION = "5.6.3"; - function getBufferResponse(response) { - return response.arrayBuffer(); - } - function fetchWrapper(requestOptions) { - const log = requestOptions.request && requestOptions.request.log ? requestOptions.request.log : console; - if (isPlainObject.isPlainObject(requestOptions.body) || Array.isArray(requestOptions.body)) { - requestOptions.body = JSON.stringify(requestOptions.body); - } - let headers = {}; - let status; - let url; - const fetch = requestOptions.request && requestOptions.request.fetch || nodeFetch; - return fetch(requestOptions.url, Object.assign( - { - method: requestOptions.method, - body: requestOptions.body, - headers: requestOptions.headers, - redirect: requestOptions.redirect - }, - requestOptions.request - )).then(async (response) => { - url = response.url; - status = response.status; - for (const keyAndValue of response.headers) { - headers[keyAndValue[0]] = keyAndValue[1]; - } - if ("deprecation" in headers) { - const matches = headers.link && headers.link.match(/<([^>]+)>; rel="deprecation"/); - const deprecationLink = matches && matches.pop(); - log.warn(`[@octokit/request] "${requestOptions.method} ${requestOptions.url}" is deprecated. It is scheduled to be removed on ${headers.sunset}${deprecationLink ? `. See ${deprecationLink}` : ""}`); - } - if (status === 204 || status === 205) { - return; - } - if (requestOptions.method === "HEAD") { - if (status < 400) { - return; - } - throw new requestError.RequestError(response.statusText, status, { - response: { - url, - status, - headers, - data: void 0 - }, - request: requestOptions - }); - } - if (status === 304) { - throw new requestError.RequestError("Not modified", status, { - response: { - url, - status, - headers, - data: await getResponseData(response) - }, - request: requestOptions - }); - } - if (status >= 400) { - const data = await getResponseData(response); - const error2 = new requestError.RequestError(toErrorMessage(data), status, { - response: { - url, - status, - headers, - data - }, - request: requestOptions - }); - throw error2; - } - return getResponseData(response); - }).then((data) => { - return { - status, - url, - headers, - data - }; - }).catch((error2) => { - if (error2 instanceof requestError.RequestError) - throw error2; - throw new requestError.RequestError(error2.message, 500, { - request: requestOptions - }); - }); - } - async function getResponseData(response) { - const contentType = response.headers.get("content-type"); - if (/application\/json/.test(contentType)) { - return response.json(); - } - if (!contentType || /^text\/|charset=utf-8$/.test(contentType)) { - return response.text(); - } - return getBufferResponse(response); - } - function toErrorMessage(data) { - if (typeof data === "string") - return data; - if ("message" in data) { - if (Array.isArray(data.errors)) { - return `${data.message}: ${data.errors.map(JSON.stringify).join(", ")}`; - } - return data.message; - } - return `Unknown error: ${JSON.stringify(data)}`; - } - function withDefaults(oldEndpoint, newDefaults) { - const endpoint2 = oldEndpoint.defaults(newDefaults); - const newApi = function(route, parameters) { - const endpointOptions = endpoint2.merge(route, parameters); - if (!endpointOptions.request || !endpointOptions.request.hook) { - return fetchWrapper(endpoint2.parse(endpointOptions)); - } - const request2 = (route2, parameters2) => { - return fetchWrapper(endpoint2.parse(endpoint2.merge(route2, parameters2))); - }; - Object.assign(request2, { - endpoint: endpoint2, - defaults: withDefaults.bind(null, endpoint2) - }); - return endpointOptions.request.hook(request2, endpointOptions); - }; - return Object.assign(newApi, { - endpoint: endpoint2, - defaults: withDefaults.bind(null, endpoint2) - }); - } - var request = withDefaults(endpoint.endpoint, { - headers: { - "user-agent": `octokit-request.js/${VERSION} ${universalUserAgent.getUserAgent()}` - } - }); - exports.request = request; - } -}); - -// -var require_btoa_node = __commonJS({ - ""(exports, module) { - module.exports = function btoa(str) { - return new Buffer(str).toString("base64"); - }; - } -}); - -// -var require_dist_node23 = __commonJS({ - ""(exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - function oauthAuthorizationUrl(options) { - const clientType = options.clientType || "oauth-app"; - const baseUrl = options.baseUrl || "https://github.com"; - const result = { - clientType, - allowSignup: options.allowSignup === false ? false : true, - clientId: options.clientId, - login: options.login || null, - redirectUrl: options.redirectUrl || null, - state: options.state || Math.random().toString(36).substr(2), - url: "" - }; - if (clientType === "oauth-app") { - const scopes = "scopes" in options ? options.scopes : []; - result.scopes = typeof scopes === "string" ? scopes.split(/[,\s]+/).filter(Boolean) : scopes; - } - result.url = urlBuilderAuthorize(`${baseUrl}/login/oauth/authorize`, result); - return result; - } - function urlBuilderAuthorize(base, options) { - const map = { - allowSignup: "allow_signup", - clientId: "client_id", - login: "login", - redirectUrl: "redirect_uri", - scopes: "scope", - state: "state" - }; - let url = base; - Object.keys(map).filter((k) => options[k] !== null).filter((k) => { - if (k !== "scopes") - return true; - if (options.clientType === "github-app") - return false; - return !Array.isArray(options[k]) || options[k].length > 0; - }).map((key) => [map[key], `${options[key]}`]).forEach(([key, value], index) => { - url += index === 0 ? `?` : "&"; - url += `${key}=${encodeURIComponent(value)}`; - }); - return url; - } - exports.oauthAuthorizationUrl = oauthAuthorizationUrl; - } -}); - -// -var require_dist_node24 = __commonJS({ - ""(exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - function _interopDefault(ex) { - return ex && typeof ex === "object" && "default" in ex ? ex["default"] : ex; - } - var oauthAuthorizationUrl = require_dist_node23(); - var request = require_dist_node13(); - var requestError = require_dist_node12(); - var btoa = _interopDefault(require_btoa_node()); - var VERSION = "2.0.2"; - function requestToOAuthBaseUrl(request2) { - const endpointDefaults = request2.endpoint.DEFAULTS; - return /^https:\/\/(api\.)?github\.com$/.test(endpointDefaults.baseUrl) ? "https://github.com" : endpointDefaults.baseUrl.replace("/api/v3", ""); - } - async function oauthRequest(request2, route, parameters) { - const withOAuthParameters = { - baseUrl: requestToOAuthBaseUrl(request2), - headers: { - accept: "application/json" - }, - ...parameters - }; - const response = await request2(route, withOAuthParameters); - if ("error" in response.data) { - const error2 = new requestError.RequestError(`${response.data.error_description} (${response.data.error}, ${response.data.error_uri})`, 400, { - request: request2.endpoint.merge(route, withOAuthParameters), - headers: response.headers - }); - error2.response = response; - throw error2; - } - return response; - } - function getWebFlowAuthorizationUrl({ - request: request$1 = request.request, - ...options - }) { - const baseUrl = requestToOAuthBaseUrl(request$1); - return oauthAuthorizationUrl.oauthAuthorizationUrl({ - ...options, - baseUrl - }); - } - async function exchangeWebFlowCode(options) { - const request$1 = options.request || request.request; - const response = await oauthRequest(request$1, "POST /login/oauth/access_token", { - client_id: options.clientId, - client_secret: options.clientSecret, - code: options.code, - redirect_uri: options.redirectUrl - }); - const authentication = { - clientType: options.clientType, - clientId: options.clientId, - clientSecret: options.clientSecret, - token: response.data.access_token, - scopes: response.data.scope.split(/\s+/).filter(Boolean) - }; - if (options.clientType === "github-app") { - if ("refresh_token" in response.data) { - const apiTimeInMs = new Date(response.headers.date).getTime(); - authentication.refreshToken = response.data.refresh_token, authentication.expiresAt = toTimestamp(apiTimeInMs, response.data.expires_in), authentication.refreshTokenExpiresAt = toTimestamp(apiTimeInMs, response.data.refresh_token_expires_in); - } - delete authentication.scopes; - } - return { - ...response, - authentication - }; - } - function toTimestamp(apiTimeInMs, expirationInSeconds) { - return new Date(apiTimeInMs + expirationInSeconds * 1e3).toISOString(); - } - async function createDeviceCode(options) { - const request$1 = options.request || request.request; - const parameters = { - client_id: options.clientId - }; - if ("scopes" in options && Array.isArray(options.scopes)) { - parameters.scope = options.scopes.join(" "); - } - return oauthRequest(request$1, "POST /login/device/code", parameters); - } - async function exchangeDeviceCode(options) { - const request$1 = options.request || request.request; - const response = await oauthRequest(request$1, "POST /login/oauth/access_token", { - client_id: options.clientId, - device_code: options.code, - grant_type: "urn:ietf:params:oauth:grant-type:device_code" - }); - const authentication = { - clientType: options.clientType, - clientId: options.clientId, - token: response.data.access_token, - scopes: response.data.scope.split(/\s+/).filter(Boolean) - }; - if ("clientSecret" in options) { - authentication.clientSecret = options.clientSecret; - } - if (options.clientType === "github-app") { - if ("refresh_token" in response.data) { - const apiTimeInMs = new Date(response.headers.date).getTime(); - authentication.refreshToken = response.data.refresh_token, authentication.expiresAt = toTimestamp$1(apiTimeInMs, response.data.expires_in), authentication.refreshTokenExpiresAt = toTimestamp$1(apiTimeInMs, response.data.refresh_token_expires_in); - } - delete authentication.scopes; - } - return { - ...response, - authentication - }; - } - function toTimestamp$1(apiTimeInMs, expirationInSeconds) { - return new Date(apiTimeInMs + expirationInSeconds * 1e3).toISOString(); - } - async function checkToken(options) { - const request$1 = options.request || request.request; - const response = await request$1("POST /applications/{client_id}/token", { - headers: { - authorization: `basic ${btoa(`${options.clientId}:${options.clientSecret}`)}` - }, - client_id: options.clientId, - access_token: options.token - }); - const authentication = { - clientType: options.clientType, - clientId: options.clientId, - clientSecret: options.clientSecret, - token: options.token, - scopes: response.data.scopes - }; - if (response.data.expires_at) - authentication.expiresAt = response.data.expires_at; - if (options.clientType === "github-app") { - delete authentication.scopes; - } - return { - ...response, - authentication - }; - } - async function refreshToken(options) { - const request$1 = options.request || request.request; - const response = await oauthRequest(request$1, "POST /login/oauth/access_token", { - client_id: options.clientId, - client_secret: options.clientSecret, - grant_type: "refresh_token", - refresh_token: options.refreshToken - }); - const apiTimeInMs = new Date(response.headers.date).getTime(); - const authentication = { - clientType: "github-app", - clientId: options.clientId, - clientSecret: options.clientSecret, - token: response.data.access_token, - refreshToken: response.data.refresh_token, - expiresAt: toTimestamp$2(apiTimeInMs, response.data.expires_in), - refreshTokenExpiresAt: toTimestamp$2(apiTimeInMs, response.data.refresh_token_expires_in) - }; - return { - ...response, - authentication - }; - } - function toTimestamp$2(apiTimeInMs, expirationInSeconds) { - return new Date(apiTimeInMs + expirationInSeconds * 1e3).toISOString(); - } - async function scopeToken(options) { - const { - request: request$1, - clientType, - clientId, - clientSecret, - token, - ...requestOptions - } = options; - const response = await (request$1 || request.request)("POST /applications/{client_id}/token/scoped", { - headers: { - authorization: `basic ${btoa(`${clientId}:${clientSecret}`)}` - }, - client_id: clientId, - access_token: token, - ...requestOptions - }); - const authentication = Object.assign({ - clientType, - clientId, - clientSecret, - token: response.data.token - }, response.data.expires_at ? { - expiresAt: response.data.expires_at - } : {}); - return { - ...response, - authentication - }; - } - async function resetToken(options) { - const request$1 = options.request || request.request; - const auth = btoa(`${options.clientId}:${options.clientSecret}`); - const response = await request$1("PATCH /applications/{client_id}/token", { - headers: { - authorization: `basic ${auth}` - }, - client_id: options.clientId, - access_token: options.token - }); - const authentication = { - clientType: options.clientType, - clientId: options.clientId, - clientSecret: options.clientSecret, - token: response.data.token, - scopes: response.data.scopes - }; - if (response.data.expires_at) - authentication.expiresAt = response.data.expires_at; - if (options.clientType === "github-app") { - delete authentication.scopes; - } - return { - ...response, - authentication - }; - } - async function deleteToken(options) { - const request$1 = options.request || request.request; - const auth = btoa(`${options.clientId}:${options.clientSecret}`); - return request$1("DELETE /applications/{client_id}/token", { - headers: { - authorization: `basic ${auth}` - }, - client_id: options.clientId, - access_token: options.token - }); - } - async function deleteAuthorization(options) { - const request$1 = options.request || request.request; - const auth = btoa(`${options.clientId}:${options.clientSecret}`); - return request$1("DELETE /applications/{client_id}/grant", { - headers: { - authorization: `basic ${auth}` - }, - client_id: options.clientId, - access_token: options.token - }); - } - exports.VERSION = VERSION; - exports.checkToken = checkToken; - exports.createDeviceCode = createDeviceCode; - exports.deleteAuthorization = deleteAuthorization; - exports.deleteToken = deleteToken; - exports.exchangeDeviceCode = exchangeDeviceCode; - exports.exchangeWebFlowCode = exchangeWebFlowCode; - exports.getWebFlowAuthorizationUrl = getWebFlowAuthorizationUrl; - exports.refreshToken = refreshToken; - exports.resetToken = resetToken; - exports.scopeToken = scopeToken; - } -}); - -// -var require_dist_node25 = __commonJS({ - ""(exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - var universalUserAgent = require_dist_node(); - var request = require_dist_node13(); - var oauthMethods = require_dist_node24(); - async function getOAuthAccessToken(state, options) { - const cachedAuthentication = getCachedAuthentication(state, options.auth); - if (cachedAuthentication) - return cachedAuthentication; - const { - data: verification - } = await oauthMethods.createDeviceCode({ - clientType: state.clientType, - clientId: state.clientId, - request: options.request || state.request, - scopes: options.auth.scopes || state.scopes - }); - await state.onVerification(verification); - const authentication = await waitForAccessToken(options.request || state.request, state.clientId, state.clientType, verification); - state.authentication = authentication; - return authentication; - } - function getCachedAuthentication(state, auth2) { - if (auth2.refresh === true) - return false; - if (!state.authentication) - return false; - if (state.clientType === "github-app") { - return state.authentication; - } - const authentication = state.authentication; - const newScope = ("scopes" in auth2 && auth2.scopes || state.scopes).join(" "); - const currentScope = authentication.scopes.join(" "); - return newScope === currentScope ? authentication : false; - } - async function wait(seconds) { - await new Promise((resolve) => setTimeout(resolve, seconds * 1e3)); - } - async function waitForAccessToken(request2, clientId, clientType, verification) { - try { - const options = { - clientId, - request: request2, - code: verification.device_code - }; - const { - authentication - } = clientType === "oauth-app" ? await oauthMethods.exchangeDeviceCode({ - ...options, - clientType: "oauth-app" - }) : await oauthMethods.exchangeDeviceCode({ - ...options, - clientType: "github-app" - }); - return { - type: "token", - tokenType: "oauth", - ...authentication - }; - } catch (error2) { - if (!error2.response) - throw error2; - const errorType = error2.response.data.error; - if (errorType === "authorization_pending") { - await wait(verification.interval); - return waitForAccessToken(request2, clientId, clientType, verification); - } - if (errorType === "slow_down") { - await wait(verification.interval + 5); - return waitForAccessToken(request2, clientId, clientType, verification); - } - throw error2; - } - } - async function auth(state, authOptions) { - return getOAuthAccessToken(state, { - auth: authOptions - }); - } - async function hook(state, request2, route, parameters) { - let endpoint = request2.endpoint.merge(route, parameters); - if (/\/login\/(oauth\/access_token|device\/code)$/.test(endpoint.url)) { - return request2(endpoint); - } - const { - token - } = await getOAuthAccessToken(state, { - request: request2, - auth: { - type: "oauth" - } - }); - endpoint.headers.authorization = `token ${token}`; - return request2(endpoint); - } - var VERSION = "4.0.1"; - function createOAuthDeviceAuth(options) { - const requestWithDefaults = options.request || request.request.defaults({ - headers: { - "user-agent": `octokit-auth-oauth-device.js/${VERSION} ${universalUserAgent.getUserAgent()}` - } - }); - const { - request: request$1 = requestWithDefaults, - ...otherOptions - } = options; - const state = options.clientType === "github-app" ? { - ...otherOptions, - clientType: "github-app", - request: request$1 - } : { - ...otherOptions, - clientType: "oauth-app", - request: request$1, - scopes: options.scopes || [] - }; - if (!options.clientId) { - throw new Error('[@octokit/auth-oauth-device] "clientId" option must be set (https://github.com/octokit/auth-oauth-device.js#usage)'); - } - if (!options.onVerification) { - throw new Error('[@octokit/auth-oauth-device] "onVerification" option must be a function (https://github.com/octokit/auth-oauth-device.js#usage)'); - } - return Object.assign(auth.bind(null, state), { - hook: hook.bind(null, state) - }); - } - exports.createOAuthDeviceAuth = createOAuthDeviceAuth; - } -}); - -// -var require_dist_node26 = __commonJS({ - ""(exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - function _interopDefault(ex) { - return ex && typeof ex === "object" && "default" in ex ? ex["default"] : ex; - } - var universalUserAgent = require_dist_node(); - var request = require_dist_node13(); - var authOauthDevice = require_dist_node25(); - var oauthMethods = require_dist_node24(); - var btoa = _interopDefault(require_btoa_node()); - var VERSION = "2.0.3"; - async function getAuthentication(state) { - if ("code" in state.strategyOptions) { - const { - authentication - } = await oauthMethods.exchangeWebFlowCode({ - clientId: state.clientId, - clientSecret: state.clientSecret, - clientType: state.clientType, - ...state.strategyOptions, - request: state.request - }); - return { - type: "token", - tokenType: "oauth", - ...authentication - }; - } - if ("onVerification" in state.strategyOptions) { - const deviceAuth = authOauthDevice.createOAuthDeviceAuth({ - clientType: state.clientType, - clientId: state.clientId, - ...state.strategyOptions, - request: state.request - }); - const authentication = await deviceAuth({ - type: "oauth" - }); - return { - clientSecret: state.clientSecret, - ...authentication - }; - } - if ("token" in state.strategyOptions) { - return { - type: "token", - tokenType: "oauth", - clientId: state.clientId, - clientSecret: state.clientSecret, - clientType: state.clientType, - ...state.strategyOptions - }; - } - throw new Error("[@octokit/auth-oauth-user] Invalid strategy options"); - } - async function auth(state, options = {}) { - if (!state.authentication) { - state.authentication = state.clientType === "oauth-app" ? await getAuthentication(state) : await getAuthentication(state); - } - if (state.authentication.invalid) { - throw new Error("[@octokit/auth-oauth-user] Token is invalid"); - } - const currentAuthentication = state.authentication; - if ("expiresAt" in currentAuthentication) { - if (options.type === "refresh" || new Date(currentAuthentication.expiresAt) < new Date()) { - const { - authentication - } = await oauthMethods.refreshToken({ - clientType: "github-app", - clientId: state.clientId, - clientSecret: state.clientSecret, - refreshToken: currentAuthentication.refreshToken, - request: state.request - }); - state.authentication = { - tokenType: "oauth", - type: "token", - ...authentication - }; - } - } - if (options.type === "refresh") { - if (state.clientType === "oauth-app") { - throw new Error("[@octokit/auth-oauth-user] OAuth Apps do not support expiring tokens"); - } - if (!currentAuthentication.hasOwnProperty("expiresAt")) { - throw new Error("[@octokit/auth-oauth-user] Refresh token missing"); - } - } - if (options.type === "check" || options.type === "reset") { - const method = options.type === "check" ? oauthMethods.checkToken : oauthMethods.resetToken; - try { - const { - authentication - } = await method({ - clientType: state.clientType, - clientId: state.clientId, - clientSecret: state.clientSecret, - token: state.authentication.token, - request: state.request - }); - state.authentication = { - tokenType: "oauth", - type: "token", - ...authentication - }; - return state.authentication; - } catch (error2) { - if (error2.status === 404) { - error2.message = "[@octokit/auth-oauth-user] Token is invalid"; - state.authentication.invalid = true; - } - throw error2; - } - } - if (options.type === "delete" || options.type === "deleteAuthorization") { - const method = options.type === "delete" ? oauthMethods.deleteToken : oauthMethods.deleteAuthorization; - try { - await method({ - clientType: state.clientType, - clientId: state.clientId, - clientSecret: state.clientSecret, - token: state.authentication.token, - request: state.request - }); - } catch (error2) { - if (error2.status !== 404) - throw error2; - } - state.authentication.invalid = true; - return state.authentication; - } - return state.authentication; - } - var ROUTES_REQUIRING_BASIC_AUTH = /\/applications\/[^/]+\/(token|grant)s?/; - function requiresBasicAuth(url) { - return url && ROUTES_REQUIRING_BASIC_AUTH.test(url); - } - async function hook(state, request2, route, parameters = {}) { - const endpoint = request2.endpoint.merge(route, parameters); - if (/\/login\/(oauth\/access_token|device\/code)$/.test(endpoint.url)) { - return request2(endpoint); - } - if (requiresBasicAuth(endpoint.url)) { - const credentials = btoa(`${state.clientId}:${state.clientSecret}`); - endpoint.headers.authorization = `basic ${credentials}`; - return request2(endpoint); - } - const { - token - } = state.clientType === "oauth-app" ? await auth({ - ...state, - request: request2 - }) : await auth({ - ...state, - request: request2 - }); - endpoint.headers.authorization = "token " + token; - return request2(endpoint); - } - function createOAuthUserAuth({ - clientId, - clientSecret, - clientType = "oauth-app", - request: request$1 = request.request.defaults({ - headers: { - "user-agent": `octokit-auth-oauth-app.js/${VERSION} ${universalUserAgent.getUserAgent()}` - } - }), - ...strategyOptions - }) { - const state = Object.assign({ - clientType, - clientId, - clientSecret, - strategyOptions, - request: request$1 - }); - return Object.assign(auth.bind(null, state), { - hook: hook.bind(null, state) - }); - } - createOAuthUserAuth.VERSION = VERSION; - exports.createOAuthUserAuth = createOAuthUserAuth; - exports.requiresBasicAuth = requiresBasicAuth; - } -}); - -// -var require_dist_node27 = __commonJS({ - ""(exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - function _interopDefault(ex) { - return ex && typeof ex === "object" && "default" in ex ? ex["default"] : ex; - } - var universalUserAgent = require_dist_node(); - var request = require_dist_node22(); - var btoa = _interopDefault(require_btoa_node()); - var authOauthUser = require_dist_node26(); - async function auth(state, authOptions) { - if (authOptions.type === "oauth-app") { - return { - type: "oauth-app", - clientId: state.clientId, - clientSecret: state.clientSecret, - clientType: state.clientType, - headers: { - authorization: `basic ${btoa(`${state.clientId}:${state.clientSecret}`)}` - } - }; - } - if ("factory" in authOptions) { - const { - type, - ...options - } = { - ...authOptions, - ...state - }; - return authOptions.factory(options); - } - const common = { - clientId: state.clientId, - clientSecret: state.clientSecret, - request: state.request, - ...authOptions - }; - const userAuth = state.clientType === "oauth-app" ? await authOauthUser.createOAuthUserAuth({ - ...common, - clientType: state.clientType - }) : await authOauthUser.createOAuthUserAuth({ - ...common, - clientType: state.clientType - }); - return userAuth(); - } - async function hook(state, request2, route, parameters) { - let endpoint = request2.endpoint.merge(route, parameters); - if (/\/login\/(oauth\/access_token|device\/code)$/.test(endpoint.url)) { - return request2(endpoint); - } - if (state.clientType === "github-app" && !authOauthUser.requiresBasicAuth(endpoint.url)) { - throw new Error(`[@octokit/auth-oauth-app] GitHub Apps cannot use their client ID/secret for basic authentication for endpoints other than "/applications/{client_id}/**". "${endpoint.method} ${endpoint.url}" is not supported.`); - } - const credentials = btoa(`${state.clientId}:${state.clientSecret}`); - endpoint.headers.authorization = `basic ${credentials}`; - try { - return await request2(endpoint); - } catch (error2) { - if (error2.status !== 401) - throw error2; - error2.message = `[@octokit/auth-oauth-app] "${endpoint.method} ${endpoint.url}" does not support clientId/clientSecret basic authentication.`; - throw error2; - } - } - var VERSION = "5.0.2"; - function createOAuthAppAuth(options) { - const state = Object.assign({ - request: request.request.defaults({ - headers: { - "user-agent": `octokit-auth-oauth-app.js/${VERSION} ${universalUserAgent.getUserAgent()}` - } - }), - clientType: "oauth-app" - }, options); - return Object.assign(auth.bind(null, state), { - hook: hook.bind(null, state) - }); - } - Object.defineProperty(exports, "createOAuthUserAuth", { - enumerable: true, - get: function() { - return authOauthUser.createOAuthUserAuth; - } - }); - exports.createOAuthAppAuth = createOAuthAppAuth; - } -}); - -// -var require_safe_buffer = __commonJS({ - ""(exports, module) { - var buffer = __require("buffer"); - var Buffer2 = buffer.Buffer; - function copyProps(src, dst) { - for (var key in src) { - dst[key] = src[key]; - } - } - if (Buffer2.from && Buffer2.alloc && Buffer2.allocUnsafe && Buffer2.allocUnsafeSlow) { - module.exports = buffer; - } else { - copyProps(buffer, exports); - exports.Buffer = SafeBuffer; - } - function SafeBuffer(arg, encodingOrOffset, length) { - return Buffer2(arg, encodingOrOffset, length); - } - SafeBuffer.prototype = Object.create(Buffer2.prototype); - copyProps(Buffer2, SafeBuffer); - SafeBuffer.from = function(arg, encodingOrOffset, length) { - if (typeof arg === "number") { - throw new TypeError("Argument must not be a number"); - } - return Buffer2(arg, encodingOrOffset, length); - }; - SafeBuffer.alloc = function(size, fill, encoding) { - if (typeof size !== "number") { - throw new TypeError("Argument must be a number"); - } - var buf = Buffer2(size); - if (fill !== void 0) { - if (typeof encoding === "string") { - buf.fill(fill, encoding); - } else { - buf.fill(fill); - } - } else { - buf.fill(0); - } - return buf; - }; - SafeBuffer.allocUnsafe = function(size) { - if (typeof size !== "number") { - throw new TypeError("Argument must be a number"); - } - return Buffer2(size); - }; - SafeBuffer.allocUnsafeSlow = function(size) { - if (typeof size !== "number") { - throw new TypeError("Argument must be a number"); - } - return buffer.SlowBuffer(size); - }; - } -}); - -// -var require_data_stream = __commonJS({ - ""(exports, module) { - var Buffer2 = require_safe_buffer().Buffer; - var Stream = __require("stream"); - var util = __require("util"); - function DataStream(data) { - this.buffer = null; - this.writable = true; - this.readable = true; - if (!data) { - this.buffer = Buffer2.alloc(0); - return this; - } - if (typeof data.pipe === "function") { - this.buffer = Buffer2.alloc(0); - data.pipe(this); - return this; - } - if (data.length || typeof data === "object") { - this.buffer = data; - this.writable = false; - process.nextTick(function() { - this.emit("end", data); - this.readable = false; - this.emit("close"); - }.bind(this)); - return this; - } - throw new TypeError("Unexpected data type (" + typeof data + ")"); - } - util.inherits(DataStream, Stream); - DataStream.prototype.write = function write(data) { - this.buffer = Buffer2.concat([this.buffer, Buffer2.from(data)]); - this.emit("data", data); - }; - DataStream.prototype.end = function end(data) { - if (data) - this.write(data); - this.emit("end", data); - this.emit("close"); - this.writable = false; - this.readable = false; - }; - module.exports = DataStream; - } -}); - -// -var require_buffer_equal_constant_time = __commonJS({ - ""(exports, module) { - "use strict"; - var Buffer2 = __require("buffer").Buffer; - var SlowBuffer = __require("buffer").SlowBuffer; - module.exports = bufferEq; - function bufferEq(a, b) { - if (!Buffer2.isBuffer(a) || !Buffer2.isBuffer(b)) { - return false; - } - if (a.length !== b.length) { - return false; - } - var c = 0; - for (var i = 0; i < a.length; i++) { - c |= a[i] ^ b[i]; - } - return c === 0; - } - bufferEq.install = function() { - Buffer2.prototype.equal = SlowBuffer.prototype.equal = function equal(that) { - return bufferEq(this, that); - }; - }; - var origBufEqual = Buffer2.prototype.equal; - var origSlowBufEqual = SlowBuffer.prototype.equal; - bufferEq.restore = function() { - Buffer2.prototype.equal = origBufEqual; - SlowBuffer.prototype.equal = origSlowBufEqual; - }; - } -}); - -// -var require_param_bytes_for_alg = __commonJS({ - ""(exports, module) { - "use strict"; - function getParamSize(keySize) { - var result = (keySize / 8 | 0) + (keySize % 8 === 0 ? 0 : 1); - return result; - } - var paramBytesForAlg = { - ES256: getParamSize(256), - ES384: getParamSize(384), - ES512: getParamSize(521) - }; - function getParamBytesForAlg(alg) { - var paramBytes = paramBytesForAlg[alg]; - if (paramBytes) { - return paramBytes; - } - throw new Error('Unknown algorithm "' + alg + '"'); - } - module.exports = getParamBytesForAlg; - } -}); - -// -var require_ecdsa_sig_formatter = __commonJS({ - ""(exports, module) { - "use strict"; - var Buffer2 = require_safe_buffer().Buffer; - var getParamBytesForAlg = require_param_bytes_for_alg(); - var MAX_OCTET = 128; - var CLASS_UNIVERSAL = 0; - var PRIMITIVE_BIT = 32; - var TAG_SEQ = 16; - var TAG_INT = 2; - var ENCODED_TAG_SEQ = TAG_SEQ | PRIMITIVE_BIT | CLASS_UNIVERSAL << 6; - var ENCODED_TAG_INT = TAG_INT | CLASS_UNIVERSAL << 6; - function base64Url(base64) { - return base64.replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_"); - } - function signatureAsBuffer(signature) { - if (Buffer2.isBuffer(signature)) { - return signature; - } else if ("string" === typeof signature) { - return Buffer2.from(signature, "base64"); - } - throw new TypeError("ECDSA signature must be a Base64 string or a Buffer"); - } - function derToJose(signature, alg) { - signature = signatureAsBuffer(signature); - var paramBytes = getParamBytesForAlg(alg); - var maxEncodedParamLength = paramBytes + 1; - var inputLength = signature.length; - var offset = 0; - if (signature[offset++] !== ENCODED_TAG_SEQ) { - throw new Error('Could not find expected "seq"'); - } - var seqLength = signature[offset++]; - if (seqLength === (MAX_OCTET | 1)) { - seqLength = signature[offset++]; - } - if (inputLength - offset < seqLength) { - throw new Error('"seq" specified length of "' + seqLength + '", only "' + (inputLength - offset) + '" remaining'); - } - if (signature[offset++] !== ENCODED_TAG_INT) { - throw new Error('Could not find expected "int" for "r"'); - } - var rLength = signature[offset++]; - if (inputLength - offset - 2 < rLength) { - throw new Error('"r" specified length of "' + rLength + '", only "' + (inputLength - offset - 2) + '" available'); - } - if (maxEncodedParamLength < rLength) { - throw new Error('"r" specified length of "' + rLength + '", max of "' + maxEncodedParamLength + '" is acceptable'); - } - var rOffset = offset; - offset += rLength; - if (signature[offset++] !== ENCODED_TAG_INT) { - throw new Error('Could not find expected "int" for "s"'); - } - var sLength = signature[offset++]; - if (inputLength - offset !== sLength) { - throw new Error('"s" specified length of "' + sLength + '", expected "' + (inputLength - offset) + '"'); - } - if (maxEncodedParamLength < sLength) { - throw new Error('"s" specified length of "' + sLength + '", max of "' + maxEncodedParamLength + '" is acceptable'); - } - var sOffset = offset; - offset += sLength; - if (offset !== inputLength) { - throw new Error('Expected to consume entire buffer, but "' + (inputLength - offset) + '" bytes remain'); - } - var rPadding = paramBytes - rLength, sPadding = paramBytes - sLength; - var dst = Buffer2.allocUnsafe(rPadding + rLength + sPadding + sLength); - for (offset = 0; offset < rPadding; ++offset) { - dst[offset] = 0; - } - signature.copy(dst, offset, rOffset + Math.max(-rPadding, 0), rOffset + rLength); - offset = paramBytes; - for (var o = offset; offset < o + sPadding; ++offset) { - dst[offset] = 0; - } - signature.copy(dst, offset, sOffset + Math.max(-sPadding, 0), sOffset + sLength); - dst = dst.toString("base64"); - dst = base64Url(dst); - return dst; - } - function countPadding(buf, start, stop) { - var padding = 0; - while (start + padding < stop && buf[start + padding] === 0) { - ++padding; - } - var needsSign = buf[start + padding] >= MAX_OCTET; - if (needsSign) { - --padding; - } - return padding; - } - function joseToDer(signature, alg) { - signature = signatureAsBuffer(signature); - var paramBytes = getParamBytesForAlg(alg); - var signatureBytes = signature.length; - if (signatureBytes !== paramBytes * 2) { - throw new TypeError('"' + alg + '" signatures must be "' + paramBytes * 2 + '" bytes, saw "' + signatureBytes + '"'); - } - var rPadding = countPadding(signature, 0, paramBytes); - var sPadding = countPadding(signature, paramBytes, signature.length); - var rLength = paramBytes - rPadding; - var sLength = paramBytes - sPadding; - var rsBytes = 1 + 1 + rLength + 1 + 1 + sLength; - var shortLength = rsBytes < MAX_OCTET; - var dst = Buffer2.allocUnsafe((shortLength ? 2 : 3) + rsBytes); - var offset = 0; - dst[offset++] = ENCODED_TAG_SEQ; - if (shortLength) { - dst[offset++] = rsBytes; - } else { - dst[offset++] = MAX_OCTET | 1; - dst[offset++] = rsBytes & 255; - } - dst[offset++] = ENCODED_TAG_INT; - dst[offset++] = rLength; - if (rPadding < 0) { - dst[offset++] = 0; - offset += signature.copy(dst, offset, 0, paramBytes); - } else { - offset += signature.copy(dst, offset, rPadding, paramBytes); - } - dst[offset++] = ENCODED_TAG_INT; - dst[offset++] = sLength; - if (sPadding < 0) { - dst[offset++] = 0; - signature.copy(dst, offset, paramBytes); - } else { - signature.copy(dst, offset, paramBytes + sPadding); - } - return dst; - } - module.exports = { - derToJose, - joseToDer - }; - } -}); - -// -var require_jwa = __commonJS({ - ""(exports, module) { - var bufferEqual = require_buffer_equal_constant_time(); - var Buffer2 = require_safe_buffer().Buffer; - var crypto = __require("crypto"); - var formatEcdsa = require_ecdsa_sig_formatter(); - var util = __require("util"); - var MSG_INVALID_ALGORITHM = '"%s" is not a valid algorithm.\n Supported algorithms are:\n "HS256", "HS384", "HS512", "RS256", "RS384", "RS512", "PS256", "PS384", "PS512", "ES256", "ES384", "ES512" and "none".'; - var MSG_INVALID_SECRET = "secret must be a string or buffer"; - var MSG_INVALID_VERIFIER_KEY = "key must be a string or a buffer"; - var MSG_INVALID_SIGNER_KEY = "key must be a string, a buffer or an object"; - var supportsKeyObjects = typeof crypto.createPublicKey === "function"; - if (supportsKeyObjects) { - MSG_INVALID_VERIFIER_KEY += " or a KeyObject"; - MSG_INVALID_SECRET += "or a KeyObject"; - } - function checkIsPublicKey(key) { - if (Buffer2.isBuffer(key)) { - return; - } - if (typeof key === "string") { - return; - } - if (!supportsKeyObjects) { - throw typeError(MSG_INVALID_VERIFIER_KEY); - } - if (typeof key !== "object") { - throw typeError(MSG_INVALID_VERIFIER_KEY); - } - if (typeof key.type !== "string") { - throw typeError(MSG_INVALID_VERIFIER_KEY); - } - if (typeof key.asymmetricKeyType !== "string") { - throw typeError(MSG_INVALID_VERIFIER_KEY); - } - if (typeof key.export !== "function") { - throw typeError(MSG_INVALID_VERIFIER_KEY); - } - } - function checkIsPrivateKey(key) { - if (Buffer2.isBuffer(key)) { - return; - } - if (typeof key === "string") { - return; - } - if (typeof key === "object") { - return; - } - throw typeError(MSG_INVALID_SIGNER_KEY); - } - function checkIsSecretKey(key) { - if (Buffer2.isBuffer(key)) { - return; - } - if (typeof key === "string") { - return key; - } - if (!supportsKeyObjects) { - throw typeError(MSG_INVALID_SECRET); - } - if (typeof key !== "object") { - throw typeError(MSG_INVALID_SECRET); - } - if (key.type !== "secret") { - throw typeError(MSG_INVALID_SECRET); - } - if (typeof key.export !== "function") { - throw typeError(MSG_INVALID_SECRET); - } - } - function fromBase64(base64) { - return base64.replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_"); - } - function toBase64(base64url) { - base64url = base64url.toString(); - var padding = 4 - base64url.length % 4; - if (padding !== 4) { - for (var i = 0; i < padding; ++i) { - base64url += "="; - } - } - return base64url.replace(/\-/g, "+").replace(/_/g, "/"); - } - function typeError(template) { - var args = [].slice.call(arguments, 1); - var errMsg = util.format.bind(util, template).apply(null, args); - return new TypeError(errMsg); - } - function bufferOrString(obj) { - return Buffer2.isBuffer(obj) || typeof obj === "string"; - } - function normalizeInput(thing) { - if (!bufferOrString(thing)) - thing = JSON.stringify(thing); - return thing; - } - function createHmacSigner(bits) { - return function sign(thing, secret) { - checkIsSecretKey(secret); - thing = normalizeInput(thing); - var hmac = crypto.createHmac("sha" + bits, secret); - var sig = (hmac.update(thing), hmac.digest("base64")); - return fromBase64(sig); - }; - } - function createHmacVerifier(bits) { - return function verify(thing, signature, secret) { - var computedSig = createHmacSigner(bits)(thing, secret); - return bufferEqual(Buffer2.from(signature), Buffer2.from(computedSig)); - }; - } - function createKeySigner(bits) { - return function sign(thing, privateKey) { - checkIsPrivateKey(privateKey); - thing = normalizeInput(thing); - var signer = crypto.createSign("RSA-SHA" + bits); - var sig = (signer.update(thing), signer.sign(privateKey, "base64")); - return fromBase64(sig); - }; - } - function createKeyVerifier(bits) { - return function verify(thing, signature, publicKey) { - checkIsPublicKey(publicKey); - thing = normalizeInput(thing); - signature = toBase64(signature); - var verifier = crypto.createVerify("RSA-SHA" + bits); - verifier.update(thing); - return verifier.verify(publicKey, signature, "base64"); - }; - } - function createPSSKeySigner(bits) { - return function sign(thing, privateKey) { - checkIsPrivateKey(privateKey); - thing = normalizeInput(thing); - var signer = crypto.createSign("RSA-SHA" + bits); - var sig = (signer.update(thing), signer.sign({ - key: privateKey, - padding: crypto.constants.RSA_PKCS1_PSS_PADDING, - saltLength: crypto.constants.RSA_PSS_SALTLEN_DIGEST - }, "base64")); - return fromBase64(sig); - }; - } - function createPSSKeyVerifier(bits) { - return function verify(thing, signature, publicKey) { - checkIsPublicKey(publicKey); - thing = normalizeInput(thing); - signature = toBase64(signature); - var verifier = crypto.createVerify("RSA-SHA" + bits); - verifier.update(thing); - return verifier.verify({ - key: publicKey, - padding: crypto.constants.RSA_PKCS1_PSS_PADDING, - saltLength: crypto.constants.RSA_PSS_SALTLEN_DIGEST - }, signature, "base64"); - }; - } - function createECDSASigner(bits) { - var inner = createKeySigner(bits); - return function sign() { - var signature = inner.apply(null, arguments); - signature = formatEcdsa.derToJose(signature, "ES" + bits); - return signature; - }; - } - function createECDSAVerifer(bits) { - var inner = createKeyVerifier(bits); - return function verify(thing, signature, publicKey) { - signature = formatEcdsa.joseToDer(signature, "ES" + bits).toString("base64"); - var result = inner(thing, signature, publicKey); - return result; - }; - } - function createNoneSigner() { - return function sign() { - return ""; - }; - } - function createNoneVerifier() { - return function verify(thing, signature) { - return signature === ""; - }; - } - module.exports = function jwa(algorithm) { - var signerFactories = { - hs: createHmacSigner, - rs: createKeySigner, - ps: createPSSKeySigner, - es: createECDSASigner, - none: createNoneSigner - }; - var verifierFactories = { - hs: createHmacVerifier, - rs: createKeyVerifier, - ps: createPSSKeyVerifier, - es: createECDSAVerifer, - none: createNoneVerifier - }; - var match = algorithm.match(/^(RS|PS|ES|HS)(256|384|512)$|^(none)$/i); - if (!match) - throw typeError(MSG_INVALID_ALGORITHM, algorithm); - var algo = (match[1] || match[3]).toLowerCase(); - var bits = match[2]; - return { - sign: signerFactories[algo](bits), - verify: verifierFactories[algo](bits) - }; - }; - } -}); - -// -var require_tostring = __commonJS({ - ""(exports, module) { - var Buffer2 = __require("buffer").Buffer; - module.exports = function toString(obj) { - if (typeof obj === "string") - return obj; - if (typeof obj === "number" || Buffer2.isBuffer(obj)) - return obj.toString(); - return JSON.stringify(obj); - }; - } -}); - -// -var require_sign_stream = __commonJS({ - ""(exports, module) { - var Buffer2 = require_safe_buffer().Buffer; - var DataStream = require_data_stream(); - var jwa = require_jwa(); - var Stream = __require("stream"); - var toString = require_tostring(); - var util = __require("util"); - function base64url(string, encoding) { - return Buffer2.from(string, encoding).toString("base64").replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_"); - } - function jwsSecuredInput(header, payload, encoding) { - encoding = encoding || "utf8"; - var encodedHeader = base64url(toString(header), "binary"); - var encodedPayload = base64url(toString(payload), encoding); - return util.format("%s.%s", encodedHeader, encodedPayload); - } - function jwsSign(opts) { - var header = opts.header; - var payload = opts.payload; - var secretOrKey = opts.secret || opts.privateKey; - var encoding = opts.encoding; - var algo = jwa(header.alg); - var securedInput = jwsSecuredInput(header, payload, encoding); - var signature = algo.sign(securedInput, secretOrKey); - return util.format("%s.%s", securedInput, signature); - } - function SignStream(opts) { - var secret = opts.secret || opts.privateKey || opts.key; - var secretStream = new DataStream(secret); - this.readable = true; - this.header = opts.header; - this.encoding = opts.encoding; - this.secret = this.privateKey = this.key = secretStream; - this.payload = new DataStream(opts.payload); - this.secret.once("close", function() { - if (!this.payload.writable && this.readable) - this.sign(); - }.bind(this)); - this.payload.once("close", function() { - if (!this.secret.writable && this.readable) - this.sign(); - }.bind(this)); - } - util.inherits(SignStream, Stream); - SignStream.prototype.sign = function sign() { - try { - var signature = jwsSign({ - header: this.header, - payload: this.payload.buffer, - secret: this.secret.buffer, - encoding: this.encoding - }); - this.emit("done", signature); - this.emit("data", signature); - this.emit("end"); - this.readable = false; - return signature; - } catch (e) { - this.readable = false; - this.emit("error", e); - this.emit("close"); - } - }; - SignStream.sign = jwsSign; - module.exports = SignStream; - } -}); - -// -var require_verify_stream = __commonJS({ - ""(exports, module) { - var Buffer2 = require_safe_buffer().Buffer; - var DataStream = require_data_stream(); - var jwa = require_jwa(); - var Stream = __require("stream"); - var toString = require_tostring(); - var util = __require("util"); - var JWS_REGEX = /^[a-zA-Z0-9\-_]+?\.[a-zA-Z0-9\-_]+?\.([a-zA-Z0-9\-_]+)?$/; - function isObject(thing) { - return Object.prototype.toString.call(thing) === "[object Object]"; - } - function safeJsonParse(thing) { - if (isObject(thing)) - return thing; - try { - return JSON.parse(thing); - } catch (e) { - return void 0; - } - } - function headerFromJWS(jwsSig) { - var encodedHeader = jwsSig.split(".", 1)[0]; - return safeJsonParse(Buffer2.from(encodedHeader, "base64").toString("binary")); - } - function securedInputFromJWS(jwsSig) { - return jwsSig.split(".", 2).join("."); - } - function signatureFromJWS(jwsSig) { - return jwsSig.split(".")[2]; - } - function payloadFromJWS(jwsSig, encoding) { - encoding = encoding || "utf8"; - var payload = jwsSig.split(".")[1]; - return Buffer2.from(payload, "base64").toString(encoding); - } - function isValidJws(string) { - return JWS_REGEX.test(string) && !!headerFromJWS(string); - } - function jwsVerify(jwsSig, algorithm, secretOrKey) { - if (!algorithm) { - var err = new Error("Missing algorithm parameter for jws.verify"); - err.code = "MISSING_ALGORITHM"; - throw err; - } - jwsSig = toString(jwsSig); - var signature = signatureFromJWS(jwsSig); - var securedInput = securedInputFromJWS(jwsSig); - var algo = jwa(algorithm); - return algo.verify(securedInput, signature, secretOrKey); - } - function jwsDecode(jwsSig, opts) { - opts = opts || {}; - jwsSig = toString(jwsSig); - if (!isValidJws(jwsSig)) - return null; - var header = headerFromJWS(jwsSig); - if (!header) - return null; - var payload = payloadFromJWS(jwsSig); - if (header.typ === "JWT" || opts.json) - payload = JSON.parse(payload, opts.encoding); - return { - header, - payload, - signature: signatureFromJWS(jwsSig) - }; - } - function VerifyStream(opts) { - opts = opts || {}; - var secretOrKey = opts.secret || opts.publicKey || opts.key; - var secretStream = new DataStream(secretOrKey); - this.readable = true; - this.algorithm = opts.algorithm; - this.encoding = opts.encoding; - this.secret = this.publicKey = this.key = secretStream; - this.signature = new DataStream(opts.signature); - this.secret.once("close", function() { - if (!this.signature.writable && this.readable) - this.verify(); - }.bind(this)); - this.signature.once("close", function() { - if (!this.secret.writable && this.readable) - this.verify(); - }.bind(this)); - } - util.inherits(VerifyStream, Stream); - VerifyStream.prototype.verify = function verify() { - try { - var valid = jwsVerify(this.signature.buffer, this.algorithm, this.key.buffer); - var obj = jwsDecode(this.signature.buffer, this.encoding); - this.emit("done", valid, obj); - this.emit("data", valid); - this.emit("end"); - this.readable = false; - return valid; - } catch (e) { - this.readable = false; - this.emit("error", e); - this.emit("close"); - } - }; - VerifyStream.decode = jwsDecode; - VerifyStream.isValid = isValidJws; - VerifyStream.verify = jwsVerify; - module.exports = VerifyStream; - } -}); - -// -var require_jws = __commonJS({ - ""(exports) { - var SignStream = require_sign_stream(); - var VerifyStream = require_verify_stream(); - var ALGORITHMS = [ - "HS256", - "HS384", - "HS512", - "RS256", - "RS384", - "RS512", - "PS256", - "PS384", - "PS512", - "ES256", - "ES384", - "ES512" - ]; - exports.ALGORITHMS = ALGORITHMS; - exports.sign = SignStream.sign; - exports.verify = VerifyStream.verify; - exports.decode = VerifyStream.decode; - exports.isValid = VerifyStream.isValid; - exports.createSign = function createSign(opts) { - return new SignStream(opts); - }; - exports.createVerify = function createVerify(opts) { - return new VerifyStream(opts); - }; - } -}); - -// -var require_decode = __commonJS({ - ""(exports, module) { - var jws = require_jws(); - module.exports = function(jwt, options) { - options = options || {}; - var decoded = jws.decode(jwt, options); - if (!decoded) { - return null; - } - var payload = decoded.payload; - if (typeof payload === "string") { - try { - var obj = JSON.parse(payload); - if (obj !== null && typeof obj === "object") { - payload = obj; - } - } catch (e) { - } - } - if (options.complete === true) { - return { - header: decoded.header, - payload, - signature: decoded.signature - }; - } - return payload; - }; - } -}); - -// -var require_JsonWebTokenError = __commonJS({ - ""(exports, module) { - var JsonWebTokenError = function(message, error2) { - Error.call(this, message); - if (Error.captureStackTrace) { - Error.captureStackTrace(this, this.constructor); - } - this.name = "JsonWebTokenError"; - this.message = message; - if (error2) - this.inner = error2; - }; - JsonWebTokenError.prototype = Object.create(Error.prototype); - JsonWebTokenError.prototype.constructor = JsonWebTokenError; - module.exports = JsonWebTokenError; - } -}); - -// -var require_NotBeforeError = __commonJS({ - ""(exports, module) { - var JsonWebTokenError = require_JsonWebTokenError(); - var NotBeforeError = function(message, date) { - JsonWebTokenError.call(this, message); - this.name = "NotBeforeError"; - this.date = date; - }; - NotBeforeError.prototype = Object.create(JsonWebTokenError.prototype); - NotBeforeError.prototype.constructor = NotBeforeError; - module.exports = NotBeforeError; - } -}); - -// -var require_TokenExpiredError = __commonJS({ - ""(exports, module) { - var JsonWebTokenError = require_JsonWebTokenError(); - var TokenExpiredError = function(message, expiredAt) { - JsonWebTokenError.call(this, message); - this.name = "TokenExpiredError"; - this.expiredAt = expiredAt; - }; - TokenExpiredError.prototype = Object.create(JsonWebTokenError.prototype); - TokenExpiredError.prototype.constructor = TokenExpiredError; - module.exports = TokenExpiredError; - } -}); - -// -var require_ms = __commonJS({ - ""(exports, module) { - var s = 1e3; - var m = s * 60; - var h = m * 60; - var d = h * 24; - var w = d * 7; - var y = d * 365.25; - module.exports = function(val, options) { - options = options || {}; - var type = typeof val; - if (type === "string" && val.length > 0) { - return parse(val); - } else if (type === "number" && isFinite(val)) { - return options.long ? fmtLong(val) : fmtShort(val); - } - throw new Error( - "val is not a non-empty string or a valid number. val=" + JSON.stringify(val) - ); - }; - function parse(str) { - str = String(str); - if (str.length > 100) { - return; - } - var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec( - str - ); - if (!match) { - return; - } - var n = parseFloat(match[1]); - var type = (match[2] || "ms").toLowerCase(); - switch (type) { - case "years": - case "year": - case "yrs": - case "yr": - case "y": - return n * y; - case "weeks": - case "week": - case "w": - return n * w; - case "days": - case "day": - case "d": - return n * d; - case "hours": - case "hour": - case "hrs": - case "hr": - case "h": - return n * h; - case "minutes": - case "minute": - case "mins": - case "min": - case "m": - return n * m; - case "seconds": - case "second": - case "secs": - case "sec": - case "s": - return n * s; - case "milliseconds": - case "millisecond": - case "msecs": - case "msec": - case "ms": - return n; - default: - return void 0; - } - } - function fmtShort(ms) { - var msAbs = Math.abs(ms); - if (msAbs >= d) { - return Math.round(ms / d) + "d"; - } - if (msAbs >= h) { - return Math.round(ms / h) + "h"; - } - if (msAbs >= m) { - return Math.round(ms / m) + "m"; - } - if (msAbs >= s) { - return Math.round(ms / s) + "s"; - } - return ms + "ms"; - } - function fmtLong(ms) { - var msAbs = Math.abs(ms); - if (msAbs >= d) { - return plural(ms, msAbs, d, "day"); - } - if (msAbs >= h) { - return plural(ms, msAbs, h, "hour"); - } - if (msAbs >= m) { - return plural(ms, msAbs, m, "minute"); - } - if (msAbs >= s) { - return plural(ms, msAbs, s, "second"); - } - return ms + " ms"; - } - function plural(ms, msAbs, n, name) { - var isPlural = msAbs >= n * 1.5; - return Math.round(ms / n) + " " + name + (isPlural ? "s" : ""); - } - } -}); - -// -var require_timespan = __commonJS({ - ""(exports, module) { - var ms = require_ms(); - module.exports = function(time, iat) { - var timestamp = iat || Math.floor(Date.now() / 1e3); - if (typeof time === "string") { - var milliseconds = ms(time); - if (typeof milliseconds === "undefined") { - return; - } - return Math.floor(timestamp + milliseconds / 1e3); - } else if (typeof time === "number") { - return timestamp + time; - } else { - return; - } - }; - } -}); - -// -var require_semver = __commonJS({ - ""(exports, module) { - exports = module.exports = SemVer; - var debug; - if (typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG)) { - debug = function() { - var args = Array.prototype.slice.call(arguments, 0); - args.unshift("SEMVER"); - console.log.apply(console, args); - }; - } else { - debug = function() { - }; - } - exports.SEMVER_SPEC_VERSION = "2.0.0"; - var MAX_LENGTH = 256; - var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991; - var MAX_SAFE_COMPONENT_LENGTH = 16; - var re = exports.re = []; - var src = exports.src = []; - var R = 0; - var NUMERICIDENTIFIER = R++; - src[NUMERICIDENTIFIER] = "0|[1-9]\\d*"; - var NUMERICIDENTIFIERLOOSE = R++; - src[NUMERICIDENTIFIERLOOSE] = "[0-9]+"; - var NONNUMERICIDENTIFIER = R++; - src[NONNUMERICIDENTIFIER] = "\\d*[a-zA-Z-][a-zA-Z0-9-]*"; - var MAINVERSION = R++; - src[MAINVERSION] = "(" + src[NUMERICIDENTIFIER] + ")\\.(" + src[NUMERICIDENTIFIER] + ")\\.(" + src[NUMERICIDENTIFIER] + ")"; - var MAINVERSIONLOOSE = R++; - src[MAINVERSIONLOOSE] = "(" + src[NUMERICIDENTIFIERLOOSE] + ")\\.(" + src[NUMERICIDENTIFIERLOOSE] + ")\\.(" + src[NUMERICIDENTIFIERLOOSE] + ")"; - var PRERELEASEIDENTIFIER = R++; - src[PRERELEASEIDENTIFIER] = "(?:" + src[NUMERICIDENTIFIER] + "|" + src[NONNUMERICIDENTIFIER] + ")"; - var PRERELEASEIDENTIFIERLOOSE = R++; - src[PRERELEASEIDENTIFIERLOOSE] = "(?:" + src[NUMERICIDENTIFIERLOOSE] + "|" + src[NONNUMERICIDENTIFIER] + ")"; - var PRERELEASE = R++; - src[PRERELEASE] = "(?:-(" + src[PRERELEASEIDENTIFIER] + "(?:\\." + src[PRERELEASEIDENTIFIER] + ")*))"; - var PRERELEASELOOSE = R++; - src[PRERELEASELOOSE] = "(?:-?(" + src[PRERELEASEIDENTIFIERLOOSE] + "(?:\\." + src[PRERELEASEIDENTIFIERLOOSE] + ")*))"; - var BUILDIDENTIFIER = R++; - src[BUILDIDENTIFIER] = "[0-9A-Za-z-]+"; - var BUILD = R++; - src[BUILD] = "(?:\\+(" + src[BUILDIDENTIFIER] + "(?:\\." + src[BUILDIDENTIFIER] + ")*))"; - var FULL = R++; - var FULLPLAIN = "v?" + src[MAINVERSION] + src[PRERELEASE] + "?" + src[BUILD] + "?"; - src[FULL] = "^" + FULLPLAIN + "$"; - var LOOSEPLAIN = "[v=\\s]*" + src[MAINVERSIONLOOSE] + src[PRERELEASELOOSE] + "?" + src[BUILD] + "?"; - var LOOSE = R++; - src[LOOSE] = "^" + LOOSEPLAIN + "$"; - var GTLT = R++; - src[GTLT] = "((?:<|>)?=?)"; - var XRANGEIDENTIFIERLOOSE = R++; - src[XRANGEIDENTIFIERLOOSE] = src[NUMERICIDENTIFIERLOOSE] + "|x|X|\\*"; - var XRANGEIDENTIFIER = R++; - src[XRANGEIDENTIFIER] = src[NUMERICIDENTIFIER] + "|x|X|\\*"; - var XRANGEPLAIN = R++; - src[XRANGEPLAIN] = "[v=\\s]*(" + src[XRANGEIDENTIFIER] + ")(?:\\.(" + src[XRANGEIDENTIFIER] + ")(?:\\.(" + src[XRANGEIDENTIFIER] + ")(?:" + src[PRERELEASE] + ")?" + src[BUILD] + "?)?)?"; - var XRANGEPLAINLOOSE = R++; - src[XRANGEPLAINLOOSE] = "[v=\\s]*(" + src[XRANGEIDENTIFIERLOOSE] + ")(?:\\.(" + src[XRANGEIDENTIFIERLOOSE] + ")(?:\\.(" + src[XRANGEIDENTIFIERLOOSE] + ")(?:" + src[PRERELEASELOOSE] + ")?" + src[BUILD] + "?)?)?"; - var XRANGE = R++; - src[XRANGE] = "^" + src[GTLT] + "\\s*" + src[XRANGEPLAIN] + "$"; - var XRANGELOOSE = R++; - src[XRANGELOOSE] = "^" + src[GTLT] + "\\s*" + src[XRANGEPLAINLOOSE] + "$"; - var COERCE = R++; - src[COERCE] = "(?:^|[^\\d])(\\d{1," + MAX_SAFE_COMPONENT_LENGTH + "})(?:\\.(\\d{1," + MAX_SAFE_COMPONENT_LENGTH + "}))?(?:\\.(\\d{1," + MAX_SAFE_COMPONENT_LENGTH + "}))?(?:$|[^\\d])"; - var LONETILDE = R++; - src[LONETILDE] = "(?:~>?)"; - var TILDETRIM = R++; - src[TILDETRIM] = "(\\s*)" + src[LONETILDE] + "\\s+"; - re[TILDETRIM] = new RegExp(src[TILDETRIM], "g"); - var tildeTrimReplace = "$1~"; - var TILDE = R++; - src[TILDE] = "^" + src[LONETILDE] + src[XRANGEPLAIN] + "$"; - var TILDELOOSE = R++; - src[TILDELOOSE] = "^" + src[LONETILDE] + src[XRANGEPLAINLOOSE] + "$"; - var LONECARET = R++; - src[LONECARET] = "(?:\\^)"; - var CARETTRIM = R++; - src[CARETTRIM] = "(\\s*)" + src[LONECARET] + "\\s+"; - re[CARETTRIM] = new RegExp(src[CARETTRIM], "g"); - var caretTrimReplace = "$1^"; - var CARET = R++; - src[CARET] = "^" + src[LONECARET] + src[XRANGEPLAIN] + "$"; - var CARETLOOSE = R++; - src[CARETLOOSE] = "^" + src[LONECARET] + src[XRANGEPLAINLOOSE] + "$"; - var COMPARATORLOOSE = R++; - src[COMPARATORLOOSE] = "^" + src[GTLT] + "\\s*(" + LOOSEPLAIN + ")$|^$"; - var COMPARATOR = R++; - src[COMPARATOR] = "^" + src[GTLT] + "\\s*(" + FULLPLAIN + ")$|^$"; - var COMPARATORTRIM = R++; - src[COMPARATORTRIM] = "(\\s*)" + src[GTLT] + "\\s*(" + LOOSEPLAIN + "|" + src[XRANGEPLAIN] + ")"; - re[COMPARATORTRIM] = new RegExp(src[COMPARATORTRIM], "g"); - var comparatorTrimReplace = "$1$2$3"; - var HYPHENRANGE = R++; - src[HYPHENRANGE] = "^\\s*(" + src[XRANGEPLAIN] + ")\\s+-\\s+(" + src[XRANGEPLAIN] + ")\\s*$"; - var HYPHENRANGELOOSE = R++; - src[HYPHENRANGELOOSE] = "^\\s*(" + src[XRANGEPLAINLOOSE] + ")\\s+-\\s+(" + src[XRANGEPLAINLOOSE] + ")\\s*$"; - var STAR = R++; - src[STAR] = "(<|>)?=?\\s*\\*"; - for (i = 0; i < R; i++) { - debug(i, src[i]); - if (!re[i]) { - re[i] = new RegExp(src[i]); - } - } - var i; - exports.parse = parse; - function parse(version, options) { - if (!options || typeof options !== "object") { - options = { - loose: !!options, - includePrerelease: false - }; - } - if (version instanceof SemVer) { - return version; - } - if (typeof version !== "string") { - return null; - } - if (version.length > MAX_LENGTH) { - return null; - } - var r = options.loose ? re[LOOSE] : re[FULL]; - if (!r.test(version)) { - return null; - } - try { - return new SemVer(version, options); - } catch (er) { - return null; - } - } - exports.valid = valid; - function valid(version, options) { - var v = parse(version, options); - return v ? v.version : null; - } - exports.clean = clean; - function clean(version, options) { - var s = parse(version.trim().replace(/^[=v]+/, ""), options); - return s ? s.version : null; - } - exports.SemVer = SemVer; - function SemVer(version, options) { - if (!options || typeof options !== "object") { - options = { - loose: !!options, - includePrerelease: false - }; - } - if (version instanceof SemVer) { - if (version.loose === options.loose) { - return version; - } else { - version = version.version; - } - } else if (typeof version !== "string") { - throw new TypeError("Invalid Version: " + version); - } - if (version.length > MAX_LENGTH) { - throw new TypeError("version is longer than " + MAX_LENGTH + " characters"); - } - if (!(this instanceof SemVer)) { - return new SemVer(version, options); - } - debug("SemVer", version, options); - this.options = options; - this.loose = !!options.loose; - var m = version.trim().match(options.loose ? re[LOOSE] : re[FULL]); - if (!m) { - throw new TypeError("Invalid Version: " + version); - } - this.raw = version; - this.major = +m[1]; - this.minor = +m[2]; - this.patch = +m[3]; - if (this.major > MAX_SAFE_INTEGER || this.major < 0) { - throw new TypeError("Invalid major version"); - } - if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) { - throw new TypeError("Invalid minor version"); - } - if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) { - throw new TypeError("Invalid patch version"); - } - if (!m[4]) { - this.prerelease = []; - } else { - this.prerelease = m[4].split(".").map(function(id) { - if (/^[0-9]+$/.test(id)) { - var num = +id; - if (num >= 0 && num < MAX_SAFE_INTEGER) { - return num; - } - } - return id; - }); - } - this.build = m[5] ? m[5].split(".") : []; - this.format(); - } - SemVer.prototype.format = function() { - this.version = this.major + "." + this.minor + "." + this.patch; - if (this.prerelease.length) { - this.version += "-" + this.prerelease.join("."); - } - return this.version; - }; - SemVer.prototype.toString = function() { - return this.version; - }; - SemVer.prototype.compare = function(other) { - debug("SemVer.compare", this.version, this.options, other); - if (!(other instanceof SemVer)) { - other = new SemVer(other, this.options); - } - return this.compareMain(other) || this.comparePre(other); - }; - SemVer.prototype.compareMain = function(other) { - if (!(other instanceof SemVer)) { - other = new SemVer(other, this.options); - } - return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch); - }; - SemVer.prototype.comparePre = function(other) { - if (!(other instanceof SemVer)) { - other = new SemVer(other, this.options); - } - if (this.prerelease.length && !other.prerelease.length) { - return -1; - } else if (!this.prerelease.length && other.prerelease.length) { - return 1; - } else if (!this.prerelease.length && !other.prerelease.length) { - return 0; - } - var i2 = 0; - do { - var a = this.prerelease[i2]; - var b = other.prerelease[i2]; - debug("prerelease compare", i2, a, b); - if (a === void 0 && b === void 0) { - return 0; - } else if (b === void 0) { - return 1; - } else if (a === void 0) { - return -1; - } else if (a === b) { - continue; - } else { - return compareIdentifiers(a, b); - } - } while (++i2); - }; - SemVer.prototype.inc = function(release, identifier) { - switch (release) { - case "premajor": - this.prerelease.length = 0; - this.patch = 0; - this.minor = 0; - this.major++; - this.inc("pre", identifier); - break; - case "preminor": - this.prerelease.length = 0; - this.patch = 0; - this.minor++; - this.inc("pre", identifier); - break; - case "prepatch": - this.prerelease.length = 0; - this.inc("patch", identifier); - this.inc("pre", identifier); - break; - case "prerelease": - if (this.prerelease.length === 0) { - this.inc("patch", identifier); - } - this.inc("pre", identifier); - break; - case "major": - if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) { - this.major++; - } - this.minor = 0; - this.patch = 0; - this.prerelease = []; - break; - case "minor": - if (this.patch !== 0 || this.prerelease.length === 0) { - this.minor++; - } - this.patch = 0; - this.prerelease = []; - break; - case "patch": - if (this.prerelease.length === 0) { - this.patch++; - } - this.prerelease = []; - break; - case "pre": - if (this.prerelease.length === 0) { - this.prerelease = [0]; - } else { - var i2 = this.prerelease.length; - while (--i2 >= 0) { - if (typeof this.prerelease[i2] === "number") { - this.prerelease[i2]++; - i2 = -2; - } - } - if (i2 === -1) { - this.prerelease.push(0); - } - } - if (identifier) { - if (this.prerelease[0] === identifier) { - if (isNaN(this.prerelease[1])) { - this.prerelease = [identifier, 0]; - } - } else { - this.prerelease = [identifier, 0]; - } - } - break; - default: - throw new Error("invalid increment argument: " + release); - } - this.format(); - this.raw = this.version; - return this; - }; - exports.inc = inc; - function inc(version, release, loose, identifier) { - if (typeof loose === "string") { - identifier = loose; - loose = void 0; - } - try { - return new SemVer(version, loose).inc(release, identifier).version; - } catch (er) { - return null; - } - } - exports.diff = diff; - function diff(version1, version2) { - if (eq(version1, version2)) { - return null; - } else { - var v1 = parse(version1); - var v2 = parse(version2); - var prefix = ""; - if (v1.prerelease.length || v2.prerelease.length) { - prefix = "pre"; - var defaultResult = "prerelease"; - } - for (var key in v1) { - if (key === "major" || key === "minor" || key === "patch") { - if (v1[key] !== v2[key]) { - return prefix + key; - } - } - } - return defaultResult; - } - } - exports.compareIdentifiers = compareIdentifiers; - var numeric = /^[0-9]+$/; - function compareIdentifiers(a, b) { - var anum = numeric.test(a); - var bnum = numeric.test(b); - if (anum && bnum) { - a = +a; - b = +b; - } - return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1; - } - exports.rcompareIdentifiers = rcompareIdentifiers; - function rcompareIdentifiers(a, b) { - return compareIdentifiers(b, a); - } - exports.major = major; - function major(a, loose) { - return new SemVer(a, loose).major; - } - exports.minor = minor; - function minor(a, loose) { - return new SemVer(a, loose).minor; - } - exports.patch = patch; - function patch(a, loose) { - return new SemVer(a, loose).patch; - } - exports.compare = compare; - function compare(a, b, loose) { - return new SemVer(a, loose).compare(new SemVer(b, loose)); - } - exports.compareLoose = compareLoose; - function compareLoose(a, b) { - return compare(a, b, true); - } - exports.rcompare = rcompare; - function rcompare(a, b, loose) { - return compare(b, a, loose); - } - exports.sort = sort; - function sort(list, loose) { - return list.sort(function(a, b) { - return exports.compare(a, b, loose); - }); - } - exports.rsort = rsort; - function rsort(list, loose) { - return list.sort(function(a, b) { - return exports.rcompare(a, b, loose); - }); - } - exports.gt = gt; - function gt(a, b, loose) { - return compare(a, b, loose) > 0; - } - exports.lt = lt; - function lt(a, b, loose) { - return compare(a, b, loose) < 0; - } - exports.eq = eq; - function eq(a, b, loose) { - return compare(a, b, loose) === 0; - } - exports.neq = neq; - function neq(a, b, loose) { - return compare(a, b, loose) !== 0; - } - exports.gte = gte; - function gte(a, b, loose) { - return compare(a, b, loose) >= 0; - } - exports.lte = lte; - function lte(a, b, loose) { - return compare(a, b, loose) <= 0; - } - exports.cmp = cmp; - function cmp(a, op, b, loose) { - switch (op) { - case "===": - if (typeof a === "object") - a = a.version; - if (typeof b === "object") - b = b.version; - return a === b; - case "!==": - if (typeof a === "object") - a = a.version; - if (typeof b === "object") - b = b.version; - return a !== b; - case "": - case "=": - case "==": - return eq(a, b, loose); - case "!=": - return neq(a, b, loose); - case ">": - return gt(a, b, loose); - case ">=": - return gte(a, b, loose); - case "<": - return lt(a, b, loose); - case "<=": - return lte(a, b, loose); - default: - throw new TypeError("Invalid operator: " + op); - } - } - exports.Comparator = Comparator; - function Comparator(comp, options) { - if (!options || typeof options !== "object") { - options = { - loose: !!options, - includePrerelease: false - }; - } - if (comp instanceof Comparator) { - if (comp.loose === !!options.loose) { - return comp; - } else { - comp = comp.value; - } - } - if (!(this instanceof Comparator)) { - return new Comparator(comp, options); - } - debug("comparator", comp, options); - this.options = options; - this.loose = !!options.loose; - this.parse(comp); - if (this.semver === ANY) { - this.value = ""; - } else { - this.value = this.operator + this.semver.version; - } - debug("comp", this); - } - var ANY = {}; - Comparator.prototype.parse = function(comp) { - var r = this.options.loose ? re[COMPARATORLOOSE] : re[COMPARATOR]; - var m = comp.match(r); - if (!m) { - throw new TypeError("Invalid comparator: " + comp); - } - this.operator = m[1]; - if (this.operator === "=") { - this.operator = ""; - } - if (!m[2]) { - this.semver = ANY; - } else { - this.semver = new SemVer(m[2], this.options.loose); - } - }; - Comparator.prototype.toString = function() { - return this.value; - }; - Comparator.prototype.test = function(version) { - debug("Comparator.test", version, this.options.loose); - if (this.semver === ANY) { - return true; - } - if (typeof version === "string") { - version = new SemVer(version, this.options); - } - return cmp(version, this.operator, this.semver, this.options); - }; - Comparator.prototype.intersects = function(comp, options) { - if (!(comp instanceof Comparator)) { - throw new TypeError("a Comparator is required"); - } - if (!options || typeof options !== "object") { - options = { - loose: !!options, - includePrerelease: false - }; - } - var rangeTmp; - if (this.operator === "") { - rangeTmp = new Range(comp.value, options); - return satisfies(this.value, rangeTmp, options); - } else if (comp.operator === "") { - rangeTmp = new Range(this.value, options); - return satisfies(comp.semver, rangeTmp, options); - } - var sameDirectionIncreasing = (this.operator === ">=" || this.operator === ">") && (comp.operator === ">=" || comp.operator === ">"); - var sameDirectionDecreasing = (this.operator === "<=" || this.operator === "<") && (comp.operator === "<=" || comp.operator === "<"); - var sameSemVer = this.semver.version === comp.semver.version; - var differentDirectionsInclusive = (this.operator === ">=" || this.operator === "<=") && (comp.operator === ">=" || comp.operator === "<="); - var oppositeDirectionsLessThan = cmp(this.semver, "<", comp.semver, options) && ((this.operator === ">=" || this.operator === ">") && (comp.operator === "<=" || comp.operator === "<")); - var oppositeDirectionsGreaterThan = cmp(this.semver, ">", comp.semver, options) && ((this.operator === "<=" || this.operator === "<") && (comp.operator === ">=" || comp.operator === ">")); - return sameDirectionIncreasing || sameDirectionDecreasing || sameSemVer && differentDirectionsInclusive || oppositeDirectionsLessThan || oppositeDirectionsGreaterThan; - }; - exports.Range = Range; - function Range(range, options) { - if (!options || typeof options !== "object") { - options = { - loose: !!options, - includePrerelease: false - }; - } - if (range instanceof Range) { - if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) { - return range; - } else { - return new Range(range.raw, options); - } - } - if (range instanceof Comparator) { - return new Range(range.value, options); - } - if (!(this instanceof Range)) { - return new Range(range, options); - } - this.options = options; - this.loose = !!options.loose; - this.includePrerelease = !!options.includePrerelease; - this.raw = range; - this.set = range.split(/\s*\|\|\s*/).map(function(range2) { - return this.parseRange(range2.trim()); - }, this).filter(function(c) { - return c.length; - }); - if (!this.set.length) { - throw new TypeError("Invalid SemVer Range: " + range); - } - this.format(); - } - Range.prototype.format = function() { - this.range = this.set.map(function(comps) { - return comps.join(" ").trim(); - }).join("||").trim(); - return this.range; - }; - Range.prototype.toString = function() { - return this.range; - }; - Range.prototype.parseRange = function(range) { - var loose = this.options.loose; - range = range.trim(); - var hr = loose ? re[HYPHENRANGELOOSE] : re[HYPHENRANGE]; - range = range.replace(hr, hyphenReplace); - debug("hyphen replace", range); - range = range.replace(re[COMPARATORTRIM], comparatorTrimReplace); - debug("comparator trim", range, re[COMPARATORTRIM]); - range = range.replace(re[TILDETRIM], tildeTrimReplace); - range = range.replace(re[CARETTRIM], caretTrimReplace); - range = range.split(/\s+/).join(" "); - var compRe = loose ? re[COMPARATORLOOSE] : re[COMPARATOR]; - var set = range.split(" ").map(function(comp) { - return parseComparator(comp, this.options); - }, this).join(" ").split(/\s+/); - if (this.options.loose) { - set = set.filter(function(comp) { - return !!comp.match(compRe); - }); - } - set = set.map(function(comp) { - return new Comparator(comp, this.options); - }, this); - return set; - }; - Range.prototype.intersects = function(range, options) { - if (!(range instanceof Range)) { - throw new TypeError("a Range is required"); - } - return this.set.some(function(thisComparators) { - return thisComparators.every(function(thisComparator) { - return range.set.some(function(rangeComparators) { - return rangeComparators.every(function(rangeComparator) { - return thisComparator.intersects(rangeComparator, options); - }); - }); - }); - }); - }; - exports.toComparators = toComparators; - function toComparators(range, options) { - return new Range(range, options).set.map(function(comp) { - return comp.map(function(c) { - return c.value; - }).join(" ").trim().split(" "); - }); - } - function parseComparator(comp, options) { - debug("comp", comp, options); - comp = replaceCarets(comp, options); - debug("caret", comp); - comp = replaceTildes(comp, options); - debug("tildes", comp); - comp = replaceXRanges(comp, options); - debug("xrange", comp); - comp = replaceStars(comp, options); - debug("stars", comp); - return comp; - } - function isX(id) { - return !id || id.toLowerCase() === "x" || id === "*"; - } - function replaceTildes(comp, options) { - return comp.trim().split(/\s+/).map(function(comp2) { - return replaceTilde(comp2, options); - }).join(" "); - } - function replaceTilde(comp, options) { - var r = options.loose ? re[TILDELOOSE] : re[TILDE]; - return comp.replace(r, function(_, M, m, p, pr) { - debug("tilde", comp, _, M, m, p, pr); - var ret; - if (isX(M)) { - ret = ""; - } else if (isX(m)) { - ret = ">=" + M + ".0.0 <" + (+M + 1) + ".0.0"; - } else if (isX(p)) { - ret = ">=" + M + "." + m + ".0 <" + M + "." + (+m + 1) + ".0"; - } else if (pr) { - debug("replaceTilde pr", pr); - ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + M + "." + (+m + 1) + ".0"; - } else { - ret = ">=" + M + "." + m + "." + p + " <" + M + "." + (+m + 1) + ".0"; - } - debug("tilde return", ret); - return ret; - }); - } - function replaceCarets(comp, options) { - return comp.trim().split(/\s+/).map(function(comp2) { - return replaceCaret(comp2, options); - }).join(" "); - } - function replaceCaret(comp, options) { - debug("caret", comp, options); - var r = options.loose ? re[CARETLOOSE] : re[CARET]; - return comp.replace(r, function(_, M, m, p, pr) { - debug("caret", comp, _, M, m, p, pr); - var ret; - if (isX(M)) { - ret = ""; - } else if (isX(m)) { - ret = ">=" + M + ".0.0 <" + (+M + 1) + ".0.0"; - } else if (isX(p)) { - if (M === "0") { - ret = ">=" + M + "." + m + ".0 <" + M + "." + (+m + 1) + ".0"; - } else { - ret = ">=" + M + "." + m + ".0 <" + (+M + 1) + ".0.0"; - } - } else if (pr) { - debug("replaceCaret pr", pr); - if (M === "0") { - if (m === "0") { - ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + M + "." + m + "." + (+p + 1); - } else { - ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + M + "." + (+m + 1) + ".0"; - } - } else { - ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + (+M + 1) + ".0.0"; - } - } else { - debug("no pr"); - if (M === "0") { - if (m === "0") { - ret = ">=" + M + "." + m + "." + p + " <" + M + "." + m + "." + (+p + 1); - } else { - ret = ">=" + M + "." + m + "." + p + " <" + M + "." + (+m + 1) + ".0"; - } - } else { - ret = ">=" + M + "." + m + "." + p + " <" + (+M + 1) + ".0.0"; - } - } - debug("caret return", ret); - return ret; - }); - } - function replaceXRanges(comp, options) { - debug("replaceXRanges", comp, options); - return comp.split(/\s+/).map(function(comp2) { - return replaceXRange(comp2, options); - }).join(" "); - } - function replaceXRange(comp, options) { - comp = comp.trim(); - var r = options.loose ? re[XRANGELOOSE] : re[XRANGE]; - return comp.replace(r, function(ret, gtlt, M, m, p, pr) { - debug("xRange", comp, ret, gtlt, M, m, p, pr); - var xM = isX(M); - var xm = xM || isX(m); - var xp = xm || isX(p); - var anyX = xp; - if (gtlt === "=" && anyX) { - gtlt = ""; - } - if (xM) { - if (gtlt === ">" || gtlt === "<") { - ret = "<0.0.0"; - } else { - ret = "*"; - } - } else if (gtlt && anyX) { - if (xm) { - m = 0; - } - p = 0; - if (gtlt === ">") { - gtlt = ">="; - if (xm) { - M = +M + 1; - m = 0; - p = 0; - } else { - m = +m + 1; - p = 0; - } - } else if (gtlt === "<=") { - gtlt = "<"; - if (xm) { - M = +M + 1; - } else { - m = +m + 1; - } - } - ret = gtlt + M + "." + m + "." + p; - } else if (xm) { - ret = ">=" + M + ".0.0 <" + (+M + 1) + ".0.0"; - } else if (xp) { - ret = ">=" + M + "." + m + ".0 <" + M + "." + (+m + 1) + ".0"; - } - debug("xRange return", ret); - return ret; - }); - } - function replaceStars(comp, options) { - debug("replaceStars", comp, options); - return comp.trim().replace(re[STAR], ""); - } - function hyphenReplace($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr, tb) { - if (isX(fM)) { - from = ""; - } else if (isX(fm)) { - from = ">=" + fM + ".0.0"; - } else if (isX(fp)) { - from = ">=" + fM + "." + fm + ".0"; - } else { - from = ">=" + from; - } - if (isX(tM)) { - to = ""; - } else if (isX(tm)) { - to = "<" + (+tM + 1) + ".0.0"; - } else if (isX(tp)) { - to = "<" + tM + "." + (+tm + 1) + ".0"; - } else if (tpr) { - to = "<=" + tM + "." + tm + "." + tp + "-" + tpr; - } else { - to = "<=" + to; - } - return (from + " " + to).trim(); - } - Range.prototype.test = function(version) { - if (!version) { - return false; - } - if (typeof version === "string") { - version = new SemVer(version, this.options); - } - for (var i2 = 0; i2 < this.set.length; i2++) { - if (testSet(this.set[i2], version, this.options)) { - return true; - } - } - return false; - }; - function testSet(set, version, options) { - for (var i2 = 0; i2 < set.length; i2++) { - if (!set[i2].test(version)) { - return false; - } - } - if (version.prerelease.length && !options.includePrerelease) { - for (i2 = 0; i2 < set.length; i2++) { - debug(set[i2].semver); - if (set[i2].semver === ANY) { - continue; - } - if (set[i2].semver.prerelease.length > 0) { - var allowed = set[i2].semver; - if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) { - return true; - } - } - } - return false; - } - return true; - } - exports.satisfies = satisfies; - function satisfies(version, range, options) { - try { - range = new Range(range, options); - } catch (er) { - return false; - } - return range.test(version); - } - exports.maxSatisfying = maxSatisfying; - function maxSatisfying(versions, range, options) { - var max = null; - var maxSV = null; - try { - var rangeObj = new Range(range, options); - } catch (er) { - return null; - } - versions.forEach(function(v) { - if (rangeObj.test(v)) { - if (!max || maxSV.compare(v) === -1) { - max = v; - maxSV = new SemVer(max, options); - } - } - }); - return max; - } - exports.minSatisfying = minSatisfying; - function minSatisfying(versions, range, options) { - var min = null; - var minSV = null; - try { - var rangeObj = new Range(range, options); - } catch (er) { - return null; - } - versions.forEach(function(v) { - if (rangeObj.test(v)) { - if (!min || minSV.compare(v) === 1) { - min = v; - minSV = new SemVer(min, options); - } - } - }); - return min; - } - exports.minVersion = minVersion; - function minVersion(range, loose) { - range = new Range(range, loose); - var minver = new SemVer("0.0.0"); - if (range.test(minver)) { - return minver; - } - minver = new SemVer("0.0.0-0"); - if (range.test(minver)) { - return minver; - } - minver = null; - for (var i2 = 0; i2 < range.set.length; ++i2) { - var comparators = range.set[i2]; - comparators.forEach(function(comparator) { - var compver = new SemVer(comparator.semver.version); - switch (comparator.operator) { - case ">": - if (compver.prerelease.length === 0) { - compver.patch++; - } else { - compver.prerelease.push(0); - } - compver.raw = compver.format(); - case "": - case ">=": - if (!minver || gt(minver, compver)) { - minver = compver; - } - break; - case "<": - case "<=": - break; - default: - throw new Error("Unexpected operation: " + comparator.operator); - } - }); - } - if (minver && range.test(minver)) { - return minver; - } - return null; - } - exports.validRange = validRange; - function validRange(range, options) { - try { - return new Range(range, options).range || "*"; - } catch (er) { - return null; - } - } - exports.ltr = ltr; - function ltr(version, range, options) { - return outside(version, range, "<", options); - } - exports.gtr = gtr; - function gtr(version, range, options) { - return outside(version, range, ">", options); - } - exports.outside = outside; - function outside(version, range, hilo, options) { - version = new SemVer(version, options); - range = new Range(range, options); - var gtfn, ltefn, ltfn, comp, ecomp; - switch (hilo) { - case ">": - gtfn = gt; - ltefn = lte; - ltfn = lt; - comp = ">"; - ecomp = ">="; - break; - case "<": - gtfn = lt; - ltefn = gte; - ltfn = gt; - comp = "<"; - ecomp = "<="; - break; - default: - throw new TypeError('Must provide a hilo val of "<" or ">"'); - } - if (satisfies(version, range, options)) { - return false; - } - for (var i2 = 0; i2 < range.set.length; ++i2) { - var comparators = range.set[i2]; - var high = null; - var low = null; - comparators.forEach(function(comparator) { - if (comparator.semver === ANY) { - comparator = new Comparator(">=0.0.0"); - } - high = high || comparator; - low = low || comparator; - if (gtfn(comparator.semver, high.semver, options)) { - high = comparator; - } else if (ltfn(comparator.semver, low.semver, options)) { - low = comparator; - } - }); - if (high.operator === comp || high.operator === ecomp) { - return false; - } - if ((!low.operator || low.operator === comp) && ltefn(version, low.semver)) { - return false; - } else if (low.operator === ecomp && ltfn(version, low.semver)) { - return false; - } - } - return true; - } - exports.prerelease = prerelease; - function prerelease(version, options) { - var parsed = parse(version, options); - return parsed && parsed.prerelease.length ? parsed.prerelease : null; - } - exports.intersects = intersects; - function intersects(r1, r2, options) { - r1 = new Range(r1, options); - r2 = new Range(r2, options); - return r1.intersects(r2); - } - exports.coerce = coerce; - function coerce(version) { - if (version instanceof SemVer) { - return version; - } - if (typeof version !== "string") { - return null; - } - var match = version.match(re[COERCE]); - if (match == null) { - return null; - } - return parse(match[1] + "." + (match[2] || "0") + "." + (match[3] || "0")); - } - } -}); - -// -var require_psSupported = __commonJS({ - ""(exports, module) { - var semver = require_semver(); - module.exports = semver.satisfies(process.version, "^6.12.0 || >=8.0.0"); - } -}); - -// -var require_verify = __commonJS({ - ""(exports, module) { - var JsonWebTokenError = require_JsonWebTokenError(); - var NotBeforeError = require_NotBeforeError(); - var TokenExpiredError = require_TokenExpiredError(); - var decode = require_decode(); - var timespan = require_timespan(); - var PS_SUPPORTED = require_psSupported(); - var jws = require_jws(); - var PUB_KEY_ALGS = ["RS256", "RS384", "RS512", "ES256", "ES384", "ES512"]; - var RSA_KEY_ALGS = ["RS256", "RS384", "RS512"]; - var HS_ALGS = ["HS256", "HS384", "HS512"]; - if (PS_SUPPORTED) { - PUB_KEY_ALGS.splice(3, 0, "PS256", "PS384", "PS512"); - RSA_KEY_ALGS.splice(3, 0, "PS256", "PS384", "PS512"); - } - module.exports = function(jwtString, secretOrPublicKey, options, callback) { - if (typeof options === "function" && !callback) { - callback = options; - options = {}; - } - if (!options) { - options = {}; - } - options = Object.assign({}, options); - var done; - if (callback) { - done = callback; - } else { - done = function(err, data) { - if (err) - throw err; - return data; - }; - } - if (options.clockTimestamp && typeof options.clockTimestamp !== "number") { - return done(new JsonWebTokenError("clockTimestamp must be a number")); - } - if (options.nonce !== void 0 && (typeof options.nonce !== "string" || options.nonce.trim() === "")) { - return done(new JsonWebTokenError("nonce must be a non-empty string")); - } - var clockTimestamp = options.clockTimestamp || Math.floor(Date.now() / 1e3); - if (!jwtString) { - return done(new JsonWebTokenError("jwt must be provided")); - } - if (typeof jwtString !== "string") { - return done(new JsonWebTokenError("jwt must be a string")); - } - var parts = jwtString.split("."); - if (parts.length !== 3) { - return done(new JsonWebTokenError("jwt malformed")); - } - var decodedToken; - try { - decodedToken = decode(jwtString, { complete: true }); - } catch (err) { - return done(err); - } - if (!decodedToken) { - return done(new JsonWebTokenError("invalid token")); - } - var header = decodedToken.header; - var getSecret; - if (typeof secretOrPublicKey === "function") { - if (!callback) { - return done(new JsonWebTokenError("verify must be called asynchronous if secret or public key is provided as a callback")); - } - getSecret = secretOrPublicKey; - } else { - getSecret = function(header2, secretCallback) { - return secretCallback(null, secretOrPublicKey); - }; - } - return getSecret(header, function(err, secretOrPublicKey2) { - if (err) { - return done(new JsonWebTokenError("error in secret or public key callback: " + err.message)); - } - var hasSignature = parts[2].trim() !== ""; - if (!hasSignature && secretOrPublicKey2) { - return done(new JsonWebTokenError("jwt signature is required")); - } - if (hasSignature && !secretOrPublicKey2) { - return done(new JsonWebTokenError("secret or public key must be provided")); - } - if (!hasSignature && !options.algorithms) { - options.algorithms = ["none"]; - } - if (!options.algorithms) { - options.algorithms = ~secretOrPublicKey2.toString().indexOf("BEGIN CERTIFICATE") || ~secretOrPublicKey2.toString().indexOf("BEGIN PUBLIC KEY") ? PUB_KEY_ALGS : ~secretOrPublicKey2.toString().indexOf("BEGIN RSA PUBLIC KEY") ? RSA_KEY_ALGS : HS_ALGS; - } - if (!~options.algorithms.indexOf(decodedToken.header.alg)) { - return done(new JsonWebTokenError("invalid algorithm")); - } - var valid; - try { - valid = jws.verify(jwtString, decodedToken.header.alg, secretOrPublicKey2); - } catch (e) { - return done(e); - } - if (!valid) { - return done(new JsonWebTokenError("invalid signature")); - } - var payload = decodedToken.payload; - if (typeof payload.nbf !== "undefined" && !options.ignoreNotBefore) { - if (typeof payload.nbf !== "number") { - return done(new JsonWebTokenError("invalid nbf value")); - } - if (payload.nbf > clockTimestamp + (options.clockTolerance || 0)) { - return done(new NotBeforeError("jwt not active", new Date(payload.nbf * 1e3))); - } - } - if (typeof payload.exp !== "undefined" && !options.ignoreExpiration) { - if (typeof payload.exp !== "number") { - return done(new JsonWebTokenError("invalid exp value")); - } - if (clockTimestamp >= payload.exp + (options.clockTolerance || 0)) { - return done(new TokenExpiredError("jwt expired", new Date(payload.exp * 1e3))); - } - } - if (options.audience) { - var audiences = Array.isArray(options.audience) ? options.audience : [options.audience]; - var target = Array.isArray(payload.aud) ? payload.aud : [payload.aud]; - var match = target.some(function(targetAudience) { - return audiences.some(function(audience) { - return audience instanceof RegExp ? audience.test(targetAudience) : audience === targetAudience; - }); - }); - if (!match) { - return done(new JsonWebTokenError("jwt audience invalid. expected: " + audiences.join(" or "))); - } - } - if (options.issuer) { - var invalid_issuer = typeof options.issuer === "string" && payload.iss !== options.issuer || Array.isArray(options.issuer) && options.issuer.indexOf(payload.iss) === -1; - if (invalid_issuer) { - return done(new JsonWebTokenError("jwt issuer invalid. expected: " + options.issuer)); - } - } - if (options.subject) { - if (payload.sub !== options.subject) { - return done(new JsonWebTokenError("jwt subject invalid. expected: " + options.subject)); - } - } - if (options.jwtid) { - if (payload.jti !== options.jwtid) { - return done(new JsonWebTokenError("jwt jwtid invalid. expected: " + options.jwtid)); - } - } - if (options.nonce) { - if (payload.nonce !== options.nonce) { - return done(new JsonWebTokenError("jwt nonce invalid. expected: " + options.nonce)); - } - } - if (options.maxAge) { - if (typeof payload.iat !== "number") { - return done(new JsonWebTokenError("iat required when maxAge is specified")); - } - var maxAgeTimestamp = timespan(options.maxAge, payload.iat); - if (typeof maxAgeTimestamp === "undefined") { - return done(new JsonWebTokenError('"maxAge" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60')); - } - if (clockTimestamp >= maxAgeTimestamp + (options.clockTolerance || 0)) { - return done(new TokenExpiredError("maxAge exceeded", new Date(maxAgeTimestamp * 1e3))); - } - } - if (options.complete === true) { - var signature = decodedToken.signature; - return done(null, { - header, - payload, - signature - }); - } - return done(null, payload); - }); - }; - } -}); - -// -var require_lodash = __commonJS({ - ""(exports, module) { - var INFINITY = 1 / 0; - var MAX_SAFE_INTEGER = 9007199254740991; - var MAX_INTEGER = 17976931348623157e292; - var NAN = 0 / 0; - var argsTag = "[object Arguments]"; - var funcTag = "[object Function]"; - var genTag = "[object GeneratorFunction]"; - var stringTag = "[object String]"; - var symbolTag = "[object Symbol]"; - var reTrim = /^\s+|\s+$/g; - var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; - var reIsBinary = /^0b[01]+$/i; - var reIsOctal = /^0o[0-7]+$/i; - var reIsUint = /^(?:0|[1-9]\d*)$/; - var freeParseInt = parseInt; - function arrayMap(array, iteratee) { - var index = -1, length = array ? array.length : 0, result = Array(length); - while (++index < length) { - result[index] = iteratee(array[index], index, array); - } - return result; - } - function baseFindIndex(array, predicate, fromIndex, fromRight) { - var length = array.length, index = fromIndex + (fromRight ? 1 : -1); - while (fromRight ? index-- : ++index < length) { - if (predicate(array[index], index, array)) { - return index; - } - } - return -1; - } - function baseIndexOf(array, value, fromIndex) { - if (value !== value) { - return baseFindIndex(array, baseIsNaN, fromIndex); - } - var index = fromIndex - 1, length = array.length; - while (++index < length) { - if (array[index] === value) { - return index; - } - } - return -1; - } - function baseIsNaN(value) { - return value !== value; - } - function baseTimes(n, iteratee) { - var index = -1, result = Array(n); - while (++index < n) { - result[index] = iteratee(index); - } - return result; - } - function baseValues(object, props) { - return arrayMap(props, function(key) { - return object[key]; - }); - } - function overArg(func, transform) { - return function(arg) { - return func(transform(arg)); - }; - } - var objectProto = Object.prototype; - var hasOwnProperty = objectProto.hasOwnProperty; - var objectToString = objectProto.toString; - var propertyIsEnumerable = objectProto.propertyIsEnumerable; - var nativeKeys = overArg(Object.keys, Object); - var nativeMax = Math.max; - function arrayLikeKeys(value, inherited) { - var result = isArray(value) || isArguments(value) ? baseTimes(value.length, String) : []; - var length = result.length, skipIndexes = !!length; - for (var key in value) { - if ((inherited || hasOwnProperty.call(value, key)) && !(skipIndexes && (key == "length" || isIndex(key, length)))) { - result.push(key); - } - } - return result; - } - function baseKeys(object) { - if (!isPrototype(object)) { - return nativeKeys(object); - } - var result = []; - for (var key in Object(object)) { - if (hasOwnProperty.call(object, key) && key != "constructor") { - result.push(key); - } - } - return result; - } - function isIndex(value, length) { - length = length == null ? MAX_SAFE_INTEGER : length; - return !!length && (typeof value == "number" || reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length); - } - function isPrototype(value) { - var Ctor = value && value.constructor, proto2 = typeof Ctor == "function" && Ctor.prototype || objectProto; - return value === proto2; - } - function includes(collection, value, fromIndex, guard) { - collection = isArrayLike(collection) ? collection : values(collection); - fromIndex = fromIndex && !guard ? toInteger(fromIndex) : 0; - var length = collection.length; - if (fromIndex < 0) { - fromIndex = nativeMax(length + fromIndex, 0); - } - return isString(collection) ? fromIndex <= length && collection.indexOf(value, fromIndex) > -1 : !!length && baseIndexOf(collection, value, fromIndex) > -1; - } - function isArguments(value) { - return isArrayLikeObject(value) && hasOwnProperty.call(value, "callee") && (!propertyIsEnumerable.call(value, "callee") || objectToString.call(value) == argsTag); - } - var isArray = Array.isArray; - function isArrayLike(value) { - return value != null && isLength(value.length) && !isFunction(value); - } - function isArrayLikeObject(value) { - return isObjectLike(value) && isArrayLike(value); - } - function isFunction(value) { - var tag = isObject(value) ? objectToString.call(value) : ""; - return tag == funcTag || tag == genTag; - } - function isLength(value) { - return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; - } - function isObject(value) { - var type = typeof value; - return !!value && (type == "object" || type == "function"); - } - function isObjectLike(value) { - return !!value && typeof value == "object"; - } - function isString(value) { - return typeof value == "string" || !isArray(value) && isObjectLike(value) && objectToString.call(value) == stringTag; - } - function isSymbol(value) { - return typeof value == "symbol" || isObjectLike(value) && objectToString.call(value) == symbolTag; - } - function toFinite(value) { - if (!value) { - return value === 0 ? value : 0; - } - value = toNumber(value); - if (value === INFINITY || value === -INFINITY) { - var sign = value < 0 ? -1 : 1; - return sign * MAX_INTEGER; - } - return value === value ? value : 0; - } - function toInteger(value) { - var result = toFinite(value), remainder = result % 1; - return result === result ? remainder ? result - remainder : result : 0; - } - function toNumber(value) { - if (typeof value == "number") { - return value; - } - if (isSymbol(value)) { - return NAN; - } - if (isObject(value)) { - var other = typeof value.valueOf == "function" ? value.valueOf() : value; - value = isObject(other) ? other + "" : other; - } - if (typeof value != "string") { - return value === 0 ? value : +value; - } - value = value.replace(reTrim, ""); - var isBinary = reIsBinary.test(value); - return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value; - } - function keys(object) { - return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); - } - function values(object) { - return object ? baseValues(object, keys(object)) : []; - } - module.exports = includes; - } -}); - -// -var require_lodash2 = __commonJS({ - ""(exports, module) { - var boolTag = "[object Boolean]"; - var objectProto = Object.prototype; - var objectToString = objectProto.toString; - function isBoolean(value) { - return value === true || value === false || isObjectLike(value) && objectToString.call(value) == boolTag; - } - function isObjectLike(value) { - return !!value && typeof value == "object"; - } - module.exports = isBoolean; - } -}); - -// -var require_lodash3 = __commonJS({ - ""(exports, module) { - var INFINITY = 1 / 0; - var MAX_INTEGER = 17976931348623157e292; - var NAN = 0 / 0; - var symbolTag = "[object Symbol]"; - var reTrim = /^\s+|\s+$/g; - var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; - var reIsBinary = /^0b[01]+$/i; - var reIsOctal = /^0o[0-7]+$/i; - var freeParseInt = parseInt; - var objectProto = Object.prototype; - var objectToString = objectProto.toString; - function isInteger(value) { - return typeof value == "number" && value == toInteger(value); - } - function isObject(value) { - var type = typeof value; - return !!value && (type == "object" || type == "function"); - } - function isObjectLike(value) { - return !!value && typeof value == "object"; - } - function isSymbol(value) { - return typeof value == "symbol" || isObjectLike(value) && objectToString.call(value) == symbolTag; - } - function toFinite(value) { - if (!value) { - return value === 0 ? value : 0; - } - value = toNumber(value); - if (value === INFINITY || value === -INFINITY) { - var sign = value < 0 ? -1 : 1; - return sign * MAX_INTEGER; - } - return value === value ? value : 0; - } - function toInteger(value) { - var result = toFinite(value), remainder = result % 1; - return result === result ? remainder ? result - remainder : result : 0; - } - function toNumber(value) { - if (typeof value == "number") { - return value; - } - if (isSymbol(value)) { - return NAN; - } - if (isObject(value)) { - var other = typeof value.valueOf == "function" ? value.valueOf() : value; - value = isObject(other) ? other + "" : other; - } - if (typeof value != "string") { - return value === 0 ? value : +value; - } - value = value.replace(reTrim, ""); - var isBinary = reIsBinary.test(value); - return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value; - } - module.exports = isInteger; - } -}); - -// -var require_lodash4 = __commonJS({ - ""(exports, module) { - var numberTag = "[object Number]"; - var objectProto = Object.prototype; - var objectToString = objectProto.toString; - function isObjectLike(value) { - return !!value && typeof value == "object"; - } - function isNumber(value) { - return typeof value == "number" || isObjectLike(value) && objectToString.call(value) == numberTag; - } - module.exports = isNumber; - } -}); - -// -var require_lodash5 = __commonJS({ - ""(exports, module) { - var objectTag = "[object Object]"; - function isHostObject(value) { - var result = false; - if (value != null && typeof value.toString != "function") { - try { - result = !!(value + ""); - } catch (e) { - } - } - return result; - } - function overArg(func, transform) { - return function(arg) { - return func(transform(arg)); - }; - } - var funcProto = Function.prototype; - var objectProto = Object.prototype; - var funcToString = funcProto.toString; - var hasOwnProperty = objectProto.hasOwnProperty; - var objectCtorString = funcToString.call(Object); - var objectToString = objectProto.toString; - var getPrototype = overArg(Object.getPrototypeOf, Object); - function isObjectLike(value) { - return !!value && typeof value == "object"; - } - function isPlainObject(value) { - if (!isObjectLike(value) || objectToString.call(value) != objectTag || isHostObject(value)) { - return false; - } - var proto2 = getPrototype(value); - if (proto2 === null) { - return true; - } - var Ctor = hasOwnProperty.call(proto2, "constructor") && proto2.constructor; - return typeof Ctor == "function" && Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString; - } - module.exports = isPlainObject; - } -}); - -// -var require_lodash6 = __commonJS({ - ""(exports, module) { - var stringTag = "[object String]"; - var objectProto = Object.prototype; - var objectToString = objectProto.toString; - var isArray = Array.isArray; - function isObjectLike(value) { - return !!value && typeof value == "object"; - } - function isString(value) { - return typeof value == "string" || !isArray(value) && isObjectLike(value) && objectToString.call(value) == stringTag; - } - module.exports = isString; - } -}); - -// -var require_lodash7 = __commonJS({ - ""(exports, module) { - var FUNC_ERROR_TEXT = "Expected a function"; - var INFINITY = 1 / 0; - var MAX_INTEGER = 17976931348623157e292; - var NAN = 0 / 0; - var symbolTag = "[object Symbol]"; - var reTrim = /^\s+|\s+$/g; - var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; - var reIsBinary = /^0b[01]+$/i; - var reIsOctal = /^0o[0-7]+$/i; - var freeParseInt = parseInt; - var objectProto = Object.prototype; - var objectToString = objectProto.toString; - function before(n, func) { - var result; - if (typeof func != "function") { - throw new TypeError(FUNC_ERROR_TEXT); - } - n = toInteger(n); - return function() { - if (--n > 0) { - result = func.apply(this, arguments); - } - if (n <= 1) { - func = void 0; - } - return result; - }; - } - function once(func) { - return before(2, func); - } - function isObject(value) { - var type = typeof value; - return !!value && (type == "object" || type == "function"); - } - function isObjectLike(value) { - return !!value && typeof value == "object"; - } - function isSymbol(value) { - return typeof value == "symbol" || isObjectLike(value) && objectToString.call(value) == symbolTag; - } - function toFinite(value) { - if (!value) { - return value === 0 ? value : 0; - } - value = toNumber(value); - if (value === INFINITY || value === -INFINITY) { - var sign = value < 0 ? -1 : 1; - return sign * MAX_INTEGER; - } - return value === value ? value : 0; - } - function toInteger(value) { - var result = toFinite(value), remainder = result % 1; - return result === result ? remainder ? result - remainder : result : 0; - } - function toNumber(value) { - if (typeof value == "number") { - return value; - } - if (isSymbol(value)) { - return NAN; - } - if (isObject(value)) { - var other = typeof value.valueOf == "function" ? value.valueOf() : value; - value = isObject(other) ? other + "" : other; - } - if (typeof value != "string") { - return value === 0 ? value : +value; - } - value = value.replace(reTrim, ""); - var isBinary = reIsBinary.test(value); - return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value; - } - module.exports = once; - } -}); - -// -var require_sign = __commonJS({ - ""(exports, module) { - var timespan = require_timespan(); - var PS_SUPPORTED = require_psSupported(); - var jws = require_jws(); - var includes = require_lodash(); - var isBoolean = require_lodash2(); - var isInteger = require_lodash3(); - var isNumber = require_lodash4(); - var isPlainObject = require_lodash5(); - var isString = require_lodash6(); - var once = require_lodash7(); - var SUPPORTED_ALGS = ["RS256", "RS384", "RS512", "ES256", "ES384", "ES512", "HS256", "HS384", "HS512", "none"]; - if (PS_SUPPORTED) { - SUPPORTED_ALGS.splice(3, 0, "PS256", "PS384", "PS512"); - } - var sign_options_schema = { - expiresIn: { isValid: function(value) { - return isInteger(value) || isString(value) && value; - }, message: '"expiresIn" should be a number of seconds or string representing a timespan' }, - notBefore: { isValid: function(value) { - return isInteger(value) || isString(value) && value; - }, message: '"notBefore" should be a number of seconds or string representing a timespan' }, - audience: { isValid: function(value) { - return isString(value) || Array.isArray(value); - }, message: '"audience" must be a string or array' }, - algorithm: { isValid: includes.bind(null, SUPPORTED_ALGS), message: '"algorithm" must be a valid string enum value' }, - header: { isValid: isPlainObject, message: '"header" must be an object' }, - encoding: { isValid: isString, message: '"encoding" must be a string' }, - issuer: { isValid: isString, message: '"issuer" must be a string' }, - subject: { isValid: isString, message: '"subject" must be a string' }, - jwtid: { isValid: isString, message: '"jwtid" must be a string' }, - noTimestamp: { isValid: isBoolean, message: '"noTimestamp" must be a boolean' }, - keyid: { isValid: isString, message: '"keyid" must be a string' }, - mutatePayload: { isValid: isBoolean, message: '"mutatePayload" must be a boolean' } - }; - var registered_claims_schema = { - iat: { isValid: isNumber, message: '"iat" should be a number of seconds' }, - exp: { isValid: isNumber, message: '"exp" should be a number of seconds' }, - nbf: { isValid: isNumber, message: '"nbf" should be a number of seconds' } - }; - function validate(schema, allowUnknown, object, parameterName) { - if (!isPlainObject(object)) { - throw new Error('Expected "' + parameterName + '" to be a plain object.'); - } - Object.keys(object).forEach(function(key) { - var validator = schema[key]; - if (!validator) { - if (!allowUnknown) { - throw new Error('"' + key + '" is not allowed in "' + parameterName + '"'); - } - return; - } - if (!validator.isValid(object[key])) { - throw new Error(validator.message); - } - }); - } - function validateOptions(options) { - return validate(sign_options_schema, false, options, "options"); - } - function validatePayload(payload) { - return validate(registered_claims_schema, true, payload, "payload"); - } - var options_to_payload = { - "audience": "aud", - "issuer": "iss", - "subject": "sub", - "jwtid": "jti" - }; - var options_for_objects = [ - "expiresIn", - "notBefore", - "noTimestamp", - "audience", - "issuer", - "subject", - "jwtid" - ]; - module.exports = function(payload, secretOrPrivateKey, options, callback) { - if (typeof options === "function") { - callback = options; - options = {}; - } else { - options = options || {}; - } - var isObjectPayload = typeof payload === "object" && !Buffer.isBuffer(payload); - var header = Object.assign({ - alg: options.algorithm || "HS256", - typ: isObjectPayload ? "JWT" : void 0, - kid: options.keyid - }, options.header); - function failure(err) { - if (callback) { - return callback(err); - } - throw err; - } - if (!secretOrPrivateKey && options.algorithm !== "none") { - return failure(new Error("secretOrPrivateKey must have a value")); - } - if (typeof payload === "undefined") { - return failure(new Error("payload is required")); - } else if (isObjectPayload) { - try { - validatePayload(payload); - } catch (error2) { - return failure(error2); - } - if (!options.mutatePayload) { - payload = Object.assign({}, payload); - } - } else { - var invalid_options = options_for_objects.filter(function(opt) { - return typeof options[opt] !== "undefined"; - }); - if (invalid_options.length > 0) { - return failure(new Error("invalid " + invalid_options.join(",") + " option for " + typeof payload + " payload")); - } - } - if (typeof payload.exp !== "undefined" && typeof options.expiresIn !== "undefined") { - return failure(new Error('Bad "options.expiresIn" option the payload already has an "exp" property.')); - } - if (typeof payload.nbf !== "undefined" && typeof options.notBefore !== "undefined") { - return failure(new Error('Bad "options.notBefore" option the payload already has an "nbf" property.')); - } - try { - validateOptions(options); - } catch (error2) { - return failure(error2); - } - var timestamp = payload.iat || Math.floor(Date.now() / 1e3); - if (options.noTimestamp) { - delete payload.iat; - } else if (isObjectPayload) { - payload.iat = timestamp; - } - if (typeof options.notBefore !== "undefined") { - try { - payload.nbf = timespan(options.notBefore, timestamp); - } catch (err) { - return failure(err); - } - if (typeof payload.nbf === "undefined") { - return failure(new Error('"notBefore" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60')); - } - } - if (typeof options.expiresIn !== "undefined" && typeof payload === "object") { - try { - payload.exp = timespan(options.expiresIn, timestamp); - } catch (err) { - return failure(err); - } - if (typeof payload.exp === "undefined") { - return failure(new Error('"expiresIn" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60')); - } - } - Object.keys(options_to_payload).forEach(function(key) { - var claim = options_to_payload[key]; - if (typeof options[key] !== "undefined") { - if (typeof payload[claim] !== "undefined") { - return failure(new Error('Bad "options.' + key + '" option. The payload already has an "' + claim + '" property.')); - } - payload[claim] = options[key]; - } - }); - var encoding = options.encoding || "utf8"; - if (typeof callback === "function") { - callback = callback && once(callback); - jws.createSign({ - header, - privateKey: secretOrPrivateKey, - payload, - encoding - }).once("error", callback).once("done", function(signature) { - callback(null, signature); - }); - } else { - return jws.sign({ header, payload, secret: secretOrPrivateKey, encoding }); - } - }; - } -}); - -// -var require_jsonwebtoken = __commonJS({ - ""(exports, module) { - module.exports = { - decode: require_decode(), - verify: require_verify(), - sign: require_sign(), - JsonWebTokenError: require_JsonWebTokenError(), - NotBeforeError: require_NotBeforeError(), - TokenExpiredError: require_TokenExpiredError() - }; - } -}); - -// -var require_dist_node28 = __commonJS({ - ""(exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - function _interopDefault(ex) { - return ex && typeof ex === "object" && "default" in ex ? ex["default"] : ex; - } - var jsonwebtoken = _interopDefault(require_jsonwebtoken()); - async function getToken({ - privateKey, - payload - }) { - return jsonwebtoken.sign(payload, privateKey, { - algorithm: "RS256" - }); - } - async function githubAppJwt({ - id, - privateKey, - now = Math.floor(Date.now() / 1e3) - }) { - const nowWithSafetyMargin = now - 30; - const expiration = nowWithSafetyMargin + 60 * 10; - const payload = { - iat: nowWithSafetyMargin, - exp: expiration, - iss: id - }; - const token = await getToken({ - privateKey, - payload - }); - return { - appId: id, - expiration, - token - }; - } - exports.githubAppJwt = githubAppJwt; - } -}); - -// -var require_iterator = __commonJS({ - ""(exports, module) { - "use strict"; - module.exports = function(Yallist) { - Yallist.prototype[Symbol.iterator] = function* () { - for (let walker = this.head; walker; walker = walker.next) { - yield walker.value; - } - }; - }; - } -}); - -// -var require_yallist = __commonJS({ - ""(exports, module) { - "use strict"; - module.exports = Yallist; - Yallist.Node = Node; - Yallist.create = Yallist; - function Yallist(list) { - var self = this; - if (!(self instanceof Yallist)) { - self = new Yallist(); - } - self.tail = null; - self.head = null; - self.length = 0; - if (list && typeof list.forEach === "function") { - list.forEach(function(item) { - self.push(item); - }); - } else if (arguments.length > 0) { - for (var i = 0, l = arguments.length; i < l; i++) { - self.push(arguments[i]); - } - } - return self; - } - Yallist.prototype.removeNode = function(node) { - if (node.list !== this) { - throw new Error("removing node which does not belong to this list"); - } - var next = node.next; - var prev = node.prev; - if (next) { - next.prev = prev; - } - if (prev) { - prev.next = next; - } - if (node === this.head) { - this.head = next; - } - if (node === this.tail) { - this.tail = prev; - } - node.list.length--; - node.next = null; - node.prev = null; - node.list = null; - return next; - }; - Yallist.prototype.unshiftNode = function(node) { - if (node === this.head) { - return; - } - if (node.list) { - node.list.removeNode(node); - } - var head = this.head; - node.list = this; - node.next = head; - if (head) { - head.prev = node; - } - this.head = node; - if (!this.tail) { - this.tail = node; - } - this.length++; - }; - Yallist.prototype.pushNode = function(node) { - if (node === this.tail) { - return; - } - if (node.list) { - node.list.removeNode(node); - } - var tail = this.tail; - node.list = this; - node.prev = tail; - if (tail) { - tail.next = node; - } - this.tail = node; - if (!this.head) { - this.head = node; - } - this.length++; - }; - Yallist.prototype.push = function() { - for (var i = 0, l = arguments.length; i < l; i++) { - push(this, arguments[i]); - } - return this.length; - }; - Yallist.prototype.unshift = function() { - for (var i = 0, l = arguments.length; i < l; i++) { - unshift(this, arguments[i]); - } - return this.length; - }; - Yallist.prototype.pop = function() { - if (!this.tail) { - return void 0; - } - var res = this.tail.value; - this.tail = this.tail.prev; - if (this.tail) { - this.tail.next = null; - } else { - this.head = null; - } - this.length--; - return res; - }; - Yallist.prototype.shift = function() { - if (!this.head) { - return void 0; - } - var res = this.head.value; - this.head = this.head.next; - if (this.head) { - this.head.prev = null; - } else { - this.tail = null; - } - this.length--; - return res; - }; - Yallist.prototype.forEach = function(fn, thisp) { - thisp = thisp || this; - for (var walker = this.head, i = 0; walker !== null; i++) { - fn.call(thisp, walker.value, i, this); - walker = walker.next; - } - }; - Yallist.prototype.forEachReverse = function(fn, thisp) { - thisp = thisp || this; - for (var walker = this.tail, i = this.length - 1; walker !== null; i--) { - fn.call(thisp, walker.value, i, this); - walker = walker.prev; - } - }; - Yallist.prototype.get = function(n) { - for (var i = 0, walker = this.head; walker !== null && i < n; i++) { - walker = walker.next; - } - if (i === n && walker !== null) { - return walker.value; - } - }; - Yallist.prototype.getReverse = function(n) { - for (var i = 0, walker = this.tail; walker !== null && i < n; i++) { - walker = walker.prev; - } - if (i === n && walker !== null) { - return walker.value; - } - }; - Yallist.prototype.map = function(fn, thisp) { - thisp = thisp || this; - var res = new Yallist(); - for (var walker = this.head; walker !== null; ) { - res.push(fn.call(thisp, walker.value, this)); - walker = walker.next; - } - return res; - }; - Yallist.prototype.mapReverse = function(fn, thisp) { - thisp = thisp || this; - var res = new Yallist(); - for (var walker = this.tail; walker !== null; ) { - res.push(fn.call(thisp, walker.value, this)); - walker = walker.prev; - } - return res; - }; - Yallist.prototype.reduce = function(fn, initial) { - var acc; - var walker = this.head; - if (arguments.length > 1) { - acc = initial; - } else if (this.head) { - walker = this.head.next; - acc = this.head.value; - } else { - throw new TypeError("Reduce of empty list with no initial value"); - } - for (var i = 0; walker !== null; i++) { - acc = fn(acc, walker.value, i); - walker = walker.next; - } - return acc; - }; - Yallist.prototype.reduceReverse = function(fn, initial) { - var acc; - var walker = this.tail; - if (arguments.length > 1) { - acc = initial; - } else if (this.tail) { - walker = this.tail.prev; - acc = this.tail.value; - } else { - throw new TypeError("Reduce of empty list with no initial value"); - } - for (var i = this.length - 1; walker !== null; i--) { - acc = fn(acc, walker.value, i); - walker = walker.prev; - } - return acc; - }; - Yallist.prototype.toArray = function() { - var arr = new Array(this.length); - for (var i = 0, walker = this.head; walker !== null; i++) { - arr[i] = walker.value; - walker = walker.next; - } - return arr; - }; - Yallist.prototype.toArrayReverse = function() { - var arr = new Array(this.length); - for (var i = 0, walker = this.tail; walker !== null; i++) { - arr[i] = walker.value; - walker = walker.prev; - } - return arr; - }; - Yallist.prototype.slice = function(from, to) { - to = to || this.length; - if (to < 0) { - to += this.length; - } - from = from || 0; - if (from < 0) { - from += this.length; - } - var ret = new Yallist(); - if (to < from || to < 0) { - return ret; - } - if (from < 0) { - from = 0; - } - if (to > this.length) { - to = this.length; - } - for (var i = 0, walker = this.head; walker !== null && i < from; i++) { - walker = walker.next; - } - for (; walker !== null && i < to; i++, walker = walker.next) { - ret.push(walker.value); - } - return ret; - }; - Yallist.prototype.sliceReverse = function(from, to) { - to = to || this.length; - if (to < 0) { - to += this.length; - } - from = from || 0; - if (from < 0) { - from += this.length; - } - var ret = new Yallist(); - if (to < from || to < 0) { - return ret; - } - if (from < 0) { - from = 0; - } - if (to > this.length) { - to = this.length; - } - for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) { - walker = walker.prev; - } - for (; walker !== null && i > from; i--, walker = walker.prev) { - ret.push(walker.value); - } - return ret; - }; - Yallist.prototype.splice = function(start, deleteCount, ...nodes) { - if (start > this.length) { - start = this.length - 1; - } - if (start < 0) { - start = this.length + start; - } - for (var i = 0, walker = this.head; walker !== null && i < start; i++) { - walker = walker.next; - } - var ret = []; - for (var i = 0; walker && i < deleteCount; i++) { - ret.push(walker.value); - walker = this.removeNode(walker); - } - if (walker === null) { - walker = this.tail; - } - if (walker !== this.head && walker !== this.tail) { - walker = walker.prev; - } - for (var i = 0; i < nodes.length; i++) { - walker = insert(this, walker, nodes[i]); - } - return ret; - }; - Yallist.prototype.reverse = function() { - var head = this.head; - var tail = this.tail; - for (var walker = head; walker !== null; walker = walker.prev) { - var p = walker.prev; - walker.prev = walker.next; - walker.next = p; - } - this.head = tail; - this.tail = head; - return this; - }; - function insert(self, node, value) { - var inserted = node === self.head ? new Node(value, null, node, self) : new Node(value, node, node.next, self); - if (inserted.next === null) { - self.tail = inserted; - } - if (inserted.prev === null) { - self.head = inserted; - } - self.length++; - return inserted; - } - function push(self, item) { - self.tail = new Node(item, self.tail, null, self); - if (!self.head) { - self.head = self.tail; - } - self.length++; - } - function unshift(self, item) { - self.head = new Node(item, null, self.head, self); - if (!self.tail) { - self.tail = self.head; - } - self.length++; - } - function Node(value, prev, next, list) { - if (!(this instanceof Node)) { - return new Node(value, prev, next, list); - } - this.list = list; - this.value = value; - if (prev) { - prev.next = this; - this.prev = prev; - } else { - this.prev = null; - } - if (next) { - next.prev = this; - this.next = next; - } else { - this.next = null; - } - } - try { - require_iterator()(Yallist); - } catch (er) { - } - } -}); - -// -var require_lru_cache = __commonJS({ - ""(exports, module) { - "use strict"; - var Yallist = require_yallist(); - var MAX = Symbol("max"); - var LENGTH = Symbol("length"); - var LENGTH_CALCULATOR = Symbol("lengthCalculator"); - var ALLOW_STALE = Symbol("allowStale"); - var MAX_AGE = Symbol("maxAge"); - var DISPOSE = Symbol("dispose"); - var NO_DISPOSE_ON_SET = Symbol("noDisposeOnSet"); - var LRU_LIST = Symbol("lruList"); - var CACHE = Symbol("cache"); - var UPDATE_AGE_ON_GET = Symbol("updateAgeOnGet"); - var naiveLength = () => 1; - var LRUCache = class { - constructor(options) { - if (typeof options === "number") - options = { max: options }; - if (!options) - options = {}; - if (options.max && (typeof options.max !== "number" || options.max < 0)) - throw new TypeError("max must be a non-negative number"); - const max = this[MAX] = options.max || Infinity; - const lc = options.length || naiveLength; - this[LENGTH_CALCULATOR] = typeof lc !== "function" ? naiveLength : lc; - this[ALLOW_STALE] = options.stale || false; - if (options.maxAge && typeof options.maxAge !== "number") - throw new TypeError("maxAge must be a number"); - this[MAX_AGE] = options.maxAge || 0; - this[DISPOSE] = options.dispose; - this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false; - this[UPDATE_AGE_ON_GET] = options.updateAgeOnGet || false; - this.reset(); - } - set max(mL) { - if (typeof mL !== "number" || mL < 0) - throw new TypeError("max must be a non-negative number"); - this[MAX] = mL || Infinity; - trim(this); - } - get max() { - return this[MAX]; - } - set allowStale(allowStale) { - this[ALLOW_STALE] = !!allowStale; - } - get allowStale() { - return this[ALLOW_STALE]; - } - set maxAge(mA) { - if (typeof mA !== "number") - throw new TypeError("maxAge must be a non-negative number"); - this[MAX_AGE] = mA; - trim(this); - } - get maxAge() { - return this[MAX_AGE]; - } - set lengthCalculator(lC) { - if (typeof lC !== "function") - lC = naiveLength; - if (lC !== this[LENGTH_CALCULATOR]) { - this[LENGTH_CALCULATOR] = lC; - this[LENGTH] = 0; - this[LRU_LIST].forEach((hit) => { - hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key); - this[LENGTH] += hit.length; - }); - } - trim(this); - } - get lengthCalculator() { - return this[LENGTH_CALCULATOR]; - } - get length() { - return this[LENGTH]; - } - get itemCount() { - return this[LRU_LIST].length; - } - rforEach(fn, thisp) { - thisp = thisp || this; - for (let walker = this[LRU_LIST].tail; walker !== null; ) { - const prev = walker.prev; - forEachStep(this, fn, walker, thisp); - walker = prev; - } - } - forEach(fn, thisp) { - thisp = thisp || this; - for (let walker = this[LRU_LIST].head; walker !== null; ) { - const next = walker.next; - forEachStep(this, fn, walker, thisp); - walker = next; - } - } - keys() { - return this[LRU_LIST].toArray().map((k) => k.key); - } - values() { - return this[LRU_LIST].toArray().map((k) => k.value); - } - reset() { - if (this[DISPOSE] && this[LRU_LIST] && this[LRU_LIST].length) { - this[LRU_LIST].forEach((hit) => this[DISPOSE](hit.key, hit.value)); - } - this[CACHE] = /* @__PURE__ */ new Map(); - this[LRU_LIST] = new Yallist(); - this[LENGTH] = 0; - } - dump() { - return this[LRU_LIST].map((hit) => isStale(this, hit) ? false : { - k: hit.key, - v: hit.value, - e: hit.now + (hit.maxAge || 0) - }).toArray().filter((h) => h); - } - dumpLru() { - return this[LRU_LIST]; - } - set(key, value, maxAge) { - maxAge = maxAge || this[MAX_AGE]; - if (maxAge && typeof maxAge !== "number") - throw new TypeError("maxAge must be a number"); - const now = maxAge ? Date.now() : 0; - const len = this[LENGTH_CALCULATOR](value, key); - if (this[CACHE].has(key)) { - if (len > this[MAX]) { - del(this, this[CACHE].get(key)); - return false; - } - const node = this[CACHE].get(key); - const item = node.value; - if (this[DISPOSE]) { - if (!this[NO_DISPOSE_ON_SET]) - this[DISPOSE](key, item.value); - } - item.now = now; - item.maxAge = maxAge; - item.value = value; - this[LENGTH] += len - item.length; - item.length = len; - this.get(key); - trim(this); - return true; - } - const hit = new Entry(key, value, len, now, maxAge); - if (hit.length > this[MAX]) { - if (this[DISPOSE]) - this[DISPOSE](key, value); - return false; - } - this[LENGTH] += hit.length; - this[LRU_LIST].unshift(hit); - this[CACHE].set(key, this[LRU_LIST].head); - trim(this); - return true; - } - has(key) { - if (!this[CACHE].has(key)) - return false; - const hit = this[CACHE].get(key).value; - return !isStale(this, hit); - } - get(key) { - return get(this, key, true); - } - peek(key) { - return get(this, key, false); - } - pop() { - const node = this[LRU_LIST].tail; - if (!node) - return null; - del(this, node); - return node.value; - } - del(key) { - del(this, this[CACHE].get(key)); - } - load(arr) { - this.reset(); - const now = Date.now(); - for (let l = arr.length - 1; l >= 0; l--) { - const hit = arr[l]; - const expiresAt = hit.e || 0; - if (expiresAt === 0) - this.set(hit.k, hit.v); - else { - const maxAge = expiresAt - now; - if (maxAge > 0) { - this.set(hit.k, hit.v, maxAge); - } - } - } - } - prune() { - this[CACHE].forEach((value, key) => get(this, key, false)); - } - }; - var get = (self, key, doUse) => { - const node = self[CACHE].get(key); - if (node) { - const hit = node.value; - if (isStale(self, hit)) { - del(self, node); - if (!self[ALLOW_STALE]) - return void 0; - } else { - if (doUse) { - if (self[UPDATE_AGE_ON_GET]) - node.value.now = Date.now(); - self[LRU_LIST].unshiftNode(node); - } - } - return hit.value; - } - }; - var isStale = (self, hit) => { - if (!hit || !hit.maxAge && !self[MAX_AGE]) - return false; - const diff = Date.now() - hit.now; - return hit.maxAge ? diff > hit.maxAge : self[MAX_AGE] && diff > self[MAX_AGE]; - }; - var trim = (self) => { - if (self[LENGTH] > self[MAX]) { - for (let walker = self[LRU_LIST].tail; self[LENGTH] > self[MAX] && walker !== null; ) { - const prev = walker.prev; - del(self, walker); - walker = prev; - } - } - }; - var del = (self, node) => { - if (node) { - const hit = node.value; - if (self[DISPOSE]) - self[DISPOSE](hit.key, hit.value); - self[LENGTH] -= hit.length; - self[CACHE].delete(hit.key); - self[LRU_LIST].removeNode(node); - } - }; - var Entry = class { - constructor(key, value, length, now, maxAge) { - this.key = key; - this.value = value; - this.length = length; - this.now = now; - this.maxAge = maxAge || 0; - } - }; - var forEachStep = (self, fn, node, thisp) => { - let hit = node.value; - if (isStale(self, hit)) { - del(self, node); - if (!self[ALLOW_STALE]) - hit = void 0; - } - if (hit) - fn.call(thisp, hit.value, hit.key, self); - }; - module.exports = LRUCache; - } -}); - -// -var require_dist_node29 = __commonJS({ - ""(exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - function _interopDefault(ex) { - return ex && typeof ex === "object" && "default" in ex ? ex["default"] : ex; - } - var universalUserAgent = require_dist_node(); - var request = require_dist_node13(); - var authOauthApp = require_dist_node27(); - var deprecation = require_dist_node3(); - var universalGithubAppJwt = require_dist_node28(); - var LRU = _interopDefault(require_lru_cache()); - var authOauthUser = require_dist_node26(); - async function getAppAuthentication({ - appId, - privateKey, - timeDifference - }) { - try { - const appAuthentication = await universalGithubAppJwt.githubAppJwt({ - id: +appId, - privateKey, - now: timeDifference && Math.floor(Date.now() / 1e3) + timeDifference - }); - return { - type: "app", - token: appAuthentication.token, - appId: appAuthentication.appId, - expiresAt: new Date(appAuthentication.expiration * 1e3).toISOString() - }; - } catch (error2) { - if (privateKey === "-----BEGIN RSA PRIVATE KEY-----") { - throw new Error("The 'privateKey` option contains only the first line '-----BEGIN RSA PRIVATE KEY-----'. If you are setting it using a `.env` file, make sure it is set on a single line with newlines replaced by '\n'"); - } else { - throw error2; - } - } - } - function getCache() { - return new LRU({ - max: 15e3, - maxAge: 1e3 * 60 * 59 - }); - } - async function get(cache, options) { - const cacheKey = optionsToCacheKey(options); - const result = await cache.get(cacheKey); - if (!result) { - return; - } - const [token, createdAt, expiresAt, repositorySelection, permissionsString, singleFileName] = result.split("|"); - const permissions = options.permissions || permissionsString.split(/,/).reduce((permissions2, string) => { - if (/!$/.test(string)) { - permissions2[string.slice(0, -1)] = "write"; - } else { - permissions2[string] = "read"; - } - return permissions2; - }, {}); - return { - token, - createdAt, - expiresAt, - permissions, - repositoryIds: options.repositoryIds, - repositoryNames: options.repositoryNames, - singleFileName, - repositorySelection - }; - } - async function set(cache, options, data) { - const key = optionsToCacheKey(options); - const permissionsString = options.permissions ? "" : Object.keys(data.permissions).map((name) => `${name}${data.permissions[name] === "write" ? "!" : ""}`).join(","); - const value = [data.token, data.createdAt, data.expiresAt, data.repositorySelection, permissionsString, data.singleFileName].join("|"); - await cache.set(key, value); - } - function optionsToCacheKey({ - installationId, - permissions = {}, - repositoryIds = [], - repositoryNames = [] - }) { - const permissionsString = Object.keys(permissions).sort().map((name) => permissions[name] === "read" ? name : `${name}!`).join(","); - const repositoryIdsString = repositoryIds.sort().join(","); - const repositoryNamesString = repositoryNames.join(","); - return [installationId, repositoryIdsString, repositoryNamesString, permissionsString].filter(Boolean).join("|"); - } - function toTokenAuthentication({ - installationId, - token, - createdAt, - expiresAt, - repositorySelection, - permissions, - repositoryIds, - repositoryNames, - singleFileName - }) { - return Object.assign({ - type: "token", - tokenType: "installation", - token, - installationId, - permissions, - createdAt, - expiresAt, - repositorySelection - }, repositoryIds ? { - repositoryIds - } : null, repositoryNames ? { - repositoryNames - } : null, singleFileName ? { - singleFileName - } : null); - } - async function getInstallationAuthentication(state, options, customRequest) { - const installationId = Number(options.installationId || state.installationId); - if (!installationId) { - throw new Error("[@octokit/auth-app] installationId option is required for installation authentication."); - } - if (options.factory) { - const { - type, - factory, - oauthApp, - ...factoryAuthOptions - } = { - ...state, - ...options - }; - return factory(factoryAuthOptions); - } - const optionsWithInstallationTokenFromState = Object.assign({ - installationId - }, options); - if (!options.refresh) { - const result = await get(state.cache, optionsWithInstallationTokenFromState); - if (result) { - const { - token: token2, - createdAt: createdAt2, - expiresAt: expiresAt2, - permissions: permissions2, - repositoryIds: repositoryIds2, - repositoryNames: repositoryNames2, - singleFileName: singleFileName2, - repositorySelection: repositorySelection2 - } = result; - return toTokenAuthentication({ - installationId, - token: token2, - createdAt: createdAt2, - expiresAt: expiresAt2, - permissions: permissions2, - repositorySelection: repositorySelection2, - repositoryIds: repositoryIds2, - repositoryNames: repositoryNames2, - singleFileName: singleFileName2 - }); - } - } - const appAuthentication = await getAppAuthentication(state); - const request2 = customRequest || state.request; - const { - data: { - token, - expires_at: expiresAt, - repositories, - permissions: permissionsOptional, - repository_selection: repositorySelectionOptional, - single_file: singleFileName - } - } = await request2("POST /app/installations/{installation_id}/access_tokens", { - installation_id: installationId, - repository_ids: options.repositoryIds, - repositories: options.repositoryNames, - permissions: options.permissions, - mediaType: { - previews: ["machine-man"] - }, - headers: { - authorization: `bearer ${appAuthentication.token}` - } - }); - const permissions = permissionsOptional || {}; - const repositorySelection = repositorySelectionOptional || "all"; - const repositoryIds = repositories ? repositories.map((r) => r.id) : void 0; - const repositoryNames = repositories ? repositories.map((repo) => repo.name) : void 0; - const createdAt = new Date().toISOString(); - await set(state.cache, optionsWithInstallationTokenFromState, { - token, - createdAt, - expiresAt, - repositorySelection, - permissions, - repositoryIds, - repositoryNames, - singleFileName - }); - return toTokenAuthentication({ - installationId, - token, - createdAt, - expiresAt, - repositorySelection, - permissions, - repositoryIds, - repositoryNames, - singleFileName - }); - } - async function auth(state, authOptions) { - switch (authOptions.type) { - case "app": - return getAppAuthentication(state); - case "oauth": - state.log.warn( - new deprecation.Deprecation(`[@octokit/auth-app] {type: "oauth"} is deprecated. Use {type: "oauth-app"} instead`) - ); - case "oauth-app": - return state.oauthApp({ - type: "oauth-app" - }); - case "installation": - return getInstallationAuthentication(state, { - ...authOptions, - type: "installation" - }); - case "oauth-user": - return state.oauthApp(authOptions); - default: - throw new Error(`Invalid auth type: ${authOptions.type}`); - } - } - var PATHS = ["/app", "/app/hook/config", "/app/hook/deliveries", "/app/hook/deliveries/{delivery_id}", "/app/hook/deliveries/{delivery_id}/attempts", "/app/installations", "/app/installations/{installation_id}", "/app/installations/{installation_id}/access_tokens", "/app/installations/{installation_id}/suspended", "/marketplace_listing/accounts/{account_id}", "/marketplace_listing/plan", "/marketplace_listing/plans", "/marketplace_listing/plans/{plan_id}/accounts", "/marketplace_listing/stubbed/accounts/{account_id}", "/marketplace_listing/stubbed/plan", "/marketplace_listing/stubbed/plans", "/marketplace_listing/stubbed/plans/{plan_id}/accounts", "/orgs/{org}/installation", "/repos/{owner}/{repo}/installation", "/users/{username}/installation"]; - function routeMatcher(paths) { - const regexes = paths.map((p) => p.split("/").map((c) => c.startsWith("{") ? "(?:.+?)" : c).join("/")); - const regex = `^(?:${regexes.map((r) => `(?:${r})`).join("|")})[^/]*$`; - return new RegExp(regex, "i"); - } - var REGEX = routeMatcher(PATHS); - function requiresAppAuth(url) { - return !!url && REGEX.test(url); - } - var FIVE_SECONDS_IN_MS = 5 * 1e3; - function isNotTimeSkewError(error2) { - return !(error2.message.match(/'Expiration time' claim \('exp'\) must be a numeric value representing the future time at which the assertion expires/) || error2.message.match(/'Issued at' claim \('iat'\) must be an Integer representing the time that the assertion was issued/)); - } - async function hook(state, request2, route, parameters) { - const endpoint = request2.endpoint.merge(route, parameters); - const url = endpoint.url; - if (/\/login\/oauth\/access_token$/.test(url)) { - return request2(endpoint); - } - if (requiresAppAuth(url.replace(request2.endpoint.DEFAULTS.baseUrl, ""))) { - const { - token: token2 - } = await getAppAuthentication(state); - endpoint.headers.authorization = `bearer ${token2}`; - let response; - try { - response = await request2(endpoint); - } catch (error2) { - if (isNotTimeSkewError(error2)) { - throw error2; - } - if (typeof error2.response.headers.date === "undefined") { - throw error2; - } - const diff = Math.floor((Date.parse(error2.response.headers.date) - Date.parse(new Date().toString())) / 1e3); - state.log.warn(error2.message); - state.log.warn(`[@octokit/auth-app] GitHub API time and system time are different by ${diff} seconds. Retrying request with the difference accounted for.`); - const { - token: token3 - } = await getAppAuthentication({ - ...state, - timeDifference: diff - }); - endpoint.headers.authorization = `bearer ${token3}`; - return request2(endpoint); - } - return response; - } - if (authOauthUser.requiresBasicAuth(url)) { - const authentication = await state.oauthApp({ - type: "oauth-app" - }); - endpoint.headers.authorization = authentication.headers.authorization; - return request2(endpoint); - } - const { - token, - createdAt - } = await getInstallationAuthentication( - state, - {}, - request2 - ); - endpoint.headers.authorization = `token ${token}`; - return sendRequestWithRetries(state, request2, endpoint, createdAt); - } - async function sendRequestWithRetries(state, request2, options, createdAt, retries = 0) { - const timeSinceTokenCreationInMs = +new Date() - +new Date(createdAt); - try { - return await request2(options); - } catch (error2) { - if (error2.status !== 401) { - throw error2; - } - if (timeSinceTokenCreationInMs >= FIVE_SECONDS_IN_MS) { - if (retries > 0) { - error2.message = `After ${retries} retries within ${timeSinceTokenCreationInMs / 1e3}s of creating the installation access token, the response remains 401. At this point, the cause may be an authentication problem or a system outage. Please check https://www.githubstatus.com for status information`; - } - throw error2; - } - ++retries; - const awaitTime = retries * 1e3; - state.log.warn(`[@octokit/auth-app] Retrying after 401 response to account for token replication delay (retry: ${retries}, wait: ${awaitTime / 1e3}s)`); - await new Promise((resolve) => setTimeout(resolve, awaitTime)); - return sendRequestWithRetries(state, request2, options, createdAt, retries); - } - } - var VERSION = "4.0.5"; - function createAppAuth2(options) { - if (!options.appId) { - throw new Error("[@octokit/auth-app] appId option is required"); - } - if (!options.privateKey) { - throw new Error("[@octokit/auth-app] privateKey option is required"); - } - if ("installationId" in options && !options.installationId) { - throw new Error("[@octokit/auth-app] installationId is set to a falsy value"); - } - const log = Object.assign({ - warn: console.warn.bind(console) - }, options.log); - const request$1 = options.request || request.request.defaults({ - headers: { - "user-agent": `octokit-auth-app.js/${VERSION} ${universalUserAgent.getUserAgent()}` - } - }); - const state = Object.assign({ - request: request$1, - cache: getCache() - }, options, options.installationId ? { - installationId: Number(options.installationId) - } : {}, { - log, - oauthApp: authOauthApp.createOAuthAppAuth({ - clientType: "github-app", - clientId: options.clientId || "", - clientSecret: options.clientSecret || "", - request: request$1 - }) - }); - return Object.assign(auth.bind(null, state), { - hook: hook.bind(null, state) - }); - } - Object.defineProperty(exports, "createOAuthUserAuth", { - enumerable: true, - get: function() { - return authOauthUser.createOAuthUserAuth; - } - }); - exports.createAppAuth = createAppAuth2; + exports.Octokit = Octokit2; } }); // var core = __toESM(require_core()); -var import_github4 = __toESM(require_github()); +var import_github3 = __toESM(require_github()); import { createHash } from "crypto"; import { existsSync, readFileSync } from "fs"; @@ -24695,46 +17188,13 @@ Alternatively, a new token can be created at: ${GITHUB_TOKEN_GENERATE_URL} AuthenticatedGitClient._token = null; AuthenticatedGitClient._authenticatedInstance = null; -// -var import_core = __toESM(require_core()); -var import_rest2 = __toESM(require_dist_node20()); -var import_auth_app = __toESM(require_dist_node29()); -var import_github3 = __toESM(require_github()); -var ANGULAR_ROBOT = [43341, "angular-robot-key"]; -async function getJwtAuthedAppClient([appId, inputKey]) { - const privateKey = (0, import_core.getInput)(inputKey, { required: true }); - return new import_rest2.Octokit({ - authStrategy: import_auth_app.createAppAuth, - auth: { appId, privateKey } - }); -} -async function getAuthTokenFor(app) { - const github = await getJwtAuthedAppClient(app); - const { id: installationId } = (await github.apps.getRepoInstallation({ - ...import_github3.context.repo - })).data; - const { token } = (await github.rest.apps.createInstallationAccessToken({ - installation_id: installationId - })).data; - return token; -} -async function revokeActiveInstallationToken(githubOrToken) { - if (typeof githubOrToken === "string") { - await new import_rest2.Octokit({ auth: githubOrToken }).apps.revokeInstallationAccessToken(); - } else { - await githubOrToken.apps.revokeInstallationAccessToken(); - } - (0, import_core.info)("Revoked installation token used for Angular Robot."); -} - // main(); async function main() { - let authToken = null; try { core.setOutput("result", "nothing"); core.setOutput("pr-number", ""); - const repo = { owner: import_github4.context.repo.owner, name: import_github4.context.repo.repo }; + const repo = { owner: import_github3.context.repo.owner, name: import_github3.context.repo.repo }; const config = { github: { ...repo, @@ -24742,8 +17202,8 @@ async function main() { } }; setConfig(config); - authToken = await getAuthTokenFor(ANGULAR_ROBOT); - AuthenticatedGitClient.configure(authToken); + const accessToken = core.getInput("angular-robot-token", { required: true }); + AuthenticatedGitClient.configure(accessToken); const git = await AuthenticatedGitClient.get(); git.run(["config", "user.email", "angular-robot@google.com"]); git.run(["config", "user.name", "Angular Robot"]); @@ -24845,10 +17305,6 @@ ${prBody}`; core.setOutput("result", "failed"); core.error(err); core.setFailed(err.message); - } finally { - if (authToken !== null) { - await revokeActiveInstallationToken(authToken); - } } } async function cleanUpObsoleteBranches(git, repo, forkRepo, branchPrefix) { @@ -24897,7 +17353,6 @@ function toGithubSearchQuery(params2) { * Copyright (c) 2014-2017, Jon Schlinkert. * Released under the MIT License. */ -/*! safe-buffer. MIT License. Feross Aboukhadijeh */ /** * @license * Copyright Google LLC All Rights Reserved.