mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 18:10:06 -05:00
Member Settings / Notification Settings / "Browser notifications on this device": the browser asks for permission and gives a push subscription, and from then on every notification the member gets in WeKan - the same recipients, watching and muted kinds as the tray and e-mail - also pops up from that browser even with WeKan closed; a click opens the card. Turn it on per browser and device, up to ten per account. web-push 3.6.7 (pinned) sends it with this WeKan's own VAPID key pair, made once and kept in a server-only collection; only the public key leaves the server. A subscription's endpoint is chosen by the browser and POSTed to by the server, so it is accepted only over https and only at the push services browsers use - an internal address or another site is refused when saved and again before every send. Gone subscriptions are forgotten. The service worker opens only paths of this WeKan. Not offered on Sandstorm. models/lib/webPush.js decides; tests/webPush.test.cjs covers the push services, internal and look-alike hosts, foreign click targets and the bound; server/lib/tests/webPush.tests.js runs in Meteor (passing): one key pair, only the public key out, an internal endpoint refused. With the webhook activity picker (c3321926ab) and the all-boards activity feed (656af74b2c), this completes both issues. The new strings are English placeholders until the next translation pass. Thanks to saurabharch, hingerl and xet7 ! Fixes #2026, Fixes #1377.
25 lines
1.1 KiB
JavaScript
25 lines
1.1 KiB
JavaScript
/* eslint-env mocha */
|
|
// #2026 / #1377: web-push loads in Meteor, VAPID keys are made once, and a
|
|
// subscription to anything but a browser push service is refused.
|
|
import { Meteor } from 'meteor/meteor';
|
|
import { expect } from 'chai';
|
|
|
|
describe('webPush (runtime)', function () {
|
|
it('makes one VAPID key pair and gives out only the public key', async function () {
|
|
const call = name => Meteor.server.method_handlers[name].call({ userId: 'runtime-test-user' });
|
|
const first = await call('webPushPublicKey');
|
|
const second = await call('webPushPublicKey');
|
|
expect(first).to.be.a('string').with.length.greaterThan(40);
|
|
expect(second).to.equal(first);
|
|
});
|
|
|
|
it('refuses a subscription to an internal address', async function () {
|
|
let error;
|
|
try {
|
|
await Meteor.server.method_handlers.webPushSubscribe.call({ userId: 'runtime-test-user' },
|
|
{ endpoint: 'https://127.0.0.1/x', keys: { p256dh: 'aaaaaaaaaaaa', auth: 'bbbbbbbbbbbb' } });
|
|
} catch (e) { error = e; }
|
|
expect(error && error.error).to.equal('web-push-invalid-subscription');
|
|
});
|
|
});
|