Skip to content

Latest commit

 

History

History
128 lines (94 loc) · 5.45 KB

authentication.js.md

File metadata and controls

128 lines (94 loc) · 5.45 KB

auth

Authentication workflow for Google Firebase.

See: FirebaseUI for Web

initializeFirebase() ⏏

Must be called before any operations on Firebase API calls.

Kind: Exported function

firestore() ⇒ Firestore

Firestore is a Google NoSQL datastore. This function returns a reference that can be used with the Firestore API.

Kind: Exported function
Returns: Firestore - An interface to Firestore
See: Firestore

userPath() ⇒ string

Return the unique path prefix for a user.

Kind: Exported function
Returns: string - A path string

gcpApi(requestOptions) ⇒ Promise

Executes an API call to Google Cloud, taking care of user authentication and token refresh.

Kind: Exported function
Returns: Promise - Promise object represents the payload response of the API call (string|object|buffer)
See: Request Options

Param Type Description
requestOptions A set of option parameters for the API request
requestOptions.url string | object HTTP(S) endpoint to call, string or object in the format of url.parse()
requestOptions.method string HTTP verb, e.g. GET, POST, etc.
requestOptions.headers object An object with any additional request headers

signInNewUser(newUser) ⇒ Promise

Completes the authentication workflow for a new user. The user credential will be saved in as a web browser identity persistence so it can be recovered on a subsequent session without forcing the user to log in again.

Kind: Exported function
Returns: Promise - A Promise object representing the user object

Param Type Description
newUser object This is an object passed from the Web UI for authentication after a successful registration of a new user

startNewSignIn(mainWindow) ⇒ Promise

Initiates the Firebase UI authentication workflow. nodeIntegration must be set to false because it would expose the login page to hacking through the IPC interface.

Kind: Exported function
Returns: Promise - A Promise object representing the new modal window for authentication workflow

Param Type Description
mainWindow BrowserWindow The parent (or main) window, so that the workflow window can be modal

getProvider() ⇒ string

Gets the identity provider that was used to authenticate the current user.

Kind: Exported function
Returns: string - The firebase representation of the identity provider, can be any of:
"google.com", "github.com", "twitter.com", "facebook.com", "password", "phone"

getSignOutUrl(provider) ⇒ string

Firebase UI doesn't have a workflow for logging out from the identity provider, so this function returns a URL that can be used to log out directly -- if the identity provider doesn't change the URL.

Kind: Exported function
Returns: string - A URL that can be called to log out of the identity provider

Param Type Description
provider string The name of the identity provider, from getProvider()

signOutUser() ⏏

Logs out the user from Firebase, but not from the identity provider.

Kind: Exported function

signOutProvider(provider, mainWindow) ⇒ BrowserWindow

Performs a complete signout from Firebase and the identity provider.

Kind: Exported function
Returns: BrowserWindow - A new window that was used for the identity provider logout

Param Type Description
provider string The identity provider, from getProvider()
mainWindow BrowserWindow A parent window, so the logout window can be modal