@asgardeo/react 0.2.1 → 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 +23 -12
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/models/auth-context.d.ts +2 -0
- package/dist/cjs/types/models/use-authentication.d.ts +1 -0
- package/dist/esm/index.js +23 -12
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/models/auth-context.d.ts +2 -0
- package/dist/esm/types/models/use-authentication.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/package.json +1 -1
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.
|
|
@@ -40508,7 +40513,7 @@ const BrandingPreferenceContext = React$1.createContext(undefined);
|
|
|
40508
40513
|
*/
|
|
40509
40514
|
const useAuthentication = () => {
|
|
40510
40515
|
const contextValue = React$1.useContext(AsgardeoContext);
|
|
40511
|
-
const { accessToken, authResponse, isAuthenticated, setUsername, user, username } = contextValue;
|
|
40516
|
+
const { accessToken, authResponse, isAuthenticated, isGlobalLoading, setUsername, user, username } = contextValue;
|
|
40512
40517
|
const signOut$1 = () => {
|
|
40513
40518
|
signOut().then(() => {
|
|
40514
40519
|
sessionStorage.clear();
|
|
@@ -40521,6 +40526,7 @@ const useAuthentication = () => {
|
|
|
40521
40526
|
accessToken,
|
|
40522
40527
|
authResponse,
|
|
40523
40528
|
isAuthenticated,
|
|
40529
|
+
isGlobalLoading,
|
|
40524
40530
|
setUsername,
|
|
40525
40531
|
signOut: signOut$1,
|
|
40526
40532
|
user,
|
|
@@ -44447,7 +44453,6 @@ const IdentifierFirst = ({ handleAuthenticate, authenticator, alert, brandingPro
|
|
|
44447
44453
|
const SignIn = (props) => {
|
|
44448
44454
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
44449
44455
|
const { basicAuthChildren, brandingProps, emailOtpChildren, identifierFirstChildren, showFooter = true, showLogo = true, showSignUp, smsOtpChildren, totpChildren, } = props;
|
|
44450
|
-
const [isComponentLoading, setIsComponentLoading] = React$1.useState(true);
|
|
44451
44456
|
const [alert, setAlert] = React$1.useState();
|
|
44452
44457
|
const [showSelfSignUp, setShowSelfSignUp] = React$1.useState(showSignUp);
|
|
44453
44458
|
const [componentBranding, setComponentBranding] = React$1.useState();
|
|
@@ -44472,12 +44477,13 @@ const SignIn = (props) => {
|
|
|
44472
44477
|
authorize()
|
|
44473
44478
|
.then((response) => {
|
|
44474
44479
|
authContext === null || authContext === void 0 ? void 0 : authContext.setAuthResponse(response);
|
|
44475
|
-
setIsComponentLoading(false);
|
|
44476
44480
|
})
|
|
44477
44481
|
.catch((error) => {
|
|
44478
44482
|
setAlert({ alertType: { error: true }, key: keys.common.error });
|
|
44479
|
-
setIsComponentLoading(false);
|
|
44480
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);
|
|
44481
44487
|
});
|
|
44482
44488
|
}, []);
|
|
44483
44489
|
/**
|
|
@@ -44491,7 +44497,7 @@ const SignIn = (props) => {
|
|
|
44491
44497
|
if ((authContext === null || authContext === void 0 ? void 0 : authContext.authResponse) === undefined) {
|
|
44492
44498
|
throw new AsgardeoUIException('REACT_UI-SIGN_IN-HA-IV02', 'Auth response is undefined.');
|
|
44493
44499
|
}
|
|
44494
|
-
authContext.setIsAuthLoading(true);
|
|
44500
|
+
authContext === null || authContext === void 0 ? void 0 : authContext.setIsAuthLoading(true);
|
|
44495
44501
|
const resp = yield authenticate({
|
|
44496
44502
|
flowId: authContext === null || authContext === void 0 ? void 0 : authContext.authResponse.flowId,
|
|
44497
44503
|
selectedAuthenticator: {
|
|
@@ -44500,7 +44506,7 @@ const SignIn = (props) => {
|
|
|
44500
44506
|
},
|
|
44501
44507
|
}).catch((authnError) => {
|
|
44502
44508
|
setAlert({ alertType: { error: true }, key: keys.common.error });
|
|
44503
|
-
authContext.setIsAuthLoading(false);
|
|
44509
|
+
authContext === null || authContext === void 0 ? void 0 : authContext.setIsAuthLoading(false);
|
|
44504
44510
|
throw new AsgardeoUIException('REACT_UI-SIGN_IN-HA-SE03', 'Authentication failed.', authnError.stack);
|
|
44505
44511
|
});
|
|
44506
44512
|
if (!authParams) {
|
|
@@ -44542,7 +44548,7 @@ const SignIn = (props) => {
|
|
|
44542
44548
|
const authInstance = AuthClient.getInstance();
|
|
44543
44549
|
const state = (yield authInstance.getDataLayer().getTemporaryDataParameter('state')).toString();
|
|
44544
44550
|
yield authInstance.requestAccessToken(resp.authData.code, resp.authData.session_state, state);
|
|
44545
|
-
authContext.setAuthentication();
|
|
44551
|
+
authContext === null || authContext === void 0 ? void 0 : authContext.setAuthentication();
|
|
44546
44552
|
}
|
|
44547
44553
|
else if (resp.flowStatus === FlowStatus.FailIncomplete) {
|
|
44548
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 }));
|
|
@@ -44552,13 +44558,13 @@ const SignIn = (props) => {
|
|
|
44552
44558
|
authContext === null || authContext === void 0 ? void 0 : authContext.setAuthResponse(resp);
|
|
44553
44559
|
setShowSelfSignUp(false);
|
|
44554
44560
|
}
|
|
44555
|
-
authContext.setIsAuthLoading(false);
|
|
44561
|
+
authContext === null || authContext === void 0 ? void 0 : authContext.setIsAuthLoading(false);
|
|
44556
44562
|
});
|
|
44557
44563
|
const renderLoginOptions = (authenticators) => {
|
|
44558
44564
|
const LoginOptions = [];
|
|
44559
44565
|
authenticators.forEach((authenticator) => {
|
|
44560
44566
|
const displayName = authenticator.idp === 'LOCAL' ? authenticator.authenticator : authenticator.idp;
|
|
44561
|
-
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));
|
|
44562
44568
|
});
|
|
44563
44569
|
return LoginOptions;
|
|
44564
44570
|
};
|
|
@@ -44605,7 +44611,7 @@ const SignIn = (props) => {
|
|
|
44605
44611
|
/**
|
|
44606
44612
|
* Renders the circular progress component while the component or text is loading.
|
|
44607
44613
|
*/
|
|
44608
|
-
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)) {
|
|
44609
44615
|
return (jsxRuntimeExports.jsx("div", { className: "Box-circularProgressHolder", children: jsxRuntimeExports.jsx(ae, { className: "circular-progress" }) }));
|
|
44610
44616
|
}
|
|
44611
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;
|
|
@@ -44614,7 +44620,7 @@ const SignIn = (props) => {
|
|
|
44614
44620
|
if (showFooter && copyrightText.includes('{{currentYear}}')) {
|
|
44615
44621
|
copyrightText = copyrightText.replace('{{currentYear}}', new Date().getFullYear().toString());
|
|
44616
44622
|
}
|
|
44617
|
-
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: [
|
|
44618
44624
|
{
|
|
44619
44625
|
children: (jsxRuntimeExports.jsx(SignIn$1.Link, { href: componentBranding.preference.urls.privacyPolicyURL, children: t(keys.common.privacy.policy) })),
|
|
44620
44626
|
},
|
|
@@ -45033,6 +45039,7 @@ const AsgardeoProvider = (props) => {
|
|
|
45033
45039
|
const [isBrandingLoading, setIsBrandingLoading] = React$1.useState(true);
|
|
45034
45040
|
const [isTextLoading, setIsTextLoading] = React$1.useState(true);
|
|
45035
45041
|
const [isAuthLoading, setIsAuthLoading] = React$1.useState(false);
|
|
45042
|
+
const [isComponentLoading, setIsComponentLoading] = React$1.useState(true);
|
|
45036
45043
|
const [authResponse, setAuthResponse] = React$1.useState();
|
|
45037
45044
|
const [username, setUsername] = React$1.useState('');
|
|
45038
45045
|
const onSignInRef = React$1.useRef();
|
|
@@ -45090,13 +45097,15 @@ const AsgardeoProvider = (props) => {
|
|
|
45090
45097
|
isAuthLoading,
|
|
45091
45098
|
isAuthenticated,
|
|
45092
45099
|
isBrandingLoading,
|
|
45093
|
-
|
|
45100
|
+
isComponentLoading,
|
|
45101
|
+
isGlobalLoading: isAuthLoading || isBrandingLoading || isComponentLoading || isTextLoading,
|
|
45094
45102
|
isTextLoading,
|
|
45095
45103
|
onSignOutRef,
|
|
45096
45104
|
setAuthResponse,
|
|
45097
45105
|
setAuthentication,
|
|
45098
45106
|
setIsAuthLoading,
|
|
45099
45107
|
setIsBrandingLoading,
|
|
45108
|
+
setIsComponentLoading,
|
|
45100
45109
|
setIsTextLoading,
|
|
45101
45110
|
setOnSignIn,
|
|
45102
45111
|
setOnSignOut,
|
|
@@ -45110,9 +45119,11 @@ const AsgardeoProvider = (props) => {
|
|
|
45110
45119
|
isAuthLoading,
|
|
45111
45120
|
isAuthenticated,
|
|
45112
45121
|
isBrandingLoading,
|
|
45122
|
+
isComponentLoading,
|
|
45113
45123
|
isTextLoading,
|
|
45114
45124
|
setAuthResponse,
|
|
45115
45125
|
setAuthentication,
|
|
45126
|
+
setIsComponentLoading,
|
|
45116
45127
|
setOnSignIn,
|
|
45117
45128
|
setOnSignOut,
|
|
45118
45129
|
setUsername,
|