Quellcode durchsuchen

Adds stronger typing for secret keys

main
Eric Amodio vor 1 Jahr
Ursprung
Commit
3cf152d5da
3 geänderte Dateien mit 7 neuen und 4 gelöschten Zeilen
  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 Datei anzeigen

@ -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 Datei anzeigen

@ -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 Datei anzeigen

@ -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',

Laden…
Abbrechen
Speichern