@valentine-efagene/qshelter-common 2.0.132 → 2.0.133

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.
@@ -10,7 +10,13 @@ declare global {
10
10
  tenantContext?: TenantContext;
11
11
  tenantPrisma?: TenantPrismaClient | PrismaClient;
12
12
  /**
13
- * API Gateway context added by serverless-express
13
+ * API Gateway context added by serverless-express.
14
+ *
15
+ * With HTTP API v2 and enableSimpleResponses=true, context is under:
16
+ * authorizer.lambda.{field}
17
+ *
18
+ * With REST API or enableSimpleResponses=false, context is under:
19
+ * authorizer.{field}
14
20
  */
15
21
  apiGateway?: {
16
22
  event: {
@@ -20,6 +26,12 @@ declare global {
20
26
  email?: string;
21
27
  roles?: string;
22
28
  tenantId?: string;
29
+ lambda?: {
30
+ userId?: string;
31
+ email?: string;
32
+ roles?: string;
33
+ tenantId?: string;
34
+ };
23
35
  };
24
36
  };
25
37
  };
@@ -21,7 +21,10 @@ export function createTenantMiddleware(options) {
21
21
  return function tenantMiddleware(req, res, next) {
22
22
  try {
23
23
  // 1. Try Lambda authorizer context first (production)
24
- const authorizerContext = req.apiGateway?.event?.requestContext?.authorizer;
24
+ // HTTP API v2 with enableSimpleResponses=true nests context under authorizer.lambda
25
+ const authorizer = req.apiGateway?.event?.requestContext?.authorizer;
26
+ const lambdaContext = authorizer?.lambda;
27
+ const authorizerContext = lambdaContext || authorizer;
25
28
  // 2. Fall back to x-authorizer-* headers (test/development)
26
29
  const headers = req.headers;
27
30
  const tenantId = authorizerContext?.tenantId || headers['x-authorizer-tenant-id'];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valentine-efagene/qshelter-common",
3
- "version": "2.0.132",
3
+ "version": "2.0.133",
4
4
  "description": "Shared database schemas and utilities for QShelter services",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",