import { AuthenticationHelper } from "./AuthenticationHelper" ; import { Credentials } from "./Credentials" ; /**
 * This class represents a user on the Realm Object Server. The credentials are provided
 * by various 3rd party providers (Facebook, Google, etc.). A user can log in to the Realm
 * Object Server, and if access is granted, it is possible to query the remote Realm.
 * Moreover, synchronization is halted when the user is logged out. It is possible to
 * persist a user. By retrieving a user, there is no need to log in to the 3rd party
 * provider again. Persisting a user between sessions, the user's credentials are stored
 * locally on the device, and should be treated as sensitive data.
 */ export class User { param credentials param server returns public static async authenticate ( credentials , server ) { return AuthenticationHelper . authenticate ( credentials , server ) ; } readonly public identity : string ; readonly public isAdmin : boolean ; readonly public server : string ; readonly public token : string ; param init public constructor ( init ) { if ( typeof init . identity === "string" ) { this . identity = init . identity ; } if ( typeof init . isAdmin === "boolean" ) { this . isAdmin = init . isAdmin ; } if ( typeof init . server === "string" ) { this . server = init . server ; } if ( typeof init . token === "string" ) { this . token = init . token ; } } /**
     * Logs out the user from the Realm Object Server. Once the Object Server has
     * confirmed the logout the user credentials will be invalidated and the user
     * will need to login again.
     */ public async logOut ( ) { try { await AuthenticationHelper . revoke ( this ) ; } catch { } this . token = null ; } }