@asgardeo/react 0.2.4 → 0.4.0
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/README.md +112 -6
- package/dist/AsgardeoReactClient.d.ts +38 -0
- package/dist/__temp__/api.d.ts +228 -0
- package/dist/__temp__/models.d.ts +97 -0
- package/dist/api/scim2/getMeProfile.d.ts +39 -0
- package/dist/api/scim2/getSchemas.d.ts +39 -0
- package/dist/api/scim2/updateMeProfile.d.ts +38 -0
- package/dist/cjs/index.js +17998 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/components/actions/SignInButton/BaseSignInButton.d.ts +66 -0
- package/dist/components/actions/SignInButton/SignInButton.d.ts +65 -0
- package/dist/components/actions/SignOutButton/BaseSignOutButton.d.ts +66 -0
- package/dist/components/actions/SignOutButton/SignOutButton.d.ts +65 -0
- package/dist/components/actions/SignUpButton/BaseSignUpButton.d.ts +66 -0
- package/dist/components/actions/SignUpButton/SignUpButton.d.ts +66 -0
- package/dist/components/control/SignedIn.d.ts +45 -0
- package/dist/components/control/SignedOut.d.ts +45 -0
- package/dist/components/factories/FieldFactory.d.ts +107 -0
- package/dist/components/presentation/SignIn/BaseSignIn.d.ts +125 -0
- package/dist/components/presentation/SignIn/SignIn.d.ts +62 -0
- package/dist/{esm/types/hooks/use-config.d.ts → components/presentation/SignIn/options/EmailOtp.d.ts} +7 -5
- package/dist/components/presentation/SignIn/options/FacebookButton.d.ts +25 -0
- package/dist/components/presentation/SignIn/options/GitHubButton.d.ts +25 -0
- package/dist/components/presentation/SignIn/options/GoogleButton.d.ts +25 -0
- package/dist/components/presentation/SignIn/options/IdentifierFirst.d.ts +25 -0
- package/dist/components/presentation/SignIn/options/LinkedInButton.d.ts +25 -0
- package/dist/{esm/types/components/SignIn/fragments/SmsOtp.d.ts → components/presentation/SignIn/options/MicrosoftButton.d.ts} +9 -5
- package/dist/components/presentation/SignIn/options/MultiOptionButton.d.ts +26 -0
- package/dist/components/presentation/SignIn/options/SignInOptionFactory.d.ts +76 -0
- package/dist/{esm/types/components/SignOutButton/SignOutButton.d.ts → components/presentation/SignIn/options/SignInWithEthereumButton.d.ts} +7 -9
- package/dist/{esm/types/contexts/branding-preference-context.d.ts → components/presentation/SignIn/options/SmsOtp.d.ts} +9 -5
- package/dist/components/presentation/SignIn/options/SocialButton.d.ts +25 -0
- package/dist/{esm/types/contexts/asgardeo-context.d.ts → components/presentation/SignIn/options/Totp.d.ts} +9 -5
- package/dist/components/presentation/SignIn/options/UsernamePassword.d.ts +25 -0
- package/dist/components/presentation/SignIn/types.d.ts +124 -0
- package/dist/components/presentation/User/BaseUser.d.ts +66 -0
- package/dist/components/presentation/User/User.d.ts +62 -0
- package/dist/components/presentation/UserDropdown/BaseUserDropdown.d.ts +76 -0
- package/dist/components/presentation/UserDropdown/UserDropdown.d.ts +49 -0
- package/dist/components/presentation/UserProfile/BaseUserProfile.d.ts +63 -0
- package/dist/components/presentation/UserProfile/UserProfile.d.ts +49 -0
- package/dist/components/primitives/Alert/Alert.d.ts +74 -0
- package/dist/{esm/types/components/SignIn/SignIn.d.ts → components/primitives/Avatar/Avatar.d.ts} +25 -14
- package/dist/components/primitives/Button/Button.d.ts +83 -0
- package/dist/components/primitives/Card/Card.d.ts +133 -0
- package/dist/{esm/types/oxygen-ui-react-auth-components/models/component.d.ts → components/primitives/Checkbox/Checkbox.d.ts} +22 -7
- package/dist/components/primitives/DatePicker/DatePicker.d.ts +50 -0
- package/dist/components/primitives/Divider/Divider.d.ts +58 -0
- package/dist/components/primitives/FormControl/FormControl.d.ts +50 -0
- package/dist/components/primitives/Icons/CircleAlert.d.ts +23 -0
- package/dist/components/primitives/Icons/CircleCheck.d.ts +23 -0
- package/dist/{esm/types/models/use-config.d.ts → components/primitives/Icons/Eye.d.ts} +7 -6
- package/dist/{esm/types/contexts/i18n-context.d.ts → components/primitives/Icons/EyeOff.d.ts} +7 -5
- package/dist/{esm/types/hooks/use-on.d.ts → components/primitives/Icons/Info.d.ts} +7 -4
- package/dist/components/primitives/Icons/TriangleAlert.d.ts +23 -0
- package/dist/components/primitives/InputLabel/InputLabel.d.ts +46 -0
- package/dist/components/primitives/OtpField/OtpField.d.ts +86 -0
- package/dist/{esm/types/components/SignInButton/SignInButton.d.ts → components/primitives/PasswordField/PasswordField.d.ts} +13 -11
- package/dist/components/primitives/Popover/Popover.d.ts +96 -0
- package/dist/components/primitives/Select/Select.d.ts +60 -0
- package/dist/components/primitives/Spinner/Spinner.d.ts +54 -0
- package/dist/components/primitives/TextField/TextField.d.ts +62 -0
- package/dist/components/primitives/Typography/Typography.d.ts +81 -0
- package/dist/contexts/Asgardeo/AsgardeoContext.d.ts +57 -0
- package/dist/{esm/types/components/public-components.d.ts → contexts/Asgardeo/AsgardeoProvider.d.ts} +9 -6
- package/dist/contexts/Asgardeo/useAsgardeo.d.ts +20 -0
- package/dist/contexts/Flow/FlowContext.d.ts +73 -0
- package/dist/contexts/Flow/FlowProvider.d.ts +46 -0
- package/dist/contexts/Flow/useFlow.d.ts +48 -0
- package/dist/contexts/I18n/I18nContext.d.ts +42 -0
- package/dist/{esm/types/components/SignedIn/SignedIn.d.ts → contexts/I18n/I18nProvider.d.ts} +12 -10
- package/dist/contexts/I18n/useI18n.d.ts +27 -0
- package/dist/{esm/types/models/asgardeo-provider-props.d.ts → contexts/Theme/ThemeContext.d.ts} +8 -7
- package/dist/{esm/types/models/branding-preference-provider-props.d.ts → contexts/Theme/ThemeProvider.d.ts} +8 -5
- package/dist/{esm/types/models/use-on.d.ts → contexts/Theme/types.d.ts} +22 -12
- package/dist/{esm/types/models/signed-props.d.ts → contexts/Theme/useTheme.d.ts} +4 -6
- package/dist/contexts/User/UserContext.d.ts +32 -0
- package/dist/contexts/User/UserProvider.d.ts +55 -0
- package/dist/contexts/User/useUser.d.ts +94 -0
- package/dist/hooks/useBrowserUrl.d.ts +47 -0
- package/dist/hooks/useForm.d.ts +192 -0
- package/dist/hooks/useTranslation.d.ts +52 -0
- package/dist/index.d.ts +121 -348
- package/dist/index.js +18064 -0
- package/dist/index.js.map +7 -0
- package/dist/{esm/types/models/public-models.d.ts → models/config.d.ts} +3 -3
- package/dist/utils/getMappedUserProfileValue.d.ts +51 -0
- package/package.json +55 -59
- package/dist/esm/index.js +0 -45278
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/types/components/SignIn/fragments/BasicAuth.d.ts +0 -35
- package/dist/esm/types/components/SignIn/fragments/EmailOtp.d.ts +0 -32
- package/dist/esm/types/components/SignIn/fragments/IdentifierFirst.d.ts +0 -35
- package/dist/esm/types/components/SignIn/fragments/LoginOptionsBox.d.ts +0 -30
- package/dist/esm/types/components/SignIn/fragments/Totp.d.ts +0 -33
- package/dist/esm/types/components/SignedOut/SignedOut.d.ts +0 -29
- package/dist/esm/types/hooks/use-authentication.d.ts +0 -27
- package/dist/esm/types/hooks/use-translations.d.ts +0 -33
- package/dist/esm/types/index.d.ts +0 -22
- package/dist/esm/types/models/auth-context.d.ts +0 -43
- package/dist/esm/types/models/basic-auth-props.d.ts +0 -29
- package/dist/esm/types/models/email-otp-props.d.ts +0 -26
- package/dist/esm/types/models/i18n.d.ts +0 -34
- package/dist/esm/types/models/jwt-verify-options.d.ts +0 -25
- package/dist/esm/types/models/login-options-box-props.d.ts +0 -24
- package/dist/esm/types/models/sign-in.d.ts +0 -49
- package/dist/esm/types/models/totp-props.d.ts +0 -26
- package/dist/esm/types/models/use-authentication.d.ts +0 -29
- package/dist/esm/types/models/use-translations.d.ts +0 -22
- package/dist/esm/types/oxygen-ui-react-auth-components/SignIn/SignIn.d.ts +0 -79
- package/dist/esm/types/oxygen-ui-react-auth-components/SignInAlert/SignInAlert.d.ts +0 -37
- package/dist/esm/types/oxygen-ui-react-auth-components/SignInButton/SignInButton.d.ts +0 -27
- package/dist/esm/types/oxygen-ui-react-auth-components/SignInDivider/SignInDivider.d.ts +0 -26
- package/dist/esm/types/oxygen-ui-react-auth-components/SignInFooter/SignInFooter.d.ts +0 -29
- package/dist/esm/types/oxygen-ui-react-auth-components/SignInImage/SignInImage.d.ts +0 -23
- package/dist/esm/types/oxygen-ui-react-auth-components/SignInLink/SignInLink.d.ts +0 -25
- package/dist/esm/types/oxygen-ui-react-auth-components/SignInPaper/SignInPaper.d.ts +0 -26
- package/dist/esm/types/oxygen-ui-react-auth-components/SignInPinInput/SignInPinInput.d.ts +0 -30
- package/dist/esm/types/oxygen-ui-react-auth-components/SignInTextField/SignInTextField.d.ts +0 -26
- package/dist/esm/types/oxygen-ui-react-auth-components/SignInTypography/SignInTypography.d.ts +0 -32
- package/dist/esm/types/oxygen-ui-react-auth-components/index.d.ts +0 -19
- package/dist/esm/types/providers/AsgardeoProvider.d.ts +0 -34
- package/dist/esm/types/providers/BrandingPreferenceProvider.d.ts +0 -32
- package/dist/esm/types/providers/I18nProvider.d.ts +0 -33
- package/dist/esm/types/theme/generate-theme-sign-in.d.ts +0 -28
- package/dist/esm/types/theme/generate-theme.d.ts +0 -30
- package/dist/esm/types/utils/crypto-utils.d.ts +0 -52
- package/dist/esm/types/utils/session-store.d.ts +0 -25
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025, 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
|
+
import { I18nBundle } from '@asgardeo/browser';
|
|
19
|
+
export interface I18nContextValue {
|
|
20
|
+
/**
|
|
21
|
+
* The current language code (e.g., 'en-US', 'fr-FR')
|
|
22
|
+
*/
|
|
23
|
+
currentLanguage: string;
|
|
24
|
+
/**
|
|
25
|
+
* The fallback language code
|
|
26
|
+
*/
|
|
27
|
+
fallbackLanguage: string;
|
|
28
|
+
/**
|
|
29
|
+
* All available i18n bundles (default + user provided)
|
|
30
|
+
*/
|
|
31
|
+
bundles: Record<string, I18nBundle>;
|
|
32
|
+
/**
|
|
33
|
+
* Function to change the current language
|
|
34
|
+
*/
|
|
35
|
+
setLanguage: (language: string) => void;
|
|
36
|
+
/**
|
|
37
|
+
* Function to get a translation by key with optional parameters
|
|
38
|
+
*/
|
|
39
|
+
t: (key: string, params?: Record<string, string | number>) => string;
|
|
40
|
+
}
|
|
41
|
+
declare const I18nContext: import("react").Context<I18nContextValue>;
|
|
42
|
+
export default I18nContext;
|
package/dist/{esm/types/components/SignedIn/SignedIn.d.ts → contexts/I18n/I18nProvider.d.ts}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
|
|
3
3
|
*
|
|
4
4
|
* WSO2 LLC. licenses this file to you under the Apache License,
|
|
5
5
|
* Version 2.0 (the "License"); you may not use this file except
|
|
@@ -16,14 +16,16 @@
|
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
18
|
import { FC, PropsWithChildren } from 'react';
|
|
19
|
-
import
|
|
19
|
+
import { I18nPreferences } from '@asgardeo/browser';
|
|
20
|
+
export interface I18nProviderProps {
|
|
21
|
+
/**
|
|
22
|
+
* The i18n preferences from the AsgardeoProvider
|
|
23
|
+
*/
|
|
24
|
+
preferences?: I18nPreferences;
|
|
25
|
+
}
|
|
20
26
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* @param {PropsWithChildren<SignedProps>} props - Props injected to the component.
|
|
24
|
-
* @param {ReactElement} props.fallback - Fallback element to render.
|
|
25
|
-
*
|
|
26
|
-
* @return {JSX.Element}
|
|
27
|
+
* I18nProvider component that manages internationalization state and provides
|
|
28
|
+
* translation functions to child components.
|
|
27
29
|
*/
|
|
28
|
-
declare const
|
|
29
|
-
export default
|
|
30
|
+
declare const I18nProvider: FC<PropsWithChildren<I18nProviderProps>>;
|
|
31
|
+
export default I18nProvider;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025, 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
|
+
import { I18nContextValue } from './I18nContext';
|
|
19
|
+
/**
|
|
20
|
+
* Hook for accessing the I18n context directly.
|
|
21
|
+
* Provides access to the full i18n context including bundles and all utilities.
|
|
22
|
+
*
|
|
23
|
+
* @returns The complete I18n context value
|
|
24
|
+
* @throws Error if used outside of I18nProvider context
|
|
25
|
+
*/
|
|
26
|
+
declare const useI18n: () => I18nContextValue;
|
|
27
|
+
export default useI18n;
|
package/dist/{esm/types/models/asgardeo-provider-props.d.ts → contexts/Theme/ThemeContext.d.ts}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
|
|
3
3
|
*
|
|
4
4
|
* WSO2 LLC. licenses this file to you under the Apache License,
|
|
5
5
|
* Version 2.0 (the "License"); you may not use this file except
|
|
@@ -15,10 +15,11 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
-
import {
|
|
19
|
-
interface
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
import { Theme } from '@asgardeo/browser';
|
|
19
|
+
export interface ThemeContextValue {
|
|
20
|
+
theme: Theme;
|
|
21
|
+
colorScheme: 'light' | 'dark';
|
|
22
|
+
toggleTheme: () => void;
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
declare const ThemeContext: import("react").Context<ThemeContextValue>;
|
|
25
|
+
export default ThemeContext;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
|
|
3
3
|
*
|
|
4
4
|
* WSO2 LLC. licenses this file to you under the Apache License,
|
|
5
5
|
* Version 2.0 (the "License"); you may not use this file except
|
|
@@ -15,8 +15,11 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
import { FC, PropsWithChildren } from 'react';
|
|
19
|
+
import { ThemeConfig, RecursivePartial } from '@asgardeo/browser';
|
|
20
|
+
export interface ThemeProviderProps {
|
|
21
|
+
theme?: RecursivePartial<ThemeConfig>;
|
|
22
|
+
defaultColorScheme?: 'light' | 'dark';
|
|
21
23
|
}
|
|
22
|
-
|
|
24
|
+
declare const ThemeProvider: FC<PropsWithChildren<ThemeProviderProps>>;
|
|
25
|
+
export default ThemeProvider;
|
|
@@ -15,17 +15,27 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
-
export
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
export interface ThemeColors {
|
|
19
|
+
primary: string;
|
|
20
|
+
background: string;
|
|
21
|
+
surface: string;
|
|
22
|
+
text: {
|
|
23
|
+
primary: string;
|
|
24
|
+
secondary: string;
|
|
25
|
+
};
|
|
26
|
+
border: string;
|
|
21
27
|
}
|
|
22
|
-
export interface
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
export interface ThemeConfig {
|
|
29
|
+
colors: ThemeColors;
|
|
30
|
+
spacing: {
|
|
31
|
+
unit: number;
|
|
32
|
+
};
|
|
33
|
+
borderRadius: {
|
|
34
|
+
small: string;
|
|
35
|
+
medium: string;
|
|
36
|
+
large: string;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export interface Theme extends ThemeConfig {
|
|
40
|
+
cssVariables: Record<string, string>;
|
|
31
41
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
|
|
3
3
|
*
|
|
4
4
|
* WSO2 LLC. licenses this file to you under the Apache License,
|
|
5
5
|
* Version 2.0 (the "License"); you may not use this file except
|
|
@@ -15,8 +15,6 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
export default SignedProps;
|
|
18
|
+
import { ThemeContextValue } from './ThemeContext';
|
|
19
|
+
declare const useTheme: () => ThemeContextValue;
|
|
20
|
+
export default useTheme;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025, 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
|
+
import { Context } from 'react';
|
|
19
|
+
import { User, Schema } from '@asgardeo/browser';
|
|
20
|
+
/**
|
|
21
|
+
* Props interface of {@link UserContext}
|
|
22
|
+
*/
|
|
23
|
+
export type UserContextProps = {
|
|
24
|
+
profile: User | null;
|
|
25
|
+
schemas: Schema[] | null;
|
|
26
|
+
flattenedProfile: User | null;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Context object for managing user profile data and related operations.
|
|
30
|
+
*/
|
|
31
|
+
declare const UserContext: Context<UserContextProps | null>;
|
|
32
|
+
export default UserContext;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025, 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
|
+
import { FC, PropsWithChildren } from 'react';
|
|
19
|
+
import { UserProfile } from '@asgardeo/browser';
|
|
20
|
+
/**
|
|
21
|
+
* Props interface of {@link UserProvider}
|
|
22
|
+
*/
|
|
23
|
+
export interface UserProviderProps {
|
|
24
|
+
profile: UserProfile;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* UserProvider component that manages user profile data and provides it through UserContext.
|
|
28
|
+
*
|
|
29
|
+
* This provider:
|
|
30
|
+
* - Fetches user profile data from the ME endpoint
|
|
31
|
+
* - Retrieves SCIM2 schemas for profile structure
|
|
32
|
+
* - Generates both nested and flattened user profiles
|
|
33
|
+
* - Provides functions for refreshing and updating user data
|
|
34
|
+
* - Handles loading states and errors
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```tsx
|
|
38
|
+
* // Basic usage
|
|
39
|
+
* <UserProvider>
|
|
40
|
+
* <App />
|
|
41
|
+
* </UserProvider>
|
|
42
|
+
*
|
|
43
|
+
* // With custom error handling
|
|
44
|
+
* <UserProvider onError={(error) => console.error('User error:', error)}>
|
|
45
|
+
* <App />
|
|
46
|
+
* </UserProvider>
|
|
47
|
+
*
|
|
48
|
+
* // Disable auto-fetch (fetch manually using refreshUser)
|
|
49
|
+
* <UserProvider autoFetch={false}>
|
|
50
|
+
* <App />
|
|
51
|
+
* </UserProvider>
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
declare const UserProvider: FC<PropsWithChildren<UserProviderProps>>;
|
|
55
|
+
export default UserProvider;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025, 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
|
+
import { UserContextProps } from './UserContext';
|
|
19
|
+
/**
|
|
20
|
+
* Hook to access the User context.
|
|
21
|
+
*
|
|
22
|
+
* This hook provides access to user profile data including:
|
|
23
|
+
* - Raw profile API response
|
|
24
|
+
* - SCIM2 schemas
|
|
25
|
+
* - Nested user object
|
|
26
|
+
* - Flattened user profile
|
|
27
|
+
* - Functions to refresh and update user data
|
|
28
|
+
* - Loading states and error handling
|
|
29
|
+
*
|
|
30
|
+
* @returns {UserContextProps} The user context value containing all user-related data and functions
|
|
31
|
+
* @throws {Error} Throws an error if used outside of UserProvider
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```tsx
|
|
35
|
+
* import {useUser} from '@asgardeo/react';
|
|
36
|
+
*
|
|
37
|
+
* function ProfileComponent() {
|
|
38
|
+
* const {
|
|
39
|
+
* isLoading,
|
|
40
|
+
* profile,
|
|
41
|
+
* schemas,
|
|
42
|
+
* user,
|
|
43
|
+
* flattenedUser,
|
|
44
|
+
* refreshUser,
|
|
45
|
+
* updateUser,
|
|
46
|
+
* error
|
|
47
|
+
* } = useUser();
|
|
48
|
+
*
|
|
49
|
+
* if (isLoading) {
|
|
50
|
+
* return <div>Loading user data...</div>;
|
|
51
|
+
* }
|
|
52
|
+
*
|
|
53
|
+
* if (error) {
|
|
54
|
+
* return <div>Error: {error.message}</div>;
|
|
55
|
+
* }
|
|
56
|
+
*
|
|
57
|
+
* return (
|
|
58
|
+
* <div>
|
|
59
|
+
* <h1>Welcome {user?.name?.givenName}!</h1>
|
|
60
|
+
* <p>Email: {flattenedUser?.emails}</p>
|
|
61
|
+
* <button onClick={refreshUser}>Refresh Profile</button>
|
|
62
|
+
* </div>
|
|
63
|
+
* );
|
|
64
|
+
* }
|
|
65
|
+
*
|
|
66
|
+
* // Access specific user properties
|
|
67
|
+
* function UserEmail() {
|
|
68
|
+
* const {flattenedUser} = useUser();
|
|
69
|
+
* return <span>{flattenedUser?.emails?.[0]}</span>;
|
|
70
|
+
* }
|
|
71
|
+
*
|
|
72
|
+
* // Update user profile
|
|
73
|
+
* function EditProfile() {
|
|
74
|
+
* const {updateUser, user} = useUser();
|
|
75
|
+
*
|
|
76
|
+
* const handleUpdate = async () => {
|
|
77
|
+
* try {
|
|
78
|
+
* await updateUser({
|
|
79
|
+
* name: {
|
|
80
|
+
* givenName: 'John',
|
|
81
|
+
* familyName: 'Doe'
|
|
82
|
+
* }
|
|
83
|
+
* });
|
|
84
|
+
* } catch (error) {
|
|
85
|
+
* console.error('Update failed:', error);
|
|
86
|
+
* }
|
|
87
|
+
* };
|
|
88
|
+
*
|
|
89
|
+
* return <button onClick={handleUpdate}>Update Name</button>;
|
|
90
|
+
* }
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
declare const useUser: () => UserContextProps;
|
|
94
|
+
export default useUser;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025, 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
|
+
* Interface for the useBrowserUrl hook return value.
|
|
20
|
+
*/
|
|
21
|
+
export interface UseBrowserUrl {
|
|
22
|
+
/**
|
|
23
|
+
* Checks if the current URL contains authentication parameters.
|
|
24
|
+
*
|
|
25
|
+
* @param url - The URL object to check for authentication parameters
|
|
26
|
+
* @param afterSignInUrl - The URL where the authorization server should redirect after authentication
|
|
27
|
+
* @returns True if the URL contains authentication parameters and matches the afterSignInUrl, or if it contains an error parameter
|
|
28
|
+
*/
|
|
29
|
+
hasAuthParams: (url: URL, afterSignInUrl: string) => boolean;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Hook that provides utilities for handling browser URLs in authentication flows.
|
|
33
|
+
*
|
|
34
|
+
* @returns An object containing URL utility functions
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```tsx
|
|
38
|
+
* const { hasAuthParams } = useBrowserUrl();
|
|
39
|
+
* const url = new URL(window.location.href);
|
|
40
|
+
*
|
|
41
|
+
* if (hasAuthParams(url, "/after-signin")) {
|
|
42
|
+
* // Handle authentication callback
|
|
43
|
+
* }
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
declare const useBrowserUrl: () => UseBrowserUrl;
|
|
47
|
+
export default useBrowserUrl;
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025, 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
|
+
* Generic form field configuration
|
|
20
|
+
*/
|
|
21
|
+
export interface FormField {
|
|
22
|
+
name: string;
|
|
23
|
+
required?: boolean;
|
|
24
|
+
initialValue?: string;
|
|
25
|
+
validator?: (value: string) => string | null;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Form validation result
|
|
29
|
+
*/
|
|
30
|
+
export interface ValidationResult {
|
|
31
|
+
isValid: boolean;
|
|
32
|
+
errors: Record<string, string>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Configuration for the useForm hook
|
|
36
|
+
*/
|
|
37
|
+
export interface UseFormConfig<T extends Record<string, string>> {
|
|
38
|
+
/**
|
|
39
|
+
* Initial form values
|
|
40
|
+
*/
|
|
41
|
+
initialValues?: Partial<T>;
|
|
42
|
+
/**
|
|
43
|
+
* Form field definitions
|
|
44
|
+
*/
|
|
45
|
+
fields?: FormField[];
|
|
46
|
+
/**
|
|
47
|
+
* Global form validator function
|
|
48
|
+
*/
|
|
49
|
+
validator?: (values: T) => Record<string, string>;
|
|
50
|
+
/**
|
|
51
|
+
* Whether to validate on change (default: false)
|
|
52
|
+
*/
|
|
53
|
+
validateOnChange?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Whether to validate on blur (default: true)
|
|
56
|
+
*/
|
|
57
|
+
validateOnBlur?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Custom required field validation message
|
|
60
|
+
*/
|
|
61
|
+
requiredMessage?: string;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Return type for the useForm hook
|
|
65
|
+
*/
|
|
66
|
+
export interface UseFormReturn<T extends Record<string, string>> {
|
|
67
|
+
/**
|
|
68
|
+
* Current form values
|
|
69
|
+
*/
|
|
70
|
+
values: T;
|
|
71
|
+
/**
|
|
72
|
+
* Fields that have been touched by the user
|
|
73
|
+
*/
|
|
74
|
+
touched: Record<keyof T, boolean>;
|
|
75
|
+
/**
|
|
76
|
+
* Current validation errors
|
|
77
|
+
*/
|
|
78
|
+
errors: Record<keyof T, string>;
|
|
79
|
+
/**
|
|
80
|
+
* Whether the form is currently valid
|
|
81
|
+
*/
|
|
82
|
+
isValid: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Whether the form has been submitted
|
|
85
|
+
*/
|
|
86
|
+
isSubmitted: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Set a single field value
|
|
89
|
+
*/
|
|
90
|
+
setValue: (name: keyof T, value: string) => void;
|
|
91
|
+
/**
|
|
92
|
+
* Set multiple field values
|
|
93
|
+
*/
|
|
94
|
+
setValues: (values: Partial<T>) => void;
|
|
95
|
+
/**
|
|
96
|
+
* Mark a field as touched
|
|
97
|
+
*/
|
|
98
|
+
setTouched: (name: keyof T, touched?: boolean) => void;
|
|
99
|
+
/**
|
|
100
|
+
* Mark multiple fields as touched
|
|
101
|
+
*/
|
|
102
|
+
setTouchedFields: (touched: Partial<Record<keyof T, boolean>>) => void;
|
|
103
|
+
/**
|
|
104
|
+
* Mark all fields as touched
|
|
105
|
+
*/
|
|
106
|
+
touchAllFields: () => void;
|
|
107
|
+
/**
|
|
108
|
+
* Set a field error
|
|
109
|
+
*/
|
|
110
|
+
setError: (name: keyof T, error: string) => void;
|
|
111
|
+
/**
|
|
112
|
+
* Set multiple field errors
|
|
113
|
+
*/
|
|
114
|
+
setErrors: (errors: Partial<Record<keyof T, string>>) => void;
|
|
115
|
+
/**
|
|
116
|
+
* Clear all errors
|
|
117
|
+
*/
|
|
118
|
+
clearErrors: () => void;
|
|
119
|
+
/**
|
|
120
|
+
* Validate a single field
|
|
121
|
+
*/
|
|
122
|
+
validateField: (name: keyof T) => string | null;
|
|
123
|
+
/**
|
|
124
|
+
* Validate all fields
|
|
125
|
+
*/
|
|
126
|
+
validateForm: () => ValidationResult;
|
|
127
|
+
/**
|
|
128
|
+
* Reset the form to initial values
|
|
129
|
+
*/
|
|
130
|
+
reset: () => void;
|
|
131
|
+
/**
|
|
132
|
+
* Handle form submission
|
|
133
|
+
*/
|
|
134
|
+
handleSubmit: (onSubmit: (values: T) => void | Promise<void>) => (e?: React.FormEvent) => Promise<void>;
|
|
135
|
+
/**
|
|
136
|
+
* Get field props for easy integration with form components
|
|
137
|
+
*/
|
|
138
|
+
getFieldProps: (name: keyof T) => {
|
|
139
|
+
name: keyof T;
|
|
140
|
+
value: string;
|
|
141
|
+
onChange: (value: string) => void;
|
|
142
|
+
onBlur: () => void;
|
|
143
|
+
error: string | undefined;
|
|
144
|
+
touched: boolean;
|
|
145
|
+
required: boolean;
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Generic form hook that provides comprehensive form state management and validation.
|
|
150
|
+
*
|
|
151
|
+
* @template T - The type of form values (must extend Record<string, string>)
|
|
152
|
+
* @param config - Configuration options for the form
|
|
153
|
+
* @returns Form state and methods
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* ```tsx
|
|
157
|
+
* interface LoginForm {
|
|
158
|
+
* username: string;
|
|
159
|
+
* password: string;
|
|
160
|
+
* }
|
|
161
|
+
*
|
|
162
|
+
* const {
|
|
163
|
+
* values,
|
|
164
|
+
* touched,
|
|
165
|
+
* errors,
|
|
166
|
+
* isValid,
|
|
167
|
+
* setValue,
|
|
168
|
+
* handleSubmit,
|
|
169
|
+
* getFieldProps
|
|
170
|
+
* } = useForm<LoginForm>({
|
|
171
|
+
* initialValues: { username: '', password: '' },
|
|
172
|
+
* fields: [
|
|
173
|
+
* { name: 'username', required: true },
|
|
174
|
+
* { name: 'password', required: true }
|
|
175
|
+
* ]
|
|
176
|
+
* });
|
|
177
|
+
*
|
|
178
|
+
* const onSubmit = handleSubmit((values) => {
|
|
179
|
+
* console.log('Form submitted:', values);
|
|
180
|
+
* });
|
|
181
|
+
*
|
|
182
|
+
* return (
|
|
183
|
+
* <form onSubmit={onSubmit}>
|
|
184
|
+
* <input {...getFieldProps('username')} />
|
|
185
|
+
* <input {...getFieldProps('password')} type="password" />
|
|
186
|
+
* <button type="submit" disabled={!isValid}>Submit</button>
|
|
187
|
+
* </form>
|
|
188
|
+
* );
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
191
|
+
export declare const useForm: <T extends Record<string, string>>(config?: UseFormConfig<T>) => UseFormReturn<T>;
|
|
192
|
+
export default useForm;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025, 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
|
+
import { I18nPreferences } from '@asgardeo/browser';
|
|
19
|
+
export interface UseTranslation {
|
|
20
|
+
/**
|
|
21
|
+
* Translation function that returns a translated string for the given key
|
|
22
|
+
*/
|
|
23
|
+
t: (key: string, params?: Record<string, string | number>) => string;
|
|
24
|
+
/**
|
|
25
|
+
* The current language code
|
|
26
|
+
*/
|
|
27
|
+
currentLanguage: string;
|
|
28
|
+
/**
|
|
29
|
+
* Function to change the current language
|
|
30
|
+
*/
|
|
31
|
+
setLanguage: (language: string) => void;
|
|
32
|
+
/**
|
|
33
|
+
* All available language codes
|
|
34
|
+
*/
|
|
35
|
+
availableLanguages: string[];
|
|
36
|
+
}
|
|
37
|
+
export interface UseTranslationWithPreferences extends UseTranslation {
|
|
38
|
+
/**
|
|
39
|
+
* Enhanced translation function that merges component-level preferences
|
|
40
|
+
*/
|
|
41
|
+
t: (key: string, params?: Record<string, string | number>) => string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Hook for accessing translation functions and language management.
|
|
45
|
+
* Must be used within an I18nProvider context.
|
|
46
|
+
*
|
|
47
|
+
* @param componentPreferences - Optional component-level i18n preferences to merge with global ones
|
|
48
|
+
* @returns An object containing translation function and language management utilities
|
|
49
|
+
* @throws Error if used outside of I18nProvider context
|
|
50
|
+
*/
|
|
51
|
+
declare const useTranslation: (componentPreferences?: I18nPreferences) => UseTranslationWithPreferences;
|
|
52
|
+
export default useTranslation;
|