kernel/cbor.ts (exported as cbor) MUST read the definite-length forms of every CBOR major type (unsigned and negative integers to 64 bits, a bigint beyond the safe range; byte and text strings; arrays; maps whose keys are integers or text strings; tags; false, true, null, undefined; half, single and double floats), one item from an offset with where it ends, or one item that is the whole input; and MUST refuse, as a Result saying what and at which byte, an indefinite length, a reserved additional value, text that is not UTF-8, a key given twice or of another type, a count the bytes cannot hold, nesting deeper than 64 levels, and bytes left over. It MUST write a value in the core deterministic encoding (the shortest heads, map keys sorted by their encoded bytes).
Enforced (check): .github: cd commons/formats && bun test suite/ — kernel/cbor.test.ts: RFC 8949 Appendix A vectors read and written back, sorted map keys, an item with its end, each refusal with its byte, a round-trip property
Proved by: formats/suite/cbor.test.ts
Tests: passed: suite/cbor.test.ts RFC 8949 Appendix A: each example decoded, and the deterministic ones written back to the ; passed: suite/cbor.test.ts a map's keys are written sorted by their encoding, whatever their order in the value; passed: suite/cbor.test.ts a value no CBOR item can hold is a programming error; passed: suite/cbor.test.ts an item followed by more bytes is read with where it ends, as authenticator data needs; passed: suite/cbor.test.ts property: integers, strings, bytes, booleans, arrays and maps written then read are what t and 1 more
Cited by: cbor, Formats, Formats