Debian Codegraph @

node_modules/@sigstore/verify/dist/bundle/index.js

raw
1 "use strict";
2 Object.defineProperty(exports, "__esModule", { value: true });
3 exports.toSignedEntity = toSignedEntity;
4 exports.signatureContent = signatureContent;
5 const core_1 = require("@sigstore/core");
6 const dsse_1 = require("./dsse");
7 const message_1 = require("./message");
8 function toSignedEntity(bundle, artifact) {
9 const { tlogEntries, timestampVerificationData } = bundle.verificationMaterial;
10 const timestamps = [];
11 for (const entry of tlogEntries) {
12 if (entry.integratedTime && entry.integratedTime !== '0') {
13 timestamps.push({
14 $case: 'transparency-log',
15 tlogEntry: entry,
16 });
17 }
18 }
19 for (const ts of timestampVerificationData?.rfc3161Timestamps ?? []) {
20 timestamps.push({
21 $case: 'timestamp-authority',
22 timestamp: core_1.RFC3161Timestamp.parse(Buffer.from(ts.signedTimestamp)),
23 });
24 }
25 return {
26 signature: signatureContent(bundle, artifact),
27 key: key(bundle),
28 tlogEntries,
29 timestamps,
30 };
31 }
32 function signatureContent(bundle, artifact) {
33 switch (bundle.content.$case) {
34 case 'dsseEnvelope':
35 return new dsse_1.DSSESignatureContent(bundle.content.dsseEnvelope);
36 case 'messageSignature':
37 return new message_1.MessageSignatureContent(bundle.content.messageSignature, artifact);
38 }
39 }
40 function key(bundle) {
41 switch (bundle.verificationMaterial.content.$case) {
42 case 'publicKey':
43 return {
44 $case: 'public-key',
45 hint: bundle.verificationMaterial.content.publicKey.hint,
46 };
47 case 'x509CertificateChain':
48 return {
49 $case: 'certificate',
50 certificate: core_1.X509Certificate.parse(Buffer.from(bundle.verificationMaterial.content.x509CertificateChain
51 .certificates[0].rawBytes)),
52 };
53 case 'certificate':
54 return {
55 $case: 'certificate',
56 certificate: core_1.X509Certificate.parse(Buffer.from(bundle.verificationMaterial.content.certificate.rawBytes)),
57 };
58 }
59 }