Skip to content

Commit

Permalink
feat: Optional strict verification
Browse files Browse the repository at this point in the history
Changed the default of failing on unsigned packages,
as most packages won't be signed anyway.

Users can opt-in to a stricter check if they expect the
package to be signed.
  • Loading branch information
franky47 committed Dec 13, 2022
1 parent 120ebc7 commit 7aeb7f4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/cli/args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const verifyCommandSchema = z.object({
packageDir: z.string().optional(),
publicKey: hexStringSchema(32).optional(),
file: z.string().optional().default(SCEAU_FILE_NAME),
strict: z.boolean().optional().default(false),
})

export type VerifyCommandArgs = z.infer<typeof verifyCommandSchema>
Expand Down Expand Up @@ -92,6 +93,7 @@ ${chalk.green('##')} ${chalk.bold('sceau verify')}
--packageDir [path] Path to the package to process (default: \`cwd\`)
--file [path] Path to the sceau file (default: \`sceau.json\`)
--publicKey [key] env: SCEAU_PUBLIC_KEY Signature public key to use for verification (defaults to using the embedded one)
--strict Fail if package is not signed
`)
process.exit(1)
}
Expand Down
7 changes: 6 additions & 1 deletion src/cli/commands/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ export async function verifyCommand(args: VerifyCommandArgs) {
const sceauFilePath = path.resolve(packageDir, args.file)
await fs.stat(sceauFilePath).catch(error => {
if (error.code === 'ENOENT') {
throw new Error('This package is not signed')
const message = 'This package is not signed'
if (args.strict) {
throw new Error(chalk.red(message))
}
console.info(message)
process.exit(0)
}
throw error
})
Expand Down

0 comments on commit 7aeb7f4

Please sign in to comment.