@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/index.d.ts CHANGED
@@ -62,6 +62,8 @@ export { I18nBundle, I18nTranslations, I18nMetadata } from './models/i18n';
62
62
  export { default as AsgardeoJavaScriptClient } from './AsgardeoJavaScriptClient';
63
63
  export { default as createTheme } from './theme/createTheme';
64
64
  export { ThemeColors, ThemeConfig, Theme, ThemeMode, ThemeDetection } from './theme/types';
65
+ export { default as bem } from './utils/bem';
66
+ export { default as formatDate } from './utils/formatDate';
65
67
  export { default as processUsername } from './utils/processUsername';
66
68
  export { default as deepMerge } from './utils/deepMerge';
67
69
  export { default as deriveOrganizationHandleFromBaseUrl } from './utils/deriveOrganizationHandleFromBaseUrl';
package/dist/index.js CHANGED
@@ -615,14 +615,7 @@ var extractUserClaimsFromIdToken_default = extractUserClaimsFromIdToken;
615
615
  var AsgardeoError = class _AsgardeoError extends Error {
616
616
  constructor(message, code, origin) {
617
617
  const _origin = _AsgardeoError.resolveOrigin(origin);
618
- const prefix = `\u{1F6E1}\uFE0F Asgardeo - ${_origin}:`;
619
- const regex = new RegExp(`\u{1F6E1}\uFE0F\\s*Asgardeo\\s*-\\s*${_origin}:`, "i");
620
- const sanitized = message.replace(regex, "");
621
- const _message = `${prefix} ${sanitized.trim()}
622
-
623
- (code="${code}")
624
- `;
625
- super(_message);
618
+ super(message);
626
619
  __publicField(this, "code");
627
620
  __publicField(this, "origin");
628
621
  this.name = new.target.name;
@@ -639,8 +632,10 @@ var AsgardeoError = class _AsgardeoError extends Error {
639
632
  return `@asgardeo/${origin}`;
640
633
  }
641
634
  toString() {
635
+ const prefix = `\u{1F6E1}\uFE0F Asgardeo - ${this.origin}:`;
642
636
  return `[${this.name}]
643
- Message: ${this.message}`;
637
+ ${prefix} ${this.message}
638
+ (code="${this.code}")`;
644
639
  }
645
640
  };
646
641
 
@@ -2709,10 +2704,10 @@ var updateMeProfile = async ({
2709
2704
  throw error2;
2710
2705
  }
2711
2706
  throw new AsgardeoAPIError(
2712
- `Network or parsing error: ${error2 instanceof Error ? error2.message : "Unknown error"}`,
2707
+ error2?.response?.data?.detail || "An error occurred while updating the user profile. Please try again.",
2713
2708
  "updateMeProfile-NetworkError-001",
2714
2709
  "javascript",
2715
- 0,
2710
+ error2?.data?.status,
2716
2711
  "Network Error"
2717
2712
  );
2718
2713
  }
@@ -2908,34 +2903,47 @@ var lightTheme = {
2908
2903
  },
2909
2904
  primary: {
2910
2905
  main: "#1a73e8",
2911
- contrastText: "#ffffff"
2906
+ contrastText: "#ffffff",
2907
+ dark: "#174ea6"
2912
2908
  },
2913
2909
  secondary: {
2914
2910
  main: "#424242",
2915
- contrastText: "#ffffff"
2911
+ contrastText: "#ffffff",
2912
+ dark: "#212121"
2916
2913
  },
2917
2914
  background: {
2918
2915
  surface: "#ffffff",
2919
2916
  disabled: "#f0f0f0",
2917
+ dark: "#212121",
2920
2918
  body: {
2921
- main: "#1a1a1a"
2919
+ main: "#1a1a1a",
2920
+ dark: "#212121"
2922
2921
  }
2923
2922
  },
2924
2923
  error: {
2925
2924
  main: "#d32f2f",
2926
- contrastText: "#ffffff"
2925
+ contrastText: "#d52828",
2926
+ dark: "#b71c1c"
2927
+ },
2928
+ info: {
2929
+ main: "#bbebff",
2930
+ contrastText: "#43aeda",
2931
+ dark: "#01579b"
2927
2932
  },
2928
2933
  success: {
2929
2934
  main: "#4caf50",
2930
- contrastText: "#ffffff"
2935
+ contrastText: "#00a807",
2936
+ dark: "#388e3c"
2931
2937
  },
2932
2938
  warning: {
2933
2939
  main: "#ff9800",
2934
- contrastText: "#ffffff"
2940
+ contrastText: "#be7100",
2941
+ dark: "#f57c00"
2935
2942
  },
2936
2943
  text: {
2937
2944
  primary: "#1a1a1a",
2938
- secondary: "#666666"
2945
+ secondary: "#666666",
2946
+ dark: "#212121"
2939
2947
  },
2940
2948
  border: "#e0e0e0"
2941
2949
  },
@@ -3004,34 +3012,47 @@ var darkTheme = {
3004
3012
  },
3005
3013
  primary: {
3006
3014
  main: "#1a73e8",
3007
- contrastText: "#ffffff"
3015
+ contrastText: "#ffffff",
3016
+ dark: "#174ea6"
3008
3017
  },
3009
3018
  secondary: {
3010
3019
  main: "#424242",
3011
- contrastText: "#ffffff"
3020
+ contrastText: "#ffffff",
3021
+ dark: "#212121"
3012
3022
  },
3013
3023
  background: {
3014
3024
  surface: "#121212",
3015
3025
  disabled: "#1f1f1f",
3026
+ dark: "#212121",
3016
3027
  body: {
3017
- main: "#ffffff"
3028
+ main: "#ffffff",
3029
+ dark: "#212121"
3018
3030
  }
3019
3031
  },
3020
3032
  error: {
3021
3033
  main: "#d32f2f",
3022
- contrastText: "#ffffff"
3034
+ contrastText: "#d52828",
3035
+ dark: "#b71c1c"
3036
+ },
3037
+ info: {
3038
+ main: "#bbebff",
3039
+ contrastText: "#43aeda",
3040
+ dark: "#01579b"
3023
3041
  },
3024
3042
  success: {
3025
3043
  main: "#4caf50",
3026
- contrastText: "#ffffff"
3044
+ contrastText: "#00a807",
3045
+ dark: "#388e3c"
3027
3046
  },
3028
3047
  warning: {
3029
3048
  main: "#ff9800",
3030
- contrastText: "#ffffff"
3049
+ contrastText: "#be7100",
3050
+ dark: "#f57c00"
3031
3051
  },
3032
3052
  text: {
3033
3053
  primary: "#ffffff",
3034
- secondary: "#b3b3b3"
3054
+ secondary: "#b3b3b3",
3055
+ dark: "#212121"
3035
3056
  },
3036
3057
  border: "#404040"
3037
3058
  },
@@ -3158,6 +3179,12 @@ var toCssVariables = (theme) => {
3158
3179
  if (theme.colors?.warning?.contrastText) {
3159
3180
  cssVars[`--${prefix}-color-warning-contrastText`] = theme.colors.warning.contrastText;
3160
3181
  }
3182
+ if (theme.colors?.info?.main) {
3183
+ cssVars[`--${prefix}-color-info-main`] = theme.colors.info.main;
3184
+ }
3185
+ if (theme.colors?.info?.contrastText) {
3186
+ cssVars[`--${prefix}-color-info-contrastText`] = theme.colors.info.contrastText;
3187
+ }
3161
3188
  if (theme.colors?.text?.primary) {
3162
3189
  cssVars[`--${prefix}-color-text-primary`] = theme.colors.text.primary;
3163
3190
  }
@@ -3247,10 +3274,31 @@ var toCssVariables = (theme) => {
3247
3274
  }
3248
3275
  });
3249
3276
  }
3277
+ if (theme.components?.Button?.styleOverrides?.root?.borderRadius) {
3278
+ cssVars[`--${prefix}-component-button-root-borderRadius`] = theme.components.Button.styleOverrides.root.borderRadius;
3279
+ }
3280
+ if (theme.components?.Field?.styleOverrides?.root?.borderRadius) {
3281
+ cssVars[`--${prefix}-component-field-root-borderRadius`] = theme.components.Field.styleOverrides.root.borderRadius;
3282
+ }
3250
3283
  return cssVars;
3251
3284
  };
3252
3285
  var toThemeVars = (theme) => {
3253
3286
  const prefix = theme.cssVarPrefix || VendorConstants_default.VENDOR_PREFIX;
3287
+ const componentVars = {};
3288
+ if (theme.components?.Button?.styleOverrides?.root?.borderRadius) {
3289
+ componentVars.Button = {
3290
+ root: {
3291
+ borderRadius: `var(--${prefix}-component-button-root-borderRadius)`
3292
+ }
3293
+ };
3294
+ }
3295
+ if (theme.components?.Field?.styleOverrides?.root?.borderRadius) {
3296
+ componentVars.Field = {
3297
+ root: {
3298
+ borderRadius: `var(--${prefix}-component-field-root-borderRadius)`
3299
+ }
3300
+ };
3301
+ }
3254
3302
  const themeVars = {
3255
3303
  colors: {
3256
3304
  action: {
@@ -3285,6 +3333,10 @@ var toThemeVars = (theme) => {
3285
3333
  main: `var(--${prefix}-color-error-main)`,
3286
3334
  contrastText: `var(--${prefix}-color-error-contrastText)`
3287
3335
  },
3336
+ info: {
3337
+ contrastText: `var(--${prefix}-color-info-contrastText)`,
3338
+ main: `var(--${prefix}-color-info-main)`
3339
+ },
3288
3340
  success: {
3289
3341
  main: `var(--${prefix}-color-success-main)`,
3290
3342
  contrastText: `var(--${prefix}-color-success-contrastText)`
@@ -3347,6 +3399,9 @@ var toThemeVars = (theme) => {
3347
3399
  };
3348
3400
  });
3349
3401
  }
3402
+ if (Object.keys(componentVars).length > 0) {
3403
+ themeVars.components = componentVars;
3404
+ }
3350
3405
  return themeVars;
3351
3406
  };
3352
3407
  var createTheme = (config = {}, isDark = false) => {
@@ -3407,6 +3462,34 @@ var createTheme = (config = {}, isDark = false) => {
3407
3462
  };
3408
3463
  var createTheme_default = createTheme;
3409
3464
 
3465
+ // src/utils/bem.ts
3466
+ var bem = (baseClass, element, modifier) => {
3467
+ let className = baseClass;
3468
+ if (element) {
3469
+ className += `__${element}`;
3470
+ }
3471
+ if (modifier) {
3472
+ className += `--${modifier}`;
3473
+ }
3474
+ return className;
3475
+ };
3476
+ var bem_default = bem;
3477
+
3478
+ // src/utils/formatDate.ts
3479
+ var formatDate = (dateString) => {
3480
+ if (!dateString) return "-";
3481
+ try {
3482
+ return new Date(dateString).toLocaleDateString("en-US", {
3483
+ year: "numeric",
3484
+ month: "long",
3485
+ day: "numeric"
3486
+ });
3487
+ } catch {
3488
+ return dateString;
3489
+ }
3490
+ };
3491
+ var formatDate_default = formatDate;
3492
+
3410
3493
  // src/utils/deepMerge.ts
3411
3494
  var isPlainObject = (value) => {
3412
3495
  return typeof value === "object" && value !== null && !Array.isArray(value) && !(value instanceof Date) && !(value instanceof RegExp) && Object.prototype.toString.call(value) === "[object Object]";
@@ -3715,6 +3798,11 @@ var translations = {
3715
3798
  "username.password.title": "Sign In",
3716
3799
  "username.password.subtitle": "Enter your username and password to continue.",
3717
3800
  /* |---------------------------------------------------------------| */
3801
+ /* | User Profile | */
3802
+ /* |---------------------------------------------------------------| */
3803
+ "user.profile.title": "Profile",
3804
+ "user.profile.update.generic.error": "An error occurred while updating your profile. Please try again.",
3805
+ /* |---------------------------------------------------------------| */
3718
3806
  /* | Organization Switcher | */
3719
3807
  /* |---------------------------------------------------------------| */
3720
3808
  "organization.switcher.select.organization": "Select Organization",
@@ -3823,7 +3911,10 @@ var withVendorCSSClassPrefix = (className) => `${VendorConstants_default.VENDOR_
3823
3911
  var withVendorCSSClassPrefix_default = withVendorCSSClassPrefix;
3824
3912
 
3825
3913
  // src/utils/transformBrandingPreferenceToTheme.ts
3826
- var extractColorValue = (colorVariant) => {
3914
+ var extractColorValue = (colorVariant, preferDark = false) => {
3915
+ if (preferDark && colorVariant?.dark && colorVariant.dark.trim()) {
3916
+ return colorVariant.dark;
3917
+ }
3827
3918
  return colorVariant?.main;
3828
3919
  };
3829
3920
  var extractContrastText = (colorVariant) => {
@@ -3834,7 +3925,7 @@ var transformThemeVariant = (themeVariant, isDark = false) => {
3834
3925
  const buttons = themeVariant.buttons;
3835
3926
  const inputs = themeVariant.inputs;
3836
3927
  const images = themeVariant.images;
3837
- return {
3928
+ const config = {
3838
3929
  colors: {
3839
3930
  action: {
3840
3931
  active: isDark ? "rgba(255, 255, 255, 0.70)" : "rgba(0, 0, 0, 0.54)",
@@ -3850,45 +3941,51 @@ var transformThemeVariant = (themeVariant, isDark = false) => {
3850
3941
  activatedOpacity: 0.12
3851
3942
  },
3852
3943
  primary: {
3853
- main: extractColorValue(colors?.primary),
3854
- contrastText: extractContrastText(colors?.primary)
3944
+ main: extractColorValue(colors?.primary, isDark),
3945
+ contrastText: extractContrastText(colors?.primary),
3946
+ dark: colors?.primary?.dark || colors?.primary?.main
3855
3947
  },
3856
3948
  secondary: {
3857
- main: extractColorValue(colors?.secondary),
3858
- contrastText: extractContrastText(colors?.secondary)
3949
+ main: extractColorValue(colors?.secondary, isDark),
3950
+ contrastText: extractContrastText(colors?.secondary),
3951
+ dark: colors?.secondary?.dark || colors?.secondary?.main
3859
3952
  },
3860
3953
  background: {
3861
- surface: extractColorValue(colors?.background?.surface),
3862
- disabled: extractColorValue(colors?.background?.surface),
3954
+ surface: extractColorValue(colors?.background?.surface, isDark),
3955
+ disabled: extractColorValue(colors?.background?.surface, isDark),
3956
+ dark: colors?.background?.surface?.dark || colors?.background?.surface?.main,
3863
3957
  body: {
3864
- main: extractColorValue(colors?.background?.body)
3958
+ main: extractColorValue(colors?.background?.body, isDark),
3959
+ dark: colors?.background?.body?.dark || colors?.background?.body?.main
3865
3960
  }
3866
3961
  },
3867
3962
  text: {
3868
3963
  primary: colors?.text?.primary,
3869
- secondary: colors?.text?.secondary
3964
+ secondary: colors?.text?.secondary,
3965
+ dark: colors?.text?.dark || colors?.text?.primary
3870
3966
  },
3871
3967
  border: colors?.outlined?.default,
3872
3968
  error: {
3873
- main: extractColorValue(colors?.alerts?.error),
3874
- contrastText: extractContrastText(colors?.alerts?.error)
3969
+ main: extractColorValue(colors?.alerts?.error, isDark),
3970
+ contrastText: extractContrastText(colors?.alerts?.error),
3971
+ dark: colors?.alerts?.error?.dark || colors?.alerts?.error?.main
3972
+ },
3973
+ info: {
3974
+ main: extractColorValue(colors?.alerts?.info, isDark),
3975
+ contrastText: extractContrastText(colors?.alerts?.info),
3976
+ dark: colors?.alerts?.info?.dark || colors?.alerts?.info?.main
3875
3977
  },
3876
3978
  success: {
3877
- main: extractColorValue(colors?.alerts?.info),
3878
- contrastText: extractContrastText(colors?.alerts?.info)
3979
+ main: extractColorValue(colors?.alerts?.neutral, isDark),
3980
+ contrastText: extractContrastText(colors?.alerts?.neutral),
3981
+ dark: colors?.alerts?.neutral?.dark || colors?.alerts?.neutral?.main
3879
3982
  },
3880
3983
  warning: {
3881
- main: extractColorValue(colors?.alerts?.warning),
3882
- contrastText: extractContrastText(colors?.alerts?.warning)
3984
+ main: extractColorValue(colors?.alerts?.warning, isDark),
3985
+ contrastText: extractContrastText(colors?.alerts?.warning),
3986
+ dark: colors?.alerts?.warning?.dark || colors?.alerts?.warning?.main
3883
3987
  }
3884
3988
  },
3885
- // Extract border radius from buttons or inputs
3886
- borderRadius: {
3887
- small: buttons?.primary?.base?.border?.borderRadius || inputs?.base?.border?.borderRadius,
3888
- medium: buttons?.secondary?.base?.border?.borderRadius,
3889
- large: buttons?.externalConnection?.base?.border?.borderRadius
3890
- },
3891
- // Extract and transform images
3892
3989
  images: {
3893
3990
  favicon: images?.favicon ? {
3894
3991
  url: images.favicon.imgURL,
@@ -3902,6 +3999,31 @@ var transformThemeVariant = (themeVariant, isDark = false) => {
3902
3999
  } : void 0
3903
4000
  }
3904
4001
  };
4002
+ const buttonBorderRadius = buttons?.primary?.base?.border?.borderRadius;
4003
+ const fieldBorderRadius = inputs?.base?.border?.borderRadius;
4004
+ if (buttonBorderRadius || fieldBorderRadius) {
4005
+ config.components = {
4006
+ ...buttonBorderRadius && {
4007
+ Button: {
4008
+ styleOverrides: {
4009
+ root: {
4010
+ borderRadius: buttonBorderRadius
4011
+ }
4012
+ }
4013
+ }
4014
+ },
4015
+ ...fieldBorderRadius && {
4016
+ Field: {
4017
+ styleOverrides: {
4018
+ root: {
4019
+ borderRadius: fieldBorderRadius
4020
+ }
4021
+ }
4022
+ }
4023
+ }
4024
+ };
4025
+ }
4026
+ return config;
3905
4027
  };
3906
4028
  var transformBrandingPreferenceToTheme = (brandingPreference, forceTheme) => {
3907
4029
  const themeConfig = brandingPreference?.preference?.theme;
@@ -4237,6 +4359,7 @@ export {
4237
4359
  TokenConstants_default as TokenConstants,
4238
4360
  VendorConstants_default as VendorConstants,
4239
4361
  WellKnownSchemaIds,
4362
+ bem_default as bem,
4240
4363
  configure as configureLogger,
4241
4364
  createComponentLogger,
4242
4365
  createLogger,
@@ -4254,6 +4377,7 @@ export {
4254
4377
  extractPkceStorageKeyFromState_default as extractPkceStorageKeyFromState,
4255
4378
  extractUserClaimsFromIdToken_default as extractUserClaimsFromIdToken,
4256
4379
  flattenUserSchema_default as flattenUserSchema,
4380
+ formatDate_default as formatDate,
4257
4381
  generateFlattenedUserProfile_default as generateFlattenedUserProfile,
4258
4382
  generateUserProfile_default as generateUserProfile,
4259
4383
  get_default as get,