Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
static listen = (observer: *) => {
let unsubscribed = false;
isSupported().then(supported => {
if (unsubscribed) return;
if (supported) {
observer.next({ type: "add", descriptor: null });
observer.complete();
} else {
observer.error(
new TransportError(
"U2F browser support is needed for Ledger. " +
"Please use Chrome, Opera or Firefox with a U2F extension. " +
"Also make sure you're on an HTTPS connection",
"U2FNotSupported"
)
);
}
});
return {
componentDidMount() {
u2f.isSupported().then(supported => {
this.setState({
isSupported: supported,
});
if (!supported) {
return;
}
this.invokeU2fFlow();
});
}
mounted() {
isSupported().then(res => {
this.items.forEach(item => {
const u2fhw = [SECALOT_TYPE, LEDGER_TYPE, BITBOX_TYPE];
const inMobile = [SECALOT_TYPE, KEEPKEY_TYPE];
const webUsb = [KEEPKEY_TYPE, LEDGER_TYPE];
if (webUsb.includes(item.name)) {
const disable =
window.location.protocol !== 'https:' ||
!window ||
!window.navigator ||
!window.navigator.usb;
item.disabled = disable;
item.msg = disable ? this.$t('errorsGlobal.browser-non-web-usb') : '';
}
if (u2fhw.includes(item.name)) {
item.disabled = !res;
onStateLoaded: async (state: RemoteState) => {
if (state.authentication_level < AuthenticationLevel.ONE_FACTOR) {
ownProps.history.push('/');
return;
}
const isU2FSupported = await u2fApi.isSupported();
if (isU2FSupported) {
await dispatch(setSecurityKeySupported(true));
await triggerSecurityKeySigning(dispatch, ownProps);
}
}
}