UNPKG

@opendatalabs/vana-sdk

Version:

A TypeScript library for interacting with Vana Network smart contracts.

27 lines (26 loc) 1.34 kB
/** * Typed errors returned by Personal Server endpoints. * * @remarks * vana-connect (and other PS clients) need to branch on a small, stable set * of lowercase error codes. Personal Server routes currently return protocol * errors as `{ error: { code, errorCode, message } }`, while older PoC * clients used `{ code, message }`; the parser accepts both shapes. * * @category Auth */ /** Stable error codes returned by Personal Server. */ export type PSErrorCode = "missing_auth" | "invalid_signature" | "unregistered_builder" | "not_owner" | "expired_token" | "grant_invalid" | "grant_required" | "grant_expired" | "grant_revoked" | "scope_mismatch" | "fee_required" | "ps_unavailable" | "server_not_configured" | "content_too_large"; /** Typed error wrapping a non-2xx Personal Server response. */ export declare class PSError extends Error { readonly code: PSErrorCode; constructor(code: PSErrorCode, message: string); } /** * Read a Personal Server JSON error body from a non-2xx {@link Response} and * return the typed {@link PSError}. The returned code is always lowercase. * * @returns A {@link PSError} for non-2xx responses with a recognised code, * or `null` for 2xx responses, malformed JSON, or unrecognised codes. */ export declare function parsePSError(response: Response): Promise<PSError | null>;