@effected/github-actions 0.24.0 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ActionEnvironment.js +6 -8
- package/ActionInput.js +14 -17
- package/ActionLogger.js +30 -2
- package/ActionsIdentityToken.js +5 -5
- package/ActionsProvenance.js +17 -15
- package/ActionsRegistryCredential.js +81 -0
- package/Artifact.js +3 -2
- package/BlobStore.js +59 -29
- package/OidcTokenIssuer.js +68 -52
- package/PackageManagerInstaller.js +19 -22
- package/README.md +6 -5
- package/Secret.js +10 -6
- package/ToolInstaller.js +3 -2
- package/index.d.ts +200 -75
- package/index.js +4 -3
- package/internal/actionsResults.js +5 -4
- package/internal/json.js +11 -0
- package/internal/runner.js +21 -1
- package/internal/unstubbed.js +1 -3
- package/package.json +11 -8
- package/internal/jwt.js +0 -41
- package/internal/sigv4.js +0 -114
package/internal/json.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
|
|
3
|
+
// src/internal/json.ts
|
|
4
|
+
/**
|
|
5
|
+
* Parse JSON text to an unknown value, failing with a `SchemaError` on text that is not JSON.
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
const decodeJson = Schema.decodeUnknownEffect(Schema.fromJsonString(Schema.Unknown));
|
|
10
|
+
|
|
11
|
+
export { decodeJson };
|
package/internal/runner.js
CHANGED
|
@@ -26,5 +26,25 @@ const isWindowsRunner = (env) => Effect.map(env.getOptional("RUNNER_OS"), (found
|
|
|
26
26
|
* @internal
|
|
27
27
|
*/
|
|
28
28
|
const toolCacheRoot = (env, path) => Effect.map(env.getOptional("RUNNER_TOOL_CACHE"), (found) => Option.getOrElse(found, () => path.join("/tmp", "runner-tool-cache")));
|
|
29
|
+
/** `RUNNER_ARCH`'s spellings (`X86`, `X64`, `ARM`, `ARM64`), lower-cased, in Node's `process.arch` spelling. */
|
|
30
|
+
const NODE_ARCH = /* @__PURE__ */ new Map([
|
|
31
|
+
["x86", "ia32"],
|
|
32
|
+
["x64", "x64"],
|
|
33
|
+
["arm", "arm"],
|
|
34
|
+
["arm64", "arm64"]
|
|
35
|
+
]);
|
|
36
|
+
/** A `RUNNER_ARCH` value in Node's spelling; anything unrecognised passes through. */
|
|
37
|
+
const archFromRunner = (runnerArch) => NODE_ARCH.get(runnerArch.toLowerCase()) ?? runnerArch;
|
|
38
|
+
/**
|
|
39
|
+
* The host architecture in Node's spelling: `RUNNER_ARCH` mapped through
|
|
40
|
+
* `archFromRunner`, or `process.arch` off a runner, where the variable is
|
|
41
|
+
* absent and the host's own answer is the honest fallback.
|
|
42
|
+
*
|
|
43
|
+
* @internal
|
|
44
|
+
*/
|
|
45
|
+
const runnerArch = (env) => Effect.map(env.getOptional("RUNNER_ARCH"), (found) => Option.match(found, {
|
|
46
|
+
onNone: () => process.arch,
|
|
47
|
+
onSome: archFromRunner
|
|
48
|
+
}));
|
|
29
49
|
|
|
30
|
-
export { isWindowsRunner, toolCacheRoot };
|
|
50
|
+
export { isWindowsRunner, runnerArch, toolCacheRoot };
|
package/internal/unstubbed.js
CHANGED
|
@@ -8,8 +8,6 @@ import { Effect } from "effect";
|
|
|
8
8
|
*
|
|
9
9
|
* @internal
|
|
10
10
|
*/
|
|
11
|
-
const unstubbed = (double) => (member) => Effect.
|
|
12
|
-
throw new Error(`${double}: ${member}() was called but not stubbed — pass a \`${member}\` override.`);
|
|
13
|
-
});
|
|
11
|
+
const unstubbed = (double) => (member) => Effect.die(/* @__PURE__ */ new Error(`${double}: ${member}() was called but not stubbed — pass a \`${member}\` override.`));
|
|
14
12
|
|
|
15
13
|
export { unstubbed };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effected/github-actions",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The GitHub Actions runtime: env, inputs, outputs, state, logging, cache, artifacts, blob storage, OIDC and the token bridge.",
|
|
6
6
|
"keywords": [
|
|
@@ -39,14 +39,17 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@azure/storage-blob": "^12.33.0",
|
|
42
|
-
"@effected/
|
|
43
|
-
"@effected/github
|
|
42
|
+
"@effected/crypto": "^0.1.1",
|
|
43
|
+
"@effected/github": "^0.23.1",
|
|
44
|
+
"@effected/github-commands": "^0.6.1",
|
|
44
45
|
"@effected/glob": "^0.14.0",
|
|
45
|
-
"@effected/
|
|
46
|
-
"@effected/
|
|
47
|
-
"@effected/
|
|
48
|
-
"@effected/
|
|
49
|
-
"@effected/
|
|
46
|
+
"@effected/jwt": "^0.6.0",
|
|
47
|
+
"@effected/markdown": "^0.21.0",
|
|
48
|
+
"@effected/npm": "^0.26.0",
|
|
49
|
+
"@effected/oidc": "^0.1.2",
|
|
50
|
+
"@effected/sbom": "^0.15.1",
|
|
51
|
+
"@effected/semver": "^0.16.0",
|
|
52
|
+
"@effected/templates": "^0.14.1",
|
|
50
53
|
"@effected/walker": "^0.19.0"
|
|
51
54
|
},
|
|
52
55
|
"peerDependencies": {
|
package/internal/jwt.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { Result } from "effect";
|
|
2
|
-
import * as Base64Url from "effect/encoding/Base64Url";
|
|
3
|
-
|
|
4
|
-
// src/internal/jwt.ts
|
|
5
|
-
/**
|
|
6
|
-
* The decoded payload of `token` — the middle segment, base64url JSON —
|
|
7
|
-
* without any check on the signature.
|
|
8
|
-
*
|
|
9
|
-
* @internal
|
|
10
|
-
*/
|
|
11
|
-
const payloadOf = (token) => {
|
|
12
|
-
const segments = token.split(".");
|
|
13
|
-
const payload = segments[1];
|
|
14
|
-
if (segments.length !== 3 || payload === void 0 || payload === "") return Result.fail({ detail: `expected three segments, got ${segments.length}` });
|
|
15
|
-
const json = Base64Url.decodeString(payload);
|
|
16
|
-
if (Result.isFailure(json)) return Result.fail({
|
|
17
|
-
detail: "the payload is not base64url JSON",
|
|
18
|
-
cause: json.failure
|
|
19
|
-
});
|
|
20
|
-
try {
|
|
21
|
-
return Result.succeed(JSON.parse(json.success));
|
|
22
|
-
} catch (cause) {
|
|
23
|
-
return Result.fail({
|
|
24
|
-
detail: "the payload is not base64url JSON",
|
|
25
|
-
cause
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* An **unsigned** JWT: `header.payload.unsigned`, each JSON segment
|
|
31
|
-
* base64url-encoded. For building test doubles and nothing else — the
|
|
32
|
-
* signature segment is a placeholder, so this token fails any verifier.
|
|
33
|
-
*
|
|
34
|
-
* @internal
|
|
35
|
-
*/
|
|
36
|
-
const unsignedJwt = (header, payload) => {
|
|
37
|
-
const segment = (value) => Base64Url.encode(JSON.stringify(value));
|
|
38
|
-
return `${segment(header)}.${segment(payload)}.unsigned`;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export { payloadOf, unsignedJwt };
|
package/internal/sigv4.js
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { sha256Hex } from "./digest.js";
|
|
2
|
-
import { createHmac } from "node:crypto";
|
|
3
|
-
|
|
4
|
-
// src/internal/sigv4.ts
|
|
5
|
-
/**
|
|
6
|
-
* AWS Signature Version 4, for S3-compatible object stores.
|
|
7
|
-
*
|
|
8
|
-
* @remarks
|
|
9
|
-
* **Pure**, and about a hundred lines, which is the whole argument for not
|
|
10
|
-
* taking an `@aws-sdk/*` dependency to obtain it. Signing is a specified
|
|
11
|
-
* algorithm over strings and HMACs; the SDK around it exists to manage
|
|
12
|
-
* credentials, retries and a service catalogue this package does not want.
|
|
13
|
-
*
|
|
14
|
-
* `node:crypto` rather than core `Crypto` because core's `Crypto` offers only
|
|
15
|
-
* one-shot SHA digests over bytes already in memory — no HMAC, no incremental
|
|
16
|
-
* hasher (see `internal/digest.ts`, this package's other `node:crypto`
|
|
17
|
-
* licence). This package is the one place in the kit where a `node:` import
|
|
18
|
-
* is sanctioned, and this is one of the four reasons.
|
|
19
|
-
*
|
|
20
|
-
* @internal
|
|
21
|
-
*/
|
|
22
|
-
const ALGORITHM = "AWS4-HMAC-SHA256";
|
|
23
|
-
const hmac = (key, value) => new Uint8Array(createHmac("sha256", key).update(value).digest());
|
|
24
|
-
/**
|
|
25
|
-
* Percent-encode one path segment the way SigV4 requires.
|
|
26
|
-
*
|
|
27
|
-
* @remarks
|
|
28
|
-
* `encodeURIComponent` leaves `!'()*` alone and AWS does not, so a key
|
|
29
|
-
* containing any of them signs one string and requests another — which fails as
|
|
30
|
-
* an opaque `SignatureDoesNotMatch` rather than as anything that names the
|
|
31
|
-
* character. The unreserved set is exactly `A-Za-z0-9-_.~`.
|
|
32
|
-
*/
|
|
33
|
-
const uriEncode = (value) => encodeURIComponent(value).replace(/[!'()*]/g, (character) => `%${character.charCodeAt(0).toString(16).toUpperCase()}`);
|
|
34
|
-
/** `20130524T000000Z` and `20130524`, the two forms the algorithm uses. */
|
|
35
|
-
const timestamps = (now) => {
|
|
36
|
-
const amzDate = `${now.toISOString().replace(/[:-]|\.\d{3}/g, "").slice(0, 15)}Z`;
|
|
37
|
-
return {
|
|
38
|
-
amzDate,
|
|
39
|
-
dateStamp: amzDate.slice(0, 8)
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* Assemble the headers that will be signed, and the canonical request over them.
|
|
44
|
-
*
|
|
45
|
-
* @remarks
|
|
46
|
-
* Exported separately from {@link sign} so a test can pin it against AWS's
|
|
47
|
-
* **own documented** canonical request rather than against this
|
|
48
|
-
* implementation's output.
|
|
49
|
-
*/
|
|
50
|
-
const canonicalize = (request, credentials) => {
|
|
51
|
-
const { amzDate, dateStamp } = timestamps(request.now);
|
|
52
|
-
const payloadHash = sha256Hex(request.body);
|
|
53
|
-
const headers = {
|
|
54
|
-
...request.headers,
|
|
55
|
-
host: request.host,
|
|
56
|
-
"x-amz-date": amzDate,
|
|
57
|
-
"x-amz-content-sha256": payloadHash,
|
|
58
|
-
...credentials.sessionToken === void 0 ? {} : { "x-amz-security-token": credentials.sessionToken }
|
|
59
|
-
};
|
|
60
|
-
const lowered = new Map(Object.entries(headers).map(([name, value]) => [name.toLowerCase(), value]));
|
|
61
|
-
const canonicalNames = [...lowered.keys()].sort();
|
|
62
|
-
const canonicalHeaders = canonicalNames.map((name) => `${name}:${(lowered.get(name) ?? "").trim().replace(/\s+/g, " ")}\n`).join("");
|
|
63
|
-
const signedHeaders = canonicalNames.join(";");
|
|
64
|
-
const canonicalPath = `/${request.path.split("/").filter((segment) => segment !== "").map(uriEncode).join("/")}`;
|
|
65
|
-
return {
|
|
66
|
-
headers,
|
|
67
|
-
signedHeaders,
|
|
68
|
-
amzDate,
|
|
69
|
-
dateStamp,
|
|
70
|
-
canonicalRequest: [
|
|
71
|
-
request.method,
|
|
72
|
-
canonicalPath,
|
|
73
|
-
"",
|
|
74
|
-
canonicalHeaders,
|
|
75
|
-
signedHeaders,
|
|
76
|
-
payloadHash
|
|
77
|
-
].join("\n")
|
|
78
|
-
};
|
|
79
|
-
};
|
|
80
|
-
/**
|
|
81
|
-
* Derive a signing key.
|
|
82
|
-
*
|
|
83
|
-
* @remarks
|
|
84
|
-
* Four nested HMACs over date, region, service and the literal `aws4_request`.
|
|
85
|
-
* Exported so a test can reproduce AWS's documented derivation example.
|
|
86
|
-
*/
|
|
87
|
-
const signingKey = (secretAccessKey, dateStamp, region, service) => hmac(hmac(hmac(hmac(`AWS4${secretAccessKey}`, dateStamp), region), service), "aws4_request");
|
|
88
|
-
/**
|
|
89
|
-
* Sign a request, returning the headers to send.
|
|
90
|
-
*
|
|
91
|
-
* @remarks
|
|
92
|
-
* The returned record is the caller's headers **plus** everything signing added
|
|
93
|
-
* — `host`, `x-amz-date`, `x-amz-content-sha256`, the optional
|
|
94
|
-
* `x-amz-security-token` and `authorization` — so a caller sends exactly what
|
|
95
|
-
* was signed rather than assembling a second, subtly different set.
|
|
96
|
-
*/
|
|
97
|
-
const sign = (request, credentials) => {
|
|
98
|
-
const { headers, canonicalRequest, signedHeaders, amzDate, dateStamp } = canonicalize(request, credentials);
|
|
99
|
-
const scope = `${dateStamp}/${credentials.region}/${credentials.service}/aws4_request`;
|
|
100
|
-
const stringToSign = [
|
|
101
|
-
ALGORITHM,
|
|
102
|
-
amzDate,
|
|
103
|
-
scope,
|
|
104
|
-
sha256Hex(canonicalRequest)
|
|
105
|
-
].join("\n");
|
|
106
|
-
const key = signingKey(credentials.secretAccessKey, dateStamp, credentials.region, credentials.service);
|
|
107
|
-
const signature = Buffer.from(hmac(key, stringToSign)).toString("hex");
|
|
108
|
-
return {
|
|
109
|
-
...headers,
|
|
110
|
-
authorization: `${ALGORITHM} Credential=${credentials.accessKeyId}/${scope}, SignedHeaders=${signedHeaders}, Signature=${signature}`
|
|
111
|
-
};
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
export { canonicalize, sha256Hex as digestHex, sign, signingKey, uriEncode };
|