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

configcat-js-chromium-extension

Package Overview
Dependencies
Maintainers
4
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

configcat-js-chromium-extension - npm Package Compare versions

Comparing version 2.1.0 to 2.2.0

10

lib/Cache.d.ts

@@ -1,8 +0,12 @@

import type { IConfigCatCache } from "configcat-common";
/// <reference types="chrome" />
import type { IConfigCatCache, IConfigCatKernel } from "configcat-common";
export declare class LocalStorageCache implements IConfigCatCache {
private readonly storage;
static setup(kernel: IConfigCatKernel, localStorageGetter?: () => chrome.storage.LocalStorageArea | null): IConfigCatKernel;
constructor(storage: chrome.storage.LocalStorageArea);
set(key: string, value: string): Promise<void>;
get(key: string): Promise<string | undefined>;
private b64EncodeUnicode;
private b64DecodeUnicode;
}
export declare function toUtf8Base64(str: string): string;
export declare function fromUtf8Base64(str: string): string;
//# sourceMappingURL=Cache.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LocalStorageCache = void 0;
exports.fromUtf8Base64 = exports.toUtf8Base64 = exports.LocalStorageCache = void 0;
var tslib_1 = require("tslib");
var configcat_common_1 = require("configcat-common");
var LocalStorageCache = /** @class */ (function () {
function LocalStorageCache() {
function LocalStorageCache(storage) {
this.storage = storage;
}
LocalStorageCache.setup = function (kernel, localStorageGetter) {
var _a, _b, _c;
var localStorage = (_a = localStorageGetter === null || localStorageGetter === void 0 ? void 0 : localStorageGetter()) !== null && _a !== void 0 ? _a : (_c = (_b = window.chrome) === null || _b === void 0 ? void 0 : _b.storage) === null || _c === void 0 ? void 0 : _c.local;
if (localStorage) {
kernel.defaultCacheFactory = function (options) { return new configcat_common_1.ExternalConfigCache(new LocalStorageCache(localStorage), options.logger); };
}
return kernel;
};
LocalStorageCache.prototype.set = function (key, value) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var ex_1;
var _a;
return tslib_1.__generator(this, function (_b) {
switch (_b.label) {
case 0:
_b.trys.push([0, 2, , 3]);
return [4 /*yield*/, chrome.storage.local.set((_a = {}, _a[key] = this.b64EncodeUnicode(value), _a))];
case 0: return [4 /*yield*/, this.storage.set((_a = {}, _a[key] = toUtf8Base64(value), _a))];
case 1:
_b.sent();
return [3 /*break*/, 3];
case 2:
ex_1 = _b.sent();
return [3 /*break*/, 3];
case 3: return [2 /*return*/];
return [2 /*return*/];
}

@@ -30,8 +33,6 @@ });

return tslib_1.__awaiter(this, void 0, void 0, function () {
var cacheObj, configString, ex_2;
var cacheObj, configString;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, chrome.storage.local.get(key)];
case 0: return [4 /*yield*/, this.storage.get(key)];
case 1:

@@ -41,9 +42,5 @@ cacheObj = _a.sent();

if (configString) {
return [2 /*return*/, this.b64DecodeUnicode(configString)];
return [2 /*return*/, fromUtf8Base64(configString)];
}
return [3 /*break*/, 3];
case 2:
ex_2 = _a.sent();
return [3 /*break*/, 3];
case 3: return [2 /*return*/];
return [2 /*return*/];
}

@@ -53,14 +50,16 @@ });

};
LocalStorageCache.prototype.b64EncodeUnicode = function (str) {
return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function (_, p1) {
return String.fromCharCode(parseInt(p1, 16));
}));
};
LocalStorageCache.prototype.b64DecodeUnicode = function (str) {
return decodeURIComponent(Array.prototype.map.call(atob(str), function (c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
}).join(''));
};
return LocalStorageCache;
}());
exports.LocalStorageCache = LocalStorageCache;
function toUtf8Base64(str) {
str = encodeURIComponent(str);
str = str.replace(/%([0-9A-F]{2})/g, function (_, p1) { return String.fromCharCode(parseInt(p1, 16)); });
return btoa(str);
}
exports.toUtf8Base64 = toUtf8Base64;
function fromUtf8Base64(str) {
str = atob(str);
str = str.replace(/[%\x80-\xFF]/g, function (m) { return "%" + m.charCodeAt(0).toString(16); });
return decodeURIComponent(str);
}
exports.fromUtf8Base64 = fromUtf8Base64;

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

