@asgardeo/javascript 0.1.15 → 0.1.17

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.js CHANGED
@@ -2813,6 +2813,14 @@ var VendorConstants = {
2813
2813
  };
2814
2814
  var VendorConstants_default = VendorConstants;
2815
2815
 
2816
+ // src/models/platforms.ts
2817
+ var Platform = /* @__PURE__ */ ((Platform2) => {
2818
+ Platform2["Asgardeo"] = "ASGARDEO";
2819
+ Platform2["IdentityServer"] = "IDENTITY_SERVER";
2820
+ Platform2["Unknown"] = "UNKNOWN";
2821
+ return Platform2;
2822
+ })(Platform || {});
2823
+
2816
2824
  // src/models/embedded-signin-flow.ts
2817
2825
  var EmbeddedSignInFlowStatus = /* @__PURE__ */ ((EmbeddedSignInFlowStatus2) => {
2818
2826
  EmbeddedSignInFlowStatus2["FailCompleted"] = "FAIL_COMPLETED";
@@ -2998,15 +3006,15 @@ var lightTheme = {
2998
3006
  var darkTheme = {
2999
3007
  colors: {
3000
3008
  action: {
3001
- active: "rgba(255, 255, 255, 0.70)",
3002
- hover: "rgba(255, 255, 255, 0.04)",
3009
+ active: "#1c1c1c",
3010
+ hover: "#1c1c1c",
3003
3011
  hoverOpacity: 0.04,
3004
- selected: "rgba(255, 255, 255, 0.08)",
3012
+ selected: "#1c1c1c",
3005
3013
  selectedOpacity: 0.08,
3006
3014
  disabled: "rgba(255, 255, 255, 0.26)",
3007
3015
  disabledBackground: "rgba(255, 255, 255, 0.12)",
3008
3016
  disabledOpacity: 0.38,
3009
- focus: "rgba(255, 255, 255, 0.12)",
3017
+ focus: "#1c1c1c",
3010
3018
  focusOpacity: 0.12,
3011
3019
  activatedOpacity: 0.12
3012
3020
  },
@@ -3016,7 +3024,7 @@ var darkTheme = {
3016
3024
  dark: "#174ea6"
3017
3025
  },
3018
3026
  secondary: {
3019
- main: "#424242",
3027
+ main: "#8b8b8b",
3020
3028
  contrastText: "#ffffff",
3021
3029
  dark: "#212121"
3022
3030
  },
@@ -3460,6 +3468,7 @@ var createTheme = (config = {}, isDark = false) => {
3460
3468
  vars: toThemeVars(mergedConfig)
3461
3469
  };
3462
3470
  };
3471
+ var DEFAULT_THEME = "light";
3463
3472
  var createTheme_default = createTheme;
3464
3473
 
3465
3474
  // src/utils/bem.ts
@@ -3566,773 +3575,858 @@ var deriveOrganizationHandleFromBaseUrl = (baseUrl) => {
3566
3575
  };
3567
3576
  var deriveOrganizationHandleFromBaseUrl_default = deriveOrganizationHandleFromBaseUrl;
3568
3577
 
3569
- // src/utils/flattenUserSchema.ts
3570
- var flattenUserSchema = (schemas) => {
3571
- const flattenedAttributes = [];
3572
- schemas.forEach((schema) => {
3573
- if (schema.attributes && Array.isArray(schema.attributes)) {
3574
- schema.attributes.forEach((attribute) => {
3575
- if (attribute.subAttributes && Array.isArray(attribute.subAttributes)) {
3576
- attribute.subAttributes.forEach((subAttribute) => {
3577
- flattenedAttributes.push({
3578
- ...subAttribute,
3579
- name: `${attribute.name}.${subAttribute.name}`,
3580
- schemaId: schema.id
3581
- });
3582
- });
3583
- } else {
3584
- flattenedAttributes.push({
3585
- ...attribute,
3586
- schemaId: schema.id
3587
- });
3588
- }
3589
- });
3590
- }
3591
- });
3592
- return flattenedAttributes;
3578
+ // src/utils/logger.ts
3579
+ var PREFIX = "\u{1F6E1}\uFE0F Asgardeo";
3580
+ var DEFAULT_CONFIG = {
3581
+ level: "info",
3582
+ prefix: `${PREFIX}`,
3583
+ timestamps: true,
3584
+ showLevel: true
3593
3585
  };
3594
- var flattenUserSchema_default = flattenUserSchema;
3595
-
3596
- // src/utils/get.ts
3597
- var get = (object, path, defaultValue) => {
3598
- if (!object || !path) return defaultValue;
3599
- const pathArray = Array.isArray(path) ? path : path.split(".");
3600
- const result = pathArray.reduce((current, key) => {
3601
- return current?.[key];
3602
- }, object);
3603
- return result !== void 0 ? result : defaultValue;
3586
+ var isBrowser = () => {
3587
+ return typeof window !== "undefined" && typeof window.document !== "undefined";
3604
3588
  };
3605
- var get_default = get;
3606
-
3607
- // src/utils/set.ts
3608
- var set = (object, path, value) => {
3609
- if (!object || !path) return object;
3610
- const pathArray = Array.isArray(path) ? path : path.split(".");
3611
- const lastIndex = pathArray.length - 1;
3612
- pathArray.reduce((current, key, index) => {
3613
- if (index === lastIndex) {
3614
- current[key] = value;
3615
- } else {
3616
- if (!(key in current) || typeof current[key] !== "object" || current[key] === null) {
3617
- const nextKey = pathArray[index + 1];
3618
- current[key] = /^\d+$/.test(nextKey) ? [] : {};
3619
- }
3620
- }
3621
- return current[key];
3622
- }, object);
3623
- return object;
3589
+ var isNode = () => {
3590
+ return typeof process !== "undefined" && process.versions && process.versions.node;
3624
3591
  };
3625
- var set_default = set;
3626
-
3627
- // src/utils/generateUserProfile.ts
3628
- var generateUserProfile = (meResponse, processedSchemas) => {
3629
- const profile = {};
3630
- processedSchemas.forEach((schema) => {
3631
- const { name, type, multiValued } = schema;
3632
- if (!name) return;
3633
- let value = get_default(meResponse, name);
3634
- if (value !== void 0) {
3635
- if (multiValued && !Array.isArray(value)) {
3636
- value = [value];
3637
- }
3638
- } else {
3639
- if (multiValued) {
3640
- value = void 0;
3641
- } else if (type === "STRING") {
3642
- value = "";
3643
- } else {
3644
- value = void 0;
3645
- }
3646
- }
3647
- set_default(profile, name, value);
3648
- });
3649
- return profile;
3592
+ var COLORS = {
3593
+ reset: "\x1B[0m",
3594
+ bright: "\x1B[1m",
3595
+ dim: "\x1B[2m",
3596
+ red: "\x1B[31m",
3597
+ green: "\x1B[32m",
3598
+ yellow: "\x1B[33m",
3599
+ blue: "\x1B[34m",
3600
+ magenta: "\x1B[35m",
3601
+ cyan: "\x1B[36m",
3602
+ white: "\x1B[37m",
3603
+ gray: "\x1B[90m"
3650
3604
  };
3651
- var generateUserProfile_default = generateUserProfile;
3652
-
3653
- // src/utils/getLatestStateParam.ts
3654
- var getLatestPkceStorageKey = (tempStore) => {
3655
- const keys = [];
3656
- Object.keys(tempStore).forEach((key) => {
3657
- if (key.startsWith(PKCEConstants_default.Storage.StorageKeys.CODE_VERIFIER)) {
3658
- keys.push(key);
3659
- }
3660
- });
3661
- const lastKey = keys.sort().pop();
3662
- return lastKey ?? null;
3605
+ var BROWSER_STYLES = {
3606
+ debug: "color: #6b7280; font-weight: normal;",
3607
+ info: "color: #2563eb; font-weight: bold;",
3608
+ warn: "color: #d97706; font-weight: bold;",
3609
+ error: "color: #dc2626; font-weight: bold;",
3610
+ prefix: "color: #7c3aed; font-weight: bold;",
3611
+ timestamp: "color: #6b7280; font-size: 0.9em;"
3663
3612
  };
3664
- var getLatestStateParam = (tempStore, state) => {
3665
- const latestPkceKey = getLatestPkceStorageKey(tempStore);
3666
- if (!latestPkceKey) {
3667
- return null;
3613
+ var Logger = class _Logger {
3614
+ constructor(config = {}) {
3615
+ __publicField(this, "config");
3616
+ this.config = { ...DEFAULT_CONFIG, ...config };
3668
3617
  }
3669
- return generateStateParamForRequestCorrelation_default(latestPkceKey, state);
3670
- };
3671
- var getLatestStateParam_default = getLatestStateParam;
3672
-
3673
- // src/utils/generateFlattenedUserProfile.ts
3674
- var generateFlattenedUserProfile = (meResponse, processedSchemas) => {
3675
- const profile = {};
3676
- const allSchemaNames = processedSchemas.map((schema) => schema.name).filter(Boolean);
3677
- processedSchemas.forEach((schema) => {
3678
- const { name, type, multiValued } = schema;
3679
- if (!name) return;
3680
- const hasChildProperties = allSchemaNames.some(
3681
- (schemaName) => schemaName !== name && schemaName.startsWith(`${name}.`)
3682
- );
3683
- if (hasChildProperties) {
3684
- return;
3618
+ /**
3619
+ * Update logger configuration
3620
+ */
3621
+ configure(config) {
3622
+ this.config = { ...this.config, ...config };
3623
+ }
3624
+ /**
3625
+ * Get current configuration
3626
+ */
3627
+ getConfig() {
3628
+ return { ...this.config };
3629
+ }
3630
+ /**
3631
+ * Check if a log level should be output
3632
+ */
3633
+ shouldLog(level) {
3634
+ return level >= this.config.level;
3635
+ }
3636
+ /**
3637
+ * Get timestamp string
3638
+ */
3639
+ getTimestamp() {
3640
+ return (/* @__PURE__ */ new Date()).toISOString();
3641
+ }
3642
+ /**
3643
+ * Get log level string
3644
+ */
3645
+ getLevelString(level) {
3646
+ switch (level) {
3647
+ case "debug":
3648
+ return "DEBUG";
3649
+ case "info":
3650
+ return "INFO";
3651
+ case "warn":
3652
+ return "WARN";
3653
+ case "error":
3654
+ return "ERROR";
3655
+ default:
3656
+ return "UNKNOWN";
3685
3657
  }
3686
- let value = get_default(meResponse, name);
3687
- if (value === void 0) {
3688
- const schemaNamespaces = [
3689
- "urn:ietf:params:scim:schemas:core:2.0:User",
3690
- "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User",
3691
- "urn:scim:wso2:schema",
3692
- "urn:scim:schemas:extension:custom:User"
3693
- ];
3694
- schemaNamespaces.some((namespace) => {
3695
- if (meResponse[namespace]) {
3696
- if (meResponse[namespace][name] !== void 0) {
3697
- value = meResponse[namespace][name];
3698
- return true;
3699
- }
3700
- const nestedValue = get_default(meResponse[namespace], name);
3701
- if (nestedValue !== void 0) {
3702
- value = nestedValue;
3703
- return true;
3704
- }
3705
- }
3706
- return false;
3707
- });
3658
+ }
3659
+ /**
3660
+ * Format message for Node.js terminal
3661
+ */
3662
+ formatForNode(level, message) {
3663
+ const parts = [];
3664
+ if (this.config.timestamps) {
3665
+ parts.push(`${COLORS.gray}[${this.getTimestamp()}]${COLORS.reset}`);
3708
3666
  }
3709
- if (value !== void 0) {
3710
- if (multiValued && !Array.isArray(value)) {
3711
- value = [value];
3667
+ if (this.config.prefix) {
3668
+ parts.push(`${COLORS.magenta}${this.config.prefix}${COLORS.reset}`);
3669
+ }
3670
+ if (this.config.showLevel) {
3671
+ const levelStr = this.getLevelString(level);
3672
+ let coloredLevel;
3673
+ switch (level) {
3674
+ case "debug":
3675
+ coloredLevel = `${COLORS.gray}[${levelStr}]${COLORS.reset}`;
3676
+ break;
3677
+ case "info":
3678
+ coloredLevel = `${COLORS.blue}[${levelStr}]${COLORS.reset}`;
3679
+ break;
3680
+ case "warn":
3681
+ coloredLevel = `${COLORS.yellow}[${levelStr}]${COLORS.reset}`;
3682
+ break;
3683
+ case "error":
3684
+ coloredLevel = `${COLORS.red}[${levelStr}]${COLORS.reset}`;
3685
+ break;
3686
+ default:
3687
+ coloredLevel = `[${levelStr}]`;
3712
3688
  }
3713
- } else if (multiValued) {
3714
- value = void 0;
3715
- } else if (type === "STRING") {
3716
- value = "";
3717
- } else {
3718
- value = void 0;
3689
+ parts.push(coloredLevel);
3719
3690
  }
3720
- profile[name] = value;
3721
- });
3722
- const flattenObject = (obj, prefix = "") => {
3723
- if (obj && typeof obj === "object" && !Array.isArray(obj)) {
3724
- Object.keys(obj).forEach((key) => {
3725
- const fullKey = prefix ? `${prefix}.${key}` : key;
3726
- const value = obj[key];
3727
- if (Object.prototype.hasOwnProperty.call(profile, fullKey)) {
3728
- return;
3729
- }
3730
- const hasSchemaChildProperties = allSchemaNames.some(
3731
- (schemaName) => schemaName.startsWith(`${fullKey}.`)
3732
- );
3733
- if (hasSchemaChildProperties) {
3734
- flattenObject(value, fullKey);
3735
- } else {
3736
- profile[fullKey] = value;
3737
- }
3738
- });
3691
+ parts.push(message);
3692
+ return parts.join(" ");
3693
+ }
3694
+ /**
3695
+ * Log message using appropriate method
3696
+ */
3697
+ logMessage(level, message, ...args) {
3698
+ if (!this.shouldLog(level)) {
3699
+ return;
3739
3700
  }
3740
- };
3741
- flattenObject(meResponse);
3742
- return profile;
3743
- };
3744
- var generateFlattenedUserProfile_default = generateFlattenedUserProfile;
3745
-
3746
- // src/i18n/index.ts
3747
- var i18n_exports = {};
3748
- __export(i18n_exports, {
3749
- en_US: () => en_US_default
3750
- });
3751
-
3752
- // src/i18n/en-US.ts
3753
- var translations = {
3754
- /* |---------------------------------------------------------------| */
3755
- /* | Elements | */
3756
- /* |---------------------------------------------------------------| */
3757
- //* Buttons */
3758
- "elements.buttons.signIn": "Sign In",
3759
- "elements.buttons.signOut": "Sign Out",
3760
- "elements.buttons.signUp": "Sign Up",
3761
- "elements.buttons.facebook": "Continue with Facebook",
3762
- "elements.buttons.google": "Continue with Google",
3763
- "elements.buttons.github": "Continue with GitHub",
3764
- "elements.buttons.microsoft": "Continue with Microsoft",
3765
- "elements.buttons.linkedin": "Continue with LinkedIn",
3766
- "elements.buttons.ethereum": "Continue with Sign In Ethereum",
3767
- "elements.buttons.multi.option": "Continue with {connection}",
3768
- "elements.buttons.social": "Continue with {connection}",
3769
- /* Fields */
3770
- "elements.fields.placeholder": "Enter your {field}",
3771
- /* |---------------------------------------------------------------| */
3772
- /* | Widgets | */
3773
- /* |---------------------------------------------------------------| */
3774
- /* Base Sign In */
3775
- "signin.title": "Sign In",
3776
- "signin.subtitle": "Enter your credentials to continue.",
3777
- /* Base Sign Up */
3778
- "signup.title": "Sign Up",
3779
- "signup.subtitle": "Create a new account to get started.",
3780
- /* Email OTP */
3781
- "email.otp.title": "OTP Verification",
3782
- "email.otp.subtitle": "Enter the code sent to your email address.",
3783
- "email.otp.submit.button": "Continue",
3784
- /* Identifier First */
3785
- "identifier.first.title": "Sign In",
3786
- "identifier.first.subtitle": "Enter your username or email address.",
3787
- "identifier.first.submit.button": "Continue",
3788
- /* SMS OTP */
3789
- "sms.otp.title": "OTP Verification",
3790
- "sms.otp.subtitle": "Enter the code sent to your phone number.",
3791
- "sms.otp.submit.button": "Continue",
3792
- /* TOTP */
3793
- "totp.title": "Verify Your Identity",
3794
- "totp.subtitle": "Enter the code from your authenticator app.",
3795
- "totp.submit.button": "Continue",
3796
- /* Username Password */
3797
- "username.password.submit.button": "Continue",
3798
- "username.password.title": "Sign In",
3799
- "username.password.subtitle": "Enter your username and password to continue.",
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
- /* |---------------------------------------------------------------| */
3806
- /* | Organization Switcher | */
3807
- /* |---------------------------------------------------------------| */
3808
- "organization.switcher.select.organization": "Select Organization",
3809
- "organization.switcher.switch.organization": "Switch Organization",
3810
- "organization.switcher.loading.organizations": "Loading organizations...",
3811
- "organization.switcher.members": "members",
3812
- "organization.switcher.member": "member",
3813
- "organization.switcher.create.organization": "Create Organization",
3814
- "organization.switcher.manage.organizations": "Manage Organizations",
3815
- "organization.switcher.manage.button": "Manage",
3816
- "organization.switcher.organizations.title": "Organizations",
3817
- "organization.switcher.switch.button": "Switch",
3818
- "organization.switcher.no.access": "No Access",
3819
- "organization.switcher.status.label": "Status:",
3820
- "organization.switcher.showing.count": "Showing {showing} of {total} organizations",
3821
- "organization.switcher.refresh.button": "Refresh",
3822
- "organization.switcher.load.more": "Load More Organizations",
3823
- "organization.switcher.loading.more": "Loading...",
3824
- "organization.switcher.no.organizations": "No organizations found",
3825
- "organization.switcher.error.prefix": "Error:",
3826
- "organization.profile.title": "Organization Profile",
3827
- "organization.profile.loading": "Loading organization...",
3828
- "organization.profile.error": "Failed to load organization",
3829
- "organization.create.title": "Create Organization",
3830
- "organization.create.name.label": "Organization Name",
3831
- "organization.create.name.placeholder": "Enter organization name",
3832
- "organization.create.handle.label": "Organization Handle",
3833
- "organization.create.handle.placeholder": "my-organization",
3834
- "organization.create.description.label": "Description",
3835
- "organization.create.description.placeholder": "Enter organization description",
3836
- "organization.create.button": "Create Organization",
3837
- "organization.create.creating": "Creating...",
3838
- "organization.create.cancel": "Cancel",
3839
- /* |---------------------------------------------------------------| */
3840
- /* | Messages | */
3841
- /* |---------------------------------------------------------------| */
3842
- "messages.loading": "Loading...",
3843
- /* |---------------------------------------------------------------| */
3844
- /* | Errors | */
3845
- /* |---------------------------------------------------------------| */
3846
- "errors.title": "Error",
3847
- "errors.sign.in.initialization": "An error occurred while initializing. Please try again later.",
3848
- "errors.sign.in.flow.failure": "An error occurred during the sign-in flow. Please try again later.",
3849
- "errors.sign.in.flow.completion.failure": "An error occurred while completing the sign-in flow. Please try again later.",
3850
- "errors.sign.in.flow.passkeys.failure": "An error occurred while signing in with passkeys. Please try again later.",
3851
- "errors.sign.in.flow.passkeys.completion.failure": "An error occurred while completing the passkeys sign-in flow. Please try again later."
3852
- };
3853
- var metadata = {
3854
- localeCode: "en-US",
3855
- countryCode: "US",
3856
- languageCode: "en",
3857
- displayName: "English (United States)",
3858
- direction: "ltr"
3859
- };
3860
- var en_US = {
3861
- metadata,
3862
- translations
3863
- };
3864
- var en_US_default = en_US;
3865
-
3866
- // src/utils/getI18nBundles.ts
3867
- var getI18nBundles = () => {
3868
- return i18n_exports;
3869
- };
3870
- var getI18nBundles_default = getI18nBundles;
3871
-
3872
- // src/utils/removeTrailingSlash.ts
3873
- var removeTrailingSlash = (path) => path.endsWith("/") ? path.slice(0, -1) : path;
3874
- var removeTrailingSlash_default = removeTrailingSlash;
3875
-
3876
- // src/utils/resolveFieldType.ts
3877
- var resolveFieldType = (field) => {
3878
- if (field.type === "STRING" /* String */) {
3879
- if (field.param === "OTPCode" /* Otp */) {
3880
- return "OTP" /* Otp */;
3881
- } else if (field?.confidential) {
3882
- return "PASSWORD" /* Password */;
3701
+ if (this.config.formatter) {
3702
+ this.config.formatter(level, message, ...args);
3703
+ return;
3704
+ }
3705
+ if (isBrowser()) {
3706
+ this.logToBrowser(level, message, ...args);
3707
+ } else if (isNode()) {
3708
+ this.logToNode(level, message, ...args);
3709
+ } else {
3710
+ console.log(message, ...args);
3883
3711
  }
3884
- return "TEXT" /* Text */;
3885
- }
3886
- throw new AsgardeoRuntimeError(
3887
- "Field type is not supported: " + field.type,
3888
- "resolveFieldType-Invalid-001",
3889
- "javascript",
3890
- "The provided field type is not supported. Please check the field configuration."
3891
- );
3892
- };
3893
- var resolveFieldType_default = resolveFieldType;
3894
-
3895
- // src/utils/resolveFieldName.ts
3896
- var resolveFieldName = (field) => {
3897
- if (field.param) {
3898
- return field.param;
3899
- }
3900
- throw new AsgardeoRuntimeError(
3901
- "Field name is not supported: ",
3902
- "resolveFieldName-Invalid-001",
3903
- "javascript",
3904
- "The provided field name is not supported. Please check the field configuration."
3905
- );
3906
- };
3907
- var resolveFieldName_default = resolveFieldName;
3908
-
3909
- // src/utils/withVendorCSSClassPrefix.ts
3910
- var withVendorCSSClassPrefix = (className) => `${VendorConstants_default.VENDOR_PREFIX}-${className}`;
3911
- var withVendorCSSClassPrefix_default = withVendorCSSClassPrefix;
3912
-
3913
- // src/utils/transformBrandingPreferenceToTheme.ts
3914
- var extractColorValue = (colorVariant, preferDark = false) => {
3915
- if (preferDark && colorVariant?.dark && colorVariant.dark.trim()) {
3916
- return colorVariant.dark;
3917
3712
  }
3918
- return colorVariant?.main;
3919
- };
3920
- var extractContrastText = (colorVariant) => {
3921
- return colorVariant?.contrastText;
3922
- };
3923
- var transformThemeVariant = (themeVariant, isDark = false) => {
3924
- const colors = themeVariant.colors;
3925
- const buttons = themeVariant.buttons;
3926
- const inputs = themeVariant.inputs;
3927
- const images = themeVariant.images;
3928
- const config = {
3929
- colors: {
3930
- action: {
3931
- active: isDark ? "rgba(255, 255, 255, 0.70)" : "rgba(0, 0, 0, 0.54)",
3932
- hover: isDark ? "rgba(255, 255, 255, 0.04)" : "rgba(0, 0, 0, 0.04)",
3933
- hoverOpacity: 0.04,
3934
- selected: isDark ? "rgba(255, 255, 255, 0.08)" : "rgba(0, 0, 0, 0.08)",
3935
- selectedOpacity: 0.08,
3936
- disabled: isDark ? "rgba(255, 255, 255, 0.26)" : "rgba(0, 0, 0, 0.26)",
3937
- disabledBackground: isDark ? "rgba(255, 255, 255, 0.12)" : "rgba(0, 0, 0, 0.12)",
3938
- disabledOpacity: 0.38,
3939
- focus: isDark ? "rgba(255, 255, 255, 0.12)" : "rgba(0, 0, 0, 0.12)",
3940
- focusOpacity: 0.12,
3941
- activatedOpacity: 0.12
3942
- },
3943
- primary: {
3944
- main: extractColorValue(colors?.primary, isDark),
3945
- contrastText: extractContrastText(colors?.primary),
3946
- dark: colors?.primary?.dark || colors?.primary?.main
3947
- },
3948
- secondary: {
3949
- main: extractColorValue(colors?.secondary, isDark),
3950
- contrastText: extractContrastText(colors?.secondary),
3951
- dark: colors?.secondary?.dark || colors?.secondary?.main
3952
- },
3953
- background: {
3954
- surface: extractColorValue(colors?.background?.surface, isDark),
3955
- disabled: extractColorValue(colors?.background?.surface, isDark),
3956
- dark: colors?.background?.surface?.dark || colors?.background?.surface?.main,
3957
- body: {
3958
- main: extractColorValue(colors?.background?.body, isDark),
3959
- dark: colors?.background?.body?.dark || colors?.background?.body?.main
3960
- }
3961
- },
3962
- text: {
3963
- primary: colors?.text?.primary,
3964
- secondary: colors?.text?.secondary,
3965
- dark: colors?.text?.dark || colors?.text?.primary
3966
- },
3967
- border: colors?.outlined?.default,
3968
- 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
3977
- },
3978
- success: {
3979
- main: extractColorValue(colors?.alerts?.neutral, isDark),
3980
- contrastText: extractContrastText(colors?.alerts?.neutral),
3981
- dark: colors?.alerts?.neutral?.dark || colors?.alerts?.neutral?.main
3982
- },
3983
- warning: {
3984
- main: extractColorValue(colors?.alerts?.warning, isDark),
3985
- contrastText: extractContrastText(colors?.alerts?.warning),
3986
- dark: colors?.alerts?.warning?.dark || colors?.alerts?.warning?.main
3987
- }
3988
- },
3989
- images: {
3990
- favicon: images?.favicon ? {
3991
- url: images.favicon.imgURL,
3992
- title: images.favicon.title,
3993
- alt: images.favicon.altText
3994
- } : void 0,
3995
- logo: images?.logo ? {
3996
- url: images.logo.imgURL,
3997
- title: images.logo.title,
3998
- alt: images.logo.altText
3999
- } : void 0
3713
+ /**
3714
+ * Log to browser console with styling
3715
+ */
3716
+ logToBrowser(level, message, ...args) {
3717
+ const parts = [];
3718
+ const styles = [];
3719
+ if (this.config.timestamps) {
3720
+ parts.push(`%c[${this.getTimestamp()}]`);
3721
+ styles.push(BROWSER_STYLES.timestamp);
4000
3722
  }
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
- }
3723
+ if (this.config.prefix) {
3724
+ parts.push(`%c${this.config.prefix}`);
3725
+ styles.push(BROWSER_STYLES.prefix);
3726
+ }
3727
+ if (this.config.showLevel) {
3728
+ const levelStr = this.getLevelString(level);
3729
+ parts.push(`%c[${levelStr}]`);
3730
+ switch (level) {
3731
+ case "debug":
3732
+ styles.push(BROWSER_STYLES.debug);
3733
+ break;
3734
+ case "info":
3735
+ styles.push(BROWSER_STYLES.info);
3736
+ break;
3737
+ case "warn":
3738
+ styles.push(BROWSER_STYLES.warn);
3739
+ break;
3740
+ case "error":
3741
+ styles.push(BROWSER_STYLES.error);
3742
+ break;
3743
+ default:
3744
+ styles.push("");
4023
3745
  }
4024
- };
4025
- }
4026
- return config;
4027
- };
4028
- var transformBrandingPreferenceToTheme = (brandingPreference, forceTheme) => {
4029
- const themeConfig = brandingPreference?.preference?.theme;
4030
- if (!themeConfig) {
4031
- return createTheme_default({}, false);
4032
- }
4033
- let activeThemeKey;
4034
- if (forceTheme) {
4035
- activeThemeKey = forceTheme.toUpperCase();
4036
- } else {
4037
- activeThemeKey = themeConfig.activeTheme || "LIGHT";
4038
- }
4039
- const themeVariant = themeConfig[activeThemeKey];
4040
- if (!themeVariant) {
4041
- const fallbackVariant = themeConfig.LIGHT || themeConfig.DARK;
4042
- if (fallbackVariant) {
4043
- const transformedConfig2 = transformThemeVariant(fallbackVariant, activeThemeKey === "DARK");
4044
- return createTheme_default(transformedConfig2, activeThemeKey === "DARK");
4045
3746
  }
4046
- return createTheme_default({}, activeThemeKey === "DARK");
3747
+ parts.push(`%c${message}`);
3748
+ styles.push("color: inherit; font-weight: normal;");
3749
+ const formattedMessage = parts.join(" ");
3750
+ switch (level) {
3751
+ case "debug":
3752
+ console.debug(formattedMessage, ...styles, ...args);
3753
+ break;
3754
+ case "info":
3755
+ console.info(formattedMessage, ...styles, ...args);
3756
+ break;
3757
+ case "warn":
3758
+ console.warn(formattedMessage, ...styles, ...args);
3759
+ break;
3760
+ case "error":
3761
+ console.error(formattedMessage, ...styles, ...args);
3762
+ break;
3763
+ default:
3764
+ console.log(formattedMessage, ...styles, ...args);
3765
+ }
4047
3766
  }
4048
- const transformedConfig = transformThemeVariant(themeVariant, activeThemeKey === "DARK");
4049
- return createTheme_default(transformedConfig, activeThemeKey === "DARK");
4050
- };
4051
- var transformBrandingPreferenceToTheme_default = transformBrandingPreferenceToTheme;
4052
-
4053
- // src/utils/logger.ts
4054
- var PREFIX = "\u{1F6E1}\uFE0F Asgardeo";
4055
- var DEFAULT_CONFIG = {
4056
- level: "info",
4057
- prefix: `${PREFIX}`,
4058
- timestamps: true,
4059
- showLevel: true
4060
- };
4061
- var isBrowser = () => {
4062
- return typeof window !== "undefined" && typeof window.document !== "undefined";
4063
- };
4064
- var isNode = () => {
4065
- return typeof process !== "undefined" && process.versions && process.versions.node;
4066
- };
4067
- var COLORS = {
4068
- reset: "\x1B[0m",
4069
- bright: "\x1B[1m",
4070
- dim: "\x1B[2m",
4071
- red: "\x1B[31m",
4072
- green: "\x1B[32m",
4073
- yellow: "\x1B[33m",
4074
- blue: "\x1B[34m",
4075
- magenta: "\x1B[35m",
4076
- cyan: "\x1B[36m",
4077
- white: "\x1B[37m",
4078
- gray: "\x1B[90m"
4079
- };
4080
- var BROWSER_STYLES = {
4081
- debug: "color: #6b7280; font-weight: normal;",
4082
- info: "color: #2563eb; font-weight: bold;",
4083
- warn: "color: #d97706; font-weight: bold;",
4084
- error: "color: #dc2626; font-weight: bold;",
4085
- prefix: "color: #7c3aed; font-weight: bold;",
4086
- timestamp: "color: #6b7280; font-size: 0.9em;"
4087
- };
4088
- var Logger = class _Logger {
4089
- constructor(config = {}) {
4090
- __publicField(this, "config");
4091
- this.config = { ...DEFAULT_CONFIG, ...config };
3767
+ /**
3768
+ * Log to Node.js console
3769
+ */
3770
+ logToNode(level, message, ...args) {
3771
+ const formattedMessage = this.formatForNode(level, message);
3772
+ switch (level) {
3773
+ case "debug":
3774
+ console.debug(formattedMessage, ...args);
3775
+ break;
3776
+ case "info":
3777
+ console.info(formattedMessage, ...args);
3778
+ break;
3779
+ case "warn":
3780
+ console.warn(formattedMessage, ...args);
3781
+ break;
3782
+ case "error":
3783
+ console.error(formattedMessage, ...args);
3784
+ break;
3785
+ default:
3786
+ console.log(formattedMessage, ...args);
3787
+ }
4092
3788
  }
4093
3789
  /**
4094
- * Update logger configuration
3790
+ * Log debug message
4095
3791
  */
4096
- configure(config) {
4097
- this.config = { ...this.config, ...config };
3792
+ debug(message, ...args) {
3793
+ this.logMessage("debug", message, ...args);
4098
3794
  }
4099
3795
  /**
4100
- * Get current configuration
3796
+ * Log info message
4101
3797
  */
4102
- getConfig() {
4103
- return { ...this.config };
3798
+ info(message, ...args) {
3799
+ this.logMessage("info", message, ...args);
4104
3800
  }
4105
3801
  /**
4106
- * Check if a log level should be output
3802
+ * Log warning message
4107
3803
  */
4108
- shouldLog(level) {
4109
- return level >= this.config.level;
3804
+ warn(message, ...args) {
3805
+ this.logMessage("warn", message, ...args);
4110
3806
  }
4111
3807
  /**
4112
- * Get timestamp string
3808
+ * Log error message
4113
3809
  */
4114
- getTimestamp() {
4115
- return (/* @__PURE__ */ new Date()).toISOString();
3810
+ error(message, ...args) {
3811
+ this.logMessage("error", message, ...args);
4116
3812
  }
4117
3813
  /**
4118
- * Get log level string
3814
+ * Create a child logger with additional prefix
4119
3815
  */
4120
- getLevelString(level) {
4121
- switch (level) {
4122
- case "debug":
4123
- return "DEBUG";
4124
- case "info":
4125
- return "INFO";
4126
- case "warn":
4127
- return "WARN";
4128
- case "error":
4129
- return "ERROR";
4130
- default:
4131
- return "UNKNOWN";
4132
- }
3816
+ child(prefix) {
3817
+ const childPrefix = this.config.prefix ? `${this.config.prefix} - ${prefix}` : prefix;
3818
+ return new _Logger({
3819
+ ...this.config,
3820
+ prefix: childPrefix
3821
+ });
4133
3822
  }
4134
3823
  /**
4135
- * Format message for Node.js terminal
3824
+ * Set log level
4136
3825
  */
4137
- formatForNode(level, message) {
4138
- const parts = [];
4139
- if (this.config.timestamps) {
4140
- parts.push(`${COLORS.gray}[${this.getTimestamp()}]${COLORS.reset}`);
3826
+ setLevel(level) {
3827
+ this.config.level = level;
3828
+ }
3829
+ /**
3830
+ * Get current log level
3831
+ */
3832
+ getLevel() {
3833
+ return this.config.level;
3834
+ }
3835
+ };
3836
+ var logger = new Logger();
3837
+ var createLogger = (config) => {
3838
+ return new Logger(config);
3839
+ };
3840
+ var logger_default = logger;
3841
+ var debug = (message, ...args) => logger.debug(message, ...args);
3842
+ var info = (message, ...args) => logger.info(message, ...args);
3843
+ var warn = (message, ...args) => logger.warn(message, ...args);
3844
+ var error = (message, ...args) => logger.error(message, ...args);
3845
+ var configure = (config) => logger.configure(config);
3846
+ var createComponentLogger = (component) => {
3847
+ return logger.child(component);
3848
+ };
3849
+ var createPackageLogger = (packageName) => {
3850
+ return createLogger({
3851
+ prefix: `${PREFIX} - ${packageName}`,
3852
+ level: "info",
3853
+ timestamps: true,
3854
+ showLevel: true
3855
+ });
3856
+ };
3857
+ var createPackageComponentLogger = (packageName, component) => {
3858
+ const packageLogger = createPackageLogger(packageName);
3859
+ return packageLogger.child(component);
3860
+ };
3861
+
3862
+ // src/utils/isRecognizedBaseUrlPattern.ts
3863
+ var isRecognizedBaseUrlPattern = (baseUrl) => {
3864
+ if (!baseUrl) {
3865
+ throw new AsgardeoRuntimeError(
3866
+ "Base URL is required to derive if the `baseUrl` is recognized.",
3867
+ "isRecognizedBaseUrlPattern-ValidationError-001",
3868
+ "javascript",
3869
+ "A valid base URL must be provided to derive if the `baseUrl` is recognized to use the sensible fallbacks."
3870
+ );
3871
+ }
3872
+ let parsedUrl;
3873
+ try {
3874
+ parsedUrl = new URL(baseUrl);
3875
+ } catch (error2) {
3876
+ throw new AsgardeoRuntimeError(
3877
+ `Invalid base URL format: ${baseUrl}`,
3878
+ "isRecognizedBaseUrlPattern-ValidationError-002",
3879
+ "javascript",
3880
+ "The provided base URL does not conform to valid URL syntax."
3881
+ );
3882
+ }
3883
+ const pathSegments = parsedUrl.pathname?.split("/")?.filter((segment) => segment?.length > 0);
3884
+ if (pathSegments.length < 2 || pathSegments[0] !== "t") {
3885
+ logger_default.warn("[isRecognizedBaseUrlPattern] The provided base URL does not follow the expected URL pattern (/t/{orgHandle}).");
3886
+ return false;
3887
+ }
3888
+ return true;
3889
+ };
3890
+ var isRecognizedBaseUrlPattern_default = isRecognizedBaseUrlPattern;
3891
+
3892
+ // src/utils/flattenUserSchema.ts
3893
+ var flattenUserSchema = (schemas) => {
3894
+ const flattenedAttributes = [];
3895
+ schemas.forEach((schema) => {
3896
+ if (schema.attributes && Array.isArray(schema.attributes)) {
3897
+ schema.attributes.forEach((attribute) => {
3898
+ if (attribute.subAttributes && Array.isArray(attribute.subAttributes)) {
3899
+ attribute.subAttributes.forEach((subAttribute) => {
3900
+ flattenedAttributes.push({
3901
+ ...subAttribute,
3902
+ name: `${attribute.name}.${subAttribute.name}`,
3903
+ schemaId: schema.id
3904
+ });
3905
+ });
3906
+ } else {
3907
+ flattenedAttributes.push({
3908
+ ...attribute,
3909
+ schemaId: schema.id
3910
+ });
3911
+ }
3912
+ });
4141
3913
  }
4142
- if (this.config.prefix) {
4143
- parts.push(`${COLORS.magenta}${this.config.prefix}${COLORS.reset}`);
3914
+ });
3915
+ return flattenedAttributes;
3916
+ };
3917
+ var flattenUserSchema_default = flattenUserSchema;
3918
+
3919
+ // src/utils/get.ts
3920
+ var get = (object, path, defaultValue) => {
3921
+ if (!object || !path) return defaultValue;
3922
+ const pathArray = Array.isArray(path) ? path : path.split(".");
3923
+ const result = pathArray.reduce((current, key) => {
3924
+ return current?.[key];
3925
+ }, object);
3926
+ return result !== void 0 ? result : defaultValue;
3927
+ };
3928
+ var get_default = get;
3929
+
3930
+ // src/utils/set.ts
3931
+ var set = (object, path, value) => {
3932
+ if (!object || !path) return object;
3933
+ const pathArray = Array.isArray(path) ? path : path.split(".");
3934
+ const lastIndex = pathArray.length - 1;
3935
+ pathArray.reduce((current, key, index) => {
3936
+ if (index === lastIndex) {
3937
+ current[key] = value;
3938
+ } else {
3939
+ if (!(key in current) || typeof current[key] !== "object" || current[key] === null) {
3940
+ const nextKey = pathArray[index + 1];
3941
+ current[key] = /^\d+$/.test(nextKey) ? [] : {};
3942
+ }
4144
3943
  }
4145
- if (this.config.showLevel) {
4146
- const levelStr = this.getLevelString(level);
4147
- let coloredLevel;
4148
- switch (level) {
4149
- case "debug":
4150
- coloredLevel = `${COLORS.gray}[${levelStr}]${COLORS.reset}`;
4151
- break;
4152
- case "info":
4153
- coloredLevel = `${COLORS.blue}[${levelStr}]${COLORS.reset}`;
4154
- break;
4155
- case "warn":
4156
- coloredLevel = `${COLORS.yellow}[${levelStr}]${COLORS.reset}`;
4157
- break;
4158
- case "error":
4159
- coloredLevel = `${COLORS.red}[${levelStr}]${COLORS.reset}`;
4160
- break;
4161
- default:
4162
- coloredLevel = `[${levelStr}]`;
3944
+ return current[key];
3945
+ }, object);
3946
+ return object;
3947
+ };
3948
+ var set_default = set;
3949
+
3950
+ // src/utils/generateUserProfile.ts
3951
+ var generateUserProfile = (meResponse, processedSchemas) => {
3952
+ const profile = {};
3953
+ processedSchemas.forEach((schema) => {
3954
+ const { name, type, multiValued } = schema;
3955
+ if (!name) return;
3956
+ let value = get_default(meResponse, name);
3957
+ if (value !== void 0) {
3958
+ if (multiValued && !Array.isArray(value)) {
3959
+ value = [value];
3960
+ }
3961
+ } else {
3962
+ if (multiValued) {
3963
+ value = void 0;
3964
+ } else if (type === "STRING") {
3965
+ value = "";
3966
+ } else {
3967
+ value = void 0;
4163
3968
  }
4164
- parts.push(coloredLevel);
4165
3969
  }
4166
- parts.push(message);
4167
- return parts.join(" ");
3970
+ set_default(profile, name, value);
3971
+ });
3972
+ return profile;
3973
+ };
3974
+ var generateUserProfile_default = generateUserProfile;
3975
+
3976
+ // src/utils/getLatestStateParam.ts
3977
+ var getLatestPkceStorageKey = (tempStore) => {
3978
+ const keys = [];
3979
+ Object.keys(tempStore).forEach((key) => {
3980
+ if (key.startsWith(PKCEConstants_default.Storage.StorageKeys.CODE_VERIFIER)) {
3981
+ keys.push(key);
3982
+ }
3983
+ });
3984
+ const lastKey = keys.sort().pop();
3985
+ return lastKey ?? null;
3986
+ };
3987
+ var getLatestStateParam = (tempStore, state) => {
3988
+ const latestPkceKey = getLatestPkceStorageKey(tempStore);
3989
+ if (!latestPkceKey) {
3990
+ return null;
4168
3991
  }
4169
- /**
4170
- * Log message using appropriate method
4171
- */
4172
- logMessage(level, message, ...args) {
4173
- if (!this.shouldLog(level)) {
3992
+ return generateStateParamForRequestCorrelation_default(latestPkceKey, state);
3993
+ };
3994
+ var getLatestStateParam_default = getLatestStateParam;
3995
+
3996
+ // src/utils/generateFlattenedUserProfile.ts
3997
+ var generateFlattenedUserProfile = (meResponse, processedSchemas) => {
3998
+ const profile = {};
3999
+ const allSchemaNames = processedSchemas.map((schema) => schema.name).filter(Boolean);
4000
+ processedSchemas.forEach((schema) => {
4001
+ const { name, type, multiValued } = schema;
4002
+ if (!name) return;
4003
+ const hasChildProperties = allSchemaNames.some(
4004
+ (schemaName) => schemaName !== name && schemaName.startsWith(`${name}.`)
4005
+ );
4006
+ if (hasChildProperties) {
4174
4007
  return;
4175
4008
  }
4176
- if (this.config.formatter) {
4177
- this.config.formatter(level, message, ...args);
4178
- return;
4009
+ let value = get_default(meResponse, name);
4010
+ if (value === void 0) {
4011
+ const schemaNamespaces = [
4012
+ "urn:ietf:params:scim:schemas:core:2.0:User",
4013
+ "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User",
4014
+ "urn:scim:wso2:schema",
4015
+ "urn:scim:schemas:extension:custom:User"
4016
+ ];
4017
+ schemaNamespaces.some((namespace) => {
4018
+ if (meResponse[namespace]) {
4019
+ if (meResponse[namespace][name] !== void 0) {
4020
+ value = meResponse[namespace][name];
4021
+ return true;
4022
+ }
4023
+ const nestedValue = get_default(meResponse[namespace], name);
4024
+ if (nestedValue !== void 0) {
4025
+ value = nestedValue;
4026
+ return true;
4027
+ }
4028
+ }
4029
+ return false;
4030
+ });
4179
4031
  }
4180
- if (isBrowser()) {
4181
- this.logToBrowser(level, message, ...args);
4182
- } else if (isNode()) {
4183
- this.logToNode(level, message, ...args);
4032
+ if (value !== void 0) {
4033
+ if (multiValued && !Array.isArray(value)) {
4034
+ value = [value];
4035
+ }
4036
+ } else if (multiValued) {
4037
+ value = void 0;
4038
+ } else if (type === "STRING") {
4039
+ value = "";
4184
4040
  } else {
4185
- console.log(message, ...args);
4186
- }
4187
- }
4188
- /**
4189
- * Log to browser console with styling
4190
- */
4191
- logToBrowser(level, message, ...args) {
4192
- const parts = [];
4193
- const styles = [];
4194
- if (this.config.timestamps) {
4195
- parts.push(`%c[${this.getTimestamp()}]`);
4196
- styles.push(BROWSER_STYLES.timestamp);
4041
+ value = void 0;
4197
4042
  }
4198
- if (this.config.prefix) {
4199
- parts.push(`%c${this.config.prefix}`);
4200
- styles.push(BROWSER_STYLES.prefix);
4043
+ profile[name] = value;
4044
+ });
4045
+ const flattenObject = (obj, prefix = "") => {
4046
+ if (obj && typeof obj === "object" && !Array.isArray(obj)) {
4047
+ Object.keys(obj).forEach((key) => {
4048
+ const fullKey = prefix ? `${prefix}.${key}` : key;
4049
+ const value = obj[key];
4050
+ if (Object.prototype.hasOwnProperty.call(profile, fullKey)) {
4051
+ return;
4052
+ }
4053
+ const hasSchemaChildProperties = allSchemaNames.some(
4054
+ (schemaName) => schemaName.startsWith(`${fullKey}.`)
4055
+ );
4056
+ if (hasSchemaChildProperties) {
4057
+ flattenObject(value, fullKey);
4058
+ } else {
4059
+ profile[fullKey] = value;
4060
+ }
4061
+ });
4201
4062
  }
4202
- if (this.config.showLevel) {
4203
- const levelStr = this.getLevelString(level);
4204
- parts.push(`%c[${levelStr}]`);
4205
- switch (level) {
4206
- case "debug":
4207
- styles.push(BROWSER_STYLES.debug);
4208
- break;
4209
- case "info":
4210
- styles.push(BROWSER_STYLES.info);
4211
- break;
4212
- case "warn":
4213
- styles.push(BROWSER_STYLES.warn);
4214
- break;
4215
- case "error":
4216
- styles.push(BROWSER_STYLES.error);
4217
- break;
4218
- default:
4219
- styles.push("");
4063
+ };
4064
+ flattenObject(meResponse);
4065
+ return profile;
4066
+ };
4067
+ var generateFlattenedUserProfile_default = generateFlattenedUserProfile;
4068
+
4069
+ // src/utils/identifyPlatform.ts
4070
+ var identifyPlatform = (config) => {
4071
+ const { baseUrl } = config;
4072
+ try {
4073
+ if (isRecognizedBaseUrlPattern_default(baseUrl)) {
4074
+ try {
4075
+ const url = new URL(baseUrl);
4076
+ if (/\.asgardeo\.io$/i.test(url.hostname) || /asgardeo\.io$/i.test(url.hostname)) {
4077
+ return "ASGARDEO" /* Asgardeo */;
4078
+ }
4079
+ } catch {
4080
+ logger_default.debug(
4081
+ `[identifyPlatform] Could not identify platform from the base URL: ${baseUrl}. Defaulting to WSO2 Identity Server as the platform.`
4082
+ );
4220
4083
  }
4084
+ return "IDENTITY_SERVER" /* IdentityServer */;
4221
4085
  }
4222
- parts.push(`%c${message}`);
4223
- styles.push("color: inherit; font-weight: normal;");
4224
- const formattedMessage = parts.join(" ");
4225
- switch (level) {
4226
- case "debug":
4227
- console.debug(formattedMessage, ...styles, ...args);
4228
- break;
4229
- case "info":
4230
- console.info(formattedMessage, ...styles, ...args);
4231
- break;
4232
- case "warn":
4233
- console.warn(formattedMessage, ...styles, ...args);
4234
- break;
4235
- case "error":
4236
- console.error(formattedMessage, ...styles, ...args);
4237
- break;
4238
- default:
4239
- console.log(formattedMessage, ...styles, ...args);
4086
+ return "UNKNOWN" /* Unknown */;
4087
+ } catch (error2) {
4088
+ logger_default.debug(`[identifyPlatform] Error identifying platform from base URL: ${baseUrl}. Error: ${error2.message}`);
4089
+ return "UNKNOWN" /* Unknown */;
4090
+ }
4091
+ };
4092
+ var identifyPlatform_default = identifyPlatform;
4093
+
4094
+ // src/utils/getRedirectBasedSignUpUrl.ts
4095
+ var getRedirectBasedSignUpUrl = (config) => {
4096
+ const { baseUrl } = config;
4097
+ if (!isRecognizedBaseUrlPattern_default(baseUrl)) return "";
4098
+ let signUpBaseUrl = baseUrl;
4099
+ if (identifyPlatform_default(config) === "ASGARDEO" /* Asgardeo */) {
4100
+ try {
4101
+ const url2 = new URL(baseUrl);
4102
+ if (/([a-z0-9-]+\.)*api\.asgardeo\.io$/i.test(url2.hostname)) {
4103
+ url2.hostname = url2.hostname.replace("api.", "accounts.");
4104
+ signUpBaseUrl = url2.toString().replace(/\/$/, "");
4105
+ }
4106
+ } catch {
4107
+ logger_default.debug(
4108
+ `[getRedirectBasedSignUpUrl] Could not parse base URL to replace 'api.' with 'accounts.'. Base URL: ${baseUrl}`
4109
+ );
4240
4110
  }
4241
4111
  }
4242
- /**
4243
- * Log to Node.js console
4244
- */
4245
- logToNode(level, message, ...args) {
4246
- const formattedMessage = this.formatForNode(level, message);
4247
- switch (level) {
4248
- case "debug":
4249
- console.debug(formattedMessage, ...args);
4250
- break;
4251
- case "info":
4252
- console.info(formattedMessage, ...args);
4253
- break;
4254
- case "warn":
4255
- console.warn(formattedMessage, ...args);
4256
- break;
4257
- case "error":
4258
- console.error(formattedMessage, ...args);
4259
- break;
4260
- default:
4261
- console.log(formattedMessage, ...args);
4112
+ const url = new URL(signUpBaseUrl + "/accountrecoveryendpoint/register.do");
4113
+ if (config.clientId) {
4114
+ url.searchParams.set("client_id", config.clientId);
4115
+ }
4116
+ if (config.applicationId) {
4117
+ url.searchParams.set("spId", config.applicationId);
4118
+ }
4119
+ logger_default.debug(`[getRedirectBasedSignUpUrl] Generated sign-up URL: ${url.toString()}`);
4120
+ return url.toString();
4121
+ };
4122
+ var getRedirectBasedSignUpUrl_default = getRedirectBasedSignUpUrl;
4123
+
4124
+ // src/i18n/index.ts
4125
+ var i18n_exports = {};
4126
+ __export(i18n_exports, {
4127
+ en_US: () => en_US_default
4128
+ });
4129
+
4130
+ // src/i18n/en-US.ts
4131
+ var translations = {
4132
+ /* |---------------------------------------------------------------| */
4133
+ /* | Elements | */
4134
+ /* |---------------------------------------------------------------| */
4135
+ //* Buttons */
4136
+ "elements.buttons.signIn": "Sign In",
4137
+ "elements.buttons.signOut": "Sign Out",
4138
+ "elements.buttons.signUp": "Sign Up",
4139
+ "elements.buttons.facebook": "Continue with Facebook",
4140
+ "elements.buttons.google": "Continue with Google",
4141
+ "elements.buttons.github": "Continue with GitHub",
4142
+ "elements.buttons.microsoft": "Continue with Microsoft",
4143
+ "elements.buttons.linkedin": "Continue with LinkedIn",
4144
+ "elements.buttons.ethereum": "Continue with Sign In Ethereum",
4145
+ "elements.buttons.multi.option": "Continue with {connection}",
4146
+ "elements.buttons.social": "Continue with {connection}",
4147
+ /* Fields */
4148
+ "elements.fields.placeholder": "Enter your {field}",
4149
+ /* |---------------------------------------------------------------| */
4150
+ /* | Widgets | */
4151
+ /* |---------------------------------------------------------------| */
4152
+ /* Base Sign In */
4153
+ "signin.title": "Sign In",
4154
+ "signin.subtitle": "Enter your credentials to continue.",
4155
+ /* Base Sign Up */
4156
+ "signup.title": "Sign Up",
4157
+ "signup.subtitle": "Create a new account to get started.",
4158
+ /* Email OTP */
4159
+ "email.otp.title": "OTP Verification",
4160
+ "email.otp.subtitle": "Enter the code sent to your email address.",
4161
+ "email.otp.submit.button": "Continue",
4162
+ /* Identifier First */
4163
+ "identifier.first.title": "Sign In",
4164
+ "identifier.first.subtitle": "Enter your username or email address.",
4165
+ "identifier.first.submit.button": "Continue",
4166
+ /* SMS OTP */
4167
+ "sms.otp.title": "OTP Verification",
4168
+ "sms.otp.subtitle": "Enter the code sent to your phone number.",
4169
+ "sms.otp.submit.button": "Continue",
4170
+ /* TOTP */
4171
+ "totp.title": "Verify Your Identity",
4172
+ "totp.subtitle": "Enter the code from your authenticator app.",
4173
+ "totp.submit.button": "Continue",
4174
+ /* Username Password */
4175
+ "username.password.submit.button": "Continue",
4176
+ "username.password.title": "Sign In",
4177
+ "username.password.subtitle": "Enter your username and password to continue.",
4178
+ /* |---------------------------------------------------------------| */
4179
+ /* | User Profile | */
4180
+ /* |---------------------------------------------------------------| */
4181
+ "user.profile.title": "Profile",
4182
+ "user.profile.update.generic.error": "An error occurred while updating your profile. Please try again.",
4183
+ /* |---------------------------------------------------------------| */
4184
+ /* | Organization Switcher | */
4185
+ /* |---------------------------------------------------------------| */
4186
+ "organization.switcher.select.organization": "Select Organization",
4187
+ "organization.switcher.switch.organization": "Switch Organization",
4188
+ "organization.switcher.loading.organizations": "Loading organizations...",
4189
+ "organization.switcher.members": "members",
4190
+ "organization.switcher.member": "member",
4191
+ "organization.switcher.create.organization": "Create Organization",
4192
+ "organization.switcher.manage.organizations": "Manage Organizations",
4193
+ "organization.switcher.manage.button": "Manage",
4194
+ "organization.switcher.organizations.title": "Organizations",
4195
+ "organization.switcher.switch.button": "Switch",
4196
+ "organization.switcher.no.access": "No Access",
4197
+ "organization.switcher.status.label": "Status:",
4198
+ "organization.switcher.showing.count": "Showing {showing} of {total} organizations",
4199
+ "organization.switcher.refresh.button": "Refresh",
4200
+ "organization.switcher.load.more": "Load More Organizations",
4201
+ "organization.switcher.loading.more": "Loading...",
4202
+ "organization.switcher.no.organizations": "No organizations found",
4203
+ "organization.switcher.error.prefix": "Error:",
4204
+ "organization.profile.title": "Organization Profile",
4205
+ "organization.profile.loading": "Loading organization...",
4206
+ "organization.profile.error": "Failed to load organization",
4207
+ "organization.create.title": "Create Organization",
4208
+ "organization.create.name.label": "Organization Name",
4209
+ "organization.create.name.placeholder": "Enter organization name",
4210
+ "organization.create.handle.label": "Organization Handle",
4211
+ "organization.create.handle.placeholder": "my-organization",
4212
+ "organization.create.description.label": "Description",
4213
+ "organization.create.description.placeholder": "Enter organization description",
4214
+ "organization.create.button": "Create Organization",
4215
+ "organization.create.creating": "Creating...",
4216
+ "organization.create.cancel": "Cancel",
4217
+ /* |---------------------------------------------------------------| */
4218
+ /* | Messages | */
4219
+ /* |---------------------------------------------------------------| */
4220
+ "messages.loading": "Loading...",
4221
+ /* |---------------------------------------------------------------| */
4222
+ /* | Errors | */
4223
+ /* |---------------------------------------------------------------| */
4224
+ "errors.title": "Error",
4225
+ "errors.sign.in.initialization": "An error occurred while initializing. Please try again later.",
4226
+ "errors.sign.in.flow.failure": "An error occurred during the sign-in flow. Please try again later.",
4227
+ "errors.sign.in.flow.completion.failure": "An error occurred while completing the sign-in flow. Please try again later.",
4228
+ "errors.sign.in.flow.passkeys.failure": "An error occurred while signing in with passkeys. Please try again later.",
4229
+ "errors.sign.in.flow.passkeys.completion.failure": "An error occurred while completing the passkeys sign-in flow. Please try again later."
4230
+ };
4231
+ var metadata = {
4232
+ localeCode: "en-US",
4233
+ countryCode: "US",
4234
+ languageCode: "en",
4235
+ displayName: "English (United States)",
4236
+ direction: "ltr"
4237
+ };
4238
+ var en_US = {
4239
+ metadata,
4240
+ translations
4241
+ };
4242
+ var en_US_default = en_US;
4243
+
4244
+ // src/utils/getI18nBundles.ts
4245
+ var getI18nBundles = () => {
4246
+ return i18n_exports;
4247
+ };
4248
+ var getI18nBundles_default = getI18nBundles;
4249
+
4250
+ // src/utils/removeTrailingSlash.ts
4251
+ var removeTrailingSlash = (path) => path.endsWith("/") ? path.slice(0, -1) : path;
4252
+ var removeTrailingSlash_default = removeTrailingSlash;
4253
+
4254
+ // src/utils/resolveFieldType.ts
4255
+ var resolveFieldType = (field) => {
4256
+ if (field.type === "STRING" /* String */) {
4257
+ if (field.param === "OTPCode" /* Otp */) {
4258
+ return "OTP" /* Otp */;
4259
+ } else if (field?.confidential) {
4260
+ return "PASSWORD" /* Password */;
4262
4261
  }
4262
+ return "TEXT" /* Text */;
4263
4263
  }
4264
- /**
4265
- * Log debug message
4266
- */
4267
- debug(message, ...args) {
4268
- this.logMessage("debug", message, ...args);
4269
- }
4270
- /**
4271
- * Log info message
4272
- */
4273
- info(message, ...args) {
4274
- this.logMessage("info", message, ...args);
4264
+ throw new AsgardeoRuntimeError(
4265
+ "Field type is not supported: " + field.type,
4266
+ "resolveFieldType-Invalid-001",
4267
+ "javascript",
4268
+ "The provided field type is not supported. Please check the field configuration."
4269
+ );
4270
+ };
4271
+ var resolveFieldType_default = resolveFieldType;
4272
+
4273
+ // src/utils/resolveFieldName.ts
4274
+ var resolveFieldName = (field) => {
4275
+ if (field.param) {
4276
+ return field.param;
4275
4277
  }
4276
- /**
4277
- * Log warning message
4278
- */
4279
- warn(message, ...args) {
4280
- this.logMessage("warn", message, ...args);
4278
+ throw new AsgardeoRuntimeError(
4279
+ "Field name is not supported: ",
4280
+ "resolveFieldName-Invalid-001",
4281
+ "javascript",
4282
+ "The provided field name is not supported. Please check the field configuration."
4283
+ );
4284
+ };
4285
+ var resolveFieldName_default = resolveFieldName;
4286
+
4287
+ // src/utils/withVendorCSSClassPrefix.ts
4288
+ var withVendorCSSClassPrefix = (className) => `${VendorConstants_default.VENDOR_PREFIX}-${className}`;
4289
+ var withVendorCSSClassPrefix_default = withVendorCSSClassPrefix;
4290
+
4291
+ // src/utils/transformBrandingPreferenceToTheme.ts
4292
+ var extractColorValue = (colorVariant, preferDark = false) => {
4293
+ if (preferDark && colorVariant?.dark && colorVariant.dark.trim()) {
4294
+ return colorVariant.dark;
4281
4295
  }
4282
- /**
4283
- * Log error message
4284
- */
4285
- error(message, ...args) {
4286
- this.logMessage("error", message, ...args);
4296
+ return colorVariant?.main;
4297
+ };
4298
+ var extractContrastText = (colorVariant) => {
4299
+ return colorVariant?.contrastText;
4300
+ };
4301
+ var transformThemeVariant = (themeVariant, isDark = false) => {
4302
+ const colors = themeVariant.colors;
4303
+ const buttons = themeVariant.buttons;
4304
+ const inputs = themeVariant.inputs;
4305
+ const images = themeVariant.images;
4306
+ const config = {
4307
+ colors: {
4308
+ action: {
4309
+ active: isDark ? "rgba(255, 255, 255, 0.70)" : "rgba(0, 0, 0, 0.54)",
4310
+ hover: isDark ? "rgba(255, 255, 255, 0.04)" : "rgba(0, 0, 0, 0.04)",
4311
+ hoverOpacity: 0.04,
4312
+ selected: isDark ? "rgba(255, 255, 255, 0.08)" : "rgba(0, 0, 0, 0.08)",
4313
+ selectedOpacity: 0.08,
4314
+ disabled: isDark ? "rgba(255, 255, 255, 0.26)" : "rgba(0, 0, 0, 0.26)",
4315
+ disabledBackground: isDark ? "rgba(255, 255, 255, 0.12)" : "rgba(0, 0, 0, 0.12)",
4316
+ disabledOpacity: 0.38,
4317
+ focus: isDark ? "rgba(255, 255, 255, 0.12)" : "rgba(0, 0, 0, 0.12)",
4318
+ focusOpacity: 0.12,
4319
+ activatedOpacity: 0.12
4320
+ },
4321
+ primary: {
4322
+ main: extractColorValue(colors?.primary, isDark),
4323
+ contrastText: extractContrastText(colors?.primary),
4324
+ dark: colors?.primary?.dark || colors?.primary?.main
4325
+ },
4326
+ secondary: {
4327
+ main: extractColorValue(colors?.secondary, isDark),
4328
+ contrastText: extractContrastText(colors?.secondary),
4329
+ dark: colors?.secondary?.dark || colors?.secondary?.main
4330
+ },
4331
+ background: {
4332
+ surface: extractColorValue(colors?.background?.surface, isDark),
4333
+ disabled: extractColorValue(colors?.background?.surface, isDark),
4334
+ dark: colors?.background?.surface?.dark || colors?.background?.surface?.main,
4335
+ body: {
4336
+ main: extractColorValue(colors?.background?.body, isDark),
4337
+ dark: colors?.background?.body?.dark || colors?.background?.body?.main
4338
+ }
4339
+ },
4340
+ text: {
4341
+ primary: colors?.text?.primary,
4342
+ secondary: colors?.text?.secondary,
4343
+ dark: colors?.text?.dark || colors?.text?.primary
4344
+ },
4345
+ border: colors?.outlined?.default,
4346
+ error: {
4347
+ main: extractColorValue(colors?.alerts?.error, isDark),
4348
+ contrastText: extractContrastText(colors?.alerts?.error),
4349
+ dark: colors?.alerts?.error?.dark || colors?.alerts?.error?.main
4350
+ },
4351
+ info: {
4352
+ main: extractColorValue(colors?.alerts?.info, isDark),
4353
+ contrastText: extractContrastText(colors?.alerts?.info),
4354
+ dark: colors?.alerts?.info?.dark || colors?.alerts?.info?.main
4355
+ },
4356
+ success: {
4357
+ main: extractColorValue(colors?.alerts?.neutral, isDark),
4358
+ contrastText: extractContrastText(colors?.alerts?.neutral),
4359
+ dark: colors?.alerts?.neutral?.dark || colors?.alerts?.neutral?.main
4360
+ },
4361
+ warning: {
4362
+ main: extractColorValue(colors?.alerts?.warning, isDark),
4363
+ contrastText: extractContrastText(colors?.alerts?.warning),
4364
+ dark: colors?.alerts?.warning?.dark || colors?.alerts?.warning?.main
4365
+ }
4366
+ },
4367
+ images: {
4368
+ favicon: images?.favicon ? {
4369
+ url: images.favicon.imgURL,
4370
+ title: images.favicon.title,
4371
+ alt: images.favicon.altText
4372
+ } : void 0,
4373
+ logo: images?.logo ? {
4374
+ url: images.logo.imgURL,
4375
+ title: images.logo.title,
4376
+ alt: images.logo.altText
4377
+ } : void 0
4378
+ }
4379
+ };
4380
+ const buttonBorderRadius = buttons?.primary?.base?.border?.borderRadius;
4381
+ const fieldBorderRadius = inputs?.base?.border?.borderRadius;
4382
+ if (buttonBorderRadius || fieldBorderRadius) {
4383
+ config.components = {
4384
+ ...buttonBorderRadius && {
4385
+ Button: {
4386
+ styleOverrides: {
4387
+ root: {
4388
+ borderRadius: buttonBorderRadius
4389
+ }
4390
+ }
4391
+ }
4392
+ },
4393
+ ...fieldBorderRadius && {
4394
+ Field: {
4395
+ styleOverrides: {
4396
+ root: {
4397
+ borderRadius: fieldBorderRadius
4398
+ }
4399
+ }
4400
+ }
4401
+ }
4402
+ };
4287
4403
  }
4288
- /**
4289
- * Create a child logger with additional prefix
4290
- */
4291
- child(prefix) {
4292
- const childPrefix = this.config.prefix ? `${this.config.prefix} - ${prefix}` : prefix;
4293
- return new _Logger({
4294
- ...this.config,
4295
- prefix: childPrefix
4296
- });
4404
+ return config;
4405
+ };
4406
+ var transformBrandingPreferenceToTheme = (brandingPreference, forceTheme) => {
4407
+ const themeConfig = brandingPreference?.preference?.theme;
4408
+ if (!themeConfig) {
4409
+ return createTheme_default({}, false);
4297
4410
  }
4298
- /**
4299
- * Set log level
4300
- */
4301
- setLevel(level) {
4302
- this.config.level = level;
4411
+ let activeThemeKey;
4412
+ if (forceTheme) {
4413
+ activeThemeKey = forceTheme.toUpperCase();
4414
+ } else {
4415
+ activeThemeKey = themeConfig.activeTheme || "LIGHT";
4303
4416
  }
4304
- /**
4305
- * Get current log level
4306
- */
4307
- getLevel() {
4308
- return this.config.level;
4417
+ const themeVariant = themeConfig[activeThemeKey];
4418
+ if (!themeVariant) {
4419
+ const fallbackVariant = themeConfig.LIGHT || themeConfig.DARK;
4420
+ if (fallbackVariant) {
4421
+ const transformedConfig2 = transformThemeVariant(fallbackVariant, activeThemeKey === "DARK");
4422
+ return createTheme_default(transformedConfig2, activeThemeKey === "DARK");
4423
+ }
4424
+ return createTheme_default({}, activeThemeKey === "DARK");
4309
4425
  }
4426
+ const transformedConfig = transformThemeVariant(themeVariant, activeThemeKey === "DARK");
4427
+ return createTheme_default(transformedConfig, activeThemeKey === "DARK");
4310
4428
  };
4311
- var logger = new Logger();
4312
- var createLogger = (config) => {
4313
- return new Logger(config);
4314
- };
4315
- var logger_default = logger;
4316
- var debug = (message, ...args) => logger.debug(message, ...args);
4317
- var info = (message, ...args) => logger.info(message, ...args);
4318
- var warn = (message, ...args) => logger.warn(message, ...args);
4319
- var error = (message, ...args) => logger.error(message, ...args);
4320
- var configure = (config) => logger.configure(config);
4321
- var createComponentLogger = (component) => {
4322
- return logger.child(component);
4323
- };
4324
- var createPackageLogger = (packageName) => {
4325
- return createLogger({
4326
- prefix: `${PREFIX} - ${packageName}`,
4327
- level: "info",
4328
- timestamps: true,
4329
- showLevel: true
4330
- });
4331
- };
4332
- var createPackageComponentLogger = (packageName, component) => {
4333
- const packageLogger = createPackageLogger(packageName);
4334
- return packageLogger.child(component);
4335
- };
4429
+ var transformBrandingPreferenceToTheme_default = transformBrandingPreferenceToTheme;
4336
4430
  export {
4337
4431
  ApplicationNativeAuthenticationConstants_default as ApplicationNativeAuthenticationConstants,
4338
4432
  AsgardeoAPIError,
@@ -4341,6 +4435,7 @@ export {
4341
4435
  AsgardeoError,
4342
4436
  AsgardeoJavaScriptClient_default as AsgardeoJavaScriptClient,
4343
4437
  AsgardeoRuntimeError,
4438
+ DEFAULT_THEME,
4344
4439
  EmbeddedFlowComponentType,
4345
4440
  EmbeddedFlowResponseType,
4346
4441
  EmbeddedFlowStatus,
@@ -4355,6 +4450,7 @@ export {
4355
4450
  FlowMode,
4356
4451
  IsomorphicCrypto,
4357
4452
  OIDCRequestConstants_default as OIDCRequestConstants,
4453
+ Platform,
4358
4454
  StorageManager_default as StorageManager,
4359
4455
  TokenConstants_default as TokenConstants,
4360
4456
  VendorConstants_default as VendorConstants,
@@ -4387,12 +4483,15 @@ export {
4387
4483
  getLatestStateParam_default as getLatestStateParam,
4388
4484
  getMeOrganizations_default as getMeOrganizations,
4389
4485
  getOrganization_default as getOrganization,
4486
+ getRedirectBasedSignUpUrl_default as getRedirectBasedSignUpUrl,
4390
4487
  getSchemas_default as getSchemas,
4391
4488
  getScim2Me_default as getScim2Me,
4392
4489
  getUserInfo_default as getUserInfo,
4490
+ identifyPlatform_default as identifyPlatform,
4393
4491
  info,
4394
4492
  initializeEmbeddedSignInFlow_default as initializeEmbeddedSignInFlow,
4395
4493
  isEmpty_default as isEmpty,
4494
+ isRecognizedBaseUrlPattern_default as isRecognizedBaseUrlPattern,
4396
4495
  logger_default as logger,
4397
4496
  processOpenIDScopes_default as processOpenIDScopes,
4398
4497
  processUsername_default as processUsername,