react-native-mosquito-transport 0.0.49 → 0.0.51
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.
|
@@ -38,7 +38,7 @@ class MosquitoTransportModule(reactContext: ReactApplicationContext) :
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
override fun getSystemUptime(promise: Promise) {
|
|
41
|
-
val uptime = SystemClock.elapsedRealtime()
|
|
41
|
+
val uptime = SystemClock.elapsedRealtime().toDouble()
|
|
42
42
|
promise.resolve(uptime)
|
|
43
43
|
}
|
|
44
44
|
|
package/ios/MosquitoTransport.mm
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#import "MosquitoTransport.h"
|
|
2
2
|
#import <React/RCTEventEmitter.h>
|
|
3
|
+
#import <mach/mach_time.h>
|
|
3
4
|
#if __has_include("MosquitoTransport-Swift.h")
|
|
4
5
|
#import "MosquitoTransport-Swift.h"
|
|
5
6
|
#else
|
|
@@ -49,9 +50,19 @@ RCT_EXPORT_MODULE()
|
|
|
49
50
|
return NO;
|
|
50
51
|
}
|
|
51
52
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
- (void)getSystemUptime:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
|
54
|
+
static mach_timebase_info_data_t timebase;
|
|
55
|
+
if (timebase.denom == 0) {
|
|
56
|
+
mach_timebase_info(&timebase);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
uint64_t time = mach_continuous_time();
|
|
60
|
+
|
|
61
|
+
uint64_t nanos = time * timebase.numer / timebase.denom;
|
|
62
|
+
|
|
63
|
+
double milliseconds = (double)nanos / 1e6;
|
|
64
|
+
|
|
65
|
+
resolve(@(milliseconds));
|
|
55
66
|
}
|
|
56
67
|
|
|
57
68
|
- (void)uploadFile:(NSDictionary *)options {
|
package/package.json
CHANGED
|
@@ -124,7 +124,7 @@ export const initTokenRefresher = async ({ config, forceRefresh, justCheck }) =>
|
|
|
124
124
|
clearInterval(Scoped.TokenRefreshTimer[projectUrl]);
|
|
125
125
|
notifyAuthReady();
|
|
126
126
|
rizz();
|
|
127
|
-
},
|
|
127
|
+
}, 9000);
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
} else {
|
|
@@ -156,7 +156,6 @@ export const getEmulatedLinks = (projectUrl) => Object.entries(CacheStore.Emulat
|
|
|
156
156
|
const refreshToken = (builder, remainRetries = 1, isForceRefresh) =>
|
|
157
157
|
new Promise(async (resolve, reject) => {
|
|
158
158
|
const { projectUrl, serverE2E_PublicKey, uglify, extraHeaders } = builder;
|
|
159
|
-
const lostProcess = simplifyError('process_lost', 'The token refresh process has been lost and replaced with another one');
|
|
160
159
|
|
|
161
160
|
try {
|
|
162
161
|
const { token, refreshToken: r_token } = CacheStore.AuthStore[projectUrl];
|
|
@@ -172,27 +171,25 @@ const refreshToken = (builder, remainRetries = 1, isForceRefresh) =>
|
|
|
172
171
|
|
|
173
172
|
const f = uglify ? await deserializeE2E(data, serverE2E_PublicKey, privateKey) : data;
|
|
174
173
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
await updateTokenTimestamp(projectUrl, f.result.token);
|
|
174
|
+
CacheStore.AuthStore[projectUrl].token = f.result.token;
|
|
175
|
+
Scoped.AuthJWTToken[projectUrl] = f.result.token;
|
|
176
|
+
await updateTokenTimestamp(projectUrl, f.result.token);
|
|
179
177
|
|
|
180
|
-
|
|
181
|
-
|
|
178
|
+
resolve(f.result.token);
|
|
179
|
+
const isInit = !Scoped.InitiatedForcedToken[projectUrl] && isForceRefresh;
|
|
182
180
|
|
|
183
|
-
|
|
184
|
-
|
|
181
|
+
triggerAuthToken(projectUrl, isInit);
|
|
182
|
+
if (isForceRefresh) Scoped.InitiatedForcedToken[projectUrl] = true;
|
|
185
183
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
184
|
+
getEmulatedLinks(projectUrl).forEach(v => {
|
|
185
|
+
CacheStore.AuthStore[v] = basicClone(CacheStore.AuthStore[projectUrl]);
|
|
186
|
+
Scoped.AuthJWTToken[v] = f.result.token;
|
|
189
187
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
} else reject(lostProcess.simpleError);
|
|
188
|
+
triggerAuthToken(v, isInit);
|
|
189
|
+
if (isForceRefresh) Scoped.InitiatedForcedToken[v] = true;
|
|
190
|
+
});
|
|
191
|
+
updateCacheStore(['AuthStore']);
|
|
192
|
+
initTokenRefresher({ config: builder });
|
|
196
193
|
} catch (e) {
|
|
197
194
|
if (e.simpleError) {
|
|
198
195
|
console.error(`refreshToken error: ${e.simpleError?.message}`);
|
|
@@ -202,7 +199,7 @@ const refreshToken = (builder, remainRetries = 1, isForceRefresh) =>
|
|
|
202
199
|
reject(
|
|
203
200
|
simplifyError('retry_limit_reached', 'The retry limit has been reach and execution prematurely stopped').simpleError
|
|
204
201
|
);
|
|
205
|
-
console.error(`refreshToken retry limit exceeded
|
|
202
|
+
console.error(`refreshToken retry limit exceeded err:`, e);
|
|
206
203
|
} else {
|
|
207
204
|
const l = listenReachableServer(c => {
|
|
208
205
|
if (c) {
|