bufferbase 2.0.0 → 3.0.0

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.
Files changed (115) hide show
  1. package/README.md +151 -63
  2. package/dist/cjs/bases.d.ts +152 -45
  3. package/dist/cjs/bases.d.ts.map +1 -1
  4. package/dist/cjs/bases.js +90 -77
  5. package/dist/cjs/bases.js.map +1 -1
  6. package/dist/cjs/bufferbase.d.ts +21 -27
  7. package/dist/cjs/bufferbase.d.ts.map +1 -1
  8. package/dist/cjs/bufferbase.js +21 -31
  9. package/dist/cjs/bufferbase.js.map +1 -1
  10. package/dist/cjs/codec-base.d.ts +56 -0
  11. package/dist/cjs/codec-base.d.ts.map +1 -0
  12. package/dist/cjs/codec-base.js +132 -0
  13. package/dist/cjs/codec-base.js.map +1 -0
  14. package/dist/cjs/codec-block.d.ts +47 -0
  15. package/dist/cjs/codec-block.d.ts.map +1 -0
  16. package/dist/cjs/codec-block.js +213 -0
  17. package/dist/cjs/codec-block.js.map +1 -0
  18. package/dist/cjs/codec-block85.d.ts +56 -0
  19. package/dist/cjs/codec-block85.d.ts.map +1 -0
  20. package/dist/cjs/codec-block85.js +271 -0
  21. package/dist/cjs/codec-block85.js.map +1 -0
  22. package/dist/cjs/codec-radix.d.ts +46 -0
  23. package/dist/cjs/codec-radix.d.ts.map +1 -0
  24. package/dist/cjs/codec-radix.js +181 -0
  25. package/dist/cjs/codec-radix.js.map +1 -0
  26. package/dist/cjs/codec.d.ts +25 -111
  27. package/dist/cjs/codec.d.ts.map +1 -1
  28. package/dist/cjs/codec.js +50 -228
  29. package/dist/cjs/codec.js.map +1 -1
  30. package/dist/cjs/codecs.d.ts +8 -59
  31. package/dist/cjs/codecs.d.ts.map +1 -1
  32. package/dist/cjs/codecs.js +6 -79
  33. package/dist/cjs/codecs.js.map +1 -1
  34. package/dist/cjs/errors.d.ts +65 -48
  35. package/dist/cjs/errors.d.ts.map +1 -1
  36. package/dist/cjs/errors.js +89 -51
  37. package/dist/cjs/errors.js.map +1 -1
  38. package/dist/cjs/example.js +44 -21
  39. package/dist/cjs/example.js.map +1 -1
  40. package/dist/cjs/functions.d.ts +27 -31
  41. package/dist/cjs/functions.d.ts.map +1 -1
  42. package/dist/cjs/functions.js +25 -47
  43. package/dist/cjs/functions.js.map +1 -1
  44. package/dist/cjs/index.d.ts +7 -5
  45. package/dist/cjs/index.d.ts.map +1 -1
  46. package/dist/cjs/index.js +17 -7
  47. package/dist/cjs/index.js.map +1 -1
  48. package/dist/cjs/package.json +13 -7
  49. package/dist/cjs/types.d.ts +108 -71
  50. package/dist/cjs/types.d.ts.map +1 -1
  51. package/dist/esm/bases.d.ts +152 -45
  52. package/dist/esm/bases.d.ts.map +1 -1
  53. package/dist/esm/bases.js +88 -75
  54. package/dist/esm/bases.js.map +1 -1
  55. package/dist/esm/bufferbase.d.ts +21 -27
  56. package/dist/esm/bufferbase.d.ts.map +1 -1
  57. package/dist/esm/bufferbase.js +18 -30
  58. package/dist/esm/bufferbase.js.map +1 -1
  59. package/dist/esm/codec-base.d.ts +56 -0
  60. package/dist/esm/codec-base.d.ts.map +1 -0
  61. package/dist/esm/codec-base.js +127 -0
  62. package/dist/esm/codec-base.js.map +1 -0
  63. package/dist/esm/codec-block.d.ts +47 -0
  64. package/dist/esm/codec-block.d.ts.map +1 -0
  65. package/dist/esm/codec-block.js +209 -0
  66. package/dist/esm/codec-block.js.map +1 -0
  67. package/dist/esm/codec-block85.d.ts +56 -0
  68. package/dist/esm/codec-block85.d.ts.map +1 -0
  69. package/dist/esm/codec-block85.js +267 -0
  70. package/dist/esm/codec-block85.js.map +1 -0
  71. package/dist/esm/codec-radix.d.ts +46 -0
  72. package/dist/esm/codec-radix.d.ts.map +1 -0
  73. package/dist/esm/codec-radix.js +177 -0
  74. package/dist/esm/codec-radix.js.map +1 -0
  75. package/dist/esm/codec.d.ts +25 -111
  76. package/dist/esm/codec.d.ts.map +1 -1
  77. package/dist/esm/codec.js +44 -226
  78. package/dist/esm/codec.js.map +1 -1
  79. package/dist/esm/codecs.d.ts +8 -59
  80. package/dist/esm/codecs.d.ts.map +1 -1
  81. package/dist/esm/codecs.js +7 -80
  82. package/dist/esm/codecs.js.map +1 -1
  83. package/dist/esm/errors.d.ts +65 -48
  84. package/dist/esm/errors.d.ts.map +1 -1
  85. package/dist/esm/errors.js +83 -50
  86. package/dist/esm/errors.js.map +1 -1
  87. package/dist/esm/example.js +45 -22
  88. package/dist/esm/example.js.map +1 -1
  89. package/dist/esm/functions.d.ts +27 -31
  90. package/dist/esm/functions.d.ts.map +1 -1
  91. package/dist/esm/functions.js +26 -48
  92. package/dist/esm/functions.js.map +1 -1
  93. package/dist/esm/index.d.ts +7 -5
  94. package/dist/esm/index.d.ts.map +1 -1
  95. package/dist/esm/index.js +6 -6
  96. package/dist/esm/index.js.map +1 -1
  97. package/dist/esm/package.json +13 -7
  98. package/dist/esm/types.d.ts +108 -71
  99. package/dist/esm/types.d.ts.map +1 -1
  100. package/package.json +13 -7
  101. package/src/algorithms.test.ts +442 -0
  102. package/src/bases.ts +98 -76
  103. package/src/bufferbase.ts +26 -36
  104. package/src/codec-base.ts +181 -0
  105. package/src/codec-block.ts +258 -0
  106. package/src/codec-block85.ts +315 -0
  107. package/src/codec-radix.ts +206 -0
  108. package/src/codec.test.ts +17 -9
  109. package/src/codec.ts +48 -247
  110. package/src/codecs.ts +11 -105
  111. package/src/errors.ts +90 -50
  112. package/src/example.ts +47 -22
  113. package/src/functions.ts +34 -54
  114. package/src/index.ts +27 -7
  115. package/src/types.ts +113 -86
