Add account locking strategy (#126)

This commit is contained in:
Jaco Greeff
2019-05-13 16:06:27 +02:00
committed by GitHub
parent b973e353d8
commit e0c4b6d929
3 changed files with 25 additions and 4 deletions
+13 -1
View File
@@ -4,12 +4,13 @@
import store from 'store'; import store from 'store';
import { CRYPTOS, ENDPOINT_DEFAULT, ENDPOINTS, LANGUAGE_DEFAULT, LANGUAGES, UIMODE_DEFAULT, UIMODES, UITHEME_DEFAULT, UITHEMES } from './defaults'; import { CRYPTOS, ENDPOINT_DEFAULT, ENDPOINTS, LANGUAGE_DEFAULT, LANGUAGES, LOCKING_DEFAULT, LOCKING, UIMODE_DEFAULT, UIMODES, UITHEME_DEFAULT, UITHEMES } from './defaults';
import { Options, SettingsStruct } from './types'; import { Options, SettingsStruct } from './types';
export class Settings implements SettingsStruct { export class Settings implements SettingsStruct {
private _apiUrl: string; private _apiUrl: string;
private _i18nLang: string; private _i18nLang: string;
private _locking: string;
private _uiMode: string; private _uiMode: string;
private _uiTheme: string; private _uiTheme: string;
@@ -18,6 +19,7 @@ export class Settings implements SettingsStruct {
this._apiUrl = settings.apiUrl || process.env.WS_URL || ENDPOINT_DEFAULT; this._apiUrl = settings.apiUrl || process.env.WS_URL || ENDPOINT_DEFAULT;
this._i18nLang = settings.i18nLang || LANGUAGE_DEFAULT; this._i18nLang = settings.i18nLang || LANGUAGE_DEFAULT;
this._locking = settings.locking || LOCKING_DEFAULT;
this._uiMode = settings.uiMode || UIMODE_DEFAULT; this._uiMode = settings.uiMode || UIMODE_DEFAULT;
this._uiTheme = settings.uiTheme || UITHEME_DEFAULT; this._uiTheme = settings.uiTheme || UITHEME_DEFAULT;
} }
@@ -30,6 +32,10 @@ export class Settings implements SettingsStruct {
return this._i18nLang; return this._i18nLang;
} }
get locking (): string {
return this._locking;
}
get uiMode (): string { get uiMode (): string {
return this._uiMode; return this._uiMode;
} }
@@ -50,6 +56,10 @@ export class Settings implements SettingsStruct {
return LANGUAGES; return LANGUAGES;
} }
get availableLocking (): Options {
return LOCKING;
}
get availableUIModes (): Options { get availableUIModes (): Options {
return UIMODES; return UIMODES;
} }
@@ -62,6 +72,7 @@ export class Settings implements SettingsStruct {
return { return {
apiUrl: this._apiUrl, apiUrl: this._apiUrl,
i18nLang: this._i18nLang, i18nLang: this._i18nLang,
locking: this._locking,
uiMode: this._uiMode, uiMode: this._uiMode,
uiTheme: this._uiTheme uiTheme: this._uiTheme
}; };
@@ -70,6 +81,7 @@ export class Settings implements SettingsStruct {
set (settings: Partial<SettingsStruct>): void { set (settings: Partial<SettingsStruct>): void {
this._apiUrl = settings.apiUrl || this._apiUrl; this._apiUrl = settings.apiUrl || this._apiUrl;
this._i18nLang = settings.i18nLang || this._i18nLang; this._i18nLang = settings.i18nLang || this._i18nLang;
this._locking = settings.locking || this._locking;
this._uiMode = settings.uiMode || this._uiMode; this._uiMode = settings.uiMode || this._uiMode;
this._uiTheme = settings.uiTheme || this._uiTheme; this._uiTheme = settings.uiTheme || this._uiTheme;
+10 -2
View File
@@ -4,13 +4,14 @@
import { Options } from './types'; import { Options } from './types';
// matches https://polkadot.js.org & https://poc-3.polkadot.io // matches https://polkadot.js.org & https://*.polkadot.io
// tslint:disable-next-line // tslint:disable-next-line
const isPolkadot = typeof window !== 'undefined' && window.location.host.indexOf('polkadot') !== -1; const isPolkadot = typeof window !== 'undefined' && window.location.host.indexOf('polkadot') !== -1;
const WSS_POLKADOT = 'wss://poc3-rpc.polkadot.io/'; const WSS_POLKADOT = 'wss://poc3-rpc.polkadot.io/';
const WSS_SUBSTRATE = 'wss://substrate-rpc.parity.io/'; const WSS_SUBSTRATE = 'wss://substrate-rpc.parity.io/';
const LANGUAGE_DEFAULT = 'default'; const LANGUAGE_DEFAULT = 'default';
const LOCKING_DEFAULT = 'session';
const CRYPTOS: Options = [ const CRYPTOS: Options = [
{ text: 'Edwards (ed25519)', value: 'ed25519' }, { text: 'Edwards (ed25519)', value: 'ed25519' },
@@ -24,7 +25,12 @@ const ENDPOINTS: Options = [
]; ];
const LANGUAGES: Options = [ const LANGUAGES: Options = [
{ value: LANGUAGE_DEFAULT, text: 'Default browser language (auto-detect)' } { text: 'Default browser language (auto-detect)', value: LANGUAGE_DEFAULT }
];
const LOCKING: Options = [
{ text: 'Once per session', value: 'session' },
{ text: 'On each transaction', value: 'tx' }
]; ];
const UIMODES: Options = [ const UIMODES: Options = [
@@ -56,6 +62,8 @@ export {
ENDPOINTS, ENDPOINTS,
LANGUAGE_DEFAULT, LANGUAGE_DEFAULT,
LANGUAGES, LANGUAGES,
LOCKING_DEFAULT,
LOCKING,
UIMODE_DEFAULT, UIMODE_DEFAULT,
UIMODES, UIMODES,
UITHEME_DEFAULT, UITHEME_DEFAULT,
+1
View File
@@ -11,6 +11,7 @@ export type Options = Array<{
export interface SettingsStruct { export interface SettingsStruct {
apiUrl: string; apiUrl: string;
i18nLang: string; i18nLang: string;
locking: string;
uiMode: string; uiMode: string;
uiTheme: string; uiTheme: string;
} }