Skip to content

Commit

Permalink
Add file extensions to relative imports.
Browse files Browse the repository at this point in the history
Use node16 module resolution in TypeScript to help catch errors.

Closes #75, #76.
  • Loading branch information
dchest committed Jan 3, 2025
1 parent 771ba76 commit 6d8cbcd
Show file tree
Hide file tree
Showing 100 changed files with 118 additions and 117 deletions.
5 changes: 3 additions & 2 deletions configs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "ES2022",
"module": "node16",
"strict": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"removeComments": false,
"preserveConstEnums": true,
"moduleResolution": "Bundler",
"moduleResolution": "node16",
"verbatimModuleSyntax": true,
"newLine": "LF",
"sourceMap": true,
"declaration": true,
Expand Down
2 changes: 1 addition & 1 deletion packages/aes-kw/aes-kw.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// MIT License. See LICENSE file for details.

import { describe, expect, it } from 'vitest';
import { AESKW } from "./aes-kw";
import { AESKW } from "./aes-kw.js";
import { encode, decode } from "@stablelib/hex";

// Test vectors sourced from RFC 3394
Expand Down
2 changes: 1 addition & 1 deletion packages/aes/aes.bench.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (C) 2016 Dmitry Chestnykh
// MIT License. See LICENSE file for details.

import { AES } from "./aes";
import { AES } from "./aes.js";
import { benchmark, report, byteSeq } from "@stablelib/benchmark";

const key = byteSeq(32);
Expand Down
2 changes: 1 addition & 1 deletion packages/aes/aes.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (C) 2016 Dmitry Chestnykh
// MIT License. See LICENSE file for details.
import { describe, expect, it } from 'vitest';
import { AES } from "./aes";
import { AES } from "./aes.js";
import { encode, decode } from "@stablelib/hex";

// TODO(dchest): add more AES test vectors.
Expand Down
2 changes: 1 addition & 1 deletion packages/base64/base64.bench.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (C) 2016 Dmitry Chestnykh
// MIT License. See LICENSE file for details.

import { encode, decode } from "./base64";
import { encode, decode } from "./base64.js";
import { benchmark, report, byteSeq } from "@stablelib/benchmark";

let buf = byteSeq(1024);
Expand Down
2 changes: 1 addition & 1 deletion packages/base64/base64.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// MIT License. See LICENSE file for details.

import { describe, expect, it } from 'vitest';
import { encode, decode, encodeURLSafe, decodeURLSafe } from "./base64";
import { encode, decode, encodeURLSafe, decodeURLSafe } from "./base64.js";

const testVectors: [number[], string][] = [
// https://tools.ietf.org/html/rfc4648
Expand Down
2 changes: 1 addition & 1 deletion packages/binary/binary.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
readUintLE, writeUintLE, readUintBE, writeUintBE,
readFloat32BE, writeFloat32BE, readFloat64BE, writeFloat64BE,
readFloat32LE, writeFloat32LE, readFloat64LE, writeFloat64LE
} from "./binary";
} from "./binary.js";

