@smileid/web-components 2.0.1 → 10.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 (125) hide show
  1. package/dist/DocumentCaptureScreens-Dwl7UqVH.js +1534 -0
  2. package/dist/DocumentCaptureScreens-Dwl7UqVH.js.map +1 -0
  3. package/dist/EndUserConsent-C5hZdJzH.js +715 -0
  4. package/dist/EndUserConsent-C5hZdJzH.js.map +1 -0
  5. package/dist/Navigation-juBE4qOw.js +136 -0
  6. package/dist/Navigation-juBE4qOw.js.map +1 -0
  7. package/dist/PoweredBySmileId-CxbaihMu.js +33 -0
  8. package/dist/PoweredBySmileId-CxbaihMu.js.map +1 -0
  9. package/dist/SelfieCaptureScreens-CQc251hz.js +7618 -0
  10. package/dist/SelfieCaptureScreens-CQc251hz.js.map +1 -0
  11. package/dist/SignaturePad-C7MtmT8m.js +324 -0
  12. package/dist/SignaturePad-C7MtmT8m.js.map +1 -0
  13. package/dist/TotpConsent-CQU5jQi4.js +730 -0
  14. package/dist/TotpConsent-CQU5jQi4.js.map +1 -0
  15. package/dist/combobox.js +300 -0
  16. package/dist/combobox.js.map +1 -0
  17. package/dist/document.js +5 -0
  18. package/dist/document.js.map +1 -0
  19. package/dist/end-user-consent.js +5 -0
  20. package/dist/end-user-consent.js.map +1 -0
  21. package/dist/main.js +22 -0
  22. package/dist/main.js.map +1 -0
  23. package/dist/navigation.js +5 -0
  24. package/dist/navigation.js.map +1 -0
  25. package/dist/package-Oi2Yil3b.js +105 -0
  26. package/dist/package-Oi2Yil3b.js.map +1 -0
  27. package/dist/selfie.js +5 -0
  28. package/dist/selfie.js.map +1 -0
  29. package/dist/signature-pad.js +5 -0
  30. package/dist/signature-pad.js.map +1 -0
  31. package/dist/smart-camera-web.js +303 -0
  32. package/dist/smart-camera-web.js.map +1 -0
  33. package/dist/styles-BUWNxWeQ.js +406 -0
  34. package/dist/styles-BUWNxWeQ.js.map +1 -0
  35. package/dist/totp-consent.js +5 -0
  36. package/dist/totp-consent.js.map +1 -0
  37. package/dist/types/combobox.d.ts +21 -0
  38. package/dist/types/document.d.ts +21 -0
  39. package/dist/types/end-user-consent.d.ts +21 -0
  40. package/dist/types/main.d.ts +331 -0
  41. package/dist/types/navigation.d.ts +21 -0
  42. package/dist/types/selfie.d.ts +21 -0
  43. package/dist/types/signature-pad.d.ts +21 -0
  44. package/dist/types/smart-camera-web.d.ts +21 -0
  45. package/dist/types/totp-consent.d.ts +21 -0
  46. package/{src → lib}/components/README.md +14 -14
  47. package/{src → lib}/components/attribution/PoweredBySmileId.js +42 -42
  48. package/{src → lib}/components/camera-permission/CameraPermission.js +140 -140
  49. package/{src → lib}/components/camera-permission/CameraPermission.stories.js +27 -27
  50. package/{src → lib}/components/combobox/src/Combobox.js +589 -589
  51. package/{src → lib}/components/combobox/src/index.js +1 -1
  52. package/{src → lib}/components/document/src/DocumentCaptureScreens.js +409 -409
  53. package/{src → lib}/components/document/src/DocumentCaptureScreens.stories.js +57 -57
  54. package/{src → lib}/components/document/src/README.md +111 -111
  55. package/{src → lib}/components/document/src/document-capture/DocumentCapture.js +760 -760
  56. package/{src → lib}/components/document/src/document-capture/DocumentCapture.stories.js +78 -78
  57. package/{src → lib}/components/document/src/document-capture/README.md +90 -90
  58. package/{src → lib}/components/document/src/document-capture/index.js +3 -3
  59. package/{src → lib}/components/document/src/document-capture-instructions/DocumentCaptureInstructions.js +499 -499
  60. package/{src → lib}/components/document/src/document-capture-instructions/DocumentCaptureInstructions.stories.js +24 -24
  61. package/{src → lib}/components/document/src/document-capture-instructions/README.md +56 -56
  62. package/{src → lib}/components/document/src/document-capture-instructions/index.js +3 -3
  63. package/{src → lib}/components/document/src/document-capture-review/DocumentCaptureReview.js +362 -362
  64. package/{src → lib}/components/document/src/document-capture-review/DocumentCaptureReview.stories.js +24 -24
  65. package/{src → lib}/components/document/src/document-capture-review/README.md +79 -79
  66. package/{src → lib}/components/document/src/document-capture-review/index.js +3 -3
  67. package/{src → lib}/components/document/src/index.js +3 -3
  68. package/{src → lib}/components/end-user-consent/src/EndUserConsent.js +795 -795
  69. package/{src → lib}/components/end-user-consent/src/EndUserConsent.stories.js +29 -29
  70. package/{src → lib}/components/end-user-consent/src/index.js +4 -4
  71. package/{src → lib}/components/navigation/src/Navigation.js +171 -171
  72. package/{src → lib}/components/navigation/src/Navigation.stories.js +24 -24
  73. package/{src → lib}/components/navigation/src/index.js +3 -3
  74. package/{src → lib}/components/selfie/README.md +225 -225
  75. package/{src → lib}/components/selfie/src/SelfieCaptureScreens.js +433 -282
  76. package/{src → lib}/components/selfie/src/SelfieCaptureScreens.stories.js +29 -29
  77. package/{src → lib}/components/selfie/src/index.js +3 -5
  78. package/{src → lib}/components/selfie/src/selfie-capture/SelfieCapture.js +1041 -1010
  79. package/{src → lib}/components/selfie/src/selfie-capture/SelfieCapture.stories.js +36 -36
  80. package/{src → lib}/components/selfie/src/selfie-capture/index.js +3 -3
  81. package/{src → lib}/components/selfie/src/selfie-capture-instructions/SelfieCaptureInstructions.js +657 -648
  82. package/{src → lib}/components/selfie/src/selfie-capture-instructions/SelfieCaptureInstructions.stories.js +23 -23
  83. package/{src → lib}/components/selfie/src/selfie-capture-instructions/index.js +3 -3
  84. package/{src → lib}/components/selfie/src/selfie-capture-review/SelfieCaptureReview.js +340 -347
  85. package/{src → lib}/components/selfie/src/selfie-capture-review/SelfieCaptureReview.stories.js +24 -24
  86. package/{src → lib}/components/selfie/src/selfie-capture-review/index.js +3 -3
  87. package/lib/components/selfie/src/selfie-capture-wrapper/SelfieCaptureWrapper.tsx +227 -0
  88. package/lib/components/selfie/src/selfie-capture-wrapper/index.ts +1 -0
  89. package/lib/components/selfie/src/smartselfie-capture/OvalProgress.tsx +81 -0
  90. package/lib/components/selfie/src/smartselfie-capture/SmartSelfieCapture.tsx +224 -0
  91. package/lib/components/selfie/src/smartselfie-capture/components/AlertDisplay.tsx +34 -0
  92. package/lib/components/selfie/src/smartselfie-capture/components/CameraPreview.tsx +97 -0
  93. package/lib/components/selfie/src/smartselfie-capture/components/CaptureControls.tsx +74 -0
  94. package/lib/components/selfie/src/smartselfie-capture/components/index.ts +3 -0
  95. package/lib/components/selfie/src/smartselfie-capture/constants.ts +23 -0
  96. package/lib/components/selfie/src/smartselfie-capture/hooks/index.ts +2 -0
  97. package/lib/components/selfie/src/smartselfie-capture/hooks/useCamera.ts +94 -0
  98. package/lib/components/selfie/src/smartselfie-capture/hooks/useFaceCapture.ts +558 -0
  99. package/lib/components/selfie/src/smartselfie-capture/index.ts +1 -0
  100. package/lib/components/selfie/src/smartselfie-capture/utils/alertMessages.ts +12 -0
  101. package/lib/components/selfie/src/smartselfie-capture/utils/canvas.ts +105 -0
  102. package/lib/components/selfie/src/smartselfie-capture/utils/faceDetection.ts +129 -0
  103. package/lib/components/selfie/src/smartselfie-capture/utils/imageCapture.ts +64 -0
  104. package/lib/components/selfie/src/smartselfie-capture/utils/index.ts +4 -0
  105. package/lib/components/selfie/src/smartselfie-capture/utils/mediapipeManager.ts +60 -0
  106. package/{src → lib}/components/signature-pad/package-lock.json +3009 -3009
  107. package/{src → lib}/components/signature-pad/package.json +30 -30
  108. package/{src → lib}/components/signature-pad/src/SignaturePad.js +484 -484
  109. package/{src → lib}/components/signature-pad/src/SignaturePad.stories.js +32 -32
  110. package/{src → lib}/components/signature-pad/src/index.js +3 -3
  111. package/{src → lib}/components/smart-camera-web/src/README.md +206 -207
  112. package/{src → lib}/components/smart-camera-web/src/SmartCameraWeb.js +299 -299
  113. package/{src → lib}/components/smart-camera-web/src/SmartCameraWeb.stories.js +57 -57
  114. package/{src → lib}/components/totp-consent/src/TotpConsent.js +949 -949
  115. package/{src → lib}/components/totp-consent/src/index.js +4 -4
  116. package/{src → lib}/domain/camera/src/README.md +38 -38
  117. package/{src → lib}/domain/camera/src/SmartCamera.js +109 -109
  118. package/{src → lib}/domain/constants/src/Constants.js +27 -27
  119. package/{src → lib}/domain/file-upload/README.md +35 -35
  120. package/{src → lib}/domain/file-upload/src/SmartFileUpload.js +65 -65
  121. package/{src → lib}/styles/README.md +3 -3
  122. package/{src → lib}/styles/src/styles.js +359 -359
  123. package/{src → lib}/styles/src/typography.js +52 -52
  124. package/package.json +109 -58
  125. package/src/index.js +0 -5
