sunuid-sdk 1.0.28 → 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 +115 -24
- package/dist/sunuid-sdk.esm.js.map +1 -1
- package/dist/sunuid-sdk.js +115 -24
- 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
|
@@ -271,7 +271,7 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
271
271
|
* @license MIT
|
|
272
272
|
*/
|
|
273
273
|
|
|
274
|
-
(function (window, _window$SunuIDConfig
|
|
274
|
+
(function (window, _window$SunuIDConfig) {
|
|
275
275
|
|
|
276
276
|
// Configuration par défaut
|
|
277
277
|
var DEFAULT_CONFIG = {
|
|
@@ -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:
|
|
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
|
|
|
@@ -1184,7 +1189,7 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
1184
1189
|
key: "generateCustomQRCode",
|
|
1185
1190
|
value: (function () {
|
|
1186
1191
|
var _generateCustomQRCode = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(content, label) {
|
|
1187
|
-
var
|
|
1192
|
+
var _qrContainer,
|
|
1188
1193
|
qrGeneratorUrl,
|
|
1189
1194
|
_response3,
|
|
1190
1195
|
responseData,
|
|
@@ -1198,8 +1203,8 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
1198
1203
|
console.log('🎨 Début génération QR personnalisé avec PHP...');
|
|
1199
1204
|
console.log('📄 Contenu:', content);
|
|
1200
1205
|
console.log('🏷️ Label:', label);
|
|
1201
|
-
|
|
1202
|
-
if (
|
|
1206
|
+
_qrContainer = document.getElementById('sunuid-qr-container');
|
|
1207
|
+
if (_qrContainer) {
|
|
1203
1208
|
_context9.n = 2;
|
|
1204
1209
|
break;
|
|
1205
1210
|
}
|
|
@@ -1210,11 +1215,18 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
1210
1215
|
console.log('✅ QR container trouvé');
|
|
1211
1216
|
|
|
1212
1217
|
// Nettoyer le conteneur
|
|
1213
|
-
|
|
1218
|
+
_qrContainer.innerHTML = '<div style="text-align: center; padding: 20px;"><p>Génération QR code avec PHP...</p></div>';
|
|
1214
1219
|
|
|
1215
1220
|
// Appeler l'endpoint PHP
|
|
1216
1221
|
console.log('🔄 Appel endpoint PHP...');
|
|
1217
|
-
|
|
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);
|
|
1218
1230
|
_context9.n = 3;
|
|
1219
1231
|
return fetch(qrGeneratorUrl, {
|
|
1220
1232
|
method: 'POST',
|
|
@@ -1256,11 +1268,11 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
1256
1268
|
this.currentQRUrl = responseData.data.dataUrl;
|
|
1257
1269
|
|
|
1258
1270
|
// Créer le conteneur avec le QR code PHP
|
|
1259
|
-
|
|
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 ");
|
|
1260
1272
|
|
|
1261
1273
|
// Afficher les instructions et le statut maintenant que le QR est prêt
|
|
1262
|
-
instructionsElement =
|
|
1263
|
-
statusElement =
|
|
1274
|
+
instructionsElement = _qrContainer.parentElement.querySelector('.sunuid-qr-instructions');
|
|
1275
|
+
statusElement = _qrContainer.parentElement.querySelector('.sunuid-qr-status');
|
|
1264
1276
|
if (instructionsElement) {
|
|
1265
1277
|
instructionsElement.style.display = 'block';
|
|
1266
1278
|
instructionsElement.classList.add('sunuid-qr-ready');
|
|
@@ -1277,7 +1289,14 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
1277
1289
|
_t6 = _context9.v;
|
|
1278
1290
|
console.error('❌ Erreur génération QR PHP:', _t6);
|
|
1279
1291
|
console.error('Stack trace:', _t6.stack);
|
|
1280
|
-
|
|
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
|
+
}
|
|
1281
1300
|
case 8:
|
|
1282
1301
|
return _context9.a(2);
|
|
1283
1302
|
}
|
|
@@ -1289,9 +1308,81 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
1289
1308
|
return generateCustomQRCode;
|
|
1290
1309
|
}()
|
|
1291
1310
|
/**
|
|
1292
|
-
*
|
|
1311
|
+
* Générer un QR code côté client en cas d'erreur CORS
|
|
1293
1312
|
*/
|
|
1294
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
|
+
*/
|
|
1295
1386
|
}, {
|
|
1296
1387
|
key: "addLogoToCenter",
|
|
1297
1388
|
value: function addLogoToCenter(ctx, x, y, width, height) {
|
|
@@ -1390,7 +1481,7 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
1390
1481
|
}, {
|
|
1391
1482
|
key: "startAutoRefresh",
|
|
1392
1483
|
value: function startAutoRefresh(containerId, type, options) {
|
|
1393
|
-
var
|
|
1484
|
+
var _this5 = this;
|
|
1394
1485
|
if (!this.config.autoRefresh) return;
|
|
1395
1486
|
this.refreshTimer = setInterval(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1() {
|
|
1396
1487
|
var _t8;
|
|
@@ -1399,7 +1490,7 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
1399
1490
|
case 0:
|
|
1400
1491
|
_context1.p = 0;
|
|
1401
1492
|
_context1.n = 1;
|
|
1402
|
-
return
|
|
1493
|
+
return _this5.refreshQR(containerId, type, options);
|
|
1403
1494
|
case 1:
|
|
1404
1495
|
_context1.n = 3;
|
|
1405
1496
|
break;
|
|
@@ -1425,9 +1516,9 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
1425
1516
|
key: "makeRequest",
|
|
1426
1517
|
value: (function () {
|
|
1427
1518
|
var _makeRequest = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(endpoint, data) {
|
|
1428
|
-
var _window$
|
|
1429
|
-
_window$
|
|
1430
|
-
|
|
1519
|
+
var _window$SunuIDConfig4,
|
|
1520
|
+
_window$SunuIDConfig5,
|
|
1521
|
+
_this6 = this;
|
|
1431
1522
|
var sanitizedData, endpointPath, url, retryCount, maxRetries, _loop, _ret;
|
|
1432
1523
|
return _regenerator().w(function (_context11) {
|
|
1433
1524
|
while (1) switch (_context11.n) {
|
|
@@ -1466,11 +1557,11 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
1466
1557
|
console.log('🔍 Debug makeRequest - isInitialized:', this.isInitialized);
|
|
1467
1558
|
|
|
1468
1559
|
// Utiliser l'endpoint depuis la configuration si disponible
|
|
1469
|
-
endpointPath = ((_window$
|
|
1560
|
+
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;
|
|
1470
1561
|
url = "".concat(this.config.apiUrl).concat(endpointPath); // Debug: Afficher l'URL finale
|
|
1471
1562
|
console.log('🔍 URL finale construite:', url);
|
|
1472
1563
|
console.log('🔍 EndpointPath:', endpointPath);
|
|
1473
|
-
console.log('🔍 SunuIDConfig endpoints:', JSON.stringify((_window$
|
|
1564
|
+
console.log('🔍 SunuIDConfig endpoints:', JSON.stringify((_window$SunuIDConfig5 = window.SunuIDConfig) === null || _window$SunuIDConfig5 === void 0 ? void 0 : _window$SunuIDConfig5.endpoints));
|
|
1474
1565
|
|
|
1475
1566
|
// Log de sécurité pour la requête
|
|
1476
1567
|
this.logSecurityEvent('API_REQUEST_START', {
|
|
@@ -1490,7 +1581,7 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
1490
1581
|
controller = new AbortController();
|
|
1491
1582
|
timeoutId = setTimeout(function () {
|
|
1492
1583
|
return controller.abort();
|
|
1493
|
-
},
|
|
1584
|
+
}, _this6.config.requestTimeout); // Headers minimaux (API SunuID n'accepte que les headers essentiels)
|
|
1494
1585
|
headers = {
|
|
1495
1586
|
'Content-Type': 'application/json'
|
|
1496
1587
|
}; // Note: En mode sécurisé, les credentials sont dans le body
|
|
@@ -1523,7 +1614,7 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
1523
1614
|
message: errorText
|
|
1524
1615
|
};
|
|
1525
1616
|
}
|
|
1526
|
-
|
|
1617
|
+
_this6.logSecurityEvent('API_REQUEST_ERROR', {
|
|
1527
1618
|
status: _response4.status,
|
|
1528
1619
|
statusText: _response4.statusText,
|
|
1529
1620
|
error: errorData.message
|
|
@@ -1534,7 +1625,7 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
1534
1625
|
return _response4.json();
|
|
1535
1626
|
case 4:
|
|
1536
1627
|
result = _context10.v;
|
|
1537
|
-
|
|
1628
|
+
_this6.logSecurityEvent('API_REQUEST_SUCCESS', {
|
|
1538
1629
|
endpoint: endpointPath,
|
|
1539
1630
|
responseKeys: Object.keys(result)
|
|
1540
1631
|
});
|
|
@@ -1549,7 +1640,7 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
1549
1640
|
_context10.n = 7;
|
|
1550
1641
|
break;
|
|
1551
1642
|
}
|
|
1552
|
-
|
|
1643
|
+
_this6.logSecurityEvent('API_REQUEST_TIMEOUT', {
|
|
1553
1644
|
retryCount: retryCount
|
|
1554
1645
|
});
|
|
1555
1646
|
if (!(retryCount > maxRetries)) {
|
|
@@ -1564,7 +1655,7 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
1564
1655
|
_context10.n = 8;
|
|
1565
1656
|
break;
|
|
1566
1657
|
}
|
|
1567
|
-
|
|
1658
|
+
_this6.logSecurityEvent('API_REQUEST_MAX_RETRIES', {
|
|
1568
1659
|
retryCount: retryCount,
|
|
1569
1660
|
error: _t9.message
|
|
1570
1661
|
});
|