mirror of
https://github.com/Qortal/qortal-ui.git
synced 2025-02-11 17:55:51 +00:00
Reworked get latest symmetric keyfile
This commit is contained in:
parent
e9ab20a451
commit
6debf5fd72
@ -2866,13 +2866,15 @@ class GroupManagement extends LitElement {
|
|||||||
|
|
||||||
let data
|
let data
|
||||||
let supArray = []
|
let supArray = []
|
||||||
|
let allSymKeys = []
|
||||||
let gAdmin = ''
|
let gAdmin = ''
|
||||||
let gAddress = ''
|
let gAddress = ''
|
||||||
|
let keysToOld = "Wait until an admin re-encrypts the keys. Only unencrypted messages will be displayed."
|
||||||
|
|
||||||
const symIdentifier = 'symmetric-qchat-group-' + groupId
|
const symIdentifier = 'symmetric-qchat-group-' + groupId
|
||||||
const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]
|
const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]
|
||||||
const nodeUrl = myNode.protocol + '://' + myNode.domain + ':' + myNode.port
|
const nodeUrl = myNode.protocol + '://' + myNode.domain + ':' + myNode.port
|
||||||
const getNameUrl = `${nodeUrl}/arbitrary/resources?service=DOCUMENT_PRIVATE&identifier=${symIdentifier}&limit=1&reverse=true`
|
const getNameUrl = `${nodeUrl}/arbitrary/resources?service=DOCUMENT_PRIVATE&identifier=${symIdentifier}&limit=0&reverse=true`
|
||||||
const getAdminUrl = `${nodeUrl}/groups/members/${groupId}?onlyAdmins=true&limit=20`
|
const getAdminUrl = `${nodeUrl}/groups/members/${groupId}?onlyAdmins=true&limit=20`
|
||||||
|
|
||||||
supArray = await fetch(getNameUrl).then(response => {
|
supArray = await fetch(getNameUrl).then(response => {
|
||||||
@ -2882,10 +2884,21 @@ class GroupManagement extends LitElement {
|
|||||||
if (this.isEmptyArray(supArray) || groupId === 0) {
|
if (this.isEmptyArray(supArray) || groupId === 0) {
|
||||||
console.log("No Symetric Key")
|
console.log("No Symetric Key")
|
||||||
} else {
|
} else {
|
||||||
supArray.map(item => {
|
supArray.forEach(item => {
|
||||||
gAdmin = item.name
|
const symInfoObj = {
|
||||||
|
name: item.name,
|
||||||
|
identifier: item.identifier,
|
||||||
|
timestamp: item.updated ? item.updated : item.created
|
||||||
|
}
|
||||||
|
allSymKeys.push(symInfoObj)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
let allSymKeysSorted = allSymKeys.sort(function(a, b) {
|
||||||
|
return b.timestamp - a.timestamp
|
||||||
|
})
|
||||||
|
|
||||||
|
gAdmin = allSymKeysSorted[0].name
|
||||||
|
|
||||||
const addressUrl = `${nodeUrl}/names/${gAdmin}`
|
const addressUrl = `${nodeUrl}/names/${gAdmin}`
|
||||||
|
|
||||||
let addressObject = await fetch(addressUrl).then(response => {
|
let addressObject = await fetch(addressUrl).then(response => {
|
||||||
@ -2913,6 +2926,10 @@ class GroupManagement extends LitElement {
|
|||||||
data = await res.text()
|
data = await res.text()
|
||||||
|
|
||||||
const decryptedKey = await this.decryptGroupEncryption(data)
|
const decryptedKey = await this.decryptGroupEncryption(data)
|
||||||
|
|
||||||
|
if (decryptedKey === undefined) {
|
||||||
|
parentEpml.request('showSnackBar', `${keysToOld}`)
|
||||||
|
} else {
|
||||||
const dataint8Array = base64ToUint8Array(decryptedKey.data)
|
const dataint8Array = base64ToUint8Array(decryptedKey.data)
|
||||||
const decryptedKeyToObject = uint8ArrayToObject(dataint8Array)
|
const decryptedKeyToObject = uint8ArrayToObject(dataint8Array)
|
||||||
|
|
||||||
@ -2924,6 +2941,7 @@ class GroupManagement extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async decryptGroupEncryption(data) {
|
async decryptGroupEncryption(data) {
|
||||||
try {
|
try {
|
||||||
|
@ -447,6 +447,7 @@ class Chat extends LitElement {
|
|||||||
|
|
||||||
let data
|
let data
|
||||||
let supArray = []
|
let supArray = []
|
||||||
|
let allSymKeys = []
|
||||||
let gAdmin = ''
|
let gAdmin = ''
|
||||||
let gAddress = ''
|
let gAddress = ''
|
||||||
let currentGroupId = url.substring(6)
|
let currentGroupId = url.substring(6)
|
||||||
@ -456,7 +457,7 @@ class Chat extends LitElement {
|
|||||||
|
|
||||||
const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]
|
const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]
|
||||||
const nodeUrl = myNode.protocol + '://' + myNode.domain + ':' + myNode.port
|
const nodeUrl = myNode.protocol + '://' + myNode.domain + ':' + myNode.port
|
||||||
const getNameUrl = `${nodeUrl}/arbitrary/resources?service=DOCUMENT_PRIVATE&identifier=${symIdentifier}&limit=1&reverse=true`
|
const getNameUrl = `${nodeUrl}/arbitrary/resources?service=DOCUMENT_PRIVATE&identifier=${symIdentifier}&limit=0&reverse=true`
|
||||||
const getAdminUrl = `${nodeUrl}/groups/members/${currentGroupId}?onlyAdmins=true&limit=20`
|
const getAdminUrl = `${nodeUrl}/groups/members/${currentGroupId}?onlyAdmins=true&limit=20`
|
||||||
|
|
||||||
if (localStorage.getItem("symKeysCurrent") === null) {
|
if (localStorage.getItem("symKeysCurrent") === null) {
|
||||||
@ -473,10 +474,21 @@ class Chat extends LitElement {
|
|||||||
} else {
|
} else {
|
||||||
parentEpml.request('showSnackBar', `${locateString}`)
|
parentEpml.request('showSnackBar', `${locateString}`)
|
||||||
|
|
||||||
supArray.map(item => {
|
supArray.forEach(item => {
|
||||||
gAdmin = item.name
|
const symInfoObj = {
|
||||||
|
name: item.name,
|
||||||
|
identifier: item.identifier,
|
||||||
|
timestamp: item.updated ? item.updated : item.created
|
||||||
|
}
|
||||||
|
allSymKeys.push(symInfoObj)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
let allSymKeysSorted = allSymKeys.sort(function(a, b) {
|
||||||
|
return b.timestamp - a.timestamp
|
||||||
|
})
|
||||||
|
|
||||||
|
gAdmin = allSymKeysSorted[0].name
|
||||||
|
|
||||||
const addressUrl = `${nodeUrl}/names/${gAdmin}`
|
const addressUrl = `${nodeUrl}/names/${gAdmin}`
|
||||||
|
|
||||||
let addressObject = await fetch(addressUrl).then(response => {
|
let addressObject = await fetch(addressUrl).then(response => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user