@smileid/web-components 1.0.0-beta
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/.eslintrc.cjs +72 -0
- package/components/README.md +14 -0
- package/components/attribution/PoweredBySmileId.js +42 -0
- package/components/camera-permission/CameraPermission.js +136 -0
- package/components/camera-permission/CameraPermission.stories.js +21 -0
- package/components/combobox/src/Combobox.js +586 -0
- package/components/combobox/src/index.js +1 -0
- package/components/document/src/DocumentCaptureScreens.js +317 -0
- package/components/document/src/DocumentCaptureScreens.stories.js +51 -0
- package/components/document/src/README.md +108 -0
- package/components/document/src/document-capture/DocumentCapture.js +677 -0
- package/components/document/src/document-capture/DocumentCapture.stories.js +71 -0
- package/components/document/src/document-capture/README.md +89 -0
- package/components/document/src/document-capture/index.js +3 -0
- package/components/document/src/document-capture-instructions/DocumentCaptureInstructions.js +499 -0
- package/components/document/src/document-capture-instructions/DocumentCaptureInstructions.stories.js +17 -0
- package/components/document/src/document-capture-instructions/README.md +56 -0
- package/components/document/src/document-capture-instructions/index.js +3 -0
- package/components/document/src/document-capture-review/DocumentCaptureReview.js +378 -0
- package/components/document/src/document-capture-review/DocumentCaptureReview.stories.js +14 -0
- package/components/document/src/document-capture-review/README.md +79 -0
- package/components/document/src/document-capture-review/index.js +3 -0
- package/components/document/src/index.js +3 -0
- package/components/end-user-consent/src/EndUserConsent.js +809 -0
- package/components/end-user-consent/src/EndUserConsent.stories.js +23 -0
- package/components/end-user-consent/src/index.js +4 -0
- package/components/navigation/src/Navigation.js +160 -0
- package/components/navigation/src/Navigation.stories.js +24 -0
- package/components/navigation/src/index.js +3 -0
- package/components/selfie/README.md +201 -0
- package/components/selfie/src/SelfieCaptureScreens.js +224 -0
- package/components/selfie/src/SelfieCaptureScreens.stories.js +21 -0
- package/components/selfie/src/index.js +5 -0
- package/components/selfie/src/selfie-capture/SelfieCapture.js +878 -0
- package/components/selfie/src/selfie-capture/SelfieCapture.stories.js +23 -0
- package/components/selfie/src/selfie-capture/index.js +3 -0
- package/components/selfie/src/selfie-capture-instructions/SelfieCaptureInstructions.js +638 -0
- package/components/selfie/src/selfie-capture-instructions/SelfieCaptureInstructions.stories.js +17 -0
- package/components/selfie/src/selfie-capture-instructions/index.js +3 -0
- package/components/selfie/src/selfie-capture-review/SelfieCaptureReview.js +348 -0
- package/components/selfie/src/selfie-capture-review/SelfieCaptureReview.stories.js +17 -0
- package/components/selfie/src/selfie-capture-review/index.js +3 -0
- package/components/signature-pad/package.json +30 -0
- package/components/signature-pad/src/SignaturePad.js +477 -0
- package/components/signature-pad/src/SignaturePad.stories.js +24 -0
- package/components/signature-pad/src/index.js +3 -0
- package/components/smart-camera-web/src/SmartCameraWeb.js +246 -0
- package/components/smart-camera-web/src/SmartCameraWeb.stories.js +35 -0
- package/components/totp-consent/src/TotpConsent.js +935 -0
- package/components/totp-consent/src/index.js +4 -0
- package/cypress/e2e/smart-camera-web-attribution.cy.js +21 -0
- package/cypress/e2e/smart-camera-web-back-press.cy.js +481 -0
- package/cypress/e2e/smart-camera-web-hide-instructions.cy.js +334 -0
- package/cypress/e2e/smart-camera-web.cy.js +309 -0
- package/cypress/fixtures/example.json +5 -0
- package/cypress/pages/capture-back-of-id-hide-attribution.html +44 -0
- package/cypress/pages/capture-back-of-id-navigation.html +72 -0
- package/cypress/pages/smart-camera-web-hide-instructions.html +38 -0
- package/cypress/pages/smart-camera-web.html +38 -0
- package/cypress/support/commands.js +144 -0
- package/cypress/support/e2e.js +20 -0
- package/cypress.config.js +11 -0
- package/domain/camera/src/README.md +38 -0
- package/domain/camera/src/SmartCamera.js +81 -0
- package/domain/constants/src/Constants.js +27 -0
- package/domain/file-upload/README.md +35 -0
- package/domain/file-upload/src/SmartFileUpload.js +65 -0
- package/esbuild.js +119 -0
- package/index.js +5 -0
- package/package.json +46 -0
- package/styles/README.md +3 -0
- package/styles/src/styles.js +348 -0
- package/styles/src/typography.js +52 -0
|
@@ -0,0 +1,935 @@
|
|
|
1
|
+
import validate from 'validate.js';
|
|
2
|
+
|
|
3
|
+
function postData(url, data) {
|
|
4
|
+
return fetch(url, {
|
|
5
|
+
body: JSON.stringify(data),
|
|
6
|
+
cache: 'no-cache',
|
|
7
|
+
headers: {
|
|
8
|
+
Accept: 'application/json',
|
|
9
|
+
'Content-Type': 'application/json',
|
|
10
|
+
},
|
|
11
|
+
method: 'POST',
|
|
12
|
+
mode: 'cors',
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function markup() {
|
|
17
|
+
return `
|
|
18
|
+
<style>
|
|
19
|
+
*,
|
|
20
|
+
*::before,
|
|
21
|
+
*::after {
|
|
22
|
+
box-sizing: border-box;
|
|
23
|
+
margin: 0;
|
|
24
|
+
padding: 0;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
:host {
|
|
28
|
+
--flow-space: 1.5rem;
|
|
29
|
+
|
|
30
|
+
--color-dark: #404040;
|
|
31
|
+
--color-grey: #555B69;
|
|
32
|
+
|
|
33
|
+
--color-success: #1EB244;
|
|
34
|
+
--color-failure: #FFEDEB;
|
|
35
|
+
--color-failure-tint: #F86B58;
|
|
36
|
+
|
|
37
|
+
--color-richblue: #043C93;
|
|
38
|
+
--color-theme: ${this.themeColor};
|
|
39
|
+
|
|
40
|
+
--color-active: #2D2B2A;
|
|
41
|
+
--color-default: #001096;
|
|
42
|
+
--color-disabled: #848282;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
html {
|
|
46
|
+
font-family: 'DM Sans', sans-serif;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
[hidden] {
|
|
50
|
+
display: none !important;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
[disabled] {
|
|
54
|
+
cursor: not-allowed !important;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.visually-hidden {
|
|
58
|
+
border: 0;
|
|
59
|
+
clip: rect(1px 1px 1px 1px);
|
|
60
|
+
clip: rect(1px, 1px, 1px, 1px);
|
|
61
|
+
height: auto;
|
|
62
|
+
margin: 0;
|
|
63
|
+
overflow: hidden;
|
|
64
|
+
padding: 0;
|
|
65
|
+
position: absolute;
|
|
66
|
+
white-space: nowrap;
|
|
67
|
+
width: 1px;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.color-dark {
|
|
71
|
+
color: var(--color-dark);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.color-grey {
|
|
75
|
+
color: var(--color-grey);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.flow > * + * {
|
|
79
|
+
margin-top: var(--flow-space);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.center {
|
|
83
|
+
margin-left: auto;
|
|
84
|
+
margin-right: auto;
|
|
85
|
+
|
|
86
|
+
text-align: center;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
h1 {
|
|
90
|
+
font-size: 1.5rem;
|
|
91
|
+
font-weight: 700;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
button, input, select, textarea {
|
|
95
|
+
font: inherit
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
label,
|
|
99
|
+
input,
|
|
100
|
+
select,
|
|
101
|
+
textarea {
|
|
102
|
+
--flow-space: .5rem;
|
|
103
|
+
display: block;
|
|
104
|
+
width: 100%;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
input,
|
|
108
|
+
select,
|
|
109
|
+
textarea {
|
|
110
|
+
border: 1px solid #d1d8d6;
|
|
111
|
+
border-radius: .5rem;
|
|
112
|
+
padding: .75rem 1rem;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
button {
|
|
116
|
+
--button-color: var(--color-default);
|
|
117
|
+
--flow-space: 3rem;
|
|
118
|
+
-webkit-appearance: none;
|
|
119
|
+
-moz-appearance: none;
|
|
120
|
+
align-items: center;
|
|
121
|
+
appearance: none;
|
|
122
|
+
background-color: transparent;
|
|
123
|
+
border-radius: 2.5rem;
|
|
124
|
+
border: none;
|
|
125
|
+
color: #ffffff;
|
|
126
|
+
cursor: pointer;
|
|
127
|
+
display: inline-flex;
|
|
128
|
+
font-size: 20px;
|
|
129
|
+
font-weight: 500;
|
|
130
|
+
inline-size: 100%;
|
|
131
|
+
justify-content: center;
|
|
132
|
+
letter-spacing: .05ch;
|
|
133
|
+
line-height: 1;
|
|
134
|
+
padding: 1rem 2.5rem;
|
|
135
|
+
text-align: center;
|
|
136
|
+
text-decoration: none;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
button[data-variant='solid'] {
|
|
140
|
+
background-color: var(--button-color);
|
|
141
|
+
border: 2px solid var(--button-color);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
button[data-variant='outline'] {
|
|
145
|
+
color: var(--button-color);
|
|
146
|
+
border: 2px solid var(--button-color);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
button[data-variant='ghost'] {
|
|
150
|
+
color: var(--button-color);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
button:hover,
|
|
154
|
+
button:focus,
|
|
155
|
+
button:active {
|
|
156
|
+
--button-color: var(--color-active);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
button:disabled {
|
|
160
|
+
--button-color: var(--color-disabled);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
button[data-type='icon'] {
|
|
164
|
+
height: 2rem;
|
|
165
|
+
padding: 0;
|
|
166
|
+
width: 2rem;
|
|
167
|
+
background: transparent;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
input {
|
|
171
|
+
font: inherit;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
fieldset {
|
|
175
|
+
margin: 0;
|
|
176
|
+
border: none;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.font-weight:bold {
|
|
180
|
+
font-weight: bold;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.justify-right {
|
|
184
|
+
justify-content: end !important;
|
|
185
|
+
}
|
|
186
|
+
.nav {
|
|
187
|
+
display: flex;
|
|
188
|
+
justify-content: space-between;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.back-wrapper {
|
|
192
|
+
display: flex;
|
|
193
|
+
align-items: center;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.back-button-text {
|
|
197
|
+
font-size: 11px;
|
|
198
|
+
line-height: 11px;
|
|
199
|
+
color: rgb(21, 31, 114);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
#error,
|
|
203
|
+
.validation-message {
|
|
204
|
+
color: red;
|
|
205
|
+
text-transform: capitalize;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.input-group {
|
|
209
|
+
--flow-space: 1.5rem;
|
|
210
|
+
text-align: initial;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.input-radio {
|
|
214
|
+
--flow-space: 1.5rem;
|
|
215
|
+
background-color: #F8F8F8;
|
|
216
|
+
border-radius: .5rem;
|
|
217
|
+
padding: .625rem 1rem;
|
|
218
|
+
display: flex;
|
|
219
|
+
align-items: center;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
.otp-mode {
|
|
223
|
+
display: flex;
|
|
224
|
+
align-items: center;
|
|
225
|
+
text-align: initial;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
.otp-mode :first-child {
|
|
229
|
+
margin: 0;
|
|
230
|
+
margin-inline-end: 1rem;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
.otp-mode :nth-child(2n) {
|
|
234
|
+
--flow-space: .5rem;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
.input-radio [type='radio'] {
|
|
238
|
+
border-radius: 50%;
|
|
239
|
+
inline-size: 2rem;
|
|
240
|
+
block-size: 2rem;
|
|
241
|
+
margin-inline-end: .5rem;
|
|
242
|
+
background-color: white;
|
|
243
|
+
border: .125rem solid #f5f5f5;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
#totp-token {
|
|
247
|
+
block-size: 3rem;
|
|
248
|
+
inline-size: 20rem;
|
|
249
|
+
max-inline-size: 100%;
|
|
250
|
+
background-color: #F5F5F5;
|
|
251
|
+
border: none;
|
|
252
|
+
border-bottom: 2px solid #2F718D;
|
|
253
|
+
font-size: 1.5rem;
|
|
254
|
+
text-align: center;
|
|
255
|
+
font-weight: 700;
|
|
256
|
+
letter-spacing: 2rem;
|
|
257
|
+
padding: .5rem 1rem;
|
|
258
|
+
margin-inline: auto;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
@keyframes spin {
|
|
262
|
+
0% {
|
|
263
|
+
transform: translate3d(-50%, -50%, 0) rotate(0deg);
|
|
264
|
+
}
|
|
265
|
+
100% {
|
|
266
|
+
transform: translate3d(-50%, -50%, 0) rotate(360deg);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
.spinner {
|
|
271
|
+
animation: 1.5s linear infinite spin;
|
|
272
|
+
animation-play-state: inherit;
|
|
273
|
+
border: solid 5px #cfd0d1;
|
|
274
|
+
border-bottom-color: var(--color-active);
|
|
275
|
+
border-radius: 50%;
|
|
276
|
+
content: "";
|
|
277
|
+
display: block;
|
|
278
|
+
height: 25px;
|
|
279
|
+
width: 25px;
|
|
280
|
+
will-change: transform;
|
|
281
|
+
position: relative;
|
|
282
|
+
top: .675rem;
|
|
283
|
+
left: 1.25rem;
|
|
284
|
+
}
|
|
285
|
+
</style>
|
|
286
|
+
|
|
287
|
+
<div class='flow center' id='id-entry'>
|
|
288
|
+
<div class="nav">
|
|
289
|
+
<div class="back-wrapper">
|
|
290
|
+
<button type='button' data-type='icon' id="back-button" class="back-button">
|
|
291
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none">
|
|
292
|
+
<path fill="#DBDBC4" d="M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10Z" opacity=".4"/>
|
|
293
|
+
<path fill="#001096" d="M15.5 11.25h-5.19l1.72-1.72c.29-.29.29-.77 0-1.06a.754.754 0 0 0-1.06 0l-3 3c-.29.29-.29.77 0 1.06l3 3c.15.15.34.22.53.22s.38-.07.53-.22c.29-.29.29-.77 0-1.06l-1.72-1.72h5.19c.41 0 .75-.34.75-.75s-.34-.75-.75-.75Z"/>
|
|
294
|
+
</svg>
|
|
295
|
+
</button>
|
|
296
|
+
<div class="back-button-text">Back</div>
|
|
297
|
+
</div>
|
|
298
|
+
<button data-type='icon' type='button' class='close-iframe'>
|
|
299
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none">
|
|
300
|
+
<path fill="#DBDBC4" d="M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10Z" opacity=".4"/>
|
|
301
|
+
<path fill="#91190F" d="m13.06 12 2.3-2.3c.29-.29.29-.77 0-1.06a.754.754 0 0 0-1.06 0l-2.3 2.3-2.3-2.3a.754.754 0 0 0-1.06 0c-.29.29-.29.77 0 1.06l2.3 2.3-2.3 2.3c-.29.29-.29.77 0 1.06.15.15.34.22.53.22s.38-.07.53-.22l2.3-2.3 2.3 2.3c.15.15.34.22.53.22s.38-.07.53-.22c.29-.29.29-.77 0-1.06l-2.3-2.3Z"/>
|
|
302
|
+
</svg>
|
|
303
|
+
<span class='visually-hidden'>Close SmileIdentity Verification frame</span>
|
|
304
|
+
</button>
|
|
305
|
+
</div>
|
|
306
|
+
<h1>
|
|
307
|
+
Enter your ${this.idTypeLabel}
|
|
308
|
+
</h1>
|
|
309
|
+
|
|
310
|
+
<form name='id-entry-form' class='flow' novalidate style='--flow-space: 5.5rem'>
|
|
311
|
+
<div id='id-number' class="input-group flow">
|
|
312
|
+
<label class='required' for="id_number">
|
|
313
|
+
${this.idTypeLabel}
|
|
314
|
+
</label>
|
|
315
|
+
|
|
316
|
+
<input aria-required='true' id="id_number" name="id_number"
|
|
317
|
+
maxlength='11' placeholder='' />
|
|
318
|
+
|
|
319
|
+
<p>
|
|
320
|
+
<small>${this.idHint}</small>
|
|
321
|
+
</p>
|
|
322
|
+
</div>
|
|
323
|
+
|
|
324
|
+
<button data-variant='solid' id='query-otp-modes' type='submit'>
|
|
325
|
+
<span class='text'>Continue</span>
|
|
326
|
+
<svg aria-hidden='true' width="25" height="24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
327
|
+
<path d="M7 12h11m0 0-4.588-4M18 12l-4.588 4" stroke="#fff" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
328
|
+
</svg>
|
|
329
|
+
<span hidden class='spinner'></span>
|
|
330
|
+
</button>
|
|
331
|
+
</form>
|
|
332
|
+
</div>
|
|
333
|
+
|
|
334
|
+
<div hidden class='flow center' id='select-mode'>
|
|
335
|
+
<div class="nav">
|
|
336
|
+
<div class="back-wrapper">
|
|
337
|
+
<button type='button' data-type='icon' id="back-to-entry-button" class="back-button">
|
|
338
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none">
|
|
339
|
+
<path fill="#DBDBC4" d="M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10Z" opacity=".4"/>
|
|
340
|
+
<path fill="#001096" d="M15.5 11.25h-5.19l1.72-1.72c.29-.29.29-.77 0-1.06a.754.754 0 0 0-1.06 0l-3 3c-.29.29-.29.77 0 1.06l3 3c.15.15.34.22.53.22s.38-.07.53-.22c.29-.29.29-.77 0-1.06l-1.72-1.72h5.19c.41 0 .75-.34.75-.75s-.34-.75-.75-.75Z"/>
|
|
341
|
+
</svg>
|
|
342
|
+
</button>
|
|
343
|
+
<div class="back-button-text">Back</div>
|
|
344
|
+
</div>
|
|
345
|
+
<button data-type='icon' type='button' class='close-iframe'>
|
|
346
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none">
|
|
347
|
+
<path fill="#DBDBC4" d="M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10Z" opacity=".4"/>
|
|
348
|
+
<path fill="#91190F" d="m13.06 12 2.3-2.3c.29-.29.29-.77 0-1.06a.754.754 0 0 0-1.06 0l-2.3 2.3-2.3-2.3a.754.754 0 0 0-1.06 0c-.29.29-.29.77 0 1.06l2.3 2.3-2.3 2.3c-.29.29-.29.77 0 1.06.15.15.34.22.53.22s.38-.07.53-.22l2.3-2.3 2.3 2.3c.15.15.34.22.53.22s.38-.07.53-.22c.29-.29.29-.77 0-1.06l-2.3-2.3Z"/>
|
|
349
|
+
</svg>
|
|
350
|
+
<span class='visually-hidden'>Close SmileIdentity Verification frame</span>
|
|
351
|
+
</button>
|
|
352
|
+
</div>
|
|
353
|
+
<h1>
|
|
354
|
+
Select contact method
|
|
355
|
+
</h1>
|
|
356
|
+
|
|
357
|
+
<form name='select-mode-form' novalidate style='--flow-space: 4.25rem' id='otp-entry' class='flow center'>
|
|
358
|
+
<fieldset class='flow center'>
|
|
359
|
+
<legend class='flow' style='--flow-space: 1.5rem'>
|
|
360
|
+
<p>
|
|
361
|
+
NIBSS, the data custodian of BVN,
|
|
362
|
+
will send you a One-Time Password (OTP)
|
|
363
|
+
</p>
|
|
364
|
+
|
|
365
|
+
<p>
|
|
366
|
+
<small>
|
|
367
|
+
The request will be from Chams Plc, who is NIBSS' technical partner.
|
|
368
|
+
</small>
|
|
369
|
+
</p>
|
|
370
|
+
</legend>
|
|
371
|
+
|
|
372
|
+
<div class='flow center'>
|
|
373
|
+
${
|
|
374
|
+
this.modes.length
|
|
375
|
+
? this.modes
|
|
376
|
+
.map(
|
|
377
|
+
(mode) => `<label class='input-radio'>
|
|
378
|
+
<input type="radio" id="" name="mode" value="${Object.keys(mode)[0]}">
|
|
379
|
+
<div class='otp-mode'>
|
|
380
|
+
${
|
|
381
|
+
Object.keys(mode)[0].includes('sms')
|
|
382
|
+
? `
|
|
383
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="29" height="37" fill="none">
|
|
384
|
+
<path stroke="#2F718D" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16.697 24.12c4.914 0 7.37 0 8.897-1.652 1.527-1.651 1.527-4.31 1.527-9.625 0-5.316 0-7.974-1.527-9.625-1.526-1.651-3.983-1.651-8.897-1.651h-5.211c-4.914 0-7.37 0-8.897 1.651-1.527 1.651-1.527 4.31-1.527 9.625 0 5.316 0 7.974 1.527 9.625.85.92 1.991 1.328 3.685 1.508"/>
|
|
385
|
+
<g filter="url(#sms)">
|
|
386
|
+
<path stroke="#2F718D" stroke-linecap="round" stroke-width="2" d="M16.697 24.12c-1.61 0-3.384.703-5.005 1.613-2.602 1.462-3.903 2.193-4.545 1.727-.64-.465-.52-1.91-.277-4.799l.055-.656" shape-rendering="crispEdges"/>
|
|
387
|
+
</g>
|
|
388
|
+
<defs>
|
|
389
|
+
<filter id="sms" width="20.023" height="15.595" x="1.675" y="21.005" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse">
|
|
390
|
+
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
|
391
|
+
<feColorMatrix in="SourceAlpha" result="hardAlpha" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"/>
|
|
392
|
+
<feOffset dy="4"/>
|
|
393
|
+
<feGaussianBlur stdDeviation="2"/>
|
|
394
|
+
<feComposite in2="hardAlpha" operator="out"/>
|
|
395
|
+
<feColorMatrix values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
|
|
396
|
+
<feBlend in2="BackgroundImageFix" result="effect1_dropShadow_2_404"/>
|
|
397
|
+
<feBlend in="SourceGraphic" in2="effect1_dropShadow_2_404" result="shape"/>
|
|
398
|
+
</filter>
|
|
399
|
+
</defs>
|
|
400
|
+
</svg>
|
|
401
|
+
`
|
|
402
|
+
: `
|
|
403
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="35" height="24" fill="none">
|
|
404
|
+
<path stroke="#2F718D" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4.062 4.367c0-1.437 1.221-2.603 2.727-2.603h21.815c1.506 0 2.727 1.166 2.727 2.603v15.62c0 1.438-1.221 2.604-2.727 2.604H6.789c-1.506 0-2.727-1.166-2.727-2.604V4.367Z"/>
|
|
405
|
+
<g filter="url(#message)">
|
|
406
|
+
<path stroke="#2F718D" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="m5.426 3.066 8.647 7.338c2.067 1.754 5.18 1.754 7.247 0l8.648-7.338" shape-rendering="crispEdges"/>
|
|
407
|
+
</g>
|
|
408
|
+
<defs>
|
|
409
|
+
<filter id="message" width="34.042" height="18.154" x=".676" y="2.316" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse">
|
|
410
|
+
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
|
411
|
+
<feColorMatrix in="SourceAlpha" result="hardAlpha" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"/>
|
|
412
|
+
<feOffset dy="4"/>
|
|
413
|
+
<feGaussianBlur stdDeviation="2"/>
|
|
414
|
+
<feComposite in2="hardAlpha" operator="out"/>
|
|
415
|
+
<feColorMatrix values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
|
|
416
|
+
<feBlend in2="BackgroundImageFix" result="effect1_dropShadow_2_394"/>
|
|
417
|
+
<feBlend in="SourceGraphic" in2="effect1_dropShadow_2_394" result="shape"/>
|
|
418
|
+
</filter>
|
|
419
|
+
</defs>
|
|
420
|
+
</svg>
|
|
421
|
+
`
|
|
422
|
+
}
|
|
423
|
+
<div class='flow'>
|
|
424
|
+
<p>
|
|
425
|
+
${Object.values(mode)[0]}
|
|
426
|
+
</p>
|
|
427
|
+
<p>
|
|
428
|
+
<small>
|
|
429
|
+
An OTP will be sent by ${
|
|
430
|
+
Object.keys(mode)[0].includes(
|
|
431
|
+
'sms',
|
|
432
|
+
)
|
|
433
|
+
? 'sms'
|
|
434
|
+
: 'email'
|
|
435
|
+
} to verify your identity
|
|
436
|
+
</small>
|
|
437
|
+
</p>
|
|
438
|
+
</div>
|
|
439
|
+
</div>
|
|
440
|
+
</label>`,
|
|
441
|
+
)
|
|
442
|
+
.join('\n')
|
|
443
|
+
: 'No modes yet'
|
|
444
|
+
}
|
|
445
|
+
</div>
|
|
446
|
+
</fieldset>
|
|
447
|
+
|
|
448
|
+
<button data-variant='ghost' id='contact-methods-outdated' style='--flow-space: .5rem' class='' type='button'>
|
|
449
|
+
I am no longer using any of these options
|
|
450
|
+
</button>
|
|
451
|
+
|
|
452
|
+
<button data-variant='solid' id='select-otp-mode' type='submit'>
|
|
453
|
+
<span class='text'>Continue</span>
|
|
454
|
+
<svg aria-hidden='true' width="25" height="24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
455
|
+
<path d="M7 12h11m0 0-4.588-4M18 12l-4.588 4" stroke="#fff" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
456
|
+
</svg>
|
|
457
|
+
<span hidden class='spinner'></span>
|
|
458
|
+
</button>
|
|
459
|
+
</form>
|
|
460
|
+
</div>
|
|
461
|
+
|
|
462
|
+
<div hidden class='flow center' id='otp-verification'>
|
|
463
|
+
<div class="nav justify-right">
|
|
464
|
+
<button data-type='icon' type='button' class='close-iframe'>
|
|
465
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none">
|
|
466
|
+
<path fill="#DBDBC4" d="M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10Z" opacity=".4"/>
|
|
467
|
+
<path fill="#91190F" d="m13.06 12 2.3-2.3c.29-.29.29-.77 0-1.06a.754.754 0 0 0-1.06 0l-2.3 2.3-2.3-2.3a.754.754 0 0 0-1.06 0c-.29.29-.29.77 0 1.06l2.3 2.3-2.3 2.3c-.29.29-.29.77 0 1.06.15.15.34.22.53.22s.38-.07.53-.22l2.3-2.3 2.3 2.3c.15.15.34.22.53.22s.38-.07.53-.22c.29-.29.29-.77 0-1.06l-2.3-2.3Z"/>
|
|
468
|
+
</svg>
|
|
469
|
+
<span class='visually-hidden'>Close SmileIdentity Verification frame</span>
|
|
470
|
+
</button>
|
|
471
|
+
</div>
|
|
472
|
+
<h1>
|
|
473
|
+
OTP Verification
|
|
474
|
+
</h1>
|
|
475
|
+
|
|
476
|
+
<div style='--flow-space: 4.25rem' id='otp-entry'>
|
|
477
|
+
<form name='otp-submission-form' novalidate style='--flow-space: 1.5rem' class='flow center'>
|
|
478
|
+
<label for='totp-token'>
|
|
479
|
+
Enter the OTP sent to <span class='font-weight:bold'>${
|
|
480
|
+
this.selectedOtpDeliveryMode
|
|
481
|
+
}</span>
|
|
482
|
+
</label>
|
|
483
|
+
<input type='text' id='totp-token' maxlength='6' inputmode='numeric' autocomplete='one-time-code' />
|
|
484
|
+
|
|
485
|
+
<p>
|
|
486
|
+
Didn't receive the OTP${
|
|
487
|
+
!this.selectedOtpDeliveryMode
|
|
488
|
+
? '?'
|
|
489
|
+
: ` at <span class='font-weight:bold'>${this.selectedOtpDeliveryMode}</span>?`
|
|
490
|
+
}
|
|
491
|
+
</p>
|
|
492
|
+
|
|
493
|
+
<button style='--flow-space: .5rem' data-variant='ghost' class='try-another-method' type='button'>
|
|
494
|
+
Try another contact method
|
|
495
|
+
</button>
|
|
496
|
+
|
|
497
|
+
<button data-variant='solid' id='submit-otp' type='submit'>
|
|
498
|
+
<span class='text'>Submit</span>
|
|
499
|
+
<svg aria-hidden='true' width="25" height="24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
500
|
+
<path d="M7 12h11m0 0-4.588-4M18 12l-4.588 4" stroke="#fff" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
501
|
+
</svg>
|
|
502
|
+
<span hidden class='spinner'></span>
|
|
503
|
+
</button>
|
|
504
|
+
</form>
|
|
505
|
+
</div>
|
|
506
|
+
</div>
|
|
507
|
+
`;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
class TotpConsent extends HTMLElement {
|
|
511
|
+
constructor() {
|
|
512
|
+
super();
|
|
513
|
+
|
|
514
|
+
this.templateString = markup.bind(this);
|
|
515
|
+
this.render = () => this.templateString();
|
|
516
|
+
|
|
517
|
+
this.attachShadow({ mode: 'open' });
|
|
518
|
+
|
|
519
|
+
this.modes = [];
|
|
520
|
+
this['otp-delivery-mode'] = '';
|
|
521
|
+
|
|
522
|
+
this.queryOtpModes = this.queryOtpModes.bind(this);
|
|
523
|
+
this.selectOtpMode = this.selectOtpMode.bind(this);
|
|
524
|
+
this.submitOtp = this.submitOtp.bind(this);
|
|
525
|
+
this.switchContactMethod = this.switchContactMethod.bind(this);
|
|
526
|
+
this.handleTotpConsentGrant = this.handleTotpConsentGrant.bind(this);
|
|
527
|
+
this.handleTotpConsentContactMethodsOutdated =
|
|
528
|
+
this.handleTotpConsentContactMethodsOutdated.bind(this);
|
|
529
|
+
this.pages = [];
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
static get observedAttributes() {
|
|
533
|
+
return ['modes', 'otp-delivery-mode'];
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
attributeChangedCallback(name) {
|
|
537
|
+
switch (name) {
|
|
538
|
+
case 'modes':
|
|
539
|
+
case 'otp-delivery-mode': {
|
|
540
|
+
const updatedTemplate = document.createElement('template');
|
|
541
|
+
updatedTemplate.innerHTML = this.render();
|
|
542
|
+
const updatedNode = updatedTemplate.content
|
|
543
|
+
.cloneNode(true)
|
|
544
|
+
.querySelector(`#${this.activeScreen.id}`);
|
|
545
|
+
updatedNode.hidden = false;
|
|
546
|
+
this.shadowRoot.replaceChild(updatedNode, this.activeScreen);
|
|
547
|
+
this.setUpEventListeners();
|
|
548
|
+
this.setActiveScreen(updatedNode);
|
|
549
|
+
break;
|
|
550
|
+
}
|
|
551
|
+
default:
|
|
552
|
+
break;
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
setUpEventListeners() {
|
|
557
|
+
// Screens
|
|
558
|
+
this.idEntryScreen = this.shadowRoot.querySelector('#id-entry');
|
|
559
|
+
this.selectModeScreen = this.shadowRoot.querySelector('#select-mode');
|
|
560
|
+
this.otpVerificationScreen =
|
|
561
|
+
this.shadowRoot.querySelector('#otp-verification');
|
|
562
|
+
|
|
563
|
+
if (!this.activeScreen) {
|
|
564
|
+
this.activeScreen = this.idEntryScreen;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
// Buttons
|
|
568
|
+
this.queryOtpModesButton =
|
|
569
|
+
this.idEntryScreen.querySelector('#query-otp-modes');
|
|
570
|
+
this.backButton = this.idEntryScreen.querySelector('#back-button');
|
|
571
|
+
this.selectOtpModeButton =
|
|
572
|
+
this.selectModeScreen.querySelector('#select-otp-mode');
|
|
573
|
+
this.entryBackbutton = this.selectModeScreen.querySelector(
|
|
574
|
+
'#back-to-entry-button',
|
|
575
|
+
);
|
|
576
|
+
this.contactMethodsOutdatedButton = this.selectModeScreen.querySelector(
|
|
577
|
+
'#contact-methods-outdated',
|
|
578
|
+
);
|
|
579
|
+
this.submitOtpButton =
|
|
580
|
+
this.otpVerificationScreen.querySelector('#submit-otp');
|
|
581
|
+
this.switchContactMethodButton = this.otpVerificationScreen.querySelector(
|
|
582
|
+
'.try-another-method',
|
|
583
|
+
);
|
|
584
|
+
const CloseIframeButtons =
|
|
585
|
+
this.shadowRoot.querySelectorAll('.close-iframe');
|
|
586
|
+
|
|
587
|
+
// Input Elements
|
|
588
|
+
this.idNumberInput = this.idEntryScreen.querySelector('#id_number');
|
|
589
|
+
this.modeInputs = this.selectModeScreen.querySelectorAll('[name="mode"]');
|
|
590
|
+
this.otpInput = this.otpVerificationScreen.querySelector('#totp-token');
|
|
591
|
+
|
|
592
|
+
// Event Handlers
|
|
593
|
+
this.queryOtpModesButton.addEventListener('click', (e) =>
|
|
594
|
+
this.queryOtpModes(e),
|
|
595
|
+
);
|
|
596
|
+
this.selectOtpModeButton.addEventListener('click', (e) =>
|
|
597
|
+
this.selectOtpMode(e),
|
|
598
|
+
);
|
|
599
|
+
this.submitOtpButton.addEventListener('click', (e) => this.submitOtp(e));
|
|
600
|
+
this.switchContactMethodButton.addEventListener('click', (e) =>
|
|
601
|
+
this.switchContactMethod(e),
|
|
602
|
+
);
|
|
603
|
+
this.contactMethodsOutdatedButton.addEventListener('click', (e) =>
|
|
604
|
+
this.handleTotpConsentContactMethodsOutdated(e),
|
|
605
|
+
);
|
|
606
|
+
|
|
607
|
+
this.entryBackbutton.addEventListener('click', () => {
|
|
608
|
+
this.handleBackClick();
|
|
609
|
+
});
|
|
610
|
+
|
|
611
|
+
this.backButton.addEventListener('click', () => {
|
|
612
|
+
this.handleBackClick();
|
|
613
|
+
});
|
|
614
|
+
|
|
615
|
+
CloseIframeButtons.forEach((button) => {
|
|
616
|
+
button.addEventListener(
|
|
617
|
+
'click',
|
|
618
|
+
() => {
|
|
619
|
+
this.closeWindow();
|
|
620
|
+
},
|
|
621
|
+
false,
|
|
622
|
+
);
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
closeWindow() {
|
|
627
|
+
const referenceWindow = this.window.parent;
|
|
628
|
+
referenceWindow.postMessage('SmileIdentity::Close', '*');
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
handleBackClick() {
|
|
632
|
+
const page = this.pages.pop();
|
|
633
|
+
if (page) {
|
|
634
|
+
this.setActiveScreen(page);
|
|
635
|
+
} else {
|
|
636
|
+
this.dispatchEvent(
|
|
637
|
+
new CustomEvent('end-user-consent.totp.cancelled', {}),
|
|
638
|
+
);
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
connectedCallback() {
|
|
643
|
+
const template = document.createElement('template');
|
|
644
|
+
template.innerHTML = this.render();
|
|
645
|
+
|
|
646
|
+
this.shadowRoot.appendChild(template.content.cloneNode(true));
|
|
647
|
+
this.setUpEventListeners();
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
switchContactMethod() {
|
|
651
|
+
this.queryOtpModes();
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
resetForm() {
|
|
655
|
+
const invalidElements =
|
|
656
|
+
this.activeScreen.querySelectorAll('[aria-invalid]');
|
|
657
|
+
invalidElements.forEach((el) => el.removeAttribute('aria-invalid'));
|
|
658
|
+
|
|
659
|
+
const validationMessages = this.activeScreen.querySelectorAll(
|
|
660
|
+
'.validation-message',
|
|
661
|
+
);
|
|
662
|
+
validationMessages.forEach((el) => el.remove());
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
handleIdNumberValidationErrors(errors) {
|
|
666
|
+
const fields = Object.keys(errors);
|
|
667
|
+
|
|
668
|
+
fields.forEach((field) => {
|
|
669
|
+
const input = this.activeScreen.querySelector(`#${field}`);
|
|
670
|
+
input.setAttribute('aria-invalid', 'true');
|
|
671
|
+
input.setAttribute('aria-describedby', `${field}-hint`);
|
|
672
|
+
|
|
673
|
+
const errorDiv = document.createElement('div');
|
|
674
|
+
errorDiv.setAttribute('id', `${field}-hint`);
|
|
675
|
+
errorDiv.setAttribute('class', 'validation-message');
|
|
676
|
+
// eslint-disable-next-line prefer-destructuring
|
|
677
|
+
errorDiv.textContent = errors[field][0];
|
|
678
|
+
|
|
679
|
+
input.insertAdjacentElement('afterend', errorDiv);
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
handleActiveScreenErrors(error) {
|
|
684
|
+
const submitButton = this.activeScreen.querySelector('[type="submit"]');
|
|
685
|
+
const errorDiv = document.createElement('div');
|
|
686
|
+
errorDiv.setAttribute('class', 'validation-message');
|
|
687
|
+
errorDiv.textContent = error;
|
|
688
|
+
submitButton.insertAdjacentElement('beforebegin', errorDiv);
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
validateIdNumber(idNumber) {
|
|
692
|
+
const validationConstraints = {
|
|
693
|
+
id_number: {
|
|
694
|
+
format: new RegExp(this.idRegex),
|
|
695
|
+
presence: {
|
|
696
|
+
allowEmpty: false,
|
|
697
|
+
message: 'is required',
|
|
698
|
+
},
|
|
699
|
+
},
|
|
700
|
+
};
|
|
701
|
+
|
|
702
|
+
const errors = validate({ id_number: idNumber }, validationConstraints);
|
|
703
|
+
|
|
704
|
+
if (errors) {
|
|
705
|
+
this.handleIdNumberValidationErrors(errors);
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
return errors;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
async queryOtpModes(event) {
|
|
712
|
+
if (event) {
|
|
713
|
+
// ACTION: disable another submission
|
|
714
|
+
event.preventDefault();
|
|
715
|
+
|
|
716
|
+
// ACTION: Reset any form validation errors'
|
|
717
|
+
this.resetForm();
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
// ACTION: Validate idNumber
|
|
721
|
+
const validationErrors = this.validateIdNumber(this.idNumberInput.value);
|
|
722
|
+
|
|
723
|
+
// ACTION: Get and set idNumber
|
|
724
|
+
localStorage.setItem('idNumber', this.idNumberInput.value || this.idNumber);
|
|
725
|
+
|
|
726
|
+
if (!validationErrors) {
|
|
727
|
+
const data = {
|
|
728
|
+
country: this.country,
|
|
729
|
+
id_number: this.idNumber,
|
|
730
|
+
id_type: this.idType,
|
|
731
|
+
partner_id: this.partnerId,
|
|
732
|
+
token: this.token,
|
|
733
|
+
};
|
|
734
|
+
const url = `${this.baseUrl}/totp_consent`;
|
|
735
|
+
|
|
736
|
+
try {
|
|
737
|
+
this.toggleLoading();
|
|
738
|
+
const response = await postData(url, data);
|
|
739
|
+
const json = await response.json();
|
|
740
|
+
this.toggleLoading();
|
|
741
|
+
|
|
742
|
+
if (!response.ok) {
|
|
743
|
+
this.handleActiveScreenErrors(json.error);
|
|
744
|
+
} else {
|
|
745
|
+
this.sessionId = json.session_id;
|
|
746
|
+
this.modes = json.modes;
|
|
747
|
+
this.setActiveScreen(this.selectModeScreen);
|
|
748
|
+
this.setAttribute('modes', json.modes);
|
|
749
|
+
}
|
|
750
|
+
} catch (error) {
|
|
751
|
+
this.toggleLoading();
|
|
752
|
+
this.handleActiveScreenErrors(error.message);
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
async selectOtpMode(event) {
|
|
758
|
+
// ACTION: disable another submission
|
|
759
|
+
event.preventDefault();
|
|
760
|
+
|
|
761
|
+
// ACTION: Reset any form validation errors'
|
|
762
|
+
this.resetForm();
|
|
763
|
+
|
|
764
|
+
// ACTION: Get mode
|
|
765
|
+
this.mode = Array.prototype.find.call(
|
|
766
|
+
this.modeInputs,
|
|
767
|
+
(node) => node.checked,
|
|
768
|
+
).value;
|
|
769
|
+
const data = {
|
|
770
|
+
country: this.country,
|
|
771
|
+
id_number: this.idNumber,
|
|
772
|
+
id_type: this.idType,
|
|
773
|
+
mode: this.mode,
|
|
774
|
+
partner_id: this.partnerId,
|
|
775
|
+
session_id: this.sessionId,
|
|
776
|
+
token: this.token,
|
|
777
|
+
};
|
|
778
|
+
const url = `${this.baseUrl}/totp_consent/mode`;
|
|
779
|
+
|
|
780
|
+
try {
|
|
781
|
+
this.toggleLoading();
|
|
782
|
+
const response = await postData(url, data);
|
|
783
|
+
const json = await response.json();
|
|
784
|
+
this.toggleLoading();
|
|
785
|
+
|
|
786
|
+
if (!response.ok) {
|
|
787
|
+
this.handleActiveScreenErrors(json.error);
|
|
788
|
+
} else {
|
|
789
|
+
this.selectedOtpDeliveryMode = this.modes.filter(
|
|
790
|
+
(mode) => mode[this.mode],
|
|
791
|
+
)[0][this.mode];
|
|
792
|
+
this.setActiveScreen(this.otpVerificationScreen);
|
|
793
|
+
this.setAttribute('otp-delivery-mode', this.selectedOtpDeliveryMode);
|
|
794
|
+
}
|
|
795
|
+
} catch (error) {
|
|
796
|
+
this.toggleLoading();
|
|
797
|
+
this.handleActiveScreenErrors(error.message);
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
async submitOtp(event) {
|
|
802
|
+
// ACTION: disable another submission
|
|
803
|
+
event.preventDefault();
|
|
804
|
+
|
|
805
|
+
// ACTION: Reset any form validation errors'
|
|
806
|
+
this.resetForm();
|
|
807
|
+
|
|
808
|
+
this.otp = this.otpInput.value;
|
|
809
|
+
|
|
810
|
+
const data = {
|
|
811
|
+
country: this.country,
|
|
812
|
+
id_number: this.idNumber,
|
|
813
|
+
id_type: this.idType,
|
|
814
|
+
otp: this.otp,
|
|
815
|
+
partner_id: this.partnerId,
|
|
816
|
+
session_id: this.sessionId,
|
|
817
|
+
token: this.token,
|
|
818
|
+
};
|
|
819
|
+
const url = `${this.baseUrl}/totp_consent/otp`;
|
|
820
|
+
|
|
821
|
+
try {
|
|
822
|
+
this.toggleLoading();
|
|
823
|
+
const response = await postData(url, data);
|
|
824
|
+
const json = await response.json();
|
|
825
|
+
this.toggleLoading();
|
|
826
|
+
|
|
827
|
+
if (!response.ok) {
|
|
828
|
+
this.handleActiveScreenErrors(json.error);
|
|
829
|
+
} else {
|
|
830
|
+
this.handleTotpConsentGrant(event);
|
|
831
|
+
}
|
|
832
|
+
} catch (error) {
|
|
833
|
+
this.toggleLoading();
|
|
834
|
+
this.handleActiveScreenErrors(error.message);
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
toggleLoading() {
|
|
839
|
+
const button = this.activeScreen.querySelector('button[type="submit"]');
|
|
840
|
+
const text = button.querySelector('.text');
|
|
841
|
+
const arrow = button.querySelector('svg');
|
|
842
|
+
const spinner = button.querySelector('.spinner');
|
|
843
|
+
|
|
844
|
+
button.toggleAttribute('disabled');
|
|
845
|
+
text.toggleAttribute('hidden');
|
|
846
|
+
arrow.toggleAttribute('hidden');
|
|
847
|
+
spinner.toggleAttribute('hidden');
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
setActiveScreen(screen) {
|
|
851
|
+
this.activeScreen.hidden = true;
|
|
852
|
+
screen.hidden = false;
|
|
853
|
+
this.activeScreen = screen;
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
get baseUrl() {
|
|
857
|
+
return this.getAttribute('base-url');
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
get country() {
|
|
861
|
+
return this.getAttribute('country');
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
get idHint() {
|
|
865
|
+
return this.getAttribute('id-hint') || 'Your BVN should be 11 digits long';
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
get idNumber() {
|
|
869
|
+
return localStorage.getItem('idNumber');
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
get idRegex() {
|
|
873
|
+
return this.getAttribute('id-regex');
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
get idType() {
|
|
877
|
+
return this.getAttribute('id-type');
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
get idTypeLabel() {
|
|
881
|
+
return this.getAttribute('id-type-label');
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
get partnerId() {
|
|
885
|
+
return this.getAttribute('partner-id');
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
get partnerName() {
|
|
889
|
+
return this.getAttribute('partner-name');
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
get token() {
|
|
893
|
+
return this.getAttribute('token');
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
handleTotpConsentGrant() {
|
|
897
|
+
const customEvent = new CustomEvent('end-user-consent.totp.granted', {
|
|
898
|
+
detail: {
|
|
899
|
+
consented: {
|
|
900
|
+
contact_information: true,
|
|
901
|
+
document_information: true,
|
|
902
|
+
personal_details: true,
|
|
903
|
+
},
|
|
904
|
+
id_number: this.idNumber,
|
|
905
|
+
session_id: this.sessionId,
|
|
906
|
+
},
|
|
907
|
+
});
|
|
908
|
+
|
|
909
|
+
this.dispatchEvent(customEvent);
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
handleTotpConsentContactMethodsOutdated() {
|
|
913
|
+
const tag = 'end-user-consent.totp.denied.contact-methods-outdated';
|
|
914
|
+
const customEvent = new CustomEvent(tag, {
|
|
915
|
+
detail: {
|
|
916
|
+
data: {
|
|
917
|
+
id_number: this.idNumber,
|
|
918
|
+
session_id: this.sessionId,
|
|
919
|
+
},
|
|
920
|
+
message: tag,
|
|
921
|
+
},
|
|
922
|
+
});
|
|
923
|
+
|
|
924
|
+
this.dispatchEvent(customEvent);
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
if ('customElements' in window) {
|
|
929
|
+
window.customElements.define('totp-consent', TotpConsent);
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
export {
|
|
933
|
+
// eslint-disable-next-line import/prefer-default-export
|
|
934
|
+
TotpConsent,
|
|
935
|
+
};
|