sunuid-sdk 1.0.18 → 1.0.20
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 +142 -178
- package/dist/sunuid-sdk.esm.js.map +1 -1
- package/dist/sunuid-sdk.js +142 -178
- package/dist/sunuid-sdk.js.map +1 -1
- package/dist/sunuid-sdk.min.js +3 -3
- package/dist/sunuid-sdk.min.js.map +1 -1
- package/package.json +1 -1
package/dist/sunuid-sdk.esm.js
CHANGED
|
@@ -204,6 +204,8 @@ function _toPropertyKey(t) {
|
|
|
204
204
|
apiUrl: ((_window$SunuIDConfig = window.SunuIDConfig) === null || _window$SunuIDConfig === void 0 ? void 0 : _window$SunuIDConfig.apiUrl) || 'https://api.sunuid.fayma.sn',
|
|
205
205
|
clientId: null,
|
|
206
206
|
secretId: null,
|
|
207
|
+
type: 1,
|
|
208
|
+
// Type par défaut (1 = authentification)
|
|
207
209
|
theme: 'light',
|
|
208
210
|
language: 'fr',
|
|
209
211
|
autoRefresh: true,
|
|
@@ -241,12 +243,12 @@ function _toPropertyKey(t) {
|
|
|
241
243
|
}
|
|
242
244
|
|
|
243
245
|
/**
|
|
244
|
-
* Générer un QR code
|
|
246
|
+
* Générer un QR code avec le type configuré
|
|
245
247
|
*/
|
|
246
248
|
}, {
|
|
247
|
-
key: "
|
|
249
|
+
key: "generateQR",
|
|
248
250
|
value: (function () {
|
|
249
|
-
var
|
|
251
|
+
var _generateQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(containerId) {
|
|
250
252
|
var options,
|
|
251
253
|
response,
|
|
252
254
|
imageBaseUrl,
|
|
@@ -266,7 +268,7 @@ function _toPropertyKey(t) {
|
|
|
266
268
|
_context.p = 1;
|
|
267
269
|
_context.n = 2;
|
|
268
270
|
return this.makeRequest('/qr-generate', _objectSpread2({
|
|
269
|
-
type:
|
|
271
|
+
type: this.config.type
|
|
270
272
|
}, options));
|
|
271
273
|
case 2:
|
|
272
274
|
response = _context.v;
|
|
@@ -277,8 +279,8 @@ function _toPropertyKey(t) {
|
|
|
277
279
|
// Construire l'URL complète de l'image QR avec la base URL pour les images
|
|
278
280
|
imageBaseUrl = 'https://sunuid.fayma.sn';
|
|
279
281
|
qrImageUrl = "".concat(imageBaseUrl).concat(response.data.qrcode);
|
|
280
|
-
this.displayQRCode(containerId, qrImageUrl,
|
|
281
|
-
this.startAutoRefresh(containerId,
|
|
282
|
+
this.displayQRCode(containerId, qrImageUrl, this.config.type, options);
|
|
283
|
+
this.startAutoRefresh(containerId, this.config.type, options);
|
|
282
284
|
return _context.a(2, _objectSpread2(_objectSpread2({}, response.data), {}, {
|
|
283
285
|
qrCodeUrl: qrImageUrl,
|
|
284
286
|
sessionId: response.data.service_id
|
|
@@ -292,27 +294,27 @@ function _toPropertyKey(t) {
|
|
|
292
294
|
_context.p = 5;
|
|
293
295
|
_t = _context.v;
|
|
294
296
|
console.error('Erreur API détectée:', _t.message);
|
|
295
|
-
console.log('Affichage du message "Service non disponible" pour
|
|
296
|
-
this.displayServiceUnavailable(containerId,
|
|
297
|
+
console.log('Affichage du message "Service non disponible" pour type ' + this.config.type);
|
|
298
|
+
this.displayServiceUnavailable(containerId, this.config.type);
|
|
297
299
|
throw new Error('Service non disponible');
|
|
298
300
|
case 6:
|
|
299
301
|
return _context.a(2);
|
|
300
302
|
}
|
|
301
303
|
}, _callee, this, [[1, 5]]);
|
|
302
304
|
}));
|
|
303
|
-
function
|
|
304
|
-
return
|
|
305
|
+
function generateQR(_x) {
|
|
306
|
+
return _generateQR.apply(this, arguments);
|
|
305
307
|
}
|
|
306
|
-
return
|
|
308
|
+
return generateQR;
|
|
307
309
|
}()
|
|
308
310
|
/**
|
|
309
|
-
* Générer un QR code
|
|
311
|
+
* Générer un QR code avec un type personnalisé
|
|
310
312
|
*/
|
|
311
313
|
)
|
|
312
314
|
}, {
|
|
313
|
-
key: "
|
|
315
|
+
key: "generateCustomQR",
|
|
314
316
|
value: (function () {
|
|
315
|
-
var
|
|
317
|
+
var _generateCustomQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(containerId, type) {
|
|
316
318
|
var options,
|
|
317
319
|
response,
|
|
318
320
|
imageBaseUrl,
|
|
@@ -322,7 +324,7 @@ function _toPropertyKey(t) {
|
|
|
322
324
|
return _regenerator().w(function (_context2) {
|
|
323
325
|
while (1) switch (_context2.p = _context2.n) {
|
|
324
326
|
case 0:
|
|
325
|
-
options = _args2.length >
|
|
327
|
+
options = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : {};
|
|
326
328
|
if (this.isInitialized) {
|
|
327
329
|
_context2.n = 1;
|
|
328
330
|
break;
|
|
@@ -332,7 +334,7 @@ function _toPropertyKey(t) {
|
|
|
332
334
|
_context2.p = 1;
|
|
333
335
|
_context2.n = 2;
|
|
334
336
|
return this.makeRequest('/qr-generate', _objectSpread2({
|
|
335
|
-
type:
|
|
337
|
+
type: type
|
|
336
338
|
}, options));
|
|
337
339
|
case 2:
|
|
338
340
|
response = _context2.v;
|
|
@@ -343,14 +345,14 @@ function _toPropertyKey(t) {
|
|
|
343
345
|
// Construire l'URL complète de l'image QR avec la base URL pour les images
|
|
344
346
|
imageBaseUrl = 'https://sunuid.fayma.sn';
|
|
345
347
|
qrImageUrl = "".concat(imageBaseUrl).concat(response.data.qrcode);
|
|
346
|
-
this.displayQRCode(containerId, qrImageUrl,
|
|
347
|
-
this.startAutoRefresh(containerId,
|
|
348
|
+
this.displayQRCode(containerId, qrImageUrl, type, options);
|
|
349
|
+
this.startAutoRefresh(containerId, type, options);
|
|
348
350
|
return _context2.a(2, _objectSpread2(_objectSpread2({}, response.data), {}, {
|
|
349
351
|
qrCodeUrl: qrImageUrl,
|
|
350
352
|
sessionId: response.data.service_id
|
|
351
353
|
}));
|
|
352
354
|
case 3:
|
|
353
|
-
throw new Error(response.message || 'Erreur lors de la génération du QR code
|
|
355
|
+
throw new Error(response.message || 'Erreur lors de la génération du QR code');
|
|
354
356
|
case 4:
|
|
355
357
|
_context2.n = 6;
|
|
356
358
|
break;
|
|
@@ -358,131 +360,118 @@ function _toPropertyKey(t) {
|
|
|
358
360
|
_context2.p = 5;
|
|
359
361
|
_t2 = _context2.v;
|
|
360
362
|
console.error('Erreur API détectée:', _t2.message);
|
|
361
|
-
console.log('Affichage du message "Service non disponible" pour
|
|
362
|
-
this.displayServiceUnavailable(containerId,
|
|
363
|
+
console.log('Affichage du message "Service non disponible" pour type ' + type);
|
|
364
|
+
this.displayServiceUnavailable(containerId, type);
|
|
363
365
|
throw new Error('Service non disponible');
|
|
364
366
|
case 6:
|
|
365
367
|
return _context2.a(2);
|
|
366
368
|
}
|
|
367
369
|
}, _callee2, this, [[1, 5]]);
|
|
368
370
|
}));
|
|
369
|
-
function
|
|
370
|
-
return
|
|
371
|
+
function generateCustomQR(_x2, _x3) {
|
|
372
|
+
return _generateCustomQR.apply(this, arguments);
|
|
371
373
|
}
|
|
372
|
-
return
|
|
373
|
-
}()
|
|
374
|
-
/**
|
|
375
|
-
* Générer un QR code avec un type personnalisé
|
|
376
|
-
*/
|
|
374
|
+
return generateCustomQR;
|
|
375
|
+
}() // Alias pour maintenir la compatibilité
|
|
377
376
|
)
|
|
378
377
|
}, {
|
|
379
|
-
key: "
|
|
380
|
-
value:
|
|
381
|
-
var
|
|
378
|
+
key: "generateAuthQR",
|
|
379
|
+
value: function () {
|
|
380
|
+
var _generateAuthQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(containerId) {
|
|
382
381
|
var options,
|
|
383
|
-
|
|
384
|
-
imageBaseUrl,
|
|
385
|
-
qrImageUrl,
|
|
386
|
-
_args3 = arguments,
|
|
387
|
-
_t3;
|
|
382
|
+
_args3 = arguments;
|
|
388
383
|
return _regenerator().w(function (_context3) {
|
|
389
|
-
while (1) switch (_context3.
|
|
384
|
+
while (1) switch (_context3.n) {
|
|
390
385
|
case 0:
|
|
391
|
-
options = _args3.length >
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
386
|
+
options = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {};
|
|
387
|
+
return _context3.a(2, this.generateQR(containerId, options));
|
|
388
|
+
}
|
|
389
|
+
}, _callee3, this);
|
|
390
|
+
}));
|
|
391
|
+
function generateAuthQR(_x4) {
|
|
392
|
+
return _generateAuthQR.apply(this, arguments);
|
|
393
|
+
}
|
|
394
|
+
return generateAuthQR;
|
|
395
|
+
}()
|
|
396
|
+
}, {
|
|
397
|
+
key: "generateKYCQR",
|
|
398
|
+
value: function () {
|
|
399
|
+
var _generateKYCQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(containerId) {
|
|
400
|
+
var options,
|
|
401
|
+
originalType,
|
|
402
|
+
_args4 = arguments;
|
|
403
|
+
return _regenerator().w(function (_context4) {
|
|
404
|
+
while (1) switch (_context4.p = _context4.n) {
|
|
405
|
+
case 0:
|
|
406
|
+
options = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
|
|
407
|
+
// Sauvegarder le type actuel
|
|
408
|
+
originalType = this.config.type; // Changer temporairement le type pour KYC
|
|
409
|
+
this.config.type = 2;
|
|
410
|
+
_context4.p = 1;
|
|
411
|
+
_context4.n = 2;
|
|
412
|
+
return this.generateQR(containerId, options);
|
|
403
413
|
case 2:
|
|
404
|
-
|
|
405
|
-
if (!response.success) {
|
|
406
|
-
_context3.n = 3;
|
|
407
|
-
break;
|
|
408
|
-
}
|
|
409
|
-
// Construire l'URL complète de l'image QR avec la base URL pour les images
|
|
410
|
-
imageBaseUrl = 'https://sunuid.fayma.sn';
|
|
411
|
-
qrImageUrl = "".concat(imageBaseUrl).concat(response.data.qrcode);
|
|
412
|
-
this.displayQRCode(containerId, qrImageUrl, type, options);
|
|
413
|
-
this.startAutoRefresh(containerId, type, options);
|
|
414
|
-
return _context3.a(2, _objectSpread2(_objectSpread2({}, response.data), {}, {
|
|
415
|
-
qrCodeUrl: qrImageUrl,
|
|
416
|
-
sessionId: response.data.service_id
|
|
417
|
-
}));
|
|
414
|
+
return _context4.a(2, _context4.v);
|
|
418
415
|
case 3:
|
|
419
|
-
|
|
416
|
+
_context4.p = 3;
|
|
417
|
+
// Restaurer le type original
|
|
418
|
+
this.config.type = originalType;
|
|
419
|
+
return _context4.f(3);
|
|
420
420
|
case 4:
|
|
421
|
-
|
|
422
|
-
break;
|
|
423
|
-
case 5:
|
|
424
|
-
_context3.p = 5;
|
|
425
|
-
_t3 = _context3.v;
|
|
426
|
-
console.error('Erreur API détectée:', _t3.message);
|
|
427
|
-
console.log('Affichage du message "Service non disponible" pour type ' + type);
|
|
428
|
-
this.displayServiceUnavailable(containerId, type);
|
|
429
|
-
throw new Error('Service non disponible');
|
|
430
|
-
case 6:
|
|
431
|
-
return _context3.a(2);
|
|
421
|
+
return _context4.a(2);
|
|
432
422
|
}
|
|
433
|
-
},
|
|
423
|
+
}, _callee4, this, [[1,, 3, 4]]);
|
|
434
424
|
}));
|
|
435
|
-
function
|
|
436
|
-
return
|
|
425
|
+
function generateKYCQR(_x5) {
|
|
426
|
+
return _generateKYCQR.apply(this, arguments);
|
|
437
427
|
}
|
|
438
|
-
return
|
|
428
|
+
return generateKYCQR;
|
|
439
429
|
}()
|
|
440
430
|
/**
|
|
441
431
|
* Vérifier le statut d'un QR code
|
|
442
432
|
*/
|
|
443
|
-
)
|
|
444
433
|
}, {
|
|
445
434
|
key: "checkQRStatus",
|
|
446
435
|
value: (function () {
|
|
447
|
-
var _checkQRStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
448
|
-
var response,
|
|
449
|
-
return _regenerator().w(function (
|
|
450
|
-
while (1) switch (
|
|
436
|
+
var _checkQRStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(sessionId) {
|
|
437
|
+
var response, _t3;
|
|
438
|
+
return _regenerator().w(function (_context5) {
|
|
439
|
+
while (1) switch (_context5.p = _context5.n) {
|
|
451
440
|
case 0:
|
|
452
441
|
if (this.isInitialized) {
|
|
453
|
-
|
|
442
|
+
_context5.n = 1;
|
|
454
443
|
break;
|
|
455
444
|
}
|
|
456
445
|
throw new Error('SunuID: SDK non initialisé');
|
|
457
446
|
case 1:
|
|
458
|
-
|
|
459
|
-
|
|
447
|
+
_context5.p = 1;
|
|
448
|
+
_context5.n = 2;
|
|
460
449
|
return this.makeRequest('/qr-status', {
|
|
461
450
|
serviceId: sessionId
|
|
462
451
|
});
|
|
463
452
|
case 2:
|
|
464
|
-
response =
|
|
453
|
+
response = _context5.v;
|
|
465
454
|
if (!response.success) {
|
|
466
|
-
|
|
455
|
+
_context5.n = 3;
|
|
467
456
|
break;
|
|
468
457
|
}
|
|
469
|
-
return
|
|
458
|
+
return _context5.a(2, response.data);
|
|
470
459
|
case 3:
|
|
471
460
|
throw new Error(response.message || 'Erreur lors de la vérification du statut');
|
|
472
461
|
case 4:
|
|
473
|
-
|
|
462
|
+
_context5.n = 6;
|
|
474
463
|
break;
|
|
475
464
|
case 5:
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
this.handleError(
|
|
479
|
-
throw
|
|
465
|
+
_context5.p = 5;
|
|
466
|
+
_t3 = _context5.v;
|
|
467
|
+
this.handleError(_t3);
|
|
468
|
+
throw _t3;
|
|
480
469
|
case 6:
|
|
481
|
-
return
|
|
470
|
+
return _context5.a(2);
|
|
482
471
|
}
|
|
483
|
-
},
|
|
472
|
+
}, _callee5, this, [[1, 5]]);
|
|
484
473
|
}));
|
|
485
|
-
function checkQRStatus(
|
|
474
|
+
function checkQRStatus(_x6) {
|
|
486
475
|
return _checkQRStatus.apply(this, arguments);
|
|
487
476
|
}
|
|
488
477
|
return checkQRStatus;
|
|
@@ -506,7 +495,7 @@ function _toPropertyKey(t) {
|
|
|
506
495
|
// Créer l'élément QR code
|
|
507
496
|
var qrElement = document.createElement('div');
|
|
508
497
|
qrElement.className = 'sunuid-qr-code';
|
|
509
|
-
qrElement.innerHTML = "\n <div class=\"sunuid-qr-header\">\n <h3>".concat(type === 1 ? 'Authentification' : type === 2 ? 'Vérification KYC' : 'Service Type ' + type, "</h3>\n </div>\n <div class=\"sunuid-qr-image\">\n <img src=\"").concat(qrUrl, "\" alt=\"QR Code SunuID\" style=\"max-width: 300px; height: auto;\">\n </div>\n <div class=\"sunuid-qr-instructions\">\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\">\n <p>En attente de scan...</p>\n </div>\n ");
|
|
498
|
+
qrElement.innerHTML = "\n <div class=\"sunuid-qr-header\">\n <h3>".concat(type === 1 ? 'Authentification' : type === 2 ? 'Vérification KYC' : type === 3 ? 'Service Type 3' : 'Service Type ' + type, "</h3>\n </div>\n <div class=\"sunuid-qr-image\">\n <img src=\"").concat(qrUrl, "\" alt=\"QR Code SunuID\" style=\"max-width: 300px; height: auto;\">\n </div>\n <div class=\"sunuid-qr-instructions\">\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\">\n <p>En attente de scan...</p>\n </div>\n ");
|
|
510
499
|
container.appendChild(qrElement);
|
|
511
500
|
|
|
512
501
|
// Appliquer le thème
|
|
@@ -534,61 +523,33 @@ function _toPropertyKey(t) {
|
|
|
534
523
|
}, {
|
|
535
524
|
key: "refreshQR",
|
|
536
525
|
value: (function () {
|
|
537
|
-
var _refreshQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
526
|
+
var _refreshQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(containerId) {
|
|
538
527
|
var options,
|
|
539
528
|
result,
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
return _regenerator().w(function (_context5) {
|
|
545
|
-
while (1) switch (_context5.p = _context5.n) {
|
|
529
|
+
_args6 = arguments,
|
|
530
|
+
_t4;
|
|
531
|
+
return _regenerator().w(function (_context6) {
|
|
532
|
+
while (1) switch (_context6.p = _context6.n) {
|
|
546
533
|
case 0:
|
|
547
|
-
options =
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
break;
|
|
552
|
-
}
|
|
553
|
-
_context5.n = 2;
|
|
554
|
-
return this.generateAuthQR(containerId, options);
|
|
534
|
+
options = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : {};
|
|
535
|
+
_context6.p = 1;
|
|
536
|
+
_context6.n = 2;
|
|
537
|
+
return this.generateQR(containerId, options);
|
|
555
538
|
case 2:
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
break;
|
|
539
|
+
result = _context6.v;
|
|
540
|
+
return _context6.a(2, result);
|
|
559
541
|
case 3:
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
return this.generateKYCQR(containerId, options);
|
|
542
|
+
_context6.p = 3;
|
|
543
|
+
_t4 = _context6.v;
|
|
544
|
+
console.error('Erreur lors du rafraîchissement:', _t4.message);
|
|
545
|
+
this.displayServiceUnavailable(containerId, this.config.type);
|
|
546
|
+
throw _t4;
|
|
566
547
|
case 4:
|
|
567
|
-
|
|
568
|
-
_context5.n = 7;
|
|
569
|
-
break;
|
|
570
|
-
case 5:
|
|
571
|
-
_context5.n = 6;
|
|
572
|
-
return this.generateCustomQR(containerId, type, options);
|
|
573
|
-
case 6:
|
|
574
|
-
_t6 = _context5.v;
|
|
575
|
-
case 7:
|
|
576
|
-
_t5 = _t6;
|
|
577
|
-
case 8:
|
|
578
|
-
result = _t5;
|
|
579
|
-
return _context5.a(2, result);
|
|
580
|
-
case 9:
|
|
581
|
-
_context5.p = 9;
|
|
582
|
-
_t7 = _context5.v;
|
|
583
|
-
console.error('Erreur lors du rafraîchissement:', _t7.message);
|
|
584
|
-
this.displayServiceUnavailable(containerId, type);
|
|
585
|
-
throw _t7;
|
|
586
|
-
case 10:
|
|
587
|
-
return _context5.a(2);
|
|
548
|
+
return _context6.a(2);
|
|
588
549
|
}
|
|
589
|
-
},
|
|
550
|
+
}, _callee6, this, [[1, 3]]);
|
|
590
551
|
}));
|
|
591
|
-
function refreshQR(
|
|
552
|
+
function refreshQR(_x7) {
|
|
592
553
|
return _refreshQR.apply(this, arguments);
|
|
593
554
|
}
|
|
594
555
|
return refreshQR;
|
|
@@ -602,25 +563,25 @@ function _toPropertyKey(t) {
|
|
|
602
563
|
value: function startAutoRefresh(containerId, type, options) {
|
|
603
564
|
var _this = this;
|
|
604
565
|
if (!this.config.autoRefresh) return;
|
|
605
|
-
this.refreshTimer = setInterval(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
606
|
-
var
|
|
607
|
-
return _regenerator().w(function (
|
|
608
|
-
while (1) switch (
|
|
566
|
+
this.refreshTimer = setInterval(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7() {
|
|
567
|
+
var _t5;
|
|
568
|
+
return _regenerator().w(function (_context7) {
|
|
569
|
+
while (1) switch (_context7.p = _context7.n) {
|
|
609
570
|
case 0:
|
|
610
|
-
|
|
611
|
-
|
|
571
|
+
_context7.p = 0;
|
|
572
|
+
_context7.n = 1;
|
|
612
573
|
return _this.refreshQR(containerId, type, options);
|
|
613
574
|
case 1:
|
|
614
|
-
|
|
575
|
+
_context7.n = 3;
|
|
615
576
|
break;
|
|
616
577
|
case 2:
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
console.warn('Erreur lors du rafraîchissement automatique:',
|
|
578
|
+
_context7.p = 2;
|
|
579
|
+
_t5 = _context7.v;
|
|
580
|
+
console.warn('Erreur lors du rafraîchissement automatique:', _t5);
|
|
620
581
|
case 3:
|
|
621
|
-
return
|
|
582
|
+
return _context7.a(2);
|
|
622
583
|
}
|
|
623
|
-
},
|
|
584
|
+
}, _callee7, null, [[0, 2]]);
|
|
624
585
|
})), this.config.refreshInterval);
|
|
625
586
|
}
|
|
626
587
|
|
|
@@ -634,17 +595,20 @@ function _toPropertyKey(t) {
|
|
|
634
595
|
}, {
|
|
635
596
|
key: "makeRequest",
|
|
636
597
|
value: (function () {
|
|
637
|
-
var _makeRequest = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
598
|
+
var _makeRequest = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(endpoint, data) {
|
|
638
599
|
var _window$SunuIDConfig2;
|
|
639
|
-
var endpointPath, url, response, errorText, errorData, result,
|
|
640
|
-
return _regenerator().w(function (
|
|
641
|
-
while (1) switch (
|
|
600
|
+
var endpointPath, url, response, errorText, errorData, result, _t6;
|
|
601
|
+
return _regenerator().w(function (_context8) {
|
|
602
|
+
while (1) switch (_context8.p = _context8.n) {
|
|
642
603
|
case 0:
|
|
643
604
|
// Utiliser l'endpoint depuis la configuration si disponible
|
|
644
605
|
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;
|
|
645
|
-
url = "".concat(this.config.apiUrl).concat(endpointPath);
|
|
646
|
-
|
|
647
|
-
|
|
606
|
+
url = "".concat(this.config.apiUrl).concat(endpointPath); // Log pour déboguer l'envoi du type
|
|
607
|
+
if (data.type !== undefined) {
|
|
608
|
+
console.log("\uD83C\uDF10 Envoi requ\xEAte API - Type: ".concat(data.type, ", Endpoint: ").concat(endpoint));
|
|
609
|
+
}
|
|
610
|
+
_context8.p = 1;
|
|
611
|
+
_context8.n = 2;
|
|
648
612
|
return fetch(url, {
|
|
649
613
|
method: 'POST',
|
|
650
614
|
headers: {
|
|
@@ -658,15 +622,15 @@ function _toPropertyKey(t) {
|
|
|
658
622
|
}))
|
|
659
623
|
});
|
|
660
624
|
case 2:
|
|
661
|
-
response =
|
|
625
|
+
response = _context8.v;
|
|
662
626
|
if (response.ok) {
|
|
663
|
-
|
|
627
|
+
_context8.n = 4;
|
|
664
628
|
break;
|
|
665
629
|
}
|
|
666
|
-
|
|
630
|
+
_context8.n = 3;
|
|
667
631
|
return response.text();
|
|
668
632
|
case 3:
|
|
669
|
-
errorText =
|
|
633
|
+
errorText = _context8.v;
|
|
670
634
|
try {
|
|
671
635
|
errorData = JSON.parse(errorText);
|
|
672
636
|
} catch (e) {
|
|
@@ -676,20 +640,20 @@ function _toPropertyKey(t) {
|
|
|
676
640
|
}
|
|
677
641
|
throw new Error(errorData.message || "Erreur HTTP: ".concat(response.status));
|
|
678
642
|
case 4:
|
|
679
|
-
|
|
643
|
+
_context8.n = 5;
|
|
680
644
|
return response.json();
|
|
681
645
|
case 5:
|
|
682
|
-
result =
|
|
683
|
-
return
|
|
646
|
+
result = _context8.v;
|
|
647
|
+
return _context8.a(2, result);
|
|
684
648
|
case 6:
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
console.error('Erreur API SunuID:',
|
|
688
|
-
throw
|
|
649
|
+
_context8.p = 6;
|
|
650
|
+
_t6 = _context8.v;
|
|
651
|
+
console.error('Erreur API SunuID:', _t6);
|
|
652
|
+
throw _t6;
|
|
689
653
|
case 7:
|
|
690
|
-
return
|
|
654
|
+
return _context8.a(2);
|
|
691
655
|
}
|
|
692
|
-
},
|
|
656
|
+
}, _callee8, this, [[1, 6]]);
|
|
693
657
|
}));
|
|
694
658
|
function makeRequest(_x8, _x9) {
|
|
695
659
|
return _makeRequest.apply(this, arguments);
|