# IdoSdk

**`Interface`**

**`Description`**

The interface for the sdk object.

## Methods

### init

▸ **init**(`clientId`, `options?`): `Promise`<`void`>

**`Description`**

Creates a new Identity Orchestration SDK instance with your client context.
Do not call this function directly - see below how to initialize via the unified web SDK

**`Throws`**

[InvalidInitOptions](/sdk-ref/idosdk/enums/errorcode#invalidinitoptions) in case of invalid init options.

**`Example`**


```ts
// Initialize an instance of the Identity Orchestration SDK using the unified SDK
import { initialize } from '@transmitsecurity/platform-web-sdk';
initialize({
  clientId: 'my-client-id',
  ido: { serverPath: 'https://api.transmitsecurity.io/ido'}
});
```

#### Parameters

| Name | Type | Description |
|  --- | --- | --- |
| `clientId` | `string` | Client ID for this application. |
| `options?` | [`IdoInitOptions`](/sdk-ref/idosdk/interfaces/idoinitoptions) | Additional environment configuration for the SDK operation. |


#### Returns

`Promise`<`void`>

The promise that will be resolved when the SDK is initialized.

### startJourney

▸ **startJourney**(`journeyId`, `options?`): `Promise`<[`IdoServiceResponse`](/sdk-ref/idosdk/interfaces/idoserviceresponse)>

**`Description`**

Starts a Journey with a given id.

**`Throws`**

[NotInitialized](/sdk-ref/idosdk/enums/errorcode#notinitialized) - Throws error if the SDK is not initialized.

**`Throws`**

[NetworkError](/sdk-ref/idosdk/enums/errorcode#networkerror) - Throws error if could not connect to server, or server did not respond before timeout.

**`Throws`**

[ServerError](/sdk-ref/idosdk/enums/errorcode#servererror) - Throws error if the server returned an unexpected error.

**`Example`**


```ts
// Start a Journey with the id 'my-journey-id'
try {
  const idoResponse = await ido.startJourney('my-journey-id', { additionalParams: 'additionalParams' });
  // Handle Journey response
} catch(error) {
  switch(sdkError.errorCode) ...
}
```

#### Parameters

| Name | Type | Description |
|  --- | --- | --- |
| `journeyId` | `string` | Journey Identifier in the Mosaic Admin Console. |
| `options?` | [`StartJourneyOptions`](/sdk-ref/idosdk/interfaces/startjourneyoptions) | Additional parameters to be passed to the journey. |


#### Returns

`Promise`<[`IdoServiceResponse`](/sdk-ref/idosdk/interfaces/idoserviceresponse)>

The promise that will be resolved when the [IdoServiceResponse](/sdk-ref/idosdk/interfaces/idoserviceresponse) is received.

### startSsoJourney

▸ **startSsoJourney**(`interactionId`, `options?`): `Promise`<[`IdoServiceResponse`](/sdk-ref/idosdk/interfaces/idoserviceresponse)>

**`Description`**

Starts an SSO Journey with a given Interaction ID.

**`Throws`**

[NotInitialized](/sdk-ref/idosdk/enums/errorcode#notinitialized) - Throws error if the SDK is not initialized.

**`Throws`**

[NetworkError](/sdk-ref/idosdk/enums/errorcode#networkerror) - Throws error if could not connect to server, or server did not respond before timeout.

**`Throws`**

[ServerError](/sdk-ref/idosdk/enums/errorcode#servererror) - Throws error if the server returned an unexpected error.

**`Example`**


```ts
// Start a Journey with the Interaction ID '2456E855-05A0-4992-85C1-A2519CBB4AA7'
try {
  const idoResponse = await ido.startSsoJourney('2456E855-05A0-4992-85C1-A2519CBB4AA7');
  // Handle Journey response
} catch(error) {
  switch(sdkError.errorCode) ...
}
```

#### Parameters

| Name | Type | Description |
|  --- | --- | --- |
| `interactionId` | `string` | Interaction identifier given as part of the response to the initial /authorize request |
| `options?` | [`StartSsoJourneyOptions`](/sdk-ref/idosdk/interfaces/startssojourneyoptions) | - |


#### Returns

`Promise`<[`IdoServiceResponse`](/sdk-ref/idosdk/interfaces/idoserviceresponse)>

The promise that will be resolved when the [IdoServiceResponse](/sdk-ref/idosdk/interfaces/idoserviceresponse) is received.

### submitClientResponse

▸ **submitClientResponse**(`clientResponseOptionId`, `data?`): `Promise`<[`IdoServiceResponse`](/sdk-ref/idosdk/interfaces/idoserviceresponse)>

**`Description`**

This method will submit client input to the Journey step to process.

**`Throws`**

[NotInitialized](/sdk-ref/idosdk/enums/errorcode#notinitialized) - Throws error if the SDK is not initialized.

**`Throws`**

[NoActiveJourney](/sdk-ref/idosdk/enums/errorcode#noactivejourney) - Throws error if the SDK state does not have an active Journey.

**`Throws`**

[NetworkError](/sdk-ref/idosdk/enums/errorcode#networkerror) - Throws error if could not connect to server, or server did not respond before timeout.

**`Throws`**

[ClientResponseNotValid](/sdk-ref/idosdk/enums/errorcode#clientresponsenotvalid) - Throws error if the client response to the Journey is not valid.

**`Throws`**

[ServerError](/sdk-ref/idosdk/enums/errorcode#servererror) - Throws error if the server returned an unexpected error.

**`Example`**


```ts
// The previous response may include multiple response options. The standard 'ClientInput' response option
// signals we are sending collected user input to the journey step.
const selectedInputOptionId = ClientResponseOptionType.ClientInput;

// Submit the client input. The data inside the JSON correspond to the expected fields from the Journey step.
try {
  const idoResponse = await ido.submitClientResponse(selectedInputOption, {
    'userEmail': 'user@input.email',
    'userPhone': '111-222-3333',
  });
} catch(sdkError) {
  switch(sdkError.errorCode) ...
}
```

#### Parameters

| Name | Type | Description |
|  --- | --- | --- |
| `clientResponseOptionId` | `string` | The response option ID is one of the IDs provided in the [clientResponseOptions](/sdk-ref/idosdk/interfaces/idoserviceresponse#clientresponseoptions). This would either be [ClientInput](/sdk-ref/idosdk/enums/clientresponseoptiontype#clientinput) for collected user input, or one of the others if another journey path was selected by the user. |
| `data?` | `any` | The client response data object. Mandatory in [ClientInput](/sdk-ref/idosdk/enums/clientresponseoptiontype#clientinput) response option type, populate with data for the Journey step to process. Optional in [Cancel](/sdk-ref/idosdk/enums/clientresponseoptiontype#cancel) and [Custom](/sdk-ref/idosdk/enums/clientresponseoptiontype#custom) as an additional parameters for the branch. |


#### Returns

`Promise`<[`IdoServiceResponse`](/sdk-ref/idosdk/interfaces/idoserviceresponse)>

The promise that will be resolved when the [IdoServiceResponse](/sdk-ref/idosdk/interfaces/idoserviceresponse) is received.

### serializeState

▸ **serializeState**(): `string`

**`Description`**

Get the current serialized state of the SDK. Can be stored by the application code and used to
restore the SDK state following page redirects or refresh

#### Returns

`string`

The current state of the SDK.

### restoreFromSerializedState

▸ **restoreFromSerializedState**(`state`): [`IdoServiceResponse`](/sdk-ref/idosdk/interfaces/idoserviceresponse)

**`Description`**

Restores the SDK state from a serialized state, can be used to recover from page redirects or refresh.
The application code also receives the latest communication from the Mosaic server.

**`Throws`**

[InvalidState](/sdk-ref/idosdk/enums/errorcode#invalidstate) - Throws error if the provided state string is invalid.

#### Parameters

| Name | Type | Description |
|  --- | --- | --- |
| `state` | `string` | The state to restore from. |


#### Returns

[`IdoServiceResponse`](/sdk-ref/idosdk/interfaces/idoserviceresponse)

The last [IdoServiceResponse](/sdk-ref/idosdk/interfaces/idoserviceresponse) that was received before the state was saved.

### generateDebugPin

▸ **generateDebugPin**(): `Promise`<`string`>

**`Description`**

This method will generate a debug PIN
const debugPin = await ido.generateDebugPin();
console.log(`Debug PIN: ${debugPin}`); // Output: Debug PIN: 1234

#### Returns

`Promise`<`string`>