diff --git a/.auri/$87kr76r2.md b/.auri/$87kr76r2.md new file mode 100644 index 000000000..dee4c10ed --- /dev/null +++ b/.auri/$87kr76r2.md @@ -0,0 +1,6 @@ +--- +package: "lucia" # package name +type: "patch" # "major", "minor", "patch" +--- + +Add proper attributes for `@noble/hashes` \ No newline at end of file diff --git a/packages/lucia/src/scrypt/MODULE_LICENSE b/packages/lucia/src/scrypt/MODULE_LICENSE new file mode 100644 index 000000000..9297a046d --- /dev/null +++ b/packages/lucia/src/scrypt/MODULE_LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2022 Paul Miller (https://paulmillr.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the “Software”), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/packages/lucia/src/scrypt/index.ts b/packages/lucia/src/scrypt/index.ts index 178515034..6cd8db4f7 100644 --- a/packages/lucia/src/scrypt/index.ts +++ b/packages/lucia/src/scrypt/index.ts @@ -10,7 +10,7 @@ const XorAndSalsa = ( ii: number, out: Uint32Array, oi: number -) => { +): void => { const y00 = prev[pi++] ^ input[ii++], y01 = prev[pi++] ^ input[ii++]; const y02 = prev[pi++] ^ input[ii++], @@ -101,7 +101,7 @@ const BlockMix = ( out: Uint32Array, oi: number, r: number -) => { +): void => { let head = oi + 0; let tail = oi + 16 * r; for (let i = 0; i < 16; i++) out[tail + i] = input[ii + (2 * r - 1) * 16 + i]; @@ -194,7 +194,7 @@ export default async ( password: Uint8Array, salt: Uint8Array, opts: ScryptOpts -) => { +): Promise => { const { N, r, p, dkLen, blockSize32, V, B32, B, tmp, blockMixCb, asyncTick } = await scryptInit(password, salt, opts); for (let pi = 0; pi < p; pi++) { diff --git a/packages/lucia/src/scrypt/pbkdf.ts b/packages/lucia/src/scrypt/pbkdf.ts index 9a2b47e1e..7aac91652 100644 --- a/packages/lucia/src/scrypt/pbkdf.ts +++ b/packages/lucia/src/scrypt/pbkdf.ts @@ -5,7 +5,7 @@ export const pbkdf2 = async ( c: number; dkLen: number; } -) => { +): Promise => { const pwKey = await crypto.subtle.importKey( "raw", password, @@ -23,6 +23,5 @@ export const pbkdf2 = async ( pwKey, options.dkLen * 8 ); - return new Uint8Array(keyBuffer); }; diff --git a/packages/lucia/src/scrypt/utils.ts b/packages/lucia/src/scrypt/utils.ts index e78ac9a69..cdfe4178f 100644 --- a/packages/lucia/src/scrypt/utils.ts +++ b/packages/lucia/src/scrypt/utils.ts @@ -1,7 +1,12 @@ -export const u32 = (arr: Uint8Array) => - new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4)); +export const u32 = (arr: Uint8Array): Uint32Array => { + return new Uint32Array( + arr.buffer, + arr.byteOffset, + Math.floor(arr.byteLength / 4) + ); +}; -export const nextTick = async () => {}; +export const nextTick = async (): Promise => {}; export function checkOpts( defaults: T1, @@ -14,11 +19,11 @@ export function checkOpts( export const asyncLoop = async ( iters: number, tick: number, - cb: (i: number) => void -) => { + callback: (i: number) => void +): Promise => { let ts = Date.now(); for (let i = 0; i < iters; i++) { - cb(i); + callback(i); const diff = Date.now() - ts; if (diff >= 0 && diff < tick) continue; await nextTick();