mosquito-transport-js 0.3.6 → 0.3.7
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 +1 -1
- package/src/index.js +8 -2
- package/src/products/auth/index.js +2 -9
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { deserializeE2E, listenReachableServer, serializeE2E } from "./helpers/peripherals";
|
|
2
2
|
import { awaitStore, releaseCacheStore } from "./helpers/utils";
|
|
3
|
-
import {
|
|
3
|
+
import { CacheStore, Scoped } from "./helpers/variables";
|
|
4
4
|
import { MTCollection, batchWrite, trySendPendingWrite } from "./products/database";
|
|
5
5
|
import { MTStorage } from "./products/storage";
|
|
6
6
|
import { ServerReachableListener, TokenRefreshListener } from "./helpers/listeners";
|
|
@@ -14,7 +14,7 @@ import { Validator } from 'guard-object';
|
|
|
14
14
|
import sendMessage from "./helpers/broadcaster";
|
|
15
15
|
import cloneDeep from 'lodash.clonedeep';
|
|
16
16
|
import { Buffer } from 'buffer';
|
|
17
|
-
import MTAuth from './products/auth';
|
|
17
|
+
import MTAuth, { purgePendingToken } from './products/auth';
|
|
18
18
|
|
|
19
19
|
const {
|
|
20
20
|
_listenCollection,
|
|
@@ -133,6 +133,12 @@ export class MosquitoTransport {
|
|
|
133
133
|
validateReleaseCacheProp({ ...prop });
|
|
134
134
|
Scoped.ReleaseCacheData = { ...prop };
|
|
135
135
|
releaseCacheStore({ ...prop });
|
|
136
|
+
// purge residue tokens
|
|
137
|
+
awaitStore().then(() => {
|
|
138
|
+
Object.keys(CacheStore.PendingAuthPurge).forEach(k => {
|
|
139
|
+
purgePendingToken(k);
|
|
140
|
+
});
|
|
141
|
+
});
|
|
136
142
|
}
|
|
137
143
|
|
|
138
144
|
getDatabase = (dbName, dbUrl) => ({
|
|
@@ -8,13 +8,6 @@ import { deserializeE2E, encodeBinary, serializeE2E } from "../../helpers/periph
|
|
|
8
8
|
import { simplifyCaughtError, simplifyError } from "simplify-error";
|
|
9
9
|
import cloneDeep from "lodash.clonedeep";
|
|
10
10
|
|
|
11
|
-
// purge residue tokens
|
|
12
|
-
awaitStore().then(() => {
|
|
13
|
-
Object.keys(CacheStore.PendingAuthPurge).forEach(k => {
|
|
14
|
-
purgePendingToken(k);
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
|
|
18
11
|
const {
|
|
19
12
|
_listenUserVerification,
|
|
20
13
|
_signOut,
|
|
@@ -290,7 +283,7 @@ export const revokeAuthIntance = async (builder, authStore) => {
|
|
|
290
283
|
await purgePendingToken(nodeId);
|
|
291
284
|
};
|
|
292
285
|
|
|
293
|
-
const purgePendingToken = async (nodeId) => {
|
|
286
|
+
export const purgePendingToken = async (nodeId) => {
|
|
294
287
|
const {
|
|
295
288
|
auth: { token, refreshToken: r_token },
|
|
296
289
|
data: { projectUrl, serverE2E_PublicKey, accessKey, uglify, extraHeaders }
|
|
@@ -300,7 +293,7 @@ const purgePendingToken = async (nodeId) => {
|
|
|
300
293
|
try {
|
|
301
294
|
let isConnected;
|
|
302
295
|
try {
|
|
303
|
-
isConnected = (await (await fetch(_areYouOk(projectUrl))).json()).status === 'yes';
|
|
296
|
+
isConnected = (await (await fetch(_areYouOk(projectUrl))).json(), { cache: 'no-cache' }).status === 'yes';
|
|
304
297
|
} catch (_) { }
|
|
305
298
|
|
|
306
299
|
if (!isConnected)
|