Skip to content

Commit

Permalink
refactor: shared code uses shared messages
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Dec 6, 2023
1 parent 71cb002 commit 9c33c62
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion messages/verify.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The registry name. The behavior is the same as npm.

# NotSigned

The plugin is not digitally signed.
The plugin isn't digitally signed.

# SignatureCheckSuccess

Expand Down
11 changes: 5 additions & 6 deletions src/shared/installationVerification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -446,8 +446,10 @@ export async function doInstallationCodeSigningVerification(
plugin: { plugin: string; tag: string },
verificationConfig: VerificationConfig
): Promise<void> {
const messages = Messages.loadMessages('@salesforce/plugin-trust', 'verify');

if (await verificationConfig.verifier?.isAllowListed()) {
verificationConfig.log(`The plugin [${plugin.plugin}] is allow-listed, skipping digital signature verification.`);
verificationConfig.log(messages.getMessage('SkipSignatureCheck', [plugin.plugin]));
return;
}
try {
Expand All @@ -456,13 +458,10 @@ export async function doInstallationCodeSigningVerification(
}
const meta = await verificationConfig.verifier.verify();
if (!meta.verified) {
const err = new SfError(
"A digital signature is specified for this plugin but it didn't verify against the certificate.",
'FailedDigitalSignatureVerification'
);
const err = messages.createError('FailedDigitalSignatureVerification');
throw setErrorName(err, 'FailedDigitalSignatureVerification');
}
verificationConfig.log(`Successfully validated digital signature for ${plugin.plugin}.`);
verificationConfig.log(messages.getMessage('SignatureCheckSuccess', [plugin.plugin]));
} catch (err) {
if (err instanceof Error) {
if (err.name === 'NotSigned' || err.message?.includes('Response code 403')) {
Expand Down

0 comments on commit 9c33c62

Please sign in to comment.