Browse Source
Merge pull request #1309 from valpinkman/explicit-params
removed unwanted params for GET http calls, also removed helpers/common
master
Gaëtan Renaudeau
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with
35 additions and
30 deletions
-
src/commands/installApp.js
-
src/commands/uninstallApp.js
-
src/components/ManagerPage/AppSearchBar.js
-
src/components/ManagerPage/AppsList.js
-
src/components/ManagerPage/FirmwareUpdate.js
-
src/components/modals/UpdateFirmware/index.js
-
src/helpers/apps/installApp.js
-
src/helpers/apps/uninstallApp.js
-
src/helpers/devices/getDeviceInfo.js
-
src/helpers/devices/getMemInfo.js
-
src/helpers/devices/isDashboardOpen.js
-
src/helpers/firmware/getFirmwareInfo.js
-
src/helpers/types.js
-
src/helpers/urls.js
|
|
@ -6,7 +6,7 @@ import { fromPromise } from 'rxjs/observable/fromPromise' |
|
|
|
import { withDevice } from 'helpers/deviceAccess' |
|
|
|
import installApp from 'helpers/apps/installApp' |
|
|
|
|
|
|
|
import type { LedgerScriptParams } from 'helpers/common' |
|
|
|
import type { LedgerScriptParams } from 'helpers/types' |
|
|
|
|
|
|
|
type Input = { |
|
|
|
app: LedgerScriptParams, |
|
|
|
|
|
@ -6,7 +6,7 @@ import { withDevice } from 'helpers/deviceAccess' |
|
|
|
|
|
|
|
import uninstallApp from 'helpers/apps/uninstallApp' |
|
|
|
|
|
|
|
import type { LedgerScriptParams } from 'helpers/common' |
|
|
|
import type { LedgerScriptParams } from 'helpers/types' |
|
|
|
|
|
|
|
type Input = { |
|
|
|
app: LedgerScriptParams, |
|
|
|
|
|
@ -3,7 +3,7 @@ |
|
|
|
import React, { PureComponent, Fragment } from 'react' |
|
|
|
import styled from 'styled-components' |
|
|
|
|
|
|
|
import type { LedgerScriptParams } from 'helpers/common' |
|
|
|
import type { LedgerScriptParams } from 'helpers/types' |
|
|
|
|
|
|
|
import Box from 'components/base/Box' |
|
|
|
import Space from 'components/base/Space' |
|
|
|
|
|
@ -7,7 +7,7 @@ import { translate } from 'react-i18next' |
|
|
|
import { connect } from 'react-redux' |
|
|
|
import { compose } from 'redux' |
|
|
|
import type { Device, T } from 'types/common' |
|
|
|
import type { LedgerScriptParams } from 'helpers/common' |
|
|
|
import type { LedgerScriptParams } from 'helpers/types' |
|
|
|
import type { DeviceInfo } from 'helpers/devices/getDeviceInfo' |
|
|
|
import { developerModeSelector } from 'reducers/settings' |
|
|
|
|
|
|
|
|
|
@ -9,7 +9,7 @@ import invariant from 'invariant' |
|
|
|
|
|
|
|
import type { Device, T } from 'types/common' |
|
|
|
|
|
|
|
import type { LedgerScriptParams } from 'helpers/common' |
|
|
|
import type { LedgerScriptParams } from 'helpers/types' |
|
|
|
import type { StepId } from 'components/modals/UpdateFirmware' |
|
|
|
|
|
|
|
import getLatestFirmwareForDevice from 'commands/getLatestFirmwareForDevice' |
|
|
|
|
|
@ -10,7 +10,7 @@ import SyncSkipUnderPriority from 'components/SyncSkipUnderPriority' |
|
|
|
|
|
|
|
import type { StepProps as DefaultStepProps, Step } from 'components/base/Stepper' |
|
|
|
import type { ModalStatus } from 'components/ManagerPage/FirmwareUpdate' |
|
|
|
import type { LedgerScriptParams } from 'helpers/common' |
|
|
|
import type { LedgerScriptParams } from 'helpers/types' |
|
|
|
|
|
|
|
import { FreezeDeviceChangeEvents } from '../../ManagerPage/HookDeviceChange' |
|
|
|
import StepFullFirmwareInstall from './steps/01-step-install-full-firmware' |
|
|
|
|
|
@ -5,9 +5,9 @@ import type Transport from '@ledgerhq/hw-transport' |
|
|
|
import { BASE_SOCKET_URL } from 'config/constants' |
|
|
|
import { createDeviceSocket } from 'helpers/socket' |
|
|
|
|
|
|
|
import type { LedgerScriptParams } from 'helpers/common' |
|
|
|
import type { LedgerScriptParams } from 'helpers/types' |
|
|
|
|
|
|
|
import { createCustomErrorClass } from '../errors' |
|
|
|
import { createCustomErrorClass } from 'helpers/errors' |
|
|
|
|
|
|
|
const ManagerNotEnoughSpaceError = createCustomErrorClass('ManagerNotEnoughSpace') |
|
|
|
const ManagerDeviceLockedError = createCustomErrorClass('ManagerDeviceLocked') |
|
|
@ -41,8 +41,11 @@ export default async function installApp( |
|
|
|
): Promise<*> { |
|
|
|
const params = { |
|
|
|
targetId, |
|
|
|
...app, |
|
|
|
perso: app.perso, |
|
|
|
deleteKey: app.delete_key, |
|
|
|
firmware: app.firmware, |
|
|
|
firmwareKey: app.firmware_key, |
|
|
|
hash: app.hash, |
|
|
|
} |
|
|
|
const url = `${BASE_SOCKET_URL}/install?${qs.stringify(params)}` |
|
|
|
return remapError(createDeviceSocket(transport, url).toPromise()) |
|
|
|
|
|
@ -5,7 +5,7 @@ import type Transport from '@ledgerhq/hw-transport' |
|
|
|
import { BASE_SOCKET_URL } from 'config/constants' |
|
|
|
import { createDeviceSocket } from 'helpers/socket' |
|
|
|
|
|
|
|
import type { LedgerScriptParams } from 'helpers/common' |
|
|
|
import type { LedgerScriptParams } from 'helpers/types' |
|
|
|
import { createCustomErrorClass } from '../errors' |
|
|
|
|
|
|
|
const ManagerDeviceLockedError = createCustomErrorClass('ManagerDeviceLocked') |
|
|
@ -34,9 +34,11 @@ export default async function uninstallApp( |
|
|
|
): Promise<*> { |
|
|
|
const params = { |
|
|
|
targetId, |
|
|
|
...app, |
|
|
|
perso: app.perso, |
|
|
|
deleteKey: app.delete_key, |
|
|
|
firmware: app.delete, |
|
|
|
firmwareKey: app.delete_key, |
|
|
|
hash: app.hash, |
|
|
|
} |
|
|
|
const url = `${BASE_SOCKET_URL}/install?${qs.stringify(params)}` |
|
|
|
return remapError(createDeviceSocket(transport, url).toPromise()) |
|
|
|
|
|
@ -2,7 +2,7 @@ |
|
|
|
|
|
|
|
import type Transport from '@ledgerhq/hw-transport' |
|
|
|
|
|
|
|
import { getFirmwareInfo } from 'helpers/common' |
|
|
|
import getFirmwareInfo from 'helpers/firmware/getFirmwareInfo' |
|
|
|
import { FORCE_PROVIDER } from 'config/constants' |
|
|
|
|
|
|
|
export type DeviceInfo = { |
|
|
|
|
|
@ -2,7 +2,7 @@ |
|
|
|
|
|
|
|
import type Transport from '@ledgerhq/hw-transport' |
|
|
|
|
|
|
|
import { getFirmwareInfo } from 'helpers/common' |
|
|
|
import getFirmwareInfo from 'helpers/firmware/getFirmwareInfo' |
|
|
|
|
|
|
|
export default async function getMemInfos(transport: Transport<*>): Promise<Object> { |
|
|
|
const { targetId } = await getFirmwareInfo(transport) // eslint-disable-line
|
|
|
|
|
|
@ -2,7 +2,7 @@ |
|
|
|
|
|
|
|
import type Transport from '@ledgerhq/hw-transport' |
|
|
|
|
|
|
|
import { getFirmwareInfo } from 'helpers/common' |
|
|
|
import getFirmwareInfo from 'helpers/firmware/getFirmwareInfo' |
|
|
|
|
|
|
|
type Result = boolean |
|
|
|
|
|
|
|
|
|
@ -1,6 +1,5 @@ |
|
|
|
// @flow
|
|
|
|
|
|
|
|
// FIXME remove this file! 'helpers/common.js' RLY? :P
|
|
|
|
import type Transport from '@ledgerhq/hw-transport' |
|
|
|
|
|
|
|
const APDUS = { |
|
|
@ -10,23 +9,10 @@ const APDUS = { |
|
|
|
GET_FIRMWARE_FALLBACK: [0xe0, 0xc4, 0x00, 0x00], |
|
|
|
} |
|
|
|
|
|
|
|
export type LedgerScriptParams = { |
|
|
|
firmware?: string, |
|
|
|
firmware_key?: string, |
|
|
|
delete?: string, |
|
|
|
delete_key?: string, |
|
|
|
targetId?: string | number, |
|
|
|
name: string, |
|
|
|
version: string, |
|
|
|
icon: string, |
|
|
|
app?: number, |
|
|
|
hash?: string, |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Retrieve targetId and firmware version from device |
|
|
|
*/ |
|
|
|
export async function getFirmwareInfo(transport: Transport<*>) { |
|
|
|
export default async function getFirmwareInfo(transport: Transport<*>) { |
|
|
|
const res = await transport.send(...APDUS.GET_FIRMWARE) |
|
|
|
const byteArray = [...res] |
|
|
|
const data = byteArray.slice(0, byteArray.length - 2) |
|
|
@ -0,0 +1,14 @@ |
|
|
|
// @flow
|
|
|
|
export type LedgerScriptParams = { |
|
|
|
firmware?: string, |
|
|
|
firmware_key?: string, |
|
|
|
delete?: string, |
|
|
|
delete_key?: string, |
|
|
|
targetId?: string | number, |
|
|
|
name: string, |
|
|
|
version: string, |
|
|
|
icon: string, |
|
|
|
app?: number, |
|
|
|
hash?: string, |
|
|
|
perso?: string, |
|
|
|
} |
|
|
@ -2,7 +2,7 @@ |
|
|
|
import qs from 'qs' |
|
|
|
|
|
|
|
import { MANAGER_API_BASE, BASE_SOCKET_URL } from 'config/constants' |
|
|
|
import type { LedgerScriptParams } from 'helpers/common' |
|
|
|
import type { LedgerScriptParams } from 'helpers/types' |
|
|
|
|
|
|
|
const urlBuilder = (base: string) => (endpoint: string): string => `${base}/${endpoint}` |
|
|
|
|
|
|
|