The @yativo/crypto-sdk package is the official TypeScript SDK for the Yativo Crypto API. It ships with full TypeScript typings, automatic token refresh, rate-limit handling, and an embeddable card widget.
interface YativoSDKOptions { /** API key for key-based authentication */ apiKey?: string; /** API secret for key-based authentication */ apiSecret?: string; /** Override the base URL (default: https://crypto-api.yativo.com/api/v1/) */ baseURL?: string; /** Request timeout in milliseconds (default: 30000) */ timeout?: number; /** Enable the IBAN feature (must be true to use sdk.standaloneIban) */ standaloneIbanEnabled?: boolean;}
Login is passwordless. Call login(email) to send an OTP to the user, then call verifyOTP(otp, email) to complete authentication. The SDK stores the token internally and auto-refreshes on 401.
// Step 1 — Send OTPawait sdk.auth.login("user@example.com");// Step 2 — Verify OTP to complete authconst session = await sdk.auth.verifyOTP("123456", "user@example.com");// session.accessToken is stored internally; auto-refreshed on 401
// Get QR code and secret for Google Authenticator setupconst details = await sdk.auth.get2faDetails();// details.qrCode — display this as a QR image// details.secret — manual entry fallback// Activate 2FA on the accountawait sdk.auth.enable2fa();// Verify a TOTP code (use instead of verifyOTP when 2FA is enabled)const session = await sdk.auth.verify2FA("654321", "user@example.com");
// Get WebAuthn challengeconst options = await sdk.auth.passkeyAuthOptions("user@example.com");// Verify WebAuthn credential (pass the result from navigator.credentials.get)const session = await sdk.auth.passkeyAuthVerify(credential);
// Create a new accountconst account = await sdk.accounts.create({ name: "Main Treasury", currency: "USD",});// List all accountsconst { accounts, total } = await sdk.accounts.list({ page: 1, limit: 20 });// Get a single accountconst account = await sdk.accounts.get("acct_abc123");
You must set standaloneIbanEnabled: true in the constructor to use this resource. Attempting to call these methods without the feature flag will throw a FeatureNotEnabledError.
The card widget displays sensitive card details (PAN, CVV, expiry) inside a secure sandboxed iframe. Card data never touches your JavaScript.Card data is displayed via a Yativo-hosted secure page — your backend requests a URL, your frontend opens it. No SDK widget to mount, no sensitive token to handle client-side.Step 1 — Request a secure view URL on your server:
// Server-side only (Node.js / backend route)const view = await sdk.cards.getCardViewToken({ yativoCardId: "yc_abc123", cardId: "card_mno345", enabledViews: ["data", "pin"], theme: { accentColor: "#6366f1", logoUrl: "https://yourapp.com/logo.png", },});// Send view.secureViewUrl to your frontend
Step 2 — Open the URL for the cardholder:
// In your frontend — open in iframe, WebView, or new tabconst iframe = document.createElement("iframe");iframe.src = secureViewUrlFromServer;iframe.width = "420";iframe.height = "740";iframe.style.border = "0";document.getElementById("card-container").appendChild(iframe);
<!-- Or directly in HTML --><iframe src="SECURE_VIEW_URL_FROM_YOUR_BACKEND" width="420" height="740" style="border:0;border-radius:16px;" allow="clipboard-read; clipboard-write"></iframe>
Always request a fresh URL immediately before showing it. Never cache or reuse a previous secure_view_url. See Get Secure Card View URL.