@marcuspuchalla/nachos 0.1.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.
Files changed (100) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/LICENSE +674 -0
  3. package/README.md +345 -0
  4. package/dist/chunk-2FUTHZQQ.cjs +755 -0
  5. package/dist/chunk-2FUTHZQQ.cjs.map +1 -0
  6. package/dist/chunk-2HBCILJS.cjs +2034 -0
  7. package/dist/chunk-2HBCILJS.cjs.map +1 -0
  8. package/dist/chunk-7CFYWHS6.js +742 -0
  9. package/dist/chunk-7CFYWHS6.js.map +1 -0
  10. package/dist/chunk-PD72MVTX.cjs +160 -0
  11. package/dist/chunk-PD72MVTX.cjs.map +1 -0
  12. package/dist/chunk-ZDZ2B5PE.js +149 -0
  13. package/dist/chunk-ZDZ2B5PE.js.map +1 -0
  14. package/dist/chunk-ZRPJUEIZ.js +2020 -0
  15. package/dist/chunk-ZRPJUEIZ.js.map +1 -0
  16. package/dist/encoder/index.cjs +57 -0
  17. package/dist/encoder/index.cjs.map +1 -0
  18. package/dist/encoder/index.d.cts +72 -0
  19. package/dist/encoder/index.d.ts +72 -0
  20. package/dist/encoder/index.js +4 -0
  21. package/dist/encoder/index.js.map +1 -0
  22. package/dist/index.cjs +606 -0
  23. package/dist/index.cjs.map +1 -0
  24. package/dist/index.d.cts +494 -0
  25. package/dist/index.d.ts +494 -0
  26. package/dist/index.js +523 -0
  27. package/dist/index.js.map +1 -0
  28. package/dist/metafile-cjs.json +1 -0
  29. package/dist/metafile-esm.json +1 -0
  30. package/dist/parser/index.cjs +85 -0
  31. package/dist/parser/index.cjs.map +1 -0
  32. package/dist/parser/index.d.cts +72 -0
  33. package/dist/parser/index.d.ts +72 -0
  34. package/dist/parser/index.js +4 -0
  35. package/dist/parser/index.js.map +1 -0
  36. package/dist/types-DvNlfbKB.d.cts +301 -0
  37. package/dist/types-DvNlfbKB.d.ts +301 -0
  38. package/dist/useCborSimpleEncoder-ButVU988.d.cts +268 -0
  39. package/dist/useCborSimpleEncoder-TVxzNJ_9.d.ts +268 -0
  40. package/dist/useCborTag-B_iaShG6.d.ts +142 -0
  41. package/dist/useCborTag-BfTIV8HM.d.cts +142 -0
  42. package/package.json +102 -0
  43. package/src/__tests__/public-api.test.ts +326 -0
  44. package/src/encoder/__tests__/cbor-collection-encoder.test.ts +331 -0
  45. package/src/encoder/__tests__/cbor-integer-encoder.test.ts +283 -0
  46. package/src/encoder/__tests__/cbor-simple-encoder.test.ts +224 -0
  47. package/src/encoder/__tests__/cbor-string-encoder.test.ts +345 -0
  48. package/src/encoder/__tests__/cbor-tag-encoder.test.ts +565 -0
  49. package/src/encoder/composables/#useCborTagEncoder.ts# +158 -0
  50. package/src/encoder/composables/useCborCollectionEncoder.ts +424 -0
  51. package/src/encoder/composables/useCborEncoder.ts +203 -0
  52. package/src/encoder/composables/useCborIntegerEncoder.ts +188 -0
  53. package/src/encoder/composables/useCborSimpleEncoder.ts +266 -0
  54. package/src/encoder/composables/useCborStringEncoder.ts +266 -0
  55. package/src/encoder/composables/useCborTagEncoder.ts +158 -0
  56. package/src/encoder/index.ts +35 -0
  57. package/src/encoder/types.ts +88 -0
  58. package/src/encoder/utils.ts +80 -0
  59. package/src/index.ts +434 -0
  60. package/src/parser/__tests__/ast-tree-structure.test.ts +311 -0
  61. package/src/parser/__tests__/cbor-collection-errors.test.ts +296 -0
  62. package/src/parser/__tests__/cbor-collection.test.ts +369 -0
  63. package/src/parser/__tests__/cbor-deterministic-encoding.test.ts +432 -0
  64. package/src/parser/__tests__/cbor-diagnostic.test.ts +333 -0
  65. package/src/parser/__tests__/cbor-duplicate-keys.test.ts +235 -0
  66. package/src/parser/__tests__/cbor-float-errors.test.ts +222 -0
  67. package/src/parser/__tests__/cbor-float.test.ts +502 -0
  68. package/src/parser/__tests__/cbor-integer-errors.test.ts +139 -0
  69. package/src/parser/__tests__/cbor-integer.test.ts +200 -0
  70. package/src/parser/__tests__/cbor-map-duplicate-keys.test.ts +403 -0
  71. package/src/parser/__tests__/cbor-parser-errors.test.ts +126 -0
  72. package/src/parser/__tests__/cbor-security-dos-protection.test.ts +503 -0
  73. package/src/parser/__tests__/cbor-sequences.test.ts +150 -0
  74. package/src/parser/__tests__/cbor-source-map.test.ts +321 -0
  75. package/src/parser/__tests__/cbor-standard-tags.test.ts +340 -0
  76. package/src/parser/__tests__/cbor-string-errors.test.ts +227 -0
  77. package/src/parser/__tests__/cbor-string.test.ts +224 -0
  78. package/src/parser/__tests__/cbor-tag-advanced.test.ts +500 -0
  79. package/src/parser/__tests__/cbor-tag-errors.test.ts +447 -0
  80. package/src/parser/__tests__/cbor-tag-source-map.test.ts +360 -0
  81. package/src/parser/__tests__/cbor-tag.test.ts +684 -0
  82. package/src/parser/__tests__/extreme-edge-cases.test.ts +146 -0
  83. package/src/parser/__tests__/pathBuilder.test.ts +256 -0
  84. package/src/parser/__tests__/rfc-test-vectors.test.ts +607 -0
  85. package/src/parser/__tests__/security-limits.test.ts +248 -0
  86. package/src/parser/__tests__/utils-errors.test.ts +127 -0
  87. package/src/parser/composables/useCborCollection.ts +509 -0
  88. package/src/parser/composables/useCborDiagnostic.ts +381 -0
  89. package/src/parser/composables/useCborFloat.ts +256 -0
  90. package/src/parser/composables/useCborInteger.ts +114 -0
  91. package/src/parser/composables/useCborParser.ts +951 -0
  92. package/src/parser/composables/useCborString.ts +330 -0
  93. package/src/parser/composables/useCborStringTypes.ts +129 -0
  94. package/src/parser/composables/useCborTag.ts +739 -0
  95. package/src/parser/index.ts +56 -0
  96. package/src/parser/types.ts +371 -0
  97. package/src/parser/utils/pathBuilder.ts +259 -0
  98. package/src/parser/utils.ts +398 -0
  99. package/src/utils/__tests__/logger.test.ts +186 -0
  100. package/src/utils/logger.ts +96 -0
