Description
My environment
- Operating System version: irrelevant
- Firebase SDK version: check below
- Firebase Product: auth, functions
- Node.js version: 14.18.1
- NPM version: 6.14.15
"firebase": "^9.2.0",
"firebase-admin": "^9.12.0",
"firebase-functions": "^3.15.7",
The problem
The UserMetadata class defines the type of creationTime
and lastSignInTime
as a UTC string. However, the actual date format returned by the admin SDK differs from the format returned by the cloud function onCreate date format, even though both claim to implement the same interface.
The Admin SDK seems to use the RFC7231 format (Thu, 28 Oct 2021 08:53:26 GMT
), where as the Firebase Functions use the ISO format
(2016-12-15T19:37:37.059Z
).
The Functions Specs mention that they use the same UserRecord as the Firebase Admin SDK
https://firebase.google.com/docs/reference/functions/providers_auth.userbuilder#user:-userrecord
=> https://firebase.google.com/docs/reference/functions/providers_auth#userrecord
The UserRecord passed to Cloud Functions is the same UserRecord that is returned by the Firebase Admin SDK.
and the Admin SDK defines the date as an UTC string: https://github.com/firebase/firebase-admin-node/blob/master/src/auth/user-record.ts#L300
This is also reflected in the test suites:
Admin SDK: https://github.com/firebase/firebase-admin-node/blob/master/test/integration/auth.spec.ts#L240
Firebase Functions: https://github.com/firebase/firebase-functions/blob/master/spec/v1/providers/auth.spec.ts#L179
I am kindly requesting this to be unified, since it is very confusing to use. Preferably with the ISO format.
Relevant Code:
Admin SDK:
const user = await admin.auth().getUser(uid)
console.log(user.metadata.creationTime)
// Thu, 01 Jan 1970 00:00:00 UTC
Firebase Authentication trigger:
exports.test = functions.auth.user().onCreate((user) => {
console.log(user.metadata.creationTime)})
// 2017-02-02T23:06:26.124Z