authscape 1.0.760 → 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 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 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); }
24
- 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); }); }; }
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 _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); }
32
- // ---- optional: import your cookie util if not global ----
33
- // import { setCookie } from "cookies-next";
34
- // import { apiService } from "@/services/api"; // wherever yours lives
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
+ };
35
319
 
36
- // Decorate a user object with role/permission helpers (idempotent)
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
+ }
675
+
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,77 +710,84 @@ function ensureUserHelpers(u) {
72
710
  });
73
711
  return u;
74
712
  }
75
- function AuthScapeApp(_ref) {
76
- var Component = _ref.Component,
77
- layout = _ref.layout,
78
- loadingLayout = _ref.loadingLayout,
79
- signInLoadingComponent = _ref.signInLoadingComponent,
80
- pageProps = _ref.pageProps,
81
- _ref$muiTheme = _ref.muiTheme,
82
- muiTheme = _ref$muiTheme === void 0 ? {} : _ref$muiTheme,
83
- _ref$store = _ref.store,
84
- store = _ref$store === void 0 ? {} : _ref$store,
85
- _ref$enforceLoggedIn = _ref.enforceLoggedIn,
86
- enforceLoggedIn = _ref$enforceLoggedIn === void 0 ? false : _ref$enforceLoggedIn,
87
- _ref$enableAuth = _ref.enableAuth,
88
- enableAuth = _ref$enableAuth === void 0 ? true : _ref$enableAuth;
89
- var _useState = (0, _react.useState)(false),
90
- _useState2 = _slicedToArray(_useState, 2),
91
- frontEndLoadedState = _useState2[0],
92
- setFrontEndLoadedState = _useState2[1];
93
- var _useState3 = (0, _react.useState)(false),
94
- _useState4 = _slicedToArray(_useState3, 2),
95
- isLoadingShow = _useState4[0],
96
- setIsLoadingShow = _useState4[1];
97
- var _useState5 = (0, _react.useState)(null),
98
- _useState6 = _slicedToArray(_useState5, 2),
99
- signedInUserState = _useState6[0],
100
- setSignedInUserState = _useState6[1];
101
- var _useState7 = (0, _react.useState)(false),
102
- _useState8 = _slicedToArray(_useState7, 2),
103
- isSigningIn = _useState8[0],
104
- setIsSigningIn = _useState8[1];
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
- // Check if we're on the signin-oidc page
114
- var isOnSignInPage = pathname === "/signin-oidc";
115
-
116
- // ----- PKCE Sign-in (browser-only) -----
117
763
  var signInValidator = /*#__PURE__*/function () {
118
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(codeFromQuery) {
119
- var codeVerifier, headers, body, response, domainHost, redirectUri, usr;
120
- return _regeneratorRuntime().wrap(function _callee$(_context) {
121
- while (1) switch (_context.prev = _context.next) {
764
+ var _ref11 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(codeFromQuery) {
765
+ var codeVerifier, headers, body, response, domainHost, redirectUri;
766
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
767
+ while (1) switch (_context8.prev = _context8.next) {
122
768
  case 0:
123
769
  if (!(queryCodeUsed.current === codeFromQuery)) {
124
- _context.next = 2;
770
+ _context8.next = 2;
125
771
  break;
126
772
  }
127
- return _context.abrupt("return");
773
+ return _context8.abrupt("return");
128
774
  case 2:
129
775
  queryCodeUsed.current = codeFromQuery;
130
776
  if (!(typeof window === "undefined")) {
131
- _context.next = 5;
777
+ _context8.next = 5;
132
778
  break;
133
779
  }
134
- return _context.abrupt("return");
780
+ return _context8.abrupt("return");
135
781
  case 5:
136
782
  setIsSigningIn(true);
137
783
  codeVerifier = window.localStorage.getItem("verifier");
138
784
  if (!(!codeFromQuery || !codeVerifier)) {
139
- _context.next = 11;
785
+ _context8.next = 11;
140
786
  break;
141
787
  }
142
- // No code or verifier - redirect to login
143
788
  window.localStorage.clear();
144
789
  module.exports.authService().login();
145
- return _context.abrupt("return");
790
+ return _context8.abrupt("return");
146
791
  case 11:
147
792
  headers = {
148
793
  "Content-Type": "application/x-www-form-urlencoded"
@@ -155,18 +800,16 @@ function AuthScapeApp(_ref) {
155
800
  client_secret: process.env.client_secret,
156
801
  code_verifier: codeVerifier
157
802
  });
158
- _context.prev = 13;
159
- _context.next = 16;
803
+ _context8.prev = 13;
804
+ _context8.next = 16;
160
805
  return _axios["default"].post(process.env.authorityUri + "/connect/token", body, {
161
806
  headers: headers
162
807
  });
163
808
  case 16:
164
- response = _context.sent;
809
+ response = _context8.sent;
165
810
  domainHost = window.location.hostname.split(".").slice(-2).join(".");
166
811
  window.localStorage.removeItem("verifier");
167
-
168
- // NOTE: replace setCookie below with your implementation if different
169
- _context.next = 21;
812
+ _context8.next = 21;
170
813
  return setCookie("access_token", response.data.access_token, {
171
814
  maxAge: 60 * 60 * 24 * 365,
172
815
  path: "/",
@@ -174,7 +817,7 @@ function AuthScapeApp(_ref) {
174
817
  secure: true
175
818
  });
176
819
  case 21:
177
- _context.next = 23;
820
+ _context8.next = 23;
178
821
  return setCookie("expires_in", response.data.expires_in, {
179
822
  maxAge: 60 * 60 * 24 * 365,
180
823
  path: "/",
@@ -182,7 +825,7 @@ function AuthScapeApp(_ref) {
182
825
  secure: true
183
826
  });
184
827
  case 23:
185
- _context.next = 25;
828
+ _context8.next = 25;
186
829
  return setCookie("refresh_token", response.data.refresh_token, {
187
830
  maxAge: 60 * 60 * 24 * 365,
188
831
  path: "/",
@@ -192,89 +835,61 @@ function AuthScapeApp(_ref) {
192
835
  case 25:
193
836
  redirectUri = window.localStorage.getItem("redirectUri") || "/";
194
837
  window.localStorage.clear();
195
-
196
- // Use history.replaceState to change URL without a page reload, then fetch user
197
- window.history.replaceState({}, "", redirectUri);
198
-
199
- // Now load the current user and update state
200
- _context.prev = 28;
201
- _context.next = 31;
202
- return module.exports.apiService().GetCurrentUser();
203
- case 31:
204
- usr = _context.sent;
205
- signedInUser.current = ensureUserHelpers(usr);
206
- setSignedInUserState(signedInUser.current);
207
- setFrontEndLoadedState(true);
208
-
209
- // Trigger a soft navigation using Next.js router
210
- _router["default"].replace(redirectUri, undefined, {
211
- shallow: false
212
- });
213
- _context.next = 41;
214
- break;
215
- case 38:
216
- _context.prev = 38;
217
- _context.t0 = _context["catch"](28);
218
- // If we can't get user, still navigate
219
- _router["default"].replace(redirectUri);
220
- case 41:
221
- _context.next = 48;
838
+ window.location.href = redirectUri;
839
+ _context8.next = 36;
222
840
  break;
223
- case 43:
224
- _context.prev = 43;
225
- _context.t1 = _context["catch"](13);
226
- console.error("PKCE sign-in failed", _context.t1);
227
- // Invalid code - clear storage and redirect to login
841
+ case 30:
842
+ _context8.prev = 30;
843
+ _context8.t0 = _context8["catch"](13);
844
+ console.error("PKCE sign-in failed", _context8.t0);
228
845
  window.localStorage.clear();
846
+ setIsSigningIn(false);
229
847
  module.exports.authService().login();
230
- case 48:
848
+ case 36:
231
849
  case "end":
232
- return _context.stop();
850
+ return _context8.stop();
233
851
  }
234
- }, _callee, null, [[13, 43], [28, 38]]);
852
+ }, _callee8, null, [[13, 30]]);
235
853
  }));
236
- return function signInValidator(_x) {
237
- return _ref2.apply(this, arguments);
854
+ return function signInValidator(_x4) {
855
+ return _ref11.apply(this, arguments);
238
856
  };
239
857
  }();
240
-
241
- // ----- GA + Clarity -----
242
- function initGA(_x2) {
858
+ function initGA(_x5) {
243
859
  return _initGA.apply(this, arguments);
244
860
  }
245
861
  function _initGA() {
246
- _initGA = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(G) {
247
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
248
- while (1) switch (_context2.prev = _context2.next) {
862
+ _initGA = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(G) {
863
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
864
+ while (1) switch (_context9.prev = _context9.next) {
249
865
  case 0:
250
866
  if (!(typeof window !== "undefined" && !_ga4React["default"].isInitialized() && G)) {
251
- _context2.next = 10;
867
+ _context9.next = 10;
252
868
  break;
253
869
  }
254
870
  ga4React.current = new _ga4React["default"](G, {
255
871
  debug_mode: !process.env.production
256
872
  });
257
- _context2.prev = 2;
258
- _context2.next = 5;
873
+ _context9.prev = 2;
874
+ _context9.next = 5;
259
875
  return ga4React.current.initialize();
260
876
  case 5:
261
- _context2.next = 10;
877
+ _context9.next = 10;
262
878
  break;
263
879
  case 7:
264
- _context2.prev = 7;
265
- _context2.t0 = _context2["catch"](2);
266
- console.error(_context2.t0);
880
+ _context9.prev = 7;
881
+ _context9.t0 = _context9["catch"](2);
882
+ console.error(_context9.t0);
267
883
  case 10:
268
884
  case "end":
269
- return _context2.stop();
885
+ return _context9.stop();
270
886
  }
271
- }, _callee2, null, [[2, 7]]);
887
+ }, _callee9, null, [[2, 7]]);
272
888
  }));
273
889
  return _initGA.apply(this, arguments);
274
890
  }
275
891
  var logEvent = function logEvent(category, action, label) {
276
892
  if (ga4React.current) ga4React.current.event(action, label, category);
277
- // your DB analytics can go here if desired
278
893
  };
279
894
  var databaseDrivenPageView = function databaseDrivenPageView(pathName) {
280
895
  var _signedInUser$current, _signedInUser$current2, _signedInUser$current3;
@@ -282,8 +897,6 @@ function AuthScapeApp(_ref) {
282
897
  if (typeof window === "undefined") return;
283
898
  if (pathName === "/signin-oidc") return;
284
899
  var host = window.location.protocol + "//" + window.location.host;
285
-
286
- // Use module.exports to access sibling exports in babel bundle
287
900
  module.exports.apiService().post("/Analytics/PageView", {
288
901
  userId: (_signedInUser$current = signedInUser.current) === null || _signedInUser$current === void 0 ? void 0 : _signedInUser$current.id,
289
902
  locationId: (_signedInUser$current2 = signedInUser.current) === null || _signedInUser$current2 === void 0 ? void 0 : _signedInUser$current2.locationId,
@@ -292,8 +905,6 @@ function AuthScapeApp(_ref) {
292
905
  host: host
293
906
  });
294
907
  };
295
-
296
- // ----- Auth init (runs once) -----
297
908
  (0, _react.useEffect)(function () {
298
909
  if (queryCode) {
299
910
  signInValidator(queryCode);
@@ -302,13 +913,20 @@ function AuthScapeApp(_ref) {
302
913
  if (!loadingAuth.current) {
303
914
  loadingAuth.current = true;
304
915
  if (enableAuth) {
305
- // Use module.exports to access sibling exports in babel bundle
306
916
  module.exports.apiService().GetCurrentUser().then(function (usr) {
307
917
  signedInUser.current = ensureUserHelpers(usr);
308
918
  setSignedInUserState(signedInUser.current);
309
919
  setFrontEndLoadedState(true);
310
- })["catch"](function () {
311
- // no user / anonymous
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) {
312
930
  signedInUser.current = null;
313
931
  setSignedInUserState(null);
314
932
  setFrontEndLoadedState(true);
@@ -317,9 +935,7 @@ function AuthScapeApp(_ref) {
317
935
  setFrontEndLoadedState(true);
318
936
  }
319
937
  }
320
- }, [queryCode, enableAuth]);
321
-
322
- // ----- Analytics init -----
938
+ }, [queryCode, enableAuth, enableErrorTracking]);
323
939
  (0, _react.useEffect)(function () {
324
940
  if (!frontEndLoadedState || typeof window === "undefined") return;
325
941
  if (pageProps.googleAnalytics4Code) {
@@ -343,26 +959,17 @@ function AuthScapeApp(_ref) {
343
959
  return _router["default"].events.off("routeChangeComplete", handler);
344
960
  };
345
961
  }, [frontEndLoadedState, pageProps.googleAnalytics4Code, pageProps.microsoftClarityCode]);
346
-
347
- // ----- Enforce login (client) -----
348
962
  (0, _react.useEffect)(function () {
349
963
  if (enforceLoggedIn && pathname !== "/signin-oidc" && frontEndLoadedState && !signedInUserState) {
350
- // Use module.exports to access sibling exports in babel bundle
351
964
  module.exports.authService().login();
352
965
  }
353
966
  }, [signedInUserState, enforceLoggedIn, frontEndLoadedState, pathname]);
354
-
355
- // Stable getter for current user (with helpers)
356
967
  var currentUser = (0, _react.useMemo)(function () {
357
968
  return ensureUserHelpers(signedInUser.current);
358
969
  }, [signedInUserState]);
359
970
  var useStore = (0, _zustand.create)(function () {
360
971
  return store;
361
972
  });
362
-
363
- // ----- Render (SSR-safe; always output page so <title> is visible) -----
364
-
365
- // Default sign-in loading component if none provided
366
973
  var defaultSignInLoading = /*#__PURE__*/_react["default"].createElement("div", {
367
974
  style: {
368
975
  display: 'flex',
@@ -388,16 +995,26 @@ function AuthScapeApp(_ref) {
388
995
  color: '#666'
389
996
  }
390
997
  }, "Signing in..."), /*#__PURE__*/_react["default"].createElement("style", null, "\n @keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n "));
391
-
392
- // Show loading screen when on signin-oidc page
393
- if (isOnSignInPage || isSigningIn) {
998
+ if (isSigningIn) {
394
999
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_head["default"], null, /*#__PURE__*/_react["default"].createElement("meta", {
395
1000
  name: "viewport",
396
1001
  content: "width=device-width, initial-scale=0.86, maximum-scale=5.0, minimum-scale=0.86"
397
- })), /*#__PURE__*/_react["default"].createElement(_styles.ThemeProvider, {
398
- theme: muiTheme
1002
+ })), /*#__PURE__*/_react["default"].createElement(AppThemeProvider, {
1003
+ customTheme: muiTheme
399
1004
  }, signInLoadingComponent || defaultSignInLoading));
400
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);
401
1018
  var pageContent = layout ? layout({
402
1019
  children: /*#__PURE__*/_react["default"].createElement(Component, _extends({}, pageProps, {
403
1020
  currentUser: currentUser,
@@ -421,12 +1038,16 @@ function AuthScapeApp(_ref) {
421
1038
  store: useStore,
422
1039
  toast: _reactToastify.toast
423
1040
  }));
1041
+ var wrappedContent = enableNotifications && currentUser ? /*#__PURE__*/_react["default"].createElement(NotificationProvider, {
1042
+ currentUser: currentUser,
1043
+ apiService: module.exports.apiService
1044
+ }, pageContent) : pageContent;
424
1045
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_head["default"], null, /*#__PURE__*/_react["default"].createElement("meta", {
425
1046
  name: "viewport",
426
1047
  content: "width=device-width, initial-scale=0.86, maximum-scale=5.0, minimum-scale=0.86"
427
- })), /*#__PURE__*/_react["default"].createElement(_styles.ThemeProvider, {
428
- theme: muiTheme
429
- }, pageContent, /*#__PURE__*/_react["default"].createElement(_reactToastify.ToastContainer, null)), loadingLayout && loadingLayout(isLoadingShow));
1048
+ })), /*#__PURE__*/_react["default"].createElement(AppThemeProvider, {
1049
+ customTheme: muiTheme
1050
+ }, wrappedContent), /*#__PURE__*/_react["default"].createElement(_reactToastify.ToastContainer, defaultToastConfig), loadingLayout && loadingLayout(isLoadingShow));
430
1051
  }
431
1052
  "use strict";
432
1053
 
@@ -8977,6 +9598,19 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
8977
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; }
8978
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); }
8979
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
+ };
8980
9614
  var setupDefaultOptions = /*#__PURE__*/function () {
8981
9615
  var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
8982
9616
  var ctx,
@@ -9048,7 +9682,6 @@ var RefreshToken = /*#__PURE__*/function () {
9048
9682
  _context2.next = 10;
9049
9683
  return setCookie('access_token', response.data.access_token, {
9050
9684
  maxAge: 60 * 60 * 24 * 365,
9051
- // 1 year,
9052
9685
  path: '/',
9053
9686
  domain: domainHost,
9054
9687
  secure: true
@@ -9057,7 +9690,6 @@ var RefreshToken = /*#__PURE__*/function () {
9057
9690
  _context2.next = 12;
9058
9691
  return setCookie('expires_in', response.data.expires_in, {
9059
9692
  maxAge: 60 * 60 * 24 * 365,
9060
- // 1 year,
9061
9693
  path: '/',
9062
9694
  domain: domainHost,
9063
9695
  secure: true
@@ -9066,7 +9698,6 @@ var RefreshToken = /*#__PURE__*/function () {
9066
9698
  _context2.next = 14;
9067
9699
  return setCookie('refresh_token', response.data.refresh_token, {
9068
9700
  maxAge: 60 * 60 * 24 * 365,
9069
- // 1 year,
9070
9701
  path: '/',
9071
9702
  domain: domainHost,
9072
9703
  secure: true
@@ -9090,8 +9721,7 @@ var apiService = exports.apiService = function apiService() {
9090
9721
  var baseUri = process.env.apiUri + "/api";
9091
9722
  var instance = _axios["default"].create({
9092
9723
  baseURL: baseUri,
9093
- //timeout: 10000,
9094
- params: {} // do not remove this, its added to add params later in the config
9724
+ params: {}
9095
9725
  });
9096
9726
  instance.interceptors.response.use(function (response) {
9097
9727
  return response;
@@ -9111,8 +9741,6 @@ var apiService = exports.apiService = function apiService() {
9111
9741
  break;
9112
9742
  }
9113
9743
  originalConfig._retry = true;
9114
-
9115
- // Do something, call refreshToken() request for example;
9116
9744
  _context3.next = 6;
9117
9745
  return RefreshToken(originalConfig, instance);
9118
9746
  case 6:
@@ -9122,43 +9750,21 @@ var apiService = exports.apiService = function apiService() {
9122
9750
  _context3.next = 10;
9123
9751
  break;
9124
9752
  }
9125
- // Do something
9126
-
9127
- if (error.response.config.url.includes("/connect/token"))
9128
- // remove the access and refresh if invalid
9129
- {
9130
- domainHost = window.location.hostname.split('.').slice(-2).join('.');
9131
- _jsCookie["default"].remove('access_token', {
9132
- path: '/',
9133
- domain: domainHost
9134
- });
9135
- _jsCookie["default"].remove('refresh_token', {
9136
- path: '/',
9137
- domain: domainHost
9138
- });
9139
- _jsCookie["default"].remove('expires_in', {
9140
- path: '/',
9141
- domain: domainHost
9142
- });
9143
-
9144
- // destroyCookie(null, "access_token", {
9145
- // maxAge: 2147483647,
9146
- // path: '/',
9147
- // domain: domainHost
9148
- // });
9149
-
9150
- // destroyCookie(null, "refresh_token", {
9151
- // maxAge: 2147483647,
9152
- // path: '/',
9153
- // domain: domainHost
9154
- // });
9155
-
9156
- // destroyCookie(null, "expires_in", {
9157
- // maxAge: 2147483647,
9158
- // path: '/',
9159
- // domain: domainHost
9160
- // });
9161
- }
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
+ }
9162
9768
  return _context3.abrupt("return", Promise.reject(error));
9163
9769
  case 10:
9164
9770
  return _context3.abrupt("return", Promise.reject(error));
@@ -9331,16 +9937,14 @@ var apiService = exports.apiService = function apiService() {
9331
9937
  }
9332
9938
  return _context8.abrupt("return", response.data);
9333
9939
  case 11:
9334
- _context8.next = 16;
9940
+ _context8.next = 15;
9335
9941
  break;
9336
9942
  case 13:
9337
9943
  _context8.prev = 13;
9338
9944
  _context8.t0 = _context8["catch"](0);
9339
- //return -1;
9340
- console.log(_context8.t0.message);
9341
- case 16:
9945
+ case 15:
9342
9946
  return _context8.abrupt("return", null);
9343
- case 17:
9947
+ case 16:
9344
9948
  case "end":
9345
9949
  return _context8.stop();
9346
9950
  }
@@ -9369,7 +9973,6 @@ var apiService = exports.apiService = function apiService() {
9369
9973
  mimeType = _args9.length > 5 && _args9[5] !== undefined ? _args9[5] : "application/octet-stream";
9370
9974
  passData = _args9.length > 6 && _args9[6] !== undefined ? _args9[6] : false;
9371
9975
  _context9.prev = 4;
9372
- //let defaultOptions = await setupDefaultOptions();
9373
9976
  defaultOptions = {};
9374
9977
  options = {
9375
9978
  responseType: "blob"
@@ -9624,6 +10227,7 @@ var _authService = exports.authService = function authService() {
9624
10227
  state,
9625
10228
  verifier,
9626
10229
  challenge,
10230
+ storedVerifier,
9627
10231
  redirectUri,
9628
10232
  loginUri,
9629
10233
  _args4 = arguments;
@@ -9642,14 +10246,23 @@ var _authService = exports.authService = function authService() {
9642
10246
  return _authService().challenge_from_verifier(verifier);
9643
10247
  case 8:
9644
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);
9645
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);
9646
10258
  redirectUri = window.location.origin + "/signin-oidc";
9647
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";
9648
10260
  if (deviceId) {
9649
10261
  loginUri += "&deviceId=" + deviceId; // will be for chrome extention and mobile apps later
9650
10262
  }
10263
+ console.log('[PKCE] Redirecting to:', loginUri);
9651
10264
  window.location.href = loginUri;
9652
- case 14:
10265
+ case 23:
9653
10266
  case "end":
9654
10267
  return _context4.stop();
9655
10268
  }
@@ -9855,41 +10468,72 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default":
9855
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); }
9856
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; }
9857
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); }
9858
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); }
9859
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); }); }; }
9860
10478
  // import Cookies from 'js-cookie';
