You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

firebase-auth-sdk

Package Overview
Dependencies
Maintainers
0
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

firebase-auth-sdk

A lightweight TypeScript wrapper for Firebase Authentication REST API. This package provides a simple interface to interact with Firebase Authentication services without the full Firebase SDK dependency.

0.0.5
latest
Source
npmnpm
Version published
Maintainers
0
Created
Source

Firebase Auth SDK

A lightweight TypeScript wrapper for Firebase Authentication REST API. This package provides a simple interface to interact with Firebase Authentication services without the full Firebase SDK dependency.

Installation

npm install firebase-auth-sdk

Features

  • User authentication (sign up, sign in)
  • Token management (refresh tokens, validate tokens)
  • Profile management
  • Password reset functionality
  • Authentication state verification

Usage

import { FirebaseAuthSDK } from "firebase-auth-sdk";

const auth = new FirebaseAuthSDK("your-api-key");

Sign Up

const signUp = async () => {
  try {
    const user = await auth.signUp("user@example.com", "password123");
    console.log("User created:", user.localId);
  } catch (error) {
    console.error("Sign up failed:", error.message);
  }
};

Sign In

const signIn = async () => {
  try {
    const user = await auth.signIn("user@example.com", "password123");
    console.log("Signed in:", user.idToken);
  } catch (error) {
    console.error("Sign in failed:", error.message);
  }
};

Email Verification

const sendVerification = async (idToken: string) => {
  try {
    await auth.sendEmailVerification(idToken);
    console.log("Verification email sent");
  } catch (error) {
    console.error("Failed to send verification:", error.message);
  }
};

// When user clicks verification link, verify the OOB code
const verifyEmail = async (oobCode: string) => {
  try {
    await auth.confirmEmailVerification(oobCode);
    console.log("Email verified successfully");
  } catch (error) {
    console.error("Email verification failed:", error.message);
  }
};

Password Reset

const resetPassword = async () => {
  try {
    // Send reset email
    await auth.sendPasswordReset("user@example.com");
    console.log("Password reset email sent");

    // When user clicks reset link, verify the OOB code and set new password
    const oobCode = "code-from-email";
    await auth.verifyPasswordReset(oobCode, "newPassword123");
    console.log("Password reset successful");
  } catch (error) {
    console.error("Password reset failed:", error.message);
  }
};

Error Handling

The SDK throws HttpError for API-related errors, which includes:

  • Status code
  • Error message
  • Additional error data (when available)

Types

The package includes TypeScript definitions for all responses from Firebase Authentication API, including:

  • FirebaseUser
  • FirebaseSignupResponse
  • FirebaseRefreshTokenResponse
  • FirebaseUpdateProfileResponse
  • LookupInfoResponse

License

MIT License

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

FAQs

Package last updated on 06 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts