Documentation ¶
Index ¶
- func IsExpired(ucan UCANView) bool
- func IsTooEarly(ucan UCANView) bool
- func Now() uint64
- type Ability
- type Capability
- type CaveatBuilder
- type Fact
- type FactBuilder
- type Link
- type MapBuilder
- type Nonce
- type Option
- type Principal
- type Resource
- type Signer
- type UCANView
- type UTCUnixTimestamp
- type Verifier
- type Version
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsTooEarly ¶
IsTooEarly checks if a UCAN is not active yet.
Types ¶
type Ability ¶
type Ability = string
Ability is a string that represents some action that a UCAN holder can do. It MUST have format `${string}/${string}` | "*"
type Capability ¶
Capability represents an ability that a UCAN holder can perform with some resource.
func NewCapability ¶
func NewCapability[Caveats any](can Ability, with Resource, nb Caveats) Capability[Caveats]
type CaveatBuilder ¶
type CaveatBuilder = MapBuilder
type Fact ¶
A map of arbitrary facts and proofs of knowledge. The enclosed data MUST be self-evident and externally verifiable. It MAY include information such as hash preimages, server challenges, a Merkle proof, dictionary data, etc. See https://github.com/ucan-wg/spec/#325-facts
type FactBuilder ¶
type FactBuilder = MapBuilder
type MapBuilder ¶
MapBuilder builds a map of string => datamodel.Node from the underlying data.
type Option ¶
type Option func(cfg *ucanConfig) error
Option is an option configuring a UCAN.
func WithExpiration ¶
WithExpiration configures the expiration time in UTC seconds since Unix epoch.
func WithFacts ¶
func WithFacts(fct []FactBuilder) Option
WithFacts configures the facts for the UCAN.
func WithNotBefore ¶
WithNotBefore configures the time in UTC seconds since Unix epoch when the UCAN will become valid.
type Resource ¶
type Resource = string
Resorce is a string that represents resource a UCAN holder can act upon. It MUST have format `${string}:${string}`
type Signer ¶
type Signer interface { Principal crypto.Signer // SignatureCode is an integer corresponding to the byteprefix of the // signature algorithm. It is used to tag the [signature] so it can self // describe what algorithm was used. // // [signature]: https://github.com/ucan-wg/ucan-ipld/#25-signature SignatureCode() uint64 // SignatureAlgorithm is the name of the signature algorithm. It is a human // readable equivalent of the `SignatureCode`, however it is also used as the // last segment in [Nonstandard Signatures], which is used as an `alg` field // of the JWT header. // // [Nonstandard Signatures]: https://github.com/ucan-wg/ucan-ipld/#251-nonstandard-signatures SignatureAlgorithm() string }
Signer is an entity that can sign UCANs with keys from a `Principal`.
type UCANView ¶
type UCANView interface { // Model references the underlying IPLD datamodel instance. Model() *udm.UCANModel // Issuer is the signer of the UCAN. Issuer() Principal // Audience is the principal delegated to. Audience() Principal // Version is the spec version the UCAN conforms to. Version() Version // Capabilities are claimed abilities that can be performed on a resource. Capabilities() []Capability[any] // Expiration is the time in seconds since the Unix epoch that the UCAN // becomes invalid. Expiration() UTCUnixTimestamp // NotBefore is the time in seconds since the Unix epoch that the UCAN // becomes valid. NotBefore() UTCUnixTimestamp // Nonce is a randomly generated string to provide a unique Nonce() Nonce // Facts are arbitrary facts and proofs of knowledge. Facts() []Fact // Proofs of delegation. Proofs() []Link // Signature of the UCAN issuer. Signature() signature.SignatureView }
UCANView represents a decoded "view" of a UCAN that can be used in your domain logic, etc.
func Issue ¶
func Issue(issuer Signer, audience Principal, capabilities []Capability[CaveatBuilder], options ...Option) (UCANView, error)
Issue creates a new signed token with a given issuer. If expiration is not set it defaults to 30 seconds from now.
func NewUCANView ¶
NewUCANView creates a UCAN view from the underlying data model. Please note that this function does no verification of the model and it is callers responsibility to ensure that:
- Data model is correct contains all the field etc.
- Payload of the signature will match paylodad when model is serialized with DAG-JSON.
In other words you should never use this function unless you've parsed or decoded a valid UCAN and want to wrap it into a view.
type UTCUnixTimestamp ¶
type UTCUnixTimestamp = uint64
UTCUnixTimestamp is a timestamp in seconds since the Unix epoch.