client

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: Apache-2.0, MIT Imports: 63 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConnection uclient.Connection
View Source
var DefaultReceiptsClient *receipt.Client

Functions

This section is empty.

Types

type AddedBlob

type AddedBlob struct {
	Digest    multihash.Multihash
	Size      uint64
	Location  invocation.Invocation
	PDPAccept invocation.Invocation
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(options ...Option) (*Client, error)

NewClient creates a new client.

func (*Client) AccessDelegate

func (c *Client) AccessDelegate(ctx context.Context, space did.DID, delegations ...delegation.Delegation) (accesscap.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() ([]did.DID, error)

func (*Client) AddProofs

func (c *Client) AddProofs(delegations ...delegation.Delegation) error

AddProofs adds the given delegations to the client's store.

func (*Client) ClaimAccess

func (c *Client) ClaimAccess(ctx context.Context) ([]udelegation.Delegation, 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) Connection

func (c *Client) Connection() uclient.Connection

Connection returns the connection used by the client.

func (*Client) DID

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

DID returns the DID of the client.

func (*Client) FilecoinInfo added in v0.5.0

func (c *Client) FilecoinInfo(ctx context.Context, space did.DID, piece ipld.Link) (filecoincap.InfoOk, error)

func (*Client) FilecoinOffer

func (c *Client) FilecoinOffer(ctx context.Context, space did.DID, content ipld.Link, piece ipld.Link, opts ...FilecoinOfferOption) (filecoincap.OfferOk, error)

func (*Client) Issuer

func (c *Client) Issuer() principal.Signer

Issuer returns the issuing signer of the client.

func (*Client) PollClaim

func (c *Client) PollClaim(ctx context.Context, authOk access.AuthorizeOk) <-chan result.Result[[]delegation.Delegation, error]

PollClaim attempts to `access/claim` and retries until it finds delegations authorized by way of the given `authOk`. It returns a channel which will produce the result and then close.

func (*Client) PollClaimWithTick

func (c *Client) PollClaimWithTick(ctx context.Context, authOk access.AuthorizeOk, tickChan <-chan time.Time) <-chan result.Result[[]delegation.Delegation, 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) Proofs

func (c *Client) Proofs(queries ...agentstore.CapabilityQuery) ([]delegation.Delegation, error)

Proofs returns delegations that match the given capability queries. If no queries are provided, returns all non-expired delegations. Delegations are filtered by:

  • Expiration: excludes expired delegations
  • NotBefore: excludes delegations that are not yet valid
  • Capability matching: if queries are provided, only returns delegations whose capabilities match at least one of the queries

Additionally, this method includes relevant session proofs (ucan/attest delegations) that attest to the returned authorizations.

Returns both stored delegations (from store) and additional proofs (from c.additionalProofs).

func (*Client) ProviderAdd

func (c *Client) ProviderAdd(ctx context.Context, customerAccount did.DID, provider did.DID, consumer did.DID) (providercap.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 string) (access.AuthorizeOk, 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() error

Reset clears all delegations from the store while preserving the principal.

func (*Client) Retrieve

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

func (*Client) SpaceBlobAdd

func (c *Client) SpaceBlobAdd(ctx context.Context, content io.Reader, space did.DID, options ...SpaceBlobAddOption) (AddedBlob, error)

SpaceBlobAdd adds a blob to the service. The issuer needs proof of `space/blob/add` delegated capability.

Required delegated capability proofs: `space/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) SpaceBlobReplicate

func (c *Client) SpaceBlobReplicate(ctx context.Context, space did.DID, blob types.Blob, replicaCount uint, locationCommitment delegation.Delegation) (spaceblobcap.ReplicateOk, fx.Effects, error)

func (*Client) SpaceIndexAdd

func (c *Client) SpaceIndexAdd(ctx context.Context, indexCID cid.Cid, indexSize uint64, rootCID cid.Cid, space did.DID) error

func (*Client) SpaceInfo

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

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

func (*Client) Spaces

func (c *Client) Spaces() ([]did.DID, error)

Spaces returns all spaces we can act as.

func (*Client) UploadAdd

func (c *Client) UploadAdd(ctx context.Context, space did.DID, root ipld.Link, shards []ipld.Link) (uploadcap.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.

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.

The `caveats` are caveats required to perform an `upload/add` invocation.

func (*Client) UploadList

func (c *Client) UploadList(ctx context.Context, space did.DID, params uploadcap.ListCaveats) (uploadcap.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.

The `params` are caveats required to perform an `upload/list` invocation.

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.

type FilecoinOfferOption

type FilecoinOfferOption func(opts *FilecoinOfferOptions)

func WithPDPAcceptInvocation

func WithPDPAcceptInvocation(inv invocation.Invocation) FilecoinOfferOption

type FilecoinOfferOptions

type FilecoinOfferOptions struct {
	// contains filtered or unexported fields
}

func NewFilecoinOfferOptions

func NewFilecoinOfferOptions(opts []FilecoinOfferOption) *FilecoinOfferOptions

func (*FilecoinOfferOptions) PDPAcceptInvocation

func (foo *FilecoinOfferOptions) PDPAcceptInvocation() invocation.Invocation

type Option

type Option func(c *Client) error

Option is an option configuring a Client.

func WithAdditionalProofs

func WithAdditionalProofs(proofs ...delegation.Delegation) Option

WithAdditionalProofs adds proofs to the client that will be included in Proofs() results but will not be saved to the client's store. This is useful for proofs that are only needed for a single operation.

func WithConnection

func WithConnection(conn uclient.Connection) Option

WithConnection configures the connection for the client to use. If one is not provided, the default connection will be used.

func WithPrincipal

func WithPrincipal(p principal.Signer) Option

WithPrincipal configures the principal for the client to use. If a store is already configured, the principal will be set on that store. Otherwise, a new memory store will be created with this principal.

func WithReceiptsClient

func WithReceiptsClient(receiptsClient *receipt.Client) Option

WithReceiptsClient configures the client to use for fetching receipts.

func WithRetrievalOptions added in v0.4.0

func WithRetrievalOptions(retrievalOpts ...rclient.Option) Option

func WithStore added in v0.5.0

func WithStore(store agentstore.Store) Option

WithStore configures the agent store for the client to use. If one is not provided, a new memory store will be created.

type SpaceBlobAddConfig added in v0.2.0

type SpaceBlobAddConfig struct {
	// contains filtered or unexported fields
}

SpaceBlobAddConfig holds configuration for SpaceBlobAdd.

func NewSpaceBlobAddConfig added in v0.2.0

func NewSpaceBlobAddConfig(options ...SpaceBlobAddOption) *SpaceBlobAddConfig

NewSpaceBlobAddConfig creates a new SpaceBlobAddConfig with the given options.

func (*SpaceBlobAddConfig) PrecomputedDigest added in v0.2.0

func (s *SpaceBlobAddConfig) PrecomputedDigest() multihash.Multihash

func (*SpaceBlobAddConfig) PrecomputedSizePtr added in v0.2.0

func (s *SpaceBlobAddConfig) PrecomputedSizePtr() *uint64

func (*SpaceBlobAddConfig) PutClient added in v0.2.0

func (s *SpaceBlobAddConfig) PutClient() *http.Client

type SpaceBlobAddOption

type SpaceBlobAddOption func(*SpaceBlobAddConfig)

SpaceBlobAddOption configures options for SpaceBlobAdd.

func WithPrecomputedDigest added in v0.2.0

func WithPrecomputedDigest(d multihash.Multihash, size uint64) SpaceBlobAddOption

WithPrecomputedDigest supplies a previously computed digest/size so we can skip re-hashing.

func WithPutClient

func WithPutClient(client *http.Client) SpaceBlobAddOption

WithPutClient configures the HTTP client to use for uploading blobs.

func WithPutProgress added in v0.4.0

func WithPutProgress(progressFn func(uploaded int64)) SpaceBlobAddOption

WithPutProgress registers a callback to receive upload progress for the HTTP PUT. The callback is best-effort and may be invoked frequently.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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