@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.
package/dist/index.js CHANGED
@@ -1111,7 +1111,7 @@ var getUserInfo_default = getUserInfo;
1111
1111
  const USERSTORE_PREFIX_REGEX = /^[A-Z_][A-Z0-9_]*\//;
1112
1112
  /**
1113
1113
  * Removes userstore prefixes from a username if they exist.
1114
- * This is commonly used to clean usernames returned from SCIM2 endpoints
1114
+ * This is commonly used to clean usernames returned from profile endpoints
1115
1115
  * that include userstore prefixes like "DEFAULT/", "ASGARDEO_USER/", "PRIMARY/", etc.
1116
1116
  *
1117
1117
  * @param username - The username string to process
@@ -1141,7 +1141,7 @@ const removeUserstorePrefix = (username) => {
1141
1141
  };
1142
1142
  /**
1143
1143
  * Processes a user object to remove userstore prefixes from username fields.
1144
- * This is a helper function for processing user objects returned from SCIM2 endpoints.
1144
+ * This is a helper function for processing user objects returned from profile endpoints.
1145
1145
  * Handles various username field variations: username, userName, and user_name.
1146
1146
  *
1147
1147
  * @param user - The user object to process
@@ -1173,9 +1173,9 @@ const processUsername = (user) => {
1173
1173
  var processUsername_default = processUsername;
1174
1174
 
1175
1175
  //#endregion
1176
- //#region src/api/getScim2Me.ts
1176
+ //#region src/api/getUsersMe.ts
1177
1177
  /**
1178
- * Retrieves the user profile information from the specified SCIM2 /Me endpoint.
1178
+ * Retrieves the user profile information from the specified /users/me endpoint.
1179
1179
  *
1180
1180
  * @param config - Request configuration object.
1181
1181
  * @returns A promise that resolves with the user profile information.
@@ -1183,8 +1183,8 @@ var processUsername_default = processUsername;
1183
1183
  * ```typescript
1184
1184
  * // Using default fetch
1185
1185
  * try {
1186
- * const userProfile = await getScim2Me({
1187
- * url: "https://localhost:8090/scim2/Me",
1186
+ * const userProfile = await getUsersMe({
1187
+ * url: "https://localhost:8090/users/me",
1188
1188
  * });
1189
1189
  * console.log(userProfile);
1190
1190
  * } catch (error) {
@@ -1198,8 +1198,8 @@ var processUsername_default = processUsername;
1198
1198
  * ```typescript
1199
1199
  * // Using custom fetcher (e.g., axios-based httpClient)
1200
1200
  * try {
1201
- * const userProfile = await getScim2Me({
1202
- * url: "https://localhost:8090/scim2/Me",
1201
+ * const userProfile = await getUsersMe({
1202
+ * url: "https://localhost:8090/users/me",
1203
1203
  * fetcher: async (url, config) => {
1204
1204
  * const response = await httpClient({
1205
1205
  * url,
@@ -1225,95 +1225,14 @@ var processUsername_default = processUsername;
1225
1225
  * }
1226
1226
  * ```
1227
1227
  */
