@smileid/web-components 10.0.6 → 11.0.1
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/README.md +15 -15
- package/dist/README.md +15 -0
- package/dist/components/README.md +14 -0
- package/dist/components/document/src/README.md +111 -0
- package/dist/components/document/src/document-capture/README.md +90 -0
- package/dist/components/document/src/document-capture-instructions/README.md +56 -0
- package/dist/components/document/src/document-capture-review/README.md +79 -0
- package/dist/components/selfie/README.md +225 -0
- package/dist/components/smart-camera-web/src/README.md +207 -0
- package/dist/domain/camera/src/README.md +38 -0
- package/dist/domain/file-upload/README.md +35 -0
- package/dist/esm/{DocumentCaptureScreens-BjATTDqu.js → DocumentCaptureScreens-DmH2JZDA.js} +3 -3
- package/dist/esm/DocumentCaptureScreens-DmH2JZDA.js.map +1 -0
- package/dist/esm/EndUserConsent-D4fd1ovG.js.map +1 -1
- package/dist/esm/Navigation-CTjK6tLU.js.map +1 -1
- package/dist/esm/PoweredBySmileId-CxbaihMu.js.map +1 -1
- package/dist/esm/SelfieCaptureScreens-DbdN2zNk.js +7901 -0
- package/dist/esm/SelfieCaptureScreens-DbdN2zNk.js.map +1 -0
- package/dist/esm/SignaturePad-C7MtmT8m.js.map +1 -1
- package/dist/esm/TotpConsent-CQU5jQi4.js.map +1 -1
- package/dist/esm/combobox.js.map +1 -1
- package/dist/esm/document.js +1 -1
- package/dist/esm/main.js +2 -2
- package/dist/esm/{package-CZlW6BZn.js → package-bgeQiff6.js} +2 -2
- package/dist/esm/package-bgeQiff6.js.map +1 -0
- package/dist/esm/selfie.js +1 -1
- package/dist/esm/smart-camera-web.js +3 -3
- package/dist/esm/smart-camera-web.js.map +1 -1
- package/dist/esm/styles-BOEZtbuc.js.map +1 -1
- package/dist/package-lock.json +4948 -0
- package/dist/package.json +59 -0
- package/dist/smart-camera-web.js +72 -98
- package/dist/smart-camera-web.js.gz +0 -0
- package/dist/smart-camera-web.js.map +1 -1
- package/dist/src/components/combobox/src/index.js +2 -0
- package/dist/src/components/combobox/src/index.js.map +7 -0
- package/dist/src/components/document/src/index.js +2 -0
- package/dist/src/components/document/src/index.js.map +7 -0
- package/dist/src/components/end-user-consent/src/index.js +14 -0
- package/dist/src/components/end-user-consent/src/index.js.map +7 -0
- package/dist/src/components/selfie/src/index.js +2 -0
- package/dist/src/components/selfie/src/index.js.map +7 -0
- package/dist/src/components/signature-pad/src/index.js +10 -0
- package/dist/src/components/signature-pad/src/index.js.map +7 -0
- package/dist/src/components/smart-camera-web/src/SmartCameraWeb.js +2 -0
- package/dist/src/components/smart-camera-web/src/SmartCameraWeb.js.map +7 -0
- package/dist/src/components/totp-consent/src/index.js +14 -0
- package/dist/src/components/totp-consent/src/index.js.map +7 -0
- package/dist/src/index.js.map +7 -0
- package/dist/styles/README.md +3 -0
- package/dist/types/combobox.d.ts +19 -19
- package/dist/types/document.d.ts +19 -19
- package/dist/types/end-user-consent.d.ts +19 -19
- package/dist/types/main.d.ts +24 -20
- package/dist/types/navigation.d.ts +19 -19
- package/dist/types/selfie.d.ts +19 -19
- package/dist/types/signature-pad.d.ts +19 -19
- package/dist/types/smart-camera-web.d.ts +19 -19
- package/dist/types/totp-consent.d.ts +19 -19
- package/lib/components/README.md +14 -14
- package/lib/components/attribution/PoweredBySmileId.js +42 -42
- package/lib/components/camera-permission/CameraPermission.js +139 -139
- package/lib/components/camera-permission/CameraPermission.stories.js +27 -27
- package/lib/components/combobox/src/Combobox.js +589 -589
- package/lib/components/combobox/src/index.js +1 -1
- package/lib/components/document/src/DocumentCaptureScreens.js +410 -409
- package/lib/components/document/src/DocumentCaptureScreens.stories.js +57 -57
- package/lib/components/document/src/README.md +111 -111
- package/lib/components/document/src/document-capture/DocumentCapture.js +760 -760
- package/lib/components/document/src/document-capture/DocumentCapture.stories.js +78 -78
- package/lib/components/document/src/document-capture/README.md +90 -90
- package/lib/components/document/src/document-capture/index.js +3 -3
- package/lib/components/document/src/document-capture-instructions/DocumentCaptureInstructions.js +545 -545
- package/lib/components/document/src/document-capture-instructions/DocumentCaptureInstructions.stories.js +24 -24
- package/lib/components/document/src/document-capture-instructions/README.md +56 -56
- package/lib/components/document/src/document-capture-instructions/index.js +3 -3
- package/lib/components/document/src/document-capture-review/DocumentCaptureReview.js +360 -360
- package/lib/components/document/src/document-capture-review/DocumentCaptureReview.stories.js +24 -24
- package/lib/components/document/src/document-capture-review/README.md +79 -79
- package/lib/components/document/src/document-capture-review/index.js +3 -3
- package/lib/components/document/src/index.js +3 -3
- package/lib/components/end-user-consent/src/EndUserConsent.js +795 -795
- package/lib/components/end-user-consent/src/EndUserConsent.stories.js +29 -29
- package/lib/components/end-user-consent/src/index.js +4 -4
- package/lib/components/navigation/src/Navigation.js +171 -171
- package/lib/components/navigation/src/Navigation.stories.js +24 -24
- package/lib/components/navigation/src/index.js +3 -3
- package/lib/components/selfie/README.md +225 -225
- package/lib/components/selfie/src/SelfieCaptureScreens.js +420 -431
- package/lib/components/selfie/src/SelfieCaptureScreens.stories.js +29 -29
- package/lib/components/selfie/src/index.js +3 -3
- package/lib/components/selfie/src/selfie-capture/SelfieCapture.js +1099 -1084
- package/lib/components/selfie/src/selfie-capture/SelfieCapture.stories.js +36 -36
- package/lib/components/selfie/src/selfie-capture/index.js +3 -3
- package/lib/components/selfie/src/selfie-capture-instructions/SelfieCaptureInstructions.js +689 -689
- package/lib/components/selfie/src/selfie-capture-instructions/SelfieCaptureInstructions.stories.js +23 -23
- package/lib/components/selfie/src/selfie-capture-instructions/index.js +3 -3
- package/lib/components/selfie/src/selfie-capture-review/SelfieCaptureReview.js +209 -209
- package/lib/components/selfie/src/selfie-capture-review/SelfieCaptureReview.stories.js +24 -24
- package/lib/components/selfie/src/selfie-capture-review/index.js +3 -3
- package/lib/components/selfie/src/selfie-capture-wrapper/SelfieCaptureWrapper.tsx +256 -239
- package/lib/components/selfie/src/selfie-capture-wrapper/index.ts +1 -1
- package/lib/components/selfie/src/smartselfie-capture/OvalProgress.tsx +81 -81
- package/lib/components/selfie/src/smartselfie-capture/SmartSelfieCapture.tsx +265 -283
- package/lib/components/selfie/src/smartselfie-capture/components/AlertDisplay.tsx +34 -34
- package/lib/components/selfie/src/smartselfie-capture/components/CameraPreview.tsx +97 -97
- package/lib/components/selfie/src/smartselfie-capture/components/CaptureControls.tsx +78 -76
- package/lib/components/selfie/src/smartselfie-capture/components/index.ts +3 -3
- package/lib/components/selfie/src/smartselfie-capture/constants.ts +23 -23
- package/lib/components/selfie/src/smartselfie-capture/hooks/index.ts +2 -2
- package/lib/components/selfie/src/smartselfie-capture/hooks/useCamera.ts +238 -238
- package/lib/components/selfie/src/smartselfie-capture/hooks/useFaceCapture.ts +618 -617
- package/lib/components/selfie/src/smartselfie-capture/index.ts +1 -1
- package/lib/components/selfie/src/smartselfie-capture/utils/alertMessages.ts +13 -13
- package/lib/components/selfie/src/smartselfie-capture/utils/canvas.ts +105 -105
- package/lib/components/selfie/src/smartselfie-capture/utils/faceDetection.ts +129 -129
- package/lib/components/selfie/src/smartselfie-capture/utils/imageCapture.ts +64 -64
- package/lib/components/selfie/src/smartselfie-capture/utils/index.ts +4 -4
- package/lib/components/selfie/src/smartselfie-capture/utils/mediapipeManager.ts +77 -77
- package/lib/components/signature-pad/package-lock.json +3009 -3009
- package/lib/components/signature-pad/package.json +30 -30
- package/lib/components/signature-pad/src/SignaturePad.js +484 -484
- package/lib/components/signature-pad/src/SignaturePad.stories.js +32 -32
- package/lib/components/signature-pad/src/index.js +3 -3
- package/lib/components/smart-camera-web/src/README.md +206 -206
- package/lib/components/smart-camera-web/src/SmartCameraWeb.js +305 -305
- package/lib/components/smart-camera-web/src/SmartCameraWeb.stories.js +57 -57
- package/lib/components/totp-consent/src/TotpConsent.js +949 -949
- package/lib/components/totp-consent/src/index.js +4 -4
- package/lib/domain/camera/src/README.md +38 -38
- package/lib/domain/camera/src/SmartCamera.js +109 -109
- package/lib/domain/constants/src/Constants.js +27 -27
- package/lib/domain/file-upload/README.md +35 -35
- package/lib/domain/file-upload/src/SmartFileUpload.js +65 -65
- package/lib/styles/README.md +3 -3
- package/lib/styles/src/styles.js +372 -372
- package/lib/styles/src/typography.js +52 -52
- package/package.json +111 -112
- package/dist/esm/DocumentCaptureScreens-BjATTDqu.js.map +0 -1
- package/dist/esm/SelfieCaptureScreens-UUzZzl1A.js +0 -11361
- package/dist/esm/SelfieCaptureScreens-UUzZzl1A.js.map +0 -1
- package/dist/esm/package-CZlW6BZn.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
2
|
-
// eslint-disable-next-line import/prefer-default-export
|
|
3
|
-
TotpConsent,
|
|
4
|
-
} from './TotpConsent';
|
|
1
|
+
export {
|
|
2
|
+
// eslint-disable-next-line import/prefer-default-export
|
|
3
|
+
TotpConsent,
|
|
4
|
+
} from './TotpConsent';
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
# SmartCamera.js
|
|
2
|
-
|
|
3
|
-
SmartCamera.js is a JavaScript class that provides an interface for interacting with the user's camera device. It has special handling for multi-camera Samsung devices to mitigate issues with blurry images at the edges.
|
|
4
|
-
|
|
5
|
-
## Usage
|
|
6
|
-
|
|
7
|
-
### Getting Media Stream
|
|
8
|
-
|
|
9
|
-
To get the media stream from the user's camera, call the `getMedia` method with the desired constraints. This method returns a Promise that resolves to a MediaStream object.
|
|
10
|
-
|
|
11
|
-
```javascript
|
|
12
|
-
const constraints = {
|
|
13
|
-
video: true,
|
|
14
|
-
audio: false,
|
|
15
|
-
};
|
|
16
|
-
const stream = await SmartCamera.getMedia(constraints);
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
`StartCamera` is a singleton so the `stream` can be accessed anytime via `SmartCamera.stream`.
|
|
20
|
-
|
|
21
|
-
```javascript
|
|
22
|
-
let video = document.createElement('video');
|
|
23
|
-
|
|
24
|
-
video.autoplay = true;
|
|
25
|
-
video.playsInline = true;
|
|
26
|
-
video.muted = true;
|
|
27
|
-
|
|
28
|
-
if ('srcObject' in video) {
|
|
29
|
-
video.srcObject = stream;
|
|
30
|
-
} else {
|
|
31
|
-
video.src = window.URL.createObjectURL(stream);
|
|
32
|
-
}
|
|
33
|
-
video.play();
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
### Stopping Media Stream
|
|
37
|
-
|
|
38
|
-
To stop the media stream, call the stopMedia method. This will stop all tracks in the stream and set the stream to null.
|
|
1
|
+
# SmartCamera.js
|
|
2
|
+
|
|
3
|
+
SmartCamera.js is a JavaScript class that provides an interface for interacting with the user's camera device. It has special handling for multi-camera Samsung devices to mitigate issues with blurry images at the edges.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
### Getting Media Stream
|
|
8
|
+
|
|
9
|
+
To get the media stream from the user's camera, call the `getMedia` method with the desired constraints. This method returns a Promise that resolves to a MediaStream object.
|
|
10
|
+
|
|
11
|
+
```javascript
|
|
12
|
+
const constraints = {
|
|
13
|
+
video: true,
|
|
14
|
+
audio: false,
|
|
15
|
+
};
|
|
16
|
+
const stream = await SmartCamera.getMedia(constraints);
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
`StartCamera` is a singleton so the `stream` can be accessed anytime via `SmartCamera.stream`.
|
|
20
|
+
|
|
21
|
+
```javascript
|
|
22
|
+
let video = document.createElement('video');
|
|
23
|
+
|
|
24
|
+
video.autoplay = true;
|
|
25
|
+
video.playsInline = true;
|
|
26
|
+
video.muted = true;
|
|
27
|
+
|
|
28
|
+
if ('srcObject' in video) {
|
|
29
|
+
video.srcObject = stream;
|
|
30
|
+
} else {
|
|
31
|
+
video.src = window.URL.createObjectURL(stream);
|
|
32
|
+
}
|
|
33
|
+
video.play();
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Stopping Media Stream
|
|
37
|
+
|
|
38
|
+
To stop the media stream, call the stopMedia method. This will stop all tracks in the stream and set the stream to null.
|
|
@@ -1,109 +1,109 @@
|
|
|
1
|
-
class SmartCamera {
|
|
2
|
-
static stream = null;
|
|
3
|
-
|
|
4
|
-
static async getMedia(constraints) {
|
|
5
|
-
SmartCamera.stream = await navigator.mediaDevices.getUserMedia(constraints);
|
|
6
|
-
return SmartCamera.stream;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
static environmentOptions = {
|
|
10
|
-
facingMode: 'environment',
|
|
11
|
-
height: {
|
|
12
|
-
ideal: 1080,
|
|
13
|
-
max: 1440,
|
|
14
|
-
min: 720,
|
|
15
|
-
},
|
|
16
|
-
width: {
|
|
17
|
-
ideal: 1920,
|
|
18
|
-
max: 2560,
|
|
19
|
-
min: 1280,
|
|
20
|
-
},
|
|
21
|
-
// NOTE: Special case for multi-camera Samsung devices (learnt from Acuant)
|
|
22
|
-
// "We found out that some triple camera Samsung devices (S10, S20, Note 20, etc) capture images blurry at edges.
|
|
23
|
-
// Zooming to 2X, matching the telephoto lens, doesn't solve it completely but mitigates it."
|
|
24
|
-
zoom: SmartCamera.isSamsungMultiCameraDevice() ? 2.0 : 1.0,
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
static stopMedia() {
|
|
28
|
-
if (SmartCamera.stream) {
|
|
29
|
-
SmartCamera.stream.getTracks().forEach((track) => track.stop());
|
|
30
|
-
SmartCamera.stream = null;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
static async supportsAgentMode() {
|
|
35
|
-
try {
|
|
36
|
-
const devices = await navigator.mediaDevices.enumerateDevices();
|
|
37
|
-
const videoDevices = devices.filter(
|
|
38
|
-
(device) => device.kind === 'videoinput',
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
let hasBackCamera = false;
|
|
42
|
-
|
|
43
|
-
videoDevices.forEach((device) => {
|
|
44
|
-
// Check if the device label or device ID indicates a back camera
|
|
45
|
-
if (
|
|
46
|
-
device.label.toLowerCase().includes('back') ||
|
|
47
|
-
device.label.toLowerCase().includes('rear')
|
|
48
|
-
) {
|
|
49
|
-
hasBackCamera = true;
|
|
50
|
-
return true;
|
|
51
|
-
}
|
|
52
|
-
return false;
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
return hasBackCamera;
|
|
56
|
-
} catch (error) {
|
|
57
|
-
console.warn('Error accessing media devices: ', error);
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
static isSamsungMultiCameraDevice() {
|
|
63
|
-
const matchedModelNumber = navigator.userAgent.match(/SM-[N|G]\d{3}/);
|
|
64
|
-
if (!matchedModelNumber) {
|
|
65
|
-
return false;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const modelNumber = parseInt(matchedModelNumber[0].match(/\d{3}/)[0], 10);
|
|
69
|
-
const smallerModelNumber = 970; // S10e
|
|
70
|
-
return !Number.isNaN(modelNumber) && modelNumber >= smallerModelNumber;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
static handleCameraError(e) {
|
|
74
|
-
switch (e.name) {
|
|
75
|
-
case 'NotAllowedError':
|
|
76
|
-
case 'SecurityError':
|
|
77
|
-
return `
|
|
78
|
-
Looks like camera access was not granted, or was blocked by a browser
|
|
79
|
-
level setting / extension. Please follow the prompt from the URL bar,
|
|
80
|
-
or extensions, and enable access.
|
|
81
|
-
You may need to refresh to start all over again
|
|
82
|
-
`;
|
|
83
|
-
case 'AbortError':
|
|
84
|
-
return `
|
|
85
|
-
Oops! Something happened, and we lost access to your stream.
|
|
86
|
-
Please refresh to start all over again
|
|
87
|
-
`;
|
|
88
|
-
case 'NotReadableError':
|
|
89
|
-
return `
|
|
90
|
-
There seems to be a problem with your device's camera, or its connection.
|
|
91
|
-
Please check this, and when resolved, try again. Or try another device.
|
|
92
|
-
`;
|
|
93
|
-
case 'NotFoundError':
|
|
94
|
-
return `
|
|
95
|
-
We are unable to find a video stream.
|
|
96
|
-
You may need to refresh to start all over again
|
|
97
|
-
`;
|
|
98
|
-
case 'TypeError':
|
|
99
|
-
return `
|
|
100
|
-
This site is insecure, and as such cannot have access to your camera.
|
|
101
|
-
Try to navigate to a secure version of this page, or contact the owner.
|
|
102
|
-
`;
|
|
103
|
-
default:
|
|
104
|
-
return e.message;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export default SmartCamera;
|
|
1
|
+
class SmartCamera {
|
|
2
|
+
static stream = null;
|
|
3
|
+
|
|
4
|
+
static async getMedia(constraints) {
|
|
5
|
+
SmartCamera.stream = await navigator.mediaDevices.getUserMedia(constraints);
|
|
6
|
+
return SmartCamera.stream;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
static environmentOptions = {
|
|
10
|
+
facingMode: 'environment',
|
|
11
|
+
height: {
|
|
12
|
+
ideal: 1080,
|
|
13
|
+
max: 1440,
|
|
14
|
+
min: 720,
|
|
15
|
+
},
|
|
16
|
+
width: {
|
|
17
|
+
ideal: 1920,
|
|
18
|
+
max: 2560,
|
|
19
|
+
min: 1280,
|
|
20
|
+
},
|
|
21
|
+
// NOTE: Special case for multi-camera Samsung devices (learnt from Acuant)
|
|
22
|
+
// "We found out that some triple camera Samsung devices (S10, S20, Note 20, etc) capture images blurry at edges.
|
|
23
|
+
// Zooming to 2X, matching the telephoto lens, doesn't solve it completely but mitigates it."
|
|
24
|
+
zoom: SmartCamera.isSamsungMultiCameraDevice() ? 2.0 : 1.0,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
static stopMedia() {
|
|
28
|
+
if (SmartCamera.stream) {
|
|
29
|
+
SmartCamera.stream.getTracks().forEach((track) => track.stop());
|
|
30
|
+
SmartCamera.stream = null;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
static async supportsAgentMode() {
|
|
35
|
+
try {
|
|
36
|
+
const devices = await navigator.mediaDevices.enumerateDevices();
|
|
37
|
+
const videoDevices = devices.filter(
|
|
38
|
+
(device) => device.kind === 'videoinput',
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
let hasBackCamera = false;
|
|
42
|
+
|
|
43
|
+
videoDevices.forEach((device) => {
|
|
44
|
+
// Check if the device label or device ID indicates a back camera
|
|
45
|
+
if (
|
|
46
|
+
device.label.toLowerCase().includes('back') ||
|
|
47
|
+
device.label.toLowerCase().includes('rear')
|
|
48
|
+
) {
|
|
49
|
+
hasBackCamera = true;
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
return false;
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
return hasBackCamera;
|
|
56
|
+
} catch (error) {
|
|
57
|
+
console.warn('Error accessing media devices: ', error);
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
static isSamsungMultiCameraDevice() {
|
|
63
|
+
const matchedModelNumber = navigator.userAgent.match(/SM-[N|G]\d{3}/);
|
|
64
|
+
if (!matchedModelNumber) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const modelNumber = parseInt(matchedModelNumber[0].match(/\d{3}/)[0], 10);
|
|
69
|
+
const smallerModelNumber = 970; // S10e
|
|
70
|
+
return !Number.isNaN(modelNumber) && modelNumber >= smallerModelNumber;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
static handleCameraError(e) {
|
|
74
|
+
switch (e.name) {
|
|
75
|
+
case 'NotAllowedError':
|
|
76
|
+
case 'SecurityError':
|
|
77
|
+
return `
|
|
78
|
+
Looks like camera access was not granted, or was blocked by a browser
|
|
79
|
+
level setting / extension. Please follow the prompt from the URL bar,
|
|
80
|
+
or extensions, and enable access.
|
|
81
|
+
You may need to refresh to start all over again
|
|
82
|
+
`;
|
|
83
|
+
case 'AbortError':
|
|
84
|
+
return `
|
|
85
|
+
Oops! Something happened, and we lost access to your stream.
|
|
86
|
+
Please refresh to start all over again
|
|
87
|
+
`;
|
|
88
|
+
case 'NotReadableError':
|
|
89
|
+
return `
|
|
90
|
+
There seems to be a problem with your device's camera, or its connection.
|
|
91
|
+
Please check this, and when resolved, try again. Or try another device.
|
|
92
|
+
`;
|
|
93
|
+
case 'NotFoundError':
|
|
94
|
+
return `
|
|
95
|
+
We are unable to find a video stream.
|
|
96
|
+
You may need to refresh to start all over again
|
|
97
|
+
`;
|
|
98
|
+
case 'TypeError':
|
|
99
|
+
return `
|
|
100
|
+
This site is insecure, and as such cannot have access to your camera.
|
|
101
|
+
Try to navigate to a secure version of this page, or contact the owner.
|
|
102
|
+
`;
|
|
103
|
+
default:
|
|
104
|
+
return e.message;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export default SmartCamera;
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The type of image submitted in the job request
|
|
3
|
-
* @readonly
|
|
4
|
-
* @enum {number}
|
|
5
|
-
*/
|
|
6
|
-
export const IMAGE_TYPE = {
|
|
7
|
-
/** ID_CARD_BACK_IMAGE_BASE64 Base64 encoded back of ID card image (.jpg or .png) */
|
|
8
|
-
ID_CARD_BACK_IMAGE_BASE64: 7,
|
|
9
|
-
/** ID_CARD_BACK_IMAGE_FILE Back of ID card image in .png or .jpg file format */
|
|
10
|
-
ID_CARD_BACK_IMAGE_FILE: 5,
|
|
11
|
-
/** ID_CARD_IMAGE_BASE64 Base64 encoded ID card image (.png or .jpg) */
|
|
12
|
-
ID_CARD_IMAGE_BASE64: 3,
|
|
13
|
-
/** ID_CARD_IMAGE_FILE ID card image in .png or .jpg file format */
|
|
14
|
-
ID_CARD_IMAGE_FILE: 1,
|
|
15
|
-
/** LIVENESS_IMAGE_BASE64 Base64 encoded liveness image (.jpg or .png) */
|
|
16
|
-
LIVENESS_IMAGE_BASE64: 6,
|
|
17
|
-
/** LIVENESS_IMAGE_FILE Liveness image in .png or .jpg file format */
|
|
18
|
-
LIVENESS_IMAGE_FILE: 4,
|
|
19
|
-
/** SELFIE_IMAGE_BASE64 Base64 encoded selfie image (.png or .jpg) */
|
|
20
|
-
SELFIE_IMAGE_BASE64: 2,
|
|
21
|
-
/** SELFIE_IMAGE_FILE Selfie image in .png or .jpg file format */
|
|
22
|
-
SELFIE_IMAGE_FILE: 0,
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export const DEFAULT_NO_OF_LIVENESS_FRAMES = 8;
|
|
26
|
-
export const PORTRAIT_ID_PREVIEW_WIDTH = 396;
|
|
27
|
-
export const PORTRAIT_ID_PREVIEW_HEIGHT = 527;
|
|
1
|
+
/**
|
|
2
|
+
* The type of image submitted in the job request
|
|
3
|
+
* @readonly
|
|
4
|
+
* @enum {number}
|
|
5
|
+
*/
|
|
6
|
+
export const IMAGE_TYPE = {
|
|
7
|
+
/** ID_CARD_BACK_IMAGE_BASE64 Base64 encoded back of ID card image (.jpg or .png) */
|
|
8
|
+
ID_CARD_BACK_IMAGE_BASE64: 7,
|
|
9
|
+
/** ID_CARD_BACK_IMAGE_FILE Back of ID card image in .png or .jpg file format */
|
|
10
|
+
ID_CARD_BACK_IMAGE_FILE: 5,
|
|
11
|
+
/** ID_CARD_IMAGE_BASE64 Base64 encoded ID card image (.png or .jpg) */
|
|
12
|
+
ID_CARD_IMAGE_BASE64: 3,
|
|
13
|
+
/** ID_CARD_IMAGE_FILE ID card image in .png or .jpg file format */
|
|
14
|
+
ID_CARD_IMAGE_FILE: 1,
|
|
15
|
+
/** LIVENESS_IMAGE_BASE64 Base64 encoded liveness image (.jpg or .png) */
|
|
16
|
+
LIVENESS_IMAGE_BASE64: 6,
|
|
17
|
+
/** LIVENESS_IMAGE_FILE Liveness image in .png or .jpg file format */
|
|
18
|
+
LIVENESS_IMAGE_FILE: 4,
|
|
19
|
+
/** SELFIE_IMAGE_BASE64 Base64 encoded selfie image (.png or .jpg) */
|
|
20
|
+
SELFIE_IMAGE_BASE64: 2,
|
|
21
|
+
/** SELFIE_IMAGE_FILE Selfie image in .png or .jpg file format */
|
|
22
|
+
SELFIE_IMAGE_FILE: 0,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const DEFAULT_NO_OF_LIVENESS_FRAMES = 8;
|
|
26
|
+
export const PORTRAIT_ID_PREVIEW_WIDTH = 396;
|
|
27
|
+
export const PORTRAIT_ID_PREVIEW_HEIGHT = 527;
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
# SmartFileUpload.js
|
|
2
|
-
|
|
3
|
-
This exports a class for dealing with file-uploads in SmileID's web components
|
|
4
|
-
|
|
5
|
-
## Usage
|
|
6
|
-
|
|
7
|
-
Suppose you have an file input field
|
|
8
|
-
|
|
9
|
-
```html
|
|
10
|
-
<input
|
|
11
|
-
type="file"
|
|
12
|
-
id="upload-photo"
|
|
13
|
-
name="document"
|
|
14
|
-
accept="image/png, image/jpeg"
|
|
15
|
-
/>
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
```javascript
|
|
19
|
-
// get the element
|
|
20
|
-
const uploadDocumentPhotoButton = document.getElementById('upload-photo');
|
|
21
|
-
// add a change event listener
|
|
22
|
-
uploadDocumentPhotoButton.addEventListener('change', async (event) => {
|
|
23
|
-
try {
|
|
24
|
-
const { files } = event.target;
|
|
25
|
-
|
|
26
|
-
// validate file, and convert file to data url
|
|
27
|
-
// returns the data url for the first file
|
|
28
|
-
const fileData = await SmartFileUpload.retrieve(files);
|
|
29
|
-
|
|
30
|
-
// use the data url
|
|
31
|
-
} catch (error) {
|
|
32
|
-
// handle error
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
```
|
|
1
|
+
# SmartFileUpload.js
|
|
2
|
+
|
|
3
|
+
This exports a class for dealing with file-uploads in SmileID's web components
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
Suppose you have an file input field
|
|
8
|
+
|
|
9
|
+
```html
|
|
10
|
+
<input
|
|
11
|
+
type="file"
|
|
12
|
+
id="upload-photo"
|
|
13
|
+
name="document"
|
|
14
|
+
accept="image/png, image/jpeg"
|
|
15
|
+
/>
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
```javascript
|
|
19
|
+
// get the element
|
|
20
|
+
const uploadDocumentPhotoButton = document.getElementById('upload-photo');
|
|
21
|
+
// add a change event listener
|
|
22
|
+
uploadDocumentPhotoButton.addEventListener('change', async (event) => {
|
|
23
|
+
try {
|
|
24
|
+
const { files } = event.target;
|
|
25
|
+
|
|
26
|
+
// validate file, and convert file to data url
|
|
27
|
+
// returns the data url for the first file
|
|
28
|
+
const fileData = await SmartFileUpload.retrieve(files);
|
|
29
|
+
|
|
30
|
+
// use the data url
|
|
31
|
+
} catch (error) {
|
|
32
|
+
// handle error
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
```
|
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
class SmartFileUpload {
|
|
2
|
-
static memoryLimit = 10240000;
|
|
3
|
-
|
|
4
|
-
static supportedTypes = ['image/jpeg', 'image/png'];
|
|
5
|
-
|
|
6
|
-
static getHumanSize(numberOfBytes) {
|
|
7
|
-
// Approximate to the closest prefixed unit
|
|
8
|
-
const units = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
|
9
|
-
const exponent = Math.min(
|
|
10
|
-
Math.floor(Math.log(numberOfBytes) / Math.log(1024)),
|
|
11
|
-
units.length - 1,
|
|
12
|
-
);
|
|
13
|
-
const approx = numberOfBytes / 1024 ** exponent;
|
|
14
|
-
const output =
|
|
15
|
-
exponent === 0
|
|
16
|
-
? `${numberOfBytes} bytes`
|
|
17
|
-
: `${approx.toFixed(0)} ${units[exponent]}`;
|
|
18
|
-
|
|
19
|
-
return output;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
static getData(file) {
|
|
23
|
-
return new Promise((resolve, reject) => {
|
|
24
|
-
const reader = new FileReader();
|
|
25
|
-
|
|
26
|
-
reader.onload = (e) => {
|
|
27
|
-
resolve(e.target.result);
|
|
28
|
-
};
|
|
29
|
-
reader.onerror = () => {
|
|
30
|
-
reject(
|
|
31
|
-
new Error(
|
|
32
|
-
'An error occurred reading the file. Please check the file, and try again',
|
|
33
|
-
),
|
|
34
|
-
);
|
|
35
|
-
};
|
|
36
|
-
reader.readAsDataURL(file);
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
static async retrieve(files) {
|
|
41
|
-
if (files.length > 1) {
|
|
42
|
-
throw new Error('Only one file upload is permitted at a time');
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const file = files[0];
|
|
46
|
-
|
|
47
|
-
if (!SmartFileUpload.supportedTypes.includes(file.type)) {
|
|
48
|
-
throw new Error(
|
|
49
|
-
'Unsupported file format. Please ensure that you are providing a JPG or PNG image',
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (file.size > SmartFileUpload.memoryLimit) {
|
|
54
|
-
throw new Error(
|
|
55
|
-
`${file.name} is too large. Please ensure that the file is less than ${SmartFileUpload.getHumanSize(SmartFileUpload.memoryLimit)}.`,
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const imageAsDataUrl = await SmartFileUpload.getData(file);
|
|
60
|
-
|
|
61
|
-
return imageAsDataUrl;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export default SmartFileUpload;
|
|
1
|
+
class SmartFileUpload {
|
|
2
|
+
static memoryLimit = 10240000;
|
|
3
|
+
|
|
4
|
+
static supportedTypes = ['image/jpeg', 'image/png'];
|
|
5
|
+
|
|
6
|
+
static getHumanSize(numberOfBytes) {
|
|
7
|
+
// Approximate to the closest prefixed unit
|
|
8
|
+
const units = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
|
9
|
+
const exponent = Math.min(
|
|
10
|
+
Math.floor(Math.log(numberOfBytes) / Math.log(1024)),
|
|
11
|
+
units.length - 1,
|
|
12
|
+
);
|
|
13
|
+
const approx = numberOfBytes / 1024 ** exponent;
|
|
14
|
+
const output =
|
|
15
|
+
exponent === 0
|
|
16
|
+
? `${numberOfBytes} bytes`
|
|
17
|
+
: `${approx.toFixed(0)} ${units[exponent]}`;
|
|
18
|
+
|
|
19
|
+
return output;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
static getData(file) {
|
|
23
|
+
return new Promise((resolve, reject) => {
|
|
24
|
+
const reader = new FileReader();
|
|
25
|
+
|
|
26
|
+
reader.onload = (e) => {
|
|
27
|
+
resolve(e.target.result);
|
|
28
|
+
};
|
|
29
|
+
reader.onerror = () => {
|
|
30
|
+
reject(
|
|
31
|
+
new Error(
|
|
32
|
+
'An error occurred reading the file. Please check the file, and try again',
|
|
33
|
+
),
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
reader.readAsDataURL(file);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static async retrieve(files) {
|
|
41
|
+
if (files.length > 1) {
|
|
42
|
+
throw new Error('Only one file upload is permitted at a time');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const file = files[0];
|
|
46
|
+
|
|
47
|
+
if (!SmartFileUpload.supportedTypes.includes(file.type)) {
|
|
48
|
+
throw new Error(
|
|
49
|
+
'Unsupported file format. Please ensure that you are providing a JPG or PNG image',
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (file.size > SmartFileUpload.memoryLimit) {
|
|
54
|
+
throw new Error(
|
|
55
|
+
`${file.name} is too large. Please ensure that the file is less than ${SmartFileUpload.getHumanSize(SmartFileUpload.memoryLimit)}.`,
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const imageAsDataUrl = await SmartFileUpload.getData(file);
|
|
60
|
+
|
|
61
|
+
return imageAsDataUrl;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export default SmartFileUpload;
|
package/lib/styles/README.md
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
# @smileid/styles
|
|
2
|
-
|
|
3
|
-
This is a package that contains global styles exported as a string to be used in composing CSS in Web Components and anywhere else
|
|
1
|
+
# @smileid/styles
|
|
2
|
+
|
|
3
|
+
This is a package that contains global styles exported as a string to be used in composing CSS in Web Components and anywhere else
|