# Functions

## initializeSDK

▸ **initializeSDK**(): `Future<void>`

Initializes the Authentication SDK using credentials from `Info.plist` (iOS) or native configuration (Android).

### Example

```dart
import 'package:flutter_ts_authentication/flutter_ts_authentication.dart';

final auth = FlutterTsAuthentication();
await auth.initializeSDK();
```

## initialize

▸ **initialize**(`clientId`, `domain`, `baseUrl`, `initOptions`): `Future<void>`

Initializes the SDK with explicit parameters and WebAuthn configuration.

### Parameters

| Name | Type | Description |
|  --- | --- | --- |
| `clientId` | `String` | Your Mosaic client ID |
| `domain` | `String` | Your application domain |
| `baseUrl` | `String` | API endpoint URL |
| `initOptions` | `TSInitOptions` | Configuration options containing WebAuthn settings |


### Example

```dart
final initOptions = TSInitOptions(
  webAuthnInitOptions: TSWebAuthnInitOptions(
    startAuthentication: '/auth/webauthn/authenticate',
    startRegistration: '/auth/webauthn/register',
  ),
);

await auth.initialize(
  'CLIENT_ID',
  'your-domain.com',
  'https://api.transmitsecurity.io',
  initOptions
);
```

## registerPinCode

▸ **registerPinCode**(`username`, `pinCode`): `Future<TSPinCodeRegistrationCompletion>`

Registers a PIN code for the specified user. After successful registration, commit it using `commitPinRegistration`.

### Parameters

| Name | Type | Description |
|  --- | --- | --- |
| `username` | `String` | The user identifier |
| `pinCode` | `String` | The PIN code to register |


### Returns

`TSPinCodeRegistrationCompletion`—contains `publicKeyId`, `publicKey`, `keyType`, and `contextIdentifier`.

### Example

```dart
final result = await auth.registerPinCode('username', '123456');
await auth.commitPinRegistration(result.contextIdentifier);
```

## commitPinRegistration

▸ **commitPinRegistration**(`contextIdentifier`): `Future<void>`

Commits a pending PIN code registration.

### Parameters

| Name | Type | Description |
|  --- | --- | --- |
| `contextIdentifier` | `String` | The context identifier returned from `registerPinCode` |


## authenticatePinCode

▸ **authenticatePinCode**(`username`, `pinCode`, `challenge`): `Future<TSPinCodeAuthenticationCompletion>`

Authenticates a user with their registered PIN code.

### Parameters

| Name | Type | Description |
|  --- | --- | --- |
| `username` | `String` | The user identifier |
| `pinCode` | `String` | The PIN code to authenticate with |
| `challenge` | `String` | A server-generated challenge string |


### Returns

`TSPinCodeAuthenticationCompletion`—contains `publicKeyId`, `signature`, and `challenge`.

### Example

```dart
final result = await auth.authenticatePinCode('username', '123456', 'challenge-string');
```

## registerNativeBiometrics

▸ **registerNativeBiometrics**(`username`): `Future<TSBiometricsRegistrationResult>`

Registers native biometrics (FaceID/TouchID or fingerprint) for the specified user.

### Parameters

| Name | Type | Description |
|  --- | --- | --- |
| `username` | `String` | The user identifier |


### Returns

`TSBiometricsRegistrationResult`—contains `publicKey`, `publicKeyId`, `os`, `keyType`, and optional `attestation`.

### Example

```dart
final result = await auth.registerNativeBiometrics('username');
```

## authenticateNativeBiometrics

▸ **authenticateNativeBiometrics**(`username`, `challenge`): `Future<TSBiometricsAuthenticationResult>`

Authenticates a user using their registered biometrics.

### Parameters

| Name | Type | Description |
|  --- | --- | --- |
| `username` | `String` | The user identifier |
| `challenge` | `String` | A server-generated challenge string |


### Returns

