chore: move decryptLnurlPayAES to utils (#3576)
This commit is contained in:
parent
f1f6af0e35
commit
49cc8104fc
8 changed files with 38 additions and 34 deletions
2
lnbits/static/bundle-components.min.js
vendored
2
lnbits/static/bundle-components.min.js
vendored
File diff suppressed because one or more lines are too long
2
lnbits/static/bundle.min.js
vendored
2
lnbits/static/bundle.min.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -111,11 +111,11 @@ window.app.component('lnbits-lnurlpay-success-action', {
|
|||
},
|
||||
mounted() {
|
||||
if (this.success_action.tag !== 'aes') return null
|
||||
decryptLnurlPayAES(this.success_action, this.payment.preimage).then(
|
||||
value => {
|
||||
this.utils
|
||||
.decryptLnurlPayAES(this.success_action, this.payment.preimage)
|
||||
.then(value => {
|
||||
this.decryptedValue = value
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -1,23 +0,0 @@
|
|||
window.decryptLnurlPayAES = (success_action, preimage) => {
|
||||
let keyb = new Uint8Array(
|
||||
preimage.match(/[\da-f]{2}/gi).map(h => parseInt(h, 16))
|
||||
)
|
||||
|
||||
return crypto.subtle
|
||||
.importKey('raw', keyb, {name: 'AES-CBC', length: 256}, false, ['decrypt'])
|
||||
.then(key => {
|
||||
let ivb = Uint8Array.from(window.atob(success_action.iv), c =>
|
||||
c.charCodeAt(0)
|
||||
)
|
||||
let ciphertextb = Uint8Array.from(
|
||||
window.atob(success_action.ciphertext),
|
||||
c => c.charCodeAt(0)
|
||||
)
|
||||
|
||||
return crypto.subtle.decrypt({name: 'AES-CBC', iv: ivb}, key, ciphertextb)
|
||||
})
|
||||
.then(valueb => {
|
||||
let decoder = new TextDecoder('utf-8')
|
||||
return decoder.decode(valueb)
|
||||
})
|
||||
}
|
||||
|
|
@ -456,7 +456,7 @@ window.PageWallet = {
|
|||
})
|
||||
break
|
||||
case 'aes':
|
||||
decryptLnurlPayAES(action, response.data.preimage)
|
||||
this.utils.decryptLnurlPayAES(action, response.data.preimage)
|
||||
Quasar.Notify.create({
|
||||
message: value,
|
||||
caption: extra.success_action.description,
|
||||
|
|
|
|||
|
|
@ -171,5 +171,34 @@ window._lnbitsUtils = {
|
|||
converter.setFlavor('github')
|
||||
converter.setOption('simpleLineBreaks', true)
|
||||
return converter.makeHtml(text)
|
||||
},
|
||||
async decryptLnurlPayAES(success_action, preimage) {
|
||||
let keyb = new Uint8Array(
|
||||
preimage.match(/[\da-f]{2}/gi).map(h => parseInt(h, 16))
|
||||
)
|
||||
|
||||
return crypto.subtle
|
||||
.importKey('raw', keyb, {name: 'AES-CBC', length: 256}, false, [
|
||||
'decrypt'
|
||||
])
|
||||
.then(key => {
|
||||
let ivb = Uint8Array.from(window.atob(success_action.iv), c =>
|
||||
c.charCodeAt(0)
|
||||
)
|
||||
let ciphertextb = Uint8Array.from(
|
||||
window.atob(success_action.ciphertext),
|
||||
c => c.charCodeAt(0)
|
||||
)
|
||||
|
||||
return crypto.subtle.decrypt(
|
||||
{name: 'AES-CBC', iv: ivb},
|
||||
key,
|
||||
ciphertextb
|
||||
)
|
||||
})
|
||||
.then(valueb => {
|
||||
let decoder = new TextDecoder('utf-8')
|
||||
return decoder.decode(valueb)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,8 +39,7 @@
|
|||
"js/base.js",
|
||||
"js/windowMixin.js",
|
||||
"js/event-reactions.js",
|
||||
"js/bolt11-decoder.js",
|
||||
"js/lnurl.js"
|
||||
"js/bolt11-decoder.js"
|
||||
],
|
||||
"components": [
|
||||
"js/pages/home.js",
|
||||
|
|
|
|||
|
|
@ -91,8 +91,7 @@
|
|||
"js/base.js",
|
||||
"js/windowMixin.js",
|
||||
"js/event-reactions.js",
|
||||
"js/bolt11-decoder.js",
|
||||
"js/lnurl.js"
|
||||
"js/bolt11-decoder.js"
|
||||
],
|
||||
"components": [
|
||||
"js/pages/home.js",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue