diff --git a/README.md b/README.md index ef7c35b..db2efb5 100644 --- a/README.md +++ b/README.md @@ -6,23 +6,24 @@ An implementation of the [`dag-jose`](https://github.com/ipld/specs/pull/269) mu To read a JWS from IPFS: -```go import ( "github.com/alexjg/dagjose" cidlink "github.com/ipld/go-ipld-prime/linking/cid" +```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( - "bagcqcerafzecmo67npzj56gfyukh3tbwxywgfsmxirr4oq57s6sddou4p5dq" -) +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} +ls := cidlink.DefaultLinkSystem() + jose, err := dagjose.LoadJOSE( jwsLnk, - context.Background(), ipld.LinkContext{}, - , + ls, //, ) if err != nil { panic(err) @@ -30,21 +31,23 @@ if err != nil { 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("") +dagJws, err := dagjose.ParseJWS([]byte("")) if err != nil { panic(err) } -link, err := dagjose.BuildJOSELink( - context.Background(), +ls := cidlink.DefaultLinkSystem() +link, err := dagjose.StoreJOSE( ipld.LinkContext{}, - dagJws, - + dagJws.AsJOSE(), + ls, ) if err != nil { panic(err)