Skip to content
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: dag-jose implementation using IPLD schema/code generation #23

Merged
merged 27 commits into from
Nov 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
f1fcd6d
feat: `dag-jose` implementation using IPLD schema/code generation
smrz2001 Sep 7, 2021
b492074
cleanup
smrz2001 Nov 14, 2021
f1e1565
support for "flattened" JOSE objects
smrz2001 Nov 15, 2021
9a2c58a
updates from review
smrz2001 Nov 16, 2021
4f4cc32
comments and renaming
smrz2001 Nov 16, 2021
8c43685
validate (then ignore) `link` when encoding
smrz2001 Nov 17, 2021
1e13125
updates and test fixes
smrz2001 Nov 17, 2021
9e74eec
first pass of unit tests
smrz2001 Nov 17, 2021
3176246
update dependencies
smrz2001 Nov 17, 2021
074958e
test fixes
smrz2001 Nov 19, 2021
42cd9eb
Introduce tests using fixtures from the ipld/ipld repo. (#24)
warpfork Nov 19, 2021
b8b195c
Merge remote-tracking branch 'origin/feat/dagjose-schema' into feat/d…
smrz2001 Nov 19, 2021
81244a6
test fixes
smrz2001 Nov 19, 2021
bfeb8fe
test fixes
smrz2001 Nov 19, 2021
67cf807
test fixes
smrz2001 Nov 19, 2021
837389d
test fixes
smrz2001 Nov 19, 2021
be1fa03
cleanup docs
smrz2001 Nov 23, 2021
cf9f2fd
remove `link` from encoded JWS
smrz2001 Nov 25, 2021
7b15497
fix up tests
smrz2001 Nov 25, 2021
b695464
minor updates and add TODOs
smrz2001 Nov 25, 2021
a8f96a0
add CID matching to spec tests
smrz2001 Nov 25, 2021
4bd8a79
remove travis.yml file and add TODOs to README.md
smrz2001 Nov 25, 2021
1893006
Update spec_test.go
smrz2001 Nov 26, 2021
411bf52
updates from review
smrz2001 Nov 26, 2021
5573e40
update to latest ipld repo
smrz2001 Nov 26, 2021
062415b
use newest go-ipld-prime
smrz2001 Nov 26, 2021
d17634a
check err from traversal
smrz2001 Nov 26, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule ".ipld"]
path = .ipld
url = https://github.com/ipld/ipld/
1 change: 1 addition & 0 deletions .ipld
Submodule .ipld added at 3ac8e8
13 changes: 0 additions & 13 deletions .travis.yml

This file was deleted.

64 changes: 8 additions & 56 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,62 +1,14 @@
# go-dag-jose

An implementation of the [`dag-jose`](https://github.com/ipld/specs/pull/269) multiformat for Go.
This is an implementation of the IPLD [dag-jose codec](https://ipld.io/specs/codecs/dag-jose/spec/).

## Example usage
Data that is encoded using the `dag-jose` codec is guaranteed to be a CBOR encoding of the general serialization of
either a JWE or a JWS.

To read a JWS from IPFS:
Module initialization registers the `dagjose.Encode` and `dagjose.Decode` with `go-ipld-prime`.

```go
import (
"github.com/alexjg/dagjose" cidlink "github.com/ipld/go-ipld-prime/linking/cid"
)
// Here we're creating a `CID` which points to a JWS
jwsCid, err := cid.Decode("some cid")
if err != nil {
panic(err)
}
// cidlink.Link is an implementation of `ipld.Link` backed by a CID
jwsLnk := cidlink.Link{Cid: jwsCid}
## TODOs

ls := cidlink.DefaultLinkSystem()

jose, err := dagjose.LoadJOSE(
jwsLnk,
ipld.LinkContext{},
ls, //<an implementation of ipld.Loader, which knows how to get the block data from IPFS>,
)
if err != nil {
panic(err)
}
if jose.AsJWS() != nil {
// We have a JWS object, print the general serialization of it
print(jose.AsJWS().GeneralJSONSerialization())
} else {
print("This is not a JWS")
}
```

To write a JWS to IPFS

```go
dagJws, err := dagjose.ParseJWS([]byte("<the general JSON serialization of a JWS>"))
if err != nil {
panic(err)
}
ls := cidlink.DefaultLinkSystem()
link, err := dagjose.StoreJOSE(
ipld.LinkContext{},
dagJws.AsJOSE(),
ls,
)
if err != nil {
panic(err)
}
fmt.Printf("Link is: %v", link)
```

## Changelog

This project attempts to stay up to date with changes in `go-ipld-prime`, this
means somewhat frequent API breakage as `go-ipld-prime` is not yet stable.
See [the changelog](./CHANGELOG.md).
- [ ] Add support for "compact" JWE/JWS serialization
- [ ] Add CI pipeline
- [ ] Add support for comparing recursive types in unit tests
109 changes: 0 additions & 109 deletions dagjose/dagjose.go

This file was deleted.

Loading