New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

firebase-auth-cfworkers

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

firebase-auth-cfworkers

Firebase/Admin auth SDK for Cloudflare Workers

unpublished
latest
Source
npmnpm
Version
1.2.3
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Firebase Auth

Firebase/Admin Auth Javascript Library for Cloudflare Workers


License GitHub CI NPM NPM Downloads

Supported operations:

  • createSessionCookie()
  • verifySessionCookie()
  • signInWithEmailAndPassword()
  • signUpWithEmailAndPassword()
  • changePassword()
  • lookupUser()
  • setCustomUserClaims()

Install

npm i firebase-auth-cfworkers

Usage

Firebase tries to use the same method names and return values as the official Firebase/Admin SDK. Sometimes, the method signature are slightly different.

Create FirebaseAuth

import { FirebaseAuth } from 'firebase-auth-cfworkers';

const auth = new FirebaseAuth({
  apiKey: 'Firebase api key',
  projectId: 'Firebase project id',
  privateKey: 'Firebase private key or service account private key',
  serviceAccountEmail: 'Firebase service account email',
});

Sign-in with email/pass

//Sign in with username and password
const { token, user } = await auth.signInWithEmailAndPassword(
  'my@email.com',
  'supersecurepassword'
);

const userEmail = user.email;
const refreshToken = token.refreshToken;

Sign-up with email/pass

//Sign up with username and password
const { token, user } = await auth.signUpWithEmailAndPassword(
  'my@email.com',
  'supersecurepassword'
);

const userEmail = user.email;
const refreshToken = token.refreshToken;

Set Custom User Claims

//Set Custom User Claims
const res = await auth.setCustomUserClaims(uid,
  {'admin':true}
);

Create session cookies

//Create a new session cookie from the user idToken
const { token, user } = await auth.signInWithEmailAndPassword(
  'my@email.com',
  'supersecurepassword'
);

const sessionCookie = await auth.createSessionCookie(token.idToken);

Verify session cookies

auth
  .verifySessionCookie(sessionCookie)
  .then((token) => useToken(token))
  .catch((e) => console.log('Invalid session cookie'));

Cache OAuth tokens with CloudflareKv KV

import { FirebaseAuth, CloudflareKv } from 'firebase-auth-cfworkers';

const auth = new FirebaseAuth({
  apiKey: 'Firebase api key',
  projectId: 'Firebase project id',
  privateKey: 'Firebase private key or service account private key',
  serviceAccountEmail: 'Firebase service account email',
  cache: new CloudflareKv(NAMESPACE),
});

Keywords

firebase

FAQs

Package last updated on 26 Nov 2022

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