diff --git a/src/helpers/signature.ts b/src/helpers/signature.ts index ba5eb46..4f1981d 100644 --- a/src/helpers/signature.ts +++ b/src/helpers/signature.ts @@ -143,3 +143,38 @@ export function verify(data: unknown, signature: string, secretKey?: string): bo return false } } + +// console.table([ +// { act: 'command', signature: sign( +// { +// merchantName: 'SAVY', +// floorName: 'L2', +// unitNumber: '01', +// deviceName: 'AC', +// roomName: 'LV', +// deviceType: 'S', +// commandType: 'C', +// towerNumber: 'T1', +// timestamp: '2025-10-21T04:00:10.673Z', +// nonce: '50ce476cd1c355ae552ae18be55af72c', +// payload: { +// action: 'AC=On', +// }, +// }, 'e3faa00e170884b3adc6c37253ec97e9') }, +// { +// act: 'state', +// signature: sign({ +// merchantName: 'SAVY', +// floorName: 'L2', +// unitNumber: '01', +// deviceName: 'AC', +// roomName: 'LV', +// deviceType: 'S', +// commandType: 'S', +// towerNumber: 'T1', +// timestamp: '2025-10-21T04:00:10.673Z', +// nonce: '50ce476cd1c355ae552ae18be55af72c', +// }, 'e3faa00e170884b3adc6c37253ec97e9'), +// }, +// ], +// ['act', 'signature']) diff --git a/src/modules/device/schema.ts b/src/modules/device/schema.ts index 580ae76..703f7d9 100644 --- a/src/modules/device/schema.ts +++ b/src/modules/device/schema.ts @@ -13,8 +13,7 @@ export const deviceCommandBody = z.object({ timestamp: z.string().datetime(), // ISO8601 nonce: z.string(), payload: z.object({ - action: z.enum(['on', 'off', 'set']), - temp: z.number().optional(), + action: z.string(), }), signature: z.string(), }) diff --git a/src/plugins/swagger.ts b/src/plugins/swagger.ts index d3ce30d..b2e75f7 100644 --- a/src/plugins/swagger.ts +++ b/src/plugins/swagger.ts @@ -7,7 +7,7 @@ type OpenApiDocumentation = Omit