firebasejuice

package
v1.36.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 15, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Description: This package provides a set of functions to interact with the Firebase API and the Firebase Admin SDK.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanupMock

func CleanupMock(ctx context.Context, app *firebase.App, user *auth.UserRecord) error

CleanupMock deletes the Firebase user.

Typically utilized in integration tests to clean up the user after the test is complete.

Use "defer" to call this function after the test is complete to delete the mock user from Firebase.

func CreateFirebaseUser

func CreateFirebaseUser(ctx context.Context, app *firebase.App, httpClient *http.Client, user *auth.UserToCreate, email string) (*auth.UserRecord, error)

CreateFirebaseUser creates a Firebase user and returns the user record.

An embedded filesystem and the path to the credentials file are required.

User is created with the specified email and password only.

The user to be passed to the function must be a pointer to a struct of type auth.UserToCreate.

- user := auth.UserToCreate{}

- user.Email(mockEmail)

- user.Password(mockPwd)

func GenerateMockFirebaseUID

func GenerateMockFirebaseUID(length int) string

GenerateMockFirebaseUID generates a random Firebase UID of the specified length.

Typically utilized in integration tests to create a mock user.

func GetFirebaseIDToken

func GetFirebaseIDToken(email, password, firebaseAPIKey string) (string, error)

GetFirebaseIDToken exchanges an email and password of an active Firebase user for its Firebase UID.

The email and password are used to authenticate with Firebase and represent the user's credentials.

A valid Firebase API key is required to authenticate with the Firebase API.

The Firebase ID token is returned.

If the request fails, an error is returned.

func InitFirebaseApp

func InitFirebaseApp(ctx context.Context, FS embed.FS, accountCredentialsPath string) (*firebase.App, error)

InitFirebaseApp initializes the Firebase Admin SDK and returns the app instance.

Types

type FirebaseError added in v1.14.5

type FirebaseError struct {
	Errors  []FirebaseErrorDetail `json:"errors"`
	Code    int                   `json:"code"`
	Message string                `json:"message"`
}

type FirebaseErrorDetail added in v1.14.5

type FirebaseErrorDetail struct {
	Domain  string `json:"domain"`
	Reason  string `json:"reason"`
	Message string `json:"message"`
}

FirebaseErrorDetail is the model for the error details in a Firebase error response.k

type FirebaseErrorResponse added in v1.14.5

type FirebaseErrorResponse struct {
	Error FirebaseError `json:"error"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL