Move ADAL specific files to ADAL folder (#298)
This commit is contained in:
Родитель
1be4dcc354
Коммит
6c2d9b4d51
|
@ -16,7 +16,7 @@ import { v4 as uuid } from 'uuid';
|
|||
import { commands, env, EventEmitter, MessageItem, QuickPickItem, Terminal, Uri, window } from 'vscode';
|
||||
import * as nls from 'vscode-nls';
|
||||
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 { AccessTokens, connectTerminal, ConsoleUris, Errors, getUserSettings, provisionConsole, resetConsole, Size } from './cloudConsoleLauncher';
|
||||
import { createServer, Queue, readJSON } from './ipc';
|
||||
|
|
|
@ -15,9 +15,8 @@ import { AzureLoginError } from "../../errors";
|
|||
import { localize } from "../../utils/localize";
|
||||
import { timeout } from "../../utils/timeUtils";
|
||||
import { AbstractCredentials, AbstractCredentials2, AbstractLoginResult, AuthProviderBase } from "../AuthProviderBase";
|
||||
import { getCallbackEnvironment, parseQuery, UriEventHandler } from "../login";
|
||||
import { getUserCode, showDeviceCodeMessage } from "../loginWithDeviceCode";
|
||||
import { addTokenToCache, clearTokenCache, deleteRefreshToken, getTokenResponse, getTokensFromToken, getTokenWithAuthorizationCode, ProxyTokenCache, storeRefreshToken, tokenFromRefreshToken } from "../tokens";
|
||||
import { getCallbackEnvironment, getUserCode, parseQuery, showDeviceCodeMessage, UriEventHandler } from "./login";
|
||||
import { addTokenToCache, clearTokenCache, deleteRefreshToken, getTokenResponse, getTokensFromToken, getTokenWithAuthorizationCode, ProxyTokenCache, storeRefreshToken, tokenFromRefreshToken } from "./tokens";
|
||||
|
||||
const staticEnvironmentNames: string[] = [
|
||||
...staticEnvironments.map(environment => environment.name),
|
||||
|
|
|
@ -6,11 +6,46 @@
|
|||
import { Environment } from "@azure/ms-rest-azure-env";
|
||||
import { AuthenticationContext, MemoryCache } from "@azure/ms-rest-nodeauth/node_modules/adal-node";
|
||||
import { UserCodeInfo } from "adal-node";
|
||||
import { env, MessageItem, window } from "vscode";
|
||||
import { clientId } from "../constants";
|
||||
import { AzureLoginError } from "../errors";
|
||||
import { localize } from "../utils/localize";
|
||||
import { openUri } from "../utils/openUri";
|
||||
import { env, EventEmitter, MessageItem, Uri, UriHandler, window } from "vscode";
|
||||
import { clientId } from "../../constants";
|
||||
import { AzureLoginError } from "../../errors";
|
||||
import { localize } from "../../utils/localize";
|
||||
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> {
|
||||
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 { DeviceTokenCredentials as DeviceTokenCredentials2 } from '@azure/ms-rest-nodeauth';
|
||||
import { AuthenticationContext, MemoryCache, TokenResponse, UserCodeInfo } from "adal-node";
|
||||
import { clientId, commonTenantId, credentialsSection } from "../constants";
|
||||
import { AzureLoginError } from "../errors";
|
||||
import { listAll } from "../utils/arrayUtils";
|
||||
import { tryGetKeyTar } from "../utils/keytar";
|
||||
import { localize } from "../utils/localize";
|
||||
import { isADFS } from "./environments";
|
||||
import { clientId, commonTenantId, credentialsSection } from "../../constants";
|
||||
import { AzureLoginError } from "../../errors";
|
||||
import { listAll } from "../../utils/arrayUtils";
|
||||
import { tryGetKeyTar } from "../../utils/keytar";
|
||||
import { localize } from "../../utils/localize";
|
||||
import { isADFS } from "../environments";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-assignment
|
||||
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 '';
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче