Docs

EmailAddress

The EmailAddress object is a model around an email address. Email addresses are used to provide identification for users.

Email addresses must be verified to ensure that they can be assigned to their rightful owners. The EmailAddress object holds all necessary state around the verification process.

The verification process always starts with the EmailAddress.prepareVerification() method, which will send a one-time verification code via an email message. The second and final step involves an attempt to complete the verification by calling the EmailAddress.attemptVerification() method, passing the one-time code as a parameter.

Finally, email addresses can be linked to other identifications.

Properties

  • Name
    id
    Type
    string
    Description

    A unique identifier for this email address.

  • Name
    emailAddress
    Type
    string
    Description

    The value of this email address.

  • Name
    verification
    Type
    Verification
    Description

    An object holding information on the verification of this email address.

  • Name
    linkedTo
    Type
    Array<{id: string, type: string}>
    Description

    An array of objects containing information about any identifications that might be linked to this email address.

Methods

create()

Creates a new email address for the current user.

function create(): Promise<EmailAddress>;

destroy()

Deletes this email address.

function destroy(): Promise<void>;

toString()

Returns the value for this email address. Can also be accessed via the EmailAddress.emailAddress attribute.

function toString(): string;

Sets up an email verification with email link flow. Calling createEmailLinkFlow() will return two functions.

The first function is async and starts the email link flow, preparing a email link verification. It sends the email link email and starts polling for verification results. The signature is startEmailLinkFlow({ redirectUrl: string }) => Promise<EmailAddress>.

The second function can be used to stop polling at any time, allowing for full control of the flow and cleanup. The signature is cancelEmailLinkFlow() => void.

function createEmailLinkFlow(): {
  startEmailLinkFlow: (params: StartEmailLinkFlowParams) => Promise<EmailAddress>;
  cancelEmailLinkFlow: () => void;
};

createEmailLinkFlow returns an object with two functions:

  • Name
    startEmailLinkFlow
    Type
    (params: StartEmailLinkFlowParams) => Promise<EmailAddress>
    Description

    Function to start the email link flow. It prepares a email link verification and polls for the verification result.

  • Name
    cancelEmailLinkFlow
    Type
    () => void
    Description

    Function to cleanup the email link flow. Stops waiting for verification results.

  • Name
    redirectUrl
    Type
    string
    Description

    The email link target URL. Users will be redirected here once they click the email link from their email.

Additional methods

In addition to the methods listed above, the EmailAddress class also has the following methods:

Validation

Feedback

What did you think of this content?