Skip to content

Commit b90cfd5

Browse files
Enable encodeInitMessageHeaders
1 parent 2d672ce commit b90cfd5

File tree

5 files changed

+44
-68
lines changed

5 files changed

+44
-68
lines changed

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

Lines changed: 4 additions & 28 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
},
2626
"license": "Apache-2.0",
2727
"devDependencies": {
28-
"google-closure-compiler": "20210601.0.0",
29-
"google-closure-library": "20210406.0.0",
28+
"@rollup/plugin-commonjs": "21.0.0",
29+
"google-closure-compiler": "20220301.0.0",
30+
"google-closure-library": "20220301.0.0",
3031
"gulp": "4.0.2",
3132
"gulp-sourcemaps": "3.0.0",
3233
"rollup": "2.57.0",
33-
"@rollup/plugin-commonjs": "21.0.0",
3434
"rollup-plugin-sourcemaps": "0.6.3",
3535
"rollup-plugin-typescript2": "0.30.0",
3636
"typescript": "4.2.2"
@@ -44,4 +44,4 @@
4444
"bugs": {
4545
"url": "https://github.com/firebase/firebase-js-sdk/issues"
4646
}
47-
}
47+
}

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

Lines changed: 1 addition & 1 deletion
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;

yarn.lock

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8438,45 +8438,45 @@ google-auth-library@^7.0.0, google-auth-library@^7.6.1:
84388438
jws "^4.0.0"
84398439
lru-cache "^6.0.0"
84408440

