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
+26
View File
@@ -0,0 +1,26 @@
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: number = 0): Uint8Array {
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: number = 0): Uint8Array {
if (globalThis.Buffer?.allocUnsafe != null) {
return asUint8Array(globalThis.Buffer.allocUnsafe(size))
}
return new Uint8Array(size)
}
+28
View File
@@ -0,0 +1,28 @@
/**
* Can be used with Array.sort to sort and array with Uint8Array entries
*/
export function compare (a: Uint8Array, b: Uint8Array): number {
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
}
+21
View File
@@ -0,0 +1,21 @@
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: Array<ArrayLike<number>>, length?: number): Uint8Array {
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)
}
+20
View File
@@ -0,0 +1,20 @@
/**
* Returns true if the two passed Uint8Arrays have the same content
*/
export function equals (a: Uint8Array, b: Uint8Array): boolean {
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
}
+26
View File
@@ -0,0 +1,26 @@
import { asUint8Array } from './util/as-uint8array.js'
import bases, { 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 function fromString (string: string, encoding: SupportedEncodings = 'utf8'): Uint8Array {
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
}
+162
View File
@@ -0,0 +1,162 @@
/**
* @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'
+25
View File
@@ -0,0 +1,25 @@
import bases, { 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 function toString (array: Uint8Array, encoding: SupportedEncodings = 'utf8'): string {
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)
}
+11
View File
@@ -0,0 +1,11 @@
/**
* To guarantee Uint8Array semantics, convert nodejs Buffers
* into vanilla Uint8Arrays
*/
export function asUint8Array (buf: Uint8Array): Uint8Array {
if (globalThis.Buffer != null) {
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength)
}
return buf
}
+59
View File
@@ -0,0 +1,59 @@
import { bases } from 'multiformats/basics'
import { allocUnsafe } from '../alloc.js'
import type { MultibaseCodec } from 'multiformats'
function createCodec (name: string, prefix: string, encode: (buf: Uint8Array) => string, decode: (str: string) => Uint8Array): MultibaseCodec<any> {
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
})
export type SupportedEncodings = 'utf8' | 'utf-8' | 'hex' | 'latin1' | 'ascii' | 'binary' | keyof typeof bases
const BASES: Record<SupportedEncodings, MultibaseCodec<any>> = {
utf8: string,
'utf-8': string,
hex: bases.base16,
latin1: ascii,
ascii,
binary: ascii,
...bases
}
export default BASES
+19
View File
@@ -0,0 +1,19 @@
import { allocUnsafe } from './alloc.js'
import { asUint8Array } from './util/as-uint8array.js'
/**
* Returns the xor distance between two arrays
*/
export function xor (a: Uint8Array, b: Uint8Array): Uint8Array {
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)
}