From d738a4afe25ad7c3235c9b4018d1d7b961d03b17 Mon Sep 17 00:00:00 2001 From: Daniel Young Lee Date: Tue, 17 Oct 2023 16:26:30 -0700 Subject: [PATCH 1/3] Fix bug where auth metadata in the auth blocking tokens are assumed to be seconds not miliseconds. --- spec/common/providers/identity.spec.ts | 12 ++++++------ src/common/providers/identity.ts | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/spec/common/providers/identity.spec.ts b/spec/common/providers/identity.spec.ts index 308845172..a5112b6c3 100644 --- a/spec/common/providers/identity.spec.ts +++ b/spec/common/providers/identity.spec.ts @@ -207,8 +207,8 @@ describe("identity", () => { describe("parseMetadata", () => { const decodedMetadata = { - last_sign_in_time: 1476235905, - creation_time: 1476136676, + last_sign_in_time: 1476235905000, + creation_time: 1476136676000, }; const metadata = { lastSignInTime: new Date(1476235905000).toUTCString(), @@ -374,8 +374,8 @@ describe("identity", () => { photo_url: "https://lh3.googleusercontent.com/1234567890/photo.jpg", tokens_valid_after_time: 1476136676, metadata: { - last_sign_in_time: 1476235905, - creation_time: 1476136676, + last_sign_in_time: 1476235905000, + creation_time: 1476136676000, }, custom_claims: { admin: true, @@ -632,8 +632,8 @@ describe("identity", () => { photo_url: "https://lh3.googleusercontent.com/1234567890/photo.jpg", tokens_valid_after_time: 1476136676, metadata: { - last_sign_in_time: 1476235905, - creation_time: 1476136676, + last_sign_in_time: 1476235905000, + creation_time: 1476136676000, }, custom_claims: { admin: true, diff --git a/src/common/providers/identity.ts b/src/common/providers/identity.ts index 9997d7569..b90c5b549 100644 --- a/src/common/providers/identity.ts +++ b/src/common/providers/identity.ts @@ -489,10 +489,10 @@ function unsafeDecodeAuthBlockingToken(token: string): DecodedPayload { */ export function parseMetadata(metadata: DecodedPayloadUserRecordMetadata): AuthUserMetadata { const creationTime = metadata?.creation_time - ? new Date(metadata.creation_time * 1000).toUTCString() + ? new Date(metadata.creation_time).toUTCString() : null; const lastSignInTime = metadata?.last_sign_in_time - ? new Date(metadata.last_sign_in_time * 1000).toUTCString() + ? new Date(metadata.last_sign_in_time).toUTCString() : null; return { creationTime, From c4ac7a8269ccc0f26521514e81a3ed39661d0b0c Mon Sep 17 00:00:00 2001 From: Daniel Lee Date: Tue, 17 Oct 2023 16:40:02 -0700 Subject: [PATCH 2/3] Add changelog. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 767a26aeb..eab4161a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,4 @@ - Remove HTTP server shutdown message. (#1457) - Add features to task queue functions. (#1423) - Add traces to V2 Firestore trigger logs. (#1440) +- Fix incorrectly parsed timestamps in auth blocking functions. (#1472) From 0e404918ab0913e6e638fb88166a02362321e206 Mon Sep 17 00:00:00 2001 From: Daniel Young Lee Date: Thu, 19 Oct 2023 12:28:53 -0700 Subject: [PATCH 3/3] Fix bin test. --- scripts/bin-test/run.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/bin-test/run.sh b/scripts/bin-test/run.sh index c3e3da673..bf07e635a 100755 --- a/scripts/bin-test/run.sh +++ b/scripts/bin-test/run.sh @@ -12,7 +12,10 @@ for f in scripts/bin-test/sources/*; do fi done -## DEBUG +# Make sure firebase-functions binary is executable +chmox +x ./lib/bin/firebase-functions.js + +# DEBUG ls -la scripts/bin-test/sources/commonjs/node_modules mocha \