@asgardeo/javascript 0.7.2 → 0.8.0
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/__legacy__/client.d.ts +1 -1
- package/dist/api/v2/getFlowMetaV2.d.ts +55 -0
- package/dist/cjs/index.js +88 -13
- package/dist/cjs/index.js.map +4 -4
- package/dist/index.d.ts +2 -0
- package/dist/index.js +86 -13
- package/dist/index.js.map +4 -4
- package/dist/models/config.d.ts +5 -0
- package/dist/models/v2/flow-meta-v2.d.ts +290 -0
- package/dist/utils/getAuthorizeRequestUrlParams.d.ts +1 -0
- package/package.json +3 -3
|
@@ -35,7 +35,7 @@ export declare class AsgardeoAuthClient<T> {
|
|
|
35
35
|
private authHelper;
|
|
36
36
|
private cryptoUtils;
|
|
37
37
|
private cryptoHelper;
|
|
38
|
-
private
|
|
38
|
+
private instanceIdValue;
|
|
39
39
|
static authHelperInstance: any;
|
|
40
40
|
/**
|
|
41
41
|
* This is the constructor method that returns an instance of the .
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
import { FlowMetadataResponse, GetFlowMetaRequestConfig } from '../../models/v2/flow-meta-v2';
|
|
19
|
+
/**
|
|
20
|
+
* Fetches aggregated flow metadata from the `GET /flow/meta` endpoint.
|
|
21
|
+
*
|
|
22
|
+
* The response includes:
|
|
23
|
+
* - Application or OU details depending on the `type` parameter
|
|
24
|
+
* - Resolved design configuration (theme and layout)
|
|
25
|
+
* - i18n translations filtered by `language` and `namespace`
|
|
26
|
+
* - Registration flow enablement status
|
|
27
|
+
*
|
|
28
|
+
* @param config - Request configuration including `baseUrl`/`url`, `type`, `id`,
|
|
29
|
+
* and optional `language` / `namespace` filters.
|
|
30
|
+
* @returns A promise that resolves to the {@link FlowMetadataResponse}.
|
|
31
|
+
*
|
|
32
|
+
* @throws {AsgardeoAPIError} When required parameters are missing or the server
|
|
33
|
+
* returns a non-OK response.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* import getFlowMetaV2 from './api/v2/getFlowMetaV2';
|
|
38
|
+
* import { FlowMetaType } from './models/v2/flow-meta-v2';
|
|
39
|
+
*
|
|
40
|
+
* const meta = await getFlowMetaV2({
|
|
41
|
+
* baseUrl: 'https://localhost:8090',
|
|
42
|
+
* type: FlowMetaType.App,
|
|
43
|
+
* id: '60a9b38b-6eba-9f9e-55f9-267067de4680',
|
|
44
|
+
* language: 'en',
|
|
45
|
+
* namespace: 'auth',
|
|
46
|
+
* });
|
|
47
|
+
*
|
|
48
|
+
* console.log(meta.application?.name);
|
|
49
|
+
* console.log(meta.i18n.translations);
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @experimental This function targets the Asgardeo V2 platform API
|
|
53
|
+
*/
|
|
54
|
+
declare const getFlowMetaV2: ({ url, baseUrl, type, id, language, namespace, ...requestConfig }: GetFlowMetaRequestConfig) => Promise<FlowMetadataResponse>;
|
|
55
|
+
export default getFlowMetaV2;
|
package/dist/cjs/index.js
CHANGED
|
@@ -48,6 +48,7 @@ __export(index_exports, {
|
|
|
48
48
|
EmbeddedSignUpFlowStatusV2: () => EmbeddedSignUpFlowStatus,
|
|
49
49
|
EmbeddedSignUpFlowTypeV2: () => EmbeddedSignUpFlowType,
|
|
50
50
|
FieldType: () => FieldType,
|
|
51
|
+
FlowMetaType: () => FlowMetaType,
|
|
51
52
|
FlowMode: () => FlowMode,
|
|
52
53
|
IsomorphicCrypto: () => IsomorphicCrypto,
|
|
53
54
|
OIDCRequestConstants: () => OIDCRequestConstants_default,
|
|
@@ -85,6 +86,7 @@ __export(index_exports, {
|
|
|
85
86
|
get: () => get_default,
|
|
86
87
|
getAllOrganizations: () => getAllOrganizations_default,
|
|
87
88
|
getBrandingPreference: () => getBrandingPreference_default,
|
|
89
|
+
getFlowMetaV2: () => getFlowMetaV2_default,
|
|
88
90
|
getLatestStateParam: () => getLatestStateParam_default,
|
|
89
91
|
getMeOrganizations: () => getMeOrganizations_default,
|
|
90
92
|
getOrganization: () => getOrganization_default,
|
|
@@ -1067,12 +1069,16 @@ var getAuthorizeRequestUrlParams = (options, pkceOptions, customParams) => {
|
|
|
1067
1069
|
}
|
|
1068
1070
|
});
|
|
1069
1071
|
}
|
|
1072
|
+
const AUTH_INSTANCE_PREFIX = "instance_";
|
|
1073
|
+
let customStateValue = "";
|
|
1074
|
+
if (options.instanceId) {
|
|
1075
|
+
customStateValue = AUTH_INSTANCE_PREFIX + options.instanceId;
|
|
1076
|
+
} else if (customParams) {
|
|
1077
|
+
customStateValue = customParams[OIDCRequestConstants_default.Params.STATE]?.toString() ?? "";
|
|
1078
|
+
}
|
|
1070
1079
|
authorizeRequestParams.set(
|
|
1071
1080
|
OIDCRequestConstants_default.Params.STATE,
|
|
1072
|
-
generateStateParamForRequestCorrelation_default(
|
|
1073
|
-
pkceKey,
|
|
1074
|
-
customParams ? customParams[OIDCRequestConstants_default.Params.STATE]?.toString() : ""
|
|
1075
|
-
)
|
|
1081
|
+
generateStateParamForRequestCorrelation_default(pkceKey, customStateValue)
|
|
1076
1082
|
);
|
|
1077
1083
|
return authorizeRequestParams;
|
|
1078
1084
|
};
|
|
@@ -1114,6 +1120,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1114
1120
|
__publicField(this, "authHelper");
|
|
1115
1121
|
__publicField(this, "cryptoUtils");
|
|
1116
1122
|
__publicField(this, "cryptoHelper");
|
|
1123
|
+
__publicField(this, "instanceIdValue");
|
|
1117
1124
|
}
|
|
1118
1125
|
/**
|
|
1119
1126
|
*
|
|
@@ -1136,18 +1143,18 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1136
1143
|
*/
|
|
1137
1144
|
async initialize(config, store, inputCryptoUtils, instanceID) {
|
|
1138
1145
|
const { clientId } = config;
|
|
1139
|
-
if (!
|
|
1140
|
-
|
|
1146
|
+
if (!this.instanceIdValue) {
|
|
1147
|
+
this.instanceIdValue = 0;
|
|
1141
1148
|
} else {
|
|
1142
|
-
|
|
1149
|
+
this.instanceIdValue += 1;
|
|
1143
1150
|
}
|
|
1144
|
-
if (instanceID) {
|
|
1145
|
-
|
|
1151
|
+
if (instanceID !== void 0) {
|
|
1152
|
+
this.instanceIdValue = instanceID;
|
|
1146
1153
|
}
|
|
1147
1154
|
if (!clientId) {
|
|
1148
|
-
this.storageManager = new StorageManager_default(`instance_${
|
|
1155
|
+
this.storageManager = new StorageManager_default(`instance_${this.instanceIdValue}`, store);
|
|
1149
1156
|
} else {
|
|
1150
|
-
this.storageManager = new StorageManager_default(`instance_${
|
|
1157
|
+
this.storageManager = new StorageManager_default(`instance_${this.instanceIdValue}-${clientId}`, store);
|
|
1151
1158
|
}
|
|
1152
1159
|
this.cryptoUtils = inputCryptoUtils;
|
|
1153
1160
|
this.cryptoHelper = new IsomorphicCrypto(inputCryptoUtils);
|
|
@@ -1192,7 +1199,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1192
1199
|
*/
|
|
1193
1200
|
// eslint-disable-next-line class-methods-use-this
|
|
1194
1201
|
getInstanceId() {
|
|
1195
|
-
return
|
|
1202
|
+
return this.instanceIdValue;
|
|
1196
1203
|
}
|
|
1197
1204
|
/**
|
|
1198
1205
|
* This is an async method that returns a Promise that resolves with the authorization URL.
|
|
@@ -1250,6 +1257,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1250
1257
|
clientId: configData.clientId,
|
|
1251
1258
|
codeChallenge,
|
|
1252
1259
|
codeChallengeMethod: PKCEConstants_default.DEFAULT_CODE_CHALLENGE_METHOD,
|
|
1260
|
+
instanceId: this.getInstanceId().toString(),
|
|
1253
1261
|
prompt: configData.prompt,
|
|
1254
1262
|
redirectUri: configData.afterSignInUrl,
|
|
1255
1263
|
responseMode: configData.responseMode,
|
|
@@ -2012,7 +2020,6 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
2012
2020
|
await this.authHelperInstance.clearSession(userId);
|
|
2013
2021
|
}
|
|
2014
2022
|
};
|
|
2015
|
-
__publicField(_AsgardeoAuthClient, "instanceIdValue");
|
|
2016
2023
|
// FIXME: Validate this.
|
|
2017
2024
|
// Ref: https://github.com/asgardeo/asgardeo-auth-js-core/pull/205
|
|
2018
2025
|
__publicField(_AsgardeoAuthClient, "authHelperInstance");
|
|
@@ -3243,6 +3250,65 @@ var executeEmbeddedUserOnboardingFlowV2 = async ({
|
|
|
3243
3250
|
};
|
|
3244
3251
|
var executeEmbeddedUserOnboardingFlowV2_default = executeEmbeddedUserOnboardingFlowV2;
|
|
3245
3252
|
|
|
3253
|
+
// src/api/v2/getFlowMetaV2.ts
|
|
3254
|
+
var getFlowMetaV2 = async ({
|
|
3255
|
+
url,
|
|
3256
|
+
baseUrl,
|
|
3257
|
+
type,
|
|
3258
|
+
id,
|
|
3259
|
+
language,
|
|
3260
|
+
namespace,
|
|
3261
|
+
...requestConfig
|
|
3262
|
+
}) => {
|
|
3263
|
+
if (!type) {
|
|
3264
|
+
throw new AsgardeoAPIError(
|
|
3265
|
+
'The "type" parameter is required',
|
|
3266
|
+
"getFlowMetaV2-ValidationError-001",
|
|
3267
|
+
"javascript",
|
|
3268
|
+
400,
|
|
3269
|
+
'The "type" query parameter must be either "APP" or "OU".'
|
|
3270
|
+
);
|
|
3271
|
+
}
|
|
3272
|
+
if (!id) {
|
|
3273
|
+
throw new AsgardeoAPIError(
|
|
3274
|
+
'The "id" parameter is required',
|
|
3275
|
+
"getFlowMetaV2-ValidationError-002",
|
|
3276
|
+
"javascript",
|
|
3277
|
+
400,
|
|
3278
|
+
'The "id" query parameter must be a valid UUID of the target application or organization unit.'
|
|
3279
|
+
);
|
|
3280
|
+
}
|
|
3281
|
+
const queryParams = new URLSearchParams({
|
|
3282
|
+
id,
|
|
3283
|
+
type,
|
|
3284
|
+
...language ? { language } : {},
|
|
3285
|
+
...namespace ? { namespace } : {}
|
|
3286
|
+
});
|
|
3287
|
+
const baseEndpoint = url ?? `${baseUrl}/flow/meta`;
|
|
3288
|
+
const endpoint = `${baseEndpoint}?${queryParams.toString()}`;
|
|
3289
|
+
const response = await fetch(endpoint, {
|
|
3290
|
+
...requestConfig,
|
|
3291
|
+
headers: {
|
|
3292
|
+
Accept: "application/json",
|
|
3293
|
+
...requestConfig.headers
|
|
3294
|
+
},
|
|
3295
|
+
method: "GET"
|
|
3296
|
+
});
|
|
3297
|
+
if (!response.ok) {
|
|
3298
|
+
const errorText = await response.text();
|
|
3299
|
+
throw new AsgardeoAPIError(
|
|
3300
|
+
`Flow metadata request failed: ${errorText}`,
|
|
3301
|
+
"getFlowMetaV2-ResponseError-001",
|
|
3302
|
+
"javascript",
|
|
3303
|
+
response.status,
|
|
3304
|
+
response.statusText
|
|
3305
|
+
);
|
|
3306
|
+
}
|
|
3307
|
+
const flowMetadata = await response.json();
|
|
3308
|
+
return flowMetadata;
|
|
3309
|
+
};
|
|
3310
|
+
var getFlowMetaV2_default = getFlowMetaV2;
|
|
3311
|
+
|
|
3246
3312
|
// src/constants/ApplicationNativeAuthenticationConstants.ts
|
|
3247
3313
|
var ApplicationNativeAuthenticationConstants = {
|
|
3248
3314
|
SupportedAuthenticators: {
|
|
@@ -3359,6 +3425,13 @@ var EmbeddedFlowEventType = /* @__PURE__ */ ((EmbeddedFlowEventType2) => {
|
|
|
3359
3425
|
return EmbeddedFlowEventType2;
|
|
3360
3426
|
})(EmbeddedFlowEventType || {});
|
|
3361
3427
|
|
|
3428
|
+
// src/models/v2/flow-meta-v2.ts
|
|
3429
|
+
var FlowMetaType = /* @__PURE__ */ ((FlowMetaType2) => {
|
|
3430
|
+
FlowMetaType2["App"] = "APP";
|
|
3431
|
+
FlowMetaType2["Ou"] = "OU";
|
|
3432
|
+
return FlowMetaType2;
|
|
3433
|
+
})(FlowMetaType || {});
|
|
3434
|
+
|
|
3362
3435
|
// src/models/flow.ts
|
|
3363
3436
|
var FlowMode = /* @__PURE__ */ ((FlowMode2) => {
|
|
3364
3437
|
FlowMode2["Embedded"] = "DIRECT";
|
|
@@ -4853,6 +4926,7 @@ var transformBrandingPreferenceToTheme_default = transformBrandingPreferenceToTh
|
|
|
4853
4926
|
EmbeddedSignUpFlowStatusV2,
|
|
4854
4927
|
EmbeddedSignUpFlowTypeV2,
|
|
4855
4928
|
FieldType,
|
|
4929
|
+
FlowMetaType,
|
|
4856
4930
|
FlowMode,
|
|
4857
4931
|
IsomorphicCrypto,
|
|
4858
4932
|
OIDCRequestConstants,
|
|
@@ -4890,6 +4964,7 @@ var transformBrandingPreferenceToTheme_default = transformBrandingPreferenceToTh
|
|
|
4890
4964
|
get,
|
|
4891
4965
|
getAllOrganizations,
|
|
4892
4966
|
getBrandingPreference,
|
|
4967
|
+
getFlowMetaV2,
|
|
4893
4968
|
getLatestStateParam,
|
|
4894
4969
|
getMeOrganizations,
|
|
4895
4970
|
getOrganization,
|