Documentation
¶
Index ¶
- Variables
- type AddedBlob
- type CapabilityQuery
- type Client
- func (c *Client) AccessDelegate(ctx context.Context, space did.DID, delegations ...delegation.Delegation) (accesscap.DelegateOk, error)
- func (c *Client) Accounts() []did.DID
- func (c *Client) AddProofs(delegations ...delegation.Delegation) error
- func (c *Client) ClaimAccess(ctx context.Context) ([]udelegation.Delegation, error)
- func (c *Client) Connection() uclient.Connection
- func (c *Client) DID() did.DID
- func (c *Client) FilecoinOffer(ctx context.Context, space did.DID, content ipld.Link, piece ipld.Link, ...) (filecoincap.OfferOk, error)
- func (c *Client) Issuer() principal.Signer
- func (c *Client) PollClaim(ctx context.Context, authOk access.AuthorizeOk) <-chan result.Result[[]delegation.Delegation, error]
- func (c *Client) PollClaimWithTick(ctx context.Context, authOk access.AuthorizeOk, tickChan <-chan time.Time) <-chan result.Result[[]delegation.Delegation, error]
- func (c *Client) Proofs(queries ...CapabilityQuery) []delegation.Delegation
- func (c *Client) ProviderAdd(ctx context.Context, customerAccount did.DID, provider did.DID, ...) (providercap.AddOk, error)
- func (c *Client) RequestAccess(ctx context.Context, account string) (access.AuthorizeOk, error)
- func (c *Client) Reset() error
- func (c *Client) Retrieve(ctx context.Context, space did.DID, location locator.Location, ...) ([]byte, error)
- func (c *Client) SpaceBlobAdd(ctx context.Context, content io.Reader, space did.DID, ...) (AddedBlob, error)
- func (c *Client) SpaceBlobReplicate(ctx context.Context, space did.DID, blob types.Blob, replicaCount uint, ...) (spaceblobcap.ReplicateOk, fx.Effects, error)
- func (c *Client) SpaceIndexAdd(ctx context.Context, indexCID cid.Cid, indexSize uint64, rootCID cid.Cid, ...) error
- func (c *Client) SpaceInfo(ctx context.Context, space did.DID) (spacecap.InfoOk, error)
- func (c *Client) Spaces() ([]did.DID, error)
- func (c *Client) UploadAdd(ctx context.Context, space did.DID, root ipld.Link, shards []ipld.Link) (uploadcap.AddOk, error)
- func (c *Client) UploadList(ctx context.Context, space did.DID, params uploadcap.ListCaveats) (uploadcap.ListOk, error)
- type FilecoinOfferOption
- type FilecoinOfferOptions
- type Option
- func WithAdditionalProofs(proofs ...delegation.Delegation) Option
- func WithConnection(conn uclient.Connection) Option
- func WithData(data agentdata.AgentData) Option
- func WithPrincipal(principal principal.Signer) Option
- func WithReceiptsClient(receiptsClient *receipt.Client) Option
- func WithSaveFn(saveFn func(agentdata.AgentData) error) Option
- type SpaceBlobAddOption
Constants ¶
This section is empty.
Variables ¶
var DefaultConnection uclient.Connection
var DefaultReceiptsClient *receipt.Client
Functions ¶
This section is empty.
Types ¶
type AddedBlob ¶
type AddedBlob struct {
Digest multihash.Multihash
Location delegation.Delegation
PDPAccept invocation.Invocation
}
type CapabilityQuery ¶
type CapabilityQuery struct {
// Can is the ability to match (e.g., "store/add"). Use "*" to match all abilities.
Can ucan.Ability
// With is the resource to match. Use "ucan:*" to match all resources.
With ucan.Resource
}
CapabilityQuery represents a query to filter proofs by capability.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
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) AddProofs ¶
func (c *Client) AddProofs(delegations ...delegation.Delegation) error
AddProofs adds the given delegations to the client's data and saves it.
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) FilecoinOffer ¶
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 ...CapabilityQuery) []delegation.Delegation
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 c.data.Delegations) 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 ¶
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) 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 (*Client) SpaceInfo ¶
SpaceInfo invokes the space/info capability to get information about a space, including which providers are associated with it.
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 ¶
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 WithData ¶
WithData configures the agent data for the client to use. If one is not provided, a new agent data will be created with a new principal.
func WithPrincipal ¶
WithPrincipal configures the principal for the client to use. If one is not provided, a new principal will be generated.
func WithReceiptsClient ¶
WithReceiptsClient configures the client to use for fetching receipts.
type SpaceBlobAddOption ¶
type SpaceBlobAddOption func(*spaceBlobAddConfig)
SpaceBlobAddOption configures options for SpaceBlobAdd.
func WithPutClient ¶
func WithPutClient(client *http.Client) SpaceBlobAddOption
WithPutClient configures the HTTP client to use for uploading blobs.