@smileid/web-components 1.0.0-beta → 1.4.2

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 (44) hide show
  1. package/README.md +15 -0
  2. package/components/README.md +1 -1
  3. package/components/camera-permission/CameraPermission.js +6 -2
  4. package/components/camera-permission/CameraPermission.stories.js +10 -4
  5. package/components/document/src/DocumentCaptureScreens.js +41 -11
  6. package/components/document/src/DocumentCaptureScreens.stories.js +16 -12
  7. package/components/document/src/README.md +11 -8
  8. package/components/document/src/document-capture/DocumentCapture.js +299 -231
  9. package/components/document/src/document-capture/DocumentCapture.stories.js +9 -2
  10. package/components/document/src/document-capture/README.md +5 -4
  11. package/components/document/src/document-capture-instructions/DocumentCaptureInstructions.js +33 -33
  12. package/components/document/src/document-capture-instructions/DocumentCaptureInstructions.stories.js +8 -1
  13. package/components/document/src/document-capture-review/DocumentCaptureReview.js +15 -31
  14. package/components/document/src/document-capture-review/DocumentCaptureReview.stories.js +12 -2
  15. package/components/document/src/document-capture-review/README.md +3 -3
  16. package/components/end-user-consent/src/EndUserConsent.js +14 -31
  17. package/components/end-user-consent/src/EndUserConsent.stories.js +8 -2
  18. package/components/navigation/src/Navigation.js +10 -2
  19. package/components/selfie/README.md +28 -4
  20. package/components/selfie/src/SelfieCaptureScreens.js +36 -10
  21. package/components/selfie/src/SelfieCaptureScreens.stories.js +13 -4
  22. package/components/selfie/src/selfie-capture/SelfieCapture.js +95 -23
  23. package/components/selfie/src/selfie-capture/SelfieCapture.stories.js +14 -1
  24. package/components/selfie/src/selfie-capture-instructions/SelfieCaptureInstructions.js +50 -44
  25. package/components/selfie/src/selfie-capture-instructions/SelfieCaptureInstructions.stories.js +8 -2
  26. package/components/selfie/src/selfie-capture-review/SelfieCaptureReview.js +3 -4
  27. package/components/selfie/src/selfie-capture-review/SelfieCaptureReview.stories.js +8 -1
  28. package/components/signature-pad/package-lock.json +3009 -0
  29. package/components/signature-pad/package.json +6 -6
  30. package/components/signature-pad/src/SignaturePad.js +5 -1
  31. package/components/signature-pad/src/SignaturePad.stories.js +10 -2
  32. package/components/smart-camera-web/src/README.md +207 -0
  33. package/components/smart-camera-web/src/SmartCameraWeb.js +56 -7
  34. package/components/smart-camera-web/src/SmartCameraWeb.stories.js +27 -7
  35. package/components/totp-consent/src/TotpConsent.js +15 -3
  36. package/cypress/e2e/smart-camera-web-agent-mode.cy.js +144 -0
  37. package/cypress/e2e/smart-camera-web-complete-flow.cy.js +221 -0
  38. package/cypress/e2e/smart-camera-web.cy.js +1 -1
  39. package/cypress/pages/smart-camera-web-agent-mode.html +36 -0
  40. package/cypress/pages/smart-camera-web-complete-flow.html +42 -0
  41. package/cypress/pages/smart-camera-web.html +1 -1
  42. package/domain/camera/src/SmartCamera.js +28 -0
  43. package/package.json +8 -8
  44. package/styles/src/styles.js +14 -3
package/README.md ADDED
@@ -0,0 +1,15 @@
1
+ # Instructions
2
+
3
+ These components can be used to capture id document or liveness images
4
+
5
+ 1. [`smart-camera-web`](./components/smart-camera-web/src/)
6
+ 2. [`document-capture-screens`](./components/document/src/README.md)
7
+ 3. [`selfie-capture-screens`](./components/selfie/README.md)
8
+
9
+ ## Orchestration
10
+
11
+ To build your own flow, we have several components that can be used together
12
+
13
+ ### document-capture-instructions
14
+
15
+ This is the screen used to instruct the user how to capture document using both the camera and/or upload.
@@ -2,7 +2,7 @@
2
2
 
3
3
  These components can be used to capture id document or liveness images
4
4
 
5
- 1. [`document-capture-screens`](./document/README.md)
5
+ 1. [`document-capture-screens`](./document/src/README.md)
6
6
  2. [`selfie-capture-screens`](./selfie/README.md)
7
7
 
8
8
  ## Orchestration
