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.
@optimizely/js-sdk-datafile-manager
Advanced tools
@optimizely/js-sdk-datafile-manager is a package designed to manage datafiles for Optimizely's JavaScript SDK. It provides functionalities to fetch, cache, and update datafiles, which are essential for running experiments and feature tests using Optimizely's platform.
Fetching Datafile
This feature allows you to fetch and automatically update the datafile from Optimizely's servers. The datafile is fetched using the provided SDK key, and updates are polled at the specified interval.
const { HttpPollingDatafileManager } = require('@optimizely/js-sdk-datafile-manager');
const datafileManager = new HttpPollingDatafileManager({
sdkKey: 'your-sdk-key',
autoUpdate: true,
updateInterval: 1000 * 60 * 5 // 5 minutes
});
datafileManager.start();
datafileManager.on('update', () => {
const datafile = datafileManager.get();
console.log('Datafile updated:', datafile);
});
Caching Datafile
This feature allows you to use a custom cache for storing the datafile. You can provide custom implementations for the get and set methods to control how the datafile is cached.
const { HttpPollingDatafileManager } = require('@optimizely/js-sdk-datafile-manager');
const datafileManager = new HttpPollingDatafileManager({
sdkKey: 'your-sdk-key',
autoUpdate: true,
cache: {
get: (key) => {/* custom get implementation */},
set: (key, value) => {/* custom set implementation */}
}
});
datafileManager.start();
Handling Datafile Updates
This feature allows you to handle datafile updates by listening to the 'update' event. When the datafile is updated, you can retrieve the latest version and perform any necessary actions.
const { HttpPollingDatafileManager } = require('@optimizely/js-sdk-datafile-manager');
const datafileManager = new HttpPollingDatafileManager({
sdkKey: 'your-sdk-key',
autoUpdate: true
});
datafileManager.start();
datafileManager.on('update', () => {
const datafile = datafileManager.get();
console.log('Datafile updated:', datafile);
});
The 'config' package is used for managing configuration files in Node.js applications. It allows you to load configuration files based on the environment and provides a way to access configuration values. Unlike @optimizely/js-sdk-datafile-manager, it is not specifically designed for managing Optimizely datafiles but can be used for general configuration management.
The 'node-cache' package is a simple in-memory caching module for Node.js. It provides functionalities to set, get, and delete cached values. While it does not specifically handle datafiles or polling, it can be used to implement custom caching logic for datafiles managed by @optimizely/js-sdk-datafile-manager.
The 'axios' package is a popular HTTP client for making requests in Node.js. It can be used to fetch datafiles from Optimizely's servers, but it does not provide built-in support for polling or caching like @optimizely/js-sdk-datafile-manager. You would need to implement these features manually using axios.
This package provides datafile manager implementations for Node.js, browsers, and React Native.
In general, an ES5-compatible environment is required, as well as Promise
(must be polyfilled if absent).
Platform-specific minimum supported versions:
8
0.61.5
npm i @optimizely/js-sdk-datafile-manager
For React Native, installation of peer dependency @react-native-async-storage/async-storage
is also required:
npm i @react-native-async-storage/async-storage
const { HttpPollingDatafileManager } = require('@optimizely/js-sdk-datafile-manager')
const manager = new HttpPollingDatafileManager({
sdkKey: '9LCprAQyd1bs1BBXZ3nVji',
autoUpdate: true,
updateInterval: 5000,
})
manager.start()
manager.onReady().then(() => {
const datafile = manager.get()
console.log('Manager is ready with datafile: ')
console.log(datafile)
})
manager.on('update', ({ datafile }) => {
console.log('New datafile available: ')
console.log(datafile)
})
lint
package.json script runs ESLint and Prettier. This applies formatting and lint fixes to all .ts
files in the src/
directory.test
package.json script runs our Jest-based test suite.tsc
package.json script runs the TypeScript compiler to build the final scripts for publishing (into the lib/
directory).FAQs
Optimizely Full Stack Datafile Manager
We found that @optimizely/js-sdk-datafile-manager 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
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.