sunuid-sdk 1.0.34 → 1.0.35

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,19 @@
593
597
  console.log('⏰ QR expiré reçu:', data);
594
598
  _this.handleQRExpired(data);
595
599
  });
600
+
601
+ // Écouter tous les événements socket pour les logger
602
+ this.socket.onAny(function (eventName) {
603
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
604
+ args[_key - 1] = arguments[_key];
605
+ }
606
+ console.log("\uD83C\uDF10 Socket Event [".concat(eventName, "]:"), args);
607
+
608
+ // Si c'est un événement qr_scan_initiated, afficher le loader
609
+ if (eventName === 'qr_scan_initiated') {
610
+ _this.showQRLoader();
611
+ }
612
+ });
596
613
  } else {
597
614
  console.log('🌐 WebSocket déjà connecté');
598
615
  }
@@ -746,6 +763,7 @@
746
763
  }, {
747
764
  key: "handleQRStatusUpdate",
748
765
  value: function handleQRStatusUpdate(data) {
766
+ console.log('📱 QR Status Update:', data);
749
767
  if (this.config.onStatusUpdate) {
750
768
  this.config.onStatusUpdate(data);
751
769
  }
@@ -757,6 +775,7 @@
757
775
  }, {
758
776
  key: "handleQRScanSuccess",
759
777
  value: function handleQRScanSuccess(data) {
778
+ console.log('✅ QR Scan Success:', data);
760
779
  if (this.config.onSuccess) {
761
780
  this.config.onSuccess(data);
762
781
  }
@@ -768,6 +787,7 @@
768
787
  }, {
769
788
  key: "handleQRExpired",
770
789
  value: function handleQRExpired(data) {
790
+ console.log('⏰ QR Expired:', data);
771
791
  if (this.config.onExpired) {
772
792
  this.config.onExpired(data);
773
793
  }
@@ -2407,6 +2427,32 @@
2407
2427
  window.SunuIDSecurityLogs = [];
2408
2428
  this.logSecurityEvent('SECURITY_LOGS_CLEARED');
2409
2429
  }
2430
+
2431
+ /**
2432
+ * Afficher un loader pendant le scan du QR code
2433
+ */
2434
+ }, {
2435
+ key: "showQRLoader",
2436
+ value: function showQRLoader() {
2437
+ console.log('🔄 Affichage du loader - Scan QR initié');
2438
+
2439
+ // Chercher le conteneur QR dans différents IDs possibles
2440
+ var containerIds = ['qr-area', 'qr-container', 'sunuid-qr-container'];
2441
+ var container = null;
2442
+ for (var _i2 = 0, _containerIds = containerIds; _i2 < _containerIds.length; _i2++) {
2443
+ var id = _containerIds[_i2];
2444
+ container = document.getElementById(id);
2445
+ if (container) break;
2446
+ }
2447
+ if (!container) {
2448
+ console.warn('⚠️ Conteneur QR non trouvé pour afficher le loader');
2449
+ return;
2450
+ }
2451
+
2452
+ // Remplacer le contenu par un loader animé
2453
+ 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 ";
2454
+ console.log('✅ Loader affiché avec succès');
2455
+ }
2410
2456
  }]);
2411
2457
  }(); // Exposer la classe globalement
2412
2458
  window.SunuID = SunuID;