import { Agent } from '@web3-storage/access/agent';
import type { Abilities, AgentMeta, Service } from '@web3-storage/access/types';
import type { Capability, DID, Proof, Signer, ConnectionView, Principal, Delegation, UCANOptions } from '@ucanto/interface';
/**
 * A Space is the core organizational structure of web3-storage,
 * similar to a bucket in S3 but with some special properties.
 *
 * At its core, a Space is just a public/private keypair that
 * that users can associate web3-storage uploads with. The keypair
 * is stored locally in a user's browser and can be registered with
 * web3-storage to enable uploads and allow for recovery of upload
 * capabilities in case the keypair is lost.
 */
export declare class Space implements Principal {
    #private;
    constructor(did: DID, meta?: Record<string, any>);
    /**
     * The given space name.
     */
    name(): string | undefined;
    /**
     * The DID of the space.
     */
    did(): DID;
    /**
     * Whether the space has been registered with the service.
     */
    registered(): boolean;
    /**
     * User defined space metadata.
     */
    meta(): Record<string, any>;
    /**
     * Compares this space's DID to `space`'s DID, returns
     * true if they are the same, false otherwise.
     * If `space` is null or undefined, returns false since
     * this space is neither.
     */
    sameAs(space?: Space): boolean;
}
export interface KeyringContextState {
    /**
     * The current space.
     */
    space?: Space;
    /**
     * Spaces available to this agent.
     */
    spaces: Space[];
    /**
     * The current user agent (this device).
     */
    agent?: Signer;
}
export interface KeyringContextActions {
    /**
     * Load the user agent and all stored data from secure storage.
     */
    loadAgent: () => Promise<void>;
    /**
     * Unload the user agent and all stored data from secure storage. Note: this
     * does not remove data, use `resetAgent` if that is desired.
     */
    unloadAgent: () => Promise<void>;
    /**
     * Unload the current space and agent from memory and remove from secure
     * storage. Note: this removes all data and is unrecoverable.
     */
    resetAgent: () => Promise<void>;
    /**
     * Create a new space with the passed name and set it as the current space.
     */
    createSpace: (name?: string) => Promise<DID>;
    /**
     * Use a specific space.
     */
    setCurrentSpace: (did: DID) => Promise<void>;
    /**
     * Register the current space, verify the email address and store in secure
     * storage. Use cancelRegisterSpace to abort. Automatically sets the
     * newly registered space as the current space.
     */
    registerSpace: (email: string) => Promise<void>;
    /**
     * Abort an ongoing account registration.
     */
    cancelRegisterSpace: () => void;
    /**
     * Get all the proofs matching the capabilities. Proofs are delegations with
     * an audience matching the agent DID.
     */
    getProofs: (caps: Capability[]) => Promise<Proof[]>;
    /**
     * Create a delegation to the passed audience for the given abilities with
     * the _current_ space as the resource.
     */
    createDelegation: (audience: Principal, abilities: Abilities[], options: CreateDelegationOptions) => Promise<Delegation>;
    /**
     * Import a proof that delegates `*` ability on a space to this agent
     */
    addSpace: (proof: Delegation) => Promise<void>;
}
export type CreateDelegationOptions = Omit<UCANOptions, 'audience'> & {
    audienceMeta?: AgentMeta;
};
export interface ServiceConfig {
    servicePrincipal?: Principal;
    connection?: ConnectionView<Service>;
}
/**
 * Convenience function for returning an agent's current Space.
 * @param agent
 * @returns the currently selected Space for the given agent
 */
export declare function getCurrentSpace(agent: Agent): Space | undefined;
/**
 * Convenience function for returning all of an agent's Spaces.
 * @param agent
 * @returns all of the given agent's Spaces
 */
export declare function getSpaces(agent: Agent): Space[];
export interface CreateAgentOptions extends ServiceConfig {
}
/**
 * Create an agent for managing identity. It uses RSA keys that are stored in
 * IndexedDB as unextractable `CryptoKey`s.
 */
export declare function createAgent(options?: CreateAgentOptions): Promise<Agent>;
