Skip to content

Commit

Permalink
Bump prettier from 2.8.8 to 3.0.0 (#350)
Browse files Browse the repository at this point in the history
  • Loading branch information
dependabot[bot] authored Jul 18, 2023
1 parent 84b54d5 commit 2ee069d
Show file tree
Hide file tree
Showing 47 changed files with 380 additions and 367 deletions.
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"eslint-config-prettier": "^8.8.0",
"mocha": "^10.2.0",
"npm-upgrade": "^3.1.0",
"prettier": "^2.8.8",
"prettier": "^3.0.0",
"ts-node": "^10.9.1",
"tsconfig-paths": "^4.2.0",
"typedoc": "^0.24.8",
Expand Down
40 changes: 20 additions & 20 deletions packages/common/src/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,22 @@ describe("common", () => {
it("has some expected values", () => {
assert.deepEqual(
[...integerToOctetStringLE(BigInt(256), 5)],
[0, 1, 0, 0, 0]
[0, 1, 0, 0, 0],
);

assert.deepEqual(
[...integerToOctetStringLE(BigInt(255), 5)],
[255, 0, 0, 0, 0]
[255, 0, 0, 0, 0],
);

assert.deepEqual(
[
...integerToOctetStringLE(
BigInt(Number.MAX_SAFE_INTEGER) + BigInt(1),
10
10,
),
],
[0, 0, 0, 0, 0, 0, 32, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 32, 0, 0, 0],
);
});

Expand All @@ -49,11 +49,11 @@ describe("common", () => {

for (const octetString of arr(
numbers,
() => new Uint8Array(arr(bytes, () => Math.floor(Math.random() * 255)))
() => new Uint8Array(arr(bytes, () => Math.floor(Math.random() * 255))),
)) {
assert.deepEqual(
octetString,
integerToOctetStringLE(octetStringToIntegerLE(octetString), bytes)
integerToOctetStringLE(octetStringToIntegerLE(octetString), bytes),
);
}
});
Expand All @@ -63,21 +63,21 @@ describe("common", () => {
it("has some expected values", () => {
assert.equal(
BigInt(256),
octetStringToIntegerLE(new Uint8Array([0, 1, 0]))
octetStringToIntegerLE(new Uint8Array([0, 1, 0])),
);
assert.equal(
BigInt(255),
octetStringToIntegerLE(new Uint8Array([255, 0, 0, 0]))
octetStringToIntegerLE(new Uint8Array([255, 0, 0, 0])),
);

assert.equal(
BigInt(256) ** BigInt(3),
octetStringToIntegerLE(new Uint8Array([0, 0, 0, 1, 0]))
octetStringToIntegerLE(new Uint8Array([0, 0, 0, 1, 0])),
);

assert.equal(
BigInt(Number.MAX_SAFE_INTEGER) + BigInt(1),
octetStringToIntegerLE(new Uint8Array([0, 0, 0, 0, 0, 0, 32, 0, 0, 0]))
octetStringToIntegerLE(new Uint8Array([0, 0, 0, 0, 0, 0, 32, 0, 0, 0])),
);
});
});
Expand All @@ -92,22 +92,22 @@ describe("common", () => {
it("has some expected values", () => {
assert.deepEqual(
[...integerToOctetStringBE(BigInt(256), 5)],
[0, 0, 0, 1, 0]
[0, 0, 0, 1, 0],
);

assert.deepEqual(
[...integerToOctetStringBE(BigInt(255), 5)],
[0, 0, 0, 0, 255]
[0, 0, 0, 0, 255],
);

assert.deepEqual(
[
...integerToOctetStringBE(
BigInt(Number.MAX_SAFE_INTEGER) + BigInt(1),
10
10,
),
],
[0, 0, 0, 32, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 32, 0, 0, 0, 0, 0, 0],
);
});

Expand All @@ -117,11 +117,11 @@ describe("common", () => {

for (const octetString of arr(
numbers,
() => new Uint8Array(arr(bytes, () => Math.floor(Math.random() * 255)))
() => new Uint8Array(arr(bytes, () => Math.floor(Math.random() * 255))),
)) {
assert.deepEqual(
octetString,
integerToOctetStringBE(octetStringToIntegerBE(octetString), bytes)
integerToOctetStringBE(octetStringToIntegerBE(octetString), bytes),
);
}
});
Expand All @@ -131,21 +131,21 @@ describe("common", () => {
it("has some expected values", () => {
assert.equal(
BigInt(256),
octetStringToIntegerBE(new Uint8Array([0, 1, 0]))
octetStringToIntegerBE(new Uint8Array([0, 1, 0])),
);
assert.equal(
BigInt(255),
octetStringToIntegerBE(new Uint8Array([0, 0, 0, 255]))
octetStringToIntegerBE(new Uint8Array([0, 0, 0, 255])),
);

assert.equal(
BigInt(256) ** BigInt(3),
octetStringToIntegerBE(new Uint8Array([0, 1, 0, 0, 0]))
octetStringToIntegerBE(new Uint8Array([0, 1, 0, 0, 0])),
);

assert.equal(
BigInt(Number.MAX_SAFE_INTEGER) + BigInt(1),
octetStringToIntegerBE(new Uint8Array([0, 0, 0, 32, 0, 0, 0, 0, 0, 0]))
octetStringToIntegerBE(new Uint8Array([0, 0, 0, 32, 0, 0, 0, 0, 0, 0])),
);
});
});
Expand Down
8 changes: 4 additions & 4 deletions packages/common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export function integerToOctetStringBE(i: bigint, len: number): Uint8Array {
const max = 256n ** BigInt(len);
if (i >= max) {
throw new Error(
`Integer ${i} too large for ${len} byte array (max ${max}).`
`Integer ${i} too large for ${len} byte array (max ${max}).`,
);
}
const octets = new Uint8Array(len);
Expand All @@ -21,7 +21,7 @@ export function integerToOctetStringLE(i: bigint, len: number): Uint8Array {
const max = 256n ** BigInt(len);
if (i >= max) {
throw new Error(
`Integer ${i} too large for ${len} byte array (max ${max}).`
`Integer ${i} too large for ${len} byte array (max ${max}).`,
);
}
const octets = new Uint8Array(len);
Expand All @@ -37,15 +37,15 @@ export function octetStringToIntegerBE(octetString: Uint8Array): bigint {
return octetString.reduceRight(
(total, value, index) =>
total + 256n ** BigInt(octetString.length - index - 1) * BigInt(value),
0n
0n,
);
}

/** @internal */
export function octetStringToIntegerLE(octetString: Uint8Array): bigint {
return octetString.reduce(
(total, value, index) => total + 256n ** BigInt(index) * BigInt(value),
0n
0n,
);
}

Expand Down
16 changes: 8 additions & 8 deletions packages/dap/src/aggregator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe("DAP Aggregator", () => {
it("should append a trailing slash on construction from a string", () => {
const aggregator = new Aggregator(
"http://example.com/aggregator",
Role.Leader
Role.Leader,
);

assert.equal(aggregator.url.toString(), "http://example.com/aggregator/");
Expand All @@ -25,7 +25,7 @@ describe("DAP Aggregator", () => {
it("should append a trailing slash on construction from a URL", () => {
const aggregator = new Aggregator(
new URL("http://example.com/aggregator"),
Role.Leader
Role.Leader,
);

assert.equal(aggregator.url.toString(), "http://example.com/aggregator/");
Expand All @@ -34,14 +34,14 @@ describe("DAP Aggregator", () => {
it("has a convenience method to build helper aggregator", () => {
assert.deepEqual(
Aggregator.helper("http://example.com"),
new Aggregator("http://example.com", Role.Helper)
new Aggregator("http://example.com", Role.Helper),
);
});

it("has a convenience method to build leader aggregator", () => {
assert.deepEqual(
Aggregator.leader("http://example.com"),
new Aggregator("http://example.com", Role.Leader)
new Aggregator("http://example.com", Role.Leader),
);
});

Expand All @@ -54,15 +54,15 @@ describe("DAP Aggregator", () => {
kem,
Kdf.Sha256,
Aead.AesGcm128,
Buffer.from(public_key)
Buffer.from(public_key),
);

aggregator.hpkeConfigList = new HpkeConfigList([hpkeConfig]);
const inputShare = new PlaintextInputShare([], Buffer.from("payload"));
const aad = new InputShareAad(
TaskId.random(),
new ReportMetadata(ReportId.random(), Date.now() / 1000),
Buffer.alloc(0)
Buffer.alloc(0),
);
const cipherText = aggregator.seal(inputShare, aad);

Expand All @@ -73,7 +73,7 @@ describe("DAP Aggregator", () => {
cipherText.encapsulatedContext,
new InputShareInfo(Role.Leader).encode(),
cipherText.payload,
aad.encode()
aad.encode(),
);

assert.deepEqual(Buffer.from(open), inputShare.encode());
Expand All @@ -85,7 +85,7 @@ describe("DAP Aggregator", () => {
const aad = new InputShareAad(
TaskId.random(),
new ReportMetadata(ReportId.random(), Date.now() / 1000),
Buffer.alloc(0)
Buffer.alloc(0),
);

assert.throws(() => aggregator.seal(inputShare, aad));
Expand Down
6 changes: 3 additions & 3 deletions packages/dap/src/aggregator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export class Aggregator {
constructor(
url: URL | string,
public role: Role,
public hpkeConfigList?: HpkeConfigList
public hpkeConfigList?: HpkeConfigList,
) {
this.url = new URL(url);
if (!this.url.pathname.endsWith("/")) {
Expand All @@ -27,15 +27,15 @@ export class Aggregator {
seal(inputShare: PlaintextInputShare, aad: InputShareAad): HpkeCiphertext {
if (!this.hpkeConfigList) {
throw new Error(
"Attempted to call Aggregator#seal before fetching a hpkeConfigList."
"Attempted to call Aggregator#seal before fetching a hpkeConfigList.",
);
}
return this.hpkeConfigList
.selectConfig()
.seal(
new InputShareInfo(this.role).encode(),
inputShare.encode(),
aad.encode()
aad.encode(),
);
}
}
4 changes: 2 additions & 2 deletions packages/dap/src/ciphertext.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe("DAP HpkeCiphertext", () => {
const ciphertext = new HpkeCiphertext(
100,
Buffer.alloc(5, 1),
Buffer.alloc(10, 255)
Buffer.alloc(10, 255),
);
assert.deepEqual(
ciphertext.encode(),
Expand All @@ -33,7 +33,7 @@ describe("DAP HpkeCiphertext", () => {
...[1, 1, 1, 1, 1], // encapcapsulated context
...[0, 0, 0, 10], // payload length
...[255, 255, 255, 255, 255, 255, 255, 255, 255, 255], //payload
])
]),
);
});
});
2 changes: 1 addition & 1 deletion packages/dap/src/ciphertext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export class HpkeCiphertext implements Encodable {
constructor(
public configId: number,
public encapsulatedContext: Buffer,
public payload: Buffer
public payload: Buffer,
) {
if (configId !== Math.floor(configId) || configId < 0 || configId > 255) {
throw new Error("configId must be a uint8 (< 256)");
Expand Down
Loading

0 comments on commit 2ee069d

Please sign in to comment.