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,148 @@
|
|
|
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>Connexion SunuID - Universel</title>
|
|
7
|
+
<style>
|
|
8
|
+
body {
|
|
9
|
+
font-family: Arial, sans-serif;
|
|
10
|
+
display: flex;
|
|
11
|
+
justify-content: center;
|
|
12
|
+
align-items: center;
|
|
13
|
+
min-height: 100vh;
|
|
14
|
+
margin: 0;
|
|
15
|
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
16
|
+
}
|
|
17
|
+
.login-card {
|
|
18
|
+
background: white;
|
|
19
|
+
padding: 40px;
|
|
20
|
+
border-radius: 15px;
|
|
21
|
+
box-shadow: 0 10px 30px rgba(0,0,0,0.2);
|
|
22
|
+
text-align: center;
|
|
23
|
+
max-width: 400px;
|
|
24
|
+
}
|
|
25
|
+
.qr-code {
|
|
26
|
+
margin: 20px 0;
|
|
27
|
+
}
|
|
28
|
+
.qr-code img {
|
|
29
|
+
max-width: 100%;
|
|
30
|
+
height: auto;
|
|
31
|
+
}
|
|
32
|
+
.status {
|
|
33
|
+
margin-top: 20px;
|
|
34
|
+
padding: 10px;
|
|
35
|
+
border-radius: 5px;
|
|
36
|
+
}
|
|
37
|
+
.status.loading {
|
|
38
|
+
background: #e3f2fd;
|
|
39
|
+
color: #1976d2;
|
|
40
|
+
}
|
|
41
|
+
.status.success {
|
|
42
|
+
background: #e8f5e8;
|
|
43
|
+
color: #2e7d32;
|
|
44
|
+
}
|
|
45
|
+
.status.error {
|
|
46
|
+
background: #ffebee;
|
|
47
|
+
color: #c62828;
|
|
48
|
+
}
|
|
49
|
+
.logo {
|
|
50
|
+
width: 80px;
|
|
51
|
+
height: 80px;
|
|
52
|
+
margin: 0 auto 20px;
|
|
53
|
+
background: #667eea;
|
|
54
|
+
border-radius: 50%;
|
|
55
|
+
display: flex;
|
|
56
|
+
align-items: center;
|
|
57
|
+
justify-content: center;
|
|
58
|
+
font-size: 40px;
|
|
59
|
+
color: white;
|
|
60
|
+
}
|
|
61
|
+
.download-link {
|
|
62
|
+
margin-top: 20px;
|
|
63
|
+
padding: 10px 20px;
|
|
64
|
+
background: #667eea;
|
|
65
|
+
color: white;
|
|
66
|
+
text-decoration: none;
|
|
67
|
+
border-radius: 25px;
|
|
68
|
+
display: inline-block;
|
|
69
|
+
transition: background 0.3s;
|
|
70
|
+
}
|
|
71
|
+
.download-link:hover {
|
|
72
|
+
background: #5a6fd8;
|
|
73
|
+
}
|
|
74
|
+
</style>
|
|
75
|
+
</head>
|
|
76
|
+
<body>
|
|
77
|
+
<div class="login-card">
|
|
78
|
+
<div class="logo">🔐</div>
|
|
79
|
+
<h1>Connexion Sécurisée</h1>
|
|
80
|
+
<p>Scannez le QR code avec l'application SunuID</p>
|
|
81
|
+
|
|
82
|
+
<div id="qr-container" class="qr-code">
|
|
83
|
+
<div class="status loading">⏳ Génération du QR code...</div>
|
|
84
|
+
</div>
|
|
85
|
+
|
|
86
|
+
<div id="status" class="status loading">
|
|
87
|
+
⏳ En attente du scan...
|
|
88
|
+
</div>
|
|
89
|
+
|
|
90
|
+
<a href="https://sunuid.sn/download" target="_blank" class="download-link">
|
|
91
|
+
📱 Télécharger SunuID
|
|
92
|
+
</a>
|
|
93
|
+
</div>
|
|
94
|
+
|
|
95
|
+
<!-- SunuID SDK -->
|
|
96
|
+
<script src="https://cdn.jsdelivr.net/npm/@sunuid/sdk@latest/dist/sunuid-sdk.min.js"></script>
|
|
97
|
+
|
|
98
|
+
<!-- QRCode library pour le fallback côté client -->
|
|
99
|
+
<script src="https://cdn.jsdelivr.net/npm/qrcode@1.5.3/lib/browser.min.js"></script>
|
|
100
|
+
|
|
101
|
+
<script>
|
|
102
|
+
// Configuration simple - REMPLACEZ PAR VOS VALEURS
|
|
103
|
+
const config = {
|
|
104
|
+
client_id: 'VOTRE_CLIENT_ID', // ← Remplacez par votre CLIENT_ID
|
|
105
|
+
secret_id: 'VOTRE_SECRET_ID', // ← Remplacez par votre SECRET_ID
|
|
106
|
+
type: 2, // ← 1=KYC, 2=AUTH, 3=Signature
|
|
107
|
+
partner_name: 'Votre Entreprise' // ← Remplacez par votre nom
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
// Initialiser SunuID
|
|
111
|
+
const sunuid = new SunuID(config);
|
|
112
|
+
|
|
113
|
+
// Démarrer automatiquement
|
|
114
|
+
sunuid.init().then(() => {
|
|
115
|
+
console.log('✅ SunuID initialisé !');
|
|
116
|
+
document.getElementById('qr-container').innerHTML =
|
|
117
|
+
'<img src="' + sunuid.getQRCode() + '" alt="QR Code SunuID">';
|
|
118
|
+
}).catch(error => {
|
|
119
|
+
console.error('❌ Erreur:', error);
|
|
120
|
+
document.getElementById('status').className = 'status error';
|
|
121
|
+
document.getElementById('status').innerHTML = '❌ Erreur de connexion: ' + error.message;
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
// Écouter les événements
|
|
125
|
+
sunuid.on('connected', (user) => {
|
|
126
|
+
console.log('👤 Utilisateur connecté:', user);
|
|
127
|
+
document.getElementById('status').className = 'status success';
|
|
128
|
+
document.getElementById('status').innerHTML = '✅ Connexion réussie ! Redirection...';
|
|
129
|
+
|
|
130
|
+
// Redirection après 2 secondes
|
|
131
|
+
setTimeout(() => {
|
|
132
|
+
window.location.href = '/dashboard'; // ← Remplacez par votre URL
|
|
133
|
+
}, 2000);
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
sunuid.on('error', (error) => {
|
|
137
|
+
console.error('❌ Erreur:', error);
|
|
138
|
+
document.getElementById('status').className = 'status error';
|
|
139
|
+
document.getElementById('status').innerHTML = '❌ Erreur: ' + error.message;
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
sunuid.on('expired', () => {
|
|
143
|
+
document.getElementById('status').className = 'status error';
|
|
144
|
+
document.getElementById('status').innerHTML = '⏰ QR expiré. Actualisez la page.';
|
|
145
|
+
});
|
|
146
|
+
</script>
|
|
147
|
+
</body>
|
|
148
|
+
</html>
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
require_once __DIR__ . '/../vendor/autoload.php';
|
|
4
|
+
|
|
5
|
+
use SunuID\SunuID;
|
|
6
|
+
|
|
7
|
+
// Configuration
|
|
8
|
+
$config = [
|
|
9
|
+
'client_id' => '1754166754_221A57B46843D755',
|
|
10
|
+
'secret_id' => '56d40fe70507228b27f2640ae65894177c2fedbf246e2b30978fde1fc43953c5',
|
|
11
|
+
'type' => 2,
|
|
12
|
+
'enable_logs' => true
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
$error = null;
|
|
16
|
+
$qrData = null;
|
|
17
|
+
|
|
18
|
+
try {
|
|
19
|
+
$sunuid = new SunuID($config);
|
|
20
|
+
$sunuid->init();
|
|
21
|
+
|
|
22
|
+
// Générer un QR code
|
|
23
|
+
$qrData = $sunuid->generateQR();
|
|
24
|
+
|
|
25
|
+
} catch (Exception $e) {
|
|
26
|
+
$error = $e->getMessage();
|
|
27
|
+
}
|
|
28
|
+
?>
|
|
29
|
+
|
|
30
|
+
<!DOCTYPE html>
|
|
31
|
+
<html lang="fr">
|
|
32
|
+
<head>
|
|
33
|
+
<meta charset="UTF-8">
|
|
34
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
35
|
+
<title>SunuID PHP SDK - Intégration Web</title>
|
|
36
|
+
<style>
|
|
37
|
+
body {
|
|
38
|
+
font-family: Arial, sans-serif;
|
|
39
|
+
max-width: 600px;
|
|
40
|
+
margin: 50px auto;
|
|
41
|
+
padding: 20px;
|
|
42
|
+
text-align: center;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.qr-container {
|
|
46
|
+
margin: 30px 0;
|
|
47
|
+
padding: 20px;
|
|
48
|
+
border: 2px dashed #ddd;
|
|
49
|
+
border-radius: 10px;
|
|
50
|
+
min-height: 300px;
|
|
51
|
+
display: flex;
|
|
52
|
+
align-items: center;
|
|
53
|
+
justify-content: center;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.qr-container img {
|
|
57
|
+
max-width: 250px;
|
|
58
|
+
border: 1px solid #ddd;
|
|
59
|
+
border-radius: 5px;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.error {
|
|
63
|
+
background: #ffebee;
|
|
64
|
+
color: #c62828;
|
|
65
|
+
padding: 15px;
|
|
66
|
+
border-radius: 5px;
|
|
67
|
+
margin: 20px 0;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.info {
|
|
71
|
+
background: #e3f2fd;
|
|
72
|
+
color: #1976d2;
|
|
73
|
+
padding: 15px;
|
|
74
|
+
border-radius: 5px;
|
|
75
|
+
margin: 20px 0;
|
|
76
|
+
text-align: left;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.success {
|
|
80
|
+
background: #e8f5e8;
|
|
81
|
+
color: #2e7d32;
|
|
82
|
+
padding: 15px;
|
|
83
|
+
border-radius: 5px;
|
|
84
|
+
margin: 20px 0;
|
|
85
|
+
}
|
|
86
|
+
</style>
|
|
87
|
+
</head>
|
|
88
|
+
<body>
|
|
89
|
+
<h1>🔐 SunuID PHP SDK</h1>
|
|
90
|
+
<p>Exemple d'intégration web</p>
|
|
91
|
+
|
|
92
|
+
<?php if ($error): ?>
|
|
93
|
+
<div class="error">
|
|
94
|
+
<h3>❌ Erreur</h3>
|
|
95
|
+
<p><?php echo htmlspecialchars($error); ?></p>
|
|
96
|
+
</div>
|
|
97
|
+
<?php elseif ($qrData): ?>
|
|
98
|
+
<div class="success">
|
|
99
|
+
<h3>✅ QR Code généré avec succès</h3>
|
|
100
|
+
<p>Scannez le QR code avec l'application SunuID</p>
|
|
101
|
+
</div>
|
|
102
|
+
|
|
103
|
+
<div class="qr-container">
|
|
104
|
+
<img src="<?php echo htmlspecialchars($qrData['qr_code_url']); ?>"
|
|
105
|
+
alt="QR Code SunuID" />
|
|
106
|
+
</div>
|
|
107
|
+
|
|
108
|
+
<div class="info">
|
|
109
|
+
<h4>📋 Informations du QR Code</h4>
|
|
110
|
+
<ul>
|
|
111
|
+
<li><strong>Type:</strong> <?php echo htmlspecialchars($qrData['type']); ?></li>
|
|
112
|
+
<li><strong>Partenaire:</strong> <?php echo htmlspecialchars($qrData['partner_name']); ?></li>
|
|
113
|
+
<li><strong>Session ID:</strong> <?php echo htmlspecialchars($qrData['session_id']); ?></li>
|
|
114
|
+
<li><strong>Label:</strong> <?php echo htmlspecialchars($qrData['label']); ?></li>
|
|
115
|
+
<li><strong>Contenu:</strong> <code><?php echo htmlspecialchars($qrData['content']); ?></code></li>
|
|
116
|
+
</ul>
|
|
117
|
+
</div>
|
|
118
|
+
|
|
119
|
+
<div class="info">
|
|
120
|
+
<h4>🔄 Vérifier le statut</h4>
|
|
121
|
+
<p>Session ID: <code><?php echo htmlspecialchars($qrData['session_id']); ?></code></p>
|
|
122
|
+
<p>Utilisez cette session ID pour vérifier le statut du scan.</p>
|
|
123
|
+
</div>
|
|
124
|
+
|
|
125
|
+
<?php else: ?>
|
|
126
|
+
<div class="error">
|
|
127
|
+
<h3>⚠️ Aucune donnée</h3>
|
|
128
|
+
<p>Aucun QR code n'a pu être généré.</p>
|
|
129
|
+
</div>
|
|
130
|
+
<?php endif; ?>
|
|
131
|
+
|
|
132
|
+
<div style="margin-top: 40px; padding: 20px; background: #f5f5f5; border-radius: 5px;">
|
|
133
|
+
<h4>📚 Documentation</h4>
|
|
134
|
+
<p>Pour plus d'informations, consultez la documentation du SDK PHP SunuID.</p>
|
|
135
|
+
<p><strong>Version:</strong> 1.0.0</p>
|
|
136
|
+
</div>
|
|
137
|
+
</body>
|
|
138
|
+
</html>
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sunuid-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.52",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "SDK JavaScript pour l'intégration des QR codes d'authentification et KYC SunuID",
|
|
5
|
+
"description": "SDK JavaScript sécurisé pour l'intégration des QR codes d'authentification et KYC SunuID",
|
|
6
6
|
"main": "dist/sunuid-sdk.js",
|
|
7
7
|
"module": "dist/sunuid-sdk.esm.js",
|
|
8
8
|
"unpkg": "dist/sunuid-sdk.min.js",
|
|
@@ -10,16 +10,20 @@
|
|
|
10
10
|
"files": [
|
|
11
11
|
"dist",
|
|
12
12
|
"README.md",
|
|
13
|
-
"LICENSE"
|
|
13
|
+
"LICENSE",
|
|
14
|
+
"docs",
|
|
15
|
+
"examples"
|
|
14
16
|
],
|
|
15
17
|
"scripts": {
|
|
16
18
|
"build": "rollup -c",
|
|
17
19
|
"dev": "rollup -c -w",
|
|
18
20
|
"test": "jest",
|
|
21
|
+
"test:coverage": "jest --coverage",
|
|
22
|
+
"security-check": "node examples/secure-integration-example.js",
|
|
19
23
|
"lint": "eslint src/**/*.js",
|
|
20
24
|
"format": "prettier --write src/**/*.js",
|
|
21
25
|
"serve": "python3 -m http.server 8080",
|
|
22
|
-
"demo": "open http://localhost:8080/examples/
|
|
26
|
+
"demo": "open http://localhost:8080/examples/secure-integration.html"
|
|
23
27
|
},
|
|
24
28
|
"keywords": [
|
|
25
29
|
"sunuid",
|
|
@@ -29,12 +33,15 @@
|
|
|
29
33
|
"identity",
|
|
30
34
|
"verification",
|
|
31
35
|
"sdk",
|
|
32
|
-
"javascript"
|
|
36
|
+
"javascript",
|
|
37
|
+
"secure",
|
|
38
|
+
"websocket",
|
|
39
|
+
"socket.io"
|
|
33
40
|
],
|
|
34
41
|
"author": {
|
|
35
42
|
"name": "SunuID Team",
|
|
36
|
-
"email": "
|
|
37
|
-
"url": "https://sunuid.sn"
|
|
43
|
+
"email": "contact@sunuid.fayma.sn",
|
|
44
|
+
"url": "https://sunuid.fayma.sn"
|
|
38
45
|
},
|
|
39
46
|
"license": "MIT",
|
|
40
47
|
"repository": {
|
|
@@ -44,9 +51,9 @@
|
|
|
44
51
|
"bugs": {
|
|
45
52
|
"url": "https://github.com/sunuid/sunuid-sdk/issues"
|
|
46
53
|
},
|
|
47
|
-
"homepage": "https://
|
|
54
|
+
"homepage": "https://sunuid.fayma.sn/docs",
|
|
48
55
|
"dependencies": {
|
|
49
|
-
"socket.io-client": "^4.7.
|
|
56
|
+
"socket.io-client": "^4.7.4",
|
|
50
57
|
"qrcode": "^1.5.3"
|
|
51
58
|
},
|
|
52
59
|
"devDependencies": {
|
|
@@ -70,5 +77,12 @@
|
|
|
70
77
|
"last 2 versions",
|
|
71
78
|
"not dead",
|
|
72
79
|
"not ie 11"
|
|
73
|
-
]
|
|
80
|
+
],
|
|
81
|
+
"exports": {
|
|
82
|
+
".": {
|
|
83
|
+
"import": "./dist/sunuid-sdk.esm.js",
|
|
84
|
+
"require": "./dist/sunuid-sdk.js"
|
|
85
|
+
},
|
|
86
|
+
"./dist/sunuid-sdk.min.js": "./dist/sunuid-sdk.min.js"
|
|
87
|
+
}
|
|
74
88
|
}
|