sunuid-sdk 1.0.33 → 1.0.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/sunuid-sdk.esm.js +984 -369
- package/dist/sunuid-sdk.esm.js.map +1 -1
- package/dist/sunuid-sdk.js +984 -369
- package/dist/sunuid-sdk.js.map +1 -1
- package/dist/sunuid-sdk.min.js +3 -3
- package/dist/sunuid-sdk.min.js.map +1 -1
- package/package.json +2 -2
package/dist/sunuid-sdk.js
CHANGED
|
@@ -283,13 +283,16 @@
|
|
|
283
283
|
secretId: null,
|
|
284
284
|
type: 2,
|
|
285
285
|
// Type par défaut (2 = authentification)
|
|
286
|
-
partnerName:
|
|
287
|
-
// Nom du partenaire
|
|
286
|
+
partnerName: null,
|
|
287
|
+
// Nom du partenaire récupéré depuis l'API
|
|
288
288
|
theme: 'light',
|
|
289
289
|
language: 'fr',
|
|
290
|
-
autoRefresh:
|
|
290
|
+
autoRefresh: false,
|
|
291
|
+
// Désactivé par défaut pour éviter les appels répétitifs
|
|
291
292
|
refreshInterval: 30000,
|
|
292
293
|
// 30 secondes
|
|
294
|
+
autoInit: true,
|
|
295
|
+
// Initialisation automatique par défaut
|
|
293
296
|
onSuccess: null,
|
|
294
297
|
onError: null,
|
|
295
298
|
onStatusUpdate: null,
|
|
@@ -308,7 +311,10 @@
|
|
|
308
311
|
}
|
|
309
312
|
return ((_window$SunuIDConfig3 = window.SunuIDConfig) === null || _window$SunuIDConfig3 === void 0 || (_window$SunuIDConfig3 = _window$SunuIDConfig3.apiUrl) === null || _window$SunuIDConfig3 === void 0 ? void 0 : _window$SunuIDConfig3.replace('/api', '')) + '/secure-init.php' || 'https://api.sunuid.fayma.sn/secure-init.php';
|
|
310
313
|
}(),
|
|
311
|
-
token: null
|
|
314
|
+
token: null,
|
|
315
|
+
// Configuration pour forcer l'utilisation du serveur distant
|
|
316
|
+
forceRemoteServer: true,
|
|
317
|
+
useLocalFallback: false
|
|
312
318
|
};
|
|
313
319
|
|
|
314
320
|
/**
|
|
@@ -324,8 +330,10 @@
|
|
|
324
330
|
this.isInitialized = false;
|
|
325
331
|
this.socket = null;
|
|
326
332
|
|
|
327
|
-
// Initialisation asynchrone
|
|
328
|
-
this.
|
|
333
|
+
// Initialisation asynchrone seulement si autoInit est activé
|
|
334
|
+
if (this.config.autoInit !== false) {
|
|
335
|
+
this.initPromise = this.init();
|
|
336
|
+
}
|
|
329
337
|
}
|
|
330
338
|
|
|
331
339
|
/**
|
|
@@ -359,31 +367,43 @@
|
|
|
359
367
|
this.logSecurityEvent('SDK_INIT_START', {
|
|
360
368
|
apiUrl: this.config.apiUrl,
|
|
361
369
|
type: this.config.type,
|
|
362
|
-
partnerName: this.config.partnerName,
|
|
363
370
|
secureInit: this.config.secureInit
|
|
364
371
|
});
|
|
365
372
|
|
|
373
|
+
// Récupérer les informations du partenaire depuis l'API
|
|
374
|
+
_context.n = 4;
|
|
375
|
+
return this.fetchPartnerInfo();
|
|
376
|
+
case 4:
|
|
366
377
|
// Obscurcir les credentials dans les logs
|
|
367
378
|
this.obfuscateCredentials();
|
|
368
379
|
this.isInitialized = true;
|
|
369
380
|
console.log('SunuID SDK initialisé avec succès');
|
|
381
|
+
console.log('📋 Configuration SDK:', {
|
|
382
|
+
apiUrl: this.config.apiUrl,
|
|
383
|
+
type: this.config.type,
|
|
384
|
+
partnerName: this.config.partnerName,
|
|
385
|
+
clientId: this.config.clientId ? '***' + this.config.clientId.slice(-4) : 'null',
|
|
386
|
+
secretId: this.config.secretId ? '***' + this.config.secretId.slice(-4) : 'null',
|
|
387
|
+
secureInit: this.config.secureInit,
|
|
388
|
+
theme: this.config.theme
|
|
389
|
+
});
|
|
370
390
|
this.logSecurityEvent('SDK_INIT_SUCCESS');
|
|
371
391
|
|
|
372
392
|
// Initialiser la connexion WebSocket
|
|
373
393
|
this.initWebSocket();
|
|
374
|
-
_context.n =
|
|
394
|
+
_context.n = 6;
|
|
375
395
|
break;
|
|
376
|
-
case
|
|
377
|
-
_context.p =
|
|
396
|
+
case 5:
|
|
397
|
+
_context.p = 5;
|
|
378
398
|
_t = _context.v;
|
|
379
399
|
this.logSecurityEvent('SDK_INIT_ERROR', {
|
|
380
400
|
error: _t.message
|
|
381
401
|
});
|
|
382
402
|
throw _t;
|
|
383
|
-
case
|
|
403
|
+
case 6:
|
|
384
404
|
return _context.a(2);
|
|
385
405
|
}
|
|
386
|
-
}, _callee, this, [[0,
|
|
406
|
+
}, _callee, this, [[0, 5]]);
|
|
387
407
|
}));
|
|
388
408
|
function init() {
|
|
389
409
|
return _init.apply(this, arguments);
|
|
@@ -430,6 +450,7 @@
|
|
|
430
450
|
return response.json();
|
|
431
451
|
case 3:
|
|
432
452
|
result = _context2.v;
|
|
453
|
+
console.log('📋 Réponse initialisation sécurisée:', result);
|
|
433
454
|
if (result.success) {
|
|
434
455
|
_context2.n = 4;
|
|
435
456
|
break;
|
|
@@ -537,25 +558,30 @@
|
|
|
537
558
|
|
|
538
559
|
// Initialiser la connexion WebSocket si elle n'existe pas
|
|
539
560
|
if (!this.socket) {
|
|
561
|
+
console.log('🌐 Initialisation Socket.IO...');
|
|
540
562
|
this.socket = io('wss://samasocket.fayma.sn:9443', {
|
|
541
563
|
query: {
|
|
542
564
|
token: this.config.clientId,
|
|
543
565
|
type: 'web',
|
|
544
566
|
userId: this.config.clientId,
|
|
545
567
|
username: ip
|
|
546
|
-
}
|
|
568
|
+
},
|
|
569
|
+
transports: ['websocket', 'polling']
|
|
547
570
|
});
|
|
548
571
|
|
|
549
572
|
// Gestion des événements WebSocket
|
|
550
573
|
this.socket.on('connect', function () {
|
|
551
574
|
console.log('🌐 WebSocket connecté avec succès');
|
|
552
575
|
console.log('📊 Socket ID:', _this.socket.id);
|
|
576
|
+
_this.socket.connected = true;
|
|
553
577
|
});
|
|
554
578
|
this.socket.on('disconnect', function (reason) {
|
|
555
579
|
console.log('❌ WebSocket déconnecté:', reason);
|
|
580
|
+
_this.socket.connected = false;
|
|
556
581
|
});
|
|
557
582
|
this.socket.on('connect_error', function (error) {
|
|
558
583
|
console.error('❌ Erreur connexion WebSocket:', error);
|
|
584
|
+
_this.socket.connected = false;
|
|
559
585
|
});
|
|
560
586
|
|
|
561
587
|
// Écouter les événements spécifiques
|
|
@@ -571,6 +597,21 @@
|
|
|
571
597
|
console.log('⏰ QR expiré reçu:', data);
|
|
572
598
|
_this.handleQRExpired(data);
|
|
573
599
|
});
|
|
600
|
+
|
|
601
|
+
// Écouter tous les événements socket pour les logger
|
|
602
|
+
this.socket.onAny(function (eventName) {
|
|
603
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
604
|
+
args[_key - 1] = arguments[_key];
|
|
605
|
+
}
|
|
606
|
+
console.log("\uD83C\uDF10 Socket Event [".concat(eventName, "]:"), args);
|
|
607
|
+
|
|
608
|
+
// Si c'est un événement qr_scan_initiated, afficher le loader
|
|
609
|
+
if (eventName === 'qr_scan_initiated') {
|
|
610
|
+
_this.showQRLoader();
|
|
611
|
+
}
|
|
612
|
+
});
|
|
613
|
+
} else {
|
|
614
|
+
console.log('🌐 WebSocket déjà connecté');
|
|
574
615
|
}
|
|
575
616
|
} catch (error) {
|
|
576
617
|
console.error('❌ Erreur initialisation WebSocket:', error);
|
|
@@ -722,6 +763,7 @@
|
|
|
722
763
|
}, {
|
|
723
764
|
key: "handleQRStatusUpdate",
|
|
724
765
|
value: function handleQRStatusUpdate(data) {
|
|
766
|
+
console.log('📱 QR Status Update:', data);
|
|
725
767
|
if (this.config.onStatusUpdate) {
|
|
726
768
|
this.config.onStatusUpdate(data);
|
|
727
769
|
}
|
|
@@ -733,6 +775,7 @@
|
|
|
733
775
|
}, {
|
|
734
776
|
key: "handleQRScanSuccess",
|
|
735
777
|
value: function handleQRScanSuccess(data) {
|
|
778
|
+
console.log('✅ QR Scan Success:', data);
|
|
736
779
|
if (this.config.onSuccess) {
|
|
737
780
|
this.config.onSuccess(data);
|
|
738
781
|
}
|
|
@@ -744,6 +787,7 @@
|
|
|
744
787
|
}, {
|
|
745
788
|
key: "handleQRExpired",
|
|
746
789
|
value: function handleQRExpired(data) {
|
|
790
|
+
console.log('⏰ QR Expired:', data);
|
|
747
791
|
if (this.config.onExpired) {
|
|
748
792
|
this.config.onExpired(data);
|
|
749
793
|
}
|
|
@@ -758,8 +802,6 @@
|
|
|
758
802
|
if (this.socket && this.socket.connected) {
|
|
759
803
|
this.socket.emit(event, data);
|
|
760
804
|
console.log("\uD83D\uDCE4 \xC9v\xE9nement WebSocket \xE9mis: ".concat(event), data);
|
|
761
|
-
} else if (typeof io === 'undefined') {
|
|
762
|
-
console.warn('⚠️ Socket.IO non disponible, impossible d\'émettre l\'événement:', event);
|
|
763
805
|
} else {
|
|
764
806
|
console.warn('⚠️ WebSocket non connecté, impossible d\'émettre l\'événement:', event);
|
|
765
807
|
}
|
|
@@ -795,18 +837,23 @@
|
|
|
795
837
|
}, {
|
|
796
838
|
key: "generateQR",
|
|
797
839
|
value: (function () {
|
|
798
|
-
var _generateQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(
|
|
799
|
-
var
|
|
800
|
-
|
|
840
|
+
var _generateQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
|
|
841
|
+
var containerId,
|
|
842
|
+
options,
|
|
843
|
+
connectionStatus,
|
|
844
|
+
socketId,
|
|
845
|
+
qrContent,
|
|
846
|
+
partnerName,
|
|
801
847
|
response,
|
|
802
|
-
imageBaseUrl,
|
|
803
848
|
qrImageUrl,
|
|
804
|
-
|
|
849
|
+
isLocal,
|
|
805
850
|
_args3 = arguments,
|
|
806
|
-
_t3
|
|
851
|
+
_t3,
|
|
852
|
+
_t4;
|
|
807
853
|
return _regenerator().w(function (_context3) {
|
|
808
854
|
while (1) switch (_context3.p = _context3.n) {
|
|
809
855
|
case 0:
|
|
856
|
+
containerId = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : 'sunuid-qr-container';
|
|
810
857
|
options = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {};
|
|
811
858
|
if (!this.initPromise) {
|
|
812
859
|
_context3.n = 2;
|
|
@@ -823,68 +870,88 @@
|
|
|
823
870
|
}
|
|
824
871
|
throw new Error('SunuID: SDK non initialisé');
|
|
825
872
|
case 3:
|
|
826
|
-
|
|
827
|
-
|
|
873
|
+
console.log('🎯 generateQR appelé avec containerId:', containerId);
|
|
874
|
+
|
|
875
|
+
// Attendre que les connexions soient prêtes
|
|
876
|
+
console.log('🔍 Attente connexions API et WebSocket...');
|
|
877
|
+
_context3.p = 4;
|
|
878
|
+
_context3.n = 5;
|
|
879
|
+
return this.waitForConnections(5000);
|
|
880
|
+
case 5:
|
|
881
|
+
connectionStatus = _context3.v;
|
|
882
|
+
// 5 secondes max
|
|
883
|
+
console.log('✅ Connexions prêtes:', connectionStatus);
|
|
884
|
+
_context3.n = 7;
|
|
885
|
+
break;
|
|
886
|
+
case 6:
|
|
887
|
+
_context3.p = 6;
|
|
888
|
+
_t3 = _context3.v;
|
|
889
|
+
console.error('❌ Erreur connexions:', _t3.message);
|
|
890
|
+
throw new Error('Connexions non disponibles - Impossible de générer le QR code');
|
|
891
|
+
case 7:
|
|
892
|
+
_context3.p = 7;
|
|
893
|
+
// Utiliser uniquement le socketID comme contenu du QR
|
|
894
|
+
socketId = this.socket ? this.socket.id : 'timeout-socket-id';
|
|
895
|
+
qrContent = socketId;
|
|
896
|
+
console.log('📄 Contenu QR préparé:', qrContent);
|
|
897
|
+
console.log('🔌 Socket ID:', socketId);
|
|
898
|
+
|
|
899
|
+
// Générer le QR avec le contenu complet
|
|
900
|
+
partnerName = this.config.partnerName || 'Partner_unknown';
|
|
901
|
+
_context3.n = 8;
|
|
828
902
|
return this.makeRequest('/qr-generate', _objectSpread2({
|
|
829
|
-
type: this.config.type
|
|
903
|
+
type: this.config.type,
|
|
904
|
+
content: qrContent,
|
|
905
|
+
// Contenu personnalisé pour le QR
|
|
906
|
+
label: "".concat(this.getTypeName(this.config.type), " ").concat(partnerName)
|
|
830
907
|
}, options));
|
|
831
|
-
case
|
|
908
|
+
case 8:
|
|
832
909
|
response = _context3.v;
|
|
833
910
|
if (!response.success) {
|
|
834
|
-
_context3.n =
|
|
911
|
+
_context3.n = 9;
|
|
835
912
|
break;
|
|
836
913
|
}
|
|
837
|
-
// Construire l'URL complète
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
this.displayQRCode(containerId, qrImageUrl, this.config.type, options);
|
|
842
|
-
|
|
843
|
-
// Générer le QR code personnalisé avec le type + code de l'API + socket ID
|
|
844
|
-
if (this.pendingQRInfo && response.data.code) {
|
|
845
|
-
// Attendre que le socket ID soit bien défini
|
|
846
|
-
_waitForSocketId = function waitForSocketId() {
|
|
847
|
-
if (_this2.socket && _this2.socket.id && _this2.socket.id !== 'unknown') {
|
|
848
|
-
var socketId = _this2.socket.id;
|
|
849
|
-
var qrContent = "".concat(_this2.config.type, "-").concat(response.data.code, "-").concat(socketId);
|
|
850
|
-
|
|
851
|
-
// Utiliser le partnerName de la réponse API et le nom du type
|
|
852
|
-
var partnerName = response.data.partnerName || _this2.config.partnerName || 'SunuID';
|
|
853
|
-
var typeName = _this2.getTypeName(_this2.config.type);
|
|
854
|
-
var qrLabel = "".concat(typeName, " - ").concat(partnerName);
|
|
855
|
-
_this2.generateCustomQRCode(qrContent, qrLabel, _this2.pendingQRInfo.options);
|
|
856
|
-
_this2.pendingQRInfo = null; // Nettoyer
|
|
857
|
-
} else {
|
|
858
|
-
// Réessayer après un délai si le socket ID n'est pas encore disponible
|
|
859
|
-
setTimeout(_waitForSocketId, 100);
|
|
860
|
-
}
|
|
861
|
-
};
|
|
862
|
-
_waitForSocketId();
|
|
914
|
+
// Construire l'URL complète du QR code
|
|
915
|
+
qrImageUrl = response.data.qrCodeUrl; // Si l'URL est relative, la rendre absolue
|
|
916
|
+
if (qrImageUrl.startsWith('/')) {
|
|
917
|
+
qrImageUrl = "".concat(this.config.apiUrl).concat(qrImageUrl);
|
|
863
918
|
}
|
|
919
|
+
this.currentQRUrl = qrImageUrl;
|
|
920
|
+
console.log('✅ QR code généré par API principale:', qrImageUrl);
|
|
921
|
+
console.log('📄 Contenu QR final:', qrContent);
|
|
922
|
+
console.log('🏷️ Label QR:', response.data.label);
|
|
923
|
+
console.log('🆔 Session ID:', response.data.sessionId);
|
|
924
|
+
|
|
925
|
+
// Afficher le QR code
|
|
926
|
+
this.displayQRCode(containerId, qrImageUrl, this.config.type, options);
|
|
864
927
|
this.startAutoRefresh(containerId, this.config.type, options);
|
|
865
928
|
|
|
866
929
|
// Émettre un événement WebSocket pour la génération du QR
|
|
867
930
|
this.emitWebSocketEvent('qr_generated', {
|
|
868
|
-
serviceId: response.data.service_id,
|
|
869
931
|
type: this.config.type,
|
|
870
932
|
qrCodeUrl: qrImageUrl,
|
|
871
|
-
|
|
933
|
+
socketId: socketId,
|
|
934
|
+
qrContent: qrContent,
|
|
935
|
+
label: response.data.label,
|
|
936
|
+
sessionId: response.data.sessionId,
|
|
872
937
|
timestamp: Date.now()
|
|
873
938
|
});
|
|
874
939
|
return _context3.a(2, _objectSpread2(_objectSpread2({}, response.data), {}, {
|
|
875
940
|
qrCodeUrl: qrImageUrl,
|
|
876
|
-
|
|
941
|
+
qrContent: qrContent,
|
|
942
|
+
label: response.data.label,
|
|
943
|
+
sessionId: response.data.sessionId
|
|
877
944
|
}));
|
|
878
|
-
case
|
|
945
|
+
case 9:
|
|
879
946
|
throw new Error(response.message || 'Erreur lors de la génération du QR code');
|
|
880
|
-
case
|
|
881
|
-
_context3.n =
|
|
947
|
+
case 10:
|
|
948
|
+
_context3.n = 12;
|
|
882
949
|
break;
|
|
883
|
-
case
|
|
884
|
-
_context3.p =
|
|
885
|
-
|
|
886
|
-
console.error('Erreur API détectée:',
|
|
887
|
-
console.error('Stack trace complet:',
|
|
950
|
+
case 11:
|
|
951
|
+
_context3.p = 11;
|
|
952
|
+
_t4 = _context3.v;
|
|
953
|
+
console.error('Erreur API détectée:', _t4.message);
|
|
954
|
+
console.error('Stack trace complet:', _t4.stack);
|
|
888
955
|
console.error('Configuration SDK:', {
|
|
889
956
|
apiUrl: this.config.apiUrl,
|
|
890
957
|
type: this.config.type,
|
|
@@ -892,15 +959,33 @@
|
|
|
892
959
|
clientId: this.config.clientId ? '***' + this.config.clientId.slice(-4) : 'null',
|
|
893
960
|
secretId: this.config.secretId ? '***' + this.config.secretId.slice(-4) : 'null'
|
|
894
961
|
});
|
|
962
|
+
|
|
963
|
+
// Fallback vers le service local seulement si activé
|
|
964
|
+
if (this.config.useLocalFallback) {
|
|
965
|
+
console.log('🔍 Vérification fallback local...');
|
|
966
|
+
console.log('🔍 Hostname:', window.location.hostname);
|
|
967
|
+
console.log('🔍 Protocol:', window.location.protocol);
|
|
968
|
+
console.log('🔍 URL complète:', window.location.href);
|
|
969
|
+
isLocal = window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1' || window.location.protocol === 'file:';
|
|
970
|
+
console.log('🔍 Est local:', isLocal);
|
|
971
|
+
if (isLocal) {
|
|
972
|
+
console.log('🔄 Tentative fallback vers service QR local...');
|
|
973
|
+
console.log('❌ Fallback local non implémenté - utilisation serveur distant uniquement');
|
|
974
|
+
} else {
|
|
975
|
+
console.log('❌ Pas en local, pas de fallback');
|
|
976
|
+
}
|
|
977
|
+
} else {
|
|
978
|
+
console.log('🔒 Fallback local désactivé, utilisation serveur distant uniquement');
|
|
979
|
+
}
|
|
895
980
|
console.log('Affichage du message "Service non disponible" pour type ' + this.config.type);
|
|
896
981
|
this.displayServiceUnavailable(containerId, this.config.type);
|
|
897
982
|
throw new Error('Service non disponible');
|
|
898
|
-
case
|
|
983
|
+
case 12:
|
|
899
984
|
return _context3.a(2);
|
|
900
985
|
}
|
|
901
|
-
}, _callee3, this, [[
|
|
986
|
+
}, _callee3, this, [[7, 11], [4, 6]]);
|
|
902
987
|
}));
|
|
903
|
-
function generateQR(
|
|
988
|
+
function generateQR() {
|
|
904
989
|
return _generateQR.apply(this, arguments);
|
|
905
990
|
}
|
|
906
991
|
return generateQR;
|
|
@@ -913,14 +998,12 @@
|
|
|
913
998
|
key: "generateCustomQR",
|
|
914
999
|
value: (function () {
|
|
915
1000
|
var _generateCustomQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(containerId, type) {
|
|
916
|
-
var _this3 = this;
|
|
917
1001
|
var options,
|
|
918
|
-
|
|
1002
|
+
response,
|
|
919
1003
|
imageBaseUrl,
|
|
920
1004
|
qrImageUrl,
|
|
921
|
-
_waitForSocketId2,
|
|
922
1005
|
_args4 = arguments,
|
|
923
|
-
|
|
1006
|
+
_t5;
|
|
924
1007
|
return _regenerator().w(function (_context4) {
|
|
925
1008
|
while (1) switch (_context4.p = _context4.n) {
|
|
926
1009
|
case 0:
|
|
@@ -946,52 +1029,35 @@
|
|
|
946
1029
|
type: type
|
|
947
1030
|
}, options));
|
|
948
1031
|
case 4:
|
|
949
|
-
|
|
950
|
-
if (!
|
|
1032
|
+
response = _context4.v;
|
|
1033
|
+
if (!response.success) {
|
|
951
1034
|
_context4.n = 5;
|
|
952
1035
|
break;
|
|
953
1036
|
}
|
|
954
1037
|
// Construire l'URL complète de l'image QR avec la base URL pour les images
|
|
955
1038
|
imageBaseUrl = 'https://sunuid.fayma.sn';
|
|
956
|
-
qrImageUrl = "".concat(imageBaseUrl).concat(
|
|
1039
|
+
qrImageUrl = "".concat(imageBaseUrl).concat(response.data.qrcode);
|
|
957
1040
|
this.displayQRCode(containerId, qrImageUrl, type, options);
|
|
958
1041
|
|
|
959
|
-
//
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
if (_this3.socket && _this3.socket.id && _this3.socket.id !== 'unknown') {
|
|
964
|
-
var socketId = _this3.socket.id;
|
|
965
|
-
var qrContent = "".concat(type, "-").concat(_response.data.code, "-").concat(socketId);
|
|
966
|
-
|
|
967
|
-
// Utiliser le partnerName de la réponse API et le nom du type
|
|
968
|
-
var partnerName = _response.data.partnerName || _this3.config.partnerName || 'SunuID';
|
|
969
|
-
var typeName = _this3.getTypeName(type);
|
|
970
|
-
var qrLabel = "".concat(typeName, " - ").concat(partnerName);
|
|
971
|
-
_this3.generateCustomQRCode(qrContent, qrLabel, _this3.pendingQRInfo.options);
|
|
972
|
-
_this3.pendingQRInfo = null; // Nettoyer
|
|
973
|
-
} else {
|
|
974
|
-
// Réessayer après un délai si le socket ID n'est pas encore disponible
|
|
975
|
-
setTimeout(_waitForSocketId2, 100);
|
|
976
|
-
}
|
|
977
|
-
};
|
|
978
|
-
_waitForSocketId2();
|
|
979
|
-
}
|
|
1042
|
+
// Le QR code est déjà généré par l'API principale
|
|
1043
|
+
console.log('✅ QR code personnalisé généré par API principale:', qrImageUrl);
|
|
1044
|
+
console.log('📄 Code de session:', response.data.code);
|
|
1045
|
+
console.log('🆔 Service ID:', response.data.service_id);
|
|
980
1046
|
this.startAutoRefresh(containerId, type, options);
|
|
981
|
-
return _context4.a(2, _objectSpread2(_objectSpread2({},
|
|
1047
|
+
return _context4.a(2, _objectSpread2(_objectSpread2({}, response.data), {}, {
|
|
982
1048
|
qrCodeUrl: qrImageUrl,
|
|
983
|
-
sessionId:
|
|
1049
|
+
sessionId: response.data.service_id
|
|
984
1050
|
}));
|
|
985
1051
|
case 5:
|
|
986
|
-
throw new Error(
|
|
1052
|
+
throw new Error(response.message || 'Erreur lors de la génération du QR code');
|
|
987
1053
|
case 6:
|
|
988
1054
|
_context4.n = 8;
|
|
989
1055
|
break;
|
|
990
1056
|
case 7:
|
|
991
1057
|
_context4.p = 7;
|
|
992
|
-
|
|
993
|
-
console.error('Erreur API détectée:',
|
|
994
|
-
console.error('Stack trace complet:',
|
|
1058
|
+
_t5 = _context4.v;
|
|
1059
|
+
console.error('Erreur API détectée:', _t5.message);
|
|
1060
|
+
console.error('Stack trace complet:', _t5.stack);
|
|
995
1061
|
console.error('Configuration SDK (Custom):', {
|
|
996
1062
|
apiUrl: this.config.apiUrl,
|
|
997
1063
|
type: type,
|
|
@@ -1007,7 +1073,7 @@
|
|
|
1007
1073
|
}
|
|
1008
1074
|
}, _callee4, this, [[3, 7]]);
|
|
1009
1075
|
}));
|
|
1010
|
-
function generateCustomQR(
|
|
1076
|
+
function generateCustomQR(_x, _x2) {
|
|
1011
1077
|
return _generateCustomQR.apply(this, arguments);
|
|
1012
1078
|
}
|
|
1013
1079
|
return generateCustomQR;
|
|
@@ -1027,7 +1093,7 @@
|
|
|
1027
1093
|
}
|
|
1028
1094
|
}, _callee5, this);
|
|
1029
1095
|
}));
|
|
1030
|
-
function generateAuthQR(
|
|
1096
|
+
function generateAuthQR(_x3) {
|
|
1031
1097
|
return _generateAuthQR.apply(this, arguments);
|
|
1032
1098
|
}
|
|
1033
1099
|
return generateAuthQR;
|
|
@@ -1061,7 +1127,7 @@
|
|
|
1061
1127
|
}
|
|
1062
1128
|
}, _callee6, this, [[1,, 3, 4]]);
|
|
1063
1129
|
}));
|
|
1064
|
-
function generateKYCQR(
|
|
1130
|
+
function generateKYCQR(_x4) {
|
|
1065
1131
|
return _generateKYCQR.apply(this, arguments);
|
|
1066
1132
|
}
|
|
1067
1133
|
return generateKYCQR;
|
|
@@ -1095,7 +1161,7 @@
|
|
|
1095
1161
|
}
|
|
1096
1162
|
}, _callee7, this, [[1,, 3, 4]]);
|
|
1097
1163
|
}));
|
|
1098
|
-
function generateSignatureQR(
|
|
1164
|
+
function generateSignatureQR(_x5) {
|
|
1099
1165
|
return _generateSignatureQR.apply(this, arguments);
|
|
1100
1166
|
}
|
|
1101
1167
|
return generateSignatureQR;
|
|
@@ -1107,7 +1173,7 @@
|
|
|
1107
1173
|
key: "checkQRStatus",
|
|
1108
1174
|
value: (function () {
|
|
1109
1175
|
var _checkQRStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(sessionId) {
|
|
1110
|
-
var
|
|
1176
|
+
var response, _t6;
|
|
1111
1177
|
return _regenerator().w(function (_context8) {
|
|
1112
1178
|
while (1) switch (_context8.p = _context8.n) {
|
|
1113
1179
|
case 0:
|
|
@@ -1123,36 +1189,225 @@
|
|
|
1123
1189
|
serviceId: sessionId
|
|
1124
1190
|
});
|
|
1125
1191
|
case 2:
|
|
1126
|
-
|
|
1127
|
-
if (!
|
|
1192
|
+
response = _context8.v;
|
|
1193
|
+
if (!response.success) {
|
|
1128
1194
|
_context8.n = 3;
|
|
1129
1195
|
break;
|
|
1130
1196
|
}
|
|
1131
|
-
return _context8.a(2,
|
|
1197
|
+
return _context8.a(2, response.data);
|
|
1132
1198
|
case 3:
|
|
1133
|
-
throw new Error(
|
|
1199
|
+
throw new Error(response.message || 'Erreur lors de la vérification du statut');
|
|
1134
1200
|
case 4:
|
|
1135
1201
|
_context8.n = 6;
|
|
1136
1202
|
break;
|
|
1137
1203
|
case 5:
|
|
1138
1204
|
_context8.p = 5;
|
|
1139
|
-
|
|
1140
|
-
this.handleError(
|
|
1141
|
-
throw
|
|
1205
|
+
_t6 = _context8.v;
|
|
1206
|
+
this.handleError(_t6);
|
|
1207
|
+
throw _t6;
|
|
1142
1208
|
case 6:
|
|
1143
1209
|
return _context8.a(2);
|
|
1144
1210
|
}
|
|
1145
1211
|
}, _callee8, this, [[1, 5]]);
|
|
1146
1212
|
}));
|
|
1147
|
-
function checkQRStatus(
|
|
1213
|
+
function checkQRStatus(_x6) {
|
|
1148
1214
|
return _checkQRStatus.apply(this, arguments);
|
|
1149
1215
|
}
|
|
1150
1216
|
return checkQRStatus;
|
|
1151
1217
|
}()
|
|
1152
1218
|
/**
|
|
1153
|
-
*
|
|
1219
|
+
* Générer un QR code avec un contenu spécifique
|
|
1220
|
+
*/
|
|
1221
|
+
)
|
|
1222
|
+
}, {
|
|
1223
|
+
key: "generateQRWithContent",
|
|
1224
|
+
value: (function () {
|
|
1225
|
+
var _generateQRWithContent = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(content, containerId, type) {
|
|
1226
|
+
var options,
|
|
1227
|
+
localQRUrl,
|
|
1228
|
+
_args9 = arguments,
|
|
1229
|
+
_t7;
|
|
1230
|
+
return _regenerator().w(function (_context9) {
|
|
1231
|
+
while (1) switch (_context9.p = _context9.n) {
|
|
1232
|
+
case 0:
|
|
1233
|
+
options = _args9.length > 3 && _args9[3] !== undefined ? _args9[3] : {};
|
|
1234
|
+
console.log('🎨 Génération QR avec contenu:', content);
|
|
1235
|
+
_context9.p = 1;
|
|
1236
|
+
if (!(window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1' || window.location.protocol === 'file:')) {
|
|
1237
|
+
_context9.n = 3;
|
|
1238
|
+
break;
|
|
1239
|
+
}
|
|
1240
|
+
console.log('🏠 Utilisation service QR local...');
|
|
1241
|
+
_context9.n = 2;
|
|
1242
|
+
return this.generateQRLocal(content, containerId, type, options);
|
|
1243
|
+
case 2:
|
|
1244
|
+
localQRUrl = _context9.v;
|
|
1245
|
+
if (!localQRUrl) {
|
|
1246
|
+
_context9.n = 3;
|
|
1247
|
+
break;
|
|
1248
|
+
}
|
|
1249
|
+
return _context9.a(2, localQRUrl);
|
|
1250
|
+
case 3:
|
|
1251
|
+
// Fallback vers le service QR distant
|
|
1252
|
+
console.log('🌐 Utilisation service QR distant...');
|
|
1253
|
+
_context9.n = 4;
|
|
1254
|
+
return this.generateQRRemote(content, containerId, type, options);
|
|
1255
|
+
case 4:
|
|
1256
|
+
return _context9.a(2, _context9.v);
|
|
1257
|
+
case 5:
|
|
1258
|
+
_context9.p = 5;
|
|
1259
|
+
_t7 = _context9.v;
|
|
1260
|
+
console.error('❌ Erreur génération QR:', _t7);
|
|
1261
|
+
// Fallback vers affichage simple du contenu
|
|
1262
|
+
this.displayQRContent(containerId, content, type, options);
|
|
1263
|
+
return _context9.a(2, null);
|
|
1264
|
+
}
|
|
1265
|
+
}, _callee9, this, [[1, 5]]);
|
|
1266
|
+
}));
|
|
1267
|
+
function generateQRWithContent(_x7, _x8, _x9) {
|
|
1268
|
+
return _generateQRWithContent.apply(this, arguments);
|
|
1269
|
+
}
|
|
1270
|
+
return generateQRWithContent;
|
|
1271
|
+
}()
|
|
1272
|
+
/**
|
|
1273
|
+
* Générer QR code avec service local
|
|
1274
|
+
*/
|
|
1275
|
+
)
|
|
1276
|
+
}, {
|
|
1277
|
+
key: "generateQRLocal",
|
|
1278
|
+
value: (function () {
|
|
1279
|
+
var _generateQRLocal = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(content, containerId, type) {
|
|
1280
|
+
var options,
|
|
1281
|
+
response,
|
|
1282
|
+
data,
|
|
1283
|
+
qrUrl,
|
|
1284
|
+
_args0 = arguments,
|
|
1285
|
+
_t8;
|
|
1286
|
+
return _regenerator().w(function (_context0) {
|
|
1287
|
+
while (1) switch (_context0.p = _context0.n) {
|
|
1288
|
+
case 0:
|
|
1289
|
+
options = _args0.length > 3 && _args0[3] !== undefined ? _args0[3] : {};
|
|
1290
|
+
_context0.p = 1;
|
|
1291
|
+
_context0.n = 2;
|
|
1292
|
+
return fetch('http://localhost:8000/api/generate/text', {
|
|
1293
|
+
method: 'POST',
|
|
1294
|
+
headers: {
|
|
1295
|
+
'Content-Type': 'application/x-www-form-urlencoded'
|
|
1296
|
+
},
|
|
1297
|
+
body: "text=".concat(encodeURIComponent(content), "&size=300")
|
|
1298
|
+
});
|
|
1299
|
+
case 2:
|
|
1300
|
+
response = _context0.v;
|
|
1301
|
+
if (!response.ok) {
|
|
1302
|
+
_context0.n = 4;
|
|
1303
|
+
break;
|
|
1304
|
+
}
|
|
1305
|
+
_context0.n = 3;
|
|
1306
|
+
return response.json();
|
|
1307
|
+
case 3:
|
|
1308
|
+
data = _context0.v;
|
|
1309
|
+
qrUrl = "data:image/png;base64,".concat(data.qrcode);
|
|
1310
|
+
this.displayQRCode(containerId, qrUrl, type, options);
|
|
1311
|
+
return _context0.a(2, qrUrl);
|
|
1312
|
+
case 4:
|
|
1313
|
+
_context0.n = 6;
|
|
1314
|
+
break;
|
|
1315
|
+
case 5:
|
|
1316
|
+
_context0.p = 5;
|
|
1317
|
+
_t8 = _context0.v;
|
|
1318
|
+
console.log('❌ Service QR local non disponible:', _t8.message);
|
|
1319
|
+
case 6:
|
|
1320
|
+
return _context0.a(2, null);
|
|
1321
|
+
}
|
|
1322
|
+
}, _callee0, this, [[1, 5]]);
|
|
1323
|
+
}));
|
|
1324
|
+
function generateQRLocal(_x0, _x1, _x10) {
|
|
1325
|
+
return _generateQRLocal.apply(this, arguments);
|
|
1326
|
+
}
|
|
1327
|
+
return generateQRLocal;
|
|
1328
|
+
}()
|
|
1329
|
+
/**
|
|
1330
|
+
* Générer QR code avec service distant
|
|
1331
|
+
*/
|
|
1332
|
+
)
|
|
1333
|
+
}, {
|
|
1334
|
+
key: "generateQRRemote",
|
|
1335
|
+
value: (function () {
|
|
1336
|
+
var _generateQRRemote = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(content, containerId, type) {
|
|
1337
|
+
var options,
|
|
1338
|
+
response,
|
|
1339
|
+
data,
|
|
1340
|
+
qrUrl,
|
|
1341
|
+
_args1 = arguments,
|
|
1342
|
+
_t9;
|
|
1343
|
+
return _regenerator().w(function (_context1) {
|
|
1344
|
+
while (1) switch (_context1.p = _context1.n) {
|
|
1345
|
+
case 0:
|
|
1346
|
+
options = _args1.length > 3 && _args1[3] !== undefined ? _args1[3] : {};
|
|
1347
|
+
_context1.p = 1;
|
|
1348
|
+
_context1.n = 2;
|
|
1349
|
+
return fetch('https://api.sunuid.fayma.sn/qr-generate', {
|
|
1350
|
+
method: 'POST',
|
|
1351
|
+
headers: {
|
|
1352
|
+
'Content-Type': 'application/json'
|
|
1353
|
+
},
|
|
1354
|
+
body: JSON.stringify({
|
|
1355
|
+
text: content,
|
|
1356
|
+
size: 300,
|
|
1357
|
+
type: type
|
|
1358
|
+
})
|
|
1359
|
+
});
|
|
1360
|
+
case 2:
|
|
1361
|
+
response = _context1.v;
|
|
1362
|
+
if (!response.ok) {
|
|
1363
|
+
_context1.n = 4;
|
|
1364
|
+
break;
|
|
1365
|
+
}
|
|
1366
|
+
_context1.n = 3;
|
|
1367
|
+
return response.json();
|
|
1368
|
+
case 3:
|
|
1369
|
+
data = _context1.v;
|
|
1370
|
+
qrUrl = "data:image/png;base64,".concat(data.qrcode);
|
|
1371
|
+
this.displayQRCode(containerId, qrUrl, type, options);
|
|
1372
|
+
return _context1.a(2, qrUrl);
|
|
1373
|
+
case 4:
|
|
1374
|
+
_context1.n = 6;
|
|
1375
|
+
break;
|
|
1376
|
+
case 5:
|
|
1377
|
+
_context1.p = 5;
|
|
1378
|
+
_t9 = _context1.v;
|
|
1379
|
+
console.error('❌ Erreur service QR distant:', _t9);
|
|
1380
|
+
case 6:
|
|
1381
|
+
// Fallback vers affichage du contenu
|
|
1382
|
+
this.displayQRContent(containerId, content, type, options);
|
|
1383
|
+
return _context1.a(2, null);
|
|
1384
|
+
}
|
|
1385
|
+
}, _callee1, this, [[1, 5]]);
|
|
1386
|
+
}));
|
|
1387
|
+
function generateQRRemote(_x11, _x12, _x13) {
|
|
1388
|
+
return _generateQRRemote.apply(this, arguments);
|
|
1389
|
+
}
|
|
1390
|
+
return generateQRRemote;
|
|
1391
|
+
}()
|
|
1392
|
+
/**
|
|
1393
|
+
* Afficher le contenu QR en texte (fallback)
|
|
1154
1394
|
*/
|
|
1155
1395
|
)
|
|
1396
|
+
}, {
|
|
1397
|
+
key: "displayQRContent",
|
|
1398
|
+
value: function displayQRContent(containerId, content, type) {
|
|
1399
|
+
var container = document.getElementById(containerId);
|
|
1400
|
+
if (!container) {
|
|
1401
|
+
throw new Error("Conteneur avec l'ID \"".concat(containerId, "\" non trouv\xE9"));
|
|
1402
|
+
}
|
|
1403
|
+
var typeName = this.getTypeName(type);
|
|
1404
|
+
container.innerHTML = "\n <div class=\"sunuid-qr-code\">\n <div class=\"sunuid-qr-header\">\n <h3>".concat(typeName, "</h3>\n </div>\n <div class=\"sunuid-qr-content\" style=\"text-align: center; padding: 20px; background: #f8f9fa; border: 1px solid #dee2e6; border-radius: 5px; margin: 10px 0;\">\n <p><strong>Contenu QR Code:</strong></p>\n <p style=\"font-family: monospace; font-size: 14px; word-break: break-all;\">").concat(content, "</p>\n </div>\n <div class=\"sunuid-qr-instructions\">\n <p>Contenu QR g\xE9n\xE9r\xE9 avec le format: {type}-{code}-{socketid}</p>\n </div>\n </div>\n ");
|
|
1405
|
+
console.log('✅ Contenu QR affiché:', content);
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
/**
|
|
1409
|
+
* Afficher un QR code dans un conteneur
|
|
1410
|
+
*/
|
|
1156
1411
|
}, {
|
|
1157
1412
|
key: "displayQRCode",
|
|
1158
1413
|
value: function displayQRCode(containerId, qrUrl, type) {
|
|
@@ -1169,20 +1424,14 @@
|
|
|
1169
1424
|
var qrElement = document.createElement('div');
|
|
1170
1425
|
qrElement.className = 'sunuid-qr-code';
|
|
1171
1426
|
|
|
1172
|
-
// Afficher
|
|
1173
|
-
this.getTypeName(type);
|
|
1174
|
-
qrElement.innerHTML = "\n <div class=\"sunuid-qr-header\">\n <h3>".concat(type === 1 ? 'Vérification KYC' : type === 2 ? 'Authentification' : type === 3 ? 'Signature' : 'Service Type ' + type, "</h3>\n </div>\n <div class=\"sunuid-qr-image\"
|
|
1427
|
+
// Afficher l'image QR avec les informations
|
|
1428
|
+
var typeName = this.getTypeName(type);
|
|
1429
|
+
qrElement.innerHTML = "\n <div class=\"sunuid-qr-header\">\n <h3>".concat(type === 1 ? 'Vérification KYC' : type === 2 ? 'Authentification' : type === 3 ? 'Signature' : 'Service Type ' + type, "</h3>\n </div>\n <div class=\"sunuid-qr-image\">\n <img src=\"").concat(qrUrl, "\" alt=\"QR Code ").concat(typeName, "\" style=\"max-width: 300px; border: 1px solid #ddd; border-radius: 5px;\" />\n </div>\n \n ");
|
|
1175
1430
|
container.appendChild(qrElement);
|
|
1176
1431
|
|
|
1177
|
-
// Stocker les informations pour la génération ultérieure
|
|
1178
|
-
this.pendingQRInfo = {
|
|
1179
|
-
containerId: containerId,
|
|
1180
|
-
type: type,
|
|
1181
|
-
options: options
|
|
1182
|
-
};
|
|
1183
|
-
|
|
1184
1432
|
// Appliquer le thème
|
|
1185
1433
|
this.applyTheme(options.theme || this.config.theme);
|
|
1434
|
+
console.log('✅ QR code affiché:', qrUrl);
|
|
1186
1435
|
}
|
|
1187
1436
|
|
|
1188
1437
|
/**
|
|
@@ -1191,199 +1440,306 @@
|
|
|
1191
1440
|
}, {
|
|
1192
1441
|
key: "generateCustomQRCode",
|
|
1193
1442
|
value: (function () {
|
|
1194
|
-
var _generateCustomQRCode = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1195
|
-
var
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
instructionsElement,
|
|
1200
|
-
statusElement,
|
|
1201
|
-
_t6;
|
|
1202
|
-
return _regenerator().w(function (_context9) {
|
|
1203
|
-
while (1) switch (_context9.p = _context9.n) {
|
|
1443
|
+
var _generateCustomQRCode = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(content, label) {
|
|
1444
|
+
var qrContainer,
|
|
1445
|
+
_t0;
|
|
1446
|
+
return _regenerator().w(function (_context10) {
|
|
1447
|
+
while (1) switch (_context10.p = _context10.n) {
|
|
1204
1448
|
case 0:
|
|
1205
|
-
|
|
1206
|
-
console.log('🎨 Début génération QR personnalisé avec PHP...');
|
|
1449
|
+
console.log('🎨 Début génération QR personnalisé...');
|
|
1207
1450
|
console.log('📄 Contenu:', content);
|
|
1208
1451
|
console.log('🏷️ Label:', label);
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1452
|
+
|
|
1453
|
+
// Chercher le conteneur QR
|
|
1454
|
+
qrContainer = document.getElementById('sunuid-qr-container');
|
|
1455
|
+
if (!qrContainer) {
|
|
1456
|
+
qrContainer = document.getElementById('qr-container');
|
|
1457
|
+
}
|
|
1458
|
+
if (qrContainer) {
|
|
1459
|
+
_context10.n = 1;
|
|
1212
1460
|
break;
|
|
1213
1461
|
}
|
|
1214
1462
|
console.error('❌ QR container not found');
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
case 2:
|
|
1463
|
+
return _context10.a(2);
|
|
1464
|
+
case 1:
|
|
1218
1465
|
console.log('✅ QR container trouvé');
|
|
1219
1466
|
|
|
1220
1467
|
// Nettoyer le conteneur
|
|
1221
|
-
|
|
1468
|
+
qrContainer.innerHTML = '<div style="text-align: center; padding: 20px;"><p>Génération QR code...</p></div>';
|
|
1469
|
+
_context10.p = 2;
|
|
1470
|
+
// Utiliser directement l'API principale (plus fiable)
|
|
1471
|
+
console.log('🎨 Tentative génération via API principale...');
|
|
1472
|
+
_context10.n = 3;
|
|
1473
|
+
return this.generateQRPHP(content, label, qrContainer);
|
|
1474
|
+
case 3:
|
|
1475
|
+
console.log('✅ QR code généré avec succès');
|
|
1476
|
+
_context10.n = 5;
|
|
1477
|
+
break;
|
|
1478
|
+
case 4:
|
|
1479
|
+
_context10.p = 4;
|
|
1480
|
+
_t0 = _context10.v;
|
|
1481
|
+
console.error('❌ Erreur génération API:', _t0);
|
|
1222
1482
|
|
|
1223
|
-
//
|
|
1224
|
-
console.log('
|
|
1225
|
-
|
|
1483
|
+
// Fallback final : image par défaut
|
|
1484
|
+
console.log('⚠️ Affichage image par défaut');
|
|
1485
|
+
this.displayDefaultQR(qrContainer, content, label);
|
|
1486
|
+
case 5:
|
|
1487
|
+
return _context10.a(2);
|
|
1488
|
+
}
|
|
1489
|
+
}, _callee10, this, [[2, 4]]);
|
|
1490
|
+
}));
|
|
1491
|
+
function generateCustomQRCode(_x14, _x15) {
|
|
1492
|
+
return _generateCustomQRCode.apply(this, arguments);
|
|
1493
|
+
}
|
|
1494
|
+
return generateCustomQRCode;
|
|
1495
|
+
}()
|
|
1496
|
+
/**
|
|
1497
|
+
* Générer un QR code côté client (méthode principale)
|
|
1498
|
+
*/
|
|
1499
|
+
)
|
|
1500
|
+
}, {
|
|
1501
|
+
key: "generateQRClientSide",
|
|
1502
|
+
value: (function () {
|
|
1503
|
+
var _generateQRClientSide = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11(content, label, qrContainer) {
|
|
1504
|
+
var _this2 = this;
|
|
1505
|
+
var canvas, ctx;
|
|
1506
|
+
return _regenerator().w(function (_context11) {
|
|
1507
|
+
while (1) switch (_context11.n) {
|
|
1508
|
+
case 0:
|
|
1509
|
+
_context11.n = 1;
|
|
1510
|
+
return this.ensureQRCodeLibrary();
|
|
1511
|
+
case 1:
|
|
1512
|
+
if (!(typeof QRCode === 'undefined')) {
|
|
1513
|
+
_context11.n = 2;
|
|
1514
|
+
break;
|
|
1515
|
+
}
|
|
1516
|
+
throw new Error('QRCode library non disponible');
|
|
1517
|
+
case 2:
|
|
1518
|
+
// Créer un canvas
|
|
1519
|
+
canvas = document.createElement('canvas');
|
|
1520
|
+
canvas.width = 300;
|
|
1521
|
+
canvas.height = 320;
|
|
1522
|
+
ctx = canvas.getContext('2d'); // Fond blanc
|
|
1523
|
+
ctx.fillStyle = '#FFFFFF';
|
|
1524
|
+
ctx.fillRect(0, 0, 300, 320);
|
|
1525
|
+
|
|
1526
|
+
// Générer le QR code
|
|
1527
|
+
return _context11.a(2, new Promise(function (resolve, reject) {
|
|
1528
|
+
QRCode.toCanvas(canvas, content, {
|
|
1529
|
+
width: 280,
|
|
1530
|
+
margin: 10,
|
|
1531
|
+
color: {
|
|
1532
|
+
dark: '#000000',
|
|
1533
|
+
light: '#FFFFFF'
|
|
1534
|
+
}
|
|
1535
|
+
}, function (error) {
|
|
1536
|
+
if (error) {
|
|
1537
|
+
reject(error);
|
|
1538
|
+
return;
|
|
1539
|
+
}
|
|
1226
1540
|
|
|
1227
|
-
|
|
1228
|
-
|
|
1541
|
+
// Ajouter le label
|
|
1542
|
+
ctx.fillStyle = '#333333';
|
|
1543
|
+
ctx.font = 'bold 14px Arial';
|
|
1544
|
+
ctx.textAlign = 'center';
|
|
1545
|
+
ctx.fillText(label, 150, 305);
|
|
1546
|
+
|
|
1547
|
+
// Convertir en data URL
|
|
1548
|
+
var dataUrl = canvas.toDataURL('image/png');
|
|
1549
|
+
|
|
1550
|
+
// Stocker l'URL
|
|
1551
|
+
_this2.currentQRUrl = dataUrl;
|
|
1552
|
+
|
|
1553
|
+
// Afficher le QR code
|
|
1554
|
+
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 ");
|
|
1555
|
+
|
|
1556
|
+
// Afficher les instructions
|
|
1557
|
+
_this2.showQRInstructions(qrContainer);
|
|
1558
|
+
resolve();
|
|
1559
|
+
});
|
|
1560
|
+
}));
|
|
1561
|
+
}
|
|
1562
|
+
}, _callee11, this);
|
|
1563
|
+
}));
|
|
1564
|
+
function generateQRClientSide(_x16, _x17, _x18) {
|
|
1565
|
+
return _generateQRClientSide.apply(this, arguments);
|
|
1566
|
+
}
|
|
1567
|
+
return generateQRClientSide;
|
|
1568
|
+
}()
|
|
1569
|
+
/**
|
|
1570
|
+
* Générer un QR code via endpoint PHP (fallback)
|
|
1571
|
+
*/
|
|
1572
|
+
)
|
|
1573
|
+
}, {
|
|
1574
|
+
key: "generateQRPHP",
|
|
1575
|
+
value: (function () {
|
|
1576
|
+
var _generateQRPHP = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12(content, label, qrContainer) {
|
|
1577
|
+
var qrGeneratorUrl, requestBody, contentType, response, responseData, qrImageUrl, imageBaseUrl;
|
|
1578
|
+
return _regenerator().w(function (_context12) {
|
|
1579
|
+
while (1) switch (_context12.n) {
|
|
1580
|
+
case 0:
|
|
1581
|
+
// Construire l'URL - Utiliser l'API principale qui fonctionne
|
|
1582
|
+
|
|
1583
|
+
if (this.config.forceRemoteServer) {
|
|
1584
|
+
qrGeneratorUrl = 'https://api.sunuid.fayma.sn/qr-generate';
|
|
1585
|
+
} else if (this.config.apiUrl.includes('api.sunuid.fayma.sn')) {
|
|
1586
|
+
qrGeneratorUrl = 'https://api.sunuid.fayma.sn/qr-generate';
|
|
1587
|
+
} else if (this.config.apiUrl.includes('localhost') || this.config.apiUrl.includes('127.0.0.1')) {
|
|
1588
|
+
qrGeneratorUrl = 'http://localhost:8000/api/generate/text';
|
|
1229
1589
|
} else {
|
|
1230
|
-
qrGeneratorUrl = this.config.apiUrl
|
|
1590
|
+
qrGeneratorUrl = this.config.apiUrl + '/qr-generate';
|
|
1231
1591
|
}
|
|
1232
1592
|
console.log('🔗 URL QR Generator:', qrGeneratorUrl);
|
|
1233
|
-
|
|
1593
|
+
|
|
1594
|
+
// Adapter le format selon l'URL
|
|
1595
|
+
|
|
1596
|
+
if (qrGeneratorUrl.includes('localhost:8000')) {
|
|
1597
|
+
// Service local - format form-data
|
|
1598
|
+
contentType = 'application/x-www-form-urlencoded';
|
|
1599
|
+
requestBody = new URLSearchParams({
|
|
1600
|
+
text: content,
|
|
1601
|
+
size: 300,
|
|
1602
|
+
margin: 10,
|
|
1603
|
+
foreground_color: '000000',
|
|
1604
|
+
background_color: 'FFFFFF'
|
|
1605
|
+
});
|
|
1606
|
+
} else {
|
|
1607
|
+
// Service distant - format JSON avec les paramètres de l'API principale
|
|
1608
|
+
contentType = 'application/json';
|
|
1609
|
+
requestBody = JSON.stringify({
|
|
1610
|
+
type: this.config.type,
|
|
1611
|
+
client_id: this.config.clientId,
|
|
1612
|
+
secret_id: this.config.secretId,
|
|
1613
|
+
content: content,
|
|
1614
|
+
label: label
|
|
1615
|
+
});
|
|
1616
|
+
}
|
|
1617
|
+
_context12.n = 1;
|
|
1234
1618
|
return fetch(qrGeneratorUrl, {
|
|
1235
1619
|
method: 'POST',
|
|
1236
1620
|
headers: {
|
|
1237
|
-
'Content-Type':
|
|
1621
|
+
'Content-Type': contentType,
|
|
1238
1622
|
'Accept': 'application/json'
|
|
1239
1623
|
},
|
|
1240
|
-
body:
|
|
1241
|
-
content: content,
|
|
1242
|
-
label: label,
|
|
1243
|
-
size: 300,
|
|
1244
|
-
margin: 10
|
|
1245
|
-
})
|
|
1624
|
+
body: requestBody
|
|
1246
1625
|
});
|
|
1247
|
-
case
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
_context9.n = 4;
|
|
1626
|
+
case 1:
|
|
1627
|
+
response = _context12.v;
|
|
1628
|
+
if (response.ok) {
|
|
1629
|
+
_context12.n = 2;
|
|
1252
1630
|
break;
|
|
1253
1631
|
}
|
|
1254
|
-
throw new Error("Erreur HTTP: ".concat(
|
|
1255
|
-
case
|
|
1256
|
-
|
|
1257
|
-
return
|
|
1258
|
-
case
|
|
1259
|
-
responseData =
|
|
1632
|
+
throw new Error("Erreur HTTP: ".concat(response.status));
|
|
1633
|
+
case 2:
|
|
1634
|
+
_context12.n = 3;
|
|
1635
|
+
return response.json();
|
|
1636
|
+
case 3:
|
|
1637
|
+
responseData = _context12.v;
|
|
1260
1638
|
if (responseData.success) {
|
|
1261
|
-
|
|
1639
|
+
_context12.n = 4;
|
|
1262
1640
|
break;
|
|
1263
1641
|
}
|
|
1264
|
-
throw new Error("Erreur
|
|
1265
|
-
case
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
// Stocker l'URL du QR code pour getQRCode()
|
|
1271
|
-
this.currentQRUrl = responseData.data.dataUrl;
|
|
1272
|
-
|
|
1273
|
-
// Créer le conteneur avec le QR code PHP
|
|
1274
|
-
_qrContainer.innerHTML = "\n <div class=\"sunuid-qr-ready\" style=\"text-align: center; padding: 20px;\">\n <img src=\"".concat(responseData.data.dataUrl, "\" alt=\"QR Code ").concat(this.config.partnerName, "\" style=\"max-width: 300px; border: 2px solid #ddd; border-radius: 10px;\">\n </div>\n ");
|
|
1275
|
-
|
|
1276
|
-
// Afficher les instructions et le statut maintenant que le QR est prêt
|
|
1277
|
-
instructionsElement = _qrContainer.parentElement.querySelector('.sunuid-qr-instructions');
|
|
1278
|
-
statusElement = _qrContainer.parentElement.querySelector('.sunuid-qr-status');
|
|
1279
|
-
if (instructionsElement) {
|
|
1280
|
-
instructionsElement.style.display = 'block';
|
|
1281
|
-
instructionsElement.classList.add('sunuid-qr-ready');
|
|
1282
|
-
}
|
|
1283
|
-
if (statusElement) {
|
|
1284
|
-
statusElement.style.display = 'block';
|
|
1285
|
-
statusElement.classList.add('sunuid-qr-ready');
|
|
1286
|
-
}
|
|
1287
|
-
console.log('✅ QR code PHP affiché dans le conteneur');
|
|
1288
|
-
_context9.n = 8;
|
|
1289
|
-
break;
|
|
1290
|
-
case 7:
|
|
1291
|
-
_context9.p = 7;
|
|
1292
|
-
_t6 = _context9.v;
|
|
1293
|
-
console.error('❌ Erreur génération QR PHP:', _t6);
|
|
1294
|
-
console.error('Stack trace:', _t6.stack);
|
|
1295
|
-
|
|
1296
|
-
// Détecter les erreurs CORS ou 404 pour activer le fallback côté client
|
|
1297
|
-
if (_t6.message.includes('Failed to fetch') || _t6.message.includes('CORS') || _t6.message.includes('404') || _t6.message.includes('Not Found')) {
|
|
1298
|
-
console.warn('🚫 Erreur PHP détectée (CORS/404), tentative de génération QR côté client...');
|
|
1299
|
-
this.generateQRCodeClientSide(content, label, qrContainer);
|
|
1642
|
+
throw new Error("Erreur QR: ".concat(responseData.error));
|
|
1643
|
+
case 4:
|
|
1644
|
+
if (qrGeneratorUrl.includes('localhost:8000')) {
|
|
1645
|
+
// Service local
|
|
1646
|
+
qrImageUrl = responseData.data_uri;
|
|
1300
1647
|
} else {
|
|
1301
|
-
|
|
1648
|
+
// Service distant - utiliser le format de l'API principale
|
|
1649
|
+
imageBaseUrl = 'https://sunuid.fayma.sn';
|
|
1650
|
+
qrImageUrl = "".concat(imageBaseUrl).concat(responseData.data.qrcode);
|
|
1302
1651
|
}
|
|
1303
|
-
|
|
1304
|
-
|
|
1652
|
+
|
|
1653
|
+
// Stocker l'URL
|
|
1654
|
+
this.currentQRUrl = qrImageUrl;
|
|
1655
|
+
|
|
1656
|
+
// Afficher le QR code
|
|
1657
|
+
qrContainer.innerHTML = "\n <div style=\"text-align: center; padding: 20px;\">\n <img src=\"".concat(qrImageUrl, "\" alt=\"QR Code\" style=\"max-width: 300px; border: 2px solid #ddd; border-radius: 10px;\">\n </div>\n ");
|
|
1658
|
+
|
|
1659
|
+
// Afficher les instructions
|
|
1660
|
+
this.showQRInstructions(qrContainer);
|
|
1661
|
+
case 5:
|
|
1662
|
+
return _context12.a(2);
|
|
1305
1663
|
}
|
|
1306
|
-
},
|
|
1664
|
+
}, _callee12, this);
|
|
1307
1665
|
}));
|
|
1308
|
-
function
|
|
1309
|
-
return
|
|
1666
|
+
function generateQRPHP(_x19, _x20, _x21) {
|
|
1667
|
+
return _generateQRPHP.apply(this, arguments);
|
|
1310
1668
|
}
|
|
1311
|
-
return
|
|
1669
|
+
return generateQRPHP;
|
|
1312
1670
|
}()
|
|
1313
1671
|
/**
|
|
1314
|
-
*
|
|
1672
|
+
* Afficher une image QR par défaut (fallback final)
|
|
1315
1673
|
*/
|
|
1316
1674
|
)
|
|
1317
1675
|
}, {
|
|
1318
|
-
key: "
|
|
1319
|
-
value: function
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
console.log('🎨 Génération QR côté client...');
|
|
1323
|
-
|
|
1324
|
-
// Vérifier si QRCode est disponible
|
|
1325
|
-
if (typeof QRCode === 'undefined') {
|
|
1326
|
-
console.error('❌ QRCode library non disponible');
|
|
1327
|
-
this.displayFallbackImage();
|
|
1328
|
-
return;
|
|
1329
|
-
}
|
|
1330
|
-
|
|
1331
|
-
// Créer un canvas pour le QR code
|
|
1332
|
-
var canvas = document.createElement('canvas');
|
|
1333
|
-
canvas.width = 300;
|
|
1334
|
-
canvas.height = 320; // Plus d'espace pour le label
|
|
1335
|
-
var ctx = canvas.getContext('2d');
|
|
1336
|
-
|
|
1337
|
-
// Remplir le fond en blanc
|
|
1338
|
-
ctx.fillStyle = '#FFFFFF';
|
|
1339
|
-
ctx.fillRect(0, 0, 300, 320);
|
|
1340
|
-
|
|
1341
|
-
// Générer le QR code avec QRCode library
|
|
1342
|
-
QRCode.toCanvas(canvas, content, {
|
|
1343
|
-
width: 280,
|
|
1344
|
-
margin: 10,
|
|
1345
|
-
color: {
|
|
1346
|
-
dark: '#000000',
|
|
1347
|
-
light: '#FFFFFF'
|
|
1348
|
-
}
|
|
1349
|
-
}, function (error) {
|
|
1350
|
-
if (error) {
|
|
1351
|
-
console.error('❌ Erreur génération QR côté client:', error);
|
|
1352
|
-
_this4.displayFallbackImage();
|
|
1353
|
-
return;
|
|
1354
|
-
}
|
|
1355
|
-
|
|
1356
|
-
// Ajouter le label en bas du QR code (sans afficher le contenu)
|
|
1357
|
-
ctx.fillStyle = '#333333';
|
|
1358
|
-
ctx.font = 'bold 14px Arial';
|
|
1359
|
-
ctx.textAlign = 'center';
|
|
1360
|
-
ctx.fillText(label, 150, 305);
|
|
1361
|
-
|
|
1362
|
-
// Convertir en data URL
|
|
1363
|
-
var dataUrl = canvas.toDataURL('image/png');
|
|
1364
|
-
|
|
1365
|
-
// Stocker l'URL du QR code pour getQRCode()
|
|
1366
|
-
_this4.currentQRUrl = dataUrl;
|
|
1367
|
-
|
|
1368
|
-
// Afficher le QR code (sans le contenu)
|
|
1369
|
-
qrContainer.innerHTML = "\n <div class=\"sunuid-qr-ready\" style=\"text-align: center; padding: 20px;\">\n <img src=\"".concat(dataUrl, "\" alt=\"QR Code ").concat(_this4.config.partnerName, "\" style=\"max-width: 300px; border: 2px solid #ddd; border-radius: 10px;\">\n </div>\n ");
|
|
1676
|
+
key: "displayDefaultQR",
|
|
1677
|
+
value: function displayDefaultQR(qrContainer, content, label) {
|
|
1678
|
+
qrContainer.innerHTML = "\n <div style=\"text-align: center; padding: 20px; color: #666;\">\n <div style=\"width: 300px; height: 300px; background: #f0f0f0; border: 2px solid #ddd; border-radius: 10px; display: flex; align-items: center; justify-content: center; margin: 0 auto;\">\n <div>\n <p style=\"font-size: 24px; margin: 0;\">\uD83D\uDCF1</p>\n <p style=\"font-size: 14px; margin: 10px 0 0 0;\">QR Code</p>\n </div>\n </div>\n <p style=\"margin-top: 10px; font-size: 12px;\">".concat(label, "</p>\n <p style=\"font-size: 10px; color: #999; margin-top: 5px;\">Contenu: ").concat(content, "</p>\n </div>\n ");
|
|
1679
|
+
}
|
|
1370
1680
|
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1681
|
+
/**
|
|
1682
|
+
* S'assurer que la bibliothèque QRCode est disponible
|
|
1683
|
+
*/
|
|
1684
|
+
}, {
|
|
1685
|
+
key: "ensureQRCodeLibrary",
|
|
1686
|
+
value: (function () {
|
|
1687
|
+
var _ensureQRCodeLibrary = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13() {
|
|
1688
|
+
return _regenerator().w(function (_context13) {
|
|
1689
|
+
while (1) switch (_context13.n) {
|
|
1690
|
+
case 0:
|
|
1691
|
+
if (!(typeof QRCode !== 'undefined')) {
|
|
1692
|
+
_context13.n = 1;
|
|
1693
|
+
break;
|
|
1694
|
+
}
|
|
1695
|
+
console.log('✅ QRCode library déjà disponible');
|
|
1696
|
+
return _context13.a(2, true);
|
|
1697
|
+
case 1:
|
|
1698
|
+
console.log('📦 Chargement QRCode library...');
|
|
1699
|
+
return _context13.a(2, new Promise(function (resolve, reject) {
|
|
1700
|
+
var script = document.createElement('script');
|
|
1701
|
+
script.src = 'https://cdn.jsdelivr.net/npm/qrcode@1.5.3/lib/browser.min.js';
|
|
1702
|
+
script.onload = function () {
|
|
1703
|
+
setTimeout(function () {
|
|
1704
|
+
if (typeof QRCode !== 'undefined') {
|
|
1705
|
+
console.log('✅ QRCode library chargée');
|
|
1706
|
+
resolve(true);
|
|
1707
|
+
} else {
|
|
1708
|
+
console.error('❌ QRCode non disponible après chargement');
|
|
1709
|
+
reject(new Error('QRCode library non disponible après chargement'));
|
|
1710
|
+
}
|
|
1711
|
+
}, 200);
|
|
1712
|
+
};
|
|
1713
|
+
script.onerror = function () {
|
|
1714
|
+
console.error('❌ Erreur chargement QRCode library');
|
|
1715
|
+
reject(new Error('Erreur chargement QRCode library'));
|
|
1716
|
+
};
|
|
1717
|
+
document.head.appendChild(script);
|
|
1718
|
+
}));
|
|
1381
1719
|
}
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1720
|
+
}, _callee13);
|
|
1721
|
+
}));
|
|
1722
|
+
function ensureQRCodeLibrary() {
|
|
1723
|
+
return _ensureQRCodeLibrary.apply(this, arguments);
|
|
1724
|
+
}
|
|
1725
|
+
return ensureQRCodeLibrary;
|
|
1726
|
+
}()
|
|
1727
|
+
/**
|
|
1728
|
+
* Afficher les instructions pour le QR code
|
|
1729
|
+
*/
|
|
1730
|
+
)
|
|
1731
|
+
}, {
|
|
1732
|
+
key: "showQRInstructions",
|
|
1733
|
+
value: function showQRInstructions(qrContainer) {
|
|
1734
|
+
var instructionsElement = qrContainer.parentElement.querySelector('.sunuid-qr-instructions');
|
|
1735
|
+
var statusElement = qrContainer.parentElement.querySelector('.sunuid-qr-status');
|
|
1736
|
+
if (instructionsElement) {
|
|
1737
|
+
instructionsElement.style.display = 'block';
|
|
1738
|
+
instructionsElement.classList.add('sunuid-qr-ready');
|
|
1739
|
+
}
|
|
1740
|
+
if (statusElement) {
|
|
1741
|
+
statusElement.style.display = 'block';
|
|
1742
|
+
statusElement.classList.add('sunuid-qr-ready');
|
|
1387
1743
|
}
|
|
1388
1744
|
}
|
|
1389
1745
|
|
|
@@ -1424,8 +1780,6 @@
|
|
|
1424
1780
|
var qrContainer = document.getElementById('sunuid-qr-container');
|
|
1425
1781
|
if (qrContainer) {
|
|
1426
1782
|
qrContainer.innerHTML = "\n <div style=\"text-align: center; padding: 20px; color: #666;\">\n <p>\u26A0\uFE0F G\xE9n\xE9ration QR personnalis\xE9 non disponible</p>\n <p>Utilisation de l'image par d\xE9faut</p>\n <p><strong>Debug:</strong> QRCode disponible: ".concat(typeof QRCode !== 'undefined', "</p>\n <p><strong>Debug:</strong> Container trouv\xE9: ").concat(qrContainer !== null, "</p>\n </div>\n ");
|
|
1427
|
-
} else {
|
|
1428
|
-
console.error('❌ Container QR non trouvé pour fallback');
|
|
1429
1783
|
}
|
|
1430
1784
|
}
|
|
1431
1785
|
|
|
@@ -1450,33 +1804,55 @@
|
|
|
1450
1804
|
}, {
|
|
1451
1805
|
key: "refreshQR",
|
|
1452
1806
|
value: (function () {
|
|
1453
|
-
var _refreshQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1807
|
+
var _refreshQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14(containerId) {
|
|
1454
1808
|
var options,
|
|
1455
1809
|
result,
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1810
|
+
_result,
|
|
1811
|
+
_args14 = arguments,
|
|
1812
|
+
_t1;
|
|
1813
|
+
return _regenerator().w(function (_context14) {
|
|
1814
|
+
while (1) switch (_context14.p = _context14.n) {
|
|
1460
1815
|
case 0:
|
|
1461
|
-
options =
|
|
1462
|
-
|
|
1463
|
-
|
|
1816
|
+
options = _args14.length > 1 && _args14[1] !== undefined ? _args14[1] : {};
|
|
1817
|
+
_context14.p = 1;
|
|
1818
|
+
if (!this.currentQRUrl) {
|
|
1819
|
+
_context14.n = 3;
|
|
1820
|
+
break;
|
|
1821
|
+
}
|
|
1822
|
+
console.log('🔄 Vérification du statut du QR code existant...');
|
|
1823
|
+
|
|
1824
|
+
// Option 1: Vérifier le statut du QR code via l'API
|
|
1825
|
+
// (à implémenter si l'API le supporte)
|
|
1826
|
+
|
|
1827
|
+
// Option 2: Régénérer le QR code seulement si nécessaire
|
|
1828
|
+
// Pour l'instant, on régénère pour s'assurer qu'il est à jour
|
|
1829
|
+
_context14.n = 2;
|
|
1464
1830
|
return this.generateQR(containerId, options);
|
|
1465
1831
|
case 2:
|
|
1466
|
-
result =
|
|
1467
|
-
return
|
|
1832
|
+
result = _context14.v;
|
|
1833
|
+
return _context14.a(2, result);
|
|
1468
1834
|
case 3:
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
this.displayServiceUnavailable(containerId, this.config.type);
|
|
1473
|
-
throw _t7;
|
|
1835
|
+
console.log('🔄 Pas de QR code existant, génération d\'un nouveau...');
|
|
1836
|
+
_context14.n = 4;
|
|
1837
|
+
return this.generateQR(containerId, options);
|
|
1474
1838
|
case 4:
|
|
1475
|
-
|
|
1839
|
+
_result = _context14.v;
|
|
1840
|
+
return _context14.a(2, _result);
|
|
1841
|
+
case 5:
|
|
1842
|
+
_context14.n = 7;
|
|
1843
|
+
break;
|
|
1844
|
+
case 6:
|
|
1845
|
+
_context14.p = 6;
|
|
1846
|
+
_t1 = _context14.v;
|
|
1847
|
+
console.error('Erreur lors du rafraîchissement:', _t1.message);
|
|
1848
|
+
this.displayServiceUnavailable(containerId, this.config.type);
|
|
1849
|
+
throw _t1;
|
|
1850
|
+
case 7:
|
|
1851
|
+
return _context14.a(2);
|
|
1476
1852
|
}
|
|
1477
|
-
},
|
|
1853
|
+
}, _callee14, this, [[1, 6]]);
|
|
1478
1854
|
}));
|
|
1479
|
-
function refreshQR(
|
|
1855
|
+
function refreshQR(_x22) {
|
|
1480
1856
|
return _refreshQR.apply(this, arguments);
|
|
1481
1857
|
}
|
|
1482
1858
|
return refreshQR;
|
|
@@ -1488,28 +1864,36 @@
|
|
|
1488
1864
|
}, {
|
|
1489
1865
|
key: "startAutoRefresh",
|
|
1490
1866
|
value: function startAutoRefresh(containerId, type, options) {
|
|
1491
|
-
var
|
|
1867
|
+
var _this3 = this;
|
|
1492
1868
|
if (!this.config.autoRefresh) return;
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1869
|
+
|
|
1870
|
+
// Arrêter le timer existant s'il y en a un
|
|
1871
|
+
if (this.refreshTimer) {
|
|
1872
|
+
clearInterval(this.refreshTimer);
|
|
1873
|
+
console.log('🔄 Timer de rafraîchissement précédent arrêté');
|
|
1874
|
+
}
|
|
1875
|
+
this.refreshTimer = setInterval(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15() {
|
|
1876
|
+
var _t10;
|
|
1877
|
+
return _regenerator().w(function (_context15) {
|
|
1878
|
+
while (1) switch (_context15.p = _context15.n) {
|
|
1497
1879
|
case 0:
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1880
|
+
_context15.p = 0;
|
|
1881
|
+
console.log('🔄 Rafraîchissement automatique du QR code...');
|
|
1882
|
+
_context15.n = 1;
|
|
1883
|
+
return _this3.refreshQR(containerId, type, options);
|
|
1501
1884
|
case 1:
|
|
1502
|
-
|
|
1885
|
+
_context15.n = 3;
|
|
1503
1886
|
break;
|
|
1504
1887
|
case 2:
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
console.warn('Erreur lors du rafraîchissement automatique:',
|
|
1888
|
+
_context15.p = 2;
|
|
1889
|
+
_t10 = _context15.v;
|
|
1890
|
+
console.warn('Erreur lors du rafraîchissement automatique:', _t10);
|
|
1508
1891
|
case 3:
|
|
1509
|
-
return
|
|
1892
|
+
return _context15.a(2);
|
|
1510
1893
|
}
|
|
1511
|
-
},
|
|
1894
|
+
}, _callee15, null, [[0, 2]]);
|
|
1512
1895
|
})), this.config.refreshInterval);
|
|
1896
|
+
console.log("\uD83D\uDD04 Timer de rafra\xEEchissement d\xE9marr\xE9 (".concat(this.config.refreshInterval, "ms)"));
|
|
1513
1897
|
}
|
|
1514
1898
|
|
|
1515
1899
|
/**
|
|
@@ -1522,16 +1906,16 @@
|
|
|
1522
1906
|
}, {
|
|
1523
1907
|
key: "makeRequest",
|
|
1524
1908
|
value: (function () {
|
|
1525
|
-
var _makeRequest = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1909
|
+
var _makeRequest = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16(endpoint, data) {
|
|
1526
1910
|
var _window$SunuIDConfig4,
|
|
1527
1911
|
_window$SunuIDConfig5,
|
|
1528
|
-
|
|
1912
|
+
_this4 = this;
|
|
1529
1913
|
var sanitizedData, endpointPath, url, retryCount, maxRetries, _loop, _ret;
|
|
1530
|
-
return _regenerator().w(function (
|
|
1531
|
-
while (1) switch (
|
|
1914
|
+
return _regenerator().w(function (_context17) {
|
|
1915
|
+
while (1) switch (_context17.n) {
|
|
1532
1916
|
case 0:
|
|
1533
1917
|
if (this.isInitialized) {
|
|
1534
|
-
|
|
1918
|
+
_context17.n = 1;
|
|
1535
1919
|
break;
|
|
1536
1920
|
}
|
|
1537
1921
|
this.logSecurityEvent('REQUEST_BEFORE_INIT', {
|
|
@@ -1540,12 +1924,12 @@
|
|
|
1540
1924
|
throw new Error('SDK non initialisé');
|
|
1541
1925
|
case 1:
|
|
1542
1926
|
if (!this.config.secureInit) {
|
|
1543
|
-
|
|
1927
|
+
_context17.n = 2;
|
|
1544
1928
|
break;
|
|
1545
1929
|
}
|
|
1546
1930
|
this.config.requestCount++;
|
|
1547
1931
|
if (!(this.config.requestCount > this.config.maxRequests)) {
|
|
1548
|
-
|
|
1932
|
+
_context17.n = 2;
|
|
1549
1933
|
break;
|
|
1550
1934
|
}
|
|
1551
1935
|
this.logSecurityEvent('API_REQUEST_LIMIT_EXCEEDED', {
|
|
@@ -1580,15 +1964,15 @@
|
|
|
1580
1964
|
retryCount = 0;
|
|
1581
1965
|
maxRetries = this.config.maxRetries;
|
|
1582
1966
|
_loop = /*#__PURE__*/_regenerator().m(function _loop() {
|
|
1583
|
-
var controller, timeoutId, headers,
|
|
1584
|
-
return _regenerator().w(function (
|
|
1585
|
-
while (1) switch (
|
|
1967
|
+
var controller, timeoutId, headers, response, errorText, errorData, result, _t11;
|
|
1968
|
+
return _regenerator().w(function (_context16) {
|
|
1969
|
+
while (1) switch (_context16.p = _context16.n) {
|
|
1586
1970
|
case 0:
|
|
1587
|
-
|
|
1971
|
+
_context16.p = 0;
|
|
1588
1972
|
controller = new AbortController();
|
|
1589
1973
|
timeoutId = setTimeout(function () {
|
|
1590
1974
|
return controller.abort();
|
|
1591
|
-
},
|
|
1975
|
+
}, _this4.config.requestTimeout); // Headers minimaux (API SunuID n'accepte que les headers essentiels)
|
|
1592
1976
|
headers = {
|
|
1593
1977
|
'Content-Type': 'application/json'
|
|
1594
1978
|
}; // Note: En mode sécurisé, les credentials sont dans le body
|
|
@@ -1596,7 +1980,7 @@
|
|
|
1596
1980
|
// if (this.config.secureInit && this.config.token) {
|
|
1597
1981
|
// headers['X-Secure-Token'] = this.config.token;
|
|
1598
1982
|
// }
|
|
1599
|
-
|
|
1983
|
+
_context16.n = 1;
|
|
1600
1984
|
return fetch(url, {
|
|
1601
1985
|
method: 'POST',
|
|
1602
1986
|
headers: headers,
|
|
@@ -1604,16 +1988,16 @@
|
|
|
1604
1988
|
signal: controller.signal
|
|
1605
1989
|
});
|
|
1606
1990
|
case 1:
|
|
1607
|
-
|
|
1991
|
+
response = _context16.v;
|
|
1608
1992
|
clearTimeout(timeoutId);
|
|
1609
|
-
if (
|
|
1610
|
-
|
|
1993
|
+
if (response.ok) {
|
|
1994
|
+
_context16.n = 3;
|
|
1611
1995
|
break;
|
|
1612
1996
|
}
|
|
1613
|
-
|
|
1614
|
-
return
|
|
1997
|
+
_context16.n = 2;
|
|
1998
|
+
return response.text();
|
|
1615
1999
|
case 2:
|
|
1616
|
-
errorText =
|
|
2000
|
+
errorText = _context16.v;
|
|
1617
2001
|
try {
|
|
1618
2002
|
errorData = JSON.parse(errorText);
|
|
1619
2003
|
} catch (e) {
|
|
@@ -1621,90 +2005,90 @@
|
|
|
1621
2005
|
message: errorText
|
|
1622
2006
|
};
|
|
1623
2007
|
}
|
|
1624
|
-
|
|
1625
|
-
status:
|
|
1626
|
-
statusText:
|
|
2008
|
+
_this4.logSecurityEvent('API_REQUEST_ERROR', {
|
|
2009
|
+
status: response.status,
|
|
2010
|
+
statusText: response.statusText,
|
|
1627
2011
|
error: errorData.message
|
|
1628
2012
|
});
|
|
1629
|
-
throw new Error(errorData.message || "Erreur HTTP: ".concat(
|
|
2013
|
+
throw new Error(errorData.message || "Erreur HTTP: ".concat(response.status));
|
|
1630
2014
|
case 3:
|
|
1631
|
-
|
|
1632
|
-
return
|
|
2015
|
+
_context16.n = 4;
|
|
2016
|
+
return response.json();
|
|
1633
2017
|
case 4:
|
|
1634
|
-
result =
|
|
1635
|
-
|
|
2018
|
+
result = _context16.v;
|
|
2019
|
+
_this4.logSecurityEvent('API_REQUEST_SUCCESS', {
|
|
1636
2020
|
endpoint: endpointPath,
|
|
1637
2021
|
responseKeys: Object.keys(result)
|
|
1638
2022
|
});
|
|
1639
|
-
return
|
|
2023
|
+
return _context16.a(2, {
|
|
1640
2024
|
v: result
|
|
1641
2025
|
});
|
|
1642
2026
|
case 5:
|
|
1643
|
-
|
|
1644
|
-
|
|
2027
|
+
_context16.p = 5;
|
|
2028
|
+
_t11 = _context16.v;
|
|
1645
2029
|
retryCount++;
|
|
1646
|
-
if (!(
|
|
1647
|
-
|
|
2030
|
+
if (!(_t11.name === 'AbortError')) {
|
|
2031
|
+
_context16.n = 7;
|
|
1648
2032
|
break;
|
|
1649
2033
|
}
|
|
1650
|
-
|
|
2034
|
+
_this4.logSecurityEvent('API_REQUEST_TIMEOUT', {
|
|
1651
2035
|
retryCount: retryCount
|
|
1652
2036
|
});
|
|
1653
2037
|
if (!(retryCount > maxRetries)) {
|
|
1654
|
-
|
|
2038
|
+
_context16.n = 6;
|
|
1655
2039
|
break;
|
|
1656
2040
|
}
|
|
1657
2041
|
throw new Error('Timeout de la requête API');
|
|
1658
2042
|
case 6:
|
|
1659
|
-
return
|
|
2043
|
+
return _context16.a(2, 0);
|
|
1660
2044
|
case 7:
|
|
1661
2045
|
if (!(retryCount > maxRetries)) {
|
|
1662
|
-
|
|
2046
|
+
_context16.n = 8;
|
|
1663
2047
|
break;
|
|
1664
2048
|
}
|
|
1665
|
-
|
|
2049
|
+
_this4.logSecurityEvent('API_REQUEST_MAX_RETRIES', {
|
|
1666
2050
|
retryCount: retryCount,
|
|
1667
|
-
error:
|
|
2051
|
+
error: _t11.message
|
|
1668
2052
|
});
|
|
1669
|
-
throw
|
|
2053
|
+
throw _t11;
|
|
1670
2054
|
case 8:
|
|
1671
|
-
|
|
2055
|
+
_context16.n = 9;
|
|
1672
2056
|
return new Promise(function (resolve) {
|
|
1673
2057
|
return setTimeout(resolve, 1000 * retryCount);
|
|
1674
2058
|
});
|
|
1675
2059
|
case 9:
|
|
1676
|
-
return
|
|
2060
|
+
return _context16.a(2);
|
|
1677
2061
|
}
|
|
1678
2062
|
}, _loop, null, [[0, 5]]);
|
|
1679
2063
|
});
|
|
1680
2064
|
case 3:
|
|
1681
2065
|
if (!(retryCount <= maxRetries)) {
|
|
1682
|
-
|
|
2066
|
+
_context17.n = 7;
|
|
1683
2067
|
break;
|
|
1684
2068
|
}
|
|
1685
|
-
return
|
|
2069
|
+
return _context17.d(_regeneratorValues(_loop()), 4);
|
|
1686
2070
|
case 4:
|
|
1687
|
-
_ret =
|
|
2071
|
+
_ret = _context17.v;
|
|
1688
2072
|
if (!(_ret === 0)) {
|
|
1689
|
-
|
|
2073
|
+
_context17.n = 5;
|
|
1690
2074
|
break;
|
|
1691
2075
|
}
|
|
1692
|
-
return
|
|
2076
|
+
return _context17.a(3, 3);
|
|
1693
2077
|
case 5:
|
|
1694
2078
|
if (!_ret) {
|
|
1695
|
-
|
|
2079
|
+
_context17.n = 6;
|
|
1696
2080
|
break;
|
|
1697
2081
|
}
|
|
1698
|
-
return
|
|
2082
|
+
return _context17.a(2, _ret.v);
|
|
1699
2083
|
case 6:
|
|
1700
|
-
|
|
2084
|
+
_context17.n = 3;
|
|
1701
2085
|
break;
|
|
1702
2086
|
case 7:
|
|
1703
|
-
return
|
|
2087
|
+
return _context17.a(2);
|
|
1704
2088
|
}
|
|
1705
|
-
},
|
|
2089
|
+
}, _callee16, this);
|
|
1706
2090
|
}));
|
|
1707
|
-
function makeRequest(
|
|
2091
|
+
function makeRequest(_x23, _x24) {
|
|
1708
2092
|
return _makeRequest.apply(this, arguments);
|
|
1709
2093
|
}
|
|
1710
2094
|
return makeRequest;
|
|
@@ -1760,9 +2144,88 @@
|
|
|
1760
2144
|
return 'req_' + Date.now() + '_' + Math.random().toString(36).substr(2, 9);
|
|
1761
2145
|
}
|
|
1762
2146
|
|
|
2147
|
+
/**
|
|
2148
|
+
* Générer un code de session unique
|
|
2149
|
+
*/
|
|
2150
|
+
}, {
|
|
2151
|
+
key: "generateSessionCode",
|
|
2152
|
+
value: function generateSessionCode() {
|
|
2153
|
+
var timestamp = Date.now();
|
|
2154
|
+
var random = Math.random().toString(36).substr(2, 9);
|
|
2155
|
+
var code = "".concat(timestamp, "_").concat(random);
|
|
2156
|
+
return btoa(code); // Encoder en base64
|
|
2157
|
+
}
|
|
2158
|
+
|
|
2159
|
+
/**
|
|
2160
|
+
* Récupérer les informations du partenaire depuis l'API
|
|
2161
|
+
*/
|
|
2162
|
+
}, {
|
|
2163
|
+
key: "fetchPartnerInfo",
|
|
2164
|
+
value: (function () {
|
|
2165
|
+
var _fetchPartnerInfo = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17() {
|
|
2166
|
+
var response, authTest, _t12;
|
|
2167
|
+
return _regenerator().w(function (_context18) {
|
|
2168
|
+
while (1) switch (_context18.p = _context18.n) {
|
|
2169
|
+
case 0:
|
|
2170
|
+
_context18.p = 0;
|
|
2171
|
+
_context18.n = 1;
|
|
2172
|
+
return this.makeRequest('/debug', {
|
|
2173
|
+
type: this.config.type,
|
|
2174
|
+
client_id: this.config.clientId,
|
|
2175
|
+
secret_id: this.config.secretId
|
|
2176
|
+
});
|
|
2177
|
+
case 1:
|
|
2178
|
+
response = _context18.v;
|
|
2179
|
+
console.log('📋 Réponse debug API:', response);
|
|
2180
|
+
if (response.success && response.authentication && response.authentication.auth_test) {
|
|
2181
|
+
authTest = response.authentication.auth_test;
|
|
2182
|
+
this.config.partnerId = authTest.partner_id;
|
|
2183
|
+
|
|
2184
|
+
// Récupérer le service_id depuis la réponse
|
|
2185
|
+
if (response.service_id) {
|
|
2186
|
+
this.config.serviceId = response.service_id;
|
|
2187
|
+
} else {
|
|
2188
|
+
// Fallback: utiliser le partner_id comme service_id
|
|
2189
|
+
this.config.serviceId = authTest.partner_id;
|
|
2190
|
+
}
|
|
2191
|
+
|
|
2192
|
+
// Utiliser le partner_id pour déterminer le nom du partenaire
|
|
2193
|
+
// Pour l'instant, on utilise une logique simple basée sur l'ID
|
|
2194
|
+
if (authTest.partner_id === 21) {
|
|
2195
|
+
this.config.partnerName = 'Fayma';
|
|
2196
|
+
} else {
|
|
2197
|
+
this.config.partnerName = "Partner_".concat(authTest.partner_id);
|
|
2198
|
+
}
|
|
2199
|
+
console.log('✅ Informations partenaire récupérées:', {
|
|
2200
|
+
partnerName: this.config.partnerName,
|
|
2201
|
+
partnerId: this.config.partnerId,
|
|
2202
|
+
serviceId: this.config.serviceId
|
|
2203
|
+
});
|
|
2204
|
+
} else {
|
|
2205
|
+
console.warn('⚠️ Impossible de récupérer les informations du partenaire, utilisation du partner_id');
|
|
2206
|
+
this.config.partnerName = "Partner_".concat(this.config.partnerId || 'unknown');
|
|
2207
|
+
}
|
|
2208
|
+
_context18.n = 3;
|
|
2209
|
+
break;
|
|
2210
|
+
case 2:
|
|
2211
|
+
_context18.p = 2;
|
|
2212
|
+
_t12 = _context18.v;
|
|
2213
|
+
console.warn('⚠️ Erreur lors de la récupération des informations du partenaire:', _t12.message);
|
|
2214
|
+
this.config.partnerName = 'Partner_unknown';
|
|
2215
|
+
case 3:
|
|
2216
|
+
return _context18.a(2);
|
|
2217
|
+
}
|
|
2218
|
+
}, _callee17, this, [[0, 2]]);
|
|
2219
|
+
}));
|
|
2220
|
+
function fetchPartnerInfo() {
|
|
2221
|
+
return _fetchPartnerInfo.apply(this, arguments);
|
|
2222
|
+
}
|
|
2223
|
+
return fetchPartnerInfo;
|
|
2224
|
+
}()
|
|
1763
2225
|
/**
|
|
1764
2226
|
* Appliquer le thème
|
|
1765
2227
|
*/
|
|
2228
|
+
)
|
|
1766
2229
|
}, {
|
|
1767
2230
|
key: "applyTheme",
|
|
1768
2231
|
value: function applyTheme(theme) {
|
|
@@ -1784,9 +2247,124 @@
|
|
|
1784
2247
|
}
|
|
1785
2248
|
}
|
|
1786
2249
|
|
|
2250
|
+
/**
|
|
2251
|
+
* Vérifier le statut des connexions
|
|
2252
|
+
*/
|
|
2253
|
+
}, {
|
|
2254
|
+
key: "checkConnections",
|
|
2255
|
+
value: (function () {
|
|
2256
|
+
var _checkConnections = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18() {
|
|
2257
|
+
var status, testResponse, debugData, _t13;
|
|
2258
|
+
return _regenerator().w(function (_context19) {
|
|
2259
|
+
while (1) switch (_context19.p = _context19.n) {
|
|
2260
|
+
case 0:
|
|
2261
|
+
status = {
|
|
2262
|
+
api: false,
|
|
2263
|
+
websocket: false,
|
|
2264
|
+
ready: false
|
|
2265
|
+
}; // Vérifier l'API en utilisant l'endpoint debug
|
|
2266
|
+
_context19.p = 1;
|
|
2267
|
+
_context19.n = 2;
|
|
2268
|
+
return fetch(this.config.apiUrl + '/debug', {
|
|
2269
|
+
method: 'GET',
|
|
2270
|
+
timeout: 3000
|
|
2271
|
+
});
|
|
2272
|
+
case 2:
|
|
2273
|
+
testResponse = _context19.v;
|
|
2274
|
+
if (!testResponse.ok) {
|
|
2275
|
+
_context19.n = 4;
|
|
2276
|
+
break;
|
|
2277
|
+
}
|
|
2278
|
+
_context19.n = 3;
|
|
2279
|
+
return testResponse.json();
|
|
2280
|
+
case 3:
|
|
2281
|
+
debugData = _context19.v;
|
|
2282
|
+
status.api = debugData.status === 'operational';
|
|
2283
|
+
console.log('🔍 API Status:', debugData.status);
|
|
2284
|
+
_context19.n = 5;
|
|
2285
|
+
break;
|
|
2286
|
+
case 4:
|
|
2287
|
+
status.api = false;
|
|
2288
|
+
case 5:
|
|
2289
|
+
_context19.n = 7;
|
|
2290
|
+
break;
|
|
2291
|
+
case 6:
|
|
2292
|
+
_context19.p = 6;
|
|
2293
|
+
_t13 = _context19.v;
|
|
2294
|
+
console.log('🔍 Test API échoué:', _t13.message);
|
|
2295
|
+
status.api = false;
|
|
2296
|
+
case 7:
|
|
2297
|
+
// Vérifier le WebSocket
|
|
2298
|
+
status.websocket = this.socket && this.socket.connected;
|
|
2299
|
+
|
|
2300
|
+
// Connexions prêtes si API est accessible
|
|
2301
|
+
status.ready = status.api;
|
|
2302
|
+
return _context19.a(2, status);
|
|
2303
|
+
}
|
|
2304
|
+
}, _callee18, this, [[1, 6]]);
|
|
2305
|
+
}));
|
|
2306
|
+
function checkConnections() {
|
|
2307
|
+
return _checkConnections.apply(this, arguments);
|
|
2308
|
+
}
|
|
2309
|
+
return checkConnections;
|
|
2310
|
+
}()
|
|
2311
|
+
/**
|
|
2312
|
+
* Attendre que les connexions soient prêtes
|
|
2313
|
+
*/
|
|
2314
|
+
)
|
|
2315
|
+
}, {
|
|
2316
|
+
key: "waitForConnections",
|
|
2317
|
+
value: (function () {
|
|
2318
|
+
var _waitForConnections = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19() {
|
|
2319
|
+
var timeout,
|
|
2320
|
+
startTime,
|
|
2321
|
+
status,
|
|
2322
|
+
_args20 = arguments;
|
|
2323
|
+
return _regenerator().w(function (_context20) {
|
|
2324
|
+
while (1) switch (_context20.n) {
|
|
2325
|
+
case 0:
|
|
2326
|
+
timeout = _args20.length > 0 && _args20[0] !== undefined ? _args20[0] : 5000;
|
|
2327
|
+
startTime = Date.now();
|
|
2328
|
+
case 1:
|
|
2329
|
+
if (!(Date.now() - startTime < timeout)) {
|
|
2330
|
+
_context20.n = 5;
|
|
2331
|
+
break;
|
|
2332
|
+
}
|
|
2333
|
+
_context20.n = 2;
|
|
2334
|
+
return this.checkConnections();
|
|
2335
|
+
case 2:
|
|
2336
|
+
status = _context20.v;
|
|
2337
|
+
if (!status.ready) {
|
|
2338
|
+
_context20.n = 3;
|
|
2339
|
+
break;
|
|
2340
|
+
}
|
|
2341
|
+
console.log('✅ Connexions prêtes');
|
|
2342
|
+
return _context20.a(2, status);
|
|
2343
|
+
case 3:
|
|
2344
|
+
console.log('⏳ Attente connexions...', status);
|
|
2345
|
+
_context20.n = 4;
|
|
2346
|
+
return new Promise(function (resolve) {
|
|
2347
|
+
return setTimeout(resolve, 1000);
|
|
2348
|
+
});
|
|
2349
|
+
case 4:
|
|
2350
|
+
_context20.n = 1;
|
|
2351
|
+
break;
|
|
2352
|
+
case 5:
|
|
2353
|
+
throw new Error('Timeout connexions - Impossible de générer le QR code');
|
|
2354
|
+
case 6:
|
|
2355
|
+
return _context20.a(2);
|
|
2356
|
+
}
|
|
2357
|
+
}, _callee19, this);
|
|
2358
|
+
}));
|
|
2359
|
+
function waitForConnections() {
|
|
2360
|
+
return _waitForConnections.apply(this, arguments);
|
|
2361
|
+
}
|
|
2362
|
+
return waitForConnections;
|
|
2363
|
+
}()
|
|
1787
2364
|
/**
|
|
1788
2365
|
* Obtenir l'URL du QR code généré
|
|
1789
2366
|
*/
|
|
2367
|
+
)
|
|
1790
2368
|
}, {
|
|
1791
2369
|
key: "getQRCode",
|
|
1792
2370
|
value: function getQRCode() {
|
|
@@ -1805,9 +2383,7 @@
|
|
|
1805
2383
|
}, {
|
|
1806
2384
|
key: "destroy",
|
|
1807
2385
|
value: function destroy() {
|
|
1808
|
-
|
|
1809
|
-
clearInterval(this.refreshTimer);
|
|
1810
|
-
}
|
|
2386
|
+
this.stopAutoRefresh();
|
|
1811
2387
|
|
|
1812
2388
|
// Fermer la connexion WebSocket
|
|
1813
2389
|
if (this.socket) {
|
|
@@ -1820,6 +2396,19 @@
|
|
|
1820
2396
|
console.log('SunuID SDK détruit');
|
|
1821
2397
|
}
|
|
1822
2398
|
|
|
2399
|
+
/**
|
|
2400
|
+
* Arrêter le rafraîchissement automatique
|
|
2401
|
+
*/
|
|
2402
|
+
}, {
|
|
2403
|
+
key: "stopAutoRefresh",
|
|
2404
|
+
value: function stopAutoRefresh() {
|
|
2405
|
+
if (this.refreshTimer) {
|
|
2406
|
+
clearInterval(this.refreshTimer);
|
|
2407
|
+
this.refreshTimer = null;
|
|
2408
|
+
console.log('🔄 Timer de rafraîchissement arrêté');
|
|
2409
|
+
}
|
|
2410
|
+
}
|
|
2411
|
+
|
|
1823
2412
|
/**
|
|
1824
2413
|
* Obtenir les logs de sécurité
|
|
1825
2414
|
*/
|
|
@@ -1838,6 +2427,32 @@
|
|
|
1838
2427
|
window.SunuIDSecurityLogs = [];
|
|
1839
2428
|
this.logSecurityEvent('SECURITY_LOGS_CLEARED');
|
|
1840
2429
|
}
|
|
2430
|
+
|
|
2431
|
+
/**
|
|
2432
|
+
* Afficher un loader pendant le scan du QR code
|
|
2433
|
+
*/
|
|
2434
|
+
}, {
|
|
2435
|
+
key: "showQRLoader",
|
|
2436
|
+
value: function showQRLoader() {
|
|
2437
|
+
console.log('🔄 Affichage du loader - Scan QR initié');
|
|
2438
|
+
|
|
2439
|
+
// Chercher le conteneur QR dans différents IDs possibles
|
|
2440
|
+
var containerIds = ['qr-area', 'qr-container', 'sunuid-qr-container'];
|
|
2441
|
+
var container = null;
|
|
2442
|
+
for (var _i2 = 0, _containerIds = containerIds; _i2 < _containerIds.length; _i2++) {
|
|
2443
|
+
var id = _containerIds[_i2];
|
|
2444
|
+
container = document.getElementById(id);
|
|
2445
|
+
if (container) break;
|
|
2446
|
+
}
|
|
2447
|
+
if (!container) {
|
|
2448
|
+
console.warn('⚠️ Conteneur QR non trouvé pour afficher le loader');
|
|
2449
|
+
return;
|
|
2450
|
+
}
|
|
2451
|
+
|
|
2452
|
+
// Remplacer le contenu par un loader animé
|
|
2453
|
+
container.innerHTML = "\n <div style=\"\n text-align: center;\n padding: 40px 20px;\n background: #f8f9fa;\n border: 2px solid #007bff;\n border-radius: 10px;\n color: #007bff;\n font-family: Arial, sans-serif;\n \">\n <div style=\"\n width: 60px;\n height: 60px;\n border: 4px solid #e3f2fd;\n border-top: 4px solid #007bff;\n border-radius: 50%;\n animation: spin 1s linear infinite;\n margin: 0 auto 20px auto;\n \"></div>\n <h3 style=\"margin: 0 0 10px 0; color: #007bff;\">\uD83D\uDD0D Scan en cours...</h3>\n <p style=\"margin: 0; font-size: 14px;\">\n Veuillez patienter pendant la v\xE9rification de votre identit\xE9.\n </p>\n <div style=\"margin-top: 15px; font-size: 12px; color: #6c757d;\">\n \u23F1\uFE0F Traitement en cours...\n </div>\n </div>\n <style>\n @keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n </style>\n ";
|
|
2454
|
+
console.log('✅ Loader affiché avec succès');
|
|
2455
|
+
}
|
|
1841
2456
|
}]);
|
|
1842
2457
|
}(); // Exposer la classe globalement
|
|
1843
2458
|
window.SunuID = SunuID;
|