@thunderid/javascript 0.5.0 → 0.6.1

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.
@@ -1131,7 +1131,7 @@ var getUserInfo_default = getUserInfo;
1131
1131
  const USERSTORE_PREFIX_REGEX = /^[A-Z_][A-Z0-9_]*\//;
1132
1132
  /**
1133
1133
  * Removes userstore prefixes from a username if they exist.
1134
- * This is commonly used to clean usernames returned from SCIM2 endpoints
1134
+ * This is commonly used to clean usernames returned from profile endpoints
1135
1135
  * that include userstore prefixes like "DEFAULT/", "ASGARDEO_USER/", "PRIMARY/", etc.
1136
1136
  *
1137
1137
  * @param username - The username string to process
@@ -1161,7 +1161,7 @@ const removeUserstorePrefix = (username) => {
1161
1161
  };
1162
1162
  /**
1163
1163
  * Processes a user object to remove userstore prefixes from username fields.
1164
- * This is a helper function for processing user objects returned from SCIM2 endpoints.
1164
+ * This is a helper function for processing user objects returned from profile endpoints.
1165
1165
  * Handles various username field variations: username, userName, and user_name.
1166
1166
  *
1167
1167
  * @param user - The user object to process
@@ -1193,9 +1193,9 @@ const processUsername = (user) => {
1193
1193
  var processUsername_default = processUsername;
1194
1194
 
1195
1195
  //#endregion
1196
- //#region src/api/getScim2Me.ts
1196
+ //#region src/api/getUsersMe.ts
1197
1197
  /**
1198
- * Retrieves the user profile information from the specified SCIM2 /Me endpoint.
1198
+ * Retrieves the user profile information from the specified /users/me endpoint.
1199
1199
  *
1200
1200
  * @param config - Request configuration object.
1201
1201
  * @returns A promise that resolves with the user profile information.
@@ -1203,8 +1203,8 @@ var processUsername_default = processUsername;
1203
1203
  * ```typescript
1204
1204
  * // Using default fetch
1205
1205
  * try {
1206
- * const userProfile = await getScim2Me({
1207
- * url: "https://localhost:8090/scim2/Me",
1206
+ * const userProfile = await getUsersMe({
1207
+ * url: "https://localhost:8090/users/me",
1208
1208
  * });
1209
1209
  * console.log(userProfile);
1210
1210
  * } catch (error) {
@@ -1218,8 +1218,8 @@ var processUsername_default = processUsername;
1218
1218
  * ```typescript
1219
1219
  * // Using custom fetcher (e.g., axios-based httpClient)
1220
1220
  * try {
1221
- * const userProfile = await getScim2Me({
1222
- * url: "https://localhost:8090/scim2/Me",
1221
+ * const userProfile = await getUsersMe({
1222
+ * url: "https://localhost:8090/users/me",
1223
1223
  * fetcher: async (url, config) => {
1224
1224
  * const response = await httpClient({
1225
1225
  * url,
@@ -1245,95 +1245,14 @@ var processUsername_default = processUsername;
1245
1245
  * }
1246
1246
  * ```
1247
1247
  */
