Class App<FunctionsFactoryType, CustomDataType>

Atlas App Services Application

Type Parameters

  • FunctionsFactoryType = Realm.DefaultFunctionsFactory & Realm.BaseFunctionsFactory

  • CustomDataType = SimpleObject

Hierarchy

  • App

Implements

  • App<FunctionsFactoryType, CustomDataType>

Constructors

  • Construct a Realm App, either from the Realm App id visible from the Atlas App Services UI or a configuration.

    Type Parameters

    • FunctionsFactoryType = DefaultFunctionsFactory & BaseFunctionsFactory

    • CustomDataType = SimpleObject

    Parameters

    • idOrConfiguration: string | AppConfiguration

      The Realm App id or a configuration to use for this app.

    Returns App<FunctionsFactoryType, CustomDataType>

Properties

_locationUrl: null | Promise<string> = null

A promise resolving to the App's location url.

authenticator: Authenticator

Internal authenticator used to complete authentication requests.

baseUrl: string

The base URL of the app.

emailPasswordAuth: EmailPasswordAuth

Inherit Doc

fetcher: Fetcher

An object which can be used to fetch responses from the server.

id: string

Inherit Doc

localApp: undefined | LocalAppConfiguration

Local app configuration. Useful to determine what name and version an authenticated user is running.

storage: AppStorage

Storage available for the app.

users: User<FunctionsFactoryType, CustomDataType, DefaultUserProfileData>[] = []

An array of active and logged-out users. Elements in the beginning of the array is considered more recent than the later elements.

Credentials: typeof Credentials = Credentials

Instances of this class can be passed to the app.logIn method to authenticate an end-user.

appCache: {
    [id: string]: App;
} = {}

A map of app instances returned from calling getApp.

Type declaration

  • [id: string]: App

Accessors

  • get allUsers(): Readonly<Record<string, User<FunctionsFactoryType, CustomDataType, DefaultUserProfileData>>>
  • All active and logged-out users:

    • First in the list are active users (ordered by most recent call to switchUser or login)
    • Followed by logged out users (also ordered by most recent call to switchUser or login).

    Returns Readonly<Record<string, User<FunctionsFactoryType, CustomDataType, DefaultUserProfileData>>>

    An array of users active or logged out users (current user being the first).

  • get currentUser(): null | User<FunctionsFactoryType, CustomDataType, DefaultUserProfileData>
  • The currently active user (or null if no active users exists).

    Returns null | User<FunctionsFactoryType, CustomDataType, DefaultUserProfileData>

    the currently active user or null.

  • get deviceInformation(): DeviceInformation
  • Returns DeviceInformation

    Information about the current device, sent to the server when authenticating.

Methods

  • Create (and store) a new user or update an existing user's access and refresh tokens. This helps de-duplicating users in the list of users known to the app.

    Parameters

    • response: AuthResponse

      A response from the Authenticator.

    • providerType: ProviderType

      The type of the authentication provider used.

    Returns User<FunctionsFactoryType, CustomDataType, DefaultUserProfileData>

    A new or an existing user.

  • Inherit Doc

    Parameters

    • user: User<FunctionsFactoryType, CustomDataType, DefaultUserProfileData>

    Returns Promise<void>

  • Log in a user.

    Parameters

    • credentials: Credentials<SimpleObject>

      Credentials to use when logging in.

    • fetchProfile: boolean = true

      Should the users profile be fetched? (default: true)

    Returns Promise<User<FunctionsFactoryType, CustomDataType, DefaultUserProfileData>>

    A promise resolving to the newly logged in user.

  • Inherit Doc

    Parameters

    • user: User<FunctionsFactoryType, CustomDataType, DefaultUserProfileData>

    Returns Promise<void>

  • Switch user.

    Parameters

    • nextUser: User<FunctionsFactoryType, CustomDataType, DefaultUserProfileData>

      The user or id of the user to switch to.

    Returns void

  • Get or create a singleton Realm App from an id. Calling this function multiple times with the same id will return the same instance.

    Parameters

    • id: string

      The Realm App id visible from the Atlas App Services UI or a configuration.

    Returns App<DefaultFunctionsFactory & BaseFunctionsFactory, SimpleObject>

    The Realm App instance.

Generated using TypeDoc