sunuid-sdk 1.0.26 → 1.0.28

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.
@@ -274,7 +274,7 @@
274
274
  * @license MIT
275
275
  */
276
276
 
277
- (function (window, _window$SunuIDConfig) {
277
+ (function (window, _window$SunuIDConfig, _window$SunuIDConfig2) {
278
278
 
279
279
  // Configuration par défaut
280
280
  var DEFAULT_CONFIG = {
@@ -302,7 +302,7 @@
302
302
  // 10 secondes
303
303
  // Options d'initialisation sécurisée
304
304
  secureInit: false,
305
- secureInitUrl: 'http://localhost:8081/secure-init.php',
305
+ secureInitUrl: ((_window$SunuIDConfig2 = window.SunuIDConfig) === null || _window$SunuIDConfig2 === void 0 || (_window$SunuIDConfig2 = _window$SunuIDConfig2.apiUrl) === null || _window$SunuIDConfig2 === void 0 ? void 0 : _window$SunuIDConfig2.replace('/api', '')) + '/secure-init.php' || 'https://sunuid.fayma.sn/secure-init.php',
306
306
  token: null
307
307
  };
308
308
 
@@ -832,6 +832,7 @@
832
832
  // Construire l'URL complète de l'image QR avec la base URL pour les images
833
833
  imageBaseUrl = 'https://sunuid.fayma.sn';
834
834
  qrImageUrl = "".concat(imageBaseUrl).concat(response.data.qrcode);
835
+ this.currentQRUrl = qrImageUrl; // Stocker l'URL pour getQRCode()
835
836
  this.displayQRCode(containerId, qrImageUrl, this.config.type, options);
836
837
 
837
838
  // Générer le QR code personnalisé avec le type + code de l'API + socket ID
@@ -1165,7 +1166,7 @@
1165
1166
 
1166
1167
  // Afficher un loader en attendant la réponse API et la connexion socket
1167
1168
  this.getTypeName(type);
1168
- 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\" id=\"sunuid-qr-container\">\n <div style=\"text-align: center; padding: 40px;\">\n <div class=\"sunuid-loader\">\n <div class=\"sunuid-spinner\"></div>\n <p style=\"margin-top: 20px; color: #666;\">Initialisation en cours...</p>\n <p style=\"font-size: 12px; color: #999; margin-top: 10px;\">Connexion API et WebSocket</p>\n <p style=\"font-size: 11px; color: #ccc; margin-top: 5px;\">Attente du Socket ID...</p>\n </div>\n </div>\n </div>\n <div class=\"sunuid-qr-instructions\" style=\"display: none;\">\n <p>Scannez ce QR code avec l'application SunuID pour vous connecter</p>\n </div>\n <div class=\"sunuid-qr-status\" id=\"sunuid-status\" style=\"display: none;\">\n <p>En attente de scan...</p>\n </div>\n ");
1169
+ 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\" id=\"sunuid-qr-container\">\n <div style=\"text-align: center; padding: 40px;\">\n <div class=\"sunuid-loader\">\n <div class=\"sunuid-spinner\"></div>\n <p style=\"margin-top: 20px; color: #666;\">Initialisation en cours...</p>\n <p style=\"font-size: 12px; color: #999; margin-top: 10px;\">Connexion API et WebSocket</p>\n <p style=\"font-size: 11px; color: #ccc; margin-top: 5px;\">Attente du Socket ID...</p>\n </div>\n </div>\n </div>\n <div class=\"sunuid-qr-instructions\" style=\"display: none;\">\n <p>Scannez ce QR code avec l'application ").concat(this.config.partnerName, " pour vous connecter</p>\n </div>\n <div class=\"sunuid-qr-status\" id=\"sunuid-status\" style=\"display: none;\">\n <p>En attente de scan...</p>\n </div>\n ");
1169
1170
  container.appendChild(qrElement);
1170
1171
 
1171
1172
  // Stocker les informations pour la génération ultérieure
@@ -1187,6 +1188,7 @@
1187
1188
  value: (function () {
1188
1189
  var _generateCustomQRCode = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(content, label) {
1189
1190
  var qrContainer,
1191
+ qrGeneratorUrl,
1190
1192
  _response3,
1191
1193
  responseData,
1192
1194
  instructionsElement,
@@ -1215,8 +1217,9 @@
1215
1217
 
1216
1218
  // Appeler l'endpoint PHP
1217
1219
  console.log('🔄 Appel endpoint PHP...');
1220
+ qrGeneratorUrl = this.config.apiUrl.replace('/api', '') + '/qr-generator.php';
1218
1221
  _context9.n = 3;
1219
- return fetch('http://localhost:8081/qr-generator.php', {
1222
+ return fetch(qrGeneratorUrl, {
1220
1223
  method: 'POST',
1221
1224
  headers: {
1222
1225
  'Content-Type': 'application/json',
@@ -1252,8 +1255,11 @@
1252
1255
  console.log('📊 Taille:', responseData.data.size + 'px');
1253
1256
  console.log('📊 Longueur base64:', responseData.data.length + ' caractères');
1254
1257
 
1258
+ // Stocker l'URL du QR code pour getQRCode()
1259
+ this.currentQRUrl = responseData.data.dataUrl;
1260
+
1255
1261
  // Créer le conteneur avec le QR code PHP
1256
- qrContainer.innerHTML = "\n <div class=\"sunuid-qr-ready\" style=\"text-align: center; padding: 20px;\">\n <img src=\"".concat(responseData.data.dataUrl, "\" alt=\"QR Code SunuID\" style=\"max-width: 300px; border: 2px solid #ddd; border-radius: 10px;\">\n <div style=\"margin-top: 15px;\">\n <p style=\"font-weight: bold; color: #333; margin: 5px 0;\">").concat(label, "</p>\n <p style=\"color: #666; font-size: 12px; margin: 5px 0;\">").concat(content, "</p>\n </div>\n </div>\n ");
1262
+ 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 ");
1257
1263
 
1258
1264
  // Afficher les instructions et le statut maintenant que le QR est prêt
1259
1265
  instructionsElement = qrContainer.parentElement.querySelector('.sunuid-qr-instructions');
@@ -1422,8 +1428,8 @@
1422
1428
  key: "makeRequest",
1423
1429
  value: (function () {
1424
1430
  var _makeRequest = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(endpoint, data) {
1425
- var _window$SunuIDConfig2,
1426
- _window$SunuIDConfig3,
1431
+ var _window$SunuIDConfig3,
1432
+ _window$SunuIDConfig4,
1427
1433
  _this5 = this;
1428
1434
  var sanitizedData, endpointPath, url, retryCount, maxRetries, _loop, _ret;
1429
1435
  return _regenerator().w(function (_context11) {
@@ -1463,11 +1469,11 @@
1463
1469
  console.log('🔍 Debug makeRequest - isInitialized:', this.isInitialized);
1464
1470
 
1465
1471
  // Utiliser l'endpoint depuis la configuration si disponible
1466
- endpointPath = ((_window$SunuIDConfig2 = window.SunuIDConfig) === null || _window$SunuIDConfig2 === void 0 || (_window$SunuIDConfig2 = _window$SunuIDConfig2.endpoints) === null || _window$SunuIDConfig2 === void 0 ? void 0 : _window$SunuIDConfig2[endpoint.replace('/', '')]) || endpoint;
1472
+ endpointPath = ((_window$SunuIDConfig3 = window.SunuIDConfig) === null || _window$SunuIDConfig3 === void 0 || (_window$SunuIDConfig3 = _window$SunuIDConfig3.endpoints) === null || _window$SunuIDConfig3 === void 0 ? void 0 : _window$SunuIDConfig3[endpoint.replace('/', '')]) || endpoint;
1467
1473
  url = "".concat(this.config.apiUrl).concat(endpointPath); // Debug: Afficher l'URL finale
1468
1474
  console.log('🔍 URL finale construite:', url);
1469
1475
  console.log('🔍 EndpointPath:', endpointPath);
1470
- console.log('🔍 SunuIDConfig endpoints:', JSON.stringify((_window$SunuIDConfig3 = window.SunuIDConfig) === null || _window$SunuIDConfig3 === void 0 ? void 0 : _window$SunuIDConfig3.endpoints));
1476
+ console.log('🔍 SunuIDConfig endpoints:', JSON.stringify((_window$SunuIDConfig4 = window.SunuIDConfig) === null || _window$SunuIDConfig4 === void 0 ? void 0 : _window$SunuIDConfig4.endpoints));
1471
1477
 
1472
1478
  // Log de sécurité pour la requête
1473
1479
  this.logSecurityEvent('API_REQUEST_START', {
@@ -1683,6 +1689,21 @@
1683
1689
  }
1684
1690
  }
1685
1691
 
1692
+ /**
1693
+ * Obtenir l'URL du QR code généré
1694
+ */
1695
+ }, {
1696
+ key: "getQRCode",
1697
+ value: function getQRCode() {
1698
+ // Retourner l'URL du QR code si disponible
1699
+ if (this.currentQRUrl) {
1700
+ return this.currentQRUrl;
1701
+ }
1702
+
1703
+ // Sinon, retourner une URL par défaut ou null
1704
+ return null;
1705
+ }
1706
+
1686
1707
  /**
1687
1708
  * Nettoyer les ressources
1688
1709
  */