Skip to content

@cyber-eco/firebase • Docs


@cyber-eco/firebase

Classes

FirebaseStorageAdapter

Implements

  • StorageAdapter

Constructors

new FirebaseStorageAdapter()

new FirebaseStorageAdapter(getFirestore): FirebaseStorageAdapter

Parameters

• getFirestore

Returns

FirebaseStorageAdapter

Defined in

adapter.ts:9

Methods

getDocument()

getDocument\<T>(collectionName, id): Promise\<null | T>

Type Parameters

• T

Parameters

• collectionName: string

• id: string

Returns

Promise\<null | T>

Implementation of

StorageAdapter.getDocument

Defined in

adapter.ts:18

setDocument()

setDocument\<T>(collectionName, id, data, options?): Promise\<WriteResult>

Type Parameters

• T

Parameters

• collectionName: string

• id: string

• data: T

• options?: WriteOptions

Returns

Promise\<WriteResult>

Implementation of

StorageAdapter.setDocument

Defined in

adapter.ts:25

updateDocument()

updateDocument(collectionName, id, data): Promise\<WriteResult>

Parameters

• collectionName: string

• id: string

• data: Record\<string, unknown>

Returns

Promise\<WriteResult>

Implementation of

StorageAdapter.updateDocument

Defined in

adapter.ts:36

deleteDocument()

deleteDocument(collectionName, id): Promise\<WriteResult>

Parameters

• collectionName: string

• id: string

Returns

Promise\<WriteResult>

Implementation of

StorageAdapter.deleteDocument

Defined in

adapter.ts:44

query()

query\<T>(collectionName, filters, options?): Promise\<PaginatedResult\<T>>

Type Parameters

• T

Parameters

• collectionName: string

• filters: QueryFilter[]

• options?: QueryOptions

Returns

Promise\<PaginatedResult\<T>>

Implementation of

StorageAdapter.query

Defined in

adapter.ts:51

batchWrite()

batchWrite(operations): Promise\<BatchResult>

Parameters

• operations: BatchOperation[]

Returns

Promise\<BatchResult>

Implementation of

StorageAdapter.batchWrite

Defined in

adapter.ts:74

subscribe()

subscribe\<T>(collectionName, id, callback): Unsubscribe

Type Parameters

• T

Parameters

• collectionName: string

• id: string

• callback

Returns

Unsubscribe

Implementation of

StorageAdapter.subscribe

Defined in

adapter.ts:79

subscribeToQuery()

subscribeToQuery\<T>(collectionName, filters, callback): Unsubscribe

Type Parameters

• T

Parameters

• collectionName: string

• filters: QueryFilter[]

• callback

Returns

Unsubscribe

Implementation of

StorageAdapter.subscribeToQuery

Defined in

adapter.ts:87

serverTimestamp()

serverTimestamp(): unknown

Returns

unknown

Implementation of

StorageAdapter.serverTimestamp

Defined in

adapter.ts:97

generateId()

generateId(collectionName): string

Parameters

• collectionName: string

Returns

string

Implementation of

StorageAdapter.generateId

Defined in

adapter.ts:101


FirebaseAuthAdapter

Implements

  • AuthAdapter

Constructors

new FirebaseAuthAdapter()

new FirebaseAuthAdapter(auth): FirebaseAuthAdapter

Parameters

• auth: Auth

Returns

FirebaseAuthAdapter

Defined in

auth/FirebaseAuthAdapter.ts:67

Methods

signIn()

signIn(email, password): Promise\<AuthUser>

Sign in with email + password. Resolves to the normalized user.

Parameters

• email: string

• password: string

Returns

Promise\<AuthUser>

Implementation of

AuthAdapter.signIn

Defined in

auth/FirebaseAuthAdapter.ts:69

signUp()

signUp(email, password, displayName): Promise\<AuthUser>

Create an account with email + password and set the display name.

Parameters

• email: string

• password: string

• displayName: string

Returns

Promise\<AuthUser>

Implementation of

AuthAdapter.signUp

Defined in

auth/FirebaseAuthAdapter.ts:74

signOut()

signOut(): Promise\<void>

Sign the current user out.

Returns

Promise\<void>

Implementation of

AuthAdapter.signOut

Defined in

auth/FirebaseAuthAdapter.ts:80

signInWithProvider()

signInWithProvider(provider): Promise\<AuthUser>

Sign in via a social provider (popup/redirect handled by the adapter).

Parameters

• provider: AuthProviderName

Returns

Promise\<AuthUser>

Implementation of

AuthAdapter.signInWithProvider

Defined in

auth/FirebaseAuthAdapter.ts:84

linkProvider()

linkProvider(provider): Promise\<void>

Link a social provider to the currently signed-in account.

Parameters

• provider: AuthProviderName

Returns

Promise\<void>

Implementation of

AuthAdapter.linkProvider

Defined in

auth/FirebaseAuthAdapter.ts:89

resetPassword()

