@smileid/web-components 11.5.0 → 11.6.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.
Files changed (82) hide show
  1. package/dist/esm/DocumentCaptureScreens-DjSTdVP-.js +5398 -0
  2. package/dist/esm/DocumentCaptureScreens-DjSTdVP-.js.map +1 -0
  3. package/dist/esm/{Navigation-Xg565kcu.js → Navigation-6DH3vF4-.js} +2 -2
  4. package/dist/esm/{Navigation-Xg565kcu.js.map → Navigation-6DH3vF4-.js.map} +1 -1
  5. package/dist/esm/{PoweredBySmileId-CxbaihMu.js → PoweredBySmileId-DoKwoPUd.js} +424 -6
  6. package/dist/esm/PoweredBySmileId-DoKwoPUd.js.map +1 -0
  7. package/dist/esm/{SelfieCaptureScreens-D3KuMzZA.js → SelfieCaptureScreens-CtX-4Tco.js} +5 -6
  8. package/dist/esm/SelfieCaptureScreens-CtX-4Tco.js.map +1 -0
  9. package/dist/esm/combobox.js +1 -1
  10. package/dist/esm/document.js +1 -1
  11. package/dist/esm/end-user-consent.js +713 -2
  12. package/dist/esm/end-user-consent.js.map +1 -1
  13. package/dist/esm/index-BqyuTk9f.js +1366 -0
  14. package/dist/esm/{index-CUwa6MPI.js.map → index-BqyuTk9f.js.map} +1 -1
  15. package/dist/esm/localisation.js +1 -1
  16. package/dist/esm/main.js +14 -14
  17. package/dist/esm/navigation.js +1 -1
  18. package/dist/esm/{package-BmVbDNny.js → package-CjZI-cNQ.js} +177 -172
  19. package/dist/esm/{package-BmVbDNny.js.map → package-CjZI-cNQ.js.map} +1 -1
  20. package/dist/esm/selfie.js +1 -1
  21. package/dist/esm/smart-camera-web.js +32 -18
  22. package/dist/esm/smart-camera-web.js.map +1 -1
  23. package/dist/esm/totp-consent.js +731 -2
  24. package/dist/esm/totp-consent.js.map +1 -1
  25. package/dist/esm/validate.js +31 -0
  26. package/dist/esm/validate.js.map +1 -0
  27. package/dist/smart-camera-web.js +696 -321
  28. package/dist/smart-camera-web.js.map +1 -1
  29. package/dist/types/main.d.ts +7 -1
  30. package/dist/types/validate.d.ts +21 -0
  31. package/lib/components/document/src/DocumentCaptureScreens.js +97 -18
  32. package/lib/components/document/src/assets/lottie.d.ts +12 -0
  33. package/lib/components/document/src/assets/svg-inline.d.ts +8 -0
  34. package/lib/components/document/src/document-auto-capture/DocumentAutoCapture.stories.js +75 -0
  35. package/lib/components/document/src/document-auto-capture/DocumentAutoCapture.tsx +1458 -0
  36. package/lib/components/document/src/document-auto-capture/README.md +73 -0
  37. package/lib/components/document/src/document-auto-capture/assets/Greenbook_Shimmer.svg +42 -0
  38. package/lib/components/document/src/document-auto-capture/assets/ID_Back_Shimmer.svg +8 -0
  39. package/lib/components/document/src/document-auto-capture/assets/ID_Front_Shimmer.svg +20 -0
  40. package/lib/components/document/src/document-auto-capture/assets/Passport-Shimmer.svg +143 -0
  41. package/lib/components/document/src/document-auto-capture/assets/shimmers.ts +21 -0
  42. package/lib/components/document/src/document-auto-capture/assets/svg-raw.d.ts +4 -0
  43. package/lib/components/document/src/document-auto-capture/components/CaptureButton.tsx +122 -0
  44. package/lib/components/document/src/document-auto-capture/components/Overlay.tsx +167 -0
  45. package/lib/components/document/src/document-auto-capture/components/TuningPanel.tsx +856 -0
  46. package/lib/components/document/src/document-auto-capture/constants/captureLayout.ts +58 -0
  47. package/lib/components/document/src/document-auto-capture/detection/cvErrorRecovery.ts +40 -0
  48. package/lib/components/document/src/document-auto-capture/detection/documentAspect.ts +20 -0
  49. package/lib/components/document/src/document-auto-capture/detection/qualityScoring.ts +35 -0
  50. package/lib/components/document/src/document-auto-capture/detection/seamRejection.ts +209 -0
  51. package/lib/components/document/src/document-auto-capture/detection/synthesisTiming.ts +10 -0
  52. package/lib/components/document/src/document-auto-capture/hooks/useCamera.ts +117 -0
  53. package/lib/components/document/src/document-auto-capture/hooks/useCardDetection.ts +3059 -0
  54. package/lib/components/document/src/document-auto-capture/index.ts +4 -0
  55. package/lib/components/document/src/document-auto-capture/theme.ts +40 -0
  56. package/lib/components/document/src/document-auto-capture/utils/debug.ts +25 -0
  57. package/lib/components/document/src/document-auto-capture/utils/opencvLoader.ts +86 -0
  58. package/lib/components/document/src/document-capture-instructions/DocumentCaptureInstructions.tsx +327 -244
  59. package/lib/components/document/src/document-capture-review/DocumentCaptureReview.js +153 -189
  60. package/lib/components/document/src/document-capture-submission/DocumentCaptureSubmission.tsx +432 -0
  61. package/lib/components/document/src/document-capture-submission/index.js +3 -0
  62. package/lib/components/selfie/README.md +13 -0
  63. package/lib/components/signature-pad/package.json +1 -1
  64. package/lib/components/smart-camera-web/src/README.md +11 -0
  65. package/lib/components/smart-camera-web/src/SmartCameraWeb.js +25 -1
  66. package/lib/components/totp-consent/src/TotpConsent.js +1 -1
  67. package/package.json +8 -4
  68. package/dist/esm/DocumentCaptureScreens-ucJDu5nH.js +0 -2232
  69. package/dist/esm/DocumentCaptureScreens-ucJDu5nH.js.map +0 -1
  70. package/dist/esm/EndUserConsent-CsiwoThZ.js +0 -717
  71. package/dist/esm/EndUserConsent-CsiwoThZ.js.map +0 -1
  72. package/dist/esm/PoweredBySmileId-CxbaihMu.js.map +0 -1
  73. package/dist/esm/SelfieCaptureScreens-D3KuMzZA.js.map +0 -1
  74. package/dist/esm/TotpConsent-CRtmtudl.js +0 -734
  75. package/dist/esm/TotpConsent-CRtmtudl.js.map +0 -1
  76. package/dist/esm/index-CUwa6MPI.js +0 -1363
  77. package/dist/esm/styles-BTEClL7R.js +0 -419
  78. package/dist/esm/styles-BTEClL7R.js.map +0 -1
  79. /package/lib/components/document/src/assets/lottie/{taking photo of green book passport.lottie → greenbook.lottie} +0 -0
  80. /package/lib/components/document/src/assets/lottie/{taking photo of ID FLIP 2D.lottie → id-card-flip.lottie} +0 -0
  81. /package/lib/components/document/src/assets/lottie/{taking photo of ID.lottie → id-card.lottie} +0 -0
  82. /package/lib/components/document/src/assets/lottie/{taking photo of passport 2.lottie → passport.lottie} +0 -0
@@ -1,5 +1,734 @@
1
- import { T as e } from "./TotpConsent-CRtmtudl.js";
1
+ import d from "./validate.js";
2
+ import { b as l } from "./index-BqyuTk9f.js";
3
+ function a(n, t) {
4
+ return fetch(n, {
5
+ body: JSON.stringify(t),
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
+ function c() {
16
+ return `
17
+ <style>
18
+ *,
19
+ *::before,
20
+ *::after {
21
+ box-sizing: border-box;
22
+ margin: 0;
23
+ padding: 0;
24
+ }
25
+
26
+ :host {
27
+ --flow-space: 1.5rem;
28
+
29
+ --color-dark: #404040;
30
+ --color-grey: #555B69;
31
+
32
+ --color-success: #1EB244;
33
+ --color-failure: #FFEDEB;
34
+ --color-failure-tint: #F86B58;
35
+
36
+ --color-richblue: #043C93;
37
+ --color-theme: ${this.themeColor};
38
+
39
+ --color-active: #2D2B2A;
40
+ --color-default: #001096;
41
+ --color-disabled: #848282;
42
+ }
43
+
44
+ html {
45
+ font-family: 'DM Sans', sans-serif;
46
+ }
47
+
48
+ [hidden] {
49
+ display: none !important;
50
+ }
51
+
52
+ [disabled] {
53
+ cursor: not-allowed !important;
54
+ }
55
+
56
+ .visually-hidden {
57
+ border: 0;
58
+ clip: rect(1px 1px 1px 1px);
59
+ clip: rect(1px, 1px, 1px, 1px);
60
+ height: auto;
61
+ margin: 0;
62
+ overflow: hidden;
63
+ padding: 0;
64
+ position: absolute;
65
+ white-space: nowrap;
66
+ width: 1px;
67
+ }
68
+
69
+ .color-dark {
70
+ color: var(--color-dark);
71
+ }
72
+
73
+ .color-grey {
74
+ color: var(--color-grey);
75
+ }
76
+
77
+ .flow > * + * {
78
+ margin-top: var(--flow-space);
79
+ }
80
+
81
+ .center {
82
+ margin-left: auto;
83
+ margin-right: auto;
84
+
85
+ text-align: center;
86
+ }
87
+
88
+ h1 {
89
+ font-size: 1.5rem;
90
+ font-weight: 700;
91
+ }
92
+
93
+ button, input, select, textarea {
94
+ font: inherit
95
+ }
96
+
97
+ label,
98
+ input,
99
+ select,
100
+ textarea {
101
+ --flow-space: .5rem;
102
+ display: block;
103
+ width: 100%;
104
+ }
105
+
106
+ input,
107
+ select,
108
+ textarea {
109
+ border: 1px solid #d1d8d6;
110
+ border-radius: .5rem;
111
+ padding: .75rem 1rem;
112
+ }
113
+
114
+ button {
115
+ --button-color: var(--color-default);
116
+ --flow-space: 3rem;
117
+ -webkit-appearance: none;
118
+ -moz-appearance: none;
119
+ align-items: center;
120
+ appearance: none;
121
+ background-color: transparent;
122
+ border-radius: 2.5rem;
123
+ border: none;
124
+ color: #ffffff;
125
+ cursor: pointer;
126
+ display: inline-flex;
127
+ font-size: 20px;
128
+ font-weight: 500;
129
+ inline-size: 100%;
130
+ justify-content: center;
131
+ letter-spacing: .05ch;
132
+ line-height: 1;
133
+ padding: 1rem 2.5rem;
134
+ text-align: center;
135
+ text-decoration: none;
136
+ }
137
+
138
+ button[data-variant='solid'] {
139
+ background-color: var(--button-color);
140
+ border: 2px solid var(--button-color);
141
+ }
142
+
143
+ button[data-variant='outline'] {
144
+ color: var(--button-color);
145
+ border: 2px solid var(--button-color);
146
+ }
147
+
148
+ button[data-variant='ghost'] {
149
+ color: var(--button-color);
150
+ }
151
+
152
+ button:hover,
153
+ button:focus,
154
+ button:active {
155
+ --button-color: var(--color-active);
156
+ }
157
+
158
+ button:disabled {
159
+ --button-color: var(--color-disabled);
160
+ }
161
+
162
+ button[data-type='icon'] {
163
+ height: 2rem;
164
+ padding: 0;
165
+ width: 2rem;
166
+ background: transparent;
167
+ }
168
+
169
+ input {
170
+ font: inherit;
171
+ }
172
+
173
+ fieldset {
174
+ margin: 0;
175
+ border: none;
176
+ }
177
+
178
+ .font-weight:bold {
179
+ font-weight: bold;
180
+ }
181
+
182
+ .justify-right {
183
+ justify-content: end !important;
184
+ }
185
+ .nav {
186
+ display: flex;
187
+ justify-content: space-between;
188
+ }
189
+
190
+ .back-wrapper {
191
+ display: flex;
192
+ align-items: center;
193
+ }
194
+
195
+ .back-button-text {
196
+ font-size: 11px;
197
+ line-height: 11px;
198
+ color: ${this.themeColor || "rgb(21, 31, 114)"};
199
+ }
200
+
201
+ #error,
202
+ .validation-message {
203
+ color: red;
204
+ text-transform: capitalize;
205
+ }
206
+
207
+ .input-group {
208
+ --flow-space: 1.5rem;
209
+ text-align: initial;
210
+ }
211
+
212
+ .input-radio {
213
+ --flow-space: 1.5rem;
214
+ background-color: #F8F8F8;
215
+ border-radius: .5rem;
216
+ padding: .625rem 1rem;
217
+ display: flex;
218
+ align-items: center;
219
+ }
220
+
221
+ .otp-mode {
222
+ display: flex;
223
+ align-items: center;
224
+ text-align: initial;
225
+ }
226
+
227
+ .otp-mode :first-child {
228
+ margin: 0;
229
+ margin-inline-end: 1rem;
230
+ }
231
+
232
+ .otp-mode :nth-child(2n) {
233
+ --flow-space: .5rem;
234
+ }
235
+
236
+ .input-radio [type='radio'] {
237
+ border-radius: 50%;
238
+ inline-size: 2rem;
239
+ block-size: 2rem;
240
+ margin-inline-end: .5rem;
241
+ background-color: white;
242
+ border: .125rem solid #f5f5f5;
243
+ }
244
+
245
+ #totp-token {
246
+ block-size: 3rem;
247
+ inline-size: 20rem;
248
+ max-inline-size: 100%;
249
+ background-color: #F5F5F5;
250
+ border: none;
251
+ border-bottom: 2px solid #2F718D;
252
+ font-size: 1.5rem;
253
+ text-align: center;
254
+ font-weight: 700;
255
+ letter-spacing: 2rem;
256
+ padding: .5rem 1rem;
257
+ margin-inline: auto;
258
+ }
259
+
260
+ @keyframes spin {
261
+ 0% {
262
+ transform: translate3d(-50%, -50%, 0) rotate(0deg);
263
+ }
264
+ 100% {
265
+ transform: translate3d(-50%, -50%, 0) rotate(360deg);
266
+ }
267
+ }
268
+
269
+ .spinner {
270
+ animation: 1.5s linear infinite spin;
271
+ animation-play-state: inherit;
272
+ border: solid 5px #cfd0d1;
273
+ border-bottom-color: var(--color-active);
274
+ border-radius: 50%;
275
+ content: "";
276
+ display: block;
277
+ height: 25px;
278
+ width: 25px;
279
+ will-change: transform;
280
+ position: relative;
281
+ top: .675rem;
282
+ left: 1.25rem;
283
+ }
284
+ </style>
285
+
286
+ <div class='flow center' id='id-entry' dir='${this.direction}'>
287
+ <div class="nav">
288
+ <div class="back-wrapper">
289
+ <button type='button' data-type='icon' id="back-button" class="back-button">
290
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none">
291
+ <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"/>
292
+ <path fill="${this.themeColor}" 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"/>
293
+ </svg>
294
+ </button>
295
+ <div class="back-button-text">Back</div>
296
+ </div>
297
+ <button data-type='icon' type='button' class='close-iframe'>
298
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none">
299
+ <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"/>
300
+ <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"/>
301
+ </svg>
302
+ <span class='visually-hidden'>Close SmileIdentity Verification frame</span>
303
+ </button>
304
+ </div>
305
+ <h1>
306
+ Enter your ${this.idTypeLabel}
307
+ </h1>
308
+
309
+ <form name='id-entry-form' class='flow' novalidate style='--flow-space: 5.5rem'>
310
+ <div id='id-number' class="input-group flow">
311
+ <label class='required' for="id_number">
312
+ ${this.idTypeLabel}
313
+ </label>
314
+
315
+ <input aria-required='true' id="id_number" name="id_number"
316
+ maxlength='11' placeholder='' />
317
+
318
+ <p>
319
+ <small>${this.idHint}</small>
320
+ </p>
321
+ </div>
322
+
323
+ <button data-variant='solid' id='query-otp-modes' type='submit'>
324
+ <span class='text'>Continue</span>
325
+ <svg aria-hidden='true' width="25" height="24" fill="none" xmlns="http://www.w3.org/2000/svg">
326
+ <path d="M7 12h11m0 0-4.588-4M18 12l-4.588 4" stroke="#fff" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
327
+ </svg>
328
+ <span hidden class='spinner'></span>
329
+ </button>
330
+ </form>
331
+ </div>
332
+
333
+ <div hidden class='flow center' id='select-mode' dir='${this.direction}'>
334
+ <div class="nav">
335
+ <div class="back-wrapper">
336
+ <button type='button' data-type='icon' id="back-to-entry-button" class="back-button">
337
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none">
338
+ <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"/>
339
+ <path fill="${this.themeColor}" 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"/>
340
+ </svg>
341
+ </button>
342
+ <div class="back-button-text">Back</div>
343
+ </div>
344
+ <button data-type='icon' type='button' class='close-iframe'>
345
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none">
346
+ <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"/>
347
+ <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"/>
348
+ </svg>
349
+ <span class='visually-hidden'>Close SmileIdentity Verification frame</span>
350
+ </button>
351
+ </div>
352
+ <h1>
353
+ Select contact method
354
+ </h1>
355
+
356
+ <form name='select-mode-form' novalidate style='--flow-space: 4.25rem' id='otp-entry' class='flow center'>
357
+ <fieldset class='flow center'>
358
+ <legend class='flow' style='--flow-space: 1.5rem'>
359
+ <p>
360
+ NIBSS, the data custodian of BVN,&nbsp;
361
+ will send you a One-Time Password (OTP)
362
+ </p>
363
+
364
+ <p>
365
+ <small>
366
+ The request will be from Chams Plc, who is NIBSS' technical partner.
367
+ </small>
368
+ </p>
369
+ </legend>
370
+
371
+ <div class='flow center'>
372
+ ${this.modes.length ? this.modes.map(
373
+ (n) => `<label class='input-radio'>
374
+ <input type="radio" id="" name="mode" value="${Object.keys(n)[0]}">
375
+ <div class='otp-mode'>
376
+ ${Object.keys(n)[0].includes("sms") ? `
377
+ <svg xmlns="http://www.w3.org/2000/svg" width="29" height="37" fill="none">
378
+ <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"/>
379
+ <g filter="url(#sms)">
380
+ <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"/>
381
+ </g>
382
+ <defs>
383
+ <filter id="sms" width="20.023" height="15.595" x="1.675" y="21.005" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse">
384
+ <feFlood flood-opacity="0" result="BackgroundImageFix"/>
385
+ <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"/>
386
+ <feOffset dy="4"/>
387
+ <feGaussianBlur stdDeviation="2"/>
388
+ <feComposite in2="hardAlpha" operator="out"/>
389
+ <feColorMatrix values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
390
+ <feBlend in2="BackgroundImageFix" result="effect1_dropShadow_2_404"/>
391
+ <feBlend in="SourceGraphic" in2="effect1_dropShadow_2_404" result="shape"/>
392
+ </filter>
393
+ </defs>
394
+ </svg>
395
+ ` : `
396
+ <svg xmlns="http://www.w3.org/2000/svg" width="35" height="24" fill="none">
397
+ <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"/>
398
+ <g filter="url(#message)">
399
+ <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"/>
400
+ </g>
401
+ <defs>
402
+ <filter id="message" width="34.042" height="18.154" x=".676" y="2.316" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse">
403
+ <feFlood flood-opacity="0" result="BackgroundImageFix"/>
404
+ <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"/>
405
+ <feOffset dy="4"/>
406
+ <feGaussianBlur stdDeviation="2"/>
407
+ <feComposite in2="hardAlpha" operator="out"/>
408
+ <feColorMatrix values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
409
+ <feBlend in2="BackgroundImageFix" result="effect1_dropShadow_2_394"/>
410
+ <feBlend in="SourceGraphic" in2="effect1_dropShadow_2_394" result="shape"/>
411
+ </filter>
412
+ </defs>
413
+ </svg>
414
+ `}
415
+ <div class='flow'>
416
+ <p>
417
+ ${Object.values(n)[0]}
418
+ </p>
419
+ <p>
420
+ <small>
421
+ An OTP will be sent by ${Object.keys(n)[0].includes(
422
+ "sms"
423
+ ) ? "sms" : "email"} to verify your identity
424
+ </small>
425
+ </p>
426
+ </div>
427
+ </div>
428
+ </label>`
429
+ ).join(`
430
+ `) : "No modes yet"}
431
+ </div>
432
+ </fieldset>
433
+
434
+ <button data-variant='ghost' id='contact-methods-outdated' style='--flow-space: .5rem' class='' type='button'>
435
+ I am no longer using any of these options
436
+ </button>
437
+
438
+ <button data-variant='solid' id='select-otp-mode' type='submit'>
439
+ <span class='text'>Continue</span>
440
+ <svg aria-hidden='true' width="25" height="24" fill="none" xmlns="http://www.w3.org/2000/svg">
441
+ <path d="M7 12h11m0 0-4.588-4M18 12l-4.588 4" stroke="#fff" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
442
+ </svg>
443
+ <span hidden class='spinner'></span>
444
+ </button>
445
+ </form>
446
+ </div>
447
+
448
+ <div hidden class='flow center' id='otp-verification' dir='${this.direction}'>
449
+ <div class="nav justify-right">
450
+ <button data-type='icon' type='button' class='close-iframe'>
451
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none">
452
+ <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"/>
453
+ <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"/>
454
+ </svg>
455
+ <span class='visually-hidden'>Close SmileIdentity Verification frame</span>
456
+ </button>
457
+ </div>
458
+ <h1>
459
+ OTP Verification
460
+ </h1>
461
+
462
+ <div style='--flow-space: 4.25rem' id='otp-entry'>
463
+ <form name='otp-submission-form' novalidate style='--flow-space: 1.5rem' class='flow center'>
464
+ <label for='totp-token'>
465
+ Enter the OTP sent to <span class='font-weight:bold'>${this.selectedOtpDeliveryMode}</span>
466
+ </label>
467
+ <input type='text' id='totp-token' maxlength='6' inputmode='numeric' autocomplete='one-time-code' />
468
+
469
+ <p>
470
+ Didn't receive the OTP${this.selectedOtpDeliveryMode ? ` at <span class='font-weight:bold'>${this.selectedOtpDeliveryMode}</span>?` : "?"}
471
+ </p>
472
+
473
+ <button style='--flow-space: .5rem' data-variant='ghost' class='try-another-method' type='button'>
474
+ Try another contact method
475
+ </button>
476
+
477
+ <button data-variant='solid' id='submit-otp' type='submit'>
478
+ <span class='text'>Submit</span>
479
+ <svg aria-hidden='true' width="25" height="24" fill="none" xmlns="http://www.w3.org/2000/svg">
480
+ <path d="M7 12h11m0 0-4.588-4M18 12l-4.588 4" stroke="#fff" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
481
+ </svg>
482
+ <span hidden class='spinner'></span>
483
+ </button>
484
+ </form>
485
+ </div>
486
+ </div>
487
+ `;
488
+ }
489
+ class h extends HTMLElement {
490
+ constructor() {
491
+ super(), this.templateString = c.bind(this), this.render = () => this.templateString(), this.attachShadow({ mode: "open" }), this.modes = [], this["otp-delivery-mode"] = "", this.queryOtpModes = this.queryOtpModes.bind(this), this.selectOtpMode = this.selectOtpMode.bind(this), this.submitOtp = this.submitOtp.bind(this), this.switchContactMethod = this.switchContactMethod.bind(this), this.handleTotpConsentGrant = this.handleTotpConsentGrant.bind(this), this.handleTotpConsentContactMethodsOutdated = this.handleTotpConsentContactMethodsOutdated.bind(this), this.pages = [];
492
+ }
493
+ static get observedAttributes() {
494
+ return ["modes", "otp-delivery-mode"];
495
+ }
496
+ attributeChangedCallback(t) {
497
+ switch (t) {
498
+ case "modes":
499
+ case "otp-delivery-mode": {
500
+ const e = document.createElement("template");
501
+ e.innerHTML = this.render();
502
+ const i = e.content.cloneNode(!0).querySelector(`#${this.activeScreen.id}`);
503
+ i.hidden = !1, this.shadowRoot.replaceChild(i, this.activeScreen), this.setUpEventListeners(), this.setActiveScreen(i);
504
+ break;
505
+ }
506
+ }
507
+ }
508
+ setUpEventListeners() {
509
+ this.idEntryScreen = this.shadowRoot.querySelector("#id-entry"), this.selectModeScreen = this.shadowRoot.querySelector("#select-mode"), this.otpVerificationScreen = this.shadowRoot.querySelector("#otp-verification"), this.activeScreen || (this.activeScreen = this.idEntryScreen), this.queryOtpModesButton = this.idEntryScreen.querySelector("#query-otp-modes"), this.backButton = this.idEntryScreen.querySelector("#back-button"), this.selectOtpModeButton = this.selectModeScreen.querySelector("#select-otp-mode"), this.entryBackbutton = this.selectModeScreen.querySelector(
510
+ "#back-to-entry-button"
511
+ ), this.contactMethodsOutdatedButton = this.selectModeScreen.querySelector(
512
+ "#contact-methods-outdated"
513
+ ), this.submitOtpButton = this.otpVerificationScreen.querySelector("#submit-otp"), this.switchContactMethodButton = this.otpVerificationScreen.querySelector(
514
+ ".try-another-method"
515
+ );
516
+ const t = this.shadowRoot.querySelectorAll(".close-iframe");
517
+ this.idNumberInput = this.idEntryScreen.querySelector("#id_number"), this.modeInputs = this.selectModeScreen.querySelectorAll('[name="mode"]'), this.otpInput = this.otpVerificationScreen.querySelector("#totp-token"), this.queryOtpModesButton.addEventListener(
518
+ "click",
519
+ (e) => this.queryOtpModes(e)
520
+ ), this.selectOtpModeButton.addEventListener(
521
+ "click",
522
+ (e) => this.selectOtpMode(e)
523
+ ), this.submitOtpButton.addEventListener("click", (e) => this.submitOtp(e)), this.switchContactMethodButton.addEventListener(
524
+ "click",
525
+ (e) => this.switchContactMethod(e)
526
+ ), this.contactMethodsOutdatedButton.addEventListener(
527
+ "click",
528
+ (e) => this.handleTotpConsentContactMethodsOutdated(e)
529
+ ), this.entryBackbutton.addEventListener("click", () => {
530
+ this.handleBackClick();
531
+ }), this.backButton.addEventListener("click", () => {
532
+ this.handleBackClick();
533
+ }), t.forEach((e) => {
534
+ e.addEventListener(
535
+ "click",
536
+ () => {
537
+ this.closeWindow();
538
+ },
539
+ !1
540
+ );
541
+ });
542
+ }
543
+ closeWindow() {
544
+ const t = window.parent;
545
+ [t.parent, t].forEach((e) => {
546
+ e.postMessage("SmileIdentity::Close", "*");
547
+ });
548
+ }
549
+ handleBackClick() {
550
+ const t = this.pages.pop();
551
+ t ? this.setActiveScreen(t) : this.dispatchEvent(
552
+ new CustomEvent("end-user-consent.totp.cancelled", {})
553
+ );
554
+ }
555
+ connectedCallback() {
556
+ const t = document.createElement("template");
557
+ t.innerHTML = this.render(), this.shadowRoot.appendChild(t.content.cloneNode(!0)), this.setUpEventListeners();
558
+ }
559
+ switchContactMethod() {
560
+ this.queryOtpModes();
561
+ }
562
+ resetForm() {
563
+ this.activeScreen.querySelectorAll("[aria-invalid]").forEach((i) => i.removeAttribute("aria-invalid")), this.activeScreen.querySelectorAll(
564
+ ".validation-message"
565
+ ).forEach((i) => i.remove());
566
+ }
567
+ handleIdNumberValidationErrors(t) {
568
+ Object.keys(t).forEach((i) => {
569
+ const o = this.activeScreen.querySelector(`#${i}`);
570
+ o.setAttribute("aria-invalid", "true"), o.setAttribute("aria-describedby", `${i}-hint`);
571
+ const s = document.createElement("div");
572
+ s.setAttribute("id", `${i}-hint`), s.setAttribute("class", "validation-message"), s.textContent = t[i][0], o.insertAdjacentElement("afterend", s);
573
+ });
574
+ }
575
+ handleActiveScreenErrors(t) {
576
+ const e = this.activeScreen.querySelector('[type="submit"]'), i = document.createElement("div");
577
+ i.setAttribute("class", "validation-message"), i.textContent = t, e.insertAdjacentElement("beforebegin", i);
578
+ }
579
+ validateIdNumber(t) {
580
+ const e = {
581
+ id_number: {
582
+ format: new RegExp(this.idRegex),
583
+ presence: {
584
+ allowEmpty: !1,
585
+ message: "is required"
586
+ }
587
+ }
588
+ }, i = d({ id_number: t }, e);
589
+ return i && this.handleIdNumberValidationErrors(i), i;
590
+ }
591
+ async queryOtpModes(t) {
592
+ t && (t.preventDefault(), this.resetForm());
593
+ const e = this.validateIdNumber(this.idNumberInput.value);
594
+ if (localStorage.setItem("idNumber", this.idNumberInput.value || this.idNumber), !e) {
595
+ const i = {
596
+ country: this.country,
597
+ id_number: this.idNumber,
598
+ id_type: this.idType,
599
+ partner_id: this.partnerId,
600
+ token: this.token
601
+ }, o = `${this.baseUrl}/totp_consent`;
602
+ try {
603
+ this.toggleLoading();
604
+ const s = await a(o, i), r = await s.json();
605
+ this.toggleLoading(), s.ok ? (this.sessionId = r.session_id, this.modes = r.modes, this.setActiveScreen(this.selectModeScreen), this.setAttribute("modes", r.modes)) : this.handleActiveScreenErrors(r.error);
606
+ } catch (s) {
607
+ this.toggleLoading(), this.handleActiveScreenErrors(s.message);
608
+ }
609
+ }
610
+ }
611
+ async selectOtpMode(t) {
612
+ t.preventDefault(), this.resetForm(), this.mode = Array.prototype.find.call(
613
+ this.modeInputs,
614
+ (o) => o.checked
615
+ ).value;
616
+ const e = {
617
+ country: this.country,
618
+ id_number: this.idNumber,
619
+ id_type: this.idType,
620
+ mode: this.mode,
621
+ partner_id: this.partnerId,
622
+ session_id: this.sessionId,
623
+ token: this.token
624
+ }, i = `${this.baseUrl}/totp_consent/mode`;
625
+ try {
626
+ this.toggleLoading();
627
+ const o = await a(i, e), s = await o.json();
628
+ this.toggleLoading(), o.ok ? (this.selectedOtpDeliveryMode = this.modes.filter(
629
+ (r) => r[this.mode]
630
+ )[0][this.mode], this.setActiveScreen(this.otpVerificationScreen), this.setAttribute("otp-delivery-mode", this.selectedOtpDeliveryMode)) : this.handleActiveScreenErrors(s.error);
631
+ } catch (o) {
632
+ this.toggleLoading(), this.handleActiveScreenErrors(o.message);
633
+ }
634
+ }
635
+ async submitOtp(t) {
636
+ t.preventDefault(), this.resetForm(), this.otp = this.otpInput.value;
637
+ const e = {
638
+ country: this.country,
639
+ id_number: this.idNumber,
640
+ id_type: this.idType,
641
+ otp: this.otp,
642
+ partner_id: this.partnerId,
643
+ session_id: this.sessionId,
644
+ token: this.token
645
+ }, i = `${this.baseUrl}/totp_consent/otp`;
646
+ try {
647
+ this.toggleLoading();
648
+ const o = await a(i, e), s = await o.json();
649
+ this.toggleLoading(), o.ok ? this.handleTotpConsentGrant(t) : this.handleActiveScreenErrors(s.error);
650
+ } catch (o) {
651
+ this.toggleLoading(), this.handleActiveScreenErrors(o.message);
652
+ }
653
+ }
654
+ toggleLoading() {
655
+ const t = this.activeScreen.querySelector('button[type="submit"]'), e = t.querySelector(".text"), i = t.querySelector("svg"), o = t.querySelector(".spinner");
656
+ t.toggleAttribute("disabled"), e.toggleAttribute("hidden"), i.toggleAttribute("hidden"), o.toggleAttribute("hidden");
657
+ }
658
+ setActiveScreen(t) {
659
+ this.activeScreen.hidden = !0, t.hidden = !1, this.activeScreen = t;
660
+ }
661
+ get baseUrl() {
662
+ return this.getAttribute("base-url");
663
+ }
664
+ get country() {
665
+ return this.getAttribute("country");
666
+ }
667
+ get idHint() {
668
+ return this.getAttribute("id-hint") || "Your BVN should be 11 digits long";
669
+ }
670
+ get idNumber() {
671
+ return localStorage.getItem("idNumber");
672
+ }
673
+ get idRegex() {
674
+ return this.getAttribute("id-regex");
675
+ }
676
+ get idType() {
677
+ return this.getAttribute("id-type");
678
+ }
679
+ get idTypeLabel() {
680
+ return this.getAttribute("id-type-label");
681
+ }
682
+ get partnerId() {
683
+ return this.getAttribute("partner-id");
684
+ }
685
+ get partnerName() {
686
+ return this.getAttribute("partner-name");
687
+ }
688
+ get token() {
689
+ return this.getAttribute("token");
690
+ }
691
+ get themeColor() {
692
+ return this.getAttribute("theme-color") || "#001096";
693
+ }
694
+ get direction() {
695
+ return this.getAttribute("dir") || l() || "ltr";
696
+ }
697
+ get hideBack() {
698
+ return this.hasAttribute("hide-back");
699
+ }
700
+ get showNavigation() {
701
+ return this.hasAttribute("show-navigation");
702
+ }
703
+ handleTotpConsentGrant() {
704
+ const t = new CustomEvent("end-user-consent.totp.granted", {
705
+ detail: {
706
+ consented: {
707
+ contact_information: !0,
708
+ document_information: !0,
709
+ personal_details: !0
710
+ },
711
+ id_number: this.idNumber,
712
+ session_id: this.sessionId
713
+ }
714
+ });
715
+ this.dispatchEvent(t);
716
+ }
717
+ handleTotpConsentContactMethodsOutdated() {
718
+ const t = "end-user-consent.totp.denied.contact-methods-outdated", e = new CustomEvent(t, {
719
+ detail: {
720
+ data: {
721
+ id_number: this.idNumber,
722
+ session_id: this.sessionId
723
+ },
724
+ message: t
725
+ }
726
+ });
727
+ this.dispatchEvent(e);
728
+ }
729
+ }
730
+ "customElements" in window && !window.customElements.get("totp-consent") && window.customElements.define("totp-consent", h);
2
731
  export {
3
- e as TotpConsent
732
+ h as TotpConsent
4
733
  };
5
734
  //# sourceMappingURL=totp-consent.js.map