@asgardeo/javascript 0.20.1 → 0.22.0
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/__legacy__/client.d.ts.map +1 -1
- package/dist/__legacy__/models/client-config.d.ts +9 -0
- package/dist/__legacy__/models/client-config.d.ts.map +1 -1
- package/dist/api/getBrandingPreference.d.ts.map +1 -1
- package/dist/cjs/index.js +894 -856
- package/dist/cjs/index.js.map +4 -4
- package/dist/edge/index.js +894 -856
- package/dist/edge/index.js.map +4 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +894 -856
- package/dist/index.js.map +4 -4
- package/dist/models/config.d.ts +22 -1
- package/dist/models/config.d.ts.map +1 -1
- package/dist/models/token-endpoint-auth.d.ts +30 -0
- package/dist/models/token-endpoint-auth.d.ts.map +1 -0
- package/dist/utils/base64Encode.d.ts +36 -0
- package/dist/utils/base64Encode.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -1088,6 +1088,16 @@ var StorageManager = class _StorageManager {
|
|
|
1088
1088
|
};
|
|
1089
1089
|
var StorageManager_default = StorageManager;
|
|
1090
1090
|
|
|
1091
|
+
// src/utils/base64Encode.ts
|
|
1092
|
+
var jose = __toESM(require("jose"), 1);
|
|
1093
|
+
var base64Encode = (value) => {
|
|
1094
|
+
const b64url = jose.base64url.encode(new TextEncoder().encode(value));
|
|
1095
|
+
const rem = b64url.length % 4;
|
|
1096
|
+
const padded = rem === 0 ? b64url : b64url + "=".repeat(4 - rem);
|
|
1097
|
+
return padded.replace(/-/g, "+").replace(/_/g, "/");
|
|
1098
|
+
};
|
|
1099
|
+
var base64Encode_default = base64Encode;
|
|
1100
|
+
|
|
1091
1101
|
// src/utils/deepMerge.ts
|
|
1092
1102
|
var isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && !(value instanceof Date) && !(value instanceof RegExp) && Object.prototype.toString.call(value) === "[object Object]";
|
|
1093
1103
|
var deepMerge = (target, ...sources) => {
|
|
@@ -1454,7 +1464,9 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1454
1464
|
}
|
|
1455
1465
|
const body = new URLSearchParams();
|
|
1456
1466
|
body.set("client_id", configData.clientId);
|
|
1457
|
-
|
|
1467
|
+
const hasSecret = Boolean(configData.clientSecret && configData.clientSecret.trim().length > 0);
|
|
1468
|
+
const tokenEndpointAuthMethod = configData.tokenRequest?.authMethod ?? (configData.platform === "AsgardeoV2" /* AsgardeoV2 */ ? "client_secret_basic" : "client_secret_post");
|
|
1469
|
+
if (hasSecret && tokenEndpointAuthMethod === "client_secret_post") {
|
|
1458
1470
|
body.set("client_secret", configData.clientSecret);
|
|
1459
1471
|
}
|
|
1460
1472
|
const code = authorizationCode;
|
|
@@ -1473,15 +1485,22 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1473
1485
|
);
|
|
1474
1486
|
await this.storageManager.removeTemporaryDataParameter(extractPkceStorageKeyFromState_default(state), userId);
|
|
1475
1487
|
}
|
|
1488
|
+
const tokenRequestHeaders = {
|
|
1489
|
+
Accept: "application/json",
|
|
1490
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
1491
|
+
};
|
|
1492
|
+
if (hasSecret && tokenEndpointAuthMethod === "client_secret_basic") {
|
|
1493
|
+
const credential = `${encodeURIComponent(configData.clientId)}:${encodeURIComponent(
|
|
1494
|
+
configData.clientSecret
|
|
1495
|
+
)}`;
|
|
1496
|
+
tokenRequestHeaders["Authorization"] = `Basic ${base64Encode_default(credential)}`;
|
|
1497
|
+
}
|
|
1476
1498
|
let tokenResponse;
|
|
1477
1499
|
try {
|
|
1478
1500
|
tokenResponse = await fetch(tokenEndpoint, {
|
|
1479
1501
|
body,
|
|
1480
1502
|
credentials: configData.sendCookiesInRequests ? "include" : "same-origin",
|
|
1481
|
-
headers:
|
|
1482
|
-
Accept: "application/json",
|
|
1483
|
-
"Content-Type": "application/x-www-form-urlencoded"
|
|
1484
|
-
},
|
|
1503
|
+
headers: tokenRequestHeaders,
|
|
1485
1504
|
method: "POST"
|
|
1486
1505
|
});
|
|
1487
1506
|
} catch (error2) {
|
|
@@ -3093,171 +3112,533 @@ var updateMeProfile = async ({
|
|
|
3093
3112
|
};
|
|
3094
3113
|
var updateMeProfile_default = updateMeProfile;
|
|
3095
3114
|
|
|
3096
|
-
// src/
|
|
3097
|
-
var
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
+
// src/utils/logger.ts
|
|
3116
|
+
var PREFIX = "\u{1F6E1}\uFE0F Asgardeo";
|
|
3117
|
+
var DEFAULT_CONFIG = {
|
|
3118
|
+
level: "info",
|
|
3119
|
+
prefix: `${PREFIX}`,
|
|
3120
|
+
showLevel: true,
|
|
3121
|
+
timestamps: true
|
|
3122
|
+
};
|
|
3123
|
+
var isBrowser = () => (
|
|
3124
|
+
/* @ts-ignore */
|
|
3125
|
+
typeof window !== "undefined" && typeof window.document !== "undefined"
|
|
3126
|
+
);
|
|
3127
|
+
var isNode = () => (
|
|
3128
|
+
/* @ts-ignore */
|
|
3129
|
+
typeof process !== "undefined" && process.versions && process.versions.node
|
|
3130
|
+
);
|
|
3131
|
+
var COLORS = {
|
|
3132
|
+
blue: "\x1B[34m",
|
|
3133
|
+
bright: "\x1B[1m",
|
|
3134
|
+
cyan: "\x1B[36m",
|
|
3135
|
+
dim: "\x1B[2m",
|
|
3136
|
+
gray: "\x1B[90m",
|
|
3137
|
+
green: "\x1B[32m",
|
|
3138
|
+
magenta: "\x1B[35m",
|
|
3139
|
+
red: "\x1B[31m",
|
|
3140
|
+
reset: "\x1B[0m",
|
|
3141
|
+
white: "\x1B[37m",
|
|
3142
|
+
yellow: "\x1B[33m"
|
|
3143
|
+
};
|
|
3144
|
+
var BROWSER_STYLES = {
|
|
3145
|
+
debug: "color: #6b7280; font-weight: normal;",
|
|
3146
|
+
error: "color: #dc2626; font-weight: bold;",
|
|
3147
|
+
info: "color: #2563eb; font-weight: bold;",
|
|
3148
|
+
prefix: "color: #7c3aed; font-weight: bold;",
|
|
3149
|
+
timestamp: "color: #6b7280; font-size: 0.9em;",
|
|
3150
|
+
warn: "color: #d97706; font-weight: bold;"
|
|
3151
|
+
};
|
|
3152
|
+
var LOG_LEVEL_ORDER = {
|
|
3153
|
+
debug: 0,
|
|
3154
|
+
error: 3,
|
|
3155
|
+
info: 1,
|
|
3156
|
+
warn: 2
|
|
3157
|
+
};
|
|
3158
|
+
var Logger = class _Logger {
|
|
3159
|
+
constructor(config = {}) {
|
|
3160
|
+
__publicField(this, "config");
|
|
3161
|
+
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
3115
3162
|
}
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
type: type || ""
|
|
3122
|
-
}).filter(([, value]) => Boolean(value))
|
|
3123
|
-
)
|
|
3124
|
-
);
|
|
3125
|
-
const fetchFn = fetcher || fetch;
|
|
3126
|
-
const resolvedUrl = `${baseUrl}/api/server/v1/branding-preference/resolve${queryParams.toString() ? `?${queryParams.toString()}` : ""}`;
|
|
3127
|
-
const requestInit = {
|
|
3128
|
-
...requestConfig,
|
|
3129
|
-
headers: {
|
|
3130
|
-
Accept: "application/json",
|
|
3131
|
-
"Content-Type": "application/json",
|
|
3132
|
-
...requestConfig.headers
|
|
3133
|
-
},
|
|
3134
|
-
method: "GET"
|
|
3135
|
-
};
|
|
3136
|
-
try {
|
|
3137
|
-
const response = await fetchFn(resolvedUrl, requestInit);
|
|
3138
|
-
if (!response?.ok) {
|
|
3139
|
-
const errorText = await response.text();
|
|
3140
|
-
throw new AsgardeoAPIError(
|
|
3141
|
-
errorText,
|
|
3142
|
-
"getBrandingPreference-ResponseError-001",
|
|
3143
|
-
"javascript",
|
|
3144
|
-
response.status,
|
|
3145
|
-
response.statusText,
|
|
3146
|
-
"Failed to get branding preference"
|
|
3147
|
-
);
|
|
3148
|
-
}
|
|
3149
|
-
const data = await response.json();
|
|
3150
|
-
return data;
|
|
3151
|
-
} catch (error2) {
|
|
3152
|
-
if (error2 instanceof AsgardeoAPIError) {
|
|
3153
|
-
throw error2;
|
|
3154
|
-
}
|
|
3155
|
-
throw new AsgardeoAPIError(
|
|
3156
|
-
`Network or parsing error: ${error2 instanceof Error ? error2.message : "Unknown error"}`,
|
|
3157
|
-
"getBrandingPreference-NetworkError-001",
|
|
3158
|
-
"javascript",
|
|
3159
|
-
0,
|
|
3160
|
-
"Network Error"
|
|
3161
|
-
);
|
|
3163
|
+
/**
|
|
3164
|
+
* Update logger configuration
|
|
3165
|
+
*/
|
|
3166
|
+
configure(config) {
|
|
3167
|
+
this.config = { ...this.config, ...config };
|
|
3162
3168
|
}
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
EmbeddedSignInFlowStatus3["Complete"] = "COMPLETE";
|
|
3169
|
-
EmbeddedSignInFlowStatus3["Error"] = "ERROR";
|
|
3170
|
-
EmbeddedSignInFlowStatus3["Incomplete"] = "INCOMPLETE";
|
|
3171
|
-
return EmbeddedSignInFlowStatus3;
|
|
3172
|
-
})(EmbeddedSignInFlowStatus || {});
|
|
3173
|
-
var EmbeddedSignInFlowType = /* @__PURE__ */ ((EmbeddedSignInFlowType3) => {
|
|
3174
|
-
EmbeddedSignInFlowType3["Redirection"] = "REDIRECTION";
|
|
3175
|
-
EmbeddedSignInFlowType3["View"] = "VIEW";
|
|
3176
|
-
return EmbeddedSignInFlowType3;
|
|
3177
|
-
})(EmbeddedSignInFlowType || {});
|
|
3178
|
-
|
|
3179
|
-
// src/api/v2/executeEmbeddedSignInFlowV2.ts
|
|
3180
|
-
var executeEmbeddedSignInFlowV2 = async ({
|
|
3181
|
-
url,
|
|
3182
|
-
baseUrl,
|
|
3183
|
-
payload,
|
|
3184
|
-
authId,
|
|
3185
|
-
...requestConfig
|
|
3186
|
-
}) => {
|
|
3187
|
-
if (!payload) {
|
|
3188
|
-
throw new AsgardeoAPIError(
|
|
3189
|
-
"Authorization payload is required",
|
|
3190
|
-
"executeEmbeddedSignInFlow-ValidationError-002",
|
|
3191
|
-
"javascript",
|
|
3192
|
-
400,
|
|
3193
|
-
"If an authorization payload is not provided, the request cannot be constructed correctly."
|
|
3194
|
-
);
|
|
3169
|
+
/**
|
|
3170
|
+
* Get current configuration
|
|
3171
|
+
*/
|
|
3172
|
+
getConfig() {
|
|
3173
|
+
return { ...this.config };
|
|
3195
3174
|
}
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
const response = await fetch(endpoint, {
|
|
3202
|
-
...requestConfig,
|
|
3203
|
-
body: JSON.stringify(requestPayload),
|
|
3204
|
-
headers: {
|
|
3205
|
-
Accept: "application/json",
|
|
3206
|
-
"Content-Type": "application/json",
|
|
3207
|
-
...requestConfig.headers
|
|
3208
|
-
},
|
|
3209
|
-
method: requestConfig.method || "POST"
|
|
3210
|
-
});
|
|
3211
|
-
if (!response.ok) {
|
|
3212
|
-
const errorText = await response.text();
|
|
3213
|
-
throw new AsgardeoAPIError(
|
|
3214
|
-
errorText,
|
|
3215
|
-
"executeEmbeddedSignInFlow-ResponseError-001",
|
|
3216
|
-
"javascript",
|
|
3217
|
-
response.status,
|
|
3218
|
-
response.statusText,
|
|
3219
|
-
"Authorization request failed"
|
|
3220
|
-
);
|
|
3175
|
+
/**
|
|
3176
|
+
* Check if a log level should be output
|
|
3177
|
+
*/
|
|
3178
|
+
shouldLog(level) {
|
|
3179
|
+
return LOG_LEVEL_ORDER[level] >= LOG_LEVEL_ORDER[this.config.level];
|
|
3221
3180
|
}
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3181
|
+
/**
|
|
3182
|
+
* Get timestamp string
|
|
3183
|
+
*/
|
|
3184
|
+
static getTimestamp() {
|
|
3185
|
+
return (/* @__PURE__ */ new Date()).toISOString();
|
|
3186
|
+
}
|
|
3187
|
+
/**
|
|
3188
|
+
* Get log level string
|
|
3189
|
+
*/
|
|
3190
|
+
static getLevelString(level) {
|
|
3191
|
+
switch (level) {
|
|
3192
|
+
case "debug":
|
|
3193
|
+
return "DEBUG";
|
|
3194
|
+
case "info":
|
|
3195
|
+
return "INFO";
|
|
3196
|
+
case "warn":
|
|
3197
|
+
return "WARN";
|
|
3198
|
+
case "error":
|
|
3199
|
+
return "ERROR";
|
|
3200
|
+
default:
|
|
3201
|
+
return "UNKNOWN";
|
|
3202
|
+
}
|
|
3203
|
+
}
|
|
3204
|
+
/**
|
|
3205
|
+
* Format message for Node.js terminal
|
|
3206
|
+
*/
|
|
3207
|
+
formatForNode(level, message) {
|
|
3208
|
+
const parts = [];
|
|
3209
|
+
if (this.config.timestamps) {
|
|
3210
|
+
parts.push(`${COLORS.gray}[${_Logger.getTimestamp()}]${COLORS.reset}`);
|
|
3211
|
+
}
|
|
3212
|
+
if (this.config.prefix) {
|
|
3213
|
+
parts.push(`${COLORS.magenta}${this.config.prefix}${COLORS.reset}`);
|
|
3214
|
+
}
|
|
3215
|
+
if (this.config.showLevel) {
|
|
3216
|
+
const levelStr = _Logger.getLevelString(level);
|
|
3217
|
+
let coloredLevel;
|
|
3218
|
+
switch (level) {
|
|
3219
|
+
case "debug":
|
|
3220
|
+
coloredLevel = `${COLORS.gray}[${levelStr}]${COLORS.reset}`;
|
|
3221
|
+
break;
|
|
3222
|
+
case "info":
|
|
3223
|
+
coloredLevel = `${COLORS.blue}[${levelStr}]${COLORS.reset}`;
|
|
3224
|
+
break;
|
|
3225
|
+
case "warn":
|
|
3226
|
+
coloredLevel = `${COLORS.yellow}[${levelStr}]${COLORS.reset}`;
|
|
3227
|
+
break;
|
|
3228
|
+
case "error":
|
|
3229
|
+
coloredLevel = `${COLORS.red}[${levelStr}]${COLORS.reset}`;
|
|
3230
|
+
break;
|
|
3231
|
+
default:
|
|
3232
|
+
coloredLevel = `[${levelStr}]`;
|
|
3233
|
+
}
|
|
3234
|
+
parts.push(coloredLevel);
|
|
3235
|
+
}
|
|
3236
|
+
parts.push(message);
|
|
3237
|
+
return parts.join(" ");
|
|
3238
|
+
}
|
|
3239
|
+
/**
|
|
3240
|
+
* Log message using appropriate method
|
|
3241
|
+
*/
|
|
3242
|
+
logMessage(level, message, ...args) {
|
|
3243
|
+
if (!this.shouldLog(level)) {
|
|
3244
|
+
return;
|
|
3245
|
+
}
|
|
3246
|
+
if (this.config.formatter) {
|
|
3247
|
+
this.config.formatter(level, message, ...args);
|
|
3248
|
+
return;
|
|
3249
|
+
}
|
|
3250
|
+
if (isBrowser()) {
|
|
3251
|
+
this.logToBrowser(level, message, ...args);
|
|
3252
|
+
} else if (isNode()) {
|
|
3253
|
+
this.logToNode(level, message, ...args);
|
|
3254
|
+
} else {
|
|
3255
|
+
console.log(message, ...args);
|
|
3256
|
+
}
|
|
3257
|
+
}
|
|
3258
|
+
/**
|
|
3259
|
+
* Log to browser console with styling
|
|
3260
|
+
*/
|
|
3261
|
+
logToBrowser(level, message, ...args) {
|
|
3262
|
+
const parts = [];
|
|
3263
|
+
const styles = [];
|
|
3264
|
+
if (this.config.timestamps) {
|
|
3265
|
+
parts.push(`%c[${_Logger.getTimestamp()}]`);
|
|
3266
|
+
styles.push(BROWSER_STYLES.timestamp);
|
|
3267
|
+
}
|
|
3268
|
+
if (this.config.prefix) {
|
|
3269
|
+
parts.push(`%c${this.config.prefix}`);
|
|
3270
|
+
styles.push(BROWSER_STYLES.prefix);
|
|
3271
|
+
}
|
|
3272
|
+
if (this.config.showLevel) {
|
|
3273
|
+
const levelStr = _Logger.getLevelString(level);
|
|
3274
|
+
parts.push(`%c[${levelStr}]`);
|
|
3275
|
+
switch (level) {
|
|
3276
|
+
case "debug":
|
|
3277
|
+
styles.push(BROWSER_STYLES.debug);
|
|
3278
|
+
break;
|
|
3279
|
+
case "info":
|
|
3280
|
+
styles.push(BROWSER_STYLES.info);
|
|
3281
|
+
break;
|
|
3282
|
+
case "warn":
|
|
3283
|
+
styles.push(BROWSER_STYLES.warn);
|
|
3284
|
+
break;
|
|
3285
|
+
case "error":
|
|
3286
|
+
styles.push(BROWSER_STYLES.error);
|
|
3287
|
+
break;
|
|
3288
|
+
default:
|
|
3289
|
+
styles.push("");
|
|
3290
|
+
}
|
|
3291
|
+
}
|
|
3292
|
+
parts.push(`%c${message}`);
|
|
3293
|
+
styles.push("color: inherit; font-weight: normal;");
|
|
3294
|
+
const formattedMessage = parts.join(" ");
|
|
3295
|
+
switch (level) {
|
|
3296
|
+
case "debug":
|
|
3297
|
+
console.debug(formattedMessage, ...styles, ...args);
|
|
3298
|
+
break;
|
|
3299
|
+
case "info":
|
|
3300
|
+
console.info(formattedMessage, ...styles, ...args);
|
|
3301
|
+
break;
|
|
3302
|
+
case "warn":
|
|
3303
|
+
console.warn(formattedMessage, ...styles, ...args);
|
|
3304
|
+
break;
|
|
3305
|
+
case "error":
|
|
3306
|
+
console.error(formattedMessage, ...styles, ...args);
|
|
3307
|
+
break;
|
|
3308
|
+
default:
|
|
3309
|
+
console.log(formattedMessage, ...styles, ...args);
|
|
3310
|
+
}
|
|
3311
|
+
}
|
|
3312
|
+
/**
|
|
3313
|
+
* Log to Node.js console
|
|
3314
|
+
*/
|
|
3315
|
+
logToNode(level, message, ...args) {
|
|
3316
|
+
const formattedMessage = this.formatForNode(level, message);
|
|
3317
|
+
switch (level) {
|
|
3318
|
+
case "debug":
|
|
3319
|
+
console.debug(formattedMessage, ...args);
|
|
3320
|
+
break;
|
|
3321
|
+
case "info":
|
|
3322
|
+
console.info(formattedMessage, ...args);
|
|
3323
|
+
break;
|
|
3324
|
+
case "warn":
|
|
3325
|
+
console.warn(formattedMessage, ...args);
|
|
3326
|
+
break;
|
|
3327
|
+
case "error":
|
|
3328
|
+
console.error(formattedMessage, ...args);
|
|
3329
|
+
break;
|
|
3330
|
+
default:
|
|
3331
|
+
console.log(formattedMessage, ...args);
|
|
3332
|
+
}
|
|
3333
|
+
}
|
|
3334
|
+
/**
|
|
3335
|
+
* Log debug message
|
|
3336
|
+
*/
|
|
3337
|
+
debug(message, ...args) {
|
|
3338
|
+
this.logMessage("debug", message, ...args);
|
|
3339
|
+
}
|
|
3340
|
+
/**
|
|
3341
|
+
* Log info message
|
|
3342
|
+
*/
|
|
3343
|
+
info(message, ...args) {
|
|
3344
|
+
this.logMessage("info", message, ...args);
|
|
3345
|
+
}
|
|
3346
|
+
/**
|
|
3347
|
+
* Log warning message
|
|
3348
|
+
*/
|
|
3349
|
+
warn(message, ...args) {
|
|
3350
|
+
this.logMessage("warn", message, ...args);
|
|
3351
|
+
}
|
|
3352
|
+
/**
|
|
3353
|
+
* Log error message
|
|
3354
|
+
*/
|
|
3355
|
+
error(message, ...args) {
|
|
3356
|
+
this.logMessage("error", message, ...args);
|
|
3357
|
+
}
|
|
3358
|
+
/**
|
|
3359
|
+
* Create a child logger with additional prefix
|
|
3360
|
+
*/
|
|
3361
|
+
child(prefix) {
|
|
3362
|
+
const childPrefix = this.config.prefix ? `${this.config.prefix} - ${prefix}` : prefix;
|
|
3363
|
+
return new _Logger({
|
|
3364
|
+
...this.config,
|
|
3365
|
+
prefix: childPrefix
|
|
3366
|
+
});
|
|
3367
|
+
}
|
|
3368
|
+
/**
|
|
3369
|
+
* Set log level
|
|
3370
|
+
*/
|
|
3371
|
+
setLevel(level) {
|
|
3372
|
+
this.config.level = level;
|
|
3373
|
+
}
|
|
3374
|
+
/**
|
|
3375
|
+
* Get current log level
|
|
3376
|
+
*/
|
|
3377
|
+
getLevel() {
|
|
3378
|
+
return this.config.level;
|
|
3379
|
+
}
|
|
3380
|
+
};
|
|
3381
|
+
var logger = new Logger();
|
|
3382
|
+
var createLogger = (config) => new Logger(config);
|
|
3383
|
+
var logger_default = logger;
|
|
3384
|
+
var debug = (message, ...args) => logger.debug(message, ...args);
|
|
3385
|
+
var info = (message, ...args) => logger.info(message, ...args);
|
|
3386
|
+
var warn = (message, ...args) => logger.warn(message, ...args);
|
|
3387
|
+
var error = (message, ...args) => logger.error(message, ...args);
|
|
3388
|
+
var configure = (config) => logger.configure(config);
|
|
3389
|
+
var createComponentLogger = (component) => logger.child(component);
|
|
3390
|
+
var createPackageLogger = (packageName) => createLogger({
|
|
3391
|
+
level: "info",
|
|
3392
|
+
prefix: `${PREFIX} - ${packageName}`,
|
|
3393
|
+
showLevel: true,
|
|
3394
|
+
timestamps: true
|
|
3395
|
+
});
|
|
3396
|
+
var createPackageComponentLogger = (packageName, component) => {
|
|
3397
|
+
const packageLogger = createPackageLogger(packageName);
|
|
3398
|
+
return packageLogger.child(component);
|
|
3399
|
+
};
|
|
3400
|
+
|
|
3401
|
+
// src/utils/isRecognizedBaseUrlPattern.ts
|
|
3402
|
+
var isRecognizedBaseUrlPattern = (baseUrl) => {
|
|
3403
|
+
if (!baseUrl) {
|
|
3404
|
+
throw new AsgardeoRuntimeError(
|
|
3405
|
+
"Base URL is required to derive if the `baseUrl` is recognized.",
|
|
3406
|
+
"isRecognizedBaseUrlPattern-ValidationError-001",
|
|
3407
|
+
"javascript",
|
|
3408
|
+
"A valid base URL must be provided to derive if the `baseUrl` is recognized to use the sensible fallbacks."
|
|
3409
|
+
);
|
|
3410
|
+
}
|
|
3411
|
+
let parsedUrl;
|
|
3412
|
+
try {
|
|
3413
|
+
parsedUrl = new URL(baseUrl);
|
|
3414
|
+
} catch (error2) {
|
|
3415
|
+
throw new AsgardeoRuntimeError(
|
|
3416
|
+
`Invalid base URL format: ${baseUrl}`,
|
|
3417
|
+
"isRecognizedBaseUrlPattern-ValidationError-002",
|
|
3418
|
+
"javascript",
|
|
3419
|
+
"The provided base URL does not conform to valid URL syntax."
|
|
3420
|
+
);
|
|
3421
|
+
}
|
|
3422
|
+
const pathSegments = parsedUrl.pathname?.split("/")?.filter((segment) => segment?.length > 0);
|
|
3423
|
+
if (pathSegments.length < 2 || pathSegments[0] !== "t") {
|
|
3424
|
+
logger_default.warn(
|
|
3425
|
+
"[isRecognizedBaseUrlPattern] The provided base URL does not follow the expected URL pattern (/t/{orgHandle})."
|
|
3426
|
+
);
|
|
3427
|
+
return false;
|
|
3428
|
+
}
|
|
3429
|
+
return true;
|
|
3430
|
+
};
|
|
3431
|
+
var isRecognizedBaseUrlPattern_default = isRecognizedBaseUrlPattern;
|
|
3432
|
+
|
|
3433
|
+
// src/utils/identifyPlatform.ts
|
|
3434
|
+
var identifyPlatform = (config) => {
|
|
3435
|
+
const { baseUrl } = config;
|
|
3436
|
+
try {
|
|
3437
|
+
if (isRecognizedBaseUrlPattern_default(baseUrl)) {
|
|
3438
|
+
try {
|
|
3439
|
+
const url = new URL(baseUrl);
|
|
3440
|
+
if (/\.asgardeo\.io$/i.test(url.hostname) || /asgardeo\.io$/i.test(url.hostname)) {
|
|
3441
|
+
return "ASGARDEO" /* Asgardeo */;
|
|
3442
|
+
}
|
|
3443
|
+
} catch {
|
|
3444
|
+
logger_default.debug(
|
|
3445
|
+
`[identifyPlatform] Could not identify platform from the base URL: ${baseUrl}. Defaulting to WSO2 Identity Server as the platform.`
|
|
3446
|
+
);
|
|
3447
|
+
}
|
|
3448
|
+
return "IDENTITY_SERVER" /* IdentityServer */;
|
|
3449
|
+
}
|
|
3450
|
+
return "UNKNOWN" /* Unknown */;
|
|
3451
|
+
} catch (error2) {
|
|
3452
|
+
logger_default.debug(`[identifyPlatform] Error identifying platform from base URL: ${baseUrl}. Error: ${error2.message}`);
|
|
3453
|
+
return "UNKNOWN" /* Unknown */;
|
|
3454
|
+
}
|
|
3455
|
+
};
|
|
3456
|
+
var identifyPlatform_default = identifyPlatform;
|
|
3457
|
+
|
|
3458
|
+
// src/api/getBrandingPreference.ts
|
|
3459
|
+
var getBrandingPreference = async ({
|
|
3460
|
+
baseUrl,
|
|
3461
|
+
locale,
|
|
3462
|
+
name,
|
|
3463
|
+
type,
|
|
3464
|
+
fetcher,
|
|
3465
|
+
...requestConfig
|
|
3466
|
+
}) => {
|
|
3467
|
+
try {
|
|
3468
|
+
new URL(baseUrl);
|
|
3469
|
+
} catch (error2) {
|
|
3470
|
+
throw new AsgardeoAPIError(
|
|
3471
|
+
`Invalid base URL provided. ${error2?.toString()}`,
|
|
3472
|
+
"getBrandingPreference-ValidationError-001",
|
|
3473
|
+
"javascript",
|
|
3474
|
+
400,
|
|
3475
|
+
"The provided `baseUrl` does not adhere to the URL schema."
|
|
3476
|
+
);
|
|
3477
|
+
}
|
|
3478
|
+
const queryParams = new URLSearchParams(
|
|
3479
|
+
Object.fromEntries(
|
|
3480
|
+
Object.entries({
|
|
3481
|
+
locale: locale || "",
|
|
3482
|
+
name: name || "",
|
|
3483
|
+
type: type || ""
|
|
3484
|
+
}).filter(([, value]) => Boolean(value))
|
|
3485
|
+
)
|
|
3486
|
+
);
|
|
3487
|
+
const fetchFn = fetcher || fetch;
|
|
3488
|
+
const resolvedUrl = `${baseUrl}/api/server/v1/branding-preference/resolve${queryParams.toString() ? `?${queryParams.toString()}` : ""}`;
|
|
3489
|
+
const requestInit = {
|
|
3490
|
+
...requestConfig,
|
|
3491
|
+
headers: {
|
|
3492
|
+
Accept: "application/json",
|
|
3493
|
+
"Content-Type": "application/json",
|
|
3494
|
+
...requestConfig.headers
|
|
3495
|
+
},
|
|
3496
|
+
method: "GET"
|
|
3497
|
+
};
|
|
3498
|
+
try {
|
|
3499
|
+
const response = await fetchFn(resolvedUrl, requestInit);
|
|
3500
|
+
if (!response?.ok) {
|
|
3501
|
+
const errorText = await response.text();
|
|
3502
|
+
const platform = identifyPlatform_default({ baseUrl });
|
|
3503
|
+
let errorDescription;
|
|
3504
|
+
try {
|
|
3505
|
+
const errorBody = JSON.parse(errorText);
|
|
3506
|
+
errorDescription = errorBody?.description || errorBody?.message || errorText;
|
|
3507
|
+
} catch {
|
|
3508
|
+
errorDescription = errorText;
|
|
3509
|
+
}
|
|
3510
|
+
let platformConsoleGuidance;
|
|
3511
|
+
if (platform === "ASGARDEO" /* Asgardeo */) {
|
|
3512
|
+
platformConsoleGuidance = "configure branding preferences in the Asgardeo console";
|
|
3513
|
+
} else if (platform === "IDENTITY_SERVER" /* IdentityServer */) {
|
|
3514
|
+
platformConsoleGuidance = "configure branding preferences in the WSO2 Identity Server console";
|
|
3515
|
+
} else {
|
|
3516
|
+
platformConsoleGuidance = "configure branding preferences in the platform console";
|
|
3517
|
+
}
|
|
3518
|
+
logger_default.warn(
|
|
3519
|
+
`[BrandingError] ${errorDescription} To resolve this issue, please ${platformConsoleGuidance}. If you want to suppress this warning and stop fetching branding preferences, set \`<AsgardeoProvider>\` -> \`preferences\` -> \`theme\` -> \`inheritFromBranding\` to false.`
|
|
3520
|
+
);
|
|
3521
|
+
throw new AsgardeoAPIError(
|
|
3522
|
+
errorText,
|
|
3523
|
+
"getBrandingPreference-ResponseError-001",
|
|
3524
|
+
"javascript",
|
|
3525
|
+
response.status,
|
|
3526
|
+
response.statusText,
|
|
3527
|
+
"Failed to get branding preference"
|
|
3528
|
+
);
|
|
3529
|
+
}
|
|
3530
|
+
const data = await response.json();
|
|
3531
|
+
return data;
|
|
3532
|
+
} catch (error2) {
|
|
3533
|
+
if (error2 instanceof AsgardeoAPIError) {
|
|
3534
|
+
throw error2;
|
|
3535
|
+
}
|
|
3536
|
+
throw new AsgardeoAPIError(
|
|
3537
|
+
`Network or parsing error: ${error2 instanceof Error ? error2.message : "Unknown error"}`,
|
|
3538
|
+
"getBrandingPreference-NetworkError-001",
|
|
3539
|
+
"javascript",
|
|
3540
|
+
0,
|
|
3541
|
+
"Network Error"
|
|
3542
|
+
);
|
|
3543
|
+
}
|
|
3544
|
+
};
|
|
3545
|
+
var getBrandingPreference_default = getBrandingPreference;
|
|
3546
|
+
|
|
3547
|
+
// src/models/v2/embedded-signin-flow-v2.ts
|
|
3548
|
+
var EmbeddedSignInFlowStatus = /* @__PURE__ */ ((EmbeddedSignInFlowStatus3) => {
|
|
3549
|
+
EmbeddedSignInFlowStatus3["Complete"] = "COMPLETE";
|
|
3550
|
+
EmbeddedSignInFlowStatus3["Error"] = "ERROR";
|
|
3551
|
+
EmbeddedSignInFlowStatus3["Incomplete"] = "INCOMPLETE";
|
|
3552
|
+
return EmbeddedSignInFlowStatus3;
|
|
3553
|
+
})(EmbeddedSignInFlowStatus || {});
|
|
3554
|
+
var EmbeddedSignInFlowType = /* @__PURE__ */ ((EmbeddedSignInFlowType3) => {
|
|
3555
|
+
EmbeddedSignInFlowType3["Redirection"] = "REDIRECTION";
|
|
3556
|
+
EmbeddedSignInFlowType3["View"] = "VIEW";
|
|
3557
|
+
return EmbeddedSignInFlowType3;
|
|
3558
|
+
})(EmbeddedSignInFlowType || {});
|
|
3559
|
+
|
|
3560
|
+
// src/api/v2/executeEmbeddedSignInFlowV2.ts
|
|
3561
|
+
var executeEmbeddedSignInFlowV2 = async ({
|
|
3562
|
+
url,
|
|
3563
|
+
baseUrl,
|
|
3564
|
+
payload,
|
|
3565
|
+
authId,
|
|
3566
|
+
...requestConfig
|
|
3567
|
+
}) => {
|
|
3568
|
+
if (!payload) {
|
|
3569
|
+
throw new AsgardeoAPIError(
|
|
3570
|
+
"Authorization payload is required",
|
|
3571
|
+
"executeEmbeddedSignInFlow-ValidationError-002",
|
|
3572
|
+
"javascript",
|
|
3573
|
+
400,
|
|
3574
|
+
"If an authorization payload is not provided, the request cannot be constructed correctly."
|
|
3575
|
+
);
|
|
3576
|
+
}
|
|
3577
|
+
const endpoint = url ?? `${baseUrl}/flow/execute`;
|
|
3578
|
+
const cleanPayload = typeof payload === "object" && payload !== null ? Object.fromEntries(Object.entries(payload).filter(([key]) => key !== "verbose")) : payload;
|
|
3579
|
+
const hasOnlyAppIdAndFlowType = typeof cleanPayload === "object" && cleanPayload !== null && "applicationId" in cleanPayload && "flowType" in cleanPayload && Object.keys(cleanPayload).length === 2;
|
|
3580
|
+
const hasOnlyFlowId = typeof cleanPayload === "object" && cleanPayload !== null && "executionId" in cleanPayload && Object.keys(cleanPayload).length === 1;
|
|
3581
|
+
const requestPayload = hasOnlyAppIdAndFlowType || hasOnlyFlowId ? { ...cleanPayload, verbose: true } : cleanPayload;
|
|
3582
|
+
const response = await fetch(endpoint, {
|
|
3583
|
+
...requestConfig,
|
|
3584
|
+
body: JSON.stringify(requestPayload),
|
|
3585
|
+
headers: {
|
|
3586
|
+
Accept: "application/json",
|
|
3587
|
+
"Content-Type": "application/json",
|
|
3588
|
+
...requestConfig.headers
|
|
3589
|
+
},
|
|
3590
|
+
method: requestConfig.method || "POST"
|
|
3591
|
+
});
|
|
3592
|
+
if (!response.ok) {
|
|
3593
|
+
const errorText = await response.text();
|
|
3594
|
+
throw new AsgardeoAPIError(
|
|
3595
|
+
errorText,
|
|
3596
|
+
"executeEmbeddedSignInFlow-ResponseError-001",
|
|
3597
|
+
"javascript",
|
|
3598
|
+
response.status,
|
|
3599
|
+
response.statusText,
|
|
3600
|
+
"Authorization request failed"
|
|
3601
|
+
);
|
|
3602
|
+
}
|
|
3603
|
+
const flowResponse = await response.json();
|
|
3604
|
+
if (flowResponse.flowStatus === "COMPLETE" /* Complete */ && flowResponse.assertion && authId) {
|
|
3605
|
+
try {
|
|
3606
|
+
const oauth2Response = await fetch(`${baseUrl}/oauth2/auth/callback`, {
|
|
3607
|
+
body: JSON.stringify({
|
|
3608
|
+
assertion: flowResponse.assertion,
|
|
3609
|
+
authId
|
|
3610
|
+
}),
|
|
3611
|
+
credentials: "include",
|
|
3612
|
+
headers: {
|
|
3613
|
+
Accept: "application/json",
|
|
3614
|
+
"Content-Type": "application/json",
|
|
3615
|
+
...requestConfig.headers
|
|
3616
|
+
},
|
|
3617
|
+
method: "POST"
|
|
3618
|
+
});
|
|
3619
|
+
if (!oauth2Response.ok) {
|
|
3620
|
+
const oauth2ErrorText = await oauth2Response.text();
|
|
3621
|
+
throw new AsgardeoAPIError(
|
|
3622
|
+
`OAuth2 authorization failed: ${oauth2ErrorText}`,
|
|
3623
|
+
"executeEmbeddedSignInFlow-OAuth2Error-002",
|
|
3624
|
+
"javascript",
|
|
3625
|
+
oauth2Response.status,
|
|
3626
|
+
oauth2Response.statusText
|
|
3627
|
+
);
|
|
3628
|
+
}
|
|
3629
|
+
const oauth2Result = await oauth2Response.json();
|
|
3630
|
+
return {
|
|
3631
|
+
flowStatus: flowResponse.flowStatus,
|
|
3632
|
+
redirectUrl: oauth2Result["redirect_uri"]
|
|
3633
|
+
};
|
|
3634
|
+
} catch (authError) {
|
|
3635
|
+
throw new AsgardeoAPIError(
|
|
3636
|
+
`OAuth2 authorization failed: ${authError instanceof Error ? authError.message : "Unknown error"}`,
|
|
3637
|
+
"executeEmbeddedSignInFlow-OAuth2Error-001",
|
|
3638
|
+
"javascript",
|
|
3639
|
+
500,
|
|
3640
|
+
"Failed to complete OAuth2 authorization after successful embedded sign-in flow."
|
|
3641
|
+
);
|
|
3261
3642
|
}
|
|
3262
3643
|
}
|
|
3263
3644
|
return flowResponse;
|
|
@@ -3775,16 +4156,16 @@ var DefaultCacheStore = class {
|
|
|
3775
4156
|
};
|
|
3776
4157
|
|
|
3777
4158
|
// src/DefaultCrypto.ts
|
|
3778
|
-
var
|
|
4159
|
+
var jose2 = __toESM(require("jose"), 1);
|
|
3779
4160
|
var DefaultCrypto = class {
|
|
3780
4161
|
// eslint-disable-next-line class-methods-use-this
|
|
3781
4162
|
base64URLDecode(value) {
|
|
3782
|
-
const decodedArray =
|
|
4163
|
+
const decodedArray = jose2.base64url.decode(value);
|
|
3783
4164
|
return new TextDecoder().decode(decodedArray);
|
|
3784
4165
|
}
|
|
3785
4166
|
// eslint-disable-next-line class-methods-use-this
|
|
3786
4167
|
base64URLEncode(value) {
|
|
3787
|
-
return
|
|
4168
|
+
return jose2.base64url.encode(value);
|
|
3788
4169
|
}
|
|
3789
4170
|
// eslint-disable-next-line class-methods-use-this
|
|
3790
4171
|
generateRandomBytes(length) {
|
|
@@ -3799,8 +4180,8 @@ var DefaultCrypto = class {
|
|
|
3799
4180
|
}
|
|
3800
4181
|
// eslint-disable-next-line class-methods-use-this
|
|
3801
4182
|
async verifyJwt(idToken, jwk, algorithms, clientId, issuer, subject, clockTolerance, validateJwtIssuer = true) {
|
|
3802
|
-
const key = await
|
|
3803
|
-
await
|
|
4183
|
+
const key = await jose2.importJWK(jwk);
|
|
4184
|
+
await jose2.jwtVerify(idToken, key, {
|
|
3804
4185
|
algorithms,
|
|
3805
4186
|
audience: [clientId],
|
|
3806
4187
|
clockTolerance,
|
|
@@ -4255,660 +4636,374 @@ var toCssVariables = (theme) => {
|
|
|
4255
4636
|
if (theme.colors?.background?.disabled) {
|
|
4256
4637
|
cssVars[`--${prefix}-color-background-disabled`] = theme.colors.background.disabled;
|
|
4257
4638
|
}
|
|
4258
|
-
if (theme.colors?.background?.body?.main) {
|
|
4259
|
-
cssVars[`--${prefix}-color-background-body-main`] = theme.colors.background.body.main;
|
|
4260
|
-
}
|
|
4261
|
-
if (theme.colors?.error?.main) {
|
|
4262
|
-
cssVars[`--${prefix}-color-error-main`] = theme.colors.error.main;
|
|
4263
|
-
}
|
|
4264
|
-
if (theme.colors?.error?.contrastText) {
|
|
4265
|
-
cssVars[`--${prefix}-color-error-contrastText`] = theme.colors.error.contrastText;
|
|
4266
|
-
}
|
|
4267
|
-
if (theme.colors?.error?.light) {
|
|
4268
|
-
cssVars[`--${prefix}-color-error-light`] = theme.colors.error.light;
|
|
4269
|
-
}
|
|
4270
|
-
if (theme.colors?.success?.main) {
|
|
4271
|
-
cssVars[`--${prefix}-color-success-main`] = theme.colors.success.main;
|
|
4272
|
-
}
|
|
4273
|
-
if (theme.colors?.success?.contrastText) {
|
|
4274
|
-
cssVars[`--${prefix}-color-success-contrastText`] = theme.colors.success.contrastText;
|
|
4275
|
-
}
|
|
4276
|
-
if (theme.colors?.success?.light) {
|
|
4277
|
-
cssVars[`--${prefix}-color-success-light`] = theme.colors.success.light;
|
|
4278
|
-
}
|
|
4279
|
-
if (theme.colors?.warning?.main) {
|
|
4280
|
-
cssVars[`--${prefix}-color-warning-main`] = theme.colors.warning.main;
|
|
4281
|
-
}
|
|
4282
|
-
if (theme.colors?.warning?.contrastText) {
|
|
4283
|
-
cssVars[`--${prefix}-color-warning-contrastText`] = theme.colors.warning.contrastText;
|
|
4284
|
-
}
|
|
4285
|
-
if (theme.colors?.warning?.light) {
|
|
4286
|
-
cssVars[`--${prefix}-color-warning-light`] = theme.colors.warning.light;
|
|
4287
|
-
}
|
|
4288
|
-
if (theme.colors?.info?.main) {
|
|
4289
|
-
cssVars[`--${prefix}-color-info-main`] = theme.colors.info.main;
|
|
4290
|
-
}
|
|
4291
|
-
if (theme.colors?.info?.contrastText) {
|
|
4292
|
-
cssVars[`--${prefix}-color-info-contrastText`] = theme.colors.info.contrastText;
|
|
4293
|
-
}
|
|
4294
|
-
if (theme.colors?.info?.light) {
|
|
4295
|
-
cssVars[`--${prefix}-color-info-light`] = theme.colors.info.light;
|
|
4296
|
-
}
|
|
4297
|
-
if (theme.colors?.text?.primary) {
|
|
4298
|
-
cssVars[`--${prefix}-color-text-primary`] = theme.colors.text.primary;
|
|
4299
|
-
}
|
|
4300
|
-
if (theme.colors?.text?.secondary) {
|
|
4301
|
-
cssVars[`--${prefix}-color-text-secondary`] = theme.colors.text.secondary;
|
|
4302
|
-
}
|
|
4303
|
-
if (theme.colors?.border) {
|
|
4304
|
-
cssVars[`--${prefix}-color-border`] = theme.colors.border;
|
|
4305
|
-
}
|
|
4306
|
-
if (theme.spacing?.unit !== void 0) {
|
|
4307
|
-
cssVars[`--${prefix}-spacing-unit`] = `${theme.spacing.unit}px`;
|
|
4308
|
-
}
|
|
4309
|
-
if (theme.borderRadius?.small) {
|
|
4310
|
-
cssVars[`--${prefix}-border-radius-small`] = theme.borderRadius.small;
|
|
4311
|
-
}
|
|
4312
|
-
if (theme.borderRadius?.medium) {
|
|
4313
|
-
cssVars[`--${prefix}-border-radius-medium`] = theme.borderRadius.medium;
|
|
4314
|
-
}
|
|
4315
|
-
if (theme.borderRadius?.large) {
|
|
4316
|
-
cssVars[`--${prefix}-border-radius-large`] = theme.borderRadius.large;
|
|
4317
|
-
}
|
|
4318
|
-
if (theme.shadows?.small) {
|
|
4319
|
-
cssVars[`--${prefix}-shadow-small`] = theme.shadows.small;
|
|
4320
|
-
}
|
|
4321
|
-
if (theme.shadows?.medium) {
|
|
4322
|
-
cssVars[`--${prefix}-shadow-medium`] = theme.shadows.medium;
|
|
4323
|
-
}
|
|
4324
|
-
if (theme.shadows?.large) {
|
|
4325
|
-
cssVars[`--${prefix}-shadow-large`] = theme.shadows.large;
|
|
4326
|
-
}
|
|
4327
|
-
if (theme.typography?.fontFamily) {
|
|
4328
|
-
cssVars[`--${prefix}-typography-fontFamily`] = theme.typography.fontFamily;
|
|
4329
|
-
}
|
|
4330
|
-
if (theme.typography?.fontSizes?.xs) {
|
|
4331
|
-
cssVars[`--${prefix}-typography-fontSize-xs`] = theme.typography.fontSizes.xs;
|
|
4332
|
-
}
|
|
4333
|
-
if (theme.typography?.fontSizes?.sm) {
|
|
4334
|
-
cssVars[`--${prefix}-typography-fontSize-sm`] = theme.typography.fontSizes.sm;
|
|
4335
|
-
}
|
|
4336
|
-
if (theme.typography?.fontSizes?.md) {
|
|
4337
|
-
cssVars[`--${prefix}-typography-fontSize-md`] = theme.typography.fontSizes.md;
|
|
4338
|
-
}
|
|
4339
|
-
if (theme.typography?.fontSizes?.lg) {
|
|
4340
|
-
cssVars[`--${prefix}-typography-fontSize-lg`] = theme.typography.fontSizes.lg;
|
|
4341
|
-
}
|
|
4342
|
-
if (theme.typography?.fontSizes?.xl) {
|
|
4343
|
-
cssVars[`--${prefix}-typography-fontSize-xl`] = theme.typography.fontSizes.xl;
|
|
4344
|
-
}
|
|
4345
|
-
if (theme.typography?.fontSizes?.["2xl"]) {
|
|
4346
|
-
cssVars[`--${prefix}-typography-fontSize-2xl`] = theme.typography.fontSizes["2xl"];
|
|
4347
|
-
}
|
|
4348
|
-
if (theme.typography?.fontSizes?.["3xl"]) {
|
|
4349
|
-
cssVars[`--${prefix}-typography-fontSize-3xl`] = theme.typography.fontSizes["3xl"];
|
|
4350
|
-
}
|
|
4351
|
-
if (theme.typography?.fontWeights?.normal !== void 0) {
|
|
4352
|
-
cssVars[`--${prefix}-typography-fontWeight-normal`] = theme.typography.fontWeights.normal.toString();
|
|
4353
|
-
}
|
|
4354
|
-
if (theme.typography?.fontWeights?.medium !== void 0) {
|
|
4355
|
-
cssVars[`--${prefix}-typography-fontWeight-medium`] = theme.typography.fontWeights.medium.toString();
|
|
4356
|
-
}
|
|
4357
|
-
if (theme.typography?.fontWeights?.semibold !== void 0) {
|
|
4358
|
-
cssVars[`--${prefix}-typography-fontWeight-semibold`] = theme.typography.fontWeights.semibold.toString();
|
|
4359
|
-
}
|
|
4360
|
-
if (theme.typography?.fontWeights?.bold !== void 0) {
|
|
4361
|
-
cssVars[`--${prefix}-typography-fontWeight-bold`] = theme.typography.fontWeights.bold.toString();
|
|
4362
|
-
}
|
|
4363
|
-
if (theme.typography?.lineHeights?.tight !== void 0) {
|
|
4364
|
-
cssVars[`--${prefix}-typography-lineHeight-tight`] = theme.typography.lineHeights.tight.toString();
|
|
4365
|
-
}
|
|
4366
|
-
if (theme.typography?.lineHeights?.normal !== void 0) {
|
|
4367
|
-
cssVars[`--${prefix}-typography-lineHeight-normal`] = theme.typography.lineHeights.normal.toString();
|
|
4368
|
-
}
|
|
4369
|
-
if (theme.typography?.lineHeights?.relaxed !== void 0) {
|
|
4370
|
-
cssVars[`--${prefix}-typography-lineHeight-relaxed`] = theme.typography.lineHeights.relaxed.toString();
|
|
4371
|
-
}
|
|
4372
|
-
if (theme.images) {
|
|
4373
|
-
Object.keys(theme.images).forEach((imageKey) => {
|
|
4374
|
-
const imageConfig = theme.images[imageKey];
|
|
4375
|
-
if (imageConfig?.url) {
|
|
4376
|
-
cssVars[`--${prefix}-image-${imageKey}-url`] = imageConfig.url;
|
|
4377
|
-
}
|
|
4378
|
-
if (imageConfig?.title) {
|
|
4379
|
-
cssVars[`--${prefix}-image-${imageKey}-title`] = imageConfig.title;
|
|
4380
|
-
}
|
|
4381
|
-
if (imageConfig?.alt) {
|
|
4382
|
-
cssVars[`--${prefix}-image-${imageKey}-alt`] = imageConfig.alt;
|
|
4383
|
-
}
|
|
4384
|
-
});
|
|
4385
|
-
}
|
|
4386
|
-
if (theme.components?.Button?.styleOverrides?.root?.borderRadius) {
|
|
4387
|
-
cssVars[`--${prefix}-component-button-root-borderRadius`] = theme.components.Button.styleOverrides.root.borderRadius;
|
|
4388
|
-
}
|
|
4389
|
-
if (theme.components?.Field?.styleOverrides?.root?.borderRadius) {
|
|
4390
|
-
cssVars[`--${prefix}-component-field-root-borderRadius`] = theme.components.Field.styleOverrides.root.borderRadius;
|
|
4391
|
-
}
|
|
4392
|
-
return cssVars;
|
|
4393
|
-
};
|
|
4394
|
-
var toThemeVars = (theme) => {
|
|
4395
|
-
const prefix = theme.cssVarPrefix || VendorConstants_default.VENDOR_PREFIX;
|
|
4396
|
-
const componentVars = {};
|
|
4397
|
-
if (theme.components?.Button?.styleOverrides?.root?.borderRadius) {
|
|
4398
|
-
componentVars.Button = {
|
|
4399
|
-
root: {
|
|
4400
|
-
borderRadius: `var(--${prefix}-component-button-root-borderRadius)`
|
|
4401
|
-
}
|
|
4402
|
-
};
|
|
4403
|
-
}
|
|
4404
|
-
if (theme.components?.Field?.styleOverrides?.root?.borderRadius) {
|
|
4405
|
-
componentVars.Field = {
|
|
4406
|
-
root: {
|
|
4407
|
-
borderRadius: `var(--${prefix}-component-field-root-borderRadius)`
|
|
4408
|
-
}
|
|
4409
|
-
};
|
|
4410
|
-
}
|
|
4411
|
-
const themeVars = {
|
|
4412
|
-
borderRadius: {
|
|
4413
|
-
large: `var(--${prefix}-border-radius-large)`,
|
|
4414
|
-
medium: `var(--${prefix}-border-radius-medium)`,
|
|
4415
|
-
small: `var(--${prefix}-border-radius-small)`
|
|
4416
|
-
},
|
|
4417
|
-
colors: {
|
|
4418
|
-
action: {
|
|
4419
|
-
activatedOpacity: `var(--${prefix}-color-action-activatedOpacity)`,
|
|
4420
|
-
active: `var(--${prefix}-color-action-active)`,
|
|
4421
|
-
disabled: `var(--${prefix}-color-action-disabled)`,
|
|
4422
|
-
disabledBackground: `var(--${prefix}-color-action-disabledBackground)`,
|
|
4423
|
-
disabledOpacity: `var(--${prefix}-color-action-disabledOpacity)`,
|
|
4424
|
-
focus: `var(--${prefix}-color-action-focus)`,
|
|
4425
|
-
focusOpacity: `var(--${prefix}-color-action-focusOpacity)`,
|
|
4426
|
-
hover: `var(--${prefix}-color-action-hover)`,
|
|
4427
|
-
hoverOpacity: `var(--${prefix}-color-action-hoverOpacity)`,
|
|
4428
|
-
selected: `var(--${prefix}-color-action-selected)`,
|
|
4429
|
-
selectedOpacity: `var(--${prefix}-color-action-selectedOpacity)`
|
|
4430
|
-
},
|
|
4431
|
-
background: {
|
|
4432
|
-
body: {
|
|
4433
|
-
main: `var(--${prefix}-color-background-body-main)`
|
|
4434
|
-
},
|
|
4435
|
-
disabled: `var(--${prefix}-color-background-disabled)`,
|
|
4436
|
-
surface: `var(--${prefix}-color-background-surface)`
|
|
4437
|
-
},
|
|
4438
|
-
border: `var(--${prefix}-color-border)`,
|
|
4439
|
-
error: {
|
|
4440
|
-
contrastText: `var(--${prefix}-color-error-contrastText)`,
|
|
4441
|
-
main: `var(--${prefix}-color-error-main)`
|
|
4442
|
-
},
|
|
4443
|
-
info: {
|
|
4444
|
-
contrastText: `var(--${prefix}-color-info-contrastText)`,
|
|
4445
|
-
main: `var(--${prefix}-color-info-main)`
|
|
4446
|
-
},
|
|
4447
|
-
primary: {
|
|
4448
|
-
contrastText: `var(--${prefix}-color-primary-contrastText)`,
|
|
4449
|
-
main: `var(--${prefix}-color-primary-main)`
|
|
4450
|
-
},
|
|
4451
|
-
secondary: {
|
|
4452
|
-
contrastText: `var(--${prefix}-color-secondary-contrastText)`,
|
|
4453
|
-
main: `var(--${prefix}-color-secondary-main)`
|
|
4454
|
-
},
|
|
4455
|
-
success: {
|
|
4456
|
-
contrastText: `var(--${prefix}-color-success-contrastText)`,
|
|
4457
|
-
main: `var(--${prefix}-color-success-main)`
|
|
4458
|
-
},
|
|
4459
|
-
text: {
|
|
4460
|
-
primary: `var(--${prefix}-color-text-primary)`,
|
|
4461
|
-
secondary: `var(--${prefix}-color-text-secondary)`
|
|
4462
|
-
},
|
|
4463
|
-
warning: {
|
|
4464
|
-
contrastText: `var(--${prefix}-color-warning-contrastText)`,
|
|
4465
|
-
main: `var(--${prefix}-color-warning-main)`
|
|
4466
|
-
}
|
|
4467
|
-
},
|
|
4468
|
-
shadows: {
|
|
4469
|
-
large: `var(--${prefix}-shadow-large)`,
|
|
4470
|
-
medium: `var(--${prefix}-shadow-medium)`,
|
|
4471
|
-
small: `var(--${prefix}-shadow-small)`
|
|
4472
|
-
},
|
|
4473
|
-
spacing: {
|
|
4474
|
-
unit: `var(--${prefix}-spacing-unit)`
|
|
4475
|
-
},
|
|
4476
|
-
typography: {
|
|
4477
|
-
fontFamily: `var(--${prefix}-typography-fontFamily)`,
|
|
4478
|
-
fontSizes: {
|
|
4479
|
-
"2xl": `var(--${prefix}-typography-fontSize-2xl)`,
|
|
4480
|
-
"3xl": `var(--${prefix}-typography-fontSize-3xl)`,
|
|
4481
|
-
lg: `var(--${prefix}-typography-fontSize-lg)`,
|
|
4482
|
-
md: `var(--${prefix}-typography-fontSize-md)`,
|
|
4483
|
-
sm: `var(--${prefix}-typography-fontSize-sm)`,
|
|
4484
|
-
xl: `var(--${prefix}-typography-fontSize-xl)`,
|
|
4485
|
-
xs: `var(--${prefix}-typography-fontSize-xs)`
|
|
4486
|
-
},
|
|
4487
|
-
fontWeights: {
|
|
4488
|
-
bold: `var(--${prefix}-typography-fontWeight-bold)`,
|
|
4489
|
-
medium: `var(--${prefix}-typography-fontWeight-medium)`,
|
|
4490
|
-
normal: `var(--${prefix}-typography-fontWeight-normal)`,
|
|
4491
|
-
semibold: `var(--${prefix}-typography-fontWeight-semibold)`
|
|
4492
|
-
},
|
|
4493
|
-
lineHeights: {
|
|
4494
|
-
normal: `var(--${prefix}-typography-lineHeight-normal)`,
|
|
4495
|
-
relaxed: `var(--${prefix}-typography-lineHeight-relaxed)`,
|
|
4496
|
-
tight: `var(--${prefix}-typography-lineHeight-tight)`
|
|
4497
|
-
}
|
|
4498
|
-
}
|
|
4499
|
-
};
|
|
4500
|
-
if (theme.images) {
|
|
4501
|
-
themeVars.images = {};
|
|
4502
|
-
Object.keys(theme.images).forEach((imageKey) => {
|
|
4503
|
-
const imageConfig = theme.images[imageKey];
|
|
4504
|
-
themeVars.images[imageKey] = {
|
|
4505
|
-
alt: imageConfig?.alt ? `var(--${prefix}-image-${imageKey}-alt)` : void 0,
|
|
4506
|
-
title: imageConfig?.title ? `var(--${prefix}-image-${imageKey}-title)` : void 0,
|
|
4507
|
-
url: imageConfig?.url ? `var(--${prefix}-image-${imageKey}-url)` : void 0
|
|
4508
|
-
};
|
|
4509
|
-
});
|
|
4510
|
-
}
|
|
4511
|
-
if (Object.keys(componentVars).length > 0) {
|
|
4512
|
-
themeVars.components = componentVars;
|
|
4639
|
+
if (theme.colors?.background?.body?.main) {
|
|
4640
|
+
cssVars[`--${prefix}-color-background-body-main`] = theme.colors.background.body.main;
|
|
4513
4641
|
}
|
|
4514
|
-
|
|
4515
|
-
};
|
|
4516
|
-
var createTheme = (config = {}, isDark = false) => {
|
|
4517
|
-
const baseTheme = isDark ? darkTheme : lightTheme;
|
|
4518
|
-
const mergedConfig = {
|
|
4519
|
-
...baseTheme,
|
|
4520
|
-
...config,
|
|
4521
|
-
borderRadius: {
|
|
4522
|
-
...baseTheme.borderRadius,
|
|
4523
|
-
...config.borderRadius
|
|
4524
|
-
},
|
|
4525
|
-
colors: {
|
|
4526
|
-
...baseTheme.colors,
|
|
4527
|
-
...config.colors,
|
|
4528
|
-
action: {
|
|
4529
|
-
...baseTheme.colors.action,
|
|
4530
|
-
...config.colors?.action || {}
|
|
4531
|
-
},
|
|
4532
|
-
secondary: {
|
|
4533
|
-
...baseTheme.colors.secondary,
|
|
4534
|
-
...config.colors?.secondary || {}
|
|
4535
|
-
}
|
|
4536
|
-
},
|
|
4537
|
-
images: {
|
|
4538
|
-
...baseTheme.images,
|
|
4539
|
-
...config.images
|
|
4540
|
-
},
|
|
4541
|
-
shadows: {
|
|
4542
|
-
...baseTheme.shadows,
|
|
4543
|
-
...config.shadows
|
|
4544
|
-
},
|
|
4545
|
-
spacing: {
|
|
4546
|
-
...baseTheme.spacing,
|
|
4547
|
-
...config.spacing
|
|
4548
|
-
},
|
|
4549
|
-
typography: {
|
|
4550
|
-
...baseTheme.typography,
|
|
4551
|
-
...config.typography,
|
|
4552
|
-
fontSizes: {
|
|
4553
|
-
...baseTheme.typography.fontSizes,
|
|
4554
|
-
...config.typography?.fontSizes || {}
|
|
4555
|
-
},
|
|
4556
|
-
fontWeights: {
|
|
4557
|
-
...baseTheme.typography.fontWeights,
|
|
4558
|
-
...config.typography?.fontWeights || {}
|
|
4559
|
-
},
|
|
4560
|
-
lineHeights: {
|
|
4561
|
-
...baseTheme.typography.lineHeights,
|
|
4562
|
-
...config.typography?.lineHeights || {}
|
|
4563
|
-
}
|
|
4564
|
-
}
|
|
4565
|
-
};
|
|
4566
|
-
return {
|
|
4567
|
-
...mergedConfig,
|
|
4568
|
-
cssVariables: toCssVariables(mergedConfig),
|
|
4569
|
-
vars: toThemeVars(mergedConfig)
|
|
4570
|
-
};
|
|
4571
|
-
};
|
|
4572
|
-
var DEFAULT_THEME = "light";
|
|
4573
|
-
var createTheme_default = createTheme;
|
|
4574
|
-
|
|
4575
|
-
// src/utils/arrayBufferToBase64url.ts
|
|
4576
|
-
var arrayBufferToBase64url = (buffer) => {
|
|
4577
|
-
const bytes = new Uint8Array(buffer);
|
|
4578
|
-
let binary = "";
|
|
4579
|
-
for (let i = 0; i < bytes.byteLength; i += 1) {
|
|
4580
|
-
binary += String.fromCharCode(bytes[i]);
|
|
4642
|
+
if (theme.colors?.error?.main) {
|
|
4643
|
+
cssVars[`--${prefix}-color-error-main`] = theme.colors.error.main;
|
|
4581
4644
|
}
|
|
4582
|
-
|
|
4583
|
-
};
|
|
4584
|
-
var arrayBufferToBase64url_default = arrayBufferToBase64url;
|
|
4585
|
-
|
|
4586
|
-
// src/utils/base64urlToArrayBuffer.ts
|
|
4587
|
-
var base64urlToArrayBuffer = (base64url2) => {
|
|
4588
|
-
const padding = "=".repeat((4 - base64url2.length % 4) % 4);
|
|
4589
|
-
const base64 = base64url2.replace(/-/g, "+").replace(/_/g, "/") + padding;
|
|
4590
|
-
const binaryString = atob(base64);
|
|
4591
|
-
const bytes = new Uint8Array(binaryString.length);
|
|
4592
|
-
for (let i = 0; i < binaryString.length; i += 1) {
|
|
4593
|
-
bytes[i] = binaryString.charCodeAt(i);
|
|
4645
|
+
if (theme.colors?.error?.contrastText) {
|
|
4646
|
+
cssVars[`--${prefix}-color-error-contrastText`] = theme.colors.error.contrastText;
|
|
4594
4647
|
}
|
|
4595
|
-
|
|
4596
|
-
};
|
|
4597
|
-
var base64urlToArrayBuffer_default = base64urlToArrayBuffer;
|
|
4598
|
-
|
|
4599
|
-
// src/utils/bem.ts
|
|
4600
|
-
var bem = (baseClass, element, modifier) => {
|
|
4601
|
-
let className = baseClass;
|
|
4602
|
-
if (element) {
|
|
4603
|
-
className += `__${element}`;
|
|
4648
|
+
if (theme.colors?.error?.light) {
|
|
4649
|
+
cssVars[`--${prefix}-color-error-light`] = theme.colors.error.light;
|
|
4604
4650
|
}
|
|
4605
|
-
if (
|
|
4606
|
-
|
|
4651
|
+
if (theme.colors?.success?.main) {
|
|
4652
|
+
cssVars[`--${prefix}-color-success-main`] = theme.colors.success.main;
|
|
4607
4653
|
}
|
|
4608
|
-
|
|
4609
|
-
};
|
|
4610
|
-
var bem_default = bem;
|
|
4611
|
-
|
|
4612
|
-
// src/utils/formatDate.ts
|
|
4613
|
-
var formatDate = (dateString) => {
|
|
4614
|
-
if (!dateString) return "-";
|
|
4615
|
-
try {
|
|
4616
|
-
return new Date(dateString).toLocaleDateString("en-US", {
|
|
4617
|
-
day: "numeric",
|
|
4618
|
-
month: "long",
|
|
4619
|
-
year: "numeric"
|
|
4620
|
-
});
|
|
4621
|
-
} catch {
|
|
4622
|
-
return dateString;
|
|
4654
|
+
if (theme.colors?.success?.contrastText) {
|
|
4655
|
+
cssVars[`--${prefix}-color-success-contrastText`] = theme.colors.success.contrastText;
|
|
4623
4656
|
}
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
// src/utils/logger.ts
|
|
4628
|
-
var PREFIX = "\u{1F6E1}\uFE0F Asgardeo";
|
|
4629
|
-
var DEFAULT_CONFIG = {
|
|
4630
|
-
level: "info",
|
|
4631
|
-
prefix: `${PREFIX}`,
|
|
4632
|
-
showLevel: true,
|
|
4633
|
-
timestamps: true
|
|
4634
|
-
};
|
|
4635
|
-
var isBrowser = () => (
|
|
4636
|
-
/* @ts-ignore */
|
|
4637
|
-
typeof window !== "undefined" && typeof window.document !== "undefined"
|
|
4638
|
-
);
|
|
4639
|
-
var isNode = () => (
|
|
4640
|
-
/* @ts-ignore */
|
|
4641
|
-
typeof process !== "undefined" && process.versions && process.versions.node
|
|
4642
|
-
);
|
|
4643
|
-
var COLORS = {
|
|
4644
|
-
blue: "\x1B[34m",
|
|
4645
|
-
bright: "\x1B[1m",
|
|
4646
|
-
cyan: "\x1B[36m",
|
|
4647
|
-
dim: "\x1B[2m",
|
|
4648
|
-
gray: "\x1B[90m",
|
|
4649
|
-
green: "\x1B[32m",
|
|
4650
|
-
magenta: "\x1B[35m",
|
|
4651
|
-
red: "\x1B[31m",
|
|
4652
|
-
reset: "\x1B[0m",
|
|
4653
|
-
white: "\x1B[37m",
|
|
4654
|
-
yellow: "\x1B[33m"
|
|
4655
|
-
};
|
|
4656
|
-
var BROWSER_STYLES = {
|
|
4657
|
-
debug: "color: #6b7280; font-weight: normal;",
|
|
4658
|
-
error: "color: #dc2626; font-weight: bold;",
|
|
4659
|
-
info: "color: #2563eb; font-weight: bold;",
|
|
4660
|
-
prefix: "color: #7c3aed; font-weight: bold;",
|
|
4661
|
-
timestamp: "color: #6b7280; font-size: 0.9em;",
|
|
4662
|
-
warn: "color: #d97706; font-weight: bold;"
|
|
4663
|
-
};
|
|
4664
|
-
var LOG_LEVEL_ORDER = {
|
|
4665
|
-
debug: 0,
|
|
4666
|
-
error: 3,
|
|
4667
|
-
info: 1,
|
|
4668
|
-
warn: 2
|
|
4669
|
-
};
|
|
4670
|
-
var Logger = class _Logger {
|
|
4671
|
-
constructor(config = {}) {
|
|
4672
|
-
__publicField(this, "config");
|
|
4673
|
-
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
4657
|
+
if (theme.colors?.success?.light) {
|
|
4658
|
+
cssVars[`--${prefix}-color-success-light`] = theme.colors.success.light;
|
|
4674
4659
|
}
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
|
|
4660
|
+
if (theme.colors?.warning?.main) {
|
|
4661
|
+
cssVars[`--${prefix}-color-warning-main`] = theme.colors.warning.main;
|
|
4662
|
+
}
|
|
4663
|
+
if (theme.colors?.warning?.contrastText) {
|
|
4664
|
+
cssVars[`--${prefix}-color-warning-contrastText`] = theme.colors.warning.contrastText;
|
|
4665
|
+
}
|
|
4666
|
+
if (theme.colors?.warning?.light) {
|
|
4667
|
+
cssVars[`--${prefix}-color-warning-light`] = theme.colors.warning.light;
|
|
4668
|
+
}
|
|
4669
|
+
if (theme.colors?.info?.main) {
|
|
4670
|
+
cssVars[`--${prefix}-color-info-main`] = theme.colors.info.main;
|
|
4671
|
+
}
|
|
4672
|
+
if (theme.colors?.info?.contrastText) {
|
|
4673
|
+
cssVars[`--${prefix}-color-info-contrastText`] = theme.colors.info.contrastText;
|
|
4674
|
+
}
|
|
4675
|
+
if (theme.colors?.info?.light) {
|
|
4676
|
+
cssVars[`--${prefix}-color-info-light`] = theme.colors.info.light;
|
|
4677
|
+
}
|
|
4678
|
+
if (theme.colors?.text?.primary) {
|
|
4679
|
+
cssVars[`--${prefix}-color-text-primary`] = theme.colors.text.primary;
|
|
4680
|
+
}
|
|
4681
|
+
if (theme.colors?.text?.secondary) {
|
|
4682
|
+
cssVars[`--${prefix}-color-text-secondary`] = theme.colors.text.secondary;
|
|
4683
|
+
}
|
|
4684
|
+
if (theme.colors?.border) {
|
|
4685
|
+
cssVars[`--${prefix}-color-border`] = theme.colors.border;
|
|
4686
|
+
}
|
|
4687
|
+
if (theme.spacing?.unit !== void 0) {
|
|
4688
|
+
cssVars[`--${prefix}-spacing-unit`] = `${theme.spacing.unit}px`;
|
|
4689
|
+
}
|
|
4690
|
+
if (theme.borderRadius?.small) {
|
|
4691
|
+
cssVars[`--${prefix}-border-radius-small`] = theme.borderRadius.small;
|
|
4692
|
+
}
|
|
4693
|
+
if (theme.borderRadius?.medium) {
|
|
4694
|
+
cssVars[`--${prefix}-border-radius-medium`] = theme.borderRadius.medium;
|
|
4695
|
+
}
|
|
4696
|
+
if (theme.borderRadius?.large) {
|
|
4697
|
+
cssVars[`--${prefix}-border-radius-large`] = theme.borderRadius.large;
|
|
4698
|
+
}
|
|
4699
|
+
if (theme.shadows?.small) {
|
|
4700
|
+
cssVars[`--${prefix}-shadow-small`] = theme.shadows.small;
|
|
4701
|
+
}
|
|
4702
|
+
if (theme.shadows?.medium) {
|
|
4703
|
+
cssVars[`--${prefix}-shadow-medium`] = theme.shadows.medium;
|
|
4704
|
+
}
|
|
4705
|
+
if (theme.shadows?.large) {
|
|
4706
|
+
cssVars[`--${prefix}-shadow-large`] = theme.shadows.large;
|
|
4707
|
+
}
|
|
4708
|
+
if (theme.typography?.fontFamily) {
|
|
4709
|
+
cssVars[`--${prefix}-typography-fontFamily`] = theme.typography.fontFamily;
|
|
4710
|
+
}
|
|
4711
|
+
if (theme.typography?.fontSizes?.xs) {
|
|
4712
|
+
cssVars[`--${prefix}-typography-fontSize-xs`] = theme.typography.fontSizes.xs;
|
|
4713
|
+
}
|
|
4714
|
+
if (theme.typography?.fontSizes?.sm) {
|
|
4715
|
+
cssVars[`--${prefix}-typography-fontSize-sm`] = theme.typography.fontSizes.sm;
|
|
4716
|
+
}
|
|
4717
|
+
if (theme.typography?.fontSizes?.md) {
|
|
4718
|
+
cssVars[`--${prefix}-typography-fontSize-md`] = theme.typography.fontSizes.md;
|
|
4719
|
+
}
|
|
4720
|
+
if (theme.typography?.fontSizes?.lg) {
|
|
4721
|
+
cssVars[`--${prefix}-typography-fontSize-lg`] = theme.typography.fontSizes.lg;
|
|
4722
|
+
}
|
|
4723
|
+
if (theme.typography?.fontSizes?.xl) {
|
|
4724
|
+
cssVars[`--${prefix}-typography-fontSize-xl`] = theme.typography.fontSizes.xl;
|
|
4725
|
+
}
|
|
4726
|
+
if (theme.typography?.fontSizes?.["2xl"]) {
|
|
4727
|
+
cssVars[`--${prefix}-typography-fontSize-2xl`] = theme.typography.fontSizes["2xl"];
|
|
4728
|
+
}
|
|
4729
|
+
if (theme.typography?.fontSizes?.["3xl"]) {
|
|
4730
|
+
cssVars[`--${prefix}-typography-fontSize-3xl`] = theme.typography.fontSizes["3xl"];
|
|
4731
|
+
}
|
|
4732
|
+
if (theme.typography?.fontWeights?.normal !== void 0) {
|
|
4733
|
+
cssVars[`--${prefix}-typography-fontWeight-normal`] = theme.typography.fontWeights.normal.toString();
|
|
4734
|
+
}
|
|
4735
|
+
if (theme.typography?.fontWeights?.medium !== void 0) {
|
|
4736
|
+
cssVars[`--${prefix}-typography-fontWeight-medium`] = theme.typography.fontWeights.medium.toString();
|
|
4737
|
+
}
|
|
4738
|
+
if (theme.typography?.fontWeights?.semibold !== void 0) {
|
|
4739
|
+
cssVars[`--${prefix}-typography-fontWeight-semibold`] = theme.typography.fontWeights.semibold.toString();
|
|
4740
|
+
}
|
|
4741
|
+
if (theme.typography?.fontWeights?.bold !== void 0) {
|
|
4742
|
+
cssVars[`--${prefix}-typography-fontWeight-bold`] = theme.typography.fontWeights.bold.toString();
|
|
4680
4743
|
}
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
|
-
*/
|
|
4684
|
-
getConfig() {
|
|
4685
|
-
return { ...this.config };
|
|
4744
|
+
if (theme.typography?.lineHeights?.tight !== void 0) {
|
|
4745
|
+
cssVars[`--${prefix}-typography-lineHeight-tight`] = theme.typography.lineHeights.tight.toString();
|
|
4686
4746
|
}
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
|
-
*/
|
|
4690
|
-
shouldLog(level) {
|
|
4691
|
-
return LOG_LEVEL_ORDER[level] >= LOG_LEVEL_ORDER[this.config.level];
|
|
4747
|
+
if (theme.typography?.lineHeights?.normal !== void 0) {
|
|
4748
|
+
cssVars[`--${prefix}-typography-lineHeight-normal`] = theme.typography.lineHeights.normal.toString();
|
|
4692
4749
|
}
|
|
4693
|
-
|
|
4694
|
-
|
|
4695
|
-
*/
|
|
4696
|
-
static getTimestamp() {
|
|
4697
|
-
return (/* @__PURE__ */ new Date()).toISOString();
|
|
4750
|
+
if (theme.typography?.lineHeights?.relaxed !== void 0) {
|
|
4751
|
+
cssVars[`--${prefix}-typography-lineHeight-relaxed`] = theme.typography.lineHeights.relaxed.toString();
|
|
4698
4752
|
}
|
|
4699
|
-
|
|
4700
|
-
|
|
4701
|
-
|
|
4702
|
-
|
|
4703
|
-
|
|
4704
|
-
|
|
4705
|
-
|
|
4706
|
-
|
|
4707
|
-
|
|
4708
|
-
|
|
4709
|
-
|
|
4710
|
-
|
|
4711
|
-
|
|
4712
|
-
default:
|
|
4713
|
-
return "UNKNOWN";
|
|
4714
|
-
}
|
|
4753
|
+
if (theme.images) {
|
|
4754
|
+
Object.keys(theme.images).forEach((imageKey) => {
|
|
4755
|
+
const imageConfig = theme.images[imageKey];
|
|
4756
|
+
if (imageConfig?.url) {
|
|
4757
|
+
cssVars[`--${prefix}-image-${imageKey}-url`] = imageConfig.url;
|
|
4758
|
+
}
|
|
4759
|
+
if (imageConfig?.title) {
|
|
4760
|
+
cssVars[`--${prefix}-image-${imageKey}-title`] = imageConfig.title;
|
|
4761
|
+
}
|
|
4762
|
+
if (imageConfig?.alt) {
|
|
4763
|
+
cssVars[`--${prefix}-image-${imageKey}-alt`] = imageConfig.alt;
|
|
4764
|
+
}
|
|
4765
|
+
});
|
|
4715
4766
|
}
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
|
|
4730
|
-
|
|
4731
|
-
case "debug":
|
|
4732
|
-
coloredLevel = `${COLORS.gray}[${levelStr}]${COLORS.reset}`;
|
|
4733
|
-
break;
|
|
4734
|
-
case "info":
|
|
4735
|
-
coloredLevel = `${COLORS.blue}[${levelStr}]${COLORS.reset}`;
|
|
4736
|
-
break;
|
|
4737
|
-
case "warn":
|
|
4738
|
-
coloredLevel = `${COLORS.yellow}[${levelStr}]${COLORS.reset}`;
|
|
4739
|
-
break;
|
|
4740
|
-
case "error":
|
|
4741
|
-
coloredLevel = `${COLORS.red}[${levelStr}]${COLORS.reset}`;
|
|
4742
|
-
break;
|
|
4743
|
-
default:
|
|
4744
|
-
coloredLevel = `[${levelStr}]`;
|
|
4767
|
+
if (theme.components?.Button?.styleOverrides?.root?.borderRadius) {
|
|
4768
|
+
cssVars[`--${prefix}-component-button-root-borderRadius`] = theme.components.Button.styleOverrides.root.borderRadius;
|
|
4769
|
+
}
|
|
4770
|
+
if (theme.components?.Field?.styleOverrides?.root?.borderRadius) {
|
|
4771
|
+
cssVars[`--${prefix}-component-field-root-borderRadius`] = theme.components.Field.styleOverrides.root.borderRadius;
|
|
4772
|
+
}
|
|
4773
|
+
return cssVars;
|
|
4774
|
+
};
|
|
4775
|
+
var toThemeVars = (theme) => {
|
|
4776
|
+
const prefix = theme.cssVarPrefix || VendorConstants_default.VENDOR_PREFIX;
|
|
4777
|
+
const componentVars = {};
|
|
4778
|
+
if (theme.components?.Button?.styleOverrides?.root?.borderRadius) {
|
|
4779
|
+
componentVars.Button = {
|
|
4780
|
+
root: {
|
|
4781
|
+
borderRadius: `var(--${prefix}-component-button-root-borderRadius)`
|
|
4745
4782
|
}
|
|
4746
|
-
|
|
4747
|
-
}
|
|
4748
|
-
parts.push(message);
|
|
4749
|
-
return parts.join(" ");
|
|
4783
|
+
};
|
|
4750
4784
|
}
|
|
4751
|
-
|
|
4752
|
-
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
}
|
|
4758
|
-
if (this.config.formatter) {
|
|
4759
|
-
this.config.formatter(level, message, ...args);
|
|
4760
|
-
return;
|
|
4761
|
-
}
|
|
4762
|
-
if (isBrowser()) {
|
|
4763
|
-
this.logToBrowser(level, message, ...args);
|
|
4764
|
-
} else if (isNode()) {
|
|
4765
|
-
this.logToNode(level, message, ...args);
|
|
4766
|
-
} else {
|
|
4767
|
-
console.log(message, ...args);
|
|
4768
|
-
}
|
|
4785
|
+
if (theme.components?.Field?.styleOverrides?.root?.borderRadius) {
|
|
4786
|
+
componentVars.Field = {
|
|
4787
|
+
root: {
|
|
4788
|
+
borderRadius: `var(--${prefix}-component-field-root-borderRadius)`
|
|
4789
|
+
}
|
|
4790
|
+
};
|
|
4769
4791
|
}
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
4792
|
+
const themeVars = {
|
|
4793
|
+
borderRadius: {
|
|
4794
|
+
large: `var(--${prefix}-border-radius-large)`,
|
|
4795
|
+
medium: `var(--${prefix}-border-radius-medium)`,
|
|
4796
|
+
small: `var(--${prefix}-border-radius-small)`
|
|
4797
|
+
},
|
|
4798
|
+
colors: {
|
|
4799
|
+
action: {
|
|
4800
|
+
activatedOpacity: `var(--${prefix}-color-action-activatedOpacity)`,
|
|
4801
|
+
active: `var(--${prefix}-color-action-active)`,
|
|
4802
|
+
disabled: `var(--${prefix}-color-action-disabled)`,
|
|
4803
|
+
disabledBackground: `var(--${prefix}-color-action-disabledBackground)`,
|
|
4804
|
+
disabledOpacity: `var(--${prefix}-color-action-disabledOpacity)`,
|
|
4805
|
+
focus: `var(--${prefix}-color-action-focus)`,
|
|
4806
|
+
focusOpacity: `var(--${prefix}-color-action-focusOpacity)`,
|
|
4807
|
+
hover: `var(--${prefix}-color-action-hover)`,
|
|
4808
|
+
hoverOpacity: `var(--${prefix}-color-action-hoverOpacity)`,
|
|
4809
|
+
selected: `var(--${prefix}-color-action-selected)`,
|
|
4810
|
+
selectedOpacity: `var(--${prefix}-color-action-selectedOpacity)`
|
|
4811
|
+
},
|
|
4812
|
+
background: {
|
|
4813
|
+
body: {
|
|
4814
|
+
main: `var(--${prefix}-color-background-body-main)`
|
|
4815
|
+
},
|
|
4816
|
+
disabled: `var(--${prefix}-color-background-disabled)`,
|
|
4817
|
+
surface: `var(--${prefix}-color-background-surface)`
|
|
4818
|
+
},
|
|
4819
|
+
border: `var(--${prefix}-color-border)`,
|
|
4820
|
+
error: {
|
|
4821
|
+
contrastText: `var(--${prefix}-color-error-contrastText)`,
|
|
4822
|
+
main: `var(--${prefix}-color-error-main)`
|
|
4823
|
+
},
|
|
4824
|
+
info: {
|
|
4825
|
+
contrastText: `var(--${prefix}-color-info-contrastText)`,
|
|
4826
|
+
main: `var(--${prefix}-color-info-main)`
|
|
4827
|
+
},
|
|
4828
|
+
primary: {
|
|
4829
|
+
contrastText: `var(--${prefix}-color-primary-contrastText)`,
|
|
4830
|
+
main: `var(--${prefix}-color-primary-main)`
|
|
4831
|
+
},
|
|
4832
|
+
secondary: {
|
|
4833
|
+
contrastText: `var(--${prefix}-color-secondary-contrastText)`,
|
|
4834
|
+
main: `var(--${prefix}-color-secondary-main)`
|
|
4835
|
+
},
|
|
4836
|
+
success: {
|
|
4837
|
+
contrastText: `var(--${prefix}-color-success-contrastText)`,
|
|
4838
|
+
main: `var(--${prefix}-color-success-main)`
|
|
4839
|
+
},
|
|
4840
|
+
text: {
|
|
4841
|
+
primary: `var(--${prefix}-color-text-primary)`,
|
|
4842
|
+
secondary: `var(--${prefix}-color-text-secondary)`
|
|
4843
|
+
},
|
|
4844
|
+
warning: {
|
|
4845
|
+
contrastText: `var(--${prefix}-color-warning-contrastText)`,
|
|
4846
|
+
main: `var(--${prefix}-color-warning-main)`
|
|
4847
|
+
}
|
|
4848
|
+
},
|
|
4849
|
+
shadows: {
|
|
4850
|
+
large: `var(--${prefix}-shadow-large)`,
|
|
4851
|
+
medium: `var(--${prefix}-shadow-medium)`,
|
|
4852
|
+
small: `var(--${prefix}-shadow-small)`
|
|
4853
|
+
},
|
|
4854
|
+
spacing: {
|
|
4855
|
+
unit: `var(--${prefix}-spacing-unit)`
|
|
4856
|
+
},
|
|
4857
|
+
typography: {
|
|
4858
|
+
fontFamily: `var(--${prefix}-typography-fontFamily)`,
|
|
4859
|
+
fontSizes: {
|
|
4860
|
+
"2xl": `var(--${prefix}-typography-fontSize-2xl)`,
|
|
4861
|
+
"3xl": `var(--${prefix}-typography-fontSize-3xl)`,
|
|
4862
|
+
lg: `var(--${prefix}-typography-fontSize-lg)`,
|
|
4863
|
+
md: `var(--${prefix}-typography-fontSize-md)`,
|
|
4864
|
+
sm: `var(--${prefix}-typography-fontSize-sm)`,
|
|
4865
|
+
xl: `var(--${prefix}-typography-fontSize-xl)`,
|
|
4866
|
+
xs: `var(--${prefix}-typography-fontSize-xs)`
|
|
4867
|
+
},
|
|
4868
|
+
fontWeights: {
|
|
4869
|
+
bold: `var(--${prefix}-typography-fontWeight-bold)`,
|
|
4870
|
+
medium: `var(--${prefix}-typography-fontWeight-medium)`,
|
|
4871
|
+
normal: `var(--${prefix}-typography-fontWeight-normal)`,
|
|
4872
|
+
semibold: `var(--${prefix}-typography-fontWeight-semibold)`
|
|
4873
|
+
},
|
|
4874
|
+
lineHeights: {
|
|
4875
|
+
normal: `var(--${prefix}-typography-lineHeight-normal)`,
|
|
4876
|
+
relaxed: `var(--${prefix}-typography-lineHeight-relaxed)`,
|
|
4877
|
+
tight: `var(--${prefix}-typography-lineHeight-tight)`
|
|
4802
4878
|
}
|
|
4803
4879
|
}
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
console.warn(formattedMessage, ...styles, ...args);
|
|
4816
|
-
break;
|
|
4817
|
-
case "error":
|
|
4818
|
-
console.error(formattedMessage, ...styles, ...args);
|
|
4819
|
-
break;
|
|
4820
|
-
default:
|
|
4821
|
-
console.log(formattedMessage, ...styles, ...args);
|
|
4822
|
-
}
|
|
4880
|
+
};
|
|
4881
|
+
if (theme.images) {
|
|
4882
|
+
themeVars.images = {};
|
|
4883
|
+
Object.keys(theme.images).forEach((imageKey) => {
|
|
4884
|
+
const imageConfig = theme.images[imageKey];
|
|
4885
|
+
themeVars.images[imageKey] = {
|
|
4886
|
+
alt: imageConfig?.alt ? `var(--${prefix}-image-${imageKey}-alt)` : void 0,
|
|
4887
|
+
title: imageConfig?.title ? `var(--${prefix}-image-${imageKey}-title)` : void 0,
|
|
4888
|
+
url: imageConfig?.url ? `var(--${prefix}-image-${imageKey}-url)` : void 0
|
|
4889
|
+
};
|
|
4890
|
+
});
|
|
4823
4891
|
}
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
*/
|
|
4827
|
-
logToNode(level, message, ...args) {
|
|
4828
|
-
const formattedMessage = this.formatForNode(level, message);
|
|
4829
|
-
switch (level) {
|
|
4830
|
-
case "debug":
|
|
4831
|
-
console.debug(formattedMessage, ...args);
|
|
4832
|
-
break;
|
|
4833
|
-
case "info":
|
|
4834
|
-
console.info(formattedMessage, ...args);
|
|
4835
|
-
break;
|
|
4836
|
-
case "warn":
|
|
4837
|
-
console.warn(formattedMessage, ...args);
|
|
4838
|
-
break;
|
|
4839
|
-
case "error":
|
|
4840
|
-
console.error(formattedMessage, ...args);
|
|
4841
|
-
break;
|
|
4842
|
-
default:
|
|
4843
|
-
console.log(formattedMessage, ...args);
|
|
4844
|
-
}
|
|
4892
|
+
if (Object.keys(componentVars).length > 0) {
|
|
4893
|
+
themeVars.components = componentVars;
|
|
4845
4894
|
}
|
|
4846
|
-
|
|
4847
|
-
|
|
4848
|
-
|
|
4849
|
-
|
|
4850
|
-
|
|
4895
|
+
return themeVars;
|
|
4896
|
+
};
|
|
4897
|
+
var createTheme = (config = {}, isDark = false) => {
|
|
4898
|
+
const baseTheme = isDark ? darkTheme : lightTheme;
|
|
4899
|
+
const mergedConfig = {
|
|
4900
|
+
...baseTheme,
|
|
4901
|
+
...config,
|
|
4902
|
+
borderRadius: {
|
|
4903
|
+
...baseTheme.borderRadius,
|
|
4904
|
+
...config.borderRadius
|
|
4905
|
+
},
|
|
4906
|
+
colors: {
|
|
4907
|
+
...baseTheme.colors,
|
|
4908
|
+
...config.colors,
|
|
4909
|
+
action: {
|
|
4910
|
+
...baseTheme.colors.action,
|
|
4911
|
+
...config.colors?.action || {}
|
|
4912
|
+
},
|
|
4913
|
+
secondary: {
|
|
4914
|
+
...baseTheme.colors.secondary,
|
|
4915
|
+
...config.colors?.secondary || {}
|
|
4916
|
+
}
|
|
4917
|
+
},
|
|
4918
|
+
images: {
|
|
4919
|
+
...baseTheme.images,
|
|
4920
|
+
...config.images
|
|
4921
|
+
},
|
|
4922
|
+
shadows: {
|
|
4923
|
+
...baseTheme.shadows,
|
|
4924
|
+
...config.shadows
|
|
4925
|
+
},
|
|
4926
|
+
spacing: {
|
|
4927
|
+
...baseTheme.spacing,
|
|
4928
|
+
...config.spacing
|
|
4929
|
+
},
|
|
4930
|
+
typography: {
|
|
4931
|
+
...baseTheme.typography,
|
|
4932
|
+
...config.typography,
|
|
4933
|
+
fontSizes: {
|
|
4934
|
+
...baseTheme.typography.fontSizes,
|
|
4935
|
+
...config.typography?.fontSizes || {}
|
|
4936
|
+
},
|
|
4937
|
+
fontWeights: {
|
|
4938
|
+
...baseTheme.typography.fontWeights,
|
|
4939
|
+
...config.typography?.fontWeights || {}
|
|
4940
|
+
},
|
|
4941
|
+
lineHeights: {
|
|
4942
|
+
...baseTheme.typography.lineHeights,
|
|
4943
|
+
...config.typography?.lineHeights || {}
|
|
4944
|
+
}
|
|
4945
|
+
}
|
|
4946
|
+
};
|
|
4947
|
+
return {
|
|
4948
|
+
...mergedConfig,
|
|
4949
|
+
cssVariables: toCssVariables(mergedConfig),
|
|
4950
|
+
vars: toThemeVars(mergedConfig)
|
|
4951
|
+
};
|
|
4952
|
+
};
|
|
4953
|
+
var DEFAULT_THEME = "light";
|
|
4954
|
+
var createTheme_default = createTheme;
|
|
4955
|
+
|
|
4956
|
+
// src/utils/arrayBufferToBase64url.ts
|
|
4957
|
+
var arrayBufferToBase64url = (buffer) => {
|
|
4958
|
+
const bytes = new Uint8Array(buffer);
|
|
4959
|
+
let binary = "";
|
|
4960
|
+
for (let i = 0; i < bytes.byteLength; i += 1) {
|
|
4961
|
+
binary += String.fromCharCode(bytes[i]);
|
|
4851
4962
|
}
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
4963
|
+
return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
4964
|
+
};
|
|
4965
|
+
var arrayBufferToBase64url_default = arrayBufferToBase64url;
|
|
4966
|
+
|
|
4967
|
+
// src/utils/base64urlToArrayBuffer.ts
|
|
4968
|
+
var base64urlToArrayBuffer = (base64url3) => {
|
|
4969
|
+
const padding = "=".repeat((4 - base64url3.length % 4) % 4);
|
|
4970
|
+
const base64 = base64url3.replace(/-/g, "+").replace(/_/g, "/") + padding;
|
|
4971
|
+
const binaryString = atob(base64);
|
|
4972
|
+
const bytes = new Uint8Array(binaryString.length);
|
|
4973
|
+
for (let i = 0; i < binaryString.length; i += 1) {
|
|
4974
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
4857
4975
|
}
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
|
|
4976
|
+
return bytes.buffer;
|
|
4977
|
+
};
|
|
4978
|
+
var base64urlToArrayBuffer_default = base64urlToArrayBuffer;
|
|
4979
|
+
|
|
4980
|
+
// src/utils/bem.ts
|
|
4981
|
+
var bem = (baseClass, element, modifier) => {
|
|
4982
|
+
let className = baseClass;
|
|
4983
|
+
if (element) {
|
|
4984
|
+
className += `__${element}`;
|
|
4863
4985
|
}
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
*/
|
|
4867
|
-
error(message, ...args) {
|
|
4868
|
-
this.logMessage("error", message, ...args);
|
|
4986
|
+
if (modifier) {
|
|
4987
|
+
className += `--${modifier}`;
|
|
4869
4988
|
}
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4989
|
+
return className;
|
|
4990
|
+
};
|
|
4991
|
+
var bem_default = bem;
|
|
4992
|
+
|
|
4993
|
+
// src/utils/formatDate.ts
|
|
4994
|
+
var formatDate = (dateString) => {
|
|
4995
|
+
if (!dateString) return "-";
|
|
4996
|
+
try {
|
|
4997
|
+
return new Date(dateString).toLocaleDateString("en-US", {
|
|
4998
|
+
day: "numeric",
|
|
4999
|
+
month: "long",
|
|
5000
|
+
year: "numeric"
|
|
4878
5001
|
});
|
|
5002
|
+
} catch {
|
|
5003
|
+
return dateString;
|
|
4879
5004
|
}
|
|
4880
|
-
/**
|
|
4881
|
-
* Set log level
|
|
4882
|
-
*/
|
|
4883
|
-
setLevel(level) {
|
|
4884
|
-
this.config.level = level;
|
|
4885
|
-
}
|
|
4886
|
-
/**
|
|
4887
|
-
* Get current log level
|
|
4888
|
-
*/
|
|
4889
|
-
getLevel() {
|
|
4890
|
-
return this.config.level;
|
|
4891
|
-
}
|
|
4892
|
-
};
|
|
4893
|
-
var logger = new Logger();
|
|
4894
|
-
var createLogger = (config) => new Logger(config);
|
|
4895
|
-
var logger_default = logger;
|
|
4896
|
-
var debug = (message, ...args) => logger.debug(message, ...args);
|
|
4897
|
-
var info = (message, ...args) => logger.info(message, ...args);
|
|
4898
|
-
var warn = (message, ...args) => logger.warn(message, ...args);
|
|
4899
|
-
var error = (message, ...args) => logger.error(message, ...args);
|
|
4900
|
-
var configure = (config) => logger.configure(config);
|
|
4901
|
-
var createComponentLogger = (component) => logger.child(component);
|
|
4902
|
-
var createPackageLogger = (packageName) => createLogger({
|
|
4903
|
-
level: "info",
|
|
4904
|
-
prefix: `${PREFIX} - ${packageName}`,
|
|
4905
|
-
showLevel: true,
|
|
4906
|
-
timestamps: true
|
|
4907
|
-
});
|
|
4908
|
-
var createPackageComponentLogger = (packageName, component) => {
|
|
4909
|
-
const packageLogger = createPackageLogger(packageName);
|
|
4910
|
-
return packageLogger.child(component);
|
|
4911
5005
|
};
|
|
5006
|
+
var formatDate_default = formatDate;
|
|
4912
5007
|
|
|
4913
5008
|
// src/utils/deriveOrganizationHandleFromBaseUrl.ts
|
|
4914
5009
|
var deriveOrganizationHandleFromBaseUrl = (baseUrl) => {
|
|
@@ -4959,38 +5054,6 @@ var deriveOrganizationHandleFromBaseUrl = (baseUrl) => {
|
|
|
4959
5054
|
};
|
|
4960
5055
|
var deriveOrganizationHandleFromBaseUrl_default = deriveOrganizationHandleFromBaseUrl;
|
|
4961
5056
|
|
|
4962
|
-
// src/utils/isRecognizedBaseUrlPattern.ts
|
|
4963
|
-
var isRecognizedBaseUrlPattern = (baseUrl) => {
|
|
4964
|
-
if (!baseUrl) {
|
|
4965
|
-
throw new AsgardeoRuntimeError(
|
|
4966
|
-
"Base URL is required to derive if the `baseUrl` is recognized.",
|
|
4967
|
-
"isRecognizedBaseUrlPattern-ValidationError-001",
|
|
4968
|
-
"javascript",
|
|
4969
|
-
"A valid base URL must be provided to derive if the `baseUrl` is recognized to use the sensible fallbacks."
|
|
4970
|
-
);
|
|
4971
|
-
}
|
|
4972
|
-
let parsedUrl;
|
|
4973
|
-
try {
|
|
4974
|
-
parsedUrl = new URL(baseUrl);
|
|
4975
|
-
} catch (error2) {
|
|
4976
|
-
throw new AsgardeoRuntimeError(
|
|
4977
|
-
`Invalid base URL format: ${baseUrl}`,
|
|
4978
|
-
"isRecognizedBaseUrlPattern-ValidationError-002",
|
|
4979
|
-
"javascript",
|
|
4980
|
-
"The provided base URL does not conform to valid URL syntax."
|
|
4981
|
-
);
|
|
4982
|
-
}
|
|
4983
|
-
const pathSegments = parsedUrl.pathname?.split("/")?.filter((segment) => segment?.length > 0);
|
|
4984
|
-
if (pathSegments.length < 2 || pathSegments[0] !== "t") {
|
|
4985
|
-
logger_default.warn(
|
|
4986
|
-
"[isRecognizedBaseUrlPattern] The provided base URL does not follow the expected URL pattern (/t/{orgHandle})."
|
|
4987
|
-
);
|
|
4988
|
-
return false;
|
|
4989
|
-
}
|
|
4990
|
-
return true;
|
|
4991
|
-
};
|
|
4992
|
-
var isRecognizedBaseUrlPattern_default = isRecognizedBaseUrlPattern;
|
|
4993
|
-
|
|
4994
5057
|
// src/utils/flattenUserSchema.ts
|
|
4995
5058
|
var flattenUserSchema = (schemas) => {
|
|
4996
5059
|
const flattenedAttributes = [];
|
|
@@ -5176,31 +5239,6 @@ var generateFlattenedUserProfile = (meResponse, processedSchemas) => {
|
|
|
5176
5239
|
};
|
|
5177
5240
|
var generateFlattenedUserProfile_default = generateFlattenedUserProfile;
|
|
5178
5241
|
|
|
5179
|
-
// src/utils/identifyPlatform.ts
|
|
5180
|
-
var identifyPlatform = (config) => {
|
|
5181
|
-
const { baseUrl } = config;
|
|
5182
|
-
try {
|
|
5183
|
-
if (isRecognizedBaseUrlPattern_default(baseUrl)) {
|
|
5184
|
-
try {
|
|
5185
|
-
const url = new URL(baseUrl);
|
|
5186
|
-
if (/\.asgardeo\.io$/i.test(url.hostname) || /asgardeo\.io$/i.test(url.hostname)) {
|
|
5187
|
-
return "ASGARDEO" /* Asgardeo */;
|
|
5188
|
-
}
|
|
5189
|
-
} catch {
|
|
5190
|
-
logger_default.debug(
|
|
5191
|
-
`[identifyPlatform] Could not identify platform from the base URL: ${baseUrl}. Defaulting to WSO2 Identity Server as the platform.`
|
|
5192
|
-
);
|
|
5193
|
-
}
|
|
5194
|
-
return "IDENTITY_SERVER" /* IdentityServer */;
|
|
5195
|
-
}
|
|
5196
|
-
return "UNKNOWN" /* Unknown */;
|
|
5197
|
-
} catch (error2) {
|
|
5198
|
-
logger_default.debug(`[identifyPlatform] Error identifying platform from base URL: ${baseUrl}. Error: ${error2.message}`);
|
|
5199
|
-
return "UNKNOWN" /* Unknown */;
|
|
5200
|
-
}
|
|
5201
|
-
};
|
|
5202
|
-
var identifyPlatform_default = identifyPlatform;
|
|
5203
|
-
|
|
5204
5242
|
// src/utils/getRedirectBasedSignUpUrl.ts
|
|
5205
5243
|
var getRedirectBasedSignUpUrl = (config) => {
|
|
5206
5244
|
const { baseUrl } = config;
|