Skip to content

Commit d26d511

Browse files
authored
Merge pull request #15 from movinsilva/react--loaders
feat(react): add loading states, update SignIn and sample app, Add rollup for react.
2 parents d951d7c + 9be9ee7 commit d26d511

Some content is hidden

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

47 files changed

+2755
-369
lines changed

packages/core/src/auth-client.ts

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

1919
import {AsgardeoAuthClient, Store, CryptoUtils, ResponseMode} from '@asgardeo/auth-js';
2020
import {UIAuthClient, UIAuthConfig} from './models/auth-config';
21+
import {BrandingPreferenceTypes} from './models/branding-api-response';
2122

2223
/**
2324
* The `AuthClient` class is a singleton class that provides an instance of the `UIAuthClient`.
@@ -42,9 +43,15 @@ export class AuthClient {
4243
*/
4344
static getInstance(authClientConfig?: UIAuthConfig, store?: Store, cryptoUtils?: CryptoUtils): UIAuthClient {
4445
if (!AuthClient.instance) {
46+
const DEFAULT_NAME: string = 'carbon.super';
47+
4548
const extendedAuthClientConfig: UIAuthConfig = {
4649
...authClientConfig,
50+
enableConsoleBranding: authClientConfig?.enableConsoleBranding ?? true,
51+
enableConsoleTextBranding: authClientConfig?.enableConsoleTextBranding ?? true,
52+
name: authClientConfig?.name ?? DEFAULT_NAME,
4753
responseMode: ResponseMode.direct,
54+
type: authClientConfig?.type ?? BrandingPreferenceTypes.Org,
4855
};
4956

5057
AuthClient.instance = new AsgardeoAuthClient();

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ const getBranding = async (props: GetBrandingProps): Promise<Branding> => {
4242
let brandingFromConsole: BrandingPreferenceAPIResponse;
4343

4444
try {
45-
if ((await AuthClient.getInstance().getDataLayer().getConfigData()).enableConsoleBranding ?? true) {
45+
const {enableConsoleBranding} = await AuthClient.getInstance().getDataLayer().getConfigData();
46+
47+
if (enableConsoleBranding) {
4648
brandingFromConsole = await getBrandingPreference();
4749
}
4850
} catch {

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import {TextObject} from './screens/model';
2222
import getBrandingPreferenceText from '../api/get-branding-preference-text';
2323
import {AuthClient} from '../auth-client';
2424
import {UIAuthConfig} from '../models/auth-config';
25-
import {BrandingPreferenceTypes} from '../models/branding-api-response';
2625
import {BrandingPreferenceTextAPIResponse} from '../models/branding-text-api-response';
2726
import GetLocalizationProps from '../models/get-localization-props';
2827

@@ -41,15 +40,13 @@ const getLocalization = async (props: GetLocalizationProps): Promise<TextObject>
4140

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

44-
const DEFAULT_NAME: string = 'carbon.super';
45-
4643
try {
47-
if (configData.enableConsoleTextBranding ?? true) {
44+
if (configData.enableConsoleTextBranding) {
4845
textFromConsoleBranding = await getBrandingPreferenceText({
4946
locale,
50-
name: configData.name ?? DEFAULT_NAME,
47+
name: configData.name,
5148
screen,
52-
type: configData.type ?? BrandingPreferenceTypes.Org,
49+
type: configData.type,
5350
});
5451
}
5552
} catch (error) {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919
import {Common} from './model';
2020

2121
export const common: Common = {
22+
'common.title': 'Sign In',
2223
copyright: '© {{currentYear}} WSO2 LLC.',
2324
error: 'Something went wrong. Please try again.',
25+
'multiple.options.prefix': 'Sign in with',
2426
or: 'OR',
2527
'prefix.register': "Don't have an account?",
2628
'privacy.policy': 'Privacy Policy',

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919
import {Common} from './model';
2020

2121
export const common: Common = {
22+
'common.title': "S'identifier",
2223
copyright: '© {{currentYear}} WSO2 LLC.',
2324
error: "Quelque chose s'est mal passé. Veuillez réessayer.",
25+
'multiple.options.prefix': 'Se connecter avec',
2426
or: 'OU',
2527
'prefix.register': "Vous n'avez pas de compte?",
2628
'privacy.policy': 'Politique de confidentialité',

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@
2020
* Interface for the common text.
2121
*/
2222
export interface Common {
23+
'common.title': string;
2324
copyright: string;
2425
error: string;
26+
'multiple.options.prefix': string;
2527
or: string;
2628
'prefix.register': string;
2729
'privacy.policy': string;

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

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

2121
export const emailOtp: EmailOTP = {
2222
continue: 'Continue',
23+
'email.heading': 'Sign In',
2324
'email.otp.heading': 'OTP Verification',
2425
'enter.verification.code.got.by.device': 'Enter the code sent to your email ID.',
2526
'resend.code': 'Resend code',
27+
'username.label': 'Username',
28+
'username.placeholder': 'Enter your username',
2629
};

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@
2121
*/
2222
export interface EmailOTP {
2323
continue: string;
24+
'email.heading': string;
2425
'email.otp.heading': string;
2526
'enter.verification.code.got.by.device': string;
2627
'resend.code': string;
28+
'username.label': string;
29+
'username.placeholder': string;
2730
}

packages/core/src/i18n/screens/keys.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,16 @@
2121
*/
2222
interface Keys {
2323
common: {
24+
common: {
25+
title: string;
26+
};
2427
copyright: string;
2528
error: string;
29+
multiple: {
30+
options: {
31+
prefix: string;
32+
};
33+
};
2634
or: string;
2735
prefix: {
2836
register: string;
@@ -43,6 +51,7 @@ interface Keys {
4351
emailOtp: {
4452
continue: string;
4553
email: {
54+
heading: string;
4655
otp: {
4756
heading: string;
4857
};
@@ -61,6 +70,10 @@ interface Keys {
6170
resend: {
6271
code: string;
6372
};
73+
username: {
74+
label: string;
75+
placeholder: string;
76+
};
6477
};
6578
login: {
6679
button: string;
@@ -116,8 +129,16 @@ interface Keys {
116129

117130
export const keys: Keys = {
118131
common: {
132+
common: {
133+
title: 'common.common.title',
134+
},
119135
copyright: 'common.copyright',
120136
error: 'common.error',
137+
multiple: {
138+
options: {
139+
prefix: 'common.multiple.options.prefix',
140+
},
141+
},
121142
or: 'common.or',
122143
prefix: {
123144
register: 'common.prefix.register',
@@ -138,6 +159,7 @@ export const keys: Keys = {
138159
emailOtp: {
139160
continue: 'emailOtp.continue',
140161
email: {
162+
heading: 'emailOtp.email.heading',
141163
otp: {
142164
heading: 'emailOtp.email.otp.heading',
143165
},
@@ -156,6 +178,10 @@ export const keys: Keys = {
156178
resend: {
157179
code: 'emailOtp.resend.code',
158180
},
181+
username: {
182+
label: 'emailOtp.username.label',
183+
placeholder: 'emailOtp.username.placeholder',
184+
},
159185
},
160186
login: {
161187
button: 'login.login.button',

packages/react/package.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
"access": "public"
3434
},
3535
"devDependencies": {
36+
"@rollup/plugin-commonjs": "^25.0.7",
37+
"@rollup/plugin-image": "^3.0.3",
38+
"@rollup/plugin-node-resolve": "^15.2.3",
39+
"@rollup/plugin-typescript": "^11.1.6",
3640
"@types/node": "^20.12.7",
3741
"@types/randombytes": "^2.0.3",
3842
"@types/react": "^18.2.79",
@@ -44,6 +48,9 @@
4448
"prettier": "^3.2.5",
4549
"react": "^18.2.0",
4650
"react-dom": "^18.2.0",
51+
"rollup-plugin-dts": "^6.1.0",
52+
"rollup-plugin-polyfill-node": "^0.13.0",
53+
"rollup-plugin-styles": "^4.0.0",
4754
"sass": "^1.75.0",
4855
"stylelint": "15.1.0",
4956
"tslib": "^2.6.2",
@@ -57,7 +64,8 @@
5764
"clsx": "^2.1.1",
5865
"fast-sha256": "^1.3.0",
5966
"jose": "^5.3.0",
60-
"randombytes": "^2.1.0"
67+
"randombytes": "^2.1.0",
68+
"rollup": "^4.17.2"
6169
},
6270
"peerDependencies": {
6371
"react": ">=18.0.0",

0 commit comments

Comments
 (0)