@asgardeo/react 0.5.28 → 0.5.30

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.
Files changed (50) hide show
  1. package/dist/AsgardeoReactClient.d.ts +1 -0
  2. package/dist/__temp__/api.d.ts +8 -0
  3. package/dist/cjs/index.js +1881 -1136
  4. package/dist/cjs/index.js.map +4 -4
  5. package/dist/components/{presentation/SignUp/options → adapters}/CheckboxInput.d.ts +1 -1
  6. package/dist/components/{presentation/SignUp/options → adapters}/DateInput.d.ts +1 -1
  7. package/dist/components/{presentation/SignUp/options → adapters}/DividerComponent.d.ts +1 -1
  8. package/dist/components/{presentation/SignUp/options → adapters}/EmailInput.d.ts +1 -1
  9. package/dist/components/{presentation/options → adapters}/FacebookButton.d.ts +8 -2
  10. package/dist/components/{presentation/SignUp/options → adapters}/FormContainer.d.ts +1 -1
  11. package/dist/components/{presentation/options → adapters}/GitHubButton.d.ts +8 -2
  12. package/dist/components/{presentation/options → adapters}/GoogleButton.d.ts +8 -2
  13. package/dist/components/{presentation/SignUp/options → adapters}/ImageComponent.d.ts +1 -1
  14. package/dist/components/{presentation/options → adapters}/LinkedInButton.d.ts +8 -2
  15. package/dist/components/{presentation/options → adapters}/MicrosoftButton.d.ts +8 -2
  16. package/dist/components/{presentation/SignUp/options → adapters}/NumberInput.d.ts +1 -1
  17. package/dist/components/{presentation/SignUp/options → adapters}/PasswordInput.d.ts +1 -1
  18. package/dist/components/{presentation/options → adapters}/SignInWithEthereumButton.d.ts +8 -2
  19. package/dist/components/adapters/SmsOtpButton.d.ts +31 -0
  20. package/dist/components/{presentation/SignUp/options → adapters}/SocialButton.d.ts +1 -1
  21. package/dist/components/{presentation/SignUp/options → adapters}/SubmitButton.d.ts +1 -1
  22. package/dist/components/{presentation/SignUp/options → adapters}/TelephoneInput.d.ts +1 -1
  23. package/dist/components/{presentation/SignUp/options → adapters}/TextInput.d.ts +1 -1
  24. package/dist/components/{presentation/SignUp/options → adapters}/Typography.d.ts +1 -1
  25. package/dist/components/presentation/SignIn/SignIn.d.ts +9 -3
  26. package/dist/components/presentation/SignIn/component-driven/BaseSignIn.d.ts +195 -0
  27. package/dist/components/presentation/SignIn/component-driven/SignIn.d.ts +144 -0
  28. package/dist/components/presentation/SignIn/component-driven/SignInOptionFactory.d.ts +30 -0
  29. package/dist/components/presentation/SignIn/component-driven/transformer.d.ts +30 -0
  30. package/dist/components/presentation/SignIn/{BaseSignIn.d.ts → non-component-driven/BaseSignIn.d.ts} +1 -1
  31. package/dist/components/presentation/SignIn/non-component-driven/BaseSignIn.styles.d.ts +52 -0
  32. package/dist/components/presentation/{options → SignIn/non-component-driven/options}/SocialButton.d.ts +1 -1
  33. package/dist/contexts/Asgardeo/AsgardeoContext.d.ts +1 -1
  34. package/dist/index.d.ts +22 -22
  35. package/dist/index.js +1832 -1075
  36. package/dist/index.js.map +4 -4
  37. package/dist/utils/getDisplayName.d.ts +49 -0
  38. package/package.json +3 -3
  39. /package/dist/components/control/{Loading/Loading.d.ts → Loading.d.ts} +0 -0
  40. /package/dist/components/control/{SignedIn/SignedIn.d.ts → SignedIn.d.ts} +0 -0
  41. /package/dist/components/control/{SignedOut/SignedOut.d.ts → SignedOut.d.ts} +0 -0
  42. /package/dist/components/presentation/SignIn/{options → non-component-driven/options}/EmailOtp.d.ts +0 -0
  43. /package/dist/components/presentation/SignIn/{options → non-component-driven/options}/IdentifierFirst.d.ts +0 -0
  44. /package/dist/components/presentation/SignIn/{options → non-component-driven/options}/MultiOptionButton.d.ts +0 -0
  45. /package/dist/components/presentation/SignIn/{options → non-component-driven/options}/SignInOptionFactory.d.ts +0 -0
  46. /package/dist/components/presentation/SignIn/{options → non-component-driven/options}/SmsOtp.d.ts +0 -0
  47. /package/dist/components/presentation/SignIn/{options → non-component-driven/options}/Totp.d.ts +0 -0
  48. /package/dist/components/presentation/SignIn/{options → non-component-driven/options}/UsernamePassword.d.ts +0 -0
  49. /package/dist/components/presentation/SignIn/{types.d.ts → non-component-driven/types.d.ts} +0 -0
  50. /package/dist/components/presentation/SignUp/{options/SignUpOptionFactory.d.ts → SignUpOptionFactory.d.ts} +0 -0
