@asgardeo/javascript 0.1.23 → 0.2.1
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/api/v2/executeEmbeddedSignUpFlowV2.d.ts +20 -0
- package/dist/cjs/index.js +102 -0
- package/dist/cjs/index.js.map +4 -4
- package/dist/index.d.ts +3 -1
- package/dist/index.js +99 -0
- package/dist/index.js.map +4 -4
- package/dist/models/config.d.ts +5 -0
- package/dist/models/embedded-flow.d.ts +96 -0
- package/dist/models/v2/embedded-signup-flow-v2.d.ts +226 -0
- package/dist/theme/types.d.ts +5 -0
- package/package.json +2 -2
package/dist/models/config.d.ts
CHANGED
|
@@ -199,6 +199,11 @@ export interface WithPreferences {
|
|
|
199
199
|
}
|
|
200
200
|
export type Config<T = unknown> = BaseConfig<T>;
|
|
201
201
|
export interface ThemePreferences {
|
|
202
|
+
/**
|
|
203
|
+
* The text direction for the UI.
|
|
204
|
+
* @default 'ltr'
|
|
205
|
+
*/
|
|
206
|
+
direction?: 'ltr' | 'rtl';
|
|
202
207
|
/**
|
|
203
208
|
* Inherit from Branding from WSO2 Identity Server or Asgardeo.
|
|
204
209
|
*/
|
|
@@ -60,8 +60,104 @@ export declare enum EmbeddedFlowComponentType {
|
|
|
60
60
|
Select = "SELECT",
|
|
61
61
|
Typography = "TYPOGRAPHY"
|
|
62
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Request configuration for executing embedded flow operations.
|
|
65
|
+
*
|
|
66
|
+
* This interface extends standard HTTP request configuration with additional
|
|
67
|
+
* properties specific to embedded flow execution, such as base URL and payload data.
|
|
68
|
+
*
|
|
69
|
+
* @template T - Type of the payload data being sent with the request
|
|
70
|
+
*/
|
|
63
71
|
export interface EmbeddedFlowExecuteRequestConfig<T = any> extends Partial<Request> {
|
|
72
|
+
/**
|
|
73
|
+
* Base URL for the API endpoint.
|
|
74
|
+
* This is typically the Asgardeo organization URL.
|
|
75
|
+
*/
|
|
64
76
|
baseUrl?: string;
|
|
77
|
+
/**
|
|
78
|
+
* Payload data to be sent with the request.
|
|
79
|
+
* The structure depends on the specific flow operation being executed.
|
|
80
|
+
*/
|
|
65
81
|
payload?: T;
|
|
82
|
+
/**
|
|
83
|
+
* Full URL for the API endpoint.
|
|
84
|
+
* If provided, this overrides the baseUrl.
|
|
85
|
+
*/
|
|
66
86
|
url?: string;
|
|
67
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* Error response structure for AsgardeoV1 embedded flow operations.
|
|
90
|
+
*
|
|
91
|
+
* This interface defines the structure of error responses returned by AsgardeoV1 APIs
|
|
92
|
+
* when flow operations (such as sign-up or sign-in) fail. This format is distinct from
|
|
93
|
+
* AsgardeoV2's error format which uses `failureReason` instead of `code`/`description`.
|
|
94
|
+
*
|
|
95
|
+
* **Key Characteristics:**
|
|
96
|
+
* - Uses structured error codes (e.g., "FEE-60005") for programmatic error handling
|
|
97
|
+
* - Provides both a brief `message` and detailed `description` for context
|
|
98
|
+
* - Includes `flowType` to identify which flow operation failed
|
|
99
|
+
*
|
|
100
|
+
* **Comparison with AsgardeoV2:**
|
|
101
|
+
* - **AsgardeoV1**: Uses `code`, `message`, `description` fields
|
|
102
|
+
* - **AsgardeoV2**: Uses `flowStatus: "ERROR"` with `failureReason` field
|
|
103
|
+
*
|
|
104
|
+
* **Error Handling:**
|
|
105
|
+
* This error response format is automatically detected and processed by the
|
|
106
|
+
* `extractErrorMessage()` and `checkForErrorResponse()` functions in the React
|
|
107
|
+
* transformer to extract meaningful error messages for display to users.
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```typescript
|
|
111
|
+
* // Typical AsgardeoV1 error response
|
|
112
|
+
* const errorResponse: EmbeddedFlowExecuteErrorResponse = {
|
|
113
|
+
* code: "FEE-60005",
|
|
114
|
+
* message: "Error while provisioning user.",
|
|
115
|
+
* description: "Error occurred while provisioning user in the request of flow id: ac57315c-6ca6-49dc-8664-fcdcff354f46",
|
|
116
|
+
* flowType: "REGISTRATION"
|
|
117
|
+
* };
|
|
118
|
+
*
|
|
119
|
+
* // The transformer will extract: "Error occurred while provisioning user in the request of flow id: ac57315c-6ca6-49dc-8664-fcdcff354f46"
|
|
120
|
+
* // (Prefers description over message as it's usually more detailed)
|
|
121
|
+
* ```
|
|
122
|
+
*
|
|
123
|
+
* @see {@link EmbeddedSignUpFlowErrorResponseV2} for the AsgardeoV2 equivalent error structure
|
|
124
|
+
*/
|
|
125
|
+
export interface EmbeddedFlowExecuteErrorResponse {
|
|
126
|
+
/**
|
|
127
|
+
* Structured error code identifying the type of error.
|
|
128
|
+
*
|
|
129
|
+
* Format typically follows pattern like "FEE-XXXXX" where:
|
|
130
|
+
* - "FEE" indicates Flow Execution Error
|
|
131
|
+
* - XXXXX is a numeric identifier for the specific error type
|
|
132
|
+
*
|
|
133
|
+
* @example "FEE-60005" - User provisioning error
|
|
134
|
+
*/
|
|
135
|
+
code: string;
|
|
136
|
+
/**
|
|
137
|
+
* Brief error message describing what went wrong.
|
|
138
|
+
*
|
|
139
|
+
* This is typically a short, high-level description of the error.
|
|
140
|
+
* For more detailed information, refer to the `description` field.
|
|
141
|
+
*
|
|
142
|
+
* @example "Error while provisioning user."
|
|
143
|
+
*/
|
|
144
|
+
message: string;
|
|
145
|
+
/**
|
|
146
|
+
* Detailed error description with contextual information.
|
|
147
|
+
*
|
|
148
|
+
* This field usually contains more specific information about the error,
|
|
149
|
+
* including flow IDs, operation details, and other debugging context.
|
|
150
|
+
* The transformer prefers this field over `message` when extracting
|
|
151
|
+
* error messages for display to users.
|
|
152
|
+
*
|
|
153
|
+
* @example "Error occurred while provisioning user in the request of flow id: ac57315c-6ca6-49dc-8664-fcdcff354f46"
|
|
154
|
+
*/
|
|
155
|
+
description: string;
|
|
156
|
+
/**
|
|
157
|
+
* Type of flow operation that encountered the error.
|
|
158
|
+
*
|
|
159
|
+
* Currently only supports 'REGISTRATION' but may be extended to
|
|
160
|
+
* include other flow types (e.g., 'LOGIN', 'PASSWORD_RESET') in the future.
|
|
161
|
+
*/
|
|
162
|
+
flowType: 'REGISTRATION';
|
|
163
|
+
}
|
|
@@ -0,0 +1,226 @@
|
|
|
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 { EmbeddedFlowExecuteRequestConfig, EmbeddedFlowResponseType, EmbeddedFlowType } from '../embedded-flow';
|
|
19
|
+
/**
|
|
20
|
+
* Status enumeration for AsgardeoV2 embedded sign-up flow responses.
|
|
21
|
+
*
|
|
22
|
+
* This enum defines the possible states of a sign-up flow operation,
|
|
23
|
+
* allowing client applications to determine the next appropriate action.
|
|
24
|
+
*
|
|
25
|
+
* @experimental Part of the new AsgardeoV2 API
|
|
26
|
+
*/
|
|
27
|
+
export declare enum EmbeddedSignUpFlowStatusV2 {
|
|
28
|
+
/**
|
|
29
|
+
* Sign-up flow has completed successfully.
|
|
30
|
+
*
|
|
31
|
+
* When this status is returned, the user has successfully registered
|
|
32
|
+
* and the flow can proceed to redirection or completion handling.
|
|
33
|
+
* The response will typically contain redirect information.
|
|
34
|
+
*/
|
|
35
|
+
Complete = "COMPLETE",
|
|
36
|
+
/**
|
|
37
|
+
* Sign-up flow is in progress and requires additional user input.
|
|
38
|
+
*
|
|
39
|
+
* This status indicates that more steps are needed to complete the
|
|
40
|
+
* sign-up process. The response will contain form components or
|
|
41
|
+
* actions that need to be presented to the user.
|
|
42
|
+
*/
|
|
43
|
+
Incomplete = "INCOMPLETE",
|
|
44
|
+
/**
|
|
45
|
+
* Sign-up flow encountered an error and cannot proceed.
|
|
46
|
+
*
|
|
47
|
+
* When this status is returned, the response will be of type
|
|
48
|
+
* `EmbeddedSignUpFlowErrorResponseV2` and will contain a `failureReason`
|
|
49
|
+
* field with details about what went wrong. This triggers error
|
|
50
|
+
* handling in the React components to display user-friendly messages.
|
|
51
|
+
*
|
|
52
|
+
* @see {@link EmbeddedSignUpFlowErrorResponseV2} for error response structure
|
|
53
|
+
*/
|
|
54
|
+
Error = "ERROR"
|
|
55
|
+
}
|
|
56
|
+
export declare enum EmbeddedSignUpFlowTypeV2 {
|
|
57
|
+
Redirection = "REDIRECTION",
|
|
58
|
+
View = "VIEW"
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Extended response structure for the embedded sign-up flow V2.
|
|
62
|
+
* @remarks This response is only done from the SDK level.
|
|
63
|
+
* @experimental
|
|
64
|
+
*/
|
|
65
|
+
export interface ExtendedEmbeddedSignUpFlowResponseV2 {
|
|
66
|
+
/**
|
|
67
|
+
* The URL to redirect the user after completing the sign-up flow.
|
|
68
|
+
*/
|
|
69
|
+
redirectUrl?: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Response structure for the new Asgardeo V2 embedded sign-up flow.
|
|
73
|
+
*
|
|
74
|
+
* This interface defines the structure for successful sign-up flow responses
|
|
75
|
+
* from AsgardeoV2 APIs. For error responses, see `EmbeddedSignUpFlowErrorResponseV2`.
|
|
76
|
+
*
|
|
77
|
+
* **Flow States:**
|
|
78
|
+
* - `INCOMPLETE`: More user input required, `data` contains form components
|
|
79
|
+
* - `COMPLETE`: Sign-up finished, may contain redirect information
|
|
80
|
+
* - For `ERROR` status, a separate `EmbeddedSignUpFlowErrorResponseV2` structure is used
|
|
81
|
+
*
|
|
82
|
+
* **Component-Driven UI:**
|
|
83
|
+
* The `data.inputs` and `data.actions` are transformed by the React transformer
|
|
84
|
+
* into component-driven format for consistent UI rendering across different
|
|
85
|
+
* Asgardeo versions.
|
|
86
|
+
*
|
|
87
|
+
* @experimental Part of the new AsgardeoV2 API
|
|
88
|
+
* @see {@link EmbeddedSignUpFlowErrorResponseV2} for error response structure
|
|
89
|
+
* @see {@link EmbeddedSignUpFlowStatusV2} for available flow statuses
|
|
90
|
+
*/
|
|
91
|
+
export interface EmbeddedSignUpFlowResponseV2 extends ExtendedEmbeddedSignUpFlowResponseV2 {
|
|
92
|
+
/**
|
|
93
|
+
* Unique identifier for this sign-up flow instance.
|
|
94
|
+
*/
|
|
95
|
+
flowId: string;
|
|
96
|
+
/**
|
|
97
|
+
* Current status of the sign-up flow.
|
|
98
|
+
* Determines whether more input is needed or the flow is complete.
|
|
99
|
+
*/
|
|
100
|
+
flowStatus: EmbeddedSignUpFlowStatusV2;
|
|
101
|
+
/**
|
|
102
|
+
* Type of response, indicating the expected user interaction.
|
|
103
|
+
*/
|
|
104
|
+
type: EmbeddedSignUpFlowTypeV2;
|
|
105
|
+
/**
|
|
106
|
+
* Flow data containing form inputs and available actions.
|
|
107
|
+
* This is transformed to component-driven format by the React transformer.
|
|
108
|
+
*/
|
|
109
|
+
data: {
|
|
110
|
+
/**
|
|
111
|
+
* Available actions the user can take (e.g., form submission, social sign-up).
|
|
112
|
+
*/
|
|
113
|
+
actions?: {
|
|
114
|
+
type: EmbeddedFlowResponseType;
|
|
115
|
+
id: string;
|
|
116
|
+
}[];
|
|
117
|
+
/**
|
|
118
|
+
* Input fields required for the current step of the sign-up flow.
|
|
119
|
+
*/
|
|
120
|
+
inputs?: {
|
|
121
|
+
name: string;
|
|
122
|
+
type: string;
|
|
123
|
+
required: boolean;
|
|
124
|
+
}[];
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Response structure for the new Asgardeo V2 embedded sign-up flow when the flow is complete.
|
|
129
|
+
* @experimental
|
|
130
|
+
*/
|
|
131
|
+
export interface EmbeddedSignUpFlowCompleteResponse {
|
|
132
|
+
redirect_uri: string;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Request payload for initiating the new Asgardeo V2 embedded sign-up flow.
|
|
136
|
+
* @experimental
|
|
137
|
+
*/
|
|
138
|
+
export type EmbeddedSignUpFlowInitiateRequestV2 = {
|
|
139
|
+
applicationId: string;
|
|
140
|
+
flowType: EmbeddedFlowType;
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* Request payload for executing steps in the new Asgardeo V2 embedded sign-up flow.
|
|
144
|
+
* @experimental
|
|
145
|
+
*/
|
|
146
|
+
export interface EmbeddedSignUpFlowRequestV2 extends Partial<EmbeddedSignUpFlowInitiateRequestV2> {
|
|
147
|
+
flowId?: string;
|
|
148
|
+
actionId?: string;
|
|
149
|
+
inputs?: Record<string, any>;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Request config for executing the new Asgardeo V2 embedded sign-up flow.
|
|
153
|
+
* @experimental
|
|
154
|
+
*/
|
|
155
|
+
export interface EmbeddedFlowExecuteRequestConfigV2<T = any> extends EmbeddedFlowExecuteRequestConfig<T> {
|
|
156
|
+
sessionDataKey?: string;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Error response structure for the new Asgardeo V2 embedded sign-up flow.
|
|
160
|
+
*
|
|
161
|
+
* This interface defines the structure of error responses returned by AsgardeoV2 APIs
|
|
162
|
+
* when sign-up operations fail. Unlike AsgardeoV1 which uses generic error codes and
|
|
163
|
+
* descriptions, AsgardeoV2 provides more specific failure reasons within the flow context.
|
|
164
|
+
*
|
|
165
|
+
* **Key Differences from AsgardeoV1:**
|
|
166
|
+
* - Uses `failureReason` instead of `message`/`description` for error details
|
|
167
|
+
* - Maintains flow context with `flowId` for tracking failed operations
|
|
168
|
+
* - Uses structured `flowStatus` enum instead of generic error codes
|
|
169
|
+
* - Provides empty `data` object for consistency with success responses
|
|
170
|
+
*
|
|
171
|
+
* **Error Handling:**
|
|
172
|
+
* This error response format is automatically detected and processed by the
|
|
173
|
+
* `extractErrorMessage()` and `checkForErrorResponse()` functions in the transformer
|
|
174
|
+
* to extract meaningful error messages for display to users.
|
|
175
|
+
*
|
|
176
|
+
* @example
|
|
177
|
+
* ```typescript
|
|
178
|
+
* // Typical AsgardeoV2 error response
|
|
179
|
+
* const errorResponse: EmbeddedSignUpFlowErrorResponseV2 = {
|
|
180
|
+
* flowId: "0ccfeaf9-18b3-43a5-bcc1-07d863dcb2c0",
|
|
181
|
+
* flowStatus: EmbeddedSignUpFlowStatusV2.Error,
|
|
182
|
+
* data: {},
|
|
183
|
+
* failureReason: "User already exists with the provided username."
|
|
184
|
+
* };
|
|
185
|
+
*
|
|
186
|
+
* // This will be automatically transformed to a user-friendly error message:
|
|
187
|
+
* // "User already exists with the provided username."
|
|
188
|
+
* ```
|
|
189
|
+
*
|
|
190
|
+
* @experimental This is part of the new AsgardeoV2 API and may change in future versions
|
|
191
|
+
* @see {@link EmbeddedSignUpFlowStatusV2.Error} for the error status enum value
|
|
192
|
+
* @see {@link EmbeddedSignUpFlowResponseV2} for the corresponding success response structure
|
|
193
|
+
*/
|
|
194
|
+
export interface EmbeddedSignUpFlowErrorResponseV2 {
|
|
195
|
+
/**
|
|
196
|
+
* Unique identifier for the sign-up flow instance.
|
|
197
|
+
* This ID is used to track the flow state and correlate error responses
|
|
198
|
+
* with the specific sign-up attempt that failed.
|
|
199
|
+
*/
|
|
200
|
+
flowId: string;
|
|
201
|
+
/**
|
|
202
|
+
* Status of the sign-up flow, which will be `EmbeddedSignUpFlowStatusV2.Error`
|
|
203
|
+
* for error responses. This field is used by error detection logic to
|
|
204
|
+
* identify failed flow responses.
|
|
205
|
+
*/
|
|
206
|
+
flowStatus: EmbeddedSignUpFlowStatusV2;
|
|
207
|
+
/**
|
|
208
|
+
* Additional response data, typically empty for error responses.
|
|
209
|
+
* Maintained for structural consistency with successful flow responses
|
|
210
|
+
* which contain components, actions, and other flow data.
|
|
211
|
+
*/
|
|
212
|
+
data: Record<string, any>;
|
|
213
|
+
/**
|
|
214
|
+
* Human-readable explanation of why the sign-up operation failed.
|
|
215
|
+
*
|
|
216
|
+
* This field contains specific error details that can be directly displayed
|
|
217
|
+
* to users, such as:
|
|
218
|
+
* - "User already exists with the provided username."
|
|
219
|
+
* - "Invalid email address format."
|
|
220
|
+
* - "Password does not meet complexity requirements."
|
|
221
|
+
*
|
|
222
|
+
* Unlike generic error codes, this provides contextual information
|
|
223
|
+
* that helps users understand and resolve the issue.
|
|
224
|
+
*/
|
|
225
|
+
failureReason: string;
|
|
226
|
+
}
|
package/dist/theme/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asgardeo/javascript",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Framework agnostic JavaScript SDK for Asgardeo.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"asgardeo",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"tslib": "^2.8.1",
|
|
49
|
-
"@asgardeo/i18n": "^0.3.
|
|
49
|
+
"@asgardeo/i18n": "^0.3.2"
|
|
50
50
|
},
|
|
51
51
|
"publishConfig": {
|
|
52
52
|
"access": "public"
|