@tmbill/push-service
v0.3.2
Published
Host-agnostic push service on top of @tmbill/push-client: durable outbox, ack, dedupe, health monitor, lossless credential rotation
Readme
@tmbill/push-service
Host-agnostic push service on top of @tmbill/push-client:
- one
ingest()seam for every transport: dedupe, a durable outbox written before the acknowledgement to Google, delivery to the renderer and replay until the renderer confirms; - health monitoring (probes through the host's backend) and lossless credential rotation (the old identity keeps receiving until the new one is proven end to end);
- everything injected by the host: settings store, renderer, backend calls, proxy resolution.
const { PushService } = require('@tmbill/push-service');
const service = new PushService({
store, // getSync() = whole settings object, getSync(key), setSync(object) replaces it, setSync(key, value)
firebase, // Firebase WEB config
getWebContents: () => mainWindow && mainWindow.webContents,
channels: { received: 'PUSH_RECEIVED' }, // renderer gets (message, entryId) and calls back ackFromRenderer(entryId)
log, // {info, warn, error, debug}
requestSubscribe: ({ token, replaces }) => backend.subscribe(token, replaces), // optional, enables rotation
requestSelfTest: ({ token, nonce }) => backend.selfTest(token, nonce), // optional, enables rotation/health
resolveProxy: (url) => session.defaultSession.resolveProxy(url),
});
service.on('token', (token) => {}); // tell the backend / renderer
service.start();
service.onRendererReady(); // after every renderer (re)load: replays unconfirmed notifications
service.ackFromRenderer(entryId);
service.status(); // GET_FCM_STATUS: connection, outbox, credentials age, rotation, health (no secrets)