- 
                Notifications
    
You must be signed in to change notification settings  - Fork 1
 
Use cbor-x instead of cbor-js for CBOR encoding/decoding #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,5 +1,4 @@ | ||
| import cbor from 'cbor-js'; | ||
| import { BinaryHelper } from '../util'; | ||
| import * as cbor from 'cbor-x'; | ||
| import { Box } from './Box'; | ||
| 
     | 
||
| export class CBORBox extends Box { | ||
| 
        
          
        
         | 
    @@ -14,7 +13,12 @@ export class CBORBox extends Box { | |
| public parse(buf: Uint8Array) { | ||
| this.rawContent = buf; | ||
| try { | ||
| this.content = cbor.decode(BinaryHelper.toArrayBuffer(buf)); | ||
| this.content = cbor.decode(buf); | ||
| 
     | 
||
| // Ignore unknown CBOR tags | ||
| 
         There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.  | 
||
| if (this.content instanceof cbor.Tag) { | ||
| this.content = this.content.value; | ||
| } | ||
| } catch { | ||
| // TODO This needs to be properly reported as a validation error | ||
| throw new Error('CBORBox: Invalid CBOR data'); | ||
| 
          
            
          
           | 
    ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. :)