update go-varsig, go-did-it, add missing resolution options
This commit is contained in:
6
go.mod
6
go.mod
@@ -5,14 +5,15 @@ go 1.24.4
|
|||||||
toolchain go1.24.5
|
toolchain go1.24.5
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/MetaMask/go-did-it v0.0.0-20250730165819-a7ebe989e01b
|
github.com/MetaMask/go-did-it v1.0.0-pre1
|
||||||
github.com/ipfs/go-cid v0.5.0
|
github.com/ipfs/go-cid v0.5.0
|
||||||
github.com/ipld/go-ipld-prime v0.21.0
|
github.com/ipld/go-ipld-prime v0.21.0
|
||||||
github.com/multiformats/go-multibase v0.2.0
|
github.com/multiformats/go-multibase v0.2.0
|
||||||
github.com/multiformats/go-multicodec v0.9.0
|
github.com/multiformats/go-multicodec v0.9.0
|
||||||
github.com/multiformats/go-multihash v0.2.3
|
github.com/multiformats/go-multihash v0.2.3
|
||||||
|
github.com/multiformats/go-varint v0.0.7
|
||||||
github.com/stretchr/testify v1.10.0
|
github.com/stretchr/testify v1.10.0
|
||||||
github.com/ucan-wg/go-varsig v1.0.0-pre6
|
github.com/ucan-wg/go-varsig v1.0.0
|
||||||
golang.org/x/crypto v0.40.0
|
golang.org/x/crypto v0.40.0
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -24,7 +25,6 @@ require (
|
|||||||
github.com/mr-tron/base58 v1.2.0 // indirect
|
github.com/mr-tron/base58 v1.2.0 // indirect
|
||||||
github.com/multiformats/go-base32 v0.1.0 // indirect
|
github.com/multiformats/go-base32 v0.1.0 // indirect
|
||||||
github.com/multiformats/go-base36 v0.2.0 // indirect
|
github.com/multiformats/go-base36 v0.2.0 // indirect
|
||||||
github.com/multiformats/go-varint v0.0.7 // indirect
|
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
github.com/polydawn/refmt v0.89.0 // indirect
|
github.com/polydawn/refmt v0.89.0 // indirect
|
||||||
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
||||||
|
|||||||
8
go.sum
8
go.sum
@@ -1,6 +1,6 @@
|
|||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
github.com/MetaMask/go-did-it v0.0.0-20250730165819-a7ebe989e01b h1:5whMOaNgR+pkjdfk5Vvj8m5WYQRkfCHzO0ZI0Vu+jpw=
|
github.com/MetaMask/go-did-it v1.0.0-pre1 h1:NTGAC7z52TwFegEF7c+csUr/6Al1nAo6ValAAxOsjto=
|
||||||
github.com/MetaMask/go-did-it v0.0.0-20250730165819-a7ebe989e01b/go.mod h1:82WNXsHTCp5ZXmBokhCwInrNaQYeIZsS7SnvwQwVaTo=
|
github.com/MetaMask/go-did-it v1.0.0-pre1/go.mod h1:7m9syDnXFTg5GmUEcydpO4Rs3eYT4McFH7vCw5fp3A4=
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
@@ -59,8 +59,8 @@ github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0b
|
|||||||
github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
||||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||||
github.com/ucan-wg/go-varsig v1.0.0-pre6 h1:go023KQG4fGaLskEUpn7Ftqg3PvW4iO2HaeWEjwIH+k=
|
github.com/ucan-wg/go-varsig v1.0.0 h1:Hrc437Zg+B5Eoajg+qZQZI3Q3ocPyjlnp3/Bz9ZnlWw=
|
||||||
github.com/ucan-wg/go-varsig v1.0.0-pre6/go.mod h1:Sakln6IPooDPH+ClQ0VvR09TuwUhHcfLqcPiPkMZGh0=
|
github.com/ucan-wg/go-varsig v1.0.0/go.mod h1:Sakln6IPooDPH+ClQ0VvR09TuwUhHcfLqcPiPkMZGh0=
|
||||||
github.com/urfave/cli v1.22.10/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
github.com/urfave/cli v1.22.10/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
||||||
github.com/warpfork/go-wish v0.0.0-20220906213052-39a1cc7a02d0 h1:GDDkbFiaK8jsSDJfjId/PEGEShv6ugrt4kYsC5UIDaQ=
|
github.com/warpfork/go-wish v0.0.0-20220906213052-39a1cc7a02d0 h1:GDDkbFiaK8jsSDJfjId/PEGEShv6ugrt4kYsC5UIDaQ=
|
||||||
github.com/warpfork/go-wish v0.0.0-20220906213052-39a1cc7a02d0/go.mod h1:x6AKhvSSexNrVSrViXSHUEbICjmGXhtgABaHIySUSGw=
|
github.com/warpfork/go-wish v0.0.0-20220906213052-39a1cc7a02d0/go.mod h1:x6AKhvSSexNrVSrViXSHUEbICjmGXhtgABaHIySUSGw=
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ type Token interface {
|
|||||||
// IsValidNow verifies that the token can be used at the current time, based on expiration or "not before" fields.
|
// IsValidNow verifies that the token can be used at the current time, based on expiration or "not before" fields.
|
||||||
// This does NOT do any other kind of verifications.
|
// This does NOT do any other kind of verifications.
|
||||||
IsValidNow() bool
|
IsValidNow() bool
|
||||||
// IsValidNow verifies that the token can be used at the given time, based on expiration or "not before" fields.
|
// IsValidAt verifies that the token can be used at the given time, based on expiration or "not before" fields.
|
||||||
// This does NOT do any other kind of verifications.
|
// This does NOT do any other kind of verifications.
|
||||||
IsValidAt(t time.Time) bool
|
IsValidAt(t time.Time) bool
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ func (t *Token) ToDagJsonWriter(w io.Writer, privKey crypto.PrivateKeySigningByt
|
|||||||
// Decode unmarshals the input data using the format specified by the
|
// Decode unmarshals the input data using the format specified by the
|
||||||
// provided codec.Decoder into a Token.
|
// provided codec.Decoder into a Token.
|
||||||
//
|
//
|
||||||
// An error is returned if the conversion fails, or if the resulting
|
// An error is returned if the conversion fails or if the resulting
|
||||||
// Token is invalid.
|
// Token is invalid.
|
||||||
func Decode(b []byte, decFn codec.Decoder, resolvOpts ...did.ResolutionOption) (*Token, error) {
|
func Decode(b []byte, decFn codec.Decoder, resolvOpts ...did.ResolutionOption) (*Token, error) {
|
||||||
node, err := ipld.Decode(b, decFn)
|
node, err := ipld.Decode(b, decFn)
|
||||||
@@ -143,7 +143,7 @@ func DecodeReader(r io.Reader, decFn codec.Decoder, resolvOpts ...did.Resolution
|
|||||||
|
|
||||||
// FromDagCbor unmarshals the input data into a Token.
|
// FromDagCbor unmarshals the input data into a Token.
|
||||||
//
|
//
|
||||||
// An error is returned if the conversion fails, or if the resulting
|
// An error is returned if the conversion fails or if the resulting
|
||||||
// Token is invalid.
|
// Token is invalid.
|
||||||
func FromDagCbor(data []byte, resolvOpts ...did.ResolutionOption) (*Token, error) {
|
func FromDagCbor(data []byte, resolvOpts ...did.ResolutionOption) (*Token, error) {
|
||||||
pay, err := envelope.FromDagCbor[*tokenPayloadModel](data, resolvOpts...)
|
pay, err := envelope.FromDagCbor[*tokenPayloadModel](data, resolvOpts...)
|
||||||
@@ -166,7 +166,7 @@ func FromDagCborReader(r io.Reader, resolvOpts ...did.ResolutionOption) (*Token,
|
|||||||
|
|
||||||
// FromDagJson unmarshals the input data into a Token.
|
// FromDagJson unmarshals the input data into a Token.
|
||||||
//
|
//
|
||||||
// An error is returned if the conversion fails, or if the resulting
|
// An error is returned if the conversion fails or if the resulting
|
||||||
// Token is invalid.
|
// Token is invalid.
|
||||||
func FromDagJson(data []byte, resolvOpts ...did.ResolutionOption) (*Token, error) {
|
func FromDagJson(data []byte, resolvOpts ...did.ResolutionOption) (*Token, error) {
|
||||||
return Decode(data, dagjson.Decode, resolvOpts...)
|
return Decode(data, dagjson.Decode, resolvOpts...)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
|
"github.com/MetaMask/go-did-it"
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
"github.com/ipld/go-ipld-prime"
|
"github.com/ipld/go-ipld-prime"
|
||||||
"github.com/ipld/go-ipld-prime/codec"
|
"github.com/ipld/go-ipld-prime/codec"
|
||||||
@@ -23,8 +24,8 @@ import (
|
|||||||
// Supported and returned types are:
|
// Supported and returned types are:
|
||||||
// - delegation.Token
|
// - delegation.Token
|
||||||
// - invocation.Token
|
// - invocation.Token
|
||||||
func FromSealed(data []byte) (Token, cid.Cid, error) {
|
func FromSealed(data []byte, resolvOpts ...did.ResolutionOption) (Token, cid.Cid, error) {
|
||||||
tkn, err := FromDagCbor(data)
|
tkn, err := FromDagCbor(data, resolvOpts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, cid.Undef, err
|
return nil, cid.Undef, err
|
||||||
}
|
}
|
||||||
@@ -38,10 +39,10 @@ func FromSealed(data []byte) (Token, cid.Cid, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FromSealedReader is the same as Unseal but accepts an io.Reader.
|
// FromSealedReader is the same as Unseal but accepts an io.Reader.
|
||||||
func FromSealedReader(r io.Reader) (Token, cid.Cid, error) {
|
func FromSealedReader(r io.Reader, resolvOpts ...did.ResolutionOption) (Token, cid.Cid, error) {
|
||||||
cidReader := envelope.NewCIDReader(r)
|
cidReader := envelope.NewCIDReader(r)
|
||||||
|
|
||||||
tkn, err := FromDagCborReader(cidReader)
|
tkn, err := FromDagCborReader(cidReader, resolvOpts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, cid.Undef, err
|
return nil, cid.Undef, err
|
||||||
}
|
}
|
||||||
@@ -61,21 +62,21 @@ func FromSealedReader(r io.Reader) (Token, cid.Cid, error) {
|
|||||||
// Supported and returned types are:
|
// Supported and returned types are:
|
||||||
// - delegation.Token
|
// - delegation.Token
|
||||||
// - invocation.Token
|
// - invocation.Token
|
||||||
func Decode(b []byte, decFn codec.Decoder) (Token, error) {
|
func Decode(b []byte, decFn codec.Decoder, resolvOpts ...did.ResolutionOption) (Token, error) {
|
||||||
node, err := ipld.Decode(b, decFn)
|
node, err := ipld.Decode(b, decFn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return fromIPLD(node)
|
return fromIPLD(node, resolvOpts...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DecodeReader is the same as Decode, but accept an io.Reader.
|
// DecodeReader is the same as Decode, but accept an io.Reader.
|
||||||
func DecodeReader(r io.Reader, decFn codec.Decoder) (Token, error) {
|
func DecodeReader(r io.Reader, decFn codec.Decoder, resolvOpts ...did.ResolutionOption) (Token, error) {
|
||||||
node, err := ipld.DecodeStreaming(r, decFn)
|
node, err := ipld.DecodeStreaming(r, decFn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return fromIPLD(node)
|
return fromIPLD(node, resolvOpts...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FromDagCbor unmarshals an arbitrary DagCbor encoded UCAN token.
|
// FromDagCbor unmarshals an arbitrary DagCbor encoded UCAN token.
|
||||||
@@ -84,31 +85,31 @@ func DecodeReader(r io.Reader, decFn codec.Decoder) (Token, error) {
|
|||||||
// Supported and returned types are:
|
// Supported and returned types are:
|
||||||
// - delegation.Token
|
// - delegation.Token
|
||||||
// - invocation.Token
|
// - invocation.Token
|
||||||
func FromDagCbor(b []byte) (Token, error) {
|
func FromDagCbor(b []byte, resolvOpts ...did.ResolutionOption) (Token, error) {
|
||||||
return Decode(b, dagcbor.Decode)
|
return Decode(b, dagcbor.Decode, resolvOpts...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FromDagCborReader is the same as FromDagCbor, but accept an io.Reader.
|
// FromDagCborReader is the same as FromDagCbor, but accept an io.Reader.
|
||||||
func FromDagCborReader(r io.Reader) (Token, error) {
|
func FromDagCborReader(r io.Reader, resolvOpts ...did.ResolutionOption) (Token, error) {
|
||||||
return DecodeReader(r, dagcbor.Decode)
|
return DecodeReader(r, dagcbor.Decode, resolvOpts...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FromDagCbor unmarshals an arbitrary DagJson encoded UCAN token.
|
// FromDagJson unmarshals an arbitrary DagJson encoded UCAN token.
|
||||||
// An error is returned if the conversion fails, or if the resulting
|
// An error is returned if the conversion fails, or if the resulting
|
||||||
// Token is invalid.
|
// Token is invalid.
|
||||||
// Supported and returned types are:
|
// Supported and returned types are:
|
||||||
// - delegation.Token
|
// - delegation.Token
|
||||||
// - invocation.Token
|
// - invocation.Token
|
||||||
func FromDagJson(b []byte) (Token, error) {
|
func FromDagJson(b []byte, resolvOpts ...did.ResolutionOption) (Token, error) {
|
||||||
return Decode(b, dagjson.Decode)
|
return Decode(b, dagjson.Decode, resolvOpts...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FromDagJsonReader is the same as FromDagJson, but accept an io.Reader.
|
// FromDagJsonReader is the same as FromDagJson, but accept an io.Reader.
|
||||||
func FromDagJsonReader(r io.Reader) (Token, error) {
|
func FromDagJsonReader(r io.Reader, resolvOpts ...did.ResolutionOption) (Token, error) {
|
||||||
return DecodeReader(r, dagjson.Decode)
|
return DecodeReader(r, dagjson.Decode, resolvOpts...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func fromIPLD(node datamodel.Node) (Token, error) {
|
func fromIPLD(node datamodel.Node, resolvOpts ...did.ResolutionOption) (Token, error) {
|
||||||
tag, err := envelope.FindTag(node)
|
tag, err := envelope.FindTag(node)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -116,9 +117,9 @@ func fromIPLD(node datamodel.Node) (Token, error) {
|
|||||||
|
|
||||||
switch tag {
|
switch tag {
|
||||||
case delegation.Tag:
|
case delegation.Tag:
|
||||||
return delegation.FromIPLD(node)
|
return delegation.FromIPLD(node, resolvOpts...)
|
||||||
case invocation.Tag:
|
case invocation.Tag:
|
||||||
return invocation.FromIPLD(node)
|
return invocation.FromIPLD(node, resolvOpts...)
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf(`unknown tag "%s"`, tag)
|
return nil, fmt.Errorf(`unknown tag "%s"`, tag)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user