@@ -1,62 +1,58 @@
1
- import type { BaseName, DecodeOptions, BufferLike } from './types.js';
1
+ import type { BufferLike, CodecSpec, DecodeOptions } from './types.js';
2
+ import type { Buffer } from 'node:buffer';
3
+ import { type BaseName } from './bases.js';
4
+ /** A named encoding, or a spec describing one directly. */
5
+ export type Base = BaseName | CodecSpec;
2
6
  /**
3
7
  * Encodes a buffer to a base-encoded string.
4
8
  *
5
9
  * @param buffer - Buffer or Uint8Array to encode
6
- * @param base - Base name (e.g., 'base58') or custom character set
7
- * @returns Encoded string
10
+ * @param base - Base name (e.g. `'base58'`) or a codec spec
8
11
  *
9
12
  * @example
10
13
  * ```typescript
11
- * // Node.js Buffer
12
- * const encoded = encode(Buffer.from('Hello'), 'base58');
13
- *
14
- * // Browser Uint8Array
15
- * const encoded = encode(new Uint8Array([72, 101, 108, 108, 111]), 'base58');
14
+ * encode(Buffer.from('fo'), 'base64'); // 'Zm8='
15
+ * encode(Uint8Array.of(5), { alphabet: '01', algorithm: 'radix' }); // '101'
16
16
  * ```
17
17
  */
