mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 22:08:26 +00:00
Add explicit ownerDisplaySecret for owner ID hash obfuscation (#22520)
* feat(config): add owner display secret setting * feat(prompt): add explicit owner hash secret to obfuscation path * test(prompt): assert owner hash secret mode behavior * Update src/agents/system-prompt.ts Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --------- Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
This commit is contained in:
@@ -16,6 +16,45 @@ describe("buildAgentSystemPrompt", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("hashes owner numbers when ownerDisplay is hash", () => {
|
||||
const prompt = buildAgentSystemPrompt({
|
||||
workspaceDir: "/tmp/openclaw",
|
||||
ownerNumbers: ["+123", "+456", ""],
|
||||
ownerDisplay: "hash",
|
||||
});
|
||||
|
||||
expect(prompt).toContain("## Authorized Senders");
|
||||
expect(prompt).toContain("Authorized senders:");
|
||||
expect(prompt).not.toContain("+123");
|
||||
expect(prompt).not.toContain("+456");
|
||||
expect(prompt).toMatch(/[a-f0-9]{12}/);
|
||||
});
|
||||
|
||||
it("uses a stable, keyed HMAC when ownerDisplaySecret is provided", () => {
|
||||
const secretA = buildAgentSystemPrompt({
|
||||
workspaceDir: "/tmp/openclaw",
|
||||
ownerNumbers: ["+123"],
|
||||
ownerDisplay: "hash",
|
||||
ownerDisplaySecret: "secret-key-A",
|
||||
});
|
||||
|
||||
const secretB = buildAgentSystemPrompt({
|
||||
workspaceDir: "/tmp/openclaw",
|
||||
ownerNumbers: ["+123"],
|
||||
ownerDisplay: "hash",
|
||||
ownerDisplaySecret: "secret-key-B",
|
||||
});
|
||||
|
||||
const lineA = secretA.split("## Authorized Senders")[1]?.split("\n")[1];
|
||||
const lineB = secretB.split("## Authorized Senders")[1]?.split("\n")[1];
|
||||
const tokenA = lineA?.match(/[a-f0-9]{12}/)?.[0];
|
||||
const tokenB = lineB?.match(/[a-f0-9]{12}/)?.[0];
|
||||
|
||||
expect(tokenA).toBeDefined();
|
||||
expect(tokenB).toBeDefined();
|
||||
expect(tokenA).not.toBe(tokenB);
|
||||
});
|
||||
|
||||
it("omits owner section when numbers are missing", () => {
|
||||
const prompt = buildAgentSystemPrompt({
|
||||
workspaceDir: "/tmp/openclaw",
|
||||
|
||||
Reference in New Issue
Block a user