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

unleash-proxy-client

Package Overview
Dependencies
Maintainers
1
Versions
94
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unleash-proxy-client - npm Package Compare versions

Comparing version 0.0.9 to 0.0.10

25

build/index.js

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

this.toggles = [];
this.etag = '';
this.storage = config.storageProvider || new storage_provider_local_1.default();

@@ -84,3 +85,3 @@ this.refreshInterval = (config.refreshInterval || 30) * 1000;

_a.sent();
this.ref = setInterval(function () { return _this.fetchToggles(); }, interval);
this.timerRef = setInterval(function () { return _this.fetchToggles(); }, interval);
return [3 /*break*/, 3];

@@ -97,4 +98,4 @@ case 2:

UnleashClient.prototype.stop = function () {
if (this.ref) {
clearInterval(this.ref);
if (this.timerRef) {
clearInterval(this.timerRef);
}

@@ -112,8 +113,8 @@ };

case 0:
if (!fetch) return [3 /*break*/, 5];
if (!fetch) return [3 /*break*/, 6];
_a.label = 1;
case 1:
_a.trys.push([1, 4, , 5]);
_a.trys.push([1, 5, , 6]);
context_1 = this.context;
urlWithQuery_1 = this.url;
urlWithQuery_1 = Object.assign('', this.url);
Object.keys(context_1).forEach(function (key) { return urlWithQuery_1.searchParams.append(key, context_1[key]); });

@@ -126,2 +127,3 @@ return [4 /*yield*/, fetch(urlWithQuery_1.toString(), {

'Content-Type': 'application/json',
'If-None-Match': this.etag,
},

@@ -131,2 +133,4 @@ })];

response = _a.sent();
if (!(response.ok && response.status !== 304)) return [3 /*break*/, 4];
this.etag = response.headers.get('ETag') || '';
return [4 /*yield*/, response.json()];

@@ -136,9 +140,10 @@ case 3:

this.storeToggles(data.toggles);
return [3 /*break*/, 5];
case 4:
_a.label = 4;
case 4: return [3 /*break*/, 6];
case 5:
e_1 = _a.sent();
// tslint:disable-next-line
console.error('Unleash: unable to fetch feature toggles', e_1);
return [3 /*break*/, 5];
case 5: return [2 /*return*/];
return [3 /*break*/, 6];
case 6: return [2 /*return*/];
}

@@ -145,0 +150,0 @@ });

2

build/main.min.js

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

