Procházet zdrojové kódy

Adds stronger typing for secret keys

main
Eric Amodio před 1 rokem
rodič
revize
3cf152d5da
3 změnil soubory, kde provedl 7 přidání a 4 odebrání
  1. +3
    -1
      src/container.ts
  2. +2
    -2
      src/plus/subscription/authenticationProvider.ts
  3. +2
    -1
      src/storage.ts

+ 3
- 1
src/container.ts Zobrazit soubor

@ -61,6 +61,8 @@ import { RebaseEditorProvider } from './webviews/rebase/rebaseEditor';
import { SettingsWebview } from './webviews/settings/settingsWebview';
import { WelcomeWebview } from './webviews/welcome/welcomeWebview';
export type Environment = 'dev' | 'staging' | 'production';
export class Container {
static #instance: Container | undefined;
static #proxy = new Proxy<Container>({} as Container, {
@ -360,7 +362,7 @@ export class Container {
}
@memoize()
get env(): 'dev' | 'staging' | 'production' {
get env(): Environment {
if (this.prereleaseOrDebugging) {
const env = configuration.getAny('gitkraken.env');
if (env === 'dev') return 'dev';

+ 2
- 2
src/plus/subscription/authenticationProvider.ts Zobrazit soubor

@ -5,7 +5,7 @@ import type {
} from 'vscode';
import { authentication, Disposable, EventEmitter, extensions, window } from 'vscode';
import { uuid } from '@env/crypto';
import type { Container } from '../../container';
import type { Container, Environment } from '../../container';
import { debug } from '../../system/decorators/log';
import { Logger } from '../../system/logger';
import { getLogScope } from '../../system/logger.scope';
@ -50,7 +50,7 @@ export class SubscriptionAuthenticationProvider implements AuthenticationProvide
this._disposable.dispose();
}
private get secretStorageKey(): string {
private get secretStorageKey(): `gitlens.plus.auth:${Environment}` {
return `gitlens.plus.auth:${this.container.env}`;
}

+ 2
- 1
src/storage.ts Zobrazit soubor

@ -1,6 +1,7 @@
import type { Disposable, Event, ExtensionContext, SecretStorageChangeEvent } from 'vscode';
import { EventEmitter } from 'vscode';
import type { ViewShowBranchComparison } from './config';
import type { Environment } from './container';
import type { StoredSearchQuery } from './git/search';
import type { Subscription } from './subscription';
import { debug } from './system/decorators/log';
@ -104,7 +105,7 @@ export class Storage implements Disposable {
}
}
export type SecretKeys = string;
export type SecretKeys = `gitlens.integration.auth:${string}` | `gitlens.plus.auth:${Environment}`;
export const enum SyncedStorageKeys {
Version = 'gitlens:synced:version',

Načítá se…
Zrušit
Uložit