Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set v2 format of integrity block as default #896

Merged
merged 2 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 <laurila@google.com> (https://github.com/sonkkeli)",
"contributors": [
"Christian Flach <cmfcmf@google.com> (https://github.com/cmfcmf)",
"Andrew Rayskiy <greengrape@google.com> (https://github.com/GrapeGreen)"
"Andrew Rayskiy <greengrape@google.com> (https://github.com/GrapeGreen)",
"Luke (Zgroza) Klimek <zgroza@google.com> (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
Loading