@asgardeo/javascript 0.2.17 → 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
@@ -600,12 +600,7 @@ var extractUserClaimsFromIdToken = (payload) => {
600
600
  protocolClaims.forEach((claim) => {
601
601
  delete filteredPayload[claim];
602
602
  });
603
- const userClaims = {};
604
- Object.entries(filteredPayload).forEach(([key, value]) => {
605
- const camelCasedKey = key.split("_").map((part, i) => i === 0 ? part : part[0].toUpperCase() + part.slice(1)).join("");
606
- userClaims[camelCasedKey] = value;
607
- });
608
- return userClaims;
603
+ return filteredPayload;
609
604
  };
610
605
  var extractUserClaimsFromIdToken_default = extractUserClaimsFromIdToken;
611
606
 
@@ -2062,6 +2057,7 @@ var executeEmbeddedSignInFlow_default = executeEmbeddedSignInFlow;
2062
2057
  var EmbeddedFlowType = /* @__PURE__ */ ((EmbeddedFlowType2) => {
2063
2058
  EmbeddedFlowType2["Authentication"] = "AUTHENTICATION";
2064
2059
  EmbeddedFlowType2["Registration"] = "REGISTRATION";
2060
+ EmbeddedFlowType2["UserOnboarding"] = "USER_ONBOARDING";
2065
2061
  return EmbeddedFlowType2;
2066
2062
  })(EmbeddedFlowType || {});
2067
2063
  var EmbeddedFlowStatus = /* @__PURE__ */ ((EmbeddedFlowStatus2) => {
@@ -3067,6 +3063,56 @@ var executeEmbeddedSignUpFlowV2 = async ({
3067
3063
  };
3068
3064
  var executeEmbeddedSignUpFlowV2_default = executeEmbeddedSignUpFlowV2;
3069
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
+
3070
3116
  // src/constants/ApplicationNativeAuthenticationConstants.ts
3071
3117
  var ApplicationNativeAuthenticationConstants = {
3072
3118
  SupportedAuthenticators: {
@@ -4723,6 +4769,7 @@ export {
4723
4769
  executeEmbeddedSignInFlowV2_default as executeEmbeddedSignInFlowV2,
4724
4770
  executeEmbeddedSignUpFlow_default as executeEmbeddedSignUpFlow,
4725
4771
  executeEmbeddedSignUpFlowV2_default as executeEmbeddedSignUpFlowV2,
4772
+ executeEmbeddedUserOnboardingFlowV2_default as executeEmbeddedUserOnboardingFlowV2,
4726
4773
  extractPkceStorageKeyFromState_default as extractPkceStorageKeyFromState,
4727
4774
  extractUserClaimsFromIdToken_default as extractUserClaimsFromIdToken,
4728
4775
  flattenUserSchema_default as flattenUserSchema,