@livedesk/client 0.1.189 → 0.1.190
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": "@livedesk/client",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.190",
|
|
4
4
|
"description": "LiveDesk local remote client",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -41,10 +41,10 @@
|
|
|
41
41
|
"ws": "^8.18.3"
|
|
42
42
|
},
|
|
43
43
|
"optionalDependencies": {
|
|
44
|
-
"@livedesk/fast-linux-x64": "0.1.
|
|
45
|
-
"@livedesk/fast-osx-arm64": "0.1.
|
|
46
|
-
"@livedesk/fast-osx-x64": "0.1.
|
|
47
|
-
"@livedesk/fast-win-x64": "0.1.
|
|
44
|
+
"@livedesk/fast-linux-x64": "0.1.397",
|
|
45
|
+
"@livedesk/fast-osx-arm64": "0.1.397",
|
|
46
|
+
"@livedesk/fast-osx-x64": "0.1.397",
|
|
47
|
+
"@livedesk/fast-win-x64": "0.1.397"
|
|
48
48
|
},
|
|
49
49
|
"publishConfig": {
|
|
50
50
|
"access": "public"
|
|
@@ -49,7 +49,20 @@ function normalizeAccountAvatarUrl(value) {
|
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
function readAccessTokenProfile(accessToken) {
|
|
53
|
+
const token = normalizeString(accessToken, 8192);
|
|
54
|
+
const payloadSegment = token.split('.')[1] || '';
|
|
55
|
+
if (!payloadSegment) return {};
|
|
56
|
+
try {
|
|
57
|
+
const payload = JSON.parse(Buffer.from(payloadSegment, 'base64url').toString('utf8'));
|
|
58
|
+
return payload && typeof payload === 'object' ? payload : {};
|
|
59
|
+
} catch {
|
|
60
|
+
return {};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
52
64
|
function readClientAccountProfile(sessionOrUser) {
|
|
65
|
+
const tokenProfile = readAccessTokenProfile(sessionOrUser?.access_token);
|
|
53
66
|
const user = sessionOrUser?.user && typeof sessionOrUser.user === 'object'
|
|
54
67
|
? sessionOrUser.user
|
|
55
68
|
: sessionOrUser && typeof sessionOrUser === 'object'
|
|
@@ -58,12 +71,19 @@ function readClientAccountProfile(sessionOrUser) {
|
|
|
58
71
|
const metadata = user.user_metadata && typeof user.user_metadata === 'object'
|
|
59
72
|
? user.user_metadata
|
|
60
73
|
: {};
|
|
61
|
-
const
|
|
74
|
+
const tokenMetadata = tokenProfile.user_metadata && typeof tokenProfile.user_metadata === 'object'
|
|
75
|
+
? tokenProfile.user_metadata
|
|
76
|
+
: {};
|
|
77
|
+
const email = normalizeString(user.email || tokenProfile.email, 320);
|
|
62
78
|
const name = normalizeString(
|
|
63
79
|
metadata.full_name
|
|
64
80
|
|| metadata.name
|
|
65
81
|
|| metadata.preferred_username
|
|
82
|
+
|| tokenMetadata.full_name
|
|
83
|
+
|| tokenMetadata.name
|
|
84
|
+
|| tokenMetadata.preferred_username
|
|
66
85
|
|| user.name
|
|
86
|
+
|| tokenProfile.name
|
|
67
87
|
|| email
|
|
68
88
|
|| user.id,
|
|
69
89
|
160
|
|
@@ -71,6 +91,8 @@ function readClientAccountProfile(sessionOrUser) {
|
|
|
71
91
|
const avatarUrl = normalizeAccountAvatarUrl(
|
|
72
92
|
metadata.avatar_url
|
|
73
93
|
|| metadata.picture
|
|
94
|
+
|| tokenMetadata.avatar_url
|
|
95
|
+
|| tokenMetadata.picture
|
|
74
96
|
|| user.avatar_url
|
|
75
97
|
|| user.picture
|
|
76
98
|
);
|
|
@@ -79,7 +101,11 @@ function readClientAccountProfile(sessionOrUser) {
|
|
|
79
101
|
|
|
80
102
|
function mergeClientAccountProfile(session, sourceUser) {
|
|
81
103
|
const profile = readClientAccountProfile(sourceUser);
|
|
104
|
+
const existingUserMetadata = session?.user?.user_metadata && typeof session.user.user_metadata === 'object'
|
|
105
|
+
? session.user.user_metadata
|
|
106
|
+
: {};
|
|
82
107
|
const userMetadata = {
|
|
108
|
+
...existingUserMetadata,
|
|
83
109
|
...(profile.name ? { full_name: profile.name } : {}),
|
|
84
110
|
...(profile.avatarUrl ? { avatar_url: profile.avatarUrl } : {})
|
|
85
111
|
};
|
|
@@ -1275,7 +1301,11 @@ export function createClientRuntimeServer(options = {}) {
|
|
|
1275
1301
|
setImmediate(() => {
|
|
1276
1302
|
void (async () => {
|
|
1277
1303
|
try {
|
|
1278
|
-
|
|
1304
|
+
// Older persisted sessions kept only id/email on `user`, while
|
|
1305
|
+
// Supabase still carries Google name/avatar claims in the
|
|
1306
|
+
// access-token payload. Recover those display-only claims
|
|
1307
|
+
// locally before any best-effort network hydration.
|
|
1308
|
+
const normalizedSession = mergeClientAccountProfile(saved.session, savedSession);
|
|
1279
1309
|
const hydratedSession = await hydrateClientAccountProfile(normalizedSession);
|
|
1280
1310
|
if (!writeSavedSession(hydratedSession)) throw new Error('refresh-token-required');
|
|
1281
1311
|
state.auth.persisted = true;
|