Skip to content

fix(lib/vscode): remove native-keymap and keytar #2961

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ci/images/centos7/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ENV PATH=/usr/local/node-$NODE_VERSION/bin:$PATH
RUN npm install -g yarn

RUN yum groupinstall -y 'Development Tools'
RUN yum install -y python2 libsecret-devel libX11-devel libxkbfile-devel
RUN yum install -y python2

RUN npm config set python python2

Expand Down
5 changes: 1 addition & 4 deletions ci/images/debian10/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ RUN curl -fsSL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
apt-get update && apt-get install -y yarn

# Installs VS Code build deps.
RUN apt-get install -y build-essential \
libsecret-1-dev \
libx11-dev \
libxkbfile-dev
RUN apt-get install -y build-essential

# Installs envsubst.
RUN apt-get install -y gettext-base
Expand Down
9 changes: 3 additions & 6 deletions docs/npm.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ Related:
sudo apt-get install -y \
build-essential \
pkg-config \
libx11-dev \
libxkbfile-dev \
libsecret-1-dev \
python3
npm config set python python3
```
Expand All @@ -38,14 +35,14 @@ npm config set python python3
```bash
sudo yum groupinstall -y 'Development Tools'
sudo yum config-manager --set-enabled PowerTools # unnecessary on CentOS 7
sudo yum install -y python2 libsecret-devel libX11-devel libxkbfile-devel
sudo yum install -y python2
npm config set python python2
```

## Alpine

```bash
apk add alpine-sdk bash libstdc++ libc6-compat libx11-dev libxkbfile-dev libsecret-dev
apk add alpine-sdk bash libstdc++ libc6-compat
npm config set python python3
```

Expand All @@ -59,5 +56,5 @@ xcode-select --install

```sh
pkg install -y git python npm-node12 yarn-node12 pkgconf
pkg install -y libsecret libxkbfile libx11 libinotify
pkg install -y libinotify
```
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@

/// <reference path='../../../../src/vs/vscode.d.ts'/>
/// <reference path='../../../../src/vs/vscode.proposed.d.ts'/>
/// <reference path='../../../../src/typings/keytar.d.ts'/>

// NOTE@coder: add keytar typeref
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@

/// <reference path='../../../../src/vs/vscode.d.ts'/>
/// <reference path='../../../../src/vs/vscode.proposed.d.ts'/>
/// <reference path='../../../../src/typings/keytar.d.ts'/>

// NOTE@coder: add keytar typeref
3 changes: 0 additions & 3 deletions lib/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,8 @@
"https-proxy-agent": "^2.2.3",
"iconv-lite-umd": "0.6.8",
"jschardet": "2.2.1",
"keytar": "7.2.0",
"minimist": "^1.2.5",
"native-is-elevated": "0.4.1",
"native-keymap": "2.2.1",
"native-watchdog": "1.3.0",
"node-pty": "0.10.0-beta19",
"proxy-agent": "^4.0.0",
Expand Down Expand Up @@ -106,7 +104,6 @@
"@types/graceful-fs": "4.1.2",
"@types/gulp-postcss": "^8.0.0",
"@types/http-proxy-agent": "^2.0.1",
"@types/keytar": "^4.4.0",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note for review: @types/keytar is deprecated since keytar includes types - I removed both and added a typings file.

"@types/minimist": "^1.2.1",
"@types/mocha": "^8.2.0",
"@types/node": "^12.19.9",
Expand Down
58 changes: 58 additions & 0 deletions lib/vscode/src/typings/keytar.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Definitions by: Milan Burda <https://github.com/miniak>, Brendan Forster <https://github.com/shiftkey>, Hari Juturu <https://github.com/juturu>
// Adapted from DefinitelyTyped: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/keytar/index.d.ts

// NOTE@coder: copy in from keytar upstream and modify
// keytar pulls in libsecret-dev, which we want to avoid,
// and vscode has a 'fallback' for web use that redirects keytar calls to use localStorage.
// Keep types in here for it to compile correctly.

declare module 'keytar' {
/**
* Get the stored password for the service and account.
*
* @param service The string service name.
* @param account The string account name.
*
* @returns A promise for the password string.
*/
export function getPassword(service: string, account: string): Promise<string | null>;

/**
* Add the password for the service and account to the keychain.
*
* @param service The string service name.
* @param account The string account name.
* @param password The string password.
*
* @returns A promise for the set password completion.
*/
export function setPassword(service: string, account: string, password: string): Promise<void>;

/**
* Delete the stored password for the service and account.
*
* @param service The string service name.
* @param account The string account name.
*
* @returns A promise for the deletion status. True on success.
*/
export function deletePassword(service: string, account: string): Promise<boolean>;

/**
* Find a password for the service in the keychain.
*
* @param service The string service name.
*
* @returns A promise for the password string.
*/
export function findPassword(service: string): Promise<string | null>;

/**
* Find all accounts and passwords for `service` in the keychain.
*
* @param service The string service name.
*
* @returns A promise for the array of found credentials.
*/
export function findCredentials(service: string): Promise<Array<{ account: string, password: string}>>;
}
75 changes: 75 additions & 0 deletions lib/vscode/src/typings/native-keymap.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

// NOTE@coder: copy from native-keymap
// only used in electron-main, so we remove it to avoid pulling X11 in at build time.
// these types are required during compile, but functions are never used

declare module 'native-keymap' {
export interface IWindowsKeyMapping {
vkey: string;
value: string;
withShift: string;
withAltGr: string;
withShiftAltGr: string;
}
export interface IWindowsKeyboardMapping {
[code: string]: IWindowsKeyMapping;
}
export interface ILinuxKeyMapping {
value: string;
withShift: string;
withAltGr: string;
withShiftAltGr: string;
}
export interface ILinuxKeyboardMapping {
[code: string]: ILinuxKeyMapping;
}
export interface IMacKeyMapping {
value: string;
valueIsDeadKey: boolean;
withShift: string;
withShiftIsDeadKey: boolean;
withAltGr: string;
withAltGrIsDeadKey: boolean;
withShiftAltGr: string;
withShiftAltGrIsDeadKey: boolean;
}
export interface IMacKeyboardMapping {
[code: string]: IMacKeyMapping;
}

export type IKeyboardMapping = IWindowsKeyboardMapping | ILinuxKeyboardMapping | IMacKeyboardMapping;

export function getKeyMap(): IKeyboardMapping;

export interface IWindowsKeyboardLayoutInfo {
name: string;
id: string;
text: string;
}

export interface ILinuxKeyboardLayoutInfo {
model: string;
layout: string;
variant: string;
options: string;
rules: string;
}

export interface IMacKeyboardLayoutInfo {
id: string;
localizedName: string;
lang: string;
}

export type IKeyboardLayoutInfo = IWindowsKeyboardLayoutInfo | ILinuxKeyboardLayoutInfo | IMacKeyboardLayoutInfo;

export function getCurrentKeyboardLayout(): IKeyboardLayoutInfo;

export function onDidChangeKeyboardLayout(callback: () => void): void;

export function isISOKeyboard(): boolean | undefined;
}
Loading