From: Chris Duncan Date: Fri, 8 Aug 2025 02:15:46 +0000 (-0700) Subject: Deprecate unnecessary unknown union types. X-Git-Tag: v0.10.5~43^2~41 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=6b83659ecf8af805e4d6edbe73a5e5788429068b;p=libnemo.git Deprecate unnecessary unknown union types. --- diff --git a/src/lib/blake2b.ts b/src/lib/blake2b.ts index 1c539e5..fbc5e94 100644 --- a/src/lib/blake2b.ts +++ b/src/lib/blake2b.ts @@ -1,8 +1,6 @@ //! SPDX-FileCopyrightText: 2025 Chris Duncan //! SPDX-License-Identifier: GPL-3.0-or-later AND ISC -import { UnknownNumber, UnknownUint8Array } from "#types" - /** * Implementation derived from blake2b@2.1.4. Copyright 2017 Emil Bay * (https://github.com/emilbayes/blake2b). See LICENSES/ISC.txt @@ -197,7 +195,8 @@ export class Blake2b { * @param {Uint8Array} [salt] - (_optional_) Used to simplify randomized hashing for digital signatures * @param {Uint8Array} [personal] - (_optional_) Arbitrary user-specified value */ - constructor (length: UnknownNumber, key?: UnknownUint8Array, salt?: UnknownUint8Array, personal?: UnknownUint8Array) { + constructor (length: number, key?: Uint8Array, salt?: Uint8Array, personal?: Uint8Array) + constructor (length: unknown, key?: unknown, salt?: unknown, personal?: unknown) { if (length == null) { throw new TypeError(`length is required`) } diff --git a/src/types.d.ts b/src/types.d.ts index 4e954e2..499ea1d 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -125,12 +125,21 @@ export declare class AccountList extends Object { */ export declare class Bip39Mnemonic { #private - get phrase (): string - private constructor () + /** + * Derives a mnemonic phrase from source of entropy or seed. + * + * The entropy must be between 16-32 bytes (32-64 characters) to stay within + * the limit of 128-256 bits defined in BIP-39. Typically, wallets use the + * maximum entropy allowed. + * + * @param {(string|ArrayBuffer|Uint8Array)} entropy - Cryptographically secure random value + * @returns {string} Mnemonic phrase created using the BIP-39 wordlist + */ + static fromEntropy (entropy: string | ArrayBuffer | Uint8Array): Promise /** * Imports and validates an existing mnemonic phrase. * - * The phrase must be valid according to the BIP-39 specification. Typically + * The phrase must be valid according to the BIP-39 specification. Typically, * wallets use the maximum of 24 words. * * @param {string} phrase - String of 12, 15, 18, 21, or 24 words @@ -138,35 +147,27 @@ export declare class Bip39Mnemonic { */ static fromPhrase (phrase: string): Promise /** - * Derives a mnemonic phrase from source of entropy or seed. + * Validates a mnemonic phrase meets the BIP-39 specification. * - * The entropy must be between 32-64 characters to stay within the defined - * limit of 128-256 bits. Typically wallets use the maximum entropy allowed. - * - * @param {string} entropy - Hexadecimal string - * @returns {string} Mnemonic phrase created using the BIP-39 wordlist + * @param {string} mnemonic - Mnemonic phrase to validate + * @returns {boolean} True if the mnemonic phrase is valid */ - static fromEntropy (entropy: string): Promise - /** - * SHA-256 hash of entropy that is appended to the entropy and subsequently - * used to generate the mnemonic phrase. - * - * @param {Entropy} entropy - Cryptographically strong pseudorandom data of length N bits - * @returns {Promise} First N/32 bits of the hash as a hexadecimal string - */ - static checksum (entropy: Entropy): Promise + static validate (mnemonic: string): Promise + get phrase (): string | undefined + private constructor () /** - * Erases seed bytes and releases variable references to allow garbage - * collection. + * Erases seed bytes and releases variable references. */ destroy (): void /** - * Validates a mnemonic phrase. + * Converts the mnemonic phrase to a BIP-39 seed. * - * @param {string} mnemonic - Mnemonic phrase to validate - * @returns {boolean} True if the mnemonic phrase is valid + * A passphrase string can be specified. If the passphrase is undefined, null, + * or not a string, the empty string ("") is used instead. + * + * @param {string} [passphrase=''] - Used as the PBKDF2 salt. Default: "" + * @returns {Promise>} Promise for seed as bytes */ - static validate (mnemonic: string): Promise toBip39Seed (passphrase: string): Promise> /** * Converts the mnemonic phrase to a BIP-39 seed. @@ -175,14 +176,20 @@ export declare class Bip39Mnemonic { * or not a string, the empty string ("") is used instead. * * @param {string} [passphrase=''] - Used as the PBKDF2 salt. Default: "" - * @returns {string} Hexadecimal seed + * @returns {Promise} Promise for seed as hexadecimal string */ toBip39Seed (passphrase: string, format: 'hex'): Promise + /** + * Converts the mnemonic phrase to a BLAKE2b seed. + * + * @returns {Promise>} Promise for seed as bytes + */ toBlake2bSeed (): Promise> /** * Converts the mnemonic phrase to a BLAKE2b seed. * - * @returns {string} Hexadecimal seed + * @param {string} format + * @returns {Promise} Promise for seed as hexadecimal string */ toBlake2bSeed (format: 'hex'): Promise } @@ -214,7 +221,7 @@ export declare class Blake2b { * @param {Uint8Array} [salt] - (_optional_) Used to simplify randomized hashing for digital signatures * @param {Uint8Array} [personal] - (_optional_) Arbitrary user-specified value */ - constructor (length: UnknownNumber, key?: UnknownUint8Array, salt?: UnknownUint8Array, personal?: UnknownUint8Array) + constructor (length: number, key?: Uint8Array, salt?: Uint8Array, personal?: Uint8Array) update (input: Uint8Array): Blake2b digest (): Uint8Array digest (out: 'hex'): string @@ -928,7 +935,3 @@ export declare class WorkerQueue { } export declare const PasskeyWorker: WorkerQueue - -export type UnknownNumber = number | unknown - -export type UnknownUint8Array = Uint8Array | unknown