Skip to content

Commit 103b83d

Browse files
authored
Merge pull request asgardeo#371 from brionmario/refactor-thunder-flows
Integrate Design APIs of Thunder
2 parents 2d6ad37 + 90b5d89 commit 103b83d

32 files changed

Lines changed: 1647 additions & 374 deletions

.changeset/tidy-hoops-cover.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@asgardeo/javascript': minor
3+
'@asgardeo/react': minor
4+
---
5+
6+
Integrate Design APIs of Thunder

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
],
2121
"scripts": {
2222
"build": "nx run-many --target=build --all",
23+
"build:packages": "nx run-many --target=build --projects=packages/*",
24+
"build:samples": "nx run-many --target=build --projects=samples/*",
2325
"fix:lint": "nx run-many --target=fix:lint --all --parallel",
2426
"lint": "nx run-many --target=lint --all --parallel",
2527
"publish:packages": "changeset publish",
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
/**
2+
* Copyright (c) 2026, 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+
import AsgardeoAPIError from '../../errors/AsgardeoAPIError';
20+
import {FlowMetadataResponse, GetFlowMetaRequestConfig} from '../../models/v2/flow-meta-v2';
21+
22+
/**
23+
* Fetches aggregated flow metadata from the `GET /flow/meta` endpoint.
24+
*
25+
* The response includes:
26+
* - Application or OU details depending on the `type` parameter
27+
* - Resolved design configuration (theme and layout)
28+
* - i18n translations filtered by `language` and `namespace`
29+
* - Registration flow enablement status
30+
*
31+
* @param config - Request configuration including `baseUrl`/`url`, `type`, `id`,
32+
* and optional `language` / `namespace` filters.
33+
* @returns A promise that resolves to the {@link FlowMetadataResponse}.
34+
*
35+
* @throws {AsgardeoAPIError} When required parameters are missing or the server
36+
* returns a non-OK response.
37+
*
38+
* @example
39+
* ```typescript
40+
* import getFlowMetaV2 from './api/v2/getFlowMetaV2';
41+
* import { FlowMetaType } from './models/v2/flow-meta-v2';
42+
*
43+
* const meta = await getFlowMetaV2({
44+
* baseUrl: 'https://localhost:8090',
45+
* type: FlowMetaType.App,
46+
* id: '60a9b38b-6eba-9f9e-55f9-267067de4680',
47+
* language: 'en',
48+
* namespace: 'auth',
49+
* });
50+
*
51+
* console.log(meta.application?.name);
52+
* console.log(meta.i18n.translations);
53+
* ```
54+
*
55+
* @experimental This function targets the Asgardeo V2 platform API
56+
*/
57+
const getFlowMetaV2 = async ({
58+
url,
59+
baseUrl,
60+
type,
61+
id,
62+
language,
63+
namespace,
64+
...requestConfig
65+
}: GetFlowMetaRequestConfig): Promise<FlowMetadataResponse> => {
66+
if (!type) {
67+
throw new AsgardeoAPIError(
68+
'The "type" parameter is required',
69+
'getFlowMetaV2-ValidationError-001',
70+
'javascript',
71+
400,
72+
'The "type" query parameter must be either "APP" or "OU".',
73+
);
74+
}
75+
76+
if (!id) {
77+
throw new AsgardeoAPIError(
78+
'The "id" parameter is required',
79+
'getFlowMetaV2-ValidationError-002',
80+
'javascript',
81+
400,
82+
'The "id" query parameter must be a valid UUID of the target application or organization unit.',
83+
);
84+
}
85+
86+
const queryParams: URLSearchParams = new URLSearchParams({
87+
id,
88+
type,
89+
...(language ? {language} : {}),
90+
...(namespace ? {namespace} : {}),
91+
});
92+
93+
const baseEndpoint: string = url ?? `${baseUrl}/flow/meta`;
94+
const endpoint: string = `${baseEndpoint}?${queryParams.toString()}`;
95+
96+
const response: Response = await fetch(endpoint, {
97+
...requestConfig,
98+
headers: {
99+
Accept: 'application/json',
100+
...requestConfig.headers,
101+
},
102+
method: 'GET',
103+
});
104+
105+
if (!response.ok) {
106+
const errorText: string = await response.text();
107+
108+
throw new AsgardeoAPIError(
109+
`Flow metadata request failed: ${errorText}`,
110+
'getFlowMetaV2-ResponseError-001',
111+
'javascript',
112+
response.status,
113+
response.statusText,
114+
);
115+
}
116+
117+
const flowMetadata: FlowMetadataResponse = await response.json();
118+
119+
return flowMetadata;
120+
};
121+
122+
export default getFlowMetaV2;

packages/javascript/src/index.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export {
5151
default as executeEmbeddedUserOnboardingFlowV2,
5252
EmbeddedUserOnboardingFlowResponse,
5353
} from './api/v2/executeEmbeddedUserOnboardingFlowV2';
54+
export {default as getFlowMetaV2} from './api/v2/getFlowMetaV2';
5455

5556
export {default as ApplicationNativeAuthenticationConstants} from './constants/ApplicationNativeAuthenticationConstants';
5657
export {default as TokenConstants} from './constants/TokenConstants';
@@ -105,6 +106,23 @@ export {
105106
EmbeddedSignUpFlowRequest as EmbeddedSignUpFlowRequestV2,
106107
EmbeddedSignUpFlowErrorResponse as EmbeddedSignUpFlowErrorResponseV2,
107108
} from './models/v2/embedded-signup-flow-v2';
109+
export {
110+
FlowMetaType,
111+
ApplicationMetadata,
112+
OUMetadata,
113+
DesignMetadata,
114+
I18nMetadata,
115+
FlowMetadataResponse,
116+
GetFlowMetaRequestConfig,
117+
FlowMetaTheme,
118+
FlowMetaThemeColorSet,
119+
FlowMetaThemeBackground,
120+
FlowMetaThemeTextColors,
121+
FlowMetaThemeColors,
122+
FlowMetaThemeColorScheme,
123+
FlowMetaThemeShape,
124+
FlowMetaThemeTypography,
125+
} from './models/v2/flow-meta-v2';
108126
export {
109127
EmbeddedFlowType,
110128
EmbeddedFlowStatus,

packages/javascript/src/models/config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,11 @@ export interface Preferences {
289289
* Internationalization preferences for the Asgardeo UI components
290290
*/
291291
i18n?: I18nPreferences;
292+
/**
293+
* Whether to resolve the theme from the Flow Meta API (GET /flow/meta).
294+
* @remarks This is only applicable when using platform `Asgardeo V2` (Thunder).
295+
*/
296+
resolveFromMeta?: boolean;
292297
/**
293298
* Theme preferences for the Asgardeo UI components
294299
*/

0 commit comments

Comments
 (0)