Skip to content

Commit 5891bdc

Browse files
committed
update go-varsig, go-did-it, add missing resolution options
1 parent 6fb2548 commit 5891bdc

5 files changed

Lines changed: 32 additions & 31 deletions

File tree

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ go 1.24.4
55
toolchain go1.24.5
66

77
require (
8-
github.com/MetaMask/go-did-it v0.0.0-20250730165819-a7ebe989e01b
8+
github.com/MetaMask/go-did-it v1.0.0-pre1
99
github.com/ipfs/go-cid v0.5.0
1010
github.com/ipld/go-ipld-prime v0.21.0
1111
github.com/multiformats/go-multibase v0.2.0
1212
github.com/multiformats/go-multicodec v0.9.0
1313
github.com/multiformats/go-multihash v0.2.3
14+
github.com/multiformats/go-varint v0.0.7
1415
github.com/stretchr/testify v1.10.0
15-
github.com/ucan-wg/go-varsig v1.0.0-pre6
16+
github.com/ucan-wg/go-varsig v1.0.0
1617
golang.org/x/crypto v0.40.0
1718
)
1819

@@ -24,7 +25,6 @@ require (
2425
github.com/mr-tron/base58 v1.2.0 // indirect
2526
github.com/multiformats/go-base32 v0.1.0 // indirect
2627
github.com/multiformats/go-base36 v0.2.0 // indirect
27-
github.com/multiformats/go-varint v0.0.7 // indirect
2828
github.com/pmezard/go-difflib v1.0.0 // indirect
2929
github.com/polydawn/refmt v0.89.0 // indirect
3030
github.com/spaolacci/murmur3 v1.1.0 // indirect

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
2-
github.com/MetaMask/go-did-it v0.0.0-20250730165819-a7ebe989e01b h1:5whMOaNgR+pkjdfk5Vvj8m5WYQRkfCHzO0ZI0Vu+jpw=
3-
github.com/MetaMask/go-did-it v0.0.0-20250730165819-a7ebe989e01b/go.mod h1:82WNXsHTCp5ZXmBokhCwInrNaQYeIZsS7SnvwQwVaTo=
2+
github.com/MetaMask/go-did-it v1.0.0-pre1 h1:NTGAC7z52TwFegEF7c+csUr/6Al1nAo6ValAAxOsjto=
3+
github.com/MetaMask/go-did-it v1.0.0-pre1/go.mod h1:7m9syDnXFTg5GmUEcydpO4Rs3eYT4McFH7vCw5fp3A4=
44
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
55
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
66
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
5959
github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
6060
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
6161
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
62-
github.com/ucan-wg/go-varsig v1.0.0-pre6 h1:go023KQG4fGaLskEUpn7Ftqg3PvW4iO2HaeWEjwIH+k=
63-
github.com/ucan-wg/go-varsig v1.0.0-pre6/go.mod h1:Sakln6IPooDPH+ClQ0VvR09TuwUhHcfLqcPiPkMZGh0=
62+
github.com/ucan-wg/go-varsig v1.0.0 h1:Hrc437Zg+B5Eoajg+qZQZI3Q3ocPyjlnp3/Bz9ZnlWw=
63+
github.com/ucan-wg/go-varsig v1.0.0/go.mod h1:Sakln6IPooDPH+ClQ0VvR09TuwUhHcfLqcPiPkMZGh0=
6464
github.com/urfave/cli v1.22.10/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
6565
github.com/warpfork/go-wish v0.0.0-20220906213052-39a1cc7a02d0 h1:GDDkbFiaK8jsSDJfjId/PEGEShv6ugrt4kYsC5UIDaQ=
6666
github.com/warpfork/go-wish v0.0.0-20220906213052-39a1cc7a02d0/go.mod h1:x6AKhvSSexNrVSrViXSHUEbICjmGXhtgABaHIySUSGw=

token/interface.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type Token interface {
1515
// IsValidNow verifies that the token can be used at the current time, based on expiration or "not before" fields.
1616
// This does NOT do any other kind of verifications.
1717
IsValidNow() bool
18-
// IsValidNow verifies that the token can be used at the given time, based on expiration or "not before" fields.
18+
// IsValidAt verifies that the token can be used at the given time, based on expiration or "not before" fields.
1919
// This does NOT do any other kind of verifications.
2020
IsValidAt(t time.Time) bool
2121
}

token/invocation/ipld.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func (t *Token) ToDagJsonWriter(w io.Writer, privKey crypto.PrivateKeySigningByt
122122
// Decode unmarshals the input data using the format specified by the
123123
// provided codec.Decoder into a Token.
124124
//
125-
// An error is returned if the conversion fails, or if the resulting
125+
// An error is returned if the conversion fails or if the resulting
126126
// Token is invalid.
127127
func Decode(b []byte, decFn codec.Decoder, resolvOpts ...did.ResolutionOption) (*Token, error) {
128128
node, err := ipld.Decode(b, decFn)
@@ -143,7 +143,7 @@ func DecodeReader(r io.Reader, decFn codec.Decoder, resolvOpts ...did.Resolution
143143

144144
// FromDagCbor unmarshals the input data into a Token.
145145
//
146-
// An error is returned if the conversion fails, or if the resulting
146+
// An error is returned if the conversion fails or if the resulting
147147
// Token is invalid.
148148
func FromDagCbor(data []byte, resolvOpts ...did.ResolutionOption) (*Token, error) {
149149
pay, err := envelope.FromDagCbor[*tokenPayloadModel](data, resolvOpts...)
@@ -166,7 +166,7 @@ func FromDagCborReader(r io.Reader, resolvOpts ...did.ResolutionOption) (*Token,
166166

167167
// FromDagJson unmarshals the input data into a Token.
168168
//
169-
// An error is returned if the conversion fails, or if the resulting
169+
// An error is returned if the conversion fails or if the resulting
170170
// Token is invalid.
171171
func FromDagJson(data []byte, resolvOpts ...did.ResolutionOption) (*Token, error) {
172172
return Decode(data, dagjson.Decode, resolvOpts...)

token/read.go

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"io"
66

7+
"github.com/MetaMask/go-did-it"
78
"github.com/ipfs/go-cid"
89
"github.com/ipld/go-ipld-prime"
910
"github.com/ipld/go-ipld-prime/codec"
@@ -23,8 +24,8 @@ import (
2324
// Supported and returned types are:
2425
// - delegation.Token
2526
// - invocation.Token
26-
func FromSealed(data []byte) (Token, cid.Cid, error) {
27-
tkn, err := FromDagCbor(data)
27+
func FromSealed(data []byte, resolvOpts ...did.ResolutionOption) (Token, cid.Cid, error) {
28+
tkn, err := FromDagCbor(data, resolvOpts...)
2829
if err != nil {
2930
return nil, cid.Undef, err
3031
}
@@ -38,10 +39,10 @@ func FromSealed(data []byte) (Token, cid.Cid, error) {
3839
}
3940

4041
// FromSealedReader is the same as Unseal but accepts an io.Reader.
41-
func FromSealedReader(r io.Reader) (Token, cid.Cid, error) {
42+
func FromSealedReader(r io.Reader, resolvOpts ...did.ResolutionOption) (Token, cid.Cid, error) {
4243
cidReader := envelope.NewCIDReader(r)
4344

44-
tkn, err := FromDagCborReader(cidReader)
45+
tkn, err := FromDagCborReader(cidReader, resolvOpts...)
4546
if err != nil {
4647
return nil, cid.Undef, err
4748
}
@@ -61,21 +62,21 @@ func FromSealedReader(r io.Reader) (Token, cid.Cid, error) {
6162
// Supported and returned types are:
6263
// - delegation.Token
6364
// - invocation.Token
64-
func Decode(b []byte, decFn codec.Decoder) (Token, error) {
65+
func Decode(b []byte, decFn codec.Decoder, resolvOpts ...did.ResolutionOption) (Token, error) {
6566
node, err := ipld.Decode(b, decFn)
6667
if err != nil {
6768
return nil, err
6869
}
69-
return fromIPLD(node)
70+
return fromIPLD(node, resolvOpts...)
7071
}
7172

7273
// DecodeReader is the same as Decode, but accept an io.Reader.
73-
func DecodeReader(r io.Reader, decFn codec.Decoder) (Token, error) {
74+
func DecodeReader(r io.Reader, decFn codec.Decoder, resolvOpts ...did.ResolutionOption) (Token, error) {
7475
node, err := ipld.DecodeStreaming(r, decFn)
7576
if err != nil {
7677
return nil, err
7778
}
78-
return fromIPLD(node)
79+
return fromIPLD(node, resolvOpts...)
7980
}
8081

8182
// FromDagCbor unmarshals an arbitrary DagCbor encoded UCAN token.
@@ -84,41 +85,41 @@ func DecodeReader(r io.Reader, decFn codec.Decoder) (Token, error) {
8485
// Supported and returned types are:
8586
// - delegation.Token
8687
// - invocation.Token
87-
func FromDagCbor(b []byte) (Token, error) {
88-
return Decode(b, dagcbor.Decode)
88+
func FromDagCbor(b []byte, resolvOpts ...did.ResolutionOption) (Token, error) {
89+
return Decode(b, dagcbor.Decode, resolvOpts...)
8990
}
9091

9192
// FromDagCborReader is the same as FromDagCbor, but accept an io.Reader.
92-
func FromDagCborReader(r io.Reader) (Token, error) {
93-
return DecodeReader(r, dagcbor.Decode)
93+
func FromDagCborReader(r io.Reader, resolvOpts ...did.ResolutionOption) (Token, error) {
94+
return DecodeReader(r, dagcbor.Decode, resolvOpts...)
9495
}
9596

96-
// FromDagCbor unmarshals an arbitrary DagJson encoded UCAN token.
97+
// FromDagJson unmarshals an arbitrary DagJson encoded UCAN token.
9798
// An error is returned if the conversion fails, or if the resulting
9899
// Token is invalid.
99100
// Supported and returned types are:
100101
// - delegation.Token
101102
// - invocation.Token
102-
func FromDagJson(b []byte) (Token, error) {
103-
return Decode(b, dagjson.Decode)
103+
func FromDagJson(b []byte, resolvOpts ...did.ResolutionOption) (Token, error) {
104+
return Decode(b, dagjson.Decode, resolvOpts...)
104105
}
105106

106107
// FromDagJsonReader is the same as FromDagJson, but accept an io.Reader.
107-
func FromDagJsonReader(r io.Reader) (Token, error) {
108-
return DecodeReader(r, dagjson.Decode)
108+
func FromDagJsonReader(r io.Reader, resolvOpts ...did.ResolutionOption) (Token, error) {
109+
return DecodeReader(r, dagjson.Decode, resolvOpts...)
109110
}
110111

111-
func fromIPLD(node datamodel.Node) (Token, error) {
112+
func fromIPLD(node datamodel.Node, resolvOpts ...did.ResolutionOption) (Token, error) {
112113
tag, err := envelope.FindTag(node)
113114
if err != nil {
114115
return nil, err
115116
}
116117

117118
switch tag {
118119
case delegation.Tag:
119-
return delegation.FromIPLD(node)
120+
return delegation.FromIPLD(node, resolvOpts...)
120121
case invocation.Tag:
121-
return invocation.FromIPLD(node)
122+
return invocation.FromIPLD(node, resolvOpts...)
122123
default:
123124
return nil, fmt.Errorf(`unknown tag "%s"`, tag)
124125
}

0 commit comments

Comments
 (0)