-
Notifications
You must be signed in to change notification settings - Fork 246
fix(compass-web): adjust sandbox code for cloud backend and electron changes COMPASS-9569 #7128
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -118,12 +118,15 @@ | |
| * @returns {Promise<string[]>} | ||
| */ | ||
| async #getCloudSessionCookies() { | ||
| const cloudHostCookies = await session.defaultSession.cookies.get({ | ||
| domain: CLOUD_CONFIG_VARIANTS === 'local' ? 'localhost' : 'mongodb.com', | ||
| }); | ||
| return cloudHostCookies.map((cookie) => { | ||
| return `${cookie.name}=${cookie.value}`; | ||
| }); | ||
| const tld = CLOUD_CONFIG_VARIANTS === 'local' ? 'localhost' : 'mongodb.com'; | ||
| const cloudHostCookies = (await session.defaultSession.cookies.get({})) | ||
| .filter((cookie) => { | ||
| return cookie.domain?.endsWith(tld) ?? true; | ||
|
||
| }) | ||
| .map((cookie) => { | ||
| return `${cookie.name}=${cookie.value}`; | ||
| }); | ||
| return cloudHostCookies; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -135,18 +138,10 @@ | |
| } | ||
|
|
||
| async #fetch(path, init) { | ||
| let csrfHeaders; | ||
| if ( | ||
| init?.method && | ||
| /^(GET|HEAD|OPTIONS|TRACE)$/i.test(init.method) === false | ||
| ) { | ||
| csrfHeaders = await this.#getCSRFHeaders(); | ||
| } | ||
| return electronFetch(`${CLOUD_ORIGIN}${path}`, { | ||
| ...init, | ||
| headers: { | ||
| ...init?.headers, | ||
| ...csrfHeaders, | ||
| }, | ||
| }).then(handleRes); | ||
| } | ||
|
|
@@ -159,17 +154,6 @@ | |
| return new URL(url, 'http://localhost').pathname.startsWith('/v2/'); | ||
| } | ||
|
|
||
| async #getCSRFHeaders() { | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Drive-by, we moved this logic to the client some time ago and forgot to remove this |
||
| const projectId = await this.getProjectId(); | ||
| const { csrfToken, csrfTime } = await this.#fetch( | ||
| `/v2/${projectId}/params` | ||
| ); | ||
| return { | ||
| ...(csrfToken && { 'X-CSRF-Token': csrfToken }), | ||
| ...(csrfTime && { 'X-CSRF-Time': csrfTime }), | ||
| }; | ||
| } | ||
|
|
||
| async getCloudHeaders(hostSubdomain = '') { | ||
| const cookie = (await this.#getCloudSessionCookies()).join('; '); | ||
| return { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drive-by, was really noisy in webpack logs and we know it's okay to ignore