LedeWire SDK API Reference
    Preparing search index...

    Interface NodeClientConfig

    Configuration options for the LedeWire Node.js client.

    interface NodeClientConfig {
        apiKey?: string;
        apiSecret?: string;
        baseUrl?: string;
        onAuthExpired?: () => void | Promise<void>;
        onTokenRefreshed?: (tokens: StoredTokens) => void | Promise<void>;
        storage?: TokenStorage;
    }
    Index

    Properties

    apiKey?: string

    LedeWire API key. Required for all seller and buyer operations. Omit when using merchant email/password auth exclusively.

    apiSecret?: string

    LedeWire API secret. When combined with apiKey, grants full (read/write) seller permission. When omitted, apiKey alone grants view (read-only) seller permission.

    baseUrl?: string

    Override the API base URL. Defaults to https://api.ledewire.com.

    baseUrl: 'https://api-staging.ledewire.com'
    
    onAuthExpired?: () => void | Promise<void>

    Called when the session fully expires and cannot be refreshed. Handle this by prompting the user to re-authenticate.

    onTokenRefreshed?: (tokens: StoredTokens) => void | Promise<void>

    Called after a successful background token refresh, in addition to storage.setTokens.

    Scope: fires only on background token refresh — not on initial login or signup. storage.setTokens fires on both. If you need to persist tokens on every auth event, the storage adapter is the correct hook.

    Use onTokenRefreshed only for side-effects that should run specifically when the SDK auto-refreshes a token in the background, e.g. audit logging, cache invalidation, or notifying a secondary system. If you are using a storage adapter, storage.setTokens is already the correct persistence hook — providing both will result in double-writes on every refresh.

    onTokenRefreshed: async (tokens) => {
    await auditLog.record('token_refreshed', { expires_at: tokens.expiresAt })
    }
    storage?: TokenStorage

    Custom token storage implementation. Defaults to MemoryTokenStorage (in-memory).

    Serverless / edge warning: MemoryTokenStorage resets on every cold start. Tokens are lost between function invocations, causing a login loop. Always provide a persistent adapter (Redis, database, encrypted httpOnly cookie) when deploying to serverless or edge runtimes.

    setTokens is called both on initial login and after every background token refresh — it is the canonical hook for persisting updated credentials.

    storage: {
    getTokens: async () => JSON.parse(await redis.get('tokens')),
    setTokens: async (t) => redis.set('tokens', JSON.stringify(t)),
    clearTokens: async () => redis.del('tokens'),
    }