8441-
google-closure-compiler-java@^20210601.0.0:
8442-
version "20210601.0.0"
8443-
resolved "https://registry.npmjs.org/google-closure-compiler-java/-/google-closure-compiler-java-20210601.0.0.tgz#88dc11b334bee6a704d9674c5143fd2e0d553517"
8444-
integrity sha512-bH6nIwOmp4qDWvlbXx5/DE3XA2aDGQoCpmRYZJGONY1Sy6Xfbq0ioXRHH9eBDP9hxhCJ5Sd/K89A0NZ8Nz9RJA==
8445-
8446-
google-closure-compiler-linux@^20210601.0.0:
8447-
version "20210601.0.0"
8448-
resolved "https://registry.npmjs.org/google-closure-compiler-linux/-/google-closure-compiler-linux-20210601.0.0.tgz#6e5dd7b00b96dc1fd1ba30e3401af85558768322"
8449-
integrity sha512-rnEQt7zz/1P1SfPhJiHQpfCgMPrsVVyEgDs09h67xn6+LXa9L0RP+hrJDEHqSWwjDPz0BkfUUv6zkqZvp1h/lw==
8450-
8451-
google-closure-compiler-osx@^20210601.0.0:
8452-
version "20210601.0.0"
8453-
resolved "https://registry.npmjs.org/google-closure-compiler-osx/-/google-closure-compiler-osx-20210601.0.0.tgz#e23356bc9ef6e68c2980f60a207f603767b50b21"
8454-
integrity sha512-A5r4s/WthR2iLMM0mxsluw8EW2AcOomC5ri/H6FjzpMq0RVEnLTgaGYdXolUAfEzH/7XtJJT2+JkYk3HSLCtrg==
8455-
8456-
google-closure-compiler-windows@^20210601.0.0:
8457-
version "20210601.0.0"
8458-
resolved "https://registry.npmjs.org/google-closure-compiler-windows/-/google-closure-compiler-windows-20210601.0.0.tgz#b5400d06bbf0bbd2602ee3ae0c2bc7ebd5829692"
8459-
integrity sha512-6r94bPShnB0XXh9+5/qXGDHJN2PQGhF9yJPcgBZj+FAZlQGzlYkT0pkyp+loZT3lG+YRbjD28Lgo7xMcY4xgkA==
8460-
8461-
google-closure-compiler@20210601.0.0:
8462-
version "20210601.0.0"
8463-
resolved "https://registry.npmjs.org/google-closure-compiler/-/google-closure-compiler-20210601.0.0.tgz#34597c33c9285ebd3a5364f5299f6c9ddc9fc88a"
8464-
integrity sha512-lzzEoG2VTB7uUjnWnMyeZMU163w69HJpM27yh8Up9Ha5McHZeESjt3NRwU8cWMbCRdY06nFbRCDIVCRcadHCiw==
8441+
google-closure-compiler-java@^20220301.0.0:
8442+
version "20220301.0.0"
8443+
resolved "https://registry.npmjs.org/google-closure-compiler-java/-/google-closure-compiler-java-20220301.0.0.tgz#6283bad6991ae9cfb3a9fdf72bbd7bf0c8f21fb6"
8444+
integrity sha512-kv5oaUI4xn3qWYWtRHRqbm314kesfeFlCxiFRcvBIx13mKfR0qvbOkgajLpSM6nb3voNM/E9MB9mfvHJ9XIXSg==
8445+
8446+
google-closure-compiler-linux@^20220301.0.0:
8447+
version "20220301.0.0"
8448+
resolved "https://registry.npmjs.org/google-closure-compiler-linux/-/google-closure-compiler-linux-20220301.0.0.tgz#3ac8cd1cb51d703a89bc49c239df4c10b57f37bb"
8449+
integrity sha512-N2D0SRnxZ7kqdoZ2WsmLIjmizR4Xr0HaUYDK2RCOtsV21RYV8OR2u0ATp7aXhYy8WfxvYH478Ehvmc9Uzy986A==
8450+
8451+
google-closure-compiler-osx@^20220301.0.0:
8452+
version "20220301.0.0"
8453+
resolved "https://registry.npmjs.org/google-closure-compiler-osx/-/google-closure-compiler-osx-20220301.0.0.tgz#1a49eb1d78b6bfb90ebe51c24a7151cee4f319a3"
8454+
integrity sha512-Xqf0m5takwfv43ML4aODJxmAsAZQMTMo683gyRs0APAecncs+YKxaDPMH+pQAdI3HPY2QsvkarlunAp0HSwU5A==
8455+
8456+
google-closure-compiler-windows@^20220301.0.0:
8457+
version "20220301.0.0"
8458+
resolved "https://registry.npmjs.org/google-closure-compiler-windows/-/google-closure-compiler-windows-20220301.0.0.tgz#b09df91a789e458eb9ebf054a9bb2d2b29622b6f"
8459+
integrity sha512-s+FU/vcpLTEgx8MCMgj0STCYkVk7syzF9KqiYPOTtbTD9ra99HPe/CEuQG7iJ3Fty9dhm9zEaetv4Dp4Wr6x+Q==
8460+
8461+
google-closure-compiler@20220301.0.0:
8462+
version "20220301.0.0"
8463+
resolved "https://registry.npmjs.org/google-closure-compiler/-/google-closure-compiler-20220301.0.0.tgz#1c4f56076ae5b2c900a91d0a72515f7ee7f5d3cd"
8464+
integrity sha512-+yAqhufKIWddg587tnvRll92eLJQIlzINmgr1h5gLXZVioY3svrSYKH4TZiUuNj0UnVFoK0o1YuW122x+iFl2g==
84658465
dependencies:
84668466
chalk "2.x"
8467-
google-closure-compiler-java "^20210601.0.0"
8467+
google-closure-compiler-java "^20220301.0.0"
84688468
minimist "1.x"
84698469
vinyl "2.x"
84708470
vinyl-sourcemaps-apply "^0.2.0"
84718471
optionalDependencies:
8472-
google-closure-compiler-linux "^20210601.0.0"
8473-
google-closure-compiler-osx "^20210601.0.0"
8474-
google-closure-compiler-windows "^20210601.0.0"
8475-
8476-
google-closure-library@20210406.0.0:
8477-
version "20210406.0.0"
8478-
resolved "https://registry.npmjs.org/google-closure-library/-/google-closure-library-20210406.0.0.tgz#47d6036c1704661ad47cde2e35f19cc55e33e775"
8479-
integrity sha512-1lAC/KC9R2QM6nygniM0pRcGrv5bkCUrIZb2hXFxLtAkA+zRiVeWtRYpFWDHXXJzkavKjsn9upiffL4x/nmmVg==
8472+
google-closure-compiler-linux "^20220301.0.0"
8473+
google-closure-compiler-osx "^20220301.0.0"
8474+
google-closure-compiler-windows "^20220301.0.0"
8475+
8476+
google-closure-library@20220301.0.0:
8477+
version "20220301.0.0"
8478+
resolved "https://registry.npmjs.org/google-closure-library/-/google-closure-library-20220301.0.0.tgz#c9aaa99218f949b1f914a86f2a4529dea20e2e47"
8479+
integrity sha512-GRRBfG80JPqkKkTxiRoVr/x4UmnPW2aeA72NH0zapPtrvSkAOCzfJFrdudLrAJJtXPdSE65+CkYrpZX8tP0mCQ==
84808480

84818481
google-gax@^2.24.1:
84828482
version "2.25.4"

0 commit comments

Comments
 (0)