sunuid-sdk 1.0.40 → 1.0.42

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.
@@ -288,8 +288,8 @@ function _unsupportedIterableToArray(r, a) {
288
288
  // Désactivé par défaut pour éviter les appels répétitifs
289
289
  refreshInterval: 30000,
290
290
  // 30 secondes
291
- autoInit: true,
292
- // Initialisation automatique par défaut
291
+ autoInit: false,
292
+ // Désactivé par défaut pour éviter les boucles
293
293
  onSuccess: null,
294
294
  onError: null,
295
295
  onStatusUpdate: null,
@@ -311,7 +311,15 @@ function _unsupportedIterableToArray(r, a) {
311
311
  token: null,
312
312
  // Configuration pour forcer l'utilisation du serveur distant
313
313
  forceRemoteServer: true,
314
- useLocalFallback: false
314
+ useLocalFallback: false,
315
+ // Nouvelles options pour les callbacks
316
+ redirectAfterSuccess: null,
317
+ verifySignature: false,
318
+ tokenMaxAge: 300,
319
+ // 5 minutes par défaut
320
+ onAuthenticationSuccess: null,
321
+ onAuthenticationError: null,
322
+ state: null
315
323
  };
316
324
 
317
325
  /**
@@ -319,6 +327,7 @@ function _unsupportedIterableToArray(r, a) {
319
327
  */
320
328
  var SunuID = /*#__PURE__*/function () {
321
329
  function SunuID() {
330
+ var _this = this;
322
331
  var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
323
332
  _classCallCheck(this, SunuID);
324
333
  this.config = _objectSpread2(_objectSpread2({}, DEFAULT_CONFIG), config);
@@ -326,10 +335,14 @@ function _unsupportedIterableToArray(r, a) {
326
335
  this.refreshTimer = null;
327
336
  this.isInitialized = false;
328
337
  this.socket = null;
329
-
330
- // Initialisation asynchrone seulement si autoInit est activé
331
- if (this.config.autoInit !== false) {
332
- this.initPromise = this.init();
338
+ this.initPromise = null;
339
+
340
+ // Initialisation asynchrone seulement si autoInit est explicitement activé
341
+ if (this.config.autoInit === true) {
342
+ // Délai pour éviter les conflits avec d'autres scripts
343
+ setTimeout(function () {
344
+ _this.init();
345
+ }, 100);
333
346
  }
334
347
  }
335
348
 
@@ -340,26 +353,68 @@ function _unsupportedIterableToArray(r, a) {
340
353
  key: "init",
341
354
  value: (function () {
342
355
  var _init = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
343
- var _t;
344
356
  return _regenerator().w(function (_context) {
345
- while (1) switch (_context.p = _context.n) {
357
+ while (1) switch (_context.n) {
346
358
  case 0:
347
- _context.p = 0;
348
- if (!this.config.secureInit) {
359
+ if (!this.isInitialized) {
360
+ _context.n = 1;
361
+ break;
362
+ }
363
+ console.log('⚠️ SDK déjà initialisé, ignoré');
364
+ return _context.a(2);
365
+ case 1:
366
+ if (!this.initPromise) {
349
367
  _context.n = 2;
350
368
  break;
351
369
  }
352
- _context.n = 1;
353
- return this.secureInit();
370
+ console.log('⚠️ Initialisation déjà en cours, attente...');
371
+ return _context.a(2, this.initPromise);
372
+ case 2:
373
+ this.initPromise = this._doInit();
374
+ return _context.a(2, this.initPromise);
375
+ }
376
+ }, _callee, this);
377
+ }));
378
+ function init() {
379
+ return _init.apply(this, arguments);
380
+ }
381
+ return init;
382
+ }()
383
+ /**
384
+ * Initialisation interne du SDK
385
+ */
386
+ )
387
+ }, {
388
+ key: "_doInit",
389
+ value: (function () {
390
+ var _doInit2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
391
+ var _t;
392
+ return _regenerator().w(function (_context2) {
393
+ while (1) switch (_context2.p = _context2.n) {
394
+ case 0:
395
+ _context2.p = 0;
396
+ if (!this.handleCallback()) {
397
+ _context2.n = 1;
398
+ break;
399
+ }
400
+ console.log('✅ Callback traité, initialisation terminée');
401
+ return _context2.a(2);
354
402
  case 1:
355
- _context.n = 3;
356
- break;
403
+ if (!this.config.secureInit) {
404
+ _context2.n = 3;
405
+ break;
406
+ }
407
+ _context2.n = 2;
408
+ return this.secureInit();
357
409
  case 2:
410
+ _context2.n = 4;
411
+ break;
412
+ case 3:
358
413
  // Validation sécurisée des paramètres
359
414
  if (this.config.validateInputs) {
360
415
  this.validateSecurityParams();
361
416
  }
362
- case 3:
417
+ case 4:
363
418
  // Log de sécurité pour l'initialisation
364
419
  this.logSecurityEvent('SDK_INIT_START', {
365
420
  apiUrl: this.config.apiUrl,
@@ -368,9 +423,9 @@ function _unsupportedIterableToArray(r, a) {
368
423
  });
369
424
 
370
425
  // Récupérer les informations du partenaire depuis l'API
371
- _context.n = 4;
426
+ _context2.n = 5;
372
427
  return this.fetchPartnerInfo();
373
- case 4:
428
+ case 5:
374
429
  // Obscurcir les credentials dans les logs
375
430
  this.obfuscateCredentials();
376
431
  this.isInitialized = true;
@@ -388,24 +443,24 @@ function _unsupportedIterableToArray(r, a) {
388
443
 
389
444
  // Initialiser la connexion WebSocket
390
445
  this.initWebSocket();
391
- _context.n = 6;
446
+ _context2.n = 7;
392
447
  break;
393
- case 5:
394
- _context.p = 5;
395
- _t = _context.v;
448
+ case 6:
449
+ _context2.p = 6;
450
+ _t = _context2.v;
396
451
  this.logSecurityEvent('SDK_INIT_ERROR', {
397
452
  error: _t.message
398
453
  });
399
454
  throw _t;
400
- case 6:
401
- return _context.a(2);
455
+ case 7:
456
+ return _context2.a(2);
402
457
  }
403
- }, _callee, this, [[0, 5]]);
458
+ }, _callee2, this, [[0, 6]]);
404
459
  }));
405
- function init() {
406
- return _init.apply(this, arguments);
460
+ function _doInit() {
461
+ return _doInit2.apply(this, arguments);
407
462
  }
408
- return init;
463
+ return _doInit;
409
464
  }()
410
465
  /**
411
466
  * Initialisation sécurisée via PHP
@@ -414,19 +469,19 @@ function _unsupportedIterableToArray(r, a) {
414
469
  }, {
415
470
  key: "secureInit",
416
471
  value: (function () {
417
- var _secureInit = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
472
+ var _secureInit = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
418
473
  var initData, response, result, decodedToken, _t2;
419
- return _regenerator().w(function (_context2) {
420
- while (1) switch (_context2.p = _context2.n) {
474
+ return _regenerator().w(function (_context3) {
475
+ while (1) switch (_context3.p = _context3.n) {
421
476
  case 0:
422
- _context2.p = 0;
477
+ _context3.p = 0;
423
478
  this.logSecurityEvent('SECURE_INIT_START');
424
479
  initData = {
425
480
  type: this.config.type,
426
481
  partnerName: this.config.partnerName,
427
482
  theme: this.config.theme
428
483
  };
429
- _context2.n = 1;
484
+ _context3.n = 1;
430
485
  return fetch(this.config.secureInitUrl, {
431
486
  method: 'POST',
432
487
  headers: {
@@ -436,20 +491,20 @@ function _unsupportedIterableToArray(r, a) {
436
491
  body: JSON.stringify(initData)
437
492
  });
438
493
  case 1:
439
- response = _context2.v;
494
+ response = _context3.v;
440
495
  if (response.ok) {
441
- _context2.n = 2;
496
+ _context3.n = 2;
442
497
  break;
443
498
  }
444
499
  throw new Error("Erreur HTTP: ".concat(response.status));
445
500
  case 2:
446
- _context2.n = 3;
501
+ _context3.n = 3;
447
502
  return response.json();
448
503
  case 3:
449
- result = _context2.v;
504
+ result = _context3.v;
450
505
  console.log('📋 Réponse initialisation sécurisée:', result);
451
506
  if (result.success) {
452
- _context2.n = 4;
507
+ _context3.n = 4;
453
508
  break;
454
509
  }
455
510
  throw new Error(result.error || 'Erreur lors de l\'initialisation sécurisée');
@@ -461,12 +516,12 @@ function _unsupportedIterableToArray(r, a) {
461
516
  // Décoder le token pour récupérer les credentials
462
517
  decodedToken = this.decodeSecureToken(result.data.token);
463
518
  if (!decodedToken) {
464
- _context2.n = 5;
519
+ _context3.n = 5;
465
520
  break;
466
521
  }
467
522
  this.config.clientId = decodedToken.client_id;
468
523
  this.config.secretId = decodedToken.secret_id;
469
- _context2.n = 6;
524
+ _context3.n = 6;
470
525
  break;
471
526
  case 5:
472
527
  throw new Error('Impossible de décoder le token sécurisé');
@@ -479,19 +534,19 @@ function _unsupportedIterableToArray(r, a) {
479
534
  maxRequests: result.data.max_requests
480
535
  });
481
536
  console.log('✅ Initialisation sécurisée réussie');
482
- _context2.n = 8;
537
+ _context3.n = 8;
483
538
  break;
484
539
  case 7:
485
- _context2.p = 7;
486
- _t2 = _context2.v;
540
+ _context3.p = 7;
541
+ _t2 = _context3.v;
487
542
  this.logSecurityEvent('SECURE_INIT_ERROR', {
488
543
  error: _t2.message
489
544
  });
490
545
  throw new Error("\xC9chec de l'initialisation s\xE9curis\xE9e: ".concat(_t2.message));
491
546
  case 8:
492
- return _context2.a(2);
547
+ return _context3.a(2);
493
548
  }
494
- }, _callee2, this, [[0, 7]]);
549
+ }, _callee3, this, [[0, 7]]);
495
550
  }));
496
551
  function secureInit() {
497
552
  return _secureInit.apply(this, arguments);
@@ -538,14 +593,14 @@ function _unsupportedIterableToArray(r, a) {
538
593
  }, {
539
594
  key: "initWebSocket",
540
595
  value: function initWebSocket() {
541
- var _this = this;
596
+ var _this2 = this;
542
597
  try {
543
598
  // Vérifier si Socket.IO est disponible
544
599
  if (typeof io === 'undefined') {
545
600
  console.warn('⚠️ Socket.IO non disponible, WebSocket sera initialisé plus tard');
546
601
  // Réessayer après un délai
547
602
  setTimeout(function () {
548
- return _this.initWebSocket();
603
+ return _this2.initWebSocket();
549
604
  }, 1000);
550
605
  return;
551
606
  }
@@ -569,36 +624,36 @@ function _unsupportedIterableToArray(r, a) {
569
624
  // Gestion des événements WebSocket
570
625
  this.socket.on('connect', function () {
571
626
  console.log('🌐 WebSocket connecté avec succès');
572
- console.log('📊 Socket ID:', _this.socket.id);
573
- _this.socket.connected = true;
627
+ console.log('📊 Socket ID:', _this2.socket.id);
628
+ _this2.socket.connected = true;
574
629
  });
575
630
  this.socket.on('disconnect', function (reason) {
576
631
  console.log('❌ WebSocket déconnecté:', reason);
577
- _this.socket.connected = false;
632
+ _this2.socket.connected = false;
578
633
  });
579
634
  this.socket.on('connect_error', function (error) {
580
635
  console.error('❌ Erreur connexion WebSocket:', error);
581
- _this.socket.connected = false;
636
+ _this2.socket.connected = false;
582
637
  });
583
638
 
584
639
  // Écouter les événements spécifiques
585
640
  this.socket.on('qr_status_update', function (data) {
586
641
  console.log('📱 Mise à jour statut QR reçue:', data);
587
- _this.handleQRStatusUpdate(data);
642
+ _this2.handleQRStatusUpdate(data);
588
643
  });
589
644
  this.socket.on('qr_scan_success', function (data) {
590
645
  console.log('✅ Scan QR réussi reçu:', data);
591
- _this.handleQRScanSuccess(data);
646
+ _this2.handleQRScanSuccess(data);
592
647
  });
593
648
  this.socket.on('qr_expired', function (data) {
594
649
  console.log('⏰ QR expiré reçu:', data);
595
- _this.handleQRExpired(data);
650
+ _this2.handleQRExpired(data);
596
651
  });
597
652
 
598
653
  // Écouter l'événement qr_scan_initiated spécifiquement
599
654
  this.socket.on('qr_scan_initiated', function (data) {
600
655
  console.log('🔍 QR Scan Initiated reçu:', data);
601
- _this.showQRLoader();
656
+ _this2.showQRLoader();
602
657
  });
603
658
 
604
659
  // Écouter l'événement message générique (fallback)
@@ -606,7 +661,7 @@ function _unsupportedIterableToArray(r, a) {
606
661
  console.log('📨 Message socket reçu:', data);
607
662
  if (data && data.type === 'qr_scan_initiated') {
608
663
  console.log('🔍 QR Scan Initiated détecté dans message:', data);
609
- _this.showQRLoader();
664
+ _this2.showQRLoader();
610
665
  }
611
666
  });
612
667
 
@@ -850,7 +905,7 @@ function _unsupportedIterableToArray(r, a) {
850
905
  }, {
851
906
  key: "generateQR",
852
907
  value: (function () {
853
- var _generateQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
908
+ var _generateQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
854
909
  var containerId,
855
910
  options,
856
911
  connectionStatus,
@@ -860,25 +915,25 @@ function _unsupportedIterableToArray(r, a) {
860
915
  response,
861
916
  qrImageUrl,
862
917
  isLocal,
863
- _args3 = arguments,
918
+ _args4 = arguments,
864
919
  _t3,
865
920
  _t4;
866
- return _regenerator().w(function (_context3) {
867
- while (1) switch (_context3.p = _context3.n) {
921
+ return _regenerator().w(function (_context4) {
922
+ while (1) switch (_context4.p = _context4.n) {
868
923
  case 0:
869
- containerId = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : 'sunuid-qr-container';
870
- options = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {};
924
+ containerId = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : 'sunuid-qr-container';
925
+ options = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
871
926
  if (!this.initPromise) {
872
- _context3.n = 2;
927
+ _context4.n = 2;
873
928
  break;
874
929
  }
875
- _context3.n = 1;
930
+ _context4.n = 1;
876
931
  return this.initPromise;
877
932
  case 1:
878
933
  this.initPromise = null;
879
934
  case 2:
880
935
  if (this.isInitialized) {
881
- _context3.n = 3;
936
+ _context4.n = 3;
882
937
  break;
883
938
  }
884
939
  throw new Error('SunuID: SDK non initialisé');
@@ -887,22 +942,22 @@ function _unsupportedIterableToArray(r, a) {
887
942
 
888
943
  // Attendre que les connexions soient prêtes
889
944
  console.log('🔍 Attente connexions API et WebSocket...');
890
- _context3.p = 4;
891
- _context3.n = 5;
945
+ _context4.p = 4;
946
+ _context4.n = 5;
892
947
  return this.waitForConnections(5000);
893
948
  case 5:
894
- connectionStatus = _context3.v;
949
+ connectionStatus = _context4.v;
895
950
  // 5 secondes max
896
951
  console.log('✅ Connexions prêtes:', connectionStatus);
897
- _context3.n = 7;
952
+ _context4.n = 7;
898
953
  break;
899
954
  case 6:
900
- _context3.p = 6;
901
- _t3 = _context3.v;
955
+ _context4.p = 6;
956
+ _t3 = _context4.v;
902
957
  console.error('❌ Erreur connexions:', _t3.message);
903
958
  throw new Error('Connexions non disponibles - Impossible de générer le QR code');
904
959
  case 7:
905
- _context3.p = 7;
960
+ _context4.p = 7;
906
961
  // Utiliser uniquement le socketID comme contenu du QR
907
962
  socketId = this.socket ? this.socket.id : 'timeout-socket-id';
908
963
  qrContent = socketId;
@@ -911,7 +966,7 @@ function _unsupportedIterableToArray(r, a) {
911
966
 
912
967
  // Générer le QR avec le contenu complet
913
968
  partnerName = this.config.partnerName || 'Partner_unknown';
914
- _context3.n = 8;
969
+ _context4.n = 8;
915
970
  return this.makeRequest('/qr-generate', _objectSpread2({
916
971
  type: this.config.type,
917
972
  data: qrContent,
@@ -919,9 +974,9 @@ function _unsupportedIterableToArray(r, a) {
919
974
  label: "".concat(this.getTypeName(this.config.type), " ").concat(partnerName)
920
975
  }, options));
921
976
  case 8:
922
- response = _context3.v;
977
+ response = _context4.v;
923
978
  if (!response.success) {
924
- _context3.n = 11;
979
+ _context4.n = 11;
925
980
  break;
926
981
  }
927
982
  // Debug: Afficher la structure complète de la réponse
@@ -936,7 +991,7 @@ function _unsupportedIterableToArray(r, a) {
936
991
 
937
992
  // Vérifier si l'URL du QR code existe
938
993
  if (qrImageUrl) {
939
- _context3.n = 10;
994
+ _context4.n = 10;
940
995
  break;
941
996
  }
942
997
  console.warn('⚠️ qrCodeUrl non trouvé dans la réponse, recherche d\'alternatives...');
@@ -944,11 +999,11 @@ function _unsupportedIterableToArray(r, a) {
944
999
  // Essayer d'autres champs possibles
945
1000
  qrImageUrl = response.data.qr_url || response.data.qrUrl || response.data.url || response.data.image_url || response.data.imageUrl;
946
1001
  if (!qrImageUrl) {
947
- _context3.n = 9;
1002
+ _context4.n = 9;
948
1003
  break;
949
1004
  }
950
1005
  console.log('✅ URL QR trouvée dans un champ alternatif:', qrImageUrl);
951
- _context3.n = 10;
1006
+ _context4.n = 10;
952
1007
  break;
953
1008
  case 9:
954
1009
  console.error('❌ Aucune URL QR trouvée dans la réponse');
@@ -974,7 +1029,7 @@ function _unsupportedIterableToArray(r, a) {
974
1029
  sessionId: response.data.sessionId,
975
1030
  timestamp: Date.now()
976
1031
  });
977
- return _context3.a(2, _objectSpread2(_objectSpread2({}, response.data), {}, {
1032
+ return _context4.a(2, _objectSpread2(_objectSpread2({}, response.data), {}, {
978
1033
  qrCodeUrl: qrImageUrl,
979
1034
  qrContent: qrContent,
980
1035
  label: response.data.label,
@@ -983,11 +1038,11 @@ function _unsupportedIterableToArray(r, a) {
983
1038
  case 11:
984
1039
  throw new Error(response.message || 'Erreur lors de la génération du QR code');
985
1040
  case 12:
986
- _context3.n = 14;
1041
+ _context4.n = 14;
987
1042
  break;
988
1043
  case 13:
989
- _context3.p = 13;
990
- _t4 = _context3.v;
1044
+ _context4.p = 13;
1045
+ _t4 = _context4.v;
991
1046
  console.error('Erreur API détectée:', _t4.message);
992
1047
  console.error('Stack trace complet:', _t4.stack);
993
1048
  console.error('Configuration SDK:', {
@@ -1019,9 +1074,9 @@ function _unsupportedIterableToArray(r, a) {
1019
1074
  this.displayServiceUnavailable(containerId, this.config.type);
1020
1075
  throw new Error('Service non disponible');
1021
1076
  case 14:
1022
- return _context3.a(2);
1077
+ return _context4.a(2);
1023
1078
  }
1024
- }, _callee3, this, [[7, 13], [4, 6]]);
1079
+ }, _callee4, this, [[7, 13], [4, 6]]);
1025
1080
  }));
1026
1081
  function generateQR() {
1027
1082
  return _generateQR.apply(this, arguments);
@@ -1035,41 +1090,41 @@ function _unsupportedIterableToArray(r, a) {
1035
1090
  }, {
1036
1091
  key: "generateCustomQR",
1037
1092
  value: (function () {
1038
- var _generateCustomQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(containerId, type) {
1093
+ var _generateCustomQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(containerId, type) {
1039
1094
  var options,
1040
1095
  response,
1041
1096
  imageBaseUrl,
1042
1097
  qrImageUrl,
1043
- _args4 = arguments,
1098
+ _args5 = arguments,
1044
1099
  _t5;
1045
- return _regenerator().w(function (_context4) {
1046
- while (1) switch (_context4.p = _context4.n) {
1100
+ return _regenerator().w(function (_context5) {
1101
+ while (1) switch (_context5.p = _context5.n) {
1047
1102
  case 0:
1048
- options = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : {};
1103
+ options = _args5.length > 2 && _args5[2] !== undefined ? _args5[2] : {};
1049
1104
  if (!this.initPromise) {
1050
- _context4.n = 2;
1105
+ _context5.n = 2;
1051
1106
  break;
1052
1107
  }
1053
- _context4.n = 1;
1108
+ _context5.n = 1;
1054
1109
  return this.initPromise;
1055
1110
  case 1:
1056
1111
  this.initPromise = null;
1057
1112
  case 2:
1058
1113
  if (this.isInitialized) {
1059
- _context4.n = 3;
1114
+ _context5.n = 3;
1060
1115
  break;
1061
1116
  }
1062
1117
  throw new Error('SunuID: SDK non initialisé');
1063
1118
  case 3:
1064
- _context4.p = 3;
1065
- _context4.n = 4;
1119
+ _context5.p = 3;
1120
+ _context5.n = 4;
1066
1121
  return this.makeRequest('/qr-generate', _objectSpread2({
1067
1122
  type: type
1068
1123
  }, options));
1069
1124
  case 4:
1070
- response = _context4.v;
1125
+ response = _context5.v;
1071
1126
  if (!response.success) {
1072
- _context4.n = 5;
1127
+ _context5.n = 5;
1073
1128
  break;
1074
1129
  }
1075
1130
  // Construire l'URL complète de l'image QR avec la base URL pour les images
@@ -1082,18 +1137,18 @@ function _unsupportedIterableToArray(r, a) {
1082
1137
  console.log('📄 Code de session:', response.data.code);
1083
1138
  console.log('🆔 Service ID:', response.data.service_id);
1084
1139
  this.startAutoRefresh(containerId, type, options);
1085
- return _context4.a(2, _objectSpread2(_objectSpread2({}, response.data), {}, {
1140
+ return _context5.a(2, _objectSpread2(_objectSpread2({}, response.data), {}, {
1086
1141
  qrCodeUrl: qrImageUrl,
1087
1142
  sessionId: response.data.service_id
1088
1143
  }));
1089
1144
  case 5:
1090
1145
  throw new Error(response.message || 'Erreur lors de la génération du QR code');
1091
1146
  case 6:
1092
- _context4.n = 8;
1147
+ _context5.n = 8;
1093
1148
  break;
1094
1149
  case 7:
1095
- _context4.p = 7;
1096
- _t5 = _context4.v;
1150
+ _context5.p = 7;
1151
+ _t5 = _context5.v;
1097
1152
  console.error('Erreur API détectée:', _t5.message);
1098
1153
  console.error('Stack trace complet:', _t5.stack);
1099
1154
  console.error('Configuration SDK (Custom):', {
@@ -1107,9 +1162,9 @@ function _unsupportedIterableToArray(r, a) {
1107
1162
  this.displayServiceUnavailable(containerId, type);
1108
1163
  throw new Error('Service non disponible');
1109
1164
  case 8:
1110
- return _context4.a(2);
1165
+ return _context5.a(2);
1111
1166
  }
1112
- }, _callee4, this, [[3, 7]]);
1167
+ }, _callee5, this, [[3, 7]]);
1113
1168
  }));
1114
1169
  function generateCustomQR(_x, _x2) {
1115
1170
  return _generateCustomQR.apply(this, arguments);
@@ -1120,16 +1175,16 @@ function _unsupportedIterableToArray(r, a) {
1120
1175
  }, {
1121
1176
  key: "generateAuthQR",
1122
1177
  value: function () {
1123
- var _generateAuthQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(containerId) {
1178
+ var _generateAuthQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(containerId) {
1124
1179
  var options,
1125
- _args5 = arguments;
1126
- return _regenerator().w(function (_context5) {
1127
- while (1) switch (_context5.n) {
1180
+ _args6 = arguments;
1181
+ return _regenerator().w(function (_context6) {
1182
+ while (1) switch (_context6.n) {
1128
1183
  case 0:
1129
- options = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : {};
1130
- return _context5.a(2, this.generateQR(containerId, options));
1184
+ options = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : {};
1185
+ return _context6.a(2, this.generateQR(containerId, options));
1131
1186
  }
1132
- }, _callee5, this);
1187
+ }, _callee6, this);
1133
1188
  }));
1134
1189
  function generateAuthQR(_x3) {
1135
1190
  return _generateAuthQR.apply(this, arguments);
@@ -1139,31 +1194,31 @@ function _unsupportedIterableToArray(r, a) {
1139
1194
  }, {
1140
1195
  key: "generateKYCQR",
1141
1196
  value: function () {
1142
- var _generateKYCQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(containerId) {
1197
+ var _generateKYCQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(containerId) {
1143
1198
  var options,
1144
1199
  originalType,
1145
- _args6 = arguments;
1146
- return _regenerator().w(function (_context6) {
1147
- while (1) switch (_context6.p = _context6.n) {
1200
+ _args7 = arguments;
1201
+ return _regenerator().w(function (_context7) {
1202
+ while (1) switch (_context7.p = _context7.n) {
1148
1203
  case 0:
1149
- options = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : {};
1204
+ options = _args7.length > 1 && _args7[1] !== undefined ? _args7[1] : {};
1150
1205
  // Sauvegarder le type actuel
1151
1206
  originalType = this.config.type; // Changer temporairement le type pour KYC
1152
1207
  this.config.type = 1;
1153
- _context6.p = 1;
1154
- _context6.n = 2;
1208
+ _context7.p = 1;
1209
+ _context7.n = 2;
1155
1210
  return this.generateQR(containerId, options);
1156
1211
  case 2:
1157
- return _context6.a(2, _context6.v);
1212
+ return _context7.a(2, _context7.v);
1158
1213
  case 3:
1159
- _context6.p = 3;
1214
+ _context7.p = 3;
1160
1215
  // Restaurer le type original
1161
1216
  this.config.type = originalType;
1162
- return _context6.f(3);
1217
+ return _context7.f(3);
1163
1218
  case 4:
1164
- return _context6.a(2);
1219
+ return _context7.a(2);
1165
1220
  }
1166
- }, _callee6, this, [[1,, 3, 4]]);
1221
+ }, _callee7, this, [[1,, 3, 4]]);
1167
1222
  }));
1168
1223
  function generateKYCQR(_x4) {
1169
1224
  return _generateKYCQR.apply(this, arguments);
@@ -1173,31 +1228,31 @@ function _unsupportedIterableToArray(r, a) {
1173
1228
  }, {
1174
1229
  key: "generateSignatureQR",
1175
1230
  value: function () {
1176
- var _generateSignatureQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(containerId) {
1231
+ var _generateSignatureQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(containerId) {
1177
1232
  var options,
1178
1233
  originalType,
1179
- _args7 = arguments;
1180
- return _regenerator().w(function (_context7) {
1181
- while (1) switch (_context7.p = _context7.n) {
1234
+ _args8 = arguments;
1235
+ return _regenerator().w(function (_context8) {
1236
+ while (1) switch (_context8.p = _context8.n) {
1182
1237
  case 0:
1183
- options = _args7.length > 1 && _args7[1] !== undefined ? _args7[1] : {};
1238
+ options = _args8.length > 1 && _args8[1] !== undefined ? _args8[1] : {};
1184
1239
  // Sauvegarder le type actuel
1185
1240
  originalType = this.config.type; // Changer temporairement le type pour Signature
1186
1241
  this.config.type = 3;
1187
- _context7.p = 1;
1188
- _context7.n = 2;
1242
+ _context8.p = 1;
1243
+ _context8.n = 2;
1189
1244
  return this.generateQR(containerId, options);
1190
1245
  case 2:
1191
- return _context7.a(2, _context7.v);
1246
+ return _context8.a(2, _context8.v);
1192
1247
  case 3:
1193
- _context7.p = 3;
1248
+ _context8.p = 3;
1194
1249
  // Restaurer le type original
1195
1250
  this.config.type = originalType;
1196
- return _context7.f(3);
1251
+ return _context8.f(3);
1197
1252
  case 4:
1198
- return _context7.a(2);
1253
+ return _context8.a(2);
1199
1254
  }
1200
- }, _callee7, this, [[1,, 3, 4]]);
1255
+ }, _callee8, this, [[1,, 3, 4]]);
1201
1256
  }));
1202
1257
  function generateSignatureQR(_x5) {
1203
1258
  return _generateSignatureQR.apply(this, arguments);
@@ -1210,43 +1265,43 @@ function _unsupportedIterableToArray(r, a) {
1210
1265
  }, {
1211
1266
  key: "checkQRStatus",
1212
1267
  value: (function () {
1213
- var _checkQRStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(sessionId) {
1268
+ var _checkQRStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(sessionId) {
1214
1269
  var response, _t6;
1215
- return _regenerator().w(function (_context8) {
1216
- while (1) switch (_context8.p = _context8.n) {
1270
+ return _regenerator().w(function (_context9) {
1271
+ while (1) switch (_context9.p = _context9.n) {
1217
1272
  case 0:
1218
1273
  if (this.isInitialized) {
1219
- _context8.n = 1;
1274
+ _context9.n = 1;
1220
1275
  break;
1221
1276
  }
1222
1277
  throw new Error('SunuID: SDK non initialisé');
1223
1278
  case 1:
1224
- _context8.p = 1;
1225
- _context8.n = 2;
1279
+ _context9.p = 1;
1280
+ _context9.n = 2;
1226
1281
  return this.makeRequest('/qr-status', {
1227
1282
  serviceId: sessionId
1228
1283
  });
1229
1284
  case 2:
1230
- response = _context8.v;
1285
+ response = _context9.v;
1231
1286
  if (!response.success) {
1232
- _context8.n = 3;
1287
+ _context9.n = 3;
1233
1288
  break;
1234
1289
  }
1235
- return _context8.a(2, response.data);
1290
+ return _context9.a(2, response.data);
1236
1291
  case 3:
1237
1292
  throw new Error(response.message || 'Erreur lors de la vérification du statut');
1238
1293
  case 4:
1239
- _context8.n = 6;
1294
+ _context9.n = 6;
1240
1295
  break;
1241
1296
  case 5:
1242
- _context8.p = 5;
1243
- _t6 = _context8.v;
1297
+ _context9.p = 5;
1298
+ _t6 = _context9.v;
1244
1299
  this.handleError(_t6);
1245
1300
  throw _t6;
1246
1301
  case 6:
1247
- return _context8.a(2);
1302
+ return _context9.a(2);
1248
1303
  }
1249
- }, _callee8, this, [[1, 5]]);
1304
+ }, _callee9, this, [[1, 5]]);
1250
1305
  }));
1251
1306
  function checkQRStatus(_x6) {
1252
1307
  return _checkQRStatus.apply(this, arguments);
@@ -1260,47 +1315,47 @@ function _unsupportedIterableToArray(r, a) {
1260
1315
  }, {
1261
1316
  key: "generateQRWithContent",
1262
1317
  value: (function () {
1263
- var _generateQRWithContent = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(content, containerId, type) {
1318
+ var _generateQRWithContent = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(content, containerId, type) {
1264
1319
  var options,
1265
1320
  localQRUrl,
1266
- _args9 = arguments,
1321
+ _args0 = arguments,
1267
1322
  _t7;
1268
- return _regenerator().w(function (_context9) {
1269
- while (1) switch (_context9.p = _context9.n) {
1323
+ return _regenerator().w(function (_context0) {
1324
+ while (1) switch (_context0.p = _context0.n) {
1270
1325
  case 0:
1271
- options = _args9.length > 3 && _args9[3] !== undefined ? _args9[3] : {};
1326
+ options = _args0.length > 3 && _args0[3] !== undefined ? _args0[3] : {};
1272
1327
  console.log('🎨 Génération QR avec contenu:', content);
1273
- _context9.p = 1;
1328
+ _context0.p = 1;
1274
1329
  if (!(window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1' || window.location.protocol === 'file:')) {
1275
- _context9.n = 3;
1330
+ _context0.n = 3;
1276
1331
  break;
1277
1332
  }
1278
1333
  console.log('🏠 Utilisation service QR local...');
1279
- _context9.n = 2;
1334
+ _context0.n = 2;
1280
1335
  return this.generateQRLocal(content, containerId, type, options);
1281
1336
  case 2:
1282
- localQRUrl = _context9.v;
1337
+ localQRUrl = _context0.v;
1283
1338
  if (!localQRUrl) {
1284
- _context9.n = 3;
1339
+ _context0.n = 3;
1285
1340
  break;
1286
1341
  }
1287
- return _context9.a(2, localQRUrl);
1342
+ return _context0.a(2, localQRUrl);
1288
1343
  case 3:
1289
1344
  // Fallback vers le service QR distant
1290
1345
  console.log('🌐 Utilisation service QR distant...');
1291
- _context9.n = 4;
1346
+ _context0.n = 4;
1292
1347
  return this.generateQRRemote(content, containerId, type, options);
1293
1348
  case 4:
1294
- return _context9.a(2, _context9.v);
1349
+ return _context0.a(2, _context0.v);
1295
1350
  case 5:
1296
- _context9.p = 5;
1297
- _t7 = _context9.v;
1351
+ _context0.p = 5;
1352
+ _t7 = _context0.v;
1298
1353
  console.error('❌ Erreur génération QR:', _t7);
1299
1354
  // Fallback vers affichage simple du contenu
1300
1355
  this.displayQRContent(containerId, content, type, options);
1301
- return _context9.a(2, null);
1356
+ return _context0.a(2, null);
1302
1357
  }
1303
- }, _callee9, this, [[1, 5]]);
1358
+ }, _callee0, this, [[1, 5]]);
1304
1359
  }));
1305
1360
  function generateQRWithContent(_x7, _x8, _x9) {
1306
1361
  return _generateQRWithContent.apply(this, arguments);
@@ -1314,19 +1369,19 @@ function _unsupportedIterableToArray(r, a) {
1314
1369
  }, {
1315
1370
  key: "generateQRLocal",
1316
1371
  value: (function () {
1317
- var _generateQRLocal = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(content, containerId, type) {
1372
+ var _generateQRLocal = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(content, containerId, type) {
1318
1373
  var options,
1319
1374
  response,
1320
1375
  data,
1321
1376
  qrUrl,
1322
- _args0 = arguments,
1377
+ _args1 = arguments,
1323
1378
  _t8;
1324
- return _regenerator().w(function (_context0) {
1325
- while (1) switch (_context0.p = _context0.n) {
1379
+ return _regenerator().w(function (_context1) {
1380
+ while (1) switch (_context1.p = _context1.n) {
1326
1381
  case 0:
1327
- options = _args0.length > 3 && _args0[3] !== undefined ? _args0[3] : {};
1328
- _context0.p = 1;
1329
- _context0.n = 2;
1382
+ options = _args1.length > 3 && _args1[3] !== undefined ? _args1[3] : {};
1383
+ _context1.p = 1;
1384
+ _context1.n = 2;
1330
1385
  return fetch('http://localhost:8000/api/generate/text', {
1331
1386
  method: 'POST',
1332
1387
  headers: {
@@ -1335,29 +1390,29 @@ function _unsupportedIterableToArray(r, a) {
1335
1390
  body: "text=".concat(encodeURIComponent(content), "&size=300")
1336
1391
  });
1337
1392
  case 2:
1338
- response = _context0.v;
1393
+ response = _context1.v;
1339
1394
  if (!response.ok) {
1340
- _context0.n = 4;
1395
+ _context1.n = 4;
1341
1396
  break;
1342
1397
  }
1343
- _context0.n = 3;
1398
+ _context1.n = 3;
1344
1399
  return response.json();
1345
1400
  case 3:
1346
- data = _context0.v;
1401
+ data = _context1.v;
1347
1402
  qrUrl = "data:image/png;base64,".concat(data.qrcode);
1348
1403
  this.displayQRCode(containerId, qrUrl, type, options);
1349
- return _context0.a(2, qrUrl);
1404
+ return _context1.a(2, qrUrl);
1350
1405
  case 4:
1351
- _context0.n = 6;
1406
+ _context1.n = 6;
1352
1407
  break;
1353
1408
  case 5:
1354
- _context0.p = 5;
1355
- _t8 = _context0.v;
1409
+ _context1.p = 5;
1410
+ _t8 = _context1.v;
1356
1411
  console.log('❌ Service QR local non disponible:', _t8.message);
1357
1412
  case 6:
1358
- return _context0.a(2, null);
1413
+ return _context1.a(2, null);
1359
1414
  }
1360
- }, _callee0, this, [[1, 5]]);
1415
+ }, _callee1, this, [[1, 5]]);
1361
1416
  }));
1362
1417
  function generateQRLocal(_x0, _x1, _x10) {
1363
1418
  return _generateQRLocal.apply(this, arguments);
@@ -1371,19 +1426,19 @@ function _unsupportedIterableToArray(r, a) {
1371
1426
  }, {
1372
1427
  key: "generateQRRemote",
1373
1428
  value: (function () {
1374
- var _generateQRRemote = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(content, containerId, type) {
1429
+ var _generateQRRemote = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(content, containerId, type) {
1375
1430
  var options,
1376
1431
  response,
1377
1432
  data,
1378
1433
  qrUrl,
1379
- _args1 = arguments,
1434
+ _args10 = arguments,
1380
1435
  _t9;
1381
- return _regenerator().w(function (_context1) {
1382
- while (1) switch (_context1.p = _context1.n) {
1436
+ return _regenerator().w(function (_context10) {
1437
+ while (1) switch (_context10.p = _context10.n) {
1383
1438
  case 0:
1384
- options = _args1.length > 3 && _args1[3] !== undefined ? _args1[3] : {};
1385
- _context1.p = 1;
1386
- _context1.n = 2;
1439
+ options = _args10.length > 3 && _args10[3] !== undefined ? _args10[3] : {};
1440
+ _context10.p = 1;
1441
+ _context10.n = 2;
1387
1442
  return fetch('https://api.sunuid.fayma.sn/qr-generate', {
1388
1443
  method: 'POST',
1389
1444
  headers: {
@@ -1396,31 +1451,31 @@ function _unsupportedIterableToArray(r, a) {
1396
1451
  })
1397
1452
  });
1398
1453
  case 2:
1399
- response = _context1.v;
1454
+ response = _context10.v;
1400
1455
  if (!response.ok) {
1401
- _context1.n = 4;
1456
+ _context10.n = 4;
1402
1457
  break;
1403
1458
  }
1404
- _context1.n = 3;
1459
+ _context10.n = 3;
1405
1460
  return response.json();
1406
1461
  case 3:
1407
- data = _context1.v;
1462
+ data = _context10.v;
1408
1463
  qrUrl = "data:image/png;base64,".concat(data.qrcode);
1409
1464
  this.displayQRCode(containerId, qrUrl, type, options);
1410
- return _context1.a(2, qrUrl);
1465
+ return _context10.a(2, qrUrl);
1411
1466
  case 4:
1412
- _context1.n = 6;
1467
+ _context10.n = 6;
1413
1468
  break;
1414
1469
  case 5:
1415
- _context1.p = 5;
1416
- _t9 = _context1.v;
1470
+ _context10.p = 5;
1471
+ _t9 = _context10.v;
1417
1472
  console.error('❌ Erreur service QR distant:', _t9);
1418
1473
  case 6:
1419
1474
  // Fallback vers affichage du contenu
1420
1475
  this.displayQRContent(containerId, content, type, options);
1421
- return _context1.a(2, null);
1476
+ return _context10.a(2, null);
1422
1477
  }
1423
- }, _callee1, this, [[1, 5]]);
1478
+ }, _callee10, this, [[1, 5]]);
1424
1479
  }));
1425
1480
  function generateQRRemote(_x11, _x12, _x13) {
1426
1481
  return _generateQRRemote.apply(this, arguments);
@@ -1478,11 +1533,11 @@ function _unsupportedIterableToArray(r, a) {
1478
1533
  }, {
1479
1534
  key: "generateCustomQRCode",
1480
1535
  value: (function () {
1481
- var _generateCustomQRCode = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(content, label) {
1536
+ var _generateCustomQRCode = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11(content, label) {
1482
1537
  var qrContainer,
1483
1538
  _t0;
1484
- return _regenerator().w(function (_context10) {
1485
- while (1) switch (_context10.p = _context10.n) {
1539
+ return _regenerator().w(function (_context11) {
1540
+ while (1) switch (_context11.p = _context11.n) {
1486
1541
  case 0:
1487
1542
  console.log('🎨 Début génération QR personnalisé...');
1488
1543
  console.log('📄 Contenu:', content);
@@ -1494,37 +1549,37 @@ function _unsupportedIterableToArray(r, a) {
1494
1549
  qrContainer = document.getElementById('qr-container');
1495
1550
  }
1496
1551
  if (qrContainer) {
1497
- _context10.n = 1;
1552
+ _context11.n = 1;
1498
1553
  break;
1499
1554
  }
1500
1555
  console.error('❌ QR container not found');
1501
- return _context10.a(2);
1556
+ return _context11.a(2);
1502
1557
  case 1:
1503
1558
  console.log('✅ QR container trouvé');
1504
1559
 
1505
1560
  // Nettoyer le conteneur
1506
1561
  qrContainer.innerHTML = '<div style="text-align: center; padding: 20px;"><p>Génération QR code...</p></div>';
1507
- _context10.p = 2;
1562
+ _context11.p = 2;
1508
1563
  // Utiliser directement l'API principale (plus fiable)
1509
1564
  console.log('🎨 Tentative génération via API principale...');
1510
- _context10.n = 3;
1565
+ _context11.n = 3;
1511
1566
  return this.generateQRPHP(content, label, qrContainer);
1512
1567
  case 3:
1513
1568
  console.log('✅ QR code généré avec succès');
1514
- _context10.n = 5;
1569
+ _context11.n = 5;
1515
1570
  break;
1516
1571
  case 4:
1517
- _context10.p = 4;
1518
- _t0 = _context10.v;
1572
+ _context11.p = 4;
1573
+ _t0 = _context11.v;
1519
1574
  console.error('❌ Erreur génération API:', _t0);
1520
1575
 
1521
1576
  // Fallback final : image par défaut
1522
1577
  console.log('⚠️ Affichage image par défaut');
1523
1578
  this.displayDefaultQR(qrContainer, content, label);
1524
1579
  case 5:
1525
- return _context10.a(2);
1580
+ return _context11.a(2);
1526
1581
  }
1527
- }, _callee10, this, [[2, 4]]);
1582
+ }, _callee11, this, [[2, 4]]);
1528
1583
  }));
1529
1584
  function generateCustomQRCode(_x14, _x15) {
1530
1585
  return _generateCustomQRCode.apply(this, arguments);
@@ -1538,17 +1593,17 @@ function _unsupportedIterableToArray(r, a) {
1538
1593
  }, {
1539
1594
  key: "generateQRClientSide",
1540
1595
  value: (function () {
1541
- var _generateQRClientSide = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11(content, label, qrContainer) {
1542
- var _this2 = this;
1596
+ var _generateQRClientSide = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12(content, label, qrContainer) {
1597
+ var _this3 = this;
1543
1598
  var canvas, ctx;
1544
- return _regenerator().w(function (_context11) {
1545
- while (1) switch (_context11.n) {
1599
+ return _regenerator().w(function (_context12) {
1600
+ while (1) switch (_context12.n) {
1546
1601
  case 0:
1547
- _context11.n = 1;
1602
+ _context12.n = 1;
1548
1603
  return this.ensureQRCodeLibrary();
1549
1604
  case 1:
1550
1605
  if (!(typeof QRCode === 'undefined')) {
1551
- _context11.n = 2;
1606
+ _context12.n = 2;
1552
1607
  break;
1553
1608
  }
1554
1609
  throw new Error('QRCode library non disponible');
@@ -1562,7 +1617,7 @@ function _unsupportedIterableToArray(r, a) {
1562
1617
  ctx.fillRect(0, 0, 300, 320);
1563
1618
 
1564
1619
  // Générer le QR code
1565
- return _context11.a(2, new Promise(function (resolve, reject) {
1620
+ return _context12.a(2, new Promise(function (resolve, reject) {
1566
1621
  QRCode.toCanvas(canvas, content, {
1567
1622
  width: 280,
1568
1623
  margin: 10,
@@ -1586,18 +1641,18 @@ function _unsupportedIterableToArray(r, a) {
1586
1641
  var dataUrl = canvas.toDataURL('image/png');
1587
1642
 
1588
1643
  // Stocker l'URL
1589
- _this2.currentQRUrl = dataUrl;
1644
+ _this3.currentQRUrl = dataUrl;
1590
1645
 
1591
1646
  // Afficher le QR code
1592
1647
  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 ");
1593
1648
 
1594
1649
  // Afficher les instructions
1595
- _this2.showQRInstructions(qrContainer);
1650
+ _this3.showQRInstructions(qrContainer);
1596
1651
  resolve();
1597
1652
  });
1598
1653
  }));
1599
1654
  }
1600
- }, _callee11, this);
1655
+ }, _callee12, this);
1601
1656
  }));
1602
1657
  function generateQRClientSide(_x16, _x17, _x18) {
1603
1658
  return _generateQRClientSide.apply(this, arguments);
@@ -1611,10 +1666,10 @@ function _unsupportedIterableToArray(r, a) {
1611
1666
  }, {
1612
1667
  key: "generateQRPHP",
1613
1668
  value: (function () {
1614
- var _generateQRPHP = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12(content, label, qrContainer) {
1669
+ var _generateQRPHP = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13(content, label, qrContainer) {
1615
1670
  var qrGeneratorUrl, requestBody, contentType, response, responseData, qrImageUrl, imageBaseUrl;
1616
- return _regenerator().w(function (_context12) {
1617
- while (1) switch (_context12.n) {
1671
+ return _regenerator().w(function (_context13) {
1672
+ while (1) switch (_context13.n) {
1618
1673
  case 0:
1619
1674
  // Construire l'URL - Utiliser l'API principale qui fonctionne
1620
1675
 
@@ -1652,7 +1707,7 @@ function _unsupportedIterableToArray(r, a) {
1652
1707
  label: label
1653
1708
  });
1654
1709
  }
1655
- _context12.n = 1;
1710
+ _context13.n = 1;
1656
1711
  return fetch(qrGeneratorUrl, {
1657
1712
  method: 'POST',
1658
1713
  headers: {
@@ -1662,19 +1717,19 @@ function _unsupportedIterableToArray(r, a) {
1662
1717
  body: requestBody
1663
1718
  });
1664
1719
  case 1:
1665
- response = _context12.v;
1720
+ response = _context13.v;
1666
1721
  if (response.ok) {
1667
- _context12.n = 2;
1722
+ _context13.n = 2;
1668
1723
  break;
1669
1724
  }
1670
1725
  throw new Error("Erreur HTTP: ".concat(response.status));
1671
1726
  case 2:
1672
- _context12.n = 3;
1727
+ _context13.n = 3;
1673
1728
  return response.json();
1674
1729
  case 3:
1675
- responseData = _context12.v;
1730
+ responseData = _context13.v;
1676
1731
  if (responseData.success) {
1677
- _context12.n = 4;
1732
+ _context13.n = 4;
1678
1733
  break;
1679
1734
  }
1680
1735
  throw new Error("Erreur QR: ".concat(responseData.error));
@@ -1697,9 +1752,9 @@ function _unsupportedIterableToArray(r, a) {
1697
1752
  // Afficher les instructions
1698
1753
  this.showQRInstructions(qrContainer);
1699
1754
  case 5:
1700
- return _context12.a(2);
1755
+ return _context13.a(2);
1701
1756
  }
1702
- }, _callee12, this);
1757
+ }, _callee13, this);
1703
1758
  }));
1704
1759
  function generateQRPHP(_x19, _x20, _x21) {
1705
1760
  return _generateQRPHP.apply(this, arguments);
@@ -1722,19 +1777,19 @@ function _unsupportedIterableToArray(r, a) {
1722
1777
  }, {
1723
1778
  key: "ensureQRCodeLibrary",
1724
1779
  value: (function () {
1725
- var _ensureQRCodeLibrary = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13() {
1726
- return _regenerator().w(function (_context13) {
1727
- while (1) switch (_context13.n) {
1780
+ var _ensureQRCodeLibrary = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14() {
1781
+ return _regenerator().w(function (_context14) {
1782
+ while (1) switch (_context14.n) {
1728
1783
  case 0:
1729
1784
  if (!(typeof QRCode !== 'undefined')) {
1730
- _context13.n = 1;
1785
+ _context14.n = 1;
1731
1786
  break;
1732
1787
  }
1733
1788
  console.log('✅ QRCode library déjà disponible');
1734
- return _context13.a(2, true);
1789
+ return _context14.a(2, true);
1735
1790
  case 1:
1736
1791
  console.log('📦 Chargement QRCode library...');
1737
- return _context13.a(2, new Promise(function (resolve, reject) {
1792
+ return _context14.a(2, new Promise(function (resolve, reject) {
1738
1793
  var script = document.createElement('script');
1739
1794
  script.src = 'https://cdn.jsdelivr.net/npm/qrcode@1.5.3/lib/browser.min.js';
1740
1795
  script.onload = function () {
@@ -1755,7 +1810,7 @@ function _unsupportedIterableToArray(r, a) {
1755
1810
  document.head.appendChild(script);
1756
1811
  }));
1757
1812
  }
1758
- }, _callee13);
1813
+ }, _callee14);
1759
1814
  }));
1760
1815
  function ensureQRCodeLibrary() {
1761
1816
  return _ensureQRCodeLibrary.apply(this, arguments);
@@ -1842,19 +1897,19 @@ function _unsupportedIterableToArray(r, a) {
1842
1897
  }, {
1843
1898
  key: "refreshQR",
1844
1899
  value: (function () {
1845
- var _refreshQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14(containerId) {
1900
+ var _refreshQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15(containerId) {
1846
1901
  var options,
1847
1902
  result,
1848
1903
  _result,
1849
- _args14 = arguments,
1904
+ _args15 = arguments,
1850
1905
  _t1;
1851
- return _regenerator().w(function (_context14) {
1852
- while (1) switch (_context14.p = _context14.n) {
1906
+ return _regenerator().w(function (_context15) {
1907
+ while (1) switch (_context15.p = _context15.n) {
1853
1908
  case 0:
1854
- options = _args14.length > 1 && _args14[1] !== undefined ? _args14[1] : {};
1855
- _context14.p = 1;
1909
+ options = _args15.length > 1 && _args15[1] !== undefined ? _args15[1] : {};
1910
+ _context15.p = 1;
1856
1911
  if (!this.currentQRUrl) {
1857
- _context14.n = 3;
1912
+ _context15.n = 3;
1858
1913
  break;
1859
1914
  }
1860
1915
  console.log('🔄 Vérification du statut du QR code existant...');
@@ -1864,31 +1919,31 @@ function _unsupportedIterableToArray(r, a) {
1864
1919
 
1865
1920
  // Option 2: Régénérer le QR code seulement si nécessaire
1866
1921
  // Pour l'instant, on régénère pour s'assurer qu'il est à jour
1867
- _context14.n = 2;
1922
+ _context15.n = 2;
1868
1923
  return this.generateQR(containerId, options);
1869
1924
  case 2:
1870
- result = _context14.v;
1871
- return _context14.a(2, result);
1925
+ result = _context15.v;
1926
+ return _context15.a(2, result);
1872
1927
  case 3:
1873
1928
  console.log('🔄 Pas de QR code existant, génération d\'un nouveau...');
1874
- _context14.n = 4;
1929
+ _context15.n = 4;
1875
1930
  return this.generateQR(containerId, options);
1876
1931
  case 4:
1877
- _result = _context14.v;
1878
- return _context14.a(2, _result);
1932
+ _result = _context15.v;
1933
+ return _context15.a(2, _result);
1879
1934
  case 5:
1880
- _context14.n = 7;
1935
+ _context15.n = 7;
1881
1936
  break;
1882
1937
  case 6:
1883
- _context14.p = 6;
1884
- _t1 = _context14.v;
1938
+ _context15.p = 6;
1939
+ _t1 = _context15.v;
1885
1940
  console.error('Erreur lors du rafraîchissement:', _t1.message);
1886
1941
  this.displayServiceUnavailable(containerId, this.config.type);
1887
1942
  throw _t1;
1888
1943
  case 7:
1889
- return _context14.a(2);
1944
+ return _context15.a(2);
1890
1945
  }
1891
- }, _callee14, this, [[1, 6]]);
1946
+ }, _callee15, this, [[1, 6]]);
1892
1947
  }));
1893
1948
  function refreshQR(_x22) {
1894
1949
  return _refreshQR.apply(this, arguments);
@@ -1902,7 +1957,7 @@ function _unsupportedIterableToArray(r, a) {
1902
1957
  }, {
1903
1958
  key: "startAutoRefresh",
1904
1959
  value: function startAutoRefresh(containerId, type, options) {
1905
- var _this3 = this;
1960
+ var _this4 = this;
1906
1961
  if (!this.config.autoRefresh) return;
1907
1962
 
1908
1963
  // Arrêter le timer existant s'il y en a un
@@ -1910,26 +1965,26 @@ function _unsupportedIterableToArray(r, a) {
1910
1965
  clearInterval(this.refreshTimer);
1911
1966
  console.log('🔄 Timer de rafraîchissement précédent arrêté');
1912
1967
  }
1913
- this.refreshTimer = setInterval(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15() {
1968
+ this.refreshTimer = setInterval(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16() {
1914
1969
  var _t10;
1915
- return _regenerator().w(function (_context15) {
1916
- while (1) switch (_context15.p = _context15.n) {
1970
+ return _regenerator().w(function (_context16) {
1971
+ while (1) switch (_context16.p = _context16.n) {
1917
1972
  case 0:
1918
- _context15.p = 0;
1973
+ _context16.p = 0;
1919
1974
  console.log('🔄 Rafraîchissement automatique du QR code...');
1920
- _context15.n = 1;
1921
- return _this3.refreshQR(containerId, type, options);
1975
+ _context16.n = 1;
1976
+ return _this4.refreshQR(containerId, type, options);
1922
1977
  case 1:
1923
- _context15.n = 3;
1978
+ _context16.n = 3;
1924
1979
  break;
1925
1980
  case 2:
1926
- _context15.p = 2;
1927
- _t10 = _context15.v;
1981
+ _context16.p = 2;
1982
+ _t10 = _context16.v;
1928
1983
  console.warn('Erreur lors du rafraîchissement automatique:', _t10);
1929
1984
  case 3:
1930
- return _context15.a(2);
1985
+ return _context16.a(2);
1931
1986
  }
1932
- }, _callee15, null, [[0, 2]]);
1987
+ }, _callee16, null, [[0, 2]]);
1933
1988
  })), this.config.refreshInterval);
1934
1989
  console.log("\uD83D\uDD04 Timer de rafra\xEEchissement d\xE9marr\xE9 (".concat(this.config.refreshInterval, "ms)"));
1935
1990
  }
@@ -1944,16 +1999,16 @@ function _unsupportedIterableToArray(r, a) {
1944
1999
  }, {
1945
2000
  key: "makeRequest",
1946
2001
  value: (function () {
1947
- var _makeRequest = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16(endpoint, data) {
2002
+ var _makeRequest = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17(endpoint, data) {
1948
2003
  var _window$SunuIDConfig4,
1949
2004
  _window$SunuIDConfig5,
1950
- _this4 = this;
2005
+ _this5 = this;
1951
2006
  var sanitizedData, endpointPath, url, retryCount, maxRetries, _loop, _ret;
1952
- return _regenerator().w(function (_context17) {
1953
- while (1) switch (_context17.n) {
2007
+ return _regenerator().w(function (_context18) {
2008
+ while (1) switch (_context18.n) {
1954
2009
  case 0:
1955
2010
  if (this.isInitialized) {
1956
- _context17.n = 1;
2011
+ _context18.n = 1;
1957
2012
  break;
1958
2013
  }
1959
2014
  this.logSecurityEvent('REQUEST_BEFORE_INIT', {
@@ -1962,12 +2017,12 @@ function _unsupportedIterableToArray(r, a) {
1962
2017
  throw new Error('SDK non initialisé');
1963
2018
  case 1:
1964
2019
  if (!this.config.secureInit) {
1965
- _context17.n = 2;
2020
+ _context18.n = 2;
1966
2021
  break;
1967
2022
  }
1968
2023
  this.config.requestCount++;
1969
2024
  if (!(this.config.requestCount > this.config.maxRequests)) {
1970
- _context17.n = 2;
2025
+ _context18.n = 2;
1971
2026
  break;
1972
2027
  }
1973
2028
  this.logSecurityEvent('API_REQUEST_LIMIT_EXCEEDED', {
@@ -2003,14 +2058,14 @@ function _unsupportedIterableToArray(r, a) {
2003
2058
  maxRetries = this.config.maxRetries;
2004
2059
  _loop = /*#__PURE__*/_regenerator().m(function _loop() {
2005
2060
  var controller, timeoutId, headers, response, errorText, errorData, result, _t11;
2006
- return _regenerator().w(function (_context16) {
2007
- while (1) switch (_context16.p = _context16.n) {
2061
+ return _regenerator().w(function (_context17) {
2062
+ while (1) switch (_context17.p = _context17.n) {
2008
2063
  case 0:
2009
- _context16.p = 0;
2064
+ _context17.p = 0;
2010
2065
  controller = new AbortController();
2011
2066
  timeoutId = setTimeout(function () {
2012
2067
  return controller.abort();
2013
- }, _this4.config.requestTimeout); // Headers minimaux (API SunuID n'accepte que les headers essentiels)
2068
+ }, _this5.config.requestTimeout); // Headers minimaux (API SunuID n'accepte que les headers essentiels)
2014
2069
  headers = {
2015
2070
  'Content-Type': 'application/json'
2016
2071
  }; // Note: En mode sécurisé, les credentials sont dans le body
@@ -2018,7 +2073,7 @@ function _unsupportedIterableToArray(r, a) {
2018
2073
  // if (this.config.secureInit && this.config.token) {
2019
2074
  // headers['X-Secure-Token'] = this.config.token;
2020
2075
  // }
2021
- _context16.n = 1;
2076
+ _context17.n = 1;
2022
2077
  return fetch(url, {
2023
2078
  method: 'POST',
2024
2079
  headers: headers,
@@ -2026,16 +2081,16 @@ function _unsupportedIterableToArray(r, a) {
2026
2081
  signal: controller.signal
2027
2082
  });
2028
2083
  case 1:
2029
- response = _context16.v;
2084
+ response = _context17.v;
2030
2085
  clearTimeout(timeoutId);
2031
2086
  if (response.ok) {
2032
- _context16.n = 3;
2087
+ _context17.n = 3;
2033
2088
  break;
2034
2089
  }
2035
- _context16.n = 2;
2090
+ _context17.n = 2;
2036
2091
  return response.text();
2037
2092
  case 2:
2038
- errorText = _context16.v;
2093
+ errorText = _context17.v;
2039
2094
  try {
2040
2095
  errorData = JSON.parse(errorText);
2041
2096
  } catch (e) {
@@ -2043,88 +2098,88 @@ function _unsupportedIterableToArray(r, a) {
2043
2098
  message: errorText
2044
2099
  };
2045
2100
  }
2046
- _this4.logSecurityEvent('API_REQUEST_ERROR', {
2101
+ _this5.logSecurityEvent('API_REQUEST_ERROR', {
2047
2102
  status: response.status,
2048
2103
  statusText: response.statusText,
2049
2104
  error: errorData.message
2050
2105
  });
2051
2106
  throw new Error(errorData.message || "Erreur HTTP: ".concat(response.status));
2052
2107
  case 3:
2053
- _context16.n = 4;
2108
+ _context17.n = 4;
2054
2109
  return response.json();
2055
2110
  case 4:
2056
- result = _context16.v;
2057
- _this4.logSecurityEvent('API_REQUEST_SUCCESS', {
2111
+ result = _context17.v;
2112
+ _this5.logSecurityEvent('API_REQUEST_SUCCESS', {
2058
2113
  endpoint: endpointPath,
2059
2114
  responseKeys: Object.keys(result)
2060
2115
  });
2061
- return _context16.a(2, {
2116
+ return _context17.a(2, {
2062
2117
  v: result
2063
2118
  });
2064
2119
  case 5:
2065
- _context16.p = 5;
2066
- _t11 = _context16.v;
2120
+ _context17.p = 5;
2121
+ _t11 = _context17.v;
2067
2122
  retryCount++;
2068
2123
  if (!(_t11.name === 'AbortError')) {
2069
- _context16.n = 7;
2124
+ _context17.n = 7;
2070
2125
  break;
2071
2126
  }
2072
- _this4.logSecurityEvent('API_REQUEST_TIMEOUT', {
2127
+ _this5.logSecurityEvent('API_REQUEST_TIMEOUT', {
2073
2128
  retryCount: retryCount
2074
2129
  });
2075
2130
  if (!(retryCount > maxRetries)) {
2076
- _context16.n = 6;
2131
+ _context17.n = 6;
2077
2132
  break;
2078
2133
  }
2079
2134
  throw new Error('Timeout de la requête API');
2080
2135
  case 6:
2081
- return _context16.a(2, 0);
2136
+ return _context17.a(2, 0);
2082
2137
  case 7:
2083
2138
  if (!(retryCount > maxRetries)) {
2084
- _context16.n = 8;
2139
+ _context17.n = 8;
2085
2140
  break;
2086
2141
  }
2087
- _this4.logSecurityEvent('API_REQUEST_MAX_RETRIES', {
2142
+ _this5.logSecurityEvent('API_REQUEST_MAX_RETRIES', {
2088
2143
  retryCount: retryCount,
2089
2144
  error: _t11.message
2090
2145
  });
2091
2146
  throw _t11;
2092
2147
  case 8:
2093
- _context16.n = 9;
2148
+ _context17.n = 9;
2094
2149
  return new Promise(function (resolve) {
2095
2150
  return setTimeout(resolve, 1000 * retryCount);
2096
2151
  });
2097
2152
  case 9:
2098
- return _context16.a(2);
2153
+ return _context17.a(2);
2099
2154
  }
2100
2155
  }, _loop, null, [[0, 5]]);
2101
2156
  });
2102
2157
  case 3:
2103
2158
  if (!(retryCount <= maxRetries)) {
2104
- _context17.n = 7;
2159
+ _context18.n = 7;
2105
2160
  break;
2106
2161
  }
2107
- return _context17.d(_regeneratorValues(_loop()), 4);
2162
+ return _context18.d(_regeneratorValues(_loop()), 4);
2108
2163
  case 4:
2109
- _ret = _context17.v;
2164
+ _ret = _context18.v;
2110
2165
  if (!(_ret === 0)) {
2111
- _context17.n = 5;
2166
+ _context18.n = 5;
2112
2167
  break;
2113
2168
  }
2114
- return _context17.a(3, 3);
2169
+ return _context18.a(3, 3);
2115
2170
  case 5:
2116
2171
  if (!_ret) {
2117
- _context17.n = 6;
2172
+ _context18.n = 6;
2118
2173
  break;
2119
2174
  }
2120
- return _context17.a(2, _ret.v);
2175
+ return _context18.a(2, _ret.v);
2121
2176
  case 6:
2122
- _context17.n = 3;
2177
+ _context18.n = 3;
2123
2178
  break;
2124
2179
  case 7:
2125
- return _context17.a(2);
2180
+ return _context18.a(2);
2126
2181
  }
2127
- }, _callee16, this);
2182
+ }, _callee17, this);
2128
2183
  }));
2129
2184
  function makeRequest(_x23, _x24) {
2130
2185
  return _makeRequest.apply(this, arguments);
@@ -2195,20 +2250,20 @@ function _unsupportedIterableToArray(r, a) {
2195
2250
  }, {
2196
2251
  key: "fetchPartnerInfo",
2197
2252
  value: (function () {
2198
- var _fetchPartnerInfo = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17() {
2253
+ var _fetchPartnerInfo = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18() {
2199
2254
  var response, data, partnerId, _t12;
2200
- return _regenerator().w(function (_context18) {
2201
- while (1) switch (_context18.p = _context18.n) {
2255
+ return _regenerator().w(function (_context19) {
2256
+ while (1) switch (_context19.p = _context19.n) {
2202
2257
  case 0:
2203
- _context18.p = 0;
2204
- _context18.n = 1;
2258
+ _context19.p = 0;
2259
+ _context19.n = 1;
2205
2260
  return this.makeRequest('/debug', {
2206
2261
  type: this.config.type,
2207
2262
  client_id: this.config.clientId,
2208
2263
  secret_id: this.config.secretId
2209
2264
  });
2210
2265
  case 1:
2211
- response = _context18.v;
2266
+ response = _context19.v;
2212
2267
  console.log('📋 Réponse debug API:', response);
2213
2268
 
2214
2269
  // Vérifier la structure de la réponse
@@ -2252,17 +2307,17 @@ function _unsupportedIterableToArray(r, a) {
2252
2307
  console.warn('⚠️ Structure de réponse invalide, utilisation du partner_id par défaut');
2253
2308
  this.config.partnerName = "Partner_".concat(this.config.partnerId || 'unknown');
2254
2309
  }
2255
- _context18.n = 3;
2310
+ _context19.n = 3;
2256
2311
  break;
2257
2312
  case 2:
2258
- _context18.p = 2;
2259
- _t12 = _context18.v;
2313
+ _context19.p = 2;
2314
+ _t12 = _context19.v;
2260
2315
  console.warn('⚠️ Erreur lors de la récupération des informations du partenaire:', _t12.message);
2261
2316
  this.config.partnerName = 'Partner_unknown';
2262
2317
  case 3:
2263
- return _context18.a(2);
2318
+ return _context19.a(2);
2264
2319
  }
2265
- }, _callee17, this, [[0, 2]]);
2320
+ }, _callee18, this, [[0, 2]]);
2266
2321
  }));
2267
2322
  function fetchPartnerInfo() {
2268
2323
  return _fetchPartnerInfo.apply(this, arguments);
@@ -2300,18 +2355,18 @@ function _unsupportedIterableToArray(r, a) {
2300
2355
  }, {
2301
2356
  key: "checkConnections",
2302
2357
  value: (function () {
2303
- var _checkConnections = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18() {
2358
+ var _checkConnections = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19() {
2304
2359
  var status, testResponse, debugData, _t13;
2305
- return _regenerator().w(function (_context19) {
2306
- while (1) switch (_context19.p = _context19.n) {
2360
+ return _regenerator().w(function (_context20) {
2361
+ while (1) switch (_context20.p = _context20.n) {
2307
2362
  case 0:
2308
2363
  status = {
2309
2364
  api: false,
2310
2365
  websocket: false,
2311
2366
  ready: false
2312
2367
  }; // Vérifier l'API en utilisant l'endpoint debug avec les credentials
2313
- _context19.p = 1;
2314
- _context19.n = 2;
2368
+ _context20.p = 1;
2369
+ _context20.n = 2;
2315
2370
  return fetch(this.config.apiUrl + '/debug', {
2316
2371
  method: 'POST',
2317
2372
  headers: {
@@ -2324,29 +2379,29 @@ function _unsupportedIterableToArray(r, a) {
2324
2379
  })
2325
2380
  });
2326
2381
  case 2:
2327
- testResponse = _context19.v;
2382
+ testResponse = _context20.v;
2328
2383
  if (!testResponse.ok) {
2329
- _context19.n = 4;
2384
+ _context20.n = 4;
2330
2385
  break;
2331
2386
  }
2332
- _context19.n = 3;
2387
+ _context20.n = 3;
2333
2388
  return testResponse.json();
2334
2389
  case 3:
2335
- debugData = _context19.v;
2390
+ debugData = _context20.v;
2336
2391
  // L'API est accessible si on reçoit une réponse avec success: true
2337
2392
  status.api = debugData.success === true;
2338
2393
  console.log('🔍 API Status:', status.api ? 'accessible' : 'inaccessible');
2339
- _context19.n = 5;
2394
+ _context20.n = 5;
2340
2395
  break;
2341
2396
  case 4:
2342
2397
  status.api = false;
2343
2398
  console.log('🔍 API Status: HTTP', testResponse.status);
2344
2399
  case 5:
2345
- _context19.n = 7;
2400
+ _context20.n = 7;
2346
2401
  break;
2347
2402
  case 6:
2348
- _context19.p = 6;
2349
- _t13 = _context19.v;
2403
+ _context20.p = 6;
2404
+ _t13 = _context20.v;
2350
2405
  console.log('🔍 Test API échoué:', _t13.message);
2351
2406
  status.api = false;
2352
2407
  case 7:
@@ -2355,9 +2410,9 @@ function _unsupportedIterableToArray(r, a) {
2355
2410
 
2356
2411
  // Connexions prêtes si API est accessible
2357
2412
  status.ready = status.api;
2358
- return _context19.a(2, status);
2413
+ return _context20.a(2, status);
2359
2414
  }
2360
- }, _callee18, this, [[1, 6]]);
2415
+ }, _callee19, this, [[1, 6]]);
2361
2416
  }));
2362
2417
  function checkConnections() {
2363
2418
  return _checkConnections.apply(this, arguments);
@@ -2371,46 +2426,46 @@ function _unsupportedIterableToArray(r, a) {
2371
2426
  }, {
2372
2427
  key: "waitForConnections",
2373
2428
  value: (function () {
2374
- var _waitForConnections = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19() {
2429
+ var _waitForConnections = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee20() {
2375
2430
  var timeout,
2376
2431
  startTime,
2377
2432
  status,
2378
- _args20 = arguments;
2379
- return _regenerator().w(function (_context20) {
2380
- while (1) switch (_context20.n) {
2433
+ _args21 = arguments;
2434
+ return _regenerator().w(function (_context21) {
2435
+ while (1) switch (_context21.n) {
2381
2436
  case 0:
2382
- timeout = _args20.length > 0 && _args20[0] !== undefined ? _args20[0] : 5000;
2437
+ timeout = _args21.length > 0 && _args21[0] !== undefined ? _args21[0] : 5000;
2383
2438
  startTime = Date.now();
2384
2439
  case 1:
2385
2440
  if (!(Date.now() - startTime < timeout)) {
2386
- _context20.n = 5;
2441
+ _context21.n = 5;
2387
2442
  break;
2388
2443
  }
2389
- _context20.n = 2;
2444
+ _context21.n = 2;
2390
2445
  return this.checkConnections();
2391
2446
  case 2:
2392
- status = _context20.v;
2447
+ status = _context21.v;
2393
2448
  if (!status.ready) {
2394
- _context20.n = 3;
2449
+ _context21.n = 3;
2395
2450
  break;
2396
2451
  }
2397
2452
  console.log('✅ Connexions prêtes');
2398
- return _context20.a(2, status);
2453
+ return _context21.a(2, status);
2399
2454
  case 3:
2400
2455
  console.log('⏳ Attente connexions...', status);
2401
- _context20.n = 4;
2456
+ _context21.n = 4;
2402
2457
  return new Promise(function (resolve) {
2403
2458
  return setTimeout(resolve, 1000);
2404
2459
  });
2405
2460
  case 4:
2406
- _context20.n = 1;
2461
+ _context21.n = 1;
2407
2462
  break;
2408
2463
  case 5:
2409
2464
  throw new Error('Timeout connexions - Impossible de générer le QR code');
2410
2465
  case 6:
2411
- return _context20.a(2);
2466
+ return _context21.a(2);
2412
2467
  }
2413
- }, _callee19, this);
2468
+ }, _callee20, this);
2414
2469
  }));
2415
2470
  function waitForConnections() {
2416
2471
  return _waitForConnections.apply(this, arguments);
@@ -2509,6 +2564,206 @@ function _unsupportedIterableToArray(r, a) {
2509
2564
  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 ";
2510
2565
  console.log('✅ Loader affiché avec succès');
2511
2566
  }
2567
+
2568
+ /**
2569
+ * Gérer le callback SunuID
2570
+ */
2571
+ }, {
2572
+ key: "handleCallback",
2573
+ value: function handleCallback() {
2574
+ var urlParams = new URLSearchParams(window.location.search);
2575
+
2576
+ // Vérifier si c'est un callback SunuID
2577
+ if (urlParams.has('token') && urlParams.has('session_id')) {
2578
+ console.log('🔗 Callback SunuID détecté');
2579
+
2580
+ // Récupérer les paramètres
2581
+ var callbackData = {
2582
+ token: urlParams.get('token'),
2583
+ state: urlParams.get('state'),
2584
+ session_id: urlParams.get('session_id'),
2585
+ user_id: urlParams.get('user_id'),
2586
+ partner_id: urlParams.get('partner_id'),
2587
+ type: urlParams.get('type'),
2588
+ timestamp: urlParams.get('timestamp'),
2589
+ signature: urlParams.get('signature')
2590
+ };
2591
+ console.log('📋 Données callback:', callbackData);
2592
+
2593
+ // Valider le callback
2594
+ this.validateCallback(callbackData);
2595
+
2596
+ // Traiter l'authentification
2597
+ this.processAuthentication(callbackData);
2598
+ return true;
2599
+ }
2600
+ return false;
2601
+ }
2602
+
2603
+ /**
2604
+ * Valider le callback
2605
+ */
2606
+ }, {
2607
+ key: "validateCallback",
2608
+ value: function validateCallback(data) {
2609
+ console.log('🔒 Validation du callback...');
2610
+
2611
+ // Vérifier l'état de sécurité
2612
+ if (data.state && data.state !== this.config.state) {
2613
+ console.error('❌ État de sécurité invalide');
2614
+ throw new Error('État de sécurité invalide');
2615
+ }
2616
+
2617
+ // Vérifier la signature (si configurée)
2618
+ if (data.signature && this.config.verifySignature) {
2619
+ if (!this.verifySignature(data)) {
2620
+ console.error('❌ Signature invalide');
2621
+ throw new Error('Signature invalide');
2622
+ }
2623
+ }
2624
+
2625
+ // Vérifier l'expiration
2626
+ if (data.timestamp && this.isExpired(data.timestamp)) {
2627
+ console.error('❌ Token expiré');
2628
+ throw new Error('Token expiré');
2629
+ }
2630
+ console.log('✅ Callback validé avec succès');
2631
+ }
2632
+
2633
+ /**
2634
+ * Traiter l'authentification
2635
+ */
2636
+ }, {
2637
+ key: "processAuthentication",
2638
+ value: function processAuthentication(data) {
2639
+ console.log('🔐 Traitement de l\'authentification...');
2640
+ try {
2641
+ // Décoder le JWT token
2642
+ var decodedToken = this.decodeJWT(data.token);
2643
+
2644
+ // Vérifier les données utilisateur
2645
+ var userData = {
2646
+ user_id: decodedToken.user_id || data.user_id,
2647
+ session_id: decodedToken.session_id || data.session_id,
2648
+ partner_id: decodedToken.partner_id || data.partner_id,
2649
+ type: decodedToken.type || data.type,
2650
+ iat: decodedToken.iat,
2651
+ exp: decodedToken.exp
2652
+ };
2653
+ console.log('👤 Données utilisateur:', userData);
2654
+
2655
+ // Émettre l'événement de succès
2656
+ this.emitWebSocketEvent('authentication_success', {
2657
+ userData: userData,
2658
+ callbackData: data,
2659
+ timestamp: Date.now()
2660
+ });
2661
+
2662
+ // Appeler le callback de succès
2663
+ if (this.config.onAuthenticationSuccess) {
2664
+ this.config.onAuthenticationSuccess(userData, data);
2665
+ }
2666
+
2667
+ // Rediriger si configuré
2668
+ if (this.config.redirectAfterSuccess) {
2669
+ this.redirectAfterSuccess(userData);
2670
+ }
2671
+ console.log('✅ Authentification traitée avec succès');
2672
+ } catch (error) {
2673
+ console.error('❌ Erreur lors du traitement:', error);
2674
+
2675
+ // Appeler le callback d'erreur
2676
+ if (this.config.onAuthenticationError) {
2677
+ this.config.onAuthenticationError(error, data);
2678
+ }
2679
+ throw error;
2680
+ }
2681
+ }
2682
+
2683
+ /**
2684
+ * Décoder un JWT token
2685
+ */
2686
+ }, {
2687
+ key: "decodeJWT",
2688
+ value: function decodeJWT(token) {
2689
+ try {
2690
+ // Décodage simple du JWT (sans vérification de signature)
2691
+ var parts = token.split('.');
2692
+ if (parts.length !== 3) {
2693
+ throw new Error('Format JWT invalide');
2694
+ }
2695
+ var payload = parts[1];
2696
+ var decoded = JSON.parse(atob(payload));
2697
+ return decoded;
2698
+ } catch (error) {
2699
+ console.error('❌ Erreur décodage JWT:', error);
2700
+ throw new Error('Token JWT invalide');
2701
+ }
2702
+ }
2703
+
2704
+ /**
2705
+ * Vérifier la signature
2706
+ */
2707
+ }, {
2708
+ key: "verifySignature",
2709
+ value: function verifySignature(data) {
2710
+ // Implémentation basique - à adapter selon vos besoins
2711
+ var expectedSignature = this.generateSignature(data);
2712
+ return data.signature === expectedSignature;
2713
+ }
2714
+
2715
+ /**
2716
+ * Générer une signature
2717
+ */
2718
+ }, {
2719
+ key: "generateSignature",
2720
+ value: function generateSignature(data) {
2721
+ // Implémentation basique - à adapter selon vos besoins
2722
+ var payload = "".concat(data.token, ".").concat(data.state, ".").concat(data.session_id, ".").concat(data.timestamp);
2723
+ return btoa(payload).slice(0, 12); // Signature simplifiée
2724
+ }
2725
+
2726
+ /**
2727
+ * Vérifier l'expiration
2728
+ */
2729
+ }, {
2730
+ key: "isExpired",
2731
+ value: function isExpired(timestamp) {
2732
+ var currentTime = Math.floor(Date.now() / 1000);
2733
+ var tokenTime = parseInt(timestamp);
2734
+ var maxAge = this.config.tokenMaxAge || 300; // 5 minutes par défaut
2735
+
2736
+ return currentTime - tokenTime > maxAge;
2737
+ }
2738
+
2739
+ /**
2740
+ * Rediriger après succès
2741
+ */
2742
+ }, {
2743
+ key: "redirectAfterSuccess",
2744
+ value: function redirectAfterSuccess(userData) {
2745
+ var redirectUrl = this.config.redirectAfterSuccess;
2746
+
2747
+ // Remplacer les variables dans l'URL
2748
+ redirectUrl = redirectUrl.replace('{user_id}', userData.user_id).replace('{session_id}', userData.session_id).replace('{partner_id}', userData.partner_id).replace('{type}', userData.type);
2749
+ console.log('🔄 Redirection vers:', redirectUrl);
2750
+
2751
+ // Redirection avec délai pour permettre les callbacks
2752
+ setTimeout(function () {
2753
+ window.location.href = redirectUrl;
2754
+ }, 100);
2755
+ }
2756
+
2757
+ /**
2758
+ * Générer un état de sécurité
2759
+ */
2760
+ }, {
2761
+ key: "generateState",
2762
+ value: function generateState() {
2763
+ var state = 'sunuid_' + Date.now() + '_' + Math.random().toString(36).substr(2, 9);
2764
+ this.config.state = state;
2765
+ return state;
2766
+ }
2512
2767
  }]);
2513
2768
  }(); // Exposer la classe globalement
2514
2769
  window.SunuID = SunuID;