-
Notifications
You must be signed in to change notification settings - Fork 28k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix layer breaker with credentials service, #74997
- Loading branch information
Showing
4 changed files
with
74 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; | ||
|
||
export const ICredentialsService = createDecorator<ICredentialsService>('ICredentialsService'); | ||
|
||
export interface ICredentialsService { | ||
_serviceBrand: any; | ||
getPassword(service: string, account: string): Promise<string | null>; | ||
setPassword(service: string, account: string, password: string): Promise<void>; | ||
deletePassword(service: string, account: string): Promise<boolean>; | ||
findPassword(service: string): Promise<string | null>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { ICredentialsService } from 'vs/platform/credentials/common/credentials'; | ||
import { IdleValue } from 'vs/base/common/async'; | ||
|
||
type KeytarModule = { | ||
getPassword(service: string, account: string): Promise<string | null>; | ||
setPassword(service: string, account: string, password: string): Promise<void>; | ||
deletePassword(service: string, account: string): Promise<boolean>; | ||
findPassword(service: string): Promise<string | null>; | ||
}; | ||
|
||
export class KeytarCredentialsService implements ICredentialsService { | ||
|
||
_serviceBrand: any; | ||
|
||
private readonly _keytar = new IdleValue<Promise<KeytarModule>>(() => import('keytar')); | ||
|
||
async getPassword(service: string, account: string): Promise<string | null> { | ||
const keytar = await this._keytar.getValue(); | ||
return keytar.getPassword(service, account); | ||
} | ||
|
||
async setPassword(service: string, account: string, password: string): Promise<void> { | ||
const keytar = await this._keytar.getValue(); | ||
return keytar.setPassword(service, account, password); | ||
} | ||
|
||
async deletePassword(service: string, account: string): Promise<boolean> { | ||
const keytar = await this._keytar.getValue(); | ||
return keytar.deletePassword(service, account); | ||
} | ||
|
||
async findPassword(service: string): Promise<string | null> { | ||
const keytar = await this._keytar.getValue(); | ||
return keytar.findPassword(service); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters