@intentius/chant 0.124.100 → 0.124.102

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.
Files changed (270) hide show
  1. package/dist/action-pins.d.ts +2 -0
  2. package/dist/action-pins.js +3 -0
  3. package/dist/ci-detect.d.ts +13 -0
  4. package/dist/ci-detect.js +12 -0
  5. package/dist/ci-evidence-claims.d.ts +12 -0
  6. package/dist/ci-evidence-claims.js +12 -0
  7. package/dist/ci-system.d.ts +66 -0
  8. package/dist/ci-system.js +61 -0
  9. package/dist/cli/handlers/build.js +27 -0
  10. package/dist/cli/handlers/release-doctor.d.ts +12 -0
  11. package/dist/cli/handlers/release-doctor.js +118 -0
  12. package/dist/cli/handlers/release-init.d.ts +10 -0
  13. package/dist/cli/handlers/release-init.js +374 -0
  14. package/dist/cli/handlers/release.d.ts +43 -2
  15. package/dist/cli/handlers/release.js +667 -39
  16. package/dist/cli/handlers/run-generate.js +11 -0
  17. package/dist/cli/main.d.ts +2 -0
  18. package/dist/cli/main.js +44 -101
  19. package/dist/cli/parse-args.js +48 -0
  20. package/dist/cli/registry.d.ts +16 -0
  21. package/dist/cli/release-commands/artifacts.d.ts +3 -0
  22. package/dist/cli/release-commands/artifacts.js +14 -0
  23. package/dist/cli/release-commands/candidates.d.ts +3 -0
  24. package/dist/cli/release-commands/candidates.js +16 -0
  25. package/dist/cli/release-commands/changed.d.ts +3 -0
  26. package/dist/cli/release-commands/changed.js +14 -0
  27. package/dist/cli/release-commands/compose.d.ts +3 -0
  28. package/dist/cli/release-commands/compose.js +16 -0
  29. package/dist/cli/release-commands/cut.d.ts +3 -0
  30. package/dist/cli/release-commands/cut.js +50 -0
  31. package/dist/cli/release-commands/doctor.d.ts +3 -0
  32. package/dist/cli/release-commands/doctor.js +14 -0
  33. package/dist/cli/release-commands/export.d.ts +3 -0
  34. package/dist/cli/release-commands/export.js +12 -0
  35. package/dist/cli/release-commands/images.d.ts +3 -0
  36. package/dist/cli/release-commands/images.js +13 -0
  37. package/dist/cli/release-commands/index.d.ts +8 -0
  38. package/dist/cli/release-commands/index.js +52 -0
  39. package/dist/cli/release-commands/init.d.ts +3 -0
  40. package/dist/cli/release-commands/init.js +19 -0
  41. package/dist/cli/release-commands/list.d.ts +3 -0
  42. package/dist/cli/release-commands/list.js +10 -0
  43. package/dist/cli/release-commands/next.d.ts +3 -0
  44. package/dist/cli/release-commands/next.js +13 -0
  45. package/dist/cli/release-commands/publish.d.ts +3 -0
  46. package/dist/cli/release-commands/publish.js +22 -0
  47. package/dist/cli/release-commands/stamp.d.ts +3 -0
  48. package/dist/cli/release-commands/stamp.js +15 -0
  49. package/dist/cli/release-commands/status.d.ts +3 -0
  50. package/dist/cli/release-commands/status.js +17 -0
  51. package/dist/cli/release-commands/tag.d.ts +3 -0
  52. package/dist/cli/release-commands/tag.js +12 -0
  53. package/dist/cli/release-commands/types.d.ts +20 -0
  54. package/dist/cli/release-commands/types.js +1 -0
  55. package/dist/cli/release-commands/verify.d.ts +3 -0
  56. package/dist/cli/release-commands/verify.js +15 -0
  57. package/dist/cli/release-commands/workflow.d.ts +3 -0
  58. package/dist/cli/release-commands/workflow.js +15 -0
  59. package/dist/cloud-lister/index.d.ts +4 -1
  60. package/dist/cloud-lister/index.js +2 -1
  61. package/dist/cloud-lister/kubernetes-components.d.ts +56 -0
  62. package/dist/cloud-lister/kubernetes-components.js +642 -0
  63. package/dist/cloud-lister/kubernetes.d.ts +18 -0
  64. package/dist/cloud-lister/kubernetes.js +26 -1
  65. package/dist/cloud-lister/mask.d.ts +5 -1
  66. package/dist/cloud-lister/mask.js +14 -5
  67. package/dist/components/cli-support.d.ts +1 -1
  68. package/dist/components/cli-support.js +1 -1
  69. package/dist/config-environments.d.ts +8 -1
  70. package/dist/config-environments.js +2 -0
  71. package/dist/config-import.d.ts +1 -1
  72. package/dist/config-import.js +6 -2
  73. package/dist/config-sandbox.d.ts +1 -1
  74. package/dist/config-sandbox.js +3 -3
  75. package/dist/config.d.ts +369 -10
  76. package/dist/config.js +127 -7
  77. package/dist/deep-observation.js +9 -3
  78. package/dist/floor-table.data.js +21 -1
  79. package/dist/forge-remote.d.ts +13 -0
  80. package/dist/forge-remote.js +15 -0
  81. package/dist/lexicon.d.ts +45 -4
  82. package/dist/lifecycle/__fixtures__/package-files.d.ts +32 -0
  83. package/dist/lifecycle/__fixtures__/package-files.js +72 -0
  84. package/dist/lifecycle/__fixtures__/publish-fakes.d.ts +62 -0
  85. package/dist/lifecycle/__fixtures__/publish-fakes.js +275 -3
  86. package/dist/lifecycle/publish-attachments.d.ts +2 -1
  87. package/dist/lifecycle/publish-attachments.js +19 -2
  88. package/dist/lifecycle/publish-cargo.d.ts +99 -0
  89. package/dist/lifecycle/publish-cargo.js +412 -0
  90. package/dist/lifecycle/publish-credentials.d.ts +1 -1
  91. package/dist/lifecycle/publish-credentials.js +13 -0
  92. package/dist/lifecycle/publish-declaration.d.ts +322 -4
  93. package/dist/lifecycle/publish-declaration.js +340 -9
  94. package/dist/lifecycle/publish-forge.d.ts +45 -2
  95. package/dist/lifecycle/publish-forge.js +434 -34
  96. package/dist/lifecycle/publish-git-ssh.d.ts +15 -0
  97. package/dist/lifecycle/publish-git-ssh.js +30 -4
  98. package/dist/lifecycle/publish-github.d.ts +40 -2
  99. package/dist/lifecycle/publish-github.js +100 -3
  100. package/dist/lifecycle/publish-helm.d.ts +83 -0
  101. package/dist/lifecycle/publish-helm.js +452 -0
  102. package/dist/lifecycle/publish-homebrew.d.ts +7 -9
  103. package/dist/lifecycle/publish-homebrew.js +34 -197
  104. package/dist/lifecycle/publish-index.d.ts +141 -0
  105. package/dist/lifecycle/publish-index.js +719 -0
  106. package/dist/lifecycle/publish-marketplace.js +77 -0
  107. package/dist/lifecycle/publish-maven.d.ts +79 -0
  108. package/dist/lifecycle/publish-maven.js +364 -0
  109. package/dist/lifecycle/publish-mcp-registry.d.ts +66 -0
  110. package/dist/lifecycle/publish-mcp-registry.js +305 -0
  111. package/dist/lifecycle/publish-npm.d.ts +27 -1
  112. package/dist/lifecycle/publish-npm.js +216 -3
  113. package/dist/lifecycle/publish-nuget.d.ts +93 -0
  114. package/dist/lifecycle/publish-nuget.js +377 -0
  115. package/dist/lifecycle/publish-oci.d.ts +91 -2
  116. package/dist/lifecycle/publish-oci.js +247 -8
  117. package/dist/lifecycle/publish-package-files.d.ts +16 -0
  118. package/dist/lifecycle/publish-package-files.js +39 -0
  119. package/dist/lifecycle/publish-pypi.d.ts +138 -0
  120. package/dist/lifecycle/publish-pypi.js +657 -0
  121. package/dist/lifecycle/publish-record.d.ts +6 -3
  122. package/dist/lifecycle/publish-record.js +6 -3
  123. package/dist/lifecycle/publish-rubygems.d.ts +84 -0
  124. package/dist/lifecycle/publish-rubygems.js +366 -0
  125. package/dist/lifecycle/publish-signing.d.ts +147 -0
  126. package/dist/lifecycle/publish-signing.js +257 -0
  127. package/dist/lifecycle/publish-targets.d.ts +37 -1
  128. package/dist/lifecycle/publish-targets.js +102 -0
  129. package/dist/lifecycle/publish-tauri.js +43 -0
  130. package/dist/lifecycle/publish-train-names.d.ts +57 -0
  131. package/dist/lifecycle/publish-train-names.js +123 -0
  132. package/dist/lifecycle/publish-verify.d.ts +121 -0
  133. package/dist/lifecycle/publish-verify.js +130 -0
  134. package/dist/lifecycle/query.js +8 -0
  135. package/dist/lifecycle/release-artifacts.d.ts +290 -0
  136. package/dist/lifecycle/release-artifacts.js +808 -0
  137. package/dist/lifecycle/release-changelog.d.ts +13 -1
  138. package/dist/lifecycle/release-changelog.js +35 -2
  139. package/dist/lifecycle/release-cut.d.ts +64 -4
  140. package/dist/lifecycle/release-cut.js +147 -34
  141. package/dist/lifecycle/release-doctor.d.ts +113 -0
  142. package/dist/lifecycle/release-doctor.js +1198 -0
  143. package/dist/lifecycle/release-green.d.ts +86 -0
  144. package/dist/lifecycle/release-green.js +286 -0
  145. package/dist/lifecycle/release-init-registries.d.ts +48 -0
  146. package/dist/lifecycle/release-init-registries.js +97 -0
  147. package/dist/lifecycle/release-init.d.ts +275 -0
  148. package/dist/lifecycle/release-init.js +984 -0
  149. package/dist/lifecycle/release-intents.d.ts +73 -0
  150. package/dist/lifecycle/release-intents.js +128 -0
  151. package/dist/lifecycle/release-next.d.ts +111 -0
  152. package/dist/lifecycle/release-next.js +251 -0
  153. package/dist/lifecycle/release-prerelease.d.ts +19 -0
  154. package/dist/lifecycle/release-prerelease.js +30 -0
  155. package/dist/lifecycle/release-publish.d.ts +256 -10
  156. package/dist/lifecycle/release-publish.js +247 -35
  157. package/dist/lifecycle/release-status-change.d.ts +226 -0
  158. package/dist/lifecycle/release-status-change.js +478 -0
  159. package/dist/lifecycle/release-status.d.ts +11 -0
  160. package/dist/lifecycle/release-status.js +1 -1
  161. package/dist/lifecycle/release-store.d.ts +73 -2
  162. package/dist/lifecycle/release-store.js +32 -1
  163. package/dist/lifecycle/release-tag.d.ts +142 -0
  164. package/dist/lifecycle/release-tag.js +322 -0
  165. package/dist/lifecycle/release-verify.d.ts +73 -1
  166. package/dist/lifecycle/release-verify.js +117 -2
  167. package/dist/lifecycle/release-version-formats.d.ts +73 -0
  168. package/dist/lifecycle/release-version-formats.js +570 -0
  169. package/dist/lifecycle/release-version.d.ts +58 -10
  170. package/dist/lifecycle/release-version.js +164 -36
  171. package/dist/lifecycle/release-workstation.d.ts +3 -2
  172. package/dist/lifecycle/release-workstation.js +3 -2
  173. package/dist/op/generate-pipeline.js +1 -1
  174. package/dist/op/local-executor.d.ts +1 -1
  175. package/dist/op/local-executor.js +2 -2
  176. package/dist/op/op-waves-evidence.js +9 -2
  177. package/dist/pr-forge-base.js +4 -2
  178. package/dist/pr-forge.d.ts +20 -2
  179. package/dist/pr-forge.js +46 -10
  180. package/dist/release-floors.d.ts +8 -1
  181. package/dist/release-floors.js +9 -2
  182. package/dist/sensitive-key.d.ts +12 -0
  183. package/dist/sensitive-key.js +52 -0
  184. package/dist/tool-pins.d.ts +40 -0
  185. package/dist/tool-pins.js +66 -0
  186. package/dist/ts-loader.d.ts +8 -0
  187. package/dist/ts-loader.js +19 -0
  188. package/dist/wave-runtime.mjs +345 -342
  189. package/dist/workspace/ci-forge.d.ts +17 -0
  190. package/dist/workspace/ci-forge.js +17 -0
  191. package/dist/workspace/ci-init.js +1 -1
  192. package/dist/workspace/composites.schema.json +1 -0
  193. package/dist/workspace/declaration.d.ts +8 -0
  194. package/dist/workspace/declaration.js +12 -0
  195. package/dist/workspace/declaration.schema.json +8 -0
  196. package/dist/workspace/environments.d.ts +2 -0
  197. package/dist/workspace/environments.js +1 -1
  198. package/dist/workspace/identity-gate-rule.d.ts +61 -5
  199. package/dist/workspace/identity-gate-rule.js +81 -12
  200. package/dist/workspace/lexicon-outputs.d.ts +1 -1
  201. package/dist/workspace/lexicon-outputs.js +1 -1
  202. package/dist/workspace/member-pipeline.d.ts +2 -1
  203. package/dist/workspace/member-pipeline.js +5 -2
  204. package/dist/workspace/reason-codes.d.ts +2 -0
  205. package/dist/workspace/reason-codes.js +3 -1
  206. package/dist/workspace/release-changed.d.ts +75 -4
  207. package/dist/workspace/release-changed.js +205 -34
  208. package/dist/workspace/release-changed.schema.json +20 -2
  209. package/dist/workspace/release-steps/artifacts.d.ts +7 -0
  210. package/dist/workspace/release-steps/artifacts.js +45 -0
  211. package/dist/workspace/release-steps/builds.d.ts +12 -0
  212. package/dist/workspace/release-steps/builds.js +38 -0
  213. package/dist/workspace/release-steps/doctor.d.ts +8 -0
  214. package/dist/workspace/release-steps/doctor.js +14 -0
  215. package/dist/workspace/release-steps/goreleaser.d.ts +16 -0
  216. package/dist/workspace/release-steps/goreleaser.js +36 -0
  217. package/dist/workspace/release-steps/green.d.ts +3 -0
  218. package/dist/workspace/release-steps/green.js +6 -0
  219. package/dist/workspace/release-steps/images.d.ts +22 -0
  220. package/dist/workspace/release-steps/images.js +59 -0
  221. package/dist/workspace/release-steps/index.d.ts +9 -0
  222. package/dist/workspace/release-steps/index.js +50 -0
  223. package/dist/workspace/release-steps/nfpm.d.ts +13 -0
  224. package/dist/workspace/release-steps/nfpm.js +29 -0
  225. package/dist/workspace/release-steps/nuget.d.ts +14 -0
  226. package/dist/workspace/release-steps/nuget.js +16 -0
  227. package/dist/workspace/release-steps/pypi.d.ts +15 -0
  228. package/dist/workspace/release-steps/pypi.js +21 -0
  229. package/dist/workspace/release-steps/qemu.d.ts +21 -0
  230. package/dist/workspace/release-steps/qemu.js +35 -0
  231. package/dist/workspace/release-steps/signing.d.ts +18 -0
  232. package/dist/workspace/release-steps/signing.js +30 -0
  233. package/dist/workspace/release-steps/stamp.d.ts +3 -0
  234. package/dist/workspace/release-steps/stamp.js +4 -0
  235. package/dist/workspace/release-steps/targets.d.ts +31 -0
  236. package/dist/workspace/release-steps/targets.js +40 -0
  237. package/dist/workspace/release-steps/types.d.ts +104 -0
  238. package/dist/workspace/release-steps/types.js +2 -0
  239. package/dist/workspace/release-steps/verify.d.ts +3 -0
  240. package/dist/workspace/release-steps/verify.js +4 -0
  241. package/dist/workspace/release-toolchains.d.ts +59 -0
  242. package/dist/workspace/release-toolchains.js +133 -0
  243. package/dist/workspace/release-train-workflow.d.ts +36 -0
  244. package/dist/workspace/release-train-workflow.js +121 -0
  245. package/dist/workspace/release-train.d.ts +3 -1
  246. package/dist/workspace/release-train.js +20 -3
  247. package/dist/workspace/release-workflow.d.ts +183 -59
  248. package/dist/workspace/release-workflow.js +570 -201
  249. package/dist/workspace/releases.schema.json +70 -1
  250. package/dist/workspace/search-contract.d.ts +1 -1
  251. package/dist/workspace/security.js +9 -2
  252. package/dist/workspace/train-cut.d.ts +182 -0
  253. package/dist/workspace/train-cut.js +504 -0
  254. package/dist/workspace/train-prepare.d.ts +64 -0
  255. package/dist/workspace/train-prepare.js +313 -0
  256. package/dist/workspace/train-publish.d.ts +177 -0
  257. package/dist/workspace/train-publish.js +574 -0
  258. package/dist/workspace/train-range-labels.d.ts +33 -0
  259. package/dist/workspace/train-range-labels.js +109 -0
  260. package/dist/workspace/train-shell.d.ts +5 -0
  261. package/dist/workspace/train-shell.js +17 -0
  262. package/dist/workspace/trust/check-evidence-report.d.ts +3 -7
  263. package/dist/workspace/trust/check-evidence-report.js +3 -7
  264. package/dist/workspace/trust/seal.d.ts +13 -3
  265. package/dist/workspace/trust/seal.js +14 -4
  266. package/dist/workspace/work-cli.d.ts +3 -2
  267. package/dist/workspace/work-cli.js +3 -2
  268. package/dist/workspace/workspace-ledger.d.ts +14 -1
  269. package/dist/workspace/workspace-ledger.js +33 -7
  270. package/package.json +1 -1
