Skip to content

Commit 380de41

Browse files
committed
Improve type stripping compat: Change .js extensions to .ts.
1 parent f779a9f commit 380de41

21 files changed

+62
-62
lines changed

src/_blake.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
* Internal helpers for blake hash.
33
* @module
44
*/
5-
import { aexists, anumber, aoutput } from './_assert.js';
6-
import { type Input, byteSwap32, byteSwapIfBE, Hash, isLE, toBytes, u32 } from './utils.js';
5+
import { aexists, anumber, aoutput } from './_assert.ts';
6+
import { type Input, byteSwap32, byteSwapIfBE, Hash, isLE, toBytes, u32 } from './utils.ts';
77

88
/**
99
* Internal blake variable.

src/_md.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
* Internal Merkle-Damgard hash utils.
33
* @module
44
*/
5-
import { aexists, aoutput } from './_assert.js';
6-
import { type Input, Hash, createView, toBytes } from './utils.js';
5+
import { aexists, aoutput } from './_assert.ts';
6+
import { type Input, Hash, createView, toBytes } from './utils.ts';
77

88
/** Polyfill for Safari 14. https://caniuse.com/mdn-javascript_builtins_dataview_setbiguint64 */
99
export function setBigUint64(

src/argon2.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
* * JS arrays do slow bound checks, so reading from `A2_BUF` slows it down
99
* @module
1010
*/
11-
import { add3H, add3L, rotr32H, rotr32L, rotrBH, rotrBL, rotrSH, rotrSL } from './_u64.js';
12-
import { blake2b } from './blake2b.js';
13-
import { type Input, nextTick, toBytes, u32, u8 } from './utils.js';
11+
import { add3H, add3L, rotr32H, rotr32L, rotrBH, rotrBL, rotrSH, rotrSL } from './_u64.ts';
12+
import { blake2b } from './blake2b.ts';
13+
import { type Input, nextTick, toBytes, u32, u8 } from './utils.ts';
1414

1515
const AT = { Argond2d: 0, Argon2i: 1, Argon2id: 2 } as const;
1616
type Types = (typeof AT)[keyof typeof AT];

src/blake1.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222
* - blake512: G1b: rotr 24 -> 25, G2b: rotr 63 -> 11
2323
* @module
2424
*/
25-
import { aexists, aoutput } from './_assert.js';
26-
import { SIGMA } from './_blake.js';
27-
import { setBigUint64 } from './_md.js';
28-
import u64, { fromBig } from './_u64.js';
29-
import { B2S_IV, G1s, G2s } from './blake2s.js';
30-
import { Hash, type Input, createView, toBytes, wrapConstructorWithOpts } from './utils.js';
25+
import { aexists, aoutput } from './_assert.ts';
26+
import { SIGMA } from './_blake.ts';
27+
import { setBigUint64 } from './_md.ts';
28+
import u64, { fromBig } from './_u64.ts';
29+
import { B2S_IV, G1s, G2s } from './blake2s.ts';
30+
import { Hash, type Input, createView, toBytes, wrapConstructorWithOpts } from './utils.ts';
3131

3232
/** Blake1 options. Basically just "salt" */
3333
export type BlakeOpts = {

src/blake2b.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
* Blake2b hash function. Focuses on 64-bit platforms, but in JS speed different from Blake2s is negligible.
33
* @module
44
*/
5-
import { BLAKE, type BlakeOpts, SIGMA } from './_blake.js';
6-
import u64 from './_u64.js';
7-
import { byteSwapIfBE, type CHashO, toBytes, u32, wrapConstructorWithOpts } from './utils.js';
5+
import { BLAKE, type BlakeOpts, SIGMA } from './_blake.ts';
6+
import u64 from './_u64.ts';
7+
import { byteSwapIfBE, type CHashO, toBytes, u32, wrapConstructorWithOpts } from './utils.ts';
88

99
// Same as SHA-512 but LE
1010
// prettier-ignore

src/blake2s.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
* Blake2s hash function. Focuses on 8-bit to 32-bit platforms. blake2b for 64-bit, but in JS it is slower.
33
* @module
44
*/
5-
import { BLAKE, type BlakeOpts, SIGMA } from './_blake.js';
6-
import { fromBig } from './_u64.js';
7-
import { byteSwapIfBE, type CHashO, rotr, toBytes, u32, wrapConstructorWithOpts } from './utils.js';
5+
import { BLAKE, type BlakeOpts, SIGMA } from './_blake.ts';
6+
import { fromBig } from './_u64.ts';
7+
import { byteSwapIfBE, type CHashO, rotr, toBytes, u32, wrapConstructorWithOpts } from './utils.ts';
88

99
/**
1010
* Initial state: same as SHA256. First 32 bits of the fractional parts of the square roots

src/blake3.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
* * It is still possible to make it faster using: a) loop unrolling b) web workers c) wasm
1212
* @module
1313
*/
14-
import { abytes, aexists, anumber, aoutput } from './_assert.js';
15-
import { BLAKE } from './_blake.js';
16-
import { fromBig } from './_u64.js';
17-
import { B2S_IV, compress } from './blake2s.js';
14+
import { abytes, aexists, anumber, aoutput } from './_assert.ts';
15+
import { BLAKE } from './_blake.ts';
16+
import { fromBig } from './_u64.ts';
17+
import { B2S_IV, compress } from './blake2s.ts';
1818
import {
1919
byteSwap32,
2020
type CHashXO,
@@ -25,7 +25,7 @@ import {
2525
u32,
2626
u8,
2727
wrapXOFConstructorWithOpts,
28-
} from './utils.js';
28+
} from './utils.ts';
2929

3030
// Flag bitset
3131
const B3_Flags = {

src/eskdf.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/**
22
* Experimental KDF for AES.
33
*/
4-
import { abytes } from './_assert.js';
5-
import { hkdf } from './hkdf.js';
6-
import { sha256 } from './sha256.js';
7-
import { pbkdf2 as _pbkdf2 } from './pbkdf2.js';
8-
import { scrypt as _scrypt } from './scrypt.js';
9-
import { bytesToHex, createView, hexToBytes, toBytes } from './utils.js';
4+
import { abytes } from './_assert.ts';
5+
import { hkdf } from './hkdf.ts';
6+
import { pbkdf2 as _pbkdf2 } from './pbkdf2.ts';
7+
import { scrypt as _scrypt } from './scrypt.ts';
8+
import { sha256 } from './sha256.ts';
9+
import { bytesToHex, createView, hexToBytes, toBytes } from './utils.ts';
1010

1111
// A tiny KDF for various applications like AES key-gen.
1212
// Uses HKDF in a non-standard way, so it's not "KDF-secure", only "PRF-secure".

src/hkdf.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
* See https://soatok.blog/2021/11/17/understanding-hkdf/.
44
* @module
55
*/
6-
import { ahash, anumber } from './_assert.js';
7-
import { hmac } from './hmac.js';
8-
import { type CHash, type Input, toBytes } from './utils.js';
6+
import { ahash, anumber } from './_assert.ts';
7+
import { hmac } from './hmac.ts';
8+
import { type CHash, type Input, toBytes } from './utils.ts';
99

1010
/**
1111
* HKDF-extract from spec. Less important part. `HKDF-Extract(IKM, salt) -> PRK`

src/hmac.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
* HMAC: RFC2104 message authentication code.
33
* @module
44
*/
5-
import { abytes, aexists, ahash } from './_assert.js';
6-
import { Hash, toBytes, type CHash, type Input } from './utils.js';
5+
import { abytes, aexists, ahash } from './_assert.ts';
6+
import { Hash, toBytes, type CHash, type Input } from './utils.ts';
77

88
export class HMAC<T extends Hash<T>> extends Hash<HMAC<T>> {
99
oHash: T;

src/legacy.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ MD5 architecture is similar to SHA1, with some differences:
1515
- per round constants: more memory accesses, additional speed-up for unroll
1616
* @module
1717
*/
18-
import { Chi, HashMD, Maj } from './_md.js';
19-
import { type CHash, rotl, wrapConstructor } from './utils.js';
18+
import { Chi, HashMD, Maj } from './_md.ts';
19+
import { type CHash, rotl, wrapConstructor } from './utils.ts';
2020

2121
/** Initial SHA1 state */
2222
const SHA1_IV = /* @__PURE__ */ new Uint32Array([

src/pbkdf2.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
* PBKDF (RFC 2898). Can be used to create a key from password and salt.
33
* @module
44
*/
5-
import { ahash, anumber } from './_assert.js';
6-
import { hmac } from './hmac.js';
5+
import { ahash, anumber } from './_assert.ts';
6+
import { hmac } from './hmac.ts';
77
import {
88
asyncLoop,
99
checkOpts,
@@ -12,7 +12,7 @@ import {
1212
toBytes,
1313
type CHash,
1414
type Input,
15-
} from './utils.js';
15+
} from './utils.ts';
1616

1717
export type Pbkdf2Opt = {
1818
c: number; // Iterations

src/ripemd160.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
* https://homes.esat.kuleuven.be/~bosselae/ripemd160/pdf/AB-9601/AB-9601.pdf
55
* @module
66
*/
7-
import { HashMD } from './_md.js';
8-
import { rotl, wrapConstructor, type CHash } from './utils.js';
7+
import { HashMD } from './_md.ts';
8+
import { rotl, wrapConstructor, type CHash } from './utils.ts';
99

1010
const Rho = /* @__PURE__ */ new Uint8Array([7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8]);
1111
const Id = /* @__PURE__ */ new Uint8Array(new Array(16).fill(0).map((_, i) => i));

src/scrypt.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
* RFC 7914 Scrypt KDF. Can be used to create a key from password and salt.
33
* @module
44
*/
5-
import { anumber } from './_assert.js';
6-
import { pbkdf2 } from './pbkdf2.js';
7-
import { sha256 } from './sha256.js';
8-
import { asyncLoop, byteSwap32, checkOpts, type Input, isLE, rotl, u32 } from './utils.js';
5+
import { anumber } from './_assert.ts';
6+
import { pbkdf2 } from './pbkdf2.ts';
7+
import { sha256 } from './sha256.ts';
8+
import { asyncLoop, byteSwap32, checkOpts, type Input, isLE, rotl, u32 } from './utils.ts';
99

1010
// The main Scrypt loop: uses Salsa extensively.
1111
// Six versions of the function were tried, this is the fastest one.

src/sha1.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
* @deprecated
55
*/
66

7-
export { SHA1, sha1 } from './legacy.js';
7+
export { SHA1, sha1 } from './legacy.ts';

src/sha2.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
* @module
44
*/
55
// Usually you either use sha256, or sha512. We re-export them as sha2 for naming consistency.
6-
export { sha224, sha256 } from './sha256.js';
7-
export { sha384, sha512, sha512_224, sha512_256 } from './sha512.js';
6+
export { sha224, sha256 } from './sha256.ts';
7+
export { sha384, sha512, sha512_224, sha512_256 } from './sha512.ts';

src/sha256.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
* Check out [FIPS 180-4](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf).
88
* @module
99
*/
10-
import { Chi, HashMD, Maj } from './_md.js';
11-
import { type CHash, rotr, wrapConstructor } from './utils.js';
10+
import { Chi, HashMD, Maj } from './_md.ts';
11+
import { type CHash, rotr, wrapConstructor } from './utils.ts';
1212

1313
/** Round constants: first 32 bits of fractional parts of the cube roots of the first 64 primes 2..311). */
1414
// prettier-ignore

src/sha3-addons.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
* * KeccakPRG: Pseudo-random generator based on Keccak [(pdf)](https://keccak.team/files/CSF-0.1.pdf)
1111
* @module
1212
*/
13-
import { anumber } from './_assert.js';
14-
import { Keccak, type ShakeOpts } from './sha3.js';
13+
import { anumber } from './_assert.ts';
14+
import { Keccak, type ShakeOpts } from './sha3.ts';
1515
import {
1616
type CHashO,
1717
type CHashXO,
@@ -22,7 +22,7 @@ import {
2222
u32,
2323
wrapConstructorWithOpts,
2424
wrapXOFConstructorWithOpts,
25-
} from './utils.js';
25+
} from './utils.ts';
2626

2727
// cSHAKE && KMAC (NIST SP800-185)
2828
const _8n = BigInt(8);

src/sha3.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
* Check out `sha3-addons` module for cSHAKE, k12, and others.
1010
* @module
1111
*/
12-
import { abytes, aexists, anumber, aoutput } from './_assert.js';
13-
import { rotlBH, rotlBL, rotlSH, rotlSL, split } from './_u64.js';
12+
import { abytes, aexists, anumber, aoutput } from './_assert.ts';
13+
import { rotlBH, rotlBL, rotlSH, rotlSL, split } from './_u64.ts';
1414
import {
1515
byteSwap32,
1616
Hash,
@@ -23,7 +23,7 @@ import {
2323
type CHashXO,
2424
type HashXOF,
2525
type Input,
26-
} from './utils.js';
26+
} from './utils.ts';
2727

2828
// Various per round constants calculations
2929
const SHA3_PI: number[] = [];

src/sha512.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
* [the paper on truncated SHA512/256](https://eprint.iacr.org/2010/548.pdf).
66
* @module
77
*/
8-
import { HashMD } from './_md.js';
9-
import u64 from './_u64.js';
10-
import { type CHash, wrapConstructor } from './utils.js';
8+
import { HashMD } from './_md.ts';
9+
import u64 from './_u64.ts';
10+
import { type CHash, wrapConstructor } from './utils.ts';
1111

1212
// Round contants (first 32 bits of the fractional parts of the cube roots of the first 80 primes 2..409):
1313
// prettier-ignore

src/utils.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
// Makes the utils un-importable in browsers without a bundler.
1212
// Once node.js 18 is deprecated (2025-04-30), we can just drop the import.
1313
import { crypto } from '@noble/hashes/crypto';
14-
import { abytes } from './_assert.js';
15-
// export { isBytes } from './_assert.js';
14+
import { abytes } from './_assert.ts';
15+
// export { isBytes } from './_assert.ts';
1616
// We can't reuse isBytes from _assert, because somehow this causes huge perf issues
1717
export function isBytes(a: unknown): a is Uint8Array {
1818
return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');

0 commit comments

Comments
 (0)