sunuid-sdk 1.0.0

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.
@@ -0,0 +1,643 @@
1
+ function asyncGeneratorStep(n, t, e, r, o, a, c) {
2
+ try {
3
+ var i = n[a](c),
4
+ u = i.value;
5
+ } catch (n) {
6
+ return void e(n);
7
+ }
8
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
9
+ }
10
+ function _asyncToGenerator(n) {
11
+ return function () {
12
+ var t = this,
13
+ e = arguments;
14
+ return new Promise(function (r, o) {
15
+ var a = n.apply(t, e);
16
+ function _next(n) {
17
+ asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
18
+ }
19
+ function _throw(n) {
20
+ asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
21
+ }
22
+ _next(void 0);
23
+ });
24
+ };
25
+ }
26
+ function _classCallCheck(a, n) {
27
+ if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
28
+ }
29
+ function _defineProperties(e, r) {
30
+ for (var t = 0; t < r.length; t++) {
31
+ var o = r[t];
32
+ o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
33
+ }
34
+ }
35
+ function _createClass(e, r, t) {
36
+ return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
37
+ writable: !1
38
+ }), e;
39
+ }
40
+ function _defineProperty(e, r, t) {
41
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
42
+ value: t,
43
+ enumerable: !0,
44
+ configurable: !0,
45
+ writable: !0
46
+ }) : e[r] = t, e;
47
+ }
48
+ function ownKeys(e, r) {
49
+ var t = Object.keys(e);
50
+ if (Object.getOwnPropertySymbols) {
51
+ var o = Object.getOwnPropertySymbols(e);
52
+ r && (o = o.filter(function (r) {
53
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
54
+ })), t.push.apply(t, o);
55
+ }
56
+ return t;
57
+ }
58
+ function _objectSpread2(e) {
59
+ for (var r = 1; r < arguments.length; r++) {
60
+ var t = null != arguments[r] ? arguments[r] : {};
61
+ r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
62
+ _defineProperty(e, r, t[r]);
63
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
64
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
65
+ });
66
+ }
67
+ return e;
68
+ }
69
+ function _regenerator() {
70
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
71
+ var e,
72
+ t,
73
+ r = "function" == typeof Symbol ? Symbol : {},
74
+ n = r.iterator || "@@iterator",
75
+ o = r.toStringTag || "@@toStringTag";
76
+ function i(r, n, o, i) {
77
+ var c = n && n.prototype instanceof Generator ? n : Generator,
78
+ u = Object.create(c.prototype);
79
+ return _regeneratorDefine(u, "_invoke", function (r, n, o) {
80
+ var i,
81
+ c,
82
+ u,
83
+ f = 0,
84
+ p = o || [],
85
+ y = !1,
86
+ G = {
87
+ p: 0,
88
+ n: 0,
89
+ v: e,
90
+ a: d,
91
+ f: d.bind(e, 4),
92
+ d: function (t, r) {
93
+ return i = t, c = 0, u = e, G.n = r, a;
94
+ }
95
+ };
96
+ function d(r, n) {
97
+ for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
98
+ var o,
99
+ i = p[t],
100
+ d = G.p,
101
+ l = i[2];
102
+ r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
103
+ }
104
+ if (o || r > 1) return a;
105
+ throw y = !0, n;
106
+ }
107
+ return function (o, p, l) {
108
+ if (f > 1) throw TypeError("Generator is already running");
109
+ for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
110
+ i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
111
+ try {
112
+ if (f = 2, i) {
113
+ if (c || (o = "next"), t = i[o]) {
114
+ if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
115
+ if (!t.done) return t;
116
+ u = t.value, c < 2 && (c = 0);
117
+ } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
118
+ i = e;
119
+ } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
120
+ } catch (t) {
121
+ i = e, c = 1, u = t;
122
+ } finally {
123
+ f = 1;
124
+ }
125
+ }
126
+ return {
127
+ value: t,
128
+ done: y
129
+ };
130
+ };
131
+ }(r, o, i), !0), u;
132
+ }
133
+ var a = {};
134
+ function Generator() {}
135
+ function GeneratorFunction() {}
136
+ function GeneratorFunctionPrototype() {}
137
+ t = Object.getPrototypeOf;
138
+ var c = [][n] ? t(t([][n]())) : (_regeneratorDefine(t = {}, n, function () {
139
+ return this;
140
+ }), t),
141
+ u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
142
+ function f(e) {
143
+ return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
144
+ }
145
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine(u), _regeneratorDefine(u, o, "Generator"), _regeneratorDefine(u, n, function () {
146
+ return this;
147
+ }), _regeneratorDefine(u, "toString", function () {
148
+ return "[object Generator]";
149
+ }), (_regenerator = function () {
150
+ return {
151
+ w: i,
152
+ m: f
153
+ };
154
+ })();
155
+ }
156
+ function _regeneratorDefine(e, r, n, t) {
157
+ var i = Object.defineProperty;
158
+ try {
159
+ i({}, "", {});
160
+ } catch (e) {
161
+ i = 0;
162
+ }
163
+ _regeneratorDefine = function (e, r, n, t) {
164
+ function o(r, n) {
165
+ _regeneratorDefine(e, r, function (e) {
166
+ return this._invoke(r, n, e);
167
+ });
168
+ }
169
+ r ? i ? i(e, r, {
170
+ value: n,
171
+ enumerable: !t,
172
+ configurable: !t,
173
+ writable: !t
174
+ }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
175
+ }, _regeneratorDefine(e, r, n, t);
176
+ }
177
+ function _toPrimitive(t, r) {
178
+ if ("object" != typeof t || !t) return t;
179
+ var e = t[Symbol.toPrimitive];
180
+ if (void 0 !== e) {
181
+ var i = e.call(t, r || "default");
182
+ if ("object" != typeof i) return i;
183
+ throw new TypeError("@@toPrimitive must return a primitive value.");
184
+ }
185
+ return ("string" === r ? String : Number)(t);
186
+ }
187
+ function _toPropertyKey(t) {
188
+ var i = _toPrimitive(t, "string");
189
+ return "symbol" == typeof i ? i : i + "";
190
+ }
191
+
192
+ /**
193
+ * SunuID SDK - Package d'intégration pour partenaires
194
+ *
195
+ * @version 1.0.0
196
+ * @author SunuID Team
197
+ * @license MIT
198
+ */
199
+
200
+ (function (window) {
201
+
202
+ // Configuration par défaut
203
+ var DEFAULT_CONFIG = {
204
+ apiUrl: 'https://sunuid.fayma.sn/api',
205
+ clientId: null,
206
+ secretId: null,
207
+ theme: 'light',
208
+ language: 'fr',
209
+ autoRefresh: true,
210
+ refreshInterval: 30000,
211
+ // 30 secondes
212
+ onSuccess: null,
213
+ onError: null,
214
+ onExpired: null
215
+ };
216
+
217
+ /**
218
+ * Classe principale SunuID
219
+ */
220
+ var SunuID = /*#__PURE__*/function () {
221
+ function SunuID() {
222
+ var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
223
+ _classCallCheck(this, SunuID);
224
+ this.config = _objectSpread2(_objectSpread2({}, DEFAULT_CONFIG), config);
225
+ this.qrCode = null;
226
+ this.refreshTimer = null;
227
+ this.isInitialized = false;
228
+ this.init();
229
+ }
230
+
231
+ /**
232
+ * Initialisation du SDK
233
+ */
234
+ return _createClass(SunuID, [{
235
+ key: "init",
236
+ value: function init() {
237
+ if (!this.config.clientId || !this.config.secretId) {
238
+ throw new Error('SunuID: clientId et secretId sont requis');
239
+ }
240
+ this.isInitialized = true;
241
+ console.log('SunuID SDK initialisé avec succès');
242
+ }
243
+
244
+ /**
245
+ * Générer un QR code d'authentification
246
+ */
247
+ }, {
248
+ key: "generateAuthQR",
249
+ value: (function () {
250
+ var _generateAuthQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(containerId) {
251
+ var options,
252
+ response,
253
+ testData,
254
+ qrData,
255
+ qrUrl,
256
+ _args = arguments,
257
+ _t;
258
+ return _regenerator().w(function (_context) {
259
+ while (1) switch (_context.p = _context.n) {
260
+ case 0:
261
+ options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
262
+ if (this.isInitialized) {
263
+ _context.n = 1;
264
+ break;
265
+ }
266
+ throw new Error('SunuID: SDK non initialisé');
267
+ case 1:
268
+ _context.p = 1;
269
+ _context.n = 2;
270
+ return this.makeRequest('/auth/qr-generate', _objectSpread2({
271
+ type: 'auth'
272
+ }, options));
273
+ case 2:
274
+ response = _context.v;
275
+ if (!response.success) {
276
+ _context.n = 3;
277
+ break;
278
+ }
279
+ this.displayQRCode(containerId, response.data.qr_code_url, 'auth', options);
280
+ this.startAutoRefresh(containerId, 'auth', options);
281
+ return _context.a(2, response.data);
282
+ case 3:
283
+ throw new Error(response.message);
284
+ case 4:
285
+ _context.n = 6;
286
+ break;
287
+ case 5:
288
+ _context.p = 5;
289
+ _t = _context.v;
290
+ console.warn('Erreur API, génération d\'un QR code de test:', _t.message);
291
+
292
+ // En cas d'échec de l'API, générer un QR code de test
293
+ testData = _objectSpread2({
294
+ type: 'auth',
295
+ clientId: this.config.clientId,
296
+ timestamp: Date.now(),
297
+ sessionId: 'test_' + Math.random().toString(36).substr(2, 9),
298
+ apiUrl: this.config.apiUrl
299
+ }, options);
300
+ qrData = JSON.stringify(testData);
301
+ qrUrl = "https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=".concat(encodeURIComponent(qrData));
302
+ this.displayQRCode(containerId, qrUrl, 'auth', options);
303
+ this.startAutoRefresh(containerId, 'auth', options);
304
+ return _context.a(2, {
305
+ success: true,
306
+ data: {
307
+ qr_code_url: qrUrl,
308
+ qr_id: testData.sessionId,
309
+ expires_at: Date.now() + 30000
310
+ }
311
+ });
312
+ case 6:
313
+ return _context.a(2);
314
+ }
315
+ }, _callee, this, [[1, 5]]);
316
+ }));
317
+ function generateAuthQR(_x) {
318
+ return _generateAuthQR.apply(this, arguments);
319
+ }
320
+ return generateAuthQR;
321
+ }()
322
+ /**
323
+ * Générer un QR code KYC
324
+ */
325
+ )
326
+ }, {
327
+ key: "generateKYCQR",
328
+ value: (function () {
329
+ var _generateKYCQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(containerId) {
330
+ var options,
331
+ response,
332
+ testData,
333
+ qrData,
334
+ qrUrl,
335
+ _args2 = arguments,
336
+ _t2;
337
+ return _regenerator().w(function (_context2) {
338
+ while (1) switch (_context2.p = _context2.n) {
339
+ case 0:
340
+ options = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : {};
341
+ if (this.isInitialized) {
342
+ _context2.n = 1;
343
+ break;
344
+ }
345
+ throw new Error('SunuID: SDK non initialisé');
346
+ case 1:
347
+ _context2.p = 1;
348
+ _context2.n = 2;
349
+ return this.makeRequest('/auth/qr-generate', _objectSpread2({
350
+ type: 'kyc'
351
+ }, options));
352
+ case 2:
353
+ response = _context2.v;
354
+ if (!response.success) {
355
+ _context2.n = 3;
356
+ break;
357
+ }
358
+ this.displayQRCode(containerId, response.data.qr_code_url, 'kyc', options);
359
+ this.startAutoRefresh(containerId, 'kyc', options);
360
+ return _context2.a(2, response.data);
361
+ case 3:
362
+ throw new Error(response.message);
363
+ case 4:
364
+ _context2.n = 6;
365
+ break;
366
+ case 5:
367
+ _context2.p = 5;
368
+ _t2 = _context2.v;
369
+ console.warn('Erreur API, génération d\'un QR code de test:', _t2.message);
370
+
371
+ // En cas d'échec de l'API, générer un QR code de test
372
+ testData = _objectSpread2({
373
+ type: 'kyc',
374
+ clientId: this.config.clientId,
375
+ timestamp: Date.now(),
376
+ sessionId: 'test_' + Math.random().toString(36).substr(2, 9),
377
+ kycType: options.kycType || 'full',
378
+ requiredFields: options.requiredFields || ['identity', 'address', 'phone'],
379
+ apiUrl: this.config.apiUrl
380
+ }, options);
381
+ qrData = JSON.stringify(testData);
382
+ qrUrl = "https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=".concat(encodeURIComponent(qrData));
383
+ this.displayQRCode(containerId, qrUrl, 'kyc', options);
384
+ this.startAutoRefresh(containerId, 'kyc', options);
385
+ return _context2.a(2, {
386
+ success: true,
387
+ data: {
388
+ qr_code_url: qrUrl,
389
+ qr_id: testData.sessionId,
390
+ expires_at: Date.now() + 30000
391
+ }
392
+ });
393
+ case 6:
394
+ return _context2.a(2);
395
+ }
396
+ }, _callee2, this, [[1, 5]]);
397
+ }));
398
+ function generateKYCQR(_x2) {
399
+ return _generateKYCQR.apply(this, arguments);
400
+ }
401
+ return generateKYCQR;
402
+ }()
403
+ /**
404
+ * Vérifier le statut d'un QR code
405
+ */
406
+ )
407
+ }, {
408
+ key: "checkQRStatus",
409
+ value: (function () {
410
+ var _checkQRStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(qrId) {
411
+ var response, _t3;
412
+ return _regenerator().w(function (_context3) {
413
+ while (1) switch (_context3.p = _context3.n) {
414
+ case 0:
415
+ _context3.p = 0;
416
+ _context3.n = 1;
417
+ return this.makeRequest('/auth/qr-status', {
418
+ qr_id: qrId
419
+ });
420
+ case 1:
421
+ response = _context3.v;
422
+ return _context3.a(2, response.data);
423
+ case 2:
424
+ _context3.p = 2;
425
+ _t3 = _context3.v;
426
+ this.handleError(_t3);
427
+ throw _t3;
428
+ case 3:
429
+ return _context3.a(2);
430
+ }
431
+ }, _callee3, this, [[0, 2]]);
432
+ }));
433
+ function checkQRStatus(_x3) {
434
+ return _checkQRStatus.apply(this, arguments);
435
+ }
436
+ return checkQRStatus;
437
+ }()
438
+ /**
439
+ * Afficher le QR code dans le conteneur
440
+ */
441
+ )
442
+ }, {
443
+ key: "displayQRCode",
444
+ value: function displayQRCode(containerId, qrUrl, type) {
445
+ var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
446
+ var container = document.getElementById(containerId);
447
+ if (!container) {
448
+ throw new Error("Conteneur avec l'ID \"".concat(containerId, "\" non trouv\xE9"));
449
+ }
450
+ var theme = options.theme || this.config.theme;
451
+ options.language || this.config.language;
452
+ container.innerHTML = "\n <div class=\"sunuid-qr-container sunuid-theme-".concat(theme, "\">\n <div class=\"sunuid-qr-header\">\n <h3 class=\"sunuid-qr-title\">\n ").concat(type === 'auth' ? '🔐 Authentification' : '📋 Vérification KYC', "\n </h3>\n <p class=\"sunuid-qr-subtitle\">\n ").concat(type === 'auth' ? 'Scannez ce QR code avec l\'application SunuID pour vous connecter' : 'Scannez ce QR code avec l\'application SunuID pour compléter votre profil', "\n </p>\n </div>\n <div class=\"sunuid-qr-code\">\n <img src=\"").concat(qrUrl, "\" alt=\"QR Code SunuID\" class=\"sunuid-qr-image\">\n <div class=\"sunuid-qr-overlay\">\n <div class=\"sunuid-qr-spinner\"></div>\n </div>\n </div>\n <div class=\"sunuid-qr-footer\">\n <p class=\"sunuid-qr-timer\">\n <i class=\"fa-solid fa-clock\"></i>\n <span id=\"sunuid-timer\">30</span> secondes\n </p>\n <button class=\"sunuid-qr-refresh\" onclick=\"sunuidInstance.refreshQR('").concat(containerId, "', '").concat(type, "', ").concat(JSON.stringify(options), ")\">\n <i class=\"fa-solid fa-sync-alt\"></i>\n Actualiser\n </button>\n </div>\n </div>\n ");
453
+ this.qrCode = {
454
+ containerId: containerId,
455
+ type: type,
456
+ options: options,
457
+ qrUrl: qrUrl
458
+ };
459
+ this.startTimer();
460
+ }
461
+
462
+ /**
463
+ * Actualiser le QR code
464
+ */
465
+ }, {
466
+ key: "refreshQR",
467
+ value: (function () {
468
+ var _refreshQR = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(containerId, type) {
469
+ var options,
470
+ _args4 = arguments,
471
+ _t4;
472
+ return _regenerator().w(function (_context4) {
473
+ while (1) switch (_context4.p = _context4.n) {
474
+ case 0:
475
+ options = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : {};
476
+ _context4.p = 1;
477
+ if (!(type === 'auth')) {
478
+ _context4.n = 3;
479
+ break;
480
+ }
481
+ _context4.n = 2;
482
+ return this.generateAuthQR(containerId, options);
483
+ case 2:
484
+ _context4.n = 4;
485
+ break;
486
+ case 3:
487
+ _context4.n = 4;
488
+ return this.generateKYCQR(containerId, options);
489
+ case 4:
490
+ _context4.n = 6;
491
+ break;
492
+ case 5:
493
+ _context4.p = 5;
494
+ _t4 = _context4.v;
495
+ this.handleError(_t4);
496
+ case 6:
497
+ return _context4.a(2);
498
+ }
499
+ }, _callee4, this, [[1, 5]]);
500
+ }));
501
+ function refreshQR(_x4, _x5) {
502
+ return _refreshQR.apply(this, arguments);
503
+ }
504
+ return refreshQR;
505
+ }()
506
+ /**
507
+ * Démarrer le timer de rafraîchissement automatique
508
+ */
509
+ )
510
+ }, {
511
+ key: "startAutoRefresh",
512
+ value: function startAutoRefresh(containerId, type, options) {
513
+ var _this = this;
514
+ if (!this.config.autoRefresh) return;
515
+ this.refreshTimer = setInterval(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5() {
516
+ var _t5;
517
+ return _regenerator().w(function (_context5) {
518
+ while (1) switch (_context5.p = _context5.n) {
519
+ case 0:
520
+ _context5.p = 0;
521
+ _context5.n = 1;
522
+ return _this.refreshQR(containerId, type, options);
523
+ case 1:
524
+ _context5.n = 3;
525
+ break;
526
+ case 2:
527
+ _context5.p = 2;
528
+ _t5 = _context5.v;
529
+ console.warn('Erreur lors du rafraîchissement automatique:', _t5);
530
+ case 3:
531
+ return _context5.a(2);
532
+ }
533
+ }, _callee5, null, [[0, 2]]);
534
+ })), this.config.refreshInterval);
535
+ }
536
+
537
+ /**
538
+ * Démarrer le timer de compte à rebours
539
+ */
540
+ }, {
541
+ key: "startTimer",
542
+ value: function startTimer() {
543
+ var _this2 = this;
544
+ var timeLeft = 30;
545
+ var timerElement = document.getElementById('sunuid-timer');
546
+ var timer = setInterval(function () {
547
+ timeLeft--;
548
+ if (timerElement) {
549
+ timerElement.textContent = timeLeft;
550
+ }
551
+ if (timeLeft <= 0) {
552
+ clearInterval(timer);
553
+ if (_this2.config.onExpired) {
554
+ _this2.config.onExpired();
555
+ }
556
+ }
557
+ }, 1000);
558
+ }
559
+
560
+ /**
561
+ * Effectuer une requête API
562
+ */
563
+ }, {
564
+ key: "makeRequest",
565
+ value: (function () {
566
+ var _makeRequest = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(endpoint, data) {
567
+ var url, response;
568
+ return _regenerator().w(function (_context6) {
569
+ while (1) switch (_context6.n) {
570
+ case 0:
571
+ url = "".concat(this.config.apiUrl).concat(endpoint);
572
+ _context6.n = 1;
573
+ return fetch(url, {
574
+ method: 'POST',
575
+ headers: {
576
+ 'Content-Type': 'application/json',
577
+ 'X-SunuID-Client-ID': this.config.clientId,
578
+ 'X-SunuID-Secret-ID': this.config.secretId
579
+ },
580
+ body: JSON.stringify(data)
581
+ });
582
+ case 1:
583
+ response = _context6.v;
584
+ if (response.ok) {
585
+ _context6.n = 2;
586
+ break;
587
+ }
588
+ throw new Error("Erreur HTTP: ".concat(response.status));
589
+ case 2:
590
+ _context6.n = 3;
591
+ return response.json();
592
+ case 3:
593
+ return _context6.a(2, _context6.v);
594
+ }
595
+ }, _callee6, this);
596
+ }));
597
+ function makeRequest(_x6, _x7) {
598
+ return _makeRequest.apply(this, arguments);
599
+ }
600
+ return makeRequest;
601
+ }()
602
+ /**
603
+ * Gérer les erreurs
604
+ */
605
+ )
606
+ }, {
607
+ key: "handleError",
608
+ value: function handleError(error) {
609
+ console.error('SunuID SDK Error:', error);
610
+ if (this.config.onError) {
611
+ this.config.onError(error);
612
+ }
613
+ }
614
+
615
+ /**
616
+ * Nettoyer les ressources
617
+ */
618
+ }, {
619
+ key: "destroy",
620
+ value: function destroy() {
621
+ if (this.refreshTimer) {
622
+ clearInterval(this.refreshTimer);
623
+ }
624
+ this.isInitialized = false;
625
+ console.log('SunuID SDK détruit');
626
+ }
627
+ }]);
628
+ }(); // Exposer la classe globalement
629
+ window.SunuID = SunuID;
630
+ window.sunuidInstance = null;
631
+
632
+ // Fonction d'initialisation globale
633
+ window.initSunuID = function (config) {
634
+ try {
635
+ window.sunuidInstance = new SunuID(config);
636
+ return window.sunuidInstance;
637
+ } catch (error) {
638
+ console.error('Erreur lors de l\'initialisation de SunuID:', error);
639
+ throw error;
640
+ }
641
+ };
642
+ })(window);
643
+ //# sourceMappingURL=sunuid-sdk.esm.js.map