-
Notifications
You must be signed in to change notification settings - Fork 41
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
feat: add DAG-JOSE implementation #177
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[package] | ||
name = "internal-package" | ||
version = "0.1.0" | ||
edition = "2021" | ||
publish = false | ||
|
||
[package.metadata.release] | ||
release = false | ||
|
||
[dependencies] | ||
libipld-core = { path = "../../../core"} | ||
libipld-cbor = { path = "../../../dag-cbor"} | ||
libipld-cbor-derive = { path = "../../../dag-cbor-derive"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
//! The purpose of this example is to test whether the derive compiles if the libipld package was | ||
//! imported from within this repo as libipld_core | ||
use libipld_cbor; | ||
use libipld_cbor_derive::DagCborInternal; | ||
|
||
#[derive(Clone, DagCborInternal, Debug, Default, PartialEq)] | ||
struct NamedStruct { | ||
boolean: bool, | ||
integer: u32, | ||
float: f64, | ||
string: String, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
[package] | ||
name = "libipld-jose" | ||
version = "0.16.0" | ||
authors = ["Nathaniel Cook <[email protected]>"] | ||
edition = "2021" | ||
license = "MIT OR Apache-2.0" | ||
description = "ipld dag-json codec" | ||
repository = "https://github.com/ipfs-rust/rust-ipld" | ||
|
||
[dependencies] | ||
anyhow = "1.0.68" | ||
base64-url = "1.4.13" | ||
libipld-core = { version = "0.16.0", path = "../core" } | ||
libipld-cbor = { version = "0.16.0", path = "../dag-cbor" } | ||
libipld-cbor-derive = { version = "0.16.0", path = "../dag-cbor-derive" } | ||
# TODO gate behind the dag-json feature flag | ||
libipld-json = { version = "0.16.0", path = "../dag-json" } | ||
multihash = "0.18.0" | ||
thiserror = "1.0.38" | ||
|
||
[dev-dependencies] | ||
libipld-json = { version = "0.16.0", path = "../dag-json" } | ||
libipld-macro = { version = "0.16.0", path = "../macro" } | ||
assert-json-diff = "2.0.2" | ||
hex = "0.4.3" | ||
once_cell = "1.17.0" | ||
serde_json = "1.0.91" | ||
testmark = {git = "https://github.com/bsundsrud/rust-testmark" } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I'm a little confused as to why this is needed. It seems like Vec is covered. Also why Box<[u8]> and not Vec.
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.
It stems from here https://github.com/ipld/libipld/blob/master/dag-cbor/src/decode.rs#L297 and here https://github.com/ipld/libipld/blob/master/dag-cbor/src/decode.rs#L321
Using a
Vec<u8>
creates an IPLD list of u8 values, where usingBox<[u8]>
creates an IPLD byte sequence.We could change the cbor Decode implementations but this was the smallest change I could make to existing code. Additionally we could try and specialize the implementation but that required Rust nightly.
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.
LIttle odd that they didn't handle Vec as a byte string, but is there a reason we need a ByteString here, and an array of u8 isn't sufficient. A large number of libraries work on Vec or bytes::Bytes, so to use this, they'll have to be regularly calling into_boxed_slice() to work with the types specified here.
dag-pb actually uses bytes::Bytes. Oddly, it also returns a Box<[u8]> for the payload here https://github.com/ipld/libipld/blob/master/dag-pb/src/codec.rs#L78 rather than the Vec or a Bytes structure.