client

package
v0.0.0-...-69aaf77 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2026 License: Apache-2.0, MIT Imports: 55 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
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

Execute sends the given invocation using the provided client and decodes the response into the specified type.

func SpaceNameMetadata

func SpaceNameMetadata(name string) datamodel.Map

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 New

func New(issuer multikey.Issuer, serviceID did.DID, serviceURL url.URL, options ...Option) (*Client, error)

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) Accounts

func (c *Client) Accounts(ctx context.Context) ([]did.DID, error)

func (*Client) AddAttestations

func (c *Client) AddAttestations(ctx context.Context, attestations ...ucan.Invocation) error

AddAttestations adds the given attestations to the client's token store.

func (*Client) AddProofs

func (c *Client) AddProofs(ctx context.Context, delegations ...ucan.Delegation) error

AddProofs adds the given delegations 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) DID

func (c *Client) DID() did.DID

DID returns the DID of the agent.

func (*Client) IndexAdd

func (c *Client) IndexAdd(ctx context.Context, indexCID cid.Cid, space did.DID) error

func (*Client) Issuer

func (c *Client) Issuer() multikey.Issuer

Issuer returns the issuing signer of the agent.

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

func (c *Client) RequestAccess(ctx context.Context, account did.DID) (*access.RequestOK, error)

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) Reset

func (c *Client) Reset(ctx context.Context) error

Reset clears all tokens from the token store.

func (*Client) Retrieve

func (c *Client) Retrieve(ctx context.Context, location locator.Location) (io.ReadCloser, error)

func (*Client) ServiceID

func (c *Client) ServiceID() did.DID

ServiceID returns the DID of the upload service this client is connected to.

func (*Client) SpaceInfo

func (c *Client) SpaceInfo(ctx context.Context, space did.DID) (*spacecmds.InfoOK, error)

SpaceInfo invokes the /space/info capability to get information about a space, including which providers are associated with it.

func (*Client) SpaceNamed

func (c *Client) SpaceNamed(ctx context.Context, name string) (Space, error)

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

func (c *Client) Spaces(ctx context.Context) ([]Space, error)

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

func (c *Client) SpacesNamed(ctx context.Context, name string) ([]Space, error)

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

type MultipleSpacesFoundError struct {
	Name   string
	Spaces []Space
}

MultipleSpacesFoundError is returned when multiple spaces are found with the same name.

func (MultipleSpacesFoundError) Error

func (e MultipleSpacesFoundError) Error() string

type Option

type Option func(c *Client) error

Option is an option configuring a Client.

func WithReceiptsClient

func WithReceiptsClient(receiptsClient *receipt.Client) Option

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.

func (Space) DID

func (s Space) DID() did.DID

DID returns the DID of this space.

func (Space) Names

func (s Space) Names() []string

Names returns the names recorded in the metadata of this space's access proofs. Typically a space has a single name, but multiple are possible when several delegations (each with their own name) grant access to it.

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL