From 3d13f56a88b95ea61e346348546b709b490bb394 Mon Sep 17 00:00:00 2001 From: Jeffrey Dallatezza Date: Mon, 12 Jul 2021 13:27:57 -0700 Subject: [PATCH 1/3] Pass auth token to the connection, and use Bearer in the header value --- packages/database/src/realtime/Connection.ts | 1 + packages/database/src/realtime/WebSocketConnection.ts | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/database/src/realtime/Connection.ts b/packages/database/src/realtime/Connection.ts index eb52e13e011..c1484c97584 100644 --- a/packages/database/src/realtime/Connection.ts +++ b/packages/database/src/realtime/Connection.ts @@ -122,6 +122,7 @@ export class Connection { this.repoInfo_, this.applicationId_, this.appCheckToken_, + this.authToken_, this.lastSessionId ); diff --git a/packages/database/src/realtime/WebSocketConnection.ts b/packages/database/src/realtime/WebSocketConnection.ts index d171fee0f6c..abeb0f70474 100644 --- a/packages/database/src/realtime/WebSocketConnection.ts +++ b/packages/database/src/realtime/WebSocketConnection.ts @@ -172,7 +172,7 @@ export class WebSocketConnection implements Transport { // Note that this header is just used to bypass appcheck, and the token should still be sent // through the websocket connection once it is established. if (this.authToken) { - options.headers['Authorization'] = this.authToken; + options.headers['Authorization'] = `Bearer ${this.authToken}`; } if (this.appCheckToken) { options.headers['X-Firebase-AppCheck'] = this.appCheckToken; @@ -238,7 +238,7 @@ export class WebSocketConnection implements Transport { /** * No-op for websockets, we don't need to do anything once the connection is confirmed as open */ - start() { } + start() {} static forceDisallow_: boolean; From af66a273768675ef719f246dc6dcbc4c5910bc51 Mon Sep 17 00:00:00 2001 From: Jeffrey Dallatezza Date: Mon, 12 Jul 2021 13:29:41 -0700 Subject: [PATCH 2/3] Add changeset. --- .changeset/wet-pets-travel.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/wet-pets-travel.md diff --git a/.changeset/wet-pets-travel.md b/.changeset/wet-pets-travel.md new file mode 100644 index 00000000000..9f794de75c0 --- /dev/null +++ b/.changeset/wet-pets-travel.md @@ -0,0 +1,5 @@ +--- +'@firebase/database': patch +--- + +Fix sending of auth tokens on node. From c4e2e9025ecf6f6ecbe28e3b827363d48d78381d Mon Sep 17 00:00:00 2001 From: Jeffrey Dallatezza Date: Wed, 14 Jul 2021 10:35:16 -0700 Subject: [PATCH 3/3] Don't use lastSessionId as transportSessionId. --- packages/database/src/realtime/Connection.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/database/src/realtime/Connection.ts b/packages/database/src/realtime/Connection.ts index c1484c97584..430d68ec9b0 100644 --- a/packages/database/src/realtime/Connection.ts +++ b/packages/database/src/realtime/Connection.ts @@ -123,6 +123,7 @@ export class Connection { this.applicationId_, this.appCheckToken_, this.authToken_, + null, this.lastSessionId );