-
Notifications
You must be signed in to change notification settings - Fork 409
Closed
Labels
Description
[REQUIRED] Step 2: Describe your environment
- Operating System version: OS Name Microsoft Windows 11 Home Version 10.0.22631 Build 22631
- Firebase SDK version: _____
- Firebase Product: cloud functions (auth, database, storage, etc)
- Node.js version: 20
- NPM version: 10.8.2
[REQUIRED] Step 3: Describe the problem
The documentation for the auth triggers is no longer valid
https://firebase.google.com/docs/auth/extend-with-functions
src/onUserCreated.ts:8:45 - error TS2339: Property 'user' does not exist on type '(app?: App | undefined) => Auth'.
8 export const onUserCreated = functions.auth.user().onCreate((user:any) => {
Steps to reproduce:
Using v12.6 of the firebase-functions package the below trigger is invalid:
// The Cloud Functions for Firebase SDK to create Cloud Functions and set up triggers.
import * as functions from 'firebase-functions';
// Start writing functions
// https://firebase.google.com/docs/functions/typescript
export const onUserCreated = functions.auth.user().onCreate((user:any) => {
//TODO: Create avatar on user create and send verification email
console.info(new Date())
console.info(user)
});
I am currently refactoring to use a blocking function - only because the project is new and I can afford to do this
// The Cloud Functions for Firebase SDK to create Cloud Functions and set up triggers.
import {
beforeUserCreated,
} from "firebase-functions/v2/identity";
// Start writing functions
// https://firebase.google.com/docs/functions/typescript
export const onUserCreated = beforeUserCreated((event:any) => {
//TODO: Create avatar on user create and send verification email
console.info(new Date())
console.info(event)
});
What happened? How can we make the problem occur?
Run firebase init and try to set up a cloud function with an auth trigger as described in the documentation.
Relevant Code:
package.json
{
"name": "functions",
"scripts": {
"lint": "eslint --ext .js,.ts .",
"build": "tsc",
"build:watch": "tsc --watch",
"serve": "npm run build && firebase emulators:start --only functions",
"shell": "npm run build && firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"engines": {
"node": "20"
},
"main": "lib/index.js",
"dependencies": {
"firebase-admin": "^12.6.0",
"firebase-functions": "^6.0.1"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.12.0",
"@typescript-eslint/parser": "^5.12.0",
"eslint": "^8.9.0",
"eslint-config-google": "^0.14.0",
"eslint-plugin-import": "^2.25.4",
"firebase-functions-test": "^3.1.0",
"typescript": "^4.9.0"
},
"private": true
}