11"use strict" ;
2+ var __createBinding = ( this && this . __createBinding ) || ( Object . create ? ( function ( o , m , k , k2 ) {
3+ if ( k2 === undefined ) k2 = k ;
4+ var desc = Object . getOwnPropertyDescriptor ( m , k ) ;
5+ if ( ! desc || ( "get" in desc ? ! m . __esModule : desc . writable || desc . configurable ) ) {
6+ desc = { enumerable : true , get : function ( ) { return m [ k ] ; } } ;
7+ }
8+ Object . defineProperty ( o , k2 , desc ) ;
9+ } ) : ( function ( o , m , k , k2 ) {
10+ if ( k2 === undefined ) k2 = k ;
11+ o [ k2 ] = m [ k ] ;
12+ } ) ) ;
13+ var __setModuleDefault = ( this && this . __setModuleDefault ) || ( Object . create ? ( function ( o , v ) {
14+ Object . defineProperty ( o , "default" , { enumerable : true , value : v } ) ;
15+ } ) : function ( o , v ) {
16+ o [ "default" ] = v ;
17+ } ) ;
18+ var __importStar = ( this && this . __importStar ) || function ( mod ) {
19+ if ( mod && mod . __esModule ) return mod ;
20+ var result = { } ;
21+ if ( mod != null ) for ( var k in mod ) if ( k !== "default" && Object . prototype . hasOwnProperty . call ( mod , k ) ) __createBinding ( result , mod , k ) ;
22+ __setModuleDefault ( result , mod ) ;
23+ return result ;
24+ } ;
225Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
326exports . Signer = void 0 ;
27+ const sigstore = __importStar ( require ( "./types/sigstore" ) ) ;
428const util_1 = require ( "./util" ) ;
529class Signer {
630 constructor ( options ) {
731 this . identityProviders = [ ] ;
832 this . ca = options . ca ;
933 this . tlog = options . tlog ;
34+ this . tsa = options . tsa ;
1035 this . identityProviders = options . identityProviders ;
36+ this . tlogUpload = options . tlogUpload ?? true ;
1137 this . signer = options . signer || this . signWithEphemeralKey . bind ( this ) ;
1238 }
1339 async signBlob ( payload ) {
1440 // Get signature and verification material for payload
1541 const sigMaterial = await this . signer ( payload ) ;
1642 // Calculate artifact digest
1743 const digest = util_1 . crypto . hash ( payload ) ;
18- // Create Rekor entry
19- return this . tlog . createMessageSignatureEntry ( digest , sigMaterial ) ;
44+ // Create a Rekor entry (if tlogUpload is enabled)
45+ const entry = this . tlogUpload
46+ ? await this . tlog . createMessageSignatureEntry ( digest , sigMaterial )
47+ : undefined ;
48+ return sigstore . toMessageSignatureBundle ( {
49+ digest,
50+ signature : sigMaterial ,
51+ tlogEntry : entry ,
52+ timestamp : this . tsa
53+ ? await this . tsa . createTimestamp ( sigMaterial . signature )
54+ : undefined ,
55+ } ) ;
2056 }
2157 async signAttestation ( payload , payloadType ) {
2258 // Pre-authentication encoding to be signed
@@ -33,7 +69,18 @@ class Signer {
3369 } ,
3470 ] ,
3571 } ;
36- return this . tlog . createDSSEEntry ( envelope , sigMaterial ) ;
72+ // Create a Rekor entry (if tlogUpload is enabled)
73+ const entry = this . tlogUpload
74+ ? await this . tlog . createDSSEEntry ( envelope , sigMaterial )
75+ : undefined ;
76+ return sigstore . toDSSEBundle ( {
77+ envelope,
78+ signature : sigMaterial ,
79+ tlogEntry : entry ,
80+ timestamp : this . tsa
81+ ? await this . tsa . createTimestamp ( sigMaterial . signature )
82+ : undefined ,
83+ } ) ;
3784 }
3885 async signWithEphemeralKey ( payload ) {
3986 // Create emphemeral key pair
0 commit comments