mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-20 02:08:47 +00:00
Remove web worker support from microsoft-authentication extension (#276762)
* Initial plan * Remove web worker support from microsoft-authentication extension - Remove browser entry point from package.json - Remove browser webpack configuration - Remove browser-specific scripts (compile-web, watch-web) - Remove src/browser/ directory with browser-specific implementations - Remove ExtensionHost.WebWorker enum value - Remove supportsWebWorkerExtensionHost flags from all flows - Simplify authProvider.ts by removing web worker detection logic - Remove web worker test case from flows.test.ts - Successfully compiled with 0 errors Co-authored-by: TylerLeonhardt <2644648+TylerLeonhardt@users.noreply.github.com> * couple references --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
d528178662
commit
a3fcd46091
@@ -3,7 +3,6 @@
|
||||
out/test/**
|
||||
out/**
|
||||
extension.webpack.config.js
|
||||
extension-browser.webpack.config.js
|
||||
package-lock.json
|
||||
src/**
|
||||
.gitignore
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
// @ts-check
|
||||
import path from 'path';
|
||||
import { browser as withBrowserDefaults } from '../shared.webpack.config.mjs';
|
||||
|
||||
export default withBrowserDefaults({
|
||||
context: import.meta.dirname,
|
||||
node: {
|
||||
global: true,
|
||||
__filename: false,
|
||||
__dirname: false,
|
||||
},
|
||||
entry: {
|
||||
extension: './src/extension.ts',
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
'./node/authServer': path.resolve(import.meta.dirname, 'src/browser/authServer'),
|
||||
'./node/buffer': path.resolve(import.meta.dirname, 'src/browser/buffer'),
|
||||
'./node/fetch': path.resolve(import.meta.dirname, 'src/browser/fetch'),
|
||||
'./node/authProvider': path.resolve(import.meta.dirname, 'src/browser/authProvider'),
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -129,13 +129,10 @@
|
||||
},
|
||||
"aiKey": "0c6ae279ed8443289764825290e4f9e2-1a736e7c-1324-4338-be46-fc2a58ae4d14-7255",
|
||||
"main": "./out/extension.js",
|
||||
"browser": "./dist/browser/extension.js",
|
||||
"scripts": {
|
||||
"vscode:prepublish": "npm run compile",
|
||||
"compile": "gulp compile-extension:microsoft-authentication",
|
||||
"compile-web": "npx webpack-cli --config extension-browser.webpack.config --mode none",
|
||||
"watch": "gulp watch-extension:microsoft-authentication",
|
||||
"watch-web": "npx webpack-cli --config extension-browser.webpack.config --mode none --watch --info-verbosity verbose"
|
||||
"watch": "gulp watch-extension:microsoft-authentication"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "22.x",
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { AuthenticationProvider, AuthenticationProviderAuthenticationSessionsChangeEvent, AuthenticationSession, EventEmitter } from 'vscode';
|
||||
|
||||
export class MsalAuthProvider implements AuthenticationProvider {
|
||||
private _onDidChangeSessions = new EventEmitter<AuthenticationProviderAuthenticationSessionsChangeEvent>();
|
||||
onDidChangeSessions = this._onDidChangeSessions.event;
|
||||
|
||||
initialize(): Thenable<void> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
getSessions(): Thenable<AuthenticationSession[]> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
createSession(): Thenable<AuthenticationSession> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
removeSession(): Thenable<void> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
dispose() {
|
||||
this._onDidChangeSessions.dispose();
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
export function startServer(_: any): any {
|
||||
throw new Error('Not implemented');
|
||||
}
|
||||
|
||||
export function createServer(_: any): any {
|
||||
throw new Error('Not implemented');
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
export function base64Encode(text: string): string {
|
||||
return btoa(text);
|
||||
}
|
||||
|
||||
export function base64Decode(text: string): string {
|
||||
// modification of https://stackoverflow.com/a/38552302
|
||||
const replacedCharacters = text.replace(/-/g, '+').replace(/_/g, '/');
|
||||
const decodedText = decodeURIComponent(atob(replacedCharacters).split('').map(function (c) {
|
||||
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
|
||||
}).join(''));
|
||||
return decodedText;
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
export default fetch;
|
||||
@@ -209,12 +209,9 @@ export class MsalAuthProvider implements AuthenticationProvider {
|
||||
}
|
||||
};
|
||||
|
||||
const isNodeEnvironment = typeof process !== 'undefined' && typeof process?.versions?.node === 'string';
|
||||
const callbackUri = await env.asExternalUri(Uri.parse(`${env.uriScheme}://vscode.microsoft-authentication`));
|
||||
const flows = getMsalFlows({
|
||||
extensionHost: isNodeEnvironment
|
||||
? this._context.extension.extensionKind === ExtensionKind.UI ? ExtensionHost.Local : ExtensionHost.Remote
|
||||
: ExtensionHost.WebWorker,
|
||||
extensionHost: this._context.extension.extensionKind === ExtensionKind.UI ? ExtensionHost.Local : ExtensionHost.Remote,
|
||||
supportedClient: isSupportedClient(callbackUri),
|
||||
isBrokerSupported: cachedPca.isBrokerAvailable
|
||||
});
|
||||
@@ -348,12 +345,9 @@ export class MsalAuthProvider implements AuthenticationProvider {
|
||||
}
|
||||
};
|
||||
|
||||
const isNodeEnvironment = typeof process !== 'undefined' && typeof process?.versions?.node === 'string';
|
||||
const callbackUri = await env.asExternalUri(Uri.parse(`${env.uriScheme}://vscode.microsoft-authentication`));
|
||||
const flows = getMsalFlows({
|
||||
extensionHost: isNodeEnvironment
|
||||
? this._context.extension.extensionKind === ExtensionKind.UI ? ExtensionHost.Local : ExtensionHost.Remote
|
||||
: ExtensionHost.WebWorker,
|
||||
extensionHost: this._context.extension.extensionKind === ExtensionKind.UI ? ExtensionHost.Local : ExtensionHost.Remote,
|
||||
isBrokerSupported: cachedPca.isBrokerAvailable,
|
||||
supportedClient: isSupportedClient(callbackUri)
|
||||
});
|
||||
|
||||
@@ -14,14 +14,12 @@ import { Config } from '../common/config';
|
||||
const DEFAULT_REDIRECT_URI = 'https://vscode.dev/redirect';
|
||||
|
||||
export const enum ExtensionHost {
|
||||
WebWorker,
|
||||
Remote,
|
||||
Local
|
||||
}
|
||||
|
||||
interface IMsalFlowOptions {
|
||||
supportsRemoteExtensionHost: boolean;
|
||||
supportsWebWorkerExtensionHost: boolean;
|
||||
supportsUnsupportedClient: boolean;
|
||||
supportsBroker: boolean;
|
||||
}
|
||||
@@ -48,7 +46,6 @@ class DefaultLoopbackFlow implements IMsalFlow {
|
||||
label = 'default';
|
||||
options: IMsalFlowOptions = {
|
||||
supportsRemoteExtensionHost: false,
|
||||
supportsWebWorkerExtensionHost: false,
|
||||
supportsUnsupportedClient: true,
|
||||
supportsBroker: true
|
||||
};
|
||||
@@ -78,7 +75,6 @@ class UrlHandlerFlow implements IMsalFlow {
|
||||
label = 'protocol handler';
|
||||
options: IMsalFlowOptions = {
|
||||
supportsRemoteExtensionHost: true,
|
||||
supportsWebWorkerExtensionHost: false,
|
||||
supportsUnsupportedClient: false,
|
||||
supportsBroker: false
|
||||
};
|
||||
@@ -108,7 +104,6 @@ class DeviceCodeFlow implements IMsalFlow {
|
||||
label = 'device code';
|
||||
options: IMsalFlowOptions = {
|
||||
supportsRemoteExtensionHost: true,
|
||||
supportsWebWorkerExtensionHost: false,
|
||||
supportsUnsupportedClient: true,
|
||||
supportsBroker: false
|
||||
};
|
||||
@@ -139,13 +134,8 @@ export function getMsalFlows(query: IMsalFlowQuery): IMsalFlow[] {
|
||||
const flows = [];
|
||||
for (const flow of allFlows) {
|
||||
let useFlow: boolean = true;
|
||||
switch (query.extensionHost) {
|
||||
case ExtensionHost.Remote:
|
||||
useFlow &&= flow.options.supportsRemoteExtensionHost;
|
||||
break;
|
||||
case ExtensionHost.WebWorker:
|
||||
useFlow &&= flow.options.supportsWebWorkerExtensionHost;
|
||||
break;
|
||||
if (query.extensionHost === ExtensionHost.Remote) {
|
||||
useFlow &&= flow.options.supportsRemoteExtensionHost;
|
||||
}
|
||||
useFlow &&= flow.options.supportsBroker || !query.isBrokerSupported;
|
||||
useFlow &&= flow.options.supportsUnsupportedClient || query.supportedClient;
|
||||
|
||||
@@ -43,16 +43,6 @@ suite('getMsalFlows', () => {
|
||||
assert.strictEqual(flows[1].label, 'device code');
|
||||
});
|
||||
|
||||
test('should return no flows for web worker extension host', () => {
|
||||
const query: IMsalFlowQuery = {
|
||||
extensionHost: ExtensionHost.WebWorker,
|
||||
supportedClient: true,
|
||||
isBrokerSupported: false
|
||||
};
|
||||
const flows = getMsalFlows(query);
|
||||
assert.strictEqual(flows.length, 0);
|
||||
});
|
||||
|
||||
test('should return only default and device code flows for local extension host with unsupported client and no broker', () => {
|
||||
const query: IMsalFlowQuery = {
|
||||
extensionHost: ExtensionHost.Local,
|
||||
|
||||
@@ -4,10 +4,7 @@
|
||||
"outDir": "./out",
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noUnusedLocals": false,
|
||||
"skipLibCheck": true,
|
||||
"lib": [
|
||||
"WebWorker"
|
||||
]
|
||||
"skipLibCheck": true
|
||||
},
|
||||
"include": [
|
||||
"src/**/*",
|
||||
|
||||
Reference in New Issue
Block a user