Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable encodeInitMessageHeaders #6107

Merged
merged 7 commits into from Sep 7, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -15,14 +15,6 @@
* limitations under the License.
*/

import {
isBrowserExtension,
isElectron,
isIE,
isMobileCordova,
isReactNative,
isUWP
} from '@firebase/util';
import {
createWebChannelTransport,
ErrorCode,
Expand Down Expand Up @@ -215,26 +207,10 @@ export class WebChannelConnection extends RestConnection {
// https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#Simple_requests
//
// Therefore to avoid the CORS preflight request (an extra network
// roundtrip), we use the httpHeadersOverwriteParam option to specify that
// the headers should instead be encoded into a special "$httpHeaders" query
// parameter, which is recognized by the webchannel backend. This is
// formally defined here:
// https://github.com/google/closure-library/blob/b0e1815b13fb92a46d7c9b3c30de5d6a396a3245/closure/goog/net/rpc/httpcors.js#L32
//
// TODO(b/145624756): There is a backend bug where $httpHeaders isn't respected if the request
// doesn't have an Origin header. So we have to exclude a few browser environments that are
// known to (sometimes) not include an Origin. See
// https://github.com/firebase/firebase-js-sdk/issues/1491.
if (
!isMobileCordova() &&
!isReactNative() &&
!isElectron() &&
!isIE() &&
!isUWP() &&
!isBrowserExtension()
) {
request.httpHeadersOverwriteParam = '$httpHeaders';
}
// roundtrip), we use the encodeInitMessageHeaders option to specify that
// the headers should instead be encoded in the request's POST payload,
// which is recognized by the webchannel backend.
request.encodeInitMessageHeaders = true;

const url = urlParts.join('');
logDebug(LOG_TAG, 'Creating WebChannel: ' + url, request);
Expand Down
4 changes: 2 additions & 2 deletions packages/webchannel-wrapper/externs/overrides.js
Expand Up @@ -51,8 +51,8 @@ goog.net.WebChannel.Options.sendRawJson;
/** @type {string|undefined} */
goog.net.WebChannel.Options.httpSessionIdParam;

/** @type {string|undefined} */
goog.net.WebChannel.Options.httpHeadersOverwriteParam;
/** @type {boolean|undefined} */
goog.net.WebChannel.Options.encodeInitMessageHeaders;

/** @type {boolean|undefined} */
goog.net.WebChannel.Options.fastHandshake;
Expand Down
8 changes: 4 additions & 4 deletions packages/webchannel-wrapper/package.json
Expand Up @@ -25,12 +25,12 @@
},
"license": "Apache-2.0",
"devDependencies": {
"google-closure-compiler": "20210601.0.0",
"google-closure-library": "20210406.0.0",
"@rollup/plugin-commonjs": "21.0.0",
"google-closure-compiler": "20220301.0.0",
"google-closure-library": "20220301.0.0",
"gulp": "4.0.2",
"gulp-sourcemaps": "3.0.0",
"rollup": "2.57.0",
"@rollup/plugin-commonjs": "21.0.0",
"rollup-plugin-sourcemaps": "0.6.3",
"rollup-plugin-typescript2": "0.30.0",
"typescript": "4.2.2"
Expand All @@ -44,4 +44,4 @@
"bugs": {
"url": "https://github.com/firebase/firebase-js-sdk/issues"
}
}
}
2 changes: 1 addition & 1 deletion packages/webchannel-wrapper/src/index.d.ts
Expand Up @@ -96,7 +96,7 @@ export interface WebChannelOptions {
supportsCrossDomainXhr?: boolean;
sendRawJson?: boolean;
httpSessionIdParam?: string;
httpHeadersOverwriteParam?: string;
encodeInitMessageHeaders?: boolean;
forceLongPolling?: boolean;
detectBufferingProxy?: boolean;
fastHandshake?: boolean;
Expand Down
66 changes: 33 additions & 33 deletions yarn.lock
Expand Up @@ -8438,45 +8438,45 @@ google-auth-library@^7.0.0, google-auth-library@^7.6.1:
jws "^4.0.0"
lru-cache "^6.0.0"

google-closure-compiler-java@^20210601.0.0:
version "20210601.0.0"
resolved "https://registry.npmjs.org/google-closure-compiler-java/-/google-closure-compiler-java-20210601.0.0.tgz#88dc11b334bee6a704d9674c5143fd2e0d553517"
integrity sha512-bH6nIwOmp4qDWvlbXx5/DE3XA2aDGQoCpmRYZJGONY1Sy6Xfbq0ioXRHH9eBDP9hxhCJ5Sd/K89A0NZ8Nz9RJA==

google-closure-compiler-linux@^20210601.0.0:
version "20210601.0.0"
resolved "https://registry.npmjs.org/google-closure-compiler-linux/-/google-closure-compiler-linux-20210601.0.0.tgz#6e5dd7b00b96dc1fd1ba30e3401af85558768322"
integrity sha512-rnEQt7zz/1P1SfPhJiHQpfCgMPrsVVyEgDs09h67xn6+LXa9L0RP+hrJDEHqSWwjDPz0BkfUUv6zkqZvp1h/lw==

google-closure-compiler-osx@^20210601.0.0:
version "20210601.0.0"
resolved "https://registry.npmjs.org/google-closure-compiler-osx/-/google-closure-compiler-osx-20210601.0.0.tgz#e23356bc9ef6e68c2980f60a207f603767b50b21"
integrity sha512-A5r4s/WthR2iLMM0mxsluw8EW2AcOomC5ri/H6FjzpMq0RVEnLTgaGYdXolUAfEzH/7XtJJT2+JkYk3HSLCtrg==

google-closure-compiler-windows@^20210601.0.0:
version "20210601.0.0"
resolved "https://registry.npmjs.org/google-closure-compiler-windows/-/google-closure-compiler-windows-20210601.0.0.tgz#b5400d06bbf0bbd2602ee3ae0c2bc7ebd5829692"
integrity sha512-6r94bPShnB0XXh9+5/qXGDHJN2PQGhF9yJPcgBZj+FAZlQGzlYkT0pkyp+loZT3lG+YRbjD28Lgo7xMcY4xgkA==

google-closure-compiler@20210601.0.0:
version "20210601.0.0"
resolved "https://registry.npmjs.org/google-closure-compiler/-/google-closure-compiler-20210601.0.0.tgz#34597c33c9285ebd3a5364f5299f6c9ddc9fc88a"
integrity sha512-lzzEoG2VTB7uUjnWnMyeZMU163w69HJpM27yh8Up9Ha5McHZeESjt3NRwU8cWMbCRdY06nFbRCDIVCRcadHCiw==
google-closure-compiler-java@^20220301.0.0:
version "20220301.0.0"
resolved "https://registry.npmjs.org/google-closure-compiler-java/-/google-closure-compiler-java-20220301.0.0.tgz#6283bad6991ae9cfb3a9fdf72bbd7bf0c8f21fb6"
integrity sha512-kv5oaUI4xn3qWYWtRHRqbm314kesfeFlCxiFRcvBIx13mKfR0qvbOkgajLpSM6nb3voNM/E9MB9mfvHJ9XIXSg==

google-closure-compiler-linux@^20220301.0.0:
version "20220301.0.0"
resolved "https://registry.npmjs.org/google-closure-compiler-linux/-/google-closure-compiler-linux-20220301.0.0.tgz#3ac8cd1cb51d703a89bc49c239df4c10b57f37bb"
integrity sha512-N2D0SRnxZ7kqdoZ2WsmLIjmizR4Xr0HaUYDK2RCOtsV21RYV8OR2u0ATp7aXhYy8WfxvYH478Ehvmc9Uzy986A==

google-closure-compiler-osx@^20220301.0.0:
version "20220301.0.0"
resolved "https://registry.npmjs.org/google-closure-compiler-osx/-/google-closure-compiler-osx-20220301.0.0.tgz#1a49eb1d78b6bfb90ebe51c24a7151cee4f319a3"
integrity sha512-Xqf0m5takwfv43ML4aODJxmAsAZQMTMo683gyRs0APAecncs+YKxaDPMH+pQAdI3HPY2QsvkarlunAp0HSwU5A==

google-closure-compiler-windows@^20220301.0.0:
version "20220301.0.0"
resolved "https://registry.npmjs.org/google-closure-compiler-windows/-/google-closure-compiler-windows-20220301.0.0.tgz#b09df91a789e458eb9ebf054a9bb2d2b29622b6f"
integrity sha512-s+FU/vcpLTEgx8MCMgj0STCYkVk7syzF9KqiYPOTtbTD9ra99HPe/CEuQG7iJ3Fty9dhm9zEaetv4Dp4Wr6x+Q==

google-closure-compiler@20220301.0.0:
version "20220301.0.0"
resolved "https://registry.npmjs.org/google-closure-compiler/-/google-closure-compiler-20220301.0.0.tgz#1c4f56076ae5b2c900a91d0a72515f7ee7f5d3cd"
integrity sha512-+yAqhufKIWddg587tnvRll92eLJQIlzINmgr1h5gLXZVioY3svrSYKH4TZiUuNj0UnVFoK0o1YuW122x+iFl2g==
dependencies:
chalk "2.x"
google-closure-compiler-java "^20210601.0.0"
google-closure-compiler-java "^20220301.0.0"
minimist "1.x"
vinyl "2.x"
vinyl-sourcemaps-apply "^0.2.0"
optionalDependencies:
google-closure-compiler-linux "^20210601.0.0"
google-closure-compiler-osx "^20210601.0.0"
google-closure-compiler-windows "^20210601.0.0"

google-closure-library@20210406.0.0:
version "20210406.0.0"
resolved "https://registry.npmjs.org/google-closure-library/-/google-closure-library-20210406.0.0.tgz#47d6036c1704661ad47cde2e35f19cc55e33e775"
integrity sha512-1lAC/KC9R2QM6nygniM0pRcGrv5bkCUrIZb2hXFxLtAkA+zRiVeWtRYpFWDHXXJzkavKjsn9upiffL4x/nmmVg==
google-closure-compiler-linux "^20220301.0.0"
google-closure-compiler-osx "^20220301.0.0"
google-closure-compiler-windows "^20220301.0.0"

google-closure-library@20220301.0.0:
version "20220301.0.0"
resolved "https://registry.npmjs.org/google-closure-library/-/google-closure-library-20220301.0.0.tgz#c9aaa99218f949b1f914a86f2a4529dea20e2e47"
integrity sha512-GRRBfG80JPqkKkTxiRoVr/x4UmnPW2aeA72NH0zapPtrvSkAOCzfJFrdudLrAJJtXPdSE65+CkYrpZX8tP0mCQ==

google-gax@^2.24.1:
version "2.25.4"
Expand Down