# Integrate the Password Manager SDK

## Prerequisites

1. [Complete the Getting Started Guide](/guides/getting-started.md)
2. [Integrate the User SDK](/guides/users/integrate-the-user-sdk.md)
3. [Integrate the Sudo Profiles SDK](/guides/sudos/integrate-the-sudo-sdk.md)
4. [Integrate the Entitlements SDK](/guides/entitlements/end-user-api/integrate-the-entitlements-sdk.md)

## Get Started

* [Integrate the JS SDK](#integrate-the-js-sdk)
* [Integrate the iOS SDK](#integrate-the-ios-sdk)
* [Integrate the Android SDK](#integrate-the-android-sdk)

## Integrate the JS SDK

{% hint style="success" %}
To gain access to the JS SDK and sample app providing a reference for integrating the SDK, please [contact us](https://sudoplatform.com/#lets-chat).
{% endhint %}

To use the **Password Manager SDK** in a Web or Node.js project, you must add `@sudoplatform/sudo-password-manager` as a dependency to your project.

```bash
yarn add '@sudoplatform/sudo-password-manager'
# or
npm install --save '@sudoplatform/sudo-password-manager'
```

{% hint style="info" %}
In order to instantiate a Password Manager client, make sure you have followed instructions for [Getting Started](/guides/getting-started.md), [User SDK](/guides/users/integrate-the-user-sdk.md), [Sudo Profiles SDK](/guides/sudos/integrate-the-sudo-sdk.md) and [Entitlements SDK](/guides/entitlements/end-user-api/integrate-the-entitlements-sdk.md) (see [Prerequisites](#prerequisites) above).

In addition, the **Password Manager SDK** depends on the Sudo Secure Vault SDK. You can provide these dependencies when instantiating the `PasswordManagerClient`.
{% endhint %}

To instantiate and initialize a client in your application, add the following:

{% tabs %}
{% tab title="TypeScript" %}

```typescript
import {
    PasswordManagerClient,
    BrowserKeyDerivingKeyStore
} from '@sudoplatform/sudo-password-manager'
import { DefaultConfigurationManager } from '@sudoplatform/sudo-common'
import { DefaultSudoUserClient } from '@sudoplatform/sudo-user'
import { DefaultSudoProfilesClient } from '@sudoplatform/sudo-profiles'
import { DefaultSudoEntitlementsClient } from '@sudoplatform/sudo-entitlements'
import { DefaultSudoSecureVaultClient } from '@sudoplatform/sudo-secure-vault'

const sdkConfigJSON = /* ... refer to Users documentation ... */
DefaultConfigurationManager.getInstance().setConfig(sdkConfigJSON)

const secretCodeStore = new BrowserKeyDerivingKeyStore()
const userClient = new DefaultSudoUserClient(/* refer to Users documentation */)
const profilesClient = new DefaultSudoProfilesClient(/* refer to Sudos documentation */)
const entitlementsClient = new DefaultSudoEntitlementsClient(/* refer to Entitlements documentation */)
const secureVaultConfig = undefined // undefined to use the config from DefaultConfigurationManager

const client = new PasswordManagerClient(
    secretCodeStore,
    userClient,
    profilesClient,
    entitlementsClient,
    secureVaultConfig,
    { logBackgroundReconciliationError: console.warn }
)
```

{% endtab %}
{% endtabs %}

## Integrate the iOS SDK

{% hint style="success" %}
To gain access to the iOS SDK and iOS sample app providing a reference for integrating the SDK, please [contact us](https://sudoplatform.com/#lets-chat).
{% endhint %}

Add this line to your [Podfile](/guides/getting-started.md#ios-only-setup-cocoapods-in-a-project):

```swift
pod 'SudoPasswordManager'
```

Install pod dependencies by running the following command in your project directory:

```swift
pod install --repo-update
```

This will update the local CocoaPods repository and install the latest version of the **Password Manager SDK**.

{% hint style="info" %}
In order to instantiate a Password Manager client, make sure you have followed instructions for [Getting Started](/guides/getting-started.md), [User SDK](/guides/users/integrate-the-user-sdk.md), [Sudo Profiles SDK](/guides/sudos/integrate-the-sudo-sdk.md) and [Entitlements SDK](/guides/entitlements/end-user-api/integrate-the-entitlements-sdk.md) (see [Prerequisites](#prerequisites) above).
{% endhint %}

To instantiate a client in your application, add the following:

{% tabs %}
{% tab title="Swift" %}

```swift
import SudoEntitlements
import SudoPasswordManager
import SudoProfiles
import SudoUser

let userClient = // ... see "Users" docs
let profilesClient = // ... see "Sudos" docs
let entitlementsClient = // ... see "Entitlements" docs

let passwordManagerClient = try DefaultPasswordManagerClient(
    userClient: userClient, 
    profilesClient: profilesClient, 
    entitlementsClient: entitlementsClient
)
```

{% endtab %}
{% endtabs %}

{% hint style="warning" %}
You only need one client instance for a given user per device. Instantiating multiple clients with the same configuration and using them at the same time may cause unexpected runtime errors to occur.
{% endhint %}

{% hint style="success" %}
**See it in action.** Be sure to take a look at the [open-source iOS sample app](https://github.com/sudoplatform/samples-ios/tree/master/password-manager) on GitHub that our team published as a reference for integrating the **Password Manager SDK** into your app as quickly and seamlessly as possible.
{% endhint %}

## Integrate the Android SDK

{% hint style="success" %}
To gain access to the Android SDK and Android sample app providing a reference for integrating the SDK, please [contact us](https://sudoplatform.com/#lets-chat).
{% endhint %}

The Android SDK is open source and compatible with Android 6 (API level 23) and above.

{% tabs %}
{% tab title="Gradle" %}
Add this line to the dependencies section of the app module `build.gradle` and synchronize your project with Android Studio.

```kotlin
dependencies {
    implementation 'com.sudoplatform:sudopasswordmanager:$latest_version'
}
```

{% hint style="info" %}
The latest version of the SDK can be found at [SDK Releases](/guides/email/sdk-releases.md).
{% endhint %}

{% hint style="info" %}
In order to instantiate a Password Manager client, make sure you have followed instructions for [Getting Started](/guides/getting-started.md), [User SDK](/guides/users/integrate-the-user-sdk.md), [Sudo Profiles SDK](/guides/sudos/integrate-the-sudo-sdk.md) and [Entitlements SDK](/guides/entitlements/end-user-api/integrate-the-entitlements-sdk.md) (see [Prerequisites](#prerequisites) above).
{% endhint %}
{% endtab %}
{% endtabs %}

To instantiate a client in your application, add the following:

{% tabs %}
{% tab title="Kotlin" %}

```kotlin
val logger = // ... use your implemenation of logger
val userClient = // ... see "Users" docs
val profilesClient = // ... see "Sudos" docs

val sudoPasswordManager = SudoPasswordManagerClient.builder()
            .setContext(appContext)
            .setSudoUserClient(userClient)
            .setSudoProfilesClient(profilesClient)
            .setLogger(logger)
            .build()
```

{% endtab %}
{% endtabs %}

{% hint style="warning" %}
You only need one client instance for a given user per device. Instantiating multiple clients with the same configuration and using them at the same time may cause unexpected runtime errors to occur.
{% endhint %}

{% hint style="success" %}
**See it in action.** Be sure to take a look at the [open source Android sample app](https://github.com/sudoplatform/samples-android/tree/master/password-manager) on GitHub that our team published as a reference for integrating the **Password Manager SDK** into your app as quickly and seamlessly as possible.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sudoplatform.com/guides/password-manager/integrate-the-password-manager-sdk.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
