Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rox-base

Package Overview
Dependencies
Maintainers
6
Versions
89
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rox-base - npm Package Compare versions

Comparing version 1.2.5 to 1.2.7

2

package.json
{
"name": "rox-base",
"version": "1.2.5",
"version": "1.2.7",
"description": "Rollout.io ROX JS SDK Base",

@@ -5,0 +5,0 @@ "author": "Rollout.io <support@rollout.io>",

@@ -12,3 +12,3 @@ import { CustomProperty } from '../entities';

import { RoxLogger, ClassRegister, configurationFetcher } from './';
import { RoxLogger, ClassRegister, ConfigurationFetcher } from './';

@@ -38,3 +38,3 @@ let _deps = {};

this.deviceProperties = _deps.DeviceProperties;
this.configurationFetcher = new ConfigurationFetcher(this.appKey, this.deviceProperties, this.devModeSecret);
_deps

@@ -53,2 +53,3 @@ .getDefaultCustomProperties(this.deviceProperties)

this.distinct_id = _options.distinctId;
this.devModeSecret = _options.devModeSecret;
}

@@ -63,5 +64,3 @@

if (this.fetchIntervalInSec < minimumIntervalInSec) this.fetchIntervalInSec = minimumIntervalInSec;
configurationFetcher.dispatchPeriodically({
appKey: this.app_key,
deviceProperties: this.deviceProperties,
this.configurationFetcher.dispatchPeriodically({
periodTimeInSec: this.fetchIntervalInSec

@@ -91,5 +90,3 @@ });

}
configurationFetcher.dispatch({
appKey: this.app_key,
deviceProperties: this.deviceProperties,
this.configurationFetcher.dispatch({
handler: () => this.syncCompletionHandler && this.syncCompletionHandler(this.metadata),

@@ -96,0 +93,0 @@ options

@@ -19,2 +19,8 @@ import { fetchRemoteConfiguration } from './RequestConfiguration';

class ConfigurationFetcher {
constructor(appKey, deviceProperties, devModeSecret) {
this.appKey = appKey;
this.deviceProperties = deviceProperties;
this.devModeSecret = devModeSecret;
}
get hasCachedConfiguration() {

@@ -32,3 +38,3 @@ const cached = Cache.get(CACHE_KEY);

dispatch({ appKey, deviceProperties, handler, options }) {
dispatch({ handler, options }) {
RoxLogger.debug('Dispatch');

@@ -40,6 +46,3 @@ var useCache = options.useCache;

const networkPromise = this.fetchFromNetwork({
appKey,
deviceProperties
}).then(response => {
const networkPromise = this.fetchFromNetwork().then(response => {
this.storeInCache(response);

@@ -56,3 +59,3 @@ if (shouldProcess) {

dispatchPeriodically({ appKey, deviceProperties, periodTimeInSec }) {
dispatchPeriodically({ periodTimeInSec }) {
if (isdispatchPeriodicallyRuning) {

@@ -67,12 +70,13 @@ RoxLogger.debug('Dispatch Periodically already running');

setInterval(() => {
this.fetchFromNetwork({
appKey,
deviceProperties
}).then(response => this.process(response));
this.fetchFromNetwork().then(response => this.process(response));
}, periodTimeInSec * 1000);
}
fetchFromNetwork({ appKey, deviceProperties }) {
RoxLogger.debug(`fetch from network for appKey ${appKey}`);
const rc = buildRequestConfiguration({ appKey, deviceProperties });
fetchFromNetwork() {
RoxLogger.debug(`fetch from network for appKey ${this.appKey}`);
const rc = buildRequestConfiguration({
appKey: this.appKey,
deviceProperties: this.deviceProperties,
devModeSecret: this.devModeSecret
});
RoxLogger.debug(rc);

@@ -90,5 +94,3 @@ return fetchRemoteConfiguration(rc);

} catch (e) {
RoxLogger.warn(
`Configuration retreived from cache, but has corrupted. Aborting. (Error: ${e})`
);
RoxLogger.warn(`Configuration retreived from cache, but has corrupted. Aborting. (Error: ${e})`);
}

@@ -116,9 +118,9 @@ if (parsed && parsed.constructor === Object) {

parsePayload(response) {
const parser = new ConfigurationParser(response, this.app_key);
const parser = new ConfigurationParser(response, this.appKey);
if (!parser.parse()) {
RoxLogger.debug(
`failed to parse payload. response = ${JSON.stringify(
response
)} deviceProps = ${this.deviceProps} app_key = ${this.app_key}`
`failed to parse payload. response = ${JSON.stringify(response)} deviceProps = ${this
.deviceProperties} app_key = ${this.appKey}`
);
return null;
}

@@ -129,11 +131,11 @@ return parser;

calculatePayload(parser) {
if (!parser) {
return;
}
TargetGroupRepository.setTargetGroups(parser.targetGroups());
ExperimentsRepository.setExperiments(parser.experiments());
new ConfigurationSetter().prepareConfigurations(
parser.remoteConfigurations()
);
new FlagsSetter().prepareFlagsWithExperiments(
parser.experiments()
);
new ConfigurationSetter().prepareConfigurations(parser.remoteConfigurations());
new FlagsSetter().prepareFlagsWithExperiments(parser.experiments());

@@ -144,2 +146,2 @@ return;

export default new ConfigurationFetcher();
export default ConfigurationFetcher;
import * as Overrider from './Overrider';
export { default as configurationFetcher } from './ConfigurationFetcher';
export { default as ConfigurationFetcher } from './ConfigurationFetcher';
export { default as RuntimeRegistry } from './RuntimeRegistry';

@@ -8,2 +8,2 @@ export { default as ClassRegister } from './ClassRegister';

export { default as createRoxClient } from './Client';
export { Overrider };
export { Overrider };

@@ -7,3 +7,3 @@ import Config from '../config';

export const buildRequestConfiguration = function ({appKey, deviceProperties }) {
export const buildRequestConfiguration = function({ appKey, deviceProperties, devModeSecret }) {
const properties = deviceProperties.getProperties();

@@ -13,19 +13,15 @@

properties.feature_flags = JSON.stringify(registry.featureFlags);
properties.feature_flags = JSON.stringify(
registry.featureFlags
);
properties.custom_properties = JSON.stringify(registry.customProperties);
properties.custom_properties = JSON.stringify(
registry.customProperties
);
properties.remoteVariables = JSON.stringify(registry.remoteConfiguration);
properties.remoteVariables = JSON.stringify(
registry.remoteConfiguration
);
properties.buid = BUID.generate(properties);
properties.buid_generators_list = BUID.GENERATOR_LIST.join(',');
properties.cache_miss_url = `${Config.get('CD_S3_ENDPOINT')}${properties.buid}`;
properties.devModeSecret = devModeSecret;
return properties;
}
};

@@ -1,4 +0,4 @@

import ExperimentsParser from './ExperimentsParser'
import TargetGroupsParser from './TargetGroupsParser'
import remoteConfigurationsParser from './RemoteConfigurationsParser'
import ExperimentsParser from './ExperimentsParser';
import TargetGroupsParser from './TargetGroupsParser';
import remoteConfigurationsParser from './RemoteConfigurationsParser';

@@ -11,10 +11,14 @@ const terms = {

REMOTE_CONFIGURATIONS: 'remoteVariables'
}
};
export default class ConfigurationParser {
constructor(json) {
constructor(json, appKey) {
if (!json || typeof json !== 'object') {
throw new Error(`ConfigurationParser should be constructed with JSON object. Recieved ${json}`);
}
if (!appKey || typeof appKey !== 'string') {
throw new Error(`ConfigurationParser should be constructed with app key string. Recieved ${appKey}`);
}
this._json = json;
this._appKey = appKey;
}

@@ -24,6 +28,9 @@

let data = this._extractInnerJson(this._json);
this._parseExperiments(data[terms.EXPERIMENTS]);
if (data[terms.APP_KEY] !== this._appKey) {
return null;
}
this._parseExperiments(data[terms.EXPERIMENTS]);
this._parseTargetGroups(data[terms.TARGET_GROUPS]);
this._parseRemoteConfigurations(data[terms.REMOTE_CONFIGURATIONS]);
return this;

@@ -30,0 +37,0 @@ }

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc