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

@devcycle/nodejs-server-sdk

Package Overview
Dependencies
Maintainers
6
Versions
192
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@devcycle/nodejs-server-sdk - npm Package Compare versions

Comparing version 1.26.0 to 1.27.0

src/clientUser.d.ts

4

config-manager/src/index.d.ts

@@ -7,2 +7,3 @@ import { DVCLogger } from '@devcycle/types';

cdnURI?: string;
clientMode?: boolean;
};

@@ -27,3 +28,4 @@ type SetIntervalInterface = (handler: () => void, timeout?: number) => any;

private readonly clearInterval;
constructor(logger: DVCLogger, sdkKey: string, setConfigBuffer: SetConfigBuffer, setInterval: SetIntervalInterface, clearInterval: ClearIntervalInterface, { configPollingIntervalMS, configPollingTimeoutMS, configCDNURI, cdnURI, }: ConfigPollingOptions);
private clientMode;
constructor(logger: DVCLogger, sdkKey: string, setConfigBuffer: SetConfigBuffer, setInterval: SetIntervalInterface, clearInterval: ClearIntervalInterface, { configPollingIntervalMS, configPollingTimeoutMS, configCDNURI, cdnURI, clientMode, }: ConfigPollingOptions);
stopPolling(): void;

@@ -30,0 +32,0 @@ cleanup(): void;

@@ -7,3 +7,3 @@ "use strict";

