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:
parent
a297eb764a
commit
aa68beb115
|
@ -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 {
|
||||
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 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) {
|
||||
// https://developers.yubico.com/U2F/Libraries/Client_error_codes.html
|
||||
if (isU2FError(err)) {
|
||||
|
@ -124,6 +133,13 @@ function ledgerErrToMessage(err: LedgerError) {
|
|||
return err;
|
||||
}
|
||||
|
||||
if (isErrorWithId(err)) {
|
||||
// Browser doesn't support U2F
|
||||
if (err.message.includes('U2F not supported')) {
|
||||
return translateRaw('U2F_NOT_SUPPORTED');
|
||||
}
|
||||
}
|
||||
|
||||
// Other
|
||||
return err.toString();
|
||||
}
|
||||
|
|
|
@ -655,6 +655,7 @@
|
|||
"NETWORK": "Network",
|
||||
"NETWORK_2": "network",
|
||||
"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."
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue