@storacha/client
Version:
Client for the storacha.network w3up api
139 lines • 5.57 kB
TypeScript
export { fromEmail };
export function list({ agent }: {
agent: API.Agent;
}, { account }?: {
account?: `did:mailto:${string}` | undefined;
}): Record<`did:mailto:${string}:${string}`, Account>;
export function login({ agent }: {
agent: API.Agent;
}, email: EmailAddress, options?: {
signal?: AbortSignal | undefined;
appName?: API.AppName | undefined;
sso?: API.SSORequestParams | undefined;
}): Promise<API.Result<Account, Error>>;
export function externalLogin({ agent }: {
agent: API.Agent;
}, { request, expiration, ...options }: {
request: API.Link;
expiration: API.UTCUnixTimestamp;
signal?: AbortSignal | undefined;
receiptsEndpoint?: string | undefined;
}): Promise<API.Result<Account, Error>>;
/**
* @typedef {object} Model
* @property {API.DidMailto} id
* @property {API.Agent} agent
* @property {API.Delegation[]} proofs
*/
export class Account {
/**
* @param {Model} model
*/
constructor(model: Model);
model: Model;
plan: AccountPlan;
get agent(): API.Agent<import("@storacha/access/types").Service>;
get proofs(): API.Delegation<API.Capabilities>[];
did(): `did:mailto:${string}:${string}`;
toEmail(): `${string}@${string}`;
/**
* @param {API.Delegation} proof
*/
addProof(proof: API.Delegation): void;
toJSON(): {
id: `did:mailto:${string}:${string}`;
proofs: API.DelegationJSON<API.Delegation<API.Capabilities>>[];
};
/**
* Provisions given `space` with this account.
*
* @param {API.SpaceDID} space
* @param {object} input
* @param {API.ProviderDID} [input.provider]
* @param {API.Agent} [input.agent]
*/
provision(space: API.SpaceDID, input?: {
provider?: `did:web:${string}` | undefined;
agent?: API.Agent<import("@storacha/access/types").Service> | undefined;
}): Promise<API.Result<{}, API.Failure | API.HandlerNotFound | API.HandlerExecutionError | API.InvalidAudience | API.Unauthorized>>;
/**
* Saves account in the agent store so it can be accessed across sessions.
*
* @param {object} input
* @param {API.Agent} [input.agent]
*/
save({ agent }?: {
agent?: API.Agent<import("@storacha/access/types").Service> | undefined;
}): Promise<API.Result<API.Unit, Error>>;
}
export class AccountPlan {
/**
* @param {Model} model
*/
constructor(model: Model);
model: Model;
/**
* Gets information about the plan associated with this account.
*
* @param {object} [options]
* @param {string} [options.nonce]
*/
get(options?: {
nonce?: string | undefined;
}): Promise<API.Result<API.PlanGetSuccess, API.HandlerNotFound | API.HandlerExecutionError | API.InvalidAudience | API.Unauthorized | API.PlanGetFailure>>;
/**
* Sets the plan associated with this account.
*
* @param {import('@ucanto/interface').DID} productDID
* @param {object} [options]
* @param {string} [options.nonce]
*/
set(productDID: import("@ucanto/interface").DID, options?: {
nonce?: string | undefined;
}): Promise<API.Result<API.Unit, API.HandlerNotFound | API.HandlerExecutionError | API.InvalidAudience | API.Unauthorized | API.PlanSetFailure>>;
/**
* Waits for a payment plan to be selected.
* This method continuously checks the account's payment plan status
* at a specified interval until a valid plan is selected, or when the timeout is reached,
* or when the abort signal is aborted.
*
* @param {object} [options]
* @param {number} [options.interval] - The polling interval in milliseconds (default is 1000ms).
* @param {number} [options.timeout] - The maximum time to wait in milliseconds before throwing a timeout error (default is 15 minutes).
* @param {AbortSignal} [options.signal] - An optional AbortSignal to cancel the waiting process.
* @returns {Promise<import('@storacha/access').PlanGetSuccess>} - Resolves once a payment plan is selected within the timeout.
* @throws {Error} - Throws an error if there is an issue retrieving the payment plan or if the timeout is exceeded.
*/
wait(options?: {
interval?: number | undefined;
timeout?: number | undefined;
signal?: AbortSignal | undefined;
}): Promise<import("@storacha/access").PlanGetSuccess>;
/**
*
* @param {import('@storacha/access').AccountDID} accountDID
* @param {string} returnURL
* @param {object} [options]
* @param {string} [options.nonce]
*/
createAdminSession(accountDID: import("@storacha/access").AccountDID, returnURL: string, options?: {
nonce?: string | undefined;
}): Promise<API.Result<API.PlanCreateAdminSessionSuccess, API.HandlerNotFound | API.HandlerExecutionError | API.InvalidAudience | API.Unauthorized | API.PlanCreateAdminSessionFailure>>;
/**
*
* @param {object} [options]
* @param {string} [options.nonce]
*/
subscriptions(options?: {
nonce?: string | undefined;
}): Promise<API.Result<import("@storacha/access").SubscriptionListSuccess, API.Failure | API.HandlerNotFound | API.HandlerExecutionError | API.InvalidAudience | API.Unauthorized>>;
}
export type EmailAddress = import("@storacha/did-mailto").EmailAddress;
export type Model = {
id: API.DidMailto;
agent: API.Agent;
proofs: API.Delegation[];
};
import { fromEmail } from '@storacha/did-mailto';
import * as API from './types.js';
//# sourceMappingURL=account.d.ts.map