@asgardeo/javascript 0.2.9 → 0.2.10
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/executeEmbeddedSignInFlowV2.d.ts +2 -1
- package/dist/api/v2/executeEmbeddedSignUpFlowV2.d.ts +2 -1
- package/dist/cjs/index.js +109 -52
- package/dist/cjs/index.js.map +4 -4
- package/dist/index.d.ts +3 -2
- package/dist/index.js +105 -52
- package/dist/index.js.map +4 -4
- package/dist/models/embedded-flow.d.ts +1 -1
- package/dist/models/v2/embedded-flow-v2.d.ts +307 -0
- package/dist/models/v2/embedded-signin-flow-v2.d.ts +261 -31
- package/dist/models/v2/embedded-signup-flow-v2.d.ts +91 -57
- package/package.json +2 -2
|
@@ -120,7 +120,7 @@ export interface EmbeddedFlowExecuteRequestConfig<T = any> extends Partial<Reque
|
|
|
120
120
|
* // (Prefers description over message as it's usually more detailed)
|
|
121
121
|
* ```
|
|
122
122
|
*
|
|
123
|
-
* @see {@link
|
|
123
|
+
* @see {@link EmbeddedSignUpFlowErrorResponse} for the AsgardeoV2 equivalent error structure
|
|
124
124
|
*/
|
|
125
125
|
export interface EmbeddedFlowExecuteErrorResponse {
|
|
126
126
|
/**
|
|
@@ -0,0 +1,307 @@
|
|
|
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 as EmbeddedFlowExecuteRequestConfigV1 } from '../embedded-flow';
|
|
19
|
+
/**
|
|
20
|
+
* Component types supported by the Asgardeo embedded flow API.
|
|
21
|
+
*
|
|
22
|
+
* These types define the different UI components that can be rendered
|
|
23
|
+
* as part of the embedded authentication flows. Each type corresponds
|
|
24
|
+
* to a specific UI element with its own behavior and properties.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* // Check component type to render appropriate UI
|
|
29
|
+
* if (component.type === EmbeddedFlowComponentType.TextInput) {
|
|
30
|
+
* // Render text input field
|
|
31
|
+
* } else if (component.type === EmbeddedFlowComponentType.Action) {
|
|
32
|
+
* // Render button/action
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @experimental This API may change in future versions
|
|
37
|
+
*/
|
|
38
|
+
export declare enum EmbeddedFlowComponentType {
|
|
39
|
+
/** Standard text input field for user data entry */
|
|
40
|
+
TextInput = "TEXT_INPUT",
|
|
41
|
+
/** Password input field with masking for sensitive data */
|
|
42
|
+
PasswordInput = "PASSWORD_INPUT",
|
|
43
|
+
/**
|
|
44
|
+
* Email input field with validation for email addresses.
|
|
45
|
+
*/
|
|
46
|
+
EmailInput = "EMAIL_INPUT",
|
|
47
|
+
/** Text display component for labels, headings, and messages */
|
|
48
|
+
Text = "TEXT",
|
|
49
|
+
/** Interactive action component (buttons, links) for user interactions */
|
|
50
|
+
Action = "ACTION",
|
|
51
|
+
/** Container block component that groups other components */
|
|
52
|
+
Block = "BLOCK"
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Action variant types for buttons and interactive elements.
|
|
56
|
+
*
|
|
57
|
+
* @experimental This API may change in future versions
|
|
58
|
+
*/
|
|
59
|
+
export declare enum EmbeddedFlowActionVariant {
|
|
60
|
+
Primary = "PRIMARY",
|
|
61
|
+
Secondary = "SECONDARY",
|
|
62
|
+
Tertiary = "TERTIARY",
|
|
63
|
+
Danger = "DANGER",
|
|
64
|
+
Success = "SUCCESS",
|
|
65
|
+
Info = "INFO",
|
|
66
|
+
Warning = "WARNING",
|
|
67
|
+
Link = "LINK"
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Text variant types for typography components.
|
|
71
|
+
*
|
|
72
|
+
* @experimental This API may change in future versions
|
|
73
|
+
*/
|
|
74
|
+
export declare enum EmbeddedFlowTextVariant {
|
|
75
|
+
Heading1 = "HEADING_1",
|
|
76
|
+
Heading2 = "HEADING_2",
|
|
77
|
+
Heading3 = "HEADING_3",
|
|
78
|
+
Heading4 = "HEADING_4",
|
|
79
|
+
Heading5 = "HEADING_5",
|
|
80
|
+
Heading6 = "HEADING_6",
|
|
81
|
+
Subtitle1 = "SUBTITLE_1",
|
|
82
|
+
Subtitle2 = "SUBTITLE_2",
|
|
83
|
+
Body1 = "BODY_1",
|
|
84
|
+
Body2 = "BODY_2",
|
|
85
|
+
Caption = "CAPTION",
|
|
86
|
+
Overline = "OVERLINE",
|
|
87
|
+
ButtonText = "BUTTON_TEXT"
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Event types for action components.
|
|
91
|
+
*
|
|
92
|
+
* @experimental This API may change in future versions
|
|
93
|
+
*/
|
|
94
|
+
export declare enum EmbeddedFlowEventType {
|
|
95
|
+
Trigger = "TRIGGER",
|
|
96
|
+
Submit = "SUBMIT",
|
|
97
|
+
Navigate = "NAVIGATE",
|
|
98
|
+
Cancel = "CANCEL",
|
|
99
|
+
Reset = "RESET",
|
|
100
|
+
Back = "BACK"
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Enhanced component interface for embedded flow components.
|
|
104
|
+
*
|
|
105
|
+
* This interface provides better support for modern form handling and user experience.
|
|
106
|
+
* It includes properties for labels, placeholders, and required field validation
|
|
107
|
+
* that are directly provided by the API response.
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```typescript
|
|
111
|
+
* const component: EmbeddedFlowComponent = {
|
|
112
|
+
* id: 'username_field',
|
|
113
|
+
* type: EmbeddedFlowComponentType.TextInput,
|
|
114
|
+
* label: 'Username',
|
|
115
|
+
* placeholder: 'Enter your username',
|
|
116
|
+
* required: true,
|
|
117
|
+
* variant: 'TEXT',
|
|
118
|
+
* eventType: 'SUBMIT',
|
|
119
|
+
* components: []
|
|
120
|
+
* };
|
|
121
|
+
* ```
|
|
122
|
+
*
|
|
123
|
+
* @experimental This interface may change in future versions
|
|
124
|
+
*/
|
|
125
|
+
export interface EmbeddedFlowComponent {
|
|
126
|
+
/**
|
|
127
|
+
* Unique identifier for the component
|
|
128
|
+
*/
|
|
129
|
+
id: string;
|
|
130
|
+
/**
|
|
131
|
+
* Reference identifier for the component (e.g., field name, action ref)
|
|
132
|
+
*/
|
|
133
|
+
ref?: string;
|
|
134
|
+
/**
|
|
135
|
+
* Component type that determines rendering behavior
|
|
136
|
+
*/
|
|
137
|
+
type: EmbeddedFlowComponentType | string;
|
|
138
|
+
/**
|
|
139
|
+
* Display label for the component (e.g., field label, button text).
|
|
140
|
+
* Supports internationalization and may contain template strings.
|
|
141
|
+
*/
|
|
142
|
+
label?: string;
|
|
143
|
+
/**
|
|
144
|
+
* Placeholder text for input components.
|
|
145
|
+
* Provides helpful hints to users about expected input format.
|
|
146
|
+
*/
|
|
147
|
+
placeholder?: string;
|
|
148
|
+
/**
|
|
149
|
+
* Indicates whether this component represents a required field.
|
|
150
|
+
* Used for form validation and UI indicators.
|
|
151
|
+
*/
|
|
152
|
+
required?: boolean;
|
|
153
|
+
/**
|
|
154
|
+
* Component variant that affects visual styling and behavior.
|
|
155
|
+
* The value depends on the component type (e.g., button variants, text variants).
|
|
156
|
+
*/
|
|
157
|
+
variant?: EmbeddedFlowActionVariant | EmbeddedFlowTextVariant | string;
|
|
158
|
+
/**
|
|
159
|
+
* Event type for action components that defines the interaction behavior.
|
|
160
|
+
* Only relevant for Action components.
|
|
161
|
+
*/
|
|
162
|
+
eventType?: EmbeddedFlowEventType | string;
|
|
163
|
+
/**
|
|
164
|
+
* Nested child components for container components like Block.
|
|
165
|
+
*/
|
|
166
|
+
components?: EmbeddedFlowComponent[];
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Response data structure for embedded flow API.
|
|
170
|
+
*
|
|
171
|
+
* This interface defines the structure of data returned by the API,
|
|
172
|
+
* which includes both legacy input/action arrays for backward compatibility
|
|
173
|
+
* and the new meta.components structure for modern component-driven UIs.
|
|
174
|
+
*
|
|
175
|
+
* The key improvement is the meta.components field, which provides
|
|
176
|
+
* a rich component tree with proper labels, placeholders, and hierarchy
|
|
177
|
+
* that can be directly rendered without additional transformation.
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* ```typescript
|
|
181
|
+
* const response: EmbeddedFlowResponseData = {
|
|
182
|
+
* // Legacy format (for backward compatibility)
|
|
183
|
+
* inputs: [
|
|
184
|
+
* { ref: 'input_001', identifier: 'username', type: 'TEXT_INPUT', required: true }
|
|
185
|
+
* ],
|
|
186
|
+
* actions: [
|
|
187
|
+
* { ref: 'action_001', nextNode: 'basic_auth', eventType: 'SUBMIT' }
|
|
188
|
+
* ],
|
|
189
|
+
* // Modern format (recommended)
|
|
190
|
+
* meta: {
|
|
191
|
+
* components: [
|
|
192
|
+
* {
|
|
193
|
+
* id: 'text_001',
|
|
194
|
+
* type: 'TEXT',
|
|
195
|
+
* label: '{{ t(signin:heading.label) }}',
|
|
196
|
+
* variant: 'HEADING_1'
|
|
197
|
+
* },
|
|
198
|
+
* {
|
|
199
|
+
* id: 'block_001',
|
|
200
|
+
* type: 'BLOCK',
|
|
201
|
+
* components: [
|
|
202
|
+
* {
|
|
203
|
+
* id: 'input_001',
|
|
204
|
+
* type: 'TEXT_INPUT',
|
|
205
|
+
* label: '{{ t(signin:fields.username.label) }}',
|
|
206
|
+
* placeholder: '{{ t(signin:fields.username.placeholder) }}',
|
|
207
|
+
* required: true
|
|
208
|
+
* },
|
|
209
|
+
* {
|
|
210
|
+
* id: 'action_001',
|
|
211
|
+
* type: 'ACTION',
|
|
212
|
+
* label: '{{ t(signin:buttons.submit.label) }}',
|
|
213
|
+
* variant: 'PRIMARY',
|
|
214
|
+
* eventType: 'ACTIVATE'
|
|
215
|
+
* }
|
|
216
|
+
* ]
|
|
217
|
+
* }
|
|
218
|
+
* ]
|
|
219
|
+
* }
|
|
220
|
+
* };
|
|
221
|
+
* ```
|
|
222
|
+
*
|
|
223
|
+
* @experimental This structure may change in future versions
|
|
224
|
+
*/
|
|
225
|
+
export interface EmbeddedFlowResponseData {
|
|
226
|
+
/**
|
|
227
|
+
* Legacy input definitions for backward compatibility.
|
|
228
|
+
* @deprecated Use meta.components for new implementations
|
|
229
|
+
*/
|
|
230
|
+
inputs?: {
|
|
231
|
+
/** Reference identifier for the input */
|
|
232
|
+
ref: string;
|
|
233
|
+
/** Field identifier used in form submission */
|
|
234
|
+
identifier: string;
|
|
235
|
+
/** Input type (TEXT_INPUT, PASSWORD_INPUT, etc.) */
|
|
236
|
+
type: string;
|
|
237
|
+
/** Whether this input is required for form submission */
|
|
238
|
+
required: boolean;
|
|
239
|
+
}[];
|
|
240
|
+
/**
|
|
241
|
+
* Legacy action definitions for backward compatibility.
|
|
242
|
+
* @deprecated Use meta.components for new implementations
|
|
243
|
+
*/
|
|
244
|
+
actions?: {
|
|
245
|
+
/** Reference identifier for the action */
|
|
246
|
+
ref: string;
|
|
247
|
+
/** Next flow node to navigate to (optional) */
|
|
248
|
+
nextNode?: string;
|
|
249
|
+
/** Event type for the action (SUBMIT, ACTIVATE, etc.) */
|
|
250
|
+
eventType?: string;
|
|
251
|
+
}[];
|
|
252
|
+
/**
|
|
253
|
+
* Modern component-driven metadata structure.
|
|
254
|
+
* This contains the complete UI component tree with proper
|
|
255
|
+
* hierarchy, labels, and configuration that can be directly rendered.
|
|
256
|
+
*
|
|
257
|
+
* **This is the primary data source for implementations.**
|
|
258
|
+
* The legacy inputs/actions arrays are maintained only for backward compatibility.
|
|
259
|
+
*/
|
|
260
|
+
meta?: {
|
|
261
|
+
/** Array of components that define the complete UI structure */
|
|
262
|
+
components: EmbeddedFlowComponent[];
|
|
263
|
+
};
|
|
264
|
+
/**
|
|
265
|
+
* Optional redirect URL for flow completion or external authentication.
|
|
266
|
+
*/
|
|
267
|
+
redirectURL?: string;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Extended request configuration for Asgardeo V2 embedded flow operations.
|
|
271
|
+
*
|
|
272
|
+
* This interface extends the base request configuration with V2-specific
|
|
273
|
+
* properties required for the enhanced embedded flow API. The authId parameter
|
|
274
|
+
* is particularly important for the V2 OAuth2 flow completion process.
|
|
275
|
+
*
|
|
276
|
+
* @template T The type of the payload data being sent with the request
|
|
277
|
+
*
|
|
278
|
+
* @example
|
|
279
|
+
* ```typescript
|
|
280
|
+
* const config: EmbeddedFlowExecuteRequestConfigV2 = {
|
|
281
|
+
* baseUrl: 'https://api.asgardeo.io/t/myorg',
|
|
282
|
+
* payload: {
|
|
283
|
+
* flowType: 'AUTHENTICATION',
|
|
284
|
+
* inputs: { username: 'user@example.com' }
|
|
285
|
+
* },
|
|
286
|
+
* authId: 'auth_12345', // V2-specific for OAuth completion
|
|
287
|
+
* headers: {
|
|
288
|
+
* 'Authorization': 'Bearer token'
|
|
289
|
+
* }
|
|
290
|
+
* };
|
|
291
|
+
* ```
|
|
292
|
+
*
|
|
293
|
+
* @experimental This configuration is part of the new Asgardeo V2 platform
|
|
294
|
+
*/
|
|
295
|
+
export interface EmbeddedFlowExecuteRequestConfig<T = any> extends EmbeddedFlowExecuteRequestConfigV1<T> {
|
|
296
|
+
/**
|
|
297
|
+
* Authentication ID used for OAuth2 flow completion in V2 API.
|
|
298
|
+
*
|
|
299
|
+
* When the embedded flow completes successfully and returns an assertion,
|
|
300
|
+
* this authId is used to complete the OAuth2 authorization flow by calling
|
|
301
|
+
* the `/oauth2/authorize` endpoint. This enables seamless transition from
|
|
302
|
+
* embedded flow to traditional OAuth2 flow completion.
|
|
303
|
+
*
|
|
304
|
+
* @example "auth_abc123def456"
|
|
305
|
+
*/
|
|
306
|
+
authId?: string;
|
|
307
|
+
}
|
|
@@ -15,75 +15,305 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
-
import {
|
|
19
|
-
|
|
18
|
+
import { EmbeddedFlowResponseType as EmbeddedFlowResponseTypeV1, EmbeddedFlowType as EmbeddedFlowTypeV1 } from '../embedded-flow';
|
|
19
|
+
import { EmbeddedFlowResponseData as EmbeddedFlowResponseDataV2 } from './embedded-flow-v2';
|
|
20
|
+
/**
|
|
21
|
+
* Status enumeration for Asgardeo embedded sign-in flow operations.
|
|
22
|
+
*
|
|
23
|
+
* These statuses indicate the current state of the sign-in flow and determine
|
|
24
|
+
* the next action required by the client application. Each status provides
|
|
25
|
+
* specific guidance on how to proceed with the authentication process.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* switch (response.flowStatus) {
|
|
30
|
+
* case EmbeddedSignInFlowStatus.Incomplete:
|
|
31
|
+
* // More user input needed - render form components
|
|
32
|
+
* break;
|
|
33
|
+
* case EmbeddedSignInFlowStatus.Complete:
|
|
34
|
+
* // Authentication successful - handle completion
|
|
35
|
+
* break;
|
|
36
|
+
* case EmbeddedSignInFlowStatus.Error:
|
|
37
|
+
* // Authentication failed - show error message
|
|
38
|
+
* break;
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @experimental Part of the new Asgardeo API
|
|
43
|
+
*/
|
|
44
|
+
export declare enum EmbeddedSignInFlowStatus {
|
|
45
|
+
/**
|
|
46
|
+
* Sign-in flow completed successfully.
|
|
47
|
+
*
|
|
48
|
+
* The user has been authenticated and the flow can proceed to
|
|
49
|
+
* OAuth2 completion or redirection. Check for redirectUrl or
|
|
50
|
+
* assertion data in the response.
|
|
51
|
+
*/
|
|
20
52
|
Complete = "COMPLETE",
|
|
53
|
+
/**
|
|
54
|
+
* Sign-in flow requires additional user input.
|
|
55
|
+
*
|
|
56
|
+
* More authentication steps are needed. The response will contain
|
|
57
|
+
* components in data.meta.components that should be rendered to
|
|
58
|
+
* collect additional user input (e.g., MFA, password, etc.).
|
|
59
|
+
*/
|
|
21
60
|
Incomplete = "INCOMPLETE",
|
|
61
|
+
/**
|
|
62
|
+
* Sign-in flow encountered an error.
|
|
63
|
+
*
|
|
64
|
+
* Authentication failed due to invalid credentials, system error,
|
|
65
|
+
* or other issues. Check error details in the response and handle
|
|
66
|
+
* appropriately (retry, show error message, etc.).
|
|
67
|
+
*/
|
|
22
68
|
Error = "ERROR"
|
|
23
69
|
}
|
|
24
|
-
|
|
70
|
+
/**
|
|
71
|
+
* Type enumeration for Asgardeo embedded sign-in flow responses.
|
|
72
|
+
*
|
|
73
|
+
* Determines the nature of the flow response and how the client should
|
|
74
|
+
* handle the returned data. This affects both UI rendering and flow
|
|
75
|
+
* continuation logic.
|
|
76
|
+
*
|
|
77
|
+
* @experimental Part of the new Asgardeo API
|
|
78
|
+
*/
|
|
79
|
+
export declare enum EmbeddedSignInFlowType {
|
|
80
|
+
/**
|
|
81
|
+
* Response requires external redirection.
|
|
82
|
+
*
|
|
83
|
+
* Used for social login providers, external identity providers,
|
|
84
|
+
* or other flows that require navigating to an external URL.
|
|
85
|
+
* The response will contain redirection information.
|
|
86
|
+
*/
|
|
25
87
|
Redirection = "REDIRECTION",
|
|
88
|
+
/**
|
|
89
|
+
* Response contains view components for rendering.
|
|
90
|
+
*
|
|
91
|
+
* Standard embedded flow response containing UI components
|
|
92
|
+
* that should be rendered within the current application
|
|
93
|
+
* context. Most common type for embedded authentication.
|
|
94
|
+
*/
|
|
26
95
|
View = "VIEW"
|
|
27
96
|
}
|
|
28
97
|
/**
|
|
29
|
-
* Extended response structure for
|
|
30
|
-
*
|
|
31
|
-
*
|
|
98
|
+
* Extended response structure for Asgardeo embedded sign-in flow.
|
|
99
|
+
*
|
|
100
|
+
* This interface defines additional properties that are added at the SDK level
|
|
101
|
+
* to enhance the basic API response with client-side computed values. These
|
|
102
|
+
* properties provide convenience for common post-authentication operations.
|
|
103
|
+
*
|
|
104
|
+
* @remarks This response structure is enhanced by the SDK and contains
|
|
105
|
+
* properties beyond the raw API response. It's designed to simplify
|
|
106
|
+
* post-authentication handling for client applications.
|
|
107
|
+
*
|
|
108
|
+
* @experimental This interface is part of the new Asgardeo platform
|
|
32
109
|
*/
|
|
33
|
-
export interface
|
|
110
|
+
export interface ExtendedEmbeddedSignInFlowResponse {
|
|
34
111
|
/**
|
|
35
|
-
*
|
|
112
|
+
* Computed redirect URL for post-authentication navigation.
|
|
113
|
+
*
|
|
114
|
+
* This URL is determined by the SDK based on the flow completion result
|
|
115
|
+
* and configured redirect settings. When present, the client application
|
|
116
|
+
* should navigate to this URL to complete the authentication process.
|
|
117
|
+
*
|
|
118
|
+
* @example "https://myapp.com/dashboard?session=abc123"
|
|
36
119
|
*/
|
|
37
120
|
redirectUrl?: string;
|
|
38
121
|
}
|
|
39
122
|
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
123
|
+
* Primary response structure for Asgardeo embedded sign-in flow operations.
|
|
124
|
+
*
|
|
125
|
+
* This is the main response interface returned by the sign-in API, combining
|
|
126
|
+
* the enhanced SDK properties with the core API response data. It provides all
|
|
127
|
+
* information needed to handle the current state of the authentication flow.
|
|
128
|
+
*
|
|
129
|
+
* The response structure adapts based on the flow status:
|
|
130
|
+
* - INCOMPLETE: Contains components for user interaction
|
|
131
|
+
* - COMPLETE: Contains completion data and potential redirection info
|
|
132
|
+
* - ERROR: Contains error information for troubleshooting
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* ```typescript
|
|
136
|
+
* const response: EmbeddedSignInFlowResponse = {
|
|
137
|
+
* flowId: "flow_12345",
|
|
138
|
+
* flowStatus: EmbeddedSignInFlowStatus.Incomplete,
|
|
139
|
+
* type: EmbeddedSignInFlowType.View,
|
|
140
|
+
* data: {
|
|
141
|
+
* meta: {
|
|
142
|
+
* components: [
|
|
143
|
+
* {
|
|
144
|
+
* id: "username_field",
|
|
145
|
+
* type: EmbeddedFlowComponentType.TextInput,
|
|
146
|
+
* label: "Username",
|
|
147
|
+
* required: true
|
|
148
|
+
* }
|
|
149
|
+
* ]
|
|
150
|
+
* }
|
|
151
|
+
* }
|
|
152
|
+
* };
|
|
153
|
+
* ```
|
|
154
|
+
*
|
|
155
|
+
* @experimental This interface is part of the new Asgardeo platform
|
|
42
156
|
*/
|
|
43
|
-
export interface
|
|
157
|
+
export interface EmbeddedSignInFlowResponse extends ExtendedEmbeddedSignInFlowResponse {
|
|
158
|
+
/**
|
|
159
|
+
* Unique identifier for this specific flow instance.
|
|
160
|
+
* Used to maintain state across multiple API calls during the authentication process.
|
|
161
|
+
*/
|
|
44
162
|
flowId: string;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
163
|
+
/**
|
|
164
|
+
* Current status of the sign-in flow.
|
|
165
|
+
* Determines the next action required by the client application.
|
|
166
|
+
*/
|
|
167
|
+
flowStatus: EmbeddedSignInFlowStatus;
|
|
168
|
+
/**
|
|
169
|
+
* Type of response indicating how to handle the returned data.
|
|
170
|
+
* Affects both UI rendering and navigation logic.
|
|
171
|
+
*/
|
|
172
|
+
type: EmbeddedSignInFlowType;
|
|
173
|
+
/**
|
|
174
|
+
* Core response data containing UI components and flow metadata.
|
|
175
|
+
* Includes both modern meta.components structure and legacy fields for compatibility.
|
|
176
|
+
*/
|
|
177
|
+
data: EmbeddedFlowResponseDataV2 & {
|
|
178
|
+
/**
|
|
179
|
+
* Legacy action definitions for backward compatibility.
|
|
180
|
+
* @deprecated Use data.meta.components for new implementations
|
|
181
|
+
*/
|
|
48
182
|
actions?: {
|
|
49
|
-
type
|
|
183
|
+
/** Action type identifier */
|
|
184
|
+
type: EmbeddedFlowResponseTypeV1;
|
|
185
|
+
/** Unique action identifier */
|
|
50
186
|
id: string;
|
|
51
187
|
}[];
|
|
188
|
+
/**
|
|
189
|
+
* Legacy input field definitions for backward compatibility.
|
|
190
|
+
* @deprecated Use data.meta.components for new implementations
|
|
191
|
+
*/
|
|
52
192
|
inputs?: {
|
|
193
|
+
/** Field name identifier */
|
|
53
194
|
name: string;
|
|
195
|
+
/** Input field type */
|
|
54
196
|
type: string;
|
|
197
|
+
/** Whether the field is required */
|
|
55
198
|
required: boolean;
|
|
56
199
|
}[];
|
|
57
200
|
};
|
|
58
201
|
}
|
|
59
202
|
/**
|
|
60
|
-
* Response structure for
|
|
61
|
-
*
|
|
203
|
+
* Response structure for completed Asgardeo embedded sign-in flows.
|
|
204
|
+
*
|
|
205
|
+
* This interface defines the response format when the embedded sign-in flow
|
|
206
|
+
* reaches the COMPLETE status and requires OAuth2 flow completion. It contains
|
|
207
|
+
* the redirect URI that should be used for the final authentication step.
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* ```typescript
|
|
211
|
+
* const completeResponse: EmbeddedSignInFlowCompleteResponse = {
|
|
212
|
+
* redirect_uri: "https://myapp.com/callback?code=abc123&state=xyz789"
|
|
213
|
+
* };
|
|
214
|
+
*
|
|
215
|
+
* // Typically handled automatically by the SDK
|
|
216
|
+
* window.location.href = completeResponse.redirect_uri;
|
|
217
|
+
* ```
|
|
218
|
+
*
|
|
219
|
+
* @experimental This interface is part of the new Asgardeo platform
|
|
62
220
|
*/
|
|
63
221
|
export interface EmbeddedSignInFlowCompleteResponse {
|
|
222
|
+
/**
|
|
223
|
+
* OAuth2 redirect URI for completing the authentication flow.
|
|
224
|
+
*
|
|
225
|
+
* Contains the final redirect URL with authorization code, state,
|
|
226
|
+
* and other OAuth2 parameters needed to complete the authentication
|
|
227
|
+
* process. This URL should be navigated to automatically or manually
|
|
228
|
+
* depending on the application's requirements.
|
|
229
|
+
*/
|
|
64
230
|
redirect_uri: string;
|
|
65
231
|
}
|
|
66
232
|
/**
|
|
67
|
-
* Request payload for initiating
|
|
68
|
-
*
|
|
233
|
+
* Request payload for initiating Asgardeo embedded sign-in flows.
|
|
234
|
+
*
|
|
235
|
+
* This type defines the minimum required information to start a new
|
|
236
|
+
* embedded sign-in flow. The flow type determines the kind of authentication
|
|
237
|
+
* process that will be initiated (e.g., standard login, MFA, etc.).
|
|
238
|
+
*
|
|
239
|
+
* @example
|
|
240
|
+
* ```typescript
|
|
241
|
+
* const initRequest: EmbeddedSignInFlowInitiateRequest = {
|
|
242
|
+
* applicationId: "app_12345",
|
|
243
|
+
* flowType: EmbeddedFlowType.Authentication
|
|
244
|
+
* };
|
|
245
|
+
*
|
|
246
|
+
* const response = await executeEmbeddedSignInFlow({
|
|
247
|
+
* baseUrl: "https://api.asgardeo.io/t/myorg",
|
|
248
|
+
* payload: initRequest
|
|
249
|
+
* });
|
|
250
|
+
* ```
|
|
251
|
+
*
|
|
252
|
+
* @experimental This type is part of the new Asgardeo platform
|
|
69
253
|
*/
|
|
70
|
-
export type
|
|
254
|
+
export type EmbeddedSignInFlowInitiateRequest = {
|
|
255
|
+
/**
|
|
256
|
+
* Unique identifier of the application initiating the sign-in flow.
|
|
257
|
+
* Must be a valid application ID registered in the Asgardeo organization.
|
|
258
|
+
*/
|
|
71
259
|
applicationId: string;
|
|
72
|
-
|
|
260
|
+
/**
|
|
261
|
+
* Type of embedded flow to initiate.
|
|
262
|
+
* Determines the authentication process and available options.
|
|
263
|
+
*/
|
|
264
|
+
flowType: EmbeddedFlowTypeV1;
|
|
73
265
|
};
|
|
74
266
|
/**
|
|
75
|
-
* Request payload for executing steps in
|
|
76
|
-
*
|
|
267
|
+
* Request payload for executing steps in Asgardeo embedded sign-in flows.
|
|
268
|
+
*
|
|
269
|
+
* This interface defines the structure for subsequent requests after flow initiation.
|
|
270
|
+
* It supports both continuing existing flows (with flowId) and submitting user
|
|
271
|
+
* input data collected from the rendered components.
|
|
272
|
+
*
|
|
273
|
+
* @example
|
|
274
|
+
* ```typescript
|
|
275
|
+
* // Continue existing flow with user input
|
|
276
|
+
* const stepRequest: EmbeddedSignInFlowRequest = {
|
|
277
|
+
* flowId: "flow_12345",
|
|
278
|
+
* actionId: "action_001",
|
|
279
|
+
* inputs: {
|
|
280
|
+
* username: "user@example.com",
|
|
281
|
+
* password: "securePassword123"
|
|
282
|
+
* }
|
|
283
|
+
* };
|
|
284
|
+
*
|
|
285
|
+
* // Submit to continue the flow
|
|
286
|
+
* const response = await executeEmbeddedSignInFlow({
|
|
287
|
+
* baseUrl: "https://api.asgardeo.io/t/myorg",
|
|
288
|
+
* payload: stepRequest
|
|
289
|
+
* });
|
|
290
|
+
* ```
|
|
291
|
+
*
|
|
292
|
+
* @experimental This interface is part of the new Asgardeo platform
|
|
77
293
|
*/
|
|
78
|
-
export interface
|
|
294
|
+
export interface EmbeddedSignInFlowRequest extends Partial<EmbeddedSignInFlowInitiateRequest> {
|
|
295
|
+
/**
|
|
296
|
+
* Identifier of the flow instance to continue.
|
|
297
|
+
* Required when submitting data for an existing flow.
|
|
298
|
+
*/
|
|
79
299
|
flowId?: string;
|
|
300
|
+
/**
|
|
301
|
+
* Identifier of the specific action being triggered.
|
|
302
|
+
* Corresponds to action components in the UI (e.g., submit button, social login).
|
|
303
|
+
*/
|
|
80
304
|
actionId?: string;
|
|
305
|
+
/**
|
|
306
|
+
* User input data collected from the form components.
|
|
307
|
+
* Keys should match the component identifiers from the response.
|
|
308
|
+
*
|
|
309
|
+
* @example
|
|
310
|
+
* ```typescript
|
|
311
|
+
* {
|
|
312
|
+
* "username": "john.doe@example.com",
|
|
313
|
+
* "password": "mySecurePassword",
|
|
314
|
+
* "rememberMe": true
|
|
315
|
+
* }
|
|
316
|
+
* ```
|
|
317
|
+
*/
|
|
81
318
|
inputs?: Record<string, any>;
|
|
82
319
|
}
|
|
83
|
-
/**
|
|
84
|
-
* Request config for executing the new Asgardeo V2 embedded sign-in flow.
|
|
85
|
-
* @experimental
|
|
86
|
-
*/
|
|
87
|
-
export interface EmbeddedFlowExecuteRequestConfigV2<T = any> extends EmbeddedFlowExecuteRequestConfig<T> {
|
|
88
|
-
authId?: string;
|
|
89
|
-
}
|