import type { ChargingStation } from '../../../../charging-station/index.js'
+import type { JsonObject } from '../../../../types/index.js'
import type { OCPPAuthAdapter } from '../interfaces/OCPPAuthService.js'
import type {
AuthConfiguration,
* Handles authentication for OCPP 1.6 charging stations by translating
* between unified auth types and OCPP 1.6 specific types and protocols.
*/
-export class OCPP16AuthAdapter implements OCPPAuthAdapter {
+export class OCPP16AuthAdapter implements OCPPAuthAdapter<string> {
readonly ocppVersion = OCPPVersion.VERSION_16
constructor (private readonly chargingStation: ChargingStation) {}
* Get OCPP 1.6 specific configuration schema
* @returns JSON schema object describing valid OCPP 1.6 auth configuration properties
*/
- getConfigurationSchema (): Record<string, unknown> {
+ getConfigurationSchema (): JsonObject {
return {
properties: {
allowOfflineTxForUnknownId: {
* Get adapter-specific status information
* @returns Status object with online state, auth settings, and station identifier
*/
- getStatus (): Record<string, unknown> {
+ getStatus (): JsonObject {
return {
isOnline: this.chargingStation.inAcceptedState(),
localAuthEnabled: this.chargingStation.getLocalAuthListEnabled(),
import type {
AdditionalInfoType,
+ JsonObject,
OCPP20AuthorizeRequest,
OCPP20AuthorizeResponse,
RequestStartStopStatusEnumType,
* Get OCPP 2.0 specific configuration schema
* @returns Configuration schema object for OCPP 2.0 authorization settings
*/
- getConfigurationSchema (): Record<string, unknown> {
+ getConfigurationSchema (): JsonObject {
return {
properties: {
authCacheEnabled: {
* Get adapter-specific status information
* @returns Status object containing adapter state and capabilities
*/
- getStatus (): Record<string, unknown> {
+ getStatus (): JsonObject {
return {
isOnline: this.chargingStation.inAcceptedState(),
localAuthEnabled: true, // Configuration dependent
-import type { OCPP20IdTokenInfoType, OCPPVersion } from '../../../../types/index.js'
+import type {
+ JsonObject,
+ OCPP20IdTokenInfoType,
+ OCPP20IdTokenType,
+ OCPPVersion,
+} from '../../../../types/index.js'
import type {
AuthConfiguration,
AuthorizationResult,
/**
* Get strategy-specific statistics
*/
- getStats(): Promise<Record<string, unknown>> | Record<string, unknown>
+ getStats(): JsonObject | Promise<JsonObject>
/**
* Initialize the strategy with configuration
readonly priority: number
}
-export interface CacheStats {
+export interface CacheStats extends JsonObject {
/** Number of entries evicted due to capacity limits */
evictions: number
* Adapters handle the translation between unified auth types
* and version-specific OCPP types and protocols.
*/
-export interface OCPPAuthAdapter {
+export interface OCPPAuthAdapter<TVersionId = OCPP20IdTokenType | string> {
/**
* Perform remote authorization using version-specific protocol
* @param identifier - Unified identifier to authorize
* @param identifier - Unified identifier
* @returns Version-specific identifier
*/
- convertFromUnifiedIdentifier(identifier: UnifiedIdentifier): object | string
+ convertFromUnifiedIdentifier(identifier: UnifiedIdentifier): TVersionId
/**
* Convert a version-specific identifier to unified format
* @returns Unified identifier
*/
convertToUnifiedIdentifier(
- identifier: object | string,
+ identifier: TVersionId,
additionalData?: Record<string, unknown>
): UnifiedIdentifier
/**
* Get adapter-specific configuration requirements
*/
- getConfigurationSchema(): Record<string, unknown>
+ getConfigurationSchema(): JsonObject
/**
* Check if remote authorization is available
+import type { JsonObject } from '../../../../types/index.js'
import type { ChargingStation } from '../../../ChargingStation.js'
import type { AuthStrategy, OCPPAuthAdapter } from '../interfaces/OCPPAuthService.js'
import type {
logger.debug(`${moduleName}: Certificate authentication strategy cleaned up`)
}
- getStats (): Record<string, unknown> {
+ getStats (): JsonObject {
return {
...this.stats,
isInitialized: this.isInitialized,
+import type { JsonObject } from '../../../../types/index.js'
import type {
AuthCache,
AuthStrategy,
* Get strategy statistics
* @returns Strategy statistics including hit rates, request counts, and cache status
*/
- public getStats (): Record<string, unknown> {
+ public getStats (): JsonObject {
const cacheStats = this.authCache ? this.authCache.getStats() : null
return {
+import type { JsonObject } from '../../../../types/index.js'
import type {
AuthCache,
AuthStrategy,
* Get strategy statistics
* @returns Strategy statistics including success rates, response times, and error counts
*/
- public async getStats (): Promise<Record<string, unknown>> {
+ public async getStats (): Promise<JsonObject> {
const cacheStats = this.authCache ? this.authCache.getStats() : null
let adapterAvailable = false
type UnifiedIdentifier,
} from '../../../../../src/charging-station/ocpp/auth/types/AuthTypes.js'
import { OCPPVersion } from '../../../../../src/types/index.js'
+import { OCPP20IdTokenEnumType, type OCPP20IdTokenType } from '../../../../../src/types/index.js'
/**
* Factory functions for creating test mocks and fixtures
convertFromUnifiedIdentifier: (identifier: UnifiedIdentifier) =>
ocppVersion === OCPPVersion.VERSION_16
? identifier.value
- : { idToken: identifier.value, type: identifier.type },
- convertToUnifiedIdentifier: (identifier: object | string) => ({
+ : { idToken: identifier.value, type: OCPP20IdTokenEnumType.Central },
+ convertToUnifiedIdentifier: (identifier: OCPP20IdTokenType | string) => ({
type: IdentifierType.ID_TAG,
- value:
- typeof identifier === 'string'
- ? identifier
- : ((identifier as { idToken?: string }).idToken ?? 'unknown'),
+ value: typeof identifier === 'string' ? identifier : identifier.idToken,
}),
getConfigurationSchema: () => ({}),
isRemoteAvailable: () => true,