Documentation
¶
Index ¶
- Constants
- func Execute[T cbg.CBORUnmarshaler](ctx context.Context, executor execution.Executor, inv ucan.Invocation, ...) (T, ucan.Receipt, ucan.Container, error)
- func SpaceNameMetadata(name string) datamodel.Map
- type AddedBlob
- type BlobAddConfig
- type BlobAddOption
- type ClaimResult
- type Client
- func (c *Client) AccessDelegate(ctx context.Context, space did.DID, delegations ...ucan.Delegation) (*access.DelegateOK, error)
- func (c *Client) Accounts(ctx context.Context) ([]did.DID, error)
- func (c *Client) AddAttestations(ctx context.Context, attestations ...ucan.Invocation) error
- func (c *Client) AddProofs(ctx context.Context, delegations ...ucan.Delegation) error
- func (c *Client) BlobAdd(ctx context.Context, content io.Reader, space did.DID, ...) (blob AddedBlob, err error)
- func (c *Client) BlobList(ctx context.Context, space did.DID, args blobcmds.ListArguments) (*blobcmds.ListOK, error)
- func (c *Client) ClaimAccess(ctx context.Context, sub did.DID) ([]ucan.Delegation, []ucan.Invocation, error)
- func (c *Client) DID() did.DID
- func (c *Client) IndexAdd(ctx context.Context, indexCID cid.Cid, space did.DID) error
- func (c *Client) Issuer() multikey.Issuer
- func (c *Client) PollClaim(ctx context.Context, requestOK *access.RequestOK) <-chan result.Result[ClaimResult, error]
- func (c *Client) PollClaimWithTick(ctx context.Context, requestOK *access.RequestOK, tickChan <-chan time.Time) <-chan result.Result[ClaimResult, error]
- func (c *Client) ProofChain(ctx context.Context, aud did.DID, cmd ucan.Command, sub did.DID) ([]ucan.Delegation, []cid.Cid, error)
- func (c *Client) ProviderAdd(ctx context.Context, customerAccount did.DID, provider did.DID, ...) (*providercmds.AddOK, error)
- func (c *Client) RequestAccess(ctx context.Context, account did.DID) (*access.RequestOK, error)
- func (c *Client) Reset(ctx context.Context) error
- func (c *Client) Retrieve(ctx context.Context, location locator.Location) (io.ReadCloser, error)
- func (c *Client) ServiceID() did.DID
- func (c *Client) SpaceInfo(ctx context.Context, space did.DID) (*spacecmds.InfoOK, error)
- func (c *Client) SpaceNamed(ctx context.Context, name string) (Space, error)
- func (c *Client) Spaces(ctx context.Context) ([]Space, error)
- func (c *Client) SpacesNamed(ctx context.Context, name string) ([]Space, error)
- func (c *Client) UploadAdd(ctx context.Context, space did.DID, root cid.Cid, shards []cid.Cid, ...) (*uploadcmds.AddOK, error)
- func (c *Client) UploadList(ctx context.Context, space did.DID, args uploadcmds.ListArguments) (*uploadcmds.ListOK, error)
- func (c *Client) UploadShardList(ctx context.Context, space did.DID, args shardcmds.ListArguments) (*shardcmds.ListOK, error)
- type MultipleSpacesFoundError
- type Option
- type RawMap
- type Space
- type SpaceNotFoundError
Constants ¶
const SpaceNameMetaKey = "name"
SpaceNameMetaKey is the delegation-metadata key under which a space's name is recorded when access to a space is granted (see the `space generate` command).
Variables ¶
This section is empty.
Functions ¶
func Execute ¶
func Execute[T cbg.CBORUnmarshaler]( ctx context.Context, executor execution.Executor, inv ucan.Invocation, options ...execution.RequestOption, ) (T, ucan.Receipt, ucan.Container, error)
Execute sends the given invocation using the provided client and decodes the response into the specified type.
func SpaceNameMetadata ¶
SpaceNameMetadata returns delegation metadata that records a space's name. It is attached when granting access to a space so that Space.Names can later recover the name.
Types ¶
type AddedBlob ¶
type AddedBlob struct {
Digest multihash.Multihash
Size uint64
Location ucan.Invocation
PDPAccept ucan.Invocation
}
type BlobAddConfig ¶
type BlobAddConfig struct {
PutClient *http.Client
PrecomputedDigest multihash.Multihash
PrecomputedSizePtr *uint64
ProgressFn func(uploaded int64)
}
BlobAddConfig holds configuration for [BlobAdd].
func NewBlobAddConfig ¶
func NewBlobAddConfig(options ...BlobAddOption) *BlobAddConfig
NewBlobAddConfig creates a new BlobAddConfig with the given options.
type BlobAddOption ¶
type BlobAddOption func(*BlobAddConfig)
BlobAddOption configures options for [BlobAdd].
func WithPrecomputedDigest ¶
func WithPrecomputedDigest(d multihash.Multihash, size uint64) BlobAddOption
WithPrecomputedDigest supplies a previously computed digest/size so we can skip re-hashing.
func WithPutClient ¶
func WithPutClient(client *http.Client) BlobAddOption
WithPutClient configures the HTTP client to use for uploading blobs.
func WithPutProgress ¶
func WithPutProgress(progressFn func(uploaded int64)) BlobAddOption
WithPutProgress registers a callback to receive upload progress for the HTTP PUT. The callback is best-effort and may be invoked frequently.
type ClaimResult ¶
type ClaimResult struct {
Delegations []ucan.Delegation
Attestations []ucan.Invocation
}
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) AccessDelegate ¶
func (c *Client) AccessDelegate(ctx context.Context, space did.DID, delegations ...ucan.Delegation) (*access.DelegateOK, error)
AccessDelegate invokes the /access/delegate capability to store delegations on the service. This allows an agent to store delegations (like space grants) so they can be retrieved later.
func (*Client) AddAttestations ¶
AddAttestations adds the given attestations to the client's token store.
func (*Client) BlobAdd ¶
func (c *Client) BlobAdd(ctx context.Context, content io.Reader, space did.DID, options ...BlobAddOption) (blob AddedBlob, err error)
BlobAdd adds a blob to the service. The issuer needs proof of `/blob/add` delegated capability.
Required delegated capability proofs: `/blob/add`
The `space` is the resource the invocation applies to. It is typically the DID of a space.
The `content` is the blob content to be added.
The `proofs` are delegation proofs to use in addition to those in the client. They won't be saved in the client, only used for this invocation.
Returns the multihash of the added blob and the location commitment that contains details about where the blob can be located, or an error if something went wrong.
func (*Client) BlobList ¶
func (c *Client) BlobList(ctx context.Context, space did.DID, args blobcmds.ListArguments) (*blobcmds.ListOK, error)
BlobList returns a paginated list of blobs stored in a space.
Required delegated capability proofs: `/blob/list`
The `space` is the resource the invocation applies to. It is typically the DID of a space.
The `args` are arguments required to perform an `/blob/list` invocation.
func (*Client) ClaimAccess ¶
func (c *Client) ClaimAccess(ctx context.Context, sub did.DID) ([]ucan.Delegation, []ucan.Invocation, error)
ClaimAccess fetches any stored delegations from the service. This is the second step of the Agent authorization process, from the Agent's point of view. After the Agent has [RequestAccess]ed, the service will instruct the user to confirm the access request out of band, e.g. via email. Once confirmed, a delegation will be available on the service for the Agent to claim.
func (*Client) PollClaim ¶
func (c *Client) PollClaim(ctx context.Context, requestOK *access.RequestOK) <-chan result.Result[ClaimResult, error]
PollClaim attempts to `/access/claim` and retries until it finds delegations authorized by way of the given `requestOK`. It returns a channel which will produce the result and then close.
func (*Client) PollClaimWithTick ¶
func (c *Client) PollClaimWithTick(ctx context.Context, requestOK *access.RequestOK, tickChan <-chan time.Time) <-chan result.Result[ClaimResult, error]
PollClaimWithTick is the same as [PollClaim], but accepts the tick channel for timing control over the polling. PollClaimWithTick will poll once for each value read on `tickChan`, until the claim succeeds or an error occurs.
func (*Client) ProofChain ¶
func (c *Client) ProofChain(ctx context.Context, aud did.DID, cmd ucan.Command, sub did.DID) ([]ucan.Delegation, []cid.Cid, error)
ProofChain recursively builds a proof chain of delegations from the given audience to the given subject for the specified command. It returns the list of delegations and their corresponding links in the order required for invocation. i.e. starting from the root Delegation (issued by the Subject), in strict sequence where the aud of the previous Delegation matches the iss of the next Delegation.
func (*Client) ProviderAdd ¶
func (c *Client) ProviderAdd(ctx context.Context, customerAccount did.DID, provider did.DID, consumer did.DID) (*providercmds.AddOK, error)
ProviderAdd invokes the /provider/add capability to provision a space with a customer account.
func (*Client) RequestAccess ¶
RequestAccess requests access to the service as an Account. This is the first step of the Agent authorization process.
The [issuer] is the Agent which would like to act as the Account.
The [account] is the Account the Agent would like to act as.
func (*Client) ServiceID ¶
ServiceID returns the DID of the upload service this client is connected to.
func (*Client) SpaceInfo ¶
SpaceInfo invokes the /space/info capability to get information about a space, including which providers are associated with it.
func (*Client) SpaceNamed ¶
SpaceNamed returns the single space with the given name. Returns SpaceNotFoundError if no space is found. Returns MultipleSpacesFoundError if multiple spaces have the same name.
func (*Client) Spaces ¶
Spaces returns all spaces we can act as, derived from the delegations held by the token store: each distinct subject of a (valid, non-attestation) delegation addressed to this agent is a space.
func (*Client) SpacesNamed ¶
SpacesNamed returns all spaces with the given name.
func (*Client) UploadAdd ¶
func (c *Client) UploadAdd(ctx context.Context, space did.DID, root cid.Cid, shards []cid.Cid, index *cid.Cid) (*uploadcmds.AddOK, error)
UploadAdd registers an "upload" with the service. The issuer needs proof of `/upload/add` delegated capability.
Required delegated capability proofs: `/upload/add`
The `space` is the resource the invocation applies to. It is typically the DID of a space.
func (*Client) UploadList ¶
func (c *Client) UploadList(ctx context.Context, space did.DID, args uploadcmds.ListArguments) (*uploadcmds.ListOK, error)
UploadList returns a paginated list of uploads in a space.
Required delegated capability proofs: `/upload/list`
The `space` is the resource the invocation applies to. It is typically the DID of a space.
func (*Client) UploadShardList ¶
func (c *Client) UploadShardList(ctx context.Context, space did.DID, args shardcmds.ListArguments) (*shardcmds.ListOK, error)
UploadShardList returns a paginated list of shards for an upload.
Required delegated capability proofs: `upload/shard/list`
The `space` is the resource the invocation applies to. It is typically the DID of a space.
type MultipleSpacesFoundError ¶
MultipleSpacesFoundError is returned when multiple spaces are found with the same name.
func (MultipleSpacesFoundError) Error ¶
func (e MultipleSpacesFoundError) Error() string
type Option ¶
Option is an option configuring a Client.
func WithReceiptsClient ¶
WithReceiptsClient configures the client to use for fetching receipts.
func WithRetrievalOptions ¶
func WithRetrievalOptions(retrievalOpts ...retrieval.ClientOption) Option
func WithTokenStore ¶
func WithTokenStore(store tokenstore.Store) Option
WithTokenStore configures the token store for the client to use. If one is not provided, a new memory store will be created.
func WithUCANClientOptions ¶
func WithUCANClientOptions(options ...client.HTTPOption) Option
WithHTTPClient configures the HTTP client for the client to use. If one is not provided, the default HTTP client will be used.
type RawMap ¶
type RawMap []byte
RawMap is a zapcore.ObjectMarshaler that decodes the given bytes as a CBOR-encoded IPLD map and logs its keys and values.
func (RawMap) MarshalLogObject ¶
func (rm RawMap) MarshalLogObject(enc zapcore.ObjectEncoder) error
type Space ¶
type Space struct {
// contains filtered or unexported fields
}
Space represents a space we can act as, along with the proofs that grant access.
func (Space) AccessProofs ¶
func (s Space) AccessProofs() []ucan.Delegation
AccessProofs returns the delegations that grant access to this space.
type SpaceNotFoundError ¶
type SpaceNotFoundError struct {
Name string
}
SpaceNotFoundError is returned when no space is found with a given name.
func (SpaceNotFoundError) Error ¶
func (e SpaceNotFoundError) Error() string