var unleash=function(a){'use strict';function b(a,b,c,d){return new(c||(c=Promise))(function(e,f){function g(a){try{i(d.next(a))}catch(a){f(a)}}function h(a){try{i(d["throw"](a))}catch(a){f(a)}}function i(a){a.done?e(a.value):new c(function(b){b(a.value)}).then(g,h)}i((d=d.apply(a,b||[])).next())})}function c(a,b){function c(a){return function(b){return d([a,b])}}function d(c){if(e)throw new TypeError("Generator is already executing.");for(;k;)try{if(e=1,h&&(i=2&c[0]?h["return"]:c[0]?h["throw"]||((i=h["return"])&&i.call(h),0):h.next)&&!(i=i.call(h,c[1])).done)return i;switch((h=0,i)&&(c=[2&c[0],i.value]),c[0]){case 0:case 1:i=c;break;case 4:return k.label++,{value:c[1],done:!1};case 5:k.label++,h=c[1],c=[0];continue;case 7:c=k.ops.pop(),k.trys.pop();continue;default:if((i=k.trys,!(i=0<i.length&&i[i.length-1]))&&(6===c[0]||2===c[0])){k=0;continue}if(3===c[0]&&(!i||c[1]>i[0]&&c[1]<i[3])){k.label=c[1];break}if(6===c[0]&&k.label<i[1]){k.label=i[1],i=c;break}if(i&&k.label<i[2]){k.label=i[2],k.ops.push(c);break}i[2]&&k.ops.pop(),k.trys.pop();continue;}c=b.call(a,k)}catch(a){c=[6,a],h=0}finally{e=i=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}var e,h,i,j,k={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return j={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(j[Symbol.iterator]=function(){return this}),j}var d=function(){function a(){this.prefix="unleash:repository"}return a.prototype.save=function(a,b){try{var c=JSON.stringify(b),d=this.prefix+":"+a;window.localStorage.setItem(d,c)}catch(a){console.error(a)}},a.prototype.get=function(a){try{var b=this.prefix+":"+a,c=window.localStorage.getItem(b);return c?JSON.parse(c):void 0}catch(a){console.error(a)}},a}(),e={name:"disabled"},f="repo",g=function(){function a(a,b){if(this.toggles=[],this.storage=a.storageProvider||new d,this.refreshInterval=1e3*(a.refreshInterval||30),!a.url)throw new Error("You have to specify the url!");if(!a.clientKey)throw new Error("You have to specify the clientKey!");this.url=new URL(a.url+"/proxy"),this.clientKey=a.clientKey,this.context=b||{},this.toggles=this.storage.get(f)||[]}return a.prototype.isEnabled=function(a){var b=this.toggles.find(function(b){return b.name===a});return!!b&&b.enabled},a.prototype.getVariant=function(a){var b=this.toggles.find(function(b){return b.name===a});return b?b.variant:e},a.prototype.updateContext=function(a){this.context=a},a.prototype.start=function(){return b(this,void 0,void 0,function(){var a,b=this;return c(this,function(c){switch(c.label){case 0:return fetch?(this.stop(),a=this.refreshInterval,[4,this.fetchToggles()]):[3,2];case 1:return c.sent(),this.ref=setInterval(function(){return b.fetchToggles()},a),[3,3];case 2:console.error("Unleash: Client does not support fetch."),c.label=3;case 3:return[2];}})})},a.prototype.stop=function(){this.ref&&clearInterval(this.ref)},a.prototype.storeToggles=function(a){this.toggles=a,this.storage.save(f,a)},a.prototype.fetchToggles=function(){return b(this,void 0,void 0,function(){var a,b,d,e,f;return c(this,function(c){switch(c.label){case 0:if(!fetch)return[3,5];c.label=1;case 1:return c.trys.push([1,4,,5]),a=this.context,b=this.url,Object.keys(a).forEach(function(c){return b.searchParams.append(c,a[c])}),[4,fetch(b.toString(),{cache:"no-cache",headers:{Authorization:this.clientKey,Accept:"application/json","Content-Type":"application/json"}})];case 2:return d=c.sent(),[4,d.json()];case 3:return e=c.sent(),this.storeToggles(e.toggles),[3,5];case 4:return f=c.sent(),console.error("Unleash: unable to fetch feature toggles",f),[3,5];case 5:return[2];}})})},a}();return a.UnleashClient=g,a}({});
var unleash=function(a){'use strict';function b(a,b,c,d){return new(c||(c=Promise))(function(e,f){function g(a){try{i(d.next(a))}catch(a){f(a)}}function h(a){try{i(d["throw"](a))}catch(a){f(a)}}function i(a){a.done?e(a.value):new c(function(b){b(a.value)}).then(g,h)}i((d=d.apply(a,b||[])).next())})}function c(a,b){function c(a){return function(b){return d([a,b])}}function d(c){if(e)throw new TypeError("Generator is already executing.");for(;k;)try{if(e=1,h&&(i=2&c[0]?h["return"]:c[0]?h["throw"]||((i=h["return"])&&i.call(h),0):h.next)&&!(i=i.call(h,c[1])).done)return i;switch((h=0,i)&&(c=[2&c[0],i.value]),c[0]){case 0:case 1:i=c;break;case 4:return k.label++,{value:c[1],done:!1};case 5:k.label++,h=c[1],c=[0];continue;case 7:c=k.ops.pop(),k.trys.pop();continue;default:if((i=k.trys,!(i=0<i.length&&i[i.length-1]))&&(6===c[0]||2===c[0])){k=0;continue}if(3===c[0]&&(!i||c[1]>i[0]&&c[1]<i[3])){k.label=c[1];break}if(6===c[0]&&k.label<i[1]){k.label=i[1],i=c;break}if(i&&k.label<i[2]){k.label=i[2],k.ops.push(c);break}i[2]&&k.ops.pop(),k.trys.pop();continue;}c=b.call(a,k)}catch(a){c=[6,a],h=0}finally{e=i=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}var e,h,i,j,k={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return j={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(j[Symbol.iterator]=function(){return this}),j}var d=function(){function a(){this.prefix="unleash:repository"}return a.prototype.save=function(a,b){try{var c=JSON.stringify(b),d=this.prefix+":"+a;window.localStorage.setItem(d,c)}catch(a){console.error(a)}},a.prototype.get=function(a){try{var b=this.prefix+":"+a,c=window.localStorage.getItem(b);return c?JSON.parse(c):void 0}catch(a){console.error(a)}},a}(),e={name:"disabled"},f="repo",g=function(){function a(a,b){if(this.toggles=[],this.etag="",this.storage=a.storageProvider||new d,this.refreshInterval=1e3*(a.refreshInterval||30),!a.url)throw new Error("You have to specify the url!");if(!a.clientKey)throw new Error("You have to specify the clientKey!");this.url=new URL(a.url+"/proxy"),this.clientKey=a.clientKey,this.context=b||{},this.toggles=this.storage.get(f)||[]}return a.prototype.isEnabled=function(a){var b=this.toggles.find(function(b){return b.name===a});return!!b&&b.enabled},a.prototype.getVariant=function(a){var b=this.toggles.find(function(b){return b.name===a});return b?b.variant:e},a.prototype.updateContext=function(a){this.context=a},a.prototype.start=function(){return b(this,void 0,void 0,function(){var a,b=this;return c(this,function(c){switch(c.label){case 0:return fetch?(this.stop(),a=this.refreshInterval,[4,this.fetchToggles()]):[3,2];case 1:return c.sent(),this.timerRef=setInterval(function(){return b.fetchToggles()},a),[3,3];case 2:console.error("Unleash: Client does not support fetch."),c.label=3;case 3:return[2];}})})},a.prototype.stop=function(){this.timerRef&&clearInterval(this.timerRef)},a.prototype.storeToggles=function(a){this.toggles=a,this.storage.save(f,a)},a.prototype.fetchToggles=function(){return b(this,void 0,void 0,function(){var a,b,d,e,f;return c(this,function(c){switch(c.label){case 0:if(!fetch)return[3,6];c.label=1;case 1:return c.trys.push([1,5,,6]),a=this.context,b=Object.assign("",this.url),Object.keys(a).forEach(function(c){return b.searchParams.append(c,a[c])}),[4,fetch(b.toString(),{cache:"no-cache",headers:{Authorization:this.clientKey,Accept:"application/json","Content-Type":"application/json","If-None-Match":this.etag}})];case 2:return(d=c.sent(),!(d.ok&&304!==d.status))?[3,4]:(this.etag=d.headers.get("ETag")||"",[4,d.json()]);case 3:e=c.sent(),this.storeToggles(e.toggles),c.label=4;case 4:return[3,6];case 5:return f=c.sent(),console.error("Unleash: unable to fetch feature toggles",f),[3,6];case 6:return[2];}})})},a}();return a.UnleashClient=g,a}({});

@@ -9,3 +9,3 @@ {

"react-scripts": "3.1.1",
"unleash-proxy-client": "^0.0.8"
"unleash-proxy-client": "^0.0.9"
},

@@ -12,0 +12,0 @@ "scripts": {

{
"name": "unleash-proxy-client",
"version": "0.0.9",
"version": "0.0.10",
"description": "A browser client that can be used together with the unleash-proxy.",

@@ -12,2 +12,3 @@ "main": "./build/index.js",

"scripts": {
"preversion": "npm run build",
"build": "npm run build:ts && npm run build:web",

@@ -14,0 +15,0 @@ "build:ts": "tsc",

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