react-native-mosquito-transport 0.0.15 → 0.0.16
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/TODO +2 -1
- package/package.json +7 -2
- package/src/helpers/values.js +10 -1
- package/src/index.d.ts +39 -2
- package/src/index.js +37 -15
- package/src/products/auth/index.js +3 -0
- package/src/products/database/accessor.js +4 -4
- package/src/products/database/index.js +1 -1
- package/src/products/database/validator.js +2 -2
package/TODO
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-mosquito-transport",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16",
|
|
4
4
|
"description": "React native javascript sdk for mosquito-transport (https://github.com/deflexable/mosquito-transport)",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -31,8 +31,13 @@
|
|
|
31
31
|
"@types/lodash": "^4.14.194",
|
|
32
32
|
"buffer": "^6.0.3",
|
|
33
33
|
"crypto-js": "^4.2.0",
|
|
34
|
+
"fast-json-stable-stringify": "^2.1.0",
|
|
35
|
+
"guard-object": "^1.0.6",
|
|
34
36
|
"json-buffer": "^3.0.1",
|
|
35
|
-
"lodash": "^4.
|
|
37
|
+
"lodash.get": "^4.4.2",
|
|
38
|
+
"lodash.isequal": "^4.5.0",
|
|
39
|
+
"lodash.set": "^4.3.2",
|
|
40
|
+
"lodash.unset": "^4.5.2",
|
|
36
41
|
"react-native-get-random-values": "^1.9.0",
|
|
37
42
|
"set-large-timeout": "^1.0.1",
|
|
38
43
|
"socket.io-client": "^4.6.2",
|
package/src/helpers/values.js
CHANGED
|
@@ -70,4 +70,13 @@ export const READ_OPS_LIST = Object.values(READ_OPS);
|
|
|
70
70
|
|
|
71
71
|
export const Regexs = {
|
|
72
72
|
LINK: () => /(\b(https?|ftp):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig
|
|
73
|
-
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export const AUTH_PROVIDER_ID = {
|
|
76
|
+
GOOGLE: 'google.com',
|
|
77
|
+
FACEBOOK: 'facebook.com',
|
|
78
|
+
PASSWORD: 'password',
|
|
79
|
+
TWITTER: 'x.com',
|
|
80
|
+
GITHUB: 'github.com',
|
|
81
|
+
APPLE: 'apple.com'
|
|
82
|
+
};
|
package/src/index.d.ts
CHANGED
|
@@ -25,6 +25,43 @@ interface mtimestamp { $timestamp: 'now' }
|
|
|
25
25
|
export const TIMESTAMP: mtimestamp;
|
|
26
26
|
export function DOCUMENT_EXTRACTION(path: string): { $dynamicValue: number };
|
|
27
27
|
|
|
28
|
+
type longitude = number;
|
|
29
|
+
type latitude = number;
|
|
30
|
+
|
|
31
|
+
export function GEO_JSON(latitude: latitude, longitude: longitude): {
|
|
32
|
+
type: "Point",
|
|
33
|
+
coordinates: [longitude, latitude],
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export function FIND_GEO_JSON(coordinates: [latitude, longitude], offSetMeters: number, centerMeters?: number): {
|
|
37
|
+
$near: {
|
|
38
|
+
$geometry: {
|
|
39
|
+
type: "Point",
|
|
40
|
+
coordinates: [longitude, latitude]
|
|
41
|
+
},
|
|
42
|
+
$minDistance: number | 0,
|
|
43
|
+
$maxDistance: number
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const AUTH_PROVIDER_ID: auth_provider_id;
|
|
48
|
+
|
|
49
|
+
interface auth_provider_id {
|
|
50
|
+
GOOGLE: 'google.com';
|
|
51
|
+
FACEBOOK: 'facebook.com';
|
|
52
|
+
PASSWORD: 'password';
|
|
53
|
+
TWITTER: 'x.com';
|
|
54
|
+
GITHUB: 'github.com';
|
|
55
|
+
APPLE: 'apple.com';
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
type auth_provider_id_values = auth_provider_id['GOOGLE'] |
|
|
59
|
+
auth_provider_id['FACEBOOK'] |
|
|
60
|
+
auth_provider_id['PASSWORD'] |
|
|
61
|
+
auth_provider_id['GITHUB'] |
|
|
62
|
+
auth_provider_id['TWITTER'] |
|
|
63
|
+
auth_provider_id['APPLE'];
|
|
64
|
+
|
|
28
65
|
interface ReleaseCacheOption_IO {
|
|
29
66
|
/**
|
|
30
67
|
* This password will be used to encrypt data stored locally
|
|
@@ -343,8 +380,8 @@ interface SignupResult extends SigninResult {
|
|
|
343
380
|
interface AuthData {
|
|
344
381
|
email?: string;
|
|
345
382
|
metadata: Object;
|
|
346
|
-
signupMethod:
|
|
347
|
-
currentAuthMethod:
|
|
383
|
+
signupMethod: auth_provider_id_values;
|
|
384
|
+
currentAuthMethod: auth_provider_id_values;
|
|
348
385
|
joinedOn: number;
|
|
349
386
|
uid: string;
|
|
350
387
|
claims: Object;
|
package/src/index.js
CHANGED
|
@@ -6,12 +6,12 @@ import { MTAuth } from "./products/auth";
|
|
|
6
6
|
import { MTCollection, batchWrite } from "./products/database";
|
|
7
7
|
import { MTStorage } from "./products/storage";
|
|
8
8
|
import { ServerReachableListener, TokenRefreshListener } from "./helpers/listeners";
|
|
9
|
-
import { initTokenRefresher, listenTokenReady, triggerAuthToken } from "./products/auth/accessor";
|
|
9
|
+
import { initTokenRefresher, listenToken, listenTokenReady, parseToken, triggerAuthToken } from "./products/auth/accessor";
|
|
10
10
|
import { TIMESTAMP, DOCUMENT_EXTRACTION, FIND_GEO_JSON, GEO_JSON } from "./products/database/types";
|
|
11
11
|
import { mfetch } from "./products/http_callable";
|
|
12
12
|
import { io } from "socket.io-client";
|
|
13
13
|
import { validateCollectionPath } from "./products/database/validator";
|
|
14
|
-
import { CACHE_PROTOCOL, Regexs } from "./helpers/values";
|
|
14
|
+
import { AUTH_PROVIDER_ID, CACHE_PROTOCOL, Regexs } from "./helpers/values";
|
|
15
15
|
import { trySendPendingWrite } from "./products/database/accessor";
|
|
16
16
|
import EngineApi from './helpers/EngineApi';
|
|
17
17
|
import { parse, stringify } from 'json-buffer';
|
|
@@ -48,20 +48,41 @@ class RNMT {
|
|
|
48
48
|
triggerAuthToken(projectUrl);
|
|
49
49
|
initTokenRefresher({ ...this.config }, true);
|
|
50
50
|
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
});
|
|
51
|
+
const disconnectionGlich = {};
|
|
52
|
+
let socket, lastUid, lastSocketProcess = 0, hasInited;
|
|
54
53
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
});
|
|
54
|
+
listenToken((token, thisInited) => {
|
|
55
|
+
const user = token && parseToken(token);
|
|
58
56
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
57
|
+
const thisUid = (user?.uid || null);
|
|
58
|
+
if (lastUid === thisUid && (hasInited || !thisInited)) return;
|
|
59
|
+
if (!hasInited) hasInited = thisInited;
|
|
60
|
+
lastUid = thisUid;
|
|
61
|
+
|
|
62
|
+
if (lastSocketProcess) disconnectionGlich[lastSocketProcess] = true;
|
|
63
|
+
socket.close();
|
|
64
|
+
|
|
65
|
+
const thisProcess = ++lastSocketProcess;
|
|
66
|
+
socket = io(`${this.config.wsPrefix}://${projectUrl.split('://')[1]}`, {
|
|
67
|
+
auth: {
|
|
68
|
+
_m_internal: true,
|
|
69
|
+
_from_base: true,
|
|
70
|
+
atoken: token
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
socket.on('_signal_signout', () => {
|
|
75
|
+
this.auth().signOut();
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
socket.on('connect', () => {
|
|
79
|
+
ServerReachableListener.dispatch(projectUrl, true);
|
|
80
|
+
});
|
|
81
|
+
socket.on('disconnect', () => {
|
|
82
|
+
if (!disconnectionGlich[thisProcess])
|
|
83
|
+
ServerReachableListener.dispatch(projectUrl, false);
|
|
84
|
+
});
|
|
85
|
+
}, projectUrl);
|
|
65
86
|
|
|
66
87
|
listenReachableServer(c => {
|
|
67
88
|
Scoped.IS_CONNECTED[projectUrl] = c;
|
|
@@ -378,7 +399,8 @@ export {
|
|
|
378
399
|
TIMESTAMP,
|
|
379
400
|
DOCUMENT_EXTRACTION,
|
|
380
401
|
FIND_GEO_JSON,
|
|
381
|
-
GEO_JSON
|
|
402
|
+
GEO_JSON,
|
|
403
|
+
AUTH_PROVIDER_ID
|
|
382
404
|
};
|
|
383
405
|
|
|
384
406
|
export default RNMT;
|
|
@@ -2,10 +2,10 @@ import { IS_RAW_OBJECT, objToUniqueString, queryEntries, shuffleArray, sortArray
|
|
|
2
2
|
import { awaitStore, updateCacheStore } from "../../helpers/utils";
|
|
3
3
|
import { CacheStore } from "../../helpers/variables";
|
|
4
4
|
import { confirmFilterDoc } from "./validator";
|
|
5
|
-
import getLodash from 'lodash
|
|
6
|
-
import setLodash from 'lodash
|
|
7
|
-
import unsetLodash from 'lodash
|
|
8
|
-
import isEqual from 'lodash
|
|
5
|
+
import getLodash from 'lodash.get';
|
|
6
|
+
import setLodash from 'lodash.set';
|
|
7
|
+
import unsetLodash from 'lodash.unset';
|
|
8
|
+
import isEqual from 'lodash.isequal';
|
|
9
9
|
import { DEFAULT_DB_NAME, DEFAULT_DB_URL, DELIVERY, RETRIEVAL, WRITE_OPS, WRITE_OPS_LIST } from "../../helpers/values";
|
|
10
10
|
import { DatabaseRecordsListener } from "../../helpers/listeners";
|
|
11
11
|
|
|
@@ -8,7 +8,7 @@ import { addPendingWrites, generateRecordID, getRecord, insertRecord, listenQuer
|
|
|
8
8
|
import { validateCollectionPath, validateFilter, validateReadConfig, validateWriteValue } from "./validator";
|
|
9
9
|
import { awaitRefreshToken, listenToken } from "../auth/accessor";
|
|
10
10
|
import { DEFAULT_DB_NAME, DEFAULT_DB_URL, DELIVERY, RETRIEVAL } from "../../helpers/values";
|
|
11
|
-
import setLodash from 'lodash
|
|
11
|
+
import setLodash from 'lodash.set';
|
|
12
12
|
|
|
13
13
|
export class MTCollection {
|
|
14
14
|
constructor(config) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IS_DECIMAL_NUMBER, IS_RAW_OBJECT, IS_WHOLE_NUMBER, queryEntries } from "../../helpers/peripherals";
|
|
2
2
|
import { READ_OPS, READ_OPS_LIST, RETRIEVAL } from "../../helpers/values";
|
|
3
|
-
import getLodash from 'lodash
|
|
4
|
-
import isEqual from 'lodash
|
|
3
|
+
import getLodash from 'lodash.get';
|
|
4
|
+
import isEqual from 'lodash.isequal';
|
|
5
5
|
|
|
6
6
|
const dirn = ['desc', 'asc', 'ascending', 'descending'];
|
|
7
7
|
|