Files
adam-acs/app/domain/device/device_id.ts
T
Kevin L'Hereec f3eb8e1650 feat: restore strong typing on TR-069/CWMP protocol layer
- Copy cwmp-1-0..4.ts source classes from cwmp-connector (papaye) into
  app/protocol/ as local files (ts-nocheck, external dependency)
- Add soap_envelope.ts: SoapEnvelope, SoapEnvelopeHeader, CwmpID, NAMESPACES
- Add tr069_types.ts: re-exports all CWMP classes + CwmpMessage discriminated
  union + typed task payload interfaces (CWMPTaskType, CWMPTaskPayload, etc.)
- Rewrite cwmp_message_builder.ts to use class-based builders instead of raw
  XML template strings; add transferCompleteResponse() and soapFault()
- soap.ts: extractCwmpMessage returns CwmpMessage union, adds runtime allowlist
  guard against unknown CWMP method names from CPE
- cwmp_middleware.ts: envelope typed SoapEnvelope|null, message CwmpMessage|null
- cwmp_controller.ts: handleInform(informData: Inform), remove any, migrate
  TransferComplete and fault to new builder path, drop buildSoapEnvelope import
- task_queue.ts: CWMPTask.type → CWMPTaskType literal union, payload →
  CWMPTaskPayload, result → CWMPTaskResultData
- device_action_executor.ts: GPV/GPN/GPA responses typed, no more any
- main_state_machine.ts: DeviceContext.message.data → CWMPTaskResultData,
  organizeParameters receives ParameterInfoStruct[] directly
- device.ts: tmpParamValues typed ParameterValueStruct[], organizeParameters
  signature updated, updateFromValues typed
- device_id.ts: fromInform typed with DeviceIdStruct
- soap_envelope.ts: remove unconditional <cwmp:noMoreRequests> header
  (CPE→ACS only per TR-069 §3.7.1.4)
2026-07-20 15:25:26 +02:00

46 lines
1.2 KiB
TypeScript

export class DeviceId {
constructor(
public readonly manufacturer: string,
public readonly oui: string,
public readonly productClass: string,
public readonly serialNumber: string
) {
this.validate()
}
private validate(): void {
if (!this.manufacturer?.trim()) {
throw new Error('Manufacturer is required')
}
if (!this.serialNumber?.trim()) {
throw new Error('Serial number is required')
}
}
public toIdentifier(): string {
return `${this.manufacturer}-${this.oui}-${this.productClass}-${this.serialNumber}`
}
public equals(other: DeviceId): boolean {
return (
this.manufacturer === other.manufacturer &&
this.oui === other.oui &&
this.productClass === other.productClass &&
this.serialNumber === other.serialNumber
)
}
public static fromInform(informData: { Manufacturer?: string; OUI?: string; ProductClass?: string; SerialNumber?: string }): DeviceId {
return new DeviceId(
String(informData?.Manufacturer ?? ''),
String(informData?.OUI ?? ''),
String(informData?.ProductClass ?? ''),
String(informData?.SerialNumber ?? '')
)
}
public toString(): string {
return this.toIdentifier()
}
}