sunuid-sdk 1.0.27 → 1.0.29

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/README.md CHANGED
@@ -44,7 +44,7 @@ npm install sunuid-sdk
44
44
 
45
45
  ## 📖 Utilisation Rapide
46
46
 
47
- > **🚀 [Démarrage en 30 secondes](GET_STARTED.md)** | **🌍 [Intégration Universelle](INTEGRATION_UNIVERSAL.md)** | **⚡ [Démarrage en 2 minutes](QUICKSTART.md)** | **💡 [Intégration simplifiée](INTEGRATION_SIMPLE.md)** | **🔒 [Intégration PHP complète](PHP_INTEGRATION.md)**
47
+ > **🚀 [Démarrage en 30 secondes](GET_STARTED.md)** | **🌍 [Intégration Universelle](INTEGRATION_UNIVERSAL.md)** | **⚡ [Démarrage en 2 minutes](QUICKSTART.md)** | **💡 [Intégration simplifiée](INTEGRATION_SIMPLE.md)** | **🔒 [Intégration PHP complète](PHP_INTEGRATION.md)** | **🏭 [Migration Production](MIGRATION_PRODUCTION.md)**
48
48
 
49
49
  ### 1. Mode Classique (Credentials visibles)
50
50
 
@@ -299,7 +299,12 @@ function _unsupportedIterableToArray(r, a) {
299
299
  // 10 secondes
300
300
  // Options d'initialisation sécurisée
301
301
  secureInit: false,
302
- secureInitUrl: 'http://localhost:8081/secure-init.php',
302
+ secureInitUrl: function (_window$SunuIDConfig2, _window$SunuIDConfig3) {
303
+ if ((_window$SunuIDConfig2 = window.SunuIDConfig) !== null && _window$SunuIDConfig2 !== void 0 && (_window$SunuIDConfig2 = _window$SunuIDConfig2.apiUrl) !== null && _window$SunuIDConfig2 !== void 0 && _window$SunuIDConfig2.includes('api.sunuid.fayma.sn')) {
304
+ return 'https://sunuid.fayma.sn/secure-init.php';
305
+ }
306
+ 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://sunuid.fayma.sn/secure-init.php';
307
+ }(),
303
308
  token: null
304
309
  };
305
310
 
@@ -1163,7 +1168,7 @@ function _unsupportedIterableToArray(r, a) {
1163
1168
 
1164
1169
  // Afficher un loader en attendant la réponse API et la connexion socket
1165
1170
  this.getTypeName(type);
1166
- 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 ");
1171
+ 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 ");
1167
1172
  container.appendChild(qrElement);
1168
1173
 
1169
1174
  // Stocker les informations pour la génération ultérieure
@@ -1185,6 +1190,7 @@ function _unsupportedIterableToArray(r, a) {
1185
1190
  value: (function () {
1186
1191
  var _generateCustomQRCode = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(content, label) {
1187
1192
  var qrContainer,
1193
+ qrGeneratorUrl,
1188
1194
  _response3,
1189
1195
  responseData,
1190
1196
  instructionsElement,
@@ -1213,8 +1219,16 @@ function _unsupportedIterableToArray(r, a) {
1213
1219
 
1214
1220
  // Appeler l'endpoint PHP
1215
1221
  console.log('🔄 Appel endpoint PHP...');
1222
+ // Construire l'URL du QR generator de manière plus robuste
1223
+
1224
+ if (this.config.apiUrl.includes('api.sunuid.fayma.sn')) {
1225
+ qrGeneratorUrl = 'https://sunuid.fayma.sn/qr-generator.php';
1226
+ } else {
1227
+ qrGeneratorUrl = this.config.apiUrl.replace('/api', '') + '/qr-generator.php';
1228
+ }
1229
+ console.log('🔗 URL QR Generator:', qrGeneratorUrl);
1216
1230
  _context9.n = 3;
1217
- return fetch('http://localhost:8081/qr-generator.php', {
1231
+ return fetch(qrGeneratorUrl, {
1218
1232
  method: 'POST',
1219
1233
  headers: {
1220
1234
  'Content-Type': 'application/json',
@@ -1254,7 +1268,7 @@ function _unsupportedIterableToArray(r, a) {
1254
1268
  this.currentQRUrl = responseData.data.dataUrl;
1255
1269
 
1256
1270
  // Créer le conteneur avec le QR code PHP
1257
- 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>\n ");
1271
+ 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 ");
1258
1272
 
1259
1273
  // Afficher les instructions et le statut maintenant que le QR est prêt
1260
1274
  instructionsElement = qrContainer.parentElement.querySelector('.sunuid-qr-instructions');
@@ -1423,8 +1437,8 @@ function _unsupportedIterableToArray(r, a) {
1423
1437
  key: "makeRequest",
1424
1438
  value: (function () {
1425
1439
  var _makeRequest = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(endpoint, data) {
1426
- var _window$SunuIDConfig2,
1427
- _window$SunuIDConfig3,
1440
+ var _window$SunuIDConfig4,
1441
+ _window$SunuIDConfig5,
1428
1442
  _this5 = this;
1429
1443
  var sanitizedData, endpointPath, url, retryCount, maxRetries, _loop, _ret;
1430
1444
  return _regenerator().w(function (_context11) {
@@ -1464,11 +1478,11 @@ function _unsupportedIterableToArray(r, a) {
1464
1478
  console.log('🔍 Debug makeRequest - isInitialized:', this.isInitialized);
1465
1479
 
1466
1480
  // Utiliser l'endpoint depuis la configuration si disponible
1467
- 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;
1481
+ endpointPath = ((_window$SunuIDConfig4 = window.SunuIDConfig) === null || _window$SunuIDConfig4 === void 0 || (_window$SunuIDConfig4 = _window$SunuIDConfig4.endpoints) === null || _window$SunuIDConfig4 === void 0 ? void 0 : _window$SunuIDConfig4[endpoint.replace('/', '')]) || endpoint;
1468
1482
  url = "".concat(this.config.apiUrl).concat(endpointPath); // Debug: Afficher l'URL finale
1469
1483
  console.log('🔍 URL finale construite:', url);
1470
1484
  console.log('🔍 EndpointPath:', endpointPath);
1471
- console.log('🔍 SunuIDConfig endpoints:', JSON.stringify((_window$SunuIDConfig3 = window.SunuIDConfig) === null || _window$SunuIDConfig3 === void 0 ? void 0 : _window$SunuIDConfig3.endpoints));
1485
+ console.log('🔍 SunuIDConfig endpoints:', JSON.stringify((_window$SunuIDConfig5 = window.SunuIDConfig) === null || _window$SunuIDConfig5 === void 0 ? void 0 : _window$SunuIDConfig5.endpoints));
1472
1486
 
1473
1487
  // Log de sécurité pour la requête
1474
1488
  this.logSecurityEvent('API_REQUEST_START', {