sunuid-sdk 1.0.41 → 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.
- package/dist/sunuid-sdk.esm.js +383 -343
- package/dist/sunuid-sdk.esm.js.map +1 -1
- package/dist/sunuid-sdk.js +383 -343
- package/dist/sunuid-sdk.js.map +1 -1
- package/dist/sunuid-sdk.min.js +1 -1
- package/dist/sunuid-sdk.min.js.map +1 -1
- package/package.json +1 -1
package/dist/sunuid-sdk.js
CHANGED
|
@@ -291,8 +291,8 @@
|
|
|
291
291
|
// Désactivé par défaut pour éviter les appels répétitifs
|
|
292
292
|
refreshInterval: 30000,
|
|
293
293
|
// 30 secondes
|
|
294
|
-
autoInit:
|
|
295
|
-
//
|
|
294
|
+
autoInit: false,
|
|
295
|
+
// Désactivé par défaut pour éviter les boucles
|
|
296
296
|
onSuccess: null,
|
|
297
297
|
onError: null,
|
|
298
298
|
onStatusUpdate: null,
|
|
@@ -330,6 +330,7 @@
|
|
|
330
330
|
*/
|
|
331
331
|
var SunuID = /*#__PURE__*/function () {
|
|
332
332
|
function SunuID() {
|
|
333
|
+
var _this = this;
|
|
333
334
|
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
334
335
|
_classCallCheck(this, SunuID);
|
|
335
336
|
this.config = _objectSpread2(_objectSpread2({}, DEFAULT_CONFIG), config);
|
|
@@ -337,10 +338,14 @@
|
|
|
337
338
|
this.refreshTimer = null;
|
|
338
339
|
this.isInitialized = false;
|
|
339
340
|
this.socket = null;
|
|
341
|
+
this.initPromise = null;
|
|
340
342
|
|
|
341
|
-
// Initialisation asynchrone seulement si autoInit est activé
|
|
342
|
-
if (this.config.autoInit
|
|
343
|
-
|
|
343
|
+
// Initialisation asynchrone seulement si autoInit est explicitement activé
|
|
344
|
+
if (this.config.autoInit === true) {
|
|
345
|
+
// Délai pour éviter les conflits avec d'autres scripts
|
|
346
|
+
setTimeout(function () {
|
|
347
|
+
_this.init();
|
|
348
|
+
}, 100);
|
|
344
349
|
}
|
|
345
350
|
}
|
|
346
351
|
|
|
@@ -351,26 +356,61 @@
|
|
|
351
356
|
key: "init",
|
|
352
357
|
value: (function () {
|
|
353
358
|
var _init = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
354
|
-
var _t;
|
|
355
359
|
return _regenerator().w(function (_context) {
|
|
356
|
-
while (1) switch (_context.
|
|
360
|
+
while (1) switch (_context.n) {
|
|
357
361
|
case 0:
|
|
358
|
-
|
|
359
|
-
if (!this.handleCallback()) {
|
|
362
|
+
if (!this.isInitialized) {
|
|
360
363
|
_context.n = 1;
|
|
361
364
|
break;
|
|
362
365
|
}
|
|
363
|
-
console.log('
|
|
366
|
+
console.log('⚠️ SDK déjà initialisé, ignoré');
|
|
364
367
|
return _context.a(2);
|
|
368
|
+
case 1:
|
|
369
|
+
if (!this.initPromise) {
|
|
370
|
+
_context.n = 2;
|
|
371
|
+
break;
|
|
372
|
+
}
|
|
373
|
+
console.log('⚠️ Initialisation déjà en cours, attente...');
|
|
374
|
+
return _context.a(2, this.initPromise);
|
|
375
|
+
case 2:
|
|
376
|
+
this.initPromise = this._doInit();
|
|
377
|
+
return _context.a(2, this.initPromise);
|
|
378
|
+
}
|
|
379
|
+
}, _callee, this);
|
|
380
|
+
}));
|
|
381
|
+
function init() {
|
|
382
|
+
return _init.apply(this, arguments);
|
|
383
|
+
}
|
|
384
|
+
return init;
|
|
385
|
+
}()
|
|
386
|
+
/**
|
|
387
|
+
* Initialisation interne du SDK
|
|
388
|
+
*/
|
|
389
|
+
)
|
|
390
|
+
}, {
|
|
391
|
+
key: "_doInit",
|
|
392
|
+
value: (function () {
|
|
393
|
+
var _doInit2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
394
|
+
var _t;
|
|
395
|
+
return _regenerator().w(function (_context2) {
|
|
396
|
+
while (1) switch (_context2.p = _context2.n) {
|
|
397
|
+
case 0:
|
|
398
|
+
_context2.p = 0;
|
|
399
|
+
if (!this.handleCallback()) {
|
|
400
|
+
_context2.n = 1;
|
|
401
|
+
break;
|
|
402
|
+
}
|
|
403
|
+
console.log('✅ Callback traité, initialisation terminée');
|
|
404
|
+
return _context2.a(2);
|
|
365
405
|
case 1:
|
|
366
406
|
if (!this.config.secureInit) {
|
|
367
|
-
|
|
407
|
+
_context2.n = 3;
|
|
368
408
|
break;
|
|
369
409
|
}
|
|
370
|
-
|
|
410
|
+
_context2.n = 2;
|
|
371
411
|
return this.secureInit();
|
|
372
412
|
case 2:
|
|
373
|
-
|
|
413
|
+
_context2.n = 4;
|
|
374
414
|
break;
|
|
375
415
|
case 3:
|
|
376
416
|
// Validation sécurisée des paramètres
|
|
@@ -386,7 +426,7 @@
|
|
|
386
426
|
});
|
|
387
427
|
|
|
388
428
|
// Récupérer les informations du partenaire depuis l'API
|
|
389
|
-
|
|
429
|
+
_context2.n = 5;
|
|
390
430
|
return this.fetchPartnerInfo();
|
|
391
431
|
case 5:
|
|
392
432
|
// Obscurcir les credentials dans les logs
|
|
@@ -406,24 +446,24 @@
|
|
|
406
446
|
|
|
407
447
|
// Initialiser la connexion WebSocket
|
|
408
448
|
this.initWebSocket();
|
|
409
|
-
|
|
449
|
+
_context2.n = 7;
|
|
410
450
|
break;
|
|
411
451
|
case 6:
|
|
412
|
-
|
|
413
|
-
_t =
|
|
452
|
+
_context2.p = 6;
|
|
453
|
+
_t = _context2.v;
|
|
414
454
|
this.logSecurityEvent('SDK_INIT_ERROR', {
|
|
415
455
|
error: _t.message
|
|
416
456
|
});
|
|
417
457
|
throw _t;
|
|
418
458
|
case 7:
|
|
419
|
-
return
|
|
459
|
+
return _context2.a(2);
|
|
420
460
|
}
|
|
421
|
-
},
|
|
461
|
+
}, _callee2, this, [[0, 6]]);
|
|
422
462
|
}));
|
|
423
|
-
function
|
|
424
|
-
return
|
|
463
|
+
function _doInit() {
|
|
464
|
+
return _doInit2.apply(this, arguments);
|
|
425
465
|
}
|
|
426
|
-
return
|
|
466
|
+
return _doInit;
|
|
427
467
|
}()
|
|
428
468
|
/**
|
|
429
469
|
* Initialisation sécurisée via PHP
|
|
@@ -432,19 +472,19 @@
|
|
|
432
472
|
}, {
|
|
433
473
|
key: "secureInit",
|
|
434
474
|
value: (function () {
|
|
435
|
-
var _secureInit = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
475
|
+
var _secureInit = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
|
|
436
476
|
var initData, response, result, decodedToken, _t2;
|
|
437
|
-
return _regenerator().w(function (
|
|
438
|
-
while (1) switch (
|
|
477
|
+
return _regenerator().w(function (_context3) {
|
|
478
|
+
while (1) switch (_context3.p = _context3.n) {
|
|
439
479
|
case 0:
|
|
440
|
-
|
|
480
|
+
_context3.p = 0;
|
|
441
481
|
this.logSecurityEvent('SECURE_INIT_START');
|
|
442
482
|
initData = {
|
|
443
483
|
type: this.config.type,
|
|
444
484
|
partnerName: this.config.partnerName,
|
|
445
485
|
theme: this.config.theme
|
|
446
486
|
};
|
|
447
|
-
|
|
487
|
+
_context3.n = 1;
|
|
448
488
|
return fetch(this.config.secureInitUrl, {
|
|
449
489
|
method: 'POST',
|
|
450
490
|
headers: {
|
|
@@ -454,20 +494,20 @@
|
|
|
454
494
|
body: JSON.stringify(initData)
|
|
455
495
|
});
|
|
456
496
|
case 1:
|
|
457
|
-
response =
|
|
497
|
+
response = _context3.v;
|
|
458
498
|
if (response.ok) {
|
|
459
|
-
|
|
499
|
+
_context3.n = 2;
|
|
460
500
|
break;
|
|
461
501
|
}
|
|
462
502
|
throw new Error("Erreur HTTP: ".concat(response.status));
|
|
463
503
|
case 2:
|
|
464
|
-
|
|
504
|
+
_context3.n = 3;
|
|
465
505
|
return response.json();
|
|
466
506
|
case 3:
|
|
467
|
-
result =
|
|
507
|
+
result = _context3.v;
|
|
468
508
|
console.log('📋 Réponse initialisation sécurisée:', result);
|
|
469
509
|
if (result.success) {
|
|
470
|
-
|
|
510
|
+
_context3.n = 4;
|
|
471
511
|
break;
|
|
472
512
|
}
|
|
473
513
|
throw new Error(result.error || 'Erreur lors de l\'initialisation sécurisée');
|
|
@@ -479,12 +519,12 @@
|
|
|
479
519
|
// Décoder le token pour récupérer les credentials
|
|
480
520
|
decodedToken = this.decodeSecureToken(result.data.token);
|
|
481
521
|
if (!decodedToken) {
|
|
482
|
-
|
|
522
|
+
_context3.n = 5;
|
|
483
523
|
break;
|
|
484
524
|
}
|
|
485
525
|
this.config.clientId = decodedToken.client_id;
|
|
486
526
|
this.config.secretId = decodedToken.secret_id;
|
|
487
|
-
|
|
527
|
+
_context3.n = 6;
|
|
488
528
|
break;
|
|
489
529
|
case 5:
|
|
490
530
|
throw new Error('Impossible de décoder le token sécurisé');
|
|
@@ -497,19 +537,19 @@
|
|
|
497
537
|
maxRequests: result.data.max_requests
|
|
498
538
|
});
|
|
499
539
|
console.log('✅ Initialisation sécurisée réussie');
|
|
500
|
-
|
|
540
|
+
_context3.n = 8;
|
|
501
541
|
break;
|
|
502
542
|
case 7:
|
|
503
|
-
|
|
504
|
-
_t2 =
|
|
543
|
+
_context3.p = 7;
|
|
544
|
+
_t2 = _context3.v;
|
|
505
545
|
this.logSecurityEvent('SECURE_INIT_ERROR', {
|
|
506
546
|
error: _t2.message
|
|
507
547
|
});
|
|
508
548
|
throw new Error("\xC9chec de l'initialisation s\xE9curis\xE9e: ".concat(_t2.message));
|
|
509
549
|
case 8:
|
|
510
|
-
return
|
|
550
|
+
return _context3.a(2);
|
|
511
551
|
}
|
|
512
|
-
},
|
|
552
|
+
}, _callee3, this, [[0, 7]]);
|
|
513
553
|
}));
|
|
514
554
|
function secureInit() {
|
|
515
555
|
return _secureInit.apply(this, arguments);
|
|
@@ -556,14 +596,14 @@
|
|
|
556
596
|
}, {
|
|
557
597
|
key: "initWebSocket",
|
|
558
598
|
value: function initWebSocket() {
|
|
559
|
-
var
|
|
599
|
+
var _this2 = this;
|
|
560
600
|
try {
|
|
561
601
|
// Vérifier si Socket.IO est disponible
|
|
562
602
|
if (typeof io === 'undefined') {
|
|
563
603
|
console.warn('⚠️ Socket.IO non disponible, WebSocket sera initialisé plus tard');
|
|
564
604
|
// Réessayer après un délai
|
|
565
605
|
setTimeout(function () {
|
|
566
|
-
return
|
|
606
|
+
return _this2.initWebSocket();
|
|
567
607
|
}, 1000);
|
|
568
608
|
return;
|
|
569
609
|
}
|
|
@@ -587,36 +627,36 @@
|
|
|
587
627
|
// Gestion des événements WebSocket
|
|
588
628
|
this.socket.on('connect', function () {
|
|
589
629
|
console.log('🌐 WebSocket connecté avec succès');
|
|
590
|
-
console.log('📊 Socket ID:',
|
|
591
|
-
|
|
630
|
+
console.log('📊 Socket ID:', _this2.socket.id);
|
|
631
|
+
_this2.socket.connected = true;
|
|
592
632
|
});
|
|
593
633
|
this.socket.on('disconnect', function (reason) {
|
|
594
634
|
console.log('❌ WebSocket déconnecté:', reason);
|
|
595
|
-
|
|
635
|
+
_this2.socket.connected = false;
|
|
596
636
|
});
|
|
597
637
|
this.socket.on('connect_error', function (error) {
|
|
598
638
|
console.error('❌ Erreur connexion WebSocket:', error);
|
|
599
|
-
|
|
639
|
+
_this2.socket.connected = false;
|
|
600
640
|
});
|
|
601
641
|
|
|
602
642
|
// Écouter les événements spécifiques
|
|
603
643
|
this.socket.on('qr_status_update', function (data) {
|
|
604
644
|
console.log('📱 Mise à jour statut QR reçue:', data);
|
|
605
|
-
|
|
645
|
+
_this2.handleQRStatusUpdate(data);
|
|
606
646
|
});
|
|
607
647
|
this.socket.on('qr_scan_success', function (data) {
|
|
608
648
|
console.log('✅ Scan QR réussi reçu:', data);
|
|
609
|
-
|
|
649
|
+
_this2.handleQRScanSuccess(data);
|
|
610
650
|
});
|
|
611
651
|
this.socket.on('qr_expired', function (data) {
|
|
612
652
|
console.log('⏰ QR expiré reçu:', data);
|
|
613
|
-
|
|
653
|
+
_this2.handleQRExpired(data);
|
|
614
654
|
});
|
|
615
655
|
|
|
616
656
|
// Écouter l'événement qr_scan_initiated spécifiquement
|
|
617
657
|
this.socket.on('qr_scan_initiated', function (data) {
|
|
618
658
|
console.log('🔍 QR Scan Initiated reçu:', data);
|
|
619
|
-
|
|
659
|
+
_this2.showQRLoader();
|
|
620
660
|
});
|
|
621
661
|
|
|
622
662
|
// Écouter l'événement message générique (fallback)
|
|
@@ -624,7 +664,7 @@
|
|
|
624
664
|
console.log('📨 Message socket reçu:', data);
|
|
625
665
|
if (data && data.type === 'qr_scan_initiated') {
|
|
626
666
|
console.log('🔍 QR Scan Initiated détecté dans message:', data);
|
|
627
|
-
|
|
667
|
+
_this2.showQRLoader();
|
|
628
668
|
}
|
|
629
669
|
});
|
|
630
670
|
|
|
@@ -868,7 +908,7 @@
|
|
|
868
908
|
}, {
|
|
869
909
|
key: "generateQR",
|
|
870
910
|
value: (function () {
|
|
871
|
-
var _generateQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
911
|
+
var _generateQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
|
|
872
912
|
var containerId,
|
|
873
913
|
options,
|
|
874
914
|
connectionStatus,
|
|
@@ -878,25 +918,25 @@
|
|
|
878
918
|
response,
|
|
879
919
|
qrImageUrl,
|
|
880
920
|
isLocal,
|
|
881
|
-
|
|
921
|
+
_args4 = arguments,
|
|
882
922
|
_t3,
|
|
883
923
|
_t4;
|
|
884
|
-
return _regenerator().w(function (
|
|
885
|
-
while (1) switch (
|
|
924
|
+
return _regenerator().w(function (_context4) {
|
|
925
|
+
while (1) switch (_context4.p = _context4.n) {
|
|
886
926
|
case 0:
|
|
887
|
-
containerId =
|
|
888
|
-
options =
|
|
927
|
+
containerId = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : 'sunuid-qr-container';
|
|
928
|
+
options = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
|
|
889
929
|
if (!this.initPromise) {
|
|
890
|
-
|
|
930
|
+
_context4.n = 2;
|
|
891
931
|
break;
|
|
892
932
|
}
|
|
893
|
-
|
|
933
|
+
_context4.n = 1;
|
|
894
934
|
return this.initPromise;
|
|
895
935
|
case 1:
|
|
896
936
|
this.initPromise = null;
|
|
897
937
|
case 2:
|
|
898
938
|
if (this.isInitialized) {
|
|
899
|
-
|
|
939
|
+
_context4.n = 3;
|
|
900
940
|
break;
|
|
901
941
|
}
|
|
902
942
|
throw new Error('SunuID: SDK non initialisé');
|
|
@@ -905,22 +945,22 @@
|
|
|
905
945
|
|
|
906
946
|
// Attendre que les connexions soient prêtes
|
|
907
947
|
console.log('🔍 Attente connexions API et WebSocket...');
|
|
908
|
-
|
|
909
|
-
|
|
948
|
+
_context4.p = 4;
|
|
949
|
+
_context4.n = 5;
|
|
910
950
|
return this.waitForConnections(5000);
|
|
911
951
|
case 5:
|
|
912
|
-
connectionStatus =
|
|
952
|
+
connectionStatus = _context4.v;
|
|
913
953
|
// 5 secondes max
|
|
914
954
|
console.log('✅ Connexions prêtes:', connectionStatus);
|
|
915
|
-
|
|
955
|
+
_context4.n = 7;
|
|
916
956
|
break;
|
|
917
957
|
case 6:
|
|
918
|
-
|
|
919
|
-
_t3 =
|
|
958
|
+
_context4.p = 6;
|
|
959
|
+
_t3 = _context4.v;
|
|
920
960
|
console.error('❌ Erreur connexions:', _t3.message);
|
|
921
961
|
throw new Error('Connexions non disponibles - Impossible de générer le QR code');
|
|
922
962
|
case 7:
|
|
923
|
-
|
|
963
|
+
_context4.p = 7;
|
|
924
964
|
// Utiliser uniquement le socketID comme contenu du QR
|
|
925
965
|
socketId = this.socket ? this.socket.id : 'timeout-socket-id';
|
|
926
966
|
qrContent = socketId;
|
|
@@ -929,7 +969,7 @@
|
|
|
929
969
|
|
|
930
970
|
// Générer le QR avec le contenu complet
|
|
931
971
|
partnerName = this.config.partnerName || 'Partner_unknown';
|
|
932
|
-
|
|
972
|
+
_context4.n = 8;
|
|
933
973
|
return this.makeRequest('/qr-generate', _objectSpread2({
|
|
934
974
|
type: this.config.type,
|
|
935
975
|
data: qrContent,
|
|
@@ -937,9 +977,9 @@
|
|
|
937
977
|
label: "".concat(this.getTypeName(this.config.type), " ").concat(partnerName)
|
|
938
978
|
}, options));
|
|
939
979
|
case 8:
|
|
940
|
-
response =
|
|
980
|
+
response = _context4.v;
|
|
941
981
|
if (!response.success) {
|
|
942
|
-
|
|
982
|
+
_context4.n = 11;
|
|
943
983
|
break;
|
|
944
984
|
}
|
|
945
985
|
// Debug: Afficher la structure complète de la réponse
|
|
@@ -954,7 +994,7 @@
|
|
|
954
994
|
|
|
955
995
|
// Vérifier si l'URL du QR code existe
|
|
956
996
|
if (qrImageUrl) {
|
|
957
|
-
|
|
997
|
+
_context4.n = 10;
|
|
958
998
|
break;
|
|
959
999
|
}
|
|
960
1000
|
console.warn('⚠️ qrCodeUrl non trouvé dans la réponse, recherche d\'alternatives...');
|
|
@@ -962,11 +1002,11 @@
|
|
|
962
1002
|
// Essayer d'autres champs possibles
|
|
963
1003
|
qrImageUrl = response.data.qr_url || response.data.qrUrl || response.data.url || response.data.image_url || response.data.imageUrl;
|
|
964
1004
|
if (!qrImageUrl) {
|
|
965
|
-
|
|
1005
|
+
_context4.n = 9;
|
|
966
1006
|
break;
|
|
967
1007
|
}
|
|
968
1008
|
console.log('✅ URL QR trouvée dans un champ alternatif:', qrImageUrl);
|
|
969
|
-
|
|
1009
|
+
_context4.n = 10;
|
|
970
1010
|
break;
|
|
971
1011
|
case 9:
|
|
972
1012
|
console.error('❌ Aucune URL QR trouvée dans la réponse');
|
|
@@ -992,7 +1032,7 @@
|
|
|
992
1032
|
sessionId: response.data.sessionId,
|
|
993
1033
|
timestamp: Date.now()
|
|
994
1034
|
});
|
|
995
|
-
return
|
|
1035
|
+
return _context4.a(2, _objectSpread2(_objectSpread2({}, response.data), {}, {
|
|
996
1036
|
qrCodeUrl: qrImageUrl,
|
|
997
1037
|
qrContent: qrContent,
|
|
998
1038
|
label: response.data.label,
|
|
@@ -1001,11 +1041,11 @@
|
|
|
1001
1041
|
case 11:
|
|
1002
1042
|
throw new Error(response.message || 'Erreur lors de la génération du QR code');
|
|
1003
1043
|
case 12:
|
|
1004
|
-
|
|
1044
|
+
_context4.n = 14;
|
|
1005
1045
|
break;
|
|
1006
1046
|
case 13:
|
|
1007
|
-
|
|
1008
|
-
_t4 =
|
|
1047
|
+
_context4.p = 13;
|
|
1048
|
+
_t4 = _context4.v;
|
|
1009
1049
|
console.error('Erreur API détectée:', _t4.message);
|
|
1010
1050
|
console.error('Stack trace complet:', _t4.stack);
|
|
1011
1051
|
console.error('Configuration SDK:', {
|
|
@@ -1037,9 +1077,9 @@
|
|
|
1037
1077
|
this.displayServiceUnavailable(containerId, this.config.type);
|
|
1038
1078
|
throw new Error('Service non disponible');
|
|
1039
1079
|
case 14:
|
|
1040
|
-
return
|
|
1080
|
+
return _context4.a(2);
|
|
1041
1081
|
}
|
|
1042
|
-
},
|
|
1082
|
+
}, _callee4, this, [[7, 13], [4, 6]]);
|
|
1043
1083
|
}));
|
|
1044
1084
|
function generateQR() {
|
|
1045
1085
|
return _generateQR.apply(this, arguments);
|
|
@@ -1053,41 +1093,41 @@
|
|
|
1053
1093
|
}, {
|
|
1054
1094
|
key: "generateCustomQR",
|
|
1055
1095
|
value: (function () {
|
|
1056
|
-
var _generateCustomQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1096
|
+
var _generateCustomQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(containerId, type) {
|
|
1057
1097
|
var options,
|
|
1058
1098
|
response,
|
|
1059
1099
|
imageBaseUrl,
|
|
1060
1100
|
qrImageUrl,
|
|
1061
|
-
|
|
1101
|
+
_args5 = arguments,
|
|
1062
1102
|
_t5;
|
|
1063
|
-
return _regenerator().w(function (
|
|
1064
|
-
while (1) switch (
|
|
1103
|
+
return _regenerator().w(function (_context5) {
|
|
1104
|
+
while (1) switch (_context5.p = _context5.n) {
|
|
1065
1105
|
case 0:
|
|
1066
|
-
options =
|
|
1106
|
+
options = _args5.length > 2 && _args5[2] !== undefined ? _args5[2] : {};
|
|
1067
1107
|
if (!this.initPromise) {
|
|
1068
|
-
|
|
1108
|
+
_context5.n = 2;
|
|
1069
1109
|
break;
|
|
1070
1110
|
}
|
|
1071
|
-
|
|
1111
|
+
_context5.n = 1;
|
|
1072
1112
|
return this.initPromise;
|
|
1073
1113
|
case 1:
|
|
1074
1114
|
this.initPromise = null;
|
|
1075
1115
|
case 2:
|
|
1076
1116
|
if (this.isInitialized) {
|
|
1077
|
-
|
|
1117
|
+
_context5.n = 3;
|
|
1078
1118
|
break;
|
|
1079
1119
|
}
|
|
1080
1120
|
throw new Error('SunuID: SDK non initialisé');
|
|
1081
1121
|
case 3:
|
|
1082
|
-
|
|
1083
|
-
|
|
1122
|
+
_context5.p = 3;
|
|
1123
|
+
_context5.n = 4;
|
|
1084
1124
|
return this.makeRequest('/qr-generate', _objectSpread2({
|
|
1085
1125
|
type: type
|
|
1086
1126
|
}, options));
|
|
1087
1127
|
case 4:
|
|
1088
|
-
response =
|
|
1128
|
+
response = _context5.v;
|
|
1089
1129
|
if (!response.success) {
|
|
1090
|
-
|
|
1130
|
+
_context5.n = 5;
|
|
1091
1131
|
break;
|
|
1092
1132
|
}
|
|
1093
1133
|
// Construire l'URL complète de l'image QR avec la base URL pour les images
|
|
@@ -1100,18 +1140,18 @@
|
|
|
1100
1140
|
console.log('📄 Code de session:', response.data.code);
|
|
1101
1141
|
console.log('🆔 Service ID:', response.data.service_id);
|
|
1102
1142
|
this.startAutoRefresh(containerId, type, options);
|
|
1103
|
-
return
|
|
1143
|
+
return _context5.a(2, _objectSpread2(_objectSpread2({}, response.data), {}, {
|
|
1104
1144
|
qrCodeUrl: qrImageUrl,
|
|
1105
1145
|
sessionId: response.data.service_id
|
|
1106
1146
|
}));
|
|
1107
1147
|
case 5:
|
|
1108
1148
|
throw new Error(response.message || 'Erreur lors de la génération du QR code');
|
|
1109
1149
|
case 6:
|
|
1110
|
-
|
|
1150
|
+
_context5.n = 8;
|
|
1111
1151
|
break;
|
|
1112
1152
|
case 7:
|
|
1113
|
-
|
|
1114
|
-
_t5 =
|
|
1153
|
+
_context5.p = 7;
|
|
1154
|
+
_t5 = _context5.v;
|
|
1115
1155
|
console.error('Erreur API détectée:', _t5.message);
|
|
1116
1156
|
console.error('Stack trace complet:', _t5.stack);
|
|
1117
1157
|
console.error('Configuration SDK (Custom):', {
|
|
@@ -1125,9 +1165,9 @@
|
|
|
1125
1165
|
this.displayServiceUnavailable(containerId, type);
|
|
1126
1166
|
throw new Error('Service non disponible');
|
|
1127
1167
|
case 8:
|
|
1128
|
-
return
|
|
1168
|
+
return _context5.a(2);
|
|
1129
1169
|
}
|
|
1130
|
-
},
|
|
1170
|
+
}, _callee5, this, [[3, 7]]);
|
|
1131
1171
|
}));
|
|
1132
1172
|
function generateCustomQR(_x, _x2) {
|
|
1133
1173
|
return _generateCustomQR.apply(this, arguments);
|
|
@@ -1138,16 +1178,16 @@
|
|
|
1138
1178
|
}, {
|
|
1139
1179
|
key: "generateAuthQR",
|
|
1140
1180
|
value: function () {
|
|
1141
|
-
var _generateAuthQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1181
|
+
var _generateAuthQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(containerId) {
|
|
1142
1182
|
var options,
|
|
1143
|
-
|
|
1144
|
-
return _regenerator().w(function (
|
|
1145
|
-
while (1) switch (
|
|
1183
|
+
_args6 = arguments;
|
|
1184
|
+
return _regenerator().w(function (_context6) {
|
|
1185
|
+
while (1) switch (_context6.n) {
|
|
1146
1186
|
case 0:
|
|
1147
|
-
options =
|
|
1148
|
-
return
|
|
1187
|
+
options = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : {};
|
|
1188
|
+
return _context6.a(2, this.generateQR(containerId, options));
|
|
1149
1189
|
}
|
|
1150
|
-
},
|
|
1190
|
+
}, _callee6, this);
|
|
1151
1191
|
}));
|
|
1152
1192
|
function generateAuthQR(_x3) {
|
|
1153
1193
|
return _generateAuthQR.apply(this, arguments);
|
|
@@ -1157,31 +1197,31 @@
|
|
|
1157
1197
|
}, {
|
|
1158
1198
|
key: "generateKYCQR",
|
|
1159
1199
|
value: function () {
|
|
1160
|
-
var _generateKYCQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1200
|
+
var _generateKYCQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(containerId) {
|
|
1161
1201
|
var options,
|
|
1162
1202
|
originalType,
|
|
1163
|
-
|
|
1164
|
-
return _regenerator().w(function (
|
|
1165
|
-
while (1) switch (
|
|
1203
|
+
_args7 = arguments;
|
|
1204
|
+
return _regenerator().w(function (_context7) {
|
|
1205
|
+
while (1) switch (_context7.p = _context7.n) {
|
|
1166
1206
|
case 0:
|
|
1167
|
-
options =
|
|
1207
|
+
options = _args7.length > 1 && _args7[1] !== undefined ? _args7[1] : {};
|
|
1168
1208
|
// Sauvegarder le type actuel
|
|
1169
1209
|
originalType = this.config.type; // Changer temporairement le type pour KYC
|
|
1170
1210
|
this.config.type = 1;
|
|
1171
|
-
|
|
1172
|
-
|
|
1211
|
+
_context7.p = 1;
|
|
1212
|
+
_context7.n = 2;
|
|
1173
1213
|
return this.generateQR(containerId, options);
|
|
1174
1214
|
case 2:
|
|
1175
|
-
return
|
|
1215
|
+
return _context7.a(2, _context7.v);
|
|
1176
1216
|
case 3:
|
|
1177
|
-
|
|
1217
|
+
_context7.p = 3;
|
|
1178
1218
|
// Restaurer le type original
|
|
1179
1219
|
this.config.type = originalType;
|
|
1180
|
-
return
|
|
1220
|
+
return _context7.f(3);
|
|
1181
1221
|
case 4:
|
|
1182
|
-
return
|
|
1222
|
+
return _context7.a(2);
|
|
1183
1223
|
}
|
|
1184
|
-
},
|
|
1224
|
+
}, _callee7, this, [[1,, 3, 4]]);
|
|
1185
1225
|
}));
|
|
1186
1226
|
function generateKYCQR(_x4) {
|
|
1187
1227
|
return _generateKYCQR.apply(this, arguments);
|
|
@@ -1191,31 +1231,31 @@
|
|
|
1191
1231
|
}, {
|
|
1192
1232
|
key: "generateSignatureQR",
|
|
1193
1233
|
value: function () {
|
|
1194
|
-
var _generateSignatureQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1234
|
+
var _generateSignatureQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(containerId) {
|
|
1195
1235
|
var options,
|
|
1196
1236
|
originalType,
|
|
1197
|
-
|
|
1198
|
-
return _regenerator().w(function (
|
|
1199
|
-
while (1) switch (
|
|
1237
|
+
_args8 = arguments;
|
|
1238
|
+
return _regenerator().w(function (_context8) {
|
|
1239
|
+
while (1) switch (_context8.p = _context8.n) {
|
|
1200
1240
|
case 0:
|
|
1201
|
-
options =
|
|
1241
|
+
options = _args8.length > 1 && _args8[1] !== undefined ? _args8[1] : {};
|
|
1202
1242
|
// Sauvegarder le type actuel
|
|
1203
1243
|
originalType = this.config.type; // Changer temporairement le type pour Signature
|
|
1204
1244
|
this.config.type = 3;
|
|
1205
|
-
|
|
1206
|
-
|
|
1245
|
+
_context8.p = 1;
|
|
1246
|
+
_context8.n = 2;
|
|
1207
1247
|
return this.generateQR(containerId, options);
|
|
1208
1248
|
case 2:
|
|
1209
|
-
return
|
|
1249
|
+
return _context8.a(2, _context8.v);
|
|
1210
1250
|
case 3:
|
|
1211
|
-
|
|
1251
|
+
_context8.p = 3;
|
|
1212
1252
|
// Restaurer le type original
|
|
1213
1253
|
this.config.type = originalType;
|
|
1214
|
-
return
|
|
1254
|
+
return _context8.f(3);
|
|
1215
1255
|
case 4:
|
|
1216
|
-
return
|
|
1256
|
+
return _context8.a(2);
|
|
1217
1257
|
}
|
|
1218
|
-
},
|
|
1258
|
+
}, _callee8, this, [[1,, 3, 4]]);
|
|
1219
1259
|
}));
|
|
1220
1260
|
function generateSignatureQR(_x5) {
|
|
1221
1261
|
return _generateSignatureQR.apply(this, arguments);
|
|
@@ -1228,43 +1268,43 @@
|
|
|
1228
1268
|
}, {
|
|
1229
1269
|
key: "checkQRStatus",
|
|
1230
1270
|
value: (function () {
|
|
1231
|
-
var _checkQRStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1271
|
+
var _checkQRStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(sessionId) {
|
|
1232
1272
|
var response, _t6;
|
|
1233
|
-
return _regenerator().w(function (
|
|
1234
|
-
while (1) switch (
|
|
1273
|
+
return _regenerator().w(function (_context9) {
|
|
1274
|
+
while (1) switch (_context9.p = _context9.n) {
|
|
1235
1275
|
case 0:
|
|
1236
1276
|
if (this.isInitialized) {
|
|
1237
|
-
|
|
1277
|
+
_context9.n = 1;
|
|
1238
1278
|
break;
|
|
1239
1279
|
}
|
|
1240
1280
|
throw new Error('SunuID: SDK non initialisé');
|
|
1241
1281
|
case 1:
|
|
1242
|
-
|
|
1243
|
-
|
|
1282
|
+
_context9.p = 1;
|
|
1283
|
+
_context9.n = 2;
|
|
1244
1284
|
return this.makeRequest('/qr-status', {
|
|
1245
1285
|
serviceId: sessionId
|
|
1246
1286
|
});
|
|
1247
1287
|
case 2:
|
|
1248
|
-
response =
|
|
1288
|
+
response = _context9.v;
|
|
1249
1289
|
if (!response.success) {
|
|
1250
|
-
|
|
1290
|
+
_context9.n = 3;
|
|
1251
1291
|
break;
|
|
1252
1292
|
}
|
|
1253
|
-
return
|
|
1293
|
+
return _context9.a(2, response.data);
|
|
1254
1294
|
case 3:
|
|
1255
1295
|
throw new Error(response.message || 'Erreur lors de la vérification du statut');
|
|
1256
1296
|
case 4:
|
|
1257
|
-
|
|
1297
|
+
_context9.n = 6;
|
|
1258
1298
|
break;
|
|
1259
1299
|
case 5:
|
|
1260
|
-
|
|
1261
|
-
_t6 =
|
|
1300
|
+
_context9.p = 5;
|
|
1301
|
+
_t6 = _context9.v;
|
|
1262
1302
|
this.handleError(_t6);
|
|
1263
1303
|
throw _t6;
|
|
1264
1304
|
case 6:
|
|
1265
|
-
return
|
|
1305
|
+
return _context9.a(2);
|
|
1266
1306
|
}
|
|
1267
|
-
},
|
|
1307
|
+
}, _callee9, this, [[1, 5]]);
|
|
1268
1308
|
}));
|
|
1269
1309
|
function checkQRStatus(_x6) {
|
|
1270
1310
|
return _checkQRStatus.apply(this, arguments);
|
|
@@ -1278,47 +1318,47 @@
|
|
|
1278
1318
|
}, {
|
|
1279
1319
|
key: "generateQRWithContent",
|
|
1280
1320
|
value: (function () {
|
|
1281
|
-
var _generateQRWithContent = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1321
|
+
var _generateQRWithContent = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(content, containerId, type) {
|
|
1282
1322
|
var options,
|
|
1283
1323
|
localQRUrl,
|
|
1284
|
-
|
|
1324
|
+
_args0 = arguments,
|
|
1285
1325
|
_t7;
|
|
1286
|
-
return _regenerator().w(function (
|
|
1287
|
-
while (1) switch (
|
|
1326
|
+
return _regenerator().w(function (_context0) {
|
|
1327
|
+
while (1) switch (_context0.p = _context0.n) {
|
|
1288
1328
|
case 0:
|
|
1289
|
-
options =
|
|
1329
|
+
options = _args0.length > 3 && _args0[3] !== undefined ? _args0[3] : {};
|
|
1290
1330
|
console.log('🎨 Génération QR avec contenu:', content);
|
|
1291
|
-
|
|
1331
|
+
_context0.p = 1;
|
|
1292
1332
|
if (!(window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1' || window.location.protocol === 'file:')) {
|
|
1293
|
-
|
|
1333
|
+
_context0.n = 3;
|
|
1294
1334
|
break;
|
|
1295
1335
|
}
|
|
1296
1336
|
console.log('🏠 Utilisation service QR local...');
|
|
1297
|
-
|
|
1337
|
+
_context0.n = 2;
|
|
1298
1338
|
return this.generateQRLocal(content, containerId, type, options);
|
|
1299
1339
|
case 2:
|
|
1300
|
-
localQRUrl =
|
|
1340
|
+
localQRUrl = _context0.v;
|
|
1301
1341
|
if (!localQRUrl) {
|
|
1302
|
-
|
|
1342
|
+
_context0.n = 3;
|
|
1303
1343
|
break;
|
|
1304
1344
|
}
|
|
1305
|
-
return
|
|
1345
|
+
return _context0.a(2, localQRUrl);
|
|
1306
1346
|
case 3:
|
|
1307
1347
|
// Fallback vers le service QR distant
|
|
1308
1348
|
console.log('🌐 Utilisation service QR distant...');
|
|
1309
|
-
|
|
1349
|
+
_context0.n = 4;
|
|
1310
1350
|
return this.generateQRRemote(content, containerId, type, options);
|
|
1311
1351
|
case 4:
|
|
1312
|
-
return
|
|
1352
|
+
return _context0.a(2, _context0.v);
|
|
1313
1353
|
case 5:
|
|
1314
|
-
|
|
1315
|
-
_t7 =
|
|
1354
|
+
_context0.p = 5;
|
|
1355
|
+
_t7 = _context0.v;
|
|
1316
1356
|
console.error('❌ Erreur génération QR:', _t7);
|
|
1317
1357
|
// Fallback vers affichage simple du contenu
|
|
1318
1358
|
this.displayQRContent(containerId, content, type, options);
|
|
1319
|
-
return
|
|
1359
|
+
return _context0.a(2, null);
|
|
1320
1360
|
}
|
|
1321
|
-
},
|
|
1361
|
+
}, _callee0, this, [[1, 5]]);
|
|
1322
1362
|
}));
|
|
1323
1363
|
function generateQRWithContent(_x7, _x8, _x9) {
|
|
1324
1364
|
return _generateQRWithContent.apply(this, arguments);
|
|
@@ -1332,19 +1372,19 @@
|
|
|
1332
1372
|
}, {
|
|
1333
1373
|
key: "generateQRLocal",
|
|
1334
1374
|
value: (function () {
|
|
1335
|
-
var _generateQRLocal = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1375
|
+
var _generateQRLocal = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(content, containerId, type) {
|
|
1336
1376
|
var options,
|
|
1337
1377
|
response,
|
|
1338
1378
|
data,
|
|
1339
1379
|
qrUrl,
|
|
1340
|
-
|
|
1380
|
+
_args1 = arguments,
|
|
1341
1381
|
_t8;
|
|
1342
|
-
return _regenerator().w(function (
|
|
1343
|
-
while (1) switch (
|
|
1382
|
+
return _regenerator().w(function (_context1) {
|
|
1383
|
+
while (1) switch (_context1.p = _context1.n) {
|
|
1344
1384
|
case 0:
|
|
1345
|
-
options =
|
|
1346
|
-
|
|
1347
|
-
|
|
1385
|
+
options = _args1.length > 3 && _args1[3] !== undefined ? _args1[3] : {};
|
|
1386
|
+
_context1.p = 1;
|
|
1387
|
+
_context1.n = 2;
|
|
1348
1388
|
return fetch('http://localhost:8000/api/generate/text', {
|
|
1349
1389
|
method: 'POST',
|
|
1350
1390
|
headers: {
|
|
@@ -1353,29 +1393,29 @@
|
|
|
1353
1393
|
body: "text=".concat(encodeURIComponent(content), "&size=300")
|
|
1354
1394
|
});
|
|
1355
1395
|
case 2:
|
|
1356
|
-
response =
|
|
1396
|
+
response = _context1.v;
|
|
1357
1397
|
if (!response.ok) {
|
|
1358
|
-
|
|
1398
|
+
_context1.n = 4;
|
|
1359
1399
|
break;
|
|
1360
1400
|
}
|
|
1361
|
-
|
|
1401
|
+
_context1.n = 3;
|
|
1362
1402
|
return response.json();
|
|
1363
1403
|
case 3:
|
|
1364
|
-
data =
|
|
1404
|
+
data = _context1.v;
|
|
1365
1405
|
qrUrl = "data:image/png;base64,".concat(data.qrcode);
|
|
1366
1406
|
this.displayQRCode(containerId, qrUrl, type, options);
|
|
1367
|
-
return
|
|
1407
|
+
return _context1.a(2, qrUrl);
|
|
1368
1408
|
case 4:
|
|
1369
|
-
|
|
1409
|
+
_context1.n = 6;
|
|
1370
1410
|
break;
|
|
1371
1411
|
case 5:
|
|
1372
|
-
|
|
1373
|
-
_t8 =
|
|
1412
|
+
_context1.p = 5;
|
|
1413
|
+
_t8 = _context1.v;
|
|
1374
1414
|
console.log('❌ Service QR local non disponible:', _t8.message);
|
|
1375
1415
|
case 6:
|
|
1376
|
-
return
|
|
1416
|
+
return _context1.a(2, null);
|
|
1377
1417
|
}
|
|
1378
|
-
},
|
|
1418
|
+
}, _callee1, this, [[1, 5]]);
|
|
1379
1419
|
}));
|
|
1380
1420
|
function generateQRLocal(_x0, _x1, _x10) {
|
|
1381
1421
|
return _generateQRLocal.apply(this, arguments);
|
|
@@ -1389,19 +1429,19 @@
|
|
|
1389
1429
|
}, {
|
|
1390
1430
|
key: "generateQRRemote",
|
|
1391
1431
|
value: (function () {
|
|
1392
|
-
var _generateQRRemote = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1432
|
+
var _generateQRRemote = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(content, containerId, type) {
|
|
1393
1433
|
var options,
|
|
1394
1434
|
response,
|
|
1395
1435
|
data,
|
|
1396
1436
|
qrUrl,
|
|
1397
|
-
|
|
1437
|
+
_args10 = arguments,
|
|
1398
1438
|
_t9;
|
|
1399
|
-
return _regenerator().w(function (
|
|
1400
|
-
while (1) switch (
|
|
1439
|
+
return _regenerator().w(function (_context10) {
|
|
1440
|
+
while (1) switch (_context10.p = _context10.n) {
|
|
1401
1441
|
case 0:
|
|
1402
|
-
options =
|
|
1403
|
-
|
|
1404
|
-
|
|
1442
|
+
options = _args10.length > 3 && _args10[3] !== undefined ? _args10[3] : {};
|
|
1443
|
+
_context10.p = 1;
|
|
1444
|
+
_context10.n = 2;
|
|
1405
1445
|
return fetch('https://api.sunuid.fayma.sn/qr-generate', {
|
|
1406
1446
|
method: 'POST',
|
|
1407
1447
|
headers: {
|
|
@@ -1414,31 +1454,31 @@
|
|
|
1414
1454
|
})
|
|
1415
1455
|
});
|
|
1416
1456
|
case 2:
|
|
1417
|
-
response =
|
|
1457
|
+
response = _context10.v;
|
|
1418
1458
|
if (!response.ok) {
|
|
1419
|
-
|
|
1459
|
+
_context10.n = 4;
|
|
1420
1460
|
break;
|
|
1421
1461
|
}
|
|
1422
|
-
|
|
1462
|
+
_context10.n = 3;
|
|
1423
1463
|
return response.json();
|
|
1424
1464
|
case 3:
|
|
1425
|
-
data =
|
|
1465
|
+
data = _context10.v;
|
|
1426
1466
|
qrUrl = "data:image/png;base64,".concat(data.qrcode);
|
|
1427
1467
|
this.displayQRCode(containerId, qrUrl, type, options);
|
|
1428
|
-
return
|
|
1468
|
+
return _context10.a(2, qrUrl);
|
|
1429
1469
|
case 4:
|
|
1430
|
-
|
|
1470
|
+
_context10.n = 6;
|
|
1431
1471
|
break;
|
|
1432
1472
|
case 5:
|
|
1433
|
-
|
|
1434
|
-
_t9 =
|
|
1473
|
+
_context10.p = 5;
|
|
1474
|
+
_t9 = _context10.v;
|
|
1435
1475
|
console.error('❌ Erreur service QR distant:', _t9);
|
|
1436
1476
|
case 6:
|
|
1437
1477
|
// Fallback vers affichage du contenu
|
|
1438
1478
|
this.displayQRContent(containerId, content, type, options);
|
|
1439
|
-
return
|
|
1479
|
+
return _context10.a(2, null);
|
|
1440
1480
|
}
|
|
1441
|
-
},
|
|
1481
|
+
}, _callee10, this, [[1, 5]]);
|
|
1442
1482
|
}));
|
|
1443
1483
|
function generateQRRemote(_x11, _x12, _x13) {
|
|
1444
1484
|
return _generateQRRemote.apply(this, arguments);
|
|
@@ -1496,11 +1536,11 @@
|
|
|
1496
1536
|
}, {
|
|
1497
1537
|
key: "generateCustomQRCode",
|
|
1498
1538
|
value: (function () {
|
|
1499
|
-
var _generateCustomQRCode = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1539
|
+
var _generateCustomQRCode = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11(content, label) {
|
|
1500
1540
|
var qrContainer,
|
|
1501
1541
|
_t0;
|
|
1502
|
-
return _regenerator().w(function (
|
|
1503
|
-
while (1) switch (
|
|
1542
|
+
return _regenerator().w(function (_context11) {
|
|
1543
|
+
while (1) switch (_context11.p = _context11.n) {
|
|
1504
1544
|
case 0:
|
|
1505
1545
|
console.log('🎨 Début génération QR personnalisé...');
|
|
1506
1546
|
console.log('📄 Contenu:', content);
|
|
@@ -1512,37 +1552,37 @@
|
|
|
1512
1552
|
qrContainer = document.getElementById('qr-container');
|
|
1513
1553
|
}
|
|
1514
1554
|
if (qrContainer) {
|
|
1515
|
-
|
|
1555
|
+
_context11.n = 1;
|
|
1516
1556
|
break;
|
|
1517
1557
|
}
|
|
1518
1558
|
console.error('❌ QR container not found');
|
|
1519
|
-
return
|
|
1559
|
+
return _context11.a(2);
|
|
1520
1560
|
case 1:
|
|
1521
1561
|
console.log('✅ QR container trouvé');
|
|
1522
1562
|
|
|
1523
1563
|
// Nettoyer le conteneur
|
|
1524
1564
|
qrContainer.innerHTML = '<div style="text-align: center; padding: 20px;"><p>Génération QR code...</p></div>';
|
|
1525
|
-
|
|
1565
|
+
_context11.p = 2;
|
|
1526
1566
|
// Utiliser directement l'API principale (plus fiable)
|
|
1527
1567
|
console.log('🎨 Tentative génération via API principale...');
|
|
1528
|
-
|
|
1568
|
+
_context11.n = 3;
|
|
1529
1569
|
return this.generateQRPHP(content, label, qrContainer);
|
|
1530
1570
|
case 3:
|
|
1531
1571
|
console.log('✅ QR code généré avec succès');
|
|
1532
|
-
|
|
1572
|
+
_context11.n = 5;
|
|
1533
1573
|
break;
|
|
1534
1574
|
case 4:
|
|
1535
|
-
|
|
1536
|
-
_t0 =
|
|
1575
|
+
_context11.p = 4;
|
|
1576
|
+
_t0 = _context11.v;
|
|
1537
1577
|
console.error('❌ Erreur génération API:', _t0);
|
|
1538
1578
|
|
|
1539
1579
|
// Fallback final : image par défaut
|
|
1540
1580
|
console.log('⚠️ Affichage image par défaut');
|
|
1541
1581
|
this.displayDefaultQR(qrContainer, content, label);
|
|
1542
1582
|
case 5:
|
|
1543
|
-
return
|
|
1583
|
+
return _context11.a(2);
|
|
1544
1584
|
}
|
|
1545
|
-
},
|
|
1585
|
+
}, _callee11, this, [[2, 4]]);
|
|
1546
1586
|
}));
|
|
1547
1587
|
function generateCustomQRCode(_x14, _x15) {
|
|
1548
1588
|
return _generateCustomQRCode.apply(this, arguments);
|
|
@@ -1556,17 +1596,17 @@
|
|
|
1556
1596
|
}, {
|
|
1557
1597
|
key: "generateQRClientSide",
|
|
1558
1598
|
value: (function () {
|
|
1559
|
-
var _generateQRClientSide = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1560
|
-
var
|
|
1599
|
+
var _generateQRClientSide = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12(content, label, qrContainer) {
|
|
1600
|
+
var _this3 = this;
|
|
1561
1601
|
var canvas, ctx;
|
|
1562
|
-
return _regenerator().w(function (
|
|
1563
|
-
while (1) switch (
|
|
1602
|
+
return _regenerator().w(function (_context12) {
|
|
1603
|
+
while (1) switch (_context12.n) {
|
|
1564
1604
|
case 0:
|
|
1565
|
-
|
|
1605
|
+
_context12.n = 1;
|
|
1566
1606
|
return this.ensureQRCodeLibrary();
|
|
1567
1607
|
case 1:
|
|
1568
1608
|
if (!(typeof QRCode === 'undefined')) {
|
|
1569
|
-
|
|
1609
|
+
_context12.n = 2;
|
|
1570
1610
|
break;
|
|
1571
1611
|
}
|
|
1572
1612
|
throw new Error('QRCode library non disponible');
|
|
@@ -1580,7 +1620,7 @@
|
|
|
1580
1620
|
ctx.fillRect(0, 0, 300, 320);
|
|
1581
1621
|
|
|
1582
1622
|
// Générer le QR code
|
|
1583
|
-
return
|
|
1623
|
+
return _context12.a(2, new Promise(function (resolve, reject) {
|
|
1584
1624
|
QRCode.toCanvas(canvas, content, {
|
|
1585
1625
|
width: 280,
|
|
1586
1626
|
margin: 10,
|
|
@@ -1604,18 +1644,18 @@
|
|
|
1604
1644
|
var dataUrl = canvas.toDataURL('image/png');
|
|
1605
1645
|
|
|
1606
1646
|
// Stocker l'URL
|
|
1607
|
-
|
|
1647
|
+
_this3.currentQRUrl = dataUrl;
|
|
1608
1648
|
|
|
1609
1649
|
// Afficher le QR code
|
|
1610
1650
|
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 ");
|
|
1611
1651
|
|
|
1612
1652
|
// Afficher les instructions
|
|
1613
|
-
|
|
1653
|
+
_this3.showQRInstructions(qrContainer);
|
|
1614
1654
|
resolve();
|
|
1615
1655
|
});
|
|
1616
1656
|
}));
|
|
1617
1657
|
}
|
|
1618
|
-
},
|
|
1658
|
+
}, _callee12, this);
|
|
1619
1659
|
}));
|
|
1620
1660
|
function generateQRClientSide(_x16, _x17, _x18) {
|
|
1621
1661
|
return _generateQRClientSide.apply(this, arguments);
|
|
@@ -1629,10 +1669,10 @@
|
|
|
1629
1669
|
}, {
|
|
1630
1670
|
key: "generateQRPHP",
|
|
1631
1671
|
value: (function () {
|
|
1632
|
-
var _generateQRPHP = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1672
|
+
var _generateQRPHP = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13(content, label, qrContainer) {
|
|
1633
1673
|
var qrGeneratorUrl, requestBody, contentType, response, responseData, qrImageUrl, imageBaseUrl;
|
|
1634
|
-
return _regenerator().w(function (
|
|
1635
|
-
while (1) switch (
|
|
1674
|
+
return _regenerator().w(function (_context13) {
|
|
1675
|
+
while (1) switch (_context13.n) {
|
|
1636
1676
|
case 0:
|
|
1637
1677
|
// Construire l'URL - Utiliser l'API principale qui fonctionne
|
|
1638
1678
|
|
|
@@ -1670,7 +1710,7 @@
|
|
|
1670
1710
|
label: label
|
|
1671
1711
|
});
|
|
1672
1712
|
}
|
|
1673
|
-
|
|
1713
|
+
_context13.n = 1;
|
|
1674
1714
|
return fetch(qrGeneratorUrl, {
|
|
1675
1715
|
method: 'POST',
|
|
1676
1716
|
headers: {
|
|
@@ -1680,19 +1720,19 @@
|
|
|
1680
1720
|
body: requestBody
|
|
1681
1721
|
});
|
|
1682
1722
|
case 1:
|
|
1683
|
-
response =
|
|
1723
|
+
response = _context13.v;
|
|
1684
1724
|
if (response.ok) {
|
|
1685
|
-
|
|
1725
|
+
_context13.n = 2;
|
|
1686
1726
|
break;
|
|
1687
1727
|
}
|
|
1688
1728
|
throw new Error("Erreur HTTP: ".concat(response.status));
|
|
1689
1729
|
case 2:
|
|
1690
|
-
|
|
1730
|
+
_context13.n = 3;
|
|
1691
1731
|
return response.json();
|
|
1692
1732
|
case 3:
|
|
1693
|
-
responseData =
|
|
1733
|
+
responseData = _context13.v;
|
|
1694
1734
|
if (responseData.success) {
|
|
1695
|
-
|
|
1735
|
+
_context13.n = 4;
|
|
1696
1736
|
break;
|
|
1697
1737
|
}
|
|
1698
1738
|
throw new Error("Erreur QR: ".concat(responseData.error));
|
|
@@ -1715,9 +1755,9 @@
|
|
|
1715
1755
|
// Afficher les instructions
|
|
1716
1756
|
this.showQRInstructions(qrContainer);
|
|
1717
1757
|
case 5:
|
|
1718
|
-
return
|
|
1758
|
+
return _context13.a(2);
|
|
1719
1759
|
}
|
|
1720
|
-
},
|
|
1760
|
+
}, _callee13, this);
|
|
1721
1761
|
}));
|
|
1722
1762
|
function generateQRPHP(_x19, _x20, _x21) {
|
|
1723
1763
|
return _generateQRPHP.apply(this, arguments);
|
|
@@ -1740,19 +1780,19 @@
|
|
|
1740
1780
|
}, {
|
|
1741
1781
|
key: "ensureQRCodeLibrary",
|
|
1742
1782
|
value: (function () {
|
|
1743
|
-
var _ensureQRCodeLibrary = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1744
|
-
return _regenerator().w(function (
|
|
1745
|
-
while (1) switch (
|
|
1783
|
+
var _ensureQRCodeLibrary = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14() {
|
|
1784
|
+
return _regenerator().w(function (_context14) {
|
|
1785
|
+
while (1) switch (_context14.n) {
|
|
1746
1786
|
case 0:
|
|
1747
1787
|
if (!(typeof QRCode !== 'undefined')) {
|
|
1748
|
-
|
|
1788
|
+
_context14.n = 1;
|
|
1749
1789
|
break;
|
|
1750
1790
|
}
|
|
1751
1791
|
console.log('✅ QRCode library déjà disponible');
|
|
1752
|
-
return
|
|
1792
|
+
return _context14.a(2, true);
|
|
1753
1793
|
case 1:
|
|
1754
1794
|
console.log('📦 Chargement QRCode library...');
|
|
1755
|
-
return
|
|
1795
|
+
return _context14.a(2, new Promise(function (resolve, reject) {
|
|
1756
1796
|
var script = document.createElement('script');
|
|
1757
1797
|
script.src = 'https://cdn.jsdelivr.net/npm/qrcode@1.5.3/lib/browser.min.js';
|
|
1758
1798
|
script.onload = function () {
|
|
@@ -1773,7 +1813,7 @@
|
|
|
1773
1813
|
document.head.appendChild(script);
|
|
1774
1814
|
}));
|
|
1775
1815
|
}
|
|
1776
|
-
},
|
|
1816
|
+
}, _callee14);
|
|
1777
1817
|
}));
|
|
1778
1818
|
function ensureQRCodeLibrary() {
|
|
1779
1819
|
return _ensureQRCodeLibrary.apply(this, arguments);
|
|
@@ -1860,19 +1900,19 @@
|
|
|
1860
1900
|
}, {
|
|
1861
1901
|
key: "refreshQR",
|
|
1862
1902
|
value: (function () {
|
|
1863
|
-
var _refreshQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1903
|
+
var _refreshQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15(containerId) {
|
|
1864
1904
|
var options,
|
|
1865
1905
|
result,
|
|
1866
1906
|
_result,
|
|
1867
|
-
|
|
1907
|
+
_args15 = arguments,
|
|
1868
1908
|
_t1;
|
|
1869
|
-
return _regenerator().w(function (
|
|
1870
|
-
while (1) switch (
|
|
1909
|
+
return _regenerator().w(function (_context15) {
|
|
1910
|
+
while (1) switch (_context15.p = _context15.n) {
|
|
1871
1911
|
case 0:
|
|
1872
|
-
options =
|
|
1873
|
-
|
|
1912
|
+
options = _args15.length > 1 && _args15[1] !== undefined ? _args15[1] : {};
|
|
1913
|
+
_context15.p = 1;
|
|
1874
1914
|
if (!this.currentQRUrl) {
|
|
1875
|
-
|
|
1915
|
+
_context15.n = 3;
|
|
1876
1916
|
break;
|
|
1877
1917
|
}
|
|
1878
1918
|
console.log('🔄 Vérification du statut du QR code existant...');
|
|
@@ -1882,31 +1922,31 @@
|
|
|
1882
1922
|
|
|
1883
1923
|
// Option 2: Régénérer le QR code seulement si nécessaire
|
|
1884
1924
|
// Pour l'instant, on régénère pour s'assurer qu'il est à jour
|
|
1885
|
-
|
|
1925
|
+
_context15.n = 2;
|
|
1886
1926
|
return this.generateQR(containerId, options);
|
|
1887
1927
|
case 2:
|
|
1888
|
-
result =
|
|
1889
|
-
return
|
|
1928
|
+
result = _context15.v;
|
|
1929
|
+
return _context15.a(2, result);
|
|
1890
1930
|
case 3:
|
|
1891
1931
|
console.log('🔄 Pas de QR code existant, génération d\'un nouveau...');
|
|
1892
|
-
|
|
1932
|
+
_context15.n = 4;
|
|
1893
1933
|
return this.generateQR(containerId, options);
|
|
1894
1934
|
case 4:
|
|
1895
|
-
_result =
|
|
1896
|
-
return
|
|
1935
|
+
_result = _context15.v;
|
|
1936
|
+
return _context15.a(2, _result);
|
|
1897
1937
|
case 5:
|
|
1898
|
-
|
|
1938
|
+
_context15.n = 7;
|
|
1899
1939
|
break;
|
|
1900
1940
|
case 6:
|
|
1901
|
-
|
|
1902
|
-
_t1 =
|
|
1941
|
+
_context15.p = 6;
|
|
1942
|
+
_t1 = _context15.v;
|
|
1903
1943
|
console.error('Erreur lors du rafraîchissement:', _t1.message);
|
|
1904
1944
|
this.displayServiceUnavailable(containerId, this.config.type);
|
|
1905
1945
|
throw _t1;
|
|
1906
1946
|
case 7:
|
|
1907
|
-
return
|
|
1947
|
+
return _context15.a(2);
|
|
1908
1948
|
}
|
|
1909
|
-
},
|
|
1949
|
+
}, _callee15, this, [[1, 6]]);
|
|
1910
1950
|
}));
|
|
1911
1951
|
function refreshQR(_x22) {
|
|
1912
1952
|
return _refreshQR.apply(this, arguments);
|
|
@@ -1920,7 +1960,7 @@
|
|
|
1920
1960
|
}, {
|
|
1921
1961
|
key: "startAutoRefresh",
|
|
1922
1962
|
value: function startAutoRefresh(containerId, type, options) {
|
|
1923
|
-
var
|
|
1963
|
+
var _this4 = this;
|
|
1924
1964
|
if (!this.config.autoRefresh) return;
|
|
1925
1965
|
|
|
1926
1966
|
// Arrêter le timer existant s'il y en a un
|
|
@@ -1928,26 +1968,26 @@
|
|
|
1928
1968
|
clearInterval(this.refreshTimer);
|
|
1929
1969
|
console.log('🔄 Timer de rafraîchissement précédent arrêté');
|
|
1930
1970
|
}
|
|
1931
|
-
this.refreshTimer = setInterval(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1971
|
+
this.refreshTimer = setInterval(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16() {
|
|
1932
1972
|
var _t10;
|
|
1933
|
-
return _regenerator().w(function (
|
|
1934
|
-
while (1) switch (
|
|
1973
|
+
return _regenerator().w(function (_context16) {
|
|
1974
|
+
while (1) switch (_context16.p = _context16.n) {
|
|
1935
1975
|
case 0:
|
|
1936
|
-
|
|
1976
|
+
_context16.p = 0;
|
|
1937
1977
|
console.log('🔄 Rafraîchissement automatique du QR code...');
|
|
1938
|
-
|
|
1939
|
-
return
|
|
1978
|
+
_context16.n = 1;
|
|
1979
|
+
return _this4.refreshQR(containerId, type, options);
|
|
1940
1980
|
case 1:
|
|
1941
|
-
|
|
1981
|
+
_context16.n = 3;
|
|
1942
1982
|
break;
|
|
1943
1983
|
case 2:
|
|
1944
|
-
|
|
1945
|
-
_t10 =
|
|
1984
|
+
_context16.p = 2;
|
|
1985
|
+
_t10 = _context16.v;
|
|
1946
1986
|
console.warn('Erreur lors du rafraîchissement automatique:', _t10);
|
|
1947
1987
|
case 3:
|
|
1948
|
-
return
|
|
1988
|
+
return _context16.a(2);
|
|
1949
1989
|
}
|
|
1950
|
-
},
|
|
1990
|
+
}, _callee16, null, [[0, 2]]);
|
|
1951
1991
|
})), this.config.refreshInterval);
|
|
1952
1992
|
console.log("\uD83D\uDD04 Timer de rafra\xEEchissement d\xE9marr\xE9 (".concat(this.config.refreshInterval, "ms)"));
|
|
1953
1993
|
}
|
|
@@ -1962,16 +2002,16 @@
|
|
|
1962
2002
|
}, {
|
|
1963
2003
|
key: "makeRequest",
|
|
1964
2004
|
value: (function () {
|
|
1965
|
-
var _makeRequest = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
2005
|
+
var _makeRequest = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17(endpoint, data) {
|
|
1966
2006
|
var _window$SunuIDConfig4,
|
|
1967
2007
|
_window$SunuIDConfig5,
|
|
1968
|
-
|
|
2008
|
+
_this5 = this;
|
|
1969
2009
|
var sanitizedData, endpointPath, url, retryCount, maxRetries, _loop, _ret;
|
|
1970
|
-
return _regenerator().w(function (
|
|
1971
|
-
while (1) switch (
|
|
2010
|
+
return _regenerator().w(function (_context18) {
|
|
2011
|
+
while (1) switch (_context18.n) {
|
|
1972
2012
|
case 0:
|
|
1973
2013
|
if (this.isInitialized) {
|
|
1974
|
-
|
|
2014
|
+
_context18.n = 1;
|
|
1975
2015
|
break;
|
|
1976
2016
|
}
|
|
1977
2017
|
this.logSecurityEvent('REQUEST_BEFORE_INIT', {
|
|
@@ -1980,12 +2020,12 @@
|
|
|
1980
2020
|
throw new Error('SDK non initialisé');
|
|
1981
2021
|
case 1:
|
|
1982
2022
|
if (!this.config.secureInit) {
|
|
1983
|
-
|
|
2023
|
+
_context18.n = 2;
|
|
1984
2024
|
break;
|
|
1985
2025
|
}
|
|
1986
2026
|
this.config.requestCount++;
|
|
1987
2027
|
if (!(this.config.requestCount > this.config.maxRequests)) {
|
|
1988
|
-
|
|
2028
|
+
_context18.n = 2;
|
|
1989
2029
|
break;
|
|
1990
2030
|
}
|
|
1991
2031
|
this.logSecurityEvent('API_REQUEST_LIMIT_EXCEEDED', {
|
|
@@ -2021,14 +2061,14 @@
|
|
|
2021
2061
|
maxRetries = this.config.maxRetries;
|
|
2022
2062
|
_loop = /*#__PURE__*/_regenerator().m(function _loop() {
|
|
2023
2063
|
var controller, timeoutId, headers, response, errorText, errorData, result, _t11;
|
|
2024
|
-
return _regenerator().w(function (
|
|
2025
|
-
while (1) switch (
|
|
2064
|
+
return _regenerator().w(function (_context17) {
|
|
2065
|
+
while (1) switch (_context17.p = _context17.n) {
|
|
2026
2066
|
case 0:
|
|
2027
|
-
|
|
2067
|
+
_context17.p = 0;
|
|
2028
2068
|
controller = new AbortController();
|
|
2029
2069
|
timeoutId = setTimeout(function () {
|
|
2030
2070
|
return controller.abort();
|
|
2031
|
-
},
|
|
2071
|
+
}, _this5.config.requestTimeout); // Headers minimaux (API SunuID n'accepte que les headers essentiels)
|
|
2032
2072
|
headers = {
|
|
2033
2073
|
'Content-Type': 'application/json'
|
|
2034
2074
|
}; // Note: En mode sécurisé, les credentials sont dans le body
|
|
@@ -2036,7 +2076,7 @@
|
|
|
2036
2076
|
// if (this.config.secureInit && this.config.token) {
|
|
2037
2077
|
// headers['X-Secure-Token'] = this.config.token;
|
|
2038
2078
|
// }
|
|
2039
|
-
|
|
2079
|
+
_context17.n = 1;
|
|
2040
2080
|
return fetch(url, {
|
|
2041
2081
|
method: 'POST',
|
|
2042
2082
|
headers: headers,
|
|
@@ -2044,16 +2084,16 @@
|
|
|
2044
2084
|
signal: controller.signal
|
|
2045
2085
|
});
|
|
2046
2086
|
case 1:
|
|
2047
|
-
response =
|
|
2087
|
+
response = _context17.v;
|
|
2048
2088
|
clearTimeout(timeoutId);
|
|
2049
2089
|
if (response.ok) {
|
|
2050
|
-
|
|
2090
|
+
_context17.n = 3;
|
|
2051
2091
|
break;
|
|
2052
2092
|
}
|
|
2053
|
-
|
|
2093
|
+
_context17.n = 2;
|
|
2054
2094
|
return response.text();
|
|
2055
2095
|
case 2:
|
|
2056
|
-
errorText =
|
|
2096
|
+
errorText = _context17.v;
|
|
2057
2097
|
try {
|
|
2058
2098
|
errorData = JSON.parse(errorText);
|
|
2059
2099
|
} catch (e) {
|
|
@@ -2061,88 +2101,88 @@
|
|
|
2061
2101
|
message: errorText
|
|
2062
2102
|
};
|
|
2063
2103
|
}
|
|
2064
|
-
|
|
2104
|
+
_this5.logSecurityEvent('API_REQUEST_ERROR', {
|
|
2065
2105
|
status: response.status,
|
|
2066
2106
|
statusText: response.statusText,
|
|
2067
2107
|
error: errorData.message
|
|
2068
2108
|
});
|
|
2069
2109
|
throw new Error(errorData.message || "Erreur HTTP: ".concat(response.status));
|
|
2070
2110
|
case 3:
|
|
2071
|
-
|
|
2111
|
+
_context17.n = 4;
|
|
2072
2112
|
return response.json();
|
|
2073
2113
|
case 4:
|
|
2074
|
-
result =
|
|
2075
|
-
|
|
2114
|
+
result = _context17.v;
|
|
2115
|
+
_this5.logSecurityEvent('API_REQUEST_SUCCESS', {
|
|
2076
2116
|
endpoint: endpointPath,
|
|
2077
2117
|
responseKeys: Object.keys(result)
|
|
2078
2118
|
});
|
|
2079
|
-
return
|
|
2119
|
+
return _context17.a(2, {
|
|
2080
2120
|
v: result
|
|
2081
2121
|
});
|
|
2082
2122
|
case 5:
|
|
2083
|
-
|
|
2084
|
-
_t11 =
|
|
2123
|
+
_context17.p = 5;
|
|
2124
|
+
_t11 = _context17.v;
|
|
2085
2125
|
retryCount++;
|
|
2086
2126
|
if (!(_t11.name === 'AbortError')) {
|
|
2087
|
-
|
|
2127
|
+
_context17.n = 7;
|
|
2088
2128
|
break;
|
|
2089
2129
|
}
|
|
2090
|
-
|
|
2130
|
+
_this5.logSecurityEvent('API_REQUEST_TIMEOUT', {
|
|
2091
2131
|
retryCount: retryCount
|
|
2092
2132
|
});
|
|
2093
2133
|
if (!(retryCount > maxRetries)) {
|
|
2094
|
-
|
|
2134
|
+
_context17.n = 6;
|
|
2095
2135
|
break;
|
|
2096
2136
|
}
|
|
2097
2137
|
throw new Error('Timeout de la requête API');
|
|
2098
2138
|
case 6:
|
|
2099
|
-
return
|
|
2139
|
+
return _context17.a(2, 0);
|
|
2100
2140
|
case 7:
|
|
2101
2141
|
if (!(retryCount > maxRetries)) {
|
|
2102
|
-
|
|
2142
|
+
_context17.n = 8;
|
|
2103
2143
|
break;
|
|
2104
2144
|
}
|
|
2105
|
-
|
|
2145
|
+
_this5.logSecurityEvent('API_REQUEST_MAX_RETRIES', {
|
|
2106
2146
|
retryCount: retryCount,
|
|
2107
2147
|
error: _t11.message
|
|
2108
2148
|
});
|
|
2109
2149
|
throw _t11;
|
|
2110
2150
|
case 8:
|
|
2111
|
-
|
|
2151
|
+
_context17.n = 9;
|
|
2112
2152
|
return new Promise(function (resolve) {
|
|
2113
2153
|
return setTimeout(resolve, 1000 * retryCount);
|
|
2114
2154
|
});
|
|
2115
2155
|
case 9:
|
|
2116
|
-
return
|
|
2156
|
+
return _context17.a(2);
|
|
2117
2157
|
}
|
|
2118
2158
|
}, _loop, null, [[0, 5]]);
|
|
2119
2159
|
});
|
|
2120
2160
|
case 3:
|
|
2121
2161
|
if (!(retryCount <= maxRetries)) {
|
|
2122
|
-
|
|
2162
|
+
_context18.n = 7;
|
|
2123
2163
|
break;
|
|
2124
2164
|
}
|
|
2125
|
-
return
|
|
2165
|
+
return _context18.d(_regeneratorValues(_loop()), 4);
|
|
2126
2166
|
case 4:
|
|
2127
|
-
_ret =
|
|
2167
|
+
_ret = _context18.v;
|
|
2128
2168
|
if (!(_ret === 0)) {
|
|
2129
|
-
|
|
2169
|
+
_context18.n = 5;
|
|
2130
2170
|
break;
|
|
2131
2171
|
}
|
|
2132
|
-
return
|
|
2172
|
+
return _context18.a(3, 3);
|
|
2133
2173
|
case 5:
|
|
2134
2174
|
if (!_ret) {
|
|
2135
|
-
|
|
2175
|
+
_context18.n = 6;
|
|
2136
2176
|
break;
|
|
2137
2177
|
}
|
|
2138
|
-
return
|
|
2178
|
+
return _context18.a(2, _ret.v);
|
|
2139
2179
|
case 6:
|
|
2140
|
-
|
|
2180
|
+
_context18.n = 3;
|
|
2141
2181
|
break;
|
|
2142
2182
|
case 7:
|
|
2143
|
-
return
|
|
2183
|
+
return _context18.a(2);
|
|
2144
2184
|
}
|
|
2145
|
-
},
|
|
2185
|
+
}, _callee17, this);
|
|
2146
2186
|
}));
|
|
2147
2187
|
function makeRequest(_x23, _x24) {
|
|
2148
2188
|
return _makeRequest.apply(this, arguments);
|
|
@@ -2213,20 +2253,20 @@
|
|
|
2213
2253
|
}, {
|
|
2214
2254
|
key: "fetchPartnerInfo",
|
|
2215
2255
|
value: (function () {
|
|
2216
|
-
var _fetchPartnerInfo = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
2256
|
+
var _fetchPartnerInfo = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18() {
|
|
2217
2257
|
var response, data, partnerId, _t12;
|
|
2218
|
-
return _regenerator().w(function (
|
|
2219
|
-
while (1) switch (
|
|
2258
|
+
return _regenerator().w(function (_context19) {
|
|
2259
|
+
while (1) switch (_context19.p = _context19.n) {
|
|
2220
2260
|
case 0:
|
|
2221
|
-
|
|
2222
|
-
|
|
2261
|
+
_context19.p = 0;
|
|
2262
|
+
_context19.n = 1;
|
|
2223
2263
|
return this.makeRequest('/debug', {
|
|
2224
2264
|
type: this.config.type,
|
|
2225
2265
|
client_id: this.config.clientId,
|
|
2226
2266
|
secret_id: this.config.secretId
|
|
2227
2267
|
});
|
|
2228
2268
|
case 1:
|
|
2229
|
-
response =
|
|
2269
|
+
response = _context19.v;
|
|
2230
2270
|
console.log('📋 Réponse debug API:', response);
|
|
2231
2271
|
|
|
2232
2272
|
// Vérifier la structure de la réponse
|
|
@@ -2270,17 +2310,17 @@
|
|
|
2270
2310
|
console.warn('⚠️ Structure de réponse invalide, utilisation du partner_id par défaut');
|
|
2271
2311
|
this.config.partnerName = "Partner_".concat(this.config.partnerId || 'unknown');
|
|
2272
2312
|
}
|
|
2273
|
-
|
|
2313
|
+
_context19.n = 3;
|
|
2274
2314
|
break;
|
|
2275
2315
|
case 2:
|
|
2276
|
-
|
|
2277
|
-
_t12 =
|
|
2316
|
+
_context19.p = 2;
|
|
2317
|
+
_t12 = _context19.v;
|
|
2278
2318
|
console.warn('⚠️ Erreur lors de la récupération des informations du partenaire:', _t12.message);
|
|
2279
2319
|
this.config.partnerName = 'Partner_unknown';
|
|
2280
2320
|
case 3:
|
|
2281
|
-
return
|
|
2321
|
+
return _context19.a(2);
|
|
2282
2322
|
}
|
|
2283
|
-
},
|
|
2323
|
+
}, _callee18, this, [[0, 2]]);
|
|
2284
2324
|
}));
|
|
2285
2325
|
function fetchPartnerInfo() {
|
|
2286
2326
|
return _fetchPartnerInfo.apply(this, arguments);
|
|
@@ -2318,18 +2358,18 @@
|
|
|
2318
2358
|
}, {
|
|
2319
2359
|
key: "checkConnections",
|
|
2320
2360
|
value: (function () {
|
|
2321
|
-
var _checkConnections = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
2361
|
+
var _checkConnections = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19() {
|
|
2322
2362
|
var status, testResponse, debugData, _t13;
|
|
2323
|
-
return _regenerator().w(function (
|
|
2324
|
-
while (1) switch (
|
|
2363
|
+
return _regenerator().w(function (_context20) {
|
|
2364
|
+
while (1) switch (_context20.p = _context20.n) {
|
|
2325
2365
|
case 0:
|
|
2326
2366
|
status = {
|
|
2327
2367
|
api: false,
|
|
2328
2368
|
websocket: false,
|
|
2329
2369
|
ready: false
|
|
2330
2370
|
}; // Vérifier l'API en utilisant l'endpoint debug avec les credentials
|
|
2331
|
-
|
|
2332
|
-
|
|
2371
|
+
_context20.p = 1;
|
|
2372
|
+
_context20.n = 2;
|
|
2333
2373
|
return fetch(this.config.apiUrl + '/debug', {
|
|
2334
2374
|
method: 'POST',
|
|
2335
2375
|
headers: {
|
|
@@ -2342,29 +2382,29 @@
|
|
|
2342
2382
|
})
|
|
2343
2383
|
});
|
|
2344
2384
|
case 2:
|
|
2345
|
-
testResponse =
|
|
2385
|
+
testResponse = _context20.v;
|
|
2346
2386
|
if (!testResponse.ok) {
|
|
2347
|
-
|
|
2387
|
+
_context20.n = 4;
|
|
2348
2388
|
break;
|
|
2349
2389
|
}
|
|
2350
|
-
|
|
2390
|
+
_context20.n = 3;
|
|
2351
2391
|
return testResponse.json();
|
|
2352
2392
|
case 3:
|
|
2353
|
-
debugData =
|
|
2393
|
+
debugData = _context20.v;
|
|
2354
2394
|
// L'API est accessible si on reçoit une réponse avec success: true
|
|
2355
2395
|
status.api = debugData.success === true;
|
|
2356
2396
|
console.log('🔍 API Status:', status.api ? 'accessible' : 'inaccessible');
|
|
2357
|
-
|
|
2397
|
+
_context20.n = 5;
|
|
2358
2398
|
break;
|
|
2359
2399
|
case 4:
|
|
2360
2400
|
status.api = false;
|
|
2361
2401
|
console.log('🔍 API Status: HTTP', testResponse.status);
|
|
2362
2402
|
case 5:
|
|
2363
|
-
|
|
2403
|
+
_context20.n = 7;
|
|
2364
2404
|
break;
|
|
2365
2405
|
case 6:
|
|
2366
|
-
|
|
2367
|
-
_t13 =
|
|
2406
|
+
_context20.p = 6;
|
|
2407
|
+
_t13 = _context20.v;
|
|
2368
2408
|
console.log('🔍 Test API échoué:', _t13.message);
|
|
2369
2409
|
status.api = false;
|
|
2370
2410
|
case 7:
|
|
@@ -2373,9 +2413,9 @@
|
|
|
2373
2413
|
|
|
2374
2414
|
// Connexions prêtes si API est accessible
|
|
2375
2415
|
status.ready = status.api;
|
|
2376
|
-
return
|
|
2416
|
+
return _context20.a(2, status);
|
|
2377
2417
|
}
|
|
2378
|
-
},
|
|
2418
|
+
}, _callee19, this, [[1, 6]]);
|
|
2379
2419
|
}));
|
|
2380
2420
|
function checkConnections() {
|
|
2381
2421
|
return _checkConnections.apply(this, arguments);
|
|
@@ -2389,46 +2429,46 @@
|
|
|
2389
2429
|
}, {
|
|
2390
2430
|
key: "waitForConnections",
|
|
2391
2431
|
value: (function () {
|
|
2392
|
-
var _waitForConnections = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
2432
|
+
var _waitForConnections = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee20() {
|
|
2393
2433
|
var timeout,
|
|
2394
2434
|
startTime,
|
|
2395
2435
|
status,
|
|
2396
|
-
|
|
2397
|
-
return _regenerator().w(function (
|
|
2398
|
-
while (1) switch (
|
|
2436
|
+
_args21 = arguments;
|
|
2437
|
+
return _regenerator().w(function (_context21) {
|
|
2438
|
+
while (1) switch (_context21.n) {
|
|
2399
2439
|
case 0:
|
|
2400
|
-
timeout =
|
|
2440
|
+
timeout = _args21.length > 0 && _args21[0] !== undefined ? _args21[0] : 5000;
|
|
2401
2441
|
startTime = Date.now();
|
|
2402
2442
|
case 1:
|
|
2403
2443
|
if (!(Date.now() - startTime < timeout)) {
|
|
2404
|
-
|
|
2444
|
+
_context21.n = 5;
|
|
2405
2445
|
break;
|
|
2406
2446
|
}
|
|
2407
|
-
|
|
2447
|
+
_context21.n = 2;
|
|
2408
2448
|
return this.checkConnections();
|
|
2409
2449
|
case 2:
|
|
2410
|
-
status =
|
|
2450
|
+
status = _context21.v;
|
|
2411
2451
|
if (!status.ready) {
|
|
2412
|
-
|
|
2452
|
+
_context21.n = 3;
|
|
2413
2453
|
break;
|
|
2414
2454
|
}
|
|
2415
2455
|
console.log('✅ Connexions prêtes');
|
|
2416
|
-
return
|
|
2456
|
+
return _context21.a(2, status);
|
|
2417
2457
|
case 3:
|
|
2418
2458
|
console.log('⏳ Attente connexions...', status);
|
|
2419
|
-
|
|
2459
|
+
_context21.n = 4;
|
|
2420
2460
|
return new Promise(function (resolve) {
|
|
2421
2461
|
return setTimeout(resolve, 1000);
|
|
2422
2462
|
});
|
|
2423
2463
|
case 4:
|
|
2424
|
-
|
|
2464
|
+
_context21.n = 1;
|
|
2425
2465
|
break;
|
|
2426
2466
|
case 5:
|
|
2427
2467
|
throw new Error('Timeout connexions - Impossible de générer le QR code');
|
|
2428
2468
|
case 6:
|
|
2429
|
-
return
|
|
2469
|
+
return _context21.a(2);
|
|
2430
2470
|
}
|
|
2431
|
-
},
|
|
2471
|
+
}, _callee20, this);
|
|
2432
2472
|
}));
|
|
2433
2473
|
function waitForConnections() {
|
|
2434
2474
|
return _waitForConnections.apply(this, arguments);
|