Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@launchdarkly/js-server-sdk-common
Advanced tools
LaunchDarkly Server SDK for JavaScript - common code
@launchdarkly/js-server-sdk-common is a common library for LaunchDarkly's JavaScript server-side SDKs. It provides core functionality for feature flag evaluation, user targeting, and other feature management capabilities.
Feature Flag Evaluation
This feature allows you to evaluate feature flags for a given user. The code sample demonstrates how to initialize the client, wait for it to be ready, and then evaluate a feature flag for a specific user.
const { LDClient } = require('@launchdarkly/js-server-sdk-common');
const client = new LDClient('YOUR_SDK_KEY');
client.on('ready', () => {
const user = { key: 'user123' };
const showFeature = client.variation('your-feature-flag-key', user, false);
console.log(`Feature flag value: ${showFeature}`);
});
User Targeting
This feature allows you to target specific users based on their attributes. The code sample shows how to include user attributes like email in the evaluation process.
const { LDClient } = require('@launchdarkly/js-server-sdk-common');
const client = new LDClient('YOUR_SDK_KEY');
client.on('ready', () => {
const user = { key: 'user123', email: 'user@example.com' };
const showFeature = client.variation('your-feature-flag-key', user, false);
console.log(`Feature flag value for user: ${showFeature}`);
});
Event Tracking
This feature allows you to track custom events for analytics and reporting. The code sample demonstrates how to track a custom event for a specific user.
const { LDClient } = require('@launchdarkly/js-server-sdk-common');
const client = new LDClient('YOUR_SDK_KEY');
client.on('ready', () => {
const user = { key: 'user123' };
client.track('custom-event', user, { key: 'value' });
console.log('Custom event tracked');
});
Flagr is an open-source feature flagging and A/B testing tool. The flagr package provides feature flag evaluation and user targeting functionalities. It is comparable to @launchdarkly/js-server-sdk-common but is open-source and can be customized to fit specific needs.
This project contains Typescript classes and interfaces that are applicable to server-side SDKs.
See Contributing.
LaunchDarkly uses the SLSA framework (Supply-chain Levels for Software Artifacts) to help developers make their supply chain more secure by ensuring the authenticity and build integrity of our published SDK packages. To learn more, see the provenance guide.
FAQs
LaunchDarkly Server SDK for JavaScript - common code
The npm package @launchdarkly/js-server-sdk-common receives a total of 555,173 weekly downloads. As such, @launchdarkly/js-server-sdk-common popularity was classified as popular.
We found that @launchdarkly/js-server-sdk-common demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.