rn-linkrunner 0.2.1 → 0.2.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/lib/commonjs/index.js
CHANGED
|
@@ -5,10 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _reactNativeDeviceInfo = _interopRequireDefault(require("react-native-device-info"));
|
|
8
|
+
var _reactNativeEncryptedStorage = _interopRequireDefault(require("react-native-encrypted-storage"));
|
|
8
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
-
|
|
10
|
-
const package_version = '0.2.1';
|
|
10
|
+
const package_version = '0.2.2';
|
|
11
11
|
const app_version = _reactNativeDeviceInfo.default.getVersion();
|
|
12
|
+
const EncryptedStorageTokenName = 'linkrunner-token';
|
|
12
13
|
const init = token => {
|
|
13
14
|
if (!token) return console.error('Linkrunner needs your project token to initialize!');
|
|
14
15
|
fetch('http://localhost:4000/api/client/init', {
|
|
@@ -22,21 +23,22 @@ const init = token => {
|
|
|
22
23
|
package_version,
|
|
23
24
|
app_version
|
|
24
25
|
})
|
|
25
|
-
}).then(res => res.json()).then(result => {
|
|
26
|
+
}).then(res => res.json()).then(async result => {
|
|
26
27
|
if (!result) throw new Error('No response obtained!');
|
|
27
28
|
if ((result === null || result === void 0 ? void 0 : result.status) !== 200 && (result === null || result === void 0 ? void 0 : result.status) !== 201) {
|
|
28
29
|
throw new Error(result === null || result === void 0 ? void 0 : result.msg);
|
|
29
30
|
}
|
|
30
|
-
|
|
31
|
+
await _reactNativeEncryptedStorage.default.setItem(EncryptedStorageTokenName, token);
|
|
31
32
|
console.log('Linkrunner initialised successfully 🔥');
|
|
32
33
|
}).catch(err => {
|
|
33
34
|
console.error('Error initializing linkrunner: ', err.message);
|
|
34
35
|
});
|
|
35
36
|
};
|
|
36
|
-
const trigger = ({
|
|
37
|
+
const trigger = async ({
|
|
37
38
|
data,
|
|
38
39
|
user_id
|
|
39
40
|
}) => {
|
|
41
|
+
const token = await _reactNativeEncryptedStorage.default.getItem(EncryptedStorageTokenName);
|
|
40
42
|
fetch('http://localhost:4000/api/client/trigger', {
|
|
41
43
|
method: 'POST',
|
|
42
44
|
headers: {
|
|
@@ -44,7 +46,7 @@ const trigger = ({
|
|
|
44
46
|
'Content-Type': 'application/json'
|
|
45
47
|
},
|
|
46
48
|
body: JSON.stringify({
|
|
47
|
-
token
|
|
49
|
+
token,
|
|
48
50
|
user_id,
|
|
49
51
|
data
|
|
50
52
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNativeDeviceInfo","_interopRequireDefault","require","obj","__esModule","default","
|
|
1
|
+
{"version":3,"names":["_reactNativeDeviceInfo","_interopRequireDefault","require","_reactNativeEncryptedStorage","obj","__esModule","default","package_version","app_version","DeviceInfo","getVersion","EncryptedStorageTokenName","init","token","console","error","fetch","method","headers","body","JSON","stringify","then","res","json","result","Error","status","msg","EncryptedStorage","setItem","log","catch","err","message","trigger","data","user_id","getItem","linkrunner","_default","exports"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;AAAA,IAAAA,sBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,4BAAA,GAAAF,sBAAA,CAAAC,OAAA;AAA8D,SAAAD,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAE9D,MAAMG,eAAe,GAAG,OAAO;AAC/B,MAAMC,WAAW,GAAGC,8BAAU,CAACC,UAAU,CAAC,CAAC;AAC3C,MAAMC,yBAAyB,GAAG,kBAAkB;AAEpD,MAAMC,IAAI,GAAIC,KAAa,IAAK;EAC9B,IAAI,CAACA,KAAK,EACR,OAAOC,OAAO,CAACC,KAAK,CAAC,oDAAoD,CAAC;EAE5EC,KAAK,CAAC,uCAAuC,EAAE;IAC7CC,MAA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O;MACPD;IACF,CAAC;EACH,CAAC,CAAC,CACCd,IAAI,CAAEC,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC,CAAC,CAAC,CACzBF,IAAI,CAAEG,MAAM,IAAK;IAChB,IAAI,CAACA,MAAM,EAAE,MAAM,IAAIC,KAAK,CAAC,uBAAuB,CAAC;IAErD,IAAI,CAAAD,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEE,MAAM,MAAK,GAAG,IAAI,CAAAF,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEE,MAAM,MAAK,GAAG,EAAE;MACpD,MAAM,IAAID,KAAK,CAACD,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEG,GAAG,CAAC;IAC9B;IAEAd,OAAO,CAACiB,GAAG,CAAC,+BAA+B,CAAC;EAC9C,CAAC,CAAC,CACDC,KAAK,CAAEC,GAAG,IAAK;IACdnB,OAAO,CAACC,KAAK,CAAC,iCAAiC,EAAEkB,GAAG,CAACC,OAAO,CAAC;EAC/D,CAAC,CAAC;AACN,CAAC;AAED,MAAMK,UAAU,GAAG;EACjB3B,IAAI;EACJuB;AACF,CAAC;AAAC,IAAAK,QAAA,GAAAC,OAAA,CAAAnC,OAAA,GAEaiC,UAAU"}
|
package/lib/module/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import DeviceInfo from 'react-native-device-info';
|
|
2
|
-
|
|
3
|
-
const package_version = '0.2.
|
|
2
|
+
import EncryptedStorage from 'react-native-encrypted-storage';
|
|
3
|
+
const package_version = '0.2.2';
|
|
4
4
|
const app_version = DeviceInfo.getVersion();
|
|
5
|
+
const EncryptedStorageTokenName = 'linkrunner-token';
|
|
5
6
|
const init = token => {
|
|
6
7
|
if (!token) return console.error('Linkrunner needs your project token to initialize!');
|
|
7
8
|
fetch('http://localhost:4000/api/client/init', {
|
|
@@ -15,21 +16,22 @@ const init = token => {
|
|
|
15
16
|
package_version,
|
|
16
17
|
app_version
|
|
17
18
|
})
|
|
18
|
-
}).then(res => res.json()).then(result => {
|
|
19
|
+
}).then(res => res.json()).then(async result => {
|
|
19
20
|
if (!result) throw new Error('No response obtained!');
|
|
20
21
|
if ((result === null || result === void 0 ? void 0 : result.status) !== 200 && (result === null || result === void 0 ? void 0 : result.status) !== 201) {
|
|
21
22
|
throw new Error(result === null || result === void 0 ? void 0 : result.msg);
|
|
22
23
|
}
|
|
23
|
-
|
|
24
|
+
await EncryptedStorage.setItem(EncryptedStorageTokenName, token);
|
|
24
25
|
console.log('Linkrunner initialised successfully 🔥');
|
|
25
26
|
}).catch(err => {
|
|
26
27
|
console.error('Error initializing linkrunner: ', err.message);
|
|
27
28
|
});
|
|
28
29
|
};
|
|
29
|
-
const trigger = ({
|
|
30
|
+
const trigger = async ({
|
|
30
31
|
data,
|
|
31
32
|
user_id
|
|
32
33
|
}) => {
|
|
34
|
+
const token = await EncryptedStorage.getItem(EncryptedStorageTokenName);
|
|
33
35
|
fetch('http://localhost:4000/api/client/trigger', {
|
|
34
36
|
method: 'POST',
|
|
35
37
|
headers: {
|
|
@@ -37,7 +39,7 @@ const trigger = ({
|
|
|
37
39
|
'Content-Type': 'application/json'
|
|
38
40
|
},
|
|
39
41
|
body: JSON.stringify({
|
|
40
|
-
token
|
|
42
|
+
token,
|
|
41
43
|
user_id,
|
|
42
44
|
data
|
|
43
45
|
})
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["DeviceInfo","
|
|
1
|
+
{"version":3,"names":["DeviceInfo","EncryptedStorage","package_version","app_version","getVersion","EncryptedStorageTokenName","init","token","console","error","fetch","method","headers","body","JSON","stringify","then","res","json","result","Error","status","msg","setItem","log","catch","err","message","trigger","data","user_id","getItem","linkrunner"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,OAAOA,UAAU,MAAM,0BAA0B;AACjD,OAAOC,gBAAgB,MAAM,gCAAgC;AAE7D,MAAMC,eAAe,GAAG,OAAO;AAC/B,MAAMC,WAA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B,CAAC8B,OAAO,CAAC1B,yBAAyB,CAAC;EAEvEK,KAAK,CAAC,0CAA0C,EAAE;IAChDC,MAAM,EAAE,MAAM;IACdC,OAAO,EAAE;MACP,QAAQ,EAAE,kBAAkB;MAC5B,cAAc,EAAE;IAClB,CAAC;IACDC,IAAI,EAAEC,IAAI,CAACC,SAAS,CAAC;MACnBR,KAAK;MACLuB,OAAO;MACPD;IACF,CAAC;EACH,CAAC,CAAC,CACCb,IAAI,CAAEC,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC,CAAC,CAAC,CACzBF,IAAI,CAAEG,MAAM,IAAK;IAChB,IAAI,CAACA,MAAM,EAAE,MAAM,IAAIC,KAAK,CAAC,uBAAuB,CAAC;IAErD,IAAI,CAAAD,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEE,MAAM,MAAK,GAAG,IAAI,CAAAF,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEE,MAAM,MAAK,GAAG,EAAE;MACpD,MAAM,IAAID,KAAK,CAACD,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEG,GAAG,CAAC;IAC9B;IAEAd,OAAO,CAACgB,GAAG,CAAC,+BAA+B,CAAC;EAC9C,CAAC,CAAC,CACDC,KAAK,CAAEC,GAAG,IAAK;IACdlB,OAAO,CAACC,KAAK,CAAC,iCAAiC,EAAEiB,GAAG,CAACC,OAAO,CAAC;EAC/D,CAAC,CAAC;AACN,CAAC;AAED,MAAMK,UAAU,GAAG;EACjB1B,IAAI;EACJsB;AACF,CAAC;AAED,eAAeI,UAAU"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AA2EA,QAAA,MAAM,UAAU;kBApEK,MAAM;;iBAoChB,MAAM,GAAG,MAAM;cAClB,GAAG;;CAkCV,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rn-linkrunner",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "React Native Package for linkrunner",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -138,6 +138,7 @@
|
|
|
138
138
|
]
|
|
139
139
|
},
|
|
140
140
|
"dependencies": {
|
|
141
|
-
"react-native-device-info": "^10.12.0"
|
|
141
|
+
"react-native-device-info": "^10.12.0",
|
|
142
|
+
"react-native-encrypted-storage": "^4.0.3"
|
|
142
143
|
}
|
|
143
144
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import DeviceInfo from 'react-native-device-info';
|
|
2
|
+
import EncryptedStorage from 'react-native-encrypted-storage';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const package_version = '0.2.1';
|
|
4
|
+
const package_version = '0.2.2';
|
|
6
5
|
const app_version = DeviceInfo.getVersion();
|
|
6
|
+
const EncryptedStorageTokenName = 'linkrunner-token';
|
|
7
7
|
|
|
8
8
|
const init = (token: string) => {
|
|
9
9
|
if (!token)
|
|
@@ -22,14 +22,14 @@ const init = (token: string) => {
|
|
|
22
22
|
}),
|
|
23
23
|
})
|
|
24
24
|
.then((res) => res.json())
|
|
25
|
-
.then((result) => {
|
|
25
|
+
.then(async (result) => {
|
|
26
26
|
if (!result) throw new Error('No response obtained!');
|
|
27
27
|
|
|
28
28
|
if (result?.status !== 200 && result?.status !== 201) {
|
|
29
29
|
throw new Error(result?.msg);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
await EncryptedStorage.setItem(EncryptedStorageTokenName, token);
|
|
33
33
|
console.log('Linkrunner initialised successfully 🔥');
|
|
34
34
|
})
|
|
35
35
|
.catch((err) => {
|
|
@@ -37,13 +37,15 @@ const init = (token: string) => {
|
|
|
37
37
|
});
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
const trigger = ({
|
|
40
|
+
const trigger = async ({
|
|
41
41
|
data,
|
|
42
42
|
user_id,
|
|
43
43
|
}: {
|
|
44
44
|
user_id: string | number;
|
|
45
45
|
data: any;
|
|
46
46
|
}) => {
|
|
47
|
+
const token = await EncryptedStorage.getItem(EncryptedStorageTokenName);
|
|
48
|
+
|
|
47
49
|
fetch('http://localhost:4000/api/client/trigger', {
|
|
48
50
|
method: 'POST',
|
|
49
51
|
headers: {
|
|
@@ -51,7 +53,7 @@ const trigger = ({
|
|
|
51
53
|
'Content-Type': 'application/json',
|
|
52
54
|
},
|
|
53
55
|
body: JSON.stringify({
|
|
54
|
-
token
|
|
56
|
+
token,
|
|
55
57
|
user_id,
|
|
56
58
|
data,
|
|
57
59
|
}),
|