Skip to content
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

First move off of keytar #185077

Merged
merged 3 commits into from
Jun 14, 2023
Merged

First move off of keytar #185077

merged 3 commits into from
Jun 14, 2023

Conversation

TylerLeonhardt
Copy link
Member

@TylerLeonhardt TylerLeonhardt commented Jun 14, 2023

Since keytar is now deprecated, we need a solution going forward. That solution is the electron safeStorage API.

This PR:

  • Uses the Electron safeStorage API for encryption on desktop
  • Since we have encrypted strings we then store them where ever and in this case it's in the StorageService (at the application & machine level)

This PR also refactors things quite a bit:
encryptionandcredservices

typo: in the new diagram, the credential service is the secret storage service

Additionally, this PR gives embedders the ability to override the behavior of the secret storage similar to the existing Credential Provider embedder API... only with a better API shape since we no longer need to conform to keytar's shape.

At this time, the only scenario that is affected by this change is the Desktop. vscode.dev is unaffected because it passes in a CredentialProvider which uses the old MainThreadSecretState.

More will come after this PR such as:

  • Converting all CredentialService usages to SecretStorageService usages
  • Using a SecretStorageProvider instead of a CredentialProvider in vscode.dev & github.dev

After a while:

  • Removing MainThreadKeytar
  • Removing all the old code marked in this PR

Since keytar is now deprecated, we need a solution going forward. That solution is the electron safeStorage API.

This PR:
* Uses the Electron safeStorage API for encryption
* Since we have encrypted strings we then store them in the StorageService (at the application & machine level)

This PR also refactors things quite a bit... a diagram of the change is going to be in the PR.

It gives embedders the ability to override the behavior of the secret storage similar to the existing Credential Provider embedder API... only with a better API surface since we no longer need to conform to keytar's shape.

More will come after this PR such as:
* Converting all CredentialService usages to SecretStorageService usages

After a while:

* Removing MainThreadKeytar
* Removing all the old code marked in this PR
@TylerLeonhardt TylerLeonhardt enabled auto-merge (squash) June 14, 2023 03:38
@TylerLeonhardt TylerLeonhardt self-assigned this Jun 14, 2023
@vscodenpa vscodenpa added this to the June 2023 milestone Jun 14, 2023
@bpasero bpasero self-requested a review June 14, 2023 18:07
@TylerLeonhardt TylerLeonhardt merged commit b07469d into main Jun 14, 2023
@TylerLeonhardt TylerLeonhardt deleted the tyler/passive-buzzard branch June 14, 2023 18:09
) { }

async encrypt(value: string): Promise<string> {
return JSON.stringify(safeStorage.encryptString(value));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Curious, what is the purpose of converting the encrypted data to JSON string in the new API ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh I just wanted to have it return a string and went with JSON.stringify as the way to do that.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Given you are using Buffer api to convert back in decrypt, why not Buffer::toString ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants