diff --git a/go.mod b/go.mod index c485298..e3ba1dd 100644 --- a/go.mod +++ b/go.mod @@ -4,10 +4,10 @@ go 1.23 require ( github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 - github.com/ipfs/go-cid v0.4.1 + github.com/ipfs/go-cid v0.5.0 github.com/ipld/go-ipld-prime v0.21.0 - github.com/lestrrat-go/jwx/v2 v2.1.1 - github.com/libp2p/go-libp2p v0.36.3 + github.com/lestrrat-go/jwx/v2 v2.1.3 + github.com/libp2p/go-libp2p v0.38.2 github.com/mr-tron/base58 v1.2.0 github.com/multiformats/go-multibase v0.2.0 github.com/multiformats/go-multicodec v0.9.0 @@ -22,7 +22,7 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/goccy/go-json v0.10.3 // indirect github.com/google/go-cmp v0.5.9 // indirect - github.com/klauspost/cpuid/v2 v2.2.8 // indirect + github.com/klauspost/cpuid/v2 v2.2.9 // indirect github.com/lestrrat-go/blackmagic v1.0.2 // indirect github.com/lestrrat-go/httpcc v1.0.1 // indirect github.com/lestrrat-go/httprc v1.0.6 // indirect @@ -36,7 +36,7 @@ require ( github.com/segmentio/asm v1.2.0 // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect golang.org/x/sys v0.29.0 // indirect - google.golang.org/protobuf v1.34.2 // indirect + google.golang.org/protobuf v1.36.0 // indirect gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect lukechampine.com/blake3 v1.3.0 // indirect diff --git a/go.sum b/go.sum index 6a7eb95..a571d7e 100644 --- a/go.sum +++ b/go.sum @@ -16,14 +16,14 @@ github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= -github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= -github.com/ipfs/go-cid v0.4.1/go.mod h1:uQHwDeX4c6CtyrFwdqyhpNcxVewur1M7l7fNU7LKwZk= +github.com/ipfs/go-cid v0.5.0 h1:goEKKhaGm0ul11IHA7I6p1GmKz8kEYniqFopaB5Otwg= +github.com/ipfs/go-cid v0.5.0/go.mod h1:0L7vmeNXpQpUS9vt+yEARkJ8rOg43DF3iPgn4GIN0mk= github.com/ipld/go-ipld-prime v0.21.0 h1:n4JmcpOlPDIxBcY037SVfpd1G+Sj1nKZah0m6QH9C2E= github.com/ipld/go-ipld-prime v0.21.0/go.mod h1:3RLqy//ERg/y5oShXXdx5YIp50cFGOanyMctpPjsvxQ= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= -github.com/klauspost/cpuid/v2 v2.2.8 h1:+StwCXwm9PdpiEkPyzBXIy+M9KUb4ODm0Zarf1kS5BM= -github.com/klauspost/cpuid/v2 v2.2.8/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= +github.com/klauspost/cpuid/v2 v2.2.9 h1:66ze0taIn2H33fBvCkXuv9BmCwDfafmiIVpKV9kKGuY= +github.com/klauspost/cpuid/v2 v2.2.9/go.mod h1:rqkxqrZ1EhYM9G+hXH7YdowN5R5RGN6NK4QwQ3WMXF8= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -36,14 +36,14 @@ github.com/lestrrat-go/httprc v1.0.6 h1:qgmgIRhpvBqexMJjA/PmwSvhNk679oqD1RbovdCG github.com/lestrrat-go/httprc v1.0.6/go.mod h1:mwwz3JMTPBjHUkkDv/IGJ39aALInZLrhBp0X7KGUZlo= github.com/lestrrat-go/iter v1.0.2 h1:gMXo1q4c2pHmC3dn8LzRhJfP1ceCbgSiT9lUydIzltI= github.com/lestrrat-go/iter v1.0.2/go.mod h1:Momfcq3AnRlRjI5b5O8/G5/BvpzrhoFTZcn06fEOPt4= -github.com/lestrrat-go/jwx/v2 v2.1.1 h1:Y2ltVl8J6izLYFs54BVcpXLv5msSW4o8eXwnzZLI32E= -github.com/lestrrat-go/jwx/v2 v2.1.1/go.mod h1:4LvZg7oxu6Q5VJwn7Mk/UwooNRnTHUpXBj2C4j3HNx0= +github.com/lestrrat-go/jwx/v2 v2.1.3 h1:Ud4lb2QuxRClYAmRleF50KrbKIoM1TddXgBrneT5/Jo= +github.com/lestrrat-go/jwx/v2 v2.1.3/go.mod h1:q6uFgbgZfEmQrfJfrCo90QcQOcXFMfbI/fO0NqRtvZo= github.com/lestrrat-go/option v1.0.1 h1:oAzP2fvZGQKWkvHa1/SAcFolBEca1oN+mQ7eooNBEYU= github.com/lestrrat-go/option v1.0.1/go.mod h1:5ZHFbivi4xwXxhxY9XHDe2FHo6/Z7WWmtT7T5nBBp3I= github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8= github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg= -github.com/libp2p/go-libp2p v0.36.3 h1:NHz30+G7D8Y8YmznrVZZla0ofVANrvBl2c+oARfMeDQ= -github.com/libp2p/go-libp2p v0.36.3/go.mod h1:4Y5vFyCUiJuluEPmpnKYf6WFx5ViKPUYs/ixe9ANFZ8= +github.com/libp2p/go-libp2p v0.38.2 h1:9SZQDOCi82A25An4kx30lEtr6kGTxrtoaDkbs5xrK5k= +github.com/libp2p/go-libp2p v0.38.2/go.mod h1:QWV4zGL3O9nXKdHirIC59DoRcZ446dfkjbOJ55NEWFo= github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM= github.com/minio/sha256-simd v1.0.1/go.mod h1:Pz6AKMiUdngCLpeTL/RJY1M9rUuPMYujV5xJjtbRSN8= github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o= @@ -52,8 +52,8 @@ github.com/multiformats/go-base32 v0.1.0 h1:pVx9xoSPqEIQG8o+UbAe7DNi51oej1NtK+aG github.com/multiformats/go-base32 v0.1.0/go.mod h1:Kj3tFY6zNr+ABYMqeUNeGvkIC/UYgtWibDcT0rExnbI= github.com/multiformats/go-base36 v0.2.0 h1:lFsAbNOGeKtuKozrtBsAkSVhv1p9D0/qedU9rQyccr0= github.com/multiformats/go-base36 v0.2.0/go.mod h1:qvnKE++v+2MWCfePClUEjE78Z7P2a1UV0xHgWc0hkp4= -github.com/multiformats/go-multiaddr v0.13.0 h1:BCBzs61E3AGHcYYTv8dqRH43ZfyrqM8RXVPT8t13tLQ= -github.com/multiformats/go-multiaddr v0.13.0/go.mod h1:sBXrNzucqkFJhvKOiwwLyqamGa/P5EIXNPLovyhQCII= +github.com/multiformats/go-multiaddr v0.14.0 h1:bfrHrJhrRuh/NXH5mCnemjpbGjzRw/b+tJFOD41g2tU= +github.com/multiformats/go-multiaddr v0.14.0/go.mod h1:6EkVAxtznq2yC3QT5CM1UTAwG0GTP3EWAIcjHuzQ+r4= github.com/multiformats/go-multibase v0.2.0 h1:isdYCVLvksgWlMW9OZRYJEa9pZETFivncJHmHnnd87g= github.com/multiformats/go-multibase v0.2.0/go.mod h1:bFBZX4lKCA/2lyOFSAoKH5SS6oPyjtnzK/XTFDPkNuk= github.com/multiformats/go-multicodec v0.9.0 h1:pb/dlPnzee/Sxv/j4PmkDRxCOi3hXTz3IbPKOXWJkmg= @@ -89,17 +89,16 @@ github.com/warpfork/go-wish v0.0.0-20220906213052-39a1cc7a02d0/go.mod h1:x6AKhvS golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc= golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc= -golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8= -golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY= +golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67 h1:1UoZQm6f0P/ZO0w1Ri+f+ifG/gXhegadRdwBIXEFWDo= +golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67/go.mod h1:qj5a5QZpwLU2NLQudwIN5koi3beDhSAlJwa67PuM98c= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU= golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= -google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= +google.golang.org/protobuf v1.36.0 h1:mjIs9gYtt56AzC4ZaffQuh88TZurBGhIJMBZGSxNerQ= +google.golang.org/protobuf v1.36.0/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/pkg/container/reader.go b/pkg/container/reader.go index a469671..c719903 100644 --- a/pkg/container/reader.go +++ b/pkg/container/reader.go @@ -115,10 +115,10 @@ func (ctn Reader) GetSealed(cid cid.Cid) ([]byte, error) { } // GetAllTokens return all the tokens in the container. -func (ctn Reader) GetAllTokens() iter.Seq[token.Bundle[token.Token]] { - return func(yield func(token.Bundle[token.Token]) bool) { +func (ctn Reader) GetAllTokens() iter.Seq[token.Bundle] { + return func(yield func(token.Bundle) bool) { for c, bndl := range ctn { - if !yield(token.Bundle[token.Token]{ + if !yield(token.Bundle{ Cid: c, Decoded: bndl.token, Sealed: bndl.sealed, @@ -143,11 +143,11 @@ func (ctn Reader) GetDelegation(cid cid.Cid) (*delegation.Token, error) { } // GetAllDelegations returns all the delegation.Token in the container. -func (ctn Reader) GetAllDelegations() iter.Seq[token.Bundle[*delegation.Token]] { - return func(yield func(token.Bundle[*delegation.Token]) bool) { +func (ctn Reader) GetAllDelegations() iter.Seq[token.Bundle] { + return func(yield func(token.Bundle) bool) { for c, bndl := range ctn { if t, ok := bndl.token.(*delegation.Token); ok { - if !yield(token.Bundle[*delegation.Token]{ + if !yield(token.Bundle{ Cid: c, Decoded: t, Sealed: bndl.sealed, @@ -179,11 +179,11 @@ func (ctn Reader) GetInvocation() (*invocation.Token, error) { } // GetAllInvocations returns all the invocation.Token in the container. -func (ctn Reader) GetAllInvocations() iter.Seq[token.Bundle[*invocation.Token]] { - return func(yield func(token.Bundle[*invocation.Token]) bool) { +func (ctn Reader) GetAllInvocations() iter.Seq[invocation.Bundle] { + return func(yield func(invocation.Bundle) bool) { for c, bndl := range ctn { if t, ok := bndl.token.(*invocation.Token); ok { - if !yield(token.Bundle[*invocation.Token]{ + if !yield(invocation.Bundle{ Cid: c, Decoded: t, Sealed: bndl.sealed, diff --git a/token/delegation/delegationtest/generator/generator.go b/token/delegation/delegationtest/generator/generator.go index 7f8b1f4..d2e56b2 100644 --- a/token/delegation/delegationtest/generator/generator.go +++ b/token/delegation/delegationtest/generator/generator.go @@ -217,7 +217,6 @@ func (g *generator) writeGoFile() error { Println("import (") Println("\t\"github.com/ipfs/go-cid\"") Println() - Println("\t\"github.com/ucan-wg/go-ucan/token\"") Println("\t\"github.com/ucan-wg/go-ucan/token/delegation\"") Println(")") @@ -243,7 +242,7 @@ func (g *generator) writeGoFile() error { Println("}") Println() - Println("var AllBundles = []token.Bundle[*delegation.Token]{") + Println("var AllBundles = []delegation.Bundle{") for _, d := range g.dlgs { Printf("\t%sBundle,\n", d.name) } diff --git a/token/delegation/delegationtest/token.go b/token/delegation/delegationtest/token.go index 7d1b280..fa1ffa0 100644 --- a/token/delegation/delegationtest/token.go +++ b/token/delegation/delegationtest/token.go @@ -8,7 +8,6 @@ import ( "github.com/ipfs/go-cid" "github.com/ucan-wg/go-ucan/pkg/command" - "github.com/ucan-wg/go-ucan/token" "github.com/ucan-wg/go-ucan/token/delegation" ) @@ -39,7 +38,7 @@ var fs embed.FS var _ delegation.Loader = (*DelegationLoader)(nil) type DelegationLoader struct { - bundles map[cid.Cid]token.Bundle[*delegation.Token] + bundles map[cid.Cid]delegation.Bundle } var ( @@ -76,7 +75,7 @@ func loadDelegations() (*DelegationLoader, error) { return nil, err } - bundles := make(map[cid.Cid]token.Bundle[*delegation.Token], len(dirEntries)) + bundles := make(map[cid.Cid]delegation.Bundle, len(dirEntries)) for _, dirEntry := range dirEntries { data, err := fs.ReadFile(filepath.Join(TokenDir, dirEntry.Name())) @@ -89,7 +88,7 @@ func loadDelegations() (*DelegationLoader, error) { return nil, err } - bundles[id] = token.Bundle[*delegation.Token]{Cid: id, Decoded: tkn, Sealed: data} + bundles[id] = delegation.Bundle{Cid: id, Decoded: tkn, Sealed: data} } return &DelegationLoader{ @@ -107,7 +106,7 @@ func CidToName(id cid.Cid) string { return cidToName[id] } -func mustGetBundle(id cid.Cid) token.Bundle[*delegation.Token] { +func mustGetBundle(id cid.Cid) delegation.Bundle { bundle, ok := GetDelegationLoader().bundles[id] if !ok { panic(delegation.ErrDelegationNotFound) diff --git a/token/delegation/delegationtest/token_gen.go b/token/delegation/delegationtest/token_gen.go index 4c1c217..5872520 100644 --- a/token/delegation/delegationtest/token_gen.go +++ b/token/delegation/delegationtest/token_gen.go @@ -5,7 +5,6 @@ package delegationtest import ( "github.com/ipfs/go-cid" - "github.com/ucan-wg/go-ucan/token" "github.com/ucan-wg/go-ucan/token/delegation" ) @@ -196,7 +195,7 @@ var AllTokens = []*delegation.Token{ TokenErinFrank_ValidExamplePolicy, } -var AllBundles = []token.Bundle[*delegation.Token]{ +var AllBundles = []delegation.Bundle{ TokenAliceBobBundle, TokenBobCarolBundle, TokenCarolDanBundle, diff --git a/token/delegation/utilities.go b/token/delegation/utilities.go index 13dd81d..558f440 100644 --- a/token/delegation/utilities.go +++ b/token/delegation/utilities.go @@ -15,3 +15,10 @@ type Loader interface { // If not found, ErrDelegationNotFound is returned. GetDelegation(cid cid.Cid) (*Token, error) } + +// Bundle carries together a decoded token with its Cid and raw signed data. +type Bundle struct { + Cid cid.Cid + Decoded *Token + Sealed []byte +} diff --git a/token/interface.go b/token/interface.go index 08e86f9..7a04f36 100644 --- a/token/interface.go +++ b/token/interface.go @@ -41,8 +41,8 @@ type Marshaller interface { } // Bundle carries together a decoded token with its Cid and raw signed data. -type Bundle[T Token] struct { +type Bundle struct { Cid cid.Cid - Decoded T + Decoded Token Sealed []byte } diff --git a/token/invocation/utilities.go b/token/invocation/utilities.go new file mode 100644 index 0000000..c58b726 --- /dev/null +++ b/token/invocation/utilities.go @@ -0,0 +1,10 @@ +package invocation + +import "github.com/ipfs/go-cid" + +// Bundle carries together a decoded token with its Cid and raw signed data. +type Bundle struct { + Cid cid.Cid + Decoded *Token + Sealed []byte +}