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