Fix dynamic key loading

This commit is contained in:
Yarmo Mackenbach 2021-05-03 11:00:07 +02:00
parent 15516c02e6
commit f8bd9a3685
No known key found for this signature in database
GPG key ID: 37367F4AF4087AD1

View file

@ -109,18 +109,20 @@ const fetchProfileKey = async function() {
const rawKeyData = await fetch(window.kx.key.url)
let key, errorMsg
// try {
// key = (await openpgp.key.read(await rawKeyData.arrayBuffer())).keys[0]
// } catch(error) {
// errorMsg = error.message
// }
try {
key = (await openpgp.key.readArmored(await rawKeyData.text())).keys[0]
} catch (error) {
key = (await openpgp.key.read(new Uint8Array(await rawKeyData.clone().arrayBuffer()))).keys[0]
} catch(error) {
errorMsg = error.message
}
if (!key) {
try {
key = (await openpgp.key.readArmored(await rawKeyData.clone().text())).keys[0]
} catch (error) {
errorMsg = error.message
}
}
if (key) {
window.kx.key.object = key
return