> ## Documentation Index
> Fetch the complete documentation index at: https://bkey.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Configuration

> Configure PIN length and the requirePin gate via BmoniEmbeddedSdk.initialize.

`BmoniEmbeddedSdk.initialize` takes a single options object, and every field is optional. You can call it as many times as needed — each call replaces the active configuration.

```ts theme={null}
BmoniEmbeddedSdk.initialize({
  pinLength: 6, // default
  requirePin: true, // default
});
```

***

## Options

| Option       | Type      | Default | Description                                                                                                                                                     |
| ------------ | --------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `pinLength`  | `number`  | `6`     | Number of characters required for a valid PIN. Enforced by `setPin` and `changePin`. Must be a positive integer.                                                |
| `requirePin` | `boolean` | `true`  | When `true`, `signMessage`, `signTransactionHash`, and `deleteWallet` verify the supplied PIN against the stored digest before forwarding to the native module. |

A `pinLength` that is not a positive integer throws a `RangeError` immediately.

***

## Reading the active config

The current configuration is always accessible:

```ts theme={null}
import { BmoniEmbeddedSdk, type BmoniEmbeddedSdkConfig } from '@bkey-inc/bmoni_embedded_sdk';

const config: BmoniEmbeddedSdkConfig = BmoniEmbeddedSdk.config;

// Convenience getters:
const length = BmoniEmbeddedSdk.pinLength; // 6
const gated = BmoniEmbeddedSdk.requirePin; // true
```

Use these in your UI to render a PIN input of the right length or hide PIN flows entirely:

```tsx theme={null}
<TextInput
  maxLength={BmoniEmbeddedSdk.pinLength}
  keyboardType="number-pad"
  secureTextEntry
/>
```

***

## `requirePin: false` — delegating auth elsewhere

When you manage authentication outside the SDK (biometrics, OS lockscreen, server-side challenge), set `requirePin: false`:

```ts theme={null}
BmoniEmbeddedSdk.initialize({ requirePin: false });

await BmoniEmbeddedSdk.initWallet();
const sig = await BmoniEmbeddedSdk.signMessage('hi'); // no pin argument needed
```

<Warning>
  When `requirePin` is `false`, **any supplied `pin` argument is silently ignored** by `signMessage`, `signTransactionHash`, and `deleteWallet`. PIN management methods (`setPin`, `changePin`, etc.) still work — toggling `requirePin` only changes whether the stored PIN is used as a gate.
</Warning>

***

## Changing the PIN length at runtime

You can change `pinLength` after a PIN is already set. The stored digest was created with the old length, so you need to prompt the user to remove and re-create their PIN before verification can succeed again.

```ts theme={null}
// Before:
BmoniEmbeddedSdk.initialize({ pinLength: 6 });
await BmoniEmbeddedSdk.setPin('123456');

// After changing length:
BmoniEmbeddedSdk.initialize({ pinLength: 4 });
// The old 6-digit PIN no longer satisfies the length constraint.
// Prompt the user to removePin + setPin with a 4-digit value.
```
