@smileid/web-components 2.0.1 → 2.0.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.
- package/package.json +58 -58
- package/src/components/README.md +14 -14
- package/src/components/attribution/PoweredBySmileId.js +42 -42
- package/src/components/camera-permission/CameraPermission.js +140 -140
- package/src/components/camera-permission/CameraPermission.stories.js +27 -27
- package/src/components/combobox/src/Combobox.js +589 -589
- package/src/components/combobox/src/index.js +1 -1
- package/src/components/document/src/DocumentCaptureScreens.js +409 -409
- package/src/components/document/src/DocumentCaptureScreens.stories.js +57 -57
- package/src/components/document/src/README.md +111 -111
- package/src/components/document/src/document-capture/DocumentCapture.js +760 -760
- package/src/components/document/src/document-capture/DocumentCapture.stories.js +78 -78
- package/src/components/document/src/document-capture/README.md +90 -90
- package/src/components/document/src/document-capture/index.js +3 -3
- package/src/components/document/src/document-capture-instructions/DocumentCaptureInstructions.js +499 -499
- package/src/components/document/src/document-capture-instructions/DocumentCaptureInstructions.stories.js +24 -24
- package/src/components/document/src/document-capture-instructions/README.md +56 -56
- package/src/components/document/src/document-capture-instructions/index.js +3 -3
- package/src/components/document/src/document-capture-review/DocumentCaptureReview.js +362 -362
- package/src/components/document/src/document-capture-review/DocumentCaptureReview.stories.js +24 -24
- package/src/components/document/src/document-capture-review/README.md +79 -79
- package/src/components/document/src/document-capture-review/index.js +3 -3
- package/src/components/document/src/index.js +3 -3
- package/src/components/end-user-consent/src/EndUserConsent.js +795 -795
- package/src/components/end-user-consent/src/EndUserConsent.stories.js +29 -29
- package/src/components/end-user-consent/src/index.js +4 -4
- package/src/components/navigation/src/Navigation.js +171 -171
- package/src/components/navigation/src/Navigation.stories.js +24 -24
- package/src/components/navigation/src/index.js +3 -3
- package/src/components/selfie/README.md +225 -225
- package/src/components/selfie/src/SelfieCaptureScreens.js +282 -282
- package/src/components/selfie/src/SelfieCaptureScreens.stories.js +29 -29
- package/src/components/selfie/src/index.js +5 -5
- package/src/components/selfie/src/selfie-capture/SelfieCapture.js +1041 -1010
- package/src/components/selfie/src/selfie-capture/SelfieCapture.stories.js +36 -36
- package/src/components/selfie/src/selfie-capture/index.js +3 -3
- package/src/components/selfie/src/selfie-capture-instructions/SelfieCaptureInstructions.js +657 -648
- package/src/components/selfie/src/selfie-capture-instructions/SelfieCaptureInstructions.stories.js +23 -23
- package/src/components/selfie/src/selfie-capture-instructions/index.js +3 -3
- package/src/components/selfie/src/selfie-capture-review/SelfieCaptureReview.js +347 -347
- package/src/components/selfie/src/selfie-capture-review/SelfieCaptureReview.stories.js +24 -24
- package/src/components/selfie/src/selfie-capture-review/index.js +3 -3
- package/src/components/signature-pad/package-lock.json +3009 -3009
- package/src/components/signature-pad/package.json +30 -30
- package/src/components/signature-pad/src/SignaturePad.js +484 -484
- package/src/components/signature-pad/src/SignaturePad.stories.js +32 -32
- package/src/components/signature-pad/src/index.js +3 -3
- package/src/components/smart-camera-web/src/README.md +207 -207
- package/src/components/smart-camera-web/src/SmartCameraWeb.js +299 -299
- package/src/components/smart-camera-web/src/SmartCameraWeb.stories.js +57 -57
- package/src/components/totp-consent/src/TotpConsent.js +949 -949
- package/src/components/totp-consent/src/index.js +4 -4
- package/src/domain/camera/src/README.md +38 -38
- package/src/domain/camera/src/SmartCamera.js +109 -109
- package/src/domain/constants/src/Constants.js +27 -27
- package/src/domain/file-upload/README.md +35 -35
- package/src/domain/file-upload/src/SmartFileUpload.js +65 -65
- package/src/index.js +5 -5
- package/src/styles/README.md +3 -3
- package/src/styles/src/styles.js +359 -359
- package/src/styles/src/typography.js +52 -52
|
@@ -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,207 @@
|
|
|
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
|
-

|
|
69
|
-
|
|
70
|
-
After granting access, the capture screen appears:
|
|
71
|
-

|
|
72
|
-
|
|
73
|
-
Upon capturing a selfie, you'll reach the review screen:
|
|
74
|
-

|
|
75
|
-
|
|
76
|
-

|
|
77
|
-
|
|
78
|
-
If the `capture-id` attribute is used, additional screens include:
|
|
79
|
-
|
|
80
|
-

|
|
81
|
-
|
|
82
|
-

|
|
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
|
+
|
|
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
|
+

|
|
69
|
+
|
|
70
|
+
After granting access, the capture screen appears:
|
|
71
|
+

|
|
72
|
+
|
|
73
|
+
Upon capturing a selfie, you'll reach the review screen:
|
|
74
|
+

|
|
75
|
+
|
|
76
|
+

|
|
77
|
+
|
|
78
|
+
If the `capture-id` attribute is used, additional screens include:
|
|
79
|
+
|
|
80
|
+

|
|
81
|
+
|
|
82
|
+

|
|
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.
|