-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
First move off of keytar #185077
Conversation
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
) { } | ||
|
||
async encrypt(value: string): Promise<string> { | ||
return JSON.stringify(safeStorage.encryptString(value)); |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
?
Since keytar is now deprecated, we need a solution going forward. That solution is the electron safeStorage API.
This PR:
This PR also refactors things quite a bit:

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:
After a while: