@qntx/ur 2.1.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index-DuVMkXeG.d.mts +236 -0
- package/dist/{index-DTjNCWBI.d.mts → index-HtwyWL4y.d.mts} +7 -7
- package/dist/{index-CcMfgay6.d.mts → index-rxH9gNTp.d.mts} +10 -6
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +1 -1
- package/dist/interop.d.mts +118 -0
- package/dist/interop.mjs +530 -0
- package/dist/registry-BGnkPqkV.mjs +1141 -0
- package/dist/registry.d.mts +4 -201
- package/dist/registry.mjs +4 -899
- package/dist/{typed-D-SyraAj.mjs → typed-C8j8iVYT.mjs} +2 -3
- package/dist/typed.d.mts +3 -3
- package/dist/typed.mjs +2 -2
- package/dist/{ur-7Ge3roVh.mjs → ur-ChGW72hQ.mjs} +10 -11
- package/package.json +13 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { T as fail, a as parseUr, i as toQrString, n as UrEncoder, r as encodeUr, s as parseUrType } from "./ur-
|
|
1
|
+
import { T as fail, a as parseUr, i as toQrString, n as UrEncoder, r as encodeUr, s as parseUrType } from "./ur-ChGW72hQ.mjs";
|
|
2
2
|
import { CborError, cbor, decodeCbor, encodeCbor, extractTaggedContent, taggedValue, validateTag } from "@blockchaincommons/dcbor";
|
|
3
3
|
//#region src/typed/ur.ts
|
|
4
4
|
function mapCborDecode(run) {
|
|
@@ -46,7 +46,7 @@ var Ur = class Ur {
|
|
|
46
46
|
return Ur.fromCborData(decoded.type, decoded.message);
|
|
47
47
|
}
|
|
48
48
|
toCborData() {
|
|
49
|
-
return mapCborType(() => encodeCbor(this.cbor));
|
|
49
|
+
return new Uint8Array(mapCborType(() => encodeCbor(this.cbor)));
|
|
50
50
|
}
|
|
51
51
|
toString() {
|
|
52
52
|
return encodeUr(this.type, this.toCborData());
|
|
@@ -98,7 +98,6 @@ function fromTagged(cbor, codec) {
|
|
|
98
98
|
return codec.decode(extractTaggedContent(cbor));
|
|
99
99
|
});
|
|
100
100
|
}
|
|
101
|
-
/** `UrType -> codec` map covering every tag name; a duplicate type is `InvalidType`. */
|
|
102
101
|
function codecMap(codecs) {
|
|
103
102
|
const map = /* @__PURE__ */ new Map();
|
|
104
103
|
for (const codec of codecs) for (const type of codecUrTypes(codec)) {
|
package/dist/typed.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { C as parseUrType, S as isUrType, _ as UrError, b as UrLimit, g as DecoderLimits, h as DEFAULT_LIMITS, v as UrErrorCode, x as UrType, y as UrErrorInfo } from "./index-
|
|
2
|
-
import { a as
|
|
3
|
-
export { DEFAULT_LIMITS, type DecoderLimits, Ur, type UrCodec, UrError, type UrErrorCode, type UrErrorInfo, type UrLimit, type UrType, codecMap, codecUrTypes, fromTagged, fromUr, fromUrWith, isUrType, parseUrType, toTagged, toUr };
|
|
1
|
+
import { C as parseUrType, S as isUrType, _ as UrError, b as UrLimit, g as DecoderLimits, h as DEFAULT_LIMITS, v as UrErrorCode, x as UrType, y as UrErrorInfo } from "./index-HtwyWL4y.mjs";
|
|
2
|
+
import { a as codecUrTypes, c as fromUrWith, d as Ur, i as codecMap, l as toTagged, n as CodecValue, o as fromTagged, r as UrCodec, s as fromUr, t as CodecMap, u as toUr } from "./index-rxH9gNTp.mjs";
|
|
3
|
+
export { type CodecMap, type CodecValue, DEFAULT_LIMITS, type DecoderLimits, Ur, type UrCodec, UrError, type UrErrorCode, type UrErrorInfo, type UrLimit, type UrType, codecMap, codecUrTypes, fromTagged, fromUr, fromUrWith, isUrType, parseUrType, toTagged, toUr };
|
package/dist/typed.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { f as DEFAULT_LIMITS, o as isUrType, s as parseUrType, w as UrError } from "./ur-
|
|
2
|
-
import { a as fromUrWith, c as Ur, i as fromUr, n as codecUrTypes, o as toTagged, r as fromTagged, s as toUr, t as codecMap } from "./typed-
|
|
1
|
+
import { f as DEFAULT_LIMITS, o as isUrType, s as parseUrType, w as UrError } from "./ur-ChGW72hQ.mjs";
|
|
2
|
+
import { a as fromUrWith, c as Ur, i as fromUr, n as codecUrTypes, o as toTagged, r as fromTagged, s as toUr, t as codecMap } from "./typed-C8j8iVYT.mjs";
|
|
3
3
|
export { DEFAULT_LIMITS, Ur, UrError, codecMap, codecUrTypes, fromTagged, fromUr, fromUrWith, isUrType, parseUrType, toTagged, toUr };
|
|
@@ -17,7 +17,6 @@ const MESSAGES = {
|
|
|
17
17
|
InvalidPadding: "invalid fountain part padding",
|
|
18
18
|
InvalidMessageChecksum: "invalid fountain message checksum",
|
|
19
19
|
EmptyMessage: "empty message",
|
|
20
|
-
InvalidFragmentLength: "invalid fragment length",
|
|
21
20
|
MessageTooLong: "message too long",
|
|
22
21
|
NotSinglePart: "expected single-part UR",
|
|
23
22
|
CborDecode: "dCBOR decode failed",
|
|
@@ -63,7 +62,7 @@ function toUrError(error) {
|
|
|
63
62
|
}
|
|
64
63
|
//#endregion
|
|
65
64
|
//#region src/consensus/crc32.ts
|
|
66
|
-
/** CRC-32 ISO-HDLC (polynomial 0xedb88320)
|
|
65
|
+
/** CRC-32 ISO-HDLC (polynomial 0xedb88320). */
|
|
67
66
|
const TABLE = (() => {
|
|
68
67
|
const table = /* @__PURE__ */ new Uint32Array(256);
|
|
69
68
|
for (let i = 0; i < 256; i++) {
|
|
@@ -83,8 +82,7 @@ function checksum(data) {
|
|
|
83
82
|
//#region src/ascii.ts
|
|
84
83
|
/**
|
|
85
84
|
* ASCII-only character helpers. `String.prototype.toLowerCase`/`toUpperCase` are Unicode-aware
|
|
86
|
-
* (e.g. `"\u212A"` folds to `"k"`); the UR wire format folds ASCII letters only
|
|
87
|
-
* `to_ascii_lowercase`/`to_ascii_uppercase`.
|
|
85
|
+
* (e.g. `"\u212A"` folds to `"k"`); the UR wire format folds ASCII letters only.
|
|
88
86
|
*/
|
|
89
87
|
/** True iff every code point of `text` is `<= 0x7F`. */
|
|
90
88
|
function isAscii(text) {
|
|
@@ -998,7 +996,7 @@ function at(list, i) {
|
|
|
998
996
|
if (v === void 0) throw new Error("unreachable: index out of range");
|
|
999
997
|
return v;
|
|
1000
998
|
}
|
|
1001
|
-
/** Walker's alias method with reverse-index ordered partition
|
|
999
|
+
/** Walker's alias method with reverse-index ordered partition. */
|
|
1002
1000
|
var Sampler = class {
|
|
1003
1001
|
#aliases;
|
|
1004
1002
|
#probs;
|
|
@@ -1062,7 +1060,7 @@ function scaledInt(d, low, high) {
|
|
|
1062
1060
|
const span = high - low + 1;
|
|
1063
1061
|
return Math.min(Math.floor(d * span), span - 1) + low;
|
|
1064
1062
|
}
|
|
1065
|
-
/** Xoshiro256** with SHA-256 seeding
|
|
1063
|
+
/** Xoshiro256** with SHA-256 seeding. */
|
|
1066
1064
|
var Xoshiro256 = class Xoshiro256 {
|
|
1067
1065
|
s0;
|
|
1068
1066
|
s1;
|
|
@@ -1184,16 +1182,16 @@ var FragmentChooser = class {
|
|
|
1184
1182
|
//#endregion
|
|
1185
1183
|
//#region src/fountain/limits.ts
|
|
1186
1184
|
/**
|
|
1187
|
-
* Production default
|
|
1185
|
+
* Production default (1 MiB message, 2000 fragments, 8192-byte fragments and URIs), frozen.
|
|
1188
1186
|
*
|
|
1189
1187
|
* Hosts that need another budget pass `new UrDecoder({ limits })`.
|
|
1190
1188
|
*/
|
|
1191
|
-
const DEFAULT_LIMITS = {
|
|
1189
|
+
const DEFAULT_LIMITS = Object.freeze({
|
|
1192
1190
|
maxMessageLength: 1048576,
|
|
1193
1191
|
maxFragmentCount: 2e3,
|
|
1194
1192
|
maxFragmentLength: 8192,
|
|
1195
1193
|
maxUriLength: 8192
|
|
1196
|
-
};
|
|
1194
|
+
});
|
|
1197
1195
|
function mergeLimits(partial) {
|
|
1198
1196
|
return {
|
|
1199
1197
|
...DEFAULT_LIMITS,
|
|
@@ -1483,7 +1481,7 @@ function partition(data, fragLen) {
|
|
|
1483
1481
|
/**
|
|
1484
1482
|
* Fountain encoder. An infinite iterator: produces parts with sequence `firstSequence + 1`, `+2`, …
|
|
1485
1483
|
* and ends after `0xFFFFFFFF` (UR-ADR-028). For `K == 1` it keeps producing identical parts with
|
|
1486
|
-
* rising sequences.
|
|
1484
|
+
* rising sequences. Message problems throw `UrError`; invalid options throw `RangeError`.
|
|
1487
1485
|
*/
|
|
1488
1486
|
var FountainEncoder = class {
|
|
1489
1487
|
#parts;
|
|
@@ -1498,7 +1496,8 @@ var FountainEncoder = class {
|
|
|
1498
1496
|
const { maxFragmentLength, minFragmentLength = DEFAULT_MIN_FRAGMENT_LENGTH, firstSequence = 0 } = options;
|
|
1499
1497
|
if (message.length === 0) fail("EmptyMessage");
|
|
1500
1498
|
if (message.length > MAX_U32$1) fail("MessageTooLong");
|
|
1501
|
-
if (!Number.isSafeInteger(maxFragmentLength) || maxFragmentLength < 1
|
|
1499
|
+
if (!Number.isSafeInteger(maxFragmentLength) || maxFragmentLength < 1) throw new RangeError("maxFragmentLength must be a positive integer");
|
|
1500
|
+
if (!Number.isSafeInteger(minFragmentLength) || minFragmentLength < 1 || minFragmentLength > maxFragmentLength) throw new RangeError("minFragmentLength must be a positive integer at most maxFragmentLength");
|
|
1502
1501
|
if (!Number.isSafeInteger(firstSequence) || firstSequence < 0 || firstSequence > MAX_U32$1) throw new RangeError("firstSequence must be an integer in 0..=0xFFFFFFFF");
|
|
1503
1502
|
const fragLen = fragmentLength(message.length, maxFragmentLength, minFragmentLength);
|
|
1504
1503
|
const fragments = partition(message, fragLen);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qntx/ur",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Uniform Resources (UR) for TypeScript: Bytewords, fountain codes, multi-part UR, typed dCBOR,
|
|
3
|
+
"version": "4.0.0",
|
|
4
|
+
"description": "Uniform Resources (UR) for TypeScript: Bytewords, fountain codes, multi-part UR, typed dCBOR, BCR-2020-006 registry types, and wallet-interop (Keystone/OneKey) codecs.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"blockchain-commons",
|
|
7
7
|
"bytewords",
|
|
@@ -34,6 +34,11 @@
|
|
|
34
34
|
"import": "./dist/index.mjs",
|
|
35
35
|
"default": "./dist/index.mjs"
|
|
36
36
|
},
|
|
37
|
+
"./interop": {
|
|
38
|
+
"types": "./dist/interop.d.mts",
|
|
39
|
+
"import": "./dist/interop.mjs",
|
|
40
|
+
"default": "./dist/interop.mjs"
|
|
41
|
+
},
|
|
37
42
|
"./registry": {
|
|
38
43
|
"types": "./dist/registry.d.mts",
|
|
39
44
|
"import": "./dist/registry.mjs",
|
|
@@ -64,7 +69,11 @@
|
|
|
64
69
|
},
|
|
65
70
|
"devDependencies": {
|
|
66
71
|
"@arethetypeswrong/cli": "0.18.5",
|
|
67
|
-
"@blockchaincommons/dcbor": "1.0.0-beta.
|
|
72
|
+
"@blockchaincommons/dcbor": "1.0.0-beta.5",
|
|
73
|
+
"@keystonehq/bc-ur-registry": "0.8.1",
|
|
74
|
+
"@keystonehq/bc-ur-registry-eth": "0.23.0",
|
|
75
|
+
"@keystonehq/bc-ur-registry-sol": "0.9.5",
|
|
76
|
+
"@keystonehq/bc-ur-registry-tron": "0.5.0",
|
|
68
77
|
"@qntx/tsconfig": "1.0.1",
|
|
69
78
|
"@types/node": "26.6.3",
|
|
70
79
|
"publint": "0.3.24",
|
|
@@ -72,7 +81,7 @@
|
|
|
72
81
|
"vite-plus": "1.0.0"
|
|
73
82
|
},
|
|
74
83
|
"peerDependencies": {
|
|
75
|
-
"@blockchaincommons/dcbor": "1.0.0-beta.
|
|
84
|
+
"@blockchaincommons/dcbor": "1.0.0-beta.5"
|
|
76
85
|
},
|
|
77
86
|
"peerDependenciesMeta": {
|
|
78
87
|
"@blockchaincommons/dcbor": {
|