1228
- const getScim2Me = async ({ url, baseUrl, fetcher,...requestConfig }) => {
1228
+ const getUsersMe = async ({ url, baseUrl, fetcher,...requestConfig }) => {
1229
1229
  try {
1230
1230
  new URL(url ?? baseUrl);
1231
1231
  } catch (error$1) {
1232
- 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.");
1232
+ 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.");
1233
1233
  }
1234
1234
  const fetchFn = fetcher || fetch;
1235
- const resolvedUrl = url ?? `${baseUrl}/scim2/Me`;
1236
- const requestInit = {
1237
- ...requestConfig,
1238
- headers: {
1239
- Accept: "application/json",
1240
- "Content-Type": "application/scim+json",
1241
- ...requestConfig.headers
1242
- },
1243
- method: "GET"
1244
- };
1245
- try {
1246
- const response = await fetchFn(resolvedUrl, requestInit);
1247
- if (!response?.ok) throw new ThunderIDAPIError(await response.text(), "getScim2Me-ResponseError-001", "javascript", response.status, response.statusText, "Failed to fetch user profile");
1248
- return processUsername_default(await response.json());
1249
- } catch (error$1) {
1250
- if (error$1 instanceof ThunderIDAPIError) throw error$1;
1251
- throw new ThunderIDAPIError(`Network or parsing error: ${error$1 instanceof Error ? error$1.message : "Unknown error"}`, "getScim2Me-NetworkError-001", "javascript", 0, "Network Error");
1252
- }
1253
- };
1254
- var getScim2Me_default = getScim2Me;
1255
-
1256
- //#endregion
1257
- //#region src/api/getSchemas.ts
1258
- /**
1259
- * Retrieves the SCIM2 schemas from the specified endpoint.
1260
- *
1261
- * @param config - Request configuration object.
1262
- * @returns A promise that resolves with the SCIM2 schemas information.
1263
- * @example
1264
- * ```typescript
1265
- * // Using default fetch
1266
- * try {
1267
- * const schemas = await getSchemas({
1268
- * url: "https://localhost:8090/scim2/Schemas",
1269
- * });
1270
- * console.log(schemas);
1271
- * } catch (error) {
1272
- * if (error instanceof ThunderIDAPIError) {
1273
- * console.error('Failed to get schemas:', error.message);
1274
- * }
1275
- * }
1276
- * ```
1277
- *
1278
- * @example
1279
- * ```typescript
1280
- * // Using custom fetcher (e.g., axios-based httpClient)
1281
- * try {
1282
- * const schemas = await getSchemas({
1283
- * url: "https://localhost:8090/scim2/Schemas",
1284
- * fetcher: async (url, config) => {
1285
- * const response = await httpClient({
1286
- * url,
1287
- * method: config.method,
1288
- * headers: config.headers,
1289
- * ...config
1290
- * });
1291
- * // Convert axios-like response to fetch-like Response
1292
- * return {
1293
- * ok: response.status >= 200 && response.status < 300,
1294
- * status: response.status,
1295
- * statusText: response.statusText,
1296
- * json: () => Promise.resolve(response.data),
1297
- * text: () => Promise.resolve(typeof response.data === 'string' ? response.data : JSON.stringify(response.data))
1298
- * } as Response;
1299
- * }
1300
- * });
1301
- * console.log(schemas);
1302
- * } catch (error) {
1303
- * if (error instanceof ThunderIDAPIError) {
1304
- * console.error('Failed to get schemas:', error.message);
1305
- * }
1306
- * }
1307
- * ```
1308
- */
1309
- const getSchemas = async ({ url, baseUrl, fetcher,...requestConfig }) => {
1310
- try {
1311
- new URL(url ?? baseUrl);
1312
- } catch (error$1) {
1313
- 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.");
1314
- }
1315
- const fetchFn = fetcher || fetch;
1316
- const resolvedUrl = url ?? `${baseUrl}/scim2/Schemas`;
1235
+ const resolvedUrl = url ?? `${baseUrl}/users/me`;
1317
1236
  const requestInit = {
1318
1237
  ...requestConfig,
1319
1238
  headers: {
@@ -1325,19 +1244,24 @@ const getSchemas = async ({ url, baseUrl, fetcher,...requestConfig }) => {
1325
1244
  };
1326
1245
  try {
1327
1246
  const response = await fetchFn(resolvedUrl, requestInit);
1328
- if (!response?.ok) throw new ThunderIDAPIError(await response.text(), "getSchemas-ResponseError-001", "javascript", response.status, response.statusText, "Failed to fetch SCIM2 schemas");
1329
- return await response.json();
1247
+ if (!response?.ok) throw new ThunderIDAPIError(await response.text(), "getUsersMe-ResponseError-001", "javascript", response.status, response.statusText, "Failed to fetch user profile");
1248
+ const user = await response.json();
1249
+ const attributes = user["attributes"] ?? {};
1250
+ return processUsername_default({
1251
+ ...user,
1252
+ ...attributes
1253
+ });
1330
1254
  } catch (error$1) {
1331
1255
  if (error$1 instanceof ThunderIDAPIError) throw error$1;
1332
- throw new ThunderIDAPIError(`Network or parsing error: ${error$1 instanceof Error ? error$1.message : "Unknown error"}`, "getSchemas-NetworkError-001", "javascript", 0, "Network Error");
1256
+ throw new ThunderIDAPIError(`Network or parsing error: ${error$1 instanceof Error ? error$1.message : "Unknown error"}`, "getUsersMe-NetworkError-001", "javascript", 0, "Network Error");
1333
1257
  }
1334
1258
  };
1335
- var getSchemas_default = getSchemas;
1259
+ var getUsersMe_default = getUsersMe;
1336
1260
 
1337
1261
  //#endregion
1338
1262
  //#region src/api/updateMeProfile.ts
1339
1263
  /**
1340
- * Updates the user profile information at the specified SCIM2 Me endpoint.
1264
+ * Updates the user profile information at the specified /users/me endpoint.
1341
1265
  *
1342
1266
  * @param config - Configuration object with URL, payload and optional request config.
1343
1267
  * @returns A promise that resolves with the updated user profile information.
@@ -1345,8 +1269,8 @@ var getSchemas_default = getSchemas;
1345
1269
  * ```typescript
1346
1270
  * // Using default fetch
1347
1271
  * await updateMeProfile({
1348
- * url: "https://localhost:8090/scim2/Me",
1349
- * payload: { "urn:scim:wso2:schema": { mobileNumbers: ["0777933830"] } }
1272
+ * url: "https://localhost:8090/users/me",
1273
+ * payload: { mobileNumbers: ["0777933830"] }
1350
1274
  * });
1351
1275
  * ```
1352
1276
  *
@@ -1354,8 +1278,8 @@ var getSchemas_default = getSchemas;
1354
1278
  * ```typescript
1355
1279
  * // Using custom fetcher (e.g., axios-based httpClient)
1356
1280
  * await updateMeProfile({
1357
- * url: "https://localhost:8090/scim2/Me",
1358
- * payload: { "urn:scim:wso2:schema": { mobileNumbers: ["0777933830"] } },
1281
+ * url: "https://localhost:8090/users/me",
1282
+ * payload: { mobileNumbers: ["0777933830"] },
1359
1283
  * fetcher: async (url, config) => {
1360
1284
  * const response = await httpClient({
1361
1285
  * url,
@@ -1382,29 +1306,28 @@ const updateMeProfile = async ({ url, baseUrl, payload, fetcher,...requestConfig
1382
1306
  } catch (error$1) {
1383
1307
  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.");
1384
1308
  }
1385
- const data = {
1386
- Operations: [{
1387
- op: "replace",
1388
- value: payload
1389
- }],
1390
- schemas: ["urn:ietf:params:scim:api:messages:2.0:PatchOp"]
1391
- };
1309
+ const data = { attributes: payload };
1392
1310
  const fetchFn = fetcher || fetch;
1393
- const resolvedUrl = url ?? `${baseUrl}/scim2/Me`;
1311
+ const resolvedUrl = url ?? `${baseUrl}/users/me`;
1394
1312
  const requestInit = {
1395
- method: "PATCH",
1396
1313
  ...requestConfig,
1314
+ method: "PUT",
1397
1315
  body: JSON.stringify(data),
1398
1316
  headers: {
1399
1317
  ...requestConfig.headers,
1400
1318
  Accept: "application/json",
1401
- "Content-Type": "application/scim+json"
1319
+ "Content-Type": "application/json"
1402
1320
  }
1403
1321
  };
1404
1322
  try {
1405
1323
  const response = await fetchFn(resolvedUrl, requestInit);
1406
1324
  if (!response?.ok) throw new ThunderIDAPIError(await response.text(), "updateMeProfile-ResponseError-001", "javascript", response.status, response.statusText, "Failed to update user profile");
1407
- return processUsername_default(await response.json());
1325
+ const user = await response.json();
1326
+ const attributes = user["attributes"] ?? {};
1327
+ return processUsername_default({
1328
+ ...user,
1329
+ ...attributes
1330
+ });
1408
1331
  } catch (error$1) {
1409
1332
  if (error$1 instanceof ThunderIDAPIError) throw error$1;
1410
1333
  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");
@@ -1707,25 +1630,6 @@ let FlowMode = /* @__PURE__ */ function(FlowMode$1) {
1707
1630
  return FlowMode$1;
1708
1631
  }({});
1709
1632
 
1710
- //#endregion
1711
- //#region src/models/scim2-schema.ts
1712
- /**
1713
- * Well-known SCIM2 schema IDs
1714
- */
1715
- let WellKnownSchemaIds = /* @__PURE__ */ function(WellKnownSchemaIds$1) {
1716
- /** Core Schema */
1717
- WellKnownSchemaIds$1["Core"] = "urn:ietf:params:scim:schemas:core:2.0";
1718
- /** Custom User Schema */
1719
- WellKnownSchemaIds$1["CustomUser"] = "urn:scim:schemas:extension:custom:User";
1720
- /** Enterprise User Schema */
1721
- WellKnownSchemaIds$1["EnterpriseUser"] = "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User";
1722
- /** System User Schema */
1723
- WellKnownSchemaIds$1["SystemUser"] = "urn:scim:wso2:schema";
1724
- /** User Schema */
1725
- WellKnownSchemaIds$1["User"] = "urn:ietf:params:scim:schemas:core:2.0:User";
1726
- return WellKnownSchemaIds$1;
1727
- }({});
1728
-
1729
1633
  //#endregion
1730
1634
  //#region src/models/field.ts
1731
1635
  /**
@@ -3078,7 +2982,7 @@ const getAuthorizeRequestUrlParams = (options, pkceOptions, customParams) => {
3078
2982
  const authorizeRequestParams = /* @__PURE__ */ new Map();
3079
2983
  authorizeRequestParams.set("response_type", "code");
3080
2984
  authorizeRequestParams.set("client_id", clientId);
3081
- authorizeRequestParams.set("scope", scopes ?? "");
2985
+ if (scopes !== void 0) authorizeRequestParams.set("scope", scopes);
3082
2986
  authorizeRequestParams.set("redirect_uri", redirectUri);
3083
2987
  if (responseMode) authorizeRequestParams.set("response_mode", responseMode);
3084
2988
  const pkceKey = pkceOptions?.key;
@@ -4326,209 +4230,6 @@ const isRecognizedBaseUrlPattern = (baseUrl) => {
4326
4230
  };
4327
4231
  var isRecognizedBaseUrlPattern_default = isRecognizedBaseUrlPattern;
4328
4232
 
4329
- //#endregion
4330
- //#region src/utils/flattenUserSchema.ts
4331
- /**
4332
- * Flattens nested schema attributes into a flat structure for easier processing
4333
- *
4334
- * This function processes SCIM2 schemas and creates a flattened representation by:
4335
- * - Processing sub-attributes and creating dot-notation names (e.g., 'name.givenName')
4336
- * - Adding schema ID reference to each flattened attribute
4337
- * - Preserving all original attribute properties while adding schema context
4338
- * - Only including leaf-level attributes (sub-attributes) and top-level simple attributes
4339
- *
4340
- * @param schemas - Array of SCIM2 schemas containing nested attribute structures
4341
- * @returns Array of flattened schema attributes with dot-notation names and schema references
4342
- *
4343
- * @example
4344
- * ```typescript
4345
- * const schemas = [
4346
- * {
4347
- * id: 'urn:ietf:params:scim:schemas:core:2.0:User',
4348
- * attributes: [
4349
- * {
4350
- * name: 'userName',
4351
- * type: 'string',
4352
- * multiValued: false
4353
- * },
4354
- * {
4355
- * name: 'name',
4356
- * type: 'complex',
4357
- * multiValued: false,
4358
- * subAttributes: [
4359
- * { name: 'givenName', type: 'string', multiValued: false },
4360
- * { name: 'familyName', type: 'string', multiValued: false }
4361
- * ]
4362
- * }
4363
- * ]
4364
- * }
4365
- * ];
4366
- *
4367
- * const flattened = flattenUserSchema(schemas);
4368
- * // Result: [
4369
- * // { name: 'userName', type: 'string', multiValued: false, schemaId: 'urn:ietf:params:scim:schemas:core:2.0:User' },
4370
- * // { name: 'name.givenName', type: 'string', multiValued: false, schemaId: 'urn:ietf:params:scim:schemas:core:2.0:User' },
4371
- * // { name: 'name.familyName', type: 'string', multiValued: false, schemaId: 'urn:ietf:params:scim:schemas:core:2.0:User' }
4372
- * // ]
4373
- * ```
4374
- */
4375
- const flattenUserSchema = (schemas) => {
4376
- const flattenedAttributes = [];
4377
- schemas.forEach((schema) => {
4378
- if (schema.attributes && Array.isArray(schema.attributes)) schema.attributes.forEach((attribute) => {
4379
- if (attribute.subAttributes && Array.isArray(attribute.subAttributes)) attribute.subAttributes.forEach((subAttribute) => {
4380
- flattenedAttributes.push({
4381
- ...subAttribute,
4382
- name: `${attribute.name}.${subAttribute.name}`,
4383
- schemaId: schema.id
4384
- });
4385
- });
4386
- else flattenedAttributes.push({
4387
- ...attribute,
4388
- schemaId: schema.id
4389
- });
4390
- });
4391
- });
4392
- return flattenedAttributes;
4393
- };
4394
- var flattenUserSchema_default = flattenUserSchema;
4395
-
4396
- //#endregion
4397
- //#region src/utils/get.ts
4398
- /**
4399
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
4400
- *
4401
- * WSO2 LLC. licenses this file to you under the Apache License,
4402
- * Version 2.0 (the "License"); you may not use this file except
4403
- * in compliance with the License.
4404
- * You may obtain a copy of the License at
4405
- *
4406
- * http://www.apache.org/licenses/LICENSE-2.0
4407
- *
4408
- * Unless required by applicable law or agreed to in writing,
4409
- * software distributed under the License is distributed on an
4410
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4411
- * KIND, either express or implied. See the License for the
4412
- * specific language governing permissions and limitations
4413
- * under the License.
4414
- */
4415
- /**
4416
- * Gets the value at path of object. If the resolved value is undefined,
4417
- * the defaultValue is returned in its place.
4418
- * Similar to Lodash's get() function
4419
- *
4420
- * @param object - The object to query
4421
- * @param path - The path of the property to get
4422
- * @param defaultValue - The value returned for undefined resolved values
4423
- * @returns The resolved value
4424
- */
4425
- const get = (object, path, defaultValue) => {
4426
- if (!object || !path) return defaultValue;
4427
- const result = (Array.isArray(path) ? path : path.split(".")).reduce((current, key) => current?.[key], object);
4428
- return result !== void 0 ? result : defaultValue;
4429
- };
4430
- var get_default = get;
4431
-
4432
- //#endregion
4433
- //#region src/utils/set.ts
4434
- /**
4435
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
4436
- *
4437
- * WSO2 LLC. licenses this file to you under the Apache License,
4438
- * Version 2.0 (the "License"); you may not use this file except
4439
- * in compliance with the License.
4440
- * You may obtain a copy of the License at
4441
- *
4442
- * http://www.apache.org/licenses/LICENSE-2.0
4443
- *
4444
- * Unless required by applicable law or agreed to in writing,
4445
- * software distributed under the License is distributed on an
4446
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4447
- * KIND, either express or implied. See the License for the
4448
- * specific language governing permissions and limitations
4449
- * under the License.
4450
- */
4451
- /**
4452
- * Sets the value at path of object. If a portion of path doesn't exist,
4453
- * it's created. Arrays are created for missing index properties while
4454
- * objects are created for all other missing properties.
4455
- * Similar to Lodash's set() function
4456
- *
4457
- * @param object - The object to modify
4458
- * @param path - The path of the property to set
4459
- * @param value - The value to set
4460
- * @returns The object
4461
- */
4462
- const set = (object, path, value) => {
4463
- if (!object || !path) return object;
4464
- const pathArray = Array.isArray(path) ? path : path.split(".");
4465
- const lastIndex = pathArray.length - 1;
4466
- pathArray.reduce((current, key, index) => {
4467
- if (index === lastIndex) current[key] = value;
4468
- else if (!(key in current) || typeof current[key] !== "object" || current[key] === null) {
4469
- const nextKey = pathArray[index + 1];
4470
- current[key] = /^\d+$/.test(nextKey) ? [] : {};
4471
- }
4472
- return current[key];
4473
- }, object);
4474
- return object;
4475
- };
4476
- var set_default = set;
4477
-
4478
- //#endregion
4479
- //#region src/utils/generateUserProfile.ts
4480
- /**
4481
- * Creates a profile structure from ME response based on processed schemas
4482
- *
4483
- * This function processes each schema attribute and populates the profile dynamically by:
4484
- * - Extracting values from the ME response using the schema attribute names
4485
- * - Handling multi-valued attributes by converting single values to arrays when needed
4486
- * - Setting appropriate default values based on schema type and multiValued properties
4487
- * - Using dynamic property setting to build the final profile object
4488
- *
4489
- * @param meResponse - The ME API response containing user data
4490
- * @param processedSchemas - The processed and flattened schemas with name, type, and multiValued properties
4491
- * @returns Flat profile object with dynamically populated user attributes
4492
- *
4493
- * @example
4494
- * ```typescript
4495
- * const meResponse = {
4496
- * userName: 'john.doe',
4497
- * emails: ['john@example.com', 'john.doe@work.com'],
4498
- * name: { givenName: 'John', familyName: 'Doe' }
4499
- * };
4500
- *
4501
- * const schemas = [
4502
- * { name: 'userName', type: 'STRING', multiValued: false },
4503
- * { name: 'emails', type: 'STRING', multiValued: true },
4504
- * { name: 'name.givenName', type: 'STRING', multiValued: false }
4505
- * ];
4506
- *
4507
- * const profile = generateUserProfile(meResponse, schemas);
4508
- * // Result: {
4509
- * // userName: 'john.doe',
4510
- * // emails: ['john@example.com', 'john.doe@work.com'],
4511
- * // 'name.givenName': 'John'
4512
- * // }
4513
- * ```
4514
- */
4515
- const generateUserProfile = (meResponse, processedSchemas) => {
4516
- const profile = {};
4517
- processedSchemas.forEach((schema) => {
4518
- const { name, type, multiValued } = schema;
4519
- if (!name) return;
4520
- let value = get_default(meResponse, name);
4521
- if (value !== void 0) {
4522
- if (multiValued && !Array.isArray(value)) value = [value];
4523
- } else if (multiValued) value = void 0;
4524
- else if (type === "STRING") value = "";
4525
- else value = void 0;
4526
- set_default(profile, name, value);
4527
- });
4528
- return profile;
4529
- };
4530
- var generateUserProfile_default = generateUserProfile;
4531
-
4532
4233
  //#endregion
4533
4234
  //#region src/utils/getLatestStateParam.ts
4534
4235
  /**
@@ -4574,95 +4275,14 @@ var getLatestStateParam_default = getLatestStateParam;
4574
4275
  //#endregion
4575
4276
  //#region src/utils/generateFlattenedUserProfile.ts
4576
4277
  /**
4577
- * Generates a flattened user profile from a response object and schema definitions.
4578
- *
4579
- * This function processes user data according to schema specifications, creating
4580
- * a flat object with dot notation keys instead of nested objects. Multi-valued
4581
- * properties and type-specific defaults are handled appropriately.
4582
- *
4583
- * Additionally, any fields present in the response but not defined in the schema
4584
- * will be included to ensure no user data is lost during flattening.
4278
+ * Generates a flattened user profile by returning the user profile as-is.
4585
4279
  *
4586
4280
  * @param meResponse - The response object containing user data
4587
- * @param processedSchemas - Array of schema objects defining field properties
4588
- * @param processedSchemas[].name - The field name/path for the property
4589
- * @param processedSchemas[].type - The data type of the field (e.g., 'STRING')
4590
- * @param processedSchemas[].multiValued - Whether the field can contain multiple values
4591
- *
4592
- * @returns A flattened user profile object with dot notation keys
4593
- *
4594
- * @example
4595
- * ```typescript
4596
- * const schemas = [
4597
- * { name: 'name.givenName', type: 'STRING', multiValued: false },
4598
- * { name: 'emails', type: 'STRING', multiValued: true }
4599
- * ];
4600
- * const response = {
4601
- * name: { givenName: 'John' },
4602
- * emails: 'john@example.com',
4603
- * country: 'US' // This will be included even if not in schema
4604
- * };
4605
- * const profile = generateFlattenedUserProfile(response, schemas);
4606
- * // Result: { "name.givenName": 'John', emails: ['john@example.com'], country: 'US' }
4607
- * ```
4281
+ * @param _processedSchemas - Deprecated/unused schemas parameter
4282
+ * @returns The user profile object
4608
4283
  */
4609
- const generateFlattenedUserProfile = (meResponse, processedSchemas) => {
4610
- const profile = {};
4611
- const allSchemaNames = processedSchemas.map((schema) => schema.name).filter(Boolean);
4612
- processedSchemas.forEach((schema) => {
4613
- const { name, type, multiValued } = schema;
4614
- if (!name) return;
4615
- if (allSchemaNames.some((schemaName) => schemaName !== name && schemaName.startsWith(`${name}.`))) return;
4616
- let value = get_default(meResponse, name);
4617
- if (value === void 0) {
4618
- const dotIndex = name.indexOf(".");
4619
- if (dotIndex > 0) {
4620
- const head = name.slice(0, dotIndex);
4621
- const tail = name.slice(dotIndex + 1);
4622
- const arr = meResponse[head];
4623
- if (Array.isArray(arr)) {
4624
- const match = arr.find((item) => item?.type === tail);
4625
- if (match?.value !== void 0) value = match.value;
4626
- }
4627
- }
4628
- }
4629
- if (value === void 0) [
4630
- "urn:ietf:params:scim:schemas:core:2.0:User",
4631
- "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User",
4632
- "urn:scim:wso2:schema",
4633
- "urn:scim:schemas:extension:custom:User"
4634
- ].some((namespace) => {
4635
- if (meResponse[namespace]) {
4636
- if (meResponse[namespace][name] !== void 0) {
4637
- value = meResponse[namespace][name];
4638
- return true;
4639
- }
4640
- const nestedValue = get_default(meResponse[namespace], name);
4641
- if (nestedValue !== void 0) {
4642
- value = nestedValue;
4643
- return true;
4644
- }
4645
- }
4646
- return false;
4647
- });
4648
- if (value !== void 0) {
4649
- if (multiValued && !Array.isArray(value)) value = [value];
4650
- } else if (multiValued) value = void 0;
4651
- else if (type === "STRING") value = "";
4652
- else value = void 0;
4653
- profile[name] = value;
4654
- });
4655
- const flattenObject = (obj, prefix = "") => {
4656
- if (obj && typeof obj === "object" && !Array.isArray(obj)) Object.keys(obj).forEach((key) => {
4657
- const fullKey = prefix ? `${prefix}.${key}` : key;
4658
- const value = obj[key];
4659
- if (Object.prototype.hasOwnProperty.call(profile, fullKey)) return;
4660
- if (allSchemaNames.some((schemaName) => schemaName.startsWith(`${fullKey}.`))) flattenObject(value, fullKey);
4661
- else profile[fullKey] = value;
4662
- });
4663
- };
4664
- flattenObject(meResponse);
4665
- return profile;
4284
+ const generateFlattenedUserProfile = (meResponse, _processedSchemas) => {
4285
+ return { ...meResponse };
4666
4286
  };
4667
4287
  var generateFlattenedUserProfile_default = generateFlattenedUserProfile;
4668
4288
 
@@ -4811,6 +4431,129 @@ const extractEmojiFromUri = (uri) => {
4811
4431
  };
4812
4432
  var extractEmojiFromUri_default = extractEmojiFromUri;
4813
4433
 
4434
+ //#endregion
4435
+ //#region src/utils/set.ts
4436
+ /**
4437
+ * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
4438
+ *
4439
+ * WSO2 LLC. licenses this file to you under the Apache License,
4440
+ * Version 2.0 (the "License"); you may not use this file except
4441
+ * in compliance with the License.
4442
+ * You may obtain a copy of the License at
4443
+ *
4444
+ * http://www.apache.org/licenses/LICENSE-2.0
4445
+ *
4446
+ * Unless required by applicable law or agreed to in writing,
4447
+ * software distributed under the License is distributed on an
4448
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4449
+ * KIND, either express or implied. See the License for the
4450
+ * specific language governing permissions and limitations
4451
+ * under the License.
4452
+ */
4453
+ /**
4454
+ * Sets the value at path of object. If a portion of path doesn't exist,
4455
+ * it's created. Arrays are created for missing index properties while
4456
+ * objects are created for all other missing properties.
4457
+ * Similar to Lodash's set() function
4458
+ *
4459
+ * @param object - The object to modify
4460
+ * @param path - The path of the property to set
4461
+ * @param value - The value to set
4462
+ * @returns The object
4463
+ */
4464
+ const set = (object, path, value) => {
4465
+ if (!object || !path) return object;
4466
+ const pathArray = Array.isArray(path) ? path : path.split(".");
4467
+ const lastIndex = pathArray.length - 1;
4468
+ pathArray.reduce((current, key, index) => {
4469
+ if (index === lastIndex) current[key] = value;
4470
+ else if (!(key in current) || typeof current[key] !== "object" || current[key] === null) {
4471
+ const nextKey = pathArray[index + 1];
4472
+ current[key] = /^\d+$/.test(nextKey) ? [] : {};
4473
+ }
4474
+ return current[key];
4475
+ }, object);
4476
+ return object;
4477
+ };
4478
+ var set_default = set;
4479
+
4480
+ //#endregion
4481
+ //#region src/utils/get.ts
4482
+ /**
4483
+ * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
4484
+ *
4485
+ * WSO2 LLC. licenses this file to you under the Apache License,
4486
+ * Version 2.0 (the "License"); you may not use this file except
4487
+ * in compliance with the License.
4488
+ * You may obtain a copy of the License at
4489
+ *
4490
+ * http://www.apache.org/licenses/LICENSE-2.0
4491
+ *
4492
+ * Unless required by applicable law or agreed to in writing,
4493
+ * software distributed under the License is distributed on an
4494
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4495
+ * KIND, either express or implied. See the License for the
4496
+ * specific language governing permissions and limitations
4497
+ * under the License.
4498
+ */
4499
+ /**
4500
+ * Gets the value at path of object. If the resolved value is undefined,
4501
+ * the defaultValue is returned in its place.
4502
+ * Similar to Lodash's get() function
4503
+ *
4504
+ * @param object - The object to query
4505
+ * @param path - The path of the property to get
4506
+ * @param defaultValue - The value returned for undefined resolved values
4507
+ * @returns The resolved value
4508
+ */
4509
+ const get = (object, path, defaultValue) => {
4510
+ if (!object || !path) return defaultValue;
4511
+ const result = (Array.isArray(path) ? path : path.split(".")).reduce((current, key) => current?.[key], object);
4512
+ return result !== void 0 ? result : defaultValue;
4513
+ };
4514
+ var get_default = get;
4515
+
4516
+ //#endregion
4517
+ //#region src/utils/startCase.ts
4518
+ /**
4519
+ * Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com). All Rights Reserved.
4520
+ *
4521
+ * WSO2 LLC. licenses this file to you under the Apache License,
4522
+ * Version 2.0 (the "License"); you may not use this file except
4523
+ * in compliance with the License.
4524
+ * You may obtain a copy of the License at
4525
+ *
4526
+ * http://www.apache.org/licenses/LICENSE-2.0
4527
+ *
4528
+ * Unless required by applicable law or agreed to in writing,
4529
+ * software distributed under the License is distributed on an
4530
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4531
+ * KIND, either express or implied. See the License for the
4532
+ * specific language governing permissions and limitations
4533
+ * under the License.
4534
+ */
4535
+ /**
4536
+ * Converts the first character of `string` to upper case.
4537
+ *
4538
+ * @param string - The string to convert.
4539
+ * @returns The converted string.
4540
+ */
4541
+ const upperFirst = (str) => {
4542
+ if (!str) return "";
4543
+ return str.charAt(0).toUpperCase() + str.slice(1);
4544
+ };
4545
+ /**
4546
+ * Converts `string` to start case.
4547
+ *
4548
+ * @param string - The string to convert.
4549
+ * @returns The start cased string.
4550
+ */
4551
+ const startCase = (str) => {
4552
+ if (!str) return "";
4553
+ return str.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/[^a-zA-Z0-9]+/g, " ").trim().split(/\s+/).map((word) => upperFirst(word)).join(" ");
4554
+ };
4555
+ var startCase_default = startCase;
4556
+
4814
4557
  //#endregion
4815
4558
  //#region src/utils/removeTrailingSlash.ts
4816
4559
  /**
@@ -6342,4 +6085,4 @@ const normalizeTranslations = (translations) => {
6342
6085
  var normalizeTranslations_default = normalizeTranslations;
6343
6086
 
6344
6087
  //#endregion
6345
- export { ApplicationNativeAuthenticationConstants_default as ApplicationNativeAuthenticationConstants, AuthenticationHelper_default as AuthenticationHelper, DEFAULT_THEME, DEFAULT_VALIDATION_MESSAGE_KEYS, EMOJI_URI_SCHEME, EmbeddedFlowActionVariant, EmbeddedFlowComponentType, EmbeddedFlowEventType, EmbeddedFlowResponseType, EmbeddedFlowTextVariant, EmbeddedFlowType, EmbeddedRecoveryFlowStatus, EmbeddedRecoveryFlowType, EmbeddedSignInFlowStatus, EmbeddedSignInFlowType, EmbeddedSignUpFlowStatus, EmbeddedSignUpFlowType, FieldType, FlowMetaType, FlowMode, HttpClient, IsomorphicCrypto, OIDCRequestConstants_default as OIDCRequestConstants, StorageManager_default as StorageManager, ThunderIDAPIError, ThunderIDAuthException, ThunderIDError, ThunderIDJavaScriptClient_default as ThunderIDJavaScriptClient, ThunderIDRuntimeError, TokenConstants_default as TokenConstants, TranslationBundleConstants_default as TranslationBundleConstants, VendorConstants_default as VendorConstants, WellKnownSchemaIds, arrayBufferToBase64url_default as arrayBufferToBase64url, base64urlToArrayBuffer_default as base64urlToArrayBuffer, bem_default as bem, buildValidatorFromRules_default as buildValidatorFromRules, configure as configureLogger, countryCodeToFlagEmoji, createComponentLogger, createLogger, createPackageComponentLogger, createPackageLogger, createTheme_default as createTheme, debug, deepMerge_default as deepMerge, error, evaluateValidationRule_default as evaluateValidationRule, executeEmbeddedRecoveryFlow_default as executeEmbeddedRecoveryFlow, executeEmbeddedSignInFlow_default as executeEmbeddedSignInFlow, executeEmbeddedSignUpFlow_default as executeEmbeddedSignUpFlow, executeEmbeddedUserOnboardingFlow_default as executeEmbeddedUserOnboardingFlow, extractEmojiFromUri_default as extractEmojiFromUri, extractPkceStorageKeyFromState_default as extractPkceStorageKeyFromState, extractUserClaimsFromIdToken_default as extractUserClaimsFromIdToken, flattenUserSchema_default as flattenUserSchema, formatDate_default as formatDate, generateFlattenedUserProfile_default as generateFlattenedUserProfile, generateUserProfile_default as generateUserProfile, get_default as get, getDefaultI18nBundles_default as getDefaultI18nBundles, getFlowMeta_default as getFlowMeta, getLatestStateParam_default as getLatestStateParam, getOrganizationUnitChildren_default as getOrganizationUnitChildren, getRedirectBasedSignUpUrl_default as getRedirectBasedSignUpUrl, getSchemas_default as getSchemas, getScim2Me_default as getScim2Me, getUserInfo_default as getUserInfo, getVendorPrefix_default as getVendorPrefix, info, isEmojiUri_default as isEmojiUri, isEmpty_default as isEmpty, isRecognizedBaseUrlPattern_default as isRecognizedBaseUrlPattern, logger_default as logger, normalizeTranslations_default as normalizeTranslations, processOpenIDScopes_default as processOpenIDScopes, processUsername_default as processUsername, removeTrailingSlash_default as removeTrailingSlash, resolveFieldName_default as resolveFieldName, resolveFlowTemplateLiterals, resolveLocaleDisplayName, resolveLocaleEmoji_default as resolveLocaleEmoji, resolveMeta, set_default as set, updateMeProfile_default as updateMeProfile, warn, withVendorCSSClassPrefix_default as withVendorCSSClassPrefix };
6088
+ export { ApplicationNativeAuthenticationConstants_default as ApplicationNativeAuthenticationConstants, AuthenticationHelper_default as AuthenticationHelper, DEFAULT_THEME, DEFAULT_VALIDATION_MESSAGE_KEYS, EMOJI_URI_SCHEME, EmbeddedFlowActionVariant, EmbeddedFlowComponentType, EmbeddedFlowEventType, EmbeddedFlowResponseType, EmbeddedFlowTextVariant, EmbeddedFlowType, EmbeddedRecoveryFlowStatus, EmbeddedRecoveryFlowType, EmbeddedSignInFlowStatus, EmbeddedSignInFlowType, EmbeddedSignUpFlowStatus, EmbeddedSignUpFlowType, FieldType, FlowMetaType, FlowMode, HttpClient, IsomorphicCrypto, OIDCRequestConstants_default as OIDCRequestConstants, StorageManager_default as StorageManager, ThunderIDAPIError, ThunderIDAuthException, ThunderIDError, ThunderIDJavaScriptClient_default as ThunderIDJavaScriptClient, ThunderIDRuntimeError, TokenConstants_default as TokenConstants, TranslationBundleConstants_default as TranslationBundleConstants, VendorConstants_default as VendorConstants, arrayBufferToBase64url_default as arrayBufferToBase64url, base64urlToArrayBuffer_default as base64urlToArrayBuffer, bem_default as bem, buildValidatorFromRules_default as buildValidatorFromRules, configure as configureLogger, countryCodeToFlagEmoji, createComponentLogger, createLogger, createPackageComponentLogger, createPackageLogger, createTheme_default as createTheme, debug, deepMerge_default as deepMerge, error, evaluateValidationRule_default as evaluateValidationRule, executeEmbeddedRecoveryFlow_default as executeEmbeddedRecoveryFlow, executeEmbeddedSignInFlow_default as executeEmbeddedSignInFlow, executeEmbeddedSignUpFlow_default as executeEmbeddedSignUpFlow, executeEmbeddedUserOnboardingFlow_default as executeEmbeddedUserOnboardingFlow, extractEmojiFromUri_default as extractEmojiFromUri, extractPkceStorageKeyFromState_default as extractPkceStorageKeyFromState, extractUserClaimsFromIdToken_default as extractUserClaimsFromIdToken, formatDate_default as formatDate, generateFlattenedUserProfile_default as generateFlattenedUserProfile, get_default as get, getDefaultI18nBundles_default as getDefaultI18nBundles, getFlowMeta_default as getFlowMeta, getLatestStateParam_default as getLatestStateParam, getOrganizationUnitChildren_default as getOrganizationUnitChildren, getRedirectBasedSignUpUrl_default as getRedirectBasedSignUpUrl, getUserInfo_default as getUserInfo, getUsersMe_default as getUsersMe, getVendorPrefix_default as getVendorPrefix, info, isEmojiUri_default as isEmojiUri, isEmpty_default as isEmpty, isRecognizedBaseUrlPattern_default as isRecognizedBaseUrlPattern, logger_default as logger, normalizeTranslations_default as normalizeTranslations, processOpenIDScopes_default as processOpenIDScopes, processUsername_default as processUsername, removeTrailingSlash_default as removeTrailingSlash, resolveFieldName_default as resolveFieldName, resolveFlowTemplateLiterals, resolveLocaleDisplayName, resolveLocaleEmoji_default as resolveLocaleEmoji, resolveMeta, set_default as set, startCase_default as startCase, updateMeProfile_default as updateMeProfile, warn, withVendorCSSClassPrefix_default as withVendorCSSClassPrefix };