resetPassword(email, options?): Promise\<void>

Send a password-reset email.

redirectTo is the absolute URL the emailed link lands on. Without it the backend falls back to its configured site root, which has no way to handle the recovery grant — the user just sees the homepage. Always point it at a page that completes the reset by calling updatePassword.

Parameters

• email: string

• options?

• options.redirectTo?: string

Returns

Promise\<void>

Implementation of

AuthAdapter.resetPassword

Defined in

auth/FirebaseAuthAdapter.ts:95

updatePassword()

updatePassword(newPassword): Promise\<void>

Set a new password for the currently authenticated user. After following a recovery link the user holds a short-lived recovery session, which is what authorizes this call.

Parameters

• newPassword: string

Returns

Promise\<void>

Implementation of

AuthAdapter.updatePassword

Defined in

auth/FirebaseAuthAdapter.ts:105

updateDisplayProfile()

updateDisplayProfile(update): Promise\<void>

Update the signed-in user's display name and/or photo.

Parameters

• update

• update.displayName?: string

• update.photoURL?: string

Returns

Promise\<void>

Implementation of

AuthAdapter.updateDisplayProfile

Defined in

auth/FirebaseAuthAdapter.ts:111

getCurrentUser()

getCurrentUser(): null | AuthUser

Current user synchronously if known, else null.

Returns

null | AuthUser

Implementation of

AuthAdapter.getCurrentUser

Defined in

auth/FirebaseAuthAdapter.ts:117

getIdToken()

getIdToken(): Promise\<null | string>

A fresh ID/access token for the signed-in user, or null.

Returns

Promise\<null | string>

Implementation of

AuthAdapter.getIdToken

Defined in

auth/FirebaseAuthAdapter.ts:121

onAuthStateChanged()

onAuthStateChanged(callback): () => void

Subscribe to auth-state changes. Returns an unsubscribe function.

Parameters

• callback

Returns

Function

Returns

void

Implementation of

AuthAdapter.onAuthStateChanged

Defined in

auth/FirebaseAuthAdapter.ts:126

setPersistence()

setPersistence(persistence): Promise\<void>

Configure where the session is persisted (optional; adapters may no-op).

Parameters

• persistence: AuthPersistence

Returns

Promise\<void>

Implementation of

AuthAdapter.setPersistence

Defined in

auth/FirebaseAuthAdapter.ts:130


FirebaseProfileStore\<T>

Type Parameters

• T = Record\<string, unknown>

Implements

  • ProfileStore\<T>

Constructors

new FirebaseProfileStore()

new FirebaseProfileStore\<T>(db, collection): FirebaseProfileStore\<T>

Parameters

• db: Firestore

• collection: string = 'users'

Returns

FirebaseProfileStore\<T>

Defined in

auth/FirebaseProfileStore.ts:19

Methods

get()

get(uid): Promise\<null | T>

Read a profile by user id, or null if none exists.

Parameters

• uid: string

Returns

Promise\<null | T>

Implementation of

ProfileStore.get

Defined in

auth/FirebaseProfileStore.ts:24

set()

set(uid, profile): Promise\<void>

Create or overwrite a profile.

Parameters

• uid: string

• profile: T

Returns

Promise\<void>

Implementation of

ProfileStore.set

Defined in

auth/FirebaseProfileStore.ts:29

update()

update(uid, partial): Promise\<void>

Merge a partial update into an existing profile.

Parameters

• uid: string

• partial: Partial\<T>

Returns

Promise\<void>

Implementation of

ProfileStore.update

Defined in

auth/FirebaseProfileStore.ts:33


FirebaseTokenVerifier

Implements

  • TokenVerifier

Constructors

new FirebaseTokenVerifier()

new FirebaseTokenVerifier(projectId): FirebaseTokenVerifier

Parameters

• projectId: string

Returns

FirebaseTokenVerifier

Defined in

auth/FirebaseTokenVerifier.ts:18

Methods

verify()

verify(token): Promise\<object>

Verify the token and return the authenticated identity.

Parameters

• token: string

Returns

Promise\<object>

uid

uid: string

email?

optional email: string

Throws

if the signature/claims are invalid or the token is expired.

Implementation of

TokenVerifier.verify

Defined in

auth/FirebaseTokenVerifier.ts:22

Interfaces

FirebaseConfig

Properties

apiKey

apiKey: string

Defined in

config.ts:6

authDomain

authDomain: string

Defined in

config.ts:7

projectId

projectId: string

Defined in

config.ts:8

storageBucket

storageBucket: string

Defined in

config.ts:9

messagingSenderId

messagingSenderId: string

Defined in

config.ts:10

appId

appId: string

Defined in

config.ts:11


FirebaseEnvironment

Properties

hubConfig

hubConfig: FirebaseConfig

Defined in

config.ts:15

appConfig?

optional appConfig: FirebaseConfig

Defined in

config.ts:16

useEmulators

useEmulators: boolean

Defined in

config.ts:17

