mirror of
https://github.com/actions/create-github-app-token.git
synced 2026-12-03 15:09:03 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f418cff399 | ||
|
|
09c1ab7079 | ||
|
|
01b8009bd6 | ||
|
|
e056864841 | ||
|
|
679345a20e | ||
|
|
660c44c8ce | ||
|
|
18e9994c8d |
No files matched your search
@@ -40,10 +40,11 @@ jobs:
|
|||||||
ref: ${{ fromJSON(steps.release-please.outputs.pr).headBranchName }}
|
ref: ${{ fromJSON(steps.release-please.outputs.pr).headBranchName }}
|
||||||
token: ${{ steps.app-token.outputs.token }}
|
token: ${{ steps.app-token.outputs.token }}
|
||||||
|
|
||||||
- uses: actions/setup-node@v6
|
- uses: actions/setup-node@v7
|
||||||
if: steps.release-please.outputs.prs_created == 'true'
|
if: steps.release-please.outputs.prs_created == 'true'
|
||||||
with:
|
with:
|
||||||
node-version-file: package.json
|
node-version-file: package.json
|
||||||
|
package-manager-cache: false
|
||||||
|
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
if: steps.release-please.outputs.prs_created == 'true'
|
if: steps.release-please.outputs.prs_created == 'true'
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ jobs:
|
|||||||
stale:
|
stale:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/stale@v10
|
- uses: actions/stale@v11
|
||||||
with:
|
with:
|
||||||
operations-per-run: 100
|
operations-per-run: 100
|
||||||
days-before-stale: ${{ env.DAYS_BEFORE_STALE }}
|
days-before-stale: ${{ env.DAYS_BEFORE_STALE }}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v7
|
- uses: actions/checkout@v7
|
||||||
|
|
||||||
- uses: actions/setup-node@v6
|
- uses: actions/setup-node@v7
|
||||||
with:
|
with:
|
||||||
node-version-file: package.json
|
node-version-file: package.json
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ jobs:
|
|||||||
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.owner.login == github.event.pull_request.base.repo.owner.login
|
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.owner.login == github.event.pull_request.base.repo.owner.login
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v7
|
- uses: actions/checkout@v7
|
||||||
- uses: actions/setup-node@v6
|
- uses: actions/setup-node@v7
|
||||||
with:
|
with:
|
||||||
node-version-file: package.json
|
node-version-file: package.json
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
@@ -62,10 +62,9 @@ jobs:
|
|||||||
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.owner.login == github.event.pull_request.base.repo.owner.login
|
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.owner.login == github.event.pull_request.base.repo.owner.login
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v7
|
- uses: actions/checkout@v7
|
||||||
- uses: actions/setup-node@v6
|
- uses: actions/setup-node@v7
|
||||||
with:
|
with:
|
||||||
node-version-file: package.json
|
node-version-file: package.json
|
||||||
cache: 'npm'
|
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
- run: npm run build
|
- run: npm run build
|
||||||
- uses: ./ # Uses the action in the root directory
|
- uses: ./ # Uses the action in the root directory
|
||||||
|
|||||||
@@ -22,16 +22,17 @@ jobs:
|
|||||||
COMMIT_MESSAGE: 'feat: update permission inputs'
|
COMMIT_MESSAGE: 'feat: update permission inputs'
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v7
|
- uses: actions/checkout@v7
|
||||||
- uses: actions/setup-node@v6
|
- uses: actions/setup-node@v7
|
||||||
with:
|
with:
|
||||||
node-version-file: package.json
|
node-version-file: package.json
|
||||||
|
package-manager-cache: false
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: npm ci
|
run: npm ci
|
||||||
- name: Run permission inputs update script
|
- name: Run permission inputs update script
|
||||||
run: node scripts/update-permission-inputs.js
|
run: node scripts/update-permission-inputs.js
|
||||||
- name: Commit changes
|
- name: Commit changes
|
||||||
id: auto-commit
|
id: auto-commit
|
||||||
uses: stefanzweifel/git-auto-commit-action@4a55954c782fc1ea30b9056cd3e7a2b40ca8887d # v7.2.0
|
uses: stefanzweifel/git-auto-commit-action@d0b01107b5db882071f96de5dd4b54961ea93f4c # v7.2.1
|
||||||
with:
|
with:
|
||||||
commit_message: ${{ env.COMMIT_MESSAGE }}
|
commit_message: ${{ env.COMMIT_MESSAGE }}
|
||||||
- name: Update PR title
|
- name: Update PR title
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
".": "3.4.0-beta"
|
".": "3.4.0"
|
||||||
}
|
}
|
||||||
+9
-2
@@ -1,11 +1,18 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## [3.4.0-beta](https://github.com/actions/create-github-app-token/compare/v3.3.0...v3.4.0-beta) (2026-11-17)
|
## [3.4.0](https://github.com/actions/create-github-app-token/compare/v3.3.0...v3.4.0) (2026-11-18)
|
||||||
|
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
* support GitHub Actions OIDC authentication ([#411](https://github.com/actions/create-github-app-token/issues/411)) ([8240f10](https://github.com/actions/create-github-app-token/commit/8240f10d3ae05b4d450da83e8e247111a36eaf2c))
|
* bump actions/setup-node from 6 to 7 ([#410](https://github.com/actions/create-github-app-token/issues/410)) ([09c1ab7](https://github.com/actions/create-github-app-token/commit/09c1ab7079f14af5f0d64c9325739c49a8541f56))
|
||||||
|
* bump actions/stale from 10 to 11 ([#409](https://github.com/actions/create-github-app-token/issues/409)) ([679345a](https://github.com/actions/create-github-app-token/commit/679345a20e2e07130130e6cf0301b9e897f18cd5))
|
||||||
|
* bump stefanzweifel/git-auto-commit-action from 7.2.0 to 7.2.1 in the github-actions group ([#408](https://github.com/actions/create-github-app-token/issues/408)) ([660c44c](https://github.com/actions/create-github-app-token/commit/660c44c8ce22207448fbba2730cd2913052c9de3))
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **deps:** bump undici ([#406](https://github.com/actions/create-github-app-token/issues/406)) ([18e9994](https://github.com/actions/create-github-app-token/commit/18e9994c8d13ac7c7e2bbcc3355a1a4f31d30de7))
|
||||||
|
|
||||||
## [3.3.0](https://github.com/actions/create-github-app-token/compare/v3.2.0...v3.3.0) (2026-10-12)
|
## [3.3.0](https://github.com/actions/create-github-app-token/compare/v3.2.0...v3.3.0) (2026-10-12)
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -13,8 +13,8 @@ inputs:
|
|||||||
required: false
|
required: false
|
||||||
deprecationMessage: "Use 'client-id' instead."
|
deprecationMessage: "Use 'client-id' instead."
|
||||||
private-key:
|
private-key:
|
||||||
description: "GitHub App private key. If omitted, authenticate using GitHub Actions OIDC (requires client-id and id-token: write, and a private app owned by the workflow repository's organization)."
|
description: "GitHub App private key"
|
||||||
required: false
|
required: true
|
||||||
owner:
|
owner:
|
||||||
description: "The owner of the GitHub App installation (defaults to current repository owner)"
|
description: "The owner of the GitHub App installation (defaults to current repository owner)"
|
||||||
required: false
|
required: false
|
||||||
|
|||||||
Vendored
+122
-72
@@ -2103,6 +2103,7 @@ var require_dispatcher = __commonJS({
|
|||||||
var require_dispatcher_base = __commonJS({
|
var require_dispatcher_base = __commonJS({
|
||||||
"node_modules/@actions/http-client/node_modules/undici/lib/dispatcher/dispatcher-base.js"(exports2, module2) {
|
"node_modules/@actions/http-client/node_modules/undici/lib/dispatcher/dispatcher-base.js"(exports2, module2) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
var buffer = require("node:buffer");
|
||||||
var Dispatcher = require_dispatcher();
|
var Dispatcher = require_dispatcher();
|
||||||
var {
|
var {
|
||||||
ClientDestroyedError,
|
ClientDestroyedError,
|
||||||
@@ -2114,6 +2115,7 @@ var require_dispatcher_base = __commonJS({
|
|||||||
var kOnClosed = /* @__PURE__ */ Symbol("onClosed");
|
var kOnClosed = /* @__PURE__ */ Symbol("onClosed");
|
||||||
var kInterceptedDispatch = /* @__PURE__ */ Symbol("Intercepted Dispatch");
|
var kInterceptedDispatch = /* @__PURE__ */ Symbol("Intercepted Dispatch");
|
||||||
var kWebSocketOptions = /* @__PURE__ */ Symbol("webSocketOptions");
|
var kWebSocketOptions = /* @__PURE__ */ Symbol("webSocketOptions");
|
||||||
|
var kEventSourceOptions = /* @__PURE__ */ Symbol("eventSourceOptions");
|
||||||
var DispatcherBase = class extends Dispatcher {
|
var DispatcherBase = class extends Dispatcher {
|
||||||
constructor(opts) {
|
constructor(opts) {
|
||||||
super();
|
super();
|
||||||
@@ -2122,6 +2124,7 @@ var require_dispatcher_base = __commonJS({
|
|||||||
this[kClosed] = false;
|
this[kClosed] = false;
|
||||||
this[kOnClosed] = [];
|
this[kOnClosed] = [];
|
||||||
this[kWebSocketOptions] = opts?.webSocket ?? {};
|
this[kWebSocketOptions] = opts?.webSocket ?? {};
|
||||||
|
this[kEventSourceOptions] = opts?.eventSource ?? {};
|
||||||
}
|
}
|
||||||
get webSocketOptions() {
|
get webSocketOptions() {
|
||||||
return {
|
return {
|
||||||
@@ -2129,6 +2132,11 @@ var require_dispatcher_base = __commonJS({
|
|||||||
maxPayloadSize: this[kWebSocketOptions].maxPayloadSize ?? 128 * 1024 * 1024
|
maxPayloadSize: this[kWebSocketOptions].maxPayloadSize ?? 128 * 1024 * 1024
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
get eventSourceOptions() {
|
||||||
|
return {
|
||||||
|
maxEventSize: this[kEventSourceOptions].maxEventSize ?? buffer.kStringMaxLength
|
||||||
|
};
|
||||||
|
}
|
||||||
get destroyed() {
|
get destroyed() {
|
||||||
return this[kDestroyed];
|
return this[kDestroyed];
|
||||||
}
|
}
|
||||||
@@ -6276,7 +6284,6 @@ var require_client_h1 = __commonJS({
|
|||||||
socket[kSocketUsed] = false;
|
socket[kSocketUsed] = false;
|
||||||
socket[kParser] = new Parser(client, socket, llhttpInstance);
|
socket[kParser] = new Parser(client, socket, llhttpInstance);
|
||||||
addListener(socket, "error", function(err) {
|
addListener(socket, "error", function(err) {
|
||||||
assert(err.code !== "ERR_TLS_CERT_ALTNAME_INVALID");
|
|
||||||
const parser = this[kParser];
|
const parser = this[kParser];
|
||||||
if (err.code === "ECONNRESET" && parser.statusCode && !parser.shouldKeepAlive) {
|
if (err.code === "ECONNRESET" && parser.statusCode && !parser.shouldKeepAlive) {
|
||||||
const parserErr = parser.finish();
|
const parserErr = parser.finish();
|
||||||
@@ -6960,7 +6967,6 @@ var require_client_h2 = __commonJS({
|
|||||||
client[kHTTP2Session] = session;
|
client[kHTTP2Session] = session;
|
||||||
socket[kHTTP2Session] = session;
|
socket[kHTTP2Session] = session;
|
||||||
util.addListener(socket, "error", function(err) {
|
util.addListener(socket, "error", function(err) {
|
||||||
assert(err.code !== "ERR_TLS_CERT_ALTNAME_INVALID");
|
|
||||||
this[kError] = err;
|
this[kError] = err;
|
||||||
this[kClient][kOnError](err);
|
this[kClient][kOnError](err);
|
||||||
});
|
});
|
||||||
@@ -7019,7 +7025,6 @@ var require_client_h2 = __commonJS({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
function onHttp2SessionError(err) {
|
function onHttp2SessionError(err) {
|
||||||
assert(err.code !== "ERR_TLS_CERT_ALTNAME_INVALID");
|
|
||||||
this[kSocket][kError] = err;
|
this[kSocket][kError] = err;
|
||||||
this[kClient][kOnError](err);
|
this[kClient][kOnError](err);
|
||||||
}
|
}
|
||||||
@@ -7713,9 +7718,10 @@ var require_client = __commonJS({
|
|||||||
// h2
|
// h2
|
||||||
maxConcurrentStreams,
|
maxConcurrentStreams,
|
||||||
allowH2,
|
allowH2,
|
||||||
webSocket
|
webSocket,
|
||||||
|
eventSource
|
||||||
} = {}) {
|
} = {}) {
|
||||||
super({ webSocket });
|
super({ webSocket, eventSource });
|
||||||
if (keepAlive !== void 0) {
|
if (keepAlive !== void 0) {
|
||||||
throw new InvalidArgumentError("unsupported keepAlive, use pipelining=0 instead");
|
throw new InvalidArgumentError("unsupported keepAlive, use pipelining=0 instead");
|
||||||
}
|
}
|
||||||
@@ -8612,7 +8618,7 @@ var require_agent = __commonJS({
|
|||||||
return opts && opts.connections === 1 ? new Client(origin, opts) : new Pool(origin, opts);
|
return opts && opts.connections === 1 ? new Client(origin, opts) : new Pool(origin, opts);
|
||||||
}
|
}
|
||||||
var Agent3 = class extends DispatcherBase {
|
var Agent3 = class extends DispatcherBase {
|
||||||
constructor({ factory = defaultFactory, maxRedirections = 0, connect, ...options } = {}) {
|
constructor({ factory = defaultFactory, maxRedirections = 0, connect, tls, ...options } = {}) {
|
||||||
if (typeof factory !== "function") {
|
if (typeof factory !== "function") {
|
||||||
throw new InvalidArgumentError("factory must be a function.");
|
throw new InvalidArgumentError("factory must be a function.");
|
||||||
}
|
}
|
||||||
@@ -8626,8 +8632,11 @@ var require_agent = __commonJS({
|
|||||||
if (connect && typeof connect !== "function") {
|
if (connect && typeof connect !== "function") {
|
||||||
connect = { ...connect };
|
connect = { ...connect };
|
||||||
}
|
}
|
||||||
|
if (tls && typeof tls !== "function") {
|
||||||
|
tls = { ...tls };
|
||||||
|
}
|
||||||
this[kInterceptors] = options.interceptors?.Agent && Array.isArray(options.interceptors.Agent) ? options.interceptors.Agent : [createRedirectInterceptor({ maxRedirections })];
|
this[kInterceptors] = options.interceptors?.Agent && Array.isArray(options.interceptors.Agent) ? options.interceptors.Agent : [createRedirectInterceptor({ maxRedirections })];
|
||||||
this[kOptions] = { ...util.deepClone(options), connect };
|
this[kOptions] = { ...util.deepClone(options), connect, tls };
|
||||||
this[kOptions].interceptors = options.interceptors ? { ...options.interceptors } : void 0;
|
this[kOptions].interceptors = options.interceptors ? { ...options.interceptors } : void 0;
|
||||||
this[kMaxRedirections] = maxRedirections;
|
this[kMaxRedirections] = maxRedirections;
|
||||||
this[kFactory] = factory;
|
this[kFactory] = factory;
|
||||||
@@ -14355,8 +14364,9 @@ var require_fetch = __commonJS({
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
response.body = { stream, source: null, length: null };
|
response.body = { stream, source: null, length: null };
|
||||||
fetchParams.controller.onAborted = onAborted;
|
if (!fetchParams.controller.resume) {
|
||||||
fetchParams.controller.on("terminated", onAborted);
|
fetchParams.controller.on("terminated", onAborted);
|
||||||
|
}
|
||||||
fetchParams.controller.resume = async () => {
|
fetchParams.controller.resume = async () => {
|
||||||
while (true) {
|
while (true) {
|
||||||
let bytes;
|
let bytes;
|
||||||
@@ -14456,7 +14466,6 @@ var require_fetch = __commonJS({
|
|||||||
headersList.append(bufferToLowerCasedHeaderName(rawHeaders[i]), rawHeaders[i + 1].toString("latin1"), true);
|
headersList.append(bufferToLowerCasedHeaderName(rawHeaders[i]), rawHeaders[i + 1].toString("latin1"), true);
|
||||||
}
|
}
|
||||||
location = headersList.get("location", true);
|
location = headersList.get("location", true);
|
||||||
this.body = new Readable({ read: resume });
|
|
||||||
const decoders = [];
|
const decoders = [];
|
||||||
const willFollow = location && request2.redirect === "follow" && redirectStatusSet.has(status);
|
const willFollow = location && request2.redirect === "follow" && redirectStatusSet.has(status);
|
||||||
if (request2.method !== "HEAD" && request2.method !== "CONNECT" && !nullBodyStatus.includes(status) && !willFollow) {
|
if (request2.method !== "HEAD" && request2.method !== "CONNECT" && !nullBodyStatus.includes(status) && !willFollow) {
|
||||||
@@ -14464,7 +14473,7 @@ var require_fetch = __commonJS({
|
|||||||
const codings = contentEncoding ? contentEncoding.toLowerCase().split(",") : [];
|
const codings = contentEncoding ? contentEncoding.toLowerCase().split(",") : [];
|
||||||
const maxContentEncodings = 5;
|
const maxContentEncodings = 5;
|
||||||
if (codings.length > maxContentEncodings) {
|
if (codings.length > maxContentEncodings) {
|
||||||
reject(new Error(`too many content-encodings in response: ${codings.length}, maximum allowed is ${maxContentEncodings}`));
|
this.abort(new Error(`too many content-encodings in response: ${codings.length}, maximum allowed is ${maxContentEncodings}`));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
for (let i = codings.length - 1; i >= 0; --i) {
|
for (let i = codings.length - 1; i >= 0; --i) {
|
||||||
@@ -14494,6 +14503,7 @@ var require_fetch = __commonJS({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.body = new Readable({ read: resume });
|
||||||
const onError = this.onError.bind(this);
|
const onError = this.onError.bind(this);
|
||||||
resolve2({
|
resolve2({
|
||||||
status,
|
status,
|
||||||
@@ -14519,9 +14529,6 @@ var require_fetch = __commonJS({
|
|||||||
if (this.abort) {
|
if (this.abort) {
|
||||||
fetchParams.controller.off("terminated", this.abort);
|
fetchParams.controller.off("terminated", this.abort);
|
||||||
}
|
}
|
||||||
if (fetchParams.controller.onAborted) {
|
|
||||||
fetchParams.controller.off("terminated", fetchParams.controller.onAborted);
|
|
||||||
}
|
|
||||||
fetchParams.controller.ended = true;
|
fetchParams.controller.ended = true;
|
||||||
this.body.push(null);
|
this.body.push(null);
|
||||||
},
|
},
|
||||||
@@ -17595,6 +17602,16 @@ var require_receiver = __commonJS({
|
|||||||
if (isControlFrame(this.#info.opcode)) {
|
if (isControlFrame(this.#info.opcode)) {
|
||||||
this.#loop = this.parseControlFrame(body);
|
this.#loop = this.parseControlFrame(body);
|
||||||
this.#state = parserStates.INFO;
|
this.#state = parserStates.INFO;
|
||||||
|
const socket = this.ws[kResponse].socket;
|
||||||
|
if (this.#loop && socket.writableNeedDrain) {
|
||||||
|
this.#loop = false;
|
||||||
|
socket.once("drain", () => {
|
||||||
|
if (this.destroyed) return;
|
||||||
|
this.#loop = true;
|
||||||
|
this.run(callback);
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!this.#info.compressed) {
|
if (!this.#info.compressed) {
|
||||||
if (!this.writeFragments(body)) {
|
if (!this.writeFragments(body)) {
|
||||||
@@ -18288,6 +18305,7 @@ var require_util8 = __commonJS({
|
|||||||
var require_eventsource_stream = __commonJS({
|
var require_eventsource_stream = __commonJS({
|
||||||
"node_modules/@actions/http-client/node_modules/undici/lib/web/eventsource/eventsource-stream.js"(exports2, module2) {
|
"node_modules/@actions/http-client/node_modules/undici/lib/web/eventsource/eventsource-stream.js"(exports2, module2) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
var buffer = require("node:buffer");
|
||||||
var { Transform } = require("node:stream");
|
var { Transform } = require("node:stream");
|
||||||
var { isASCIINumber, isValidLastEventId } = require_util8();
|
var { isASCIINumber, isValidLastEventId } = require_util8();
|
||||||
var BOM = [239, 187, 191];
|
var BOM = [239, 187, 191];
|
||||||
@@ -18295,24 +18313,28 @@ var require_eventsource_stream = __commonJS({
|
|||||||
var CR = 13;
|
var CR = 13;
|
||||||
var COLON = 58;
|
var COLON = 58;
|
||||||
var SPACE = 32;
|
var SPACE = 32;
|
||||||
|
var defaultMaxEventSize = buffer.kStringMaxLength;
|
||||||
var DATA = Buffer.from("data");
|
var DATA = Buffer.from("data");
|
||||||
var EVENT = Buffer.from("event");
|
var EVENT = Buffer.from("event");
|
||||||
var ID = Buffer.from("id");
|
var ID = Buffer.from("id");
|
||||||
var RETRY = Buffer.from("retry");
|
var RETRY = Buffer.from("retry");
|
||||||
function isASCIINumberBytes(buffer, start) {
|
var minParserItems = 1024;
|
||||||
if (start >= buffer.length) {
|
var maxParserItems = 131072;
|
||||||
|
var bytesPerParserItem = 128;
|
||||||
|
function isASCIINumberBytes(buffer2, start) {
|
||||||
|
if (start >= buffer2.length) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (let i = start; i < buffer.length; i++) {
|
for (let i = start; i < buffer2.length; i++) {
|
||||||
if (buffer[i] < 48 || buffer[i] > 57) {
|
if (buffer2[i] < 48 || buffer2[i] > 57) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
function isValidLastEventIdBytes(buffer, start) {
|
function isValidLastEventIdBytes(buffer2, start) {
|
||||||
for (let i = start; i < buffer.length; i++) {
|
for (let i = start; i < buffer2.length; i++) {
|
||||||
if (buffer[i] === 0) {
|
if (buffer2[i] === 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -18329,6 +18351,11 @@ var require_eventsource_stream = __commonJS({
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
function createMaxEventSizeExceededError() {
|
||||||
|
const error2 = new Error("EventSource message size exceeded");
|
||||||
|
error2.aborted = false;
|
||||||
|
return error2;
|
||||||
|
}
|
||||||
var EventSourceStream = class extends Transform {
|
var EventSourceStream = class extends Transform {
|
||||||
/**
|
/**
|
||||||
* @type {eventSourceSettings}
|
* @type {eventSourceSettings}
|
||||||
@@ -18355,6 +18382,13 @@ var require_eventsource_stream = __commonJS({
|
|||||||
pos = 0;
|
pos = 0;
|
||||||
lineChunkIndex = 0;
|
lineChunkIndex = 0;
|
||||||
linePos = 0;
|
linePos = 0;
|
||||||
|
lineLength = 0;
|
||||||
|
eventSize = 0;
|
||||||
|
eventFieldSizes = { data: 0, event: 0, id: 0, retry: 0 };
|
||||||
|
dataLineCount = 0;
|
||||||
|
maxEventSize;
|
||||||
|
maxDataLines;
|
||||||
|
maxBufferedChunks;
|
||||||
event = {
|
event = {
|
||||||
data: void 0,
|
data: void 0,
|
||||||
event: void 0,
|
event: void 0,
|
||||||
@@ -18363,6 +18397,7 @@ var require_eventsource_stream = __commonJS({
|
|||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* @param {object} options
|
* @param {object} options
|
||||||
|
* @param {number} [options.maxEventSize]
|
||||||
* @param {eventSourceSettings} options.eventSourceSettings
|
* @param {eventSourceSettings} options.eventSourceSettings
|
||||||
* @param {Function} [options.push]
|
* @param {Function} [options.push]
|
||||||
*/
|
*/
|
||||||
@@ -18370,6 +18405,10 @@ var require_eventsource_stream = __commonJS({
|
|||||||
options.readableObjectMode = true;
|
options.readableObjectMode = true;
|
||||||
super(options);
|
super(options);
|
||||||
this.state = options.eventSourceSettings || {};
|
this.state = options.eventSourceSettings || {};
|
||||||
|
this.maxEventSize = options.maxEventSize ?? defaultMaxEventSize;
|
||||||
|
const parserItemLimit = this.maxEventSize > 0 ? Math.min(maxParserItems, Math.max(minParserItems, Math.floor(this.maxEventSize / bytesPerParserItem))) : 0;
|
||||||
|
this.maxDataLines = parserItemLimit;
|
||||||
|
this.maxBufferedChunks = parserItemLimit;
|
||||||
if (options.push) {
|
if (options.push) {
|
||||||
this.push = options.push;
|
this.push = options.push;
|
||||||
}
|
}
|
||||||
@@ -18385,6 +18424,10 @@ var require_eventsource_stream = __commonJS({
|
|||||||
callback();
|
callback();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (this.maxEventSize > 0 && this.chunks.length >= this.maxBufferedChunks && chunk[0] !== LF && chunk[0] !== CR) {
|
||||||
|
callback(createMaxEventSizeExceededError());
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.chunks.push(chunk);
|
this.chunks.push(chunk);
|
||||||
if (this.checkBOM) {
|
if (this.checkBOM) {
|
||||||
if (this.handleBOM()) {
|
if (this.handleBOM()) {
|
||||||
@@ -18421,18 +18464,32 @@ var require_eventsource_stream = __commonJS({
|
|||||||
if (byte === CR) {
|
if (byte === CR) {
|
||||||
this.crlfCheck = true;
|
this.crlfCheck = true;
|
||||||
}
|
}
|
||||||
this.parseLine(this.readLine(), this.event);
|
try {
|
||||||
|
this.parseLine(this.readLine(), this.event);
|
||||||
|
} catch (error2) {
|
||||||
|
callback(error2);
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.consumeCurrentByte();
|
this.consumeCurrentByte();
|
||||||
this.eventEndCheck = true;
|
this.eventEndCheck = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (this.maxEventSize > 0 && ++this.lineLength > this.maxEventSize + 7) {
|
||||||
|
callback(createMaxEventSizeExceededError());
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.advanceCursor();
|
this.advanceCursor();
|
||||||
}
|
}
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
|
_destroy(error2, callback) {
|
||||||
|
this.chunks.length = 0;
|
||||||
|
this.clearEvent();
|
||||||
|
super._destroy(error2, callback);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @param {Buffer} line
|
* @param {Buffer} line
|
||||||
* @param {EventStreamEvent} event
|
* @param {EventSourceStreamEvent} event
|
||||||
*/
|
*/
|
||||||
parseLine(line, event) {
|
parseLine(line, event) {
|
||||||
if (line.length === 0) {
|
if (line.length === 0) {
|
||||||
@@ -18452,6 +18509,12 @@ var require_eventsource_stream = __commonJS({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isFieldName(line, fieldLength, DATA)) {
|
if (isFieldName(line, fieldLength, DATA)) {
|
||||||
|
if (this.maxEventSize > 0 && this.dataLineCount >= this.maxDataLines) {
|
||||||
|
throw createMaxEventSizeExceededError();
|
||||||
|
}
|
||||||
|
const valueBytes = line.length - valueStart;
|
||||||
|
const dataSize = this.eventFieldSizes.data + (event.data === void 0 ? 0 : 1) + valueBytes;
|
||||||
|
this.setEventFieldSize("data", dataSize);
|
||||||
const value = line.toString("utf8", valueStart);
|
const value = line.toString("utf8", valueStart);
|
||||||
if (event.data === void 0) {
|
if (event.data === void 0) {
|
||||||
event.data = value;
|
event.data = value;
|
||||||
@@ -18459,27 +18522,38 @@ var require_eventsource_stream = __commonJS({
|
|||||||
event.data += `
|
event.data += `
|
||||||
${value}`;
|
${value}`;
|
||||||
}
|
}
|
||||||
|
this.dataLineCount++;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isFieldName(line, fieldLength, RETRY)) {
|
if (isFieldName(line, fieldLength, RETRY)) {
|
||||||
if (isASCIINumberBytes(line, valueStart)) {
|
if (isASCIINumberBytes(line, valueStart)) {
|
||||||
|
this.setEventFieldSize("retry", line.length - valueStart);
|
||||||
event.retry = line.toString("utf8", valueStart);
|
event.retry = line.toString("utf8", valueStart);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isFieldName(line, fieldLength, ID)) {
|
if (isFieldName(line, fieldLength, ID)) {
|
||||||
if (isValidLastEventIdBytes(line, valueStart)) {
|
if (isValidLastEventIdBytes(line, valueStart)) {
|
||||||
|
this.setEventFieldSize("id", line.length - valueStart);
|
||||||
event.id = line.toString("utf8", valueStart);
|
event.id = line.toString("utf8", valueStart);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isFieldName(line, fieldLength, EVENT)) {
|
if (isFieldName(line, fieldLength, EVENT)) {
|
||||||
const value = line.toString("utf8", valueStart);
|
if (valueStart < line.length) {
|
||||||
if (value.length > 0) {
|
this.setEventFieldSize("event", line.length - valueStart);
|
||||||
event.event = value;
|
event.event = line.toString("utf8", valueStart);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
setEventFieldSize(field, size) {
|
||||||
|
const eventSize = this.eventSize - this.eventFieldSizes[field] + size;
|
||||||
|
if (this.maxEventSize > 0 && eventSize > this.maxEventSize) {
|
||||||
|
throw createMaxEventSizeExceededError();
|
||||||
|
}
|
||||||
|
this.eventSize = eventSize;
|
||||||
|
this.eventFieldSizes[field] = size;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @param {EventSourceStreamEvent} event
|
* @param {EventSourceStreamEvent} event
|
||||||
*/
|
*/
|
||||||
@@ -18506,6 +18580,12 @@ ${value}`;
|
|||||||
this.event.event = void 0;
|
this.event.event = void 0;
|
||||||
this.event.id = void 0;
|
this.event.id = void 0;
|
||||||
this.event.retry = void 0;
|
this.event.retry = void 0;
|
||||||
|
this.eventSize = 0;
|
||||||
|
this.dataLineCount = 0;
|
||||||
|
this.eventFieldSizes.data = 0;
|
||||||
|
this.eventFieldSizes.event = 0;
|
||||||
|
this.eventFieldSizes.id = 0;
|
||||||
|
this.eventFieldSizes.retry = 0;
|
||||||
}
|
}
|
||||||
hasPendingEvent() {
|
hasPendingEvent() {
|
||||||
return this.event.data !== void 0 || this.event.event !== void 0 || this.event.id !== void 0 || this.event.retry !== void 0;
|
return this.event.data !== void 0 || this.event.event !== void 0 || this.event.id !== void 0 || this.event.retry !== void 0;
|
||||||
@@ -18530,13 +18610,15 @@ ${value}`;
|
|||||||
syncLineStartToCursor() {
|
syncLineStartToCursor() {
|
||||||
this.lineChunkIndex = this.chunkIndex;
|
this.lineChunkIndex = this.chunkIndex;
|
||||||
this.linePos = this.pos;
|
this.linePos = this.pos;
|
||||||
|
this.lineLength = 0;
|
||||||
this.dropConsumedChunks();
|
this.dropConsumedChunks();
|
||||||
}
|
}
|
||||||
dropConsumedChunks() {
|
dropConsumedChunks() {
|
||||||
while (this.lineChunkIndex > 0) {
|
if (this.lineChunkIndex > 0) {
|
||||||
this.chunks.shift();
|
const consumed = this.lineChunkIndex;
|
||||||
this.lineChunkIndex--;
|
this.chunks.splice(0, consumed);
|
||||||
this.chunkIndex--;
|
this.lineChunkIndex = 0;
|
||||||
|
this.chunkIndex -= consumed;
|
||||||
}
|
}
|
||||||
if (this.chunkIndex === this.chunks.length) {
|
if (this.chunkIndex === this.chunks.length) {
|
||||||
this.chunks.length = 0;
|
this.chunks.length = 0;
|
||||||
@@ -18639,6 +18721,7 @@ var require_eventsource = __commonJS({
|
|||||||
var { delay } = require_util8();
|
var { delay } = require_util8();
|
||||||
var { kEnumerableProperty } = require_util();
|
var { kEnumerableProperty } = require_util();
|
||||||
var { environmentSettingsObject } = require_util2();
|
var { environmentSettingsObject } = require_util2();
|
||||||
|
var { getGlobalDispatcher } = require_global2();
|
||||||
var experimentalWarned = false;
|
var experimentalWarned = false;
|
||||||
var defaultReconnectionTime = 3e3;
|
var defaultReconnectionTime = 3e3;
|
||||||
var CONNECTING = 0;
|
var CONNECTING = 0;
|
||||||
@@ -18779,6 +18862,7 @@ var require_eventsource = __commonJS({
|
|||||||
this.#state.origin = response.urlList[response.urlList.length - 1].origin;
|
this.#state.origin = response.urlList[response.urlList.length - 1].origin;
|
||||||
const eventSourceStream = new EventSourceStream({
|
const eventSourceStream = new EventSourceStream({
|
||||||
eventSourceSettings: this.#state,
|
eventSourceSettings: this.#state,
|
||||||
|
maxEventSize: this.#dispatcher.eventSourceOptions?.maxEventSize,
|
||||||
push: (event) => {
|
push: (event) => {
|
||||||
this.dispatchEvent(createFastMessageEvent(
|
this.dispatchEvent(createFastMessageEvent(
|
||||||
event.type,
|
event.type,
|
||||||
@@ -18911,7 +18995,8 @@ var require_eventsource = __commonJS({
|
|||||||
{
|
{
|
||||||
key: "dispatcher",
|
key: "dispatcher",
|
||||||
// undici only
|
// undici only
|
||||||
converter: webidl.converters.any
|
converter: webidl.converters.any,
|
||||||
|
defaultValue: () => getGlobalDispatcher()
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
module2.exports = {
|
module2.exports = {
|
||||||
@@ -23991,47 +24076,17 @@ async function pRetry(input, options = {}) {
|
|||||||
throw new Error("Retry attempts exhausted without throwing an error.");
|
throw new Error("Retry attempts exhausted without throwing an error.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// lib/create-oidc-auth.js
|
|
||||||
async function createOidcAuth(clientId, core, request2) {
|
|
||||||
const audience = `${process.env.GITHUB_SERVER_URL || "https://github.com"}/login/oauth`;
|
|
||||||
const token = await core.getIDToken(audience);
|
|
||||||
const auth5 = async ({ installationId, repositoryNames, permissions }) => {
|
|
||||||
const { data } = await request2(
|
|
||||||
"POST /app/installations/{installation_id}/access_tokens{?client_id}",
|
|
||||||
{
|
|
||||||
installation_id: installationId,
|
|
||||||
client_id: clientId,
|
|
||||||
repositories: repositoryNames,
|
|
||||||
permissions,
|
|
||||||
headers: { authorization: `Bearer ${token}` }
|
|
||||||
}
|
|
||||||
);
|
|
||||||
return { token: data.token, expiresAt: data.expires_at };
|
|
||||||
};
|
|
||||||
auth5.hook = (hookRequest, route, parameters) => {
|
|
||||||
const endpoint2 = hookRequest.endpoint(route, parameters);
|
|
||||||
const url = new URL(endpoint2.url);
|
|
||||||
url.searchParams.set("client_id", clientId);
|
|
||||||
endpoint2.url = url.toString();
|
|
||||||
endpoint2.headers.authorization = `Bearer ${token}`;
|
|
||||||
return hookRequest(endpoint2);
|
|
||||||
};
|
|
||||||
return auth5;
|
|
||||||
}
|
|
||||||
|
|
||||||
// lib/main.js
|
// lib/main.js
|
||||||
async function main(clientId, privateKey, enterprise, owner, repositories, permissions, core, createAppAuth2, request2, skipTokenRevoke) {
|
async function main(clientId, privateKey, enterprise, owner, repositories, permissions, core, createAppAuth2, request2, skipTokenRevoke) {
|
||||||
if (enterprise && (owner || repositories.length > 0)) {
|
if (enterprise && (owner || repositories.length > 0)) {
|
||||||
throw new Error("Cannot use 'enterprise' input with 'owner' or 'repositories' inputs");
|
throw new Error("Cannot use 'enterprise' input with 'owner' or 'repositories' inputs");
|
||||||
}
|
}
|
||||||
if (enterprise && !privateKey) {
|
|
||||||
throw new Error("The 'enterprise' input requires 'private-key'; OIDC authentication is not supported for enterprise installations.");
|
|
||||||
}
|
|
||||||
const target = resolveInstallationTarget(enterprise, owner, repositories, core);
|
const target = resolveInstallationTarget(enterprise, owner, repositories, core);
|
||||||
if (!privateKey) {
|
const auth5 = createAppAuth2({
|
||||||
core.info("No 'private-key' provided; authenticating with GitHub Actions OIDC.");
|
appId: clientId,
|
||||||
}
|
privateKey,
|
||||||
const auth5 = privateKey ? createAppAuth2({ appId: clientId, privateKey, request: request2 }) : await createOidcAuth(clientId, core, request2);
|
request: request2
|
||||||
|
});
|
||||||
const { authentication, installationId, appSlug } = await pRetry(
|
const { authentication, installationId, appSlug } = await pRetry(
|
||||||
() => getTokenFromTarget(request2, auth5, target, permissions),
|
() => getTokenFromTarget(request2, auth5, target, permissions),
|
||||||
createTokenRetryOptions(core, getTokenRetryDescription(target))
|
createTokenRetryOptions(core, getTokenRetryDescription(target))
|
||||||
@@ -24252,12 +24307,7 @@ async function run() {
|
|||||||
}
|
}
|
||||||
const privateKey = getInput("private-key");
|
const privateKey = getInput("private-key");
|
||||||
if (!privateKey) {
|
if (!privateKey) {
|
||||||
if (!process.env.ACTIONS_ID_TOKEN_REQUEST_URL || !process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN) {
|
throw new Error("The 'private-key' input must be set to a non-empty string. If using a secret or variable, ensure it is available in this workflow context.");
|
||||||
throw new Error("The 'private-key' input must be set to a non-empty string, or the workflow must have 'id-token: write' permissions to authenticate with OIDC. If using a secret or variable, ensure it is available in this workflow context.");
|
|
||||||
}
|
|
||||||
if (!getInput("client-id")) {
|
|
||||||
throw new Error("The 'client-id' input is required for OIDC authentication. The deprecated 'app-id' input is only supported with 'private-key'.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
const enterprise = getInput("enterprise");
|
const enterprise = getInput("enterprise");
|
||||||
const owner = getInput("owner");
|
const owner = getInput("owner");
|
||||||
|
|||||||
Vendored
+116
-31
@@ -2101,6 +2101,7 @@ var require_dispatcher = __commonJS({
|
|||||||
var require_dispatcher_base = __commonJS({
|
var require_dispatcher_base = __commonJS({
|
||||||
"node_modules/@actions/http-client/node_modules/undici/lib/dispatcher/dispatcher-base.js"(exports2, module2) {
|
"node_modules/@actions/http-client/node_modules/undici/lib/dispatcher/dispatcher-base.js"(exports2, module2) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
var buffer = require("node:buffer");
|
||||||
var Dispatcher = require_dispatcher();
|
var Dispatcher = require_dispatcher();
|
||||||
var {
|
var {
|
||||||
ClientDestroyedError,
|
ClientDestroyedError,
|
||||||
@@ -2112,6 +2113,7 @@ var require_dispatcher_base = __commonJS({
|
|||||||
var kOnClosed = /* @__PURE__ */ Symbol("onClosed");
|
var kOnClosed = /* @__PURE__ */ Symbol("onClosed");
|
||||||
var kInterceptedDispatch = /* @__PURE__ */ Symbol("Intercepted Dispatch");
|
var kInterceptedDispatch = /* @__PURE__ */ Symbol("Intercepted Dispatch");
|
||||||
var kWebSocketOptions = /* @__PURE__ */ Symbol("webSocketOptions");
|
var kWebSocketOptions = /* @__PURE__ */ Symbol("webSocketOptions");
|
||||||
|
var kEventSourceOptions = /* @__PURE__ */ Symbol("eventSourceOptions");
|
||||||
var DispatcherBase = class extends Dispatcher {
|
var DispatcherBase = class extends Dispatcher {
|
||||||
constructor(opts) {
|
constructor(opts) {
|
||||||
super();
|
super();
|
||||||
@@ -2120,6 +2122,7 @@ var require_dispatcher_base = __commonJS({
|
|||||||
this[kClosed] = false;
|
this[kClosed] = false;
|
||||||
this[kOnClosed] = [];
|
this[kOnClosed] = [];
|
||||||
this[kWebSocketOptions] = opts?.webSocket ?? {};
|
this[kWebSocketOptions] = opts?.webSocket ?? {};
|
||||||
|
this[kEventSourceOptions] = opts?.eventSource ?? {};
|
||||||
}
|
}
|
||||||
get webSocketOptions() {
|
get webSocketOptions() {
|
||||||
return {
|
return {
|
||||||
@@ -2127,6 +2130,11 @@ var require_dispatcher_base = __commonJS({
|
|||||||
maxPayloadSize: this[kWebSocketOptions].maxPayloadSize ?? 128 * 1024 * 1024
|
maxPayloadSize: this[kWebSocketOptions].maxPayloadSize ?? 128 * 1024 * 1024
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
get eventSourceOptions() {
|
||||||
|
return {
|
||||||
|
maxEventSize: this[kEventSourceOptions].maxEventSize ?? buffer.kStringMaxLength
|
||||||
|
};
|
||||||
|
}
|
||||||
get destroyed() {
|
get destroyed() {
|
||||||
return this[kDestroyed];
|
return this[kDestroyed];
|
||||||
}
|
}
|
||||||
@@ -6274,7 +6282,6 @@ var require_client_h1 = __commonJS({
|
|||||||
socket[kSocketUsed] = false;
|
socket[kSocketUsed] = false;
|
||||||
socket[kParser] = new Parser(client, socket, llhttpInstance);
|
socket[kParser] = new Parser(client, socket, llhttpInstance);
|
||||||
addListener(socket, "error", function(err) {
|
addListener(socket, "error", function(err) {
|
||||||
assert(err.code !== "ERR_TLS_CERT_ALTNAME_INVALID");
|
|
||||||
const parser = this[kParser];
|
const parser = this[kParser];
|
||||||
if (err.code === "ECONNRESET" && parser.statusCode && !parser.shouldKeepAlive) {
|
if (err.code === "ECONNRESET" && parser.statusCode && !parser.shouldKeepAlive) {
|
||||||
const parserErr = parser.finish();
|
const parserErr = parser.finish();
|
||||||
@@ -6958,7 +6965,6 @@ var require_client_h2 = __commonJS({
|
|||||||
client[kHTTP2Session] = session;
|
client[kHTTP2Session] = session;
|
||||||
socket[kHTTP2Session] = session;
|
socket[kHTTP2Session] = session;
|
||||||
util.addListener(socket, "error", function(err) {
|
util.addListener(socket, "error", function(err) {
|
||||||
assert(err.code !== "ERR_TLS_CERT_ALTNAME_INVALID");
|
|
||||||
this[kError] = err;
|
this[kError] = err;
|
||||||
this[kClient][kOnError](err);
|
this[kClient][kOnError](err);
|
||||||
});
|
});
|
||||||
@@ -7017,7 +7023,6 @@ var require_client_h2 = __commonJS({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
function onHttp2SessionError(err) {
|
function onHttp2SessionError(err) {
|
||||||
assert(err.code !== "ERR_TLS_CERT_ALTNAME_INVALID");
|
|
||||||
this[kSocket][kError] = err;
|
this[kSocket][kError] = err;
|
||||||
this[kClient][kOnError](err);
|
this[kClient][kOnError](err);
|
||||||
}
|
}
|
||||||
@@ -7711,9 +7716,10 @@ var require_client = __commonJS({
|
|||||||
// h2
|
// h2
|
||||||
maxConcurrentStreams,
|
maxConcurrentStreams,
|
||||||
allowH2,
|
allowH2,
|
||||||
webSocket
|
webSocket,
|
||||||
|
eventSource
|
||||||
} = {}) {
|
} = {}) {
|
||||||
super({ webSocket });
|
super({ webSocket, eventSource });
|
||||||
if (keepAlive !== void 0) {
|
if (keepAlive !== void 0) {
|
||||||
throw new InvalidArgumentError("unsupported keepAlive, use pipelining=0 instead");
|
throw new InvalidArgumentError("unsupported keepAlive, use pipelining=0 instead");
|
||||||
}
|
}
|
||||||
@@ -8610,7 +8616,7 @@ var require_agent = __commonJS({
|
|||||||
return opts && opts.connections === 1 ? new Client(origin, opts) : new Pool(origin, opts);
|
return opts && opts.connections === 1 ? new Client(origin, opts) : new Pool(origin, opts);
|
||||||
}
|
}
|
||||||
var Agent3 = class extends DispatcherBase {
|
var Agent3 = class extends DispatcherBase {
|
||||||
constructor({ factory = defaultFactory, maxRedirections = 0, connect, ...options } = {}) {
|
constructor({ factory = defaultFactory, maxRedirections = 0, connect, tls, ...options } = {}) {
|
||||||
if (typeof factory !== "function") {
|
if (typeof factory !== "function") {
|
||||||
throw new InvalidArgumentError("factory must be a function.");
|
throw new InvalidArgumentError("factory must be a function.");
|
||||||
}
|
}
|
||||||
@@ -8624,8 +8630,11 @@ var require_agent = __commonJS({
|
|||||||
if (connect && typeof connect !== "function") {
|
if (connect && typeof connect !== "function") {
|
||||||
connect = { ...connect };
|
connect = { ...connect };
|
||||||
}
|
}
|
||||||
|
if (tls && typeof tls !== "function") {
|
||||||
|
tls = { ...tls };
|
||||||
|
}
|
||||||
this[kInterceptors] = options.interceptors?.Agent && Array.isArray(options.interceptors.Agent) ? options.interceptors.Agent : [createRedirectInterceptor({ maxRedirections })];
|
this[kInterceptors] = options.interceptors?.Agent && Array.isArray(options.interceptors.Agent) ? options.interceptors.Agent : [createRedirectInterceptor({ maxRedirections })];
|
||||||
this[kOptions] = { ...util.deepClone(options), connect };
|
this[kOptions] = { ...util.deepClone(options), connect, tls };
|
||||||
this[kOptions].interceptors = options.interceptors ? { ...options.interceptors } : void 0;
|
this[kOptions].interceptors = options.interceptors ? { ...options.interceptors } : void 0;
|
||||||
this[kMaxRedirections] = maxRedirections;
|
this[kMaxRedirections] = maxRedirections;
|
||||||
this[kFactory] = factory;
|
this[kFactory] = factory;
|
||||||
@@ -14353,8 +14362,9 @@ var require_fetch = __commonJS({
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
response.body = { stream, source: null, length: null };
|
response.body = { stream, source: null, length: null };
|
||||||
fetchParams.controller.onAborted = onAborted;
|
if (!fetchParams.controller.resume) {
|
||||||
fetchParams.controller.on("terminated", onAborted);
|
fetchParams.controller.on("terminated", onAborted);
|
||||||
|
}
|
||||||
fetchParams.controller.resume = async () => {
|
fetchParams.controller.resume = async () => {
|
||||||
while (true) {
|
while (true) {
|
||||||
let bytes;
|
let bytes;
|
||||||
@@ -14454,7 +14464,6 @@ var require_fetch = __commonJS({
|
|||||||
headersList.append(bufferToLowerCasedHeaderName(rawHeaders[i]), rawHeaders[i + 1].toString("latin1"), true);
|
headersList.append(bufferToLowerCasedHeaderName(rawHeaders[i]), rawHeaders[i + 1].toString("latin1"), true);
|
||||||
}
|
}
|
||||||
location = headersList.get("location", true);
|
location = headersList.get("location", true);
|
||||||
this.body = new Readable({ read: resume });
|
|
||||||
const decoders = [];
|
const decoders = [];
|
||||||
const willFollow = location && request2.redirect === "follow" && redirectStatusSet.has(status);
|
const willFollow = location && request2.redirect === "follow" && redirectStatusSet.has(status);
|
||||||
if (request2.method !== "HEAD" && request2.method !== "CONNECT" && !nullBodyStatus.includes(status) && !willFollow) {
|
if (request2.method !== "HEAD" && request2.method !== "CONNECT" && !nullBodyStatus.includes(status) && !willFollow) {
|
||||||
@@ -14462,7 +14471,7 @@ var require_fetch = __commonJS({
|
|||||||
const codings = contentEncoding ? contentEncoding.toLowerCase().split(",") : [];
|
const codings = contentEncoding ? contentEncoding.toLowerCase().split(",") : [];
|
||||||
const maxContentEncodings = 5;
|
const maxContentEncodings = 5;
|
||||||
if (codings.length > maxContentEncodings) {
|
if (codings.length > maxContentEncodings) {
|
||||||
reject(new Error(`too many content-encodings in response: ${codings.length}, maximum allowed is ${maxContentEncodings}`));
|
this.abort(new Error(`too many content-encodings in response: ${codings.length}, maximum allowed is ${maxContentEncodings}`));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
for (let i = codings.length - 1; i >= 0; --i) {
|
for (let i = codings.length - 1; i >= 0; --i) {
|
||||||
@@ -14492,6 +14501,7 @@ var require_fetch = __commonJS({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.body = new Readable({ read: resume });
|
||||||
const onError = this.onError.bind(this);
|
const onError = this.onError.bind(this);
|
||||||
resolve2({
|
resolve2({
|
||||||
status,
|
status,
|
||||||
@@ -14517,9 +14527,6 @@ var require_fetch = __commonJS({
|
|||||||
if (this.abort) {
|
if (this.abort) {
|
||||||
fetchParams.controller.off("terminated", this.abort);
|
fetchParams.controller.off("terminated", this.abort);
|
||||||
}
|
}
|
||||||
if (fetchParams.controller.onAborted) {
|
|
||||||
fetchParams.controller.off("terminated", fetchParams.controller.onAborted);
|
|
||||||
}
|
|
||||||
fetchParams.controller.ended = true;
|
fetchParams.controller.ended = true;
|
||||||
this.body.push(null);
|
this.body.push(null);
|
||||||
},
|
},
|
||||||
@@ -17593,6 +17600,16 @@ var require_receiver = __commonJS({
|
|||||||
if (isControlFrame(this.#info.opcode)) {
|
if (isControlFrame(this.#info.opcode)) {
|
||||||
this.#loop = this.parseControlFrame(body);
|
this.#loop = this.parseControlFrame(body);
|
||||||
this.#state = parserStates.INFO;
|
this.#state = parserStates.INFO;
|
||||||
|
const socket = this.ws[kResponse].socket;
|
||||||
|
if (this.#loop && socket.writableNeedDrain) {
|
||||||
|
this.#loop = false;
|
||||||
|
socket.once("drain", () => {
|
||||||
|
if (this.destroyed) return;
|
||||||
|
this.#loop = true;
|
||||||
|
this.run(callback);
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!this.#info.compressed) {
|
if (!this.#info.compressed) {
|
||||||
if (!this.writeFragments(body)) {
|
if (!this.writeFragments(body)) {
|
||||||
@@ -18286,6 +18303,7 @@ var require_util8 = __commonJS({
|
|||||||
var require_eventsource_stream = __commonJS({
|
var require_eventsource_stream = __commonJS({
|
||||||
"node_modules/@actions/http-client/node_modules/undici/lib/web/eventsource/eventsource-stream.js"(exports2, module2) {
|
"node_modules/@actions/http-client/node_modules/undici/lib/web/eventsource/eventsource-stream.js"(exports2, module2) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
var buffer = require("node:buffer");
|
||||||
var { Transform } = require("node:stream");
|
var { Transform } = require("node:stream");
|
||||||
var { isASCIINumber, isValidLastEventId } = require_util8();
|
var { isASCIINumber, isValidLastEventId } = require_util8();
|
||||||
var BOM = [239, 187, 191];
|
var BOM = [239, 187, 191];
|
||||||
@@ -18293,24 +18311,28 @@ var require_eventsource_stream = __commonJS({
|
|||||||
var CR = 13;
|
var CR = 13;
|
||||||
var COLON = 58;
|
var COLON = 58;
|
||||||
var SPACE = 32;
|
var SPACE = 32;
|
||||||
|
var defaultMaxEventSize = buffer.kStringMaxLength;
|
||||||
var DATA = Buffer.from("data");
|
var DATA = Buffer.from("data");
|
||||||
var EVENT = Buffer.from("event");
|
var EVENT = Buffer.from("event");
|
||||||
var ID = Buffer.from("id");
|
var ID = Buffer.from("id");
|
||||||
var RETRY = Buffer.from("retry");
|
var RETRY = Buffer.from("retry");
|
||||||
function isASCIINumberBytes(buffer, start) {
|
var minParserItems = 1024;
|
||||||
if (start >= buffer.length) {
|
var maxParserItems = 131072;
|
||||||
|
var bytesPerParserItem = 128;
|
||||||
|
function isASCIINumberBytes(buffer2, start) {
|
||||||
|
if (start >= buffer2.length) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (let i = start; i < buffer.length; i++) {
|
for (let i = start; i < buffer2.length; i++) {
|
||||||
if (buffer[i] < 48 || buffer[i] > 57) {
|
if (buffer2[i] < 48 || buffer2[i] > 57) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
function isValidLastEventIdBytes(buffer, start) {
|
function isValidLastEventIdBytes(buffer2, start) {
|
||||||
for (let i = start; i < buffer.length; i++) {
|
for (let i = start; i < buffer2.length; i++) {
|
||||||
if (buffer[i] === 0) {
|
if (buffer2[i] === 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -18327,6 +18349,11 @@ var require_eventsource_stream = __commonJS({
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
function createMaxEventSizeExceededError() {
|
||||||
|
const error2 = new Error("EventSource message size exceeded");
|
||||||
|
error2.aborted = false;
|
||||||
|
return error2;
|
||||||
|
}
|
||||||
var EventSourceStream = class extends Transform {
|
var EventSourceStream = class extends Transform {
|
||||||
/**
|
/**
|
||||||
* @type {eventSourceSettings}
|
* @type {eventSourceSettings}
|
||||||
@@ -18353,6 +18380,13 @@ var require_eventsource_stream = __commonJS({
|
|||||||
pos = 0;
|
pos = 0;
|
||||||
lineChunkIndex = 0;
|
lineChunkIndex = 0;
|
||||||
linePos = 0;
|
linePos = 0;
|
||||||
|
lineLength = 0;
|
||||||
|
eventSize = 0;
|
||||||
|
eventFieldSizes = { data: 0, event: 0, id: 0, retry: 0 };
|
||||||
|
dataLineCount = 0;
|
||||||
|
maxEventSize;
|
||||||
|
maxDataLines;
|
||||||
|
maxBufferedChunks;
|
||||||
event = {
|
event = {
|
||||||
data: void 0,
|
data: void 0,
|
||||||
event: void 0,
|
event: void 0,
|
||||||
@@ -18361,6 +18395,7 @@ var require_eventsource_stream = __commonJS({
|
|||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* @param {object} options
|
* @param {object} options
|
||||||
|
* @param {number} [options.maxEventSize]
|
||||||
* @param {eventSourceSettings} options.eventSourceSettings
|
* @param {eventSourceSettings} options.eventSourceSettings
|
||||||
* @param {Function} [options.push]
|
* @param {Function} [options.push]
|
||||||
*/
|
*/
|
||||||
@@ -18368,6 +18403,10 @@ var require_eventsource_stream = __commonJS({
|
|||||||
options.readableObjectMode = true;
|
options.readableObjectMode = true;
|
||||||
super(options);
|
super(options);
|
||||||
this.state = options.eventSourceSettings || {};
|
this.state = options.eventSourceSettings || {};
|
||||||
|
this.maxEventSize = options.maxEventSize ?? defaultMaxEventSize;
|
||||||
|
const parserItemLimit = this.maxEventSize > 0 ? Math.min(maxParserItems, Math.max(minParserItems, Math.floor(this.maxEventSize / bytesPerParserItem))) : 0;
|
||||||
|
this.maxDataLines = parserItemLimit;
|
||||||
|
this.maxBufferedChunks = parserItemLimit;
|
||||||
if (options.push) {
|
if (options.push) {
|
||||||
this.push = options.push;
|
this.push = options.push;
|
||||||
}
|
}
|
||||||
@@ -18383,6 +18422,10 @@ var require_eventsource_stream = __commonJS({
|
|||||||
callback();
|
callback();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (this.maxEventSize > 0 && this.chunks.length >= this.maxBufferedChunks && chunk[0] !== LF && chunk[0] !== CR) {
|
||||||
|
callback(createMaxEventSizeExceededError());
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.chunks.push(chunk);
|
this.chunks.push(chunk);
|
||||||
if (this.checkBOM) {
|
if (this.checkBOM) {
|
||||||
if (this.handleBOM()) {
|
if (this.handleBOM()) {
|
||||||
@@ -18419,18 +18462,32 @@ var require_eventsource_stream = __commonJS({
|
|||||||
if (byte === CR) {
|
if (byte === CR) {
|
||||||
this.crlfCheck = true;
|
this.crlfCheck = true;
|
||||||
}
|
}
|
||||||
this.parseLine(this.readLine(), this.event);
|
try {
|
||||||
|
this.parseLine(this.readLine(), this.event);
|
||||||
|
} catch (error2) {
|
||||||
|
callback(error2);
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.consumeCurrentByte();
|
this.consumeCurrentByte();
|
||||||
this.eventEndCheck = true;
|
this.eventEndCheck = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (this.maxEventSize > 0 && ++this.lineLength > this.maxEventSize + 7) {
|
||||||
|
callback(createMaxEventSizeExceededError());
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.advanceCursor();
|
this.advanceCursor();
|
||||||
}
|
}
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
|
_destroy(error2, callback) {
|
||||||
|
this.chunks.length = 0;
|
||||||
|
this.clearEvent();
|
||||||
|
super._destroy(error2, callback);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @param {Buffer} line
|
* @param {Buffer} line
|
||||||
* @param {EventStreamEvent} event
|
* @param {EventSourceStreamEvent} event
|
||||||
*/
|
*/
|
||||||
parseLine(line, event) {
|
parseLine(line, event) {
|
||||||
if (line.length === 0) {
|
if (line.length === 0) {
|
||||||
@@ -18450,6 +18507,12 @@ var require_eventsource_stream = __commonJS({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isFieldName(line, fieldLength, DATA)) {
|
if (isFieldName(line, fieldLength, DATA)) {
|
||||||
|
if (this.maxEventSize > 0 && this.dataLineCount >= this.maxDataLines) {
|
||||||
|
throw createMaxEventSizeExceededError();
|
||||||
|
}
|
||||||
|
const valueBytes = line.length - valueStart;
|
||||||
|
const dataSize = this.eventFieldSizes.data + (event.data === void 0 ? 0 : 1) + valueBytes;
|
||||||
|
this.setEventFieldSize("data", dataSize);
|
||||||
const value = line.toString("utf8", valueStart);
|
const value = line.toString("utf8", valueStart);
|
||||||
if (event.data === void 0) {
|
if (event.data === void 0) {
|
||||||
event.data = value;
|
event.data = value;
|
||||||
@@ -18457,27 +18520,38 @@ var require_eventsource_stream = __commonJS({
|
|||||||
event.data += `
|
event.data += `
|
||||||
${value}`;
|
${value}`;
|
||||||
}
|
}
|
||||||
|
this.dataLineCount++;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isFieldName(line, fieldLength, RETRY)) {
|
if (isFieldName(line, fieldLength, RETRY)) {
|
||||||
if (isASCIINumberBytes(line, valueStart)) {
|
if (isASCIINumberBytes(line, valueStart)) {
|
||||||
|
this.setEventFieldSize("retry", line.length - valueStart);
|
||||||
event.retry = line.toString("utf8", valueStart);
|
event.retry = line.toString("utf8", valueStart);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isFieldName(line, fieldLength, ID)) {
|
if (isFieldName(line, fieldLength, ID)) {
|
||||||
if (isValidLastEventIdBytes(line, valueStart)) {
|
if (isValidLastEventIdBytes(line, valueStart)) {
|
||||||
|
this.setEventFieldSize("id", line.length - valueStart);
|
||||||
event.id = line.toString("utf8", valueStart);
|
event.id = line.toString("utf8", valueStart);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isFieldName(line, fieldLength, EVENT)) {
|
if (isFieldName(line, fieldLength, EVENT)) {
|
||||||
const value = line.toString("utf8", valueStart);
|
if (valueStart < line.length) {
|
||||||
if (value.length > 0) {
|
this.setEventFieldSize("event", line.length - valueStart);
|
||||||
event.event = value;
|
event.event = line.toString("utf8", valueStart);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
setEventFieldSize(field, size) {
|
||||||
|
const eventSize = this.eventSize - this.eventFieldSizes[field] + size;
|
||||||
|
if (this.maxEventSize > 0 && eventSize > this.maxEventSize) {
|
||||||
|
throw createMaxEventSizeExceededError();
|
||||||
|
}
|
||||||
|
this.eventSize = eventSize;
|
||||||
|
this.eventFieldSizes[field] = size;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @param {EventSourceStreamEvent} event
|
* @param {EventSourceStreamEvent} event
|
||||||
*/
|
*/
|
||||||
@@ -18504,6 +18578,12 @@ ${value}`;
|
|||||||
this.event.event = void 0;
|
this.event.event = void 0;
|
||||||
this.event.id = void 0;
|
this.event.id = void 0;
|
||||||
this.event.retry = void 0;
|
this.event.retry = void 0;
|
||||||
|
this.eventSize = 0;
|
||||||
|
this.dataLineCount = 0;
|
||||||
|
this.eventFieldSizes.data = 0;
|
||||||
|
this.eventFieldSizes.event = 0;
|
||||||
|
this.eventFieldSizes.id = 0;
|
||||||
|
this.eventFieldSizes.retry = 0;
|
||||||
}
|
}
|
||||||
hasPendingEvent() {
|
hasPendingEvent() {
|
||||||
return this.event.data !== void 0 || this.event.event !== void 0 || this.event.id !== void 0 || this.event.retry !== void 0;
|
return this.event.data !== void 0 || this.event.event !== void 0 || this.event.id !== void 0 || this.event.retry !== void 0;
|
||||||
@@ -18528,13 +18608,15 @@ ${value}`;
|
|||||||
syncLineStartToCursor() {
|
syncLineStartToCursor() {
|
||||||
this.lineChunkIndex = this.chunkIndex;
|
this.lineChunkIndex = this.chunkIndex;
|
||||||
this.linePos = this.pos;
|
this.linePos = this.pos;
|
||||||
|
this.lineLength = 0;
|
||||||
this.dropConsumedChunks();
|
this.dropConsumedChunks();
|
||||||
}
|
}
|
||||||
dropConsumedChunks() {
|
dropConsumedChunks() {
|
||||||
while (this.lineChunkIndex > 0) {
|
if (this.lineChunkIndex > 0) {
|
||||||
this.chunks.shift();
|
const consumed = this.lineChunkIndex;
|
||||||
this.lineChunkIndex--;
|
this.chunks.splice(0, consumed);
|
||||||
this.chunkIndex--;
|
this.lineChunkIndex = 0;
|
||||||
|
this.chunkIndex -= consumed;
|
||||||
}
|
}
|
||||||
if (this.chunkIndex === this.chunks.length) {
|
if (this.chunkIndex === this.chunks.length) {
|
||||||
this.chunks.length = 0;
|
this.chunks.length = 0;
|
||||||
@@ -18637,6 +18719,7 @@ var require_eventsource = __commonJS({
|
|||||||
var { delay } = require_util8();
|
var { delay } = require_util8();
|
||||||
var { kEnumerableProperty } = require_util();
|
var { kEnumerableProperty } = require_util();
|
||||||
var { environmentSettingsObject } = require_util2();
|
var { environmentSettingsObject } = require_util2();
|
||||||
|
var { getGlobalDispatcher } = require_global2();
|
||||||
var experimentalWarned = false;
|
var experimentalWarned = false;
|
||||||
var defaultReconnectionTime = 3e3;
|
var defaultReconnectionTime = 3e3;
|
||||||
var CONNECTING = 0;
|
var CONNECTING = 0;
|
||||||
@@ -18777,6 +18860,7 @@ var require_eventsource = __commonJS({
|
|||||||
this.#state.origin = response.urlList[response.urlList.length - 1].origin;
|
this.#state.origin = response.urlList[response.urlList.length - 1].origin;
|
||||||
const eventSourceStream = new EventSourceStream({
|
const eventSourceStream = new EventSourceStream({
|
||||||
eventSourceSettings: this.#state,
|
eventSourceSettings: this.#state,
|
||||||
|
maxEventSize: this.#dispatcher.eventSourceOptions?.maxEventSize,
|
||||||
push: (event) => {
|
push: (event) => {
|
||||||
this.dispatchEvent(createFastMessageEvent(
|
this.dispatchEvent(createFastMessageEvent(
|
||||||
event.type,
|
event.type,
|
||||||
@@ -18909,7 +18993,8 @@ var require_eventsource = __commonJS({
|
|||||||
{
|
{
|
||||||
key: "dispatcher",
|
key: "dispatcher",
|
||||||
// undici only
|
// undici only
|
||||||
converter: webidl.converters.any
|
converter: webidl.converters.any,
|
||||||
|
defaultValue: () => getGlobalDispatcher()
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
module2.exports = {
|
module2.exports = {
|
||||||
|
|||||||
@@ -1,48 +0,0 @@
|
|||||||
// @ts-check
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates an auth strategy compatible with `@octokit/auth-app` that authenticates
|
|
||||||
* as a GitHub App using a GitHub Actions OIDC token instead of a private key.
|
|
||||||
*
|
|
||||||
* @param {string} clientId
|
|
||||||
* @param {Pick<import("@actions/core"), "getIDToken">} core
|
|
||||||
* @param {import("@octokit/request").request} request
|
|
||||||
*/
|
|
||||||
export async function createOidcAuth(clientId, core, request) {
|
|
||||||
const audience = `${process.env.GITHUB_SERVER_URL || "https://github.com"}/login/oauth`;
|
|
||||||
const token = await core.getIDToken(audience);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {{ installationId: number, repositoryNames?: string[], permissions?: Record<string, string> }} options
|
|
||||||
*/
|
|
||||||
const auth = async ({ installationId, repositoryNames, permissions }) => {
|
|
||||||
const { data } = await request(
|
|
||||||
"POST /app/installations/{installation_id}/access_tokens{?client_id}",
|
|
||||||
{
|
|
||||||
installation_id: installationId,
|
|
||||||
client_id: clientId,
|
|
||||||
repositories: repositoryNames,
|
|
||||||
permissions,
|
|
||||||
headers: { authorization: `Bearer ${token}` },
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
return { token: data.token, expiresAt: data.expires_at };
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {import("@octokit/request").request} hookRequest
|
|
||||||
* @param {string} route
|
|
||||||
* @param {Record<string, unknown>} [parameters]
|
|
||||||
*/
|
|
||||||
auth.hook = (hookRequest, route, parameters) => {
|
|
||||||
const endpoint = hookRequest.endpoint(route, parameters);
|
|
||||||
const url = new URL(endpoint.url);
|
|
||||||
url.searchParams.set("client_id", clientId);
|
|
||||||
endpoint.url = url.toString();
|
|
||||||
endpoint.headers.authorization = `Bearer ${token}`;
|
|
||||||
return hookRequest(endpoint);
|
|
||||||
};
|
|
||||||
|
|
||||||
return auth;
|
|
||||||
}
|
|
||||||
+5
-13
@@ -1,6 +1,5 @@
|
|||||||
import pRetry from "p-retry";
|
import pRetry from "p-retry";
|
||||||
import isNetworkError from "is-network-error";
|
import isNetworkError from "is-network-error";
|
||||||
import { createOidcAuth } from "./create-oidc-auth.js";
|
|
||||||
// @ts-check
|
// @ts-check
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -32,20 +31,13 @@ export async function main(
|
|||||||
throw new Error("Cannot use 'enterprise' input with 'owner' or 'repositories' inputs");
|
throw new Error("Cannot use 'enterprise' input with 'owner' or 'repositories' inputs");
|
||||||
}
|
}
|
||||||
|
|
||||||
// The enterprise installation lookup endpoint doesn't accept OIDC tokens
|
|
||||||
if (enterprise && !privateKey) {
|
|
||||||
throw new Error("The 'enterprise' input requires 'private-key'; OIDC authentication is not supported for enterprise installations.");
|
|
||||||
}
|
|
||||||
|
|
||||||
const target = resolveInstallationTarget(enterprise, owner, repositories, core);
|
const target = resolveInstallationTarget(enterprise, owner, repositories, core);
|
||||||
|
|
||||||
if (!privateKey) {
|
const auth = createAppAuth({
|
||||||
core.info("No 'private-key' provided; authenticating with GitHub Actions OIDC.");
|
appId: clientId,
|
||||||
}
|
privateKey,
|
||||||
|
request,
|
||||||
const auth = privateKey
|
});
|
||||||
? createAppAuth({ appId: clientId, privateKey, request })
|
|
||||||
: await createOidcAuth(clientId, core, request);
|
|
||||||
|
|
||||||
const { authentication, installationId, appSlug } = await pRetry(
|
const { authentication, installationId, appSlug } = await pRetry(
|
||||||
() => getTokenFromTarget(request, auth, target, permissions),
|
() => getTokenFromTarget(request, auth, target, permissions),
|
||||||
|
|||||||
@@ -24,12 +24,7 @@ async function run() {
|
|||||||
}
|
}
|
||||||
const privateKey = core.getInput("private-key");
|
const privateKey = core.getInput("private-key");
|
||||||
if (!privateKey) {
|
if (!privateKey) {
|
||||||
if (!process.env.ACTIONS_ID_TOKEN_REQUEST_URL || !process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN) {
|
throw new Error("The 'private-key' input must be set to a non-empty string. If using a secret or variable, ensure it is available in this workflow context.");
|
||||||
throw new Error("The 'private-key' input must be set to a non-empty string, or the workflow must have 'id-token: write' permissions to authenticate with OIDC. If using a secret or variable, ensure it is available in this workflow context.");
|
|
||||||
}
|
|
||||||
if (!core.getInput("client-id")) {
|
|
||||||
throw new Error("The 'client-id' input is required for OIDC authentication. The deprecated 'app-id' input is only supported with 'private-key'.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
const enterprise = core.getInput("enterprise");
|
const enterprise = core.getInput("enterprise");
|
||||||
const owner = core.getInput("owner");
|
const owner = core.getInput("owner");
|
||||||
|
|||||||
Generated
+9
-9
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "create-github-app-token",
|
"name": "create-github-app-token",
|
||||||
"version": "3.4.0-beta",
|
"version": "3.4.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "create-github-app-token",
|
"name": "create-github-app-token",
|
||||||
"version": "3.4.0-beta",
|
"version": "3.4.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^3.0.1",
|
"@actions/core": "^3.0.1",
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
"c8": "^12.0.0",
|
"c8": "^12.0.0",
|
||||||
"esbuild": "^0.28.2",
|
"esbuild": "^0.28.2",
|
||||||
"open-cli": "^9.0.0",
|
"open-cli": "^9.0.0",
|
||||||
"undici": "^8.11.2",
|
"undici": "^8.12.4",
|
||||||
"yaml": "^2.9.1"
|
"yaml": "^2.9.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
@@ -57,9 +57,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@actions/http-client/node_modules/undici": {
|
"node_modules/@actions/http-client/node_modules/undici": {
|
||||||
"version": "6.29.0",
|
"version": "6.29.1",
|
||||||
"resolved": "https://registry.npmjs.org/undici/-/undici-6.29.0.tgz",
|
"resolved": "https://registry.npmjs.org/undici/-/undici-6.29.1.tgz",
|
||||||
"integrity": "sha512-R+RODBqp6i2pPflGdq+xIOUkl+RNfGgHwoinecKu/JCuf2uO06cOKoDbI2P7Dn6KcswdKwrczbU6IYJ6K8X+wg==",
|
"integrity": "sha512-EvRlUt/QqAEvXdQeRMYUfwOQsfzpDztykrG2owGEE/rBOBoYv9uF39ZzsNDh4lTFHhTr2XOZjKkYgueD12ZmGA==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.17"
|
"node": ">=18.17"
|
||||||
@@ -1806,9 +1806,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/undici": {
|
"node_modules/undici": {
|
||||||
"version": "8.11.2",
|
"version": "8.12.4",
|
||||||
"resolved": "https://registry.npmjs.org/undici/-/undici-8.11.2.tgz",
|
"resolved": "https://registry.npmjs.org/undici/-/undici-8.12.4.tgz",
|
||||||
"integrity": "sha512-u4UB2/IrKdU6lFxumHmmo1a3fCQO5tzQllRorfoRS63txhrB7xTpSn1PftwC4qEHkOaqP95fCWW4lJzwErwzhQ==",
|
"integrity": "sha512-8Mx+uNKKER2bA4AdtedkqRbwUCIJFr2nJckXRe5yrDqzePqwLP7VNcctN8/XdmDSbF7mS+jJKIszlL+vbam1VA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|||||||
+2
-2
@@ -2,7 +2,7 @@
|
|||||||
"name": "create-github-app-token",
|
"name": "create-github-app-token",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "3.4.0-beta",
|
"version": "3.4.0",
|
||||||
"description": "GitHub Action for creating a GitHub App Installation Access Token",
|
"description": "GitHub Action for creating a GitHub App Installation Access Token",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=24.4.0"
|
"node": ">=24.4.0"
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
"c8": "^12.0.0",
|
"c8": "^12.0.0",
|
||||||
"esbuild": "^0.28.2",
|
"esbuild": "^0.28.2",
|
||||||
"open-cli": "^9.0.0",
|
"open-cli": "^9.0.0",
|
||||||
"undici": "^8.11.2",
|
"undici": "^8.12.4",
|
||||||
"yaml": "^2.9.1"
|
"yaml": "^2.9.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -34,4 +34,3 @@ We have tests both for the `main.js` and `post.js` scripts.
|
|||||||
|
|
||||||
- If you do not expect an error, take [main-token-permissions-set.test.js](main-token-permissions-set.test.js) as a starting point.
|
- If you do not expect an error, take [main-token-permissions-set.test.js](main-token-permissions-set.test.js) as a starting point.
|
||||||
- If your test has an expected error, take [main-missing-client-and-app-id.test.js](main-missing-client-and-app-id.test.js) as a starting point.
|
- If your test has an expected error, take [main-missing-client-and-app-id.test.js](main-missing-client-and-app-id.test.js) as a starting point.
|
||||||
- To authenticate with GitHub Actions OIDC instead of a private key, pass `OIDC_ENV` to `test()`, as in [main-oidc-token-permissions-set.test.js](main-oidc-token-permissions-set.test.js).
|
|
||||||
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
import { readdirSync } from "node:fs";
|
import { readdirSync } from "node:fs";
|
||||||
import { execFile } from "node:child_process";
|
import { execFile } from "node:child_process";
|
||||||
import { promisify } from "node:util";
|
import { promisify, stripVTControlCharacters } from "node:util";
|
||||||
|
|
||||||
import { snapshot, test } from "node:test";
|
import { snapshot, test } from "node:test";
|
||||||
|
|
||||||
@@ -60,8 +60,8 @@ for (const file of testFiles) {
|
|||||||
|
|
||||||
({ stderr, stdout } = error);
|
({ stderr, stdout } = error);
|
||||||
}
|
}
|
||||||
const trimmedStderr = stderr.replace(/\r?\n$/, "");
|
const trimmedStderr = stripVTControlCharacters(stderr).replace(/\r?\n$/, "");
|
||||||
const trimmedStdout = stdout.replace(/\r?\n$/, "");
|
const trimmedStdout = stripVTControlCharacters(stdout).replace(/\r?\n$/, "");
|
||||||
await t.test("stderr", (t) => {
|
await t.test("stderr", (t) => {
|
||||||
if (trimmedStderr) t.assert.snapshot(trimmedStderr);
|
if (trimmedStderr) t.assert.snapshot(trimmedStderr);
|
||||||
else t.assert.strictEqual(trimmedStderr, "");
|
else t.assert.strictEqual(trimmedStderr, "");
|
||||||
|
|||||||
+2
-62
@@ -148,77 +148,17 @@ GITHUB_REPOSITORY_OWNER missing, must be set to '<owner>'
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`main-missing-private-key.test.js > stderr 1`] = `
|
exports[`main-missing-private-key.test.js > stderr 1`] = `
|
||||||
The 'private-key' input must be set to a non-empty string, or the workflow must have 'id-token: write' permissions to authenticate with OIDC. If using a secret or variable, ensure it is available in this workflow context.
|
The 'private-key' input must be set to a non-empty string. If using a secret or variable, ensure it is available in this workflow context.
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`main-missing-private-key.test.js > stdout 1`] = `
|
exports[`main-missing-private-key.test.js > stdout 1`] = `
|
||||||
::error::The 'private-key' input must be set to a non-empty string, or the workflow must have 'id-token: write' permissions to authenticate with OIDC. If using a secret or variable, ensure it is available in this workflow context.
|
::error::The 'private-key' input must be set to a non-empty string. If using a secret or variable, ensure it is available in this workflow context.
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`main-missing-repository.test.js > stderr 1`] = `
|
exports[`main-missing-repository.test.js > stderr 1`] = `
|
||||||
GITHUB_REPOSITORY missing, must be set to '<owner>/<repo>'
|
GITHUB_REPOSITORY missing, must be set to '<owner>/<repo>'
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`main-oidc-custom-server-url.test.js > stdout 1`] = `
|
|
||||||
Input 'repositories' is not set. Creating token for all repositories owned by actions.
|
|
||||||
No 'private-key' provided; authenticating with GitHub Actions OIDC.
|
|
||||||
::debug::ID token url is http://127.0.0.1:<port>/token?api-version=2.0&audience=https%253A%252F%252Fgithub.example.com%252Flogin%252Foauth
|
|
||||||
::add-mask::oidc-token
|
|
||||||
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a
|
|
||||||
|
|
||||||
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a
|
|
||||||
|
|
||||||
::set-output name=installation-id::123456
|
|
||||||
|
|
||||||
::set-output name=app-slug::github-actions
|
|
||||||
::save-state name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a
|
|
||||||
::save-state name=expiresAt::2016-07-11T22:14:10Z
|
|
||||||
--- OIDC REQUESTS ---
|
|
||||||
GET /token?api-version=2.0&audience=https%3A%2F%2Fgithub.example.com%2Flogin%2Foauth
|
|
||||||
--- REQUESTS ---
|
|
||||||
GET /users/actions/installation?client_id=Iv1.0123456789abcdef
|
|
||||||
POST /app/installations/123456/access_tokens?client_id=Iv1.0123456789abcdef
|
|
||||||
null
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`main-oidc-enterprise-requires-private-key.test.js > stderr 1`] = `
|
|
||||||
The 'enterprise' input requires 'private-key'; OIDC authentication is not supported for enterprise installations.
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`main-oidc-enterprise-requires-private-key.test.js > stdout 1`] = `
|
|
||||||
::error::The 'enterprise' input requires 'private-key'; OIDC authentication is not supported for enterprise installations.
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`main-oidc-missing-client-id.test.js > stderr 1`] = `
|
|
||||||
The 'client-id' input is required for OIDC authentication. The deprecated 'app-id' input is only supported with 'private-key'.
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`main-oidc-missing-client-id.test.js > stdout 1`] = `
|
|
||||||
::error::The 'client-id' input is required for OIDC authentication. The deprecated 'app-id' input is only supported with 'private-key'.
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`main-oidc-token-permissions-set.test.js > stdout 1`] = `
|
|
||||||
Inputs 'owner' and 'repositories' are not set. Creating token for this repository (actions/create-github-app-token).
|
|
||||||
No 'private-key' provided; authenticating with GitHub Actions OIDC.
|
|
||||||
::debug::ID token url is http://127.0.0.1:<port>/token?api-version=2.0&audience=https%253A%252F%252Fgithub.com%252Flogin%252Foauth
|
|
||||||
::add-mask::oidc-token
|
|
||||||
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a
|
|
||||||
|
|
||||||
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a
|
|
||||||
|
|
||||||
::set-output name=installation-id::123456
|
|
||||||
|
|
||||||
::set-output name=app-slug::github-actions
|
|
||||||
::save-state name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a
|
|
||||||
::save-state name=expiresAt::2016-07-11T22:14:10Z
|
|
||||||
--- OIDC REQUESTS ---
|
|
||||||
GET /token?api-version=2.0&audience=https%3A%2F%2Fgithub.com%2Flogin%2Foauth
|
|
||||||
--- REQUESTS ---
|
|
||||||
GET /repos/actions/create-github-app-token/installation?client_id=Iv1.0123456789abcdef
|
|
||||||
POST /app/installations/123456/access_tokens?client_id=Iv1.0123456789abcdef
|
|
||||||
{"repositories":["create-github-app-token"],"permissions":{"issues":"write"}}
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`main-private-key-with-escaped-newlines.test.js > stdout 1`] = `
|
exports[`main-private-key-with-escaped-newlines.test.js > stdout 1`] = `
|
||||||
Inputs 'owner' and 'repositories' are not set. Creating token for this repository (actions/create-github-app-token).
|
Inputs 'owner' and 'repositories' are not set. Creating token for this repository (actions/create-github-app-token).
|
||||||
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a
|
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a
|
||||||
|
|||||||
@@ -13,10 +13,7 @@ for (const [key, value] of Object.entries({
|
|||||||
const _error = console.error;
|
const _error = console.error;
|
||||||
console.error = (err) => _error(err?.message ?? err);
|
console.error = (err) => _error(err?.message ?? err);
|
||||||
|
|
||||||
delete process.env.ACTIONS_ID_TOKEN_REQUEST_URL;
|
// Verify `main` exits with an error when `private-key` is not set.
|
||||||
delete process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN;
|
|
||||||
|
|
||||||
// Verify a missing private-key without OIDC permissions produces an actionable error.
|
|
||||||
const { default: promise } = await import("../main.js");
|
const { default: promise } = await import("../main.js");
|
||||||
await promise;
|
await promise;
|
||||||
process.exitCode = 0;
|
process.exitCode = 0;
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
import { OIDC_ENV, test } from "./main.js";
|
|
||||||
|
|
||||||
// Verify the OIDC audience is derived from `GITHUB_SERVER_URL`, using an `owner` target.
|
|
||||||
await test((mockPool) => {
|
|
||||||
process.env.GITHUB_SERVER_URL = "https://github.example.com";
|
|
||||||
process.env.INPUT_OWNER = process.env.GITHUB_REPOSITORY_OWNER;
|
|
||||||
delete process.env.INPUT_REPOSITORIES;
|
|
||||||
|
|
||||||
mockPool
|
|
||||||
.intercept({
|
|
||||||
path: `/users/${process.env.INPUT_OWNER}/installation?client_id=${OIDC_ENV["INPUT_CLIENT-ID"]}`,
|
|
||||||
method: "GET",
|
|
||||||
headers: {
|
|
||||||
accept: "application/vnd.github.v3+json",
|
|
||||||
"user-agent": "actions/create-github-app-token",
|
|
||||||
authorization: "Bearer oidc-token",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.reply(
|
|
||||||
200,
|
|
||||||
{ id: "123456", app_slug: "github-actions" },
|
|
||||||
{ headers: { "content-type": "application/json" } },
|
|
||||||
);
|
|
||||||
}, OIDC_ENV);
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
import { OIDC_ENV } from "./main.js";
|
|
||||||
|
|
||||||
for (const [key, value] of Object.entries({
|
|
||||||
...OIDC_ENV,
|
|
||||||
ACTIONS_ID_TOKEN_REQUEST_URL: "https://oidc.example/token",
|
|
||||||
INPUT_ENTERPRISE: "test-enterprise",
|
|
||||||
})) {
|
|
||||||
process.env[key] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
const _error = console.error;
|
|
||||||
console.error = (err) => _error(err?.message ?? err);
|
|
||||||
|
|
||||||
// Verify `main` exits with an error when OIDC authentication is used with the `enterprise` input.
|
|
||||||
const { default: promise } = await import("../main.js");
|
|
||||||
await promise;
|
|
||||||
process.exitCode = 0;
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
import { OIDC_ENV } from "./main.js";
|
|
||||||
|
|
||||||
for (const [key, value] of Object.entries({
|
|
||||||
...OIDC_ENV,
|
|
||||||
"INPUT_CLIENT-ID": "",
|
|
||||||
"INPUT_APP-ID": "123456",
|
|
||||||
ACTIONS_ID_TOKEN_REQUEST_URL: "https://oidc.example/token",
|
|
||||||
})) {
|
|
||||||
process.env[key] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
const _error = console.error;
|
|
||||||
console.error = (err) => _error(err?.message ?? err);
|
|
||||||
|
|
||||||
// Verify the deprecated `app-id` input is rejected for OIDC authentication.
|
|
||||||
const { default: promise } = await import("../main.js");
|
|
||||||
await promise;
|
|
||||||
process.exitCode = 0;
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
import { OIDC_ENV, test } from "./main.js";
|
|
||||||
|
|
||||||
// Verify `main` authenticates with an OIDC token when `private-key` isn’t set, and that the
|
|
||||||
// OIDC audience falls back to https://github.com when `GITHUB_SERVER_URL` isn’t set.
|
|
||||||
await test(() => {
|
|
||||||
delete process.env.GITHUB_SERVER_URL;
|
|
||||||
process.env["INPUT_PERMISSION-ISSUES"] = "write";
|
|
||||||
}, OIDC_ENV);
|
|
||||||
+5
-61
@@ -1,7 +1,5 @@
|
|||||||
// Base for all `main` tests.
|
// Base for all `main` tests.
|
||||||
// @ts-check
|
// @ts-check
|
||||||
import { createServer } from "node:http";
|
|
||||||
|
|
||||||
import { createMockAgent } from "./mock-agent.js";
|
import { createMockAgent } from "./mock-agent.js";
|
||||||
|
|
||||||
export const DEFAULT_ENV = {
|
export const DEFAULT_ENV = {
|
||||||
@@ -44,48 +42,6 @@ x3WQZRiXlWejSMUAHuMwXrhGlltF3lw83+xAjnqsVp75kGS6OH61
|
|||||||
"INPUT_PERMISSION-ADMINISTRATION": "",
|
"INPUT_PERMISSION-ADMINISTRATION": "",
|
||||||
};
|
};
|
||||||
|
|
||||||
// Authenticate with GitHub Actions OIDC instead of a private key.
|
|
||||||
export const OIDC_ENV = {
|
|
||||||
...DEFAULT_ENV,
|
|
||||||
"INPUT_PRIVATE-KEY": "",
|
|
||||||
ACTIONS_ID_TOKEN_REQUEST_TOKEN: "runner-token",
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Starts a local server that mimics the Actions OIDC token endpoint, because
|
|
||||||
* `core.getIDToken()` uses `@actions/http-client`, which `MockAgent` can't intercept.
|
|
||||||
*/
|
|
||||||
async function startOidcServer() {
|
|
||||||
/** @type {string[]} */
|
|
||||||
const requests = [];
|
|
||||||
const server = createServer((request, response) => {
|
|
||||||
requests.push(`${request.method} ${request.url}`);
|
|
||||||
const authorized = request.headers.authorization === "Bearer runner-token";
|
|
||||||
response.writeHead(authorized ? 200 : 401, {
|
|
||||||
"content-type": "application/json",
|
|
||||||
});
|
|
||||||
response.end(JSON.stringify(authorized ? { value: "oidc-token" } : { message: "Unauthorized" }));
|
|
||||||
});
|
|
||||||
await new Promise((resolve) => server.listen(0, "127.0.0.1", () => resolve(undefined)));
|
|
||||||
const { port } = /** @type {import("node:net").AddressInfo} */ (server.address());
|
|
||||||
process.env.ACTIONS_ID_TOKEN_REQUEST_URL = `http://127.0.0.1:${port}/token?api-version=2.0`;
|
|
||||||
|
|
||||||
// `core.getIDToken()` logs the token URL, so replace the random port to keep snapshots stable.
|
|
||||||
const write = process.stdout.write.bind(process.stdout);
|
|
||||||
process.stdout.write = /** @type {any} */ (
|
|
||||||
(/** @type {unknown} */ chunk, /** @type {any[]} */ ...args) =>
|
|
||||||
write(
|
|
||||||
typeof chunk === "string" ? chunk.replaceAll(`127.0.0.1:${port}`, "127.0.0.1:<port>") : chunk,
|
|
||||||
...args
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
return {
|
|
||||||
requests,
|
|
||||||
close: () => new Promise((resolve) => server.close(() => resolve(undefined))),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function test(cb = (_mockPool) => {}, env = DEFAULT_ENV) {
|
export async function test(cb = (_mockPool) => {}, env = DEFAULT_ENV) {
|
||||||
for (const [key, value] of Object.entries(env)) {
|
for (const [key, value] of Object.entries(env)) {
|
||||||
process.env[key] = value;
|
process.env[key] = value;
|
||||||
@@ -99,12 +55,6 @@ export async function test(cb = (_mockPool) => {}, env = DEFAULT_ENV) {
|
|||||||
|
|
||||||
// Calling `auth({ type: "app" })` to obtain a JWT doesn’t make network requests, so no need to intercept.
|
// Calling `auth({ type: "app" })` to obtain a JWT doesn’t make network requests, so no need to intercept.
|
||||||
|
|
||||||
// Without a private key, the action authenticates with an OIDC token and passes `client_id`.
|
|
||||||
const oidcServer = env["INPUT_PRIVATE-KEY"] ? undefined : await startOidcServer();
|
|
||||||
const clientIdQuery = oidcServer ? `?client_id=${env["INPUT_CLIENT-ID"]}` : "";
|
|
||||||
// JWT creation is not idempotent, so the `authorization` header is only asserted for OIDC.
|
|
||||||
const authorization = oidcServer ? { authorization: "Bearer oidc-token" } : {};
|
|
||||||
|
|
||||||
// Mock installation ID and app slug request
|
// Mock installation ID and app slug request
|
||||||
const mockInstallationId = "123456";
|
const mockInstallationId = "123456";
|
||||||
const mockAppSlug = "github-actions";
|
const mockAppSlug = "github-actions";
|
||||||
@@ -121,12 +71,12 @@ export async function test(cb = (_mockPool) => {}, env = DEFAULT_ENV) {
|
|||||||
|
|
||||||
mockPool
|
mockPool
|
||||||
.intercept({
|
.intercept({
|
||||||
path: `${basePath}/repos/${owner}/${repo}/installation${clientIdQuery}`,
|
path: `${basePath}/repos/${owner}/${repo}/installation`,
|
||||||
method: "GET",
|
method: "GET",
|
||||||
headers: {
|
headers: {
|
||||||
accept: "application/vnd.github.v3+json",
|
accept: "application/vnd.github.v3+json",
|
||||||
"user-agent": "actions/create-github-app-token",
|
"user-agent": "actions/create-github-app-token",
|
||||||
...authorization,
|
// Intentionally omitting the `authorization` header, since JWT creation is not idempotent.
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.reply(
|
.reply(
|
||||||
@@ -142,12 +92,12 @@ export async function test(cb = (_mockPool) => {}, env = DEFAULT_ENV) {
|
|||||||
|
|
||||||
mockPool
|
mockPool
|
||||||
.intercept({
|
.intercept({
|
||||||
path: `${basePath}/app/installations/${mockInstallationId}/access_tokens${clientIdQuery}`,
|
path: `${basePath}/app/installations/${mockInstallationId}/access_tokens`,
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
accept: "application/vnd.github.v3+json",
|
accept: "application/vnd.github.v3+json",
|
||||||
"user-agent": "actions/create-github-app-token",
|
"user-agent": "actions/create-github-app-token",
|
||||||
...authorization,
|
// Note: Intentionally omitting the `authorization` header, since JWT creation is not idempotent.
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.reply(
|
.reply(
|
||||||
@@ -163,18 +113,12 @@ export async function test(cb = (_mockPool) => {}, env = DEFAULT_ENV) {
|
|||||||
const { default: promise } = await import("../main.js");
|
const { default: promise } = await import("../main.js");
|
||||||
await promise;
|
await promise;
|
||||||
|
|
||||||
if (oidcServer) {
|
|
||||||
await oidcServer.close();
|
|
||||||
console.log("--- OIDC REQUESTS ---");
|
|
||||||
console.log(oidcServer.requests.join("\n"));
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log("--- REQUESTS ---");
|
console.log("--- REQUESTS ---");
|
||||||
const calls = mockAgent
|
const calls = mockAgent
|
||||||
.getCallHistory()
|
.getCallHistory()
|
||||||
.calls()
|
.calls()
|
||||||
.map((call) => {
|
.map((call) => {
|
||||||
const route = `${call.method} ${call.path}${new URL(call.fullUrl).search}`;
|
const route = `${call.method} ${call.path}`;
|
||||||
if (call.method === "GET") return route;
|
if (call.method === "GET") return route;
|
||||||
|
|
||||||
return `${route}\n${call.body}`;
|
return `${route}\n${call.body}`;
|
||||||
|
|||||||
Reference in new issue
Block a user