@octostar/platform-api 0.5.18 → 0.5.20

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.
@@ -6684,7 +6684,7 @@ var forwardCallsToFutureObject = exports.forwardCallsToFutureObject = function f
6684
6684
  });
6685
6685
  };
6686
6686
 
6687
- },{"./constants":33,"./utils":45,"post-robot":5}],35:[function(require,module,exports){
6687
+ },{"./constants":33,"./utils":44,"post-robot":5}],35:[function(require,module,exports){
6688
6688
  "use strict";
6689
6689
 
6690
6690
  Object.defineProperty(exports, "__esModule", {
@@ -6800,30 +6800,19 @@ Object.keys(_userWorkspace).forEach(function (key) {
6800
6800
  }
6801
6801
  });
6802
6802
  });
6803
- var _ContextAPI = require("./lib/ContextAPI");
6804
- Object.keys(_ContextAPI).forEach(function (key) {
6803
+ var _LiveContextAPI = require("./lib/LiveContextAPI");
6804
+ Object.keys(_LiveContextAPI).forEach(function (key) {
6805
6805
  if (key === "default" || key === "__esModule") return;
6806
- if (key in exports && exports[key] === _ContextAPI[key]) return;
6806
+ if (key in exports && exports[key] === _LiveContextAPI[key]) return;
6807
6807
  Object.defineProperty(exports, key, {
6808
6808
  enumerable: true,
6809
6809
  get: function get() {
6810
- return _ContextAPI[key];
6811
- }
6812
- });
6813
- });
6814
- var _classInstanceToObject = require("./lib/classInstanceToObject");
6815
- Object.keys(_classInstanceToObject).forEach(function (key) {
6816
- if (key === "default" || key === "__esModule") return;
6817
- if (key in exports && exports[key] === _classInstanceToObject[key]) return;
6818
- Object.defineProperty(exports, key, {
6819
- enumerable: true,
6820
- get: function get() {
6821
- return _classInstanceToObject[key];
6810
+ return _LiveContextAPI[key];
6822
6811
  }
6823
6812
  });
6824
6813
  });
6825
6814
 
6826
- },{"./apis":22,"./components":32,"./constants":33,"./lib/AIClientImpl":36,"./lib/ContextAPI":38,"./lib/JWTProvider":39,"./lib/Proxy":40,"./lib/classInstanceToObject":41,"./lib/userWorkspace":42,"./permissions":43,"./types":44,"./utils":45}],36:[function(require,module,exports){
6815
+ },{"./apis":22,"./components":32,"./constants":33,"./lib/AIClientImpl":36,"./lib/JWTProvider":38,"./lib/LiveContextAPI":39,"./lib/Proxy":40,"./lib/userWorkspace":41,"./permissions":42,"./types":43,"./utils":44}],36:[function(require,module,exports){
6827
6816
  "use strict";
6828
6817
 
6829
6818
  Object.defineProperty(exports, "__esModule", {
@@ -7076,51 +7065,225 @@ AsyncServiceLocator.instances = {};
7076
7065
  Object.defineProperty(exports, "__esModule", {
7077
7066
  value: true
7078
7067
  });
7079
- exports.ContextAPI = void 0;
7068
+ exports.JWTProvider = void 0;
7069
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
7070
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return r; }; var t, r = {}, e = Object.prototype, n = e.hasOwnProperty, o = "function" == typeof Symbol ? Symbol : {}, i = o.iterator || "@@iterator", a = o.asyncIterator || "@@asyncIterator", u = o.toStringTag || "@@toStringTag"; function c(t, r, e, n) { return Object.defineProperty(t, r, { value: e, enumerable: !n, configurable: !n, writable: !n }); } try { c({}, ""); } catch (t) { c = function c(t, r, e) { return t[r] = e; }; } function h(r, e, n, o) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype); return c(a, "_invoke", function (r, e, n) { var o = 1; return function (i, a) { if (3 === o) throw Error("Generator is already running"); if (4 === o) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var u = n.delegate; if (u) { var c = d(u, n); if (c) { if (c === f) continue; return c; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (1 === o) throw o = 4, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = 3; var h = s(r, e, n); if ("normal" === h.type) { if (o = n.done ? 4 : 2, h.arg === f) continue; return { value: h.arg, done: n.done }; } "throw" === h.type && (o = 4, n.method = "throw", n.arg = h.arg); } }; }(r, n, new Context(o || [])), !0), a; } function s(t, r, e) { try { return { type: "normal", arg: t.call(r, e) }; } catch (t) { return { type: "throw", arg: t }; } } r.wrap = h; var f = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var l = {}; c(l, i, function () { return this; }); var p = Object.getPrototypeOf, y = p && p(p(x([]))); y && y !== e && n.call(y, i) && (l = y); var v = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(l); function g(t) { ["next", "throw", "return"].forEach(function (r) { c(t, r, function (t) { return this._invoke(r, t); }); }); } function AsyncIterator(t, r) { function e(o, i, a, u) { var c = s(t[o], t, i); if ("throw" !== c.type) { var h = c.arg, f = h.value; return f && "object" == _typeof(f) && n.call(f, "__await") ? r.resolve(f.__await).then(function (t) { e("next", t, a, u); }, function (t) { e("throw", t, a, u); }) : r.resolve(f).then(function (t) { h.value = t, a(h); }, function (t) { return e("throw", t, a, u); }); } u(c.arg); } var o; c(this, "_invoke", function (t, n) { function i() { return new r(function (r, o) { e(t, n, r, o); }); } return o = o ? o.then(i, i) : i(); }, !0); } function d(r, e) { var n = e.method, o = r.i[n]; 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; var i = s(o, r.i, e.arg); if ("throw" === i.type) return e.method = "throw", e.arg = i.arg, e.delegate = null, f; var a = i.arg; 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); } function w(t) { this.tryEntries.push(t); } function m(r) { var e = r[4] || {}; e.type = "normal", e.arg = t, r[4] = e; } function Context(t) { this.tryEntries = [[-1]], t.forEach(w, this), this.reset(!0); } function x(r) { if (null != r) { var e = r[i]; if (e) return e.call(r); if ("function" == typeof r.next) return r; if (!isNaN(r.length)) { var o = -1, a = function e() { for (; ++o < r.length;) if (n.call(r, o)) return e.value = r[o], e.done = !1, e; return e.value = t, e.done = !0, e; }; return a.next = a; } } throw new TypeError(_typeof(r) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, c(v, "constructor", GeneratorFunctionPrototype), c(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = c(GeneratorFunctionPrototype, u, "GeneratorFunction"), r.isGeneratorFunction = function (t) { var r = "function" == typeof t && t.constructor; return !!r && (r === GeneratorFunction || "GeneratorFunction" === (r.displayName || r.name)); }, r.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, c(t, u, "GeneratorFunction")), t.prototype = Object.create(v), t; }, r.awrap = function (t) { return { __await: t }; }, g(AsyncIterator.prototype), c(AsyncIterator.prototype, a, function () { return this; }), r.AsyncIterator = AsyncIterator, r.async = function (t, e, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(h(t, e, n, o), i); return r.isGeneratorFunction(e) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, g(v), c(v, u, "Generator"), c(v, i, function () { return this; }), c(v, "toString", function () { return "[object Generator]"; }), r.keys = function (t) { var r = Object(t), e = []; for (var n in r) e.unshift(n); return function t() { for (; e.length;) if ((n = e.pop()) in r) return t.value = n, t.done = !1, t; return t.done = !0, t; }; }, r.values = x, Context.prototype = { constructor: Context, reset: function reset(r) { 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); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0][4]; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(r) { if (this.done) throw r; var e = this; function n(t) { a.type = "throw", a.arg = r, e.next = t; } for (var o = e.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i[4], u = this.prev, c = i[1], h = i[2]; if (-1 === i[0]) return n("end"), !1; if (!c && !h) throw Error("try statement without catch or finally"); if (null != i[0] && i[0] <= u) { if (u < c) return this.method = "next", this.arg = t, n(c), !0; if (u < h) return n(h), !1; } } }, abrupt: function abrupt(t, r) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var n = this.tryEntries[e]; if (n[0] > -1 && n[0] <= this.prev && this.prev < n[2]) { var o = n; break; } } o && ("break" === t || "continue" === t) && o[0] <= r && r <= o[2] && (o = null); var i = o ? o[4] : {}; return i.type = t, i.arg = r, o ? (this.method = "next", this.next = o[2], f) : this.complete(i); }, complete: function complete(t, r) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && r && (this.next = r), f; }, finish: function finish(t) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var e = this.tryEntries[r]; if (e[2] === t) return this.complete(e[4], e[3]), m(e), f; } }, "catch": function _catch(t) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var e = this.tryEntries[r]; if (e[0] === t) { var n = e[4]; if ("throw" === n.type) { var o = n.arg; m(e); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(r, e, n) { return this.delegate = { i: x(r), r: e, n: n }, "next" === this.method && (this.arg = t), f; } }, r; }
7071
+ function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
7072
+ function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
7073
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
7074
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
7075
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
7076
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
7077
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7078
+ var JWTProvider = exports.JWTProvider = /*#__PURE__*/function () {
7079
+ function JWTProvider(tokenProvider) {
7080
+ var expiresThreshold = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 300;
7081
+ _classCallCheck(this, JWTProvider);
7082
+ this.token = null;
7083
+ this.decoded = null;
7084
+ this.tokenProvider = tokenProvider;
7085
+ this.expiresThreshold = expiresThreshold;
7086
+ }
7087
+ return _createClass(JWTProvider, [{
7088
+ key: "fetchToken",
7089
+ value: function () {
7090
+ var _fetchToken = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
7091
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
7092
+ while (1) switch (_context.prev = _context.next) {
7093
+ case 0:
7094
+ _context.next = 2;
7095
+ return this.tokenProvider.getToken();
7096
+ case 2:
7097
+ this.token = _context.sent;
7098
+ this.decoded = JSON.parse(atob(this.token.split('.')[1])); // Decode the payload
7099
+ case 4:
7100
+ case "end":
7101
+ return _context.stop();
7102
+ }
7103
+ }, _callee, this);
7104
+ }));
7105
+ function fetchToken() {
7106
+ return _fetchToken.apply(this, arguments);
7107
+ }
7108
+ return fetchToken;
7109
+ }()
7110
+ }, {
7111
+ key: "isExpiredOrExpiringSoon",
7112
+ value: function isExpiredOrExpiringSoon() {
7113
+ if (!this.decoded || !this.decoded.exp) {
7114
+ return true; // Treat as expired if there's no expiration time
7115
+ }
7116
+ var currentTime = Math.floor(Date.now() / 1000);
7117
+ return this.decoded.exp < currentTime + this.expiresThreshold;
7118
+ }
7119
+ }, {
7120
+ key: "getToken",
7121
+ value: function () {
7122
+ var _getToken = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
7123
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
7124
+ while (1) switch (_context2.prev = _context2.next) {
7125
+ case 0:
7126
+ if (!(!this.token || this.isExpiredOrExpiringSoon())) {
7127
+ _context2.next = 3;
7128
+ break;
7129
+ }
7130
+ _context2.next = 3;
7131
+ return this.fetchToken();
7132
+ case 3:
7133
+ return _context2.abrupt("return", this.token);
7134
+ case 4:
7135
+ case "end":
7136
+ return _context2.stop();
7137
+ }
7138
+ }, _callee2, this);
7139
+ }));
7140
+ function getToken() {
7141
+ return _getToken.apply(this, arguments);
7142
+ }
7143
+ return getToken;
7144
+ }()
7145
+ }]);
7146
+ }();
7147
+
7148
+ },{}],39:[function(require,module,exports){
7149
+ "use strict";
7150
+
7151
+ Object.defineProperty(exports, "__esModule", {
7152
+ value: true
7153
+ });
7154
+ exports.LiveContextAPI = void 0;
7080
7155
  var _uuid = require("uuid");
7081
7156
  var postRobot = _interopRequireWildcard(require("post-robot"));
7082
7157
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
7083
7158
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
7159
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return r; }; var t, r = {}, e = Object.prototype, n = e.hasOwnProperty, o = "function" == typeof Symbol ? Symbol : {}, i = o.iterator || "@@iterator", a = o.asyncIterator || "@@asyncIterator", u = o.toStringTag || "@@toStringTag"; function c(t, r, e, n) { return Object.defineProperty(t, r, { value: e, enumerable: !n, configurable: !n, writable: !n }); } try { c({}, ""); } catch (t) { c = function c(t, r, e) { return t[r] = e; }; } function h(r, e, n, o) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype); return c(a, "_invoke", function (r, e, n) { var o = 1; return function (i, a) { if (3 === o) throw Error("Generator is already running"); if (4 === o) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var u = n.delegate; if (u) { var c = d(u, n); if (c) { if (c === f) continue; return c; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (1 === o) throw o = 4, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = 3; var h = s(r, e, n); if ("normal" === h.type) { if (o = n.done ? 4 : 2, h.arg === f) continue; return { value: h.arg, done: n.done }; } "throw" === h.type && (o = 4, n.method = "throw", n.arg = h.arg); } }; }(r, n, new Context(o || [])), !0), a; } function s(t, r, e) { try { return { type: "normal", arg: t.call(r, e) }; } catch (t) { return { type: "throw", arg: t }; } } r.wrap = h; var f = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var l = {}; c(l, i, function () { return this; }); var p = Object.getPrototypeOf, y = p && p(p(x([]))); y && y !== e && n.call(y, i) && (l = y); var v = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(l); function g(t) { ["next", "throw", "return"].forEach(function (r) { c(t, r, function (t) { return this._invoke(r, t); }); }); } function AsyncIterator(t, r) { function e(o, i, a, u) { var c = s(t[o], t, i); if ("throw" !== c.type) { var h = c.arg, f = h.value; return f && "object" == _typeof(f) && n.call(f, "__await") ? r.resolve(f.__await).then(function (t) { e("next", t, a, u); }, function (t) { e("throw", t, a, u); }) : r.resolve(f).then(function (t) { h.value = t, a(h); }, function (t) { return e("throw", t, a, u); }); } u(c.arg); } var o; c(this, "_invoke", function (t, n) { function i() { return new r(function (r, o) { e(t, n, r, o); }); } return o = o ? o.then(i, i) : i(); }, !0); } function d(r, e) { var n = e.method, o = r.i[n]; 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; var i = s(o, r.i, e.arg); if ("throw" === i.type) return e.method = "throw", e.arg = i.arg, e.delegate = null, f; var a = i.arg; 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); } function w(t) { this.tryEntries.push(t); } function m(r) { var e = r[4] || {}; e.type = "normal", e.arg = t, r[4] = e; } function Context(t) { this.tryEntries = [[-1]], t.forEach(w, this), this.reset(!0); } function x(r) { if (null != r) { var e = r[i]; if (e) return e.call(r); if ("function" == typeof r.next) return r; if (!isNaN(r.length)) { var o = -1, a = function e() { for (; ++o < r.length;) if (n.call(r, o)) return e.value = r[o], e.done = !1, e; return e.value = t, e.done = !0, e; }; return a.next = a; } } throw new TypeError(_typeof(r) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, c(v, "constructor", GeneratorFunctionPrototype), c(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = c(GeneratorFunctionPrototype, u, "GeneratorFunction"), r.isGeneratorFunction = function (t) { var r = "function" == typeof t && t.constructor; return !!r && (r === GeneratorFunction || "GeneratorFunction" === (r.displayName || r.name)); }, r.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, c(t, u, "GeneratorFunction")), t.prototype = Object.create(v), t; }, r.awrap = function (t) { return { __await: t }; }, g(AsyncIterator.prototype), c(AsyncIterator.prototype, a, function () { return this; }), r.AsyncIterator = AsyncIterator, r.async = function (t, e, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(h(t, e, n, o), i); return r.isGeneratorFunction(e) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, g(v), c(v, u, "Generator"), c(v, i, function () { return this; }), c(v, "toString", function () { return "[object Generator]"; }), r.keys = function (t) { var r = Object(t), e = []; for (var n in r) e.unshift(n); return function t() { for (; e.length;) if ((n = e.pop()) in r) return t.value = n, t.done = !1, t; return t.done = !0, t; }; }, r.values = x, Context.prototype = { constructor: Context, reset: function reset(r) { 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); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0][4]; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(r) { if (this.done) throw r; var e = this; function n(t) { a.type = "throw", a.arg = r, e.next = t; } for (var o = e.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i[4], u = this.prev, c = i[1], h = i[2]; if (-1 === i[0]) return n("end"), !1; if (!c && !h) throw Error("try statement without catch or finally"); if (null != i[0] && i[0] <= u) { if (u < c) return this.method = "next", this.arg = t, n(c), !0; if (u < h) return n(h), !1; } } }, abrupt: function abrupt(t, r) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var n = this.tryEntries[e]; if (n[0] > -1 && n[0] <= this.prev && this.prev < n[2]) { var o = n; break; } } o && ("break" === t || "continue" === t) && o[0] <= r && r <= o[2] && (o = null); var i = o ? o[4] : {}; return i.type = t, i.arg = r, o ? (this.method = "next", this.next = o[2], f) : this.complete(i); }, complete: function complete(t, r) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && r && (this.next = r), f; }, finish: function finish(t) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var e = this.tryEntries[r]; if (e[2] === t) return this.complete(e[4], e[3]), m(e), f; } }, "catch": function _catch(t) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var e = this.tryEntries[r]; if (e[0] === t) { var n = e[4]; if ("throw" === n.type) { var o = n.arg; m(e); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(r, e, n) { return this.delegate = { i: x(r), r: e, n: n }, "next" === this.method && (this.arg = t), f; } }, r; }
7084
7160
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
7085
7161
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7086
7162
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
7163
+ function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
7164
+ function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
7087
7165
  function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
