authscape 1.0.114 → 1.0.118

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -1,1886 +1,1233 @@
1
- "use strict";
2
-
3
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.Datatable = void 0;
9
-
10
- var _react = _interopRequireWildcard(require("react"));
11
-
12
- var _reactDataTableComponent = _interopRequireWildcard(require("react-data-table-component"));
13
-
14
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
-
16
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
-
18
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
19
-
20
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
21
-
22
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
23
-
24
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
25
-
26
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
27
-
28
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
29
-
30
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
31
-
32
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
33
-
34
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
35
-
36
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
37
-
38
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
39
-
40
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
41
-
42
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
43
-
44
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
45
-
46
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
47
-
48
- var Datatable = /*#__PURE__*/function (_Component) {
49
- _inherits(Datatable, _Component);
50
-
51
- var _super = _createSuper(Datatable);
52
-
53
- function Datatable(props) {
54
- var _this;
55
-
56
- _classCallCheck(this, Datatable);
57
-
58
- _this = _super.call(this, props);
59
-
60
- _defineProperty(_assertThisInitialized(_this), "componentDidMount", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
61
- return _regeneratorRuntime().wrap(function _callee$(_context) {
62
- while (1) {
63
- switch (_context.prev = _context.next) {
64
- case 0:
65
- _context.next = 2;
66
- return _this.GetDataFromUrl(_this.state.pageNumber, _this.state.pageLength, _this.props.params);
67
-
68
- case 2:
69
- (0, _reactDataTableComponent.createTheme)('dataTable', {
70
- text: {}
71
- });
72
-
73
- case 3:
74
- case "end":
75
- return _context.stop();
76
- }
77
- }
78
- }, _callee);
79
- })));
80
-
81
- _defineProperty(_assertThisInitialized(_this), "reload", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
82
- var reset,
83
- _args3 = arguments;
84
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
85
- while (1) {
86
- switch (_context3.prev = _context3.next) {
87
- case 0:
88
- reset = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : false;
89
-
90
- if (!(reset === true)) {
91
- _context3.next = 5;
92
- break;
93
- }
94
-
95
- _this.setState({
96
- pageNumber: 1
97
- }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
98
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
99
- while (1) {
100
- switch (_context2.prev = _context2.next) {
101
- case 0:
102
- _context2.next = 2;
103
- return _this.GetDataFromUrl(_this.state.pageNumber, _this.state.pageLength, _this.props.params);
104
-
105
- case 2:
106
- case "end":
107
- return _context2.stop();
108
- }
109
- }
110
- }, _callee2);
111
- })));
112
-
113
- _context3.next = 7;
114
- break;
115
-
116
- case 5:
117
- _context3.next = 7;
118
- return _this.GetDataFromUrl(_this.state.pageNumber, _this.state.pageLength, _this.props.params);
119
-
120
- case 7:
121
- case "end":
122
- return _context3.stop();
123
- }
124
- }
125
- }, _callee3);
126
- })));
127
-
128
- _defineProperty(_assertThisInitialized(_this), "GetDataFromUrl", function (page, length) {
129
- var postData = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
130
-
131
- _this.setState({
132
- loading: true
133
- }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
134
- var data, response;
135
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
136
- while (1) {
137
- switch (_context4.prev = _context4.next) {
138
- case 0:
139
- data = postData;
140
- data.offset = page;
141
- data.length = length;
142
- response = null;
143
-
144
- if (!(this.props.methodType == "get")) {
145
- _context4.next = 10;
146
- break;
147
- }
148
-
149
- _context4.next = 7;
150
- return apiService().get(this.props.url);
151
-
152
- case 7:
153
- response = _context4.sent;
154
- _context4.next = 13;
155
- break;
156
-
157
- case 10:
158
- _context4.next = 12;
159
- return apiService().post(this.props.url, postData);
160
-
161
- case 12:
162
- response = _context4.sent;
163
-
164
- case 13:
165
- if (response != null && response.status === 200) {
166
- if (this.props.returnResult != null) {
167
- this.props.returnResult(response.data.data);
168
- }
169
-
170
- this.setState({
171
- totalRows: response.data.recordsTotal,
172
- data: response.data.data,
173
- loading: false
174
- });
175
- } else {//console.error(response.status + " - " + response.data);
176
- }
177
-
178
- case 14:
179
- case "end":
180
- return _context4.stop();
181
- }
182
- }
183
- }, _callee4, this);
184
- })));
185
- });
186
-
187
- _defineProperty(_assertThisInitialized(_this), "handlePageChange", /*#__PURE__*/function () {
188
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(page) {
189
- var pageLength;
190
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
191
- while (1) {
192
- switch (_context5.prev = _context5.next) {
193
- case 0:
194
- pageLength = _this.state.pageLength;
195
-
196
- _this.setState({
197
- pageNumber: page
198
- });
199
-
200
- _context5.next = 4;
201
- return _this.GetDataFromUrl(page, pageLength, _this.props.params);
202
-
203
- case 4:
204
- case "end":
205
- return _context5.stop();
206
- }
207
- }
208
- }, _callee5);
209
- }));
210
-
211
- return function (_x) {
212
- return _ref5.apply(this, arguments);
213
- };
214
- }());
215
-
216
- _this.state = {
217
- pageNumber: 1,
218
- pageLength: props.pageLength ? props.pageLength : 10,
219
- data: [],
220
- loading: false,
221
- totalRows: 0
222
- };
223
- return _this;
224
- }
225
-
226
- _createClass(Datatable, [{
227
- key: "render",
228
- value: function render() {
229
- return /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(_reactDataTableComponent["default"], _extends({
230
- title: this.props.title,
231
- columns: this.props.columns,
232
- data: this.state.data,
233
- paginationRowsPerPageOptions: this.props.pageLength ? [this.props.pageLength] : [10],
234
- progressPending: this.state.loading //customStyles={this.props.customStyles}
235
- ,
236
- paginationPerPage: this.props.pageLength ? this.props.pageLength : 10,
237
- paginationServer: true,
238
- pagination: true
239
- }, this.props.options, {
240
- //expandableRows={this.props.expandableRows}
241
- //expandableRowsComponent={this.props.expandableRowsComponent}
242
- paginationTotalRows: this.state.totalRows // onChangeRowsPerPage={this.handlePerRowsChange}
243
- ,
244
- onChangePage: this.handlePageChange,
245
- noDataComponent: this.props.noDataComponent
246
- })));
247
- }
248
- }]);
249
-
250
- return Datatable;
251
- }(_react.Component);
252
-
253
- exports.Datatable = Datatable;
254
-
255
- _defineProperty(Datatable, "defaultProps", {
256
- options: {}
257
- });
258
- "use strict";
259
-
260
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
261
-
262
- Object.defineProperty(exports, "__esModule", {
263
- value: true
264
- });
265
- exports.checkoutForm = void 0;
266
-
267
- var _react = _interopRequireWildcard(require("react"));
268
-
269
- var _Button = _interopRequireDefault(require("@mui/material/Button"));
270
-
271
- var _reactStripeJs = require("@stripe/react-stripe-js");
272
-
273
- var _PaymentRounded = _interopRequireDefault(require("@mui/icons-material/PaymentRounded"));
274
-
275
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
276
-
277
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
278
-
279
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
280
-
281
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
282
-
283
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
284
-
285
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
286
-
287
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
288
-
289
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
290
-
291
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
292
-
293
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
294
-
295
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
296
-
297
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
298
-
299
- var checkoutForm = function checkoutForm(_ref) {
300
- var payButtonText = _ref.payButtonText,
301
- clientSecret = _ref.clientSecret,
302
- onResponse = _ref.onResponse,
303
- amount = _ref.amount;
304
-
305
- var _useState = (0, _react.useState)(false),
306
- _useState2 = _slicedToArray(_useState, 2),
307
- isPaymentProcessing = _useState2[0],
308
- setIsPaymentProcessing = _useState2[1];
309
-
310
- var stripe = (0, _reactStripeJs.useStripe)();
311
- var elements = (0, _reactStripeJs.useElements)();
312
-
313
- var _useState3 = (0, _react.useState)(null),
314
- _useState4 = _slicedToArray(_useState3, 2),
315
- errorMessage = _useState4[0],
316
- setErrorMessage = _useState4[1];
317
-
318
- var handleSubmit = /*#__PURE__*/function () {
319
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(event) {
320
- var _yield$stripe$confirm, error, response, setupIntent, _yield$stripe$confirm2, _error, _response, paymentIntent;
321
-
322
- return _regeneratorRuntime().wrap(function _callee$(_context) {
323
- while (1) {
324
- switch (_context.prev = _context.next) {
325
- case 0:
326
- setIsPaymentProcessing(true); // We don't want to let default form submission happen here,
327
- // which would refresh the page.
328
-
329
- event.preventDefault();
330
-
331
- if (!(!stripe || !elements)) {
332
- _context.next = 5;
333
- break;
334
- }
335
-
336
- // Stripe.js has not yet loaded.
337
- // Make sure to disable form submission until Stripe.js has loaded.
338
- setIsPaymentProcessing(false);
339
- return _context.abrupt("return");
340
-
341
- case 5:
342
- if (!(amount == null)) {
343
- _context.next = 34;
344
- break;
345
- }
346
-
347
- _context.next = 8;
348
- return stripe.confirmSetup({
349
- //`Elements` instance that was used to create the Payment Element
350
- elements: elements,
351
- redirect: "if_required" // confirmParams: {
352
- // return_url: process.env.WebsiteBaseUri + '/confirmSetup?redirectUrl=' + encodeURIComponent(window.location.search),
353
- // },
354
-
355
- });
356
-
357
- case 8:
358
- _yield$stripe$confirm = _context.sent;
359
- error = _yield$stripe$confirm.error;
360
-
361
- if (!error) {
362
- _context.next = 15;
363
- break;
364
- }
365
-
366
- // This point will only be reached if there is an immediate error when
367
- // confirming the payment. Show error to your customer (for example, payment
368
- // details incomplete)
369
- setIsPaymentProcessing(false);
370
- setErrorMessage(error.message);
371
- _context.next = 32;
372
- break;
373
-
374
- case 15:
375
- // Your customer will be redirected to your `return_url`. For some payment
376
- // methods like iDEAL, your customer will be redirected to an intermediate
377
- // site first to authorize the payment, then redirected to the `return_url`.
378
- setIsPaymentProcessing(false);
379
- response = null;
380
- _context.next = 19;
381
- return stripe.retrieveSetupIntent(clientSecret);
382
-
383
- case 19:
384
- response = _context.sent;
385
- //
386
- setupIntent = response.setupIntent;
387
- _context.t0 = setupIntent.status;
388
- _context.next = _context.t0 === 'succeeded' ? 24 : _context.t0 === 'processing' ? 26 : _context.t0 === 'requires_payment_method' ? 28 : 30;
389
- break;
390
-
391
- case 24:
392
- // need to store the payment intent with the customer if they are logged in... currentUser
393
- onResponse("succeeded", setupIntent.id, setupIntent.payment_method);
394
- return _context.abrupt("break", 32);
395
-
396
- case 26:
397
- onResponse("processing", setupIntent.id, setupIntent.payment_method);
398
- return _context.abrupt("break", 32);
399
-
400
- case 28:
401
- onResponse("requires_payment_method", null);
402
- return _context.abrupt("break", 32);
403
-
404
- case 30:
405
- onResponse("failed", null);
406
- return _context.abrupt("break", 32);
407
-
408
- case 32:
409
- _context.next = 66;
410
- break;
411
-
412
- case 34:
413
- _context.next = 36;
414
- return stripe.confirmPayment({
415
- //`Elements` instance that was used to create the Payment Element
416
- elements: elements,
417
- redirect: "if_required",
418
- confirmParams: {
419
- return_url: process.env.WebsiteBaseUri + '/confirmPayment?redirectUrl=' + encodeURIComponent(window.location.search)
420
- }
421
- });
422
-
423
- case 36:
424
- _yield$stripe$confirm2 = _context.sent;
425
- _error = _yield$stripe$confirm2.error;
426
-
427
- if (!_error) {
428
- _context.next = 43;
429
- break;
430
- }
431
-
432
- // This point will only be reached if there is an immediate error when
433
- // confirming the payment. Show error to your customer (for example, payment
434
- // details incomplete)
435
- setIsPaymentProcessing(false);
436
- setErrorMessage(_error.message);
437
- _context.next = 66;
438
- break;
439
-
440
- case 43:
441
- // Your customer will be redirected to your `return_url`. For some payment
442
- // methods like iDEAL, your customer will be redirected to an intermediate
443
- // site first to authorize the payment, then redirected to the `return_url`.
444
- setIsPaymentProcessing(false);
445
- _response = null;
446
-
447
- if (!(amount == null)) {
448
- _context.next = 51;
449
- break;
450
- }
451
-
452
- _context.next = 48;
453
- return stripe.retrieveSetupIntent(clientSecret);
454
-
455
- case 48:
456
- _response = _context.sent;
457
- _context.next = 54;
458
- break;
459
-
460
- case 51:
461
- _context.next = 53;
462
- return stripe.retrievePaymentIntent(clientSecret);
463
-
464
- case 53:
465
- _response = _context.sent;
466
-
467
- case 54:
468
- paymentIntent = _response.paymentIntent;
469
- _context.t1 = paymentIntent.status;
470
- _context.next = _context.t1 === 'succeeded' ? 58 : _context.t1 === 'processing' ? 60 : _context.t1 === 'requires_payment_method' ? 62 : 64;
471
- break;
472
-
473
- case 58:
474
- // need to store the payment intent with the customer if they are logged in... currentUser
475
- onResponse("succeeded", paymentIntent.id);
476
- return _context.abrupt("break", 66);
477
-
478
- case 60:
479
- onResponse("processing", paymentIntent.id);
480
- return _context.abrupt("break", 66);
481
-
482
- case 62:
483
- onResponse("requires_payment_method", null);
484
- return _context.abrupt("break", 66);
485
-
486
- case 64:
487
- onResponse("failed", null);
488
- return _context.abrupt("break", 66);
489
-
490
- case 66:
491
- case "end":
492
- return _context.stop();
493
- }
494
- }
495
- }, _callee);
496
- }));
497
-
498
- return function handleSubmit(_x) {
499
- return _ref2.apply(this, arguments);
500
- };
501
- }();
502
-
503
- return /*#__PURE__*/_react["default"].createElement("form", {
504
- onSubmit: handleSubmit
505
- }, /*#__PURE__*/_react["default"].createElement(_reactStripeJs.PaymentElement, null), /*#__PURE__*/_react["default"].createElement(_Button["default"], {
506
- startIcon: /*#__PURE__*/_react["default"].createElement(_PaymentRounded["default"], null),
507
- type: "submit",
508
- fullWidth: true,
509
- variant: "contained",
510
- disabled: !stripe || isPaymentProcessing,
511
- sx: {
512
- marginTop: 2
513
- }
514
- }, payButtonText), errorMessage && /*#__PURE__*/_react["default"].createElement("div", null, errorMessage));
515
- };
516
-
517
- exports.checkoutForm = checkoutForm;
518
- "use strict";
519
-
520
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
521
-
522
- Object.defineProperty(exports, "__esModule", {
523
- value: true
524
- });
525
- exports.stripePayment = void 0;
526
-
527
- var _react = _interopRequireWildcard(require("react"));
528
-
529
- var _reactStripeJs = require("@stripe/react-stripe-js");
530
-
531
- var _stripeJs = require("@stripe/stripe-js");
532
-
533
- var _Box = _interopRequireDefault(require("@mui/material/Box"));
534
-
535
- var _Dialog = _interopRequireDefault(require("@mui/material/Dialog"));
536
-
537
- var _DialogActions = _interopRequireDefault(require("@mui/material/DialogActions"));
538
-
539
- var _DialogContent = _interopRequireDefault(require("@mui/material/DialogContent"));
540
-
541
- var _DialogTitle = _interopRequireDefault(require("@mui/material/DialogTitle"));
542
-
543
- var _IconButton = _interopRequireDefault(require("@mui/material/IconButton"));
544
-
545
- var _Close = _interopRequireDefault(require("@mui/icons-material/Close"));
546
-
547
- var _Tabs = _interopRequireDefault(require("@mui/material/Tabs"));
548
-
549
- var _Tab = _interopRequireDefault(require("@mui/material/Tab"));
550
-
551
- var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
552
-
553
- var _Select = _interopRequireDefault(require("@mui/material/Select"));
554
-
555
- var _MenuItem = _interopRequireDefault(require("@mui/material/MenuItem"));
556
-
557
- var _Grid = _interopRequireDefault(require("@mui/material/Grid"));
558
-
559
- var _excluded = ["children", "value", "index"];
560
-
561
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
562
-
563
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
564
-
565
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
566
-
567
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
568
-
569
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
570
-
571
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
572
-
573
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
574
-
575
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
576
-
577
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
578
-
579
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
580
-
581
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
582
-
583
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
584
-
585
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
586
-
587
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
588
-
589
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
590
-
591
- var stripePayment = function stripePayment(_ref) {
592
- var title = _ref.title,
593
- description = _ref.description,
594
- _ref$amount = _ref.amount,
595
- amount = _ref$amount === void 0 ? null : _ref$amount,
596
- _ref$priceId = _ref.priceId,
597
- priceId = _ref$priceId === void 0 ? null : _ref$priceId,
598
- _ref$stripeCustomerId = _ref.stripeCustomerId,
599
- stripeCustomerId = _ref$stripeCustomerId === void 0 ? null : _ref$stripeCustomerId,
600
- _ref$isModal = _ref.isModal,
601
- isModal = _ref$isModal === void 0 ? true : _ref$isModal,
602
- logOffUserName = _ref.logOffUserName,
603
- logOffEmail = _ref.logOffEmail,
604
- _ref$paymentRequestTy = _ref.paymentRequestType,
605
- paymentRequestType = _ref$paymentRequestTy === void 0 ? 3 : _ref$paymentRequestTy,
606
- currentUser = _ref.currentUser,
607
- isOpen = _ref.isOpen,
608
- onModalClose = _ref.onModalClose,
609
- onResponse = _ref.onResponse,
610
- _ref$payButtonText = _ref.payButtonText,
611
- payButtonText = _ref$payButtonText === void 0 ? "PAY NOW" : _ref$payButtonText;
612
- var stripePromise = (0, _stripeJs.loadStripe)(process.env.stripePublicKey);
613
-
614
- var _useState = (0, _react.useState)(null),
615
- _useState2 = _slicedToArray(_useState, 2),
616
- options = _useState2[0],
617
- setOptions = _useState2[1];
618
-
619
- var _useState3 = (0, _react.useState)(0),
620
- _useState4 = _slicedToArray(_useState3, 2),
621
- value = _useState4[0],
622
- setValue = _useState4[1];
623
-
624
- var _useState5 = (0, _react.useState)([]),
625
- _useState6 = _slicedToArray(_useState5, 2),
626
- paymentMethods = _useState6[0],
627
- setPaymentMethods = _useState6[1];
628
-
629
- var _useState7 = (0, _react.useState)(null),
630
- _useState8 = _slicedToArray(_useState7, 2),
631
- paymentMethod = _useState8[0],
632
- setPaymentMethod = _useState8[1];
633
-
634
- var paymentMethodOpened = /*#__PURE__*/function () {
635
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
636
- var response, responsePayments;
637
- return _regeneratorRuntime().wrap(function _callee$(_context) {
638
- while (1) {
639
- switch (_context.prev = _context.next) {
640
- case 0:
641
- response = null;
642
-
643
- if (!(currentUser == null)) {
644
- _context.next = 7;
645
- break;
646
- }
647
-
648
- _context.next = 4;
649
- return apiService().post("/Payment/ConnectCustomerNoAuth", {
650
- paymentRequestType: paymentRequestType,
651
- amount: amount,
652
- priceId: priceId,
653
- name: logOffUserName,
654
- email: logOffEmail,
655
- stripeCustomerId: stripeCustomerId
656
- });
657
-
658
- case 4:
659
- response = _context.sent;
660
- _context.next = 10;
661
- break;
662
-
663
- case 7:
664
- _context.next = 9;
665
- return apiService().post("/Payment/ConnectCustomer", {
666
- paymentRequestType: paymentRequestType,
667
- amount: amount,
668
- priceId: priceId,
669
- stripeCustomerId: stripeCustomerId
670
- });
671
-
672
- case 9:
673
- response = _context.sent;
674
-
675
- case 10:
676
- if (!(response != null && response.status == 200)) {
677
- _context.next = 16;
678
- break;
679
- }
680
-
681
- setOptions({
682
- clientSecret: response.data
683
- });
684
- _context.next = 14;
685
- return apiService().get("/Payment/GetPaymentMethods");
686
-
687
- case 14:
688
- responsePayments = _context.sent;
689
-
690
- if (responsePayments != null && responsePayments.status == 200) {
691
- if (responsePayments.data.length > 0) {
692
- setValue(1);
693
- }
694
-
695
- setPaymentMethods(responsePayments.data);
696
- }
697
-
698
- case 16:
699
- case "end":
700
- return _context.stop();
701
- }
702
- }
703
- }, _callee);
704
- }));
705
-
706
- return function paymentMethodOpened() {
707
- return _ref2.apply(this, arguments);
708
- };
709
- }();
710
-
711
- (0, _react.useEffect)(function () {
712
- if (isOpen) {
713
- paymentMethodOpened();
714
- }
715
- }, [isOpen]);
716
-
717
- var handleChange = function handleChange(event, newValue) {
718
- setValue(newValue);
719
- };
720
-
721
- function a11yProps(index) {
722
- return {
723
- id: "simple-tab-".concat(index),
724
- 'aria-controls': "simple-tabpanel-".concat(index)
725
- };
726
- }
727
-
728
- var PaymentMethod = function PaymentMethod(_ref3) {
729
- var paymentMethod = _ref3.paymentMethod,
730
- clicked = _ref3.clicked;
731
- return /*#__PURE__*/_react["default"].createElement(_Box["default"], {
732
- fullWidth: true,
733
- sx: {
734
- height: 160,
735
- width: "100%",
736
- marginTop: 2,
737
- backgroundColor: "#2196F3",
738
- position: "relative",
739
- border: "1px solid #2196F3",
740
- borderRadius: 1,
741
- display: "flex",
742
- flexDirection: "column",
743
- justifyContent: "center",
744
- textAlign: "center",
745
- cursor: "pointer"
746
- },
747
- onClick: function onClick() {
748
- clicked(paymentMethod.id);
749
- }
750
- }, /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
751
- gutterBottom: true,
752
- variant: "body",
753
- component: "div",
754
- sx: {
755
- fontSize: 14,
756
- position: "absolute",
757
- left: 15,
758
- top: 10,
759
- color: "white"
760
- }
761
- }, paymentMethod.brand), /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
762
- gutterBottom: true,
763
- variant: "body",
764
- component: "div",
765
- sx: {
766
- verticalAlign: "middle",
767
- fontSize: 18,
768
- color: "white"
769
- }
770
- }, "* * * * \xA0 * * * * \xA0 * * * * \xA0 ", paymentMethod.last4), /*#__PURE__*/_react["default"].createElement(_Grid["default"], {
771
- container: true,
772
- spacing: 1,
773
- sx: {
774
- position: "absolute",
775
- bottom: 8,
776
- marginLeft: 0,
777
- width: "100%"
778
- }
779
- }, /*#__PURE__*/_react["default"].createElement(_Grid["default"], {
780
- item: true,
781
- xs: 12,
782
- sx: {
783
- textAlign: "right",
784
- paddingRight: 2
785
- }
786
- }, /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
787
- gutterBottom: true,
788
- variant: "body",
789
- component: "div",
790
- sx: {
791
- fontSize: 12,
792
- marginLeft: 2,
793
- marginTop: 1,
794
- color: "#e9e9e9"
795
- }
796
- }, "EXPIRES"), /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
797
- gutterBottom: true,
798
- variant: "body",
799
- component: "div",
800
- sx: {
801
- fontSize: 12,
802
- marginLeft: 2,
803
- marginTop: "-9px",
804
- color: "white"
805
- }
806
- }, paymentMethod.expMonth, "/", paymentMethod.expYear))));
807
- };
808
-
809
- function TabPanel(props) {
810
- var children = props.children,
811
- value = props.value,
812
- index = props.index,
813
- other = _objectWithoutProperties(props, _excluded);
814
-
815
- return /*#__PURE__*/_react["default"].createElement("div", _extends({
816
- role: "tabpanel",
817
- hidden: value !== index,
818
- id: "simple-tabpanel-".concat(index),
819
- "aria-labelledby": "simple-tab-".concat(index)
820
- }, other), value === index && /*#__PURE__*/_react["default"].createElement(_Box["default"], {
821
- sx: {
822
- p: 3
823
- }
824
- }, /*#__PURE__*/_react["default"].createElement(_Typography["default"], null, children)));
825
- }
826
-
827
- var PaymentContent = function PaymentContent() {
828
- return /*#__PURE__*/_react["default"].createElement(_Box["default"], {
829
- sx: {
830
- width: '100%'
831
- }
832
- }, /*#__PURE__*/_react["default"].createElement(_Box["default"], {
833
- sx: {
834
- borderBottom: 1,
835
- borderColor: 'divider'
836
- }
837
- }, /*#__PURE__*/_react["default"].createElement(_Tabs["default"], {
838
- value: value,
839
- onChange: handleChange,
840
- "aria-label": "basic tabs example"
841
- }, /*#__PURE__*/_react["default"].createElement(_Tab["default"], _extends({
842
- label: "Add Payment Method"
843
- }, a11yProps(0))), paymentMethods.length > 0 && /*#__PURE__*/_react["default"].createElement(_Tab["default"], _extends({
844
- label: "Existing Payment Method"
845
- }, a11yProps(1))))), paymentMethods.length > 0 && /*#__PURE__*/_react["default"].createElement(TabPanel, {
846
- value: value,
847
- index: 1
848
- }, /*#__PURE__*/_react["default"].createElement(_Select["default"], {
849
- sx: {
850
- marginTop: 4
851
- },
852
- fullWidth: true,
853
- id: "demo-simple-select",
854
- value: paymentMethod,
855
- onChange: function onChange(val) {
856
- setPaymentMethod(val.target.value);
857
- }
858
- }, paymentMethods != null && paymentMethods.map(function (paymentMethod, index) {
859
- return /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
860
- key: index,
861
- value: paymentMethod.id,
862
- fullWidth: true,
863
- sx: {
864
- width: "100%"
865
- }
866
- }, /*#__PURE__*/_react["default"].createElement(PaymentMethod, {
867
- paymentMethod: paymentMethod,
868
- clicked: function clicked() {}
869
- }));
870
- }))), /*#__PURE__*/_react["default"].createElement(TabPanel, {
871
- value: value,
872
- index: 0
873
- }, /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(_Box["default"], {
874
- mt: 4,
875
- mb: 2
876
- }, options != null && process.env.stripePublicKey != null && /*#__PURE__*/_react["default"].createElement(_reactStripeJs.Elements, {
877
- stripe: stripePromise,
878
- options: options
879
- }, /*#__PURE__*/_react["default"].createElement("checkoutForm", {
880
- payButtonText: payButtonText,
881
- clientSecret: options != null ? options.clientSecret : null,
882
- onResponse: onResponse,
883
- amount: amount
884
- }))))));
885
- };
886
-
887
- return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, isModal && /*#__PURE__*/_react["default"].createElement(_Dialog["default"], {
888
- fullWidth: true,
889
- maxWidth: "sm",
890
- open: isOpen,
891
- onClose: function onClose() {
892
- return onModalClose();
893
- }
894
- }, /*#__PURE__*/_react["default"].createElement(_DialogTitle["default"], null, title, /*#__PURE__*/_react["default"].createElement(_IconButton["default"], {
895
- "aria-label": "close",
896
- onClick: function onClick() {
897
- onModalClose();
898
- },
899
- sx: {
900
- position: 'absolute',
901
- right: 8,
902
- top: 8,
903
- color: function color(theme) {
904
- return theme.palette.grey[500];
905
- }
906
- }
907
- }, /*#__PURE__*/_react["default"].createElement(_Close["default"], null))), /*#__PURE__*/_react["default"].createElement(_DialogContent["default"], null, description, /*#__PURE__*/_react["default"].createElement(PaymentContent, null)), /*#__PURE__*/_react["default"].createElement(_DialogActions["default"], null)), !isModal && /*#__PURE__*/_react["default"].createElement(PaymentContent, null));
908
- };
909
-
910
- exports.stripePayment = stripePayment;
911
- "use strict";
912
-
913
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
914
-
915
- Object.defineProperty(exports, "__esModule", {
916
- value: true
917
- });
918
- exports.apiService = void 0;
919
-
920
- var _axios = _interopRequireDefault(require("axios"));
921
-
922
- var _queryString = _interopRequireDefault(require("query-string"));
923
-
924
- var _jsFileDownload = _interopRequireDefault(require("js-file-download"));
925
-
926
- var _nookies = require("nookies");
927
-
928
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
929
-
930
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
931
-
932
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
933
-
934
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
935
-
936
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
937
-
938
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
939
-
940
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
941
-
942
- var setupDefaultOptions = /*#__PURE__*/function () {
943
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
944
- var ctx,
945
- defaultOptions,
946
- accessToken,
947
- _args = arguments;
948
- return _regeneratorRuntime().wrap(function _callee$(_context) {
949
- while (1) {
950
- switch (_context.prev = _context.next) {
951
- case 0:
952
- ctx = _args.length > 0 && _args[0] !== undefined ? _args[0] : null;
953
- defaultOptions = {};
954
-
955
- if (ctx == null) {
956
- accessToken = (0, _nookies.parseCookies)().access_token || '';
957
-
958
- if (accessToken !== null && accessToken !== undefined && accessToken != "") {
959
- defaultOptions = {
960
- headers: {
961
- Authorization: "Bearer " + accessToken
962
- }
963
- };
964
- } else {
965
- defaultOptions = {
966
- headers: {}
967
- };
968
- }
969
- } else {
970
- defaultOptions = {
971
- headers: {}
972
- };
973
- }
974
-
975
- return _context.abrupt("return", defaultOptions);
976
-
977
- case 4:
978
- case "end":
979
- return _context.stop();
980
- }
981
- }
982
- }, _callee);
983
- }));
984
-
985
- return function setupDefaultOptions() {
986
- return _ref.apply(this, arguments);
987
- };
988
- }();
989
-
990
- var RefreshToken = /*#__PURE__*/function () {
991
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(originalRequest, instance) {
992
- var accessToken, refreshToken, response;
993
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
994
- while (1) {
995
- switch (_context2.prev = _context2.next) {
996
- case 0:
997
- accessToken = (0, _nookies.parseCookies)().access_token || '';
998
- refreshToken = (0, _nookies.parseCookies)().refresh_token || '';
999
- _context2.next = 4;
1000
- return instance.post(process.env.AUTHORITYURI + "/connect/token", _queryString["default"].stringify({
1001
- grant_type: 'refresh_token',
1002
- client_id: process.env.client_id,
1003
- client_secret: process.env.client_secret,
1004
- refresh_token: refreshToken
1005
- }), {
1006
- headers: {
1007
- "Content-Type": "application/x-www-form-urlencoded",
1008
- "Authorization": "Bearer " + accessToken
1009
- }
1010
- });
1011
-
1012
- case 4:
1013
- response = _context2.sent;
1014
-
1015
- if (!(response != null && response.status == 200)) {
1016
- _context2.next = 13;
1017
- break;
1018
- }
1019
-
1020
- originalRequest.headers['Authorization'] = 'Bearer ' + response.data.access_token;
1021
- _context2.next = 9;
1022
- return (0, _nookies.setCookie)(null, "access_token", response.data.access_token, {
1023
- maxAge: 2147483647,
1024
- path: '/',
1025
- domain: process.env.cookieDomain,
1026
- secure: true
1027
- });
1028
-
1029
- case 9:
1030
- _context2.next = 11;
1031
- return (0, _nookies.setCookie)(null, "expires_in", response.data.expires_in, {
1032
- maxAge: 2147483647,
1033
- path: '/',
1034
- domain: process.env.cookieDomain,
1035
- secure: true
1036
- });
1037
-
1038
- case 11:
1039
- _context2.next = 13;
1040
- return (0, _nookies.setCookie)(null, "refresh_token", response.data.refresh_token, {
1041
- maxAge: 2147483647,
1042
- path: '/',
1043
- domain: process.env.cookieDomain,
1044
- secure: true
1045
- });
1046
-
1047
- case 13:
1048
- case "end":
1049
- return _context2.stop();
1050
- }
1051
- }
1052
- }, _callee2);
1053
- }));
1054
-
1055
- return function RefreshToken(_x, _x2) {
1056
- return _ref2.apply(this, arguments);
1057
- };
1058
- }();
1059
-
1060
- var apiService = function apiService() {
1061
- var ctx = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
1062
- var env = process.env.STAGE;
1063
-
1064
- if (env == "development") {
1065
- process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
1066
- }
1067
-
1068
- var baseUri = process.env.APIURI + "/api";
1069
-
1070
- var instance = _axios["default"].create({
1071
- baseURL: baseUri,
1072
- //timeout: 10000,
1073
- params: {} // do not remove this, its added to add params later in the config
1074
-
1075
- });
1076
-
1077
- instance.interceptors.response.use(function (response) {
1078
- return response;
1079
- }, /*#__PURE__*/function () {
1080
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(error) {
1081
- var originalConfig;
1082
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
1083
- while (1) {
1084
- switch (_context3.prev = _context3.next) {
1085
- case 0:
1086
- originalConfig = error.config;
1087
-
1088
- if (!error.response) {
1089
- _context3.next = 10;
1090
- break;
1091
- }
1092
-
1093
- if (!(error.response.status === 401 && !originalConfig._retry)) {
1094
- _context3.next = 7;
1095
- break;
1096
- }
1097
-
1098
- originalConfig._retry = true; // Do something, call refreshToken() request for example;
1099
-
1100
- _context3.next = 6;
1101
- return RefreshToken(originalConfig, instance);
1102
-
1103
- case 6:
1104
- return _context3.abrupt("return", instance.request(originalConfig));
1105
-
1106
- case 7:
1107
- if (!(error.response.status === 400)) {
1108
- _context3.next = 10;
1109
- break;
1110
- }
1111
-
1112
- // Do something
1113
- if (error.response.config.url.includes("/connect/token")) // remove the access and refresh if invalid
1114
- {
1115
- (0, _nookies.destroyCookie)(null, "access_token", {
1116
- maxAge: 2147483647,
1117
- path: '/',
1118
- domain: process.env.cookieDomain
1119
- });
1120
- (0, _nookies.destroyCookie)(null, "refresh_token", {
1121
- maxAge: 2147483647,
1122
- path: '/',
1123
- domain: process.env.cookieDomain
1124
- });
1125
- (0, _nookies.destroyCookie)(null, "expires_in", {
1126
- maxAge: 2147483647,
1127
- path: '/',
1128
- domain: process.env.cookieDomain
1129
- });
1130
- }
1131
-
1132
- return _context3.abrupt("return", Promise.reject(error));
1133
-
1134
- case 10:
1135
- return _context3.abrupt("return", Promise.reject(error));
1136
-
1137
- case 11:
1138
- case "end":
1139
- return _context3.stop();
1140
- }
1141
- }
1142
- }, _callee3);
1143
- }));
1144
-
1145
- return function (_x3) {
1146
- return _ref3.apply(this, arguments);
1147
- };
1148
- }());
1149
- return {
1150
- get: function () {
1151
- var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(url) {
1152
- var options,
1153
- defaultOptions,
1154
- _args4 = arguments;
1155
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
1156
- while (1) {
1157
- switch (_context4.prev = _context4.next) {
1158
- case 0:
1159
- options = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
1160
- _context4.prev = 1;
1161
- _context4.next = 4;
1162
- return setupDefaultOptions(ctx);
1163
-
1164
- case 4:
1165
- defaultOptions = _context4.sent;
1166
- _context4.next = 7;
1167
- return instance.get(url, _objectSpread(_objectSpread({}, defaultOptions), options));
1168
-
1169
- case 7:
1170
- return _context4.abrupt("return", _context4.sent);
1171
-
1172
- case 10:
1173
- _context4.prev = 10;
1174
- _context4.t0 = _context4["catch"](1);
1175
- return _context4.abrupt("return", _context4.t0.response);
1176
-
1177
- case 13:
1178
- case "end":
1179
- return _context4.stop();
1180
- }
1181
- }
1182
- }, _callee4, null, [[1, 10]]);
1183
- }));
1184
-
1185
- function get(_x4) {
1186
- return _get.apply(this, arguments);
1187
- }
1188
-
1189
- return get;
1190
- }(),
1191
- post: function () {
1192
- var _post = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(url, data) {
1193
- var options,
1194
- defaultOptions,
1195
- _args5 = arguments;
1196
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
1197
- while (1) {
1198
- switch (_context5.prev = _context5.next) {
1199
- case 0:
1200
- options = _args5.length > 2 && _args5[2] !== undefined ? _args5[2] : {};
1201
- _context5.prev = 1;
1202
- _context5.next = 4;
1203
- return setupDefaultOptions(ctx);
1204
-
1205
- case 4:
1206
- defaultOptions = _context5.sent;
1207
- _context5.next = 7;
1208
- return instance.post(url, data, _objectSpread(_objectSpread({}, defaultOptions), options));
1209
-
1210
- case 7:
1211
- return _context5.abrupt("return", _context5.sent);
1212
-
1213
- case 10:
1214
- _context5.prev = 10;
1215
- _context5.t0 = _context5["catch"](1);
1216
- return _context5.abrupt("return", _context5.t0.response);
1217
-
1218
- case 13:
1219
- case "end":
1220
- return _context5.stop();
1221
- }
1222
- }
1223
- }, _callee5, null, [[1, 10]]);
1224
- }));
1225
-
1226
- function post(_x5, _x6) {
1227
- return _post.apply(this, arguments);
1228
- }
1229
-
1230
- return post;
1231
- }(),
1232
- put: function () {
1233
- var _put = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(url, data) {
1234
- var options,
1235
- defaultOptions,
1236
- _args6 = arguments;
1237
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
1238
- while (1) {
1239
- switch (_context6.prev = _context6.next) {
1240
- case 0:
1241
- options = _args6.length > 2 && _args6[2] !== undefined ? _args6[2] : {};
1242
- _context6.prev = 1;
1243
- _context6.next = 4;
1244
- return setupDefaultOptions(ctx);
1245
-
1246
- case 4:
1247
- defaultOptions = _context6.sent;
1248
- _context6.next = 7;
1249
- return instance.put(url, data, _objectSpread(_objectSpread({}, defaultOptions), options));
1250
-
1251
- case 7:
1252
- return _context6.abrupt("return", _context6.sent);
1253
-
1254
- case 10:
1255
- _context6.prev = 10;
1256
- _context6.t0 = _context6["catch"](1);
1257
- return _context6.abrupt("return", _context6.t0.response);
1258
-
1259
- case 13:
1260
- case "end":
1261
- return _context6.stop();
1262
- }
1263
- }
1264
- }, _callee6, null, [[1, 10]]);
1265
- }));
1266
-
1267
- function put(_x7, _x8) {
1268
- return _put.apply(this, arguments);
1269
- }
1270
-
1271
- return put;
1272
- }(),
1273
- "delete": function () {
1274
- var _delete2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(url) {
1275
- var options,
1276
- defaultOptions,
1277
- _args7 = arguments;
1278
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
1279
- while (1) {
1280
- switch (_context7.prev = _context7.next) {
1281
- case 0:
1282
- options = _args7.length > 1 && _args7[1] !== undefined ? _args7[1] : {};
1283
- _context7.prev = 1;
1284
- _context7.next = 4;
1285
- return setupDefaultOptions(ctx);
1286
-
1287
- case 4:
1288
- defaultOptions = _context7.sent;
1289
- _context7.next = 7;
1290
- return instance["delete"](url, _objectSpread(_objectSpread({}, defaultOptions), options));
1291
-
1292
- case 7:
1293
- return _context7.abrupt("return", _context7.sent);
1294
-
1295
- case 10:
1296
- _context7.prev = 10;
1297
- _context7.t0 = _context7["catch"](1);
1298
- return _context7.abrupt("return", _context7.t0.response);
1299
-
1300
- case 13:
1301
- case "end":
1302
- return _context7.stop();
1303
- }
1304
- }
1305
- }, _callee7, null, [[1, 10]]);
1306
- }));
1307
-
1308
- function _delete(_x9) {
1309
- return _delete2.apply(this, arguments);
1310
- }
1311
-
1312
- return _delete;
1313
- }(),
1314
- GetCurrentUser: function () {
1315
- var _GetCurrentUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
1316
- var accessToken, defaultOptions, response;
1317
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
1318
- while (1) {
1319
- switch (_context8.prev = _context8.next) {
1320
- case 0:
1321
- _context8.prev = 0;
1322
- accessToken = (0, _nookies.parseCookies)().access_token || null;
1323
-
1324
- if (!accessToken) {
1325
- _context8.next = 11;
1326
- break;
1327
- }
1328
-
1329
- _context8.next = 5;
1330
- return setupDefaultOptions(null);
1331
-
1332
- case 5:
1333
- defaultOptions = _context8.sent;
1334
- _context8.next = 8;
1335
- return instance.get('/UserManagement', defaultOptions);
1336
-
1337
- case 8:
1338
- response = _context8.sent;
1339
-
1340
- if (!(response != null && response.status == 200)) {
1341
- _context8.next = 11;
1342
- break;
1343
- }
1344
-
1345
- return _context8.abrupt("return", response.data);
1346
-
1347
- case 11:
1348
- _context8.next = 16;
1349
- break;
1350
-
1351
- case 13:
1352
- _context8.prev = 13;
1353
- _context8.t0 = _context8["catch"](0);
1354
- //return -1;
1355
- console.log(_context8.t0.message);
1356
-
1357
- case 16:
1358
- return _context8.abrupt("return", null);
1359
-
1360
- case 17:
1361
- case "end":
1362
- return _context8.stop();
1363
- }
1364
- }
1365
- }, _callee8, null, [[0, 13]]);
1366
- }));
1367
-
1368
- function GetCurrentUser() {
1369
- return _GetCurrentUser.apply(this, arguments);
1370
- }
1371
-
1372
- return GetCurrentUser;
1373
- }(),
1374
- DownloadFile: function () {
1375
- var _DownloadFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(url, fileName, completed) {
1376
- var defaultOptions, options, response;
1377
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
1378
- while (1) {
1379
- switch (_context9.prev = _context9.next) {
1380
- case 0:
1381
- _context9.prev = 0;
1382
- //let defaultOptions = await setupDefaultOptions();
1383
- defaultOptions = {};
1384
- options = {
1385
- responseType: "blob"
1386
- };
1387
- _context9.next = 5;
1388
- return instance.get(url, _objectSpread(_objectSpread({}, defaultOptions), options));
1389
-
1390
- case 5:
1391
- response = _context9.sent;
1392
-
1393
- if (response.status === 200) {
1394
- (0, _jsFileDownload["default"])(response.data, fileName);
1395
-
1396
- if (completed !== undefined) {
1397
- completed();
1398
- }
1399
- }
1400
-
1401
- _context9.next = 13;
1402
- break;
1403
-
1404
- case 9:
1405
- _context9.prev = 9;
1406
- _context9.t0 = _context9["catch"](0);
1407
- console.error(_context9.t0);
1408
-
1409
- if (completed !== undefined) {
1410
- completed();
1411
- }
1412
-
1413
- case 13:
1414
- case "end":
1415
- return _context9.stop();
1416
- }
1417
- }
1418
- }, _callee9, null, [[0, 9]]);
1419
- }));
1420
-
1421
- function DownloadFile(_x10, _x11, _x12) {
1422
- return _DownloadFile.apply(this, arguments);
1423
- }
1424
-
1425
- return DownloadFile;
1426
- }()
1427
- };
1428
- };
1429
-
1430
- exports.apiService = apiService;
1431
- "use strict";
1432
-
1433
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
1434
-
1435
- Object.defineProperty(exports, "__esModule", {
1436
- value: true
1437
- });
1438
- exports.AuthorizationComponent = AuthorizationComponent;
1439
-
1440
- var _react = _interopRequireWildcard(require("react"));
1441
-
1442
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
1443
-
1444
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
1445
-
1446
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
1447
-
1448
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
1449
-
1450
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
1451
-
1452
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
1453
-
1454
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
1455
-
1456
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
1457
-
1458
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
1459
-
1460
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
1461
-
1462
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
1463
-
1464
- //import apiService from './apiService';
1465
- function AuthorizationComponent(_ref) {
1466
- var children = _ref.children,
1467
- setCurrentUser = _ref.setCurrentUser,
1468
- userLoaded = _ref.userLoaded,
1469
- isLoading = _ref.isLoading;
1470
-
1471
- var _useState = (0, _react.useState)(false),
1472
- _useState2 = _slicedToArray(_useState, 2),
1473
- loaded = _useState2[0],
1474
- setLoaded = _useState2[1];
1475
-
1476
- var validateUserSignedIn = /*#__PURE__*/function () {
1477
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
1478
- var usr;
1479
- return _regeneratorRuntime().wrap(function _callee$(_context) {
1480
- while (1) {
1481
- switch (_context.prev = _context.next) {
1482
- case 0:
1483
- setLoaded(true);
1484
- _context.next = 3;
1485
- return apiService().GetCurrentUser();
1486
-
1487
- case 3:
1488
- usr = _context.sent;
1489
-
1490
- if (usr != null) {
1491
- setCurrentUser(usr);
1492
- } else {
1493
- setCurrentUser(null);
1494
- }
1495
-
1496
- userLoaded();
1497
-
1498
- case 6:
1499
- case "end":
1500
- return _context.stop();
1501
- }
1502
- }
1503
- }, _callee);
1504
- }));
1505
-
1506
- return function validateUserSignedIn() {
1507
- return _ref2.apply(this, arguments);
1508
- };
1509
- }();
1510
-
1511
- (0, _react.useEffect)(function () {
1512
- if (!loaded) {
1513
- validateUserSignedIn();
1514
- }
1515
- }, [loaded]);
1516
- return children;
1517
- }
1518
- "use strict";
1519
-
1520
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
1521
-
1522
- Object.defineProperty(exports, "__esModule", {
1523
- value: true
1524
- });
1525
- exports.authService = void 0;
1526
-
1527
- var _react = _interopRequireDefault(require("react"));
1528
-
1529
- var _nookies = require("nookies");
1530
-
1531
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
1532
-
1533
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
1534
-
1535
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
1536
-
1537
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
1538
-
1539
- var authService = function authService() {
1540
- return {
1541
- dec2hex: function dec2hex(dec) {
1542
- return ('0' + dec.toString(16)).substr(-2);
1543
- },
1544
- generateRandomString: function generateRandomString() {
1545
- var array = new Uint32Array(56 / 2);
1546
- window.crypto.getRandomValues(array);
1547
- return Array.from(array, authService().dec2hex).join('');
1548
- },
1549
- sha256: function sha256(plain) {
1550
- var encoder = new TextEncoder();
1551
- var data = encoder.encode(plain);
1552
- return window.crypto.subtle.digest('SHA-256', data);
1553
- },
1554
- base64urlencode: function base64urlencode(a) {
1555
- var str = "";
1556
- var bytes = new Uint8Array(a);
1557
- var len = bytes.byteLength;
1558
-
1559
- for (var i = 0; i < len; i++) {
1560
- str += String.fromCharCode(bytes[i]);
1561
- }
1562
-
1563
- return btoa(str).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
1564
- },
1565
- challenge_from_verifier: function () {
1566
- var _challenge_from_verifier = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(v) {
1567
- var hashed, base64encoded;
1568
- return _regeneratorRuntime().wrap(function _callee$(_context) {
1569
- while (1) {
1570
- switch (_context.prev = _context.next) {
1571
- case 0:
1572
- _context.next = 2;
1573
- return authService().sha256(v);
1574
-
1575
- case 2:
1576
- hashed = _context.sent;
1577
- base64encoded = authService().base64urlencode(hashed);
1578
- return _context.abrupt("return", base64encoded);
1579
-
1580
- case 5:
1581
- case "end":
1582
- return _context.stop();
1583
- }
1584
- }
1585
- }, _callee);
1586
- }));
1587
-
1588
- function challenge_from_verifier(_x) {
1589
- return _challenge_from_verifier.apply(this, arguments);
1590
- }
1591
-
1592
- return challenge_from_verifier;
1593
- }(),
1594
- login: function () {
1595
- var _login = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
1596
- var redirectUserUri,
1597
- dnsRecord,
1598
- deviceId,
1599
- state,
1600
- verifier,
1601
- challenge,
1602
- redirectUri,
1603
- loginUri,
1604
- _args2 = arguments;
1605
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1606
- while (1) {
1607
- switch (_context2.prev = _context2.next) {
1608
- case 0:
1609
- redirectUserUri = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : null;
1610
- dnsRecord = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : null;
1611
- deviceId = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : null;
1612
- state = "1234";
1613
-
1614
- if (redirectUserUri != null) {
1615
- localStorage.setItem("redirectUri", redirectUserUri);
1616
- }
1617
-
1618
- verifier = authService().generateRandomString();
1619
- _context2.next = 8;
1620
- return authService().challenge_from_verifier(verifier);
1621
-
1622
- case 8:
1623
- challenge = _context2.sent;
1624
- window.localStorage.setItem("verifier", verifier);
1625
- redirectUri = window.location.origin + "/signin-oidc";
1626
- loginUri = process.env.AUTHORITYURI + "/connect/authorize?response_type=code&state=" + state + "&client_id=" + process.env.client_id + "&scope=email%20openid%20offline_access%20profile%20api1&redirect_uri=" + redirectUri + "&code_challenge=" + challenge + "&code_challenge_method=S256";
1627
-
1628
- if (deviceId) {
1629
- loginUri += "&deviceId=" + deviceId; // will be for chrome extention and mobile apps later
1630
- }
1631
-
1632
- window.location.href = loginUri;
1633
-
1634
- case 14:
1635
- case "end":
1636
- return _context2.stop();
1637
- }
1638
- }
1639
- }, _callee2);
1640
- }));
1641
-
1642
- function login() {
1643
- return _login.apply(this, arguments);
1644
- }
1645
-
1646
- return login;
1647
- }(),
1648
- signUp: function signUp() {
1649
- var redirectUrl = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
1650
- var AuthUri = process.env.AUTHORITYURI;
1651
- var url = "";
1652
-
1653
- if (redirectUrl == null) {
1654
- url = AuthUri + "/Account/Register?returnUrl=" + window.location.href;
1655
- localStorage.setItem("redirectUri", window.location.href);
1656
- } else {
1657
- url = AuthUri + "/Account/Register?returnUrl=" + redirectUrl;
1658
- localStorage.setItem("redirectUri", redirectUrl);
1659
- }
1660
-
1661
- window.location.href = url;
1662
- },
1663
- logout: function () {
1664
- var _logout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
1665
- var redirectUri,
1666
- AuthUri,
1667
- cookieDomain,
1668
- _args3 = arguments;
1669
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
1670
- while (1) {
1671
- switch (_context3.prev = _context3.next) {
1672
- case 0:
1673
- redirectUri = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : null;
1674
- AuthUri = process.env.AUTHORITYURI;
1675
- cookieDomain = process.env.cookieDomain;
1676
- (0, _nookies.destroyCookie)({}, "access_token", {
1677
- maxAge: 2147483647,
1678
- path: '/',
1679
- domain: cookieDomain
1680
- });
1681
- (0, _nookies.destroyCookie)({}, "refresh_token", {
1682
- maxAge: 2147483647,
1683
- path: '/',
1684
- domain: cookieDomain
1685
- });
1686
- (0, _nookies.destroyCookie)({}, "expires_in", {
1687
- maxAge: 2147483647,
1688
- path: '/',
1689
- domain: cookieDomain
1690
- });
1691
- setTimeout(function () {
1692
- if (redirectUri == null) {
1693
- window.location.href = AuthUri + "/connect/logout?redirect=" + window.location.href;
1694
- } else {
1695
- window.location.href = AuthUri + "/connect/logout?redirect=" + redirectUri;
1696
- }
1697
- }, 500);
1698
-
1699
- case 7:
1700
- case "end":
1701
- return _context3.stop();
1702
- }
1703
- }
1704
- }, _callee3);
1705
- }));
1706
-
1707
- function logout() {
1708
- return _logout.apply(this, arguments);
1709
- }
1710
-
1711
- return logout;
1712
- }()
1713
- };
1714
- };
1715
-
1716
- exports.authService = authService;
1717
- "use strict";
1718
-
1719
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
1720
-
1721
- Object.defineProperty(exports, "__esModule", {
1722
- value: true
1723
- });
1724
- exports.signInValidator = void 0;
1725
-
1726
- var _react = _interopRequireWildcard(require("react"));
1727
-
1728
- var _axios = _interopRequireDefault(require("axios"));
1729
-
1730
- var _queryString = _interopRequireDefault(require("query-string"));
1731
-
1732
- var _nookies = require("nookies");
1733
-
1734
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
1735
-
1736
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
1737
-
1738
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
1739
-
1740
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
1741
-
1742
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
1743
-
1744
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
1745
-
1746
- var signInValidator = /*#__PURE__*/function () {
1747
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(queryCode) {
1748
- var codeVerifier, headers, queryString, response, domain, redirectUri;
1749
- return _regeneratorRuntime().wrap(function _callee$(_context) {
1750
- while (1) {
1751
- switch (_context.prev = _context.next) {
1752
- case 0:
1753
- codeVerifier = window.localStorage.getItem("verifier");
1754
-
1755
- if (!(queryCode != null && codeVerifier != null)) {
1756
- _context.next = 18;
1757
- break;
1758
- }
1759
-
1760
- headers = {
1761
- 'Content-Type': 'application/x-www-form-urlencoded'
1762
- };
1763
- queryString = _queryString["default"].stringify({
1764
- code: queryCode,
1765
- grant_type: "authorization_code",
1766
- redirect_uri: window.location.origin + "/signin-oidc",
1767
- client_id: process.env.client_id,
1768
- client_secret: process.env.client_secret,
1769
- code_verifier: codeVerifier
1770
- });
1771
- _context.next = 6;
1772
- return _axios["default"].post(process.env.AUTHORITYURI + '/connect/token', queryString, {
1773
- headers: headers
1774
- });
1775
-
1776
- case 6:
1777
- response = _context.sent;
1778
- window.localStorage.removeItem("verifier");
1779
- domain = process.env.cookieDomain;
1780
- _context.next = 11;
1781
- return (0, _nookies.setCookie)(null, "access_token", response.data.access_token, {
1782
- maxAge: 2147483647,
1783
- path: '/',
1784
- domain: domain,
1785
- secure: true
1786
- });
1787
-
1788
- case 11:
1789
- _context.next = 13;
1790
- return (0, _nookies.setCookie)(null, "expires_in", response.data.expires_in, {
1791
- maxAge: 2147483647,
1792
- path: '/',
1793
- domain: domain,
1794
- secure: true
1795
- });
1796
-
1797
- case 13:
1798
- _context.next = 15;
1799
- return (0, _nookies.setCookie)(null, "refresh_token", response.data.refresh_token, {
1800
- maxAge: 2147483647,
1801
- path: '/',
1802
- domain: domain,
1803
- secure: true
1804
- });
1805
-
1806
- case 15:
1807
- redirectUri = localStorage.getItem("redirectUri");
1808
- localStorage.clear();
1809
-
1810
- if (redirectUri != null) {
1811
- window.location.href = redirectUri;
1812
- } else {
1813
- window.location.href = "/";
1814
- }
1815
-
1816
- case 18:
1817
- case "end":
1818
- return _context.stop();
1819
- }
1820
- }
1821
- }, _callee);
1822
- }));
1823
-
1824
- return function signInValidator(_x) {
1825
- return _ref.apply(this, arguments);
1826
- };
1827
- }();
1828
-
1829
- exports.signInValidator = signInValidator;
1830
- "use strict";
1831
-
1832
- Object.defineProperty(exports, "__esModule", {
1833
- value: true
1834
- });
1835
- exports.Slug = void 0;
1836
-
1837
- var Slug = function Slug(slug) {
1838
- var index = slug.lastIndexOf("-") + 1;
1839
-
1840
- if (slug.length > index) {
1841
- slug = slug.substr(index);
1842
- return slug;
1843
- }
1844
-
1845
- return null;
1846
- };
1847
-
1848
- exports.Slug = Slug;
1849
- "use strict";
1850
-
1851
- Object.defineProperty(exports, "__esModule", {
1852
- value: true
1853
- });
1854
- exports.storeWithExpiry = void 0;
1855
-
1856
- var storeWithExpiry = function storeWithExpiry() {
1857
- return {
1858
- set: function set(key, value, ttl) {
1859
- var now = new Date();
1860
- var item = {
1861
- value: value,
1862
- expiry: now.getTime() + ttl
1863
- };
1864
- localStorage.setItem(key, JSON.stringify(item));
1865
- },
1866
- get: function get(key) {
1867
- var itemStr = localStorage.getItem(key);
1868
-
1869
- if (!itemStr) {
1870
- return null;
1871
- }
1872
-
1873
- var item = JSON.parse(itemStr);
1874
- var now = new Date();
1875
-
1876
- if (now.getTime() > item.expiry) {
1877
- localStorage.removeItem(key);
1878
- return null;
1879
- }
1880
-
1881
- return item.value;
1882
- }
1883
- };
1884
- };
1885
-
1886
- exports.storeWithExpiry = storeWithExpiry;
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.Datatable = void 0;
9
+
10
+ var _react = _interopRequireWildcard(require("react"));
11
+
12
+ var _reactDataTableComponent = _interopRequireWildcard(require("react-data-table-component"));
13
+
14
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
+
16
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
+
18
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
19
+
20
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
21
+
22
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
23
+
24
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
25
+
26
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
27
+
28
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
29
+
30
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
31
+
32
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
33
+
34
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
35
+
36
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
37
+
38
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
39
+
40
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
41
+
42
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
43
+
44
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
45
+
46
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
47
+
48
+ var Datatable = /*#__PURE__*/function (_Component) {
49
+ _inherits(Datatable, _Component);
50
+
51
+ var _super = _createSuper(Datatable);
52
+
53
+ function Datatable(props) {
54
+ var _this;
55
+
56
+ _classCallCheck(this, Datatable);
57
+
58
+ _this = _super.call(this, props);
59
+
60
+ _defineProperty(_assertThisInitialized(_this), "componentDidMount", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
61
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
62
+ while (1) {
63
+ switch (_context.prev = _context.next) {
64
+ case 0:
65
+ _context.next = 2;
66
+ return _this.GetDataFromUrl(_this.state.pageNumber, _this.state.pageLength, _this.props.params);
67
+
68
+ case 2:
69
+ (0, _reactDataTableComponent.createTheme)('dataTable', {
70
+ text: {}
71
+ });
72
+
73
+ case 3:
74
+ case "end":
75
+ return _context.stop();
76
+ }
77
+ }
78
+ }, _callee);
79
+ })));
80
+
81
+ _defineProperty(_assertThisInitialized(_this), "reload", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
82
+ var reset,
83
+ _args3 = arguments;
84
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
85
+ while (1) {
86
+ switch (_context3.prev = _context3.next) {
87
+ case 0:
88
+ reset = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : false;
89
+
90
+ if (!(reset === true)) {
91
+ _context3.next = 5;
92
+ break;
93
+ }
94
+
95
+ _this.setState({
96
+ pageNumber: 1
97
+ }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
98
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
99
+ while (1) {
100
+ switch (_context2.prev = _context2.next) {
101
+ case 0:
102
+ _context2.next = 2;
103
+ return _this.GetDataFromUrl(_this.state.pageNumber, _this.state.pageLength, _this.props.params);
104
+
105
+ case 2:
106
+ case "end":
107
+ return _context2.stop();
108
+ }
109
+ }
110
+ }, _callee2);
111
+ })));
112
+
113
+ _context3.next = 7;
114
+ break;
115
+
116
+ case 5:
117
+ _context3.next = 7;
118
+ return _this.GetDataFromUrl(_this.state.pageNumber, _this.state.pageLength, _this.props.params);
119
+
120
+ case 7:
121
+ case "end":
122
+ return _context3.stop();
123
+ }
124
+ }
125
+ }, _callee3);
126
+ })));
127
+
128
+ _defineProperty(_assertThisInitialized(_this), "GetDataFromUrl", function (page, length) {
129
+ var postData = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
130
+
131
+ _this.setState({
132
+ loading: true
133
+ }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
134
+ var data, response;
135
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
136
+ while (1) {
137
+ switch (_context4.prev = _context4.next) {
138
+ case 0:
139
+ data = postData;
140
+ data.offset = page;
141
+ data.length = length;
142
+ response = null;
143
+
144
+ if (!(this.props.methodType == "get")) {
145
+ _context4.next = 10;
146
+ break;
147
+ }
148
+
149
+ _context4.next = 7;
150
+ return apiService().get(this.props.url);
151
+
152
+ case 7:
153
+ response = _context4.sent;
154
+ _context4.next = 13;
155
+ break;
156
+
157
+ case 10:
158
+ _context4.next = 12;
159
+ return apiService().post(this.props.url, postData);
160
+
161
+ case 12:
162
+ response = _context4.sent;
163
+
164
+ case 13:
165
+ if (response != null && response.status === 200) {
166
+ if (this.props.returnResult != null) {
167
+ this.props.returnResult(response.data.data);
168
+ }
169
+
170
+ this.setState({
171
+ totalRows: response.data.recordsTotal,
172
+ data: response.data.data,
173
+ loading: false
174
+ });
175
+ } else {//console.error(response.status + " - " + response.data);
176
+ }
177
+
178
+ case 14:
179
+ case "end":
180
+ return _context4.stop();
181
+ }
182
+ }
183
+ }, _callee4, this);
184
+ })));
185
+ });
186
+
187
+ _defineProperty(_assertThisInitialized(_this), "handlePageChange", /*#__PURE__*/function () {
188
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(page) {
189
+ var pageLength;
190
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
191
+ while (1) {
192
+ switch (_context5.prev = _context5.next) {
193
+ case 0:
194
+ pageLength = _this.state.pageLength;
195
+
196
+ _this.setState({
197
+ pageNumber: page
198
+ });
199
+
200
+ _context5.next = 4;
201
+ return _this.GetDataFromUrl(page, pageLength, _this.props.params);
202
+
203
+ case 4:
204
+ case "end":
205
+ return _context5.stop();
206
+ }
207
+ }
208
+ }, _callee5);
209
+ }));
210
+
211
+ return function (_x) {
212
+ return _ref5.apply(this, arguments);
213
+ };
214
+ }());
215
+
216
+ _this.state = {
217
+ pageNumber: 1,
218
+ pageLength: props.pageLength ? props.pageLength : 10,
219
+ data: [],
220
+ loading: false,
221
+ totalRows: 0
222
+ };
223
+ return _this;
224
+ }
225
+
226
+ _createClass(Datatable, [{
227
+ key: "render",
228
+ value: function render() {
229
+ return /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(_reactDataTableComponent["default"], _extends({
230
+ title: this.props.title,
231
+ columns: this.props.columns,
232
+ data: this.state.data,
233
+ paginationRowsPerPageOptions: this.props.pageLength ? [this.props.pageLength] : [10],
234
+ progressPending: this.state.loading //customStyles={this.props.customStyles}
235
+ ,
236
+ paginationPerPage: this.props.pageLength ? this.props.pageLength : 10,
237
+ paginationServer: true,
238
+ pagination: true
239
+ }, this.props.options, {
240
+ //expandableRows={this.props.expandableRows}
241
+ //expandableRowsComponent={this.props.expandableRowsComponent}
242
+ paginationTotalRows: this.state.totalRows // onChangeRowsPerPage={this.handlePerRowsChange}
243
+ ,
244
+ onChangePage: this.handlePageChange,
245
+ noDataComponent: this.props.noDataComponent
246
+ })));
247
+ }
248
+ }]);
249
+
250
+ return Datatable;
251
+ }(_react.Component);
252
+
253
+ exports.Datatable = Datatable;
254
+
255
+ _defineProperty(Datatable, "defaultProps", {
256
+ options: {}
257
+ });
258
+ "use strict";
259
+
260
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
261
+
262
+ Object.defineProperty(exports, "__esModule", {
263
+ value: true
264
+ });
265
+ exports.apiService = void 0;
266
+
267
+ var _axios = _interopRequireDefault(require("axios"));
268
+
269
+ var _queryString = _interopRequireDefault(require("query-string"));
270
+
271
+ var _jsFileDownload = _interopRequireDefault(require("js-file-download"));
272
+
273
+ var _nookies = require("nookies");
274
+
275
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
276
+
277
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
278
+
279
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
280
+
281
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
282
+
283
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
284
+
285
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
286
+
287
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
288
+
289
+ var setupDefaultOptions = /*#__PURE__*/function () {
290
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
291
+ var ctx,
292
+ defaultOptions,
293
+ accessToken,
294
+ _args = arguments;
295
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
296
+ while (1) {
297
+ switch (_context.prev = _context.next) {
298
+ case 0:
299
+ ctx = _args.length > 0 && _args[0] !== undefined ? _args[0] : null;
300
+ defaultOptions = {};
301
+
302
+ if (ctx == null) {
303
+ accessToken = (0, _nookies.parseCookies)().access_token || '';
304
+
305
+ if (accessToken !== null && accessToken !== undefined && accessToken != "") {
306
+ defaultOptions = {
307
+ headers: {
308
+ Authorization: "Bearer " + accessToken
309
+ }
310
+ };
311
+ } else {
312
+ defaultOptions = {
313
+ headers: {}
314
+ };
315
+ }
316
+ } else {
317
+ defaultOptions = {
318
+ headers: {}
319
+ };
320
+ }
321
+
322
+ return _context.abrupt("return", defaultOptions);
323
+
324
+ case 4:
325
+ case "end":
326
+ return _context.stop();
327
+ }
328
+ }
329
+ }, _callee);
330
+ }));
331
+
332
+ return function setupDefaultOptions() {
333
+ return _ref.apply(this, arguments);
334
+ };
335
+ }();
336
+
337
+ var RefreshToken = /*#__PURE__*/function () {
338
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(originalRequest, instance) {
339
+ var accessToken, refreshToken, response;
340
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
341
+ while (1) {
342
+ switch (_context2.prev = _context2.next) {
343
+ case 0:
344
+ accessToken = (0, _nookies.parseCookies)().access_token || '';
345
+ refreshToken = (0, _nookies.parseCookies)().refresh_token || '';
346
+ _context2.next = 4;
347
+ return instance.post(process.env.AUTHORITYURI + "/connect/token", _queryString["default"].stringify({
348
+ grant_type: 'refresh_token',
349
+ client_id: process.env.client_id,
350
+ client_secret: process.env.client_secret,
351
+ refresh_token: refreshToken
352
+ }), {
353
+ headers: {
354
+ "Content-Type": "application/x-www-form-urlencoded",
355
+ "Authorization": "Bearer " + accessToken
356
+ }
357
+ });
358
+
359
+ case 4:
360
+ response = _context2.sent;
361
+
362
+ if (!(response != null && response.status == 200)) {
363
+ _context2.next = 13;
364
+ break;
365
+ }
366
+
367
+ originalRequest.headers['Authorization'] = 'Bearer ' + response.data.access_token;
368
+ _context2.next = 9;
369
+ return (0, _nookies.setCookie)(null, "access_token", response.data.access_token, {
370
+ maxAge: 2147483647,
371
+ path: '/',
372
+ domain: process.env.cookieDomain,
373
+ secure: true
374
+ });
375
+
376
+ case 9:
377
+ _context2.next = 11;
378
+ return (0, _nookies.setCookie)(null, "expires_in", response.data.expires_in, {
379
+ maxAge: 2147483647,
380
+ path: '/',
381
+ domain: process.env.cookieDomain,
382
+ secure: true
383
+ });
384
+
385
+ case 11:
386
+ _context2.next = 13;
387
+ return (0, _nookies.setCookie)(null, "refresh_token", response.data.refresh_token, {
388
+ maxAge: 2147483647,
389
+ path: '/',
390
+ domain: process.env.cookieDomain,
391
+ secure: true
392
+ });
393
+
394
+ case 13:
395
+ case "end":
396
+ return _context2.stop();
397
+ }
398
+ }
399
+ }, _callee2);
400
+ }));
401
+
402
+ return function RefreshToken(_x, _x2) {
403
+ return _ref2.apply(this, arguments);
404
+ };
405
+ }();
406
+
407
+ var apiService = function apiService() {
408
+ var ctx = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
409
+ var env = process.env.STAGE;
410
+
411
+ if (env == "development") {
412
+ process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
413
+ }
414
+
415
+ var baseUri = process.env.APIURI + "/api";
416
+
417
+ var instance = _axios["default"].create({
418
+ baseURL: baseUri,
419
+ //timeout: 10000,
420
+ params: {} // do not remove this, its added to add params later in the config
421
+
422
+ });
423
+
424
+ instance.interceptors.response.use(function (response) {
425
+ return response;
426
+ }, /*#__PURE__*/function () {
427
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(error) {
428
+ var originalConfig;
429
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
430
+ while (1) {
431
+ switch (_context3.prev = _context3.next) {
432
+ case 0:
433
+ originalConfig = error.config;
434
+
435
+ if (!error.response) {
436
+ _context3.next = 10;
437
+ break;
438
+ }
439
+
440
+ if (!(error.response.status === 401 && !originalConfig._retry)) {
441
+ _context3.next = 7;
442
+ break;
443
+ }
444
+
445
+ originalConfig._retry = true; // Do something, call refreshToken() request for example;
446
+
447
+ _context3.next = 6;
448
+ return RefreshToken(originalConfig, instance);
449
+
450
+ case 6:
451
+ return _context3.abrupt("return", instance.request(originalConfig));
452
+
453
+ case 7:
454
+ if (!(error.response.status === 400)) {
455
+ _context3.next = 10;
456
+ break;
457
+ }
458
+
459
+ // Do something
460
+ if (error.response.config.url.includes("/connect/token")) // remove the access and refresh if invalid
461
+ {
462
+ (0, _nookies.destroyCookie)(null, "access_token", {
463
+ maxAge: 2147483647,
464
+ path: '/',
465
+ domain: process.env.cookieDomain
466
+ });
467
+ (0, _nookies.destroyCookie)(null, "refresh_token", {
468
+ maxAge: 2147483647,
469
+ path: '/',
470
+ domain: process.env.cookieDomain
471
+ });
472
+ (0, _nookies.destroyCookie)(null, "expires_in", {
473
+ maxAge: 2147483647,
474
+ path: '/',
475
+ domain: process.env.cookieDomain
476
+ });
477
+ }
478
+
479
+ return _context3.abrupt("return", Promise.reject(error));
480
+
481
+ case 10:
482
+ return _context3.abrupt("return", Promise.reject(error));
483
+
484
+ case 11:
485
+ case "end":
486
+ return _context3.stop();
487
+ }
488
+ }
489
+ }, _callee3);
490
+ }));
491
+
492
+ return function (_x3) {
493
+ return _ref3.apply(this, arguments);
494
+ };
495
+ }());
496
+ return {
497
+ get: function () {
498
+ var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(url) {
499
+ var options,
500
+ defaultOptions,
501
+ _args4 = arguments;
502
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
503
+ while (1) {
504
+ switch (_context4.prev = _context4.next) {
505
+ case 0:
506
+ options = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
507
+ _context4.prev = 1;
508
+ _context4.next = 4;
509
+ return setupDefaultOptions(ctx);
510
+
511
+ case 4:
512
+ defaultOptions = _context4.sent;
513
+ _context4.next = 7;
514
+ return instance.get(url, _objectSpread(_objectSpread({}, defaultOptions), options));
515
+
516
+ case 7:
517
+ return _context4.abrupt("return", _context4.sent);
518
+
519
+ case 10:
520
+ _context4.prev = 10;
521
+ _context4.t0 = _context4["catch"](1);
522
+ return _context4.abrupt("return", _context4.t0.response);
523
+
524
+ case 13:
525
+ case "end":
526
+ return _context4.stop();
527
+ }
528
+ }
529
+ }, _callee4, null, [[1, 10]]);
530
+ }));
531
+
532
+ function get(_x4) {
533
+ return _get.apply(this, arguments);
534
+ }
535
+
536
+ return get;
537
+ }(),
538
+ post: function () {
539
+ var _post = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(url, data) {
540
+ var options,
541
+ defaultOptions,
542
+ _args5 = arguments;
543
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
544
+ while (1) {
545
+ switch (_context5.prev = _context5.next) {
546
+ case 0:
547
+ options = _args5.length > 2 && _args5[2] !== undefined ? _args5[2] : {};
548
+ _context5.prev = 1;
549
+ _context5.next = 4;
550
+ return setupDefaultOptions(ctx);
551
+
552
+ case 4:
553
+ defaultOptions = _context5.sent;
554
+ _context5.next = 7;
555
+ return instance.post(url, data, _objectSpread(_objectSpread({}, defaultOptions), options));
556
+
557
+ case 7:
558
+ return _context5.abrupt("return", _context5.sent);
559
+
560
+ case 10:
561
+ _context5.prev = 10;
562
+ _context5.t0 = _context5["catch"](1);
563
+ return _context5.abrupt("return", _context5.t0.response);
564
+
565
+ case 13:
566
+ case "end":
567
+ return _context5.stop();
568
+ }
569
+ }
570
+ }, _callee5, null, [[1, 10]]);
571
+ }));
572
+
573
+ function post(_x5, _x6) {
574
+ return _post.apply(this, arguments);
575
+ }
576
+
577
+ return post;
578
+ }(),
579
+ put: function () {
580
+ var _put = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(url, data) {
581
+ var options,
582
+ defaultOptions,
583
+ _args6 = arguments;
584
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
585
+ while (1) {
586
+ switch (_context6.prev = _context6.next) {
587
+ case 0:
588
+ options = _args6.length > 2 && _args6[2] !== undefined ? _args6[2] : {};
589
+ _context6.prev = 1;
590
+ _context6.next = 4;
591
+ return setupDefaultOptions(ctx);
592
+
593
+ case 4:
594
+ defaultOptions = _context6.sent;
595
+ _context6.next = 7;
596
+ return instance.put(url, data, _objectSpread(_objectSpread({}, defaultOptions), options));
597
+
598
+ case 7:
599
+ return _context6.abrupt("return", _context6.sent);
600
+
601
+ case 10:
602
+ _context6.prev = 10;
603
+ _context6.t0 = _context6["catch"](1);
604
+ return _context6.abrupt("return", _context6.t0.response);
605
+
606
+ case 13:
607
+ case "end":
608
+ return _context6.stop();
609
+ }
610
+ }
611
+ }, _callee6, null, [[1, 10]]);
612
+ }));
613
+
614
+ function put(_x7, _x8) {
615
+ return _put.apply(this, arguments);
616
+ }
617
+
618
+ return put;
619
+ }(),
620
+ "delete": function () {
621
+ var _delete2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(url) {
622
+ var options,
623
+ defaultOptions,
624
+ _args7 = arguments;
625
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
626
+ while (1) {
627
+ switch (_context7.prev = _context7.next) {
628
+ case 0:
629
+ options = _args7.length > 1 && _args7[1] !== undefined ? _args7[1] : {};
630
+ _context7.prev = 1;
631
+ _context7.next = 4;
632
+ return setupDefaultOptions(ctx);
633
+
634
+ case 4:
635
+ defaultOptions = _context7.sent;
636
+ _context7.next = 7;
637
+ return instance["delete"](url, _objectSpread(_objectSpread({}, defaultOptions), options));
638
+
639
+ case 7:
640
+ return _context7.abrupt("return", _context7.sent);
641
+
642
+ case 10:
643
+ _context7.prev = 10;
644
+ _context7.t0 = _context7["catch"](1);
645
+ return _context7.abrupt("return", _context7.t0.response);
646
+
647
+ case 13:
648
+ case "end":
649
+ return _context7.stop();
650
+ }
651
+ }
652
+ }, _callee7, null, [[1, 10]]);
653
+ }));
654
+
655
+ function _delete(_x9) {
656
+ return _delete2.apply(this, arguments);
657
+ }
658
+
659
+ return _delete;
660
+ }(),
661
+ GetCurrentUser: function () {
662
+ var _GetCurrentUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
663
+ var accessToken, defaultOptions, response;
664
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
665
+ while (1) {
666
+ switch (_context8.prev = _context8.next) {
667
+ case 0:
668
+ _context8.prev = 0;
669
+ accessToken = (0, _nookies.parseCookies)().access_token || null;
670
+
671
+ if (!accessToken) {
672
+ _context8.next = 11;
673
+ break;
674
+ }
675
+
676
+ _context8.next = 5;
677
+ return setupDefaultOptions(null);
678
+
679
+ case 5:
680
+ defaultOptions = _context8.sent;
681
+ _context8.next = 8;
682
+ return instance.get('/UserManagement', defaultOptions);
683
+
684
+ case 8:
685
+ response = _context8.sent;
686
+
687
+ if (!(response != null && response.status == 200)) {
688
+ _context8.next = 11;
689
+ break;
690
+ }
691
+
692
+ return _context8.abrupt("return", response.data);
693
+
694
+ case 11:
695
+ _context8.next = 16;
696
+ break;
697
+
698
+ case 13:
699
+ _context8.prev = 13;
700
+ _context8.t0 = _context8["catch"](0);
701
+ //return -1;
702
+ console.log(_context8.t0.message);
703
+
704
+ case 16:
705
+ return _context8.abrupt("return", null);
706
+
707
+ case 17:
708
+ case "end":
709
+ return _context8.stop();
710
+ }
711
+ }
712
+ }, _callee8, null, [[0, 13]]);
713
+ }));
714
+
715
+ function GetCurrentUser() {
716
+ return _GetCurrentUser.apply(this, arguments);
717
+ }
718
+
719
+ return GetCurrentUser;
720
+ }(),
721
+ DownloadFile: function () {
722
+ var _DownloadFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(url, fileName, completed) {
723
+ var defaultOptions, options, response;
724
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
725
+ while (1) {
726
+ switch (_context9.prev = _context9.next) {
727
+ case 0:
728
+ _context9.prev = 0;
729
+ //let defaultOptions = await setupDefaultOptions();
730
+ defaultOptions = {};
731
+ options = {
732
+ responseType: "blob"
733
+ };
734
+ _context9.next = 5;
735
+ return instance.get(url, _objectSpread(_objectSpread({}, defaultOptions), options));
736
+
737
+ case 5:
738
+ response = _context9.sent;
739
+
740
+ if (response.status === 200) {
741
+ (0, _jsFileDownload["default"])(response.data, fileName);
742
+
743
+ if (completed !== undefined) {
744
+ completed();
745
+ }
746
+ }
747
+
748
+ _context9.next = 13;
749
+ break;
750
+
751
+ case 9:
752
+ _context9.prev = 9;
753
+ _context9.t0 = _context9["catch"](0);
754
+ console.error(_context9.t0);
755
+
756
+ if (completed !== undefined) {
757
+ completed();
758
+ }
759
+
760
+ case 13:
761
+ case "end":
762
+ return _context9.stop();
763
+ }
764
+ }
765
+ }, _callee9, null, [[0, 9]]);
766
+ }));
767
+
768
+ function DownloadFile(_x10, _x11, _x12) {
769
+ return _DownloadFile.apply(this, arguments);
770
+ }
771
+
772
+ return DownloadFile;
773
+ }()
774
+ };
775
+ };
776
+
777
+ exports.apiService = apiService;
778
+ "use strict";
779
+
780
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
781
+
782
+ Object.defineProperty(exports, "__esModule", {
783
+ value: true
784
+ });
785
+ exports.AuthorizationComponent = AuthorizationComponent;
786
+
787
+ var _react = _interopRequireWildcard(require("react"));
788
+
789
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
790
+
791
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
792
+
793
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
794
+
795
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
796
+
797
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
798
+
799
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
800
+
801
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
802
+
803
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
804
+
805
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
806
+
807
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
808
+
809
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
810
+
811
+ //import apiService from './apiService';
812
+ function AuthorizationComponent(_ref) {
813
+ var children = _ref.children,
814
+ setCurrentUser = _ref.setCurrentUser,
815
+ userLoaded = _ref.userLoaded,
816
+ isLoading = _ref.isLoading;
817
+
818
+ var _useState = (0, _react.useState)(false),
819
+ _useState2 = _slicedToArray(_useState, 2),
820
+ loaded = _useState2[0],
821
+ setLoaded = _useState2[1];
822
+
823
+ var validateUserSignedIn = /*#__PURE__*/function () {
824
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
825
+ var usr;
826
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
827
+ while (1) {
828
+ switch (_context.prev = _context.next) {
829
+ case 0:
830
+ setLoaded(true);
831
+ _context.next = 3;
832
+ return apiService().GetCurrentUser();
833
+
834
+ case 3:
835
+ usr = _context.sent;
836
+
837
+ if (usr != null) {
838
+ setCurrentUser(usr);
839
+ } else {
840
+ setCurrentUser(null);
841
+ }
842
+
843
+ userLoaded();
844
+
845
+ case 6:
846
+ case "end":
847
+ return _context.stop();
848
+ }
849
+ }
850
+ }, _callee);
851
+ }));
852
+
853
+ return function validateUserSignedIn() {
854
+ return _ref2.apply(this, arguments);
855
+ };
856
+ }();
857
+
858
+ (0, _react.useEffect)(function () {
859
+ if (!loaded) {
860
+ validateUserSignedIn();
861
+ }
862
+ }, [loaded]);
863
+ return children;
864
+ }
865
+ "use strict";
866
+
867
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
868
+
869
+ Object.defineProperty(exports, "__esModule", {
870
+ value: true
871
+ });
872
+ exports.authService = void 0;
873
+
874
+ var _react = _interopRequireDefault(require("react"));
875
+
876
+ var _nookies = require("nookies");
877
+
878
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
879
+
880
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
881
+
882
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
883
+
884
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
885
+
886
+ var authService = function authService() {
887
+ return {
888
+ dec2hex: function dec2hex(dec) {
889
+ return ('0' + dec.toString(16)).substr(-2);
890
+ },
891
+ generateRandomString: function generateRandomString() {
892
+ var array = new Uint32Array(56 / 2);
893
+ window.crypto.getRandomValues(array);
894
+ return Array.from(array, authService().dec2hex).join('');
895
+ },
896
+ sha256: function sha256(plain) {
897
+ var encoder = new TextEncoder();
898
+ var data = encoder.encode(plain);
899
+ return window.crypto.subtle.digest('SHA-256', data);
900
+ },
901
+ base64urlencode: function base64urlencode(a) {
902
+ var str = "";
903
+ var bytes = new Uint8Array(a);
904
+ var len = bytes.byteLength;
905
+
906
+ for (var i = 0; i < len; i++) {
907
+ str += String.fromCharCode(bytes[i]);
908
+ }
909
+
910
+ return btoa(str).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
911
+ },
912
+ challenge_from_verifier: function () {
913
+ var _challenge_from_verifier = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(v) {
914
+ var hashed, base64encoded;
915
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
916
+ while (1) {
917
+ switch (_context.prev = _context.next) {
918
+ case 0:
919
+ _context.next = 2;
920
+ return authService().sha256(v);
921
+
922
+ case 2:
923
+ hashed = _context.sent;
924
+ base64encoded = authService().base64urlencode(hashed);
925
+ return _context.abrupt("return", base64encoded);
926
+
927
+ case 5:
928
+ case "end":
929
+ return _context.stop();
930
+ }
931
+ }
932
+ }, _callee);
933
+ }));
934
+
935
+ function challenge_from_verifier(_x) {
936
+ return _challenge_from_verifier.apply(this, arguments);
937
+ }
938
+
939
+ return challenge_from_verifier;
940
+ }(),
941
+ login: function () {
942
+ var _login = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
943
+ var redirectUserUri,
944
+ dnsRecord,
945
+ deviceId,
946
+ state,
947
+ verifier,
948
+ challenge,
949
+ redirectUri,
950
+ loginUri,
951
+ _args2 = arguments;
952
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
953
+ while (1) {
954
+ switch (_context2.prev = _context2.next) {
955
+ case 0:
956
+ redirectUserUri = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : null;
957
+ dnsRecord = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : null;
958
+ deviceId = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : null;
959
+ state = "1234";
960
+
961
+ if (redirectUserUri != null) {
962
+ localStorage.setItem("redirectUri", redirectUserUri);
963
+ }
964
+
965
+ verifier = authService().generateRandomString();
966
+ _context2.next = 8;
967
+ return authService().challenge_from_verifier(verifier);
968
+
969
+ case 8:
970
+ challenge = _context2.sent;
971
+ window.localStorage.setItem("verifier", verifier);
972
+ redirectUri = window.location.origin + "/signin-oidc";
973
+ loginUri = process.env.AUTHORITYURI + "/connect/authorize?response_type=code&state=" + state + "&client_id=" + process.env.client_id + "&scope=email%20openid%20offline_access%20profile%20api1&redirect_uri=" + redirectUri + "&code_challenge=" + challenge + "&code_challenge_method=S256";
974
+
975
+ if (deviceId) {
976
+ loginUri += "&deviceId=" + deviceId; // will be for chrome extention and mobile apps later
977
+ }
978
+
979
+ window.location.href = loginUri;
980
+
981
+ case 14:
982
+ case "end":
983
+ return _context2.stop();
984
+ }
985
+ }
986
+ }, _callee2);
987
+ }));
988
+
989
+ function login() {
990
+ return _login.apply(this, arguments);
991
+ }
992
+
993
+ return login;
994
+ }(),
995
+ signUp: function signUp() {
996
+ var redirectUrl = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
997
+ var AuthUri = process.env.AUTHORITYURI;
998
+ var url = "";
999
+
1000
+ if (redirectUrl == null) {
1001
+ url = AuthUri + "/Account/Register?returnUrl=" + window.location.href;
1002
+ localStorage.setItem("redirectUri", window.location.href);
1003
+ } else {
1004
+ url = AuthUri + "/Account/Register?returnUrl=" + redirectUrl;
1005
+ localStorage.setItem("redirectUri", redirectUrl);
1006
+ }
1007
+
1008
+ window.location.href = url;
1009
+ },
1010
+ logout: function () {
1011
+ var _logout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
1012
+ var redirectUri,
1013
+ AuthUri,
1014
+ cookieDomain,
1015
+ _args3 = arguments;
1016
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
1017
+ while (1) {
1018
+ switch (_context3.prev = _context3.next) {
1019
+ case 0:
1020
+ redirectUri = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : null;
1021
+ AuthUri = process.env.AUTHORITYURI;
1022
+ cookieDomain = process.env.cookieDomain;
1023
+ (0, _nookies.destroyCookie)({}, "access_token", {
1024
+ maxAge: 2147483647,
1025
+ path: '/',
1026
+ domain: cookieDomain
1027
+ });
1028
+ (0, _nookies.destroyCookie)({}, "refresh_token", {
1029
+ maxAge: 2147483647,
1030
+ path: '/',
1031
+ domain: cookieDomain
1032
+ });
1033
+ (0, _nookies.destroyCookie)({}, "expires_in", {
1034
+ maxAge: 2147483647,
1035
+ path: '/',
1036
+ domain: cookieDomain
1037
+ });
1038
+ setTimeout(function () {
1039
+ if (redirectUri == null) {
1040
+ window.location.href = AuthUri + "/connect/logout?redirect=" + window.location.href;
1041
+ } else {
1042
+ window.location.href = AuthUri + "/connect/logout?redirect=" + redirectUri;
1043
+ }
1044
+ }, 500);
1045
+
1046
+ case 7:
1047
+ case "end":
1048
+ return _context3.stop();
1049
+ }
1050
+ }
1051
+ }, _callee3);
1052
+ }));
1053
+
1054
+ function logout() {
1055
+ return _logout.apply(this, arguments);
1056
+ }
1057
+
1058
+ return logout;
1059
+ }()
1060
+ };
1061
+ };
1062
+
1063
+ exports.authService = authService;
1064
+ "use strict";
1065
+
1066
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
1067
+
1068
+ Object.defineProperty(exports, "__esModule", {
1069
+ value: true
1070
+ });
1071
+ exports.signInValidator = void 0;
1072
+
1073
+ var _react = _interopRequireWildcard(require("react"));
1074
+
1075
+ var _axios = _interopRequireDefault(require("axios"));
1076
+
1077
+ var _queryString = _interopRequireDefault(require("query-string"));
1078
+
1079
+ var _nookies = require("nookies");
1080
+
1081
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
1082
+
1083
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
1084
+
1085
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
1086
+
1087
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
1088
+
1089
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
1090
+
1091
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
1092
+
1093
+ var signInValidator = /*#__PURE__*/function () {
1094
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(queryCode) {
1095
+ var codeVerifier, headers, queryString, response, domain, redirectUri;
1096
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1097
+ while (1) {
1098
+ switch (_context.prev = _context.next) {
1099
+ case 0:
1100
+ codeVerifier = window.localStorage.getItem("verifier");
1101
+
1102
+ if (!(queryCode != null && codeVerifier != null)) {
1103
+ _context.next = 18;
1104
+ break;
1105
+ }
1106
+
1107
+ headers = {
1108
+ 'Content-Type': 'application/x-www-form-urlencoded'
1109
+ };
1110
+ queryString = _queryString["default"].stringify({
1111
+ code: queryCode,
1112
+ grant_type: "authorization_code",
1113
+ redirect_uri: window.location.origin + "/signin-oidc",
1114
+ client_id: process.env.client_id,
1115
+ client_secret: process.env.client_secret,
1116
+ code_verifier: codeVerifier
1117
+ });
1118
+ _context.next = 6;
1119
+ return _axios["default"].post(process.env.AUTHORITYURI + '/connect/token', queryString, {
1120
+ headers: headers
1121
+ });
1122
+
1123
+ case 6:
1124
+ response = _context.sent;
1125
+ window.localStorage.removeItem("verifier");
1126
+ domain = process.env.cookieDomain;
1127
+ _context.next = 11;
1128
+ return (0, _nookies.setCookie)(null, "access_token", response.data.access_token, {
1129
+ maxAge: 2147483647,
1130
+ path: '/',
1131
+ domain: domain,
1132
+ secure: true
1133
+ });
1134
+
1135
+ case 11:
1136
+ _context.next = 13;
1137
+ return (0, _nookies.setCookie)(null, "expires_in", response.data.expires_in, {
1138
+ maxAge: 2147483647,
1139
+ path: '/',
1140
+ domain: domain,
1141
+ secure: true
1142
+ });
1143
+
1144
+ case 13:
1145
+ _context.next = 15;
1146
+ return (0, _nookies.setCookie)(null, "refresh_token", response.data.refresh_token, {
1147
+ maxAge: 2147483647,
1148
+ path: '/',
1149
+ domain: domain,
1150
+ secure: true
1151
+ });
1152
+
1153
+ case 15:
1154
+ redirectUri = localStorage.getItem("redirectUri");
1155
+ localStorage.clear();
1156
+
1157
+ if (redirectUri != null) {
1158
+ window.location.href = redirectUri;
1159
+ } else {
1160
+ window.location.href = "/";
1161
+ }
1162
+
1163
+ case 18:
1164
+ case "end":
1165
+ return _context.stop();
1166
+ }
1167
+ }
1168
+ }, _callee);
1169
+ }));
1170
+
1171
+ return function signInValidator(_x) {
1172
+ return _ref.apply(this, arguments);
1173
+ };
1174
+ }();
1175
+
1176
+ exports.signInValidator = signInValidator;
1177
+ "use strict";
1178
+
1179
+ Object.defineProperty(exports, "__esModule", {
1180
+ value: true
1181
+ });
1182
+ exports.Slug = void 0;
1183
+
1184
+ var Slug = function Slug(slug) {
1185
+ var index = slug.lastIndexOf("-") + 1;
1186
+
1187
+ if (slug.length > index) {
1188
+ slug = slug.substr(index);
1189
+ return slug;
1190
+ }
1191
+
1192
+ return null;
1193
+ };
1194
+
1195
+ exports.Slug = Slug;
1196
+ "use strict";
1197
+
1198
+ Object.defineProperty(exports, "__esModule", {
1199
+ value: true
1200
+ });
1201
+ exports.storeWithExpiry = void 0;
1202
+
1203
+ var storeWithExpiry = function storeWithExpiry() {
1204
+ return {
1205
+ set: function set(key, value, ttl) {
1206
+ var now = new Date();
1207
+ var item = {
1208
+ value: value,
1209
+ expiry: now.getTime() + ttl
1210
+ };
1211
+ localStorage.setItem(key, JSON.stringify(item));
1212
+ },
1213
+ get: function get(key) {
1214
+ var itemStr = localStorage.getItem(key);
1215
+
1216
+ if (!itemStr) {
1217
+ return null;
1218
+ }
1219
+
1220
+ var item = JSON.parse(itemStr);
1221
+ var now = new Date();
1222
+
1223
+ if (now.getTime() > item.expiry) {
1224
+ localStorage.removeItem(key);
1225
+ return null;
1226
+ }
1227
+
1228
+ return item.value;
1229
+ }
1230
+ };
1231
+ };
1232
+
1233
+ exports.storeWithExpiry = storeWithExpiry;