@asgardeo/javascript 0.3.0 → 0.4.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/index.d.ts
CHANGED
|
@@ -33,6 +33,7 @@ export { default as updateMeProfile, UpdateMeProfileConfig } from './api/updateM
|
|
|
33
33
|
export { default as getBrandingPreference, GetBrandingPreferenceConfig } from './api/getBrandingPreference';
|
|
34
34
|
export { default as executeEmbeddedSignInFlowV2 } from './api/v2/executeEmbeddedSignInFlowV2';
|
|
35
35
|
export { default as executeEmbeddedSignUpFlowV2 } from './api/v2/executeEmbeddedSignUpFlowV2';
|
|
36
|
+
export { default as executeEmbeddedUserOnboardingFlowV2, EmbeddedUserOnboardingFlowResponse, } from './api/v2/executeEmbeddedUserOnboardingFlowV2';
|
|
36
37
|
export { default as ApplicationNativeAuthenticationConstants } from './constants/ApplicationNativeAuthenticationConstants';
|
|
37
38
|
export { default as TokenConstants } from './constants/TokenConstants';
|
|
38
39
|
export { default as OIDCRequestConstants } from './constants/OIDCRequestConstants';
|
package/dist/index.js
CHANGED
|
@@ -2057,6 +2057,7 @@ var executeEmbeddedSignInFlow_default = executeEmbeddedSignInFlow;
|
|
|
2057
2057
|
var EmbeddedFlowType = /* @__PURE__ */ ((EmbeddedFlowType2) => {
|
|
2058
2058
|
EmbeddedFlowType2["Authentication"] = "AUTHENTICATION";
|
|
2059
2059
|
EmbeddedFlowType2["Registration"] = "REGISTRATION";
|
|
2060
|
+
EmbeddedFlowType2["UserOnboarding"] = "USER_ONBOARDING";
|
|
2060
2061
|
return EmbeddedFlowType2;
|
|
2061
2062
|
})(EmbeddedFlowType || {});
|
|
2062
2063
|
var EmbeddedFlowStatus = /* @__PURE__ */ ((EmbeddedFlowStatus2) => {
|
|
@@ -3062,6 +3063,56 @@ var executeEmbeddedSignUpFlowV2 = async ({
|
|
|
3062
3063
|
};
|
|
3063
3064
|
var executeEmbeddedSignUpFlowV2_default = executeEmbeddedSignUpFlowV2;
|
|
3064
3065
|
|
|
3066
|
+
// src/api/v2/executeEmbeddedUserOnboardingFlowV2.ts
|
|
3067
|
+
var executeEmbeddedUserOnboardingFlowV2 = async ({
|
|
3068
|
+
url,
|
|
3069
|
+
baseUrl,
|
|
3070
|
+
payload,
|
|
3071
|
+
...requestConfig
|
|
3072
|
+
}) => {
|
|
3073
|
+
if (!payload) {
|
|
3074
|
+
throw new AsgardeoAPIError(
|
|
3075
|
+
"User onboarding payload is required",
|
|
3076
|
+
"executeEmbeddedUserOnboardingFlow-ValidationError-002",
|
|
3077
|
+
"javascript",
|
|
3078
|
+
400,
|
|
3079
|
+
"If a user onboarding payload is not provided, the request cannot be constructed correctly."
|
|
3080
|
+
);
|
|
3081
|
+
}
|
|
3082
|
+
const endpoint = url ?? `${baseUrl}/flow/execute`;
|
|
3083
|
+
const cleanPayload = typeof payload === "object" && payload !== null ? Object.fromEntries(Object.entries(payload).filter(([key]) => key !== "verbose")) : payload;
|
|
3084
|
+
const hasOnlyFlowType = typeof cleanPayload === "object" && cleanPayload !== null && "flowType" in cleanPayload && Object.keys(cleanPayload).length === 1;
|
|
3085
|
+
const hasOnlyFlowId = typeof cleanPayload === "object" && cleanPayload !== null && "flowId" in cleanPayload && Object.keys(cleanPayload).length === 1;
|
|
3086
|
+
const hasFlowIdWithInputs = typeof cleanPayload === "object" && cleanPayload !== null && "flowId" in cleanPayload && "inputs" in cleanPayload;
|
|
3087
|
+
const requestPayload = hasOnlyFlowType || hasOnlyFlowId || hasFlowIdWithInputs ? { ...cleanPayload, verbose: true } : cleanPayload;
|
|
3088
|
+
if ("flowType" in requestPayload && requestPayload["flowType"] !== "USER_ONBOARDING" /* UserOnboarding */) {
|
|
3089
|
+
requestPayload["flowType"] = "USER_ONBOARDING" /* UserOnboarding */;
|
|
3090
|
+
}
|
|
3091
|
+
const response = await fetch(endpoint, {
|
|
3092
|
+
...requestConfig,
|
|
3093
|
+
method: requestConfig.method || "POST",
|
|
3094
|
+
headers: {
|
|
3095
|
+
"Content-Type": "application/json",
|
|
3096
|
+
Accept: "application/json",
|
|
3097
|
+
...requestConfig.headers
|
|
3098
|
+
},
|
|
3099
|
+
body: JSON.stringify(requestPayload)
|
|
3100
|
+
});
|
|
3101
|
+
if (!response.ok) {
|
|
3102
|
+
const errorText = await response.text();
|
|
3103
|
+
throw new AsgardeoAPIError(
|
|
3104
|
+
`User onboarding request failed: ${errorText}`,
|
|
3105
|
+
"executeEmbeddedUserOnboardingFlow-ResponseError-001",
|
|
3106
|
+
"javascript",
|
|
3107
|
+
response.status,
|
|
3108
|
+
response.statusText
|
|
3109
|
+
);
|
|
3110
|
+
}
|
|
3111
|
+
const flowResponse = await response.json();
|
|
3112
|
+
return flowResponse;
|
|
3113
|
+
};
|
|
3114
|
+
var executeEmbeddedUserOnboardingFlowV2_default = executeEmbeddedUserOnboardingFlowV2;
|
|
3115
|
+
|
|
3065
3116
|
// src/constants/ApplicationNativeAuthenticationConstants.ts
|
|
3066
3117
|
var ApplicationNativeAuthenticationConstants = {
|
|
3067
3118
|
SupportedAuthenticators: {
|
|
@@ -4718,6 +4769,7 @@ export {
|
|
|
4718
4769
|
executeEmbeddedSignInFlowV2_default as executeEmbeddedSignInFlowV2,
|
|
4719
4770
|
executeEmbeddedSignUpFlow_default as executeEmbeddedSignUpFlow,
|
|
4720
4771
|
executeEmbeddedSignUpFlowV2_default as executeEmbeddedSignUpFlowV2,
|
|
4772
|
+
executeEmbeddedUserOnboardingFlowV2_default as executeEmbeddedUserOnboardingFlowV2,
|
|
4721
4773
|
extractPkceStorageKeyFromState_default as extractPkceStorageKeyFromState,
|
|
4722
4774
|
extractUserClaimsFromIdToken_default as extractUserClaimsFromIdToken,
|
|
4723
4775
|
flattenUserSchema_default as flattenUserSchema,
|