Skip to content

Commit

Permalink
mk: upgrade to @yoursunny/xo-config 0.60.0
Browse files Browse the repository at this point in the history
  • Loading branch information
yoursunny committed Dec 12, 2024
1 parent 5ecd035 commit 9a6656a
Show file tree
Hide file tree
Showing 25 changed files with 62 additions and 71 deletions.
8 changes: 4 additions & 4 deletions integ/browser-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@
"devDependencies": {
"@nodelib/fs.walk": "^3.0.1",
"@types/webpack": "^5.28.5",
"@zenfs/core": "^1.6.7",
"@zenfs/dom": "^1.0.7",
"@zenfs/core": "^1.6.8",
"@zenfs/dom": "^1.1.0",
"fork-ts-checker-webpack-plugin": "^9.0.2",
"html-webpack-plugin": "^5.6.3",
"puppeteer": "^23.10.2",
"puppeteer": "^23.10.3",
"ts-loader": "^9.5.1",
"tslib": "^2.8.1",
"type-fest": "^4.30.0",
"webpack": "^5.97.1",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^5.1.0"
"webpack-dev-server": "^5.2.0"
}
}
4 changes: 1 addition & 3 deletions integ/browser-tests/tests/autoconfig/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,5 @@ export interface TestRecord {
}

declare global {
interface Window {
testConnectToNetwork: () => Promise<TestRecord>;
}
function testConnectToNetwork(): Promise<TestRecord>;
}
2 changes: 1 addition & 1 deletion integ/browser-tests/tests/autoconfig/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { H3Transport } from "@ndn/quic-transport";

FwTracer.enable();

