Skip to content

Commit dba30a4

Browse files
committed
fix(compass-web): adjust sandbox code to account for backend changes
1 parent 36985b8 commit dba30a4

File tree

2 files changed

+12
-25
lines changed

2 files changed

+12
-25
lines changed

configs/webpack-config-compass/src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ const sharedIgnoreWarnings: NonNullable<Configuration['ignoreWarnings']> = [
4545
/the request of a dependency is an expression/,
4646
// Optional, platform-specific dependencies (mostly from driver)
4747
/Module not found.+?(mongo_crypt_v1.(dll|so|dylib)|@mongodb-js\/zstd|aws-crt|gcp-metadata)/,
48+
// Optional, comes from emotion trying to (safely) use react apis that we
49+
// don't have in React 17
50+
/export 'useInsertionEffect'/,
4851
];
4952

5053
const sharedResolveOptions = (

packages/compass-web/scripts/electron-proxy.js

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,15 @@ class AtlasCloudAuthenticator {
118118
* @returns {Promise<string[]>}
119119
*/
120120
async #getCloudSessionCookies() {
121-
const cloudHostCookies = await session.defaultSession.cookies.get({
122-
domain: CLOUD_CONFIG_VARIANTS === 'local' ? 'localhost' : 'mongodb.com',
123-
});
124-
return cloudHostCookies.map((cookie) => {
125-
return `${cookie.name}=${cookie.value}`;
126-
});
121+
const tld = CLOUD_CONFIG_VARIANTS === 'local' ? 'localhost' : 'mongodb.com';
122+
const cloudHostCookies = (await session.defaultSession.cookies.get({}))
123+
.filter((cookie) => {
124+
return cookie.domain?.endsWith(tld) ?? true;
125+
})
126+
.map((cookie) => {
127+
return `${cookie.name}=${cookie.value}`;
128+
});
129+
return cloudHostCookies;
127130
}
128131

129132
/**
@@ -135,18 +138,10 @@ class AtlasCloudAuthenticator {
135138
}
136139

137140
async #fetch(path, init) {
138-
let csrfHeaders;
139-
if (
140-
init?.method &&
141-
/^(GET|HEAD|OPTIONS|TRACE)$/i.test(init.method) === false
142-
) {
143-
csrfHeaders = await this.#getCSRFHeaders();
144-
}
145141
return electronFetch(`${CLOUD_ORIGIN}${path}`, {
146142
...init,
147143
headers: {
148144
...init?.headers,
149-
...csrfHeaders,
150145
},
151146
}).then(handleRes);
152147
}
@@ -159,17 +154,6 @@ class AtlasCloudAuthenticator {
159154
return new URL(url, 'http://localhost').pathname.startsWith('/v2/');
160155
}
161156

162-
async #getCSRFHeaders() {
163-
const projectId = await this.getProjectId();
164-
const { csrfToken, csrfTime } = await this.#fetch(
165-
`/v2/${projectId}/params`
166-
);
167-
return {
168-
...(csrfToken && { 'X-CSRF-Token': csrfToken }),
169-
...(csrfTime && { 'X-CSRF-Time': csrfTime }),
170-
};
171-
}
172-
173157
async getCloudHeaders(hostSubdomain = '') {
174158
const cookie = (await this.#getCloudSessionCookies()).join('; ');
175159
return {

0 commit comments

Comments
 (0)