feat: add webchat pwa push subscription support

This commit is contained in:
William Valentin
2026-02-18 10:46:55 -08:00
parent 02fa604c7c
commit 8234cc93f3
17 changed files with 743 additions and 2 deletions
+23
View File
@@ -147,6 +147,13 @@ describe('configSchema — server', () => {
expect(result.server.nodes.push.enabled).toBe(false);
});
it('defaults webchat push settings', () => {
const result = configSchema.parse(minimalConfig);
expect(result.server.webchat_push.enabled).toBe(false);
expect(result.server.webchat_push.vapid_public_key).toBeUndefined();
expect(result.server.webchat_push.max_subscriptions).toBe(5000);
});
it('accepts custom node policy settings', () => {
const result = configSchema.parse({
...minimalConfig,
@@ -194,6 +201,22 @@ describe('configSchema — server', () => {
expect(result.server.discovery.service_type).toBe('_custom._tcp');
expect(result.server.discovery.txt).toEqual({ env: 'dev' });
});
it('accepts custom webchat push settings', () => {
const result = configSchema.parse({
...minimalConfig,
server: {
webchat_push: {
enabled: true,
vapid_public_key: 'BOrSAMPLEPUBLICKEY____',
max_subscriptions: 42,
},
},
});
expect(result.server.webchat_push.enabled).toBe(true);
expect(result.server.webchat_push.vapid_public_key).toBe('BOrSAMPLEPUBLICKEY____');
expect(result.server.webchat_push.max_subscriptions).toBe(42);
});
});
describe('configSchema — browser', () => {
+11
View File
@@ -79,6 +79,15 @@ const serverDiscoverySchema = z.object({
txt: z.record(z.string(), z.string()).default({}),
}).default({});
const serverWebchatPushSchema = z.object({
/** Enable WebChat web-push subscription endpoints and PWA metadata. */
enabled: z.boolean().default(false),
/** VAPID public key used by browser PushManager.subscribe(). */
vapid_public_key: z.string().optional(),
/** Soft cap for stored web-push subscriptions. */
max_subscriptions: z.number().min(1).max(50_000).default(5000),
}).default({});
const serverNodePolicySchema = z.object({
/** Enable node registration/capability RPC surface. */
enabled: z.boolean().default(false),
@@ -118,6 +127,8 @@ const serverSchema = z.object({
queue: laneQueueSchema,
/** Optional companion-node registration/capability settings. */
nodes: serverNodePolicySchema,
/** Optional WebChat PWA push-subscription settings. */
webchat_push: serverWebchatPushSchema,
/** Optional Bonjour/mDNS advertisement settings. */
discovery: serverDiscoverySchema,
});