@asgardeo/javascript 0.1.8 → 0.1.9
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 +124 -40
- package/dist/cjs/index.js.map +3 -3
- package/dist/index.d.ts +2 -0
- package/dist/index.js +122 -40
- package/dist/index.js.map +3 -3
- package/dist/models/i18n.d.ts +2 -0
- package/dist/theme/types.d.ts +26 -0
- package/dist/utils/bem.d.ts +46 -0
- package/dist/utils/formatDate.d.ts +33 -0
- package/package.json +1 -1
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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: "#
|
|
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: "#
|
|
2935
|
+
contrastText: "#00a807",
|
|
2936
|
+
dark: "#388e3c"
|
|
2931
2937
|
},
|
|
2932
2938
|
warning: {
|
|
2933
2939
|
main: "#ff9800",
|
|
2934
|
-
contrastText: "#
|
|
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: "#
|
|
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: "#
|
|
3044
|
+
contrastText: "#00a807",
|
|
3045
|
+
dark: "#388e3c"
|
|
3027
3046
|
},
|
|
3028
3047
|
warning: {
|
|
3029
3048
|
main: "#ff9800",
|
|
3030
|
-
contrastText: "#
|
|
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
|
}
|
|
@@ -3285,6 +3312,10 @@ var toThemeVars = (theme) => {
|
|
|
3285
3312
|
main: `var(--${prefix}-color-error-main)`,
|
|
3286
3313
|
contrastText: `var(--${prefix}-color-error-contrastText)`
|
|
3287
3314
|
},
|
|
3315
|
+
info: {
|
|
3316
|
+
contrastText: `var(--${prefix}-color-info-contrastText)`,
|
|
3317
|
+
main: `var(--${prefix}-color-info-main)`
|
|
3318
|
+
},
|
|
3288
3319
|
success: {
|
|
3289
3320
|
main: `var(--${prefix}-color-success-main)`,
|
|
3290
3321
|
contrastText: `var(--${prefix}-color-success-contrastText)`
|
|
@@ -3407,6 +3438,34 @@ var createTheme = (config = {}, isDark = false) => {
|
|
|
3407
3438
|
};
|
|
3408
3439
|
var createTheme_default = createTheme;
|
|
3409
3440
|
|
|
3441
|
+
// src/utils/bem.ts
|
|
3442
|
+
var bem = (baseClass, element, modifier) => {
|
|
3443
|
+
let className = baseClass;
|
|
3444
|
+
if (element) {
|
|
3445
|
+
className += `__${element}`;
|
|
3446
|
+
}
|
|
3447
|
+
if (modifier) {
|
|
3448
|
+
className += `--${modifier}`;
|
|
3449
|
+
}
|
|
3450
|
+
return className;
|
|
3451
|
+
};
|
|
3452
|
+
var bem_default = bem;
|
|
3453
|
+
|
|
3454
|
+
// src/utils/formatDate.ts
|
|
3455
|
+
var formatDate = (dateString) => {
|
|
3456
|
+
if (!dateString) return "-";
|
|
3457
|
+
try {
|
|
3458
|
+
return new Date(dateString).toLocaleDateString("en-US", {
|
|
3459
|
+
year: "numeric",
|
|
3460
|
+
month: "long",
|
|
3461
|
+
day: "numeric"
|
|
3462
|
+
});
|
|
3463
|
+
} catch {
|
|
3464
|
+
return dateString;
|
|
3465
|
+
}
|
|
3466
|
+
};
|
|
3467
|
+
var formatDate_default = formatDate;
|
|
3468
|
+
|
|
3410
3469
|
// src/utils/deepMerge.ts
|
|
3411
3470
|
var isPlainObject = (value) => {
|
|
3412
3471
|
return typeof value === "object" && value !== null && !Array.isArray(value) && !(value instanceof Date) && !(value instanceof RegExp) && Object.prototype.toString.call(value) === "[object Object]";
|
|
@@ -3715,6 +3774,11 @@ var translations = {
|
|
|
3715
3774
|
"username.password.title": "Sign In",
|
|
3716
3775
|
"username.password.subtitle": "Enter your username and password to continue.",
|
|
3717
3776
|
/* |---------------------------------------------------------------| */
|
|
3777
|
+
/* | User Profile | */
|
|
3778
|
+
/* |---------------------------------------------------------------| */
|
|
3779
|
+
"user.profile.title": "Profile",
|
|
3780
|
+
"user.profile.update.generic.error": "An error occurred while updating your profile. Please try again.",
|
|
3781
|
+
/* |---------------------------------------------------------------| */
|
|
3718
3782
|
/* | Organization Switcher | */
|
|
3719
3783
|
/* |---------------------------------------------------------------| */
|
|
3720
3784
|
"organization.switcher.select.organization": "Select Organization",
|
|
@@ -3823,7 +3887,10 @@ var withVendorCSSClassPrefix = (className) => `${VendorConstants_default.VENDOR_
|
|
|
3823
3887
|
var withVendorCSSClassPrefix_default = withVendorCSSClassPrefix;
|
|
3824
3888
|
|
|
3825
3889
|
// src/utils/transformBrandingPreferenceToTheme.ts
|
|
3826
|
-
var extractColorValue = (colorVariant) => {
|
|
3890
|
+
var extractColorValue = (colorVariant, preferDark = false) => {
|
|
3891
|
+
if (preferDark && colorVariant?.dark && colorVariant.dark.trim()) {
|
|
3892
|
+
return colorVariant.dark;
|
|
3893
|
+
}
|
|
3827
3894
|
return colorVariant?.main;
|
|
3828
3895
|
};
|
|
3829
3896
|
var extractContrastText = (colorVariant) => {
|
|
@@ -3850,36 +3917,49 @@ var transformThemeVariant = (themeVariant, isDark = false) => {
|
|
|
3850
3917
|
activatedOpacity: 0.12
|
|
3851
3918
|
},
|
|
3852
3919
|
primary: {
|
|
3853
|
-
main: extractColorValue(colors?.primary),
|
|
3854
|
-
contrastText: extractContrastText(colors?.primary)
|
|
3920
|
+
main: extractColorValue(colors?.primary, isDark),
|
|
3921
|
+
contrastText: extractContrastText(colors?.primary),
|
|
3922
|
+
dark: colors?.primary?.dark || colors?.primary?.main
|
|
3855
3923
|
},
|
|
3856
3924
|
secondary: {
|
|
3857
|
-
main: extractColorValue(colors?.secondary),
|
|
3858
|
-
contrastText: extractContrastText(colors?.secondary)
|
|
3925
|
+
main: extractColorValue(colors?.secondary, isDark),
|
|
3926
|
+
contrastText: extractContrastText(colors?.secondary),
|
|
3927
|
+
dark: colors?.secondary?.dark || colors?.secondary?.main
|
|
3859
3928
|
},
|
|
3860
3929
|
background: {
|
|
3861
|
-
surface: extractColorValue(colors?.background?.surface),
|
|
3862
|
-
disabled: extractColorValue(colors?.background?.surface),
|
|
3930
|
+
surface: extractColorValue(colors?.background?.surface, isDark),
|
|
3931
|
+
disabled: extractColorValue(colors?.background?.surface, isDark),
|
|
3932
|
+
dark: colors?.background?.surface?.dark || colors?.background?.surface?.main,
|
|
3863
3933
|
body: {
|
|
3864
|
-
main: extractColorValue(colors?.background?.body)
|
|
3934
|
+
main: extractColorValue(colors?.background?.body, isDark),
|
|
3935
|
+
dark: colors?.background?.body?.dark || colors?.background?.body?.main
|
|
3865
3936
|
}
|
|
3866
3937
|
},
|
|
3867
3938
|
text: {
|
|
3868
3939
|
primary: colors?.text?.primary,
|
|
3869
|
-
secondary: colors?.text?.secondary
|
|
3940
|
+
secondary: colors?.text?.secondary,
|
|
3941
|
+
dark: colors?.text?.dark || colors?.text?.primary
|
|
3870
3942
|
},
|
|
3871
3943
|
border: colors?.outlined?.default,
|
|
3872
3944
|
error: {
|
|
3873
|
-
main: extractColorValue(colors?.alerts?.error),
|
|
3874
|
-
contrastText: extractContrastText(colors?.alerts?.error)
|
|
3945
|
+
main: extractColorValue(colors?.alerts?.error, isDark),
|
|
3946
|
+
contrastText: extractContrastText(colors?.alerts?.error),
|
|
3947
|
+
dark: colors?.alerts?.error?.dark || colors?.alerts?.error?.main
|
|
3948
|
+
},
|
|
3949
|
+
info: {
|
|
3950
|
+
main: extractColorValue(colors?.alerts?.info, isDark),
|
|
3951
|
+
contrastText: extractContrastText(colors?.alerts?.info),
|
|
3952
|
+
dark: colors?.alerts?.info?.dark || colors?.alerts?.info?.main
|
|
3875
3953
|
},
|
|
3876
3954
|
success: {
|
|
3877
|
-
main: extractColorValue(colors?.alerts?.
|
|
3878
|
-
contrastText: extractContrastText(colors?.alerts?.
|
|
3955
|
+
main: extractColorValue(colors?.alerts?.neutral, isDark),
|
|
3956
|
+
contrastText: extractContrastText(colors?.alerts?.neutral),
|
|
3957
|
+
dark: colors?.alerts?.neutral?.dark || colors?.alerts?.neutral?.main
|
|
3879
3958
|
},
|
|
3880
3959
|
warning: {
|
|
3881
|
-
main: extractColorValue(colors?.alerts?.warning),
|
|
3882
|
-
contrastText: extractContrastText(colors?.alerts?.warning)
|
|
3960
|
+
main: extractColorValue(colors?.alerts?.warning, isDark),
|
|
3961
|
+
contrastText: extractContrastText(colors?.alerts?.warning),
|
|
3962
|
+
dark: colors?.alerts?.warning?.dark || colors?.alerts?.warning?.main
|
|
3883
3963
|
}
|
|
3884
3964
|
},
|
|
3885
3965
|
// Extract border radius from buttons or inputs
|
|
@@ -4237,6 +4317,7 @@ export {
|
|
|
4237
4317
|
TokenConstants_default as TokenConstants,
|
|
4238
4318
|
VendorConstants_default as VendorConstants,
|
|
4239
4319
|
WellKnownSchemaIds,
|
|
4320
|
+
bem_default as bem,
|
|
4240
4321
|
configure as configureLogger,
|
|
4241
4322
|
createComponentLogger,
|
|
4242
4323
|
createLogger,
|
|
@@ -4254,6 +4335,7 @@ export {
|
|
|
4254
4335
|
extractPkceStorageKeyFromState_default as extractPkceStorageKeyFromState,
|
|
4255
4336
|
extractUserClaimsFromIdToken_default as extractUserClaimsFromIdToken,
|
|
4256
4337
|
flattenUserSchema_default as flattenUserSchema,
|
|
4338
|
+
formatDate_default as formatDate,
|
|
4257
4339
|
generateFlattenedUserProfile_default as generateFlattenedUserProfile,
|
|
4258
4340
|
generateUserProfile_default as generateUserProfile,
|
|
4259
4341
|
get_default as get,
|