Skip to content

Commit 504ce8a

Browse files
Merge 9f9f553 into 87c90a7
2 parents 87c90a7 + 9f9f553 commit 504ce8a

File tree

7 files changed

+53
-68
lines changed

7 files changed

+53
-68
lines changed

.changeset/eleven-moons-shave.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@firebase/firestore": minor
3+
"@firebase/webchannel-wrapper": minor
4+
---
5+
6+
Enable encodeInitMessageHeaders. This transitions the Firestore client from encoding HTTP Headers via the Query Param to the request's POST payload.
7+
8+
Requires Cloud Firestore Emulator v1.14.4 or newer.

packages/firestore/src/platform/browser/webchannel_connection.ts

+4-28
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,6 @@
1515
* limitations under the License.
1616
*/
1717

18-
import {
19-
isBrowserExtension,
20-
isElectron,
21-
isIE,
22-
isMobileCordova,
23-
isReactNative,
24-
isUWP
25-
} from '@firebase/util';
2618
import {
2719
createWebChannelTransport,
2820
ErrorCode,
@@ -215,26 +207,10 @@ export class WebChannelConnection extends RestConnection {
215207
// https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#Simple_requests
216208
//
217209
// Therefore to avoid the CORS preflight request (an extra network
218-
// roundtrip), we use the httpHeadersOverwriteParam option to specify that
219-
// the headers should instead be encoded into a special "$httpHeaders" query
220-
// parameter, which is recognized by the webchannel backend. This is
221-
// formally defined here:
222-
// https://github.com/google/closure-library/blob/b0e1815b13fb92a46d7c9b3c30de5d6a396a3245/closure/goog/net/rpc/httpcors.js#L32
223-
//
224-
// TODO(b/145624756): There is a backend bug where $httpHeaders isn't respected if the request
225-
// doesn't have an Origin header. So we have to exclude a few browser environments that are
226-
// known to (sometimes) not include an Origin. See
227-
// https://github.com/firebase/firebase-js-sdk/issues/1491.
228-
if (
229-
!isMobileCordova() &&
230-
!isReactNative() &&
231-
!isElectron() &&
232-
!isIE() &&
233-
!isUWP() &&
234-
!isBrowserExtension()
235-
) {
236-
request.httpHeadersOverwriteParam = '$httpHeaders';
237-
}
210+
// roundtrip), we use the encodeInitMessageHeaders option to specify that
211+
// the headers should instead be encoded in the request's POST payload,
212+
// which is recognized by the webchannel backend.
213+
request.encodeInitMessageHeaders = true;
238214

239215
const url = urlParts.join('');
240216
logDebug(LOG_TAG, 'Creating WebChannel: ' + url, request);

packages/webchannel-wrapper/externs/overrides.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ goog.net.WebChannel.Options.sendRawJson;
5151
/** @type {string|undefined} */
5252
goog.net.WebChannel.Options.httpSessionIdParam;
5353

54-
/** @type {string|undefined} */
55-
goog.net.WebChannel.Options.httpHeadersOverwriteParam;
54+
/** @type {boolean|undefined} */
55+
goog.net.WebChannel.Options.encodeInitMessageHeaders;
5656

5757
/** @type {boolean|undefined} */
5858
goog.net.WebChannel.Options.fastHandshake;

packages/webchannel-wrapper/package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@
2626
},
2727
"license": "Apache-2.0",
2828
"devDependencies": {
29-
"google-closure-compiler": "20210601.0.0",
30-
"google-closure-library": "20210406.0.0",
29+
"@rollup/plugin-commonjs": "21.0.0",
30+
"google-closure-compiler": "20220301.0.0",
31+
"google-closure-library": "20220301.0.0",
3132
"gulp": "4.0.2",
3233
"gulp-sourcemaps": "3.0.0",
3334
"rollup": "2.72.1",

packages/webchannel-wrapper/src/index.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export interface WebChannelOptions {
9696
supportsCrossDomainXhr?: boolean;
9797
sendRawJson?: boolean;
9898
httpSessionIdParam?: string;
99-
httpHeadersOverwriteParam?: string;
99+
encodeInitMessageHeaders?: boolean;
100100
forceLongPolling?: boolean;
101101
detectBufferingProxy?: boolean;
102102
fastHandshake?: boolean;

scripts/emulator-testing/emulators/firestore-emulator.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ export class FirestoreEmulator extends Emulator {
2222

2323
constructor(port: number, projectId = 'test-emulator') {
2424
super(
25-
'cloud-firestore-emulator-v1.11.7.jar',
25+
'cloud-firestore-emulator-v1.14.4.jar',
2626
// Use locked version of emulator for test to be deterministic.
2727
// The latest version can be found from firestore emulator doc:
2828
// https://firebase.google.com/docs/firestore/security/test-rules-emulator
29-
'https://storage.googleapis.com/firebase-preview-drop/emulator/cloud-firestore-emulator-v1.11.7.jar',
29+
'https://storage.googleapis.com/firebase-preview-drop/emulator/cloud-firestore-emulator-v1.14.4.jar',
3030
port
3131
);
3232
this.projectId = projectId;

yarn.lock

+33-33
Original file line numberDiff line numberDiff line change
@@ -8869,45 +8869,45 @@ google-auth-library@^8.0.2:
88698869
jws "^4.0.0"
88708870
lru-cache "^6.0.0"
88718871

8872-
google-closure-compiler-java@^20210601.0.0:
8873-
version "20210601.0.0"
8874-
resolved "https://registry.npmjs.org/google-closure-compiler-java/-/google-closure-compiler-java-20210601.0.0.tgz#88dc11b334bee6a704d9674c5143fd2e0d553517"
8875-
integrity sha512-bH6nIwOmp4qDWvlbXx5/DE3XA2aDGQoCpmRYZJGONY1Sy6Xfbq0ioXRHH9eBDP9hxhCJ5Sd/K89A0NZ8Nz9RJA==
8876-
8877-
google-closure-compiler-linux@^20210601.0.0:
8878-
version "20210601.0.0"
8879-
resolved "https://registry.npmjs.org/google-closure-compiler-linux/-/google-closure-compiler-linux-20210601.0.0.tgz#6e5dd7b00b96dc1fd1ba30e3401af85558768322"
8880-
integrity sha512-rnEQt7zz/1P1SfPhJiHQpfCgMPrsVVyEgDs09h67xn6+LXa9L0RP+hrJDEHqSWwjDPz0BkfUUv6zkqZvp1h/lw==
8881-
8882-
google-closure-compiler-osx@^20210601.0.0:
8883-
version "20210601.0.0"
8884-
resolved "https://registry.npmjs.org/google-closure-compiler-osx/-/google-closure-compiler-osx-20210601.0.0.tgz#e23356bc9ef6e68c2980f60a207f603767b50b21"
8885-
integrity sha512-A5r4s/WthR2iLMM0mxsluw8EW2AcOomC5ri/H6FjzpMq0RVEnLTgaGYdXolUAfEzH/7XtJJT2+JkYk3HSLCtrg==
8886-
8887-
google-closure-compiler-windows@^20210601.0.0:
8888-
version "20210601.0.0"
8889-
resolved "https://registry.npmjs.org/google-closure-compiler-windows/-/google-closure-compiler-windows-20210601.0.0.tgz#b5400d06bbf0bbd2602ee3ae0c2bc7ebd5829692"
8890-
integrity sha512-6r94bPShnB0XXh9+5/qXGDHJN2PQGhF9yJPcgBZj+FAZlQGzlYkT0pkyp+loZT3lG+YRbjD28Lgo7xMcY4xgkA==
8891-
8892-
google-closure-compiler@20210601.0.0:
8893-
version "20210601.0.0"
8894-
resolved "https://registry.npmjs.org/google-closure-compiler/-/google-closure-compiler-20210601.0.0.tgz#34597c33c9285ebd3a5364f5299f6c9ddc9fc88a"
8895-
integrity sha512-lzzEoG2VTB7uUjnWnMyeZMU163w69HJpM27yh8Up9Ha5McHZeESjt3NRwU8cWMbCRdY06nFbRCDIVCRcadHCiw==
8872+
google-closure-compiler-java@^20220301.0.0:
8873+
version "20220301.0.0"
8874+
resolved "https://registry.npmjs.org/google-closure-compiler-java/-/google-closure-compiler-java-20220301.0.0.tgz#6283bad6991ae9cfb3a9fdf72bbd7bf0c8f21fb6"
8875+
integrity sha512-kv5oaUI4xn3qWYWtRHRqbm314kesfeFlCxiFRcvBIx13mKfR0qvbOkgajLpSM6nb3voNM/E9MB9mfvHJ9XIXSg==
8876+
8877+
google-closure-compiler-linux@^20220301.0.0:
8878+
version "20220301.0.0"
8879+
resolved "https://registry.npmjs.org/google-closure-compiler-linux/-/google-closure-compiler-linux-20220301.0.0.tgz#3ac8cd1cb51d703a89bc49c239df4c10b57f37bb"
8880+
integrity sha512-N2D0SRnxZ7kqdoZ2WsmLIjmizR4Xr0HaUYDK2RCOtsV21RYV8OR2u0ATp7aXhYy8WfxvYH478Ehvmc9Uzy986A==
8881+
8882+
google-closure-compiler-osx@^20220301.0.0:
8883+
version "20220301.0.0"
8884+
resolved "https://registry.npmjs.org/google-closure-compiler-osx/-/google-closure-compiler-osx-20220301.0.0.tgz#1a49eb1d78b6bfb90ebe51c24a7151cee4f319a3"
8885+
integrity sha512-Xqf0m5takwfv43ML4aODJxmAsAZQMTMo683gyRs0APAecncs+YKxaDPMH+pQAdI3HPY2QsvkarlunAp0HSwU5A==
8886+
8887+
google-closure-compiler-windows@^20220301.0.0:
8888+
version "20220301.0.0"
8889+
resolved "https://registry.npmjs.org/google-closure-compiler-windows/-/google-closure-compiler-windows-20220301.0.0.tgz#b09df91a789e458eb9ebf054a9bb2d2b29622b6f"
8890+
integrity sha512-s+FU/vcpLTEgx8MCMgj0STCYkVk7syzF9KqiYPOTtbTD9ra99HPe/CEuQG7iJ3Fty9dhm9zEaetv4Dp4Wr6x+Q==
8891+
8892+
google-closure-compiler@20220301.0.0:
8893+
version "20220301.0.0"
8894+
resolved "https://registry.npmjs.org/google-closure-compiler/-/google-closure-compiler-20220301.0.0.tgz#1c4f56076ae5b2c900a91d0a72515f7ee7f5d3cd"
8895+
integrity sha512-+yAqhufKIWddg587tnvRll92eLJQIlzINmgr1h5gLXZVioY3svrSYKH4TZiUuNj0UnVFoK0o1YuW122x+iFl2g==
88968896
dependencies:
88978897
chalk "2.x"
8898-
google-closure-compiler-java "^20210601.0.0"
8898+
google-closure-compiler-java "^20220301.0.0"
88998899
minimist "1.x"
89008900
vinyl "2.x"
89018901
vinyl-sourcemaps-apply "^0.2.0"
89028902
optionalDependencies:
8903-
google-closure-compiler-linux "^20210601.0.0"
8904-
google-closure-compiler-osx "^20210601.0.0"
8905-
google-closure-compiler-windows "^20210601.0.0"
8906-
8907-
google-closure-library@20210406.0.0:
8908-
version "20210406.0.0"
8909-
resolved "https://registry.npmjs.org/google-closure-library/-/google-closure-library-20210406.0.0.tgz#47d6036c1704661ad47cde2e35f19cc55e33e775"
8910-
integrity sha512-1lAC/KC9R2QM6nygniM0pRcGrv5bkCUrIZb2hXFxLtAkA+zRiVeWtRYpFWDHXXJzkavKjsn9upiffL4x/nmmVg==
8903+
google-closure-compiler-linux "^20220301.0.0"
8904+
google-closure-compiler-osx "^20220301.0.0"
8905+
google-closure-compiler-windows "^20220301.0.0"
8906+
8907+
google-closure-library@20220301.0.0:
8908+
version "20220301.0.0"
8909+
resolved "https://registry.npmjs.org/google-closure-library/-/google-closure-library-20220301.0.0.tgz#c9aaa99218f949b1f914a86f2a4529dea20e2e47"
8910+
integrity sha512-GRRBfG80JPqkKkTxiRoVr/x4UmnPW2aeA72NH0zapPtrvSkAOCzfJFrdudLrAJJtXPdSE65+CkYrpZX8tP0mCQ==
89118911

89128912
google-gax@^3.0.1:
89138913
version "3.1.3"

0 commit comments

Comments
 (0)