@@ -87,40 +87,62 @@ export class GpgWrapper {
8787 }
8888
8989 public async encryptFile ( { inputPath, outputPath, recipient, signer, signerPassphrase } : EncryptFileInput ) : Promise < EncryptFileResult > {
90+ // TODO: move this into the constructor?
91+ try {
92+ log ( `[DEBUG] Checking GPG binary at path: '${ this . binPath } '` ) ;
93+ await access ( this . binPath , constants . X_OK ) ;
94+ log ( `[DEBUG] GPG binary is executable.` ) ;
95+ }
96+ catch {
97+ log ( `[ERROR] GPG binary not found or not executable at path: '${ this . binPath } '` ) ;
98+ return { success : false , error : `GPG binary not found or not executable at path: '${ this . binPath } '` , code : GpgErrorCode . GPG_NOT_FOUND }
99+ }
90100
91101 // check read permissions on input
92- try { await access ( inputPath , constants . R_OK ) }
102+ try {
103+ log ( `[DEBUG] Checking read access for input file at path: '${ inputPath } '` ) ;
104+ await access ( inputPath , constants . R_OK ) ;
105+ log ( `[DEBUG] Read access confirmed for input file.` ) ;
106+ }
93107 catch {
94108 log ( `[ERROR] Unable to read input file, insufficient permissions for path: '${ inputPath } '` ) ;
95109 return { success : false , error : `Unable to read input file: '${ inputPath } '` , code : "INPUT_NOT_READABLE" }
96110 }
97111
98112 // check write permissions on output
99113 const outputDir = dirname ( outputPath ) ;
100- try { await access ( outputDir , constants . W_OK ) }
114+ try {
115+ log ( `[DEBUG] Checking write access for output directory at path: '${ outputDir } '` ) ;
116+ await access ( outputDir , constants . W_OK ) ;
117+ log ( `[DEBUG] Write access confirmed for output directory.` ) ;
118+ }
101119 catch {
102120 log ( `[ERROR] Unable to write to output directory, insufficient permissions for path: '${ outputDir } '` ) ;
103121 return { success : false , error : `Unable to write to output path: '${ outputPath } '` , code : "OUTPUT_NOT_WRITABLE" }
104122 }
105123
106124 // check recipient key is in keyring and valid
107125 if ( this . options . verifyRecipientKey ) {
126+ log ( `[DEBUG] Verifying recipient key exists in keyring: '${ recipient } '` ) ;
108127 const okay = this . keyExists ( recipient , "RECIPIENT" ) ;
109128 if ( ! okay ) {
110129 const msg = `Recipient key not found in local keyring: '${ recipient } '` ;
111130 log ( `[ERROR] ${ msg } ` ) ;
112131 return { success : false , error : msg , code : GpgErrorCode . RECIPIENT_KEY_NOT_FOUND }
113132 }
133+ log ( `[DEBUG] Recipient key exists in keyring.` ) ;
114134 }
115135
116136 // check signer key is in the keyring and valid
117137 if ( signer && this . options . verifySignerKey ) {
138+ log ( `[DEBUG] Verifying signer secret key exists in keyring: '${ signer } '` ) ;
118139 const okay = this . keyExists ( signer , "SIGNER" ) ;
119140 if ( ! okay ) {
120141 const msg = `Signer secret key not found in local keyring: '${ signer } '`
121142 log ( `[ERROR] ${ msg } ` ) ;
122143 return { success : false , error : msg , code : GpgErrorCode . SIGNER_KEY_NOT_FOUND }
123144 }
145+ log ( `[DEBUG] Signer secret key exists in keyring.` ) ;
124146 }
125147
126148 // https://www.gnupg.org/documentation/manuals/gnupg/GPG-Configuration-Options.html
@@ -156,7 +178,7 @@ export class GpgWrapper {
156178 const result = spawnSync ( this . binPath , finalArgs , {
157179 stdio : [ 'pipe' , 'pipe' , 'pipe' ] ,
158180 env : { ...process . env } ,
159- timeout : this . options . timeoutMs ?? 30_000 ,
181+ timeout : this . options . timeoutMs ?? 60_000 ,
160182 encoding : "utf-8" ,
161183 input : inputData
162184 } ) ;
0 commit comments