Skip to content

Commit 164eebd

Browse files
authored
add verify-signature command. Fixes #1044 (#1045)
1 parent e646982 commit 164eebd

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/main.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import program from 'commander';
22
import leven from 'leven';
3-
import { packageCommand, ls, Targets, generateManifest } from './package';
3+
import { packageCommand, ls, Targets, generateManifest, verifySignature } from './package';
44
import { publish, unpublish } from './publish';
55
import { show } from './show';
66
import { search } from './search';
@@ -317,6 +317,14 @@ module.exports = function (argv: string[]): void {
317317
.option('-o, --out <path>', 'Output the extension manifest to <path> location (defaults to <packagename>.manifest)')
318318
.action(({ packagePath, out }) => main(generateManifest(packagePath, out)));
319319

320+
program
321+
.command('verify-signature')
322+
.description('Verifies the provided signature file against the provided VSIX package and manifest.')
323+
.requiredOption('-i, --packagePath <path>', 'Path to the VSIX package')
324+
.requiredOption('-m, --manifestPath <path>', 'Path to the Manifest file')
325+
.requiredOption('-s, --signaturePath <path>', 'Path to the Signature file')
326+
.action(({ packagePath, manifestPath, signaturePath }) => main(verifySignature(packagePath, manifestPath, signaturePath)));
327+
320328
program
321329
.command('ls-publishers')
322330
.description('Lists all known publishers')

src/package.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1885,6 +1885,19 @@ export function generateManifest(packageFile: string, outputFile?: string): Prom
18851885
return vsceSign.generateManifest(packageFile, outputFile);
18861886
}
18871887

1888+
export async function verifySignature(packageFile: string, manifestFile: string, signatureFile: string): Promise<void> {
1889+
const sigzipPath = await createSignatureArchive(manifestFile, signatureFile);
1890+
try {
1891+
const result = await vsceSign.verify(packageFile, sigzipPath, true);
1892+
console.log(`Signature verification result: ${result.code}`);
1893+
if (result.output) {
1894+
console.log(result.output)
1895+
}
1896+
} finally {
1897+
await fs.promises.unlink(sigzipPath);
1898+
}
1899+
}
1900+
18881901
// Create a signature zip file containing the manifest and signature file
18891902
export async function createSignatureArchive(manifestFile: string, signatureFile: string, outputFile?: string): Promise<string> {
18901903
return vsceSign.zip(manifestFile, signatureFile, outputFile)

0 commit comments

Comments
 (0)