acsi-core 0.9.18 → 0.9.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -2
- package/dist/index.js +166 -43
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +168 -44
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -28,6 +28,5 @@ import CustomAsyncSelect from "./components/Selects/CustomAsyncSelect";
|
|
|
28
28
|
import CustomCreatable from "./components/Selects/CustomCreatable";
|
|
29
29
|
import CustomSelectOption from "./components/Selects/CustomSelectOption";
|
|
30
30
|
import utcToLocalTime from "./utils/utcToLocalTime";
|
|
31
|
-
import timeSpanToLocalMoment from "./utils/timeSpanToLocalMoment";
|
|
32
31
|
import Cookies from "js-cookie";
|
|
33
|
-
export { setLoading, setLoadingPage, BASE_URL, OPENSALT_BASE_URL, ACCESS_TOKEN, DATE_TIME_MIN_VALUE, ORGANIZATION_TEAM, ORGANIZATION_TENANT, firstCheckToken, getImageUrl, Login, utcToLocalTime,
|
|
32
|
+
export { setLoading, setLoadingPage, BASE_URL, OPENSALT_BASE_URL, ACCESS_TOKEN, DATE_TIME_MIN_VALUE, ORGANIZATION_TEAM, ORGANIZATION_TENANT, firstCheckToken, getImageUrl, Login, utcToLocalTime, getAccessToken, store, historyCore, setAlert, setUser, setTenant, setAddTenant, setTeam, setMenuCollapse, setIsRefetchSidebar, Loading, NotFound, LayoutContext, api, apiUpload, ConfirmDialog, CommonDialog, ToastContainer, toast, Role, Cookies, CustomPagination, useGoogleSignOut, CoreButton, CoreInput, CoreSelect, CoreCheckbox, CoreRadio, CoreError, CoreModal, CoreRange, CoreTextArea, CoreSearch, CoreSelectCompact, CoreInputCompact, CoreTitleInput, CoreTooltip, getErrorMessage, MarkdownLatexRender, CustomSelect, CustomAsyncSelect, CustomCreatable, CustomSelectOption, GoogleOAuthProvider, useAmplitude, AmplitudeEvent, initializeAmplitude, initSentry };
|
package/dist/index.js
CHANGED
|
@@ -19,10 +19,10 @@ var rehypeRaw = _interopDefault(require('rehype-raw'));
|
|
|
19
19
|
require('katex/dist/katex.min.css');
|
|
20
20
|
var Cookies = _interopDefault(require('js-cookie'));
|
|
21
21
|
var moment = _interopDefault(require('moment'));
|
|
22
|
+
var msalBrowser = require('@azure/msal-browser');
|
|
22
23
|
var reactToastify = require('react-toastify');
|
|
23
24
|
var reactGoogleLogin = require('@leecheuk/react-google-login');
|
|
24
25
|
var material = require('@mui/material');
|
|
25
|
-
require('@azure/msal-browser');
|
|
26
26
|
var amplitude = require('@amplitude/analytics-browser');
|
|
27
27
|
var Sentry = require('@sentry/react');
|
|
28
28
|
var fa = require('react-icons/fa');
|
|
@@ -672,25 +672,6 @@ var ORGANIZATION_TEAM = "ORGANIZATION_TEAM";
|
|
|
672
672
|
|
|
673
673
|
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"};
|
|
674
674
|
|
|
675
|
-
// A type of promise-like that resolves synchronously and supports only one observer
|
|
676
|
-
|
|
677
|
-
const _iteratorSymbol = /*#__PURE__*/ typeof Symbol !== "undefined" ? (Symbol.iterator || (Symbol.iterator = Symbol("Symbol.iterator"))) : "@@iterator";
|
|
678
|
-
|
|
679
|
-
const _asyncIteratorSymbol = /*#__PURE__*/ typeof Symbol !== "undefined" ? (Symbol.asyncIterator || (Symbol.asyncIterator = Symbol("Symbol.asyncIterator"))) : "@@asyncIterator";
|
|
680
|
-
|
|
681
|
-
// Asynchronously call a function and send errors to recovery continuation
|
|
682
|
-
function _catch(body, recover) {
|
|
683
|
-
try {
|
|
684
|
-
var result = body();
|
|
685
|
-
} catch(e) {
|
|
686
|
-
return recover(e);
|
|
687
|
-
}
|
|
688
|
-
if (result && result.then) {
|
|
689
|
-
return result.then(void 0, recover);
|
|
690
|
-
}
|
|
691
|
-
return result;
|
|
692
|
-
}
|
|
693
|
-
|
|
694
675
|
function _arrayLikeToArray(r, a) {
|
|
695
676
|
(null == a || a > r.length) && (a = r.length);
|
|
696
677
|
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
@@ -739,6 +720,25 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
739
720
|
}
|
|
740
721
|
}
|
|
741
722
|
|
|
723
|
+
// A type of promise-like that resolves synchronously and supports only one observer
|
|
724
|
+
|
|
725
|
+
const _iteratorSymbol = /*#__PURE__*/ typeof Symbol !== "undefined" ? (Symbol.iterator || (Symbol.iterator = Symbol("Symbol.iterator"))) : "@@iterator";
|
|
726
|
+
|
|
727
|
+
const _asyncIteratorSymbol = /*#__PURE__*/ typeof Symbol !== "undefined" ? (Symbol.asyncIterator || (Symbol.asyncIterator = Symbol("Symbol.asyncIterator"))) : "@@asyncIterator";
|
|
728
|
+
|
|
729
|
+
// Asynchronously call a function and send errors to recovery continuation
|
|
730
|
+
function _catch(body, recover) {
|
|
731
|
+
try {
|
|
732
|
+
var result = body();
|
|
733
|
+
} catch(e) {
|
|
734
|
+
return recover(e);
|
|
735
|
+
}
|
|
736
|
+
if (result && result.then) {
|
|
737
|
+
return result.then(void 0, recover);
|
|
738
|
+
}
|
|
739
|
+
return result;
|
|
740
|
+
}
|
|
741
|
+
|
|
742
742
|
var styles = {"core-button":"_xvNBN","primary":"_U9Qyp","secondary":"_1VzMy","text":"_pZNuj","danger":"_2uYm1","light":"_wxH5S"};
|
|
743
743
|
|
|
744
744
|
var _excluded = ["type", "children", "onClick", "icon", "disabled", "htmlType"];
|
|
@@ -2322,6 +2322,55 @@ var TypeLogin;
|
|
|
2322
2322
|
TypeLogin[TypeLogin["Microsoft"] = 3] = "Microsoft";
|
|
2323
2323
|
})(TypeLogin || (TypeLogin = {}));
|
|
2324
2324
|
|
|
2325
|
+
var AuthenticationMessage;
|
|
2326
|
+
(function (AuthenticationMessage) {
|
|
2327
|
+
AuthenticationMessage["NotAllowedToRegister"] = "NotAllowedToRegister";
|
|
2328
|
+
AuthenticationMessage["InvalidGoogleToken"] = "InvalidGoogleToken";
|
|
2329
|
+
})(AuthenticationMessage || (AuthenticationMessage = {}));
|
|
2330
|
+
(function (Role) {
|
|
2331
|
+
Role["Student"] = "Student";
|
|
2332
|
+
Role["Teacher"] = "Teacher";
|
|
2333
|
+
Role["Admin"] = "Admin";
|
|
2334
|
+
})(exports.Role || (exports.Role = {}));
|
|
2335
|
+
var msalConfig = function msalConfig(clientId, redirectUri) {
|
|
2336
|
+
return {
|
|
2337
|
+
auth: {
|
|
2338
|
+
clientId: clientId,
|
|
2339
|
+
authority: "https://login.microsoftonline.com/common",
|
|
2340
|
+
redirectUri: redirectUri
|
|
2341
|
+
},
|
|
2342
|
+
cache: {
|
|
2343
|
+
cacheLocation: "sessionStorage",
|
|
2344
|
+
storeAuthStateInCookie: false
|
|
2345
|
+
},
|
|
2346
|
+
system: {
|
|
2347
|
+
loggerOptions: {
|
|
2348
|
+
loggerCallback: function loggerCallback(level, message, containsPii) {
|
|
2349
|
+
if (containsPii) {
|
|
2350
|
+
return;
|
|
2351
|
+
}
|
|
2352
|
+
switch (level) {
|
|
2353
|
+
case msalBrowser.LogLevel.Error:
|
|
2354
|
+
console.error(message);
|
|
2355
|
+
return;
|
|
2356
|
+
case msalBrowser.LogLevel.Info:
|
|
2357
|
+
console.info(message);
|
|
2358
|
+
return;
|
|
2359
|
+
case msalBrowser.LogLevel.Verbose:
|
|
2360
|
+
console.debug(message);
|
|
2361
|
+
return;
|
|
2362
|
+
case msalBrowser.LogLevel.Warning:
|
|
2363
|
+
console.warn(message);
|
|
2364
|
+
return;
|
|
2365
|
+
default:
|
|
2366
|
+
return;
|
|
2367
|
+
}
|
|
2368
|
+
}
|
|
2369
|
+
}
|
|
2370
|
+
}
|
|
2371
|
+
};
|
|
2372
|
+
};
|
|
2373
|
+
|
|
2325
2374
|
var BlockLogin = function BlockLogin(_ref) {
|
|
2326
2375
|
var onNavigate = _ref.onNavigate,
|
|
2327
2376
|
role = _ref.role,
|
|
@@ -2456,6 +2505,91 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
|
2456
2505
|
return console.log(errorResponse);
|
|
2457
2506
|
}
|
|
2458
2507
|
});
|
|
2508
|
+
var fnLoginMicrosoft = function fnLoginMicrosoft() {
|
|
2509
|
+
try {
|
|
2510
|
+
var msalInstance = new msalBrowser.PublicClientApplication(msalConfig(MICROSOFT_CLIENT_ID, MICROSOFT_URL_DIRECT));
|
|
2511
|
+
if (!msalInstance) {
|
|
2512
|
+
console.error("MSAL instance not initialized");
|
|
2513
|
+
return Promise.resolve();
|
|
2514
|
+
}
|
|
2515
|
+
return Promise.resolve(_catch(function () {
|
|
2516
|
+
return Promise.resolve(msalInstance.initialize()).then(function () {
|
|
2517
|
+
var loginRequest = {
|
|
2518
|
+
scopes: ["openid", "profile", "email"]
|
|
2519
|
+
};
|
|
2520
|
+
var silentRequest = _extends$1({}, loginRequest, {
|
|
2521
|
+
prompt: "select_account"
|
|
2522
|
+
});
|
|
2523
|
+
return Promise.resolve(msalInstance.loginPopup(silentRequest)).then(function (response) {
|
|
2524
|
+
return function () {
|
|
2525
|
+
if (response && response.account) {
|
|
2526
|
+
var account = response.account;
|
|
2527
|
+
var fullName = (account === null || account === void 0 ? void 0 : account.name) || "";
|
|
2528
|
+
var infoLogin = {
|
|
2529
|
+
firstName: fullName.split(' ').slice(0, -1).join(' '),
|
|
2530
|
+
lastName: fullName.split(' ').slice(-1).join(' '),
|
|
2531
|
+
fullName: fullName,
|
|
2532
|
+
imageUrl: "",
|
|
2533
|
+
email: (account === null || account === void 0 ? void 0 : account.username) || "",
|
|
2534
|
+
token: (response === null || response === void 0 ? void 0 : response.accessToken) || "",
|
|
2535
|
+
googleId: (account === null || account === void 0 ? void 0 : account.homeAccountId) || "",
|
|
2536
|
+
role: role,
|
|
2537
|
+
type: TypeLogin.Microsoft
|
|
2538
|
+
};
|
|
2539
|
+
dispatch(setLoading(true));
|
|
2540
|
+
return Promise.resolve(apiLoginGoogle(infoLogin)).then(function (authResult) {
|
|
2541
|
+
var _authResult$data2;
|
|
2542
|
+
if (((_authResult$data2 = authResult.data) === null || _authResult$data2 === void 0 ? void 0 : _authResult$data2.id) == null) {
|
|
2543
|
+
dispatch(setLoading(false));
|
|
2544
|
+
alert("Please contact admin.");
|
|
2545
|
+
return;
|
|
2546
|
+
}
|
|
2547
|
+
localStorage.clear();
|
|
2548
|
+
var tokenJWT = authResult.data.token;
|
|
2549
|
+
trackEvent === null || trackEvent === void 0 ? void 0 : trackEvent({
|
|
2550
|
+
eventName: exports.AmplitudeEvent.LOGIN,
|
|
2551
|
+
eventProperties: {
|
|
2552
|
+
email: email,
|
|
2553
|
+
login_method: 'google',
|
|
2554
|
+
user_role: authResult.data.role,
|
|
2555
|
+
success: true,
|
|
2556
|
+
timestamp: new Date().toISOString()
|
|
2557
|
+
}
|
|
2558
|
+
});
|
|
2559
|
+
if (role === "LandingPage") {
|
|
2560
|
+
CookieService.setAuthCookie({
|
|
2561
|
+
token: tokenJWT,
|
|
2562
|
+
expiresAt: Date.now() + 24 * 60 * 60 * 1000
|
|
2563
|
+
});
|
|
2564
|
+
var getRedirectUrl = function getRedirectUrl(role) {
|
|
2565
|
+
switch (role) {
|
|
2566
|
+
case "Admin":
|
|
2567
|
+
return ADMIN_ORIGIN;
|
|
2568
|
+
case "Teacher":
|
|
2569
|
+
return TEACHER_ORIGIN;
|
|
2570
|
+
default:
|
|
2571
|
+
return role + "." + REQUEST_ORIGIN;
|
|
2572
|
+
}
|
|
2573
|
+
};
|
|
2574
|
+
var redirectUrl = getRedirectUrl(authResult.data.role);
|
|
2575
|
+
window.location.href = redirectUrl + "/dashboard";
|
|
2576
|
+
dispatch(setLoading(false));
|
|
2577
|
+
}
|
|
2578
|
+
localStorage.setItem(ACCESS_TOKEN, tokenJWT);
|
|
2579
|
+
onNavigate("/dashboard");
|
|
2580
|
+
dispatch(setLoading(false));
|
|
2581
|
+
});
|
|
2582
|
+
}
|
|
2583
|
+
}();
|
|
2584
|
+
});
|
|
2585
|
+
});
|
|
2586
|
+
}, function (error) {
|
|
2587
|
+
console.error("Microsoft login error:", error);
|
|
2588
|
+
}));
|
|
2589
|
+
} catch (e) {
|
|
2590
|
+
return Promise.reject(e);
|
|
2591
|
+
}
|
|
2592
|
+
};
|
|
2459
2593
|
React__default.useEffect(function () {
|
|
2460
2594
|
return function () {
|
|
2461
2595
|
if (resendTimer) {
|
|
@@ -2563,7 +2697,18 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
|
2563
2697
|
height: 24,
|
|
2564
2698
|
alt: "Google sign-in",
|
|
2565
2699
|
src: "/images/icons/Google__G__logo.png"
|
|
2566
|
-
}), "Sign in with Google")), React__default.createElement("
|
|
2700
|
+
}), "Sign in with Google")), React__default.createElement("div", {
|
|
2701
|
+
className: "" + styleGlobal["microsoft_button"]
|
|
2702
|
+
}, React__default.createElement("button", {
|
|
2703
|
+
onClick: function onClick() {
|
|
2704
|
+
return fnLoginMicrosoft();
|
|
2705
|
+
}
|
|
2706
|
+
}, React__default.createElement("img", {
|
|
2707
|
+
width: 24,
|
|
2708
|
+
height: 24,
|
|
2709
|
+
alt: "Google sign-in",
|
|
2710
|
+
src: "/images/Single-Sign-On-logo.png"
|
|
2711
|
+
}), "Sign in with Microsoft")), React__default.createElement("span", {
|
|
2567
2712
|
className: "" + styleGlobal["box-field"]
|
|
2568
2713
|
}, "OR"), React__default.createElement("div", {
|
|
2569
2714
|
className: "" + styleGlobal["box-input"]
|
|
@@ -3393,17 +3538,6 @@ var CommonDialog = function CommonDialog(_ref) {
|
|
|
3393
3538
|
}, title)), children);
|
|
3394
3539
|
};
|
|
3395
3540
|
|
|
3396
|
-
var AuthenticationMessage;
|
|
3397
|
-
(function (AuthenticationMessage) {
|
|
3398
|
-
AuthenticationMessage["NotAllowedToRegister"] = "NotAllowedToRegister";
|
|
3399
|
-
AuthenticationMessage["InvalidGoogleToken"] = "InvalidGoogleToken";
|
|
3400
|
-
})(AuthenticationMessage || (AuthenticationMessage = {}));
|
|
3401
|
-
(function (Role) {
|
|
3402
|
-
Role["Student"] = "Student";
|
|
3403
|
-
Role["Teacher"] = "Teacher";
|
|
3404
|
-
Role["Admin"] = "Admin";
|
|
3405
|
-
})(exports.Role || (exports.Role = {}));
|
|
3406
|
-
|
|
3407
3541
|
var CustomPagination = function CustomPagination(_ref) {
|
|
3408
3542
|
var currentPage = _ref.currentPage,
|
|
3409
3543
|
totalPage = _ref.totalPage,
|
|
@@ -3906,16 +4040,6 @@ var utcToLocalTime = (function (time, FORMAT) {
|
|
|
3906
4040
|
}
|
|
3907
4041
|
});
|
|
3908
4042
|
|
|
3909
|
-
var timeSpanToLocalMoment = (function (time) {
|
|
3910
|
-
if (!time) return null;
|
|
3911
|
-
var times = time.split(":");
|
|
3912
|
-
if (times.length !== 3) return null;
|
|
3913
|
-
var totalSeconds = +times[0] * 60 * 60 + +times[1] * 60 + +times[2];
|
|
3914
|
-
var startOfDay = moment.utc().startOf("day");
|
|
3915
|
-
var dateTime = startOfDay.add(totalSeconds, "seconds");
|
|
3916
|
-
return dateTime.local();
|
|
3917
|
-
});
|
|
3918
|
-
|
|
3919
4043
|
var historyCore = createBrowserHistory();
|
|
3920
4044
|
|
|
3921
4045
|
Object.defineProperty(exports, 'GoogleOAuthProvider', {
|
|
@@ -3988,7 +4112,6 @@ exports.setTeam = setTeam;
|
|
|
3988
4112
|
exports.setTenant = setTenant;
|
|
3989
4113
|
exports.setUser = setUser;
|
|
3990
4114
|
exports.store = store;
|
|
3991
|
-
exports.timeSpanToLocalMoment = timeSpanToLocalMoment;
|
|
3992
4115
|
exports.useAmplitude = useAmplitude;
|
|
3993
4116
|
exports.useGoogleSignOut = useGoogleSignOut;
|
|
3994
4117
|
exports.utcToLocalTime = utcToLocalTime;
|