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