@salesforcedevs/dx-components 1.2.6-avatar-button-3 → 1.2.6-avatar-button-5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/dx-components",
3
- "version": "1.2.6-avatar-button-3",
3
+ "version": "1.2.6-avatar-button-5",
4
4
  "description": "DX Lightning web components",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -12,9 +12,8 @@ const TBID_PROFILE_URL = `${TBID_BASE_URL}/id`;
12
12
  const TBID_IFRAME_URL = `${TBID_BASE_URL}/secur/logout.jsp`;
13
13
 
14
14
  // API URLs:
15
- const TBID_API_BASE_URL = `${
16
- process.env.BASE_URL || "https://developer.salesforce.com"
17
- }/tbid`;
15
+ // TODO: Switch this to env variable once we're out of dev
16
+ const TBID_API_BASE_URL = "https://development.developer.salesforce.com/tbid";
18
17
  const TBID_API_LOGOUT_URL = `${TBID_API_BASE_URL}/logout`;
19
18
  const TBID_API_USERINFO_URL = `${TBID_API_BASE_URL}/userinfo`;
20
19
  const TBID_API_LOGIN_URL = `${TBID_API_BASE_URL}/dologin`;
@@ -312,38 +311,44 @@ export default class AvatarButton extends LightningElement {
312
311
  return;
313
312
  }
314
313
 
315
- const nextUserInfo: UserInfo = {};
316
- nextUserInfo.avatarImgSrc = userInfo.photos?.thumbnail;
317
- nextUserInfo.firstName = userInfo.given_name;
318
- nextUserInfo.lastName = userInfo.family_name;
319
- nextUserInfo.username = userInfo.preferred_username;
320
- nextUserInfo.id = userInfo.user_id;
321
- nextUserInfo.orgId = userInfo.organization_id;
322
- nextUserInfo.fullName =
323
- nextUserInfo.firstName && nextUserInfo.lastName
324
- ? `${nextUserInfo.firstName} ${nextUserInfo.lastName}`
325
- : nextUserInfo.firstName || nextUserInfo.lastName || "";
314
+ const uncleanNextUserInfo: UserInfo = {};
315
+ uncleanNextUserInfo.avatarImgSrc = userInfo.photos?.thumbnail;
316
+ uncleanNextUserInfo.firstName = userInfo.given_name;
317
+ uncleanNextUserInfo.lastName = userInfo.family_name;
318
+ uncleanNextUserInfo.username = userInfo.preferred_username;
319
+ uncleanNextUserInfo.id = userInfo.user_id;
320
+ uncleanNextUserInfo.orgId = userInfo.organization_id;
321
+ uncleanNextUserInfo.fullName =
322
+ uncleanNextUserInfo.firstName && uncleanNextUserInfo.lastName
323
+ ? `${uncleanNextUserInfo.firstName} ${uncleanNextUserInfo.lastName}`
324
+ : uncleanNextUserInfo.firstName ||
325
+ uncleanNextUserInfo.lastName ||
326
+ "";
326
327
 
327
328
  if (userInfo.custom_attributes) {
328
329
  // ProfilePictureUrl updates earlier than photos.thumbnail, so we prefer it if it's available here.
329
- nextUserInfo.avatarImgSrc =
330
+ uncleanNextUserInfo.avatarImgSrc =
330
331
  userInfo.custom_attributes.ProfilePictureUrl ||
331
- nextUserInfo.avatarImgSrc;
332
- nextUserInfo.company = userInfo.custom_attributes.CompanyName;
333
- nextUserInfo.relationship =
332
+ uncleanNextUserInfo.avatarImgSrc;
333
+ uncleanNextUserInfo.company =
334
+ userInfo.custom_attributes.CompanyName;
335
+ uncleanNextUserInfo.relationship =
334
336
  userInfo.custom_attributes.RelationshipToSalesforce;
335
- nextUserInfo.role = userInfo.custom_attributes.Role;
337
+ uncleanNextUserInfo.role = userInfo.custom_attributes.Role;
336
338
  }
337
339
 
338
- // A little extra safety here just to make sure we aren't receiving/displaying any unsafe values...
339
- const htmlSafeNextUserInfo: UserInfo = Object.fromEntries(
340
- Object.entries(nextUserInfo).map(([key, val]) => [
341
- key,
342
- escapeHtml(val)
343
- ])
344
- );
340
+ const cleanUserInfo: UserInfo = {};
341
+ Object.entries(uncleanNextUserInfo).forEach(([key, val]) => {
342
+ if (val === "undefined") {
343
+ // Clean away bad JSON string data by skipping these.
344
+ return;
345
+ }
346
+ // Also just a little extra safety to make sure we aren't injecting anything unsafe...
347
+ cleanUserInfo[key as keyof UserInfo] = escapeHtml(val);
348
+ });
345
349
 
346
- this.userInfo = defaults(htmlSafeNextUserInfo, this.userInfo);
350
+ // Keep the old info for any values not defined on `cleanUserInfo`
351
+ this.userInfo = defaults(cleanUserInfo, this.userInfo);
347
352
  };
348
353
 
349
354
  private requestUserInfo = async () => {