@@ -0,0 +1,93 @@
1
+ /**
2
+ * The NuGet target (#5232): `.nupkg` files pushed to nuget.org, or to another
3
+ * feed that takes NuGet's push API (`PUT <pushUrl>`, a multipart body whose
4
+ * first part is the package, the key in `X-NuGet-ApiKey`).
5
+ *
6
+ * The packages are files, directories of them, or `artifact:<name>`. Each
7
+ * file the release records must match its digest. The id and version are
8
+ * read from the `.nuspec` at the package's root.
9
+ *
10
+ * A feed has no draft: a version is listed once it is pushed and validated,
11
+ * and an id and version can never be pushed again. So the stage pushes
12
+ * nothing. It checks the packages and the credential, and reads the feed's
13
+ * flat container (`<base>/<id>/index.json`) for the versions it already
14
+ * holds: such a version is `present`. nuget.org signs every package it takes
15
+ * with its repository signature, so the bytes it serves are never the bytes
16
+ * pushed and no digest is compared. The reveal reads the flat container
17
+ * again and pushes the rest; a push answered 409 (the version exists) is
18
+ * `present` too, since a version pushed moments ago is not in the flat
19
+ * container until nuget.org has validated it.
20
+ *
21
+ * Credentials:
22
+ *
23
+ * - `auth: "token"`: an API key from `tokenEnv` (default `NUGET_API_KEY`).
24
+ * - `auth: "trusted-publishing"`, nuget.org only: the run's OIDC ID token
25
+ * (audience `https://www.nuget.org`, from GitHub Actions or
26
+ * `NUGET_ID_TOKEN`, a GitLab job's `id_tokens`) is posted to
27
+ * `https://www.nuget.org/api/v2/token` with the user in `userEnv` (default
28
+ * `NUGET_USER`), the nuget.org profile whose trusted publishing policy
29
+ * names the workflow, for an API key that lasts an hour. nuget.org takes
30
+ * an ID token once, so the stage exchanges one only in GitHub Actions,
31
+ * which issues a new token each time it is asked; with `NUGET_ID_TOKEN`
32
+ * the reveal's exchange is the only one.
33
+ *
34
+ * Unset, `auth` is a token when the key's variable is set, else trusted
35
+ * publishing when the run has an OIDC ID token.
36
+ *
37
+ * A status change (#5163): `chant release yank` unlists each version the
38
+ * release pushed (`DELETE <pushUrl>/<id>/<version>`, which nuget.org reads as
39
+ * an unlist; the version stays restorable for anyone who names it), and
40
+ * `restore` lists it again (`POST`). NuGet's API has no deprecation, so
41
+ * `deprecate` changes nothing.
42
+ *
43
+ * Under the `supply-chain` group a package that carries no SBOM (an
44
+ * `.spdx.json`, `.cdx.json` or `.cyclonedx.json` file, or `_manifest/spdx_*`
45
+ * as Microsoft's sbom-tool writes it) is refused unless `sbom` is `false`.
46
+ */
47
+ import type { NugetPublishDeclaration } from "./publish-declaration.js";
48
+ import { type PublishDeps, type PublishTarget } from "./release-publish.js";
49
+ /** The first chant that publishes a `nuget` target (#5232). */
50
+ export declare const PUBLISH_NUGET_FLOOR = "0.124.102";
51
+ export declare const NUGET_ORG: {
52
+ readonly label: "nuget.org";
53
+ readonly site: "https://www.nuget.org";
54
+ readonly push: "https://www.nuget.org/api/v2/package";
55
+ readonly flat: "https://api.nuget.org/v3-flatcontainer/";
56
+ readonly token: "https://www.nuget.org/api/v2/token";
57
+ };
58
+ /** The audience nuget.org takes an OIDC ID token for. */
59
+ export declare const NUGET_AUDIENCE = "https://www.nuget.org";
60
+ /** The variable an OIDC ID token for nuget.org is read from outside GitHub Actions, as nuget.org's docs name it for GitLab. */
61
+ export declare const NUGET_ID_TOKEN_ENV = "NUGET_ID_TOKEN";
62
+ /** The feed a declaration pushes to. */
63
+ export declare function nugetFeed(decl: Pick<NugetPublishDeclaration, "pushUrl" | "flatContainerUrl">): {
64
+ label: string;
65
+ nugetOrg: boolean;
66
+ push: string;
67
+ flat: string;
68
+ };
69
+ export declare const nugetTokenEnv: (decl: Pick<NugetPublishDeclaration, "tokenEnv">) => string;
70
+ export declare const nugetUserEnv: (decl: Pick<NugetPublishDeclaration, "userEnv">) => string;
71
+ /** How the target authenticates in `env`. */
72
+ export declare function nugetAuth(decl: NugetPublishDeclaration, env: NodeJS.ProcessEnv): "token" | "trusted-publishing";
73
+ /**
74
+ * A NuGet version as the flat container lists it: lowercased, no build
75
+ * metadata, no leading zeros, and a fourth part of `0` left off.
76
+ */
77
+ export declare function normalizeNugetVersion(version: string): string;
78
+ /** One `.nupkg`, read. */
79
+ export interface NugetPackage {
80
+ path: string;
81
+ file: string;
82
+ bytes: Buffer;
83
+ digest: string;
84
+ id: string;
85
+ version: string;
86
+ /** The package ids its `.nuspec` depends on. */
87
+ dependencies: string[];
88
+ /** The SBOM entry it carries, if any. */
89
+ sbom: string | null;
90
+ }
91
+ /** Read one `.nupkg`: its `.nuspec`'s id, version and dependencies. */
92
+ export declare function readNupkg(path: string, abs: string): NugetPackage;
93
+ export declare function nugetTarget(decl: NugetPublishDeclaration, deps: PublishDeps): PublishTarget;
@@ -0,0 +1,377 @@
1
+ /**
2
+ * The NuGet target (#5232): `.nupkg` files pushed to nuget.org, or to another
3
+ * feed that takes NuGet's push API (`PUT <pushUrl>`, a multipart body whose
4
+ * first part is the package, the key in `X-NuGet-ApiKey`).
5
+ *
6
+ * The packages are files, directories of them, or `artifact:<name>`. Each
7
+ * file the release records must match its digest. The id and version are
8
+ * read from the `.nuspec` at the package's root.
9
+ *
10
+ * A feed has no draft: a version is listed once it is pushed and validated,
11
+ * and an id and version can never be pushed again. So the stage pushes
12
+ * nothing. It checks the packages and the credential, and reads the feed's
13
+ * flat container (`<base>/<id>/index.json`) for the versions it already
14
+ * holds: such a version is `present`. nuget.org signs every package it takes
15
+ * with its repository signature, so the bytes it serves are never the bytes
16
+ * pushed and no digest is compared. The reveal reads the flat container
17
+ * again and pushes the rest; a push answered 409 (the version exists) is
18
+ * `present` too, since a version pushed moments ago is not in the flat
19
+ * container until nuget.org has validated it.
20
+ *
21
+ * Credentials:
22
+ *
23
+ * - `auth: "token"`: an API key from `tokenEnv` (default `NUGET_API_KEY`).
24
+ * - `auth: "trusted-publishing"`, nuget.org only: the run's OIDC ID token
25
+ * (audience `https://www.nuget.org`, from GitHub Actions or
26
+ * `NUGET_ID_TOKEN`, a GitLab job's `id_tokens`) is posted to
27
+ * `https://www.nuget.org/api/v2/token` with the user in `userEnv` (default
28
+ * `NUGET_USER`), the nuget.org profile whose trusted publishing policy
29
+ * names the workflow, for an API key that lasts an hour. nuget.org takes
30
+ * an ID token once, so the stage exchanges one only in GitHub Actions,
31
+ * which issues a new token each time it is asked; with `NUGET_ID_TOKEN`
32
+ * the reveal's exchange is the only one.
33
+ *
34
+ * Unset, `auth` is a token when the key's variable is set, else trusted
35
+ * publishing when the run has an OIDC ID token.
36
+ *
37
+ * A status change (#5163): `chant release yank` unlists each version the
38
+ * release pushed (`DELETE <pushUrl>/<id>/<version>`, which nuget.org reads as
39
+ * an unlist; the version stays restorable for anyone who names it), and
40
+ * `restore` lists it again (`POST`). NuGet's API has no deprecation, so
41
+ * `deprecate` changes nothing.
42
+ *
43
+ * Under the `supply-chain` group a package that carries no SBOM (an
44
+ * `.spdx.json`, `.cdx.json` or `.cyclonedx.json` file, or `_manifest/spdx_*`
45
+ * as Microsoft's sbom-tool writes it) is refused unless `sbom` is `false`.
46
+ */
47
+ import { readFileSync } from "node:fs";
48
+ import { randomBytes } from "node:crypto";
49
+ import { readCredential } from "./publish-credentials.js";
50
+ import { releaseVersion } from "./publish-index.js";
51
+ import { packageFiles } from "./publish-package-files.js";
52
+ import { zipEntry, zipEntryNames } from "./publish-pypi.js";
53
+ import { bytesDigest, checkReleaseDigest, hasIdToken, publishTargetKey, runIdToken } from "./publish-targets.js";
54
+ import { trainName, waitUntilServed } from "./publish-train-names.js";
55
+ import { NEXT_RELEASE } from "../release-floors.js";
56
+ import { PublishTargetError } from "./release-publish.js";
57
+ /** The first chant that publishes a `nuget` target (#5232). */
58
+ export const PUBLISH_NUGET_FLOOR = NEXT_RELEASE;
59
+ export const NUGET_ORG = { label: "nuget.org", site: "https://www.nuget.org", push: "https://www.nuget.org/api/v2/package", flat: "https://api.nuget.org/v3-flatcontainer/", token: "https://www.nuget.org/api/v2/token" };
60
+ /** The audience nuget.org takes an OIDC ID token for. */
61
+ export const NUGET_AUDIENCE = "https://www.nuget.org";
62
+ /** The variable an OIDC ID token for nuget.org is read from outside GitHub Actions, as nuget.org's docs name it for GitLab. */
63
+ export const NUGET_ID_TOKEN_ENV = "NUGET_ID_TOKEN";
64
+ /** The feed a declaration pushes to. */
65
+ export function nugetFeed(decl) {
66
+ if (decl.pushUrl && decl.flatContainerUrl) {
67
+ return { label: new URL(decl.pushUrl).host, nugetOrg: false, push: decl.pushUrl.replace(/\/+$/, ""), flat: decl.flatContainerUrl.endsWith("/") ? decl.flatContainerUrl : `${decl.flatContainerUrl}/` };
68
+ }
69
+ return { label: NUGET_ORG.label, nugetOrg: true, push: NUGET_ORG.push, flat: NUGET_ORG.flat };
70
+ }
71
+ export const nugetTokenEnv = (decl) => decl.tokenEnv ?? "NUGET_API_KEY";
72
+ export const nugetUserEnv = (decl) => decl.userEnv ?? "NUGET_USER";
73
+ /** How the target authenticates in `env`. */
74
+ export function nugetAuth(decl, env) {
75
+ if (decl.auth)
76
+ return decl.auth;
77
+ if (env[nugetTokenEnv(decl)])
78
+ return "token";
79
+ return nugetFeed(decl).nugetOrg && hasIdToken(env, NUGET_ID_TOKEN_ENV) ? "trusted-publishing" : "token";
80
+ }
81
+ /**
82
+ * A NuGet version as the flat container lists it: lowercased, no build
83
+ * metadata, no leading zeros, and a fourth part of `0` left off.
84
+ */
85
+ export function normalizeNugetVersion(version) {
86
+ const v = version.trim().toLowerCase().replace(/\+.*$/, "");
87
+ const dash = v.indexOf("-");
88
+ const core = dash < 0 ? v : v.slice(0, dash);
89
+ const pre = dash < 0 ? "" : v.slice(dash);
90
+ const parts = core.split(".").map((p) => (/^\d+$/.test(p) ? String(Number(p)) : p));
91
+ while (parts.length < 3)
92
+ parts.push("0");
93
+ if (parts.length === 4 && parts[3] === "0")
94
+ parts.pop();
95
+ return `${parts.join(".")}${pre}`;
96
+ }
97
+ const xmlText = (s) => s.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/&amp;/g, "&").trim();
98
+ /** Read one `.nupkg`: its `.nuspec`'s id, version and dependencies. */
99
+ export function readNupkg(path, abs) {
100
+ const bytes = readFileSync(abs);
101
+ const file = abs.split(/[\\/]/).pop();
102
+ const bad = (why) => new PublishTargetError("publish-nuget-not-a-package", `${path} is not a NuGet package chant can read: ${why}`, "Name the .nupkg files dotnet pack writes.");
103
+ let names;
104
+ try {
105
+ names = zipEntryNames(bytes);
106
+ }
107
+ catch (err) {
108
+ throw bad(err instanceof Error ? err.message : String(err));
109
+ }
110
+ const spec = names.find((n) => /^[^/]+\.nuspec$/i.test(n));
111
+ if (!spec)
112
+ throw bad("it holds no .nuspec at its root");
113
+ let text;
114
+ try {
115
+ text = zipEntry(bytes, spec)?.toString("utf-8") ?? "";
116
+ }
117
+ catch (err) {
118
+ throw bad(err instanceof Error ? err.message : String(err));
119
+ }
120
+ const metadata = /<metadata\b[^>]*>([\s\S]*?)<\/metadata>/i.exec(text)?.[1] ?? "";
121
+ const id = /<id>([^<]+)<\/id>/i.exec(metadata)?.[1];
122
+ const version = /<version>([^<]+)<\/version>/i.exec(metadata)?.[1];
123
+ if (!id || !version)
124
+ throw bad(`${spec} has no <id> or <version>`);
125
+ const dependencies = [...new Set([...metadata.matchAll(/<dependency\b[^>]*\bid="([^"]+)"/gi)].map((m) => xmlText(m[1])))];
126
+ const sbom = names.find((n) => /(^|\/)_manifest\/spdx_[^/]+\/[^/]+\.json$/i.test(n) || /\.(spdx|cdx|cyclonedx)\.json$/i.test(n)) ?? null;
127
+ return { path, file, bytes, digest: bytesDigest(new Uint8Array(bytes)), id: xmlText(id), version: xmlText(version), dependencies, sbom };
128
+ }
129
+ export function nugetTarget(decl, deps) {
130
+ const fetchImpl = deps.fetch ?? ((url, init) => fetch(url, init));
131
+ const feed = nugetFeed(decl);
132
+ const tokenName = nugetTokenEnv(decl);
133
+ const userName = nugetUserEnv(decl);
134
+ const packages = (ctx) => {
135
+ const out = packageFiles(ctx, decl.packages, ".nupkg", "publish-nuget", "Build the packages before publishing, such as with dotnet pack -o dist/nuget.").map(({ path, abs }) => {
136
+ const p = readNupkg(path, abs);
137
+ checkReleaseDigest(ctx.release, "asset", ctx.cwd, path, [p.digest]);
138
+ return p;
139
+ });
140
+ if (ctx.requireSbom && decl.sbom !== false) {
141
+ const without = out.find((p) => p.sbom === null);
142
+ if (without) {
143
+ throw new PublishTargetError("publish-sbom-missing", `${without.file} carries no SBOM: a feed keeps no file beside a package, so a package carries its SBOM, such as _manifest/spdx_2.2/manifest.spdx.json`, "Build packages that carry an SBOM, such as with Microsoft's sbom-tool, or set sbom: false to publish without one.");
144
+ }
145
+ }
146
+ return out;
147
+ };
148
+ const item = (p) => ({
149
+ name: `${p.id}@${p.version}`,
150
+ destination: feed.nugetOrg ? `${NUGET_ORG.site}/packages/${p.id}/${p.version}` : `${feed.flat}${p.id.toLowerCase()}/`,
151
+ digest: p.digest,
152
+ ...(p.sbom ? { sbom: p.sbom } : {}),
153
+ });
154
+ const fail = (ctx, code, what, status, text, fix) => {
155
+ throw new PublishTargetError(code, ctx.redactor.redact(`${what} on ${feed.label} answered ${status}${text ? `: ${text.replace(/\s+/g, " ").slice(0, 300)}` : ""}`), fix);
156
+ };
157
+ /** The versions the feed lists for an id, normalized; empty when it has no such package. */
158
+ const versions = async (ctx, id, key) => {
159
+ const url = `${feed.flat}${id.toLowerCase()}/index.json`;
160
+ const res = await fetchImpl(url, { method: "GET", headers: { "user-agent": "chant", accept: "application/json", ...(!feed.nugetOrg && key ? { "x-nuget-apikey": key } : {}) } });
161
+ const text = await res.text().catch(() => "");
162
+ if (res.status === 404)
163
+ return new Set();
164
+ if (res.status !== 200)
165
+ fail(ctx, "publish-nuget-failed", `reading ${url}`, res.status, text);
166
+ try {
167
+ const list = JSON.parse(text).versions;
168
+ return new Set(Array.isArray(list) ? list.filter((v) => typeof v === "string").map(normalizeNugetVersion) : []);
169
+ }
170
+ catch {
171
+ return fail(ctx, "publish-nuget-failed", `reading ${url}`, res.status, "not JSON");
172
+ }
173
+ };
174
+ const presence = async (ctx, pkgs, key) => {
175
+ const byId = new Map();
176
+ const out = new Map();
177
+ for (const p of pkgs) {
178
+ const k = p.id.toLowerCase();
179
+ if (!byId.has(k))
180
+ byId.set(k, await versions(ctx, p.id, key));
181
+ out.set(`${p.id}@${p.version}`, byId.get(k).has(normalizeNugetVersion(p.version)));
182
+ }
183
+ return out;
184
+ };
185
+ /** The API key, or null under trusted publishing; refuses a run with neither. */
186
+ const credential = (ctx) => {
187
+ const auth = nugetAuth(decl, ctx.env);
188
+ if (auth === "token") {
189
+ const key = readCredential(ctx.env, [tokenName], ctx.redactor);
190
+ if (!key) {
191
+ throw new PublishTargetError("publish-credentials-missing", `the ${feed.label} target reads its API key from ${tokenName}, and it is not set${feed.nugetOrg ? ", and this run has no OIDC ID token for trusted publishing" : ""}`, feed.nugetOrg ? `Set ${tokenName} to a nuget.org API key that may push the packages, or publish from a CI job with an OIDC ID token and a trusted publishing policy on nuget.org.` : `Set ${tokenName} to a key the feed takes.`);
192
+ }
193
+ return { auth, key, user: null };
194
+ }
195
+ if (!hasIdToken(ctx.env, NUGET_ID_TOKEN_ENV)) {
196
+ throw new PublishTargetError("publish-credentials-missing", `the nuget.org target publishes with trusted publishing, and this run has no OIDC ID token: not a GitHub Actions job with id-token: write, and ${NUGET_ID_TOKEN_ENV} is not set`, `In GitHub Actions, give the job permissions: id-token: write. In GitLab CI, declare ${NUGET_ID_TOKEN_ENV} under the job's id_tokens with aud: ${NUGET_AUDIENCE}.`);
197
+ }
198
+ const user = readCredential(ctx.env, [userName], ctx.redactor);
199
+ if (!user)
200
+ throw new PublishTargetError("publish-credentials-missing", `trusted publishing on nuget.org names the user whose policy trusts this workflow, and ${userName} is not set`, `Set ${userName} to that nuget.org profile name (not the email address).`);
201
+ return { auth, key: null, user: user.value };
202
+ };
203
+ /** Trusted publishing: an API key for this run, for its OIDC ID token. It lasts an hour. */
204
+ const exchange = async (ctx, user) => {
205
+ const jwt = await runIdToken(ctx, fetchImpl, NUGET_AUDIENCE, NUGET_ID_TOKEN_ENV, "publish-nuget-trusted-publishing");
206
+ const res = await fetchImpl(NUGET_ORG.token, { method: "POST", headers: { "user-agent": "chant", "content-type": "application/json", authorization: `Bearer ${jwt}` }, body: JSON.stringify({ username: user, tokenType: "ApiKey" }) });
207
+ const text = await res.text().catch(() => "");
208
+ let body = {};
209
+ try {
210
+ body = JSON.parse(text);
211
+ }
212
+ catch {
213
+ // Reported by its status.
214
+ }
215
+ if (res.status !== 200 || typeof body.apiKey !== "string" || !body.apiKey) {
216
+ throw new PublishTargetError("publish-nuget-trusted-publishing", ctx.redactor.redact(`nuget.org gave no API key for this run's OIDC ID token: it answered ${res.status}${typeof body.error === "string" ? `: ${body.error}` : text ? `: ${text.replace(/\s+/g, " ").slice(0, 300)}` : ""}`), `Add a trusted publishing policy on nuget.org for this repository and workflow file, and set ${userName} to the profile name of the user who created it.`);
217
+ }
218
+ ctx.redactor.add(body.apiKey);
219
+ return body.apiKey;
220
+ };
221
+ /** Whether the stage can exchange without spending the reveal's ID token: GitHub Actions issues one per request. */
222
+ const canCheckExchange = (env) => !env[NUGET_ID_TOKEN_ENV] && Boolean(env.ACTIONS_ID_TOKEN_REQUEST_URL && env.ACTIONS_ID_TOKEN_REQUEST_TOKEN);
223
+ const push = async (ctx, p, key) => {
224
+ const boundary = `chant-${randomBytes(12).toString("hex")}`;
225
+ const body = Buffer.concat([
226
+ Buffer.from(`--${boundary}\r\nContent-Disposition: form-data; name="package"; filename="${p.file}"\r\nContent-Type: application/octet-stream\r\n\r\n`, "utf-8"),
227
+ p.bytes,
228
+ Buffer.from(`\r\n--${boundary}--\r\n`, "utf-8"),
229
+ ]);
230
+ ctx.log(`pushing ${p.file} (${p.bytes.byteLength} bytes) to ${feed.label}`);
231
+ const res = await fetchImpl(feed.push, {
232
+ method: "PUT",
233
+ headers: { "user-agent": "chant", "content-type": `multipart/form-data; boundary=${boundary}`, "x-nuget-apikey": key, "x-nuget-protocol-version": "4.1.0" },
234
+ body: new Uint8Array(body),
235
+ });
236
+ const text = await res.text().catch(() => "");
237
+ if (res.status === 200 || res.status === 201 || res.status === 202)
238
+ return "sent";
239
+ if (res.status === 409)
240
+ return "present";
241
+ if (res.status === 400)
242
+ return fail(ctx, "publish-nuget-invalid", `pushing ${p.file}`, res.status, text, "Fix the package: the feed refused it as invalid.");
243
+ return fail(ctx, "publish-nuget-failed", `pushing ${p.file}`, res.status, text, res.status === 401 || res.status === 403 ? `Check that the key may push ${p.id}: on nuget.org, its scope and glob pattern, or the trusted publishing policy's.` : undefined);
244
+ };
245
+ const target = {
246
+ kind: "nuget",
247
+ name: `${feed.label} ${decl.packages.join(", ")}`,
248
+ destination: feed.label,
249
+ credentialEnv: [tokenName, userName, NUGET_ID_TOKEN_ENV],
250
+ key: publishTargetKey(decl),
251
+ uploadsAtReveal: true,
252
+ async names(ctx) {
253
+ const pkgs = packages(ctx);
254
+ const provides = [...new Set(pkgs.map((p) => trainName("nuget", p.id)))];
255
+ const needs = new Set(pkgs.flatMap((p) => p.dependencies.map((d) => trainName("nuget", d))));
256
+ return { provides, needs: [...needs].filter((n) => !provides.includes(n)) };
257
+ },
258
+ /** #5165: whether the feed lists each package at the release's version. */
259
+ async published(ctx) {
260
+ const version = releaseVersion(ctx.label);
261
+ if (!version)
262
+ return null;
263
+ let pkgs;
264
+ try {
265
+ pkgs = packages(ctx);
266
+ }
267
+ catch {
268
+ return null;
269
+ }
270
+ const key = readCredential(ctx.env, [tokenName], ctx.redactor)?.value ?? null;
271
+ const present = await presence(ctx, pkgs.map((p) => ({ id: p.id, version })), key);
272
+ return [...present.values()].every(Boolean);
273
+ },
274
+ /** #5165: wait until the flat container lists each version the reveal pushed. nuget.org validates and indexes a package first, which takes minutes. */
275
+ async visible(ctx, published) {
276
+ const pkgs = published.items.filter((i) => i.attachment === undefined && !i.refused).map((i) => /^(.+)@([^@]+)$/.exec(i.name)).filter((m) => m !== null).map((m) => ({ id: m[1], version: m[2] }));
277
+ if (pkgs.length === 0)
278
+ return;
279
+ const key = readCredential(ctx.env, [tokenName], ctx.redactor)?.value ?? null;
280
+ await waitUntilServed(ctx, deps, {
281
+ what: feed.label,
282
+ code: "publish-nuget-not-served",
283
+ check: async () => {
284
+ const present = await presence(ctx, pkgs, key);
285
+ return [...present.entries()].filter(([, v]) => !v).map(([k]) => k);
286
+ },
287
+ });
288
+ },
289
+ async plan(ctx) {
290
+ const pkgs = packages(ctx);
291
+ credential(ctx);
292
+ return pkgs.map(item);
293
+ },
294
+ async stage(ctx) {
295
+ const pkgs = packages(ctx);
296
+ const cred = credential(ctx);
297
+ if (cred.key)
298
+ ctx.log(`using the API key from ${cred.key.from}; ${feed.label} has no read-only check of a key, so whether it may push shows at the reveal`);
299
+ else if (canCheckExchange(ctx.env)) {
300
+ await exchange(ctx, cred.user);
301
+ ctx.log("nuget.org takes this run as a trusted publisher; the reveal asks for a new key");
302
+ }
303
+ else
304
+ ctx.log(`nuget.org takes an ID token once, so the reveal makes the trusted-publishing exchange with ${NUGET_ID_TOKEN_ENV}`);
305
+ const present = await presence(ctx, pkgs, cred.key?.value ?? null);
306
+ const items = pkgs.map((p) => (present.get(`${p.id}@${p.version}`) ? { ...item(p), present: true } : item(p)));
307
+ const waiting = items.filter((i) => !i.present).map((i) => i.name);
308
+ ctx.log(waiting.length === 0 ? `${feed.label} already lists every package at its version` : `${waiting.join(", ")} ${waiting.length === 1 ? "is" : "are"} pushed at the reveal, since ${feed.label} has no draft`);
309
+ const staged = { target: target.name, destination: target.destination, items, state: waiting.length === 0 ? { present: "true" } : {} };
310
+ return staged;
311
+ },
312
+ async reveal(ctx, staged) {
313
+ if (staged.state.present === "true")
314
+ return { target: target.name, destination: target.destination, items: staged.items.map((i) => ({ ...i, present: true })) };
315
+ const pkgs = packages(ctx);
316
+ const cred = credential(ctx);
317
+ // Read again: a reveal run after a push whose record was lost finds the version there.
318
+ const present = await presence(ctx, pkgs, cred.key?.value ?? null);
319
+ let key = cred.key?.value ?? null;
320
+ const done = [];
321
+ const items = [];
322
+ for (const p of pkgs) {
323
+ const name = `${p.id}@${p.version}`;
324
+ if (present.get(name)) {
325
+ items.push({ ...item(p), present: true });
326
+ continue;
327
+ }
328
+ key ?? (key = await exchange(ctx, cred.user));
329
+ let r;
330
+ try {
331
+ r = await push(ctx, p, key);
332
+ }
333
+ catch (err) {
334
+ if (err instanceof PublishTargetError && done.length > 0)
335
+ throw new PublishTargetError(err.code, `${err.message}. Pushed before it: ${done.join(", ")}; the same publish run again pushes only the rest`, err.fix);
336
+ throw err;
337
+ }
338
+ if (r === "present")
339
+ ctx.log(`${feed.label} already has ${name}; it signs what it takes, so the bytes are not compared`);
340
+ else
341
+ done.push(name);
342
+ items.push(r === "present" ? { ...item(p), present: true } : item(p));
343
+ }
344
+ return { target: target.name, destination: target.destination, items };
345
+ },
346
+ /**
347
+ * #5163: a yank unlists each version the release pushed, a restore lists
348
+ * it again. NuGet's API has no deprecation.
349
+ */
350
+ async setStatus(ctx) {
351
+ if (ctx.status === "deprecated")
352
+ return [{ what: `${feed.label} unchanged: NuGet's API has no deprecation; yank unlists the versions`, already: true }];
353
+ const relist = ctx.status === "active";
354
+ const pkgs = ctx.revealed.filter((i) => i.attachment === undefined && !i.refused && i.name.lastIndexOf("@") > 0).map((i) => ({ id: i.name.slice(0, i.name.lastIndexOf("@")), version: i.name.slice(i.name.lastIndexOf("@") + 1) }));
355
+ const what = (p) => `${relist ? "POST" : "DELETE"} ${feed.push}/${p.id}/${p.version} (${relist ? "list" : "unlist"} ${p.id}@${p.version})`;
356
+ if (!ctx.apply)
357
+ return pkgs.map((p) => ({ what: what(p) }));
358
+ const cred = credential(ctx);
359
+ const key = cred.key?.value ?? (await exchange(ctx, cred.user));
360
+ const actions = [];
361
+ for (const p of pkgs) {
362
+ ctx.log(`${relist ? "listing" : "unlisting"} ${p.id}@${p.version} on ${feed.label}`);
363
+ const res = await fetchImpl(`${feed.push}/${encodeURIComponent(p.id)}/${encodeURIComponent(p.version)}`, { method: relist ? "POST" : "DELETE", headers: { "user-agent": "chant", "x-nuget-apikey": key, "x-nuget-protocol-version": "4.1.0" } });
364
+ const text = await res.text().catch(() => "");
365
+ if (res.status === 404) {
366
+ actions.push({ what: `${p.id}@${p.version} is not on ${feed.label}; nothing to ${relist ? "restore" : "yank"}`, already: true });
367
+ continue;
368
+ }
369
+ if (res.status < 200 || res.status > 299)
370
+ fail(ctx, "release-status-nuget-failed", what(p), res.status, text, `Unlisting needs a key that may unlist ${p.id}.`);
371
+ actions.push({ what: what(p) });
372
+ }
373
+ return actions;
374
+ },
375
+ };
376
+ return target;
377
+ }
@@ -22,6 +22,13 @@
22
22
  * discover` or `cosign tree` finds them. A referrer the registry already
23
23
  * holds is not pushed again.
24
24
  *
25
+ * When the publish signs (#5164, ./publish-signing.ts), the stage also
26
+ * pushes a cosign signature and SLSA provenance of the image, each a Sigstore
27
+ * bundle in an artifact manifest whose subject is the image. On a registry
28
+ * without the referrers API (GHCR, Docker Hub) they are listed under the
29
+ * referrers tag `sha256-<hex>`, as cosign does. An image that already has a
30
+ * bundle with the same predicate type is not signed again.
31
+ *
25
32
  * Credentials come from `usernameEnv` and `passwordEnv` (default
26
33
  * `OCI_USERNAME`, `OCI_PASSWORD`), or else from the `auths` entry for the
27
34
  * registry in the docker config file (`$DOCKER_CONFIG/config.json` or
@@ -36,8 +43,9 @@
36
43
  * and a one-part Docker Hub name is under `library/`.
37
44
  */
38
45
  import { type Attachment } from "./publish-attachments.js";
46
+ import { type Credential } from "./publish-credentials.js";
39
47
  import type { OciPublishDeclaration } from "./publish-declaration.js";
40
- import { type PublishContext, type PublishDeps, type PublishTarget } from "./release-publish.js";
48
+ import { type PublishContext, type PublishContextBase, type PublishDeps, type PublishFetch, type PublishTarget } from "./release-publish.js";
41
49
  /** A repository reference split into where the registry is and the name in it. */
42
50
  export interface OciRepository {
43
51
  /** The host as written, used to find docker config credentials. */
@@ -48,10 +56,83 @@ export interface OciRepository {
48
56
  name: string;
49
57
  }
50
58
  export declare function parseRepository(repository: string): OciRepository;
59
+ /** The credential for `repo`: the declared variables, else the docker config's `auths` entry. */
60
+ export declare function ociCredential(decl: Pick<OciPublishDeclaration, "usernameEnv" | "passwordEnv">, repo: OciRepository, ctx: Pick<PublishContext, "env" | "redactor">): {
61
+ username: string;
62
+ password: Credential;
63
+ } | null;
51
64
  /** How many times an upload or a manifest is tried before the target fails (#4877). */
52
65
  export declare const OCI_PUSH_ATTEMPTS = 4;
53
66
  /** The wait before the second try, doubled for each try after it. */
54
67
  export declare const OCI_PUSH_RETRY_MS = 2000;
68
+ /**
69
+ * A registry client that answers the registry's auth challenge and keeps the
70
+ * token. A 401 under a token it already holds, as when the registry's token
71
+ * expires during a long push, is answered once more (#4877).
72
+ */
73
+ export declare class Registry {
74
+ private readonly repo;
75
+ private readonly fetch;
76
+ private readonly cred;
77
+ private readonly ctx;
78
+ private readonly sleep;
79
+ private auth;
80
+ constructor(repo: OciRepository, fetch: PublishFetch, cred: {
81
+ username: string;
82
+ password: Credential;
83
+ } | null, ctx: PublishContextBase, sleep?: (ms: number) => Promise<void>);
84
+ private fail;
85
+ request(method: string, path: string, headers?: Record<string, string>, body?: Uint8Array): Promise<Awaited<ReturnType<PublishFetch>>>;
86
+ private answerChallenge;
87
+ /**
88
+ * Run `attempt` up to {@link OCI_PUSH_ATTEMPTS} times while it fails with a
89
+ * {@link retryable} answer or a dropped connection, waiting longer before
90
+ * each try (#4877). Any other answer fails the target at once.
91
+ */
92
+ private tries;
93
+ /** Upload a blob unless the registry holds it. True when it was uploaded. */
94
+ pushBlob(digest: string, bytes: () => Uint8Array): Promise<boolean>;
95
+ /** Whether the registry holds the manifest `digest`. */
96
+ hasManifest(digest: string, mediaType: string): Promise<boolean>;
97
+ /** The manifest `ref` (a tag or a digest) names, or null when the registry has none (#5163). */
98
+ getManifest(ref: string): Promise<{
99
+ mediaType: string;
100
+ bytes: Uint8Array;
101
+ digest: string;
102
+ } | null>;
103
+ /** Put a manifest. True when the registry answered with `OCI-Subject`, so its referrers API lists a manifest with a subject. */
104
+ putManifest(ref: string, mediaType: string, bytes: Uint8Array): Promise<boolean>;
105
+ /**
106
+ * The referrers of `digest` (#5164): the referrers API's index, else, on a
107
+ * registry without it (GHCR, Docker Hub), the index the referrers tag
108
+ * schema keeps at the tag `sha256-<hex>`. Empty when there is neither.
109
+ */
110
+ referrers(digest: string): Promise<ReferrerDescriptor[]>;
111
+ private referrersTag;
112
+ /** Add `descriptor` to the referrers tag of `subject` (the OCI distribution spec's fallback), unless it is listed there. */
113
+ addToReferrersTag(subject: string, descriptor: ReferrerDescriptor): Promise<void>;
114
+ }
115
+ /** One referrer as an index lists it. */
116
+ interface ReferrerDescriptor {
117
+ mediaType: string;
118
+ digest: string;
119
+ size: number;
120
+ artifactType?: string;
121
+ annotations?: Record<string, string>;
122
+ }
123
+ /** The tag the referrers tag schema keeps the referrers of `digest` under: `sha256-<hex>`. */
124
+ export declare function referrersTagOf(digest: string): string;
125
+ /**
126
+ * The artifact manifest that attaches a Sigstore bundle to the image
127
+ * `subject` (#5164), as `cosign sign` and `cosign attest` push one: the
128
+ * bundle media type as the artifact type and the one layer, and the
129
+ * statement's predicate type in `dev.sigstore.bundle.predicateType`.
130
+ */
131
+ export declare function bundleReferrerManifest(bundle: Attachment, predicateType: string, subject: {
132
+ mediaType: string;
133
+ digest: string;
134
+ size: number;
135
+ }): Uint8Array;
55
136
  /**
56
137
  * The artifact manifest that attaches `a` to the image `subject` (OCI image
57
138
  * spec 1.1): `artifactType` is the file's media type, the config is the empty
@@ -62,8 +143,16 @@ export declare function referrerManifest(a: Attachment, subject: {
62
143
  digest: string;
63
144
  size: number;
64
145
  }): Uint8Array;
65
- /** The tags to point at the digest: the context's tag when set, else the declared ones with `{label}` filled in. */
146
+ /** The tags to point at the digest: the context's tag when set, else the declared ones with `{label}` filled in, without `latest` for a prerelease label. */
66
147
  export declare function ociTags(decl: OciPublishDeclaration, ctx: Pick<PublishContext, "tag" | "label">): string[];
67
148
  /** The digest an OCI archive (a layout directory or a tar file of one) is pushed under: its top manifest's (#4657). */
68
149
  export declare function ociArchiveDigest(abs: string): string;
150
+ /**
151
+ * The tags a status change moves (#5163): the channel's tag when the release
152
+ * was cut to one, else the declared tags with no `{label}` in them, such as
153
+ * `latest`, without `latest` for a prerelease label, which never moved it
154
+ * (#5166). A tag that names the label belongs to that release and stays.
155
+ */
156
+ export declare function ociMovingTags(decl: OciPublishDeclaration, channel: string | null, label?: string | null): string[];
69
157
  export declare function ociTarget(decl: OciPublishDeclaration, deps: PublishDeps): PublishTarget;
158
+ export {};