Description
Related issues
[REQUIRED] Version info
node: 18.12.1 although not relevant here
firebase-functions: 4.4.0
firebase-tools: 12.0.0
firebase-admin: 11.8.0
[REQUIRED] Test case
export const Example = functions.database.ref(someRef).onDelete(async (snap, context) => {
if (context.auth) type Problem = typeof context.auth.token
});
[REQUIRED] Steps to reproduce
Inspect the type Problem
(or the context.auth
) in the code above.
The auth
object is typed as:
auth?: {
token: object;
uid: string;
};
Where the token
key is just typed as object
without any further details.
I'm assuming but I didn't check that the same is true for similar database triggers.
[REQUIRED] Expected behavior
Expected to have typing similar to DecodedIdToken
or ParsedToken
as described in the reference:
The EventContext.auth
reference page says to see the security rules reference, linking to the Cloud Firestore Rules reference page, as does the typescript definition file itself. I'm assuming it should actually link to the Database Rules reference page, especially since the reference and the typescript definition file about EventContext.auth
say that "This field is only populated for Realtime Database triggers and Callable functions.". The reference about the Database Rules explains with detail what the keys of the token
object are, which is why I was expecting that this would be reflected in the typing as well.
[REQUIRED] Actual behavior
Inspection of the type learns that it is just typed as object
.
Were you able to successfully deploy your functions?
Yes, this is about typescript typing, so it doesn't impede deployment because it can be easily coerced to be of a specific type, just lowers type safety.