diff --git a/extensions/github-authentication/src/githubServer.ts b/extensions/github-authentication/src/githubServer.ts index a9f94ccf65d..a2ddbdc548f 100644 --- a/extensions/github-authentication/src/githubServer.ts +++ b/extensions/github-authentication/src/githubServer.ts @@ -114,11 +114,12 @@ export class GitHubServer implements IGitHubServer { const supportedClient = isSupportedClient(callbackUri); const supportedTarget = isSupportedTarget(this._type, this._ghesUri); + const isNodeEnvironment = typeof process !== 'undefined' && typeof process?.versions?.node === 'string'; const flows = getFlows({ target: this._type === AuthProviderType.github ? GitHubTarget.DotCom : supportedTarget ? GitHubTarget.HostedEnterprise : GitHubTarget.Enterprise, - extensionHost: typeof navigator === 'undefined' + extensionHost: isNodeEnvironment ? this._extensionKind === vscode.ExtensionKind.UI ? ExtensionHost.Local : ExtensionHost.Remote : ExtensionHost.WebWorker, isSupportedClient: supportedClient diff --git a/extensions/microsoft-authentication/src/extension.ts b/extensions/microsoft-authentication/src/extension.ts index 6a5fac9765d..487f76c2cdc 100644 --- a/extensions/microsoft-authentication/src/extension.ts +++ b/extensions/microsoft-authentication/src/extension.ts @@ -71,8 +71,9 @@ export async function activate(context: ExtensionContext) { commands.executeCommand('workbench.action.reloadWindow'); } })); + const isNodeEnvironment = typeof process !== 'undefined' && typeof process?.versions?.node === 'string'; // Only activate the new extension if we are not running in a browser environment - if (useMsal && typeof navigator === 'undefined') { + if (useMsal && isNodeEnvironment) { await extensionV2.activate(context, mainTelemetryReporter); } else { mainTelemetryReporter.sendActivatedWithClassicImplementationEvent(); diff --git a/extensions/microsoft-authentication/src/node/authProvider.ts b/extensions/microsoft-authentication/src/node/authProvider.ts index 5ce9acd3e6a..4e72ce92b54 100644 --- a/extensions/microsoft-authentication/src/node/authProvider.ts +++ b/extensions/microsoft-authentication/src/node/authProvider.ts @@ -210,8 +210,9 @@ export class MsalAuthProvider implements AuthenticationProvider { } }; + const isNodeEnvironment = typeof process !== 'undefined' && typeof process?.versions?.node === 'string'; const flows = getMsalFlows({ - extensionHost: typeof navigator === 'undefined' + extensionHost: isNodeEnvironment ? this._context.extension.extensionKind === ExtensionKind.UI ? ExtensionHost.Local : ExtensionHost.Remote : ExtensionHost.WebWorker, });