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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 SunuID Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,301 @@
1
+ # 🔐 SunuID SDK
2
+
3
+ [![npm version](https://badge.fury.io/js/sunuid-sdk.svg)](https://badge.fury.io/js/sunuid-sdk)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+ [![Build Status](https://github.com/sunuid/sunuid-sdk/workflows/Build/badge.svg)](https://github.com/sunuid/sunuid-sdk/actions)
6
+
7
+ SDK JavaScript officiel pour intégrer facilement les QR codes d'authentification et KYC SunuID dans vos applications web.
8
+
9
+ ## ✨ Fonctionnalités
10
+
11
+ - 🔐 **Authentification QR Code** - Connexion sécurisée avec SunuID
12
+ - 📋 **Vérification KYC** - Collecte et validation d'identité
13
+ - 🎨 **Thèmes personnalisables** - Support des thèmes clair et sombre
14
+ - 🔄 **Actualisation automatique** - QR codes qui se renouvellent automatiquement
15
+ - 📱 **Responsive design** - Compatible mobile et desktop
16
+ - 🌍 **Multi-langue** - Support français, anglais, arabe
17
+ - 🛡️ **Sécurisé** - Authentification par clés API
18
+
19
+ ## 🚀 Installation
20
+
21
+ ### Via NPM
22
+
23
+ ```bash
24
+ npm install sunuid-sdk
25
+ ```
26
+
27
+ ### Via CDN
28
+
29
+ ```html
30
+ <!-- CSS -->
31
+ <link rel="stylesheet" href="https://unpkg.com/sunuid-sdk@1.0.0/dist/sunuid-sdk.css">
32
+
33
+ <!-- JavaScript -->
34
+ <script src="https://unpkg.com/sunuid-sdk@1.0.0/dist/sunuid-sdk.js"></script>
35
+ ```
36
+
37
+ ## 📖 Utilisation Rapide
38
+
39
+ ### 1. Initialisation
40
+
41
+ ```javascript
42
+ const sunuid = initSunuID({
43
+ apiUrl: 'https://sunuid.fayma.sn/api',
44
+ clientId: 'VOTRE_CLIENT_ID',
45
+ secretId: 'VOTRE_SECRET_ID',
46
+ theme: 'light'
47
+ });
48
+ ```
49
+
50
+ ### 2. Authentification
51
+
52
+ ```html
53
+ <div id="auth-qr-container"></div>
54
+ ```
55
+
56
+ ```javascript
57
+ sunuid.generateAuthQR('auth-qr-container', {
58
+ redirectUrl: 'https://votre-site.com/dashboard'
59
+ });
60
+ ```
61
+
62
+ ### 3. KYC
63
+
64
+ ```html
65
+ <div id="kyc-qr-container"></div>
66
+ ```
67
+
68
+ ```javascript
69
+ sunuid.generateKYCQR('kyc-qr-container', {
70
+ kycType: 'full',
71
+ requiredFields: ['identity', 'address', 'phone']
72
+ });
73
+ ```
74
+
75
+ ## 🎨 Exemples
76
+
77
+ ### Page de Connexion
78
+
79
+ ```html
80
+ <!DOCTYPE html>
81
+ <html lang="fr">
82
+ <head>
83
+ <meta charset="UTF-8">
84
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
85
+ <title>Connexion - Mon Application</title>
86
+ <link rel="stylesheet" href="https://unpkg.com/sunuid-sdk@1.0.0/dist/sunuid-sdk.css">
87
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
88
+ </head>
89
+ <body>
90
+ <div class="login-container">
91
+ <h1>Connexion Sécurisée</h1>
92
+ <p>Scannez le QR code avec l'application SunuID</p>
93
+
94
+ <div id="auth-qr-container"></div>
95
+
96
+ <div class="login-footer">
97
+ <p>Pas encore d'application SunuID ?</p>
98
+ <a href="https://sunuid.sn/download" target="_blank">Télécharger</a>
99
+ </div>
100
+ </div>
101
+
102
+ <script src="https://unpkg.com/sunuid-sdk@1.0.0/dist/sunuid-sdk.js"></script>
103
+ <script>
104
+ const sunuid = initSunuID({
105
+ apiUrl: 'https://sunuid.fayma.sn/api',
106
+ clientId: 'VOTRE_CLIENT_ID',
107
+ secretId: 'VOTRE_SECRET_ID',
108
+ theme: 'light',
109
+ onSuccess: function(data) {
110
+ window.location.href = '/dashboard?token=' + data.token;
111
+ },
112
+ onError: function(error) {
113
+ alert('Erreur de connexion: ' + error.message);
114
+ }
115
+ });
116
+
117
+ sunuid.generateAuthQR('auth-qr-container');
118
+ </script>
119
+ </body>
120
+ </html>
121
+ ```
122
+
123
+ ## 🔧 Configuration
124
+
125
+ ### Options disponibles
126
+
127
+ | Option | Type | Défaut | Description |
128
+ |--------|------|--------|-------------|
129
+ | `apiUrl` | string | `'https://sunuid.fayma.sn/api'` | URL de l'API SunuID |
130
+ | `clientId` | string | - | Clé client (requise) |
131
+ | `secretId` | string | - | Clé secrète (requise) |
132
+ | `theme` | string | `'light'` | Thème: `'light'` ou `'dark'` |
133
+ | `language` | string | `'fr'` | Langue: `'fr'`, `'en'`, `'ar'` |
134
+ | `autoRefresh` | boolean | `true` | Actualisation automatique |
135
+ | `refreshInterval` | number | `30000` | Intervalle en millisecondes |
136
+ | `onSuccess` | function | - | Callback en cas de succès |
137
+ | `onError` | function | - | Callback en cas d'erreur |
138
+ | `onExpired` | function | - | Callback quand le QR expire |
139
+
140
+ ### Événements
141
+
142
+ ```javascript
143
+ const sunuid = initSunuID({
144
+ // ... configuration
145
+ onSuccess: function(data) {
146
+ console.log('Authentification réussie:', data);
147
+ // data contient: token, user, partner, etc.
148
+ },
149
+ onError: function(error) {
150
+ console.error('Erreur:', error);
151
+ // error contient: message, code, details
152
+ },
153
+ onExpired: function() {
154
+ console.log('QR code expiré');
155
+ // Le QR code a expiré, actualisation automatique
156
+ }
157
+ });
158
+ ```
159
+
160
+ ## 📱 API Référence
161
+
162
+ ### Méthodes principales
163
+
164
+ #### `generateAuthQR(containerId, options)`
165
+ Génère un QR code d'authentification.
166
+
167
+ ```javascript
168
+ sunuid.generateAuthQR('container-id', {
169
+ theme: 'light',
170
+ redirectUrl: 'https://votre-site.com/dashboard',
171
+ customData: { /* données personnalisées */ }
172
+ });
173
+ ```
174
+
175
+ #### `generateKYCQR(containerId, options)`
176
+ Génère un QR code KYC.
177
+
178
+ ```javascript
179
+ sunuid.generateKYCQR('container-id', {
180
+ theme: 'dark',
181
+ kycType: 'full', // 'basic' ou 'full'
182
+ requiredFields: ['identity', 'address', 'phone'],
183
+ redirectUrl: 'https://votre-site.com/kyc-complete'
184
+ });
185
+ ```
186
+
187
+ #### `checkQRStatus(qrId)`
188
+ Vérifie le statut d'un QR code.
189
+
190
+ ```javascript
191
+ const status = await sunuid.checkQRStatus('qr-id-123');
192
+ console.log('Statut:', status);
193
+ ```
194
+
195
+ #### `refreshQR(containerId, type, options)`
196
+ Actualise un QR code.
197
+
198
+ ```javascript
199
+ sunuid.refreshQR('container-id', 'auth', { theme: 'light' });
200
+ ```
201
+
202
+ #### `destroy()`
203
+ Nettoie les ressources du SDK.
204
+
205
+ ```javascript
206
+ sunuid.destroy();
207
+ ```
208
+
209
+ ## 🛡️ Sécurité
210
+
211
+ ### Authentification
212
+ Le SDK utilise les clés API pour s'authentifier :
213
+ - `X-SunuID-Client-ID`
214
+ - `X-SunuID-Secret-ID`
215
+
216
+ ### Validation
217
+ - Vérification des paramètres requis
218
+ - Validation des URLs de redirection
219
+ - Protection contre les attaques CSRF
220
+
221
+ ## 🌐 Compatibilité
222
+
223
+ - **Navigateurs** : Chrome 60+, Firefox 55+, Safari 12+, Edge 79+
224
+ - **Mobile** : iOS Safari 12+, Chrome Mobile 60+
225
+ - **Node.js** : 14.0.0+
226
+
227
+ ## 📊 Monitoring
228
+
229
+ ### Logs
230
+ Le SDK génère des logs pour le debugging :
231
+ ```javascript
232
+ console.log('SunuID SDK initialisé avec succès');
233
+ console.error('SunuID SDK Error:', error);
234
+ ```
235
+
236
+ ### Métriques
237
+ Les partenaires peuvent suivre :
238
+ - Nombre de QR codes générés
239
+ - Taux de succès d'authentification
240
+ - Temps de réponse de l'API
241
+
242
+ ## 🆘 Support
243
+
244
+ ### Documentation
245
+ - [Guide d'intégration](https://docs.sunuid.sn)
246
+ - [API Reference](https://api.sunuid.sn/docs)
247
+ - [Exemples](https://github.com/sunuid/sdk-examples)
248
+
249
+ ### Support technique
250
+ - Email : support@sunuid.sn
251
+ - Chat : https://chat.sunuid.sn
252
+ - Documentation : https://docs.sunuid.sn
253
+
254
+ ### Communauté
255
+ - [GitHub Issues](https://github.com/sunuid/sunuid-sdk/issues)
256
+ - [Discussions](https://github.com/sunuid/sunuid-sdk/discussions)
257
+ - [Stack Overflow](https://stackoverflow.com/questions/tagged/sunuid)
258
+
259
+ ## 🤝 Contribution
260
+
261
+ Les contributions sont les bienvenues ! Consultez notre [guide de contribution](CONTRIBUTING.md).
262
+
263
+ ### Développement
264
+
265
+ ```bash
266
+ # Cloner le repository
267
+ git clone https://github.com/sunuid/sunuid-sdk.git
268
+ cd sunuid-sdk
269
+
270
+ # Installer les dépendances
271
+ npm install
272
+
273
+ # Démarrer le mode développement
274
+ npm run dev
275
+
276
+ # Construire pour la production
277
+ npm run build
278
+
279
+ # Lancer les tests
280
+ npm test
281
+
282
+ # Démarrer le serveur de démonstration
283
+ npm run serve
284
+ npm run demo
285
+ ```
286
+
287
+ ## 📄 Licence
288
+
289
+ Ce projet est distribué sous licence MIT. Voir le fichier [LICENSE](LICENSE) pour plus de détails.
290
+
291
+ ## 🙏 Remerciements
292
+
293
+ - [FontAwesome](https://fontawesome.com/) pour les icônes
294
+ - [Inter](https://rsms.me/inter/) pour la typographie
295
+ - [Rollup](https://rollupjs.org/) pour le bundling
296
+
297
+ ---
298
+
299
+ **Développé avec ❤️ par l'équipe SunuID**
300
+
301
+ [![SunuID](https://sunuid.sn/logo.png)](https://sunuid.sn)