New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@configcat/sdk

Package Overview
Dependencies
Maintainers
0
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@configcat/sdk - npm Package Compare versions

Comparing version 0.0.1 to 0.1.0

lib/cjs/browser/LocalStorageConfigCache.d.ts

2

lib/cjs/AutoPollConfigService.js

@@ -84,4 +84,4 @@ "use strict";

onConfigFetched(newConfig) {
this.signalInitialization();
super.onConfigFetched(newConfig);
this.signalInitialization();
}

@@ -88,0 +88,0 @@ setOnlineCore() {

@@ -25,13 +25,17 @@ "use strict";

const Polyfills_1 = require("../Polyfills.js");
const IndexedDBConfigCache_1 = require("../shared/IndexedDBConfigCache.js");
const Version_1 = __importDefault(require("../Version.js"));
const LocalStorageCache_1 = require("./LocalStorageCache.js");
const LocalStorageConfigCache_1 = require("./LocalStorageConfigCache.js");
const XmlHttpRequestConfigFetcher_1 = require("./XmlHttpRequestConfigFetcher.js");
(0, Polyfills_1.setupPolyfills)();
function getClient(sdkKey, pollingMode, options) {
return (0, index_pubternals_core_1.getClient)(sdkKey, pollingMode !== null && pollingMode !== void 0 ? pollingMode : 0, options, LocalStorageCache_1.LocalStorageCache.setup({
return (0, index_pubternals_core_1.getClient)(sdkKey, pollingMode !== null && pollingMode !== void 0 ? pollingMode : 0, options, {
configFetcher: new XmlHttpRequestConfigFetcher_1.XmlHttpRequestConfigFetcher(),
sdkType: "ConfigCat-JS",
sdkType: "ConfigCat-UnifiedJS-Browser",
sdkVersion: Version_1.default,
eventEmitterFactory: () => new DefaultEventEmitter_1.DefaultEventEmitter()
}));
eventEmitterFactory: () => new DefaultEventEmitter_1.DefaultEventEmitter(),
defaultCacheFactory: typeof localStorage !== "undefined"
? LocalStorageConfigCache_1.LocalStorageConfigCache.tryGetFactory()
: IndexedDBConfigCache_1.IndexedDBConfigCache.tryGetFactory()
});
}

@@ -38,0 +42,0 @@ var index_pubternals_core_2 = require("../index.pubternals.core.js");

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SettingKeyValue = exports.ConfigCatClient = exports.ConfigCatClientCache = void 0;
exports.ConfigCatClient = exports.ConfigCatClientCache = void 0;
const AutoPollConfigService_1 = require("./AutoPollConfigService.js");

@@ -216,3 +216,3 @@ const ConfigCatClientOptions_1 = require("./ConfigCatClientOptions.js");

[evaluationDetailsArray, evaluationErrors] = (0, RolloutEvaluator_1.evaluateAll)(this.evaluator, settings, user, remoteConfig, this.options.logger, defaultReturnValue);
result = evaluationDetailsArray.map(details => new SettingKeyValue(details.key, details.value));
result = evaluationDetailsArray.map(details => ({ settingKey: details.key, settingValue: details.value }));
}

@@ -262,3 +262,3 @@ catch (err) {

if (variationId === setting.variationId) {
return new SettingKeyValue(settingKey, ensureAllowedValue(setting.value));
return { settingKey, settingValue: ensureAllowedValue(setting.value) };
}

@@ -273,3 +273,3 @@ const targetingRules = settings[settingKey].targetingRules;

if (variationId === percentageOption.variationId) {
return new SettingKeyValue(settingKey, ensureAllowedValue(percentageOption.value));
return { settingKey, settingValue: ensureAllowedValue(percentageOption.value) };
}

@@ -279,3 +279,3 @@ }

else if (variationId === then.variationId) {
return new SettingKeyValue(settingKey, ensureAllowedValue(then.value));
return { settingKey, settingValue: ensureAllowedValue(then.value) };
}

@@ -289,3 +289,3 @@ }

if (variationId === percentageOption.variationId) {
return new SettingKeyValue(settingKey, ensureAllowedValue(percentageOption.value));
return { settingKey, settingValue: ensureAllowedValue(percentageOption.value) };
}

