@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/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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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: "#
|
|
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: "#
|
|
3024
|
+
contrastText: "#00a807",
|
|
3025
|
+
dark: "#388e3c"
|
|
3018
3026
|
},
|
|
3019
3027
|
warning: {
|
|
3020
3028
|
main: "#ff9800",
|
|
3021
|
-
contrastText: "#
|
|
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: "#
|
|
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: "#
|
|
3133
|
+
contrastText: "#00a807",
|
|
3134
|
+
dark: "#388e3c"
|
|
3114
3135
|
},
|
|
3115
3136
|
warning: {
|
|
3116
3137
|
main: "#ff9800",
|
|
3117
|
-
contrastText: "#
|
|
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
|
}
|
|
@@ -3372,6 +3401,10 @@ var toThemeVars = (theme) => {
|
|
|
3372
3401
|
main: `var(--${prefix}-color-error-main)`,
|
|
3373
3402
|
contrastText: `var(--${prefix}-color-error-contrastText)`
|
|
3374
3403
|
},
|
|
3404
|
+
info: {
|
|
3405
|
+
contrastText: `var(--${prefix}-color-info-contrastText)`,
|
|
3406
|
+
main: `var(--${prefix}-color-info-main)`
|
|
3407
|
+
},
|
|
3375
3408
|
success: {
|
|
3376
3409
|
main: `var(--${prefix}-color-success-main)`,
|
|
3377
3410
|
contrastText: `var(--${prefix}-color-success-contrastText)`
|
|
@@ -3494,6 +3527,34 @@ var createTheme = (config = {}, isDark = false) => {
|
|
|
3494
3527
|
};
|
|
3495
3528
|
var createTheme_default = createTheme;
|
|
3496
3529
|
|
|
3530
|
+
// src/utils/bem.ts
|
|
3531
|
+
var bem = (baseClass, element, modifier) => {
|
|
3532
|
+
let className = baseClass;
|
|
3533
|
+
if (element) {
|
|
3534
|
+
className += `__${element}`;
|
|
3535
|
+
}
|
|
3536
|
+
if (modifier) {
|
|
3537
|
+
className += `--${modifier}`;
|
|
3538
|
+
}
|
|
3539
|
+
return className;
|
|
3540
|
+
};
|
|
3541
|
+
var bem_default = bem;
|
|
3542
|
+
|
|
3543
|
+
// src/utils/formatDate.ts
|
|
3544
|
+
var formatDate = (dateString) => {
|
|
3545
|
+
if (!dateString) return "-";
|
|
3546
|
+
try {
|
|
3547
|
+
return new Date(dateString).toLocaleDateString("en-US", {
|
|
3548
|
+
year: "numeric",
|
|
3549
|
+
month: "long",
|
|
3550
|
+
day: "numeric"
|
|
3551
|
+
});
|
|
3552
|
+
} catch {
|
|
3553
|
+
return dateString;
|
|
3554
|
+
}
|
|
3555
|
+
};
|
|
3556
|
+
var formatDate_default = formatDate;
|
|
3557
|
+
|
|
3497
3558
|
// src/utils/deepMerge.ts
|
|
3498
3559
|
var isPlainObject = (value) => {
|
|
3499
3560
|
return typeof value === "object" && value !== null && !Array.isArray(value) && !(value instanceof Date) && !(value instanceof RegExp) && Object.prototype.toString.call(value) === "[object Object]";
|
|
@@ -3802,6 +3863,11 @@ var translations = {
|
|
|
3802
3863
|
"username.password.title": "Sign In",
|
|
3803
3864
|
"username.password.subtitle": "Enter your username and password to continue.",
|
|
3804
3865
|
/* |---------------------------------------------------------------| */
|
|
3866
|
+
/* | User Profile | */
|
|
3867
|
+
/* |---------------------------------------------------------------| */
|
|
3868
|
+
"user.profile.title": "Profile",
|
|
3869
|
+
"user.profile.update.generic.error": "An error occurred while updating your profile. Please try again.",
|
|
3870
|
+
/* |---------------------------------------------------------------| */
|
|
3805
3871
|
/* | Organization Switcher | */
|
|
3806
3872
|
/* |---------------------------------------------------------------| */
|
|
3807
3873
|
"organization.switcher.select.organization": "Select Organization",
|
|
@@ -3910,7 +3976,10 @@ var withVendorCSSClassPrefix = (className) => `${VendorConstants_default.VENDOR_
|
|
|
3910
3976
|
var withVendorCSSClassPrefix_default = withVendorCSSClassPrefix;
|
|
3911
3977
|
|
|
3912
3978
|
// src/utils/transformBrandingPreferenceToTheme.ts
|
|
3913
|
-
var extractColorValue = (colorVariant) => {
|
|
3979
|
+
var extractColorValue = (colorVariant, preferDark = false) => {
|
|
3980
|
+
if (preferDark && colorVariant?.dark && colorVariant.dark.trim()) {
|
|
3981
|
+
return colorVariant.dark;
|
|
3982
|
+
}
|
|
3914
3983
|
return colorVariant?.main;
|
|
3915
3984
|
};
|
|
3916
3985
|
var extractContrastText = (colorVariant) => {
|
|
@@ -3937,36 +4006,49 @@ var transformThemeVariant = (themeVariant, isDark = false) => {
|
|
|
3937
4006
|
activatedOpacity: 0.12
|
|
3938
4007
|
},
|
|
3939
4008
|
primary: {
|
|
3940
|
-
main: extractColorValue(colors?.primary),
|
|
3941
|
-
contrastText: extractContrastText(colors?.primary)
|
|
4009
|
+
main: extractColorValue(colors?.primary, isDark),
|
|
4010
|
+
contrastText: extractContrastText(colors?.primary),
|
|
4011
|
+
dark: colors?.primary?.dark || colors?.primary?.main
|
|
3942
4012
|
},
|
|
3943
4013
|
secondary: {
|
|
3944
|
-
main: extractColorValue(colors?.secondary),
|
|
3945
|
-
contrastText: extractContrastText(colors?.secondary)
|
|
4014
|
+
main: extractColorValue(colors?.secondary, isDark),
|
|
4015
|
+
contrastText: extractContrastText(colors?.secondary),
|
|
4016
|
+
dark: colors?.secondary?.dark || colors?.secondary?.main
|
|
3946
4017
|
},
|
|
3947
4018
|
background: {
|
|
3948
|
-
surface: extractColorValue(colors?.background?.surface),
|
|
3949
|
-
disabled: extractColorValue(colors?.background?.surface),
|
|
4019
|
+
surface: extractColorValue(colors?.background?.surface, isDark),
|
|
4020
|
+
disabled: extractColorValue(colors?.background?.surface, isDark),
|
|
4021
|
+
dark: colors?.background?.surface?.dark || colors?.background?.surface?.main,
|
|
3950
4022
|
body: {
|
|
3951
|
-
main: extractColorValue(colors?.background?.body)
|
|
4023
|
+
main: extractColorValue(colors?.background?.body, isDark),
|
|
4024
|
+
dark: colors?.background?.body?.dark || colors?.background?.body?.main
|
|
3952
4025
|
}
|
|
3953
4026
|
},
|
|
3954
4027
|
text: {
|
|
3955
4028
|
primary: colors?.text?.primary,
|
|
3956
|
-
secondary: colors?.text?.secondary
|
|
4029
|
+
secondary: colors?.text?.secondary,
|
|
4030
|
+
dark: colors?.text?.dark || colors?.text?.primary
|
|
3957
4031
|
},
|
|
3958
4032
|
border: colors?.outlined?.default,
|
|
3959
4033
|
error: {
|
|
3960
|
-
main: extractColorValue(colors?.alerts?.error),
|
|
3961
|
-
contrastText: extractContrastText(colors?.alerts?.error)
|
|
4034
|
+
main: extractColorValue(colors?.alerts?.error, isDark),
|
|
4035
|
+
contrastText: extractContrastText(colors?.alerts?.error),
|
|
4036
|
+
dark: colors?.alerts?.error?.dark || colors?.alerts?.error?.main
|
|
4037
|
+
},
|
|
4038
|
+
info: {
|
|
4039
|
+
main: extractColorValue(colors?.alerts?.info, isDark),
|
|
4040
|
+
contrastText: extractContrastText(colors?.alerts?.info),
|
|
4041
|
+
dark: colors?.alerts?.info?.dark || colors?.alerts?.info?.main
|
|
3962
4042
|
},
|
|
3963
4043
|
success: {
|
|
3964
|
-
main: extractColorValue(colors?.alerts?.
|
|
3965
|
-
contrastText: extractContrastText(colors?.alerts?.
|
|
4044
|
+
main: extractColorValue(colors?.alerts?.neutral, isDark),
|
|
4045
|
+
contrastText: extractContrastText(colors?.alerts?.neutral),
|
|
4046
|
+
dark: colors?.alerts?.neutral?.dark || colors?.alerts?.neutral?.main
|
|
3966
4047
|
},
|
|
3967
4048
|
warning: {
|
|
3968
|
-
main: extractColorValue(colors?.alerts?.warning),
|
|
3969
|
-
contrastText: extractContrastText(colors?.alerts?.warning)
|
|
4049
|
+
main: extractColorValue(colors?.alerts?.warning, isDark),
|
|
4050
|
+
contrastText: extractContrastText(colors?.alerts?.warning),
|
|
4051
|
+
dark: colors?.alerts?.warning?.dark || colors?.alerts?.warning?.main
|
|
3970
4052
|
}
|
|
3971
4053
|
},
|
|
3972
4054
|
// Extract border radius from buttons or inputs
|
|
@@ -4325,6 +4407,7 @@ var createPackageComponentLogger = (packageName, component) => {
|
|
|
4325
4407
|
TokenConstants,
|
|
4326
4408
|
VendorConstants,
|
|
4327
4409
|
WellKnownSchemaIds,
|
|
4410
|
+
bem,
|
|
4328
4411
|
configureLogger,
|
|
4329
4412
|
createComponentLogger,
|
|
4330
4413
|
createLogger,
|
|
@@ -4342,6 +4425,7 @@ var createPackageComponentLogger = (packageName, component) => {
|
|
|
4342
4425
|
extractPkceStorageKeyFromState,
|
|
4343
4426
|
extractUserClaimsFromIdToken,
|
|
4344
4427
|
flattenUserSchema,
|
|
4428
|
+
formatDate,
|
|
4345
4429
|
generateFlattenedUserProfile,
|
|
4346
4430
|
generateUserProfile,
|
|
4347
4431
|
get,
|