sunuid-sdk 1.0.34 → 1.0.36

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.
@@ -291,6 +291,8 @@
291
291
  // Désactivé par défaut pour éviter les appels répétitifs
292
292
  refreshInterval: 30000,
293
293
  // 30 secondes
294
+ autoInit: true,
295
+ // Initialisation automatique par défaut
294
296
  onSuccess: null,
295
297
  onError: null,
296
298
  onStatusUpdate: null,
@@ -328,8 +330,10 @@
328
330
  this.isInitialized = false;
329
331
  this.socket = null;
330
332
 
331
- // Initialisation asynchrone
332
- this.initPromise = this.init();
333
+ // Initialisation asynchrone seulement si autoInit est activé
334
+ if (this.config.autoInit !== false) {
335
+ this.initPromise = this.init();
336
+ }
333
337
  }
334
338
 
335
339
  /**
@@ -593,6 +597,35 @@
593
597
  console.log('⏰ QR expiré reçu:', data);
594
598
  _this.handleQRExpired(data);
595
599
  });
600
+
601
+ // Écouter l'événement qr_scan_initiated spécifiquement
602
+ this.socket.on('qr_scan_initiated', function (data) {
603
+ console.log('🔍 QR Scan Initiated reçu:', data);
604
+ _this.showQRLoader();
605
+ });
606
+
607
+ // Écouter l'événement message générique (fallback)
608
+ this.socket.on('message', function (data) {
609
+ console.log('📨 Message socket reçu:', data);
610
+ if (data && data.type === 'qr_scan_initiated') {
611
+ console.log('🔍 QR Scan Initiated détecté dans message:', data);
612
+ _this.showQRLoader();
613
+ }
614
+ });
615
+
616
+ // Écouter tous les événements socket pour le debugging
617
+ this.socket.onAny = this.socket.onAny || function (eventName, callback) {
618
+ // Fallback pour les versions de Socket.IO qui n'ont pas onAny
619
+ console.log("\uD83C\uDF10 Socket Event [".concat(eventName, "]:"), callback);
620
+ };
621
+
622
+ // Logger tous les événements reçus
623
+ this.socket.onAny(function (eventName) {
624
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
625
+ args[_key - 1] = arguments[_key];
626
+ }
627
+ console.log("\uD83C\uDF10 Socket Event [".concat(eventName, "]:"), args);
628
+ });
596
629
  } else {
597
630
  console.log('🌐 WebSocket déjà connecté');
598
631
  }
@@ -746,6 +779,7 @@
746
779
  }, {
747
780
  key: "handleQRStatusUpdate",
748
781
  value: function handleQRStatusUpdate(data) {
782
+ console.log('📱 QR Status Update:', data);
749
783
  if (this.config.onStatusUpdate) {
750
784
  this.config.onStatusUpdate(data);
751
785
  }
@@ -757,6 +791,7 @@
757
791
  }, {
758
792
  key: "handleQRScanSuccess",
759
793
  value: function handleQRScanSuccess(data) {
794
+ console.log('✅ QR Scan Success:', data);
760
795
  if (this.config.onSuccess) {
761
796
  this.config.onSuccess(data);
762
797
  }
@@ -768,6 +803,7 @@
768
803
  }, {
769
804
  key: "handleQRExpired",
770
805
  value: function handleQRExpired(data) {
806
+ console.log('⏰ QR Expired:', data);
771
807
  if (this.config.onExpired) {
772
808
  this.config.onExpired(data);
773
809
  }
@@ -2407,6 +2443,32 @@
2407
2443
  window.SunuIDSecurityLogs = [];
2408
2444
  this.logSecurityEvent('SECURITY_LOGS_CLEARED');
2409
2445
  }
2446
+
2447
+ /**
2448
+ * Afficher un loader pendant le scan du QR code
2449
+ */
2450
+ }, {
2451
+ key: "showQRLoader",
2452
+ value: function showQRLoader() {
2453
+ console.log('🔄 Affichage du loader - Scan QR initié');
2454
+
2455
+ // Chercher le conteneur QR dans différents IDs possibles
2456
+ var containerIds = ['qr-area', 'qr-container', 'sunuid-qr-container'];
2457
+ var container = null;
2458
+ for (var _i2 = 0, _containerIds = containerIds; _i2 < _containerIds.length; _i2++) {
2459
+ var id = _containerIds[_i2];
2460
+ container = document.getElementById(id);
2461
+ if (container) break;
2462
+ }
2463
+ if (!container) {
2464
+ console.warn('⚠️ Conteneur QR non trouvé pour afficher le loader');
2465
+ return;
2466
+ }
2467
+
2468
+ // Remplacer le contenu par un loader animé
2469
+ container.innerHTML = "\n <div style=\"\n text-align: center;\n padding: 40px 20px;\n background: #f8f9fa;\n border: 2px solid #007bff;\n border-radius: 10px;\n color: #007bff;\n font-family: Arial, sans-serif;\n \">\n <div style=\"\n width: 60px;\n height: 60px;\n border: 4px solid #e3f2fd;\n border-top: 4px solid #007bff;\n border-radius: 50%;\n animation: spin 1s linear infinite;\n margin: 0 auto 20px auto;\n \"></div>\n <h3 style=\"margin: 0 0 10px 0; color: #007bff;\">\uD83D\uDD0D Scan en cours...</h3>\n <p style=\"margin: 0; font-size: 14px;\">\n Veuillez patienter pendant la v\xE9rification de votre identit\xE9.\n </p>\n <div style=\"margin-top: 15px; font-size: 12px; color: #6c757d;\">\n \u23F1\uFE0F Traitement en cours...\n </div>\n </div>\n <style>\n @keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n </style>\n ";
2470
+ console.log('✅ Loader affiché avec succès');
2471
+ }
2410
2472
  }]);
2411
2473
  }(); // Exposer la classe globalement
2412
2474
  window.SunuID = SunuID;