18
- export declare function encode(buffer: BufferLike, base: BaseName | string): string;
18
+ export declare function encode(buffer: BufferLike, base: Base): string;
19
19
  /**
20
20
  * Decodes a base-encoded string to a buffer.
21
21
  *
22
22
  * @param encoded - String to decode
23
- * @param base - Base name (e.g., 'base58') or custom character set
24
- * @param options - Decode options (e.g., { size: 32 })
25
- * @returns Decoded buffer
23
+ * @param base - Base name (e.g. `'base58'`) or a codec spec
24
+ * @param options - Decode options, such as a required `size`
25
+ * @throws {InvalidCharacterError} If a character is not in the alphabet
26
+ * @throws {InvalidLengthError} If the length cannot encode a whole number of bytes
27
+ * @throws {NonCanonicalError} If spare bits are set and the codec is strict
28
+ * @throws {BufferSizeError} If the result does not have the requested `size`
26
29
  *
27
30
  * @example
28
31
  * ```typescript
29
- * const buffer = decode('9Ajdvz', 'base58');
30
- * const fixedSize = decode('9Ajdvz', 'base58', { size: 32 });
32
+ * decode('Zm8=', 'base64'); // Buffer('fo')
33
+ * decode('9Ajdvzr', 'base58', { size: 32 });
31
34
  * ```
32
35
  */
33
- export declare function decode(encoded: string, base: BaseName | string, options?: DecodeOptions): Buffer;
36
+ export declare function decode(encoded: string, base: Base, options?: DecodeOptions): Buffer;
34
37
  /**
35
- * Converts a string from one base to another.
36
- *
37
- * @param input - String to convert
38
- * @param from - Source base name or character set
39
- * @param to - Target base name or character set
40
- * @returns Converted string
38
+ * Converts a string from one base to another, through the bytes they describe.
41
39
  *
42
40
  * @example
43
41
  * ```typescript
44
- * const base64 = convert('9Ajdvz', 'base58', 'base64url');
42
+ * convert('9Ajdvzr', 'base58', 'base64url');
43
+ * convert(legacy, 'radix64', 'base64'); // migrate data written by bufferbase 2
45
44
  * ```
46
45
  */
47
- export declare function convert(input: string, from: BaseName | string, to: BaseName | string): string;
46
+ export declare function convert(input: string, from: Base, to: Base): string;
48
47
  /**
49
- * Validates if a string contains only valid characters for the specified base.
50
- *
51
- * @param input - String to validate
52
- * @param base - Base name or character set
53
- * @returns true if valid, false otherwise
48
+ * Reports whether `decode` would succeed for this input.
54
49
  *
55
50
  * @example
56
51
  * ```typescript
57
- * validate('9Ajdvz', 'base58'); // true
58
- * validate('0Ajdvz', 'base58'); // false ('0' is not in base58)
52
+ * validate('Zm8=', 'base64'); // true
53
+ * validate('Zm9=', 'base64'); // false spare bits are not zero
54
+ * validate('Zm9vd', 'base64'); // false — 5 characters cannot be whole bytes
59
55
  * ```
60
56
  */
61
- export declare function validate(input: string, base: BaseName | string): boolean;
57
+ export declare function validate(input: string, base: Base): boolean;
62
58
  //# sourceMappingURL=functions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../src/functions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAoBtE;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,MAAM,CAE1E;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,MAAM,CAEhG;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,MAAM,EAAE,EAAE,EAAE,QAAQ,GAAG,MAAM,GAAG,MAAM,CAI7F;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,OAAO,CAExE"}
1
+ {"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../src/functions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACvE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAe,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGxD,2DAA2D;AAC3D,MAAM,MAAM,IAAI,GAAG,QAAQ,GAAG,SAAS,CAAC;AAExC;;;;;;;;;;;GAWG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,GAAG,MAAM,CAE7D;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,MAAM,CAEnF;AAED;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,GAAG,MAAM,CAInE;AAED;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CAE3D"}
@@ -1,87 +1,65 @@
1
- import { Codec } from './codec.js';
2
- import { resolveChars } from './bases.js';
3
- // Cache for codec instances
4
- const codecCache = new Map();
5
- /**
6
- * Gets or creates a codec for the specified base.
7
- */
8
- function getCodec(base) {
9
- const chars = resolveChars(base);
10
- let codec = codecCache.get(chars);
11
- if (!codec) {
12
- codec = new Codec(chars);
13
- codecCache.set(chars, codec);
14
- }
15
- return codec;
16
- }
1
+ import { resolveSpec } from './bases.js';
2
+ import { getCodec } from './codec.js';
17
3
  /**
18
4
  * Encodes a buffer to a base-encoded string.
19
5
  *
20
6
  * @param buffer - Buffer or Uint8Array to encode
21
- * @param base - Base name (e.g., 'base58') or custom character set
22
- * @returns Encoded string
7
+ * @param base - Base name (e.g. `'base58'`) or a codec spec
23
8
  *
24
9
  * @example
25
10
  * ```typescript
26
- * // Node.js Buffer
27
- * const encoded = encode(Buffer.from('Hello'), 'base58');
28
- *
29
- * // Browser Uint8Array
30
- * const encoded = encode(new Uint8Array([72, 101, 108, 108, 111]), 'base58');
11
+ * encode(Buffer.from('fo'), 'base64'); // 'Zm8='
12
+ * encode(Uint8Array.of(5), { alphabet: '01', algorithm: 'radix' }); // '101'
31
13
  * ```
32
14
  */
