Class: Client
client.Client
Hierarchy
↳
Client
Constructors
constructor
• new Client(agentData
, options?
)
Parameters
Name | Type |
---|---|
agentData | AgentData |
options? | Object |
options.serviceConf | undefined | ServiceConf |
Overrides
Defined in
Properties
_agent
• Protected
_agent: Agent
Inherited from
Defined in
_serviceConf
• Protected
_serviceConf: ServiceConf
Inherited from
Defined in
capability
• capability: Object
Type declaration
Name | Type |
---|---|
space | SpaceClient |
store | StoreClient |
upload | UploadClient |
Defined in
Methods
_invocationConfig
▸ Protected
_invocationConfig(abilities
): Promise
<{ audience
: Principal
<`did:${string}:${string}`> ; issuer
: Signer
<`did:${string}:${string}`, SigAlg
> ; proofs
: Delegation
<Capabilities
>[] ; with
: `did:${string}:${string}` = resource }>
Parameters
Name | Type |
---|---|
abilities | Ability [] |
Returns
Promise
<{ audience
: Principal
<`did:${string}:${string}`> ; issuer
: Signer
<`did:${string}:${string}`, SigAlg
> ; proofs
: Delegation
<Capabilities
>[] ; with
: `did:${string}:${string}` = resource }>
Inherited from
Defined in
addProof
▸ addProof(proof
): Promise
<void
>
Add a proof to the agent. Proofs are delegations with an audience matching the agent DID.
Parameters
Name | Type |
---|---|
proof | Delegation <Capabilities > |
Returns
Promise
<void
>
Defined in
addSpace
▸ addSpace(proof
): Promise
<Space
>
Add a space from a received proof.
Parameters
Name | Type |
---|---|
proof | Delegation <Capabilities > |
Returns
Promise
<Space
>
Defined in
agent
▸ agent(): Signer
<`did:${string}:${string}`, SigAlg
>
The current user agent (this device).
Returns
Signer
<`did:${string}:${string}`, SigAlg
>
Defined in
createDelegation
▸ createDelegation(audience
, abilities
, options?
): Promise
<Delegation
<Capabilities
>>
Create a delegation to the passed audience for the given abilities with the current space as the resource.
Parameters
Name | Type |
---|---|
audience | Principal <`did:${string}:${string}`> |
abilities | TupleToUnion <AbilitiesArray >[] |
options? | Omit <UCANOptions , "audience" > & { audienceMeta? : AgentMeta } |
Returns
Promise
<Delegation
<Capabilities
>>
Defined in
createSpace
▸ createSpace(name?
): Promise
<Space
>
Create a new space with an optional name.
Parameters
Name | Type |
---|---|
name? | string |
Returns
Promise
<Space
>
Defined in
currentSpace
▸ currentSpace(): undefined
| Space
The current space.
Returns
undefined
| Space
Defined in
delegations
▸ delegations(caps?
): Delegation
<Capabilities
>[]
Get delegations created by the agent for others.
Parameters
Name | Type | Description |
---|---|---|
caps? | Capability <Ability , `${string}:${string}`, any >[] | Capabilities to filter by. Empty or undefined caps with return all the delegations. |
Returns
Defined in
proofs
▸ proofs(caps?
): Delegation
<Capabilities
>[]
Get all the proofs matching the capabilities.
Proofs are delegations with an audience matching the agent DID.
Parameters
Name | Type | Description |
---|---|---|
caps? | Capability <Ability , `${string}:${string}`, any >[] | Capabilities to filter by. Empty or undefined caps with return all the proofs. |
Returns
Defined in
registerSpace
▸ registerSpace(email
, options?
): Promise
<void
>
Register the current space with the service.
Invokes voucher/redeem
for the free tier, waits on the websocket for the
voucher/claim
and invokes it.
It also adds a full space delegation to the service in the voucher/claim
invocation to allow for recovery.
Parameters
Name | Type |
---|---|
email | string |
options? | Object |
options.signal | undefined | AbortSignal |
Returns
Promise
<void
>
Defined in
setCurrentSpace
▸ setCurrentSpace(did
): Promise
<void
>
Use a specific space.
Parameters
Name | Type |
---|---|
did | `did:${string}:${string}` |
Returns
Promise
<void
>
Defined in
spaces
▸ spaces(): Space
[]
Spaces available to this agent.
Returns
Space
[]
Defined in
uploadCAR
▸ uploadCAR(car
, options?
): Promise
<AnyLink
>
Uploads a CAR file to the service.
The difference between this function and capability.store.add
is that the
CAR file is automatically sharded and an "upload" is registered, linking
the individual shards (see capability.upload.add
).
Use the onShardStored
callback to obtain the CIDs of the CAR file shards.
Parameters
Name | Type | Description |
---|---|---|
car | BlobLike | CAR file. |
options? | UploadOptions |
Returns
Promise
<AnyLink
>
Defined in
uploadDirectory
▸ uploadDirectory(files
, options?
): Promise
<AnyLink
>
Uploads a directory of files to the service and returns the root data CID for the generated DAG. All files are added to a container directory, with paths in file names preserved.
Parameters
Name | Type | Description |
---|---|---|
files | FileLike [] | File data. |
options? | UploadOptions |
Returns
Promise
<AnyLink
>
Defined in
uploadFile
▸ uploadFile(file
, options?
): Promise
<AnyLink
>
Uploads a file to the service and returns the root data CID for the generated DAG.
Parameters
Name | Type | Description |
---|---|---|
file | BlobLike | File data. |
options? | UploadOptions |
Returns
Promise
<AnyLink
>