9861
10479
 
9862
10480
  var signInValidator = exports.signInValidator = /*#__PURE__*/function () {
9863
10481
  var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(queryCode) {
9864
- 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;
9865
10483
  return _regeneratorRuntime().wrap(function _callee$(_context) {
9866
10484
  while (1) switch (_context.prev = _context.next) {
9867
10485
  case 0:
9868
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);
9869
10490
  if (!(queryCode != null && codeVerifier != null)) {
9870
- _context.next = 18;
10491
+ _context.next = 38;
9871
10492
  break;
9872
10493
  }
9873
10494
  headers = {
9874
10495
  'Content-Type': 'application/x-www-form-urlencoded'
9875
10496
  };
9876
- queryString = _queryString["default"].stringify({
10497
+ tokenParams = {
9877
10498
  code: queryCode,
9878
10499
  grant_type: "authorization_code",
9879
10500
  redirect_uri: window.location.origin + "/signin-oidc",
9880
10501
  client_id: process.env.client_id,
9881
10502
  client_secret: process.env.client_secret,
9882
10503
  code_verifier: codeVerifier
9883
- });
9884
- _context.next = 6;
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;
9885
10515
  return _axios["default"].post(process.env.authorityUri + '/connect/token', queryString, {
9886
10516
  headers: headers
9887
10517
  });
9888
- case 6:
10518
+ case 14:
9889
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:
9890
10534
  domainHost = window.location.hostname.split('.').slice(-2).join('.');
9891
10535
  window.localStorage.removeItem("verifier");
9892
- _context.next = 11;
10536
+ _context.next = 31;
9893
10537
  return setCookie('access_token', response.data.access_token, {
9894
10538
  maxAge: 60 * 60 * 24 * 365,
9895
10539
  // 1 year,
@@ -9897,8 +10541,8 @@ var signInValidator = exports.signInValidator = /*#__PURE__*/function () {
9897
10541
  domain: domainHost,
9898
10542
  secure: true
9899
10543
  });
9900
- case 11:
9901
- _context.next = 13;
10544
+ case 31:
10545
+ _context.next = 33;
9902
10546
  return setCookie('expires_in', response.data.expires_in, {
9903
10547
  maxAge: 60 * 60 * 24 * 365,
9904
10548
  // 1 year,
@@ -9906,8 +10550,8 @@ var signInValidator = exports.signInValidator = /*#__PURE__*/function () {
9906
10550
  domain: domainHost,
9907
10551
  secure: true
9908
10552
  });
9909
- case 13:
9910
- _context.next = 15;
10553
+ case 33:
10554
+ _context.next = 35;
9911
10555
  return setCookie('refresh_token', response.data.refresh_token, {
9912
10556
  maxAge: 60 * 60 * 24 * 365,
9913
10557
  // 1 year,
@@ -9915,7 +10559,7 @@ var signInValidator = exports.signInValidator = /*#__PURE__*/function () {
9915
10559
  domain: domainHost,
9916
10560
  secure: true
9917
10561
  });
9918
- case 15:
10562
+ case 35:
9919
10563
  // await setCookie(null, "access_token", response.data.access_token,
9920
10564
  // {
9921
10565
  // maxAge: 2147483647,
@@ -9944,11 +10588,11 @@ var signInValidator = exports.signInValidator = /*#__PURE__*/function () {
9944
10588
  } else {
9945
10589
  window.location.href = "/";
9946
10590
  }
9947
- case 18:
10591
+ case 38:
9948
10592
  case "end":
9949
10593
  return _context.stop();
9950
10594
  }
9951
- }, _callee);
10595
+ }, _callee, null, [[11, 20]]);
9952
10596
  }));
9953
10597
  return function signInValidator(_x) {
9954
10598
  return _ref.apply(this, arguments);