33
15
  export function encode(buffer, base) {
34
- return getCodec(base).encode(buffer);
16
+ return getCodec(resolveSpec(base)).encode(buffer);
35
17
  }
36
18
  /**
37
19
  * Decodes a base-encoded string to a buffer.
38
20
  *
39
21
  * @param encoded - String to decode
40
- * @param base - Base name (e.g., 'base58') or custom character set
41
- * @param options - Decode options (e.g., { size: 32 })
42
- * @returns Decoded buffer
22
+ * @param base - Base name (e.g. `'base58'`) or a codec spec
23
+ * @param options - Decode options, such as a required `size`
24
+ * @throws {InvalidCharacterError} If a character is not in the alphabet
25
+ * @throws {InvalidLengthError} If the length cannot encode a whole number of bytes
26
+ * @throws {NonCanonicalError} If spare bits are set and the codec is strict
27
+ * @throws {BufferSizeError} If the result does not have the requested `size`
43
28
  *
44
29
  * @example
45
30
  * ```typescript
46
- * const buffer = decode('9Ajdvz', 'base58');
47
- * const fixedSize = decode('9Ajdvz', 'base58', { size: 32 });
31
+ * decode('Zm8=', 'base64'); // Buffer('fo')
32
+ * decode('9Ajdvzr', 'base58', { size: 32 });
48
33
  * ```
49
34
  */
50
35
  export function decode(encoded, base, options) {
51
- return getCodec(base).decode(encoded, options);
36
+ return getCodec(resolveSpec(base)).decode(encoded, options);
52
37
  }
53
38
  /**
54
- * Converts a string from one base to another.
55
- *
56
- * @param input - String to convert
57
- * @param from - Source base name or character set
58
- * @param to - Target base name or character set
59
- * @returns Converted string
39
+ * Converts a string from one base to another, through the bytes they describe.
60
40
  *
61
41
  * @example
62
42
  * ```typescript
63
- * const base64 = convert('9Ajdvz', 'base58', 'base64url');
43
+ * convert('9Ajdvzr', 'base58', 'base64url');
44
+ * convert(legacy, 'radix64', 'base64'); // migrate data written by bufferbase 2
64
45
  * ```
65
46
  */
66
47
  export function convert(input, from, to) {
67
- const fromCodec = getCodec(from);
68
- const toCodec = getCodec(to);
69
- return fromCodec.convertTo(toCodec, input);
48
+ const source = getCodec(resolveSpec(from));
49
+ const target = getCodec(resolveSpec(to));
50
+ return source.convertTo(target, input);
70
51
  }
71
52
  /**
72
- * Validates if a string contains only valid characters for the specified base.
73
- *
74
- * @param input - String to validate
75
- * @param base - Base name or character set
76
- * @returns true if valid, false otherwise
53
+ * Reports whether `decode` would succeed for this input.
77
54
  *
78
55
  * @example
79
56
  * ```typescript
80
- * validate('9Ajdvz', 'base58'); // true
81
- * validate('0Ajdvz', 'base58'); // false ('0' is not in base58)
57
+ * validate('Zm8=', 'base64'); // true
58
+ * validate('Zm9=', 'base64'); // false spare bits are not zero
59
+ * validate('Zm9vd', 'base64'); // false — 5 characters cannot be whole bytes
82
60
  * ```
83
61
  */
84
62
  export function validate(input, base) {
85
- return getCodec(base).validate(input);
63
+ return getCodec(resolveSpec(base)).validate(input);
86
64
  }
87
65
  //# sourceMappingURL=functions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"functions.js","sourceRoot":"","sources":["../../src/functions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,4BAA4B;AA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ources":["../../src/functions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAiB,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAKtC;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,MAAM,CAAC,MAAkB,EAAE,IAAU;IACnD,OAAO,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AACpD,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,MAAM,CAAC,OAAe,EAAE,IAAU,EAAE,OAAuB;IACzE,OAAO,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC9D,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,OAAO,CAAC,KAAa,EAAE,IAAU,EAAE,EAAQ;IACzD,MAAM,MAAM,GAAG,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3C,MAAM,MAAM,GAAG,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC;IACzC,OAAO,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AACzC,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAa,EAAE,IAAU;IAChD,OAAO,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACrD,CAAC"}
