@oxyhq/core 3.4.16 → 3.4.17

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.
@@ -397,6 +397,7 @@ export class AuthManager {
397
397
  user: {
398
398
  id: session.user.id,
399
399
  username: session.user.username,
400
+ name: session.user.name,
400
401
  avatar: session.user.avatar ?? null,
401
402
  },
402
403
  accessToken: session.accessToken,
@@ -628,6 +629,7 @@ export class AuthManager {
628
629
  return {
629
630
  id: account.user.id,
630
631
  username: account.user.username,
632
+ name: account.user.name,
631
633
  avatar: account.user.avatar ?? undefined,
632
634
  };
633
635
  }
@@ -672,6 +674,7 @@ export class AuthManager {
672
674
  this.currentUser = {
673
675
  id: hydrated.id,
674
676
  username: hydrated.username,
677
+ name: hydrated.name,
675
678
  avatar: hydrated.avatar ?? undefined,
676
679
  };
677
680
  this.notifyListeners();
@@ -873,6 +876,7 @@ export class AuthManager {
873
876
  ? {
874
877
  id: updated.user.id,
875
878
  username: updated.user.username,
879
+ name: updated.user.name,
876
880
  avatar: updated.user.avatar ?? undefined,
877
881
  }
878
882
  : null;
@@ -928,6 +932,7 @@ export class AuthManager {
928
932
  ? {
929
933
  id: next.user.id,
930
934
  username: next.user.username,
935
+ name: next.user.name,
931
936
  avatar: next.user.avatar ?? undefined,
932
937
  }
933
938
  : null;
@@ -489,7 +489,7 @@ export function OxyServicesAuthMixin(Base) {
489
489
  continue;
490
490
  }
491
491
  const userId = e.user.id ?? e.user._id;
492
- if (!userId || !e.user.username) {
492
+ if (!userId || !e.user.username || !e.user.name?.displayName) {
493
493
  continue;
494
494
  }
495
495
  if (typeof e.authuser !== 'number') {
@@ -111,12 +111,13 @@ export function OxyServicesSsoMixin(Base) {
111
111
  throw this.handleError(new Error('SSO exchange returned no sessionId'));
112
112
  }
113
113
  const userId = payload.user?.id ?? payload.user?._id;
114
- if (!userId || typeof payload.user?.username !== 'string') {
114
+ if (!userId || typeof payload.user?.username !== 'string' || typeof payload.user.name?.displayName !== 'string') {
115
115
  throw this.handleError(new Error('SSO exchange returned an invalid user'));
116
116
  }
117
117
  const user = {
118
118
  id: userId,
119
119
  username: payload.user.username,
120
+ name: payload.user.name,
120
121
  avatar: payload.user.avatar,
121
122
  };
122
123
  // Plant the access token exactly like exchangeIdTokenForSession does.
@@ -24,7 +24,7 @@ export function OxyServicesUserMixin(Base) {
24
24
  }
25
25
  /**
26
26
  * Lightweight username lookup for login flows.
27
- * Returns minimal public info: exists, color, avatar, displayName.
27
+ * Returns minimal public info: exists, color, avatar, name.displayName.
28
28
  * Faster than getProfileByUsername — no stats, no formatting.
29
29
  */
30
30
  async lookupUsername(username) {
@@ -17,12 +17,13 @@ export const formatPublicKeyHandle = (publicKey) => {
17
17
  * Resolve a friendly display name for a user.
18
18
  *
19
19
  * Order of preference:
20
- * 1. `displayName` from the API contract.
20
+ * 1. `name.displayName` from the API user contract.
21
21
  * 2. `name.full`, or composed `name.first name.last` for local unsaved shapes.
22
- * 3. `name` when stored as a plain string.
23
- * 4. `username`
24
- * 5. `Account 0x12345678…` (derived from publicKey, when present)
25
- * 6. Translated fallback (e.g. "Unnamed")
22
+ * 3. `name` when passed as a plain string by local non-DTO call sites.
23
+ * 4. pre-normalized account-row `displayName`.
24
+ * 5. `username`
25
+ * 6. `Account 0x12345678…` (derived from publicKey, when present)
26
+ * 7. Translated fallback (e.g. "Unnamed")
26
27
  *
27
28
  * The translation key `common.unnamed` is used for the final fallback. If the
28
29
  * caller does not pass a locale, the default English translation is used.
@@ -31,9 +32,10 @@ export const getAccountDisplayName = (user, locale) => {
31
32
  if (!user)
32
33
  return translate(locale, 'common.unnamed');
33
34
  const { name, displayName, username, publicKey } = user;
34
- if (typeof displayName === 'string' && displayName.trim())
35
- return displayName.trim();
36
35
  if (name && typeof name === 'object') {
36
+ if (typeof name.displayName === 'string' && name.displayName.trim()) {
37
+ return name.displayName.trim();
38
+ }
37
39
  if (typeof name.full === 'string' && name.full.trim())
38
40
  return name.full.trim();
39
41
  const first = typeof name.first === 'string' ? name.first.trim() : '';
@@ -45,6 +47,8 @@ export const getAccountDisplayName = (user, locale) => {
45
47
  else if (typeof name === 'string' && name.trim()) {
46
48
  return name.trim();
47
49
  }
50
+ if (typeof displayName === 'string' && displayName.trim())
51
+ return displayName.trim();
48
52
  if (typeof username === 'string' && username.trim())
49
53
  return username.trim();
50
54
  if (typeof publicKey === 'string' && publicKey.length > 0) {
@@ -96,18 +100,19 @@ export const createQuickAccount = (sessionId, userData, existingAccount, getFile
96
100
  const userId = userData.id || (typeof userData._id === 'string' ? userData._id : userData._id?.toString());
97
101
  // Preserve existing avatarUrl if avatar hasn't changed (prevents image reload)
98
102
  let avatarUrl;
99
- if (existingAccount && existingAccount.avatar === userData.avatar && existingAccount.avatarUrl) {
103
+ const avatar = userData.avatar ?? undefined;
104
+ if (existingAccount && existingAccount.avatar === avatar && existingAccount.avatarUrl) {
100
105
  avatarUrl = existingAccount.avatarUrl;
101
106
  }
102
- else if (userData.avatar && getFileDownloadUrl) {
103
- avatarUrl = getFileDownloadUrl(userData.avatar, 'thumb');
107
+ else if (avatar && getFileDownloadUrl) {
108
+ avatarUrl = getFileDownloadUrl(avatar, 'thumb');
104
109
  }
105
110
  return {
106
111
  sessionId,
107
112
  userId,
108
113
  username: userData.username || '',
109
114
  displayName,
110
- avatar: userData.avatar,
115
+ avatar,
111
116
  avatarUrl,
112
117
  };
113
118
  };