acsi-core 1.0.0 → 1.1.1
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/containers/Login/apiClient/index.d.ts +5 -5
- package/dist/index.js +180 -38
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +181 -39
- package/dist/index.modern.js.map +1 -1
- package/dist/services/accountService.d.ts +6 -6
- package/dist/utils/constants.d.ts +1 -0
- package/dist/utils/timeSpanToLocalMoment.d.ts +2 -2
- package/package.json +2 -1
- package/dist/components/MarkdownLatexRender/MarkdownLatexRender.d.ts +0 -7
package/dist/index.modern.js
CHANGED
|
@@ -18,15 +18,16 @@ import 'katex/dist/katex.min.css';
|
|
|
18
18
|
import Cookies from 'js-cookie';
|
|
19
19
|
export { default as Cookies } from 'js-cookie';
|
|
20
20
|
import moment from 'moment';
|
|
21
|
+
import { LogLevel, PublicClientApplication } from '@azure/msal-browser';
|
|
21
22
|
import { toast } from 'react-toastify';
|
|
22
23
|
export { ToastContainer, toast } from 'react-toastify';
|
|
23
24
|
import { useGoogleLogout } from '@leecheuk/react-google-login';
|
|
24
25
|
import { Box, Typography } from '@mui/material';
|
|
25
|
-
import '@azure/msal-browser';
|
|
26
26
|
import { Identify, identify, track, setUserId, reset as reset$1, init } from '@amplitude/analytics-browser';
|
|
27
27
|
import { init as init$1, replayIntegration } from '@sentry/react';
|
|
28
28
|
import { FaCaretDown } from 'react-icons/fa';
|
|
29
29
|
import CreatableSelect from 'react-select/creatable';
|
|
30
|
+
import moment$1 from 'moment-timezone';
|
|
30
31
|
|
|
31
32
|
var setLoading = createAction("common/setLoading");
|
|
32
33
|
var setLoadingPage = createAction("common/setLoadingPage");
|
|
@@ -56,6 +57,7 @@ var PUSHER_CONFIG = {
|
|
|
56
57
|
};
|
|
57
58
|
var MICROSOFT_CLIENT_ID = process.env.REACT_APP_MICROSOFT_CLIENT_ID || "";
|
|
58
59
|
var MICROSOFT_URL_DIRECT = process.env.REACT_APP_MICROSOFT_URL_DIRECT || "";
|
|
60
|
+
var MICROSOFT_SSO_ENABLED = process.env.REACT_APP_MICROSOFT_SSO_ENABLED || "false";
|
|
59
61
|
var OPENSALT_BASE_URL = process.env.REACT_APP_OPENSALT || "";
|
|
60
62
|
var ACCESS_TOKEN = "ACCESS_TOKEN";
|
|
61
63
|
var AUTH_COOKIE = "auth";
|
|
@@ -87,25 +89,6 @@ var ORGANIZATION_TEAM = "ORGANIZATION_TEAM";
|
|
|
87
89
|
|
|
88
90
|
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"};
|
|
89
91
|
|
|
90
|
-
// A type of promise-like that resolves synchronously and supports only one observer
|
|
91
|
-
|
|
92
|
-
const _iteratorSymbol = /*#__PURE__*/ typeof Symbol !== "undefined" ? (Symbol.iterator || (Symbol.iterator = Symbol("Symbol.iterator"))) : "@@iterator";
|
|
93
|
-
|
|
94
|
-
const _asyncIteratorSymbol = /*#__PURE__*/ typeof Symbol !== "undefined" ? (Symbol.asyncIterator || (Symbol.asyncIterator = Symbol("Symbol.asyncIterator"))) : "@@asyncIterator";
|
|
95
|
-
|
|
96
|
-
// Asynchronously call a function and send errors to recovery continuation
|
|
97
|
-
function _catch(body, recover) {
|
|
98
|
-
try {
|
|
99
|
-
var result = body();
|
|
100
|
-
} catch(e) {
|
|
101
|
-
return recover(e);
|
|
102
|
-
}
|
|
103
|
-
if (result && result.then) {
|
|
104
|
-
return result.then(void 0, recover);
|
|
105
|
-
}
|
|
106
|
-
return result;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
92
|
function _arrayLikeToArray(r, a) {
|
|
110
93
|
(null == a || a > r.length) && (a = r.length);
|
|
111
94
|
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
@@ -154,6 +137,25 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
154
137
|
}
|
|
155
138
|
}
|
|
156
139
|
|
|
140
|
+
// A type of promise-like that resolves synchronously and supports only one observer
|
|
141
|
+
|
|
142
|
+
const _iteratorSymbol = /*#__PURE__*/ typeof Symbol !== "undefined" ? (Symbol.iterator || (Symbol.iterator = Symbol("Symbol.iterator"))) : "@@iterator";
|
|
143
|
+
|
|
144
|
+
const _asyncIteratorSymbol = /*#__PURE__*/ typeof Symbol !== "undefined" ? (Symbol.asyncIterator || (Symbol.asyncIterator = Symbol("Symbol.asyncIterator"))) : "@@asyncIterator";
|
|
145
|
+
|
|
146
|
+
// Asynchronously call a function and send errors to recovery continuation
|
|
147
|
+
function _catch(body, recover) {
|
|
148
|
+
try {
|
|
149
|
+
var result = body();
|
|
150
|
+
} catch(e) {
|
|
151
|
+
return recover(e);
|
|
152
|
+
}
|
|
153
|
+
if (result && result.then) {
|
|
154
|
+
return result.then(void 0, recover);
|
|
155
|
+
}
|
|
156
|
+
return result;
|
|
157
|
+
}
|
|
158
|
+
|
|
157
159
|
var styles = {"core-button":"_xvNBN","primary":"_U9Qyp","secondary":"_1VzMy","text":"_pZNuj","danger":"_2uYm1","light":"_wxH5S"};
|
|
158
160
|
|
|
159
161
|
var _excluded = ["type", "children", "onClick", "icon", "disabled", "htmlType"];
|
|
@@ -1746,6 +1748,56 @@ var TypeLogin;
|
|
|
1746
1748
|
TypeLogin[TypeLogin["Microsoft"] = 3] = "Microsoft";
|
|
1747
1749
|
})(TypeLogin || (TypeLogin = {}));
|
|
1748
1750
|
|
|
1751
|
+
var AuthenticationMessage;
|
|
1752
|
+
(function (AuthenticationMessage) {
|
|
1753
|
+
AuthenticationMessage["NotAllowedToRegister"] = "NotAllowedToRegister";
|
|
1754
|
+
AuthenticationMessage["InvalidGoogleToken"] = "InvalidGoogleToken";
|
|
1755
|
+
})(AuthenticationMessage || (AuthenticationMessage = {}));
|
|
1756
|
+
var Role;
|
|
1757
|
+
(function (Role) {
|
|
1758
|
+
Role["Student"] = "Student";
|
|
1759
|
+
Role["Teacher"] = "Teacher";
|
|
1760
|
+
Role["Admin"] = "Admin";
|
|
1761
|
+
})(Role || (Role = {}));
|
|
1762
|
+
var msalConfig = function msalConfig(clientId, redirectUri) {
|
|
1763
|
+
return {
|
|
1764
|
+
auth: {
|
|
1765
|
+
clientId: clientId,
|
|
1766
|
+
authority: "https://login.microsoftonline.com/common",
|
|
1767
|
+
redirectUri: redirectUri
|
|
1768
|
+
},
|
|
1769
|
+
cache: {
|
|
1770
|
+
cacheLocation: "sessionStorage",
|
|
1771
|
+
storeAuthStateInCookie: false
|
|
1772
|
+
},
|
|
1773
|
+
system: {
|
|
1774
|
+
loggerOptions: {
|
|
1775
|
+
loggerCallback: function loggerCallback(level, message, containsPii) {
|
|
1776
|
+
if (containsPii) {
|
|
1777
|
+
return;
|
|
1778
|
+
}
|
|
1779
|
+
switch (level) {
|
|
1780
|
+
case LogLevel.Error:
|
|
1781
|
+
console.error(message);
|
|
1782
|
+
return;
|
|
1783
|
+
case LogLevel.Info:
|
|
1784
|
+
console.info(message);
|
|
1785
|
+
return;
|
|
1786
|
+
case LogLevel.Verbose:
|
|
1787
|
+
console.debug(message);
|
|
1788
|
+
return;
|
|
1789
|
+
case LogLevel.Warning:
|
|
1790
|
+
console.warn(message);
|
|
1791
|
+
return;
|
|
1792
|
+
default:
|
|
1793
|
+
return;
|
|
1794
|
+
}
|
|
1795
|
+
}
|
|
1796
|
+
}
|
|
1797
|
+
}
|
|
1798
|
+
};
|
|
1799
|
+
};
|
|
1800
|
+
|
|
1749
1801
|
var BlockLogin = function BlockLogin(_ref) {
|
|
1750
1802
|
var onNavigate = _ref.onNavigate,
|
|
1751
1803
|
role = _ref.role,
|
|
@@ -1880,6 +1932,91 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
|
1880
1932
|
return console.log(errorResponse);
|
|
1881
1933
|
}
|
|
1882
1934
|
});
|
|
1935
|
+
var fnLoginMicrosoft = function fnLoginMicrosoft() {
|
|
1936
|
+
try {
|
|
1937
|
+
var msalInstance = new PublicClientApplication(msalConfig(MICROSOFT_CLIENT_ID, MICROSOFT_URL_DIRECT));
|
|
1938
|
+
if (!msalInstance) {
|
|
1939
|
+
console.error("MSAL instance not initialized");
|
|
1940
|
+
return Promise.resolve();
|
|
1941
|
+
}
|
|
1942
|
+
return Promise.resolve(_catch(function () {
|
|
1943
|
+
return Promise.resolve(msalInstance.initialize()).then(function () {
|
|
1944
|
+
var loginRequest = {
|
|
1945
|
+
scopes: ["openid", "profile", "email"]
|
|
1946
|
+
};
|
|
1947
|
+
var silentRequest = _extends({}, loginRequest, {
|
|
1948
|
+
prompt: "select_account"
|
|
1949
|
+
});
|
|
1950
|
+
return Promise.resolve(msalInstance.loginPopup(silentRequest)).then(function (response) {
|
|
1951
|
+
return function () {
|
|
1952
|
+
if (response && response.account) {
|
|
1953
|
+
var account = response.account;
|
|
1954
|
+
var fullName = (account === null || account === void 0 ? void 0 : account.name) || "";
|
|
1955
|
+
var infoLogin = {
|
|
1956
|
+
firstName: fullName.split(' ').slice(0, -1).join(' '),
|
|
1957
|
+
lastName: fullName.split(' ').slice(-1).join(' '),
|
|
1958
|
+
fullName: fullName,
|
|
1959
|
+
imageUrl: "",
|
|
1960
|
+
email: (account === null || account === void 0 ? void 0 : account.username) || "",
|
|
1961
|
+
token: (response === null || response === void 0 ? void 0 : response.accessToken) || "",
|
|
1962
|
+
googleId: (account === null || account === void 0 ? void 0 : account.homeAccountId) || "",
|
|
1963
|
+
role: role,
|
|
1964
|
+
type: TypeLogin.Microsoft
|
|
1965
|
+
};
|
|
1966
|
+
dispatch(setLoading(true));
|
|
1967
|
+
return Promise.resolve(apiLoginGoogle(infoLogin)).then(function (authResult) {
|
|
1968
|
+
var _authResult$data2;
|
|
1969
|
+
if (((_authResult$data2 = authResult.data) === null || _authResult$data2 === void 0 ? void 0 : _authResult$data2.id) == null) {
|
|
1970
|
+
dispatch(setLoading(false));
|
|
1971
|
+
alert("Please contact admin.");
|
|
1972
|
+
return;
|
|
1973
|
+
}
|
|
1974
|
+
localStorage.clear();
|
|
1975
|
+
var tokenJWT = authResult.data.token;
|
|
1976
|
+
trackEvent === null || trackEvent === void 0 ? void 0 : trackEvent({
|
|
1977
|
+
eventName: AmplitudeEvent.LOGIN,
|
|
1978
|
+
eventProperties: {
|
|
1979
|
+
email: email,
|
|
1980
|
+
login_method: 'microsoft',
|
|
1981
|
+
user_role: authResult.data.role,
|
|
1982
|
+
success: true,
|
|
1983
|
+
timestamp: new Date().toISOString()
|
|
1984
|
+
}
|
|
1985
|
+
});
|
|
1986
|
+
if (role === "LandingPage") {
|
|
1987
|
+
CookieService.setAuthCookie({
|
|
1988
|
+
token: tokenJWT,
|
|
1989
|
+
expiresAt: Date.now() + 24 * 60 * 60 * 1000
|
|
1990
|
+
});
|
|
1991
|
+
var getRedirectUrl = function getRedirectUrl(role) {
|
|
1992
|
+
switch (role) {
|
|
1993
|
+
case "Admin":
|
|
1994
|
+
return ADMIN_ORIGIN;
|
|
1995
|
+
case "Teacher":
|
|
1996
|
+
return TEACHER_ORIGIN;
|
|
1997
|
+
default:
|
|
1998
|
+
return role + "." + REQUEST_ORIGIN;
|
|
1999
|
+
}
|
|
2000
|
+
};
|
|
2001
|
+
var redirectUrl = getRedirectUrl(authResult.data.role);
|
|
2002
|
+
window.location.href = redirectUrl + "/dashboard";
|
|
2003
|
+
dispatch(setLoading(false));
|
|
2004
|
+
}
|
|
2005
|
+
localStorage.setItem(ACCESS_TOKEN, tokenJWT);
|
|
2006
|
+
onNavigate("/dashboard");
|
|
2007
|
+
dispatch(setLoading(false));
|
|
2008
|
+
});
|
|
2009
|
+
}
|
|
2010
|
+
}();
|
|
2011
|
+
});
|
|
2012
|
+
});
|
|
2013
|
+
}, function (error) {
|
|
2014
|
+
console.error("Microsoft login error:", error);
|
|
2015
|
+
}));
|
|
2016
|
+
} catch (e) {
|
|
2017
|
+
return Promise.reject(e);
|
|
2018
|
+
}
|
|
2019
|
+
};
|
|
1883
2020
|
React.useEffect(function () {
|
|
1884
2021
|
return function () {
|
|
1885
2022
|
if (resendTimer) {
|
|
@@ -1987,7 +2124,18 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
|
1987
2124
|
height: 24,
|
|
1988
2125
|
alt: "Google sign-in",
|
|
1989
2126
|
src: "/images/icons/Google__G__logo.png"
|
|
1990
|
-
}), "Sign in with Google")), React.createElement("
|
|
2127
|
+
}), "Sign in with Google")), MICROSOFT_SSO_ENABLED === "true" && React.createElement("div", {
|
|
2128
|
+
className: "" + styleGlobal["microsoft_button"]
|
|
2129
|
+
}, React.createElement("button", {
|
|
2130
|
+
onClick: function onClick() {
|
|
2131
|
+
return fnLoginMicrosoft();
|
|
2132
|
+
}
|
|
2133
|
+
}, React.createElement("img", {
|
|
2134
|
+
width: 24,
|
|
2135
|
+
height: 24,
|
|
2136
|
+
alt: "Google sign-in",
|
|
2137
|
+
src: "/images/Single-Sign-On-logo.png"
|
|
2138
|
+
}), "Sign in with Microsoft")), React.createElement("span", {
|
|
1991
2139
|
className: "" + styleGlobal["box-field"]
|
|
1992
2140
|
}, "OR"), React.createElement("div", {
|
|
1993
2141
|
className: "" + styleGlobal["box-input"]
|
|
@@ -2821,18 +2969,6 @@ var CommonDialog = function CommonDialog(_ref) {
|
|
|
2821
2969
|
}, title)), children);
|
|
2822
2970
|
};
|
|
2823
2971
|
|
|
2824
|
-
var AuthenticationMessage;
|
|
2825
|
-
(function (AuthenticationMessage) {
|
|
2826
|
-
AuthenticationMessage["NotAllowedToRegister"] = "NotAllowedToRegister";
|
|
2827
|
-
AuthenticationMessage["InvalidGoogleToken"] = "InvalidGoogleToken";
|
|
2828
|
-
})(AuthenticationMessage || (AuthenticationMessage = {}));
|
|
2829
|
-
var Role;
|
|
2830
|
-
(function (Role) {
|
|
2831
|
-
Role["Student"] = "Student";
|
|
2832
|
-
Role["Teacher"] = "Teacher";
|
|
2833
|
-
Role["Admin"] = "Admin";
|
|
2834
|
-
})(Role || (Role = {}));
|
|
2835
|
-
|
|
2836
2972
|
var CustomPagination = function CustomPagination(_ref) {
|
|
2837
2973
|
var currentPage = _ref.currentPage,
|
|
2838
2974
|
totalPage = _ref.totalPage,
|
|
@@ -3335,13 +3471,19 @@ var utcToLocalTime = (function (time, FORMAT) {
|
|
|
3335
3471
|
}
|
|
3336
3472
|
});
|
|
3337
3473
|
|
|
3338
|
-
var timeSpanToLocalMoment = (function (time) {
|
|
3474
|
+
var timeSpanToLocalMoment = (function (time, timezone) {
|
|
3475
|
+
if (timezone === void 0) {
|
|
3476
|
+
timezone = "UTC";
|
|
3477
|
+
}
|
|
3339
3478
|
if (!time) return null;
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
var
|
|
3343
|
-
|
|
3344
|
-
|
|
3479
|
+
if (time.split(":").length !== 3) return null;
|
|
3480
|
+
var dateTime;
|
|
3481
|
+
var isOffset = /^(UTC|GMT)?[+-]/.test(timezone);
|
|
3482
|
+
if (isOffset) {
|
|
3483
|
+
dateTime = moment$1.utc(time, "HH:mm:ss").utcOffset(timezone);
|
|
3484
|
+
} else {
|
|
3485
|
+
dateTime = moment$1.tz(time, "HH:mm:ss", timezone);
|
|
3486
|
+
}
|
|
3345
3487
|
return dateTime.local();
|
|
3346
3488
|
});
|
|
3347
3489
|
|