-
Notifications
You must be signed in to change notification settings - Fork 238
Description
If I have a DAG-CBOR block with a CID in it, it has a tag 42. This tag is not present in "vanilla" CBOR.
Currently if I request a DAG-CBOR block that contains tag 42 in the cbor format from Kubo, it happily serves me binary with tag 42 present which I then cannot deserialize it using only a vanilla CBOR parser, so the returned value is invalid, or at least close to invalid.
Compare this to DAG-JSON which may contain serialized CIDs as { "/": "QmFoo" }, which can be lossily deserialized using a vanilla JSON parser.
If the user has explicitly requested a DAG-CBOR CID in the cbor format, perhaps any CIDs present should be converted to A1 61 2F 65 Qmfoo (e.g. { "/": "QmFoo"}) so it is parsable by a CBOR parser?
Then the user could arrive back at the original bytes if they wanted to via:
- Convert DAG-CBOR bytes to CBOR bytes
- Deserialize CBOR bytes as object
- Serialize object to JSON
- Deserialize JSON to object using DAG-JSON parser
- Serialize object to DAG-CBOR
Alternatively the gateway should return a 406 if tag 42 is present in a block requested in the cbor format, since it cannot be represented as vanilla CBOR, and the user can request dag-cbor, which means they are ready and prepared to handle tag 42.