Socket
Socket
Sign inDemoInstall

configcat-js-ssr

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

configcat-js-ssr - npm Package Compare versions

Comparing version 1.0.2 to 2.0.0

6

lib/Cache.d.ts

@@ -5,7 +5,7 @@ import { ICache } from "configcat-common";

cache: {
[apiKey: string]: ProjectConfig;
[sdkKey: string]: ProjectConfig;
};
Set(apiKey: string, config: ProjectConfig): void;
Get(apiKey: string): ProjectConfig;
Set(sdkKey: string, config: ProjectConfig): void;
Get(sdkKey: string): ProjectConfig;
private getLocalStorageKey;
}

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

}
LocalStorageCache.prototype.Set = function (apiKey, config) {
this.cache[apiKey] = config;
LocalStorageCache.prototype.Set = function (sdkKey, config) {
this.cache[sdkKey] = config;
try {
localStorage.setItem(this.getLocalStorageKey(apiKey), btoa(JSON.stringify(config)));
localStorage.setItem(this.getLocalStorageKey(sdkKey), btoa(JSON.stringify(config)));
}

@@ -17,4 +17,4 @@ catch (ex) {

};
LocalStorageCache.prototype.Get = function (apiKey) {
var config = this.cache[apiKey];
LocalStorageCache.prototype.Get = function (sdkKey) {
var config = this.cache[sdkKey];
if (config) {

@@ -24,7 +24,7 @@ return config;

try {
var configString = localStorage.getItem(this.getLocalStorageKey(apiKey));
var configString = localStorage.getItem(this.getLocalStorageKey(sdkKey));
if (configString) {
var config_1 = JSON.parse(atob(configString));
if (config_1) {
this.cache[apiKey] = config_1;
this.cache[sdkKey] = config_1;
return config_1;

@@ -39,4 +39,4 @@ }

};
LocalStorageCache.prototype.getLocalStorageKey = function (apiKey) {
return "ConfigCat_v4" + apiKey;
LocalStorageCache.prototype.getLocalStorageKey = function (sdkKey) {
return "ConfigCat_v4" + sdkKey;
};

@@ -43,0 +43,0 @@ return LocalStorageCache;

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

options.logger.error("Failed to download feature flags & settings from ConfigCat. " + response.status + " - " + response.statusText);
options.logger.info("Double-check your API KEY on https://app.configcat.com/apikey");
options.logger.info("Double-check your SDK Key on https://app.configcat.com/sdkkey");
callback(lastProjectConfig);

@@ -40,3 +40,3 @@ }

options.logger.error("Failed to download feature flags & settings from ConfigCat. " + error.response.status + " - " + error.response.statusText);
options.logger.info("Double-check your API KEY on https://app.configcat.com/apikey");
options.logger.info("Double-check your SDK Key on https://app.configcat.com/sdkkey");
callback(lastProjectConfig);

@@ -43,0 +43,0 @@ }

@@ -5,21 +5,21 @@ import * as configcatcommon from "configcat-common";

/** Create an instance of ConfigCatClient and setup Auto polling with default options.*/
export declare function createClient(apiKey: string): IConfigCatClient;
export declare function createClient(sdkKey: string): IConfigCatClient;
/**
* Create an instance of ConfigCatClient and setup Auto polling.
* @param {string} apiKey - ApiKey to access your configuration.
* @param {string} sdkKey - SDK Key to access your configuration.
* @param options - Options for Auto polling
*/
export declare function createClientWithAutoPoll(apiKey: string, options?: IJSAutoPollOptions): IConfigCatClient;
export declare function createClientWithAutoPoll(sdkKey: string, options?: IJSAutoPollOptions): IConfigCatClient;
/**
* Create an instance of ConfigCatClient and setup Manual polling.
* @param {string} apiKey - ApiKey to access your configuration.
* @param {string} sdkKey - SDK Key to access your configuration.
* @param options - Options for Manual polling
*/
export declare function createClientWithManualPoll(apiKey: string, options?: IJSManualPollOptions): IConfigCatClient;
export declare function createClientWithManualPoll(sdkKey: string, options?: IJSManualPollOptions): IConfigCatClient;
/**
* Create an instance of ConfigCatClient and setup Lazy loading.
* @param {string} apiKey - ApiKey to access your configuration.
* @param {string} sdkKey - SDK Key to access your configuration.
* @param options - Options for Lazy loading
*/
export declare function createClientWithLazyLoad(apiKey: string, options?: IJSLazyLoadingOptions): IConfigCatClient;
export declare function createClientWithLazyLoad(sdkKey: string, options?: IJSLazyLoadingOptions): IConfigCatClient;
export declare function createConsoleLogger(logLevel: LogLevel): configcatcommon.IConfigCatLogger;

@@ -26,0 +26,0 @@ export interface IJSAutoPollOptions extends configcatcommon.IAutoPollOptions {

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

/** Create an instance of ConfigCatClient and setup Auto polling with default options.*/
function createClient(apiKey) {
return this.createClientWithAutoPoll(apiKey);
function createClient(sdkKey) {
return this.createClientWithAutoPoll(sdkKey);
}

@@ -14,7 +14,7 @@ exports.createClient = createClient;

* Create an instance of ConfigCatClient and setup Auto polling.
* @param {string} apiKey - ApiKey to access your configuration.
* @param {string} sdkKey - SDK Key to access your configuration.
* @param options - Options for Auto polling
*/
function createClientWithAutoPoll(apiKey, options) {
return configcatcommon.createClientWithAutoPoll(apiKey, { configFetcher: new ConfigFetcher_1.HttpConfigFetcher(), cache: new Cache_1.LocalStorageCache() }, options);
function createClientWithAutoPoll(sdkKey, options) {
return configcatcommon.createClientWithAutoPoll(sdkKey, { configFetcher: new ConfigFetcher_1.HttpConfigFetcher(), cache: new Cache_1.LocalStorageCache() }, options);
}

@@ -24,7 +24,7 @@ exports.createClientWithAutoPoll = createClientWithAutoPoll;

* Create an instance of ConfigCatClient and setup Manual polling.
* @param {string} apiKey - ApiKey to access your configuration.
* @param {string} sdkKey - SDK Key to access your configuration.
* @param options - Options for Manual polling
*/
function createClientWithManualPoll(apiKey, options) {
return configcatcommon.createClientWithManualPoll(apiKey, { configFetcher: new ConfigFetcher_1.HttpConfigFetcher(), cache: new Cache_1.LocalStorageCache() }, options);
function createClientWithManualPoll(sdkKey, options) {
return configcatcommon.createClientWithManualPoll(sdkKey, { configFetcher: new ConfigFetcher_1.HttpConfigFetcher(), cache: new Cache_1.LocalStorageCache() }, options);
}

@@ -34,7 +34,7 @@ exports.createClientWithManualPoll = createClientWithManualPoll;

* Create an instance of ConfigCatClient and setup Lazy loading.
* @param {string} apiKey - ApiKey to access your configuration.
* @param {string} sdkKey - SDK Key to access your configuration.
* @param options - Options for Lazy loading
*/
function createClientWithLazyLoad(apiKey, options) {
return configcatcommon.createClientWithLazyLoad(apiKey, { configFetcher: new ConfigFetcher_1.HttpConfigFetcher(), cache: new Cache_1.LocalStorageCache() }, options);
function createClientWithLazyLoad(sdkKey, options) {
return configcatcommon.createClientWithLazyLoad(sdkKey, { configFetcher: new ConfigFetcher_1.HttpConfigFetcher(), cache: new Cache_1.LocalStorageCache() }, options);
}

@@ -41,0 +41,0 @@ exports.createClientWithLazyLoad = createClientWithLazyLoad;

{
"name": "configcat-js-ssr",
"version": "1.0.2",
"version": "2.0.0",
"description": "ConfigCat Feature Flags for Server Side Rendered apps like NuxtJS. Official ConfigCat SDK for Server Side Rendered to easily access feature flags.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -19,5 +19,2 @@ # ConfigCat SDK for JavaScript Server Side Rendered applications

> For SSR (Server-Side Rendering) Universal applications use [configcat-node](https://github.com/configcat/node-sdk) SDK.
### 1. Install and import package:

@@ -33,13 +30,8 @@

*via CDN:*
```html
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/configcat-js-ssr@latest/dist/configcat.min.js"></script>
```
### 2. Go to the <a href="https://app.configcat.com/sdkkey" target="_blank">Dashboard</a> to get your *API Key*:
![API-KEY](https://raw.githubusercontent.com/ConfigCat/js-ssr-sdk/master/media/readme01.png "API-KEY")
### 2. Go to the <a href="https://app.configcat.com/apikey" target="_blank">Dashboard</a> to get your *API Key*:
![API-KEY](https://raw.githubusercontent.com/ConfigCat/js-sdk/master/media/readme01.png "API-KEY")
### 3. Create a *ConfigCat* client instance:
```js
var configCatClient = configcat.createClient("#YOUR-API-KEY#");
var configCatClient = configcat.createClient("#YOUR-SDK-KEY#");
```

@@ -74,3 +66,3 @@ > We strongly recommend using the *ConfigCat Client* as a Singleton object in your application.

Read more about [Targeting here](https://docs.configcat.com/docs/advanced/targeting/).
Read more about [Targeting here](https://configcat.com/docs/advanced/targeting/).
```js

@@ -89,8 +81,6 @@ const userObject = { identifier : "#USER-IDENTIFIER#" };

## Sample/Demo apps
- [Angular 2+](https://github.com/configcat/js-sdk/tree/master/samples/angular-sample)
- [React](https://github.com/configcat/js-sdk/tree/master/samples/react-sample)
- [Pure HTML + JS](https://github.com/configcat/js-sdk/tree/master/samples/html)
- [NuxtJS](https://github.com/configcat/js-ssr-sdk/tree/master/samples/nuxt-ssr)
## Polling Modes
The ConfigCat SDK supports 3 different polling mechanisms to acquire the setting values from ConfigCat. After latest setting values are downloaded, they are stored in the internal cache then all requests are served from there. Read more about Polling Modes and how to use them at [ConfigCat Docs](https://docs.configcat.com/docs/sdk-reference/js/).
The ConfigCat SDK supports 3 different polling mechanisms to acquire the setting values from ConfigCat. After latest setting values are downloaded, they are stored in the internal cache then all requests are served from there. Read more about Polling Modes and how to use them at [ConfigCat Docs](https://configcat.com/docs/sdk-reference/js-ssr).

@@ -105,3 +95,3 @@ ## Support

- [Official ConfigCat SDK's for other platforms](https://github.com/configcat)
- [Documentation](https://docs.configcat.com)
- [Documentation](https://configcat.com/docs)
- [Blog](https://blog.configcat.com)

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