const int16BEVectors: [number, number[]][] = [
[0, [0, 0]],
Expand Down
2 changes: 1 addition & 1 deletion packages/blake2b/blake2b.bench.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (C) 2016 Dmitry Chestnykh
// MIT License. See LICENSE file for details.

import { hash } from "./blake2b";
import { hash } from "./blake2b.js";
import { benchmark, report, byteSeq } from "@stablelib/benchmark";

let buf1M = byteSeq(1024 << 10);
Expand Down
2 changes: 1 addition & 1 deletion packages/blake2b/blake2b.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// MIT License. See LICENSE file for details.

import { describe, expect, it } from 'vitest';
import { BLAKE2b } from "./blake2b";
import { BLAKE2b } from "./blake2b.js";
import { encode } from "@stablelib/hex";

const vectors = [
Expand Down
2 changes: 1 addition & 1 deletion packages/blake2s/blake2s.bench.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (C) 2016 Dmitry Chestnykh
// MIT License. See LICENSE file for details.

import { hash } from "./blake2s";
import { hash } from "./blake2s.js";
import { benchmark, report, byteSeq } from "@stablelib/benchmark";

let buf1M = byteSeq(1024 << 10);
Expand Down
2 changes: 1 addition & 1 deletion packages/blake2s/blake2s.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// MIT License. See LICENSE file for details.

import { describe, expect, it } from 'vitest';
import { BLAKE2s } from "./blake2s";
import { BLAKE2s } from "./blake2s.js";
import { encode } from "@stablelib/hex";

const vectors = [
Expand Down
2 changes: 1 addition & 1 deletion packages/blake2xs/blake2xs.bench.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (C) 2016 Dmitry Chestnykh
// MIT License. See LICENSE file for details.

import { xof } from "./blake2xs";
import { xof } from "./blake2xs.js";
import { benchmark, report, byteSeq } from "@stablelib/benchmark";

let key = byteSeq(32);
Expand Down
2 changes: 1 addition & 1 deletion packages/blake2xs/blake2xs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { describe, expect, it } from 'vitest';
import * as hex from "@stablelib/hex";
import { concat } from "@stablelib/bytes";
import { BLAKE2Xs } from "./blake2xs";
import { BLAKE2Xs } from "./blake2xs.js";

/* eslint:disable */
const vectors = [
Expand Down
2 changes: 1 addition & 1 deletion packages/bytereader/bytereader.bench.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (C) 2016 Dmitry Chestnykh
// MIT License. See LICENSE file for details.

import { ByteReader } from "./bytereader";
import { ByteReader } from "./bytereader.js";
import { report, benchmark, byteSeq } from "@stablelib/benchmark";

const buf = byteSeq(8 << 10);
Expand Down
2 changes: 1 addition & 1 deletion packages/bytereader/bytereader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// MIT License. See LICENSE file for details.

import { describe, expect, it } from 'vitest';
import { ByteReader } from "./bytereader";
import { ByteReader } from "./bytereader.js";

describe("ByteReader", () => {
it("should read bytes", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/bytes/bytes.bench.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (C) 2016 Dmitry Chestnykh
// MIT License. See LICENSE file for details.

import { concat } from "./bytes";
import { concat } from "./bytes.js";
import { benchmark, report } from "@stablelib/benchmark";

const a0 = new Uint8Array([1, 2, 3]);
Expand Down
2 changes: 1 addition & 1 deletion packages/bytes/bytes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// MIT License. See LICENSE file for details.

import { describe, expect, it } from 'vitest';
import { concat } from "./bytes";
import { concat } from "./bytes.js";

describe("concat", () => {
it("should concatenate byte arrays", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/bytewriter/bytewriter.bench.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (C) 2016 Dmitry Chestnykh
// MIT License. See LICENSE file for details.

import { ByteWriter } from "./bytewriter";
import { ByteWriter } from "./bytewriter.js";
import { report, benchmark, byteSeq } from "@stablelib/benchmark";

report("ByteWriter write", benchmark(() => benchmarkWrite(8192), 8192));
Expand Down
2 changes: 1 addition & 1 deletion packages/bytewriter/bytewriter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// MIT License. See LICENSE file for details.

import { describe, expect, it } from 'vitest';
import { ByteWriter } from "./bytewriter";
import { ByteWriter } from "./bytewriter.js";

describe("ByteWriter", () => {
it("should write bytes", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/cbor/cbor.bench.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (C) 2016 Dmitry Chestnykh
// MIT License. See LICENSE file for details.

import { encode, decode, Tagged } from "./cbor";
import { encode, decode, Tagged } from "./cbor.js";
import { benchmark, report, byteSeq } from "@stablelib/benchmark";

const buf = byteSeq(128);
Expand Down
4 changes: 2 additions & 2 deletions packages/cbor/cbor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import { describe, expect, it } from 'vitest';
import * as hex from "@stablelib/hex";
import { concat } from "@stablelib/bytes";
import type { TaggedEncoder, TaggedDecoder} from "./cbor";
import type { TaggedEncoder, TaggedDecoder} from "./cbor.js";
import {
encode, decode, Simple, Tagged,
DEFAULT_TAGGED_ENCODERS, DEFAULT_TAGGED_DECODERS
} from "./cbor";
} from "./cbor.js";

// Test vectors from RFC 7049: Appendix A. Examples.
const encoderTestVectors = [
Expand Down
4 changes: 2 additions & 2 deletions packages/chacha-drbg/chacha-drbg.bench.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright (C) 2016 Dmitry Chestnykh
// MIT License. See LICENSE file for details.

import { ChaChaDRBG } from "./chacha-drbg";
import type { RandomSource } from "@stablelib/random/source";
import { ChaChaDRBG } from "./chacha-drbg.js";
import type { RandomSource } from "@stablelib/random/source/index.js";
import { benchmark, report } from "@stablelib/benchmark";

class XKCDSource implements RandomSource {
Expand Down
2 changes: 1 addition & 1 deletion packages/chacha/chacha.bench.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (C) 2016 Dmitry Chestnykh
// MIT License. See LICENSE file for details.

import { streamXOR } from "./chacha";
import { streamXOR } from "./chacha.js";
import { benchmark, report, byteSeq } from "@stablelib/benchmark";

const buf16K = byteSeq(16 << 10);
Expand Down
2 changes: 1 addition & 1 deletion packages/chacha/chacha.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// MIT License. See LICENSE file for details.

import { describe, expect, it } from 'vitest';
import { streamXOR, stream } from "./chacha";
import { streamXOR, stream } from "./chacha.js";
import { encode, decode } from "@stablelib/hex";

function seq(len: number): Uint8Array {
Expand Down
2 changes: 1 addition & 1 deletion packages/chacha20poly1305/chacha20poly1305.bench.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (C) 2016 Dmitry Chestnykh
// MIT License. See LICENSE file for details.

import { ChaCha20Poly1305 } from "./chacha20poly1305";
import { ChaCha20Poly1305 } from "./chacha20poly1305.js";
import { benchmark, report, byteSeq } from "@stablelib/benchmark";

const buf8192 = byteSeq(8192);
Expand Down
2 changes: 1 addition & 1 deletion packages/chacha20poly1305/chacha20poly1305.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// MIT License. See LICENSE file for details.

import { describe, expect, it } from 'vitest';
import { ChaCha20Poly1305 } from "./chacha20poly1305";
import { ChaCha20Poly1305 } from "./chacha20poly1305.js";
import { encode, decode } from "@stablelib/hex";

const testVectors = [
Expand Down
2 changes: 1 addition & 1 deletion packages/cmac/cmac.bench.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (C) 2016 Dmitry Chestnykh
// MIT License. See LICENSE file for details.

import { CMAC } from "./cmac";
import { CMAC } from "./cmac.js";
import { AES } from "@stablelib/aes";
import { benchmark, report, byteSeq } from "@stablelib/benchmark";

Expand Down
2 changes: 1 addition & 1 deletion packages/cmac/cmac.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// MIT License. See LICENSE file for details.

import { describe, expect, it } from 'vitest';
import { CMAC } from "./cmac";
import { CMAC } from "./cmac.js";
import { AES } from "@stablelib/aes";
import { encode, decode } from "@stablelib/hex";

Expand Down
2 changes: 1 addition & 1 deletion packages/constant-time/constant-time.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// MIT License. See LICENSE file for details.

import { describe, expect, it } from 'vitest';
import { select, lessOrEqual, compare, equal } from "./constant-time";
import { select, lessOrEqual, compare, equal } from "./constant-time.js";

describe("constant-time.select", () => {
it("should select correct value", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/ctr/ctr.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import { AES } from "@stablelib/aes";
import { benchmark, report, byteSeq } from "@stablelib/benchmark";
import { CTR } from "./ctr";
import { CTR } from "./ctr.js";

const buf8192 = byteSeq(8192);
const buf1111 = byteSeq(1111);
Expand Down
2 changes: 1 addition & 1 deletion packages/ctr/ctr.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { describe, expect, it } from 'vitest';
import { AES } from "@stablelib/aes";
import { encode, decode } from "@stablelib/hex";
import { CTR } from "./ctr";
import { CTR } from "./ctr.js";

describe("AES-CTR", () => {
const v = {
Expand Down
2 changes: 1 addition & 1 deletion packages/ed25519/ed25519.bench.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (C) 2016 Dmitry Chestnykh
// MIT License. See LICENSE file for details.

import { sign, verify, generateKeyPairFromSeed, generateKeyPair } from "./ed25519";
import { sign, verify, generateKeyPairFromSeed, generateKeyPair } from "./ed25519.js";
import { benchmark, report } from "@stablelib/benchmark";

const k = generateKeyPair();
Expand Down
2 changes: 1 addition & 1 deletion packages/ed25519/ed25519.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import { describe, expect, it } from 'vitest';
import { encode, decode } from "@stablelib/base64";
import { sign, verify, generateKeyPair, extractPublicKeyFromSecretKey, convertPublicKeyToX25519, convertSecretKeyToX25519 } from "./ed25519";
import { sign, verify, generateKeyPair, extractPublicKeyFromSecretKey, convertPublicKeyToX25519, convertSecretKeyToX25519 } from "./ed25519.js";

/* eslint:disable */
const testVectors = [
Expand Down
2 changes: 1 addition & 1 deletion packages/float/float.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// MIT License. See LICENSE file for details.

import { describe, expect, it } from 'vitest';
import { isNegativeZero, fround } from "./float";
import { isNegativeZero, fround } from "./float.js";

describe("isNegativeZero", () => {
it("should return true for -0", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/gcm/gcm.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// MIT License. See LICENSE file for details.

import { AES } from "@stablelib/aes";
import { GCM } from "./gcm";
import { GCM } from "./gcm.js";
import { benchmark, report, byteSeq } from "@stablelib/benchmark";

const buf8192 = byteSeq(8192);
Expand Down
2 changes: 1 addition & 1 deletion packages/gcm/gcm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import { describe, expect, it } from 'vitest';
import { AES } from "@stablelib/aes";
import { GCM } from "./gcm";
import { GCM } from "./gcm.js";
import { encode, decode } from "@stablelib/hex";

// TODO(dchest): add more test vectors.
Expand Down
2 changes: 1 addition & 1 deletion packages/gf256/gf256.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// MIT License. See LICENSE file for details.

import { benchmark, report } from "@stablelib/benchmark";
import { mul, div } from "./gf256";
import { mul, div } from "./gf256.js";

report("gf256.mul", benchmark(() => mul(100, 18)));
report("gf256.div", benchmark(() => div(100, 18)));
2 changes: 1 addition & 1 deletion packages/gf256/gf256.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// MIT License. See LICENSE file for details.

import { describe, expect, it } from 'vitest';
import { add, sub, mul, div } from "./gf256";
import { add, sub, mul, div } from "./gf256.js";


describe("add/sub", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/halfsiphash/halfsiphash.bench.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (C) 2017 Dmitry Chestnykh
// MIT License. See LICENSE file for details.

import { halfSipHash } from "./halfsiphash";
import { halfSipHash } from "./halfsiphash.js";
import { benchmark, report, byteSeq } from "@stablelib/benchmark";

const buf1M = byteSeq(1024 << 10);
Expand Down
2 changes: 1 addition & 1 deletion packages/halfsiphash/halfsiphash.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import { describe, expect, it } from 'vitest';
import * as hex from "@stablelib/hex";
import { halfSipHash } from "./halfsiphash";
import { halfSipHash } from "./halfsiphash.js";

const testVectors = [
"A9359F5B",
Expand Down
2 changes: 1 addition & 1 deletion packages/hex/hex.bench.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (C) 2016 Dmitry Chestnykh
// MIT License. See LICENSE file for details.

import { encode, decode } from "./hex";
import { encode, decode } from "./hex.js";
import { benchmark, report, byteSeq } from "@stablelib/benchmark";

let buf = byteSeq(1024);
Expand Down
2 changes: 1 addition & 1 deletion packages/hex/hex.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// MIT License. See LICENSE file for details.

import { describe, expect, it } from 'vitest';
import { encode, decode } from "./hex";
import { encode, decode } from "./hex.js";

let buf = new Uint8Array(256);
for (let i = 0; i < buf.length; i++) {
Expand Down
Loading

0 comments on commit 6d8cbcd

Please sign in to comment.