@smileid/web-components 1.5.0 → 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.
Files changed (81) hide show
  1. package/package.json +21 -11
  2. package/{components → src/components}/combobox/src/Combobox.js +4 -1
  3. package/{components → src/components}/document/src/DocumentCaptureScreens.js +1 -1
  4. package/{components → src/components}/end-user-consent/src/EndUserConsent.js +4 -1
  5. package/{components → src/components}/navigation/src/Navigation.js +4 -1
  6. package/{components → src/components}/selfie/src/SelfieCaptureScreens.js +7 -15
  7. package/{components → src/components}/selfie/src/selfie-capture/SelfieCapture.js +39 -8
  8. package/{components → src/components}/signature-pad/package.json +1 -1
  9. package/{components → src/components}/signature-pad/src/SignaturePad.js +4 -1
  10. package/{components → src/components}/smart-camera-web/src/SmartCameraWeb.js +1 -1
  11. package/{components → src/components}/totp-consent/src/TotpConsent.js +1 -1
  12. package/.eslintrc.cjs +0 -72
  13. package/cypress/e2e/smart-camera-web-agent-mode.cy.js +0 -144
  14. package/cypress/e2e/smart-camera-web-attribution.cy.js +0 -249
  15. package/cypress/e2e/smart-camera-web-back-press.cy.js +0 -481
  16. package/cypress/e2e/smart-camera-web-complete-flow.cy.js +0 -221
  17. package/cypress/e2e/smart-camera-web-hide-back-to-host.cy.js +0 -61
  18. package/cypress/e2e/smart-camera-web-hide-instructions.cy.js +0 -334
  19. package/cypress/e2e/smart-camera-web.cy.js +0 -309
  20. package/cypress/fixtures/example.json +0 -5
  21. package/cypress/pages/capture-back-of-id-hide-attribution.html +0 -44
  22. package/cypress/pages/capture-back-of-id-navigation.html +0 -72
  23. package/cypress/pages/smart-camera-web-agent-mode.html +0 -36
  24. package/cypress/pages/smart-camera-web-complete-flow.html +0 -42
  25. package/cypress/pages/smart-camera-web-hide-instructions.html +0 -38
  26. package/cypress/pages/smart-camera-web.html +0 -38
  27. package/cypress/support/commands.js +0 -144
  28. package/cypress/support/e2e.js +0 -20
  29. package/cypress.config.js +0 -11
  30. package/esbuild.js +0 -119
  31. package/generate-exports.js +0 -34
  32. /package/{components → src/components}/README.md +0 -0
  33. /package/{components → src/components}/attribution/PoweredBySmileId.js +0 -0
  34. /package/{components → src/components}/camera-permission/CameraPermission.js +0 -0
  35. /package/{components → src/components}/camera-permission/CameraPermission.stories.js +0 -0
  36. /package/{components → src/components}/combobox/src/index.js +0 -0
  37. /package/{components → src/components}/document/src/DocumentCaptureScreens.stories.js +0 -0
  38. /package/{components → src/components}/document/src/README.md +0 -0
  39. /package/{components → src/components}/document/src/document-capture/DocumentCapture.js +0 -0
  40. /package/{components → src/components}/document/src/document-capture/DocumentCapture.stories.js +0 -0
  41. /package/{components → src/components}/document/src/document-capture/README.md +0 -0
  42. /package/{components → src/components}/document/src/document-capture/index.js +0 -0
  43. /package/{components → src/components}/document/src/document-capture-instructions/DocumentCaptureInstructions.js +0 -0
  44. /package/{components → src/components}/document/src/document-capture-instructions/DocumentCaptureInstructions.stories.js +0 -0
  45. /package/{components → src/components}/document/src/document-capture-instructions/README.md +0 -0
  46. /package/{components → src/components}/document/src/document-capture-instructions/index.js +0 -0
  47. /package/{components → src/components}/document/src/document-capture-review/DocumentCaptureReview.js +0 -0
  48. /package/{components → src/components}/document/src/document-capture-review/DocumentCaptureReview.stories.js +0 -0
  49. /package/{components → src/components}/document/src/document-capture-review/README.md +0 -0
  50. /package/{components → src/components}/document/src/document-capture-review/index.js +0 -0
  51. /package/{components → src/components}/document/src/index.js +0 -0
  52. /package/{components → src/components}/end-user-consent/src/EndUserConsent.stories.js +0 -0
  53. /package/{components → src/components}/end-user-consent/src/index.js +0 -0
  54. /package/{components → src/components}/navigation/src/Navigation.stories.js +0 -0
  55. /package/{components → src/components}/navigation/src/index.js +0 -0
  56. /package/{components → src/components}/selfie/README.md +0 -0
  57. /package/{components → src/components}/selfie/src/SelfieCaptureScreens.stories.js +0 -0
  58. /package/{components → src/components}/selfie/src/index.js +0 -0
  59. /package/{components → src/components}/selfie/src/selfie-capture/SelfieCapture.stories.js +0 -0
  60. /package/{components → src/components}/selfie/src/selfie-capture/index.js +0 -0
  61. /package/{components → src/components}/selfie/src/selfie-capture-instructions/SelfieCaptureInstructions.js +0 -0
  62. /package/{components → src/components}/selfie/src/selfie-capture-instructions/SelfieCaptureInstructions.stories.js +0 -0
  63. /package/{components → src/components}/selfie/src/selfie-capture-instructions/index.js +0 -0
  64. /package/{components → src/components}/selfie/src/selfie-capture-review/SelfieCaptureReview.js +0 -0
  65. /package/{components → src/components}/selfie/src/selfie-capture-review/SelfieCaptureReview.stories.js +0 -0
  66. /package/{components → src/components}/selfie/src/selfie-capture-review/index.js +0 -0
  67. /package/{components → src/components}/signature-pad/package-lock.json +0 -0
  68. /package/{components → src/components}/signature-pad/src/SignaturePad.stories.js +0 -0
  69. /package/{components → src/components}/signature-pad/src/index.js +0 -0
  70. /package/{components → src/components}/smart-camera-web/src/README.md +0 -0
  71. /package/{components → src/components}/smart-camera-web/src/SmartCameraWeb.stories.js +0 -0
  72. /package/{components → src/components}/totp-consent/src/index.js +0 -0
  73. /package/{domain → src/domain}/camera/src/README.md +0 -0
  74. /package/{domain → src/domain}/camera/src/SmartCamera.js +0 -0
  75. /package/{domain → src/domain}/constants/src/Constants.js +0 -0
  76. /package/{domain → src/domain}/file-upload/README.md +0 -0
  77. /package/{domain → src/domain}/file-upload/src/SmartFileUpload.js +0 -0
  78. /package/{index.js → src/index.js} +0 -0
  79. /package/{styles → src/styles}/README.md +0 -0
  80. /package/{styles → src/styles}/src/styles.js +0 -0
  81. /package/{styles → src/styles}/src/typography.js +0 -0