7088
7166
  function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
7089
7167
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
7090
7168
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
7091
7169
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7092
7170
  var CONTEXT_UPDATE_EVENT = 'context-update';
7093
- var ContextAPI = exports.ContextAPI = /*#__PURE__*/function () {
7094
- function ContextAPI(contextData) {
7171
+ var LiveContextAPI = exports.LiveContextAPI = /*#__PURE__*/function () {
7172
+ function LiveContextAPI(contextData) {
7095
7173
  var _window$frameElement;
7096
- _classCallCheck(this, ContextAPI);
7174
+ _classCallCheck(this, LiveContextAPI);
7097
7175
  this.listeners = {};
7098
7176
  this.iframeChannelAttr = 'data-octostar-iframe-channel';
7177
+ this.id = (0, _uuid.v4)();
7099
7178
  this.contextData = contextData;
7100
7179
  var iframeChannelId = (_window$frameElement = window.frameElement) === null || _window$frameElement === void 0 ? void 0 : _window$frameElement.getAttribute(this.iframeChannelAttr);
7101
7180
  this.channelId = iframeChannelId || (0, _uuid.v4)();
7102
7181
  this.type = iframeChannelId ? 'iframe' : 'parent';
7103
7182
  }
7104
- return _createClass(ContextAPI, [{
7105
- key: "getTargetWindow",
7106
- value: function getTargetWindow() {
7107
- var _document$querySelect;
7108
- if (this.type === 'iframe') {
7109
- return window.top;
7183
+ return _createClass(LiveContextAPI, [{
7184
+ key: "connectPostRobot",
7185
+ value: function () {
7186
+ var _connectPostRobot = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
7187
+ var _this = this;
7188
+ var targetWindow, postRobotEventName;
7189
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
7190
+ while (1) switch (_context.prev = _context.next) {
7191
+ case 0:
7192
+ _context.next = 2;
7193
+ return this.getTargetWindow();
7194
+ case 2:
7195
+ targetWindow = _context.sent;
7196
+ postRobotEventName = this.getPostRobotEventName(this.channelId);
7197
+ this.postRobotListener = postRobot.on(postRobotEventName, {
7198
+ window: targetWindow
7199
+ }, function (event) {
7200
+ if (event.data.type === 'init') {
7201
+ _this.setContext(function (context) {
7202
+ return _objectSpread(_objectSpread({}, context), event.data.context);
7203
+ });
7204
+ } else {
7205
+ _this.setContextAndNotify(function (context) {
7206
+ return _objectSpread(_objectSpread({}, context), event.data.context);
7207
+ });
7208
+ }
7209
+ return Promise.resolve();
7210
+ });
7211
+ _context.next = 7;
7212
+ return this.sendContextUpdate(true);
7213
+ case 7:
7214
+ case "end":
7215
+ return _context.stop();
7216
+ }
7217
+ }, _callee, this);
7218
+ }));
7219
+ function connectPostRobot() {
7220
+ return _connectPostRobot.apply(this, arguments);
7110
7221
  }
7111
- return ((_document$querySelect = document.querySelector("iframe[".concat(this.iframeChannelAttr, "='").concat(this.channelId, "']"))) === null || _document$querySelect === void 0 ? void 0 : _document$querySelect.contentWindow) || undefined;
7222
+ return connectPostRobot;
7223
+ }()
7224
+ }, {
7225
+ key: "getConnectId",
7226
+ value: function getConnectId(contextAPI) {
7227
+ return "ContextAPI-".concat(contextAPI.id);
7112
7228
  }
7229
+ }, {
7230
+ key: "getTargetWindow",
7231
+ value: function () {
7232
+ var _getTargetWindow = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
7233
+ var _this2 = this;
7234
+ var iframe;
7235
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
7236
+ while (1) switch (_context2.prev = _context2.next) {
7237
+ case 0:
7238
+ if (!(this.type === 'iframe' && window.top)) {
7239
+ _context2.next = 2;
7240
+ break;
7241
+ }
7242
+ return _context2.abrupt("return", window.top);
7243
+ case 2:
7244
+ iframe = document.querySelector("iframe[".concat(this.iframeChannelAttr, "='").concat(this.channelId, "']"));
7245
+ if (!(iframe !== null && iframe !== void 0 && iframe.contentWindow)) {
7246
+ _context2.next = 5;
7247
+ break;
7248
+ }
7249
+ return _context2.abrupt("return", iframe.contentWindow);
7250
+ case 5:
7251
+ return _context2.abrupt("return", new Promise(function (resolve) {
7252
+ var observer = new MutationObserver(function () {
7253
+ var iframe = document.querySelector("iframe[".concat(_this2.iframeChannelAttr, "='").concat(_this2.channelId, "']"));
7254
+ if (iframe !== null && iframe !== void 0 && iframe.contentWindow) {
7255
+ observer.disconnect();
7256
+ resolve(iframe.contentWindow);
7257
+ }
7258
+ });
7259
+ // Start observing
7260
+ observer.observe(document.body, {
7261
+ childList: true,
7262
+ subtree: true
7263
+ });
7264
+ }));
7265
+ case 6:
7266
+ case "end":
7267
+ return _context2.stop();
7268
+ }
7269
+ }, _callee2, this);
7270
+ }));
7271
+ function getTargetWindow() {
7272
+ return _getTargetWindow.apply(this, arguments);
7273
+ }
7274
+ return getTargetWindow;
7275
+ }()
7113
7276
  }, {
7114
7277
  key: "setContextAndNotify",
7115
7278
  value: function setContextAndNotify(context) {
7116
- var _this = this;
7279
+ var _this3 = this;
7117
7280
  if (typeof context === 'function') {
7118
7281
  this.contextData = context(this.contextData);
7119
7282
  } else {
7120
7283
  this.contextData = context;
7121
7284
  }
7122
7285
  Object.values(this.listeners).forEach(function (listener) {
7123
- return listener(_this.contextData);
7286
+ return listener(_this3.contextData);
7124
7287
  });
7125
7288
  }
7126
7289
  }, {
@@ -7128,50 +7291,45 @@ var ContextAPI = exports.ContextAPI = /*#__PURE__*/function () {
7128
7291
  value: function getPostRobotEventName(channelId) {
7129
7292
  return "".concat(channelId, "-").concat(CONTEXT_UPDATE_EVENT);
7130
7293
  }
7131
- }, {
7132
- key: "connect",
7133
- value: function connect(channelId) {
7134
- var _this2 = this;
7135
- var targetWindow = this.getTargetWindow();
7136
- if (!targetWindow) {
7137
- var error = new Error('Target window not found');
7138
- throw error;
7139
- }
7140
- var postRobotEventName = this.getPostRobotEventName(channelId);
7141
- this.postRobotListener = postRobot.on(postRobotEventName, {
7142
- window: targetWindow
7143
- }, function (event) {
7144
- if (event.data.type === 'init') {
7145
- _this2.setContext(function (context) {
7146
- return _objectSpread(_objectSpread({}, context), event.data.context);
7147
- });
7148
- } else {
7149
- _this2.setContextAndNotify(function (context) {
7150
- return _objectSpread(_objectSpread({}, context), event.data.context);
7151
- });
7152
- }
7153
- return Promise.resolve();
7154
- });
7155
- this.sendContextUpdate(true);
7156
- }
7157
7294
  }, {
7158
7295
  key: "sendContextUpdate",
7159
- value: function sendContextUpdate() {
7160
- var isInit = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
7161
- var targetWindow = this.getTargetWindow();
7162
- if (!targetWindow) {
7163
- return;
7164
- }
7165
- try {
7166
- postRobot.send(targetWindow, this.getPostRobotEventName(this.channelId), _objectSpread({
7167
- context: this.contextData
7168
- }, isInit && {
7169
- type: 'init'
7170
- }));
7171
- } catch (error) {
7172
- // do nothing
7296
+ value: function () {
7297
+ var _sendContextUpdate = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
7298
+ var isInit,
7299
+ targetWindow,
7300
+ _args3 = arguments;
7301
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
7302
+ while (1) switch (_context3.prev = _context3.next) {
7303
+ case 0:
7304
+ isInit = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : false;
7305
+ _context3.prev = 1;
7306
+ _context3.next = 4;
7307
+ return this.getTargetWindow();
7308
+ case 4:
7309
+ targetWindow = _context3.sent;
7310
+ postRobot.send(targetWindow, this.getPostRobotEventName(this.channelId), _objectSpread({
7311
+ context: this.contextData
7312
+ }, isInit && {
7313
+ type: 'init'
7314
+ }));
7315
+ _context3.next = 11;
7316
+ break;
7317
+ case 8:
7318
+ _context3.prev = 8;
7319
+ _context3.t0 = _context3["catch"](1);
7320
+ // Silently ignore any errors during context update
7321
+ console.debug('Failed to send context update:', _context3.t0);
7322
+ case 11:
7323
+ case "end":
7324
+ return _context3.stop();
7325
+ }
7326
+ }, _callee3, this, [[1, 8]]);
7327
+ }));
7328
+ function sendContextUpdate() {
7329
+ return _sendContextUpdate.apply(this, arguments);
7173
7330
  }
