Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor (emit) {
this.emit = emit
this.devices = {}
TrezorConnect.on('DEVICE_EVENT', e => {
if (e.type === 'device-connect' || e.type === 'device-changed') {
if (!this.devices[e.payload.path]) {
this.devices[e.payload.path] = new Device(e.payload, this.emit)
} else {
this.devices[e.payload.path].update(e.payload)
}
} else if (e.type === 'device-disconnect') {
if (this.devices[e.payload.path]) this.devices[e.payload.path].disconnect()
delete this.devices[e.payload.path]
}
})
TrezorConnect.on('UI_EVENT', e => {
if (e.type === 'ui-request_pin') {
const device = this.devices[e.payload.device.path]
if (device) device.needPin()
} else if (e.type === 'ui-request_passphrase') {
console.log('Device needs passphrase')
}
})
const manifest = { email: 'jordan@frame.sh', appUrl: 'https://frame.sh' }
const config = { manifest, popup: false, webusb: false, debug: false, lazyLoad: false }
try {
TrezorConnect.init(config).then(() => {
ready = true
events.emit('ready')
}).catch(err => console.warn('TrezorConnect Init Error', err))
} catch (e) { console.warn(e) }
}
constructor (emit) {
this.emit = emit
this.devices = {}
TrezorConnect.on('DEVICE_EVENT', e => {
if (e.type === 'device-connect' || e.type === 'device-changed') {
if (!this.devices[e.payload.path]) {
this.devices[e.payload.path] = new Device(e.payload, this.emit)
} else {
this.devices[e.payload.path].update(e.payload)
}
} else if (e.type === 'device-disconnect') {
if (this.devices[e.payload.path]) this.devices[e.payload.path].disconnect()
delete this.devices[e.payload.path]
}
})
TrezorConnect.on('UI_EVENT', e => {
if (e.type === 'ui-request_pin') {
const device = this.devices[e.payload.device.path]
if (device) device.needPin()
} else if (e.type === 'ui-request_passphrase') {