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

21
apps/web5-dwn/node_modules/micro-packed/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2022 Paul Miller (https://paulmillr.com)
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.

289
apps/web5-dwn/node_modules/micro-packed/README.md generated vendored Normal file
View File

@@ -0,0 +1,289 @@
# micro-packed
> Less painful binary encoding / decoding
Define complex binary structures using composable primitives.
Comes with a friendly debugger.
## Usage
> npm install micro-packed
```ts
import * as P from 'micro-packed';
let other = P.struct({ a: U16BE, b: U16LE });
let s = P.struct({
field1: P.U32BE,
// strings, bytes, prefix and array first arg is length. It can be:
// - dynamic: via CoderType<number>. First U8 in this case if length of elemnt
field2: P.string(P.U8),
// - fixed length, reads 32 bytes, no prefix
field3: P.bytes(32),
// NOTE: array uses prefix as element count, not byte count!
field4: P.array(P.U16BE, P.struct({subField1: P.U64BE, subField2: P.string(10) }))
// - string to access previous fields in structure
field5: P.array('field1', P.U8), // Array of size 'field1' of U8
// Use sub-structure
field6: other,
field7: P.string(null),
// - null -- read until buffer exhausted
field8: P.array(null, P.U64BE),
});
```
## Debugger
```ts
import * as PD from 'micro-packed/debugger';
PD.decode(<coder>, data);
PD.diff(<coder>, actual, expected);
```
![Decode](./test/screens/decode.png)
![Diff](./test/screens/diff.png)
## Utils
- [Array](#array)
- [Bytes](#bytes)
- [String](#string)
- [Tuple](#tuple)
- [Map](#map)
- [Tag](#tag)
- [Magic](#magic)
- [Bits](#bits)
- [Pointer](#pointer)
- [Padding](#padding)
- [Flag](#flag)
- [Flagged](#flagged)
- [Optional](#optional)
- [Lazy](#lazy)
- [Dict](#dict)
- [Validate](#validate)
- [Debug](#debug)
- [Primitive types](#primitive-types)
### Array
Probably most powerful building block
```ts
import * as P from 'micro-packed';
let a1 = P.array(P.U16BE, child); // Dynamic size array (prefixed with P.U16BE number of array length)
let a2 = P.array(4, child); // Fixed size array
let a3 = P.array(null, child); // Unknown size array, will parse until end of buffer
let a4 = P.array(new Uint8Array([0]), child); // zero-terminated array (NOTE: terminator can be any buffer)
```
### Bytes
Same as array of bytes, should be a bit faster than generic implementation, also returns Uint8Array,
instead of array of ints
```ts
import * as P from 'micro-packed';
// same as
let bytes = (len) => P.array(len, P.U8);
const b1 = bytes(P.U16BE);
const b2 = bytes(P.U16BE, true); // bytes in little-endian order
```
### String
Same as bytes, but returns utf8 decoded string
```ts
import * as P from 'micro-packed';
const s = P.string(P.U16BE);
s.decode(new Uint8Array([116, 101, 115, 116])); // -> test
const s2 = P.cstring; // NUL-terminated strings
s.decode(new Uint8Array([116, 101, 115, 116, 0])); // -> test
```
### Tuple
Same as struct, but without fields names
```ts
import * as P from 'micro-packed';
let s = P.tuple([P.U32BE, P.U8, P.bytes(32), ...])
```
### Map
Like enum in C (but without iota).
Allows to map encoded values to string
```ts
import * as P from 'micro-packed';
let s = P.map(P.U8, {
name1: 1,
name2: 2,
});
s.decode(new Uint8Array([0x01])); // 'name1'
s.decode(new Uint8Array([0x02])); // 'name2'
s.decode(new Uint8Array([0x00])); // Error!
```
### Tag
Like enum in Rust.
Allows to choice stucture based on some value.
Depending on value of first byte, it will be decoded as array, string or number.
```ts
import * as P from 'micro-packed';
let s = P.tag(P.U8, {
0x1: P.array(u16, ...),
0x2: P.string(u16, ...),
0x3: P.U32BE,
})
```
### Magic
Encodes some constant value into bytes and checks if it is the same on decoding.
```ts
import * as P from 'micro-packed';
let s = P.magic(U8, 123);
s.encode(); // Uint8Array([123])
s.decode(new Uint8Array([123])); // ok
s.decode(new Uint8Array([124])); // error!
```
### Bits
Allows to parse bit-level elements:
```ts
import * as P from 'micro-packed';
// NOTE: structure should parse whole amount of bytes before it can start parsing byte-level elements.
let s = P.struct({ magic: P.bits(1), version: P.bits(1), tag: P.bits(4), len: P.bits(2) });
```
### Pointer
Encodes element as offset into real bytes
```ts
import * as P from 'micro-packed';
const s = P.pointer(P.U8, P.U8);
s.encode(123); // new Uint8Array([1, 123]), first byte is offset position of real value
```
### Padding
Allows to pad value with zero bytes. Optional argument allows to generate padding value based on position.
```ts
import * as P from 'micro-packed';
P.padLeft(3, U8).encode(123); // Uint8Array([0, 0, 123])
P.padRight(3, U8).encode(123); // Uint8Array([123, 0, 0])
```
### Flag
Decodes as true if the value is the same.
```ts
import * as P from 'micro-packed';
const s = P.flag(new Uint8Array([1, 2, 3]));
```
### Flagged
Decodes / encodes struct only when flag/bool value (described as path in structure) is true (conditional encoding).
```ts
import * as P from 'micro-packed';
const s = P.struct({ f: P.flag(new Uint8Array([0x0, 0x1])), f2: P.flagged('f', P.U32BE) });
```
### Optional
Decodes/encodes value only if prefixed flag is true (or encodes default value).
```ts
import * as P from 'micro-packed';
const s = P.optional(P.bool, P.U32BE, 123);
```
### Lazy
Allows definition of circular structures
```ts
import * as P from 'micro-packed';
type Tree = { name: string; childs: Tree[] };
const tree = P.struct({
name: P.cstring,
childs: P.array(
P.U16BE,
P.lazy((): P.CoderType<Tree> => tree)
),
});
```
### Dict
Converts array (key, value) tuples to dict/object/hashmap:
```ts
import * as P from 'micro-packed';
const dict: P.CoderType<Record<string, number>> = P.apply(
P.array(P.U16BE, P.tuple([P.cstring, P.U32LE] as const)),
P.coders.dict()
);
```
### Validate
Validation of value before encoding and after decoding:
```ts
import * as P from 'micro-packed';
const val = (n: number) => {
if (n > 10) throw new Error(`${n} > 10`);
return n;
};
const RangedInt = P.validate(P.U32LE, val); // will check in both encoding and decoding
```
### Debug
Easy debug (via console.log), just wrap specific coder for it:
```ts
import * as P from 'micro-packed';
const debugInt = P.debug(P.U32LE); // Will print info to console
```
### Primitive types
There is: bool, U8, U[16|32|64|128|256][le|be]
Other numeric types can be created via
```ts
import * as P from 'micro-packed';
const U32LE = P.int(4, true); // up to 6 bytes (48 bits)
const I256LE = P.bigint(32, true, true); // no limits
```
## License
MIT (c) Paul Miller [(https://paulmillr.com)](https://paulmillr.com), see LICENSE file.

270
apps/web5-dwn/node_modules/micro-packed/debugger.ts generated vendored Normal file
View File

@@ -0,0 +1,270 @@
import { base64, hex } from '@scure/base';
import * as P from './index.js';
const UNKNOWN = '(???)';
const bold = '\x1b[1m';
const gray = '\x1b[90m';
const reset = '\x1b[0m';
const red = '\x1b[31m';
const green = '\x1b[32m';
const yellow = '\x1b[33m';
type DebugPath = { start: number; end?: number; path: string; value?: any };
class DebugReader extends P.Reader {
debugLst: DebugPath[] = [];
cur?: DebugPath;
get lastElm() {
if (this.debugLst.length) return this.debugLst[this.debugLst.length - 1];
return { start: 0, end: 0, path: '' };
}
fieldPathPush(s: string) {
const last = this.lastElm;
if (last.end === undefined) last.end = this.pos;
else if (last.end !== this.pos) {
this.debugLst.push({
path: [...this.fieldPath, UNKNOWN].join('/'),
start: last.end,
end: this.pos,
});
}
this.cur = { path: [...this.fieldPath, s].join('/'), start: this.pos };
super.fieldPathPush(s);
}
fieldPathPop() {
// happens if pop after pop (exit from nested structure)
if (!this.cur) {
const last = this.lastElm;
if (last.end === undefined) last.end = this.pos;
else if (last.end !== this.pos) {
this.debugLst.push({ start: last.end, end: this.pos, path: last.path + `/${UNKNOWN}` });
}
} else {
this.cur.end = this.pos;
const lastItem = this.path[this.path.length - 1];
const lastField = this.fieldPath[this.fieldPath.length - 1];
if (lastItem && lastField !== undefined) this.cur.value = lastItem[lastField];
this.debugLst.push(this.cur);
this.cur = undefined;
}
super.fieldPathPop();
}
finishDebug(): void {
const end = this.data.length;
if (this.cur) this.debugLst.push({ end, ...this.cur });
const last = this.lastElm;
if (!last || last.end !== end) this.debugLst.push({ start: this.pos, end, path: UNKNOWN });
}
}
function toBytes(data: string | P.Bytes): P.Bytes {
if (P.isBytes(data)) return data;
if (typeof data !== 'string') throw new Error('PD: data should be string or Uint8Array');
try {
return base64.decode(data);
} catch (e) {}
try {
return hex.decode(data);
} catch (e) {}
throw new Error(`PD: data has unknown string format: ${data}`);
}
type DebugData = { path: string; data: P.Bytes; value?: any };
function mapData(lst: DebugPath[], data: P.Bytes): DebugData[] {
let end = 0;
const res: DebugData[] = [];
for (const elm of lst) {
if (elm.start !== end) throw new Error(`PD: elm start=${elm.start} after prev elm end=${end}`);
if (elm.end === undefined) throw new Error(`PD: elm.end is undefined=${elm}`);
res.push({ path: elm.path, data: data.slice(elm.start, elm.end), value: elm.value });
end = elm.end;
}
if (end !== data.length) throw new Error('PD: not all data mapped');
return res;
}
function chrWidth(s: string) {
/*
It is almost impossible to find out real characters width in terminal since it depends on terminal itself, current unicode version and moon's phase.
So, we just stripping ANSI, tabs and unicode supplimental characters. Emoji support requires big tables (and have no guarantee to work), so we ignore it for now.
Also, no support for full width unicode characters for now.
*/
return s
.replace(
/[\u001B\u009B][[\]()#;?]*(?:(?:(?:[a-zA-Z\d]*(?:;[-a-zA-Z\d\/#&.:=?%@~_]*)*)?\u0007)|(?:(?:\d{1,4}(?:;\d{0,4})*)?[\dA-PR-TZcf-ntqry=><~]))/g,
''
)
.replace('\t', ' ')
.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, ' ').length;
}
function wrap(s: string, padding: number = 0) {
// @ts-ignore
const limit = process.stdout.columns - 3 - padding;
if (chrWidth(s) <= limit) return s;
while (chrWidth(s) > limit) s = s.slice(0, -1);
return `${s}${reset}...`;
}
export function table(data: any[]) {
let res: string[] = [];
const str = (v: any) => (v === undefined ? '' : '' + v);
const pad = (s: string, width: number) =>
`${s}${''.padEnd(Math.max(0, width - chrWidth(s)), ' ')}`;
let widths: Record<string, number> = {};
for (let elm of data) {
for (let k in elm) {
widths[k] = Math.max(
widths[k] || 0,
chrWidth(str(k)),
str(elm[k])
.split('\n')
.reduce((a, b) => Math.max(a, chrWidth(b)), 0)
);
}
}
const columns = Object.keys(widths);
if (!data.length || !columns.length) throw new Error('No data');
const padding = ` ${reset}${gray}${reset} `;
res.push(wrap(` ${columns.map((c) => `${bold}${pad(c, widths[c])}`).join(padding)}${reset}`, 3));
for (let idx = 0; idx < data.length; idx++) {
const elm = data[idx];
const row = columns.map((i) => str(elm[i]).split('\n'));
let message = [...Array(Math.max(...row.map((i) => i.length))).keys()]
.map((line) => row.map((c, i) => pad(str(c[line]), widths[columns[i]])))
.map((line, _) => wrap(` ${line.join(padding)} `, 1))
.join('\n');
res.push(message);
}
for (let i = 0; i < res.length; i++) {
const border = columns
.map((c) => ''.padEnd(widths[c], '─'))
.join(`${i === res.length - 1 ? '┴' : '┼'}`);
res[i] += wrap(`\n${reset}${gray}${border}${reset}`);
}
// @ts-ignore
console.log(res.join('\n'));
}
function fmtData(data: P.Bytes, perLine = 8) {
const res = [];
for (let i = 0; i < data.length; i += perLine) {
res.push(hex.encode(data.slice(i, i + perLine)));
}
return res.map((i) => `${bold}${i}${reset}`).join('\n');
}
function fmtValue(value: any) {
if (P.isBytes(value)) return `b(${green}${hex.encode(value)}${reset} len=${value.length})`;
if (typeof value === 'string') return `s(${green}"${value}"${reset} len=${value.length})`;
if (typeof value === 'number' || typeof value === 'bigint') return `n(${value})`;
// console.log('fmt', value);
// if (Object.prototype.toString.call(value) === '[object Object]') return inspect(value);
return '' + value;
}
export function decode(
coder: P.CoderType<any>,
data: string | P.Bytes,
forcePrint = false
): ReturnType<(typeof coder)['decode']> {
data = toBytes(data);
const r = new DebugReader(data);
let res, e;
try {
res = coder.decodeStream(r);
r.finish();
} catch (_e) {
e = _e;
}
r.finishDebug();
if (e || forcePrint) {
// @ts-ignore
console.log('==== DECODED BEFORE ERROR ====');
table(
mapData(r.debugLst, data).map((elm) => ({
Data: fmtData(elm.data),
Len: elm.data.length,
Path: `${green}${elm.path}${reset}`,
Value: fmtValue(elm.value),
}))
);
// @ts-ignore
console.log('==== /DECODED BEFORE ERROR ====');
}
if (e) throw e;
return res;
}
function getMap(coder: P.CoderType<any>, data: string | P.Bytes) {
data = toBytes(data);
const r = new DebugReader(data);
coder.decodeStream(r);
r.finish();
r.finishDebug();
return mapData(r.debugLst, data);
}
function diffData(a: P.Bytes, e: P.Bytes) {
const len = Math.max(a.length, e.length);
let outA = '',
outE = '';
const charHex = (n: number) => n.toString(16).padStart(2, '0');
for (let i = 0; i < len; i++) {
const [aI, eI] = [a[i], e[i]];
if (i && !(i % 8)) {
if (aI !== undefined) outA += '\n';
if (eI !== undefined) outE += '\n';
}
if (aI !== undefined) outA += aI === eI ? charHex(aI) : `${yellow}${charHex(aI)}${reset}`;
if (eI !== undefined) outE += aI === eI ? charHex(eI) : `${yellow}${charHex(eI)}${reset}`;
}
return [outA, outE];
}
function diffPath(a: string, e: string) {
if (a === e) return a;
return `A: ${red}${a}${reset}\nE: ${green}${e}${reset}`;
}
function diffLength(a: P.Bytes, e: P.Bytes) {
const [aLen, eLen] = [a.length, e.length];
if (aLen === eLen) return aLen;
return `A: ${red}${aLen}${reset}\nE: ${green}${eLen}${reset}`;
}
function diffValue(a: any, e: any) {
const [aV, eV] = [a, e].map(fmtValue);
if (aV === eV) return aV;
return `A: ${red}${aV}${reset}\nE: ${green}${eV}${reset}`;
}
export function diff(
coder: P.CoderType<any>,
actual: string | P.Bytes,
expected: string | P.Bytes,
skipSame = true
) {
// @ts-ignore
console.log('==== DIFF ====');
const [_actual, _expected] = [actual, expected].map((i) => getMap(coder, i)) as [
DebugData[],
DebugData[],
];
const len = Math.max(_actual.length, _expected.length);
const data = [];
const DEF = { data: P.EMPTY, path: '' };
for (let i = 0; i < len; i++) {
const [a, e] = [_actual[i] || DEF, _expected[i] || DEF];
if (P.equalBytes(a.data, e.data) && skipSame) continue;
const [adata, edata] = diffData(a.data, e.data);
data.push({
'Data (A)': adata,
'Data (E)': edata,
Len: diffLength(a.data, e.data),
Path: diffPath(a.path, e.path),
Value: diffValue(a.value, e.value),
});
}
table(data);
// @ts-ignore
console.log('==== /DIFF ====');
}

1314
apps/web5-dwn/node_modules/micro-packed/index.ts generated vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,5 @@
import * as P from './index.js';
export declare function table(data: any[]): void;
export declare function decode(coder: P.CoderType<any>, data: string | P.Bytes, forcePrint?: boolean): ReturnType<(typeof coder)['decode']>;
export declare function diff(coder: P.CoderType<any>, actual: string | P.Bytes, expected: string | P.Bytes, skipSame?: boolean): void;
//# sourceMappingURL=debugger.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"debugger.d.ts","sourceRoot":"","sources":["../debugger.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,YAAY,CAAC;AA0GhC,wBAAgB,KAAK,CAAC,IAAI,EAAE,GAAG,EAAE,QAsChC;AAmBD,wBAAgB,MAAM,CACpB,KAAK,EAAE,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,EACvB,IAAI,EAAE,MAAM,GAAG,CAAC,CAAC,KAAK,EACtB,UAAU,UAAQ,GACjB,UAAU,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,CA2BtC;AA4CD,wBAAgB,IAAI,CAClB,KAAK,EAAE,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,EACvB,MAAM,EAAE,MAAM,GAAG,CAAC,CAAC,KAAK,EACxB,QAAQ,EAAE,MAAM,GAAG,CAAC,CAAC,KAAK,EAC1B,QAAQ,UAAO,QA0BhB"}

268
apps/web5-dwn/node_modules/micro-packed/lib/debugger.js generated vendored Normal file
View File

@@ -0,0 +1,268 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.diff = exports.decode = exports.table = void 0;
const base_1 = require("@scure/base");
const P = require("./index.js");
const UNKNOWN = '(???)';
const bold = '\x1b[1m';
const gray = '\x1b[90m';
const reset = '\x1b[0m';
const red = '\x1b[31m';
const green = '\x1b[32m';
const yellow = '\x1b[33m';
class DebugReader extends P.Reader {
constructor() {
super(...arguments);
this.debugLst = [];
}
get lastElm() {
if (this.debugLst.length)
return this.debugLst[this.debugLst.length - 1];
return { start: 0, end: 0, path: '' };
}
fieldPathPush(s) {
const last = this.lastElm;
if (last.end === undefined)
last.end = this.pos;
else if (last.end !== this.pos) {
this.debugLst.push({
path: [...this.fieldPath, UNKNOWN].join('/'),
start: last.end,
end: this.pos,
});
}
this.cur = { path: [...this.fieldPath, s].join('/'), start: this.pos };
super.fieldPathPush(s);
}
fieldPathPop() {
// happens if pop after pop (exit from nested structure)
if (!this.cur) {
const last = this.lastElm;
if (last.end === undefined)
last.end = this.pos;
else if (last.end !== this.pos) {
this.debugLst.push({ start: last.end, end: this.pos, path: last.path + `/${UNKNOWN}` });
}
}
else {
this.cur.end = this.pos;
const lastItem = this.path[this.path.length - 1];
const lastField = this.fieldPath[this.fieldPath.length - 1];
if (lastItem && lastField !== undefined)
this.cur.value = lastItem[lastField];
this.debugLst.push(this.cur);
this.cur = undefined;
}
super.fieldPathPop();
}
finishDebug() {
const end = this.data.length;
if (this.cur)
this.debugLst.push({ end, ...this.cur });
const last = this.lastElm;
if (!last || last.end !== end)
this.debugLst.push({ start: this.pos, end, path: UNKNOWN });
}
}
function toBytes(data) {
if (P.isBytes(data))
return data;
if (typeof data !== 'string')
throw new Error('PD: data should be string or Uint8Array');
try {
return base_1.base64.decode(data);
}
catch (e) { }
try {
return base_1.hex.decode(data);
}
catch (e) { }
throw new Error(`PD: data has unknown string format: ${data}`);
}
function mapData(lst, data) {
let end = 0;
const res = [];
for (const elm of lst) {
if (elm.start !== end)
throw new Error(`PD: elm start=${elm.start} after prev elm end=${end}`);
if (elm.end === undefined)
throw new Error(`PD: elm.end is undefined=${elm}`);
res.push({ path: elm.path, data: data.slice(elm.start, elm.end), value: elm.value });
end = elm.end;
}
if (end !== data.length)
throw new Error('PD: not all data mapped');
return res;
}
function chrWidth(s) {
/*
It is almost impossible to find out real characters width in terminal since it depends on terminal itself, current unicode version and moon's phase.
So, we just stripping ANSI, tabs and unicode supplimental characters. Emoji support requires big tables (and have no guarantee to work), so we ignore it for now.
Also, no support for full width unicode characters for now.
*/
return s
.replace(/[\u001B\u009B][[\]()#;?]*(?:(?:(?:[a-zA-Z\d]*(?:;[-a-zA-Z\d\/#&.:=?%@~_]*)*)?\u0007)|(?:(?:\d{1,4}(?:;\d{0,4})*)?[\dA-PR-TZcf-ntqry=><~]))/g, '')
.replace('\t', ' ')
.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, ' ').length;
}
function wrap(s, padding = 0) {
// @ts-ignore
const limit = process.stdout.columns - 3 - padding;
if (chrWidth(s) <= limit)
return s;
while (chrWidth(s) > limit)
s = s.slice(0, -1);
return `${s}${reset}...`;
}
function table(data) {
let res = [];
const str = (v) => (v === undefined ? '' : '' + v);
const pad = (s, width) => `${s}${''.padEnd(Math.max(0, width - chrWidth(s)), ' ')}`;
let widths = {};
for (let elm of data) {
for (let k in elm) {
widths[k] = Math.max(widths[k] || 0, chrWidth(str(k)), str(elm[k])
.split('\n')
.reduce((a, b) => Math.max(a, chrWidth(b)), 0));
}
}
const columns = Object.keys(widths);
if (!data.length || !columns.length)
throw new Error('No data');
const padding = ` ${reset}${gray}${reset} `;
res.push(wrap(` ${columns.map((c) => `${bold}${pad(c, widths[c])}`).join(padding)}${reset}`, 3));
for (let idx = 0; idx < data.length; idx++) {
const elm = data[idx];
const row = columns.map((i) => str(elm[i]).split('\n'));
let message = [...Array(Math.max(...row.map((i) => i.length))).keys()]
.map((line) => row.map((c, i) => pad(str(c[line]), widths[columns[i]])))
.map((line, _) => wrap(` ${line.join(padding)} `, 1))
.join('\n');
res.push(message);
}
for (let i = 0; i < res.length; i++) {
const border = columns
.map((c) => ''.padEnd(widths[c], '─'))
.join(`${i === res.length - 1 ? '┴' : '┼'}`);
res[i] += wrap(`\n${reset}${gray}${border}${reset}`);
}
// @ts-ignore
console.log(res.join('\n'));
}
exports.table = table;
function fmtData(data, perLine = 8) {
const res = [];
for (let i = 0; i < data.length; i += perLine) {
res.push(base_1.hex.encode(data.slice(i, i + perLine)));
}
return res.map((i) => `${bold}${i}${reset}`).join('\n');
}
function fmtValue(value) {
if (P.isBytes(value))
return `b(${green}${base_1.hex.encode(value)}${reset} len=${value.length})`;
if (typeof value === 'string')
return `s(${green}"${value}"${reset} len=${value.length})`;
if (typeof value === 'number' || typeof value === 'bigint')
return `n(${value})`;
// console.log('fmt', value);
// if (Object.prototype.toString.call(value) === '[object Object]') return inspect(value);
return '' + value;
}
function decode(coder, data, forcePrint = false) {
data = toBytes(data);
const r = new DebugReader(data);
let res, e;
try {
res = coder.decodeStream(r);
r.finish();
}
catch (_e) {
e = _e;
}
r.finishDebug();
if (e || forcePrint) {
// @ts-ignore
console.log('==== DECODED BEFORE ERROR ====');
table(mapData(r.debugLst, data).map((elm) => ({
Data: fmtData(elm.data),
Len: elm.data.length,
Path: `${green}${elm.path}${reset}`,
Value: fmtValue(elm.value),
})));
// @ts-ignore
console.log('==== /DECODED BEFORE ERROR ====');
}
if (e)
throw e;
return res;
}
exports.decode = decode;
function getMap(coder, data) {
data = toBytes(data);
const r = new DebugReader(data);
coder.decodeStream(r);
r.finish();
r.finishDebug();
return mapData(r.debugLst, data);
}
function diffData(a, e) {
const len = Math.max(a.length, e.length);
let outA = '', outE = '';
const charHex = (n) => n.toString(16).padStart(2, '0');
for (let i = 0; i < len; i++) {
const [aI, eI] = [a[i], e[i]];
if (i && !(i % 8)) {
if (aI !== undefined)
outA += '\n';
if (eI !== undefined)
outE += '\n';
}
if (aI !== undefined)
outA += aI === eI ? charHex(aI) : `${yellow}${charHex(aI)}${reset}`;
if (eI !== undefined)
outE += aI === eI ? charHex(eI) : `${yellow}${charHex(eI)}${reset}`;
}
return [outA, outE];
}
function diffPath(a, e) {
if (a === e)
return a;
return `A: ${red}${a}${reset}\nE: ${green}${e}${reset}`;
}
function diffLength(a, e) {
const [aLen, eLen] = [a.length, e.length];
if (aLen === eLen)
return aLen;
return `A: ${red}${aLen}${reset}\nE: ${green}${eLen}${reset}`;
}
function diffValue(a, e) {
const [aV, eV] = [a, e].map(fmtValue);
if (aV === eV)
return aV;
return `A: ${red}${aV}${reset}\nE: ${green}${eV}${reset}`;
}
function diff(coder, actual, expected, skipSame = true) {
// @ts-ignore
console.log('==== DIFF ====');
const [_actual, _expected] = [actual, expected].map((i) => getMap(coder, i));
const len = Math.max(_actual.length, _expected.length);
const data = [];
const DEF = { data: P.EMPTY, path: '' };
for (let i = 0; i < len; i++) {
const [a, e] = [_actual[i] || DEF, _expected[i] || DEF];
if (P.equalBytes(a.data, e.data) && skipSame)
continue;
const [adata, edata] = diffData(a.data, e.data);
data.push({
'Data (A)': adata,
'Data (E)': edata,
Len: diffLength(a.data, e.data),
Path: diffPath(a.path, e.path),
Value: diffValue(a.value, e.value),
});
}
table(data);
// @ts-ignore
console.log('==== /DIFF ====');
}
exports.diff = diff;

View File

@@ -0,0 +1,262 @@
import { base64, hex } from '@scure/base';
import * as P from './index.js';
const UNKNOWN = '(???)';
const bold = '\x1b[1m';
const gray = '\x1b[90m';
const reset = '\x1b[0m';
const red = '\x1b[31m';
const green = '\x1b[32m';
const yellow = '\x1b[33m';
class DebugReader extends P.Reader {
constructor() {
super(...arguments);
this.debugLst = [];
}
get lastElm() {
if (this.debugLst.length)
return this.debugLst[this.debugLst.length - 1];
return { start: 0, end: 0, path: '' };
}
fieldPathPush(s) {
const last = this.lastElm;
if (last.end === undefined)
last.end = this.pos;
else if (last.end !== this.pos) {
this.debugLst.push({
path: [...this.fieldPath, UNKNOWN].join('/'),
start: last.end,
end: this.pos,
});
}
this.cur = { path: [...this.fieldPath, s].join('/'), start: this.pos };
super.fieldPathPush(s);
}
fieldPathPop() {
// happens if pop after pop (exit from nested structure)
if (!this.cur) {
const last = this.lastElm;
if (last.end === undefined)
last.end = this.pos;
else if (last.end !== this.pos) {
this.debugLst.push({ start: last.end, end: this.pos, path: last.path + `/${UNKNOWN}` });
}
}
else {
this.cur.end = this.pos;
const lastItem = this.path[this.path.length - 1];
const lastField = this.fieldPath[this.fieldPath.length - 1];
if (lastItem && lastField !== undefined)
this.cur.value = lastItem[lastField];
this.debugLst.push(this.cur);
this.cur = undefined;
}
super.fieldPathPop();
}
finishDebug() {
const end = this.data.length;
if (this.cur)
this.debugLst.push({ end, ...this.cur });
const last = this.lastElm;
if (!last || last.end !== end)
this.debugLst.push({ start: this.pos, end, path: UNKNOWN });
}
}
function toBytes(data) {
if (P.isBytes(data))
return data;
if (typeof data !== 'string')
throw new Error('PD: data should be string or Uint8Array');
try {
return base64.decode(data);
}
catch (e) { }
try {
return hex.decode(data);
}
catch (e) { }
throw new Error(`PD: data has unknown string format: ${data}`);
}
function mapData(lst, data) {
let end = 0;
const res = [];
for (const elm of lst) {
if (elm.start !== end)
throw new Error(`PD: elm start=${elm.start} after prev elm end=${end}`);
if (elm.end === undefined)
throw new Error(`PD: elm.end is undefined=${elm}`);
res.push({ path: elm.path, data: data.slice(elm.start, elm.end), value: elm.value });
end = elm.end;
}
if (end !== data.length)
throw new Error('PD: not all data mapped');
return res;
}
function chrWidth(s) {
/*
It is almost impossible to find out real characters width in terminal since it depends on terminal itself, current unicode version and moon's phase.
So, we just stripping ANSI, tabs and unicode supplimental characters. Emoji support requires big tables (and have no guarantee to work), so we ignore it for now.
Also, no support for full width unicode characters for now.
*/
return s
.replace(/[\u001B\u009B][[\]()#;?]*(?:(?:(?:[a-zA-Z\d]*(?:;[-a-zA-Z\d\/#&.:=?%@~_]*)*)?\u0007)|(?:(?:\d{1,4}(?:;\d{0,4})*)?[\dA-PR-TZcf-ntqry=><~]))/g, '')
.replace('\t', ' ')
.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, ' ').length;
}
function wrap(s, padding = 0) {
// @ts-ignore
const limit = process.stdout.columns - 3 - padding;
if (chrWidth(s) <= limit)
return s;
while (chrWidth(s) > limit)
s = s.slice(0, -1);
return `${s}${reset}...`;
}
export function table(data) {
let res = [];
const str = (v) => (v === undefined ? '' : '' + v);
const pad = (s, width) => `${s}${''.padEnd(Math.max(0, width - chrWidth(s)), ' ')}`;
let widths = {};
for (let elm of data) {
for (let k in elm) {
widths[k] = Math.max(widths[k] || 0, chrWidth(str(k)), str(elm[k])
.split('\n')
.reduce((a, b) => Math.max(a, chrWidth(b)), 0));
}
}
const columns = Object.keys(widths);
if (!data.length || !columns.length)
throw new Error('No data');
const padding = ` ${reset}${gray}${reset} `;
res.push(wrap(` ${columns.map((c) => `${bold}${pad(c, widths[c])}`).join(padding)}${reset}`, 3));
for (let idx = 0; idx < data.length; idx++) {
const elm = data[idx];
const row = columns.map((i) => str(elm[i]).split('\n'));
let message = [...Array(Math.max(...row.map((i) => i.length))).keys()]
.map((line) => row.map((c, i) => pad(str(c[line]), widths[columns[i]])))
.map((line, _) => wrap(` ${line.join(padding)} `, 1))
.join('\n');
res.push(message);
}
for (let i = 0; i < res.length; i++) {
const border = columns
.map((c) => ''.padEnd(widths[c], '─'))
.join(`${i === res.length - 1 ? '┴' : '┼'}`);
res[i] += wrap(`\n${reset}${gray}${border}${reset}`);
}
// @ts-ignore
console.log(res.join('\n'));
}
function fmtData(data, perLine = 8) {
const res = [];
for (let i = 0; i < data.length; i += perLine) {
res.push(hex.encode(data.slice(i, i + perLine)));
}
return res.map((i) => `${bold}${i}${reset}`).join('\n');
}
function fmtValue(value) {
if (P.isBytes(value))
return `b(${green}${hex.encode(value)}${reset} len=${value.length})`;
if (typeof value === 'string')
return `s(${green}"${value}"${reset} len=${value.length})`;
if (typeof value === 'number' || typeof value === 'bigint')
return `n(${value})`;
// console.log('fmt', value);
// if (Object.prototype.toString.call(value) === '[object Object]') return inspect(value);
return '' + value;
}
export function decode(coder, data, forcePrint = false) {
data = toBytes(data);
const r = new DebugReader(data);
let res, e;
try {
res = coder.decodeStream(r);
r.finish();
}
catch (_e) {
e = _e;
}
r.finishDebug();
if (e || forcePrint) {
// @ts-ignore
console.log('==== DECODED BEFORE ERROR ====');
table(mapData(r.debugLst, data).map((elm) => ({
Data: fmtData(elm.data),
Len: elm.data.length,
Path: `${green}${elm.path}${reset}`,
Value: fmtValue(elm.value),
})));
// @ts-ignore
console.log('==== /DECODED BEFORE ERROR ====');
}
if (e)
throw e;
return res;
}
function getMap(coder, data) {
data = toBytes(data);
const r = new DebugReader(data);
coder.decodeStream(r);
r.finish();
r.finishDebug();
return mapData(r.debugLst, data);
}
function diffData(a, e) {
const len = Math.max(a.length, e.length);
let outA = '', outE = '';
const charHex = (n) => n.toString(16).padStart(2, '0');
for (let i = 0; i < len; i++) {
const [aI, eI] = [a[i], e[i]];
if (i && !(i % 8)) {
if (aI !== undefined)
outA += '\n';
if (eI !== undefined)
outE += '\n';
}
if (aI !== undefined)
outA += aI === eI ? charHex(aI) : `${yellow}${charHex(aI)}${reset}`;
if (eI !== undefined)
outE += aI === eI ? charHex(eI) : `${yellow}${charHex(eI)}${reset}`;
}
return [outA, outE];
}
function diffPath(a, e) {
if (a === e)
return a;
return `A: ${red}${a}${reset}\nE: ${green}${e}${reset}`;
}
function diffLength(a, e) {
const [aLen, eLen] = [a.length, e.length];
if (aLen === eLen)
return aLen;
return `A: ${red}${aLen}${reset}\nE: ${green}${eLen}${reset}`;
}
function diffValue(a, e) {
const [aV, eV] = [a, e].map(fmtValue);
if (aV === eV)
return aV;
return `A: ${red}${aV}${reset}\nE: ${green}${eV}${reset}`;
}
export function diff(coder, actual, expected, skipSame = true) {
// @ts-ignore
console.log('==== DIFF ====');
const [_actual, _expected] = [actual, expected].map((i) => getMap(coder, i));
const len = Math.max(_actual.length, _expected.length);
const data = [];
const DEF = { data: P.EMPTY, path: '' };
for (let i = 0; i < len; i++) {
const [a, e] = [_actual[i] || DEF, _expected[i] || DEF];
if (P.equalBytes(a.data, e.data) && skipSame)
continue;
const [adata, edata] = diffData(a.data, e.data);
data.push({
'Data (A)': adata,
'Data (E)': edata,
Len: diffLength(a.data, e.data),
Path: diffPath(a.path, e.path),
Value: diffValue(a.value, e.value),
});
}
table(data);
// @ts-ignore
console.log('==== /DIFF ====');
}

1225
apps/web5-dwn/node_modules/micro-packed/lib/esm/index.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,10 @@
{
"type": "module",
"sideEffects": false,
"browser": {
"node:crypto": false
},
"node": {
"./crypto": "./esm/cryptoNode.js"
}
}

257
apps/web5-dwn/node_modules/micro-packed/lib/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,257 @@
import type { Coder as BaseCoder } from '@scure/base';
/**
* TODO:
* - Holes, simplify pointers. Hole is some sized element which is skipped at encoding,
* but later other elements can write to it by path
* - Composite / tuple keys for dict
* - Web UI for easier debugging. We can wrap every coder to something that would write
* start & end positions to; and we can colorize specific bytes used by specific coder
*/
export declare const EMPTY: Uint8Array;
export declare const NULL: Uint8Array;
export declare function equalBytes(a: Uint8Array, b: Uint8Array): boolean;
export declare function isBytes(a: unknown): a is Bytes;
/**
* Copies several Uint8Arrays into one.
*/
export declare function concatBytes(...arrays: Uint8Array[]): Uint8Array;
export type Bytes = Uint8Array;
export type Option<T> = T | undefined;
export interface Coder<F, T> {
encode(from: F): T;
decode(to: T): F;
}
export interface BytesCoder<T> extends Coder<T, Bytes> {
size?: number;
encode: (data: T) => Bytes;
decode: (data: Bytes) => T;
}
export interface BytesCoderStream<T> {
size?: number;
encodeStream: (w: Writer, value: T) => void;
decodeStream: (r: Reader) => T;
}
export type CoderType<T> = BytesCoderStream<T> & BytesCoder<T>;
export type Sized<T> = CoderType<T> & {
size: number;
};
export type UnwrapCoder<T> = T extends CoderType<infer U> ? U : T;
export type Length = CoderType<number> | CoderType<bigint> | number | Bytes | string | null;
type ArrLike<T> = Array<T> | ReadonlyArray<T>;
export type TypedArray = Uint8Array | Int8Array | Uint8ClampedArray | Uint16Array | Int16Array | Uint32Array | Int32Array;
export type Writable<T> = T extends {} ? T extends TypedArray ? T : {
-readonly [P in keyof T]: Writable<T[P]>;
} : T;
export type Values<T> = T[keyof T];
export type NonUndefinedKey<T, K extends keyof T> = T[K] extends undefined ? never : K;
export type NullableKey<T, K extends keyof T> = T[K] extends NonNullable<T[K]> ? never : K;
export type OptKey<T, K extends keyof T> = NullableKey<T, K> & NonUndefinedKey<T, K>;
export type ReqKey<T, K extends keyof T> = T[K] extends NonNullable<T[K]> ? K : never;
export type OptKeys<T> = Pick<T, {
[K in keyof T]: OptKey<T, K>;
}[keyof T]>;
export type ReqKeys<T> = Pick<T, {
[K in keyof T]: ReqKey<T, K>;
}[keyof T]>;
export type StructInput<T extends Record<string, any>> = {
[P in keyof ReqKeys<T>]: T[P];
} & {
[P in keyof OptKeys<T>]?: T[P];
};
export type StructRecord<T extends Record<string, any>> = {
[P in keyof T]: CoderType<T[P]>;
};
export type StructOut = Record<string, any>;
export type PadFn = (i: number) => number;
export type ReaderOpts = {
allowUnreadBytes?: boolean;
allowMultipleReads?: boolean;
};
export declare class Reader {
readonly data: Bytes;
readonly opts: ReaderOpts;
path: StructOut[];
fieldPath: string[];
private parent;
parentOffset: number;
pos: number;
bitBuf: number;
bitPos: number;
private bs;
constructor(data: Bytes, opts?: ReaderOpts, path?: StructOut[], fieldPath?: string[], parent?: Reader | undefined, parentOffset?: number);
enablePtr(): void;
private markBytesBS;
private markBytes;
err(msg: string): Error;
absBytes(n: number): Uint8Array;
offsetReader(n: number): Reader;
bytes(n: number, peek?: boolean): Uint8Array;
byte(peek?: boolean): number;
get leftBytes(): number;
isEnd(): boolean;
length(len: Length): number;
bits(bits: number): number;
find(needle: Bytes, pos?: number): number | undefined;
finish(): void;
fieldPathPush(s: string): void;
fieldPathPop(): void;
}
export declare class Writer {
path: StructOut[];
fieldPath: string[];
private buffers;
pos: number;
ptrs: {
pos: number;
ptr: CoderType<number>;
buffer: Bytes;
}[];
bitBuf: number;
bitPos: number;
constructor(path?: StructOut[], fieldPath?: string[]);
err(msg: string): Error;
bytes(b: Bytes): void;
byte(b: number): void;
get buffer(): Bytes;
length(len: Length, value: number): void;
bits(value: number, bits: number): void;
fieldPathPush(s: string): void;
fieldPathPop(): void;
}
export declare function checkBounds(p: Writer | Reader, value: bigint, bits: bigint, signed: boolean): void;
export declare function wrap<T>(inner: BytesCoderStream<T>): BytesCoderStream<T> & BytesCoder<T>;
export declare function isCoder<T>(elm: any): elm is CoderType<T>;
declare function dict<T>(): BaseCoder<[string, T][], Record<string, T>>;
type Enum = {
[k: string]: number | string;
} & {
[k: number]: string;
};
type EnumKeys<T extends Enum> = keyof T;
declare function tsEnum<T extends Enum>(e: T): BaseCoder<number, EnumKeys<T>>;
declare function decimal(precision: number): {
encode: (from: bigint) => string;
decode: (to: string) => bigint;
};
type BaseInput<F> = F extends BaseCoder<infer T, any> ? T : never;
type BaseOutput<F> = F extends BaseCoder<any, infer T> ? T : never;
/**
* Allows to split big conditional coders into a small one; also sort of parser combinator:
*
* `encode = [Ae, Be]; decode = [Ad, Bd]`
* ->
* `match([{encode: Ae, decode: Ad}, {encode: Be; decode: Bd}])`
*
* 1. It is easier to reason: encode/decode of specific part are closer to each other
* 2. Allows composable coders and ability to add conditions on runtime
* @param lst
* @returns
*/
declare function match<L extends BaseCoder<unknown | undefined, unknown | undefined>[], I = {
[K in keyof L]: NonNullable<BaseInput<L[K]>>;
}[number], O = {
[K in keyof L]: NonNullable<BaseOutput<L[K]>>;
}[number]>(lst: L): BaseCoder<I, O>;
export declare const coders: {
dict: typeof dict;
number: BaseCoder<bigint, number>;
tsEnum: typeof tsEnum;
decimal: typeof decimal;
match: typeof match;
reverse: <F, T>(coder: Coder<F, T>) => Coder<T, F>;
};
export declare const bits: (len: number) => CoderType<number>;
export declare const bigint: (size: number, le?: boolean, signed?: boolean, sized?: boolean) => CoderType<bigint>;
export declare const U256LE: CoderType<bigint>;
export declare const U256BE: CoderType<bigint>;
export declare const I256LE: CoderType<bigint>;
export declare const I256BE: CoderType<bigint>;
export declare const U128LE: CoderType<bigint>;
export declare const U128BE: CoderType<bigint>;
export declare const I128LE: CoderType<bigint>;
export declare const I128BE: CoderType<bigint>;
export declare const U64LE: CoderType<bigint>;
export declare const U64BE: CoderType<bigint>;
export declare const I64LE: CoderType<bigint>;
export declare const I64BE: CoderType<bigint>;
export declare const int: (size: number, le?: boolean, signed?: boolean, sized?: boolean) => CoderType<number>;
export declare const U32LE: CoderType<number>;
export declare const U32BE: CoderType<number>;
export declare const I32LE: CoderType<number>;
export declare const I32BE: CoderType<number>;
export declare const U16LE: CoderType<number>;
export declare const U16BE: CoderType<number>;
export declare const I16LE: CoderType<number>;
export declare const I16BE: CoderType<number>;
export declare const U8: CoderType<number>;
export declare const I8: CoderType<number>;
export declare const bool: CoderType<boolean>;
export declare const bytes: (len: Length, le?: boolean) => CoderType<Bytes>;
export declare const string: (len: Length, le?: boolean) => CoderType<string>;
export declare const cstring: CoderType<string>;
export declare const hex: (len: Length, le?: boolean, withZero?: boolean) => CoderType<string>;
export declare function apply<T, F>(inner: CoderType<T>, b: BaseCoder<T, F>): CoderType<F>;
export declare function validate<T>(inner: CoderType<T>, fn: (elm: T) => T): CoderType<T>;
export declare function lazy<T>(fn: () => CoderType<T>): CoderType<T>;
type baseFmt = 'utf8' | 'hex' | 'base16' | 'base32' | 'base64' | 'base64url' | 'base58' | 'base58xmr';
export declare const bytesFormatted: (len: Length, fmt: baseFmt, le?: boolean) => BytesCoderStream<string> & BytesCoder<string>;
export declare const flag: (flagValue: Bytes, xor?: boolean) => CoderType<boolean>;
export declare function flagged<T>(path: string | BytesCoderStream<boolean>, inner: BytesCoderStream<T>, def?: T): CoderType<Option<T>>;
export declare function optional<T>(flag: BytesCoderStream<boolean>, inner: BytesCoderStream<T>, def?: T): CoderType<Option<T>>;
export declare function magic<T>(inner: CoderType<T>, constant: T, check?: boolean): CoderType<undefined>;
export declare const magicBytes: (constant: Bytes | string) => CoderType<undefined>;
export declare function constant<T>(c: T): CoderType<T>;
export declare function struct<T extends Record<string, any>>(fields: StructRecord<T>): CoderType<StructInput<T>>;
export declare function tuple<T extends ArrLike<CoderType<any>>, O = Writable<{
[K in keyof T]: UnwrapCoder<T[K]>;
}>>(fields: T): CoderType<O>;
type PrefixLength = string | number | CoderType<number> | CoderType<bigint>;
export declare function prefix<T>(len: PrefixLength, inner: CoderType<T>): CoderType<T>;
export declare function array<T>(len: Length, inner: CoderType<T>): CoderType<T[]>;
export declare function map<T>(inner: CoderType<T>, variants: Record<string, T>): CoderType<string>;
export declare function tag<T extends Values<{
[P in keyof Variants]: {
TAG: P;
data: UnwrapCoder<Variants[P]>;
};
}>, TagValue extends string | number, Variants extends Record<TagValue, CoderType<any>>>(tag: CoderType<TagValue>, variants: Variants): CoderType<T>;
export declare function mappedTag<T extends Values<{
[P in keyof Variants]: {
TAG: P;
data: UnwrapCoder<Variants[P][1]>;
};
}>, TagValue extends string | number, Variants extends Record<string, [TagValue, CoderType<any>]>>(tagCoder: CoderType<TagValue>, variants: Variants): CoderType<T>;
export declare function bitset<Names extends readonly string[]>(names: Names, pad?: boolean): CoderType<Record<Names[number], boolean>>;
export declare const ZeroPad: PadFn;
export declare function padLeft<T>(blockSize: number, inner: CoderType<T>, padFn: Option<PadFn>): CoderType<T>;
export declare function padRight<T>(blockSize: number, inner: CoderType<T>, padFn: Option<PadFn>): CoderType<T>;
export declare function pointer<T>(ptr: CoderType<number>, inner: CoderType<T>, sized?: boolean): CoderType<T>;
export declare function base64armor<T>(name: string, lineLen: number, inner: Coder<T, Bytes>, checksum?: (data: Bytes) => Bytes): Coder<T, string>;
export declare const nothing: CoderType<undefined>;
export declare function debug<T>(inner: CoderType<T>): CoderType<T>;
export declare const _TEST: {
_bitset: {
BITS: number;
FULL_MASK: number;
len: (len: number) => number;
create: (len: number) => Uint32Array;
clean: (bs: Uint32Array) => Uint32Array;
debug: (bs: Uint32Array) => string[];
checkLen: (bs: Uint32Array, len: number) => void;
chunkLen: (bsLen: number, pos: number, len: number) => void;
set: (bs: Uint32Array, chunk: number, value: number, allowRewrite?: boolean) => boolean;
pos: (pos: number, i: number) => {
chunk: number;
mask: number;
};
indices: (bs: Uint32Array, len: number, invert?: boolean) => number[];
range: (arr: number[]) => {
pos: number;
length: number;
}[];
rangeDebug: (bs: Uint32Array, len: number, invert?: boolean) => string;
setRange: (bs: Uint32Array, bsLen: number, pos: number, len: number, allowRewrite?: boolean) => boolean;
};
};
export {};
//# sourceMappingURL=index.d.ts.map

File diff suppressed because one or more lines are too long

1267
apps/web5-dwn/node_modules/micro-packed/lib/index.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

64
apps/web5-dwn/node_modules/micro-packed/package.json generated vendored Normal file
View File

@@ -0,0 +1,64 @@
{
"name": "micro-packed",
"version": "0.5.3",
"description": "Define complex binary structures using composable primitives",
"files": [
"lib/index.js",
"lib/debugger.js",
"lib/esm/index.js",
"lib/esm/debugger.js",
"lib/index.d.ts",
"lib/debugger.d.ts",
"lib/index.d.ts.map",
"lib/debugger.d.ts.map",
"index.ts",
"debugger.ts",
"lib/esm/package.json"
],
"main": "lib/index.js",
"module": "lib/esm/index.js",
"types": "lib/index.d.ts",
"exports": {
".": {
"types": "./lib/index.d.ts",
"import": "./lib/esm/index.js",
"default": "./lib/index.js"
},
"./debugger": {
"types": "./lib/debugger.d.ts",
"import": "./lib/esm/debugger.js",
"default": "./lib/debugger.js"
}
},
"dependencies": {
"@scure/base": "~1.1.5"
},
"scripts": {
"build": "tsc && tsc -p tsconfig.esm.json",
"lint": "prettier --check index.ts debugger.ts",
"format": "prettier --write index.ts debugger.ts",
"test": "node test/index.js && node test/debugger.test.js"
},
"author": "Paul Miller (https://paulmillr.com)",
"license": "MIT",
"homepage": "https://github.com/paulmillr/micro-packed",
"repository": {
"type": "git",
"url": "git+https://github.com/paulmillr/micro-packed.git"
},
"devDependencies": {
"micro-should": "0.4.0",
"prettier": "3.1.1",
"typescript": "5.3.2"
},
"keywords": [
"encode",
"encoder",
"binary",
"bytes",
"struct",
"tuple",
"enum"
],
"funding": "https://paulmillr.com/funding/"
}