Guides

API Reference

NonCustodialSDK API Reference

Static Methods

createInstance(config: NonCustodialSDKConfig): Promise<NonCustodialSDK>

Creates and initializes the SDK instance.

const sdk = await NonCustodialSDK.createInstance(config);

Instance Methods

startSession(payload: StartSessionPayload): Promise<void>

Starts the SDK session using the verification code and authenticatorId.

await sdk.startSession({
  code: 'email-code',
  authenticatorId: 'auth-id'
});

getPublicKey(): string

Returns the iframe public key to use in the challenge.

const publicKey = sdk.getPublicKey();

signPayoutPayload(payload: any): Promise<string>

Signs a payout transaction.

const signature = await sdk.signPayoutPayload(body);

isSessionActive(): boolean

Checks if a session is currently active.

if (sdk.isSessionActive()) {
  // Safe to proceed
}

clearSession(): void

Clears the session state.

sdk.clearSession();

getClientSessionExpiry(): Date | null

Returns the session's expiration time.

const expiry = sdk.getClientSessionExpiry();

Full Usage Flow

// 1. Create SDK instance
const sdk = await NonCustodialSDK.createInstance({
  iframeContainerId: 'auth-iframe-container-id',
  iframeElement: document.getElementById('auth-iframe-container-id')
});

// 2. Get public key
const publicKey = sdk.getPublicKey();

// 3. Backend: trigger challenge with publicKey + user ID

// 4. User inputs email code → start session
await sdk.startSession({
  code: codeFromUser,
  authenticatorId: authIdFromBackend
});

// 5. Backend: fetch /body-to-sign/:id
const signature = await sdk.signPayoutPayload(body);

// 6. Backend: send signature to /execute/:id

Type Definitions

interface NonCustodialSDKConfig {
  iframeContainerId: string;
  iframeElement: HTMLElement;
}

interface StartSessionPayload {
  code: string;
  authenticatorId: string;
}

interface TransactionBodyData {
  [key: string]: any;
}

Error Handling

The SDK throws clear errors for:

  • Missing config or parameters
  • Invalid or expired sessions
  • Incorrect or altered payloads
  • Network or signing failures

Wrap all SDK interactions in try/catch:

try {
  const sdk = await NonCustodialSDK.createInstance(...);
} catch (err) {
  console.error('SDK error:', err);
}

**Key Changes Made:**
1. ✅ `MuralBrowserSDK` → `NonCustodialSDK`
2. ✅ `MuralBrowserSDKConfig` → `NonCustodialSDKConfig`
3. ✅ `turnkey-auth-iframe-container-id` → `auth-iframe-container-id`
4. ✅ All method signatures match your actual implementation

This documentation now correctly reflects your actual SDK implementation!