dauth-context-react 1.0.1 → 1.0.3

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.
@@ -1,349 +1,146 @@
1
1
  import React, { useReducer, useCallback, useEffect, useMemo, createContext, useContext } from 'react';
2
2
 
3
- function _regeneratorRuntime() {
4
- _regeneratorRuntime = function () {
5
- return e;
6
- };
7
- var t,
8
- e = {},
9
- r = Object.prototype,
10
- n = r.hasOwnProperty,
11
- o = Object.defineProperty || function (t, e, r) {
12
- t[e] = r.value;
13
- },
14
- i = "function" == typeof Symbol ? Symbol : {},
15
- a = i.iterator || "@@iterator",
16
- c = i.asyncIterator || "@@asyncIterator",
17
- u = i.toStringTag || "@@toStringTag";
18
- function define(t, e, r) {
19
- return Object.defineProperty(t, e, {
20
- value: r,
21
- enumerable: !0,
22
- configurable: !0,
23
- writable: !0
24
- }), t[e];
25
- }
3
+ function asyncGeneratorStep(n, t, e, r, o, a, c) {
26
4
  try {
27
- define({}, "");
28
- } catch (t) {
29
- define = function (t, e, r) {
30
- return t[e] = r;
31
- };
32
- }
33
- function wrap(t, e, r, n) {
34
- var i = e && e.prototype instanceof Generator ? e : Generator,
35
- a = Object.create(i.prototype),
36
- c = new Context(n || []);
37
- return o(a, "_invoke", {
38
- value: makeInvokeMethod(t, r, c)
39
- }), a;
40
- }
41
- function tryCatch(t, e, r) {
42
- try {
43
- return {
44
- type: "normal",
45
- arg: t.call(e, r)
46
- };
47
- } catch (t) {
48
- return {
49
- type: "throw",
50
- arg: t
51
- };
52
- }
5
+ var i = n[a](c),
6
+ u = i.value;
7
+ } catch (n) {
8
+ return void e(n);
53
9
  }
54
- e.wrap = wrap;
55
- var h = "suspendedStart",
56
- l = "suspendedYield",
57
- f = "executing",
58
- s = "completed",
59
- y = {};
60
- function Generator() {}
61
- function GeneratorFunction() {}
62
- function GeneratorFunctionPrototype() {}
63
- var p = {};
64
- define(p, a, function () {
65
- return this;
66
- });
67
- var d = Object.getPrototypeOf,
68
- v = d && d(d(values([])));
69
- v && v !== r && n.call(v, a) && (p = v);
70
- var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
71
- function defineIteratorMethods(t) {
72
- ["next", "throw", "return"].forEach(function (e) {
73
- define(t, e, function (t) {
74
- return this._invoke(e, t);
75
- });
76
- });
77
- }
78
- function AsyncIterator(t, e) {
79
- function invoke(r, o, i, a) {
80
- var c = tryCatch(t[r], t, o);
81
- if ("throw" !== c.type) {
82
- var u = c.arg,
83
- h = u.value;
84
- return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
85
- invoke("next", t, i, a);
86
- }, function (t) {
87
- invoke("throw", t, i, a);
88
- }) : e.resolve(h).then(function (t) {
89
- u.value = t, i(u);
90
- }, function (t) {
91
- return invoke("throw", t, i, a);
92
- });
10
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
11
+ }
12
+ function _asyncToGenerator(n) {
13
+ return function () {
14
+ var t = this,
15
+ e = arguments;
16
+ return new Promise(function (r, o) {
17
+ var a = n.apply(t, e);
18
+ function _next(n) {
19
+ asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
93
20
  }
94
- a(c.arg);
95
- }
96
- var r;
97
- o(this, "_invoke", {
98
- value: function (t, n) {
99
- function callInvokeWithMethodAndArg() {
100
- return new e(function (e, r) {
101
- invoke(t, n, e, r);
102
- });
103
- }
104
- return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
21
+ function _throw(n) {
22
+ asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
105
23
  }
24
+ _next(void 0);
106
25
  });
107
- }
108
- function makeInvokeMethod(e, r, n) {
109
- var o = h;
110
- return function (i, a) {
111
- if (o === f) throw new Error("Generator is already running");
112
- if (o === s) {
113
- if ("throw" === i) throw a;
114
- return {
115
- value: t,
116
- done: !0
26
+ };
27
+ }
28
+ function _extends() {
29
+ return _extends = Object.assign ? Object.assign.bind() : function (n) {
30
+ for (var e = 1; e < arguments.length; e++) {
31
+ var t = arguments[e];
32
+ for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
33
+ }
34
+ return n;
35
+ }, _extends.apply(null, arguments);
36
+ }
37
+ function _regenerator() {
38
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
39
+ var e,
40
+ t,
41
+ r = "function" == typeof Symbol ? Symbol : {},
42
+ n = r.iterator || "@@iterator",
43
+ o = r.toStringTag || "@@toStringTag";
44
+ function i(r, n, o, i) {
45
+ var c = n && n.prototype instanceof Generator ? n : Generator,
46
+ u = Object.create(c.prototype);
47
+ return _regeneratorDefine(u, "_invoke", function (r, n, o) {
48
+ var i,
49
+ c,
50
+ u,
51
+ f = 0,
52
+ p = o || [],
53
+ y = !1,
54
+ G = {
55
+ p: 0,
56
+ n: 0,
57
+ v: e,
58
+ a: d,
59
+ f: d.bind(e, 4),
60
+ d: function (t, r) {
61
+ return i = t, c = 0, u = e, G.n = r, a;
62
+ }
117
63
  };
64
+ function d(r, n) {
65
+ for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
66
+ var o,
67
+ i = p[t],
68
+ d = G.p,
69
+ l = i[2];
70
+ r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
71
+ }
72
+ if (o || r > 1) return a;
73
+ throw y = !0, n;
118
74
  }
119
- for (n.method = i, n.arg = a;;) {
120
- var c = n.delegate;
121
- if (c) {
122
- var u = maybeInvokeDelegate(c, n);
123
- if (u) {
124
- if (u === y) continue;
125
- return u;
75
+ return function (o, p, l) {
76
+ if (f > 1) throw TypeError("Generator is already running");
77
+ for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
78
+ i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
79
+ try {
80
+ if (f = 2, i) {
81
+ if (c || (o = "next"), t = i[o]) {
82
+ if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
83
+ if (!t.done) return t;
84
+ u = t.value, c < 2 && (c = 0);
85
+ } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
86
+ i = e;
87
+ } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
88
+ } catch (t) {
89
+ i = e, c = 1, u = t;
90
+ } finally {
91
+ f = 1;
126
92
  }
127
93
  }
128
- if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
129
- if (o === h) throw o = s, n.arg;
130
- n.dispatchException(n.arg);
131
- } else "return" === n.method && n.abrupt("return", n.arg);
132
- o = f;
133
- var p = tryCatch(e, r, n);
134
- if ("normal" === p.type) {
135
- if (o = n.done ? s : l, p.arg === y) continue;
136
- return {
137
- value: p.arg,
138
- done: n.done
139
- };
140
- }
141
- "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
142
- }
143
- };
144
- }
145
- function maybeInvokeDelegate(e, r) {
146
- var n = r.method,
147
- o = e.iterator[n];
148
- 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;
149
- var i = tryCatch(o, e.iterator, r.arg);
150
- if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
151
- var a = i.arg;
152
- 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);
153
- }
154
- function pushTryEntry(t) {
155
- var e = {
156
- tryLoc: t[0]
157
- };
158
- 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
159
- }
160
- function resetTryEntry(t) {
161
- var e = t.completion || {};
162
- e.type = "normal", delete e.arg, t.completion = e;
163
- }
164
- function Context(t) {
165
- this.tryEntries = [{
166
- tryLoc: "root"
167
- }], t.forEach(pushTryEntry, this), this.reset(!0);
94
+ return {
95
+ value: t,
96
+ done: y
97
+ };
98
+ };
99
+ }(r, o, i), !0), u;
168
100
  }
169
- function values(e) {
170
- if (e || "" === e) {
171
- var r = e[a];
172
- if (r) return r.call(e);
173
- if ("function" == typeof e.next) return e;
174
- if (!isNaN(e.length)) {
175
- var o = -1,
176
- i = function next() {
177
- for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
178
- return next.value = t, next.done = !0, next;
179
- };
180
- return i.next = i;
181
- }
182
- }
183
- throw new TypeError(typeof e + " is not iterable");
101
+ var a = {};
102
+ function Generator() {}
103
+ function GeneratorFunction() {}
104
+ function GeneratorFunctionPrototype() {}
105
+ t = Object.getPrototypeOf;
106
+ var c = [][n] ? t(t([][n]())) : (_regeneratorDefine(t = {}, n, function () {
107
+ return this;
108
+ }), t),
109
+ u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
110
+ function f(e) {
111
+ return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
184
112
  }
185
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
186
- value: GeneratorFunctionPrototype,
187
- configurable: !0
188
- }), o(GeneratorFunctionPrototype, "constructor", {
189
- value: GeneratorFunction,
190
- configurable: !0
191
- }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
192
- var e = "function" == typeof t && t.constructor;
193
- return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
194
- }, e.mark = function (t) {
195
- return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
196
- }, e.awrap = function (t) {
197
- return {
198
- __await: t
199
- };
200
- }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
201
- return this;
202
- }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
203
- void 0 === i && (i = Promise);
204
- var a = new AsyncIterator(wrap(t, r, n, o), i);
205
- return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
206
- return t.done ? t.value : a.next();
207
- });
208
- }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
113
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine(u), _regeneratorDefine(u, o, "Generator"), _regeneratorDefine(u, n, function () {
209
114
  return this;
210
- }), define(g, "toString", function () {
115
+ }), _regeneratorDefine(u, "toString", function () {
211
116
  return "[object Generator]";
212
- }), e.keys = function (t) {
213
- var e = Object(t),
214
- r = [];
215
- for (var n in e) r.push(n);
216
- return r.reverse(), function next() {
217
- for (; r.length;) {
218
- var t = r.pop();
219
- if (t in e) return next.value = t, next.done = !1, next;
220
- }
221
- return next.done = !0, next;
117
+ }), (_regenerator = function () {
118
+ return {
119
+ w: i,
120
+ m: f
222
121
  };
223
- }, e.values = values, Context.prototype = {
224
- constructor: Context,
225
- reset: function (e) {
226
- 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);
227
- },
228
- stop: function () {
229
- this.done = !0;
230
- var t = this.tryEntries[0].completion;
231
- if ("throw" === t.type) throw t.arg;
232
- return this.rval;
233
- },
234
- dispatchException: function (e) {
235
- if (this.done) throw e;
236
- var r = this;
237
- function handle(n, o) {
238
- return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
239
- }
240
- for (var o = this.tryEntries.length - 1; o >= 0; --o) {
241
- var i = this.tryEntries[o],
242
- a = i.completion;
243
- if ("root" === i.tryLoc) return handle("end");
244
- if (i.tryLoc <= this.prev) {
245
- var c = n.call(i, "catchLoc"),
246
- u = n.call(i, "finallyLoc");
247
- if (c && u) {
248
- if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
249
- if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
250
- } else if (c) {
251
- if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
252
- } else {
253
- if (!u) throw new Error("try statement without catch or finally");
254
- if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
255
- }
256
- }
257
- }
258
- },
259
- abrupt: function (t, e) {
260
- for (var r = this.tryEntries.length - 1; r >= 0; --r) {
261
- var o = this.tryEntries[r];
262
- if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
263
- var i = o;
264
- break;
265
- }
266
- }
267
- i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
268
- var a = i ? i.completion : {};
269
- return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
270
- },
271
- complete: function (t, e) {
272
- if ("throw" === t.type) throw t.arg;
273
- 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;
274
- },
275
- finish: function (t) {
276
- for (var e = this.tryEntries.length - 1; e >= 0; --e) {
277
- var r = this.tryEntries[e];
278
- if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
279
- }
280
- },
281
- catch: function (t) {
282
- for (var e = this.tryEntries.length - 1; e >= 0; --e) {
283
- var r = this.tryEntries[e];
284
- if (r.tryLoc === t) {
285
- var n = r.completion;
286
- if ("throw" === n.type) {
287
- var o = n.arg;
288
- resetTryEntry(r);
289
- }
290
- return o;
291
- }
292
- }
293
- throw new Error("illegal catch attempt");
294
- },
295
- delegateYield: function (e, r, n) {
296
- return this.delegate = {
297
- iterator: values(e),
298
- resultName: r,
299
- nextLoc: n
300
- }, "next" === this.method && (this.arg = t), y;
301
- }
302
- }, e;
122
+ })();
303
123
  }