@@ -0,0 +1,301 @@
1
+ /**
2
+ * CBOR Parser Type Definitions
3
+ * Following RFC 8949 specification
4
+ */
5
+ /**
6
+ * Parser resource limits for DoS protection
7
+ */
8
+ interface ParserLimits {
9
+ /** Maximum input size in bytes (default: 10 MB) */
10
+ maxInputSize?: number;
11
+ /** Maximum output size in bytes (default: 100 MB) */
12
+ maxOutputSize?: number;
13
+ /** Maximum string length in bytes (default: 1 MB) */
14
+ maxStringLength?: number;
15
+ /** Maximum array length (default: 10,000) */
16
+ maxArrayLength?: number;
17
+ /** Maximum map size (default: 10,000) */
18
+ maxMapSize?: number;
19
+ /** Maximum nesting depth for arrays/maps (default: 100) */
20
+ maxDepth?: number;
21
+ /** Maximum tag nesting depth (default: 100) - Prevents RUSTSEC-2019-0025 */
22
+ maxTagDepth?: number;
23
+ /** Maximum bignum size in bytes for tags 2/3 (default: 1024 bytes = 8192 bits) - Prevents CVE-2020-28491 */
24
+ maxBignumBytes?: number;
25
+ /** Maximum parse time in milliseconds (default: 1000) */
26
+ maxParseTime?: number;
27
+ }
28
+ /**
29
+ * Duplicate map key handling modes
30
+ * Following RFC 8949 Section 5.6 guidance
31
+ */
32
+ type DupMapKeyMode = 'allow' | 'warn' | 'reject';
33
+ /**
34
+ * Parser options for controlling behavior
35
+ */
36
+ interface ParseOptions {
37
+ /** Enable strict Cardano mode (all validations) */
38
+ strict?: boolean;
39
+ /** Validate canonical encoding (shortest form, sorted maps) */
40
+ validateCanonical?: boolean;
41
+ /** Allow indefinite-length encoding (false in strict mode) */
42
+ allowIndefinite?: boolean;
43
+ /**
44
+ * Duplicate map key handling (RFC 8949 Section 5.6)
45
+ * - 'allow': Allow duplicates (default, permissive)
46
+ * - 'warn': Warn on duplicates but continue parsing
47
+ * - 'reject': Throw error on duplicate keys (strict mode)
48
+ */
49
+ dupMapKeyMode?: DupMapKeyMode;
50
+ /** Validate UTF-8 strictly (reject overlongs) */
51
+ validateUtf8Strict?: boolean;
52
+ /** Validate set uniqueness (Tag 258 - reject duplicates) */
53
+ validateSetUniqueness?: boolean;
54
+ /** Validate semantic tag constraints (Tag 4, Tag 5 array structure) */
55
+ validateTagSemantics?: boolean;
56
+ /** Validate Plutus constructor semantics (Tags 102, 121-127, 1280-1400) */
57
+ validatePlutusSemantics?: boolean;
58
+ /** Resource limits */
59
+ limits?: ParserLimits;
60
+ }
61
+ /**
62
+ * Default resource limits for parser
63
+ */
64
+ declare const DEFAULT_LIMITS: Required<ParserLimits>;
65
+ /**
66
+ * Default parse options
67
+ */
68
+ declare const DEFAULT_OPTIONS: Required<ParseOptions>;
69
+ /**
70
+ * Parsing context that tracks state during CBOR decoding
71
+ */
72
+ interface CborContext {
73
+ /** Raw byte buffer */
74
+ buffer: Uint8Array;
75
+ /** Current byte offset */
76
+ offset: number;
77
+ /** Source map entries for visualization */
78
+ sourceMap: SourceMapEntry[];
79
+ /** Current nesting depth for arrays/maps (for limit checking) */
80
+ currentDepth?: number;
81
+ /** Current tag nesting depth (for tag limit checking) */
82
+ currentTagDepth?: number;
83
+ /** Parse start time (for timeout checking) */
84
+ startTime?: number;
85
+ /** Bytes allocated (for output size tracking) */
86
+ bytesAllocated?: number;
87
+ /** Parser options */
88
+ options?: ParseOptions;
89
+ }
90
+ /**
91
+ * Result of parsing a CBOR value
92
+ */
93
+ interface ParseResult {
94
+ /** Decoded CBOR value */
95
+ value: CborValue;
96
+ /** Number of bytes consumed */
97
+ bytesRead: number;
98
+ }
99
+ /**
100
+ * Parse result with source mapping information
101
+ */
102
+ interface ParseResultWithMap extends ParseResult {
103
+ /** Source map for hex/JSON linking */
104
+ sourceMap: SourceMapEntry[];
105
+ }
106
+ /**
107
+ * Source map entry for bi-directional visualization
108
+ */
109
+ interface SourceMapEntry {
110
+ /** JSON Pointer path (RFC 6901) */
111
+ path: string;
112
+ /** Starting byte offset */
113
+ start: number;
114
+ /** Ending byte offset (exclusive) */
115
+ end: number;
116
+ /** CBOR major type (0-7) */
117
+ majorType: number;
118
+ /** Human-readable type description */
119
+ type: string;
120
+ /** Parent entry path (for nested structures like tags) */
121
+ parent?: string;
122
+ /** Child entry paths (for container types) */
123
+ children?: string[];
124
+ /** Whether this entry represents a header (initial byte + length info) */
125
+ isHeader?: boolean;
126
+ /** Whether this entry represents content (payload data) */
127
+ isContent?: boolean;
128
+ /** Byte offset where header ends and content begins */
129
+ headerEnd?: number;
130
+ /** JSON Pointer path to the content portion (for split header/content entries) */
131
+ contentPath?: string;
132
+ }
133
+ /**
134
+ * CBOR byte string (can be definite or indefinite length)
135
+ */
136
+ interface CborByteString {
137
+ readonly type: 'cbor-byte-string';
138
+ readonly bytes: Uint8Array;
139
+ readonly chunks?: Uint8Array[];
140
+ [INDEFINITE_SYMBOL]?: boolean;
141
+ }
142
+ /**
143
+ * CBOR text string (can be definite or indefinite length)
144
+ */
145
+ interface CborTextString {
146
+ readonly type: 'cbor-text-string';
147
+ readonly text: string;
148
+ readonly chunks?: string[];
149
+ [INDEFINITE_SYMBOL]?: boolean;
150
+ }
151
+ /**
152
+ * All possible CBOR values
153
+ */
154
+ type CborValue = number | bigint | string | boolean | null | undefined | Uint8Array | CborByteString | CborTextString | CborValue[] | CborMap | TaggedValue | SimpleValue;
155
+ /**
156
+ * Symbol to mark arrays/maps as indefinite-length encoded
157
+ * This allows round-trip preservation of encoding style
158
+ */
159
+ declare const INDEFINITE_SYMBOL: unique symbol;
160
+ /**
161
+ * CBOR map type (Map with any CBOR value as keys)
162
+ *
163
+ * Uses JavaScript Map to preserve key types (integers, Uint8Arrays, etc.)
164
+ * This is essential for:
165
+ * - Cardano transactions (use integer keys 0-18)
166
+ * - Round-trip encoding (must preserve exact key types)
167
+ * - CBOR specification compliance (maps can have any type as keys)
168
+ *
169
+ * @example
170
+ * ```typescript
171
+ * // Cardano transaction body
172
+ * new Map([
173
+ * [0, inputs], // Integer key
174
+ * [1, outputs], // Integer key
175
+ * [2, 1000000] // Integer key (fee)
176
+ * ])
177
+ * ```
178
+ */
179
+ type CborMap = Map<CborValue, CborValue> & {
180
+ [INDEFINITE_SYMBOL]?: boolean;
181
+ };
182
+ /**
183
+ * Tagged CBOR value (Major Type 6)
184
+ */
185
+ interface TaggedValue {
186
+ tag: number;
187
+ value: CborValue;
188
+ plutus?: PlutusConstr;
189
+ }
190
+ /**
191
+ * Simple CBOR value (Major Type 7, unassigned simple values)
192
+ */
193
+ interface SimpleValue {
194
+ simpleValue: number;
195
+ }
196
+ /**
197
+ * Plutus Data types for Cardano smart contracts
198
+ */
199
+ type PlutusData = PlutusConstr | PlutusMap | PlutusList | PlutusInt | PlutusBytes;
200
+ /**
201
+ * Plutus Constructor (algebraic data type)
202
+ */
203
+ interface PlutusConstr {
204
+ constructor: number;
205
+ fields: PlutusData[];
206
+ }
207
+ /**
208
+ * Plutus Map (key-value pairs)
209
+ */
210
+ interface PlutusMap {
211
+ entries: Array<[PlutusData, PlutusData]>;
212
+ }
213
+ /**
214
+ * Plutus List (sequential collection)
215
+ */
216
+ type PlutusList = PlutusData[];
217
+ /**
218
+ * Plutus Integer (arbitrary precision)
219
+ */
220
+ type PlutusInt = number | bigint;
221
+ /**
222
+ * Plutus Bytes (bounded byte string, max 64 bytes)
223
+ */
224
+ type PlutusBytes = Uint8Array;
225
+ /**
226
+ * CBOR Major Types (0-7)
227
+ */
228
+ declare enum CborMajorType {
229
+ UNSIGNED_INT = 0,
230
+ NEGATIVE_INT = 1,
231
+ BYTE_STRING = 2,
232
+ TEXT_STRING = 3,
233
+ ARRAY = 4,
234
+ MAP = 5,
235
+ TAG = 6,
236
+ SIMPLE = 7
237
+ }
238
+ /**
239
+ * Additional Information values
240
+ */
241
+ declare enum CborAdditionalInfo {
242
+ DIRECT = 23,// Values 0-23
243
+ ONE_BYTE = 24,// 1 byte follows
244
+ TWO_BYTES = 25,// 2 bytes follow
245
+ FOUR_BYTES = 26,// 4 bytes follow
246
+ EIGHT_BYTES = 27,// 8 bytes follow
247
+ INDEFINITE = 31
248
+ }
249
+ /**
250
+ * Simple values (Major Type 7)
251
+ */
252
+ declare enum CborSimpleValue {
253
+ FALSE = 20,
254
+ TRUE = 21,
255
+ NULL = 22,
256
+ UNDEFINED = 23,
257
+ FLOAT16 = 25,
258
+ FLOAT32 = 26,
259
+ FLOAT64 = 27,
260
+ BREAK = 31
261
+ }
262
+ /**
263
+ * Common semantic tags
264
+ */
265
+ declare enum CborTag {
266
+ DATE_TIME_STRING = 0,
267
+ EPOCH_DATE_TIME = 1,
268
+ POSITIVE_BIGNUM = 2,
269
+ NEGATIVE_BIGNUM = 3,
270
+ DECIMAL_FRACTION = 4,
271
+ BIGFLOAT = 5,
272
+ BASE64URL = 21,
273
+ BASE64 = 22,
274
+ BASE16 = 23,
275
+ CBOR_ENCODED = 24,
276
+ URI = 32,
277
+ BASE64URL_NO_PAD = 33,
278
+ BASE64_NO_PAD = 34,
279
+ REGEXP = 35,
280
+ MIME_MESSAGE = 36
281
+ }
282
+ /**
283
+ * Parse error types
284
+ */
285
+ interface ParseError {
286
+ type: 'INVALID_HEX' | 'UNEXPECTED_EOF' | 'INVALID_CBOR' | 'UNSUPPORTED_TYPE';
287
+ message: string;
288
+ offset?: number;
289
+ }
290
+ /**
291
+ * Result type for operations that can fail
292
+ */
293
+ type Result<T, E> = {
294
+ success: true;
295
+ value: T;
296
+ } | {
297
+ success: false;
298
+ error: E;
299
+ };
300
+
301
+ export { type CborContext as C, DEFAULT_OPTIONS as D, type ParseOptions as P, type Result as R, type SourceMapEntry as S, type TaggedValue as T, type ParseResult as a, type ParseResultWithMap as b, type ParseError as c, type ParserLimits as d, type CborValue as e, type CborMap as f, type PlutusData as g, type PlutusConstr as h, type PlutusMap as i, type PlutusList as j, type PlutusInt as k, type PlutusBytes as l, DEFAULT_LIMITS as m, CborMajorType as n, CborAdditionalInfo as o, CborSimpleValue as p, CborTag as q, type DupMapKeyMode as r, type CborByteString as s, type CborTextString as t };
@@ -0,0 +1,268 @@
1
+ import { h as PlutusConstr, s as CborByteString, t as CborTextString } from './types-DvNlfbKB.cjs';
2
+
3
+ /**
4
+ * CBOR Encoder Type Definitions
5
+ * Following RFC 8949 specification
6
+ */
7
+
8
+ /**
9
+ * Encoder options for controlling behavior
10
+ */
11
+ interface EncodeOptions {
12
+ /** Enable canonical encoding (shortest form, sorted maps) */
13
+ canonical?: boolean;
14
+ /** Allow indefinite-length encoding (false in canonical mode) */
15
+ allowIndefinite?: boolean;
16
+ /** Reject duplicate map keys */
17
+ rejectDuplicateKeys?: boolean;
18
+ /** Maximum nesting depth */
19
+ maxDepth?: number;
20
+ /** Maximum output size in bytes */
21
+ maxOutputSize?: number;
22
+ }
23
+ /**
24
+ * Default encode options
25
+ */
26
+ declare const DEFAULT_ENCODE_OPTIONS: Required<EncodeOptions>;
27
+ /**
28
+ * Result of encoding operation
29
+ */
30
+ interface EncodeResult {
31
+ /** Encoded CBOR bytes */
32
+ bytes: Uint8Array;
33
+ /** Hex string representation */
34
+ hex: string;
35
+ }
36
+ /**
37
+ * Values that can be encoded to CBOR
38
+ *
39
+ * Supports both plain objects (for convenience) and Maps (for type preservation).
40
+ * Map<any, any> is preferred for maps with non-string keys (integers, Uint8Arrays, etc.)
41
+ */
42
+ type EncodableValue = number | bigint | string | boolean | null | undefined | Uint8Array | EncodableValue[] | {
43
+ [key: string]: EncodableValue;
44
+ } | Map<EncodableValue, EncodableValue> | TaggedValue;
45
+ /**
46
+ * Tagged CBOR value (Major Type 6)
47
+ */
48
+ interface TaggedValue {
49
+ tag: number;
50
+ value: EncodableValue;
51
+ plutus?: PlutusConstr;
52
+ }
53
+ /**
54
+ * Encoding context that tracks state during CBOR encoding
55
+ */
56
+ interface EncodeContext {
57
+ /** Current nesting depth */
58
+ depth: number;
59
+ /** Bytes written so far */
60
+ bytesWritten: number;
61
+ /** Encoder options */
62
+ options: Required<EncodeOptions>;
63
+ }
64
+
65
+ /**
66
+ * Main CBOR Encoder Composable
67
+ * High-level API for encoding JavaScript values to CBOR
68
+ * Following RFC 8949 specification
69
+ */
70
+
71
+ /**
72
+ * Main CBOR Encoder Composable
73
+ *
74
+ * Provides a unified interface for encoding any JavaScript value to CBOR.
75
+ * Automatically selects the appropriate encoder based on value type.
76
+ *
77
+ * @param options - Global encoder options
78
+ *
79
+ * @example
80
+ * ```ts
81
+ * const { encode } = useCborEncoder()
82
+ *
83
+ * // Encode various types
84
+ * encode(42) // Integer
85
+ * encode("hello") // Text string
86
+ * encode([1, 2, 3]) // Array
87
+ * encode({ a: 1 }) // Map
88
+ * encode(true) // Boolean
89
+ * encode(3.14) // Float
90
+ * encode(new Uint8Array([0xff])) // Byte string
91
+ *
92
+ * // With options
93
+ * const { encode: encodeCanonical } = useCborEncoder({ canonical: true })
94
+ * encodeCanonical({ z: 1, a: 2 }) // Keys will be sorted
95
+ * ```
96
+ */
97
+ declare function useCborEncoder(globalOptions?: Partial<EncodeOptions>): {
98
+ encode: (value: EncodableValue) => EncodeResult;
99
+ encodeToHex: (value: EncodableValue) => string;
100
+ encodeToBytes: (value: EncodableValue) => Uint8Array;
101
+ encodeSequence: (values: EncodableValue[]) => EncodeResult;
102
+ };
103
+
104
+ /**
105
+ * CBOR Integer Encoder Composable
106
+ * Handles Major Type 0 (Unsigned) and Major Type 1 (Negative)
107
+ * Following RFC 8949 specification
108
+ */
109
+
110
+ /**
111
+ * CBOR Integer Encoder Composable
112
+ *
113
+ * Provides functions to encode integers to CBOR format:
114
+ * - Major Type 0: Unsigned integers (0 to 2^64-1)
115
+ * - Major Type 1: Negative integers (-1 to -2^64)
116
+ *
117
+ * @example
118
+ * ```ts
119
+ * const { encodeUnsignedInt, encodeNegativeInt, encodeInteger } = useCborIntegerEncoder()
120
+ *
121
+ * // Encode unsigned integer
122
+ * const result1 = encodeUnsignedInt(100)
123
+ * // result1: { bytes: Uint8Array([0x18, 0x64]), hex: '1864' }
124
+ *
125
+ * // Encode negative integer
126
+ * const result2 = encodeNegativeInt(-100)
127
+ * // result2: { bytes: Uint8Array([0x38, 0x63]), hex: '3863' }
128
+ *
129
+ * // Auto-detect integer type
130
+ * const result3 = encodeInteger(-100)
131
+ * // result3: { bytes: Uint8Array([0x38, 0x63]), hex: '3863' }
132
+ * ```
133
+ */
134
+ declare function useCborIntegerEncoder(): {
135
+ encodeUnsignedInt: (value: number | bigint) => EncodeResult;
136
+ encodeNegativeInt: (value: number | bigint) => EncodeResult;
137
+ encodeInteger: (value: number | bigint) => EncodeResult;
138
+ };
139
+
140
+ /**
141
+ * CBOR String Encoder Composable
142
+ * Handles Major Type 2 (Byte Strings) and Major Type 3 (Text Strings)
143
+ * Following RFC 8949 specification
144
+ */
145
+
146
+ interface StringEncodeOptions {
147
+ indefinite?: boolean;
148
+ }
149
+ /**
150
+ * CBOR String Encoder Composable
151
+ *
152
+ * Provides functions to encode byte strings and text strings:
153
+ * - Major Type 2: Byte strings (Uint8Array)
154
+ * - Major Type 3: Text strings (UTF-8 encoded)
155
+ *
156
+ * Supports both definite-length and indefinite-length encoding.
157
+ *
158
+ * @param options - Global encoder options
159
+ *
160
+ * @example
161
+ * ```ts
162
+ * const { encodeByteString, encodeTextString } = useCborStringEncoder()
163
+ *
164
+ * // Encode byte string
165
+ * const bytes = new Uint8Array([0x01, 0x02, 0x03])
166
+ * const result1 = encodeByteString(bytes)
167
+ * // result1: { bytes: Uint8Array([0x43, 0x01, 0x02, 0x03]), hex: '43010203' }
168
+ *
169
+ * // Encode text string
170
+ * const result2 = encodeTextString('Hello')
171
+ * // result2: { bytes: Uint8Array([0x65, 0x48, 0x65, 0x6c, 0x6c, 0x6f]), hex: '6548656c6c6f' }
172
+ *
173
+ * // Indefinite-length encoding
174
+ * const chunks = [new Uint8Array([0xaa]), new Uint8Array([0xbb])]
175
+ * const result3 = encodeByteStringIndefinite(chunks)
176
+ * // result3: { bytes: Uint8Array([0x5f, 0x41, 0xaa, 0x41, 0xbb, 0xff]), hex: '5f41aa41bbff' }
177
+ * ```
178
+ */
179
+ declare function useCborStringEncoder(globalOptions?: Partial<EncodeOptions>): {
180
+ encodeByteString: (data: Uint8Array | Uint8Array[] | CborByteString, encodeOptions?: StringEncodeOptions) => EncodeResult;
181
+ encodeByteStringIndefinite: (chunks: Uint8Array[]) => EncodeResult;
182
+ encodeTextString: (text: string | CborTextString, encodeOptions?: StringEncodeOptions) => EncodeResult;
183
+ encodeTextStringIndefinite: (chunks: string[]) => EncodeResult;
184
+ };
185
+
186
+ /**
187
+ * CBOR Collection Encoder Composable
188
+ * Handles Major Type 4 (Arrays) and Major Type 5 (Maps)
189
+ * Following RFC 8949 specification
190
+ */
191
+
192
+ interface CollectionEncodeOptions {
193
+ indefinite?: boolean;
194
+ }
195
+ /**
196
+ * CBOR Collection Encoder Composable
197
+ *
198
+ * Provides functions to encode arrays and maps:
199
+ * - Major Type 4: Arrays
200
+ * - Major Type 5: Maps (objects or Map instances)
201
+ *
202
+ * Supports both definite-length and indefinite-length encoding.
203
+ * Handles canonical encoding with sorted map keys.
204
+ * Enforces depth and size limits.
205
+ *
206
+ * @param options - Global encoder options
207
+ *
208
+ * @example
209
+ * ```ts
210
+ * const { encodeArray, encodeMap } = useCborCollectionEncoder()
211
+ *
212
+ * // Encode array
213
+ * const arr = [1, 2, 3]
214
+ * const result1 = encodeArray(arr)
215
+ * // result1: { bytes: Uint8Array([0x83, 0x01, 0x02, 0x03]), hex: '83010203' }
216
+ *
217
+ * // Encode map
218
+ * const map = { amount: 1000000 }
219
+ * const result2 = encodeMap(map)
220
+ * // result2: { bytes: ..., hex: 'a166616d6f756e741a000f4240' }
221
+ * ```
222
+ */
223
+ declare function useCborCollectionEncoder(globalOptions?: Partial<EncodeOptions>): {
224
+ encodeArray: (array: EncodableValue[], encodeOptions?: CollectionEncodeOptions) => EncodeResult;
225
+ encodeArrayIndefinite: (array: EncodableValue[]) => EncodeResult;
226
+ encodeMap: (map: Map<EncodableValue, EncodableValue> | {
227
+ [key: string]: EncodableValue;
228
+ }, encodeOptions?: CollectionEncodeOptions) => EncodeResult;
229
+ encodeMapIndefinite: (map: Map<EncodableValue, EncodableValue> | {
230
+ [key: string]: EncodableValue;
231
+ }) => EncodeResult;
232
+ setMainEncode: (encodeFn: (value: EncodableValue) => EncodeResult) => void;
233
+ };
234
+
235
+ /**
236
+ * CBOR Simple Values and Floats Encoder Composable
237
+ * Handles Major Type 7 (Floats and Simple Values)
238
+ * Following RFC 8949 specification
239
+ */
240
+
241
+ /**
242
+ * CBOR Simple Values and Floats Encoder Composable
243
+ *
244
+ * Provides functions to encode:
245
+ * - Simple values: false, true, null, undefined
246
+ * - Floating-point numbers: float16, float32, float64
247
+ *
248
+ * @param options - Global encoder options
249
+ *
250
+ * @example
251
+ * ```ts
252
+ * const { encodeSimple, encodeFloat } = useCborSimpleEncoder()
253
+ *
254
+ * // Encode simple values
255
+ * const result1 = encodeSimple(true)
256
+ * // result1: { bytes: Uint8Array([0xf5]), hex: 'f5' }
257
+ *
258
+ * // Encode float
259
+ * const result2 = encodeFloat(1.1)
260
+ * // result2: { bytes: Uint8Array([0xfb, ...]), hex: 'fb...' }
261
+ * ```
262
+ */
263
+ declare function useCborSimpleEncoder(_globalOptions?: Partial<EncodeOptions>): {
264
+ encodeSimple: (value: boolean | null | undefined) => EncodeResult;
265
+ encodeFloat: (value: number, precision?: 16 | 32 | 64) => EncodeResult;
266
+ };
267
+
268
+ export { DEFAULT_ENCODE_OPTIONS as D, type EncodableValue as E, type TaggedValue as T, type EncodeOptions as a, type EncodeResult as b, useCborIntegerEncoder as c, useCborStringEncoder as d, useCborCollectionEncoder as e, useCborSimpleEncoder as f, type EncodeContext as g, useCborEncoder as u };