@compilot/web-sdk 2.145.0-dev → 2.146.0-dev

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.
@@ -7,274 +7,116 @@ import { isDeepEqual } from 'remeda';
7
7
  import { EventEmitter } from 'eventemitter3';
8
8
  import jwtDecode from 'jwt-decode';
9
9
 
10
- function _regeneratorRuntime() {
11
- _regeneratorRuntime = function () {
12
- return r;
13
- };
14
- var t,
15
- r = {},
16
- e = Object.prototype,
17
- n = e.hasOwnProperty,
18
- o = "function" == typeof Symbol ? Symbol : {},
19
- i = o.iterator || "@@iterator",
20
- a = o.asyncIterator || "@@asyncIterator",
21
- u = o.toStringTag || "@@toStringTag";
22
- function c(t, r, e, n) {
23
- Object.defineProperty(t, r, {
24
- value: e,
25
- enumerable: !n,
26
- configurable: !n,
27
- writable: !n
28
- });
29
- }
10
+ function _regeneratorDefine(e, r, n, t) {
11
+ var i = Object.defineProperty;
30
12
  try {
31
- c({}, "");
32
- } catch (t) {
33
- c = function (t, r, e) {
34
- return t[r] = e;
35
- };
13
+ i({}, "", {});
14
+ } catch (e) {
15
+ i = 0;
36
16
  }
37
- function h(r, e, n, o) {
38
- var i = e && e.prototype instanceof Generator ? e : Generator,
39
- a = Object.create(i.prototype);
40
- return c(a, "_invoke", function (r, e, n) {
41
- var o = 1;
42
- return function (i, a) {
43
- if (3 === o) throw Error("Generator is already running");
44
- if (4 === o) {
45
- if ("throw" === i) throw a;
46
- return {
47
- value: t,
48
- done: !0
49
- };
50
- }
51
- for (n.method = i, n.arg = a;;) {
52
- var u = n.delegate;
53
- if (u) {
54
- var c = d(u, n);
55
- if (c) {
56
- if (c === f) continue;
57
- return c;
58
- }
17
+ _regeneratorDefine = function (e, r, n, t) {
18
+ if (r) i ? i(e, r, {
19
+ value: n,
20
+ enumerable: !t,
21
+ configurable: !t,
22
+ writable: !t
23
+ }) : e[r] = n;else {
24
+ function o(r, n) {
25
+ _regeneratorDefine(e, r, function (e) {
26
+ return this._invoke(r, n, e);
27
+ });
28
+ }
29
+ o("next", 0), o("throw", 1), o("return", 2);
30
+ }
31
+ }, _regeneratorDefine(e, r, n, t);
32
+ }
33
+
34
+ function _regenerator() {
35
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
36
+ var e,
37
+ t,
38
+ r = "function" == typeof Symbol ? Symbol : {},
39
+ n = r.iterator || "@@iterator",
40
+ o = r.toStringTag || "@@toStringTag";
41
+ function i(r, n, o, i) {
42
+ var c = n && n.prototype instanceof Generator ? n : Generator,
43
+ u = Object.create(c.prototype);
44
+ return _regeneratorDefine(u, "_invoke", function (r, n, o) {
45
+ var i,
46
+ c,
47
+ u,
48
+ f = 0,
49
+ p = o || [],
50
+ y = !1,
51
+ G = {
52
+ p: 0,
53
+ n: 0,
54
+ v: e,
55
+ a: d,
56
+ f: d.bind(e, 4),
57
+ d: function (t, r) {
58
+ return i = t, c = 0, u = e, G.n = r, a;
59
59
  }
60
- if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
61
- if (1 === o) throw o = 4, n.arg;
62
- n.dispatchException(n.arg);
63
- } else "return" === n.method && n.abrupt("return", n.arg);
64
- o = 3;
65
- var h = s(r, e, n);
66
- if ("normal" === h.type) {
67
- if (o = n.done ? 4 : 2, h.arg === f) continue;
68
- return {
69
- value: h.arg,
70
- done: n.done
71
- };
60
+ };
61
+ function d(r, n) {
62
+ for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
63
+ var o,
64
+ i = p[t],
65
+ d = G.p,
66
+ l = i[2];
67
+ r > 3 ? (o = l === n) && (c = i[4] || 3, u = i[5] === e ? i[3] : i[5], i[4] = 3, 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));
68
+ }
69
+ if (o || r > 1) return a;
70
+ throw y = !0, n;
71
+ }
72
+ return function (o, p, l) {
73
+ if (f > 1) throw TypeError("Generator is already running");
74
+ for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
75
+ i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
76
+ try {
77
+ if (f = 2, i) {
78
+ if (c || (o = "next"), t = i[o]) {
79
+ if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
80
+ if (!t.done) return t;
81
+ u = t.value, c < 2 && (c = 0);
82
+ } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
83
+ i = e;
84
+ } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
85
+ } catch (t) {
86
+ i = e, c = 1, u = t;
87
+ } finally {
88
+ f = 1;
72
89
  }
73
- "throw" === h.type && (o = 4, n.method = "throw", n.arg = h.arg);
74
90
  }
91
+ return {
92
+ value: t,
93
+ done: y
94
+ };
75
95
  };
76
- }(r, n, new Context(o || [])), !0), a;
77
- }
78
- function s(t, r, e) {
79
- try {
80
- return {
81
- type: "normal",
82
- arg: t.call(r, e)
83
- };
84
- } catch (t) {
85
- return {
86
- type: "throw",
87
- arg: t
88
- };
89
- }
96
+ }(r, o, i), !0), u;
90
97
  }
91
- r.wrap = h;
92
- var f = {};
98
+ var a = {};
93
99
  function Generator() {}
94
100
  function GeneratorFunction() {}
95
101
  function GeneratorFunctionPrototype() {}
96
- var l = {};
97
- c(l, i, function () {
98
- return this;
99
- });
100
- var p = Object.getPrototypeOf,
101
- y = p && p(p(x([])));
102
- y && y !== e && n.call(y, i) && (l = y);
103
- var v = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(l);
104
- function g(t) {
105
- ["next", "throw", "return"].forEach(function (r) {
106
- c(t, r, function (t) {
107
- return this._invoke(r, t);
108
- });
109
- });
110
- }
111
- function AsyncIterator(t, r) {
112
- function e(o, i, a, u) {
113
- var c = s(t[o], t, i);
114
- if ("throw" !== c.type) {
115
- var h = c.arg,
116
- f = h.value;
117
- return f && "object" == typeof f && n.call(f, "__await") ? r.resolve(f.__await).then(function (t) {
118
- e("next", t, a, u);
119
- }, function (t) {
120
- e("throw", t, a, u);
121
- }) : r.resolve(f).then(function (t) {
122
- h.value = t, a(h);
123
- }, function (t) {
124
- return e("throw", t, a, u);
125
- });
126
- }
127
- u(c.arg);
128
- }
129
- var o;
130
- c(this, "_invoke", function (t, n) {
131
- function i() {
132
- return new r(function (r, o) {
133
- e(t, n, r, o);
134
- });
135
- }
136
- return o = o ? o.then(i, i) : i();
137
- }, !0);
138
- }
139
- function d(r, e) {
140
- var n = e.method,
141
- o = r.i[n];
142
- if (o === t) return e.delegate = null, "throw" === n && r.i.return && (e.method = "return", e.arg = t, d(r, e), "throw" === e.method) || "return" !== n && (e.method = "throw", e.arg = new TypeError("The iterator does not provide a '" + n + "' method")), f;
143
- var i = s(o, r.i, e.arg);
144
- if ("throw" === i.type) return e.method = "throw", e.arg = i.arg, e.delegate = null, f;
145
- var a = i.arg;
146
- return a ? a.done ? (e[r.r] = a.value, e.next = r.n, "return" !== e.method && (e.method = "next", e.arg = t), e.delegate = null, f) : a : (e.method = "throw", e.arg = new TypeError("iterator result is not an object"), e.delegate = null, f);
147
- }
148
- function w(t) {
149
- this.tryEntries.push(t);
102
+ t = Object.getPrototypeOf;
103
+ var c = [][n] ? t(t([][n]())) : (_regeneratorDefine(t = {}, n, function () {
104
+ return this;
105
+ }), t),
106
+ u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
107
+ function f(e) {
108
+ return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
150
109
  }
151
- function m(r) {
152
- var e = r[4] || {};
153
- e.type = "normal", e.arg = t, r[4] = e;
154
- }
155
- function Context(t) {
156
- this.tryEntries = [[-1]], t.forEach(w, this), this.reset(!0);
157
- }
158
- function x(r) {
159
- if (null != r) {
160
- var e = r[i];
161
- if (e) return e.call(r);
162
- if ("function" == typeof r.next) return r;
163
- if (!isNaN(r.length)) {
164
- var o = -1,
165
- a = function e() {
166
- for (; ++o < r.length;) if (n.call(r, o)) return e.value = r[o], e.done = !1, e;
167
- return e.value = t, e.done = !0, e;
168
- };
169
- return a.next = a;
170
- }
171
- }
172
- throw new TypeError(typeof r + " is not iterable");
173
- }
174
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, c(v, "constructor", GeneratorFunctionPrototype), c(GeneratorFunctionPrototype, "constructor", GeneratorFunction), c(GeneratorFunctionPrototype, u, GeneratorFunction.displayName = "GeneratorFunction"), r.isGeneratorFunction = function (t) {
175
- var r = "function" == typeof t && t.constructor;
176
- return !!r && (r === GeneratorFunction || "GeneratorFunction" === (r.displayName || r.name));
177
- }, r.mark = function (t) {
178
- return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, c(t, u, "GeneratorFunction")), t.prototype = Object.create(v), t;
179
- }, r.awrap = function (t) {
180
- return {
181
- __await: t
182
- };
183
- }, g(AsyncIterator.prototype), c(AsyncIterator.prototype, a, function () {
184
- return this;
185
- }), r.AsyncIterator = AsyncIterator, r.async = function (t, e, n, o, i) {
186
- void 0 === i && (i = Promise);
187
- var a = new AsyncIterator(h(t, e, n, o), i);
188
- return r.isGeneratorFunction(e) ? a : a.next().then(function (t) {
189
- return t.done ? t.value : a.next();
190
- });
191
- }, g(v), c(v, u, "Generator"), c(v, i, function () {
110
+ 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 () {
192
111
  return this;
193
- }), c(v, "toString", function () {
112
+ }), _regeneratorDefine(u, "toString", function () {
194
113
  return "[object Generator]";
195
- }), r.keys = function (t) {
196
- var r = Object(t),
197
- e = [];
198
- for (var n in r) e.unshift(n);
199
- return function t() {
200
- for (; e.length;) if ((n = e.pop()) in r) return t.value = n, t.done = !1, t;
201
- return t.done = !0, t;
114
+ }), (_regenerator = function () {
115
+ return {
116
+ w: i,
117
+ m: f
202
118
  };
203
- }, r.values = x, Context.prototype = {
204
- constructor: Context,
205
- reset: function (r) {
206
- if (this.prev = this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(m), !r) for (var e in this) "t" === e.charAt(0) && n.call(this, e) && !isNaN(+e.slice(1)) && (this[e] = t);
207
- },
208
- stop: function () {
209
- this.done = !0;
210
- var t = this.tryEntries[0][4];
211
- if ("throw" === t.type) throw t.arg;
212
- return this.rval;
213
- },
214
- dispatchException: function (r) {
215
- if (this.done) throw r;
216
- var e = this;
217
- function n(t) {
218
- a.type = "throw", a.arg = r, e.next = t;
219
- }
220
- for (var o = e.tryEntries.length - 1; o >= 0; --o) {
221
- var i = this.tryEntries[o],
222
- a = i[4],
223
- u = this.prev,
224
- c = i[1],
225
- h = i[2];
226
- if (-1 === i[0]) return n("end"), !1;
227
- if (!c && !h) throw Error("try statement without catch or finally");
228
- if (null != i[0] && i[0] <= u) {
229
- if (u < c) return this.method = "next", this.arg = t, n(c), !0;
230
- if (u < h) return n(h), !1;
231
- }
232
- }
233
- },
234
- abrupt: function (t, r) {
235
- for (var e = this.tryEntries.length - 1; e >= 0; --e) {
236
- var n = this.tryEntries[e];
237
- if (n[0] > -1 && n[0] <= this.prev && this.prev < n[2]) {
238
- var o = n;
239
- break;
240
- }
241
- }
242
- o && ("break" === t || "continue" === t) && o[0] <= r && r <= o[2] && (o = null);
243
- var i = o ? o[4] : {};
244
- return i.type = t, i.arg = r, o ? (this.method = "next", this.next = o[2], f) : this.complete(i);
245
- },
246
- complete: function (t, r) {
247
- if ("throw" === t.type) throw t.arg;
248
- 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 && r && (this.next = r), f;
249
- },
250
- finish: function (t) {
251
- for (var r = this.tryEntries.length - 1; r >= 0; --r) {
252
- var e = this.tryEntries[r];
253
- if (e[2] === t) return this.complete(e[4], e[3]), m(e), f;
254
- }
255
- },
256
- catch: function (t) {
257
- for (var r = this.tryEntries.length - 1; r >= 0; --r) {
258
- var e = this.tryEntries[r];
259
- if (e[0] === t) {
260
- var n = e[4];
261
- if ("throw" === n.type) {
262
- var o = n.arg;
263
- m(e);
264
- }
265
- return o;
266
- }
267
- }
268
- throw Error("illegal catch attempt");
269
- },
270
- delegateYield: function (r, e, n) {
271
- return this.delegate = {
272
- i: x(r),
273
- r: e,
274
- n: n
275
- }, "next" === this.method && (this.arg = t), f;
276
- }
277
- }, r;
119
+ })();
278
120
  }
279
121
 
280
122
  function asyncGeneratorStep(n, t, e, r, o, a, c) {
@@ -703,17 +545,14 @@ var createAuthAdapter = function createAuthAdapter(params) {
703
545
  createSession = _parsed$data.createSession,
704
546
  isAuthenticated = _parsed$data.isAuthenticated;
705
547
  var login = /*#__PURE__*/function () {
706
- var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
707
- return _regeneratorRuntime().wrap(function _callee$(_context) {
708
- while (1) switch (_context.prev = _context.next) {
548
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
549
+ return _regenerator().w(function (_context) {
550
+ while (1) switch (_context.n) {
709
551
  case 0:
710
- _context.next = 2;
552
+ _context.n = 1;
711
553
  return createSession();
712
- case 2:
713
- return _context.abrupt("return", _context.sent);
714
- case 3:
715
- case "end":
716
- return _context.stop();
554
+ case 1:
555
+ return _context.a(2, _context.v);
717
556
  }
718
557
  }, _callee);
719
558
  }));
@@ -969,36 +808,35 @@ function createIframeHandler(_ref) {
969
808
  }
970
809
  window.addEventListener("message", handleMessage);
971
810
  var waitForIframeLoad = /*#__PURE__*/function () {
972
- var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref2) {
811
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref2) {
973
812
  var _ref2$maxWaitTime, maxWaitTime, _ref2$interval, interval, _ref2$onTimeout, onTimeout, count;
974
- return _regeneratorRuntime().wrap(function _callee$(_context) {
975
- while (1) switch (_context.prev = _context.next) {
813
+ return _regenerator().w(function (_context) {
814
+ while (1) switch (_context.n) {
976
815
  case 0:
977
816
  _ref2$maxWaitTime = _ref2.maxWaitTime, maxWaitTime = _ref2$maxWaitTime === void 0 ? 3000 : _ref2$maxWaitTime, _ref2$interval = _ref2.interval, interval = _ref2$interval === void 0 ? 100 : _ref2$interval, _ref2$onTimeout = _ref2.onTimeout, onTimeout = _ref2$onTimeout === void 0 ? function () {
978
817
  logger.error("iframe not loaded");
979
818
  throw new Error("iframe not loaded");
980
819
  } : _ref2$onTimeout;
981
820
  count = maxWaitTime / interval;
982
- case 2:
821
+ case 1:
983
822
  if (!(!iframe && count > 0)) {
984
- _context.next = 8;
823
+ _context.n = 3;
985
824
  break;
986
825
  }
987
- _context.next = 5;
826
+ _context.n = 2;
988
827
  return new Promise(function (resolve) {
989
828
  return setTimeout(resolve, interval);
990
829
  });
991
- case 5:
830
+ case 2:
992
831
  count--;
993
- _context.next = 2;
832
+ _context.n = 1;
994
833
  break;
995
- case 8:
834
+ case 3:
996
835
  if (!iframe) {
997
836
  onTimeout === null || onTimeout === void 0 || onTimeout();
998
837
  }
999
- case 9:
1000
- case "end":
1001
- return _context.stop();
838
+ case 4:
839
+ return _context.a(2);
1002
840
  }
1003
841
  }, _callee);
1004
842
  }));
@@ -1025,23 +863,22 @@ function createIframeHandler(_ref) {
1025
863
  }
1026
864
  },
1027
865
  show: function () {
1028
- var _show = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
1029
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1030
- while (1) switch (_context2.prev = _context2.next) {
866
+ var _show = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
867
+ return _regenerator().w(function (_context2) {
868
+ while (1) switch (_context2.n) {
1031
869
  case 0:
1032
870
  if (iframe) {
1033
- _context2.next = 3;
871
+ _context2.n = 1;
1034
872
  break;
1035
873
  }
1036
- _context2.next = 3;
874
+ _context2.n = 1;
1037
875
  return waitForIframeLoad({});
1038
- case 3:
876
+ case 1:
1039
877
  showElement(backdrop);
1040
878
  showElement(iframe);
1041
879
  onShow();
1042
- case 6:
1043
- case "end":
1044
- return _context2.stop();
880
+ case 2:
881
+ return _context2.a(2);
1045
882
  }
1046
883
  }, _callee2);
1047
884
  }));
@@ -1051,22 +888,21 @@ function createIframeHandler(_ref) {
1051
888
  return show;
1052
889
  }(),
1053
890
  hide: function () {
1054
- var _hide = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
1055
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
1056
- while (1) switch (_context3.prev = _context3.next) {
891
+ var _hide = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
892
+ return _regenerator().w(function (_context3) {
893
+ while (1) switch (_context3.n) {
1057
894
  case 0:
1058
895
  if (iframe) {
1059
- _context3.next = 3;
896
+ _context3.n = 1;
1060
897
  break;
1061
898
  }
1062
- _context3.next = 3;
899
+ _context3.n = 1;
1063
900
  return waitForIframeLoad({});
1064
- case 3:
901
+ case 1:
1065
902
  hideElement(iframe);
1066
903
  hideElement(backdrop);
1067
- case 5:
1068
- case "end":
1069
- return _context3.stop();
904
+ case 2:
905
+ return _context3.a(2);
1070
906
  }
1071
907
  }, _callee3);
1072
908
  }));
@@ -1076,21 +912,18 @@ function createIframeHandler(_ref) {
1076
912
  return hide;
1077
913
  }(),
1078
914
  isShown: function () {
1079
- var _isShown = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
1080
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
1081
- while (1) switch (_context4.prev = _context4.next) {
915
+ var _isShown = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
916
+ return _regenerator().w(function (_context4) {
917
+ while (1) switch (_context4.n) {
1082
918
  case 0:
1083
919
  if (iframe) {
1084
- _context4.next = 3;
920
+ _context4.n = 1;
1085
921
  break;
1086
922
  }
1087
- _context4.next = 3;
923
+ _context4.n = 1;
1088
924
  return waitForIframeLoad({});
1089
- case 3:
1090
- return _context4.abrupt("return", iframe.style.visibility === "visible");
1091
- case 4:
1092
- case "end":
1093
- return _context4.stop();
925
+ case 1:
926
+ return _context4.a(2, iframe.style.visibility === "visible");
1094
927
  }
1095
928
  }, _callee4);
1096
929
  }));
@@ -1100,17 +933,17 @@ function createIframeHandler(_ref) {
1100
933
  return isShown;
1101
934
  }(),
1102
935
  postMessage: function () {
1103
- var _postMessage = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(message) {
1104
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
1105
- while (1) switch (_context5.prev = _context5.next) {
936
+ var _postMessage = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(message) {
937
+ return _regenerator().w(function (_context5) {
938
+ while (1) switch (_context5.n) {
1106
939
  case 0:
1107
940
  if (iframe) {
1108
- _context5.next = 3;
941
+ _context5.n = 1;
1109
942
  break;
1110
943
  }
1111
- _context5.next = 3;
944
+ _context5.n = 1;
1112
945
  return waitForIframeLoad({});
1113
- case 3:
946
+ case 1:
1114
947
  logger.debug({
1115
948
  msg: "🔧↗️📱 Sending message to identity app",
1116
949
  values: message
@@ -1121,9 +954,8 @@ function createIframeHandler(_ref) {
1121
954
  frames[iframe.name].postMessage(_objectSpread2(_objectSpread2({}, message), {}, {
1122
955
  identifier: identifier
1123
956
  }), baseURL);
1124
- case 5:
1125
- case "end":
1126
- return _context5.stop();
957
+ case 2:
958
+ return _context5.a(2);
1127
959
  }
1128
960
  }, _callee5);
1129
961
  }));
@@ -1299,36 +1131,36 @@ var createConfig = function createConfig(params) {
1299
1131
  var unsubscribe = widgetStateStore.subscribe(function (state) {
1300
1132
  return state.auth;
1301
1133
  }, /*#__PURE__*/function () {
1302
- var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(auth) {
1134
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(auth) {
1303
1135
  var maxWait, isLoaded;
1304
- return _regeneratorRuntime().wrap(function _callee$(_context) {
1305
- while (1) switch (_context.prev = _context.next) {
1136
+ return _regenerator().w(function (_context) {
1137
+ while (1) switch (_context.n) {
1306
1138
  case 0:
1307
1139
  if (!(auth !== "not_authenticated" && auth !== "loading")) {
1308
- _context.next = 15;
1140
+ _context.n = 5;
1309
1141
  break;
1310
1142
  }
1311
1143
  // this might happen before the iframe is loaded, so we need to check for the ACK message
1312
1144
  // before sending the auth session to the iframe
1313
1145
  maxWait = 2000;
1314
1146
  isLoaded = false;
1315
- case 3:
1147
+ case 1:
1316
1148
  if (!(!isLoaded && maxWait > 0)) {
1317
- _context.next = 10;
1149
+ _context.n = 3;
1318
1150
  break;
1319
1151
  }
1320
1152
  isLoaded = widgetStateStore.select(function (state) {
1321
1153
  return state.injected === "loaded" || state.injected === "configured";
1322
1154
  });
1323
1155
  maxWait -= 100;
1324
- _context.next = 8;
1156
+ _context.n = 2;
1325
1157
  return new Promise(function (resolve) {
1326
1158
  return setTimeout(resolve, 100);
1327
1159
  });
1328
- case 8:
1329
- _context.next = 3;
1160
+ case 2:
1161
+ _context.n = 1;
1330
1162
  break;
1331
- case 10:
1163
+ case 3:
1332
1164
  if (!isLoaded) {
1333
1165
  logger.error({
1334
1166
  msg: "Failed to send auth session to iframe",
@@ -1337,39 +1169,38 @@ var createConfig = function createConfig(params) {
1337
1169
  }
1338
1170
  });
1339
1171
  }
1340
- _context.next = 13;
1172
+ _context.n = 4;
1341
1173
  return iframeHandler.postMessage({
1342
1174
  type: "appConfig",
1343
1175
  data: {
1344
1176
  authSession: auth
1345
1177
  }
1346
1178
  });
1347
- case 13:
1348
- _context.next = 21;
1179
+ case 4:
1180
+ _context.n = 7;
1349
1181
  break;
1350
- case 15:
1182
+ case 5:
1351
1183
  if (!(auth === "not_authenticated")) {
1352
- _context.next = 21;
1184
+ _context.n = 7;
1353
1185
  break;
1354
1186
  }
1355
1187
  if (!(widgetStateStore.select(function (state) {
1356
1188
  return state.visible;
1357
1189
  }) === "visible")) {
1358
- _context.next = 21;
1190
+ _context.n = 7;
1359
1191
  break;
1360
1192
  }
1361
- _context.next = 19;
1193
+ _context.n = 6;
1362
1194
  return iframeHandler.hide();
1363
- case 19:
1195
+ case 6:
1364
1196
  externalEventEmitter.emit("screenClosed");
1365
1197
  widgetStateStore.update(function (state) {
1366
1198
  return _objectSpread2(_objectSpread2({}, state), {}, {
1367
1199
  visible: "not_visible"
1368
1200
  });
1369
1201
  });
1370
- case 21:
1371
- case "end":
1372
- return _context.stop();
1202
+ case 7:
1203
+ return _context.a(2);
1373
1204
  }
1374
1205
  }, _callee);
1375
1206
  }));
@@ -1381,29 +1212,26 @@ var createConfig = function createConfig(params) {
1381
1212
  emitImmediately: true
1382
1213
  });
1383
1214
  var onSignMessage = /*#__PURE__*/function () {
1384
- var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref2) {
1215
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref2) {
1385
1216
  var message, _yield$authAdapter$si, signature;
1386
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1387
- while (1) switch (_context2.prev = _context2.next) {
1217
+ return _regenerator().w(function (_context2) {
1218
+ while (1) switch (_context2.n) {
1388
1219
  case 0:
1389
1220
  message = _ref2.message;
1390
1221
  if (isWeb3AuthAdapter(authAdapter)) {
1391
- _context2.next = 3;
1222
+ _context2.n = 1;
1392
1223
  break;
1393
1224
  }
1394
1225
  throw new Web3AuthRequiredForThisAction("signMessage");
1395
- case 3:
1396
- _context2.next = 5;
1226
+ case 1:
1227
+ _context2.n = 2;
1397
1228
  return authAdapter.signMessage({
1398
1229
  message: message
1399
1230
  });
1400
- case 5:
1401
- _yield$authAdapter$si = _context2.sent;
1231
+ case 2:
1232
+ _yield$authAdapter$si = _context2.v;
1402
1233
  signature = _yield$authAdapter$si.signature;
1403
- return _context2.abrupt("return", signature);
1404
- case 8:
1405
- case "end":
1406
- return _context2.stop();
1234
+ return _context2.a(2, signature);
1407
1235
  }
1408
1236
  }, _callee2);
1409
1237
  }));
@@ -1436,110 +1264,110 @@ var createConfig = function createConfig(params) {
1436
1264
  });
1437
1265
  },
1438
1266
  onMessage: function () {
1439
- var _onMessage = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref5) {
1440
- var message, rawEvent, txHash, _message$data;
1441
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
1442
- while (1) switch (_context3.prev = _context3.next) {
1267
+ var _onMessage = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(_ref5) {
1268
+ var message, rawEvent, txHash, _message$data, _t, _t2, _t3, _t4, _t5, _t6;
1269
+ return _regenerator().w(function (_context3) {
1270
+ while (1) switch (_context3.n) {
1443
1271
  case 0:
1444
1272
  message = _ref5.message, rawEvent = _ref5.rawEvent;
1445
- _context3.t0 = message.type;
1446
- _context3.next = _context3.t0 === "identityAppLoaded" ? 4 : _context3.t0 === "identityAppConfigured" ? 7 : _context3.t0 === "authenticationExpired" ? 9 : _context3.t0 === "walletSignRequest" ? 11 : _context3.t0 === "sendTransactionRequest" ? 21 : _context3.t0 === "kycCompletion" ? 29 : _context3.t0 === "scenarioExecution" ? 31 : _context3.t0 === "closeScreen" ? 33 : _context3.t0 === "txAuthDataSignatureResponse" ? 38 : _context3.t0 === "txAuthDataSignatureGatingError" ? 40 : _context3.t0 === "getCustomerStatusResponse" ? 42 : 44;
1273
+ _t = message.type;
1274
+ _context3.n = _t === "identityAppLoaded" ? 1 : _t === "identityAppConfigured" ? 2 : _t === "authenticationExpired" ? 3 : _t === "walletSignRequest" ? 4 : _t === "sendTransactionRequest" ? 7 : _t === "kycCompletion" ? 11 : _t === "scenarioExecution" ? 12 : _t === "closeScreen" ? 13 : _t === "txAuthDataSignatureResponse" ? 15 : _t === "txAuthDataSignatureGatingError" ? 16 : _t === "getCustomerStatusResponse" ? 17 : 18;
1447
1275
  break;
1448
- case 4:
1276
+ case 1:
1449
1277
  externalEventEmitter.emit("appLoaded");
1450
1278
  widgetStateStore.update(function (state) {
1451
1279
  return _objectSpread2(_objectSpread2({}, state), {}, {
1452
1280
  injected: "loaded"
1453
1281
  });
1454
1282
  });
1455
- return _context3.abrupt("break", 46);
1456
- case 7:
1283
+ return _context3.a(3, 19);
1284
+ case 2:
1457
1285
  widgetStateStore.update(function (state) {
1458
1286
  return _objectSpread2(_objectSpread2({}, state), {}, {
1459
1287
  injected: "configured",
1460
1288
  auth: message.data.auth
1461
1289
  });
1462
1290
  });
1463
- return _context3.abrupt("break", 46);
1464
- case 9:
1291
+ return _context3.a(3, 19);
1292
+ case 3:
1465
1293
  widgetStateStore.update(function (state) {
1466
1294
  return _objectSpread2(_objectSpread2({}, state), {}, {
1467
1295
  auth: "not_authenticated"
1468
1296
  });
1469
1297
  });
1470
- return _context3.abrupt("break", 46);
1471
- case 11:
1472
- _context3.t1 = iframeHandler;
1473
- _context3.t2 = message.data.message;
1474
- _context3.next = 15;
1298
+ return _context3.a(3, 19);
1299
+ case 4:
1300
+ _t2 = iframeHandler;
1301
+ _t3 = message.data.message;
1302
+ _context3.n = 5;
1475
1303
  return onSignMessage({
1476
1304
  message: message.data.message
1477
1305
  });
1478
- case 15:
1479
- _context3.t3 = _context3.sent;
1480
- _context3.t4 = {
1481
- message: _context3.t2,
1482
- signature: _context3.t3
1306
+ case 5:
1307
+ _t4 = _context3.v;
1308
+ _t5 = {
1309
+ message: _t3,
1310
+ signature: _t4
1483
1311
  };
1484
- _context3.t5 = {
1312
+ _t6 = {
1485
1313
  type: "walletSignResponse",
1486
- data: _context3.t4
1314
+ data: _t5
1487
1315
  };
1488
- _context3.next = 20;
1489
- return _context3.t1.postMessage.call(_context3.t1, _context3.t5);
1490
- case 20:
1491
- return _context3.abrupt("break", 46);
1492
- case 21:
1493
- _context3.next = 23;
1316
+ _context3.n = 6;
1317
+ return _t2.postMessage.call(_t2, _t6);
1318
+ case 6:
1319
+ return _context3.a(3, 19);
1320
+ case 7:
1321
+ _context3.n = 8;
1494
1322
  return onSendTransaction({
1495
1323
  data: message.data
1496
1324
  });
1497
- case 23:
1498
- txHash = _context3.sent;
1325
+ case 8:
1326
+ txHash = _context3.v;
1499
1327
  if (!(txHash === undefined)) {
1500
- _context3.next = 26;
1328
+ _context3.n = 9;
1501
1329
  break;
1502
1330
  }
1503
1331
  throw new Error("Returned TxHash was undefined");
1504
- case 26:
1505
- _context3.next = 28;
1332
+ case 9:
1333
+ _context3.n = 10;
1506
1334
  return iframeHandler.postMessage({
1507
1335
  type: "transactionResponse",
1508
1336
  data: {
1509
1337
  txHash: txHash
1510
1338
  }
1511
1339
  });
1512
- case 28:
1513
- return _context3.abrupt("break", 46);
1514
- case 29:
1340
+ case 10:
1341
+ return _context3.a(3, 19);
1342
+ case 11:
1515
1343
  externalEventEmitter.emit("kycCompleted", KycCompletionData.parse(message.data));
1516
- return _context3.abrupt("break", 46);
1517
- case 31:
1344
+ return _context3.a(3, 19);
1345
+ case 12:
1518
1346
  externalEventEmitter.emit("scenarioExecuted", ScenarioExecutionData.parse(message.data));
1519
- return _context3.abrupt("break", 46);
1520
- case 33:
1521
- _context3.next = 35;
1347
+ return _context3.a(3, 19);
1348
+ case 13:
1349
+ _context3.n = 14;
1522
1350
  return iframeHandler.hide();
1523
- case 35:
1351
+ case 14:
1524
1352
  externalEventEmitter.emit("screenClosed");
1525
1353
  widgetStateStore.update(function (state) {
1526
1354
  return _objectSpread2(_objectSpread2({}, state), {}, {
1527
1355
  visible: "not_visible"
1528
1356
  });
1529
1357
  });
1530
- return _context3.abrupt("break", 46);
1531
- case 38:
1358
+ return _context3.a(3, 19);
1359
+ case 15:
1532
1360
  externalEventEmitter.emit("txAuthDataSignatureResponse", message.data);
1533
- return _context3.abrupt("break", 46);
1534
- case 40:
1361
+ return _context3.a(3, 19);
1362
+ case 16:
1535
1363
  externalEventEmitter.emit("txAuthDataSignatureGatingError", message.data);
1536
- return _context3.abrupt("break", 46);
1537
- case 42:
1364
+ return _context3.a(3, 19);
1365
+ case 17:
1538
1366
  externalEventEmitter.emit("getCustomerStatusResponse", {
1539
1367
  status: (_message$data = message.data) !== null && _message$data !== void 0 ? _message$data : null
1540
1368
  });
1541
- return _context3.abrupt("break", 46);
1542
- case 44:
1369
+ return _context3.a(3, 19);
1370
+ case 18:
1543
1371
  logger.debug({
1544
1372
  msg: "Unhandled message type:",
1545
1373
  values: {
@@ -1547,10 +1375,9 @@ var createConfig = function createConfig(params) {
1547
1375
  rawEvent: rawEvent
1548
1376
  }
1549
1377
  });
1550
- return _context3.abrupt("break", 46);
1551
- case 46:
1552
- case "end":
1553
- return _context3.stop();
1378
+ return _context3.a(3, 19);
1379
+ case 19:
1380
+ return _context3.a(2);
1554
1381
  }
1555
1382
  }, _callee3);
1556
1383
  }));
@@ -1643,54 +1470,54 @@ var createWeb3AuthAdapter = function createWeb3AuthAdapter(params) {
1643
1470
  env: getEnv()
1644
1471
  });
1645
1472
  var login = /*#__PURE__*/function () {
1646
- var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(loginParams) {
1647
- var address, blockchainId, challengeRes, signatureRes, VerifyWalletChallengeRequest, res;
1648
- return _regeneratorRuntime().wrap(function _callee$(_context) {
1649
- while (1) switch (_context.prev = _context.next) {
1473
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(loginParams) {
1474
+ var address, blockchainId, challengeRes, signatureRes, VerifyWalletChallengeRequest, res, _t;
1475
+ return _regenerator().w(function (_context) {
1476
+ while (1) switch (_context.n) {
1650
1477
  case 0:
1651
- _context.next = 2;
1478
+ _context.n = 1;
1652
1479
  return wallet.getAddress();
1653
- case 2:
1654
- address = _context.sent;
1480
+ case 1:
1481
+ address = _context.v;
1655
1482
  if (address) {
1656
- _context.next = 5;
1483
+ _context.n = 2;
1657
1484
  break;
1658
1485
  }
1659
1486
  throw new AddressUndefinedButRequiredForLogin();
1660
- case 5:
1487
+ case 2:
1661
1488
  blockchainId = undefined;
1662
1489
  if (!wallet.getBlockchainId) {
1663
- _context.next = 10;
1490
+ _context.n = 4;
1664
1491
  break;
1665
1492
  }
1666
- _context.next = 9;
1493
+ _context.n = 3;
1667
1494
  return wallet.getBlockchainId();
1668
- case 9:
1669
- blockchainId = _context.sent;
1670
- case 10:
1671
- _context.next = 12;
1495
+ case 3:
1496
+ blockchainId = _context.v;
1497
+ case 4:
1498
+ _context.n = 5;
1672
1499
  return generateChallenge({
1673
1500
  address: address,
1674
1501
  namespace: wallet.namespace,
1675
1502
  blockchainId: blockchainId,
1676
1503
  origin: getOrigin(loginParams)
1677
1504
  });
1678
- case 12:
1679
- challengeRes = _context.sent;
1680
- _context.prev = 13;
1681
- _context.next = 16;
1505
+ case 5:
1506
+ challengeRes = _context.v;
1507
+ _context.p = 6;
1508
+ _context.n = 7;
1682
1509
  return wallet.sign({
1683
1510
  message: challengeRes.challenge
1684
1511
  });
1685
- case 16:
1686
- signatureRes = _context.sent;
1687
- _context.next = 22;
1512
+ case 7:
1513
+ signatureRes = _context.v;
1514
+ _context.n = 9;
1688
1515
  break;
1689
- case 19:
1690
- _context.prev = 19;
1691
- _context.t0 = _context["catch"](13);
1692
- throw new Web3SignatureRejected(_context.t0);
1693
- case 22:
1516
+ case 8:
1517
+ _context.p = 8;
1518
+ _t = _context.v;
1519
+ throw new Web3SignatureRejected(_t);
1520
+ case 9:
1694
1521
  VerifyWalletChallengeRequest = _objectSpread2({
1695
1522
  address: address,
1696
1523
  namespace: wallet.namespace,
@@ -1699,12 +1526,9 @@ var createWeb3AuthAdapter = function createWeb3AuthAdapter(params) {
1699
1526
  res = params.verifyChallenge ? params.verifyChallenge(VerifyWalletChallengeRequest) : identityApiClient.auth.verifyWalletChallenge({
1700
1527
  requestBody: VerifyWalletChallengeRequest
1701
1528
  });
1702
- return _context.abrupt("return", res);
1703
- case 25:
1704
- case "end":
1705
- return _context.stop();
1529
+ return _context.a(2, res);
1706
1530
  }
1707
- }, _callee, null, [[13, 19]]);
1531
+ }, _callee, null, [[6, 8]]);
1708
1532
  }));
1709
1533
  return function login(_x) {
1710
1534
  return _ref.apply(this, arguments);
@@ -1724,23 +1548,20 @@ var createWeb3AuthAdapter = function createWeb3AuthAdapter(params) {
1724
1548
  * @private
1725
1549
  */
1726
1550
  var getSessionData = /*#__PURE__*/function () {
1727
- var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(auth) {
1551
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(auth) {
1728
1552
  var decoded, res;
1729
- return _regeneratorRuntime().wrap(function _callee$(_context) {
1730
- while (1) switch (_context.prev = _context.next) {
1553
+ return _regenerator().w(function (_context) {
1554
+ while (1) switch (_context.n) {
1731
1555
  case 0:
1732
1556
  decoded = jwtDecode(auth.token);
1733
1557
  res = IdentityWidgetAccessToken_NEW.safeParse(decoded);
1734
1558
  if (res.success) {
1735
- _context.next = 4;
1559
+ _context.n = 1;
1736
1560
  break;
1737
1561
  }
1738
1562
  throw new SessionDataIncompleteError(decoded, IdentityWidgetAccessToken_NEW);
1739
- case 4:
1740
- return _context.abrupt("return", res.data);
1741
- case 5:
1742
- case "end":
1743
- return _context.stop();
1563
+ case 1:
1564
+ return _context.a(2, res.data);
1744
1565
  }
1745
1566
  }, _callee);
1746
1567
  }));
@@ -1776,71 +1597,71 @@ var isAuthenticated = function isAuthenticated(config) {
1776
1597
  * @throws {Web3SignatureRejected} if the signature is rejected
1777
1598
  */
1778
1599
  var attachWalletToIdentity = /*#__PURE__*/function () {
1779
- var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(config, options) {
1780
- var authSession, wallet, identityApiClient, address, origin, blockchainId, sessionData, workflowId, challengeRes, signatureRes, walletAddRes, _err$body;
1781
- return _regeneratorRuntime().wrap(function _callee$(_context) {
1782
- while (1) switch (_context.prev = _context.next) {
1600
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(config, options) {
1601
+ var authSession, wallet, identityApiClient, address, origin, blockchainId, sessionData, workflowId, challengeRes, signatureRes, walletAddRes, _err$body, _t, _t2, _t3;
1602
+ return _regenerator().w(function (_context) {
1603
+ while (1) switch (_context.n) {
1783
1604
  case 0:
1784
1605
  if (isAuthenticated(config)) {
1785
- _context.next = 2;
1606
+ _context.n = 1;
1786
1607
  break;
1787
1608
  }
1788
1609
  throw new MustBeLoggedIn(config._internal.logger, "attachWallet");
1789
- case 2:
1610
+ case 1:
1790
1611
  authSession = config._internal.widgetStateStore.select(function (state) {
1791
1612
  return state.auth;
1792
1613
  });
1793
1614
  if (!(authSession === "loading" || authSession === "not_authenticated")) {
1794
- _context.next = 5;
1615
+ _context.n = 2;
1795
1616
  break;
1796
1617
  }
1797
1618
  throw new MustBeLoggedIn(config._internal.logger, "attachWallet");
1798
- case 5:
1619
+ case 2:
1799
1620
  wallet = options.wallet;
1800
1621
  if (wallet) {
1801
- _context.next = 8;
1622
+ _context.n = 3;
1802
1623
  break;
1803
1624
  }
1804
1625
  throw new Web3AuthRequiredForThisAction("attachWallet");
1805
- case 8:
1626
+ case 3:
1806
1627
  // request a challenge to attach the wallet
1807
1628
  identityApiClient = createIdentityApiClient({
1808
1629
  env: getEnv(),
1809
1630
  jwt: authSession.token
1810
1631
  });
1811
- _context.next = 11;
1632
+ _context.n = 4;
1812
1633
  return wallet.getAddress();
1813
- case 11:
1814
- address = _context.sent;
1634
+ case 4:
1635
+ address = _context.v;
1815
1636
  if (address) {
1816
- _context.next = 14;
1637
+ _context.n = 5;
1817
1638
  break;
1818
1639
  }
1819
1640
  throw new AddressUndefinedButRequiredForLogin();
1820
- case 14:
1641
+ case 5:
1821
1642
  origin = getOrigin({
1822
1643
  origin: options.origin
1823
1644
  });
1824
1645
  if (!wallet.getBlockchainId) {
1825
- _context.next = 21;
1646
+ _context.n = 7;
1826
1647
  break;
1827
1648
  }
1828
- _context.next = 18;
1649
+ _context.n = 6;
1829
1650
  return wallet.getBlockchainId();
1830
- case 18:
1831
- _context.t0 = _context.sent;
1832
- _context.next = 22;
1651
+ case 6:
1652
+ _t = _context.v;
1653
+ _context.n = 8;
1833
1654
  break;
1834
- case 21:
1835
- _context.t0 = undefined;
1836
- case 22:
1837
- blockchainId = _context.t0;
1838
- _context.next = 25;
1655
+ case 7:
1656
+ _t = undefined;
1657
+ case 8:
1658
+ blockchainId = _t;
1659
+ _context.n = 9;
1839
1660
  return getSessionData(authSession);
1840
- case 25:
1841
- sessionData = _context.sent;
1661
+ case 9:
1662
+ sessionData = _context.v;
1842
1663
  workflowId = sessionData.workflowId;
1843
- _context.next = 29;
1664
+ _context.n = 10;
1844
1665
  return identityApiClient.identity.createWalletChallengeToAddWallet({
1845
1666
  requestBody: {
1846
1667
  address: address,
@@ -1851,52 +1672,51 @@ var attachWalletToIdentity = /*#__PURE__*/function () {
1851
1672
  workflowId: workflowId
1852
1673
  }
1853
1674
  });
1854
- case 29:
1855
- challengeRes = _context.sent;
1856
- _context.prev = 30;
1857
- _context.next = 33;
1675
+ case 10:
1676
+ challengeRes = _context.v;
1677
+ _context.p = 11;
1678
+ _context.n = 12;
1858
1679
  return wallet.sign({
1859
1680
  message: challengeRes.challenge
1860
1681
  });
1861
- case 33:
1862
- signatureRes = _context.sent;
1863
- _context.next = 39;
1682
+ case 12:
1683
+ signatureRes = _context.v;
1684
+ _context.n = 14;
1864
1685
  break;
1865
- case 36:
1866
- _context.prev = 36;
1867
- _context.t1 = _context["catch"](30);
1868
- throw new Web3SignatureRejected(_context.t1);
1869
- case 39:
1870
- _context.prev = 39;
1871
- _context.next = 42;
1686
+ case 13:
1687
+ _context.p = 13;
1688
+ _t2 = _context.v;
1689
+ throw new Web3SignatureRejected(_t2);
1690
+ case 14:
1691
+ _context.p = 14;
1692
+ _context.n = 15;
1872
1693
  return identityApiClient.identity.addWalletToIdentity({
1873
1694
  requestBody: signatureRes
1874
1695
  });
1875
- case 42:
1876
- walletAddRes = _context.sent;
1877
- return _context.abrupt("return", walletAddRes.success);
1878
- case 46:
1879
- _context.prev = 46;
1880
- _context.t2 = _context["catch"](39);
1881
- if (!(_context.t2 instanceof ApiError &&
1696
+ case 15:
1697
+ walletAddRes = _context.v;
1698
+ return _context.a(2, walletAddRes.success);
1699
+ case 16:
1700
+ _context.p = 16;
1701
+ _t3 = _context.v;
1702
+ if (!(_t3 instanceof ApiError &&
1882
1703
  // TODO: have a better way to check for this error
1883
1704
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
1884
- (_context.t2 === null || _context.t2 === void 0 || (_err$body = _context.t2.body) === null || _err$body === void 0 ? void 0 : _err$body.message) === "Wallet already attached to another identity")) {
1885
- _context.next = 50;
1705
+ (_t3 === null || _t3 === void 0 || (_err$body = _t3.body) === null || _err$body === void 0 ? void 0 : _err$body.message) === "Wallet already attached to another identity")) {
1706
+ _context.n = 17;
1886
1707
  break;
1887
1708
  }
1888
- throw new WalletAlreadyLinkedToAnotherIdentity(config._internal.logger, _context.t2);
1889
- case 50:
1709
+ throw new WalletAlreadyLinkedToAnotherIdentity(config._internal.logger, _t3);
1710
+ case 17:
1890
1711
  config._internal.logger.error({
1891
1712
  msg: "Failed to add wallet to identity",
1892
- err: _context.t2
1713
+ err: _t3
1893
1714
  });
1894
- throw _context.t2;
1895
- case 52:
1896
- case "end":
1897
- return _context.stop();
1715
+ throw _t3;
1716
+ case 18:
1717
+ return _context.a(2);
1898
1718
  }
1899
- }, _callee, null, [[30, 36], [39, 46]]);
1719
+ }, _callee, null, [[14, 16], [11, 13]]);
1900
1720
  }));
1901
1721
  return function attachWalletToIdentity(_x, _x2) {
1902
1722
  return _ref.apply(this, arguments);
@@ -1912,10 +1732,10 @@ var attachWalletToIdentity = /*#__PURE__*/function () {
1912
1732
  * @returns a promise that resolves to true if the user has been successfully authenticated, false otherwise
1913
1733
  */
1914
1734
  var authenticate = /*#__PURE__*/function () {
1915
- var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(config, loginParams) {
1916
- var authAdapter, widgetStateStore, auth, authSession;
1917
- return _regeneratorRuntime().wrap(function _callee$(_context) {
1918
- while (1) switch (_context.prev = _context.next) {
1735
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(config, loginParams) {
1736
+ var authAdapter, widgetStateStore, auth, authSession, _t;
1737
+ return _regenerator().w(function (_context) {
1738
+ while (1) switch (_context.n) {
1919
1739
  case 0:
1920
1740
  authAdapter = config._internal.authAdapter;
1921
1741
  widgetStateStore = config._internal.widgetStateStore;
@@ -1923,46 +1743,46 @@ var authenticate = /*#__PURE__*/function () {
1923
1743
  return state.auth;
1924
1744
  });
1925
1745
  if (!(auth !== "not_authenticated" && auth !== "loading")) {
1926
- _context.next = 5;
1746
+ _context.n = 1;
1927
1747
  break;
1928
1748
  }
1929
- return _context.abrupt("return", true);
1930
- case 5:
1749
+ return _context.a(2, true);
1750
+ case 1:
1931
1751
  if (!(auth === "loading")) {
1932
- _context.next = 7;
1752
+ _context.n = 2;
1933
1753
  break;
1934
1754
  }
1935
- return _context.abrupt("return", false);
1936
- case 7:
1937
- _context.prev = 7;
1755
+ return _context.a(2, false);
1756
+ case 2:
1757
+ _context.p = 2;
1938
1758
  widgetStateStore.update(function (s) {
1939
1759
  return _objectSpread2(_objectSpread2({}, s), {}, {
1940
1760
  auth: "loading"
1941
1761
  });
1942
1762
  });
1943
- _context.next = 11;
1763
+ _context.n = 3;
1944
1764
  return authAdapter.login(loginParams);
1945
- case 11:
1946
- authSession = _context.sent;
1765
+ case 3:
1766
+ authSession = _context.v;
1947
1767
  widgetStateStore.update(function (s) {
1948
1768
  return _objectSpread2(_objectSpread2({}, s), {}, {
1949
1769
  auth: authSession
1950
1770
  });
1951
1771
  });
1952
- return _context.abrupt("return", true);
1953
- case 16:
1954
- _context.prev = 16;
1955
- _context.t0 = _context["catch"](7);
1772
+ return _context.a(2, true);
1773
+ case 4:
1774
+ _context.p = 4;
1775
+ _t = _context.v;
1956
1776
  // log less verbose for signature rejection as it is expected
1957
- if (_context.t0 instanceof Web3SignatureRejected) {
1777
+ if (_t instanceof Web3SignatureRejected) {
1958
1778
  config._internal.logger.debug({
1959
1779
  msg: "User rejected signature request",
1960
- err: _context.t0
1780
+ err: _t
1961
1781
  });
1962
1782
  } else {
1963
1783
  config._internal.logger.error({
1964
1784
  msg: "Failed to authenticate",
1965
- err: _context.t0
1785
+ err: _t
1966
1786
  });
1967
1787
  }
1968
1788
  widgetStateStore.update(function (s) {
@@ -1970,12 +1790,11 @@ var authenticate = /*#__PURE__*/function () {
1970
1790
  auth: "not_authenticated"
1971
1791
  });
1972
1792
  });
1973
- throw _context.t0;
1974
- case 21:
1975
- case "end":
1976
- return _context.stop();
1793
+ throw _t;
1794
+ case 5:
1795
+ return _context.a(2);
1977
1796
  }
1978
- }, _callee, null, [[7, 16]]);
1797
+ }, _callee, null, [[2, 4]]);
1979
1798
  }));
1980
1799
  return function authenticate(_x, _x2) {
1981
1800
  return _ref.apply(this, arguments);
@@ -2016,37 +1835,34 @@ var closeWidget = function closeWidget(config) {
2016
1835
  */
2017
1836
  // eslint-disable-next-line @typescript-eslint/require-await
2018
1837
  var disconnect = /*#__PURE__*/function () {
2019
- var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(config) {
1838
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(config) {
2020
1839
  var widgetStateStore, auth;
2021
- return _regeneratorRuntime().wrap(function _callee$(_context) {
2022
- while (1) switch (_context.prev = _context.next) {
1840
+ return _regenerator().w(function (_context) {
1841
+ while (1) switch (_context.n) {
2023
1842
  case 0:
2024
1843
  widgetStateStore = config._internal.widgetStateStore;
2025
1844
  auth = widgetStateStore.select(function (state) {
2026
1845
  return state.auth;
2027
1846
  });
2028
1847
  if (!(auth === "not_authenticated")) {
2029
- _context.next = 4;
1848
+ _context.n = 1;
2030
1849
  break;
2031
1850
  }
2032
- return _context.abrupt("return", true);
2033
- case 4:
1851
+ return _context.a(2, true);
1852
+ case 1:
2034
1853
  if (!(auth === "loading")) {
2035
- _context.next = 6;
1854
+ _context.n = 2;
2036
1855
  break;
2037
1856
  }
2038
- return _context.abrupt("return", false);
2039
- case 6:
1857
+ return _context.a(2, false);
1858
+ case 2:
2040
1859
  config._internal.iframeHandler.reset();
2041
1860
  widgetStateStore.update(function (s) {
2042
1861
  return _objectSpread2(_objectSpread2({}, s), {}, {
2043
1862
  auth: "not_authenticated"
2044
1863
  });
2045
1864
  });
2046
- return _context.abrupt("return", true);
2047
- case 9:
2048
- case "end":
2049
- return _context.stop();
1865
+ return _context.a(2, true);
2050
1866
  }
2051
1867
  }, _callee);
2052
1868
  }));
@@ -2142,49 +1958,48 @@ var waitForWidgetAppConfigured = function waitForWidgetAppConfigured(config) {
2142
1958
  * @returns the customer status
2143
1959
  */
2144
1960
  var getCustomerStatus = /*#__PURE__*/function () {
2145
- var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(config) {
2146
- var authenticated;
2147
- return _regeneratorRuntime().wrap(function _callee$(_context) {
2148
- while (1) switch (_context.prev = _context.next) {
1961
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(config) {
1962
+ var authenticated, _t;
1963
+ return _regenerator().w(function (_context) {
1964
+ while (1) switch (_context.n) {
2149
1965
  case 0:
2150
- _context.next = 2;
1966
+ _context.n = 1;
2151
1967
  return load(config);
2152
- case 2:
1968
+ case 1:
2153
1969
  authenticated = isAuthenticated(config);
2154
1970
  if (authenticated) {
2155
- _context.next = 5;
1971
+ _context.n = 2;
2156
1972
  break;
2157
1973
  }
2158
- return _context.abrupt("return", null);
2159
- case 5:
2160
- _context.prev = 5;
2161
- _context.next = 8;
1974
+ return _context.a(2, null);
1975
+ case 2:
1976
+ _context.p = 2;
1977
+ _context.n = 3;
2162
1978
  return waitForWidgetAppConfigured(config);
2163
- case 8:
2164
- _context.next = 10;
1979
+ case 3:
1980
+ _context.n = 4;
2165
1981
  return config._internal.iframeHandler.postMessage({
2166
1982
  type: "getCustomerStatusRequest"
2167
1983
  });
2168
- case 10:
2169
- return _context.abrupt("return", new Promise(function (resolve) {
1984
+ case 4:
1985
+ return _context.a(2, new Promise(function (resolve) {
2170
1986
  return config._internal.externalEventEmitter.once("getCustomerStatusResponse", function (_ref2) {
2171
1987
  var status = _ref2.status;
2172
1988
  return resolve(status);
2173
1989
  });
2174
1990
  }));
2175
- case 13:
2176
- _context.prev = 13;
2177
- _context.t0 = _context["catch"](5);
1991
+ case 5:
1992
+ _context.p = 5;
1993
+ _t = _context.v;
2178
1994
  config._internal.logger.error({
2179
1995
  msg: "Failed to fetch user status",
2180
- err: _context.t0
1996
+ err: _t
2181
1997
  });
2182
- throw _context.t0;
2183
- case 17:
2184
- case "end":
2185
- return _context.stop();
1998
+ throw _t;
1999
+ case 6:
2000
+ return _context.a(2);
2186
2001
  }
2187
- }, _callee, null, [[5, 13]]);
2002
+ }, _callee, null, [[2, 5]]);
2188
2003
  }));
2189
2004
  return function getCustomerStatus(_x) {
2190
2005
  return _ref.apply(this, arguments);
@@ -2200,34 +2015,31 @@ var getCustomerStatus = /*#__PURE__*/function () {
2200
2015
  * @throws {MustBeLoggedIn} if the user is not logged in
2201
2016
  */
2202
2017
  var getIdentityId = /*#__PURE__*/function () {
2203
- var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(config) {
2018
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(config) {
2204
2019
  var authSession, sessionData;
2205
- return _regeneratorRuntime().wrap(function _callee$(_context) {
2206
- while (1) switch (_context.prev = _context.next) {
2020
+ return _regenerator().w(function (_context) {
2021
+ while (1) switch (_context.n) {
2207
2022
  case 0:
2208
2023
  if (isAuthenticated(config)) {
2209
- _context.next = 2;
2024
+ _context.n = 1;
2210
2025
  break;
2211
2026
  }
2212
2027
  throw new MustBeLoggedIn(config._internal.logger, "attachWallet");
2213
- case 2:
2028
+ case 1:
2214
2029
  authSession = config._internal.widgetStateStore.select(function (state) {
2215
2030
  return state.auth;
2216
2031
  });
2217
2032
  if (!(authSession === "loading" || authSession === "not_authenticated")) {
2218
- _context.next = 5;
2033
+ _context.n = 2;
2219
2034
  break;
2220
2035
  }
2221
2036
  throw new MustBeLoggedIn(config._internal.logger, "attachWallet");
2222
- case 5:
2223
- _context.next = 7;
2037
+ case 2:
2038
+ _context.n = 3;
2224
2039
  return getSessionData(authSession);
2225
- case 7:
2226
- sessionData = _context.sent;
2227
- return _context.abrupt("return", sessionData.sub);
2228
- case 9:
2229
- case "end":
2230
- return _context.stop();
2040
+ case 3:
2041
+ sessionData = _context.v;
2042
+ return _context.a(2, sessionData.sub);
2231
2043
  }
2232
2044
  }, _callee);
2233
2045
  }));
@@ -2245,38 +2057,35 @@ var getIdentityId = /*#__PURE__*/function () {
2245
2057
  * @throws {MustBeLoggedIn} if the user is not logged in
2246
2058
  */
2247
2059
  var getIdentityWallets = /*#__PURE__*/function () {
2248
- var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(config) {
2060
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(config) {
2249
2061
  var authSession, identityApiClient, wallets;
2250
- return _regeneratorRuntime().wrap(function _callee$(_context) {
2251
- while (1) switch (_context.prev = _context.next) {
2062
+ return _regenerator().w(function (_context) {
2063
+ while (1) switch (_context.n) {
2252
2064
  case 0:
2253
2065
  if (isAuthenticated(config)) {
2254
- _context.next = 2;
2066
+ _context.n = 1;
2255
2067
  break;
2256
2068
  }
2257
2069
  throw new MustBeLoggedIn(config._internal.logger, "attachWallet");
2258
- case 2:
2070
+ case 1:
2259
2071
  authSession = config._internal.widgetStateStore.select(function (state) {
2260
2072
  return state.auth;
2261
2073
  });
2262
2074
  if (!(authSession === "loading" || authSession === "not_authenticated")) {
2263
- _context.next = 5;
2075
+ _context.n = 2;
2264
2076
  break;
2265
2077
  }
2266
2078
  throw new MustBeLoggedIn(config._internal.logger, "attachWallet");
2267
- case 5:
2079
+ case 2:
2268
2080
  identityApiClient = createIdentityApiClient({
2269
2081
  env: getEnv(),
2270
2082
  jwt: authSession.token
2271
2083
  });
2272
- _context.next = 8;
2084
+ _context.n = 3;
2273
2085
  return identityApiClient.identity.listWallets();
2274
- case 8:
2275
- wallets = _context.sent;
2276
- return _context.abrupt("return", wallets.wallets);
2277
- case 10:
2278
- case "end":
2279
- return _context.stop();
2086
+ case 3:
2087
+ wallets = _context.v;
2088
+ return _context.a(2, wallets.wallets);
2280
2089
  }
2281
2090
  }, _callee);
2282
2091
  }));
@@ -2286,7 +2095,7 @@ var getIdentityWallets = /*#__PURE__*/function () {
2286
2095
  }();
2287
2096
 
2288
2097
  var getTxAuthDataSignature = /*#__PURE__*/function () {
2289
- var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(
2098
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(
2290
2099
  /**
2291
2100
  * Request ComPilot to sign the user transaction data with Compilot's signer private key.
2292
2101
  * This is the action that should be used to handle signature gating.
@@ -2297,33 +2106,33 @@ var getTxAuthDataSignature = /*#__PURE__*/function () {
2297
2106
  * @returns a promise that resolves to the signed transaction data response.
2298
2107
  */
2299
2108
  config, input) {
2300
- var authenticated;
2301
- return _regeneratorRuntime().wrap(function _callee$(_context) {
2302
- while (1) switch (_context.prev = _context.next) {
2109
+ var authenticated, _t;
2110
+ return _regenerator().w(function (_context) {
2111
+ while (1) switch (_context.n) {
2303
2112
  case 0:
2304
- _context.next = 2;
2113
+ _context.n = 1;
2305
2114
  return load(config);
2306
- case 2:
2115
+ case 1:
2307
2116
  authenticated = isAuthenticated(config);
2308
2117
  if (authenticated) {
2309
- _context.next = 5;
2118
+ _context.n = 2;
2310
2119
  break;
2311
2120
  }
2312
2121
  throw new Error("Not authenticated, cannot sign transaction data");
2313
- case 5:
2314
- _context.prev = 5;
2315
- _context.next = 8;
2122
+ case 2:
2123
+ _context.p = 2;
2124
+ _context.n = 3;
2316
2125
  return waitForWidgetAppConfigured(config);
2317
- case 8:
2318
- _context.next = 10;
2126
+ case 3:
2127
+ _context.n = 4;
2319
2128
  return config._internal.iframeHandler.postMessage({
2320
2129
  type: "txAuthDataSignatureGatingRequest",
2321
2130
  data: {
2322
2131
  input: input
2323
2132
  }
2324
2133
  });
2325
- case 10:
2326
- return _context.abrupt("return", new Promise(function (resolve, reject) {
2134
+ case 4:
2135
+ return _context.a(2, new Promise(function (resolve, reject) {
2327
2136
  var responseUnwatch = config._internal.externalEventEmitter.once("txAuthDataSignatureResponse", function (response) {
2328
2137
  unwatch();
2329
2138
  // the API will respond code 200 + error if the contract is not registered or not in the project
@@ -2361,19 +2170,18 @@ var getTxAuthDataSignature = /*#__PURE__*/function () {
2361
2170
  errorUnwatch();
2362
2171
  };
2363
2172
  }));
2364
- case 13:
2365
- _context.prev = 13;
2366
- _context.t0 = _context["catch"](5);
2173
+ case 5:
2174
+ _context.p = 5;
2175
+ _t = _context.v;
2367
2176
  config._internal.logger.error({
2368
2177
  msg: "Failed to sign transaction data",
2369
- err: _context.t0
2178
+ err: _t
2370
2179
  });
2371
- throw _context.t0;
2372
- case 17:
2373
- case "end":
2374
- return _context.stop();
2180
+ throw _t;
2181
+ case 6:
2182
+ return _context.a(2);
2375
2183
  }
2376
- }, _callee, null, [[5, 13]]);
2184
+ }, _callee, null, [[2, 5]]);
2377
2185
  }));
2378
2186
  return function getTxAuthDataSignature(_x, _x2) {
2379
2187
  return _ref.apply(this, arguments);
@@ -2426,48 +2234,47 @@ var isWidgetAppLoaded = function isWidgetAppLoaded(config) {
2426
2234
  * @returns A promise that resolves when the widget is open
2427
2235
  */
2428
2236
  var openWidget = /*#__PURE__*/function () {
2429
- var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(config, loginParams) {
2430
- var authenticated;
2431
- return _regeneratorRuntime().wrap(function _callee$(_context) {
2432
- while (1) switch (_context.prev = _context.next) {
2237
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(config, loginParams) {
2238
+ var authenticated, _t;
2239
+ return _regenerator().w(function (_context) {
2240
+ while (1) switch (_context.n) {
2433
2241
  case 0:
2434
- _context.next = 2;
2242
+ _context.n = 1;
2435
2243
  return load(config);
2436
- case 2:
2437
- _context.prev = 2;
2438
- _context.next = 5;
2244
+ case 1:
2245
+ _context.p = 1;
2246
+ _context.n = 2;
2439
2247
  return authenticate(config, loginParams);
2440
- case 5:
2441
- authenticated = _context.sent;
2248
+ case 2:
2249
+ authenticated = _context.v;
2442
2250
  if (!(authenticated && !isOpen(config))) {
2443
- _context.next = 9;
2251
+ _context.n = 3;
2444
2252
  break;
2445
2253
  }
2446
- _context.next = 9;
2254
+ _context.n = 3;
2447
2255
  return config._internal.iframeHandler.show();
2448
- case 9:
2449
- return _context.abrupt("return", true);
2450
- case 12:
2451
- _context.prev = 12;
2452
- _context.t0 = _context["catch"](2);
2256
+ case 3:
2257
+ return _context.a(2, true);
2258
+ case 4:
2259
+ _context.p = 4;
2260
+ _t = _context.v;
2453
2261
  // log less verbose for signature rejection as it is expected
2454
- if (_context.t0 instanceof Web3SignatureRejected) {
2262
+ if (_t instanceof Web3SignatureRejected) {
2455
2263
  config._internal.logger.debug({
2456
2264
  msg: "User rejected signature request",
2457
- err: _context.t0
2265
+ err: _t
2458
2266
  });
2459
2267
  } else {
2460
2268
  config._internal.logger.error({
2461
2269
  msg: "Failed to authenticate",
2462
- err: _context.t0
2270
+ err: _t
2463
2271
  });
2464
2272
  }
2465
- throw _context.t0;
2466
- case 16:
2467
- case "end":
2468
- return _context.stop();
2273
+ throw _t;
2274
+ case 5:
2275
+ return _context.a(2);
2469
2276
  }
2470
- }, _callee, null, [[2, 12]]);
2277
+ }, _callee, null, [[1, 4]]);
2471
2278
  }));
2472
2279
  return function openWidget(_x, _x2) {
2473
2280
  return _ref.apply(this, arguments);
@@ -2482,21 +2289,20 @@ var openWidget = /*#__PURE__*/function () {
2482
2289
  * @param adapter the auth adapter to use
2483
2290
  */
2484
2291
  var setAuthAdapter = /*#__PURE__*/function () {
2485
- var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(config, adapter) {
2486
- return _regeneratorRuntime().wrap(function _callee$(_context) {
2487
- while (1) switch (_context.prev = _context.next) {
2292
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(config, adapter) {
2293
+ return _regenerator().w(function (_context) {
2294
+ while (1) switch (_context.n) {
2488
2295
  case 0:
2489
2296
  if (!isAuthenticated(config)) {
2490
- _context.next = 3;
2297
+ _context.n = 1;
2491
2298
  break;
2492
2299
  }
2493
- _context.next = 3;
2300
+ _context.n = 1;
2494
2301
  return disconnect(config);
2495
- case 3:
2302
+ case 1:
2496
2303
  config._internal.authAdapter = adapter;
2497
- case 4:
2498
- case "end":
2499
- return _context.stop();
2304
+ case 2:
2305
+ return _context.a(2);
2500
2306
  }
2501
2307
  }, _callee);
2502
2308
  }));
@@ -2539,39 +2345,38 @@ var waitForWidgetAppLoaded = function waitForWidgetAppLoaded(config) {
2539
2345
  * @param adapter the auth adapter to use
2540
2346
  */
2541
2347
  var setAuthSession = /*#__PURE__*/function () {
2542
- var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(config, session) {
2543
- return _regeneratorRuntime().wrap(function _callee$(_context) {
2544
- while (1) switch (_context.prev = _context.next) {
2348
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(config, session) {
2349
+ return _regenerator().w(function (_context) {
2350
+ while (1) switch (_context.n) {
2545
2351
  case 0:
2546
- _context.next = 2;
2352
+ _context.n = 1;
2547
2353
  return waitForWidgetAppLoaded(config);
2548
- case 2:
2354
+ case 1:
2549
2355
  if (!isAuthenticated(config)) {
2550
- _context.next = 5;
2356
+ _context.n = 2;
2551
2357
  break;
2552
2358
  }
2553
- _context.next = 5;
2359
+ _context.n = 2;
2554
2360
  return disconnect(config);
2555
- case 5:
2361
+ case 2:
2556
2362
  if (!isAuthSessionExpired(session)) {
2557
- _context.next = 8;
2363
+ _context.n = 3;
2558
2364
  break;
2559
2365
  }
2560
2366
  config._internal.logger.warn({
2561
2367
  message: "Session is expired, ignoring",
2562
2368
  session: session
2563
2369
  });
2564
- return _context.abrupt("return");
2565
- case 8:
2370
+ return _context.a(2);
2371
+ case 3:
2566
2372
  // set the auth session, the config should be propagated by the createConfig code
2567
2373
  config._internal.widgetStateStore.update(function (state) {
2568
2374
  return _objectSpread2(_objectSpread2({}, state), {}, {
2569
2375
  auth: session
2570
2376
  });
2571
2377
  });
2572
- case 9:
2573
- case "end":
2574
- return _context.stop();
2378
+ case 4:
2379
+ return _context.a(2);
2575
2380
  }
2576
2381
  }, _callee);
2577
2382
  }));