Accessing the Password Manager
Setting up and managing access to the Password Manager
Setting Up the Password Manager Client
The first step in accessing the Password Manager is to check the registration status by calling the getRegistrationStatus method.
import { RegistrationStatus } from '@sudoplatform/sudo-password-manager'
const status = await client.getRegistrationStatus()
switch (status) {
case RegistrationStatus.Unregistered:
// call client.register()
break
case RegistrationStatus.SecretCodeRequired:
// provide the secret code
// using client.unlock(password, secretCode)
break
case RegistrationStatus.Registered:
// the vault may be unlocked
// using client.unlock(password)
break
}var client: PasswordManagerClient!
client.getRegistrationStatus { (result) in
switch result {
case .success(let status):
switch status {
case .registered:
break
case .notRegistered:
break
case .missingSecretCode:
break
}
case .failure(let error):
break
}
}If the client is successful in fetching the registration status, a PasswordManagerRegistrationStatus will be returned. Inspect this value to determine what to do next to finish the setup of the Password Manager.
If the registration status is
registered, the next step is unlocking the Password Manager before accessing items.If the registration status is
notRegistered, register the user by calling theregistermethod and passing in the user's master password.If the registration status is
missingSecretCode, the user has already registered on another device. The Password Manager requires the user's master password and secret code. The user can find their secret code on their rescue kit PDF which was downloaded during onboarding.
Registering to Use the Password Manager
To register as a new user of the Password Manager, call the register method and pass in the user's master password. If successful, the client will be registered and the Password Manager will be unlocked and ready to create new vaults.
Unlocking the Password Manager
To access the Password Manager, it must first be unlocked by calling the unlock method and passing in the user's master password. This method also accepts the user's secret code, which is only required if the registration status returned by getRegistrationStatus is missingSecretCode.
An error will be returned by unlock if the secret code is not provided to unlock and not present on the user's device.
Once the Password Manager is unlocked, you can access create/access vaults and their contents.
Locking the Password Manager
You can use the isLocked method to synchronously determine if the Password Manager is locked. If isLocked returns false, then the next call to a method that accesses the Password Manager will not fail due to it being locked.
You can use the lock method to lock the Password Manager. Use this method in response to user action or after a period of user inactivity.
Accessing the Secret Code
Both the master password and secret code must be present to unlock the Password Manager. The secret code is automatically generated during registration and stored on the user's device. To unlock an existing Password Manager for the first time on a new device, you must pass the secret code and master password into the unlock method. If the secret code is already stored on the user's device, you do not need to provide it in subsequent calls to the unlock method.
You can retrieve the secret code stored on the user's device using the showSecretCode method. You should take steps to ensure that the user does not lose their secret code. If they do, they will be unable to unlock their Password Manager vaults.
Generating the Rescue Kit PDF
The Rescue Kit provides a way for users to save and print their secret code with the option to handwrite their master password and email address. This is part of the data recovery in case the user forgets or loses their keys. They should also store this in a safe location.
To generate the Rescue Kit PDF from the SDK you can provide your own PDF template or by default, it will use the Sudo Platform template.

Changing the Master Password
To change the master password the Password Manager must be unlocked first. After the Password Manager is unlocked, use the changeMasterPassword method.
Deregistering from the Password Manager
To deregister a user from the Password Manager and delete all created vaults and vault items, use the deregister method.
To reset all local state saved by the Password Manager, such as secret codes that are stored on the user's device, use the reset method. Note that if the user has not backed up their secret code, they will be unable to subsequently log into the Password Manager and their vaults will be inaccessible.
Last updated