@taquito/signer 25.1.0 → 25.2.0-beta0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,555 +0,0 @@
1
- /*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */
2
- /** Transforms values between two representations. */
3
- export interface Coder<F, T> {
4
- /**
5
- * Converts a value from the input representation to the output representation.
6
- * @param from - Value in the source representation.
7
- * @returns Converted value.
8
- */
9
- encode(from: F): T;
10
- /**
11
- * Converts a value from the output representation back to the input representation.
12
- * @param to - Value in the target representation.
13
- * @returns Converted value.
14
- */
15
- decode(to: T): F;
16
- }
17
- /** Coder that works with byte arrays and strings. */
18
- export interface BytesCoder extends Coder<Uint8Array, string> {
19
- /**
20
- * Encodes bytes into a string representation.
21
- * @param data - Bytes to encode.
22
- * @returns Encoded string.
23
- */
24
- encode: (data: Uint8Array) => string;
25
- /**
26
- * Decodes a string representation into raw bytes.
27
- * @param str - Encoded string.
28
- * @returns Decoded bytes.
29
- */
30
- decode: (str: string) => Uint8Array;
31
- }
32
- /**
33
- * Bytes API type helpers for old + new TypeScript.
34
- *
35
- * TS 5.6 has `Uint8Array`, while TS 5.9+ made it generic `Uint8Array<ArrayBuffer>`.
36
- * We can't use specific return type, because TS 5.6 will error.
37
- * We can't use generic return type, because most TS 5.9 software will expect specific type.
38
- *
39
- * Maps typed-array input leaves to broad forms.
40
- * These are compatibility adapters, not ownership guarantees.
41
- *
42
- * - `TArg` keeps byte inputs broad.
43
- * - `TRet` marks byte outputs for TS 5.6 and TS 5.9+ compatibility.
44
- */
45
- 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;
46
- /** Maps typed-array output leaves to narrow TS-compatible forms. */
47
- 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;
48
- /** Recursively adapts byte-carrying API input types. See {@link TypedArg}. */
49
- export type TArg<T> = T | ([TypedArg<T>] extends [never] ? T extends (...args: infer A) => infer R ? ((...args: {
50
- [K in keyof A]: TRet<A[K]>;
51
- }) => TArg<R>) & {
52
- [K in keyof T]: T[K] extends (...args: any) => any ? T[K] : TArg<T[K]>;
53
- } : T extends [infer A, ...infer R] ? [TArg<A>, ...{
54
- [K in keyof R]: TArg<R[K]>;
55
- }] : T extends readonly [infer A, ...infer R] ? readonly [TArg<A>, ...{
56
- [K in keyof R]: TArg<R[K]>;
57
- }] : 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 ? {
58
- [K in keyof T]: TArg<T[K]>;
59
- } : T : TypedArg<T>);
60
- /** Recursively adapts byte-carrying API output types. See {@link TypedArg}. */
61
- export type TRet<T> = T extends unknown ? T & ([TypedRet<T>] extends [never] ? T extends (...args: infer A) => infer R ? ((...args: {
62
- [K in keyof A]: TArg<A[K]>;
63
- }) => TRet<R>) & {
64
- [K in keyof T]: T[K] extends (...args: any) => any ? T[K] : TRet<T[K]>;
65
- } : T extends [infer A, ...infer R] ? [TRet<A>, ...{
66
- [K in keyof R]: TRet<R[K]>;
67
- }] : T extends readonly [infer A, ...infer R] ? readonly [TRet<A>, ...{
68
- [K in keyof R]: TRet<R[K]>;
69
- }] : 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 ? {
70
- [K in keyof T]: TRet<T[K]>;
71
- } : T : TypedRet<T>) : never;
72
- type Chain = [Coder<any, any>, ...Coder<any, any>[]];
73
- type Input<F> = F extends Coder<infer T, any> ? T : never;
74
- type Output<F> = F extends Coder<any, infer T> ? T : never;
75
- type First<T> = T extends [infer U, ...any[]] ? U : never;
76
- type Last<T> = T extends [...any[], infer U] ? U : never;
77
- type Tail<T> = T extends [any, ...infer U] ? U : never;
78
- type AsChain<C extends Chain, Rest = Tail<C>> = {
79
- [K in keyof C]: Coder<Input<C[K]>, Input<K extends keyof Rest ? Rest[K] : any>>;
80
- };
81
- /**
82
- * @__NO_SIDE_EFFECTS__
83
- */
84
- declare function chain<T extends Chain & AsChain<T>>(...args: T): Coder<Input<First<T>>, Output<Last<T>>>;
85
- /**
86
- * Encodes integer radix representation to array of strings using alphabet and back.
87
- * Could also be array of strings.
88
- * @__NO_SIDE_EFFECTS__
89
- */
90
- declare function alphabet(letters: string | string[]): Coder<number[], string[]>;
91
- /**
92
- * @__NO_SIDE_EFFECTS__
93
- */
94
- declare function join(separator?: string): Coder<string[], string>;
95
- /**
96
- * Pad strings array so it has integer number of bits
97
- * @__NO_SIDE_EFFECTS__
98
- */
99
- declare function padding(bits: number, chr?: string): Coder<string[], string[]>;
100
- /**
101
- * Slow: O(n^2) time complexity
102
- */
103
- declare function convertRadix(data: number[], from: number, to: number): number[];
104
- /**
105
- * Implemented with numbers, because BigInt is 5x slower
106
- */
107
- declare function convertRadix2(data: number[], from: number, to: number, padding: boolean): number[];
108
- /**
109
- * @__NO_SIDE_EFFECTS__
110
- */
111
- declare function radix(num: number): TRet<Coder<Uint8Array, number[]>>;
112
- /**
113
- * If both bases are power of same number (like `2**8 <-> 2**64`),
114
- * there is a linear algorithm. For now we have implementation for power-of-two bases only.
115
- * @__NO_SIDE_EFFECTS__
116
- */
117
- declare function radix2(bits: number, revPadding?: boolean): TRet<Coder<Uint8Array, number[]>>;
118
- type BytesFn = (data: TArg<Uint8Array>) => TRet<Uint8Array>;
119
- declare function checksum(len: number, fn: TArg<BytesFn>): TRet<Coder<Uint8Array, Uint8Array>>;
120
- /**
121
- * Low-level building blocks used by the exported codecs.
122
- * @example
123
- * Build a radix-32 coder from the low-level helpers.
124
- * ```ts
125
- * import { utils } from '@scure/base';
126
- * utils.radix2(5).encode(Uint8Array.from([1, 2, 3]));
127
- * ```
128
- */
129
- export declare const utils: {
130
- alphabet: typeof alphabet;
131
- chain: typeof chain;
132
- checksum: typeof checksum;
133
- convertRadix: typeof convertRadix;
134
- convertRadix2: typeof convertRadix2;
135
- radix: typeof radix;
136
- radix2: typeof radix2;
137
- join: typeof join;
138
- padding: typeof padding;
139
- };
140
- /**
141
- * base16 encoding from RFC 4648.
142
- * This codec uses RFC 4648 Table 5's uppercase alphabet directly.
143
- * RFC 4648 §8 calls base16 "case-insensitive hex encoding", but we intentionally do not case-fold decode input here.
144
- * Use `hex` for case-insensitive hex decoding.
145
- * @example
146
- * ```js
147
- * base16.encode(Uint8Array.from([0x12, 0xab]));
148
- * // => '12AB'
149
- * ```
150
- */
151
- export declare const base16: BytesCoder;
152
- /**
153
- * base32 encoding from RFC 4648. Has padding.
154
- * RFC 4648 §6 Table 3 uses uppercase letters, and RFC 4648 §3.4 allows applications to choose
155
- * upper- or lowercase alphabets. We keep the published uppercase table and do not case-fold decode input.
156
- * Use `base32nopad` for unpadded version.
157
- * Also check out `base32hex`, `base32hexnopad`, `base32crockford`.
158
- * @example
159
- * ```js
160
- * base32.encode(Uint8Array.from([0x12, 0xab]));
161
- * // => 'CKVQ===='
162
- * base32.decode('CKVQ====');
163
- * // => Uint8Array.from([0x12, 0xab])
164
- * ```
165
- */
166
- export declare const base32: BytesCoder;
167
- /**
168
- * base32 encoding from RFC 4648. No padding.
169
- * This variant inherits RFC 4648 base32's uppercase table and intentionally does not case-fold decode input.
170
- * Use `base32` for padded version.
171
- * Also check out `base32hex`, `base32hexnopad`, `base32crockford`.
172
- * @example
173
- * ```js
174
- * base32nopad.encode(Uint8Array.from([0x12, 0xab]));
175
- * // => 'CKVQ'
176
- * base32nopad.decode('CKVQ');
177
- * // => Uint8Array.from([0x12, 0xab])
178
- * ```
179
- */
180
- export declare const base32nopad: BytesCoder;
181
- /**
182
- * base32 encoding from RFC 4648. Padded. Compared to ordinary `base32`, slightly different alphabet.
183
- * RFC 4648 §7 Table 4 uses uppercase letters, and we intentionally keep that table without case-folding decode input.
184
- * Use `base32hexnopad` for unpadded version.
185
- * @example
186
- * ```js
187
- * base32hex.encode(Uint8Array.from([0x12, 0xab]));
188
- * // => '2ALG===='
189
- * base32hex.decode('2ALG====');
190
- * // => Uint8Array.from([0x12, 0xab])
191
- * ```
192
- */
193
- export declare const base32hex: BytesCoder;
194
- /**
195
- * base32 encoding from RFC 4648. No padding. Compared to ordinary `base32`, slightly different alphabet.
196
- * This variant inherits RFC 4648 base32hex's uppercase table and intentionally does not case-fold decode input.
197
- * Use `base32hex` for padded version.
198
- * @example
199
- * ```js
200
- * base32hexnopad.encode(Uint8Array.from([0x12, 0xab]));
201
- * // => '2ALG'
202
- * base32hexnopad.decode('2ALG');
203
- * // => Uint8Array.from([0x12, 0xab])
204
- * ```
205
- */
206
- export declare const base32hexnopad: BytesCoder;
207
- /**
208
- * base32 encoding from RFC 4648. Doug Crockford's version.
209
- * See {@link https://www.crockford.com/base32.html | Douglas Crockford's Base32}.
210
- * @example
211
- * ```js
212
- * base32crockford.encode(Uint8Array.from([0x12, 0xab]));
213
- * // => '2ANG'
214
- * base32crockford.decode('2ANG');
215
- * // => Uint8Array.from([0x12, 0xab])
216
- * ```
217
- */
218
- export declare const base32crockford: BytesCoder;
219
- /**
220
- * base64 from RFC 4648. Padded.
221
- * Use `base64nopad` for unpadded version.
222
- * Also check out `base64url`, `base64urlnopad`.
223
- * Falls back to built-in function, when available.
224
- * @example
225
- * ```js
226
- * base64.encode(Uint8Array.from([0x12, 0xab]));
227
- * // => 'Eqs='
228
- * base64.decode('Eqs=');
229
- * // => Uint8Array.from([0x12, 0xab])
230
- * ```
231
- */
232
- export declare const base64: BytesCoder;
233
- /**
234
- * base64 from RFC 4648. No padding.
235
- * Use `base64` for padded version.
236
- * @example
237
- * ```js
238
- * base64nopad.encode(Uint8Array.from([0x12, 0xab]));
239
- * // => 'Eqs'
240
- * base64nopad.decode('Eqs');
241
- * // => Uint8Array.from([0x12, 0xab])
242
- * ```
243
- */
244
- export declare const base64nopad: BytesCoder;
245
- /**
246
- * base64 from RFC 4648, using URL-safe alphabet. Padded.
247
- * Use `base64urlnopad` for unpadded version.
248
- * Falls back to built-in function, when available.
249
- * @example
250
- * ```js
251
- * base64url.encode(Uint8Array.from([0x12, 0xab]));
252
- * // => 'Eqs='
253
- * base64url.decode('Eqs=');
254
- * // => Uint8Array.from([0x12, 0xab])
255
- * ```
256
- */
257
- export declare const base64url: BytesCoder;
258
- /**
259
- * base64 from RFC 4648, using URL-safe alphabet. No padding.
260
- * Use `base64url` for padded version.
261
- * @example
262
- * ```js
263
- * base64urlnopad.encode(Uint8Array.from([0x12, 0xab]));
264
- * // => 'Eqs'
265
- * base64urlnopad.decode('Eqs');
266
- * // => Uint8Array.from([0x12, 0xab])
267
- * ```
268
- */
269
- export declare const base64urlnopad: BytesCoder;
270
- /**
271
- * base58: base64 without ambigous characters +, /, 0, O, I, l.
272
- * Quadratic (O(n^2)) - so, can't be used on large inputs.
273
- * @example
274
- * ```js
275
- * const text = base58.encode(Uint8Array.from([0, 1, 2]));
276
- * base58.decode(text);
277
- * // => Uint8Array.from([0, 1, 2])
278
- * ```
279
- */
280
- export declare const base58: BytesCoder;
281
- /**
282
- * base58: flickr version. Check out `base58`.
283
- * @example
284
- * Round-trip bytes with the Flickr alphabet.
285
- * ```ts
286
- * const text = base58flickr.encode(Uint8Array.from([0, 1, 2]));
287
- * base58flickr.decode(text);
288
- * ```
289
- */
290
- export declare const base58flickr: BytesCoder;
291
- /**
292
- * base58: XRP version. Check out `base58`.
293
- * @example
294
- * Round-trip bytes with the XRP alphabet.
295
- * ```ts
296
- * const text = base58xrp.encode(Uint8Array.from([0, 1, 2]));
297
- * base58xrp.decode(text);
298
- * ```
299
- */
300
- export declare const base58xrp: BytesCoder;
301
- /**
302
- * base58: XMR version. Check out `base58`.
303
- * Done in 8-byte blocks (which equals 11 chars in decoding). Last (non-full) block padded with '1' to size in XMR_BLOCK_LEN.
304
- * Block encoding significantly reduces quadratic complexity of base58.
305
- * @example
306
- * Round-trip bytes with the Monero block codec.
307
- * ```ts
308
- * const text = base58xmr.encode(Uint8Array.from([0, 1, 2]));
309
- * base58xmr.decode(text);
310
- * ```
311
- */
312
- export declare const base58xmr: BytesCoder;
313
- /**
314
- * Method, which creates base58check encoder.
315
- * Requires function, calculating sha256.
316
- * Callers must include any version bytes in `data`; this helper only applies the
317
- * 4-byte double-SHA256 checksum used by Bitcoin Base58Check.
318
- * @param sha256 - Function used to calculate the checksum hash.
319
- * @returns base58check codec using 4 checksum bytes.
320
- * @throws On wrong argument types. {@link TypeError}
321
- * @example
322
- * Create a base58check codec from a SHA-256 implementation.
323
- * ```ts
324
- * import { createBase58check } from '@scure/base';
325
- * import { sha256 } from '@noble/hashes/sha2.js';
326
- * const coder = createBase58check(sha256);
327
- * coder.encode(Uint8Array.from([1, 2, 3]));
328
- * ```
329
- */
330
- export declare const createBase58check: (sha256: TArg<BytesFn>) => BytesCoder;
331
- /**
332
- * Use `createBase58check` instead.
333
- * @deprecated Use {@link createBase58check} instead.
334
- * Callers must include any version bytes in `data`; this alias keeps the same
335
- * 4-byte double-SHA256 checksum behavior as `createBase58check`.
336
- * @param sha256 - Function used to calculate the checksum hash.
337
- * @returns base58check codec using 4 checksum bytes.
338
- * @example
339
- * Create a base58check codec with the deprecated alias.
340
- * ```ts
341
- * import { base58check } from '@scure/base';
342
- * import { sha256 } from '@noble/hashes/sha2.js';
343
- * const coder = base58check(sha256);
344
- * coder.encode(Uint8Array.from([1, 2, 3]));
345
- * ```
346
- */
347
- export declare const base58check: (sha256: TArg<BytesFn>) => BytesCoder;
348
- /** Result of bech32 decoding. */
349
- export interface Bech32Decoded<Prefix extends string = string> {
350
- /** Human-readable bech32 prefix. */
351
- prefix: Prefix;
352
- /** Decoded 5-bit word payload. */
353
- words: number[];
354
- }
355
- /** Result of bech32 decoding with original bytes attached. */
356
- export interface Bech32DecodedWithArray<Prefix extends string = string> {
357
- /** Human-readable bech32 prefix. */
358
- prefix: Prefix;
359
- /** Decoded 5-bit word payload. */
360
- words: number[];
361
- /** Decoded payload converted back into raw bytes. */
362
- bytes: Uint8Array;
363
- }
364
- /** bech32 codec surface. */
365
- export interface Bech32 {
366
- /**
367
- * Encodes a human-readable prefix and 5-bit words into a bech32 string.
368
- * @param prefix - Human-readable prefix.
369
- * @param words - 5-bit words or raw bytes.
370
- * @param limit - Maximum accepted output length, or `false` to disable the limit.
371
- * @returns Encoded bech32 string.
372
- */
373
- encode<Prefix extends string>(prefix: Prefix, words: number[] | Uint8Array, limit?: number | false): `${Lowercase<Prefix>}1${string}`;
374
- /**
375
- * Decodes a bech32 string into prefix and words.
376
- * @param str - Encoded bech32 string.
377
- * @param limit - Maximum accepted input length, or `false` to disable the limit.
378
- * @returns Decoded prefix and 5-bit words.
379
- */
380
- decode<Prefix extends string>(str: `${Prefix}1${string}`, limit?: number | false): Bech32Decoded<Prefix>;
381
- decode(str: string, limit?: number | false): Bech32Decoded;
382
- /**
383
- * Encodes raw bytes by first converting them to 5-bit words.
384
- * @param prefix - Human-readable prefix.
385
- * @param bytes - Raw bytes to encode.
386
- * @returns Encoded bech32 string.
387
- */
388
- encodeFromBytes(prefix: string, bytes: Uint8Array): string;
389
- /**
390
- * Decodes a bech32 string and converts the payload back into bytes.
391
- * @param str - Encoded bech32 string.
392
- * @returns Decoded prefix, words, and bytes.
393
- */
394
- decodeToBytes(str: string): Bech32DecodedWithArray;
395
- /**
396
- * Decodes a bech32 string, returning `undefined` instead of throwing on invalid input.
397
- * @param str - Encoded bech32 string.
398
- * @param limit - Maximum accepted input length, or `false` to disable the limit.
399
- * @returns Decoded prefix and words, or `undefined` for invalid input.
400
- */
401
- decodeUnsafe(str: string, limit?: number | false): void | Bech32Decoded<string>;
402
- /**
403
- * Converts 5-bit words back into raw bytes.
404
- * @param to - 5-bit words to decode.
405
- * @returns Decoded bytes.
406
- */
407
- fromWords(to: number[]): Uint8Array;
408
- /**
409
- * Converts 5-bit words back into raw bytes, returning `undefined` instead of throwing.
410
- * @param to - 5-bit words to decode.
411
- * @returns Decoded bytes, or `undefined` for invalid input.
412
- */
413
- fromWordsUnsafe(to: number[]): void | Uint8Array;
414
- /**
415
- * Converts raw bytes into 5-bit words for bech32 encoding.
416
- * @param from - Raw bytes to convert.
417
- * @returns 5-bit words.
418
- */
419
- toWords(from: Uint8Array): number[];
420
- }
421
- /**
422
- * bech32 from BIP 173. Operates on words.
423
- * For high-level helpers, check out {@link https://github.com/paulmillr/scure-btc-signer | scure-btc-signer}.
424
- * @example
425
- * Convert bytes to words, encode them, then decode back.
426
- * ```ts
427
- * const words = bech32.toWords(Uint8Array.from([1, 2, 3]));
428
- * const text = bech32.encode('bc', words);
429
- * bech32.decode(text);
430
- * ```
431
- */
432
- export declare const bech32: TRet<Bech32>;
433
- /**
434
- * bech32m from BIP 350. Operates on words.
435
- * It was to mitigate `bech32` weaknesses.
436
- * For high-level helpers, check out {@link https://github.com/paulmillr/scure-btc-signer | scure-btc-signer}.
437
- * @example
438
- * Convert bytes to words, encode them with bech32m, then decode back.
439
- * ```ts
440
- * const words = bech32m.toWords(Uint8Array.from([1, 2, 3]));
441
- * const text = bech32m.encode('bc', words);
442
- * bech32m.decode(text);
443
- * ```
444
- */
445
- export declare const bech32m: TRet<Bech32>;
446
- /**
447
- * ASCII-to-byte decoder. Rejects non-ASCII text and bytes instead of doing UTF-8 replacement.
448
- * Method names follow `BytesCoder`, so `encode(bytes)` returns a string and `decode(string)` returns bytes.
449
- * @example
450
- * ```js
451
- * const b = ascii.decode("ABC"); // => new Uint8Array([ 65, 66, 67 ])
452
- * const str = ascii.encode(b); // "ABC"
453
- * ```
454
- */
455
- export declare const ascii: TRet<BytesCoder>;
456
- /**
457
- * Strict UTF-8-to-byte decoder. Uses built-in TextDecoder / TextEncoder when available.
458
- * Method names follow `BytesCoder`, so `encode(bytes)` returns a string and
459
- * `decode(string)` returns bytes.
460
- * `encode(bytes)` requires Uint8Array input, preserves an explicit leading BOM, and
461
- * throws on invalid UTF-8 bytes.
462
- * `decode(string)` requires a primitive string and throws on malformed UTF-16 strings with
463
- * lone surrogates.
464
- * @example
465
- * ```js
466
- * const b = utf8.decode("hey"); // => new Uint8Array([ 104, 101, 121 ])
467
- * const str = utf8.encode(b); // "hey"
468
- * ```
469
- */
470
- export declare const utf8: BytesCoder;
471
- export declare const __TESTS: {
472
- utf8Fallback: BytesCoder;
473
- _isWellFormedShim: (str: string) => boolean;
474
- };
475
- /**
476
- * hex string decoder. Uses built-in function, when available.
477
- * Lowercase codec; unlike `base16`, this variant accepts either hex case and emits lowercase.
478
- * @example
479
- * ```js
480
- * const b = hex.decode("0102ff"); // => new Uint8Array([ 1, 2, 255 ])
481
- * const str = hex.encode(b); // "0102ff"
482
- * ```
483
- */
484
- export declare const hex: BytesCoder;
485
- /** Built-in codecs exposed through the deprecated string conversion helpers. */
486
- export type SomeCoders = {
487
- /** UTF-8 string codec. */
488
- utf8: BytesCoder;
489
- /** Hex codec. */
490
- hex: BytesCoder;
491
- /** Uppercase RFC 4648 base16 codec. */
492
- base16: BytesCoder;
493
- /** RFC 4648 base32 codec with padding. */
494
- base32: BytesCoder;
495
- /** RFC 4648 base64 codec with padding. */
496
- base64: BytesCoder;
497
- /** URL-safe base64 codec without `+` or `/`. */
498
- base64url: BytesCoder;
499
- /** Bitcoin-style base58 codec. */
500
- base58: BytesCoder;
501
- /** Monero-style base58 codec. */
502
- base58xmr: BytesCoder;
503
- };
504
- type CoderType = keyof SomeCoders;
505
- /**
506
- * Encodes bytes with one of the built-in codecs.
507
- * @deprecated Use the codec directly, for example `hex.encode(bytes)`.
508
- * @param type - Codec name.
509
- * @param bytes - Bytes to encode.
510
- * @returns Encoded string.
511
- * @throws On wrong argument types. {@link TypeError}
512
- * @example
513
- * ```ts
514
- * bytesToString('hex', Uint8Array.from([1, 2, 255]));
515
- * ```
516
- */
517
- export declare const bytesToString: (type: CoderType, bytes: TArg<Uint8Array>) => string;
518
- /**
519
- * Alias for `bytesToString`.
520
- * @deprecated Use {@link bytesToString} or the codec directly instead.
521
- * @param type - Codec name.
522
- * @param bytes - Bytes to encode.
523
- * @returns Encoded string.
524
- * @example
525
- * ```ts
526
- * str('hex', Uint8Array.from([1, 2, 255]));
527
- * ```
528
- */
529
- export declare const str: (type: CoderType, bytes: TArg<Uint8Array>) => string;
530
- /**
531
- * Decodes a string with one of the built-in codecs.
532
- * @deprecated Use the codec directly, for example `hex.decode(text)`.
533
- * @param type - Codec name.
534
- * @param str - Encoded string.
535
- * @returns Decoded bytes.
536
- * @throws On wrong argument types. {@link TypeError}
537
- * @example
538
- * ```ts
539
- * stringToBytes('hex', '0102ff');
540
- * ```
541
- */
542
- export declare const stringToBytes: (type: CoderType, str: string) => TRet<Uint8Array>;
543
- /**
544
- * Alias for `stringToBytes`.
545
- * @deprecated Use {@link stringToBytes} or the codec directly instead.
546
- * @param type - Codec name.
547
- * @param str - Encoded string.
548
- * @returns Decoded bytes.
549
- * @example
550
- * ```ts
551
- * bytes('hex', '0102ff');
552
- * ```
553
- */
554
- export declare const bytes: (type: CoderType, str: string) => TRet<Uint8Array>;
555
- export {};