@tmbill/push-client
v0.3.2
Published
Resilient FCM (Google MCS) receiver: connection state machine, protocol, proxy/IPv6/TLS-inspection aware network layer, registration
Readme
@tmbill/push-client
FCM (Google MCS) push receiver for Node >= 18 and Electron >= 24, built for bad networks: one reconnect state machine
(classified backoff with jitter, endpoint rotation :5228 -> :443, every step bounded), proxy support (env and
system/PAC, HTTP CONNECT), its own happy eyeballs for IPv6, TLS-inspection detection, bounded check-in and registration.
No Electron dependency: the host passes resolveProxy.
const { PushClient, createNetwork } = require('@tmbill/push-client');
const client = new PushClient({
firebase: { apiKey, projectId, messagingSenderId, appId }, // the Firebase WEB config
credentials, // from a previous 'credentials' event; omit to register a new identity
persistentIds, // ids already handled (acknowledged at the next login)
network: createNetwork({ resolveProxy }),
});
client.on('credentials', ({ newCredentials }) => persist(newCredentials));
client.on('notification', ({ message, persistentId }) => {
// throw to keep it unacknowledged (redelivered); throw an error with `holdAck: true` if YOUR storage failed
});
client.on('credentials-rejected', (e) => {}); // Google refuses the identity: re-register (repeats while it lasts)
client.start();
client.setOnline(false); // host network hints; reconnectNow() after resume
client.status(); // state, counters, route, last errors (no secrets)Most hosts should use @tmbill/push-service, which adds the
durable outbox, dedupe, health monitoring and lossless credential rotation on top.
Contains code derived from MIT-licensed work; see lib/vendor/LICENSE and lib/vendor/NOTICE.md.
