OptionalapiLedeWire API key. Required for all seller and buyer operations. Omit when using merchant email/password auth exclusively.
OptionalapiLedeWire API secret.
When combined with apiKey, grants full (read/write) seller permission.
When omitted, apiKey alone grants view (read-only) seller permission.
OptionalbaseOverride the API base URL.
Defaults to https://api.ledewire.com.
OptionalonCalled when the session fully expires and cannot be refreshed. Handle this by prompting the user to re-authenticate.
OptionalonCalled 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.
OptionalstorageCustom 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'),
}
Configuration options for the LedeWire Node.js client.