@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 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # `@qntx/ur`
4
4
 
5
- Uniform Resources (UR) for TypeScript: bytewords, fountain codes, and single- or multi-part UR strings. Transport-only at the root; typed dCBOR is `@qntx/ur/typed` and registry types are `@qntx/ur/registry`. Wire-compatible with [bcur](https://crates.io/crates/bcur).
5
+ Uniform Resources (UR) for TypeScript: bytewords, fountain codes, and single- or multi-part UR strings. Transport-only at the root; typed dCBOR is `@qntx/ur/typed`, registry types are `@qntx/ur/registry`, and wallet-interop codecs (Keystone/OneKey dialects) are `@qntx/ur/interop`. Wire-compatible with [bcur](https://crates.io/crates/bcur).
6
6
 
7
7
  See the [documentation](https://github.com/qntx/ur/tree/main/docs).
8
8
 
@@ -0,0 +1,236 @@
1
+ import { r as UrCodec } from "./index-rxH9gNTp.mjs";
2
+ import { Cbor, CborMap, Tag } from "@blockchaincommons/dcbor";
3
+ //#region src/registry/keypath.d.ts
4
+ type PathComponent = {
5
+ readonly kind: "index";
6
+ readonly index: number;
7
+ readonly hardened: boolean;
8
+ } | {
9
+ readonly kind: "range";
10
+ readonly low: number;
11
+ readonly high: number;
12
+ readonly hardened: boolean;
13
+ } | {
14
+ readonly kind: "wildcard";
15
+ readonly hardened: boolean;
16
+ } | {
17
+ readonly kind: "pair";
18
+ readonly external: {
19
+ readonly index: number;
20
+ readonly hardened: boolean;
21
+ };
22
+ readonly internal: {
23
+ readonly index: number;
24
+ readonly hardened: boolean;
25
+ };
26
+ };
27
+ type Keypath = {
28
+ readonly components: ReadonlyArray<PathComponent>;
29
+ readonly sourceFingerprint?: number;
30
+ readonly depth?: number;
31
+ };
32
+ declare const keypathCodec: UrCodec<Keypath>;
33
+ /**
34
+ * Deprecated v1 writer (`ur:crypto-keypath`, tag 304). The body is identical to v2; only the tag
35
+ * differs.
36
+ */
37
+ declare const cryptoKeypathCodec: UrCodec<Keypath>;
38
+ //#endregion
39
+ //#region src/registry/coin-info.d.ts
40
+ declare const CoinType: {
41
+ readonly btc: 0;
42
+ readonly eth: 0x3c;
43
+ };
44
+ declare const Network: {
45
+ readonly mainnet: 0;
46
+ readonly btcTestnet: 1;
47
+ };
48
+ type CoinInfo = {
49
+ readonly type?: number;
50
+ readonly network?: number;
51
+ };
52
+ declare const coinInfoCodec: UrCodec<CoinInfo>;
53
+ /**
54
+ * Deprecated v1 writer (`ur:crypto-coin-info`, tag 305). Presence-preserving: `type` and `network`
55
+ * are written iff present, `0` included — unlike the v2 writer, which omits defaults.
56
+ */
57
+ declare const cryptoCoinInfoCodec: UrCodec<CoinInfo>;
58
+ //#endregion
59
+ //#region src/registry/hdkey.d.ts
60
+ type MasterHdKey = {
61
+ readonly kind: "master";
62
+ readonly keyData: Uint8Array;
63
+ readonly chainCode: Uint8Array;
64
+ };
65
+ type DerivedHdKey = {
66
+ readonly kind: "derived";
67
+ readonly isPrivate?: boolean;
68
+ readonly keyData: Uint8Array;
69
+ readonly chainCode?: Uint8Array;
70
+ readonly useInfo?: CoinInfo;
71
+ readonly origin?: Keypath;
72
+ readonly children?: Keypath;
73
+ readonly parentFingerprint?: number;
74
+ readonly name?: string;
75
+ readonly note?: string;
76
+ };
77
+ type HdKey = MasterHdKey | DerivedHdKey;
78
+ declare const hdKeyCodec: UrCodec<HdKey>;
79
+ /**
80
+ * Deprecated v1 writer (`ur:crypto-hdkey`, tag 303). Presence-preserving: `is-private` is written
81
+ * iff `isPrivate` is present (`false` included), and the nested use-info / origin / children values
82
+ * carry the v1 tags (305/304) with v1 rules. Every other field matches v2.
83
+ */
84
+ declare const cryptoHdKeyCodec: UrCodec<HdKey>;
85
+ //#endregion
86
+ //#region src/registry/seed.d.ts
87
+ type Seed = {
88
+ readonly payload: Uint8Array;
89
+ readonly creationDate?: Date;
90
+ readonly name?: string;
91
+ readonly note?: string;
92
+ };
93
+ declare const seedCodec: UrCodec<Seed>;
94
+ //#endregion
95
+ //#region src/registry/psbt.d.ts
96
+ type Psbt = {
97
+ readonly bytes: Uint8Array;
98
+ };
99
+ declare const psbtCodec: UrCodec<Psbt>;
100
+ /**
101
+ * Deprecated v1 writer (`ur:crypto-psbt`, tag 310). The body is identical to v2; only the tag
102
+ * differs.
103
+ */
104
+ declare const cryptoPsbtCodec: UrCodec<Psbt>;
105
+ //#endregion
106
+ //#region src/registry/eckey.d.ts
107
+ type EcKey = {
108
+ readonly curve?: number;
109
+ readonly isPrivate?: boolean;
110
+ readonly data: Uint8Array;
111
+ };
112
+ declare const ecKeyCodec: UrCodec<EcKey>;
113
+ //#endregion
114
+ //#region src/registry/address.d.ts
115
+ declare const ADDRESS_TYPES: readonly ["p2pkh", "p2sh", "p2wpkh"];
116
+ type AddressType = (typeof ADDRESS_TYPES)[number];
117
+ type Address = {
118
+ readonly info?: CoinInfo;
119
+ readonly type?: AddressType;
120
+ readonly data: Uint8Array;
121
+ };
122
+ declare const addressCodec: UrCodec<Address>;
123
+ //#endregion
124
+ //#region src/registry/script-expression.d.ts
125
+ type DescriptorKey = {
126
+ readonly kind: "hdkey";
127
+ readonly key: HdKey;
128
+ } | {
129
+ readonly kind: "eckey";
130
+ readonly key: EcKey;
131
+ } | {
132
+ readonly kind: "address";
133
+ readonly address: Address;
134
+ };
135
+ //#endregion
136
+ //#region src/registry/output-descriptor.d.ts
137
+ type OutputDescriptor = {
138
+ readonly source: string;
139
+ readonly keys: ReadonlyArray<DescriptorKey>;
140
+ readonly name?: string;
141
+ readonly note?: string;
142
+ };
143
+ declare const outputDescriptorCodec: UrCodec<OutputDescriptor>;
144
+ /**
145
+ * Deprecated v1 writer (`ur:crypto-output`, tag 308): a script-expression tree whose embedded keys
146
+ * use the v1 tags (303/306/307). Decode accepts both the tree and a tagged v2 map, but only
147
+ * descriptors the v1 writer can re-encode — no `name`/`note`, `source` inside the script-expression
148
+ * grammar.
149
+ */
150
+ declare const cryptoOutputCodec: UrCodec<OutputDescriptor>;
151
+ //#endregion
152
+ //#region src/registry/account-descriptor.d.ts
153
+ type AccountDescriptor = {
154
+ readonly masterFingerprint: number;
155
+ readonly outputDescriptors: ReadonlyArray<OutputDescriptor>;
156
+ };
157
+ declare const accountDescriptorCodec: UrCodec<AccountDescriptor>;
158
+ /**
159
+ * Deprecated v1 writer (`ur:crypto-account`, tag 311): `{1: mfp, 2: entries}`. The entries are bare
160
+ * script-expression trees — Keystone's spelling, which deployed readers expect — not BCR-2020-015's
161
+ * tagged `308` outputs. Decode accepts v1/v2 entry forms but rejects anything the v1 writer cannot
162
+ * re-encode.
163
+ */
164
+ declare const cryptoAccountCodec: UrCodec<AccountDescriptor>;
165
+ //#endregion
166
+ //#region src/registry/sskr.d.ts
167
+ type SskrShare = {
168
+ readonly identifier: number;
169
+ readonly groupThreshold: number;
170
+ readonly groupCount: number;
171
+ readonly groupIndex: number;
172
+ readonly memberThreshold: number;
173
+ readonly memberIndex: number;
174
+ readonly shareValue: Uint8Array;
175
+ };
176
+ declare const sskrCodec: UrCodec<SskrShare>;
177
+ //#endregion
178
+ //#region src/registry/envelope.d.ts
179
+ /** Inclusive cap: depth 0..=64 accepted (65 frames). Predicate is `>`, not `>=`. */
180
+ declare const ENVELOPE_MAX_DEPTH = 64;
181
+ declare function assertEnvelopeContent(cbor: Cbor, depth?: number): void;
182
+ declare const envelopeCodec: UrCodec<Cbor>;
183
+ //#endregion
184
+ //#region src/registry/digest.d.ts
185
+ /** BCR-2021-002: SHA-256 of the raw seed payload, not the CBOR map. */
186
+ declare function seedDigest(seed: Seed): Uint8Array<ArrayBuffer>;
187
+ /** BCR-2021-002: dCBOR of [keyData, chainCode | null, coinType, network]. */
188
+ declare function hdKeyDigestSource(key: HdKey): Uint8Array<ArrayBuffer>;
189
+ declare function hdKeyDigest(key: HdKey): Uint8Array<ArrayBuffer>;
190
+ //#endregion
191
+ //#region src/registry/tags.d.ts
192
+ /**
193
+ * Codecs that exist in this version. The `crypto-*` entries are the deprecated v1 tags
194
+ * (BCR-2020-006); the v2 codecs accept them on read, and the separate `crypto*Codec` writers emit
195
+ * them. `SCRIPT_TAGS` are the BCR-2020-010 script-expression tags embedded inside v1 crypto-output
196
+ * bodies.
197
+ */
198
+ declare const TAGS: Readonly<{
199
+ envelope: Tag;
200
+ seed: Tag;
201
+ hdkey: Tag;
202
+ keypath: Tag;
203
+ "coin-info": Tag;
204
+ eckey: Tag;
205
+ address: Tag;
206
+ "output-descriptor": Tag;
207
+ sskr: Tag;
208
+ psbt: Tag;
209
+ "account-descriptor": Tag;
210
+ "crypto-seed": Tag;
211
+ "crypto-hdkey": Tag;
212
+ "crypto-keypath": Tag;
213
+ "crypto-coin-info": Tag;
214
+ "crypto-eckey": Tag;
215
+ "crypto-address": Tag;
216
+ "crypto-output": Tag;
217
+ "crypto-sskr": Tag;
218
+ "crypto-psbt": Tag;
219
+ "crypto-account": Tag;
220
+ }>;
221
+ /** BCR-2020-010 script-expression tags by descriptor function name. */
222
+ declare const SCRIPT_TAGS: Readonly<{
223
+ sh: Tag;
224
+ wsh: Tag;
225
+ pk: Tag;
226
+ pkh: Tag;
227
+ wpkh: Tag;
228
+ combo: Tag;
229
+ multi: Tag;
230
+ sortedmulti: Tag;
231
+ raw: Tag;
232
+ tr: Tag;
233
+ cosigner: Tag;
234
+ }>;
235
+ //#endregion
236
+ export { MasterHdKey as A, cryptoKeypathCodec as B, Psbt as C, seedCodec as D, Seed as E, Network as F, coinInfoCodec as I, cryptoCoinInfoCodec as L, hdKeyCodec as M, CoinInfo as N, DerivedHdKey as O, CoinType as P, Keypath as R, ecKeyCodec as S, psbtCodec as T, keypathCodec as V, DescriptorKey as _, seedDigest as a, addressCodec as b, envelopeCodec as c, AccountDescriptor as d, accountDescriptorCodec as f, outputDescriptorCodec as g, cryptoOutputCodec as h, hdKeyDigestSource as i, cryptoHdKeyCodec as j, HdKey as k, SskrShare as l, OutputDescriptor as m, TAGS as n, ENVELOPE_MAX_DEPTH as o, cryptoAccountCodec as p, hdKeyDigest as r, assertEnvelopeContent as s, SCRIPT_TAGS as t, sskrCodec as u, Address as v, cryptoPsbtCodec as w, EcKey as x, AddressType as y, PathComponent as z };
@@ -10,9 +10,9 @@ declare function parseUrType(text: string): UrType;
10
10
  declare function isUrType(text: string): text is UrType;
11
11
  //#endregion
12
12
  //#region src/error.d.ts
13
- /** Discriminated error codes for the UR transport stack. Mirrors `bcur::ErrorKind`. */
14
- type UrErrorCode = "NonAscii" | "InvalidWord" | "InvalidBytewordsLength" | "InvalidBytewordsChecksum" | "InvalidScheme" | "TypeUnspecified" | "InvalidType" | "InvalidIndices" | "UnexpectedType" | "InvalidPartCbor" | "InvalidPart" | "InconsistentPart" | "ResourceLimit" | "InvalidPadding" | "InvalidMessageChecksum" | "EmptyMessage" | "InvalidFragmentLength" | "MessageTooLong" | "NotSinglePart" | "CborDecode" | "CborType" | "Internal";
15
- /** Decoder budget names carried by `ResourceLimit` errors. Mirrors `bcur::Limit`. */
13
+ /** Discriminated error codes for the UR transport stack. */
14
+ type UrErrorCode = "NonAscii" | "InvalidWord" | "InvalidBytewordsLength" | "InvalidBytewordsChecksum" | "InvalidScheme" | "TypeUnspecified" | "InvalidType" | "InvalidIndices" | "UnexpectedType" | "InvalidPartCbor" | "InvalidPart" | "InconsistentPart" | "ResourceLimit" | "InvalidPadding" | "InvalidMessageChecksum" | "EmptyMessage" | "MessageTooLong" | "NotSinglePart" | "CborDecode" | "CborType" | "Internal";
15
+ /** Decoder budget names carried by `ResourceLimit` errors. */
16
16
  type UrLimit = "messageLength" | "fragmentCount" | "fragmentLength" | "uriLength";
17
17
  /** Per-code error detail; `switch (info.code)` narrows the payload. */
18
18
  type UrErrorInfo = Readonly<{
@@ -37,14 +37,14 @@ declare class UrError extends Error {
37
37
  //#endregion
38
38
  //#region src/fountain/limits.d.ts
39
39
  /** Hard limits for adversarial multi-part streams (UR-ADR-015). */
40
- type DecoderLimits = {
40
+ type DecoderLimits = Readonly<{
41
41
  maxMessageLength: number;
42
42
  maxFragmentCount: number;
43
43
  maxFragmentLength: number;
44
44
  maxUriLength: number;
45
- };
45
+ }>;
46
46
  /**
47
- * Production default; same integers as bcur.
47
+ * Production default (1 MiB message, 2000 fragments, 8192-byte fragments and URIs), frozen.
48
48
  *
49
49
  * Hosts that need another budget pass `new UrDecoder({ limits })`.
50
50
  */
@@ -145,7 +145,7 @@ type FountainEncoderOptions = Readonly<{
145
145
  /**
146
146
  * Fountain encoder. An infinite iterator: produces parts with sequence `firstSequence + 1`, `+2`, …
147
147
  * and ends after `0xFFFFFFFF` (UR-ADR-028). For `K == 1` it keeps producing identical parts with
148
- * rising sequences.
148
+ * rising sequences. Message problems throw `UrError`; invalid options throw `RangeError`.
149
149
  */
150
150
  declare class FountainEncoder implements IterableIterator<Part> {
151
151
  #private;
@@ -1,4 +1,4 @@
1
- import { a as UrEncoderOptions, i as UrEncoder, t as DecodedUr, x as UrType } from "./index-DTjNCWBI.mjs";
1
+ import { a as UrEncoderOptions, i as UrEncoder, t as DecodedUr, x as UrType } from "./index-HtwyWL4y.mjs";
2
2
  import { Cbor, CborInput, Tag } from "@blockchaincommons/dcbor";
3
3
  //#region src/typed/ur.d.ts
4
4
  /** Uniform Resource whose payload is deterministic CBOR. */
@@ -13,7 +13,7 @@ declare class Ur {
13
13
  static parse(text: string): Ur;
14
14
  /** Wrap a completed {@link UrDecoder} result; the message must be dCBOR. */
15
15
  static fromDecoded(decoded: DecodedUr): Ur;
16
- toCborData(): Uint8Array;
16
+ toCborData(): Uint8Array<ArrayBuffer>;
17
17
  toString(): string;
18
18
  toQrString(): string;
19
19
  /** L3 encoder over this UR's dCBOR bytes. */
@@ -43,12 +43,16 @@ declare function fromUr<T>(ur: Ur, codec: UrCodec<T>): T;
43
43
  declare function toTagged<T>(value: T, codec: UrCodec<T>): Cbor;
44
44
  /** Unwraps any of the codec's tags, then decodes the body. */
45
45
  declare function fromTagged<T>(cbor: Cbor, codec: UrCodec<T>): T;
46
+ /** Value type of a codec. */
47
+ type CodecValue<C> = C extends UrCodec<infer T> ? T : never;
48
+ /** `UrType -> codec` map, typed by the union of the codecs' value types. */
49
+ type CodecMap<T> = ReadonlyMap<UrType, UrCodec<T>>;
46
50
  /** `UrType -> codec` map covering every tag name; a duplicate type is `InvalidType`. */
47
- declare function codecMap(codecs: ReadonlyArray<UrCodec<unknown>>): ReadonlyMap<UrType, UrCodec<unknown>>;
51
+ declare function codecMap<const C extends ReadonlyArray<UrCodec<unknown>>>(codecs: C): CodecMap<CodecValue<C[number]>>;
48
52
  /** Decodes `ur` through the codec registered for its type. */
49
- declare function fromUrWith(ur: Ur, codecs: ReadonlyMap<UrType, UrCodec<unknown>>): Readonly<{
53
+ declare function fromUrWith<T>(ur: Ur, codecs: CodecMap<T>): Readonly<{
50
54
  type: UrType;
51
- value: unknown;
55
+ value: T;
52
56
  }>;
53
57
  //#endregion
54
- export { fromUr as a, toUr as c, fromTagged as i, Ur as l, codecMap as n, fromUrWith as o, codecUrTypes as r, toTagged as s, UrCodec as t };
58
+ export { codecUrTypes as a, fromUrWith as c, Ur as d, codecMap as i, toTagged as l, CodecValue as n, fromTagged as o, UrCodec as r, fromUr as s, CodecMap as t, toUr as u };
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { C as parseUrType, S as isUrType, _ as UrError, a as UrEncoderOptions, b as UrLimit, c as FountainEncoder, d as FountainDecoder, f as Progress, g as DecoderLimits, h as DEFAULT_LIMITS, i as UrEncoder, l as FountainEncoderOptions, m as Part, n as UrDecoder, o as encodeUr, p as ReceiveResult, r as UrDecoderOptions, s as toQrString, t as DecodedUr, u as DecoderState, v as UrErrorCode, x as UrType, y as UrErrorInfo } from "./index-DTjNCWBI.mjs";
1
+ import { C as parseUrType, S as isUrType, _ as UrError, a as UrEncoderOptions, b as UrLimit, c as FountainEncoder, d as FountainDecoder, f as Progress, g as DecoderLimits, h as DEFAULT_LIMITS, i as UrEncoder, l as FountainEncoderOptions, m as Part, n as UrDecoder, o as encodeUr, p as ReceiveResult, r as UrDecoderOptions, s as toQrString, t as DecodedUr, u as DecoderState, v as UrErrorCode, x as UrType, y as UrErrorInfo } from "./index-HtwyWL4y.mjs";
2
2
  //#region src/consensus/crc32.d.ts
3
3
  /** CRC-32 ISO-HDLC checksum of `data`. */
4
4
  declare function checksum(data: Uint8Array): number;
@@ -26,7 +26,7 @@ export declare function bytewordsIdentifier(data: Uint8Array): string;
26
26
  /** Four-emoji identifier of a 4-byte digest (BCR-2024-008). */
27
27
  export declare function bytemojiIdentifier(data: Uint8Array): string;
28
28
  /** Decode bytewords and verify CRC-32. Case-insensitive. */
29
- export declare function decodeBytewords(text: string, style: BytewordsStyle): Uint8Array;
29
+ export declare function decodeBytewords(text: string, style: BytewordsStyle): Uint8Array<ArrayBuffer>;
30
30
  /** Canonicalize a 2–4 letter token to the full 4-letter lowercase byteword. */
31
31
  export declare function canonicalizeByteword(token: string): string | undefined;
32
32
  //#endregion
@@ -35,7 +35,7 @@ export declare function canonicalizeByteword(token: string): string | undefined;
35
35
  * Encode a part as fixed-schema deterministic CBOR: `array(5) [sequence, sequenceCount,
36
36
  * messageLength, checksum, data]` with shortest-form integers.
37
37
  */
38
- export declare function encodePart(part: Part): Uint8Array;
38
+ export declare function encodePart(part: Part): Uint8Array<ArrayBuffer>;
39
39
  /**
40
40
  * Decode a part from CBOR. Lenient on integer width (UR-ADR-017): any well-formed definite-length
41
41
  * encoding is accepted; re-encode with {@link encodePart} for the shortest form. `limits` apply
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { C as checksum, S as WORDS, _ as canonicalizeByteword, a as parseUr, b as BYTEMOJIS, c as decodePart, d as FountainDecoder, f as DEFAULT_LIMITS, g as bytewordsIdentifier, h as bytewordsEncodedLength, i as toQrString, l as encodePart, m as bytewordsChecksum, n as UrEncoder, o as isUrType, p as bytemojiIdentifier, r as encodeUr, s as parseUrType, t as UrDecoder, u as FountainEncoder, v as decodeBytewords, w as UrError, x as MINIMALS, y as encodeBytewords } from "./ur-7Ge3roVh.mjs";
1
+ import { C as checksum, S as WORDS, _ as canonicalizeByteword, a as parseUr, b as BYTEMOJIS, c as decodePart, d as FountainDecoder, f as DEFAULT_LIMITS, g as bytewordsIdentifier, h as bytewordsEncodedLength, i as toQrString, l as encodePart, m as bytewordsChecksum, n as UrEncoder, o as isUrType, p as bytemojiIdentifier, r as encodeUr, s as parseUrType, t as UrDecoder, u as FountainEncoder, v as decodeBytewords, w as UrError, x as MINIMALS, y as encodeBytewords } from "./ur-ChGW72hQ.mjs";
2
2
  export { BYTEMOJIS, DEFAULT_LIMITS, FountainDecoder, FountainEncoder, MINIMALS, UrDecoder, UrEncoder, UrError, WORDS, bytemojiIdentifier, bytewordsChecksum, bytewordsEncodedLength, bytewordsIdentifier, canonicalizeByteword, checksum as crc32, decodeBytewords, decodePart, encodeBytewords, encodePart, encodeUr, isUrType, parseUr, parseUrType, toQrString };
@@ -0,0 +1,118 @@
1
+ import { C as parseUrType, S as isUrType, _ as UrError, b as UrLimit, 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
+ import { B as cryptoKeypathCodec, N as CoinInfo, O as DerivedHdKey, R as Keypath, z as PathComponent } from "./index-DuVMkXeG.mjs";
4
+ import { Tag } from "@blockchaincommons/dcbor";
5
+ //#region src/interop/tags.d.ts
6
+ /**
7
+ * Interop (vendor-extension) tags — Keystone / OneKey / ERC-4527. `401`/`402` collide with the
8
+ * BCR-2020-010 `wsh`/`pk` script-expression tags; these types are never embedded tagged, so no
9
+ * global name registration happens here.
10
+ */
11
+ export declare const INTEROP_TAGS: Readonly<{
12
+ "crypto-multi-accounts": Tag;
13
+ "eth-sign-request": Tag;
14
+ "eth-signature": Tag;
15
+ "sol-sign-request": Tag;
16
+ "sol-signature": Tag;
17
+ "tron-sign-request": Tag;
18
+ "tron-signature": Tag;
19
+ uuid: Tag;
20
+ }>;
21
+ //#endregion
22
+ //#region src/interop/eth.d.ts
23
+ type EthDataType = "transaction" | "typedData" | "personalMessage" | "typedTransaction";
24
+ type EthSignRequest = {
25
+ readonly requestId?: Uint8Array;
26
+ readonly signData: Uint8Array;
27
+ readonly dataType: EthDataType;
28
+ readonly chainId?: number;
29
+ readonly derivationPath: Keypath;
30
+ readonly address?: Uint8Array;
31
+ readonly origin?: string;
32
+ };
33
+ type EthSignature = {
34
+ readonly requestId?: Uint8Array;
35
+ readonly signature: Uint8Array;
36
+ readonly origin?: string;
37
+ };
38
+ export declare const ethSignRequestCodec: UrCodec<EthSignRequest>;
39
+ export declare const ethSignatureCodec: UrCodec<EthSignature>;
40
+ //#endregion
41
+ //#region src/interop/sol.d.ts
42
+ type SolSignType = "transaction" | "message" | "offchainMessageLegacy" | "offchainMessageStandard";
43
+ type SolSignRequest = {
44
+ readonly requestId?: Uint8Array;
45
+ readonly signData: Uint8Array;
46
+ readonly derivationPath: Keypath;
47
+ readonly address?: Uint8Array;
48
+ readonly origin?: string;
49
+ readonly signType: SolSignType;
50
+ };
51
+ type SolSignature = {
52
+ readonly requestId?: Uint8Array;
53
+ readonly signature: Uint8Array;
54
+ };
55
+ export declare const solSignRequestCodec: UrCodec<SolSignRequest>;
56
+ export declare const solSignatureCodec: UrCodec<SolSignature>;
57
+ //#endregion
58
+ //#region src/interop/tron.d.ts
59
+ type TronDataType = "transaction" | "messageV1" | "messageV2";
60
+ type TronSignRequest = {
61
+ readonly requestId?: Uint8Array;
62
+ readonly signData: Uint8Array;
63
+ readonly dataType: TronDataType;
64
+ readonly derivationPath: Keypath;
65
+ readonly address?: Uint8Array;
66
+ readonly origin?: string;
67
+ };
68
+ type TronSignature = {
69
+ readonly requestId?: Uint8Array;
70
+ readonly signature: Uint8Array;
71
+ };
72
+ /**
73
+ * Keystone's `tron-sign-request` writer (tag 5101): `{1 uuid?, 2 signData, 3 dataType, 4 path, 5
74
+ * address?, 6 origin?}` where `dataType` is 1 transaction / 2 messageV2 — `messageV1` has no
75
+ * Keystone wire value, so both encode and decode reject it (decode would not round-trip). Reads the
76
+ * OneKey dialect too at the body level: key 3's CBOR type picks the layout, and `transaction`/
77
+ * `messageV2` OneKey bodies decode because they re-encode under this writer. `fromTagged` requires
78
+ * this codec's own tag (5101).
79
+ */
80
+ export declare const tronSignRequestCodec: UrCodec<TronSignRequest>;
81
+ /**
82
+ * OneKey's `tron-sign-request` writer (tag 5201, same UR type name): the `BaseSignRequest` layout
83
+ * `{1 uuid?, 2 signData, 3 path, 4 address?, 5 origin?, 6 requestType}` where `requestType` is 1
84
+ * transaction / 2 messageV1 / 3 messageV2. Accepts every data type and reads the Keystone dialect
85
+ * too at the body level. `fromTagged` requires this codec's own tag (5201).
86
+ */
87
+ export declare const oneKeyTronSignRequestCodec: UrCodec<TronSignRequest>;
88
+ export declare const tronSignatureCodec: UrCodec<TronSignature>;
89
+ //#endregion
90
+ //#region src/interop/multi-accounts.d.ts
91
+ type Ed25519HdKey = {
92
+ readonly isPrivate?: false;
93
+ readonly keyData: Uint8Array;
94
+ readonly chainCode?: Uint8Array;
95
+ readonly useInfo?: CoinInfo;
96
+ readonly origin?: Keypath;
97
+ readonly children?: Keypath;
98
+ readonly parentFingerprint?: number;
99
+ readonly name?: string;
100
+ readonly note?: string;
101
+ };
102
+ type MultiAccountsKey = {
103
+ readonly curve: "secp256k1";
104
+ readonly key: DerivedHdKey;
105
+ } | {
106
+ readonly curve: "ed25519";
107
+ readonly key: Ed25519HdKey;
108
+ };
109
+ type MultiAccounts = {
110
+ readonly masterFingerprint: number;
111
+ readonly keys: ReadonlyArray<MultiAccountsKey>;
112
+ readonly device?: string;
113
+ readonly deviceId?: string;
114
+ readonly version?: string;
115
+ };
116
+ export declare const cryptoMultiAccountsCodec: UrCodec<MultiAccounts>;
117
+ //#endregion
118
+ export { type CodecMap, type CodecValue, type CoinInfo, type DerivedHdKey, type Ed25519HdKey, type EthDataType, type EthSignRequest, type EthSignature, type Keypath, type MultiAccounts, type MultiAccountsKey, type PathComponent, type SolSignRequest, type SolSignType, type SolSignature, type TronDataType, type TronSignRequest, type TronSignature, Ur, type UrCodec, UrError, type UrErrorCode, type UrErrorInfo, type UrLimit, type UrType, codecMap, codecUrTypes, cryptoKeypathCodec, fromTagged, fromUr, fromUrWith, isUrType, parseUrType, toTagged, toUr };