@stokr/components-library 2.1.1 → 2.1.2-beta.2
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/dist/components/2FA/enable-2fa-flow.js +73 -44
- package/dist/components/2FA/main-flow.js +86 -20
- package/dist/components/2FA/main-flow.stories.js +1 -1
- package/dist/components/Input/Select.js +27 -7
- package/dist/components/Input/Select.styles.js +14 -25
- package/dist/context/Auth.js +14 -0
- package/dist/context/AuthContext.js +8 -9
- package/package.json +1 -1
|
@@ -32,103 +32,132 @@ var stepsNames = ['app', 'connect', 'enter-code'];
|
|
|
32
32
|
var Enable2FAFlow = function Enable2FAFlow(_ref) {
|
|
33
33
|
var showFlow = _ref.showFlow,
|
|
34
34
|
setShowFlow = _ref.setShowFlow,
|
|
35
|
-
_ref$withSuccessPage = _ref.withSuccessPage,
|
|
36
|
-
withSuccessPage = _ref$withSuccessPage === void 0 ? false : _ref$withSuccessPage,
|
|
37
35
|
onSuccess = _ref.onSuccess,
|
|
36
|
+
totpData = _ref.totpData,
|
|
38
37
|
onRequiresRecentLoginError = _ref.onRequiresRecentLoginError;
|
|
39
38
|
var _useContext = (0, _react.useContext)(_AuthContext.AuthContext),
|
|
40
39
|
user = _useContext.user,
|
|
41
40
|
generateTotpSecret = _useContext.generateTotpSecret,
|
|
42
|
-
enrollUserToTotp = _useContext.enrollUserToTotp
|
|
41
|
+
enrollUserToTotp = _useContext.enrollUserToTotp,
|
|
42
|
+
refreshIdToken = _useContext.refreshIdToken;
|
|
43
43
|
var _useState = (0, _react.useState)(false),
|
|
44
44
|
_useState2 = _slicedToArray(_useState, 2),
|
|
45
45
|
showSuccess = _useState2[0],
|
|
46
46
|
setshowSuccess = _useState2[1];
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
totpData = _useState4[0],
|
|
50
|
-
settotpData = _useState4[1];
|
|
51
|
-
var _useState5 = (0, _react.useState)({
|
|
47
|
+
//const [totpData, settotpData] = useState(totpData)
|
|
48
|
+
var _useState3 = (0, _react.useState)({
|
|
52
49
|
popup: undefined,
|
|
53
50
|
message: undefined
|
|
54
51
|
}),
|
|
55
|
-
|
|
56
|
-
popupError =
|
|
57
|
-
setpopupError =
|
|
52
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
53
|
+
popupError = _useState4[0],
|
|
54
|
+
setpopupError = _useState4[1];
|
|
58
55
|
(0, _react.useEffect)(function () {
|
|
59
56
|
if (user) {
|
|
60
|
-
|
|
61
|
-
settotpData(data);
|
|
62
|
-
return;
|
|
63
|
-
}).catch(function (error) {
|
|
64
|
-
console.log(error);
|
|
65
|
-
if (error.code === 'auth/requires-recent-login' || error.code === 'auth/unsupported-first-factor') {
|
|
66
|
-
onRequiresRecentLoginError && onRequiresRecentLoginError();
|
|
67
|
-
}
|
|
68
|
-
});
|
|
57
|
+
refreshToken();
|
|
69
58
|
}
|
|
70
59
|
}, [user]);
|
|
71
|
-
var
|
|
72
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(
|
|
60
|
+
var refreshToken = /*#__PURE__*/function () {
|
|
61
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
73
62
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
74
63
|
while (1) switch (_context.prev = _context.next) {
|
|
64
|
+
case 0:
|
|
65
|
+
try {
|
|
66
|
+
refreshIdToken();
|
|
67
|
+
console.log('RefreshIdTOken called');
|
|
68
|
+
} catch (error) {
|
|
69
|
+
console.log('🚀 ~ error:', error);
|
|
70
|
+
}
|
|
71
|
+
case 1:
|
|
72
|
+
case "end":
|
|
73
|
+
return _context.stop();
|
|
74
|
+
}
|
|
75
|
+
}, _callee);
|
|
76
|
+
}));
|
|
77
|
+
return function refreshToken() {
|
|
78
|
+
return _ref2.apply(this, arguments);
|
|
79
|
+
};
|
|
80
|
+
}();
|
|
81
|
+
// useEffect(() => {
|
|
82
|
+
// if (user) {
|
|
83
|
+
// generateTotpSecret(user)
|
|
84
|
+
// .then((data) => {
|
|
85
|
+
// settotpData(data)
|
|
86
|
+
// return
|
|
87
|
+
// })
|
|
88
|
+
// .catch((error) => {
|
|
89
|
+
// console.log(error)
|
|
90
|
+
// if (
|
|
91
|
+
// error.code === 'auth/requires-recent-login' ||
|
|
92
|
+
// error.code === 'auth/unsupported-first-factor'
|
|
93
|
+
// ) {
|
|
94
|
+
// onRequiresRecentLoginError && onRequiresRecentLoginError()
|
|
95
|
+
// }
|
|
96
|
+
// })
|
|
97
|
+
// }
|
|
98
|
+
// }, [user])
|
|
99
|
+
|
|
100
|
+
var onSubmit = /*#__PURE__*/function () {
|
|
101
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(data) {
|
|
102
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
103
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
75
104
|
case 0:
|
|
76
105
|
if (!(!user || !data)) {
|
|
77
|
-
|
|
106
|
+
_context2.next = 2;
|
|
78
107
|
break;
|
|
79
108
|
}
|
|
80
|
-
return
|
|
109
|
+
return _context2.abrupt("return", console.log('not enough data'));
|
|
81
110
|
case 2:
|
|
82
|
-
|
|
83
|
-
|
|
111
|
+
_context2.prev = 2;
|
|
112
|
+
_context2.next = 5;
|
|
84
113
|
return enrollUserToTotp(user, totpData.totpSecret, data.otpInput, user.displayName);
|
|
85
114
|
case 5:
|
|
86
115
|
setshowSuccess(true);
|
|
87
|
-
|
|
88
|
-
|
|
116
|
+
_context2.prev = 6;
|
|
117
|
+
_context2.next = 9;
|
|
89
118
|
return (0, _fetchData.default)('auth/enable-2fa-email');
|
|
90
119
|
case 9:
|
|
91
|
-
|
|
120
|
+
_context2.next = 14;
|
|
92
121
|
break;
|
|
93
122
|
case 11:
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
console.log('🚀 ~ error while sending email:',
|
|
123
|
+
_context2.prev = 11;
|
|
124
|
+
_context2.t0 = _context2["catch"](6);
|
|
125
|
+
console.log('🚀 ~ error while sending email:', _context2.t0);
|
|
97
126
|
case 14:
|
|
98
|
-
|
|
127
|
+
_context2.next = 25;
|
|
99
128
|
break;
|
|
100
129
|
case 16:
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
console.log('🚀 ~ file: enable-2fa-flow.js:60 ~ error:',
|
|
104
|
-
if (!(
|
|
105
|
-
|
|
130
|
+
_context2.prev = 16;
|
|
131
|
+
_context2.t1 = _context2["catch"](2);
|
|
132
|
+
console.log('🚀 ~ file: enable-2fa-flow.js:60 ~ error:', _context2.t1);
|
|
133
|
+
if (!(_context2.t1.code === 'auth/invalid-verification-code')) {
|
|
134
|
+
_context2.next = 24;
|
|
106
135
|
break;
|
|
107
136
|
}
|
|
108
137
|
setpopupError({
|
|
109
138
|
popup: 'enter2fa',
|
|
110
139
|
message: 'That’s not the right 2FA code. Try again'
|
|
111
140
|
});
|
|
112
|
-
return
|
|
141
|
+
return _context2.abrupt("return", {
|
|
113
142
|
otpInput: 'Invalid code'
|
|
114
143
|
});
|
|
115
144
|
case 24:
|
|
116
|
-
if (
|
|
145
|
+
if (_context2.t1.code === 'auth/requires-recent-login') {
|
|
117
146
|
onRequiresRecentLoginError && onRequiresRecentLoginError();
|
|
118
147
|
} else {
|
|
119
148
|
setpopupError({
|
|
120
149
|
popup: 'enter2fa',
|
|
121
|
-
message: "".concat(
|
|
150
|
+
message: "".concat(_context2.t1 !== null && _context2.t1 !== void 0 && _context2.t1.message ? _context2.t1 === null || _context2.t1 === void 0 ? void 0 : _context2.t1.message : 'Something went wrong. Try again?')
|
|
122
151
|
});
|
|
123
152
|
}
|
|
124
153
|
case 25:
|
|
125
154
|
case "end":
|
|
126
|
-
return
|
|
155
|
+
return _context2.stop();
|
|
127
156
|
}
|
|
128
|
-
},
|
|
157
|
+
}, _callee2, null, [[2, 16], [6, 11]]);
|
|
129
158
|
}));
|
|
130
159
|
return function onSubmit(_x) {
|
|
131
|
-
return
|
|
160
|
+
return _ref3.apply(this, arguments);
|
|
132
161
|
};
|
|
133
162
|
}();
|
|
134
163
|
var onBackButtonClick = function onBackButtonClick(stepController, prevStepIndex) {
|
|
@@ -23,14 +23,14 @@ var _excluded = ["onRequiresRecentLoginError", "open2faflow", "onLoginAgainClick
|
|
|
23
23
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
24
24
|
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); }
|
|
25
25
|
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; }
|
|
26
|
-
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 e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
27
|
-
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); } }
|
|
28
|
-
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); }); }; }
|
|
29
26
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
30
27
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
31
28
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
32
29
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
33
30
|
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
31
|
+
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 e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
32
|
+
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); } }
|
|
33
|
+
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); }); }; }
|
|
34
34
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
35
35
|
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."); }
|
|
36
36
|
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); }
|
|
@@ -48,7 +48,8 @@ var Main2FAFlow = function Main2FAFlow(_ref) {
|
|
|
48
48
|
var _useContext = (0, _react.useContext)(_AuthContext.AuthContext),
|
|
49
49
|
user = _useContext.user,
|
|
50
50
|
checkMfaEnrollment = _useContext.checkMfaEnrollment,
|
|
51
|
-
userMfaEnrollment = _useContext.userMfaEnrollment
|
|
51
|
+
userMfaEnrollment = _useContext.userMfaEnrollment,
|
|
52
|
+
generateTotpSecret = _useContext.generateTotpSecret;
|
|
52
53
|
var _useState = (0, _react.useState)({
|
|
53
54
|
enable2fa: open2faflow || false,
|
|
54
55
|
disable2fa: openDisable2faflow || false,
|
|
@@ -65,11 +66,20 @@ var Main2FAFlow = function Main2FAFlow(_ref) {
|
|
|
65
66
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
66
67
|
successMessage = _useState6[0],
|
|
67
68
|
setsuccessMessage = _useState6[1];
|
|
69
|
+
var _useState7 = (0, _react.useState)(false),
|
|
70
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
71
|
+
isLoginRequired = _useState8[0],
|
|
72
|
+
setisLoginRequired = _useState8[1];
|
|
73
|
+
var _useState9 = (0, _react.useState)(),
|
|
74
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
75
|
+
totpData = _useState10[0],
|
|
76
|
+
settotpData = _useState10[1];
|
|
68
77
|
(0, _react.useEffect)(function () {
|
|
69
|
-
if (userMfaEnrollment) {
|
|
70
|
-
|
|
78
|
+
if ((userMfaEnrollment === null || userMfaEnrollment === void 0 ? void 0 : userMfaEnrollment.length) > 0) {
|
|
79
|
+
setis2FAEnabled(true);
|
|
71
80
|
} else if (user) {
|
|
72
81
|
checkMfaEnrollment(user);
|
|
82
|
+
generateTotp();
|
|
73
83
|
}
|
|
74
84
|
}, [user, userMfaEnrollment]);
|
|
75
85
|
|
|
@@ -81,44 +91,76 @@ var Main2FAFlow = function Main2FAFlow(_ref) {
|
|
|
81
91
|
}, 5000);
|
|
82
92
|
}
|
|
83
93
|
}, [successMessage]);
|
|
94
|
+
var generateTotp = /*#__PURE__*/function () {
|
|
95
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
96
|
+
var response;
|
|
97
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
98
|
+
while (1) switch (_context.prev = _context.next) {
|
|
99
|
+
case 0:
|
|
100
|
+
_context.prev = 0;
|
|
101
|
+
_context.next = 3;
|
|
102
|
+
return generateTotpSecret(user);
|
|
103
|
+
case 3:
|
|
104
|
+
response = _context.sent;
|
|
105
|
+
console.log('🚀 ~ response:', response);
|
|
106
|
+
settotpData(response);
|
|
107
|
+
_context.next = 11;
|
|
108
|
+
break;
|
|
109
|
+
case 8:
|
|
110
|
+
_context.prev = 8;
|
|
111
|
+
_context.t0 = _context["catch"](0);
|
|
112
|
+
if (_context.t0.code === 'auth/requires-recent-login' || _context.t0.code === 'auth/unsupported-first-factor') {
|
|
113
|
+
setisLoginRequired(true);
|
|
114
|
+
// onRequiresRecentLoginError && onRequiresRecentLoginError()
|
|
115
|
+
}
|
|
116
|
+
case 11:
|
|
117
|
+
case "end":
|
|
118
|
+
return _context.stop();
|
|
119
|
+
}
|
|
120
|
+
}, _callee, null, [[0, 8]]);
|
|
121
|
+
}));
|
|
122
|
+
return function generateTotp() {
|
|
123
|
+
return _ref2.apply(this, arguments);
|
|
124
|
+
};
|
|
125
|
+
}();
|
|
84
126
|
var switchOpenFlow = function switchOpenFlow(prevFlowId, nextFlowId) {
|
|
85
127
|
var _objectSpread2;
|
|
86
128
|
setIsFlowOpen(_objectSpread(_objectSpread({}, isFlowopen), {}, (_objectSpread2 = {}, _defineProperty(_objectSpread2, prevFlowId, false), _defineProperty(_objectSpread2, nextFlowId, true), _objectSpread2)));
|
|
87
129
|
};
|
|
88
130
|
var onEnable2FASuccess = /*#__PURE__*/function () {
|
|
89
|
-
var
|
|
90
|
-
return _regeneratorRuntime().wrap(function
|
|
91
|
-
while (1) switch (
|
|
131
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
132
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
133
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
92
134
|
case 0:
|
|
93
135
|
setis2FAEnabled(true);
|
|
94
136
|
checkMfaEnrollment(user);
|
|
95
137
|
setsuccessMessage('Your log in 2FA authentication is now set');
|
|
96
138
|
case 3:
|
|
97
139
|
case "end":
|
|
98
|
-
return
|
|
140
|
+
return _context2.stop();
|
|
99
141
|
}
|
|
100
|
-
},
|
|
142
|
+
}, _callee2);
|
|
101
143
|
}));
|
|
102
144
|
return function onEnable2FASuccess() {
|
|
103
|
-
return
|
|
145
|
+
return _ref3.apply(this, arguments);
|
|
104
146
|
};
|
|
105
147
|
}();
|
|
106
148
|
var onDisable2FASuccess = /*#__PURE__*/function () {
|
|
107
|
-
var
|
|
108
|
-
return _regeneratorRuntime().wrap(function
|
|
109
|
-
while (1) switch (
|
|
149
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
150
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
151
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
110
152
|
case 0:
|
|
111
153
|
setis2FAEnabled(false);
|
|
112
154
|
checkMfaEnrollment(user);
|
|
113
155
|
setsuccessMessage('Your log in 2FA authentication is removed');
|
|
114
156
|
case 3:
|
|
115
157
|
case "end":
|
|
116
|
-
return
|
|
158
|
+
return _context3.stop();
|
|
117
159
|
}
|
|
118
|
-
},
|
|
160
|
+
}, _callee3);
|
|
119
161
|
}));
|
|
120
162
|
return function onDisable2FASuccess() {
|
|
121
|
-
return
|
|
163
|
+
return _ref4.apply(this, arguments);
|
|
122
164
|
};
|
|
123
165
|
}();
|
|
124
166
|
var onRequiresRecentLoginErrorHandler = function onRequiresRecentLoginErrorHandler() {
|
|
@@ -152,7 +194,14 @@ var Main2FAFlow = function Main2FAFlow(_ref) {
|
|
|
152
194
|
margin: 0
|
|
153
195
|
},
|
|
154
196
|
handleChange: function handleChange(value) {
|
|
155
|
-
if
|
|
197
|
+
//log in again is only if you try to set up 2fa, not disable it
|
|
198
|
+
if (isLoginRequired && value === 'disabled') {
|
|
199
|
+
setIsFlowOpen({
|
|
200
|
+
requiresRecentLogin: true,
|
|
201
|
+
enable2fa: false,
|
|
202
|
+
disable2fa: false
|
|
203
|
+
});
|
|
204
|
+
} else if (value === 'enabled') {
|
|
156
205
|
switchOpenFlow('disable2fa', 'enable2fa');
|
|
157
206
|
} else if (value === 'disabled') {
|
|
158
207
|
switchOpenFlow('enable2fa', 'disable2fa');
|
|
@@ -173,6 +222,7 @@ var Main2FAFlow = function Main2FAFlow(_ref) {
|
|
|
173
222
|
enable2fa: value
|
|
174
223
|
}));
|
|
175
224
|
},
|
|
225
|
+
totpData: totpData,
|
|
176
226
|
onRequiresRecentLoginError: onRequiresRecentLoginErrorHandler,
|
|
177
227
|
onSuccess: onEnable2FASuccess
|
|
178
228
|
}), isFlowopen.disable2fa && /*#__PURE__*/_react.default.createElement(_disable2faFlow.default, {
|
|
@@ -184,7 +234,23 @@ var Main2FAFlow = function Main2FAFlow(_ref) {
|
|
|
184
234
|
},
|
|
185
235
|
onRequiresRecentLoginError: onRequiresRecentLoginErrorHandler,
|
|
186
236
|
onSuccess: onDisable2FASuccess
|
|
187
|
-
}),
|
|
237
|
+
}), isFlowopen.requiresRecentLogin && /*#__PURE__*/_react.default.createElement(_Modal.Modal, {
|
|
238
|
+
isOpen: isFlowopen.requiresRecentLogin,
|
|
239
|
+
onClose: function onClose() {
|
|
240
|
+
return setIsFlowOpen(_objectSpread(_objectSpread({}, isFlowopen), {}, {
|
|
241
|
+
requiresRecentLogin: false
|
|
242
|
+
}));
|
|
243
|
+
}
|
|
244
|
+
}, /*#__PURE__*/_react.default.createElement(_Modal.ModalInner, {
|
|
245
|
+
noPadding: true
|
|
246
|
+
}, /*#__PURE__*/_react.default.createElement(_Sucess2FA.default, {
|
|
247
|
+
onClick: function onClick() {
|
|
248
|
+
onLoginAgainClick && onLoginAgainClick();
|
|
249
|
+
},
|
|
250
|
+
titleText: "LOG IN AGAIN",
|
|
251
|
+
subTitleLeft: "To enable your log in two factor authentication please log in again",
|
|
252
|
+
buttonText: "Log in again"
|
|
253
|
+
}))), !user && /*#__PURE__*/_react.default.createElement(_loginWithOtpFlow.default, null));
|
|
188
254
|
};
|
|
189
255
|
exports.Main2FAFlow = Main2FAFlow;
|
|
190
256
|
Main2FAFlow.propTypes = {
|
|
@@ -13,6 +13,11 @@ var _Select = require("./Select.styles");
|
|
|
13
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
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
15
|
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; }
|
|
16
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
17
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
18
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
19
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
20
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
16
21
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
17
22
|
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."); }
|
|
18
23
|
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); }
|
|
@@ -99,20 +104,35 @@ var Select = function Select(props) {
|
|
|
99
104
|
onChange: onChange,
|
|
100
105
|
onBlur: onBlur,
|
|
101
106
|
onFocus: onFocus,
|
|
102
|
-
value: options.find(function (option) {
|
|
107
|
+
value: options === null || options === void 0 ? void 0 : options.find(function (option) {
|
|
103
108
|
return option.value === value;
|
|
104
109
|
}),
|
|
105
110
|
placeholder: "",
|
|
106
111
|
isSearchable: search,
|
|
112
|
+
styles: {
|
|
113
|
+
control: function control() {
|
|
114
|
+
return _Select.SelectControl;
|
|
115
|
+
},
|
|
116
|
+
menu: function menu() {
|
|
117
|
+
return _Select.SelectMenu;
|
|
118
|
+
},
|
|
119
|
+
option: function option() {
|
|
120
|
+
return _Select.SelectOption;
|
|
121
|
+
},
|
|
122
|
+
selectContainer: function selectContainer() {
|
|
123
|
+
return _Select.SelectContainer;
|
|
124
|
+
},
|
|
125
|
+
valueContainer: function valueContainer(baseStyle) {
|
|
126
|
+
return _objectSpread(_objectSpread({}, baseStyle), {}, {
|
|
127
|
+
padding: 0,
|
|
128
|
+
marginLeft: '-2px'
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
},
|
|
107
132
|
components: {
|
|
108
|
-
Control: _Select.SelectControl,
|
|
109
133
|
DropdownIndicator: DropdownIndicator,
|
|
110
134
|
IndicatorSeparator: null,
|
|
111
|
-
|
|
112
|
-
MenuList: SelectMenuListWithScroll,
|
|
113
|
-
Option: _Select.SelectOption,
|
|
114
|
-
SelectContainer: _Select.SelectContainer,
|
|
115
|
-
ValueContainer: _Select.SelectValueContainer
|
|
135
|
+
MenuList: SelectMenuListWithScroll
|
|
116
136
|
}
|
|
117
137
|
}));
|
|
118
138
|
};
|
|
@@ -1,62 +1,51 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.SelectWrapper = exports.SelectValueContainer = exports.SelectOption = exports.SelectMenuList = exports.SelectMenu = exports.SelectIcon = exports.SelectControl = exports.SelectContainer = void 0;
|
|
7
|
-
var _styledComponents =
|
|
8
|
-
var _reactSelect = require("react-select");
|
|
8
|
+
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
9
9
|
var _ComponentScroll = require("../ComponentScroll/ComponentScroll.styles");
|
|
10
10
|
var _ComponentScroll2 = _interopRequireDefault(require("../ComponentScroll/ComponentScroll"));
|
|
11
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
|
11
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
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); }
|
|
14
|
+
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; }
|
|
15
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
16
|
+
var SelectControl = (0, _styledComponents.css)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n &&& {\n z-index: 10 !important;\n position: relative;\n display: flex;\n align-items: center;\n width: 100%;\n height: 40px;\n font-weight: 600;\n font-size: 12px;\n line-height: 18px;\n padding: 15px 0;\n padding-bottom: 5px;\n border-radius: 0;\n box-shadow: none;\n border: 0;\n border-top: 1px solid transparent;\n border-bottom: 1px solid #f0f0f0;\n color: #202020;\n background-color: transparent;\n transition: border-color 0.2s;\n cursor: pointer;\n\n &:hover {\n box-shadow: none;\n border-top-color: transparent;\n border-bottom-color: #0050ca;\n }\n\n &.active {\n z-index: 12 !important;\n }\n }\n"])));
|
|
16
17
|
exports.SelectControl = SelectControl;
|
|
17
|
-
var SelectMenu = (0, _styledComponents.
|
|
18
|
-
displayName: "Selectstyles__SelectMenu",
|
|
19
|
-
componentId: "sc-1wc1ybn-1"
|
|
20
|
-
})(["&&&{margin-top:-1px;border-radius:0;box-shadow:none;border:0;border-top:1px solid #f0f0f0 !important;border-bottom:1px solid #f0f0f0 !important;background-color:#ffffff;}"]);
|
|
18
|
+
var SelectMenu = (0, _styledComponents.css)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n &&& {\n margin-top: -1px;\n border-radius: 0;\n box-shadow: none;\n border: 0;\n border-top: 1px solid #f0f0f0 !important;\n border-bottom: 1px solid #f0f0f0 !important;\n background-color: #ffffff;\n }\n"])));
|
|
21
19
|
exports.SelectMenu = SelectMenu;
|
|
22
20
|
var SelectMenuList = (0, _styledComponents.default)(_ComponentScroll2.default).withConfig({
|
|
23
21
|
displayName: "Selectstyles__SelectMenuList",
|
|
24
|
-
componentId: "sc-1wc1ybn-
|
|
22
|
+
componentId: "sc-1wc1ybn-0"
|
|
25
23
|
})(["", "{right:6px;}"], _ComponentScroll.TrackV);
|
|
26
24
|
exports.SelectMenuList = SelectMenuList;
|
|
27
|
-
var SelectOption = (0, _styledComponents.
|
|
28
|
-
displayName: "Selectstyles__SelectOption",
|
|
29
|
-
componentId: "sc-1wc1ybn-3"
|
|
30
|
-
})(["&&&{cursor:pointer;padding:8px 0 !important;padding-left:2px !important;font-size:12px;line-height:18px;border:0;background-color:transparent;color:#202020;", " ", " &:hover{background-color:transparent;font-weight:bold;}}"], function (props) {
|
|
25
|
+
var SelectOption = (0, _styledComponents.css)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n &&& {\n cursor: pointer;\n padding: 8px 0 !important;\n padding-left: 2px !important;\n font-size: 12px;\n line-height: 18px;\n border: 0;\n background-color: transparent;\n color: #202020;\n\n ", "\n\n ", "\n\n &:hover {\n background-color: transparent;\n font-weight: bold;\n }\n }\n"])), function (props) {
|
|
31
26
|
return props.isFocused && "\n font-weight: bold;\n ";
|
|
32
27
|
}, function (props) {
|
|
33
28
|
return props.isSelected && "\n font-weight: bold;\n ";
|
|
34
29
|
});
|
|
35
30
|
exports.SelectOption = SelectOption;
|
|
36
|
-
var SelectContainer = (0, _styledComponents.
|
|
37
|
-
displayName: "Selectstyles__SelectContainer",
|
|
38
|
-
componentId: "sc-1wc1ybn-4"
|
|
39
|
-
})(["z-index:100;", ""], function (props) {
|
|
31
|
+
var SelectContainer = (0, _styledComponents.css)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n z-index: 100;\n ", "\n"])), function (props) {
|
|
40
32
|
return props.selectProps.menuIsOpen && "\n z-index: 150 !important;\n ";
|
|
41
33
|
});
|
|
42
34
|
exports.SelectContainer = SelectContainer;
|
|
43
|
-
var SelectValueContainer = (0, _styledComponents.
|
|
44
|
-
displayName: "Selectstyles__SelectValueContainer",
|
|
45
|
-
componentId: "sc-1wc1ybn-5"
|
|
46
|
-
})(["&&&{font-family:'Open sans';padding:0;margin-left:-2px;top:-4px;}"]);
|
|
35
|
+
var SelectValueContainer = (0, _styledComponents.css)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n &&& {\n font-family: 'Open sans';\n padding: 0;\n margin-left: -2px;\n top: -4px;\n }\n"])));
|
|
47
36
|
exports.SelectValueContainer = SelectValueContainer;
|
|
48
37
|
var SelectIcon = _styledComponents.default.i.attrs({
|
|
49
38
|
className: 'ion ion-ios-arrow-down'
|
|
50
39
|
}).withConfig({
|
|
51
40
|
displayName: "Selectstyles__SelectIcon",
|
|
52
|
-
componentId: "sc-1wc1ybn-
|
|
41
|
+
componentId: "sc-1wc1ybn-1"
|
|
53
42
|
})(["&&&{transition:0.3s transform;transform:rotate(0);", "}"], function (props) {
|
|
54
43
|
return props.isMenuOpen && "\n transform: rotate(180deg);\n ";
|
|
55
44
|
});
|
|
56
45
|
exports.SelectIcon = SelectIcon;
|
|
57
46
|
var SelectWrapper = _styledComponents.default.div.withConfig({
|
|
58
47
|
displayName: "Selectstyles__SelectWrapper",
|
|
59
|
-
componentId: "sc-1wc1ybn-
|
|
48
|
+
componentId: "sc-1wc1ybn-2"
|
|
60
49
|
})(["display:inline-block;vertical-align:middle;margin-left:24px;", " ", " &&& ", "{height:24px;font-weight:normal;font-size:11px;line-height:18px;padding:3px 0;border-top:1px solid transparent;border-bottom:1px solid transparent;}&&& ", "{left:0;right:0;width:auto;margin:-6px -12px;margin-top:0;box-shadow:0 1px 4px 0 rgba(0,0,0,0.2);border:0;padding:6px 12px;}&&& ", "{top:0;}"], function (props) {
|
|
61
50
|
return props.minWidth && "\n min-width: ".concat(props.minWidth, ";\n ");
|
|
62
51
|
}, function (props) {
|
package/dist/context/Auth.js
CHANGED
|
@@ -153,6 +153,20 @@ var Auth = /*#__PURE__*/function () {
|
|
|
153
153
|
});
|
|
154
154
|
});
|
|
155
155
|
}
|
|
156
|
+
}, {
|
|
157
|
+
key: "refreshIdToken",
|
|
158
|
+
value: function refreshIdToken() {
|
|
159
|
+
return new Promise(function (resolve, reject) {
|
|
160
|
+
var user = _firebaseConfig.auth.currentUser;
|
|
161
|
+
if (!user) reject('User not available');
|
|
162
|
+
user.getIdToken(true).then(function (idToken) {
|
|
163
|
+
console.log('Token refreshed');
|
|
164
|
+
resolve(idToken);
|
|
165
|
+
}).catch(function (error) {
|
|
166
|
+
reject(error);
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
}
|
|
156
170
|
}, {
|
|
157
171
|
key: "signInWithToken",
|
|
158
172
|
value: function signInWithToken(token) {
|
|
@@ -102,7 +102,7 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
|
|
|
102
102
|
_context.t0 = _context["catch"](0);
|
|
103
103
|
console.log('🚀 ~ file: AuthContext.js:56 ~ error:', _context.t0);
|
|
104
104
|
_context.t1 = _context.t0.code;
|
|
105
|
-
_context.next = _context.t1 === 'auth/multi-factor-auth-required' ? 21 : _context.t1 === 'auth/requires-recent-login' ? 23 : _context.t1 === 'auth/invalid-login-credentials' ? 25 : 27;
|
|
105
|
+
_context.next = _context.t1 === 'auth/multi-factor-auth-required' ? 21 : _context.t1 === 'auth/requires-recent-login' ? 23 : _context.t1 === 'auth/invalid-login-credentials' ? 25 : _context.t1 === 'auth/invalid-credential' ? 25 : 27;
|
|
106
106
|
break;
|
|
107
107
|
case 21:
|
|
108
108
|
_this.setState({
|
|
@@ -217,7 +217,6 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
|
|
|
217
217
|
multiFactorSession,
|
|
218
218
|
totpSecret,
|
|
219
219
|
totpUri,
|
|
220
|
-
secret,
|
|
221
220
|
_args4 = arguments;
|
|
222
221
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
223
222
|
while (1) switch (_context4.prev = _context4.next) {
|
|
@@ -232,22 +231,21 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
|
|
|
232
231
|
return _auth.TotpMultiFactorGenerator.generateSecret(multiFactorSession);
|
|
233
232
|
case 7:
|
|
234
233
|
totpSecret = _context4.sent;
|
|
235
|
-
totpUri = totpSecret.generateQrCodeUrl(user.email, appName);
|
|
236
|
-
secret = totpSecret.secretKey;
|
|
234
|
+
totpUri = totpSecret.generateQrCodeUrl(user.email, appName);
|
|
237
235
|
return _context4.abrupt("return", {
|
|
238
236
|
totpUri: totpUri,
|
|
239
237
|
totpSecret: totpSecret
|
|
240
238
|
});
|
|
241
|
-
case
|
|
242
|
-
_context4.prev =
|
|
239
|
+
case 12:
|
|
240
|
+
_context4.prev = 12;
|
|
243
241
|
_context4.t0 = _context4["catch"](1);
|
|
244
242
|
console.log('🚀 ~ file: AuthContext.js:51 ~ error:', _context4.t0);
|
|
245
243
|
throw _context4.t0;
|
|
246
|
-
case
|
|
244
|
+
case 16:
|
|
247
245
|
case "end":
|
|
248
246
|
return _context4.stop();
|
|
249
247
|
}
|
|
250
|
-
}, _callee4, null, [[1,
|
|
248
|
+
}, _callee4, null, [[1, 12]]);
|
|
251
249
|
}));
|
|
252
250
|
return function (_x8) {
|
|
253
251
|
return _ref4.apply(this, arguments);
|
|
@@ -1013,7 +1011,8 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
|
|
|
1013
1011
|
updateFirebaseUser: _Auth.default.updateFirebaseUser,
|
|
1014
1012
|
handleResetPassword: this.handleResetPassword,
|
|
1015
1013
|
handleVerifyEmail: this.handleVerifyEmail,
|
|
1016
|
-
setUser: this.setUser
|
|
1014
|
+
setUser: this.setUser,
|
|
1015
|
+
refreshIdToken: _Auth.default.refreshIdToken
|
|
1017
1016
|
})
|
|
1018
1017
|
}, children);
|
|
1019
1018
|
}
|