From 3378cda945da322a8db4b193e19d46352ebe2de5 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 4 Sep 2024 04:41:08 +0000 Subject: [PATCH] build(release): 1.10.4 [skip ci] ## [1.10.4](https://github.com/actions/create-github-app-token/compare/v1.10.3...v1.10.4) (2024-09-04) ### Bug Fixes * **deps:** bump the production-dependencies group across 1 directory with 3 updates ([#166](https://github.com/actions/create-github-app-token/issues/166)) ([e177c20](https://github.com/actions/create-github-app-token/commit/e177c20e0f736e68f4a37ffee6aa32c73da13988)), closes [#641](https://github.com/actions/create-github-app-token/issues/641) [#641](https://github.com/actions/create-github-app-token/issues/641) [#639](https://github.com/actions/create-github-app-token/issues/639) [#638](https://github.com/actions/create-github-app-token/issues/638) [#637](https://github.com/actions/create-github-app-token/issues/637) [#636](https://github.com/actions/create-github-app-token/issues/636) [#633](https://github.com/actions/create-github-app-token/issues/633) [#632](https://github.com/actions/create-github-app-token/issues/632) [#631](https://github.com/actions/create-github-app-token/issues/631) [#630](https://github.com/actions/create-github-app-token/issues/630) [#629](https://github.com/actions/create-github-app-token/issues/629) [#714](https://github.com/actions/create-github-app-token/issues/714) [#711](https://github.com/actions/create-github-app-token/issues/711) [#714](https://github.com/actions/create-github-app-token/issues/714) [#716](https://github.com/actions/create-github-app-token/issues/716) [#711](https://github.com/actions/create-github-app-token/issues/711) [#712](https://github.com/actions/create-github-app-token/issues/712) [#710](https://github.com/actions/create-github-app-token/issues/710) [#709](https://github.com/actions/create-github-app-token/issues/709) [#708](https://github.com/actions/create-github-app-token/issues/708) [#702](https://github.com/actions/create-github-app-token/issues/702) [#706](https://github.com/actions/create-github-app-token/issues/706) [#3458](https://github.com/actions/create-github-app-token/issues/3458) [#3461](https://github.com/actions/create-github-app-token/issues/3461) [#3460](https://github.com/actions/create-github-app-token/issues/3460) [#3454](https://github.com/actions/create-github-app-token/issues/3454) [#3450](https://github.com/actions/create-github-app-token/issues/3450) [#3445](https://github.com/actions/create-github-app-token/issues/3445) --- dist/main.cjs | 565 +++++++++++++++++++++++++------------------------- dist/post.cjs | 561 ++++++++++++++++++++++++------------------------- package.json | 2 +- 3 files changed, 571 insertions(+), 557 deletions(-) diff --git a/dist/main.cjs b/dist/main.cjs index 474eaef..515e8be 100644 --- a/dist/main.cjs +++ b/dist/main.cjs @@ -2239,6 +2239,7 @@ var require_decodeText = __commonJS({ return decoders.utf8; case "latin1": case "ascii": + // TODO: Make these a separate, strict decoder? case "us-ascii": case "iso-8859-1": case "iso8859-1": @@ -2938,6 +2939,7 @@ var require_basename = __commonJS({ for (var i = path.length - 1; i >= 0; --i) { switch (path.charCodeAt(i)) { case 47: + // '/' case 92: path = path.slice(i + 1); return path === ".." || path === "." ? "" : path; @@ -4172,7 +4174,21 @@ var require_util2 = __commonJS({ return referrerOrigin; } case "strict-origin": + // eslint-disable-line + /** + * 1. If referrerURL is a potentially trustworthy URL and + * request’s current URL is not a potentially trustworthy URL, + * then return no referrer. + * 2. Return referrerOrigin + */ case "no-referrer-when-downgrade": + // eslint-disable-line + /** + * 1. If referrerURL is a potentially trustworthy URL and + * request’s current URL is not a potentially trustworthy URL, + * then return no referrer. + * 2. Return referrerOrigin + */ default: return isNonPotentiallyTrustWorthy ? "no-referrer" : referrerOrigin; } @@ -20172,6 +20188,27 @@ var require_util8 = __commonJS({ } var kEnumerableProperty = /* @__PURE__ */ Object.create(null); kEnumerableProperty.enumerable = true; + var normalizedMethodRecordsBase = { + delete: "DELETE", + DELETE: "DELETE", + get: "GET", + GET: "GET", + head: "HEAD", + HEAD: "HEAD", + options: "OPTIONS", + OPTIONS: "OPTIONS", + post: "POST", + POST: "POST", + put: "PUT", + PUT: "PUT" + }; + var normalizedMethodRecords = { + ...normalizedMethodRecordsBase, + patch: "patch", + PATCH: "PATCH" + }; + Object.setPrototypeOf(normalizedMethodRecordsBase, null); + Object.setPrototypeOf(normalizedMethodRecords, null); module2.exports = { kEnumerableProperty, nop, @@ -20210,6 +20247,8 @@ var require_util8 = __commonJS({ isValidHeaderValue, isTokenCharCode, parseRangeHeader, + normalizedMethodRecordsBase, + normalizedMethodRecords, isValidPort, isHttpOrHttpsPrefixed, nodeMajor, @@ -20425,7 +20464,8 @@ var require_request3 = __commonJS({ isBlobLike, buildURL, validateHandler, - getServerName + getServerName, + normalizedMethodRecords } = require_util8(); var { channels } = require_diagnostics(); var { headerNameLowerCasedRecord } = require_constants6(); @@ -20452,12 +20492,12 @@ var require_request3 = __commonJS({ throw new InvalidArgumentError("path must be a string"); } else if (path[0] !== "/" && !(path.startsWith("http://") || path.startsWith("https://")) && method !== "CONNECT") { throw new InvalidArgumentError("path must be an absolute URL or start with a slash"); - } else if (invalidPathRegex.exec(path) !== null) { + } else if (invalidPathRegex.test(path)) { throw new InvalidArgumentError("invalid request path"); } if (typeof method !== "string") { throw new InvalidArgumentError("method must be a string"); - } else if (!isValidHTTPToken(method)) { + } else if (normalizedMethodRecords[method] === void 0 && !isValidHTTPToken(method)) { throw new InvalidArgumentError("invalid request method"); } if (upgrade && typeof upgrade !== "string") { @@ -21002,7 +21042,7 @@ var require_connect2 = __commonJS({ } }; } - function buildConnector({ allowH2, maxCachedSessions, socketPath, timeout, ...opts }) { + function buildConnector({ allowH2, maxCachedSessions, socketPath, timeout, session: customSession, ...opts }) { if (maxCachedSessions != null && (!Number.isInteger(maxCachedSessions) || maxCachedSessions < 0)) { throw new InvalidArgumentError("maxCachedSessions must be a positive integer or zero"); } @@ -21018,7 +21058,7 @@ var require_connect2 = __commonJS({ } servername = servername || options.servername || util.getServerName(host) || null; const sessionKey = servername || hostname; - const session = sessionCache.get(sessionKey) || null; + const session = customSession || sessionCache.get(sessionKey) || null; assert(sessionKey); socket = tls.connect({ highWaterMark: 16384, @@ -22536,7 +22576,7 @@ var require_util9 = __commonJS({ var { getGlobalOrigin } = require_global3(); var { collectASequenceOfCodePoints, collectAnHTTPQuotedString, removeChars, parseMIMEType } = require_data_url(); var { performance: performance2 } = require("node:perf_hooks"); - var { isBlobLike, ReadableStreamFrom, isValidHTTPToken } = require_util8(); + var { isBlobLike, ReadableStreamFrom, isValidHTTPToken, normalizedMethodRecordsBase } = require_util8(); var assert = require("node:assert"); var { isUint8Array } = require("node:util/types"); var { webidl } = require_webidl2(); @@ -22643,7 +22683,7 @@ var require_util9 = __commonJS({ } function appendRequestOriginHeader(request2) { let serializedOrigin = request2.origin; - if (serializedOrigin === "client") { + if (serializedOrigin === "client" || serializedOrigin === void 0) { return; } if (request2.responseTainting === "cors" || request2.mode === "websocket") { @@ -22761,7 +22801,21 @@ var require_util9 = __commonJS({ return referrerOrigin; } case "strict-origin": + // eslint-disable-line + /** + * 1. If referrerURL is a potentially trustworthy URL and + * request’s current URL is not a potentially trustworthy URL, + * then return no referrer. + * 2. Return referrerOrigin + */ case "no-referrer-when-downgrade": + // eslint-disable-line + /** + * 1. If referrerURL is a potentially trustworthy URL and + * request’s current URL is not a potentially trustworthy URL, + * then return no referrer. + * 2. Return referrerOrigin + */ default: return isNonPotentiallyTrustWorthy ? "no-referrer" : referrerOrigin; } @@ -22924,29 +22978,8 @@ var require_util9 = __commonJS({ function isCancelled(fetchParams) { return fetchParams.controller.state === "aborted" || fetchParams.controller.state === "terminated"; } - var normalizeMethodRecordBase = { - delete: "DELETE", - DELETE: "DELETE", - get: "GET", - GET: "GET", - head: "HEAD", - HEAD: "HEAD", - options: "OPTIONS", - OPTIONS: "OPTIONS", - post: "POST", - POST: "POST", - put: "PUT", - PUT: "PUT" - }; - var normalizeMethodRecord = { - ...normalizeMethodRecordBase, - patch: "patch", - PATCH: "PATCH" - }; - Object.setPrototypeOf(normalizeMethodRecordBase, null); - Object.setPrototypeOf(normalizeMethodRecord, null); function normalizeMethod(method) { - return normalizeMethodRecordBase[method.toLowerCase()] ?? method; + return normalizedMethodRecordsBase[method.toLowerCase()] ?? method; } function serializeJavascriptValueToJSONString(value) { const result = JSON.stringify(value); @@ -23083,7 +23116,7 @@ var require_util9 = __commonJS({ } }); } - async function fullyReadBody(body, processBody, processBodyError, shouldClone) { + async function fullyReadBody(body, processBody, processBodyError) { const successSteps = processBody; const errorSteps = processBodyError; let reader; @@ -23094,7 +23127,7 @@ var require_util9 = __commonJS({ return; } try { - successSteps(await readAllBytes(reader, shouldClone)); + successSteps(await readAllBytes(reader)); } catch (e) { errorSteps(e); } @@ -23117,19 +23150,12 @@ var require_util9 = __commonJS({ assert(!invalidIsomorphicEncodeValueRegex.test(input)); return input; } - async function readAllBytes(reader, shouldClone) { + async function readAllBytes(reader) { const bytes = []; let byteLength = 0; while (true) { const { done, value: chunk } = await reader.read(); if (done) { - if (bytes.length === 1) { - const { buffer, byteOffset, byteLength: byteLength2 } = bytes[0]; - if (shouldClone === false) { - return Buffer.from(buffer, byteOffset, byteLength2); - } - return Buffer.from(buffer.slice(byteOffset, byteOffset + byteLength2), 0, byteLength2); - } return Buffer.concat(bytes, byteLength); } if (!isUint8Array(chunk)) { @@ -23392,7 +23418,6 @@ var require_util9 = __commonJS({ urlHasHttpsScheme, urlIsHttpHttpsScheme, readAllBytes, - normalizeMethodRecord, simpleRangeHeaderValue, buildContentRange, parseMetadata, @@ -23892,11 +23917,23 @@ var require_body2 = __commonJS({ var { webidl } = require_webidl2(); var { Blob: Blob2 } = require("node:buffer"); var assert = require("node:assert"); - var { isErrored } = require_util8(); + var { isErrored, isDisturbed } = require("node:stream"); var { isArrayBuffer } = require("node:util/types"); var { serializeAMimeType } = require_data_url(); var { multipartFormDataParser } = require_formdata_parser(); var textEncoder = new TextEncoder(); + function noop() { + } + var hasFinalizationRegistry = globalThis.FinalizationRegistry && process.version.indexOf("v18") !== 0; + var streamRegistry; + if (hasFinalizationRegistry) { + streamRegistry = new FinalizationRegistry((weakRef) => { + const stream = weakRef.deref(); + if (stream && !stream.locked && !isDisturbed(stream) && !isErrored(stream)) { + stream.cancel("Response object has been garbage collected").catch(noop); + } + }); + } function extractBody(object, keepalive = false) { let stream = null; if (object instanceof ReadableStream) { @@ -24039,8 +24076,11 @@ Content-Type: ${value.type || "application/octet-stream"}\r } return extractBody(object, keepalive); } - function cloneBody(body) { + function cloneBody(instance, body) { const [out1, out2] = body.stream.tee(); + if (hasFinalizationRegistry) { + streamRegistry.register(instance, new WeakRef(out1)); + } body.stream = out1; return { stream: out2, @@ -24064,18 +24104,18 @@ Content-Type: ${value.type || "application/octet-stream"}\r mimeType = serializeAMimeType(mimeType); } return new Blob2([bytes], { type: mimeType }); - }, instance, false); + }, instance); }, arrayBuffer() { return consumeBody(this, (bytes) => { - return bytes.buffer; - }, instance, true); + return new Uint8Array(bytes).buffer; + }, instance); }, text() { - return consumeBody(this, utf8DecodeBytes, instance, false); + return consumeBody(this, utf8DecodeBytes, instance); }, json() { - return consumeBody(this, parseJSONFromBytes, instance, false); + return consumeBody(this, parseJSONFromBytes, instance); }, formData() { return consumeBody(this, (value) => { @@ -24104,12 +24144,12 @@ Content-Type: ${value.type || "application/octet-stream"}\r throw new TypeError( 'Content-Type was not one of "multipart/form-data" or "application/x-www-form-urlencoded".' ); - }, instance, false); + }, instance); }, bytes() { return consumeBody(this, (bytes) => { - return new Uint8Array(bytes.buffer, 0, bytes.byteLength); - }, instance, true); + return new Uint8Array(bytes); + }, instance); } }; return methods; @@ -24117,9 +24157,9 @@ Content-Type: ${value.type || "application/octet-stream"}\r function mixinBody(prototype) { Object.assign(prototype.prototype, bodyMixinMethods(prototype)); } - async function consumeBody(object, convertBytesToJSValue, instance, shouldClone) { + async function consumeBody(object, convertBytesToJSValue, instance) { webidl.brandCheck(object, instance); - if (bodyUnusable(object[kState].body)) { + if (bodyUnusable(object)) { throw new TypeError("Body is unusable: Body has already been read"); } throwIfAborted(object[kState]); @@ -24136,10 +24176,11 @@ Content-Type: ${value.type || "application/octet-stream"}\r successSteps(Buffer.allocUnsafe(0)); return promise.promise; } - await fullyReadBody(object[kState].body, successSteps, errorSteps, shouldClone); + await fullyReadBody(object[kState].body, successSteps, errorSteps); return promise.promise; } - function bodyUnusable(body) { + function bodyUnusable(object) { + const body = object[kState].body; return body != null && (body.stream.locked || util.isDisturbed(body.stream)); } function parseJSONFromBytes(bytes) { @@ -24157,7 +24198,10 @@ Content-Type: ${value.type || "application/octet-stream"}\r extractBody, safelyExtractBody, cloneBody, - mixinBody + mixinBody, + streamRegistry, + hasFinalizationRegistry, + bodyUnusable }; } }); @@ -24889,25 +24933,25 @@ upgrade: ${upgrade}\r channels.sendHeaders.publish({ request: request2, headers: header, socket }); } if (!body || bodyLength === 0) { - writeBuffer({ abort, body: null, client, request: request2, socket, contentLength, header, expectsPayload }); + writeBuffer(abort, null, client, request2, socket, contentLength, header, expectsPayload); } else if (util.isBuffer(body)) { - writeBuffer({ abort, body, client, request: request2, socket, contentLength, header, expectsPayload }); + writeBuffer(abort, body, client, request2, socket, contentLength, header, expectsPayload); } else if (util.isBlobLike(body)) { if (typeof body.stream === "function") { - writeIterable({ abort, body: body.stream(), client, request: request2, socket, contentLength, header, expectsPayload }); + writeIterable(abort, body.stream(), client, request2, socket, contentLength, header, expectsPayload); } else { - writeBlob({ abort, body, client, request: request2, socket, contentLength, header, expectsPayload }); + writeBlob(abort, body, client, request2, socket, contentLength, header, expectsPayload); } } else if (util.isStream(body)) { - writeStream({ abort, body, client, request: request2, socket, contentLength, header, expectsPayload }); + writeStream(abort, body, client, request2, socket, contentLength, header, expectsPayload); } else if (util.isIterable(body)) { - writeIterable({ abort, body, client, request: request2, socket, contentLength, header, expectsPayload }); + writeIterable(abort, body, client, request2, socket, contentLength, header, expectsPayload); } else { assert(false); } return true; } - function writeStream({ abort, body, client, request: request2, socket, contentLength, header, expectsPayload }) { + function writeStream(abort, body, client, request2, socket, contentLength, header, expectsPayload) { assert(contentLength !== 0 || client[kRunning] === 0, "stream body cannot be pipelined"); let finished = false; const writer = new AsyncWriter({ abort, socket, request: request2, contentLength, client, expectsPayload, header }); @@ -24976,7 +25020,7 @@ upgrade: ${upgrade}\r setImmediate(onClose); } } - function writeBuffer({ abort, body, client, request: request2, socket, contentLength, header, expectsPayload }) { + function writeBuffer(abort, body, client, request2, socket, contentLength, header, expectsPayload) { try { if (!body) { if (contentLength === 0) { @@ -25007,7 +25051,7 @@ upgrade: ${upgrade}\r abort(err); } } - async function writeBlob({ abort, body, client, request: request2, socket, contentLength, header, expectsPayload }) { + async function writeBlob(abort, body, client, request2, socket, contentLength, header, expectsPayload) { assert(contentLength === body.size, "blob body must have content length"); try { if (contentLength != null && contentLength !== body.size) { @@ -25030,7 +25074,7 @@ upgrade: ${upgrade}\r abort(err); } } - async function writeIterable({ abort, body, client, request: request2, socket, contentLength, header, expectsPayload }) { + async function writeIterable(abort, body, client, request2, socket, contentLength, header, expectsPayload) { assert(contentLength !== 0 || client[kRunning] === 0, "iterator body cannot be pipelined"); let callback = null; function onDrain() { @@ -25493,81 +25537,79 @@ var require_client_h2 = __commonJS({ return true; function writeBodyH2() { if (!body || contentLength === 0) { - writeBuffer({ + writeBuffer( abort, + stream, + null, client, - request: request2, + request2, + client[kSocket], contentLength, - expectsPayload, - h2stream: stream, - body: null, - socket: client[kSocket] - }); + expectsPayload + ); } else if (util.isBuffer(body)) { - writeBuffer({ + writeBuffer( abort, + stream, + body, client, - request: request2, + request2, + client[kSocket], contentLength, - body, - expectsPayload, - h2stream: stream, - socket: client[kSocket] - }); + expectsPayload + ); } else if (util.isBlobLike(body)) { if (typeof body.stream === "function") { - writeIterable({ + writeIterable( abort, + stream, + body.stream(), client, - request: request2, + request2, + client[kSocket], contentLength, - expectsPayload, - h2stream: stream, - body: body.stream(), - socket: client[kSocket] - }); + expectsPayload + ); } else { - writeBlob({ + writeBlob( abort, + stream, body, client, - request: request2, + request2, + client[kSocket], contentLength, - expectsPayload, - h2stream: stream, - socket: client[kSocket] - }); + expectsPayload + ); } } else if (util.isStream(body)) { - writeStream({ + writeStream( abort, + client[kSocket], + expectsPayload, + stream, body, client, - request: request2, - contentLength, - expectsPayload, - socket: client[kSocket], - h2stream: stream, - header: "" - }); + request2, + contentLength + ); } else if (util.isIterable(body)) { - writeIterable({ + writeIterable( abort, + stream, body, client, - request: request2, + request2, + client[kSocket], contentLength, - expectsPayload, - header: "", - h2stream: stream, - socket: client[kSocket] - }); + expectsPayload + ); } else { assert(false); } } } - function writeBuffer({ abort, h2stream, body, client, request: request2, socket, contentLength, expectsPayload }) { + function writeBuffer(abort, h2stream, body, client, request2, socket, contentLength, expectsPayload) { try { if (body != null && util.isBuffer(body)) { assert(contentLength === body.byteLength, "buffer body must have content length"); @@ -25586,7 +25628,7 @@ var require_client_h2 = __commonJS({ abort(error); } } - function writeStream({ abort, socket, expectsPayload, h2stream, body, client, request: request2, contentLength }) { + function writeStream(abort, socket, expectsPayload, h2stream, body, client, request2, contentLength) { assert(contentLength !== 0 || client[kRunning] === 0, "stream body cannot be pipelined"); const pipe = pipeline( body, @@ -25610,7 +25652,7 @@ var require_client_h2 = __commonJS({ request2.onBodySent(chunk); } } - async function writeBlob({ abort, h2stream, body, client, request: request2, socket, contentLength, expectsPayload }) { + async function writeBlob(abort, h2stream, body, client, request2, socket, contentLength, expectsPayload) { assert(contentLength === body.size, "blob body must have content length"); try { if (contentLength != null && contentLength !== body.size) { @@ -25631,7 +25673,7 @@ var require_client_h2 = __commonJS({ abort(err); } } - async function writeIterable({ abort, h2stream, body, client, request: request2, socket, contentLength, expectsPayload }) { + async function writeIterable(abort, h2stream, body, client, request2, socket, contentLength, expectsPayload) { assert(contentLength !== 0 || client[kRunning] === 0, "iterator body cannot be pipelined"); let callback = null; function onDrain() { @@ -26713,8 +26755,13 @@ var require_balanced_pool2 = __commonJS({ var kMaxWeightPerServer = Symbol("kMaxWeightPerServer"); var kErrorPenalty = Symbol("kErrorPenalty"); function getGreatestCommonDivisor(a, b) { - if (b === 0) return a; - return getGreatestCommonDivisor(b, a % b); + if (a === 0) return b; + while (b !== 0) { + const t = b; + b = a % b; + a = t; + } + return a; } function defaultFactory(origin, opts) { return new Pool(origin, opts); @@ -26768,7 +26815,11 @@ var require_balanced_pool2 = __commonJS({ return this; } _updateBalancedPoolStats() { - this[kGreatestCommonDivisor] = this[kClients].map((p) => p[kWeight]).reduce(getGreatestCommonDivisor, 0); + let result = 0; + for (let i = 0; i < this[kClients].length; i++) { + result = getGreatestCommonDivisor(this[kClients][i][kWeight], result); + } + this[kGreatestCommonDivisor] = result; } removeUpstream(upstream) { const upstreamOrigin = parseOrigin(upstream).origin; @@ -27376,7 +27427,7 @@ var require_retry_handler = __commonJS({ this.abort( new RequestRetryError("Content-Range mismatch", statusCode, { headers, - count: this.retryCount + data: { count: this.retryCount } }) ); return false; @@ -27385,7 +27436,7 @@ var require_retry_handler = __commonJS({ this.abort( new RequestRetryError("ETag mismatch", statusCode, { headers, - count: this.retryCount + data: { count: this.retryCount } }) ); return false; @@ -30153,7 +30204,7 @@ var require_response2 = __commonJS({ "node_modules/undici/lib/web/fetch/response.js"(exports2, module2) { "use strict"; var { Headers, HeadersList, fill, getHeadersGuard, setHeadersGuard, setHeadersList } = require_headers2(); - var { extractBody, cloneBody, mixinBody } = require_body2(); + var { extractBody, cloneBody, mixinBody, hasFinalizationRegistry, streamRegistry, bodyUnusable } = require_body2(); var util = require_util8(); var nodeUtil = require("node:util"); var { kEnumerableProperty } = util; @@ -30178,19 +30229,7 @@ var require_response2 = __commonJS({ var { kConstruct } = require_symbols6(); var assert = require("node:assert"); var { types } = require("node:util"); - var { isDisturbed, isErrored } = require("node:stream"); var textEncoder = new TextEncoder("utf-8"); - var hasFinalizationRegistry = globalThis.FinalizationRegistry && process.version.indexOf("v18") !== 0; - var registry; - if (hasFinalizationRegistry) { - registry = new FinalizationRegistry((stream) => { - if (!stream.locked && !isDisturbed(stream) && !isErrored(stream)) { - stream.cancel("Response object has been garbage collected").catch(noop); - } - }); - } - function noop() { - } var Response = class _Response { // Creates network error Response. static error() { @@ -30302,7 +30341,7 @@ var require_response2 = __commonJS({ // Returns a clone of response. clone() { webidl.brandCheck(this, _Response); - if (this.bodyUsed || this.body?.locked) { + if (bodyUnusable(this)) { throw webidl.errors.exception({ header: "Response.clone", message: "Body has already been consumed." @@ -30361,7 +30400,7 @@ var require_response2 = __commonJS({ } const newResponse = makeResponse({ ...response, body: null }); if (response.body != null) { - newResponse.body = cloneBody(response.body); + newResponse.body = cloneBody(newResponse, response.body); } return newResponse; } @@ -30486,7 +30525,7 @@ var require_response2 = __commonJS({ setHeadersList(response[kHeaders], innerResponse.headersList); setHeadersGuard(response[kHeaders], guard); if (hasFinalizationRegistry && innerResponse.body?.stream) { - registry.register(response, innerResponse.body.stream); + streamRegistry.register(response, new WeakRef(innerResponse.body.stream)); } return response; } @@ -30601,7 +30640,7 @@ var require_dispatcher_weakref2 = __commonJS({ var require_request4 = __commonJS({ "node_modules/undici/lib/web/fetch/request.js"(exports2, module2) { "use strict"; - var { extractBody, mixinBody, cloneBody } = require_body2(); + var { extractBody, mixinBody, cloneBody, bodyUnusable } = require_body2(); var { Headers, fill: fillHeaders, HeadersList, setHeadersGuard, getHeadersGuard, setHeadersList, getHeadersList } = require_headers2(); var { FinalizationRegistry: FinalizationRegistry2 } = require_dispatcher_weakref2()(); var util = require_util8(); @@ -30609,9 +30648,7 @@ var require_request4 = __commonJS({ var { isValidHTTPToken, sameOrigin, - normalizeMethod, - environmentSettingsObject, - normalizeMethodRecord + environmentSettingsObject } = require_util9(); var { forbiddenMethodsSet, @@ -30623,7 +30660,7 @@ var require_request4 = __commonJS({ requestCache, requestDuplex } = require_constants8(); - var { kEnumerableProperty } = util; + var { kEnumerableProperty, normalizedMethodRecordsBase, normalizedMethodRecords } = util; var { kHeaders, kSignal, kState, kDispatcher } = require_symbols7(); var { webidl } = require_webidl2(); var { URLSerializer } = require_data_url(); @@ -30820,17 +30857,18 @@ var require_request4 = __commonJS({ } if (init.method !== void 0) { let method = init.method; - const mayBeNormalized = normalizeMethodRecord[method]; + const mayBeNormalized = normalizedMethodRecords[method]; if (mayBeNormalized !== void 0) { request2.method = mayBeNormalized; } else { if (!isValidHTTPToken(method)) { throw new TypeError(`'${method}' is not a valid HTTP method.`); } - if (forbiddenMethodsSet.has(method.toUpperCase())) { + const upperCase = method.toUpperCase(); + if (forbiddenMethodsSet.has(upperCase)) { throw new TypeError(`'${method}' HTTP method is unsupported.`); } - method = normalizeMethod(method); + method = normalizedMethodRecordsBase[upperCase] ?? method; request2.method = method; } if (!patchMethodWarning && request2.method === "patch") { @@ -30923,7 +30961,7 @@ var require_request4 = __commonJS({ } let finalBody = inputOrInitBody; if (initBody == null && inputBody != null) { - if (util.isDisturbed(inputBody.stream) || inputBody.stream.locked) { + if (bodyUnusable(input)) { throw new TypeError( "Cannot construct a Request with a Request object that has already been used." ); @@ -31058,7 +31096,7 @@ var require_request4 = __commonJS({ // Returns a clone of request. clone() { webidl.brandCheck(this, _Request); - if (this.bodyUsed || this.body?.locked) { + if (bodyUnusable(this)) { throw new TypeError("unusable"); } const clonedRequest = cloneRequest(this[kState]); @@ -31151,7 +31189,7 @@ var require_request4 = __commonJS({ function cloneRequest(request2) { const newRequest = makeRequest({ ...request2, body: null }); if (request2.body != null) { - newRequest.body = cloneBody(request2.body); + newRequest.body = cloneBody(newRequest, request2.body); } return newRequest; } @@ -35546,7 +35584,6 @@ var require_websocket2 = __commonJS({ var { types } = require("node:util"); var { ErrorEvent, CloseEvent } = require_events2(); var { SendQueue } = require_sender(); - var experimentalWarned = false; var WebSocket = class _WebSocket extends EventTarget { #events = { open: null, @@ -35567,12 +35604,6 @@ var require_websocket2 = __commonJS({ super(); const prefix = "WebSocket constructor"; webidl.argumentLengthCheck(arguments, 1, prefix); - if (!experimentalWarned) { - experimentalWarned = true; - process.emitWarning("WebSockets are experimental, expect them to change at any time.", { - code: "UNDICI-WS" - }); - } const options = webidl.converters["DOMString or sequence or WebSocketInit"](protocols, prefix, "options"); url = webidl.converters.USVString(url, prefix, "url"); protocols = options.protocols; @@ -36972,132 +37003,116 @@ var RequestError = class extends Error { // node_modules/@octokit/request/dist-bundle/index.js var VERSION2 = "0.0.0-development"; +var defaults_default = { + headers: { + "user-agent": `octokit-request.js/${VERSION2} ${getUserAgent()}` + } +}; function isPlainObject2(value) { - if (typeof value !== "object" || value === null) - return false; - if (Object.prototype.toString.call(value) !== "[object Object]") - return false; + if (typeof value !== "object" || value === null) return false; + if (Object.prototype.toString.call(value) !== "[object Object]") return false; const proto = Object.getPrototypeOf(value); - if (proto === null) - return true; + if (proto === null) return true; const Ctor = Object.prototype.hasOwnProperty.call(proto, "constructor") && proto.constructor; return typeof Ctor === "function" && Ctor instanceof Ctor && Function.prototype.call(Ctor) === Function.prototype.call(value); } -function getBufferResponse(response) { - return response.arrayBuffer(); -} -function fetchWrapper(requestOptions) { - const log = requestOptions.request && requestOptions.request.log ? requestOptions.request.log : console; - const parseSuccessResponseBody = requestOptions.request?.parseSuccessResponseBody !== false; - if (isPlainObject2(requestOptions.body) || Array.isArray(requestOptions.body)) { - requestOptions.body = JSON.stringify(requestOptions.body); - } - let headers = {}; - let status; - let url; - let { fetch } = globalThis; - if (requestOptions.request?.fetch) { - fetch = requestOptions.request.fetch; - } +async function fetchWrapper(requestOptions) { + const fetch = requestOptions.request?.fetch || globalThis.fetch; if (!fetch) { throw new Error( "fetch is not set. Please pass a fetch implementation as new Octokit({ request: { fetch }}). Learn more at https://github.com/octokit/octokit.js/#fetch-missing" ); } - return fetch(requestOptions.url, { - method: requestOptions.method, - body: requestOptions.body, - redirect: requestOptions.request?.redirect, - // Header values must be `string` - headers: Object.fromEntries( - Object.entries(requestOptions.headers).map(([name, value]) => [ - name, - String(value) - ]) - ), - signal: requestOptions.request?.signal, - // duplex must be set if request.body is ReadableStream or Async Iterables. - // See https://fetch.spec.whatwg.org/#dom-requestinit-duplex. - ...requestOptions.body && { duplex: "half" } - }).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; + const log = requestOptions.request?.log || console; + const parseSuccessResponseBody = requestOptions.request?.parseSuccessResponseBody !== false; + const body = isPlainObject2(requestOptions.body) || Array.isArray(requestOptions.body) ? JSON.stringify(requestOptions.body) : requestOptions.body; + const requestHeaders = Object.fromEntries( + Object.entries(requestOptions.headers).map(([name, value]) => [ + name, + String(value) + ]) + ); + let fetchResponse; + try { + fetchResponse = await fetch(requestOptions.url, { + method: requestOptions.method, + body, + redirect: requestOptions.request?.redirect, + headers: requestHeaders, + signal: requestOptions.request?.signal, + // duplex must be set if request.body is ReadableStream or Async Iterables. + // See https://fetch.spec.whatwg.org/#dom-requestinit-duplex. + ...requestOptions.body && { duplex: "half" } + }); + } catch (error) { + let message = "Unknown Error"; + if (error instanceof Error) { + if (error.name === "AbortError") { + error.status = 500; + throw error; } - throw new RequestError(response.statusText, status, { - response: { - url, - status, - headers, - data: void 0 - }, - request: requestOptions - }); - } - if (status === 304) { - throw new RequestError("Not modified", status, { - response: { - url, - status, - headers, - data: await getResponseData(response) - }, - request: requestOptions - }); - } - if (status >= 400) { - const data = await getResponseData(response); - const error = new RequestError(toErrorMessage(data), status, { - response: { - url, - status, - headers, - data - }, - request: requestOptions - }); - throw error; - } - return parseSuccessResponseBody ? await getResponseData(response) : response.body; - }).then((data) => { - return { - status, - url, - headers, - data - }; - }).catch((error) => { - if (error instanceof RequestError) - throw error; - else if (error.name === "AbortError") - throw error; - let message = error.message; - if (error.name === "TypeError" && "cause" in error) { - if (error.cause instanceof Error) { - message = error.cause.message; - } else if (typeof error.cause === "string") { - message = error.cause; + message = error.message; + if (error.name === "TypeError" && "cause" in error) { + if (error.cause instanceof Error) { + message = error.cause.message; + } else if (typeof error.cause === "string") { + message = error.cause; + } } } - throw new RequestError(message, 500, { + const requestError = new RequestError(message, 500, { request: requestOptions }); - }); + requestError.cause = error; + throw requestError; + } + const status = fetchResponse.status; + const url = fetchResponse.url; + const responseHeaders = {}; + for (const [key, value] of fetchResponse.headers) { + responseHeaders[key] = value; + } + const octokitResponse = { + url, + status, + headers: responseHeaders, + data: "" + }; + if ("deprecation" in responseHeaders) { + const matches = responseHeaders.link && responseHeaders.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 ${responseHeaders.sunset}${deprecationLink ? `. See ${deprecationLink}` : ""}` + ); + } + if (status === 204 || status === 205) { + return octokitResponse; + } + if (requestOptions.method === "HEAD") { + if (status < 400) { + return octokitResponse; + } + throw new RequestError(fetchResponse.statusText, status, { + response: octokitResponse, + request: requestOptions + }); + } + if (status === 304) { + octokitResponse.data = await getResponseData(fetchResponse); + throw new RequestError("Not modified", status, { + response: octokitResponse, + request: requestOptions + }); + } + if (status >= 400) { + octokitResponse.data = await getResponseData(fetchResponse); + throw new RequestError(toErrorMessage(octokitResponse.data), status, { + response: octokitResponse, + request: requestOptions + }); + } + octokitResponse.data = parseSuccessResponseBody ? await getResponseData(fetchResponse) : fetchResponse.body; + return octokitResponse; } async function getResponseData(response) { const contentType = response.headers.get("content-type"); @@ -37107,22 +37122,18 @@ async function getResponseData(response) { if (!contentType || /^text\/|charset=utf-8$/.test(contentType)) { return response.text(); } - return getBufferResponse(response); + return response.arrayBuffer(); } function toErrorMessage(data) { - if (typeof data === "string") + if (typeof data === "string") { return data; - let suffix; - if ("documentation_url" in data) { - suffix = ` - ${data.documentation_url}`; - } else { - suffix = ""; + } + if (data instanceof ArrayBuffer) { + return "Unknown error"; } if ("message" in data) { - if (Array.isArray(data.errors)) { - return `${data.message}: ${data.errors.map(JSON.stringify).join(", ")}${suffix}`; - } - return `${data.message}${suffix}`; + const suffix = "documentation_url" in data ? ` - ${data.documentation_url}` : ""; + return Array.isArray(data.errors) ? `${data.message}: ${data.errors.map((v) => JSON.stringify(v)).join(", ")}${suffix}` : `${data.message}${suffix}`; } return `Unknown error: ${JSON.stringify(data)}`; } @@ -37149,11 +37160,7 @@ function withDefaults2(oldEndpoint, newDefaults) { defaults: withDefaults2.bind(null, endpoint2) }); } -var request = withDefaults2(endpoint, { - headers: { - "user-agent": `octokit-request.js/${VERSION2} ${getUserAgent()}` - } -}); +var request = withDefaults2(endpoint, defaults_default); // node_modules/@octokit/oauth-methods/dist-bundle/index.js function requestToOAuthBaseUrl(request2) { @@ -39499,7 +39506,7 @@ async function hook4(state, request2, route, parameters) { state, // @ts-expect-error TBD {}, - request2 + request2.defaults({ baseUrl: endpoint2.baseUrl }) ); endpoint2.headers.authorization = `token ${token}`; return sendRequestWithRetries( @@ -39532,7 +39539,7 @@ async function sendRequestWithRetries(state, request2, options, createdAt, retri return sendRequestWithRetries(state, request2, options, createdAt, retries); } } -var VERSION6 = "7.1.0"; +var VERSION6 = "7.1.1"; function createAppAuth(options) { if (!options.appId) { throw new Error("[@octokit/auth-app] appId option is required"); diff --git a/dist/post.cjs b/dist/post.cjs index 0307466..f77a8f1 100644 --- a/dist/post.cjs +++ b/dist/post.cjs @@ -2238,6 +2238,7 @@ var require_decodeText = __commonJS({ return decoders.utf8; case "latin1": case "ascii": + // TODO: Make these a separate, strict decoder? case "us-ascii": case "iso-8859-1": case "iso8859-1": @@ -2937,6 +2938,7 @@ var require_basename = __commonJS({ for (var i = path.length - 1; i >= 0; --i) { switch (path.charCodeAt(i)) { case 47: + // '/' case 92: path = path.slice(i + 1); return path === ".." || path === "." ? "" : path; @@ -4171,7 +4173,21 @@ var require_util2 = __commonJS({ return referrerOrigin; } case "strict-origin": + // eslint-disable-line + /** + * 1. If referrerURL is a potentially trustworthy URL and + * request’s current URL is not a potentially trustworthy URL, + * then return no referrer. + * 2. Return referrerOrigin + */ case "no-referrer-when-downgrade": + // eslint-disable-line + /** + * 1. If referrerURL is a potentially trustworthy URL and + * request’s current URL is not a potentially trustworthy URL, + * then return no referrer. + * 2. Return referrerOrigin + */ default: return isNonPotentiallyTrustWorthy ? "no-referrer" : referrerOrigin; } @@ -19943,6 +19959,27 @@ var require_util8 = __commonJS({ } var kEnumerableProperty = /* @__PURE__ */ Object.create(null); kEnumerableProperty.enumerable = true; + var normalizedMethodRecordsBase = { + delete: "DELETE", + DELETE: "DELETE", + get: "GET", + GET: "GET", + head: "HEAD", + HEAD: "HEAD", + options: "OPTIONS", + OPTIONS: "OPTIONS", + post: "POST", + POST: "POST", + put: "PUT", + PUT: "PUT" + }; + var normalizedMethodRecords = { + ...normalizedMethodRecordsBase, + patch: "patch", + PATCH: "PATCH" + }; + Object.setPrototypeOf(normalizedMethodRecordsBase, null); + Object.setPrototypeOf(normalizedMethodRecords, null); module2.exports = { kEnumerableProperty, nop, @@ -19981,6 +20018,8 @@ var require_util8 = __commonJS({ isValidHeaderValue, isTokenCharCode, parseRangeHeader, + normalizedMethodRecordsBase, + normalizedMethodRecords, isValidPort, isHttpOrHttpsPrefixed, nodeMajor, @@ -20196,7 +20235,8 @@ var require_request3 = __commonJS({ isBlobLike, buildURL, validateHandler, - getServerName + getServerName, + normalizedMethodRecords } = require_util8(); var { channels } = require_diagnostics(); var { headerNameLowerCasedRecord } = require_constants6(); @@ -20223,12 +20263,12 @@ var require_request3 = __commonJS({ throw new InvalidArgumentError("path must be a string"); } else if (path[0] !== "/" && !(path.startsWith("http://") || path.startsWith("https://")) && method !== "CONNECT") { throw new InvalidArgumentError("path must be an absolute URL or start with a slash"); - } else if (invalidPathRegex.exec(path) !== null) { + } else if (invalidPathRegex.test(path)) { throw new InvalidArgumentError("invalid request path"); } if (typeof method !== "string") { throw new InvalidArgumentError("method must be a string"); - } else if (!isValidHTTPToken(method)) { + } else if (normalizedMethodRecords[method] === void 0 && !isValidHTTPToken(method)) { throw new InvalidArgumentError("invalid request method"); } if (upgrade && typeof upgrade !== "string") { @@ -20773,7 +20813,7 @@ var require_connect2 = __commonJS({ } }; } - function buildConnector({ allowH2, maxCachedSessions, socketPath, timeout, ...opts }) { + function buildConnector({ allowH2, maxCachedSessions, socketPath, timeout, session: customSession, ...opts }) { if (maxCachedSessions != null && (!Number.isInteger(maxCachedSessions) || maxCachedSessions < 0)) { throw new InvalidArgumentError("maxCachedSessions must be a positive integer or zero"); } @@ -20789,7 +20829,7 @@ var require_connect2 = __commonJS({ } servername = servername || options.servername || util.getServerName(host) || null; const sessionKey = servername || hostname; - const session = sessionCache.get(sessionKey) || null; + const session = customSession || sessionCache.get(sessionKey) || null; assert(sessionKey); socket = tls.connect({ highWaterMark: 16384, @@ -22307,7 +22347,7 @@ var require_util9 = __commonJS({ var { getGlobalOrigin } = require_global3(); var { collectASequenceOfCodePoints, collectAnHTTPQuotedString, removeChars, parseMIMEType } = require_data_url(); var { performance: performance2 } = require("node:perf_hooks"); - var { isBlobLike, ReadableStreamFrom, isValidHTTPToken } = require_util8(); + var { isBlobLike, ReadableStreamFrom, isValidHTTPToken, normalizedMethodRecordsBase } = require_util8(); var assert = require("node:assert"); var { isUint8Array } = require("node:util/types"); var { webidl } = require_webidl2(); @@ -22414,7 +22454,7 @@ var require_util9 = __commonJS({ } function appendRequestOriginHeader(request2) { let serializedOrigin = request2.origin; - if (serializedOrigin === "client") { + if (serializedOrigin === "client" || serializedOrigin === void 0) { return; } if (request2.responseTainting === "cors" || request2.mode === "websocket") { @@ -22532,7 +22572,21 @@ var require_util9 = __commonJS({ return referrerOrigin; } case "strict-origin": + // eslint-disable-line + /** + * 1. If referrerURL is a potentially trustworthy URL and + * request’s current URL is not a potentially trustworthy URL, + * then return no referrer. + * 2. Return referrerOrigin + */ case "no-referrer-when-downgrade": + // eslint-disable-line + /** + * 1. If referrerURL is a potentially trustworthy URL and + * request’s current URL is not a potentially trustworthy URL, + * then return no referrer. + * 2. Return referrerOrigin + */ default: return isNonPotentiallyTrustWorthy ? "no-referrer" : referrerOrigin; } @@ -22695,29 +22749,8 @@ var require_util9 = __commonJS({ function isCancelled(fetchParams) { return fetchParams.controller.state === "aborted" || fetchParams.controller.state === "terminated"; } - var normalizeMethodRecordBase = { - delete: "DELETE", - DELETE: "DELETE", - get: "GET", - GET: "GET", - head: "HEAD", - HEAD: "HEAD", - options: "OPTIONS", - OPTIONS: "OPTIONS", - post: "POST", - POST: "POST", - put: "PUT", - PUT: "PUT" - }; - var normalizeMethodRecord = { - ...normalizeMethodRecordBase, - patch: "patch", - PATCH: "PATCH" - }; - Object.setPrototypeOf(normalizeMethodRecordBase, null); - Object.setPrototypeOf(normalizeMethodRecord, null); function normalizeMethod(method) { - return normalizeMethodRecordBase[method.toLowerCase()] ?? method; + return normalizedMethodRecordsBase[method.toLowerCase()] ?? method; } function serializeJavascriptValueToJSONString(value) { const result = JSON.stringify(value); @@ -22854,7 +22887,7 @@ var require_util9 = __commonJS({ } }); } - async function fullyReadBody(body, processBody, processBodyError, shouldClone) { + async function fullyReadBody(body, processBody, processBodyError) { const successSteps = processBody; const errorSteps = processBodyError; let reader; @@ -22865,7 +22898,7 @@ var require_util9 = __commonJS({ return; } try { - successSteps(await readAllBytes(reader, shouldClone)); + successSteps(await readAllBytes(reader)); } catch (e) { errorSteps(e); } @@ -22888,19 +22921,12 @@ var require_util9 = __commonJS({ assert(!invalidIsomorphicEncodeValueRegex.test(input)); return input; } - async function readAllBytes(reader, shouldClone) { + async function readAllBytes(reader) { const bytes = []; let byteLength = 0; while (true) { const { done, value: chunk } = await reader.read(); if (done) { - if (bytes.length === 1) { - const { buffer, byteOffset, byteLength: byteLength2 } = bytes[0]; - if (shouldClone === false) { - return Buffer.from(buffer, byteOffset, byteLength2); - } - return Buffer.from(buffer.slice(byteOffset, byteOffset + byteLength2), 0, byteLength2); - } return Buffer.concat(bytes, byteLength); } if (!isUint8Array(chunk)) { @@ -23163,7 +23189,6 @@ var require_util9 = __commonJS({ urlHasHttpsScheme, urlIsHttpHttpsScheme, readAllBytes, - normalizeMethodRecord, simpleRangeHeaderValue, buildContentRange, parseMetadata, @@ -23663,11 +23688,23 @@ var require_body2 = __commonJS({ var { webidl } = require_webidl2(); var { Blob: Blob2 } = require("node:buffer"); var assert = require("node:assert"); - var { isErrored } = require_util8(); + var { isErrored, isDisturbed } = require("node:stream"); var { isArrayBuffer } = require("node:util/types"); var { serializeAMimeType } = require_data_url(); var { multipartFormDataParser } = require_formdata_parser(); var textEncoder = new TextEncoder(); + function noop() { + } + var hasFinalizationRegistry = globalThis.FinalizationRegistry && process.version.indexOf("v18") !== 0; + var streamRegistry; + if (hasFinalizationRegistry) { + streamRegistry = new FinalizationRegistry((weakRef) => { + const stream = weakRef.deref(); + if (stream && !stream.locked && !isDisturbed(stream) && !isErrored(stream)) { + stream.cancel("Response object has been garbage collected").catch(noop); + } + }); + } function extractBody(object, keepalive = false) { let stream = null; if (object instanceof ReadableStream) { @@ -23810,8 +23847,11 @@ Content-Type: ${value.type || "application/octet-stream"}\r } return extractBody(object, keepalive); } - function cloneBody(body) { + function cloneBody(instance, body) { const [out1, out2] = body.stream.tee(); + if (hasFinalizationRegistry) { + streamRegistry.register(instance, new WeakRef(out1)); + } body.stream = out1; return { stream: out2, @@ -23835,18 +23875,18 @@ Content-Type: ${value.type || "application/octet-stream"}\r mimeType = serializeAMimeType(mimeType); } return new Blob2([bytes], { type: mimeType }); - }, instance, false); + }, instance); }, arrayBuffer() { return consumeBody(this, (bytes) => { - return bytes.buffer; - }, instance, true); + return new Uint8Array(bytes).buffer; + }, instance); }, text() { - return consumeBody(this, utf8DecodeBytes, instance, false); + return consumeBody(this, utf8DecodeBytes, instance); }, json() { - return consumeBody(this, parseJSONFromBytes, instance, false); + return consumeBody(this, parseJSONFromBytes, instance); }, formData() { return consumeBody(this, (value) => { @@ -23875,12 +23915,12 @@ Content-Type: ${value.type || "application/octet-stream"}\r throw new TypeError( 'Content-Type was not one of "multipart/form-data" or "application/x-www-form-urlencoded".' ); - }, instance, false); + }, instance); }, bytes() { return consumeBody(this, (bytes) => { - return new Uint8Array(bytes.buffer, 0, bytes.byteLength); - }, instance, true); + return new Uint8Array(bytes); + }, instance); } }; return methods; @@ -23888,9 +23928,9 @@ Content-Type: ${value.type || "application/octet-stream"}\r function mixinBody(prototype) { Object.assign(prototype.prototype, bodyMixinMethods(prototype)); } - async function consumeBody(object, convertBytesToJSValue, instance, shouldClone) { + async function consumeBody(object, convertBytesToJSValue, instance) { webidl.brandCheck(object, instance); - if (bodyUnusable(object[kState].body)) { + if (bodyUnusable(object)) { throw new TypeError("Body is unusable: Body has already been read"); } throwIfAborted(object[kState]); @@ -23907,10 +23947,11 @@ Content-Type: ${value.type || "application/octet-stream"}\r successSteps(Buffer.allocUnsafe(0)); return promise.promise; } - await fullyReadBody(object[kState].body, successSteps, errorSteps, shouldClone); + await fullyReadBody(object[kState].body, successSteps, errorSteps); return promise.promise; } - function bodyUnusable(body) { + function bodyUnusable(object) { + const body = object[kState].body; return body != null && (body.stream.locked || util.isDisturbed(body.stream)); } function parseJSONFromBytes(bytes) { @@ -23928,7 +23969,10 @@ Content-Type: ${value.type || "application/octet-stream"}\r extractBody, safelyExtractBody, cloneBody, - mixinBody + mixinBody, + streamRegistry, + hasFinalizationRegistry, + bodyUnusable }; } }); @@ -24660,25 +24704,25 @@ upgrade: ${upgrade}\r channels.sendHeaders.publish({ request: request2, headers: header, socket }); } if (!body || bodyLength === 0) { - writeBuffer({ abort, body: null, client, request: request2, socket, contentLength, header, expectsPayload }); + writeBuffer(abort, null, client, request2, socket, contentLength, header, expectsPayload); } else if (util.isBuffer(body)) { - writeBuffer({ abort, body, client, request: request2, socket, contentLength, header, expectsPayload }); + writeBuffer(abort, body, client, request2, socket, contentLength, header, expectsPayload); } else if (util.isBlobLike(body)) { if (typeof body.stream === "function") { - writeIterable({ abort, body: body.stream(), client, request: request2, socket, contentLength, header, expectsPayload }); + writeIterable(abort, body.stream(), client, request2, socket, contentLength, header, expectsPayload); } else { - writeBlob({ abort, body, client, request: request2, socket, contentLength, header, expectsPayload }); + writeBlob(abort, body, client, request2, socket, contentLength, header, expectsPayload); } } else if (util.isStream(body)) { - writeStream({ abort, body, client, request: request2, socket, contentLength, header, expectsPayload }); + writeStream(abort, body, client, request2, socket, contentLength, header, expectsPayload); } else if (util.isIterable(body)) { - writeIterable({ abort, body, client, request: request2, socket, contentLength, header, expectsPayload }); + writeIterable(abort, body, client, request2, socket, contentLength, header, expectsPayload); } else { assert(false); } return true; } - function writeStream({ abort, body, client, request: request2, socket, contentLength, header, expectsPayload }) { + function writeStream(abort, body, client, request2, socket, contentLength, header, expectsPayload) { assert(contentLength !== 0 || client[kRunning] === 0, "stream body cannot be pipelined"); let finished = false; const writer = new AsyncWriter({ abort, socket, request: request2, contentLength, client, expectsPayload, header }); @@ -24747,7 +24791,7 @@ upgrade: ${upgrade}\r setImmediate(onClose); } } - function writeBuffer({ abort, body, client, request: request2, socket, contentLength, header, expectsPayload }) { + function writeBuffer(abort, body, client, request2, socket, contentLength, header, expectsPayload) { try { if (!body) { if (contentLength === 0) { @@ -24778,7 +24822,7 @@ upgrade: ${upgrade}\r abort(err); } } - async function writeBlob({ abort, body, client, request: request2, socket, contentLength, header, expectsPayload }) { + async function writeBlob(abort, body, client, request2, socket, contentLength, header, expectsPayload) { assert(contentLength === body.size, "blob body must have content length"); try { if (contentLength != null && contentLength !== body.size) { @@ -24801,7 +24845,7 @@ upgrade: ${upgrade}\r abort(err); } } - async function writeIterable({ abort, body, client, request: request2, socket, contentLength, header, expectsPayload }) { + async function writeIterable(abort, body, client, request2, socket, contentLength, header, expectsPayload) { assert(contentLength !== 0 || client[kRunning] === 0, "iterator body cannot be pipelined"); let callback = null; function onDrain() { @@ -25264,81 +25308,79 @@ var require_client_h2 = __commonJS({ return true; function writeBodyH2() { if (!body || contentLength === 0) { - writeBuffer({ + writeBuffer( abort, + stream, + null, client, - request: request2, + request2, + client[kSocket], contentLength, - expectsPayload, - h2stream: stream, - body: null, - socket: client[kSocket] - }); + expectsPayload + ); } else if (util.isBuffer(body)) { - writeBuffer({ + writeBuffer( abort, + stream, + body, client, - request: request2, + request2, + client[kSocket], contentLength, - body, - expectsPayload, - h2stream: stream, - socket: client[kSocket] - }); + expectsPayload + ); } else if (util.isBlobLike(body)) { if (typeof body.stream === "function") { - writeIterable({ + writeIterable( abort, + stream, + body.stream(), client, - request: request2, + request2, + client[kSocket], contentLength, - expectsPayload, - h2stream: stream, - body: body.stream(), - socket: client[kSocket] - }); + expectsPayload + ); } else { - writeBlob({ + writeBlob( abort, + stream, body, client, - request: request2, + request2, + client[kSocket], contentLength, - expectsPayload, - h2stream: stream, - socket: client[kSocket] - }); + expectsPayload + ); } } else if (util.isStream(body)) { - writeStream({ + writeStream( abort, + client[kSocket], + expectsPayload, + stream, body, client, - request: request2, - contentLength, - expectsPayload, - socket: client[kSocket], - h2stream: stream, - header: "" - }); + request2, + contentLength + ); } else if (util.isIterable(body)) { - writeIterable({ + writeIterable( abort, + stream, body, client, - request: request2, + request2, + client[kSocket], contentLength, - expectsPayload, - header: "", - h2stream: stream, - socket: client[kSocket] - }); + expectsPayload + ); } else { assert(false); } } } - function writeBuffer({ abort, h2stream, body, client, request: request2, socket, contentLength, expectsPayload }) { + function writeBuffer(abort, h2stream, body, client, request2, socket, contentLength, expectsPayload) { try { if (body != null && util.isBuffer(body)) { assert(contentLength === body.byteLength, "buffer body must have content length"); @@ -25357,7 +25399,7 @@ var require_client_h2 = __commonJS({ abort(error); } } - function writeStream({ abort, socket, expectsPayload, h2stream, body, client, request: request2, contentLength }) { + function writeStream(abort, socket, expectsPayload, h2stream, body, client, request2, contentLength) { assert(contentLength !== 0 || client[kRunning] === 0, "stream body cannot be pipelined"); const pipe = pipeline( body, @@ -25381,7 +25423,7 @@ var require_client_h2 = __commonJS({ request2.onBodySent(chunk); } } - async function writeBlob({ abort, h2stream, body, client, request: request2, socket, contentLength, expectsPayload }) { + async function writeBlob(abort, h2stream, body, client, request2, socket, contentLength, expectsPayload) { assert(contentLength === body.size, "blob body must have content length"); try { if (contentLength != null && contentLength !== body.size) { @@ -25402,7 +25444,7 @@ var require_client_h2 = __commonJS({ abort(err); } } - async function writeIterable({ abort, h2stream, body, client, request: request2, socket, contentLength, expectsPayload }) { + async function writeIterable(abort, h2stream, body, client, request2, socket, contentLength, expectsPayload) { assert(contentLength !== 0 || client[kRunning] === 0, "iterator body cannot be pipelined"); let callback = null; function onDrain() { @@ -26484,8 +26526,13 @@ var require_balanced_pool2 = __commonJS({ var kMaxWeightPerServer = Symbol("kMaxWeightPerServer"); var kErrorPenalty = Symbol("kErrorPenalty"); function getGreatestCommonDivisor(a, b) { - if (b === 0) return a; - return getGreatestCommonDivisor(b, a % b); + if (a === 0) return b; + while (b !== 0) { + const t = b; + b = a % b; + a = t; + } + return a; } function defaultFactory(origin, opts) { return new Pool(origin, opts); @@ -26539,7 +26586,11 @@ var require_balanced_pool2 = __commonJS({ return this; } _updateBalancedPoolStats() { - this[kGreatestCommonDivisor] = this[kClients].map((p) => p[kWeight]).reduce(getGreatestCommonDivisor, 0); + let result = 0; + for (let i = 0; i < this[kClients].length; i++) { + result = getGreatestCommonDivisor(this[kClients][i][kWeight], result); + } + this[kGreatestCommonDivisor] = result; } removeUpstream(upstream) { const upstreamOrigin = parseOrigin(upstream).origin; @@ -27147,7 +27198,7 @@ var require_retry_handler = __commonJS({ this.abort( new RequestRetryError("Content-Range mismatch", statusCode, { headers, - count: this.retryCount + data: { count: this.retryCount } }) ); return false; @@ -27156,7 +27207,7 @@ var require_retry_handler = __commonJS({ this.abort( new RequestRetryError("ETag mismatch", statusCode, { headers, - count: this.retryCount + data: { count: this.retryCount } }) ); return false; @@ -29924,7 +29975,7 @@ var require_response2 = __commonJS({ "node_modules/undici/lib/web/fetch/response.js"(exports2, module2) { "use strict"; var { Headers, HeadersList, fill, getHeadersGuard, setHeadersGuard, setHeadersList } = require_headers2(); - var { extractBody, cloneBody, mixinBody } = require_body2(); + var { extractBody, cloneBody, mixinBody, hasFinalizationRegistry, streamRegistry, bodyUnusable } = require_body2(); var util = require_util8(); var nodeUtil = require("node:util"); var { kEnumerableProperty } = util; @@ -29949,19 +30000,7 @@ var require_response2 = __commonJS({ var { kConstruct } = require_symbols6(); var assert = require("node:assert"); var { types } = require("node:util"); - var { isDisturbed, isErrored } = require("node:stream"); var textEncoder = new TextEncoder("utf-8"); - var hasFinalizationRegistry = globalThis.FinalizationRegistry && process.version.indexOf("v18") !== 0; - var registry; - if (hasFinalizationRegistry) { - registry = new FinalizationRegistry((stream) => { - if (!stream.locked && !isDisturbed(stream) && !isErrored(stream)) { - stream.cancel("Response object has been garbage collected").catch(noop); - } - }); - } - function noop() { - } var Response = class _Response { // Creates network error Response. static error() { @@ -30073,7 +30112,7 @@ var require_response2 = __commonJS({ // Returns a clone of response. clone() { webidl.brandCheck(this, _Response); - if (this.bodyUsed || this.body?.locked) { + if (bodyUnusable(this)) { throw webidl.errors.exception({ header: "Response.clone", message: "Body has already been consumed." @@ -30132,7 +30171,7 @@ var require_response2 = __commonJS({ } const newResponse = makeResponse({ ...response, body: null }); if (response.body != null) { - newResponse.body = cloneBody(response.body); + newResponse.body = cloneBody(newResponse, response.body); } return newResponse; } @@ -30257,7 +30296,7 @@ var require_response2 = __commonJS({ setHeadersList(response[kHeaders], innerResponse.headersList); setHeadersGuard(response[kHeaders], guard); if (hasFinalizationRegistry && innerResponse.body?.stream) { - registry.register(response, innerResponse.body.stream); + streamRegistry.register(response, new WeakRef(innerResponse.body.stream)); } return response; } @@ -30372,7 +30411,7 @@ var require_dispatcher_weakref2 = __commonJS({ var require_request4 = __commonJS({ "node_modules/undici/lib/web/fetch/request.js"(exports2, module2) { "use strict"; - var { extractBody, mixinBody, cloneBody } = require_body2(); + var { extractBody, mixinBody, cloneBody, bodyUnusable } = require_body2(); var { Headers, fill: fillHeaders, HeadersList, setHeadersGuard, getHeadersGuard, setHeadersList, getHeadersList } = require_headers2(); var { FinalizationRegistry: FinalizationRegistry2 } = require_dispatcher_weakref2()(); var util = require_util8(); @@ -30380,9 +30419,7 @@ var require_request4 = __commonJS({ var { isValidHTTPToken, sameOrigin, - normalizeMethod, - environmentSettingsObject, - normalizeMethodRecord + environmentSettingsObject } = require_util9(); var { forbiddenMethodsSet, @@ -30394,7 +30431,7 @@ var require_request4 = __commonJS({ requestCache, requestDuplex } = require_constants8(); - var { kEnumerableProperty } = util; + var { kEnumerableProperty, normalizedMethodRecordsBase, normalizedMethodRecords } = util; var { kHeaders, kSignal, kState, kDispatcher } = require_symbols7(); var { webidl } = require_webidl2(); var { URLSerializer } = require_data_url(); @@ -30591,17 +30628,18 @@ var require_request4 = __commonJS({ } if (init.method !== void 0) { let method = init.method; - const mayBeNormalized = normalizeMethodRecord[method]; + const mayBeNormalized = normalizedMethodRecords[method]; if (mayBeNormalized !== void 0) { request2.method = mayBeNormalized; } else { if (!isValidHTTPToken(method)) { throw new TypeError(`'${method}' is not a valid HTTP method.`); } - if (forbiddenMethodsSet.has(method.toUpperCase())) { + const upperCase = method.toUpperCase(); + if (forbiddenMethodsSet.has(upperCase)) { throw new TypeError(`'${method}' HTTP method is unsupported.`); } - method = normalizeMethod(method); + method = normalizedMethodRecordsBase[upperCase] ?? method; request2.method = method; } if (!patchMethodWarning && request2.method === "patch") { @@ -30694,7 +30732,7 @@ var require_request4 = __commonJS({ } let finalBody = inputOrInitBody; if (initBody == null && inputBody != null) { - if (util.isDisturbed(inputBody.stream) || inputBody.stream.locked) { + if (bodyUnusable(input)) { throw new TypeError( "Cannot construct a Request with a Request object that has already been used." ); @@ -30829,7 +30867,7 @@ var require_request4 = __commonJS({ // Returns a clone of request. clone() { webidl.brandCheck(this, _Request); - if (this.bodyUsed || this.body?.locked) { + if (bodyUnusable(this)) { throw new TypeError("unusable"); } const clonedRequest = cloneRequest(this[kState]); @@ -30922,7 +30960,7 @@ var require_request4 = __commonJS({ function cloneRequest(request2) { const newRequest = makeRequest({ ...request2, body: null }); if (request2.body != null) { - newRequest.body = cloneBody(request2.body); + newRequest.body = cloneBody(newRequest, request2.body); } return newRequest; } @@ -35317,7 +35355,6 @@ var require_websocket2 = __commonJS({ var { types } = require("node:util"); var { ErrorEvent, CloseEvent } = require_events2(); var { SendQueue } = require_sender(); - var experimentalWarned = false; var WebSocket = class _WebSocket extends EventTarget { #events = { open: null, @@ -35338,12 +35375,6 @@ var require_websocket2 = __commonJS({ super(); const prefix = "WebSocket constructor"; webidl.argumentLengthCheck(arguments, 1, prefix); - if (!experimentalWarned) { - experimentalWarned = true; - process.emitWarning("WebSockets are experimental, expect them to change at any time.", { - code: "UNDICI-WS" - }); - } const options = webidl.converters["DOMString or sequence or WebSocketInit"](protocols, prefix, "options"); url = webidl.converters.USVString(url, prefix, "url"); protocols = options.protocols; @@ -36784,132 +36815,116 @@ var RequestError = class extends Error { // node_modules/@octokit/request/dist-bundle/index.js var VERSION2 = "0.0.0-development"; +var defaults_default = { + headers: { + "user-agent": `octokit-request.js/${VERSION2} ${getUserAgent()}` + } +}; function isPlainObject2(value) { - if (typeof value !== "object" || value === null) - return false; - if (Object.prototype.toString.call(value) !== "[object Object]") - return false; + if (typeof value !== "object" || value === null) return false; + if (Object.prototype.toString.call(value) !== "[object Object]") return false; const proto = Object.getPrototypeOf(value); - if (proto === null) - return true; + if (proto === null) return true; const Ctor = Object.prototype.hasOwnProperty.call(proto, "constructor") && proto.constructor; return typeof Ctor === "function" && Ctor instanceof Ctor && Function.prototype.call(Ctor) === Function.prototype.call(value); } -function getBufferResponse(response) { - return response.arrayBuffer(); -} -function fetchWrapper(requestOptions) { - const log = requestOptions.request && requestOptions.request.log ? requestOptions.request.log : console; - const parseSuccessResponseBody = requestOptions.request?.parseSuccessResponseBody !== false; - if (isPlainObject2(requestOptions.body) || Array.isArray(requestOptions.body)) { - requestOptions.body = JSON.stringify(requestOptions.body); - } - let headers = {}; - let status; - let url; - let { fetch } = globalThis; - if (requestOptions.request?.fetch) { - fetch = requestOptions.request.fetch; - } +async function fetchWrapper(requestOptions) { + const fetch = requestOptions.request?.fetch || globalThis.fetch; if (!fetch) { throw new Error( "fetch is not set. Please pass a fetch implementation as new Octokit({ request: { fetch }}). Learn more at https://github.com/octokit/octokit.js/#fetch-missing" ); } - return fetch(requestOptions.url, { - method: requestOptions.method, - body: requestOptions.body, - redirect: requestOptions.request?.redirect, - // Header values must be `string` - headers: Object.fromEntries( - Object.entries(requestOptions.headers).map(([name, value]) => [ - name, - String(value) - ]) - ), - signal: requestOptions.request?.signal, - // duplex must be set if request.body is ReadableStream or Async Iterables. - // See https://fetch.spec.whatwg.org/#dom-requestinit-duplex. - ...requestOptions.body && { duplex: "half" } - }).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; + const log = requestOptions.request?.log || console; + const parseSuccessResponseBody = requestOptions.request?.parseSuccessResponseBody !== false; + const body = isPlainObject2(requestOptions.body) || Array.isArray(requestOptions.body) ? JSON.stringify(requestOptions.body) : requestOptions.body; + const requestHeaders = Object.fromEntries( + Object.entries(requestOptions.headers).map(([name, value]) => [ + name, + String(value) + ]) + ); + let fetchResponse; + try { + fetchResponse = await fetch(requestOptions.url, { + method: requestOptions.method, + body, + redirect: requestOptions.request?.redirect, + headers: requestHeaders, + signal: requestOptions.request?.signal, + // duplex must be set if request.body is ReadableStream or Async Iterables. + // See https://fetch.spec.whatwg.org/#dom-requestinit-duplex. + ...requestOptions.body && { duplex: "half" } + }); + } catch (error) { + let message = "Unknown Error"; + if (error instanceof Error) { + if (error.name === "AbortError") { + error.status = 500; + throw error; + } + message = error.message; + if (error.name === "TypeError" && "cause" in error) { + if (error.cause instanceof Error) { + message = error.cause.message; + } else if (typeof error.cause === "string") { + message = error.cause; + } } - throw new RequestError(response.statusText, status, { - response: { - url, - status, - headers, - data: void 0 - }, - request: requestOptions - }); } - if (status === 304) { - throw new RequestError("Not modified", status, { - response: { - url, - status, - headers, - data: await getResponseData(response) - }, - request: requestOptions - }); + const requestError = new RequestError(message, 500, { + request: requestOptions + }); + requestError.cause = error; + throw requestError; + } + const status = fetchResponse.status; + const url = fetchResponse.url; + const responseHeaders = {}; + for (const [key, value] of fetchResponse.headers) { + responseHeaders[key] = value; + } + const octokitResponse = { + url, + status, + headers: responseHeaders, + data: "" + }; + if ("deprecation" in responseHeaders) { + const matches = responseHeaders.link && responseHeaders.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 ${responseHeaders.sunset}${deprecationLink ? `. See ${deprecationLink}` : ""}` + ); + } + if (status === 204 || status === 205) { + return octokitResponse; + } + if (requestOptions.method === "HEAD") { + if (status < 400) { + return octokitResponse; } - if (status >= 400) { - const data = await getResponseData(response); - const error = new RequestError(toErrorMessage(data), status, { - response: { - url, - status, - headers, - data - }, - request: requestOptions - }); - throw error; - } - return parseSuccessResponseBody ? await getResponseData(response) : response.body; - }).then((data) => { - return { - status, - url, - headers, - data - }; - }).catch((error) => { - if (error instanceof RequestError) - throw error; - else if (error.name === "AbortError") - throw error; - let message = error.message; - if (error.name === "TypeError" && "cause" in error) { - if (error.cause instanceof Error) { - message = error.cause.message; - } else if (typeof error.cause === "string") { - message = error.cause; - } - } - throw new RequestError(message, 500, { + throw new RequestError(fetchResponse.statusText, status, { + response: octokitResponse, request: requestOptions }); - }); + } + if (status === 304) { + octokitResponse.data = await getResponseData(fetchResponse); + throw new RequestError("Not modified", status, { + response: octokitResponse, + request: requestOptions + }); + } + if (status >= 400) { + octokitResponse.data = await getResponseData(fetchResponse); + throw new RequestError(toErrorMessage(octokitResponse.data), status, { + response: octokitResponse, + request: requestOptions + }); + } + octokitResponse.data = parseSuccessResponseBody ? await getResponseData(fetchResponse) : fetchResponse.body; + return octokitResponse; } async function getResponseData(response) { const contentType = response.headers.get("content-type"); @@ -36919,22 +36934,18 @@ async function getResponseData(response) { if (!contentType || /^text\/|charset=utf-8$/.test(contentType)) { return response.text(); } - return getBufferResponse(response); + return response.arrayBuffer(); } function toErrorMessage(data) { - if (typeof data === "string") + if (typeof data === "string") { return data; - let suffix; - if ("documentation_url" in data) { - suffix = ` - ${data.documentation_url}`; - } else { - suffix = ""; + } + if (data instanceof ArrayBuffer) { + return "Unknown error"; } if ("message" in data) { - if (Array.isArray(data.errors)) { - return `${data.message}: ${data.errors.map(JSON.stringify).join(", ")}${suffix}`; - } - return `${data.message}${suffix}`; + const suffix = "documentation_url" in data ? ` - ${data.documentation_url}` : ""; + return Array.isArray(data.errors) ? `${data.message}: ${data.errors.map((v) => JSON.stringify(v)).join(", ")}${suffix}` : `${data.message}${suffix}`; } return `Unknown error: ${JSON.stringify(data)}`; } @@ -36961,11 +36972,7 @@ function withDefaults2(oldEndpoint, newDefaults) { defaults: withDefaults2.bind(null, endpoint2) }); } -var request = withDefaults2(endpoint, { - headers: { - "user-agent": `octokit-request.js/${VERSION2} ${getUserAgent()}` - } -}); +var request = withDefaults2(endpoint, defaults_default); // lib/request.js var import_undici = __toESM(require_undici2(), 1); diff --git a/package.json b/package.json index c2b621d..e58c7e5 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "create-github-app-token", "private": true, "type": "module", - "version": "1.10.3", + "version": "1.10.4", "description": "GitHub Action for creating a GitHub App Installation Access Token", "scripts": { "build": "esbuild main.js post.js --bundle --outdir=dist --out-extension:.js=.cjs --platform=node --target=node20.0.0 --packages=bundle",