sunuid-sdk 1.0.43 → 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.
@@ -854,9 +854,29 @@ function _unsupportedIterableToArray(r, a) {
854
854
  }, {
855
855
  key: "handleQRScanSuccess",
856
856
  value: function handleQRScanSuccess(data) {
857
- console.log('✅ QR Scan Success:', data);
858
- if (this.config.onSuccess) {
859
- this.config.onSuccess(data);
857
+ console.log('✅ QR Scan Success reçu:', data);
858
+ try {
859
+ // Extraire les données d'authentification du format WebSocket
860
+ var authData = this.extractAuthDataFromWebSocket(data);
861
+
862
+ // Traiter l'authentification comme un callback
863
+ this.processAuthentication(authData);
864
+
865
+ // Afficher un message de succès
866
+ this.showSuccessMessage(authData);
867
+
868
+ // Appeler le callback de succès (pour compatibilité)
869
+ if (this.config.onSuccess) {
870
+ this.config.onSuccess(authData);
871
+ }
872
+ console.log('✅ Authentification WebSocket traitée avec succès');
873
+ } catch (error) {
874
+ console.error('❌ Erreur lors du traitement WebSocket:', error);
875
+
876
+ // Appeler le callback d'erreur
877
+ if (this.config.onAuthenticationError) {
878
+ this.config.onAuthenticationError(error, data);
879
+ }
860
880
  }
861
881
  }
862
882
 
@@ -2576,6 +2596,84 @@ function _unsupportedIterableToArray(r, a) {
2576
2596
  console.log('✅ Loader affiché avec succès');
2577
2597
  }
2578
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
+
2646
+ /**
2647
+ * Afficher un message de succès après authentification
2648
+ */
2649
+ }, {
2650
+ key: "showSuccessMessage",
2651
+ value: function showSuccessMessage(data) {
2652
+ console.log('✅ Affichage du message de succès');
2653
+
2654
+ // Chercher le conteneur QR dans différents IDs possibles
2655
+ var containerIds = ['qr-area', 'qr-container', 'sunuid-qr-container'];
2656
+ var container = null;
2657
+ for (var _i3 = 0, _containerIds2 = containerIds; _i3 < _containerIds2.length; _i3++) {
2658
+ var id = _containerIds2[_i3];
2659
+ container = document.getElementById(id);
2660
+ if (container) break;
2661
+ }
2662
+ if (!container) {
2663
+ console.warn('⚠️ Conteneur QR non trouvé pour afficher le message de succès');
2664
+ return;
2665
+ }
2666
+
2667
+ // Extraire les informations utilisateur
2668
+ var userInfo = data.user_info || {};
2669
+ var userName = userInfo.name || userInfo.username || 'Utilisateur';
2670
+ var userEmail = userInfo.email || '';
2671
+
2672
+ // Remplacer le contenu par un message de succès
2673
+ container.innerHTML = "\n <div style=\"\n text-align: center;\n padding: 40px 20px;\n background: #d4edda;\n border: 2px solid #28a745;\n border-radius: 10px;\n color: #155724;\n font-family: Arial, sans-serif;\n \">\n <div style=\"\n width: 60px;\n height: 60px;\n background: #28a745;\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n margin: 0 auto 20px auto;\n font-size: 30px;\n color: white;\n \">\u2705</div>\n <h3 style=\"margin: 0 0 10px 0; color: #155724;\">\uD83C\uDF89 Authentification r\xE9ussie !</h3>\n <p style=\"margin: 0 0 15px 0; font-size: 16px; font-weight: bold;\">\n Bienvenue, ".concat(userName, " !\n </p>\n ").concat(userEmail ? "<p style=\"margin: 0 0 15px 0; font-size: 14px; color: #6c757d;\">".concat(userEmail, "</p>") : '', "\n <p style=\"margin: 0; font-size: 14px;\">\n Votre identit\xE9 a \xE9t\xE9 v\xE9rifi\xE9e avec succ\xE8s.\n </p>\n <div style=\"margin-top: 20px; font-size: 12px; color: #6c757d;\">\n \uD83D\uDD04 Redirection en cours...\n </div>\n </div>\n ");
2674
+ console.log('✅ Message de succès affiché');
2675
+ }
2676
+
2579
2677
  /**
2580
2678
  * Gérer le callback SunuID
2581
2679
  */