openvibe-sdk/commerce
Generated at from
openvibe-contracts v0.454.0 and
openvibe-sdk v0.193.0.
From types/commerce.d.ts (server only). Declarations are shown verbatim.
class CommerceError
The Billing client Tips and VIP share (server only). openvibe-contracts is required lazily, when a token client is created.
export declare class CommerceError extends Error {
constructor(message: string, init?: { status?: number | null; code?: string | null; body?: unknown });
status: number | null;
code: string | null;
body: unknown;
/** No status, 5xx, 429, 401 or code 'billing.frozen'. */
readonly retryable: boolean;
}function intentKey
`prefix` then each part that is neither null/undefined nor '', joined with ':'; throws TypeError on an empty prefix.
export declare function intentKey(prefix: string, parts: (string | number | null | undefined)[]): string;function receipt
{ kind, at: now ISO, ...fields } with null/undefined fields stripped; constructed, never posted.
export declare function receipt(kind: string, fields?: Record<string, unknown>): { kind: string; at: string; [field: string]: unknown };type CommerceConfig
export type CommerceConfig = {
billing: { url: string; audience?: string; timeoutMs?: number };
network?: { internalUrl: string };
oauth?: { clientId: string; clientSecret: string };
};type CommerceCaps
export type CommerceCaps = { intent?: string; transfer?: string; subscription?: string; entitlement?: string; rates?: string; tier?: string };type CommerceTier
export type CommerceTier = { tier: number; price_cents: number; status: 'active' | 'archived'; updated_at?: string };type CommerceTokenClient
export type CommerceTokenClient = { authHeaders(): Promise<Record<string, string>>; invalidate(): void };type CommerceOptions
export type CommerceOptions = {
caps: CommerceCaps;
fetchImpl?: typeof fetch;
/** Keyed by logical key (intent, transfer, …) or by capability string. */
tokenClients?: Record<string, CommerceTokenClient> | null;
timeoutMs?: number;
};type CommerceCall
export type CommerceCall = { key?: string; traceparent?: string; /** Extra headers for the call (the subject assertion rides on them). */ headers?: Record<string, string> };type CommerceClient
export type CommerceClient = {
createIntent(a: { provider: string; kind?: 'purchase' | 'subscription'; subject: string; bits?: number; creator?: string; tier?: number; autoRenew?: boolean; successUrl?: string; cancelUrl?: string } & CommerceCall): Promise<any>;
createTransfer(a: { from: string; to: string; amount: number; kind?: string; target?: unknown; message?: string } & CommerceCall): Promise<any>;
refundTransfer(a: { txnId: string; amount?: number; reason?: string; key?: string }): Promise<any>;
subscribeWithCredit(a: { subscriber: string; creator: string; tier?: number; autoRenew?: boolean } & CommerceCall): Promise<any>;
cancelSubscription(a: { id: string } & CommerceCall): Promise<any>;
getSubscription(id: string, o?: { headers?: Record<string, string> }): Promise<any>;
listSubscriptions(a?: { streamer?: string; subscriber?: string; status?: string }, o?: { headers?: Record<string, string> }): Promise<any>;
entitlement(subject: string, creator?: string, o?: { headers?: Record<string, string> }): Promise<any>;
rates(): Promise<any>;
/** A creator's tier prices (Billing, contracts 0.201.0); uses caps.tier, else caps.intent. */
listTiers(creator: string): Promise<{ streamer: { type: 'user'; id: string }; tiers: CommerceTier[]; default_price_cents: number; min_price_cents: number; max_price_cents: number; max_tiers: number }>;
/** Set one tier's monthly price (billing.tier.manage). */
setTier(a: { creator: string; tier: number; priceCents: number; status?: 'active' | 'archived' } & CommerceCall): Promise<{ tier: CommerceTier }>;
baseUrl(): string;
};function createCommerceClient
export declare function createCommerceClient(config: CommerceConfig, options: CommerceOptions): CommerceClient;