Agent

Usage:

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

Type Parameters

Hierarchy

  • Agent

Constructors

  • Type Parameters

    Parameters

    Returns Agent<S>

Properties

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

Accessors

  • get issuer(): Signer<`did:key:${string}`, SigAlg>
  • Returns Signer<`did:key:${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.

    Parameters

    Returns Promise<{}>

  • Adds set of proofs to the agent store.

    Parameters

    Returns Promise<{}>

  • Creates a space signer and a delegation to the agent

    Parameters

    • name: string

    Returns Promise<OwnedSpace>

  • Get current space DID

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

  • Get current space DID, proofs and abilities

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

  • Get delegations created by the agent for others.

    Parameters

    • Optional caps: CapabilityQuery[]

      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: CapabilityQuery[]

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

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

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

  • Execute invocations on the agent's connection

    Type Parameters

    Parameters

    • Rest ...invocations: I

    Returns Await<InferReceipts<I, S>>

    Example

    const i1 = await agent.invoke(Space.info, {})
    const i2 = await agent.invoke(Space.recover, {
    nb: {
    identity: 'mailto:hello@web3.storage',
    },
    })

    const results = await agent.execute2(i1, i2)
  • Get Space information from Access service

    Parameters

    • Optional space: URI<"did:">

    Returns Promise<SpaceInfoResult>

  • Import a space from a delegation.

    Parameters

    Returns Promise<SharedSpace>

  • Invoke and execute the given capability on the Access service connection


    await agent.invokeAndExecute(Space.recover, {
    nb: {
    identity: 'mailto: email@gmail.com',
    },
    })

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

    await recoverInvocation.execute(agent.connection)

    Type Parameters

    Parameters

    Returns Promise<InferReceipt<Capability<A, R, C>, S>>

  • Get all the proofs matching the capabilities.

    Proofs are delegations with an audience matching agent DID, or with an audience matching the session DID.

    Proof of session will also be included in the returned proofs if any proofs matching the passed capabilities require it.

    Parameters

    • Optional caps: CapabilityQuery[]

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

    • Optional options: {
          sessionProofIssuer?: `did:${string}:${string}`;
      }
      • Optional sessionProofIssuer?: `did:${string}:${string}`

        only include session proofs for this issuer

    Returns Delegation<Capabilities>[]

  • Parameters

    • secret: string
    • options: {
          name: string;
      }
      • name: string

    Returns Promise<OwnedSpace>

  • 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:key:${string}`

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

  • Create a new Agent instance, optionally with the passed initialization data.

    Type Parameters

    Parameters

    Returns Promise<Agent<R_2>>

Generated using TypeDoc