# Functions

## initializeSDK

▸ **initializeSDK**({`configurationFile`}): `Future<void>`

Initializes the SDK using a configuration file (iOS plist or Android auto-detected configuration).

### Parameters

| Name | Type | Description |
|  --- | --- | --- |
| `configurationFile` | `String?` | Name of the configuration file (without extension on iOS) |


### Example

```dart
final orchestration = FlutterTsIdentityOrchestration();
await orchestration.initializeSDK(configurationFile: 'TransmitSecurity');
```

## initialize

▸ **initialize**({`clientId`, `options`}): `Future<void>`

Initializes the SDK with explicit parameters.

### Parameters

| Name | Type | Description |
|  --- | --- | --- |
| `clientId` | `String` | Your Mosaic client ID |
| `options` | `Map<String, dynamic>` | Configuration options (see below) |


**Options:**

| Key | Type | Description |
|  --- | --- | --- |
| `serverPath` | `String` | Server URL (default: `https://api.transmitsecurity.io`) |
| `resource` | `String?` | Custom resource path |
| `pollingTimeout` | `int?` | Polling timeout in milliseconds |
| `locale` | `String?` | Locale setting (default: `'en'`) |


### Example

```dart
await orchestration.initialize(
  clientId: 'CLIENT_ID',
  options: {
    'serverPath': 'https://api.transmitsecurity.io',
    'pollingTimeout': 30000,
    'locale': 'en',
  },
);
```

## journeyResponseStream

▸ **journeyResponseStream**: `Stream<Map<String, dynamic>>`

Stream that delivers real-time journey events. This is the only way the SDK communicates journey responses to your app.

Important
You **must** listen to this stream **before** starting any journey. Without an active listener, your app will not receive journey responses—steps, authentication results, and errors will be lost.

### Response format

| Key | Type | Description |
|  --- | --- | --- |
| `success` | `bool` | Whether the response represents a successful step |
| `response` | `Map?` | Response data including `journeyStepId` |
| `error` | `String?` | Error message if `success` is `false` |
| `type` | `String?` | Response type (e.g., `'instructions'`) |
| `instructions` | `Map?` | Additional instructions data when `type` is `'instructions'` |


### Instructions callback

When calling `submitClientResponse` or `startMobileApproveJourney`, the native SDK may trigger additional instructions through the event stream. These are delivered as responses with `type` set to `'instructions'` and should be handled separately from regular journey step responses.

### Example

```dart
orchestration.journeyResponseStream.listen(
  (response) {
    if (response['type'] == 'instructions') {
      final instructions = response['instructions'];
      // Handle native SDK instructions
      return;
    }

    if (response['success'] == true) {
      final stepId = response['response']?['journeyStepId'];
      // Handle journey step
    } else {
      print('Error: ${response['error']}');
    }
  },
  onError: (error) {
    print('Stream error: $error');
  },
);
```

## startJourney

▸ **startJourney**({`journeyId`, `options`}): `Future<void>`

Starts an orchestration journey. Responses are delivered via `journeyResponseStream`.

### Parameters

| Name | Type | Description |
|  --- | --- | --- |
| `journeyId` | `String` | The journey identifier configured in the Admin Portal |
| `options` | `Map<String, dynamic>?` | Journey options (see below) |


**Options:**

| Key | Type | Description |
|  --- | --- | --- |
| `additionalParams` | `Map<String, String>?` | Additional parameters to pass to the journey |
| `flowId` | `String?` | Custom flow identifier |
| `encryptionMode` | `bool?` | Enable encryption for the journey session |


### Example

```dart
await orchestration.startJourney(
  journeyId: 'registration-flow',
  options: {
    'additionalParams': {'userType': 'premium'},
    'encryptionMode': true,
  },
);
```

## submitClientResponse

▸ **submitClientResponse**({`responseId`, `data`}): `Future<bool>`

Submits a client response during a journey flow. The next step is delivered via `journeyResponseStream`.

### Parameters

| Name | Type | Description |
|  --- | --- | --- |
| `responseId` | `String` | Identifier for the response type |
| `data` | `Map<String, dynamic>?` | Data to submit |


**Common response IDs:**

| ID | Description |
|  --- | --- |
| `'clientInput'` | Submit user input |
| `'cancel'` | Cancel current step |
| `'fail'` | Mark step as failed |
| `'resend'` | Request resend (e.g., OTP) |


### Returns

`bool`—`true` if the response was submitted successfully.

### Example

```dart
await orchestration.submitClientResponse(
  responseId: 'clientInput',
  data: {'email': 'user@example.com', 'password': 'secret'},
);
```

Platform differences
The response ID for login form submissions may differ between platforms. On Android, use `'password'`; on iOS, use `'Password'`.

```dart
import 'dart:io' show Platform;

final responseId = Platform.isAndroid ? 'password' : 'Password';
await orchestration.submitClientResponse(
  responseId: responseId,
  data: {'username': username, 'password': password},
);
```

## startMobileApproveJourney

▸ **startMobileApproveJourney**({`payload`, `startJourneyOptions`}): `Future<void>`

Starts a mobile approve journey. Responses are delivered via `journeyResponseStream`.

### Parameters

| Name | Type | Description |
|  --- | --- | --- |
| `payload` | `Map<String, dynamic>` | Mobile approve payload (e.g., session data) |
| `startJourneyOptions` | `Map<String, dynamic>` | Journey options (e.g., encryption settings) |


### Example

```dart
await orchestration.startMobileApproveJourney(
  payload: {'sessionId': 'session-123'},
  startJourneyOptions: {'encrypted': true},
);
```

## generateDebugPin

▸ **generateDebugPin**(): `Future<String>`

Generates a debug PIN for development and testing.

### Returns

`String`—the generated debug PIN.

### Example

```dart
final pin = await orchestration.generateDebugPin();
```

## setLoggingEnabled

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

Enables or disables SDK logging.

### 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 orchestration.setLoggingEnabled(true);
```

## setPushToken

▸ **setPushToken**(`token`): `Future<void>`

Sets the push notification token for the SDK to enable push-based flows.

### Parameters

| Name | Type | Description |
|  --- | --- | --- |
| `token` | `String` | The push notification token from Firebase or APNs |


### Example

```dart
final token = await FirebaseMessaging.instance.getToken();
if (token != null) {
  await orchestration.setPushToken(token);
}
```

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