sunuid-sdk 1.0.29 → 1.0.30
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 +96 -17
- package/dist/sunuid-sdk.esm.js.map +1 -1
- package/dist/sunuid-sdk.js +96 -17
- 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.esm.js
CHANGED
|
@@ -1189,7 +1189,7 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
1189
1189
|
key: "generateCustomQRCode",
|
|
1190
1190
|
value: (function () {
|
|
1191
1191
|
var _generateCustomQRCode = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(content, label) {
|
|
1192
|
-
var
|
|
1192
|
+
var _qrContainer,
|
|
1193
1193
|
qrGeneratorUrl,
|
|
1194
1194
|
_response3,
|
|
1195
1195
|
responseData,
|
|
@@ -1203,8 +1203,8 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
1203
1203
|
console.log('🎨 Début génération QR personnalisé avec PHP...');
|
|
1204
1204
|
console.log('📄 Contenu:', content);
|
|
1205
1205
|
console.log('🏷️ Label:', label);
|
|
1206
|
-
|
|
1207
|
-
if (
|
|
1206
|
+
_qrContainer = document.getElementById('sunuid-qr-container');
|
|
1207
|
+
if (_qrContainer) {
|
|
1208
1208
|
_context9.n = 2;
|
|
1209
1209
|
break;
|
|
1210
1210
|
}
|
|
@@ -1215,7 +1215,7 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
1215
1215
|
console.log('✅ QR container trouvé');
|
|
1216
1216
|
|
|
1217
1217
|
// Nettoyer le conteneur
|
|
1218
|
-
|
|
1218
|
+
_qrContainer.innerHTML = '<div style="text-align: center; padding: 20px;"><p>Génération QR code avec PHP...</p></div>';
|
|
1219
1219
|
|
|
1220
1220
|
// Appeler l'endpoint PHP
|
|
1221
1221
|
console.log('🔄 Appel endpoint PHP...');
|
|
@@ -1268,11 +1268,11 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
1268
1268
|
this.currentQRUrl = responseData.data.dataUrl;
|
|
1269
1269
|
|
|
1270
1270
|
// Créer le conteneur avec le QR code PHP
|
|
1271
|
-
|
|
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 ");
|
|
1272
1272
|
|
|
1273
1273
|
// Afficher les instructions et le statut maintenant que le QR est prêt
|
|
1274
|
-
instructionsElement =
|
|
1275
|
-
statusElement =
|
|
1274
|
+
instructionsElement = _qrContainer.parentElement.querySelector('.sunuid-qr-instructions');
|
|
1275
|
+
statusElement = _qrContainer.parentElement.querySelector('.sunuid-qr-status');
|
|
1276
1276
|
if (instructionsElement) {
|
|
1277
1277
|
instructionsElement.style.display = 'block';
|
|
1278
1278
|
instructionsElement.classList.add('sunuid-qr-ready');
|
|
@@ -1289,7 +1289,14 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
1289
1289
|
_t6 = _context9.v;
|
|
1290
1290
|
console.error('❌ Erreur génération QR PHP:', _t6);
|
|
1291
1291
|
console.error('Stack trace:', _t6.stack);
|
|
1292
|
-
|
|
1292
|
+
|
|
1293
|
+
// Détecter les erreurs CORS spécifiquement
|
|
1294
|
+
if (_t6.message.includes('Failed to fetch') || _t6.message.includes('CORS')) {
|
|
1295
|
+
console.warn('🚫 Erreur CORS détectée, tentative de génération QR côté client...');
|
|
1296
|
+
this.generateQRCodeClientSide(content, label, qrContainer);
|
|
1297
|
+
} else {
|
|
1298
|
+
this.displayFallbackImage();
|
|
1299
|
+
}
|
|
1293
1300
|
case 8:
|
|
1294
1301
|
return _context9.a(2);
|
|
1295
1302
|
}
|
|
@@ -1301,9 +1308,81 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
1301
1308
|
return generateCustomQRCode;
|
|
1302
1309
|
}()
|
|
1303
1310
|
/**
|
|
1304
|
-
*
|
|
1311
|
+
* Générer un QR code côté client en cas d'erreur CORS
|
|
1305
1312
|
*/
|
|
1306
1313
|
)
|
|
1314
|
+
}, {
|
|
1315
|
+
key: "generateQRCodeClientSide",
|
|
1316
|
+
value: function generateQRCodeClientSide(content, label, qrContainer) {
|
|
1317
|
+
var _this4 = this;
|
|
1318
|
+
try {
|
|
1319
|
+
console.log('🎨 Génération QR côté client...');
|
|
1320
|
+
|
|
1321
|
+
// Vérifier si QRCode est disponible
|
|
1322
|
+
if (typeof QRCode === 'undefined') {
|
|
1323
|
+
console.error('❌ QRCode library non disponible');
|
|
1324
|
+
this.displayFallbackImage();
|
|
1325
|
+
return;
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
// Créer un canvas pour le QR code
|
|
1329
|
+
var canvas = document.createElement('canvas');
|
|
1330
|
+
canvas.width = 300;
|
|
1331
|
+
canvas.height = 300;
|
|
1332
|
+
var ctx = canvas.getContext('2d');
|
|
1333
|
+
|
|
1334
|
+
// Générer le QR code avec QRCode library
|
|
1335
|
+
QRCode.toCanvas(canvas, content, {
|
|
1336
|
+
width: 280,
|
|
1337
|
+
margin: 10,
|
|
1338
|
+
color: {
|
|
1339
|
+
dark: '#000000',
|
|
1340
|
+
light: '#FFFFFF'
|
|
1341
|
+
}
|
|
1342
|
+
}, function (error) {
|
|
1343
|
+
if (error) {
|
|
1344
|
+
console.error('❌ Erreur génération QR côté client:', error);
|
|
1345
|
+
_this4.displayFallbackImage();
|
|
1346
|
+
return;
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
// Ajouter le label en bas du QR code
|
|
1350
|
+
ctx.fillStyle = '#333333';
|
|
1351
|
+
ctx.font = '14px Arial';
|
|
1352
|
+
ctx.textAlign = 'center';
|
|
1353
|
+
ctx.fillText(label, 150, 295);
|
|
1354
|
+
|
|
1355
|
+
// Convertir en data URL
|
|
1356
|
+
var dataUrl = canvas.toDataURL('image/png');
|
|
1357
|
+
|
|
1358
|
+
// Stocker l'URL du QR code pour getQRCode()
|
|
1359
|
+
_this4.currentQRUrl = dataUrl;
|
|
1360
|
+
|
|
1361
|
+
// Afficher le QR code
|
|
1362
|
+
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 ");
|
|
1363
|
+
|
|
1364
|
+
// Afficher les instructions et le statut
|
|
1365
|
+
var instructionsElement = qrContainer.parentElement.querySelector('.sunuid-qr-instructions');
|
|
1366
|
+
var statusElement = qrContainer.parentElement.querySelector('.sunuid-qr-status');
|
|
1367
|
+
if (instructionsElement) {
|
|
1368
|
+
instructionsElement.style.display = 'block';
|
|
1369
|
+
instructionsElement.classList.add('sunuid-qr-ready');
|
|
1370
|
+
}
|
|
1371
|
+
if (statusElement) {
|
|
1372
|
+
statusElement.style.display = 'block';
|
|
1373
|
+
statusElement.classList.add('sunuid-qr-ready');
|
|
1374
|
+
}
|
|
1375
|
+
console.log('✅ QR code côté client généré avec succès');
|
|
1376
|
+
});
|
|
1377
|
+
} catch (error) {
|
|
1378
|
+
console.error('❌ Erreur génération QR côté client:', error);
|
|
1379
|
+
this.displayFallbackImage();
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
|
+
/**
|
|
1384
|
+
* Ajouter le logo au centre du QR code
|
|
1385
|
+
*/
|
|
1307
1386
|
}, {
|
|
1308
1387
|
key: "addLogoToCenter",
|
|
1309
1388
|
value: function addLogoToCenter(ctx, x, y, width, height) {
|
|
@@ -1402,7 +1481,7 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
1402
1481
|
}, {
|
|
1403
1482
|
key: "startAutoRefresh",
|
|
1404
1483
|
value: function startAutoRefresh(containerId, type, options) {
|
|
1405
|
-
var
|
|
1484
|
+
var _this5 = this;
|
|
1406
1485
|
if (!this.config.autoRefresh) return;
|
|
1407
1486
|
this.refreshTimer = setInterval(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1() {
|
|
1408
1487
|
var _t8;
|
|
@@ -1411,7 +1490,7 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
1411
1490
|
case 0:
|
|
1412
1491
|
_context1.p = 0;
|
|
1413
1492
|
_context1.n = 1;
|
|
1414
|
-
return
|
|
1493
|
+
return _this5.refreshQR(containerId, type, options);
|
|
1415
1494
|
case 1:
|
|
1416
1495
|
_context1.n = 3;
|
|
1417
1496
|
break;
|
|
@@ -1439,7 +1518,7 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
1439
1518
|
var _makeRequest = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(endpoint, data) {
|
|
1440
1519
|
var _window$SunuIDConfig4,
|
|
1441
1520
|
_window$SunuIDConfig5,
|
|
1442
|
-
|
|
1521
|
+
_this6 = this;
|
|
1443
1522
|
var sanitizedData, endpointPath, url, retryCount, maxRetries, _loop, _ret;
|
|
1444
1523
|
return _regenerator().w(function (_context11) {
|
|
1445
1524
|
while (1) switch (_context11.n) {
|
|
@@ -1502,7 +1581,7 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
1502
1581
|
controller = new AbortController();
|
|
1503
1582
|
timeoutId = setTimeout(function () {
|
|
1504
1583
|
return controller.abort();
|
|
1505
|
-
},
|
|
1584
|
+
}, _this6.config.requestTimeout); // Headers minimaux (API SunuID n'accepte que les headers essentiels)
|
|
1506
1585
|
headers = {
|
|
1507
1586
|
'Content-Type': 'application/json'
|
|
1508
1587
|
}; // Note: En mode sécurisé, les credentials sont dans le body
|
|
@@ -1535,7 +1614,7 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
1535
1614
|
message: errorText
|
|
1536
1615
|
};
|
|
1537
1616
|
}
|
|
1538
|
-
|
|
1617
|
+
_this6.logSecurityEvent('API_REQUEST_ERROR', {
|
|
1539
1618
|
status: _response4.status,
|
|
1540
1619
|
statusText: _response4.statusText,
|
|
1541
1620
|
error: errorData.message
|
|
@@ -1546,7 +1625,7 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
1546
1625
|
return _response4.json();
|
|
1547
1626
|
case 4:
|
|
1548
1627
|
result = _context10.v;
|
|
1549
|
-
|
|
1628
|
+
_this6.logSecurityEvent('API_REQUEST_SUCCESS', {
|
|
1550
1629
|
endpoint: endpointPath,
|
|
1551
1630
|
responseKeys: Object.keys(result)
|
|
1552
1631
|
});
|
|
@@ -1561,7 +1640,7 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
1561
1640
|
_context10.n = 7;
|
|
1562
1641
|
break;
|
|
1563
1642
|
}
|
|
1564
|
-
|
|
1643
|
+
_this6.logSecurityEvent('API_REQUEST_TIMEOUT', {
|
|
1565
1644
|
retryCount: retryCount
|
|
1566
1645
|
});
|
|
1567
1646
|
if (!(retryCount > maxRetries)) {
|
|
@@ -1576,7 +1655,7 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
1576
1655
|
_context10.n = 8;
|
|
1577
1656
|
break;
|
|
1578
1657
|
}
|
|
1579
|
-
|
|
1658
|
+
_this6.logSecurityEvent('API_REQUEST_MAX_RETRIES', {
|
|
1580
1659
|
retryCount: retryCount,
|
|
1581
1660
|
error: _t9.message
|
|
1582
1661
|
});
|