MCPcopy Create free account
hub / github.com/WICG/webpackage / parseArguments

Function parseArguments

js/sign/src/cli-sign.ts:90–393  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

88 .helpOption('-h, --help', 'Display help');
89
90async function parseArguments(): Promise<void> {
91 program.commandsGroup('General commands');
92 program.helpCommand('help [command]', 'Display help for command');
93
94 program
95 .command('info')
96 .summary('Display integrity block information for a signed web bundle.')
97 .description(
98 'Display integrity block information for a signed web bundle, including the Web Bundle ID and signatures. \n\n' +
99 'WARNING: Experimental. The output format is subject to change. Do not use in scripts or automation.'
100 )
101 .argument('<web_bundle>', 'Path to a signed web bundle `*.swbn`')
102 .action(async (webBundlePath) => {
103 const webBundle = await fs.promises.readFile(webBundlePath);
104 const signedWebBundle = SignedWebBundle.fromBytes(webBundle);
105
106 signedWebBundle.printInfo();
107
108 const validations = signedWebBundle.validateSignatures();
109 validations.forEach((val, i) => {
110 if (val.status === 'error') {
111 console.log(pc.red(`Signature ${i} validation failed: ${val.error}`));
112 } else {
113 console.log(
114 `Signature ${i} derived Web Bundle ID: ${val.derivedBundleId}`
115 );
116 console.log(
117 `Signature ${i} is correct: ${
118 val.isValid ? pc.green('Yes') : pc.red('No')
119 }`
120 );
121 }
122 });
123 });
124
125 program.commandsGroup('Signature management commands');
126 program
127 .command('add-signature')
128 .summary('Add signatures to an existing signed web bundle.')
129 .description(
130 'Add one or more signatures to the integrity block of a signed web bundle. ' +
131 'This updates the bundle’s metadata with new signatures without altering ' +
132 'the bundled resources.\n\n' +
133 'For encrypted keys, you will be prompted for a password unless the ' +
134 'WEB_BUNDLE_SIGNING_PASSPHRASE environment variable is set.'
135 )
136 .argument('<signed_web_bundle>', 'Path to a signed web bundle (*.swbn).')
137 .argument(
138 '<private_keys...>',
139 '*.pem files containing ecdsaP256 or ed25519 private keys.'
140 )
141 .option(
142 '-i, --in-place',
143 'Overwrite the input file with the new signatures. Incompatible with --output.',
144 false
145 )
146 .option(
147 '-o, --output <file>',

Callers 1

mainFunction · 0.85

Calls 14

greenConsoleLogFunction · 0.90
infoLogFunction · 0.90
warnLogFunction · 0.90
errorLogFunction · 0.90
getOutputPathFunction · 0.85
parseRemovalKeyFunction · 0.85
fromBytesMethod · 0.80
validateSignaturesMethod · 0.80
addSignatureMethod · 0.80

Tested by

no test coverage detected