@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.
package/dist/cjs/index.js
CHANGED
|
@@ -39999,13 +39999,18 @@ const I18nContext = React$1.createContext(undefined);
|
|
|
39999
39999
|
const useTranslations = (props) => {
|
|
40000
40000
|
const { componentLocaleOverride, componentTextOverrides, screen } = props;
|
|
40001
40001
|
const [isLoading, setIsLoading] = React$1.useState(true);
|
|
40002
|
+
const { setIsTextLoading } = React$1.useContext(AsgardeoContext);
|
|
40002
40003
|
const contextValue = React$1.useContext(I18nContext);
|
|
40003
40004
|
const { text, setTranslations } = contextValue;
|
|
40004
40005
|
React$1.useEffect(() => {
|
|
40005
40006
|
setTranslations({ componentLocaleOverride, componentTextOverrides, screen }).then((response) => {
|
|
40006
40007
|
setIsLoading(!response);
|
|
40008
|
+
setIsTextLoading(!response);
|
|
40007
40009
|
});
|
|
40008
40010
|
}, [componentLocaleOverride, componentTextOverrides, screen, setTranslations]);
|
|
40011
|
+
React$1.useEffect(() => {
|
|
40012
|
+
setIsTextLoading(isLoading);
|
|
40013
|
+
}, [isLoading]);
|
|
40009
40014
|
/**
|
|
40010
40015
|
* `t` is a function that retrieves a specific translation from the fetched translations.
|
|
40011
40016
|
* It takes a key as an argument, which is a string that represents a path to the desired translation.
|
|
@@ -44448,7 +44453,6 @@ const IdentifierFirst = ({ handleAuthenticate, authenticator, alert, brandingPro
|
|
|
44448
44453
|
const SignIn = (props) => {
|
|
44449
44454
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
44450
44455
|
const { basicAuthChildren, brandingProps, emailOtpChildren, identifierFirstChildren, showFooter = true, showLogo = true, showSignUp, smsOtpChildren, totpChildren, } = props;
|
|
44451
|
-
const [isComponentLoading, setIsComponentLoading] = React$1.useState(true);
|
|
44452
44456
|
const [alert, setAlert] = React$1.useState();
|
|
44453
44457
|
const [showSelfSignUp, setShowSelfSignUp] = React$1.useState(showSignUp);
|
|
44454
44458
|
const [componentBranding, setComponentBranding] = React$1.useState();
|
|
@@ -44473,12 +44477,13 @@ const SignIn = (props) => {
|
|
|
44473
44477
|
authorize()
|
|
44474
44478
|
.then((response) => {
|
|
44475
44479
|
authContext === null || authContext === void 0 ? void 0 : authContext.setAuthResponse(response);
|
|
44476
|
-
setIsComponentLoading(false);
|
|
44477
44480
|
})
|
|
44478
44481
|
.catch((error) => {
|
|
44479
44482
|
setAlert({ alertType: { error: true }, key: keys.common.error });
|
|
44480
|
-
setIsComponentLoading(false);
|
|
44481
44483
|
throw new AsgardeoUIException('REACT_UI-SIGN_IN-SI-SE01', 'Authorization failed', error.stack);
|
|
44484
|
+
})
|
|
44485
|
+
.finally(() => {
|
|
44486
|
+
authContext === null || authContext === void 0 ? void 0 : authContext.setIsComponentLoading(false);
|
|
44482
44487
|
});
|
|
44483
44488
|
}, []);
|
|
44484
44489
|
/**
|
|
@@ -44492,7 +44497,7 @@ const SignIn = (props) => {
|
|
|
44492
44497
|
if ((authContext === null || authContext === void 0 ? void 0 : authContext.authResponse) === undefined) {
|
|
44493
44498
|
throw new AsgardeoUIException('REACT_UI-SIGN_IN-HA-IV02', 'Auth response is undefined.');
|
|
44494
44499
|
}
|
|
44495
|
-
authContext.setIsAuthLoading(true);
|
|
44500
|
+
authContext === null || authContext === void 0 ? void 0 : authContext.setIsAuthLoading(true);
|
|
44496
44501
|
const resp = yield authenticate({
|
|
44497
44502
|
flowId: authContext === null || authContext === void 0 ? void 0 : authContext.authResponse.flowId,
|
|
44498
44503
|
selectedAuthenticator: {
|
|
@@ -44501,7 +44506,7 @@ const SignIn = (props) => {
|
|
|
44501
44506
|
},
|
|
44502
44507
|
}).catch((authnError) => {
|
|
44503
44508
|
setAlert({ alertType: { error: true }, key: keys.common.error });
|
|
44504
|
-
authContext.setIsAuthLoading(false);
|
|
44509
|
+
authContext === null || authContext === void 0 ? void 0 : authContext.setIsAuthLoading(false);
|
|
44505
44510
|
throw new AsgardeoUIException('REACT_UI-SIGN_IN-HA-SE03', 'Authentication failed.', authnError.stack);
|
|
44506
44511
|
});
|
|
44507
44512
|
if (!authParams) {
|
|
@@ -44543,7 +44548,7 @@ const SignIn = (props) => {
|
|
|
44543
44548
|
const authInstance = AuthClient.getInstance();
|
|
44544
44549
|
const state = (yield authInstance.getDataLayer().getTemporaryDataParameter('state')).toString();
|
|
44545
44550
|
yield authInstance.requestAccessToken(resp.authData.code, resp.authData.session_state, state);
|
|
44546
|
-
authContext.setAuthentication();
|
|
44551
|
+
authContext === null || authContext === void 0 ? void 0 : authContext.setAuthentication();
|
|
44547
44552
|
}
|
|
44548
44553
|
else if (resp.flowStatus === FlowStatus.FailIncomplete) {
|
|
44549
44554
|
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 }));
|
|
@@ -44553,13 +44558,13 @@ const SignIn = (props) => {
|
|
|
44553
44558
|
authContext === null || authContext === void 0 ? void 0 : authContext.setAuthResponse(resp);
|
|
44554
44559
|
setShowSelfSignUp(false);
|
|
44555
44560
|
}
|
|
44556
|
-
authContext.setIsAuthLoading(false);
|
|
44561
|
+
authContext === null || authContext === void 0 ? void 0 : authContext.setIsAuthLoading(false);
|
|
44557
44562
|
});
|
|
44558
44563
|
const renderLoginOptions = (authenticators) => {
|
|
44559
44564
|
const LoginOptions = [];
|
|
44560
44565
|
authenticators.forEach((authenticator) => {
|
|
44561
44566
|
const displayName = authenticator.idp === 'LOCAL' ? authenticator.authenticator : authenticator.idp;
|
|
44562
|
-
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));
|
|
44567
|
+
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));
|
|
44563
44568
|
});
|
|
44564
44569
|
return LoginOptions;
|
|
44565
44570
|
};
|
|
@@ -44606,7 +44611,7 @@ const SignIn = (props) => {
|
|
|
44606
44611
|
/**
|
|
44607
44612
|
* Renders the circular progress component while the component or text is loading.
|
|
44608
44613
|
*/
|
|
44609
|
-
if (isComponentLoading || isLoading || authContext.isBrandingLoading) {
|
|
44614
|
+
if ((authContext === null || authContext === void 0 ? void 0 : authContext.isComponentLoading) || isLoading || (authContext === null || authContext === void 0 ? void 0 : authContext.isBrandingLoading)) {
|
|
44610
44615
|
return (jsxRuntimeExports.jsx("div", { className: "Box-circularProgressHolder", children: jsxRuntimeExports.jsx(ae, { className: "circular-progress" }) }));
|
|
44611
44616
|
}
|
|
44612
44617
|
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;
|
|
@@ -44615,7 +44620,7 @@ const SignIn = (props) => {
|
|
|
44615
44620
|
if (showFooter && copyrightText.includes('{{currentYear}}')) {
|
|
44616
44621
|
copyrightText = copyrightText.replace('{{currentYear}}', new Date().getFullYear().toString());
|
|
44617
44622
|
}
|
|
44618
|
-
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: [
|
|
44623
|
+
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: [
|
|
44619
44624
|
{
|
|
44620
44625
|
children: (jsxRuntimeExports.jsx(SignIn$1.Link, { href: componentBranding.preference.urls.privacyPolicyURL, children: t(keys.common.privacy.policy) })),
|
|
44621
44626
|
},
|
|
@@ -45034,6 +45039,7 @@ const AsgardeoProvider = (props) => {
|
|
|
45034
45039
|
const [isBrandingLoading, setIsBrandingLoading] = React$1.useState(true);
|
|
45035
45040
|
const [isTextLoading, setIsTextLoading] = React$1.useState(true);
|
|
45036
45041
|
const [isAuthLoading, setIsAuthLoading] = React$1.useState(false);
|
|
45042
|
+
const [isComponentLoading, setIsComponentLoading] = React$1.useState(true);
|
|
45037
45043
|
const [authResponse, setAuthResponse] = React$1.useState();
|
|
45038
45044
|
const [username, setUsername] = React$1.useState('');
|
|
45039
45045
|
const onSignInRef = React$1.useRef();
|
|
@@ -45091,13 +45097,15 @@ const AsgardeoProvider = (props) => {
|
|
|
45091
45097
|
isAuthLoading,
|
|
45092
45098
|
isAuthenticated,
|
|
45093
45099
|
isBrandingLoading,
|
|
45094
|
-
|
|
45100
|
+
isComponentLoading,
|
|
45101
|
+
isGlobalLoading: isAuthLoading || isBrandingLoading || isComponentLoading || isTextLoading,
|
|
45095
45102
|
isTextLoading,
|
|
45096
45103
|
onSignOutRef,
|
|
45097
45104
|
setAuthResponse,
|
|
45098
45105
|
setAuthentication,
|
|
45099
45106
|
setIsAuthLoading,
|
|
45100
45107
|
setIsBrandingLoading,
|
|
45108
|
+
setIsComponentLoading,
|
|
45101
45109
|
setIsTextLoading,
|
|
45102
45110
|
setOnSignIn,
|
|
45103
45111
|
setOnSignOut,
|
|
@@ -45111,9 +45119,11 @@ const AsgardeoProvider = (props) => {
|
|
|
45111
45119
|
isAuthLoading,
|
|
45112
45120
|
isAuthenticated,
|
|
45113
45121
|
isBrandingLoading,
|
|
45122
|
+
isComponentLoading,
|
|
45114
45123
|
isTextLoading,
|
|
45115
45124
|
setAuthResponse,
|
|
45116
45125
|
setAuthentication,
|
|
45126
|
+
setIsComponentLoading,
|
|
45117
45127
|
setOnSignIn,
|
|
45118
45128
|
setOnSignOut,
|
|
45119
45129
|
setUsername,
|