authscape 1.0.762 → 1.0.763
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/index.js +849 -181
- package/package.json +3 -3
- package/src/components/AuthScapeApp.js +459 -38
- package/src/services/apiService.js +50 -150
- package/src/services/authService.js +13 -2
- package/src/services/signInValidator.js +33 -5
package/index.js
CHANGED
|
@@ -4,9 +4,42 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.AuthScapeApp = AuthScapeApp;
|
|
7
|
+
Object.defineProperty(exports, "Bounce", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function get() {
|
|
10
|
+
return _reactToastify.Bounce;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(exports, "Flip", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function get() {
|
|
16
|
+
return _reactToastify.Flip;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "Slide", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function get() {
|
|
22
|
+
return _reactToastify.Slide;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(exports, "Zoom", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function get() {
|
|
28
|
+
return _reactToastify.Zoom;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
exports.logError = logError;
|
|
32
|
+
exports.setErrorTrackingUserId = setErrorTrackingUserId;
|
|
33
|
+
Object.defineProperty(exports, "toast", {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
get: function get() {
|
|
36
|
+
return _reactToastify.toast;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
exports.useAppTheme = void 0;
|
|
40
|
+
exports.useNotifications = useNotifications;
|
|
7
41
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
42
|
var _reactToastify = require("react-toastify");
|
|
9
|
-
var _styles = require("@mui/material/styles");
|
|
10
43
|
var _head = _interopRequireDefault(require("next/head"));
|
|
11
44
|
var _navigation = require("next/navigation");
|
|
12
45
|
var _axios = _interopRequireDefault(require("axios"));
|
|
@@ -15,36 +48,641 @@ var _router = _interopRequireDefault(require("next/router"));
|
|
|
15
48
|
var _ga4React = _interopRequireDefault(require("ga-4-react"));
|
|
16
49
|
var _zustand = require("zustand");
|
|
17
50
|
var _reactMicrosoftClarity = require("react-microsoft-clarity");
|
|
51
|
+
var _styles = require("@mui/material/styles");
|
|
52
|
+
var _CssBaseline = _interopRequireDefault(require("@mui/material/CssBaseline"));
|
|
53
|
+
var _signalr = require("@microsoft/signalr");
|
|
54
|
+
var _jsCookie = _interopRequireDefault(require("js-cookie"));
|
|
18
55
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
19
56
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
20
57
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
21
58
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
59
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
60
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
61
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
62
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
63
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
22
64
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
23
|
-
function
|
|
24
|
-
function
|
|
65
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
66
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
67
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
68
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
69
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
25
70
|
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
26
71
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
27
72
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
28
73
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
29
74
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
30
75
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
31
|
-
function
|
|
32
|
-
//
|
|
33
|
-
//
|
|
34
|
-
//
|
|
76
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
77
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; } // Re-export toast and transitions so pages can import from authscape
|
|
78
|
+
// ============================================================================
|
|
79
|
+
// Cookie utility function
|
|
80
|
+
// ============================================================================
|
|
81
|
+
var setCookie = function setCookie(name, value) {
|
|
82
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
83
|
+
return new Promise(function (resolve) {
|
|
84
|
+
var cookieString = "".concat(name, "=").concat(value, ";");
|
|
85
|
+
if (options.maxAge) cookieString += "max-age=".concat(options.maxAge, ";");
|
|
86
|
+
if (options.path) cookieString += "path=".concat(options.path, ";");
|
|
87
|
+
if (options.domain) cookieString += "domain=".concat(options.domain, ";");
|
|
88
|
+
if (options.secure) cookieString += "secure;";
|
|
89
|
+
document.cookie = cookieString;
|
|
90
|
+
resolve();
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
// ============================================================================
|
|
95
|
+
// Error Tracking Service
|
|
96
|
+
// ============================================================================
|
|
97
|
+
var errorTrackingSessionId = null;
|
|
98
|
+
var errorTrackingUserId = null;
|
|
99
|
+
var errorTrackingInitialized = false;
|
|
100
|
+
function generateGuid() {
|
|
101
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
102
|
+
var r = Math.random() * 16 | 0;
|
|
103
|
+
var v = c === 'x' ? r : r & 0x3 | 0x8;
|
|
104
|
+
return v.toString(16);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
function getOrCreateSessionId() {
|
|
108
|
+
if (typeof window === 'undefined') return null;
|
|
109
|
+
var storedSessionId = sessionStorage.getItem('errorTrackingSessionId');
|
|
110
|
+
if (!storedSessionId) {
|
|
111
|
+
storedSessionId = sessionStorage.getItem('analyticsSessionId') || generateGuid();
|
|
112
|
+
sessionStorage.setItem('errorTrackingSessionId', storedSessionId);
|
|
113
|
+
}
|
|
114
|
+
return storedSessionId;
|
|
115
|
+
}
|
|
116
|
+
function initializeErrorTracking() {
|
|
117
|
+
var currentUser = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
118
|
+
if (currentUser && currentUser.id) {
|
|
119
|
+
errorTrackingUserId = currentUser.id;
|
|
120
|
+
}
|
|
121
|
+
errorTrackingSessionId = getOrCreateSessionId();
|
|
122
|
+
errorTrackingInitialized = true;
|
|
123
|
+
}
|
|
124
|
+
function logError(_x) {
|
|
125
|
+
return _logError.apply(this, arguments);
|
|
126
|
+
}
|
|
127
|
+
function _logError() {
|
|
128
|
+
_logError = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(errorData) {
|
|
129
|
+
var error, response;
|
|
130
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
131
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
132
|
+
case 0:
|
|
133
|
+
if (!errorTrackingSessionId && typeof window !== 'undefined') {
|
|
134
|
+
errorTrackingSessionId = getOrCreateSessionId();
|
|
135
|
+
}
|
|
136
|
+
error = {
|
|
137
|
+
message: errorData.message || 'Unknown error',
|
|
138
|
+
errorType: errorData.errorType || 'JavaScriptError',
|
|
139
|
+
stackTrace: errorData.stackTrace || '',
|
|
140
|
+
url: errorData.url || (typeof window !== 'undefined' ? window.location.href : ''),
|
|
141
|
+
componentName: errorData.componentName || null,
|
|
142
|
+
userId: errorTrackingUserId || null,
|
|
143
|
+
sessionId: errorTrackingSessionId || null,
|
|
144
|
+
userAgent: typeof navigator !== 'undefined' ? navigator.userAgent : null,
|
|
145
|
+
ipAddress: '',
|
|
146
|
+
metadata: errorData.metadata || null
|
|
147
|
+
};
|
|
148
|
+
_context10.prev = 2;
|
|
149
|
+
_context10.next = 5;
|
|
150
|
+
return module.exports.apiService().post('/ErrorTracking/LogError', error);
|
|
151
|
+
case 5:
|
|
152
|
+
response = _context10.sent;
|
|
153
|
+
if (response && response.status !== 200) {
|
|
154
|
+
console.error('Error tracking API returned:', response.status);
|
|
155
|
+
}
|
|
156
|
+
_context10.next = 12;
|
|
157
|
+
break;
|
|
158
|
+
case 9:
|
|
159
|
+
_context10.prev = 9;
|
|
160
|
+
_context10.t0 = _context10["catch"](2);
|
|
161
|
+
console.error('Failed to send error to tracking system:', _context10.t0.message);
|
|
162
|
+
case 12:
|
|
163
|
+
case "end":
|
|
164
|
+
return _context10.stop();
|
|
165
|
+
}
|
|
166
|
+
}, _callee10, null, [[2, 9]]);
|
|
167
|
+
}));
|
|
168
|
+
return _logError.apply(this, arguments);
|
|
169
|
+
}
|
|
170
|
+
function setErrorTrackingUserId(newUserId) {
|
|
171
|
+
errorTrackingUserId = newUserId;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// ============================================================================
|
|
175
|
+
// AppThemeProvider
|
|
176
|
+
// ============================================================================
|
|
177
|
+
var ThemeContext = /*#__PURE__*/(0, _react.createContext)();
|
|
178
|
+
var useAppTheme = exports.useAppTheme = function useAppTheme() {
|
|
179
|
+
var context = (0, _react.useContext)(ThemeContext);
|
|
180
|
+
if (!context) {
|
|
181
|
+
return {
|
|
182
|
+
mode: 'light',
|
|
183
|
+
toggleTheme: function toggleTheme() {}
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
return context;
|
|
187
|
+
};
|
|
188
|
+
var AppThemeProvider = function AppThemeProvider(_ref) {
|
|
189
|
+
var children = _ref.children,
|
|
190
|
+
customTheme = _ref.customTheme;
|
|
191
|
+
var _useState = (0, _react.useState)('light'),
|
|
192
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
193
|
+
mode = _useState2[0],
|
|
194
|
+
setMode = _useState2[1];
|
|
195
|
+
(0, _react.useEffect)(function () {
|
|
196
|
+
if (typeof window !== 'undefined') {
|
|
197
|
+
var savedMode = localStorage.getItem('themeMode');
|
|
198
|
+
if (savedMode) {
|
|
199
|
+
setMode(savedMode);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}, []);
|
|
203
|
+
(0, _react.useEffect)(function () {
|
|
204
|
+
if (typeof document !== 'undefined') {
|
|
205
|
+
document.documentElement.setAttribute('data-theme', mode);
|
|
206
|
+
}
|
|
207
|
+
}, [mode]);
|
|
208
|
+
var toggleTheme = function toggleTheme() {
|
|
209
|
+
var newMode = mode === 'light' ? 'dark' : 'light';
|
|
210
|
+
setMode(newMode);
|
|
211
|
+
if (typeof window !== 'undefined') {
|
|
212
|
+
localStorage.setItem('themeMode', newMode);
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
var theme = customTheme || (0, _styles.createTheme)({
|
|
216
|
+
palette: _objectSpread({
|
|
217
|
+
mode: mode
|
|
218
|
+
}, mode === 'light' ? {
|
|
219
|
+
primary: {
|
|
220
|
+
main: '#0098e5',
|
|
221
|
+
light: '#4db8ff',
|
|
222
|
+
dark: '#006ba6'
|
|
223
|
+
},
|
|
224
|
+
secondary: {
|
|
225
|
+
main: '#44596e',
|
|
226
|
+
light: '#6b7f94',
|
|
227
|
+
dark: '#2d3d4f'
|
|
228
|
+
},
|
|
229
|
+
background: {
|
|
230
|
+
"default": '#f5f8fa',
|
|
231
|
+
paper: '#ffffff'
|
|
232
|
+
},
|
|
233
|
+
text: {
|
|
234
|
+
primary: '#1a202c',
|
|
235
|
+
secondary: '#4a5568'
|
|
236
|
+
},
|
|
237
|
+
divider: 'rgba(0, 0, 0, 0.12)'
|
|
238
|
+
} : {
|
|
239
|
+
primary: {
|
|
240
|
+
main: '#2196f3',
|
|
241
|
+
light: '#42a5f5',
|
|
242
|
+
dark: '#1976d2'
|
|
243
|
+
},
|
|
244
|
+
secondary: {
|
|
245
|
+
main: '#90caf9',
|
|
246
|
+
light: '#bbdefb',
|
|
247
|
+
dark: '#42a5f5'
|
|
248
|
+
},
|
|
249
|
+
background: {
|
|
250
|
+
"default": '#121212',
|
|
251
|
+
paper: '#1e1e1e'
|
|
252
|
+
},
|
|
253
|
+
text: {
|
|
254
|
+
primary: '#ffffff',
|
|
255
|
+
secondary: '#b0b0b0'
|
|
256
|
+
},
|
|
257
|
+
divider: 'rgba(255, 255, 255, 0.12)',
|
|
258
|
+
action: {
|
|
259
|
+
hover: 'rgba(255, 255, 255, 0.08)',
|
|
260
|
+
selected: 'rgba(255, 255, 255, 0.16)'
|
|
261
|
+
}
|
|
262
|
+
}),
|
|
263
|
+
typography: {
|
|
264
|
+
fontFamily: 'Poppins, sans-serif'
|
|
265
|
+
},
|
|
266
|
+
components: {
|
|
267
|
+
MuiPaper: {
|
|
268
|
+
styleOverrides: {
|
|
269
|
+
root: _objectSpread({
|
|
270
|
+
backgroundImage: 'none'
|
|
271
|
+
}, mode === 'dark' && {
|
|
272
|
+
backgroundColor: '#1e1e1e',
|
|
273
|
+
boxShadow: '0 2px 8px rgba(0, 0, 0, 0.4)'
|
|
274
|
+
})
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
MuiTextField: {
|
|
278
|
+
styleOverrides: {
|
|
279
|
+
root: {
|
|
280
|
+
'& .MuiOutlinedInput-root': _objectSpread({}, mode === 'dark' && {
|
|
281
|
+
'& fieldset': {
|
|
282
|
+
borderColor: 'rgba(255, 255, 255, 0.23)'
|
|
283
|
+
},
|
|
284
|
+
'&:hover fieldset': {
|
|
285
|
+
borderColor: 'rgba(255, 255, 255, 0.4)'
|
|
286
|
+
},
|
|
287
|
+
'&.Mui-focused fieldset': {
|
|
288
|
+
borderColor: '#2196f3'
|
|
289
|
+
}
|
|
290
|
+
})
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
},
|
|
294
|
+
MuiChip: {
|
|
295
|
+
styleOverrides: {
|
|
296
|
+
root: _objectSpread({}, mode === 'dark' && {
|
|
297
|
+
borderColor: 'rgba(255, 255, 255, 0.23)'
|
|
298
|
+
})
|
|
299
|
+
}
|
|
300
|
+
},
|
|
301
|
+
MuiDivider: {
|
|
302
|
+
styleOverrides: {
|
|
303
|
+
root: _objectSpread({}, mode === 'dark' && {
|
|
304
|
+
borderColor: 'rgba(255, 255, 255, 0.12)'
|
|
305
|
+
})
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
return /*#__PURE__*/_react["default"].createElement(ThemeContext.Provider, {
|
|
311
|
+
value: {
|
|
312
|
+
mode: mode,
|
|
313
|
+
toggleTheme: toggleTheme
|
|
314
|
+
}
|
|
315
|
+
}, /*#__PURE__*/_react["default"].createElement(_styles.ThemeProvider, {
|
|
316
|
+
theme: theme
|
|
317
|
+
}, /*#__PURE__*/_react["default"].createElement(_CssBaseline["default"]), children));
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
// ============================================================================
|
|
321
|
+
// NotificationProvider
|
|
322
|
+
// ============================================================================
|
|
323
|
+
var NotificationContext = /*#__PURE__*/(0, _react.createContext)();
|
|
324
|
+
var globalConnection = null;
|
|
325
|
+
var globalUserId = null;
|
|
326
|
+
var globalIsInitialized = false;
|
|
327
|
+
function useNotifications() {
|
|
328
|
+
var context = (0, _react.useContext)(NotificationContext);
|
|
329
|
+
if (!context) {
|
|
330
|
+
return {
|
|
331
|
+
notifications: [],
|
|
332
|
+
unreadCount: 0,
|
|
333
|
+
isConnected: false,
|
|
334
|
+
markAsRead: function markAsRead() {},
|
|
335
|
+
markAllAsRead: function markAllAsRead() {},
|
|
336
|
+
deleteNotification: function deleteNotification() {},
|
|
337
|
+
clearAll: function clearAll() {},
|
|
338
|
+
refresh: function refresh() {}
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
return context;
|
|
342
|
+
}
|
|
343
|
+
function NotificationProvider(_ref2) {
|
|
344
|
+
var children = _ref2.children,
|
|
345
|
+
currentUser = _ref2.currentUser,
|
|
346
|
+
apiService = _ref2.apiService;
|
|
347
|
+
var _useState3 = (0, _react.useState)([]),
|
|
348
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
349
|
+
notifications = _useState4[0],
|
|
350
|
+
setNotifications = _useState4[1];
|
|
351
|
+
var _useState5 = (0, _react.useState)(0),
|
|
352
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
353
|
+
unreadCount = _useState6[0],
|
|
354
|
+
setUnreadCount = _useState6[1];
|
|
355
|
+
var _useState7 = (0, _react.useState)(false),
|
|
356
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
357
|
+
isConnected = _useState8[0],
|
|
358
|
+
setIsConnected = _useState8[1];
|
|
359
|
+
var markAsRead = (0, _react.useCallback)(/*#__PURE__*/function () {
|
|
360
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(notificationId) {
|
|
361
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
362
|
+
while (1) switch (_context.prev = _context.next) {
|
|
363
|
+
case 0:
|
|
364
|
+
_context.prev = 0;
|
|
365
|
+
_context.next = 3;
|
|
366
|
+
return apiService().post('/Notification/MarkAsRead', {
|
|
367
|
+
notificationId: notificationId
|
|
368
|
+
});
|
|
369
|
+
case 3:
|
|
370
|
+
setNotifications(function (prev) {
|
|
371
|
+
return prev.map(function (n) {
|
|
372
|
+
return n.id === notificationId ? _objectSpread(_objectSpread({}, n), {}, {
|
|
373
|
+
isRead: true,
|
|
374
|
+
readAt: new Date()
|
|
375
|
+
}) : n;
|
|
376
|
+
});
|
|
377
|
+
});
|
|
378
|
+
setUnreadCount(function (prev) {
|
|
379
|
+
return Math.max(0, prev - 1);
|
|
380
|
+
});
|
|
381
|
+
_context.next = 10;
|
|
382
|
+
break;
|
|
383
|
+
case 7:
|
|
384
|
+
_context.prev = 7;
|
|
385
|
+
_context.t0 = _context["catch"](0);
|
|
386
|
+
console.error('Failed to mark as read:', _context.t0);
|
|
387
|
+
case 10:
|
|
388
|
+
case "end":
|
|
389
|
+
return _context.stop();
|
|
390
|
+
}
|
|
391
|
+
}, _callee, null, [[0, 7]]);
|
|
392
|
+
}));
|
|
393
|
+
return function (_x2) {
|
|
394
|
+
return _ref3.apply(this, arguments);
|
|
395
|
+
};
|
|
396
|
+
}(), [apiService]);
|
|
397
|
+
var markAllAsRead = (0, _react.useCallback)(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
398
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
399
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
400
|
+
case 0:
|
|
401
|
+
_context2.prev = 0;
|
|
402
|
+
_context2.next = 3;
|
|
403
|
+
return apiService().post('/Notification/MarkAllAsRead');
|
|
404
|
+
case 3:
|
|
405
|
+
setNotifications(function (prev) {
|
|
406
|
+
return prev.map(function (n) {
|
|
407
|
+
return _objectSpread(_objectSpread({}, n), {}, {
|
|
408
|
+
isRead: true,
|
|
409
|
+
readAt: new Date()
|
|
410
|
+
});
|
|
411
|
+
});
|
|
412
|
+
});
|
|
413
|
+
setUnreadCount(0);
|
|
414
|
+
_context2.next = 10;
|
|
415
|
+
break;
|
|
416
|
+
case 7:
|
|
417
|
+
_context2.prev = 7;
|
|
418
|
+
_context2.t0 = _context2["catch"](0);
|
|
419
|
+
console.error('Failed to mark all as read:', _context2.t0);
|
|
420
|
+
case 10:
|
|
421
|
+
case "end":
|
|
422
|
+
return _context2.stop();
|
|
423
|
+
}
|
|
424
|
+
}, _callee2, null, [[0, 7]]);
|
|
425
|
+
})), [apiService]);
|
|
426
|
+
var deleteNotification = (0, _react.useCallback)(/*#__PURE__*/function () {
|
|
427
|
+
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(notificationId) {
|
|
428
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
429
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
430
|
+
case 0:
|
|
431
|
+
_context3.prev = 0;
|
|
432
|
+
_context3.next = 3;
|
|
433
|
+
return apiService()["delete"]("/Notification/DeleteNotification?id=".concat(notificationId));
|
|
434
|
+
case 3:
|
|
435
|
+
setNotifications(function (prev) {
|
|
436
|
+
var notification = prev.find(function (n) {
|
|
437
|
+
return n.id === notificationId;
|
|
438
|
+
});
|
|
439
|
+
if (notification && !notification.isRead) {
|
|
440
|
+
setUnreadCount(function (count) {
|
|
441
|
+
return Math.max(0, count - 1);
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
return prev.filter(function (n) {
|
|
445
|
+
return n.id !== notificationId;
|
|
446
|
+
});
|
|
447
|
+
});
|
|
448
|
+
_context3.next = 9;
|
|
449
|
+
break;
|
|
450
|
+
case 6:
|
|
451
|
+
_context3.prev = 6;
|
|
452
|
+
_context3.t0 = _context3["catch"](0);
|
|
453
|
+
console.error('Failed to delete notification:', _context3.t0);
|
|
454
|
+
case 9:
|
|
455
|
+
case "end":
|
|
456
|
+
return _context3.stop();
|
|
457
|
+
}
|
|
458
|
+
}, _callee3, null, [[0, 6]]);
|
|
459
|
+
}));
|
|
460
|
+
return function (_x3) {
|
|
461
|
+
return _ref5.apply(this, arguments);
|
|
462
|
+
};
|
|
463
|
+
}(), [apiService]);
|
|
464
|
+
var clearAll = (0, _react.useCallback)(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
465
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
466
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
467
|
+
case 0:
|
|
468
|
+
_context4.prev = 0;
|
|
469
|
+
_context4.next = 3;
|
|
470
|
+
return apiService()["delete"]('/Notification/ClearAllNotifications');
|
|
471
|
+
case 3:
|
|
472
|
+
setNotifications([]);
|
|
473
|
+
setUnreadCount(0);
|
|
474
|
+
_context4.next = 10;
|
|
475
|
+
break;
|
|
476
|
+
case 7:
|
|
477
|
+
_context4.prev = 7;
|
|
478
|
+
_context4.t0 = _context4["catch"](0);
|
|
479
|
+
console.error('Failed to clear notifications:', _context4.t0);
|
|
480
|
+
case 10:
|
|
481
|
+
case "end":
|
|
482
|
+
return _context4.stop();
|
|
483
|
+
}
|
|
484
|
+
}, _callee4, null, [[0, 7]]);
|
|
485
|
+
})), [apiService]);
|
|
486
|
+
var fetchNotifications = (0, _react.useCallback)(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
487
|
+
var _yield$Promise$all, _yield$Promise$all2, notifResponse, countResponse;
|
|
488
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
489
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
490
|
+
case 0:
|
|
491
|
+
_context5.prev = 0;
|
|
492
|
+
_context5.next = 3;
|
|
493
|
+
return Promise.all([apiService().get('/Notification/GetNotifications?unreadOnly=false&take=50'), apiService().get('/Notification/GetUnreadCount')]);
|
|
494
|
+
case 3:
|
|
495
|
+
_yield$Promise$all = _context5.sent;
|
|
496
|
+
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
|
|
497
|
+
notifResponse = _yield$Promise$all2[0];
|
|
498
|
+
countResponse = _yield$Promise$all2[1];
|
|
499
|
+
if (notifResponse.status === 200) {
|
|
500
|
+
setNotifications(notifResponse.data);
|
|
501
|
+
}
|
|
502
|
+
if (countResponse.status === 200) {
|
|
503
|
+
setUnreadCount(countResponse.data.count);
|
|
504
|
+
}
|
|
505
|
+
_context5.next = 14;
|
|
506
|
+
break;
|
|
507
|
+
case 11:
|
|
508
|
+
_context5.prev = 11;
|
|
509
|
+
_context5.t0 = _context5["catch"](0);
|
|
510
|
+
console.error('Failed to fetch notifications:', _context5.t0);
|
|
511
|
+
case 14:
|
|
512
|
+
case "end":
|
|
513
|
+
return _context5.stop();
|
|
514
|
+
}
|
|
515
|
+
}, _callee5, null, [[0, 11]]);
|
|
516
|
+
})), [apiService]);
|
|
517
|
+
(0, _react.useEffect)(function () {
|
|
518
|
+
var userId = currentUser === null || currentUser === void 0 ? void 0 : currentUser.id;
|
|
519
|
+
if (!userId) return;
|
|
520
|
+
var fetchData = /*#__PURE__*/function () {
|
|
521
|
+
var _ref8 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
522
|
+
var _yield$Promise$all3, _yield$Promise$all4, notifResponse, countResponse;
|
|
523
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
524
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
525
|
+
case 0:
|
|
526
|
+
_context6.prev = 0;
|
|
527
|
+
_context6.next = 3;
|
|
528
|
+
return Promise.all([apiService().get('/Notification/GetNotifications?unreadOnly=false&take=50'), apiService().get('/Notification/GetUnreadCount')]);
|
|
529
|
+
case 3:
|
|
530
|
+
_yield$Promise$all3 = _context6.sent;
|
|
531
|
+
_yield$Promise$all4 = _slicedToArray(_yield$Promise$all3, 2);
|
|
532
|
+
notifResponse = _yield$Promise$all4[0];
|
|
533
|
+
countResponse = _yield$Promise$all4[1];
|
|
534
|
+
if (notifResponse.status === 200) {
|
|
535
|
+
setNotifications(notifResponse.data);
|
|
536
|
+
}
|
|
537
|
+
if (countResponse.status === 200) {
|
|
538
|
+
setUnreadCount(countResponse.data.count);
|
|
539
|
+
}
|
|
540
|
+
_context6.next = 14;
|
|
541
|
+
break;
|
|
542
|
+
case 11:
|
|
543
|
+
_context6.prev = 11;
|
|
544
|
+
_context6.t0 = _context6["catch"](0);
|
|
545
|
+
console.error('Failed to fetch notifications:', _context6.t0);
|
|
546
|
+
case 14:
|
|
547
|
+
case "end":
|
|
548
|
+
return _context6.stop();
|
|
549
|
+
}
|
|
550
|
+
}, _callee6, null, [[0, 11]]);
|
|
551
|
+
}));
|
|
552
|
+
return function fetchData() {
|
|
553
|
+
return _ref8.apply(this, arguments);
|
|
554
|
+
};
|
|
555
|
+
}();
|
|
556
|
+
if (globalIsInitialized && globalUserId === userId && globalConnection) {
|
|
557
|
+
setIsConnected(globalConnection.state === 'Connected');
|
|
558
|
+
fetchData();
|
|
559
|
+
return;
|
|
560
|
+
}
|
|
561
|
+
if (globalConnection && globalUserId !== userId) {
|
|
562
|
+
globalConnection.stop();
|
|
563
|
+
globalConnection = null;
|
|
564
|
+
globalIsInitialized = false;
|
|
565
|
+
}
|
|
566
|
+
globalUserId = userId;
|
|
567
|
+
globalIsInitialized = true;
|
|
568
|
+
var apiBaseUrl = process.env.apiUri || 'http://localhost:54218';
|
|
569
|
+
var hubUrl = "".concat(apiBaseUrl, "/notifications");
|
|
570
|
+
|
|
571
|
+
// Get access token for SignalR authentication
|
|
572
|
+
var accessToken = _jsCookie["default"].get('access_token') || '';
|
|
573
|
+
var connection = new _signalr.HubConnectionBuilder().withUrl(hubUrl, {
|
|
574
|
+
accessTokenFactory: function accessTokenFactory() {
|
|
575
|
+
return accessToken;
|
|
576
|
+
},
|
|
577
|
+
transport: _signalr.HttpTransportType.WebSockets | _signalr.HttpTransportType.LongPolling
|
|
578
|
+
}).withAutomaticReconnect([0, 2000, 5000, 10000, 30000]).configureLogging(_signalr.LogLevel.Warning).build();
|
|
579
|
+
globalConnection = connection;
|
|
580
|
+
connection.on('OnNotificationReceived', function (notification) {
|
|
581
|
+
setNotifications(function (prev) {
|
|
582
|
+
return [notification].concat(_toConsumableArray(prev));
|
|
583
|
+
});
|
|
584
|
+
setUnreadCount(function (prev) {
|
|
585
|
+
return prev + 1;
|
|
586
|
+
});
|
|
587
|
+
var description = notification.message || notification.categoryName || '';
|
|
588
|
+
_reactToastify.toast.info(/*#__PURE__*/_react["default"].createElement('div', null, /*#__PURE__*/_react["default"].createElement('strong', null, notification.title), description && /*#__PURE__*/_react["default"].createElement('div', {
|
|
589
|
+
style: {
|
|
590
|
+
fontSize: '0.9em',
|
|
591
|
+
marginTop: '4px'
|
|
592
|
+
}
|
|
593
|
+
}, description)), {
|
|
594
|
+
onClick: function onClick() {
|
|
595
|
+
if (notification.linkUrl) {
|
|
596
|
+
window.location.href = notification.linkUrl;
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
});
|
|
600
|
+
});
|
|
601
|
+
connection.onreconnecting(function () {
|
|
602
|
+
return setIsConnected(false);
|
|
603
|
+
});
|
|
604
|
+
connection.onreconnected(function () {
|
|
605
|
+
setIsConnected(true);
|
|
606
|
+
fetchData();
|
|
607
|
+
});
|
|
608
|
+
connection.onclose(function () {
|
|
609
|
+
return setIsConnected(false);
|
|
610
|
+
});
|
|
611
|
+
var startConnection = /*#__PURE__*/function () {
|
|
612
|
+
var _ref9 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
613
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
614
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
615
|
+
case 0:
|
|
616
|
+
_context7.prev = 0;
|
|
617
|
+
_context7.next = 3;
|
|
618
|
+
return connection.start();
|
|
619
|
+
case 3:
|
|
620
|
+
setIsConnected(true);
|
|
621
|
+
_context7.next = 6;
|
|
622
|
+
return connection.invoke('JoinUserNotifications', userId);
|
|
623
|
+
case 6:
|
|
624
|
+
if (!(currentUser !== null && currentUser !== void 0 && currentUser.companyId)) {
|
|
625
|
+
_context7.next = 9;
|
|
626
|
+
break;
|
|
627
|
+
}
|
|
628
|
+
_context7.next = 9;
|
|
629
|
+
return connection.invoke('JoinCompanyNotifications', currentUser.companyId);
|
|
630
|
+
case 9:
|
|
631
|
+
if (!(currentUser !== null && currentUser !== void 0 && currentUser.locationId)) {
|
|
632
|
+
_context7.next = 12;
|
|
633
|
+
break;
|
|
634
|
+
}
|
|
635
|
+
_context7.next = 12;
|
|
636
|
+
return connection.invoke('JoinLocationNotifications', currentUser.locationId);
|
|
637
|
+
case 12:
|
|
638
|
+
_context7.next = 14;
|
|
639
|
+
return fetchData();
|
|
640
|
+
case 14:
|
|
641
|
+
_context7.next = 21;
|
|
642
|
+
break;
|
|
643
|
+
case 16:
|
|
644
|
+
_context7.prev = 16;
|
|
645
|
+
_context7.t0 = _context7["catch"](0);
|
|
646
|
+
console.error('Failed to connect to NotificationHub:', _context7.t0.message);
|
|
647
|
+
_context7.next = 21;
|
|
648
|
+
return fetchData();
|
|
649
|
+
case 21:
|
|
650
|
+
case "end":
|
|
651
|
+
return _context7.stop();
|
|
652
|
+
}
|
|
653
|
+
}, _callee7, null, [[0, 16]]);
|
|
654
|
+
}));
|
|
655
|
+
return function startConnection() {
|
|
656
|
+
return _ref9.apply(this, arguments);
|
|
657
|
+
};
|
|
658
|
+
}();
|
|
659
|
+
startConnection();
|
|
660
|
+
}, [currentUser === null || currentUser === void 0 ? void 0 : currentUser.id, currentUser === null || currentUser === void 0 ? void 0 : currentUser.companyId, currentUser === null || currentUser === void 0 ? void 0 : currentUser.locationId, apiService]);
|
|
661
|
+
var value = {
|
|
662
|
+
notifications: notifications,
|
|
663
|
+
unreadCount: unreadCount,
|
|
664
|
+
isConnected: isConnected,
|
|
665
|
+
markAsRead: markAsRead,
|
|
666
|
+
markAllAsRead: markAllAsRead,
|
|
667
|
+
deleteNotification: deleteNotification,
|
|
668
|
+
clearAll: clearAll,
|
|
669
|
+
refresh: fetchNotifications
|
|
670
|
+
};
|
|
671
|
+
return /*#__PURE__*/_react["default"].createElement(NotificationContext.Provider, {
|
|
672
|
+
value: value
|
|
673
|
+
}, children);
|
|
674
|
+
}
|
|
35
675
|
|
|
36
|
-
//
|
|
676
|
+
// ============================================================================
|
|
677
|
+
// User Helpers
|
|
678
|
+
// ============================================================================
|
|
37
679
|
function ensureUserHelpers(u) {
|
|
38
680
|
if (!u || _typeof(u) !== "object") return u;
|
|
39
|
-
|
|
40
|
-
// Avoid redefining on every call
|
|
41
681
|
if (typeof u.hasRole === "function" && typeof u.hasRoleId === "function" && typeof u.hasPermission === "function") {
|
|
42
682
|
return u;
|
|
43
683
|
}
|
|
44
684
|
var rolesArr = Array.isArray(u.roles) ? u.roles : [];
|
|
45
685
|
var permsArr = Array.isArray(u.permissions) ? u.permissions : [];
|
|
46
|
-
|
|
47
|
-
// defineProperty keeps them non-enumerable
|
|
48
686
|
Object.defineProperty(u, "hasRole", {
|
|
49
687
|
value: function hasRole(name) {
|
|
50
688
|
if (!name) return false;
|
|
@@ -72,74 +710,84 @@ function ensureUserHelpers(u) {
|
|
|
72
710
|
});
|
|
73
711
|
return u;
|
|
74
712
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
var
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
713
|
+
|
|
714
|
+
// ============================================================================
|
|
715
|
+
// AuthScapeApp Component
|
|
716
|
+
// ============================================================================
|
|
717
|
+
function AuthScapeApp(_ref10) {
|
|
718
|
+
var Component = _ref10.Component,
|
|
719
|
+
layout = _ref10.layout,
|
|
720
|
+
loadingLayout = _ref10.loadingLayout,
|
|
721
|
+
signInLoadingComponent = _ref10.signInLoadingComponent,
|
|
722
|
+
pageProps = _ref10.pageProps,
|
|
723
|
+
_ref10$muiTheme = _ref10.muiTheme,
|
|
724
|
+
muiTheme = _ref10$muiTheme === void 0 ? null : _ref10$muiTheme,
|
|
725
|
+
_ref10$store = _ref10.store,
|
|
726
|
+
store = _ref10$store === void 0 ? {} : _ref10$store,
|
|
727
|
+
_ref10$enforceLoggedI = _ref10.enforceLoggedIn,
|
|
728
|
+
enforceLoggedIn = _ref10$enforceLoggedI === void 0 ? false : _ref10$enforceLoggedI,
|
|
729
|
+
_ref10$enableAuth = _ref10.enableAuth,
|
|
730
|
+
enableAuth = _ref10$enableAuth === void 0 ? true : _ref10$enableAuth,
|
|
731
|
+
_ref10$enableNotifica = _ref10.enableNotifications,
|
|
732
|
+
enableNotifications = _ref10$enableNotifica === void 0 ? true : _ref10$enableNotifica,
|
|
733
|
+
_ref10$enableErrorTra = _ref10.enableErrorTracking,
|
|
734
|
+
enableErrorTracking = _ref10$enableErrorTra === void 0 ? true : _ref10$enableErrorTra,
|
|
735
|
+
_ref10$toastConfig = _ref10.toastConfig,
|
|
736
|
+
toastConfig = _ref10$toastConfig === void 0 ? {} : _ref10$toastConfig,
|
|
737
|
+
_ref10$onUserLoaded = _ref10.onUserLoaded,
|
|
738
|
+
onUserLoaded = _ref10$onUserLoaded === void 0 ? null : _ref10$onUserLoaded;
|
|
739
|
+
var _useState9 = (0, _react.useState)(false),
|
|
740
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
741
|
+
frontEndLoadedState = _useState10[0],
|
|
742
|
+
setFrontEndLoadedState = _useState10[1];
|
|
743
|
+
var _useState11 = (0, _react.useState)(false),
|
|
744
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
745
|
+
isLoadingShow = _useState12[0],
|
|
746
|
+
setIsLoadingShow = _useState12[1];
|
|
747
|
+
var _useState13 = (0, _react.useState)(null),
|
|
748
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
749
|
+
signedInUserState = _useState14[0],
|
|
750
|
+
setSignedInUserState = _useState14[1];
|
|
751
|
+
var _useState15 = (0, _react.useState)(false),
|
|
752
|
+
_useState16 = _slicedToArray(_useState15, 2),
|
|
753
|
+
isSigningIn = _useState16[0],
|
|
754
|
+
setIsSigningIn = _useState16[1];
|
|
105
755
|
var loadingAuth = (0, _react.useRef)(false);
|
|
106
756
|
var signedInUser = (0, _react.useRef)(null);
|
|
107
757
|
var queryCodeUsed = (0, _react.useRef)(null);
|
|
108
758
|
var ga4React = (0, _react.useRef)(null);
|
|
759
|
+
var errorTrackingInitializedRef = (0, _react.useRef)(false);
|
|
109
760
|
var searchParams = (0, _navigation.useSearchParams)();
|
|
110
761
|
var queryCode = searchParams.get("code");
|
|
111
762
|
var pathname = (0, _navigation.usePathname)();
|
|
112
|
-
|
|
113
|
-
// ----- PKCE Sign-in (browser-only) -----
|
|
114
763
|
var signInValidator = /*#__PURE__*/function () {
|
|
115
|
-
var
|
|
764
|
+
var _ref11 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(codeFromQuery) {
|
|
116
765
|
var codeVerifier, headers, body, response, domainHost, redirectUri;
|
|
117
|
-
return _regeneratorRuntime().wrap(function
|
|
118
|
-
while (1) switch (
|
|
766
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
767
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
119
768
|
case 0:
|
|
120
769
|
if (!(queryCodeUsed.current === codeFromQuery)) {
|
|
121
|
-
|
|
770
|
+
_context8.next = 2;
|
|
122
771
|
break;
|
|
123
772
|
}
|
|
124
|
-
return
|
|
773
|
+
return _context8.abrupt("return");
|
|
125
774
|
case 2:
|
|
126
775
|
queryCodeUsed.current = codeFromQuery;
|
|
127
776
|
if (!(typeof window === "undefined")) {
|
|
128
|
-
|
|
777
|
+
_context8.next = 5;
|
|
129
778
|
break;
|
|
130
779
|
}
|
|
131
|
-
return
|
|
780
|
+
return _context8.abrupt("return");
|
|
132
781
|
case 5:
|
|
133
782
|
setIsSigningIn(true);
|
|
134
783
|
codeVerifier = window.localStorage.getItem("verifier");
|
|
135
784
|
if (!(!codeFromQuery || !codeVerifier)) {
|
|
136
|
-
|
|
785
|
+
_context8.next = 11;
|
|
137
786
|
break;
|
|
138
787
|
}
|
|
139
|
-
// No code or verifier - redirect to login
|
|
140
788
|
window.localStorage.clear();
|
|
141
789
|
module.exports.authService().login();
|
|
142
|
-
return
|
|
790
|
+
return _context8.abrupt("return");
|
|
143
791
|
case 11:
|
|
144
792
|
headers = {
|
|
145
793
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
@@ -152,18 +800,16 @@ function AuthScapeApp(_ref) {
|
|
|
152
800
|
client_secret: process.env.client_secret,
|
|
153
801
|
code_verifier: codeVerifier
|
|
154
802
|
});
|
|
155
|
-
|
|
156
|
-
|
|
803
|
+
_context8.prev = 13;
|
|
804
|
+
_context8.next = 16;
|
|
157
805
|
return _axios["default"].post(process.env.authorityUri + "/connect/token", body, {
|
|
158
806
|
headers: headers
|
|
159
807
|
});
|
|
160
808
|
case 16:
|
|
161
|
-
response =
|
|
809
|
+
response = _context8.sent;
|
|
162
810
|
domainHost = window.location.hostname.split(".").slice(-2).join(".");
|
|
163
811
|
window.localStorage.removeItem("verifier");
|
|
164
|
-
|
|
165
|
-
// NOTE: replace setCookie below with your implementation if different
|
|
166
|
-
_context.next = 21;
|
|
812
|
+
_context8.next = 21;
|
|
167
813
|
return setCookie("access_token", response.data.access_token, {
|
|
168
814
|
maxAge: 60 * 60 * 24 * 365,
|
|
169
815
|
path: "/",
|
|
@@ -171,7 +817,7 @@ function AuthScapeApp(_ref) {
|
|
|
171
817
|
secure: true
|
|
172
818
|
});
|
|
173
819
|
case 21:
|
|
174
|
-
|
|
820
|
+
_context8.next = 23;
|
|
175
821
|
return setCookie("expires_in", response.data.expires_in, {
|
|
176
822
|
maxAge: 60 * 60 * 24 * 365,
|
|
177
823
|
path: "/",
|
|
@@ -179,7 +825,7 @@ function AuthScapeApp(_ref) {
|
|
|
179
825
|
secure: true
|
|
180
826
|
});
|
|
181
827
|
case 23:
|
|
182
|
-
|
|
828
|
+
_context8.next = 25;
|
|
183
829
|
return setCookie("refresh_token", response.data.refresh_token, {
|
|
184
830
|
maxAge: 60 * 60 * 24 * 365,
|
|
185
831
|
path: "/",
|
|
@@ -189,68 +835,61 @@ function AuthScapeApp(_ref) {
|
|
|
189
835
|
case 25:
|
|
190
836
|
redirectUri = window.localStorage.getItem("redirectUri") || "/";
|
|
191
837
|
window.localStorage.clear();
|
|
192
|
-
|
|
193
|
-
// Navigate to the redirect URI - use window.location for a clean page load
|
|
194
|
-
// This ensures all state is properly initialized on the target page
|
|
195
838
|
window.location.href = redirectUri;
|
|
196
|
-
|
|
839
|
+
_context8.next = 36;
|
|
197
840
|
break;
|
|
198
841
|
case 30:
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
console.error("PKCE sign-in failed",
|
|
202
|
-
// Invalid code - clear storage and redirect to login
|
|
842
|
+
_context8.prev = 30;
|
|
843
|
+
_context8.t0 = _context8["catch"](13);
|
|
844
|
+
console.error("PKCE sign-in failed", _context8.t0);
|
|
203
845
|
window.localStorage.clear();
|
|
204
846
|
setIsSigningIn(false);
|
|
205
847
|
module.exports.authService().login();
|
|
206
848
|
case 36:
|
|
207
849
|
case "end":
|
|
208
|
-
return
|
|
850
|
+
return _context8.stop();
|
|
209
851
|
}
|
|
210
|
-
},
|
|
852
|
+
}, _callee8, null, [[13, 30]]);
|
|
211
853
|
}));
|
|
212
|
-
return function signInValidator(
|
|
213
|
-
return
|
|
854
|
+
return function signInValidator(_x4) {
|
|
855
|
+
return _ref11.apply(this, arguments);
|
|
214
856
|
};
|
|
215
857
|
}();
|
|
216
|
-
|
|
217
|
-
// ----- GA + Clarity -----
|
|
218
|
-
function initGA(_x2) {
|
|
858
|
+
function initGA(_x5) {
|
|
219
859
|
return _initGA.apply(this, arguments);
|
|
220
860
|
}
|
|
221
861
|
function _initGA() {
|
|
222
|
-
_initGA = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
223
|
-
return _regeneratorRuntime().wrap(function
|
|
224
|
-
while (1) switch (
|
|
862
|
+
_initGA = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(G) {
|
|
863
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
864
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
225
865
|
case 0:
|
|
226
866
|
if (!(typeof window !== "undefined" && !_ga4React["default"].isInitialized() && G)) {
|
|
227
|
-
|
|
867
|
+
_context9.next = 10;
|
|
228
868
|
break;
|
|
229
869
|
}
|
|
230
870
|
ga4React.current = new _ga4React["default"](G, {
|
|
231
871
|
debug_mode: !process.env.production
|
|
232
872
|
});
|
|
233
|
-
|
|
234
|
-
|
|
873
|
+
_context9.prev = 2;
|
|
874
|
+
_context9.next = 5;
|
|
235
875
|
return ga4React.current.initialize();
|
|
236
876
|
case 5:
|
|
237
|
-
|
|
877
|
+
_context9.next = 10;
|
|
238
878
|
break;
|
|
239
879
|
case 7:
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
console.error(
|
|
880
|
+
_context9.prev = 7;
|
|
881
|
+
_context9.t0 = _context9["catch"](2);
|
|
882
|
+
console.error(_context9.t0);
|
|
243
883
|
case 10:
|
|
244
884
|
case "end":
|
|
245
|
-
return
|
|
885
|
+
return _context9.stop();
|
|
246
886
|
}
|
|
247
|
-
},
|
|
887
|
+
}, _callee9, null, [[2, 7]]);
|
|
248
888
|
}));
|
|
249
889
|
return _initGA.apply(this, arguments);
|
|
250
890
|
}
|
|
251
891
|
var logEvent = function logEvent(category, action, label) {
|
|
252
892
|
if (ga4React.current) ga4React.current.event(action, label, category);
|
|
253
|
-
// your DB analytics can go here if desired
|
|
254
893
|
};
|
|
255
894
|
var databaseDrivenPageView = function databaseDrivenPageView(pathName) {
|
|
256
895
|
var _signedInUser$current, _signedInUser$current2, _signedInUser$current3;
|
|
@@ -258,8 +897,6 @@ function AuthScapeApp(_ref) {
|
|
|
258
897
|
if (typeof window === "undefined") return;
|
|
259
898
|
if (pathName === "/signin-oidc") return;
|
|
260
899
|
var host = window.location.protocol + "//" + window.location.host;
|
|
261
|
-
|
|
262
|
-
// Use module.exports to access sibling exports in babel bundle
|
|
263
900
|
module.exports.apiService().post("/Analytics/PageView", {
|
|
264
901
|
userId: (_signedInUser$current = signedInUser.current) === null || _signedInUser$current === void 0 ? void 0 : _signedInUser$current.id,
|
|
265
902
|
locationId: (_signedInUser$current2 = signedInUser.current) === null || _signedInUser$current2 === void 0 ? void 0 : _signedInUser$current2.locationId,
|
|
@@ -268,8 +905,6 @@ function AuthScapeApp(_ref) {
|
|
|
268
905
|
host: host
|
|
269
906
|
});
|
|
270
907
|
};
|
|
271
|
-
|
|
272
|
-
// ----- Auth init (runs once) -----
|
|
273
908
|
(0, _react.useEffect)(function () {
|
|
274
909
|
if (queryCode) {
|
|
275
910
|
signInValidator(queryCode);
|
|
@@ -278,13 +913,20 @@ function AuthScapeApp(_ref) {
|
|
|
278
913
|
if (!loadingAuth.current) {
|
|
279
914
|
loadingAuth.current = true;
|
|
280
915
|
if (enableAuth) {
|
|
281
|
-
// Use module.exports to access sibling exports in babel bundle
|
|
282
916
|
module.exports.apiService().GetCurrentUser().then(function (usr) {
|
|
283
917
|
signedInUser.current = ensureUserHelpers(usr);
|
|
284
918
|
setSignedInUserState(signedInUser.current);
|
|
285
919
|
setFrontEndLoadedState(true);
|
|
286
|
-
|
|
287
|
-
//
|
|
920
|
+
|
|
921
|
+
// Initialize error tracking with user info
|
|
922
|
+
if (enableErrorTracking && usr && !errorTrackingInitializedRef.current) {
|
|
923
|
+
initializeErrorTracking(usr);
|
|
924
|
+
errorTrackingInitializedRef.current = true;
|
|
925
|
+
}
|
|
926
|
+
if (onUserLoaded && usr) {
|
|
927
|
+
onUserLoaded(usr);
|
|
928
|
+
}
|
|
929
|
+
})["catch"](function (err) {
|
|
288
930
|
signedInUser.current = null;
|
|
289
931
|
setSignedInUserState(null);
|
|
290
932
|
setFrontEndLoadedState(true);
|
|
@@ -293,9 +935,7 @@ function AuthScapeApp(_ref) {
|
|
|
293
935
|
setFrontEndLoadedState(true);
|
|
294
936
|
}
|
|
295
937
|
}
|
|
296
|
-
}, [queryCode, enableAuth]);
|
|
297
|
-
|
|
298
|
-
// ----- Analytics init -----
|
|
938
|
+
}, [queryCode, enableAuth, enableErrorTracking]);
|
|
299
939
|
(0, _react.useEffect)(function () {
|
|
300
940
|
if (!frontEndLoadedState || typeof window === "undefined") return;
|
|
301
941
|
if (pageProps.googleAnalytics4Code) {
|
|
@@ -319,26 +959,17 @@ function AuthScapeApp(_ref) {
|
|
|
319
959
|
return _router["default"].events.off("routeChangeComplete", handler);
|
|
320
960
|
};
|
|
321
961
|
}, [frontEndLoadedState, pageProps.googleAnalytics4Code, pageProps.microsoftClarityCode]);
|
|
322
|
-
|
|
323
|
-
// ----- Enforce login (client) -----
|
|
324
962
|
(0, _react.useEffect)(function () {
|
|
325
963
|
if (enforceLoggedIn && pathname !== "/signin-oidc" && frontEndLoadedState && !signedInUserState) {
|
|
326
|
-
// Use module.exports to access sibling exports in babel bundle
|
|
327
964
|
module.exports.authService().login();
|
|
328
965
|
}
|
|
329
966
|
}, [signedInUserState, enforceLoggedIn, frontEndLoadedState, pathname]);
|
|
330
|
-
|
|
331
|
-
// Stable getter for current user (with helpers)
|
|
332
967
|
var currentUser = (0, _react.useMemo)(function () {
|
|
333
968
|
return ensureUserHelpers(signedInUser.current);
|
|
334
969
|
}, [signedInUserState]);
|
|
335
970
|
var useStore = (0, _zustand.create)(function () {
|
|
336
971
|
return store;
|
|
337
972
|
});
|
|
338
|
-
|
|
339
|
-
// ----- Render (SSR-safe; always output page so <title> is visible) -----
|
|
340
|
-
|
|
341
|
-
// Default sign-in loading component if none provided
|
|
342
973
|
var defaultSignInLoading = /*#__PURE__*/_react["default"].createElement("div", {
|
|
343
974
|
style: {
|
|
344
975
|
display: 'flex',
|
|
@@ -364,16 +995,26 @@ function AuthScapeApp(_ref) {
|
|
|
364
995
|
color: '#666'
|
|
365
996
|
}
|
|
366
997
|
}, "Signing in..."), /*#__PURE__*/_react["default"].createElement("style", null, "\n @keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n "));
|
|
367
|
-
|
|
368
|
-
// Show loading screen when signing in
|
|
369
998
|
if (isSigningIn) {
|
|
370
999
|
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_head["default"], null, /*#__PURE__*/_react["default"].createElement("meta", {
|
|
371
1000
|
name: "viewport",
|
|
372
1001
|
content: "width=device-width, initial-scale=0.86, maximum-scale=5.0, minimum-scale=0.86"
|
|
373
|
-
})), /*#__PURE__*/_react["default"].createElement(
|
|
374
|
-
|
|
1002
|
+
})), /*#__PURE__*/_react["default"].createElement(AppThemeProvider, {
|
|
1003
|
+
customTheme: muiTheme
|
|
375
1004
|
}, signInLoadingComponent || defaultSignInLoading));
|
|
376
1005
|
}
|
|
1006
|
+
var defaultToastConfig = _objectSpread({
|
|
1007
|
+
position: "top-right",
|
|
1008
|
+
autoClose: 3000,
|
|
1009
|
+
hideProgressBar: false,
|
|
1010
|
+
newestOnTop: true,
|
|
1011
|
+
closeOnClick: true,
|
|
1012
|
+
rtl: false,
|
|
1013
|
+
pauseOnFocusLoss: true,
|
|
1014
|
+
draggable: true,
|
|
1015
|
+
pauseOnHover: true,
|
|
1016
|
+
theme: "colored"
|
|
1017
|
+
}, toastConfig);
|
|
377
1018
|
var pageContent = layout ? layout({
|
|
378
1019
|
children: /*#__PURE__*/_react["default"].createElement(Component, _extends({}, pageProps, {
|
|
379
1020
|
currentUser: currentUser,
|
|
@@ -397,12 +1038,16 @@ function AuthScapeApp(_ref) {
|
|
|
397
1038
|
store: useStore,
|
|
398
1039
|
toast: _reactToastify.toast
|
|
399
1040
|
}));
|
|
1041
|
+
var wrappedContent = enableNotifications && currentUser ? /*#__PURE__*/_react["default"].createElement(NotificationProvider, {
|
|
1042
|
+
currentUser: currentUser,
|
|
1043
|
+
apiService: module.exports.apiService
|
|
1044
|
+
}, pageContent) : pageContent;
|
|
400
1045
|
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_head["default"], null, /*#__PURE__*/_react["default"].createElement("meta", {
|
|
401
1046
|
name: "viewport",
|
|
402
1047
|
content: "width=device-width, initial-scale=0.86, maximum-scale=5.0, minimum-scale=0.86"
|
|
403
|
-
})), /*#__PURE__*/_react["default"].createElement(
|
|
404
|
-
|
|
405
|
-
},
|
|
1048
|
+
})), /*#__PURE__*/_react["default"].createElement(AppThemeProvider, {
|
|
1049
|
+
customTheme: muiTheme
|
|
1050
|
+
}, wrappedContent), /*#__PURE__*/_react["default"].createElement(_reactToastify.ToastContainer, defaultToastConfig), loadingLayout && loadingLayout(isLoadingShow));
|
|
406
1051
|
}
|
|
407
1052
|
"use strict";
|
|
408
1053
|
|
|
@@ -8953,6 +9598,19 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
8953
9598
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
8954
9599
|
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
8955
9600
|
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
9601
|
+
// Cookie utility function
|
|
9602
|
+
var setCookie = function setCookie(name, value) {
|
|
9603
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
9604
|
+
return new Promise(function (resolve) {
|
|
9605
|
+
var cookieString = "".concat(name, "=").concat(value, ";");
|
|
9606
|
+
if (options.maxAge) cookieString += "max-age=".concat(options.maxAge, ";");
|
|
9607
|
+
if (options.path) cookieString += "path=".concat(options.path, ";");
|
|
9608
|
+
if (options.domain) cookieString += "domain=".concat(options.domain, ";");
|
|
9609
|
+
if (options.secure) cookieString += "secure;";
|
|
9610
|
+
document.cookie = cookieString;
|
|
9611
|
+
resolve();
|
|
9612
|
+
});
|
|
9613
|
+
};
|
|
8956
9614
|
var setupDefaultOptions = /*#__PURE__*/function () {
|
|
8957
9615
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
8958
9616
|
var ctx,
|
|
@@ -9024,7 +9682,6 @@ var RefreshToken = /*#__PURE__*/function () {
|
|
|
9024
9682
|
_context2.next = 10;
|
|
9025
9683
|
return setCookie('access_token', response.data.access_token, {
|
|
9026
9684
|
maxAge: 60 * 60 * 24 * 365,
|
|
9027
|
-
// 1 year,
|
|
9028
9685
|
path: '/',
|
|
9029
9686
|
domain: domainHost,
|
|
9030
9687
|
secure: true
|
|
@@ -9033,7 +9690,6 @@ var RefreshToken = /*#__PURE__*/function () {
|
|
|
9033
9690
|
_context2.next = 12;
|
|
9034
9691
|
return setCookie('expires_in', response.data.expires_in, {
|
|
9035
9692
|
maxAge: 60 * 60 * 24 * 365,
|
|
9036
|
-
// 1 year,
|
|
9037
9693
|
path: '/',
|
|
9038
9694
|
domain: domainHost,
|
|
9039
9695
|
secure: true
|
|
@@ -9042,7 +9698,6 @@ var RefreshToken = /*#__PURE__*/function () {
|
|
|
9042
9698
|
_context2.next = 14;
|
|
9043
9699
|
return setCookie('refresh_token', response.data.refresh_token, {
|
|
9044
9700
|
maxAge: 60 * 60 * 24 * 365,
|
|
9045
|
-
// 1 year,
|
|
9046
9701
|
path: '/',
|
|
9047
9702
|
domain: domainHost,
|
|
9048
9703
|
secure: true
|
|
@@ -9066,8 +9721,7 @@ var apiService = exports.apiService = function apiService() {
|
|
|
9066
9721
|
var baseUri = process.env.apiUri + "/api";
|
|
9067
9722
|
var instance = _axios["default"].create({
|
|
9068
9723
|
baseURL: baseUri,
|
|
9069
|
-
|
|
9070
|
-
params: {} // do not remove this, its added to add params later in the config
|
|
9724
|
+
params: {}
|
|
9071
9725
|
});
|
|
9072
9726
|
instance.interceptors.response.use(function (response) {
|
|
9073
9727
|
return response;
|
|
@@ -9087,8 +9741,6 @@ var apiService = exports.apiService = function apiService() {
|
|
|
9087
9741
|
break;
|
|
9088
9742
|
}
|
|
9089
9743
|
originalConfig._retry = true;
|
|
9090
|
-
|
|
9091
|
-
// Do something, call refreshToken() request for example;
|
|
9092
9744
|
_context3.next = 6;
|
|
9093
9745
|
return RefreshToken(originalConfig, instance);
|
|
9094
9746
|
case 6:
|
|
@@ -9098,43 +9750,21 @@ var apiService = exports.apiService = function apiService() {
|
|
|
9098
9750
|
_context3.next = 10;
|
|
9099
9751
|
break;
|
|
9100
9752
|
}
|
|
9101
|
-
|
|
9102
|
-
|
|
9103
|
-
|
|
9104
|
-
|
|
9105
|
-
|
|
9106
|
-
|
|
9107
|
-
|
|
9108
|
-
|
|
9109
|
-
|
|
9110
|
-
|
|
9111
|
-
|
|
9112
|
-
|
|
9113
|
-
|
|
9114
|
-
|
|
9115
|
-
|
|
9116
|
-
path: '/',
|
|
9117
|
-
domain: domainHost
|
|
9118
|
-
});
|
|
9119
|
-
|
|
9120
|
-
// destroyCookie(null, "access_token", {
|
|
9121
|
-
// maxAge: 2147483647,
|
|
9122
|
-
// path: '/',
|
|
9123
|
-
// domain: domainHost
|
|
9124
|
-
// });
|
|
9125
|
-
|
|
9126
|
-
// destroyCookie(null, "refresh_token", {
|
|
9127
|
-
// maxAge: 2147483647,
|
|
9128
|
-
// path: '/',
|
|
9129
|
-
// domain: domainHost
|
|
9130
|
-
// });
|
|
9131
|
-
|
|
9132
|
-
// destroyCookie(null, "expires_in", {
|
|
9133
|
-
// maxAge: 2147483647,
|
|
9134
|
-
// path: '/',
|
|
9135
|
-
// domain: domainHost
|
|
9136
|
-
// });
|
|
9137
|
-
}
|
|
9753
|
+
if (error.response.config.url.includes("/connect/token")) {
|
|
9754
|
+
domainHost = window.location.hostname.split('.').slice(-2).join('.');
|
|
9755
|
+
_jsCookie["default"].remove('access_token', {
|
|
9756
|
+
path: '/',
|
|
9757
|
+
domain: domainHost
|
|
9758
|
+
});
|
|
9759
|
+
_jsCookie["default"].remove('refresh_token', {
|
|
9760
|
+
path: '/',
|
|
9761
|
+
domain: domainHost
|
|
9762
|
+
});
|
|
9763
|
+
_jsCookie["default"].remove('expires_in', {
|
|
9764
|
+
path: '/',
|
|
9765
|
+
domain: domainHost
|
|
9766
|
+
});
|
|
9767
|
+
}
|
|
9138
9768
|
return _context3.abrupt("return", Promise.reject(error));
|
|
9139
9769
|
case 10:
|
|
9140
9770
|
return _context3.abrupt("return", Promise.reject(error));
|
|
@@ -9307,16 +9937,14 @@ var apiService = exports.apiService = function apiService() {
|
|
|
9307
9937
|
}
|
|
9308
9938
|
return _context8.abrupt("return", response.data);
|
|
9309
9939
|
case 11:
|
|
9310
|
-
_context8.next =
|
|
9940
|
+
_context8.next = 15;
|
|
9311
9941
|
break;
|
|
9312
9942
|
case 13:
|
|
9313
9943
|
_context8.prev = 13;
|
|
9314
9944
|
_context8.t0 = _context8["catch"](0);
|
|
9315
|
-
|
|
9316
|
-
console.log(_context8.t0.message);
|
|
9317
|
-
case 16:
|
|
9945
|
+
case 15:
|
|
9318
9946
|
return _context8.abrupt("return", null);
|
|
9319
|
-
case
|
|
9947
|
+
case 16:
|
|
9320
9948
|
case "end":
|
|
9321
9949
|
return _context8.stop();
|
|
9322
9950
|
}
|
|
@@ -9345,7 +9973,6 @@ var apiService = exports.apiService = function apiService() {
|
|
|
9345
9973
|
mimeType = _args9.length > 5 && _args9[5] !== undefined ? _args9[5] : "application/octet-stream";
|
|
9346
9974
|
passData = _args9.length > 6 && _args9[6] !== undefined ? _args9[6] : false;
|
|
9347
9975
|
_context9.prev = 4;
|
|
9348
|
-
//let defaultOptions = await setupDefaultOptions();
|
|
9349
9976
|
defaultOptions = {};
|
|
9350
9977
|
options = {
|
|
9351
9978
|
responseType: "blob"
|
|
@@ -9600,6 +10227,7 @@ var _authService = exports.authService = function authService() {
|
|
|
9600
10227
|
state,
|
|
9601
10228
|
verifier,
|
|
9602
10229
|
challenge,
|
|
10230
|
+
storedVerifier,
|
|
9603
10231
|
redirectUri,
|
|
9604
10232
|
loginUri,
|
|
9605
10233
|
_args4 = arguments;
|
|
@@ -9618,14 +10246,23 @@ var _authService = exports.authService = function authService() {
|
|
|
9618
10246
|
return _authService().challenge_from_verifier(verifier);
|
|
9619
10247
|
case 8:
|
|
9620
10248
|
challenge = _context4.sent;
|
|
10249
|
+
console.log('[PKCE] Login initiated');
|
|
10250
|
+
console.log('[PKCE] Verifier generated | length:', verifier.length, '| preview:', verifier.substring(0, 10) + '...');
|
|
10251
|
+
console.log('[PKCE] Challenge generated | value:', challenge);
|
|
10252
|
+
console.log('[PKCE] authorityUri:', process.env.authorityUri);
|
|
10253
|
+
console.log('[PKCE] client_id:', process.env.client_id);
|
|
9621
10254
|
window.localStorage.setItem("verifier", verifier);
|
|
10255
|
+
storedVerifier = window.localStorage.getItem("verifier");
|
|
10256
|
+
console.log('[PKCE] Verifier stored successfully:', storedVerifier === verifier);
|
|
10257
|
+
console.log('[PKCE] Stored verifier length:', storedVerifier === null || storedVerifier === void 0 ? void 0 : storedVerifier.length);
|
|
9622
10258
|
redirectUri = window.location.origin + "/signin-oidc";
|
|
9623
10259
|
loginUri = process.env.authorityUri + "/connect/authorize?response_type=code&state=" + state + "&client_id=" + process.env.client_id + "&scope=email%20openid%20offline_access%20profile%20api1&redirect_uri=" + redirectUri + "&code_challenge=" + challenge + "&code_challenge_method=S256";
|
|
9624
10260
|
if (deviceId) {
|
|
9625
10261
|
loginUri += "&deviceId=" + deviceId; // will be for chrome extention and mobile apps later
|
|
9626
10262
|
}
|
|
10263
|
+
console.log('[PKCE] Redirecting to:', loginUri);
|
|
9627
10264
|
window.location.href = loginUri;
|
|
9628
|
-
case
|
|
10265
|
+
case 23:
|
|
9629
10266
|
case "end":
|
|
9630
10267
|
return _context4.stop();
|
|
9631
10268
|
}
|
|
@@ -9831,41 +10468,72 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default":
|
|
|
9831
10468
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
9832
10469
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
9833
10470
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
10471
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
10472
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
10473
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
10474
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
10475
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
9834
10476
|
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
9835
10477
|
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
9836
10478
|
// import Cookies from 'js-cookie';
|
|
9837
10479
|
|
|
9838
10480
|
var signInValidator = exports.signInValidator = /*#__PURE__*/function () {
|
|
9839
10481
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(queryCode) {
|
|
9840
|
-
var codeVerifier, headers, queryString, response, domainHost, redirectUri;
|
|
10482
|
+
var codeVerifier, _tokenParams$code, _tokenParams$code_ver, _tokenParams$code_ver2, headers, tokenParams, queryString, response, _response$data, _response$data2, _err$response, _err$response2, domainHost, redirectUri;
|
|
9841
10483
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
9842
10484
|
while (1) switch (_context.prev = _context.next) {
|
|
9843
10485
|
case 0:
|
|
9844
10486
|
codeVerifier = window.localStorage.getItem("verifier");
|
|
10487
|
+
console.log('[PKCE] signInValidator called');
|
|
10488
|
+
console.log('[PKCE] queryCode present:', !!queryCode, '| value:', queryCode);
|
|
10489
|
+
console.log('[PKCE] codeVerifier present:', !!codeVerifier, '| length:', codeVerifier === null || codeVerifier === void 0 ? void 0 : codeVerifier.length);
|
|
9845
10490
|
if (!(queryCode != null && codeVerifier != null)) {
|
|
9846
|
-
_context.next =
|
|
10491
|
+
_context.next = 38;
|
|
9847
10492
|
break;
|
|
9848
10493
|
}
|
|
9849
10494
|
headers = {
|
|
9850
10495
|
'Content-Type': 'application/x-www-form-urlencoded'
|
|
9851
10496
|
};
|
|
9852
|
-
|
|
10497
|
+
tokenParams = {
|
|
9853
10498
|
code: queryCode,
|
|
9854
10499
|
grant_type: "authorization_code",
|
|
9855
10500
|
redirect_uri: window.location.origin + "/signin-oidc",
|
|
9856
10501
|
client_id: process.env.client_id,
|
|
9857
10502
|
client_secret: process.env.client_secret,
|
|
9858
10503
|
code_verifier: codeVerifier
|
|
9859
|
-
}
|
|
9860
|
-
|
|
10504
|
+
};
|
|
10505
|
+
console.log('[PKCE] Token request params:', _objectSpread(_objectSpread({}, tokenParams), {}, {
|
|
10506
|
+
client_secret: tokenParams.client_secret ? '***' : '(missing!)',
|
|
10507
|
+
code: ((_tokenParams$code = tokenParams.code) === null || _tokenParams$code === void 0 ? void 0 : _tokenParams$code.substring(0, 10)) + '...',
|
|
10508
|
+
code_verifier: ((_tokenParams$code_ver = tokenParams.code_verifier) === null || _tokenParams$code_ver === void 0 ? void 0 : _tokenParams$code_ver.substring(0, 10)) + '... (length: ' + ((_tokenParams$code_ver2 = tokenParams.code_verifier) === null || _tokenParams$code_ver2 === void 0 ? void 0 : _tokenParams$code_ver2.length) + ')'
|
|
10509
|
+
}));
|
|
10510
|
+
console.log('[PKCE] Token endpoint:', process.env.authorityUri + '/connect/token');
|
|
10511
|
+
console.log('[PKCE] redirect_uri:', tokenParams.redirect_uri);
|
|
10512
|
+
queryString = _queryString["default"].stringify(tokenParams);
|
|
10513
|
+
_context.prev = 11;
|
|
10514
|
+
_context.next = 14;
|
|
9861
10515
|
return _axios["default"].post(process.env.authorityUri + '/connect/token', queryString, {
|
|
9862
10516
|
headers: headers
|
|
9863
10517
|
});
|
|
9864
|
-
case
|
|
10518
|
+
case 14:
|
|
9865
10519
|
response = _context.sent;
|
|
10520
|
+
console.log('[PKCE] Token response status:', response.status);
|
|
10521
|
+
console.log('[PKCE] Token response has access_token:', !!((_response$data = response.data) !== null && _response$data !== void 0 && _response$data.access_token));
|
|
10522
|
+
console.log('[PKCE] Token response has refresh_token:', !!((_response$data2 = response.data) !== null && _response$data2 !== void 0 && _response$data2.refresh_token));
|
|
10523
|
+
_context.next = 27;
|
|
10524
|
+
break;
|
|
10525
|
+
case 20:
|
|
10526
|
+
_context.prev = 20;
|
|
10527
|
+
_context.t0 = _context["catch"](11);
|
|
10528
|
+
console.error('[PKCE] Token request FAILED');
|
|
10529
|
+
console.error('[PKCE] Status:', (_err$response = _context.t0.response) === null || _err$response === void 0 ? void 0 : _err$response.status);
|
|
10530
|
+
console.error('[PKCE] Error data:', JSON.stringify((_err$response2 = _context.t0.response) === null || _err$response2 === void 0 ? void 0 : _err$response2.data));
|
|
10531
|
+
console.error('[PKCE] Error message:', _context.t0.message);
|
|
10532
|
+
throw _context.t0;
|
|
10533
|
+
case 27:
|
|
9866
10534
|
domainHost = window.location.hostname.split('.').slice(-2).join('.');
|
|
9867
10535
|
window.localStorage.removeItem("verifier");
|
|
9868
|
-
_context.next =
|
|
10536
|
+
_context.next = 31;
|
|
9869
10537
|
return setCookie('access_token', response.data.access_token, {
|
|
9870
10538
|
maxAge: 60 * 60 * 24 * 365,
|
|
9871
10539
|
// 1 year,
|
|
@@ -9873,8 +10541,8 @@ var signInValidator = exports.signInValidator = /*#__PURE__*/function () {
|
|
|
9873
10541
|
domain: domainHost,
|
|
9874
10542
|
secure: true
|
|
9875
10543
|
});
|
|
9876
|
-
case
|
|
9877
|
-
_context.next =
|
|
10544
|
+
case 31:
|
|
10545
|
+
_context.next = 33;
|
|
9878
10546
|
return setCookie('expires_in', response.data.expires_in, {
|
|
9879
10547
|
maxAge: 60 * 60 * 24 * 365,
|
|
9880
10548
|
// 1 year,
|
|
@@ -9882,8 +10550,8 @@ var signInValidator = exports.signInValidator = /*#__PURE__*/function () {
|
|
|
9882
10550
|
domain: domainHost,
|
|
9883
10551
|
secure: true
|
|
9884
10552
|
});
|
|
9885
|
-
case
|
|
9886
|
-
_context.next =
|
|
10553
|
+
case 33:
|
|
10554
|
+
_context.next = 35;
|
|
9887
10555
|
return setCookie('refresh_token', response.data.refresh_token, {
|
|
9888
10556
|
maxAge: 60 * 60 * 24 * 365,
|
|
9889
10557
|
// 1 year,
|
|
@@ -9891,7 +10559,7 @@ var signInValidator = exports.signInValidator = /*#__PURE__*/function () {
|
|
|
9891
10559
|
domain: domainHost,
|
|
9892
10560
|
secure: true
|
|
9893
10561
|
});
|
|
9894
|
-
case
|
|
10562
|
+
case 35:
|
|
9895
10563
|
// await setCookie(null, "access_token", response.data.access_token,
|
|
9896
10564
|
// {
|
|
9897
10565
|
// maxAge: 2147483647,
|
|
@@ -9920,11 +10588,11 @@ var signInValidator = exports.signInValidator = /*#__PURE__*/function () {
|
|
|
9920
10588
|
} else {
|
|
9921
10589
|
window.location.href = "/";
|
|
9922
10590
|
}
|
|
9923
|
-
case
|
|
10591
|
+
case 38:
|
|
9924
10592
|
case "end":
|
|
9925
10593
|
return _context.stop();
|
|
9926
10594
|
}
|
|
9927
|
-
}, _callee);
|
|
10595
|
+
}, _callee, null, [[11, 20]]);
|
|
9928
10596
|
}));
|
|
9929
10597
|
return function signInValidator(_x) {
|
|
9930
10598
|
return _ref.apply(this, arguments);
|