Skip to content

Commit 837aeb7

Browse files
authored
Merge pull request #907 from zgroza/main
Do not treat cborg as external in cjs build
2 parents 352e9f1 + f96169f commit 837aeb7

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

js/sign/package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/sign/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "wbn-sign",
3-
"version": "0.2.3",
3+
"version": "0.2.4",
44
"description": "Signing tool to sign a web bundle with integrity block",
55
"homepage": "https://github.com/WICG/webpackage/tree/main/js/sign",
66
"main": "./lib/wbn-sign.cjs",
@@ -13,7 +13,7 @@
1313
"scripts": {
1414
"build": "npm run build:esm && npm run build:cjs",
1515
"build:esm": "tsc",
16-
"build:cjs": "esbuild --bundle --format=cjs --external:cborg --outfile=lib/wbn-sign.cjs src/wbn-sign.ts --platform=node",
16+
"build:cjs": "esbuild --bundle --format=cjs --outfile=lib/wbn-sign.cjs src/wbn-sign.ts --platform=node",
1717
"test": "jasmine tests/*.js tests/*.cjs",
1818
"lint": "npx prettier --write . --ignore-unknown --config ./package.json"
1919
},
@@ -40,7 +40,7 @@
4040
"license": "W3C-20150513",
4141
"dependencies": {
4242
"base32-encode": "^2.0.0",
43-
"cborg": "^4.0.0",
43+
"cborg": "^4.2.14",
4444
"commander": "^7.0.0",
4545
"read": "^2.0.0"
4646
},

js/sign/src/signers/integrity-block-signer.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import crypto, { KeyObject } from 'crypto';
2-
import * as cborg from 'cborg';
2+
import { encode } from 'cborg';
33
import { INTEGRITY_BLOCK_MAGIC, VERSION_B2 } from '../utils/constants.js';
44
import { checkDeterministic } from '../cbor/deterministic.js';
55
import {
@@ -40,7 +40,7 @@ export class IntegrityBlockSigner {
4040
};
4141

4242
const ibCbor = integrityBlock.toCBOR();
43-
const attrCbor = cborg.encode(newAttributes);
43+
const attrCbor = encode(newAttributes);
4444
checkDeterministic(ibCbor);
4545
checkDeterministic(attrCbor);
4646

@@ -175,7 +175,7 @@ export class IntegrityBlock {
175175
}
176176

177177
toCBOR(): Uint8Array {
178-
return cborg.encode([
178+
return encode([
179179
INTEGRITY_BLOCK_MAGIC,
180180
VERSION_B2,
181181
this.attributes,

js/sign/src/wbn-sign.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ export {
44
IntegrityBlock,
55
IntegrityBlockSigner,
66
} from './signers/integrity-block-signer.js';
7-
export { WebBundleId } from './web-bundle-id.js';
7+
export { WebBundleId, getBundleId } from './web-bundle-id.js';
88
export { parsePemKey, readPassphrase, getRawPublicKey } from './utils/utils.js';

js/sign/src/web-bundle-id.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
getSignatureType,
77
} from './utils/utils.js';
88
import { SignatureType } from './utils/constants.js';
9-
import * as cborg from 'cborg';
9+
import { decodeFirst } from 'cborg';
1010

1111
// Web Bundle ID is a base32-encoded (without padding) ed25519 public key
1212
// transformed to lowercase. More information:
@@ -58,7 +58,7 @@ export class WebBundleId {
5858

5959
export function getBundleId(signedWebBundle: Uint8Array) {
6060
try {
61-
const decodedData = cborg.decodeFirst(signedWebBundle);
61+
const decodedData = decodeFirst(signedWebBundle);
6262

6363
if (!decodedData[0] || !decodedData[0][2]) {
6464
throw Error('Signed Web Bundle structure is invalid');

0 commit comments

Comments
 (0)