Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
},
storage: {
type: 'REDIS'
}
};
// For browser
browserSettings = {
core: {
authorizationKey: 'another-key',
key: 'customer-key'
}
};
// With sync settings should return ISDK, if settings have async storage it should return IAsyncSDK
SDK = SplitFactory(browserSettings);
SDK = SplitFactory(nodeSettings);
AsyncSDK = SplitFactory(asyncSettings);
// The settings values the SDK expose.
const instantiatedSettingsCore: {
authorizationKey: string,
key: SplitIO.SplitKey,
trafficType: string,
labelsEnabled: boolean,
IPAddressesEnabled: boolean
} = SDK.settings.core;
const instantiatedSettingsMode: ('standalone' | 'consumer') = SDK.settings.mode;
const instantiatedSettingsScheduler: {[key: string]: number} = SDK.settings.scheduler;
const instantiatedSettingsStartup: {[key: string]: number} = SDK.settings.startup;
const instantiatedSettingsStorage: {
prefix: string,
options: Object,
// It can have any of the storages.
authorizationKey: 'key'
},
storage: {
type: 'REDIS'
}
};
// For browser
browserSettings = {
core: {
authorizationKey: 'another-key',
key: 'customer-key'
}
};
// With sync settings should return ISDK, if settings have async storage it should return IAsyncSDK
SDK = SplitFactory(browserSettings);
SDK = SplitFactory(nodeSettings);
AsyncSDK = SplitFactory(asyncSettings);
// The settings values the SDK expose.
const instantiatedSettingsCore: {
authorizationKey: string,
key: SplitIO.SplitKey,
trafficType: string,
labelsEnabled: boolean,
IPAddressesEnabled: boolean
} = SDK.settings.core;
const instantiatedSettingsMode: ('standalone' | 'consumer') = SDK.settings.mode;
const instantiatedSettingsScheduler: {[key: string]: number} = SDK.settings.scheduler;
const instantiatedSettingsStartup: {[key: string]: number} = SDK.settings.startup;
const instantiatedSettingsStorage: {
prefix: string,
options: Object,
core: {
authorizationKey: 'key'
},
storage: {
type: 'REDIS'
}
};
// For browser
browserSettings = {
core: {
authorizationKey: 'another-key',
key: 'customer-key'
}
};
// With sync settings should return ISDK, if settings have async storage it should return IAsyncSDK
SDK = SplitFactory(browserSettings);
SDK = SplitFactory(nodeSettings);
AsyncSDK = SplitFactory(asyncSettings);
// The settings values the SDK expose.
const instantiatedSettingsCore: {
authorizationKey: string,
key: SplitIO.SplitKey,
trafficType: string,
labelsEnabled: boolean,
IPAddressesEnabled: boolean
} = SDK.settings.core;
const instantiatedSettingsMode: ('standalone' | 'consumer') = SDK.settings.mode;
const instantiatedSettingsScheduler: {[key: string]: number} = SDK.settings.scheduler;
const instantiatedSettingsStartup: {[key: string]: number} = SDK.settings.startup;
const instantiatedSettingsStorage: {
prefix: string,
const initializeClient = (): {
client: SplitIO.IClient;
manager: SplitIO.IManager;
} => {
if (!adapterState.splitioSettings) {
throw Error(
'cannot initialize SplitIo without configured settings, call configure() first'
);
}
const sdk = SplitFactory(adapterState.splitioSettings); // eslint-disable-line new-cap
return {
client: sdk.client(),
manager: sdk.manager(),
};
};
logger.info(`SDK_URL: ${process.env.SDK_URL}`);
logger.info(`EVENTS_URL: ${process.env.EVENTS_URL}`);
if (process.env.SPLITIO_IMPRESSION_LISTENER) {
settings = merge({}, settings, {
impressionListener: {
logImpression,
},
});
context.start();
logger.info(`IMPRESSION_LISTENER: ${process.env.SPLITIO_IMPRESSION_LISTENER}`);
}
let isClientReady = false;
// Our SDK factory instance.
const factory = SplitFactory(settings);
// Our client.
const client = factory.client();
// Our manager.
const manager = factory.manager();
// Returns true if the client is ready.
const isReady = () => isClientReady;
client.on(client.Event.SDK_READY, () => {
logger.info(`ON SDK_READY, IS CLIENT READY?: ${isClientReady}`);
return isClientReady === true;
});
module.exports = {
factory,
client,
manager,
factory = {
client: jest.fn(() => ({
on: onStub,
getTreatments: jest.fn(() => flags),
Event: {
SDK_READY: 'SDK_READY',
SDK_UPDATE: 'SDK_UPDATE',
},
})),
manager: jest.fn(() => ({
names: jest.fn(() => names),
})),
};
SplitFactory.mockReturnValue(factory);
return adapter.configure(
{
authorizationKey,
user: userWithKey,
},
{
onStatusStateChange,
onFlagsStateChange,
}
);
});
const touch = require('touch');
const mkdirp = require('mkdirp');
const browserify = require('browserify');
const envify = require('envify/custom');
const uglify = require('uglify-js');
const strStream = require('string-to-stream');
const splitPkg = require('@splitsoftware/splitio/package');
const splitSource = require.resolve('@splitsoftware/splitio/lib/browser.js');
const bundlesDir = path.resolve(path.join(process.cwd(), `splitio`));
const debugBundlePath = path.resolve(path.join(bundlesDir, `split-${splitPkg.version}.js`));
const productionBundlePath = path.resolve(path.join(bundlesDir, `split-${splitPkg.version}.min.js`));
function minify(bundlePath, customUglifySetting) {
return uglify.minify(bundlePath, Object.assign({
compress: {
sequences : true,
properties : true,
dead_code : true,
drop_debugger : true,
unsafe : false,
unsafe_comps : false,
conditionals : true,
comparisons : true,
evaluate : true,
booleans : true,
loops : true,
unused : true,