@@ -1,9 +1,11 @@
1
- export type { BaseName, DecodeOptions, ICodec, BufferLike } from './types.js';
1
+ export type { Algorithm, Block85Spec, BlockSpec, BufferLike, CodecSpec, DecodeOptions, ICodec, RadixSpec, } from './types.js';
2
+ export type { BaseName } from './bases.js';
3
+ export type { Base } from './functions.js';
2
4
  export type { CodecName } from './codecs.js';
3
- export { InvalidCharacterError, BufferSizeError, UnknownBaseError } from './errors.js';
4
- export { Codec, createCodec } from './codec.js';
5
- export { Chars, resolveChars, isBaseName } from './bases.js';
6
- export { encode, decode, convert, validate } from './functions.js';
5
+ export { BufferSizeError, CheckSymbolError, InvalidCharacterError, InvalidCodecError, InvalidLengthError, NonCanonicalError, UnknownBaseError, ValueRangeError, } from './errors.js';
6
+ export { Block85Codec, BlockCodec, Codec, RadixCodec, createCodec, getCodec } from './codec.js';
7
+ export { Bases, Chars, isBaseName, resolveSpec } from './bases.js';
8
+ export { convert, decode, encode, validate } from './functions.js';
7
9
  export { Codecs } from './codecs.js';
8
10
  export { BufferEncoder, Converter, Validator } from './bufferbase.js';
9
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC9E,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAG7C,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGvF,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAGhD,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAG7D,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAGnE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,SAAS,EACT,WAAW,EACX,SAAS,EACT,UAAU,EACV,SAAS,EACT,aAAa,EACb,MAAM,EACN,SAAS,GACV,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,YAAY,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAC3C,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAG7C,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,GAChB,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGhG,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAGnE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAGnE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC"}
package/dist/esm/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  // Errors
2
- export { InvalidCharacterError, BufferSizeError, UnknownBaseError } from './errors.js';
3
- // Codec class and factory
4
- export { Codec, createCodec } from './codec.js';
5
- // Character sets and utilities
6
- export { Chars, resolveChars, isBaseName } from './bases.js';
2
+ export { BufferSizeError, CheckSymbolError, InvalidCharacterError, InvalidCodecError, InvalidLengthError, NonCanonicalError, UnknownBaseError, ValueRangeError, } from './errors.js';
3
+ // Codec implementations and factory
4
+ export { Block85Codec, BlockCodec, Codec, RadixCodec, createCodec, getCodec } from './codec.js';
5
+ // Character sets, encoding definitions, and lookup helpers
6
+ export { Bases, Chars, isBaseName, resolveSpec } from './bases.js';
7
7
  // Simple function API
8
- export { encode, decode, convert, validate } from './functions.js';
8
+ export { convert, decode, encode, validate } from './functions.js';
9
9
  // Pre-defined codecs (namespaced)
10
10
  export { Codecs } from './codecs.js';
11
11
  // Deprecated exports for backward compatibility
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAIA,SAAS;AACT,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEvF,0BAA0B;AAC1B,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEhD,+BAA+B;AAC/B,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7D,sBAAsB;AACtB,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAEnE,kCAAkC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,gDAAgD;AAChD,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAeA,SAAS;AACT,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,GAChB,MAAM,aAAa,CAAC;AAErB,oCAAoC;AACpC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEhG,2DAA2D;AAC3D,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEnE,sBAAsB;AACtB,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAEnE,kCAAkC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,gDAAgD;AAChD,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bufferbase",
3
- "version": "2.0.0",
4
- "description": "Buffer-to-BaseN Encoder, Decoder, Converter, and Validator",
3
+ "version": "3.0.0",
4
+ "description": "Buffer-to-BaseN encoding: RFC 4648 block encodings, Ascii85/Z85, and Base58-style radix conversion",
5
5
  "sideEffects": false,
6
6
  "type": "module",
7
7
  "scripts": {
@@ -10,7 +10,8 @@
10
10
  "build:esm": "tsc -p tsconfig.json",
11
11
  "prepublishOnly": "bun run build",
12
12
  "example": "bun src/example.ts",
13
- "test": "bun test"
13
+ "test": "bun test",
14
+ "release": "bin/release"
14
15
  },
15
16
  "devDependencies": {
16
17
  "@types/bun": "^1.1.0",
@@ -27,19 +28,24 @@
27
28
  "src"
28
29
  ],
