feat: handle forced logout
This commit is contained in:
parent
90938e89e1
commit
218ee77acd
2 changed files with 32 additions and 7 deletions
|
|
@ -426,14 +426,15 @@ async function serialSigner(path) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleLogoutResponse: function (res = '') {
|
handleLogoutResponse: function (res = '') {
|
||||||
this.hww.authenticated = !(res.trim() === '1')
|
const authenticated = !(res.trim() === '1')
|
||||||
if (this.hww.authenticated) {
|
if (this.hww.authenticated && !authenticated) {
|
||||||
this.$q.notify({
|
this.$q.notify({
|
||||||
type: 'warning',
|
type: 'positive',
|
||||||
message: 'Failed to logout from Hardware Wallet',
|
message: 'Logged Out',
|
||||||
timeout: 10000
|
timeout: 10000
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
this.hww.authenticated = authenticated
|
||||||
},
|
},
|
||||||
hwwSendPsbt: async function (psbtBase64, tx) {
|
hwwSendPsbt: async function (psbtBase64, tx) {
|
||||||
try {
|
try {
|
||||||
|
|
@ -523,13 +524,12 @@ async function serialSigner(path) {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
hwwCheckPairing: async function () {
|
hwwCheckPairing: async function () {
|
||||||
const testString = 'lnbits'
|
|
||||||
const iv = window.crypto.getRandomValues(new Uint8Array(16))
|
const iv = window.crypto.getRandomValues(new Uint8Array(16))
|
||||||
console.log('### this.sharedSecret', this.sharedSecret)
|
console.log('### this.sharedSecret', this.sharedSecret)
|
||||||
const encrypted = await this.encryptMessage(
|
const encrypted = await this.encryptMessage(
|
||||||
this.sharedSecret,
|
this.sharedSecret,
|
||||||
iv,
|
iv,
|
||||||
testString.length + ' ' + testString
|
PAIRING_CONTROL_TEXT.length + ' ' + PAIRING_CONTROL_TEXT
|
||||||
)
|
)
|
||||||
|
|
||||||
const encryptedHex = nobleSecp256k1.utils.bytesToHex(encrypted)
|
const encryptedHex = nobleSecp256k1.utils.bytesToHex(encrypted)
|
||||||
|
|
@ -548,7 +548,31 @@ async function serialSigner(path) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleCheckPairingResponse: async function (res = '') {
|
handleCheckPairingResponse: async function (res = '') {
|
||||||
console.log('### handleCheckPairingResponse', res)
|
const [statusCode, encryptedMessage] = res.split(' ')
|
||||||
|
switch (statusCode) {
|
||||||
|
case '0':
|
||||||
|
const controlText = await this.decryptData(encryptedMessage)
|
||||||
|
if (controlText == PAIRING_CONTROL_TEXT) {
|
||||||
|
this.$q.notify({
|
||||||
|
type: 'positive',
|
||||||
|
message: 'Re-paired with success!',
|
||||||
|
timeout: 10000
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
this.$q.notify({
|
||||||
|
type: 'warning',
|
||||||
|
message: 'Re-pairing failed!',
|
||||||
|
caption: 'Remove (forget) device and try again!',
|
||||||
|
timeout: 10000
|
||||||
|
})
|
||||||
|
}
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
// noting to do here yet
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
hwwPair: async function () {
|
hwwPair: async function () {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ const COMMAND_LOG = '/log'
|
||||||
const COMMAND_CHECK_PAIRING = '/check-pairing'
|
const COMMAND_CHECK_PAIRING = '/check-pairing'
|
||||||
|
|
||||||
const DEFAULT_RECEIVE_GAP_LIMIT = 20
|
const DEFAULT_RECEIVE_GAP_LIMIT = 20
|
||||||
|
const PAIRING_CONTROL_TEXT = 'lnbits'
|
||||||
|
|
||||||
const blockTimeToDate = blockTime =>
|
const blockTimeToDate = blockTime =>
|
||||||
blockTime ? moment(blockTime * 1000).format('LLL') : ''
|
blockTime ? moment(blockTime * 1000).format('LLL') : ''
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue