rename tokens to token
This commit is contained in:
@@ -11,7 +11,7 @@ import (
|
|||||||
"github.com/ucan-wg/go-ucan/did"
|
"github.com/ucan-wg/go-ucan/did"
|
||||||
"github.com/ucan-wg/go-ucan/pkg/command"
|
"github.com/ucan-wg/go-ucan/pkg/command"
|
||||||
"github.com/ucan-wg/go-ucan/pkg/policy"
|
"github.com/ucan-wg/go-ucan/pkg/policy"
|
||||||
"github.com/ucan-wg/go-ucan/tokens/delegation"
|
"github.com/ucan-wg/go-ucan/token/delegation"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -12,11 +12,12 @@ import (
|
|||||||
"github.com/ipld/go-ipld-prime/codec/dagcbor"
|
"github.com/ipld/go-ipld-prime/codec/dagcbor"
|
||||||
"github.com/ipld/go-ipld-prime/codec/dagjson"
|
"github.com/ipld/go-ipld-prime/codec/dagjson"
|
||||||
"github.com/libp2p/go-libp2p/core/crypto"
|
"github.com/libp2p/go-libp2p/core/crypto"
|
||||||
|
|
||||||
"github.com/ucan-wg/go-ucan/did"
|
"github.com/ucan-wg/go-ucan/did"
|
||||||
"github.com/ucan-wg/go-ucan/pkg/command"
|
"github.com/ucan-wg/go-ucan/pkg/command"
|
||||||
"github.com/ucan-wg/go-ucan/pkg/policy"
|
"github.com/ucan-wg/go-ucan/pkg/policy"
|
||||||
"github.com/ucan-wg/go-ucan/tokens/delegation"
|
"github.com/ucan-wg/go-ucan/token/delegation"
|
||||||
"github.com/ucan-wg/go-ucan/tokens/internal/envelope"
|
"github.com/ucan-wg/go-ucan/token/internal/envelope"
|
||||||
)
|
)
|
||||||
|
|
||||||
// The following example shows how to create a delegation.Token with
|
// The following example shows how to create a delegation.Token with
|
||||||
@@ -50,11 +51,11 @@ func ExampleNew() {
|
|||||||
|
|
||||||
printCIDAndSealed(id, data)
|
printCIDAndSealed(id, data)
|
||||||
|
|
||||||
//Output:
|
// Output:
|
||||||
//CID (base58BTC): zdpuAw26pFuvZa2Z9YAtpZZnWN6Vmn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yYWZ0g2NhbGxpLnJldmlld2Vyg2RsaWtlZi5lbWFpbG0qQGV4YW1wbGUuY29tg2NhbnllLnRhZ3OCYm9ygoNiPT1hLmRuZXdzg2I9PWEuZXByZXNzY3N1Yng4ZGlkOmtleTp6Nk1rdEExdUJkQ3BxNHVKQnFFOWpqTWlMeXhaQmc5YTZ4Z1BQS0pqTXFzczZaYzJkbWV0YaBlbm9uY2VMAAECAwQFBgcICQoL
|
||||||
//Converted to DAG-JSON out:
|
// Converted to DAG-JSON out:
|
||||||
//[
|
// [
|
||||||
// {
|
// {
|
||||||
// "/": {
|
// "/": {
|
||||||
// "bytes": "mnAkgfjAx4SA5pzJmtaHRJtTGNpF1y6oqb4yhGoM2H2EUGbBYT4rVDjMKBgCjhdGHjipm00L8iR5SsQh3sIEBQ"
|
// "bytes": "mnAkgfjAx4SA5pzJmtaHRJtTGNpF1y6oqb4yhGoM2H2EUGbBYT4rVDjMKBgCjhdGHjipm00L8iR5SsQh3sIEBQ"
|
||||||
@@ -115,7 +116,7 @@ func ExampleNew() {
|
|||||||
// "sub": "did:key:z6MktA1uBdCpq4uJBqE9jjMiLyxZBg9a6xgPPKJjMqss6Zc2"
|
// "sub": "did:key:z6MktA1uBdCpq4uJBqE9jjMiLyxZBg9a6xgPPKJjMqss6Zc2"
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//]
|
// ]
|
||||||
}
|
}
|
||||||
|
|
||||||
// The following example shows how to create a UCAN root delegation.Token
|
// The following example shows how to create a UCAN root delegation.Token
|
||||||
@@ -148,11 +149,11 @@ func ExampleRoot() {
|
|||||||
|
|
||||||
printCIDAndSealed(id, data)
|
printCIDAndSealed(id, data)
|
||||||
|
|
||||||
//Output:
|
// Output:
|
||||||
//CID (base58BTC): zdpuAnbsR3e6DK8hBk5WA7KwbHYN6CKY4a3Bv1GNehvFYShQ8
|
// CID (base58BTC): zdpuAnbsR3e6DK8hBk5WA7KwbHYN6CKY4a3Bv1GNehvFYShQ8
|
||||||
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uZXdzg2I9PWEuZXByZXNzY3N1Yng4ZGlkOmtleTp6Nk1rcHpuMm4zWkdUMlZhcU1HU1FDM3R6bXpWNFRTOVM3MWlGc0RYRTFXbm9OSDJkbWV0YaBlbm9uY2VMAAECAwQFBgcICQoL
|
||||||
//Converted to DAG-JSON out:
|
// Converted to DAG-JSON out:
|
||||||
//[
|
// [
|
||||||
// {
|
// {
|
||||||
// "/": {
|
// "/": {
|
||||||
// "bytes": "67ASBczF/wlIP0ESENn+4ZNQKukjcTNz+fo7K2tYa6OUm0rWICDJJkDWm7lJeQt+KvSA+Y4ctHTQbAr3Lr7mDg"
|
// "bytes": "67ASBczF/wlIP0ESENn+4ZNQKukjcTNz+fo7K2tYa6OUm0rWICDJJkDWm7lJeQt+KvSA+Y4ctHTQbAr3Lr7mDg"
|
||||||
@@ -213,7 +214,7 @@ func ExampleRoot() {
|
|||||||
// "sub": "did:key:z6Mkpzn2n3ZGT2VaqMGSQC3tzmzV4TS9S71iFsDXE1WnoNH2"
|
// "sub": "did:key:z6Mkpzn2n3ZGT2VaqMGSQC3tzmzV4TS9S71iFsDXE1WnoNH2"
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//]
|
// ]
|
||||||
}
|
}
|
||||||
|
|
||||||
// The following example demonstrates how to get a delegation.Token from
|
// The following example demonstrates how to get a delegation.Token from
|
||||||
@@ -236,18 +237,18 @@ func ExampleToken_FromSealed() {
|
|||||||
fmt.Println("NotBefore (nbf):", tkn.NotBefore())
|
fmt.Println("NotBefore (nbf):", tkn.NotBefore())
|
||||||
fmt.Println("Expiration (exp):", tkn.Expiration())
|
fmt.Println("Expiration (exp):", tkn.Expiration())
|
||||||
|
|
||||||
//Output:
|
// Output:
|
||||||
//DAG-CBOR (base64) in: glhAmnAkgfjAx4SA5pzJmtaHRJtTGNpF1y6oqb4yhGoM2H2EUGbBYT4rVDjMKBgCjhdGHjipm00L8iR5SsQh3sIEBaJhaEQ07QFxc3VjYW4vZGxnQDEuMC4wLX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QoL
|
||||||
//CID (base58BTC): zdpuAw26pFuvZa2Z9YAtpZZnWN6VmnRFr7Z8LVY5c7RVWoxGY
|
// CID (base58BTC): zdpuAw26pFuvZa2Z9YAtpZZnWN6VmnRFr7Z8LVY5c7RVWoxGY
|
||||||
//Issuer (iss): did:key:z6Mkpzn2n3ZGT2VaqMGSQC3tzmzV4TS9S71iFsDXE1WnoNH2
|
// Issuer (iss): did:key:z6Mkpzn2n3ZGT2VaqMGSQC3tzmzV4TS9S71iFsDXE1WnoNH2
|
||||||
//Audience (aud): did:key:z6Mkq5YmbJcTrPExNDi26imrTCpKhepjBFBSHqrBDN2ArPkv
|
// Audience (aud): did:key:z6Mkq5YmbJcTrPExNDi26imrTCpKhepjBFBSHqrBDN2ArPkv
|
||||||
//Subject (sub): did:key:z6MktA1uBdCpq4uJBqE9jjMiLyxZBg9a6xgPPKJjMqss6Zc2
|
// Subject (sub): did:key:z6MktA1uBdCpq4uJBqE9jjMiLyxZBg9a6xgPPKJjMqss6Zc2
|
||||||
//Command (cmd): /foo/bar
|
// Command (cmd): /foo/bar
|
||||||
//Policy (pol): TODO
|
// Policy (pol): TODO
|
||||||
//Nonce (nonce): 000102030405060708090a0b
|
// Nonce (nonce): 000102030405060708090a0b
|
||||||
//Meta (meta): TODO
|
// Meta (meta): TODO
|
||||||
//NotBefore (nbf): <nil>
|
// NotBefore (nbf): <nil>
|
||||||
//Expiration (exp): <nil>
|
// Expiration (exp): <nil>
|
||||||
}
|
}
|
||||||
|
|
||||||
func exampleCBORData() []byte {
|
func exampleCBORData() []byte {
|
||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
"github.com/libp2p/go-libp2p/core/crypto"
|
"github.com/libp2p/go-libp2p/core/crypto"
|
||||||
|
|
||||||
"github.com/ucan-wg/go-ucan/did"
|
"github.com/ucan-wg/go-ucan/did"
|
||||||
"github.com/ucan-wg/go-ucan/tokens/internal/envelope"
|
"github.com/ucan-wg/go-ucan/token/internal/envelope"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ToSealed wraps the delegation token in an envelope, generates the
|
// ToSealed wraps the delegation token in an envelope, generates the
|
||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
"github.com/ipld/go-ipld-prime/schema"
|
"github.com/ipld/go-ipld-prime/schema"
|
||||||
|
|
||||||
"github.com/ucan-wg/go-ucan/pkg/meta"
|
"github.com/ucan-wg/go-ucan/pkg/meta"
|
||||||
"github.com/ucan-wg/go-ucan/tokens/internal/envelope"
|
"github.com/ucan-wg/go-ucan/token/internal/envelope"
|
||||||
)
|
)
|
||||||
|
|
||||||
// [Tag] is the string used as a key within the SigPayload that identifies
|
// [Tag] is the string used as a key within the SigPayload that identifies
|
||||||
@@ -11,8 +11,8 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"gotest.tools/v3/golden"
|
"gotest.tools/v3/golden"
|
||||||
|
|
||||||
"github.com/ucan-wg/go-ucan/tokens/delegation"
|
"github.com/ucan-wg/go-ucan/token/delegation"
|
||||||
"github.com/ucan-wg/go-ucan/tokens/internal/envelope"
|
"github.com/ucan-wg/go-ucan/token/internal/envelope"
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:embed delegation.ipldsch
|
//go:embed delegation.ipldsch
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
package tokens
|
package token
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/ipld/go-ipld-prime/datamodel"
|
"github.com/ipld/go-ipld-prime/datamodel"
|
||||||
|
|
||||||
"github.com/ucan-wg/go-ucan/tokens/internal/envelope"
|
"github.com/ucan-wg/go-ucan/token/internal/envelope"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Info = envelope.Info
|
type Info = envelope.Info
|
||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"gotest.tools/v3/golden"
|
"gotest.tools/v3/golden"
|
||||||
|
|
||||||
"github.com/ucan-wg/go-ucan/tokens/internal/envelope"
|
"github.com/ucan-wg/go-ucan/token/internal/envelope"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCidFromBytes(t *testing.T) {
|
func TestCidFromBytes(t *testing.T) {
|
||||||
@@ -18,7 +18,7 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"gotest.tools/v3/golden"
|
"gotest.tools/v3/golden"
|
||||||
|
|
||||||
"github.com/ucan-wg/go-ucan/tokens/internal/envelope"
|
"github.com/ucan-wg/go-ucan/token/internal/envelope"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -43,7 +43,7 @@ import (
|
|||||||
"github.com/libp2p/go-libp2p/core/crypto"
|
"github.com/libp2p/go-libp2p/core/crypto"
|
||||||
|
|
||||||
"github.com/ucan-wg/go-ucan/did"
|
"github.com/ucan-wg/go-ucan/did"
|
||||||
"github.com/ucan-wg/go-ucan/tokens/internal/varsig"
|
"github.com/ucan-wg/go-ucan/token/internal/varsig"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -13,7 +13,7 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"gotest.tools/v3/golden"
|
"gotest.tools/v3/golden"
|
||||||
|
|
||||||
"github.com/ucan-wg/go-ucan/tokens/internal/envelope"
|
"github.com/ucan-wg/go-ucan/token/internal/envelope"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestDecode(t *testing.T) {
|
func TestDecode(t *testing.T) {
|
||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
"github.com/libp2p/go-libp2p/core/crypto/pb"
|
"github.com/libp2p/go-libp2p/core/crypto/pb"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
|
||||||
"github.com/ucan-wg/go-ucan/tokens/internal/varsig"
|
"github.com/ucan-wg/go-ucan/token/internal/varsig"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestDecode(t *testing.T) {
|
func TestDecode(t *testing.T) {
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package tokens
|
package token
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
@@ -10,8 +10,8 @@ import (
|
|||||||
"github.com/ipld/go-ipld-prime/codec/dagjson"
|
"github.com/ipld/go-ipld-prime/codec/dagjson"
|
||||||
"github.com/ipld/go-ipld-prime/datamodel"
|
"github.com/ipld/go-ipld-prime/datamodel"
|
||||||
|
|
||||||
"github.com/ucan-wg/go-ucan/tokens/delegation"
|
"github.com/ucan-wg/go-ucan/token/delegation"
|
||||||
"github.com/ucan-wg/go-ucan/tokens/internal/envelope"
|
"github.com/ucan-wg/go-ucan/token/internal/envelope"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Decode unmarshals the input data using the format specified by the
|
// Decode unmarshals the input data using the format specified by the
|
||||||
@@ -20,7 +20,7 @@ import (
|
|||||||
// Token is invalid.
|
// Token is invalid.
|
||||||
// Supported and returned types are:
|
// Supported and returned types are:
|
||||||
// - delegation.Token
|
// - delegation.Token
|
||||||
func Decode(b []byte, decFn codec.Decoder) (any, error) {
|
func Decode(b []byte, decFn codec.Decoder) (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
|
||||||
@@ -29,7 +29,7 @@ func Decode(b []byte, decFn codec.Decoder) (any, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 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) (any, error) {
|
func DecodeReader(r io.Reader, decFn codec.Decoder) (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
|
||||||
@@ -42,12 +42,12 @@ func DecodeReader(r io.Reader, decFn codec.Decoder) (any, error) {
|
|||||||
// Token is invalid.
|
// Token is invalid.
|
||||||
// Supported and returned types are:
|
// Supported and returned types are:
|
||||||
// - delegation.Token
|
// - delegation.Token
|
||||||
func FromDagCbor(b []byte) (any, error) {
|
func FromDagCbor(b []byte) (Token, error) {
|
||||||
return Decode(b, dagcbor.Decode)
|
return Decode(b, dagcbor.Decode)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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) (any, error) {
|
func FromDagCborReader(r io.Reader) (Token, error) {
|
||||||
return DecodeReader(r, dagcbor.Decode)
|
return DecodeReader(r, dagcbor.Decode)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,16 +56,16 @@ func FromDagCborReader(r io.Reader) (any, error) {
|
|||||||
// Token is invalid.
|
// Token is invalid.
|
||||||
// Supported and returned types are:
|
// Supported and returned types are:
|
||||||
// - delegation.Token
|
// - delegation.Token
|
||||||
func FromDagJson(b []byte) (any, error) {
|
func FromDagJson(b []byte) (Token, error) {
|
||||||
return Decode(b, dagjson.Decode)
|
return Decode(b, dagjson.Decode)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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) (any, error) {
|
func FromDagJsonReader(r io.Reader) (Token, error) {
|
||||||
return DecodeReader(r, dagjson.Decode)
|
return DecodeReader(r, dagjson.Decode)
|
||||||
}
|
}
|
||||||
|
|
||||||
func fromIPLD(node datamodel.Node) (any, error) {
|
func fromIPLD(node datamodel.Node) (Token, error) {
|
||||||
tag, err := envelope.FindTag(node)
|
tag, err := envelope.FindTag(node)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
Reference in New Issue
Block a user