29
30
  "keywords": [
30
- "number",
31
31
  "encode",
32
+ "decode",
32
33
  "convert",
33
- "decimal",
34
34
  "base",
35
+ "rfc4648",
35
36
  "base16",
37
+ "hex",
36
38
  "base32",
39
+ "base32hex",
37
40
  "crockford",
38
41
  "base36",
39
42
  "base58",
40
43
  "base64",
41
- "Ascii85",
42
- "base85"
44
+ "base64url",
45
+ "ascii85",
46
+ "base85",
47
+ "z85",
48
+ "radix"
43
49
  ],
44
50
  "author": "misebox",
45
51
  "license": "ISC",
@@ -3,105 +3,142 @@ import { Buffer } from 'node:buffer';
3
3
  * Input type accepted by encode functions.
4
4
  *
5
5
  * Supports both Node.js `Buffer` and standard `Uint8Array` for browser compatibility.
6
- *
7
- * @example
8
- * ```typescript
9
- * // Node.js Buffer
10
- * encode(Buffer.from('Hello'), 'base58');
11
- *
12
- * // Browser Uint8Array
13
- * encode(new Uint8Array([72, 101, 108, 108, 111]), 'base58');
14
- * ```
15
6
  */
16
7
  export type BufferLike = Buffer | Uint8Array;
