Add comprehensive installation and setup documentation

- Add GETTING_STARTED.md with quick start guide and development modes
- Add INSTALL.sh automated installation script
- Add INSTALLATION_CHECKLIST.md, INSTALLATION_SUCCESS.md, and INSTALLATION_SUMMARY.md
- Add QUICK_REFERENCE.md for common commands
- Add SETUP_GUIDE.md with detailed setup instructions
- Update README.md with improved project overview
- Add did-wallet app dependencies and node_modules
This commit is contained in:
Dorian
2026-01-27 17:18:21 +00:00
parent a81f655133
commit 0d073fa89e
22658 changed files with 4494151 additions and 6 deletions
+4
View File
@@ -0,0 +1,4 @@
This project is dual licensed under MIT and Apache-2.0.
MIT: https://www.opensource.org/licenses/mit
Apache-2.0: https://www.apache.org/licenses/license-2.0
+176
View File
@@ -0,0 +1,176 @@
[![codecov](https://img.shields.io/codecov/c/github/achingbrain/uint8arrays.svg?style=flat-square)](https://codecov.io/gh/achingbrain/uint8arrays)
[![CI](https://img.shields.io/github/actions/workflow/status/achingbrain/uint8arrays/js-test-and-release.yml?branch=main\&style=flat-square)](https://github.com/achingbrain/uint8arrays/actions/workflows/js-test-and-release.yml?query=branch%3Amain)
> Utility functions to make dealing with Uint8Arrays easier
# About
`Uint8Array`s bring memory-efficient(ish) byte handling to browsers - they are similar to Node.js `Buffer`s but lack a lot of the utility methods present on that class.
This module exports a number of function that let you do common operations - joining Uint8Arrays together, seeing if they have the same contents etc.
Since Node.js `Buffer`s are also `Uint8Array`s, it falls back to `Buffer` internally where it makes sense for performance reasons.
## alloc(size)
Create a new `Uint8Array`. If `globalThis.Buffer` is defined, it will be used in preference to `globalThis.Uint8Array`.
### Example
```js
import { alloc } from 'uint8arrays/alloc'
const buf = alloc(100)
```
## allocUnsafe(size)
Create a new `Uint8Array`. If `globalThis.Buffer` is defined, it will be used in preference to `globalThis.Uint8Array`.
On platforms that support it, memory referenced by the returned `Uint8Array` will not be initialized.
### Example
```js
import { allocUnsafe } from 'uint8arrays/alloc'
const buf = allocUnsafe(100)
```
## compare(a, b)
Compare two `Uint8Arrays`
### Example
```js
import { compare } from 'uint8arrays/compare'
const arrays = [
Uint8Array.from([3, 4, 5]),
Uint8Array.from([0, 1, 2])
]
const sorted = arrays.sort(compare)
console.info(sorted)
// [
// Uint8Array[0, 1, 2]
// Uint8Array[3, 4, 5]
// ]
```
## concat(arrays, \[length])
Concatenate one or more `Uint8Array`s and return a `Uint8Array` with their contents.
If you know the length of the arrays, pass it as a second parameter, otherwise it will be calculated by traversing the list of arrays.
### Example
```js
import { concat } from 'uint8arrays/concat'
const arrays = [
Uint8Array.from([0, 1, 2]),
Uint8Array.from([3, 4, 5])
]
const all = concat(arrays, 6)
console.info(all)
// Uint8Array[0, 1, 2, 3, 4, 5]
```
## equals(a, b)
Returns true if the two arrays are the same array or if they have the same length and contents.
### Example
```js
import { equals } from 'uint8arrays/equals'
const a = Uint8Array.from([0, 1, 2])
const b = Uint8Array.from([3, 4, 5])
const c = Uint8Array.from([0, 1, 2])
console.info(equals(a, b)) // false
console.info(equals(a, c)) // true
console.info(equals(a, a)) // true
```
## fromString(string, encoding = 'utf8')
Returns a new `Uint8Array` created from the passed string and interpreted as the passed encoding.
Supports `utf8` and any of the [multibase encodings](https://github.com/multiformats/multibase/blob/master/multibase.csv) as implemented by the [multiformats module](https://www.npmjs.com/package/multiformats).
### Example
```js
import { fromString } from 'uint8arrays/from-string'
console.info(fromString('hello world')) // Uint8Array[104, 101 ...
console.info(fromString('00010203aabbcc', 'base16')) // Uint8Array[0, 1 ...
console.info(fromString('AAECA6q7zA', 'base64')) // Uint8Array[0, 1 ...
console.info(fromString('01234', 'ascii')) // Uint8Array[48, 49 ...
```
## toString(array, encoding = 'utf8')
Returns a string created from the passed `Uint8Array` in the passed encoding.
Supports `utf8` and any of the [multibase encodings](https://github.com/multiformats/multibase/blob/master/multibase.csv) as implemented by the [multiformats module](https://www.npmjs.com/package/multiformats).
### Example
```js
import { toString } from 'uint8arrays/to-string'
console.info(toString(Uint8Array.from([104, 101...]))) // 'hello world'
console.info(toString(Uint8Array.from([0, 1, 2...]), 'base16')) // '00010203aabbcc'
console.info(toString(Uint8Array.from([0, 1, 2...]), 'base64')) // 'AAECA6q7zA'
console.info(toString(Uint8Array.from([48, 49, 50...]), 'ascii')) // '01234'
```
## xor(a, b)
Returns a `Uint8Array` containing `a` and `b` xored together.
### Example
```js
import { xor } from 'uint8arrays/xor'
console.info(xor(Uint8Array.from([1, 0]), Uint8Array.from([0, 1]))) // Uint8Array[1, 1]
```
# Install
```console
$ npm i uint8arrays
```
## Browser `<script>` tag
Loading this module through a script tag will make it's exports available as `Uint8arrays` in the global namespace.
```html
<script src="https://unpkg.com/uint8arrays/dist/index.min.js"></script>
```
# API Docs
- <https://achingbrain.github.io/uint8arrays>
# License
Licensed under either of
- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
# Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
File diff suppressed because one or more lines are too long
+12
View File
@@ -0,0 +1,12 @@
/**
* Returns a `Uint8Array` of the requested size. Referenced memory will
* be initialized to 0.
*/
export declare function alloc(size?: number): Uint8Array;
/**
* Where possible returns a Uint8Array of the requested size that references
* uninitialized memory. Only use if you are certain you will immediately
* overwrite every value in the returned `Uint8Array`.
*/
export declare function allocUnsafe(size?: number): Uint8Array;
//# sourceMappingURL=alloc.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"alloc.d.ts","sourceRoot":"","sources":["../../src/alloc.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,KAAK,CAAE,IAAI,GAAE,MAAU,GAAG,UAAU,CAMnD;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAE,IAAI,GAAE,MAAU,GAAG,UAAU,CAMzD"}
+23
View File
@@ -0,0 +1,23 @@
import { asUint8Array } from './util/as-uint8array.js';
/**
* Returns a `Uint8Array` of the requested size. Referenced memory will
* be initialized to 0.
*/
export function alloc(size = 0) {
if (globalThis.Buffer?.alloc != null) {
return asUint8Array(globalThis.Buffer.alloc(size));
}
return new Uint8Array(size);
}
/**
* Where possible returns a Uint8Array of the requested size that references
* uninitialized memory. Only use if you are certain you will immediately
* overwrite every value in the returned `Uint8Array`.
*/
export function allocUnsafe(size = 0) {
if (globalThis.Buffer?.allocUnsafe != null) {
return asUint8Array(globalThis.Buffer.allocUnsafe(size));
}
return new Uint8Array(size);
}
//# sourceMappingURL=alloc.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"alloc.js","sourceRoot":"","sources":["../../src/alloc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAEtD;;;GAGG;AACH,MAAM,UAAU,KAAK,CAAE,OAAe,CAAC;IACrC,IAAI,UAAU,CAAC,MAAM,EAAE,KAAK,IAAI,IAAI,EAAE,CAAC;QACrC,OAAO,YAAY,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;IACpD,CAAC;IAED,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,CAAA;AAC7B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAE,OAAe,CAAC;IAC3C,IAAI,UAAU,CAAC,MAAM,EAAE,WAAW,IAAI,IAAI,EAAE,CAAC;QAC3C,OAAO,YAAY,CAAC,UAAU,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAA;IAC1D,CAAC;IAED,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,CAAA;AAC7B,CAAC"}
+5
View File
@@ -0,0 +1,5 @@
/**
* Can be used with Array.sort to sort and array with Uint8Array entries
*/
export declare function compare(a: Uint8Array, b: Uint8Array): number;
//# sourceMappingURL=compare.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"compare.d.ts","sourceRoot":"","sources":["../../src/compare.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,OAAO,CAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,GAAG,MAAM,CAwB7D"}
+24
View File
@@ -0,0 +1,24 @@
/**
* Can be used with Array.sort to sort and array with Uint8Array entries
*/
export function compare(a, b) {
if (globalThis.Buffer != null) {
return globalThis.Buffer.compare(a, b);
}
for (let i = 0; i < a.byteLength; i++) {
if (a[i] < b[i]) {
return -1;
}
if (a[i] > b[i]) {
return 1;
}
}
if (a.byteLength > b.byteLength) {
return 1;
}
if (a.byteLength < b.byteLength) {
return -1;
}
return 0;
}
//# sourceMappingURL=compare.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"compare.js","sourceRoot":"","sources":["../../src/compare.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,OAAO,CAAE,CAAa,EAAE,CAAa;IACnD,IAAI,UAAU,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC;QAC9B,OAAO,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IACxC,CAAC;IAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAChB,OAAO,CAAC,CAAC,CAAA;QACX,CAAC;QAED,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAChB,OAAO,CAAC,CAAA;QACV,CAAC;IACH,CAAC;IAED,IAAI,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,UAAU,EAAE,CAAC;QAChC,OAAO,CAAC,CAAA;IACV,CAAC;IAED,IAAI,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,UAAU,EAAE,CAAC;QAChC,OAAO,CAAC,CAAC,CAAA;IACX,CAAC;IAED,OAAO,CAAC,CAAA;AACV,CAAC"}
+5
View File
@@ -0,0 +1,5 @@
/**
* Returns a new Uint8Array created by concatenating the passed ArrayLikes
*/
export declare function concat(arrays: Array<ArrayLike<number>>, length?: number): Uint8Array;
//# sourceMappingURL=concat.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"concat.d.ts","sourceRoot":"","sources":["../../src/concat.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAgB,MAAM,CAAE,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,UAAU,CAcrF"}
+18
View File
@@ -0,0 +1,18 @@
import { allocUnsafe } from './alloc.js';
import { asUint8Array } from './util/as-uint8array.js';
/**
* Returns a new Uint8Array created by concatenating the passed ArrayLikes
*/
export function concat(arrays, length) {
if (length == null) {
length = arrays.reduce((acc, curr) => acc + curr.length, 0);
}
const output = allocUnsafe(length);
let offset = 0;
for (const arr of arrays) {
output.set(arr, offset);
offset += arr.length;
}
return asUint8Array(output);
}
//# sourceMappingURL=concat.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"concat.js","sourceRoot":"","sources":["../../src/concat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAEtD;;GAEG;AACH,MAAM,UAAU,MAAM,CAAE,MAAgC,EAAE,MAAe;IACvE,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;QACnB,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;IAC7D,CAAC;IAED,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,CAAA;IAClC,IAAI,MAAM,GAAG,CAAC,CAAA;IAEd,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;QACzB,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;QACvB,MAAM,IAAI,GAAG,CAAC,MAAM,CAAA;IACtB,CAAC;IAED,OAAO,YAAY,CAAC,MAAM,CAAC,CAAA;AAC7B,CAAC"}
+5
View File
@@ -0,0 +1,5 @@
/**
* Returns true if the two passed Uint8Arrays have the same content
*/
export declare function equals(a: Uint8Array, b: Uint8Array): boolean;
//# sourceMappingURL=equals.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"equals.d.ts","sourceRoot":"","sources":["../../src/equals.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,MAAM,CAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,GAAG,OAAO,CAgB7D"}
+18
View File
@@ -0,0 +1,18 @@
/**
* Returns true if the two passed Uint8Arrays have the same content
*/
export function equals(a, b) {
if (a === b) {
return true;
}
if (a.byteLength !== b.byteLength) {
return false;
}
for (let i = 0; i < a.byteLength; i++) {
if (a[i] !== b[i]) {
return false;
}
}
return true;
}
//# sourceMappingURL=equals.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"equals.js","sourceRoot":"","sources":["../../src/equals.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,MAAM,CAAE,CAAa,EAAE,CAAa;IAClD,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACZ,OAAO,IAAI,CAAA;IACb,CAAC;IAED,IAAI,CAAC,CAAC,UAAU,KAAK,CAAC,CAAC,UAAU,EAAE,CAAC;QAClC,OAAO,KAAK,CAAA;IACd,CAAC;IAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAClB,OAAO,KAAK,CAAA;QACd,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC"}
+11
View File
@@ -0,0 +1,11 @@
import { type SupportedEncodings } from './util/bases.js';
export type { SupportedEncodings };
/**
* Create a `Uint8Array` from the passed string
*
* Supports `utf8`, `utf-8`, `hex`, and any encoding supported by the multiformats module.
*
* Also `ascii` which is similar to node's 'binary' encoding.
*/
export declare function fromString(string: string, encoding?: SupportedEncodings): Uint8Array;
//# sourceMappingURL=from-string.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"from-string.d.ts","sourceRoot":"","sources":["../../src/from-string.ts"],"names":[],"mappings":"AACA,OAAc,EAAE,KAAK,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAEhE,YAAY,EAAE,kBAAkB,EAAE,CAAA;AAElC;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAE,kBAA2B,GAAG,UAAU,CAa7F"}
+21
View File
@@ -0,0 +1,21 @@
import { asUint8Array } from './util/as-uint8array.js';
import bases, {} from './util/bases.js';
/**
* Create a `Uint8Array` from the passed string
*
* Supports `utf8`, `utf-8`, `hex`, and any encoding supported by the multiformats module.
*
* Also `ascii` which is similar to node's 'binary' encoding.
*/
export function fromString(string, encoding = 'utf8') {
const base = bases[encoding];
if (base == null) {
throw new Error(`Unsupported encoding "${encoding}"`);
}
if ((encoding === 'utf8' || encoding === 'utf-8') && globalThis.Buffer != null && globalThis.Buffer.from != null) {
return asUint8Array(globalThis.Buffer.from(string, 'utf-8'));
}
// add multibase prefix
return base.decoder.decode(`${base.prefix}${string}`); // eslint-disable-line @typescript-eslint/restrict-template-expressions
}
//# sourceMappingURL=from-string.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"from-string.js","sourceRoot":"","sources":["../../src/from-string.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AACtD,OAAO,KAAK,EAAE,EAA2B,MAAM,iBAAiB,CAAA;AAIhE;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAE,MAAc,EAAE,WAA+B,MAAM;IAC/E,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAA;IAE5B,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,yBAAyB,QAAQ,GAAG,CAAC,CAAA;IACvD,CAAC;IAED,IAAI,CAAC,QAAQ,KAAK,MAAM,IAAI,QAAQ,KAAK,OAAO,CAAC,IAAI,UAAU,CAAC,MAAM,IAAI,IAAI,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,IAAI,IAAI,EAAE,CAAC;QACjH,OAAO,YAAY,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;IAC9D,CAAC;IAED,uBAAuB;IACvB,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,CAAA,CAAC,uEAAuE;AAC/H,CAAC"}
+153
View File
@@ -0,0 +1,153 @@
/**
* @packageDocumentation
*
* `Uint8Array`s bring memory-efficient(ish) byte handling to browsers - they are similar to Node.js `Buffer`s but lack a lot of the utility methods present on that class.
*
* This module exports a number of function that let you do common operations - joining Uint8Arrays together, seeing if they have the same contents etc.
*
* Since Node.js `Buffer`s are also `Uint8Array`s, it falls back to `Buffer` internally where it makes sense for performance reasons.
*
* ## alloc(size)
*
* Create a new `Uint8Array`. If `globalThis.Buffer` is defined, it will be used in preference to `globalThis.Uint8Array`.
*
* ### Example
*
* ```js
* import { alloc } from 'uint8arrays/alloc'
*
* const buf = alloc(100)
* ```
*
* ## allocUnsafe(size)
*
* Create a new `Uint8Array`. If `globalThis.Buffer` is defined, it will be used in preference to `globalThis.Uint8Array`.
*
* On platforms that support it, memory referenced by the returned `Uint8Array` will not be initialized.
*
* ### Example
*
* ```js
* import { allocUnsafe } from 'uint8arrays/alloc'
*
* const buf = allocUnsafe(100)
* ```
*
* ## compare(a, b)
*
* Compare two `Uint8Arrays`
*
* ### Example
*
* ```js
* import { compare } from 'uint8arrays/compare'
*
* const arrays = [
* Uint8Array.from([3, 4, 5]),
* Uint8Array.from([0, 1, 2])
* ]
*
* const sorted = arrays.sort(compare)
*
* console.info(sorted)
* // [
* // Uint8Array[0, 1, 2]
* // Uint8Array[3, 4, 5]
* // ]
* ```
*
* ## concat(arrays, \[length])
*
* Concatenate one or more `Uint8Array`s and return a `Uint8Array` with their contents.
*
* If you know the length of the arrays, pass it as a second parameter, otherwise it will be calculated by traversing the list of arrays.
*
* ### Example
*
* ```js
* import { concat } from 'uint8arrays/concat'
*
* const arrays = [
* Uint8Array.from([0, 1, 2]),
* Uint8Array.from([3, 4, 5])
* ]
*
* const all = concat(arrays, 6)
*
* console.info(all)
* // Uint8Array[0, 1, 2, 3, 4, 5]
* ```
*
* ## equals(a, b)
*
* Returns true if the two arrays are the same array or if they have the same length and contents.
*
* ### Example
*
* ```js
* import { equals } from 'uint8arrays/equals'
*
* const a = Uint8Array.from([0, 1, 2])
* const b = Uint8Array.from([3, 4, 5])
* const c = Uint8Array.from([0, 1, 2])
*
* console.info(equals(a, b)) // false
* console.info(equals(a, c)) // true
* console.info(equals(a, a)) // true
* ```
*
* ## fromString(string, encoding = 'utf8')
*
* Returns a new `Uint8Array` created from the passed string and interpreted as the passed encoding.
*
* Supports `utf8` and any of the [multibase encodings](https://github.com/multiformats/multibase/blob/master/multibase.csv) as implemented by the [multiformats module](https://www.npmjs.com/package/multiformats).
*
* ### Example
*
* ```js
* import { fromString } from 'uint8arrays/from-string'
*
* console.info(fromString('hello world')) // Uint8Array[104, 101 ...
* console.info(fromString('00010203aabbcc', 'base16')) // Uint8Array[0, 1 ...
* console.info(fromString('AAECA6q7zA', 'base64')) // Uint8Array[0, 1 ...
* console.info(fromString('01234', 'ascii')) // Uint8Array[48, 49 ...
* ```
*
* ## toString(array, encoding = 'utf8')
*
* Returns a string created from the passed `Uint8Array` in the passed encoding.
*
* Supports `utf8` and any of the [multibase encodings](https://github.com/multiformats/multibase/blob/master/multibase.csv) as implemented by the [multiformats module](https://www.npmjs.com/package/multiformats).
*
* ### Example
*
* ```js
* import { toString } from 'uint8arrays/to-string'
*
* console.info(toString(Uint8Array.from([104, 101...]))) // 'hello world'
* console.info(toString(Uint8Array.from([0, 1, 2...]), 'base16')) // '00010203aabbcc'
* console.info(toString(Uint8Array.from([0, 1, 2...]), 'base64')) // 'AAECA6q7zA'
* console.info(toString(Uint8Array.from([48, 49, 50...]), 'ascii')) // '01234'
* ```
*
* ## xor(a, b)
*
* Returns a `Uint8Array` containing `a` and `b` xored together.
*
* ### Example
*
* ```js
* import { xor } from 'uint8arrays/xor'
*
* console.info(xor(Uint8Array.from([1, 0]), Uint8Array.from([0, 1]))) // Uint8Array[1, 1]
* ```
*/
import { compare } from './compare.js';
import { concat } from './concat.js';
import { equals } from './equals.js';
import { fromString } from './from-string.js';
import { toString } from './to-string.js';
import { xor } from './xor.js';
export { compare, concat, equals, fromString, toString, xor };
export type { SupportedEncodings } from './util/bases.js';
//# sourceMappingURL=index.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+IG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAE9B,OAAO,EACL,OAAO,EACP,MAAM,EACN,MAAM,EACN,UAAU,EACV,QAAQ,EACR,GAAG,EACJ,CAAA;AAED,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA"}
+152
View File
@@ -0,0 +1,152 @@
/**
* @packageDocumentation
*
* `Uint8Array`s bring memory-efficient(ish) byte handling to browsers - they are similar to Node.js `Buffer`s but lack a lot of the utility methods present on that class.
*
* This module exports a number of function that let you do common operations - joining Uint8Arrays together, seeing if they have the same contents etc.
*
* Since Node.js `Buffer`s are also `Uint8Array`s, it falls back to `Buffer` internally where it makes sense for performance reasons.
*
* ## alloc(size)
*
* Create a new `Uint8Array`. If `globalThis.Buffer` is defined, it will be used in preference to `globalThis.Uint8Array`.
*
* ### Example
*
* ```js
* import { alloc } from 'uint8arrays/alloc'
*
* const buf = alloc(100)
* ```
*
* ## allocUnsafe(size)
*
* Create a new `Uint8Array`. If `globalThis.Buffer` is defined, it will be used in preference to `globalThis.Uint8Array`.
*
* On platforms that support it, memory referenced by the returned `Uint8Array` will not be initialized.
*
* ### Example
*
* ```js
* import { allocUnsafe } from 'uint8arrays/alloc'
*
* const buf = allocUnsafe(100)
* ```
*
* ## compare(a, b)
*
* Compare two `Uint8Arrays`
*
* ### Example
*
* ```js
* import { compare } from 'uint8arrays/compare'
*
* const arrays = [
* Uint8Array.from([3, 4, 5]),
* Uint8Array.from([0, 1, 2])
* ]
*
* const sorted = arrays.sort(compare)
*
* console.info(sorted)
* // [
* // Uint8Array[0, 1, 2]
* // Uint8Array[3, 4, 5]
* // ]
* ```
*
* ## concat(arrays, \[length])
*
* Concatenate one or more `Uint8Array`s and return a `Uint8Array` with their contents.
*
* If you know the length of the arrays, pass it as a second parameter, otherwise it will be calculated by traversing the list of arrays.
*
* ### Example
*
* ```js
* import { concat } from 'uint8arrays/concat'
*
* const arrays = [
* Uint8Array.from([0, 1, 2]),
* Uint8Array.from([3, 4, 5])
* ]
*
* const all = concat(arrays, 6)
*
* console.info(all)
* // Uint8Array[0, 1, 2, 3, 4, 5]
* ```
*
* ## equals(a, b)
*
* Returns true if the two arrays are the same array or if they have the same length and contents.
*
* ### Example
*
* ```js
* import { equals } from 'uint8arrays/equals'
*
* const a = Uint8Array.from([0, 1, 2])
* const b = Uint8Array.from([3, 4, 5])
* const c = Uint8Array.from([0, 1, 2])
*
* console.info(equals(a, b)) // false
* console.info(equals(a, c)) // true
* console.info(equals(a, a)) // true
* ```
*
* ## fromString(string, encoding = 'utf8')
*
* Returns a new `Uint8Array` created from the passed string and interpreted as the passed encoding.
*
* Supports `utf8` and any of the [multibase encodings](https://github.com/multiformats/multibase/blob/master/multibase.csv) as implemented by the [multiformats module](https://www.npmjs.com/package/multiformats).
*
* ### Example
*
* ```js
* import { fromString } from 'uint8arrays/from-string'
*
* console.info(fromString('hello world')) // Uint8Array[104, 101 ...
* console.info(fromString('00010203aabbcc', 'base16')) // Uint8Array[0, 1 ...
* console.info(fromString('AAECA6q7zA', 'base64')) // Uint8Array[0, 1 ...
* console.info(fromString('01234', 'ascii')) // Uint8Array[48, 49 ...
* ```
*
* ## toString(array, encoding = 'utf8')
*
* Returns a string created from the passed `Uint8Array` in the passed encoding.
*
* Supports `utf8` and any of the [multibase encodings](https://github.com/multiformats/multibase/blob/master/multibase.csv) as implemented by the [multiformats module](https://www.npmjs.com/package/multiformats).
*
* ### Example
*
* ```js
* import { toString } from 'uint8arrays/to-string'
*
* console.info(toString(Uint8Array.from([104, 101...]))) // 'hello world'
* console.info(toString(Uint8Array.from([0, 1, 2...]), 'base16')) // '00010203aabbcc'
* console.info(toString(Uint8Array.from([0, 1, 2...]), 'base64')) // 'AAECA6q7zA'
* console.info(toString(Uint8Array.from([48, 49, 50...]), 'ascii')) // '01234'
* ```
*
* ## xor(a, b)
*
* Returns a `Uint8Array` containing `a` and `b` xored together.
*
* ### Example
*
* ```js
* import { xor } from 'uint8arrays/xor'
*
* console.info(xor(Uint8Array.from([1, 0]), Uint8Array.from([0, 1]))) // Uint8Array[1, 1]
* ```
*/
import { compare } from './compare.js';
import { concat } from './concat.js';
import { equals } from './equals.js';
import { fromString } from './from-string.js';
import { toString } from './to-string.js';
import { xor } from './xor.js';
export { compare, concat, equals, fromString, toString, xor };
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+IG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAE9B,OAAO,EACL,OAAO,EACP,MAAM,EACN,MAAM,EACN,UAAU,EACV,QAAQ,EACR,GAAG,EACJ,CAAA"}
+11
View File
@@ -0,0 +1,11 @@
import { type SupportedEncodings } from './util/bases.js';
export type { SupportedEncodings };
/**
* Turns a `Uint8Array` into a string.
*
* Supports `utf8`, `utf-8` and any encoding supported by the multibase module.
*
* Also `ascii` which is similar to node's 'binary' encoding.
*/
export declare function toString(array: Uint8Array, encoding?: SupportedEncodings): string;
//# sourceMappingURL=to-string.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"to-string.d.ts","sourceRoot":"","sources":["../../src/to-string.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,KAAK,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAEhE,YAAY,EAAE,kBAAkB,EAAE,CAAA;AAElC;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,GAAE,kBAA2B,GAAG,MAAM,CAa1F"}
+20
View File
@@ -0,0 +1,20 @@
import bases, {} from './util/bases.js';
/**
* Turns a `Uint8Array` into a string.
*
* Supports `utf8`, `utf-8` and any encoding supported by the multibase module.
*
* Also `ascii` which is similar to node's 'binary' encoding.
*/
export function toString(array, encoding = 'utf8') {
const base = bases[encoding];
if (base == null) {
throw new Error(`Unsupported encoding "${encoding}"`);
}
if ((encoding === 'utf8' || encoding === 'utf-8') && globalThis.Buffer != null && globalThis.Buffer.from != null) {
return globalThis.Buffer.from(array.buffer, array.byteOffset, array.byteLength).toString('utf8');
}
// strip multibase prefix
return base.encoder.encode(array).substring(1);
}
//# sourceMappingURL=to-string.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"to-string.js","sourceRoot":"","sources":["../../src/to-string.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAA2B,MAAM,iBAAiB,CAAA;AAIhE;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CAAE,KAAiB,EAAE,WAA+B,MAAM;IAChF,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAA;IAE5B,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,yBAAyB,QAAQ,GAAG,CAAC,CAAA;IACvD,CAAC;IAED,IAAI,CAAC,QAAQ,KAAK,MAAM,IAAI,QAAQ,KAAK,OAAO,CAAC,IAAI,UAAU,CAAC,MAAM,IAAI,IAAI,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,IAAI,IAAI,EAAE,CAAC;QACjH,OAAO,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;IAClG,CAAC;IAED,yBAAyB;IACzB,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;AAChD,CAAC"}
@@ -0,0 +1,6 @@
/**
* To guarantee Uint8Array semantics, convert nodejs Buffers
* into vanilla Uint8Arrays
*/
export declare function asUint8Array(buf: Uint8Array): Uint8Array;
//# sourceMappingURL=as-uint8array.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"as-uint8array.d.ts","sourceRoot":"","sources":["../../../src/util/as-uint8array.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,YAAY,CAAE,GAAG,EAAE,UAAU,GAAG,UAAU,CAMzD"}
+11
View File
@@ -0,0 +1,11 @@
/**
* To guarantee Uint8Array semantics, convert nodejs Buffers
* into vanilla Uint8Arrays
*/
export function asUint8Array(buf) {
if (globalThis.Buffer != null) {
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
}
return buf;
}
//# sourceMappingURL=as-uint8array.js.map
@@ -0,0 +1 @@
{"version":3,"file":"as-uint8array.js","sourceRoot":"","sources":["../../../src/util/as-uint8array.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAE,GAAe;IAC3C,IAAI,UAAU,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC;QAC9B,OAAO,IAAI,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,UAAU,CAAC,CAAA;IACnE,CAAC;IAED,OAAO,GAAG,CAAA;AACZ,CAAC"}
+6
View File
@@ -0,0 +1,6 @@
import { bases } from 'multiformats/basics';
import type { MultibaseCodec } from 'multiformats';
export type SupportedEncodings = 'utf8' | 'utf-8' | 'hex' | 'latin1' | 'ascii' | 'binary' | keyof typeof bases;
declare const BASES: Record<SupportedEncodings, MultibaseCodec<any>>;
export default BASES;
//# sourceMappingURL=bases.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"bases.d.ts","sourceRoot":"","sources":["../../../src/util/bases.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAE3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AA2ClD,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,OAAO,KAAK,CAAA;AAE9G,QAAA,MAAM,KAAK,EAAE,MAAM,CAAC,kBAAkB,EAAE,cAAc,CAAC,GAAG,CAAC,CAS1D,CAAA;AAED,eAAe,KAAK,CAAA"}
+48
View File
@@ -0,0 +1,48 @@
import { bases } from 'multiformats/basics';
import { allocUnsafe } from '../alloc.js';
function createCodec(name, prefix, encode, decode) {
return {
name,
prefix,
encoder: {
name,
prefix,
encode
},
decoder: {
decode
}
};
}
const string = createCodec('utf8', 'u', (buf) => {
const decoder = new TextDecoder('utf8');
return 'u' + decoder.decode(buf);
}, (str) => {
const encoder = new TextEncoder();
return encoder.encode(str.substring(1));
});
const ascii = createCodec('ascii', 'a', (buf) => {
let string = 'a';
for (let i = 0; i < buf.length; i++) {
string += String.fromCharCode(buf[i]);
}
return string;
}, (str) => {
str = str.substring(1);
const buf = allocUnsafe(str.length);
for (let i = 0; i < str.length; i++) {
buf[i] = str.charCodeAt(i);
}
return buf;
});
const BASES = {
utf8: string,
'utf-8': string,
hex: bases.base16,
latin1: ascii,
ascii,
binary: ascii,
...bases
};
export default BASES;
//# sourceMappingURL=bases.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"bases.js","sourceRoot":"","sources":["../../../src/util/bases.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAGzC,SAAS,WAAW,CAAE,IAAY,EAAE,MAAc,EAAE,MAAmC,EAAE,MAAmC;IAC1H,OAAO;QACL,IAAI;QACJ,MAAM;QACN,OAAO,EAAE;YACP,IAAI;YACJ,MAAM;YACN,MAAM;SACP;QACD,OAAO,EAAE;YACP,MAAM;SACP;KACF,CAAA;AACH,CAAC;AAED,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE;IAC9C,MAAM,OAAO,GAAG,IAAI,WAAW,CAAC,MAAM,CAAC,CAAA;IACvC,OAAO,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;AAClC,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE;IACT,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAA;IACjC,OAAO,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAA;AACzC,CAAC,CAAC,CAAA;AAEF,MAAM,KAAK,GAAG,WAAW,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE;IAC9C,IAAI,MAAM,GAAG,GAAG,CAAA;IAEhB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACpC,MAAM,IAAI,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;IACvC,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE;IACT,GAAG,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;IACtB,MAAM,GAAG,GAAG,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;IAEnC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACpC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;IAC5B,CAAC;IAED,OAAO,GAAG,CAAA;AACZ,CAAC,CAAC,CAAA;AAIF,MAAM,KAAK,GAAoD;IAC7D,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,MAAM;IACf,GAAG,EAAE,KAAK,CAAC,MAAM;IACjB,MAAM,EAAE,KAAK;IACb,KAAK;IACL,MAAM,EAAE,KAAK;IAEb,GAAG,KAAK;CACT,CAAA;AAED,eAAe,KAAK,CAAA"}
+5
View File
@@ -0,0 +1,5 @@
/**
* Returns the xor distance between two arrays
*/
export declare function xor(a: Uint8Array, b: Uint8Array): Uint8Array;
//# sourceMappingURL=xor.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"xor.d.ts","sourceRoot":"","sources":["../../src/xor.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAgB,GAAG,CAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,GAAG,UAAU,CAY7D"}
+16
View File
@@ -0,0 +1,16 @@
import { allocUnsafe } from './alloc.js';
import { asUint8Array } from './util/as-uint8array.js';
/**
* Returns the xor distance between two arrays
*/
export function xor(a, b) {
if (a.length !== b.length) {
throw new Error('Inputs should have the same length');
}
const result = allocUnsafe(a.length);
for (let i = 0; i < a.length; i++) {
result[i] = a[i] ^ b[i];
}
return asUint8Array(result);
}
//# sourceMappingURL=xor.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"xor.js","sourceRoot":"","sources":["../../src/xor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAEtD;;GAEG;AACH,MAAM,UAAU,GAAG,CAAE,CAAa,EAAE,CAAa;IAC/C,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAA;IACvD,CAAC;IAED,MAAM,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;IAEpC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAClC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;IACzB,CAAC;IAED,OAAO,YAAY,CAAC,MAAM,CAAC,CAAA;AAC7B,CAAC"}
+18
View File
@@ -0,0 +1,18 @@
{
"alloc": "https://achingbrain.github.io/uint8arrays/functions/alloc.alloc.html",
"./alloc:alloc": "https://achingbrain.github.io/uint8arrays/functions/alloc.alloc.html",
"allocUnsafe": "https://achingbrain.github.io/uint8arrays/functions/alloc.allocUnsafe.html",
"./alloc:allocUnsafe": "https://achingbrain.github.io/uint8arrays/functions/alloc.allocUnsafe.html",
"compare": "https://achingbrain.github.io/uint8arrays/functions/compare.compare.html",
"./compare:compare": "https://achingbrain.github.io/uint8arrays/functions/compare.compare.html",
"concat": "https://achingbrain.github.io/uint8arrays/functions/concat.concat.html",
"./concat:concat": "https://achingbrain.github.io/uint8arrays/functions/concat.concat.html",
"equals": "https://achingbrain.github.io/uint8arrays/functions/equals.equals.html",
"./equals:equals": "https://achingbrain.github.io/uint8arrays/functions/equals.equals.html",
"fromString": "https://achingbrain.github.io/uint8arrays/functions/from_string.fromString.html",
"./from-string:fromString": "https://achingbrain.github.io/uint8arrays/functions/from_string.fromString.html",
"SupportedEncodings": "https://achingbrain.github.io/uint8arrays/types/index.SupportedEncodings.html",
"./to-string:toString": "https://achingbrain.github.io/uint8arrays/functions/to_string.toString.html",
"xor": "https://achingbrain.github.io/uint8arrays/functions/xor.xor.html",
"./xor:xor": "https://achingbrain.github.io/uint8arrays/functions/xor.xor.html"
}
@@ -0,0 +1,356 @@
## [12.1.3](https://github.com/multiformats/js-multiformats/compare/v12.1.2...v12.1.3) (2023-10-25)
### Trivial Changes
* **deps:** bump actions/setup-node from 3.8.1 to 3.8.2 ([f190ad7](https://github.com/multiformats/js-multiformats/commit/f190ad7da5a0a17b44a88645dfa58c532d51dd56))
### Dependencies
* **dev:** bump crypto-hash from 2.0.1 to 3.0.0 ([f5b9958](https://github.com/multiformats/js-multiformats/commit/f5b995889b0b30b2e655e618b561bdfdf7df5299))
## [12.1.2](https://github.com/multiformats/js-multiformats/compare/v12.1.1...v12.1.2) (2023-10-03)
### Bug Fixes
* switch interface method decl style ([a33d24f](https://github.com/multiformats/js-multiformats/commit/a33d24f3ca56e4b40c80a3237e419cda261aa3e6))
### Dependencies
* **dev:** bump aegir from 40.0.13 to 41.0.0 ([41f008b](https://github.com/multiformats/js-multiformats/commit/41f008b09378085adef4aede1dd504a4eba5fa80))
## [12.1.1](https://github.com/multiformats/js-multiformats/compare/v12.1.0...v12.1.1) (2023-09-05)
### Bug Fixes
* update link interface path in exports map ([#270](https://github.com/multiformats/js-multiformats/issues/270)) ([d38e4a8](https://github.com/multiformats/js-multiformats/commit/d38e4a8ba1d2d33c60481265356708df80ed925e))
### Trivial Changes
* **deps:** bump actions/checkout from 3 to 4 ([f94559e](https://github.com/multiformats/js-multiformats/commit/f94559e4a0fa7c4ad320261507040df5bc03f63a))
## [12.1.0](https://github.com/multiformats/js-multiformats/compare/v12.0.2...v12.1.0) (2023-08-28)
### Features
* add sha1 support ([4da0085](https://github.com/multiformats/js-multiformats/commit/4da008580dd3dc3fa2c5f14c5a3bf64fd99221e6))
## [12.0.2](https://github.com/multiformats/js-multiformats/compare/v12.0.1...v12.0.2) (2023-08-28)
### Bug Fixes
* linting ([3d74818](https://github.com/multiformats/js-multiformats/commit/3d74818e975099c7c83112434f7ed23a68b9af0a))
* remove old ts option ([638dbed](https://github.com/multiformats/js-multiformats/commit/638dbed357cfe65e4d3402899dde5a7620ab5ce7))
### Trivial Changes
* add or force update .github/workflows/js-test-and-release.yml ([21b7591](https://github.com/multiformats/js-multiformats/commit/21b75911e0aee1ba7a6be9687db83328cfd961b5))
* delete templates [skip ci] ([#263](https://github.com/multiformats/js-multiformats/issues/263)) ([d2b614d](https://github.com/multiformats/js-multiformats/commit/d2b614d34631537a97176657b478691ca0ab5522))
* **deps:** bump actions/setup-node from 3.5.0 to 3.8.0 ([7dcf225](https://github.com/multiformats/js-multiformats/commit/7dcf225914fd6cebfa9f5cf0f5897cc0a0f356ab))
* **deps:** bump actions/setup-node from 3.8.0 to 3.8.1 ([d7ec85c](https://github.com/multiformats/js-multiformats/commit/d7ec85c29500ff0a9bb02d2ea4c808047938ce97))
* **deps:** bump gozala/typescript-error-reporter-action ([4a36fb7](https://github.com/multiformats/js-multiformats/commit/4a36fb7ee49edb4300267b90301ef0e4300cbc46))
* Update .github/dependabot.yml [skip ci] ([58bebda](https://github.com/multiformats/js-multiformats/commit/58bebda0a892429bf125ea6bc2e4f0a2208b27a6))
### Dependencies
* **dev:** bump aegir from 37.12.1 to 40.0.11 ([d17424d](https://github.com/multiformats/js-multiformats/commit/d17424d257fd9995ad775d2309a67ae2dc4f3c54))
## [12.0.1](https://github.com/multiformats/js-multiformats/compare/v12.0.0...v12.0.1) (2023-06-15)
### Trivial Changes
* **deps:** bump codecov/codecov-action from 3.1.1 to 3.1.4 ([#256](https://github.com/multiformats/js-multiformats/issues/256)) ([910eeeb](https://github.com/multiformats/js-multiformats/commit/910eeeb36c9fe4bd087ee83e6cec03e03c2e1899))
### Dependencies
* **dev:** bump @types/node from 18.16.18 to 20.3.1 ([7a6d036](https://github.com/multiformats/js-multiformats/commit/7a6d036adc1c18d8311a978d339e323ebd724da8))
## [12.0.0](https://github.com/multiformats/js-multiformats/compare/v11.0.2...v12.0.0) (2023-06-14)
### ⚠ BREAKING CHANGES
* use aegir for ESM-only build/testing/release
### Features
* use aegir for ESM-only build/testing/release ([f82e61b](https://github.com/multiformats/js-multiformats/commit/f82e61bf1c6bfb67a709089e79ec57767fb1bcb7))
## [11.0.2](https://github.com/multiformats/js-multiformats/compare/v11.0.1...v11.0.2) (2023-03-09)
### Bug Fixes
* add interface files to the exports map ([#246](https://github.com/multiformats/js-multiformats/issues/246)) ([a58a398](https://github.com/multiformats/js-multiformats/commit/a58a39896d7264ba0bcbaf737cce7f3a65c644ba)), closes [/github.com/ipld/js-dag-cbor/blob/master/src/index.js#L9](https://github.com/multiformats//github.com/ipld/js-dag-cbor/blob/master/src/index.js/issues/L9)
## [11.0.1](https://github.com/multiformats/js-multiformats/compare/v11.0.0...v11.0.1) (2023-01-18)
### Bug Fixes
* throw on CID.parse v0 string with multibase prefix ([258a0be](https://github.com/multiformats/js-multiformats/commit/258a0be344ddd5d08e08e55b3e088212df0c409a))
## [11.0.0](https://github.com/multiformats/js-multiformats/compare/v10.0.3...v11.0.0) (2023-01-02)
### ⚠ BREAKING CHANGES
* Make link.toJSON return a DAG-JSON link
### Features
* Make link.toJSON return a DAG-JSON link ([9e087d6](https://github.com/multiformats/js-multiformats/commit/9e087d64ee3c90d8b019dd48989936b17b1cb2f3))
### Bug Fixes
* build browser bundle ([2ee6012](https://github.com/multiformats/js-multiformats/commit/2ee6012dbb702cff2425668c16fe101fdf79517d)), closes [#234](https://github.com/multiformats/js-multiformats/issues/234)
* list links of a block that _is a_ CID ([#226](https://github.com/multiformats/js-multiformats/issues/226)) ([c17673d](https://github.com/multiformats/js-multiformats/commit/c17673d9e15bd5a4df074c9f73267a257e0dcfad))
### Documentation
* fix typos in jsdoc comments ([a246054](https://github.com/multiformats/js-multiformats/commit/a246054653cf588e92d76f8161b0a6cd6035533b))
## [10.0.3](https://github.com/multiformats/js-multiformats/compare/v10.0.2...v10.0.3) (2022-12-16)
### Documentation
* publish typedocs in gh-pages branch ([#233](https://github.com/multiformats/js-multiformats/issues/233)) ([3a6d3ed](https://github.com/multiformats/js-multiformats/commit/3a6d3ed1f653d62e30d72d7bd00dc5815a17ffe3))
## [10.0.2](https://github.com/multiformats/js-multiformats/compare/v10.0.1...v10.0.2) (2022-10-19)
### Bug Fixes
* use slash as flag that an object is a CID ([#217](https://github.com/multiformats/js-multiformats/issues/217)) ([1cec619](https://github.com/multiformats/js-multiformats/commit/1cec619e2818d893292323539f397324ace82280)), closes [#212](https://github.com/multiformats/js-multiformats/issues/212) [#213](https://github.com/multiformats/js-multiformats/issues/213)
### Trivial Changes
* **no-release:** rename varint test file so it is run ([#209](https://github.com/multiformats/js-multiformats/issues/209)) ([e32fe47](https://github.com/multiformats/js-multiformats/commit/e32fe4703ee0c48100af89f9c9c7181f65935176))
* remove unnecessary dev deps ([#218](https://github.com/multiformats/js-multiformats/issues/218)) ([a43ffff](https://github.com/multiformats/js-multiformats/commit/a43ffff672495ba86486be47084697df4e1ecacc))
## [10.0.1](https://github.com/multiformats/js-multiformats/compare/v10.0.0...v10.0.1) (2022-10-17)
### Bug Fixes
* convert byteOffset and byteLength to getters ([#215](https://github.com/multiformats/js-multiformats/issues/215)) ([4e09490](https://github.com/multiformats/js-multiformats/commit/4e09490beeba0e0a47432a7bb51112ab5f556e3f)), closes [#208](https://github.com/multiformats/js-multiformats/issues/208) [#210](https://github.com/multiformats/js-multiformats/issues/210)
## [10.0.0](https://github.com/multiformats/js-multiformats/compare/v9.9.0...v10.0.0) (2022-10-12)
### ⚠ BREAKING CHANGES
* remove use of Object.defineProperties in CID class
* use aegir for ESM-only build/testing/release
### Features
* add complete set of aegir-based scripts ([1190bc6](https://github.com/multiformats/js-multiformats/commit/1190bc6fcc2d11a317979538692940d6b8085874))
* define Link interface for CID ([88e29ea](https://github.com/multiformats/js-multiformats/commit/88e29ea7a8c1a1a284c654311cfb1d67cbfd8e6c))
* remove deprecated CID properties & methods ([ffc4e6f](https://github.com/multiformats/js-multiformats/commit/ffc4e6fac0b9f755a141f5e7fea61950d195b4fa))
* use aegir for ESM-only build/testing/release ([163d463](https://github.com/multiformats/js-multiformats/commit/163d4632708b874b60c5a8de0f77811034557f74))
### Bug Fixes
* --no-cov for all but chrome main ([b92f25f](https://github.com/multiformats/js-multiformats/commit/b92f25fe6f3ca9ed9c9468a209bf1101a3005a3d))
* add "browser" field, remove named local imports ([d60ea06](https://github.com/multiformats/js-multiformats/commit/d60ea06f0c1d3145200138548e71677d0007f9ef))
* additional lint items from Link interface work ([91f677b](https://github.com/multiformats/js-multiformats/commit/91f677be1bc6304b066d4c6aaeea2b1af94876b7))
* address JS & TS linting complaints ([c12db2a](https://github.com/multiformats/js-multiformats/commit/c12db2a53a11f701fbfbd04f5f977580c37af54b))
* changes for new lint rules ([e6c9957](https://github.com/multiformats/js-multiformats/commit/e6c9957383d6023291fafaa1f6718bd903539e43))
* distribute types in dist/types/ ([c6defdb](https://github.com/multiformats/js-multiformats/commit/c6defdb039520e4e7dd0e279b212b72683ceac85))
* ensure "master" as release branch ([16f8d9e](https://github.com/multiformats/js-multiformats/commit/16f8d9e1215caaa00cc7d708058f01dc6d10b824))
* make CID#asCID a regular property ([a74f1c7](https://github.com/multiformats/js-multiformats/commit/a74f1c75b73c6d019614ecbf8f06ab97a232a48b))
* only release on master ([d15f26f](https://github.com/multiformats/js-multiformats/commit/d15f26fbcf51bd9d382e27ca9099af71c217bb25))
* properly export types, build more complete pack ([8172ea8](https://github.com/multiformats/js-multiformats/commit/8172ea8977296ece7a1b9d165caa99c284b604fd))
* remove "main" ([ad3306c](https://github.com/multiformats/js-multiformats/commit/ad3306c459e0e4f22184963c151bf3cc737ec9b0))
* remove use of Object.defineProperties in CID class ([6149fae](https://github.com/multiformats/js-multiformats/commit/6149fae84b74b7a6b0ca8f9e21e731ac9fabcf3a)), closes [#200](https://github.com/multiformats/js-multiformats/issues/200)
* run coverage only where it's supposed to ([872d121](https://github.com/multiformats/js-multiformats/commit/872d12126132a38677f623b87699b6fbff968cfd))
* test on all branches and pull requests ([f2ae077](https://github.com/multiformats/js-multiformats/commit/f2ae07760739c2f16e2eb5c83a2fad15a877243f))
* ts-use import path ([53651c1](https://github.com/multiformats/js-multiformats/commit/53651c1fae60b0bf9424c5f8f688d42959835480))
* use extensions for relative ts imports ([451998a](https://github.com/multiformats/js-multiformats/commit/451998a43516d7d5c468a18fe074ea1b53ac883e)), closes [/github.com/multiformats/js-multiformats/pull/199#issuecomment-1252793515](https://github.com/multiformats//github.com/multiformats/js-multiformats/pull/199/issues/issuecomment-1252793515)
* use parent `tsc` in ts-use ([85a9296](https://github.com/multiformats/js-multiformats/commit/85a9296f54118ff676bf1deb107d65c4c892186d))
### Tests
* check for non-enumerability of asCID property ([b4ba07d](https://github.com/multiformats/js-multiformats/commit/b4ba07db92e4610a55101f7dd17505f21a341a85))
### Trivial Changes
* add test for structural copying ([#206](https://github.com/multiformats/js-multiformats/issues/206)) ([e8def36](https://github.com/multiformats/js-multiformats/commit/e8def3663cd328023fbf7e4e88c9e47e71846d06))
* **no-release:** bump @types/mocha from 9.1.1 to 10.0.0 ([#205](https://github.com/multiformats/js-multiformats/issues/205)) ([a9a9347](https://github.com/multiformats/js-multiformats/commit/a9a9347789ee720d1de9508598d8879abf443baf))
* **no-release:** bump actions/setup-node from 3.4.1 to 3.5.0 ([#204](https://github.com/multiformats/js-multiformats/issues/204)) ([604ca1f](https://github.com/multiformats/js-multiformats/commit/604ca1fe498864a32851294317d76f0aaa13d280))
## [9.9.0](https://github.com/multiformats/js-multiformats/compare/v9.8.1...v9.9.0) (2022-09-20)
### Features
* add optional offset param to varint.decode ([#201](https://github.com/multiformats/js-multiformats/issues/201)) ([1e1b583](https://github.com/multiformats/js-multiformats/commit/1e1b583893bc0c984dcbeaf321c17f6637629b4e))
## [9.7.1](https://github.com/multiformats/js-multiformats/compare/v9.7.0...v9.7.1) (2022-07-26)
### Bug Fixes
* typo ([#192](https://github.com/multiformats/js-multiformats/issues/192)) ([b602f63](https://github.com/multiformats/js-multiformats/commit/b602f6315d35ee5c83d6f0b9995988f065f47ec8))
### Trivial Changes
* **no-release:** bump actions/setup-node from 3.3.0 to 3.4.0 ([#189](https://github.com/multiformats/js-multiformats/issues/189)) ([362b167](https://github.com/multiformats/js-multiformats/commit/362b167c939066b1e3217db4442a7652fba38e85))
* **no-release:** bump actions/setup-node from 3.4.0 to 3.4.1 ([#190](https://github.com/multiformats/js-multiformats/issues/190)) ([67f22c4](https://github.com/multiformats/js-multiformats/commit/67f22c4696777529d3871ee1e2fdbd436ad55fc0))
## [9.7.0](https://github.com/multiformats/js-multiformats/compare/v9.6.5...v9.7.0) (2022-06-23)
### Features
* add base256emoji ([#187](https://github.com/multiformats/js-multiformats/issues/187)) ([c6c5c46](https://github.com/multiformats/js-multiformats/commit/c6c5c46b12686c48db741836c5957dbc72f4bbd4))
### Trivial Changes
* **no-release:** bump @types/node from 17.0.45 to 18.0.0 ([#188](https://github.com/multiformats/js-multiformats/issues/188)) ([99e94ed](https://github.com/multiformats/js-multiformats/commit/99e94ed8025aabae64e58c2f2d2fff6b24dddfcb))
* **no-release:** bump actions/setup-node from 3.1.0 to 3.2.0 ([#182](https://github.com/multiformats/js-multiformats/issues/182)) ([86ec43d](https://github.com/multiformats/js-multiformats/commit/86ec43d89d60c6c4be0e001c06d1e28570a3d36a))
* **no-release:** bump actions/setup-node from 3.2.0 to 3.3.0 ([#186](https://github.com/multiformats/js-multiformats/issues/186)) ([712c1c4](https://github.com/multiformats/js-multiformats/commit/712c1c4fe5066d0a6fdc89b53a7943bb67edf0b8))
* **no-release:** fix typo implemnetation -> implementation ([#184](https://github.com/multiformats/js-multiformats/issues/184)) ([3d4ae50](https://github.com/multiformats/js-multiformats/commit/3d4ae504928b372886d1021e48a39c06ecbf8fde))
### [9.6.5](https://github.com/multiformats/js-multiformats/compare/v9.6.4...v9.6.5) (2022-05-06)
### Trivial Changes
* **no-release:** bump actions/checkout from 2.4.0 to 3 ([#172](https://github.com/multiformats/js-multiformats/issues/172)) ([a1b38c2](https://github.com/multiformats/js-multiformats/commit/a1b38c235809287e284c7bde80634e669e6d1ac6))
* **no-release:** bump actions/setup-node from 2.5.1 to 3.0.0 ([#169](https://github.com/multiformats/js-multiformats/issues/169)) ([8deb4d5](https://github.com/multiformats/js-multiformats/commit/8deb4d5dae2e01d8fd60f2dd6e944747c4ee2ef1))
* **no-release:** bump actions/setup-node from 3.0.0 to 3.1.0 ([#174](https://github.com/multiformats/js-multiformats/issues/174)) ([9bcd7fe](https://github.com/multiformats/js-multiformats/commit/9bcd7fef62888d7cefe8e4f5e929d4e3c9dadda9))
* **no-release:** bump mocha from 9.2.2 to 10.0.0 ([#179](https://github.com/multiformats/js-multiformats/issues/179)) ([b2951dc](https://github.com/multiformats/js-multiformats/commit/b2951dcbee5812522f2336bbf7c28eab9babdfa9))
* **no-release:** bump polendina from 2.0.15 to 3.0.0 ([#180](https://github.com/multiformats/js-multiformats/issues/180)) ([659516b](https://github.com/multiformats/js-multiformats/commit/659516bb231bcc8332d93ded03ebcfa8e675f2dc))
* **no-release:** bump standard from 16.0.4 to 17.0.0 ([#178](https://github.com/multiformats/js-multiformats/issues/178)) ([2683344](https://github.com/multiformats/js-multiformats/commit/268334426ca97f38a8c2eab0c834943c6e1a04d0))
* update tsdoc for CID `code` param to clarify "what kind of code?" ([#181](https://github.com/multiformats/js-multiformats/issues/181)) ([adec0c4](https://github.com/multiformats/js-multiformats/commit/adec0c4714ef39879c3b059dc9a4882e19406420))
### [9.6.4](https://github.com/multiformats/js-multiformats/compare/v9.6.3...v9.6.4) (2022-02-14)
### Trivial Changes
* clean typos and formatting ([0d976fd](https://github.com/multiformats/js-multiformats/commit/0d976fd33923e8b9cbe1535d3bc269affe151d66))
### [9.6.3](https://github.com/multiformats/js-multiformats/compare/v9.6.2...v9.6.3) (2022-02-04)
### Bug Fixes
* run test:ci in CI, fix package.json keywords ([#139](https://github.com/multiformats/js-multiformats/issues/139)) ([8ec8eb0](https://github.com/multiformats/js-multiformats/commit/8ec8eb0ca29ed51d244495a0d6c7d7a08a31ac39))
### [9.6.2](https://github.com/multiformats/js-multiformats/compare/v9.6.1...v9.6.2) (2022-01-20)
### Bug Fixes
* add encode to identity ([2724f8a](https://github.com/multiformats/js-multiformats/commit/2724f8aa8e0e7c24db7594eb29f683b1c01f3e42)), closes [#160](https://github.com/multiformats/js-multiformats/issues/160)
* coverage by using encode ([132d829](https://github.com/multiformats/js-multiformats/commit/132d829eb84776afd3820788df024a7a9f6d8834))
### [9.6.1](https://github.com/multiformats/js-multiformats/compare/v9.6.0...v9.6.1) (2022-01-20)
### Bug Fixes
* export only `identity` hasher const ([330082a](https://github.com/multiformats/js-multiformats/commit/330082aeaf2f493e351c413411ce9a4db25ebe5f))
## [9.6.0](https://github.com/multiformats/js-multiformats/compare/v9.5.9...v9.6.0) (2022-01-19)
### Features
* add sync multihash hasher ([#160](https://github.com/multiformats/js-multiformats/issues/160)) ([c3a650c](https://github.com/multiformats/js-multiformats/commit/c3a650c8b48989ea52045d85eb06eebee8bb59d1))
### [9.5.9](https://github.com/multiformats/js-multiformats/compare/v9.5.8...v9.5.9) (2022-01-18)
### Trivial Changes
* Reanable tsc action and reconfigure project slightly ([#157](https://github.com/multiformats/js-multiformats/issues/157)) ([c936a6d](https://github.com/multiformats/js-multiformats/commit/c936a6d3f125b6032358ffcc0e9c71e2bf986bf3))
### [9.5.8](https://github.com/multiformats/js-multiformats/compare/v9.5.7...v9.5.8) (2022-01-07)
### Trivial Changes
* **test:** use chai throws() & chai-as-promised isRejected() ([6e4ba86](https://github.com/multiformats/js-multiformats/commit/6e4ba86a59ef1f5a93b1869f1650073da184ebe4))
### [9.5.7](https://github.com/multiformats/js-multiformats/compare/v9.5.6...v9.5.7) (2022-01-07)
### Bug Fixes
* **types:** combine composite tsconfigs ([18c5734](https://github.com/multiformats/js-multiformats/commit/18c5734060c972cbcb45d6acea1642b2d09fde13))
### Trivial Changes
* **types:** re-enable typechecks for tests by split tsconfig ([4c017dc](https://github.com/multiformats/js-multiformats/commit/4c017dc80280bb42b0e2da07eb5f5da58c2efd76))
* **types:** remove explicit typecheck action ([b0467e5](https://github.com/multiformats/js-multiformats/commit/b0467e52870a91f3fc3122afb969505a31dc3210))
### [9.5.6](https://github.com/multiformats/js-multiformats/compare/v9.5.5...v9.5.6) (2022-01-04)
### Bug Fixes
* **types:** fix publishing of types ([58b5604](https://github.com/multiformats/js-multiformats/commit/58b5604fff734ca997dbedf0d8309247f4e518e4)), closes [#150](https://github.com/multiformats/js-multiformats/issues/150)
### [9.5.5](https://github.com/multiformats/js-multiformats/compare/v9.5.4...v9.5.5) (2022-01-04)
### Bug Fixes
* enable ts on tests ([62774c2](https://github.com/multiformats/js-multiformats/commit/62774c2bca1b2c4eb7c125bd092f6f9dcadb19e5))
* type inference for base32 ([b912ecc](https://github.com/multiformats/js-multiformats/commit/b912ecc136908eaa8dd4f9e5fae48b7b52132651))
### Trivial Changes
* **no-release:** bump @types/node from 16.11.14 to 17.0.0 ([#145](https://github.com/multiformats/js-multiformats/issues/145)) ([66aaf0f](https://github.com/multiformats/js-multiformats/commit/66aaf0fa8cfb6d0a41e12e3f3463147a0bbda0ea))
* **no-release:** bump actions/setup-node from 2.5.0 to 2.5.1 ([#147](https://github.com/multiformats/js-multiformats/issues/147)) ([32cf7bd](https://github.com/multiformats/js-multiformats/commit/32cf7bd9709173683e194c7c0e7b8f4acf49e9a5))
### [9.5.4](https://github.com/multiformats/js-multiformats/compare/v9.5.3...v9.5.4) (2021-12-09)
### Bug Fixes
* remove publish script ([da1d722](https://github.com/multiformats/js-multiformats/commit/da1d7228aca1eebf749f0a922a3f7e90b805009d))
### [9.5.3](https://github.com/multiformats/js-multiformats/compare/v9.5.2...v9.5.3) (2021-12-09)
### Bug Fixes
* add windows CI support (replace hundreds with c8 direct) ([5da242c](https://github.com/multiformats/js-multiformats/commit/5da242c65d39845ab869e027219c06510d700b6e))
* ipjs windows fix, add windows back in to CI ([196e404](https://github.com/multiformats/js-multiformats/commit/196e4041a9aaefd2309e87b372e2efe8febd11fc))
* prepare auto-release from dist dir & w/ build ([90693dd](https://github.com/multiformats/js-multiformats/commit/90693dd4e3b95099e834c15dcfd8090bb0a8367a))
### Trivial Changes
* drop test support for 12.x ([a7a2110](https://github.com/multiformats/js-multiformats/commit/a7a2110559e7cf66c3741ade42cea80d8a12a82a))
* remove windows from CI pending ipjs fix ([2ab914b](https://github.com/multiformats/js-multiformats/commit/2ab914b1943fb8fc4e0aeead0fb7ce5dc979514e))
* update auto-release work w/ semantic-release ([db86f48](https://github.com/multiformats/js-multiformats/commit/db86f487dcba790522908583c6f4a9c7ce504dea))
* update devDeps ([55b9856](https://github.com/multiformats/js-multiformats/commit/55b98569017a647fd070bb699d453df9bb482715))
* upgrade polendina, test esm & cjs in browser ([852f1a5](https://github.com/multiformats/js-multiformats/commit/852f1a5dfecf0489679dfb24f9d2dc48ec21e95a))
@@ -0,0 +1,4 @@
This project is dual licensed under MIT and Apache-2.0.
MIT: https://www.opensource.org/licenses/mit
Apache-2.0: https://www.apache.org/licenses/license-2.0
@@ -0,0 +1,5 @@
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
@@ -0,0 +1,19 @@
The MIT License (MIT)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
@@ -0,0 +1,259 @@
# multiformats <!-- omit in toc -->
[![multiformats.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://multiformats.io)
[![codecov](https://img.shields.io/codecov/c/github/multiformats/js-multiformats.svg?style=flat-square)](https://codecov.io/gh/multiformats/js-multiformats)
[![CI](https://img.shields.io/github/actions/workflow/status/multiformats/js-multiformats/js-test-and-release.yml?branch=master\&style=flat-square)](https://github.com/multiformats/js-multiformats/actions/workflows/js-test-and-release.yml?query=branch%3Amaster)
> Interface for multihash, multicodec, multibase and CID
## Table of contents <!-- omit in toc -->
- [Install](#install)
- [Browser `<script>` tag](#browser-script-tag)
- [Interfaces](#interfaces)
- [Creating Blocks](#creating-blocks)
- [Multibase Encoders / Decoders / Codecs](#multibase-encoders--decoders--codecs)
- [Multicodec Encoders / Decoders / Codecs](#multicodec-encoders--decoders--codecs)
- [Multihash Hashers](#multihash-hashers)
- [Traversal](#traversal)
- [Legacy interface](#legacy-interface)
- [Implementations](#implementations)
- [Multibase codecs](#multibase-codecs)
- [Multihash hashers](#multihash-hashers-1)
- [IPLD codecs (multicodec)](#ipld-codecs-multicodec)
- [API Docs](#api-docs)
- [License](#license)
- [Contribution](#contribution)
## Install
```console
$ npm i multiformats
```
### Browser `<script>` tag
Loading this module through a script tag will make it's exports available as `Multiformats` in the global namespace.
```html
<script src="https://unpkg.com/multiformats/dist/index.min.js"></script>
```
## Interfaces
This library defines common interfaces and low level building blocks for various interrelated multiformat technologies (multicodec, multihash, multibase, and CID). They can be used to implement custom base encoders / decoders / codecs, codec encoders /decoders and multihash hashers that comply to the interface that layers above assume.
This library provides implementations for most basics and many others can be found in linked repositories.
```js
import { CID } from 'multiformats/cid'
import * as json from 'multiformats/codecs/json'
import { sha256 } from 'multiformats/hashes/sha2'
const bytes = json.encode({ hello: 'world' })
const hash = await sha256.digest(bytes)
const cid = CID.create(1, json.code, hash)
//> CID(bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea)
```
### Creating Blocks
```js
import * as Block from 'multiformats/block'
import * as codec from '@ipld/dag-cbor'
import { sha256 as hasher } from 'multiformats/hashes/sha2'
const value = { hello: 'world' }
// encode a block
let block = await Block.encode({ value, codec, hasher })
block.value // { hello: 'world' }
block.bytes // Uint8Array
block.cid // CID() w/ sha2-256 hash address and dag-cbor codec
// you can also decode blocks from their binary state
block = await Block.decode({ bytes: block.bytes, codec, hasher })
// if you have the cid you can also verify the hash on decode
block = await Block.create({ bytes: block.bytes, cid: block.cid, codec, hasher })
```
### Multibase Encoders / Decoders / Codecs
CIDs can be serialized to string representation using multibase encoders that implement [`MultibaseEncoder`](https://github.com/multiformats/js-multiformats/blob/master/src/bases/interface.ts) interface. This library provides quite a few implementations that can be imported:
```js
import { base64 } from "multiformats/bases/base64"
cid.toString(base64.encoder)
//> 'mAYAEEiCTojlxqRTl6svwqNJRVM2jCcPBxy+7mRTUfGDzy2gViA'
```
Parsing CID string serialized CIDs requires multibase decoder that implements [`MultibaseDecoder`](https://github.com/multiformats/js-multiformats/blob/master/src/bases/interface.ts) interface. This library provides a decoder for every encoder it provides:
```js
CID.parse('mAYAEEiCTojlxqRTl6svwqNJRVM2jCcPBxy+7mRTUfGDzy2gViA', base64.decoder)
//> CID(bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea)
```
Dual of multibase encoder & decoder is defined as multibase codec and it exposes
them as `encoder` and `decoder` properties. For added convenience codecs also
implement `MultibaseEncoder` and `MultibaseDecoder` interfaces so they could be
used as either or both:
```js
cid.toString(base64)
CID.parse(cid.toString(base64), base64)
```
**Note:** CID implementation comes bundled with `base32` and `base58btc`
multibase codecs so that CIDs can be base serialized to (version specific)
default base encoding and parsed without having to supply base encoders/decoders:
```js
const v1 = CID.parse('bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea')
v1.toString()
//> 'bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea'
const v0 = CID.parse('QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n')
v0.toString()
//> 'QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n'
v0.toV1().toString()
//> 'bafybeihdwdcefgh4dqkjv67uzcmw7ojee6xedzdetojuzjevtenxquvyku'
```
### Multicodec Encoders / Decoders / Codecs
This library defines [`BlockEncoder`, `BlockDecoder` and `BlockCodec` interfaces](https://github.com/multiformats/js-multiformats/blob/master/src/codecs/interface.ts).
Codec implementations should conform to the `BlockCodec` interface which implements both `BlockEncoder` and `BlockDecoder`.
Here is an example implementation of JSON `BlockCodec`.
```js
/**
* @template T
* @type {BlockCodec<0x0200, T>}
*/
export const { name, code, encode, decode } = {
name: 'json',
code: 0x0200,
encode: json => new TextEncoder().encode(JSON.stringify(json)),
decode: bytes => JSON.parse(new TextDecoder().decode(bytes))
}
```
### Multihash Hashers
This library defines [`MultihashHasher` and `MultihashDigest` interfaces](https://github.com/multiformats/js-multiformats/blob/master/src/hashes/interface.ts) and convinient function for implementing them:
```js
import * as hasher from 'multiformats/hashes/hasher'
const sha256 = hasher.from({
// As per multiformats table
// https://github.com/multiformats/multicodec/blob/master/table.csv#L9
name: 'sha2-256',
code: 0x12,
encode: (input) => new Uint8Array(crypto.createHash('sha256').update(input).digest())
})
const hash = await sha256.digest(json.encode({ hello: 'world' }))
CID.create(1, json.code, hash)
//> CID(bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea)
```
### Traversal
This library contains higher-order functions for traversing graphs of data easily.
`walk()` walks through the links in each block of a DAG calling a user-supplied loader function for each one, in depth-first order with no duplicate block visits. The loader should return a `Block` object and can be used to inspect and collect block ordering for a full DAG walk. The loader should `throw` on error, and return `null` if a block should be skipped by `walk()`.
```js
import { walk } from 'multiformats/traversal'
import * as Block from 'multiformats/block'
import * as codec from 'multiformats/codecs/json'
import { sha256 as hasher } from 'multiformats/hashes/sha2'
// build a DAG (a single block for this simple example)
const value = { hello: 'world' }
const block = await Block.encode({ value, codec, hasher })
const { cid } = block
console.log(cid)
//> CID(bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea)
// create a loader function that also collects CIDs of blocks in
// their traversal order
const load = (cid, blocks) => async (cid) => {
// fetch a block using its cid
// e.g.: const block = await fetchBlockByCID(cid)
blocks.push(cid)
return block
}
// collect blocks in this DAG starting from the root `cid`
const blocks = []
await walk({ cid, load: load(cid, blocks) })
console.log(blocks)
//> [CID(bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea)]
```
## Legacy interface
[`blockcodec-to-ipld-format`](https://github.com/ipld/js-blockcodec-to-ipld-format) converts a multiformats [`BlockCodec`](https://github.com/multiformats/js-multiformats/blob/master/src/codecs/interface.ts#L21) into an
[`interface-ipld-format`](https://github.com/ipld/interface-ipld-format) for use with the [`ipld`](https://github.com/ipld/ipld) package. This can help bridge IPLD codecs implemented using the structure and interfaces defined here to existing code that assumes, or requires `interface-ipld-format`. This bridge also includes the relevant TypeScript definitions.
## Implementations
By default, no base encodings (other than base32 & base58btc), hash functions,
or codec implementations are exposed by `multiformats`, you need to
import the ones you need yourself.
### Multibase codecs
| bases | import | repo |
| ------------------------------------------------------------- | --------------------------- | ------------------------------------------------------------------------------------------------- |
| `base16` | `multiformats/bases/base16` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) |
| `base32`, `base32pad`, `base32hex`, `base32hexpad`, `base32z` | `multiformats/bases/base32` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) |
| `base64`, `base64pad`, `base64url`, `base64urlpad` | `multiformats/bases/base64` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) |
| `base58btc`, `base58flick4` | `multiformats/bases/base58` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) |
Other (less useful) bases implemented in [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) include: `base2`, `base8`, `base10`, `base36` and `base256emoji`.
### Multihash hashers
| hashes | import | repo |
| ------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------ |
| `sha2-256`, `sha2-512` | `multiformats/hashes/sha2` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/hashes) |
| `sha3-224`, `sha3-256`, `sha3-384`,`sha3-512`, `shake-128`, `shake-256`, `keccak-224`, `keccak-256`, `keccak-384`, `keccak-512` | `@multiformats/sha3` | [multiformats/js-sha3](https://github.com/multiformats/js-sha3) |
| `identity` | `multiformats/hashes/identity` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/hashes/identity.js) |
| `murmur3-128`, `murmur3-32` | `@multiformats/murmur3` | [multiformats/js-murmur3](https://github.com/multiformats/js-murmur3) |
| `blake2b-*`, `blake2s-*` | `@multiformats/blake2` | [multiformats/js-blake2](https://github.com/multiformats/js-blake2) |
### IPLD codecs (multicodec)
| codec | import | repo |
| ---------- | -------------------------- | ------------------------------------------------------------------------------------------------------ |
| `raw` | `multiformats/codecs/raw` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/codecs) |
| `json` | `multiformats/codecs/json` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/codecs) |
| `dag-cbor` | `@ipld/dag-cbor` | [ipld/js-dag-cbor](https://github.com/ipld/js-dag-cbor) |
| `dag-json` | `@ipld/dag-json` | [ipld/js-dag-json](https://github.com/ipld/js-dag-json) |
| `dag-pb` | `@ipld/dag-pb` | [ipld/js-dag-pb](https://github.com/ipld/js-dag-pb) |
| `dag-jose` | `dag-jose` | [ceramicnetwork/js-dag-jose](https://github.com/ceramicnetwork/js-dag-jose) |
## API Docs
- <https://multiformats.github.io/js-multiformats>
## License
Licensed under either of
- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
## Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
File diff suppressed because one or more lines are too long
@@ -0,0 +1,163 @@
{
"base10": "https://multiformats.github.io/js-multiformats/variables/bases_base10.base10.html",
"./bases/base10:base10": "https://multiformats.github.io/js-multiformats/variables/bases_base10.base10.html",
"base16": "https://multiformats.github.io/js-multiformats/variables/bases_base16.base16.html",
"./bases/base16:base16": "https://multiformats.github.io/js-multiformats/variables/bases_base16.base16.html",
"base16upper": "https://multiformats.github.io/js-multiformats/variables/bases_base16.base16upper.html",
"./bases/base16:base16upper": "https://multiformats.github.io/js-multiformats/variables/bases_base16.base16upper.html",
"base2": "https://multiformats.github.io/js-multiformats/variables/bases_base2.base2.html",
"./bases/base2:base2": "https://multiformats.github.io/js-multiformats/variables/bases_base2.base2.html",
"base256emoji": "https://multiformats.github.io/js-multiformats/variables/bases_base256emoji.base256emoji.html",
"./bases/base256emoji:base256emoji": "https://multiformats.github.io/js-multiformats/variables/bases_base256emoji.base256emoji.html",
"base32": "https://multiformats.github.io/js-multiformats/variables/bases_base32.base32.html",
"./bases/base32:base32": "https://multiformats.github.io/js-multiformats/variables/bases_base32.base32.html",
"base32hex": "https://multiformats.github.io/js-multiformats/variables/bases_base32.base32hex.html",
"./bases/base32:base32hex": "https://multiformats.github.io/js-multiformats/variables/bases_base32.base32hex.html",
"base32hexpad": "https://multiformats.github.io/js-multiformats/variables/bases_base32.base32hexpad.html",
"./bases/base32:base32hexpad": "https://multiformats.github.io/js-multiformats/variables/bases_base32.base32hexpad.html",
"base32hexpadupper": "https://multiformats.github.io/js-multiformats/variables/bases_base32.base32hexpadupper.html",
"./bases/base32:base32hexpadupper": "https://multiformats.github.io/js-multiformats/variables/bases_base32.base32hexpadupper.html",
"base32hexupper": "https://multiformats.github.io/js-multiformats/variables/bases_base32.base32hexupper.html",
"./bases/base32:base32hexupper": "https://multiformats.github.io/js-multiformats/variables/bases_base32.base32hexupper.html",
"base32pad": "https://multiformats.github.io/js-multiformats/variables/bases_base32.base32pad.html",
"./bases/base32:base32pad": "https://multiformats.github.io/js-multiformats/variables/bases_base32.base32pad.html",
"base32padupper": "https://multiformats.github.io/js-multiformats/variables/bases_base32.base32padupper.html",
"./bases/base32:base32padupper": "https://multiformats.github.io/js-multiformats/variables/bases_base32.base32padupper.html",
"base32upper": "https://multiformats.github.io/js-multiformats/variables/bases_base32.base32upper.html",
"./bases/base32:base32upper": "https://multiformats.github.io/js-multiformats/variables/bases_base32.base32upper.html",
"base32z": "https://multiformats.github.io/js-multiformats/variables/bases_base32.base32z.html",
"./bases/base32:base32z": "https://multiformats.github.io/js-multiformats/variables/bases_base32.base32z.html",
"base36": "https://multiformats.github.io/js-multiformats/variables/bases_base36.base36.html",
"./bases/base36:base36": "https://multiformats.github.io/js-multiformats/variables/bases_base36.base36.html",
"base36upper": "https://multiformats.github.io/js-multiformats/variables/bases_base36.base36upper.html",
"./bases/base36:base36upper": "https://multiformats.github.io/js-multiformats/variables/bases_base36.base36upper.html",
"base58btc": "https://multiformats.github.io/js-multiformats/variables/bases_base58.base58btc.html",
"./bases/base58:base58btc": "https://multiformats.github.io/js-multiformats/variables/bases_base58.base58btc.html",
"base58flickr": "https://multiformats.github.io/js-multiformats/variables/bases_base58.base58flickr.html",
"./bases/base58:base58flickr": "https://multiformats.github.io/js-multiformats/variables/bases_base58.base58flickr.html",
"base64": "https://multiformats.github.io/js-multiformats/variables/bases_base64.base64.html",
"./bases/base64:base64": "https://multiformats.github.io/js-multiformats/variables/bases_base64.base64.html",
"base64pad": "https://multiformats.github.io/js-multiformats/variables/bases_base64.base64pad.html",
"./bases/base64:base64pad": "https://multiformats.github.io/js-multiformats/variables/bases_base64.base64pad.html",
"base64url": "https://multiformats.github.io/js-multiformats/variables/bases_base64.base64url.html",
"./bases/base64:base64url": "https://multiformats.github.io/js-multiformats/variables/bases_base64.base64url.html",
"base64urlpad": "https://multiformats.github.io/js-multiformats/variables/bases_base64.base64urlpad.html",
"./bases/base64:base64urlpad": "https://multiformats.github.io/js-multiformats/variables/bases_base64.base64urlpad.html",
"base8": "https://multiformats.github.io/js-multiformats/variables/bases_base8.base8.html",
"./bases/base8:base8": "https://multiformats.github.io/js-multiformats/variables/bases_base8.base8.html",
"identity": "https://multiformats.github.io/js-multiformats/variables/bases_identity.identity.html",
"./bases/identity:identity": "https://multiformats.github.io/js-multiformats/variables/bases_identity.identity.html",
"bases": "https://multiformats.github.io/js-multiformats/variables/basics.bases.html",
"./basics:bases": "https://multiformats.github.io/js-multiformats/variables/basics.bases.html",
"codecs": "https://multiformats.github.io/js-multiformats/variables/basics.codecs.html",
"./basics:codecs": "https://multiformats.github.io/js-multiformats/variables/basics.codecs.html",
"hashes": "https://multiformats.github.io/js-multiformats/variables/basics.hashes.html",
"./basics:hashes": "https://multiformats.github.io/js-multiformats/variables/basics.hashes.html",
"Block": "https://multiformats.github.io/js-multiformats/classes/block.Block.html",
"./block:Block": "https://multiformats.github.io/js-multiformats/classes/block.Block.html",
"RequiredCreateOptions": "https://multiformats.github.io/js-multiformats/interfaces/block.RequiredCreateOptions.html",
"./block:RequiredCreateOptions": "https://multiformats.github.io/js-multiformats/interfaces/block.RequiredCreateOptions.html",
"create": "https://multiformats.github.io/js-multiformats/functions/block.create.html",
"./block:create": "https://multiformats.github.io/js-multiformats/functions/block.create.html",
"createUnsafe": "https://multiformats.github.io/js-multiformats/functions/block.createUnsafe.html",
"./block:createUnsafe": "https://multiformats.github.io/js-multiformats/functions/block.createUnsafe.html",
"decode": "https://multiformats.github.io/js-multiformats/functions/block.decode.html",
"./block:decode": "https://multiformats.github.io/js-multiformats/functions/block.decode.html",
"encode": "https://multiformats.github.io/js-multiformats/functions/block.encode.html",
"./block:encode": "https://multiformats.github.io/js-multiformats/functions/block.encode.html",
"empty": "https://multiformats.github.io/js-multiformats/variables/bytes.empty.html",
"./bytes:empty": "https://multiformats.github.io/js-multiformats/variables/bytes.empty.html",
"coerce": "https://multiformats.github.io/js-multiformats/functions/bytes.coerce.html",
"./bytes:coerce": "https://multiformats.github.io/js-multiformats/functions/bytes.coerce.html",
"equals": "https://multiformats.github.io/js-multiformats/functions/bytes.equals.html",
"./bytes:equals": "https://multiformats.github.io/js-multiformats/functions/bytes.equals.html",
"fromHex": "https://multiformats.github.io/js-multiformats/functions/bytes.fromHex.html",
"./bytes:fromHex": "https://multiformats.github.io/js-multiformats/functions/bytes.fromHex.html",
"fromString": "https://multiformats.github.io/js-multiformats/functions/bytes.fromString.html",
"./bytes:fromString": "https://multiformats.github.io/js-multiformats/functions/bytes.fromString.html",
"isBinary": "https://multiformats.github.io/js-multiformats/functions/bytes.isBinary.html",
"./bytes:isBinary": "https://multiformats.github.io/js-multiformats/functions/bytes.isBinary.html",
"toHex": "https://multiformats.github.io/js-multiformats/functions/bytes.toHex.html",
"./bytes:toHex": "https://multiformats.github.io/js-multiformats/functions/bytes.toHex.html",
"./bytes:toString": "https://multiformats.github.io/js-multiformats/functions/bytes.toString.html",
"CID": "https://multiformats.github.io/js-multiformats/classes/cid.CID.html",
"./cid:CID": "https://multiformats.github.io/js-multiformats/classes/cid.CID.html",
"format": "https://multiformats.github.io/js-multiformats/functions/cid.format.html",
"./cid:format": "https://multiformats.github.io/js-multiformats/functions/cid.format.html",
"fromJSON": "https://multiformats.github.io/js-multiformats/functions/cid.fromJSON.html",
"./cid:fromJSON": "https://multiformats.github.io/js-multiformats/functions/cid.fromJSON.html",
"toJSON": "https://multiformats.github.io/js-multiformats/functions/cid.toJSON.html",
"./cid:toJSON": "https://multiformats.github.io/js-multiformats/functions/cid.toJSON.html",
"ByteView": "https://multiformats.github.io/js-multiformats/types/codecs_json.ByteView.html",
"./codecs/json:ByteView": "https://multiformats.github.io/js-multiformats/types/codecs_json.ByteView.html",
"code": "https://multiformats.github.io/js-multiformats/variables/codecs_json.code.html",
"./codecs/json:code": "https://multiformats.github.io/js-multiformats/variables/codecs_json.code.html",
"name": "https://multiformats.github.io/js-multiformats/variables/codecs_json.name.html",
"./codecs/json:name": "https://multiformats.github.io/js-multiformats/variables/codecs_json.name.html",
"./codecs/json:decode": "https://multiformats.github.io/js-multiformats/functions/codecs_json.decode.html",
"./codecs/json:encode": "https://multiformats.github.io/js-multiformats/functions/codecs_json.encode.html",
"./codecs/raw:ByteView": "https://multiformats.github.io/js-multiformats/types/codecs_raw.ByteView.html",
"./codecs/raw:code": "https://multiformats.github.io/js-multiformats/variables/codecs_raw.code.html",
"./codecs/raw:name": "https://multiformats.github.io/js-multiformats/variables/codecs_raw.name.html",
"./codecs/raw:decode": "https://multiformats.github.io/js-multiformats/functions/codecs_raw.decode.html",
"./codecs/raw:encode": "https://multiformats.github.io/js-multiformats/functions/codecs_raw.encode.html",
"Digest": "https://multiformats.github.io/js-multiformats/classes/hashes_digest.Digest.html",
"./hashes/digest:Digest": "https://multiformats.github.io/js-multiformats/classes/hashes_digest.Digest.html",
"MultihashDigest": "https://multiformats.github.io/js-multiformats/types/hashes_digest.MultihashDigest.html",
"./hashes/digest:MultihashDigest": "https://multiformats.github.io/js-multiformats/types/hashes_digest.MultihashDigest.html",
"./hashes/digest:create": "https://multiformats.github.io/js-multiformats/functions/hashes_digest.create.html",
"./hashes/digest:decode": "https://multiformats.github.io/js-multiformats/functions/hashes_digest.decode.html",
"./hashes/digest:equals": "https://multiformats.github.io/js-multiformats/functions/hashes_digest.equals.html",
"Hasher": "https://multiformats.github.io/js-multiformats/classes/hashes_hasher.Hasher.html",
"./hashes/hasher:Hasher": "https://multiformats.github.io/js-multiformats/classes/hashes_hasher.Hasher.html",
"MultihashHasher": "https://multiformats.github.io/js-multiformats/interfaces/hashes_hasher.MultihashHasher.html",
"Await": "https://multiformats.github.io/js-multiformats/types/hashes_hasher.Await.html",
"./hashes/hasher:Await": "https://multiformats.github.io/js-multiformats/types/hashes_hasher.Await.html",
"from": "https://multiformats.github.io/js-multiformats/functions/hashes_hasher.from.html",
"./hashes/hasher:from": "https://multiformats.github.io/js-multiformats/functions/hashes_hasher.from.html",
"./hashes/identity:identity": "https://multiformats.github.io/js-multiformats/variables/hashes_identity.identity.html",
"sha1": "https://multiformats.github.io/js-multiformats/variables/hashes_sha1.sha1.html",
"./hashes/sha1:sha1": "https://multiformats.github.io/js-multiformats/variables/hashes_sha1.sha1.html",
"sha256": "https://multiformats.github.io/js-multiformats/variables/hashes_sha2.sha256.html",
"./hashes/sha2:sha256": "https://multiformats.github.io/js-multiformats/variables/hashes_sha2.sha256.html",
"sha512": "https://multiformats.github.io/js-multiformats/variables/hashes_sha2.sha512.html",
"./hashes/sha2:sha512": "https://multiformats.github.io/js-multiformats/variables/hashes_sha2.sha512.html",
"encodeTo": "https://multiformats.github.io/js-multiformats/functions/index.varint.encodeTo.html",
"encodingLength": "https://multiformats.github.io/js-multiformats/functions/index.varint.encodingLength.html",
"BaseCodec": "https://multiformats.github.io/js-multiformats/interfaces/index.BaseCodec.html",
"BaseDecoder": "https://multiformats.github.io/js-multiformats/interfaces/index.BaseDecoder.html",
"BaseEncoder": "https://multiformats.github.io/js-multiformats/interfaces/index.BaseEncoder.html",
"BlockCodec": "https://multiformats.github.io/js-multiformats/interfaces/index.BlockCodec.html",
"BlockDecoder": "https://multiformats.github.io/js-multiformats/interfaces/index.BlockDecoder.html",
"BlockEncoder": "https://multiformats.github.io/js-multiformats/interfaces/index.BlockEncoder.html",
"BlockView": "https://multiformats.github.io/js-multiformats/interfaces/index.BlockView.html",
"CombobaseDecoder": "https://multiformats.github.io/js-multiformats/interfaces/index.CombobaseDecoder.html",
"LegacyLink": "https://multiformats.github.io/js-multiformats/interfaces/index.LegacyLink.html",
"Link": "https://multiformats.github.io/js-multiformats/interfaces/index.Link.html",
"LinkJSON": "https://multiformats.github.io/js-multiformats/interfaces/index.LinkJSON.html",
"MultibaseCodec": "https://multiformats.github.io/js-multiformats/interfaces/index.MultibaseCodec.html",
"MultibaseDecoder": "https://multiformats.github.io/js-multiformats/interfaces/index.MultibaseDecoder.html",
"MultibaseEncoder": "https://multiformats.github.io/js-multiformats/interfaces/index.MultibaseEncoder.html",
"Phantom": "https://multiformats.github.io/js-multiformats/interfaces/index.Phantom.html",
"SyncMultihashHasher": "https://multiformats.github.io/js-multiformats/interfaces/index.SyncMultihashHasher.html",
"UnibaseDecoder": "https://multiformats.github.io/js-multiformats/interfaces/index.UnibaseDecoder.html",
"BlockCursorView": "https://multiformats.github.io/js-multiformats/types/index.BlockCursorView.html",
"DAG_PB": "https://multiformats.github.io/js-multiformats/types/index.DAG_PB.html",
"Multibase": "https://multiformats.github.io/js-multiformats/types/index.Multibase.html",
"SHA_256": "https://multiformats.github.io/js-multiformats/types/index.SHA_256.html",
"ToString": "https://multiformats.github.io/js-multiformats/types/index.ToString.html",
"UnknownLink": "https://multiformats.github.io/js-multiformats/types/index.UnknownLink.html",
"Version": "https://multiformats.github.io/js-multiformats/types/index.Version.html",
"./link:create": "https://multiformats.github.io/js-multiformats/functions/link.create.html",
"createLegacy": "https://multiformats.github.io/js-multiformats/functions/link.createLegacy.html",
"./link:createLegacy": "https://multiformats.github.io/js-multiformats/functions/link.createLegacy.html",
"./link:decode": "https://multiformats.github.io/js-multiformats/functions/link.decode.html",
"isLink": "https://multiformats.github.io/js-multiformats/functions/link.isLink.html",
"./link:isLink": "https://multiformats.github.io/js-multiformats/functions/link.isLink.html",
"parse": "https://multiformats.github.io/js-multiformats/functions/link.parse.html",
"./link:parse": "https://multiformats.github.io/js-multiformats/functions/link.parse.html",
"./traversal:BlockView": "https://multiformats.github.io/js-multiformats/types/traversal.BlockView.html",
"./traversal:CID": "https://multiformats.github.io/js-multiformats/types/traversal.CID.html",
"walk": "https://multiformats.github.io/js-multiformats/functions/traversal.walk.html",
"./traversal:walk": "https://multiformats.github.io/js-multiformats/functions/traversal.walk.html"
}
@@ -0,0 +1,148 @@
export function or<L extends string, R extends string>(left: API.UnibaseDecoder<L> | API.CombobaseDecoder<L>, right: API.UnibaseDecoder<R> | API.CombobaseDecoder<R>): ComposedDecoder<L | R>;
/**
* @class
* @template {string} Base
* @template {string} Prefix
* @implements {API.MultibaseCodec<Prefix>}
* @implements {API.MultibaseEncoder<Prefix>}
* @implements {API.MultibaseDecoder<Prefix>}
* @implements {API.BaseCodec}
* @implements {API.BaseEncoder}
* @implements {API.BaseDecoder}
*/
export class Codec<Base extends string, Prefix extends string> implements API.MultibaseCodec<Prefix>, API.MultibaseEncoder<Prefix>, API.MultibaseDecoder<Prefix>, API.BaseCodec, API.BaseEncoder, API.BaseDecoder {
/**
* @param {Base} name
* @param {Prefix} prefix
* @param {(bytes:Uint8Array) => string} baseEncode
* @param {(text:string) => Uint8Array} baseDecode
*/
constructor(name: Base, prefix: Prefix, baseEncode: (bytes: Uint8Array) => string, baseDecode: (text: string) => Uint8Array);
name: Base;
prefix: Prefix;
baseEncode: (bytes: Uint8Array) => string;
baseDecode: (text: string) => Uint8Array;
encoder: Encoder<Base, Prefix>;
decoder: Decoder<Base, Prefix>;
/**
* @param {Uint8Array} input
*/
encode(input: Uint8Array): API.Multibase<Prefix>;
/**
* @param {string} input
*/
decode(input: string): Uint8Array;
}
export function from<Base extends string, Prefix extends string>({ name, prefix, encode, decode }: {
name: Base;
prefix: Prefix;
encode: (bytes: Uint8Array) => string;
decode: (input: string) => Uint8Array;
}): Codec<Base, Prefix>;
export function baseX<Base extends string, Prefix extends string>({ prefix, name, alphabet }: {
name: Base;
prefix: Prefix;
alphabet: string;
}): Codec<Base, Prefix>;
export function rfc4648<Base extends string, Prefix extends string>({ name, prefix, bitsPerChar, alphabet }: {
name: Base;
prefix: Prefix;
alphabet: string;
bitsPerChar: number;
}): Codec<Base, Prefix>;
export type Decoders<Prefix extends string> = Record<Prefix, API.UnibaseDecoder<Prefix>>;
import * as API from './interface.js';
/**
* @template {string} Prefix
* @typedef {Record<Prefix, API.UnibaseDecoder<Prefix>>} Decoders
*/
/**
* @template {string} Prefix
* @implements {API.MultibaseDecoder<Prefix>}
* @implements {API.CombobaseDecoder<Prefix>}
*/
declare class ComposedDecoder<Prefix extends string> implements API.MultibaseDecoder<Prefix>, API.CombobaseDecoder<Prefix> {
/**
* @param {Decoders<Prefix>} decoders
*/
constructor(decoders: Decoders<Prefix>);
decoders: Decoders<Prefix>;
/**
* @template {string} OtherPrefix
* @param {API.UnibaseDecoder<OtherPrefix>|ComposedDecoder<OtherPrefix>} decoder
* @returns {ComposedDecoder<Prefix|OtherPrefix>}
*/
or<OtherPrefix extends string>(decoder: API.UnibaseDecoder<OtherPrefix> | ComposedDecoder<OtherPrefix>): ComposedDecoder<Prefix | OtherPrefix>;
/**
* @param {string} input
* @returns {Uint8Array}
*/
decode(input: string): Uint8Array;
}
/**
* Class represents both BaseEncoder and MultibaseEncoder meaning it
* can be used to encode to multibase or base encode without multibase
* prefix.
*
* @class
* @template {string} Base
* @template {string} Prefix
* @implements {API.MultibaseEncoder<Prefix>}
* @implements {API.BaseEncoder}
*/
declare class Encoder<Base extends string, Prefix extends string> implements API.MultibaseEncoder<Prefix>, API.BaseEncoder {
/**
* @param {Base} name
* @param {Prefix} prefix
* @param {(bytes:Uint8Array) => string} baseEncode
*/
constructor(name: Base, prefix: Prefix, baseEncode: (bytes: Uint8Array) => string);
name: Base;
prefix: Prefix;
baseEncode: (bytes: Uint8Array) => string;
/**
* @param {Uint8Array} bytes
* @returns {API.Multibase<Prefix>}
*/
encode(bytes: Uint8Array): API.Multibase<Prefix>;
}
/**
* @template {string} Prefix
*/
/**
* Class represents both BaseDecoder and MultibaseDecoder so it could be used
* to decode multibases (with matching prefix) or just base decode strings
* with corresponding base encoding.
*
* @class
* @template {string} Base
* @template {string} Prefix
* @implements {API.MultibaseDecoder<Prefix>}
* @implements {API.UnibaseDecoder<Prefix>}
* @implements {API.BaseDecoder}
*/
declare class Decoder<Base extends string, Prefix extends string> implements API.MultibaseDecoder<Prefix>, API.UnibaseDecoder<Prefix>, API.BaseDecoder {
/**
* @param {Base} name
* @param {Prefix} prefix
* @param {(text:string) => Uint8Array} baseDecode
*/
constructor(name: Base, prefix: Prefix, baseDecode: (text: string) => Uint8Array);
name: Base;
prefix: Prefix;
/** @private */
private prefixCodePoint;
baseDecode: (text: string) => Uint8Array;
/**
* @param {string} text
*/
decode(text: string): Uint8Array;
/**
* @template {string} OtherPrefix
* @param {API.UnibaseDecoder<OtherPrefix>|ComposedDecoder<OtherPrefix>} decoder
* @returns {ComposedDecoder<Prefix|OtherPrefix>}
*/
or<OtherPrefix extends string>(decoder: API.UnibaseDecoder<OtherPrefix> | ComposedDecoder<OtherPrefix>): ComposedDecoder<Prefix | OtherPrefix>;
}
export {};
//# sourceMappingURL=base.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../src/bases/base.js"],"names":[],"mappings":"AAoJO,8LAGJ;AAEH;;;;;;;;;;GAUG;AACH,0EAPgB,GAAG,CAAC,cAAc,CAAC,MAAM,GACzB,GAAG,CAAC,gBAAgB,CAAC,MAAM,GAC3B,GAAG,CAAC,gBAAgB,CAAC,MAAM,GAC3B,GAAG,CAAC,SAAS,EACb,GAAG,CAAC,WAAW,EACf,GAAG,CAAC,WAAW;IAG7B;;;;;OAKG;IACH,kBALW,IAAI,UACJ,MAAM,sBACC,UAAU,KAAK,MAAM,qBACtB,MAAM,KAAK,UAAU,EASrC;IANC,WAAgB;IAChB,eAAoB;IACpB,oBANgB,UAAU,KAAK,MAAM,CAMT;IAC5B,mBANe,MAAM,KAAK,UAAU,CAMR;IAC5B,+BAAoD;IACpD,+BAAoD;IAGtD;;OAEG;IACH,cAFW,UAAU,yBAIpB;IAED;;OAEG;IACH,cAFW,MAAM,cAIhB;CACF;AAYM;;;oBAJW,UAAU,KAAK,MAAM;oBACrB,MAAM,KAAK,UAAU;wBAIE;AAWlC;;;cAHI,MAAM;wBAchB;AA2GM;;;cAHI,MAAM;iBACN,MAAM;wBAahB;8CArPY,OAAO,MAAM,EAAE,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC;qBAjGlC,gBAAgB;AA+FrC;;;GAGG;AAEH;;;;GAIG;AACH,gEAHgB,GAAG,CAAC,gBAAgB,CAAC,MAAM,GAC3B,GAAG,CAAC,gBAAgB,CAAC,MAAM;IAGzC;;OAEG;IACH,sBAFW,SAAS,MAAM,CAAC,EAI1B;IADC,2BAAwB;IAG1B;;;;OAIG;IACH,+IAEC;IAED;;;OAGG;IACH,cAHW,MAAM,GACJ,UAAU,CAUtB;CACF;AArID;;;;;;;;;;GAUG;AACH,6EAHgB,GAAG,CAAC,gBAAgB,CAAC,MAAM,GAC3B,GAAG,CAAC,WAAW;IAG7B;;;;OAIG;IACH,kBAJW,IAAI,UACJ,MAAM,sBACC,UAAU,KAAK,MAAM,EAMtC;IAHC,WAAgB;IAChB,eAAoB;IACpB,oBALgB,UAAU,KAAK,MAAM,CAKT;IAG9B;;;OAGG;IACH,cAHW,UAAU,GACR,IAAI,SAAS,CAAC,MAAM,CAAC,CAQjC;CACF;AAED;;GAEG;AACH;;;;;;;;;;;GAWG;AACH,6EAJgB,GAAG,CAAC,gBAAgB,CAAC,MAAM,GAC3B,GAAG,CAAC,cAAc,CAAC,MAAM,GACzB,GAAG,CAAC,WAAW;IAG7B;;;;OAIG;IACH,kBAJW,IAAI,UACJ,MAAM,qBACA,MAAM,KAAK,UAAU,EAYrC;IATC,WAAgB;IAChB,eAAoB;IAKpB,eAAe;IACf,wBAAoE;IACpE,mBAXe,MAAM,KAAK,UAAU,CAWR;IAG9B;;OAEG;IACH,aAFW,MAAM,cAWhB;IAED;;;;OAIG;IACH,+IAEC;CACF"}
@@ -0,0 +1,2 @@
export const base10: import("./base.js").Codec<"base10", "9">;
//# sourceMappingURL=base10.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"base10.d.ts","sourceRoot":"","sources":["../../../../src/bases/base10.js"],"names":[],"mappings":"AAEA,8DAIE"}
@@ -0,0 +1,3 @@
export const base16: import("./base.js").Codec<"base16", "f">;
export const base16upper: import("./base.js").Codec<"base16upper", "F">;
//# sourceMappingURL=base16.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"base16.d.ts","sourceRoot":"","sources":["../../../../src/bases/base16.js"],"names":[],"mappings":"AAIA,8DAKE;AAEF,wEAKE"}
@@ -0,0 +1,2 @@
export const base2: import("./base.js").Codec<"base2", "0">;
//# sourceMappingURL=base2.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"base2.d.ts","sourceRoot":"","sources":["../../../../src/bases/base2.js"],"names":[],"mappings":"AAIA,4DAKE"}
@@ -0,0 +1,2 @@
export const base256emoji: import("./base.js").Codec<"base256emoji", "🚀">;
//# sourceMappingURL=base256emoji.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"base256emoji.d.ts","sourceRoot":"","sources":["../../../../src/bases/base256emoji.js"],"names":[],"mappings":"AAiCA,2EAKE"}
@@ -0,0 +1,10 @@
export const base32: import("./base.js").Codec<"base32", "b">;
export const base32upper: import("./base.js").Codec<"base32upper", "B">;
export const base32pad: import("./base.js").Codec<"base32pad", "c">;
export const base32padupper: import("./base.js").Codec<"base32padupper", "C">;
export const base32hex: import("./base.js").Codec<"base32hex", "v">;
export const base32hexupper: import("./base.js").Codec<"base32hexupper", "V">;
export const base32hexpad: import("./base.js").Codec<"base32hexpad", "t">;
export const base32hexpadupper: import("./base.js").Codec<"base32hexpadupper", "T">;
export const base32z: import("./base.js").Codec<"base32z", "h">;
//# sourceMappingURL=base32.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"base32.d.ts","sourceRoot":"","sources":["../../../../src/bases/base32.js"],"names":[],"mappings":"AAEA,8DAKE;AAEF,wEAKE;AAEF,oEAKE;AAEF,8EAKE;AAEF,oEAKE;AAEF,8EAKE;AAEF,0EAKE;AAEF,oFAKE;AAEF,gEAKE"}
@@ -0,0 +1,3 @@
export const base36: import("./base.js").Codec<"base36", "k">;
export const base36upper: import("./base.js").Codec<"base36upper", "K">;
//# sourceMappingURL=base36.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"base36.d.ts","sourceRoot":"","sources":["../../../../src/bases/base36.js"],"names":[],"mappings":"AAEA,8DAIE;AAEF,wEAIE"}
@@ -0,0 +1,3 @@
export const base58btc: import("./base.js").Codec<"base58btc", "z">;
export const base58flickr: import("./base.js").Codec<"base58flickr", "Z">;
//# sourceMappingURL=base58.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"base58.d.ts","sourceRoot":"","sources":["../../../../src/bases/base58.js"],"names":[],"mappings":"AAEA,oEAIE;AAEF,0EAIE"}
@@ -0,0 +1,5 @@
export const base64: import("./base.js").Codec<"base64", "m">;
export const base64pad: import("./base.js").Codec<"base64pad", "M">;
export const base64url: import("./base.js").Codec<"base64url", "u">;
export const base64urlpad: import("./base.js").Codec<"base64urlpad", "U">;
//# sourceMappingURL=base64.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"base64.d.ts","sourceRoot":"","sources":["../../../../src/bases/base64.js"],"names":[],"mappings":"AAIA,8DAKE;AAEF,oEAKE;AAEF,oEAKE;AAEF,0EAKE"}
@@ -0,0 +1,2 @@
export const base8: import("./base.js").Codec<"base8", "7">;
//# sourceMappingURL=base8.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"base8.d.ts","sourceRoot":"","sources":["../../../../src/bases/base8.js"],"names":[],"mappings":"AAIA,4DAKE"}
@@ -0,0 +1,2 @@
export const identity: import("./base.js").Codec<"identity", "\0">;
//# sourceMappingURL=identity.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../../../src/bases/identity.js"],"names":[],"mappings":"AAKA,mEAKE"}
@@ -0,0 +1,89 @@
/**
* Base encoder just encodes bytes into base encoded string.
*/
export interface BaseEncoder {
/**
* Base encodes to a **plain** (and not a multibase) string. Unlike
* `encode` no multibase prefix is added.
*
* @param bytes
*/
baseEncode(bytes: Uint8Array): string;
}
/**
* Base decoder decodes encoded with matching base encoding into bytes.
*/
export interface BaseDecoder {
/**
* Decodes **plain** (and not a multibase) string. Unlike
* decode
*
* @param text
*/
baseDecode(text: string): Uint8Array;
}
/**
* Base codec is just dual of encoder and decoder.
*/
export interface BaseCodec {
encoder: BaseEncoder;
decoder: BaseDecoder;
}
/**
* Multibase represents base encoded strings with a prefix first character
* describing it's encoding.
*/
export type Multibase<Prefix extends string> = string | string & {
[0]: Prefix;
};
/**
* Multibase encoder for the specific base encoding encodes bytes into
* multibase of that encoding.
*/
export interface MultibaseEncoder<Prefix extends string> {
/**
* Name of the encoding.
*/
name: string;
/**
* Prefix character for that base encoding.
*/
prefix: Prefix;
/**
* Encodes binary data into **multibase** string (which will have a
* prefix added).
*/
encode(bytes: Uint8Array): Multibase<Prefix>;
}
/**
* Interface implemented by multibase decoder, that takes multibase strings
* to bytes. It may support single encoding like base32 or multiple encodings
* like base32, base58btc, base64. If passed multibase is incompatible it will
* throw an exception.
*/
export interface MultibaseDecoder<Prefix extends string> {
/**
* Decodes **multibase** string (which must have a multibase prefix added).
* If prefix does not match
*
* @param multibase
*/
decode(multibase: Multibase<Prefix>): Uint8Array;
}
/**
* Dual of multibase encoder and decoder.
*/
export interface MultibaseCodec<Prefix extends string> {
name: string;
prefix: Prefix;
encoder: MultibaseEncoder<Prefix>;
decoder: MultibaseDecoder<Prefix>;
}
export interface UnibaseDecoder<Prefix extends string> extends MultibaseDecoder<Prefix> {
readonly decoders?: null;
readonly prefix: Prefix;
}
export interface CombobaseDecoder<Prefix extends string> extends MultibaseDecoder<Prefix> {
readonly decoders: Record<Prefix, UnibaseDecoder<Prefix>>;
}
//# sourceMappingURL=interface.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../../src/bases/interface.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;;OAKG;IACH,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAAA;CACtC;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;;OAKG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAAA;CACrC;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,WAAW,CAAA;IACpB,OAAO,EAAE,WAAW,CAAA;CACrB;AAED;;;GAGG;AACH,MAAM,MAAM,SAAS,CAAC,MAAM,SAAS,MAAM,IACvC,MAAM,GACN,MAAM,GAAG;IAAE,CAAC,CAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAE5B;;;GAGG;AACH,MAAM,WAAW,gBAAgB,CAAC,MAAM,SAAS,MAAM;IACrD;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,CAAC,MAAM,CAAC,CAAA;CAC7C;AAED;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB,CAAC,MAAM,SAAS,MAAM;IACrD;;;;;OAKG;IACH,MAAM,CAAC,SAAS,EAAE,SAAS,CAAC,MAAM,CAAC,GAAG,UAAU,CAAA;CACjD;AAED;;GAEG;AACH,MAAM,WAAW,cAAc,CAAC,MAAM,SAAS,MAAM;IACnD,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAA;IACjC,OAAO,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAA;CAClC;AAED,MAAM,WAAW,cAAc,CAAC,MAAM,SAAS,MAAM,CAAE,SAAQ,gBAAgB,CAAC,MAAM,CAAC;IAErF,QAAQ,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAA;IAExB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CACxB;AAED,MAAM,WAAW,gBAAgB,CAAC,MAAM,SAAS,MAAM,CAAE,SAAQ,gBAAgB,CAAC,MAAM,CAAC;IACvF,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC,CAAA;CAC1D"}
@@ -0,0 +1,49 @@
import { CID } from './index.js';
import { hasher } from './index.js';
import { digest } from './index.js';
import { varint } from './index.js';
import { bytes } from './index.js';
export const hashes: {
identity: {
code: number;
name: string;
encode: (input: Uint8Array) => Uint8Array;
digest: (input: Uint8Array) => digest.Digest<0, number>;
};
sha256: hasher.Hasher<"sha2-256", 18>;
sha512: hasher.Hasher<"sha2-512", 19>;
};
export const bases: {
base256emoji: import("./bases/base.js").Codec<"base256emoji", "🚀">;
base64: import("./bases/base.js").Codec<"base64", "m">;
base64pad: import("./bases/base.js").Codec<"base64pad", "M">;
base64url: import("./bases/base.js").Codec<"base64url", "u">;
base64urlpad: import("./bases/base.js").Codec<"base64urlpad", "U">;
base58btc: import("./bases/base.js").Codec<"base58btc", "z">;
base58flickr: import("./bases/base.js").Codec<"base58flickr", "Z">;
base36: import("./bases/base.js").Codec<"base36", "k">;
base36upper: import("./bases/base.js").Codec<"base36upper", "K">;
base32: import("./bases/base.js").Codec<"base32", "b">;
base32upper: import("./bases/base.js").Codec<"base32upper", "B">;
base32pad: import("./bases/base.js").Codec<"base32pad", "c">;
base32padupper: import("./bases/base.js").Codec<"base32padupper", "C">;
base32hex: import("./bases/base.js").Codec<"base32hex", "v">;
base32hexupper: import("./bases/base.js").Codec<"base32hexupper", "V">;
base32hexpad: import("./bases/base.js").Codec<"base32hexpad", "t">;
base32hexpadupper: import("./bases/base.js").Codec<"base32hexpadupper", "T">;
base32z: import("./bases/base.js").Codec<"base32z", "h">;
base16: import("./bases/base.js").Codec<"base16", "f">;
base16upper: import("./bases/base.js").Codec<"base16upper", "F">;
base10: import("./bases/base.js").Codec<"base10", "9">;
base8: import("./bases/base.js").Codec<"base8", "7">;
base2: import("./bases/base.js").Codec<"base2", "0">;
identity: import("./bases/base.js").Codec<"identity", "\0">;
};
export namespace codecs {
export { raw };
export { json };
}
import * as raw from './codecs/raw.js';
import * as json from './codecs/json.js';
export { CID, hasher, digest, varint, bytes };
//# sourceMappingURL=basics.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"basics.d.ts","sourceRoot":"","sources":["../../../src/basics.js"],"names":[],"mappings":"oBAgBmD,YAAY;uBAAZ,YAAY;uBAAZ,YAAY;uBAAZ,YAAY;sBAAZ,YAAY;AAG/D;;;;;;;;;EAAuC;AADvC;;;;;;;;;;;;;;;;;;;;;;;;;EAAwI;;;;;qBALnH,iBAAiB;sBADhB,kBAAkB"}
@@ -0,0 +1,109 @@
export type RequiredCreateOptions = {
cid: CID;
};
/**
* @template {unknown} T - Logical type of the data encoded in the block
* @template {number} Code - multicodec code corresponding to codec used to encode the block
* @template {number} Alg - multicodec code corresponding to the hashing algorithm used in CID creation.
* @param {object} options
* @param {T} options.value
* @param {API.BlockEncoder<Code, T>} options.codec
* @param {API.MultihashHasher<Alg>} options.hasher
* @returns {Promise<API.BlockView<T, Code, Alg>>}
*/
export function encode<T extends unknown, Code extends number, Alg extends number>({ value, codec, hasher }: {
value: T;
codec: API.BlockEncoder<Code, T>;
hasher: API.MultihashHasher<Alg>;
}): Promise<API.BlockView<T, Code, Alg, 1>>;
/**
* @template {unknown} T - Logical type of the data encoded in the block
* @template {number} Code - multicodec code corresponding to codec used to encode the block
* @template {number} Alg - multicodec code corresponding to the hashing algorithm used in CID creation.
* @param {object} options
* @param {API.ByteView<T>} options.bytes
* @param {API.BlockDecoder<Code, T>} options.codec
* @param {API.MultihashHasher<Alg>} options.hasher
* @returns {Promise<API.BlockView<T, Code, Alg>>}
*/
export function decode<T extends unknown, Code extends number, Alg extends number>({ bytes, codec, hasher }: {
bytes: API.ByteView<T>;
codec: API.BlockDecoder<Code, T>;
hasher: API.MultihashHasher<Alg>;
}): Promise<API.BlockView<T, Code, Alg, 1>>;
/**
* @template {unknown} T - Logical type of the data encoded in the block
* @template {number} Code - multicodec code corresponding to codec used to encode the block
* @template {number} Alg - multicodec code corresponding to the hashing algorithm used in CID creation.
* @template {API.Version} V - CID version
* @param {object} options
* @param {API.Link<T, Code, Alg, V>} options.cid
* @param {API.ByteView<T>} options.bytes
* @param {API.BlockDecoder<Code, T>} options.codec
* @param {API.MultihashHasher<Alg>} options.hasher
* @returns {Promise<API.BlockView<T, Code, Alg, V>>}
*/
export function create<T extends unknown, Code extends number, Alg extends number, V extends API.Version>({ bytes, cid, hasher, codec }: {
cid: API.Link<T, Code, Alg, V>;
bytes: API.ByteView<T>;
codec: API.BlockDecoder<Code, T>;
hasher: API.MultihashHasher<Alg>;
}): Promise<API.BlockView<T, Code, Alg, V>>;
/**
* @typedef {object} RequiredCreateOptions
* @property {CID} options.cid
*/
/**
* @template {unknown} T - Logical type of the data encoded in the block
* @template {number} Code - multicodec code corresponding to codec used to encode the block
* @template {number} Alg - multicodec code corresponding to the hashing algorithm used in CID creation.
* @template {API.Version} V - CID version
* @param {{ cid: API.Link<T, Code, Alg, V>, value:T, codec?: API.BlockDecoder<Code, T>, bytes: API.ByteView<T> }|{cid:API.Link<T, Code, Alg, V>, bytes:API.ByteView<T>, value?:void, codec:API.BlockDecoder<Code, T>}} options
* @returns {API.BlockView<T, Code, Alg, V>}
*/
export function createUnsafe<T extends unknown, Code extends number, Alg extends number, V extends API.Version>({ bytes, cid, value: maybeValue, codec }: {
cid: API.Link<T, Code, Alg, V>;
value: T;
codec?: API.BlockDecoder<Code, T> | undefined;
bytes: API.ByteView<T>;
} | {
cid: API.Link<T, Code, Alg, V>;
bytes: API.ByteView<T>;
value?: void | undefined;
codec: API.BlockDecoder<Code, T>;
}): API.BlockView<T, Code, Alg, V>;
/**
* @template {unknown} T - Logical type of the data encoded in the block
* @template {number} C - multicodec code corresponding to codec used to encode the block
* @template {number} A - multicodec code corresponding to the hashing algorithm used in CID creation.
* @template {API.Version} V - CID version
* @implements {API.BlockView<T, C, A, V>}
*/
export class Block<T extends unknown, C extends number, A extends number, V extends API.Version> implements API.BlockView<T, C, A, V> {
/**
* @param {object} options
* @param {CID<T, C, A, V>} options.cid
* @param {API.ByteView<T>} options.bytes
* @param {T} options.value
*/
constructor({ cid, bytes, value }: {
cid: CID<T, C, A, V>;
bytes: API.ByteView<T>;
value: T;
});
cid: CID<T, C, A, V>;
bytes: API.ByteView<T>;
value: T & ({} | null);
asBlock: this;
links(): Iterable<[string, CID<any, number, number, API.Version>]>;
tree(): Iterable<string>;
/**
*
* @param {string} [path]
* @returns {API.BlockCursorView<unknown>}
*/
get(path?: string | undefined): API.BlockCursorView<unknown>;
}
import * as API from './interface.js';
import { CID } from './index.js';
//# sourceMappingURL=block.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../../../src/block.js"],"names":[],"mappings":";SAwNc,GAAG;;AAlDjB;;;;;;;;;GASG;AACH;;;;4CAcC;AAED;;;;;;;;;GASG;AACH;;;;4CAUC;AA8BD;;;;;;;;;;;GAWG;AACH;;;;;4CAeC;AAvDD;;;GAGG;AAEH;;;;;;;GAOG;AACH;;;;;;;;;;mCAaC;AA3HD;;;;;;GAMG;AACH,4GAFgB,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;IAGtC;;;;;OAKG;IACH;QAJoC,GAAG,EAA5B,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QACU,KAAK,EAA9B,IAAI,QAAQ,CAAC,CAAC,CAAC;QACJ,KAAK,EAAhB,CAAC;OAiBX;IAZC,qBAAc;IACd,uBAAkB;IAClB,uBAAkB;IAClB,cAAmB;IAWrB,mEAEC;IAED,yBAEC;IAED;;;;OAIG;IACH,gCAFa,IAAI,eAAe,CAAC,OAAO,CAAC,CAIxC;CACF;qBAjKoB,gBAAgB;oBAHA,YAAY"}
@@ -0,0 +1,58 @@
import type { CID } from '../cid.js';
import type { Link, Version } from '../link/interface.js';
/**
* A byte-encoded representation of some type of `Data`.
*
* A `ByteView` is essentially a `Uint8Array` that's been "tagged" with
* a `Data` type parameter indicating the type of encoded data.
*
* For example, a `ByteView<{ hello: "world" }>` is a `Uint8Array` containing a
* binary representation of a `{hello: "world"}`.
*/
export interface ByteView<Data> extends Uint8Array, Phantom<Data> {
}
declare const Marker: unique symbol;
/**
* A utility type to retain an unused type parameter `T`.
* Similar to [phantom type parameters in Rust](https://doc.rust-lang.org/rust-by-example/generics/phantom.html).
*
* Capturing unused type parameters allows us to define "nominal types," which
* TypeScript does not natively support. Nominal types in turn allow us to capture
* semantics not represented in the actual type structure, without requiring us to define
* new classes or pay additional runtime costs.
*
* For a concrete example, see {@link ByteView}, which extends the `Uint8Array` type to capture
* type information about the structure of the data encoded into the array.
*/
export interface Phantom<T> {
[Marker]?: T;
}
/**
* Represents an IPLD block (including its CID) that can be decoded to data of
* type `T`.
*
* @template T - Logical type of the data encoded in the block
* @template C - multicodec code corresponding to codec used to encode the block
* @template A - multicodec code corresponding to the hashing algorithm used in CID creation.
* @template V - CID version
*/
export interface Block<T = unknown, C extends number = number, A extends number = number, V extends Version = 1> {
bytes: ByteView<T>;
cid: Link<T, C, A, V>;
}
export type BlockCursorView<T extends unknown = unknown> = {
value: T;
remaining?: undefined;
} | {
value: CID;
remaining: string;
};
export interface BlockView<T = unknown, C extends number = number, A extends number = number, V extends Version = 1> extends Block<T, C, A, V> {
cid: CID<T, C, A, V>;
value: T;
links(): Iterable<[string, CID]>;
tree(): Iterable<string>;
get(path: string): BlockCursorView<unknown>;
}
export {};
//# sourceMappingURL=interface.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../../src/block/interface.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAEzD;;;;;;;;GAQG;AACH,MAAM,WAAW,QAAQ,CAAC,IAAI,CAAE,SAAQ,UAAU,EAAE,OAAO,CAAC,IAAI,CAAC;CAAG;AAEpE,OAAO,CAAC,MAAM,MAAM,EAAE,OAAO,MAAM,CAAA;AAEnC;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,OAAO,CAAC,CAAC;IAIxB,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAA;CACb;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,KAAK,CACpB,CAAC,GAAG,OAAO,EACX,CAAC,SAAS,MAAM,GAAG,MAAM,EACzB,CAAC,SAAS,MAAM,GAAG,MAAM,EACzB,CAAC,SAAS,OAAO,GAAG,CAAC;IAErB,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAA;IAClB,GAAG,EAAE,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;CACtB;AAED,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,IACnD;IAAE,KAAK,EAAE,CAAC,CAAC;IAAC,SAAS,CAAC,EAAE,SAAS,CAAA;CAAE,GACnC;IAAE,KAAK,EAAE,GAAG,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAA;AAErC,MAAM,WAAW,SAAS,CACxB,CAAC,GAAG,OAAO,EACX,CAAC,SAAS,MAAM,GAAG,MAAM,EACzB,CAAC,SAAS,MAAM,GAAG,MAAM,EACzB,CAAC,SAAS,OAAO,GAAG,CAAC,CACrB,SAAQ,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACzB,GAAG,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;IACpB,KAAK,EAAE,CAAC,CAAA;IAER,KAAK,IAAI,QAAQ,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAA;IAChC,IAAI,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAA;IACxB,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAAC,OAAO,CAAC,CAAA;CAC5C"}
@@ -0,0 +1,35 @@
/**
* @param {Uint8Array} aa
* @param {Uint8Array} bb
*/
export function equals(aa: Uint8Array, bb: Uint8Array): boolean;
/**
* @param {ArrayBufferView|ArrayBuffer|Uint8Array} o
* @returns {Uint8Array}
*/
export function coerce(o: ArrayBufferView | ArrayBuffer | Uint8Array): Uint8Array;
/**
* @param {any} o
* @returns {o is ArrayBuffer|ArrayBufferView}
*/
export function isBinary(o: any): o is ArrayBufferView | ArrayBuffer;
/**
* @param {string} hex
*/
export function fromHex(hex: string): Uint8Array;
/**
* @param {Uint8Array} d
*/
export function toHex(d: Uint8Array): string;
/**
* @param {string} str
* @returns {Uint8Array}
*/
export function fromString(str: string): Uint8Array;
/**
* @param {Uint8Array} b
* @returns {string}
*/
export function toString(b: Uint8Array): string;
export const empty: Uint8Array;
//# sourceMappingURL=bytes.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"bytes.d.ts","sourceRoot":"","sources":["../../../src/bytes.js"],"names":[],"mappings":"AAeA;;;GAGG;AACH,2BAHW,UAAU,MACV,UAAU,WAepB;AAED;;;GAGG;AACH,0BAHW,eAAe,GAAC,WAAW,GAAC,UAAU,GACpC,UAAU,CAStB;AAED;;;GAGG;AACH,4BAHW,GAAG,sCAIqC;AA7CnD;;GAEG;AACH,6BAFW,MAAM,cAKhB;AAXD;;GAEG;AACH,yBAFW,UAAU,UAEmE;AAiDxF;;;GAGG;AACH,gCAHW,MAAM,GACJ,UAAU,CAEkC;AAEzD;;;GAGG;AACH,4BAHW,UAAU,GACR,MAAM,CAEgC;AAhEnD,+BAA+B"}
@@ -0,0 +1,199 @@
export * from "./link/interface.js";
export function format<T extends API.Link<unknown, number, number, API.Version>, Prefix extends string>(link: T, base?: API.MultibaseEncoder<Prefix> | undefined): API.ToString<T, Prefix>;
export function toJSON<Link extends API.UnknownLink>(link: Link): API.LinkJSON<Link>;
export function fromJSON<Link extends API.UnknownLink>(json: API.LinkJSON<Link>): CID<unknown, number, number, API.Version>;
/**
* @template {unknown} [Data=unknown]
* @template {number} [Format=number]
* @template {number} [Alg=number]
* @template {API.Version} [Version=API.Version]
* @implements {API.Link<Data, Format, Alg, Version>}
*/
export class CID<Data extends unknown = unknown, Format extends number = number, Alg extends number = number, Version extends API.Version = API.Version> implements API.Link<Data, Format, Alg, Version> {
/**
* @template {unknown} Data
* @template {number} Format
* @template {number} Alg
* @template {API.Version} Version
* @param {API.Link<Data, Format, Alg, Version>} self
* @param {unknown} other
* @returns {other is CID}
*/
static equals<Data_1 extends unknown, Format_1 extends number, Alg_1 extends number, Version_1 extends API.Version>(self: API.Link<Data_1, Format_1, Alg_1, Version_1>, other: unknown): other is CID<any, number, number, API.Version>;
/**
* Takes any input `value` and returns a `CID` instance if it was
* a `CID` otherwise returns `null`. If `value` is instanceof `CID`
* it will return value back. If `value` is not instance of this CID
* class, but is compatible CID it will return new instance of this
* `CID` class. Otherwise returns null.
*
* This allows two different incompatible versions of CID library to
* co-exist and interop as long as binary interface is compatible.
*
* @template {unknown} Data
* @template {number} Format
* @template {number} Alg
* @template {API.Version} Version
* @template {unknown} U
* @param {API.Link<Data, Format, Alg, Version>|U} input
* @returns {CID<Data, Format, Alg, Version>|null}
*/
static asCID<Data_2 extends unknown, Format_2 extends number, Alg_2 extends number, Version_2 extends API.Version, U extends unknown>(input: U | API.Link<Data_2, Format_2, Alg_2, Version_2>): CID<Data_2, Format_2, Alg_2, Version_2> | null;
/**
*
* @template {unknown} Data
* @template {number} Format
* @template {number} Alg
* @template {API.Version} Version
* @param {Version} version - Version of the CID
* @param {Format} code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv
* @param {API.MultihashDigest<Alg>} digest - (Multi)hash of the of the content.
* @returns {CID<Data, Format, Alg, Version>}
*/
static create<Data_3 extends unknown, Format_3 extends number, Alg_3 extends number, Version_3 extends API.Version>(version: Version_3, code: Format_3, digest: API.MultihashDigest<Alg_3>): CID<Data_3, Format_3, Alg_3, Version_3>;
/**
* Simplified version of `create` for CIDv0.
*
* @template {unknown} [T=unknown]
* @param {API.MultihashDigest<typeof SHA_256_CODE>} digest - Multihash.
* @returns {CID<T, typeof DAG_PB_CODE, typeof SHA_256_CODE, 0>}
*/
static createV0<T extends unknown = unknown>(digest: API.MultihashDigest<typeof SHA_256_CODE>): CID<T, 112, 18, 0>;
/**
* Simplified version of `create` for CIDv1.
*
* @template {unknown} Data
* @template {number} Code
* @template {number} Alg
* @param {Code} code - Content encoding format code.
* @param {API.MultihashDigest<Alg>} digest - Miltihash of the content.
* @returns {CID<Data, Code, Alg, 1>}
*/
static createV1<Data_4 extends unknown, Code extends number, Alg_4 extends number>(code: Code, digest: API.MultihashDigest<Alg_4>): CID<Data_4, Code, Alg_4, 1>;
/**
* Decoded a CID from its binary representation. The byte array must contain
* only the CID with no additional bytes.
*
* An error will be thrown if the bytes provided do not contain a valid
* binary representation of a CID.
*
* @template {unknown} Data
* @template {number} Code
* @template {number} Alg
* @template {API.Version} Ver
* @param {API.ByteView<API.Link<Data, Code, Alg, Ver>>} bytes
* @returns {CID<Data, Code, Alg, Ver>}
*/
static decode<Data_5 extends unknown, Code_1 extends number, Alg_5 extends number, Ver extends API.Version>(bytes: API.ByteView<API.Link<Data_5, Code_1, Alg_5, Ver>>): CID<Data_5, Code_1, Alg_5, Ver>;
/**
* Decoded a CID from its binary representation at the beginning of a byte
* array.
*
* Returns an array with the first element containing the CID and the second
* element containing the remainder of the original byte array. The remainder
* will be a zero-length byte array if the provided bytes only contained a
* binary CID representation.
*
* @template {unknown} T
* @template {number} C
* @template {number} A
* @template {API.Version} V
* @param {API.ByteView<API.Link<T, C, A, V>>} bytes
* @returns {[CID<T, C, A, V>, Uint8Array]}
*/
static decodeFirst<T_1 extends unknown, C extends number, A extends number, V extends API.Version>(bytes: API.ByteView<API.Link<T_1, C, A, V>>): [CID<T_1, C, A, V>, Uint8Array];
/**
* Inspect the initial bytes of a CID to determine its properties.
*
* Involves decoding up to 4 varints. Typically this will require only 4 to 6
* bytes but for larger multicodec code values and larger multihash digest
* lengths these varints can be quite large. It is recommended that at least
* 10 bytes be made available in the `initialBytes` argument for a complete
* inspection.
*
* @template {unknown} T
* @template {number} C
* @template {number} A
* @template {API.Version} V
* @param {API.ByteView<API.Link<T, C, A, V>>} initialBytes
* @returns {{ version:V, codec:C, multihashCode:A, digestSize:number, multihashSize:number, size:number }}
*/
static inspectBytes<T_2 extends unknown, C_1 extends number, A_1 extends number, V_1 extends API.Version>(initialBytes: API.ByteView<API.Link<T_2, C_1, A_1, V_1>>): {
version: V_1;
codec: C_1;
multihashCode: A_1;
digestSize: number;
multihashSize: number;
size: number;
};
/**
* Takes cid in a string representation and creates an instance. If `base`
* decoder is not provided will use a default from the configuration. It will
* throw an error if encoding of the CID is not compatible with supplied (or
* a default decoder).
*
* @template {string} Prefix
* @template {unknown} Data
* @template {number} Code
* @template {number} Alg
* @template {API.Version} Ver
* @param {API.ToString<API.Link<Data, Code, Alg, Ver>, Prefix>} source
* @param {API.MultibaseDecoder<Prefix>} [base]
* @returns {CID<Data, Code, Alg, Ver>}
*/
static parse<Prefix extends string, Data_6 extends unknown, Code_2 extends number, Alg_6 extends number, Ver_1 extends API.Version>(source: API.ToString<API.Link<Data_6, Code_2, Alg_6, Ver_1>, Prefix>, base?: API.MultibaseDecoder<Prefix> | undefined): CID<Data_6, Code_2, Alg_6, Ver_1>;
/**
* @param {Version} version - Version of the CID
* @param {Format} code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv
* @param {API.MultihashDigest<Alg>} multihash - (Multi)hash of the of the content.
* @param {Uint8Array} bytes
*/
constructor(version: Version, code: Format, multihash: API.MultihashDigest<Alg>, bytes: Uint8Array);
/** @readonly */
readonly code: Format;
/** @readonly */
readonly version: Version;
/** @readonly */
readonly multihash: API.MultihashDigest<Alg>;
/** @readonly */
readonly bytes: Uint8Array;
/** @readonly */
readonly '/': Uint8Array;
/**
* Signalling `cid.asCID === cid` has been replaced with `cid['/'] === cid.bytes`
* please either use `CID.asCID(cid)` or switch to new signalling mechanism
*
* @deprecated
*/
get asCID(): this;
get byteOffset(): number;
get byteLength(): number;
/**
* @returns {CID<Data, API.DAG_PB, API.SHA_256, 0>}
*/
toV0(): CID<Data, API.DAG_PB, API.SHA_256, 0>;
/**
* @returns {CID<Data, Format, Alg, 1>}
*/
toV1(): CID<Data, Format, Alg, 1>;
/**
* @param {unknown} other
* @returns {other is CID<Data, Format, Alg, Version>}
*/
equals(other: unknown): other is CID<Data, Format, Alg, Version>;
/**
* @param {API.MultibaseEncoder<string>} [base]
* @returns {string}
*/
toString(base?: API.MultibaseEncoder<string> | undefined): string;
/**
* @returns {API.LinkJSON<this>}
*/
toJSON(): API.LinkJSON<this>;
link(): this;
get [Symbol.toStringTag](): string;
}
import * as API from "./link/interface.js";
declare const SHA_256_CODE: 18;
declare const DAG_PB_CODE: 112;
//# sourceMappingURL=cid.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"cid.d.ts","sourceRoot":"","sources":["../../../src/cid.js"],"names":[],"mappings":";AAmBO,2LAgBN;AAOM,qFAEL;AAMK,4HACe;AAmBtB;;;;;;GAMG;AAEH,oKAHgB,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO;IA+GjD;;;;;;;;OAQG;IACH,+KAHW,OAAO,kDAcjB;IA+BD;;;;;;;;;;;;;;;;;OAiBG;IACH,+OAoCC;IAED;;;;;;;;;;OAUG;IACH,qOA2BC;IAED;;;;;;OAMG;IACH,qDAHW,IAAI,eAAe,CAAC,mBAAmB,CAAC,sBAKlD;IAED;;;;;;;;;OASG;IACH,gKAEC;IAED;;;;;;;;;;;;;OAaG;IACH,wMAMC;IAED;;;;;;;;;;;;;;;OAeG;IACH,iLAuBC;IAED;;;;;;;;;;;;;;;OAeG;IACH;;;;oBAF+D,MAAM;uBAAgB,MAAM;cAAO,MAAM;MA+BvG;IAED;;;;;;;;;;;;;;OAcG;IACH,8RAaC;IAjaD;;;;;OAKG;IACH,qBALW,OAAO,QACP,MAAM,aACN,IAAI,eAAe,CAAC,GAAG,CAAC,SACxB,UAAU,EAgBpB;IAbC,gBAAgB;IAChB,sBAAgB;IAChB,gBAAgB;IAChB,0BAAsB;IACtB,gBAAgB;IAChB,6CAA0B;IAC1B,gBAAgB;IAChB,2BAAkB;IAIlB,gBAAgB;IAChB,yBAAiB;IAGnB;;;;;OAKG;IACH,kBAEC;IAGD,yBAEC;IAGD,yBAEC;IAED;;OAEG;IACH,QAFa,IAAI,IAAI,EAAE,IAAI,MAAM,EAAE,IAAI,OAAO,EAAE,CAAC,CAAC,CA+BjD;IAED;;OAEG;IACH,QAFa,IAAI,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAoBrC;IAED;;;OAGG;IACH,cAHW,OAAO,4CAKjB;IAwBD;;;OAGG;IACH,2DAFa,MAAM,CAIlB;IAED;;OAEG;IACH,UAFa,IAAI,QAAQ,CAAC,IAAI,CAAC,CAI9B;IAED,aAEC;IAED,mCAEC;CA4QF;qBA3eoB,qBAAqB;AA6jB1C,+BAAyB;AADzB,+BAAwB"}
@@ -0,0 +1,23 @@
import type { ByteView } from '../block/interface.js';
/**
* IPLD encoder part of the codec.
*/
export interface BlockEncoder<Code extends number, T> {
name: string;
code: Code;
encode(data: T): ByteView<T>;
}
/**
* IPLD decoder part of the codec.
*/
export interface BlockDecoder<Code extends number, T> {
code: Code;
decode(bytes: ByteView<T>): T;
}
/**
* An IPLD codec is a combination of both encoder and decoder.
*/
export interface BlockCodec<Code extends number, T> extends BlockEncoder<Code, T>, BlockDecoder<Code, T> {
}
export type { ByteView };
//# sourceMappingURL=interface.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../../src/codecs/interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAErD;;GAEG;AACH,MAAM,WAAW,YAAY,CAAC,IAAI,SAAS,MAAM,EAAE,CAAC;IAClD,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,IAAI,CAAA;IACV,MAAM,CAAC,IAAI,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAA;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,YAAY,CAAC,IAAI,SAAS,MAAM,EAAE,CAAC;IAClD,IAAI,EAAE,IAAI,CAAA;IACV,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,UAAU,CAAC,IAAI,SAAS,MAAM,EAAE,CAAC,CAAE,SAAQ,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC;CAAG;AAE3G,YAAY,EAAE,QAAQ,EAAE,CAAA"}
@@ -0,0 +1,6 @@
export const name: "json";
export const code: 512;
export function encode<T>(node: T): import("./interface.js").ByteView<T>;
export function decode<T>(data: import("./interface.js").ByteView<T>): T;
export type ByteView<T> = import('./interface.js').ByteView<T>;
//# sourceMappingURL=json.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../../../src/codecs/json.js"],"names":[],"mappings":"AAUA,0BAA0B;AAC1B,uBAA0B;AAOnB,yEAAiE;AAOjE,yEAA6D;0BArBvD,OAAO,gBAAgB,EAAE,QAAQ,CAAC,CAAC,CAAC"}
@@ -0,0 +1,10 @@
/**
* @template T
* @typedef {import('./interface.js').ByteView<T>} ByteView
*/
export const name: "raw";
export const code: 85;
export function encode(node: Uint8Array): ByteView<Uint8Array>;
export function decode(data: ByteView<Uint8Array>): Uint8Array;
export type ByteView<T> = import('./interface.js').ByteView<T>;
//# sourceMappingURL=raw.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"raw.d.ts","sourceRoot":"","sources":["../../../../src/codecs/raw.js"],"names":[],"mappings":"AAIA;;;GAGG;AAEH,yBAAyB;AACzB,sBAAwB;AAMjB,6BAHI,UAAU,GACR,SAAS,UAAU,CAAC,CAEW;AAMrC,6BAHI,SAAS,UAAU,CAAC,GAClB,UAAU,CAEqB;0BAhB/B,OAAO,gBAAgB,EAAE,QAAQ,CAAC,CAAC,CAAC"}
@@ -0,0 +1,32 @@
export function create<Code extends number>(code: Code, digest: Uint8Array): Digest<Code, number>;
export function decode(multihash: Uint8Array): MultihashDigest;
export function equals(a: MultihashDigest, b: unknown): b is import("./interface.js").MultihashDigest<number>;
/**
* @typedef {import('./interface.js').MultihashDigest} MultihashDigest
*/
/**
* Represents a multihash digest which carries information about the
* hashing algorithm and an actual hash digest.
*
* @template {number} Code
* @template {number} Size
* @class
* @implements {MultihashDigest}
*/
export class Digest<Code extends number, Size extends number> implements MultihashDigest {
/**
* Creates a multihash digest.
*
* @param {Code} code
* @param {Size} size
* @param {Uint8Array} digest
* @param {Uint8Array} bytes
*/
constructor(code: Code, size: Size, digest: Uint8Array, bytes: Uint8Array);
code: Code;
size: Size;
digest: Uint8Array;
bytes: Uint8Array;
}
export type MultihashDigest = import('./interface.js').MultihashDigest;
//# sourceMappingURL=digest.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"digest.d.ts","sourceRoot":"","sources":["../../../../src/hashes/digest.js"],"names":[],"mappings":"AAUO,gEAFI,UAAU,wBAapB;AAQM,kCAHI,UAAU,GACR,eAAe,CAa3B;AAOM,0BAJI,eAAe,KACf,OAAO,yDAgBjB;AAED;;GAEG;AAEH;;;;;;;;GAQG;AACH;IACE;;;;;;;OAOG;IACH,kBALW,IAAI,QACJ,IAAI,UACJ,UAAU,SACV,UAAU,EAOpB;IAJC,WAAgB;IAChB,WAAgB;IAChB,mBAAoB;IACpB,kBAAkB;CAErB;8BA3BY,OAAO,gBAAgB,EAAE,eAAe"}
@@ -0,0 +1,35 @@
export function from<Name extends string, Code extends number>({ name, code, encode }: {
name: Name;
code: Code;
encode: (input: Uint8Array) => Await<Uint8Array>;
}): Hasher<Name, Code>;
/**
* Hasher represents a hashing algorithm implementation that produces as
* `MultihashDigest`.
*
* @template {string} Name
* @template {number} Code
* @class
* @implements {MultihashHasher<Code>}
*/
export class Hasher<Name extends string, Code extends number> implements MultihashHasher<Code> {
/**
*
* @param {Name} name
* @param {Code} code
* @param {(input: Uint8Array) => Await<Uint8Array>} encode
*/
constructor(name: Name, code: Code, encode: (input: Uint8Array) => Await<Uint8Array>);
name: Name;
code: Code;
encode: (input: Uint8Array) => Await<Uint8Array>;
/**
* @param {Uint8Array} input
* @returns {Await<Digest.Digest<Code, number>>}
*/
digest(input: Uint8Array): Await<Digest.Digest<Code, number>>;
}
export type MultihashHasher<Alg extends number> = import('./interface.js').MultihashHasher;
export type Await<T> = Promise<T> | T;
import * as Digest from './digest.js';
//# sourceMappingURL=hasher.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"hasher.d.ts","sourceRoot":"","sources":["../../../../src/hashes/hasher.js"],"names":[],"mappings":"AAUO;;;oBAFY,UAAU,KAAK,MAAM,UAAU,CAAC;uBAE2B;AAE9E;;;;;;;;GAQG;AACH,yFAFgC,IAAI;IAGlC;;;;;OAKG;IACH,kBAJW,IAAI,QACJ,IAAI,kBACI,UAAU,KAAK,MAAM,UAAU,CAAC,EAMlD;IAHC,WAAgB;IAChB,WAAgB;IAChB,gBALiB,UAAU,KAAK,MAAM,UAAU,CAAC,CAK7B;IAGtB;;;OAGG;IACH,cAHW,UAAU,GACR,MAAM,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAa9C;CACF;kDAIY,OAAO,gBAAgB,EAAE,eAAe;uBAKxC,QAAQ,CAAC,CAAC,GAAC,CAAC;wBA3DD,aAAa"}
@@ -0,0 +1,18 @@
export namespace identity {
export { code };
export { name };
export { encode };
export { digest };
}
declare const code: 0;
declare const name: "identity";
/** @type {(input:Uint8Array) => Uint8Array} */
declare const encode: (input: Uint8Array) => Uint8Array;
/**
* @param {Uint8Array} input
* @returns {Digest.Digest<typeof code, number>}
*/
declare function digest(input: Uint8Array): Digest.Digest<typeof code, number>;
import * as Digest from './digest.js';
export {};
//# sourceMappingURL=identity.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../../../src/hashes/identity.js"],"names":[],"mappings":";;;;;;AAGA,sBAAgB;AAChB,+BAAuB;AAEvB,+CAA+C;AAC/C,8BADkB,UAAU,KAAK,UAAU,CACtB;AAErB;;;GAGG;AACH,+BAHW,UAAU,GACR,aAAa,CAAC,WAAW,EAAE,MAAM,CAAC,CAEa;wBAZpC,aAAa"}
@@ -0,0 +1,59 @@
/**
* Represents a multihash digest which carries information about the
* hashing algorithm and an actual hash digest.
*/
export interface MultihashDigest<Code extends number = number> {
/**
* Code of the multihash
*/
code: Code;
/**
* Raw digest (without a hashing algorithm info)
*/
digest: Uint8Array;
/**
* byte length of the `this.digest`
*/
size: number;
/**
* Binary representation of this multihash digest.
*/
bytes: Uint8Array;
}
/**
* Hasher represents a hashing algorithm implementation that produces as
* `MultihashDigest`.
*/
export interface MultihashHasher<Code extends number = number> {
/**
* Takes binary `input` and returns it (multi) hash digest. Return value is
* either promise of a digest or a digest. This way general use can `await`
* while performance critical code may asses return value to decide whether
* await is needed.
*
* @param {Uint8Array} input
*/
digest(input: Uint8Array): Promise<MultihashDigest<Code>> | MultihashDigest<Code>;
/**
* Name of the multihash
*/
name: string;
/**
* Code of the multihash
*/
code: Code;
}
/**
* Sync variant of `MultihashHasher` that refines return type of the `digest`
* to `MultihashDigest`. It is subtype of `MultihashHasher` so implementations
* of this interface can be passed anywhere `MultihashHasher` is expected,
* allowing consumer to either `await` or check the return type to decide
* whether to await or proceed with return value.
*
* `SyncMultihashHasher` is useful in certain APIs where async hashing would be
* impractical e.g. implementation of Hash Array Mapped Trie (HAMT).
*/
export interface SyncMultihashHasher<Code extends number = number> extends MultihashHasher<Code> {
digest(input: Uint8Array): MultihashDigest<Code>;
}
//# sourceMappingURL=interface.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../../src/hashes/interface.ts"],"names":[],"mappings":"AAEA;;;GAGG;AAMH,MAAM,WAAW,eAAe,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM;IAC3D;;OAEG;IACH,IAAI,EAAE,IAAI,CAAA;IAEV;;OAEG;IACH,MAAM,EAAE,UAAU,CAAA;IAElB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IAEZ;;OAEG;IACH,KAAK,EAAE,UAAU,CAAA;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM;IAC3D;;;;;;;OAOG;IACH,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,GAAG,eAAe,CAAC,IAAI,CAAC,CAAA;IAEjF;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IAEZ;;OAEG;IACH,IAAI,EAAE,IAAI,CAAA;CACX;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,mBAAmB,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM,CAAE,SAAQ,eAAe,CAAC,IAAI,CAAC;IAC9F,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,eAAe,CAAC,IAAI,CAAC,CAAA;CACjD"}
@@ -0,0 +1,2 @@
export const sha1: import("./hasher.js").Hasher<"sha-1", 17>;
//# sourceMappingURL=sha1-browser.d.ts.map

Some files were not shown because too many files have changed in this diff Show More