mirror of
https://github.com/lnbits/lnbits-legend.git
synced 2024-11-20 10:39:59 +01:00
feat: handle forced logout
This commit is contained in:
parent
90938e89e1
commit
218ee77acd
@ -426,14 +426,15 @@ async function serialSigner(path) {
|
||||
}
|
||||
},
|
||||
handleLogoutResponse: function (res = '') {
|
||||
this.hww.authenticated = !(res.trim() === '1')
|
||||
if (this.hww.authenticated) {
|
||||
const authenticated = !(res.trim() === '1')
|
||||
if (this.hww.authenticated && !authenticated) {
|
||||
this.$q.notify({
|
||||
type: 'warning',
|
||||
message: 'Failed to logout from Hardware Wallet',
|
||||
type: 'positive',
|
||||
message: 'Logged Out',
|
||||
timeout: 10000
|
||||
})
|
||||
}
|
||||
this.hww.authenticated = authenticated
|
||||
},
|
||||
hwwSendPsbt: async function (psbtBase64, tx) {
|
||||
try {
|
||||
@ -523,13 +524,12 @@ async function serialSigner(path) {
|
||||
})
|
||||
},
|
||||
hwwCheckPairing: async function () {
|
||||
const testString = 'lnbits'
|
||||
const iv = window.crypto.getRandomValues(new Uint8Array(16))
|
||||
console.log('### this.sharedSecret', this.sharedSecret)
|
||||
const encrypted = await this.encryptMessage(
|
||||
this.sharedSecret,
|
||||
iv,
|
||||
testString.length + ' ' + testString
|
||||
PAIRING_CONTROL_TEXT.length + ' ' + PAIRING_CONTROL_TEXT
|
||||
)
|
||||
|
||||
const encryptedHex = nobleSecp256k1.utils.bytesToHex(encrypted)
|
||||
@ -548,7 +548,31 @@ async function serialSigner(path) {
|
||||
}
|
||||
},
|
||||
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 () {
|
||||
try {
|
||||
|
@ -17,6 +17,7 @@ const COMMAND_LOG = '/log'
|
||||
const COMMAND_CHECK_PAIRING = '/check-pairing'
|
||||
|
||||
const DEFAULT_RECEIVE_GAP_LIMIT = 20
|
||||
const PAIRING_CONTROL_TEXT = 'lnbits'
|
||||
|
||||
const blockTimeToDate = blockTime =>
|
||||
blockTime ? moment(blockTime * 1000).format('LLL') : ''
|
||||
|
Loading…
Reference in New Issue
Block a user