Agent

Usage:

import { Agent } from '@web3-storage/access/agent'

Hierarchy

  • Agent

Constructors

Properties

#private: any
connection: ConnectionView<Service>
url: URL

Accessors

  • get issuer(): Signer<`did:${string}:${string}`, SigAlg>
  • Returns Signer<`did:${string}:${string}`, SigAlg>

  • get meta(): AgentMeta
  • Returns AgentMeta

  • get spaces(): Map<`did:${string}:${string}`, SpaceMeta>
  • Returns Map<`did:${string}:${string}`, SpaceMeta>

Methods

  • Add a proof to the agent store

    A proof is a delegation with an audience matching agent DID

    Parameters

    Returns Promise<void>

  • Creates a space signer and a delegation to the agent

    Parameters

    • Optional name: string

    Returns Promise<{
        did: `did:key:${string}`;
        meta: SpaceMeta;
        proof: Delegation<[ToDeriveClaim<{
            can: "*";
            nb?: InferCaveats<{}>;
            with: URI<"did:">;
        }>]>;
    }>

  • Get current space DID

    Returns undefined | `did:${string}:${string}`

  • Get current space DID, proofs and abilities

    Returns undefined | {
        capabilities: any[];
        did: `did:${string}:${string}`;
        meta: undefined | SpaceMeta;
        proofs: Delegation<Capabilities>[];
    }

  • Get delegations created by the agent for others.

    Parameters

    • Optional caps: Capability<Ability, `${string}:${string}`, any>[]

      Capabilities to filter by. Empty or undefined caps with return all the delegations.

    Returns Delegation<Capabilities>[]

  • Get delegations created by the agent for others and their metadata.

    Parameters

    • Optional caps: Capability<Ability, `${string}:${string}`, any>[]

      Capabilities to filter by. Empty or undefined caps with return all the delegations.

    Returns {
        delegation: Delegation<Capabilities>;
        meta: DelegationMeta;
    }[]

  • Returns `did:${string}:${string}`

  • Get Space information from Access service

    Parameters

    • Optional space: URI<"did:">

    Returns Promise<Selectable<SpaceTable> & {
        error?: undefined;
    }>

  • Import a space from a '*' delegation

    Parameters

    Returns Promise<{
        did: `did:${string}:${string}`;
        meta: SpaceMeta;
        proof: Delegation<[{
            can: "*";
            nb?: InferCaveats<{}>;
            with: URI<"did:">;
        }]>;
    }>

  • Creates an invocation for the given capability with Agent's proofs, service, issuer and space.

    Example

    const recoverInvocation = await agent.invoke(Space.recover, {
    nb: {
    identity: 'mailto: email@gmail.com',
    },
    })

    await recoverInvocation.execute(agent.connection)
    // or
    await agent.execute(recoverInvocation)

    Type Parameters

    Parameters

    Returns Promise<IssuedInvocationView<InferInvokedCapability<CAP_1>>>

  • Parameters

    Returns Peer

  • Get all the proofs matching the capabilities

    Proofs are delegations with an audience matching agent DID.

    Parameters

    • Optional caps: Capability<Ability, `${string}:${string}`, any>[]

      Capabilities to filter by. Empty or undefined caps with return all the proofs.

    Returns Delegation<Capabilities>[]

  • Parameters

    • email: string
    • Optional opts: {
          signal?: AbortSignal;
      }
      • Optional signal?: AbortSignal

    Returns Promise<Delegation<[{
        can: "*";
        nb?: InferCaveats<{}>;
        with: URI<"did:">;
    }]>[]>

  • Invokes voucher/redeem for the free tier, wait 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

    • email: string
    • Optional opts: {
          signal?: AbortSignal;
      }
      • Optional signal?: AbortSignal

    Returns Promise<void>

  • Clean up any expired delegations.

    Returns Promise<void>

  • Sets the current selected space

    Other methods will default to use the current space if no resource is defined

    Parameters

    • space: `did:${string}:${string}`

    Returns Promise<`did:${string}:${string}`>

Generated using TypeDoc