@reactoo/watchtogether-sdk-js 2.5.51 → 2.5.55
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/dist/watchtogether-sdk.js +21 -9
- package/dist/watchtogether-sdk.min.js +2 -2
- package/example/index.html +1 -1
- package/package.json +2 -1
- package/src/models/auth.js +2 -2
- package/src/modules/wt-utils.js +32 -12
package/example/index.html
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reactoo/watchtogether-sdk-js",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.55",
|
|
4
4
|
"description": "Javascript SDK for Reactoo",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"unpkg": "dist/watchtogether-sdk.min.js",
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@fingerprintjs/fingerprintjs": "^3.3.2",
|
|
46
|
+
"@fingerprintjs/fingerprintjs-pro": "^3.7.0",
|
|
46
47
|
"aws-iot-device-sdk": "^2.2.11",
|
|
47
48
|
"serialize-error": "9.1.0",
|
|
48
49
|
"swagger-client": "^3.18.0",
|
package/src/models/auth.js
CHANGED
|
@@ -33,8 +33,8 @@ let auth = function () {
|
|
|
33
33
|
return this.__privates.providerAuth;
|
|
34
34
|
},
|
|
35
35
|
|
|
36
|
-
deviceLogin: (salt) => {
|
|
37
|
-
return getBrowserFingerprint(this.__instanceType, salt)
|
|
36
|
+
deviceLogin: ( usePrecise = false, salt = 'ThisIsSaltyAF') => {
|
|
37
|
+
return getBrowserFingerprint(this.__instanceType, usePrecise, salt)
|
|
38
38
|
.then( deviceId => Promise.all([deviceId, this.__privates.auth.__client]))
|
|
39
39
|
.then(([deviceId, client]) => client.apis.auth.deviceSignIn({},{requestBody:{deviceId, domain: location.hostname}}))
|
|
40
40
|
.then(response => {
|
package/src/modules/wt-utils.js
CHANGED
|
@@ -1,21 +1,41 @@
|
|
|
1
1
|
import FingerprintJs from "@fingerprintjs/fingerprintjs";
|
|
2
|
+
import FingerprintJsPro from "@fingerprintjs/fingerprintjs-pro";
|
|
2
3
|
|
|
3
4
|
let wait = function(ms) { return new Promise(resolve => setTimeout(resolve, ms))};
|
|
4
5
|
let fingerprint = FingerprintJs.load({
|
|
5
6
|
monitoring: false
|
|
6
7
|
})
|
|
7
|
-
let
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
8
|
+
let fingerprintPro = FingerprintJsPro.load({
|
|
9
|
+
monitoring: false,
|
|
10
|
+
apiKey: '5UHdpSuX3wHr3CjyEiSP',
|
|
11
|
+
endpoint: "https://fingerprint.reactoo.com"
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
let getBrowserFingerprint = function (instanceType = '', usePrecise = false, salt = '') {
|
|
15
|
+
|
|
16
|
+
if(!usePrecise) {
|
|
17
|
+
return fingerprint
|
|
18
|
+
.then(fp => fp.get())
|
|
19
|
+
.then(result => {
|
|
20
|
+
const components = {
|
|
21
|
+
...result.components,
|
|
22
|
+
instanceType: { value: instanceType + '_' + salt },
|
|
23
|
+
}
|
|
24
|
+
return [8,13,18,23].reduce((acc, cur) => {
|
|
25
|
+
return acc.slice(0,cur) + '-' + acc.slice(cur)
|
|
26
|
+
}, FingerprintJs.hashComponents(components)).substring(0,36)
|
|
27
|
+
})
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
return fingerprintPro
|
|
31
|
+
.then(fp => fp.get())
|
|
32
|
+
.then(result => {
|
|
33
|
+
let id = result.visitorId.padEnd(32, '0');
|
|
34
|
+
return [8,13,18,23].reduce((acc, cur) => {
|
|
35
|
+
return acc.slice(0,cur) + '-' + acc.slice(cur)
|
|
36
|
+
}, id).substring(0,36)
|
|
37
|
+
})
|
|
38
|
+
}
|
|
19
39
|
};
|
|
20
40
|
|
|
21
41
|
let generateUUID = function () {
|