@effected/github-actions 0.25.0 → 0.27.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 CHANGED
@@ -97,6 +97,37 @@ 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 log groups are open around the current fiber.
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
+ * Keyed by `WorkflowCommand.groupDepthKey`, the kit-wide key for this count,
112
+ * rather than a key of this package's own: Effect looks a reference up by its
113
+ * key, so `@effected/cli`'s `Render.context`, which builds its own reference
114
+ * from the same key, sees the depth this member provides, and a document it
115
+ * renders inside a group opens no second one.
116
+ *
117
+ * @internal
118
+ */
119
+ const GroupDepth = Context.Reference(WorkflowCommand.groupDepthKey, { defaultValue: () => 0 });
120
+ /**
121
+ * The `▸ <name>` line a nested group writes in place of a second `::group::`,
122
+ * and the line {@link ActionLoggerShape.heading} writes.
123
+ *
124
+ * @remarks
125
+ * Line breaks collapse to spaces so the header stays one line — the
126
+ * top-level form escapes them into one command — and the result is
127
+ * neutralized, because a group name is caller text and a `::` or `##[` in it
128
+ * would otherwise be a command.
129
+ */
130
+ const nestedHeader = (name) => CommandNeutralizer.text(`▸ ${name.replace(/\r\n|\r|\n/g, " ")}`);
100
131
  /** Drop a transcript without writing it, so a green step stays quiet. */
