Compare commits
No commits in common. "085b315883ea50483b4e3e427b6e4625d62ef292" and "28db1ae9251a8d1d13b4f2a8fc622ca025f32e9e" have entirely different histories.
085b315883
...
28db1ae925
@ -699,11 +699,12 @@ export class Service {
|
||||
const data: Record<string, any> = {};
|
||||
// Now we decrypt all we can in the processes
|
||||
for (const [processId, process] of Object.entries(filteredProcesses)) {
|
||||
console.log('process roles:', this.getRoles(process));
|
||||
// We also take the public data
|
||||
let lastState = this.getLastCommitedState(process);
|
||||
const lastState = this.getLastCommitedState(process);
|
||||
if (!lastState) {
|
||||
// fallback on the first state
|
||||
lastState = process.states[0];
|
||||
console.error(`❌ Process ${processId} doesn't have a commited state`);
|
||||
continue;
|
||||
}
|
||||
const processData: Record<string, any> = {};
|
||||
for (const attribute of Object.keys(lastState.public_data)) {
|
||||
@ -1294,7 +1295,7 @@ export class Service {
|
||||
if (clear) {
|
||||
// deserialize the result to get the actual data
|
||||
const decoded = wasm.decode_value(clear);
|
||||
return this.convertMapsToObjects(decoded);
|
||||
return decoded;
|
||||
} else {
|
||||
throw new Error('decrypt_data returned null');
|
||||
}
|
||||
@ -1309,49 +1310,13 @@ export class Service {
|
||||
|
||||
decodeValue(value: number[]): any | null {
|
||||
try {
|
||||
const decoded = wasm.decode_value(new Uint8Array(value));
|
||||
return this.convertMapsToObjects(decoded);
|
||||
return wasm.decode_value(new Uint8Array(value));
|
||||
} catch (e) {
|
||||
console.error(`Failed to decode value: ${e}`);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convertit récursivement les Map en objets sérialisables
|
||||
*/
|
||||
private convertMapsToObjects(obj: any): any {
|
||||
if (obj === null || obj === undefined) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
if (obj instanceof Map) {
|
||||
const result: any = {};
|
||||
for (const [key, value] of obj.entries()) {
|
||||
result[key] = this.convertMapsToObjects(value);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
if (obj instanceof Set) {
|
||||
return Array.from(obj).map(item => this.convertMapsToObjects(item));
|
||||
}
|
||||
|
||||
if (Array.isArray(obj)) {
|
||||
return obj.map(item => this.convertMapsToObjects(item));
|
||||
}
|
||||
|
||||
if (typeof obj === 'object') {
|
||||
const result: any = {};
|
||||
for (const [key, value] of Object.entries(obj)) {
|
||||
result[key] = this.convertMapsToObjects(value);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
public async updateDevice(): Promise<void> {
|
||||
let myPairingProcessId: string;
|
||||
try {
|
||||
|
Loading…
x
Reference in New Issue
Block a user