acsi-core 0.1.92 → 0.1.95
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/index.js +32 -181
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +33 -182
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -13,10 +13,10 @@ var ReactSelect = require('react-select');
|
|
|
13
13
|
var ReactSelect__default = _interopDefault(ReactSelect);
|
|
14
14
|
var Cookies = _interopDefault(require('js-cookie'));
|
|
15
15
|
var moment = _interopDefault(require('moment'));
|
|
16
|
-
var msalBrowser = require('@azure/msal-browser');
|
|
17
16
|
var reactToastify = require('react-toastify');
|
|
18
17
|
var reactGoogleLogin = require('@leecheuk/react-google-login');
|
|
19
18
|
var material = require('@mui/material');
|
|
19
|
+
require('@azure/msal-browser');
|
|
20
20
|
var amplitude = require('@amplitude/analytics-browser');
|
|
21
21
|
var Sentry = require('@sentry/react');
|
|
22
22
|
var fa = require('react-icons/fa');
|
|
@@ -80,25 +80,6 @@ var ORGANIZATION_TEAM = "ORGANIZATION_TEAM";
|
|
|
80
80
|
|
|
81
81
|
var styleGlobal = {"signup_wrap":"_1KLz9","box-signin":"_2Jo1o","signin_title":"_3egBO","signup_link":"_1DoIT","google_button":"_34hK_","microsoft_button":"_19ESb","box-field":"_2e9xO","box-input":"_3zXRp","box-text":"_8NJga","box-button-email":"_21FPk","box-signin-container":"_1QERu","box-signin-text":"_2-znH","box-signin-logo":"_1aB2m","box-right":"_3qndF","image-slideshow":"_1aM7m","active":"_Vx1zf","box-right-body":"_JzdCr","box-right-footer":"_19aCA","pr-30":"_2HB5r","width-400":"_4ehXP"};
|
|
82
82
|
|
|
83
|
-
function _extends() {
|
|
84
|
-
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
85
|
-
for (var e = 1; e < arguments.length; e++) {
|
|
86
|
-
var t = arguments[e];
|
|
87
|
-
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
88
|
-
}
|
|
89
|
-
return n;
|
|
90
|
-
}, _extends.apply(null, arguments);
|
|
91
|
-
}
|
|
92
|
-
function _objectWithoutPropertiesLoose(r, e) {
|
|
93
|
-
if (null == r) return {};
|
|
94
|
-
var t = {};
|
|
95
|
-
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
96
|
-
if (-1 !== e.indexOf(n)) continue;
|
|
97
|
-
t[n] = r[n];
|
|
98
|
-
}
|
|
99
|
-
return t;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
83
|
// A type of promise-like that resolves synchronously and supports only one observer
|
|
103
84
|
|
|
104
85
|
const _iteratorSymbol = /*#__PURE__*/ typeof Symbol !== "undefined" ? (Symbol.iterator || (Symbol.iterator = Symbol("Symbol.iterator"))) : "@@iterator";
|
|
@@ -118,6 +99,25 @@ function _catch(body, recover) {
|
|
|
118
99
|
return result;
|
|
119
100
|
}
|
|
120
101
|
|
|
102
|
+
function _extends() {
|
|
103
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
104
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
105
|
+
var t = arguments[e];
|
|
106
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
107
|
+
}
|
|
108
|
+
return n;
|
|
109
|
+
}, _extends.apply(null, arguments);
|
|
110
|
+
}
|
|
111
|
+
function _objectWithoutPropertiesLoose(r, e) {
|
|
112
|
+
if (null == r) return {};
|
|
113
|
+
var t = {};
|
|
114
|
+
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
115
|
+
if (-1 !== e.indexOf(n)) continue;
|
|
116
|
+
t[n] = r[n];
|
|
117
|
+
}
|
|
118
|
+
return t;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
121
|
var styles = {"core-button":"_xvNBN","primary":"_U9Qyp","secondary":"_1VzMy","text":"_pZNuj","danger":"_2uYm1","light":"_wxH5S"};
|
|
122
122
|
|
|
123
123
|
var _excluded = ["type", "children", "onClick", "icon", "disabled", "htmlType"];
|
|
@@ -1223,55 +1223,6 @@ var TypeLogin;
|
|
|
1223
1223
|
TypeLogin[TypeLogin["Microsoft"] = 3] = "Microsoft";
|
|
1224
1224
|
})(TypeLogin || (TypeLogin = {}));
|
|
1225
1225
|
|
|
1226
|
-
var AuthenticationMessage;
|
|
1227
|
-
(function (AuthenticationMessage) {
|
|
1228
|
-
AuthenticationMessage["NotAllowedToRegister"] = "NotAllowedToRegister";
|
|
1229
|
-
AuthenticationMessage["InvalidGoogleToken"] = "InvalidGoogleToken";
|
|
1230
|
-
})(AuthenticationMessage || (AuthenticationMessage = {}));
|
|
1231
|
-
(function (Role) {
|
|
1232
|
-
Role["Student"] = "Student";
|
|
1233
|
-
Role["Teacher"] = "Teacher";
|
|
1234
|
-
Role["Admin"] = "Admin";
|
|
1235
|
-
})(exports.Role || (exports.Role = {}));
|
|
1236
|
-
var msalConfig = function msalConfig(clientId, redirectUri) {
|
|
1237
|
-
return {
|
|
1238
|
-
auth: {
|
|
1239
|
-
clientId: clientId,
|
|
1240
|
-
authority: "https://login.microsoftonline.com/common",
|
|
1241
|
-
redirectUri: redirectUri
|
|
1242
|
-
},
|
|
1243
|
-
cache: {
|
|
1244
|
-
cacheLocation: "sessionStorage",
|
|
1245
|
-
storeAuthStateInCookie: false
|
|
1246
|
-
},
|
|
1247
|
-
system: {
|
|
1248
|
-
loggerOptions: {
|
|
1249
|
-
loggerCallback: function loggerCallback(level, message, containsPii) {
|
|
1250
|
-
if (containsPii) {
|
|
1251
|
-
return;
|
|
1252
|
-
}
|
|
1253
|
-
switch (level) {
|
|
1254
|
-
case msalBrowser.LogLevel.Error:
|
|
1255
|
-
console.error(message);
|
|
1256
|
-
return;
|
|
1257
|
-
case msalBrowser.LogLevel.Info:
|
|
1258
|
-
console.info(message);
|
|
1259
|
-
return;
|
|
1260
|
-
case msalBrowser.LogLevel.Verbose:
|
|
1261
|
-
console.debug(message);
|
|
1262
|
-
return;
|
|
1263
|
-
case msalBrowser.LogLevel.Warning:
|
|
1264
|
-
console.warn(message);
|
|
1265
|
-
return;
|
|
1266
|
-
default:
|
|
1267
|
-
return;
|
|
1268
|
-
}
|
|
1269
|
-
}
|
|
1270
|
-
}
|
|
1271
|
-
}
|
|
1272
|
-
};
|
|
1273
|
-
};
|
|
1274
|
-
|
|
1275
1226
|
var BlockLogin = function BlockLogin(_ref) {
|
|
1276
1227
|
var onNavigate = _ref.onNavigate,
|
|
1277
1228
|
role = _ref.role,
|
|
@@ -1302,9 +1253,6 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
|
1302
1253
|
var _useState5 = React.useState(0),
|
|
1303
1254
|
currentImageIndex = _useState5[0],
|
|
1304
1255
|
setCurrentImageIndex = _useState5[1];
|
|
1305
|
-
var _useState6 = React.useState(),
|
|
1306
|
-
msalInstance = _useState6[0],
|
|
1307
|
-
setMsalInstance = _useState6[1];
|
|
1308
1256
|
var handleGetImage = function handleGetImage() {
|
|
1309
1257
|
try {
|
|
1310
1258
|
var _temp = _catch(function () {
|
|
@@ -1409,91 +1357,6 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
|
1409
1357
|
return console.log(errorResponse);
|
|
1410
1358
|
}
|
|
1411
1359
|
});
|
|
1412
|
-
var fnLoginMicrosoft = function fnLoginMicrosoft() {
|
|
1413
|
-
try {
|
|
1414
|
-
if (!msalInstance) {
|
|
1415
|
-
console.error("MSAL instance not initialized");
|
|
1416
|
-
return Promise.resolve();
|
|
1417
|
-
}
|
|
1418
|
-
return Promise.resolve(_catch(function () {
|
|
1419
|
-
return Promise.resolve(msalInstance.initialize()).then(function () {
|
|
1420
|
-
var loginRequest = {
|
|
1421
|
-
scopes: ["openid", "profile", "email"]
|
|
1422
|
-
};
|
|
1423
|
-
var silentRequest = _extends({}, loginRequest, {
|
|
1424
|
-
prompt: "select_account"
|
|
1425
|
-
});
|
|
1426
|
-
return Promise.resolve(msalInstance.loginPopup(silentRequest)).then(function (response) {
|
|
1427
|
-
return function () {
|
|
1428
|
-
if (response && response.account) {
|
|
1429
|
-
var account = response.account;
|
|
1430
|
-
var fullName = (account === null || account === void 0 ? void 0 : account.name) || "";
|
|
1431
|
-
var infoLogin = {
|
|
1432
|
-
firstName: fullName.split(' ').slice(0, -1).join(' '),
|
|
1433
|
-
lastName: fullName.split(' ').slice(-1).join(' '),
|
|
1434
|
-
fullName: fullName,
|
|
1435
|
-
imageUrl: "",
|
|
1436
|
-
email: (account === null || account === void 0 ? void 0 : account.username) || "",
|
|
1437
|
-
token: (response === null || response === void 0 ? void 0 : response.accessToken) || "",
|
|
1438
|
-
googleId: (account === null || account === void 0 ? void 0 : account.homeAccountId) || "",
|
|
1439
|
-
role: role,
|
|
1440
|
-
type: TypeLogin.Microsoft
|
|
1441
|
-
};
|
|
1442
|
-
dispatch(setLoading(true));
|
|
1443
|
-
return Promise.resolve(apiLoginGoogle(infoLogin)).then(function (authResult) {
|
|
1444
|
-
var _authResult$data2;
|
|
1445
|
-
if (((_authResult$data2 = authResult.data) === null || _authResult$data2 === void 0 ? void 0 : _authResult$data2.id) == null) {
|
|
1446
|
-
dispatch(setLoading(false));
|
|
1447
|
-
alert("Please contact admin.");
|
|
1448
|
-
return;
|
|
1449
|
-
}
|
|
1450
|
-
localStorage.clear();
|
|
1451
|
-
var tokenJWT = authResult.data.token;
|
|
1452
|
-
trackEvent === null || trackEvent === void 0 ? void 0 : trackEvent({
|
|
1453
|
-
eventName: exports.AmplitudeEvent.LOGIN,
|
|
1454
|
-
eventProperties: {
|
|
1455
|
-
email: email,
|
|
1456
|
-
login_method: 'google',
|
|
1457
|
-
user_role: authResult.data.role,
|
|
1458
|
-
success: true,
|
|
1459
|
-
timestamp: new Date().toISOString()
|
|
1460
|
-
}
|
|
1461
|
-
});
|
|
1462
|
-
if (role === "LandingPage") {
|
|
1463
|
-
CookieService.setAuthCookie({
|
|
1464
|
-
token: tokenJWT,
|
|
1465
|
-
expiresAt: Date.now() + 24 * 60 * 60 * 1000
|
|
1466
|
-
});
|
|
1467
|
-
var getRedirectUrl = function getRedirectUrl(role) {
|
|
1468
|
-
switch (role) {
|
|
1469
|
-
case "Admin":
|
|
1470
|
-
return ADMIN_ORIGIN;
|
|
1471
|
-
case "Teacher":
|
|
1472
|
-
return TEACHER_ORIGIN;
|
|
1473
|
-
default:
|
|
1474
|
-
return role + "." + REQUEST_ORIGIN;
|
|
1475
|
-
}
|
|
1476
|
-
};
|
|
1477
|
-
var redirectUrl = getRedirectUrl(authResult.data.role);
|
|
1478
|
-
window.location.href = redirectUrl + "/dashboard";
|
|
1479
|
-
dispatch(setLoading(false));
|
|
1480
|
-
}
|
|
1481
|
-
localStorage.setItem(ACCESS_TOKEN, tokenJWT);
|
|
1482
|
-
onNavigate("/dashboard");
|
|
1483
|
-
dispatch(setLoading(false));
|
|
1484
|
-
});
|
|
1485
|
-
}
|
|
1486
|
-
}();
|
|
1487
|
-
});
|
|
1488
|
-
});
|
|
1489
|
-
}, function (error) {
|
|
1490
|
-
console.error("Microsoft login error:", error);
|
|
1491
|
-
alert("Microsoft login failed. Please try again.");
|
|
1492
|
-
}));
|
|
1493
|
-
} catch (e) {
|
|
1494
|
-
return Promise.reject(e);
|
|
1495
|
-
}
|
|
1496
|
-
};
|
|
1497
1360
|
React__default.useEffect(function () {
|
|
1498
1361
|
return function () {
|
|
1499
1362
|
if (resendTimer) {
|
|
@@ -1558,18 +1421,6 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
|
1558
1421
|
return clearInterval(interval);
|
|
1559
1422
|
};
|
|
1560
1423
|
}, [images.length]);
|
|
1561
|
-
var initInformationSSO = function initInformationSSO() {
|
|
1562
|
-
try {
|
|
1563
|
-
var _msalInstance = new msalBrowser.PublicClientApplication(msalConfig(MICROSOFT_CLIENT_ID, MICROSOFT_URL_DIRECT));
|
|
1564
|
-
setMsalInstance(_msalInstance);
|
|
1565
|
-
return Promise.resolve();
|
|
1566
|
-
} catch (e) {
|
|
1567
|
-
return Promise.reject(e);
|
|
1568
|
-
}
|
|
1569
|
-
};
|
|
1570
|
-
React.useEffect(function () {
|
|
1571
|
-
initInformationSSO();
|
|
1572
|
-
}, []);
|
|
1573
1424
|
return React__default.createElement(React__default.Fragment, null, React__default.createElement(reactstrap.Row, {
|
|
1574
1425
|
style: {
|
|
1575
1426
|
height: "100%"
|
|
@@ -1613,18 +1464,7 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
|
1613
1464
|
height: 24,
|
|
1614
1465
|
alt: "Google sign-in",
|
|
1615
1466
|
src: "/images/icons/Google__G__logo.png"
|
|
1616
|
-
}), "Sign in with Google")), React__default.createElement("
|
|
1617
|
-
className: "" + styleGlobal["microsoft_button"]
|
|
1618
|
-
}, React__default.createElement("button", {
|
|
1619
|
-
onClick: function onClick() {
|
|
1620
|
-
return fnLoginMicrosoft();
|
|
1621
|
-
}
|
|
1622
|
-
}, React__default.createElement("img", {
|
|
1623
|
-
width: 24,
|
|
1624
|
-
height: 24,
|
|
1625
|
-
alt: "Google sign-in",
|
|
1626
|
-
src: "/images/Single-Sign-On-logo.png"
|
|
1627
|
-
}), "Sign in with Microsoft")), React__default.createElement("span", {
|
|
1467
|
+
}), "Sign in with Google")), React__default.createElement("span", {
|
|
1628
1468
|
className: "" + styleGlobal["box-field"]
|
|
1629
1469
|
}, "OR"), React__default.createElement("div", {
|
|
1630
1470
|
className: "" + styleGlobal["box-input"]
|
|
@@ -2454,6 +2294,17 @@ var CommonDialog = function CommonDialog(_ref) {
|
|
|
2454
2294
|
}, title)), children);
|
|
2455
2295
|
};
|
|
2456
2296
|
|
|
2297
|
+
var AuthenticationMessage;
|
|
2298
|
+
(function (AuthenticationMessage) {
|
|
2299
|
+
AuthenticationMessage["NotAllowedToRegister"] = "NotAllowedToRegister";
|
|
2300
|
+
AuthenticationMessage["InvalidGoogleToken"] = "InvalidGoogleToken";
|
|
2301
|
+
})(AuthenticationMessage || (AuthenticationMessage = {}));
|
|
2302
|
+
(function (Role) {
|
|
2303
|
+
Role["Student"] = "Student";
|
|
2304
|
+
Role["Teacher"] = "Teacher";
|
|
2305
|
+
Role["Admin"] = "Admin";
|
|
2306
|
+
})(exports.Role || (exports.Role = {}));
|
|
2307
|
+
|
|
2457
2308
|
var CustomPagination = function CustomPagination(_ref) {
|
|
2458
2309
|
var currentPage = _ref.currentPage,
|
|
2459
2310
|
totalPage = _ref.totalPage,
|