Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
bc8bb9f
feat(react): :sparkles: handle loading states in basic auth and totp
movinsilva May 16, 2024
2d404b5
chore(react): :heavy_plus_sign: add rollup plugin packages
movinsilva May 16, 2024
9edf524
feat(react): :package: add rollup
movinsilva May 17, 2024
fda3da9
feat(react): :sparkles: add showSignUp prop for SignIn component & up…
movinsilva May 17, 2024
3c7994b
feat(react): :lipstick: add styling for textfields
movinsilva May 17, 2024
dbaf229
fix(react): :bug: fix display name for local options in multi option …
movinsilva May 17, 2024
ba06c47
feat(react): :sparkles: clean totp entered upon submitting
movinsilva May 17, 2024
c5f61b4
feat(react): :technologist: improve loading state of the signin button
movinsilva May 17, 2024
cccfe89
feat(react): :technologist: introduce auth loading state for social l…
movinsilva May 17, 2024
90b1d54
feat(react): :sparkles: update emailOtp to handle both screens: usern…
movinsilva May 19, 2024
6e24f44
feat(react): :sparkles: add placeholder for emailotp username textfield
movinsilva May 19, 2024
969b2c7
feat(react): :technologist: improve loading states of email otp
movinsilva May 19, 2024
7ff39ed
fix(react): :goal_net: handle error state of authn
movinsilva May 19, 2024
90f8e49
feat(react): :sparkles: add alert when basic auth is missing
movinsilva May 19, 2024
685e316
feat(react): :sparkles: add totp alert
movinsilva May 19, 2024
642b07e
feat(react): :sparkles: add loading state for sign in button
movinsilva May 19, 2024
87d78e9
fix(react): :lipstick: remove padding from signin button
movinsilva May 19, 2024
dedc3da
feat(react): :sparkles: introduce new props for signin and signin but…
movinsilva May 19, 2024
9695b2d
refactor(core): :recycle: set default values for some configs in auth…
movinsilva May 20, 2024
be2c4a6
fix(react): :adhesive_bandage: improve authorize call in SignIn
movinsilva May 20, 2024
619e4be
fix(react): :adhesive_bandage: add null check when acessing authentic…
movinsilva May 20, 2024
7bb052c
refactor(react): :recycle: introduce a new constant for the default l…
movinsilva May 20, 2024
8a1d174
fix(react): :label: add types for username, password and totp
movinsilva May 20, 2024
d9ffebc
refactor(react): :label: update jsx.element types to reactelement
movinsilva May 20, 2024
c90521f
refactor(react): :recycle: refactor fallback values in control compon…
movinsilva May 20, 2024
07d3f0f
feat(react): :bento: add sms and totp icons
movinsilva May 20, 2024
9491056
feat(sample-app): :coffin: update sample app
movinsilva May 20, 2024
fc7ef3e
fix(sample-app): :coffin: remove unused file
movinsilva May 20, 2024
e557552
fix(react): :construction: update sample app
movinsilva May 20, 2024
6ab62f0
feat(react): :lipstick: update generateThemeSignIn function
movinsilva May 20, 2024
a8a8ead
feat: :globe_with_meridians: add some common strings for i18n
movinsilva May 20, 2024
5478a3e
feat(react): :sparkles: add useOn custom hook for onSignIn and onSign…
movinsilva May 21, 2024
9be9ee7
chore(sample-app): :wrench: untrack .env file
movinsilva May 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/core/src/auth-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

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

