From d9cc92db1464cbf608e59fb8b942ffa604645b9e Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Thu, 24 Oct 2019 15:08:29 +0200 Subject: [PATCH] Camera settings (#234) --- packages/react-identicon/package.json | 4 +- packages/ui-keyring/package.json | 6 +-- packages/ui-settings/package.json | 2 +- packages/ui-settings/src/Settings.ts | 15 +++++- packages/ui-settings/src/defaults/index.ts | 17 +++++++ packages/ui-settings/src/types.ts | 1 + packages/ui-shared/package.json | 2 +- tsconfig.json | 4 ++ yarn.lock | 57 +++++++++++++++++----- 9 files changed, 89 insertions(+), 19 deletions(-) diff --git a/packages/react-identicon/package.json b/packages/react-identicon/package.json index bf14d4cb..208b43c9 100644 --- a/packages/react-identicon/package.json +++ b/packages/react-identicon/package.json @@ -25,8 +25,8 @@ "react": "*" }, "devDependencies": { - "@polkadot/keyring": "^1.5.1", - "@polkadot/util-crypto": "^1.5.1", + "@polkadot/keyring": "^1.6.1", + "@polkadot/util-crypto": "^1.6.1", "xmlserializer": "^0.6.1" } } diff --git a/packages/ui-keyring/package.json b/packages/ui-keyring/package.json index 90cdeaee..9ebb250c 100644 --- a/packages/ui-keyring/package.json +++ b/packages/ui-keyring/package.json @@ -30,9 +30,9 @@ "store": "^2.0.12" }, "devDependencies": { - "@polkadot/keyring": "^1.5.1", - "@polkadot/types": "^0.95.0-beta.30", - "@polkadot/util": "^1.5.1" + "@polkadot/keyring": "^1.6.1", + "@polkadot/types": "^0.95.0-beta.33", + "@polkadot/util": "^1.6.1" }, "optionalDependencies": { "@ledgerhq/hw-transport-node-hid": "^4.72.2" diff --git a/packages/ui-settings/package.json b/packages/ui-settings/package.json index 748d081a..5fa16192 100644 --- a/packages/ui-settings/package.json +++ b/packages/ui-settings/package.json @@ -14,7 +14,7 @@ "store": "^2.0.12" }, "devDependencies": { - "@polkadot/util": "^1.5.1" + "@polkadot/util": "^1.6.1" }, "peerDependencies": { "@polkadot/util": "*" diff --git a/packages/ui-settings/src/Settings.ts b/packages/ui-settings/src/Settings.ts index 6ebbd058..1def3c83 100644 --- a/packages/ui-settings/src/Settings.ts +++ b/packages/ui-settings/src/Settings.ts @@ -6,7 +6,7 @@ import EventEmitter from 'eventemitter3'; import store from 'store'; import { isUndefined } from '@polkadot/util'; -import { CRYPTOS, ENDPOINT_DEFAULT, ENDPOINTS, ICON_DEFAULT, ICONS, LANGUAGE_DEFAULT, LANGUAGES, LEDGER_CONN, LEDGER_CONN_DEFAULT, LOCKING_DEFAULT, LOCKING, PREFIX_DEFAULT, PREFIXES, UIMODE_DEFAULT, UIMODES, UITHEME_DEFAULT, UITHEMES } from './defaults'; +import { CAMERA_DEFAULT, CAMERA, CRYPTOS, ENDPOINT_DEFAULT, ENDPOINTS, ICON_DEFAULT, ICONS, LANGUAGE_DEFAULT, LANGUAGES, LEDGER_CONN, LEDGER_CONN_DEFAULT, LOCKING_DEFAULT, LOCKING, PREFIX_DEFAULT, PREFIXES, UIMODE_DEFAULT, UIMODES, UITHEME_DEFAULT, UITHEMES } from './defaults'; import { Option, SettingsStruct } from './types'; type ChangeCallback = (settings: SettingsStruct) => void; @@ -15,6 +15,8 @@ type OnTypes = 'change'; export class Settings implements SettingsStruct { private _apiUrl: string; + private _camera: string; + private _emitter: EventEmitter; private _i18nLang: string; @@ -37,6 +39,7 @@ export class Settings implements SettingsStruct { this._emitter = new EventEmitter(); this._apiUrl = settings.apiUrl || process.env.WS_URL || ENDPOINT_DEFAULT; + this._camera = settings.camera || CAMERA_DEFAULT; this._ledgerConn = settings.ledgerConn || LEDGER_CONN_DEFAULT; this._i18nLang = settings.i18nLang || LANGUAGE_DEFAULT; this._icon = settings.icon || ICON_DEFAULT; @@ -46,6 +49,10 @@ export class Settings implements SettingsStruct { this._uiTheme = settings.uiTheme || UITHEME_DEFAULT; } + public get camera (): string { + return this._camera; + } + public get apiUrl (): string { return this._apiUrl; } @@ -78,6 +85,10 @@ export class Settings implements SettingsStruct { return this._uiTheme; } + public get availableCamera (): Option[] { + return CAMERA; + } + public get availableCryptos (): Option[] { return CRYPTOS; } @@ -117,6 +128,7 @@ export class Settings implements SettingsStruct { public get (): SettingsStruct { return { apiUrl: this._apiUrl, + camera: this._camera, i18nLang: this._i18nLang, icon: this._icon, ledgerConn: this._ledgerConn, @@ -129,6 +141,7 @@ export class Settings implements SettingsStruct { public set (settings: Partial): void { this._apiUrl = settings.apiUrl || this._apiUrl; + this._camera = settings.camera || this._camera; this._ledgerConn = settings.ledgerConn || this._ledgerConn; this._i18nLang = settings.i18nLang || this._i18nLang; this._icon = settings.icon || this._icon; diff --git a/packages/ui-settings/src/defaults/index.ts b/packages/ui-settings/src/defaults/index.ts index e90e54f5..2f3eae49 100644 --- a/packages/ui-settings/src/defaults/index.ts +++ b/packages/ui-settings/src/defaults/index.ts @@ -10,6 +10,21 @@ import { LEDGER_CONN, LEDGER_CONN_DEFAULT } from './ledger'; import { PREFIXES, PREFIX_DEFAULT } from './ss58'; import { ICON_DEFAULT, ICON_DEFAULT_HOST, ICONS, UIMODE_DEFAULT, UIMODES, UITHEME_DEFAULT, UITHEMES } from './ui'; +const CAMERA_DEFAULT = 'on'; + +const CAMERA: Option[] = [ + { + info: 'on', + text: 'Allow camera access', + value: 'on' + }, + { + info: 'off', + text: 'Do not allow camera access', + value: 'off' + } +]; + const LANGUAGE_DEFAULT = 'default'; const LANGUAGES: Option[] = [ @@ -36,6 +51,8 @@ const LOCKING: Option[] = [ ]; export { + CAMERA_DEFAULT, + CAMERA, CRYPTOS, ENDPOINT_DEFAULT, ENDPOINTS, diff --git a/packages/ui-settings/src/types.ts b/packages/ui-settings/src/types.ts index ab0c7154..3223fca5 100644 --- a/packages/ui-settings/src/types.ts +++ b/packages/ui-settings/src/types.ts @@ -11,6 +11,7 @@ export type Option = { export interface SettingsStruct { apiUrl: string; + camera: string; i18nLang: string; icon: string; ledgerConn: string; diff --git a/packages/ui-shared/package.json b/packages/ui-shared/package.json index 7abfc858..4aae43ed 100644 --- a/packages/ui-shared/package.json +++ b/packages/ui-shared/package.json @@ -17,6 +17,6 @@ "@polkadot/util-crypto": "*" }, "devDependencies": { - "@polkadot/util-crypto": "^1.5.1" + "@polkadot/util-crypto": "^1.6.1" } } diff --git a/tsconfig.json b/tsconfig.json index 002d0b4d..70608a6c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,9 @@ { "extends": "./node_modules/@polkadot/dev/config/tsconfig", + "exclude": [ + "build/**/*", + "**/build/**/*" + ], "compilerOptions": { "baseUrl": ".", "paths": { diff --git a/yarn.lock b/yarn.lock index 747f1197..4b4a5fea 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2140,14 +2140,14 @@ typescript "^3.6.4" vuepress "^1.2.0" -"@polkadot/keyring@^1.5.1": - version "1.5.1" - resolved "https://registry.yarnpkg.com/@polkadot/keyring/-/keyring-1.5.1.tgz#74091e246c9ce4bc15960f15afffdb3bb8e208c7" - integrity sha512-sp1uNK5FKs8Vnlvl/0NvlRZfu4KcCWtyIL6YFa3oH1iYnAmwEV+XekQwTNe4wXWJVXdjLi1Xvjxx2yGxQkWolw== +"@polkadot/keyring@^1.6.1": + version "1.6.1" + resolved "https://registry.yarnpkg.com/@polkadot/keyring/-/keyring-1.6.1.tgz#35966afba142b647b31767e3a349652947c57a90" + integrity sha512-ortPbweoaANKTKZR0JDbO796U6B3JGjj87yZD+ghlFRUWjMjlbP+LOWnfNyXHcI87yxNC23nK3YDv1KCl0eDUQ== dependencies: - "@babel/runtime" "^7.6.2" - "@polkadot/util" "^1.5.1" - "@polkadot/util-crypto" "^1.5.1" + "@babel/runtime" "^7.6.3" + "@polkadot/util" "^1.6.1" + "@polkadot/util-crypto" "^1.6.1" "@polkadot/ts@^0.1.82": version "0.1.82" @@ -2156,10 +2156,10 @@ dependencies: "@types/chrome" "^0.0.91" -"@polkadot/types@^0.95.0-beta.30": - version "0.95.0-beta.30" - resolved "https://registry.yarnpkg.com/@polkadot/types/-/types-0.95.0-beta.30.tgz#2c5e6aa569b85b4eaedb3d892b4dcaab83eb63c3" - integrity sha512-qYcehtmDoXP2ygdPDAY8H/htHDFm6ZUhhUzEAJWALkMLNDCsJ+ZRb+U02TFg1hVvwJmRT0w9gBAeZ/kY2Oxrlg== +"@polkadot/types@^0.95.0-beta.33": + version "0.95.0-beta.33" + resolved "https://registry.yarnpkg.com/@polkadot/types/-/types-0.95.0-beta.33.tgz#bc2cd2f536bb061c926e13c0126c64dee53f24a9" + integrity sha512-d1M0z6r4vZ9kGEAaRYw9PI8s/TVCjjQAdmEfPtKPVj9uuoL8jW8TajAzA3Yvd4s/Y9F/0nNipHUg6w88UdgxYg== dependencies: "@babel/runtime" "^7.6.3" "@polkadot/util" "^1.5.1" @@ -2189,6 +2189,28 @@ tweetnacl "^1.0.1" xxhashjs "^0.2.2" +"@polkadot/util-crypto@^1.6.1": + version "1.6.1" + resolved "https://registry.yarnpkg.com/@polkadot/util-crypto/-/util-crypto-1.6.1.tgz#6d924c5eaecbf98f971da1aac69fb60b17a4bf55" + integrity sha512-Dbo5qsIGKO82HpkysFKh9GDY0w6O6tX9h5HPRDy4KIaTaCo3H5QTmxit+hPU9n3PIHsxGhnyPq8q1i2wD/iWYQ== + dependencies: + "@babel/runtime" "^7.6.3" + "@polkadot/util" "^1.6.1" + "@polkadot/wasm-crypto" "^0.14.1" + "@types/bip39" "^2.4.2" + "@types/bs58" "^4.0.0" + "@types/pbkdf2" "^3.0.0" + "@types/secp256k1" "^3.5.0" + "@types/xxhashjs" "^0.2.1" + base-x "3.0.5" + bip39 "^2.5.0" + blakejs "^1.1.0" + bs58 "^4.0.1" + js-sha3 "^0.8.0" + secp256k1 "^3.7.0" + tweetnacl "^1.0.1" + xxhashjs "^0.2.2" + "@polkadot/util@^1.5.1": version "1.5.1" resolved "https://registry.yarnpkg.com/@polkadot/util/-/util-1.5.1.tgz#acc6d1fd041959a1a781ee2a4d0fc8dae99d4e1a" @@ -2202,6 +2224,19 @@ ip-regex "^4.1.0" moment "^2.24.0" +"@polkadot/util@^1.6.1": + version "1.6.1" + resolved "https://registry.yarnpkg.com/@polkadot/util/-/util-1.6.1.tgz#8110c12a1670e564c5d6a1c19347cbb0dba8a3ce" + integrity sha512-uKRfapAXwZMcWQ24MdV+zg8jrYtidbKxJhUbq0G77Yy27d45OID8d+JcI3Q+d6d2pmC/h733iSeCqdiLYCKqMw== + dependencies: + "@babel/runtime" "^7.6.3" + "@types/bn.js" "^4.11.5" + bn.js "^4.11.8" + camelcase "^5.3.1" + chalk "^2.4.2" + ip-regex "^4.1.0" + moment "^2.24.0" + "@polkadot/wasm-crypto@^0.14.1": version "0.14.1" resolved "https://registry.yarnpkg.com/@polkadot/wasm-crypto/-/wasm-crypto-0.14.1.tgz#f4923bba22d7c68a4be3575ba27790947b212633"