npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@gasboost/auth-realtime-firebase

v0.1.1

Published

Firebase Authentication integration adapter for @gasboost/auth.

Readme

@gasboost/auth-realtime-firebase

Firebase Authentication integration adapter for @gasboost/auth.

@gasboost/auth の認証 lifecycle と、@gasboost/realtime-firebase の Firebase Custom Token generation を接続します。

@gasboost/auth
      ↓ afterSignIn
@gasboost/auth-realtime-firebase
      ↓
@gasboost/realtime-firebase
      ↓
Firebase Custom Token

Install

pnpm add \
  @gasboost/auth \
  @gasboost/auth-realtime-firebase \
  @gasboost/realtime-firebase

Usage

import { AppsScriptAuth, type EmailPasswordAuthOptions } from "@gasboost/auth";
import {
  FirebaseAuthHook,
  type FirebaseAuthHookResult,
} from "@gasboost/auth-realtime-firebase";

const firebase = new FirebaseAuthHook({
  serviceAccount: {
    email: serviceAccountEmail,
    privateKey,
  },

  utilities: Utilities,
});

const auth = new AppsScriptAuth<
  EmailPasswordAuthOptions,
  FirebaseAuthHookResult
>({
  repository,

  runtime: {
    utilities: Utilities,
    session: Session,
    cacheService: CacheService,
    propertiesService: PropertiesService,
  },

  session: {
    storageType: "cache",
  },

  emailPassword: {
    enabled: true,
    pepper,
  },

  hooks: {
    afterSignIn: firebase.afterSignIn,
  },
});

Sign In result から Firebase Custom Token を取得できます。

const result = await auth.signIn.email({
  email: "[email protected]",
  password: "password",
});

result.user;
result.session;
result.hooks.customToken;

UID

Gasboost Auth の User.id を Firebase Authentication の uid として利用します。

Auth User.id
    ↓
Firebase uid

adapter側で別のFirebase User IDを管理する必要はありません。

Custom Claims

claims を指定すると Firebase Custom Token の custom claims を生成できます。

const firebase = new FirebaseAuthHook({
  serviceAccount: {
    email: serviceAccountEmail,
    privateKey,
  },

  utilities: Utilities,

  claims: ({ user, session }) => ({
    storeId: "store-1",
    authSessionId: session.id,
  }),
});

生成されたclaimsはFirebase Authentication後、

auth.token.storeId

などとしてFirebase Security Rulesから参照できます。

Service Account

Firebase Custom Token は Google Service Account によって署名する必要があります。

このpackageでは @gasboost/realtime-firebase のローカル署名方式を利用するため、以下が必要です。

serviceAccount: {
  email: serviceAccountEmail,
  privateKey,
}

private key はソースコードへ直接埋め込まず、安全なcredential storageから取得してください。

Service Account credentialの保存やSecret Manager integrationは、このpackageの責務ではありません。

GAS Utilities

署名処理にはGoogle Apps Script標準の Utilities を利用できます。

const firebase = new FirebaseAuthHook({
  serviceAccount,
  utilities: Utilities,
});

公開APIはGAS固有型には依存していないため、実際の署名処理は @gasboost/realtime-firebase が要求する最小interfaceを通じて実行されます。

Client

Sign Inで取得したCustom Tokenはfrontendへ返し、Firebase公式SDKへ渡します。

import { getAuth, signInWithCustomToken } from "firebase/auth";

await signInWithCustomToken(getAuth(), result.hooks.customToken);

このpackageはFirebase Browser SDKをラップしません。

Package Boundary

このpackageが担当するのは integration のみです。

AfterSignInContext
   ├─ User
   └─ Session
        ↓
FirebaseAuthHook
        ↓
uid / claims
        ↓
FirebaseCustomToken.generate()

以下は担当しません。

  • Gasboost Auth の認証処理
  • Firebase Custom Token JWT生成ロジック
  • Firebase Admin SDK
  • Firebase Browser SDK
  • signInWithCustomToken() の実行
  • Firebase Auth session管理
  • Service Account credential storage
  • Secret Manager integration

License

MIT