propro-utils 1.7.19 → 1.7.21
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
package/src/server/index.js
CHANGED
|
@@ -93,9 +93,9 @@ class AuthMiddleware {
|
|
|
93
93
|
const response = await this.proxyToAuthServer(req, `/api/v1/auth/login`);
|
|
94
94
|
|
|
95
95
|
const { account, tokens } = response.data;
|
|
96
|
-
|
|
96
|
+
console.log('account:', account);
|
|
97
97
|
const user = await checkIfUserExists(account.accountId);
|
|
98
|
-
|
|
98
|
+
console.log('user:', user);
|
|
99
99
|
|
|
100
100
|
if (returnTokens === 'true') {
|
|
101
101
|
res.status(response.status).json({ account, user, tokens });
|
|
@@ -72,7 +72,6 @@ const setChromeExtensionCookie = details => {
|
|
|
72
72
|
}
|
|
73
73
|
});
|
|
74
74
|
} catch (error) {
|
|
75
|
-
console.log('Error setting cookie: setChromeExtensionCookie', error);
|
|
76
75
|
// Not in extension context
|
|
77
76
|
resolve(null);
|
|
78
77
|
}
|
|
@@ -159,46 +158,31 @@ const setAuthCookies = async (res, tokens, account, user, appUrl) => {
|
|
|
159
158
|
try {
|
|
160
159
|
Object.entries({ ...httpOnlyCookies, ...regularCookies }).forEach(
|
|
161
160
|
([name, config]) => {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
...config,
|
|
167
|
-
});
|
|
168
|
-
// console.log('Setting cookie 2:', {response})
|
|
169
|
-
} catch (error) {
|
|
170
|
-
console.error('Error setting cookie: Object.entries', {
|
|
171
|
-
error: error.message,
|
|
172
|
-
stack: error.stack,
|
|
173
|
-
});
|
|
174
|
-
}
|
|
161
|
+
res.cookie(name, config.value, {
|
|
162
|
+
...commonAttributes,
|
|
163
|
+
...config,
|
|
164
|
+
});
|
|
175
165
|
}
|
|
176
166
|
);
|
|
177
167
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
// return res.cookie(name, config.value, {
|
|
195
|
-
// ...commonAttributes,
|
|
196
|
-
// ...config,
|
|
197
|
-
// url: `https://${domain || 'propro.so'}`,
|
|
198
|
-
// });
|
|
199
|
-
// });
|
|
168
|
+
const extensionCookiePromises = Object.entries({
|
|
169
|
+
...httpOnlyCookies,
|
|
170
|
+
...regularCookies,
|
|
171
|
+
}).map(([name, config]) => {
|
|
172
|
+
return setChromeExtensionCookie({
|
|
173
|
+
url: `https://${domain || 'propro.so'}`,
|
|
174
|
+
name,
|
|
175
|
+
value: config.value,
|
|
176
|
+
secure: true,
|
|
177
|
+
httpOnly: !!config.httpOnly,
|
|
178
|
+
sameSite: 'no_restriction',
|
|
179
|
+
path: '/',
|
|
180
|
+
expirationDate: Math.floor((Date.now() + config.maxAge) / 1000),
|
|
181
|
+
domain: domain?.startsWith('.') ? domain : `.${domain || 'propro.so'}`,
|
|
182
|
+
});
|
|
183
|
+
});
|
|
200
184
|
|
|
201
|
-
|
|
185
|
+
await Promise.allSettled(extensionCookiePromises);
|
|
202
186
|
|
|
203
187
|
console.log('Auth cookies set successfully', {
|
|
204
188
|
domain,
|