@@ -5,7 +5,7 @@ import '../navigation/src';
5
5
 
6
6
  function templateString() {
7
7
  return `
8
- ${styles}
8
+ ${styles(this.themeColor)}
9
9
  <style>
10
10
  .camera-permission-screen {
11
11
  padding-block: 2rem;
@@ -32,7 +32,7 @@ function templateString() {
32
32
  }
33
33
  </style>
34
34
  <div class='camera-permission-screen flow center'>
35
- <smileid-navigation ${this.showNavigation ? 'show-navigation' : ''} ${this.hideBack ? 'hide-back' : ''}></smileid-navigation>
35
+ <smileid-navigation theme-color='${this.themeColor}' ${this.showNavigation ? 'show-navigation' : ''} ${this.hideBack ? 'hide-back' : ''}></smileid-navigation>
36
36
  <div class='flow center'>
37
37
  <p class='color-red | center' id='error'>
38
38
  </p>
@@ -127,6 +127,10 @@ class CameraPermission extends HTMLElement {
127
127
  get hideBack() {
128
128
  return this.hasAttribute('hide-back');
129
129
  }
130
+
131
+ get themeColor() {
132
+ return this.getAttribute('theme-color') || '#001096';
133
+ }
130
134
  }
131
135
 
132
136
  if (window.customElements && !window.customElements.get('camera-permission')) {
@@ -1,21 +1,27 @@
1
1
  import './CameraPermission';
2
2
 
3
3
  const meta = {
4
+ args: {
5
+ 'theme-color': '#001096',
6
+ },
7
+ argTypes: {
8
+ 'theme-color': { control: 'color' },
9
+ },
4
10
  component: 'camera-permission',
5
11
  };
6
12
 
7
13
  export default meta;
8
14
 
9
15
  export const CameraPermission = {
10
- render: () => `
11
- <camera-permission>
16
+ render: (args) => `
17
+ <camera-permission theme-color='${args['theme-color']}'>
12
18
  </camera-permission>
13
19
  `,
14
20
  };
15
21
 
