Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@firebase/messaging-compat
Advanced tools
The @firebase/messaging-compat package is a compatibility layer for Firebase Cloud Messaging (FCM) that allows developers to use the modern Firebase Messaging API in applications that still rely on the older Firebase JavaScript SDKs. This package enables seamless integration of messaging functionalities in web applications to send and receive messages across platforms efficiently.
Receive messages
This feature allows the application to receive messages sent from the Firebase Console or other backend services. The code sample demonstrates how to set up a listener that triggers whenever a new message is received while the app is in the foreground.
import { getMessaging, onMessage } from '@firebase/messaging-compat';
const messaging = getMessaging();
onMessage(messaging, (payload) => {
console.log('Message received. ', payload);
// handle the received payload
});
Retrieve an instance token
This feature is used to retrieve the current token for the client app instance. A valid VAPID key is required to authenticate the token request. This token is essential for sending messages to the user's device.
import { getMessaging, getToken } from '@firebase/messaging-compat';
const messaging = getMessaging();
getToken(messaging, { vapidKey: 'your-vapid-key' }).then((currentToken) => {
if (currentToken) {
console.log('Token retrieved: ', currentToken);
} else {
console.log('No Instance ID token available. Request permission to generate one.');
}
}).catch((err) => {
console.error('An error occurred while retrieving token. ', err);
});
firebase-messaging is the modern version of Firebase Cloud Messaging integration for web applications. Unlike @firebase/messaging-compat, it is designed for use with the latest Firebase SDKs and supports additional features like background message handling and improved payload management. It is more suitable for new projects that do not require compatibility with older Firebase versions.
push.js is a JavaScript library that allows web developers to send push notifications to users' browsers. It is not tied to Firebase and works with any backend, providing more flexibility in terms of setup and usage. However, it lacks the integrated backend services and analytics provided by Firebase.
This is the compat package that recreates the v8 APIs.
This package is not intended for direct usage, and should only be used via the officially supported firebase package.
FAQs
This is the compat package that recreates the v8 APIs.
We found that @firebase/messaging-compat demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.