From e6df9cbba002c9bfcb5fc2204e0a2ff50aade28b Mon Sep 17 00:00:00 2001 From: Sosthene Date: Thu, 11 Sep 2025 08:54:50 +0200 Subject: [PATCH] [Auth] Add clientAuth to build request to back --- src/front/Api/Auth/Customer/Auth.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/front/Api/Auth/Customer/Auth.ts b/src/front/Api/Auth/Customer/Auth.ts index edb9a53d..05684f10 100644 --- a/src/front/Api/Auth/Customer/Auth.ts +++ b/src/front/Api/Auth/Customer/Auth.ts @@ -115,4 +115,31 @@ export default class Auth extends BaseApiService { return Promise.reject(err); } } + + public async clientAuth(body: IClientAuthParams): Promise { + // Construct the full URL for the client-auth endpoint + // This endpoint is at /api/v1/client-auth, not part of the customer auth namespace + const url = new URL(this.baseURl.concat("/client-auth")); + try { + // Create custom headers for this specific endpoint + const headers = new Headers(); + headers.set("Content-Type", "application/json"); + headers.set("x-session-id", body.sessionId); + + const response = await fetch(url, { + method: "POST", + headers, + body: JSON.stringify({ pairingId: body.pairingId }) + }); + + if (!response.ok) { + throw new Error(`HTTP error! status: ${response.status}`); + } + + return await response.json(); + } catch (err) { + this.onError(err); + return Promise.reject(err); + } + } }