@@ -16,7 +16,7 @@
16
16
  * under the License.
17
17
  */
18
18
  import { FC } from 'react';
19
- import { BaseSignUpOptionProps } from './SignUpOptionFactory';
19
+ import { BaseSignUpOptionProps } from '../presentation/SignUp/SignUpOptionFactory';
20
20
  /**
21
21
  * Checkbox input component for sign-up forms.
22
22
  */
@@ -16,7 +16,7 @@
16
16
  * under the License.
17
17
  */
18
18
  import { FC } from 'react';
19
- import { BaseSignUpOptionProps } from './SignUpOptionFactory';
19
+ import { BaseSignUpOptionProps } from '../presentation/SignUp/SignUpOptionFactory';
20
20
  /**
21
21
  * Date input component for sign-up forms.
22
22
  */
@@ -16,7 +16,7 @@
16
16
  * under the License.
17
17
  */
18
18
  import { FC } from 'react';
19
- import { BaseSignUpOptionProps } from './SignUpOptionFactory';
19
+ import { BaseSignUpOptionProps } from '../presentation/SignUp/SignUpOptionFactory';
20
20
  /**
21
21
  * Divider component for sign-up forms.
22
22
  */
@@ -16,7 +16,7 @@
16
16
  * under the License.
17
17
  */
18
18
  import { FC } from 'react';
19
- import { BaseSignUpOptionProps } from './SignUpOptionFactory';
19
+ import { BaseSignUpOptionProps } from '../presentation/SignUp/SignUpOptionFactory';
20
20
  /**
21
21
  * Email input component for sign-up forms.
22
22
  */
@@ -16,10 +16,16 @@
16
16
  * under the License.
17
17
  */
18
18
  import { FC, HTMLAttributes } from 'react';
19
- import { BaseSignInOptionProps } from '../SignIn/options/SignInOptionFactory';
19
+ import { WithPreferences } from '@asgardeo/browser';
20
+ export interface FacebookButtonProps extends WithPreferences {
21
+ /**
22
+ * Whether the component is in loading state.
23
+ */
24
+ isLoading?: boolean;
25
+ }
20
26
  /**
21
27
  * Facebook Sign-In Button Component.
22
28
  * Handles authentication with Facebook identity provider.
23
29
  */
24
- declare const FacebookButton: FC<BaseSignInOptionProps & HTMLAttributes<HTMLButtonElement>>;
30
+ declare const FacebookButton: FC<FacebookButtonProps & HTMLAttributes<HTMLButtonElement>>;
25
31
  export default FacebookButton;
@@ -16,7 +16,7 @@
16
16
  * under the License.
17
17
  */
18
18
  import { FC } from 'react';
19
- import { BaseSignUpOptionProps } from './SignUpOptionFactory';
19
+ import { BaseSignUpOptionProps } from '../presentation/SignUp/SignUpOptionFactory';
20
20
  /**
21
21
  * Form container component that renders child components.
22
22
  */
