File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import type { SecretStorage } from "vscode" ;
21import { SquareCloudAPI } from "@squarecloud/api" ;
32
4- import { Config , ExtensionID } from "../constants" ;
53import { ApiKeyStore } from "./store" ;
64
75export class ApiKey {
86 private readonly store = new ApiKeyStore ( ) ;
97
10- constructor ( private readonly secrets : SecretStorage ) { }
11-
128 async get ( ) {
13- let apiKey = await this . store . get ( ) ;
14-
15- if ( ! apiKey ) {
16- const secretsApiKey = await this . secrets . get (
17- `${ ExtensionID } .${ Config . APIKey } ` ,
18- ) ;
19- if ( secretsApiKey ) {
20- await this . set ( secretsApiKey ) ;
21- apiKey = secretsApiKey ;
22- }
23- }
24-
9+ const apiKey = await this . store . get ( ) ;
2510 return apiKey ;
2611 }
2712
2813 async set ( value : string | undefined ) {
2914 if ( ! value ) return void ( await this . store . delete ( ) ) ;
30- await this . store . store ( value ) ;
15+ await this . store . set ( value ) ;
3116 }
3217
3318 async test ( apiKey ?: string ) {
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ export class ApiKeyStore {
2424 }
2525 }
2626
27- async store ( apiKey : string ) : Promise < void > {
27+ async set ( apiKey : string ) : Promise < void > {
2828 await this . reload ( ) ;
2929 this . apiKey = apiKey ;
3030 await this . write ( apiKey ) ;
You can’t perform that action at this time.
0 commit comments