@asgardeo/react 0.2.2 → 0.2.3
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.
|
@@ -24,6 +24,7 @@ interface AuthContext {
|
|
|
24
24
|
isAuthLoading: boolean;
|
|
25
25
|
isAuthenticated: boolean | undefined;
|
|
26
26
|
isBrandingLoading: boolean;
|
|
27
|
+
isComponentLoading: boolean;
|
|
27
28
|
isGlobalLoading: boolean;
|
|
28
29
|
isTextLoading: boolean;
|
|
29
30
|
onSignOutRef: React.MutableRefObject<Function>;
|
|
@@ -31,6 +32,7 @@ interface AuthContext {
|
|
|
31
32
|
setAuthentication: () => void;
|
|
32
33
|
setIsAuthLoading: (value: boolean) => void;
|
|
33
34
|
setIsBrandingLoading: (value: boolean) => void;
|
|
35
|
+
setIsComponentLoading: (value: boolean) => void;
|
|
34
36
|
setIsTextLoading: (value: boolean) => void;
|
|
35
37
|
setOnSignIn: (response?: any) => void | Promise<void>;
|
|
36
38
|
setOnSignOut: (response?: any) => void | Promise<void>;
|
package/dist/esm/index.js
CHANGED
|
@@ -39979,13 +39979,18 @@ const I18nContext = createContext(undefined);
|
|
|
39979
39979
|
const useTranslations = (props) => {
|
|
39980
39980
|
const { componentLocaleOverride, componentTextOverrides, screen } = props;
|
|
39981
39981
|
const [isLoading, setIsLoading] = useState(true);
|
|
39982
|
+
const { setIsTextLoading } = useContext(AsgardeoContext);
|
|
39982
39983
|
const contextValue = useContext(I18nContext);
|
|
39983
39984
|
const { text, setTranslations } = contextValue;
|
|
39984
39985
|
useEffect(() => {
|
|
39985
39986
|
setTranslations({ componentLocaleOverride, componentTextOverrides, screen }).then((response) => {
|
|
39986
39987
|
setIsLoading(!response);
|
|
39988
|
+
setIsTextLoading(!response);
|
|
39987
39989
|
});
|
|
39988
39990
|
}, [componentLocaleOverride, componentTextOverrides, screen, setTranslations]);
|
|
39991
|
+
useEffect(() => {
|
|
39992
|
+
setIsTextLoading(isLoading);
|
|
39993
|
+
}, [isLoading]);
|
|
39989
39994
|
/**
|
|
39990
39995
|
* `t` is a function that retrieves a specific translation from the fetched translations.
|
|
39991
39996
|
* It takes a key as an argument, which is a string that represents a path to the desired translation.
|
|
@@ -44428,7 +44433,6 @@ const IdentifierFirst = ({ handleAuthenticate, authenticator, alert, brandingPro
|
|
|
44428
44433
|
const SignIn = (props) => {
|
|
44429
44434
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
44430
44435
|
const { basicAuthChildren, brandingProps, emailOtpChildren, identifierFirstChildren, showFooter = true, showLogo = true, showSignUp, smsOtpChildren, totpChildren, } = props;
|
|
44431
|
-
const [isComponentLoading, setIsComponentLoading] = useState(true);
|
|
44432
44436
|
const [alert, setAlert] = useState();
|
|
44433
44437
|
const [showSelfSignUp, setShowSelfSignUp] = useState(showSignUp);
|
|
44434
44438
|
const [componentBranding, setComponentBranding] = useState();
|
|
@@ -44453,12 +44457,13 @@ const SignIn = (props) => {
|
|
|
44453
44457
|
authorize()
|
|
44454
44458
|
.then((response) => {
|
|
44455
44459
|
authContext === null || authContext === void 0 ? void 0 : authContext.setAuthResponse(response);
|
|
44456
|
-
setIsComponentLoading(false);
|
|
44457
44460
|
})
|
|
44458
44461
|
.catch((error) => {
|
|
44459
44462
|
setAlert({ alertType: { error: true }, key: keys.common.error });
|
|
44460
|
-
setIsComponentLoading(false);
|
|
44461
44463
|
throw new AsgardeoUIException('REACT_UI-SIGN_IN-SI-SE01', 'Authorization failed', error.stack);
|
|
44464
|
+
})
|
|
44465
|
+
.finally(() => {
|
|
44466
|
+
authContext === null || authContext === void 0 ? void 0 : authContext.setIsComponentLoading(false);
|
|
44462
44467
|
});
|
|
44463
44468
|
}, []);
|
|
44464
44469
|
/**
|
|
@@ -44472,7 +44477,7 @@ const SignIn = (props) => {
|
|
|
44472
44477
|
if ((authContext === null || authContext === void 0 ? void 0 : authContext.authResponse) === undefined) {
|
|
44473
44478
|
throw new AsgardeoUIException('REACT_UI-SIGN_IN-HA-IV02', 'Auth response is undefined.');
|
|
44474
44479
|
}
|
|
44475
|
-
authContext.setIsAuthLoading(true);
|
|
44480
|
+
authContext === null || authContext === void 0 ? void 0 : authContext.setIsAuthLoading(true);
|
|
44476
44481
|
const resp = yield authenticate({
|
|
44477
44482
|
flowId: authContext === null || authContext === void 0 ? void 0 : authContext.authResponse.flowId,
|
|
44478
44483
|
selectedAuthenticator: {
|
|
@@ -44481,7 +44486,7 @@ const SignIn = (props) => {
|
|
|
44481
44486
|
},
|
|
44482
44487
|
}).catch((authnError) => {
|
|
44483
44488
|
setAlert({ alertType: { error: true }, key: keys.common.error });
|
|
44484
|
-
authContext.setIsAuthLoading(false);
|
|
44489
|
+
authContext === null || authContext === void 0 ? void 0 : authContext.setIsAuthLoading(false);
|
|
44485
44490
|
throw new AsgardeoUIException('REACT_UI-SIGN_IN-HA-SE03', 'Authentication failed.', authnError.stack);
|
|
44486
44491
|
});
|
|
44487
44492
|
if (!authParams) {
|
|
@@ -44523,7 +44528,7 @@ const SignIn = (props) => {
|
|
|
44523
44528
|
const authInstance = AuthClient.getInstance();
|
|
44524
44529
|
const state = (yield authInstance.getDataLayer().getTemporaryDataParameter('state')).toString();
|
|
44525
44530
|
yield authInstance.requestAccessToken(resp.authData.code, resp.authData.session_state, state);
|
|
44526
|
-
authContext.setAuthentication();
|
|
44531
|
+
authContext === null || authContext === void 0 ? void 0 : authContext.setAuthentication();
|
|
44527
44532
|
}
|
|
44528
44533
|
else if (resp.flowStatus === FlowStatus.FailIncomplete) {
|
|
44529
44534
|
authContext === null || authContext === void 0 ? void 0 : authContext.setAuthResponse(Object.assign(Object.assign({}, resp), { nextStep: authContext === null || authContext === void 0 ? void 0 : authContext.authResponse.nextStep }));
|
|
@@ -44533,13 +44538,13 @@ const SignIn = (props) => {
|
|
|
44533
44538
|
authContext === null || authContext === void 0 ? void 0 : authContext.setAuthResponse(resp);
|
|
44534
44539
|
setShowSelfSignUp(false);
|
|
44535
44540
|
}
|
|
44536
|
-
authContext.setIsAuthLoading(false);
|
|
44541
|
+
authContext === null || authContext === void 0 ? void 0 : authContext.setIsAuthLoading(false);
|
|
44537
44542
|
});
|
|
44538
44543
|
const renderLoginOptions = (authenticators) => {
|
|
44539
44544
|
const LoginOptions = [];
|
|
44540
44545
|
authenticators.forEach((authenticator) => {
|
|
44541
44546
|
const displayName = authenticator.idp === 'LOCAL' ? authenticator.authenticator : authenticator.idp;
|
|
44542
|
-
LoginOptions.push(jsxRuntimeExports.jsx(LoginOptionsBox, { isAuthLoading: authContext.isAuthLoading, socialName: authenticator.authenticator, displayName: `${t(keys.common.multiple.options.prefix)} ${displayName}`, handleOnClick: () => handleAuthenticate(authenticator.authenticatorId) }, authenticator.authenticatorId));
|
|
44547
|
+
LoginOptions.push(jsxRuntimeExports.jsx(LoginOptionsBox, { isAuthLoading: authContext === null || authContext === void 0 ? void 0 : authContext.isAuthLoading, socialName: authenticator.authenticator, displayName: `${t(keys.common.multiple.options.prefix)} ${displayName}`, handleOnClick: () => handleAuthenticate(authenticator.authenticatorId) }, authenticator.authenticatorId));
|
|
44543
44548
|
});
|
|
44544
44549
|
return LoginOptions;
|
|
44545
44550
|
};
|
|
@@ -44586,7 +44591,7 @@ const SignIn = (props) => {
|
|
|
44586
44591
|
/**
|
|
44587
44592
|
* Renders the circular progress component while the component or text is loading.
|
|
44588
44593
|
*/
|
|
44589
|
-
if (isComponentLoading || isLoading || authContext.isBrandingLoading) {
|
|
44594
|
+
if ((authContext === null || authContext === void 0 ? void 0 : authContext.isComponentLoading) || isLoading || (authContext === null || authContext === void 0 ? void 0 : authContext.isBrandingLoading)) {
|
|
44590
44595
|
return (jsxRuntimeExports.jsx("div", { className: "Box-circularProgressHolder", children: jsxRuntimeExports.jsx(ae, { className: "circular-progress" }) }));
|
|
44591
44596
|
}
|
|
44592
44597
|
const imgUrl = (_f = (_e = (_d = (_c = (_b = brandingPreference === null || brandingPreference === void 0 ? void 0 : brandingPreference.preference) === null || _b === void 0 ? void 0 : _b.theme) === null || _c === void 0 ? void 0 : _c.LIGHT) === null || _d === void 0 ? void 0 : _d.images) === null || _e === void 0 ? void 0 : _e.logo) === null || _f === void 0 ? void 0 : _f.imgURL;
|
|
@@ -44595,7 +44600,7 @@ const SignIn = (props) => {
|
|
|
44595
44600
|
if (showFooter && copyrightText.includes('{{currentYear}}')) {
|
|
44596
44601
|
copyrightText = copyrightText.replace('{{currentYear}}', new Date().getFullYear().toString());
|
|
44597
44602
|
}
|
|
44598
|
-
return (jsxRuntimeExports.jsx(eo, { theme: generateThemeSignIn(componentBranding === null || componentBranding === void 0 ? void 0 : componentBranding.preference.theme), children: jsxRuntimeExports.jsxs(SignIn$1, { className: "Box-asgardeoSignIn", children: [showLogo && !(isLoading || isComponentLoading) && (jsxRuntimeExports.jsx(SignIn$1.Image, { className: "asgardeo-sign-in-logo", src: imgUrl })), ((_g = authContext === null || authContext === void 0 ? void 0 : authContext.authResponse) === null || _g === void 0 ? void 0 : _g.flowStatus) !== FlowStatus.SuccessCompleted && !isAuthenticated && (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [renderSignIn(), showFooter && !(isLoading || isComponentLoading) && (jsxRuntimeExports.jsx(SignIn$1.Footer, { className: "asgardeo-sign-in-footer", copyrights: { children: copyrightText }, items: [
|
|
44603
|
+
return (jsxRuntimeExports.jsx(eo, { theme: generateThemeSignIn(componentBranding === null || componentBranding === void 0 ? void 0 : componentBranding.preference.theme), children: jsxRuntimeExports.jsxs(SignIn$1, { className: "Box-asgardeoSignIn", children: [showLogo && !(isLoading || (authContext === null || authContext === void 0 ? void 0 : authContext.isComponentLoading)) && (jsxRuntimeExports.jsx(SignIn$1.Image, { className: "asgardeo-sign-in-logo", src: imgUrl })), ((_g = authContext === null || authContext === void 0 ? void 0 : authContext.authResponse) === null || _g === void 0 ? void 0 : _g.flowStatus) !== FlowStatus.SuccessCompleted && !isAuthenticated && (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [renderSignIn(), showFooter && !(isLoading || (authContext === null || authContext === void 0 ? void 0 : authContext.isComponentLoading)) && (jsxRuntimeExports.jsx(SignIn$1.Footer, { className: "asgardeo-sign-in-footer", copyrights: { children: copyrightText }, items: [
|
|
44599
44604
|
{
|
|
44600
44605
|
children: (jsxRuntimeExports.jsx(SignIn$1.Link, { href: componentBranding.preference.urls.privacyPolicyURL, children: t(keys.common.privacy.policy) })),
|
|
44601
44606
|
},
|
|
@@ -45014,6 +45019,7 @@ const AsgardeoProvider = (props) => {
|
|
|
45014
45019
|
const [isBrandingLoading, setIsBrandingLoading] = useState(true);
|
|
45015
45020
|
const [isTextLoading, setIsTextLoading] = useState(true);
|
|
45016
45021
|
const [isAuthLoading, setIsAuthLoading] = useState(false);
|
|
45022
|
+
const [isComponentLoading, setIsComponentLoading] = useState(true);
|
|
45017
45023
|
const [authResponse, setAuthResponse] = useState();
|
|
45018
45024
|
const [username, setUsername] = useState('');
|
|
45019
45025
|
const onSignInRef = useRef();
|
|
@@ -45071,13 +45077,15 @@ const AsgardeoProvider = (props) => {
|
|
|
45071
45077
|
isAuthLoading,
|
|
45072
45078
|
isAuthenticated,
|
|
45073
45079
|
isBrandingLoading,
|
|
45074
|
-
|
|
45080
|
+
isComponentLoading,
|
|
45081
|
+
isGlobalLoading: isAuthLoading || isBrandingLoading || isComponentLoading || isTextLoading,
|
|
45075
45082
|
isTextLoading,
|
|
45076
45083
|
onSignOutRef,
|
|
45077
45084
|
setAuthResponse,
|
|
45078
45085
|
setAuthentication,
|
|
45079
45086
|
setIsAuthLoading,
|
|
45080
45087
|
setIsBrandingLoading,
|
|
45088
|
+
setIsComponentLoading,
|
|
45081
45089
|
setIsTextLoading,
|
|
45082
45090
|
setOnSignIn,
|
|
45083
45091
|
setOnSignOut,
|
|
@@ -45091,9 +45099,11 @@ const AsgardeoProvider = (props) => {
|
|
|
45091
45099
|
isAuthLoading,
|
|
45092
45100
|
isAuthenticated,
|
|
45093
45101
|
isBrandingLoading,
|
|
45102
|
+
isComponentLoading,
|
|
45094
45103
|
isTextLoading,
|
|
45095
45104
|
setAuthResponse,
|
|
45096
45105
|
setAuthentication,
|
|
45106
|
+
setIsComponentLoading,
|
|
45097
45107
|
setOnSignIn,
|
|
45098
45108
|
setOnSignOut,
|
|
45099
45109
|
setUsername,
|