mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-07 10:59:57 +00:00
fix: harden device pairing token generation and verification
Improved token generation in newToken() and added timing-safe token comparison in verifyDeviceToken() following the existing pattern from gateway auth.
This commit is contained in:
committed by
Gustavo Madeira Santana
parent
b97191b81a
commit
37c4db02ab
@@ -1,4 +1,4 @@
|
||||
import { randomUUID } from "node:crypto";
|
||||
import { randomUUID, randomBytes } from "node:crypto";
|
||||
import { safeEqualSecret } from "../security/secret-equal.js";
|
||||
import {
|
||||
createAsyncLock,
|
||||
@@ -176,7 +176,7 @@ function scopesAllow(requested: string[], allowed: string[]): boolean {
|
||||
}
|
||||
|
||||
function newToken() {
|
||||
return randomUUID().replaceAll("-", "");
|
||||
return randomBytes(32).toString("base64url");
|
||||
}
|
||||
|
||||
export async function listDevicePairing(baseDir?: string): Promise<DevicePairingList> {
|
||||
|
||||
Reference in New Issue
Block a user