@@ -16,10 +16,16 @@
16
16
  * under the License.
17
17
  */
18
18
  import { FC, HTMLAttributes } from 'react';
19
- import { BaseSignInOptionProps } from '../SignIn/options/SignInOptionFactory';
19
+ import { WithPreferences } from '@asgardeo/browser';
20
+ export interface GithubButtonProps extends WithPreferences {
21
+ /**
22
+ * Whether the component is in loading state.
23
+ */
24
+ isLoading?: boolean;
25
+ }
20
26
  /**
21
27
  * GitHub Sign-In Button Component.
22
28
  * Handles authentication with GitHub identity provider.
23
29
  */
24
- declare const GitHubButton: FC<BaseSignInOptionProps & HTMLAttributes<HTMLButtonElement>>;
30
+ declare const GitHubButton: FC<GithubButtonProps & HTMLAttributes<HTMLButtonElement>>;
25
31
  export default GitHubButton;
@@ -16,10 +16,16 @@
16
16
  * under the License.
17
17
  */
18
18
  import { FC, HTMLAttributes } from 'react';
19
- import { BaseSignInOptionProps } from '../SignIn/options/SignInOptionFactory';
19
+ import { WithPreferences } from '@asgardeo/browser';
20
+ export interface GoogleButtonProps extends WithPreferences {
21
+ /**
22
+ * Whether the component is in loading state.
23
+ */
24
+ isLoading?: boolean;
25
+ }
20
26
  /**
21
27
  * Google Sign-In Button Component.
22
28
  * Handles authentication with Google identity provider.
23
29
  */
24
- declare const GoogleButton: FC<BaseSignInOptionProps & HTMLAttributes<HTMLButtonElement>>;
30
+ declare const GoogleButton: FC<GoogleButtonProps & HTMLAttributes<HTMLButtonElement>>;
25
31
  export default GoogleButton;
@@ -16,7 +16,7 @@
16
16
  * under the License.
17
17
  */
18
18
  import { FC } from 'react';
19
- import { BaseSignUpOptionProps } from './SignUpOptionFactory';
19
+ import { BaseSignUpOptionProps } from '../presentation/SignUp/SignUpOptionFactory';
20
20
  /**
21
21
  * Image component for sign-up forms.
22
22
  */
@@ -16,10 +16,16 @@
16
16
  * under the License.
17
17
  */
18
18
  import { FC, HTMLAttributes } from 'react';
19
- import { BaseSignInOptionProps } from '../SignIn/options/SignInOptionFactory';
19
+ import { WithPreferences } from '@asgardeo/browser';
20
+ export interface LinkedInButtonProps extends WithPreferences {
21
+ /**
22
+ * Whether the component is in loading state.
23
+ */
24
+ isLoading?: boolean;
25
+ }
20
26
  /**
21
27
  * LinkedIn Sign-In Button Component.
22
28
  * Handles authentication with LinkedIn identity provider.
23
29
  */
24
- declare const LinkedInButton: FC<BaseSignInOptionProps & HTMLAttributes<HTMLButtonElement>>;
30
+ declare const LinkedInButton: FC<LinkedInButtonProps & HTMLAttributes<HTMLButtonElement>>;
25
31
  export default LinkedInButton;
@@ -16,10 +16,16 @@
16
16
  * under the License.
17
17
  */
18
18
  import { FC, HTMLAttributes } from 'react';
19
- import { BaseSignInOptionProps } from '../SignIn/options/SignInOptionFactory';
19
+ import { WithPreferences } from '@asgardeo/browser';
20
+ export interface MicrosoftButtonProps extends WithPreferences {
21
+ /**
22
+ * Whether the component is in loading state.
23
+ */
24
+ isLoading?: boolean;
25
+ }
20
26
  /**
21
27
  * Microsoft Sign-In Button Component.
22
28
  * Handles authentication with Microsoft identity provider.
23
29
  */
