Skip to content

Commit

Permalink
Set v2 format of integrity block as default (#896)
Browse files Browse the repository at this point in the history
* Set v2 format of integrity block as default

* Added myself to contributors
  • Loading branch information
zgroza authored Aug 27, 2024
1 parent 343d8c5 commit a983ab3
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
7 changes: 7 additions & 0 deletions js/sign/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,13 @@ environment variable named `WEB_BUNDLE_SIGNING_PASSPHRASE`.

## Release Notes

### v0.2.1

- Moved is_v2 to the last and optional (defaulting to true) argument of
`IntegrityBlockSigner` constructor. This is a preparation for the future
removal of the deprecated v1 format.
- CLI signer defaults to v2 format of integrity block now.

### v0.2.0

- Add support for the v2 integrity block format. Now web-bundle-id is no longer
Expand Down
5 changes: 3 additions & 2 deletions js/sign/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wbn-sign",
"version": "0.2.0",
"version": "0.2.1",
"description": "Signing tool to sign a web bundle with integrity block",
"homepage": "https://github.com/WICG/webpackage/tree/main/js/sign",
"main": "./lib/wbn-sign.cjs",
Expand Down Expand Up @@ -34,7 +34,8 @@
"author": "Sonja Laurila <[email protected]> (https://github.com/sonkkeli)",
"contributors": [
"Christian Flach <[email protected]> (https://github.com/cmfcmf)",
"Andrew Rayskiy <[email protected]> (https://github.com/GrapeGreen)"
"Andrew Rayskiy <[email protected]> (https://github.com/GrapeGreen)",
"Luke (Zgroza) Klimek <[email protected]> (https://github.com/zgroza)"
],
"license": "W3C-20150513",
"dependencies": {
Expand Down
6 changes: 3 additions & 3 deletions js/sign/src/cli-sign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const program = new Command()
function readOptions() {
return program
.addOption(
new Option('--version <version>').choices(['v1', 'v2']).default('v1')
new Option('--version <version>').choices(['v1', 'v2']).default('v2')
)
.requiredOption(
'-i, --input <file>',
Expand Down Expand Up @@ -80,10 +80,10 @@ export async function main() {
? options.webBundleId
: new WebBundleId(privateKeys[0]).serialize();
const signer = new IntegrityBlockSigner(
/*is_v2=*/ options.version === 'v2',
webBundle,
webBundleId,
privateKeys.map((privateKey) => new NodeCryptoSigningStrategy(privateKey))
privateKeys.map((privateKey) => new NodeCryptoSigningStrategy(privateKey)),
/*is_v2=*/ options.version === 'v2'
);
const { signedWebBundle } = await signer.sign();
greenConsoleLog(`${webBundleId}`);
Expand Down
4 changes: 2 additions & 2 deletions js/sign/src/signers/integrity-block-signer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ type IntegritySignature = {
export class IntegrityBlockSigner {
// `webBundleId` is ignored if `is_v2` is false.
constructor(
private readonly is_v2: boolean,
private readonly webBundle: Uint8Array,
private readonly webBundleId: string,
private readonly signingStrategies: Array<ISigningStrategy>
private readonly signingStrategies: Array<ISigningStrategy>,
private readonly is_v2: boolean = true
) {}

async sign(): Promise<{
Expand Down
4 changes: 2 additions & 2 deletions js/sign/tests/integrity-block-signer_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ describe('Integrity Block Signer', () => {
const file = path.resolve(__dirname, 'testdata/unsigned.wbn');
const contents = fs.readFileSync(file);
const signer = new wbnSign.IntegrityBlockSigner(
/*is_v2=*/ !!webBundleId,
contents,
/*webBundleId=*/ webBundleId,
privateKeys.map(
(privateKey) => new wbnSign.NodeCryptoSigningStrategy(privateKey)
)
),
/*is_v2=*/ !!webBundleId
);
return signer;
}
Expand Down

0 comments on commit a983ab3

Please sign in to comment.