-
Notifications
You must be signed in to change notification settings - Fork 107
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
fix: @helia/* modules validate CID codec #643
base: main
Are you sure you want to change the base?
Conversation
if (cid.code !== jsonCodec.code) { | ||
throw new TypeError('The passed CID had an incorrect codec, it may correspond to a non-JSON block') | ||
} | ||
|
||
const buf = await this.components.blockstore.get(cid, options) |
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.
Checks that the codec codes match inside of the JSON.get implementation.
@@ -115,6 +115,10 @@ class DefaultJSON implements JSON { | |||
} | |||
|
|||
async get <T> (cid: CID, options: Partial<GetOptions> = {}): Promise<T> { |
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.
Random question, was looking at the GetOptions type. It contains codec: BlockCodec
property which is passed to the blockstore.get
call. Is this ever used?
Before I finish the other modules, does this approach look ok? |
This looks good to me. It should be pretty straightforward |
The |
|
Removing |
Title
fix: @helia/* modules validate CID codec
Description
Closes: #377
@helia/* modules related to importing structured data, e.g. @helia/json; @helia/strings, check CID that is handed to
.get
method.If the CID code does not match the codec of the importer then it rejects with a TypeError.
@helia/unixfsNotes & open questions
Change checklist