Skip to content

Commit d951d7c

Browse files
Merge pull request #14 from movinsilva/react-ui--components
2 parents 2d995dc + 50868d0 commit d951d7c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+2108
-35
lines changed

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"workspace",
44
"core",
55
"react",
6-
"auth-components"
6+
"auth-components",
7+
"sample-app"
78
],
89
"editor.codeActionsOnSave": {
910
"source.fixAll.eslint": "explicit"

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"nx": "18.2.4"
99
},
1010
"workspaces": [
11-
"packages/*"
11+
"packages/*",
12+
"recipes/*"
1213
]
1314
}

packages/core/src/api/sign-out.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import {AuthClient, ResponseMode} from '../auth-client';
2020
import AsgardeoUIException from '../exception';
21+
import {UIAuthClient} from '../models/auth-config';
2122

2223
/**
2324
* Sign out the user.
@@ -45,9 +46,11 @@ const signOut = async (): Promise<void> => {
4546

4647
const formBody: URLSearchParams = new URLSearchParams();
4748

49+
const authClient: UIAuthClient = AuthClient.getInstance();
50+
4851
try {
49-
formBody.append('id_token_hint', await AuthClient.getInstance().getIDToken());
50-
formBody.append('client_id', (await AuthClient.getInstance().getDataLayer().getConfigData()).clientID);
52+
formBody.append('id_token_hint', await authClient.getIDToken());
53+
formBody.append('client_id', (await authClient.getDataLayer().getConfigData()).clientID);
5154
formBody.append('response_mode', ResponseMode.direct);
5255
} catch (error) {
5356
throw new AsgardeoUIException('JS_UI_CORE-SIGNOUT-SO-IV', 'Failed to build the body of the signout request.');
@@ -60,7 +63,8 @@ const signOut = async (): Promise<void> => {
6063
};
6164

6265
try {
63-
signOutUrl = (await AuthClient.getInstance().getOIDCServiceEndpoints()).endSessionEndpoint;
66+
const {endSessionEndpoint} = await authClient.getOIDCServiceEndpoints();
67+
signOutUrl = endSessionEndpoint;
6468
} catch (error) {
6569
throw new AsgardeoUIException('JS_UI_CORE-SIGNOUT-SO-NF', 'Failed to retrieve the sign out endpoint.');
6670
}

packages/core/src/branding/get-branding.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,14 @@ const getBranding = async (props: GetBrandingProps): Promise<Branding> => {
4141
if (!merged) {
4242
let brandingFromConsole: BrandingPreferenceAPIResponse;
4343

44-
if ((await AuthClient.getInstance().getDataLayer().getConfigData()).enableConsoleBranding ?? true) {
45-
brandingFromConsole = await getBrandingPreference();
44+
try {
45+
if ((await AuthClient.getInstance().getDataLayer().getConfigData()).enableConsoleBranding ?? true) {
46+
brandingFromConsole = await getBrandingPreference();
47+
}
48+
} catch {
49+
/**
50+
* If the branding from the console cannot be fetched, proceed with the default branding.
51+
*/
4652
}
4753

4854
if (brandingFromConsole?.preference?.configs?.isBrandingEnabled) {

packages/core/src/i18n/get-localization.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import merge from 'lodash.merge';
2121
import {TextObject} from './screens/model';
2222
import getBrandingPreferenceText from '../api/get-branding-preference-text';
2323
import {AuthClient} from '../auth-client';
24-
import AsgardeoUIException from '../exception';
2524
import {UIAuthConfig} from '../models/auth-config';
2625
import {BrandingPreferenceTypes} from '../models/branding-api-response';
2726
import {BrandingPreferenceTextAPIResponse} from '../models/branding-text-api-response';
@@ -42,21 +41,21 @@ const getLocalization = async (props: GetLocalizationProps): Promise<TextObject>
4241

4342
const configData: AuthClientConfig<UIAuthConfig> = await AuthClient.getInstance().getDataLayer().getConfigData();
4443

44+
const DEFAULT_NAME: string = 'carbon.super';
45+
4546
try {
4647
if (configData.enableConsoleTextBranding ?? true) {
4748
textFromConsoleBranding = await getBrandingPreferenceText({
4849
locale,
49-
name: configData.name ?? 'carbon.super',
50+
name: configData.name ?? DEFAULT_NAME,
5051
screen,
5152
type: configData.type ?? BrandingPreferenceTypes.Org,
5253
});
5354
}
5455
} catch (error) {
55-
throw new AsgardeoUIException(
56-
'JS_UI_CORE-LOCALIZATION-IV',
57-
'Error occurred while fetching text from console branding.',
58-
error.stack,
59-
);
56+
/**
57+
* If the branding from the console cannot be fetched, proceed with the default branding.
58+
*/
6059
}
6160

6261
/**

packages/core/src/i18n/screens/common/en-US.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ import {Common} from './model';
2020

2121
export const common: Common = {
2222
copyright: '© {{currentYear}} WSO2 LLC.',
23+
error: 'Something went wrong. Please try again.',
24+
or: 'OR',
25+
'prefix.register': "Don't have an account?",
2326
'privacy.policy': 'Privacy Policy',
27+
register: 'Register',
2428
'site.title': 'WSO2 Identity Server',
2529
'terms.of.service': 'Terms of Servicet',
2630
};

packages/core/src/i18n/screens/common/fr-FR.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ import {Common} from './model';
2020

2121
export const common: Common = {
2222
copyright: '© {{currentYear}} WSO2 LLC.',
23+
error: "Quelque chose s'est mal passé. Veuillez réessayer.",
24+
or: 'OU',
25+
'prefix.register': "Vous n'avez pas de compte?",
2326
'privacy.policy': 'Politique de confidentialité',
27+
register: "S'inscrire",
2428
'site.title': 'Identity Server WSO2',
2529
'terms.of.service': 'Conditions de service',
2630
};

packages/core/src/i18n/screens/common/model.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@
2121
*/
2222
export interface Common {
2323
copyright: string;
24+
error: string;
25+
or: string;
26+
'prefix.register': string;
2427
'privacy.policy': string;
28+
register: string;
2529
'site.title': string;
2630
'terms.of.service': string;
2731
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
3+
*
4+
* WSO2 LLC. licenses this file to you under the Apache License,
5+
* Version 2.0 (the "License"); you may not use this file except
6+
* in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing,
12+
* software distributed under the License is distributed on an
13+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
* KIND, either express or implied. See the License for the
15+
* specific language governing permissions and limitations
16+
* under the License.
17+
*/
18+
19+
import {EmailOTP} from './model';
20+
21+
export const emailOtp: EmailOTP = {
22+
continue: 'Continue',
23+
'email.otp.heading': 'OTP Verification',
24+
'enter.verification.code.got.by.device': 'Enter the code sent to your email ID.',
25+
'resend.code': 'Resend code',
26+
};
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
3+
*
4+
* WSO2 LLC. licenses this file to you under the Apache License,
5+
* Version 2.0 (the "License"); you may not use this file except
6+
* in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing,
12+
* software distributed under the License is distributed on an
13+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
* KIND, either express or implied. See the License for the
15+
* specific language governing permissions and limitations
16+
* under the License.
17+
*/
18+
19+
/**
20+
* Interface for the TOTP text.
21+
*/
22+
export interface EmailOTP {
23+
continue: string;
24+
'email.otp.heading': string;
25+
'enter.verification.code.got.by.device': string;
26+
'resend.code': string;
27+
}

0 commit comments

Comments
 (0)