Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@scure/base

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@scure/base - npm Package Compare versions

Comparing version
2.0.0
to
2.2.0
+286
-24
index.d.ts
/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */
/** Transforms values between two representations. */
export interface Coder<F, T> {
/**
* Converts a value from the input representation to the output representation.
* @param from - Value in the source representation.
* @returns Converted value.
*/
encode(from: F): T;
/**
* Converts a value from the output representation back to the input representation.
* @param to - Value in the target representation.
* @returns Converted value.
*/
decode(to: T): F;
}
/** Coder that works with byte arrays and strings. */
export interface BytesCoder extends Coder<Uint8Array, string> {
/**
* Encodes bytes into a string representation.
* @param data - Bytes to encode.
* @returns Encoded string.
*/
encode: (data: Uint8Array) => string;
/**
* Decodes a string representation into raw bytes.
* @param str - Encoded string.
* @returns Decoded bytes.
*/
decode: (str: string) => Uint8Array;
}
/**
* Bytes API type helpers for old + new TypeScript.
*
* TS 5.6 has `Uint8Array`, while TS 5.9+ made it generic `Uint8Array<ArrayBuffer>`.
* We can't use specific return type, because TS 5.6 will error.
* We can't use generic return type, because most TS 5.9 software will expect specific type.
*
* Maps typed-array input leaves to broad forms.
* These are compatibility adapters, not ownership guarantees.
*
* - `TArg` keeps byte inputs broad.
* - `TRet` marks byte outputs for TS 5.6 and TS 5.9+ compatibility.
*/
export type TypedArg<T> = T extends BigInt64Array ? BigInt64Array : T extends BigUint64Array ? BigUint64Array : T extends Float32Array ? Float32Array : T extends Float64Array ? Float64Array : T extends Int16Array ? Int16Array : T extends Int32Array ? Int32Array : T extends Int8Array ? Int8Array : T extends Uint16Array ? Uint16Array : T extends Uint32Array ? Uint32Array : T extends Uint8ClampedArray ? Uint8ClampedArray : T extends Uint8Array ? Uint8Array : never;
/** Maps typed-array output leaves to narrow TS-compatible forms. */
export type TypedRet<T> = T extends BigInt64Array ? ReturnType<typeof BigInt64Array.of> : T extends BigUint64Array ? ReturnType<typeof BigUint64Array.of> : T extends Float32Array ? ReturnType<typeof Float32Array.of> : T extends Float64Array ? ReturnType<typeof Float64Array.of> : T extends Int16Array ? ReturnType<typeof Int16Array.of> : T extends Int32Array ? ReturnType<typeof Int32Array.of> : T extends Int8Array ? ReturnType<typeof Int8Array.of> : T extends Uint16Array ? ReturnType<typeof Uint16Array.of> : T extends Uint32Array ? ReturnType<typeof Uint32Array.of> : T extends Uint8ClampedArray ? ReturnType<typeof Uint8ClampedArray.of> : T extends Uint8Array ? ReturnType<typeof Uint8Array.of> : never;
/** Recursively adapts byte-carrying API input types. See {@link TypedArg}. */
export type TArg<T> = T | ([TypedArg<T>] extends [never] ? T extends (...args: infer A) => infer R ? ((...args: {
[K in keyof A]: TRet<A[K]>;
}) => TArg<R>) & {
[K in keyof T]: T[K] extends (...args: any) => any ? T[K] : TArg<T[K]>;
} : T extends [infer A, ...infer R] ? [TArg<A>, ...{
[K in keyof R]: TArg<R[K]>;
}] : T extends readonly [infer A, ...infer R] ? readonly [TArg<A>, ...{
[K in keyof R]: TArg<R[K]>;
}] : T extends (infer A)[] ? TArg<A>[] : T extends readonly (infer A)[] ? readonly TArg<A>[] : T extends Promise<infer A> ? Promise<TArg<A>> : T extends object ? {
[K in keyof T]: TArg<T[K]>;
} : T : TypedArg<T>);
/** Recursively adapts byte-carrying API output types. See {@link TypedArg}. */
export type TRet<T> = T extends unknown ? T & ([TypedRet<T>] extends [never] ? T extends (...args: infer A) => infer R ? ((...args: {
[K in keyof A]: TArg<A[K]>;
}) => TRet<R>) & {
[K in keyof T]: T[K] extends (...args: any) => any ? T[K] : TRet<T[K]>;
} : T extends [infer A, ...infer R] ? [TRet<A>, ...{
[K in keyof R]: TRet<R[K]>;
}] : T extends readonly [infer A, ...infer R] ? readonly [TRet<A>, ...{
[K in keyof R]: TRet<R[K]>;
}] : T extends (infer A)[] ? TRet<A>[] : T extends readonly (infer A)[] ? readonly TRet<A>[] : T extends Promise<infer A> ? Promise<TRet<A>> : T extends object ? {
[K in keyof T]: TRet<T[K]>;
} : T : TypedRet<T>) : never;
type Chain = [Coder<any, any>, ...Coder<any, any>[]];

@@ -49,3 +111,3 @@ type Input<F> = F extends Coder<infer T, any> ? T : never;

