Security News
cURL Project and Go Security Teams Reject CVSS as Broken
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
connectivity-monitor
Advanced tools
When creating applications that need to handle spotty connectivity or work offline, it is useful to have a way to check the connectivity and also monitor when the device connectivity changes.
// Try to fetch user session, and if it fails because of connectivity, fetch from storage instead
try {
const response = await fetch('/user-session/');
return await response.json();
} catch (error) {
if (await connectivityMonitor.getConnectionStatus() === 'disconnected') {
return localStorage['/user-session/'];
} else {
throw error;
}
}
// Monitor connectivity and warn the user when offline
connectivityMonitor.listen((connectivityStatus) => {
if (connectivityStatus === 'disconnected') {
window.alert('Warning: your device is currently offline, so any changes will not be saved!');
}
});
The ConnectivityMonitor
implementation leverages window.navigator.online
, and will also call an API operation you provide to verify connectivity whenever the connectivity status changes or getConnectionStatus
is called.
const connectivityMonitor = new ConnectivityMonitor(serviceProxy, '/connectivity-test/');
The MockConnectivityMonitor
implementation is useful for testing and when running your app with mock data and mock services. It does not actually check connectivity, and instead relies on the connectivity status to be set manually via its setConnectionStatus
method.
const connectivityMonitor = new ConnectivityMonitor(serviceProxy);
connectivityMonitor.setConnectionStatus('connected');
connectivityMonitor.setConnectionStatus('disconnected');
FAQs
Handle browser connectivity events
We found that connectivity-monitor demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.