24
- declare const MicrosoftButton: FC<BaseSignInOptionProps & HTMLAttributes<HTMLButtonElement>>;
30
+ declare const MicrosoftButton: FC<MicrosoftButtonProps & HTMLAttributes<HTMLButtonElement>>;
25
31
  export default MicrosoftButton;
@@ -16,7 +16,7 @@
16
16
  * under the License.
17
17
  */
18
18
  import { FC } from 'react';
19
- import { BaseSignUpOptionProps } from './SignUpOptionFactory';
19
+ import { BaseSignUpOptionProps } from '../presentation/SignUp/SignUpOptionFactory';
20
20
  /**
21
21
  * Number input component for sign-up forms.
22
22
  */
@@ -16,7 +16,7 @@
16
16
  * under the License.
17
17
  */
18
18
  import { FC } from 'react';
19
- import { BaseSignUpOptionProps } from './SignUpOptionFactory';
19
+ import { BaseSignUpOptionProps } from '../presentation/SignUp/SignUpOptionFactory';
20
20
  /**
21
21
  * Password input component for sign-up forms.
22
22
  */
@@ -16,10 +16,16 @@
16
16
  * under the License.
17
17
  */
18
18
  import { FC, HTMLAttributes } from 'react';
19
- import { BaseSignInOptionProps } from '../SignIn/options/SignInOptionFactory';
19
+ import { WithPreferences } from '@asgardeo/browser';
20
+ export interface SignInWithEthereumButtonProps extends WithPreferences {
21
+ /**
22
+ * Whether the component is in loading state.
23
+ */
24
+ isLoading?: boolean;
25
+ }
20
26
  /**
21
27
  * Sign In With Ethereum Button Component.
22
28
  * Handles authentication with Sign In With Ethereum identity provider.
23
29
  */
24
- declare const SignInWithEthereumButton: FC<BaseSignInOptionProps & HTMLAttributes<HTMLButtonElement>>;
30
+ declare const SignInWithEthereumButton: FC<SignInWithEthereumButtonProps & HTMLAttributes<HTMLButtonElement>>;
25
31
  export default SignInWithEthereumButton;
@@ -0,0 +1,31 @@
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, HTMLAttributes } from 'react';
19
+ import { WithPreferences } from '@asgardeo/browser';
20
+ export interface SmsOtpButtonProps extends WithPreferences {
21
+ /**
22
+ * Whether the component is in loading state.
23
+ */
24
+ isLoading?: boolean;
25
+ }
26
+ /**
27
+ * SMS OTP Sign-In Button Component.
28
+ * Handles authentication with SMS OTP.
29
+ */
30
+ declare const SmsOtpButton: FC<SmsOtpButtonProps & HTMLAttributes<HTMLButtonElement>>;
31
+ export default SmsOtpButton;
@@ -16,7 +16,7 @@
16
16
  * under the License.
17
17
  */
18
18
  import { FC } from 'react';
19
- import { BaseSignUpOptionProps } from './SignUpOptionFactory';
19
+ import { BaseSignUpOptionProps } from '../presentation/SignUp/SignUpOptionFactory';
20
20
  /**
21
21
  * Social button component for sign-up forms.
22
22
  */
@@ -16,7 +16,7 @@
16
16
  * under the License.
17
17
  */
18
18
  import { FC } from 'react';
19
- import { BaseSignUpOptionProps } from './SignUpOptionFactory';
19
+ import { BaseSignUpOptionProps } from '../presentation/SignUp/SignUpOptionFactory';
20
20
  /**
21
21
  * Button component for sign-up forms that handles all button variants.
22
22
  */
@@ -16,7 +16,7 @@
16
16
  * under the License.
17
17
  */
18
18
  import { FC } from 'react';
19
- import { BaseSignUpOptionProps } from './SignUpOptionFactory';
19
+ import { BaseSignUpOptionProps } from '../presentation/SignUp/SignUpOptionFactory';
20
20
  /**
21
21
  * Telephone input component for sign-up forms.
22
22
  */
@@ -16,7 +16,7 @@
16
16
  * under the License.
17
17
  */
18
18
  import { FC } from 'react';
