sunuid-sdk 1.0.44 → 1.0.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -856,15 +856,18 @@ function _unsupportedIterableToArray(r, a) {
856
856
  value: function handleQRScanSuccess(data) {
857
857
  console.log('✅ QR Scan Success reçu:', data);
858
858
  try {
859
+ // Extraire les données d'authentification du format WebSocket
860
+ var authData = this.extractAuthDataFromWebSocket(data);
861
+
859
862
  // Traiter l'authentification comme un callback
860
- this.processAuthentication(data);
863
+ this.processAuthentication(authData);
861
864
 
862
865
  // Afficher un message de succès
863
- this.showSuccessMessage(data);
866
+ this.showSuccessMessage(authData);
864
867
 
865
868
  // Appeler le callback de succès (pour compatibilité)
866
869
  if (this.config.onSuccess) {
867
- this.config.onSuccess(data);
870
+ this.config.onSuccess(authData);
868
871
  }
869
872
  console.log('✅ Authentification WebSocket traitée avec succès');
870
873
  } catch (error) {
@@ -2593,6 +2596,53 @@ function _unsupportedIterableToArray(r, a) {
2593
2596
  console.log('✅ Loader affiché avec succès');
2594
2597
  }
2595
2598
 
2599
+ /**
2600
+ * Extraire les données d'authentification du format WebSocket
2601
+ */
2602
+ }, {
2603
+ key: "extractAuthDataFromWebSocket",
2604
+ value: function extractAuthDataFromWebSocket(websocketData) {
2605
+ console.log('🔍 Extraction des données d\'authentification du WebSocket:', websocketData);
2606
+
2607
+ // Si les données sont déjà dans le bon format (callback), les retourner directement
2608
+ if (websocketData.token && websocketData.session_id) {
2609
+ console.log('✅ Données déjà au bon format (callback)');
2610
+ return websocketData;
2611
+ }
2612
+
2613
+ // Si c'est un format WebSocket, extraire les données de responseData
2614
+ if (websocketData.responseData) {
2615
+ console.log('✅ Format WebSocket détecté, extraction de responseData');
2616
+ var authData = {
2617
+ token: websocketData.responseData.token || websocketData.responseData.auth_token,
2618
+ session_id: websocketData.responseData.session_id || websocketData.responseData.sessionId,
2619
+ user_id: websocketData.responseData.user_id || websocketData.responseData.userId,
2620
+ partner_id: websocketData.responseData.partner_id || websocketData.responseData.partnerId,
2621
+ type: websocketData.responseData.type,
2622
+ timestamp: websocketData.responseData.timestamp || websocketData.timestamp,
2623
+ signature: websocketData.responseData.signature,
2624
+ user_info: websocketData.responseData.user_info || websocketData.responseData.userInfo,
2625
+ redirect_url: websocketData.responseData.redirect_url || websocketData.responseData.redirectUrl
2626
+ };
2627
+ console.log('📋 Données d\'authentification extraites:', authData);
2628
+ return authData;
2629
+ }
2630
+
2631
+ // Fallback : essayer d'extraire directement des champs principaux
2632
+ console.log('⚠️ Format non reconnu, tentative d\'extraction directe');
2633
+ return {
2634
+ token: websocketData.token || websocketData.auth_token,
2635
+ session_id: websocketData.session_id || websocketData.sessionId,
2636
+ user_id: websocketData.user_id || websocketData.userId,
2637
+ partner_id: websocketData.partner_id || websocketData.partnerId,
2638
+ type: websocketData.type,
2639
+ timestamp: websocketData.timestamp,
2640
+ signature: websocketData.signature,
2641
+ user_info: websocketData.user_info || websocketData.userInfo,
2642
+ redirect_url: websocketData.redirect_url || websocketData.redirectUrl
2643
+ };
2644
+ }
2645
+
2596
2646
  /**
2597
2647
  * Afficher un message de succès après authentification
2598
2648
  */