16
22
  export const CameraPermissionAtributes = {
17
- render: () => `
18
- <camera-permission show-navigation>
23
+ render: (args) => `
24
+ <camera-permission theme-color='${args['theme-color']}' show-navigation>
19
25
  </camera-permission>
20
26
  `,
21
27
  };
@@ -32,20 +32,22 @@ class DocumentCaptureScreens extends HTMLElement {
32
32
 
33
33
  connectedCallback() {
34
34
  this.innerHTML = `
35
- ${styles}
35
+ ${styles(this.themeColor)}
36
36
  <div>
37
- <document-capture-instructions id='document-capture-instructions-front' ${this.title} ${this.documentCaptureModes} ${this.showNavigation} ${this.hideInstructions ? 'hidden' : ''}></document-capture-instructions>
37
+ <document-capture-instructions theme-color='${this.themeColor}' id='document-capture-instructions-front' ${this.title} ${this.documentCaptureModes} ${this.showNavigation} ${this.hideInstructions ? 'hidden' : ''}></document-capture-instructions>
38
38
  <document-capture id='document-capture-front' side-of-id='Front'
39
39
  ${this.title} ${this.showNavigation} ${this.hideInstructions ? '' : 'hidden'}
40
- ${this.documentCaptureModes} ${this.documentType}
40
+ ${this.documentCaptureModes} ${this.documentType} theme-color='${this.themeColor}'
41
41
  ></document-capture>
42
- <document-capture-instructions id='document-capture-instructions-back' side-of-id='Back' title='Submit Back of ID' ${this.documentCaptureModes} ${this.showNavigation} hidden></document-capture-instructions>
42
+ <document-capture-instructions id='document-capture-instructions-back' side-of-id='Back' title='Submit Back of ID'
43
+ ${this.documentCaptureModes} ${this.showNavigation} theme-color='${this.themeColor}' hidden
44
+ ></document-capture-instructions>
43
45
  <document-capture id='document-capture-back' side-of-id='Back' ${this.title} ${this.showNavigation}
44
- ${this.documentCaptureModes}
46
+ ${this.documentCaptureModes} theme-color='${this.themeColor}'
45
47
  hidden
46
48
  ></document-capture>
47
- <document-capture-review id='front-of-document-capture-review' hidden></document-capture-review>
48
- <document-capture-review id='back-of-document-capture-review' hidden></document-capture-review>
49
+ <document-capture-review id='front-of-document-capture-review' theme-color='${this.themeColor}' hidden></document-capture-review>
50
+ <document-capture-review id='back-of-document-capture-review' theme-color='${this.themeColor}' hidden></document-capture-review>
49
51
  </div>
50
52
  `;
51
53
 
@@ -107,7 +109,7 @@ class DocumentCaptureScreens extends HTMLElement {
107
109
  this.documentInstruction.addEventListener(
108
110
  'document-capture-instructions.upload',
109
111
  async (event) => {
110
- this.idReview.setAttribute('data-image', event.detail.image);
112
+ this.idReview.setAttribute('data-image', event.detail.previewImage);
111
113
  this._data.images.push({
112
114
  image: event.detail.image.split(',')[1],
113
115
  image_type_id: IMAGE_TYPE.ID_CARD_IMAGE_BASE64,
@@ -117,7 +119,7 @@ class DocumentCaptureScreens extends HTMLElement {
117
119
  );
118
120
 
119
121
  this.idCapture.addEventListener('document-capture.publish', (event) => {
120
- this.idReview.setAttribute('data-image', event.detail.image);
122
+ this.idReview.setAttribute('data-image', event.detail.previewImage);
121
123
  this._data.images.push({
122
124
  image: event.detail.image.split(',')[1],
123
125
  image_type_id: IMAGE_TYPE.ID_CARD_IMAGE_BASE64,
@@ -187,7 +189,7 @@ class DocumentCaptureScreens extends HTMLElement {
187
189
  this.documentInstructionBack.addEventListener(
188
190
  'document-capture-instructions.upload',
189
191
  async (event) => {
190
- this.idReview.setAttribute('data-image', event.detail.image);
192
+ this.backOfIdReview.setAttribute('data-image', event.detail.image);
191
193
  this._data.images.push({
192
194
  image: event.detail.image.split(',')[1],
193
195
  image_type_id: IMAGE_TYPE.ID_CARD_BACK_IMAGE_BASE64,
@@ -196,7 +198,7 @@ class DocumentCaptureScreens extends HTMLElement {
196
198
  },
197
199
  );
198
200
  this.idCaptureBack.addEventListener('document-capture.publish', (event) => {
199
- this.backOfIdReview.setAttribute('data-image', event.detail.image);
201
+ this.backOfIdReview.setAttribute('data-image', event.detail.previewImage);
200
202
  this._data.images.push({
201
203
  image: event.detail.image.split(',')[1],
202
204
  image_type_id: IMAGE_TYPE.ID_CARD_BACK_IMAGE_BASE64,
@@ -292,6 +294,10 @@ class DocumentCaptureScreens extends HTMLElement {
292
294
  : '';
293
295
  }
294
296
 
297
+ get themeColor() {
298
+ return this.getAttribute('theme-color') || '#001096';
299
+ }
300
+
295
301
  handleBackEvents() {
296
302
  this.dispatchEvent(new CustomEvent('document-capture-screens.cancelled'));
297
303
  }
@@ -305,6 +311,30 @@ class DocumentCaptureScreens extends HTMLElement {
305
311
  screen.removeAttribute('hidden');
306
312
  this.activeScreen = screen;
307
313
  }
314
+
315
+ static get observedAttributes() {
316
+ return [
317
+ 'document-capture-modes',
318
+ 'document-type',
319
+ 'hide-back-to-host',
320
+ 'show-navigation',
321
+ 'hide-back-of-id',
322
+ ];
323
+ }
324
+
325
+ attributeChangedCallback(name) {
326
+ switch (name) {
327
+ case 'document-capture-modes':
328
+ case 'document-type':
329
+ case 'hide-back-of-id':
330
+ case 'hide-back-to-host':
331
+ case 'show-navigation':
332
+ this.connectedCallback();
333
+ break;
334
+ default:
335
+ break;
336
+ }
337
+ }
308
338
  }
309
339
 
310
340
  if (
@@ -1,44 +1,48 @@
1
1
  import './index';
2
2
 
3
3
  const meta = {
4
+ args: {
5
+ 'theme-color': '#001096',
6
+ },
7
+ argTypes: {
8
+ 'theme-color': { control: 'color' },
9
+ },
4
10
  component: 'document-capture-screens',
5
11
  };
6
12
 
7
13
  export default meta;
8
14
 
9
15
  export const DocumentCapture = {
10
- render: () => `
11
- <document-capture-screens>
16
+ render: (args) => `
17
+ <document-capture-screens theme-color='${args['theme-color']}'>
12
18
  </document-capture-screens>
13
19
  `,
14
20
  };
15
21
 