/**
* The `AuthClient` class is a singleton class that provides an instance of the `UIAuthClient`.
Expand All @@ -42,9 +43,15 @@ export class AuthClient {
*/
static getInstance(authClientConfig?: UIAuthConfig, store?: Store, cryptoUtils?: CryptoUtils): UIAuthClient {
if (!AuthClient.instance) {
const DEFAULT_NAME: string = 'carbon.super';

const extendedAuthClientConfig: UIAuthConfig = {
...authClientConfig,
enableConsoleBranding: authClientConfig?.enableConsoleBranding ?? true,
enableConsoleTextBranding: authClientConfig?.enableConsoleTextBranding ?? true,
Comment on lines +50 to +51
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the console part here? How about enableBranding and enableTextBranding? @brionmario @dasuni-30 WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Branding is taken from props as well.
Need to specify this is coming from asgardeo/IS, right?

name: authClientConfig?.name ?? DEFAULT_NAME,
responseMode: ResponseMode.direct,
type: authClientConfig?.type ?? BrandingPreferenceTypes.Org,
};

AuthClient.instance = new AsgardeoAuthClient();
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/branding/get-branding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ const getBranding = async (props: GetBrandingProps): Promise<Branding> => {
let brandingFromConsole: BrandingPreferenceAPIResponse;

try {
if ((await AuthClient.getInstance().getDataLayer().getConfigData()).enableConsoleBranding ?? true) {
const {enableConsoleBranding} = await AuthClient.getInstance().getDataLayer().getConfigData();

if (enableConsoleBranding) {
brandingFromConsole = await getBrandingPreference();
}
} catch {
Expand Down
9 changes: 3 additions & 6 deletions packages/core/src/i18n/get-localization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {TextObject} from './screens/model';
import getBrandingPreferenceText from '../api/get-branding-preference-text';
import {AuthClient} from '../auth-client';
import {UIAuthConfig} from '../models/auth-config';
import {BrandingPreferenceTypes} from '../models/branding-api-response';
import {BrandingPreferenceTextAPIResponse} from '../models/branding-text-api-response';
import GetLocalizationProps from '../models/get-localization-props';

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

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

const DEFAULT_NAME: string = 'carbon.super';

try {
if (configData.enableConsoleTextBranding ?? true) {
if (configData.enableConsoleTextBranding) {
textFromConsoleBranding = await getBrandingPreferenceText({
locale,
name: configData.name ?? DEFAULT_NAME,
name: configData.name,
screen,
type: configData.type ?? BrandingPreferenceTypes.Org,
type: configData.type,
});
}
} catch (error) {
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/i18n/screens/common/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
import {Common} from './model';

export const common: Common = {
'common.title': 'Sign In',
copyright: '© {{currentYear}} WSO2 LLC.',
error: 'Something went wrong. Please try again.',
'multiple.options.prefix': 'Sign in with',
or: 'OR',
'prefix.register': "Don't have an account?",
'privacy.policy': 'Privacy Policy',
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/i18n/screens/common/fr-FR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
import {Common} from './model';

export const common: Common = {
'common.title': "S'identifier",
copyright: '© {{currentYear}} WSO2 LLC.',
error: "Quelque chose s'est mal passé. Veuillez réessayer.",
'multiple.options.prefix': 'Se connecter avec',
or: 'OU',
'prefix.register': "Vous n'avez pas de compte?",
'privacy.policy': 'Politique de confidentialité',
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/i18n/screens/common/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
* Interface for the common text.
*/
export interface Common {
'common.title': string;
copyright: string;
error: string;
'multiple.options.prefix': string;
or: string;
'prefix.register': string;
'privacy.policy': string;
Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/i18n/screens/emailOtp/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ import {EmailOTP} from './model';

export const emailOtp: EmailOTP = {
continue: 'Continue',
'email.heading': 'Sign In',
'email.otp.heading': 'OTP Verification',
'enter.verification.code.got.by.device': 'Enter the code sent to your email ID.',
'resend.code': 'Resend code',
'username.label': 'Username',
'username.placeholder': 'Enter your username',
};
3 changes: 3 additions & 0 deletions packages/core/src/i18n/screens/emailOtp/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
*/
export interface EmailOTP {
continue: string;
'email.heading': string;
'email.otp.heading': string;
'enter.verification.code.got.by.device': string;
'resend.code': string;
'username.label': string;
'username.placeholder': string;
}
26 changes: 26 additions & 0 deletions packages/core/src/i18n/screens/keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,16 @@
*/
interface Keys {
common: {
common: {
title: string;
};
copyright: string;
error: string;
multiple: {
options: {
prefix: string;
};
};
or: string;
prefix: {
register: string;
Expand All @@ -43,6 +51,7 @@ interface Keys {
emailOtp: {
continue: string;
email: {
heading: string;
otp: {
heading: string;
};
Expand All @@ -61,6 +70,10 @@ interface Keys {
resend: {
code: string;
};
username: {
label: string;
placeholder: string;
};
};
login: {
button: string;
Expand Down Expand Up @@ -116,8 +129,16 @@ interface Keys {

export const keys: Keys = {
common: {
common: {
title: 'common.common.title',
},
copyright: 'common.copyright',
error: 'common.error',
multiple: {
options: {
prefix: 'common.multiple.options.prefix',
},
},
or: 'common.or',
prefix: {
register: 'common.prefix.register',
Expand All @@ -138,6 +159,7 @@ export const keys: Keys = {
emailOtp: {
continue: 'emailOtp.continue',
email: {
heading: 'emailOtp.email.heading',
otp: {
heading: 'emailOtp.email.otp.heading',
},
Expand All @@ -156,6 +178,10 @@ export const keys: Keys = {
resend: {
code: 'emailOtp.resend.code',
},
username: {
label: 'emailOtp.username.label',
placeholder: 'emailOtp.username.placeholder',
},
},
login: {
button: 'login.login.button',
Expand Down
10 changes: 9 additions & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
"access": "public"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-image": "^3.0.3",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-typescript": "^11.1.6",
"@types/node": "^20.12.7",
"@types/randombytes": "^2.0.3",
"@types/react": "^18.2.79",
Expand All @@ -44,6 +48,9 @@
"prettier": "^3.2.5",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"rollup-plugin-dts": "^6.1.0",
"rollup-plugin-polyfill-node": "^0.13.0",
"rollup-plugin-styles": "^4.0.0",
"sass": "^1.75.0",
"stylelint": "15.1.0",
"tslib": "^2.6.2",
Expand All @@ -57,7 +64,8 @@
"clsx": "^2.1.1",
"fast-sha256": "^1.3.0",
"jose": "^5.3.0",
"randombytes": "^2.1.0"
"randombytes": "^2.1.0",
"rollup": "^4.17.2"
},
"peerDependencies": {
"react": ">=18.0.0",
Expand Down
73 changes: 73 additions & 0 deletions packages/react/rollup.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/**
* Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

const commonjs = require('@rollup/plugin-commonjs');
const image = require('@rollup/plugin-image');
const nodeResolve = require('@rollup/plugin-node-resolve');
const typescript = require('@rollup/plugin-typescript');
const dts = require('rollup-plugin-dts');
const nodePolyfills = require('rollup-plugin-polyfill-node');
const styles = require('rollup-plugin-styles');

const pkg = require('./package.json');

module.exports = [
{
cache: false,
external: ['react', 'react-dom'],
input: 'src/index.ts',
onwarn(warning, warn) {
// Suppress this error message... there are hundreds of them
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to supress this error?

if (warning.code === 'MODULE_LEVEL_DIRECTIVE') return;
// Use default for everything else
warn(warning);
},
output: [
{
file: pkg.main,
format: 'cjs',
sourcemap: true,
},
{
file: pkg.module,
format: 'esm',
sourcemap: true,
},
],
plugins: [
nodePolyfills(),
nodeResolve({
browser: true,
preferBuiltins: true,
}),
commonjs(),
typescript({tsconfig: './tsconfig.lib.json'}),
styles({
mode: 'inject',
}),
image(),
],
},
{
cache: false,
external: [/\.(sass|scss|css)$/] /* ignore style files */,
input: 'dist/esm/types/index.d.ts',
output: [{file: 'dist/index.d.ts', format: 'esm'}],
plugins: [dts.default()],
},
];
2 changes: 1 addition & 1 deletion packages/react/src/assets/email-solid.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions packages/react/src/assets/sms-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions packages/react/src/assets/totp.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading