@smileid/web-components 1.5.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +58 -48
- package/{components → src/components}/combobox/src/Combobox.js +4 -1
- package/{components → src/components}/document/src/DocumentCaptureScreens.js +409 -409
- package/{components → src/components}/document/src/document-capture/DocumentCapture.js +760 -760
- package/{components → src/components}/end-user-consent/src/EndUserConsent.js +4 -1
- package/{components → src/components}/navigation/src/Navigation.js +4 -1
- package/{components → src/components}/selfie/src/SelfieCaptureScreens.js +282 -290
- package/{components → src/components}/selfie/src/selfie-capture/SelfieCapture.js +1010 -1011
- package/{components → src/components}/selfie/src/selfie-capture/SelfieCapture.stories.js +36 -36
- package/{components → src/components}/signature-pad/package.json +30 -30
- package/{components → src/components}/signature-pad/src/SignaturePad.js +4 -1
- package/{components → src/components}/smart-camera-web/src/SmartCameraWeb.js +1 -1
- package/{components → src/components}/totp-consent/src/TotpConsent.js +1 -1
- package/.eslintrc.cjs +0 -72
- package/cypress/e2e/smart-camera-web-agent-mode.cy.js +0 -144
- package/cypress/e2e/smart-camera-web-attribution.cy.js +0 -249
- package/cypress/e2e/smart-camera-web-back-press.cy.js +0 -481
- package/cypress/e2e/smart-camera-web-complete-flow.cy.js +0 -221
- package/cypress/e2e/smart-camera-web-hide-back-to-host.cy.js +0 -61
- package/cypress/e2e/smart-camera-web-hide-instructions.cy.js +0 -334
- package/cypress/e2e/smart-camera-web.cy.js +0 -309
- package/cypress/fixtures/example.json +0 -5
- package/cypress/pages/capture-back-of-id-hide-attribution.html +0 -44
- package/cypress/pages/capture-back-of-id-navigation.html +0 -72
- package/cypress/pages/smart-camera-web-agent-mode.html +0 -36
- package/cypress/pages/smart-camera-web-complete-flow.html +0 -42
- package/cypress/pages/smart-camera-web-hide-instructions.html +0 -38
- package/cypress/pages/smart-camera-web.html +0 -38
- package/cypress/support/commands.js +0 -144
- package/cypress/support/e2e.js +0 -20
- package/cypress.config.js +0 -11
- package/esbuild.js +0 -119
- /package/{components → src/components}/README.md +0 -0
- /package/{components → src/components}/attribution/PoweredBySmileId.js +0 -0
- /package/{components → src/components}/camera-permission/CameraPermission.js +0 -0
- /package/{components → src/components}/camera-permission/CameraPermission.stories.js +0 -0
- /package/{components → src/components}/combobox/src/index.js +0 -0
- /package/{components → src/components}/document/src/DocumentCaptureScreens.stories.js +0 -0
- /package/{components → src/components}/document/src/README.md +0 -0
- /package/{components → src/components}/document/src/document-capture/DocumentCapture.stories.js +0 -0
- /package/{components → src/components}/document/src/document-capture/README.md +0 -0
- /package/{components → src/components}/document/src/document-capture/index.js +0 -0
- /package/{components → src/components}/document/src/document-capture-instructions/DocumentCaptureInstructions.js +0 -0
- /package/{components → src/components}/document/src/document-capture-instructions/DocumentCaptureInstructions.stories.js +0 -0
- /package/{components → src/components}/document/src/document-capture-instructions/README.md +0 -0
- /package/{components → src/components}/document/src/document-capture-instructions/index.js +0 -0
- /package/{components → src/components}/document/src/document-capture-review/DocumentCaptureReview.js +0 -0
- /package/{components → src/components}/document/src/document-capture-review/DocumentCaptureReview.stories.js +0 -0
- /package/{components → src/components}/document/src/document-capture-review/README.md +0 -0
- /package/{components → src/components}/document/src/document-capture-review/index.js +0 -0
- /package/{components → src/components}/document/src/index.js +0 -0
- /package/{components → src/components}/end-user-consent/src/EndUserConsent.stories.js +0 -0
- /package/{components → src/components}/end-user-consent/src/index.js +0 -0
- /package/{components → src/components}/navigation/src/Navigation.stories.js +0 -0
- /package/{components → src/components}/navigation/src/index.js +0 -0
- /package/{components → src/components}/selfie/README.md +0 -0
- /package/{components → src/components}/selfie/src/SelfieCaptureScreens.stories.js +0 -0
- /package/{components → src/components}/selfie/src/index.js +0 -0
- /package/{components → src/components}/selfie/src/selfie-capture/index.js +0 -0
- /package/{components → src/components}/selfie/src/selfie-capture-instructions/SelfieCaptureInstructions.js +0 -0
- /package/{components → src/components}/selfie/src/selfie-capture-instructions/SelfieCaptureInstructions.stories.js +0 -0
- /package/{components → src/components}/selfie/src/selfie-capture-instructions/index.js +0 -0
- /package/{components → src/components}/selfie/src/selfie-capture-review/SelfieCaptureReview.js +0 -0
- /package/{components → src/components}/selfie/src/selfie-capture-review/SelfieCaptureReview.stories.js +0 -0
- /package/{components → src/components}/selfie/src/selfie-capture-review/index.js +0 -0
- /package/{components → src/components}/signature-pad/package-lock.json +0 -0
- /package/{components → src/components}/signature-pad/src/SignaturePad.stories.js +0 -0
- /package/{components → src/components}/signature-pad/src/index.js +0 -0
- /package/{components → src/components}/smart-camera-web/src/README.md +0 -0
- /package/{components → src/components}/smart-camera-web/src/SmartCameraWeb.stories.js +0 -0
- /package/{components → src/components}/totp-consent/src/index.js +0 -0
- /package/{domain → src/domain}/camera/src/README.md +0 -0
- /package/{domain → src/domain}/camera/src/SmartCamera.js +0 -0
- /package/{domain → src/domain}/constants/src/Constants.js +0 -0
- /package/{domain → src/domain}/file-upload/README.md +0 -0
- /package/{domain → src/domain}/file-upload/src/SmartFileUpload.js +0 -0
- /package/{index.js → src/index.js} +0 -0
- /package/{styles → src/styles}/README.md +0 -0
- /package/{styles → src/styles}/src/styles.js +0 -0
- /package/{styles → src/styles}/src/typography.js +0 -0
|
@@ -782,7 +782,10 @@ class EndUserConsent extends HTMLElement {
|
|
|
782
782
|
}
|
|
783
783
|
}
|
|
784
784
|
|
|
785
|
-
if (
|
|
785
|
+
if (
|
|
786
|
+
'customElements' in window &&
|
|
787
|
+
!window.customElements.get('end-user-consent')
|
|
788
|
+
) {
|
|
786
789
|
window.customElements.define('end-user-consent', EndUserConsent);
|
|
787
790
|
}
|
|
788
791
|
|
|
@@ -161,7 +161,10 @@ button[data-type="icon"] {
|
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
-
if (
|
|
164
|
+
if (
|
|
165
|
+
'customElements' in window &&
|
|
166
|
+
!window.customElements.get('smileid-navigation')
|
|
167
|
+
) {
|
|
165
168
|
window.customElements.define('smileid-navigation', Navigation);
|
|
166
169
|
}
|
|
167
170
|
|
|
@@ -1,290 +1,282 @@
|
|
|
1
|
-
import './selfie-capture';
|
|
2
|
-
import './selfie-capture-instructions';
|
|
3
|
-
import './selfie-capture-review';
|
|
4
|
-
import SmartCamera from '../../../domain/camera/src/SmartCamera';
|
|
5
|
-
import styles from '../../../styles/src/styles';
|
|
6
|
-
import packageJson from '
|
|
7
|
-
|
|
8
|
-
const COMPONENTS_VERSION = packageJson.version;
|
|
9
|
-
|
|
10
|
-
const smartCameraWeb = document.querySelector('smart-camera-web');
|
|
11
|
-
|
|
12
|
-
async function getPermissions(captureScreen, facingMode = 'user') {
|
|
13
|
-
try {
|
|
14
|
-
const stream = await SmartCamera.getMedia({
|
|
15
|
-
audio: false,
|
|
16
|
-
video: { facingMode },
|
|
17
|
-
});
|
|
18
|
-
const devices = await navigator.mediaDevices.enumerateDevices();
|
|
19
|
-
const videoDevice = devices.find(
|
|
20
|
-
(device) =>
|
|
21
|
-
device.kind === 'videoinput' &&
|
|
22
|
-
stream.getVideoTracks()[0].getSettings().deviceId === device.deviceId,
|
|
23
|
-
);
|
|
24
|
-
smartCameraWeb?.dispatchEvent(
|
|
25
|
-
new CustomEvent('metadata.camera-name', {
|
|
26
|
-
detail: { cameraName: videoDevice?.label },
|
|
27
|
-
}),
|
|
28
|
-
);
|
|
29
|
-
captureScreen.removeAttribute('data-camera-error');
|
|
30
|
-
captureScreen.setAttribute('data-camera-ready', true);
|
|
31
|
-
} catch (error) {
|
|
32
|
-
captureScreen.removeAttribute('data-camera-ready');
|
|
33
|
-
captureScreen.setAttribute(
|
|
34
|
-
'data-camera-error',
|
|
35
|
-
SmartCamera.handleCameraError(error),
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
class SelfieCaptureScreens extends HTMLElement {
|
|
41
|
-
constructor() {
|
|
42
|
-
super();
|
|
43
|
-
this.activeScreen = null;
|
|
44
|
-
smartCameraWeb?.dispatchEvent(new CustomEvent('metadata.initialize'));
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
connectedCallback() {
|
|
48
|
-
this.innerHTML = `
|
|
49
|
-
${styles(this.themeColor)}
|
|
50
|
-
<div>
|
|
51
|
-
<selfie-capture-instructions theme-color='${this.themeColor}' ${this.showNavigation} ${this.hideAttribution} ${this.hideBack} hidden></selfie-capture-instructions>
|
|
52
|
-
<selfie-capture theme-color='${this.themeColor}' ${this.showNavigation} ${this.allowAgentMode} ${this.allowAgentModeTests} ${this.hideAttribution} ${this.disableImageTests} hidden></selfie-capture>
|
|
53
|
-
<selfie-capture-review theme-color='${this.themeColor}' ${this.showNavigation} ${this.hideAttribution} hidden></selfie-capture-review>
|
|
54
|
-
</div>
|
|
55
|
-
`;
|
|
56
|
-
|
|
57
|
-
this._data = {
|
|
58
|
-
images: [],
|
|
59
|
-
meta: {
|
|
60
|
-
libraryVersion: COMPONENTS_VERSION,
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
this.selfieInstruction = this.querySelector('selfie-capture-instructions');
|
|
65
|
-
this.selfieCapture = this.querySelector('selfie-capture');
|
|
66
|
-
this.selfieReview = this.querySelector('selfie-capture-review');
|
|
67
|
-
|
|
68
|
-
if (this.hideInstructions && !this.hasAttribute('hidden')) {
|
|
69
|
-
getPermissions(this.selfieCapture, this.getAgentMode());
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// If the initial screen is selfie-capture, we need to get permissions
|
|
73
|
-
if (this.getAttribute('initial-screen') === 'selfie-capture') {
|
|
74
|
-
getPermissions(this.selfieCapture, this.getAgentMode()).then(() =>
|
|
75
|
-
this.setActiveScreen(this.selfieCapture),
|
|
76
|
-
);
|
|
77
|
-
} else if (this.hideInstructions) {
|
|
78
|
-
this.setActiveScreen(this.selfieCapture);
|
|
79
|
-
} else {
|
|
80
|
-
this.setActiveScreen(this.selfieInstruction);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
this.setUpEventListeners();
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
getAgentMode() {
|
|
87
|
-
return this.inAgentMode ? 'environment' : 'user';
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
disconnectedCallback() {
|
|
91
|
-
SmartCamera.stopMedia();
|
|
92
|
-
if (this.activeScreen) {
|
|
93
|
-
this.activeScreen.removeAttribute('hidden');
|
|
94
|
-
}
|
|
95
|
-
this.activeScreen = null;
|
|
96
|
-
this.innerHTML = '';
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
setUpEventListeners() {
|
|
100
|
-
this.selfieInstruction.addEventListener(
|
|
101
|
-
'selfie-capture-instructions.capture',
|
|
102
|
-
async () => {
|
|
103
|
-
await getPermissions(this.selfieCapture, this.getAgentMode()).then(() =>
|
|
104
|
-
this.setActiveScreen(this.selfieCapture),
|
|
105
|
-
);
|
|
106
|
-
smartCameraWeb?.dispatchEvent(
|
|
107
|
-
new CustomEvent('metadata.selfie-capture-start'),
|
|
108
|
-
);
|
|
109
|
-
smartCameraWeb?.dispatchEvent(
|
|
110
|
-
new CustomEvent('metadata.selfie-origin', {
|
|
111
|
-
detail: {
|
|
112
|
-
imageOrigin: {
|
|
113
|
-
environment: 'back_camera',
|
|
114
|
-
user: 'front_camera',
|
|
115
|
-
}[this.getAgentMode()],
|
|
116
|
-
},
|
|
117
|
-
}),
|
|
118
|
-
);
|
|
119
|
-
},
|
|
120
|
-
);
|
|
121
|
-
this.selfieInstruction.addEventListener(
|
|
122
|
-
'selfie-capture-instructions.cancelled',
|
|
123
|
-
() => {
|
|
124
|
-
this.handleBackEvents();
|
|
125
|
-
},
|
|
126
|
-
);
|
|
127
|
-
|
|
128
|
-
this.selfieCapture.addEventListener('selfie-capture.cancelled', () => {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
this.
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
this.
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
get
|
|
200
|
-
return this.hasAttribute('hide-
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
get
|
|
204
|
-
return this.hasAttribute('
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
get
|
|
208
|
-
return this.
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
get
|
|
212
|
-
return this.
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
get
|
|
216
|
-
return this.
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
this.
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
'
|
|
265
|
-
'
|
|
266
|
-
'initial-screen'
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
if (
|
|
284
|
-
'customElements' in window &&
|
|
285
|
-
!customElements.get('selfie-capture-screens')
|
|
286
|
-
) {
|
|
287
|
-
customElements.define('selfie-capture-screens', SelfieCaptureScreens);
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
export default SelfieCaptureScreens;
|
|
1
|
+
import './selfie-capture';
|
|
2
|
+
import './selfie-capture-instructions';
|
|
3
|
+
import './selfie-capture-review';
|
|
4
|
+
import SmartCamera from '../../../domain/camera/src/SmartCamera';
|
|
5
|
+
import styles from '../../../styles/src/styles';
|
|
6
|
+
import packageJson from '../../../../package.json';
|
|
7
|
+
|
|
8
|
+
const COMPONENTS_VERSION = packageJson.version;
|
|
9
|
+
|
|
10
|
+
const smartCameraWeb = document.querySelector('smart-camera-web');
|
|
11
|
+
|
|
12
|
+
async function getPermissions(captureScreen, facingMode = 'user') {
|
|
13
|
+
try {
|
|
14
|
+
const stream = await SmartCamera.getMedia({
|
|
15
|
+
audio: false,
|
|
16
|
+
video: { facingMode },
|
|
17
|
+
});
|
|
18
|
+
const devices = await navigator.mediaDevices.enumerateDevices();
|
|
19
|
+
const videoDevice = devices.find(
|
|
20
|
+
(device) =>
|
|
21
|
+
device.kind === 'videoinput' &&
|
|
22
|
+
stream.getVideoTracks()[0].getSettings().deviceId === device.deviceId,
|
|
23
|
+
);
|
|
24
|
+
smartCameraWeb?.dispatchEvent(
|
|
25
|
+
new CustomEvent('metadata.camera-name', {
|
|
26
|
+
detail: { cameraName: videoDevice?.label },
|
|
27
|
+
}),
|
|
28
|
+
);
|
|
29
|
+
captureScreen.removeAttribute('data-camera-error');
|
|
30
|
+
captureScreen.setAttribute('data-camera-ready', true);
|
|
31
|
+
} catch (error) {
|
|
32
|
+
captureScreen.removeAttribute('data-camera-ready');
|
|
33
|
+
captureScreen.setAttribute(
|
|
34
|
+
'data-camera-error',
|
|
35
|
+
SmartCamera.handleCameraError(error),
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
class SelfieCaptureScreens extends HTMLElement {
|
|
41
|
+
constructor() {
|
|
42
|
+
super();
|
|
43
|
+
this.activeScreen = null;
|
|
44
|
+
smartCameraWeb?.dispatchEvent(new CustomEvent('metadata.initialize'));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
connectedCallback() {
|
|
48
|
+
this.innerHTML = `
|
|
49
|
+
${styles(this.themeColor)}
|
|
50
|
+
<div>
|
|
51
|
+
<selfie-capture-instructions theme-color='${this.themeColor}' ${this.showNavigation} ${this.hideAttribution} ${this.hideBack} hidden></selfie-capture-instructions>
|
|
52
|
+
<selfie-capture theme-color='${this.themeColor}' ${this.showNavigation} ${this.allowAgentMode} ${this.allowAgentModeTests} ${this.hideAttribution} ${this.disableImageTests} hidden></selfie-capture>
|
|
53
|
+
<selfie-capture-review theme-color='${this.themeColor}' ${this.showNavigation} ${this.hideAttribution} hidden></selfie-capture-review>
|
|
54
|
+
</div>
|
|
55
|
+
`;
|
|
56
|
+
|
|
57
|
+
this._data = {
|
|
58
|
+
images: [],
|
|
59
|
+
meta: {
|
|
60
|
+
libraryVersion: COMPONENTS_VERSION,
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
this.selfieInstruction = this.querySelector('selfie-capture-instructions');
|
|
65
|
+
this.selfieCapture = this.querySelector('selfie-capture');
|
|
66
|
+
this.selfieReview = this.querySelector('selfie-capture-review');
|
|
67
|
+
|
|
68
|
+
if (this.hideInstructions && !this.hasAttribute('hidden')) {
|
|
69
|
+
getPermissions(this.selfieCapture, this.getAgentMode());
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// If the initial screen is selfie-capture, we need to get permissions
|
|
73
|
+
if (this.getAttribute('initial-screen') === 'selfie-capture') {
|
|
74
|
+
getPermissions(this.selfieCapture, this.getAgentMode()).then(() =>
|
|
75
|
+
this.setActiveScreen(this.selfieCapture),
|
|
76
|
+
);
|
|
77
|
+
} else if (this.hideInstructions) {
|
|
78
|
+
this.setActiveScreen(this.selfieCapture);
|
|
79
|
+
} else {
|
|
80
|
+
this.setActiveScreen(this.selfieInstruction);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
this.setUpEventListeners();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
getAgentMode() {
|
|
87
|
+
return this.inAgentMode ? 'environment' : 'user';
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
disconnectedCallback() {
|
|
91
|
+
SmartCamera.stopMedia();
|
|
92
|
+
if (this.activeScreen) {
|
|
93
|
+
this.activeScreen.removeAttribute('hidden');
|
|
94
|
+
}
|
|
95
|
+
this.activeScreen = null;
|
|
96
|
+
this.innerHTML = '';
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
setUpEventListeners() {
|
|
100
|
+
this.selfieInstruction.addEventListener(
|
|
101
|
+
'selfie-capture-instructions.capture',
|
|
102
|
+
async () => {
|
|
103
|
+
await getPermissions(this.selfieCapture, this.getAgentMode()).then(() =>
|
|
104
|
+
this.setActiveScreen(this.selfieCapture),
|
|
105
|
+
);
|
|
106
|
+
smartCameraWeb?.dispatchEvent(
|
|
107
|
+
new CustomEvent('metadata.selfie-capture-start'),
|
|
108
|
+
);
|
|
109
|
+
smartCameraWeb?.dispatchEvent(
|
|
110
|
+
new CustomEvent('metadata.selfie-origin', {
|
|
111
|
+
detail: {
|
|
112
|
+
imageOrigin: {
|
|
113
|
+
environment: 'back_camera',
|
|
114
|
+
user: 'front_camera',
|
|
115
|
+
}[this.getAgentMode()],
|
|
116
|
+
},
|
|
117
|
+
}),
|
|
118
|
+
);
|
|
119
|
+
},
|
|
120
|
+
);
|
|
121
|
+
this.selfieInstruction.addEventListener(
|
|
122
|
+
'selfie-capture-instructions.cancelled',
|
|
123
|
+
() => {
|
|
124
|
+
this.handleBackEvents();
|
|
125
|
+
},
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
this.selfieCapture.addEventListener('selfie-capture.cancelled', () => {
|
|
129
|
+
this.selfieCapture.reset();
|
|
130
|
+
SmartCamera.stopMedia();
|
|
131
|
+
if (this.hideInstructions) {
|
|
132
|
+
this.handleBackEvents();
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
this.setActiveScreen(this.selfieInstruction);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
this.selfieCapture.addEventListener('selfie-capture.publish', (event) => {
|
|
140
|
+
smartCameraWeb?.dispatchEvent(
|
|
141
|
+
new CustomEvent('metadata.selfie-capture-end'),
|
|
142
|
+
);
|
|
143
|
+
this.selfieReview.setAttribute('data-image', event.detail.referenceImage);
|
|
144
|
+
this._data.images = event.detail.images;
|
|
145
|
+
SmartCamera.stopMedia();
|
|
146
|
+
this.setActiveScreen(this.selfieReview);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
this.selfieReview.addEventListener(
|
|
150
|
+
'selfie-capture-review.rejected',
|
|
151
|
+
async () => {
|
|
152
|
+
smartCameraWeb?.dispatchEvent(
|
|
153
|
+
new CustomEvent('metadata.selfie-capture-retry'),
|
|
154
|
+
);
|
|
155
|
+
this.selfieReview.removeAttribute('data-image');
|
|
156
|
+
this._data.images = [];
|
|
157
|
+
if (this.hideInstructions) {
|
|
158
|
+
this.setActiveScreen(this.selfieCapture);
|
|
159
|
+
await getPermissions(this.selfieCapture, this.getAgentMode());
|
|
160
|
+
} else {
|
|
161
|
+
this.setActiveScreen(this.selfieInstruction);
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
this.selfieReview.addEventListener(
|
|
167
|
+
'selfie-capture-review.accepted',
|
|
168
|
+
async () => {
|
|
169
|
+
this._publishSelectedImages();
|
|
170
|
+
},
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
[this.selfieInstruction, this.selfieCapture, this.selfieReview].forEach(
|
|
174
|
+
(screen) => {
|
|
175
|
+
screen.addEventListener(
|
|
176
|
+
`${screen.nodeName.toLowerCase()}.close`,
|
|
177
|
+
() => {
|
|
178
|
+
this.handleCloseEvent();
|
|
179
|
+
},
|
|
180
|
+
);
|
|
181
|
+
},
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
_publishSelectedImages() {
|
|
186
|
+
this.dispatchEvent(
|
|
187
|
+
new CustomEvent('selfie-capture-screens.publish', { detail: this._data }),
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
get hideInstructions() {
|
|
192
|
+
return this.hasAttribute('hide-instructions');
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
get hideAttribution() {
|
|
196
|
+
return this.hasAttribute('hide-attribution') ? 'hide-attribution' : '';
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
get hideBackOfId() {
|
|
200
|
+
return this.hasAttribute('hide-back-of-id');
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
get showNavigation() {
|
|
204
|
+
return this.hasAttribute('show-navigation') ? 'show-navigation' : '';
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
get inAgentMode() {
|
|
208
|
+
return this.getAttribute('allow-agent-mode') === 'true';
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
get allowAgentMode() {
|
|
212
|
+
return this.inAgentMode ? "allow-agent-mode='true'" : '';
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
get allowAgentModeTests() {
|
|
216
|
+
return this.hasAttribute('show-agent-mode-for-tests')
|
|
217
|
+
? 'show-agent-mode-for-tests'
|
|
218
|
+
: '';
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
get hideBack() {
|
|
222
|
+
return this.hasAttribute('hide-back-to-host') ||
|
|
223
|
+
this.hasAttribute('hide-back')
|
|
224
|
+
? 'hide-back'
|
|
225
|
+
: '';
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
get disableImageTests() {
|
|
229
|
+
return this.hasAttribute('disable-image-tests')
|
|
230
|
+
? 'disable-image-tests'
|
|
231
|
+
: '';
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
get themeColor() {
|
|
235
|
+
return this.getAttribute('theme-color') || '#001096';
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
setActiveScreen(screen) {
|
|
239
|
+
this.activeScreen?.setAttribute('hidden', '');
|
|
240
|
+
screen.removeAttribute('hidden');
|
|
241
|
+
this.activeScreen = screen;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
handleBackEvents() {
|
|
245
|
+
this.dispatchEvent(new CustomEvent('selfie-capture-screens.cancelled'));
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
handleCloseEvent() {
|
|
249
|
+
this.dispatchEvent(new CustomEvent('selfie-capture-screens.close'));
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
static get observedAttributes() {
|
|
253
|
+
return [
|
|
254
|
+
'title',
|
|
255
|
+
'hidden',
|
|
256
|
+
'show-navigation',
|
|
257
|
+
'hide-back-to-host',
|
|
258
|
+
'initial-screen',
|
|
259
|
+
];
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
attributeChangedCallback(name) {
|
|
263
|
+
switch (name) {
|
|
264
|
+
case 'title':
|
|
265
|
+
case 'hidden':
|
|
266
|
+
case 'initial-screen':
|
|
267
|
+
this.connectedCallback();
|
|
268
|
+
break;
|
|
269
|
+
default:
|
|
270
|
+
break;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
if (
|
|
276
|
+
'customElements' in window &&
|
|
277
|
+
!customElements.get('selfie-capture-screens')
|
|
278
|
+
) {
|
|
279
|
+
customElements.define('selfie-capture-screens', SelfieCaptureScreens);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
export default SelfieCaptureScreens;
|