@spytecgps/lambda-utils 2.3.23 → 2.3.25
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/dist/index.js +6 -4
- package/dist/logger/index.d.ts +2 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -498,7 +498,10 @@ const offlineAuthMiddleware = ({ authFunctionName = 'spytec-web-api-auth-prod-Au
|
|
|
498
498
|
// Extract Bearer token from the Authorization header
|
|
499
499
|
const authHeader = event.headers?.Authorization || event.headers?.authorization;
|
|
500
500
|
if (!authHeader || !authHeader.startsWith('Bearer ')) {
|
|
501
|
-
throw new Error('Authorization header is missing or invalid')
|
|
501
|
+
// throw new Error('Authorization header is missing or invalid')
|
|
502
|
+
// if we can't extract the token, this is is a public route, ignore it
|
|
503
|
+
sdkLogger.logger.warn('Authorization header is missing or invalid, skipping fake offline authorization');
|
|
504
|
+
return;
|
|
502
505
|
}
|
|
503
506
|
const token = authHeader.slice(7); // Remove 'Bearer ' prefix
|
|
504
507
|
// Prepare payload for the auth function
|
|
@@ -533,9 +536,8 @@ const responseWrapperMiddleware = () => {
|
|
|
533
536
|
const responseWrapperMiddlewareError = (req) => {
|
|
534
537
|
const statusCode = req.error?.code ?? 500;
|
|
535
538
|
const errorMessage = req.error?.message || 'Error';
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
}
|
|
539
|
+
const loggerMethod = statusCode >= 500 ? 'error' : 'info';
|
|
540
|
+
sdkLogger.logger[loggerMethod](req.error, 'Request failed');
|
|
539
541
|
req.response = buildProxyResult({
|
|
540
542
|
statusCode,
|
|
541
543
|
message: errorMessage,
|
package/package.json
CHANGED