window.testConnectToNetwork = async () => {
globalThis.testConnectToNetwork = async () => {
const faces = await connectToNetwork({
H3Transport,
preferH3: true,
Expand Down
2 changes: 1 addition & 1 deletion integ/browser-tests/tests/autoconfig/test.t.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ import { navigateToPage, pageInvoke } from "../../test-fixture/pptr";
beforeEach(() => navigateToPage(import.meta.url));

test("connectToNetwork", async () => {
const record = await pageInvoke<typeof window.testConnectToNetwork>("testConnectToNetwork");
const record = await pageInvoke<typeof globalThis.testConnectToNetwork>("testConnectToNetwork");
expect(record.faces.length).toBeGreaterThan(0);
});
20 changes: 9 additions & 11 deletions integ/browser-tests/tests/keychain/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ export type SignVerifyTestResult = [
];

declare global {
interface Window {
testKeyStore: (enabled: KeyStoreEnable) => Promise<KeyStoreRecord>;
testCertStore: () => Promise<CertStoreRecord>;
testDigestSigning: () => Promise<Serialize.Value<SignVerifyTestResult>>;
testECDSA: (curve: EcCurve) => Promise<Serialize.Value<SignVerifyTestResult>>;
testRSA: (modulusLength: RsaModulusLength) => Promise<Serialize.Value<SignVerifyTestResult>>;
testHMAC: () => Promise<Serialize.Value<SignVerifyTestResult>>;
testEd25519: () => Promise<Serialize.Value<SignVerifyTestResult>>;
testSafeBagDecode: (wire: Serialize.Value<Uint8Array>, passphrase: string) => Promise<[sigType: number, certName: string]>;
testSafeBagEncode: (passphrase: string) => Promise<Serialize.Value<Uint8Array>>;
}
function testKeyStore(enabled: KeyStoreEnable): Promise<KeyStoreRecord>;
function testCertStore(): Promise<CertStoreRecord>;
function testDigestSigning(): Promise<Serialize.Value<SignVerifyTestResult>>;
function testECDSA(curve: EcCurve): Promise<Serialize.Value<SignVerifyTestResult>>;
function testRSA(modulusLength: RsaModulusLength): Promise<Serialize.Value<SignVerifyTestResult>>;
function testHMAC(): Promise<Serialize.Value<SignVerifyTestResult>>;
function testEd25519(): Promise<Serialize.Value<SignVerifyTestResult>>;
function testSafeBagDecode(wire: Serialize.Value<Uint8Array>, passphrase: string): Promise<[sigType: number, certName: string]>;
function testSafeBagEncode(passphrase: string): Promise<Serialize.Value<Uint8Array>>;
}
18 changes: 9 additions & 9 deletions integ/browser-tests/tests/keychain/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import { Decoder, Encoder } from "@ndn/tlv";
import * as Serialize from "../../test-fixture/serialize";
import type { SignVerifyTestResult } from "./api";

window.testKeyStore = (enable: KeyStoreEnable) => {
globalThis.testKeyStore = (enable: KeyStoreEnable) => {
const keyChain = KeyChain.open("296616c2-7abb-4d9e-94b3-a97e4fd327b5", CryptoAlgorithmListFull);
return testKeyStore(keyChain, enable);
};

window.testCertStore = () => {
globalThis.testCertStore = () => {
const keyChain = KeyChain.open("005a04be-9752-4f1f-adaf-b52f31742b37");
return testCertStore(keyChain);
};
Expand All @@ -29,33 +29,33 @@ async function testSigningKey(pvtA: Signer, pubA: Verifier,
]));
}

window.testDigestSigning = () => testSigningKey(digestSigning, digestSigning, digestSigning, digestSigning);
globalThis.testDigestSigning = () => testSigningKey(digestSigning, digestSigning, digestSigning, digestSigning);

window.testECDSA = async (curve: EcCurve) => {
globalThis.testECDSA = async (curve: EcCurve) => {
const [pvtA, pubA] = await generateSigningKey("/EC-A", ECDSA, { curve });
const [pvtB, pubB] = await generateSigningKey("/EC-B", ECDSA, { curve });
return testSigningKey(pvtA, pubA, pvtB, pubB);
};

window.testRSA = async (modulusLength: RsaModulusLength) => {
globalThis.testRSA = async (modulusLength: RsaModulusLength) => {
const [pvtA, pubA] = await generateSigningKey("/RSA-A", RSA, { modulusLength });
const [pvtB, pubB] = await generateSigningKey("/RSA-B", RSA, { modulusLength });
return testSigningKey(pvtA, pubA, pvtB, pubB);
};

window.testHMAC = async () => {
globalThis.testHMAC = async () => {
const [pvtA, pubA] = await generateSigningKey("/HMAC-A", HMAC);
const [pvtB, pubB] = await generateSigningKey("/HMAC-B", HMAC);
return testSigningKey(pvtA, pubA, pvtB, pubB);
};

window.testEd25519 = async () => {
globalThis.testEd25519 = async () => {
const [pvtA, pubA] = await generateSigningKey("/Ed25519-A", Ed25519);
const [pvtB, pubB] = await generateSigningKey("/Ed25519-B", Ed25519);
return testSigningKey(pvtA, pubA, pvtB, pubB);
};

window.testSafeBagDecode = async (wire: Serialize.Value<Uint8Array>, passphrase: string) => {
globalThis.testSafeBagDecode = async (wire: Serialize.Value<Uint8Array>, passphrase: string) => {
const keyChain = KeyChain.createTemp(CryptoAlgorithmListFull);
const safeBag = Decoder.decode(Serialize.parse(wire), SafeBag);
const certName = safeBag.certificate.name;
Expand All @@ -67,7 +67,7 @@ window.testSafeBagDecode = async (wire: Serialize.Value<Uint8Array>, passphrase:
return [data.sigInfo.type, `${certName}`];
};

window.testSafeBagEncode = async (passphrase: string) => {
globalThis.testSafeBagEncode = async (passphrase: string) => {
const keyPair = await ECDSA.cryptoGenerate({}, true);
const pkcs8 = new Uint8Array(await crypto.subtle.exportKey("pkcs8", keyPair.privateKey));

Expand Down
18 changes: 9 additions & 9 deletions integ/browser-tests/tests/keychain/test.t.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,46 +17,46 @@ beforeEach(() => navigateToPage(import.meta.url));

test("KeyStore", async () => {
const enabled: TestKeyStore.Enable = { Ed25519: false };
const result = await pageInvoke<typeof window.testKeyStore>("testKeyStore", enabled);
const result = await pageInvoke<typeof globalThis.testKeyStore>("testKeyStore", enabled);
TestKeyStore.check(result, enabled);
});

test("CertStore", async () => {
const result = await pageInvoke<typeof window.testCertStore>("testCertStore");
const result = await pageInvoke<typeof globalThis.testCertStore>("testCertStore");
TestCertStore.check(result);
});

test("SHA256", async () => {
const [rI, rD] = Serialize.parse(
await pageInvoke<typeof window.testDigestSigning>("testDigestSigning"));
await pageInvoke<typeof globalThis.testDigestSigning>("testDigestSigning"));
TestSignVerify.check(rI, { deterministic: true, sameAB: true });
TestSignVerify.check(rD, { deterministic: true, sameAB: true });
});

test.each(EcCurve.Choices)("ECDSA %s", async (curve) => {
const [rI, rD] = Serialize.parse(
await pageInvoke<typeof window.testECDSA>("testECDSA", curve));
await pageInvoke<typeof globalThis.testECDSA>("testECDSA", curve));
TestSignVerify.check(rI);
TestSignVerify.check(rD);
});

test.each(RsaModulusLength.Choices)("RSA %d", async (modulusLength) => {
const [rI, rD] = Serialize.parse(
await pageInvoke<typeof window.testRSA>("testRSA", modulusLength));
await pageInvoke<typeof globalThis.testRSA>("testRSA", modulusLength));
TestSignVerify.check(rI, { deterministic: true });
TestSignVerify.check(rD, { deterministic: true });
});

test("HMAC", async () => {
const [rI, rD] = Serialize.parse(
await pageInvoke<typeof window.testHMAC>("testHMAC"));
await pageInvoke<typeof globalThis.testHMAC>("testHMAC"));
TestSignVerify.check(rI, { deterministic: true });
TestSignVerify.check(rD, { deterministic: true });
});

test("Ed25519", async () => {
const [rI, rD] = Serialize.parse(
await pageInvoke<typeof window.testEd25519>("testEd25519"));
await pageInvoke<typeof globalThis.testEd25519>("testEd25519"));
TestSignVerify.check(rI, { deterministic: true });
TestSignVerify.check(rD, { deterministic: true });
});
Expand All @@ -65,15 +65,15 @@ test.each([
SafeBagEC, SafeBagRSA,
])("SafeBagDecode %#", async ({ sigType, certName, wire, passphrase }) => {
const [aSigType, aCertName] =
await pageInvoke<typeof window.testSafeBagDecode>("testSafeBagDecode", Serialize.stringify(wire), passphrase);
await pageInvoke<typeof globalThis.testSafeBagDecode>("testSafeBagDecode", Serialize.stringify(wire), passphrase);
expect(aSigType).toBe(sigType);
expect(new Name(aCertName)).toEqualName(certName);
});

test("SafeBagEncode", async () => {
const passphrase = "9c570742-82ed-41a8-a370-8e0c8806e5e4";
const wire = Serialize.parse(
await pageInvoke<typeof window.testSafeBagEncode>("testSafeBagEncode", passphrase));
await pageInvoke<typeof globalThis.testSafeBagEncode>("testSafeBagEncode", passphrase));

const safeBag = Decoder.decode(wire, SafeBag);
const { certificate: cert } = safeBag;
Expand Down
6 changes: 2 additions & 4 deletions integ/browser-tests/tests/segmented-object/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ export interface FetchedInfo {
}

declare global {
interface Window {
testBlobChunkSource: () => Promise<FetchedInfo>;
testZenFS: (payloadHex: string) => Promise<FetchedInfo>;
}
function testBlobChunkSource(): Promise<FetchedInfo>;
function testZenFS(payloadHex: string): Promise<FetchedInfo>;
}
4 changes: 2 additions & 2 deletions integ/browser-tests/tests/segmented-object/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ async function fetchAndReport(server: Server): Promise<FetchedInfo> {
};
}

window.testBlobChunkSource = (): Promise<FetchedInfo> => {
globalThis.testBlobChunkSource = (): Promise<FetchedInfo> => {
const file = upload.files![0]!;
const server = serve("/R", new BlobChunkSource(file));
return fetchAndReport(server);
};

window.testZenFS = async (payloadHex): Promise<FetchedInfo> => {
globalThis.testZenFS = async (payloadHex): Promise<FetchedInfo> => {
const root = await navigator.storage.getDirectory();
const file = await root.getFileHandle("R.bin", { create: true });
const writable = await file.createWritable();
Expand Down
4 changes: 2 additions & 2 deletions integ/browser-tests/tests/segmented-object/test.t.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ test("blob to buffer", async () => {
await fileChooser.accept([filename]);
await delay(500);

const { size, digest } = await pageInvoke<typeof window.testBlobChunkSource>("testBlobChunkSource");
const { size, digest } = await pageInvoke<typeof globalThis.testBlobChunkSource>("testBlobChunkSource");
expect(size).toBe(objectBody.byteLength);
expect(digest).toBe(objectBodyDigest);
});

test("file to buffer", async () => {
const { size, digest } = await pageInvoke<typeof window.testZenFS>("testZenFS", toHex(objectBody));
const { size, digest } = await pageInvoke<typeof globalThis.testZenFS>("testZenFS", toHex(objectBody));
expect(size).toBe(objectBody.byteLength);
expect(digest).toBe(objectBodyDigest);
});
6 changes: 2 additions & 4 deletions integ/browser-tests/tests/sync/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ export interface UpdateRecord {
}

declare global {
interface Window {
startPSyncPartial: (uri: string) => Promise<void>;
endPSyncPartial: () => Promise<UpdateRecord[]>;
}
function startPSyncPartial(uri: string): Promise<void>;
function endPSyncPartial(): Promise<UpdateRecord[]>;
}
4 changes: 2 additions & 2 deletions integ/browser-tests/tests/sync/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function saveUpdate(update: SyncUpdate<unknown>): void {
}
}

window.startPSyncPartial = async (uri) => {
globalThis.startPSyncPartial = async (uri) => {
face = await WsTransport.createFace({}, uri);
sub = new PartialSubscriber({
p: makePSyncCompatParam(),
Expand All @@ -36,7 +36,7 @@ window.startPSyncPartial = async (uri) => {
});
};

window.endPSyncPartial = async () => {
globalThis.endPSyncPartial = async () => {
face.close();
return updates;
};
4 changes: 2 additions & 2 deletions integ/browser-tests/tests/sync/test.t.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ test("PSyncPartial", async () => {
closers.push(pub);

await Promise.all([
pageInvoke<typeof window.startPSyncPartial>("startPSyncPartial", server.uri),
pageInvoke<typeof globalThis.startPSyncPartial>("startPSyncPartial", server.uri),
(async () => {
const sock = (await server.waitNClients(1))[0]!;
const face = await WsTransport.createFace({}, sock);
Expand All @@ -51,7 +51,7 @@ test("PSyncPartial", async () => {
}

await delay(500);
const updates = await pageInvoke<typeof window.endPSyncPartial>("endPSyncPartial");
const updates = await pageInvoke<typeof globalThis.endPSyncPartial>("endPSyncPartial");
expect(updates).toHaveLength(3);
expect(updates.map((u) => u.seqNum)).toEqual([1, 2, 3]);
});
6 changes: 2 additions & 4 deletions integ/browser-tests/tests/ws-transport/api.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import type { TestRecord } from "@ndn/l3face/test-fixture/transport";

declare global {
interface Window {
connectWsTransportPair: (uri: string) => Promise<void>;
testWsTransportPair: () => Promise<TestRecord>;
}
function connectWsTransportPair(uri: string): Promise<void>;
function testWsTransportPair(): Promise<TestRecord>;
}
4 changes: 2 additions & 2 deletions integ/browser-tests/tests/ws-transport/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import { WsTransport } from "@ndn/ws-transport";
let transportA: WsTransport;
let transportB: WsTransport;

window.connectWsTransportPair = async (uri) => {
globalThis.connectWsTransportPair = async (uri) => {
[transportA, transportB] = await Promise.all([
WsTransport.connect(uri),
WsTransport.connect(uri),
]);
};

window.testWsTransportPair = async () => testTransport(transportA, transportB);
globalThis.testWsTransportPair = async () => testTransport(transportA, transportB);
4 changes: 2 additions & 2 deletions integ/browser-tests/tests/ws-transport/test.t.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ beforeEach(async () => {
});

test("pair", async () => {
await pageInvoke<typeof window.connectWsTransportPair>("connectWsTransportPair", server.uri);
await pageInvoke<typeof globalThis.connectWsTransportPair>("connectWsTransportPair", server.uri);
const sockets = await server.waitNClients(2);
bridgeWebSockets(sockets);

const result = await pageInvoke<typeof window.testWsTransportPair>("testWsTransportPair");
const result = await pageInvoke<typeof globalThis.testWsTransportPair>("testWsTransportPair");
TestTransport.check(result);
});
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
},
"packageManager": "[email protected]+sha512.76e2379760a4328ec4415815bcd6628dee727af3779aaa4c914e3944156c4299921a89f976381ee107d41f12cfa4b66681ca9c718f0668fa0831ed4c6d8ba56c",
"devDependencies": {
"@types/node": "^22.10.1",
"@types/node": "^22.10.2",
"@types/wtfnode": "^0.7.3",
"@typescript/lib-dom": "npm:@types/[email protected]",
"@vitest/coverage-v8": "^2.1.8",
"@yoursunny/xo-config": "0.59.0",
"@yoursunny/xo-config": "0.60.0",
"codedown": "^3.2.1",
"tslib": "^2.8.1",
"typedoc": "^0.27.4",
Expand Down
2 changes: 1 addition & 1 deletion pkg/fileserver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@ndn/segmented-object": "workspace:*",
"@ndn/tlv": "workspace:*",
"@ndn/util": "workspace:*",
"@zenfs/core": "^1.6.7",
"@zenfs/core": "^1.6.8",
"mnemonist": "^0.39.8",
"obliterator": "^2.0.4",
"streaming-iterables": "^8.0.1",
Expand Down
2 changes: 1 addition & 1 deletion pkg/fileserver/src/ls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface DirEntry {
export function* parseDirectoryListing(input: Uint8Array): Iterable<DirEntry> {
for (let start = 0; start < input.length;) {
const pos = input.indexOf(0, start);
if (pos < 0) {
if (pos === -1) {
throw new Error(`bad directory listing near offset ${start}`);
}
let isDir = false;
Expand Down
2 changes: 1 addition & 1 deletion pkg/nac/src/packet/kdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export namespace KeyDecryptionKey {
export function parseName(name: Name): NameParts {
const pos = name.comps.findIndex((comp) => comp.equals(Keyword.ENCRYPTED_BY));
let memberKeyName: Name;
if (pos < 0 || !CertNaming.isKeyName(memberKeyName = name.slice(pos + 1))) {
if (pos === -1 || !CertNaming.isKeyName(memberKeyName = name.slice(pos + 1))) {
throw new Error("bad KDK name");
}
return {
Expand Down
2 changes: 1 addition & 1 deletion pkg/nac/src/packet/kek.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export interface KeyEncryptionKey extends Readonly<KeyEncryptionKey.NameParts> {
export function parseNameInternal(name: Name, keyword2: Component, type = "KEK"): KeyEncryptionKey.NameParts {
const pos1 = name.comps.findIndex((comp) => comp.equals(Keyword.NAC));
const pos2 = name.comps.findIndex((comp) => comp.equals(keyword2));
if (pos1 < 0 || pos2 < 0 || name.length !== pos2 + 2) {
if (pos1 === -1 || pos2 === -1 || name.length !== pos2 + 2) {
throw new Error(`bad ${type} name`);
}
return {
Expand Down
1 change: 1 addition & 0 deletions pkg/packet/src/security/signed-interest-policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ class SeqNumRule extends SequencedRuleBase<bigint> implements Rule {
constructor({
initialSeqNum = 0n,
}: SignedInterestPolicy.SeqNumOptions) {
// eslint-disable-next-line unicorn/prefer-math-min-max
super("seqNum", "SigSeqNum", (value, prev = 0n) => value > prev ? value : prev);
this.beforeInitialSeqNum = initialSeqNum - 1n;
}
Expand Down
Loading

0 comments on commit 9a6656a

Please sign in to comment.