@marcuspuchalla/nachos 0.1.1 → 0.1.3

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 (46) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/{chunk-7CFYWHS6.js → chunk-2MTLSQ7E.js} +58 -10
  3. package/dist/chunk-2MTLSQ7E.js.map +1 -0
  4. package/dist/{chunk-ZRPJUEIZ.js → chunk-5A5T56JB.js} +170 -22
  5. package/dist/chunk-5A5T56JB.js.map +1 -0
  6. package/dist/{chunk-2HBCILJS.cjs → chunk-PTWN7K3Y.cjs} +169 -21
  7. package/dist/chunk-PTWN7K3Y.cjs.map +1 -0
  8. package/dist/{chunk-2FUTHZQQ.cjs → chunk-R62CQQNI.cjs} +58 -10
  9. package/dist/chunk-R62CQQNI.cjs.map +1 -0
  10. package/dist/encoder/index.cjs +13 -13
  11. package/dist/encoder/index.js +1 -1
  12. package/dist/index.cjs +20 -20
  13. package/dist/index.d.cts +1 -1
  14. package/dist/index.d.ts +1 -1
  15. package/dist/index.js +4 -4
  16. package/dist/metafile-cjs.json +1 -1
  17. package/dist/metafile-esm.json +1 -1
  18. package/dist/parser/index.cjs +14 -14
  19. package/dist/parser/index.d.cts +1 -1
  20. package/dist/parser/index.d.ts +1 -1
  21. package/dist/parser/index.js +1 -1
  22. package/dist/{useCborTag-BfTIV8HM.d.cts → useCborTag-Cs1CZuXZ.d.cts} +2 -2
  23. package/dist/{useCborTag-B_iaShG6.d.ts → useCborTag-xV2Pz2VY.d.ts} +2 -2
  24. package/package.json +1 -1
  25. package/src/__tests__/roundtrip.test.ts +702 -0
  26. package/src/encoder/__tests__/cbor-collection-encoder.test.ts +26 -0
  27. package/src/encoder/__tests__/cbor-encoder-errors.test.ts +812 -0
  28. package/src/encoder/__tests__/cbor-string-encoder.test.ts +14 -0
  29. package/src/encoder/composables/useCborCollectionEncoder.ts +30 -0
  30. package/src/encoder/composables/useCborEncoder.ts +6 -1
  31. package/src/encoder/composables/useCborSimpleEncoder.ts +7 -2
  32. package/src/encoder/composables/useCborStringEncoder.ts +23 -10
  33. package/src/parser/__tests__/cbor-float-errors.test.ts +41 -0
  34. package/src/parser/__tests__/cbor-security-dos-protection.test.ts +2 -2
  35. package/src/parser/__tests__/cbor-standard-tags.test.ts +29 -0
  36. package/src/parser/__tests__/cbor-string-errors.test.ts +4 -4
  37. package/src/parser/__tests__/cbor-tag-errors.test.ts +1 -1
  38. package/src/parser/composables/useCborFloat.ts +93 -8
  39. package/src/parser/composables/useCborParser.ts +0 -19
  40. package/src/parser/composables/useCborString.ts +22 -4
  41. package/src/parser/composables/useCborTag.ts +104 -16
  42. package/dist/chunk-2FUTHZQQ.cjs.map +0 -1
  43. package/dist/chunk-2HBCILJS.cjs.map +0 -1
  44. package/dist/chunk-7CFYWHS6.js.map +0 -1
  45. package/dist/chunk-ZRPJUEIZ.js.map +0 -1
  46. package/src/encoder/composables/#useCborTagEncoder.ts# +0 -158
@@ -6,6 +6,7 @@
6
6
  import { describe, it, expect } from 'vitest'
7
7
  import { useCborCollectionEncoder } from '../composables/useCborCollectionEncoder'
8
8
  import type { EncodableValue } from '../types'
9
+ import { ALL_ENTRIES_SYMBOL } from '../types'
9
10
 
10
11
  describe('CBOR Collection Encoder', () => {
11
12
  describe('Arrays (Major Type 4)', () => {
@@ -122,6 +123,13 @@ describe('CBOR Collection Encoder', () => {
122
123
  expect(() => encodeArray([], { indefinite: true }))
123
124
  .toThrow('Indefinite-length encoding not allowed in canonical mode')
124
125
  })
126
+
127
+ it('should reject indefinite arrays when allowIndefinite is false', () => {
128
+ const { encodeArray } = useCborCollectionEncoder({ allowIndefinite: false })
129
+
130
+ expect(() => encodeArray([], { indefinite: true }))
131
+ .toThrow('Indefinite-length encoding is not allowed')
132
+ })
125
133
  })
126
134
  })
127
135
 
@@ -258,6 +266,24 @@ describe('CBOR Collection Encoder', () => {
258
266
  expect(() => encodeMap({}, { indefinite: true }))
259
267
  .toThrow('Indefinite-length encoding not allowed in canonical mode')
260
268
  })
269
+
270
+ it('should reject indefinite maps when allowIndefinite is false', () => {
271
+ const { encodeMap } = useCborCollectionEncoder({ allowIndefinite: false })
272
+
273
+ expect(() => encodeMap({}, { indefinite: true }))
274
+ .toThrow('Indefinite-length encoding is not allowed')
275
+ })
276
+ })
277
+
278
+ describe('Duplicate key handling', () => {
279
+ it('should reject duplicate keys when rejectDuplicateKeys is true', () => {
280
+ const { encodeMap } = useCborCollectionEncoder({ rejectDuplicateKeys: true })
281
+ const map = new Map<EncodableValue, EncodableValue>([['a', 1]])
282
+ ;(map as any)[ALL_ENTRIES_SYMBOL] = [['a', 1], ['a', 2]]
283
+
284
+ expect(() => encodeMap(map))
285
+ .toThrow('Duplicate map key detected')
286
+ })
261
287
  })
262
288
  })
263
289