Note

Do not use the @tanker/fake-authentication package in production. Instead, please consult the guide on user management.

Installation and usage

See Core documentation for instructions on how to install and use the @tanker/fake-authentication package.

Constructor

const config = { appId: 'your-app-id' };
const fakeAuth = new FakeAuthentication(config);
Parameters Description
config: Object The configuration of this FakeAuthentication instance, containing:
config.appId: string The app ID

Note

This documentation uses flow type annotations.

PrivateIdentity

An object that contains the private identity of a user.

Fields Description
identity: string The private identity of a user. Needed to start a Tanker session
provisionalIdentity: string The provisional identity of the user (if there is one) (optional)

getIdentity

Returns the private identity associated with the provided email. It is guaranteed that this function will always return the same private identity given an email. If getPublicIdentities() is called before getIdentity() for a given email, the private identity also contains a provisional identity. If no email is provided it generates a disposable identity.

function getIdentity(email?: string) : Promise<PrivateIdentity>
Parameters Description
email?: string The email address corresponding to the identity to retrieve (optional)
Returns
Promise<PrivateIdentity> The identity corresponding to the given email

getPublicIdentities

Returns an array of public identities from an array of emails.

function getPublicIdentities(email: Array<string>) : Promise<Array<string>>
Parameters Description
emails: Array The emails addresses corresponding to the public identities to retrieve
Returns
Promise> The public identities corresponding to the given emails

setIdentityRegistered

Notifies the fake authentication server than an identity has been registered.

function setIdentityRegistered(email: string) : Promise<void>
Parameters Description
email: string email corresponding to the identity to notify as registered
Returns
Promise The promise is fulfilled once the fake authentication server responded