19
- import { BaseSignUpOptionProps } from './SignUpOptionFactory';
19
+ import { BaseSignUpOptionProps } from '../presentation/SignUp/SignUpOptionFactory';
20
20
  /**
21
21
  * Text input component for sign-up forms.
22
22
  */
@@ -16,7 +16,7 @@
16
16
  * under the License.
17
17
  */
18
18
  import { FC } from 'react';
19
- import { BaseSignUpOptionProps } from './SignUpOptionFactory';
19
+ import { BaseSignUpOptionProps } from '../presentation/SignUp/SignUpOptionFactory';
20
20
  /**
21
21
  * Typography component for sign-up forms (titles, descriptions, etc.).
22
22
  */
@@ -15,13 +15,19 @@
15
15
  * specific language governing permissions and limitations
16
16
  * under the License.
17
17
  */
18
- import { FC } from 'react';
19
- import { BaseSignInProps } from './BaseSignIn';
18
+ import { FC, ReactElement } from 'react';
19
+ import { BaseSignInProps } from './non-component-driven/BaseSignIn';
20
+ import { SignInRenderProps } from './component-driven/SignIn';
20
21
  /**
21
22
  * Props for the SignIn component.
22
23
  * Extends BaseSignInProps for full compatibility with the React BaseSignIn component
23
24
  */