emulatorPorts

emulatorPorts: object

auth

auth: number

firestore

firestore: number

Defined in

config.ts:18


EmulatorPorts

Properties

auth?

optional auth: number

Defined in

emulator.ts:6

firestore?

optional firestore: number

Defined in

emulator.ts:7

Functions

getHubAuth()

getHubAuth(): Auth

Returns

Auth

Defined in

auth/operations.ts:14


getCurrentUser()

getCurrentUser(): User | null

Returns

User | null

Defined in

auth/operations.ts:18


signIn()

signIn(email, password): Promise\<UserCredential>

Parameters

• email: string

• password: string

Returns

Promise\<UserCredential>

Defined in

auth/operations.ts:23


signUp()

signUp(email, password, displayName?): Promise\<UserCredential>

Parameters

• email: string

• password: string

• displayName?: string

Returns

Promise\<UserCredential>

Defined in

auth/operations.ts:28


signOut()

signOut(): Promise\<void>

Returns

Promise\<void>

Defined in

auth/operations.ts:39


resetPassword()

resetPassword(email): Promise\<void>

Parameters

• email: string

Returns

Promise\<void>

Defined in

auth/operations.ts:44


onAuthChange()

onAuthChange(callback): Unsubscribe

Parameters

• callback

Returns

Unsubscribe

Defined in

auth/operations.ts:49


initializeFirebase()

initializeFirebase(env): object

Parameters

• env: FirebaseEnvironment

Returns

object

hubApp

hubApp: FirebaseApp

appApp

appApp: undefined | FirebaseApp

Defined in

config.ts:27


getHubApp()

getHubApp(): FirebaseApp

Returns

FirebaseApp

Defined in

config.ts:73


getAppApp()

getAppApp(): FirebaseApp | undefined

Returns

FirebaseApp | undefined

Defined in

config.ts:80


connectEmulators()

connectEmulators(app, ports): void

Parameters

• app: FirebaseApp

• ports: EmulatorPorts = {}

Returns

void

Defined in

emulator.ts:15


executeBatch()

executeBatch(db, operations): Promise\<BatchResult>

Parameters

• db: Firestore

• operations: BatchOperation[]

Returns

Promise\<BatchResult>

Defined in

firestore/batch.ts:4


getHubFirestore()

getHubFirestore(): Firestore

Returns

Firestore

Defined in

firestore/operations.ts:16


getAppFirestore()

getAppFirestore(): Firestore

Returns

Firestore

Defined in

firestore/operations.ts:20


getDocumentData()

getDocumentData\<T>(db, path, id): Promise\<T | null>

Type Parameters

• T

Parameters

• db: Firestore

• path: string

• id: string

Returns

Promise\<T | null>

Defined in

firestore/operations.ts:28


setDocumentData()

setDocumentData\<T>(db, path, id, data): Promise\<void>

Type Parameters

• T extends Record\<string, any>

Parameters

• db: Firestore

• path: string

• id: string

• data: T

Returns

Promise\<void>

Defined in

firestore/operations.ts:34


updateDocumentData()

updateDocumentData(db, path, id, data): Promise\<void>

Parameters

• db: Firestore

• path: string

• id: string

• data: Record\<string, any>

Returns

Promise\<void>

Defined in

firestore/operations.ts:44


deleteDocumentData()

deleteDocumentData(db, path, id): Promise\<void>

Parameters

• db: Firestore

• path: string

• id: string

Returns

Promise\<void>

Defined in

firestore/operations.ts:54


queryDocuments()

queryDocuments\<T>(db, path, ...constraints): Promise\<T[]>

Type Parameters

• T

Parameters

• db: Firestore

• path: string

• ...constraints: QueryConstraint[]

Returns

Promise\<T[]>

Defined in

firestore/operations.ts:63


enablePersistence()

enablePersistence(db): Promise\<void>

Parameters

• db: Firestore

Returns

Promise\<void>

Defined in

firestore/persistence.ts:7


clearPersistence()

clearPersistence(db): Promise\<void>

Parameters

• db: Firestore

Returns

Promise\<void>

Defined in

firestore/persistence.ts:19


buildQueryConstraints()

buildQueryConstraints(filters, options?): QueryConstraint[]

Parameters

• filters: QueryFilter[]

• options?: QueryOptions

Returns

QueryConstraint[]

Defined in

firestore/query-builder.ts:4


subscribeToDocument()

subscribeToDocument\<T>(db, path, id, callback): Unsubscribe

Type Parameters

• T

Parameters

• db: Firestore

• path: string

• id: string

• callback

Returns

Unsubscribe

Defined in

firestore/subscriptions.ts:10


subscribeToCollection()

subscribeToCollection\<T>(db, path, callback, ...constraints): Unsubscribe

Type Parameters

• T

Parameters

• db: Firestore

• path: string

• callback

• ...constraints: QueryConstraint[]

Returns

Unsubscribe

Defined in

firestore/subscriptions.ts:22