Skip to main content

Types and interfaces

capacitor-auth-manager is TypeScript-first: every configuration object, result, and user shape is a named, exported type. This page documents the types you interact with most. They are all re-exported from the package root.

import type {
AuthUser,
AuthResult,
AuthCredential,
AuthState,
AuthManagerConfig,
SignInOptions,
SignOutOptions,
ProviderOptions,
AuthPersistence,
} from 'capacitor-auth-manager';

AuthProvider, AuthErrorCode, AuthPersistence, BiometricType, and AppleAuthScope are enums (runtime values), so import them without type when you need their members.

AuthManagerConfig

Passed to configure() and initialize().

FieldTypeNotes
providersRecord<string, ProviderOptions>Map of provider id → its options.
persistence'local' | 'session' | 'memory'Where the web session is stored. Default local.
autoRefreshTokenbooleanSchedule token refresh before expiry.
tokenRefreshBuffernumberMilliseconds before expiry to refresh. Default 300000 (5 min).
enableLoggingbooleanToggle the internal logger.
logLevel'debug' | 'info' | 'warn' | 'error'Logger verbosity.
storageStorageInterfaceCustom storage backend. See Storage.

AuthState

The shape emitted by onAuthStateChange and returned by getAuthState(). It does not carry raw tokens.

FieldType
userAuthUser | null
isLoadingboolean
isAuthenticatedboolean
providerstring | null

AuthStateListener is (state: AuthState) => void.

AuthUser

The authenticated user. uid is the only required field.

FieldTypeNotes
uidstringStable user id.
emailstring | nullOptional.
emailVerifiedbooleanOptional.
displayNamestring | nullOptional.
photoURLstring | nullOptional.
phoneNumberstring | nullOptional.
isAnonymousbooleanOptional.
tenantIdstring | nullOptional.
providerDataUserInfo[]Per-provider identities.
metadataUserMetadataCreation / sign-in timestamps.
refreshTokenstringOptional.
customClaimsRecord<string, string | number | boolean | null>Optional.

UserInfo carries { providerId, uid, displayName?, email?, phoneNumber?, photoURL? }. UserMetadata carries { creationTime?, lastSignInTime?, lastRefreshTime? } (all ISO strings).

AuthResult

Returned by signIn, refreshToken, and linkAccount.

FieldTypeNotes
userAuthUserThe resulting user.
credentialAuthCredentialTokens for this sign-in.
additionalUserInfoAdditionalUserInfoOptional. { isNewUser, providerId, profile?, username? }.
operationType'signIn' | 'link' | 'reauthenticate'Optional.

AuthCredential

FieldType
providerIdstring
signInMethodstring
accessTokenstring (optional)
idTokenstring (optional)
refreshTokenstring (optional)
expiresAtnumber (optional, epoch ms)
tokenTypestring (optional)
scopestring (optional)
rawNoncestring (optional)

SignInOptions

The object form accepted by auth.signIn.

FieldTypeNotes
providerAuthProviderThe provider to use (enum or its string value).
credentialsAuthCredentialsOptional. Union of email/password, phone, username, code, OAuth, and custom credential shapes.
optionsSignInProviderOptionsOptional. scopes, customParameters, loginHint, prompt, state, nonce, pkceEnabled, and more.

SignOutOptions carries { provider?, revokeToken?, clearCache?, redirectUrl? }.

ProviderOptions

A union of every provider's option interface — GoogleAuthOptions, AppleAuthOptions, MicrosoftAuthOptions, FacebookAuthOptions, GitHubAuthOptions, SlackAuthOptions, LinkedInAuthOptions, FirebaseAuthOptions, EmailMagicLinkOptions, SmsAuthOptions, EmailPasswordOptions, PhonePasswordOptions, UsernamePasswordOptions, EmailCodeOptions, and BiometricAuthOptions. Each provider page documents its own fields.

AuthProvider

String enum of provider ids: GOOGLE, APPLE, MICROSOFT, FACEBOOK, GITHUB, SLACK, LINKEDIN, FIREBASE, EMAIL_MAGIC_LINK, MAGIC_LINK, SMS, EMAIL_PASSWORD, PHONE_PASSWORD, USERNAME_PASSWORD, EMAIL_CODE, BIOMETRIC. You can pass the enum member or its string value (for example AuthProvider.GOOGLE or 'google').

In 2.4.x only AuthProvider.GOOGLE is enabled. The other members exist in the enum, but signing in with them throws AuthErrorCode.PROVIDER_NOT_ENABLED until each provider is re-enabled. See the provider overview.

AuthPersistence

enum AuthPersistence { LOCAL = 'local', SESSION = 'session', NONE = 'none' }

The config accepts the literals 'local' | 'session' | 'memory'; 'memory' maps internally to AuthPersistence.NONE (in-memory, non-persisted).