@reactoo/watchtogether-sdk-js 2.5.89 → 2.5.90

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reactoo/watchtogether-sdk-js",
3
- "version": "2.5.89",
3
+ "version": "2.5.90",
4
4
  "description": "Javascript SDK for Reactoo",
5
5
  "main": "src/index.js",
6
6
  "unpkg": "dist/watchtogether-sdk.min.js",
@@ -43,7 +43,7 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@fingerprintjs/fingerprintjs": "^3.3.2",
46
- "@fingerprintjs/fingerprintjs-pro": "^3.7.0",
46
+ "@fingerprintjs/fingerprintjs-pro": "^3.8.1",
47
47
  "aws-iot-device-sdk": "^2.2.11",
48
48
  "serialize-error": "9.1.0",
49
49
  "swagger-client": "^3.18.0",
@@ -2,39 +2,53 @@ import FingerprintJs from "@fingerprintjs/fingerprintjs";
2
2
  import FingerprintJsPro from "@fingerprintjs/fingerprintjs-pro";
3
3
 
4
4
  let wait = function(ms) { return new Promise(resolve => setTimeout(resolve, ms))};
5
- let fingerprint = FingerprintJs.load({
6
- monitoring: false
7
- })
8
- let fingerprintPro = FingerprintJsPro.load({
9
- monitoring: false,
10
- apiKey: '5UHdpSuX3wHr3CjyEiSP',
11
- endpoint: "https://fingerprint.reactoo.com"
12
- })
13
5
 
14
- let getBrowserFingerprint = function (instanceType = '', usePrecise = false, salt = '') {
15
6
 
7
+ const getFingerPrint = function(instanceType, salt) {
8
+
9
+ let fingerprint = FingerprintJs.load({
10
+ monitoring: false
11
+ })
12
+
13
+ return fingerprint
14
+ .then(fp => fp.get())
15
+ .then(result => {
16
+ const components = {
17
+ ...result.components,
18
+ instanceType: { value: instanceType + '_' + salt },
19
+ }
20
+ return [8,13,18,23].reduce((acc, cur) => {
21
+ return acc.slice(0,cur) + '-' + acc.slice(cur)
22
+ }, FingerprintJs.hashComponents(components)).substring(0,36)
23
+ })
24
+ }
25
+
26
+ const getPreciseFingerPrint = function() {
27
+
28
+ let fingerprintPro = FingerprintJsPro.load({
29
+ monitoring: false,
30
+ apiKey: '5UHdpSuX3wHr3CjyEiSP',
31
+ endpoint: "https://fingerprint.reactoo.com"
32
+ })
33
+
34
+ return fingerprintPro
35
+ .then(fp => fp.get())
36
+ .then(result => {
37
+ let id = result.visitorId.padEnd(32, '0');
38
+ return [8,13,18,23].reduce((acc, cur) => {
39
+ return acc.slice(0,cur) + '-' + acc.slice(cur)
40
+ }, id).substring(0,36)
41
+ })
42
+ }
43
+
44
+
45
+ let getBrowserFingerprint = function (instanceType = '', usePrecise = false, salt = '') {
16
46
  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
- })
47
+ return getFingerPrint(instanceType, salt)
28
48
  }
29
49
  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
- })
50
+ return getPreciseFingerPrint()
51
+ .catch(() => getFingerPrint(instanceType, salt))
38
52
  }
39
53
  };
40
54