24
- export type SignInProps = Pick<BaseSignInProps, 'className' | 'onSuccess' | 'onError' | 'variant' | 'size'>;
25
+ export type SignInProps = Pick<BaseSignInProps, 'className' | 'onSuccess' | 'onError' | 'variant' | 'size'> & {
26
+ /**
27
+ * Render function for custom UI (render props pattern).
28
+ */
29
+ children?: (props: SignInRenderProps) => ReactElement;
30
+ };
25
31
  /**
26
32
  * A styled SignIn component that provides native authentication flow with pre-built styling.
27
33
  * This component handles the API calls for authentication and delegates UI logic to BaseSignIn.
@@ -0,0 +1,195 @@
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, ReactNode } from 'react';
19
+ import { EmbeddedFlowComponent, EmbeddedSignInFlowRequestV2 } from '@asgardeo/browser';
20
+ import { CardProps } from '../../../primitives/Card/Card';
21
+ /**
22
+ * Render props for custom UI rendering
23
+ */
24
+ export interface BaseSignInRenderProps {
25
+ /**
26
+ * Form values
27
+ */
28
+ values: Record<string, string>;
29
+ /**
30
+ * Form errors
31
+ */
32
+ errors: Record<string, string>;
33
+ /**
34
+ * Touched fields
35
+ */
36
+ touched: Record<string, boolean>;
37
+ /**
38
+ * Whether the form is valid
39
+ */
40
+ isValid: boolean;
41
+ /**
42
+ * Loading state
43
+ */
44
+ isLoading: boolean;
45
+ /**
46
+ * Current error message
47
+ */
48
+ error: string | null;
49
+ /**
50
+ * Flow components
51
+ */
52
+ components: EmbeddedFlowComponent[];
53
+ /**
54
+ * Function to handle input changes
55
+ */
56
+ handleInputChange: (name: string, value: string) => void;
57
+ /**
58
+ * Function to handle form submission
59
+ */
60
+ handleSubmit: (component: EmbeddedFlowComponent, data?: Record<string, any>) => Promise<void>;
61
+ /**
62
+ * Function to validate the form
63
+ */
64
+ validateForm: () => {
65
+ isValid: boolean;
66
+ errors: Record<string, string>;
67
+ };
68
+ /**
69
+ * Flow title
70
+ */
71
+ title: string;
72
+ /**
73
+ * Flow subtitle
74
+ */
75
+ subtitle: string;
76
+ /**
77
+ * Flow messages
78
+ */
79
+ messages: Array<{
80
+ message: string;
81
+ type: string;
82
+ }>;
83
+ }
84
+ /**
85
+ * Props for the BaseSignIn component.
86
+ */
87
+ export interface BaseSignInProps {
88
+ /**
89
+ * Custom CSS class name for the submit button.
90
+ */
91
+ buttonClassName?: string;
92
+ /**
93
+ * Custom CSS class name for the form container.
94
+ */
95
+ className?: string;
96
+ /**
97
+ * Array of flow components to render.
98
+ */
99
+ components?: EmbeddedFlowComponent[];
100
+ /**
101
+ * Custom CSS class name for error messages.
102
+ */
103
+ errorClassName?: string;
104
+ /**
105
+ * Flag to determine if the component is ready to be rendered.
106
+ */
107
+ isLoading?: boolean;
108
+ /**
109
+ * Custom CSS class name for form inputs.
110
+ */
111
+ inputClassName?: string;
112
+ /**
113
+ * Custom CSS class name for info messages.
114
+ */
115
+ messageClassName?: string;
116
+ /**
117
+ * Callback function called when authentication fails.
118
+ * @param error - The error that occurred during authentication.
119
+ */
120
+ onError?: (error: Error) => void;
121
+ /**
122
+ * Function to handle form submission.
123
+ * @param payload - The form data to submit.
124
+ * @param component - The component that triggered the submission.
125
+ */
126
+ onSubmit?: (payload: EmbeddedSignInFlowRequestV2, component: EmbeddedFlowComponent) => Promise<void>;
127
+ /**
128
+ * Callback function called when authentication is successful.
129
+ * @param authData - The authentication data returned upon successful completion.
130
+ */
131
+ onSuccess?: (authData: Record<string, any>) => void;
132
+ /**
133
+ * Size variant for the component.
134
+ */
135
+ size?: 'small' | 'medium' | 'large';
136
+ /**
137
+ * Theme variant for the component.
138
+ */
139
+ variant?: CardProps['variant'];
140
+ /**
141
+ * Render props function for custom UI
142
+ */
143
+ children?: (props: BaseSignInRenderProps) => ReactNode;
144
+ }
145
+ /**
146
+ * Base SignIn component that provides generic authentication flow.
147
+ * This component handles component-driven UI rendering and can transform input
148
+ * structure to component-driven format automatically.
149
+ *
150
+ * @example
151
+ * // Default UI
152
+ * ```tsx
153
+ * import { BaseSignIn } from '@asgardeo/react';
154
+ *
155
+ * const MySignIn = () => {
156
+ * return (
157
+ * <BaseSignIn
158
+ * components={components}
159
+ * onSubmit={async (payload) => {
160
+ * return await handleAuth(payload);
161
+ * }}
162
+ * onSuccess={(authData) => {
163
+ * console.log('Success:', authData);
164
+ * }}
165
+ * className="max-w-md mx-auto"
166
+ * />
167
+ * );
168
+ * };
169
+ * ```
170
+ *
171
+ * @example
172
+ * // Custom UI with render props
173
+ * ```tsx
174
+ * <BaseSignIn components={components} onSubmit={handleSubmit}>
175
+ * {({values, errors, handleInputChange, handleSubmit, isLoading, components}) => (
176
+ * <div className="custom-form">
177
+ * <input
178
+ * name="username"
179
+ * value={values.username || ''}
180
+ * onChange={(e) => handleInputChange('username', e.target.value)}
181
+ * />
182
+ * {errors.username && <span>{errors.username}</span>}
183
+ * <button
184
+ * onClick={() => handleSubmit(components[0], values)}
185
+ * disabled={isLoading}
186
+ * >
187
+ * Sign In
188
+ * </button>
189
+ * </div>
190
+ * )}
191
+ * </BaseSignIn>
192
+ * ```
193
+ */
194
+ declare const BaseSignIn: FC<BaseSignInProps>;
195
+ export default BaseSignIn;
@@ -0,0 +1,144 @@
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, ReactNode } from 'react';
19
+ import { BaseSignInProps } from './BaseSignIn';
20
+ import { EmbeddedFlowComponent, EmbeddedSignInFlowRequestV2 } from '@asgardeo/browser';
21
+ /**
22
+ * Render props function parameters
23
+ */
24
+ export interface SignInRenderProps {
25
+ /**
26
+ * Function to manually initialize the flow
27
+ */
28
+ initialize: () => Promise<void>;
29
+ /**
30
+ * Function to submit authentication data (primary)
31
+ */
32
+ onSubmit: (payload: EmbeddedSignInFlowRequestV2) => Promise<void>;
33
+ /**
34
+ * Loading state indicator
35
+ */
36
+ isLoading: boolean;
37
+ /**
38
+ * Whether the flow has been initialized
39
+ */
40
+ isInitialized: boolean;
41
+ /**
42
+ * Current flow components
43
+ */
44
+ components: EmbeddedFlowComponent[];
45
+ /**
46
+ * Current error if any
47
+ */
48
+ error: Error | null;
49
+ }
50
+ /**
51
+ * Props for the SignIn component.
52
+ * Matches the interface from the main SignIn component for consistency.
53
+ */
54
+ export type SignInProps = {
55
+ /**
56
+ * Custom CSS class name for the form container.
57
+ */
58
+ className?: string;
59
+ /**
60
+ * Callback function called when authentication is successful.
61
+ * @param authData - The authentication data returned upon successful completion.
62
+ */
63
+ onSuccess?: (authData: Record<string, any>) => void;
64
+ /**
65
+ * Callback function called when authentication fails.
66
+ * @param error - The error that occurred during authentication.
67
+ */
68
+ onError?: (error: Error) => void;
69
+ /**
70
+ * Theme variant for the component.
71
+ */
72
+ variant?: BaseSignInProps['variant'];
73
+ /**
74
+ * Size variant for the component.
75
+ */
76
+ size?: 'small' | 'medium' | 'large';
77
+ /**
78
+ * Render props function for custom UI
79
+ */
80
+ children?: (props: SignInRenderProps) => ReactNode;
81
+ };
82
+ /**
83
+ * A component-driven SignIn component that provides authentication flow with pre-built styling.
84
+ * This component handles the flow API calls for authentication and delegates UI logic to BaseSignIn.
85
+ * It automatically transforms simple input-based responses into component-driven UI format.
86
+ *
87
+ * @example
88
+ * // Default UI
89
+ * ```tsx
90
+ * import { SignIn } from '@asgardeo/react/component-driven';
91
+ *
92
+ * const App = () => {
93
+ * return (
94
+ * <SignIn
95
+ * onSuccess={(authData) => {
96
+ * console.log('Authentication successful:', authData);
97
+ * }}
98
+ * onError={(error) => {
99
+ * console.error('Authentication failed:', error);
100
+ * }}
101
+ * size="medium"
102
+ * variant="outlined"
103
+ * />
104
+ * );
105
+ * };
106
+ * ```
107
+ *
108
+ * @example
109
+ * // Custom UI with render props
110
+ * ```tsx
111
+ * import { SignIn } from '@asgardeo/react/component-driven';
112
+ *
113
+ * const App = () => {
114
+ * return (
115
+ * <SignIn
116
+ * onSuccess={(authData) => console.log('Success:', authData)}
117
+ * onError={(error) => console.error('Error:', error)}
118
+ * >
119
+ * {({signIn, isLoading, components, error, isInitialized}) => (
120
+ * <div className="custom-signin">
121
+ * <h1>Custom Sign In</h1>
122
+ * {!isInitialized ? (
123
+ * <p>Initializing...</p>
124
+ * ) : error ? (
125
+ * <div className="error">{error.message}</div>
126
+ * ) : (
127
+ * <form onSubmit={(e) => {
128
+ * e.preventDefault();
129
+ * signIn({inputs: {username: 'user', password: 'pass'}});
130
+ * }}>
131
+ * <button type="submit" disabled={isLoading}>
132
+ * {isLoading ? 'Signing in...' : 'Sign In'}
133
+ * </button>
134
+ * </form>
135
+ * )}
136
+ * </div>
137
+ * )}
138
+ * </SignIn>
139
+ * );
140
+ * };
141
+ * ```
142
+ */
143
+ declare const SignIn: FC<SignInProps>;
144
+ export default SignIn;