@asgardeo/react 0.6.17 → 0.6.18
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/dist/cjs/index.js +1760 -1316
- package/dist/cjs/index.js.map +4 -4
- package/dist/components/adapters/CheckboxInput.d.ts +2 -2
- package/dist/components/adapters/DateInput.d.ts +2 -2
- package/dist/components/adapters/DividerComponent.d.ts +2 -2
- package/dist/components/adapters/EmailInput.d.ts +2 -2
- package/dist/components/adapters/FormContainer.d.ts +2 -2
- package/dist/components/adapters/ImageComponent.d.ts +2 -2
- package/dist/components/adapters/NumberInput.d.ts +2 -2
- package/dist/components/adapters/PasswordInput.d.ts +2 -2
- package/dist/components/adapters/SelectInput.d.ts +2 -2
- package/dist/components/adapters/SocialButton.d.ts +2 -2
- package/dist/components/adapters/SubmitButton.d.ts +2 -2
- package/dist/components/adapters/TelephoneInput.d.ts +2 -2
- package/dist/components/adapters/TextInput.d.ts +2 -2
- package/dist/components/adapters/Typography.d.ts +2 -2
- package/dist/components/presentation/{SignIn/component-driven/SignInOptionFactory.d.ts → auth/AuthOptionFactory.d.ts} +14 -2
- package/dist/components/presentation/{SignIn → auth/SignIn}/BaseSignIn.d.ts +2 -2
- package/dist/components/presentation/{SignIn → auth/SignIn}/SignIn.d.ts +3 -3
- package/dist/components/presentation/{SignIn/non-component-driven → auth/SignIn/v1}/BaseSignIn.d.ts +1 -1
- package/dist/components/presentation/{SignIn/component-driven → auth/SignIn/v2}/BaseSignIn.d.ts +3 -3
- package/dist/components/presentation/{SignIn/component-driven → auth/SignIn/v2}/SignIn.d.ts +1 -1
- package/dist/components/presentation/auth/SignUp/BaseSignUp.d.ts +27 -0
- package/dist/components/presentation/{SignUp → auth/SignUp}/SignUp.d.ts +6 -13
- package/dist/components/presentation/{SignUp → auth/SignUp/v1}/BaseSignUp.d.ts +3 -53
- package/dist/components/presentation/auth/SignUp/v1/SignUp.d.ts +38 -0
- package/dist/components/presentation/{SignUp → auth/SignUp/v1}/SignUpOptionFactory.d.ts +3 -52
- package/dist/components/presentation/auth/SignUp/v2/BaseSignUp.d.ts +171 -0
- package/dist/components/presentation/auth/SignUp/v2/SignUp.d.ts +38 -0
- package/dist/index.d.ts +16 -16
- package/dist/index.js +1463 -1011
- package/dist/index.js.map +4 -4
- package/dist/models/adapters.d.ts +68 -0
- package/dist/utils/v2/flowTransformer.d.ts +111 -0
- package/dist/utils/v2/getAuthComponentHeadings.d.ts +69 -0
- package/dist/utils/v2/resolveTranslation.d.ts +27 -0
- package/dist/utils/v2/resolveTranslationsInArray.d.ts +27 -0
- package/dist/{components/presentation/SignIn/component-driven/transformer.d.ts → utils/v2/resolveTranslationsInObject.d.ts} +8 -11
- package/package.json +3 -3
- package/dist/components/presentation/SignUp/transformer.d.ts +0 -104
- /package/dist/components/presentation/{SignIn → auth/SignIn}/BaseSignIn.styles.d.ts +0 -0
- /package/dist/components/presentation/{SignIn/non-component-driven → auth/SignIn/v1}/options/EmailOtp.d.ts +0 -0
- /package/dist/components/presentation/{SignIn/non-component-driven → auth/SignIn/v1}/options/IdentifierFirst.d.ts +0 -0
- /package/dist/components/presentation/{SignIn/non-component-driven → auth/SignIn/v1}/options/MultiOptionButton.d.ts +0 -0
- /package/dist/components/presentation/{SignIn/non-component-driven → auth/SignIn/v1}/options/SignInOptionFactory.d.ts +0 -0
- /package/dist/components/presentation/{SignIn/non-component-driven → auth/SignIn/v1}/options/SmsOtp.d.ts +0 -0
- /package/dist/components/presentation/{SignIn/non-component-driven → auth/SignIn/v1}/options/SocialButton.d.ts +0 -0
- /package/dist/components/presentation/{SignIn/non-component-driven → auth/SignIn/v1}/options/Totp.d.ts +0 -0
- /package/dist/components/presentation/{SignIn/non-component-driven → auth/SignIn/v1}/options/UsernamePassword.d.ts +0 -0
- /package/dist/components/presentation/{SignIn/non-component-driven → auth/SignIn/v1}/types.d.ts +0 -0
- /package/dist/components/presentation/{SignUp → auth/SignUp}/BaseSignUp.styles.d.ts +0 -0
|
@@ -0,0 +1,68 @@
|
|
|
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 { EmbeddedFlowComponent, WithPreferences } from '@asgardeo/browser';
|
|
19
|
+
/**
|
|
20
|
+
* Props shared by all adapter components.
|
|
21
|
+
*/
|
|
22
|
+
export interface AdapterProps extends WithPreferences {
|
|
23
|
+
/**
|
|
24
|
+
* Custom CSS class name for buttons.
|
|
25
|
+
*/
|
|
26
|
+
buttonClassName?: string;
|
|
27
|
+
/**
|
|
28
|
+
* The component configuration from the flow response.
|
|
29
|
+
*/
|
|
30
|
+
component: EmbeddedFlowComponent;
|
|
31
|
+
/**
|
|
32
|
+
* Form validation errors.
|
|
33
|
+
*/
|
|
34
|
+
formErrors: Record<string, string>;
|
|
35
|
+
/**
|
|
36
|
+
* Current form values.
|
|
37
|
+
*/
|
|
38
|
+
formValues: Record<string, string>;
|
|
39
|
+
/**
|
|
40
|
+
* Custom CSS class name for form inputs.
|
|
41
|
+
*/
|
|
42
|
+
inputClassName?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Whether the form is valid.
|
|
45
|
+
*/
|
|
46
|
+
isFormValid: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Whether the component is in loading state.
|
|
49
|
+
*/
|
|
50
|
+
isLoading: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Callback function called when input values change.
|
|
53
|
+
*/
|
|
54
|
+
onInputChange: (name: string, value: string) => void;
|
|
55
|
+
onSubmit?: (component: EmbeddedFlowComponent, data?: Record<string, any>) => void;
|
|
56
|
+
/**
|
|
57
|
+
* Component size variant.
|
|
58
|
+
*/
|
|
59
|
+
size?: 'small' | 'medium' | 'large';
|
|
60
|
+
/**
|
|
61
|
+
* Touched state for form fields.
|
|
62
|
+
*/
|
|
63
|
+
touchedFields: Record<string, boolean>;
|
|
64
|
+
/**
|
|
65
|
+
* Component theme variant.
|
|
66
|
+
*/
|
|
67
|
+
variant?: any;
|
|
68
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
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
|
+
* @fileoverview Shared flow response transformer utilities for v2 embedded flows.
|
|
20
|
+
*
|
|
21
|
+
* This module provides reusable transformation functions for normalizing embedded flow
|
|
22
|
+
* responses from Asgardeo APIs. It handles both successful responses with component
|
|
23
|
+
* extraction and error responses with proper error message extraction.
|
|
24
|
+
*
|
|
25
|
+
* Key features:
|
|
26
|
+
* - Component extraction from flow meta structure
|
|
27
|
+
* - Translation string resolution in components
|
|
28
|
+
* - Error response detection and message extraction
|
|
29
|
+
* - Configurable error handling (throw vs return errors)
|
|
30
|
+
*
|
|
31
|
+
* Usage:
|
|
32
|
+
* ```typescript
|
|
33
|
+
* import { normalizeFlowResponse } from '../../../utils/v2/flowTransformer';
|
|
34
|
+
*
|
|
35
|
+
* const { flowId, components } = normalizeFlowResponse(apiResponse, t, {
|
|
36
|
+
* defaultErrorKey: 'components.signIn.errors.generic'
|
|
37
|
+
* });
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* This transformer is used by both SignIn and SignUp v2 components to ensure
|
|
41
|
+
* consistent response handling across all embedded flows.
|
|
42
|
+
*/
|
|
43
|
+
import { EmbeddedFlowComponentV2 as EmbeddedFlowComponent } from '@asgardeo/browser';
|
|
44
|
+
import { UseTranslation } from '../../hooks/useTranslation';
|
|
45
|
+
/**
|
|
46
|
+
* Generic flow error response interface that covers common error structure
|
|
47
|
+
*/
|
|
48
|
+
export interface FlowErrorResponse {
|
|
49
|
+
flowId: string;
|
|
50
|
+
flowStatus: 'ERROR';
|
|
51
|
+
failureReason?: string;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Configuration options for flow transformation
|
|
55
|
+
*/
|
|
56
|
+
export interface FlowTransformOptions {
|
|
57
|
+
/**
|
|
58
|
+
* Whether to throw errors or return them as normalized response
|
|
59
|
+
* @default true
|
|
60
|
+
*/
|
|
61
|
+
throwOnError?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Default error message key for translation fallback
|
|
64
|
+
* @default 'errors.flow.generic'
|
|
65
|
+
*/
|
|
66
|
+
defaultErrorKey?: string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Transform and resolve translations in components from flow response.
|
|
70
|
+
* This function extracts components from the response meta structure and resolves
|
|
71
|
+
* any translation strings within them.
|
|
72
|
+
*
|
|
73
|
+
* @param response - The flow response object containing components in meta structure
|
|
74
|
+
* @param t - Translation function from useTranslation hook
|
|
75
|
+
* @returns Array of flow components with resolved translations
|
|
76
|
+
*/
|
|
77
|
+
export declare const transformComponents: (response: any, t: UseTranslation["t"]) => EmbeddedFlowComponent[];
|
|
78
|
+
/**
|
|
79
|
+
* Extract error message from flow error response.
|
|
80
|
+
* Supports any flow error response that follows the standard structure.
|
|
81
|
+
*
|
|
82
|
+
* @param error - The error response object
|
|
83
|
+
* @param t - Translation function for fallback messages
|
|
84
|
+
* @param defaultErrorKey - Default translation key for generic errors
|
|
85
|
+
* @returns Extracted error message or fallback
|
|
86
|
+
*/
|
|
87
|
+
export declare const extractErrorMessage: (error: FlowErrorResponse | any, t: UseTranslation["t"], defaultErrorKey?: string) => string;
|
|
88
|
+
/**
|
|
89
|
+
* Check if a response is an error response and extract the error message.
|
|
90
|
+
* This function identifies error responses by checking for ERROR status and failure reasons.
|
|
91
|
+
*
|
|
92
|
+
* @param response - The flow response to check
|
|
93
|
+
* @param t - Translation function for error messages
|
|
94
|
+
* @param defaultErrorKey - Default translation key for generic errors
|
|
95
|
+
* @returns Error message string if response is an error, null otherwise
|
|
96
|
+
*/
|
|
97
|
+
export declare const checkForErrorResponse: (response: any, t: UseTranslation["t"], defaultErrorKey?: string) => string | null;
|
|
98
|
+
/**
|
|
99
|
+
* Generic flow response normalizer that handles both success and error responses.
|
|
100
|
+
* This is the main transformer function that should be used by all flow components.
|
|
101
|
+
*
|
|
102
|
+
* @param response - The raw flow response from the API
|
|
103
|
+
* @param t - Translation function from useTranslation hook
|
|
104
|
+
* @param options - Configuration options for transformation behavior
|
|
105
|
+
* @returns Normalized flow response with flowId and transformed components
|
|
106
|
+
* @throws {any} The original response if it's an error and throwOnError is true
|
|
107
|
+
*/
|
|
108
|
+
export declare const normalizeFlowResponse: (response: any, t: UseTranslation["t"], options?: FlowTransformOptions) => {
|
|
109
|
+
flowId: string;
|
|
110
|
+
components: EmbeddedFlowComponent[];
|
|
111
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
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 { EmbeddedFlowComponentV2 as EmbeddedFlowComponent } from '@asgardeo/browser';
|
|
19
|
+
/**
|
|
20
|
+
* Result of heading extraction from flow components
|
|
21
|
+
*/
|
|
22
|
+
export interface HeadingExtractionResult {
|
|
23
|
+
heading: EmbeddedFlowComponent | null;
|
|
24
|
+
subheading: EmbeddedFlowComponent | null;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Complete result of authentication component heading extraction
|
|
28
|
+
*/
|
|
29
|
+
export interface AuthComponentHeadingsResult {
|
|
30
|
+
title: string;
|
|
31
|
+
subtitle: string;
|
|
32
|
+
componentsWithoutHeadings: EmbeddedFlowComponent[];
|
|
33
|
+
headingComponents: HeadingExtractionResult;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Extracts heading and subheading components from authentication flow components
|
|
37
|
+
* and provides resolved title/subtitle text with fallback logic.
|
|
38
|
+
*
|
|
39
|
+
* This utility helps maintain consistent heading extraction across authentication
|
|
40
|
+
* components (SignIn, SignUp, etc.) by identifying heading components within the
|
|
41
|
+
* flow structure and providing clean fallback behavior.
|
|
42
|
+
*
|
|
43
|
+
* @param components - Array of flow components to search
|
|
44
|
+
* @param flowTitle - Title from flow context (highest priority)
|
|
45
|
+
* @param flowSubtitle - Subtitle from flow context (highest priority)
|
|
46
|
+
* @param defaultTitle - Default title fallback (lowest priority)
|
|
47
|
+
* @param defaultSubtitle - Default subtitle fallback (lowest priority)
|
|
48
|
+
* @returns Object with resolved title and subtitle text, plus filtered components
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* const result = getAuthComponentHeadings(
|
|
53
|
+
* components,
|
|
54
|
+
* flowTitle,
|
|
55
|
+
* flowSubtitle,
|
|
56
|
+
* t('signin.heading'),
|
|
57
|
+
* t('signin.subheading')
|
|
58
|
+
* );
|
|
59
|
+
*
|
|
60
|
+
* // Use resolved titles
|
|
61
|
+
* <Card.Title>{result.title}</Card.Title>
|
|
62
|
+
* <Typography>{result.subtitle}</Typography>
|
|
63
|
+
*
|
|
64
|
+
* // Render filtered components (without headings)
|
|
65
|
+
* renderComponents(result.componentsWithoutHeadings);
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
declare const getAuthComponentHeadings: (components: EmbeddedFlowComponent[], flowTitle?: string, flowSubtitle?: string, defaultTitle?: string, defaultSubtitle?: string) => AuthComponentHeadingsResult;
|
|
69
|
+
export default getAuthComponentHeadings;
|
|
@@ -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 { UseTranslation } from '../../hooks/useTranslation';
|
|
19
|
+
/**
|
|
20
|
+
* Resolves a translation string using the provided translation function.
|
|
21
|
+
* If the text is not a translation string, returns the original text.
|
|
22
|
+
* @param text - The text to resolve (could be a translation string or regular text)
|
|
23
|
+
* @param t - The translation function from useTranslation
|
|
24
|
+
* @returns The resolved text
|
|
25
|
+
*/
|
|
26
|
+
export declare const resolveTranslation: (text: string | undefined, t: UseTranslation["t"]) => string;
|
|
27
|
+
export default resolveTranslation;
|
|
@@ -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 { UseTranslation } from '../../hooks/useTranslation';
|
|
19
|
+
/**
|
|
20
|
+
* Recursively resolves translation strings in an array of objects.
|
|
21
|
+
* @param items - Array of objects to process
|
|
22
|
+
* @param t - The translation function from useTranslation
|
|
23
|
+
* @param properties - Array of property names to resolve (optional)
|
|
24
|
+
* @returns A new array with resolved translations
|
|
25
|
+
*/
|
|
26
|
+
declare const resolveTranslationsInArray: <T extends Record<string, any>>(items: T[], t: UseTranslation["t"], properties?: string[]) => T[];
|
|
27
|
+
export default resolveTranslationsInArray;
|
|
@@ -15,16 +15,13 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
-
import {
|
|
19
|
-
import { UseTranslation } from '../../../../hooks/useTranslation';
|
|
18
|
+
import { UseTranslation } from '../../hooks/useTranslation';
|
|
20
19
|
/**
|
|
21
|
-
*
|
|
20
|
+
* Resolves translation strings in an object's properties.
|
|
21
|
+
* @param obj - The object to process
|
|
22
|
+
* @param t - The translation function from useTranslation
|
|
23
|
+
* @param properties - Array of property names to resolve (optional, defaults to common properties)
|
|
24
|
+
* @returns A new object with resolved translations
|
|
22
25
|
*/
|
|
23
|
-
export declare const
|
|
24
|
-
|
|
25
|
-
* Generic transformer that handles both simple and component-driven responses
|
|
26
|
-
*/
|
|
27
|
-
export declare const normalizeFlowResponse: (response: any, t: UseTranslation["t"]) => {
|
|
28
|
-
flowId: string;
|
|
29
|
-
components: EmbeddedFlowComponent[];
|
|
30
|
-
};
|
|
26
|
+
export declare const resolveTranslationsInObject: <T extends Record<string, any>>(obj: T, t: UseTranslation["t"], properties?: string[]) => T;
|
|
27
|
+
export default resolveTranslationsInObject;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asgardeo/react",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.18",
|
|
4
4
|
"description": "React implementation of Asgardeo JavaScript SDK.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"asgardeo",
|
|
@@ -59,8 +59,8 @@
|
|
|
59
59
|
"esbuild": "0.25.9",
|
|
60
60
|
"react-dom": "19.1.4",
|
|
61
61
|
"tslib": "2.8.1",
|
|
62
|
-
"@asgardeo/i18n": "0.3.
|
|
63
|
-
"@asgardeo/browser": "0.1.
|
|
62
|
+
"@asgardeo/i18n": "0.3.8",
|
|
63
|
+
"@asgardeo/browser": "0.1.35"
|
|
64
64
|
},
|
|
65
65
|
"publishConfig": {
|
|
66
66
|
"access": "public"
|
|
@@ -1,104 +0,0 @@
|
|
|
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 { EmbeddedFlowComponent, EmbeddedSignUpFlowErrorResponseV2, EmbeddedFlowExecuteErrorResponse } from '@asgardeo/browser';
|
|
19
|
-
import { UseTranslation } from '../../../hooks/useTranslation';
|
|
20
|
-
/**
|
|
21
|
-
* Transform simple flow response to component-driven format
|
|
22
|
-
*/
|
|
23
|
-
export declare const transformSimpleToComponentDriven: (response: any, t: UseTranslation["t"]) => EmbeddedFlowComponent[];
|
|
24
|
-
/**
|
|
25
|
-
* Extract error message from various error response formats.
|
|
26
|
-
*
|
|
27
|
-
* This function supports multiple error formats from different versions of Asgardeo APIs:
|
|
28
|
-
* - **AsgardeoV2 format**: Uses `failureReason` field from responses with `flowStatus: "ERROR"`
|
|
29
|
-
* - **AsgardeoV1 format**: Uses `description` or `message` fields from responses with error `code`
|
|
30
|
-
* - **AsgardeoAPIError**: Parses JSON from error messages to extract detailed error information
|
|
31
|
-
* - **Standard Error objects**: Falls back to the `message` property
|
|
32
|
-
* - **String errors**: Returns the string as-is
|
|
33
|
-
*
|
|
34
|
-
* @param error - The error object, which can be:
|
|
35
|
-
* - AsgardeoV2 error response: `{ flowStatus: "ERROR", failureReason: string, ... }`
|
|
36
|
-
* - AsgardeoV1 error response: `{ code: string, message?: string, description?: string, ... }`
|
|
37
|
-
* - AsgardeoAPIError instance with JSON message
|
|
38
|
-
* - Standard Error object
|
|
39
|
-
* - String error message
|
|
40
|
-
* @param t - Translation function for fallback error messages
|
|
41
|
-
* @returns Localized error message extracted from the error object
|
|
42
|
-
*
|
|
43
|
-
* @example
|
|
44
|
-
* ```typescript
|
|
45
|
-
* // AsgardeoV2 error
|
|
46
|
-
* const v2Error = { flowStatus: "ERROR", failureReason: "User already exists" };
|
|
47
|
-
* const message = extractErrorMessage(v2Error, t); // "User already exists"
|
|
48
|
-
*
|
|
49
|
-
* // AsgardeoV1 error
|
|
50
|
-
* const v1Error = { code: "FEE-60005", description: "Error while provisioning user" };
|
|
51
|
-
* const message = extractErrorMessage(v1Error, t); // "Error while provisioning user"
|
|
52
|
-
*
|
|
53
|
-
* // AsgardeoAPIError
|
|
54
|
-
* const apiError = new AsgardeoAPIError('{"failureReason": "Invalid credentials"}');
|
|
55
|
-
* const message = extractErrorMessage(apiError, t); // "Invalid credentials"
|
|
56
|
-
* ```
|
|
57
|
-
*/
|
|
58
|
-
export declare const extractErrorMessage: (error: EmbeddedSignUpFlowErrorResponseV2 | EmbeddedFlowExecuteErrorResponse, t: UseTranslation["t"]) => string;
|
|
59
|
-
/**
|
|
60
|
-
* Check if a response is an error response and extract the error message.
|
|
61
|
-
*
|
|
62
|
-
* This function serves as a guard to identify error responses from successful responses
|
|
63
|
-
* in both AsgardeoV1 and AsgardeoV2 API formats. It's particularly useful for flow
|
|
64
|
-
* normalization where error responses should be handled differently from success responses.
|
|
65
|
-
*
|
|
66
|
-
* **Supported Error Response Formats:**
|
|
67
|
-
* - **AsgardeoV2**: Responses with `flowStatus: "ERROR"` and `failureReason`
|
|
68
|
-
* - **AsgardeoV1**: Responses with error `code` and `message`/`description` fields
|
|
69
|
-
*
|
|
70
|
-
* @param response - The API response object to check for error indicators
|
|
71
|
-
* @param t - Translation function for extracting localized error messages
|
|
72
|
-
* @returns `null` if the response is not an error, or the extracted error message string if it is an error
|
|
73
|
-
*
|
|
74
|
-
* @example
|
|
75
|
-
* ```typescript
|
|
76
|
-
* // Success response
|
|
77
|
-
* const successResponse = { flowStatus: "INCOMPLETE", data: { components: [] } };
|
|
78
|
-
* const error = checkForErrorResponse(successResponse, t); // null
|
|
79
|
-
*
|
|
80
|
-
* // AsgardeoV2 error response
|
|
81
|
-
* const v2ErrorResponse = {
|
|
82
|
-
* flowStatus: "ERROR",
|
|
83
|
-
* failureReason: "User already exists with the provided username."
|
|
84
|
-
* };
|
|
85
|
-
* const error = checkForErrorResponse(v2ErrorResponse, t); // "User already exists with the provided username."
|
|
86
|
-
*
|
|
87
|
-
* // AsgardeoV1 error response
|
|
88
|
-
* const v1ErrorResponse = {
|
|
89
|
-
* code: "FEE-60005",
|
|
90
|
-
* message: "Error while provisioning user.",
|
|
91
|
-
* description: "Error occurred while provisioning user in the request of flow id: ac57315c-6ca6-49dc-8664-fcdcff354f46"
|
|
92
|
-
* };
|
|
93
|
-
* const error = checkForErrorResponse(v1ErrorResponse, t); // "Error occurred while provisioning user in the request of flow id: ac57315c-6ca6-49dc-8664-fcdcff354f46"
|
|
94
|
-
* ```
|
|
95
|
-
*/
|
|
96
|
-
export declare const checkForErrorResponse: (response: any, t: UseTranslation["t"]) => string | null;
|
|
97
|
-
/**
|
|
98
|
-
* Generic transformer that handles both simple and component-driven responses
|
|
99
|
-
* Also handles AsgardeoV2 error responses that should be thrown as errors
|
|
100
|
-
*/
|
|
101
|
-
export declare const normalizeFlowResponse: (response: any, t: UseTranslation["t"]) => {
|
|
102
|
-
flowId: string;
|
|
103
|
-
components: EmbeddedFlowComponent[];
|
|
104
|
-
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/components/presentation/{SignIn/non-component-driven → auth/SignIn/v1}/types.d.ts
RENAMED
|
File without changes
|
|
File without changes
|