@entur-partner/app-shell 4.0.1 → 5.0.1-alpha.0

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.
@@ -3,309 +3,333 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var React = require('react');
6
- var loader = require('@entur/loader');
7
6
  var alert = require('@entur/alert');
8
- var tokens = require('@entur/tokens');
9
7
  var typography = require('@entur/typography');
10
- var util = require('@entur-partner/util');
8
+ var loader = require('@entur/loader');
9
+ var tokens = require('@entur/tokens');
10
+ var auth0React = require('@auth0/auth0-react');
11
11
  var common = require('@entur-partner/common');
12
- var createAuth0Client = require('@auth0/auth0-spa-js');
12
+ var util = require('@entur-partner/util');
13
13
 
14
14
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
15
15
 
16
16
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
17
- var createAuth0Client__default = /*#__PURE__*/_interopDefaultLegacy(createAuth0Client);
18
17
 
18
+ function _construct(t, e, r) {
19
+ if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
20
+ var o = [null];
21
+ o.push.apply(o, e);
22
+ var p = new (t.bind.apply(t, o))();
23
+ return r && _setPrototypeOf(p, r.prototype), p;
24
+ }
25
+ function _isNativeReflectConstruct() {
26
+ try {
27
+ var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
28
+ } catch (t) {}
29
+ return (_isNativeReflectConstruct = function () {
30
+ return !!t;
31
+ })();
32
+ }
19
33
  function _regeneratorRuntime() {
20
34
  _regeneratorRuntime = function () {
21
- return exports;
35
+ return e;
22
36
  };
23
- var exports = {},
24
- Op = Object.prototype,
25
- hasOwn = Op.hasOwnProperty,
26
- $Symbol = "function" == typeof Symbol ? Symbol : {},
27
- iteratorSymbol = $Symbol.iterator || "@@iterator",
28
- asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
29
- toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
30
- function define(obj, key, value) {
31
- return Object.defineProperty(obj, key, {
32
- value: value,
37
+ var t,
38
+ e = {},
39
+ r = Object.prototype,
40
+ n = r.hasOwnProperty,
41
+ o = Object.defineProperty || function (t, e, r) {
42
+ t[e] = r.value;
43
+ },
44
+ i = "function" == typeof Symbol ? Symbol : {},
45
+ a = i.iterator || "@@iterator",
46
+ c = i.asyncIterator || "@@asyncIterator",
47
+ u = i.toStringTag || "@@toStringTag";
48
+ function define(t, e, r) {
49
+ return Object.defineProperty(t, e, {
50
+ value: r,
33
51
  enumerable: !0,
34
52
  configurable: !0,
35
53
  writable: !0
36
- }), obj[key];
54
+ }), t[e];
37
55
  }
38
56
  try {
39
57
  define({}, "");
40
- } catch (err) {
41
- define = function (obj, key, value) {
42
- return obj[key] = value;
58
+ } catch (t) {
59
+ define = function (t, e, r) {
60
+ return t[e] = r;
43
61
  };
44
62
  }
45
- function wrap(innerFn, outerFn, self, tryLocsList) {
46
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
47
- generator = Object.create(protoGenerator.prototype),
48
- context = new Context(tryLocsList || []);
49
- return generator._invoke = function (innerFn, self, context) {
50
- var state = "suspendedStart";
51
- return function (method, arg) {
52
- if ("executing" === state) throw new Error("Generator is already running");
53
- if ("completed" === state) {
54
- if ("throw" === method) throw arg;
55
- return doneResult();
56
- }
57
- for (context.method = method, context.arg = arg;;) {
58
- var delegate = context.delegate;
59
- if (delegate) {
60
- var delegateResult = maybeInvokeDelegate(delegate, context);
61
- if (delegateResult) {
62
- if (delegateResult === ContinueSentinel) continue;
63
- return delegateResult;
64
- }
65
- }
66
- if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
67
- if ("suspendedStart" === state) throw state = "completed", context.arg;
68
- context.dispatchException(context.arg);
69
- } else "return" === context.method && context.abrupt("return", context.arg);
70
- state = "executing";
71
- var record = tryCatch(innerFn, self, context);
72
- if ("normal" === record.type) {
73
- if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
74
- return {
75
- value: record.arg,
76
- done: context.done
77
- };
78
- }
79
- "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
80
- }
81
- };
82
- }(innerFn, self, context), generator;
63
+ function wrap(t, e, r, n) {
64
+ var i = e && e.prototype instanceof Generator ? e : Generator,
65
+ a = Object.create(i.prototype),
66
+ c = new Context(n || []);
67
+ return o(a, "_invoke", {
68
+ value: makeInvokeMethod(t, r, c)
69
+ }), a;
83
70
  }
84
- function tryCatch(fn, obj, arg) {
71
+ function tryCatch(t, e, r) {
85
72
  try {
86
73
  return {
87
74
  type: "normal",
88
- arg: fn.call(obj, arg)
75
+ arg: t.call(e, r)
89
76
  };
90
- } catch (err) {
77
+ } catch (t) {
91
78
  return {
92
79
  type: "throw",
93
- arg: err
80
+ arg: t
94
81
  };
95
82
  }
96
83
  }
97
- exports.wrap = wrap;
98
- var ContinueSentinel = {};
84
+ e.wrap = wrap;
85
+ var h = "suspendedStart",
86
+ l = "suspendedYield",
87
+ f = "executing",
88
+ s = "completed",
89
+ y = {};
99
90
  function Generator() {}
100
91
  function GeneratorFunction() {}
101
92
  function GeneratorFunctionPrototype() {}
102
- var IteratorPrototype = {};
103
- define(IteratorPrototype, iteratorSymbol, function () {
93
+ var p = {};
94
+ define(p, a, function () {
104
95
  return this;
105
96
  });
106
- var getProto = Object.getPrototypeOf,
107
- NativeIteratorPrototype = getProto && getProto(getProto(values([])));
108
- NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
109
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
110
- function defineIteratorMethods(prototype) {
111
- ["next", "throw", "return"].forEach(function (method) {
112
- define(prototype, method, function (arg) {
113
- return this._invoke(method, arg);
97
+ var d = Object.getPrototypeOf,
98
+ v = d && d(d(values([])));
99
+ v && v !== r && n.call(v, a) && (p = v);
100
+ var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
101
+ function defineIteratorMethods(t) {
102
+ ["next", "throw", "return"].forEach(function (e) {
103
+ define(t, e, function (t) {
104
+ return this._invoke(e, t);
114
105
  });
115
106
  });
116
107
  }
117
- function AsyncIterator(generator, PromiseImpl) {
118
- function invoke(method, arg, resolve, reject) {
119
- var record = tryCatch(generator[method], generator, arg);
120
- if ("throw" !== record.type) {
121
- var result = record.arg,
122
- value = result.value;
123
- return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
124
- invoke("next", value, resolve, reject);
125
- }, function (err) {
126
- invoke("throw", err, resolve, reject);
127
- }) : PromiseImpl.resolve(value).then(function (unwrapped) {
128
- result.value = unwrapped, resolve(result);
129
- }, function (error) {
130
- return invoke("throw", error, resolve, reject);
108
+ function AsyncIterator(t, e) {
109
+ function invoke(r, o, i, a) {
110
+ var c = tryCatch(t[r], t, o);
111
+ if ("throw" !== c.type) {
112
+ var u = c.arg,
113
+ h = u.value;
114
+ return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
115
+ invoke("next", t, i, a);
116
+ }, function (t) {
117
+ invoke("throw", t, i, a);
118
+ }) : e.resolve(h).then(function (t) {
119
+ u.value = t, i(u);
120
+ }, function (t) {
121
+ return invoke("throw", t, i, a);
131
122
  });
132
123
  }
133
- reject(record.arg);
124
+ a(c.arg);
134
125
  }
135
- var previousPromise;
136
- this._invoke = function (method, arg) {
137
- function callInvokeWithMethodAndArg() {
138
- return new PromiseImpl(function (resolve, reject) {
139
- invoke(method, arg, resolve, reject);
140
- });
126
+ var r;
127
+ o(this, "_invoke", {
128
+ value: function (t, n) {
129
+ function callInvokeWithMethodAndArg() {
130
+ return new e(function (e, r) {
131
+ invoke(t, n, e, r);
132
+ });
133
+ }
134
+ return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
141
135
  }
142
- return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
143
- };
136
+ });
144
137
  }
145
- function maybeInvokeDelegate(delegate, context) {
146
- var method = delegate.iterator[context.method];
147
- if (undefined === method) {
148
- if (context.delegate = null, "throw" === context.method) {
149
- if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
150
- context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
138
+ function makeInvokeMethod(e, r, n) {
139
+ var o = h;
140
+ return function (i, a) {
141
+ if (o === f) throw Error("Generator is already running");
142
+ if (o === s) {
143
+ if ("throw" === i) throw a;
144
+ return {
145
+ value: t,
146
+ done: !0
147
+ };
151
148
  }
152
- return ContinueSentinel;
153
- }
154
- var record = tryCatch(method, delegate.iterator, context.arg);
155
- if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
156
- var info = record.arg;
157
- return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
149
+ for (n.method = i, n.arg = a;;) {
150
+ var c = n.delegate;
151
+ if (c) {
152
+ var u = maybeInvokeDelegate(c, n);
153
+ if (u) {
154
+ if (u === y) continue;
155
+ return u;
156
+ }
157
+ }
158
+ if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
159
+ if (o === h) throw o = s, n.arg;
160
+ n.dispatchException(n.arg);
161
+ } else "return" === n.method && n.abrupt("return", n.arg);
162
+ o = f;
163
+ var p = tryCatch(e, r, n);
164
+ if ("normal" === p.type) {
165
+ if (o = n.done ? s : l, p.arg === y) continue;
166
+ return {
167
+ value: p.arg,
168
+ done: n.done
169
+ };
170
+ }
171
+ "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
172
+ }
173
+ };
158
174
  }
159
- function pushTryEntry(locs) {
160
- var entry = {
161
- tryLoc: locs[0]
175
+ function maybeInvokeDelegate(e, r) {
176
+ var n = r.method,
177
+ o = e.iterator[n];
178
+ 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;
179
+ var i = tryCatch(o, e.iterator, r.arg);
180
+ if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
181
+ var a = i.arg;
182
+ 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);
183
+ }
184
+ function pushTryEntry(t) {
185
+ var e = {
186
+ tryLoc: t[0]
162
187
  };
163
- 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
188
+ 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
164
189
  }
165
- function resetTryEntry(entry) {
166
- var record = entry.completion || {};
167
- record.type = "normal", delete record.arg, entry.completion = record;
190
+ function resetTryEntry(t) {
191
+ var e = t.completion || {};
192
+ e.type = "normal", delete e.arg, t.completion = e;
168
193
  }
169
- function Context(tryLocsList) {
194
+ function Context(t) {
170
195
  this.tryEntries = [{
171
196
  tryLoc: "root"
172
- }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
197
+ }], t.forEach(pushTryEntry, this), this.reset(!0);
173
198
  }
174
- function values(iterable) {
175
- if (iterable) {
176
- var iteratorMethod = iterable[iteratorSymbol];
177
- if (iteratorMethod) return iteratorMethod.call(iterable);
178
- if ("function" == typeof iterable.next) return iterable;
179
- if (!isNaN(iterable.length)) {
180
- var i = -1,
181
- next = function next() {
182
- for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
183
- return next.value = undefined, next.done = !0, next;
199
+ function values(e) {
200
+ if (e || "" === e) {
201
+ var r = e[a];
202
+ if (r) return r.call(e);
203
+ if ("function" == typeof e.next) return e;
204
+ if (!isNaN(e.length)) {
205
+ var o = -1,
206
+ i = function next() {
207
+ for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
208
+ return next.value = t, next.done = !0, next;
184
209
  };
185
- return next.next = next;
210
+ return i.next = i;
186
211
  }
187
212
  }
188
- return {
189
- next: doneResult
190
- };
213
+ throw new TypeError(typeof e + " is not iterable");
191
214
  }
192
- function doneResult() {
215
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
216
+ value: GeneratorFunctionPrototype,
217
+ configurable: !0
218
+ }), o(GeneratorFunctionPrototype, "constructor", {
219
+ value: GeneratorFunction,
220
+ configurable: !0
221
+ }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
222
+ var e = "function" == typeof t && t.constructor;
223
+ return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
224
+ }, e.mark = function (t) {
225
+ return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
226
+ }, e.awrap = function (t) {
193
227
  return {
194
- value: undefined,
195
- done: !0
228
+ __await: t
196
229
  };
197
- }
198
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
199
- var ctor = "function" == typeof genFun && genFun.constructor;
200
- return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
201
- }, exports.mark = function (genFun) {
202
- return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
203
- }, exports.awrap = function (arg) {
204
- return {
205
- __await: arg
206
- };
207
- }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
230
+ }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
208
231
  return this;
209
- }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
210
- void 0 === PromiseImpl && (PromiseImpl = Promise);
211
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
212
- return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
213
- return result.done ? result.value : iter.next();
232
+ }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
233
+ void 0 === i && (i = Promise);
234
+ var a = new AsyncIterator(wrap(t, r, n, o), i);
235
+ return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
236
+ return t.done ? t.value : a.next();
214
237
  });
215
- }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
238
+ }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
216
239
  return this;
217
- }), define(Gp, "toString", function () {
240
+ }), define(g, "toString", function () {
218
241
  return "[object Generator]";
219
- }), exports.keys = function (object) {
220
- var keys = [];
221
- for (var key in object) keys.push(key);
222
- return keys.reverse(), function next() {
223
- for (; keys.length;) {
224
- var key = keys.pop();
225
- if (key in object) return next.value = key, next.done = !1, next;
242
+ }), e.keys = function (t) {
243
+ var e = Object(t),
244
+ r = [];
245
+ for (var n in e) r.push(n);
246
+ return r.reverse(), function next() {
247
+ for (; r.length;) {
248
+ var t = r.pop();
249
+ if (t in e) return next.value = t, next.done = !1, next;
226
250
  }
227
251
  return next.done = !0, next;
228
252
  };
229
- }, exports.values = values, Context.prototype = {
253
+ }, e.values = values, Context.prototype = {
230
254
  constructor: Context,
231
- reset: function (skipTempReset) {
232
- if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
255
+ reset: function (e) {
256
+ 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);
233
257
  },
234
258
  stop: function () {
235
259
  this.done = !0;
236
- var rootRecord = this.tryEntries[0].completion;
237
- if ("throw" === rootRecord.type) throw rootRecord.arg;
260
+ var t = this.tryEntries[0].completion;
261
+ if ("throw" === t.type) throw t.arg;
238
262
  return this.rval;
239
263
  },
240
- dispatchException: function (exception) {
241
- if (this.done) throw exception;
242
- var context = this;
243
- function handle(loc, caught) {
244
- return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
264
+ dispatchException: function (e) {
265
+ if (this.done) throw e;
266
+ var r = this;
267
+ function handle(n, o) {
268
+ return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
245
269
  }
246
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
247
- var entry = this.tryEntries[i],
248
- record = entry.completion;
249
- if ("root" === entry.tryLoc) return handle("end");
250
- if (entry.tryLoc <= this.prev) {
251
- var hasCatch = hasOwn.call(entry, "catchLoc"),
252
- hasFinally = hasOwn.call(entry, "finallyLoc");
253
- if (hasCatch && hasFinally) {
254
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
255
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
256
- } else if (hasCatch) {
257
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
270
+ for (var o = this.tryEntries.length - 1; o >= 0; --o) {
271
+ var i = this.tryEntries[o],
272
+ a = i.completion;
273
+ if ("root" === i.tryLoc) return handle("end");
274
+ if (i.tryLoc <= this.prev) {
275
+ var c = n.call(i, "catchLoc"),
276
+ u = n.call(i, "finallyLoc");
277
+ if (c && u) {
278
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
279
+ if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
280
+ } else if (c) {
281
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
258
282
  } else {
259
- if (!hasFinally) throw new Error("try statement without catch or finally");
260
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
283
+ if (!u) throw Error("try statement without catch or finally");
284
+ if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
261
285
  }
262
286
  }
263
287
  }
264
288
  },
265
- abrupt: function (type, arg) {
266
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
267
- var entry = this.tryEntries[i];
268
- if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
269
- var finallyEntry = entry;
289
+ abrupt: function (t, e) {
290
+ for (var r = this.tryEntries.length - 1; r >= 0; --r) {
291
+ var o = this.tryEntries[r];
292
+ if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
293
+ var i = o;
270
294
  break;
271
295
  }
272
296
  }
273
- finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
274
- var record = finallyEntry ? finallyEntry.completion : {};
275
- return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
297
+ i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
298
+ var a = i ? i.completion : {};
299
+ return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
276
300
  },
277
- complete: function (record, afterLoc) {
278
- if ("throw" === record.type) throw record.arg;
279
- return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
301
+ complete: function (t, e) {
302
+ if ("throw" === t.type) throw t.arg;
303
+ 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;
280
304
  },
281
- finish: function (finallyLoc) {
282
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
283
- var entry = this.tryEntries[i];
284
- if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
305
+ finish: function (t) {
306
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
307
+ var r = this.tryEntries[e];
308
+ if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
285
309
  }
286
310
  },
287
- catch: function (tryLoc) {
288
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
289
- var entry = this.tryEntries[i];
290
- if (entry.tryLoc === tryLoc) {
291
- var record = entry.completion;
292
- if ("throw" === record.type) {
293
- var thrown = record.arg;
294
- resetTryEntry(entry);
311
+ catch: function (t) {
312
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
313
+ var r = this.tryEntries[e];
314
+ if (r.tryLoc === t) {
315
+ var n = r.completion;
316
+ if ("throw" === n.type) {
317
+ var o = n.arg;
318
+ resetTryEntry(r);
295
319
  }
296
- return thrown;
320
+ return o;
297
321
  }
298
322
  }
299
- throw new Error("illegal catch attempt");
323
+ throw Error("illegal catch attempt");
300
324
  },
301
- delegateYield: function (iterable, resultName, nextLoc) {
325
+ delegateYield: function (e, r, n) {
302
326
  return this.delegate = {
303
- iterator: values(iterable),
304
- resultName: resultName,
305
- nextLoc: nextLoc
306
- }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
327
+ iterator: values(e),
328
+ resultName: r,
329
+ nextLoc: n
330
+ }, "next" === this.method && (this.arg = t), y;
307
331
  }
308
- }, exports;
332
+ }, e;
309
333
  }
310
334
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
311
335
  try {
@@ -369,34 +393,12 @@ function _setPrototypeOf(o, p) {
369
393
  };
370
394
  return _setPrototypeOf(o, p);
371
395
  }
372
- function _isNativeReflectConstruct() {
373
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
374
- if (Reflect.construct.sham) return false;
375
- if (typeof Proxy === "function") return true;
396
+ function _isNativeFunction(fn) {
376
397
  try {
377
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
378
- return true;
398
+ return Function.toString.call(fn).indexOf("[native code]") !== -1;
379
399
  } catch (e) {
380
- return false;
381
- }
382
- }
383
- function _construct(Parent, args, Class) {
384
- if (_isNativeReflectConstruct()) {
385
- _construct = Reflect.construct.bind();
386
- } else {
387
- _construct = function _construct(Parent, args, Class) {
388
- var a = [null];
389
- a.push.apply(a, args);
390
- var Constructor = Function.bind.apply(Parent, a);
391
- var instance = new Constructor();
392
- if (Class) _setPrototypeOf(instance, Class.prototype);
393
- return instance;
394
- };
400
+ return typeof fn === "function";
395
401
  }
396
- return _construct.apply(null, arguments);
397
- }
398
- function _isNativeFunction(fn) {
399
- return Function.toString.call(fn).indexOf("[native code]") !== -1;
400
402
  }
401
403
  function _wrapNativeSuper(Class) {
402
404
  var _cache = typeof Map === "function" ? new Map() : undefined;
@@ -437,234 +439,6 @@ function _objectWithoutPropertiesLoose(source, excluded) {
437
439
  return target;
438
440
  }
439
441
 
440
- var initialState$1 = {
441
- status: 'AUTHENTICATING'
442
- };
443
- function authReducer(state, event) {
444
- switch (event.type) {
445
- case 'AUTHENTICATED':
446
- return {
447
- status: 'AUTHENTICATED',
448
- user: event.data.user
449
- };
450
- case 'LOGOUT':
451
- return initialState$1;
452
- case 'ERROR':
453
- return {
454
- error: event.error,
455
- status: 'ERROR'
456
- };
457
- case 'NOT_AUTHENTICATED':
458
- return _extends({}, state, {
459
- status: 'NOT_AUTHENTICATED'
460
- });
461
- default:
462
- return state;
463
- }
464
- }
465
-
466
- var _excluded$2 = ["children", "decorateUser"];
467
- var POST_LOGIN_ROUTE_KEY = '@entur-partner:post-login-route';
468
- var LOGIN_LAST_RETRY = '@entur-partner:last-login-retry';
469
- var redirect = function redirect(pathname) {
470
- if (pathname === void 0) {
471
- pathname = '/';
472
- }
473
- return window.history.replaceState({}, document.title, pathname);
474
- }; // TODO: replace with react-router history
475
- var Auth0Context = /*#__PURE__*/React__default["default"].createContext(undefined);
476
- var useAuth = function useAuth() {
477
- var auth = React.useContext(Auth0Context);
478
- util.assertIsDefined(auth, 'A `<Auth0Provider>` component needs to be higher up in the component hierarchy.');
479
- return auth;
480
- };
481
- var initialState = {
482
- status: 'AUTHENTICATING'
483
- };
484
- var AuthProvider = function AuthProvider(_ref) {
485
- var children = _ref.children,
486
- decorateUser = _ref.decorateUser,
487
- initOptions = _objectWithoutPropertiesLoose(_ref, _excluded$2);
488
- var _useReducer = React.useReducer(authReducer, initialState),
489
- state = _useReducer[0],
490
- dispatch = _useReducer[1];
491
- var _useState = React.useState(),
492
- auth0Client = _useState[0],
493
- setAuth0 = _useState[1];
494
- React.useEffect(function () {
495
- var initAuth0 = /*#__PURE__*/function () {
496
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
497
- var client, route, postLoginRoute, isAuthenticated, auth0User, token, user;
498
- return _regeneratorRuntime().wrap(function _callee$(_context) {
499
- while (1) switch (_context.prev = _context.next) {
500
- case 0:
501
- _context.next = 2;
502
- return createAuth0Client__default["default"](initOptions);
503
- case 2:
504
- client = _context.sent;
505
- setAuth0(client);
506
- if (!window.location.search.includes('code=')) {
507
- _context.next = 11;
508
- break;
509
- }
510
- _context.next = 7;
511
- return client.handleRedirectCallback();
512
- case 7:
513
- route = localStorage.getItem(POST_LOGIN_ROUTE_KEY);
514
- localStorage.removeItem(POST_LOGIN_ROUTE_KEY);
515
- postLoginRoute = route || '/';
516
- redirect(postLoginRoute);
517
- case 11:
518
- _context.next = 13;
519
- return client.isAuthenticated();
520
- case 13:
521
- isAuthenticated = _context.sent;
522
- if (!isAuthenticated) {
523
- _context.next = 27;
524
- break;
525
- }
526
- _context.next = 17;
527
- return client.getUser();
528
- case 17:
529
- auth0User = _context.sent;
530
- _context.next = 20;
531
- return client.getTokenSilently();
532
- case 20:
533
- token = _context.sent;
534
- _context.next = 23;
535
- return decorateUser(auth0User, token);
536
- case 23:
537
- user = _context.sent;
538
- dispatch({
539
- type: 'AUTHENTICATED',
540
- data: {
541
- user: user
542
- }
543
- });
544
- _context.next = 28;
545
- break;
546
- case 27:
547
- dispatch({
548
- type: 'NOT_AUTHENTICATED'
549
- });
550
- case 28:
551
- case "end":
552
- return _context.stop();
553
- }
554
- }, _callee);
555
- }));
556
- return function initAuth0() {
557
- return _ref2.apply(this, arguments);
558
- };
559
- }();
560
- initAuth0()["catch"]( /*#__PURE__*/function () {
561
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(error) {
562
- var _localStorage$getItem, lastRetryEpochSeconds, nowEpochSeconds, timeSinceLastRetry, minimumTimeForRetry;
563
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
564
- while (1) switch (_context2.prev = _context2.next) {
565
- case 0:
566
- _context2.prev = 0;
567
- lastRetryEpochSeconds = parseInt((_localStorage$getItem = localStorage.getItem(LOGIN_LAST_RETRY)) != null ? _localStorage$getItem : '0');
568
- nowEpochSeconds = Math.floor(Date.now() / 1000);
569
- timeSinceLastRetry = nowEpochSeconds - lastRetryEpochSeconds;
570
- minimumTimeForRetry = 120; // Has there been more than x seconds since last retry?
571
- if (!(timeSinceLastRetry >= minimumTimeForRetry)) {
572
- _context2.next = 12;
573
- break;
574
- }
575
- localStorage.setItem(LOGIN_LAST_RETRY, nowEpochSeconds.toString());
576
- redirect('/');
577
- _context2.next = 10;
578
- return initAuth0();
579
- case 10:
580
- _context2.next = 13;
581
- break;
582
- case 12:
583
- throw error;
584
- case 13:
585
- _context2.next = 18;
586
- break;
587
- case 15:
588
- _context2.prev = 15;
589
- _context2.t0 = _context2["catch"](0);
590
- dispatch({
591
- type: 'ERROR',
592
- error: error
593
- });
594
- case 18:
595
- case "end":
596
- return _context2.stop();
597
- }
598
- }, _callee2, null, [[0, 15]]);
599
- }));
600
- return function (_x) {
601
- return _ref3.apply(this, arguments);
602
- };
603
- }());
604
- // eslint-disable-next-line
605
- }, []);
606
- var logout = function logout() {
607
- util.assertIsDefined(auth0Client);
608
- var _window$location = window.location,
609
- protocol = _window$location.protocol,
610
- hostname = _window$location.hostname,
611
- port = _window$location.port;
612
- auth0Client.logout({
613
- returnTo: protocol + "//" + hostname + ":" + port
614
- });
615
- };
616
- var login = /*#__PURE__*/function () {
617
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(redirectUri) {
618
- var _window, location;
619
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
620
- while (1) switch (_context3.prev = _context3.next) {
621
- case 0:
622
- if (redirectUri === void 0) {
623
- redirectUri = window.location.origin;
624
- }
625
- util.assertIsDefined(auth0Client);
626
- _window = window, location = _window.location;
627
- localStorage.setItem(POST_LOGIN_ROUTE_KEY, "" + location.pathname + location.search);
628
- auth0Client.loginWithRedirect({
629
- redirect_uri: redirectUri
630
- });
631
- case 5:
632
- case "end":
633
- return _context3.stop();
634
- }
635
- }, _callee3);
636
- }));
637
- return function login(_x2) {
638
- return _ref4.apply(this, arguments);
639
- };
640
- }();
641
- var getToken = /*#__PURE__*/function () {
642
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(options) {
643
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
644
- while (1) switch (_context4.prev = _context4.next) {
645
- case 0:
646
- util.assertIsDefined(auth0Client);
647
- return _context4.abrupt("return", auth0Client.getTokenSilently(options));
648
- case 2:
649
- case "end":
650
- return _context4.stop();
651
- }
652
- }, _callee4);
653
- }));
654
- return function getToken(_x3) {
655
- return _ref5.apply(this, arguments);
656
- };
657
- }();
658
- return React__default["default"].createElement(Auth0Context.Provider, {
659
- value: _extends({}, state, {
660
- auth0Client: auth0Client,
661
- logout: logout,
662
- getToken: getToken,
663
- login: login
664
- })
665
- }, children);
666
- };
667
-
668
442
  var EnvironmentBanner = function EnvironmentBanner(_ref) {
669
443
  var environment = _ref.environment;
670
444
  return React__default["default"].createElement("div", {
@@ -682,73 +456,121 @@ var EnvironmentBanner = function EnvironmentBanner(_ref) {
682
456
  });
683
457
  };
684
458
 
685
- var Login = function Login(_ref) {
686
- var redirectUri = _ref.redirectUri;
687
- var _useAuth = useAuth(),
688
- login = _useAuth.login;
459
+ function userLogout(logout) {
460
+ var _window$location = window.location,
461
+ protocol = _window$location.protocol,
462
+ hostname = _window$location.hostname,
463
+ port = _window$location.port;
464
+ return logout({
465
+ logoutParams: {
466
+ returnTo: protocol + "//" + hostname + ":" + port
467
+ }
468
+ });
469
+ }
470
+ var Authenticate = function Authenticate(_ref) {
471
+ var children = _ref.children,
472
+ decorateUser = _ref.decorateUser;
473
+ var _useState = React.useState(undefined),
474
+ userWithPermission = _useState[0],
475
+ setUserWithPermission = _useState[1];
476
+ var _useAuth = auth0React.useAuth0(),
477
+ user = _useAuth.user,
478
+ getAccessTokenSilently = _useAuth.getAccessTokenSilently,
479
+ loginWithRedirect = _useAuth.loginWithRedirect,
480
+ _logout = _useAuth.logout,
481
+ isLoading = _useAuth.isLoading,
482
+ isAuthenticated = _useAuth.isAuthenticated,
483
+ error = _useAuth.error;
689
484
  React.useEffect(function () {
690
- login(redirectUri);
691
- }, [login, redirectUri]);
692
- return null;
693
- };
694
- var Authenticate = function Authenticate(_ref2) {
695
- var children = _ref2.children,
696
- redirectUri = _ref2.redirectUri;
697
- var _useAuth2 = useAuth(),
698
- status = _useAuth2.status,
699
- user = _useAuth2.user,
700
- error = _useAuth2.error,
701
- logout = _useAuth2.logout,
702
- getToken = _useAuth2.getToken;
703
- switch (status) {
704
- case 'NOT_AUTHENTICATED':
705
- return React__default["default"].createElement(Login, {
706
- redirectUri: redirectUri
707
- });
708
- case 'AUTHENTICATED':
709
- util.assertIsDefined(user);
710
- return React__default["default"].createElement(React__default["default"].Fragment, null, children({
711
- user: user,
712
- logout: logout,
713
- getToken: getToken
485
+ var fetchUserData = /*#__PURE__*/function () {
486
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
487
+ var token, decoratedUser;
488
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
489
+ while (1) switch (_context.prev = _context.next) {
490
+ case 0:
491
+ _context.prev = 0;
492
+ _context.next = 3;
493
+ return getAccessTokenSilently();
494
+ case 3:
495
+ token = _context.sent;
496
+ _context.next = 6;
497
+ return decorateUser(user, token);
498
+ case 6:
499
+ decoratedUser = _context.sent;
500
+ setUserWithPermission(decoratedUser);
501
+ _context.next = 13;
502
+ break;
503
+ case 10:
504
+ _context.prev = 10;
505
+ _context.t0 = _context["catch"](0);
506
+ console.error('Error fetching user data:', _context.t0);
507
+ case 13:
508
+ case "end":
509
+ return _context.stop();
510
+ }
511
+ }, _callee, null, [[0, 10]]);
714
512
  }));
715
- case 'AUTHENTICATING':
716
- return React__default["default"].createElement(loader.Loader, {
717
- style: {
718
- marginTop: tokens.space.extraLarge9
719
- }
720
- }, "Authenticating");
721
- case 'ERROR':
722
- console.error(error);
723
- return React__default["default"].createElement(alert.BannerAlertBox, {
724
- variant: "error",
725
- title: "Authentication failed",
726
- style: {
727
- maxWidth: '600px',
728
- margin: '0 auto'
729
- }
730
- }, React__default["default"].createElement(typography.Paragraph, null, "Something went wrong while trying to authenticate you. If the problem persists you should contact", ' ', React__default["default"].createElement(typography.Link, {
731
- href: "mailto:support@entur.org"
732
- }, "support@entur.org"), " to get it resolved."), React__default["default"].createElement(typography.Paragraph, null, "Authentication failed with: ", React__default["default"].createElement(typography.CodeText, null, error == null ? void 0 : error.toString())));
733
- default:
734
- return null;
513
+ return function fetchUserData() {
514
+ return _ref2.apply(this, arguments);
515
+ };
516
+ }();
517
+ if (isAuthenticated) {
518
+ fetchUserData();
519
+ }
520
+ }, [decorateUser, getAccessTokenSilently, isAuthenticated, user]);
521
+ if (!isLoading && !isAuthenticated) {
522
+ loginWithRedirect();
523
+ return React__default["default"].createElement(loader.Loader, {
524
+ style: {
525
+ marginTop: tokens.space.extraLarge9
526
+ }
527
+ }, "Redirecting to login page");
528
+ }
529
+ if (isLoading || !userWithPermission) {
530
+ return React__default["default"].createElement(loader.Loader, {
531
+ style: {
532
+ marginTop: tokens.space.extraLarge9
533
+ }
534
+ }, "Authenticating");
735
535
  }
536
+ if (error) {
537
+ console.error(error);
538
+ return React__default["default"].createElement(alert.BannerAlertBox, {
539
+ variant: "error",
540
+ title: "Authentication failed",
541
+ style: {
542
+ maxWidth: '600px',
543
+ margin: '0 auto'
544
+ }
545
+ }, React__default["default"].createElement(typography.Paragraph, null, "Something went wrong while trying to authenticate you. If the problem persists you should contact", ' ', React__default["default"].createElement(typography.Link, {
546
+ href: "mailto:support@entur.org"
547
+ }, "support@entur.org"), " to get it resolved."), React__default["default"].createElement(typography.Paragraph, null, "Authentication failed with: ", React__default["default"].createElement(typography.CodeText, null, error == null ? void 0 : error.toString())));
548
+ }
549
+ util.assertIsDefined(userWithPermission);
550
+ return React__default["default"].createElement(React__default["default"].Fragment, null, children({
551
+ user: userWithPermission,
552
+ logout: function logout() {
553
+ return userLogout(_logout);
554
+ },
555
+ getToken: getAccessTokenSilently
556
+ }));
736
557
  };
737
558
  var AppShell = function AppShell(_ref3) {
738
559
  var children = _ref3.children,
739
560
  audience = _ref3.audience,
740
561
  domain = _ref3.domain,
741
562
  clientId = _ref3.clientId,
742
- redirectUri = _ref3.redirectUri,
743
563
  decorateUser = _ref3.decorateUser,
744
564
  environment = _ref3.environment;
745
- return React__default["default"].createElement(AuthProvider, {
746
- audience: audience,
565
+ return React__default["default"].createElement(auth0React.Auth0Provider, {
747
566
  domain: domain,
748
- client_id: clientId,
749
- decorateUser: decorateUser
567
+ clientId: clientId,
568
+ authorizationParams: {
569
+ redirect_uri: window.location.origin,
570
+ audience: audience
571
+ }
750
572
  }, React__default["default"].createElement(Authenticate, {
751
- redirectUri: redirectUri
573
+ decorateUser: decorateUser
752
574
  }, function (params) {
753
575
  return React__default["default"].createElement(React__default["default"].Fragment, null, environment && environment !== common.Environment.Production && React__default["default"].createElement(EnvironmentBanner, {
754
576
  environment: environment
@@ -931,7 +753,6 @@ var LanguageProvider = function LanguageProvider(_ref) {
931
753
  };
932
754
 
933
755
  var OrganisationsError = /*#__PURE__*/function (_Error) {
934
- _inheritsLoose(OrganisationsError, _Error);
935
756
  function OrganisationsError() {
936
757
  var _this;
937
758
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
@@ -941,6 +762,7 @@ var OrganisationsError = /*#__PURE__*/function (_Error) {
941
762
  _this.message = 'Failed fetching organisations';
942
763
  return _this;
943
764
  }
765
+ _inheritsLoose(OrganisationsError, _Error);
944
766
  return OrganisationsError;
945
767
  }( /*#__PURE__*/_wrapNativeSuper(Error));
946
768