Demo usage of keytar. This is primarily to show the differences of credential management on macOS and Windows.
This uses the insider of VS Code that's build using electron 1.7.9. For a different electron version, update the extensions/.yarnrc
file. You can find the electron version VC Code uses in the About Dialog or you can open Developer Tools and eval process.versions
.
Note: If you use
npm
instead ofyarn
you need to explicitly specify what electron version the extensions need to be compiled against. You would compile them like:
cd extensions/keytar-getter
npm install --runtime=electron --target=1.7.9 --disturl=https://atom.io/download/electron
yarn run build
yarn run sample
The sample uses two node processes, one writing credentials and the other retrieving them.- If code-insiders is running, quit it.
yarn start
- Cmd+Shift+P >
Keytar 2: Retrieve Credential
An extension reads the credentials one of the node processes wrote in step 2. - Cmd+Shift+P >
Keytar 1: Store Credential
An extension overwrites the credentials the node process wrote in step 2. - Cmd+Shift+P >
Keytar 2: Retrieve Credential
An extension reads the credentials written by another extension in step 6.
The following steps use Git Bash.
- To compile native modules you need Python and a C++ toolchain. If you don't have one, use
yarn install --global --production windows-build-tools
to install it. yarn install
yarn run sample
cd extensions/keytar-getter
yarn install
cd ../keytar-putter
yarn install
cd ../..
yarn start
- Ctrl+Shift+P >
Keytar 2: Retrieve Credential
An extension reads the credentials one of the node processes wrote in step 3. - Ctrl+Shift+P >
Keytar 1: Store Credential
An extension overwrites the credentials the node process wrote in step 3. - Ctrl+Shift+P >
Keytar 2: Retrieve Credential
An extension reads the credentials written by another extension in step 11.