mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 23:51:23 +00:00
refactor(exec-approvals): share socket default merge
This commit is contained in:
@@ -241,6 +241,24 @@ export function normalizeExecApprovals(file: ExecApprovalsFile): ExecApprovalsFi
|
||||
return normalized;
|
||||
}
|
||||
|
||||
export function mergeExecApprovalsSocketDefaults(params: {
|
||||
normalized: ExecApprovalsFile;
|
||||
current?: ExecApprovalsFile;
|
||||
}): ExecApprovalsFile {
|
||||
const currentSocketPath = params.current?.socket?.path?.trim();
|
||||
const currentToken = params.current?.socket?.token?.trim();
|
||||
const socketPath =
|
||||
params.normalized.socket?.path?.trim() ?? currentSocketPath ?? resolveExecApprovalsSocketPath();
|
||||
const token = params.normalized.socket?.token?.trim() ?? currentToken ?? "";
|
||||
return {
|
||||
...params.normalized,
|
||||
socket: {
|
||||
path: socketPath,
|
||||
token,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function generateToken(): string {
|
||||
return crypto.randomBytes(24).toString("base64url");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user