Skip to content

Commit 7d2ac98

Browse files
authored
fix build error in job launcher server (#2590)
1 parent 0c6f11e commit 7d2ac98

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

packages/apps/job-launcher/server/src/common/constants/errors.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,10 @@ export enum ErrorQualification {
171171
FailedToFetchQualifications = 'Failed to fetch qualifications',
172172
InvalidQualification = `Invalid qualification`,
173173
}
174+
175+
/**
176+
* Represents error messages associated with encryption.
177+
*/
178+
export enum ErrorEncryption {
179+
MissingPrivateKey = 'Encryption private key cannot be empty, when it is enabled',
180+
}

packages/apps/job-launcher/server/src/modules/encryption/encryption.module.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,20 @@ import { Module, Global, Provider } from '@nestjs/common';
22
import { Encryption } from '@human-protocol/sdk';
33
import { ConfigModule } from '@nestjs/config';
44
import { PGPConfigService } from '../../common/config/pgp-config.service';
5+
import { ErrorEncryption } from '../../common/constants/errors';
56

67
const encryptionProvider: Provider = {
78
provide: Encryption,
89
useFactory: async (pgpConfigService: PGPConfigService) => {
9-
if (!pgpConfigService.encrypt) {
10+
if (!pgpConfigService.encrypt && !pgpConfigService.privateKey) {
1011
return null;
1112
}
1213
const privateKey = pgpConfigService.privateKey;
1314
const passPhrase = pgpConfigService.passphrase;
14-
return await Encryption.build(privateKey, passPhrase);
15+
16+
if (privateKey) return await Encryption.build(privateKey, passPhrase);
17+
18+
throw new Error(ErrorEncryption.MissingPrivateKey);
1519
},
1620
inject: [PGPConfigService],
1721
};

0 commit comments

Comments
 (0)