`TSBiometricsAuthenticationResult`—contains `publicKeyId` and `signature`.

### Example

```dart
final result = await auth.authenticateNativeBiometrics('username', 'challenge-string');
```

## unregisterNativeBiometrics

▸ **unregisterNativeBiometrics**(`userId`): `Future<TSNativeBiometricsUnregisterResult>`

Unregisters native biometrics for the specified user.

### Parameters

| Name | Type | Description |
|  --- | --- | --- |
| `userId` | `String` | The user identifier |


### Returns

`TSNativeBiometricsUnregisterResult`—contains `publicKeyId` of the unregistered biometric.

### Example

```dart
final result = await auth.unregisterNativeBiometrics('userId');
```

## approvalNativeBiometrics

▸ **approvalNativeBiometrics**(`username`, `challenge`): `Future<TSBiometricsAuthenticationResult>`

Performs biometric approval for transaction signing or sensitive operations.

### Parameters

| Name | Type | Description |
|  --- | --- | --- |
| `username` | `String` | The user identifier |
| `challenge` | `String` | A server-generated challenge string |


### Returns

`TSBiometricsAuthenticationResult`—contains `publicKeyId` and `signature`.

### Example

```dart
final result = await auth.approvalNativeBiometrics('username', 'challenge-string');
```

## isWebAuthnSupported

▸ **isWebAuthnSupported**(): `Future<bool>`

Checks if WebAuthn is supported on the current device.

### Returns

`bool`—`true` if WebAuthn is supported.

### Example

```dart
final isSupported = await auth.isWebAuthnSupported();
```

## registerWebAuthn

▸ **registerWebAuthn**(`username`, `displayName`): `Future<TSWebAuthnResult>`

Registers a WebAuthn passkey for the specified user.

### Parameters

| Name | Type | Description |
|  --- | --- | --- |
| `username` | `String` | The user identifier |
| `displayName` | `String` | Display name shown during passkey registration |


### Returns

`TSWebAuthnResult`—contains `result`.

### Example

```dart
final result = await auth.registerWebAuthn('username', 'Display Name');
```

## authenticateWebAuthn

▸ **authenticateWebAuthn**(`username`): `Future<TSWebAuthnResult>`

Authenticates a user using their registered WebAuthn passkey.

### Parameters

| Name | Type | Description |
|  --- | --- | --- |
| `username` | `String` | The user identifier |


### Returns

`TSWebAuthnResult`—contains `result`.

### Example

```dart
final result = await auth.authenticateWebAuthn('username');
```

## signWebauthnTransaction

▸ **signWebauthnTransaction**(`username`): `Future<TSWebAuthnResult>`

Signs a transaction using the user's WebAuthn credential.

### Parameters

| Name | Type | Description |
|  --- | --- | --- |
| `username` | `String` | The user identifier |


### Returns

`TSWebAuthnResult`—contains `result`.

### Example

```dart
final result = await auth.signWebauthnTransaction('username');
```

## approvalWebAuthn

▸ **approvalWebAuthn**(`approvalData`, `username`, `options`): `Future<TSWebAuthnResult>`

Performs WebAuthn approval with custom approval data.

### Parameters

| Name | Type | Description |
|  --- | --- | --- |
| `approvalData` | `Map<String, String>` | Key-value pairs describing the operation to approve |
| `username` | `String` | The user identifier |
| `options` | `List<String>` | Additional options for the approval |


### Returns

`TSWebAuthnResult`—contains `result`.

### Example

```dart
final approvalData = {'transaction': 'transfer', 'amount': '100'};
final options = <String>['option1', 'option2'];

final result = await auth.approvalWebAuthn(approvalData, 'username', options);
```

## approvalWebAuthnWithData

▸ **approvalWebAuthnWithData**(`authData`, `options`): `Future<TSWebAuthnResult>`

Performs WebAuthn approval using raw authentication data.

### Parameters

