sunuid-sdk 1.0.29 → 1.0.31
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 +99 -20
- package/dist/sunuid-sdk.esm.js.map +1 -1
- package/dist/sunuid-sdk.js +99 -20
- 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
|
@@ -304,9 +304,9 @@
|
|
|
304
304
|
secureInit: false,
|
|
305
305
|
secureInitUrl: function (_window$SunuIDConfig2, _window$SunuIDConfig3) {
|
|
306
306
|
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')) {
|
|
307
|
-
return 'https://sunuid.fayma.sn/secure-init.php';
|
|
307
|
+
return 'https://api.sunuid.fayma.sn/secure-init.php';
|
|
308
308
|
}
|
|
309
|
-
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';
|
|
309
|
+
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
310
|
}(),
|
|
311
311
|
token: null
|
|
312
312
|
};
|
|
@@ -1192,7 +1192,7 @@
|
|
|
1192
1192
|
key: "generateCustomQRCode",
|
|
1193
1193
|
value: (function () {
|
|
1194
1194
|
var _generateCustomQRCode = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(content, label) {
|
|
1195
|
-
var
|
|
1195
|
+
var _qrContainer,
|
|
1196
1196
|
qrGeneratorUrl,
|
|
1197
1197
|
_response3,
|
|
1198
1198
|
responseData,
|
|
@@ -1206,8 +1206,8 @@
|
|
|
1206
1206
|
console.log('🎨 Début génération QR personnalisé avec PHP...');
|
|
1207
1207
|
console.log('📄 Contenu:', content);
|
|
1208
1208
|
console.log('🏷️ Label:', label);
|
|
1209
|
-
|
|
1210
|
-
if (
|
|
1209
|
+
_qrContainer = document.getElementById('sunuid-qr-container');
|
|
1210
|
+
if (_qrContainer) {
|
|
1211
1211
|
_context9.n = 2;
|
|
1212
1212
|
break;
|
|
1213
1213
|
}
|
|
@@ -1218,14 +1218,14 @@
|
|
|
1218
1218
|
console.log('✅ QR container trouvé');
|
|
1219
1219
|
|
|
1220
1220
|
// Nettoyer le conteneur
|
|
1221
|
-
|
|
1221
|
+
_qrContainer.innerHTML = '<div style="text-align: center; padding: 20px;"><p>Génération QR code avec PHP...</p></div>';
|
|
1222
1222
|
|
|
1223
1223
|
// Appeler l'endpoint PHP
|
|
1224
1224
|
console.log('🔄 Appel endpoint PHP...');
|
|
1225
1225
|
// Construire l'URL du QR generator de manière plus robuste
|
|
1226
1226
|
|
|
1227
1227
|
if (this.config.apiUrl.includes('api.sunuid.fayma.sn')) {
|
|
1228
|
-
qrGeneratorUrl = 'https://sunuid.fayma.sn/qr-generator.php';
|
|
1228
|
+
qrGeneratorUrl = 'https://api.sunuid.fayma.sn/qr-generator.php';
|
|
1229
1229
|
} else {
|
|
1230
1230
|
qrGeneratorUrl = this.config.apiUrl.replace('/api', '') + '/qr-generator.php';
|
|
1231
1231
|
}
|
|
@@ -1271,11 +1271,11 @@
|
|
|
1271
1271
|
this.currentQRUrl = responseData.data.dataUrl;
|
|
1272
1272
|
|
|
1273
1273
|
// Créer le conteneur avec le QR code PHP
|
|
1274
|
-
|
|
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
1275
|
|
|
1276
1276
|
// Afficher les instructions et le statut maintenant que le QR est prêt
|
|
1277
|
-
instructionsElement =
|
|
1278
|
-
statusElement =
|
|
1277
|
+
instructionsElement = _qrContainer.parentElement.querySelector('.sunuid-qr-instructions');
|
|
1278
|
+
statusElement = _qrContainer.parentElement.querySelector('.sunuid-qr-status');
|
|
1279
1279
|
if (instructionsElement) {
|
|
1280
1280
|
instructionsElement.style.display = 'block';
|
|
1281
1281
|
instructionsElement.classList.add('sunuid-qr-ready');
|
|
@@ -1292,7 +1292,14 @@
|
|
|
1292
1292
|
_t6 = _context9.v;
|
|
1293
1293
|
console.error('❌ Erreur génération QR PHP:', _t6);
|
|
1294
1294
|
console.error('Stack trace:', _t6.stack);
|
|
1295
|
-
|
|
1295
|
+
|
|
1296
|
+
// Détecter les erreurs CORS spécifiquement
|
|
1297
|
+
if (_t6.message.includes('Failed to fetch') || _t6.message.includes('CORS')) {
|
|
1298
|
+
console.warn('🚫 Erreur CORS détectée, tentative de génération QR côté client...');
|
|
1299
|
+
this.generateQRCodeClientSide(content, label, qrContainer);
|
|
1300
|
+
} else {
|
|
1301
|
+
this.displayFallbackImage();
|
|
1302
|
+
}
|
|
1296
1303
|
case 8:
|
|
1297
1304
|
return _context9.a(2);
|
|
1298
1305
|
}
|
|
@@ -1304,9 +1311,81 @@
|
|
|
1304
1311
|
return generateCustomQRCode;
|
|
1305
1312
|
}()
|
|
1306
1313
|
/**
|
|
1307
|
-
*
|
|
1314
|
+
* Générer un QR code côté client en cas d'erreur CORS
|
|
1308
1315
|
*/
|
|
1309
1316
|
)
|
|
1317
|
+
}, {
|
|
1318
|
+
key: "generateQRCodeClientSide",
|
|
1319
|
+
value: function generateQRCodeClientSide(content, label, qrContainer) {
|
|
1320
|
+
var _this4 = this;
|
|
1321
|
+
try {
|
|
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 = 300;
|
|
1335
|
+
var ctx = canvas.getContext('2d');
|
|
1336
|
+
|
|
1337
|
+
// Générer le QR code avec QRCode library
|
|
1338
|
+
QRCode.toCanvas(canvas, content, {
|
|
1339
|
+
width: 280,
|
|
1340
|
+
margin: 10,
|
|
1341
|
+
color: {
|
|
1342
|
+
dark: '#000000',
|
|
1343
|
+
light: '#FFFFFF'
|
|
1344
|
+
}
|
|
1345
|
+
}, function (error) {
|
|
1346
|
+
if (error) {
|
|
1347
|
+
console.error('❌ Erreur génération QR côté client:', error);
|
|
1348
|
+
_this4.displayFallbackImage();
|
|
1349
|
+
return;
|
|
1350
|
+
}
|
|
1351
|
+
|
|
1352
|
+
// Ajouter le label en bas du QR code
|
|
1353
|
+
ctx.fillStyle = '#333333';
|
|
1354
|
+
ctx.font = '14px Arial';
|
|
1355
|
+
ctx.textAlign = 'center';
|
|
1356
|
+
ctx.fillText(label, 150, 295);
|
|
1357
|
+
|
|
1358
|
+
// Convertir en data URL
|
|
1359
|
+
var dataUrl = canvas.toDataURL('image/png');
|
|
1360
|
+
|
|
1361
|
+
// Stocker l'URL du QR code pour getQRCode()
|
|
1362
|
+
_this4.currentQRUrl = dataUrl;
|
|
1363
|
+
|
|
1364
|
+
// Afficher le QR code
|
|
1365
|
+
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 <p style=\"margin-top: 10px; font-size: 12px; color: #666;\">G\xE9n\xE9r\xE9 c\xF4t\xE9 client (CORS)</p>\n </div>\n ");
|
|
1366
|
+
|
|
1367
|
+
// Afficher les instructions et le statut
|
|
1368
|
+
var instructionsElement = qrContainer.parentElement.querySelector('.sunuid-qr-instructions');
|
|
1369
|
+
var statusElement = qrContainer.parentElement.querySelector('.sunuid-qr-status');
|
|
1370
|
+
if (instructionsElement) {
|
|
1371
|
+
instructionsElement.style.display = 'block';
|
|
1372
|
+
instructionsElement.classList.add('sunuid-qr-ready');
|
|
1373
|
+
}
|
|
1374
|
+
if (statusElement) {
|
|
1375
|
+
statusElement.style.display = 'block';
|
|
1376
|
+
statusElement.classList.add('sunuid-qr-ready');
|
|
1377
|
+
}
|
|
1378
|
+
console.log('✅ QR code côté client généré avec succès');
|
|
1379
|
+
});
|
|
1380
|
+
} catch (error) {
|
|
1381
|
+
console.error('❌ Erreur génération QR côté client:', error);
|
|
1382
|
+
this.displayFallbackImage();
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
|
|
1386
|
+
/**
|
|
1387
|
+
* Ajouter le logo au centre du QR code
|
|
1388
|
+
*/
|
|
1310
1389
|
}, {
|
|
1311
1390
|
key: "addLogoToCenter",
|
|
1312
1391
|
value: function addLogoToCenter(ctx, x, y, width, height) {
|
|
@@ -1405,7 +1484,7 @@
|
|
|
1405
1484
|
}, {
|
|
1406
1485
|
key: "startAutoRefresh",
|
|
1407
1486
|
value: function startAutoRefresh(containerId, type, options) {
|
|
1408
|
-
var
|
|
1487
|
+
var _this5 = this;
|
|
1409
1488
|
if (!this.config.autoRefresh) return;
|
|
1410
1489
|
this.refreshTimer = setInterval(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1() {
|
|
1411
1490
|
var _t8;
|
|
@@ -1414,7 +1493,7 @@
|
|
|
1414
1493
|
case 0:
|
|
1415
1494
|
_context1.p = 0;
|
|
1416
1495
|
_context1.n = 1;
|
|
1417
|
-
return
|
|
1496
|
+
return _this5.refreshQR(containerId, type, options);
|
|
1418
1497
|
case 1:
|
|
1419
1498
|
_context1.n = 3;
|
|
1420
1499
|
break;
|
|
@@ -1442,7 +1521,7 @@
|
|
|
1442
1521
|
var _makeRequest = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(endpoint, data) {
|
|
1443
1522
|
var _window$SunuIDConfig4,
|
|
1444
1523
|
_window$SunuIDConfig5,
|
|
1445
|
-
|
|
1524
|
+
_this6 = this;
|
|
1446
1525
|
var sanitizedData, endpointPath, url, retryCount, maxRetries, _loop, _ret;
|
|
1447
1526
|
return _regenerator().w(function (_context11) {
|
|
1448
1527
|
while (1) switch (_context11.n) {
|
|
@@ -1505,7 +1584,7 @@
|
|
|
1505
1584
|
controller = new AbortController();
|
|
1506
1585
|
timeoutId = setTimeout(function () {
|
|
1507
1586
|
return controller.abort();
|
|
1508
|
-
},
|
|
1587
|
+
}, _this6.config.requestTimeout); // Headers minimaux (API SunuID n'accepte que les headers essentiels)
|
|
1509
1588
|
headers = {
|
|
1510
1589
|
'Content-Type': 'application/json'
|
|
1511
1590
|
}; // Note: En mode sécurisé, les credentials sont dans le body
|
|
@@ -1538,7 +1617,7 @@
|
|
|
1538
1617
|
message: errorText
|
|
1539
1618
|
};
|
|
1540
1619
|
}
|
|
1541
|
-
|
|
1620
|
+
_this6.logSecurityEvent('API_REQUEST_ERROR', {
|
|
1542
1621
|
status: _response4.status,
|
|
1543
1622
|
statusText: _response4.statusText,
|
|
1544
1623
|
error: errorData.message
|
|
@@ -1549,7 +1628,7 @@
|
|
|
1549
1628
|
return _response4.json();
|
|
1550
1629
|
case 4:
|
|
1551
1630
|
result = _context10.v;
|
|
1552
|
-
|
|
1631
|
+
_this6.logSecurityEvent('API_REQUEST_SUCCESS', {
|
|
1553
1632
|
endpoint: endpointPath,
|
|
1554
1633
|
responseKeys: Object.keys(result)
|
|
1555
1634
|
});
|
|
@@ -1564,7 +1643,7 @@
|
|
|
1564
1643
|
_context10.n = 7;
|
|
1565
1644
|
break;
|
|
1566
1645
|
}
|
|
1567
|
-
|
|
1646
|
+
_this6.logSecurityEvent('API_REQUEST_TIMEOUT', {
|
|
1568
1647
|
retryCount: retryCount
|
|
1569
1648
|
});
|
|
1570
1649
|
if (!(retryCount > maxRetries)) {
|
|
@@ -1579,7 +1658,7 @@
|
|
|
1579
1658
|
_context10.n = 8;
|
|
1580
1659
|
break;
|
|
1581
1660
|
}
|
|
1582
|
-
|
|
1661
|
+
_this6.logSecurityEvent('API_REQUEST_MAX_RETRIES', {
|
|
1583
1662
|
retryCount: retryCount,
|
|
1584
1663
|
error: _t9.message
|
|
1585
1664
|
});
|