瀏覽代碼

Adds stronger typing for secret keys

main
Eric Amodio 1 年之前
父節點
當前提交
3cf152d5da
共有 3 個文件被更改,包括 7 次插入4 次删除
  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 查看文件

@ -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 查看文件

@ -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 查看文件

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

Loading…
取消
儲存