@effected/github-actions 0.25.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/ActionLogger.js +30 -2
- package/ActionsRegistryCredential.js +81 -0
- package/BlobStore.js +1 -1
- package/OidcTokenIssuer.js +45 -0
- package/README.md +3 -2
- package/index.d.ts +149 -4
- package/index.js +3 -2
- package/internal/unstubbed.js +1 -3
- package/package.json +11 -11
package/ActionLogger.js
CHANGED
|
@@ -97,6 +97,30 @@ const commandLogger = Logger.withConsoleLog(renderLogger);
|
|
|
97
97
|
* @internal
|
|
98
98
|
*/
|
|
99
99
|
const ActiveBuffer = Context.Reference("@effected/github-actions/ActiveBuffer", { defaultValue: () => null });
|
|
100
|
+
/**
|
|
101
|
+
* How many {@link ActionLoggerShape.group} calls the current fiber is inside.
|
|
102
|
+
*
|
|
103
|
+
* @remarks
|
|
104
|
+
* The runner does not nest groups: a second `::group::` implicitly ends the
|
|
105
|
+
* first, leaving an empty outer header and a stray `::endgroup::`. So only
|
|
106
|
+
* depth 0 writes the group commands, and a nested call writes a plain header
|
|
107
|
+
* line instead. Fiber-scoped for the same reason as {@link ActiveBuffer}: a
|
|
108
|
+
* `Context.Reference` is provided around the body, so it unwinds on every
|
|
109
|
+
* exit path with nothing to restore.
|
|
110
|
+
*
|
|
111
|
+
* @internal
|
|
112
|
+
*/
|
|
113
|
+
const GroupDepth = Context.Reference("@effected/github-actions/GroupDepth", { defaultValue: () => 0 });
|
|
114
|
+
/**
|
|
115
|
+
* The line a nested group writes in place of a second `::group::`.
|
|
116
|
+
*
|
|
117
|
+
* @remarks
|
|
118
|
+
* Line breaks collapse to spaces so the header stays one line — the
|
|
119
|
+
* top-level form escapes them into one command — and the result is
|
|
120
|
+
* neutralized, because a group name is caller text and a `::` or `##[` in it
|
|
121
|
+
* would otherwise be a command.
|
|
122
|
+
*/
|
|
123
|
+
const nestedHeader = (name) => CommandNeutralizer.text(`▸ ${name.replace(/\r\n|\r|\n/g, " ")}`);
|
|
100
124
|
/** Drop a transcript without writing it, so a green step stays quiet. */
|
|
101
125
|
const discard = (state) => Effect.sync(() => {
|
|
102
126
|
state.entries.length = 0;
|
|
@@ -132,7 +156,10 @@ const make = Effect.gen(function* () {
|
|
|
132
156
|
return yield* effect.pipe(Effect.provideService(References.MinimumLogLevel, "All"), Effect.provideService(Logger.CurrentLoggers, /* @__PURE__ */ new Set([buffering])), Effect.provideService(ActiveBuffer, state), Effect.onExit((exit) => Exit.isSuccess(exit) && options?.onSuccess === "discard" ? discard(state) : flush(state)));
|
|
133
157
|
});
|
|
134
158
|
return {
|
|
135
|
-
group: (name, effect) => Effect.
|
|
159
|
+
group: (name, effect) => Effect.flatMap(GroupDepth, (depth) => {
|
|
160
|
+
const body = Effect.tapCause(Effect.provideService(effect, GroupDepth, depth + 1), () => flushActive);
|
|
161
|
+
return depth === 0 ? Effect.acquireUseRelease(Console.log(WorkflowCommand.group(name)), () => body, () => Console.log(WorkflowCommand.endGroup())) : Effect.andThen(Console.log(nestedHeader(name)), body);
|
|
162
|
+
}),
|
|
136
163
|
withBuffer,
|
|
137
164
|
withStep: (name, effect, options) => withBuffer(name, Effect.tapCause(effect, () => Console.log(CommandNeutralizer.text(`❌ ${name}`))), { onSuccess: "discard" }).pipe(Effect.tap(() => Effect.logInfo(options?.summary ?? `✅ ${name}`))),
|
|
138
165
|
notice: (message, properties = {}) => Console.log(WorkflowCommand.notice(message, properties)),
|
|
@@ -200,7 +227,8 @@ var ActionLogger = class ActionLogger extends Context.Service()("@effected/githu
|
|
|
200
227
|
* {@link ActionEnvironment.makeTest}. A logger that dies when a suite logs
|
|
201
228
|
* would make every double unusable, and silence is the honest default for a
|
|
202
229
|
* service whose whole job is output. Group and buffer wrappers pass their
|
|
203
|
-
* effect through unchanged
|
|
230
|
+
* effect through unchanged, so the double does not model group nesting:
|
|
231
|
+
* a test of nested-group output needs the live {@link ActionLogger.layer}.
|
|
204
232
|
*/
|
|
205
233
|
static makeTest = (overrides = {}) => ({
|
|
206
234
|
group: (_name, effect) => effect,
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { OidcTokenIssuer } from "./OidcTokenIssuer.js";
|
|
2
|
+
import { Secret } from "./Secret.js";
|
|
3
|
+
import { Effect } from "effect";
|
|
4
|
+
import { workloadCredential } from "@effected/npm";
|
|
5
|
+
|
|
6
|
+
// src/ActionsRegistryCredential.ts
|
|
7
|
+
/**
|
|
8
|
+
* Registry credentials minted from the runner's own workload identity.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* The GitHub Actions half of `@effected/npm`'s workload credential. npm owns
|
|
12
|
+
* the credential's shape and the npmrc write and takes no Actions edge, so it
|
|
13
|
+
* cannot mint or mask; this class does both, so a consumer never holds the
|
|
14
|
+
* identity token or the prefixed value as plaintext and never reaches for
|
|
15
|
+
* `Secret.forSigning` to build one.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* import { ActionsRegistryCredential } from "@effected/github-actions";
|
|
20
|
+
* import { PackagePublish } from "@effected/npm";
|
|
21
|
+
* import { Effect } from "effect";
|
|
22
|
+
*
|
|
23
|
+
* const program = Effect.gen(function* () {
|
|
24
|
+
* const credential = yield* ActionsRegistryCredential.workload({
|
|
25
|
+
* audience: "https://registry.example",
|
|
26
|
+
* prefix: "example_workload_",
|
|
27
|
+
* });
|
|
28
|
+
* const publish = yield* PackagePublish;
|
|
29
|
+
* yield* publish.setupAuth({
|
|
30
|
+
* registry: "https://registry.example/npm",
|
|
31
|
+
* credential,
|
|
32
|
+
* npmrcPath: "/home/runner/.npmrc",
|
|
33
|
+
* });
|
|
34
|
+
* });
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
39
|
+
var ActionsRegistryCredential = class {
|
|
40
|
+
constructor() {}
|
|
41
|
+
/**
|
|
42
|
+
* Mint a workload identity token for `audience`, mask it and its prefixed
|
|
43
|
+
* form, and return `@effected/npm`'s `WorkloadCredential`.
|
|
44
|
+
*
|
|
45
|
+
* @remarks
|
|
46
|
+
* In order: the runner's {@link OidcTokenIssuer} mints a token for
|
|
47
|
+
* `audience` (verbatim — it is the registry's own audience, and a token
|
|
48
|
+
* minted for another is refused); the bare token is masked; npm's
|
|
49
|
+
* `workloadCredential` prefixes it; the prefixed value is masked too,
|
|
50
|
+
* because the runner's log filter matches whole registered values and the
|
|
51
|
+
* prefixed form is a new one. Both masks are emitted before the credential
|
|
52
|
+
* is returned, so no later step — the npm subprocess included — can print
|
|
53
|
+
* either value in clear.
|
|
54
|
+
*
|
|
55
|
+
* A mint failure stays an {@link OidcTokenError}, distinct from a later
|
|
56
|
+
* `PublishError` of kind `"auth"` from `setupAuth`, so a caller can tell
|
|
57
|
+
* "the runner refused an identity token" from "the npmrc could not be
|
|
58
|
+
* written". On an issuer failure nothing is masked and nothing is built.
|
|
59
|
+
*
|
|
60
|
+
* **In a detached worker the masks are a leak**, exactly as for
|
|
61
|
+
* {@link Secret.mask}: mint in the parent, where the runner parses stdout.
|
|
62
|
+
*
|
|
63
|
+
* @param options - `audience` for the identity token; `prefix` is the
|
|
64
|
+
* registry's token prefix, an open string because the vocabulary belongs
|
|
65
|
+
* to the registry, not to this kit.
|
|
66
|
+
*/
|
|
67
|
+
static workload = Effect.fn("ActionsRegistryCredential.workload")(function* (options) {
|
|
68
|
+
yield* Effect.annotateCurrentSpan({ audience: options.audience });
|
|
69
|
+
const identityToken = yield* (yield* OidcTokenIssuer).token(options.audience);
|
|
70
|
+
yield* Secret.mask(identityToken);
|
|
71
|
+
const credential = workloadCredential({
|
|
72
|
+
audience: options.audience,
|
|
73
|
+
prefix: options.prefix,
|
|
74
|
+
identityToken
|
|
75
|
+
});
|
|
76
|
+
yield* Secret.mask(credential.token);
|
|
77
|
+
return credential;
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export { ActionsRegistryCredential };
|
package/BlobStore.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { unstubbed } from "./internal/unstubbed.js";
|
|
2
|
-
import { BlobEnvelope } from "./BlobEnvelope.js";
|
|
3
2
|
import { Secret } from "./Secret.js";
|
|
3
|
+
import { BlobEnvelope } from "./BlobEnvelope.js";
|
|
4
4
|
import { Context, Crypto, DateTime, Effect, Layer, Option, Schema } from "effect";
|
|
5
5
|
import { HttpClient, HttpClientRequest } from "effect/http";
|
|
6
6
|
import { SigV4 } from "@effected/crypto";
|
package/OidcTokenIssuer.js
CHANGED
|
@@ -187,6 +187,51 @@ var OidcTokenIssuer = class OidcTokenIssuer extends Context.Service()("@effected
|
|
|
187
187
|
token: () => Effect.succeed(OidcTokenIssuer.unsignedTokenFor(claims)),
|
|
188
188
|
claims: () => Effect.succeed(claims)
|
|
189
189
|
});
|
|
190
|
+
/**
|
|
191
|
+
* A {@link OidcTokenIssuer.layerFor} double that also records the audience
|
|
192
|
+
* every call asked for.
|
|
193
|
+
*
|
|
194
|
+
* @remarks
|
|
195
|
+
* A sibling of `layerTest` rather than a recording `layerTest`, following
|
|
196
|
+
* `ActionOutputs.recording`: the doubles here are override-and-die, and a
|
|
197
|
+
* recorder is a different contract. The audience is the one input a token
|
|
198
|
+
* request carries, and a token minted for the wrong audience is refused by
|
|
199
|
+
* the party it was meant for — so "which audience did this ask for" is
|
|
200
|
+
* worth an assertion rather than an assumption.
|
|
201
|
+
*
|
|
202
|
+
* Each call returns a fresh journal and a fresh layer: bind the result to a
|
|
203
|
+
* `const` and provide its `layer` once.
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* ```ts
|
|
207
|
+
* import type { ActionsOidcClaims } from "@effected/github";
|
|
208
|
+
* import { OidcTokenIssuer } from "@effected/github-actions";
|
|
209
|
+
* import { Effect } from "effect";
|
|
210
|
+
*
|
|
211
|
+
* declare const claims: ActionsOidcClaims;
|
|
212
|
+
* const recorder = OidcTokenIssuer.recording(claims);
|
|
213
|
+
* const program = Effect.gen(function* () {
|
|
214
|
+
* const issuer = yield* OidcTokenIssuer;
|
|
215
|
+
* yield* issuer.token("https://registry.example");
|
|
216
|
+
* return recorder.audiences();
|
|
217
|
+
* });
|
|
218
|
+
* Effect.runPromise(Effect.provide(program, recorder.layer)).then(console.log);
|
|
219
|
+
* // => ["https://registry.example"]
|
|
220
|
+
* ```
|
|
221
|
+
*/
|
|
222
|
+
static recording = (claims) => {
|
|
223
|
+
const audiences = [];
|
|
224
|
+
const record = (audience) => Effect.sync(() => {
|
|
225
|
+
audiences.push(audience);
|
|
226
|
+
});
|
|
227
|
+
return {
|
|
228
|
+
layer: Layer.succeed(OidcTokenIssuer, {
|
|
229
|
+
token: (audience) => Effect.as(record(audience), OidcTokenIssuer.unsignedTokenFor(claims)),
|
|
230
|
+
claims: (audience) => Effect.as(record(audience), claims)
|
|
231
|
+
}),
|
|
232
|
+
audiences: () => audiences.slice()
|
|
233
|
+
};
|
|
234
|
+
};
|
|
190
235
|
};
|
|
191
236
|
|
|
192
237
|
export { OidcTokenError, OidcTokenIssuer };
|
package/README.md
CHANGED
|
@@ -296,13 +296,14 @@ const TestOutputs = ActionOutputs.layerTest({
|
|
|
296
296
|
- `ActionInput` — typed input accessors (`string`, `boolean`, `integer`, `redacted`, `lines`, `list`, `pairs`, `schema`) sharing one absence rule, plus the `INPUT_`-aware `ConfigProvider` `Action.run` installs by default. `pairs` always rejects an empty key (`=value`, whose damage lands far from the typo) and takes `requireValue` to reject an empty value too.
|
|
297
297
|
- `ActionOutputs` — step outputs, JSON outputs, the job summary, exported variables, `PATH` additions, failure annotations and log masking.
|
|
298
298
|
- `ActionState` / `ActionEnvironment` — persisted `pre`/`main`/`post` state, and the fiber-local `GITHUB_*`/`RUNNER_*` context read once from `process.env`.
|
|
299
|
-
- `ActionLogger` — collapsible groups, buffered step transcripts (`withBuffer({ onSuccess: "discard" })` drops a green step's transcript entirely, while a failure, defect or interruption still flushes it), `withStep(name, effect, options?)` for the same buffering plus one summary line on success and a `❌ <name>` header above the transcript on failure, `::notice::` annotations, and the `Logger` that renders every `Effect.log*` as a workflow command.
|
|
299
|
+
- `ActionLogger` — collapsible groups (nesting-aware: the runner cannot nest groups, so a group opened inside another writes a `▸ <name>` header line instead of a second group command), buffered step transcripts (`withBuffer({ onSuccess: "discard" })` drops a green step's transcript entirely, while a failure, defect or interruption still flushes it), `withStep(name, effect, options?)` for the same buffering plus one summary line on success and a `❌ <name>` header above the transcript on failure, `::notice::` annotations, and the `Logger` that renders every `Effect.log*` as a workflow command.
|
|
300
300
|
- `DryRun` — the rehearsal guard every mutation goes through, driven by the `dry-run` input by default.
|
|
301
301
|
- `Secret` — the one declassification seam between a `Redacted` value and a plain string, masking before it returns plaintext.
|
|
302
302
|
- `GitHubToken` — the App-token lifecycle shaped like the `pre`/`main`/`post` workflow: mint, verify scopes, persist, read, revoke.
|
|
303
303
|
- `ActionCache` / `Artifact` — the runner's cache and artifact protocols over Twirp v2, excluded from the default runtime so a consumer that skips them never links Azure.
|
|
304
304
|
- `CacheKey` — cache keys and their restore-key ladder, `withNamespace(segment)` for a bust token or a shared-runner prefix, plus `hashFiles`/`matchingFiles`/`hashMatching` byte-compatible with `@actions/glob`.
|
|
305
|
-
- `OidcTokenIssuer` — the runner's OIDC token service, with unverified claim decoding for provenance predicates.
|
|
305
|
+
- `OidcTokenIssuer` — the runner's OIDC token service, with unverified claim decoding for provenance predicates, and a `recording(claims)` double that journals the audiences asked for.
|
|
306
|
+
- `ActionsRegistryCredential` — `workload({ audience, prefix })` mints an identity token for a registry, masks the bare and the prefixed value, and returns `@effected/npm`'s publish-only `WorkloadCredential` for `PackagePublish.setupAuth`.
|
|
306
307
|
- `ActionsIdentityToken` / `ActionsProvenance` — the `@effected/sbom` seam: `layer` serves `@effected/oidc`'s `IdentityToken` contract from the runner's issuer, and `capture` builds a `SlsaProvenance` predicate out of the runner's OIDC claims.
|
|
307
308
|
- `GitHubMarkdown` — the escaping-safe writer for GitHub surfaces: `table`, `tableFor(schema)`, `heading`, `link`, `code`, `codeBlock`, `list`, `details` and `raw`, and the package's only importer of `@effected/markdown`.
|
|
308
309
|
- `ManagedDocument` — marker-delimited named regions in text a human also edits, for a sticky comment or a managed pull request description; content outside the regions survives byte-for-byte, and each region can carry marker metadata that round-trips through `entry(key)` without ever addressing the region.
|
package/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { ChildProcessSpawner } from "effect/process";
|
|
|
6
6
|
import { IdentityToken } from "@effected/oidc";
|
|
7
7
|
import { ActionsOidcClaims, BotIdentity, GitHubApp, GitHubClient, InstallationToken, PermissionLevel, RetryPolicy } from "@effected/github";
|
|
8
8
|
import { SlsaProvenance } from "@effected/sbom";
|
|
9
|
-
import { IntegrityHashBrand, PackageManagerPin } from "@effected/npm";
|
|
9
|
+
import { IntegrityHashBrand, PackageManagerPin, WorkloadCredential } from "@effected/npm";
|
|
10
10
|
declare const ActionEnvironmentError_base: Schema.Class<ActionEnvironmentError, Schema.TaggedStruct<"ActionEnvironmentError", {
|
|
11
11
|
/** `missing` — absent or empty; `malformed` — present but unusable. */
|
|
12
12
|
readonly reason: Schema.Literals<readonly ["missing", "malformed"]>;
|
|
@@ -299,7 +299,38 @@ interface WithStepOptions {
|
|
|
299
299
|
* @public
|
|
300
300
|
*/
|
|
301
301
|
interface ActionLoggerShape {
|
|
302
|
-
/**
|
|
302
|
+
/**
|
|
303
|
+
* Run an effect inside a collapsible log group.
|
|
304
|
+
*
|
|
305
|
+
* @remarks
|
|
306
|
+
* The runner cannot nest groups — a second `::group::` implicitly closes the
|
|
307
|
+
* first — so this is nesting-aware: the outermost call writes the
|
|
308
|
+
* `::group::` / `::endgroup::` pair, and a call made inside it writes one
|
|
309
|
+
* `▸ <name>` header line inside the open group instead (line breaks
|
|
310
|
+
* collapsed to spaces, the text neutralized so it cannot be a command). The
|
|
311
|
+
* header goes out through `Console` like the group command it replaces, so
|
|
312
|
+
* it is never captured into, or discarded with, an enclosing `withBuffer`
|
|
313
|
+
* or `withStep` transcript. A failure at any depth flushes the active
|
|
314
|
+
* buffer before the group closes. That ordering is visible in a failed
|
|
315
|
+
* run's log: the replayed transcript lands BELOW every nested header that
|
|
316
|
+
* was written live, including lines that were logged before the header.
|
|
317
|
+
*
|
|
318
|
+
* The depth is fiber-scoped, which leaves four edges:
|
|
319
|
+
*
|
|
320
|
+
* 1. **Concurrent sibling groups interleave.** Two top-level groups on
|
|
321
|
+
* separate fibers each write a `::group::`, and their output shares one
|
|
322
|
+
* log stream; that is the runner's limitation, not one a depth can fix.
|
|
323
|
+
* 2. **A fiber forked inside a group keeps the depth it was forked at.** A
|
|
324
|
+
* `forkChild` joined inside the group nests correctly; a detached fiber
|
|
325
|
+
* that outlives the group still writes headers rather than a group.
|
|
326
|
+
* 3. **Only groups opened here are counted.** A raw
|
|
327
|
+
* `WorkflowCommand.group(...)`, a document rendered by `@effected/cli`'s
|
|
328
|
+
* `Render.githubLog` with a top-level collapsible, or a consumer's own
|
|
329
|
+
* wrapper opens a group this member cannot see, and a group opened
|
|
330
|
+
* inside one still nests at the runner.
|
|
331
|
+
* 4. **The test doubles do not model nesting.** `makeTest`, `layerTest` and
|
|
332
|
+
* `layerSilent` pass the effect through unchanged.
|
|
333
|
+
*/
|
|
303
334
|
readonly group: <A, E, R>(name: string, effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
|
|
304
335
|
/**
|
|
305
336
|
* Run an effect with its verbose output captured and replayed on exit.
|
|
@@ -436,7 +467,8 @@ export declare class ActionLogger extends ActionLogger_base {
|
|
|
436
467
|
* {@link ActionEnvironment.makeTest}. A logger that dies when a suite logs
|
|
437
468
|
* would make every double unusable, and silence is the honest default for a
|
|
438
469
|
* service whose whole job is output. Group and buffer wrappers pass their
|
|
439
|
-
* effect through unchanged
|
|
470
|
+
* effect through unchanged, so the double does not model group nesting:
|
|
471
|
+
* a test of nested-group output needs the live {@link ActionLogger.layer}.
|
|
440
472
|
*/
|
|
441
473
|
static readonly makeTest: (overrides?: Partial<ActionLoggerShape>) => ActionLoggerShape;
|
|
442
474
|
/** {@link ActionLogger.makeTest} behind `Layer.succeed`. */
|
|
@@ -1999,6 +2031,21 @@ interface OidcTokenIssuerShape {
|
|
|
1999
2031
|
*/
|
|
2000
2032
|
readonly claims: (audience?: string) => Effect.Effect<ActionsOidcClaims, OidcTokenError>;
|
|
2001
2033
|
}
|
|
2034
|
+
/**
|
|
2035
|
+
* What {@link OidcTokenIssuer.recording} returns: the layer to provide and the
|
|
2036
|
+
* audiences it was asked for.
|
|
2037
|
+
*
|
|
2038
|
+
* @public
|
|
2039
|
+
*/
|
|
2040
|
+
interface RecordingOidcTokenIssuer {
|
|
2041
|
+
/** The double. */
|
|
2042
|
+
readonly layer: Layer.Layer<OidcTokenIssuer>;
|
|
2043
|
+
/**
|
|
2044
|
+
* A snapshot of the audience each `token` or `claims` call asked for, in
|
|
2045
|
+
* order; `undefined` for a call that named none.
|
|
2046
|
+
*/
|
|
2047
|
+
readonly audiences: () => ReadonlyArray<string | undefined>;
|
|
2048
|
+
}
|
|
2002
2049
|
declare const OidcTokenIssuer_base: Context.ServiceClass<OidcTokenIssuer, "@effected/github-actions/OidcTokenIssuer", OidcTokenIssuerShape>;
|
|
2003
2050
|
/**
|
|
2004
2051
|
* The runner's OIDC token service.
|
|
@@ -2057,6 +2104,39 @@ export declare class OidcTokenIssuer extends OidcTokenIssuer_base {
|
|
|
2057
2104
|
* takes the other one.
|
|
2058
2105
|
*/
|
|
2059
2106
|
static readonly layerFor: (claims: ActionsOidcClaims) => Layer.Layer<OidcTokenIssuer>;
|
|
2107
|
+
/**
|
|
2108
|
+
* A {@link OidcTokenIssuer.layerFor} double that also records the audience
|
|
2109
|
+
* every call asked for.
|
|
2110
|
+
*
|
|
2111
|
+
* @remarks
|
|
2112
|
+
* A sibling of `layerTest` rather than a recording `layerTest`, following
|
|
2113
|
+
* `ActionOutputs.recording`: the doubles here are override-and-die, and a
|
|
2114
|
+
* recorder is a different contract. The audience is the one input a token
|
|
2115
|
+
* request carries, and a token minted for the wrong audience is refused by
|
|
2116
|
+
* the party it was meant for — so "which audience did this ask for" is
|
|
2117
|
+
* worth an assertion rather than an assumption.
|
|
2118
|
+
*
|
|
2119
|
+
* Each call returns a fresh journal and a fresh layer: bind the result to a
|
|
2120
|
+
* `const` and provide its `layer` once.
|
|
2121
|
+
*
|
|
2122
|
+
* @example
|
|
2123
|
+
* ```ts
|
|
2124
|
+
* import type { ActionsOidcClaims } from "@effected/github";
|
|
2125
|
+
* import { OidcTokenIssuer } from "@effected/github-actions";
|
|
2126
|
+
* import { Effect } from "effect";
|
|
2127
|
+
*
|
|
2128
|
+
* declare const claims: ActionsOidcClaims;
|
|
2129
|
+
* const recorder = OidcTokenIssuer.recording(claims);
|
|
2130
|
+
* const program = Effect.gen(function* () {
|
|
2131
|
+
* const issuer = yield* OidcTokenIssuer;
|
|
2132
|
+
* yield* issuer.token("https://registry.example");
|
|
2133
|
+
* return recorder.audiences();
|
|
2134
|
+
* });
|
|
2135
|
+
* Effect.runPromise(Effect.provide(program, recorder.layer)).then(console.log);
|
|
2136
|
+
* // => ["https://registry.example"]
|
|
2137
|
+
* ```
|
|
2138
|
+
*/
|
|
2139
|
+
static readonly recording: (claims: ActionsOidcClaims) => RecordingOidcTokenIssuer;
|
|
2060
2140
|
}
|
|
2061
2141
|
/**
|
|
2062
2142
|
* Serves `@effected/oidc`'s `IdentityToken` contract from the runner's own OIDC
|
|
@@ -2177,6 +2257,71 @@ export declare class ActionsProvenance {
|
|
|
2177
2257
|
*/
|
|
2178
2258
|
static readonly capture: (audience?: string) => Effect.Effect<SlsaProvenance, OidcTokenError, OidcTokenIssuer | ActionEnvironment>;
|
|
2179
2259
|
}
|
|
2260
|
+
/**
|
|
2261
|
+
* Registry credentials minted from the runner's own workload identity.
|
|
2262
|
+
*
|
|
2263
|
+
* @remarks
|
|
2264
|
+
* The GitHub Actions half of `@effected/npm`'s workload credential. npm owns
|
|
2265
|
+
* the credential's shape and the npmrc write and takes no Actions edge, so it
|
|
2266
|
+
* cannot mint or mask; this class does both, so a consumer never holds the
|
|
2267
|
+
* identity token or the prefixed value as plaintext and never reaches for
|
|
2268
|
+
* `Secret.forSigning` to build one.
|
|
2269
|
+
*
|
|
2270
|
+
* @example
|
|
2271
|
+
* ```ts
|
|
2272
|
+
* import { ActionsRegistryCredential } from "@effected/github-actions";
|
|
2273
|
+
* import { PackagePublish } from "@effected/npm";
|
|
2274
|
+
* import { Effect } from "effect";
|
|
2275
|
+
*
|
|
2276
|
+
* const program = Effect.gen(function* () {
|
|
2277
|
+
* const credential = yield* ActionsRegistryCredential.workload({
|
|
2278
|
+
* audience: "https://registry.example",
|
|
2279
|
+
* prefix: "example_workload_",
|
|
2280
|
+
* });
|
|
2281
|
+
* const publish = yield* PackagePublish;
|
|
2282
|
+
* yield* publish.setupAuth({
|
|
2283
|
+
* registry: "https://registry.example/npm",
|
|
2284
|
+
* credential,
|
|
2285
|
+
* npmrcPath: "/home/runner/.npmrc",
|
|
2286
|
+
* });
|
|
2287
|
+
* });
|
|
2288
|
+
* ```
|
|
2289
|
+
*
|
|
2290
|
+
* @public
|
|
2291
|
+
*/
|
|
2292
|
+
export declare class ActionsRegistryCredential {
|
|
2293
|
+
private constructor();
|
|
2294
|
+
/**
|
|
2295
|
+
* Mint a workload identity token for `audience`, mask it and its prefixed
|
|
2296
|
+
* form, and return `@effected/npm`'s `WorkloadCredential`.
|
|
2297
|
+
*
|
|
2298
|
+
* @remarks
|
|
2299
|
+
* In order: the runner's {@link OidcTokenIssuer} mints a token for
|
|
2300
|
+
* `audience` (verbatim — it is the registry's own audience, and a token
|
|
2301
|
+
* minted for another is refused); the bare token is masked; npm's
|
|
2302
|
+
* `workloadCredential` prefixes it; the prefixed value is masked too,
|
|
2303
|
+
* because the runner's log filter matches whole registered values and the
|
|
2304
|
+
* prefixed form is a new one. Both masks are emitted before the credential
|
|
2305
|
+
* is returned, so no later step — the npm subprocess included — can print
|
|
2306
|
+
* either value in clear.
|
|
2307
|
+
*
|
|
2308
|
+
* A mint failure stays an {@link OidcTokenError}, distinct from a later
|
|
2309
|
+
* `PublishError` of kind `"auth"` from `setupAuth`, so a caller can tell
|
|
2310
|
+
* "the runner refused an identity token" from "the npmrc could not be
|
|
2311
|
+
* written". On an issuer failure nothing is masked and nothing is built.
|
|
2312
|
+
*
|
|
2313
|
+
* **In a detached worker the masks are a leak**, exactly as for
|
|
2314
|
+
* {@link Secret.mask}: mint in the parent, where the runner parses stdout.
|
|
2315
|
+
*
|
|
2316
|
+
* @param options - `audience` for the identity token; `prefix` is the
|
|
2317
|
+
* registry's token prefix, an open string because the vocabulary belongs
|
|
2318
|
+
* to the registry, not to this kit.
|
|
2319
|
+
*/
|
|
2320
|
+
static readonly workload: (options: {
|
|
2321
|
+
readonly audience: string;
|
|
2322
|
+
readonly prefix: string;
|
|
2323
|
+
}) => Effect.Effect<WorkloadCredential, OidcTokenError, OidcTokenIssuer | ActionOutputs>;
|
|
2324
|
+
}
|
|
2180
2325
|
declare const ArtifactError_base: Schema.Class<ArtifactError, Schema.TaggedStruct<"ArtifactError", {
|
|
2181
2326
|
/**
|
|
2182
2327
|
* `misconfigured` — the results backend is not reachable from here (see
|
|
@@ -5071,5 +5216,5 @@ export declare class Secret {
|
|
|
5071
5216
|
*/
|
|
5072
5217
|
static readonly adopt: (name: string) => Config.Config<Redacted.Redacted<string>>;
|
|
5073
5218
|
}
|
|
5074
|
-
export { type ActionCacheShape, type ActionEnvironmentShape, type ActionLoggerShape, type ActionOutputError, type ActionOutputsShape, type ActionRunOptions, type ActionServices, type ActionStateShape, type AnnotationProperties, type ArtifactItem, type ArtifactRef, type ArtifactShape, type BlobEnvelopeError, type BlobStoreShape, type CacheKeyError, type CheckDocumentOptions, type CheckDocumentShape, type CheckDocumentSink, type CheckFlushOutcome, type CheckRunConclusion, type CheckRunProjection, type ClientLayerOptions, type DataBlobTransfer, type DetachedProcessError, type DetachedProcessOps, type DetachedSpawnOptions, type DownloadOptions, type DownloadResult, type DryRunShape, type ExtractOptions, type FileBlobTransfer, type GitHubHeadingDepth, type GitHubListOptions, type GitHubRowSchema, type GitHubSchemaTable, type GitHubSchemaTableColumn, type GitHubSchemaTableColumns, type GitHubSchemaTableFormatRequiredKeys, type GitHubSchemaTableFormattedColumn, type GitHubSchemaTableOptions, type ManagedDocumentSource, type OidcTokenIssuerShape, type PackageManagerInstallOptions, type PackageManagerInstallerShape, type PairsOptions, type PathPrependEnv, type PathPrependOptions, type ProvisionFileOptions, type ProvisionOptions, type ProvisionedFile, type ReadOptions, type ReadinessOptions, type RecordedOutputMember, type RecordingOutputs, type S3Config, type StoredBlob, type ToolDownloadOptions, type ToolInstallerShape, type UploadOptions, type UploadResult, type WithBufferOptions, type WithStepOptions, WorkflowCommand };
|
|
5219
|
+
export { type ActionCacheShape, type ActionEnvironmentShape, type ActionLoggerShape, type ActionOutputError, type ActionOutputsShape, type ActionRunOptions, type ActionServices, type ActionStateShape, type AnnotationProperties, type ArtifactItem, type ArtifactRef, type ArtifactShape, type BlobEnvelopeError, type BlobStoreShape, type CacheKeyError, type CheckDocumentOptions, type CheckDocumentShape, type CheckDocumentSink, type CheckFlushOutcome, type CheckRunConclusion, type CheckRunProjection, type ClientLayerOptions, type DataBlobTransfer, type DetachedProcessError, type DetachedProcessOps, type DetachedSpawnOptions, type DownloadOptions, type DownloadResult, type DryRunShape, type ExtractOptions, type FileBlobTransfer, type GitHubHeadingDepth, type GitHubListOptions, type GitHubRowSchema, type GitHubSchemaTable, type GitHubSchemaTableColumn, type GitHubSchemaTableColumns, type GitHubSchemaTableFormatRequiredKeys, type GitHubSchemaTableFormattedColumn, type GitHubSchemaTableOptions, type ManagedDocumentSource, type OidcTokenIssuerShape, type PackageManagerInstallOptions, type PackageManagerInstallerShape, type PairsOptions, type PathPrependEnv, type PathPrependOptions, type ProvisionFileOptions, type ProvisionOptions, type ProvisionedFile, type ReadOptions, type ReadinessOptions, type RecordedOutputMember, type RecordingOidcTokenIssuer, type RecordingOutputs, type S3Config, type StoredBlob, type ToolDownloadOptions, type ToolInstallerShape, type UploadOptions, type UploadResult, type WithBufferOptions, type WithStepOptions, WorkflowCommand };
|
|
5075
5220
|
//# sourceMappingURL=index.d.ts.map
|
package/index.js
CHANGED
|
@@ -9,9 +9,10 @@ import { ActionCache, ActionCacheError } from "./ActionCache.js";
|
|
|
9
9
|
import { OidcTokenError, OidcTokenIssuer } from "./OidcTokenIssuer.js";
|
|
10
10
|
import { ActionsIdentityToken } from "./ActionsIdentityToken.js";
|
|
11
11
|
import { ActionsProvenance } from "./ActionsProvenance.js";
|
|
12
|
+
import { Secret } from "./Secret.js";
|
|
13
|
+
import { ActionsRegistryCredential } from "./ActionsRegistryCredential.js";
|
|
12
14
|
import { Artifact, ArtifactError } from "./Artifact.js";
|
|
13
15
|
import { BlobEnvelope, BlobMetadataDecodeError, BlobMetadataEncodeError, NotABlobEnvelopeError, TruncatedBlobEnvelopeError, UnsupportedBlobEnvelopeVersionError } from "./BlobEnvelope.js";
|
|
14
|
-
import { Secret } from "./Secret.js";
|
|
15
16
|
import { BlobStore, BlobStoreError } from "./BlobStore.js";
|
|
16
17
|
import { GitHubCacheBlobStore } from "./BlobStore.githubCache.js";
|
|
17
18
|
import { CacheKey, CacheKeyBadPatternError, CacheKeyReadError } from "./CacheKey.js";
|
|
@@ -27,4 +28,4 @@ import { ToolInstaller, ToolInstallerError } from "./ToolInstaller.js";
|
|
|
27
28
|
import { AmbientPackageManager, CachedPackageManager, InstalledPackageManager, PackageManagerInstaller, PackageManagerInstallerError } from "./PackageManagerInstaller.js";
|
|
28
29
|
import { WorkflowCommand } from "@effected/github-commands";
|
|
29
30
|
|
|
30
|
-
export { Action, ActionCache, ActionCacheError, ActionEnvironment, ActionEnvironmentError, ActionInput, ActionLogger, ActionOutputs, ActionRuntime, ActionState, ActionStateError, ActionsIdentityToken, ActionsProvenance, AmbientPackageManager, Artifact, ArtifactError, BlobEnvelope, BlobMetadataDecodeError, BlobMetadataEncodeError, BlobStore, BlobStoreError, BlobTransferError, CacheKey, CacheKeyBadPatternError, CacheKeyReadError, CachedPackageManager, CheckDocument, CheckDocumentError, CheckDocumentStamp, CheckReport, CheckState, ChildEnv, DetachedLogUnavailableError, DetachedNotReadyError, DetachedOutputError, DetachedProcess, DetachedSignalFailedError, DetachedSpawnFailedError, DryRun, GitHubCacheBlobStore, GitHubContext, GitHubMarkdown, GitHubToken, GitHubTokenError, InstalledPackageManager, InvalidOutputNameError, InvalidPidError, ManagedDocument, ManagedDocumentError, NotABlobEnvelopeError, OidcTokenError, OidcTokenIssuer, OutputEncodeError, PackageManagerInstaller, PackageManagerInstallerError, ProcessId, RecordedOutput, RunnerContext, RunnerFileUnavailableError, RunnerFileWriteError, Secret, ToolInstaller, ToolInstallerError, TruncatedBlobEnvelopeError, UnsupportedBlobEnvelopeVersionError, WorkflowCommand, describeCause, projectCheckState };
|
|
31
|
+
export { Action, ActionCache, ActionCacheError, ActionEnvironment, ActionEnvironmentError, ActionInput, ActionLogger, ActionOutputs, ActionRuntime, ActionState, ActionStateError, ActionsIdentityToken, ActionsProvenance, ActionsRegistryCredential, AmbientPackageManager, Artifact, ArtifactError, BlobEnvelope, BlobMetadataDecodeError, BlobMetadataEncodeError, BlobStore, BlobStoreError, BlobTransferError, CacheKey, CacheKeyBadPatternError, CacheKeyReadError, CachedPackageManager, CheckDocument, CheckDocumentError, CheckDocumentStamp, CheckReport, CheckState, ChildEnv, DetachedLogUnavailableError, DetachedNotReadyError, DetachedOutputError, DetachedProcess, DetachedSignalFailedError, DetachedSpawnFailedError, DryRun, GitHubCacheBlobStore, GitHubContext, GitHubMarkdown, GitHubToken, GitHubTokenError, InstalledPackageManager, InvalidOutputNameError, InvalidPidError, ManagedDocument, ManagedDocumentError, NotABlobEnvelopeError, OidcTokenError, OidcTokenIssuer, OutputEncodeError, PackageManagerInstaller, PackageManagerInstallerError, ProcessId, RecordedOutput, RunnerContext, RunnerFileUnavailableError, RunnerFileWriteError, Secret, ToolInstaller, ToolInstallerError, TruncatedBlobEnvelopeError, UnsupportedBlobEnvelopeVersionError, WorkflowCommand, describeCause, projectCheckState };
|
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,17 +39,17 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@azure/storage-blob": "^12.33.0",
|
|
42
|
-
"@effected/crypto": "^0.1.
|
|
43
|
-
"@effected/github": "^0.23.
|
|
44
|
-
"@effected/github-commands": "^0.6.
|
|
42
|
+
"@effected/crypto": "^0.1.1",
|
|
43
|
+
"@effected/github": "^0.23.1",
|
|
44
|
+
"@effected/github-commands": "^0.6.1",
|
|
45
45
|
"@effected/glob": "^0.14.0",
|
|
46
|
-
"@effected/jwt": "^0.
|
|
47
|
-
"@effected/markdown": "^0.
|
|
48
|
-
"@effected/npm": "^0.
|
|
49
|
-
"@effected/oidc": "^0.1.
|
|
50
|
-
"@effected/sbom": "^0.15.
|
|
51
|
-
"@effected/semver": "^0.
|
|
52
|
-
"@effected/templates": "^0.14.
|
|
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",
|
|
53
53
|
"@effected/walker": "^0.19.0"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|