package/package.json CHANGED
@@ -1,25 +1,35 @@
1
1
  {
2
2
  "name": "@smileid/web-components",
3
- "version": "1.5.0",
3
+ "version": "2.0.0",
4
4
  "main": "index.js",
5
5
  "exports": {
6
6
  ".": "./index.js",
7
- "./combobox": "./components/combobox/src/index.js",
8
- "./document-capture": "./components/document/src/index.js",
9
- "./end-user-consent": "./components/end-user-consent/src/index.js",
10
- "./navigation": "./components/navigation/src/index.js",
11
- "./selfie-capture": "./components/selfie/src/index.js",
12
- "./signature-pad": "./components/signature-pad/src/index.js",
13
- "./totp-consent": "./components/totp-consent/src/index.js",
14
- "./smart-camera-web": "./components/smart-camera-web/src/SmartCameraWeb.js"
7
+ "./combobox": "./src/components/combobox/src/index.js",
8
+ "./document-capture": "./src/components/document/src/index.js",
9
+ "./end-user-consent": "./src/components/end-user-consent/src/index.js",
10
+ "./navigation": "./src/components/navigation/src/index.js",
11
+ "./selfie-capture": "./src/components/selfie/src/index.js",
12
+ "./signature-pad": "./src/components/signature-pad/src/index.js",
13
+ "./totp-consent": "./src/components/totp-consent/src/index.js",
14
+ "./smart-camera-web": "./src/components/smart-camera-web/src/SmartCameraWeb.js"
15
15
  },
16
+ "files": [
17
+ "./src/components/",
18
+ "./src/domain/",
19
+ "./src/styles/",
20
+ "./README.md",
21
+ "index.js",
22
+ "package.json"
23
+ ],
16
24
  "scripts": {
17
- "build": "cross-env NODE_ENV=development node esbuild.js",
25
+ "build": "cross-env NODE_ENV=production node esbuild.js",
26
+ "build:dev": "cross-env NODE_ENV=development node esbuild.js",
18
27
  "clean": "rm -rf build dist",
28
+ "prepublishOnly": "npm run build",
19
29
  "lint:fix": "eslint . --ext .js --fix",
20
30
  "lint:html": "npx prettier --write $(git ls-files '*.html')",
21
31
  "lint": "eslint . --ext .js",
22
- "start": "npm run build && npx serve -p 8000 build",
32
+ "start": "npm run build:dev && npx serve -p 8000 dist",
23
33
  "test": "npx cypress run"
24
34
  },
25
35
  "description": "A collection of Web Components used by SmileID",
@@ -576,7 +576,10 @@ const Trigger = ComboboxTrigger;
576
576
  const List = ComboboxListbox;
577
577
  const Option = ComboboxOption;
578
578
 
579
- if ('customElements' in window) {
579
+ if (
580
+ 'customElements' in window &&
581
+ !window.customElements.get('smileid-combobox')
582
+ ) {
580
583
  window.customElements.define('smileid-combobox', Root);
581
584
  window.customElements.define('smileid-combobox-trigger', Trigger);
582
585
  window.customElements.define('smileid-combobox-listbox', List);
@@ -5,7 +5,7 @@ import SmartCamera from '../../../domain/camera/src/SmartCamera';
5
5
  import './document-capture';
6
6
  import './document-capture-review';
7
7
  import './document-capture-instructions';
8
- import packageJson from '../../../package.json';
8
+ import packageJson from '../../../../package.json';
9
9
 
10
10
  const COMPONENTS_VERSION = packageJson.version;
11
11
 
@@ -782,7 +782,10 @@ class EndUserConsent extends HTMLElement {
782
782
  }
783
783
  }
784
784
 
785
- if ('customElements' in window) {
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 ('customElements' in window) {
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
 
@@ -3,7 +3,7 @@ import './selfie-capture-instructions';
3
3
  import './selfie-capture-review';
4
4
  import SmartCamera from '../../../domain/camera/src/SmartCamera';
5
5
  import styles from '../../../styles/src/styles';
6
- import packageJson from '../../../package.json';
6
+ import packageJson from '../../../../package.json';
7
7
 
8
8
  const COMPONENTS_VERSION = packageJson.version;
9
9
 
@@ -126,11 +126,14 @@ class SelfieCaptureScreens extends HTMLElement {
126
126
  );
127
127
 
128
128
  this.selfieCapture.addEventListener('selfie-capture.cancelled', () => {
129
+ this.selfieCapture.reset();
130
+ SmartCamera.stopMedia();
129
131
  if (this.hideInstructions) {
130
- this.dispatchEvent(new CustomEvent('selfie-capture-screens.cancelled'));
131
- } else {
132
- this.setActiveScreen(this.selfieInstruction);
132
+ this.handleBackEvents();
133
+ return;
133
134
  }
135
+
136
+ this.setActiveScreen(this.selfieInstruction);
134
137
  });
135
138
 
136
139
  this.selfieCapture.addEventListener('selfie-capture.publish', (event) => {
@@ -143,17 +146,6 @@ class SelfieCaptureScreens extends HTMLElement {
143
146
  this.setActiveScreen(this.selfieReview);
144
147
  });
145
148
 
146
- this.selfieCapture.addEventListener('selfie-capture.cancelled', () => {
147
- this.selfieCapture.reset();
148
- SmartCamera.stopMedia();
149
- if (this.hideInstructions) {
150
- this.handleBackEvents();
151
- return;
152
- }
153
-
154
- this.setActiveScreen(this.selfieInstruction);
155
- });
156
-
157
149
  this.selfieReview.addEventListener(
158
150
  'selfie-capture-review.rejected',
159
151
  async () => {
@@ -1,7 +1,7 @@
1
1
  import { IMAGE_TYPE } from '../../../../domain/constants/src/Constants';
2
2
  import SmartCamera from '../../../../domain/camera/src/SmartCamera';
3
3
  import styles from '../../../../styles/src/styles';
4
- import packageJson from '../../../../package.json';
4
+ import packageJson from '../../../../../package.json';
5
5
  import '../../../navigation/src';
6
6
 
7
7
  const COMPONENTS_VERSION = packageJson.version;
@@ -518,7 +518,6 @@ function templateString() {
518
518
 
519
519
  <div className="error">
520
520
  ${this.cameraError ? `<p class="color-red">${this.cameraError}</p>` : ''}
521
- ${this.hideAttribution ? '' : '<powered-by-smile-id></powered-by-smile-id>'}
522
521
  </div>
523
522
  <div class='section | flow' ${this.cameraError ? 'hidden' : ''}>
524
523
  <div class='video-container'>
@@ -706,9 +705,25 @@ class SelfieCaptureScreen extends HTMLElement {
706
705
 
707
706
  _capturePOLPhoto() {
708
707
  const canvas = document.createElement('canvas');
709
- canvas.width = 240;
710
- canvas.height =
711
- (canvas.width * this._video.videoHeight) / this._video.videoWidth;
708
+ // Determine orientation of the video
709
+ const isPortrait = this._video.videoHeight > this._video.videoWidth;
710
+
711
+ // Set dimensions based on orientation, ensuring minimums
712
+ if (isPortrait) {
713
+ // Portrait orientation (taller than wide)
714
+ canvas.width = 240;
715
+ canvas.height = Math.max(
716
+ 320,
717
+ (canvas.width * this._video.videoHeight) / this._video.videoWidth,
718
+ );
719
+ } else {
720
+ // Landscape orientation (wider than tall)
721
+ canvas.height = 240;
722
+ canvas.width = Math.max(
723
+ 320,
724
+ (canvas.height * this._video.videoWidth) / this._video.videoHeight,
725
+ );
726
+ }
712
727
 
713
728
  // NOTE: we do not want to test POL images
714
729
  this._drawImage(canvas, false);
@@ -718,9 +733,25 @@ class SelfieCaptureScreen extends HTMLElement {
718
733
 
719
734
  _captureReferencePhoto() {
720
735
  const canvas = document.createElement('canvas');
721
- canvas.width = 480;
722
- canvas.height =
723
- (canvas.width * this._video.videoHeight) / this._video.videoWidth;
736
+ // Determine orientation of the video
737
+ const isPortrait = this._video.videoHeight > this._video.videoWidth;
738
+
739
+ // Set dimensions based on orientation, ensuring minimums
740
+ if (isPortrait) {
741
+ // Portrait orientation (taller than wide)
742
+ canvas.width = 480;
743
+ canvas.height = Math.max(
744
+ 640,
745
+ (canvas.width * this._video.videoHeight) / this._video.videoWidth,
746
+ );
747
+ } else {
748
+ // Landscape orientation (wider than tall)
749
+ canvas.height = 480;
750
+ canvas.width = Math.max(
751
+ 640,
752
+ (canvas.height * this._video.videoWidth) / this._video.videoHeight,
753
+ );
754
+ }
724
755
 
725
756
  // NOTE: we want to test the image quality of the reference photo
726
757
  this._drawImage(canvas, !this.disableImageTests);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smileid/signature-pad",
3
- "version": "1.5.0",
3
+ "version": "2.0.0",
4
4
  "private": "true",
5
5
  "exports": {
6
6
  ".": "./index.js"
@@ -474,7 +474,10 @@ button:disabled {
474
474
  }
475
475
  }
476
476
 
477
- if ('customElements' in window) {
477
+ if (
478
+ 'customElements' in window &&
479
+ !window.customElements.get('smileid-signature-pad')
480
+ ) {
478
481
  window.customElements.define('smileid-signature-pad', SignaturePad);
479
482
  }
480
483
 
@@ -4,7 +4,7 @@ import SmartCamera from '../../../domain/camera/src/SmartCamera';
4
4
  import '../../document/src';
5
5
  import '../../selfie/src';
6
6
  import '../../camera-permission/CameraPermission';
7
- import packageJson from '../../../package.json';
7
+ import packageJson from '../../../../package.json';
8
8
 
9
9
  const COMPONENTS_VERSION = packageJson.version;
10
10
 
@@ -939,7 +939,7 @@ class TotpConsent extends HTMLElement {
939
939
  }
940
940
  }
941
941
 
942
- if ('customElements' in window) {
942
+ if ('customElements' in window && !window.customElements.get('totp-consent')) {
943
943
  window.customElements.define('totp-consent', TotpConsent);
944
944
  }
945
945
 
package/.eslintrc.cjs DELETED
@@ -1,72 +0,0 @@
1
- module.exports = {
2
- env: {
3
- browser: true,
4
- commonjs: true,
5
- 'cypress/globals': true,
6
- es2021: true,
7
- },
8
- extends: 'airbnb-base',
9
- ignorePatterns: [
10
- 'build/',
11
- 'instrumentation',
12
- 'dist/',
13
- 'libs/',
14
- 'node_modules/',
15
- ],
16
- overrides: [
17
- {
18
- env: {
19
- node: true,
20
- },
21
- files: ['.eslintrc.{js,cjs}'],
22
- parserOptions: {
23
- sourceType: 'script',
24
- },
25
- },
26
- ],
27
- parserOptions: {
28
- ecmaVersion: 'latest',
29
- sourceType: 'module',
30
- },
31
- plugins: ['cypress'],
32
- rules: {
33
- 'class-methods-use-this': 'off',
34
- 'function-paren-newline': 'off',
35
- 'implicit-arrow-linebreak': 'off',
36
- 'import/no-extraneous-dependencies': [
37
- 'error',
38
- {
39
- devDependencies: [
40
- 'esbuild.js',
41
- 'cypress.config.js',
42
- '**/*{.,_,-}{test,spec}.js', // tests where the extension or filename suffix denotes that it is a test
43
- ],
44
- optionalDependencies: false,
45
- },
46
- ],
47
- indent: 0,
48
- 'max-classes-per-file': 'off',
49
- 'max-len': 'off',
50
- 'object-curly-newline': 'off',
51
- 'operator-linebreak': 'off',
52
- 'no-console': ['error', { allow: ['warn', 'error', 'info'] }],
53
- 'no-param-reassign': 'off',
54
- 'no-plusplus': 'off',
55
- 'no-underscore-dangle': 'off',
56
- 'no-unused-vars': [
57
- 'error',
58
- { args: 'after-used', ignoreRestSiblings: false, vars: 'all' },
59
- ],
60
- 'prefer-destructuring': [
61
- 'error',
62
- {
63
- array: false,
64
- object: true,
65
- },
66
- {
67
- enforceForRenamedProperties: false,
68
- },
69
- ],
70
- 'sort-keys': 'error',
71
- },
72
- };
@@ -1,144 +0,0 @@
1
- context('SmartCameraWeb', () => {
2
- beforeEach(() => {
3
- cy.visit('/smart-camera-web-agent-mode');
4
- });
5
-
6
- it('should switch from the selfie mode to agent mode"', () => {
7
- cy.log('Enable agent mode for tests');
8
- cy.get('smart-camera-web')
9
- .invoke('attr', 'allow-agent-mode', 'true')
10
- .should('have.attr', 'allow-agent-mode', 'true');
11
-
12
- cy.get('smart-camera-web').invoke(
13
- 'attr',
14
- 'show-agent-mode-for-tests',
15
- 'true',
16
- );
17
- cy.get('smart-camera-web').invoke('attr', 'disable-image-tests', '');
18
-
19
- cy.clock();
20
- cy.get('smart-camera-web')
21
- .shadow()
22
- .find('selfie-capture-instructions')
23
- .shadow()
24
- .find('#allow')
25
- .click();
26
-
27
- cy.get('smart-camera-web')
28
- .shadow()
29
- .find('selfie-capture')
30
- .should('be.visible');
31
-
32
- cy.get('smart-camera-web')
33
- .shadow()
34
- .find('selfie-capture')
35
- .shadow()
36
- .should('contain.text', 'Agent Mode On');
37
-
38
- cy.get('smart-camera-web')
39
- .shadow()
40
- .find('selfie-capture')
41
- .shadow()
42
- .find('#switch-camera')
43
- .click();
44
-
45
- cy.get('smart-camera-web')
46
- .shadow()
47
- .find('selfie-capture')
48
- .shadow()
49
- .should('contain.text', 'Agent Mode Off');
50
-
51
- cy.get('smart-camera-web')
52
- .shadow()
53
- .find('selfie-capture')
54
- .shadow()
55
- .find('#switch-camera')
56
- .click();
57
-
58
- cy.get('smart-camera-web')
59
- .shadow()
60
- .find('selfie-capture')
61
- .shadow()
62
- .should('contain.text', 'Agent Mode On');
63
-
64
- cy.get('smart-camera-web')
65
- .shadow()
66
- .find('selfie-capture')
67
- .shadow()
68
- .should('contain.text', 'Take a Selfie');
69
-
70
- cy.get('smart-camera-web')
71
- .shadow()
72
- .find('selfie-capture')
73
- .shadow()
74
- .find('#start-image-capture')
75
- .click();
76
-
77
- cy.tick(8000);
78
-
79
- cy.get('smart-camera-web')
80
- .shadow()
81
- .find('selfie-capture')
82
- .shadow()
83
- .should('not.be.visible');
84
-
85
- cy.get('smart-camera-web')
86
- .shadow()
87
- .find('selfie-capture-review')
88
- .should('be.visible');
89
- });
90
-
91
- it('should not show the agent mode switch button"', () => {
92
- cy.get('smart-camera-web')
93
- .shadow()
94
- .find('selfie-capture')
95
- .invoke('attr', 'show-agent-mode-for-tests', 'false');
96
- cy.get('smart-camera-web').invoke('attr', 'disable-image-tests', '');
97
-
98
- cy.clock();
99
- cy.get('smart-camera-web')
100
- .shadow()
101
- .find('selfie-capture-instructions')
102
- .shadow()
103
- .find('#allow')
104
- .click();
105
-
106
- cy.get('smart-camera-web')
107
- .shadow()
108
- .find('selfie-capture')
109
- .should('be.visible');
110
-
111
- cy.get('smart-camera-web')
112
- .shadow()
113
- .find('selfie-capture')
114
- .shadow()
115
- .find('#switch-camera')
116
- .should('not.exist');
117
-
118
- cy.get('smart-camera-web')
119
- .shadow()
120
- .find('selfie-capture')
121
- .shadow()
122
- .should('contain.text', 'Take a Selfie');
123
-
124
- cy.get('smart-camera-web')
125
- .shadow()
126
- .find('selfie-capture')
127
- .shadow()
128
- .find('#start-image-capture')
129
- .click();
130
-
131
- cy.tick(8000);
132
-
133
- cy.get('smart-camera-web')
134
- .shadow()
135
- .find('selfie-capture')
136
- .shadow()
137
- .should('not.be.visible');
138
-
139
- cy.get('smart-camera-web')
140
- .shadow()
141
- .find('selfie-capture-review')
142
- .should('be.visible');
143
- });
144
- });