sunuid-sdk 1.0.51 → 1.0.52
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/README.md +429 -193
- package/docs/INTEGRATION_GUIDE.md +334 -0
- package/docs/SECURITY_GUIDE.md +368 -0
- package/examples/.htaccess.example +187 -0
- package/examples/README.md +192 -0
- package/examples/auto-code.js +234 -0
- package/examples/auto-integration.html +337 -0
- package/examples/basic-usage.php +42 -0
- package/examples/callback-example.html +232 -0
- package/examples/config-example.js +41 -0
- package/examples/demo.html +323 -0
- package/examples/env.example +83 -0
- package/examples/local-qr.php +49 -0
- package/examples/minimal-code.js +147 -0
- package/examples/minimal-integration.html +157 -0
- package/examples/no-loop-example.html +250 -0
- package/examples/partner-name-config.js +123 -0
- package/examples/production-config.js +60 -0
- package/examples/secure-integration-example.js +186 -0
- package/examples/secure-integration.html +410 -0
- package/examples/secure-usage.php +309 -0
- package/examples/simple-kyc.html +95 -0
- package/examples/simple-login.html +96 -0
- package/examples/test-partner-name.html +251 -0
- package/examples/test-production.html +200 -0
- package/examples/universal-kyc.html +199 -0
- package/examples/universal-login.html +148 -0
- package/examples/web-integration.php +138 -0
- package/package.json +24 -10
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
// ========================================
|
|
2
|
+
// INTÉGRATION SÉCURISÉE SUNUID SDK
|
|
3
|
+
// ========================================
|
|
4
|
+
// Les credentials ne sont JAMAIS exposés dans le code client
|
|
5
|
+
|
|
6
|
+
// 1. INCLUSION DES SCRIPTS (dans le HTML)
|
|
7
|
+
/*
|
|
8
|
+
<script src="https://cdn.socket.io/4.7.4/socket.io.min.js"></script>
|
|
9
|
+
<script src="https://unpkg.com/sunuid-sdk@1.0.34/dist/sunuid-sdk.min.js"></script>
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
// 2. CONFIGURATION SÉCURISÉE (sans credentials)
|
|
13
|
+
const secureConfig = {
|
|
14
|
+
// Aucun credential ici - ils seront récupérés via secure-init.php
|
|
15
|
+
type: 2, // 1=KYC, 2=AUTH, 3=SIGNATURE
|
|
16
|
+
partnerName: 'MonApplication', // Nom de votre application
|
|
17
|
+
theme: 'light',
|
|
18
|
+
language: 'fr',
|
|
19
|
+
|
|
20
|
+
// Activer l'initialisation sécurisée
|
|
21
|
+
secureInit: true,
|
|
22
|
+
secureInitUrl: '/secure-init.php', // URL vers votre endpoint sécurisé
|
|
23
|
+
|
|
24
|
+
// Options de sécurité
|
|
25
|
+
enableSecurityLogs: true,
|
|
26
|
+
validateInputs: true,
|
|
27
|
+
maxRetries: 3,
|
|
28
|
+
requestTimeout: 10000,
|
|
29
|
+
|
|
30
|
+
// Callbacks
|
|
31
|
+
onSuccess: (data) => console.log('🎉 Authentification réussie:', data),
|
|
32
|
+
onError: (error) => console.error('💥 Erreur:', error),
|
|
33
|
+
onStatusUpdate: (status) => console.log('📊 Statut:', status)
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// 3. CODE D'INTÉGRATION SÉCURISÉE
|
|
37
|
+
async function initSunuIDSecure() {
|
|
38
|
+
try {
|
|
39
|
+
console.log('🔒 Initialisation sécurisée...');
|
|
40
|
+
|
|
41
|
+
// Créer l'instance SDK avec configuration sécurisée
|
|
42
|
+
const sunuid = new SunuID(secureConfig);
|
|
43
|
+
|
|
44
|
+
// Initialiser (les credentials seront récupérés automatiquement)
|
|
45
|
+
await sunuid.init();
|
|
46
|
+
|
|
47
|
+
console.log('✅ SDK initialisé de manière sécurisée');
|
|
48
|
+
console.log('🔒 Credentials récupérés via token sécurisé');
|
|
49
|
+
|
|
50
|
+
// Générer le QR code
|
|
51
|
+
const result = await sunuid.generateQR('qr-container');
|
|
52
|
+
|
|
53
|
+
console.log('✅ QR Code généré:', result.qrCodeUrl);
|
|
54
|
+
return result;
|
|
55
|
+
|
|
56
|
+
} catch (error) {
|
|
57
|
+
console.error('❌ Erreur sécurisée:', error.message);
|
|
58
|
+
throw error;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// 4. UTILISATION SIMPLE
|
|
63
|
+
// initSunuIDSecure().then(result => console.log('Succès:', result));
|
|
64
|
+
|
|
65
|
+
// ========================================
|
|
66
|
+
// EXEMPLE AVEC GESTION D'ÉTAT SÉCURISÉE
|
|
67
|
+
// ========================================
|
|
68
|
+
|
|
69
|
+
let secureSunuidInstance = null;
|
|
70
|
+
|
|
71
|
+
async function initSecureSDK() {
|
|
72
|
+
if (secureSunuidInstance) {
|
|
73
|
+
console.log('SDK sécurisé déjà initialisé');
|
|
74
|
+
return secureSunuidInstance;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
console.log('🔒 Création instance SDK sécurisée...');
|
|
78
|
+
secureSunuidInstance = new SunuID(secureConfig);
|
|
79
|
+
await secureSunuidInstance.init();
|
|
80
|
+
|
|
81
|
+
console.log('✅ SDK sécurisé initialisé');
|
|
82
|
+
return secureSunuidInstance;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async function generateSecureQRCode(containerId = 'qr-container') {
|
|
86
|
+
if (!secureSunuidInstance) {
|
|
87
|
+
await initSecureSDK();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return await secureSunuidInstance.generateQR(containerId);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// ========================================
|
|
94
|
+
// EXEMPLE AVEC DIFFÉRENTS TYPES SÉCURISÉS
|
|
95
|
+
// ========================================
|
|
96
|
+
|
|
97
|
+
// Authentification sécurisée
|
|
98
|
+
async function generateSecureAuthQR() {
|
|
99
|
+
const authConfig = { ...secureConfig, type: 2 };
|
|
100
|
+
const sunuid = new SunuID(authConfig);
|
|
101
|
+
await sunuid.init();
|
|
102
|
+
return await sunuid.generateQR('qr-container');
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// KYC sécurisé
|
|
106
|
+
async function generateSecureKYCQR() {
|
|
107
|
+
const kycConfig = { ...secureConfig, type: 1 };
|
|
108
|
+
const sunuid = new SunuID(kycConfig);
|
|
109
|
+
await sunuid.init();
|
|
110
|
+
return await sunuid.generateQR('qr-container');
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Signature sécurisée
|
|
114
|
+
async function generateSecureSignatureQR() {
|
|
115
|
+
const signatureConfig = { ...secureConfig, type: 3 };
|
|
116
|
+
const sunuid = new SunuID(signatureConfig);
|
|
117
|
+
await sunuid.init();
|
|
118
|
+
return await sunuid.generateQR('qr-container');
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// ========================================
|
|
122
|
+
// EXEMPLE COMPLET AVEC HTML
|
|
123
|
+
// ========================================
|
|
124
|
+
|
|
125
|
+
/*
|
|
126
|
+
HTML requis :
|
|
127
|
+
|
|
128
|
+
<div id="qr-container">
|
|
129
|
+
<!-- Le QR code sera affiché ici -->
|
|
130
|
+
</div>
|
|
131
|
+
|
|
132
|
+
<button onclick="initSunuIDSecure()">Générer QR Code Sécurisé</button>
|
|
133
|
+
*/
|
|
134
|
+
|
|
135
|
+
// ========================================
|
|
136
|
+
// FONCTIONS UTILITAIRES SÉCURISÉES
|
|
137
|
+
// ========================================
|
|
138
|
+
|
|
139
|
+
// Vérifier le statut de sécurité
|
|
140
|
+
function checkSecurityStatus() {
|
|
141
|
+
if (!secureSunuidInstance) {
|
|
142
|
+
return { initialized: false, secure: false };
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return {
|
|
146
|
+
initialized: secureSunuidInstance.isInitialized,
|
|
147
|
+
secure: secureSunuidInstance.config.secureInit,
|
|
148
|
+
token: secureSunuidInstance.config.token ? '***' + secureSunuidInstance.config.token.slice(-8) : null,
|
|
149
|
+
websocket: secureSunuidInstance.getWebSocketStatus()
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Obtenir les logs de sécurité
|
|
154
|
+
function getSecurityLogs() {
|
|
155
|
+
if (!secureSunuidInstance) {
|
|
156
|
+
return [];
|
|
157
|
+
}
|
|
158
|
+
return secureSunuidInstance.getSecurityLogs();
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Nettoyer les logs de sécurité
|
|
162
|
+
function clearSecurityLogs() {
|
|
163
|
+
if (secureSunuidInstance) {
|
|
164
|
+
secureSunuidInstance.clearSecurityLogs();
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// ========================================
|
|
169
|
+
// EXPORT POUR UTILISATION MODULE
|
|
170
|
+
// ========================================
|
|
171
|
+
|
|
172
|
+
if (typeof module !== 'undefined' && module.exports) {
|
|
173
|
+
module.exports = {
|
|
174
|
+
initSunuIDSecure,
|
|
175
|
+
initSecureSDK,
|
|
176
|
+
generateSecureQRCode,
|
|
177
|
+
generateSecureAuthQR,
|
|
178
|
+
generateSecureKYCQR,
|
|
179
|
+
generateSecureSignatureQR,
|
|
180
|
+
checkSecurityStatus,
|
|
181
|
+
getSecurityLogs,
|
|
182
|
+
clearSecurityLogs,
|
|
183
|
+
secureConfig
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
|
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="fr">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>SunuID SDK - Intégration Sécurisée</title>
|
|
7
|
+
<style>
|
|
8
|
+
body {
|
|
9
|
+
font-family: Arial, sans-serif;
|
|
10
|
+
max-width: 800px;
|
|
11
|
+
margin: 0 auto;
|
|
12
|
+
padding: 20px;
|
|
13
|
+
background-color: #f5f5f5;
|
|
14
|
+
}
|
|
15
|
+
.container {
|
|
16
|
+
background: white;
|
|
17
|
+
padding: 30px;
|
|
18
|
+
border-radius: 10px;
|
|
19
|
+
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
|
20
|
+
}
|
|
21
|
+
.header {
|
|
22
|
+
text-align: center;
|
|
23
|
+
margin-bottom: 30px;
|
|
24
|
+
}
|
|
25
|
+
.header h1 {
|
|
26
|
+
color: #333;
|
|
27
|
+
margin-bottom: 10px;
|
|
28
|
+
}
|
|
29
|
+
.header p {
|
|
30
|
+
color: #666;
|
|
31
|
+
font-size: 16px;
|
|
32
|
+
}
|
|
33
|
+
.security-info {
|
|
34
|
+
background: #e8f5e8;
|
|
35
|
+
border: 1px solid #4caf50;
|
|
36
|
+
border-radius: 5px;
|
|
37
|
+
padding: 15px;
|
|
38
|
+
margin-bottom: 20px;
|
|
39
|
+
}
|
|
40
|
+
.security-info h3 {
|
|
41
|
+
color: #2e7d32;
|
|
42
|
+
margin-top: 0;
|
|
43
|
+
}
|
|
44
|
+
.qr-container {
|
|
45
|
+
text-align: center;
|
|
46
|
+
margin: 20px 0;
|
|
47
|
+
min-height: 300px;
|
|
48
|
+
border: 2px dashed #ddd;
|
|
49
|
+
border-radius: 10px;
|
|
50
|
+
display: flex;
|
|
51
|
+
align-items: center;
|
|
52
|
+
justify-content: center;
|
|
53
|
+
}
|
|
54
|
+
.qr-container.loading {
|
|
55
|
+
background: #f8f9fa;
|
|
56
|
+
}
|
|
57
|
+
.qr-container.error {
|
|
58
|
+
border-color: #dc3545;
|
|
59
|
+
background: #f8d7da;
|
|
60
|
+
}
|
|
61
|
+
.qr-container.success {
|
|
62
|
+
border-color: #28a745;
|
|
63
|
+
background: #d4edda;
|
|
64
|
+
}
|
|
65
|
+
.buttons {
|
|
66
|
+
text-align: center;
|
|
67
|
+
margin: 20px 0;
|
|
68
|
+
}
|
|
69
|
+
.btn {
|
|
70
|
+
background: #007bff;
|
|
71
|
+
color: white;
|
|
72
|
+
border: none;
|
|
73
|
+
padding: 12px 24px;
|
|
74
|
+
border-radius: 5px;
|
|
75
|
+
cursor: pointer;
|
|
76
|
+
margin: 5px;
|
|
77
|
+
font-size: 16px;
|
|
78
|
+
}
|
|
79
|
+
.btn:hover {
|
|
80
|
+
background: #0056b3;
|
|
81
|
+
}
|
|
82
|
+
.btn:disabled {
|
|
83
|
+
background: #6c757d;
|
|
84
|
+
cursor: not-allowed;
|
|
85
|
+
}
|
|
86
|
+
.btn.success {
|
|
87
|
+
background: #28a745;
|
|
88
|
+
}
|
|
89
|
+
.btn.success:hover {
|
|
90
|
+
background: #1e7e34;
|
|
91
|
+
}
|
|
92
|
+
.btn.warning {
|
|
93
|
+
background: #ffc107;
|
|
94
|
+
color: #212529;
|
|
95
|
+
}
|
|
96
|
+
.btn.warning:hover {
|
|
97
|
+
background: #e0a800;
|
|
98
|
+
}
|
|
99
|
+
.status {
|
|
100
|
+
margin: 20px 0;
|
|
101
|
+
padding: 15px;
|
|
102
|
+
border-radius: 5px;
|
|
103
|
+
font-family: monospace;
|
|
104
|
+
font-size: 14px;
|
|
105
|
+
}
|
|
106
|
+
.status.info {
|
|
107
|
+
background: #d1ecf1;
|
|
108
|
+
border: 1px solid #bee5eb;
|
|
109
|
+
color: #0c5460;
|
|
110
|
+
}
|
|
111
|
+
.status.success {
|
|
112
|
+
background: #d4edda;
|
|
113
|
+
border: 1px solid #c3e6cb;
|
|
114
|
+
color: #155724;
|
|
115
|
+
}
|
|
116
|
+
.status.error {
|
|
117
|
+
background: #f8d7da;
|
|
118
|
+
border: 1px solid #f5c6cb;
|
|
119
|
+
color: #721c24;
|
|
120
|
+
}
|
|
121
|
+
.logs {
|
|
122
|
+
background: #f8f9fa;
|
|
123
|
+
border: 1px solid #dee2e6;
|
|
124
|
+
border-radius: 5px;
|
|
125
|
+
padding: 15px;
|
|
126
|
+
margin-top: 20px;
|
|
127
|
+
max-height: 200px;
|
|
128
|
+
overflow-y: auto;
|
|
129
|
+
}
|
|
130
|
+
.logs h4 {
|
|
131
|
+
margin-top: 0;
|
|
132
|
+
color: #495057;
|
|
133
|
+
}
|
|
134
|
+
.log-entry {
|
|
135
|
+
margin: 5px 0;
|
|
136
|
+
padding: 5px;
|
|
137
|
+
border-left: 3px solid #007bff;
|
|
138
|
+
background: white;
|
|
139
|
+
}
|
|
140
|
+
.log-entry.error {
|
|
141
|
+
border-left-color: #dc3545;
|
|
142
|
+
}
|
|
143
|
+
.log-entry.success {
|
|
144
|
+
border-left-color: #28a745;
|
|
145
|
+
}
|
|
146
|
+
</style>
|
|
147
|
+
</head>
|
|
148
|
+
<body>
|
|
149
|
+
<div class="container">
|
|
150
|
+
<div class="header">
|
|
151
|
+
<h1>🔒 SunuID SDK - Intégration Sécurisée</h1>
|
|
152
|
+
<p>Authentification sécurisée sans exposition des credentials</p>
|
|
153
|
+
</div>
|
|
154
|
+
|
|
155
|
+
<div class="security-info">
|
|
156
|
+
<h3>🛡️ Sécurité Garantie</h3>
|
|
157
|
+
<p><strong>Aucun credential n'est exposé dans le code client.</strong> Les credentials sont récupérés de manière sécurisée via un token temporaire généré par le serveur.</p>
|
|
158
|
+
</div>
|
|
159
|
+
|
|
160
|
+
<div class="buttons">
|
|
161
|
+
<button class="btn" onclick="initSecureSDK()">🔒 Initialiser SDK Sécurisé</button>
|
|
162
|
+
<button class="btn success" onclick="generateAuthQR()">🔐 Authentification</button>
|
|
163
|
+
<button class="btn warning" onclick="generateKYCQR()">📋 KYC</button>
|
|
164
|
+
<button class="btn" onclick="generateSignatureQR()">✍️ Signature</button>
|
|
165
|
+
<button class="btn" onclick="checkStatus()">📊 Statut</button>
|
|
166
|
+
<button class="btn" onclick="showLogs()">📝 Logs</button>
|
|
167
|
+
</div>
|
|
168
|
+
|
|
169
|
+
<div id="qr-container" class="qr-container">
|
|
170
|
+
<p>Cliquez sur "Initialiser SDK Sécurisé" pour commencer</p>
|
|
171
|
+
</div>
|
|
172
|
+
|
|
173
|
+
<div id="status" class="status info" style="display: none;">
|
|
174
|
+
<!-- Le statut sera affiché ici -->
|
|
175
|
+
</div>
|
|
176
|
+
|
|
177
|
+
<div id="logs" class="logs" style="display: none;">
|
|
178
|
+
<h4>📝 Logs de Sécurité</h4>
|
|
179
|
+
<div id="log-content">
|
|
180
|
+
<!-- Les logs seront affichés ici -->
|
|
181
|
+
</div>
|
|
182
|
+
</div>
|
|
183
|
+
</div>
|
|
184
|
+
|
|
185
|
+
<!-- Scripts requis -->
|
|
186
|
+
<script src="https://cdn.socket.io/4.7.4/socket.io.min.js"></script>
|
|
187
|
+
<script src="../src/sunuid-sdk.js"></script>
|
|
188
|
+
|
|
189
|
+
<script>
|
|
190
|
+
// Configuration sécurisée (sans credentials)
|
|
191
|
+
const secureConfig = {
|
|
192
|
+
type: 2, // Authentification par défaut
|
|
193
|
+
partnerName: 'DemoSécurisée',
|
|
194
|
+
theme: 'light',
|
|
195
|
+
language: 'fr',
|
|
196
|
+
|
|
197
|
+
// Activer l'initialisation sécurisée
|
|
198
|
+
secureInit: true,
|
|
199
|
+
secureInitUrl: '../secure-init.php', // Chemin vers votre endpoint sécurisé
|
|
200
|
+
|
|
201
|
+
// Options de sécurité
|
|
202
|
+
enableSecurityLogs: true,
|
|
203
|
+
validateInputs: true,
|
|
204
|
+
maxRetries: 3,
|
|
205
|
+
requestTimeout: 10000,
|
|
206
|
+
|
|
207
|
+
// Callbacks
|
|
208
|
+
onSuccess: (data) => {
|
|
209
|
+
console.log('🎉 Authentification réussie:', data);
|
|
210
|
+
showStatus('✅ Authentification réussie !', 'success');
|
|
211
|
+
updateQRContainer('success', '🎉 Authentification réussie !');
|
|
212
|
+
},
|
|
213
|
+
onError: (error) => {
|
|
214
|
+
console.error('💥 Erreur:', error);
|
|
215
|
+
showStatus('❌ Erreur: ' + error.message, 'error');
|
|
216
|
+
updateQRContainer('error', '❌ Erreur: ' + error.message);
|
|
217
|
+
},
|
|
218
|
+
onStatusUpdate: (status) => {
|
|
219
|
+
console.log('📊 Statut:', status);
|
|
220
|
+
showStatus('📊 Mise à jour: ' + JSON.stringify(status), 'info');
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
let secureSunuidInstance = null;
|
|
225
|
+
|
|
226
|
+
// Initialiser le SDK de manière sécurisée
|
|
227
|
+
async function initSecureSDK() {
|
|
228
|
+
try {
|
|
229
|
+
showStatus('🔒 Initialisation sécurisée en cours...', 'info');
|
|
230
|
+
updateQRContainer('loading', '🔒 Initialisation sécurisée...');
|
|
231
|
+
|
|
232
|
+
if (secureSunuidInstance) {
|
|
233
|
+
showStatus('⚠️ SDK déjà initialisé', 'info');
|
|
234
|
+
return secureSunuidInstance;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
console.log('🔒 Création instance SDK sécurisée...');
|
|
238
|
+
secureSunuidInstance = new SunuID(secureConfig);
|
|
239
|
+
await secureSunuidInstance.init();
|
|
240
|
+
|
|
241
|
+
showStatus('✅ SDK sécurisé initialisé avec succès', 'success');
|
|
242
|
+
updateQRContainer('success', '✅ SDK initialisé ! Cliquez sur un type de service.');
|
|
243
|
+
|
|
244
|
+
console.log('✅ SDK sécurisé initialisé');
|
|
245
|
+
return secureSunuidInstance;
|
|
246
|
+
|
|
247
|
+
} catch (error) {
|
|
248
|
+
console.error('❌ Erreur initialisation sécurisée:', error);
|
|
249
|
+
showStatus('❌ Erreur: ' + error.message, 'error');
|
|
250
|
+
updateQRContainer('error', '❌ Erreur: ' + error.message);
|
|
251
|
+
throw error;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// Générer QR code d'authentification
|
|
256
|
+
async function generateAuthQR() {
|
|
257
|
+
try {
|
|
258
|
+
if (!secureSunuidInstance) {
|
|
259
|
+
await initSecureSDK();
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
showStatus('🔐 Génération QR Authentification...', 'info');
|
|
263
|
+
updateQRContainer('loading', '🔐 Génération QR Authentification...');
|
|
264
|
+
|
|
265
|
+
const result = await secureSunuidInstance.generateQR('qr-container');
|
|
266
|
+
|
|
267
|
+
showStatus('✅ QR Authentification généré', 'success');
|
|
268
|
+
console.log('✅ QR Authentification:', result);
|
|
269
|
+
|
|
270
|
+
return result;
|
|
271
|
+
|
|
272
|
+
} catch (error) {
|
|
273
|
+
console.error('❌ Erreur QR Authentification:', error);
|
|
274
|
+
showStatus('❌ Erreur: ' + error.message, 'error');
|
|
275
|
+
updateQRContainer('error', '❌ Erreur: ' + error.message);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// Générer QR code KYC
|
|
280
|
+
async function generateKYCQR() {
|
|
281
|
+
try {
|
|
282
|
+
if (!secureSunuidInstance) {
|
|
283
|
+
await initSecureSDK();
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
showStatus('📋 Génération QR KYC...', 'info');
|
|
287
|
+
updateQRContainer('loading', '📋 Génération QR KYC...');
|
|
288
|
+
|
|
289
|
+
const result = await secureSunuidInstance.generateKYCQR('qr-container');
|
|
290
|
+
|
|
291
|
+
showStatus('✅ QR KYC généré', 'success');
|
|
292
|
+
console.log('✅ QR KYC:', result);
|
|
293
|
+
|
|
294
|
+
return result;
|
|
295
|
+
|
|
296
|
+
} catch (error) {
|
|
297
|
+
console.error('❌ Erreur QR KYC:', error);
|
|
298
|
+
showStatus('❌ Erreur: ' + error.message, 'error');
|
|
299
|
+
updateQRContainer('error', '❌ Erreur: ' + error.message);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// Générer QR code Signature
|
|
304
|
+
async function generateSignatureQR() {
|
|
305
|
+
try {
|
|
306
|
+
if (!secureSunuidInstance) {
|
|
307
|
+
await initSecureSDK();
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
showStatus('✍️ Génération QR Signature...', 'info');
|
|
311
|
+
updateQRContainer('loading', '✍️ Génération QR Signature...');
|
|
312
|
+
|
|
313
|
+
const result = await secureSunuidInstance.generateSignatureQR('qr-container');
|
|
314
|
+
|
|
315
|
+
showStatus('✅ QR Signature généré', 'success');
|
|
316
|
+
console.log('✅ QR Signature:', result);
|
|
317
|
+
|
|
318
|
+
return result;
|
|
319
|
+
|
|
320
|
+
} catch (error) {
|
|
321
|
+
console.error('❌ Erreur QR Signature:', error);
|
|
322
|
+
showStatus('❌ Erreur: ' + error.message, 'error');
|
|
323
|
+
updateQRContainer('error', '❌ Erreur: ' + error.message);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// Vérifier le statut
|
|
328
|
+
function checkStatus() {
|
|
329
|
+
if (!secureSunuidInstance) {
|
|
330
|
+
showStatus('⚠️ SDK non initialisé', 'info');
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
const status = {
|
|
335
|
+
initialized: secureSunuidInstance.isInitialized,
|
|
336
|
+
secure: secureSunuidInstance.config.secureInit,
|
|
337
|
+
token: secureSunuidInstance.config.token ? '***' + secureSunuidInstance.config.token.slice(-8) : null,
|
|
338
|
+
websocket: secureSunuidInstance.getWebSocketStatus(),
|
|
339
|
+
partnerName: secureSunuidInstance.config.partnerName,
|
|
340
|
+
type: secureSunuidInstance.config.type
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
showStatus('📊 Statut: ' + JSON.stringify(status, null, 2), 'info');
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
// Afficher les logs
|
|
347
|
+
function showLogs() {
|
|
348
|
+
if (!secureSunuidInstance) {
|
|
349
|
+
showStatus('⚠️ SDK non initialisé', 'info');
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
const logs = secureSunuidInstance.getSecurityLogs();
|
|
354
|
+
const logContent = document.getElementById('log-content');
|
|
355
|
+
const logsDiv = document.getElementById('logs');
|
|
356
|
+
|
|
357
|
+
if (logs.length === 0) {
|
|
358
|
+
logContent.innerHTML = '<p>Aucun log disponible</p>';
|
|
359
|
+
} else {
|
|
360
|
+
logContent.innerHTML = logs.map(log => `
|
|
361
|
+
<div class="log-entry ${log.event.includes('ERROR') ? 'error' : log.event.includes('SUCCESS') ? 'success' : ''}">
|
|
362
|
+
<strong>${log.timestamp}</strong> - ${log.event}<br>
|
|
363
|
+
<small>${JSON.stringify(log.data)}</small>
|
|
364
|
+
</div>
|
|
365
|
+
`).join('');
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
logsDiv.style.display = 'block';
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
// Fonctions utilitaires
|
|
372
|
+
function showStatus(message, type) {
|
|
373
|
+
const statusDiv = document.getElementById('status');
|
|
374
|
+
statusDiv.textContent = message;
|
|
375
|
+
statusDiv.className = `status ${type}`;
|
|
376
|
+
statusDiv.style.display = 'block';
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
function updateQRContainer(state, message) {
|
|
380
|
+
const container = document.getElementById('qr-container');
|
|
381
|
+
container.className = `qr-container ${state}`;
|
|
382
|
+
|
|
383
|
+
if (state === 'loading') {
|
|
384
|
+
container.innerHTML = `
|
|
385
|
+
<div>
|
|
386
|
+
<div style="width: 50px; height: 50px; border: 4px solid #f3f3f3; border-top: 4px solid #007bff; border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto 20px auto;"></div>
|
|
387
|
+
<p>${message}</p>
|
|
388
|
+
</div>
|
|
389
|
+
<style>
|
|
390
|
+
@keyframes spin {
|
|
391
|
+
0% { transform: rotate(0deg); }
|
|
392
|
+
100% { transform: rotate(360deg); }
|
|
393
|
+
}
|
|
394
|
+
</style>
|
|
395
|
+
`;
|
|
396
|
+
} else if (state === 'error') {
|
|
397
|
+
container.innerHTML = `<p style="color: #dc3545;">${message}</p>`;
|
|
398
|
+
} else if (state === 'success') {
|
|
399
|
+
container.innerHTML = `<p style="color: #28a745;">${message}</p>`;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
// Initialisation automatique au chargement (optionnel)
|
|
404
|
+
// window.addEventListener('load', () => {
|
|
405
|
+
// console.log('🚀 Page chargée, prêt pour l\'intégration sécurisée');
|
|
406
|
+
// });
|
|
407
|
+
</script>
|
|
408
|
+
</body>
|
|
409
|
+
</html>
|
|
410
|
+
|