304
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
124
+ function _regeneratorDefine(e, r, n, t) {
125
+ var i = Object.defineProperty;
305
126
  try {
306
- var info = gen[key](arg);
307
- var value = info.value;
308
- } catch (error) {
309
- reject(error);
310
- return;
311
- }
312
- if (info.done) {
313
- resolve(value);
314
- } else {
315
- Promise.resolve(value).then(_next, _throw);
127
+ i({}, "", {});
128
+ } catch (e) {
129
+ i = 0;
316
130
  }
317
- }
318
- function _asyncToGenerator(fn) {
319
- return function () {
320
- var self = this,
321
- args = arguments;
322
- return new Promise(function (resolve, reject) {
323
- var gen = fn.apply(self, args);
324
- function _next(value) {
325
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
326
- }
327
- function _throw(err) {
328
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
329
- }
330
- _next(undefined);
331
- });
332
- };
333
- }
334
- function _extends() {
335
- _extends = Object.assign ? Object.assign.bind() : function (target) {
336
- for (var i = 1; i < arguments.length; i++) {
337
- var source = arguments[i];
338
- for (var key in source) {
339
- if (Object.prototype.hasOwnProperty.call(source, key)) {
340
- target[key] = source[key];
341
- }
342
- }
131
+ _regeneratorDefine = function (e, r, n, t) {
132
+ function o(r, n) {
133
+ _regeneratorDefine(e, r, function (e) {
134
+ return this._invoke(r, n, e);
135
+ });
343
136
  }
344
- return target;
345
- };
346
- return _extends.apply(this, arguments);
137
+ r ? i ? i(e, r, {
138
+ value: n,
139
+ enumerable: !t,
140
+ configurable: !t,
141
+ writable: !t
142
+ }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
143
+ }, _regeneratorDefine(e, r, n, t);
347
144
  }
348
145
 
349
146
  var initialDauthState = {
@@ -441,30 +238,26 @@ function checkIsLocalhost() {
441
238
  var hostname = window.location.hostname;
442
239
  return Boolean(hostname === 'localhost' || hostname === '[::1]' || hostname.match(/(192)\.(168)\.(1)\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/gm) || hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/));
443
240
  }
444
- function getServerBasePath(_ref) {
445
- var domainName = _ref.domainName;
241
+ function getServerBasePath() {
446
242
  var isLocalhost = checkIsLocalhost();
447
243
  var serverPort = 4012;
448
244
  var serverLocalUrl = window.location.protocol + "//" + window.location.hostname + ":" + serverPort + "/api/" + apiVersion;
449
- var serverProdUrl = "https://" + domainName + "." + serverDomain + "/api/" + apiVersion;
450
- var serverBasePath = isLocalhost ? serverLocalUrl : serverProdUrl;
451
- return serverBasePath;
245
+ var serverProdUrl = "https://" + serverDomain + "/api/" + apiVersion;
246
+ return isLocalhost ? serverLocalUrl : serverProdUrl;
452
247
  }
453
- function getClientBasePath(_ref2) {
454
- var domainName = _ref2.domainName;
248
+ function getClientBasePath() {
455
249
  var isLocalhost = checkIsLocalhost();
456
250
  var clientPort = 5185;
457
251
  var clientLocalUrl = window.location.protocol + "//" + window.location.hostname + ":" + clientPort;
458
- var clientProdUrl = "https://" + domainName + "." + serverDomain;
459
- var clientBasePath = isLocalhost ? clientLocalUrl : clientProdUrl;
460
- return clientBasePath;
252
+ var clientProdUrl = "https://" + serverDomain;
253
+ return isLocalhost ? clientLocalUrl : clientProdUrl;
461
254
  }
462
255
 
463
256
  var getUserAPI = /*#__PURE__*/function () {
464
- var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(domainName, token) {
257
+ var _ref = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(domainName, token) {
465
258
  var params, response, data;
466
- return _regeneratorRuntime().wrap(function _callee$(_context) {
467
- while (1) switch (_context.prev = _context.next) {
259
+ return _regenerator().w(function (_context) {
260
+ while (1) switch (_context.n) {
468
261
  case 0:
469
262
  params = {
470
263
  method: 'GET',
@@ -473,23 +266,18 @@ var getUserAPI = /*#__PURE__*/function () {
473
266
  'Content-Type': 'application/json'
474
267
  }
475
268
  };
476
- _context.next = 3;
477
- return fetch(getServerBasePath({
478
- domainName: domainName
479
- }) + "/tenant/" + domainName + "/user", params);
480
- case 3:
481
- response = _context.sent;
482
- _context.next = 6;
269
+ _context.n = 1;
270
+ return fetch(getServerBasePath() + "/app/" + domainName + "/user", params);
271
+ case 1:
272
+ response = _context.v;
273
+ _context.n = 2;
483
274
  return response.json();
484
- case 6:
485
- data = _context.sent;
486
- return _context.abrupt("return", {
275
+ case 2:
276
+ data = _context.v;
277
+ return _context.a(2, {
487
278
  response: response,
488
279
  data: data
489
280
  });
490
- case 8:
491
- case "end":
492
- return _context.stop();
493
281
  }
494
282
  }, _callee);
495
283
  }));
@@ -498,10 +286,10 @@ var getUserAPI = /*#__PURE__*/function () {
498
286
  };
499
287
  }();
500
288
  var updateUserAPI = /*#__PURE__*/function () {
501
- var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(domainName, user, token) {
289
+ var _ref2 = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(domainName, user, token) {
502
290
  var params, response, data;
503
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
504
- while (1) switch (_context2.prev = _context2.next) {
291
+ return _regenerator().w(function (_context2) {
292
+ while (1) switch (_context2.n) {
505
293
  case 0:
506
294
  params = {
507
295
  method: 'PATCH',
@@ -511,23 +299,18 @@ var updateUserAPI = /*#__PURE__*/function () {
511
299
  },
512
300
  body: JSON.stringify(user)
513
301
  };
514
- _context2.next = 3;
515
- return fetch(getServerBasePath({
516
- domainName: domainName
517
- }) + "/tenant/" + domainName + "/user", params);
518
- case 3:
519
- response = _context2.sent;
520
- _context2.next = 6;
302
+ _context2.n = 1;
303
+ return fetch(getServerBasePath() + "/app/" + domainName + "/user", params);
304
+ case 1:
305
+ response = _context2.v;
306
+ _context2.n = 2;
521
307
  return response.json();
522
- case 6:
523
- data = _context2.sent;
524
- return _context2.abrupt("return", {
308
+ case 2:
309
+ data = _context2.v;
310
+ return _context2.a(2, {
525
311
  response: response,
526
312
  data: data
527
313
  });
528
- case 8:
529
- case "end":
530
- return _context2.stop();
531
314
  }
532
315
  }, _callee2);
533
316
  }));
@@ -536,10 +319,10 @@ var updateUserAPI = /*#__PURE__*/function () {
536
319
  };
537
320
  }();
538
321
  var sendEmailVerificationAPI = /*#__PURE__*/function () {
539
- var _ref3 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(domainName, token) {
322
+ var _ref3 = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(domainName, token) {
540
323
  var params, response, data;
541
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
542
- while (1) switch (_context3.prev = _context3.next) {
324
+ return _regenerator().w(function (_context3) {
325
+ while (1) switch (_context3.n) {
543
326
  case 0:
544
327
  params = {
545
328
  method: 'GET',
@@ -548,23 +331,18 @@ var sendEmailVerificationAPI = /*#__PURE__*/function () {
548
331
  'Content-Type': 'application/json'
549
332
  }
550
333
  };
551
- _context3.next = 3;
552
- return fetch(getServerBasePath({
553
- domainName: domainName
554
- }) + "/tenant/" + domainName + "/resend-email-verification", params);
555
- case 3:
556
- response = _context3.sent;
557
- _context3.next = 6;
334
+ _context3.n = 1;
335
+ return fetch(getServerBasePath() + "/app/" + domainName + "/resend-email-verification", params);
336
+ case 1:
337
+ response = _context3.v;
338
+ _context3.n = 2;
558
339
  return response.json();
559
- case 6:
560
- data = _context3.sent;
561
- return _context3.abrupt("return", {
340
+ case 2:
341
+ data = _context3.v;
342
+ return _context3.a(2, {
562
343
  response: response,
563
344
  data: data
564
345
  });
565
- case 8:
566
- case "end":
567
- return _context3.stop();
568
346
  }
569
347
  }, _callee3);
570
348
  }));
@@ -573,10 +351,10 @@ var sendEmailVerificationAPI = /*#__PURE__*/function () {
573
351
  };
574
352
  }();
575
353
  var refreshAccessTokenAPI = /*#__PURE__*/function () {
576
- var _ref4 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(domainName, token) {
354
+ var _ref4 = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(domainName, token) {
577
355
  var params, response, data;
578
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
579
- while (1) switch (_context4.prev = _context4.next) {
356
+ return _regenerator().w(function (_context4) {
357
+ while (1) switch (_context4.n) {
580
358
  case 0:
581
359
  params = {
582
360
  method: 'GET',
@@ -585,23 +363,18 @@ var refreshAccessTokenAPI = /*#__PURE__*/function () {
585
363
  'Content-Type': 'application/json'
586
364
  }
587
365
  };
588
- _context4.next = 3;
589
- return fetch(getServerBasePath({
590
- domainName: domainName
591
- }) + "/tenant/" + domainName + "/refresh-access-token", params);
592
- case 3:
593
- response = _context4.sent;
594
- _context4.next = 6;
366
+ _context4.n = 1;
367
+ return fetch(getServerBasePath() + "/app/" + domainName + "/refresh-access-token", params);
368
+ case 1:
369
+ response = _context4.v;
370
+ _context4.n = 2;
595
371
  return response.json();
596
- case 6:
597
- data = _context4.sent;
598
- return _context4.abrupt("return", {
372
+ case 2:
373
+ data = _context4.v;
374
+ return _context4.a(2, {
599
375
  response: response,
600
376
  data: data
601
377
  });
602
- case 8:
603
- case "end":
604
- return _context4.stop();
605
378
  }
606
379
  }, _callee4);
607
380
  }));
@@ -610,10 +383,10 @@ var refreshAccessTokenAPI = /*#__PURE__*/function () {
610
383
  };
611
384
  }();
612
385
  var verifyTokenAPI = /*#__PURE__*/function () {
613
- var _ref6 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(_ref5) {
386
+ var _ref6 = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(_ref5) {
614
387
  var domainName, tsk, token, params, response, data;
615
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
616
- while (1) switch (_context5.prev = _context5.next) {
388
+ return _regenerator().w(function (_context5) {
389
+ while (1) switch (_context5.n) {
617
390
  case 0:
618
391
  domainName = _ref5.domainName, tsk = _ref5.tsk, token = _ref5.token;
619
392
  params = {
@@ -626,27 +399,22 @@ var verifyTokenAPI = /*#__PURE__*/function () {
626
399
  tsk: tsk
627
400
  })
628
401
  };
629
- _context5.next = 4;
630
- return fetch(getServerBasePath({
631
- domainName: domainName
632
- }) + "/tenant/" + domainName + "/verify-token", params);
633
- case 4:
634
- response = _context5.sent;
635
- _context5.next = 7;
402
+ _context5.n = 1;
403
+ return fetch(getServerBasePath() + "/app/" + domainName + "/verify-token", params);
404
+ case 1:
405
+ response = _context5.v;
406
+ _context5.n = 2;
636
407
  return response.json();
637
- case 7:
638
- data = _context5.sent;
639
- return _context5.abrupt("return", {
408
+ case 2:
409
+ data = _context5.v;
410
+ return _context5.a(2, {
640
411
  response: response,
641
412
  data: data
642
413
  });
643
- case 9:
644
- case "end":
645
- return _context5.stop();
646
414
  }
647
415
  }, _callee5);
648
416
  }));
649
- return function verifyTokenAPI(_x10) {
417
+ return function verifyTokenAPI(_x0) {
650
418
  return _ref6.apply(this, arguments);
651
419
  };
652
420
  }();
@@ -662,10 +430,10 @@ function setDauthStateAction(_x) {
662
430
  return _setDauthStateAction.apply(this, arguments);
663
431
  }
664
432
  function _setDauthStateAction() {
665
- _setDauthStateAction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
666
- var dispatch, token, domainName, getUserFetch;
667
- return _regeneratorRuntime().wrap(function _callee$(_context) {
668
- while (1) switch (_context.prev = _context.next) {
433
+ _setDauthStateAction = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
434
+ var dispatch, token, domainName, getUserFetch, _t;
435
+ return _regenerator().w(function (_context) {
436
+ while (1) switch (_context.p = _context.n) {
669
437
  case 0:
670
438
  dispatch = _ref.dispatch, token = _ref.token, domainName = _ref.domainName;
671
439
  dispatch({
@@ -674,13 +442,13 @@ function _setDauthStateAction() {
674
442
  isLoading: true
675
443
  }
676
444
  });
677
- _context.prev = 2;
678
- _context.next = 5;
445
+ _context.p = 1;
446
+ _context.n = 2;
679
447
  return getUserAPI(domainName, token);
680
- case 5:
681
- getUserFetch = _context.sent;
448
+ case 2:
449
+ getUserFetch = _context.v;
682
450
  if (!(getUserFetch.response.status === 200)) {
683
- _context.next = 12;
451
+ _context.n = 3;
684
452
  break;
685
453
  }
686
454
  dispatch({
@@ -691,32 +459,31 @@ function _setDauthStateAction() {
691
459
  isAuthenticated: true
692
460
  }
693
461
  });
694
- window.history.replaceState({}, document.title, getUserFetch.data.domain.loginRedirect);
695
- return _context.abrupt("return", localStorage.setItem(TOKEN_LS, token));
696
- case 12:
697
- return _context.abrupt("return", resetUser(dispatch));
698
- case 13:
699
- _context.next = 19;
462
+ window.history.replaceState({}, document.title, window.location.pathname);
463
+ return _context.a(2, localStorage.setItem(TOKEN_LS, token));
464
+ case 3:
465
+ return _context.a(2, resetUser(dispatch));
466
+ case 4:
467
+ _context.n = 6;
700
468
  break;
701
- case 15:
702
- _context.prev = 15;
703
- _context.t0 = _context["catch"](2);
704
- console.error(_context.t0);
705
- return _context.abrupt("return", resetUser(dispatch));
706
- case 19:
707
- _context.prev = 19;
469
+ case 5:
470
+ _context.p = 5;
471
+ _t = _context.v;
472
+ console.error(_t);
473
+ return _context.a(2, resetUser(dispatch));
474
+ case 6:
475
+ _context.p = 6;
708
476
  dispatch({
709
477
  type: SET_IS_LOADING,
710
478
  payload: {
711
479
  isLoading: false
712
480
  }
713
481
  });
714
- return _context.finish(19);
715
- case 22:
716
- case "end":
717
- return _context.stop();
482
+ return _context.f(6);
483
+ case 7:
484
+ return _context.a(2);
718
485
  }
719
- }, _callee, null, [[2, 15, 19, 22]]);
486
+ }, _callee, null, [[1, 5, 6, 7]]);
720
487
  }));
721
488
  return _setDauthStateAction.apply(this, arguments);
722
489
  }
@@ -724,10 +491,10 @@ function setAutoLoginAction(_x2) {
724
491
  return _setAutoLoginAction.apply(this, arguments);
725
492
  }
726
493
  function _setAutoLoginAction() {
727
- _setAutoLoginAction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref2) {
728
- var dispatch, token_ls, domainName, refreshAccessTokenFetch, newToken, getUserFetch;
729
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
730
- while (1) switch (_context2.prev = _context2.next) {
494
+ _setAutoLoginAction = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref2) {
495
+ var dispatch, token_ls, domainName, refreshAccessTokenFetch, newToken, getUserFetch, _t2;
496
+ return _regenerator().w(function (_context2) {
497
+ while (1) switch (_context2.p = _context2.n) {
731
498
  case 0:
732
499
  dispatch = _ref2.dispatch, token_ls = _ref2.token_ls, domainName = _ref2.domainName;
733
500
  dispatch({
@@ -736,22 +503,22 @@ function _setAutoLoginAction() {
736
503
  isLoading: true
737
504
  }
738
505
  });
739
- _context2.prev = 2;
740
- _context2.next = 5;
506
+ _context2.p = 1;
507
+ _context2.n = 2;
741
508
  return refreshAccessTokenAPI(domainName, token_ls);
742
- case 5:
743
- refreshAccessTokenFetch = _context2.sent;
509
+ case 2:
510
+ refreshAccessTokenFetch = _context2.v;
744
511
  if (!(refreshAccessTokenFetch.response.status === 200)) {
745
- _context2.next = 21;
512
+ _context2.n = 6;
746
513
  break;
747
514
  }
748
515
  newToken = refreshAccessTokenFetch.data.accessToken || token_ls;
749
- _context2.next = 10;
516
+ _context2.n = 3;
750
517
  return getUserAPI(domainName, newToken);
751
- case 10:
752
- getUserFetch = _context2.sent;
518
+ case 3:
519
+ getUserFetch = _context2.v;
753
520
  if (!(getUserFetch.response.status === 200)) {
754
- _context2.next = 17;
521
+ _context2.n = 4;
755
522
  break;
756
523
  }
757
524
  dispatch({
@@ -763,42 +530,37 @@ function _setAutoLoginAction() {
763
530
  }
764
531
  });
765
532
  localStorage.setItem(TOKEN_LS, refreshAccessTokenFetch.data.accessToken);
766
- return _context2.abrupt("return");
767
- case 17:
768
- window.location.replace(getClientBasePath({
769
- domainName: domainName
770
- }) + "/" + domainName + "/" + routes.signin);
771
- return _context2.abrupt("return", resetUser(dispatch));
772
- case 19:
773
- _context2.next = 23;
533
+ return _context2.a(2);
534
+ case 4:
535
+ window.location.replace(getClientBasePath() + "/" + domainName + "/" + routes.signin);
536
+ return _context2.a(2, resetUser(dispatch));
537
+ case 5:
538
+ _context2.n = 7;
774
539
  break;
775
- case 21:
776
- window.location.replace(getClientBasePath({
777
- domainName: domainName
778
- }) + "/" + domainName + "/" + routes.signin);
779
- return _context2.abrupt("return", resetUser(dispatch));
780
- case 23:
781
- _context2.next = 29;
540
+ case 6:
541
+ window.location.replace(getClientBasePath() + "/" + domainName + "/" + routes.signin);
542
+ return _context2.a(2, resetUser(dispatch));
543
+ case 7:
544
+ _context2.n = 9;
782
545
  break;
783
- case 25:
784
- _context2.prev = 25;
785
- _context2.t0 = _context2["catch"](2);
786
- console.error(_context2.t0);
787
- return _context2.abrupt("return", resetUser(dispatch));
788
- case 29:
789
- _context2.prev = 29;
546
+ case 8:
547
+ _context2.p = 8;
548
+ _t2 = _context2.v;
549
+ console.error(_t2);
550
+ return _context2.a(2, resetUser(dispatch));
551
+ case 9:
552
+ _context2.p = 9;
790
553
  dispatch({
791
554
  type: SET_IS_LOADING,
792
555
  payload: {
793
556
  isLoading: false
794
557
  }
795
558
  });
796
- return _context2.finish(29);
797
- case 32:
798
- case "end":
799
- return _context2.stop();
559
+ return _context2.f(9);
560
+ case 10:
561
+ return _context2.a(2);
800
562
  }
801
- }, _callee2, null, [[2, 25, 29, 32]]);
563
+ }, _callee2, null, [[1, 8, 9, 10]]);
802
564
  }));
803
565
  return _setAutoLoginAction.apply(this, arguments);
804
566
  }
@@ -832,55 +594,54 @@ function setUpdateUserAction(_x3) {
832
594
  return _setUpdateUserAction.apply(this, arguments);
833
595
  }
834
596
  function _setUpdateUserAction() {
835
- _setUpdateUserAction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref4) {
836
- var dispatch, domainName, user, token, getUserFetch;
837
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
838
- while (1) switch (_context3.prev = _context3.next) {
597
+ _setUpdateUserAction = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(_ref4) {
598
+ var dispatch, domainName, user, token, getUserFetch, _t3;
599
+ return _regenerator().w(function (_context3) {
600
+ while (1) switch (_context3.p = _context3.n) {
839
601
  case 0:
840
602
  dispatch = _ref4.dispatch, domainName = _ref4.domainName, user = _ref4.user, token = _ref4.token;
841
603
  if (user.language) {
842
604
  window.document.documentElement.setAttribute('lang', user.language);
843
605
  }
844
606
  if (token) {
845
- _context3.next = 5;
607
+ _context3.n = 1;
846
608
  break;
847
609
  }
848
610
  dispatch({
849
611
  type: UPDATE_USER,
850
612
  payload: user
851
613
  });
852
- return _context3.abrupt("return", false);
853
- case 5:
854
- _context3.prev = 5;
855
- _context3.next = 8;
614
+ return _context3.a(2, false);
615
+ case 1:
616
+ _context3.p = 1;
617
+ _context3.n = 2;
856
618
  return updateUserAPI(domainName, user, token);
857
- case 8:
858
- getUserFetch = _context3.sent;
619
+ case 2:
620
+ getUserFetch = _context3.v;
859
621
  if (!(getUserFetch.response.status === 200)) {
860
- _context3.next = 14;
622
+ _context3.n = 3;
861
623
  break;
862
624
  }
863
625
  dispatch({
864
626
  type: UPDATE_USER,
865
627
  payload: getUserFetch.data.user
866
628
  });
867
- return _context3.abrupt("return", true);
868
- case 14:
629
+ return _context3.a(2, true);
630
+ case 3:
869
631
  console.error('Update user error', getUserFetch.data.message);
870
- return _context3.abrupt("return", false);
871
- case 16:
872
- _context3.next = 22;
632
+ return _context3.a(2, false);
633
+ case 4:
634
+ _context3.n = 6;
873
635
  break;
874
- case 18:
875
- _context3.prev = 18;
876
- _context3.t0 = _context3["catch"](5);
877
- console.error('Update user error', _context3.t0);
878
- return _context3.abrupt("return", false);
879
- case 22:
880
- case "end":
881
- return _context3.stop();
636
+ case 5:
637
+ _context3.p = 5;
638
+ _t3 = _context3.v;
639
+ console.error('Update user error', _t3);
640
+ return _context3.a(2, false);
641
+ case 6:
642
+ return _context3.a(2);
882
643
  }
883
- }, _callee3, null, [[5, 18]]);
644
+ }, _callee3, null, [[1, 5]]);
884
645
  }));
885
646
  return _setUpdateUserAction.apply(this, arguments);
886
647
  }
@@ -888,10 +649,10 @@ function sendEmailVerificationAction(_x4) {
888
649
  return _sendEmailVerificationAction.apply(this, arguments);
889
650
  }
890
651
  function _sendEmailVerificationAction() {
891
- _sendEmailVerificationAction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(_ref5) {
652
+ _sendEmailVerificationAction = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(_ref5) {
892
653
  var dispatch, domainName, token, sendEmailFetch;
893
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
894
- while (1) switch (_context4.prev = _context4.next) {
654
+ return _regenerator().w(function (_context4) {
655
+ while (1) switch (_context4.p = _context4.n) {
895
656
  case 0:
896
657
  dispatch = _ref5.dispatch, domainName = _ref5.domainName, token = _ref5.token;
897
658
  dispatch({
@@ -905,13 +666,13 @@ function _sendEmailVerificationAction() {
905
666
  message: 'Sending email verification...'
906
667
  }
907
668
  });
908
- _context4.prev = 3;
909
- _context4.next = 6;
669
+ _context4.p = 1;
670
+ _context4.n = 2;
910
671
  return sendEmailVerificationAPI(domainName, token);
911
- case 6:
912
- sendEmailFetch = _context4.sent;
672
+ case 2:
673
+ sendEmailFetch = _context4.v;
913
674
  if (!(sendEmailFetch.response.status === 200)) {
914
- _context4.next = 13;
675
+ _context4.n = 3;
915
676
  break;
916
677
  }
917
678
  dispatch({
@@ -925,8 +686,8 @@ function _sendEmailVerificationAction() {
925
686
  type: SET_SEND_EMAIL_VERIFICATION_IS_LOADING,
926
687
  payload: false
927
688
  });
928
- return _context4.abrupt("return", true);
929
- case 13:
689
+ return _context4.a(2, true);
690
+ case 3:
930
691
  dispatch({
931
692
  type: SET_SEND_EMAIL_VERIFICATION_STATUS,
932
693
  payload: {
@@ -938,13 +699,12 @@ function _sendEmailVerificationAction() {
938
699
  type: SET_SEND_EMAIL_VERIFICATION_IS_LOADING,
939
700
  payload: false
940
701
  });
941
- return _context4.abrupt("return", false);
942
- case 16:
943
- _context4.next = 23;
702
+ return _context4.a(2, false);
703
+ case 4:
704
+ _context4.n = 6;
944
705
  break;
945
- case 18:
946
- _context4.prev = 18;
947
- _context4.t0 = _context4["catch"](3);
706
+ case 5:
707
+ _context4.p = 5;
948
708
  dispatch({
949
709
  type: SET_SEND_EMAIL_VERIFICATION_STATUS,
950
710
  payload: {
@@ -956,12 +716,11 @@ function _sendEmailVerificationAction() {
956
716
  type: SET_SEND_EMAIL_VERIFICATION_IS_LOADING,
957
717
  payload: false
958
718
  });
959
- return _context4.abrupt("return", false);
960
- case 23:
961
- case "end":
962
- return _context4.stop();
719
+ return _context4.a(2, false);
720
+ case 6:
721
+ return _context4.a(2);
963
722
  }
964
- }, _callee4, null, [[3, 18]]);
723
+ }, _callee4, null, [[1, 5]]);
965
724
  }));
966
725
  return _sendEmailVerificationAction.apply(this, arguments);
967
726
  }
@@ -969,43 +728,40 @@ function checkTokenAction(_x5) {
969
728
  return _checkTokenAction.apply(this, arguments);
970
729
  }
971
730
  function _checkTokenAction() {
972
- _checkTokenAction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(_ref6) {
973
- var dispatch, domainName, token, refreshAccessTokenFetch;
974
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
975
- while (1) switch (_context5.prev = _context5.next) {
731
+ _checkTokenAction = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(_ref6) {
732
+ var dispatch, domainName, token, refreshAccessTokenFetch, _t5;
733
+ return _regenerator().w(function (_context5) {
734
+ while (1) switch (_context5.p = _context5.n) {
976
735
  case 0:
977
736
  dispatch = _ref6.dispatch, domainName = _ref6.domainName, token = _ref6.token;
978
- _context5.prev = 1;
979
- _context5.next = 4;
737
+ _context5.p = 1;
738
+ _context5.n = 2;
980
739
  return refreshAccessTokenAPI(domainName, token);
981
- case 4:
982
- refreshAccessTokenFetch = _context5.sent;
740
+ case 2:
741
+ refreshAccessTokenFetch = _context5.v;
983
742
  if (!(refreshAccessTokenFetch.response.status === 200)) {
984
- _context5.next = 10;
743
+ _context5.n = 3;
985
744
  break;
986
745
  }
987
746
  if (refreshAccessTokenFetch.data.accessToken) {
988
747
  localStorage.setItem(TOKEN_LS, refreshAccessTokenFetch.data.accessToken);
989
748
  }
990
- return _context5.abrupt("return");
991
- case 10:
992
- window.location.replace(getClientBasePath({
993
- domainName: domainName
994
- }) + "/" + domainName + "/" + routes.signin);
995
- return _context5.abrupt("return", resetUser(dispatch));
996
- case 12:
997
- _context5.next = 18;
749
+ return _context5.a(2);
750
+ case 3:
751
+ window.location.replace(getClientBasePath() + "/" + domainName + "/" + routes.signin);
752
+ return _context5.a(2, resetUser(dispatch));
753
+ case 4:
754
+ _context5.n = 6;
998
755
  break;
999
- case 14:
1000
- _context5.prev = 14;
1001
- _context5.t0 = _context5["catch"](1);
756
+ case 5:
757
+ _context5.p = 5;
758
+ _t5 = _context5.v;
1002
759
  resetUser(dispatch);
1003
- throw _context5.t0;
1004
- case 18:
1005
- case "end":
1006
- return _context5.stop();
760
+ throw _t5;
761
+ case 6:
762
+ return _context5.a(2);
1007
763
  }
1008
- }, _callee5, null, [[1, 14]]);
764
+ }, _callee5, null, [[1, 5]]);
1009
765
  }));
1010
766
  return _checkTokenAction.apply(this, arguments);
1011
767
  }
@@ -1015,45 +771,44 @@ function getAccessTokenAction(_x6) {
1015
771
  ///////////////////////////////////////////
1016
772
  //////////////////////////////////////////
1017
773
  function _getAccessTokenAction() {
1018
- _getAccessTokenAction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(_ref7) {
1019
- var dispatch, domainName, token_ls, refreshAccessTokenFetch, _refreshAccessTokenFe;
1020
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
1021
- while (1) switch (_context6.prev = _context6.next) {
774
+ _getAccessTokenAction = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(_ref7) {
775
+ var dispatch, domainName, token_ls, refreshAccessTokenFetch, _refreshAccessTokenFe, _t6;
776
+ return _regenerator().w(function (_context6) {
777
+ while (1) switch (_context6.p = _context6.n) {
1022
778
  case 0:
1023
779
  dispatch = _ref7.dispatch, domainName = _ref7.domainName;
1024
780
  token_ls = localStorage.getItem(TOKEN_LS);
1025
781
  if (token_ls) {
1026
- _context6.next = 4;
782
+ _context6.n = 1;
1027
783
  break;
1028
784
  }
1029
- return _context6.abrupt("return");
1030
- case 4:
1031
- _context6.prev = 4;
1032
- _context6.next = 7;
785
+ return _context6.a(2);
786
+ case 1:
787
+ _context6.p = 1;
788
+ _context6.n = 2;
1033
789
  return refreshAccessTokenAPI(domainName, token_ls);
1034
- case 7:
1035
- refreshAccessTokenFetch = _context6.sent;
790
+ case 2:
791
+ refreshAccessTokenFetch = _context6.v;
1036
792
  if (!(refreshAccessTokenFetch.response.status === 200)) {
1037
- _context6.next = 12;
793
+ _context6.n = 3;
1038
794
  break;
1039
795
  }
1040
- return _context6.abrupt("return", (_refreshAccessTokenFe = refreshAccessTokenFetch.data.accessToken) != null ? _refreshAccessTokenFe : token_ls);
1041
- case 12:
796
+ return _context6.a(2, (_refreshAccessTokenFe = refreshAccessTokenFetch.data.accessToken) != null ? _refreshAccessTokenFe : token_ls);
797
+ case 3:
1042
798
  resetUser(dispatch);
1043
- return _context6.abrupt("return", 'token-not-found');
1044
- case 14:
1045
- _context6.next = 20;
799
+ return _context6.a(2, 'token-not-found');
800
+ case 4:
801
+ _context6.n = 6;
1046
802
  break;
1047
- case 16:
1048
- _context6.prev = 16;
1049
- _context6.t0 = _context6["catch"](4);
803
+ case 5:
804
+ _context6.p = 5;
805
+ _t6 = _context6.v;
1050
806
  resetUser(dispatch);
1051
- throw _context6.t0;
1052
- case 20:
1053
- case "end":
1054
- return _context6.stop();
807
+ throw _t6;
808
+ case 6:
809
+ return _context6.a(2);
1055
810
  }
1056
- }, _callee6, null, [[4, 16]]);
811
+ }, _callee6, null, [[1, 5]]);
1057
812
  }));
1058
813
  return _getAccessTokenAction.apply(this, arguments);
1059
814
  }
@@ -1076,37 +831,33 @@ var DauthProvider = function DauthProvider(props) {
1076
831
  var _useReducer = useReducer(userReducer, initialDauthState),
1077
832
  dauthState = _useReducer[0],
1078
833
  dispatch = _useReducer[1];
1079
- var isValidTsk = useCallback( /*#__PURE__*/function () {
1080
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(token) {
834
+ var isValidTsk = useCallback(/*#__PURE__*/function () {
835
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(token) {
1081
836
  var verifyToken;
1082
- return _regeneratorRuntime().wrap(function _callee$(_context) {
1083
- while (1) switch (_context.prev = _context.next) {
837
+ return _regenerator().w(function (_context) {
838
+ while (1) switch (_context.p = _context.n) {
1084
839
  case 0:
1085
- _context.prev = 0;
1086
- _context.next = 3;
840
+ _context.p = 0;
841
+ _context.n = 1;
1087
842
  return verifyTokenAPI({
1088
843
  domainName: domainName,
1089
844
  token: token,
1090
845
  tsk: tsk
1091
846
  });
1092
- case 3:
1093
- verifyToken = _context.sent;
847
+ case 1:
848
+ verifyToken = _context.v;
1094
849
  if (!(verifyToken.response.status !== 200)) {
1095
- _context.next = 6;
850
+ _context.n = 2;
1096
851
  break;
1097
852
  }
1098
- return _context.abrupt("return", false);
1099
- case 6:
1100
- return _context.abrupt("return", true);
1101
- case 9:
1102
- _context.prev = 9;
1103
- _context.t0 = _context["catch"](0);
1104
- return _context.abrupt("return", false);
1105
- case 12:
1106
- case "end":
1107
- return _context.stop();
853
+ return _context.a(2, false);
854
+ case 2:
855
+ return _context.a(2, true);
856
+ case 3:
857
+ _context.p = 3;
858
+ return _context.a(2, false);
1108
859
  }
1109
- }, _callee, null, [[0, 9]]);
860
+ }, _callee, null, [[0, 3]]);
1110
861
  }));
1111
862
  return function (_x) {
1112
863
  return _ref.apply(this, arguments);
@@ -1115,39 +866,38 @@ var DauthProvider = function DauthProvider(props) {
1115
866
  // Check token periodically
1116
867
  useEffect(function () {
1117
868
  if (!dauthState.isAuthenticated) return;
1118
- var interval = setInterval( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
869
+ var interval = setInterval(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
1119
870
  var token_ls, isValid;
1120
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1121
- while (1) switch (_context2.prev = _context2.next) {
871
+ return _regenerator().w(function (_context2) {
872
+ while (1) switch (_context2.n) {
1122
873
  case 0:
1123
874
  token_ls = localStorage.getItem(TOKEN_LS);
1124
875
  if (token_ls) {
1125
- _context2.next = 3;
876
+ _context2.n = 1;
1126
877
  break;
1127
878
  }
1128
- return _context2.abrupt("return");
1129
- case 3:
1130
- _context2.next = 5;
879
+ return _context2.a(2);
880
+ case 1:
881
+ _context2.n = 2;
1131
882
  return isValidTsk(token_ls);
1132
- case 5:
1133
- isValid = _context2.sent;
883
+ case 2:
884
+ isValid = _context2.v;
1134
885
  if (!isValid) {
1135
- _context2.next = 10;
886
+ _context2.n = 3;
1136
887
  break;
1137
888
  }
1138
- return _context2.abrupt("return", checkTokenAction({
889
+ return _context2.a(2, checkTokenAction({
1139
890
  dispatch: dispatch,
1140
891
  domainName: domainName,
1141
892
  token: token_ls
1142
893
  }));
1143
- case 10:
894
+ case 3:
1144
895
  setLogoutAction({
1145
896
  dispatch: dispatch
1146
897
  });
1147
898
  throw new Error('Ask value in DauthProvider is not valid');
1148
- case 12:
1149
- case "end":
1150
- return _context2.stop();
899
+ case 4:
900
+ return _context2.a(2);
1151
901
  }
1152
902
  }, _callee2);
1153
903
  })), 1000 * 60 * 5);
@@ -1157,130 +907,123 @@ var DauthProvider = function DauthProvider(props) {
1157
907
  }, [dauthState.isAuthenticated, isValidTsk]);
1158
908
  // Catch login redirect
1159
909
  useEffect(function () {
1160
- _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
910
+ _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
1161
911
  var queryString, urlParams, token_url, isValid;
1162
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
1163
- while (1) switch (_context3.prev = _context3.next) {
912
+ return _regenerator().w(function (_context3) {
913
+ while (1) switch (_context3.n) {
1164
914
  case 0:
1165
915
  queryString = window.location.search;
1166
916
  if (queryString) {
1167
- _context3.next = 3;
917
+ _context3.n = 1;
1168
918
  break;
1169
919
  }
1170
- return _context3.abrupt("return");
1171
- case 3:
920
+ return _context3.a(2);
921
+ case 1:
1172
922
  urlParams = new URLSearchParams(queryString);
1173
923
  token_url = urlParams.get(TOKEN_LS);
1174
924
  if (!(token_url && !dauthState.isAuthenticated)) {
1175
- _context3.next = 15;
925
+ _context3.n = 4;
1176
926
  break;
1177
927
  }
1178
- _context3.next = 8;
928
+ _context3.n = 2;
1179
929
  return isValidTsk(token_url);
1180
- case 8:
1181
- isValid = _context3.sent;
930
+ case 2:
931
+ isValid = _context3.v;
1182
932
  if (!isValid) {
1183
- _context3.next = 13;
933
+ _context3.n = 3;
1184
934
  break;
1185
935
  }
1186
- return _context3.abrupt("return", setDauthStateAction({
936
+ return _context3.a(2, setDauthStateAction({
1187
937
  dispatch: dispatch,
1188
938
  token: token_url,
1189
939
  domainName: domainName
1190
940
  }));
1191
- case 13:
941
+ case 3:
1192
942
  setLogoutAction({
1193
943
  dispatch: dispatch
1194
944
  });
1195
945
  throw new Error('Ask value in DauthProvider is not valid');
1196
- case 15:
1197
- case "end":
1198
- return _context3.stop();
946
+ case 4:
947
+ return _context3.a(2);
1199
948
  }
1200
949
  }, _callee3);
1201
950
  }))();
1202
951
  }, []);
1203
952
  // Auto Login
1204
953
  useEffect(function () {
1205
- _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
954
+ _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
1206
955
  var token_ls, isValid;
1207
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
1208
- while (1) switch (_context4.prev = _context4.next) {
956
+ return _regenerator().w(function (_context4) {
957
+ while (1) switch (_context4.n) {
1209
958
  case 0:
1210
959
  token_ls = localStorage.getItem(TOKEN_LS);
1211
960
  if (!(token_ls && !dauthState.isAuthenticated)) {
1212
- _context4.next = 13;
961
+ _context4.n = 4;
1213
962
  break;
1214
963
  }
1215
- _context4.next = 4;
964
+ _context4.n = 1;
1216
965
  return isValidTsk(token_ls);
1217
- case 4:
1218
- isValid = _context4.sent;
966
+ case 1:
967
+ isValid = _context4.v;
1219
968
  if (!isValid) {
1220
- _context4.next = 9;
969
+ _context4.n = 2;
1221
970
  break;
1222
971
  }
1223
- return _context4.abrupt("return", setAutoLoginAction({
972
+ return _context4.a(2, setAutoLoginAction({
1224
973
  dispatch: dispatch,
1225
974
  token_ls: token_ls,
1226
975
  domainName: domainName
1227
976
  }));
1228
- case 9:
977
+ case 2:
1229
978
  setLogoutAction({
1230
979
  dispatch: dispatch
1231
980
  });
1232
981
  throw new Error('Ask value in DauthProvider is not valid');
1233
- case 11:
1234
- _context4.next = 14;
982
+ case 3:
983
+ _context4.n = 5;
1235
984
  break;
1236
- case 13:
1237
- return _context4.abrupt("return", dispatch({
985
+ case 4:
986
+ return _context4.a(2, dispatch({
1238
987
  type: SET_IS_LOADING,
1239
988
  payload: {
1240
989
  isLoading: false
1241
990
  }
1242
991
  }));
1243
- case 14:
1244
- case "end":
1245
- return _context4.stop();
992
+ case 5:
993
+ return _context4.a(2);
1246
994
  }
1247
995
  }, _callee4);
1248
996
  }))();
1249
997
  }, []);
1250
998
  var loginWithRedirect = useCallback(function () {
1251
- return window.location.replace(getClientBasePath({
1252
- domainName: domainName
1253
- }) + "/" + domainName + "/" + routes.signin);
999
+ return window.location.replace(getClientBasePath() + "/" + domainName + "/" + routes.signin);
1254
1000
  }, [domainName]);
1255
1001
  var logout = useCallback(function () {
1256
1002
  return setLogoutAction({
1257
1003
  dispatch: dispatch
1258
1004
  });
1259
1005
  }, []);
1260
- var getAccessToken = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
1006
+ var getAccessToken = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5() {
1261
1007
  var token;
1262
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
1263
- while (1) switch (_context5.prev = _context5.next) {
1008
+ return _regenerator().w(function (_context5) {
1009
+ while (1) switch (_context5.n) {
1264
1010
  case 0:
1265
- _context5.next = 2;
1011
+ _context5.n = 1;
1266
1012
  return getAccessTokenAction({
1267
1013
  dispatch: dispatch,
1268
1014
  domainName: domainName
1269
1015
  });
1270
- case 2:
1271
- token = _context5.sent;
1272
- return _context5.abrupt("return", token);
1273
- case 4:
1274
- case "end":
1275
- return _context5.stop();
1016
+ case 1:
1017
+ token = _context5.v;
1018
+ return _context5.a(2, token);
1276
1019
  }
1277
1020
  }, _callee5);
1278
1021
  })), [domainName]);
1279
- var updateUser = useCallback( /*#__PURE__*/function () {
1280
- var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(_ref6) {
1022
+ var updateUser = useCallback(/*#__PURE__*/function () {
1023
+ var _ref7 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(_ref6) {
1281
1024
  var name, lastname, nickname, telPrefix, telSuffix, language, avatar, token_ls, user;
1282
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
1283
- while (1) switch (_context6.prev = _context6.next) {
1025
+ return _regenerator().w(function (_context6) {
1026
+ while (1) switch (_context6.n) {
1284
1027
  case 0:
1285
1028
  name = _ref6.name, lastname = _ref6.lastname, nickname = _ref6.nickname, telPrefix = _ref6.telPrefix, telSuffix = _ref6.telSuffix, language = _ref6.language, avatar = _ref6.avatar;
1286
1029
  token_ls = localStorage.getItem(TOKEN_LS);
@@ -1293,18 +1036,15 @@ var DauthProvider = function DauthProvider(props) {
1293
1036
  language: language,
1294
1037
  avatar: avatar
1295
1038
  };
1296
- _context6.next = 5;
1039
+ _context6.n = 1;
1297
1040
  return setUpdateUserAction({
1298
1041
  dispatch: dispatch,
1299
1042
  domainName: domainName,
1300
1043
  user: user,
1301
1044
  token: token_ls
1302
1045
  });
1303
- case 5:
1304
- return _context6.abrupt("return", _context6.sent);
1305
- case 6:
1306
- case "end":
1307
- return _context6.stop();
1046
+ case 1:
1047
+ return _context6.a(2, _context6.v);
1308
1048
  }
1309
1049
  }, _callee6);
1310
1050
  }));
@@ -1315,33 +1055,28 @@ var DauthProvider = function DauthProvider(props) {
1315
1055
  var updateUserWithRedirect = useCallback(function () {
1316
1056
  var token_ls = localStorage.getItem(TOKEN_LS);
1317
1057
  if (!token_ls) return;
1318
- return window.location.replace(getClientBasePath({
1319
- domainName: domainName
1320
- }) + "/" + domainName + "/" + routes.updateUser + "/" + token_ls);
1058
+ return window.location.replace(getClientBasePath() + "/" + domainName + "/" + routes.updateUser + "/" + token_ls);
1321
1059
  }, [domainName]);
1322
- var sendEmailVerification = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
1060
+ var sendEmailVerification = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7() {
1323
1061
  var token_ls;
1324
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
1325
- while (1) switch (_context7.prev = _context7.next) {
1062
+ return _regenerator().w(function (_context7) {
1063
+ while (1) switch (_context7.n) {
1326
1064
  case 0:
1327
1065
  token_ls = localStorage.getItem(TOKEN_LS);
1328
1066
  if (token_ls) {
1329
- _context7.next = 3;
1067
+ _context7.n = 1;
1330
1068
  break;
1331
1069
  }
1332
- return _context7.abrupt("return", false);
1333
- case 3:
1334
- _context7.next = 5;
1070
+ return _context7.a(2, false);
1071
+ case 1:
1072
+ _context7.n = 2;
1335
1073
  return sendEmailVerificationAction({
1336
1074
  dispatch: dispatch,
1337
1075
  domainName: domainName,
1338
1076
  token: token_ls
1339
1077
  });
1340
- case 5:
1341
- return _context7.abrupt("return", _context7.sent);
1342
- case 6:
1343
- case "end":
1344
- return _context7.stop();
1078
+ case 2:
1079
+ return _context7.a(2, _context7.v);
1345
1080
  }
1346
1081
  }, _callee7);
1347
1082
  })), [domainName]);