@@ -1,32 +1,32 @@
1
- import './SignaturePad';
2
-
3
- const meta = {
4
- args: {
5
- 'theme-color': '#001096',
6
- },
7
- argTypes: {
8
- 'theme-color': { control: 'color' },
9
- },
10
- component: 'smileid-signature-pad',
11
- };
12
-
13
- export default meta;
14
-
15
- export const SignaturePad = {
16
- render: (args) => `
17
- <smileid-signature-pad
18
- theme-color='${args['theme-color']}'
19
- >
20
- </smileid-signature-pad>
21
- `,
22
- };
23
-
24
- export const SignaturePadWithUploads = {
25
- render: (args) => `
26
- <smileid-signature-pad
27
- allow-upload
28
- theme-color='${args['theme-color']}'
29
- >
30
- </smileid-signature-pad>
31
- `,
32
- };
1
+ import './SignaturePad';
2
+
3
+ const meta = {
4
+ args: {
5
+ 'theme-color': '#001096',
6
+ },
7
+ argTypes: {
8
+ 'theme-color': { control: 'color' },
9
+ },
10
+ component: 'smileid-signature-pad',
11
+ };
12
+
13
+ export default meta;
14
+
15
+ export const SignaturePad = {
16
+ render: (args) => `
17
+ <smileid-signature-pad
18
+ theme-color='${args['theme-color']}'
19
+ >
20
+ </smileid-signature-pad>
21
+ `,
22
+ };
23
+
24
+ export const SignaturePadWithUploads = {
25
+ render: (args) => `
26
+ <smileid-signature-pad
27
+ allow-upload
28
+ theme-color='${args['theme-color']}'
29
+ >
30
+ </smileid-signature-pad>
31
+ `,
32
+ };
@@ -1,3 +1,3 @@
1
- import SignaturePad from './SignaturePad';
2
-
3
- export default SignaturePad;
1
+ import SignaturePad from './SignaturePad';
2
+
3
+ export default SignaturePad;
@@ -1,207 +1,206 @@
1
- # SmartCameraWeb
2
-
3
- `SmartCameraWeb` is a [Web Component](https://developer.mozilla.org/en-US/docs/Web/Web_Components) designed to capture images including selfies, liveness images, and ID Document images for use with SmileIdentity. It interfaces with the [Server to Server](https://docs.usesmileid.com/server-to-server) libraries, serving as a user interface client.
4
-
5
- Explore an [example full stack integration](https://glitch.com/edit/#!/smart-camera-web-demo-node) using our [NodeJS](https://docs.usesmileid.com/server-to-server/javascript) library.
6
-
7
- ## Getting Started
8
-
9
- To integrate `SmartCameraWeb`, follow these steps:
10
-
11
- - [SmartCameraWeb](#smartcameraweb)
12
- - [Getting Started](#getting-started)
13
- - [Choose a Server to Server Library](#choose-a-server-to-server-library)
14
- - [Installation](#installation)
15
- - [Install Via NPM](#install-via-npm)
16
- - [Usage](#usage)
17
- - [Compatibility](#compatibility)
18
- - [Support](#support)
19
- - [Development](#development)
20
-
21
- ### Choose a Server to Server Library
22
-
23
- Supported [Server to Server Libraries](https://docs.usesmileid.com/server-to-server) include:
24
-
25
- - [Java](https://docs.usesmileid.com/server-to-server/java)
26
- - [NodeJS](https://docs.usesmileid.com/server-to-server/javascript)
27
- - [PHP](https://docs.usesmileid.com/server-to-server/php)
28
- - [Python](https://docs.usesmileid.com/server-to-server/python)
29
- - [Ruby](https://docs.usesmileid.com/server-to-server/ruby)
30
-
31
- > **Note**: Code samples in this documentation utilize the NodeJS Server to Server library.
32
-
33
- ### Installation
34
-
35
- You can install via NPM or directly include it from our CDN.
36
-
37
- #### Install Via NPM
38
-
39
- ```shell
40
- npm install @smileid/web-components@<version>
41
- ```
42
-
43
- Then, in your VueJS, AngularJS, or React component:
44
-
45
- ```js
46
- import '@smileid/web-components/smart-camera-web';
47
- ```
48
-
49
- ### Usage
50
-
51
- After installation and necessary imports:
52
-
53
- 1. Add the desired markup to your page/component:
54
-
55
- - **For Selfie Capture / Liveness Images**:
56
-
57
- ```html
58
- <smart-camera-web></smart-camera-web>
59
- ```
60
-
61
- - **For Selfie Capture / Liveness and ID Images**:
62
-
63
- ```html
64
- <smart-camera-web capture-id></smart-camera-web>
65
- ```
66
-
67
- Initially, you'll see this image:
68
- ![Selfie Capture Instruction](https://cdn.smileidentity.com/images/smart-camera-web/selfie-capture-instruction.png)
69
-
70
- After granting access, the capture screen appears:
71
- ![Selfie Camera](https://cdn.smileidentity.com/images/smart-camera-web/selfie-capture.png)
72
-
73
- Upon capturing a selfie, you'll reach the review screen:
74
- ![Selfie Review](https://cdn.smileidentity.com/images/smart-camera-web/selfie-capture-review.png)
75
-
76
- ![Document Capture Instruction](https://cdn.smileidentity.com/images/smart-camera-web/document-capture-instruction.png)
77
-
78
- If the `capture-id` attribute is used, additional screens include:
79
-
80
- ![ID Camera](https://cdn.smileidentity.com/images/smart-camera-web/document-capture.png)
81
-
82
- ![ID Review](https://cdn.smileidentity.com/images/smart-camera-web/document-review-new.png)
83
-
84
- 2. Handle the `smart-camera-web.publish` event:
85
-
86
- When the user approves the captured image, an `smart-camera-web.publish` event is dispatched. The event returns a [CustomEvent](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent) payload in `e.detail`.
87
-
88
- Here's a script example to handle the event and send data to a backend endpoint:
89
-
90
- ```html
91
- <script>
92
- const app = document.querySelector('smart-camera-web');
93
-
94
- const postContent = async (data) => {
95
- const options = {
96
- method: 'POST',
97
- headers: {
98
- 'Content-Type': 'application/json',
99
- },
100
- body: JSON.stringify(data),
101
- };
102
-
103
- try {
104
- const response = await fetch('/', options);
105
- const json = await response.json();
106
-
107
- return json;
108
- } catch (e) {
109
- throw e;
110
- }
111
- };
112
-
113
- app.addEventListener('smart-camera-web.publish', async (e) => {
114
- try {
115
- const response = await postContent(e.detail);
116
-
117
- console.log(response);
118
- } catch (e) {
119
- console.error(e);
120
- }
121
- });
122
- </script>
123
- ```
124
-
125
- The provided backend endpoint uses the NodeJS Server to Server library and ExpressJS:
126
-
127
- ```js
128
- const express = require('express');
129
- const { v4: UUID } = require('uuid');
130
-
131
- if (process.env.NODE_ENV === 'development') {
132
- const dotenv = require('dotenv');
133
-
134
- dotenv.config();
135
- }
136
-
137
- const SIDCore = require('smile-identity-core');
138
- const SIDSignature = SIDCore.Signature;
139
- const SIDWebAPI = SIDCore.WebApi;
140
-
141
- const app = express();
142
-
143
- app.use(express.json({ limit: '500kb' }));
144
- app.use(express.static('public'));
145
-
146
- app.post('/', async (req, res, next) => {
147
- try {
148
- const { PARTNER_ID, API_KEY, SID_SERVER } = process.env;
149
- const connection = new SIDWebAPI(
150
- PARTNER_ID,
151
- '/callback',
152
- API_KEY,
153
- SID_SERVER,
154
- );
155
-
156
- const partner_params_from_server = {
157
- user_id: `user-${UUID()}`,
158
- job_id: `job-${UUID()}`,
159
- job_type: 4, // job_type is the simplest job we have which enrolls a user using their selfie
160
- };
161
-
162
- const {
163
- images,
164
- partner_params: { libraryVersion },
165
- } = req.body;
166
-
167
- const options = {
168
- return_job_status: true,
169
- };
170
-
171
- const partner_params = Object.assign({}, partner_params_from_server, {
172
- libraryVersion,
173
- });
174
-
175
- const result = await connection.submit_job(
176
- partner_params,
177
- images,
178
- {},
179
- options,
180
- );
181
-
182
- res.json(result);
183
- } catch (e) {
184
- console.error(e);
185
- }
186
- });
187
-
188
- // NOTE: This can be used to process responses. don't forget to add it as a callback option in the `connection` config on L22
189
- // https://docs.usesmileid.com/further-reading/faqs/how-do-i-setup-a-callback
190
- app.post('/callback', (req, res, next) => {});
191
-
192
- app.listen(process.env.PORT || 4000);
193
- ```
194
-
195
- This approach can also be achieved using other Server to Server libraries.
196
-
197
- ## Compatibility
198
-
199
- `SmartCameraWeb` is compatible with most JavaScript frameworks and libraries. For integration with [ReactJS](https://reactjs.org), refer to this [tutorial](https://www.robinwieruch.de/react-web-components) due to React-WebComponents compatibility issues.
200
-
201
- ## Support
202
-
203
- Tested on the latest versions of Chrome, Edge, Firefox, and Safari. If compatibility issues arise on certain browsers, please notify us.
204
-
205
- ## Development
206
-
207
- Note: `smart-camera-web.js` is generated from `src/` using [esbuild](https://esbuild.github.io/). To make changes, edit the source files and run `npm run build` to generate the new `smart-camera-web.js` file.
1
+ # SmartCameraWeb
2
+
3
+ `SmartCameraWeb` is a [Web Component](https://developer.mozilla.org/en-US/docs/Web/Web_Components) designed to capture images including selfies, liveness images, and ID Document images for use with SmileIdentity. It interfaces with the [Server to Server](https://docs.usesmileid.com/server-to-server) libraries, serving as a user interface client.
4
+
5
+ Explore an [example full stack integration](https://glitch.com/edit/#!/smart-camera-web-demo-node) using our [NodeJS](https://docs.usesmileid.com/server-to-server/javascript) library.
6
+
7
+ ## Getting Started
8
+
9
+ To integrate `SmartCameraWeb`, follow these steps:
10
+
11
+ - [SmartCameraWeb](#smartcameraweb)
12
+ - [Getting Started](#getting-started)
13
+ - [Choose a Server to Server Library](#choose-a-server-to-server-library)
14
+ - [Installation](#installation)
15
+ - [Install Via NPM](#install-via-npm)
16
+ - [Usage](#usage)
17
+ - [Compatibility](#compatibility)
18
+ - [Support](#support)
19
+ - [Development](#development)
20
+
21
+ ### Choose a Server to Server Library
22
+
23
+ Supported [Server to Server Libraries](https://docs.usesmileid.com/server-to-server) include:
24
+
25
+ - [Java](https://docs.usesmileid.com/server-to-server/java)
26
+ - [NodeJS](https://docs.usesmileid.com/server-to-server/javascript)
27
+ - [PHP](https://docs.usesmileid.com/server-to-server/php)
28
+ - [Python](https://docs.usesmileid.com/server-to-server/python)
29
+ - [Ruby](https://docs.usesmileid.com/server-to-server/ruby)
30
+
31
+ > **Note**: Code samples in this documentation utilize the NodeJS Server to Server library.
32
+
33
+ ### Installation
34
+
35
+ You can install via NPM or directly include it from our CDN.
36
+
37
+ #### Install Via NPM
38
+
39
+ ```shell
40
+ npm install @smileid/web-components@<version>
41
+ ```
42
+
43
+ Then, in your VueJS, AngularJS, or React component:
44
+
45
+ ```js
46
+ import '@smileid/web-components/smart-camera-web';
47
+ ```
48
+
49
+ ### Usage
50
+
51
+ After installation and necessary imports:
52
+
53
+ 1. Add the desired markup to your page/component:
54
+ - **For Selfie Capture / Liveness Images**:
55
+
56
+ ```html
57
+ <smart-camera-web></smart-camera-web>
58
+ ```
59
+
60
+ - **For Selfie Capture / Liveness and ID Images**:
61
+
62
+ ```html
63
+ <smart-camera-web capture-id></smart-camera-web>
64
+ ```
65
+
66
+ Initially, you'll see this image:
67
+ ![Selfie Capture Instruction](https://cdn.smileidentity.com/images/smart-camera-web/selfie-capture-instruction.png)
68
+
69
+ After granting access, the capture screen appears:
70
+ ![Selfie Camera](https://cdn.smileidentity.com/images/smart-camera-web/selfie-capture.png)
71
+
72
+ Upon capturing a selfie, you'll reach the review screen:
73
+ ![Selfie Review](https://cdn.smileidentity.com/images/smart-camera-web/selfie-capture-review.png)
74
+
75
+ ![Document Capture Instruction](https://cdn.smileidentity.com/images/smart-camera-web/document-capture-instruction.png)
76
+
77
+ If the `capture-id` attribute is used, additional screens include:
78
+
79
+ ![ID Camera](https://cdn.smileidentity.com/images/smart-camera-web/document-capture.png)
80
+
81
+ ![ID Review](https://cdn.smileidentity.com/images/smart-camera-web/document-review-new.png)
82
+
83
+ 2. Handle the `smart-camera-web.publish` event:
84
+
85
+ When the user approves the captured image, an `smart-camera-web.publish` event is dispatched. The event returns a [CustomEvent](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent) payload in `e.detail`.
86
+
87
+ Here's a script example to handle the event and send data to a backend endpoint:
88
+
89
+ ```html
90
+ <script>
91
+ const app = document.querySelector('smart-camera-web');
92
+
93
+ const postContent = async (data) => {
94
+ const options = {
95
+ method: 'POST',
96
+ headers: {
97
+ 'Content-Type': 'application/json',
98
+ },
99
+ body: JSON.stringify(data),
100
+ };
101
+
102
+ try {
103
+ const response = await fetch('/', options);
104
+ const json = await response.json();
105
+
106
+ return json;
107
+ } catch (e) {
108
+ throw e;
109
+ }
110
+ };
111
+
112
+ app.addEventListener('smart-camera-web.publish', async (e) => {
113
+ try {
114
+ const response = await postContent(e.detail);
115
+
116
+ console.log(response);
117
+ } catch (e) {
118
+ console.error(e);
119
+ }
120
+ });
121
+ </script>
122
+ ```
123
+
124
+ The provided backend endpoint uses the NodeJS Server to Server library and ExpressJS:
125
+
126
+ ```js
127
+ const express = require('express');
128
+ const { v4: UUID } = require('uuid');
129
+
130
+ if (process.env.NODE_ENV === 'development') {
131
+ const dotenv = require('dotenv');
132
+
133
+ dotenv.config();
134
+ }
135
+
136
+ const SIDCore = require('smile-identity-core');
137
+ const SIDSignature = SIDCore.Signature;
138
+ const SIDWebAPI = SIDCore.WebApi;
139
+
140
+ const app = express();
141
+
142
+ app.use(express.json({ limit: '500kb' }));
143
+ app.use(express.static('public'));
144
+
145
+ app.post('/', async (req, res, next) => {
146
+ try {
147
+ const { PARTNER_ID, API_KEY, SID_SERVER } = process.env;
148
+ const connection = new SIDWebAPI(
149
+ PARTNER_ID,
150
+ '/callback',
151
+ API_KEY,
152
+ SID_SERVER,
153
+ );
154
+
155
+ const partner_params_from_server = {
156
+ user_id: `user-${UUID()}`,
157
+ job_id: `job-${UUID()}`,
158
+ job_type: 4, // job_type is the simplest job we have which enrolls a user using their selfie
159
+ };
160
+
161
+ const {
162
+ images,
163
+ partner_params: { libraryVersion },
164
+ } = req.body;
165
+
166
+ const options = {
167
+ return_job_status: true,
168
+ };
169
+
170
+ const partner_params = Object.assign({}, partner_params_from_server, {
171
+ libraryVersion,
172
+ });
173
+
174
+ const result = await connection.submit_job(
175
+ partner_params,
176
+ images,
177
+ {},
178
+ options,
179
+ );
180
+
181
+ res.json(result);
182
+ } catch (e) {
183
+ console.error(e);
184
+ }
185
+ });
186
+
187
+ // NOTE: This can be used to process responses. don't forget to add it as a callback option in the `connection` config on L22
188
+ // https://docs.usesmileid.com/further-reading/faqs/how-do-i-setup-a-callback
189
+ app.post('/callback', (req, res, next) => {});
190
+
191
+ app.listen(process.env.PORT || 4000);
192
+ ```
193
+
194
+ This approach can also be achieved using other Server to Server libraries.
195
+
196
+ ## Compatibility
197
+
198
+ `SmartCameraWeb` is compatible with most JavaScript frameworks and libraries. For integration with [ReactJS](https://reactjs.org), refer to this [tutorial](https://www.robinwieruch.de/react-web-components) due to React-WebComponents compatibility issues.
199
+
200
+ ## Support
201
+
202
+ Tested on the latest versions of Chrome, Edge, Firefox, and Safari. If compatibility issues arise on certain browsers, please notify us.
203
+
204
+ ## Development
205
+
206
+ Note: `smart-camera-web.js` is generated from `src/` using [esbuild](https://esbuild.github.io/). To make changes, edit the source files and run `npm run build` to generate the new `smart-camera-web.js` file.