17
8
  /**
18
- * Supported base encoding names.
9
+ * How bytes are mapped to characters.
19
10
  *
20
- * These names can be used with the function API:
21
- * - `'decimal'` - Base 10 (0-9)
22
- * - `'base16'` / `'hex'` - Hexadecimal (0-9A-F)
23
- * - `'base32'` - RFC 4648 Base32 (A-Z2-7)
24
- * - `'base32crockford'` - Crockford's Base32 (0-9A-HJKMNP-TV-Z)
25
- * - `'base36'` - Alphanumeric (0-9A-Z)
26
- * - `'base52'` - Letters only (A-Za-z)
27
- * - `'base58'` - Bitcoin alphabet (no 0OIl)
28
- * - `'base64'` - Standard Base64 (A-Za-z0-9+/)
29
- * - `'base64url'` - URL-safe Base64 (A-Za-z0-9-_)
30
- * - `'base64xml'` - XML token Base64 (A-Za-z0-9._)
31
- * - `'base64xmlname'` - XML name Base64 (A-Za-z0-9_:)
32
- * - `'ascii85'` - ASCII85 encoding
33
- * - `'base85'` - Base85 encoding
34
- * - `'z85'` - ZeroMQ Z85 encoding
11
+ * An alphabet alone does not determine an encoding: the same 64 characters can
12
+ * be used by a radix conversion or by a bit-block encoding, producing different
13
+ * output. Every codec therefore names its algorithm explicitly.
14
+ *
15
+ * - `'radix'` treats the whole buffer as one big integer and rewrites it in
16
+ * base `alphabet.length`. Works with any alphabet and any input length.
17
+ * Leading zero bytes are preserved as leading `alphabet[0]` characters.
18
+ * Used by Base58, Base36, and custom alphabets. Not RFC 4648.
19
+ * - `'block'` regroups the bit stream into `log2(alphabet.length)`-bit chunks,
20
+ * as specified by RFC 4648. Requires an alphabet of 2, 4, 8, 16, 32, or 64
21
+ * characters. Used by Base16, Base32, and Base64.
22
+ * - `'block85'` — converts each 4-byte block to 5 characters (85^5 > 2^32).
23
+ * Requires an alphabet of exactly 85 characters. Used by Ascii85 and Z85.
24
+ */
25
+ export type Algorithm = 'radix' | 'block' | 'block85';
26
+ /** Options shared by every algorithm. */
27
+ interface CommonSpec {
28
+ /** Characters used for encoding, ordered by value. */
29
+ readonly alphabet: string;
30
+ /**
31
+ * Reject input that is well-formed but not the canonical encoding of any
32
+ * byte sequence (RFC 4648 §3.5). Defaults to `true`.
33
+ *
34
+ * With `strict: false`, `'Zm9='` and `'Zm8='` both decode to `'fo'`, so
35
+ * decoding is no longer injective. Only disable it to read data produced by
36
+ * a lenient encoder.
37
+ */
38
+ readonly strict?: boolean;
39
+ /**
40
+ * Accept either letter case when decoding, and when validating.
41
+ * Requires an alphabet that does not contain both cases of the same letter.
42
+ * Defaults to `false`.
43
+ */
44
+ readonly caseInsensitive?: boolean;
45
+ /**
46
+ * Extra characters accepted when decoding, each mapped to the alphabet
47
+ * character it stands for.
48
+ *
49
+ * Crockford's Base32 uses `{ I: '1', L: '1', O: '0' }` so that a symbol
50
+ * written down by hand is read back as the digit it resembles. Encoding
51
+ * never emits them.
52
+ */
53
+ readonly aliases?: Readonly<Record<string, string>>;
54
+ /**
55
+ * Characters skipped when decoding, such as the hyphens Crockford's Base32
56
+ * allows for readability. Encoding never emits them.
57
+ */
58
+ readonly ignore?: string;
59
+ }
60
+ /** A codec that rewrites the buffer as an integer in base `alphabet.length`. */
61
+ export interface RadixSpec extends CommonSpec {
62
+ readonly algorithm: 'radix';
63
+ /**
64
+ * Symbols that extend the alphabet for a trailing check symbol, which
65
+ * encodes the value modulo `alphabet.length + checkSymbols.length`.
66
+ *
67
+ * Crockford's Base32 uses `'*~$=U'`, giving a modulus of 37. When set, every
68
+ * encoding carries the symbol and every decoding verifies it.
69
+ */
70
+ readonly checkSymbols?: string;
71
+ }
72
+ /** A codec that regroups the bit stream, as specified by RFC 4648. */
73
+ export interface BlockSpec extends CommonSpec {
74
+ readonly algorithm: 'block';
75
+ /**
76
+ * Character used to pad the final block to a whole number of characters,
77
+ * or `false` to emit no padding. Defaults to `'='`.
78
+ */
79
+ readonly pad?: string | false;
80
+ }
81
+ /** A codec that converts each 4-byte block to 5 characters. */
82
+ export interface Block85Spec extends CommonSpec {
83
+ readonly algorithm: 'block85';
84
+ /** Write a block of four zero bytes as `'z'`. Defaults to `false`. */
85
+ readonly zeroShortcut?: boolean;
86
+ /** Write a block of four spaces as `'y'`. Defaults to `false`. */
87
+ readonly spaceShortcut?: boolean;
88
+ /** Wrap the output in `'<~'` and `'~>'`. Defaults to `false`. */
89
+ readonly delimiters?: boolean;
90
+ /**
91
+ * Require the input length to be a multiple of 4 bytes, as Z85 does.
92
+ * Defaults to `false`, which encodes a trailing partial block as
93
+ * `length + 1` characters.
94
+ */
95
+ readonly requireFullBlocks?: boolean;
96
+ }
97
+ /**
98
+ * A complete codec definition: an alphabet plus the algorithm that uses it.
35
99
  *
36
100
  * @example
37
101
  * ```typescript
38
- * import { encode, decode } from 'bufferbase';
102
+ * import { encode, type CodecSpec } from 'bufferbase';
39
103
  *
40
- * const encoded = encode(Buffer.from('Hello'), 'base58');
41
- * const decoded = decode(encoded, 'base58');
104
+ * const binary: CodecSpec = { alphabet: '01', algorithm: 'radix' };
105
+ * encode(Uint8Array.of(5), binary); // '101'
42
106
  * ```
43
107
  */
44
- export type BaseName = 'decimal' | 'base16' | 'hex' | 'base32' | 'base32crockford' | 'base36' | 'base52' | 'base58' | 'base64' | 'base64url' | 'base64xml' | 'base64xmlname' | 'ascii85' | 'base85' | 'z85';
108
+ export type CodecSpec = RadixSpec | BlockSpec | Block85Spec;
45
109
  /**
46
110
  * Options for decode operations.
47
- *
48
- * @example
49
- * ```typescript
50
- * // Decode with fixed buffer size (pads with leading zeros)
51
- * const buffer = decode(encoded, 'base58', { size: 32 });
52
- * ```
53
111
  */
54
112
  export interface DecodeOptions {
55
113
  /**
56
- * Expected buffer size in bytes.
57
- * - If decoded result is smaller, pads with leading zeros.
58
- * - If decoded result is larger, throws `BufferSizeError`.
114
+ * Required byte length of the result.
115
+ *
116
+ * The decoded buffer must be exactly this long, otherwise `BufferSizeError`
117
+ * is thrown. Because leading zeros carry no value in a radix encoding, a
118
+ * `'radix'` codec pads a shorter result with leading zero bytes to reach it;
119
+ * `'block'` and `'block85'` codecs derive the length from the input and can
120
+ * only check it.
59
121
  */
60
122
  size?: number;
61
123
  }