7174
- }
7331
+ return sendContextUpdate;
7332
+ }()
7175
7333
  }, {
7176
7334
  key: "getContext",
7177
7335
  value: function getContext() {
@@ -7179,10 +7337,25 @@ var ContextAPI = exports.ContextAPI = /*#__PURE__*/function () {
7179
7337
  }
7180
7338
  }, {
7181
7339
  key: "setContext",
7182
- value: function setContext(context) {
7183
- this.setContextAndNotify(context);
7184
- this.sendContextUpdate();
7185
- }
7340
+ value: function () {
7341
+ var _setContext = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(context) {
7342
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
7343
+ while (1) switch (_context4.prev = _context4.next) {
7344
+ case 0:
7345
+ this.setContextAndNotify(context);
7346
+ _context4.next = 3;
7347
+ return this.sendContextUpdate();
7348
+ case 3:
7349
+ case "end":
7350
+ return _context4.stop();
7351
+ }
7352
+ }, _callee4, this);
7353
+ }));
7354
+ function setContext(_x) {
7355
+ return _setContext.apply(this, arguments);
7356
+ }
7357
+ return setContext;
7358
+ }()
7186
7359
  }, {
7187
7360
  key: "subscribeToChanges",
7188
7361
  value: function subscribeToChanges(idOrContextListener, contextListenerOrNothing) {
@@ -7201,29 +7374,40 @@ var ContextAPI = exports.ContextAPI = /*#__PURE__*/function () {
7201
7374
  delete this.listeners[id];
7202
7375
  }
7203
7376
  }, {
7204
- key: "connectToIframe",
7205
- value: function connectToIframe() {
7206
- var _this3 = this;
7207
- if (this.type !== 'parent') {
7208
- var error = new Error('ContextAPI is not a parent');
7209
- throw error;
7210
- }
7211
- var onIframeLoad = function onIframeLoad() {
7212
- _this3.connect(_this3.channelId);
7377
+ key: "addContextListener",
7378
+ value: function addContextListener(LiveContextAPItoConnect) {
7379
+ var _this4 = this;
7380
+ var mapContext = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (context) {
7381
+ return context;
7213
7382
  };
7214
- return {
7215
- channelId: this.channelId,
7216
- onIframeLoad: onIframeLoad
7383
+ // Merge the new context with existing context
7384
+ this.setContext(function (currentContext) {
7385
+ return _objectSpread(_objectSpread({}, currentContext), mapContext(LiveContextAPItoConnect.getContext()));
7386
+ });
7387
+ // Subscribe to changes if id is provided
7388
+ var subscriptionId = this.getConnectId(LiveContextAPItoConnect);
7389
+ LiveContextAPItoConnect.subscribeToChanges(subscriptionId, function (updatedContext) {
7390
+ _this4.setContext(function (currentContext) {
7391
+ return _objectSpread(_objectSpread({}, currentContext), mapContext(updatedContext));
7392
+ });
7393
+ });
7394
+ // Return a callback function that unsubscribes
7395
+ return function () {
7396
+ return _this4.unsubscribeFromChanges(subscriptionId);
7217
7397
  };
7218
7398
  }
7219
7399
  }, {
7220
- key: "connectToParent",
7221
- value: function connectToParent() {
7222
- if (this.type !== 'iframe') {
7223
- var error = new Error('ContextAPI is not an iframe');
7224
- throw error;
7225
- }
7226
- this.connect(this.channelId);
7400
+ key: "removeContextListener",
7401
+ value: function removeContextListener(idOrContextAPI) {
7402
+ var id = typeof idOrContextAPI === 'string' ? idOrContextAPI : this.getConnectId(idOrContextAPI);
7403
+ this.unsubscribeFromChanges(id);
7404
+ }
7405
+ }, {
7406
+ key: "connect",
7407
+ value: function connect() {
7408
+ var channelId = this.channelId;
7409
+ this.connectPostRobot();
7410
+ return channelId;
7227
7411
  }
7228
7412
  }, {
7229
7413
  key: "destroy",
@@ -7234,93 +7418,7 @@ var ContextAPI = exports.ContextAPI = /*#__PURE__*/function () {
7234
7418
  }]);
7235
7419
  }();
7236
7420
 
7237
- },{"post-robot":5,"uuid":6}],39:[function(require,module,exports){
7238
- "use strict";
7239
-
7240
- Object.defineProperty(exports, "__esModule", {
7241
- value: true
7242
- });
7243
- exports.JWTProvider = void 0;
7244
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
7245
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return r; }; var t, r = {}, e = Object.prototype, n = e.hasOwnProperty, o = "function" == typeof Symbol ? Symbol : {}, i = o.iterator || "@@iterator", a = o.asyncIterator || "@@asyncIterator", u = o.toStringTag || "@@toStringTag"; function c(t, r, e, n) { return Object.defineProperty(t, r, { value: e, enumerable: !n, configurable: !n, writable: !n }); } try { c({}, ""); } catch (t) { c = function c(t, r, e) { return t[r] = e; }; } function h(r, e, n, o) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype); return c(a, "_invoke", function (r, e, n) { var o = 1; return function (i, a) { if (3 === o) throw Error("Generator is already running"); if (4 === o) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var u = n.delegate; if (u) { var c = d(u, n); if (c) { if (c === f) continue; return c; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (1 === o) throw o = 4, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = 3; var h = s(r, e, n); if ("normal" === h.type) { if (o = n.done ? 4 : 2, h.arg === f) continue; return { value: h.arg, done: n.done }; } "throw" === h.type && (o = 4, n.method = "throw", n.arg = h.arg); } }; }(r, n, new Context(o || [])), !0), a; } function s(t, r, e) { try { return { type: "normal", arg: t.call(r, e) }; } catch (t) { return { type: "throw", arg: t }; } } r.wrap = h; var f = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var l = {}; c(l, i, function () { return this; }); var p = Object.getPrototypeOf, y = p && p(p(x([]))); y && y !== e && n.call(y, i) && (l = y); var v = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(l); function g(t) { ["next", "throw", "return"].forEach(function (r) { c(t, r, function (t) { return this._invoke(r, t); }); }); } function AsyncIterator(t, r) { function e(o, i, a, u) { var c = s(t[o], t, i); if ("throw" !== c.type) { var h = c.arg, f = h.value; return f && "object" == _typeof(f) && n.call(f, "__await") ? r.resolve(f.__await).then(function (t) { e("next", t, a, u); }, function (t) { e("throw", t, a, u); }) : r.resolve(f).then(function (t) { h.value = t, a(h); }, function (t) { return e("throw", t, a, u); }); } u(c.arg); } var o; c(this, "_invoke", function (t, n) { function i() { return new r(function (r, o) { e(t, n, r, o); }); } return o = o ? o.then(i, i) : i(); }, !0); } function d(r, e) { var n = e.method, o = r.i[n]; 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; var i = s(o, r.i, e.arg); if ("throw" === i.type) return e.method = "throw", e.arg = i.arg, e.delegate = null, f; var a = i.arg; 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); } function w(t) { this.tryEntries.push(t); } function m(r) { var e = r[4] || {}; e.type = "normal", e.arg = t, r[4] = e; } function Context(t) { this.tryEntries = [[-1]], t.forEach(w, this), this.reset(!0); } function x(r) { if (null != r) { var e = r[i]; if (e) return e.call(r); if ("function" == typeof r.next) return r; if (!isNaN(r.length)) { var o = -1, a = function e() { for (; ++o < r.length;) if (n.call(r, o)) return e.value = r[o], e.done = !1, e; return e.value = t, e.done = !0, e; }; return a.next = a; } } throw new TypeError(_typeof(r) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, c(v, "constructor", GeneratorFunctionPrototype), c(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = c(GeneratorFunctionPrototype, u, "GeneratorFunction"), r.isGeneratorFunction = function (t) { var r = "function" == typeof t && t.constructor; return !!r && (r === GeneratorFunction || "GeneratorFunction" === (r.displayName || r.name)); }, r.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, c(t, u, "GeneratorFunction")), t.prototype = Object.create(v), t; }, r.awrap = function (t) { return { __await: t }; }, g(AsyncIterator.prototype), c(AsyncIterator.prototype, a, function () { return this; }), r.AsyncIterator = AsyncIterator, r.async = function (t, e, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(h(t, e, n, o), i); return r.isGeneratorFunction(e) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, g(v), c(v, u, "Generator"), c(v, i, function () { return this; }), c(v, "toString", function () { return "[object Generator]"; }), r.keys = function (t) { var r = Object(t), e = []; for (var n in r) e.unshift(n); return function t() { for (; e.length;) if ((n = e.pop()) in r) return t.value = n, t.done = !1, t; return t.done = !0, t; }; }, r.values = x, Context.prototype = { constructor: Context, reset: function reset(r) { 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); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0][4]; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(r) { if (this.done) throw r; var e = this; function n(t) { a.type = "throw", a.arg = r, e.next = t; } for (var o = e.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i[4], u = this.prev, c = i[1], h = i[2]; if (-1 === i[0]) return n("end"), !1; if (!c && !h) throw Error("try statement without catch or finally"); if (null != i[0] && i[0] <= u) { if (u < c) return this.method = "next", this.arg = t, n(c), !0; if (u < h) return n(h), !1; } } }, abrupt: function abrupt(t, r) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var n = this.tryEntries[e]; if (n[0] > -1 && n[0] <= this.prev && this.prev < n[2]) { var o = n; break; } } o && ("break" === t || "continue" === t) && o[0] <= r && r <= o[2] && (o = null); var i = o ? o[4] : {}; return i.type = t, i.arg = r, o ? (this.method = "next", this.next = o[2], f) : this.complete(i); }, complete: function complete(t, r) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && r && (this.next = r), f; }, finish: function finish(t) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var e = this.tryEntries[r]; if (e[2] === t) return this.complete(e[4], e[3]), m(e), f; } }, "catch": function _catch(t) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var e = this.tryEntries[r]; if (e[0] === t) { var n = e[4]; if ("throw" === n.type) { var o = n.arg; m(e); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(r, e, n) { return this.delegate = { i: x(r), r: e, n: n }, "next" === this.method && (this.arg = t), f; } }, r; }
7246
- function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
7247
- function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
7248
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
7249
- function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
7250
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
7251
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
7252
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7253
- var JWTProvider = exports.JWTProvider = /*#__PURE__*/function () {
7254
- function JWTProvider(tokenProvider) {
7255
- var expiresThreshold = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 300;
7256
- _classCallCheck(this, JWTProvider);
7257
- this.token = null;
7258
- this.decoded = null;
7259
- this.tokenProvider = tokenProvider;
7260
- this.expiresThreshold = expiresThreshold;
7261
- }
7262
- return _createClass(JWTProvider, [{
7263
- key: "fetchToken",
7264
- value: function () {
7265
- var _fetchToken = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
7266
- return _regeneratorRuntime().wrap(function _callee$(_context) {
7267
- while (1) switch (_context.prev = _context.next) {
7268
- case 0:
7269
- _context.next = 2;
7270
- return this.tokenProvider.getToken();
7271
- case 2:
7272
- this.token = _context.sent;
7273
- this.decoded = JSON.parse(atob(this.token.split('.')[1])); // Decode the payload
7274
- case 4:
7275
- case "end":
7276
- return _context.stop();
7277
- }
7278
- }, _callee, this);
7279
- }));
7280
- function fetchToken() {
7281
- return _fetchToken.apply(this, arguments);
7282
- }
7283
- return fetchToken;
7284
- }()
7285
- }, {
7286
- key: "isExpiredOrExpiringSoon",
7287
- value: function isExpiredOrExpiringSoon() {
7288
- if (!this.decoded || !this.decoded.exp) {
7289
- return true; // Treat as expired if there's no expiration time
7290
- }
7291
- var currentTime = Math.floor(Date.now() / 1000);
7292
- return this.decoded.exp < currentTime + this.expiresThreshold;
7293
- }
7294
- }, {
7295
- key: "getToken",
7296
- value: function () {
7297
- var _getToken = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
7298
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
7299
- while (1) switch (_context2.prev = _context2.next) {
7300
- case 0:
7301
- if (!(!this.token || this.isExpiredOrExpiringSoon())) {
7302
- _context2.next = 3;
7303
- break;
7304
- }
7305
- _context2.next = 3;
7306
- return this.fetchToken();
7307
- case 3:
7308
- return _context2.abrupt("return", this.token);
7309
- case 4:
7310
- case "end":
7311
- return _context2.stop();
7312
- }
7313
- }, _callee2, this);
7314
- }));
7315
- function getToken() {
7316
- return _getToken.apply(this, arguments);
7317
- }
7318
- return getToken;
7319
- }()
7320
- }]);
7321
- }();
7322
-
7323
- },{}],40:[function(require,module,exports){
7421
+ },{"post-robot":5,"uuid":6}],40:[function(require,module,exports){
7324
7422
  "use strict";
7325
7423
 
7326
7424
  Object.defineProperty(exports, "__esModule", {
@@ -7358,68 +7456,6 @@ var makeProxy = exports.makeProxy = function makeProxy(obj) {
7358
7456
  },{}],41:[function(require,module,exports){
7359
7457
  "use strict";
7360
7458
 
7361
- Object.defineProperty(exports, "__esModule", {
7362
- value: true
7363
- });
7364
- exports.classInstanceToObject = void 0;
7365
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
7366
- // Check if an object contains functions deeply
7367
- var containsDeepFunction = function containsDeepFunction(obj) {
7368
- if (obj === null || obj === undefined) {
7369
- return false;
7370
- }
7371
- if (typeof obj === 'function') {
7372
- return true;
7373
- }
7374
- if (_typeof(obj) !== 'object') {
7375
- return false;
7376
- }
7377
- if (Array.isArray(obj)) {
7378
- return obj.some(function (item) {
7379
- return containsDeepFunction(item);
7380
- });
7381
- }
7382
- return Object.values(obj).some(function (value) {
7383
- return containsDeepFunction(value);
7384
- });
7385
- };
7386
- var classInstanceToObject = exports.classInstanceToObject = function classInstanceToObject(instance, options) {
7387
- // Handle null or undefined
7388
- if (instance === null || instance === undefined) {
7389
- return instance;
7390
- }
7391
- // Handle primitive values
7392
- if (_typeof(instance) !== 'object' || instance instanceof Date) {
7393
- return instance;
7394
- }
7395
- // Handle arrays
7396
- if (Array.isArray(instance)) {
7397
- return instance.map(function (item) {
7398
- return classInstanceToObject(item, options);
7399
- });
7400
- }
7401
- // Handle objects
7402
- var obj = {};
7403
- // Get all own properties (data properties, not methods)
7404
- Object.keys(instance).forEach(function (key) {
7405
- var value = instance[key];
7406
- // Skip functions directly
7407
- if (typeof value === 'function') {
7408
- return;
7409
- }
7410
- // Skip properties that contain functions deeply
7411
- if (_typeof(value) === 'object' && value !== null && containsDeepFunction(value)) {
7412
- return;
7413
- }
7414
- // Recursively convert nested objects
7415
- obj[key] = classInstanceToObject(value, options);
7416
- });
7417
- return obj;
7418
- };
7419
-
7420
- },{}],42:[function(require,module,exports){
7421
- "use strict";
7422
-
7423
7459
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
7424
7460
  Object.defineProperty(exports, "__esModule", {
7425
7461
  value: true
@@ -7470,7 +7506,7 @@ var getOrCreateUsersPrivateWorkspaceRecord = exports.getOrCreateUsersPrivateWork
7470
7506
  };
7471
7507
  }();
7472
7508
 
7473
- },{"uuid":6}],43:[function(require,module,exports){
7509
+ },{"uuid":6}],42:[function(require,module,exports){
7474
7510
  "use strict";
7475
7511
 
7476
7512
  Object.defineProperty(exports, "__esModule", {
@@ -7495,14 +7531,14 @@ var ONTOLOGY_PERMISSION_GROUP = exports.ONTOLOGY_PERMISSION_GROUP = 'octostar:on
7495
7531
  var ALL_PERMISSIONS = exports.ALL_PERMISSIONS = 'all';
7496
7532
  var ALL_PERMISSIONS_ARRAY = exports.ALL_PERMISSIONS_ARRAY = [ALL_PERMISSIONS];
7497
7533
 
7498
- },{}],44:[function(require,module,exports){
7534
+ },{}],43:[function(require,module,exports){
7499
7535
  "use strict";
7500
7536
 
7501
7537
  Object.defineProperty(exports, "__esModule", {
7502
7538
  value: true
7503
7539
  });
7504
7540
 
7505
- },{}],45:[function(require,module,exports){
7541
+ },{}],44:[function(require,module,exports){
7506
7542
  "use strict";
7507
7543
 
7508
7544
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }