diff --git a/js/sign/README.md b/js/sign/README.md index 325f849e..3da28ecb 100644 --- a/js/sign/README.md +++ b/js/sign/README.md @@ -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 diff --git a/js/sign/package.json b/js/sign/package.json index 71550f5d..5ae0feaa 100644 --- a/js/sign/package.json +++ b/js/sign/package.json @@ -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", @@ -34,7 +34,8 @@ "author": "Sonja Laurila (https://github.com/sonkkeli)", "contributors": [ "Christian Flach (https://github.com/cmfcmf)", - "Andrew Rayskiy (https://github.com/GrapeGreen)" + "Andrew Rayskiy (https://github.com/GrapeGreen)", + "Luke (Zgroza) Klimek (https://github.com/zgroza)" ], "license": "W3C-20150513", "dependencies": { diff --git a/js/sign/src/cli-sign.ts b/js/sign/src/cli-sign.ts index a47e06dc..8c06b8e2 100644 --- a/js/sign/src/cli-sign.ts +++ b/js/sign/src/cli-sign.ts @@ -20,7 +20,7 @@ const program = new Command() function readOptions() { return program .addOption( - new Option('--version ').choices(['v1', 'v2']).default('v1') + new Option('--version ').choices(['v1', 'v2']).default('v2') ) .requiredOption( '-i, --input ', @@ -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}`); diff --git a/js/sign/src/signers/integrity-block-signer.ts b/js/sign/src/signers/integrity-block-signer.ts index 917b9524..55e95cb6 100644 --- a/js/sign/src/signers/integrity-block-signer.ts +++ b/js/sign/src/signers/integrity-block-signer.ts @@ -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 + private readonly signingStrategies: Array, + private readonly is_v2: boolean = true ) {} async sign(): Promise<{ diff --git a/js/sign/tests/integrity-block-signer_test.js b/js/sign/tests/integrity-block-signer_test.js index 91ff13dc..8e030431 100644 --- a/js/sign/tests/integrity-block-signer_test.js +++ b/js/sign/tests/integrity-block-signer_test.js @@ -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; }