Merge branch 'main' of gitlab.com:skyrainstudioindonesia-group/vega-cloud

This commit is contained in:
2025-12-08 18:53:38 +07:00
2 changed files with 5 additions and 2 deletions
+3 -2
View File
@@ -103,7 +103,7 @@ export function canonicalizeObject<T = unknown>(data: T): unknown {
* @returns The canonical JSON string.
*/
export function canonicalize(data: unknown, timestamp: number, nonce: string): string {
const body = canonicalizeObject(data)
const body = JSON.stringify(canonicalizeObject(data))
return JSON.stringify({
timestamp,
nonce,
@@ -119,8 +119,9 @@ export function canonicalize(data: unknown, timestamp: number, nonce: string): s
* @returns The signature.
*/
export function sign(data: unknown, timestamp: number, nonce: string, secretKey: string): string {
const canned = canonicalize(data, timestamp, nonce)
return createHmac('sha256', secretKey)
.update(canonicalize(data, timestamp, nonce), 'utf8')
.update(canned, 'utf8')
.digest('hex')
}
+2
View File
@@ -19,6 +19,7 @@ export const router = new Elysia({
}
return result
}, {
verifyKey: true,
body: deviceCommandBody,
response: deviceCommandResponseSchema,
detail: {
@@ -49,6 +50,7 @@ export const router = new Elysia({
return { status: 'internal_error', message: 'Server error' }
}
}, {
verifyKey: true,
query: deviceQueryParams,
response: deviceQueryResponseSchema,
detail: {