Skip to content

Commit 5bec006

Browse files
committed
fix(push): use valid default VAPID subject
1 parent 691d626 commit 5bec006

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

docs/web/control-ui.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ Override the VAPID keypair through env vars on the Gateway process when you want
215215

216216
- `OPENCLAW_VAPID_PUBLIC_KEY`
217217
- `OPENCLAW_VAPID_PRIVATE_KEY`
218-
- `OPENCLAW_VAPID_SUBJECT` (defaults to `mailto:openclaw@localhost`)
218+
- `OPENCLAW_VAPID_SUBJECT` (defaults to `https://openclaw.ai`)
219219

220220
The Control UI uses these scope-gated Gateway methods to register and test browser subscriptions:
221221

src/infra/push-web.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,11 @@ describe("resolveVapidKeys", () => {
5858
const keys = await resolveVapidKeys(tmpDir);
5959
expect(keys.publicKey).toBe("test-public-key-base64url");
6060
expect(keys.privateKey).toBe("test-private-key-base64url");
61-
expect(keys.subject).toMatch(/^mailto:/);
61+
expect(keys.subject).toBe("https://openclaw.ai");
62+
const persistedKeys = JSON.parse(
63+
await fs.readFile(path.join(tmpDir, "push", "vapid-keys.json"), "utf8"),
64+
) as { subject?: string };
65+
expect(persistedKeys.subject).toBe("https://openclaw.ai");
6266

6367
// Second call returns same keys.
6468
const keys2 = await resolveVapidKeys(tmpDir);
@@ -211,7 +215,7 @@ describe("sending", () => {
211215
expect(result.ok).toBe(true);
212216
expect(vi.mocked(webPush.setVapidDetails)).toHaveBeenCalledTimes(1);
213217
expect(vi.mocked(webPush.setVapidDetails)).toHaveBeenCalledWith(
214-
"mailto:openclaw@localhost",
218+
"https://openclaw.ai",
215219
"test-public-key-base64url",
216220
"test-private-key-base64url",
217221
);

src/infra/push-web.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const WEB_PUSH_STATE_FILENAME = "push/web-push-subscriptions.json";
3636
const VAPID_KEYS_FILENAME = "push/vapid-keys.json";
3737
const MAX_ENDPOINT_LENGTH = 2048;
3838
const MAX_KEY_LENGTH = 512;
39-
const DEFAULT_VAPID_SUBJECT = "mailto:openclaw@localhost";
39+
const DEFAULT_VAPID_SUBJECT = "https://openclaw.ai";
4040

4141
const withLock = createAsyncLock();
4242

0 commit comments

Comments
 (0)