@@ -474,9 +474,2 @@ }

}
class SettingKeyValue {
constructor(settingKey, settingValue) {
this.settingKey = settingKey;
this.settingValue = settingValue;
}
}
exports.SettingKeyValue = SettingKeyValue;
function isValidSdkKey(sdkKey, customBaseUrl) {

@@ -483,0 +476,0 @@ const proxyPrefix = "configcat-proxy/";

@@ -27,3 +27,2 @@ "use strict";

this.baseUrlOverriden = false;
this.proxy = "";
this.offline = false;

@@ -70,5 +69,2 @@ if (!sdkKey) {

}
if (options.proxy) {
this.proxy = options.proxy;
}
if (options.flagOverrides) {

@@ -75,0 +71,0 @@ this.flagOverrides = options.flagOverrides;

@@ -84,3 +84,5 @@ "use strict";

}
onConfigFetched(newConfig) { }
onConfigFetched(newConfig) {
this.options.logger.debug("config fetched");
}
onConfigChanged(newConfig) {

@@ -87,0 +89,0 @@ var _a;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.QueryParamsOverrideDataSource = exports.MapOverrideDataSource = exports.OverrideBehaviour = exports.FlagOverrides = void 0;
exports.QueryParamsOverrideDataSource = exports.MapOverrideDataSource = exports.OverrideBehaviour = void 0;
exports.nameOfOverrideBehaviour = nameOfOverrideBehaviour;
const ProjectConfig_1 = require("./ProjectConfig.js");
const Utils_1 = require("./Utils.js");
class FlagOverrides {
constructor(dataSource, behaviour) {
this.dataSource = dataSource;
this.behaviour = behaviour;
}
}
exports.FlagOverrides = FlagOverrides;
var OverrideBehaviour;

@@ -52,3 +45,7 @@ (function (OverrideBehaviour) {

class DefaultQueryStringProvider {
get currentValue() { return window === null || window === void 0 ? void 0 : window.location.search; }
get currentValue() {
if (typeof location === "undefined")
return;
return location === null || location === void 0 ? void 0 : location.search;
}
}

@@ -55,0 +52,0 @@ let defaultQueryStringProvider;

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConfigJson = exports.RefreshResult = exports.ClientCacheState = exports.OverrideBehaviour = exports.User = exports.SettingKeyValue = exports.UserComparator = exports.SettingType = exports.SegmentComparator = exports.PrerequisiteFlagComparator = exports.FormattableLogMessage = exports.LogLevel = exports.DataGovernance = exports.PollingMode = void 0;
exports.ConfigJson = exports.RefreshResult = exports.ClientCacheState = exports.OverrideBehaviour = exports.User = exports.UserComparator = exports.SettingType = exports.SegmentComparator = exports.PrerequisiteFlagComparator = exports.FormattableLogMessage = exports.LogLevel = exports.DataGovernance = exports.PollingMode = void 0;
var ConfigCatClientOptions_1 = require("./ConfigCatClientOptions.js");

@@ -40,4 +17,2 @@ Object.defineProperty(exports, "PollingMode", { enumerable: true, get: function () { return ConfigCatClientOptions_1.PollingMode; } });

Object.defineProperty(exports, "UserComparator", { enumerable: true, get: function () { return ConfigJson_1.UserComparator; } });
var ConfigCatClient_1 = require("./ConfigCatClient.js");
Object.defineProperty(exports, "SettingKeyValue", { enumerable: true, get: function () { return ConfigCatClient_1.SettingKeyValue; } });
var User_1 = require("./User.js");

@@ -50,3 +25,4 @@ Object.defineProperty(exports, "User", { enumerable: true, get: function () { return User_1.User; } });

Object.defineProperty(exports, "RefreshResult", { enumerable: true, get: function () { return ConfigServiceBase_1.RefreshResult; } });
exports.ConfigJson = __importStar(require("./ConfigJson.js"));
var ProjectConfig_1 = require("./ProjectConfig.js");
Object.defineProperty(exports, "ConfigJson", { enumerable: true, get: function () { return ProjectConfig_1.ConfigJson; } });
//# sourceMappingURL=index.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.InMemoryConfigCache = exports.ExternalConfigCache = exports.FetchStatus = exports.FetchResult = exports.FetchError = void 0;
exports.getClient = getClient;

@@ -22,14 +21,7 @@ exports.disposeAllClients = disposeAllClients;

function createFlagOverridesFromMap(map, behaviour, watchChanges) {
return new FlagOverrides_1.FlagOverrides(new FlagOverrides_1.MapOverrideDataSource(map, watchChanges), behaviour);
return { dataSource: new FlagOverrides_1.MapOverrideDataSource(map, watchChanges), behaviour };
}
function createFlagOverridesFromQueryParams(behaviour, watchChanges, paramPrefix, queryStringProvider) {
return new FlagOverrides_1.FlagOverrides(new FlagOverrides_1.QueryParamsOverrideDataSource(watchChanges, paramPrefix, queryStringProvider), behaviour);
return { dataSource: new FlagOverrides_1.QueryParamsOverrideDataSource(watchChanges, paramPrefix, queryStringProvider), behaviour };
}
var ConfigFetcher_1 = require("./ConfigFetcher.js");
Object.defineProperty(exports, "FetchError", { enumerable: true, get: function () { return ConfigFetcher_1.FetchError; } });
Object.defineProperty(exports, "FetchResult", { enumerable: true, get: function () { return ConfigFetcher_1.FetchResult; } });
Object.defineProperty(exports, "FetchStatus", { enumerable: true, get: function () { return ConfigFetcher_1.FetchStatus; } });
var ConfigCatCache_1 = require("./ConfigCatCache.js");
Object.defineProperty(exports, "ExternalConfigCache", { enumerable: true, get: function () { return ConfigCatCache_1.ExternalConfigCache; } });
Object.defineProperty(exports, "InMemoryConfigCache", { enumerable: true, get: function () { return ConfigCatCache_1.InMemoryConfigCache; } });
//# sourceMappingURL=index.pubternals.core.js.map

@@ -17,8 +17,19 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.FetchApiConfigFetcher = exports.XmlHttpRequestConfigFetcher = exports.LocalStorageCache = exports.DefaultEventEmitter = void 0;
exports.FetchApiConfigFetcher = exports.XmlHttpRequestConfigFetcher = exports.IndexedDBConfigCache = exports.LocalStorageConfigCache = exports.DefaultEventEmitter = exports.FetchStatus = exports.FetchResult = exports.FetchError = exports.InMemoryConfigCache = exports.ExternalConfigCache = exports.settingFromValue = void 0;
const ProjectConfig_1 = require("./ProjectConfig.js");
__exportStar(require("./index.pubternals.core.js"), exports);
exports.settingFromValue = ProjectConfig_1.Setting.fromValue;
var ConfigCatCache_1 = require("./ConfigCatCache.js");
Object.defineProperty(exports, "ExternalConfigCache", { enumerable: true, get: function () { return ConfigCatCache_1.ExternalConfigCache; } });
Object.defineProperty(exports, "InMemoryConfigCache", { enumerable: true, get: function () { return ConfigCatCache_1.InMemoryConfigCache; } });
var ConfigFetcher_1 = require("./ConfigFetcher.js");
Object.defineProperty(exports, "FetchError", { enumerable: true, get: function () { return ConfigFetcher_1.FetchError; } });
Object.defineProperty(exports, "FetchResult", { enumerable: true, get: function () { return ConfigFetcher_1.FetchResult; } });
Object.defineProperty(exports, "FetchStatus", { enumerable: true, get: function () { return ConfigFetcher_1.FetchStatus; } });
var DefaultEventEmitter_1 = require("./DefaultEventEmitter.js");
Object.defineProperty(exports, "DefaultEventEmitter", { enumerable: true, get: function () { return DefaultEventEmitter_1.DefaultEventEmitter; } });
var LocalStorageCache_1 = require("./browser/LocalStorageCache.js");
Object.defineProperty(exports, "LocalStorageCache", { enumerable: true, get: function () { return LocalStorageCache_1.LocalStorageCache; } });
var LocalStorageConfigCache_1 = require("./browser/LocalStorageConfigCache.js");
Object.defineProperty(exports, "LocalStorageConfigCache", { enumerable: true, get: function () { return LocalStorageConfigCache_1.LocalStorageConfigCache; } });
var IndexedDBConfigCache_1 = require("./shared/IndexedDBConfigCache.js");
Object.defineProperty(exports, "IndexedDBConfigCache", { enumerable: true, get: function () { return IndexedDBConfigCache_1.IndexedDBConfigCache; } });
var XmlHttpRequestConfigFetcher_1 = require("./browser/XmlHttpRequestConfigFetcher.js");

@@ -25,0 +36,0 @@ Object.defineProperty(exports, "XmlHttpRequestConfigFetcher", { enumerable: true, get: function () { return XmlHttpRequestConfigFetcher_1.XmlHttpRequestConfigFetcher; } });

@@ -28,4 +28,4 @@ "use strict";

return (0, index_pubternals_core_1.getClient)(sdkKey, pollingMode !== null && pollingMode !== void 0 ? pollingMode : 0, options, {
configFetcher: new NodeHttpConfigFetcher_1.NodeHttpConfigFetcher(),
sdkType: "ConfigCat-Node",
configFetcher: new NodeHttpConfigFetcher_1.NodeHttpConfigFetcher(options),
sdkType: "ConfigCat-UnifiedJS-Node",
sdkVersion: Version_1.default,

@@ -32,0 +32,0 @@ eventEmitterFactory: () => new events_1.EventEmitter()

@@ -34,2 +34,5 @@ "use strict";

class NodeHttpConfigFetcher {
constructor(options) {
this.proxy = options === null || options === void 0 ? void 0 : options.proxy;
}
handleResponse(response, resolve, reject) {

@@ -69,5 +72,5 @@ try {

let agent;
if (options.proxy) {
if (this.proxy) {
try {
const proxy = new url_1.URL(options.proxy);
const proxy = new url_1.URL(this.proxy);
let agentFactory;

@@ -89,3 +92,3 @@ if (proxy.protocol === "https:") {

catch (err) {
options.logger.log(1, 0, ConfigCatLogger_1.FormattableLogMessage.from("PROXY") `Failed to parse \`options.proxy\`: '${options.proxy}'.`, err);
options.logger.log(1, 0, ConfigCatLogger_1.FormattableLogMessage.from("PROXY") `Failed to parse \`options.proxy\`: '${this.proxy}'.`, err);
}

@@ -92,0 +95,0 @@ }

@@ -103,3 +103,4 @@ "use strict";

this.settings = json.f != null
? Object.entries(json.f).reduce((acc, [key, value]) => (acc[key] = new Setting(value, this), acc), {})
? Object.entries(json.f)
.reduce((acc, [key, value]) => (acc[key] = new Setting(value, this), acc), {})
: {};

@@ -106,0 +107,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = "0.0.1";
exports.default = "0.1.0";
//# sourceMappingURL=Version.js.map

@@ -81,4 +81,4 @@ import { ConfigServiceBase } from "./ConfigServiceBase.js";

onConfigFetched(newConfig) {
this.signalInitialization();
super.onConfigFetched(newConfig);
this.signalInitialization();
}

@@ -85,0 +85,0 @@ setOnlineCore() {

@@ -16,2 +16,3 @@ import type { IConfigCatClient } from "../ConfigCatClient.js";

export { createConsoleLogger, createFlagOverridesFromMap, createFlagOverridesFromQueryParams, disposeAllClients } from "../index.pubternals.core.js";
export type { IQueryStringProvider } from "../index.pubternals.core.js";
/** Options used to configure the ConfigCat SDK in the case of Auto Polling mode. */

@@ -18,0 +19,0 @@ export interface IJSAutoPollOptions extends IAutoPollOptions {

import { DefaultEventEmitter } from "../DefaultEventEmitter.js";
import { getClient as getClientCommon } from "../index.pubternals.core.js";
import { setupPolyfills } from "../Polyfills.js";
import { IndexedDBConfigCache } from "../shared/IndexedDBConfigCache.js";
import CONFIGCAT_SDK_VERSION from "../Version.js";
import { LocalStorageCache } from "./LocalStorageCache.js";
import { LocalStorageConfigCache } from "./LocalStorageConfigCache.js";
import { XmlHttpRequestConfigFetcher } from "./XmlHttpRequestConfigFetcher.js";
setupPolyfills();
export function getClient(sdkKey, pollingMode, options) {
return getClientCommon(sdkKey, pollingMode !== null && pollingMode !== void 0 ? pollingMode : 0, options, LocalStorageCache.setup({
return getClientCommon(sdkKey, pollingMode !== null && pollingMode !== void 0 ? pollingMode : 0, options, {
configFetcher: new XmlHttpRequestConfigFetcher(),
sdkType: "ConfigCat-JS",
sdkType: "ConfigCat-UnifiedJS-Browser",
sdkVersion: CONFIGCAT_SDK_VERSION,
eventEmitterFactory: () => new DefaultEventEmitter()
}));
eventEmitterFactory: () => new DefaultEventEmitter(),
defaultCacheFactory: typeof localStorage !== "undefined"
? LocalStorageConfigCache.tryGetFactory()
: IndexedDBConfigCache.tryGetFactory()
});
}

@@ -16,0 +20,0 @@ export { createConsoleLogger, createFlagOverridesFromMap, createFlagOverridesFromQueryParams, disposeAllClients } from "../index.pubternals.core.js";

@@ -16,2 +16,3 @@ import type { IConfigCatClient } from "../ConfigCatClient.js";

export { createConsoleLogger, createFlagOverridesFromMap, createFlagOverridesFromQueryParams, disposeAllClients } from "../index.pubternals.core.js";
export type { IQueryStringProvider } from "../index.pubternals.core.js";
/** Options used to configure the ConfigCat SDK in the case of Auto Polling mode. */

@@ -18,0 +19,0 @@ export interface IJSAutoPollOptions extends IAutoPollOptions {

@@ -5,12 +5,15 @@ import { DefaultEventEmitter } from "../DefaultEventEmitter.js";

import { FetchApiConfigFetcher } from "../shared/FetchApiConfigFetcher.js";
import { IndexedDBConfigCache } from "../shared/IndexedDBConfigCache.js";
import CONFIGCAT_SDK_VERSION from "../Version.js";
import { ChromeLocalStorageCache } from "./ChromeLocalStorageCache.js";
import { ChromeLocalStorageConfigCache } from "./ChromeLocalStorageConfigCache.js";
setupPolyfills();
export function getClient(sdkKey, pollingMode, options) {
return getClientCommon(sdkKey, pollingMode !== null && pollingMode !== void 0 ? pollingMode : 0, options, ChromeLocalStorageCache.setup({
var _a;
return getClientCommon(sdkKey, pollingMode !== null && pollingMode !== void 0 ? pollingMode : 0, options, {
configFetcher: new FetchApiConfigFetcher(),
sdkType: "ConfigCat-JS-Chromium",
sdkType: "ConfigCat-UnifiedJS-ChromiumExtension",
sdkVersion: CONFIGCAT_SDK_VERSION,
eventEmitterFactory: () => new DefaultEventEmitter()
}));
eventEmitterFactory: () => new DefaultEventEmitter(),
defaultCacheFactory: (_a = ChromeLocalStorageConfigCache.tryGetFactory()) !== null && _a !== void 0 ? _a : IndexedDBConfigCache.tryGetFactory()
});
}

@@ -17,0 +20,0 @@ export { createConsoleLogger, createFlagOverridesFromMap, createFlagOverridesFromQueryParams, disposeAllClients } from "../index.pubternals.core.js";

@@ -11,3 +11,3 @@ import type { IConfigCache } from "./ConfigCatCache.js";

import type { IEvaluationDetails, IRolloutEvaluator, SettingTypeOf } from "./RolloutEvaluator.js";
import type { User } from "./User.js";
import type { IUser } from "./User.js";
/** ConfigCat SDK client. */

@@ -27,3 +27,3 @@ export interface IConfigCatClient extends IProvidesHooks {

*/
getValueAsync<T extends SettingValue>(key: string, defaultValue: T, user?: User): Promise<SettingTypeOf<T>>;
getValueAsync<T extends SettingValue>(key: string, defaultValue: T, user?: IUser): Promise<SettingTypeOf<T>>;
/**

@@ -41,3 +41,3 @@ * Returns the value along with evaluation details of a feature flag or setting identified by `key`.

*/
getValueDetailsAsync<T extends SettingValue>(key: string, defaultValue: T, user?: User): Promise<IEvaluationDetails<SettingTypeOf<T>>>;
getValueDetailsAsync<T extends SettingValue>(key: string, defaultValue: T, user?: IUser): Promise<IEvaluationDetails<SettingTypeOf<T>>>;
/**

@@ -53,3 +53,3 @@ * Returns all setting keys.

*/
getAllValuesAsync(user?: User): Promise<SettingKeyValue[]>;
getAllValuesAsync(user?: IUser): Promise<SettingKeyValue[]>;
/**

@@ -60,3 +60,3 @@ * Returns the values along with evaluation details of all feature flags and settings.

*/
getAllValueDetailsAsync(user?: User): Promise<IEvaluationDetails[]>;
getAllValueDetailsAsync(user?: IUser): Promise<IEvaluationDetails[]>;
/** Returns the key of a setting and it's value identified by the given Variation ID (analytics) */

@@ -88,3 +88,3 @@ /**

*/
setDefaultUser(defaultUser: User): void;
setDefaultUser(defaultUser: IUser): void;
/**

@@ -133,3 +133,3 @@ * Clears the default user.

*/
getValue<T extends SettingValue>(key: string, defaultValue: T, user?: User): SettingTypeOf<T>;
getValue<T extends SettingValue>(key: string, defaultValue: T, user?: IUser): SettingTypeOf<T>;
/**

@@ -147,3 +147,3 @@ * Returns the value along with evaluation details of a feature flag or setting identified by `key` synchronously, based on the snapshot.

*/
getValueDetails<T extends SettingValue>(key: string, defaultValue: T, user?: User): IEvaluationDetails<SettingTypeOf<T>>;
getValueDetails<T extends SettingValue>(key: string, defaultValue: T, user?: IUser): IEvaluationDetails<SettingTypeOf<T>>;
}

@@ -173,3 +173,3 @@ export interface IConfigCatKernel {

static get<TMode extends PollingMode>(sdkKey: string, pollingMode: TMode, options: OptionsForPollingMode<TMode> | undefined | null, configCatKernel: IConfigCatKernel): IConfigCatClient;
constructor(options: ConfigCatClientOptions, configCatKernel: IConfigCatKernel, cacheToken?: object);
constructor(options: ConfigCatClientOptions, configCatKernel: IConfigCatKernel, cacheToken?: object | undefined);
private static finalize;

@@ -179,10 +179,10 @@ private static close;

static disposeAll(): void;
getValueAsync<T extends SettingValue>(key: string, defaultValue: T, user?: User): Promise<SettingTypeOf<T>>;
getValueDetailsAsync<T extends SettingValue>(key: string, defaultValue: T, user?: User): Promise<IEvaluationDetails<SettingTypeOf<T>>>;
getValueAsync<T extends SettingValue>(key: string, defaultValue: T, user?: IUser): Promise<SettingTypeOf<T>>;
getValueDetailsAsync<T extends SettingValue>(key: string, defaultValue: T, user?: IUser): Promise<IEvaluationDetails<SettingTypeOf<T>>>;
getAllKeysAsync(): Promise<string[]>;
getAllValuesAsync(user?: User): Promise<SettingKeyValue[]>;
getAllValueDetailsAsync(user?: User): Promise<IEvaluationDetails[]>;
getAllValuesAsync(user?: IUser): Promise<SettingKeyValue[]>;
getAllValueDetailsAsync(user?: IUser): Promise<IEvaluationDetails[]>;
getKeyAndValueAsync(variationId: string): Promise<SettingKeyValue | null>;
forceRefreshAsync(): Promise<RefreshResult>;
setDefaultUser(defaultUser: User): void;
setDefaultUser(defaultUser: IUser): void;
clearDefaultUser(): void;

@@ -215,6 +215,5 @@ get isOffline(): boolean;

/** Setting key-value pair. */
export declare class SettingKeyValue<TValue extends SettingValue = SettingValue> {
export type SettingKeyValue<TValue extends SettingValue = SettingValue> = {
settingKey: string;
settingValue: TValue;
constructor(settingKey: string, settingValue: TValue);
}
};

@@ -212,3 +212,3 @@ import { AutoPollConfigService } from "./AutoPollConfigService.js";

[evaluationDetailsArray, evaluationErrors] = evaluateAll(this.evaluator, settings, user, remoteConfig, this.options.logger, defaultReturnValue);
result = evaluationDetailsArray.map(details => new SettingKeyValue(details.key, details.value));
result = evaluationDetailsArray.map(details => ({ settingKey: details.key, settingValue: details.value }));
}

@@ -258,3 +258,3 @@ catch (err) {

if (variationId === setting.variationId) {
return new SettingKeyValue(settingKey, ensureAllowedValue(setting.value));
return { settingKey, settingValue: ensureAllowedValue(setting.value) };
}

@@ -269,3 +269,3 @@ const targetingRules = settings[settingKey].targetingRules;

if (variationId === percentageOption.variationId) {
return new SettingKeyValue(settingKey, ensureAllowedValue(percentageOption.value));
return { settingKey, settingValue: ensureAllowedValue(percentageOption.value) };
}

@@ -275,3 +275,3 @@ }

else if (variationId === then.variationId) {
return new SettingKeyValue(settingKey, ensureAllowedValue(then.value));
return { settingKey, settingValue: ensureAllowedValue(then.value) };
}

@@ -285,3 +285,3 @@ }

if (variationId === percentageOption.variationId) {
return new SettingKeyValue(settingKey, ensureAllowedValue(percentageOption.value));
return { settingKey, settingValue: ensureAllowedValue(percentageOption.value) };
}

@@ -469,8 +469,2 @@ }

}
export class SettingKeyValue {
constructor(settingKey, settingValue) {
this.settingKey = settingKey;
this.settingValue = settingValue;
}
}
function isValidSdkKey(sdkKey, customBaseUrl) {

@@ -477,0 +471,0 @@ const proxyPrefix = "configcat-proxy/";

@@ -8,3 +8,3 @@ import type { IConfigCache, IConfigCatCache } from "./ConfigCatCache.js";

import { Hooks } from "./Hooks.js";
import type { User } from "./User.js";
import type { IUser } from "./User.js";
/** Specifies the supported polling modes. */

@@ -44,4 +44,2 @@ export declare enum PollingMode {

baseUrl?: string | null;
/** Proxy settings (supported only in the Node SDK currently). */
proxy?: string | null;
/**

@@ -66,3 +64,3 @@ * Set this property to be in sync with the Data Governance preference on the Dashboard:

*/
defaultUser?: User | null;
defaultUser?: IUser | null;
/**

@@ -112,7 +110,6 @@ * Indicates whether the client should be initialized to offline mode or not. Defaults to `false`.

baseUrlOverriden: boolean;
proxy: string;
dataGovernance: DataGovernance;
cache: IConfigCache;
flagOverrides?: FlagOverrides;
defaultUser?: User;
defaultUser?: IUser;
offline: boolean;

@@ -119,0 +116,0 @@ hooks: SafeHooksWrapper;

@@ -24,3 +24,2 @@ import { ExternalConfigCache, InMemoryConfigCache } from "./ConfigCatCache.js";

this.baseUrlOverriden = false;
this.proxy = "";
this.offline = false;

@@ -67,5 +66,2 @@ if (!sdkKey) {

}
if (options.proxy) {
this.proxy = options.proxy;
}
if (options.flagOverrides) {

@@ -72,0 +68,0 @@ this.flagOverrides = options.flagOverrides;

@@ -52,3 +52,3 @@ import type { SafeHooksWrapper } from "./Hooks.js";

get eol(): string;
constructor(logger: IConfigCatLogger, hooks?: SafeHooksWrapper);
constructor(logger: IConfigCatLogger, hooks?: SafeHooksWrapper | undefined);
isEnabled(logLevel: LogLevel): boolean;

@@ -55,0 +55,0 @@ /** @inheritdoc */

@@ -11,3 +11,3 @@ import type { OptionsBase } from "./ConfigCatClientOptions.js";

config: ProjectConfig;
errorMessage?: string;
errorMessage?: string | undefined;
errorException?: any;

@@ -14,0 +14,0 @@ private constructor();

@@ -80,3 +80,5 @@ import { FetchError, FetchResult } from "./ConfigFetcher.js";

}
onConfigFetched(newConfig) { }
onConfigFetched(newConfig) {
this.options.logger.debug("config fetched");
}
onConfigChanged(newConfig) {

@@ -83,0 +85,0 @@ var _a;

@@ -8,3 +8,3 @@ import { DefaultEventEmitter } from "../DefaultEventEmitter.js";

configFetcher: new FetchApiConfigFetcher(),
sdkType: "ConfigCat-Deno",
sdkType: "ConfigCat-UnifiedJS-Deno",
sdkVersion: CONFIGCAT_SDK_VERSION,

@@ -11,0 +11,0 @@ eventEmitterFactory: () => new DefaultEventEmitter()

import type { SettingValue } from "./ProjectConfig.js";
import { Setting } from "./ProjectConfig.js";
export declare class FlagOverrides {
export type FlagOverrides = {
dataSource: IOverrideDataSource;
behaviour: OverrideBehaviour;
constructor(dataSource: IOverrideDataSource, behaviour: OverrideBehaviour);
}
};
/**

@@ -9,0 +8,0 @@ * Specifies the behaviours for flag overrides.

import { Setting } from "./ProjectConfig.js";
import { isArray, parseFloatStrict } from "./Utils.js";
export class FlagOverrides {
constructor(dataSource, behaviour) {
this.dataSource = dataSource;
this.behaviour = behaviour;
}
}
export var OverrideBehaviour;

@@ -46,3 +40,7 @@ (function (OverrideBehaviour) {

class DefaultQueryStringProvider {
get currentValue() { return window === null || window === void 0 ? void 0 : window.location.search; }
get currentValue() {
if (typeof location === "undefined")
return;
return location === null || location === void 0 ? void 0 : location.search;
}
}

@@ -49,0 +47,0 @@ let defaultQueryStringProvider;

@@ -10,6 +10,5 @@ export { PollingMode } from "./ConfigCatClientOptions.js";

export { PrerequisiteFlagComparator, SegmentComparator, SettingType, UserComparator } from "./ConfigJson.js";
export type { IConfigCatClient, IConfigCatClientSnapshot } from "./ConfigCatClient.js";
export { SettingKeyValue } from "./ConfigCatClient.js";
export type { IConfigCatClient, IConfigCatClientSnapshot, SettingKeyValue } from "./ConfigCatClient.js";
export type { IEvaluationDetails, SettingTypeOf } from "./RolloutEvaluator.js";
export type { UserAttributeValue } from "./User.js";
export type { IUser, UserAttributeValue } from "./User.js";
export { User } from "./User.js";

@@ -20,2 +19,2 @@ export type { FlagOverrides } from "./FlagOverrides.js";

export type { HookEvents, IProvidesHooks } from "./Hooks.js";
export * as ConfigJson from "./ConfigJson.js";
export { ConfigJson } from "./ProjectConfig.js";

@@ -6,8 +6,6 @@ export { PollingMode } from "./ConfigCatClientOptions.js";

export { PrerequisiteFlagComparator, SegmentComparator, SettingType, UserComparator } from "./ConfigJson.js";
export { SettingKeyValue } from "./ConfigCatClient.js";
export { User } from "./User.js";
export { OverrideBehaviour } from "./FlagOverrides.js";
export { ClientCacheState, RefreshResult } from "./ConfigServiceBase.js";
import * as ConfigJson_1 from "./ConfigJson.js";
export { ConfigJson_1 as ConfigJson };
export { ConfigJson } from "./ProjectConfig.js";
//# sourceMappingURL=index.js.map
import type { IConfigCatClient, IConfigCatKernel } from "./ConfigCatClient.js";
import type { OptionsForPollingMode, PollingMode } from "./ConfigCatClientOptions.js";
import type { IConfigCatLogger, LogLevel } from "./ConfigCatLogger.js";
import type { IQueryStringProvider, OverrideBehaviour } from "./FlagOverrides.js";
import { FlagOverrides } from "./FlagOverrides.js";
import type { FlagOverrides, IQueryStringProvider, OverrideBehaviour } from "./FlagOverrides.js";
import type { SettingValue } from "./ProjectConfig.js";

@@ -51,12 +50,5 @@ /**

* @param queryStringProvider The provider object used to obtain the query string.
* Defaults to a provider that returns the value of `window.location.search`.
* Defaults to a provider that returns the value of `globalThis.location.search`.
*/
export declare function createFlagOverridesFromQueryParams(behaviour: OverrideBehaviour, watchChanges?: boolean, paramPrefix?: string, queryStringProvider?: IQueryStringProvider): FlagOverrides;
export type { IQueryStringProvider };
export type { IConfigCatKernel };
export type { FetchErrorCauses, IConfigFetcher, IFetchResponse } from "./ConfigFetcher.js";
export { FetchError, FetchResult, FetchStatus } from "./ConfigFetcher.js";
export type { OptionsBase } from "./ConfigCatClientOptions.js";
export type { IConfigCache } from "./ConfigCatCache.js";
export { ExternalConfigCache, InMemoryConfigCache } from "./ConfigCatCache.js";
export type { IEventEmitter, IEventProvider } from "./EventEmitter.js";
import { ConfigCatClient } from "./ConfigCatClient.js";
import { ConfigCatConsoleLogger } from "./ConfigCatLogger.js";
import { FlagOverrides, MapOverrideDataSource, QueryParamsOverrideDataSource } from "./FlagOverrides.js";
import { MapOverrideDataSource, QueryParamsOverrideDataSource } from "./FlagOverrides.js";
export function getClient(sdkKey, pollingMode, options, configCatKernel) {

@@ -14,9 +14,7 @@ return ConfigCatClient.get(sdkKey, pollingMode, options, configCatKernel);

export function createFlagOverridesFromMap(map, behaviour, watchChanges) {
return new FlagOverrides(new MapOverrideDataSource(map, watchChanges), behaviour);
return { dataSource: new MapOverrideDataSource(map, watchChanges), behaviour };
}
export function createFlagOverridesFromQueryParams(behaviour, watchChanges, paramPrefix, queryStringProvider) {
return new FlagOverrides(new QueryParamsOverrideDataSource(watchChanges, paramPrefix, queryStringProvider), behaviour);
return { dataSource: new QueryParamsOverrideDataSource(watchChanges, paramPrefix, queryStringProvider), behaviour };
}
export { FetchError, FetchResult, FetchStatus } from "./ConfigFetcher.js";
export { ExternalConfigCache, InMemoryConfigCache } from "./ConfigCatCache.js";
//# sourceMappingURL=index.pubternals.core.js.map

@@ -0,5 +1,16 @@

import { Setting } from "./ProjectConfig.js";
export * from "./index.pubternals.core.js";
export type { IConfigCatKernel } from "./ConfigCatClient.js";
export type { OptionsBase } from "./ConfigCatClientOptions.js";
export type { IOverrideDataSource } from "./FlagOverrides.js";
export declare const settingFromValue: typeof Setting.fromValue;
export type { IConfigCache } from "./ConfigCatCache.js";
export { ExternalConfigCache, InMemoryConfigCache } from "./ConfigCatCache.js";
export type { FetchErrorCauses, IConfigFetcher, IFetchResponse } from "./ConfigFetcher.js";
export { FetchError, FetchResult, FetchStatus } from "./ConfigFetcher.js";
export type { IEventEmitter, IEventProvider } from "./EventEmitter.js";
export { DefaultEventEmitter } from "./DefaultEventEmitter.js";
export { LocalStorageCache } from "./browser/LocalStorageCache.js";
export { LocalStorageConfigCache } from "./browser/LocalStorageConfigCache.js";
export { IndexedDBConfigCache } from "./shared/IndexedDBConfigCache.js";
export { XmlHttpRequestConfigFetcher } from "./browser/XmlHttpRequestConfigFetcher.js";
export { FetchApiConfigFetcher } from "./shared/FetchApiConfigFetcher.js";

@@ -0,6 +1,11 @@

import { Setting } from "./ProjectConfig.js";
export * from "./index.pubternals.core.js";
export const settingFromValue = Setting.fromValue;
export { ExternalConfigCache, InMemoryConfigCache } from "./ConfigCatCache.js";
export { FetchError, FetchResult, FetchStatus } from "./ConfigFetcher.js";
export { DefaultEventEmitter } from "./DefaultEventEmitter.js";
export { LocalStorageCache } from "./browser/LocalStorageCache.js";
export { LocalStorageConfigCache } from "./browser/LocalStorageConfigCache.js";
export { IndexedDBConfigCache } from "./shared/IndexedDBConfigCache.js";
export { XmlHttpRequestConfigFetcher } from "./browser/XmlHttpRequestConfigFetcher.js";
export { FetchApiConfigFetcher } from "./shared/FetchApiConfigFetcher.js";
//# sourceMappingURL=index.pubternals.js.map
import type { IConfigCatClient } from "../ConfigCatClient.js";
import type { IAutoPollOptions, ILazyLoadingOptions, IManualPollOptions } from "../ConfigCatClientOptions.js";
import { PollingMode } from "../ConfigCatClientOptions.js";
import type { INodeHttpConfigFetcherOptions } from "./NodeHttpConfigFetcher.js";
/**

@@ -17,11 +18,11 @@ * Returns an instance of `ConfigCatClient` for the specified SDK Key.

/** Options used to configure the ConfigCat SDK in the case of Auto Polling mode. */
export interface INodeAutoPollOptions extends IAutoPollOptions {
export interface INodeAutoPollOptions extends IAutoPollOptions, INodeHttpConfigFetcherOptions {
}
/** Options used to configure the ConfigCat SDK in the case of Lazy Loading mode. */
export interface INodeLazyLoadingOptions extends ILazyLoadingOptions {
export interface INodeLazyLoadingOptions extends ILazyLoadingOptions, INodeHttpConfigFetcherOptions {
}
/** Options used to configure the ConfigCat SDK in the case of Manual Polling mode. */
export interface INodeManualPollOptions extends IManualPollOptions {
export interface INodeManualPollOptions extends IManualPollOptions, INodeHttpConfigFetcherOptions {
}
export type OptionsForPollingMode<TMode extends PollingMode | undefined> = TMode extends PollingMode.AutoPoll ? INodeAutoPollOptions : TMode extends PollingMode.ManualPoll ? INodeManualPollOptions : TMode extends PollingMode.LazyLoad ? INodeLazyLoadingOptions : TMode extends undefined ? INodeAutoPollOptions : never;
export * from "../index.js";

@@ -7,4 +7,4 @@ import { EventEmitter } from "events";

return getClientCommon(sdkKey, pollingMode !== null && pollingMode !== void 0 ? pollingMode : 0, options, {
configFetcher: new NodeHttpConfigFetcher(),
sdkType: "ConfigCat-Node",
configFetcher: new NodeHttpConfigFetcher(options),
sdkType: "ConfigCat-UnifiedJS-Node",
sdkVersion: CONFIGCAT_SDK_VERSION,

@@ -11,0 +11,0 @@ eventEmitterFactory: () => new EventEmitter()

import type { OptionsBase } from "../ConfigCatClientOptions.js";
import type { IConfigFetcher, IFetchResponse } from "../ConfigFetcher.js";
export interface INodeHttpConfigFetcherOptions {
/** Proxy settings. */
proxy?: string | null;
}
export declare class NodeHttpConfigFetcher implements IConfigFetcher {
private readonly proxy?;
constructor(options?: INodeHttpConfigFetcherOptions);
private handleResponse;
fetchLogic(options: OptionsBase, lastEtag: string): Promise<IFetchResponse>;
}

@@ -8,2 +8,5 @@ import * as http from "http";

export class NodeHttpConfigFetcher {
constructor(options) {
this.proxy = options === null || options === void 0 ? void 0 : options.proxy;
}
handleResponse(response, resolve, reject) {

@@ -43,5 +46,5 @@ try {

let agent;
if (options.proxy) {
if (this.proxy) {
try {
const proxy = new URL(options.proxy);
const proxy = new URL(this.proxy);
let agentFactory;

@@ -63,3 +66,3 @@ if (proxy.protocol === "https:") {

catch (err) {
options.logger.log(1, 0, FormattableLogMessage.from("PROXY") `Failed to parse \`options.proxy\`: '${options.proxy}'.`, err);
options.logger.log(1, 0, FormattableLogMessage.from("PROXY") `Failed to parse \`options.proxy\`: '${this.proxy}'.`, err);
}

@@ -66,0 +69,0 @@ }

@@ -75,3 +75,4 @@ import * as ConfigJson from "./ConfigJson.js";

this.settings = json.f != null
? Object.entries(json.f).reduce((acc, [key, value]) => (acc[key] = new Setting(value, this), acc), {})
? Object.entries(json.f)
.reduce((acc, [key, value]) => (acc[key] = new Setting(value, this), acc), {})
: {};

@@ -78,0 +79,0 @@ }

import type { LoggerWrapper } from "./ConfigCatLogger.js";
import { EvaluateLogBuilder } from "./EvaluateLogBuilder.js";
import type { IPercentageOption, ITargetingRule, PercentageOption, ProjectConfig, Setting, SettingValue, SettingValueContainer, TargetingRule, VariationIdValue } from "./ProjectConfig.js";
import type { User } from "./User.js";
import type { IUser } from "./User.js";
export declare class EvaluateContext {
readonly key: string;
readonly setting: Setting;
readonly user: User | undefined;
readonly user: IUser | undefined;
readonly settings: Readonly<{

@@ -17,3 +17,3 @@ [key: string]: Setting;

logBuilder?: EvaluateLogBuilder;
constructor(key: string, setting: Setting, user: User | undefined, settings: Readonly<{
constructor(key: string, setting: Setting, user: IUser | undefined, settings: Readonly<{
[key: string]: Setting;

@@ -68,3 +68,3 @@ }>);

/** The User object used for the evaluation (if available). */
user?: User;
user?: IUser;
/**

@@ -84,9 +84,9 @@ * Indicates whether the default value passed to the setting evaluation methods like `IConfigCatClient.getValueAsync`, `IConfigCatClient.getValueDetailsAsync`, etc.

}
export declare function evaluationDetailsFromDefaultValue<T extends SettingValue>(key: string, defaultValue: T, fetchTime?: Date, user?: User, errorMessage?: string, errorException?: any): IEvaluationDetails<SettingTypeOf<T>>;
export declare function evaluationDetailsFromDefaultValue<T extends SettingValue>(key: string, defaultValue: T, fetchTime?: Date, user?: IUser, errorMessage?: string, errorException?: any): IEvaluationDetails<SettingTypeOf<T>>;
export declare function evaluate<T extends SettingValue>(evaluator: IRolloutEvaluator, settings: Readonly<{
[key: string]: Setting;
}> | null, key: string, defaultValue: T, user: User | undefined, remoteConfig: ProjectConfig | null, logger: LoggerWrapper): IEvaluationDetails<SettingTypeOf<T>>;
}> | null, key: string, defaultValue: T, user: IUser | undefined, remoteConfig: ProjectConfig | null, logger: LoggerWrapper): IEvaluationDetails<SettingTypeOf<T>>;
export declare function evaluateAll(evaluator: IRolloutEvaluator, settings: Readonly<{
[key: string]: Setting;
}> | null, user: User | undefined, remoteConfig: ProjectConfig | null, logger: LoggerWrapper, defaultReturnValue: string): [IEvaluationDetails[], any[] | undefined];
}> | null, user: IUser | undefined, remoteConfig: ProjectConfig | null, logger: LoggerWrapper, defaultReturnValue: string): [IEvaluationDetails[], any[] | undefined];
export declare function checkSettingsAvailable(settings: Readonly<{

@@ -93,0 +93,0 @@ [key: string]: Setting;

export type WellKnownUserObjectAttribute = "Identifier" | "Email" | "Country";
export type UserAttributeValue = string | number | Date | ReadonlyArray<string>;
/**
* User Object. Contains user attributes which are used for evaluating targeting rules and percentage options.
* @remarks
* Please note that the `User` class is not designed to be used as a DTO (data transfer object).
* (Since the type of the `custom` property is polymorphic, it's not guaranteed that deserializing a serialized instance produces an instance with an identical or even valid data content.)
* The interface of User Object.
* Defines the user attributes which are used for evaluating targeting rules and percentage options.
**/
export declare class User {
export interface IUser {
/** The unique identifier of the user or session (e.g. email address, primary key, session ID, etc.) */

@@ -49,46 +47,24 @@ identifier: string;

};
constructor(
/** The unique identifier of the user or session (e.g. email address, primary key, session ID, etc.) */
identifier: string,
/** Email address of the user. */
email?: string,
/** Country of the user. */
country?: string,
/**
* Custom attributes of the user for advanced targeting rule definitions (e.g. user role, subscription type, etc.)
* @remarks
* All comparators support `string` values as User Object attribute (in some cases they need to be provided in a specific format though, see below),
* but some of them also support other types of values. It depends on the comparator how the values will be handled. The following rules apply:
*
* **Text-based comparators** (EQUALS, IS ONE OF, etc.)
* * accept `string` values,
* * all other values are automatically converted to `string` (a warning will be logged but evaluation will continue as normal).
*
* **SemVer-based comparators** (IS ONE OF, &lt;, &gt;=, etc.)
* * accept `string` values containing a properly formatted, valid semver value,
* * all other values are considered invalid (a warning will be logged and the currently evaluated targeting rule will be skipped).
*
* **Number-based comparators** (=, &lt;, &gt;=, etc.)
* * accept `number` values,
* * accept `string` values containing a properly formatted, valid `number` value,
* * all other values are considered invalid (a warning will be logged and the currently evaluated targeting rule will be skipped).
*
* **Date time-based comparators** (BEFORE / AFTER)
* * accept `Date` values, which are automatically converted to a second-based Unix timestamp,
* * accept `number` values representing a second-based Unix timestamp,
* * accept `string` values containing a properly formatted, valid `number` value,
* * all other values are considered invalid (a warning will be logged and the currently evaluated targeting rule will be skipped).
*
* **String array-based comparators** (ARRAY CONTAINS ANY OF / ARRAY NOT CONTAINS ANY OF)
* * accept arrays of `string`,
* * accept `string` values containing a valid JSON string which can be deserialized to an array of `string`,
* * all other values are considered invalid (a warning will be logged and the currently evaluated targeting rule will be skipped).
**/
custom?: {
}
/**
* User Object.
* Contains user attributes which are used for evaluating targeting rules and percentage options.
* @remarks
* Please note that the `User` class is not designed to be used as a DTO (data transfer object).
* (Since the type of the `custom` property is polymorphic, it's not guaranteed that deserializing a serialized instance produces an instance with an identical or even valid data content.)
**/
export declare class User implements IUser {
identifier: string;
email?: string | undefined;
country?: string | undefined;
custom: {
[key: string]: UserAttributeValue;
};
constructor(identifier: string, email?: string | undefined, country?: string | undefined, custom?: {
[key: string]: UserAttributeValue;
});
}
export declare function getUserAttribute(user: User, name: string): UserAttributeValue | null | undefined;
export declare function getUserAttributes(user: User): {
export declare function getUserAttribute(user: IUser, name: string): UserAttributeValue | null | undefined;
export declare function getUserAttributes(user: IUser): {
[key: string]: UserAttributeValue;
};

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

export default "0.0.1";
export default "0.1.0";
//# sourceMappingURL=Version.js.map
{
"name": "@configcat/sdk",
"version": "0.0.1",
"version": "0.1.0",
"description": "ConfigCat is a configuration as a service that lets you manage your features and configurations without actually deploying new code.",

@@ -11,3 +11,5 @@ "main": "lib/cjs/node/index.root.js",

"types": {
"bun": "./lib/esm/bun/index.d.ts",
"deno": "./lib/esm/deno/index.d.ts",
"workerd": "./lib/esm/cloudflare-worker/index.d.ts",
"browser": "./lib/esm/browser/index.root.d.ts",

@@ -17,3 +19,5 @@ "import": "./lib/esm/node/index.root.d.ts",

},
"bun": "./lib/esm/bun/index.js",
"deno": "./lib/esm/deno/index.js",
"workerd": "./lib/esm/cloudflare-worker/index.js",
"browser": "./lib/esm/browser/index.root.js",

@@ -27,2 +31,6 @@ "import": "./lib/esm/node/index.root.js",

},
"./bun": {
"types": "./lib/esm/bun/index.d.ts",
"import": "./lib/esm/bun/index.js"
},
"./chromium-extension": {

@@ -32,2 +40,6 @@ "types": "./lib/esm/chromium-extension/index.d.ts",

},
"./cloudflare-worker": {
"types": "./lib/esm/cloudflare-worker/index.d.ts",
"import": "./lib/esm/cloudflare-worker/index.js"
},
"./deno": {

@@ -52,5 +64,11 @@ "types": "./lib/esm/deno/index.d.ts",

},
"#lib/bun": {
"browser": "./lib/esm/bun/index.js"
},
"#lib/chromium-extension": {
"browser": "./lib/esm/chromium-extension/index.js"
},
"#lib/cloudflare-worker": {
"browser": "./lib/esm/cloudflare-worker/index.js"
},
"#lib/node": {

@@ -82,7 +100,9 @@ "require": "./lib/cjs/node/index.js"

"test:browser:firefox": "karma start karma.browser.firefox.conf.js",
"test:bun": "bun run --tsconfig-override ./tsconfig.mocha.bun.json ./node_modules/mocha/bin/mocha.js test/bun/index.ts --timeout 30000",
"test:chromium-extension:chrome": "karma start karma.chromium-extension.chrome.conf.js",
"test:chromium-extension:chromium": "karma start karma.chromium-extension.chromium.conf.js",
"test:cloudflare-worker": "webpack -c webpack.workerd.cloudflare-worker.config.js && concurrently --raw --success command-1 --kill-others \"node test/cloudflare-worker/test-run-helper/server.mjs\" \"workerd test workerd.config.capnp\"",
"test:deno": "node deno.import-map.generator.js && node deno.set-env.js deno run $DENO_NODE_MODULES_DIR -A test/deno/index.ts --timeout 30000",
"test:node": "cross-env NODE_EXTRA_CA_CERTS=./test/node/cert/testCA.pem TS_NODE_PROJECT=./tsconfig.mocha.node.json node --expose-gc --require ts-node/register node_modules/mocha/bin/_mocha 'test/node/index.ts' --exit --timeout 30000",
"test": "npm run check:ts-compat && npm run test:node && npm run test:browser:chrome && npm run test:chromium-extension:chrome && npm run test:deno"
"test": "npm run check:ts-compat && npm run test:browser:chrome && npm run test:chromium-extension:chrome && npm run test:cloudflare-worker && npm run test:bun && npm run test:deno && npm run test:node"
},

@@ -110,4 +130,7 @@ "keywords": [

"@babel/preset-env": "^7.20.2",
"@cloudflare/workers-types": "^4.20241106.0",
"@types/bun": "^1.1.13",
"@types/chai": "~4.3.4",
"@types/chrome": "~0.0.270",
"@types/deno": "^2.0.0",
"@types/mocha": "~10.0.1",

@@ -120,2 +143,3 @@ "@types/node": "~18.19.7",

"chai": "^4.3.7",
"concurrently": "^9.1.0",
"core-js": "^3.38.1",

@@ -151,3 +175,4 @@ "coverage-istanbul-loader": "^3.0.5",

"webpack": "^5.94.0",
"webpack-cli": "^5.1.4"
"webpack-cli": "^5.1.4",
"workerd": "^1.20241112.0"
},

@@ -154,0 +179,0 @@ "overrides": {

# ConfigCat SDK for JavaScript
[![JS SDK CI](https://github.com/configcat/js-unified-sdk/actions/workflows/js-ci.yml/badge.svg?branch=master)](https://github.com/configcat/js-unified-sdk/actions/workflows/js-ci.yml)
[![JS SDK CI](https://github.com/configcat/js-unified-sdk/actions/workflows/js-sdk-ci.yml/badge.svg?branch=master)](https://github.com/configcat/js-unified-sdk/actions/workflows/js-sdk-ci.yml)
[![Quality Gate Status](https://img.shields.io/sonar/quality_gate/configcat_js-unified-sdk?logo=SonarCloud&server=https%3A%2F%2Fsonarcloud.io)](https://sonarcloud.io/project/overview?id=configcat_js-unified-sdk)

@@ -14,2 +14,18 @@ [![SonarCloud Coverage](https://img.shields.io/sonar/coverage/configcat_js-unified-sdk?logo=SonarCloud&server=https%3A%2F%2Fsonarcloud.io)](https://sonarcloud.io/project/overview?id=configcat_js-unified-sdk)

This repository hosts the next generation of the ConfigCat SDK for JavaScript platforms. It ships in the form of a single, unified NPM package for
different JS platforms, as opposed to the one package per platform model used before.
The new SDK combines and, thus, supersedes these packages:
* [configcat-common](https://www.npmjs.com/package/configcat-common)
* [configcat-js](https://www.npmjs.com/package/configcat-js)
* [configcat-js-ssr](https://www.npmjs.com/package/configcat-js-ssr)
* [configcat-js-chromium-extension](https://www.npmjs.com/package/configcat-js-chromium-extension)
* [configcat-node](https://www.npmjs.com/package/configcat-node)
The new SDK maintains backward compatibility, so it can be used as a drop-in replacement for the packages listed above. In most cases you just need to
replace the old package with the new and adjust the import specifiers (as shown [here](#1-install-and-import-package)).
> [!CAUTION]
> Please note that the SDK is still under development and is currently in beta phase. Use it at your own risk.
## Getting Started

@@ -29,3 +45,3 @@

* Frontend applications running in the browser:
* Frontend applications and Web Workers running in the browser:
```js

@@ -40,2 +56,7 @@ import * as configcat from "@configcat/sdk/browser";

* Bun backend applications:
```js
import * as configcat from "@configcat/sdk/bun";
```
* Deno backend applications:

@@ -48,2 +69,7 @@ ```js

* Cloudflare Workers:
```js
import * as configcat from "@configcat/sdk/cloudflare-worker";
```
* Extensions for Chromium-based browsers (Chrome, Edge, etc.):

@@ -60,3 +86,3 @@ ```js

* Frontend applications running in the browser:
* Frontend applications and Web Workers running in the browser:

@@ -75,8 +101,2 @@ ```html

* Deno backend applications:
```js
import * as configcat from "https://cdn.skypack.dev/@configcat/sdk@1.0.0?dts";
```
* Extensions for Chromium-based browsers (Chrome, Edge, etc.):

@@ -89,3 +109,3 @@

### 2. Go to the <a href="https://app.configcat.com/sdkkey" target="_blank">ConfigCat Dashboard</a> to get your *SDK Key*:
![SDK-KEY](https://raw.githubusercontent.com/ConfigCat/js-sdk/master/media/readme02-3.png "SDK-KEY")
![SDK-KEY](https://raw.githubusercontent.com/configcat/js-unified-sdk/master/media/readme02-3.png "SDK-KEY")

@@ -147,2 +167,3 @@ ### 3. Create a *ConfigCat* client instance:

- [Plain HTML + JS using ECMAScript module system](https://github.com/configcat/js-unified-sdk/tree/master/samples/html-esm)
- [Plain HTML + TS running the SDK in a Web Worker](https://github.com/configcat/js-unified-sdk/tree/master/samples/web-worker)
- [Sample Angular web application](https://github.com/configcat/js-unified-sdk/tree/master/samples/angular-sample)

@@ -158,3 +179,5 @@ - [Sample React web application](https://github.com/configcat/js-unified-sdk/tree/master/samples/react-sample)

- [Sample Node.js application on how to get real time updates on feature flag changes](https://github.com/configcat/js-unified-sdk/tree/master/samples/node-realtimeupdate)
- [Sample Bun console application](https://github.com/configcat/js-unified-sdk/tree/master/samples/bun-console)
- [Sample Deno console application](https://github.com/configcat/js-unified-sdk/tree/master/samples/deno-console)
- [Sample Cloudflare Worker](https://github.com/configcat/js-unified-sdk/tree/master/samples/cloudflare-worker)
- [Sample Chrome extension](https://github.com/configcat/js-unified-sdk/tree/master/samples/chrome-extension)

@@ -205,3 +228,3 @@

The SDK is [tested](https://github.com/configcat/js-unified-sdk/blob/master/.github/workflows/js-ci.yml) against the following runtimes:
The SDK is [tested](https://github.com/configcat/js-unified-sdk/blob/master/.github/workflows/js-sdk-ci.yml) against the following runtimes:
- @configcat/sdk/browser:

@@ -211,5 +234,4 @@ - Chrome (stable, latest, beta)

- Firefox (latest, latest-beta, 84.0)
- @configcat/sdk/chromium-extension:
- Chrome (stable, latest, beta)
- Chromium (72.0.3626.0, 80.0.3987.0)
- @configcat/sdk/bun:
- Bun (v1.1.0, v1.1.34) on Windows
- @configcat/sdk/deno:

@@ -219,2 +241,7 @@ - Deno (v1.31, v1.46, latest stable) on Windows / Ubuntu / macOS

- Node.js (v14.x, v16.x, v18.x, v20.x, v22.x) on Windows / Ubuntu / macOS
- @configcat/sdk/cloudflare-worker:
- Workerd (2023-02-28)
- @configcat/sdk/chromium-extension:
- Chrome (stable, latest, beta)
- Chromium (72.0.3626.0, 80.0.3987.0)

@@ -225,3 +252,3 @@ The SDK should be compatible with TypeScript v4.0.2 or newer. Earlier versions may work but those are not tested, thus, not supported officially.

You can view a sample run [here](https://github.com/configcat/js-unified-sdk/actions/runs/TODO).
You can view a sample run [here](https://github.com/configcat/js-unified-sdk/actions/runs/11745259578).

@@ -228,0 +255,0 @@ > We strive to provide an extensive support for the various JS runtimes and build tools. If you still encounter an issue with the SDK on some platform, please open a [GitHub issue](https://github.com/configcat/js-unified-sdk/issues/new/choose) or [contact support](https://configcat.com/support).

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

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

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

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

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

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

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