Move ADAL specific files to ADAL folder (#298)

This commit is contained in:
Will Lorey 2021-07-28 09:52:49 -07:00 коммит произвёл GitHub
Родитель 1be4dcc354
Коммит 6c2d9b4d51
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
5 изменённых файлов: 49 добавлений и 56 удалений

Просмотреть файл

@ -16,7 +16,7 @@ import { v4 as uuid } from 'uuid';
import { commands, env, EventEmitter, MessageItem, QuickPickItem, Terminal, Uri, window } from 'vscode'; import { commands, env, EventEmitter, MessageItem, QuickPickItem, Terminal, Uri, window } from 'vscode';
import * as nls from 'vscode-nls'; import * as nls from 'vscode-nls';
import { AzureAccount, AzureLoginStatus, AzureSession, CloudShell, CloudShellStatus, UploadOptions } from '../azure-account.api'; import { AzureAccount, AzureLoginStatus, AzureSession, CloudShell, CloudShellStatus, UploadOptions } from '../azure-account.api';
import { tokenFromRefreshToken } from '../login/tokens'; import { tokenFromRefreshToken } from '../login/adal/tokens';
import { TelemetryReporter } from '../telemetry'; import { TelemetryReporter } from '../telemetry';
import { AccessTokens, connectTerminal, ConsoleUris, Errors, getUserSettings, provisionConsole, resetConsole, Size } from './cloudConsoleLauncher'; import { AccessTokens, connectTerminal, ConsoleUris, Errors, getUserSettings, provisionConsole, resetConsole, Size } from './cloudConsoleLauncher';
import { createServer, Queue, readJSON } from './ipc'; import { createServer, Queue, readJSON } from './ipc';

Просмотреть файл

@ -15,9 +15,8 @@ import { AzureLoginError } from "../../errors";
import { localize } from "../../utils/localize"; import { localize } from "../../utils/localize";
import { timeout } from "../../utils/timeUtils"; import { timeout } from "../../utils/timeUtils";
import { AbstractCredentials, AbstractCredentials2, AbstractLoginResult, AuthProviderBase } from "../AuthProviderBase"; import { AbstractCredentials, AbstractCredentials2, AbstractLoginResult, AuthProviderBase } from "../AuthProviderBase";
import { getCallbackEnvironment, parseQuery, UriEventHandler } from "../login"; import { getCallbackEnvironment, getUserCode, parseQuery, showDeviceCodeMessage, UriEventHandler } from "./login";
import { getUserCode, showDeviceCodeMessage } from "../loginWithDeviceCode"; import { addTokenToCache, clearTokenCache, deleteRefreshToken, getTokenResponse, getTokensFromToken, getTokenWithAuthorizationCode, ProxyTokenCache, storeRefreshToken, tokenFromRefreshToken } from "./tokens";
import { addTokenToCache, clearTokenCache, deleteRefreshToken, getTokenResponse, getTokensFromToken, getTokenWithAuthorizationCode, ProxyTokenCache, storeRefreshToken, tokenFromRefreshToken } from "../tokens";
const staticEnvironmentNames: string[] = [ const staticEnvironmentNames: string[] = [
...staticEnvironments.map(environment => environment.name), ...staticEnvironments.map(environment => environment.name),

Просмотреть файл

@ -6,11 +6,46 @@
import { Environment } from "@azure/ms-rest-azure-env"; import { Environment } from "@azure/ms-rest-azure-env";
import { AuthenticationContext, MemoryCache } from "@azure/ms-rest-nodeauth/node_modules/adal-node"; import { AuthenticationContext, MemoryCache } from "@azure/ms-rest-nodeauth/node_modules/adal-node";
import { UserCodeInfo } from "adal-node"; import { UserCodeInfo } from "adal-node";
import { env, MessageItem, window } from "vscode"; import { env, EventEmitter, MessageItem, Uri, UriHandler, window } from "vscode";
import { clientId } from "../constants"; import { clientId } from "../../constants";
import { AzureLoginError } from "../errors"; import { AzureLoginError } from "../../errors";
import { localize } from "../utils/localize"; import { localize } from "../../utils/localize";
import { openUri } from "../utils/openUri"; import { openUri } from "../../utils/openUri";
export class UriEventHandler extends EventEmitter<Uri> implements UriHandler {
public handleUri(uri: Uri): void {
this.fire(uri);
}
}
/* eslint-disable @typescript-eslint/no-unsafe-return, @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access */
export function parseQuery(uri: Uri): any {
return uri.query.split('&').reduce((prev: any, current) => {
const queryString: string[] = current.split('=');
prev[queryString[0]] = queryString[1];
return prev;
}, {});
}
/* eslint-enable @typescript-eslint/no-unsafe-return, @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access */
export function getCallbackEnvironment(callbackUri: Uri): string {
if (callbackUri.authority.endsWith('.workspaces.github.com') || callbackUri.authority.endsWith('.github.dev')) {
return `${callbackUri.authority},`;
}
switch (callbackUri.authority) {
case 'online.visualstudio.com':
return 'vso,';
case 'online-ppe.core.vsengsaas.visualstudio.com':
return 'vsoppe,';
case 'online.dev.core.vsengsaas.visualstudio.com':
return 'vsodev,';
case 'canary.online.visualstudio.com':
return 'vsocanary,';
default:
return '';
}
}
export async function showDeviceCodeMessage(userCode: UserCodeInfo): Promise<void> { export async function showDeviceCodeMessage(userCode: UserCodeInfo): Promise<void> {
const copyAndOpen: MessageItem = { title: localize('azure-account.copyAndOpen', "Copy & Open") }; const copyAndOpen: MessageItem = { title: localize('azure-account.copyAndOpen', "Copy & Open") };

Просмотреть файл

@ -7,12 +7,12 @@ import { SubscriptionClient, SubscriptionModels } from "@azure/arm-subscriptions
import { Environment } from "@azure/ms-rest-azure-env"; import { Environment } from "@azure/ms-rest-azure-env";
import { DeviceTokenCredentials as DeviceTokenCredentials2 } from '@azure/ms-rest-nodeauth'; import { DeviceTokenCredentials as DeviceTokenCredentials2 } from '@azure/ms-rest-nodeauth';
import { AuthenticationContext, MemoryCache, TokenResponse, UserCodeInfo } from "adal-node"; import { AuthenticationContext, MemoryCache, TokenResponse, UserCodeInfo } from "adal-node";
import { clientId, commonTenantId, credentialsSection } from "../constants"; import { clientId, commonTenantId, credentialsSection } from "../../constants";
import { AzureLoginError } from "../errors"; import { AzureLoginError } from "../../errors";
import { listAll } from "../utils/arrayUtils"; import { listAll } from "../../utils/arrayUtils";
import { tryGetKeyTar } from "../utils/keytar"; import { tryGetKeyTar } from "../../utils/keytar";
import { localize } from "../utils/localize"; import { localize } from "../../utils/localize";
import { isADFS } from "./environments"; import { isADFS } from "../environments";
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-assignment // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-assignment
const CacheDriver = require('adal-node/lib/cache-driver'); const CacheDriver = require('adal-node/lib/cache-driver');

Просмотреть файл

@ -1,41 +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 * as vscode from 'vscode';
export class UriEventHandler extends vscode.EventEmitter<vscode.Uri> implements vscode.UriHandler {
public handleUri(uri: vscode.Uri): void {
this.fire(uri);
}
}
/* eslint-disable @typescript-eslint/no-unsafe-return, @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access */
export function parseQuery(uri: vscode.Uri): any {
return uri.query.split('&').reduce((prev: any, current) => {
const queryString: string[] = current.split('=');
prev[queryString[0]] = queryString[1];
return prev;
}, {});
}
/* eslint-enable @typescript-eslint/no-unsafe-return, @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access */
export function getCallbackEnvironment(callbackUri: vscode.Uri): string {
if (callbackUri.authority.endsWith('.workspaces.github.com') || callbackUri.authority.endsWith('.github.dev')) {
return `${callbackUri.authority},`;
}
switch (callbackUri.authority) {
case 'online.visualstudio.com':
return 'vso,';
case 'online-ppe.core.vsengsaas.visualstudio.com':
return 'vsoppe,';
case 'online.dev.core.vsengsaas.visualstudio.com':
return 'vsodev,';
case 'canary.online.visualstudio.com':
return 'vsocanary,';
default:
return '';
}
}