class EnvironmentConfigManager {
constructor(logger, sdkKey, setConfigBuffer, setInterval, clearInterval, { configPollingIntervalMS = 10000, configPollingTimeoutMS = 5000, configCDNURI, cdnURI = 'https://config-cdn.devcycle.com', }) {
constructor(logger, sdkKey, setConfigBuffer, setInterval, clearInterval, { configPollingIntervalMS = 10000, configPollingTimeoutMS = 5000, configCDNURI, cdnURI = 'https://config-cdn.devcycle.com', clientMode = false, }) {
this.hasConfig = false;

@@ -16,2 +16,3 @@ this.disablePolling = false;

this.clearInterval = clearInterval;
this.clientMode = clientMode;
this.pollingIntervalMS =

@@ -50,2 +51,5 @@ configPollingIntervalMS >= 1000 ? configPollingIntervalMS : 1000;

getConfigURL() {
if (this.clientMode) {
return `${this.cdnURI}/config/v1/server/bootstrap/${this.sdkKey}.json`;
}
return `${this.cdnURI}/config/v1/server/${this.sdkKey}.json`;

@@ -91,3 +95,3 @@ }

const lastModified = (res === null || res === void 0 ? void 0 : res.headers.get('last-modified')) || '';
this.setConfigBuffer(this.sdkKey, projectConfig);
this.setConfigBuffer(`${this.sdkKey}${this.clientMode ? '_client' : ''}`, projectConfig);
this.hasConfig = true;

@@ -94,0 +98,0 @@ this.configEtag = etag;

@@ -7,2 +7,3 @@ import { DVCLogger } from '@devcycle/types';

cdnURI?: string;
clientMode?: boolean;
};

@@ -27,3 +28,4 @@ type SetIntervalInterface = (handler: () => void, timeout?: number) => any;

private readonly clearInterval;
constructor(logger: DVCLogger, sdkKey: string, setConfigBuffer: SetConfigBuffer, setInterval: SetIntervalInterface, clearInterval: ClearIntervalInterface, { configPollingIntervalMS, configPollingTimeoutMS, configCDNURI, cdnURI, }: ConfigPollingOptions);
private clientMode;
constructor(logger: DVCLogger, sdkKey: string, setConfigBuffer: SetConfigBuffer, setInterval: SetIntervalInterface, clearInterval: ClearIntervalInterface, { configPollingIntervalMS, configPollingTimeoutMS, configCDNURI, cdnURI, clientMode, }: ConfigPollingOptions);
stopPolling(): void;

@@ -30,0 +32,0 @@ cleanup(): void;

@@ -7,3 +7,3 @@ "use strict";

class EnvironmentConfigManager {
constructor(logger, sdkKey, setConfigBuffer, setInterval, clearInterval, { configPollingIntervalMS = 10000, configPollingTimeoutMS = 5000, configCDNURI, cdnURI = 'https://config-cdn.devcycle.com', }) {
constructor(logger, sdkKey, setConfigBuffer, setInterval, clearInterval, { configPollingIntervalMS = 10000, configPollingTimeoutMS = 5000, configCDNURI, cdnURI = 'https://config-cdn.devcycle.com', clientMode = false, }) {
this.hasConfig = false;

@@ -16,2 +16,3 @@ this.disablePolling = false;

this.clearInterval = clearInterval;
this.clientMode = clientMode;
this.pollingIntervalMS =

@@ -50,2 +51,5 @@ configPollingIntervalMS >= 1000 ? configPollingIntervalMS : 1000;

getConfigURL() {
if (this.clientMode) {
return `${this.cdnURI}/config/v1/server/bootstrap/${this.sdkKey}.json`;
}
return `${this.cdnURI}/config/v1/server/${this.sdkKey}.json`;

@@ -91,3 +95,3 @@ }

const lastModified = (res === null || res === void 0 ? void 0 : res.headers.get('last-modified')) || '';
this.setConfigBuffer(this.sdkKey, projectConfig);
this.setConfigBuffer(`${this.sdkKey}${this.clientMode ? '_client' : ''}`, projectConfig);
this.hasConfig = true;

@@ -94,0 +98,0 @@ this.configEtag = etag;

{
"name": "@devcycle/nodejs-server-sdk",
"version": "1.26.0",
"version": "1.27.0",
"description": "The DevCycle NodeJS Server SDK used for feature management.",

@@ -23,5 +23,5 @@ "license": "MIT",

"dependencies": {
"@devcycle/bucketing-assembly-script": "^1.18.1",
"@devcycle/js-cloud-server-sdk": "^1.10.1",
"@devcycle/types": "^1.11.1",
"@devcycle/bucketing-assembly-script": "^1.19.0",
"@devcycle/js-cloud-server-sdk": "^1.11.0",
"@devcycle/types": "^1.12.0",
"cross-fetch": "^4.0.0",

@@ -28,0 +28,0 @@ "fetch-retry": "^5.0.6"

@@ -1,2 +0,2 @@

import { DevCycleServerSDKOptions, VariableTypeAlias } from '@devcycle/types';
import { BucketedUserConfig, DevCycleServerSDKOptions, VariableTypeAlias } from '@devcycle/types';
import { DevCycleUser, DVCVariable, DVCVariableValue, DVCVariableSet, DVCFeatureSet, DevCycleEvent } from '@devcycle/js-cloud-server-sdk';

@@ -8,2 +8,3 @@ type DevCycleProviderConstructor = typeof import('./open-feature-provider/DevCycleProvider').DevCycleProvider;

private configHelper;
private clientConfigHelper?;
private eventQueue;

@@ -29,2 +30,12 @@ private onInitialized;

track(user: DevCycleUser, event: DevCycleEvent): void;
/**
* Call this to obtain a config that is suitable for use in the "bootstrapConfig" option of client-side JS SDKs
* Useful for serverside-rendering use cases where the server performs the initial rendering pass, and provides it
* to the client along with the DevCycle config to allow hydration
* @param user
* @param userAgent
*/
getClientBootstrapConfig(user: DevCycleUser, userAgent: string): Promise<BucketedUserConfig & {
sdkKey: string;
}>;
flushEvents(callback?: () => void): Promise<void>;

@@ -31,0 +42,0 @@ close(): Promise<void>;

@@ -66,3 +66,7 @@ "use strict";

.then(() => {
var _a;
this.configHelper = new config_manager_1.EnvironmentConfigManager(this.logger, sdkKey, bucketing_1.setConfigDataUTF8, setInterval, clearInterval, options || {});
if (options === null || options === void 0 ? void 0 : options.enableClientBootstrapping) {
this.clientConfigHelper = new config_manager_1.EnvironmentConfigManager(this.logger, sdkKey, bucketing_1.setConfigDataUTF8, setInterval, clearInterval, { ...options, clientMode: true });
}
this.eventQueue = new eventQueue_1.EventQueue(sdkKey, {

@@ -80,3 +84,6 @@ ...options,

(0, bucketing_1.getBucketingLib)().setPlatformData(JSON.stringify(platformData));
return this.configHelper.fetchConfigPromise;
return Promise.all([
this.configHelper.fetchConfigPromise,
(_a = this.clientConfigHelper) === null || _a === void 0 ? void 0 : _a.fetchConfigPromise,
]);
});

@@ -199,2 +206,33 @@ this.onInitialized = initializePromise

}
/**
* Call this to obtain a config that is suitable for use in the "bootstrapConfig" option of client-side JS SDKs
* Useful for serverside-rendering use cases where the server performs the initial rendering pass, and provides it
* to the client along with the DevCycle config to allow hydration
* @param user
* @param userAgent
*/
async getClientBootstrapConfig(user, userAgent) {
const incomingUser = castIncomingUser(user);
await this.onInitialized;
if (!this.clientConfigHelper) {
throw new Error('enableClientBootstrapping option must be set to true to use getClientBootstrapConfig');
}
const sdkKey = (0, userBucketingHelper_1.getSDKKeyFromConfig)(`${this.sdkKey}_client`);
if (!sdkKey) {
throw new Error('Client bootstrapping config is malformed. Please contact DevCycle support.');
}
try {
const { generateClientPopulatedUser } = await import('./clientUser.js');
const populatedUser = generateClientPopulatedUser(incomingUser, userAgent);
return {
...(0, userBucketingHelper_1.bucketUserForConfig)(populatedUser, `${this.sdkKey}_client`),
sdkKey,
};
}
catch (e) {
throw new Error('@devcycle/js-client-sdk package could not be found. ' +
'Please install it to use client boostrapping. Error: ' +
e.message);
}
}
async flushEvents(callback) {

@@ -201,0 +239,0 @@ return this.eventQueue.flushEvents().then(callback);

import { BucketedUserConfig, SDKVariable, VariableType } from '@devcycle/types';
import { DVCPopulatedUser } from '@devcycle/js-cloud-server-sdk';
export declare function bucketUserForConfig(user: DVCPopulatedUser, sdkKey: string): BucketedUserConfig;
export declare function getSDKKeyFromConfig(sdkKey: string): string | null;
export declare function getVariableTypeCode(type: VariableType): number;
export declare function variableForUser(sdkKey: string, user: DVCPopulatedUser, key: string, type: number): SDKVariable | null;
export declare function variableForUser_PB(sdkKey: string, user: DVCPopulatedUser, key: string, type: number): SDKVariable | null;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.variableForUser_PB = exports.variableForUser = exports.getVariableTypeCode = exports.bucketUserForConfig = void 0;
exports.variableForUser_PB = exports.variableForUser = exports.getVariableTypeCode = exports.getSDKKeyFromConfig = exports.bucketUserForConfig = void 0;
const types_1 = require("@devcycle/types");

@@ -13,2 +13,6 @@ const bucketing_1 = require("../bucketing");

exports.bucketUserForConfig = bucketUserForConfig;
function getSDKKeyFromConfig(sdkKey) {
return (0, bucketing_1.getBucketingLib)().getSDKKeyFromConfig(sdkKey);
}
exports.getSDKKeyFromConfig = getSDKKeyFromConfig;
function getVariableTypeCode(type) {

@@ -15,0 +19,0 @@ const Bucketing = (0, bucketing_1.getBucketingLib)();

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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