Search
K
Links
Comment on page

User Reference

Passage.js methods for managing a user from your frontend application.
The User class represents an authenticated Passage user. This class has methods that can be used to retrieve data on the current user which require authentication.
All methods are a part of the User class which should be used as follows:
import { Passage } from '@passageidentity/passage-js';
const passage = new Passage('YOUR_APP_ID');
const user = passage.getCurrentUser();
const userInfo = await user.userInfo();
.getCurrentUser()
This function prepares all necessary aspects of making authenticated for current user information and exposes methods that simplify the most common use cases.
Returns
Parameters
User
Returns the User object that represents an authenticated user.
N/A

Current User Methods

.userInfo()
Returns the user information for the currently authenticated user.
Returns
Parameters
Promise<PassageUserInfo | undefined>
Returns the Passage user object. If the user's token could not be validated, returns undefined.
interface PassageUserInfo {
created_at: string;
update_at: string;
status: string;
id: string;
email: string;
email_verified: boolean;
phone: string;
phone_verified: boolean;
webauthn: boolean;
webauthn_devices: PassageDevice[];
last_login_at: string;
login_count: number;
user_metadata: Metadata | null;
webauthn_types: WebAuthnType[];
}
None
.changeEmail(newEmail: string)
Initiates an email change for the currently authenticated user. An email will be sent to the provided email, which they will need to verify before the change takes effect.
Parameters
Returns
newEmail: string
Promise<PassageMagicLinkRequest>
Returns a Promise that resolves to a magic link request. An email will be sent to the new email which will need to be verified by clicking the magic link in the email.
interface PassageMagicLinkRequest {
id: string;
}
.changePhone(newPhone: string)
Initiates a phone number change for the currently authenticated user. A text will be sent to the provided phone number, which they will need to verify before the change takes effect.
Parameters
Returns
newPhone: string - valid E164 formatted phone number.
Promise<PassageMagicLinkRequest>
Returns a Promise that resolves to a magic link request. A text will be sent to the new phone number which will need to be verified by clicking the magic link in the text.
interface PassageMagicLinkRequest {
id: string;
}
.listDevices()
List devices for the current authenticated user. Device information includes the friendly name, ID, when the device was added, and when it was last used.
Returns
Parameters
Promise<PassageDevice[]>
Returns a promise that resolves to a list of devices for the current user. A device represents a device or credential that can be used for a WebAuthn exchange.
interface PassageDevice {
id: string;
cred_id: string;
friendly_name: string;
usage_count: number;
updated_at: string;
created_at: string;
}
None
.editDevice(deviceID: string, editDeviceRequest: PassageEditDeviceRequest)
Edits the information about the device provided. Currently only the name can be edited.
Parameters
Returns
deviceID - ID for the device to be edited. Can be found via userInfo or listDevices methods.
editDeviceRequest - new fields to edited. Currently, only the name can be changed.
Promise<PassageDevice>
Returns a Promise that resolves to the new device information. A device represents a device or credential that can be used for a WebAuthn exchange.
interface PassageDevice {
id: string;
cred_id: string;
friendly_name: string;
usage_count: number;
updated_at: string;
created_at: string;
}
.addDevice()
Adds the current device for the current authenticated user. If WebAuthn is supported by the current device and browser, the platform will request authorization from the authenticator (e.g. FaceID).
Returns
Parameters
Promise<PassageDevice>
Returns a Promise that resolves to the new device that was just added. A device represents a device or credential that can be used for a WebAuthn exchange.
interface PassageDevice {
id: string;
cred_id: string;
friendly_name: string;
usage_count: number;
updated_at: string;
created_at: string;
user_id: string;
}
Promise<PassageDevice>
Returns a Promise that resolves to the new device information. A device represents a device or credential that can be used for a WebAuthn exchange.
interface PassageDevice {
id: string;
cred_id: string;
friendly_name: string;
usage_count: number;
updated_at: string;
created_at: string;
}
.deleteDevice(deviceID: string)
Revokes a device for the current authenticated user. The device will no longer be able to log into the Passage account and will need to be re-added.
Parameters
Returns
deviceID - ID for the device to be edited. Can be found via userInfo or listDevices methods.
Promise<boolean>
Returns true if the device was successfully deleted.