101
132
  const discard = (state) => Effect.sync(() => {
102
133
  state.entries.length = 0;
@@ -132,7 +163,11 @@ const make = Effect.gen(function* () {
132
163
  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
164
  });
134
165
  return {
135
- group: (name, effect) => Effect.acquireUseRelease(Console.log(WorkflowCommand.group(name)), () => Effect.tapCause(effect, () => flushActive), () => Console.log(WorkflowCommand.endGroup())),
166
+ group: (name, effect) => Effect.flatMap(GroupDepth, (depth) => {
167
+ const body = Effect.tapCause(Effect.provideService(effect, GroupDepth, depth + 1), () => flushActive);
168
+ return depth === 0 ? Effect.acquireUseRelease(Console.log(WorkflowCommand.group(name)), () => body, () => Console.log(WorkflowCommand.endGroup())) : Effect.andThen(Console.log(nestedHeader(name)), body);
169
+ }),
170
+ heading: (name, effect) => Effect.andThen(Console.log(nestedHeader(name)), effect),
136
171
  withBuffer,
137
172
  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
173
  notice: (message, properties = {}) => Console.log(WorkflowCommand.notice(message, properties)),
@@ -199,11 +234,13 @@ var ActionLogger = class ActionLogger extends Context.Service()("@effected/githu
199
234
  * **A recorded exception to the die-on-unstubbed rule**, alongside
200
235
  * {@link ActionEnvironment.makeTest}. A logger that dies when a suite logs
201
236
  * would make every double unusable, and silence is the honest default for a
202
- * service whose whole job is output. Group and buffer wrappers pass their
203
- * effect through unchanged.
237
+ * service whose whole job is output. Group, heading and buffer wrappers pass their
238
+ * effect through unchanged, so the double does not model group nesting:
239
+ * a test of nested-group output needs the live {@link ActionLogger.layer}.
204
240
  */
205
241
  static makeTest = (overrides = {}) => ({
206
242
  group: (_name, effect) => effect,
243
+ heading: (_name, effect) => effect,
207
244
  withBuffer: (_label, effect) => effect,
208
245
  withStep: (_name, effect) => effect,
209
246
  notice: () => Effect.void,
@@ -0,0 +1,81 @@
1
+ import { Secret } from "./Secret.js";
2
+ import { OidcTokenIssuer } from "./OidcTokenIssuer.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";
@@ -1,5 +1,7 @@
1
1
  import { ActionEnvironment } from "./ActionEnvironment.js";
2
2
  import { unstubbed } from "./internal/unstubbed.js";
3
+ import { ActionOutputs } from "./ActionOutputs.js";
4
+ import { Secret } from "./Secret.js";
3
5
  import { Context, Effect, Layer, Redacted, Schema } from "effect";
4
6
  import { HttpClient, HttpClientRequest } from "effect/http";
5
7
  import { Oidc } from "@effected/oidc";
@@ -81,12 +83,13 @@ const unsignedJwt = (header, payload) => {
81
83
  const make = Effect.gen(function* () {
82
84
  const env = yield* ActionEnvironment;
83
85
  const http = yield* HttpClient.HttpClient;
86
+ const outputs = yield* ActionOutputs;
84
87
  const required = (name) => env.get(name).pipe(Effect.mapError(() => new OidcTokenError({
85
88
  reason: "unavailable",
86
89
  detail: name
87
90
  })));
88
91
  /**
89
- * The raw JWT, before it is wrapped.
92
+ * The raw JWT, masked, before it is wrapped.
90
93
  *
91
94
  * @remarks
92
95
  * `claims` reads this rather than unwrapping what `token` returns, so
@@ -94,6 +97,11 @@ const make = Effect.gen(function* () {
94
97
  * declassification invariant is that `Secret.ts` is the only place a secret
95
98
  * becomes a string, and a wrap-then-immediately-unwrap here would be a
96
99
  * genuine exception to it rather than a cosmetic one.
100
+ *
101
+ * This is the one place every issued token passes, so it is where the token
102
+ * is registered with the runner's log filter: `token` and `claims` both get
103
+ * it, once per token, before anything downstream can decode, fail on or
104
+ * declassify it. The `ActionOutputs` is the one the layer was built with.
97
105
  */
98
106
  const issue = Effect.fn("OidcTokenIssuer.token")(function* (audience) {
99
107
  const bearer = yield* required(REQUEST_TOKEN);
@@ -107,10 +115,12 @@ const make = Effect.gen(function* () {
107
115
  reason: "requestFailed",
108
116
  status: response.status
109
117
  }));
110
- return (yield* HttpClientResponse.schemaBodyJson(TokenEnvelope)(response).pipe(Effect.mapError((cause) => new OidcTokenError({
118
+ const envelope = yield* HttpClientResponse.schemaBodyJson(TokenEnvelope)(response).pipe(Effect.mapError((cause) => new OidcTokenError({
111
119
  reason: "malformedResponse",
112
120
  cause
113
- })))).value;
121
+ })));
122
+ yield* Secret.mask(Redacted.make(envelope.value)).pipe(Effect.provideService(ActionOutputs, outputs));
123
+ return envelope.value;
114
124
  });
115
125
  return {
116
126
  token: (audience) => Effect.map(issue(audience), Redacted.make),
@@ -150,6 +160,13 @@ var OidcTokenIssuer = class OidcTokenIssuer extends Context.Service()("@effected
150
160
  * @remarks
151
161
  * Fails with {@link OidcTokenError} (`unavailable`) at use when the workflow
152
162
  * lacks `permissions: id-token: write`.
163
+ *
164
+ * Requires {@link ActionOutputs} because every token it issues is masked
165
+ * through it at issuance (see {@link OidcTokenIssuerShape.token}). Under
166
+ * `ActionRuntime.layer` that is already at hand; a worker that composes
167
+ * `ActionOutputs.layerDetached` gets an issuer whose mask is the documented
168
+ * no-op, which is the right thing there and no substitute for minting in
169
+ * the parent.
153
170
  */
154
171
  static layer = Layer.effect(this, make);
155
172
  /**
@@ -187,6 +204,51 @@ var OidcTokenIssuer = class OidcTokenIssuer extends Context.Service()("@effected
187
204
  token: () => Effect.succeed(OidcTokenIssuer.unsignedTokenFor(claims)),
188
205
  claims: () => Effect.succeed(claims)
189
206
  });
207
+ /**
208
+ * A {@link OidcTokenIssuer.layerFor} double that also records the audience
209
+ * every call asked for.
210
+ *
211
+ * @remarks
212
+ * A sibling of `layerTest` rather than a recording `layerTest`, following
213
+ * `ActionOutputs.recording`: the doubles here are override-and-die, and a
214
+ * recorder is a different contract. The audience is the one input a token
215
+ * request carries, and a token minted for the wrong audience is refused by
216
+ * the party it was meant for — so "which audience did this ask for" is
217
+ * worth an assertion rather than an assumption.
218
+ *
219
+ * Each call returns a fresh journal and a fresh layer: bind the result to a
220
+ * `const` and provide its `layer` once.
221
+ *
222
+ * @example
223
+ * ```ts
224
+ * import type { ActionsOidcClaims } from "@effected/github";
225
+ * import { OidcTokenIssuer } from "@effected/github-actions";
226
+ * import { Effect } from "effect";
227
+ *
228
+ * declare const claims: ActionsOidcClaims;
229
+ * const recorder = OidcTokenIssuer.recording(claims);
230
+ * const program = Effect.gen(function* () {
231
+ * const issuer = yield* OidcTokenIssuer;
232
+ * yield* issuer.token("https://registry.example");
233
+ * return recorder.audiences();
234
+ * });
235
+ * Effect.runPromise(Effect.provide(program, recorder.layer)).then(console.log);
236
+ * // => ["https://registry.example"]
237
+ * ```
238
+ */
239
+ static recording = (claims) => {
240
+ const audiences = [];
241
+ const record = (audience) => Effect.sync(() => {
242
+ audiences.push(audience);
243
+ });
244
+ return {
245
+ layer: Layer.succeed(OidcTokenIssuer, {
246
+ token: (audience) => Effect.as(record(audience), OidcTokenIssuer.unsignedTokenFor(claims)),
247
+ claims: (audience) => Effect.as(record(audience), claims)
248
+ }),
249
+ audiences: () => audiences.slice()
250
+ };
251
+ };
190
252
  };
191
253
 
192
254
  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"]>;
@@ -293,14 +293,70 @@ interface WithStepOptions {
293
293
  readonly summary?: string;
294
294
  }
295
295
  /**
296
- * The members of the {@link ActionLogger} service: log groups, buffered steps,
297
- * notices and source annotations.
296
+ * The members of the {@link ActionLogger} service: log groups and headings,
297
+ * buffered steps, notices and source annotations.
298
298
  *
299
299
  * @public
300
300
  */
301
301
  interface ActionLoggerShape {
302
- /** Run an effect inside a collapsible log group. */
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 a writer that reads the shared depth is counted.** The depth
327
+ * lives in the fiber-local keyed by `WorkflowCommand.groupDepthKey`
328
+ * (from `@effected/github-commands`), which `@effected/cli` reads too:
329
+ * `Render.context` built inside a group carries it as
330
+ * `RenderContext.groupDepth`, so `Doc.print` and `Render.githubLog`
331
+ * render a top-level collapsible as plain text there rather than as a
332
+ * second group. A raw `WorkflowCommand.group(...)`, or a consumer's
333
+ * own wrapper that does not read the key, opens a group this member
334
+ * cannot see, and a group opened inside one still nests at the runner.
335
+ * 4. **The test doubles do not model nesting.** `makeTest`, `layerTest` and
336
+ * `layerSilent` pass the effect through unchanged.
337
+ */
303
338
  readonly group: <A, E, R>(name: string, effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
339
+ /**
340
+ * Run an effect under a `▸ <name>` header line, without opening a group.
341
+ *
342
+ * @remarks
343
+ * The phase-level banner: the same one-line, neutralized header a nested
344
+ * {@link ActionLoggerShape.group} writes, then the body, with no
345
+ * `::group::` and no change to the depth. So the groups inside it stay
346
+ * top level and each renders as its own collapsible section in the runner
347
+ * log, which a `group` wrapper cannot give them: the runner does not nest
348
+ * groups, and a wrapper that opened one would swallow every inner group
349
+ * into a header line. Reach for this when a phase encloses groups, and for
350
+ * `group` when it encloses only lines.
351
+ *
352
+ * The header goes out through `Console`, like a group command, so it is
353
+ * never captured into, or discarded with, an enclosing `withBuffer` or
354
+ * `withStep` transcript. Nothing is written when the body ends, and a
355
+ * failure flushes no buffer here: the groups inside do that for their own
356
+ * sections. Called inside an open group it is simply a header line in that
357
+ * group. The test doubles pass the body through unchanged.
358
+ */
359
+ readonly heading: <A, E, R>(name: string, effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
304
360
  /**
305
361
  * Run an effect with its verbose output captured and replayed on exit.
306
362
  *
@@ -435,8 +491,9 @@ export declare class ActionLogger extends ActionLogger_base {
435
491
  * **A recorded exception to the die-on-unstubbed rule**, alongside
436
492
  * {@link ActionEnvironment.makeTest}. A logger that dies when a suite logs
437
493
  * would make every double unusable, and silence is the honest default for a
438
- * service whose whole job is output. Group and buffer wrappers pass their
439
- * effect through unchanged.
494
+ * service whose whole job is output. Group, heading and buffer wrappers pass their
495
+ * effect through unchanged, so the double does not model group nesting:
496
+ * a test of nested-group output needs the live {@link ActionLogger.layer}.
440
497
  */
441
498
  static readonly makeTest: (overrides?: Partial<ActionLoggerShape>) => ActionLoggerShape;
442
499
  /** {@link ActionLogger.makeTest} behind `Layer.succeed`. */
@@ -1968,6 +2025,17 @@ interface OidcTokenIssuerShape {
1968
2025
  * Omitting the audience sends no `audience` parameter at all, matching
1969
2026
  * `@actions/core.getIDToken` — the runner's default audience is not the empty
1970
2027
  * string.
2028
+ *
2029
+ * **The live issuer masks the token at issuance.** Every token it fetches is
2030
+ * registered with the runner's log filter (`Secret.mask`, one `::add-mask::`)
2031
+ * before it is returned, so a consumer that declassifies and logs it, or
2032
+ * serializes an error carrying it, prints a redaction rather than the JWT.
2033
+ * Masking is the issuer's job because it is the one place every token
2034
+ * passes; a consumer masking again is harmless. The caveat `Secret.mask`
2035
+ * documents applies: in a **detached worker** the mask line itself is the
2036
+ * leak, since no runner parses that process's stdout, so mint in the parent
2037
+ * and compose `ActionOutputs.layerDetached` in the worker, under which the
2038
+ * mask is a no-op. The doubles mask nothing: they issue no real token.
1971
2039
  */
1972
2040
  readonly token: (audience?: string) => Effect.Effect<Redacted.Redacted<string>, OidcTokenError>;
1973
2041
  /**
@@ -1996,9 +2064,30 @@ interface OidcTokenIssuerShape {
1996
2064
  * {@link OidcTokenIssuer.layerFor} answers with real, decodable claims, so
1997
2065
  * a test cannot silently skip the path under test because the double
1998
2066
  * returned a token that is not a JWT.
2067
+ *
2068
+ * The token this fetches to decode is masked too, exactly as
2069
+ * {@link OidcTokenIssuerShape.token}'s is, though it never leaves: the raw
2070
+ * JWT exists in this process for the decode, and a decode failure's cause can
2071
+ * carry what it failed on, so the mask costs one command and closes that
2072
+ * path. There is one mask site, where the token is issued, for both members.
1999
2073
  */
2000
2074
  readonly claims: (audience?: string) => Effect.Effect<ActionsOidcClaims, OidcTokenError>;
2001
2075
  }
2076
+ /**
2077
+ * What {@link OidcTokenIssuer.recording} returns: the layer to provide and the
2078
+ * audiences it was asked for.
2079
+ *
2080
+ * @public
2081
+ */
2082
+ interface RecordingOidcTokenIssuer {
2083
+ /** The double. */
2084
+ readonly layer: Layer.Layer<OidcTokenIssuer>;
2085
+ /**
2086
+ * A snapshot of the audience each `token` or `claims` call asked for, in
2087
+ * order; `undefined` for a call that named none.
2088
+ */
2089
+ readonly audiences: () => ReadonlyArray<string | undefined>;
2090
+ }
2002
2091
  declare const OidcTokenIssuer_base: Context.ServiceClass<OidcTokenIssuer, "@effected/github-actions/OidcTokenIssuer", OidcTokenIssuerShape>;
2003
2092
  /**
2004
2093
  * The runner's OIDC token service.
@@ -2030,8 +2119,15 @@ export declare class OidcTokenIssuer extends OidcTokenIssuer_base {
2030
2119
  * @remarks
2031
2120
  * Fails with {@link OidcTokenError} (`unavailable`) at use when the workflow
2032
2121
  * lacks `permissions: id-token: write`.
2122
+ *
2123
+ * Requires {@link ActionOutputs} because every token it issues is masked
2124
+ * through it at issuance (see {@link OidcTokenIssuerShape.token}). Under
2125
+ * `ActionRuntime.layer` that is already at hand; a worker that composes
2126
+ * `ActionOutputs.layerDetached` gets an issuer whose mask is the documented
2127
+ * no-op, which is the right thing there and no substitute for minting in
2128
+ * the parent.
2033
2129
  */
2034
- static readonly layer: Layer.Layer<OidcTokenIssuer, never, ActionEnvironment | HttpClient.HttpClient>;
2130
+ static readonly layer: Layer.Layer<OidcTokenIssuer, never, ActionEnvironment | HttpClient.HttpClient | ActionOutputs>;
2035
2131
  /**
2036
2132
  * An **unsigned** JWT carrying these claims.
2037
2133
  *
@@ -2057,6 +2153,39 @@ export declare class OidcTokenIssuer extends OidcTokenIssuer_base {
2057
2153
  * takes the other one.
2058
2154
  */
2059
2155
  static readonly layerFor: (claims: ActionsOidcClaims) => Layer.Layer<OidcTokenIssuer>;
2156
+ /**
2157
+ * A {@link OidcTokenIssuer.layerFor} double that also records the audience
2158
+ * every call asked for.
2159
+ *
2160
+ * @remarks
2161
+ * A sibling of `layerTest` rather than a recording `layerTest`, following
2162
+ * `ActionOutputs.recording`: the doubles here are override-and-die, and a
2163
+ * recorder is a different contract. The audience is the one input a token
2164
+ * request carries, and a token minted for the wrong audience is refused by
2165
+ * the party it was meant for — so "which audience did this ask for" is
2166
+ * worth an assertion rather than an assumption.
2167
+ *
2168
+ * Each call returns a fresh journal and a fresh layer: bind the result to a
2169
+ * `const` and provide its `layer` once.
2170
+ *
2171
+ * @example
2172
+ * ```ts
2173
+ * import type { ActionsOidcClaims } from "@effected/github";
2174
+ * import { OidcTokenIssuer } from "@effected/github-actions";
2175
+ * import { Effect } from "effect";
2176
+ *
2177
+ * declare const claims: ActionsOidcClaims;
2178
+ * const recorder = OidcTokenIssuer.recording(claims);
2179
+ * const program = Effect.gen(function* () {
2180
+ * const issuer = yield* OidcTokenIssuer;
2181
+ * yield* issuer.token("https://registry.example");
2182
+ * return recorder.audiences();
2183
+ * });
2184
+ * Effect.runPromise(Effect.provide(program, recorder.layer)).then(console.log);
2185
+ * // => ["https://registry.example"]
2186
+ * ```
2187
+ */
2188
+ static readonly recording: (claims: ActionsOidcClaims) => RecordingOidcTokenIssuer;
2060
2189
  }
2061
2190
  /**
2062
2191
  * Serves `@effected/oidc`'s `IdentityToken` contract from the runner's own OIDC
@@ -2177,6 +2306,71 @@ export declare class ActionsProvenance {
2177
2306
  */
2178
2307
  static readonly capture: (audience?: string) => Effect.Effect<SlsaProvenance, OidcTokenError, OidcTokenIssuer | ActionEnvironment>;
2179
2308
  }
2309
+ /**
2310
+ * Registry credentials minted from the runner's own workload identity.
2311
+ *
2312
+ * @remarks
2313
+ * The GitHub Actions half of `@effected/npm`'s workload credential. npm owns
2314
+ * the credential's shape and the npmrc write and takes no Actions edge, so it
2315
+ * cannot mint or mask; this class does both, so a consumer never holds the
2316
+ * identity token or the prefixed value as plaintext and never reaches for
2317
+ * `Secret.forSigning` to build one.
2318
+ *
2319
+ * @example
2320
+ * ```ts
2321
+ * import { ActionsRegistryCredential } from "@effected/github-actions";
2322
+ * import { PackagePublish } from "@effected/npm";
2323
+ * import { Effect } from "effect";
2324
+ *
2325
+ * const program = Effect.gen(function* () {
2326
+ * const credential = yield* ActionsRegistryCredential.workload({
2327
+ * audience: "https://registry.example",
2328
+ * prefix: "example_workload_",
2329
+ * });
2330
+ * const publish = yield* PackagePublish;
2331
+ * yield* publish.setupAuth({
2332
+ * registry: "https://registry.example/npm",
2333
+ * credential,
2334
+ * npmrcPath: "/home/runner/.npmrc",
2335
+ * });
2336
+ * });
2337
+ * ```
2338
+ *
2339
+ * @public
2340
+ */
2341
+ export declare class ActionsRegistryCredential {
2342
+ private constructor();
2343
+ /**
2344
+ * Mint a workload identity token for `audience`, mask it and its prefixed
2345
+ * form, and return `@effected/npm`'s `WorkloadCredential`.
2346
+ *
2347
+ * @remarks
2348
+ * In order: the runner's {@link OidcTokenIssuer} mints a token for
2349
+ * `audience` (verbatim — it is the registry's own audience, and a token
2350
+ * minted for another is refused); the bare token is masked; npm's
2351
+ * `workloadCredential` prefixes it; the prefixed value is masked too,
2352
+ * because the runner's log filter matches whole registered values and the
2353
+ * prefixed form is a new one. Both masks are emitted before the credential
2354
+ * is returned, so no later step — the npm subprocess included — can print
2355
+ * either value in clear.
2356
+ *
2357
+ * A mint failure stays an {@link OidcTokenError}, distinct from a later
2358
+ * `PublishError` of kind `"auth"` from `setupAuth`, so a caller can tell
2359
+ * "the runner refused an identity token" from "the npmrc could not be
2360
+ * written". On an issuer failure nothing is masked and nothing is built.
2361
+ *
2362
+ * **In a detached worker the masks are a leak**, exactly as for
2363
+ * {@link Secret.mask}: mint in the parent, where the runner parses stdout.
2364
+ *
2365
+ * @param options - `audience` for the identity token; `prefix` is the
2366
+ * registry's token prefix, an open string because the vocabulary belongs
2367
+ * to the registry, not to this kit.
2368
+ */
2369
+ static readonly workload: (options: {
2370
+ readonly audience: string;
2371
+ readonly prefix: string;
2372
+ }) => Effect.Effect<WorkloadCredential, OidcTokenError, OidcTokenIssuer | ActionOutputs>;
2373
+ }
2180
2374
  declare const ArtifactError_base: Schema.Class<ArtifactError, Schema.TaggedStruct<"ArtifactError", {
2181
2375
  /**
2182
2376
  * `misconfigured` — the results backend is not reachable from here (see
@@ -5071,5 +5265,5 @@ export declare class Secret {
5071
5265
  */
5072
5266
  static readonly adopt: (name: string) => Config.Config<Redacted.Redacted<string>>;
5073
5267
  }
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 };
5268
+ 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
5269
  //# sourceMappingURL=index.d.ts.map
package/index.js CHANGED
@@ -6,12 +6,13 @@ import { ActionState, ActionStateError } from "./ActionState.js";
6
6
  import { Action, ActionRuntime, describeCause } from "./Action.js";
7
7
  import { BlobTransferError } from "./BlobTransfer.js";
8
8
  import { ActionCache, ActionCacheError } from "./ActionCache.js";
9
+ import { Secret } from "./Secret.js";
9
10
  import { OidcTokenError, OidcTokenIssuer } from "./OidcTokenIssuer.js";
10
11
  import { ActionsIdentityToken } from "./ActionsIdentityToken.js";
11
12
  import { ActionsProvenance } from "./ActionsProvenance.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 };
@@ -8,8 +8,6 @@ import { Effect } from "effect";
8
8
  *
9
9
  * @internal
10
10
  */
11
- const unstubbed = (double) => (member) => Effect.sync(() => {
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.25.0",
3
+ "version": "0.27.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.0",
43
- "@effected/github": "^0.23.0",
44
- "@effected/github-commands": "^0.6.0",
42
+ "@effected/crypto": "^0.1.1",
43
+ "@effected/github": "^0.24.0",
44
+ "@effected/github-commands": "^0.6.2",
45
45
  "@effected/glob": "^0.14.0",
46
- "@effected/jwt": "^0.5.0",
47
- "@effected/markdown": "^0.20.0",
48
- "@effected/npm": "^0.25.0",
49
- "@effected/oidc": "^0.1.0",
50
- "@effected/sbom": "^0.15.0",
51
- "@effected/semver": "^0.15.0",
52
- "@effected/templates": "^0.14.0",
46
+ "@effected/jwt": "^0.6.0",
47
+ "@effected/markdown": "^0.22.0",
48
+ "@effected/npm": "^0.26.1",
49
+ "@effected/oidc": "^0.1.2",
50
+ "@effected/sbom": "^0.16.0",
51
+ "@effected/semver": "^0.17.0",
52
+ "@effected/templates": "^0.14.1",
53
53
  "@effected/walker": "^0.19.0"
54
54
  },
55
55
  "peerDependencies": {