@asgardeo/javascript 0.1.14 → 0.1.16

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