1248
- const getScim2Me = async ({ url, baseUrl, fetcher,...requestConfig }) => {
1248
+ const getUsersMe = async ({ url, baseUrl, fetcher,...requestConfig }) => {
1249
1249
  try {
1250
1250
  new URL(url ?? baseUrl);
1251
1251
  } catch (error$1) {
1252
- throw new ThunderIDAPIError(`Invalid URL provided. ${error$1?.toString()}`, "getScim2Me-ValidationError-001", "javascript", 400, "The provided `url` or `baseUrl` path does not adhere to the URL schema.");
1252
+ throw new ThunderIDAPIError(`Invalid URL provided. ${error$1?.toString()}`, "getUsersMe-ValidationError-001", "javascript", 400, "The provided `url` or `baseUrl` path does not adhere to the URL schema.");
1253
1253
  }
1254
1254
  const fetchFn = fetcher || fetch;
1255
- const resolvedUrl = url ?? `${baseUrl}/scim2/Me`;
1256
- const requestInit = {
1257
- ...requestConfig,
1258
- headers: {
1259
- Accept: "application/json",
1260
- "Content-Type": "application/scim+json",
1261
- ...requestConfig.headers
1262
- },
1263
- method: "GET"
1264
- };
1265
- try {
1266
- const response = await fetchFn(resolvedUrl, requestInit);
1267
- if (!response?.ok) throw new ThunderIDAPIError(await response.text(), "getScim2Me-ResponseError-001", "javascript", response.status, response.statusText, "Failed to fetch user profile");
1268
- return processUsername_default(await response.json());
1269
- } catch (error$1) {
1270
- if (error$1 instanceof ThunderIDAPIError) throw error$1;
1271
- throw new ThunderIDAPIError(`Network or parsing error: ${error$1 instanceof Error ? error$1.message : "Unknown error"}`, "getScim2Me-NetworkError-001", "javascript", 0, "Network Error");
1272
- }
1273
- };
1274
- var getScim2Me_default = getScim2Me;
1275
-
1276
- //#endregion
1277
- //#region src/api/getSchemas.ts
1278
- /**
1279
- * Retrieves the SCIM2 schemas from the specified endpoint.
1280
- *
1281
- * @param config - Request configuration object.
1282
- * @returns A promise that resolves with the SCIM2 schemas information.
1283
- * @example
1284
- * ```typescript
1285
- * // Using default fetch
1286
- * try {
1287
- * const schemas = await getSchemas({
1288
- * url: "https://localhost:8090/scim2/Schemas",
1289
- * });
1290
- * console.log(schemas);
1291
- * } catch (error) {
1292
- * if (error instanceof ThunderIDAPIError) {
1293
- * console.error('Failed to get schemas:', error.message);
1294
- * }
1295
- * }
1296
- * ```
1297
- *
1298
- * @example
1299
- * ```typescript
1300
- * // Using custom fetcher (e.g., axios-based httpClient)
1301
- * try {
1302
- * const schemas = await getSchemas({
1303
- * url: "https://localhost:8090/scim2/Schemas",
1304
- * fetcher: async (url, config) => {
1305
- * const response = await httpClient({
1306
- * url,
1307
- * method: config.method,
1308
- * headers: config.headers,
1309
- * ...config
1310
- * });
1311
- * // Convert axios-like response to fetch-like Response
1312
- * return {
1313
- * ok: response.status >= 200 && response.status < 300,
1314
- * status: response.status,
1315
- * statusText: response.statusText,
1316
- * json: () => Promise.resolve(response.data),
1317
- * text: () => Promise.resolve(typeof response.data === 'string' ? response.data : JSON.stringify(response.data))
1318
- * } as Response;
1319
- * }
1320
- * });
1321
- * console.log(schemas);
1322
- * } catch (error) {
1323
- * if (error instanceof ThunderIDAPIError) {
1324
- * console.error('Failed to get schemas:', error.message);
1325
- * }
1326
- * }
1327
- * ```
1328
- */
1329
- const getSchemas = async ({ url, baseUrl, fetcher,...requestConfig }) => {
1330
- try {
1331
- new URL(url ?? baseUrl);
1332
- } catch (error$1) {
1333
- throw new ThunderIDAPIError(`Invalid URL provided. ${error$1?.toString()}`, "getSchemas-ValidationError-001", "javascript", 400, "The provided `url` or `baseUrl` path does not adhere to the URL schema.");
1334
- }
1335
- const fetchFn = fetcher || fetch;
1336
- const resolvedUrl = url ?? `${baseUrl}/scim2/Schemas`;
1255
+ const resolvedUrl = url ?? `${baseUrl}/users/me`;
1337
1256
  const requestInit = {
1338
1257
  ...requestConfig,
1339
1258
  headers: {
@@ -1345,19 +1264,24 @@ const getSchemas = async ({ url, baseUrl, fetcher,...requestConfig }) => {
1345
1264
  };
1346
1265
  try {
1347
1266
  const response = await fetchFn(resolvedUrl, requestInit);
1348
- if (!response?.ok) throw new ThunderIDAPIError(await response.text(), "getSchemas-ResponseError-001", "javascript", response.status, response.statusText, "Failed to fetch SCIM2 schemas");
1349
- return await response.json();
1267
+ if (!response?.ok) throw new ThunderIDAPIError(await response.text(), "getUsersMe-ResponseError-001", "javascript", response.status, response.statusText, "Failed to fetch user profile");
1268
+ const user = await response.json();
1269
+ const attributes = user["attributes"] ?? {};
1270
+ return processUsername_default({
1271
+ ...user,
1272
+ ...attributes
1273
+ });
1350
1274
  } catch (error$1) {
1351
1275
  if (error$1 instanceof ThunderIDAPIError) throw error$1;
1352
- throw new ThunderIDAPIError(`Network or parsing error: ${error$1 instanceof Error ? error$1.message : "Unknown error"}`, "getSchemas-NetworkError-001", "javascript", 0, "Network Error");
1276
+ throw new ThunderIDAPIError(`Network or parsing error: ${error$1 instanceof Error ? error$1.message : "Unknown error"}`, "getUsersMe-NetworkError-001", "javascript", 0, "Network Error");
1353
1277
  }
1354
1278
  };
1355
- var getSchemas_default = getSchemas;
1279
+ var getUsersMe_default = getUsersMe;
1356
1280
 
1357
1281
  //#endregion
1358
1282
  //#region src/api/updateMeProfile.ts
1359
1283
  /**
1360
- * Updates the user profile information at the specified SCIM2 Me endpoint.
1284
+ * Updates the user profile information at the specified /users/me endpoint.
1361
1285
  *
1362
1286
  * @param config - Configuration object with URL, payload and optional request config.
1363
1287
  * @returns A promise that resolves with the updated user profile information.
@@ -1365,8 +1289,8 @@ var getSchemas_default = getSchemas;
1365
1289
  * ```typescript
1366
1290
  * // Using default fetch
1367
1291
  * await updateMeProfile({
1368
- * url: "https://localhost:8090/scim2/Me",
1369
- * payload: { "urn:scim:wso2:schema": { mobileNumbers: ["0777933830"] } }
1292
+ * url: "https://localhost:8090/users/me",
1293
+ * payload: { mobileNumbers: ["0777933830"] }
1370
1294
  * });
1371
1295
  * ```
1372
1296
  *
@@ -1374,8 +1298,8 @@ var getSchemas_default = getSchemas;
1374
1298
  * ```typescript
1375
1299
  * // Using custom fetcher (e.g., axios-based httpClient)
1376
1300
  * await updateMeProfile({
1377
- * url: "https://localhost:8090/scim2/Me",
1378
- * payload: { "urn:scim:wso2:schema": { mobileNumbers: ["0777933830"] } },
1301
+ * url: "https://localhost:8090/users/me",
1302
+ * payload: { mobileNumbers: ["0777933830"] },
1379
1303
  * fetcher: async (url, config) => {
1380
1304
  * const response = await httpClient({
1381
1305
  * url,
@@ -1402,29 +1326,28 @@ const updateMeProfile = async ({ url, baseUrl, payload, fetcher,...requestConfig
1402
1326
  } catch (error$1) {
1403
1327
  throw new ThunderIDAPIError(`Invalid URL provided. ${error$1?.toString()}`, "updateMeProfile-ValidationError-001", "javascript", 400, "The provided `url` or `baseUrl` path does not adhere to the URL schema.");
1404
1328
  }
1405
- const data = {
1406
- Operations: [{
1407
- op: "replace",
1408
- value: payload
1409
- }],
1410
- schemas: ["urn:ietf:params:scim:api:messages:2.0:PatchOp"]
1411
- };
1329
+ const data = { attributes: payload };
1412
1330
  const fetchFn = fetcher || fetch;
1413
- const resolvedUrl = url ?? `${baseUrl}/scim2/Me`;
1331
+ const resolvedUrl = url ?? `${baseUrl}/users/me`;
1414
1332
  const requestInit = {
1415
- method: "PATCH",
1416
1333
  ...requestConfig,
1334
+ method: "PUT",
1417
1335
  body: JSON.stringify(data),
1418
1336
  headers: {
1419
1337
  ...requestConfig.headers,
1420
1338
  Accept: "application/json",
1421
- "Content-Type": "application/scim+json"
1339
+ "Content-Type": "application/json"
1422
1340
  }
1423
1341
  };
1424
1342
  try {
1425
1343
  const response = await fetchFn(resolvedUrl, requestInit);
1426
1344
  if (!response?.ok) throw new ThunderIDAPIError(await response.text(), "updateMeProfile-ResponseError-001", "javascript", response.status, response.statusText, "Failed to update user profile");
1427
- return processUsername_default(await response.json());
1345
+ const user = await response.json();
1346
+ const attributes = user["attributes"] ?? {};
1347
+ return processUsername_default({
1348
+ ...user,
1349
+ ...attributes
1350
+ });
1428
1351
  } catch (error$1) {
1429
1352
  if (error$1 instanceof ThunderIDAPIError) throw error$1;
1430
1353
  throw new ThunderIDAPIError(error$1?.response?.data?.detail || "An error occurred while updating the user profile. Please try again.", "updateMeProfile-NetworkError-001", "javascript", error$1?.data?.status, "Network Error");
@@ -1727,25 +1650,6 @@ let FlowMode = /* @__PURE__ */ function(FlowMode$1) {
1727
1650
  return FlowMode$1;
1728
1651
  }({});
1729
1652
 
1730
- //#endregion
1731
- //#region src/models/scim2-schema.ts
1732
- /**
1733
- * Well-known SCIM2 schema IDs
1734
- */
1735
- let WellKnownSchemaIds = /* @__PURE__ */ function(WellKnownSchemaIds$1) {
1736
- /** Core Schema */
1737
- WellKnownSchemaIds$1["Core"] = "urn:ietf:params:scim:schemas:core:2.0";
1738
- /** Custom User Schema */
1739
- WellKnownSchemaIds$1["CustomUser"] = "urn:scim:schemas:extension:custom:User";
1740
- /** Enterprise User Schema */
1741
- WellKnownSchemaIds$1["EnterpriseUser"] = "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User";
1742
- /** System User Schema */
1743
- WellKnownSchemaIds$1["SystemUser"] = "urn:scim:wso2:schema";
1744
- /** User Schema */
1745
- WellKnownSchemaIds$1["User"] = "urn:ietf:params:scim:schemas:core:2.0:User";
1746
- return WellKnownSchemaIds$1;
1747
- }({});
1748
-
1749
1653
  //#endregion
1750
1654
  //#region src/models/field.ts
1751
1655
  /**
@@ -3098,7 +3002,7 @@ const getAuthorizeRequestUrlParams = (options, pkceOptions, customParams) => {
3098
3002
  const authorizeRequestParams = /* @__PURE__ */ new Map();
3099
3003
  authorizeRequestParams.set("response_type", "code");
3100
3004
  authorizeRequestParams.set("client_id", clientId);
3101
- authorizeRequestParams.set("scope", scopes ?? "");
3005
+ if (scopes !== void 0) authorizeRequestParams.set("scope", scopes);
3102
3006
  authorizeRequestParams.set("redirect_uri", redirectUri);
3103
3007
  if (responseMode) authorizeRequestParams.set("response_mode", responseMode);
3104
3008
  const pkceKey = pkceOptions?.key;
@@ -4346,209 +4250,6 @@ const isRecognizedBaseUrlPattern = (baseUrl) => {
4346
4250
  };
4347
4251
  var isRecognizedBaseUrlPattern_default = isRecognizedBaseUrlPattern;
4348
4252
 
4349
- //#endregion
4350
- //#region src/utils/flattenUserSchema.ts
4351
- /**
4352
- * Flattens nested schema attributes into a flat structure for easier processing
4353
- *
4354
- * This function processes SCIM2 schemas and creates a flattened representation by:
4355
- * - Processing sub-attributes and creating dot-notation names (e.g., 'name.givenName')
4356
- * - Adding schema ID reference to each flattened attribute
4357
- * - Preserving all original attribute properties while adding schema context
4358
- * - Only including leaf-level attributes (sub-attributes) and top-level simple attributes
4359
- *
4360
- * @param schemas - Array of SCIM2 schemas containing nested attribute structures
4361
- * @returns Array of flattened schema attributes with dot-notation names and schema references
4362
- *
4363
- * @example
4364
- * ```typescript
4365
- * const schemas = [
4366
- * {
4367
- * id: 'urn:ietf:params:scim:schemas:core:2.0:User',
4368
- * attributes: [
4369
- * {
4370
- * name: 'userName',
4371
- * type: 'string',
4372
- * multiValued: false
4373
- * },
4374
- * {
4375
- * name: 'name',
4376
- * type: 'complex',
4377
- * multiValued: false,
4378
- * subAttributes: [
4379
- * { name: 'givenName', type: 'string', multiValued: false },
4380
- * { name: 'familyName', type: 'string', multiValued: false }
4381
- * ]
4382
- * }
4383
- * ]
4384
- * }
4385
- * ];
4386
- *
4387
- * const flattened = flattenUserSchema(schemas);
4388
- * // Result: [
4389
- * // { name: 'userName', type: 'string', multiValued: false, schemaId: 'urn:ietf:params:scim:schemas:core:2.0:User' },
4390
- * // { name: 'name.givenName', type: 'string', multiValued: false, schemaId: 'urn:ietf:params:scim:schemas:core:2.0:User' },
4391
- * // { name: 'name.familyName', type: 'string', multiValued: false, schemaId: 'urn:ietf:params:scim:schemas:core:2.0:User' }
4392
- * // ]
4393
- * ```
4394
- */
4395
- const flattenUserSchema = (schemas) => {
4396
- const flattenedAttributes = [];
4397
- schemas.forEach((schema) => {
4398
- if (schema.attributes && Array.isArray(schema.attributes)) schema.attributes.forEach((attribute) => {
4399
- if (attribute.subAttributes && Array.isArray(attribute.subAttributes)) attribute.subAttributes.forEach((subAttribute) => {
4400
- flattenedAttributes.push({
4401
- ...subAttribute,
4402
- name: `${attribute.name}.${subAttribute.name}`,
4403
- schemaId: schema.id
4404
- });
4405
- });
4406
- else flattenedAttributes.push({
4407
- ...attribute,
4408
- schemaId: schema.id
4409
- });
4410
- });
4411
- });
4412
- return flattenedAttributes;
4413
- };
4414
- var flattenUserSchema_default = flattenUserSchema;
4415
-
4416
- //#endregion
4417
- //#region src/utils/get.ts
4418
- /**
4419
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
4420
- *
4421
- * WSO2 LLC. licenses this file to you under the Apache License,
4422
- * Version 2.0 (the "License"); you may not use this file except
4423
- * in compliance with the License.
4424
- * You may obtain a copy of the License at
4425
- *
4426
- * http://www.apache.org/licenses/LICENSE-2.0
4427
- *
4428
- * Unless required by applicable law or agreed to in writing,
4429
- * software distributed under the License is distributed on an
4430
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4431
- * KIND, either express or implied. See the License for the
4432
- * specific language governing permissions and limitations
4433
- * under the License.
4434
- */
4435
- /**
4436
- * Gets the value at path of object. If the resolved value is undefined,
4437
- * the defaultValue is returned in its place.
4438
- * Similar to Lodash's get() function
4439
- *
4440
- * @param object - The object to query
4441
- * @param path - The path of the property to get
4442
- * @param defaultValue - The value returned for undefined resolved values
4443
- * @returns The resolved value
4444
- */
4445
- const get = (object, path, defaultValue) => {
4446
- if (!object || !path) return defaultValue;
4447
- const result = (Array.isArray(path) ? path : path.split(".")).reduce((current, key) => current?.[key], object);
4448
- return result !== void 0 ? result : defaultValue;
4449
- };
4450
- var get_default = get;
4451
-
4452
- //#endregion
4453
- //#region src/utils/set.ts
4454
- /**
4455
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
4456
- *
4457
- * WSO2 LLC. licenses this file to you under the Apache License,
4458
- * Version 2.0 (the "License"); you may not use this file except
4459
- * in compliance with the License.
4460
- * You may obtain a copy of the License at
4461
- *
4462
- * http://www.apache.org/licenses/LICENSE-2.0
4463
- *
4464
- * Unless required by applicable law or agreed to in writing,
4465
- * software distributed under the License is distributed on an
4466
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4467
- * KIND, either express or implied. See the License for the
4468
- * specific language governing permissions and limitations
4469
- * under the License.
4470
- */
4471
- /**
4472
- * Sets the value at path of object. If a portion of path doesn't exist,
4473
- * it's created. Arrays are created for missing index properties while
4474
- * objects are created for all other missing properties.
4475
- * Similar to Lodash's set() function
4476
- *
4477
- * @param object - The object to modify
4478
- * @param path - The path of the property to set
4479
- * @param value - The value to set
4480
- * @returns The object
4481
- */
4482
- const set = (object, path, value) => {
4483
- if (!object || !path) return object;
4484
- const pathArray = Array.isArray(path) ? path : path.split(".");
4485
- const lastIndex = pathArray.length - 1;
4486
- pathArray.reduce((current, key, index) => {
4487
- if (index === lastIndex) current[key] = value;
4488
- else if (!(key in current) || typeof current[key] !== "object" || current[key] === null) {
4489
- const nextKey = pathArray[index + 1];
4490
- current[key] = /^\d+$/.test(nextKey) ? [] : {};
4491
- }
4492
- return current[key];
4493
- }, object);
4494
- return object;
4495
- };
4496
- var set_default = set;
4497
-
4498
- //#endregion
4499
- //#region src/utils/generateUserProfile.ts
4500
- /**
4501
- * Creates a profile structure from ME response based on processed schemas
4502
- *
4503
- * This function processes each schema attribute and populates the profile dynamically by:
4504
- * - Extracting values from the ME response using the schema attribute names
4505
- * - Handling multi-valued attributes by converting single values to arrays when needed
4506
- * - Setting appropriate default values based on schema type and multiValued properties
4507
- * - Using dynamic property setting to build the final profile object
4508
- *
4509
- * @param meResponse - The ME API response containing user data
4510
- * @param processedSchemas - The processed and flattened schemas with name, type, and multiValued properties
4511
- * @returns Flat profile object with dynamically populated user attributes
4512
- *
4513
- * @example
4514
- * ```typescript
4515
- * const meResponse = {
4516
- * userName: 'john.doe',
4517
- * emails: ['john@example.com', 'john.doe@work.com'],
4518
- * name: { givenName: 'John', familyName: 'Doe' }
4519
- * };
4520
- *
4521
- * const schemas = [
4522
- * { name: 'userName', type: 'STRING', multiValued: false },
4523
- * { name: 'emails', type: 'STRING', multiValued: true },
4524
- * { name: 'name.givenName', type: 'STRING', multiValued: false }
4525
- * ];
4526
- *
4527
- * const profile = generateUserProfile(meResponse, schemas);
4528
- * // Result: {
4529
- * // userName: 'john.doe',
4530
- * // emails: ['john@example.com', 'john.doe@work.com'],
4531
- * // 'name.givenName': 'John'
4532
- * // }
4533
- * ```
4534
- */
4535
- const generateUserProfile = (meResponse, processedSchemas) => {
4536
- const profile = {};
4537
- processedSchemas.forEach((schema) => {
4538
- const { name, type, multiValued } = schema;
4539
- if (!name) return;
4540
- let value = get_default(meResponse, name);
4541
- if (value !== void 0) {
4542
- if (multiValued && !Array.isArray(value)) value = [value];
4543
- } else if (multiValued) value = void 0;
4544
- else if (type === "STRING") value = "";
4545
- else value = void 0;
4546
- set_default(profile, name, value);
4547
- });
4548
- return profile;
4549
- };
4550
- var generateUserProfile_default = generateUserProfile;
4551
-
4552
4253
  //#endregion
4553
4254
  //#region src/utils/getLatestStateParam.ts
4554
4255
  /**
@@ -4594,95 +4295,14 @@ var getLatestStateParam_default = getLatestStateParam;
4594
4295
  //#endregion
4595
4296
  //#region src/utils/generateFlattenedUserProfile.ts
4596
4297
  /**
4597
- * Generates a flattened user profile from a response object and schema definitions.
4598
- *
4599
- * This function processes user data according to schema specifications, creating
4600
- * a flat object with dot notation keys instead of nested objects. Multi-valued
4601
- * properties and type-specific defaults are handled appropriately.
4602
- *
4603
- * Additionally, any fields present in the response but not defined in the schema
4604
- * will be included to ensure no user data is lost during flattening.
4298
+ * Generates a flattened user profile by returning the user profile as-is.
4605
4299
  *
4606
4300
  * @param meResponse - The response object containing user data
4607
- * @param processedSchemas - Array of schema objects defining field properties
4608
- * @param processedSchemas[].name - The field name/path for the property
4609
- * @param processedSchemas[].type - The data type of the field (e.g., 'STRING')
4610
- * @param processedSchemas[].multiValued - Whether the field can contain multiple values
4611
- *
4612
- * @returns A flattened user profile object with dot notation keys
4613
- *
4614
- * @example
4615
- * ```typescript
4616
- * const schemas = [
4617
- * { name: 'name.givenName', type: 'STRING', multiValued: false },
4618
- * { name: 'emails', type: 'STRING', multiValued: true }
4619
- * ];
4620
- * const response = {
4621
- * name: { givenName: 'John' },
4622
- * emails: 'john@example.com',
4623
- * country: 'US' // This will be included even if not in schema
4624
- * };
4625
- * const profile = generateFlattenedUserProfile(response, schemas);
4626
- * // Result: { "name.givenName": 'John', emails: ['john@example.com'], country: 'US' }
4627
- * ```
4301
+ * @param _processedSchemas - Deprecated/unused schemas parameter
4302
+ * @returns The user profile object
4628
4303
  */
4629
- const generateFlattenedUserProfile = (meResponse, processedSchemas) => {
4630
- const profile = {};
4631
- const allSchemaNames = processedSchemas.map((schema) => schema.name).filter(Boolean);
4632
- processedSchemas.forEach((schema) => {
4633
- const { name, type, multiValued } = schema;
4634
- if (!name) return;
4635
- if (allSchemaNames.some((schemaName) => schemaName !== name && schemaName.startsWith(`${name}.`))) return;
4636
- let value = get_default(meResponse, name);
4637
- if (value === void 0) {
4638
- const dotIndex = name.indexOf(".");
4639
- if (dotIndex > 0) {
4640
- const head = name.slice(0, dotIndex);
4641
- const tail = name.slice(dotIndex + 1);
4642
- const arr = meResponse[head];
4643
- if (Array.isArray(arr)) {
4644
- const match = arr.find((item) => item?.type === tail);
4645
- if (match?.value !== void 0) value = match.value;
4646
- }
4647
- }
4648
- }
4649
- if (value === void 0) [
4650
- "urn:ietf:params:scim:schemas:core:2.0:User",
4651
- "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User",
4652
- "urn:scim:wso2:schema",
4653
- "urn:scim:schemas:extension:custom:User"
4654
- ].some((namespace) => {
4655
- if (meResponse[namespace]) {
4656
- if (meResponse[namespace][name] !== void 0) {
4657
- value = meResponse[namespace][name];
4658
- return true;
4659
- }
4660
- const nestedValue = get_default(meResponse[namespace], name);
4661
- if (nestedValue !== void 0) {
4662
- value = nestedValue;
4663
- return true;
4664
- }
4665
- }
4666
- return false;
4667
- });
4668
- if (value !== void 0) {
4669
- if (multiValued && !Array.isArray(value)) value = [value];
4670
- } else if (multiValued) value = void 0;
4671
- else if (type === "STRING") value = "";
4672
- else value = void 0;
4673
- profile[name] = value;
4674
- });
4675
- const flattenObject = (obj, prefix = "") => {
4676
- if (obj && typeof obj === "object" && !Array.isArray(obj)) Object.keys(obj).forEach((key) => {
4677
- const fullKey = prefix ? `${prefix}.${key}` : key;
4678
- const value = obj[key];
4679
- if (Object.prototype.hasOwnProperty.call(profile, fullKey)) return;
4680
- if (allSchemaNames.some((schemaName) => schemaName.startsWith(`${fullKey}.`))) flattenObject(value, fullKey);
4681
- else profile[fullKey] = value;
4682
- });
4683
- };
4684
- flattenObject(meResponse);
4685
- return profile;
4304
+ const generateFlattenedUserProfile = (meResponse, _processedSchemas) => {
4305
+ return { ...meResponse };
4686
4306
  };
4687
4307
  var generateFlattenedUserProfile_default = generateFlattenedUserProfile;
4688
4308
 
@@ -4831,6 +4451,129 @@ const extractEmojiFromUri = (uri) => {
4831
4451
  };
4832
4452
  var extractEmojiFromUri_default = extractEmojiFromUri;
4833
4453
 
4454
+ //#endregion
4455
+ //#region src/utils/set.ts
4456
+ /**
4457
+ * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
4458
+ *
4459
+ * WSO2 LLC. licenses this file to you under the Apache License,
4460
+ * Version 2.0 (the "License"); you may not use this file except
4461
+ * in compliance with the License.
4462
+ * You may obtain a copy of the License at
4463
+ *
4464
+ * http://www.apache.org/licenses/LICENSE-2.0
4465
+ *
4466
+ * Unless required by applicable law or agreed to in writing,
4467
+ * software distributed under the License is distributed on an
4468
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4469
+ * KIND, either express or implied. See the License for the
4470
+ * specific language governing permissions and limitations
4471
+ * under the License.
4472
+ */
4473
+ /**
4474
+ * Sets the value at path of object. If a portion of path doesn't exist,
4475
+ * it's created. Arrays are created for missing index properties while
4476
+ * objects are created for all other missing properties.
4477
+ * Similar to Lodash's set() function
4478
+ *
4479
+ * @param object - The object to modify
4480
+ * @param path - The path of the property to set
4481
+ * @param value - The value to set
4482
+ * @returns The object
4483
+ */
4484
+ const set = (object, path, value) => {
4485
+ if (!object || !path) return object;
4486
+ const pathArray = Array.isArray(path) ? path : path.split(".");
4487
+ const lastIndex = pathArray.length - 1;
4488
+ pathArray.reduce((current, key, index) => {
4489
+ if (index === lastIndex) current[key] = value;
4490
+ else if (!(key in current) || typeof current[key] !== "object" || current[key] === null) {
4491
+ const nextKey = pathArray[index + 1];
4492
+ current[key] = /^\d+$/.test(nextKey) ? [] : {};
4493
+ }
4494
+ return current[key];
4495
+ }, object);
4496
+ return object;
4497
+ };
4498
+ var set_default = set;
4499
+
4500
+ //#endregion
4501
+ //#region src/utils/get.ts
4502
+ /**
4503
+ * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
4504
+ *
4505
+ * WSO2 LLC. licenses this file to you under the Apache License,
4506
+ * Version 2.0 (the "License"); you may not use this file except
4507
+ * in compliance with the License.
4508
+ * You may obtain a copy of the License at
4509
+ *
4510
+ * http://www.apache.org/licenses/LICENSE-2.0
4511
+ *
4512
+ * Unless required by applicable law or agreed to in writing,
4513
+ * software distributed under the License is distributed on an
4514
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4515
+ * KIND, either express or implied. See the License for the
4516
+ * specific language governing permissions and limitations
4517
+ * under the License.
4518
+ */
4519
+ /**
4520
+ * Gets the value at path of object. If the resolved value is undefined,
4521
+ * the defaultValue is returned in its place.
4522
+ * Similar to Lodash's get() function
4523
+ *
4524
+ * @param object - The object to query
4525
+ * @param path - The path of the property to get
4526
+ * @param defaultValue - The value returned for undefined resolved values
4527
+ * @returns The resolved value
4528
+ */
4529
+ const get = (object, path, defaultValue) => {
4530
+ if (!object || !path) return defaultValue;
4531
+ const result = (Array.isArray(path) ? path : path.split(".")).reduce((current, key) => current?.[key], object);
4532
+ return result !== void 0 ? result : defaultValue;
4533
+ };
4534
+ var get_default = get;
4535
+
4536
+ //#endregion
4537
+ //#region src/utils/startCase.ts
4538
+ /**
4539
+ * Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com). All Rights Reserved.
4540
+ *
4541
+ * WSO2 LLC. licenses this file to you under the Apache License,
4542
+ * Version 2.0 (the "License"); you may not use this file except
4543
+ * in compliance with the License.
4544
+ * You may obtain a copy of the License at
4545
+ *
4546
+ * http://www.apache.org/licenses/LICENSE-2.0
4547
+ *
4548
+ * Unless required by applicable law or agreed to in writing,
4549
+ * software distributed under the License is distributed on an
4550
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4551
+ * KIND, either express or implied. See the License for the
4552
+ * specific language governing permissions and limitations
4553
+ * under the License.
4554
+ */
4555
+ /**
4556
+ * Converts the first character of `string` to upper case.
4557
+ *
4558
+ * @param string - The string to convert.
4559
+ * @returns The converted string.
4560
+ */
4561
+ const upperFirst = (str) => {
4562
+ if (!str) return "";
4563
+ return str.charAt(0).toUpperCase() + str.slice(1);
4564
+ };
4565
+ /**
4566
+ * Converts `string` to start case.
4567
+ *
4568
+ * @param string - The string to convert.
4569
+ * @returns The start cased string.
4570
+ */
4571
+ const startCase = (str) => {
4572
+ if (!str) return "";
4573
+ return str.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/[^a-zA-Z0-9]+/g, " ").trim().split(/\s+/).map((word) => upperFirst(word)).join(" ");
4574
+ };
4575
+ var startCase_default = startCase;
4576
+
4834
4577
  //#endregion
4835
4578
  //#region src/utils/removeTrailingSlash.ts
4836
4579
  /**
@@ -6394,7 +6137,6 @@ exports.ThunderIDRuntimeError = ThunderIDRuntimeError;
6394
6137
  exports.TokenConstants = TokenConstants_default;
6395
6138
  exports.TranslationBundleConstants = TranslationBundleConstants_default;
6396
6139
  exports.VendorConstants = VendorConstants_default;
6397
- exports.WellKnownSchemaIds = WellKnownSchemaIds;
6398
6140
  exports.arrayBufferToBase64url = arrayBufferToBase64url_default;
6399
6141
  exports.base64urlToArrayBuffer = base64urlToArrayBuffer_default;
6400
6142
  exports.bem = bem_default;
@@ -6417,19 +6159,16 @@ exports.executeEmbeddedUserOnboardingFlow = executeEmbeddedUserOnboardingFlow_de
6417
6159
  exports.extractEmojiFromUri = extractEmojiFromUri_default;
6418
6160
  exports.extractPkceStorageKeyFromState = extractPkceStorageKeyFromState_default;
6419
6161
  exports.extractUserClaimsFromIdToken = extractUserClaimsFromIdToken_default;
6420
- exports.flattenUserSchema = flattenUserSchema_default;
6421
6162
  exports.formatDate = formatDate_default;
6422
6163
  exports.generateFlattenedUserProfile = generateFlattenedUserProfile_default;
6423
- exports.generateUserProfile = generateUserProfile_default;
6424
6164
  exports.get = get_default;
6425
6165
  exports.getDefaultI18nBundles = getDefaultI18nBundles_default;
6426
6166
  exports.getFlowMeta = getFlowMeta_default;
6427
6167
  exports.getLatestStateParam = getLatestStateParam_default;
6428
6168
  exports.getOrganizationUnitChildren = getOrganizationUnitChildren_default;
6429
6169
  exports.getRedirectBasedSignUpUrl = getRedirectBasedSignUpUrl_default;
6430
- exports.getSchemas = getSchemas_default;
6431
- exports.getScim2Me = getScim2Me_default;
6432
6170
  exports.getUserInfo = getUserInfo_default;
6171
+ exports.getUsersMe = getUsersMe_default;
6433
6172
  exports.getVendorPrefix = getVendorPrefix_default;
6434
6173
  exports.info = info;
6435
6174
  exports.isEmojiUri = isEmojiUri_default;
@@ -6446,6 +6185,7 @@ exports.resolveLocaleDisplayName = resolveLocaleDisplayName;
6446
6185
  exports.resolveLocaleEmoji = resolveLocaleEmoji_default;
6447
6186
  exports.resolveMeta = resolveMeta;
6448
6187
  exports.set = set_default;
6188
+ exports.startCase = startCase_default;
6449
6189
  exports.updateMeProfile = updateMeProfile_default;
6450
6190
  exports.warn = warn;
6451
6191
  exports.withVendorCSSClassPrefix = withVendorCSSClassPrefix_default;