| Name | Type | Description |
|  --- | --- | --- |
| `authData` | `TSWebAuthnAuthenticationData` | Pre-obtained WebAuthn authentication data |
| `options` | `List<String>` | Additional options for the approval |


### Returns

`TSWebAuthnResult`—contains `result`.

### Example

```dart
final authData = TSWebAuthnAuthenticationData(data: {
  'webauthnSessionId': 'session-id',
  'credentialRequestOptions': {}
});

final result = await auth.approvalWebAuthnWithData(authData, options);
```

## registerTOTP

▸ **registerTOTP**(`uri`, `securityType`): `Future<TSTOTPRegistrationCompletion>`

Registers a TOTP authenticator from a `otpauth://` URI.

### Parameters

| Name | Type | Description |
|  --- | --- | --- |
| `uri` | `String` | The TOTP provisioning URI (e.g., `otpauth://totp/...`) |
| `securityType` | `TSTOTPSecurityType` | `.biometric` requires biometric authentication to generate codes; `.none` has no additional security |


### Returns

`TSTOTPRegistrationCompletion`—contains `issuer`, `label`, and `uuid`.

### Example

```dart
final result = await auth.registerTOTP(
  'otpauth://totp/Example:user@example.com?secret=JBSWY3DPEHPK3PXP&issuer=Example',
  TSTOTPSecurityType.biometric
);
```

## generateTOTPCode

▸ **generateTOTPCode**(`uuid`): `Future<TSTOTPGenerateCodeCompletion>`

Generates a TOTP code for standard time-based authentication.

### Parameters

| Name | Type | Description |
|  --- | --- | --- |
| `uuid` | `String` | The TOTP identifier returned from `registerTOTP` |


### Returns

`TSTOTPGenerateCodeCompletion`—contains the generated `code`.

### Example

```dart
final result = await auth.generateTOTPCode('your-totp-uuid');
```

## generateTOTPCodeWithChallenge

▸ **generateTOTPCodeWithChallenge**(`uuid`, `challenge`): `Future<TSTOTPGenerateCodeCompletion>`

Generates a TOTP code bound to a challenge for transaction signing or enhanced security scenarios.

### Parameters

| Name | Type | Description |
|  --- | --- | --- |
| `uuid` | `String` | The TOTP identifier returned from `registerTOTP` |
| `challenge` | `String` | A server-generated challenge string |


### Returns

`TSTOTPGenerateCodeCompletion`—contains the generated `code`.

### Example

```dart
final result = await auth.generateTOTPCodeWithChallenge('your-totp-uuid', 'challenge-string');
```

## signWithDeviceKey

▸ **signWithDeviceKey**(`challenge`): `Future<TSSignChallengeResult>`

Signs a challenge using the device key for secure authentication and transaction validation.

### Parameters

| Name | Type | Description |
|  --- | --- | --- |
| `challenge` | `String` | The challenge to sign |


### Returns

`TSSignChallengeResult`—contains the `signature`.

### Example

```dart
final result = await auth.signWithDeviceKey('challenge-to-sign');
```

## getDeviceInfo

▸ **getDeviceInfo**(): `Future<DeviceInfo>`

Retrieves the device's public key information.

### Returns

`DeviceInfo`—contains `publicKeyId` and `publicKey`.

### Example

```dart
final deviceInfo = await auth.getDeviceInfo();
```

## setLoggingEnabled

▸ **setLoggingEnabled**(`enabled`): `Future<bool>`

Enables or disables SDK logging for debugging.

### Parameters

| Name | Type | Description |
|  --- | --- | --- |
| `enabled` | `bool` | `true` to enable logging, `false` to disable |


### Returns

`bool`—`true` if the configuration was applied successfully.

### Example

```dart
await auth.setLoggingEnabled(true);
```

style
table th:first-of-type {
    width: 30%;
}
table th:nth-of-type(2) {
    width: 30%;
}
table th:nth-of-type(3) {
    width: 40%;
}