@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
package/dist/index.d.ts
CHANGED
|
@@ -34,6 +34,7 @@ export { default as getBrandingPreference, GetBrandingPreferenceConfig } from '.
|
|
|
34
34
|
export { default as executeEmbeddedSignInFlowV2 } from './api/v2/executeEmbeddedSignInFlowV2';
|
|
35
35
|
export { default as executeEmbeddedSignUpFlowV2 } from './api/v2/executeEmbeddedSignUpFlowV2';
|
|
36
36
|
export { default as executeEmbeddedUserOnboardingFlowV2, EmbeddedUserOnboardingFlowResponse, } from './api/v2/executeEmbeddedUserOnboardingFlowV2';
|
|
37
|
+
export { default as getFlowMetaV2 } from './api/v2/getFlowMetaV2';
|
|
37
38
|
export { default as ApplicationNativeAuthenticationConstants } from './constants/ApplicationNativeAuthenticationConstants';
|
|
38
39
|
export { default as TokenConstants } from './constants/TokenConstants';
|
|
39
40
|
export { default as OIDCRequestConstants } from './constants/OIDCRequestConstants';
|
|
@@ -48,6 +49,7 @@ export { EmbeddedSignInFlowInitiateResponse, EmbeddedSignInFlowStatus, EmbeddedS
|
|
|
48
49
|
export { EmbeddedFlowComponentType as EmbeddedFlowComponentTypeV2, EmbeddedFlowActionVariant as EmbeddedFlowActionVariantV2, EmbeddedFlowTextVariant as EmbeddedFlowTextVariantV2, EmbeddedFlowEventType as EmbeddedFlowEventTypeV2, EmbeddedFlowComponent as EmbeddedFlowComponentV2, EmbeddedFlowResponseData as EmbeddedFlowResponseDataV2, EmbeddedFlowExecuteRequestConfig as EmbeddedFlowExecuteRequestConfigV2, } from './models/v2/embedded-flow-v2';
|
|
49
50
|
export { EmbeddedSignInFlowStatus as EmbeddedSignInFlowStatusV2, EmbeddedSignInFlowType as EmbeddedSignInFlowTypeV2, ExtendedEmbeddedSignInFlowResponse as ExtendedEmbeddedSignInFlowResponseV2, EmbeddedSignInFlowResponse as EmbeddedSignInFlowResponseV2, EmbeddedSignInFlowCompleteResponse as EmbeddedSignInFlowCompleteResponseV2, EmbeddedSignInFlowInitiateRequest as EmbeddedSignInFlowInitiateRequestV2, EmbeddedSignInFlowRequest as EmbeddedSignInFlowRequestV2, } from './models/v2/embedded-signin-flow-v2';
|
|
50
51
|
export { EmbeddedSignUpFlowStatus as EmbeddedSignUpFlowStatusV2, EmbeddedSignUpFlowType as EmbeddedSignUpFlowTypeV2, ExtendedEmbeddedSignUpFlowResponse as ExtendedEmbeddedSignUpFlowResponseV2, EmbeddedSignUpFlowResponse as EmbeddedSignUpFlowResponseV2, EmbeddedSignUpFlowCompleteResponse as EmbeddedSignUpFlowCompleteResponseV2, EmbeddedSignUpFlowInitiateRequest as EmbeddedSignUpFlowInitiateRequestV2, EmbeddedSignUpFlowRequest as EmbeddedSignUpFlowRequestV2, EmbeddedSignUpFlowErrorResponse as EmbeddedSignUpFlowErrorResponseV2, } from './models/v2/embedded-signup-flow-v2';
|
|
52
|
+
export { FlowMetaType, ApplicationMetadata, OUMetadata, DesignMetadata, I18nMetadata, FlowMetadataResponse, GetFlowMetaRequestConfig, FlowMetaTheme, FlowMetaThemeColorSet, FlowMetaThemeBackground, FlowMetaThemeTextColors, FlowMetaThemeColors, FlowMetaThemeColorScheme, FlowMetaThemeShape, FlowMetaThemeTypography, } from './models/v2/flow-meta-v2';
|
|
51
53
|
export { EmbeddedFlowType, EmbeddedFlowStatus, EmbeddedFlowExecuteResponse, EmbeddedFlowResponseType, EmbeddedSignUpFlowData, EmbeddedFlowComponent, EmbeddedFlowComponentType, EmbeddedFlowExecuteRequestPayload, EmbeddedFlowExecuteRequestConfig, EmbeddedFlowExecuteErrorResponse, } from './models/embedded-flow';
|
|
52
54
|
export { FlowMode } from './models/flow';
|
|
53
55
|
export { AsgardeoClient } from './models/client';
|
package/dist/index.js
CHANGED
|
@@ -957,12 +957,16 @@ var getAuthorizeRequestUrlParams = (options, pkceOptions, customParams) => {
|
|
|
957
957
|
}
|
|
958
958
|
});
|
|
959
959
|
}
|
|
960
|
+
const AUTH_INSTANCE_PREFIX = "instance_";
|
|
961
|
+
let customStateValue = "";
|
|
962
|
+
if (options.instanceId) {
|
|
963
|
+
customStateValue = AUTH_INSTANCE_PREFIX + options.instanceId;
|
|
964
|
+
} else if (customParams) {
|
|
965
|
+
customStateValue = customParams[OIDCRequestConstants_default.Params.STATE]?.toString() ?? "";
|
|
966
|
+
}
|
|
960
967
|
authorizeRequestParams.set(
|
|
961
968
|
OIDCRequestConstants_default.Params.STATE,
|
|
962
|
-
generateStateParamForRequestCorrelation_default(
|
|
963
|
-
pkceKey,
|
|
964
|
-
customParams ? customParams[OIDCRequestConstants_default.Params.STATE]?.toString() : ""
|
|
965
|
-
)
|
|
969
|
+
generateStateParamForRequestCorrelation_default(pkceKey, customStateValue)
|
|
966
970
|
);
|
|
967
971
|
return authorizeRequestParams;
|
|
968
972
|
};
|
|
@@ -1004,6 +1008,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1004
1008
|
__publicField(this, "authHelper");
|
|
1005
1009
|
__publicField(this, "cryptoUtils");
|
|
1006
1010
|
__publicField(this, "cryptoHelper");
|
|
1011
|
+
__publicField(this, "instanceIdValue");
|
|
1007
1012
|
}
|
|
1008
1013
|
/**
|
|
1009
1014
|
*
|
|
@@ -1026,18 +1031,18 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1026
1031
|
*/
|
|
1027
1032
|
async initialize(config, store, inputCryptoUtils, instanceID) {
|
|
1028
1033
|
const { clientId } = config;
|
|
1029
|
-
if (!
|
|
1030
|
-
|
|
1034
|
+
if (!this.instanceIdValue) {
|
|
1035
|
+
this.instanceIdValue = 0;
|
|
1031
1036
|
} else {
|
|
1032
|
-
|
|
1037
|
+
this.instanceIdValue += 1;
|
|
1033
1038
|
}
|
|
1034
|
-
if (instanceID) {
|
|
1035
|
-
|
|
1039
|
+
if (instanceID !== void 0) {
|
|
1040
|
+
this.instanceIdValue = instanceID;
|
|
1036
1041
|
}
|
|
1037
1042
|
if (!clientId) {
|
|
1038
|
-
this.storageManager = new StorageManager_default(`instance_${
|
|
1043
|
+
this.storageManager = new StorageManager_default(`instance_${this.instanceIdValue}`, store);
|
|
1039
1044
|
} else {
|
|
1040
|
-
this.storageManager = new StorageManager_default(`instance_${
|
|
1045
|
+
this.storageManager = new StorageManager_default(`instance_${this.instanceIdValue}-${clientId}`, store);
|
|
1041
1046
|
}
|
|
1042
1047
|
this.cryptoUtils = inputCryptoUtils;
|
|
1043
1048
|
this.cryptoHelper = new IsomorphicCrypto(inputCryptoUtils);
|
|
@@ -1082,7 +1087,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1082
1087
|
*/
|
|
1083
1088
|
// eslint-disable-next-line class-methods-use-this
|
|
1084
1089
|
getInstanceId() {
|
|
1085
|
-
return
|
|
1090
|
+
return this.instanceIdValue;
|
|
1086
1091
|
}
|
|
1087
1092
|
/**
|
|
1088
1093
|
* This is an async method that returns a Promise that resolves with the authorization URL.
|
|
@@ -1140,6 +1145,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1140
1145
|
clientId: configData.clientId,
|
|
1141
1146
|
codeChallenge,
|
|
1142
1147
|
codeChallengeMethod: PKCEConstants_default.DEFAULT_CODE_CHALLENGE_METHOD,
|
|
1148
|
+
instanceId: this.getInstanceId().toString(),
|
|
1143
1149
|
prompt: configData.prompt,
|
|
1144
1150
|
redirectUri: configData.afterSignInUrl,
|
|
1145
1151
|
responseMode: configData.responseMode,
|
|
@@ -1902,7 +1908,6 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1902
1908
|
await this.authHelperInstance.clearSession(userId);
|
|
1903
1909
|
}
|
|
1904
1910
|
};
|
|
1905
|
-
__publicField(_AsgardeoAuthClient, "instanceIdValue");
|
|
1906
1911
|
// FIXME: Validate this.
|
|
1907
1912
|
// Ref: https://github.com/asgardeo/asgardeo-auth-js-core/pull/205
|
|
1908
1913
|
__publicField(_AsgardeoAuthClient, "authHelperInstance");
|
|
@@ -3133,6 +3138,65 @@ var executeEmbeddedUserOnboardingFlowV2 = async ({
|
|
|
3133
3138
|
};
|
|
3134
3139
|
var executeEmbeddedUserOnboardingFlowV2_default = executeEmbeddedUserOnboardingFlowV2;
|
|
3135
3140
|
|
|
3141
|
+
// src/api/v2/getFlowMetaV2.ts
|
|
3142
|
+
var getFlowMetaV2 = async ({
|
|
3143
|
+
url,
|
|
3144
|
+
baseUrl,
|
|
3145
|
+
type,
|
|
3146
|
+
id,
|
|
3147
|
+
language,
|
|
3148
|
+
namespace,
|
|
3149
|
+
...requestConfig
|
|
3150
|
+
}) => {
|
|
3151
|
+
if (!type) {
|
|
3152
|
+
throw new AsgardeoAPIError(
|
|
3153
|
+
'The "type" parameter is required',
|
|
3154
|
+
"getFlowMetaV2-ValidationError-001",
|
|
3155
|
+
"javascript",
|
|
3156
|
+
400,
|
|
3157
|
+
'The "type" query parameter must be either "APP" or "OU".'
|
|
3158
|
+
);
|
|
3159
|
+
}
|
|
3160
|
+
if (!id) {
|
|
3161
|
+
throw new AsgardeoAPIError(
|
|
3162
|
+
'The "id" parameter is required',
|
|
3163
|
+
"getFlowMetaV2-ValidationError-002",
|
|
3164
|
+
"javascript",
|
|
3165
|
+
400,
|
|
3166
|
+
'The "id" query parameter must be a valid UUID of the target application or organization unit.'
|
|
3167
|
+
);
|
|
3168
|
+
}
|
|
3169
|
+
const queryParams = new URLSearchParams({
|
|
3170
|
+
id,
|
|
3171
|
+
type,
|
|
3172
|
+
...language ? { language } : {},
|
|
3173
|
+
...namespace ? { namespace } : {}
|
|
3174
|
+
});
|
|
3175
|
+
const baseEndpoint = url ?? `${baseUrl}/flow/meta`;
|
|
3176
|
+
const endpoint = `${baseEndpoint}?${queryParams.toString()}`;
|
|
3177
|
+
const response = await fetch(endpoint, {
|
|
3178
|
+
...requestConfig,
|
|
3179
|
+
headers: {
|
|
3180
|
+
Accept: "application/json",
|
|
3181
|
+
...requestConfig.headers
|
|
3182
|
+
},
|
|
3183
|
+
method: "GET"
|
|
3184
|
+
});
|
|
3185
|
+
if (!response.ok) {
|
|
3186
|
+
const errorText = await response.text();
|
|
3187
|
+
throw new AsgardeoAPIError(
|
|
3188
|
+
`Flow metadata request failed: ${errorText}`,
|
|
3189
|
+
"getFlowMetaV2-ResponseError-001",
|
|
3190
|
+
"javascript",
|
|
3191
|
+
response.status,
|
|
3192
|
+
response.statusText
|
|
3193
|
+
);
|
|
3194
|
+
}
|
|
3195
|
+
const flowMetadata = await response.json();
|
|
3196
|
+
return flowMetadata;
|
|
3197
|
+
};
|
|
3198
|
+
var getFlowMetaV2_default = getFlowMetaV2;
|
|
3199
|
+
|
|
3136
3200
|
// src/constants/ApplicationNativeAuthenticationConstants.ts
|
|
3137
3201
|
var ApplicationNativeAuthenticationConstants = {
|
|
3138
3202
|
SupportedAuthenticators: {
|
|
@@ -3249,6 +3313,13 @@ var EmbeddedFlowEventType = /* @__PURE__ */ ((EmbeddedFlowEventType2) => {
|
|
|
3249
3313
|
return EmbeddedFlowEventType2;
|
|
3250
3314
|
})(EmbeddedFlowEventType || {});
|
|
3251
3315
|
|
|
3316
|
+
// src/models/v2/flow-meta-v2.ts
|
|
3317
|
+
var FlowMetaType = /* @__PURE__ */ ((FlowMetaType2) => {
|
|
3318
|
+
FlowMetaType2["App"] = "APP";
|
|
3319
|
+
FlowMetaType2["Ou"] = "OU";
|
|
3320
|
+
return FlowMetaType2;
|
|
3321
|
+
})(FlowMetaType || {});
|
|
3322
|
+
|
|
3252
3323
|
// src/models/flow.ts
|
|
3253
3324
|
var FlowMode = /* @__PURE__ */ ((FlowMode2) => {
|
|
3254
3325
|
FlowMode2["Embedded"] = "DIRECT";
|
|
@@ -4742,6 +4813,7 @@ export {
|
|
|
4742
4813
|
EmbeddedSignUpFlowStatus as EmbeddedSignUpFlowStatusV2,
|
|
4743
4814
|
EmbeddedSignUpFlowType as EmbeddedSignUpFlowTypeV2,
|
|
4744
4815
|
FieldType,
|
|
4816
|
+
FlowMetaType,
|
|
4745
4817
|
FlowMode,
|
|
4746
4818
|
IsomorphicCrypto,
|
|
4747
4819
|
OIDCRequestConstants_default as OIDCRequestConstants,
|
|
@@ -4779,6 +4851,7 @@ export {
|
|
|
4779
4851
|
get_default as get,
|
|
4780
4852
|
getAllOrganizations_default as getAllOrganizations,
|
|
4781
4853
|
getBrandingPreference_default as getBrandingPreference,
|
|
4854
|
+
getFlowMetaV2_default as getFlowMetaV2,
|
|
4782
4855
|
getLatestStateParam_default as getLatestStateParam,
|
|
4783
4856
|
getMeOrganizations_default as getMeOrganizations,
|
|
4784
4857
|
getOrganization_default as getOrganization,
|