@userhub/gcip-functions
TypeScript icon, indicating that this package has built-in type declarations

0.5.1 • Public • Published

Google Cloud Identity Platform Functions

Helper functions for the UserHub Google Cloud Identity Platform (Firebase Authentication) connection.

Usage

const { UserHubFunctions } = require("@userhub/gcip-functions");
const { runWith } = require("firebase-functions/v1");
const { defineSecret, defineString } = require("firebase-functions/params");

const API_KEY = defineSecret("USERHUB_API_KEY");
const CONNECTION_ID = defineString("USERHUB_CONNECTION_ID");

const functions = new UserHubFunctions({
  apiKey: API_KEY,
  connectionId: CONNECTION_ID,
});

exports.onCreate = runWith({
  memory: "128MB",
  secrets: [API_KEY],
})
  .auth.user()
  .onCreate(functions.onCreate);

exports.onDelete = runWith({
  memory: "128MB",
  secrets: [API_KEY],
})
  .auth.user()
  .onDelete(functions.onDelete);

There is also support for the blocking beforeSignIn function which ensures the user exists in UserHub before the sign-in process completes.

Enabling this function adds latency to the sign-in flow and requires that your Firebase project be updated to Firebase Authentication with Identity Platform.

exports.beforeSignIn = runWith({
  memory: "128MB",
  minInstances: 1,
  secrets: [API_KEY],
})
  .auth.user()
  .beforeSignIn(functions.beforeSignIn);

/@userhub/gcip-functions/

    Package Sidebar

    Install

    npm i @userhub/gcip-functions

    Weekly Downloads

    10

    Version

    0.5.1

    License

    MIT

    Unpacked Size

    21.3 kB

    Total Files

    7

    Last publish

    Collaborators

    • userhub-bot
    • silas