@opexa/portal-sdk 0.59.99 → 0.59.101
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/dist/index.cjs +16 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +16 -23
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3,7 +3,6 @@ import { GraphQLClient, isPlainObject } from './chunk-7APXFZ5G.js';
|
|
|
3
3
|
import './chunk-WVFSGB7Y.js';
|
|
4
4
|
import { ObjectId } from '@opexa/object-id';
|
|
5
5
|
export { ObjectId } from '@opexa/object-id';
|
|
6
|
-
import { App } from '@capacitor/app';
|
|
7
6
|
import { Capacitor } from '@capacitor/core';
|
|
8
7
|
import cookies from 'js-cookie';
|
|
9
8
|
|
|
@@ -443,7 +442,7 @@ var SessionManager = class {
|
|
|
443
442
|
version,
|
|
444
443
|
...data,
|
|
445
444
|
accessTokenExpiresAt: addMinutes(now, 8).getTime(),
|
|
446
|
-
refreshTokenExpiresAt: subMinutes(addDays(now,
|
|
445
|
+
refreshTokenExpiresAt: subMinutes(addDays(now, 1), 2).getTime()
|
|
447
446
|
})
|
|
448
447
|
);
|
|
449
448
|
return true;
|
|
@@ -643,8 +642,7 @@ var SessionManager = class {
|
|
|
643
642
|
...obj,
|
|
644
643
|
accessToken: res.data.accessToken,
|
|
645
644
|
refreshToken: res.data.refreshToken ?? obj.refreshToken,
|
|
646
|
-
accessTokenExpiresAt: addMinutes(now, 8).getTime()
|
|
647
|
-
refreshTokenExpiresAt: subMinutes(addDays(now, 30), 2).getTime()
|
|
645
|
+
accessTokenExpiresAt: addMinutes(now, 8).getTime()
|
|
648
646
|
};
|
|
649
647
|
localStorage.setItem(this.storageKey, JSON.stringify(obj));
|
|
650
648
|
}
|
|
@@ -3674,35 +3672,30 @@ var Sdk = class {
|
|
|
3674
3672
|
const interval = clamp(input.interval ?? 3e4, 5e3, 6e4);
|
|
3675
3673
|
let counter = 0;
|
|
3676
3674
|
let timeout = null;
|
|
3677
|
-
let isForeground = true;
|
|
3678
3675
|
let stopped = false;
|
|
3679
|
-
const listener = App.addListener("appStateChange", ({ isActive }) => {
|
|
3680
|
-
isForeground = isActive;
|
|
3681
|
-
});
|
|
3682
3676
|
const stop = () => {
|
|
3683
3677
|
stopped = true;
|
|
3684
3678
|
if (timeout) {
|
|
3685
3679
|
clearTimeout(timeout);
|
|
3686
3680
|
timeout = null;
|
|
3687
3681
|
}
|
|
3688
|
-
listener.then((handle) => handle.remove());
|
|
3689
3682
|
};
|
|
3690
3683
|
const assignTimeout = () => {
|
|
3691
|
-
const duration = counter <= 0 ? interval *
|
|
3684
|
+
const duration = counter <= 0 ? interval * 1.5 : interval;
|
|
3692
3685
|
return setTimeout(async () => {
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3686
|
+
let res;
|
|
3687
|
+
try {
|
|
3688
|
+
res = await this.sessionManager.verify();
|
|
3689
|
+
} catch {
|
|
3690
|
+
res = null;
|
|
3691
|
+
}
|
|
3692
|
+
if (stopped) {
|
|
3693
|
+
return;
|
|
3694
|
+
}
|
|
3695
|
+
if (res && !res.valid) {
|
|
3696
|
+
stop();
|
|
3697
|
+
await input.onInvalid(res.reason ?? "INVALID_SESSION");
|
|
3698
|
+
return;
|
|
3706
3699
|
}
|
|
3707
3700
|
counter += 1;
|
|
3708
3701
|
timeout = assignTimeout();
|