sunuid-sdk 1.0.41 → 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.
@@ -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,
@@ -334,11 +334,11 @@ function _unsupportedIterableToArray(r, a) {
334
334
  this.refreshTimer = null;
335
335
  this.isInitialized = false;
336
336
  this.socket = null;
337
+ this.initPromise = null;
337
338
 
338
- // Initialisation asynchrone seulement si autoInit est activé
339
- if (this.config.autoInit !== false) {
340
- this.initPromise = this.init();
341
- }
339
+ // DÉSACTIVÉ : Initialisation automatique pour éviter les boucles
340
+ // L'utilisateur doit appeler init() manuellement
341
+ console.log('🔧 SDK SunuID créé - Appelez init() manuellement');
342
342
  }
343
343
 
344
344
  /**
@@ -348,26 +348,77 @@ function _unsupportedIterableToArray(r, a) {
348
348
  key: "init",
349
349
  value: (function () {
350
350
  var _init = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
351
- var _t;
352
351
  return _regenerator().w(function (_context) {
353
352
  while (1) switch (_context.p = _context.n) {
354
353
  case 0:
355
- _context.p = 0;
356
- if (!this.handleCallback()) {
354
+ if (!this.isInitialized) {
357
355
  _context.n = 1;
358
356
  break;
359
357
  }
360
- console.log(' Callback traité, initialisation terminée');
358
+ console.log('⚠️ SDK déjà initialisé, ignoré');
361
359
  return _context.a(2);
362
360
  case 1:
363
- if (!this.config.secureInit) {
361
+ if (!this.initPromise) {
362
+ _context.n = 2;
363
+ break;
364
+ }
365
+ console.log('⚠️ Initialisation déjà en cours, attente...');
366
+ return _context.a(2, this.initPromise);
367
+ case 2:
368
+ if (!this._initInProgress) {
364
369
  _context.n = 3;
365
370
  break;
366
371
  }
367
- _context.n = 2;
372
+ console.log('⚠️ Initialisation en cours, ignoré');
373
+ return _context.a(2);
374
+ case 3:
375
+ this._initInProgress = true;
376
+ this.initPromise = this._doInit();
377
+ _context.p = 4;
378
+ _context.n = 5;
379
+ return this.initPromise;
380
+ case 5:
381
+ _context.p = 5;
382
+ this._initInProgress = false;
383
+ return _context.f(5);
384
+ case 6:
385
+ return _context.a(2, this.initPromise);
386
+ }
387
+ }, _callee, this, [[4,, 5, 6]]);
388
+ }));
389
+ function init() {
390
+ return _init.apply(this, arguments);
391
+ }
392
+ return init;
393
+ }()
394
+ /**
395
+ * Initialisation interne du SDK
396
+ */
397
+ )
398
+ }, {
399
+ key: "_doInit",
400
+ value: (function () {
401
+ var _doInit2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
402
+ var _t;
403
+ return _regenerator().w(function (_context2) {
404
+ while (1) switch (_context2.p = _context2.n) {
405
+ case 0:
406
+ _context2.p = 0;
407
+ if (!this.handleCallback()) {
408
+ _context2.n = 1;
409
+ break;
410
+ }
411
+ console.log('✅ Callback traité, initialisation terminée');
412
+ return _context2.a(2);
413
+ case 1:
414
+ if (!this.config.secureInit) {
415
+ _context2.n = 3;
416
+ break;
417
+ }
418
+ _context2.n = 2;
368
419
  return this.secureInit();
369
420
  case 2:
370
- _context.n = 4;
421
+ _context2.n = 4;
371
422
  break;
372
423
  case 3:
373
424
  // Validation sécurisée des paramètres
@@ -383,7 +434,7 @@ function _unsupportedIterableToArray(r, a) {
383
434
  });
384
435
 
385
436
  // Récupérer les informations du partenaire depuis l'API
386
- _context.n = 5;
437
+ _context2.n = 5;
387
438
  return this.fetchPartnerInfo();
388
439
  case 5:
389
440
  // Obscurcir les credentials dans les logs
@@ -403,24 +454,24 @@ function _unsupportedIterableToArray(r, a) {
403
454
 
404
455
  // Initialiser la connexion WebSocket
405
456
  this.initWebSocket();
406
- _context.n = 7;
457
+ _context2.n = 7;
407
458
  break;
408
459
  case 6:
409
- _context.p = 6;
410
- _t = _context.v;
460
+ _context2.p = 6;
461
+ _t = _context2.v;
411
462
  this.logSecurityEvent('SDK_INIT_ERROR', {
412
463
  error: _t.message
413
464
  });
414
465
  throw _t;
415
466
  case 7:
416
- return _context.a(2);
467
+ return _context2.a(2);
417
468
  }
418
- }, _callee, this, [[0, 6]]);
469
+ }, _callee2, this, [[0, 6]]);
419
470
  }));
420
- function init() {
421
- return _init.apply(this, arguments);
471
+ function _doInit() {
472
+ return _doInit2.apply(this, arguments);
422
473
  }
423
- return init;
474
+ return _doInit;
424
475
  }()