*/
declare function radix(num: number): Coder<Uint8Array, number[]>;
declare function radix(num: number): TRet<Coder<Uint8Array, number[]>>;
/**

@@ -56,4 +118,14 @@ * If both bases are power of same number (like `2**8 <-> 2**64`),

*/
declare function radix2(bits: number, revPadding?: boolean): Coder<Uint8Array, number[]>;
declare function checksum(len: number, fn: (data: Uint8Array) => Uint8Array): Coder<Uint8Array, Uint8Array>;
declare function radix2(bits: number, revPadding?: boolean): TRet<Coder<Uint8Array, number[]>>;
type BytesFn = (data: TArg<Uint8Array>) => TRet<Uint8Array>;
declare function checksum(len: number, fn: TArg<BytesFn>): TRet<Coder<Uint8Array, Uint8Array>>;
/**
* Low-level building blocks used by the exported codecs.
* @example
* Build a radix-32 coder from the low-level helpers.
* ```ts
* import { utils } from '@scure/base';
* utils.radix2(5).encode(Uint8Array.from([1, 2, 3]));
* ```
*/
export declare const utils: {

@@ -72,2 +144,5 @@ alphabet: typeof alphabet;

* base16 encoding from RFC 4648.
* This codec uses RFC 4648 Table 5's uppercase alphabet directly.
* RFC 4648 §8 calls base16 "case-insensitive hex encoding", but we intentionally do not case-fold decode input here.
* Use `hex` for case-insensitive hex decoding.
* @example

@@ -82,2 +157,4 @@ * ```js

* base32 encoding from RFC 4648. Has padding.
* RFC 4648 §6 Table 3 uses uppercase letters, and RFC 4648 §3.4 allows applications to choose
* upper- or lowercase alphabets. We keep the published uppercase table and do not case-fold decode input.
* Use `base32nopad` for unpadded version.

@@ -96,2 +173,3 @@ * Also check out `base32hex`, `base32hexnopad`, `base32crockford`.

* base32 encoding from RFC 4648. No padding.
* This variant inherits RFC 4648 base32's uppercase table and intentionally does not case-fold decode input.
* Use `base32` for padded version.

@@ -110,2 +188,3 @@ * Also check out `base32hex`, `base32hexnopad`, `base32crockford`.

* base32 encoding from RFC 4648. Padded. Compared to ordinary `base32`, slightly different alphabet.
* RFC 4648 §7 Table 4 uses uppercase letters, and we intentionally keep that table without case-folding decode input.
* Use `base32hexnopad` for unpadded version.

@@ -123,2 +202,3 @@ * @example

* base32 encoding from RFC 4648. No padding. Compared to ordinary `base32`, slightly different alphabet.
* This variant inherits RFC 4648 base32hex's uppercase table and intentionally does not case-fold decode input.
* Use `base32hex` for padded version.

@@ -136,3 +216,3 @@ * @example

* base32 encoding from RFC 4648. Doug Crockford's version.
* https://www.crockford.com/base32.html
* See {@link https://www.crockford.com/base32.html | Douglas Crockford's Base32}.
* @example

@@ -203,4 +283,5 @@ * ```js

* ```js
* base58.decode('01abcdef');
* // => '3UhJW'
* const text = base58.encode(Uint8Array.from([0, 1, 2]));
* base58.decode(text);
* // => Uint8Array.from([0, 1, 2])
* ```

@@ -211,2 +292,8 @@ */

* base58: flickr version. Check out `base58`.
* @example
* Round-trip bytes with the Flickr alphabet.
* ```ts
* const text = base58flickr.encode(Uint8Array.from([0, 1, 2]));
* base58flickr.decode(text);
* ```
*/

@@ -216,2 +303,8 @@ export declare const base58flickr: BytesCoder;

* base58: XRP version. Check out `base58`.
* @example
* Round-trip bytes with the XRP alphabet.
* ```ts
* const text = base58xrp.encode(Uint8Array.from([0, 1, 2]));
* base58xrp.decode(text);
* ```
*/

@@ -223,2 +316,8 @@ export declare const base58xrp: BytesCoder;

* Block encoding significantly reduces quadratic complexity of base58.
* @example
* Round-trip bytes with the Monero block codec.
* ```ts
* const text = base58xmr.encode(Uint8Array.from([0, 1, 2]));
* base58xmr.decode(text);
* ```
*/

@@ -229,26 +328,105 @@ export declare const base58xmr: BytesCoder;

* Requires function, calculating sha256.
* Callers must include any version bytes in `data`; this helper only applies the
* 4-byte double-SHA256 checksum used by Bitcoin Base58Check.
* @param sha256 - Function used to calculate the checksum hash.
* @returns base58check codec using 4 checksum bytes.
* @throws On wrong argument types. {@link TypeError}
* @example
* Create a base58check codec from a SHA-256 implementation.
* ```ts
* import { createBase58check } from '@scure/base';
* import { sha256 } from '@noble/hashes/sha2.js';
* const coder = createBase58check(sha256);
* coder.encode(Uint8Array.from([1, 2, 3]));
* ```
*/
export declare const createBase58check: (sha256: (data: Uint8Array) => Uint8Array) => BytesCoder;
export declare const createBase58check: (sha256: TArg<BytesFn>) => BytesCoder;
/**
* Use `createBase58check` instead.
* @deprecated
* @deprecated Use {@link createBase58check} instead.
* Callers must include any version bytes in `data`; this alias keeps the same
* 4-byte double-SHA256 checksum behavior as `createBase58check`.
* @param sha256 - Function used to calculate the checksum hash.
* @returns base58check codec using 4 checksum bytes.
* @example
* Create a base58check codec with the deprecated alias.
* ```ts
* import { base58check } from '@scure/base';
* import { sha256 } from '@noble/hashes/sha2.js';
* const coder = base58check(sha256);
* coder.encode(Uint8Array.from([1, 2, 3]));
* ```
*/
export declare const base58check: (sha256: (data: Uint8Array) => Uint8Array) => BytesCoder;
export declare const base58check: (sha256: TArg<BytesFn>) => BytesCoder;
/** Result of bech32 decoding. */
export interface Bech32Decoded<Prefix extends string = string> {
/** Human-readable bech32 prefix. */
prefix: Prefix;
/** Decoded 5-bit word payload. */
words: number[];
}
/** Result of bech32 decoding with original bytes attached. */
export interface Bech32DecodedWithArray<Prefix extends string = string> {
/** Human-readable bech32 prefix. */
prefix: Prefix;
/** Decoded 5-bit word payload. */
words: number[];
/** Decoded payload converted back into raw bytes. */
bytes: Uint8Array;
}
/** bech32 codec surface. */
export interface Bech32 {
/**
* Encodes a human-readable prefix and 5-bit words into a bech32 string.
* @param prefix - Human-readable prefix.
* @param words - 5-bit words or raw bytes.
* @param limit - Maximum accepted output length, or `false` to disable the limit.
* @returns Encoded bech32 string.
*/
encode<Prefix extends string>(prefix: Prefix, words: number[] | Uint8Array, limit?: number | false): `${Lowercase<Prefix>}1${string}`;
/**
* Decodes a bech32 string into prefix and words.
* @param str - Encoded bech32 string.
* @param limit - Maximum accepted input length, or `false` to disable the limit.
* @returns Decoded prefix and 5-bit words.
*/
decode<Prefix extends string>(str: `${Prefix}1${string}`, limit?: number | false): Bech32Decoded<Prefix>;
decode(str: string, limit?: number | false): Bech32Decoded;
/**
* Encodes raw bytes by first converting them to 5-bit words.
* @param prefix - Human-readable prefix.
* @param bytes - Raw bytes to encode.
* @returns Encoded bech32 string.
*/
encodeFromBytes(prefix: string, bytes: Uint8Array): string;
/**
* Decodes a bech32 string and converts the payload back into bytes.
* @param str - Encoded bech32 string.
* @returns Decoded prefix, words, and bytes.
*/
decodeToBytes(str: string): Bech32DecodedWithArray;
/**
* Decodes a bech32 string, returning `undefined` instead of throwing on invalid input.
* @param str - Encoded bech32 string.
* @param limit - Maximum accepted input length, or `false` to disable the limit.
* @returns Decoded prefix and words, or `undefined` for invalid input.
*/
decodeUnsafe(str: string, limit?: number | false): void | Bech32Decoded<string>;
/**
* Converts 5-bit words back into raw bytes.
* @param to - 5-bit words to decode.
* @returns Decoded bytes.
*/
fromWords(to: number[]): Uint8Array;
/**
* Converts 5-bit words back into raw bytes, returning `undefined` instead of throwing.
* @param to - 5-bit words to decode.
* @returns Decoded bytes, or `undefined` for invalid input.
*/
fromWordsUnsafe(to: number[]): void | Uint8Array;
/**
* Converts raw bytes into 5-bit words for bech32 encoding.
* @param from - Raw bytes to convert.
* @returns 5-bit words.
*/
toWords(from: Uint8Array): number[];

@@ -258,17 +436,45 @@ }

* bech32 from BIP 173. Operates on words.
* For high-level, check out scure-btc-signer:
* https://github.com/paulmillr/scure-btc-signer.
* For high-level helpers, check out {@link https://github.com/paulmillr/scure-btc-signer | scure-btc-signer}.
* @example
* Convert bytes to words, encode them, then decode back.
* ```ts
* const words = bech32.toWords(Uint8Array.from([1, 2, 3]));
* const text = bech32.encode('bc', words);
* bech32.decode(text);
* ```
*/
export declare const bech32: Bech32;
export declare const bech32: TRet<Bech32>;
/**
* bech32m from BIP 350. Operates on words.
* It was to mitigate `bech32` weaknesses.
* For high-level, check out scure-btc-signer:
* https://github.com/paulmillr/scure-btc-signer.
* For high-level helpers, check out {@link https://github.com/paulmillr/scure-btc-signer | scure-btc-signer}.
* @example
* Convert bytes to words, encode them with bech32m, then decode back.
* ```ts
* const words = bech32m.toWords(Uint8Array.from([1, 2, 3]));
* const text = bech32m.encode('bc', words);
* bech32m.decode(text);
* ```
*/
export declare const bech32m: Bech32;
export declare const bech32m: TRet<Bech32>;
/**
* UTF-8-to-byte decoder. Uses built-in TextDecoder / TextEncoder.
* ASCII-to-byte decoder. Rejects non-ASCII text and bytes instead of doing UTF-8 replacement.
* Method names follow `BytesCoder`, so `encode(bytes)` returns a string and `decode(string)` returns bytes.
* @example
* ```js
* const b = ascii.decode("ABC"); // => new Uint8Array([ 65, 66, 67 ])
* const str = ascii.encode(b); // "ABC"
* ```
*/
export declare const ascii: TRet<BytesCoder>;
/**
* Strict UTF-8-to-byte decoder. Uses built-in TextDecoder / TextEncoder when available.
* Method names follow `BytesCoder`, so `encode(bytes)` returns a string and
* `decode(string)` returns bytes.
* `encode(bytes)` requires Uint8Array input, preserves an explicit leading BOM, and
* throws on invalid UTF-8 bytes.
* `decode(string)` requires a primitive string and throws on malformed UTF-16 strings with
* lone surrogates.
* @example
* ```js
* const b = utf8.decode("hey"); // => new Uint8Array([ 104, 101, 121 ])

@@ -279,4 +485,9 @@ * const str = utf8.encode(b); // "hey"

export declare const utf8: BytesCoder;
export declare const __TESTS: {
utf8Fallback: BytesCoder;
_isWellFormedShim: (str: string) => boolean;
};
/**
* hex string decoder. Uses built-in function, when available.
* Lowercase codec; unlike `base16`, this variant accepts either hex case and emits lowercase.
* @example

@@ -289,22 +500,73 @@ * ```js

export declare const hex: BytesCoder;
/** Built-in codecs exposed through the deprecated string conversion helpers. */
export type SomeCoders = {
/** UTF-8 string codec. */
utf8: BytesCoder;
/** Hex codec. */
hex: BytesCoder;
/** Uppercase RFC 4648 base16 codec. */
base16: BytesCoder;
/** RFC 4648 base32 codec with padding. */
base32: BytesCoder;
/** RFC 4648 base64 codec with padding. */
base64: BytesCoder;
/** URL-safe base64 codec without `+` or `/`. */
base64url: BytesCoder;
/** Bitcoin-style base58 codec. */
base58: BytesCoder;
/** Monero-style base58 codec. */
base58xmr: BytesCoder;
};
type CoderType = keyof SomeCoders;
/** @deprecated */
export declare const bytesToString: (type: CoderType, bytes: Uint8Array) => string;
/** @deprecated */
export declare const str: (type: CoderType, bytes: Uint8Array) => string;
/** @deprecated */
export declare const stringToBytes: (type: CoderType, str: string) => Uint8Array;
/** @deprecated */
export declare const bytes: (type: CoderType, str: string) => Uint8Array;
/**
* Encodes bytes with one of the built-in codecs.
* @deprecated Use the codec directly, for example `hex.encode(bytes)`.
* @param type - Codec name.
* @param bytes - Bytes to encode.
* @returns Encoded string.
* @throws On wrong argument types. {@link TypeError}
* @example
* ```ts
* bytesToString('hex', Uint8Array.from([1, 2, 255]));
* ```
*/
export declare const bytesToString: (type: CoderType, bytes: TArg<Uint8Array>) => string;
/**
* Alias for `bytesToString`.
* @deprecated Use {@link bytesToString} or the codec directly instead.
* @param type - Codec name.
* @param bytes - Bytes to encode.
* @returns Encoded string.
* @example
* ```ts
* str('hex', Uint8Array.from([1, 2, 255]));
* ```
*/
export declare const str: (type: CoderType, bytes: TArg<Uint8Array>) => string;
/**
* Decodes a string with one of the built-in codecs.
* @deprecated Use the codec directly, for example `hex.decode(text)`.
* @param type - Codec name.
* @param str - Encoded string.
* @returns Decoded bytes.
* @throws On wrong argument types. {@link TypeError}
* @example
* ```ts
* stringToBytes('hex', '0102ff');
* ```
*/
export declare const stringToBytes: (type: CoderType, str: string) => TRet<Uint8Array>;
/**
* Alias for `stringToBytes`.
* @deprecated Use {@link stringToBytes} or the codec directly instead.
* @param type - Codec name.
* @param str - Encoded string.
* @returns Decoded bytes.
* @example
* ```ts
* bytes('hex', '0102ff');
* ```
*/
export declare const bytes: (type: CoderType, str: string) => TRet<Uint8Array>;
export {};
//# sourceMappingURL=index.d.ts.map
+1
-1

@@ -1,1 +0,1 @@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AAE,UAAU,CAAC;IACjB,iBAAiB;IACjB,GAAG,EAAE,UAAU,CAAC;IAChB,uCAAuC;IACvC,MAAM,EAAE,UAAU,CAAC;IACnB,0CAA0C;IAC1C,MAAM,EAAE,UAAU,CAAC;IACnB,0CAA0C;IAC1C,MAAM,EAAE,UAAU,CAAC;IACnB,gDAAgD;IAChD,SAAS,EAAE,UAAU,CAAC;IACtB,kCAAkC;IAClC,MAAM,EAAE,UAAU,CAAC;IACnB,iCAAiC;IACjC,SAAS,EAAE,UAAU,CAAC;CACvB,CAAC;AAMF,KAAK,SAAS,GAAG,MAAM,UAAU,CAAC;AAIlC;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,aAAa,GAAI,MAAM,SAAS,EAAE,OAAO,IAAI,CAAC,UAAU,CAAC,KAAG,MAIxE,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,GAAG,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,KAAK,MAAsB,CAAC;AAEvF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,aAAa,GAAI,MAAM,SAAS,EAAE,KAAK,MAAM,KAAG,IAAI,CAAC,UAAU,CAK3E,CAAC;AACF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,KAAK,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC,UAAU,CAAiB,CAAC"}
+420
-67
/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */
function isBytes(a) {
return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');
// Plain `instanceof Uint8Array` is too strict for some Buffer / proxy / cross-realm cases. The
// fallback still requires a real ArrayBuffer view, so plain JSON-deserialized
// `{ constructor: ... }` spoofing is rejected. `BYTES_PER_ELEMENT === 1` keeps the
// fallback on byte-oriented views.
return (a instanceof Uint8Array ||
(ArrayBuffer.isView(a) &&
a.constructor.name === 'Uint8Array' &&
'BYTES_PER_ELEMENT' in a &&
a.BYTES_PER_ELEMENT === 1));
}

@@ -8,3 +16,3 @@ /** Asserts something is Uint8Array. */

if (!isBytes(b))
throw new Error('Uint8Array expected');
throw new TypeError('Uint8Array expected');
}

@@ -25,3 +33,3 @@ function isArrayOf(isString, arr) {

if (typeof input !== 'function')
throw new Error('function expected');
throw new TypeError('function expected');
return true;

@@ -31,20 +39,22 @@ }

if (typeof input !== 'string')
throw new Error(`${label}: string expected`);
throw new TypeError(`${label}: string expected`);
return true;
}
function anumber(n) {
if (typeof n !== 'number')
throw new TypeError(`number expected, got ${typeof n}`);
if (!Number.isSafeInteger(n))
throw new Error(`invalid integer: ${n}`);
throw new RangeError(`invalid integer: ${n}`);
}
function aArr(input) {
if (!Array.isArray(input))
throw new Error('array expected');
throw new TypeError('array expected');
}
function astrArr(label, input) {
if (!isArrayOf(true, input))
throw new Error(`${label}: array of strings expected`);
throw new TypeError(`${label}: array of strings expected`);
}
function anumArr(label, input) {
if (!isArrayOf(false, input))
throw new Error(`${label}: array of numbers expected`);
throw new TypeError(`${label}: array of numbers expected`);
}

@@ -102,2 +112,4 @@ /**

astr('join', separator);
// join('') is only lossless when each chunk is already unambiguous, such as single-symbol alphabets.
// Multi-character tokens need a separator that cannot appear inside the chunks.
return {

@@ -124,2 +136,4 @@ encode: (from) => {

astrArr('padding.encode', data);
// Mutates the intermediate token array in place while appending pad chars.
// utils.padding callers that need to preserve their input should pass a copy.
while ((data.length * bits) % 8)

@@ -157,5 +171,5 @@ data.push(chr);

if (from < 2)
throw new Error(`convertRadix: invalid from=${from}, base cannot be less than 2`);
throw new RangeError(`convertRadix: invalid from=${from}, base cannot be less than 2`);
if (to < 2)
throw new Error(`convertRadix: invalid to=${to}, base cannot be less than 2`);
throw new RangeError(`convertRadix: invalid to=${to}, base cannot be less than 2`);
aArr(data);

@@ -202,2 +216,3 @@ if (!data.length)

}
// Preserve explicit leading zero digits so callers like base58 keep zero-prefix semantics.
for (let i = 0; i < data.length - 1 && data[i] === 0; i++)

@@ -208,2 +223,4 @@ res.push(0);

const gcd = (a, b) => (b === 0 ? a : gcd(b, a % b));
// Maximum carry width before the `pos` cycle repeats.
// Residues advance in gcd(from, to) steps, so the largest pre-drain width is from + (to - gcd).
const radix2carry = /* @__NO_SIDE_EFFECTS__ */ (from, to) => from + (to - gcd(from, to));

