X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=ui%2Fweb%2Fsrc%2Fcomposables%2FUIClient.ts;h=9522c59213c666a526d48927447024f3e8fc065a;hb=7445d18b9b9ac750b9dc3dc3638d4fd0e8aff818;hp=fcbf191f3c9d2dabfc6fa6354359d703eb67e28b;hpb=276e05aec38f4e8b4a8d5ebd8cbbcb30592b414d;p=e-mobility-charging-stations-simulator.git diff --git a/ui/web/src/composables/UIClient.ts b/ui/web/src/composables/UIClient.ts index fcbf191f..9522c592 100644 --- a/ui/web/src/composables/UIClient.ts +++ b/ui/web/src/composables/UIClient.ts @@ -12,7 +12,7 @@ import { type UIServerConfigurationSection } from '@/types' -import { randomUUID } from './Utils' +import { randomUUID, validateUUID } from './Utils' type ResponseHandler = { procedureName: ProcedureName @@ -238,10 +238,10 @@ export class UIClient { private responseHandler(messageEvent: MessageEvent): void { let response: ProtocolResponse try { - response = JSON.parse(messageEvent.data) as ProtocolResponse + response = JSON.parse(messageEvent.data) } catch (error) { - useToast().error('Invalid response format') - console.error('Invalid response format', error) + useToast().error('Invalid response JSON format') + console.error('Invalid response JSON format', error) return } @@ -253,7 +253,11 @@ export class UIClient { const [uuid, responsePayload] = response - console.log('responsePayload', responsePayload.state?.templateStatistics) + if (!validateUUID(uuid)) { + useToast().error('Response UUID field is invalid') + console.error('Response UUID field is invalid:', response) + return + } if (this.responseHandlers.has(uuid)) { const { procedureName, resolve, reject } = this.responseHandlers.get(uuid)!