425
476
  /**
426
477
  * Initialisation sécurisée via PHP
@@ -429,19 +480,19 @@ function _unsupportedIterableToArray(r, a) {
429
480
  }, {
430
481
  key: "secureInit",
431
482
  value: (function () {
432
- var _secureInit = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
483
+ var _secureInit = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
433
484
  var initData, response, result, decodedToken, _t2;
434
- return _regenerator().w(function (_context2) {
435
- while (1) switch (_context2.p = _context2.n) {
485
+ return _regenerator().w(function (_context3) {
486
+ while (1) switch (_context3.p = _context3.n) {
436
487
  case 0:
437
- _context2.p = 0;
488
+ _context3.p = 0;
438
489
  this.logSecurityEvent('SECURE_INIT_START');
439
490
  initData = {
440
491
  type: this.config.type,
441
492
  partnerName: this.config.partnerName,
442
493
  theme: this.config.theme
443
494
  };
444
- _context2.n = 1;
495
+ _context3.n = 1;
445
496
  return fetch(this.config.secureInitUrl, {
446
497
  method: 'POST',
447
498
  headers: {
@@ -451,20 +502,20 @@ function _unsupportedIterableToArray(r, a) {
451
502
  body: JSON.stringify(initData)
452
503
  });
453
504
  case 1:
454
- response = _context2.v;
505
+ response = _context3.v;
455
506
  if (response.ok) {
456
- _context2.n = 2;
507
+ _context3.n = 2;
457
508
  break;
458
509
  }
459
510
  throw new Error("Erreur HTTP: ".concat(response.status));
460
511
  case 2:
461
- _context2.n = 3;
512
+ _context3.n = 3;
462
513
  return response.json();
463
514
  case 3:
464
- result = _context2.v;
515
+ result = _context3.v;
465
516
  console.log('📋 Réponse initialisation sécurisée:', result);
466
517
  if (result.success) {
467
- _context2.n = 4;
518
+ _context3.n = 4;
468
519
  break;
469
520
  }
470
521
  throw new Error(result.error || 'Erreur lors de l\'initialisation sécurisée');
@@ -476,12 +527,12 @@ function _unsupportedIterableToArray(r, a) {
476
527
  // Décoder le token pour récupérer les credentials
477
528
  decodedToken = this.decodeSecureToken(result.data.token);
478
529
  if (!decodedToken) {
479
- _context2.n = 5;
530
+ _context3.n = 5;
480
531
  break;
481
532
  }
482
533
  this.config.clientId = decodedToken.client_id;
483
534
  this.config.secretId = decodedToken.secret_id;
484
- _context2.n = 6;
535
+ _context3.n = 6;
485
536
  break;
486
537
  case 5:
487
538
  throw new Error('Impossible de décoder le token sécurisé');
@@ -494,19 +545,19 @@ function _unsupportedIterableToArray(r, a) {
494
545
  maxRequests: result.data.max_requests
495
546
  });
496
547
  console.log('✅ Initialisation sécurisée réussie');
497
- _context2.n = 8;
548
+ _context3.n = 8;
498
549
  break;
499
550
  case 7:
500
- _context2.p = 7;
501
- _t2 = _context2.v;
551
+ _context3.p = 7;
552
+ _t2 = _context3.v;
502
553
  this.logSecurityEvent('SECURE_INIT_ERROR', {
503
554
  error: _t2.message
504
555
  });
505
556
  throw new Error("\xC9chec de l'initialisation s\xE9curis\xE9e: ".concat(_t2.message));
506
557
  case 8:
507
- return _context2.a(2);
558
+ return _context3.a(2);
508
559
  }
509
- }, _callee2, this, [[0, 7]]);
560
+ }, _callee3, this, [[0, 7]]);
510
561
  }));
511
562
  function secureInit() {
512
563
  return _secureInit.apply(this, arguments);
@@ -865,7 +916,7 @@ function _unsupportedIterableToArray(r, a) {
865
916
  }, {
866
917
  key: "generateQR",
867
918
  value: (function () {
868
- var _generateQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
919
+ var _generateQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
869
920
  var containerId,
870
921
  options,
871
922
  connectionStatus,
@@ -875,25 +926,25 @@ function _unsupportedIterableToArray(r, a) {
875
926
  response,
876
927
  qrImageUrl,
877
928
  isLocal,
878
- _args3 = arguments,
929
+ _args4 = arguments,
879
930
  _t3,
880
931
  _t4;
881
- return _regenerator().w(function (_context3) {
882
- while (1) switch (_context3.p = _context3.n) {
932
+ return _regenerator().w(function (_context4) {
933
+ while (1) switch (_context4.p = _context4.n) {
883
934
  case 0:
884
- containerId = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : 'sunuid-qr-container';
885
- options = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {};
935
+ containerId = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : 'sunuid-qr-container';
936
+ options = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
886
937
  if (!this.initPromise) {
887
- _context3.n = 2;
938
+ _context4.n = 2;
888
939
  break;
889
940
  }
890
- _context3.n = 1;
941
+ _context4.n = 1;
891
942
  return this.initPromise;
892
943
  case 1:
893
944
  this.initPromise = null;
894
945
  case 2:
895
946
  if (this.isInitialized) {
896
- _context3.n = 3;
947
+ _context4.n = 3;
897
948
  break;
898
949
  }
899
950
  throw new Error('SunuID: SDK non initialisé');
@@ -902,22 +953,22 @@ function _unsupportedIterableToArray(r, a) {
902
953
 
903
954
  // Attendre que les connexions soient prêtes
904
955
  console.log('🔍 Attente connexions API et WebSocket...');
905
- _context3.p = 4;
906
- _context3.n = 5;
956
+ _context4.p = 4;
957
+ _context4.n = 5;
907
958
  return this.waitForConnections(5000);
908
959
  case 5:
909
- connectionStatus = _context3.v;
960
+ connectionStatus = _context4.v;
910
961
  // 5 secondes max
911
962
  console.log('✅ Connexions prêtes:', connectionStatus);
912
- _context3.n = 7;
963
+ _context4.n = 7;
913
964
  break;
914
965
  case 6:
915
- _context3.p = 6;
916
- _t3 = _context3.v;
966
+ _context4.p = 6;
967
+ _t3 = _context4.v;
917
968
  console.error('❌ Erreur connexions:', _t3.message);
918
969
  throw new Error('Connexions non disponibles - Impossible de générer le QR code');
919
970
  case 7:
920
- _context3.p = 7;
971
+ _context4.p = 7;
921
972
  // Utiliser uniquement le socketID comme contenu du QR
922
973
  socketId = this.socket ? this.socket.id : 'timeout-socket-id';
923
974
  qrContent = socketId;
@@ -926,7 +977,7 @@ function _unsupportedIterableToArray(r, a) {
926
977
 
927
978
  // Générer le QR avec le contenu complet
928
979
  partnerName = this.config.partnerName || 'Partner_unknown';
929
- _context3.n = 8;
980
+ _context4.n = 8;
930
981
  return this.makeRequest('/qr-generate', _objectSpread2({
931
982
  type: this.config.type,
932
983
  data: qrContent,
@@ -934,9 +985,9 @@ function _unsupportedIterableToArray(r, a) {
934
985
  label: "".concat(this.getTypeName(this.config.type), " ").concat(partnerName)
935
986
  }, options));
936
987
  case 8:
937
- response = _context3.v;
988
+ response = _context4.v;
938
989
  if (!response.success) {
939
- _context3.n = 11;
990
+ _context4.n = 11;
940
991
  break;
941
992
  }
942
993
  // Debug: Afficher la structure complète de la réponse
@@ -951,7 +1002,7 @@ function _unsupportedIterableToArray(r, a) {
951
1002
 
952
1003
  // Vérifier si l'URL du QR code existe
953
1004
  if (qrImageUrl) {
954
- _context3.n = 10;
1005
+ _context4.n = 10;
955
1006
  break;
956
1007
  }
957
1008
  console.warn('⚠️ qrCodeUrl non trouvé dans la réponse, recherche d\'alternatives...');
@@ -959,11 +1010,11 @@ function _unsupportedIterableToArray(r, a) {
959
1010
  // Essayer d'autres champs possibles
960
1011
  qrImageUrl = response.data.qr_url || response.data.qrUrl || response.data.url || response.data.image_url || response.data.imageUrl;
961
1012
  if (!qrImageUrl) {
962
- _context3.n = 9;
1013
+ _context4.n = 9;
963
1014
  break;
964
1015
  }
965
1016
  console.log('✅ URL QR trouvée dans un champ alternatif:', qrImageUrl);
966
- _context3.n = 10;
1017
+ _context4.n = 10;
967
1018
  break;
968
1019
  case 9:
969
1020
  console.error('❌ Aucune URL QR trouvée dans la réponse');
@@ -989,7 +1040,7 @@ function _unsupportedIterableToArray(r, a) {
989
1040
  sessionId: response.data.sessionId,
990
1041
  timestamp: Date.now()
991
1042
  });
992
- return _context3.a(2, _objectSpread2(_objectSpread2({}, response.data), {}, {
1043
+ return _context4.a(2, _objectSpread2(_objectSpread2({}, response.data), {}, {
993
1044
  qrCodeUrl: qrImageUrl,
994
1045
  qrContent: qrContent,
995
1046
  label: response.data.label,
@@ -998,11 +1049,11 @@ function _unsupportedIterableToArray(r, a) {
998
1049
  case 11:
999
1050
  throw new Error(response.message || 'Erreur lors de la génération du QR code');
1000
1051
  case 12:
1001
- _context3.n = 14;
1052
+ _context4.n = 14;
1002
1053
  break;
1003
1054
  case 13:
1004
- _context3.p = 13;
1005
- _t4 = _context3.v;
1055
+ _context4.p = 13;
1056
+ _t4 = _context4.v;
1006
1057
  console.error('Erreur API détectée:', _t4.message);
1007
1058
  console.error('Stack trace complet:', _t4.stack);
1008
1059
  console.error('Configuration SDK:', {
@@ -1034,9 +1085,9 @@ function _unsupportedIterableToArray(r, a) {
1034
1085
  this.displayServiceUnavailable(containerId, this.config.type);
1035
1086
  throw new Error('Service non disponible');
1036
1087
  case 14:
1037
- return _context3.a(2);
1088
+ return _context4.a(2);
1038
1089
  }
1039
- }, _callee3, this, [[7, 13], [4, 6]]);
1090
+ }, _callee4, this, [[7, 13], [4, 6]]);
1040
1091
  }));
1041
1092
  function generateQR() {
1042
1093
  return _generateQR.apply(this, arguments);
@@ -1050,41 +1101,41 @@ function _unsupportedIterableToArray(r, a) {
1050
1101
  }, {
1051
1102
  key: "generateCustomQR",
1052
1103
  value: (function () {
1053
- var _generateCustomQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(containerId, type) {
1104
+ var _generateCustomQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(containerId, type) {
1054
1105
  var options,
1055
1106
  response,
1056
1107
  imageBaseUrl,
1057
1108
  qrImageUrl,
1058
- _args4 = arguments,
1109
+ _args5 = arguments,
1059
1110
  _t5;
1060
- return _regenerator().w(function (_context4) {
1061
- while (1) switch (_context4.p = _context4.n) {
1111
+ return _regenerator().w(function (_context5) {
1112
+ while (1) switch (_context5.p = _context5.n) {
1062
1113
  case 0:
1063
- options = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : {};
1114
+ options = _args5.length > 2 && _args5[2] !== undefined ? _args5[2] : {};
1064
1115
  if (!this.initPromise) {
1065
- _context4.n = 2;
1116
+ _context5.n = 2;
1066
1117
  break;
1067
1118
  }
1068
- _context4.n = 1;
1119
+ _context5.n = 1;
1069
1120
  return this.initPromise;
1070
1121
  case 1:
1071
1122
  this.initPromise = null;
1072
1123
  case 2:
1073
1124
  if (this.isInitialized) {
1074
- _context4.n = 3;
1125
+ _context5.n = 3;
1075
1126
  break;
1076
1127
  }
1077
1128
  throw new Error('SunuID: SDK non initialisé');
1078
1129
  case 3:
1079
- _context4.p = 3;
1080
- _context4.n = 4;
1130
+ _context5.p = 3;
1131
+ _context5.n = 4;
1081
1132
  return this.makeRequest('/qr-generate', _objectSpread2({
1082
1133
  type: type
1083
1134
  }, options));
1084
1135
  case 4:
1085
- response = _context4.v;
1136
+ response = _context5.v;
1086
1137
  if (!response.success) {
1087
- _context4.n = 5;
1138
+ _context5.n = 5;
1088
1139
  break;
1089
1140
  }
1090
1141
  // Construire l'URL complète de l'image QR avec la base URL pour les images
@@ -1097,18 +1148,18 @@ function _unsupportedIterableToArray(r, a) {
1097
1148
  console.log('📄 Code de session:', response.data.code);
1098
1149
  console.log('🆔 Service ID:', response.data.service_id);
1099
1150
  this.startAutoRefresh(containerId, type, options);
1100
- return _context4.a(2, _objectSpread2(_objectSpread2({}, response.data), {}, {
1151
+ return _context5.a(2, _objectSpread2(_objectSpread2({}, response.data), {}, {
1101
1152
  qrCodeUrl: qrImageUrl,
1102
1153
  sessionId: response.data.service_id
1103
1154
  }));
1104
1155
  case 5:
1105
1156
  throw new Error(response.message || 'Erreur lors de la génération du QR code');
1106
1157
  case 6:
1107
- _context4.n = 8;
1158
+ _context5.n = 8;
1108
1159
  break;
1109
1160
  case 7:
1110
- _context4.p = 7;
1111
- _t5 = _context4.v;
1161
+ _context5.p = 7;
1162
+ _t5 = _context5.v;
1112
1163
  console.error('Erreur API détectée:', _t5.message);
1113
1164
  console.error('Stack trace complet:', _t5.stack);
1114
1165
  console.error('Configuration SDK (Custom):', {
@@ -1122,9 +1173,9 @@ function _unsupportedIterableToArray(r, a) {
1122
1173
  this.displayServiceUnavailable(containerId, type);
1123
1174
  throw new Error('Service non disponible');
1124
1175
  case 8:
1125
- return _context4.a(2);
1176
+ return _context5.a(2);
1126
1177
  }
1127
- }, _callee4, this, [[3, 7]]);
1178
+ }, _callee5, this, [[3, 7]]);
1128
1179
  }));
1129
1180
  function generateCustomQR(_x, _x2) {
1130
1181
  return _generateCustomQR.apply(this, arguments);
@@ -1135,16 +1186,16 @@ function _unsupportedIterableToArray(r, a) {
1135
1186
  }, {
1136
1187
  key: "generateAuthQR",
1137
1188
  value: function () {
1138
- var _generateAuthQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(containerId) {
1189
+ var _generateAuthQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(containerId) {
1139
1190
  var options,
1140
- _args5 = arguments;
1141
- return _regenerator().w(function (_context5) {
1142
- while (1) switch (_context5.n) {
1191
+ _args6 = arguments;
1192
+ return _regenerator().w(function (_context6) {
1193
+ while (1) switch (_context6.n) {
1143
1194
  case 0:
1144
- options = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : {};
1145
- return _context5.a(2, this.generateQR(containerId, options));
1195
+ options = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : {};
1196
+ return _context6.a(2, this.generateQR(containerId, options));
1146
1197
  }
1147
- }, _callee5, this);
1198
+ }, _callee6, this);
1148
1199
  }));
1149
1200
  function generateAuthQR(_x3) {
1150
1201
  return _generateAuthQR.apply(this, arguments);
@@ -1154,31 +1205,31 @@ function _unsupportedIterableToArray(r, a) {
1154
1205
  }, {
1155
1206
  key: "generateKYCQR",
1156
1207
  value: function () {
1157
- var _generateKYCQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(containerId) {
1208
+ var _generateKYCQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(containerId) {
1158
1209
  var options,
1159
1210
  originalType,
1160
- _args6 = arguments;
1161
- return _regenerator().w(function (_context6) {
1162
- while (1) switch (_context6.p = _context6.n) {
1211
+ _args7 = arguments;
1212
+ return _regenerator().w(function (_context7) {
1213
+ while (1) switch (_context7.p = _context7.n) {
1163
1214
  case 0:
1164
- options = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : {};
1215
+ options = _args7.length > 1 && _args7[1] !== undefined ? _args7[1] : {};
1165
1216
  // Sauvegarder le type actuel
1166
1217
  originalType = this.config.type; // Changer temporairement le type pour KYC
1167
1218
  this.config.type = 1;
1168
- _context6.p = 1;
1169
- _context6.n = 2;
1219
+ _context7.p = 1;
1220
+ _context7.n = 2;
1170
1221
  return this.generateQR(containerId, options);
1171
1222
  case 2:
1172
- return _context6.a(2, _context6.v);
1223
+ return _context7.a(2, _context7.v);
1173
1224
  case 3:
1174
- _context6.p = 3;
1225
+ _context7.p = 3;
1175
1226
  // Restaurer le type original
1176
1227
  this.config.type = originalType;
1177
- return _context6.f(3);
1228
+ return _context7.f(3);
1178
1229
  case 4:
1179
- return _context6.a(2);
1230
+ return _context7.a(2);
1180
1231
  }
1181
- }, _callee6, this, [[1,, 3, 4]]);
1232
+ }, _callee7, this, [[1,, 3, 4]]);
1182
1233
  }));
1183
1234
  function generateKYCQR(_x4) {
1184
1235
  return _generateKYCQR.apply(this, arguments);
@@ -1188,31 +1239,31 @@ function _unsupportedIterableToArray(r, a) {
1188
1239
  }, {
1189
1240
  key: "generateSignatureQR",
1190
1241
  value: function () {
1191
- var _generateSignatureQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(containerId) {
1242
+ var _generateSignatureQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(containerId) {
1192
1243
  var options,
1193
1244
  originalType,
1194
- _args7 = arguments;
1195
- return _regenerator().w(function (_context7) {
1196
- while (1) switch (_context7.p = _context7.n) {
1245
+ _args8 = arguments;
1246
+ return _regenerator().w(function (_context8) {
1247
+ while (1) switch (_context8.p = _context8.n) {
1197
1248
  case 0:
1198
- options = _args7.length > 1 && _args7[1] !== undefined ? _args7[1] : {};
1249
+ options = _args8.length > 1 && _args8[1] !== undefined ? _args8[1] : {};
1199
1250
  // Sauvegarder le type actuel
1200
1251
  originalType = this.config.type; // Changer temporairement le type pour Signature
1201
1252
  this.config.type = 3;
1202
- _context7.p = 1;
1203
- _context7.n = 2;
1253
+ _context8.p = 1;
1254
+ _context8.n = 2;
1204
1255
  return this.generateQR(containerId, options);
1205
1256
  case 2:
1206
- return _context7.a(2, _context7.v);
1257
+ return _context8.a(2, _context8.v);
1207
1258
  case 3:
1208
- _context7.p = 3;
1259
+ _context8.p = 3;
1209
1260
  // Restaurer le type original
1210
1261
  this.config.type = originalType;
1211
- return _context7.f(3);
1262
+ return _context8.f(3);
1212
1263
  case 4:
1213
- return _context7.a(2);
1264
+ return _context8.a(2);
1214
1265
  }
1215
- }, _callee7, this, [[1,, 3, 4]]);
1266
+ }, _callee8, this, [[1,, 3, 4]]);
1216
1267
  }));
1217
1268
  function generateSignatureQR(_x5) {
1218
1269
  return _generateSignatureQR.apply(this, arguments);
@@ -1225,43 +1276,43 @@ function _unsupportedIterableToArray(r, a) {
1225
1276
  }, {
1226
1277
  key: "checkQRStatus",
1227
1278
  value: (function () {
1228
- var _checkQRStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(sessionId) {
1279
+ var _checkQRStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(sessionId) {
1229
1280
  var response, _t6;
1230
- return _regenerator().w(function (_context8) {
1231
- while (1) switch (_context8.p = _context8.n) {
1281
+ return _regenerator().w(function (_context9) {
1282
+ while (1) switch (_context9.p = _context9.n) {
1232
1283
  case 0:
1233
1284
  if (this.isInitialized) {
1234
- _context8.n = 1;
1285
+ _context9.n = 1;
1235
1286
  break;
1236
1287
  }
1237
1288
  throw new Error('SunuID: SDK non initialisé');
1238
1289
  case 1:
1239
- _context8.p = 1;
1240
- _context8.n = 2;
1290
+ _context9.p = 1;
1291
+ _context9.n = 2;
1241
1292
  return this.makeRequest('/qr-status', {
1242
1293
  serviceId: sessionId
1243
1294
  });
1244
1295
  case 2:
1245
- response = _context8.v;
1296
+ response = _context9.v;
1246
1297
  if (!response.success) {
1247
- _context8.n = 3;
1298
+ _context9.n = 3;
1248
1299
  break;
1249
1300
  }
1250
- return _context8.a(2, response.data);
1301
+ return _context9.a(2, response.data);
1251
1302
  case 3:
1252
1303
  throw new Error(response.message || 'Erreur lors de la vérification du statut');
1253
1304
  case 4:
1254
- _context8.n = 6;
1305
+ _context9.n = 6;
1255
1306
  break;
1256
1307
  case 5:
1257
- _context8.p = 5;
1258
- _t6 = _context8.v;
1308
+ _context9.p = 5;
1309
+ _t6 = _context9.v;
1259
1310
  this.handleError(_t6);
1260
1311
  throw _t6;
1261
1312
  case 6:
1262
- return _context8.a(2);
1313
+ return _context9.a(2);
1263
1314
  }
1264
- }, _callee8, this, [[1, 5]]);
1315
+ }, _callee9, this, [[1, 5]]);
1265
1316
  }));
1266
1317
  function checkQRStatus(_x6) {
1267
1318
  return _checkQRStatus.apply(this, arguments);
@@ -1275,47 +1326,47 @@ function _unsupportedIterableToArray(r, a) {
1275
1326
  }, {
1276
1327
  key: "generateQRWithContent",
1277
1328
  value: (function () {
1278
- var _generateQRWithContent = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(content, containerId, type) {
1329
+ var _generateQRWithContent = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(content, containerId, type) {
1279
1330
  var options,
1280
1331
  localQRUrl,
1281
- _args9 = arguments,
1332
+ _args0 = arguments,
1282
1333
  _t7;
1283
- return _regenerator().w(function (_context9) {
1284
- while (1) switch (_context9.p = _context9.n) {
1334
+ return _regenerator().w(function (_context0) {
1335
+ while (1) switch (_context0.p = _context0.n) {
1285
1336
  case 0:
1286
- options = _args9.length > 3 && _args9[3] !== undefined ? _args9[3] : {};
1337
+ options = _args0.length > 3 && _args0[3] !== undefined ? _args0[3] : {};
1287
1338
  console.log('🎨 Génération QR avec contenu:', content);
1288
- _context9.p = 1;
1339
+ _context0.p = 1;
1289
1340
  if (!(window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1' || window.location.protocol === 'file:')) {
1290
- _context9.n = 3;
1341
+ _context0.n = 3;
1291
1342
  break;
1292
1343
  }
1293
1344
  console.log('🏠 Utilisation service QR local...');
1294
- _context9.n = 2;
1345
+ _context0.n = 2;
1295
1346
  return this.generateQRLocal(content, containerId, type, options);
1296
1347
  case 2:
1297
- localQRUrl = _context9.v;
1348
+ localQRUrl = _context0.v;
1298
1349
  if (!localQRUrl) {
1299
- _context9.n = 3;
1350
+ _context0.n = 3;
1300
1351
  break;
1301
1352
  }
1302
- return _context9.a(2, localQRUrl);
1353
+ return _context0.a(2, localQRUrl);
1303
1354
  case 3:
1304
1355
  // Fallback vers le service QR distant
1305
1356
  console.log('🌐 Utilisation service QR distant...');
1306
- _context9.n = 4;
1357
+ _context0.n = 4;
1307
1358
  return this.generateQRRemote(content, containerId, type, options);
1308
1359
  case 4:
1309
- return _context9.a(2, _context9.v);
1360
+ return _context0.a(2, _context0.v);
1310
1361
  case 5:
1311
- _context9.p = 5;
1312
- _t7 = _context9.v;
1362
+ _context0.p = 5;
1363
+ _t7 = _context0.v;
1313
1364
  console.error('❌ Erreur génération QR:', _t7);
1314
1365
  // Fallback vers affichage simple du contenu
1315
1366
  this.displayQRContent(containerId, content, type, options);
1316
- return _context9.a(2, null);
1367
+ return _context0.a(2, null);
1317
1368
  }
1318
- }, _callee9, this, [[1, 5]]);
1369
+ }, _callee0, this, [[1, 5]]);
1319
1370
  }));
1320
1371
  function generateQRWithContent(_x7, _x8, _x9) {
1321
1372
  return _generateQRWithContent.apply(this, arguments);
@@ -1329,19 +1380,19 @@ function _unsupportedIterableToArray(r, a) {
1329
1380
  }, {
1330
1381
  key: "generateQRLocal",
1331
1382
  value: (function () {
1332
- var _generateQRLocal = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(content, containerId, type) {
1383
+ var _generateQRLocal = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(content, containerId, type) {
1333
1384
  var options,
1334
1385
  response,
1335
1386
  data,
1336
1387
  qrUrl,
1337
- _args0 = arguments,
1388
+ _args1 = arguments,
1338
1389
  _t8;
1339
- return _regenerator().w(function (_context0) {
1340
- while (1) switch (_context0.p = _context0.n) {
1390
+ return _regenerator().w(function (_context1) {
1391
+ while (1) switch (_context1.p = _context1.n) {
1341
1392
  case 0:
1342
- options = _args0.length > 3 && _args0[3] !== undefined ? _args0[3] : {};
1343
- _context0.p = 1;
1344
- _context0.n = 2;
1393
+ options = _args1.length > 3 && _args1[3] !== undefined ? _args1[3] : {};
1394
+ _context1.p = 1;
1395
+ _context1.n = 2;
1345
1396
  return fetch('http://localhost:8000/api/generate/text', {
1346
1397
  method: 'POST',
1347
1398
  headers: {
@@ -1350,29 +1401,29 @@ function _unsupportedIterableToArray(r, a) {
1350
1401
  body: "text=".concat(encodeURIComponent(content), "&size=300")
1351
1402
  });
1352
1403
  case 2:
1353
- response = _context0.v;
1404
+ response = _context1.v;
1354
1405
  if (!response.ok) {
1355
- _context0.n = 4;
1406
+ _context1.n = 4;
1356
1407
  break;
1357
1408
  }
1358
- _context0.n = 3;
1409
+ _context1.n = 3;
1359
1410
  return response.json();
1360
1411
  case 3:
1361
- data = _context0.v;
1412
+ data = _context1.v;
1362
1413
  qrUrl = "data:image/png;base64,".concat(data.qrcode);
1363
1414
  this.displayQRCode(containerId, qrUrl, type, options);
1364
- return _context0.a(2, qrUrl);
1415
+ return _context1.a(2, qrUrl);
1365
1416
  case 4:
1366
- _context0.n = 6;
1417
+ _context1.n = 6;
1367
1418
  break;
1368
1419
  case 5:
1369
- _context0.p = 5;
1370
- _t8 = _context0.v;
1420
+ _context1.p = 5;
1421
+ _t8 = _context1.v;
1371
1422
  console.log('❌ Service QR local non disponible:', _t8.message);
1372
1423
  case 6:
1373
- return _context0.a(2, null);
1424
+ return _context1.a(2, null);
1374
1425
  }
1375
- }, _callee0, this, [[1, 5]]);
1426
+ }, _callee1, this, [[1, 5]]);
1376
1427
  }));
1377
1428
  function generateQRLocal(_x0, _x1, _x10) {
1378
1429
  return _generateQRLocal.apply(this, arguments);
@@ -1386,19 +1437,19 @@ function _unsupportedIterableToArray(r, a) {
1386
1437
  }, {
1387
1438
  key: "generateQRRemote",
1388
1439
  value: (function () {
1389
- var _generateQRRemote = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(content, containerId, type) {
1440
+ var _generateQRRemote = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(content, containerId, type) {
1390
1441
  var options,
1391
1442
  response,
1392
1443
  data,
1393
1444
  qrUrl,
1394
- _args1 = arguments,
1445
+ _args10 = arguments,
1395
1446
  _t9;
1396
- return _regenerator().w(function (_context1) {
1397
- while (1) switch (_context1.p = _context1.n) {
1447
+ return _regenerator().w(function (_context10) {
1448
+ while (1) switch (_context10.p = _context10.n) {
1398
1449
  case 0:
1399
- options = _args1.length > 3 && _args1[3] !== undefined ? _args1[3] : {};
1400
- _context1.p = 1;
1401
- _context1.n = 2;
1450
+ options = _args10.length > 3 && _args10[3] !== undefined ? _args10[3] : {};
1451
+ _context10.p = 1;
1452
+ _context10.n = 2;
1402
1453
  return fetch('https://api.sunuid.fayma.sn/qr-generate', {
1403
1454
  method: 'POST',
1404
1455
  headers: {
@@ -1411,31 +1462,31 @@ function _unsupportedIterableToArray(r, a) {
1411
1462
  })
1412
1463
  });
1413
1464
  case 2:
1414
- response = _context1.v;
1465
+ response = _context10.v;
1415
1466
  if (!response.ok) {
1416
- _context1.n = 4;
1467
+ _context10.n = 4;
1417
1468
  break;
1418
1469
  }
1419
- _context1.n = 3;
1470
+ _context10.n = 3;
1420
1471
  return response.json();
1421
1472
  case 3:
1422
- data = _context1.v;
1473
+ data = _context10.v;
1423
1474
  qrUrl = "data:image/png;base64,".concat(data.qrcode);
1424
1475
  this.displayQRCode(containerId, qrUrl, type, options);
1425
- return _context1.a(2, qrUrl);
1476
+ return _context10.a(2, qrUrl);
1426
1477
  case 4:
1427
- _context1.n = 6;
1478
+ _context10.n = 6;
1428
1479
  break;
1429
1480
  case 5:
1430
- _context1.p = 5;
1431
- _t9 = _context1.v;
1481
+ _context10.p = 5;
1482
+ _t9 = _context10.v;
1432
1483
  console.error('❌ Erreur service QR distant:', _t9);
1433
1484
  case 6:
1434
1485
  // Fallback vers affichage du contenu
1435
1486
  this.displayQRContent(containerId, content, type, options);
1436
- return _context1.a(2, null);
1487
+ return _context10.a(2, null);
1437
1488
  }
1438
- }, _callee1, this, [[1, 5]]);
1489
+ }, _callee10, this, [[1, 5]]);
1439
1490
  }));
1440
1491
  function generateQRRemote(_x11, _x12, _x13) {
1441
1492
  return _generateQRRemote.apply(this, arguments);
@@ -1493,11 +1544,11 @@ function _unsupportedIterableToArray(r, a) {
1493
1544
  }, {
1494
1545
  key: "generateCustomQRCode",
1495
1546
  value: (function () {
1496
- var _generateCustomQRCode = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(content, label) {
1547
+ var _generateCustomQRCode = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11(content, label) {
1497
1548
  var qrContainer,
1498
1549
  _t0;
1499
- return _regenerator().w(function (_context10) {
1500
- while (1) switch (_context10.p = _context10.n) {
1550
+ return _regenerator().w(function (_context11) {
1551
+ while (1) switch (_context11.p = _context11.n) {
1501
1552
  case 0:
1502
1553
  console.log('🎨 Début génération QR personnalisé...');
1503
1554
  console.log('📄 Contenu:', content);
@@ -1509,37 +1560,37 @@ function _unsupportedIterableToArray(r, a) {
1509
1560
  qrContainer = document.getElementById('qr-container');
1510
1561
  }
1511
1562
  if (qrContainer) {
1512
- _context10.n = 1;
1563
+ _context11.n = 1;
1513
1564
  break;
1514
1565
  }
1515
1566
  console.error('❌ QR container not found');
1516
- return _context10.a(2);
1567
+ return _context11.a(2);
1517
1568
  case 1:
1518
1569
  console.log('✅ QR container trouvé');
1519
1570
 
1520
1571
  // Nettoyer le conteneur
1521
1572
  qrContainer.innerHTML = '<div style="text-align: center; padding: 20px;"><p>Génération QR code...</p></div>';
1522
- _context10.p = 2;
1573
+ _context11.p = 2;
1523
1574
  // Utiliser directement l'API principale (plus fiable)
1524
1575
  console.log('🎨 Tentative génération via API principale...');
1525
- _context10.n = 3;
1576
+ _context11.n = 3;
1526
1577
  return this.generateQRPHP(content, label, qrContainer);
1527
1578
  case 3:
1528
1579
  console.log('✅ QR code généré avec succès');
1529
- _context10.n = 5;
1580
+ _context11.n = 5;
1530
1581
  break;
1531
1582
  case 4:
1532
- _context10.p = 4;
1533
- _t0 = _context10.v;
1583
+ _context11.p = 4;
1584
+ _t0 = _context11.v;
1534
1585
  console.error('❌ Erreur génération API:', _t0);
1535
1586
 
1536
1587
  // Fallback final : image par défaut
1537
1588
  console.log('⚠️ Affichage image par défaut');
1538
1589
  this.displayDefaultQR(qrContainer, content, label);
1539
1590
  case 5:
1540
- return _context10.a(2);
1591
+ return _context11.a(2);
1541
1592
  }
1542
- }, _callee10, this, [[2, 4]]);
1593
+ }, _callee11, this, [[2, 4]]);
1543
1594
  }));
1544
1595
  function generateCustomQRCode(_x14, _x15) {
1545
1596
  return _generateCustomQRCode.apply(this, arguments);
@@ -1553,17 +1604,17 @@ function _unsupportedIterableToArray(r, a) {
1553
1604
  }, {
1554
1605
  key: "generateQRClientSide",
1555
1606
  value: (function () {
1556
- var _generateQRClientSide = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11(content, label, qrContainer) {
1607
+ var _generateQRClientSide = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12(content, label, qrContainer) {
1557
1608
  var _this2 = this;
1558
1609
  var canvas, ctx;
1559
- return _regenerator().w(function (_context11) {
1560
- while (1) switch (_context11.n) {
1610
+ return _regenerator().w(function (_context12) {
1611
+ while (1) switch (_context12.n) {
1561
1612
  case 0:
1562
- _context11.n = 1;
1613
+ _context12.n = 1;
1563
1614
  return this.ensureQRCodeLibrary();
1564
1615
  case 1:
1565
1616
  if (!(typeof QRCode === 'undefined')) {
1566
- _context11.n = 2;
1617
+ _context12.n = 2;
1567
1618
  break;
1568
1619
  }
1569
1620
  throw new Error('QRCode library non disponible');
@@ -1577,7 +1628,7 @@ function _unsupportedIterableToArray(r, a) {
1577
1628
  ctx.fillRect(0, 0, 300, 320);
1578
1629
 
1579
1630
  // Générer le QR code
1580
- return _context11.a(2, new Promise(function (resolve, reject) {
1631
+ return _context12.a(2, new Promise(function (resolve, reject) {
1581
1632
  QRCode.toCanvas(canvas, content, {
1582
1633
  width: 280,
1583
1634
  margin: 10,
@@ -1612,7 +1663,7 @@ function _unsupportedIterableToArray(r, a) {
1612
1663
  });
1613
1664
  }));
1614
1665
  }
1615
- }, _callee11, this);
1666
+ }, _callee12, this);
1616
1667
  }));
1617
1668
  function generateQRClientSide(_x16, _x17, _x18) {
1618
1669
  return _generateQRClientSide.apply(this, arguments);
@@ -1626,10 +1677,10 @@ function _unsupportedIterableToArray(r, a) {
1626
1677
  }, {
1627
1678
  key: "generateQRPHP",
1628
1679
  value: (function () {
1629
- var _generateQRPHP = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12(content, label, qrContainer) {
1680
+ var _generateQRPHP = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13(content, label, qrContainer) {
1630
1681
  var qrGeneratorUrl, requestBody, contentType, response, responseData, qrImageUrl, imageBaseUrl;
1631
- return _regenerator().w(function (_context12) {
1632
- while (1) switch (_context12.n) {
1682
+ return _regenerator().w(function (_context13) {
1683
+ while (1) switch (_context13.n) {
1633
1684
  case 0:
1634
1685
  // Construire l'URL - Utiliser l'API principale qui fonctionne
1635
1686
 
@@ -1667,7 +1718,7 @@ function _unsupportedIterableToArray(r, a) {
1667
1718
  label: label
1668
1719
  });
1669
1720
  }
1670
- _context12.n = 1;
1721
+ _context13.n = 1;
1671
1722
  return fetch(qrGeneratorUrl, {
1672
1723
  method: 'POST',
1673
1724
  headers: {
@@ -1677,19 +1728,19 @@ function _unsupportedIterableToArray(r, a) {
1677
1728
  body: requestBody
1678
1729
  });
1679
1730
  case 1:
1680
- response = _context12.v;
1731
+ response = _context13.v;
1681
1732
  if (response.ok) {
1682
- _context12.n = 2;
1733
+ _context13.n = 2;
1683
1734
  break;
1684
1735
  }
1685
1736
  throw new Error("Erreur HTTP: ".concat(response.status));
1686
1737
  case 2:
1687
- _context12.n = 3;
1738
+ _context13.n = 3;
1688
1739
  return response.json();
1689
1740
  case 3:
1690
- responseData = _context12.v;
1741
+ responseData = _context13.v;
1691
1742
  if (responseData.success) {
1692
- _context12.n = 4;
1743
+ _context13.n = 4;
1693
1744
  break;
1694
1745
  }
1695
1746
  throw new Error("Erreur QR: ".concat(responseData.error));
@@ -1712,9 +1763,9 @@ function _unsupportedIterableToArray(r, a) {
1712
1763
  // Afficher les instructions
1713
1764
  this.showQRInstructions(qrContainer);
1714
1765
  case 5:
1715
- return _context12.a(2);
1766
+ return _context13.a(2);
1716
1767
  }
1717
- }, _callee12, this);
1768
+ }, _callee13, this);
1718
1769
  }));
1719
1770
  function generateQRPHP(_x19, _x20, _x21) {
1720
1771
  return _generateQRPHP.apply(this, arguments);
@@ -1737,19 +1788,19 @@ function _unsupportedIterableToArray(r, a) {
1737
1788
  }, {
1738
1789
  key: "ensureQRCodeLibrary",
1739
1790
  value: (function () {
1740
- var _ensureQRCodeLibrary = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13() {
1741
- return _regenerator().w(function (_context13) {
1742
- while (1) switch (_context13.n) {
1791
+ var _ensureQRCodeLibrary = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14() {
1792
+ return _regenerator().w(function (_context14) {
1793
+ while (1) switch (_context14.n) {
1743
1794
  case 0:
1744
1795
  if (!(typeof QRCode !== 'undefined')) {
1745
- _context13.n = 1;
1796
+ _context14.n = 1;
1746
1797
  break;
1747
1798
  }
1748
1799
  console.log('✅ QRCode library déjà disponible');
1749
- return _context13.a(2, true);
1800
+ return _context14.a(2, true);
1750
1801
  case 1:
1751
1802
  console.log('📦 Chargement QRCode library...');
1752
- return _context13.a(2, new Promise(function (resolve, reject) {
1803
+ return _context14.a(2, new Promise(function (resolve, reject) {
1753
1804
  var script = document.createElement('script');
1754
1805
  script.src = 'https://cdn.jsdelivr.net/npm/qrcode@1.5.3/lib/browser.min.js';
1755
1806
  script.onload = function () {
@@ -1770,7 +1821,7 @@ function _unsupportedIterableToArray(r, a) {
1770
1821
  document.head.appendChild(script);
1771
1822
  }));
1772
1823
  }
1773
- }, _callee13);
1824
+ }, _callee14);
1774
1825
  }));
1775
1826
  function ensureQRCodeLibrary() {
1776
1827
  return _ensureQRCodeLibrary.apply(this, arguments);
@@ -1857,19 +1908,19 @@ function _unsupportedIterableToArray(r, a) {
1857
1908
  }, {
1858
1909
  key: "refreshQR",
1859
1910
  value: (function () {
1860
- var _refreshQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14(containerId) {
1911
+ var _refreshQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15(containerId) {
1861
1912
  var options,
1862
1913
  result,
1863
1914
  _result,
1864
- _args14 = arguments,
1915
+ _args15 = arguments,
1865
1916
  _t1;
1866
- return _regenerator().w(function (_context14) {
1867
- while (1) switch (_context14.p = _context14.n) {
1917
+ return _regenerator().w(function (_context15) {
1918
+ while (1) switch (_context15.p = _context15.n) {
1868
1919
  case 0:
1869
- options = _args14.length > 1 && _args14[1] !== undefined ? _args14[1] : {};
1870
- _context14.p = 1;
1920
+ options = _args15.length > 1 && _args15[1] !== undefined ? _args15[1] : {};
1921
+ _context15.p = 1;
1871
1922
  if (!this.currentQRUrl) {
1872
- _context14.n = 3;
1923
+ _context15.n = 3;
1873
1924
  break;
1874
1925
  }
1875
1926
  console.log('🔄 Vérification du statut du QR code existant...');
@@ -1879,31 +1930,31 @@ function _unsupportedIterableToArray(r, a) {
1879
1930
 
1880
1931
  // Option 2: Régénérer le QR code seulement si nécessaire
1881
1932
  // Pour l'instant, on régénère pour s'assurer qu'il est à jour
1882
- _context14.n = 2;
1933
+ _context15.n = 2;
1883
1934
  return this.generateQR(containerId, options);
1884
1935
  case 2:
1885
- result = _context14.v;
1886
- return _context14.a(2, result);
1936
+ result = _context15.v;
1937
+ return _context15.a(2, result);
1887
1938
  case 3:
1888
1939
  console.log('🔄 Pas de QR code existant, génération d\'un nouveau...');
1889
- _context14.n = 4;
1940
+ _context15.n = 4;
1890
1941
  return this.generateQR(containerId, options);
1891
1942
  case 4:
1892
- _result = _context14.v;
1893
- return _context14.a(2, _result);
1943
+ _result = _context15.v;
1944
+ return _context15.a(2, _result);
1894
1945
  case 5:
1895
- _context14.n = 7;
1946
+ _context15.n = 7;
1896
1947
  break;
1897
1948
  case 6:
1898
- _context14.p = 6;
1899
- _t1 = _context14.v;
1949
+ _context15.p = 6;
1950
+ _t1 = _context15.v;
1900
1951
  console.error('Erreur lors du rafraîchissement:', _t1.message);
1901
1952
  this.displayServiceUnavailable(containerId, this.config.type);
1902
1953
  throw _t1;
1903
1954
  case 7:
1904
- return _context14.a(2);
1955
+ return _context15.a(2);
1905
1956
  }
1906
- }, _callee14, this, [[1, 6]]);
1957
+ }, _callee15, this, [[1, 6]]);
1907
1958
  }));
1908
1959
  function refreshQR(_x22) {
1909
1960
  return _refreshQR.apply(this, arguments);
@@ -1925,26 +1976,26 @@ function _unsupportedIterableToArray(r, a) {
1925
1976
  clearInterval(this.refreshTimer);
1926
1977
  console.log('🔄 Timer de rafraîchissement précédent arrêté');
1927
1978
  }
1928
- this.refreshTimer = setInterval(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15() {
1979
+ this.refreshTimer = setInterval(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16() {
1929
1980
  var _t10;
1930
- return _regenerator().w(function (_context15) {
1931
- while (1) switch (_context15.p = _context15.n) {
1981
+ return _regenerator().w(function (_context16) {
1982
+ while (1) switch (_context16.p = _context16.n) {
1932
1983
  case 0:
1933
- _context15.p = 0;
1984
+ _context16.p = 0;
1934
1985
  console.log('🔄 Rafraîchissement automatique du QR code...');
1935
- _context15.n = 1;
1986
+ _context16.n = 1;
1936
1987
  return _this3.refreshQR(containerId, type, options);
1937
1988
  case 1:
1938
- _context15.n = 3;
1989
+ _context16.n = 3;
1939
1990
  break;
1940
1991
  case 2:
1941
- _context15.p = 2;
1942
- _t10 = _context15.v;
1992
+ _context16.p = 2;
1993
+ _t10 = _context16.v;
1943
1994
  console.warn('Erreur lors du rafraîchissement automatique:', _t10);
1944
1995
  case 3:
1945
- return _context15.a(2);
1996
+ return _context16.a(2);
1946
1997
  }
1947
- }, _callee15, null, [[0, 2]]);
1998
+ }, _callee16, null, [[0, 2]]);
1948
1999
  })), this.config.refreshInterval);
1949
2000
  console.log("\uD83D\uDD04 Timer de rafra\xEEchissement d\xE9marr\xE9 (".concat(this.config.refreshInterval, "ms)"));
1950
2001
  }
@@ -1959,16 +2010,16 @@ function _unsupportedIterableToArray(r, a) {
1959
2010
  }, {
1960
2011
  key: "makeRequest",
1961
2012
  value: (function () {
1962
- var _makeRequest = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16(endpoint, data) {
2013
+ var _makeRequest = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17(endpoint, data) {
1963
2014
  var _window$SunuIDConfig4,
1964
2015
  _window$SunuIDConfig5,
1965
2016
  _this4 = this;
1966
2017
  var sanitizedData, endpointPath, url, retryCount, maxRetries, _loop, _ret;
1967
- return _regenerator().w(function (_context17) {
1968
- while (1) switch (_context17.n) {
2018
+ return _regenerator().w(function (_context18) {
2019
+ while (1) switch (_context18.n) {
1969
2020
  case 0:
1970
2021
  if (this.isInitialized) {
1971
- _context17.n = 1;
2022
+ _context18.n = 1;
1972
2023
  break;
1973
2024
  }
1974
2025
  this.logSecurityEvent('REQUEST_BEFORE_INIT', {
@@ -1977,12 +2028,12 @@ function _unsupportedIterableToArray(r, a) {
1977
2028
  throw new Error('SDK non initialisé');
1978
2029
  case 1:
1979
2030
  if (!this.config.secureInit) {
1980
- _context17.n = 2;
2031
+ _context18.n = 2;
1981
2032
  break;
1982
2033
  }
1983
2034
  this.config.requestCount++;
1984
2035
  if (!(this.config.requestCount > this.config.maxRequests)) {
1985
- _context17.n = 2;
2036
+ _context18.n = 2;
1986
2037
  break;
1987
2038
  }
1988
2039
  this.logSecurityEvent('API_REQUEST_LIMIT_EXCEEDED', {
@@ -2018,10 +2069,10 @@ function _unsupportedIterableToArray(r, a) {
2018
2069
  maxRetries = this.config.maxRetries;
2019
2070
  _loop = /*#__PURE__*/_regenerator().m(function _loop() {
2020
2071
  var controller, timeoutId, headers, response, errorText, errorData, result, _t11;
2021
- return _regenerator().w(function (_context16) {
2022
- while (1) switch (_context16.p = _context16.n) {
2072
+ return _regenerator().w(function (_context17) {
2073
+ while (1) switch (_context17.p = _context17.n) {
2023
2074
  case 0:
2024
- _context16.p = 0;
2075
+ _context17.p = 0;
2025
2076
  controller = new AbortController();
2026
2077
  timeoutId = setTimeout(function () {
2027
2078
  return controller.abort();
@@ -2033,7 +2084,7 @@ function _unsupportedIterableToArray(r, a) {
2033
2084
  // if (this.config.secureInit && this.config.token) {
2034
2085
  // headers['X-Secure-Token'] = this.config.token;
2035
2086
  // }
2036
- _context16.n = 1;
2087
+ _context17.n = 1;
2037
2088
  return fetch(url, {
2038
2089
  method: 'POST',
2039
2090
  headers: headers,
@@ -2041,16 +2092,16 @@ function _unsupportedIterableToArray(r, a) {
2041
2092
  signal: controller.signal
2042
2093
  });
2043
2094
  case 1:
2044
- response = _context16.v;
2095
+ response = _context17.v;
2045
2096
  clearTimeout(timeoutId);
2046
2097
  if (response.ok) {
2047
- _context16.n = 3;
2098
+ _context17.n = 3;
2048
2099
  break;
2049
2100
  }
2050
- _context16.n = 2;
2101
+ _context17.n = 2;
2051
2102
  return response.text();
2052
2103
  case 2:
2053
- errorText = _context16.v;
2104
+ errorText = _context17.v;
2054
2105
  try {
2055
2106
  errorData = JSON.parse(errorText);
2056
2107
  } catch (e) {
@@ -2065,38 +2116,38 @@ function _unsupportedIterableToArray(r, a) {
2065
2116
  });
2066
2117
  throw new Error(errorData.message || "Erreur HTTP: ".concat(response.status));
2067
2118
  case 3:
2068
- _context16.n = 4;
2119
+ _context17.n = 4;
2069
2120
  return response.json();
2070
2121
  case 4:
2071
- result = _context16.v;
2122
+ result = _context17.v;
2072
2123
  _this4.logSecurityEvent('API_REQUEST_SUCCESS', {
2073
2124
  endpoint: endpointPath,
2074
2125
  responseKeys: Object.keys(result)
2075
2126
  });
2076
- return _context16.a(2, {
2127
+ return _context17.a(2, {
2077
2128
  v: result
2078
2129
  });
2079
2130
  case 5:
2080
- _context16.p = 5;
2081
- _t11 = _context16.v;
2131
+ _context17.p = 5;
2132
+ _t11 = _context17.v;
2082
2133
  retryCount++;
2083
2134
  if (!(_t11.name === 'AbortError')) {
2084
- _context16.n = 7;
2135
+ _context17.n = 7;
2085
2136
  break;
2086
2137
  }
2087
2138
  _this4.logSecurityEvent('API_REQUEST_TIMEOUT', {
2088
2139
  retryCount: retryCount
2089
2140
  });
2090
2141
  if (!(retryCount > maxRetries)) {
2091
- _context16.n = 6;
2142
+ _context17.n = 6;
2092
2143
  break;
2093
2144
  }
2094
2145
  throw new Error('Timeout de la requête API');
2095
2146
  case 6:
2096
- return _context16.a(2, 0);
2147
+ return _context17.a(2, 0);
2097
2148
  case 7:
2098
2149
  if (!(retryCount > maxRetries)) {
2099
- _context16.n = 8;
2150
+ _context17.n = 8;
2100
2151
  break;
2101
2152
  }
2102
2153
  _this4.logSecurityEvent('API_REQUEST_MAX_RETRIES', {
@@ -2105,41 +2156,41 @@ function _unsupportedIterableToArray(r, a) {
2105
2156
  });
2106
2157
  throw _t11;
2107
2158
  case 8:
2108
- _context16.n = 9;
2159
+ _context17.n = 9;
2109
2160
  return new Promise(function (resolve) {
2110
2161
  return setTimeout(resolve, 1000 * retryCount);
2111
2162
  });
2112
2163
  case 9:
2113
- return _context16.a(2);
2164
+ return _context17.a(2);
2114
2165
  }
2115
2166
  }, _loop, null, [[0, 5]]);
2116
2167
  });
2117
2168
  case 3:
2118
2169
  if (!(retryCount <= maxRetries)) {
2119
- _context17.n = 7;
2170
+ _context18.n = 7;
2120
2171
  break;
2121
2172
  }
2122
- return _context17.d(_regeneratorValues(_loop()), 4);
2173
+ return _context18.d(_regeneratorValues(_loop()), 4);
2123
2174
  case 4:
2124
- _ret = _context17.v;
2175
+ _ret = _context18.v;
2125
2176
  if (!(_ret === 0)) {
2126
- _context17.n = 5;
2177
+ _context18.n = 5;
2127
2178
  break;
2128
2179
  }
2129
- return _context17.a(3, 3);
2180
+ return _context18.a(3, 3);
2130
2181
  case 5:
2131
2182
  if (!_ret) {
2132
- _context17.n = 6;
2183
+ _context18.n = 6;
2133
2184
  break;
2134
2185
  }
2135
- return _context17.a(2, _ret.v);
2186
+ return _context18.a(2, _ret.v);
2136
2187
  case 6:
2137
- _context17.n = 3;
2188
+ _context18.n = 3;
2138
2189
  break;
2139
2190
  case 7:
2140
- return _context17.a(2);
2191
+ return _context18.a(2);
2141
2192
  }
2142
- }, _callee16, this);
2193
+ }, _callee17, this);
2143
2194
  }));
2144
2195
  function makeRequest(_x23, _x24) {
2145
2196
  return _makeRequest.apply(this, arguments);
@@ -2210,20 +2261,20 @@ function _unsupportedIterableToArray(r, a) {
2210
2261
  }, {
2211
2262
  key: "fetchPartnerInfo",
2212
2263
  value: (function () {
2213
- var _fetchPartnerInfo = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17() {
2264
+ var _fetchPartnerInfo = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18() {
2214
2265
  var response, data, partnerId, _t12;
2215
- return _regenerator().w(function (_context18) {
2216
- while (1) switch (_context18.p = _context18.n) {
2266
+ return _regenerator().w(function (_context19) {
2267
+ while (1) switch (_context19.p = _context19.n) {
2217
2268
  case 0:
2218
- _context18.p = 0;
2219
- _context18.n = 1;
2269
+ _context19.p = 0;
2270
+ _context19.n = 1;
2220
2271
  return this.makeRequest('/debug', {
2221
2272
  type: this.config.type,
2222
2273
  client_id: this.config.clientId,
2223
2274
  secret_id: this.config.secretId
2224
2275
  });
2225
2276
  case 1:
2226
- response = _context18.v;
2277
+ response = _context19.v;
2227
2278
  console.log('📋 Réponse debug API:', response);
2228
2279
 
2229
2280
  // Vérifier la structure de la réponse
@@ -2267,17 +2318,17 @@ function _unsupportedIterableToArray(r, a) {
2267
2318
  console.warn('⚠️ Structure de réponse invalide, utilisation du partner_id par défaut');
2268
2319
  this.config.partnerName = "Partner_".concat(this.config.partnerId || 'unknown');
2269
2320
  }
2270
- _context18.n = 3;
2321
+ _context19.n = 3;
2271
2322
  break;
2272
2323
  case 2:
2273
- _context18.p = 2;
2274
- _t12 = _context18.v;
2324
+ _context19.p = 2;
2325
+ _t12 = _context19.v;
2275
2326
  console.warn('⚠️ Erreur lors de la récupération des informations du partenaire:', _t12.message);
2276
2327
  this.config.partnerName = 'Partner_unknown';
2277
2328
  case 3:
2278
- return _context18.a(2);
2329
+ return _context19.a(2);
2279
2330
  }
2280
- }, _callee17, this, [[0, 2]]);
2331
+ }, _callee18, this, [[0, 2]]);
2281
2332
  }));
2282
2333
  function fetchPartnerInfo() {
2283
2334
  return _fetchPartnerInfo.apply(this, arguments);
@@ -2315,18 +2366,18 @@ function _unsupportedIterableToArray(r, a) {
2315
2366
  }, {
2316
2367
  key: "checkConnections",
2317
2368
  value: (function () {
2318
- var _checkConnections = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18() {
2369
+ var _checkConnections = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19() {
2319
2370
  var status, testResponse, debugData, _t13;
2320
- return _regenerator().w(function (_context19) {
2321
- while (1) switch (_context19.p = _context19.n) {
2371
+ return _regenerator().w(function (_context20) {
2372
+ while (1) switch (_context20.p = _context20.n) {
2322
2373
  case 0:
2323
2374
  status = {
2324
2375
  api: false,
2325
2376
  websocket: false,
2326
2377
  ready: false
2327
2378
  }; // Vérifier l'API en utilisant l'endpoint debug avec les credentials
2328
- _context19.p = 1;
2329
- _context19.n = 2;
2379
+ _context20.p = 1;
2380
+ _context20.n = 2;
2330
2381
  return fetch(this.config.apiUrl + '/debug', {
2331
2382
  method: 'POST',
2332
2383
  headers: {
@@ -2339,29 +2390,29 @@ function _unsupportedIterableToArray(r, a) {
2339
2390
  })
2340
2391
  });
2341
2392
  case 2:
2342
- testResponse = _context19.v;
2393
+ testResponse = _context20.v;
2343
2394
  if (!testResponse.ok) {
2344
- _context19.n = 4;
2395
+ _context20.n = 4;
2345
2396
  break;
2346
2397
  }
2347
- _context19.n = 3;
2398
+ _context20.n = 3;
2348
2399
  return testResponse.json();
2349
2400
  case 3:
2350
- debugData = _context19.v;
2401
+ debugData = _context20.v;
2351
2402
  // L'API est accessible si on reçoit une réponse avec success: true
2352
2403
  status.api = debugData.success === true;
2353
2404
  console.log('🔍 API Status:', status.api ? 'accessible' : 'inaccessible');
2354
- _context19.n = 5;
2405
+ _context20.n = 5;
2355
2406
  break;
2356
2407
  case 4:
2357
2408
  status.api = false;
2358
2409
  console.log('🔍 API Status: HTTP', testResponse.status);
2359
2410
  case 5:
2360
- _context19.n = 7;
2411
+ _context20.n = 7;
2361
2412
  break;
2362
2413
  case 6:
2363
- _context19.p = 6;
2364
- _t13 = _context19.v;
2414
+ _context20.p = 6;
2415
+ _t13 = _context20.v;
2365
2416
  console.log('🔍 Test API échoué:', _t13.message);
2366
2417
  status.api = false;
2367
2418
  case 7:
@@ -2370,9 +2421,9 @@ function _unsupportedIterableToArray(r, a) {
2370
2421
 
2371
2422
  // Connexions prêtes si API est accessible
2372
2423
  status.ready = status.api;
2373
- return _context19.a(2, status);
2424
+ return _context20.a(2, status);
2374
2425
  }
2375
- }, _callee18, this, [[1, 6]]);
2426
+ }, _callee19, this, [[1, 6]]);
2376
2427
  }));
2377
2428
  function checkConnections() {
2378
2429
  return _checkConnections.apply(this, arguments);
@@ -2386,46 +2437,46 @@ function _unsupportedIterableToArray(r, a) {
2386
2437
  }, {
2387
2438
  key: "waitForConnections",
2388
2439
  value: (function () {
2389
- var _waitForConnections = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19() {
2440
+ var _waitForConnections = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee20() {
2390
2441
  var timeout,
2391
2442
  startTime,
2392
2443
  status,
2393
- _args20 = arguments;
2394
- return _regenerator().w(function (_context20) {
2395
- while (1) switch (_context20.n) {
2444
+ _args21 = arguments;
2445
+ return _regenerator().w(function (_context21) {
2446
+ while (1) switch (_context21.n) {
2396
2447
  case 0:
2397
- timeout = _args20.length > 0 && _args20[0] !== undefined ? _args20[0] : 5000;
2448
+ timeout = _args21.length > 0 && _args21[0] !== undefined ? _args21[0] : 5000;
2398
2449
  startTime = Date.now();
2399
2450
  case 1:
2400
2451
  if (!(Date.now() - startTime < timeout)) {
2401
- _context20.n = 5;
2452
+ _context21.n = 5;
2402
2453
  break;
2403
2454
  }
2404
- _context20.n = 2;
2455
+ _context21.n = 2;
2405
2456
  return this.checkConnections();
2406
2457
  case 2:
2407
- status = _context20.v;
2458
+ status = _context21.v;
2408
2459
  if (!status.ready) {
2409
- _context20.n = 3;
2460
+ _context21.n = 3;
2410
2461
  break;
2411
2462
  }
2412
2463
  console.log('✅ Connexions prêtes');
2413
- return _context20.a(2, status);
2464
+ return _context21.a(2, status);
2414
2465
  case 3:
2415
2466
  console.log('⏳ Attente connexions...', status);
2416
- _context20.n = 4;
2467
+ _context21.n = 4;
2417
2468
  return new Promise(function (resolve) {
2418
2469
  return setTimeout(resolve, 1000);
2419
2470
  });
2420
2471
  case 4:
2421
- _context20.n = 1;
2472
+ _context21.n = 1;
2422
2473
  break;
2423
2474
  case 5:
2424
2475
  throw new Error('Timeout connexions - Impossible de générer le QR code');
2425
2476
  case 6:
2426
- return _context20.a(2);
2477
+ return _context21.a(2);
2427
2478
  }
2428
- }, _callee19, this);
2479
+ }, _callee20, this);
2429
2480
  }));
2430
2481
  function waitForConnections() {
2431
2482
  return _waitForConnections.apply(this, arguments);