From 76cb9c2a39d477a64824a985ade40507e3bbade1 Mon Sep 17 00:00:00 2001 From: Adam Mathes Date: Fri, 13 Feb 2026 21:34:48 -0800 Subject: feat(vanilla): add testing infrastructure and tests (NK-wjnczv) --- .../node_modules/@exodus/bytes/base58check.d.ts | 131 +++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 vanilla/node_modules/@exodus/bytes/base58check.d.ts (limited to 'vanilla/node_modules/@exodus/bytes/base58check.d.ts') diff --git a/vanilla/node_modules/@exodus/bytes/base58check.d.ts b/vanilla/node_modules/@exodus/bytes/base58check.d.ts new file mode 100644 index 0000000..9e6c29a --- /dev/null +++ b/vanilla/node_modules/@exodus/bytes/base58check.d.ts @@ -0,0 +1,131 @@ +/** + * Implements [base58check](https://en.bitcoin.it/wiki/Base58Check_encoding) encoding. + * + * ```js + * import { fromBase58check, toBase58check } from '@exodus/bytes/base58check.js' + * import { fromBase58checkSync, toBase58checkSync } from '@exodus/bytes/base58check.js' + * import { makeBase58check } from '@exodus/bytes/base58check.js' + * ``` + * + * On non-Node.js, requires peer dependency [@noble/hashes](https://www.npmjs.com/package/@noble/hashes) to be installed. + * + * @module @exodus/bytes/base58check.js + */ + +/// + +import type { OutputFormat, Uint8ArrayBuffer } from './array.js'; + +/** + * Hash function type that takes Uint8Array and returns a Promise of Uint8Array + */ +export type HashFunction = (data: Uint8Array) => Promise; + +/** + * Synchronous hash function type that takes Uint8Array and returns Uint8Array + */ +export type HashFunctionSync = (data: Uint8Array) => Uint8Array; + +/** + * Base58Check encoder/decoder instance with async methods + */ +export interface Base58CheckAsync { + /** + * Encode bytes to base58check string asynchronously + * + * @param arr - The input bytes to encode + * @returns A Promise that resolves to the base58check encoded string + */ + encode(arr: Uint8Array): Promise; + + /** + * Decode a base58check string to bytes asynchronously + * + * @param string - The base58check encoded string + * @param format - Output format (default: 'uint8') + * @returns A Promise that resolves to the decoded bytes + */ + decode(string: string, format?: 'uint8'): Promise; + decode(string: string, format: 'buffer'): Promise; + decode(string: string, format?: OutputFormat): Promise; +} + +/** + * Base58Check encoder/decoder instance with both async and sync methods + */ +export interface Base58CheckSync extends Base58CheckAsync { + /** + * Encode bytes to base58check string synchronously + * + * @param arr - The input bytes to encode + * @returns The base58check encoded string + */ + encodeSync(arr: Uint8Array): string; + + /** + * Decode a base58check string to bytes synchronously + * + * @param string - The base58check encoded string + * @param format - Output format (default: 'uint8') + * @returns The decoded bytes + */ + decodeSync(string: string, format?: 'uint8'): Uint8ArrayBuffer; + decodeSync(string: string, format: 'buffer'): Buffer; + decodeSync(string: string, format?: OutputFormat): Uint8ArrayBuffer | Buffer; +} + +/** + * Create a base58check encoder/decoder with custom hash functions + * + * @param hashAlgo - Async hash function (typically double SHA-256) + * @param hashAlgoSync - Optional sync hash function + * @returns Base58Check encoder/decoder instance + */ +export function makeBase58check(hashAlgo: HashFunction | HashFunctionSync, hashAlgoSync: HashFunctionSync): Base58CheckSync; +export function makeBase58check(hashAlgo: HashFunction | HashFunctionSync, hashAlgoSync?: undefined): Base58CheckAsync; + +/** + * Encode bytes to base58check string asynchronously + * + * Uses double SHA-256 for checksum calculation + * + * @param arr - The input bytes to encode + * @returns A Promise that resolves to the base58check encoded string + */ +export function toBase58check(arr: Uint8Array): Promise; + +/** + * Decode a base58check string to bytes asynchronously + * + * Validates the checksum using double SHA-256 + * + * @param string - The base58check encoded string + * @param format - Output format (default: 'uint8') + * @returns A Promise that resolves to the decoded bytes + */ +export function fromBase58check(string: string, format?: 'uint8'): Promise; +export function fromBase58check(string: string, format: 'buffer'): Promise; +export function fromBase58check(string: string, format?: OutputFormat): Promise; + +/** + * Encode bytes to base58check string synchronously + * + * Uses double SHA-256 for checksum calculation + * + * @param arr - The input bytes to encode + * @returns The base58check encoded string + */ +export function toBase58checkSync(arr: Uint8Array): string; + +/** + * Decode a base58check string to bytes synchronously + * + * Validates the checksum using double SHA-256 + * + * @param string - The base58check encoded string + * @param format - Output format (default: 'uint8') + * @returns The decoded bytes + */ +export function fromBase58checkSync(string: string, format?: 'uint8'): Uint8ArrayBuffer; +export function fromBase58checkSync(string: string, format: 'buffer'): Buffer; +export function fromBase58checkSync(string: string, format?: OutputFormat): Uint8ArrayBuffer | Buffer; -- cgit v1.2.3