Skip to content

Use cbor-x instead of cbor-js for CBOR encoding/decoding#34

Merged
cyraxx merged 1 commit into
mainfrom
feature/cbor-x
Jul 27, 2024
Merged

Use cbor-x instead of cbor-js for CBOR encoding/decoding#34
cyraxx merged 1 commit into
mainfrom
feature/cbor-x

Conversation

@cyraxx

@cyraxx cyraxx commented Jul 26, 2024

Copy link
Copy Markdown
Contributor

Switch to newer, well maintained library cbor-x that includes proper tagging support.

It's pretty straightforward. Only two adjustments were necessary:

  • src/cose/SigStructure.ts shows an example of CBOR encoding – it needs a special flag to properly encode Uint8Array to the format we need.
  • src/jumbf/CBORBox.ts needs to deal with the fact that cbor-x returns a special Tag object when encountering CBOR tags it doesn't natively understand.

@cyraxx cyraxx requested a review from UlrichEckhardt July 26, 2024 10:45
Comment thread package.json
"devDependencies": {
"@eslint/js": "^9.7.0",
"@ianvs/prettier-plugin-sort-imports": "^4.3.1",
"@types/cbor-js": "^0.1.1",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. :)

Comment thread src/jumbf/CBORBox.ts
this.content = cbor.decode(BinaryHelper.toArrayBuffer(buf));
this.content = cbor.decode(buf);

// Ignore unknown CBOR tags

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really unknown: Some of the JPEGs have data with tag #18 here, which is COSE_Sign1 according to this list off assigned CBOR tags. I'll add this link in the typed-binary branch.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, unknown as in „unknown by cbor-x“. The COSE data is supposed to be tagged according to the COSE RFC.

@cyraxx cyraxx merged commit b0b3d08 into main Jul 27, 2024
@cyraxx cyraxx deleted the feature/cbor-x branch July 27, 2024 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants