rn-linkrunner 0.2.0 → 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 +31 -15
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +31 -12
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/index.d.ts +4 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/package.json +4 -3
- package/src/index.ts +40 -14
package/lib/commonjs/index.js
CHANGED
|
@@ -5,17 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _reactNativeDeviceInfo = _interopRequireDefault(require("react-native-device-info"));
|
|
8
|
-
var
|
|
9
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
10
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
8
|
+
var _reactNativeEncryptedStorage = _interopRequireDefault(require("react-native-encrypted-storage"));
|
|
11
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
const package_version = '0.2.2';
|
|
11
|
+
const app_version = _reactNativeDeviceInfo.default.getVersion();
|
|
12
|
+
const EncryptedStorageTokenName = 'linkrunner-token';
|
|
15
13
|
const init = token => {
|
|
16
14
|
if (!token) return console.error('Linkrunner needs your project token to initialize!');
|
|
17
|
-
const package_version = packageJson === null || packageJson === void 0 ? void 0 : packageJson.version;
|
|
18
|
-
const app_version = _reactNativeDeviceInfo.default.getVersion();
|
|
19
15
|
fetch('http://localhost:4000/api/client/init', {
|
|
20
16
|
method: 'POST',
|
|
21
17
|
headers: {
|
|
@@ -27,26 +23,46 @@ const init = token => {
|
|
|
27
23
|
package_version,
|
|
28
24
|
app_version
|
|
29
25
|
})
|
|
30
|
-
}).then(res => res.json()).then(result => {
|
|
26
|
+
}).then(res => res.json()).then(async result => {
|
|
31
27
|
if (!result) throw new Error('No response obtained!');
|
|
32
28
|
if ((result === null || result === void 0 ? void 0 : result.status) !== 200 && (result === null || result === void 0 ? void 0 : result.status) !== 201) {
|
|
33
29
|
throw new Error(result === null || result === void 0 ? void 0 : result.msg);
|
|
34
30
|
}
|
|
35
|
-
|
|
31
|
+
await _reactNativeEncryptedStorage.default.setItem(EncryptedStorageTokenName, token);
|
|
36
32
|
console.log('Linkrunner initialised successfully 🔥');
|
|
37
33
|
}).catch(err => {
|
|
38
34
|
console.error('Error initializing linkrunner: ', err.message);
|
|
39
35
|
});
|
|
40
36
|
};
|
|
41
|
-
const trigger = (
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
37
|
+
const trigger = async ({
|
|
38
|
+
data,
|
|
39
|
+
user_id
|
|
40
|
+
}) => {
|
|
41
|
+
const token = await _reactNativeEncryptedStorage.default.getItem(EncryptedStorageTokenName);
|
|
42
|
+
fetch('http://localhost:4000/api/client/trigger', {
|
|
43
|
+
method: 'POST',
|
|
44
|
+
headers: {
|
|
45
|
+
'Accept': 'application/json',
|
|
46
|
+
'Content-Type': 'application/json'
|
|
47
|
+
},
|
|
48
|
+
body: JSON.stringify({
|
|
49
|
+
token,
|
|
50
|
+
user_id,
|
|
51
|
+
data
|
|
52
|
+
})
|
|
53
|
+
}).then(res => res.json()).then(result => {
|
|
54
|
+
if (!result) throw new Error('No response obtained!');
|
|
55
|
+
if ((result === null || result === void 0 ? void 0 : result.status) !== 200 && (result === null || result === void 0 ? void 0 : result.status) !== 201) {
|
|
56
|
+
throw new Error(result === null || result === void 0 ? void 0 : result.msg);
|
|
57
|
+
}
|
|
58
|
+
console.log('Linkrunner: Trigger called 🔥');
|
|
59
|
+
}).catch(err => {
|
|
60
|
+
console.error('Error initializing linkrunner: ', err.message);
|
|
61
|
+
});
|
|
45
62
|
};
|
|
46
63
|
const linkrunner = {
|
|
47
64
|
init,
|
|
48
65
|
trigger
|
|
49
66
|
};
|
|
50
67
|
var _default = exports.default = linkrunner;
|
|
51
|
-
linkrunner.init('FEhvnvlyBgJBTtrATPBpkkRMqtLcKWOs');
|
|
52
68
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNativeDeviceInfo","_interopRequireDefault","require","
|
|
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,OA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AAc,EAAE;IAClB,CAAC;IACDC,IAAI,EAAEC,IAAI,CAACC,SAAS,CAAC;MACnBR,KAAK;MACLwB,OAAO;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,11 +1,10 @@
|
|
|
1
1
|
import DeviceInfo from 'react-native-device-info';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import EncryptedStorage from 'react-native-encrypted-storage';
|
|
3
|
+
const package_version = '0.2.2';
|
|
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
|
-
const package_version = packageJson === null || packageJson === void 0 ? void 0 : packageJson.version;
|
|
8
|
-
const app_version = DeviceInfo.getVersion();
|
|
9
8
|
fetch('http://localhost:4000/api/client/init', {
|
|
10
9
|
method: 'POST',
|
|
11
10
|
headers: {
|
|
@@ -17,26 +16,46 @@ const init = token => {
|
|
|
17
16
|
package_version,
|
|
18
17
|
app_version
|
|
19
18
|
})
|
|
20
|
-
}).then(res => res.json()).then(result => {
|
|
19
|
+
}).then(res => res.json()).then(async result => {
|
|
21
20
|
if (!result) throw new Error('No response obtained!');
|
|
22
21
|
if ((result === null || result === void 0 ? void 0 : result.status) !== 200 && (result === null || result === void 0 ? void 0 : result.status) !== 201) {
|
|
23
22
|
throw new Error(result === null || result === void 0 ? void 0 : result.msg);
|
|
24
23
|
}
|
|
25
|
-
|
|
24
|
+
await EncryptedStorage.setItem(EncryptedStorageTokenName, token);
|
|
26
25
|
console.log('Linkrunner initialised successfully 🔥');
|
|
27
26
|
}).catch(err => {
|
|
28
27
|
console.error('Error initializing linkrunner: ', err.message);
|
|
29
28
|
});
|
|
30
29
|
};
|
|
31
|
-
const trigger = (
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
const trigger = async ({
|
|
31
|
+
data,
|
|
32
|
+
user_id
|
|
33
|
+
}) => {
|
|
34
|
+
const token = await EncryptedStorage.getItem(EncryptedStorageTokenName);
|
|
35
|
+
fetch('http://localhost:4000/api/client/trigger', {
|
|
36
|
+
method: 'POST',
|
|
37
|
+
headers: {
|
|
38
|
+
'Accept': 'application/json',
|
|
39
|
+
'Content-Type': 'application/json'
|
|
40
|
+
},
|
|
41
|
+
body: JSON.stringify({
|
|
42
|
+
token,
|
|
43
|
+
user_id,
|
|
44
|
+
data
|
|
45
|
+
})
|
|
46
|
+
}).then(res => res.json()).then(result => {
|
|
47
|
+
if (!result) throw new Error('No response obtained!');
|
|
48
|
+
if ((result === null || result === void 0 ? void 0 : result.status) !== 200 && (result === null || result === void 0 ? void 0 : result.status) !== 201) {
|
|
49
|
+
throw new Error(result === null || result === void 0 ? void 0 : result.msg);
|
|
50
|
+
}
|
|
51
|
+
console.log('Linkrunner: Trigger called 🔥');
|
|
52
|
+
}).catch(err => {
|
|
53
|
+
console.error('Error initializing linkrunner: ', err.message);
|
|
54
|
+
});
|
|
35
55
|
};
|
|
36
56
|
const linkrunner = {
|
|
37
57
|
init,
|
|
38
58
|
trigger
|
|
39
59
|
};
|
|
40
60
|
export default linkrunner;
|
|
41
|
-
linkrunner.init('FEhvnvlyBgJBTtrATPBpkkRMqtLcKWOs');
|
|
42
61
|
//# sourceMappingURL=index.js.map
|
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,WAAW,GAAGH,UAAU,CAACI,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,MAAM,EAAE,MAAM;IACdC,OAAO,EAAE;MACP,QAAQ,EAAE,kBAAkB;MAC5B,cAAc,EAAE;IAClB,CAAC;IACDC,IAAI,EAAEC,IAAI,CAACC,SAAS,CAAC;MACnBR,KAAK;MACLL,eAAe;MACfC;IACF,CAAC;EACH,CAAC,CAAC,CACCa,IAAI,CAAEC,GAAG,IAAKA,GAAG,CAACC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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,10 +1,10 @@
|
|
|
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",
|
|
7
|
-
"types": "lib/typescript/
|
|
7
|
+
"types": "lib/typescript/index.d.ts",
|
|
8
8
|
"react-native": "src/index",
|
|
9
9
|
"source": "src/index",
|
|
10
10
|
"files": [
|
|
@@ -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,16 +1,14 @@
|
|
|
1
1
|
import DeviceInfo from 'react-native-device-info';
|
|
2
|
-
|
|
3
|
-
import * as packageJson from '../../package.json';
|
|
2
|
+
import EncryptedStorage from 'react-native-encrypted-storage';
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
const package_version = '0.2.2';
|
|
5
|
+
const app_version = DeviceInfo.getVersion();
|
|
6
|
+
const EncryptedStorageTokenName = 'linkrunner-token';
|
|
6
7
|
|
|
7
8
|
const init = (token: string) => {
|
|
8
9
|
if (!token)
|
|
9
10
|
return console.error('Linkrunner needs your project token to initialize!');
|
|
10
11
|
|
|
11
|
-
const package_version = packageJson?.version;
|
|
12
|
-
const app_version = DeviceInfo.getVersion();
|
|
13
|
-
|
|
14
12
|
fetch('http://localhost:4000/api/client/init', {
|
|
15
13
|
method: 'POST',
|
|
16
14
|
headers: {
|
|
@@ -24,14 +22,14 @@ const init = (token: string) => {
|
|
|
24
22
|
}),
|
|
25
23
|
})
|
|
26
24
|
.then((res) => res.json())
|
|
27
|
-
.then((result) => {
|
|
25
|
+
.then(async (result) => {
|
|
28
26
|
if (!result) throw new Error('No response obtained!');
|
|
29
27
|
|
|
30
28
|
if (result?.status !== 200 && result?.status !== 201) {
|
|
31
29
|
throw new Error(result?.msg);
|
|
32
30
|
}
|
|
33
31
|
|
|
34
|
-
|
|
32
|
+
await EncryptedStorage.setItem(EncryptedStorageTokenName, token);
|
|
35
33
|
console.log('Linkrunner initialised successfully 🔥');
|
|
36
34
|
})
|
|
37
35
|
.catch((err) => {
|
|
@@ -39,10 +37,40 @@ const init = (token: string) => {
|
|
|
39
37
|
});
|
|
40
38
|
};
|
|
41
39
|
|
|
42
|
-
const trigger = (
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
const trigger = async ({
|
|
41
|
+
data,
|
|
42
|
+
user_id,
|
|
43
|
+
}: {
|
|
44
|
+
user_id: string | number;
|
|
45
|
+
data: any;
|
|
46
|
+
}) => {
|
|
47
|
+
const token = await EncryptedStorage.getItem(EncryptedStorageTokenName);
|
|
48
|
+
|
|
49
|
+
fetch('http://localhost:4000/api/client/trigger', {
|
|
50
|
+
method: 'POST',
|
|
51
|
+
headers: {
|
|
52
|
+
'Accept': 'application/json',
|
|
53
|
+
'Content-Type': 'application/json',
|
|
54
|
+
},
|
|
55
|
+
body: JSON.stringify({
|
|
56
|
+
token,
|
|
57
|
+
user_id,
|
|
58
|
+
data,
|
|
59
|
+
}),
|
|
60
|
+
})
|
|
61
|
+
.then((res) => res.json())
|
|
62
|
+
.then((result) => {
|
|
63
|
+
if (!result) throw new Error('No response obtained!');
|
|
64
|
+
|
|
65
|
+
if (result?.status !== 200 && result?.status !== 201) {
|
|
66
|
+
throw new Error(result?.msg);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
console.log('Linkrunner: Trigger called 🔥');
|
|
70
|
+
})
|
|
71
|
+
.catch((err) => {
|
|
72
|
+
console.error('Error initializing linkrunner: ', err.message);
|
|
73
|
+
});
|
|
46
74
|
};
|
|
47
75
|
|
|
48
76
|
const linkrunner = {
|
|
@@ -51,5 +79,3 @@ const linkrunner = {
|
|
|
51
79
|
};
|
|
52
80
|
|
|
53
81
|
export default linkrunner;
|
|
54
|
-
|
|
55
|
-
linkrunner.init('FEhvnvlyBgJBTtrATPBpkkRMqtLcKWOs');
|