@@ -222,5 +239,5 @@ const powers = /* @__PURE__ */ (() => {

if (from <= 0 || from > 32)
throw new Error(`convertRadix2: wrong from=${from}`);
throw new RangeError(`convertRadix2: wrong from=${from}`);
if (to <= 0 || to > 32)
throw new Error(`convertRadix2: wrong to=${to}`);
throw new RangeError(`convertRadix2: wrong to=${to}`);
if (radix2carry(from, to) > 32) {

@@ -250,2 +267,4 @@ throw new Error(`convertRadix2: carry overflow from=${from} to=${to} carryBits=${radix2carry(from, to)}`);

carry = (carry << (to - pos)) & mask;
// Canonical decode paths reject leftover whole input words and non-zero pad bits.
// For Bech32 5->8 regrouping, this is the "4 bits or less, all zeroes" tail rule.
if (!padding && pos >= from)

@@ -265,6 +284,7 @@ throw new Error('Excess padding');

const _256 = 2 ** 8;
// Base-range and carry-overflow checks live in convertRadix so encode/decode reject unsupported bases symmetrically.
return {
encode: (bytes) => {
if (!isBytes(bytes))
throw new Error('radix.encode input should be Uint8Array');
throw new TypeError('radix.encode input should be Uint8Array');
return convertRadix(Array.from(bytes), _256, num);

@@ -286,9 +306,11 @@ },

if (bits <= 0 || bits > 32)
throw new Error('radix2: bits should be in (0..32]');
throw new RangeError('radix2: bits should be in (0..32]');
if (radix2carry(8, bits) > 32 || radix2carry(bits, 8) > 32)
throw new Error('radix2: carry overflow');
throw new RangeError('radix2: carry overflow');
// revPadding flips which direction allows a partial zero tail.
// Default pads 8->bits and rejects extra bits on bits->8; `true` does the opposite.
return {
encode: (bytes) => {
if (!isBytes(bytes))
throw new Error('radix2.encode input should be Uint8Array');
throw new TypeError('radix2.encode input should be Uint8Array');
return convertRadix2(Array.from(bytes), 8, bits, !revPadding);

@@ -305,2 +327,4 @@ },

return function (...args) {
// Only for *Unsafe APIs that intentionally collapse validation failures to `undefined`.
// Do not wrap code that needs to preserve exception details.
try {

@@ -314,8 +338,15 @@ return fn.apply(null, args);

anumber(len);
// Reject degenerate zero-byte checksums up front so callers don't accidentally
// build a no-op checksum stage.
if (len <= 0)
throw new RangeError(`checksum length must be positive: ${len}`);
afn(fn);
const _fn = fn;
// Uses the first `len` bytes of fn(data) in both directions.
// Current call sites rely on `len > 0` and checksum functions that return at least that many bytes.
return {
encode(data) {
if (!isBytes(data))
throw new Error('checksum.encode: input should be Uint8Array');
const sum = fn(data).slice(0, len);
throw new TypeError('checksum.encode: input should be Uint8Array');
const sum = _fn(data).slice(0, len);
const res = new Uint8Array(data.length + len);

@@ -328,6 +359,6 @@ res.set(data);

if (!isBytes(data))
throw new Error('checksum.decode: input should be Uint8Array');
throw new TypeError('checksum.decode: input should be Uint8Array');
const payload = data.slice(0, -len);
const oldChecksum = data.slice(-len);
const newChecksum = fn(payload).slice(0, len);
const newChecksum = _fn(payload).slice(0, len);
for (let i = 0; i < len; i++)

@@ -341,5 +372,14 @@ if (newChecksum[i] !== oldChecksum[i])

// prettier-ignore
export const utils = {
/**
* Low-level building blocks used by the exported codecs.
* @example
* Build a radix-32 coder from the low-level helpers.
* ```ts
* import { utils } from '@scure/base';
* utils.radix2(5).encode(Uint8Array.from([1, 2, 3]));
* ```
*/
export const utils = /* @__PURE__ */ Object.freeze({
alphabet, chain, checksum, convertRadix, convertRadix2, radix, radix2, join, padding,
};
});
// RFC 4648 aka RFC 3548

@@ -349,2 +389,5 @@ // ---------------------

* base16 encoding from RFC 4648.
* This codec uses RFC 4648 Table 5's uppercase alphabet directly.
* RFC 4648 §8 calls base16 "case-insensitive hex encoding", but we intentionally do not case-fold decode input here.
* Use `hex` for case-insensitive hex decoding.
* @example

@@ -356,5 +399,7 @@ * ```js

*/
export const base16 = chain(radix2(4), alphabet('0123456789ABCDEF'), join(''));
export const base16 = /* @__PURE__ */ Object.freeze(chain(radix2(4), alphabet('0123456789ABCDEF'), join('')));
/**
* base32 encoding from RFC 4648. Has padding.
* RFC 4648 §6 Table 3 uses uppercase letters, and RFC 4648 §3.4 allows applications to choose
* upper- or lowercase alphabets. We keep the published uppercase table and do not case-fold decode input.
* Use `base32nopad` for unpadded version.

@@ -370,5 +415,6 @@ * Also check out `base32hex`, `base32hexnopad`, `base32crockford`.

*/
export const base32 = chain(radix2(5), alphabet('ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'), padding(5), join(''));
export const base32 = /* @__PURE__ */ Object.freeze(chain(radix2(5), alphabet('ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'), padding(5), join('')));
/**
* base32 encoding from RFC 4648. No padding.
* This variant inherits RFC 4648 base32's uppercase table and intentionally does not case-fold decode input.
* Use `base32` for padded version.

@@ -384,5 +430,6 @@ * Also check out `base32hex`, `base32hexnopad`, `base32crockford`.

*/
export const base32nopad = chain(radix2(5), alphabet('ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'), join(''));
export const base32nopad = /* @__PURE__ */ Object.freeze(chain(radix2(5), alphabet('ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'), join('')));
/**
* base32 encoding from RFC 4648. Padded. Compared to ordinary `base32`, slightly different alphabet.
* RFC 4648 §7 Table 4 uses uppercase letters, and we intentionally keep that table without case-folding decode input.
* Use `base32hexnopad` for unpadded version.

@@ -397,5 +444,6 @@ * @example

*/
export const base32hex = chain(radix2(5), alphabet('0123456789ABCDEFGHIJKLMNOPQRSTUV'), padding(5), join(''));
export const base32hex = /* @__PURE__ */ Object.freeze(chain(radix2(5), alphabet('0123456789ABCDEFGHIJKLMNOPQRSTUV'), padding(5), join('')));
/**
* base32 encoding from RFC 4648. No padding. Compared to ordinary `base32`, slightly different alphabet.
* This variant inherits RFC 4648 base32hex's uppercase table and intentionally does not case-fold decode input.
* Use `base32hex` for padded version.

@@ -410,6 +458,6 @@ * @example

*/
export const base32hexnopad = chain(radix2(5), alphabet('0123456789ABCDEFGHIJKLMNOPQRSTUV'), join(''));
export const base32hexnopad = /* @__PURE__ */ Object.freeze(chain(radix2(5), alphabet('0123456789ABCDEFGHIJKLMNOPQRSTUV'), join('')));
/**
* base32 encoding from RFC 4648. Doug Crockford's version.
* https://www.crockford.com/base32.html
* See {@link https://www.crockford.com/base32.html | Douglas Crockford's Base32}.
* @example

@@ -423,12 +471,19 @@ * ```js

*/
export const base32crockford = chain(radix2(5), alphabet('0123456789ABCDEFGHJKMNPQRSTVWXYZ'), join(''), normalize((s) => s.toUpperCase().replace(/O/g, '0').replace(/[IL]/g, '1')));
export const base32crockford = /* @__PURE__ */ Object.freeze(chain(radix2(5), alphabet('0123456789ABCDEFGHJKMNPQRSTVWXYZ'), join(''), normalize((s) => s.toUpperCase().replace(/O/g, '0').replace(/[IL]/g, '1'))));
// Built-in base64 conversion https://caniuse.com/mdn-javascript_builtins_uint8array_frombase64
// Require both directions before taking the native fast path, so base64/base64url don't mix native and JS behavior.
// prettier-ignore
const hasBase64Builtin = /* @__PURE__ */ (() => typeof Uint8Array.from([]).toBase64 === 'function' &&
typeof Uint8Array.fromBase64 === 'function')();
// Native `Uint8Array.fromBase64()` accepts these ASCII whitespace chars.
// Reject them first so the native base64 path still follows RFC 4648 §3.3.
// ASCII whitespace is U+0009 TAB, U+000A LF, U+000C FF, U+000D CR, or U+0020 SPACE
const ASCII_WHITESPACE = /[\t\n\f\r ]/;
const decodeBase64Builtin = (s, isUrl) => {
astr('base64', s);
const re = isUrl ? /^[A-Za-z0-9=_-]+$/ : /^[A-Za-z0-9=+/]+$/;
const alphabet = isUrl ? 'base64url' : 'base64';
if (s.length > 0 && !re.test(s))
// Per spec, .fromBase64 already throws on any other non-alphabet symbols except ASCII whitespace
// And checking just for whitespace makes decoding about 3x faster than a full range check.
// lastChunkHandling: 'strict' rejects loose tails and non-zero pad bits so native decoding stays canonical.
if (s.length > 0 && ASCII_WHITESPACE.test(s))
throw new Error('invalid base64');

@@ -451,6 +506,6 @@ return Uint8Array.fromBase64(s, { alphabet, lastChunkHandling: 'strict' });

// prettier-ignore
export const base64 = hasBase64Builtin ? {
export const base64 = /* @__PURE__ */ Object.freeze(hasBase64Builtin ? {
encode(b) { abytes(b); return b.toBase64(); },
decode(s) { return decodeBase64Builtin(s, false); },
} : chain(radix2(6), alphabet('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'), padding(6), join(''));
} : chain(radix2(6), alphabet('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'), padding(6), join('')));
/**

@@ -467,3 +522,3 @@ * base64 from RFC 4648. No padding.

*/
export const base64nopad = chain(radix2(6), alphabet('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'), join(''));
export const base64nopad = /* @__PURE__ */ Object.freeze(chain(radix2(6), alphabet('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'), join('')));
/**

@@ -482,6 +537,6 @@ * base64 from RFC 4648, using URL-safe alphabet. Padded.

// prettier-ignore
export const base64url = hasBase64Builtin ? {
export const base64url = /* @__PURE__ */ Object.freeze(hasBase64Builtin ? {
encode(b) { abytes(b); return b.toBase64({ alphabet: 'base64url' }); },
decode(s) { return decodeBase64Builtin(s, true); },
} : chain(radix2(6), alphabet('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_'), padding(6), join(''));
} : chain(radix2(6), alphabet('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_'), padding(6), join('')));
/**

@@ -498,3 +553,3 @@ * base64 from RFC 4648, using URL-safe alphabet. No padding.

*/
export const base64urlnopad = chain(radix2(6), alphabet('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_'), join(''));
export const base64urlnopad = /* @__PURE__ */ Object.freeze(chain(radix2(6), alphabet('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_'), join('')));
// base58 code

@@ -508,16 +563,30 @@ // -----------

* ```js
* base58.decode('01abcdef');
* // => '3UhJW'
* const text = base58.encode(Uint8Array.from([0, 1, 2]));
* base58.decode(text);
* // => Uint8Array.from([0, 1, 2])
* ```
*/
export const base58 = genBase58('123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz');
export const base58 = /* @__PURE__ */ Object.freeze(genBase58('123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'));
/**
* base58: flickr version. Check out `base58`.
* @example
* Round-trip bytes with the Flickr alphabet.
* ```ts
* const text = base58flickr.encode(Uint8Array.from([0, 1, 2]));
* base58flickr.decode(text);
* ```
*/
export const base58flickr = genBase58('123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ');
export const base58flickr = /* @__PURE__ */ Object.freeze(genBase58('123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'));
/**
* base58: XRP version. Check out `base58`.
* @example
* Round-trip bytes with the XRP alphabet.
* ```ts
* const text = base58xrp.encode(Uint8Array.from([0, 1, 2]));
* base58xrp.decode(text);
* ```
*/
export const base58xrp = genBase58('rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz');
// Data len (index) -> encoded block len
export const base58xrp = /* @__PURE__ */ Object.freeze(genBase58('rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz'));
// Data len (index) -> encoded block len.
// Monero pads each 1..8-byte block to this fixed base58 width so decode can recover the tail length.
const XMR_BLOCK_LEN = [0, 2, 3, 5, 6, 7, 9, 10, 11];

@@ -528,5 +597,12 @@ /**

* Block encoding significantly reduces quadratic complexity of base58.
* @example
* Round-trip bytes with the Monero block codec.
* ```ts
* const text = base58xmr.encode(Uint8Array.from([0, 1, 2]));
* base58xmr.decode(text);
* ```
*/
export const base58xmr = {
export const base58xmr = /* @__PURE__ */ Object.freeze({
encode(data) {
abytes(data);
let res = '';

@@ -540,2 +616,3 @@ for (let i = 0; i < data.length; i += 8) {

decode(str) {
astr('base58xmr.decode', str);
let res = [];

@@ -554,15 +631,48 @@ for (let i = 0; i < str.length; i += 11) {

},
};
});
/**
* Method, which creates base58check encoder.
* Requires function, calculating sha256.
* Callers must include any version bytes in `data`; this helper only applies the
* 4-byte double-SHA256 checksum used by Bitcoin Base58Check.
* @param sha256 - Function used to calculate the checksum hash.
* @returns base58check codec using 4 checksum bytes.
* @throws On wrong argument types. {@link TypeError}
* @example
* Create a base58check codec from a SHA-256 implementation.
* ```ts
* import { createBase58check } from '@scure/base';
* import { sha256 } from '@noble/hashes/sha2.js';
* const coder = createBase58check(sha256);
* coder.encode(Uint8Array.from([1, 2, 3]));
* ```
*/
export const createBase58check = (sha256) => chain(checksum(4, (data) => sha256(sha256(data))), base58);
export const createBase58check = (sha256) => {
// Validate the hash function at construction time so wrong inputs fail before returning a coder.
afn(sha256);
const _sha256 = sha256;
return chain(checksum(4, (data) => _sha256(_sha256(data))), base58);
};
/**
* Use `createBase58check` instead.
* @deprecated
* @deprecated Use {@link createBase58check} instead.
* Callers must include any version bytes in `data`; this alias keeps the same
* 4-byte double-SHA256 checksum behavior as `createBase58check`.
* @param sha256 - Function used to calculate the checksum hash.
* @returns base58check codec using 4 checksum bytes.
* @example
* Create a base58check codec with the deprecated alias.
* ```ts
* import { base58check } from '@scure/base';
* import { sha256 } from '@noble/hashes/sha2.js';
* const coder = base58check(sha256);
* coder.encode(Uint8Array.from([1, 2, 3]));
* ```
*/
export const base58check = createBase58check;
// BIP 173 character table: data values 0..31 map to `qpzry9x8gf2tvdw0s3jn54khce6mua7l`.
const BECH_ALPHABET = chain(alphabet('qpzry9x8gf2tvdw0s3jn54khce6mua7l'), join(''));
// BIP 173 `bech32_polymod` GEN coefficients.
const POLYMOD_GENERATORS = [0x3b6a57b2, 0x26508e6d, 0x1ea119fa, 0x3d4233dd, 0x2a1462b3];
// BIP 173 step split: this applies the polymod state transition before callers xor in the next 5-bit value.
function bech32Polymod(pre) {

@@ -593,2 +703,3 @@ const b = pre >> 25;

chk = bech32Polymod(chk);
// BIP 173/BIP 350: xor the final checksum constant, then emit the 30-bit state as six 5-bit symbols.
chk ^= encodingConst;

@@ -601,2 +712,3 @@ return BECH_ALPHABET.encode(convertRadix2([chk % powers[30]], 30, 5, false));

function genBech32(encoding) {
// BIP 173 uses final xor constant 1; BIP 350 swaps in 0x2bc830a3 for Bech32m.
const ENCODING_CONST = encoding === 'bech32' ? 1 : 0x2bc830a3;

@@ -615,2 +727,3 @@ const _words = radix2(5);

throw new TypeError(`Invalid prefix length ${plen}`);
// Total output is hrp + `1` separator + payload words + 6 checksum chars.
const actualLength = plen + 7 + words.length;

@@ -626,2 +739,3 @@ if (limit !== false && actualLength > limit)

const slen = str.length;
// Minimum length is 1-char hrp + `1` separator + 6-char checksum.
if (slen < 8 || (limit !== false && slen > limit))

@@ -648,6 +762,12 @@ throw new TypeError(`invalid string length: ${slen} (${str}). Expected (8..${limit})`);

function decodeToBytes(str) {
// Keep the byte helper unbounded; callers that need the default BIP 173 length cap should use decode(str).
const { prefix, words } = decode(str, false);
return { prefix, words, bytes: fromWords(words) };
return {
prefix,
words,
bytes: fromWords(words),
};
}
function encodeFromBytes(prefix, bytes) {
// Keep the convenience wrapper on encode()'s default 90-char cap; custom limits should call encode(prefix, toWords(bytes), limit).
return encode(prefix, toWords(bytes));

@@ -668,17 +788,175 @@ }

* bech32 from BIP 173. Operates on words.
* For high-level, check out scure-btc-signer:
* https://github.com/paulmillr/scure-btc-signer.
* For high-level helpers, check out {@link https://github.com/paulmillr/scure-btc-signer | scure-btc-signer}.
* @example
* Convert bytes to words, encode them, then decode back.
* ```ts
* const words = bech32.toWords(Uint8Array.from([1, 2, 3]));
* const text = bech32.encode('bc', words);
* bech32.decode(text);
* ```
*/
export const bech32 = genBech32('bech32');
export const bech32 = /* @__PURE__ */ Object.freeze(genBech32('bech32'));
/**
* bech32m from BIP 350. Operates on words.
* It was to mitigate `bech32` weaknesses.
* For high-level, check out scure-btc-signer:
* https://github.com/paulmillr/scure-btc-signer.
* For high-level helpers, check out {@link https://github.com/paulmillr/scure-btc-signer | scure-btc-signer}.
* @example
* Convert bytes to words, encode them with bech32m, then decode back.
* ```ts
* const words = bech32m.toWords(Uint8Array.from([1, 2, 3]));
* const text = bech32m.encode('bc', words);
* bech32m.decode(text);
* ```
*/
export const bech32m = genBech32('bech32m');
export const bech32m = /* @__PURE__ */ Object.freeze(genBech32('bech32m'));
/**
* UTF-8-to-byte decoder. Uses built-in TextDecoder / TextEncoder.
* ASCII-to-byte decoder. Rejects non-ASCII text and bytes instead of doing UTF-8 replacement.
* Method names follow `BytesCoder`, so `encode(bytes)` returns a string and `decode(string)` returns bytes.
* @example
* ```js
* const b = ascii.decode("ABC"); // => new Uint8Array([ 65, 66, 67 ])
* const str = ascii.encode(b); // "ABC"
* ```
*/
export const ascii = /* @__PURE__ */ Object.freeze({
encode(data) {
abytes(data);
let res = '';
for (let i = 0; i < data.length; i++) {
const byte = data[i];
// ASCII is 7-bit; reject bytes outside 0x00..0x7f instead of silently widening to
// Latin-1/UTF-8.
if (byte > 127)
throw new RangeError(`bytes contain non-ASCII byte ${byte} at position ${i}`);
res += String.fromCharCode(byte);
}
return res;
},
decode(str) {
if (typeof str !== 'string')
throw new TypeError('ascii string expected, got ' + typeof str);
const res = new Uint8Array(str.length);
for (let i = 0; i < str.length; i++) {
// Indexed access is much faster than Uint8Array.from(str, mapFn) here and keeps
// exact error positions.
const charCode = str.charCodeAt(i);
if (charCode > 127) {
throw new RangeError(`string contains non-ASCII character "${str[i]}" with code ${charCode} at position ${i}`);
}
res[i] = charCode;
}
return res;
},
});
const _isWellFormedShim = (str) => {
// encodeURI rejects malformed UTF-16, giving a compact fallback that matches native
// isWellFormed on our tests/fuzz corpus.
try {
return encodeURI(str) !== null;
}
catch {
return false;
}
};
const _isWellFormed = /* @__PURE__ */ (() =>
// Pick the native check once so utf8.decode doesn't re-probe String.prototype on every call.
typeof ''.isWellFormed === 'function'
? (str) => str.isWellFormed()
: _isWellFormedShim)();
// This fallback stays small because strict UTF-8 only needs fatal decoding plus well-formed
// UTF-16 checks, not the replacement, streaming, or legacy-encoding behavior of full platform
// text codecs.
const utf8Fallback = /* @__PURE__ */ Object.freeze({
encode(data) {
abytes(data);
let res = '';
for (let i = 0; i < data.length;) {
const a = data[i++];
if (a < 0b1000_0000) {
res += String.fromCharCode(a);
continue;
}
if (a < 0b1100_0010 || i >= data.length)
throw new TypeError(`invalid utf8 at byte ${i - 1}`);
const b = data[i++];
if ((b & 0b1100_0000) !== 0b1000_0000)
throw new TypeError(`invalid utf8 at byte ${i - 1}`);
let cp = ((a & 0b0001_1111) << 6) | (b & 0b0011_1111);
if (a >= 0b1110_0000) {
if (i >= data.length)
throw new TypeError(`invalid utf8 at byte ${i - 1}`);
const c = data[i++];
if ((c & 0b1100_0000) !== 0b1000_0000 ||
(a === 0b1110_0000 && b < 0b1010_0000) ||
(a === 0xed && b >= 0b1010_0000))
throw new TypeError(`invalid utf8 at byte ${i - 1}`);
cp = ((a & 0b0000_1111) << 12) | ((b & 0b0011_1111) << 6) | (c & 0b0011_1111);
if (a >= 0b1111_0000) {
if (i >= data.length)
throw new TypeError(`invalid utf8 at byte ${i - 1}`);
const d = data[i++];
if (a > 0b1111_0100 ||
(d & 0b1100_0000) !== 0b1000_0000 ||
(a === 0b1111_0000 && b < 0b1001_0000) ||
(a === 0b1111_0100 && b >= 0b1001_0000))
throw new TypeError(`invalid utf8 at byte ${i - 1}`);
cp =
((a & 7) << 18) |
((b & 0b0011_1111) << 12) |
((c & 0b0011_1111) << 6) |
(d & 0b0011_1111);
}
}
if (cp < 0x10000)
res += String.fromCharCode(cp);
else {
cp -= 0x10000;
res += String.fromCharCode((cp >> 10) + 0xd800, (cp & 0x3ff) + 0xdc00);
}
}
return res;
},
decode(str) {
astr('utf8', str);
if (!_isWellFormed(str))
throw new TypeError('utf8 expected well-formed string');
// Direct Uint8Array writes are much faster than number[] + Uint8Array.from on Hermes and
// large Node inputs.
const res = new Uint8Array(str.length * 3);
let pos = 0;
for (let i = 0; i < str.length; i++) {
let c = str.charCodeAt(i);
if (c < 0b1000_0000) {
res[pos++] = c;
continue;
}
if (c >= 0xd800 && c <= 0xdfff) {
const d = str.charCodeAt(++i);
c = 0x10000 + ((c - 0xd800) << 10) + d - 0xdc00;
}
if (c >= 0x10000) {
res[pos++] = (c >> 18) | 0b1111_0000;
res[pos++] = ((c >> 12) & 0b0011_1111) | 0b1000_0000;
}
else if (c >= 0x800)
res[pos++] = (c >> 12) | 0b1110_0000;
else
res[pos++] = (c >> 6) | 0b1100_0000;
if (c >= 0x800)
res[pos++] = ((c >> 6) & 0b0011_1111) | 0b1000_0000;
res[pos++] = (c & 0b0011_1111) | 0b1000_0000;
}
return res.subarray(0, pos);
},
});
/**
* Strict UTF-8-to-byte decoder. Uses built-in TextDecoder / TextEncoder when available.
* Method names follow `BytesCoder`, so `encode(bytes)` returns a string and
* `decode(string)` returns bytes.
* `encode(bytes)` requires Uint8Array input, preserves an explicit leading BOM, and
* throws on invalid UTF-8 bytes.
* `decode(string)` requires a primitive string and throws on malformed UTF-16 strings with
* lone surrogates.
* @example
* ```js
* const b = utf8.decode("hey"); // => new Uint8Array([ 104, 101, 121 ])

@@ -688,13 +966,43 @@ * const str = utf8.encode(b); // "hey"

*/
export const utf8 = {
encode: (data) => new TextDecoder().decode(data),
decode: (str) => new TextEncoder().encode(str),
};
export const utf8 = /* @__PURE__ */ (() => {
let _utf8Encoder;
let _utf8Decoder;
const utf8Builtin = {
// ignoreBOM preserves an explicit leading U+FEFF;
// fatal rejects invalid UTF-8 bytes instead of replacing them.
encode(data) {
abytes(data);
return (_utf8Decoder || (_utf8Decoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }))).decode(data);
},
decode(str) {
astr('utf8', str);
if (!_isWellFormed(str))
throw new TypeError('utf8 expected well-formed string');
return (_utf8Encoder || (_utf8Encoder = new TextEncoder())).encode(str);
},
};
return Object.freeze({
// Select each direction once at module init, since
// TextEncoder and TextDecoder can exist independently.
encode: typeof TextDecoder === 'function' ? utf8Builtin.encode : utf8Fallback.encode,
decode: typeof TextEncoder === 'function' ? utf8Builtin.decode : utf8Fallback.decode,
});
})();
// Keep fallback parity probes behind a test-only export until runtime fallback behavior is decided.
export const __TESTS = /* @__PURE__ */ Object.freeze({
utf8Fallback: utf8Fallback,
_isWellFormedShim: _isWellFormedShim,
});
// Built-in hex conversion https://caniuse.com/mdn-javascript_builtins_uint8array_fromhex
// prettier-ignore
const hasHexBuiltin = /* @__PURE__ */ (() => typeof Uint8Array.from([]).toHex === 'function' &&
const hasHexBuiltin = /* @__PURE__ */ (() =>
// Require both directions before enabling the native hex path so encode/decode stay symmetric.
typeof Uint8Array.from([]).toHex === 'function' &&
typeof Uint8Array.fromHex === 'function')();
// prettier-ignore
const hexBuiltin = {
// Keep local type guards so the native path preserves library-level input errors.
// Native toHex emits lowercase hex, matching the fallback alphabet and Node's hex strings.
encode(data) { abytes(data); return data.toHex(); },
// Native fromHex accepts either hex case and rejects odd-length / non-hex syntax.
decode(s) { astr('hex', s); return Uint8Array.fromHex(s); },

@@ -704,2 +1012,3 @@ };

* hex string decoder. Uses built-in function, when available.
* Lowercase codec; unlike `base16`, this variant accepts either hex case and emits lowercase.
* @example

@@ -711,3 +1020,3 @@ * ```js

*/
export const hex = hasHexBuiltin
export const hex = /* @__PURE__ */ Object.freeze(hasHexBuiltin
? hexBuiltin

@@ -718,4 +1027,5 @@ : chain(radix2(4), alphabet('0123456789abcdef'), join(''), normalize((s) => {

return s.toLowerCase();
}));
})));
// prettier-ignore
// Keep this registry aligned with CoderType/coderTypeError; only byte<->string codecs belong here.
const CODERS = {

@@ -725,3 +1035,14 @@ utf8, hex, base16, base32, base64, base64url, base58, base58xmr

const coderTypeError = 'Invalid encoding type. Available types: utf8, hex, base16, base32, base64, base64url, base58, base58xmr';
/** @deprecated */
/**
* Encodes bytes with one of the built-in codecs.
* @deprecated Use the codec directly, for example `hex.encode(bytes)`.
* @param type - Codec name.
* @param bytes - Bytes to encode.
* @returns Encoded string.
* @throws On wrong argument types. {@link TypeError}
* @example
* ```ts
* bytesToString('hex', Uint8Array.from([1, 2, 255]));
* ```
*/
export const bytesToString = (type, bytes) => {

@@ -734,7 +1055,29 @@ if (typeof type !== 'string' || !CODERS.hasOwnProperty(type))

};
/** @deprecated */
/**
* Alias for `bytesToString`.
* @deprecated Use {@link bytesToString} or the codec directly instead.
* @param type - Codec name.
* @param bytes - Bytes to encode.
* @returns Encoded string.
* @example
* ```ts
* str('hex', Uint8Array.from([1, 2, 255]));
* ```
*/
export const str = bytesToString; // as in python, but for bytes only
/** @deprecated */
/**
* Decodes a string with one of the built-in codecs.
* @deprecated Use the codec directly, for example `hex.decode(text)`.
* @param type - Codec name.
* @param str - Encoded string.
* @returns Decoded bytes.
* @throws On wrong argument types. {@link TypeError}
* @example
* ```ts
* stringToBytes('hex', '0102ff');
* ```
*/
export const stringToBytes = (type, str) => {
if (!CODERS.hasOwnProperty(type))
// Match bytesToString's selector validation so hostile `toString()` coercions can't leak custom errors.
if (typeof type !== 'string' || !CODERS.hasOwnProperty(type))
throw new TypeError(coderTypeError);

@@ -745,4 +1088,14 @@ if (typeof str !== 'string')

};
/** @deprecated */
/**
* Alias for `stringToBytes`.
* @deprecated Use {@link stringToBytes} or the codec directly instead.
* @param type - Codec name.
* @param str - Encoded string.
* @returns Decoded bytes.
* @example
* ```ts
* bytes('hex', '0102ff');
* ```
*/
export const bytes = stringToBytes;
//# sourceMappingURL=index.js.map

@@ -1,1 +0,1 @@

{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,oEAAoE;AAYpE,SAAS,OAAO,CAAC,CA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C,CAAC,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,GAAG,GAAyD,aAAa,CAAC,CAAC,mCAAmC;AAE3H;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAAe,EAAE,GAAW,EAAoB,EAAE;IAC9E,wGAAwG;IACxG,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC;QAAE,MAAM,IAAI,SAAS,CAAC,cAAc,CAAC,CAAC;IAClG,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,MAAM,IAAI,SAAS,CAAC,gCAAgC,CAAC,CAAC;IACnF,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,GAAG,CAAqB,CAAC;AACtD,CAAC,CAAC;AACF;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,KAAK,GAAuD,aAAa,CAAC"}
+670
-130
/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */
/** Transforms values between two representations. */
export interface Coder<F, T> {
/**
* Converts a value from the input representation to the output representation.
* @param from - Value in the source representation.
* @returns Converted value.
*/
encode(from: F): T;
/**
* Converts a value from the output representation back to the input representation.
* @param to - Value in the target representation.
* @returns Converted value.
*/
decode(to: T): F;
}
/** Coder that works with byte arrays and strings. */
export interface BytesCoder extends Coder<Uint8Array, string> {
/**
* Encodes bytes into a string representation.
* @param data - Bytes to encode.
* @returns Encoded string.
*/
encode: (data: Uint8Array) => string;
/**
* Decodes a string representation into raw bytes.
* @param str - Encoded string.
* @returns Decoded bytes.
*/
decode: (str: string) => Uint8Array;
}
/**
* Bytes API type helpers for old + new TypeScript.
*
* TS 5.6 has `Uint8Array`, while TS 5.9+ made it generic `Uint8Array<ArrayBuffer>`.
* We can't use specific return type, because TS 5.6 will error.
* We can't use generic return type, because most TS 5.9 software will expect specific type.
*
* Maps typed-array input leaves to broad forms.
* These are compatibility adapters, not ownership guarantees.
*
* - `TArg` keeps byte inputs broad.
* - `TRet` marks byte outputs for TS 5.6 and TS 5.9+ compatibility.
*/
export type TypedArg<T> = T extends BigInt64Array
? BigInt64Array
: T extends BigUint64Array
? BigUint64Array
: T extends Float32Array
? Float32Array
: T extends Float64Array
? Float64Array
: T extends Int16Array
? Int16Array
: T extends Int32Array
? Int32Array
: T extends Int8Array
? Int8Array
: T extends Uint16Array
? Uint16Array
: T extends Uint32Array
? Uint32Array
: T extends Uint8ClampedArray
? Uint8ClampedArray
: T extends Uint8Array
? Uint8Array
: never;
/** Maps typed-array output leaves to narrow TS-compatible forms. */
export type TypedRet<T> = T extends BigInt64Array
? ReturnType<typeof BigInt64Array.of>
: T extends BigUint64Array
? ReturnType<typeof BigUint64Array.of>
: T extends Float32Array
? ReturnType<typeof Float32Array.of>
: T extends Float64Array
? ReturnType<typeof Float64Array.of>
: T extends Int16Array
? ReturnType<typeof Int16Array.of>
: T extends Int32Array
? ReturnType<typeof Int32Array.of>
: T extends Int8Array
? ReturnType<typeof Int8Array.of>
: T extends Uint16Array
? ReturnType<typeof Uint16Array.of>
: T extends Uint32Array
? ReturnType<typeof Uint32Array.of>
: T extends Uint8ClampedArray
? ReturnType<typeof Uint8ClampedArray.of>
: T extends Uint8Array
? ReturnType<typeof Uint8Array.of>
: never;
/** Recursively adapts byte-carrying API input types. See {@link TypedArg}. */
export type TArg<T> =
| T
| ([TypedArg<T>] extends [never]
? T extends (...args: infer A) => infer R
? ((...args: { [K in keyof A]: TRet<A[K]> }) => TArg<R>) & {
[K in keyof T]: T[K] extends (...args: any) => any ? T[K] : TArg<T[K]>;
}
: T extends [infer A, ...infer R]
? [TArg<A>, ...{ [K in keyof R]: TArg<R[K]> }]
: T extends readonly [infer A, ...infer R]
? readonly [TArg<A>, ...{ [K in keyof R]: TArg<R[K]> }]
: T extends (infer A)[]
? TArg<A>[]
: T extends readonly (infer A)[]
? readonly TArg<A>[]
: T extends Promise<infer A>
? Promise<TArg<A>>
: T extends object
? { [K in keyof T]: TArg<T[K]> }
: T
: TypedArg<T>);
/** Recursively adapts byte-carrying API output types. See {@link TypedArg}. */
export type TRet<T> = T extends unknown
? T &
([TypedRet<T>] extends [never]
? T extends (...args: infer A) => infer R
? ((...args: { [K in keyof A]: TArg<A[K]> }) => TRet<R>) & {
[K in keyof T]: T[K] extends (...args: any) => any ? T[K] : TRet<T[K]>;
}
: T extends [infer A, ...infer R]
? [TRet<A>, ...{ [K in keyof R]: TRet<R[K]> }]
: T extends readonly [infer A, ...infer R]
? readonly [TRet<A>, ...{ [K in keyof R]: TRet<R[K]> }]
: T extends (infer A)[]
? TRet<A>[]
: T extends readonly (infer A)[]
? readonly TRet<A>[]
: T extends Promise<infer A>
? Promise<TRet<A>>
: T extends object
? { [K in keyof T]: TRet<T[K]> }
: T
: TypedRet<T>)
: never;
function isBytes(a: unknown): a is Uint8Array {
return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');
// Plain `instanceof Uint8Array` is too strict for some Buffer / proxy / cross-realm cases. The
// fallback still requires a real ArrayBuffer view, so plain JSON-deserialized
// `{ constructor: ... }` spoofing is rejected. `BYTES_PER_ELEMENT === 1` keeps the
// fallback on byte-oriented views.
return (
a instanceof Uint8Array ||
(ArrayBuffer.isView(a) &&
a.constructor.name === 'Uint8Array' &&
'BYTES_PER_ELEMENT' in a &&
a.BYTES_PER_ELEMENT === 1)
);
}
/** Asserts something is Uint8Array. */
function abytes(b: Uint8Array | undefined): void {
if (!isBytes(b)) throw new Error('Uint8Array expected');
function abytes(b: TArg<Uint8Array | undefined>): void {
if (!isBytes(b)) throw new TypeError('Uint8Array expected');
}

@@ -32,3 +170,3 @@

function afn(input: Function): input is Function {
if (typeof input !== 'function') throw new Error('function expected');
if (typeof input !== 'function') throw new TypeError('function expected');
return true;

@@ -38,3 +176,3 @@ }

function astr(label: string, input: unknown): input is string {
if (typeof input !== 'string') throw new Error(`${label}: string expected`);
if (typeof input !== 'string') throw new TypeError(`${label}: string expected`);
return true;

@@ -44,13 +182,14 @@ }

function anumber(n: number): void {
if (!Number.isSafeInteger(n)) throw new Error(`invalid integer: ${n}`);
if (typeof n !== 'number') throw new TypeError(`number expected, got ${typeof n}`);
if (!Number.isSafeInteger(n)) throw new RangeError(`invalid integer: ${n}`);
}
function aArr(input: any[]) {
if (!Array.isArray(input)) throw new Error('array expected');
if (!Array.isArray(input)) throw new TypeError('array expected');
}
function astrArr(label: string, input: string[]) {
if (!isArrayOf(true, input)) throw new Error(`${label}: array of strings expected`);
if (!isArrayOf(true, input)) throw new TypeError(`${label}: array of strings expected`);
}
function anumArr(label: string, input: number[]) {
if (!isArrayOf(false, input)) throw new Error(`${label}: array of numbers expected`);
if (!isArrayOf(false, input)) throw new TypeError(`${label}: array of numbers expected`);
}

@@ -129,2 +268,4 @@

astr('join', separator);
// join('') is only lossless when each chunk is already unambiguous, such as single-symbol alphabets.
// Multi-character tokens need a separator that cannot appear inside the chunks.
return {

@@ -152,2 +293,4 @@ encode: (from) => {

astrArr('padding.encode', data);
// Mutates the intermediate token array in place while appending pad chars.
// utils.padding callers that need to preserve their input should pass a copy.
while ((data.length * bits) % 8) data.push(chr);

@@ -184,4 +327,5 @@ return data;

// base 1 is impossible
if (from < 2) throw new Error(`convertRadix: invalid from=${from}, base cannot be less than 2`);
if (to < 2) throw new Error(`convertRadix: invalid to=${to}, base cannot be less than 2`);
if (from < 2)
throw new RangeError(`convertRadix: invalid from=${from}, base cannot be less than 2`);
if (to < 2) throw new RangeError(`convertRadix: invalid to=${to}, base cannot be less than 2`);
aArr(data);

@@ -224,2 +368,3 @@ if (!data.length) return [];

}
// Preserve explicit leading zero digits so callers like base58 keep zero-prefix semantics.
for (let i = 0; i < data.length - 1 && data[i] === 0; i++) res.push(0);

@@ -230,2 +375,4 @@ return res.reverse();

const gcd = (a: number, b: number): number => (b === 0 ? a : gcd(b, a % b));
// Maximum carry width before the `pos` cycle repeats.
// Residues advance in gcd(from, to) steps, so the largest pre-drain width is from + (to - gcd).
const radix2carry = /* @__NO_SIDE_EFFECTS__ */ (from: number, to: number) =>

@@ -243,4 +390,4 @@ from + (to - gcd(from, to));

aArr(data);
if (from <= 0 || from > 32) throw new Error(`convertRadix2: wrong from=${from}`);
if (to <= 0 || to > 32) throw new Error(`convertRadix2: wrong to=${to}`);
if (from <= 0 || from > 32) throw new RangeError(`convertRadix2: wrong from=${from}`);
if (to <= 0 || to > 32) throw new RangeError(`convertRadix2: wrong to=${to}`);
if (radix2carry(from, to) > 32) {

@@ -268,2 +415,4 @@ throw new Error(

carry = (carry << (to - pos)) & mask;
// Canonical decode paths reject leftover whole input words and non-zero pad bits.
// For Bech32 5->8 regrouping, this is the "4 bits or less, all zeroes" tail rule.
if (!padding && pos >= from) throw new Error('Excess padding');

@@ -278,8 +427,9 @@ if (!padding && carry > 0) throw new Error(`Non-zero padding: ${carry}`);

*/
function radix(num: number): Coder<Uint8Array, number[]> {
function radix(num: number): TRet<Coder<Uint8Array, number[]>> {
anumber(num);
const _256 = 2 ** 8;
// Base-range and carry-overflow checks live in convertRadix so encode/decode reject unsupported bases symmetrically.
return {
encode: (bytes: Uint8Array) => {
if (!isBytes(bytes)) throw new Error('radix.encode input should be Uint8Array');
encode: (bytes: TArg<Uint8Array>) => {
if (!isBytes(bytes)) throw new TypeError('radix.encode input should be Uint8Array');
return convertRadix(Array.from(bytes), _256, num);

@@ -299,10 +449,12 @@ },

*/
function radix2(bits: number, revPadding = false): Coder<Uint8Array, number[]> {
function radix2(bits: number, revPadding = false): TRet<Coder<Uint8Array, number[]>> {
anumber(bits);
if (bits <= 0 || bits > 32) throw new Error('radix2: bits should be in (0..32]');
if (bits <= 0 || bits > 32) throw new RangeError('radix2: bits should be in (0..32]');
if (radix2carry(8, bits) > 32 || radix2carry(bits, 8) > 32)
throw new Error('radix2: carry overflow');
throw new RangeError('radix2: carry overflow');
// revPadding flips which direction allows a partial zero tail.
// Default pads 8->bits and rejects extra bits on bits->8; `true` does the opposite.
return {
encode: (bytes: Uint8Array) => {
if (!isBytes(bytes)) throw new Error('radix2.encode input should be Uint8Array');
encode: (bytes: TArg<Uint8Array>) => {
if (!isBytes(bytes)) throw new TypeError('radix2.encode input should be Uint8Array');
return convertRadix2(Array.from(bytes), 8, bits, !revPadding);

@@ -318,5 +470,8 @@ },

type ArgumentTypes<F extends Function> = F extends (...args: infer A) => any ? A : never;
type BytesFn = (data: TArg<Uint8Array>) => TRet<Uint8Array>;
function unsafeWrapper<T extends (...args: any) => any>(fn: T) {
afn(fn);
return function (...args: ArgumentTypes<T>): ReturnType<T> | void {
// Only for *Unsafe APIs that intentionally collapse validation failures to `undefined`.
// Do not wrap code that needs to preserve exception details.
try {

@@ -328,12 +483,15 @@ return fn.apply(null, args);

function checksum(
len: number,
fn: (data: Uint8Array) => Uint8Array
): Coder<Uint8Array, Uint8Array> {
function checksum(len: number, fn: TArg<BytesFn>): TRet<Coder<Uint8Array, Uint8Array>> {
anumber(len);
// Reject degenerate zero-byte checksums up front so callers don't accidentally
// build a no-op checksum stage.
if (len <= 0) throw new RangeError(`checksum length must be positive: ${len}`);
afn(fn);
const _fn = fn as BytesFn;
// Uses the first `len` bytes of fn(data) in both directions.
// Current call sites rely on `len > 0` and checksum functions that return at least that many bytes.
return {
encode(data: Uint8Array) {
if (!isBytes(data)) throw new Error('checksum.encode: input should be Uint8Array');
const sum = fn(data).slice(0, len);
encode(data: TArg<Uint8Array>) {
if (!isBytes(data)) throw new TypeError('checksum.encode: input should be Uint8Array');
const sum = _fn(data).slice(0, len);
const res = new Uint8Array(data.length + len);

@@ -344,7 +502,7 @@ res.set(data);

},
decode(data: Uint8Array) {
if (!isBytes(data)) throw new Error('checksum.decode: input should be Uint8Array');
decode(data: TArg<Uint8Array>) {
if (!isBytes(data)) throw new TypeError('checksum.decode: input should be Uint8Array');
const payload = data.slice(0, -len);
const oldChecksum = data.slice(-len);
const newChecksum = fn(payload).slice(0, len);
const newChecksum = _fn(payload).slice(0, len);
for (let i = 0; i < len; i++)

@@ -358,5 +516,14 @@ if (newChecksum[i] !== oldChecksum[i]) throw new Error('Invalid checksum');

// prettier-ignore
export const utils: { alphabet: typeof alphabet; chain: typeof chain; checksum: typeof checksum; convertRadix: typeof convertRadix; convertRadix2: typeof convertRadix2; radix: typeof radix; radix2: typeof radix2; join: typeof join; padding: typeof padding; } = {
/**
* Low-level building blocks used by the exported codecs.
* @example
* Build a radix-32 coder from the low-level helpers.
* ```ts
* import { utils } from '@scure/base';
* utils.radix2(5).encode(Uint8Array.from([1, 2, 3]));
* ```
*/
export const utils: { alphabet: typeof alphabet; chain: typeof chain; checksum: typeof checksum; convertRadix: typeof convertRadix; convertRadix2: typeof convertRadix2; radix: typeof radix; radix2: typeof radix2; join: typeof join; padding: typeof padding; } = /* @__PURE__ */ Object.freeze({
alphabet, chain, checksum, convertRadix, convertRadix2, radix, radix2, join, padding,
};
});

@@ -368,2 +535,5 @@ // RFC 4648 aka RFC 3548

* base16 encoding from RFC 4648.
* This codec uses RFC 4648 Table 5's uppercase alphabet directly.
* RFC 4648 §8 calls base16 "case-insensitive hex encoding", but we intentionally do not case-fold decode input here.
* Use `hex` for case-insensitive hex decoding.
* @example

@@ -375,6 +545,10 @@ * ```js

*/
export const base16: BytesCoder = chain(radix2(4), alphabet('0123456789ABCDEF'), join(''));
export const base16: BytesCoder = /* @__PURE__ */ Object.freeze(
chain(radix2(4), alphabet('0123456789ABCDEF'), join(''))
);
/**
* base32 encoding from RFC 4648. Has padding.
* RFC 4648 §6 Table 3 uses uppercase letters, and RFC 4648 §3.4 allows applications to choose
* upper- or lowercase alphabets. We keep the published uppercase table and do not case-fold decode input.
* Use `base32nopad` for unpadded version.

@@ -390,7 +564,4 @@ * Also check out `base32hex`, `base32hexnopad`, `base32crockford`.

*/
export const base32: BytesCoder = chain(
radix2(5),
alphabet('ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'),
padding(5),
join('')
export const base32: BytesCoder = /* @__PURE__ */ Object.freeze(
chain(radix2(5), alphabet('ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'), padding(5), join(''))
);

@@ -400,2 +571,3 @@

* base32 encoding from RFC 4648. No padding.
* This variant inherits RFC 4648 base32's uppercase table and intentionally does not case-fold decode input.
* Use `base32` for padded version.

@@ -411,9 +583,8 @@ * Also check out `base32hex`, `base32hexnopad`, `base32crockford`.

*/
export const base32nopad: BytesCoder = chain(
radix2(5),
alphabet('ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'),
join('')
export const base32nopad: BytesCoder = /* @__PURE__ */ Object.freeze(
chain(radix2(5), alphabet('ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'), join(''))
);
/**
* base32 encoding from RFC 4648. Padded. Compared to ordinary `base32`, slightly different alphabet.
* RFC 4648 §7 Table 4 uses uppercase letters, and we intentionally keep that table without case-folding decode input.
* Use `base32hexnopad` for unpadded version.

@@ -428,7 +599,4 @@ * @example

*/
export const base32hex: BytesCoder = chain(
radix2(5),
alphabet('0123456789ABCDEFGHIJKLMNOPQRSTUV'),
padding(5),
join('')
export const base32hex: BytesCoder = /* @__PURE__ */ Object.freeze(
chain(radix2(5), alphabet('0123456789ABCDEFGHIJKLMNOPQRSTUV'), padding(5), join(''))
);

@@ -438,2 +606,3 @@

* base32 encoding from RFC 4648. No padding. Compared to ordinary `base32`, slightly different alphabet.
* This variant inherits RFC 4648 base32hex's uppercase table and intentionally does not case-fold decode input.
* Use `base32hex` for padded version.

@@ -448,10 +617,8 @@ * @example

*/
export const base32hexnopad: BytesCoder = chain(
radix2(5),
alphabet('0123456789ABCDEFGHIJKLMNOPQRSTUV'),
join('')
export const base32hexnopad: BytesCoder = /* @__PURE__ */ Object.freeze(
chain(radix2(5), alphabet('0123456789ABCDEFGHIJKLMNOPQRSTUV'), join(''))
);
/**
* base32 encoding from RFC 4648. Doug Crockford's version.
* https://www.crockford.com/base32.html
* See {@link https://www.crockford.com/base32.html | Douglas Crockford's Base32}.
* @example

@@ -465,10 +632,13 @@ * ```js

*/
export const base32crockford: BytesCoder = chain(
radix2(5),
alphabet('0123456789ABCDEFGHJKMNPQRSTVWXYZ'),
join(''),
normalize((s: string) => s.toUpperCase().replace(/O/g, '0').replace(/[IL]/g, '1'))
export const base32crockford: BytesCoder = /* @__PURE__ */ Object.freeze(
chain(
radix2(5),
alphabet('0123456789ABCDEFGHJKMNPQRSTVWXYZ'),
join(''),
normalize((s: string) => s.toUpperCase().replace(/O/g, '0').replace(/[IL]/g, '1'))
)
);
// Built-in base64 conversion https://caniuse.com/mdn-javascript_builtins_uint8array_frombase64
// Require both directions before taking the native fast path, so base64/base64url don't mix native and JS behavior.
// prettier-ignore

@@ -479,7 +649,14 @@ const hasBase64Builtin: boolean = /* @__PURE__ */ (() =>

// Native `Uint8Array.fromBase64()` accepts these ASCII whitespace chars.
// Reject them first so the native base64 path still follows RFC 4648 §3.3.
// ASCII whitespace is U+0009 TAB, U+000A LF, U+000C FF, U+000D CR, or U+0020 SPACE
const ASCII_WHITESPACE = /[\t\n\f\r ]/;
const decodeBase64Builtin = (s: string, isUrl: boolean) => {
astr('base64', s);
const re = isUrl ? /^[A-Za-z0-9=_-]+$/ : /^[A-Za-z0-9=+/]+$/;
const alphabet = isUrl ? 'base64url' : 'base64';
if (s.length > 0 && !re.test(s)) throw new Error('invalid base64');
// Per spec, .fromBase64 already throws on any other non-alphabet symbols except ASCII whitespace
// And checking just for whitespace makes decoding about 3x faster than a full range check.
// lastChunkHandling: 'strict' rejects loose tails and non-zero pad bits so native decoding stays canonical.
if (s.length > 0 && ASCII_WHITESPACE.test(s)) throw new Error('invalid base64');
return (Uint8Array as any).fromBase64(s, { alphabet, lastChunkHandling: 'strict' });

@@ -502,3 +679,3 @@ };

// prettier-ignore
export const base64: BytesCoder = hasBase64Builtin ? {
export const base64: BytesCoder = /* @__PURE__ */ Object.freeze(hasBase64Builtin ? {
encode(b) { abytes(b); return (b as any).toBase64(); },

@@ -511,3 +688,3 @@ decode(s) { return decodeBase64Builtin(s, false); },

join('')
);
));
/**

@@ -524,6 +701,8 @@ * base64 from RFC 4648. No padding.

*/
export const base64nopad: BytesCoder = chain(
radix2(6),
alphabet('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'),
join('')
export const base64nopad: BytesCoder = /* @__PURE__ */ Object.freeze(
chain(
radix2(6),
alphabet('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'),
join('')
)
);

@@ -544,3 +723,3 @@

// prettier-ignore
export const base64url: BytesCoder = hasBase64Builtin ? {
export const base64url: BytesCoder = /* @__PURE__ */ Object.freeze(hasBase64Builtin ? {
encode(b) { abytes(b); return (b as any).toBase64({ alphabet: 'base64url' }); },

@@ -553,3 +732,3 @@ decode(s) { return decodeBase64Builtin(s, true); },

join('')
);
));

@@ -567,6 +746,8 @@ /**

*/
export const base64urlnopad: BytesCoder = chain(
radix2(6),
alphabet('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_'),
join('')
export const base64urlnopad: BytesCoder = /* @__PURE__ */ Object.freeze(
chain(
radix2(6),
alphabet('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_'),
join('')
)
);

@@ -584,23 +765,37 @@

* ```js
* base58.decode('01abcdef');
* // => '3UhJW'
* const text = base58.encode(Uint8Array.from([0, 1, 2]));
* base58.decode(text);
* // => Uint8Array.from([0, 1, 2])
* ```
*/
export const base58: BytesCoder = genBase58(
'123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
export const base58: BytesCoder = /* @__PURE__ */ Object.freeze(
genBase58('123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz')
);
/**
* base58: flickr version. Check out `base58`.
* @example
* Round-trip bytes with the Flickr alphabet.
* ```ts
* const text = base58flickr.encode(Uint8Array.from([0, 1, 2]));
* base58flickr.decode(text);
* ```
*/
export const base58flickr: BytesCoder = genBase58(
'123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'
export const base58flickr: BytesCoder = /* @__PURE__ */ Object.freeze(
genBase58('123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ')
);
/**
* base58: XRP version. Check out `base58`.
* @example
* Round-trip bytes with the XRP alphabet.
* ```ts
* const text = base58xrp.encode(Uint8Array.from([0, 1, 2]));
* base58xrp.decode(text);
* ```
*/
export const base58xrp: BytesCoder = genBase58(
'rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz'
export const base58xrp: BytesCoder = /* @__PURE__ */ Object.freeze(
genBase58('rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz')
);
// Data len (index) -> encoded block len
// Data len (index) -> encoded block len.
// Monero pads each 1..8-byte block to this fixed base58 width so decode can recover the tail length.
const XMR_BLOCK_LEN = [0, 2, 3, 5, 6, 7, 9, 10, 11];

@@ -612,5 +807,12 @@

* Block encoding significantly reduces quadratic complexity of base58.
* @example
* Round-trip bytes with the Monero block codec.
* ```ts
* const text = base58xmr.encode(Uint8Array.from([0, 1, 2]));
* base58xmr.decode(text);
* ```
*/
export const base58xmr: BytesCoder = {
encode(data: Uint8Array) {
export const base58xmr: BytesCoder = /* @__PURE__ */ Object.freeze({
encode(data: TArg<Uint8Array>) {
abytes(data);
let res = '';

@@ -624,2 +826,3 @@ for (let i = 0; i < data.length; i += 8) {

decode(str: string) {
astr('base58xmr.decode', str);
let res: number[] = [];

@@ -637,3 +840,3 @@ for (let i = 0; i < str.length; i += 11) {

},
};
});

@@ -643,28 +846,64 @@ /**

* Requires function, calculating sha256.
* Callers must include any version bytes in `data`; this helper only applies the
* 4-byte double-SHA256 checksum used by Bitcoin Base58Check.
* @param sha256 - Function used to calculate the checksum hash.
* @returns base58check codec using 4 checksum bytes.
* @throws On wrong argument types. {@link TypeError}
* @example
* Create a base58check codec from a SHA-256 implementation.
* ```ts
* import { createBase58check } from '@scure/base';
* import { sha256 } from '@noble/hashes/sha2.js';
* const coder = createBase58check(sha256);
* coder.encode(Uint8Array.from([1, 2, 3]));
* ```
*/
export const createBase58check = (sha256: (data: Uint8Array) => Uint8Array): BytesCoder =>
chain(
checksum(4, (data) => sha256(sha256(data))),
export const createBase58check = (sha256: TArg<BytesFn>): BytesCoder => {
// Validate the hash function at construction time so wrong inputs fail before returning a coder.
afn(sha256);
const _sha256 = sha256 as BytesFn;
return chain(
checksum(4, (data: TArg<Uint8Array>) => _sha256(_sha256(data))),
base58
);
};
/**
* Use `createBase58check` instead.
* @deprecated
* @deprecated Use {@link createBase58check} instead.
* Callers must include any version bytes in `data`; this alias keeps the same
* 4-byte double-SHA256 checksum behavior as `createBase58check`.
* @param sha256 - Function used to calculate the checksum hash.
* @returns base58check codec using 4 checksum bytes.
* @example
* Create a base58check codec with the deprecated alias.
* ```ts
* import { base58check } from '@scure/base';
* import { sha256 } from '@noble/hashes/sha2.js';
* const coder = base58check(sha256);
* coder.encode(Uint8Array.from([1, 2, 3]));
* ```
*/
export const base58check: (sha256: (data: Uint8Array) => Uint8Array) => BytesCoder =
createBase58check;
export const base58check: (sha256: TArg<BytesFn>) => BytesCoder = createBase58check;
// Bech32 code
// -----------
/** Result of bech32 decoding. */
export interface Bech32Decoded<Prefix extends string = string> {
/** Human-readable bech32 prefix. */
prefix: Prefix;
/** Decoded 5-bit word payload. */
words: number[];
}
/** Result of bech32 decoding with original bytes attached. */
export interface Bech32DecodedWithArray<Prefix extends string = string> {
/** Human-readable bech32 prefix. */
prefix: Prefix;
/** Decoded 5-bit word payload. */
words: number[];
/** Decoded payload converted back into raw bytes. */
bytes: Uint8Array;
}
// BIP 173 character table: data values 0..31 map to `qpzry9x8gf2tvdw0s3jn54khce6mua7l`.
const BECH_ALPHABET: Coder<number[], string> = chain(

@@ -675,3 +914,5 @@ alphabet('qpzry9x8gf2tvdw0s3jn54khce6mua7l'),

// BIP 173 `bech32_polymod` GEN coefficients.
const POLYMOD_GENERATORS = [0x3b6a57b2, 0x26508e6d, 0x1ea119fa, 0x3d4233dd, 0x2a1462b3];
// BIP 173 step split: this applies the polymod state transition before callers xor in the next 5-bit value.
function bech32Polymod(pre: number): number {

@@ -698,2 +939,3 @@ const b = pre >> 25;

for (let i = 0; i < 6; i++) chk = bech32Polymod(chk);
// BIP 173/BIP 350: xor the final checksum constant, then emit the 30-bit state as six 5-bit symbols.
chk ^= encodingConst;

@@ -703,3 +945,11 @@ return BECH_ALPHABET.encode(convertRadix2([chk % powers[30]!], 30, 5, false));

/** bech32 codec surface. */
export interface Bech32 {
/**
* Encodes a human-readable prefix and 5-bit words into a bech32 string.
* @param prefix - Human-readable prefix.
* @param words - 5-bit words or raw bytes.
* @param limit - Maximum accepted output length, or `false` to disable the limit.
* @returns Encoded bech32 string.
*/
encode<Prefix extends string>(

@@ -710,2 +960,8 @@ prefix: Prefix,

): `${Lowercase<Prefix>}1${string}`;
/**
* Decodes a bech32 string into prefix and words.
* @param str - Encoded bech32 string.
* @param limit - Maximum accepted input length, or `false` to disable the limit.
* @returns Decoded prefix and 5-bit words.
*/
decode<Prefix extends string>(

@@ -715,7 +971,40 @@ str: `${Prefix}1${string}`,

): Bech32Decoded<Prefix>;
decode(str: string, limit?: number | false): Bech32Decoded;
/**
* Encodes raw bytes by first converting them to 5-bit words.
* @param prefix - Human-readable prefix.
* @param bytes - Raw bytes to encode.
* @returns Encoded bech32 string.
*/
encodeFromBytes(prefix: string, bytes: Uint8Array): string;
/**
* Decodes a bech32 string and converts the payload back into bytes.
* @param str - Encoded bech32 string.
* @returns Decoded prefix, words, and bytes.
*/
decodeToBytes(str: string): Bech32DecodedWithArray;
/**
* Decodes a bech32 string, returning `undefined` instead of throwing on invalid input.
* @param str - Encoded bech32 string.
* @param limit - Maximum accepted input length, or `false` to disable the limit.
* @returns Decoded prefix and words, or `undefined` for invalid input.
*/
decodeUnsafe(str: string, limit?: number | false): void | Bech32Decoded<string>;
/**
* Converts 5-bit words back into raw bytes.
* @param to - 5-bit words to decode.
* @returns Decoded bytes.
*/
fromWords(to: number[]): Uint8Array;
/**
* Converts 5-bit words back into raw bytes, returning `undefined` instead of throwing.
* @param to - 5-bit words to decode.
* @returns Decoded bytes, or `undefined` for invalid input.
*/
fromWordsUnsafe(to: number[]): void | Uint8Array;
/**
* Converts raw bytes into 5-bit words for bech32 encoding.
* @param from - Raw bytes to convert.
* @returns 5-bit words.
*/
toWords(from: Uint8Array): number[];

@@ -726,3 +1015,4 @@ }

*/
function genBech32(encoding: 'bech32' | 'bech32m'): Bech32 {
function genBech32(encoding: 'bech32' | 'bech32m'): TRet<Bech32> {
// BIP 173 uses final xor constant 1; BIP 350 swaps in 0x2bc830a3 for Bech32m.
const ENCODING_CONST = encoding === 'bech32' ? 1 : 0x2bc830a3;

@@ -736,3 +1026,3 @@ const _words = radix2(5);

prefix: Prefix,
words: number[] | Uint8Array,
words: TArg<number[] | Uint8Array>,
limit: number | false = 90

@@ -745,2 +1035,3 @@ ): `${Lowercase<Prefix>}1${string}` {

if (plen === 0) throw new TypeError(`Invalid prefix length ${plen}`);
// Total output is hrp + `1` separator + payload words + 6 checksum chars.
const actualLength = plen + 7 + words.length;

@@ -762,2 +1053,3 @@ if (limit !== false && actualLength > limit)

const slen = str.length;
// Minimum length is 1-char hrp + `1` separator + 6-char checksum.
if (slen < 8 || (limit !== false && slen > limit))

@@ -783,8 +1075,14 @@ throw new TypeError(`invalid string length: ${slen} (${str}). Expected (8..${limit})`);

function decodeToBytes(str: string): Bech32DecodedWithArray {
function decodeToBytes(str: string): TRet<Bech32DecodedWithArray> {
// Keep the byte helper unbounded; callers that need the default BIP 173 length cap should use decode(str).
const { prefix, words } = decode(str, false);
return { prefix, words, bytes: fromWords(words) };
return {
prefix,
words,
bytes: fromWords(words) as TRet<Uint8Array>,
} as TRet<Bech32DecodedWithArray>;
}
function encodeFromBytes(prefix: string, bytes: Uint8Array) {
function encodeFromBytes(prefix: string, bytes: TArg<Uint8Array>) {
// Keep the convenience wrapper on encode()'s default 90-char cap; custom limits should call encode(prefix, toWords(bytes), limit).
return encode(prefix, toWords(bytes));

@@ -807,6 +1105,12 @@ }

* bech32 from BIP 173. Operates on words.
* For high-level, check out scure-btc-signer:
* https://github.com/paulmillr/scure-btc-signer.
* For high-level helpers, check out {@link https://github.com/paulmillr/scure-btc-signer | scure-btc-signer}.
* @example
* Convert bytes to words, encode them, then decode back.
* ```ts
* const words = bech32.toWords(Uint8Array.from([1, 2, 3]));
* const text = bech32.encode('bc', words);
* bech32.decode(text);
* ```
*/
export const bech32: Bech32 = genBech32('bech32');
export const bech32: TRet<Bech32> = /* @__PURE__ */ Object.freeze(genBech32('bech32'));

@@ -816,6 +1120,12 @@ /**

* It was to mitigate `bech32` weaknesses.
* For high-level, check out scure-btc-signer:
* https://github.com/paulmillr/scure-btc-signer.
* For high-level helpers, check out {@link https://github.com/paulmillr/scure-btc-signer | scure-btc-signer}.
* @example
* Convert bytes to words, encode them with bech32m, then decode back.
* ```ts
* const words = bech32m.toWords(Uint8Array.from([1, 2, 3]));
* const text = bech32m.encode('bc', words);
* bech32m.decode(text);
* ```
*/
export const bech32m: Bech32 = genBech32('bech32m');
export const bech32m: TRet<Bech32> = /* @__PURE__ */ Object.freeze(genBech32('bech32m'));

@@ -826,5 +1136,146 @@ declare const TextEncoder: any;

/**
* UTF-8-to-byte decoder. Uses built-in TextDecoder / TextEncoder.
* ASCII-to-byte decoder. Rejects non-ASCII text and bytes instead of doing UTF-8 replacement.
* Method names follow `BytesCoder`, so `encode(bytes)` returns a string and `decode(string)` returns bytes.
* @example
* ```js
* const b = ascii.decode("ABC"); // => new Uint8Array([ 65, 66, 67 ])
* const str = ascii.encode(b); // "ABC"
* ```
*/
export const ascii: TRet<BytesCoder> = /* @__PURE__ */ Object.freeze({
encode(data: TArg<Uint8Array>) {
abytes(data);
let res = '';
for (let i = 0; i < data.length; i++) {
const byte = data[i]!;
// ASCII is 7-bit; reject bytes outside 0x00..0x7f instead of silently widening to
// Latin-1/UTF-8.
if (byte > 127) throw new RangeError(`bytes contain non-ASCII byte ${byte} at position ${i}`);
res += String.fromCharCode(byte);
}
return res;
},
decode(str: string) {
if (typeof str !== 'string') throw new TypeError('ascii string expected, got ' + typeof str);
const res = new Uint8Array(str.length);
for (let i = 0; i < str.length; i++) {
// Indexed access is much faster than Uint8Array.from(str, mapFn) here and keeps
// exact error positions.
const charCode = str.charCodeAt(i);
if (charCode > 127) {
throw new RangeError(
`string contains non-ASCII character "${str[i]}" with code ${charCode} at position ${i}`
);
}
res[i] = charCode;
}
return res;
},
});
const _isWellFormedShim = (str: string): boolean => {
// encodeURI rejects malformed UTF-16, giving a compact fallback that matches native
// isWellFormed on our tests/fuzz corpus.
try {
return encodeURI(str) !== null;
} catch {
return false;
}
};
const _isWellFormed: (str: string) => boolean = /* @__PURE__ */ (() =>
// Pick the native check once so utf8.decode doesn't re-probe String.prototype on every call.
typeof ('' as any).isWellFormed === 'function'
? (str) => (str as any).isWellFormed()
: _isWellFormedShim)();
// This fallback stays small because strict UTF-8 only needs fatal decoding plus well-formed
// UTF-16 checks, not the replacement, streaming, or legacy-encoding behavior of full platform
// text codecs.
const utf8Fallback: BytesCoder = /* @__PURE__ */ Object.freeze({
encode(data: TArg<Uint8Array>) {
abytes(data);
let res = '';
for (let i = 0; i < data.length; ) {
const a = data[i++]!;
if (a < 0b1000_0000) {
res += String.fromCharCode(a);
continue;
}
if (a < 0b1100_0010 || i >= data.length) throw new TypeError(`invalid utf8 at byte ${i - 1}`);
const b = data[i++]!;
if ((b & 0b1100_0000) !== 0b1000_0000) throw new TypeError(`invalid utf8 at byte ${i - 1}`);
let cp = ((a & 0b0001_1111) << 6) | (b & 0b0011_1111);
if (a >= 0b1110_0000) {
if (i >= data.length) throw new TypeError(`invalid utf8 at byte ${i - 1}`);
const c = data[i++]!;
if (
(c & 0b1100_0000) !== 0b1000_0000 ||
(a === 0b1110_0000 && b < 0b1010_0000) ||
(a === 0xed && b >= 0b1010_0000)
)
throw new TypeError(`invalid utf8 at byte ${i - 1}`);
cp = ((a & 0b0000_1111) << 12) | ((b & 0b0011_1111) << 6) | (c & 0b0011_1111);
if (a >= 0b1111_0000) {
if (i >= data.length) throw new TypeError(`invalid utf8 at byte ${i - 1}`);
const d = data[i++]!;
if (
a > 0b1111_0100 ||
(d & 0b1100_0000) !== 0b1000_0000 ||
(a === 0b1111_0000 && b < 0b1001_0000) ||
(a === 0b1111_0100 && b >= 0b1001_0000)
)
throw new TypeError(`invalid utf8 at byte ${i - 1}`);
cp =
((a & 7) << 18) |
((b & 0b0011_1111) << 12) |
((c & 0b0011_1111) << 6) |
(d & 0b0011_1111);
}
}
if (cp < 0x10000) res += String.fromCharCode(cp);
else {
cp -= 0x10000;
res += String.fromCharCode((cp >> 10) + 0xd800, (cp & 0x3ff) + 0xdc00);
}
}
return res;
},
decode(str: string) {
astr('utf8', str);
if (!_isWellFormed(str)) throw new TypeError('utf8 expected well-formed string');
// Direct Uint8Array writes are much faster than number[] + Uint8Array.from on Hermes and
// large Node inputs.
const res = new Uint8Array(str.length * 3);
let pos = 0;
for (let i = 0; i < str.length; i++) {
let c = str.charCodeAt(i);
if (c < 0b1000_0000) {
res[pos++] = c;
continue;
}
if (c >= 0xd800 && c <= 0xdfff) {
const d = str.charCodeAt(++i);
c = 0x10000 + ((c - 0xd800) << 10) + d - 0xdc00;
}
if (c >= 0x10000) {
res[pos++] = (c >> 18) | 0b1111_0000;
res[pos++] = ((c >> 12) & 0b0011_1111) | 0b1000_0000;
} else if (c >= 0x800) res[pos++] = (c >> 12) | 0b1110_0000;
else res[pos++] = (c >> 6) | 0b1100_0000;
if (c >= 0x800) res[pos++] = ((c >> 6) & 0b0011_1111) | 0b1000_0000;
res[pos++] = (c & 0b0011_1111) | 0b1000_0000;
}
return res.subarray(0, pos);
},
});
/**
* Strict UTF-8-to-byte decoder. Uses built-in TextDecoder / TextEncoder when available.
* Method names follow `BytesCoder`, so `encode(bytes)` returns a string and
* `decode(string)` returns bytes.
* `encode(bytes)` requires Uint8Array input, preserves an explicit leading BOM, and
* throws on invalid UTF-8 bytes.
* `decode(string)` requires a primitive string and throws on malformed UTF-16 strings with
* lone surrogates.
* @example
* ```js
* const b = utf8.decode("hey"); // => new Uint8Array([ 104, 101, 121 ])

@@ -834,6 +1285,35 @@ * const str = utf8.encode(b); // "hey"

*/
export const utf8: BytesCoder = {
encode: (data) => new TextDecoder().decode(data),
decode: (str) => new TextEncoder().encode(str),
};
export const utf8: BytesCoder = /* @__PURE__ */ (() => {
let _utf8Encoder: any;
let _utf8Decoder: any;
const utf8Builtin: BytesCoder = {
// ignoreBOM preserves an explicit leading U+FEFF;
// fatal rejects invalid UTF-8 bytes instead of replacing them.
encode(data) {
abytes(data);
return (
_utf8Decoder || (_utf8Decoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }))
).decode(data);
},
decode(str) {
astr('utf8', str);
if (!_isWellFormed(str)) throw new TypeError('utf8 expected well-formed string');
return (_utf8Encoder || (_utf8Encoder = new TextEncoder())).encode(str);
},
};
return Object.freeze({
// Select each direction once at module init, since
// TextEncoder and TextDecoder can exist independently.
encode: typeof TextDecoder === 'function' ? utf8Builtin.encode : utf8Fallback.encode,
decode: typeof TextEncoder === 'function' ? utf8Builtin.decode : utf8Fallback.decode,
});
})();
// Keep fallback parity probes behind a test-only export until runtime fallback behavior is decided.
export const __TESTS: {
utf8Fallback: BytesCoder;
_isWellFormedShim: (str: string) => boolean;
} = /* @__PURE__ */ Object.freeze({
utf8Fallback: utf8Fallback,
_isWellFormedShim: _isWellFormedShim,
});

@@ -843,2 +1323,3 @@ // Built-in hex conversion https://caniuse.com/mdn-javascript_builtins_uint8array_fromhex

const hasHexBuiltin: boolean = /* @__PURE__ */ (() =>
// Require both directions before enabling the native hex path so encode/decode stay symmetric.
typeof (Uint8Array as any).from([]).toHex === 'function' &&

@@ -848,3 +1329,6 @@ typeof (Uint8Array as any).fromHex === 'function')();

const hexBuiltin: BytesCoder = {
// Keep local type guards so the native path preserves library-level input errors.
// Native toHex emits lowercase hex, matching the fallback alphabet and Node's hex strings.
encode(data) { abytes(data); return (data as any).toHex(); },
// Native fromHex accepts either hex case and rejects odd-length / non-hex syntax.
decode(s) { astr('hex', s); return (Uint8Array as any).fromHex(s); },

@@ -854,2 +1338,3 @@ };

* hex string decoder. Uses built-in function, when available.
* Lowercase codec; unlike `base16`, this variant accepts either hex case and emits lowercase.
* @example

@@ -861,28 +1346,40 @@ * ```js

*/
export const hex: BytesCoder = hasHexBuiltin
? hexBuiltin
: chain(
radix2(4),
alphabet('0123456789abcdef'),
join(''),
normalize((s: string) => {
if (typeof s !== 'string' || s.length % 2 !== 0)
throw new TypeError(
`hex.decode: expected string, got ${typeof s} with length ${s.length}`
);
return s.toLowerCase();
})
);
export const hex: BytesCoder = /* @__PURE__ */ Object.freeze(
hasHexBuiltin
? hexBuiltin
: chain(
radix2(4),
alphabet('0123456789abcdef'),
join(''),
normalize((s: string) => {
if (typeof s !== 'string' || s.length % 2 !== 0)
throw new TypeError(
`hex.decode: expected string, got ${typeof s} with length ${s.length}`
);
return s.toLowerCase();
})
)
);
/** Built-in codecs exposed through the deprecated string conversion helpers. */
export type SomeCoders = {
/** UTF-8 string codec. */
utf8: BytesCoder;
/** Hex codec. */
hex: BytesCoder;
/** Uppercase RFC 4648 base16 codec. */
base16: BytesCoder;
/** RFC 4648 base32 codec with padding. */
base32: BytesCoder;
/** RFC 4648 base64 codec with padding. */
base64: BytesCoder;
/** URL-safe base64 codec without `+` or `/`. */
base64url: BytesCoder;
/** Bitcoin-style base58 codec. */
base58: BytesCoder;
/** Monero-style base58 codec. */
base58xmr: BytesCoder;
};
// prettier-ignore
// Keep this registry aligned with CoderType/coderTypeError; only byte<->string codecs belong here.
const CODERS: SomeCoders = {

@@ -895,4 +1392,15 @@ utf8, hex, base16, base32, base64, base64url, base58, base58xmr

/** @deprecated */
export const bytesToString = (type: CoderType, bytes: Uint8Array): string => {
/**
* Encodes bytes with one of the built-in codecs.
* @deprecated Use the codec directly, for example `hex.encode(bytes)`.
* @param type - Codec name.
* @param bytes - Bytes to encode.
* @returns Encoded string.
* @throws On wrong argument types. {@link TypeError}
* @example
* ```ts
* bytesToString('hex', Uint8Array.from([1, 2, 255]));
* ```
*/
export const bytesToString = (type: CoderType, bytes: TArg<Uint8Array>): string => {
if (typeof type !== 'string' || !CODERS.hasOwnProperty(type)) throw new TypeError(coderTypeError);

@@ -903,12 +1411,44 @@ if (!isBytes(bytes)) throw new TypeError('bytesToString() expects Uint8Array');

/** @deprecated */
export const str: (type: CoderType, bytes: Uint8Array) => string = bytesToString; // as in python, but for bytes only
/**
* Alias for `bytesToString`.
* @deprecated Use {@link bytesToString} or the codec directly instead.
* @param type - Codec name.
* @param bytes - Bytes to encode.
* @returns Encoded string.
* @example
* ```ts
* str('hex', Uint8Array.from([1, 2, 255]));
* ```
*/
export const str: (type: CoderType, bytes: TArg<Uint8Array>) => string = bytesToString; // as in python, but for bytes only
/** @deprecated */
export const stringToBytes = (type: CoderType, str: string): Uint8Array => {
if (!CODERS.hasOwnProperty(type)) throw new TypeError(coderTypeError);
/**
* Decodes a string with one of the built-in codecs.
* @deprecated Use the codec directly, for example `hex.decode(text)`.
* @param type - Codec name.
* @param str - Encoded string.
* @returns Decoded bytes.
* @throws On wrong argument types. {@link TypeError}
* @example
* ```ts
* stringToBytes('hex', '0102ff');
* ```
*/
export const stringToBytes = (type: CoderType, str: string): TRet<Uint8Array> => {
// Match bytesToString's selector validation so hostile `toString()` coercions can't leak custom errors.
if (typeof type !== 'string' || !CODERS.hasOwnProperty(type)) throw new TypeError(coderTypeError);
if (typeof str !== 'string') throw new TypeError('stringToBytes() expects string');
return CODERS[type].decode(str);
return CODERS[type].decode(str) as TRet<Uint8Array>;
};
/** @deprecated */
export const bytes: (type: CoderType, str: string) => Uint8Array = stringToBytes;
/**
* Alias for `stringToBytes`.
* @deprecated Use {@link stringToBytes} or the codec directly instead.
* @param type - Codec name.
* @param str - Encoded string.
* @returns Decoded bytes.
* @example
* ```ts
* bytes('hex', '0102ff');
* ```
*/
export const bytes: (type: CoderType, str: string) => TRet<Uint8Array> = stringToBytes;
{
"name": "@scure/base",
"version": "2.0.0",
"version": "2.2.0",
"description": "Secure, audited & 0-dep implementation of base64, bech32, base58, base32 & base16",

@@ -13,8 +13,8 @@ "files": [

"devDependencies": {
"@noble/hashes": "2.0.0",
"@paulmillr/jsbt": "0.4.4",
"@types/node": "24.2.1",
"@noble/hashes": "2.2.0",
"@paulmillr/jsbt": "0.5.0",
"@types/node": "25.3.0",
"fast-check": "4.2.0",
"prettier": "3.6.2",
"typescript": "5.9.2"
"typescript": "6.0.2"
},

@@ -25,2 +25,6 @@ "scripts": {

"build:release": "npx --no @paulmillr/jsbt esbuild test/build",
"check": "npx --no @paulmillr/jsbt check package.json",
"check:readme": "npx --no @paulmillr/jsbt readme package.json",
"check:treeshake": "npx --no @paulmillr/jsbt treeshake package.json test/build/out-treeshake",
"check:jsdoc": "npx --no @paulmillr/jsbt tsdoc package.json",
"format": "prettier --write index.ts test/*.test.ts",

@@ -27,0 +31,0 @@ "test": "node test/index.ts",

+38
-14

@@ -71,9 +71,30 @@ # scure-base

> `npm install @noble/hashes`
```js
import { createBase58check } from '@scure/base';
import { sha256 } from '@noble/hashes/sha2.js';
const data = Uint8Array.from([1, 2, 3]);
createBase58check(sha256).encode(data);
```
## Bech32, Bech32m and Bitcoin
```js
import { bech32 } from '@scure/base';
const words = bech32.toWords(new TextEncoder().encode('hello'));
const addr = bech32.encode('test', words);
console.log(addr); // "test1w508d6qejxtdg4"
const { prefix, words: decoded } = bech32.decode(addr);
console.log(prefix); // "test"
console.log(new TextDecoder().decode(bech32.fromWords(decoded))); // "hello"
console.log(bech32.decodeUnsafe('invalid')); // undefined
```
We provide low-level bech32 operations.

@@ -95,2 +116,5 @@ If you need high-level methods for BTC (addresses, and others), use

```ts
import { bech32 } from '@scure/base';
const address = bech32.encode('bc', [0, ...bech32.toWords(new Uint8Array(20))]);
const decoded = bech32.decode(address);

@@ -180,7 +204,9 @@ // NOTE: words in bitcoin addresses contain version as first element,

The library has been independently audited:
The library has been audited:
- at version 1.0.0, in Jan 2022, by [cure53](https://cure53.de)
- at version 2.2.0, in Apr 2026, by ourselves (self-audited)
- Scope: everything
- [Changes since audit](https://github.com/paulmillr/scure-base/compare/2.2.0..main)
- at version 1.0.0, in Jan 2022, independently, by [cure53](https://cure53.de)
- PDFs: [online](https://cure53.de/pentest-report_hashing-libs.pdf), [offline](./audit/2022-01-05-cure53-audit-nbl2.pdf)
- [Changes since audit](https://github.com/paulmillr/scure-base/compare/1.0.0..main).
- The audit has been funded by [Ethereum Foundation](https://ethereum.org/en/) with help of [Nomic Labs](https://nomiclabs.io)

@@ -195,16 +221,14 @@

- **Commits** are signed with PGP keys, to prevent forgery. Make sure to verify commit signatures
- **Releases** are transparent and built on GitHub CI. Make sure to verify [provenance](https://docs.npmjs.com/generating-provenance-statements) logs
- Use GitHub CLI to verify single-file builds:
`gh attestation verify --owner paulmillr scure-base.js`
- **Rare releasing** is followed to ensure less re-audit need for end-users
- **Dependencies** are minimized and locked-down: any dependency could get hacked and users will be downloading malware with every install.
- We make sure to use as few dependencies as possible
- Automatic dep updates are prevented by locking-down version ranges; diffs are checked with `npm-diff`
- **Dev Dependencies** are disabled for end-users; they are only used to develop / build the source code
- **Commits** are signed with PGP keys to prevent forgery. Be sure to verify the commit signatures
- **Releases** are made transparently through token-less GitHub CI and Trusted Publishing. Be sure to verify the [provenance logs](https://docs.npmjs.com/generating-provenance-statements) for authenticity.
- **Rare releasing** is practiced to minimize the need for re-audits by end-users.
- **Dependencies** are minimized and strictly pinned to reduce supply-chain risk.
- We use as few dependencies as possible.
- Version ranges are locked, and changes are checked with npm-diff.
- **Dev dependencies** are excluded from end-user installs; they’re only used for development and build steps.
For this package, there are 0 dependencies; and a few dev dependencies:
- micro-bmark, micro-should and jsbt are used for benchmarking / testing / build tooling and developed by the same author
- prettier, fast-check and typescript are used for code quality / test generation / ts compilation. It's hard to audit their source code thoroughly and fully because of their size
- jsbt is used for benchmarking / testing / build tooling and developed by the same author
- prettier, fast-check and typescript are used for code quality / test generation / ts compilation

@@ -211,0 +235,0 @@ ## Contributing & testing