@@ -65,18 +65,40 @@ Index: sagemaker-code-editor/vscode/src/vs/code/browser/workbench/workbench.ts
6565 }
6666
6767 private startListening(): void {
68+ @@ -550,17 +551,6 @@ class WorkspaceProvider implements IWork
69+ }
70+ }
71+
72+ -function readCookie(name: string): string | undefined {
73+ - const cookies = document.cookie.split('; ');
74+ - for (const cookie of cookies) {
75+ - if (cookie.startsWith(name + '=')) {
76+ - return cookie.substring(name.length + 1);
77+ - }
78+ - }
79+ -
80+ - return undefined;
81+ -}
82+ -
83+ (function () {
84+
85+ // Find config by checking for DOM
86+ @@ -569,8 +559,8 @@ function readCookie(name: string): strin
87+ if (!configElement || !configElementAttribute) {
88+ throw new Error('Missing web configuration element');
89+ }
90+ - const config: IWorkbenchConstructionOptions & { folderUri?: UriComponents; workspaceUri?: UriComponents; callbackRoute: string } = JSON.parse(configElementAttribute);
91+ - const secretStorageKeyPath = readCookie('vscode-secret-key-path');
92+ + const config: IWorkbenchConstructionOptions & { folderUri?: UriComponents; workspaceUri?: UriComponents; callbackRoute: string } = { ...JSON.parse(configElementAttribute), remoteAuthority: location.host }
93+ + const secretStorageKeyPath = (window.location.pathname + "/mint-key").replace(/\/\/+/g, "/");
94+ const secretStorageCrypto = secretStorageKeyPath && ServerKeyedAESCrypto.supported()
95+ ? new ServerKeyedAESCrypto(secretStorageKeyPath) : new TransparentCrypto();
96+
97+
6898Index: sagemaker-code-editor/vscode/src/vs/platform/extensionResourceLoader/common/extensionResourceLoader.ts
6999===================================================================
70100--- sagemaker-code-editor.orig/vscode/src/vs/platform/extensionResourceLoader/common/extensionResourceLoader.ts
71101+++ sagemaker-code-editor/vscode/src/vs/platform/extensionResourceLoader/common/extensionResourceLoader.ts
72- @@ -16,7 +16,6 @@ import { getServiceMachineId } from 'vs/
73- import { IStorageService } from 'vs/platform/storage/common/storage';
74- import { TelemetryLevel } from 'vs/platform/telemetry/common/telemetry';
75- import { getTelemetryLevel, supportsTelemetry } from 'vs/platform/telemetry/common/telemetryUtils';
76- - import { RemoteAuthorities } from 'vs/base/common/network';
77- import { TargetPlatform } from 'vs/platform/extensions/common/extensions';
78-
79- const WEB_EXTENSION_RESOURCE_END_POINT_SEGMENT = '/web-extension-resource/';
80102@@ -99,7 +98,7 @@ export abstract class AbstractExtensionR
81103 : version,
82104 path: 'extension'
@@ -102,39 +124,29 @@ Index: sagemaker-code-editor/vscode/src/vs/server/node/webClientServer.ts
102124===================================================================
103125--- sagemaker-code-editor.orig/vscode/src/vs/server/node/webClientServer.ts
104126+++ sagemaker-code-editor/vscode/src/vs/server/node/webClientServer.ts
105- @@ -270,16 +270,15 @@ export class WebClientServer {
106- return void res.end();
107- }
108-
109- - const getFirstHeader = (headerName: string) => {
110- - const val = req.headers[headerName];
111- - return Array.isArray(val) ? val[0] : val;
112- - };
113- -
114- const useTestResolver = (!this._environmentService.isBuilt && this._environmentService.args['use-test-resolver']);
115- + // For now we are getting the remote authority from the client to avoid
116- + // needing specific configuration for reverse proxies to work. Set this to
117- + // something invalid to make sure we catch code that is using this value
118- + // from the backend when it should not.
127+ @@ -278,7 +278,7 @@ export class WebClientServer {
119128 const remoteAuthority = (
120129 useTestResolver
121130 ? 'test+test'
122131- : (getFirstHeader('x-original-host') || getFirstHeader('x-forwarded-host') || req.headers.host)
123- + : 'remote'
132+ + : (getFirstHeader('x-original-host') || getFirstHeader('x-forwarded-host') || req.headers.host || window.location.host)
124133 );
125134 if (!remoteAuthority) {
126135 return serveError(req, res, 400, `Bad request.`);
127- @@ -306,6 +305,9 @@ export class WebClientServer {
136+ @@ -305,7 +305,12 @@ export class WebClientServer {
128137 scopes: [['user:email'], ['repo']]
129138 } : undefined;
130-
131- + const base = relativeRoot(getOriginalUrl(req))
132- + const vscodeBase = relativePath(getOriginalUrl(req))
139+
140+ + const basePath: string = this._environmentService.args['server-base-path'] || "/"
141+ + const base = relativeRoot(basePath)
142+ + const vscodeBase = relativePath(basePath)
133143+
134144 const productConfiguration = {
145+ + rootEndpoint: base,
135146 embedderIdentifier: 'server-distro',
136147 extensionsGallery: this._webExtensionResourceUrlTemplate && this._productService.extensionsGallery ? {
137- @@ -342,8 +344,10 @@ export class WebClientServer {
148+ ...this._productService.extensionsGallery,
149+ @@ -340,8 +345,10 @@ export class WebClientServer {
138150 const values: { [key: string]: string } = {
139151 WORKBENCH_WEB_CONFIGURATION: asJSON(workbenchWebConfiguration),
140152 WORKBENCH_AUTH_SESSION: authSessionInfo ? asJSON(authSessionInfo) : '',
@@ -147,12 +159,11 @@ Index: sagemaker-code-editor/vscode/src/vs/server/node/webClientServer.ts
147159 };
148160
149161 if (useTestResolver) {
150- @@ -443,3 +447,60 @@ export class WebClientServer {
162+ @@ -443,3 +445,70 @@ export class WebClientServer {
151163 return void res.end(data);
152164 }
153165 }
154166+
155- +
156167+ /**
157168+ * Remove extra slashes in a URL.
158169+ *
@@ -208,6 +219,17 @@ Index: sagemaker-code-editor/vscode/src/vs/server/node/webClientServer.ts
208219+ const parts = originalUrl.split("?", 1)[0].split("/")
209220+ return normalizeUrlPath("./" + parts[parts.length - 1])
210221+ }
222+ +
223+ + /**
224+ + * code-server serves Code using Express. Express removes the base from the url
225+ + * and puts the original in `originalUrl` so we must use this to get the correct
226+ + * depth. Code is not aware it is behind Express so the types do not match. We
227+ + * may want to continue moving code into Code and eventually remove the Express
228+ + * wrapper or move the web server back into code-server.
229+ + */
230+ + export const getOriginalUrl = (req: http.IncomingMessage): string => {
231+ + return (req as any).originalUrl || req.url
232+ + }
211233Index: sagemaker-code-editor/vscode/src/vs/server/node/serverEnvironmentService.ts
212234===================================================================
213235--- sagemaker-code-editor.orig/vscode/src/vs/server/node/serverEnvironmentService.ts
0 commit comments