@cubewire/wallet-ts-sdk
v0.2.9
Published
TypeScript SDK for the Cubewire Wallet API (Speakeasy-generated, typed client and models).
Readme
@cubewire/wallet-ts-sdk
Type-safe TypeScript SDK for the Cubewire Wallet API — manage vaults, transactions, policies, signing, and more.
Features
- Full Wallet API coverage — vaults, transactions, signing, policies, assets, networks, webhooks, and more
- Type-safe — generated models and operations with full TypeScript types
- Tree-shakeable — standalone functions for minimal bundle size (FUNCTIONS.md)
- Configurable retries — built-in backoff strategy for transient failures
- Multi-runtime — Node.js 18+, Bun, Deno, and browsers (RUNTIMES.md)
Installation
npm install @cubewire/wallet-ts-sdkThis package is published as an ES Module (ESM) only. For CommonJS, use
await import().
Quick Start
1. Get API credentials (a client ID and client secret) from the Cubewire Dashboard → Settings → API Keys.
2. Exchange your credentials for a short-lived access token via the OAuth2 client-credentials flow, then pass it as bearerAuth:
import { SDK } from "@cubewire/wallet-ts-sdk";
const serverURL = "https://api.cubewire.com";
const { accessToken } = await new SDK({ serverURL }).oAuth2.requestOauth2AccessToken({
grantType: "client_credentials",
clientId: process.env.CUBEWIRE_CLIENT_ID!,
clientSecret: process.env.CUBEWIRE_CLIENT_SECRET!,
});
const sdk = new SDK({ serverURL, bearerAuth: accessToken });Access tokens are short-lived.
bearerAuthalso accepts a() => Promise<string>callback, so you can fetch and refresh the token on demand.
3. Make API calls:
const vaults = await sdk.vaults.getVaults();
const tx = await sdk.transactions.createTransactionSend({
sender: { vaultId: "e06476b1-e31b-433f-a225-d43ded705399" },
chainId: 1,
recipient: { address: "0x..." },
asset: { type: "native" },
amount: "1.5",
});Available Resources
| Resource | Description |
|---|---|
| sdk.vaults | Create, list, update, and manage vaults |
| sdk.transactions | Send, broadcast, simulate, and query transactions |
| sdk.contracts | Read contract state, deploy, and manage smart contract interactions |
| sdk.signing | Sign data and EIP-712 typed data |
| sdk.policies | Create and manage transaction policies |
| sdk.assets | Discover and manage vault assets and balances |
| sdk.networks | Configure blockchain networks and tokens |
| sdk.organizations | Manage organization settings, HSM, and compliance |
| sdk.roles | Manage roles and permissions |
| sdk.webhooks | Create and manage webhooks |
| sdk.auditLogs | Query audit logs and compliance reports |
| sdk.namedLists | Manage named lists for policy conditions |
| sdk.oAuth2 | Request OAuth2 access tokens |
For the full list of operations, see FUNCTIONS.md or the API reference on GitHub.
Error Handling
All HTTP errors extend SDKError:
import { SDK } from "@cubewire/wallet-ts-sdk";
import * as errors from "@cubewire/wallet-ts-sdk/models/errors";
try {
const result = await sdk.vaults.getVaultsById({ id: "..." });
} catch (error) {
if (error instanceof errors.SDKError) {
console.log(error.statusCode); // e.g. 404
console.log(error.message);
console.log(error.body);
}
}Retries
Override the default retry strategy per-call or globally:
const result = await sdk.vaults.getVaults({}, {
retries: {
strategy: "backoff",
backoff: {
initialInterval: 1,
maxInterval: 50,
exponent: 1.1,
maxElapsedTime: 100,
},
retryConnectionErrors: false,
},
});Documentation
Full guides and API reference at docs.cubewire.com:
- Introduction
- Authentication & OAuth2
- Managing Vaults
- Transactions
- Smart Contracts
- Policies & Approvals
- Networks
Contributing
This SDK is generated by Speakeasy. Manual changes to generated files will be overwritten on the next generation. Report issues or feature requests upstream.
License
MIT © Cubewire
