veryfi-lens-wasm 1.0.6 → 1.0.8
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 +76 -19
- package/index.d.ts +7 -7
- package/package.json +1 -1
- package/src/{opencv.js → wasm/opencv.js} +10324 -45
- package/src/wasm/wasm.js +4 -59
- package/veryfi-lens.js +4 -1
package/README.md
CHANGED
|
@@ -1,24 +1,81 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
|
|
2
|
+
***You can skip first step and copy wasm folder from package directory manually if you want to do so*.**
|
|
3
|
+
1. run `npm exec veryfi-lens-wasm-setup` and provide it with path to directory where you will serve wasm files, **they have to be accessible from your project's entry point with relative paths**
|
|
4
|
+
(for next.js `public/wasm`)
|
|
5
|
+
2. Import package `import VeryfiLens from 'veryfi-lens-wasm'`
|
|
6
|
+
3. Add id='veryfi-container' to container you want lens to appear
|
|
7
|
+
4. Add id='blur-detector' to edit screen if you want to use it's logic
|
|
8
|
+
5. Create function
|
|
6
9
|
```
|
|
7
10
|
const startLens = async () => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
veryfiLens.setUserAgent(navigator.userAgent); // if package loads before navigator
|
|
12
|
+
veryfiLens.init(sessionToken);
|
|
13
|
+
veryfiLens.startCamera();
|
|
14
|
+
intervalRef = window.setInterval(() => {
|
|
15
|
+
setSocketStatusColor(veryfiLens.getSocketStatusColor());
|
|
16
|
+
}, INTERVAL);
|
|
17
|
+
};
|
|
15
18
|
```
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
7. Call it
|
|
20
|
+
8. Use the following function on capture button
|
|
18
21
|
```
|
|
19
22
|
const takePhoto = () => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
veryfiLens.capture(setImage, setIsEditing);
|
|
24
|
+
// setImage is cropped image setter(for example react's useState hook), returns string
|
|
25
|
+
// setIsEditing returns `true` if image was succesfully cropped (we use it to change screens)
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
To use wasm in dev environment, you have to use https and ssl
|
|
31
|
+
And also add following to next.config.js:
|
|
32
|
+
```
|
|
33
|
+
async headers() {
|
|
34
|
+
return [
|
|
35
|
+
{
|
|
36
|
+
source: '/(.*)',
|
|
37
|
+
headers: [
|
|
38
|
+
{
|
|
39
|
+
key: 'Cross-Origin-Opener-Policy',
|
|
40
|
+
value: 'same-origin'
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
key: 'Cross-Origin-Embedder-Policy',
|
|
44
|
+
value: 'require-corp'
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
experimental: {
|
|
51
|
+
urlImports: ["https://unpkg.com/wasm-feature-detect/dist/umd/index.js"],
|
|
52
|
+
},
|
|
53
|
+
webpack: (config) => {
|
|
54
|
+
config.resolve.fallback = { fs: false, path:false, "crypto": false };
|
|
55
|
+
return config;
|
|
56
|
+
},
|
|
57
|
+
```
|
|
58
|
+
This to vite.config.js (if using vite and vue)
|
|
59
|
+
```
|
|
60
|
+
server: {
|
|
61
|
+
https: {
|
|
62
|
+
key: fs.readFileSync(path.resolve(__dirname, 'localhost-key.pem')), //path to your local serificate
|
|
63
|
+
cert: fs.readFileSync(path.resolve(__dirname, 'localhost.pem')),},
|
|
64
|
+
proxy: {},
|
|
65
|
+
hmr: {
|
|
66
|
+
protocol: 'wss',
|
|
67
|
+
timeout: 30000,
|
|
68
|
+
},
|
|
69
|
+
watch: {},
|
|
70
|
+
open: true,
|
|
71
|
+
host: true,
|
|
72
|
+
strictPort: false,
|
|
73
|
+
force: false,
|
|
74
|
+
cors: true,
|
|
75
|
+
headers: {
|
|
76
|
+
'Cross-Origin-Opener-Policy': 'same-origin',
|
|
77
|
+
'Cross-Origin-Embedder-Policy': 'require-corp',
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
package/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
declare module 'veryfi-lens-
|
|
2
|
-
declare module 'veryfi-lens-
|
|
3
|
-
declare module 'veryfi-lens-
|
|
4
|
-
declare module 'veryfi-lens-
|
|
5
|
-
declare module 'veryfy-lens-
|
|
6
|
-
declare module 'veryfy-lens-
|
|
7
|
-
declare module 'veryfy-lens-
|
|
1
|
+
declare module 'veryfi-lens-wasm'
|
|
2
|
+
declare module 'veryfi-lens-wasm/veryfi-lens'
|
|
3
|
+
declare module 'veryfi-lens-wasm/device-uuid'
|
|
4
|
+
declare module 'veryfi-lens-wasm/fingerprint-id'
|
|
5
|
+
declare module 'veryfy-lens-wasm/blur-detector'
|
|
6
|
+
declare module 'veryfy-lens-wasm/lens-wasm'
|
|
7
|
+
declare module 'veryfy-lens-wasm/opencv'
|