@asgardeo/javascript 0.1.8 → 0.1.10

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/cjs/index.js CHANGED
@@ -46,6 +46,7 @@ __export(index_exports, {
46
46
  TokenConstants: () => TokenConstants_default,
47
47
  VendorConstants: () => VendorConstants_default,
48
48
  WellKnownSchemaIds: () => WellKnownSchemaIds,
49
+ bem: () => bem_default,
49
50
  configureLogger: () => configure,
50
51
  createComponentLogger: () => createComponentLogger,
51
52
  createLogger: () => createLogger,
@@ -63,6 +64,7 @@ __export(index_exports, {
63
64
  extractPkceStorageKeyFromState: () => extractPkceStorageKeyFromState_default,
64
65
  extractUserClaimsFromIdToken: () => extractUserClaimsFromIdToken_default,
65
66
  flattenUserSchema: () => flattenUserSchema_default,
67
+ formatDate: () => formatDate_default,
66
68
  generateFlattenedUserProfile: () => generateFlattenedUserProfile_default,
67
69
  generateUserProfile: () => generateUserProfile_default,
68
70
  get: () => get_default,
@@ -702,14 +704,7 @@ var extractUserClaimsFromIdToken_default = extractUserClaimsFromIdToken;
702
704
  var AsgardeoError = class _AsgardeoError extends Error {
703
705
  constructor(message, code, origin) {
704
706
  const _origin = _AsgardeoError.resolveOrigin(origin);
705
- const prefix = `\u{1F6E1}\uFE0F Asgardeo - ${_origin}:`;
706
- const regex = new RegExp(`\u{1F6E1}\uFE0F\\s*Asgardeo\\s*-\\s*${_origin}:`, "i");
707
- const sanitized = message.replace(regex, "");
708
- const _message = `${prefix} ${sanitized.trim()}
709
-
710
- (code="${code}")
711
- `;
712
- super(_message);
707
+ super(message);
713
708
  __publicField(this, "code");
714
709
  __publicField(this, "origin");
715
710
  this.name = new.target.name;
@@ -726,8 +721,10 @@ var AsgardeoError = class _AsgardeoError extends Error {
726
721
  return `@asgardeo/${origin}`;
727
722
  }
728
723
  toString() {
724
+ const prefix = `\u{1F6E1}\uFE0F Asgardeo - ${this.origin}:`;
729
725
  return `[${this.name}]
730
- Message: ${this.message}`;
726
+ ${prefix} ${this.message}
727
+ (code="${this.code}")`;
731
728
  }
732
729
  };
733
730
 
@@ -2796,10 +2793,10 @@ var updateMeProfile = async ({
2796
2793
  throw error2;
2797
2794
  }
2798
2795
  throw new AsgardeoAPIError(
2799
- `Network or parsing error: ${error2 instanceof Error ? error2.message : "Unknown error"}`,
2796
+ error2?.response?.data?.detail || "An error occurred while updating the user profile. Please try again.",
2800
2797
  "updateMeProfile-NetworkError-001",
2801
2798
  "javascript",
2802
- 0,
2799
+ error2?.data?.status,
2803
2800
  "Network Error"
2804
2801
  );
2805
2802
  }
@@ -2995,34 +2992,47 @@ var lightTheme = {
2995
2992
  },
2996
2993
  primary: {
2997
2994
  main: "#1a73e8",
2998
- contrastText: "#ffffff"
2995
+ contrastText: "#ffffff",
2996
+ dark: "#174ea6"
2999
2997
  },
3000
2998
  secondary: {
3001
2999
  main: "#424242",
3002
- contrastText: "#ffffff"
3000
+ contrastText: "#ffffff",
3001
+ dark: "#212121"
3003
3002
  },
3004
3003
  background: {
3005
3004
  surface: "#ffffff",
3006
3005
  disabled: "#f0f0f0",
3006
+ dark: "#212121",
3007
3007
  body: {
3008
- main: "#1a1a1a"
3008
+ main: "#1a1a1a",
3009
+ dark: "#212121"
3009
3010
  }
3010
3011
  },
3011
3012
  error: {
3012
3013
  main: "#d32f2f",
3013
- contrastText: "#ffffff"
3014
+ contrastText: "#d52828",
3015
+ dark: "#b71c1c"
3016
+ },
3017
+ info: {
3018
+ main: "#bbebff",
3019
+ contrastText: "#43aeda",
3020
+ dark: "#01579b"
3014
3021
  },
3015
3022
  success: {
3016
3023
  main: "#4caf50",
3017
- contrastText: "#ffffff"
3024
+ contrastText: "#00a807",
3025
+ dark: "#388e3c"
3018
3026
  },
3019
3027
  warning: {
3020
3028
  main: "#ff9800",
3021
- contrastText: "#ffffff"
3029
+ contrastText: "#be7100",
3030
+ dark: "#f57c00"
3022
3031
  },
3023
3032
  text: {
3024
3033
  primary: "#1a1a1a",
3025
- secondary: "#666666"
3034
+ secondary: "#666666",
3035
+ dark: "#212121"
3026
3036
  },
3027
3037
  border: "#e0e0e0"
3028
3038
  },
@@ -3091,34 +3101,47 @@ var darkTheme = {
3091
3101
  },
3092
3102
  primary: {
3093
3103
  main: "#1a73e8",
3094
- contrastText: "#ffffff"
3104
+ contrastText: "#ffffff",
3105
+ dark: "#174ea6"
3095
3106
  },
3096
3107
  secondary: {
3097
3108
  main: "#424242",
3098
- contrastText: "#ffffff"
3109
+ contrastText: "#ffffff",
3110
+ dark: "#212121"
3099
3111
  },
3100
3112
  background: {
3101
3113
  surface: "#121212",
3102
3114
  disabled: "#1f1f1f",
3115
+ dark: "#212121",
3103
3116
  body: {
3104
- main: "#ffffff"
3117
+ main: "#ffffff",
3118
+ dark: "#212121"
3105
3119
  }
3106
3120
  },
3107
3121
  error: {
3108
3122
  main: "#d32f2f",
3109
- contrastText: "#ffffff"
3123
+ contrastText: "#d52828",
3124
+ dark: "#b71c1c"
3125
+ },
3126
+ info: {
3127
+ main: "#bbebff",
3128
+ contrastText: "#43aeda",
3129
+ dark: "#01579b"
3110
3130
  },
3111
3131
  success: {
3112
3132
  main: "#4caf50",
3113
- contrastText: "#ffffff"
3133
+ contrastText: "#00a807",
3134
+ dark: "#388e3c"
3114
3135
  },
3115
3136
  warning: {
3116
3137
  main: "#ff9800",
3117
- contrastText: "#ffffff"
3138
+ contrastText: "#be7100",
3139
+ dark: "#f57c00"
3118
3140
  },
3119
3141
  text: {
3120
3142
  primary: "#ffffff",
3121
- secondary: "#b3b3b3"
3143
+ secondary: "#b3b3b3",
3144
+ dark: "#212121"
3122
3145
  },
3123
3146
  border: "#404040"
3124
3147
  },
@@ -3245,6 +3268,12 @@ var toCssVariables = (theme) => {
3245
3268
  if (theme.colors?.warning?.contrastText) {
3246
3269
  cssVars[`--${prefix}-color-warning-contrastText`] = theme.colors.warning.contrastText;
3247
3270
  }
3271
+ if (theme.colors?.info?.main) {
3272
+ cssVars[`--${prefix}-color-info-main`] = theme.colors.info.main;
3273
+ }
3274
+ if (theme.colors?.info?.contrastText) {
3275
+ cssVars[`--${prefix}-color-info-contrastText`] = theme.colors.info.contrastText;
3276
+ }
3248
3277
  if (theme.colors?.text?.primary) {
3249
3278
  cssVars[`--${prefix}-color-text-primary`] = theme.colors.text.primary;
3250
3279
  }
@@ -3334,10 +3363,31 @@ var toCssVariables = (theme) => {
3334
3363
  }
3335
3364
  });
3336
3365
  }
3366
+ if (theme.components?.Button?.styleOverrides?.root?.borderRadius) {
3367
+ cssVars[`--${prefix}-component-button-root-borderRadius`] = theme.components.Button.styleOverrides.root.borderRadius;
3368
+ }
3369
+ if (theme.components?.Field?.styleOverrides?.root?.borderRadius) {
3370
+ cssVars[`--${prefix}-component-field-root-borderRadius`] = theme.components.Field.styleOverrides.root.borderRadius;
3371
+ }
3337
3372
  return cssVars;
3338
3373
  };
3339
3374
  var toThemeVars = (theme) => {
3340
3375
  const prefix = theme.cssVarPrefix || VendorConstants_default.VENDOR_PREFIX;
3376
+ const componentVars = {};
3377
+ if (theme.components?.Button?.styleOverrides?.root?.borderRadius) {
3378
+ componentVars.Button = {
3379
+ root: {
3380
+ borderRadius: `var(--${prefix}-component-button-root-borderRadius)`
3381
+ }
3382
+ };
3383
+ }
3384
+ if (theme.components?.Field?.styleOverrides?.root?.borderRadius) {
3385
+ componentVars.Field = {
3386
+ root: {
3387
+ borderRadius: `var(--${prefix}-component-field-root-borderRadius)`
3388
+ }
3389
+ };
3390
+ }
3341
3391
  const themeVars = {
3342
3392
  colors: {
3343
3393
  action: {
@@ -3372,6 +3422,10 @@ var toThemeVars = (theme) => {
3372
3422
  main: `var(--${prefix}-color-error-main)`,
3373
3423
  contrastText: `var(--${prefix}-color-error-contrastText)`
3374
3424
  },
3425
+ info: {
3426
+ contrastText: `var(--${prefix}-color-info-contrastText)`,
3427
+ main: `var(--${prefix}-color-info-main)`
3428
+ },
3375
3429
  success: {
3376
3430
  main: `var(--${prefix}-color-success-main)`,
3377
3431
  contrastText: `var(--${prefix}-color-success-contrastText)`
@@ -3434,6 +3488,9 @@ var toThemeVars = (theme) => {
3434
3488
  };
3435
3489
  });
3436
3490
  }
3491
+ if (Object.keys(componentVars).length > 0) {
3492
+ themeVars.components = componentVars;
3493
+ }
3437
3494
  return themeVars;
3438
3495
  };
3439
3496
  var createTheme = (config = {}, isDark = false) => {
@@ -3494,6 +3551,34 @@ var createTheme = (config = {}, isDark = false) => {
3494
3551
  };
3495
3552
  var createTheme_default = createTheme;
3496
3553
 
3554
+ // src/utils/bem.ts
3555
+ var bem = (baseClass, element, modifier) => {
3556
+ let className = baseClass;
3557
+ if (element) {
3558
+ className += `__${element}`;
3559
+ }
3560
+ if (modifier) {
3561
+ className += `--${modifier}`;
3562
+ }
3563
+ return className;
3564
+ };
3565
+ var bem_default = bem;
3566
+
3567
+ // src/utils/formatDate.ts
3568
+ var formatDate = (dateString) => {
3569
+ if (!dateString) return "-";
3570
+ try {
3571
+ return new Date(dateString).toLocaleDateString("en-US", {
3572
+ year: "numeric",
3573
+ month: "long",
3574
+ day: "numeric"
3575
+ });
3576
+ } catch {
3577
+ return dateString;
3578
+ }
3579
+ };
3580
+ var formatDate_default = formatDate;
3581
+
3497
3582
  // src/utils/deepMerge.ts
3498
3583
  var isPlainObject = (value) => {
3499
3584
  return typeof value === "object" && value !== null && !Array.isArray(value) && !(value instanceof Date) && !(value instanceof RegExp) && Object.prototype.toString.call(value) === "[object Object]";
@@ -3802,6 +3887,11 @@ var translations = {
3802
3887
  "username.password.title": "Sign In",
3803
3888
  "username.password.subtitle": "Enter your username and password to continue.",
3804
3889
  /* |---------------------------------------------------------------| */
3890
+ /* | User Profile | */
3891
+ /* |---------------------------------------------------------------| */
3892
+ "user.profile.title": "Profile",
3893
+ "user.profile.update.generic.error": "An error occurred while updating your profile. Please try again.",
3894
+ /* |---------------------------------------------------------------| */
3805
3895
  /* | Organization Switcher | */
3806
3896
  /* |---------------------------------------------------------------| */
3807
3897
  "organization.switcher.select.organization": "Select Organization",
@@ -3910,7 +4000,10 @@ var withVendorCSSClassPrefix = (className) => `${VendorConstants_default.VENDOR_
3910
4000
  var withVendorCSSClassPrefix_default = withVendorCSSClassPrefix;
3911
4001
 
3912
4002
  // src/utils/transformBrandingPreferenceToTheme.ts
3913
- var extractColorValue = (colorVariant) => {
4003
+ var extractColorValue = (colorVariant, preferDark = false) => {
4004
+ if (preferDark && colorVariant?.dark && colorVariant.dark.trim()) {
4005
+ return colorVariant.dark;
4006
+ }
3914
4007
  return colorVariant?.main;
3915
4008
  };
3916
4009
  var extractContrastText = (colorVariant) => {
@@ -3921,7 +4014,7 @@ var transformThemeVariant = (themeVariant, isDark = false) => {
3921
4014
  const buttons = themeVariant.buttons;
3922
4015
  const inputs = themeVariant.inputs;
3923
4016
  const images = themeVariant.images;
3924
- return {
4017
+ const config = {
3925
4018
  colors: {
3926
4019
  action: {
3927
4020
  active: isDark ? "rgba(255, 255, 255, 0.70)" : "rgba(0, 0, 0, 0.54)",
@@ -3937,45 +4030,51 @@ var transformThemeVariant = (themeVariant, isDark = false) => {
3937
4030
  activatedOpacity: 0.12
3938
4031
  },
3939
4032
  primary: {
3940
- main: extractColorValue(colors?.primary),
3941
- contrastText: extractContrastText(colors?.primary)
4033
+ main: extractColorValue(colors?.primary, isDark),
4034
+ contrastText: extractContrastText(colors?.primary),
4035
+ dark: colors?.primary?.dark || colors?.primary?.main
3942
4036
  },
3943
4037
  secondary: {
3944
- main: extractColorValue(colors?.secondary),
3945
- contrastText: extractContrastText(colors?.secondary)
4038
+ main: extractColorValue(colors?.secondary, isDark),
4039
+ contrastText: extractContrastText(colors?.secondary),
4040
+ dark: colors?.secondary?.dark || colors?.secondary?.main
3946
4041
  },
3947
4042
  background: {
3948
- surface: extractColorValue(colors?.background?.surface),
3949
- disabled: extractColorValue(colors?.background?.surface),
4043
+ surface: extractColorValue(colors?.background?.surface, isDark),
4044
+ disabled: extractColorValue(colors?.background?.surface, isDark),
4045
+ dark: colors?.background?.surface?.dark || colors?.background?.surface?.main,
3950
4046
  body: {
3951
- main: extractColorValue(colors?.background?.body)
4047
+ main: extractColorValue(colors?.background?.body, isDark),
4048
+ dark: colors?.background?.body?.dark || colors?.background?.body?.main
3952
4049
  }
3953
4050
  },
3954
4051
  text: {
3955
4052
  primary: colors?.text?.primary,
3956
- secondary: colors?.text?.secondary
4053
+ secondary: colors?.text?.secondary,
4054
+ dark: colors?.text?.dark || colors?.text?.primary
3957
4055
  },
3958
4056
  border: colors?.outlined?.default,
3959
4057
  error: {
3960
- main: extractColorValue(colors?.alerts?.error),
3961
- contrastText: extractContrastText(colors?.alerts?.error)
4058
+ main: extractColorValue(colors?.alerts?.error, isDark),
4059
+ contrastText: extractContrastText(colors?.alerts?.error),
4060
+ dark: colors?.alerts?.error?.dark || colors?.alerts?.error?.main
4061
+ },
4062
+ info: {
4063
+ main: extractColorValue(colors?.alerts?.info, isDark),
4064
+ contrastText: extractContrastText(colors?.alerts?.info),
4065
+ dark: colors?.alerts?.info?.dark || colors?.alerts?.info?.main
3962
4066
  },
3963
4067
  success: {
3964
- main: extractColorValue(colors?.alerts?.info),
3965
- contrastText: extractContrastText(colors?.alerts?.info)
4068
+ main: extractColorValue(colors?.alerts?.neutral, isDark),
4069
+ contrastText: extractContrastText(colors?.alerts?.neutral),
4070
+ dark: colors?.alerts?.neutral?.dark || colors?.alerts?.neutral?.main
3966
4071
  },
3967
4072
  warning: {
3968
- main: extractColorValue(colors?.alerts?.warning),
3969
- contrastText: extractContrastText(colors?.alerts?.warning)
4073
+ main: extractColorValue(colors?.alerts?.warning, isDark),
4074
+ contrastText: extractContrastText(colors?.alerts?.warning),
4075
+ dark: colors?.alerts?.warning?.dark || colors?.alerts?.warning?.main
3970
4076
  }
3971
4077
  },
3972
- // Extract border radius from buttons or inputs
3973
- borderRadius: {
3974
- small: buttons?.primary?.base?.border?.borderRadius || inputs?.base?.border?.borderRadius,
3975
- medium: buttons?.secondary?.base?.border?.borderRadius,
3976
- large: buttons?.externalConnection?.base?.border?.borderRadius
3977
- },
3978
- // Extract and transform images
3979
4078
  images: {
3980
4079
  favicon: images?.favicon ? {
3981
4080
  url: images.favicon.imgURL,
@@ -3989,6 +4088,31 @@ var transformThemeVariant = (themeVariant, isDark = false) => {
3989
4088
  } : void 0
3990
4089
  }
3991
4090
  };
4091
+ const buttonBorderRadius = buttons?.primary?.base?.border?.borderRadius;
4092
+ const fieldBorderRadius = inputs?.base?.border?.borderRadius;
4093
+ if (buttonBorderRadius || fieldBorderRadius) {
4094
+ config.components = {
4095
+ ...buttonBorderRadius && {
4096
+ Button: {
4097
+ styleOverrides: {
4098
+ root: {
4099
+ borderRadius: buttonBorderRadius
4100
+ }
4101
+ }
4102
+ }
4103
+ },
4104
+ ...fieldBorderRadius && {
4105
+ Field: {
4106
+ styleOverrides: {
4107
+ root: {
4108
+ borderRadius: fieldBorderRadius
4109
+ }
4110
+ }
4111
+ }
4112
+ }
4113
+ };
4114
+ }
4115
+ return config;
3992
4116
  };
3993
4117
  var transformBrandingPreferenceToTheme = (brandingPreference, forceTheme) => {
3994
4118
  const themeConfig = brandingPreference?.preference?.theme;
@@ -4325,6 +4449,7 @@ var createPackageComponentLogger = (packageName, component) => {
4325
4449
  TokenConstants,
4326
4450
  VendorConstants,
4327
4451
  WellKnownSchemaIds,
4452
+ bem,
4328
4453
  configureLogger,
4329
4454
  createComponentLogger,
4330
4455
  createLogger,
@@ -4342,6 +4467,7 @@ var createPackageComponentLogger = (packageName, component) => {
4342
4467
  extractPkceStorageKeyFromState,
4343
4468
  extractUserClaimsFromIdToken,
4344
4469
  flattenUserSchema,
4470
+ formatDate,
4345
4471
  generateFlattenedUserProfile,
4346
4472
  generateUserProfile,
4347
4473
  get,