62
124
  /**
63
125
  * Codec interface for encoding/decoding operations.
64
126
  *
65
- * Implemented by the `Codec` class and used by pre-defined codecs in `Codecs`.
66
- *
67
- * @example
68
- * ```typescript
69
- * import { Codecs } from 'bufferbase';
70
- *
71
- * const encoded = Codecs.base58.encode(Buffer.from('Hello'));
72
- * const decoded = Codecs.base58.decode(encoded);
73
- * ```
127
+ * `validate(input)` returns `true` exactly when `decode(input)` succeeds.
74
128
  */
75
129
  export interface ICodec {
76
130
  /** Character set used for encoding. */
77
131
  readonly chars: string;
78
- /**
79
- * Encodes a buffer to a base-encoded string.
80
- * @param buffer - The buffer or Uint8Array to encode
81
- * @returns Base-encoded string
82
- */
132
+ /** The algorithm this codec applies to `chars`. */
133
+ readonly algorithm: Algorithm;
134
+ /** Encodes a buffer to a base-encoded string. */
83
135
  encode(buffer: BufferLike): string;
84
- /**
85
- * Decodes a base-encoded string to a buffer.
86
- * @param encoded - The string to decode
87
- * @param options - Decode options (e.g., fixed size)
88
- * @returns Decoded buffer
89
- * @throws {InvalidCharacterError} If the string contains invalid characters
90
- * @throws {BufferSizeError} If the result exceeds the specified size
91
- */
136
+ /** Decodes a base-encoded string to a buffer. */
92
137
  decode(encoded: string, options?: DecodeOptions): Buffer;
93
- /**
94
- * Validates if a string contains only valid characters for this base.
95
- * @param input - The string to validate
96
- * @returns `true` if valid, `false` otherwise
97
- */
138
+ /** Reports whether `decode` would succeed for this input. */
98
139
  validate(input: string): boolean;
99
- /**
100
- * Converts a string from this base to another base.
101
- * @param target - Target codec to convert to
102
- * @param input - The string to convert
103
- * @returns String in the target base encoding
104
- */
140
+ /** Decodes with this codec, then re-encodes with `target`. */
105
141
  convertTo(target: ICodec, input: string): string;
106
142
  }
143
+ export {};
107
144
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/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WAAW,aAAa;IAC5B;;;;;;;;OAQG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;GAIG;AACH,MAAM,WAAW,MAAM;IACrB,uCAAuC;IACvC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAEvB,mDAAmD;IACnD,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAE9B,iDAAiD;IACjD,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC;IAEnC,iDAAiD;IACjD,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,MAAM,CAAC;IAEzD,6DAA6D;IAC7D,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;IAEjC,8DAA8D;IAC9D,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;CAClD"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bufferbase",
3
- "version": "2.0.0",
4
- "description": "Buffer-to-BaseN Encoder, Decoder, Converter, and Validator",
3
+ "version": "3.0.0",
4
+ "description": "Buffer-to-BaseN encoding: RFC 4648 block encodings, Ascii85/Z85, and Base58-style radix conversion",
5
5
  "sideEffects": false,
6
6
  "type": "module",
7
7
  "main": "./dist/cjs/index.js",
@@ -26,7 +26,8 @@
26
26
  "build:esm": "tsc -p tsconfig.json",
27
27
  "prepublishOnly": "bun run build",
28
28
  "example": "bun src/example.ts",
29
- "test": "bun test"
29
+ "test": "bun test",
30
+ "release": "bin/release"
30
31
  },
31
32
  "devDependencies": {
32
33
  "@types/bun": "^1.1.0",
@@ -43,19 +44,24 @@
43
44
  "src"
44
45
  ],
45
46
  "keywords": [
46
- "number",
47
47
  "encode",
48
+ "decode",
48
49
  "convert",
49
- "decimal",
50
50
  "base",
51
+ "rfc4648",
51
52
  "base16",
53
+ "hex",
52
54
  "base32",
55
+ "base32hex",
53
56
  "crockford",
54
57
  "base36",
55
58
  "base58",
56
59
  "base64",
57
- "Ascii85",
58
- "base85"
60
+ "base64url",
61
+ "ascii85",
62
+ "base85",
63
+ "z85",
64
+ "radix"
59
65
  ],
60
66
  "author": "misebox",
61
67
  "license": "ISC",