@govish/shared-services 1.3.0 → 1.5.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## Version 1.5.1
4
+
5
+ ### Fixed
6
+ - **AuditService**: Fixed `microservice` field in audit logs to always use the receiving service name from `SERVER_NAME` environment variable instead of the API key's microservice. The `source_microservice` and `authenticated_microservice` fields now correctly contain the API key's microservice information.
7
+
8
+ ---
9
+
10
+ ## Version 1.4.0
11
+
12
+ ### Changed
13
+ - **StationDutyBlockCacheService**: Fetching data only (read-only). Get methods: `getBlocks`, `getBlocksByStationId`, `getBlock`, `getSectors`, `getSector`. App remains responsible for storing and invalidating cache.
14
+
15
+ ---
16
+
3
17
  ## Version 1.3.0
4
18
 
5
19
  ### Added
package/README.md CHANGED
@@ -29,7 +29,7 @@ const authenticateDeviceOrOfficer = createAuthenticateDeviceOrOfficer(dependenci
29
29
  - **PenalCodeCacheService**: Redis-based caching service for penal codes
30
30
  - **DeviceCacheService**: Redis-based caching service for devices with indexing
31
31
  - **StationCacheService**: Redis-based caching service for police stations (JSON list, set of IDs, and per-station hashes)
32
- - **StationDutyBlockCacheService**: Read-only cache for station-duty blocks and sectors (`getBlocks`, `getBlocksByStationId`, `getBlock`, `getSectors`, `getSector`)
32
+ - **StationDutyBlockCacheService**: Read-only cache for station-duty blocks and sectors — fetch only (`getBlocks`, `getBlocksByStationId`, `getBlock`, `getSectors`, `getSector`)
33
33
  - **RankLeaveDaysCacheService**: Read-only cache for rank leave days (`getLeaveDays`, `getLeaveDay`)
34
34
  - **ApiKeyService**: Service for managing and validating API keys with Redis caching
35
35
  - **AuditService**: Service for logging audit events to Kafka with comprehensive event tracking
@@ -1,7 +1,7 @@
1
1
  import { Request, Response, NextFunction } from 'express';
2
2
  import { SharedServicesDependencies } from '../types/dependencies';
3
3
  /**
4
- * Middleware to authenticate either a device, an officer, or a microservice (via API key)
4
+ * Middleware to authenticate either a device, an officer, a microservice (via API key), or combinations thereof
5
5
  * Checks JWT token and validates against Device or Officer table
6
6
  * Also checks for API keys for microservice authentication
7
7
  *
@@ -10,6 +10,17 @@ import { SharedServicesDependencies } from '../types/dependencies';
10
10
  * - Device-Token: <device_jwt_token> (for device authentication)
11
11
  * - Authorization: Bearer <user_jwt_token> (for officer/user authentication)
12
12
  *
13
- * Priority: API Key > Device Token > Authorization Token
13
+ * Supports combined authentication:
14
+ * - API Key + Officer: X-API-Key + Authorization header (sets authType: 'api_key_and_officer')
15
+ * - Device + Officer: Device-Token + Authorization header (sets authType: 'both')
16
+ *
17
+ * Authentication Priority/Combination Logic:
18
+ * 1. API Key + Officer (if both headers present) -> authType: 'api_key_and_officer'
19
+ * 2. API Key only (if only X-API-Key present) -> authType: 'api_key'
20
+ * 3. Device + Officer (if both headers present) -> authType: 'both'
21
+ * 4. Device only (if only Device-Token present) -> authType: 'device'
22
+ * 5. Officer only (if only Authorization present) -> authType: 'officer'
23
+ *
24
+ * At least one authentication method must succeed for the request to proceed.
14
25
  */
15
26
  export declare const createAuthenticateDeviceOrOfficer: (deps: SharedServicesDependencies) => (req: Request, res: Response, next: NextFunction) => Promise<void | Response<any, Record<string, any>>>;