1
1
"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
+ } ;
2
25
Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
3
26
exports . Signer = void 0 ;
27
+ const sigstore = __importStar ( require ( "./types/sigstore" ) ) ;
4
28
const util_1 = require ( "./util" ) ;
5
29
class Signer {
6
30
constructor ( options ) {
7
31
this . identityProviders = [ ] ;
8
32
this . ca = options . ca ;
9
33
this . tlog = options . tlog ;
34
+ this . tsa = options . tsa ;
10
35
this . identityProviders = options . identityProviders ;
36
+ this . tlogUpload = options . tlogUpload ?? true ;
11
37
this . signer = options . signer || this . signWithEphemeralKey . bind ( this ) ;
12
38
}
13
39
async signBlob ( payload ) {
14
40
// Get signature and verification material for payload
15
41
const sigMaterial = await this . signer ( payload ) ;
16
42
// Calculate artifact digest
17
43
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
+ } ) ;
20
56
}
21
57
async signAttestation ( payload , payloadType ) {
22
58
// Pre-authentication encoding to be signed
@@ -33,7 +69,18 @@ class Signer {
33
69
} ,
34
70
] ,
35
71
} ;
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
+ } ) ;
37
84
}
38
85
async signWithEphemeralKey ( payload ) {
39
86
// Create emphemeral key pair
0 commit comments