propro-utils 1.7.54 → 1.7.55
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/middlewares/access_token.js +12 -1
- package/package.json +1 -1
|
@@ -38,6 +38,7 @@ const ServiceManager = require('../utils/serviceManager');
|
|
|
38
38
|
const USER_CACHE_TTL_SECONDS = 60;
|
|
39
39
|
const IN_PROCESS_AUTH_CACHE_TTL_MS = 5000;
|
|
40
40
|
const MAX_IN_PROCESS_CACHE_ENTRIES = 1000;
|
|
41
|
+
const AUTH_SERVICE_TIMEOUT_MS = 10000;
|
|
41
42
|
const validationMemoryCache = new Map();
|
|
42
43
|
const userMemoryCache = new Map();
|
|
43
44
|
|
|
@@ -86,7 +87,8 @@ const authValidation = (requiredPermissions = []) => {
|
|
|
86
87
|
{
|
|
87
88
|
accessToken: accessToken,
|
|
88
89
|
requiredPermissions: requiredPermissions,
|
|
89
|
-
}
|
|
90
|
+
},
|
|
91
|
+
{ timeout: AUTH_SERVICE_TIMEOUT_MS }
|
|
90
92
|
);
|
|
91
93
|
return response.data;
|
|
92
94
|
};
|
|
@@ -135,6 +137,15 @@ const authValidation = (requiredPermissions = []) => {
|
|
|
135
137
|
if (error.response && error.response.status) {
|
|
136
138
|
return next(new Error(error.response.data.message));
|
|
137
139
|
}
|
|
140
|
+
if (error.code === 'ECONNABORTED') {
|
|
141
|
+
console.error(`[auth] Auth service timed out after ${AUTH_SERVICE_TIMEOUT_MS}ms: ${process.env.AUTH_URL}`);
|
|
142
|
+
return next(new Error('Auth service timeout'));
|
|
143
|
+
}
|
|
144
|
+
if (error.code) {
|
|
145
|
+
console.error(`[auth] Auth service unreachable (${error.code}): ${process.env.AUTH_URL}`, error.message);
|
|
146
|
+
return next(new Error('Auth service unreachable'));
|
|
147
|
+
}
|
|
148
|
+
console.error('[auth] Unexpected error during token validation:', error);
|
|
138
149
|
return next(new Error('Error validating token'));
|
|
139
150
|
}
|
|
140
151
|
};
|