Adjust error message for "U2F not supported" (#1976)

* Update config snapshot

* Add checking for other types of messages for ledger and improve verbiage.
This commit is contained in:
Connor Bryan 2018-06-25 12:30:56 -05:00 committed by Daniel Ternyak
parent a297eb764a
commit aa68beb115
2 changed files with 19 additions and 2 deletions

View File

@ -15,7 +15,14 @@ interface U2FError {
}; };
} }
type LedgerError = U2FError | Error | string; interface ErrorWithId {
id: string;
message: string;
name: string;
stack: string;
}
type LedgerError = U2FError | ErrorWithId | Error | string;
export class LedgerWallet extends HardwareWallet { export class LedgerWallet extends HardwareWallet {
public static async getChainCode(dpath: string): Promise<ChainCodeResponse> { public static async getChainCode(dpath: string): Promise<ChainCodeResponse> {
@ -100,6 +107,8 @@ async function makeApp() {
const isU2FError = (err: LedgerError): err is U2FError => !!err && !!(err as U2FError).metaData; const isU2FError = (err: LedgerError): err is U2FError => !!err && !!(err as U2FError).metaData;
const isStringError = (err: LedgerError): err is string => typeof err === 'string'; const isStringError = (err: LedgerError): err is string => typeof err === 'string';
const isErrorWithId = (err: LedgerError): err is ErrorWithId =>
err.hasOwnProperty('id') && err.hasOwnProperty('message');
function ledgerErrToMessage(err: LedgerError) { function ledgerErrToMessage(err: LedgerError) {
// https://developers.yubico.com/U2F/Libraries/Client_error_codes.html // https://developers.yubico.com/U2F/Libraries/Client_error_codes.html
if (isU2FError(err)) { if (isU2FError(err)) {
@ -124,6 +133,13 @@ function ledgerErrToMessage(err: LedgerError) {
return err; return err;
} }
if (isErrorWithId(err)) {
// Browser doesn't support U2F
if (err.message.includes('U2F not supported')) {
return translateRaw('U2F_NOT_SUPPORTED');
}
}
// Other // Other
return err.toString(); return err.toString();
} }

View File

@ -655,6 +655,7 @@
"NETWORK": "Network", "NETWORK": "Network",
"NETWORK_2": "network", "NETWORK_2": "network",
"PROVIDED_BY": "provided by", "PROVIDED_BY": "provided by",
"YOU_ARE_INTERACTING": "You are interacting with the" "YOU_ARE_INTERACTING": "You are interacting with the",
"U2F_NOT_SUPPORTED": "The U2F standard that hardware wallets use does not seem to be supported by your browser. Please try again using Google Chrome."
} }
} }