Skip to main content
Version: 4.2

Installation

Follow these steps to install Identity Vault into your app.

Installation

If you have not already setup Ionic Enterprise in your app, follow the one-time setup steps.

Next, install the plugin:

npm install @ionic-enterprise/identity-vault
npx cap sync

Update the native project config files:


_10
// iOS - Info.plist
_10
<key>NSFaceIDUsageDescription</key>
_10
<string>Use Face ID to authenticate yourself and login</string>
_10
_10
// Android - No additional changes needed

Configuring the Vault

The IonicIdentityVaultUser class takes a generic session type which represents the type of the session you'll store in the vault. You can use the DefaultSession or extend the class to create a custom session. In the constructor of your Identity service, the vault is configured by providing options to the super() call:


_35
interface MyCustomSession extends DefaultSession {
_35
// username & token are inherited
_35
email: string;
_35
age: number;
_35
nicknames: string[];
_35
}
_35
_35
export class IdentityService extends IonicIdentityVaultUser<MyCustomSession> {
_35
_35
constructor(private http: HttpClient, private router: Router, platform: Platform) {
_35
super(platform, {
_35
authMode: AuthMode.BiometricAndPasscode, // Use biometrics auth with passcode fallback
_35
restoreSessionOnReady: false, // whether or not to immediately attempt to restore the session when the vault is ready
_35
unlockOnReady: false, // set true to auto prompt the user to unlock when vault is ready
_35
unlockOnAccess: true, // set to true to auto prompt the user to unlock on first read access
_35
lockAfter: 5000, // lock after 5 seconds in the background
_35
hideScreenOnBackground: true // when in app launcher mode hide the current screen and display the splashscreen
_35
});
_35
_35
onVaultUnlocked(config: VaultConfig) {
_35
//Route to my home page
_35
}
_35
_35
onVaultLocked() {
_35
//Route to my login page
_35
}
_35
_35
async onPasscodeRequest(isPasscodeSetRequest: boolean) {
_35
// Display a custom Passcode prompt and return the passcode as a string
_35
// or return undefined to use the build in native prompts. isPasscodeSetRequest
_35
// is true when attempting to set a new passcode on the vault, you can use
_35
// it to do something like prompt the user twice for the pin.
_35
}
_35
_35
}