16
22
  export const DocumentCaptureHiddenInstructions = {
17
- render: () => `
18
- <document-capture-screens hide-instructions>
23
+ render: (args) => `
24
+ <document-capture-screens hide-instructions theme-color='${args['theme-color']}'>
19
25
  </document-capture-screens>
20
26
  `,
21
27
  };
22
28
 
23
29
  export const DocumentCaptureHideBackOfId = {
24
- render: () => `
25
- <document-capture-screens
26
- hide-back-of-id
27
- >
30
+ render: (args) => `
31
+ <document-capture-screens hide-back-of-id theme-color='${args['theme-color']}'>
28
32
  </document-capture-screens>
29
33
  `,
30
34
  };
31
35
 
32
36
  export const DocumentCaptureAllowAttributes = {
33
- render: () => `
34
- <document-capture-screens document-capture-screens-modes='camera,upload'>
37
+ render: (args) => `
38
+ <document-capture-screens document-capture-screens-modes='camera,upload' theme-color='${args['theme-color']}'>
35
39
  </document-capture-screens>
36
40
  `,
37
41
  };
38
42
 
39
43
  export const DocumentCaptureHideInstructionNBackOfId = {
40
- render: () => `
41
- <document-capture-screens hide-back-of-id hide-instructions>
44
+ render: (args) => `
45
+ <document-capture-screens hide-back-of-id hide-instructions theme-color='${args['theme-color']}'>
42
46
  </document-capture-screens>
43
47
  `,
44
48
  };
@@ -2,11 +2,12 @@
2
2
 
3
3
  ## Overview
4
4
 
5
- The `DocumentCapture` is a bespoke web component designed for capturing document images using a camera. It leverages the `SmartCamera` module for camera interaction and permission management.
5
+ The `DocumentCaptureScreens` is a bespoke web component designed for capturing document images using a camera. It leverages the `SmartCamera` module for camera interaction and permission management.
6
+ This component contains the flow for capturing both front and the back of id documents.
6
7
 
7
8
  ### Importing the Component
8
9
 
9
- To utilize the DocumentCapture component within your project, import it into your JavaScript file as follows:
10
+ To utilize the `DocumentCaptureScreens` component within your project, import it into your JavaScript file as follows:
10
11
 
11
12
  ```js
12
13
  import '@smileid/components/document-capture';
@@ -17,7 +18,7 @@ import '@smileid/components/document-capture';
17
18
  The DocumentCapture component can be embedded in your HTML similarly to any standard HTML element:
18
19
 
19
20
  ```html
20
- <document-capture></document-capture>
21
+ <document-capture-screens></document-capture-screens>
21
22
  ```
22
23
 
23
24
  ### Attributes
@@ -29,7 +30,7 @@ Customize the component's behavior with the following attributes:
29
30
  Omits the capture instructions. This attribute is boolean and does not require a value.
30
31
 
31
32
  ```html
32
- <document-capture hide-instructions></document-capture>
33
+ <document-capture-screens hide-instructions></document-capture-screens>
33
34
  ```
34
35
 
35
36
  #### `hide-back-of-id`
@@ -37,7 +38,7 @@ Omits the capture instructions. This attribute is boolean and does not require a
37
38
  Excludes the option to capture the ID's back side. This attribute is boolean.
38
39
 
39
40
  ```html
40
- <document-capture hide-back-of-id></document-capture>
41
+ <document-capture-screens hide-back-of-id></document-capture-screens>
41
42
  ```
42
43
 
43
44
  #### `show-navigation`
@@ -45,7 +46,7 @@ Excludes the option to capture the ID's back side. This attribute is boolean.
45
46
  Displays navigation controls for the capture process. This attribute is boolean.
46
47
 
47
48
  ```html
48
- <document-capture show-navigation></document-capture>
49
+ <document-capture-screens show-navigation></document-capture-screens>
49
50
  ```
50
51
 
51
52
  #### `document-capture-modes`
@@ -53,7 +54,9 @@ Displays navigation controls for the capture process. This attribute is boolean.
53
54
  Specifies the capture modes, accepting `camera`, `upload`, or both. Value required.
54
55
 
55
56
  ```html
56
- <document-capture document-capture-modes="camera,upload"></document-capture>
57
+ <document-capture-screens
58
+ document-capture-modes="camera,upload"
59
+ ></document-capture-screens>
57
60
  ```
58
61
 
59
62
  ### Permissions
@@ -85,7 +88,7 @@ To handle this event:
85
88
 
86
89
  ```js
87
90
  document
88
- .querySelector('document-capture')
91
+ .querySelector('document-capture-screens')
89
92
  .addEventListener('document-capture-screens.publish', function (event) {
90
93
  console.log(event.detail);
91
94
  });