mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-21 16:34:47 +00:00
fix(push): use valid default VAPID subject (#83317)
This commit is contained in:
@@ -215,7 +215,7 @@ Override the VAPID keypair through env vars on the Gateway process when you want
|
||||
|
||||
- `OPENCLAW_VAPID_PUBLIC_KEY`
|
||||
- `OPENCLAW_VAPID_PRIVATE_KEY`
|
||||
- `OPENCLAW_VAPID_SUBJECT` (defaults to `mailto:openclaw@localhost`)
|
||||
- `OPENCLAW_VAPID_SUBJECT` (defaults to `https://openclaw.ai`)
|
||||
|
||||
The Control UI uses these scope-gated Gateway methods to register and test browser subscriptions:
|
||||
|
||||
|
||||
@@ -58,7 +58,11 @@ describe("resolveVapidKeys", () => {
|
||||
const keys = await resolveVapidKeys(tmpDir);
|
||||
expect(keys.publicKey).toBe("test-public-key-base64url");
|
||||
expect(keys.privateKey).toBe("test-private-key-base64url");
|
||||
expect(keys.subject).toMatch(/^mailto:/);
|
||||
expect(keys.subject).toBe("https://openclaw.ai");
|
||||
const persistedKeys = JSON.parse(
|
||||
await fs.readFile(path.join(tmpDir, "push", "vapid-keys.json"), "utf8"),
|
||||
) as { subject?: string };
|
||||
expect(persistedKeys.subject).toBe("https://openclaw.ai");
|
||||
|
||||
// Second call returns same keys.
|
||||
const keys2 = await resolveVapidKeys(tmpDir);
|
||||
@@ -211,7 +215,7 @@ describe("sending", () => {
|
||||
expect(result.ok).toBe(true);
|
||||
expect(vi.mocked(webPush.setVapidDetails)).toHaveBeenCalledTimes(1);
|
||||
expect(vi.mocked(webPush.setVapidDetails)).toHaveBeenCalledWith(
|
||||
"mailto:openclaw@localhost",
|
||||
"https://openclaw.ai",
|
||||
"test-public-key-base64url",
|
||||
"test-private-key-base64url",
|
||||
);
|
||||
|
||||
@@ -36,7 +36,7 @@ const WEB_PUSH_STATE_FILENAME = "push/web-push-subscriptions.json";
|
||||
const VAPID_KEYS_FILENAME = "push/vapid-keys.json";
|
||||
const MAX_ENDPOINT_LENGTH = 2048;
|
||||
const MAX_KEY_LENGTH = 512;
|
||||
const DEFAULT_VAPID_SUBJECT = "mailto:openclaw@localhost";
|
||||
const DEFAULT_VAPID_SUBJECT = "https://openclaw.ai";
|
||||
|
||||
const withLock = createAsyncLock();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user