Compare commits
2 Commits
28db1ae925
...
085b315883
Author | SHA1 | Date | |
---|---|---|---|
![]() |
085b315883 | ||
![]() |
c630aa8079 |
@ -699,12 +699,11 @@ export class Service {
|
|||||||
const data: Record<string, any> = {};
|
const data: Record<string, any> = {};
|
||||||
// Now we decrypt all we can in the processes
|
// Now we decrypt all we can in the processes
|
||||||
for (const [processId, process] of Object.entries(filteredProcesses)) {
|
for (const [processId, process] of Object.entries(filteredProcesses)) {
|
||||||
console.log('process roles:', this.getRoles(process));
|
|
||||||
// We also take the public data
|
// We also take the public data
|
||||||
const lastState = this.getLastCommitedState(process);
|
let lastState = this.getLastCommitedState(process);
|
||||||
if (!lastState) {
|
if (!lastState) {
|
||||||
console.error(`❌ Process ${processId} doesn't have a commited state`);
|
// fallback on the first state
|
||||||
continue;
|
lastState = process.states[0];
|
||||||
}
|
}
|
||||||
const processData: Record<string, any> = {};
|
const processData: Record<string, any> = {};
|
||||||
for (const attribute of Object.keys(lastState.public_data)) {
|
for (const attribute of Object.keys(lastState.public_data)) {
|
||||||
@ -1295,7 +1294,7 @@ export class Service {
|
|||||||
if (clear) {
|
if (clear) {
|
||||||
// deserialize the result to get the actual data
|
// deserialize the result to get the actual data
|
||||||
const decoded = wasm.decode_value(clear);
|
const decoded = wasm.decode_value(clear);
|
||||||
return decoded;
|
return this.convertMapsToObjects(decoded);
|
||||||
} else {
|
} else {
|
||||||
throw new Error('decrypt_data returned null');
|
throw new Error('decrypt_data returned null');
|
||||||
}
|
}
|
||||||
@ -1310,13 +1309,49 @@ export class Service {
|
|||||||
|
|
||||||
decodeValue(value: number[]): any | null {
|
decodeValue(value: number[]): any | null {
|
||||||
try {
|
try {
|
||||||
return wasm.decode_value(new Uint8Array(value));
|
const decoded = wasm.decode_value(new Uint8Array(value));
|
||||||
|
return this.convertMapsToObjects(decoded);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(`Failed to decode value: ${e}`);
|
console.error(`Failed to decode value: ${e}`);
|
||||||
return null;
|
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> {
|
public async updateDevice(): Promise<void> {
|
||||||
let myPairingProcessId: string;
|
let myPairingProcessId: string;
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user