Skip to content

Commit 3b20062

Browse files
authored
feat(artifacts): handle attestation bundle downloads
feat(artifacts): handle attestation bundle downloads
2 parents 0487e44 + 6cc5329 commit 3b20062

File tree

4 files changed

+14
-21
lines changed

4 files changed

+14
-21
lines changed

client/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
"@tanstack/react-query-devtools": "^5.85.0",
3131
"axios": "^1.7.2",
3232
"dayjs": "^1.11.7",
33-
"file-saver": "^2.0.5",
3433
"js-yaml": "^4.1.0",
3534
"oidc-client-ts": "^2.4.0",
3635
"pvtsutils": "^1.3.6",

client/src/app/pages/Artifacts/components/ArtifactAttestation.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
} from "@patternfly/react-core";
2121
import { useState } from "react";
2222
import { RekorEntryPanel } from "./RekorEntryPanel";
23-
import { relativeDateString } from "@app/utils/utils";
23+
import { handleDownloadBundle, relativeDateString } from "@app/utils/utils";
2424
import { EllipsisVIcon } from "@patternfly/react-icons";
2525
import { CertificateChain } from "./CertificateChain";
2626
import { LeafCertificate } from "./LeafCertificate";
@@ -35,7 +35,6 @@ export const ArtifactAttestation = ({ attestation }: { attestation: AttestationV
3535
const handleToggleActions = () => setActionsOpened(!isActionsOpened);
3636

3737
const handleActionSelect = () => {
38-
// TODO: probably some logic there
3938
setActionsOpened(false);
4039
};
4140

@@ -111,7 +110,11 @@ export const ArtifactAttestation = ({ attestation }: { attestation: AttestationV
111110
onOpenChange={setActionsOpened}
112111
>
113112
<DropdownList>
114-
<DropdownItem key="download bundle" isDisabled>
113+
<DropdownItem
114+
key="download bundle"
115+
onClick={() => handleDownloadBundle(attestation)}
116+
isDisabled={!attestation.rawBundleJson}
117+
>
115118
Download Bundle
116119
</DropdownItem>
117120
</DropdownList>

client/src/app/utils/utils.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import type {
77
ParsedCertificate,
88
SignatureIdentity,
99
SignatureView,
10+
AttestationView,
1011
} from "@app/queries/artifacts.view-model";
1112

1213
// minimal shape required for eslint, uses only we actually need
@@ -180,24 +181,21 @@ export const getRekorSetBytes = (signedEntryTimestamp?: string): Uint8Array | un
180181
}
181182
};
182183

183-
export const handleDownloadBundle = (signature: SignatureView) => {
184-
if (!signature.rawBundleJson) {
184+
export const handleDownloadBundle = (source: SignatureView | AttestationView): void => {
185+
if (!source.rawBundleJson) {
185186
return;
186187
}
187188

188189
const bundleString =
189-
typeof signature.rawBundleJson === "string"
190-
? signature.rawBundleJson
191-
: JSON.stringify(signature.rawBundleJson, null, 2);
192-
193-
const blob = new Blob([bundleString], {
194-
type: "application/json",
195-
});
190+
typeof source.rawBundleJson === "string" ? source.rawBundleJson : JSON.stringify(source.rawBundleJson, null, 2);
196191

192+
const blob = new Blob([bundleString], { type: "application/json" });
197193
const url = URL.createObjectURL(blob);
198194

199195
const link = document.createElement("a");
200-
const hashPrefix = signature.hash.value.slice(0, 12);
196+
const hashValue = "hash" in source ? source.hash.value : source.digest.value;
197+
const hashPrefix = hashValue.slice(0, 12);
198+
201199
link.download = `sigstore-bundle-${hashPrefix}.json`;
202200
link.href = url;
203201
document.body.appendChild(link);

package-lock.json

Lines changed: 0 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)