sunuid-sdk 1.0.42 → 1.0.43

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.
@@ -330,7 +330,6 @@
330
330
  */
331
331
  var SunuID = /*#__PURE__*/function () {
332
332
  function SunuID() {
333
- var _this = this;
334
333
  var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
335
334
  _classCallCheck(this, SunuID);
336
335
  this.config = _objectSpread2(_objectSpread2({}, DEFAULT_CONFIG), config);
@@ -340,13 +339,9 @@
340
339
  this.socket = null;
341
340
  this.initPromise = null;
342
341
 
343
- // Initialisation asynchrone seulement si autoInit est explicitement activé
344
- if (this.config.autoInit === true) {
345
- // Délai pour éviter les conflits avec d'autres scripts
346
- setTimeout(function () {
347
- _this.init();
348
- }, 100);
349
- }
342
+ // DÉSACTIVÉ : Initialisation automatique pour éviter les boucles
343
+ // L'utilisateur doit appeler init() manuellement
344
+ console.log('🔧 SDK SunuID créé - Appelez init() manuellement');
350
345
  }
351
346
 
352
347
  /**
@@ -357,7 +352,7 @@
357
352
  value: (function () {
358
353
  var _init = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
359
354
  return _regenerator().w(function (_context) {
360
- while (1) switch (_context.n) {
355
+ while (1) switch (_context.p = _context.n) {
361
356
  case 0:
362
357
  if (!this.isInitialized) {
363
358
  _context.n = 1;
@@ -373,10 +368,26 @@
373
368
  console.log('⚠️ Initialisation déjà en cours, attente...');
374
369
  return _context.a(2, this.initPromise);
375
370
  case 2:
371
+ if (!this._initInProgress) {
372
+ _context.n = 3;
373
+ break;
374
+ }
375
+ console.log('⚠️ Initialisation en cours, ignoré');
376
+ return _context.a(2);
377
+ case 3:
378
+ this._initInProgress = true;
376
379
  this.initPromise = this._doInit();
380
+ _context.p = 4;
381
+ _context.n = 5;
382
+ return this.initPromise;
383
+ case 5:
384
+ _context.p = 5;
385
+ this._initInProgress = false;
386
+ return _context.f(5);
387
+ case 6:
377
388
  return _context.a(2, this.initPromise);
378
389
  }
379
- }, _callee, this);
390
+ }, _callee, this, [[4,, 5, 6]]);
380
391
  }));
381
392
  function init() {
382
393
  return _init.apply(this, arguments);
@@ -596,14 +607,14 @@
596
607
  }, {
597
608
  key: "initWebSocket",
598
609
  value: function initWebSocket() {
599
- var _this2 = this;
610
+ var _this = this;
600
611
  try {
601
612
  // Vérifier si Socket.IO est disponible
602
613
  if (typeof io === 'undefined') {
603
614
  console.warn('⚠️ Socket.IO non disponible, WebSocket sera initialisé plus tard');
604
615
  // Réessayer après un délai
605
616
  setTimeout(function () {
606
- return _this2.initWebSocket();
617
+ return _this.initWebSocket();
607
618
  }, 1000);
608
619
  return;
609
620
  }
@@ -627,36 +638,36 @@
627
638
  // Gestion des événements WebSocket
628
639
  this.socket.on('connect', function () {
629
640
  console.log('🌐 WebSocket connecté avec succès');
630
- console.log('📊 Socket ID:', _this2.socket.id);
631
- _this2.socket.connected = true;
641
+ console.log('📊 Socket ID:', _this.socket.id);
642
+ _this.socket.connected = true;
632
643
  });
633
644
  this.socket.on('disconnect', function (reason) {
634
645
  console.log('❌ WebSocket déconnecté:', reason);
635
- _this2.socket.connected = false;
646
+ _this.socket.connected = false;
636
647
  });
637
648
  this.socket.on('connect_error', function (error) {
638
649
  console.error('❌ Erreur connexion WebSocket:', error);
639
- _this2.socket.connected = false;
650
+ _this.socket.connected = false;
640
651
  });
641
652
 
642
653
  // Écouter les événements spécifiques
643
654
  this.socket.on('qr_status_update', function (data) {
644
655
  console.log('📱 Mise à jour statut QR reçue:', data);
645
- _this2.handleQRStatusUpdate(data);
656
+ _this.handleQRStatusUpdate(data);
646
657
  });
647
658
  this.socket.on('qr_scan_success', function (data) {
648
659
  console.log('✅ Scan QR réussi reçu:', data);
649
- _this2.handleQRScanSuccess(data);
660
+ _this.handleQRScanSuccess(data);
650
661
  });
651
662
  this.socket.on('qr_expired', function (data) {
652
663
  console.log('⏰ QR expiré reçu:', data);
653
- _this2.handleQRExpired(data);
664
+ _this.handleQRExpired(data);
654
665
  });
655
666
 
656
667
  // Écouter l'événement qr_scan_initiated spécifiquement
657
668
  this.socket.on('qr_scan_initiated', function (data) {
658
669
  console.log('🔍 QR Scan Initiated reçu:', data);
659
- _this2.showQRLoader();
670
+ _this.showQRLoader();
660
671
  });
661
672
 
662
673
  // Écouter l'événement message générique (fallback)
@@ -664,7 +675,7 @@
664
675
  console.log('📨 Message socket reçu:', data);
665
676
  if (data && data.type === 'qr_scan_initiated') {
666
677
  console.log('🔍 QR Scan Initiated détecté dans message:', data);
667
- _this2.showQRLoader();
678
+ _this.showQRLoader();
668
679
  }
669
680
  });
670
681
 
@@ -1597,7 +1608,7 @@
1597
1608
  key: "generateQRClientSide",
1598
1609
  value: (function () {
1599
1610
  var _generateQRClientSide = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12(content, label, qrContainer) {
1600
- var _this3 = this;
1611
+ var _this2 = this;
1601
1612
  var canvas, ctx;
1602
1613
  return _regenerator().w(function (_context12) {
1603
1614
  while (1) switch (_context12.n) {
@@ -1644,13 +1655,13 @@
1644
1655
  var dataUrl = canvas.toDataURL('image/png');
1645
1656
 
1646
1657
  // Stocker l'URL
1647
- _this3.currentQRUrl = dataUrl;
1658
+ _this2.currentQRUrl = dataUrl;
1648
1659
 
1649
1660
  // Afficher le QR code
1650
1661
  qrContainer.innerHTML = "\n <div style=\"text-align: center; padding: 20px;\">\n <img src=\"".concat(dataUrl, "\" alt=\"QR Code\" style=\"max-width: 300px; border: 2px solid #ddd; border-radius: 10px;\">\n </div>\n ");
1651
1662
 
1652
1663
  // Afficher les instructions
1653
- _this3.showQRInstructions(qrContainer);
1664
+ _this2.showQRInstructions(qrContainer);
1654
1665
  resolve();
1655
1666
  });
1656
1667
  }));
@@ -1960,7 +1971,7 @@
1960
1971
  }, {
1961
1972
  key: "startAutoRefresh",
1962
1973
  value: function startAutoRefresh(containerId, type, options) {
1963
- var _this4 = this;
1974
+ var _this3 = this;
1964
1975
  if (!this.config.autoRefresh) return;
1965
1976
 
1966
1977
  // Arrêter le timer existant s'il y en a un
@@ -1976,7 +1987,7 @@
1976
1987
  _context16.p = 0;
1977
1988
  console.log('🔄 Rafraîchissement automatique du QR code...');
1978
1989
  _context16.n = 1;
1979
- return _this4.refreshQR(containerId, type, options);
1990
+ return _this3.refreshQR(containerId, type, options);
1980
1991
  case 1:
1981
1992
  _context16.n = 3;
1982
1993
  break;
@@ -2005,7 +2016,7 @@
2005
2016
  var _makeRequest = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17(endpoint, data) {
2006
2017
  var _window$SunuIDConfig4,
2007
2018
  _window$SunuIDConfig5,
2008
- _this5 = this;
2019
+ _this4 = this;
2009
2020
  var sanitizedData, endpointPath, url, retryCount, maxRetries, _loop, _ret;
2010
2021
  return _regenerator().w(function (_context18) {
2011
2022
  while (1) switch (_context18.n) {
@@ -2068,7 +2079,7 @@
2068
2079
  controller = new AbortController();
2069
2080
  timeoutId = setTimeout(function () {
2070
2081
  return controller.abort();
2071
- }, _this5.config.requestTimeout); // Headers minimaux (API SunuID n'accepte que les headers essentiels)
2082
+ }, _this4.config.requestTimeout); // Headers minimaux (API SunuID n'accepte que les headers essentiels)
2072
2083
  headers = {
2073
2084
  'Content-Type': 'application/json'
2074
2085
  }; // Note: En mode sécurisé, les credentials sont dans le body
@@ -2101,7 +2112,7 @@
2101
2112
  message: errorText
2102
2113
  };
2103
2114
  }
2104
- _this5.logSecurityEvent('API_REQUEST_ERROR', {
2115
+ _this4.logSecurityEvent('API_REQUEST_ERROR', {
2105
2116
  status: response.status,
2106
2117
  statusText: response.statusText,
2107
2118
  error: errorData.message
@@ -2112,7 +2123,7 @@
2112
2123
  return response.json();
2113
2124
  case 4:
2114
2125
  result = _context17.v;
2115
- _this5.logSecurityEvent('API_REQUEST_SUCCESS', {
2126
+ _this4.logSecurityEvent('API_REQUEST_SUCCESS', {
2116
2127
  endpoint: endpointPath,
2117
2128
  responseKeys: Object.keys(result)
2118
2129
  });
@@ -2127,7 +2138,7 @@
2127
2138
  _context17.n = 7;
2128
2139
  break;
2129
2140
  }
2130
- _this5.logSecurityEvent('API_REQUEST_TIMEOUT', {
2141
+ _this4.logSecurityEvent('API_REQUEST_TIMEOUT', {
2131
2142
  retryCount: retryCount
2132
2143
  });
2133
2144
  if (!(retryCount > maxRetries)) {
@@ -2142,7 +2153,7 @@
2142
2153
  _context17.n = 8;
2143
2154
  break;
2144
2155
  }
2145
- _this5.logSecurityEvent('API_REQUEST_MAX_RETRIES', {
2156
+ _this4.logSecurityEvent('API_REQUEST_MAX_RETRIES', {
2146
2157
  retryCount: retryCount,
2147
2158
  error: _t11.message
2148
2159
  });