Skip to main content

Overview

The Login Strategy Service manages different authentication methods and login flows. It provides a unified interface for authenticating users through various strategies including password, SSO, WebAuthn, API keys, and auth requests.

LoginStrategyServiceAbstraction

Core service for managing authentication strategies and login flows.

Properties

currentAuthType$

Observable that emits the current authentication strategy being used. Emits null if the session has timed out.

authenticationSessionTimeout$

Observable that emits true when the authentication session has expired.

Methods

getEmail()

Returns the email address if the login strategy uses it, otherwise returns null. Returns: Promise<string | null> - Email address or null

getMasterPasswordHash()

Returns the master password hash if the user is logging in with a master password, otherwise returns null. Returns: Promise<string | null> - Master password hash or null

getSsoEmail2FaSessionToken()

Returns the SSO email 2FA session token if the user is logging in with SSO, otherwise returns null. Returns: Promise<string | null> - SSO email 2FA session token or null See also: SsoLoginStrategyData.ssoEmail2FaSessionToken

getAccessCode()

Returns the access code if the user is logging in with an Auth Request, otherwise returns null. Returns: Promise<string | null> - Access code or null

getAuthRequestId()

Returns the auth request ID if the user is logging in with an Auth Request, otherwise returns null. Returns: Promise<string | null> - Auth request ID or null

logIn()

Sends a token request to the server using the provided credentials. Parameters:
  • credentials - Login credentials for the chosen authentication method
Returns: Promise<AuthResult> - Authentication result

logInTwoFactor()

Sends a token request to the server with the provided two-factor token. This uses data stored from logIn(), so that must be called first. Parameters:
  • twoFactor - Two-factor authentication request
Returns: Promise<AuthResult> - Authentication result Throws: Error if no session data is found

makePasswordPreLoginMasterKey()

Creates a master key from the provided master password and email. Parameters:
  • masterPassword - User’s master password
  • email - User’s email address
Returns: Promise<MasterKey> - Generated master key

getPasswordPrelogin()

Prefetches and caches the KDF configuration for the given email. No-op if already in-flight or cached. Parameters:
  • email - User’s email address
Returns: Promise<void>

logInNewDeviceVerification()

Sends a token request to the server with the provided device verification OTP. Parameters:
  • deviceVerificationOtp - Device verification one-time password
Returns: Promise<AuthResult> - Authentication result

Login Credential Types

PasswordLoginCredentials

Credentials for password-based authentication. Properties:
  • email - User’s email address
  • masterPassword - User’s master password
  • twoFactor - Optional two-factor authentication token
  • masterPasswordPoliciesFromOrgInvite - Optional master password policies from organization invite

SsoLoginCredentials

Credentials for SSO-based authentication. Properties:
  • code - OAuth authorization code
  • codeVerifier - PKCE code verifier
  • redirectUrl - OAuth redirect URL
  • orgId - Organization ID
  • email - Optional email address (used for 2FA token lookup)
  • twoFactor - Optional two-factor authentication token

UserApiLoginCredentials

Credentials for API key-based authentication. Properties:
  • clientId - API key client ID
  • clientSecret - API key client secret

AuthRequestLoginCredentials

Credentials for passwordless authentication via auth request. Properties:
  • email - User’s email address
  • accessCode - Access code from auth request
  • authRequestId - Auth request ID
  • decryptedUserKey - Decrypted user key (if available)
  • twoFactor - Optional two-factor authentication token

WebAuthnLoginCredentials

Credentials for WebAuthn (passkey) authentication. Properties:
  • token - Authentication token
  • deviceResponse - WebAuthn assertion response from the browser
  • prfKey - Optional PRF key for key derivation

Login Strategy Base Class

LoginStrategy

Abstract base class for all login strategies. Implements common login flow logic.

Methods

logIn()
Executes the login flow for the specific strategy.
logInTwoFactor()
Handles two-factor authentication for the login flow. Parameters:
  • twoFactor - Two-factor authentication request
Returns: Promise<AuthResult> - Authentication result with master password if available Throws: Error if token request is undefined

Example Usage

Password Login

SSO Login

API Key Login


AuthResult

Result object returned from login operations.

AuthenticationType

Enum defining available authentication types.