@storacha/client
Version:
Client for the storacha.network w3up api
57 lines • 1.99 kB
TypeScript
export class CouponAPI extends Base {
/**
* Redeems coupon from the the the archive. Throws an error if the coupon
* password is invalid or if provided archive is not a valid.
*
* @param {Uint8Array} archive
* @param {object} [options]
* @param {string} [options.password]
*/
redeem(archive: Uint8Array, options?: {
password?: string | undefined;
}): Promise<GrantedAccess>;
/**
* Issues a coupon for the given delegation.
*
* @param {Omit<CouponOptions, 'issuer'>} options
*/
issue({ proofs, ...options }: Omit<CouponOptions, "issuer">): Promise<Coupon>;
}
export function extract(archive: Uint8Array): Promise<API.Result<Coupon, Error>>;
export function archive(coupon: Model): Promise<API.Result<Uint8Array<ArrayBufferLike>, Error>>;
export function issue({ password, ...options }: CouponOptions): Promise<Coupon>;
export function redeem(coupon: Model, { agent, password }: {
agent: API.Agent;
password?: string | undefined;
}): Promise<API.Result<GrantedAccess, Error>>;
export class Coupon {
/**
* @param {Model} model
*/
constructor(model: Model);
model: Model;
get proofs(): [API.Delegation<API.Capabilities>];
/**
*
* @param {API.Agent} agent
* @param {object} [options]
* @param {string} [options.password]
*/
redeem(agent: API.Agent, options?: {
password?: string | undefined;
}): Promise<API.Result<GrantedAccess, Error>>;
archive(): Promise<API.Result<Uint8Array<ArrayBufferLike>, Error>>;
}
/**
* Issues a coupon for the given delegation.
*/
export type CouponOptions = Omit<import("@ucanto/interface").DelegationOptions<API.Capabilities>, "audience"> & {
password?: string;
};
export type Model = {
proofs: [API.Delegation];
};
import { Base } from './base.js';
import { GrantedAccess } from '@storacha/access/access';
import * as API from '@storacha/access/types';
//# sourceMappingURL=coupon.d.ts.map