analytica.click 0.0.259 → 0.0.262
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.d.ts +0 -8
- package/dist/index.js +174 -131
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
@@ -216,14 +216,6 @@ declare module 'analytica.click/ui-npm/src/components/UserProvider/refreshToken'
|
|
216
216
|
logout: () => void;
|
217
217
|
}): Promise<User | undefined>;
|
218
218
|
|
219
|
-
}
|
220
|
-
declare module 'analytica.click/ui-npm/src/components/UserProvider/useGranularHook' {
|
221
|
-
import { DependencyList, EffectCallback } from 'react';
|
222
|
-
type HookWithDependencies<C, R> = (callback: C, deps: DependencyList) => R;
|
223
|
-
export const useGranularHook: <T extends HookWithDependencies<C, ReturnType<T>>, C>(hook: T, callback: C, primaryDeps: DependencyList, secondaryDeps: DependencyList) => ReturnType<T>;
|
224
|
-
export const useGranularEffect: (effect: EffectCallback, primaryDeps: DependencyList, secondaryDeps: DependencyList) => void;
|
225
|
-
export {};
|
226
|
-
|
227
219
|
}
|
228
220
|
declare module 'analytica.click/ui-npm/src/components/index' {
|
229
221
|
export * from 'analytica.click/ui-npm/src/components/AnalyticaConfig/index';
|
package/dist/index.js
CHANGED
@@ -36,7 +36,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
36
36
|
}
|
37
37
|
return to;
|
38
38
|
};
|
39
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
39
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
40
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
41
|
+
mod
|
42
|
+
));
|
40
43
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
41
44
|
var __async = (__this, __arguments, generator) => {
|
42
45
|
return new Promise((resolve, reject) => {
|
@@ -730,8 +733,17 @@ var require_ErrorBoundary = __commonJS({
|
|
730
733
|
if (notify) {
|
731
734
|
notify(hasError);
|
732
735
|
}
|
733
|
-
return react_1.default.createElement(
|
734
|
-
|
736
|
+
return react_1.default.createElement(
|
737
|
+
Modal_1.Modal,
|
738
|
+
{ open: true, setOpen: () => {
|
739
|
+
} },
|
740
|
+
react_1.default.createElement(
|
741
|
+
Base,
|
742
|
+
null,
|
743
|
+
"A fatal error has occurred - the admin has been notified.",
|
744
|
+
react_1.default.createElement("button", { type: "button", onClick: () => window.location.reload() }, "Press here to restart app")
|
745
|
+
)
|
746
|
+
);
|
735
747
|
}
|
736
748
|
return children;
|
737
749
|
}
|
@@ -903,7 +915,11 @@ var errorTrack = (_0) => __async(void 0, [_0], function* ({
|
|
903
915
|
}) {
|
904
916
|
var _a2;
|
905
917
|
if (isLocal) {
|
906
|
-
(0, import_log.debug)(
|
918
|
+
(0, import_log.debug)(
|
919
|
+
`local error tracking ignored:${data.data.message} ${JSON.stringify(
|
920
|
+
data
|
921
|
+
)}, to ${overrideBaseUrl}`
|
922
|
+
);
|
907
923
|
return {};
|
908
924
|
}
|
909
925
|
if (!(0, import_logsend.isValidLogMessage)((_a2 = data == null ? void 0 : data.data) == null ? void 0 : _a2.message)) {
|
@@ -920,6 +936,7 @@ var errorTrack = (_0) => __async(void 0, [_0], function* ({
|
|
920
936
|
|
921
937
|
// src/components/AnalyticaConfig/index.tsx
|
922
938
|
var import_react = __toESM(require("react"));
|
939
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
923
940
|
var stubState = {
|
924
941
|
analyticaToken: void 0,
|
925
942
|
overrideBaseUrl: void 0
|
@@ -959,9 +976,10 @@ var AnalyticaConfigProvider = ({
|
|
959
976
|
(0, import_react.useEffect)(() => {
|
960
977
|
overloadConsole(values);
|
961
978
|
}, []);
|
962
|
-
return /* @__PURE__ */
|
963
|
-
value: state
|
964
|
-
|
979
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AnalyticaConfigContext.Provider, {
|
980
|
+
value: state,
|
981
|
+
children
|
982
|
+
});
|
965
983
|
};
|
966
984
|
|
967
985
|
// src/helpers/log.ts
|
@@ -989,7 +1007,9 @@ var feedback = (_0) => __async(void 0, [_0], function* ({
|
|
989
1007
|
}) {
|
990
1008
|
var _a2;
|
991
1009
|
if (typeof window !== "undefined" && ((_a2 = window == null ? void 0 : window.location) == null ? void 0 : _a2.hostname) === "localhost") {
|
992
|
-
(0, import_log3.debug)(
|
1010
|
+
(0, import_log3.debug)(
|
1011
|
+
`local feedback ignored:${JSON.stringify(data)}, to ${overrideBaseUrl}`
|
1012
|
+
);
|
993
1013
|
return {};
|
994
1014
|
}
|
995
1015
|
(0, import_log3.debug)("feedback", JSON.stringify(data));
|
@@ -1003,7 +1023,9 @@ var feedback = (_0) => __async(void 0, [_0], function* ({
|
|
1003
1023
|
return {};
|
1004
1024
|
});
|
1005
1025
|
var useFeedback = () => {
|
1006
|
-
const { analyticaToken, overrideBaseUrl } = (0, import_react2.useContext)(
|
1026
|
+
const { analyticaToken, overrideBaseUrl } = (0, import_react2.useContext)(
|
1027
|
+
AnalyticaConfigContext
|
1028
|
+
);
|
1007
1029
|
if (!analyticaToken) {
|
1008
1030
|
(0, import_log3.warn)(tokenMissing("useFeedback"));
|
1009
1031
|
return { trackWithToken: () => ({ error: "no token" }) };
|
@@ -1109,7 +1131,9 @@ var page = (_0) => __async(void 0, [_0], function* ({
|
|
1109
1131
|
return track({ analyticaToken, userData, overrideBaseUrl, eventName: "PAGE" });
|
1110
1132
|
});
|
1111
1133
|
var useTrack = () => {
|
1112
|
-
const { analyticaToken, overrideBaseUrl } = (0, import_react3.useContext)(
|
1134
|
+
const { analyticaToken, overrideBaseUrl } = (0, import_react3.useContext)(
|
1135
|
+
AnalyticaConfigContext
|
1136
|
+
);
|
1113
1137
|
if (!analyticaToken) {
|
1114
1138
|
(0, import_log5.warn)(tokenMissing("useTrack"));
|
1115
1139
|
const def = () => __async(void 0, null, function* () {
|
@@ -1125,8 +1149,9 @@ var useTrack = () => {
|
|
1125
1149
|
|
1126
1150
|
// src/components/ErrorBoundary/index.tsx
|
1127
1151
|
var import_ErrorBoundary = __toESM(require_ErrorBoundary());
|
1128
|
-
var import_react4 =
|
1152
|
+
var import_react4 = require("react");
|
1129
1153
|
var import_log6 = require("ag-common/dist/common/helpers/log");
|
1154
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
1130
1155
|
function onBrowserError(_0) {
|
1131
1156
|
return __async(this, arguments, function* ({
|
1132
1157
|
ev,
|
@@ -1171,9 +1196,11 @@ var ErrorBoundary = ({
|
|
1171
1196
|
}, [analyticaToken, filterBrowserError]);
|
1172
1197
|
if (!analyticaToken) {
|
1173
1198
|
(0, import_log6.warn)(tokenMissing("ErrorBoundary"));
|
1174
|
-
return /* @__PURE__ */
|
1199
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
1200
|
+
children
|
1201
|
+
});
|
1175
1202
|
}
|
1176
|
-
return /* @__PURE__ */
|
1203
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ErrorBoundary.ErrorBoundary, {
|
1177
1204
|
notify: (data) => __async(void 0, null, function* () {
|
1178
1205
|
const { href } = window.location;
|
1179
1206
|
yield errorTrack({
|
@@ -1184,8 +1211,9 @@ var ErrorBoundary = ({
|
|
1184
1211
|
})
|
1185
1212
|
}
|
1186
1213
|
});
|
1187
|
-
})
|
1188
|
-
|
1214
|
+
}),
|
1215
|
+
children
|
1216
|
+
});
|
1189
1217
|
};
|
1190
1218
|
|
1191
1219
|
// src/components/ExternalComponent/index.tsx
|
@@ -1193,6 +1221,7 @@ var import_react5 = __toESM(require("react"));
|
|
1193
1221
|
var import_createRequires = require("@paciolan/remote-component/dist/createRequires");
|
1194
1222
|
var import_useRemoteComponent = require("@paciolan/remote-component/dist/hooks/useRemoteComponent");
|
1195
1223
|
var import_react_dom = __toESM(require("react-dom"));
|
1224
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
1196
1225
|
var styled = require("styled-components");
|
1197
1226
|
var cache = {};
|
1198
1227
|
var ExternalComponent = ({
|
@@ -1215,17 +1244,25 @@ var ExternalComponent = ({
|
|
1215
1244
|
if (!cache[url] && !loading && !error2 && Component) {
|
1216
1245
|
cache[url] = Component;
|
1217
1246
|
}
|
1218
|
-
return /* @__PURE__ */
|
1247
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
|
1248
|
+
children: [
|
1249
|
+
!loading && !error2 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, __spreadValues({}, props)),
|
1250
|
+
error2 && error2
|
1251
|
+
]
|
1252
|
+
});
|
1219
1253
|
};
|
1220
1254
|
|
1221
1255
|
// src/components/Feedback/index.tsx
|
1222
|
-
var import_react6 =
|
1256
|
+
var import_react6 = require("react");
|
1223
1257
|
var import_log7 = require("ag-common/dist/common/helpers/log");
|
1258
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
1224
1259
|
var Feedback = (props) => {
|
1225
|
-
const { analyticaToken, overrideBaseUrl, devMode } = (0, import_react6.useContext)(
|
1260
|
+
const { analyticaToken, overrideBaseUrl, devMode } = (0, import_react6.useContext)(
|
1261
|
+
AnalyticaConfigContext
|
1262
|
+
);
|
1226
1263
|
if (!analyticaToken) {
|
1227
1264
|
(0, import_log7.warn)(tokenMissing("Feedback"));
|
1228
|
-
return /* @__PURE__ */
|
1265
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {});
|
1229
1266
|
}
|
1230
1267
|
const int = __spreadProps(__spreadValues({}, props), {
|
1231
1268
|
submitFeedback: feedback,
|
@@ -1236,7 +1273,7 @@ var Feedback = (props) => {
|
|
1236
1273
|
if (devMode) {
|
1237
1274
|
url = `/feedback.js`;
|
1238
1275
|
}
|
1239
|
-
return /* @__PURE__ */
|
1276
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ExternalComponent, {
|
1240
1277
|
url,
|
1241
1278
|
props: int
|
1242
1279
|
});
|
@@ -1386,26 +1423,17 @@ function getTokensFromCode(_0) {
|
|
1386
1423
|
});
|
1387
1424
|
}
|
1388
1425
|
|
1389
|
-
// src/components/UserProvider/useGranularHook.ts
|
1390
|
-
var import_react7 = require("react");
|
1391
|
-
var useGranularHook = (hook, callback, primaryDeps, secondaryDeps) => {
|
1392
|
-
const ref = (0, import_react7.useRef)();
|
1393
|
-
if (!ref.current || !primaryDeps.every((w, i) => {
|
1394
|
-
var _a2;
|
1395
|
-
return Object.is(w, (_a2 = ref.current) == null ? void 0 : _a2[i]);
|
1396
|
-
}))
|
1397
|
-
ref.current = [...primaryDeps, ...secondaryDeps];
|
1398
|
-
return hook(callback, ref.current);
|
1399
|
-
};
|
1400
|
-
var useGranularEffect = (effect, primaryDeps, secondaryDeps) => useGranularHook(import_react7.useEffect, effect, primaryDeps, secondaryDeps);
|
1401
|
-
|
1402
1426
|
// src/components/UserProvider/index.tsx
|
1403
1427
|
var import_log9 = require("ag-common/dist/common/helpers/log");
|
1404
|
-
var
|
1428
|
+
var import_react7 = __toESM(require("react"));
|
1405
1429
|
var import_useLocalStorage = require("ag-common/dist/ui/helpers/useLocalStorage");
|
1406
1430
|
var import_cookie = require("ag-common/dist/ui/helpers/cookie");
|
1407
1431
|
var import_dom3 = __toESM(require_dom());
|
1408
|
-
var
|
1432
|
+
var import_useGranularHook = require("ag-common/dist/ui/helpers/useGranularHook");
|
1433
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
1434
|
+
var CognitoAuthContext = import_react7.default.createContext(
|
1435
|
+
void 0
|
1436
|
+
);
|
1409
1437
|
var getStatefulUrl = ({
|
1410
1438
|
redirectUrl,
|
1411
1439
|
qs
|
@@ -1435,7 +1463,7 @@ var CognitoAuthProvider = ({
|
|
1435
1463
|
cookieDocument
|
1436
1464
|
}) => {
|
1437
1465
|
var _a2, _b;
|
1438
|
-
const [error2, setError] = (0,
|
1466
|
+
const [error2, setError] = (0, import_react7.useState)();
|
1439
1467
|
const [idTokenRaw, setIdToken] = (0, import_cookie.useCookieString)({
|
1440
1468
|
name: "id_token",
|
1441
1469
|
cookieDocument: typeof window === "undefined" ? cookieDocument : void 0,
|
@@ -1456,7 +1484,7 @@ var CognitoAuthProvider = ({
|
|
1456
1484
|
setUserRaw(value2);
|
1457
1485
|
return;
|
1458
1486
|
};
|
1459
|
-
const [loading, setLoading] = (0,
|
1487
|
+
const [loading, setLoading] = (0, import_react7.useState)(false);
|
1460
1488
|
const qs = (0, import_dom3.extractQs)({
|
1461
1489
|
search: typeof window === "undefined" ? "" : window.location.search,
|
1462
1490
|
sanatise: false
|
@@ -1471,7 +1499,7 @@ var CognitoAuthProvider = ({
|
|
1471
1499
|
yield goToPageUrl({ url: location.origin, login: false });
|
1472
1500
|
setLoading(false);
|
1473
1501
|
});
|
1474
|
-
(0,
|
1502
|
+
(0, import_react7.useEffect)(() => {
|
1475
1503
|
var _a3;
|
1476
1504
|
const newT = (_a3 = user == null ? void 0 : user.jwt) == null ? void 0 : _a3.id_token;
|
1477
1505
|
if (!!newT && newT !== idToken) {
|
@@ -1497,87 +1525,93 @@ var CognitoAuthProvider = ({
|
|
1497
1525
|
login: true
|
1498
1526
|
});
|
1499
1527
|
});
|
1500
|
-
useGranularEffect(
|
1501
|
-
|
1502
|
-
|
1503
|
-
|
1504
|
-
|
1505
|
-
|
1506
|
-
|
1507
|
-
|
1508
|
-
|
1509
|
-
}
|
1510
|
-
try {
|
1511
|
-
setLoading(true);
|
1512
|
-
if (qs == null ? void 0 : qs.error) {
|
1513
|
-
const newerror = {
|
1514
|
-
message: (qs == null ? void 0 : qs.error_description) || "auth error"
|
1515
|
-
};
|
1516
|
-
if (JSON.stringify(newerror || {}) !== JSON.stringify(error2 || {})) {
|
1517
|
-
setError(newerror);
|
1518
|
-
}
|
1528
|
+
(0, import_useGranularHook.useGranularEffect)(
|
1529
|
+
() => {
|
1530
|
+
function run() {
|
1531
|
+
return __async(this, null, function* () {
|
1532
|
+
var _a3, _b2, _c, _d;
|
1533
|
+
const hasQs = !!(qs == null ? void 0 : qs.code) || !!(qs == null ? void 0 : qs.error);
|
1534
|
+
const expired = jwtExpired(user == null ? void 0 : user.jwt);
|
1535
|
+
const onlyJwt = !(user == null ? void 0 : user.userId) && !!(user == null ? void 0 : user.jwt);
|
1536
|
+
if (loading || error2 || ((_a3 = user == null ? void 0 : user.idJwt) == null ? void 0 : _a3.email) && !hasQs && !expired) {
|
1519
1537
|
return;
|
1520
1538
|
}
|
1521
|
-
|
1522
|
-
|
1523
|
-
|
1524
|
-
|
1525
|
-
|
1526
|
-
|
1527
|
-
|
1528
|
-
|
1529
|
-
|
1539
|
+
try {
|
1540
|
+
setLoading(true);
|
1541
|
+
if (qs == null ? void 0 : qs.error) {
|
1542
|
+
const newerror = {
|
1543
|
+
message: (qs == null ? void 0 : qs.error_description) || "auth error"
|
1544
|
+
};
|
1545
|
+
if (JSON.stringify(newerror || {}) !== JSON.stringify(error2 || {})) {
|
1546
|
+
setError(newerror);
|
1547
|
+
}
|
1548
|
+
return;
|
1549
|
+
}
|
1550
|
+
if ((qs == null ? void 0 : qs.code) && !expired) {
|
1551
|
+
yield goToPageUrl({ url: redirectUrl, login: false });
|
1552
|
+
return;
|
1553
|
+
}
|
1554
|
+
if (qs == null ? void 0 : qs.code) {
|
1555
|
+
if (expired) {
|
1556
|
+
yield getTokensFromCode({
|
1557
|
+
code: qs.code,
|
1558
|
+
redirectUrl,
|
1559
|
+
config,
|
1560
|
+
setUser
|
1561
|
+
});
|
1562
|
+
}
|
1563
|
+
yield goToPageUrl({
|
1564
|
+
url: getStatefulUrl({ redirectUrl, qs }),
|
1565
|
+
login: false
|
1566
|
+
});
|
1567
|
+
return;
|
1568
|
+
}
|
1569
|
+
if (expired && ((_b2 = user == null ? void 0 : user.jwt) == null ? void 0 : _b2.refresh_token)) {
|
1570
|
+
yield refreshToken({
|
1571
|
+
setUser,
|
1572
|
+
setError,
|
1573
|
+
user,
|
1530
1574
|
config,
|
1531
|
-
|
1575
|
+
logout
|
1532
1576
|
});
|
1577
|
+
return;
|
1533
1578
|
}
|
1534
|
-
|
1535
|
-
|
1536
|
-
|
1537
|
-
|
1538
|
-
|
1539
|
-
|
1540
|
-
|
1541
|
-
|
1542
|
-
|
1543
|
-
|
1544
|
-
|
1545
|
-
|
1546
|
-
|
1547
|
-
|
1548
|
-
return;
|
1549
|
-
}
|
1550
|
-
if (onlyJwt) {
|
1551
|
-
const token = (_d = (_c = user == null ? void 0 : user.jwt) == null ? void 0 : _c.id_token) == null ? void 0 : _d.substr(user.jwt.id_token.indexOf(" ") + 1);
|
1552
|
-
if (!user || !token) {
|
1553
|
-
(0, import_log9.info)("logging out no token");
|
1554
|
-
setUser(void 0);
|
1555
|
-
setError(void 0);
|
1556
|
-
} else {
|
1557
|
-
setUser(__spreadProps(__spreadValues({}, getUserFromIdToken(token)), {
|
1558
|
-
jwt: user.jwt,
|
1559
|
-
credentials: user.credentials
|
1560
|
-
}));
|
1579
|
+
if (onlyJwt) {
|
1580
|
+
const token = (_d = (_c = user == null ? void 0 : user.jwt) == null ? void 0 : _c.id_token) == null ? void 0 : _d.substr(
|
1581
|
+
user.jwt.id_token.indexOf(" ") + 1
|
1582
|
+
);
|
1583
|
+
if (!user || !token) {
|
1584
|
+
(0, import_log9.info)("logging out no token");
|
1585
|
+
setUser(void 0);
|
1586
|
+
setError(void 0);
|
1587
|
+
} else {
|
1588
|
+
setUser(__spreadProps(__spreadValues({}, getUserFromIdToken(token)), {
|
1589
|
+
jwt: user.jwt,
|
1590
|
+
credentials: user.credentials
|
1591
|
+
}));
|
1592
|
+
}
|
1561
1593
|
}
|
1594
|
+
} finally {
|
1595
|
+
setLoading(false);
|
1562
1596
|
}
|
1563
|
-
}
|
1564
|
-
|
1565
|
-
|
1566
|
-
|
1567
|
-
|
1568
|
-
|
1569
|
-
|
1570
|
-
|
1571
|
-
|
1572
|
-
|
1573
|
-
|
1574
|
-
|
1575
|
-
|
1576
|
-
|
1577
|
-
|
1578
|
-
|
1579
|
-
|
1580
|
-
(0,
|
1597
|
+
});
|
1598
|
+
}
|
1599
|
+
void run();
|
1600
|
+
},
|
1601
|
+
[user == null ? void 0 : user.jwt, qs],
|
1602
|
+
[
|
1603
|
+
config,
|
1604
|
+
error2,
|
1605
|
+
goToPageUrl,
|
1606
|
+
logout,
|
1607
|
+
loading,
|
1608
|
+
qs,
|
1609
|
+
redirectUrl,
|
1610
|
+
setUser,
|
1611
|
+
user
|
1612
|
+
]
|
1613
|
+
);
|
1614
|
+
(0, import_react7.useEffect)(() => {
|
1581
1615
|
var _a3;
|
1582
1616
|
if (error2) {
|
1583
1617
|
(0, import_log9.error)(JSON.stringify(error2));
|
@@ -1602,17 +1636,19 @@ var CognitoAuthProvider = ({
|
|
1602
1636
|
error: error2,
|
1603
1637
|
user
|
1604
1638
|
};
|
1605
|
-
return /* @__PURE__ */
|
1606
|
-
value
|
1607
|
-
|
1639
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CognitoAuthContext.Provider, {
|
1640
|
+
value,
|
1641
|
+
children
|
1642
|
+
});
|
1608
1643
|
};
|
1609
1644
|
|
1610
1645
|
// src/components/UserProvider/DashboardAuthValidation.tsx
|
1611
1646
|
var import_log10 = require("ag-common/dist/common/helpers/log");
|
1612
1647
|
var import_string = require("ag-common/dist/common/helpers/string");
|
1613
1648
|
var import_Loader = require("ag-common/dist/ui/components/Loader");
|
1649
|
+
var import_useGranularHook2 = require("ag-common/dist/ui/helpers/useGranularHook");
|
1614
1650
|
var import_useQueryString = require("ag-common/dist/ui/helpers/useQueryString");
|
1615
|
-
var
|
1651
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
1616
1652
|
var DashboardAuthValidation = ({
|
1617
1653
|
rc: { request, pushPath },
|
1618
1654
|
cac: {
|
@@ -1626,39 +1662,46 @@ var DashboardAuthValidation = ({
|
|
1626
1662
|
getUnauthedPage,
|
1627
1663
|
addToast
|
1628
1664
|
}) => {
|
1629
|
-
useGranularEffect(
|
1630
|
-
|
1631
|
-
|
1665
|
+
(0, import_useGranularHook2.useGranularEffect)(
|
1666
|
+
() => {
|
1667
|
+
if (authError) {
|
1668
|
+
const emailOption = authError.message.includes("email") ? ` We require the use of your email for the functionality of this app.
|
1632
1669
|
You can update your settings at https://www.facebook.com/settings?tab=applications` : "";
|
1633
|
-
|
1634
|
-
|
1635
|
-
|
1636
|
-
|
1637
|
-
|
1638
|
-
|
1639
|
-
|
1670
|
+
addToast(
|
1671
|
+
`An Error has occured with your login attempt.${emailOption}`,
|
1672
|
+
{
|
1673
|
+
appearance: "error"
|
1674
|
+
}
|
1675
|
+
);
|
1676
|
+
(0, import_log10.error)(`auth error:`, JSON.stringify(authError, null, 2));
|
1677
|
+
void logout();
|
1678
|
+
}
|
1679
|
+
},
|
1680
|
+
[authError],
|
1681
|
+
[authError, addToast, logout]
|
1682
|
+
);
|
1640
1683
|
const forceLogin = Object.keys(request.url.query || {}).includes("login");
|
1641
1684
|
if (forceLogin) {
|
1642
1685
|
if (!isAuthenticated) {
|
1643
1686
|
void loginWithRedirect(request.url.query.state);
|
1644
|
-
return { render: /* @__PURE__ */
|
1687
|
+
return { render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {}), openApiDisabled: true };
|
1645
1688
|
}
|
1646
1689
|
if (isAuthenticated) {
|
1647
1690
|
void pushPath(getDashboardPath());
|
1648
|
-
return { render: /* @__PURE__ */
|
1691
|
+
return { render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {}), openApiDisabled: true };
|
1649
1692
|
}
|
1650
1693
|
}
|
1651
1694
|
if (request.url.query.state && isAuthenticated) {
|
1652
1695
|
const decoded = JSON.parse((0, import_string.fromBase64)(request.url.query.state));
|
1653
1696
|
if (decoded.redirect) {
|
1654
1697
|
void pushPath(decoded.redirect);
|
1655
|
-
return { render: /* @__PURE__ */
|
1698
|
+
return { render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {}), openApiDisabled: true };
|
1656
1699
|
}
|
1657
1700
|
}
|
1658
1701
|
const serverAuthLoading = import_useQueryString.isServer && !authError && !authLoading && !isAuthenticated && Object.keys(request.url.query || {}).includes("code");
|
1659
1702
|
if (authLoading || serverAuthLoading) {
|
1660
1703
|
return {
|
1661
|
-
render: /* @__PURE__ */
|
1704
|
+
render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Loader.Loader, {
|
1662
1705
|
name: "authload"
|
1663
1706
|
}),
|
1664
1707
|
openApiDisabled: true
|
@@ -1666,7 +1709,7 @@ var DashboardAuthValidation = ({
|
|
1666
1709
|
}
|
1667
1710
|
if (!isAuthenticated && !authLoading && !authError && getUnauthedPage) {
|
1668
1711
|
void pushPath(getUnauthedPage());
|
1669
|
-
return { render: /* @__PURE__ */
|
1712
|
+
return { render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {}), openApiDisabled: true };
|
1670
1713
|
}
|
1671
1714
|
const openApiDisabled = !isAuthenticated || authLoading || !!authError;
|
1672
1715
|
return { openApiDisabled };
|