Skip to content
Merged
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
10 changes: 8 additions & 2 deletions src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ export interface IStore extends Iterable<IPublisher> {
delete(name: string): Promise<void>;
}

export interface IKeytar {
findCredentials(service: string): Promise<Array<{ account: string; password: string }>>;
setPassword(service: string, account: string, password: string): Promise<void>;
deletePassword(service: string, account: string): Promise<boolean>;
};

export class FileStore implements IStore {
private static readonly DefaultPath = path.join(homedir(), '.vsce');

Expand Down Expand Up @@ -75,7 +81,7 @@ export class FileStore implements IStore {

export class KeytarStore implements IStore {
static async open(serviceName = 'vscode-vsce'): Promise<KeytarStore> {
const keytar = await import('keytar');
const keytar = await import('keytar').then(module => module.default);
const creds = await keytar.findCredentials(serviceName);

return new KeytarStore(
Expand All @@ -90,7 +96,7 @@ export class KeytarStore implements IStore {
}

private constructor(
private readonly keytar: typeof import('keytar'),
private readonly keytar: IKeytar,
private readonly serviceName: string,
private publishers: IPublisher[]
) { }
Expand Down
Loading