return tslib_1.__awaiter(this, void 0, void 0, function () {
var requestInit, cleanup, controller_1, timeoutId_1, response, statusCode, reasonPhrase, body, eTag, err_1;
var requestInit, cleanup, controller_1, timeoutId_1, url, response, statusCode, reasonPhrase, body, eTag, err_1;
return tslib_1.__generator(this, function (_d) {

@@ -31,3 +31,8 @@ switch (_d.label) {

_d.trys.push([1, 6, 7, 8]);
return [4 /*yield*/, fetch(options.getUrl(), requestInit)];
url = options.getUrl();
if (lastEtag) {
// We are sending the etag as a query parameter so if the browser doesn't automatically adds the If-None-Match header, we can transform this query param to the header in our CDN provider.
url += "&ccetag=" + encodeURIComponent(lastEtag);
}
return [4 /*yield*/, fetch(url, requestInit)];
case 2:

@@ -34,0 +39,0 @@ response = _d.sent();

import { __awaiter, __generator } from "tslib";
import { ExternalConfigCache } from "configcat-common";
var LocalStorageCache = /** @class */ (function () {
function LocalStorageCache() {
function LocalStorageCache(storage) {
this.storage = storage;
}
LocalStorageCache.setup = function (kernel, localStorageGetter) {
var _a, _b, _c;
var localStorage = (_a = localStorageGetter === null || localStorageGetter === void 0 ? void 0 : localStorageGetter()) !== null && _a !== void 0 ? _a : (_c = (_b = window.chrome) === null || _b === void 0 ? void 0 : _b.storage) === null || _c === void 0 ? void 0 : _c.local;
if (localStorage) {
kernel.defaultCacheFactory = function (options) { return new ExternalConfigCache(new LocalStorageCache(localStorage), options.logger); };
}
return kernel;
};
LocalStorageCache.prototype.set = function (key, value) {
return __awaiter(this, void 0, void 0, function () {
var ex_1;
var _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_b.trys.push([0, 2, , 3]);
return [4 /*yield*/, chrome.storage.local.set((_a = {}, _a[key] = this.b64EncodeUnicode(value), _a))];
case 0: return [4 /*yield*/, this.storage.set((_a = {}, _a[key] = toUtf8Base64(value), _a))];
case 1:
_b.sent();
return [3 /*break*/, 3];
case 2:
ex_1 = _b.sent();
return [3 /*break*/, 3];
case 3: return [2 /*return*/];
return [2 /*return*/];
}

@@ -27,8 +30,6 @@ });

return __awaiter(this, void 0, void 0, function () {
var cacheObj, configString, ex_2;
var cacheObj, configString;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, chrome.storage.local.get(key)];
case 0: return [4 /*yield*/, this.storage.get(key)];
case 1:

@@ -38,9 +39,5 @@ cacheObj = _a.sent();

if (configString) {
return [2 /*return*/, this.b64DecodeUnicode(configString)];
return [2 /*return*/, fromUtf8Base64(configString)];
}
return [3 /*break*/, 3];
case 2:
ex_2 = _a.sent();
return [3 /*break*/, 3];
case 3: return [2 /*return*/];
return [2 /*return*/];
}

@@ -50,14 +47,14 @@ });

};
LocalStorageCache.prototype.b64EncodeUnicode = function (str) {
return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function (_, p1) {
return String.fromCharCode(parseInt(p1, 16));
}));
};
LocalStorageCache.prototype.b64DecodeUnicode = function (str) {
return decodeURIComponent(Array.prototype.map.call(atob(str), function (c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
}).join(''));
};
return LocalStorageCache;
}());
export { LocalStorageCache };
export function toUtf8Base64(str) {
str = encodeURIComponent(str);
str = str.replace(/%([0-9A-F]{2})/g, function (_, p1) { return String.fromCharCode(parseInt(p1, 16)); });
return btoa(str);
}
export function fromUtf8Base64(str) {
str = atob(str);
str = str.replace(/[%\x80-\xFF]/g, function (m) { return "%" + m.charCodeAt(0).toString(16); });
return decodeURIComponent(str);
}

@@ -9,3 +9,3 @@ import { __awaiter, __generator } from "tslib";

return __awaiter(this, void 0, void 0, function () {
var requestInit, cleanup, controller_1, timeoutId_1, response, statusCode, reasonPhrase, body, eTag, err_1;
var requestInit, cleanup, controller_1, timeoutId_1, url, response, statusCode, reasonPhrase, body, eTag, err_1;
return __generator(this, function (_d) {

@@ -28,3 +28,8 @@ switch (_d.label) {

_d.trys.push([1, 6, 7, 8]);
return [4 /*yield*/, fetch(options.getUrl(), requestInit)];
url = options.getUrl();
if (lastEtag) {
// We are sending the etag as a query parameter so if the browser doesn't automatically adds the If-None-Match header, we can transform this query param to the header in our CDN provider.
url += "&ccetag=" + encodeURIComponent(lastEtag);
}
return [4 /*yield*/, fetch(url, requestInit)];
case 2:

@@ -31,0 +36,0 @@ response = _d.sent();

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

import { ExternalConfigCache, FlagOverrides, MapOverrideDataSource, PollingMode } from "configcat-common";
import { FlagOverrides, MapOverrideDataSource, PollingMode } from "configcat-common";
import * as configcatcommon from "configcat-common";

@@ -17,8 +17,7 @@ import { LocalStorageCache } from "./Cache";

export function getClient(sdkKey, pollingMode, options) {
return configcatcommon.getClient(sdkKey, pollingMode !== null && pollingMode !== void 0 ? pollingMode : PollingMode.AutoPoll, options, {
return configcatcommon.getClient(sdkKey, pollingMode !== null && pollingMode !== void 0 ? pollingMode : PollingMode.AutoPoll, options, LocalStorageCache.setup({
configFetcher: new HttpConfigFetcher(),
sdkType: "ConfigCat-JS-Chromium",
sdkVersion: CONFIGCAT_SDK_VERSION,
defaultCacheFactory: function (options) { return new ExternalConfigCache(new LocalStorageCache(), options.logger); }
});
}));
}

@@ -25,0 +24,0 @@ /**

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

export default "2.1.0";
export default "2.2.0";

@@ -20,8 +20,7 @@ "use strict";

function getClient(sdkKey, pollingMode, options) {
return configcatcommon.getClient(sdkKey, pollingMode !== null && pollingMode !== void 0 ? pollingMode : configcat_common_1.PollingMode.AutoPoll, options, {
return configcatcommon.getClient(sdkKey, pollingMode !== null && pollingMode !== void 0 ? pollingMode : configcat_common_1.PollingMode.AutoPoll, options, Cache_1.LocalStorageCache.setup({
configFetcher: new ConfigFetcher_1.HttpConfigFetcher(),
sdkType: "ConfigCat-JS-Chromium",
sdkVersion: Version_1.default,
defaultCacheFactory: function (options) { return new configcat_common_1.ExternalConfigCache(new Cache_1.LocalStorageCache(), options.logger); }
});
}));
}

@@ -28,0 +27,0 @@ exports.getClient = getClient;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = "2.1.0";
exports.default = "2.2.0";
{
"name": "configcat-js-chromium-extension",
"version": "2.1.0",
"version": "2.2.0",
"description": "ConfigCat is a configuration as a service that lets you manage your features and configurations without actually deploying new code.",

@@ -36,3 +36,3 @@ "main": "lib/index.js",

"@types/chrome": "0.0.193",
"configcat-common": "^9.0.0",
"configcat-common": "^9.1.0",
"tslib": "^2.4.1"

@@ -39,0 +39,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 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