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
+33
View File
@@ -0,0 +1,33 @@
import { createHash, randomBytes as rand } from 'node:crypto'
const decoder = new TextDecoder()
export const arr2text = (data, enc) => {
if (data.byteLength > 1024) {
if (!enc) return decoder.decode(data)
const dec = new TextDecoder(enc)
return dec.decode(data)
}
return Buffer.from(data).toString(enc || 'utf8')
}
export const text2arr = str => new Uint8Array(Buffer.from(str, 'utf8'))
export const arr2base = data => Buffer.from(data).toString('base64')
export const base2arr = str => new Uint8Array(Buffer.from(str, 'base64'))
export const hex2bin = hex => Buffer.from(hex, 'hex').toString('binary')
export const bin2hex = bin => Buffer.from(bin, 'binary').toString('hex')
export const hash = async (data, format, algo = 'sha1') => {
algo = algo.replace('sha-', 'sha')
const out = createHash(algo).update(data)
return format ? out.digest(format) : new Uint8Array(out.digest().buffer)
}
export const randomBytes = size => {
return new Uint8Array(rand(size))
}
export * from './util.js'
+68
View File
@@ -0,0 +1,68 @@
import { arr2hex, hex2arr, alphabet } from './util.js'
import { decode, encode } from 'base64-arraybuffer'
const decoder = new TextDecoder()
// 50% slower at < 48 chars, but little impact at 4M OPS/s vs 8M OPS/s
export const arr2text = (data, enc) => {
if (!enc) return decoder.decode(data)
const dec = new TextDecoder(enc)
return dec.decode(data)
}
// sacrifice ~20% speed for bundle size
const encoder = new TextEncoder()
export const text2arr = str => encoder.encode(str)
export const arr2base = data => encode(data)
export const base2arr = str => new Uint8Array(decode(str))
export const bin2hex = str => {
let res = ''
let c
let i = 0
const len = str.length
while (i < len) {
c = str.charCodeAt(i++)
res += alphabet[c >> 4] + alphabet[c & 0xF]
}
return res
}
const MAX_ARGUMENTS_LENGTH = 0x10000
export const hex2bin = hex => {
const points = hex2arr(hex)
if (points.length <= MAX_ARGUMENTS_LENGTH) return String.fromCharCode(...points)
let res = ''
let i = 0
while (i < points.length) {
res += String.fromCharCode(...points.subarray(i, i += MAX_ARGUMENTS_LENGTH))
}
return res
}
const scope = typeof window !== 'undefined' ? window : self
const crypto = scope.crypto || scope.msCrypto || {}
const subtle = crypto.subtle || crypto.webkitSubtle
const formatMap = {
hex: arr2hex,
base64: arr2base
}
export const hash = async (data, format, algo = 'sha-1') => {
if (!subtle) throw new Error('no web crypto support')
if (typeof data === 'string') data = text2arr(data)
const out = new Uint8Array(await subtle.digest(algo, data))
return format ? formatMap[format](out) : out
}
export const randomBytes = size => {
const view = new Uint8Array(size)
return crypto.getRandomValues(view)
}
export * from './util.js'
+61
View File
@@ -0,0 +1,61 @@
type TypedArray =
| Int8Array
| Uint8Array
| Uint8ClampedArray
| Int16Array
| Uint16Array
| Int32Array
| Uint32Array
| Float32Array
| Float64Array
| BigInt64Array
| BigUint64Array
type Encoding =
| 'utf-8'
| 'utf-16le'
| 'latin-1'
| 'ascii'
type HashType =
| 'hex'
| 'base64'
type HashAlgo =
| 'sha-1'
| 'sha-256'
| 'sha-384'
| 'sha-512'
type Uint8 = Uint8Array | Array<number>
type Hex = string
type Base64 = string
export function concat (chunks: (TypedArray | Array<number>)[], size?: number): Uint8Array
export function equal (a: Uint8, b: Uint8): boolean
export function arr2hex (data: Uint8): Hex
export function hex2arr (str: Hex): Uint8Array
export function arr2text (data: ArrayBuffer | Uint8Array, enc?: Encoding): string
export function arr2base (data: Uint8): Base64
export function base2arr (str: Base64): Uint8Array
export function text2arr (str: string): Uint8Array
export function hex2bin (str: Hex): string
export function bin2hex (str: string): Hex
export function hash (data: string | TypedArray | ArrayBuffer | DataView, format?: undefined, algo?: HashAlgo): Promise<Uint8Array>
export function hash (data: string | TypedArray | ArrayBuffer | DataView, format: HashType, algo?: HashAlgo): Promise<Hex | Base64>
export function hash (data: string | TypedArray | ArrayBuffer | DataView, format?: HashType, algo?: HashAlgo): Promise<Uint8Array | Hex | Base64>
export function randomBytes (size: number): Uint8Array
+79
View File
@@ -0,0 +1,79 @@
{
"name": "uint8-util",
"version": "2.2.6",
"description": "Fastest possible buffer-like utilities for uint8.",
"main": "index.js",
"browser": "browser.js",
"chromeapp": "browser.js",
"type": "module",
"exports": {
"node": {
"types": "./index.d.ts",
"import": "./_node.js"
},
"browser": {
"types": "./index.d.ts",
"import": "./browser.js"
},
"chromeapp": {
"types": "./index.d.ts",
"import": "./browser.js"
},
"default": {
"types": "./index.d.ts",
"import": "./browser.js"
}
},
"types": "./index.d.ts",
"repository": {
"type": "git",
"url": "git+https://github.com/ThaUnknown/uint8-util.git"
},
"files": [
"_node.js",
"browser.js",
"util.js",
"index.d.ts"
],
"keywords": [
"uint8",
"buffer",
"sha1",
"crypto",
"hex",
"tohex",
"tostring"
],
"author": "ThaUnknown",
"license": "MIT",
"bugs": {
"url": "https://github.com/ThaUnknown/uint8-util/issues"
},
"homepage": "https://github.com/ThaUnknown/uint8-util#readme",
"devDependencies": {
"@babel/core": "^7.20.5",
"@babel/preset-env": "^7.20.2",
"@babel/plugin-syntax-import-assertions": "^7.20.0",
"airtap": "^4.0.4",
"airtap-manual": "^1.0.0",
"babelify": "^10.0.0",
"benchmark": "^2.1.4"
},
"dependencies": {
"base64-arraybuffer": "^1.0.2"
},
"scripts": {
"bench-node-bin2hex": "node benchmark/bin2hex.js",
"bench-node-hex2bin": "node benchmark/hex2bin.js",
"bench-node-2text": "node benchmark/arr2text.js",
"bench-node-2arr": "node benchmark/text2arr.js",
"bench-node-hex2arr": "node benchmark/hex2arr.js",
"bench-browser-hex2arr": "airtap --preset local -- benchmark/hex2arr.js",
"bench-browser-bin2hex": "airtap --preset local -- benchmark/bin2hex.js",
"bench-browser-hex2bin": "airtap --preset local -- benchmark/hex2bin.js",
"bench-browser-2text": "airtap --preset local -- benchmark/arr2text.js",
"bench-browser-2arr": "airtap --preset local -- benchmark/text2arr.js",
"bench-browser-2base": "airtap --preset local -- benchmark/arr2base.js",
"bench-browser-4base": "airtap --preset local -- benchmark/base2arr.js"
}
}
+32
View File
@@ -0,0 +1,32 @@
# Uint8 Utilities
This libraries brings features from Node's `Buffer` to JS's Uint8Arrays and in some cases other Typed Arrays, in the fastest ways possible, often faster than Node's own `Buffer`'s methods.
# Usage
```js
import { arr2text, text2arr, arr2hex, hex2arr, arr2base, base2arr } from 'uint8-util'
const str = arr2text(new Uint8Array([1, 2, 3]))
const uint8 = text2arr('uflnpq')
const hexString = arr2hex(new Uint8Array([1, 2, 3]))
const uint8 = hex2arr('abc')
const base64String = arr2base(new Uint8Array([89, 87, 74, 106, 77, 84, 73]))
const uint8 = base2arr('YWJjMTI')
import { concat, equal, hash, randomBytes } from 'uint8-util'
const joined = concat([[1,2,3], new Uint8Array([1, 2, 3])])
const same = equal([1,2,3], [1,2,3])
const hash = await hash('mystring')
const hash = await hash(new Uint8Array([1, 2, 3]))
const rand = arr2hex(randomBytes(128))
+66
View File
@@ -0,0 +1,66 @@
/* Common package for dealing with hex/string/uint8 conversions (and sha1 hashing)
*
* @author Jimmy Wärting <jimmy@warting.se> (https://jimmy.warting.se/opensource)
* @license MIT
*/
export const alphabet = '0123456789abcdef'
const encodeLookup = []
const decodeLookup = []
for (let i = 0; i < 256; i++) {
encodeLookup[i] = alphabet[i >> 4 & 0xf] + alphabet[i & 0xf]
if (i < 16) {
if (i < 10) {
decodeLookup[0x30 + i] = i
} else {
decodeLookup[0x61 - 10 + i] = i
}
}
}
export const arr2hex = data => {
const length = data.length
let string = ''
let i = 0
while (i < length) {
string += encodeLookup[data[i++]]
}
return string
}
export const hex2arr = str => {
const sizeof = str.length >> 1
const length = sizeof << 1
const array = new Uint8Array(sizeof)
let n = 0
let i = 0
while (i < length) {
array[n++] = decodeLookup[str.charCodeAt(i++)] << 4 | decodeLookup[str.charCodeAt(i++)]
}
return array
}
export const concat = (chunks, size = 0) => {
const length = chunks.length || 0
if (!size) {
let i = length
while (i--) size += chunks[i].length
}
const b = new Uint8Array(size)
let offset = size
let i = length
while (i--) {
offset -= chunks[i].length
b.set(chunks[i], offset)
}
return b
}
export const equal = (a, b) => {
if (a.length !== b.length) return false
for (let i = a.length; i > -1; i -= 1) {
if ((a[i] !== b[i])) return false
}
return true
}