diff --git a/extensions/vscode-account/package.json b/extensions/vscode-account/package.json index 35649821a85..1cc728195e9 100644 --- a/extensions/vscode-account/package.json +++ b/extensions/vscode-account/package.json @@ -17,14 +17,13 @@ "main": "./out/extension.js", "scripts": { "vscode:prepublish": "npm run compile", - "compile": "tsc -p ./", - "watch": "tsc -watch -p ./" + "compile": "gulp compile-extension:vscode-account", + "watch": "gulp watch-extension:vscode-account" }, "devDependencies": { "typescript": "^3.7.4", "tslint": "^5.12.1", "@types/node": "^10.12.21", - "@types/keytar": "^4.0.1", - "@types/vscode": "^1.41.0" + "@types/keytar": "^4.0.1" } } diff --git a/extensions/vscode-account/src/AADHelper.ts b/extensions/vscode-account/src/AADHelper.ts index 44605a504be..764db8bca9c 100644 --- a/extensions/vscode-account/src/AADHelper.ts +++ b/extensions/vscode-account/src/AADHelper.ts @@ -22,7 +22,7 @@ interface IToken { accessToken: string; refreshToken: string; - displayName: string; + accountName: string; scope: string; sessionId: string; // The account id + the scope } @@ -170,11 +170,11 @@ export class AzureActiveDirectoryService { }, 1000 * 30); } - private convertToSession(token: IToken): vscode.Session { + private convertToSession(token: IToken): vscode.AuthenticationSession { return { id: token.sessionId, accessToken: token.accessToken, - displayName: token.displayName, + accountName: token.accountName, scopes: token.scope.split(' ') }; } @@ -188,7 +188,7 @@ export class AzureActiveDirectoryService { } } - get sessions(): vscode.Session[] { + get sessions(): vscode.AuthenticationSession[] { return this._tokens.map(token => this.convertToSession(token)); } @@ -288,7 +288,7 @@ export class AzureActiveDirectoryService { }); vscode.env.openExternal(uri); - const timeoutPromise = new Promise((resolve: (value: IToken) => void, reject) => { + const timeoutPromise = new Promise((_: (value: IToken) => void, reject) => { const wait = setTimeout(() => { clearTimeout(wait); reject('Login timed out.'); @@ -362,7 +362,7 @@ export class AzureActiveDirectoryService { refreshToken: json.refresh_token, scope, sessionId: `${claims.tid}/${(claims.oid || (claims.altsecid || '' + claims.ipd || ''))}/${scope}`, - displayName: claims.email || claims.unique_name || 'user@example.com' + accountName: claims.email || claims.unique_name || 'user@example.com' }; } diff --git a/extensions/vscode-account/src/extension.ts b/extensions/vscode-account/src/extension.ts index 83988aa7c18..7d896b01d6a 100644 --- a/extensions/vscode-account/src/extension.ts +++ b/extensions/vscode-account/src/extension.ts @@ -6,7 +6,7 @@ import * as vscode from 'vscode'; import { AzureActiveDirectoryService, onDidChangeSessions } from './AADHelper'; -export async function activate(context: vscode.ExtensionContext) { +export async function activate(_: vscode.ExtensionContext) { const loginService = new AzureActiveDirectoryService(); diff --git a/extensions/vscode-account/src/keychain.ts b/extensions/vscode-account/src/keychain.ts index 28cd962a2ab..465a160fef7 100644 --- a/extensions/vscode-account/src/keychain.ts +++ b/extensions/vscode-account/src/keychain.ts @@ -7,6 +7,7 @@ // how we load it import * as keytarType from 'keytar'; import { env } from 'vscode'; +import Logger from './logger'; function getKeytar(): Keytar | undefined { try { @@ -44,22 +45,27 @@ export class Keychain { return await this.keytar.setPassword(SERVICE_ID, ACCOUNT_ID, token); } catch (e) { // Ignore + Logger.error(`Setting token failed: ${e}`); } } - async getToken() { + async getToken(): Promise { try { return await this.keytar.getPassword(SERVICE_ID, ACCOUNT_ID); } catch (e) { // Ignore + Logger.error(`Getting token failed: ${e}`); + return Promise.resolve(undefined); } } - async deleteToken() { + async deleteToken(): Promise { try { return await this.keytar.deletePassword(SERVICE_ID, ACCOUNT_ID); } catch (e) { // Ignore + Logger.error(`Deleting token failed: ${e}`); + return Promise.resolve(undefined); } } } diff --git a/extensions/vscode-account/src/typings/refs.d.ts b/extensions/vscode-account/src/typings/refs.d.ts new file mode 100644 index 00000000000..c9849d48e08 --- /dev/null +++ b/extensions/vscode-account/src/typings/refs.d.ts @@ -0,0 +1,7 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +/// +/// diff --git a/extensions/vscode-account/src/vscode.proposed.d.ts b/extensions/vscode-account/src/vscode.proposed.d.ts deleted file mode 100644 index d6ad851d3dd..00000000000 --- a/extensions/vscode-account/src/vscode.proposed.d.ts +++ /dev/null @@ -1,61 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -/** - * This is the place for API experiments and proposals. - * These API are NOT stable and subject to change. They are only available in the Insiders - * distribution and CANNOT be used in published extensions. - * - * To test these API in local environment: - * - Use Insiders release of VS Code. - * - Add `"enableProposedApi": true` to your package.json. - * - Copy this file to your project. - */ - -declare module 'vscode' { - - export interface Session { - id: string; - accessToken: string; - displayName: string; - scopes: string[] - } - - export interface AuthenticationProvider { - readonly id: string; - readonly displayName: string; - readonly onDidChangeSessions: Event; - - /** - * Returns an array of current sessions. - */ - getSessions(): Promise>; - - /** - * Prompts a user to login. - */ - login(scopes: string[]): Promise; - logout(sessionId: string): Promise; - } - - export namespace authentication { - export function registerAuthenticationProvider(provider: AuthenticationProvider): Disposable; - - /** - * Fires with the provider id that was registered or unregistered. - */ - export const onDidRegisterAuthenticationProvider: Event; - export const onDidUnregisterAuthenticationProvider: Event; - - export const providers: ReadonlyArray; - } - - // #region Ben - extension auth flow (desktop+web) - - export namespace env { - - export function asExternalUri(target: Uri): Thenable - } -} diff --git a/extensions/vscode-account/tsconfig.json b/extensions/vscode-account/tsconfig.json index 46be6dc9581..1225709307b 100644 --- a/extensions/vscode-account/tsconfig.json +++ b/extensions/vscode-account/tsconfig.json @@ -1,24 +1,13 @@ { + "extends": "../shared.tsconfig.json", "compilerOptions": { - "module": "commonjs", - "target": "es6", - "outDir": "out", - "lib": [ - "es6", - "es2016", - "dom" - ], + "outDir": "./out", + "experimentalDecorators": true, "typeRoots": [ - "node_modules/@types", - "src/typings" - ], - "sourceMap": true, - "rootDir": "src", - "strict": true, - "noImplicitAny": true + "./node_modules/@types" + ] }, - "exclude": [ - "node_modules", - ".vscode-test" + "include": [ + "src/**/*" ] }