mftsccs-browser 2.0.10-beta → 2.0.12-beta
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/main.bundle.js +263 -175
- package/dist/main.bundle.js.map +1 -1
- package/dist/serviceWorker.bundle.js +356 -198
- package/dist/serviceWorker.bundle.js.map +1 -1
- package/dist/types/AccessTracker/accessTracker.d.ts +1 -1
- package/dist/types/Middleware/logger.service.d.ts +2 -0
- package/dist/types/Widgets/WidgetTree.d.ts +1 -1
- package/dist/types/app.d.ts +3 -0
- package/package.json +1 -1
|
@@ -93,10 +93,7 @@ class AccessTracker {
|
|
|
93
93
|
static sendToServer() {
|
|
94
94
|
return __awaiter(this, void 0, void 0, function* () {
|
|
95
95
|
try {
|
|
96
|
-
|
|
97
|
-
if (!accessToken)
|
|
98
|
-
return;
|
|
99
|
-
yield this.syncToServer(accessToken);
|
|
96
|
+
yield this.syncToServer();
|
|
100
97
|
}
|
|
101
98
|
catch (error) {
|
|
102
99
|
console.error("Failed to process Access Tracker Sync with Server");
|
|
@@ -106,16 +103,18 @@ class AccessTracker {
|
|
|
106
103
|
/**
|
|
107
104
|
* Syncs the concept and connection data with the server.
|
|
108
105
|
*/
|
|
109
|
-
static syncToServer(
|
|
106
|
+
static syncToServer() {
|
|
110
107
|
return __awaiter(this, void 0, void 0, function* () {
|
|
111
108
|
try {
|
|
112
109
|
if (!Object.keys(this.conceptsData).length && !Object.keys(this.connectionsData).length) {
|
|
113
110
|
return;
|
|
114
111
|
}
|
|
112
|
+
const accessToken = _DataStructures_Security_TokenStorage__WEBPACK_IMPORTED_MODULE_1__.TokenStorage.BearerAccessToken;
|
|
113
|
+
if (!accessToken)
|
|
114
|
+
return;
|
|
115
115
|
// Ensure conceptsData and connectionsData are not undefined or null
|
|
116
116
|
const conceptsToSend = this.conceptsData && Object.keys(this.conceptsData).length > 0 ? this.conceptsData : {};
|
|
117
117
|
const connectionsToSend = this.connectionsData && Object.keys(this.connectionsData).length > 0 ? this.connectionsData : {};
|
|
118
|
-
console.log("Access Tracker Sent to SERVER..", conceptsToSend, connectionsToSend);
|
|
119
118
|
const response = yield fetch(_app__WEBPACK_IMPORTED_MODULE_0__.BaseUrl.PostPrefetchConceptConnections(), {
|
|
120
119
|
method: 'POST',
|
|
121
120
|
headers: {
|
|
@@ -130,7 +129,7 @@ class AccessTracker {
|
|
|
130
129
|
if (!response.ok) {
|
|
131
130
|
throw new Error('Failed to sync data to the server.');
|
|
132
131
|
}
|
|
133
|
-
|
|
132
|
+
yield response.json();
|
|
134
133
|
this.conceptsData = {};
|
|
135
134
|
this.connectionsData = {};
|
|
136
135
|
this.setNextSyncTime();
|
|
@@ -154,13 +153,10 @@ class AccessTracker {
|
|
|
154
153
|
* This will automatically call `syncToServer` every 5 minutes
|
|
155
154
|
*/
|
|
156
155
|
static startAutoSync() {
|
|
157
|
-
const tokenString = _DataStructures_Security_TokenStorage__WEBPACK_IMPORTED_MODULE_1__.TokenStorage.BearerAccessToken;
|
|
158
|
-
if (tokenString) {
|
|
159
|
-
this.syncNow().catch(console.error);
|
|
160
|
-
}
|
|
161
156
|
setInterval(() => {
|
|
162
157
|
const currentTime = Date.now();
|
|
163
158
|
// console.log(`[CHECK] Current Time: ${new Date(currentTime).toISOString()}`);
|
|
159
|
+
// console.log(`Update Time: ${this.nextSyncTime}`);
|
|
164
160
|
if (this.nextSyncTime && currentTime >= this.nextSyncTime) {
|
|
165
161
|
// console.log(`[SYNC TRIGGER] Time to sync! Triggering sync at: ${new Date(currentTime).toISOString()}`);
|
|
166
162
|
this.syncNow().catch(console.error);
|
|
@@ -172,12 +168,17 @@ class AccessTracker {
|
|
|
172
168
|
*/
|
|
173
169
|
static syncNow() {
|
|
174
170
|
return __awaiter(this, void 0, void 0, function* () {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
171
|
+
try {
|
|
172
|
+
// console.log("Status of Access Tracker is : ", this.activateStatus);
|
|
173
|
+
if (this.activateStatus) {
|
|
174
|
+
yield this.syncToServer();
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
console.warn("Access Tracker inactive.");
|
|
178
|
+
}
|
|
178
179
|
}
|
|
179
|
-
|
|
180
|
-
console.
|
|
180
|
+
catch (error) {
|
|
181
|
+
console.error("Error on sync access tracker");
|
|
181
182
|
}
|
|
182
183
|
});
|
|
183
184
|
}
|
|
@@ -1782,6 +1783,9 @@ function GetConcept(id) {
|
|
|
1782
1783
|
}
|
|
1783
1784
|
}
|
|
1784
1785
|
let result = (0,_app__WEBPACK_IMPORTED_MODULE_3__.CreateDefaultConcept)();
|
|
1786
|
+
if (id == 0 || id == undefined || id == null) {
|
|
1787
|
+
return result;
|
|
1788
|
+
}
|
|
1785
1789
|
var conceptUse = yield _DataStructures_ConceptData__WEBPACK_IMPORTED_MODULE_0__.ConceptsData.GetConcept(id);
|
|
1786
1790
|
let isNpc = _DataStructures_ConceptData__WEBPACK_IMPORTED_MODULE_0__.ConceptsData.GetNpc(id);
|
|
1787
1791
|
if (conceptUse.id != 0 || isNpc) {
|
|
@@ -5287,6 +5291,9 @@ class ConceptsData {
|
|
|
5287
5291
|
(0,_app__WEBPACK_IMPORTED_MODULE_5__.handleServiceWorkerException)(error);
|
|
5288
5292
|
}
|
|
5289
5293
|
}
|
|
5294
|
+
if (id == 0 || id == undefined || id == null) {
|
|
5295
|
+
return (0,_Services_CreateDefaultConcept__WEBPACK_IMPORTED_MODULE_4__.CreateDefaultConcept)();
|
|
5296
|
+
}
|
|
5290
5297
|
var myConcept = (0,_Services_CreateDefaultConcept__WEBPACK_IMPORTED_MODULE_4__.CreateDefaultConcept)();
|
|
5291
5298
|
var node = yield _BinaryTree__WEBPACK_IMPORTED_MODULE_1__.BinaryTree.getNodeFromTree(id);
|
|
5292
5299
|
if (node === null || node === void 0 ? void 0 : node.value) {
|
|
@@ -11378,7 +11385,6 @@ class ApplicationMonitor {
|
|
|
11378
11385
|
};
|
|
11379
11386
|
_logger_service__WEBPACK_IMPORTED_MODULE_1__.Logger.logApplication("INFO", "Network Request", networkDetails);
|
|
11380
11387
|
return originalFetch(...args);
|
|
11381
|
-
// return new Response(null, { status: 200 });
|
|
11382
11388
|
}
|
|
11383
11389
|
let networkDetails = {
|
|
11384
11390
|
"request": {
|
|
@@ -11653,6 +11659,8 @@ class Logger {
|
|
|
11653
11659
|
// this.saveLogToLocalStorage(this.mftsccsBrowser, logEntry)
|
|
11654
11660
|
}
|
|
11655
11661
|
static log(level, message, data) {
|
|
11662
|
+
if (!this.logPackageActivationStatus)
|
|
11663
|
+
return;
|
|
11656
11664
|
try {
|
|
11657
11665
|
Logger.formatLogData(level, message, data || null);
|
|
11658
11666
|
}
|
|
@@ -11661,87 +11669,109 @@ class Logger {
|
|
|
11661
11669
|
}
|
|
11662
11670
|
}
|
|
11663
11671
|
static logInfo(startTime, userId, operationType, requestFrom, requestIP, responseStatus, responseData, functionName, functionParameters, userAgent, conceptsUsed) {
|
|
11664
|
-
|
|
11665
|
-
|
|
11666
|
-
|
|
11667
|
-
|
|
11668
|
-
|
|
11669
|
-
|
|
11670
|
-
|
|
11671
|
-
|
|
11672
|
-
|
|
11673
|
-
|
|
11674
|
-
|
|
11675
|
-
|
|
11676
|
-
|
|
11677
|
-
|
|
11678
|
-
|
|
11679
|
-
|
|
11680
|
-
|
|
11681
|
-
|
|
11672
|
+
try {
|
|
11673
|
+
const sessionId = getCookie("SessionId");
|
|
11674
|
+
const responseTime = `${(performance.now() - startTime).toFixed(3)}ms`;
|
|
11675
|
+
const responseSize = responseData ? `${JSON.stringify(responseData).length}` : "0";
|
|
11676
|
+
const logData = {
|
|
11677
|
+
userId,
|
|
11678
|
+
operationType,
|
|
11679
|
+
requestFrom,
|
|
11680
|
+
requestIP,
|
|
11681
|
+
responseStatus,
|
|
11682
|
+
responseTime,
|
|
11683
|
+
responseSize,
|
|
11684
|
+
sessionId: sessionId === null || sessionId === void 0 ? void 0 : sessionId.toString(),
|
|
11685
|
+
functionName,
|
|
11686
|
+
functionParameters,
|
|
11687
|
+
userAgent,
|
|
11688
|
+
conceptsUsed,
|
|
11689
|
+
};
|
|
11690
|
+
Logger.log("INFO", `Information logged for ${functionName}`, logData);
|
|
11691
|
+
}
|
|
11692
|
+
catch (error) {
|
|
11693
|
+
console.error("Error on logInfo");
|
|
11694
|
+
}
|
|
11682
11695
|
}
|
|
11683
11696
|
static logError(startTime, userId, operationType, requestFrom, requestIP, responseStatus, responseData, functionName, functionParameters, userAgent, conceptsUsed) {
|
|
11684
|
-
|
|
11685
|
-
|
|
11686
|
-
|
|
11687
|
-
|
|
11688
|
-
|
|
11689
|
-
|
|
11690
|
-
|
|
11691
|
-
|
|
11692
|
-
|
|
11693
|
-
|
|
11694
|
-
|
|
11695
|
-
|
|
11696
|
-
|
|
11697
|
-
|
|
11698
|
-
|
|
11699
|
-
|
|
11700
|
-
|
|
11701
|
-
|
|
11697
|
+
try {
|
|
11698
|
+
const sessionId = getCookie("SessionId");
|
|
11699
|
+
const responseTime = `${(performance.now() - startTime).toFixed(3)}ms`;
|
|
11700
|
+
const responseSize = responseData ? `${JSON.stringify(responseData).length}` : "0";
|
|
11701
|
+
const logData = {
|
|
11702
|
+
userId,
|
|
11703
|
+
operationType,
|
|
11704
|
+
requestFrom,
|
|
11705
|
+
requestIP,
|
|
11706
|
+
responseStatus,
|
|
11707
|
+
responseTime,
|
|
11708
|
+
responseSize,
|
|
11709
|
+
sessionId: sessionId === null || sessionId === void 0 ? void 0 : sessionId.toString(),
|
|
11710
|
+
functionName,
|
|
11711
|
+
functionParameters,
|
|
11712
|
+
userAgent,
|
|
11713
|
+
conceptsUsed,
|
|
11714
|
+
};
|
|
11715
|
+
Logger.formatLogData("ERROR", `Information logged for ${functionName}`, logData);
|
|
11716
|
+
}
|
|
11717
|
+
catch (error) {
|
|
11718
|
+
console.error("Error on logError");
|
|
11719
|
+
}
|
|
11702
11720
|
}
|
|
11703
11721
|
static logWarning(startTime, userId, operationType, requestFrom, requestIP, responseStatus, responseData, functionName, functionParameters, userAgent, conceptsUsed) {
|
|
11704
|
-
|
|
11705
|
-
|
|
11706
|
-
|
|
11707
|
-
|
|
11708
|
-
|
|
11709
|
-
|
|
11710
|
-
|
|
11711
|
-
|
|
11712
|
-
|
|
11713
|
-
|
|
11714
|
-
|
|
11715
|
-
|
|
11716
|
-
|
|
11717
|
-
|
|
11718
|
-
|
|
11719
|
-
|
|
11720
|
-
|
|
11721
|
-
|
|
11722
|
+
try {
|
|
11723
|
+
const sessionId = getCookie("SessionId");
|
|
11724
|
+
const responseTime = `${(performance.now() - startTime).toFixed(3)}ms`;
|
|
11725
|
+
const responseSize = responseData ? `${JSON.stringify(responseData).length}` : "0";
|
|
11726
|
+
const logData = {
|
|
11727
|
+
userId,
|
|
11728
|
+
operationType,
|
|
11729
|
+
requestFrom,
|
|
11730
|
+
requestIP,
|
|
11731
|
+
responseStatus,
|
|
11732
|
+
responseTime,
|
|
11733
|
+
responseSize,
|
|
11734
|
+
sessionId: sessionId === null || sessionId === void 0 ? void 0 : sessionId.toString(),
|
|
11735
|
+
functionName,
|
|
11736
|
+
functionParameters,
|
|
11737
|
+
userAgent,
|
|
11738
|
+
conceptsUsed,
|
|
11739
|
+
};
|
|
11740
|
+
Logger.formatLogData("WARNING", `Information logged for ${functionName}`, logData);
|
|
11741
|
+
}
|
|
11742
|
+
catch (error) {
|
|
11743
|
+
console.error("Error on logWarning");
|
|
11744
|
+
}
|
|
11722
11745
|
}
|
|
11723
11746
|
static logDebug(startTime, userId, operationType, requestFrom, requestIP, responseStatus, responseData, functionName, functionParameters, userAgent, conceptsUsed) {
|
|
11724
|
-
|
|
11725
|
-
|
|
11726
|
-
|
|
11727
|
-
|
|
11728
|
-
|
|
11729
|
-
|
|
11730
|
-
|
|
11731
|
-
|
|
11732
|
-
|
|
11733
|
-
|
|
11734
|
-
|
|
11735
|
-
|
|
11736
|
-
|
|
11737
|
-
|
|
11738
|
-
|
|
11739
|
-
|
|
11740
|
-
|
|
11741
|
-
|
|
11747
|
+
try {
|
|
11748
|
+
const sessionId = getCookie("SessionId");
|
|
11749
|
+
const responseTime = `${(performance.now() - startTime).toFixed(3)}ms`;
|
|
11750
|
+
const responseSize = responseData ? `${JSON.stringify(responseData).length}` : "0";
|
|
11751
|
+
const logData = {
|
|
11752
|
+
userId,
|
|
11753
|
+
operationType,
|
|
11754
|
+
requestFrom,
|
|
11755
|
+
requestIP,
|
|
11756
|
+
responseStatus,
|
|
11757
|
+
responseTime,
|
|
11758
|
+
responseSize,
|
|
11759
|
+
sessionId: sessionId === null || sessionId === void 0 ? void 0 : sessionId.toString(),
|
|
11760
|
+
functionName,
|
|
11761
|
+
functionParameters,
|
|
11762
|
+
userAgent,
|
|
11763
|
+
conceptsUsed,
|
|
11764
|
+
};
|
|
11765
|
+
Logger.formatLogData("DEBUG", `Information logged for ${functionName}`, logData);
|
|
11766
|
+
}
|
|
11767
|
+
catch (error) {
|
|
11768
|
+
console.error("Error on logDebug");
|
|
11769
|
+
}
|
|
11742
11770
|
}
|
|
11743
11771
|
// Log Application Activity
|
|
11744
11772
|
static logApplication(type, message, data) {
|
|
11773
|
+
if (!this.logApplicationActivationStatus)
|
|
11774
|
+
return;
|
|
11745
11775
|
try {
|
|
11746
11776
|
const timestamp = new Date().toLocaleString();
|
|
11747
11777
|
const logEntry = {
|
|
@@ -11763,18 +11793,13 @@ class Logger {
|
|
|
11763
11793
|
static sendApplicationLogsToServer() {
|
|
11764
11794
|
return __awaiter(this, void 0, void 0, function* () {
|
|
11765
11795
|
try {
|
|
11766
|
-
|
|
11767
|
-
// console.log("Log To Server : \n", this.applicationLogsData);
|
|
11768
|
-
if (this.applicationLogsData.length < 0) {
|
|
11796
|
+
if (this.applicationLogsData.length === 0) {
|
|
11769
11797
|
return;
|
|
11770
11798
|
}
|
|
11771
11799
|
const accessToken = _DataStructures_Security_TokenStorage__WEBPACK_IMPORTED_MODULE_1__.TokenStorage.BearerAccessToken;
|
|
11772
|
-
const storedLogs = this.applicationLogsData;
|
|
11773
|
-
console.log("Application Logs of AppLog : ", storedLogs);
|
|
11774
11800
|
if (!accessToken)
|
|
11775
11801
|
return;
|
|
11776
|
-
|
|
11777
|
-
return;
|
|
11802
|
+
const storedLogs = this.applicationLogsData;
|
|
11778
11803
|
const chunkSize = 50;
|
|
11779
11804
|
for (let i = 0; i < storedLogs.length; i += chunkSize) {
|
|
11780
11805
|
const chunk = storedLogs.slice(i, i + chunkSize);
|
|
@@ -11797,8 +11822,6 @@ class Logger {
|
|
|
11797
11822
|
}
|
|
11798
11823
|
// clear application log from memory
|
|
11799
11824
|
this.applicationLogsData = [];
|
|
11800
|
-
// this.clearLogsFromLocalStorage(this.appLogs)
|
|
11801
|
-
// Logger.log("INFO", "Sync Application Logs to server")
|
|
11802
11825
|
}
|
|
11803
11826
|
catch (error) {
|
|
11804
11827
|
console.error("Error while sending logs to server:", error);
|
|
@@ -11808,18 +11831,15 @@ class Logger {
|
|
|
11808
11831
|
static sendLogsToServer() {
|
|
11809
11832
|
return __awaiter(this, void 0, void 0, function* () {
|
|
11810
11833
|
try {
|
|
11811
|
-
console.warn("Log sending to server...");
|
|
11812
|
-
// console.log("Log To Server : \n", this.logsData);
|
|
11813
11834
|
if (this.logsData.length === 0)
|
|
11814
11835
|
return;
|
|
11836
|
+
if (this.logsData.length === 0) {
|
|
11837
|
+
return;
|
|
11838
|
+
}
|
|
11815
11839
|
const accessToken = _DataStructures_Security_TokenStorage__WEBPACK_IMPORTED_MODULE_1__.TokenStorage.BearerAccessToken;
|
|
11816
|
-
const storedLogs = this.logsData;
|
|
11817
|
-
console.log("Package Logs for syncing... ", storedLogs);
|
|
11818
11840
|
if (!accessToken)
|
|
11819
11841
|
return;
|
|
11820
|
-
|
|
11821
|
-
if (storedLogs.length === 0)
|
|
11822
|
-
return;
|
|
11842
|
+
const storedLogs = this.logsData;
|
|
11823
11843
|
const chunkSize = 50;
|
|
11824
11844
|
for (let i = 0; i < storedLogs.length; i += chunkSize) {
|
|
11825
11845
|
const chunk = storedLogs.slice(i, i + chunkSize);
|
|
@@ -11842,8 +11862,6 @@ class Logger {
|
|
|
11842
11862
|
}
|
|
11843
11863
|
// clear mftsccs log from memory
|
|
11844
11864
|
this.logsData = [];
|
|
11845
|
-
// this.clearLogsFromLocalStorage(this.mftsccsBrowser)
|
|
11846
|
-
// Logger.log("INFO", "Sync Application Logs to server")
|
|
11847
11865
|
}
|
|
11848
11866
|
catch (error) {
|
|
11849
11867
|
console.error("Error while sending logs to server:", error);
|
|
@@ -11889,6 +11907,8 @@ Logger.SYNC_INTERVAL_MS = 120 * 1000; // 120 Sec
|
|
|
11889
11907
|
Logger.nextSyncTime = null;
|
|
11890
11908
|
Logger.appLogs = "app";
|
|
11891
11909
|
Logger.mftsccsBrowser = "mftsccs";
|
|
11910
|
+
Logger.logApplicationActivationStatus = false;
|
|
11911
|
+
Logger.logPackageActivationStatus = false;
|
|
11892
11912
|
// Private auto-sync interval management
|
|
11893
11913
|
Logger.autoSyncInterval = null;
|
|
11894
11914
|
// Ensure logs are managed automatically
|
|
@@ -11901,19 +11921,25 @@ Logger.autoSyncInterval = null;
|
|
|
11901
11921
|
* @returns Cookie value
|
|
11902
11922
|
*/
|
|
11903
11923
|
function getCookie(cname) {
|
|
11904
|
-
|
|
11905
|
-
|
|
11906
|
-
|
|
11907
|
-
|
|
11908
|
-
let
|
|
11909
|
-
|
|
11910
|
-
|
|
11911
|
-
|
|
11912
|
-
|
|
11913
|
-
|
|
11924
|
+
try {
|
|
11925
|
+
let name = cname + "=";
|
|
11926
|
+
let decodedCookie = decodeURIComponent(document.cookie);
|
|
11927
|
+
let ca = decodedCookie.split(';');
|
|
11928
|
+
for (let i = 0; i < ca.length; i++) {
|
|
11929
|
+
let c = ca[i];
|
|
11930
|
+
while (c.charAt(0) == ' ') {
|
|
11931
|
+
c = c.substring(1);
|
|
11932
|
+
}
|
|
11933
|
+
if (c.indexOf(name) == 0) {
|
|
11934
|
+
return c.substring(name.length, c.length);
|
|
11935
|
+
}
|
|
11914
11936
|
}
|
|
11937
|
+
return "";
|
|
11938
|
+
}
|
|
11939
|
+
catch (error) {
|
|
11940
|
+
console.error("Error on getcookie");
|
|
11941
|
+
return "";
|
|
11915
11942
|
}
|
|
11916
|
-
return "";
|
|
11917
11943
|
}
|
|
11918
11944
|
|
|
11919
11945
|
|
|
@@ -21993,7 +22019,7 @@ class WidgetTree {
|
|
|
21993
22019
|
this.version = 0;
|
|
21994
22020
|
this.mount_child = "";
|
|
21995
22021
|
this.children = [];
|
|
21996
|
-
this.wrapper = 0;
|
|
22022
|
+
this.wrapper = '0';
|
|
21997
22023
|
this.widget = new _BuilderStatefulWidget__WEBPACK_IMPORTED_MODULE_0__.BuilderStatefulWidget();
|
|
21998
22024
|
}
|
|
21999
22025
|
}
|
|
@@ -23180,12 +23206,14 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
23180
23206
|
/* harmony export */ getFromDatabaseWithType: () => (/* reexport safe */ _Database_NoIndexDb__WEBPACK_IMPORTED_MODULE_15__.getFromDatabaseWithType),
|
|
23181
23207
|
/* harmony export */ getObjectsFromIndexDb: () => (/* reexport safe */ _Database_NoIndexDb__WEBPACK_IMPORTED_MODULE_15__.getObjectsFromIndexDb),
|
|
23182
23208
|
/* harmony export */ handleServiceWorkerException: () => (/* binding */ handleServiceWorkerException),
|
|
23209
|
+
/* harmony export */ hasActivatedSW: () => (/* binding */ hasActivatedSW),
|
|
23183
23210
|
/* harmony export */ init: () => (/* binding */ init),
|
|
23184
23211
|
/* harmony export */ recursiveFetch: () => (/* reexport safe */ _Services_GetComposition__WEBPACK_IMPORTED_MODULE_7__.recursiveFetch),
|
|
23185
23212
|
/* harmony export */ recursiveFetchNew: () => (/* reexport safe */ _Services_Composition_BuildComposition__WEBPACK_IMPORTED_MODULE_45__.recursiveFetchNew),
|
|
23186
23213
|
/* harmony export */ searchLinkMultipleListener: () => (/* reexport safe */ _WrapperFunctions_SearchLinkMultipleAllObservable__WEBPACK_IMPORTED_MODULE_69__.searchLinkMultipleListener),
|
|
23187
23214
|
/* harmony export */ sendMessage: () => (/* binding */ sendMessage),
|
|
23188
23215
|
/* harmony export */ serviceWorker: () => (/* binding */ serviceWorker),
|
|
23216
|
+
/* harmony export */ setHasActivatedSW: () => (/* binding */ setHasActivatedSW),
|
|
23189
23217
|
/* harmony export */ storeToDatabase: () => (/* reexport safe */ _Database_NoIndexDb__WEBPACK_IMPORTED_MODULE_15__.storeToDatabase),
|
|
23190
23218
|
/* harmony export */ subscribedListeners: () => (/* binding */ subscribedListeners),
|
|
23191
23219
|
/* harmony export */ updateAccessToken: () => (/* binding */ updateAccessToken)
|
|
@@ -23444,6 +23472,7 @@ var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _argume
|
|
|
23444
23472
|
|
|
23445
23473
|
|
|
23446
23474
|
|
|
23475
|
+
|
|
23447
23476
|
|
|
23448
23477
|
|
|
23449
23478
|
var serviceWorker;
|
|
@@ -23451,6 +23480,10 @@ const TABID = Date.now().toString(36) + Math.random().toString(36).substring(2);
|
|
|
23451
23480
|
let subscribedListeners = [];
|
|
23452
23481
|
let serviceWorkerReady = false;
|
|
23453
23482
|
let messageQueue = [];
|
|
23483
|
+
// for sw use only START
|
|
23484
|
+
let hasActivatedSW = false;
|
|
23485
|
+
function setHasActivatedSW(value) { hasActivatedSW = value; }
|
|
23486
|
+
// for sw use only END
|
|
23454
23487
|
/**
|
|
23455
23488
|
* This function lets you update the access token that the package uses. If this is not passed you cannot create, update, view or delete
|
|
23456
23489
|
* Your concepts using this package.
|
|
@@ -23473,7 +23506,7 @@ function updateAccessToken(accessToken = "") {
|
|
|
23473
23506
|
* @param enableSW {activate: boolean, scope?: string, pathToSW?: string, manual?: boolean} | undefined - This is for enabling service worker with its scope
|
|
23474
23507
|
*/
|
|
23475
23508
|
function init() {
|
|
23476
|
-
return __awaiter(this, arguments, void 0, function* (url = "", aiurl = "", accessToken = "", nodeUrl = "", enableAi = true, applicationName = "", enableSW = undefined, flag = { logApplication: false, accessTracker: false, isTest: false }) {
|
|
23509
|
+
return __awaiter(this, arguments, void 0, function* (url = "", aiurl = "", accessToken = "", nodeUrl = "", enableAi = true, applicationName = "", enableSW = undefined, flag = { logApplication: false, logPackage: false, accessTracker: false, isTest: false }) {
|
|
23477
23510
|
try {
|
|
23478
23511
|
_DataStructures_BaseUrl__WEBPACK_IMPORTED_MODULE_98__.BaseUrl.BASE_URL = url;
|
|
23479
23512
|
_DataStructures_BaseUrl__WEBPACK_IMPORTED_MODULE_98__.BaseUrl.AI_URL = aiurl;
|
|
@@ -23496,19 +23529,31 @@ function init() {
|
|
|
23496
23529
|
_DataStructures_IdentifierFlags__WEBPACK_IMPORTED_MODULE_1__.IdentifierFlags.isLocalConnectionLoaded = true;
|
|
23497
23530
|
return true;
|
|
23498
23531
|
}
|
|
23499
|
-
|
|
23500
|
-
|
|
23501
|
-
|
|
23532
|
+
// Flag setup
|
|
23533
|
+
try {
|
|
23534
|
+
if (flag.logApplication) {
|
|
23535
|
+
_Middleware_ApplicationMonitor__WEBPACK_IMPORTED_MODULE_103__.ApplicationMonitor.initialize();
|
|
23536
|
+
_app__WEBPACK_IMPORTED_MODULE_105__.Logger.logApplicationActivationStatus = true;
|
|
23537
|
+
console.warn("Application log started...");
|
|
23538
|
+
}
|
|
23539
|
+
if (flag.logPackage) {
|
|
23540
|
+
_app__WEBPACK_IMPORTED_MODULE_105__.Logger.logPackageActivationStatus = true;
|
|
23541
|
+
console.warn("Package log started...");
|
|
23542
|
+
}
|
|
23543
|
+
if (flag.accessTracker) {
|
|
23544
|
+
_app__WEBPACK_IMPORTED_MODULE_105__.AccessTracker.activateStatus = true;
|
|
23545
|
+
console.warn("Access Tracker Activated...");
|
|
23546
|
+
}
|
|
23502
23547
|
}
|
|
23503
|
-
|
|
23504
|
-
|
|
23505
|
-
console.warn("Access Tracker Activated...");
|
|
23548
|
+
catch (error) {
|
|
23549
|
+
console.error("Flag setup failed in init");
|
|
23506
23550
|
}
|
|
23507
23551
|
if (!("serviceWorker" in navigator)) {
|
|
23508
23552
|
yield initConceptConnection();
|
|
23509
23553
|
console.warn("Service Worker not supported in this browser.");
|
|
23510
23554
|
return;
|
|
23511
23555
|
}
|
|
23556
|
+
listenPostMessagaes();
|
|
23512
23557
|
listenBroadCastMessages();
|
|
23513
23558
|
if (enableSW && enableSW.activate && enableSW.manual) {
|
|
23514
23559
|
yield new Promise((resolve, reject) => {
|
|
@@ -23574,48 +23619,45 @@ function init() {
|
|
|
23574
23619
|
.then((registration) => __awaiter(this, void 0, void 0, function* () {
|
|
23575
23620
|
console.log("Service Worker registered:", registration);
|
|
23576
23621
|
// If the service worker is already active, mark it as ready
|
|
23577
|
-
if (registration.active) {
|
|
23578
|
-
|
|
23579
|
-
|
|
23580
|
-
|
|
23581
|
-
|
|
23582
|
-
|
|
23583
|
-
|
|
23584
|
-
|
|
23585
|
-
|
|
23586
|
-
|
|
23587
|
-
|
|
23588
|
-
|
|
23589
|
-
|
|
23590
|
-
|
|
23591
|
-
|
|
23592
|
-
}
|
|
23593
|
-
|
|
23594
|
-
|
|
23595
|
-
|
|
23596
|
-
|
|
23597
|
-
|
|
23598
|
-
}, 5000);
|
|
23599
|
-
}
|
|
23622
|
+
// if (registration.active) {
|
|
23623
|
+
// serviceWorkerReady = true;
|
|
23624
|
+
// console.log("active sw");
|
|
23625
|
+
// serviceWorker = registration.active;
|
|
23626
|
+
// await sendMessage("init", {
|
|
23627
|
+
// url,
|
|
23628
|
+
// aiurl,
|
|
23629
|
+
// accessToken,
|
|
23630
|
+
// nodeUrl,
|
|
23631
|
+
// enableAi,
|
|
23632
|
+
// applicationName,
|
|
23633
|
+
// flag
|
|
23634
|
+
// });
|
|
23635
|
+
// processMessageQueue();
|
|
23636
|
+
// resolve();
|
|
23637
|
+
// } else {
|
|
23638
|
+
// // Handle if on state change didn't trigger
|
|
23639
|
+
// setTimeout(() => {
|
|
23640
|
+
// if (!success) reject("Not Completed Initialization");
|
|
23641
|
+
// }, 5000);
|
|
23642
|
+
// }
|
|
23600
23643
|
// state change
|
|
23601
|
-
if (registration.installing || registration.waiting || registration.active) {
|
|
23602
|
-
|
|
23603
|
-
|
|
23604
|
-
|
|
23605
|
-
|
|
23606
|
-
|
|
23607
|
-
|
|
23608
|
-
|
|
23609
|
-
|
|
23610
|
-
|
|
23611
|
-
|
|
23612
|
-
|
|
23613
|
-
|
|
23614
|
-
|
|
23615
|
-
|
|
23616
|
-
|
|
23617
|
-
|
|
23618
|
-
}
|
|
23644
|
+
// if (registration.installing || registration.waiting || registration.active) {
|
|
23645
|
+
// registration.addEventListener('statechange', async (event: any) => {
|
|
23646
|
+
// if (event?.target?.state === 'activating') {
|
|
23647
|
+
// serviceWorker = navigator.serviceWorker.controller
|
|
23648
|
+
// console.log('Service Worker is activating statechange');
|
|
23649
|
+
// await sendMessage("init", {
|
|
23650
|
+
// url,
|
|
23651
|
+
// aiurl,
|
|
23652
|
+
// accessToken,
|
|
23653
|
+
// nodeUrl,
|
|
23654
|
+
// enableAi,
|
|
23655
|
+
// applicationName,
|
|
23656
|
+
// flag
|
|
23657
|
+
// });
|
|
23658
|
+
// }
|
|
23659
|
+
// });
|
|
23660
|
+
// }
|
|
23619
23661
|
// Add Listeners before initializing the service worker
|
|
23620
23662
|
// Listen for updates to the service worker
|
|
23621
23663
|
console.log("update listen start");
|
|
@@ -23624,7 +23666,7 @@ function init() {
|
|
|
23624
23666
|
console.log("new worker", newWorker);
|
|
23625
23667
|
if (newWorker) {
|
|
23626
23668
|
newWorker.onstatechange = () => __awaiter(this, void 0, void 0, function* () {
|
|
23627
|
-
console.
|
|
23669
|
+
console.warn("on state change triggered", (newWorker.state === "installed" || newWorker.state === "activated" || newWorker.state === 'redundant'), navigator.serviceWorker.controller);
|
|
23628
23670
|
if (newWorker.state === "installing") {
|
|
23629
23671
|
console.log("Service Worker installing");
|
|
23630
23672
|
serviceWorker = undefined;
|
|
@@ -23659,7 +23701,7 @@ function init() {
|
|
|
23659
23701
|
console.warn('controller change triggered', navigator.serviceWorker.controller);
|
|
23660
23702
|
if (navigator.serviceWorker.controller) {
|
|
23661
23703
|
serviceWorker = navigator.serviceWorker.controller;
|
|
23662
|
-
console.
|
|
23704
|
+
console.warn('Service worker has been activated; controller change');
|
|
23663
23705
|
yield sendMessage("init", {
|
|
23664
23706
|
url,
|
|
23665
23707
|
aiurl,
|
|
@@ -23679,7 +23721,7 @@ function init() {
|
|
|
23679
23721
|
var _a;
|
|
23680
23722
|
if (((_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.state) === 'activating') {
|
|
23681
23723
|
serviceWorker = navigator.serviceWorker.controller;
|
|
23682
|
-
console.
|
|
23724
|
+
console.warn('Service Worker is activating statechange');
|
|
23683
23725
|
yield sendMessage("init", {
|
|
23684
23726
|
url,
|
|
23685
23727
|
aiurl,
|
|
@@ -23714,7 +23756,7 @@ function init() {
|
|
|
23714
23756
|
setTimeout(() => {
|
|
23715
23757
|
if (!success)
|
|
23716
23758
|
reject("Not Completed Initialization");
|
|
23717
|
-
},
|
|
23759
|
+
}, 10000);
|
|
23718
23760
|
}
|
|
23719
23761
|
}))
|
|
23720
23762
|
.catch((error) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -23762,6 +23804,7 @@ function sendMessage(type, payload) {
|
|
|
23762
23804
|
return new Promise((resolve, reject) => {
|
|
23763
23805
|
// navigator.serviceWorker.ready
|
|
23764
23806
|
// .then((registration) => {
|
|
23807
|
+
console.debug('debug', navigator.serviceWorker.controller, serviceWorker, serviceWorkerReady, type == 'init');
|
|
23765
23808
|
if ((navigator.serviceWorker.controller || serviceWorker) && (serviceWorkerReady || type == 'init')) {
|
|
23766
23809
|
const responseHandler = (event) => {
|
|
23767
23810
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -23800,7 +23843,7 @@ function sendMessage(type, payload) {
|
|
|
23800
23843
|
serviceWorker.postMessage({ type, payload: newPayload });
|
|
23801
23844
|
}
|
|
23802
23845
|
catch (err) {
|
|
23803
|
-
console.log(err);
|
|
23846
|
+
console.log('Retrying again on catch service worker', err);
|
|
23804
23847
|
// serviceWorker.postMessage({ type, payload: newPayload });
|
|
23805
23848
|
serviceWorker.postMessage({ type, payload: newPayload });
|
|
23806
23849
|
}
|
|
@@ -23810,6 +23853,7 @@ function sendMessage(type, payload) {
|
|
|
23810
23853
|
console.warn(`Service Worker hasn't loaded yet. messageId: ${messageId}, type: ${type}`);
|
|
23811
23854
|
if (serviceWorkerReady)
|
|
23812
23855
|
console.warn('service worker was registered already but is not available NOW!!!');
|
|
23856
|
+
console.info('ready', navigator.serviceWorker.ready);
|
|
23813
23857
|
// wait one second before checking again
|
|
23814
23858
|
setTimeout(() => {
|
|
23815
23859
|
console.warn(`Re-Trying after certain time. messageId: ${messageId}, type: ${type}`);
|
|
@@ -23829,7 +23873,7 @@ function sendMessage(type, payload) {
|
|
|
23829
23873
|
setTimeout(() => {
|
|
23830
23874
|
reject(`No response from service worker after timeout: ${type}`);
|
|
23831
23875
|
navigator.serviceWorker.removeEventListener("message", responseHandler);
|
|
23832
|
-
},
|
|
23876
|
+
}, 210000); // 3.5 minutes
|
|
23833
23877
|
}
|
|
23834
23878
|
else {
|
|
23835
23879
|
messageQueue.push({ message: { type, payload: newPayload } });
|
|
@@ -23904,7 +23948,47 @@ function listenBroadCastMessages() {
|
|
|
23904
23948
|
responseData = yield broadcastActions[type](payload);
|
|
23905
23949
|
}
|
|
23906
23950
|
else {
|
|
23907
|
-
console.
|
|
23951
|
+
console.warn(`Unable to handle "${type}" case in BC service worker`);
|
|
23952
|
+
}
|
|
23953
|
+
}));
|
|
23954
|
+
}
|
|
23955
|
+
/**
|
|
23956
|
+
* Method to trigger broadcast message listener
|
|
23957
|
+
*/
|
|
23958
|
+
function listenPostMessagaes() {
|
|
23959
|
+
// broadcast event can be listened through both the service worker and other tabs
|
|
23960
|
+
navigator.serviceWorker.addEventListener('message', (event) => __awaiter(this, void 0, void 0, function* () {
|
|
23961
|
+
var _a, _b, _c, _d;
|
|
23962
|
+
try {
|
|
23963
|
+
if (event.data && event.data.type === 'API_401') {
|
|
23964
|
+
const { requestDetails } = event.data;
|
|
23965
|
+
// Re-create the POST request with the same headers and body
|
|
23966
|
+
const requestOptions = {
|
|
23967
|
+
method: requestDetails.method,
|
|
23968
|
+
headers: new Headers(requestDetails.headers),
|
|
23969
|
+
body: requestDetails.body // Pass the original body
|
|
23970
|
+
};
|
|
23971
|
+
// Re-hit the API with the same details
|
|
23972
|
+
const apiResponse = yield fetch(requestDetails.url, requestOptions);
|
|
23973
|
+
const responseBody = yield (apiResponse === null || apiResponse === void 0 ? void 0 : apiResponse.json()); // Get the response text
|
|
23974
|
+
// Send the response back to the Service Worker (same client)
|
|
23975
|
+
(_b = (_a = navigator === null || navigator === void 0 ? void 0 : navigator.serviceWorker) === null || _a === void 0 ? void 0 : _a.controller) === null || _b === void 0 ? void 0 : _b.postMessage({
|
|
23976
|
+
type: 'API_RESPONSE',
|
|
23977
|
+
messageId: event.data.messageId,
|
|
23978
|
+
response: new Response(responseBody, {
|
|
23979
|
+
status: apiResponse.status,
|
|
23980
|
+
statusText: apiResponse.statusText,
|
|
23981
|
+
headers: apiResponse.headers
|
|
23982
|
+
})
|
|
23983
|
+
});
|
|
23984
|
+
}
|
|
23985
|
+
}
|
|
23986
|
+
catch (error) {
|
|
23987
|
+
console.error("Error during listenPostMessage", error);
|
|
23988
|
+
(_d = (_c = navigator === null || navigator === void 0 ? void 0 : navigator.serviceWorker) === null || _c === void 0 ? void 0 : _c.controller) === null || _d === void 0 ? void 0 : _d.postMessage({
|
|
23989
|
+
type: 'API_RESPONSE',
|
|
23990
|
+
messageId: event.data.messageId
|
|
23991
|
+
});
|
|
23908
23992
|
}
|
|
23909
23993
|
}));
|
|
23910
23994
|
}
|
|
@@ -24033,10 +24117,12 @@ function processMessageQueue() {
|
|
|
24033
24117
|
});
|
|
24034
24118
|
}
|
|
24035
24119
|
const handleServiceWorkerException = (error) => {
|
|
24120
|
+
// if (error instanceof FreeSchemaResponse && error.getStatus() != 401) {
|
|
24036
24121
|
if (error instanceof _DataStructures_Responses_ErrorResponse__WEBPACK_IMPORTED_MODULE_104__.FreeSchemaResponse) {
|
|
24037
24122
|
console.error('FreeSchemaResponse Error', error);
|
|
24038
24123
|
throw error;
|
|
24039
24124
|
}
|
|
24125
|
+
// if (error instanceof FreeSchemaResponse && error.getStatus() == 401) console.error('401 triggered in sw defaulting')
|
|
24040
24126
|
console.error('Service Worker Error', error);
|
|
24041
24127
|
};
|
|
24042
24128
|
|
|
@@ -24142,6 +24228,7 @@ self.addEventListener("install", (event) => {
|
|
|
24142
24228
|
});
|
|
24143
24229
|
// Activate Service Worker
|
|
24144
24230
|
self.addEventListener("activate", (event) => __awaiter(void 0, void 0, void 0, function* () {
|
|
24231
|
+
yield (0,_app__WEBPACK_IMPORTED_MODULE_0__.setHasActivatedSW)(true);
|
|
24145
24232
|
console.log("Service Worker activating... sw");
|
|
24146
24233
|
// Using event.waitUntil to wait for the Promise to resolve
|
|
24147
24234
|
event.waitUntil(new Promise((resolve, reject) => {
|
|
@@ -24160,28 +24247,12 @@ self.addEventListener("activate", (event) => __awaiter(void 0, void 0, void 0, f
|
|
|
24160
24247
|
}));
|
|
24161
24248
|
}));
|
|
24162
24249
|
// Handle 401 in service worker
|
|
24163
|
-
//
|
|
24164
|
-
|
|
24165
|
-
|
|
24166
|
-
|
|
24167
|
-
|
|
24168
|
-
|
|
24169
|
-
// event.source.postMessage({success: false, data: {status: 401, statusText: response.statusText}, messageId: event?.payload?.messageId})
|
|
24170
|
-
// // (self as any).clients.matchAll().then((clients: any) => {
|
|
24171
|
-
// // clients.forEach((client: any) => {
|
|
24172
|
-
// // client.postMessage({ type: 'auth-error', message: 'Unauthorized' });
|
|
24173
|
-
// // });
|
|
24174
|
-
// // });
|
|
24175
|
-
// }
|
|
24176
|
-
// return response;
|
|
24177
|
-
// })
|
|
24178
|
-
// .catch(error => {
|
|
24179
|
-
// console.error('Network error: ', error)
|
|
24180
|
-
// // Handle network errors
|
|
24181
|
-
// return new Response('Network error', { status: 500 });
|
|
24182
|
-
// })
|
|
24183
|
-
// );
|
|
24184
|
-
// });
|
|
24250
|
+
// Fetch event listener
|
|
24251
|
+
self.addEventListener('fetch', (event) => {
|
|
24252
|
+
if (!event.clientId) {
|
|
24253
|
+
event.respondWith(handleInterceptRequest(event));
|
|
24254
|
+
}
|
|
24255
|
+
});
|
|
24185
24256
|
// For Caching gives the event when fetch request is triggered
|
|
24186
24257
|
// self.addEventListener('fetch', (event: any) => {
|
|
24187
24258
|
// console.log('Fetching: sw', event.request.url);
|
|
@@ -24211,7 +24282,26 @@ self.addEventListener("message", (event) => __awaiter(void 0, void 0, void 0, fu
|
|
|
24211
24282
|
return;
|
|
24212
24283
|
if (type != 'init' && !checkSWInitialization()) {
|
|
24213
24284
|
console.warn('Message received before sw initialization', type);
|
|
24214
|
-
|
|
24285
|
+
// wait for init to complete
|
|
24286
|
+
yield new Promise((resolve) => {
|
|
24287
|
+
let count = 1;
|
|
24288
|
+
const interval = setInterval(() => {
|
|
24289
|
+
if (TSCCS_init) {
|
|
24290
|
+
clearInterval(interval);
|
|
24291
|
+
resolve(undefined);
|
|
24292
|
+
}
|
|
24293
|
+
else {
|
|
24294
|
+
console.warn(`Watring for init ${count}:`, type);
|
|
24295
|
+
}
|
|
24296
|
+
}, 200); // check every 200ms
|
|
24297
|
+
setTimeout(() => {
|
|
24298
|
+
console.warn('Tried waiting for init but couldn\'t complete in time: ', type);
|
|
24299
|
+
clearInterval(interval);
|
|
24300
|
+
resolve(undefined);
|
|
24301
|
+
}, 90000); // 1.5 minute
|
|
24302
|
+
});
|
|
24303
|
+
if (!TSCCS_init)
|
|
24304
|
+
event.source.postMessage(responseData);
|
|
24215
24305
|
}
|
|
24216
24306
|
if (!tabActionsMap.has(tabId))
|
|
24217
24307
|
tabActionsMap.set(tabId, { concepts: [], connections: [] });
|
|
@@ -24262,7 +24352,7 @@ self.addEventListener("message", (event) => __awaiter(void 0, void 0, void 0, fu
|
|
|
24262
24352
|
event.source.postMessage(responseData);
|
|
24263
24353
|
}
|
|
24264
24354
|
catch (error) {
|
|
24265
|
-
console.
|
|
24355
|
+
console.error('Service worker Message Handle Error: ', type, error);
|
|
24266
24356
|
if ((error === null || error === void 0 ? void 0 : error.status) == 401 || (error === null || error === void 0 ? void 0 : error.status) == 500) {
|
|
24267
24357
|
responseData = { success: false, data: { status: error.status, statusText: error === null || error === void 0 ? void 0 : error.url }, messageId: payload.messageId };
|
|
24268
24358
|
}
|
|
@@ -24400,6 +24490,74 @@ const checkSWInitialization = () => {
|
|
|
24400
24490
|
}
|
|
24401
24491
|
return true;
|
|
24402
24492
|
};
|
|
24493
|
+
// let refreshingToken = false;
|
|
24494
|
+
// let refreshTokenPromise;
|
|
24495
|
+
const handleInterceptRequest = (event) => __awaiter(void 0, void 0, void 0, function* () {
|
|
24496
|
+
try {
|
|
24497
|
+
const response = yield fetch(event.request);
|
|
24498
|
+
// If the response is 401 (Unauthorized), send it back to the main thread
|
|
24499
|
+
if (response.status === 401) {
|
|
24500
|
+
const messageId = Math.random().toString(36).substring(2);
|
|
24501
|
+
event.waitUntil(
|
|
24502
|
+
// (self as any).clients.matchAll().then((clients: any) => {
|
|
24503
|
+
// clients.forEach(async (client: any) => {
|
|
24504
|
+
// client.postMessage({
|
|
24505
|
+
event.source.postMessage({
|
|
24506
|
+
type: 'API_401',
|
|
24507
|
+
messageId,
|
|
24508
|
+
message: 'Unauthorized',
|
|
24509
|
+
payload: {
|
|
24510
|
+
method: event.request.method,
|
|
24511
|
+
url: event.request.url,
|
|
24512
|
+
headers: Array.from(event.request.headers.entries()), // Convert headers to array
|
|
24513
|
+
// body: await event.request.clone().text() // Clone and send the body
|
|
24514
|
+
body: yield event.request.clone().json() // Clone and send the body
|
|
24515
|
+
}
|
|
24516
|
+
})
|
|
24517
|
+
// });
|
|
24518
|
+
// })
|
|
24519
|
+
);
|
|
24520
|
+
// Wait for the main thread to send back the response
|
|
24521
|
+
const newResponse = yield new Promise((resolve) => {
|
|
24522
|
+
console.log('Re resolving 401', response.url);
|
|
24523
|
+
// fallback
|
|
24524
|
+
setTimeout(() => resolve(response), 60000); // 60 sec
|
|
24525
|
+
navigator.serviceWorker.addEventListener('message', (e) => {
|
|
24526
|
+
var _a, _b, _c;
|
|
24527
|
+
if (e.data && ((_a = e.data) === null || _a === void 0 ? void 0 : _a.messageId) == messageId && ((_b = e.data) === null || _b === void 0 ? void 0 : _b.type) === 'API_RESPONSE') {
|
|
24528
|
+
if ((_c = e === null || e === void 0 ? void 0 : e.data) === null || _c === void 0 ? void 0 : _c.response)
|
|
24529
|
+
resolve(e.data.response); // Resolve with the old response
|
|
24530
|
+
else {
|
|
24531
|
+
console.log('Unable to resolve re 401', response.url);
|
|
24532
|
+
resolve(response); // Resolve with the old response
|
|
24533
|
+
}
|
|
24534
|
+
}
|
|
24535
|
+
});
|
|
24536
|
+
});
|
|
24537
|
+
return newResponse; // Return the new response
|
|
24538
|
+
}
|
|
24539
|
+
// if (response.status == 401) {
|
|
24540
|
+
// if (!refreshingToken) {
|
|
24541
|
+
// refreshingToken = true;
|
|
24542
|
+
// refreshTokenPromise = refreshToken()
|
|
24543
|
+
// }
|
|
24544
|
+
// console.warn('Awating to perform token refresh')
|
|
24545
|
+
// // set options to update if need else not
|
|
24546
|
+
// setTimeout(() => {
|
|
24547
|
+
// return response
|
|
24548
|
+
// }, 30000) // return after 30 sec if unable to update token
|
|
24549
|
+
// await refreshingToken
|
|
24550
|
+
// const clonedRequest = event.request.clone()
|
|
24551
|
+
// clonedRequest.headers.set()
|
|
24552
|
+
// }
|
|
24553
|
+
// If no issues, return the response as is
|
|
24554
|
+
return response;
|
|
24555
|
+
}
|
|
24556
|
+
catch (error) {
|
|
24557
|
+
console.error('Error occured during 401 intercepting', error);
|
|
24558
|
+
throw error;
|
|
24559
|
+
}
|
|
24560
|
+
});
|
|
24403
24561
|
|
|
24404
24562
|
|
|
24405
24563
|
//# sourceMappingURL=serviceWorker.bundle.js.map
|