Client UUID added to JWT

This commit is contained in:
Magnus Åhall 2025-01-12 17:35:29 +01:00
parent dfd6260a7a
commit dc010df448
6 changed files with 65 additions and 38 deletions

View file

@ -70,7 +70,6 @@ export class NodeStore {
this.sendQueue = new SimpleNodeStore(this.db, 'send_queue')
this.nodesHistory = new SimpleNodeStore(this.db, 'nodes_history')
this.initializeRootNode()
.then(() => this.initializeClientUUID())
.then(() => resolve())
}
@ -110,13 +109,6 @@ export class NodeStore {
getRequest.onerror = (event) => reject(event.target.error)
})
}//}}}
async initializeClientUUID() {//{{{
let clientUUID = await this.getAppState('client_uuid')
if (clientUUID !== null)
return
clientUUID = crypto.randomUUID()
return this.setAppState('client_uuid', clientUUID)
}//}}}
node(uuid, dataIfUndefined, newLevel) {//{{{
let n = this.nodes[uuid]

View file

@ -13,7 +13,6 @@ export class Sync {
// The latest sync node value is used to retrieve the changes
// from the backend.
const state = await nodeStore.getAppState('latest_sync_node')
const clientUUID = await nodeStore.getAppState('client_uuid')
const oldMax = (state?.value ? state.value : 0)
let currMax = oldMax
@ -22,7 +21,7 @@ export class Sync {
let batch = 0
do {
batch++
res = await API.query('POST', `/sync/from_server/${oldMax}/${offset}`, { ClientUUID: clientUUID.value })
res = await API.query('POST', `/sync/from_server/${oldMax}/${offset}`)
if (res.Nodes.length > 0)
console.log(`Node sync batch #${batch}`)
offset += res.Nodes.length
@ -96,10 +95,8 @@ export class Sync {
break
console.debug(`Sending ${nodesToSend.length} node(s) to server`)
const clientUUID = await nodeStore.getAppState('client_uuid')
const request = {
NodeData: JSON.stringify(nodesToSend),
ClientUUID: clientUUID.value,
}
const res = await API.query('POST', '/sync/to_server', request)
if (!res.OK) {